|
|
|
@ -46,32 +46,39 @@ namespace DFHack
|
|
|
|
|
public:
|
|
|
|
|
API(const std::string path_to_xml);
|
|
|
|
|
~API();
|
|
|
|
|
/*
|
|
|
|
|
* Basic control over DF's process state
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bool Attach();
|
|
|
|
|
bool Detach();
|
|
|
|
|
bool isAttached();
|
|
|
|
|
|
|
|
|
|
//true if paused, false if not
|
|
|
|
|
bool ReadPauseState();
|
|
|
|
|
|
|
|
|
|
// read the DF menu view state (stock screen, unit screen, other screens
|
|
|
|
|
bool ReadViewScreen(t_viewscreen &);
|
|
|
|
|
|
|
|
|
|
// read the DF menu state (designation menu ect)
|
|
|
|
|
uint32_t ReadMenuState();
|
|
|
|
|
|
|
|
|
|
// stop DF from executing
|
|
|
|
|
/// stop DF from executing
|
|
|
|
|
bool Suspend();
|
|
|
|
|
// stop DF from executing, asynchronous, use with polling
|
|
|
|
|
bool isSuspended();
|
|
|
|
|
|
|
|
|
|
/// stop DF from executing, asynchronous, use with polling
|
|
|
|
|
bool AsyncSuspend();
|
|
|
|
|
// resume DF
|
|
|
|
|
|
|
|
|
|
/// resume DF
|
|
|
|
|
bool Resume();
|
|
|
|
|
/**
|
|
|
|
|
* Force resume
|
|
|
|
|
* be careful with this one
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// forces resume on Windows. This can be a bad thing with multiple DF tools running!
|
|
|
|
|
bool ForceResume();
|
|
|
|
|
bool isSuspended();
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Query the DF's GUI state
|
|
|
|
|
*/
|
|
|
|
|
///true if paused, false if not
|
|
|
|
|
bool ReadPauseState();
|
|
|
|
|
/// read the DF menu view state (stock screen, unit screen, other screens
|
|
|
|
|
bool ReadViewScreen(t_viewscreen &);
|
|
|
|
|
/// read the DF menu state (designation menu ect)
|
|
|
|
|
uint32_t ReadMenuState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Matgloss. next four methods look very similar. I could use two and move the processing one level up...
|
|
|
|
|
* I'll keep it like this, even with the code duplication as it will hopefully get more features and separate data types later.
|
|
|
|
|
* Yay for nebulous plans for a rock survey tool that tracks how much of which metal could be smelted from available resorces
|
|
|
|
@ -135,111 +142,148 @@ namespace DFHack
|
|
|
|
|
*/
|
|
|
|
|
uint32_t getBlockPtr (uint32_t blockx, uint32_t blocky, uint32_t blockz);
|
|
|
|
|
|
|
|
|
|
/// read the whole map block at block coords (see DFTypes.h for the block structure)
|
|
|
|
|
bool ReadBlock40d(uint32_t blockx, uint32_t blocky, uint32_t blockz, mapblock40d * buffer);
|
|
|
|
|
|
|
|
|
|
bool ReadTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t)
|
|
|
|
|
bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t)
|
|
|
|
|
/// read/write block tile types
|
|
|
|
|
bool ReadTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, tiletypes40d *buffer);
|
|
|
|
|
bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, tiletypes40d *buffer);
|
|
|
|
|
|
|
|
|
|
bool ReadDesignations(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer); // 256 * sizeof(uint32_t)
|
|
|
|
|
bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer);
|
|
|
|
|
/// read/write block designations
|
|
|
|
|
bool ReadDesignations(uint32_t blockx, uint32_t blocky, uint32_t blockz, designations40d *buffer);
|
|
|
|
|
bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, designations40d *buffer);
|
|
|
|
|
|
|
|
|
|
bool ReadOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer); // 256 * sizeof(uint32_t)
|
|
|
|
|
bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer); // 256 * sizeof(uint32_t)
|
|
|
|
|
/// read/write block occupancies
|
|
|
|
|
bool ReadOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, occupancies40d *buffer);
|
|
|
|
|
bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, occupancies40d *buffer);
|
|
|
|
|
|
|
|
|
|
/// read/write the block dirty bit - this is used to mark a map block so that DF scans it for designated jobs like digging
|
|
|
|
|
bool ReadDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool &dirtybit);
|
|
|
|
|
bool WriteDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool dirtybit);
|
|
|
|
|
|
|
|
|
|
/// read region offsets of a block
|
|
|
|
|
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer); // 16 * sizeof(uint8_t)
|
|
|
|
|
/// read region offsets of a block - used for determining layer stone matgloss
|
|
|
|
|
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, biome_indices40d *buffer);
|
|
|
|
|
|
|
|
|
|
/// read aggregated veins of a block
|
|
|
|
|
bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, std::vector <t_vein> & veins, std::vector <t_frozenliquidvein>& ices);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Buildings, constructions, plants, all pretty straighforward. InitReadBuildings returns all the building types as a mapping between a numeric values and strings
|
|
|
|
|
/*
|
|
|
|
|
* Constructions (costructed walls, floors, ramps, etc...)
|
|
|
|
|
*/
|
|
|
|
|
/// start reading constructions. numconstructions is an output - total constructions present
|
|
|
|
|
bool InitReadConstructions( uint32_t & numconstructions );
|
|
|
|
|
/// read a construiction at index
|
|
|
|
|
bool ReadConstruction(const int32_t index, t_construction & construction);
|
|
|
|
|
/// cleanup after reading constructions
|
|
|
|
|
void FinishReadConstructions();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Buildings - also includes zones and stockpiles
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadBuildings ( uint32_t & numbuildings );
|
|
|
|
|
bool ReadBuilding(const int32_t index, t_building & building);
|
|
|
|
|
void FinishReadBuildings();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Effects like mist, dragonfire or dust
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadEffects ( uint32_t & numeffects );
|
|
|
|
|
bool ReadEffect(const int32_t index, t_effect_df40d & effect);
|
|
|
|
|
bool WriteEffect(const int32_t index, const t_effect_df40d & effect);
|
|
|
|
|
void FinishReadEffects();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Trees and shrubs
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadVegetation( uint32_t & numplants );
|
|
|
|
|
bool ReadVegetation(const int32_t index, t_tree_desc & shrubbery);
|
|
|
|
|
void FinishReadVegetation();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Creatures
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadCreatures( uint32_t & numcreatures );
|
|
|
|
|
/// returns index of creature actually read or -1 if no creature can be found
|
|
|
|
|
/**
|
|
|
|
|
* Read creatures in a box, starting with index. Returns -1 if no more creatures
|
|
|
|
|
* found. Call repeatedly do get all creatures in a specified box (uses tile coords)
|
|
|
|
|
*/
|
|
|
|
|
int32_t ReadCreatureInBox(const int32_t index, t_creature & furball,
|
|
|
|
|
const uint16_t x1, const uint16_t y1,const uint16_t z1,
|
|
|
|
|
const uint16_t x2, const uint16_t y2,const uint16_t z2);
|
|
|
|
|
bool ReadCreature(const int32_t index, t_creature & furball);
|
|
|
|
|
void FinishReadCreatures();
|
|
|
|
|
|
|
|
|
|
/// read/write size bytes of raw data at offset. DANGEROUS, CAN SEGFAULT DF!
|
|
|
|
|
void ReadRaw (const uint32_t offset, const uint32_t size, uint8_t *target);
|
|
|
|
|
void WriteRaw (const uint32_t offset, const uint32_t size, uint8_t *source);
|
|
|
|
|
/// write labors of a creature (for Dwarf Therapist)
|
|
|
|
|
void WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
|
|
|
|
|
|
|
|
|
|
bool InitViewAndCursor();
|
|
|
|
|
/*
|
|
|
|
|
* Notes placed by the player
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// start reading notes. numnotes is an output - total notes present
|
|
|
|
|
bool InitReadNotes( uint32_t & numnotes );
|
|
|
|
|
/// read note from the note vector at index
|
|
|
|
|
bool ReadNote(const int32_t index, t_note & note);
|
|
|
|
|
/// free the note vector
|
|
|
|
|
void FinishReadNotes();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Settlements
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadSettlements( uint32_t & numsettlements );
|
|
|
|
|
bool ReadSettlement(const int32_t index, t_settlement & settlement);
|
|
|
|
|
bool ReadCurrentSettlement(t_settlement & settlement);
|
|
|
|
|
void FinishReadSettlements();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Hotkeys (DF's zoom locations)
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadHotkeys( );
|
|
|
|
|
bool ReadHotkeys(t_hotkey hotkeys[]);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Cursor, and view coords
|
|
|
|
|
*/
|
|
|
|
|
bool InitViewAndCursor();
|
|
|
|
|
bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
|
bool setViewCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
|
|
|
|
|
|
|
|
bool getCursorCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
|
bool setCursorCoords (const int32_t x, const int32_t y, const int32_t z);
|
|
|
|
|
|
|
|
|
|
/// This returns false if there is nothing under the cursor, it puts the addresses in a vector if there is
|
|
|
|
|
/// get the creature vector index of the creature currently under DF' cursor
|
|
|
|
|
bool getCurrentCursorCreature (uint32_t & creature_index);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Window size in tiles
|
|
|
|
|
*/
|
|
|
|
|
bool InitViewSize();
|
|
|
|
|
bool getWindowSize(int32_t & width, int32_t & height);
|
|
|
|
|
/* unimplemented
|
|
|
|
|
bool setWindowSize(const int32_t & width, const int32_t & height);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bool getItemIndexesInBox(std::vector<uint32_t> &indexes,
|
|
|
|
|
const uint16_t x1, const uint16_t y1, const uint16_t z1,
|
|
|
|
|
const uint16_t x2, const uint16_t y2, const uint16_t z2);
|
|
|
|
|
/*
|
|
|
|
|
// FIXME: add a real creature class, move these
|
|
|
|
|
string getLastName(const uint32_t &index, bool);
|
|
|
|
|
string getSquadName(const uint32_t &index, bool);
|
|
|
|
|
string getProfession(const uint32_t &index);
|
|
|
|
|
string getCurrentJob(const uint32_t &index);
|
|
|
|
|
vector<t_skill> getSkills(const uint32_t &index);
|
|
|
|
|
vector<t_trait> getTraits(const uint32_t &index);
|
|
|
|
|
vector<t_labor> getLabors(const uint32_t &index);
|
|
|
|
|
* DF translation tables and name translation
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadNameTables (std::vector< std::vector<std::string> > & translations , std::vector< std::vector<std::string> > & foreign_languages);
|
|
|
|
|
void FinishReadNameTables();
|
|
|
|
|
|
|
|
|
|
std::string TranslateName(const t_name & name,const std::vector< std::vector<std::string> > & translations ,const std::vector< std::vector<std::string> > & foreign_languages, bool inEnglish=true);
|
|
|
|
|
|
|
|
|
|
void WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Item reading
|
|
|
|
|
*/
|
|
|
|
|
bool InitReadItems(uint32_t & numitems);
|
|
|
|
|
bool getItemIndexesInBox(std::vector<uint32_t> &indexes,
|
|
|
|
|
const uint16_t x1, const uint16_t y1, const uint16_t z1,
|
|
|
|
|
const uint16_t x2, const uint16_t y2, const uint16_t z2);
|
|
|
|
|
bool ReadItem(const uint32_t index, t_item & item);
|
|
|
|
|
void FinishReadItems();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Get the other API parts for raw access
|
|
|
|
|
*/
|
|
|
|
|
memory_info *getMemoryInfo();
|
|
|
|
|
Process * getProcess();
|
|
|
|
|
DFWindow * getWindow();
|
|
|
|
|