• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dfhack::Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dfhack::Context的典型用法代码示例。如果您正苦于以下问题:C++ Context类的具体用法?C++ Context怎么用?C++ Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main (int argc, char** argv)
{
    bool quiet = false;
    for(int i = 1; i < argc; i++)
    {
        string test = argv[i];
        if(test == "-q")
        {
            quiet = true;
        }
    }

    DFHack::Position * Position = 0;
    DFHack::ContextManager DFMgr("Memory.xml");
    DFHack::Context * DF;
    try
    {
        DF = DFMgr.getSingleContext();
        DF->Attach();
        Position = DF->getPosition();
    }
    catch (exception& e)
    {
        cerr << e.what() << endl;
        #ifndef LINUX_BUILD
            cin.ignore();
        #endif
        return 1;
    }
    if (Position)
    {
       int32_t x,y,z;
       int32_t width,height;

       if(Position->getViewCoords(x,y,z))
            cout << "view coords: " << x << "/" << y << "/" << z << endl;
       if(Position->getCursorCoords(x,y,z))
            cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
       if(Position->getWindowSize(width,height))
           cout << "window size : " << width << " " << height << endl;
    }
    else
    {
        cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
    }

    if(!DF->Detach())
    {
        cerr << "Can't detach from DF" << endl;
    }

    #ifndef LINUX_BUILD
        if(!quiet)
        {
            cout << "Done. Press any key to continue" << endl;
            cin.ignore();
        }
    #endif
    return 0;
}
开发者ID:potato,项目名称:dfhack,代码行数:60,代码来源:position.cpp


示例2: main

int main (int numargs, const char ** args)
{
    /*
    DFHack::VersionInfoFactory * VIF = new DFHack::VersionInfoFactory("Memory.xml");
    for(int i = 0; i < VIF->versions.size(); i++)
    {
        cout << VIF->versions[i]->PrintOffsets();
    }
    */
    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;
    }
    cout << DF->getMemoryInfo()->PrintOffsets();
    #ifndef LINUX_BUILD
        cout << "Done. Press any key to continue" << endl;
        cin.ignore();
    #endif
    //delete VIF;
    return 0;
}
开发者ID:nickrart,项目名称:dfhack,代码行数:31,代码来源:dumpoffsets.cpp


示例3: main

int main (int numargs, const char ** args)
{
    bool temporary_terminal = TemporaryTerminal();
    /*
    DFHack::VersionInfoFactory * VIF = new DFHack::VersionInfoFactory("Memory.xml");
    for(int i = 0; i < VIF->versions.size(); i++)
    {
        cout << VIF->versions[i]->PrintOffsets();
    }
    */
    DFHack::ContextManager DFMgr("Memory.xml");
    DFHack::Context *DF = DFMgr.getSingleContext();
    try
    {
        DF->Attach();
    }
    catch (exception& e)
    {
        cerr << e.what() << endl;
        if(temporary_terminal)
            cin.ignore();
        return 1;
    }
    cout << DF->getMemoryInfo()->PrintOffsets();
    if(temporary_terminal)
    {
        cout << "Done. Press any key to continue" << endl;
        cin.ignore();
    }
    //delete VIF;
    return 0;
}
开发者ID:NonRealDeveloper,项目名称:dfhack,代码行数:32,代码来源:dumpoffsets.cpp


示例4: 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;
}
开发者ID:potato,项目名称:dfhack,代码行数:59,代码来源:cleartask.cpp


示例5: main

int main (void)
{
    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::memory_info * mem = DF->getMemoryInfo();
    DFHack::Position * Pos = DF->getPosition();
    // get stone matgloss mapping
    /*
    uint32_t numNotes;
    if(!DF.InitReadNotes(numNotes))
    {
        cerr << "Can't get notes" << endl;
        return 1;
    }
    */
    /*
    cout << "Notes" << endl;
    for(uint32_t i = 0; i < numNotes; i++)
    {
        DFHack::t_note temp;
        DF.ReadNote(i,temp);
        cout << "x: " << temp.x << "\ty: " << temp.y << "\tz: " << temp.z <<
            "\tsymbol: " << temp.symbol << "\tfg: " << temp.foreground << "\tbg: " << temp.background <<
            "\ttext: " << temp.name << endl;
    }
    */
    cout << "Hotkeys" << endl;
    DFHack::t_hotkey hotkeys[NUM_HOTKEYS];
    Pos->ReadHotkeys(hotkeys);
    for(uint32_t i =0;i< NUM_HOTKEYS;i++)
    {
        cout << "x: " << hotkeys[i].x << "\ty: " << hotkeys[i].y << "\tz: " << hotkeys[i].z <<
            "\ttext: " << hotkeys[i].name << endl;
    }
    //DF.FinishReadNotes();
    DF->Detach();
    #ifndef LINUX_BUILD
    cout << "Done. Press any key to continue" << endl;
    cin.ignore();
    #endif
    return 0;
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:56,代码来源:hotkeynotedump.cpp


示例6: sf

/*
{
    vector <uint64_t> found;
    Bytestream select;
    while (Incremental(found,"byte stream",select,"byte stream","byte streams"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Incremental< Bytestream ,uint32_t>(select,1,found, findBytestream);
        DF->Detach();
    }
}
*/
void DataPtrTrace(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    int element_size;
    do
    {
        getNumber("Set search granularity",element_size, 4);
    } while (element_size < 1);

    vector <uint64_t> found;
    set <uint64_t> check; // to detect circles
    uint32_t select;
    Bytestream bs_select;
    DFHack::Context * DF = DFMgr.getSingleContext();
    DF->Attach();
    DFMgr.Refresh();
    found.clear();
    SegmentedFinder sf(ranges,DF);
    while(found.empty())
    {
        Incremental(found,"byte stream",bs_select,"byte stream","byte streams");
        
        sf.Incremental< Bytestream ,uint32_t>(bs_select,1,found, findBytestream);
    }
    select = found[0];
    
    
    
    
    cout <<"Starting: 0x" << hex << select << endl;
    while(sf.getSegmentForAddress(select))
    {
        sf.Incremental<uint32_t,uint32_t>(select,element_size,found, equalityP<uint32_t>);
        if(found.empty())
        {
            cout << ".";
            cout.flush();
            select -=element_size;
            continue;
        }
        cout << endl;
        cout <<"Object start: 0x" << hex << select << endl;
        cout <<"Pointer:      0x" << hex << found[0] << endl;
        // make sure we don't go in circles'
        if(check.count(select))
        {
            break;
        }
        check.insert(select);
        // ascend
        select = found[0];
        found.clear();
    }
    DF->Detach();
}
开发者ID:potato,项目名称:dfhack,代码行数:69,代码来源:incrementalsearch.cpp


示例7: main

int main(int argc, char *argv[])
{
    bool temporary_terminal = TemporaryTerminal();

    uint32_t x_max = 0, y_max = 0, z_max = 0;
    DFHack::ContextManager manager("Memory.xml");

    DFHack::Context *context = manager.getSingleContext();
    if (!context->Attach())
    {
        std::cerr << "Unable to attach to DF!" << std::endl;
        if(temporary_terminal)
            std::cin.ignore();
        return 1;
    }

    DFHack::Maps *maps = context->getMaps();
    if (!maps->Start())
    {
        std::cerr << "Cannot get map info!" << std::endl;
        context->Detach();
        if(temporary_terminal)
            std::cin.ignore();
        return 1;
    }
    maps->getSize(x_max, y_max, z_max);
    MapExtras::MapCache map(maps);

    for(uint32_t z = 0; z < z_max; z++)
    {
        for(uint32_t b_y = 0; b_y < y_max; b_y++)
        {
            for(uint32_t b_x = 0; b_x < x_max; b_x++)
            {
                // Get the map block
                DFHack::DFCoord blockCoord(b_x, b_y);
                MapExtras::Block *b = map.BlockAt(DFHack::DFCoord(b_x, b_y, z));
                if (!b || !b->valid)
                {
                    continue;
                }

                DFHack::t_blockflags flags = b->BlockFlags();
                flags.whole = flags.whole ^ 0xFFFFFFFF;
                b->setBlockFlags(flags);
                b->Write();
            } // block x
        } // block y
    } // z

    maps->Finish();
    context->Detach();
    return 0;
}
开发者ID:kaypy,项目名称:dfhack,代码行数:54,代码来源:blockflags.cpp


示例8: main

int main(int argc, char** argv) {
  if(argc < 2) {
    ::std::cout << "gimme a file!" << ::std::endl;
    return 1;
  }

  ::std::ifstream map_in(argv[1]);

  ::std::vector< ::std::string > dig_map;
  while (map_in.good() && !map_in.eof() && !map_in.bad()) {
    ::std::string line;
    map_in >> line;

    dig_map.push_back(line);
  }
  dig_map.resize(dig_map.size() - 1);

  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
    ::std::cin.ignore();
#endif
    return 1;
  }

  DFHack::Maps *layers = DF->getMaps();
  if (layers && layers->Start()) {

    dig(layers, DF->getGui(), dig_map, true);

    ::std::cout << "Finished digging" << ::std::endl;
    layers->Finish();

    if (!DF->Detach()) {
      ::std::cerr << "Unable to detach DF process" << ::std::endl;
    }

  } else {
    ::std::cerr << "Unable to init map" << ::std::endl;
  }

#ifndef LINUX_BUILD
  ::std::cout << "Done. Press any key to continue" << ::std::endl;
  ::std::cin.ignore();
#endif
  return 0;
}
开发者ID:AlexanderStarr,项目名称:dfhack,代码行数:52,代码来源:digger2.cpp


示例9: FindStrings

void FindStrings(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    vector <uint64_t> found;
    string select;
    while (Incremental(found,"string",select,"string","strings"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Incremental< const char * ,uint32_t>(select.c_str(),1,found, findString);
        DF->Detach();
    }
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:14,代码来源:incrementalsearch.cpp


示例10: FindData

void FindData(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    vector <uint64_t> found;
    Bytestream select;
    while (Incremental(found,"byte stream",select,"byte stream","byte streams"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Incremental< Bytestream ,uint32_t>(select,1,found, findBytestream);
        DF->Detach();
    }
}
开发者ID:potato,项目名称:dfhack,代码行数:14,代码来源:incrementalsearch.cpp


示例11: FindVectorByFirstObjectRawname

void FindVectorByFirstObjectRawname(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    vector <uint64_t> found;
    string select;
    while (Incremental(found, "raw name",select,"vector","vectors"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Find<int ,vecTriplet>(0,4,found, vectorAll);
        sf.Filter<const char * ,vecTriplet>(select.c_str(),found, vectorStringFirst);
        DF->Detach();
    }
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:15,代码来源:incrementalsearch.cpp


示例12: FindPtrVectorsByObjectAddress

void FindPtrVectorsByObjectAddress(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    vector <uint64_t> found;
    uint32_t select;
    while (Incremental(found, "object address",select,"vector","vectors"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Find<int ,vecTriplet>(0,4,found, vectorAll);
        sf.Filter<uint32_t ,vecTriplet>(select,found, vectorOfPtrWithin);
        DF->Detach();
    }
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:15,代码来源:incrementalsearch.cpp


示例13: FindVectorByBounds

void FindVectorByBounds(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    vector <uint64_t> found;
    uint32_t select;
    while (Incremental(found, "address between vector.start and vector.end",select,"vector","vectors"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Find<int ,vecTriplet>(0,4,found, vectorAll);
        sf.Filter<uint32_t ,vecTriplet>(select,found, vectorAddrWithin);
        // sort by size of vector
        std::sort(found.begin(), found.end(), VectorSizeFunctor(sf));
        DF->Detach();
    }
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:17,代码来源:incrementalsearch.cpp


示例14: FindIntegers

void FindIntegers(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
    // input / validation of variable size
    int size;
    do
    {
        getNumber("Select variable size (1,2,4 bytes)",size, 4);
    } while (size != 1 && size != 2 && size != 4);
    // input / validation of variable alignment (default is to use the same alignment as size)
    int alignment;
    do
    {
        getNumber("Select variable alignment (1,2,4 bytes)",alignment, size);
    } while (alignment != 1 && alignment != 2 && alignment != 4);

    uint32_t test1;
    vector <uint64_t> found;
    found.reserve(100);
    while(Incremental(found, "integer",test1))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        switch(size)
        {
            case 1:
                sf.Incremental<uint8_t,uint8_t>(test1,alignment,found, equalityP<uint8_t>);
                break;
            case 2:
                sf.Incremental<uint16_t,uint16_t>(test1,alignment,found, equalityP<uint16_t>);
                break;
            case 4:
                sf.Incremental<uint32_t,uint32_t>(test1,alignment,found, equalityP<uint32_t>);
                break;
        }
        DF->Detach();
    }
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:39,代码来源:incrementalsearch.cpp


示例15: FindVectorByLength

void FindVectorByLength(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges )
{
    int element_size;
    do
    {
        getNumber("Select searched vector item size in bytes",element_size, 4);
    } while (element_size < 1);

    uint32_t length;
    vector <uint64_t> found;
    found.reserve(100);
    while (Incremental(found, "vector length",length,"vector","vectors"))
    {
        DFMgr.Refresh();
        DFHack::Context * DF = DFMgr.getSingleContext();
        DF->Attach();
        SegmentedFinder sf(ranges,DF);
        sf.Incremental<int ,vecTriplet>(0,4,found,vectorAll);
        sf.Filter<uint32_t,vecTriplet>(length * element_size,found,vectorLength<uint32_t>);
        DF->Detach();
    }
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:22,代码来源:incrementalsearch.cpp


示例16: main

int main (void)
{
    string blah;
    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;
    }
    cout << "Attached, DF should be suspended now" << endl;
    getline(cin, blah);
    
    DF->Resume();
    cout << "Resumed, DF should be running" << endl;
    getline(cin, blah);
    
    DF->Suspend();
    cout << "Suspended, DF should be suspended now" << endl;
    getline(cin, blah);
    
    DF->Resume();
    cout << "Resumed, testing ForceResume. Suspend using SysInternals Process Explorer" << endl;
    getline(cin, blah);

    DF->ForceResume();
    cout << "ForceResumed. DF should be running." << endl;
    getline(cin, blah);

    if(!DF->Detach())
    {
        cerr << "Can't detach from DF" << endl;
        return 1;
    }
    cout << "Detached, DF should be running again" << endl;
    getline(cin, blah);
    
    return 0;
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:47,代码来源:suspendtest.cpp


示例17: main

int main (int argc, char* argv[])
{
    // Command line options
    bool updown = false;
    if(argc > 1 && strcmp(argv[1],"-x") == 0)
        updown = true;

    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;
    }

    uint32_t x_max,y_max,z_max;
    DFHack::Maps * Maps = DF->getMaps();
    DFHack::Gui * Gui = DF->getGui();

    // init the map
    if(!Maps->Start())
    {
        cerr << "Can't init map. Make sure you have a map loaded in DF." << endl;
        DF->Detach();
        #ifndef LINUX_BUILD
            cin.ignore();
        #endif
        return 1;
    }

    int32_t cx, cy, cz;
    Maps->getSize(x_max,y_max,z_max);
    uint32_t tx_max = x_max * 16;
    uint32_t ty_max = y_max * 16;

    Gui->getCursorCoords(cx,cy,cz);
    while(cx == -30000)
    {
        cerr << "Cursor is not active. Point the cursor at a vein." << endl;
        DF->Resume();
        cin.ignore();
        DF->Suspend();
        Gui->getCursorCoords(cx,cy,cz);
    }
    DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
    if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
    {
        cerr << "I won't dig the borders. That would be cheating!" << endl;
        DF->Detach();
        #ifndef LINUX_BUILD
            cin.ignore();
        #endif
        return 1;
    }
    MapCache * MCache = new MapCache(Maps);

    DFHack::t_designation des = MCache->designationAt(xy);
    int16_t tt = MCache->tiletypeAt(xy);
    int16_t veinmat = MCache->veinMaterialAt(xy);

    if( veinmat == -1 )
    {
        cerr << "This tile is non-vein. Bye :)" << endl;
        delete MCache;
        DF->Detach();
        #ifndef LINUX_BUILD
            cin.ignore();
        #endif
        return 1;
    }
    printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
    stack <DFHack::DFCoord> flood;
    flood.push(xy);


    while( !flood.empty() )
    {
        DFHack::DFCoord current = flood.top();
        flood.pop();
        int16_t vmat2 = MCache->veinMaterialAt(current);
        tt = MCache->tiletypeAt(current);
        if(!DFHack::isWallTerrain(tt))
            continue;
        if(vmat2!=veinmat)
            continue;

        // found a good tile, dig+unset material
        DFHack::t_designation des = MCache->designationAt(current);
        DFHack::t_designation des_minus;
        DFHack::t_designation des_plus;
        des_plus.whole = des_minus.whole = 0;
        int16_t vmat_minus = -1;
//.........这里部分代码省略.........
开发者ID:raoulxq,项目名称:dfhack,代码行数:101,代码来源:vdig.cpp


示例18: main

int 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); 

    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;
    vector<t_grassvein> grass;
    vector<t_worldconstruction> wconstructs;
    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();
        Maps = DF->getMaps();
    }
    catch (exception& e)
    {
        cerr << e.what() << endl;
        #ifndef LINUX_BUILD
            cin.ignore();
        #endif
        finish(0);
    }
    bool hasmats = true;
    try
    {
        Mats = DF->getMaterials();
    }
    catch (exception& e)
    {
        hasmats = false;
    }
    
    // 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;
    
    bool hasInorgMats = false;
    bool hasPlantMats = false;
//.........这里部分代码省略.........
开发者ID:raoulxq,项目名称:dfhack,代码行数:101,代码来源:veinlook.cpp


示例19: main

int main (void)
{
    uint32_t x_max,y_max,z_max;
    DFHack::designations40d designations;
    
    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::Maps *Maps =DF->getMaps();
    DFHack::Gui *Gui =DF->getGui();
    // walk the map, save the hide bits, reveal.
    cout << "Pausing..." << endl;

    // horrible hack to make sure the pause is really set
    // preblem here is that we could be 'arriving' at the wrong time and DF could be in the middle of a frame.
    // that could mean that revealing, even with suspending DF's thread, would mean unleashing hell *in the same frame* 
    // this here hack sets the pause state, resumes DF, waits a second for it to enter the pause (I know, BS value.) and suspends.
    Gui->SetPauseState(true);
    DF->Resume();
    waitmsec(1000);
    DF->Suspend();

    // init the map
    if(!Maps->Start())
    {
        cerr << "Can't init map." << endl;
        #ifndef LINUX_BUILD
            cin.ignore();
        #endif
        return 1;
    }

    cout << "Revealing, please wait..." << endl;

    Maps->getSize(x_max,y_max,z_max);
    vector <hideblock> hidesaved;

    for(uint32_t x = 0; x< x_max;x++)
    {
        for(uint32_t y = 0; y< y_max;y++)
        {
            for(uint32_t z = 0; z< z_max;z++)
            {
                if(Maps->isValidBlock(x,y,z))
                {
                    hideblock hb;
                    hb.x = x;
                    hb.y = y;
                    hb.z = z;
                    // read block designations
                    Maps->ReadDesignations(x,y,z, &designations);
                    // change the hidden flag to 0
                    for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
                    {
                        hb.hiddens[i][j] = designations[i][j].bits.hidden;
                        designations[i][j].bits.hidden = 0;
                    }
                    hidesaved.push_back(hb);
                    // write the designations back
                    Maps->WriteDesignations(x,y,z, &designations);
                }
            }
        }
    }
    // FIXME: force game pause here!
    DF->Detach();
    cout << "Map revealed. The game has been paused for you." << endl;
    cout << "Unpausing can unleash the forces of hell!" << endl << endl;
    cout << "Press any key to unreveal." << endl;
    cout << "Close to keep the map revealed." << endl;
    cin.ignore();
    cout << "Unrevealing... please wait." << endl;
    // FIXME: do some consistency checks here!
    DF->Attach();
    Maps = DF->getMaps();
    Maps->Start();
    for(int i = 0; i < hidesaved.size();i++)
    {
        hideblock & hb = hidesaved[i];
        Maps->ReadDesignations(hb.x,hb.y,hb.z, &designations);
        for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
        {
            designations[i][j].bits.hidden = hb.hiddens[i][j];
        }
        Maps->WriteDesignations(hb.x,hb.y,hb.z, &designations);
    }
    #ifndef LINUX_BUILD
//.........这里部分代码省略.........
开发者ID:nickrart,项目名称:dfhack,代码行数:101,代码来源:reveal.cpp


示例20: 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;
}
开发者ID:RusAnon,项目名称:dfhack,代码行数:75,代码来源:incrementalsearch.cpp



注:本文中的dfhack::Context类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dfhack::ContextManager类代码示例发布时间:2022-05-31
下一篇:
C++ devs::ExternalEventList类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap