diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 411cbb15e..767cbff6d 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -52,7 +52,6 @@ include/dfhack/modules/Gui.h include/dfhack/modules/Items.h include/dfhack/modules/Maps.h include/dfhack/modules/Materials.h -include/dfhack/modules/Position.h include/dfhack/modules/Translation.h include/dfhack/modules/Vegetation.h include/dfhack/modules/WindowIO.h diff --git a/library/DFContext.cpp b/library/DFContext.cpp index 3fee55d71..435776296 100644 --- a/library/DFContext.cpp +++ b/library/DFContext.cpp @@ -163,7 +163,6 @@ MODULE_GETTER(Maps); MODULE_GETTER(Gui); MODULE_GETTER(WindowIO); MODULE_GETTER(World); -MODULE_GETTER(Position); MODULE_GETTER(Materials); MODULE_GETTER(Items); MODULE_GETTER(Translation); diff --git a/library/DFProcess-linux.cpp b/library/DFProcess-linux.cpp index d6d21edfa..b707ab972 100644 --- a/library/DFProcess-linux.cpp +++ b/library/DFProcess-linux.cpp @@ -207,12 +207,10 @@ bool NormalProcess::resume() perror("ptrace resume error"); return false; } - int status; suspended = false; return true; } - bool NormalProcess::attach() { int status; diff --git a/library/include/dfhack/DFTypes.h b/library/include/dfhack/DFTypes.h index 52c7826b7..3513d5732 100644 --- a/library/include/dfhack/DFTypes.h +++ b/library/include/dfhack/DFTypes.h @@ -168,12 +168,6 @@ union t_itemflags naked_itemflags bits; }; -//cooked -struct t_viewscreen -{ - int32_t type; - //There is more info in these objects, but I don't know what it is yet -}; struct t_note { diff --git a/library/include/dfhack/modules/Constructions.h b/library/include/dfhack/modules/Constructions.h index e775df80a..deb30ee9b 100644 --- a/library/include/dfhack/modules/Constructions.h +++ b/library/include/dfhack/modules/Constructions.h @@ -31,11 +31,11 @@ namespace DFHack struct t_construction { //0 - uint16_t x; - uint16_t y; + uint16_t x; /*!< X coordinate */ + uint16_t y; /*!< Y coordinate */ // 4 - uint16_t z; - e_construction_base form : 16; + uint16_t z; /*!< Z coordinate */ + e_construction_base form : 16; /*!< type of item the construction is made of */ // 8 uint16_t unk_8; // = -1 in many cases uint16_t mat_type; diff --git a/library/include/dfhack/modules/Creatures.h b/library/include/dfhack/modules/Creatures.h index a4d58d921..4f1ee296f 100644 --- a/library/include/dfhack/modules/Creatures.h +++ b/library/include/dfhack/modules/Creatures.h @@ -6,187 +6,111 @@ #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" #include "dfhack/modules/Items.h" +/** + * \defgroup grp_creatures Creatures module parts + * @ingroup grp_modules + */ namespace DFHack { - /* - bits: - - 0 Can the dwarf move or are they waiting for their movement timer - 1 Dead (might also be set for incoming/leaving critters that are alive) - 2 Currently in mood - 3 Had a mood - 4 "marauder" -- wide class of invader/inside creature attackers - 5 Drowning - 6 Active merchant - 7 "forest" (used for units no longer linked to merchant/diplomacy, they just try to leave mostly) - 8 Left (left the map) - 9 Rider - 10 Incoming - 11 Diplomat - 12 Zombie - 13 Skeleton - 14 Can swap tiles during movement (prevents multiple swaps) - 15 On the ground (can be conscious) - 16 Projectile - 17 Active invader (for organized ones) - 18 Hidden in ambush - 19 Invader origin (could be inactive and fleeing) - 20 Will flee if invasion turns around - 21 Active marauder/invader moving inward - 22 Marauder resident/invader moving in all the way - 23 Check against flows next time you get a chance - 24 Ridden - 25 Caged - 26 Tame - 27 Chained - 28 Royal guard - 29 Fortress guard - 30 Suppress wield for beatings/etc - 31 Is an important historical figure - */ - - struct naked_creaturflags1 - { - unsigned int move_state : 1; // Can the dwarf move or are they waiting for their movement timer - unsigned int dead : 1; // might also be set for incoming/leaving critters that are alive - unsigned int has_mood : 1; // Currently in mood - unsigned int had_mood : 1; // Had a mood - - unsigned int marauder : 1; // wide class of invader/inside creature attackers - unsigned int drowning : 1; - unsigned int merchant : 1; // active merchant - unsigned int forest : 1; // used for units no longer linked to merchant/diplomacy, they just try to leave mostly - - unsigned int left : 1; // left the map - unsigned int rider : 1; - unsigned int incoming : 1; - unsigned int diplomat : 1; - - unsigned int zombie : 1; - unsigned int skeleton : 1; - unsigned int can_swap : 1; // Can swap tiles during movement (prevents multiple swaps) - unsigned int on_ground : 1; // can be conscious - - unsigned int projectile : 1; - unsigned int active_invader : 1; // for organized ones - unsigned int hidden_in_ambush : 1; - unsigned int invader_origin : 1; // could be inactive and fleeing - - unsigned int coward : 1; // Will flee if invasion turns around - unsigned int hidden_ambusher : 1; // maybe - unsigned int invades : 1; // Active marauder/invader moving inward - unsigned int check_flows : 1; // Check against flows next time you get a chance - - // 0100 0000 - 8000 0000 - unsigned int ridden : 1; - unsigned int caged : 1; - unsigned int tame : 1; - unsigned int chained : 1; - - unsigned int royal_guard : 1; - unsigned int fortress_guard : 1; - unsigned int suppress_wield : 1; // Suppress wield for beatings/etc - unsigned int important_historical_figure : 1; // Is an important historical figure - }; - + /** + * easy access to first crature flags block + * \ingroup grp_creatures + */ union t_creaturflags1 { - uint32_t whole; - naked_creaturflags1 bits; - }; - - /* - bits: - - 0 Swimming - 1 Play combat for sparring - 2 Do not notify about level gains (for embark etc) - 3 Unused - - 4 Nerves calculated - 5 Body part info calculated - 6 Is important historical figure (slight variation) - 7 Has been killed by kill function (slightly different from dead, not necessarily violent death) - - 8 Must be forgotten by forget function (just cleanup) - 9 Must be deleted (cleanup) - 10 Recently forgotten (cleanup) - 11 Offered for trade - - 12 Trade resolved - 13 Has breaks - 14 Gutted - 15 Circulatory spray - - 16 Locked in for trading (it's a projectile on the other set of flags, might be what the flying was) - 17 Marked for slaughter - 18 Underworld creature - 19 Current resident - - 20 Marked for special cleanup as unused load from unit block on disk - 21 Insulation from clothing calculated - 22 Uninvited guest - 23 Visitor - - 24 Inventory order calculated - 25 Vision -- have good part - 26 Vision -- have damaged part - 27 Vision -- have missing part - - 28 Breathing -- have good part - 29 Breathing -- having a problem - 30 Roaming wilderness population source - 31 Roaming wilderness population source -- not a map feature - */ - struct naked_creaturflags2 - { - unsigned int swimming : 1; - unsigned int sparring : 1; - unsigned int no_notify : 1; // Do not notify about level gains (for embark etc) - unsigned int unused : 1; - - unsigned int calculated_nerves : 1; - unsigned int calculated_bodyparts : 1; - unsigned int important_historical_figure : 1; // slight variation - unsigned int killed : 1; // killed by kill() function - - unsigned int cleanup_1 : 1; // Must be forgotten by forget function (just cleanup) - unsigned int cleanup_2 : 1; // Must be deleted (cleanup) - unsigned int cleanup_3 : 1; // Recently forgotten (cleanup) - unsigned int for_trade : 1; // Offered for trade - - unsigned int trade_resolved : 1; - unsigned int has_breaks : 1; - unsigned int gutted : 1; - unsigned int circulatory_spray : 1; - - unsigned int locked_in_for_trading : 1; - unsigned int slaughter : 1; // marked for slaughter - unsigned int underworld : 1; // Underworld creature - unsigned int resident : 1; // Current resident - - unsigned int cleanup_4 : 1; // Marked for special cleanup as unused load from unit block on disk - unsigned int calculated_insulation : 1; // Insulation from clothing calculated - unsigned int visitor_uninvited : 1; // Uninvited guest - unsigned int visitor : 1; // visitor - - unsigned int calculated_inventory : 1; // Inventory order calculated - unsigned int vision_good : 1; // Vision -- have good part - unsigned int vision_damaged : 1; // Vision -- have damaged part - unsigned int vision_missing : 1; // Vision -- have missing part - - unsigned int breathing_good : 1; // Breathing -- have good part - unsigned int breathing_problem : 1; // Breathing -- having a problem - unsigned int roaming_wilderness_population_source : 1; - unsigned int roaming_wilderness_population_source_not_a_map_feature : 1; + uint32_t whole;/*!< Access all flags as a single 32bit number. */ + struct + { + unsigned int move_state : 1; /*!< 0 : Can the dwarf move or are they waiting for their movement timer */ + unsigned int dead : 1; /*!< 1 : Dead (might also be set for incoming/leaving critters that are alive) */ + unsigned int has_mood : 1; /*!< 2 : Currently in mood */ + unsigned int had_mood : 1; /*!< 3 : Had a mood already */ + + unsigned int marauder : 1; /*!< 4 : wide class of invader/inside creature attackers */ + unsigned int drowning : 1; /*!< 5 : Is currently drowning */ + unsigned int merchant : 1; /*!< 6 : An active merchant */ + unsigned int forest : 1; /*!< 7 : used for units no longer linked to merchant/diplomacy, they just try to leave mostly */ + + unsigned int left : 1; /*!< 8 : left the map */ + unsigned int rider : 1; /*!< 9 : Is riding an another creature */ + unsigned int incoming : 1; /*!< 10 */ + unsigned int diplomat : 1; /*!< 11 */ + + unsigned int zombie : 1; /*!< 12 */ + unsigned int skeleton : 1; /*!< 13 */ + unsigned int can_swap : 1; /*!< 14: Can swap tiles during movement (prevents multiple swaps) */ + unsigned int on_ground : 1; /*!< 15: The creature is laying on the floor, can be conscious */ + + unsigned int projectile : 1; /*!< 16: Launched into the air? Funny. */ + unsigned int active_invader : 1; /*!< 17: Active invader (for organized ones) */ + unsigned int hidden_in_ambush : 1; /*!< 18 */ + unsigned int invader_origin : 1; /*!< 19: Invader origin (could be inactive and fleeing) */ + + unsigned int coward : 1; /*!< 20: Will flee if invasion turns around */ + unsigned int hidden_ambusher : 1; /*!< 21: Active marauder/invader moving inward? */ + unsigned int invades : 1; /*!< 22: Marauder resident/invader moving in all the way */ + unsigned int check_flows : 1; /*!< 23: Check against flows next time you get a chance */ + + unsigned int ridden : 1; /*!< 24*/ + unsigned int caged : 1; /*!< 25*/ + unsigned int tame : 1; /*!< 26*/ + unsigned int chained : 1; /*!< 27*/ + + unsigned int royal_guard : 1; /*!< 28*/ + unsigned int fortress_guard : 1; /*!< 29*/ + unsigned int suppress_wield : 1; /*!< 30: Suppress wield for beatings/etc */ + unsigned int important_historical_figure : 1; /*!< 31: Is an important historical figure */ + } bits; }; union t_creaturflags2 { - uint32_t whole; - naked_creaturflags2 bits; + uint32_t whole; /*!< Access all flags as a single 32bit number. */ + struct + { + unsigned int swimming : 1; + unsigned int sparring : 1; + unsigned int no_notify : 1; /*!< Do not notify about level gains (for embark etc)*/ + unsigned int unused : 1; + + unsigned int calculated_nerves : 1; + unsigned int calculated_bodyparts : 1; + unsigned int important_historical_figure : 1; /*!< Is important historical figure (slight variation)*/ + unsigned int killed : 1; /*!< Has been killed by kill function (slightly different from dead, not necessarily violent death)*/ + + unsigned int cleanup_1 : 1; /*!< Must be forgotten by forget function (just cleanup) */ + unsigned int cleanup_2 : 1; /*!< Must be deleted (cleanup) */ + unsigned int cleanup_3 : 1; /*!< Recently forgotten (cleanup) */ + unsigned int for_trade : 1; /*!< Offered for trade */ + + unsigned int trade_resolved : 1; + unsigned int has_breaks : 1; + unsigned int gutted : 1; + unsigned int circulatory_spray : 1; + + unsigned int locked_in_for_trading : 1; /*!< Locked in for trading (it's a projectile on the other set of flags, might be what the flying was) */ + unsigned int slaughter : 1; /*!< marked for slaughter */ + unsigned int underworld : 1; /*!< Underworld creature */ + unsigned int resident : 1; /*!< Current resident */ + + unsigned int cleanup_4 : 1; /*!< Marked for special cleanup as unused load from unit block on disk */ + unsigned int calculated_insulation : 1; /*!< Insulation from clothing calculated */ + unsigned int visitor_uninvited : 1; /*!< Uninvited guest */ + unsigned int visitor : 1; /*!< visitor */ + + unsigned int calculated_inventory : 1; /*!< Inventory order calculated */ + unsigned int vision_good : 1; /*!< Vision -- have good part */ + unsigned int vision_damaged : 1; /*!< Vision -- have damaged part */ + unsigned int vision_missing : 1; /*!< Vision -- have missing part */ + + unsigned int breathing_good : 1; /*!< Breathing -- have good part */ + unsigned int breathing_problem : 1; /*!< Breathing -- having a problem */ + unsigned int roaming_wilderness_population_source : 1; + unsigned int roaming_wilderness_population_source_not_a_map_feature : 1; + } bits; }; + // FIXME: WTF IS THIS SHIT? /* struct t_labor { @@ -255,13 +179,18 @@ namespace DFHack } }; */ - + /** + * \ingroup grp_creatures + */ struct t_skill { uint32_t id; uint32_t rating; uint32_t experience; }; + /** + * \ingroup grp_creatures + */ struct t_job { bool active; @@ -269,6 +198,9 @@ namespace DFHack uint8_t jobType; uint32_t occupationPtr; }; + /** + * \ingroup grp_creatures + */ struct t_like { int16_t type; @@ -279,12 +211,15 @@ namespace DFHack }; - // FIXME: define in Memory.xml instead? + // FIXME: THIS IS VERY, VERY BAD. #define NUM_CREATURE_TRAITS 30 #define NUM_CREATURE_LABORS 102 #define NUM_CREATURE_MENTAL_ATTRIBUTES 13 #define NUM_CREATURE_PHYSICAL_ATTRIBUTES 6 - + /** + * structure for holding a DF creature's soul + * \ingroup grp_creatures + */ struct t_soul { uint8_t numSkills; @@ -310,7 +245,10 @@ namespace DFHack }; #define MAX_COLORS 15 - + /** + * structure for holding a DF creature + * \ingroup grp_creatures + */ struct t_creature { uint32_t origin; @@ -358,7 +296,11 @@ namespace DFHack }; class DFContextShared; - struct t_creature; + /** + * The Creatures module - allows reading all non-vermin creatures and their properties + * \ingroup grp_modules + * \ingroup grp_creatures + */ class DFHACK_EXPORT Creatures : public Module { public: diff --git a/library/include/dfhack/modules/Gui.h b/library/include/dfhack/modules/Gui.h index 6ac91f35c..f24cb9486 100644 --- a/library/include/dfhack/modules/Gui.h +++ b/library/include/dfhack/modules/Gui.h @@ -1,38 +1,95 @@ #ifndef CL_MOD_GUI #define CL_MOD_GUI -/* -* Gui: Query the DF's GUI state -*/ #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" +/** + * \defgroup grp_gui query DF's GUI state + * @ingroup grp_modules + */ + namespace DFHack { class DFContextShared; - struct t_viewscreen; + /** + * \ingroup grp_gui + */ + struct t_viewscreen + { + int32_t type; + //There is more info in these objects, but I don't know what it is yet + }; + #define NUM_HOTKEYS 16 + /** + * \ingroup grp_gui + */ + struct t_hotkey + { + char name[10]; + int16_t mode; + int32_t x; + int32_t y; + int32_t z; + }; + /** + * \ingroup grp_gui + */ + struct t_screen + { + uint8_t symbol; + uint8_t foreground; + uint8_t background; + uint8_t bright; + uint8_t gtile; + uint8_t grayscale; + }; + /** + * The Gui module + * \ingroup grp_modules + * \ingroup grp_gui + */ class DFHACK_EXPORT Gui: public Module { public: - + Gui(DFHack::DFContextShared * d); ~Gui(); bool Start(); bool Finish(); + /* + * Cursor and window coords + */ + 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); + /* + * Hotkeys (DF's zoom locations) + */ + bool ReadHotkeys(t_hotkey hotkeys[]); + + /* + * Window size in tiles + */ + bool getWindowSize(int32_t & width, int32_t & height); + + /* + * Screen tiles + */ + bool getScreenTiles(int32_t width, int32_t height, t_screen screen[]); - ///true if paused, false if not - bool ReadPauseState(); - ///true if paused, false if not - void SetPauseState(bool paused); /// 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(); - + private: struct Private; Private *d; }; + typedef class Gui Position; } #endif diff --git a/library/include/dfhack/modules/Maps.h b/library/include/dfhack/modules/Maps.h index ce27a1da8..98b0bffe5 100644 --- a/library/include/dfhack/modules/Maps.h +++ b/library/include/dfhack/modules/Maps.h @@ -8,12 +8,20 @@ #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" #include "Vegetation.h" + +/** + * \defgroup grp_maps Maps module and its types + * @ingroup grp_modules + */ + namespace DFHack { /*************************************************************************** T Y P E S ***************************************************************************/ - + /** + * \ingroup grp_maps + */ enum e_feature { feature_Other, @@ -21,9 +29,16 @@ namespace DFHack feature_Underworld, feature_Hell_Temple }; - - extern DFHACK_EXPORT const char * sa_feature(int index); - + /** + * Function for translating feature index to its name + * \ingroup grp_maps + */ + extern DFHACK_EXPORT const char * sa_feature(e_feature index); + + /** + * Class for holding a world coordinate. Can do math with coordinates and can be used as an index for std::map + * \ingroup grp_maps + */ class DFCoord { public: @@ -82,9 +97,15 @@ namespace DFHack uint64_t comparate; }; }; - + /** + * \ingroup grp_maps + */ typedef DFCoord planecoord; + /** + * A local or global map feature + * \ingroup grp_maps + */ struct t_feature { e_feature type; @@ -98,7 +119,10 @@ namespace DFHack uint32_t origin; }; - /// mineral vein object + /** + * mineral vein object - bitmap with a material type + * \ingroup grp_maps + */ struct t_vein { uint32_t vtable; @@ -112,7 +136,10 @@ namespace DFHack uint32_t address_of; }; - /// stores what tiles should appear when the ice melts + /** + * stores what tiles should appear when the ice melts - bitmap of material types + * \ingroup grp_maps + */ struct t_frozenliquidvein { uint32_t vtable; @@ -122,8 +149,12 @@ namespace DFHack uint32_t address_of; }; - /// a 'spattervein' defines what coverings the individual map tiles have (snow, blood, etc) - /// @see PrintSplatterType in DFMiscUtils.h -- incomplete, but illustrative + /** + * a 'spattervein' defines what coverings the individual map tiles have (snow, blood, etc) + * bitmap of intensity with matrial type + * \ingroup grp_maps + * @see PrintSplatterType + */ struct t_spattervein { uint32_t vtable; @@ -139,7 +170,11 @@ namespace DFHack /// this is NOT part of the DF vein, but an address of the vein as seen by DFhack. uint32_t address_of; }; - + /** + * a 'grass vein' defines the grass coverage of a map block + * bitmap of density (max = 100) with plant material type + * \ingroup grp_maps + */ struct t_grassvein { uint32_t vtable; @@ -150,7 +185,10 @@ namespace DFHack /// this is NOT part of the DF vein, but an address of the vein as seen by DFhack. uint32_t address_of; }; - + /** + * defines the world constructions present. The material member is a mystery. + * \ingroup grp_maps + */ struct t_worldconstruction { uint32_t vtable; @@ -162,6 +200,9 @@ namespace DFHack uint32_t address_of; }; + /** + * \ingroup grp_maps + */ enum BiomeOffset { eNorthWest, @@ -176,6 +217,9 @@ namespace DFHack eBiomeCount }; + /** + * \ingroup grp_maps + */ enum e_traffic { traffic_normal, @@ -184,7 +228,10 @@ namespace DFHack traffic_restricted }; - /// type of a designation for a tile + /** + * type of a designation for a tile + * \ingroup grp_maps + */ enum e_designation { /// no designation @@ -204,13 +251,21 @@ namespace DFHack /// whatever. for completenes I guess designation_7 }; - + + /** + * type of liquid in a tile + * \ingroup grp_maps + */ enum e_liquidtype { liquid_water, liquid_magma }; + /** + * designation bit field + * \ingroup grp_maps + */ struct naked_designation { unsigned int flow_size : 3; // how much liquid is here? @@ -254,16 +309,21 @@ namespace DFHack unsigned int water_salt : 1; // e_liquidcharacter liquid_character : 2; }; - + /** + * designation bit field wrapper + * \ingroup grp_maps + */ union t_designation { uint32_t whole; naked_designation bits; }; - // occupancy flags (rat,dwarf,horse,built wall,not build wall,etc) - //FIXME: THIS IS NOT VALID FOR 31.xx versions!!!! - struct naked_occupancy + /** + * occupancy flags (rat,dwarf,horse,built wall,not build wall,etc) + * \ingroup grp_maps + */ + struct naked_occupancy //FIXME: THIS IS NOT VALID FOR 31.xx versions!!!! { // building type... should be an enum? // 7 = door @@ -303,28 +363,20 @@ namespace DFHack unsigned int snow : 1; */ }; - - struct naked_occupancy_grouped - { - unsigned int building : 3; - /// the tile contains a standing? creature - unsigned int unit : 1; - /// the tile contains a prone creature - unsigned int unit_grounded : 1; - /// the tile contains an item - unsigned int item : 1; - /// changed - unsigned int unknown : 26; - }; - + /** + * occupancy flags (rat,dwarf,horse,built wall,not build wall,etc) wrapper + * \ingroup grp_maps + */ union t_occupancy { uint32_t whole; naked_occupancy bits; - naked_occupancy_grouped unibits; }; - // map block flags + /** + * map block flags + * \ingroup grp_maps + */ struct naked_blockflags { /// designated for jobs (digging and stuff like that) @@ -339,19 +391,50 @@ namespace DFHack // there's a possibility that this flags field is shorter than 32 bits }; + /** + * map block flags wrapper + * \ingroup grp_maps + */ union t_blockflags { uint32_t whole; naked_blockflags bits; }; + /** + * 16x16 array of tile types + * \ingroup grp_maps + */ typedef int16_t tiletypes40d [16][16]; - typedef int16_t t_blockmaterials [16][16]; ///< used for squashed block materials + /** + * 16x16 array used for squashed block materials + * \ingroup grp_maps + */ + typedef int16_t t_blockmaterials [16][16]; + /** + * 16x16 array of designation flags + * \ingroup grp_maps + */ typedef DFHack::t_designation designations40d [16][16]; + /** + * 16x16 array of occupancy flags + * \ingroup grp_maps + */ typedef DFHack::t_occupancy occupancies40d [16][16]; + /** + * array of 16 biome indexes valid for the block + * \ingroup grp_maps + */ typedef uint8_t biome_indices40d [16]; + /** + * 16x16 array of temperatures + * \ingroup grp_maps + */ typedef uint16_t t_temperatures [16][16]; - + /** + * structure for holding whole blocks + * \ingroup grp_maps + */ typedef struct { /// type of the tiles @@ -376,7 +459,11 @@ namespace DFHack ***************************************************************************/ #ifndef BUILD_SHM class DFContextShared; - struct t_viewscreen; + /** + * The Maps module + * \ingroup grp_modules + * \ingroup grp_maps + */ class DFHACK_EXPORT Maps : public Module { public: diff --git a/library/include/dfhack/modules/Materials.h b/library/include/dfhack/modules/Materials.h index 9c686f968..15503fb28 100644 --- a/library/include/dfhack/modules/Materials.h +++ b/library/include/dfhack/modules/Materials.h @@ -1,14 +1,17 @@ #ifndef CL_MOD_MATERIALS #define CL_MOD_MATERIALS -/* - * Materials +/** + * \defgroup grp_materials Materials module - used for reading raws mostly + * @ingroup grp_modules */ #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" namespace DFHack { class DFContextShared; - + /** + * \ingroup grp_materials + */ struct t_matgloss { char id[128]; //the id in the raws @@ -17,7 +20,9 @@ namespace DFHack uint8_t bright; char name[128]; //this is the name displayed ingame }; - + /** + * \ingroup grp_materials + */ struct t_descriptor_color { char id[128]; // id in the raws @@ -26,7 +31,9 @@ namespace DFHack float b; char name[128]; //displayed name }; - + /** + * \ingroup grp_materials + */ struct t_matglossPlant { char id[128]; //the id in the raws @@ -38,7 +45,9 @@ namespace DFHack char food_name[128]; char extract_name[128]; }; - + /** + * \ingroup grp_materials + */ struct t_bodypart { char id[128]; @@ -46,7 +55,9 @@ namespace DFHack char single[128]; char plural[128]; }; - + /** + * \ingroup grp_materials + */ struct t_colormodifier { char part[128]; @@ -54,7 +65,9 @@ namespace DFHack uint32_t startdate; /* in days */ uint32_t enddate; /* in days */ }; - + /** + * \ingroup grp_materials + */ struct t_creaturecaste { char rawname[128]; @@ -82,17 +95,23 @@ namespace DFHack t_attrib musicality; t_attrib kinesthetic_sense; }; - + /** + * \ingroup grp_materials + */ struct t_matglossOther { char rawname[128]; }; - + /** + * \ingroup grp_materials + */ struct t_creatureextract { char rawname[128]; }; - // this doesn't transfer well across the shm gap... + /** + * \ingroup grp_materials + */ struct t_creaturetype { char rawname[128]; @@ -107,7 +126,10 @@ namespace DFHack } tilecolor; }; - // this structure describes what are things made of in the DF world + /** + * this structure describes what are things made of in the DF world + * \ingroup grp_materials + */ struct t_material { int16_t itemType; @@ -116,7 +138,11 @@ namespace DFHack int32_t index; uint32_t flags; }; - + /** + * The Materials module + * \ingroup grp_modules + * \ingroup grp_materials + */ class DFHACK_EXPORT Materials : public Module { public: diff --git a/library/include/dfhack/modules/Position.h b/library/include/dfhack/modules/Position.h index 376208df2..ca930c964 100644 --- a/library/include/dfhack/modules/Position.h +++ b/library/include/dfhack/modules/Position.h @@ -1,67 +1,4 @@ #ifndef CL_MOD_POSITION #define CL_MOD_POSITION -/* -* View position and size and cursor position -*/ -#include "dfhack/DFExport.h" -#include "dfhack/DFModule.h" -namespace DFHack -{ - #define NUM_HOTKEYS 16 - struct t_hotkey - { - char name[10]; - int16_t mode; - int32_t x; - int32_t y; - int32_t z; - }; - - struct t_screen - { - uint8_t symbol; - uint8_t foreground; - uint8_t background; - uint8_t bright; - uint8_t gtile; - uint8_t grayscale; - }; - - class DFContextShared; - class DFHACK_EXPORT Position : public Module - { - public: - - Position(DFContextShared * d); - ~Position(); - bool Finish(){return true;}; - /* - * Cursor and window coords - */ - 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); - - /* - * Hotkeys (DF's zoom locations) - */ - bool ReadHotkeys(t_hotkey hotkeys[]); - - /* - * Window size in tiles - */ - bool getWindowSize(int32_t & width, int32_t & height); - - /* - * Screen tiles - */ - bool getScreenTiles(int32_t width, int32_t height, t_screen screen[]); - - private: - struct Private; - Private *d; - }; -} +// blorp #endif diff --git a/library/include/dfhack/modules/Translation.h b/library/include/dfhack/modules/Translation.h index 5b562bc77..8e253fae4 100644 --- a/library/include/dfhack/modules/Translation.h +++ b/library/include/dfhack/modules/Translation.h @@ -1,20 +1,32 @@ #ifndef CL_MOD_TRANSLATION #define CL_MOD_TRANSLATION -/* -* DF translation tables and name translation -*/ +/** + * \defgroup grp_translation Translation: DF word tables and name translation/reading + * @ingroup grp_modules + */ + #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" namespace DFHack { class DFContextShared; + /** + * \ingroup grp_translation + */ typedef std::vector< std::vector > DFDict; + /** + * \ingroup grp_translation + */ typedef struct { DFDict translations; DFDict foreign_languages; } Dicts; - + /** + * The Tanslation module + * \ingroup grp_translation + * \ingroup grp_maps + */ class DFHACK_EXPORT Translation : public Module { public: diff --git a/library/include/dfhack/modules/Vegetation.h b/library/include/dfhack/modules/Vegetation.h index 9ab390e7f..50a5747fd 100644 --- a/library/include/dfhack/modules/Vegetation.h +++ b/library/include/dfhack/modules/Vegetation.h @@ -1,21 +1,26 @@ #ifndef CL_MOD_VEGETATION #define CL_MOD_VEGETATION -/* -* DF vegetation - stuff that grows and gets cut down or trampled by dwarves -*/ +/** + * \defgroup grp_vegetation Vegetation : stuff that grows and gets cut down or trampled by dwarves + * @ingroup grp_modules + */ + #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" namespace DFHack { - /* - types - 0: sapling?, dead sapling?, grown maple tree - 1: willow sapling? - 2: shrub - 3: shrub near water! - */ + + /** + * \ingroup grp_vegetation + */ struct t_tree { + /** + 0: sapling?, dead sapling?, grown maple tree + 1: willow sapling? + 2: shrub + 3: shrub near water! + */ uint16_t type; // +0x6C uint16_t material; // +0x6E uint16_t x; // +0x70 @@ -27,8 +32,13 @@ namespace DFHack */ uint32_t address; }; - + class DFContextShared; + /** + * The Vegetation module + * \ingroup grp_vegetation + * \ingroup grp_modules + */ class DFHACK_EXPORT Vegetation : public Module { public: @@ -37,7 +47,7 @@ namespace DFHack bool Start(uint32_t & numTrees); bool Read (const uint32_t index, t_tree & shrubbery); bool Finish(); - + private: struct Private; Private *d; diff --git a/library/include/dfhack/modules/WindowIO.h b/library/include/dfhack/modules/WindowIO.h index 5244d2a1c..4e05e6e9b 100644 --- a/library/include/dfhack/modules/WindowIO.h +++ b/library/include/dfhack/modules/WindowIO.h @@ -25,15 +25,23 @@ distribution. #ifndef KEYS_H_INCLUDED #define KEYS_H_INCLUDED +/** + * \defgroup grp_windowio WindowIO: Send events to DF's window + * @ingroup grp_modules + */ + + #include "../DFPragma.h" #include "../DFExport.h" #include "../DFModule.h" namespace DFHack { - class Process; - +/** + * enum of all possible special keys + * \ingroup grp_windowio + */ enum t_special { ENTER, @@ -89,6 +97,11 @@ enum t_special NUM_SPECIALS }; class DFContextShared; +/** + * The WindowIO module + * \ingroup grp_windowio + * \ingroup grp_modules + */ class DFHACK_EXPORT WindowIO : public Module { class Private; diff --git a/library/include/dfhack/modules/World.h b/library/include/dfhack/modules/World.h index 597108018..33514aeea 100644 --- a/library/include/dfhack/modules/World.h +++ b/library/include/dfhack/modules/World.h @@ -1,21 +1,29 @@ #ifndef CL_MOD_WORLD #define CL_MOD_WORLD -/* -* World: all kind of stuff related to the current world state -*/ +/** + * \defgroup grp_world World: all kind of stuff related to the current world state + * @ingroup grp_modules + */ + #include "dfhack/DFExport.h" #include "dfhack/DFModule.h" #include namespace DFHack { + /** + * \ingroup grp_world + */ enum WeatherType { CLEAR, RAINING, SNOWING }; + /** + * \ingroup grp_world + */ enum ControlMode { CM_Managing = 0, @@ -24,6 +32,9 @@ namespace DFHack CM_Menu = 3, CM_MAX = 3 }; + /** + * \ingroup grp_world + */ enum GameMode { GM_Fort = 0, @@ -31,17 +42,25 @@ namespace DFHack GM_Legends = 2, GM_Menu = 3, GM_Arena = 4, - GM_Arena_Assumed = 5, - GM_Kittens = 6, - GM_Worldgen = 7, + GM_Arena_Assumed = 5, + GM_Kittens = 6, + GM_Worldgen = 7, GM_MAX = 7, }; + /** + * \ingroup grp_world + */ struct t_gamemodes { ControlMode control_mode; GameMode game_mode; }; class DFContextShared; + /** + * The World module + * \ingroup grp_modules + * \ingroup grp_world + */ class DFHACK_EXPORT World : public Module { public: @@ -51,6 +70,11 @@ namespace DFHack bool Start(); bool Finish(); + ///true if paused, false if not + bool ReadPauseState(); + ///true if paused, false if not + void SetPauseState(bool paused); + uint32_t ReadCurrentTick(); uint32_t ReadCurrentYear(); uint32_t ReadCurrentMonth(); diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 14f308eab..dae710e77 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -28,6 +28,7 @@ distribution. #include "dfhack/DFProcess.h" #include "dfhack/VersionInfo.h" #include "dfhack/DFTypes.h" +#include "dfhack/DFError.h" #include "ModuleFactory.h" using namespace DFHack; @@ -41,15 +42,31 @@ struct Gui::Private { Private() { - Started = PauseInited = ViewScreeInited = MenuStateInited = false; + Started = ViewScreeInited = MenuStateInited = false; + StartedHotkeys = StartedScreen = false; } - bool Started; - uint32_t pause_state_offset; - bool PauseInited; - uint32_t view_screen_offset; bool ViewScreeInited; - uint32_t current_menu_state_offset; + uint32_t view_screen_offset; + bool MenuStateInited; + uint32_t current_menu_state_offset; + + bool Started; + 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 StartedHotkeys; + uint32_t hotkey_start; + uint32_t hotkey_mode_offset; + uint32_t hotkey_xyz_offset; + uint32_t hotkey_size; + + bool StartedScreen; + uint32_t screen_tiles_ptr_offset; + DFContextShared *d; Process * owner; }; @@ -60,7 +77,8 @@ Gui::Gui(DFContextShared * _d) d = new Private; d->d = _d; d->owner = _d->p; - OffsetGroup * OG_Gui = d->d->offset_descriptor->getGroup("GUI"); + VersionInfo * mem = d->d->offset_descriptor; + OffsetGroup * OG_Gui = mem->getGroup("GUI"); try { d->current_menu_state_offset = OG_Gui->getAddress("current_menu_state"); @@ -69,17 +87,38 @@ Gui::Gui(DFContextShared * _d) catch(exception &){}; try { - d->pause_state_offset = OG_Gui->getAddress ("pause_state"); - d->PauseInited = true; + d->view_screen_offset = OG_Gui->getAddress ("view_screen"); + d->ViewScreeInited = true; } catch(exception &){}; + OffsetGroup * OG_Position; try { - d->view_screen_offset = OG_Gui->getAddress ("view_screen"); - d->ViewScreeInited = true; + OG_Position = mem->getGroup("Position"); + d->window_x_offset = OG_Position->getAddress ("window_x"); + d->window_y_offset = OG_Position->getAddress ("window_y"); + d->window_z_offset = OG_Position->getAddress ("window_z"); + d->cursor_xyz_offset = OG_Position->getAddress ("cursor_xyz"); + d->window_dims_offset = OG_Position->getAddress ("window_dims"); + d->Started = true; } - catch(exception &){}; - d->Started = true; + catch(Error::All &){}; + try + { + OffsetGroup * OG_Hotkeys = mem->getGroup("Hotkeys"); + d->hotkey_start = OG_Hotkeys->getAddress("start"); + d->hotkey_mode_offset = OG_Hotkeys->getOffset ("mode"); + d->hotkey_xyz_offset = OG_Hotkeys->getOffset("coords"); + d->hotkey_size = OG_Hotkeys->getHexValue("size"); + d->StartedHotkeys = true; + } + catch(Error::All &){}; + try + { + d->screen_tiles_ptr_offset = OG_Position->getAddress ("screen_tiles_pointer"); + d->StartedScreen = true; + } + catch(Error::All &){}; } Gui::~Gui() @@ -97,21 +136,6 @@ bool Gui::Finish() return true; } -bool Gui::ReadPauseState() -{ - if(!d->PauseInited) return false; - - uint32_t pauseState = d->owner->readDWord (d->pause_state_offset); - return pauseState & 1; -} - -void Gui::SetPauseState(bool paused) -{ - if(!d->PauseInited) return; - cout << "pause set" << endl; - d->owner->writeDWord (d->pause_state_offset, paused); -} - uint32_t Gui::ReadMenuState() { if(d->MenuStateInited) @@ -135,3 +159,108 @@ bool Gui::ReadViewScreen (t_viewscreen &screen) } return d->d->offset_descriptor->resolveObjectToClassID (last, screen.type); } + +bool Gui::ReadHotkeys(t_hotkey hotkeys[]) +{ + if (!d->StartedHotkeys) + { + return false; + } + uint32_t currHotkey = d->hotkey_start; + Process * p = d->owner; + + for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++) + { + p->readSTLString(currHotkey,hotkeys[i].name,10); + hotkeys[i].mode = p->readWord(currHotkey+d->hotkey_mode_offset); + p->read (currHotkey + d->hotkey_xyz_offset, 3*sizeof (int32_t), (uint8_t *) &hotkeys[i].x); + currHotkey+=d->hotkey_size; + } + return true; +} + +bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z) +{ + if (!d->Started) return false; + Process * p = d->owner; + + p->readDWord (d->window_x_offset, (uint32_t &) x); + p->readDWord (d->window_y_offset, (uint32_t &) y); + p->readDWord (d->window_z_offset, (uint32_t &) z); + return true; +} + +//FIXME: confine writing of coords to map bounds? +bool Gui::setViewCoords (const int32_t x, const int32_t y, const int32_t z) +{ + if (!d->Started) + { + return false; + } + Process * p = d->owner; + + p->writeDWord (d->window_x_offset, (uint32_t) x); + p->writeDWord (d->window_y_offset, (uint32_t) y); + p->writeDWord (d->window_z_offset, (uint32_t) z); + return true; +} + +bool Gui::getCursorCoords (int32_t &x, int32_t &y, int32_t &z) +{ + if(!d->Started) return false; + int32_t coords[3]; + d->owner->read (d->cursor_xyz_offset, 3*sizeof (int32_t), (uint8_t *) coords); + x = coords[0]; + y = coords[1]; + z = coords[2]; + if (x == -30000) return false; + return true; +} + +//FIXME: confine writing of coords to map bounds? +bool Gui::setCursorCoords (const int32_t x, const int32_t y, const int32_t z) +{ + if (!d->Started) return false; + int32_t coords[3] = {x, y, z}; + d->owner->write (d->cursor_xyz_offset, 3*sizeof (int32_t), (uint8_t *) coords); + return true; +} + +bool Gui::getWindowSize (int32_t &width, int32_t &height) +{ + if(!d->Started) return false; + + int32_t coords[2]; + d->owner->read (d->window_dims_offset, 2*sizeof (int32_t), (uint8_t *) coords); + width = coords[0]; + height = coords[1]; + return true; +} + + +bool Gui::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) +{ + if(!d->StartedScreen) return false; + + uint32_t screen_addr = d->owner->readDWord(d->screen_tiles_ptr_offset); + uint8_t* tiles = new uint8_t[width*height*4/* + 80 + width*height*4*/]; + + d->owner->read (screen_addr, (width*height*4/* + 80 + width*height*4*/), (uint8_t *) tiles); + + for(int32_t iy=0; iyoffsets; DfVector vegptrs(d->owner, addr + off.vegvector); - for(int i = 0; i < vegptrs.size(); i++) + for(size_t i = 0; i < vegptrs.size(); i++) { d->owner->read (vegptrs[i] + off.tree_desc_offset, sizeof (t_tree), (uint8_t *) &shrubbery); shrubbery.address = vegptrs[i]; diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index ff0deb880..d52221fe0 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -1,211 +1,2 @@ -/* -www.sourceforge.net/projects/dfhack -Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf +// blorp -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include "Internal.h" -#include "ContextShared.h" -#include "dfhack/modules/Position.h" -#include "dfhack/VersionInfo.h" -#include "dfhack/DFProcess.h" -#include "dfhack/DFError.h" -#include "ModuleFactory.h" - -using namespace DFHack; - -Module* DFHack::createPosition(DFContextShared * d) -{ - return new Position(d); -} - -struct Position::Private -{ - 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; - - uint32_t hotkey_start; - uint32_t hotkey_mode_offset; - uint32_t hotkey_xyz_offset; - uint32_t hotkey_size; - - uint32_t screen_tiles_ptr_offset; - - DFContextShared *d; - Process * owner; - bool Inited; - bool Started; - bool StartedHotkeys; - bool StartedScreen; -}; - -Position::Position(DFContextShared * d_) -{ - d = new Private; - d->d = d_; - d->owner = d_->p; - d->Inited = true; - d->StartedHotkeys = d->Started = d->StartedScreen = false; - OffsetGroup * OG_Position; - VersionInfo * mem = d->d->offset_descriptor; - // this is how to do feature detection properly - try - { - OG_Position = mem->getGroup("Position"); - d->window_x_offset = OG_Position->getAddress ("window_x"); - d->window_y_offset = OG_Position->getAddress ("window_y"); - d->window_z_offset = OG_Position->getAddress ("window_z"); - d->cursor_xyz_offset = OG_Position->getAddress ("cursor_xyz"); - d->window_dims_offset = OG_Position->getAddress ("window_dims"); - d->Started = true; - } - catch(Error::All &){}; - try - { - OffsetGroup * OG_Hotkeys = mem->getGroup("Hotkeys"); - d->hotkey_start = OG_Hotkeys->getAddress("start"); - d->hotkey_mode_offset = OG_Hotkeys->getOffset ("mode"); - d->hotkey_xyz_offset = OG_Hotkeys->getOffset("coords"); - d->hotkey_size = OG_Hotkeys->getHexValue("size"); - d->StartedHotkeys = true; - } - catch(Error::All &){}; - try - { - d->screen_tiles_ptr_offset = OG_Position->getAddress ("screen_tiles_pointer"); - d->StartedScreen = true; - } - catch(Error::All &){}; -} - -Position::~Position() -{ - delete d; -} - -bool Position::ReadHotkeys(t_hotkey hotkeys[]) -{ - if (!d->StartedHotkeys) - { - return false; - } - uint32_t currHotkey = d->hotkey_start; - Process * p = d->owner; - - for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++) - { - p->readSTLString(currHotkey,hotkeys[i].name,10); - hotkeys[i].mode = p->readWord(currHotkey+d->hotkey_mode_offset); - p->read (currHotkey + d->hotkey_xyz_offset, 3*sizeof (int32_t), (uint8_t *) &hotkeys[i].x); - currHotkey+=d->hotkey_size; - } - return true; -} - -bool Position::getViewCoords (int32_t &x, int32_t &y, int32_t &z) -{ - if (!d->Inited) return false; - Process * p = d->owner; - - p->readDWord (d->window_x_offset, (uint32_t &) x); - p->readDWord (d->window_y_offset, (uint32_t &) y); - p->readDWord (d->window_z_offset, (uint32_t &) z); - return true; -} - -//FIXME: confine writing of coords to map bounds? -bool Position::setViewCoords (const int32_t x, const int32_t y, const int32_t z) -{ - if (!d->Inited) - { - return false; - } - Process * p = d->owner; - - p->writeDWord (d->window_x_offset, (uint32_t) x); - p->writeDWord (d->window_y_offset, (uint32_t) y); - p->writeDWord (d->window_z_offset, (uint32_t) z); - return true; -} - -bool Position::getCursorCoords (int32_t &x, int32_t &y, int32_t &z) -{ - if(!d->Inited) return false; - int32_t coords[3]; - d->owner->read (d->cursor_xyz_offset, 3*sizeof (int32_t), (uint8_t *) coords); - x = coords[0]; - y = coords[1]; - z = coords[2]; - if (x == -30000) return false; - return true; -} - -//FIXME: confine writing of coords to map bounds? -bool Position::setCursorCoords (const int32_t x, const int32_t y, const int32_t z) -{ - if (!d->Inited) return false; - int32_t coords[3] = {x, y, z}; - d->owner->write (d->cursor_xyz_offset, 3*sizeof (int32_t), (uint8_t *) coords); - return true; -} - -bool Position::getWindowSize (int32_t &width, int32_t &height) -{ - if(!d->Inited) return false; - - int32_t coords[2]; - d->owner->read (d->window_dims_offset, 2*sizeof (int32_t), (uint8_t *) coords); - width = coords[0]; - height = coords[1]; - return true; -} - - -bool Position::getScreenTiles (int32_t width, int32_t height, t_screen screen[]) -{ - if(!d->Inited) return false; - if(!d->StartedScreen) return false; - - uint32_t screen_addr = d->owner->readDWord(d->screen_tiles_ptr_offset); - uint8_t* tiles = new uint8_t[width*height*4/* + 80 + width*height*4*/]; - - d->owner->read (screen_addr, (width*height*4/* + 80 + width*height*4*/), (uint8_t *) tiles); - - for(int32_t iy=0; iyReadCurrentYear(); - currentTick = Wold->ReadCurrentTick(); - currentMonth = (currentTick+9)/33600; - currentDay = ((currentTick+9)%33600)/1200; - currentHour = ((currentTick+9)-(((currentMonth*28)+currentDay)*1200))/50; - currentTickRel = (currentTick+9)-(((((currentMonth*28)+currentDay)*24)+currentHour)*50); - */ - #include "Internal.h" #include "ContextShared.h" #include "dfhack/modules/World.h" @@ -52,13 +40,23 @@ Module* DFHack::createWorld(DFContextShared * d) struct World::Private { + Private() + { + Inited = StartedTime = StartedWeather = StartedMode = PauseInited = false; + } bool Inited; + + bool PauseInited; + uint32_t pause_state_offset; + bool StartedTime; - bool StartedWeather; - bool StartedMode; uint32_t year_offset; uint32_t tick_offset; + + bool StartedWeather; uint32_t weather_offset; + + bool StartedMode; uint32_t gamemode_offset; uint32_t controlmode_offset; uint32_t controlmodecopy_offset; @@ -72,7 +70,6 @@ World::World(DFContextShared * _d) d = new Private; d->d = _d; d->owner = _d->p; - d->Inited = d->StartedTime = d->StartedWeather = d->StartedMode = false; OffsetGroup * OG_World = d->d->offset_descriptor->getGroup("World"); try @@ -82,6 +79,13 @@ World::World(DFContextShared * _d) d->StartedTime = true; } catch(Error::All &){}; + OffsetGroup * OG_Gui = d->d->offset_descriptor->getGroup("GUI"); // FIXME: legacy + try + { + d->pause_state_offset = OG_Gui->getAddress ("pause_state"); + d->PauseInited = true; + } + catch(exception &){}; try { d->weather_offset = OG_World->getAddress( "current_weather" ); @@ -114,6 +118,20 @@ bool World::Finish() return true; } +bool World::ReadPauseState() +{ + if(!d->PauseInited) return false; + + uint32_t pauseState = d->owner->readDWord (d->pause_state_offset); + return pauseState & 1; +} + +void World::SetPauseState(bool paused) +{ + if(!d->PauseInited) return; + d->owner->writeDWord (d->pause_state_offset, paused); +} + uint32_t World::ReadCurrentYear() { if(d->Inited && d->StartedTime) @@ -150,6 +168,18 @@ bool World::WriteGameMode(const t_gamemodes & wr) return false; } +/* +FIXME: Japa said that he had to do this with the time stuff he got from here + Investigate. + + currentYear = Wold->ReadCurrentYear(); + currentTick = Wold->ReadCurrentTick(); + currentMonth = (currentTick+9)/33600; + currentDay = ((currentTick+9)%33600)/1200; + currentHour = ((currentTick+9)-(((currentMonth*28)+currentDay)*1200))/50; + currentTickRel = (currentTick+9)-(((((currentMonth*28)+currentDay)*24)+currentHour)*50); + */ + // FIX'D according to this: /* World::ReadCurrentMonth and World::ReadCurrentDay @@ -176,13 +206,7 @@ uint8_t World::ReadCurrentWeather() return(d->owner->readByte(d->weather_offset + 12)); return 0; } -/* -void World::SetCurrentWeather(uint8_t weather) -{ - if (d->Inited && d->StartedWeather) - d->owner->writeByte(d->weather_offset,weather); -} -*/ + void World::SetCurrentWeather(uint8_t weather) { if (d->Inited && d->StartedWeather) diff --git a/library/private/ContextShared.h b/library/private/ContextShared.h index 89403836c..18b9ea798 100644 --- a/library/private/ContextShared.h +++ b/library/private/ContextShared.h @@ -35,7 +35,6 @@ namespace DFHack class Creatures; class Maps; - class Position; class Gui; class World; class Materials; @@ -76,7 +75,7 @@ namespace DFHack { Creatures * pCreatures; Maps * pMaps; - Position * pPosition; + Gui * pPosition; // blerp Gui * pGui; World * pWorld; Materials * pMaterials;