diff --git a/dfhack/modules/Creatures-data.h b/dfhack/modules/Creatures-data.h new file mode 100644 index 000000000..0a11df357 --- /dev/null +++ b/dfhack/modules/Creatures-data.h @@ -0,0 +1,4 @@ +bool creaturesInited; +Creatures::creature_offsets creatures; +uint32_t creature_module; +DfVector *p_cre; \ No newline at end of file diff --git a/dfhack/modules/Creatures-proc.h b/dfhack/modules/Creatures-proc.h new file mode 100644 index 000000000..9b980903b --- /dev/null +++ b/dfhack/modules/Creatures-proc.h @@ -0,0 +1,14 @@ +/* + * Creatures + */ +bool InitReadCreatures( uint32_t & numcreatures ); + +// 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(); +/// write labors of a creature (for Dwarf Therapist) +bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]); \ No newline at end of file diff --git a/dfhack/modules/Gui-data.h b/dfhack/modules/Gui-data.h new file mode 100644 index 000000000..2c1fcb058 --- /dev/null +++ b/dfhack/modules/Gui-data.h @@ -0,0 +1,4 @@ +uint32_t pause_state_offset; +uint32_t view_screen_offset; +uint32_t current_cursor_creature_offset; +uint32_t current_menu_state_offset; \ No newline at end of file diff --git a/dfhack/modules/Gui-proc.h b/dfhack/modules/Gui-proc.h new file mode 100644 index 000000000..e964520ba --- /dev/null +++ b/dfhack/modules/Gui-proc.h @@ -0,0 +1,10 @@ +/* +* Query the DF's GUI state +*/ +bool InitReadGuiState(); +///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(); \ No newline at end of file diff --git a/dfhack/modules/Maps-data.h b/dfhack/modules/Maps-data.h new file mode 100644 index 000000000..9e187eaab --- /dev/null +++ b/dfhack/modules/Maps-data.h @@ -0,0 +1,17 @@ +uint32_t * block; +uint32_t x_block_count, y_block_count, z_block_count; +uint32_t regionX, regionY, regionZ; +uint32_t worldSizeX, worldSizeY; + +uint32_t tile_type_offset; +uint32_t designation_offset; +uint32_t block_flags_offset; + +uint32_t veinvector; +uint32_t vein_mineral_vptr; +uint32_t vein_ice_vptr; +uint32_t vein_spatter_vptr; +uint32_t maps_module; + +//uint32_t biome_stuffs; +//vector v_geology[eBiomeCount]; \ No newline at end of file diff --git a/dfhack/modules/Maps-proc.h b/dfhack/modules/Maps-proc.h new file mode 100644 index 000000000..e3db2105e --- /dev/null +++ b/dfhack/modules/Maps-proc.h @@ -0,0 +1,80 @@ +// read region surroundings, get their vectors of geolayers so we can do translation (or just hand the translation table to the client) +// returns an array of 9 vectors of indices into stone matgloss +/** + Method for reading the geological surrounding of the currently loaded region. + assign is a reference to an array of nine vectors of unsigned words that are to be filled with the data + array is indexed by the BiomeOffset enum + + I omitted resolving the layer matgloss in this API, because it would + introduce overhead by calling some method for each tile. You have to do it + yourself. First get the stuff from ReadGeology and then for each block get + the RegionOffsets. For each tile get the real region from RegionOffsets and + cross-reference it with the geology stuff (region -- array of vectors, depth -- + vector). I'm thinking about turning that Geology stuff into a + two-dimensional array with static size. + + this is the algorithm for applying matgloss: + void DfMap::applyGeoMatgloss(Block * b) + { + // load layer matgloss + for(int x_b = 0; x_b < BLOCK_SIZE; x_b++) + { + for(int y_b = 0; y_b < BLOCK_SIZE; y_b++) + { + int geolayer = b->designation[x_b][y_b].bits.geolayer_index; + int biome = b->designation[x_b][y_b].bits.biome; + b->material[x_b][y_b].type = Mat_Stone; + b->material[x_b][y_b].index = v_geology[b->RegionOffsets[biome]][geolayer]; + } + } + } + */ +bool ReadGeology( std::vector < std::vector >& assign ); + +/* + * BLOCK DATA + */ +/// allocate and read pointers to map blocks +bool InitMap(); +/// destroy the mapblock cache +bool DestroyMap(); +/// get size of the map in tiles +void getSize(uint32_t& x, uint32_t& y, uint32_t& z); + +/** + * Return false/0 on failure, buffer allocated by client app, 256 items long + */ +bool isValidBlock(uint32_t blockx, uint32_t blocky, uint32_t blockz); +/** + * Get the address of a block or 0 if block is not valid + */ +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); + +/// 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); + +/// 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); + +/// 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/write the block flags +bool ReadBlockFlags(uint32_t blockx, uint32_t blocky, uint32_t blockz, t_blockflags &blockflags); +bool WriteBlockFlags(uint32_t blockx, uint32_t blocky, uint32_t blockz, t_blockflags blockflags); + +/// 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 & veins, std::vector & ices); \ No newline at end of file diff --git a/dfhack/modules/Materials-data.h b/dfhack/modules/Materials-data.h new file mode 100644 index 000000000..e69de29bb diff --git a/dfhack/modules/Materials-proc.h b/dfhack/modules/Materials-proc.h new file mode 100644 index 000000000..e67a51b11 --- /dev/null +++ b/dfhack/modules/Materials-proc.h @@ -0,0 +1,11 @@ +/* +* 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 +*/ +bool ReadInorganicMaterials (std::vector & output); +bool ReadOrganicMaterials (std::vector & output); +bool ReadWoodMaterials (std::vector & output); +bool ReadPlantMaterials (std::vector & output); +bool ReadPlantMaterials (std::vector & output); +bool ReadCreatureTypes (std::vector & output); \ No newline at end of file diff --git a/dfhack/modules/Position-data.h b/dfhack/modules/Position-data.h new file mode 100644 index 000000000..f781e332e --- /dev/null +++ b/dfhack/modules/Position-data.h @@ -0,0 +1,6 @@ +uint32_t window_x_offset; +uint32_t window_y_offset; +uint32_t window_z_offset; +uint32_t cursor_xyz_offset; +uint32_t window_dims_offset; +bool cursorWindowInited; \ No newline at end of file diff --git a/dfhack/modules/Position-proc.h b/dfhack/modules/Position-proc.h new file mode 100644 index 000000000..9ef54b5a2 --- /dev/null +++ b/dfhack/modules/Position-proc.h @@ -0,0 +1,17 @@ +/* +* Cursor and window 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); + +/* +* Window size in tiles +*/ +bool InitViewSize(); +bool getWindowSize(int32_t & width, int32_t & height); +/// get the creature vector index of the creature currently under DF' cursor +bool getCurrentCursorCreature (uint32_t & creature_index);