diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml
index 56fa6df23..015bc0498 100644
--- a/data/Memory-ng.xml
+++ b/data/Memory-ng.xml
@@ -1032,6 +1032,7 @@
+
@@ -1595,6 +1596,9 @@
+
+
+
diff --git a/library/include/dfhack-c/modules/World_C.h b/library/include/dfhack-c/modules/World_C.h
index f6261a738..c4348b5e9 100644
--- a/library/include/dfhack-c/modules/World_C.h
+++ b/library/include/dfhack-c/modules/World_C.h
@@ -40,6 +40,9 @@ DFHACK_EXPORT int World_ReadCurrentYear(DFHackObject* world, uint32_t* year);
DFHACK_EXPORT int World_ReadCurrentMonth(DFHackObject* world, uint32_t* month);
DFHACK_EXPORT int World_ReadCurrentDay(DFHackObject* world, uint32_t* day);
+DFHACK_EXPORT int World_ReadCurrentWeather(DFHackObject* world, uint8_t* weather);
+DFHACK_EXPORT int World_WriteCurrentWeather(DFHackObject* world, uint8_t weather);
+
#ifdef __cplusplus
}
#endif
diff --git a/library/include/dfhack/modules/World.h b/library/include/dfhack/modules/World.h
index fdb08baf7..7834d4719 100644
--- a/library/include/dfhack/modules/World.h
+++ b/library/include/dfhack/modules/World.h
@@ -9,21 +9,29 @@
namespace DFHack
{
+ enum WeatherType
+ {
+ CLEAR,
+ RAINING,
+ SNOWING
+ };
class DFContextShared;
class DFHACK_EXPORT World : public Module
{
public:
-
+
World(DFHack::DFContextShared * d);
~World();
bool Start();
bool Finish();
-
+
uint32_t ReadCurrentTick();
uint32_t ReadCurrentYear();
uint32_t ReadCurrentMonth();
uint32_t ReadCurrentDay();
-
+ uint8_t ReadCurrentWeather();
+ void SetCurrentWeather(uint8_t weather);
+
private:
struct Private;
Private *d;
diff --git a/library/modules/World.cpp b/library/modules/World.cpp
index 7a2cab963..a24dbf2a6 100644
--- a/library/modules/World.cpp
+++ b/library/modules/World.cpp
@@ -49,6 +49,7 @@ struct World::Private
bool Started;
uint32_t year_offset;
uint32_t tick_offset;
+ uint32_t weather_offset;
DFContextShared *d;
Process * owner;
};
@@ -63,6 +64,7 @@ World::World(DFContextShared * _d)
OffsetGroup * OG_World = d->d->offset_descriptor->getGroup("World");
d->year_offset = OG_World->getAddress( "current_year" );
d->tick_offset = OG_World->getAddress( "current_tick" );
+ d->weather_offset = OG_World->getAddress( "current_weather" );
d->Inited = d->Started = true;
}
@@ -114,3 +116,16 @@ uint32_t World::ReadCurrentDay()
{
return ((this->ReadCurrentTick() / 1200) % 28) + 1;
}
+
+uint8_t World::ReadCurrentWeather()
+{
+ if (d->Inited)
+ return(d->owner->readByte(d->weather_offset));
+ return 0;
+}
+
+void World::SetCurrentWeather(uint8_t weather)
+{
+ if (d->Inited)
+ d->owner->writeByte(d->weather_offset,weather);
+}
diff --git a/library/modules/World_C.cpp b/library/modules/World_C.cpp
index a5be3bcd0..6aa0b320f 100644
--- a/library/modules/World_C.cpp
+++ b/library/modules/World_C.cpp
@@ -39,7 +39,7 @@ int World_Start(DFHackObject* world)
else
return 0;
}
-
+
return -1;
}
@@ -52,7 +52,7 @@ int World_Finish(DFHackObject* world)
else
return 0;
}
-
+
return -1;
}
@@ -63,7 +63,7 @@ int World_ReadCurrentTick(DFHackObject* world, uint32_t* tick)
*tick = ((DFHack::World*)world)->ReadCurrentTick();
return 1;
}
-
+
return -1;
}
@@ -74,7 +74,7 @@ int World_ReadCurrentYear(DFHackObject* world, uint32_t* year)
*year = ((DFHack::World*)world)->ReadCurrentYear();
return 1;
}
-
+
return -1;
}
@@ -85,7 +85,7 @@ int World_ReadCurrentMonth(DFHackObject* world, uint32_t* month)
*month = ((DFHack::World*)world)->ReadCurrentMonth();
return 1;
}
-
+
return -1;
}
@@ -96,10 +96,32 @@ int World_ReadCurrentDay(DFHackObject* world, uint32_t* day)
*day = ((DFHack::World*)world)->ReadCurrentDay();
return 1;
}
-
+
return -1;
}
+int World_ReadCurrentWeather(DFHackObject* world, uint8_t* weather)
+{
+ if(world != NULL)
+ {
+ *weather = ((DFHack::World*)world)->ReadCurrentWeather();
+ return 1;
+ }
+
+ return -1;
+}
+
+int World_WriteCurrentWeather(DFHackObject* world, uint8_t weather)
+{
+ if (world != NULL)
+ {
+ ((DFHack::World*)world)->SetCurrentWeather(weather);
+ return 1;
+ }
+
+ return -1;
+}
+
#ifdef __cplusplus
}
#endif