From 8a4740c479e5a49b38ad11b1137857fe49bf5810 Mon Sep 17 00:00:00 2001 From: Quietust Date: Sat, 28 Jan 2012 14:12:41 -0600 Subject: [PATCH] Make all "origin" fields strongly typed, and fix building.origin to actually be meaningful --- library/include/modules/Buildings.h | 4 +++- library/include/modules/Maps.h | 6 +++--- library/include/modules/Vermin.h | 5 ++++- library/modules/Buildings.cpp | 3 +-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/library/include/modules/Buildings.h b/library/include/modules/Buildings.h index 7da2ad9dc..39fbe8de6 100644 --- a/library/include/modules/Buildings.h +++ b/library/include/modules/Buildings.h @@ -24,6 +24,8 @@ distribution. #pragma once #include "Export.h" +#include "DataDefs.h" +#include "df/building.h" namespace DFHack { @@ -45,7 +47,7 @@ struct t_building t_matglossPair material; uint32_t type; int32_t custom_type; - void * origin; + df::building * origin; }; /** diff --git a/library/include/modules/Maps.h b/library/include/modules/Maps.h index 76006b2e8..f9c8d328b 100644 --- a/library/include/modules/Maps.h +++ b/library/include/modules/Maps.h @@ -39,7 +39,7 @@ distribution. #include "modules/Materials.h" #include "df/world.h" -#include "df/feature_type.h" +#include "df/feature_init.h" #include "df/map_block.h" #include "df/block_square_event.h" #include "df/block_square_event_mineralst.h" @@ -84,7 +84,7 @@ struct t_feature /// placeholder bool discovered; /// this is NOT part of the DF feature, but an address of the feature as seen by DFhack. - void * origin; + df::feature_init * origin; }; /** @@ -178,7 +178,7 @@ typedef struct /// values used for geology/biome assignment biome_indices40d biome_indices; /// the address where the block came from - void * origin; + df::map_block * origin; t_blockflags blockflags; /// index into the global feature vector int32_t global_feature; diff --git a/library/include/modules/Vermin.h b/library/include/modules/Vermin.h index 9ca2730d8..bc04111a5 100644 --- a/library/include/modules/Vermin.h +++ b/library/include/modules/Vermin.h @@ -3,6 +3,9 @@ * \defgroup grp_vermin Wild vermin (ants, bees, etc) */ #include "Export.h" +#include "DataDefs.h" +#include "df/vermin.h" + namespace DFHack { namespace Simple { namespace Vermin { /** @@ -11,7 +14,7 @@ namespace DFHack { namespace Simple { namespace Vermin */ struct t_vermin { - void * origin; + df::vermin * origin; int16_t race; int16_t caste; uint16_t x; diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 2213abd35..1673cfc5c 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -43,7 +43,6 @@ using namespace DFHack::Simple; #include "DataDefs.h" #include "df/world.h" #include "df/building_def.h" -#include "df/building.h" #include "df/building_workshopst.h" using namespace df::enums; @@ -72,7 +71,7 @@ bool Buildings::Read (const uint32_t index, t_building & building) building.material.type = bld_40d->mat_type; building.type = type; building.custom_type = bld_40d->getCustomType(); - building.origin = (void *) &bld_40d; + building.origin = bld_40d; return true; }