|
|
@ -46,32 +46,39 @@ namespace DFHack
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
API(const std::string path_to_xml);
|
|
|
|
API(const std::string path_to_xml);
|
|
|
|
~API();
|
|
|
|
~API();
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Basic control over DF's process state
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
bool Attach();
|
|
|
|
bool Attach();
|
|
|
|
bool Detach();
|
|
|
|
bool Detach();
|
|
|
|
bool isAttached();
|
|
|
|
bool isAttached();
|
|
|
|
|
|
|
|
|
|
|
|
//true if paused, false if not
|
|
|
|
/// stop DF from executing
|
|
|
|
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
|
|
|
|
|
|
|
|
bool Suspend();
|
|
|
|
bool Suspend();
|
|
|
|
// stop DF from executing, asynchronous, use with polling
|
|
|
|
bool isSuspended();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// stop DF from executing, asynchronous, use with polling
|
|
|
|
bool AsyncSuspend();
|
|
|
|
bool AsyncSuspend();
|
|
|
|
// resume DF
|
|
|
|
|
|
|
|
|
|
|
|
/// resume DF
|
|
|
|
bool Resume();
|
|
|
|
bool Resume();
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Force resume
|
|
|
|
/// forces resume on Windows. This can be a bad thing with multiple DF tools running!
|
|
|
|
* be careful with this one
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool ForceResume();
|
|
|
|
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...
|
|
|
|
* 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.
|
|
|
|
* 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
|
|
|
|
* 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);
|
|
|
|
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 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)
|
|
|
|
/// read/write block tile types
|
|
|
|
bool WriteTileTypes(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint16_t *buffer); // 256 * sizeof(uint16_t)
|
|
|
|
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)
|
|
|
|
/// read/write block designations
|
|
|
|
bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer);
|
|
|
|
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)
|
|
|
|
/// read/write block occupancies
|
|
|
|
bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint32_t *buffer); // 256 * sizeof(uint32_t)
|
|
|
|
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 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);
|
|
|
|
bool WriteDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool dirtybit);
|
|
|
|
|
|
|
|
|
|
|
|
/// read region offsets of a block
|
|
|
|
/// read region offsets of a block - used for determining layer stone matgloss
|
|
|
|
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer); // 16 * sizeof(uint8_t)
|
|
|
|
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, biome_indices40d *buffer);
|
|
|
|
|
|
|
|
|
|
|
|
/// read aggregated veins of a block
|
|
|
|
/// 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);
|
|
|
|
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 );
|
|
|
|
bool InitReadConstructions( uint32_t & numconstructions );
|
|
|
|
|
|
|
|
/// read a construiction at index
|
|
|
|
bool ReadConstruction(const int32_t index, t_construction & construction);
|
|
|
|
bool ReadConstruction(const int32_t index, t_construction & construction);
|
|
|
|
|
|
|
|
/// cleanup after reading constructions
|
|
|
|
void FinishReadConstructions();
|
|
|
|
void FinishReadConstructions();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Buildings - also includes zones and stockpiles
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitReadBuildings ( uint32_t & numbuildings );
|
|
|
|
bool InitReadBuildings ( uint32_t & numbuildings );
|
|
|
|
bool ReadBuilding(const int32_t index, t_building & building);
|
|
|
|
bool ReadBuilding(const int32_t index, t_building & building);
|
|
|
|
void FinishReadBuildings();
|
|
|
|
void FinishReadBuildings();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Effects like mist, dragonfire or dust
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitReadEffects ( uint32_t & numeffects );
|
|
|
|
bool InitReadEffects ( uint32_t & numeffects );
|
|
|
|
bool ReadEffect(const int32_t index, t_effect_df40d & effect);
|
|
|
|
bool ReadEffect(const int32_t index, t_effect_df40d & effect);
|
|
|
|
bool WriteEffect(const int32_t index, const t_effect_df40d & effect);
|
|
|
|
bool WriteEffect(const int32_t index, const t_effect_df40d & effect);
|
|
|
|
void FinishReadEffects();
|
|
|
|
void FinishReadEffects();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Trees and shrubs
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitReadVegetation( uint32_t & numplants );
|
|
|
|
bool InitReadVegetation( uint32_t & numplants );
|
|
|
|
bool ReadVegetation(const int32_t index, t_tree_desc & shrubbery);
|
|
|
|
bool ReadVegetation(const int32_t index, t_tree_desc & shrubbery);
|
|
|
|
void FinishReadVegetation();
|
|
|
|
void FinishReadVegetation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Creatures
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitReadCreatures( uint32_t & numcreatures );
|
|
|
|
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,
|
|
|
|
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 x1, const uint16_t y1,const uint16_t z1,
|
|
|
|
const uint16_t x2, const uint16_t y2,const uint16_t z2);
|
|
|
|
const uint16_t x2, const uint16_t y2,const uint16_t z2);
|
|
|
|
bool ReadCreature(const int32_t index, t_creature & furball);
|
|
|
|
bool ReadCreature(const int32_t index, t_creature & furball);
|
|
|
|
void FinishReadCreatures();
|
|
|
|
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 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);
|
|
|
|
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 );
|
|
|
|
bool InitReadNotes( uint32_t & numnotes );
|
|
|
|
|
|
|
|
/// read note from the note vector at index
|
|
|
|
bool ReadNote(const int32_t index, t_note & note);
|
|
|
|
bool ReadNote(const int32_t index, t_note & note);
|
|
|
|
|
|
|
|
/// free the note vector
|
|
|
|
void FinishReadNotes();
|
|
|
|
void FinishReadNotes();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Settlements
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitReadSettlements( uint32_t & numsettlements );
|
|
|
|
bool InitReadSettlements( uint32_t & numsettlements );
|
|
|
|
bool ReadSettlement(const int32_t index, t_settlement & settlement);
|
|
|
|
bool ReadSettlement(const int32_t index, t_settlement & settlement);
|
|
|
|
bool ReadCurrentSettlement(t_settlement & settlement);
|
|
|
|
bool ReadCurrentSettlement(t_settlement & settlement);
|
|
|
|
void FinishReadSettlements();
|
|
|
|
void FinishReadSettlements();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Hotkeys (DF's zoom locations)
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitReadHotkeys( );
|
|
|
|
bool InitReadHotkeys( );
|
|
|
|
bool ReadHotkeys(t_hotkey hotkeys[]);
|
|
|
|
bool ReadHotkeys(t_hotkey hotkeys[]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Cursor, and view coords
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool InitViewAndCursor();
|
|
|
|
bool getViewCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
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 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 getCursorCoords (int32_t &x, int32_t &y, int32_t &z);
|
|
|
|
bool setCursorCoords (const int32_t x, const int32_t y, const 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);
|
|
|
|
bool getCurrentCursorCreature (uint32_t & creature_index);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Window size in tiles
|
|
|
|
|
|
|
|
*/
|
|
|
|
bool InitViewSize();
|
|
|
|
bool InitViewSize();
|
|
|
|
bool getWindowSize(int32_t & width, int32_t & height);
|
|
|
|
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
|
|
|
|
* DF translation tables and name translation
|
|
|
|
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);
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
bool InitReadNameTables (std::vector< std::vector<std::string> > & translations , std::vector< std::vector<std::string> > & foreign_languages);
|
|
|
|
bool InitReadNameTables (std::vector< std::vector<std::string> > & translations , std::vector< std::vector<std::string> > & foreign_languages);
|
|
|
|
void FinishReadNameTables();
|
|
|
|
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);
|
|
|
|
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 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);
|
|
|
|
bool ReadItem(const uint32_t index, t_item & item);
|
|
|
|
void FinishReadItems();
|
|
|
|
void FinishReadItems();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Get the other API parts for raw access
|
|
|
|
|
|
|
|
*/
|
|
|
|
memory_info *getMemoryInfo();
|
|
|
|
memory_info *getMemoryInfo();
|
|
|
|
Process * getProcess();
|
|
|
|
Process * getProcess();
|
|
|
|
DFWindow * getWindow();
|
|
|
|
DFWindow * getWindow();
|
|
|
|