本文整理汇总了C++中dfhack::Context::getProcess方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::getProcess方法的具体用法?C++ Context::getProcess怎么用?C++ Context::getProcess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dfhack::Context
的用法示例。
在下文中一共展示了Context::getProcess方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ()
{
DFHack::Process * p;
unsigned int i;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::VersionInfo * mem = DF->getMemoryInfo();
p = DF->getProcess();
uint32_t item_vec_offset = 0;
try
{
item_vec_offset = p->getDescriptor()->getAddress ("items_vector");
}
catch(DFHack::Error::AllMemdef & e)
{
cerr << "missing offset for the item vector, exiting :(" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::DfVector <uint32_t> p_items (p, item_vec_offset);
uint32_t size = p_items.size();
int numtasked = 0;
for (i=0;i<size;i++)
{
DFHack::t_itemflags flags;
flags.whole = p->readDWord(p_items[i] + 0x0C);
if (flags.bits.in_job)
{
flags.bits.in_job = 0;
p->writeDWord(p_items[i] + 0x0C, flags.whole);
numtasked++;
}
}
cout << "Found and untasked " << numtasked << " items." << endl;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}
示例2: main
//.........这里部分代码省略.........
buildCommands["building_stonefall_trapst"]="Ts";
buildCommands["building_weapon_trapst"]="Tw";
buildCommands["building_spikest"]="";
buildCommands["building_animal_trapst"]="m";
buildCommands["building_screw_pumpst"]="Ms";
buildCommands["building_water_wheelst"]="Mw";
buildCommands["building_windmillst"]="Mm";
buildCommands["building_gear_assemblyst"]="Mg";
buildCommands["building_horizontal_axlest"]="Mh";
buildCommands["building_vertical_axlest"]="Mv";
buildCommands["building_supportst"]="S";
buildCommands["building_cagest"]="j";
buildCommands["building_archery_targetst"]="A";
buildCommands["building_restraintst"]="v";
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
try
{
DF->Attach();
}
catch (std::exception& e)
{
std::cerr << e.what() << std::endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Gui *Gui = DF->getGui();
DFHack::VersionInfo* mem = DF->getMemoryInfo();
DFHack::Process * p = DF->getProcess();
OffsetGroup * OG_Maps = mem->getGroup("Maps");
OffsetGroup * OG_MapBlock = OG_Maps->getGroup("block");
OffsetGroup * OG_LocalFt = OG_Maps->getGroup("features")->getGroup("local");
uint32_t designations = OG_MapBlock->getOffset("designation");
uint32_t block_feature1 = OG_MapBlock->getOffset("feature_local");
uint32_t block_feature2 = OG_MapBlock->getOffset("feature_global");
uint32_t region_x_offset = OG_Maps->getAddress("region_x");
uint32_t region_y_offset = OG_Maps->getAddress("region_y");
uint32_t region_z_offset = OG_Maps->getAddress("region_z");
uint32_t feature1_start_ptr = OG_LocalFt->getAddress("start_ptr");
int32_t regionX, regionY, regionZ;
// read position of the region inside DF world
p->readDWord (region_x_offset, (uint32_t &)regionX);
p->readDWord (region_y_offset, (uint32_t &)regionY);
p->readDWord (region_z_offset, (uint32_t &)regionZ);
while(1){
int32_t cx1,cy1,cz1;
cx1 = -30000;
while(cx1 == -30000)
{
DF->ForceResume();
cout << "Set cursor at first position, then press any key";
cin.ignore();
DF->Suspend();
Gui->getCursorCoords(cx1,cy1,cz1);
}
uint32_t tx1,ty1,tz1;
tx1 = cx1/16;
ty1 = cy1/16;
tz1 = cz1;
示例3: main
int main (void)
{
string select;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF = DFMgr.getSingleContext();
try
{
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Process * p = DF->getProcess();
vector <DFHack::t_memrange> selected_ranges;
getRanges(p,selected_ranges);
DFHack::memory_info *minfo = DF->getMemoryInfo();
DFHack::memory_info::OSType os = minfo->getOS();
string prompt =
"Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n"
" 4=string, 5=automated offset search, 6=vector by address in its array,\n"
" 7=pointer vector by address of an object, 8=vector>first object>string\n";
int mode;
do
{
getNumber(prompt,mode, 1, false);
} while (mode < 1 || mode > 8 );
switch (mode)
{
case 1:
DF->Detach();
FindIntegers(DFMgr, selected_ranges);
break;
case 2:
DF->Detach();
FindVectorByLength(DFMgr, selected_ranges);
break;
case 3:
DF->Detach();
FindVectorByObjectRawname(DFMgr, selected_ranges);
break;
case 4:
DF->Detach();
FindStrings(DFMgr, selected_ranges);
break;
case 5:
automatedLangtables(DF,selected_ranges);
break;
case 6:
DF->Detach();
FindVectorByBounds(DFMgr,selected_ranges);
break;
case 7:
DF->Detach();
FindPtrVectorsByObjectAddress(DFMgr,selected_ranges);
break;
case 8:
DF->Detach();
FindVectorByFirstObjectRawname(DFMgr, selected_ranges);
break;
default:
cout << "not implemented :(" << endl;
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}
示例4: DFMgr
main(int argc, char *argv[])
{
/* initialize your non-curses data structures here */
signal(SIGINT, finish); /* arrange interrupts to terminate */
setlocale(LC_ALL,"");
initscr(); /* initialize the curses library */
keypad(stdscr, TRUE); /* enable keyboard mapping */
nonl(); /* tell curses not to do NL->CR/NL on output */
cbreak(); /* take input chars one at a time, no wait for \n */
noecho(); /* don't echo input */
//nodelay(stdscr, true);
int wxMax = getmaxx(stdscr);
int wyMax = getmaxy(stdscr);
keypad(stdscr, TRUE);
scrollok(stdscr, TRUE);
if (has_colors())
{
start_color();
/*
* Simple color assignment, often all we need.
*/
init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
init_color(COLOR_CYAN, 700, 700, 700); // lt grey
init_color(COLOR_MAGENTA, 500, 500, 500); // dk grey
init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
}
int x_max,y_max,z_max;
uint32_t x_max_a,y_max_a,z_max_a;
/*
uint16_t tiletypes[16][16];
DFHack::t_designation designations[16][16];
uint8_t regionoffsets[16];
*/
map <int16_t, uint32_t> materials;
materials.clear();
mapblock40d blocks[3][3];
vector<DFHack::t_effect_df40d> effects;
vector< vector <uint16_t> > layerassign;
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
vector<t_spattervein> splatter;
t_temperatures b_temp1;
t_temperatures b_temp2;
DFHack::Materials * Mats = 0;
DFHack::Maps * Maps = 0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context* DF;
try
{
pDF = DF = DFMgr.getSingleContext();
DF->Attach();
Mats = DF->getMaterials();
Maps = DF->getMaps();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
finish(0);
}
Process* p = DF->getProcess();
// init the map
if(!Maps->Start())
{
error = "Can't find a map to look at.";
finish(0);
}
Maps->getSize(x_max_a,y_max_a,z_max_a);
x_max = x_max_a;
y_max = y_max_a;
z_max = z_max_a;
// get stone matgloss mapping
if(!Mats->ReadInorganicMaterials())
{
error = "Can't read stone types.";
pDF = 0;
finish(0);
}
/*
if(!Mats->ReadCreatureTypes())
//.........这里部分代码省略.........
示例5: main
int main (int numargs, char ** args)
{
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
DFHack::Process * p;
try
{
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
p = DF->getProcess();
string check = "";
if(numargs == 2)
check = args[1];
DFHack::Creatures * Creatures = DF->getCreatures();
Materials = DF->getMaterials();
DFHack::Translation * Tran = DF->getTranslation();
uint32_t numCreatures;
if(!Creatures->Start(numCreatures))
{
cerr << "Can't get creatures" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
if(!numCreatures)
{
cerr << "No creatures to print" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
mem = DF->getMemoryInfo();
if(!Materials->ReadInorganicMaterials())
{
cerr << "Can't get the inorganics types." << endl;
return 1;
}
if(!Materials->ReadCreatureTypesEx())
{
cerr << "Can't get the creature types." << endl;
return 1;
}
if(!Tran->Start())
{
cerr << "Can't get name tables" << endl;
return 1;
}
vector<uint32_t> addrs;
//DF.InitViewAndCursor();
for(uint32_t i = 0; i < numCreatures; i++)
{
DFHack::t_creature temp;
unsigned int current_job;
unsigned int mat_start;
unsigned int mat_end;
unsigned int j,k;
unsigned int matptr;
Creatures->ReadCreature(i,temp);
if(temp.mood>=0)
{
current_job = p->readDWord(temp.origin + 0x390);
if(current_job == 0)
continue;
mat_start = p->readDWord(current_job + 0xa4 + 4*3);
mat_end = p->readDWord(current_job + 0xa4 + 4*4);
for(j=mat_start;j<mat_end;j+=4)
{
matptr = p->readDWord(j);
for(k=0;k<4;k++)
printf("%.4X ", p->readWord(matptr + k*2));
for(k=0;k<3;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x8));
for(k=0;k<2;k++)
printf("%.4X ", p->readWord(matptr + k*2 + 0x14));
for(k=0;k<3;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x18));
for(k=0;k<4;k++)
printf("%.2X ", p->readByte(matptr + k + 0x24));
for(k=0;k<6;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x28));
for(k=0;k<4;k++)
printf("%.2X ", p->readByte(matptr + k + 0x40));
for(k=0;k<9;k++)
printf("%.8X ", p->readDWord(matptr + k*4 + 0x44));
printf(" [%p]\n", matptr);
}
//.........这里部分代码省略.........
示例6: main
int main ( int argc, char** argv )
{
DFHack::memory_info *mem;
DFHack::Process *proc;
uint32_t creature_pregnancy_offset;
//bool femaleonly = 0;
bool showcreatures = 0;
int maxpreg = 1000; // random start value, since its not required and im not sure how to set it to infinity
list<string> s_creatures;
// parse input, handle this nice and neat before we get to the connecting
argstream as(argc,argv);
as // >>option('f',"female",femaleonly,"Impregnate females only")
>>option('s',"show",showcreatures,"Show creature list (read only)")
>>parameter('m',"max",maxpreg,"The maximum limit of pregnancies ", false)
>>values<string>(back_inserter(s_creatures), "any number of creatures")
>>help();
// make the creature list unique
s_creatures.unique();
if (!as.isOk())
{
cout << as.errorLog();
return(0);
}
else if (as.helpRequested())
{
cout<<as.usage()<<endl;
return(1);
}
else if(showcreatures==1)
{
}
else if (s_creatures.size() == 0 && showcreatures != 1)
{
cout << as.usage() << endl << "---------------------------------------" << endl;
cout << "Creature list empty, assuming CATs" << endl;
s_creatures.push_back("CAT");
}
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
proc = DF->getProcess();
mem = DF->getMemoryInfo();
DFHack::Materials *Mats = DF->getMaterials();
DFHack::Creatures *Cre = DF->getCreatures();
creature_pregnancy_offset = mem->getOffset("creature_pregnancy");
if(!Mats->ReadCreatureTypesEx())
{
cerr << "Can't get the creature types." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
uint32_t numCreatures;
if(!Cre->Start(numCreatures))
{
cerr << "Can't get creatures" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
int totalcount=0;
int totalchanged=0;
string sextype;
// shows all the creatures and returns.
int maxlength = 0;
map<string, vector <t_creature> > male_counts;
map<string, vector <t_creature> > female_counts;
// classify
for(uint32_t i =0;i < numCreatures;i++)
{
DFHack::t_creature creature;
Cre->ReadCreature(i,creature);
DFHack::t_creaturetype & crt = Mats->raceEx[creature.race];
string castename = crt.castes[creature.sex].rawname;
//.........这里部分代码省略.........
示例7: main
int main (int argc, char *argv[])
{
bool print_refs = false;
bool print_hex = false;
bool print_acc = false;
for(int i = 1; i < argc; i++)
{
char *arg = argv[i];
if (arg[0] != '-')
continue;
for (; *arg; arg++) {
switch (arg[0]) {
case 'r':
print_refs = true;
break;
case 'x':
print_hex = true;
break;
case 'a':
print_acc = true;
break;
}
}
}
DFHack::Process * p;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Materials * Materials = DF->getMaterials();
Materials->ReadAllMaterials();
DFHack::Gui * Gui = DF->getGui();
DFHack::Items * Items = DF->getItems();
Items->Start();
DFHack::VersionInfo * mem = DF->getMemoryInfo();
p = DF->getProcess();
int32_t x,y,z;
Gui->getCursorCoords(x,y,z);
std::vector<uint32_t> p_items;
Items->readItemVector(p_items);
uint32_t size = p_items.size();
// FIXME: tools should never be exposed to DFHack internals!
DFHack::OffsetGroup* itemGroup = mem->getGroup("Items");
uint32_t ref_vector = itemGroup->getOffset("item_ref_vector");
for(size_t i = 0; i < size; i++)
{
DFHack::dfh_item itm;
memset(&itm, 0, sizeof(DFHack::dfh_item));
Items->readItem(p_items[i],itm);
if (x != -30000
&& !(itm.base.x == x && itm.base.y == y && itm.base.z == z
&& itm.base.flags.on_ground
&& !itm.base.flags.in_chest
&& !itm.base.flags.in_inventory
&& !itm.base.flags.in_building))
continue;
printf(
"%5d: %08x %6d %08x (%d,%d,%d) #%08x [%d] *%d %s - %s\n",
i, itm.origin, itm.id, itm.base.flags.whole,
itm.base.x, itm.base.y, itm.base.z,
itm.base.vtable,
itm.wear_level,
itm.quantity,
Items->getItemClass(itm).c_str(),
Items->getItemDescription(itm, Materials).c_str()
);
if (print_hex)
hexdump(DF,p_items[i],0x300);
if (print_acc)
cout << Items->dumpAccessors(itm) << endl;
if (print_refs) {
DFHack::DfVector<uint32_t> p_refs(p, itm.origin + ref_vector);
for (size_t j = 0; j < p_refs.size(); j++) {
uint32_t vptr = p->readDWord(p_refs[j]);
//.........这里部分代码省略.........