2011-06-16 15:53:39 -06:00
|
|
|
/*
|
|
|
|
https://github.com/peterix/dfhack
|
|
|
|
Copyright (c) 2009-2011 Petr Mrázek (peterix@gmail.com)
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2011-04-10 05:12:28 -06:00
|
|
|
#pragma once
|
2010-05-12 07:27:51 -06:00
|
|
|
#ifndef CL_MOD_WORLD
|
|
|
|
#define CL_MOD_WORLD
|
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* \defgroup grp_world World: all kind of stuff related to the current world state
|
|
|
|
* @ingroup grp_modules
|
|
|
|
*/
|
|
|
|
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Export.h"
|
|
|
|
#include "Module.h"
|
2011-03-01 14:18:26 -07:00
|
|
|
#include <ostream>
|
2010-05-12 07:27:51 -06:00
|
|
|
|
|
|
|
namespace DFHack
|
|
|
|
{
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* \ingroup grp_world
|
|
|
|
*/
|
2010-09-01 09:22:19 -06:00
|
|
|
enum WeatherType
|
|
|
|
{
|
|
|
|
CLEAR,
|
|
|
|
RAINING,
|
|
|
|
SNOWING
|
|
|
|
};
|
2011-07-07 02:57:57 -06:00
|
|
|
typedef unsigned char weather_map [5][5];
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* \ingroup grp_world
|
|
|
|
*/
|
2011-07-06 03:13:36 -06:00
|
|
|
enum GameMode
|
2011-03-01 14:18:26 -07:00
|
|
|
{
|
2011-07-06 03:13:36 -06:00
|
|
|
GAMEMODE_DWARF,
|
|
|
|
GAMEMODE_ADVENTURE,
|
|
|
|
GAMEMODENUM,
|
|
|
|
GAMEMODE_NONE
|
2011-03-01 14:18:26 -07:00
|
|
|
};
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* \ingroup grp_world
|
|
|
|
*/
|
2011-07-06 03:13:36 -06:00
|
|
|
enum GameType
|
2011-02-28 22:59:23 -07:00
|
|
|
{
|
2011-07-06 03:13:36 -06:00
|
|
|
GAMETYPE_DWARF_MAIN,
|
|
|
|
GAMETYPE_ADVENTURE_MAIN,
|
|
|
|
GAMETYPE_VIEW_LEGENDS,
|
|
|
|
GAMETYPE_DWARF_RECLAIM,
|
|
|
|
GAMETYPE_DWARF_ARENA,
|
|
|
|
GAMETYPE_ADVENTURE_ARENA,
|
|
|
|
GAMETYPENUM,
|
|
|
|
GAMETYPE_NONE
|
2011-03-01 14:18:26 -07:00
|
|
|
};
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* \ingroup grp_world
|
|
|
|
*/
|
2011-03-01 14:18:26 -07:00
|
|
|
struct t_gamemodes
|
|
|
|
{
|
2011-07-06 03:13:36 -06:00
|
|
|
GameMode g_mode;
|
|
|
|
GameType g_type;
|
2011-02-28 22:59:23 -07:00
|
|
|
};
|
2010-05-26 04:24:45 -06:00
|
|
|
class DFContextShared;
|
2012-01-07 08:21:31 -07:00
|
|
|
|
|
|
|
class DFHACK_EXPORT PersistentDataItem {
|
|
|
|
friend class World;
|
|
|
|
|
|
|
|
int id;
|
|
|
|
std::string key_value;
|
|
|
|
|
|
|
|
std::string *str_value;
|
|
|
|
int *int_values;
|
|
|
|
public:
|
|
|
|
static const int NumInts = 7;
|
|
|
|
|
|
|
|
bool isValid() { return id != 0; }
|
|
|
|
|
|
|
|
const std::string &key() { return key_value; }
|
|
|
|
|
|
|
|
std::string &val() { return *str_value; }
|
|
|
|
int &ival(int i) { return int_values[i]; }
|
|
|
|
|
|
|
|
PersistentDataItem() : id(0), str_value(0), int_values(0) {}
|
|
|
|
PersistentDataItem(int id, const std::string &key, std::string *sv, int *iv)
|
|
|
|
: id(id), key_value(key), str_value(sv), int_values(iv) {}
|
|
|
|
};
|
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
/**
|
|
|
|
* The World module
|
|
|
|
* \ingroup grp_modules
|
|
|
|
* \ingroup grp_world
|
|
|
|
*/
|
2010-06-24 23:11:26 -06:00
|
|
|
class DFHACK_EXPORT World : public Module
|
2010-05-12 07:27:51 -06:00
|
|
|
{
|
|
|
|
public:
|
2011-07-07 02:57:57 -06:00
|
|
|
weather_map * wmap;
|
2011-06-17 07:02:43 -06:00
|
|
|
World();
|
2010-05-12 07:27:51 -06:00
|
|
|
~World();
|
|
|
|
bool Start();
|
|
|
|
bool Finish();
|
2010-09-01 09:22:19 -06:00
|
|
|
|
2011-03-18 04:09:26 -06:00
|
|
|
///true if paused, false if not
|
|
|
|
bool ReadPauseState();
|
|
|
|
///true if paused, false if not
|
|
|
|
void SetPauseState(bool paused);
|
|
|
|
|
2010-05-12 07:27:51 -06:00
|
|
|
uint32_t ReadCurrentTick();
|
|
|
|
uint32_t ReadCurrentYear();
|
|
|
|
uint32_t ReadCurrentMonth();
|
|
|
|
uint32_t ReadCurrentDay();
|
2010-09-01 09:22:19 -06:00
|
|
|
uint8_t ReadCurrentWeather();
|
|
|
|
void SetCurrentWeather(uint8_t weather);
|
2011-03-01 14:18:26 -07:00
|
|
|
bool ReadGameMode(t_gamemodes& rd);
|
|
|
|
bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous
|
2011-07-16 17:00:50 -06:00
|
|
|
std::string ReadWorldFolder();
|
2012-01-07 08:21:31 -07:00
|
|
|
|
|
|
|
// Store data in fake historical figure names.
|
|
|
|
// This ensures that the values are stored in save games.
|
|
|
|
PersistentDataItem AddPersistentData(const std::string &key);
|
|
|
|
PersistentDataItem GetPersistentData(const std::string &key);
|
|
|
|
void GetPersistentData(std::vector<PersistentDataItem> *vec, const std::string &key);
|
|
|
|
void DeletePersistentData(const PersistentDataItem &item);
|
|
|
|
|
2010-05-12 07:27:51 -06:00
|
|
|
private:
|
|
|
|
struct Private;
|
|
|
|
Private *d;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|