diff options
| author | Timothy Collett | 2012-09-10 11:56:23 -0400 |
|---|---|---|
| committer | Timothy Collett | 2012-09-10 11:56:23 -0400 |
| commit | ccefd02ee3921a84a4a053bb163968530b1b2346 (patch) | |
| tree | bb003b30eacde789646a25dd696cc1fd38d6dce6 /library/include | |
| parent | 96abc903abb93b7bf7418f2da3455ee6da5ad942 (diff) | |
| parent | 8ab615f6d0dce167a1952c4684922a7e48263c23 (diff) | |
| download | dfhack-ccefd02ee3921a84a4a053bb163968530b1b2346.tar.gz dfhack-ccefd02ee3921a84a4a053bb163968530b1b2346.tar.bz2 dfhack-ccefd02ee3921a84a4a053bb163968530b1b2346.tar.xz | |
Merge branch 'master' of git://github.com/angavrilov/dfhack
Diffstat (limited to 'library/include')
| -rw-r--r-- | library/include/BitArray.h | 4 | ||||
| -rw-r--r-- | library/include/DataDefs.h | 2 | ||||
| -rw-r--r-- | library/include/DataIdentity.h | 2 | ||||
| -rw-r--r-- | library/include/MemAccess.h | 3 | ||||
| -rw-r--r-- | library/include/PluginManager.h | 4 | ||||
| -rw-r--r-- | library/include/VTableInterpose.h | 14 | ||||
| -rw-r--r-- | library/include/modules/Gui.h | 22 | ||||
| -rw-r--r-- | library/include/modules/MapCache.h | 10 | ||||
| -rw-r--r-- | library/include/modules/Maps.h | 10 | ||||
| -rw-r--r-- | library/include/modules/Screen.h | 6 | ||||
| -rw-r--r-- | library/include/modules/Units.h | 20 |
11 files changed, 89 insertions, 8 deletions
diff --git a/library/include/BitArray.h b/library/include/BitArray.h index fd9bd98f..ff68ea1d 100644 --- a/library/include/BitArray.h +++ b/library/include/BitArray.h @@ -64,7 +64,7 @@ namespace DFHack if (newsize == size) return; uint8_t* mem = (uint8_t *) realloc(bits, newsize); - if(!mem) + if(!mem && newsize != 0) throw std::bad_alloc(); bits = mem; if (newsize > size) @@ -207,7 +207,7 @@ namespace DFHack else { T* mem = (T*) realloc(m_data, sizeof(T)*new_size); - if(!mem) + if(!mem && new_size != 0) throw std::bad_alloc(); m_data = mem; } diff --git a/library/include/DataDefs.h b/library/include/DataDefs.h index 6b3aeb3e..61d5dec4 100644 --- a/library/include/DataDefs.h +++ b/library/include/DataDefs.h @@ -303,7 +303,7 @@ namespace DFHack void *vtable_ptr; friend class VMethodInterposeLinkBase; - std::vector<VMethodInterposeLinkBase*> interpose_list; + std::map<int,VMethodInterposeLinkBase*> interpose_list; protected: virtual void doInit(Core *core); diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index 0f5fd9e7..21dc68d1 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -390,7 +390,7 @@ namespace df } virtual bool resize(void *ptr, int size) { - ((container*)ptr)->resize(size); + ((container*)ptr)->resize(size*8); return true; } diff --git a/library/include/MemAccess.h b/library/include/MemAccess.h index 0e5f618e..a226018a 100644 --- a/library/include/MemAccess.h +++ b/library/include/MemAccess.h @@ -281,6 +281,9 @@ namespace DFHack /// get the DF Process FilePath std::string getPath(); + /// millisecond tick count, exactly as DF uses + uint32_t getTickCount(); + /// modify permisions of memory range bool setPermisions(const t_memrange & range,const t_memrange &trgrange); diff --git a/library/include/PluginManager.h b/library/include/PluginManager.h index 25b05ad4..38f0e2e5 100644 --- a/library/include/PluginManager.h +++ b/library/include/PluginManager.h @@ -128,7 +128,9 @@ namespace DFHack { PS_UNLOADED, PS_LOADED, - PS_BROKEN + PS_BROKEN, + PS_LOADING, + PS_UNLOADING }; friend class PluginManager; friend class RPCService; diff --git a/library/include/VTableInterpose.h b/library/include/VTableInterpose.h index bb7a37ce..7ba6b67a 100644 --- a/library/include/VTableInterpose.h +++ b/library/include/VTableInterpose.h @@ -134,22 +134,32 @@ namespace DFHack 1) Allow multiple hooks into the same vmethod 2) Auto-remove hooks when a plugin is unloaded. */ + friend class virtual_identity; virtual_identity *host; // Class with the vtable int vmethod_idx; void *interpose_method; // Pointer to the code of the interposing method void *chain_mptr; // Pointer to the chain field below + bool applied; void *saved_chain; // Previous pointer to the code VMethodInterposeLinkBase *next, *prev; // Other hooks for the same method + // inherited vtable members + std::set<virtual_identity*> child_hosts; + std::set<VMethodInterposeLinkBase*> child_next; + void set_chain(void *chain); + void on_host_delete(virtual_identity *host); + + VMethodInterposeLinkBase *get_first_interpose(virtual_identity *id); + void find_child_hosts(virtual_identity *cur, void *vmptr); public: VMethodInterposeLinkBase(virtual_identity *host, int vmethod_idx, void *interpose_method, void *chain_mptr); ~VMethodInterposeLinkBase(); - bool is_applied() { return saved_chain != NULL; } - bool apply(); + bool is_applied() { return applied; } + bool apply(bool enable = true); void remove(); }; diff --git a/library/include/modules/Gui.h b/library/include/modules/Gui.h index 273d84ce..97e8bd42 100644 --- a/library/include/modules/Gui.h +++ b/library/include/modules/Gui.h @@ -32,6 +32,7 @@ distribution. #include "DataDefs.h" #include "df/init.h" #include "df/ui.h" +#include "df/announcement_type.h" namespace df { struct viewscreen; @@ -92,11 +93,32 @@ namespace DFHack // Show a plain announcement, or a titan-style popup message DFHACK_EXPORT void showAnnouncement(std::string message, int color = 7, bool bright = true); + DFHACK_EXPORT void showZoomAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true); DFHACK_EXPORT void showPopupAnnouncement(std::string message, int color = 7, bool bright = true); + // Show an announcement with effects determined by announcements.txt + DFHACK_EXPORT void showAutoAnnouncement(df::announcement_type type, df::coord pos, std::string message, int color = 7, bool bright = true); + /* * Cursor and window coords */ + DFHACK_EXPORT df::coord getViewportPos(); + DFHACK_EXPORT df::coord getCursorPos(); + + static const int AREA_MAP_WIDTH = 23; + static const int MENU_WIDTH = 30; + + struct DwarfmodeDims { + int map_x1, map_x2, menu_x1, menu_x2, area_x1, area_x2; + int y1, y2; + bool menu_on, area_on, menu_forced; + }; + + DFHACK_EXPORT DwarfmodeDims getDwarfmodeViewDims(); + + DFHACK_EXPORT void resetDwarfmodeView(bool pause = false); + DFHACK_EXPORT bool revealInDwarfmodeMap(df::coord pos, bool center = false); + DFHACK_EXPORT bool getViewCoords (int32_t &x, int32_t &y, int32_t &z); DFHACK_EXPORT bool setViewCoords (const int32_t x, const int32_t y, const int32_t z); diff --git a/library/include/modules/MapCache.h b/library/include/modules/MapCache.h index 109a20a4..262e70bb 100644 --- a/library/include/modules/MapCache.h +++ b/library/include/modules/MapCache.h @@ -253,6 +253,8 @@ public: bool is_valid() { return valid; } df::map_block *getRaw() { return block; } + bool Allocate(); + MapCache *getParent() { return parent; } private: @@ -262,6 +264,8 @@ private: MapCache *parent; df::map_block *block; + void init(); + int biomeIndexAt(df::coord2d p); bool valid; @@ -347,6 +351,12 @@ class DFHACK_EXPORT MapCache return BlockAt(df::coord(coord.x>>4,coord.y>>4,coord.z)); } + bool ensureBlockAt(df::coord coord) + { + Block *b = BlockAtTile(coord); + return b ? b->Allocate() : false; + } + df::tiletype baseTiletypeAt (DFCoord tilecoord) { Block *b = BlockAtTile(tilecoord); diff --git a/library/include/modules/Maps.h b/library/include/modules/Maps.h index e63eef73..869b2158 100644 --- a/library/include/modules/Maps.h +++ b/library/include/modules/Maps.h @@ -50,6 +50,7 @@ distribution. #include "df/tile_dig_designation.h" #include "df/tile_traffic.h" #include "df/feature_init.h" +#include "df/flow_type.h" /** * \defgroup grp_maps Maps module and its types @@ -232,14 +233,19 @@ extern DFHACK_EXPORT void getSize(uint32_t& x, uint32_t& y, uint32_t& z); /// get the position of the map on world map extern DFHACK_EXPORT void getPosition(int32_t& x, int32_t& y, int32_t& z); +extern DFHACK_EXPORT bool isValidTilePos(int32_t x, int32_t y, int32_t z); +inline bool isValidTilePos(df::coord pos) { return isValidTilePos(pos.x, pos.y, pos.z); } + /** * Get the map block or NULL if block is not valid */ extern DFHACK_EXPORT df::map_block * getBlock (int32_t blockx, int32_t blocky, int32_t blockz); extern DFHACK_EXPORT df::map_block * getTileBlock (int32_t x, int32_t y, int32_t z); +extern DFHACK_EXPORT df::map_block * ensureTileBlock (int32_t x, int32_t y, int32_t z); inline df::map_block * getBlock (df::coord pos) { return getBlock(pos.x, pos.y, pos.z); } inline df::map_block * getTileBlock (df::coord pos) { return getTileBlock(pos.x, pos.y, pos.z); } +inline df::map_block * ensureTileBlock (df::coord pos) { return ensureTileBlock(pos.x, pos.y, pos.z); } extern DFHACK_EXPORT df::tiletype *getTileType(int32_t x, int32_t y, int32_t z); extern DFHACK_EXPORT df::tile_designation *getTileDesignation(int32_t x, int32_t y, int32_t z); @@ -258,7 +264,7 @@ inline df::tile_occupancy *getTileOccupancy(df::coord pos) { /** * Returns biome info about the specified world region. */ -DFHACK_EXPORT df::world_data::T_region_map *getRegionBiome(df::coord2d rgn_pos); +DFHACK_EXPORT df::region_map_entry *getRegionBiome(df::coord2d rgn_pos); /** * Returns biome world region coordinates for the given tile within given block. @@ -272,6 +278,8 @@ inline df::coord2d getTileBiomeRgn(df::coord pos) { // Enables per-frame updates for liquid flow and/or temperature. DFHACK_EXPORT void enableBlockUpdates(df::map_block *blk, bool flow = false, bool temperature = false); +DFHACK_EXPORT df::flow_info *spawnFlow(df::coord pos, df::flow_type type, int mat_type = 0, int mat_index = -1, int density = 100); + /// sorts the block event vector into multiple vectors by type /// mineral veins, what's under ice, blood smears and mud extern DFHACK_EXPORT bool SortBlockEvents(df::map_block *block, diff --git a/library/include/modules/Screen.h b/library/include/modules/Screen.h index 492e1eec..4f47205f 100644 --- a/library/include/modules/Screen.h +++ b/library/include/modules/Screen.h @@ -65,6 +65,9 @@ namespace DFHack } tile_mode; int8_t tile_fg, tile_bg; + bool valid() const { return tile >= 0; } + bool empty() const { return ch == 0 && tile == 0; } + Pen(char ch = 0, int8_t fg = 7, int8_t bg = 0, int tile = 0, bool color_tile = false) : ch(ch), fg(fg&7), bg(bg), bold(!!(fg&8)), tile(tile), tile_mode(color_tile ? CharColor : AsIs), tile_fg(0), tile_bg(0) @@ -92,6 +95,9 @@ namespace DFHack /// Paint one screen tile with the given pen DFHACK_EXPORT bool paintTile(const Pen &pen, int x, int y); + /// Retrieves one screen tile from the buffer + DFHACK_EXPORT Pen readTile(int x, int y); + /// Paint a string onto the screen. Ignores ch and tile of pen. DFHACK_EXPORT bool paintString(const Pen &pen, int x, int y, const std::string &text); diff --git a/library/include/modules/Units.h b/library/include/modules/Units.h index 9003dc3a..65f0b58a 100644 --- a/library/include/modules/Units.h +++ b/library/include/modules/Units.h @@ -32,6 +32,10 @@ distribution. #include "modules/Items.h" #include "DataDefs.h" #include "df/unit.h" +#include "df/misc_trait_type.h" +#include "df/physical_attribute_type.h" +#include "df/mental_attribute_type.h" +#include "df/job_skill.h" namespace df { @@ -41,6 +45,7 @@ namespace df struct historical_entity; struct entity_position_assignment; struct entity_position; + struct unit_misc_trait; } /** @@ -208,6 +213,18 @@ DFHACK_EXPORT df::language_name *getVisibleName(df::unit *unit); DFHACK_EXPORT df::assumed_identity *getIdentity(df::unit *unit); DFHACK_EXPORT df::nemesis_record *getNemesis(df::unit *unit); +DFHACK_EXPORT bool isHidingCurse(df::unit *unit); +DFHACK_EXPORT int getPhysicalAttrValue(df::unit *unit, df::physical_attribute_type attr); +DFHACK_EXPORT int getMentalAttrValue(df::unit *unit, df::mental_attribute_type attr); + +DFHACK_EXPORT bool isCrazed(df::unit *unit); +DFHACK_EXPORT bool isOpposedToLife(df::unit *unit); +DFHACK_EXPORT bool hasExtravision(df::unit *unit); +DFHACK_EXPORT bool isBloodsucker(df::unit *unit); +DFHACK_EXPORT bool isMischievous(df::unit *unit); + +DFHACK_EXPORT df::unit_misc_trait *getMiscTrait(df::unit *unit, df::misc_trait_type type, bool create = false); + DFHACK_EXPORT bool isDead(df::unit *unit); DFHACK_EXPORT bool isAlive(df::unit *unit); DFHACK_EXPORT bool isSane(df::unit *unit); @@ -216,6 +233,9 @@ DFHACK_EXPORT bool isDwarf(df::unit *unit); DFHACK_EXPORT double getAge(df::unit *unit, bool true_age = false); +DFHACK_EXPORT int getEffectiveSkill(df::unit *unit, df::job_skill skill_id); +DFHACK_EXPORT int computeMovementSpeed(df::unit *unit); + struct NoblePosition { df::historical_entity *entity; df::entity_position_assignment *assignment; |
