-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathWorld.h
More file actions
129 lines (108 loc) · 5.37 KB
/
World.h
File metadata and controls
129 lines (108 loc) · 5.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2012 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.
*/
#pragma once
#ifndef CL_MOD_WORLD
#define CL_MOD_WORLD
/**
* \defgroup grp_world World: all kind of stuff related to the current world state
* @ingroup grp_modules
*/
#include "Export.h"
#include "Module.h"
#include "modules/Persistence.h"
#include <ostream>
#include "DataDefs.h"
namespace df
{
struct tile_bitmask;
struct map_block;
}
namespace DFHack
{
typedef df::game_mode GameMode;
typedef df::game_type GameType;
#define GAMEMODE_ADVENTURE df::enums::game_mode::ADVENTURE
/**
* \ingroup grp_world
*/
struct t_gamemodes
{
GameMode g_mode;
GameType g_type;
};
class DFContextShared;
/**
* The World module
* \ingroup grp_modules
* \ingroup grp_world
*/
namespace World
{
///true if paused, false if not
DFHACK_EXPORT bool ReadPauseState();
///true if paused, false if not
DFHACK_EXPORT void SetPauseState(bool paused);
DFHACK_EXPORT uint32_t ReadCurrentTick();
DFHACK_EXPORT uint32_t ReadCurrentYear();
DFHACK_EXPORT uint32_t ReadCurrentMonth();
DFHACK_EXPORT uint32_t ReadCurrentDay();
DFHACK_EXPORT uint8_t ReadCurrentWeather();
DFHACK_EXPORT void SetCurrentWeather(uint8_t weather);
DFHACK_EXPORT bool ReadGameMode(t_gamemodes& rd);
DFHACK_EXPORT bool WriteGameMode(const t_gamemodes & wr); // this is very dangerous
DFHACK_EXPORT std::string ReadWorldFolder();
DFHACK_EXPORT bool isFortressMode(df::game_type t = (df::game_type)-1);
DFHACK_EXPORT bool isAdventureMode(df::game_type t = (df::game_type)-1);
DFHACK_EXPORT bool isArena(df::game_type t = (df::game_type)-1);
DFHACK_EXPORT bool isLegends(df::game_type t = (df::game_type)-1);
DFHACK_EXPORT std::string getWorldName(bool in_english = false);
DFHACK_EXPORT df::unit * getAdventurer();
DFHACK_EXPORT int32_t GetCurrentSiteId();
DFHACK_EXPORT void GetCurrentSiteIdsWithExtraRange(std::vector<int32_t>& ids, const int32_t x_range = 0, const int32_t y_range = 0, const uint32_t max = UINT_MAX);
DFHACK_EXPORT bool IsSiteLoaded();
// Store DFHack tool data in the game save directory.
// Use the relevant API depending on whether you are storing world-global data,
// site-specific data, or data specific to some other historical entity (including
// sites that may not be the current one).
DFHACK_EXPORT PersistentDataItem AddPersistentEntityData(int entity_id, const std::string &key);
DFHACK_EXPORT PersistentDataItem AddPersistentWorldData(const std::string &key);
DFHACK_EXPORT PersistentDataItem AddPersistentSiteData(const std::string &key);
// Calls GetPersistent*Data(key); if not found, creates and returns a new entry.
// The result can still be not isValid() e.g. if a world is not loaded.
DFHACK_EXPORT PersistentDataItem GetPersistentEntityData(int entity_id, const std::string &key, bool create = false);
DFHACK_EXPORT PersistentDataItem GetPersistentWorldData(const std::string &key, bool create = false);
DFHACK_EXPORT PersistentDataItem GetPersistentSiteData(const std::string &key, bool create = false);
// Get all items with the given key.
// If prefix is true, search for keys starting with key+"/".
// GetPersistent*Data(&vec, "", true) returns all items in the specified namespace.
// Items have alphabetic order by key; same key ordering is undefined.
DFHACK_EXPORT void GetPersistentEntityData(std::vector<PersistentDataItem> *vec, int entity_id,
const std::string &key, bool prefix = false);
DFHACK_EXPORT void GetPersistentWorldData(std::vector<PersistentDataItem> *vec,
const std::string &key, bool prefix = false);
DFHACK_EXPORT void GetPersistentSiteData(std::vector<PersistentDataItem> *vec,
const std::string &key, bool prefix = false);
// Deletes the item; returns true if success.
DFHACK_EXPORT bool DeletePersistentData(const PersistentDataItem &item);
// Create or delete block data associated with the given persistent data item
DFHACK_EXPORT df::tile_bitmask *getPersistentTilemask(PersistentDataItem &item, df::map_block *block, bool create = false);
DFHACK_EXPORT bool deletePersistentTilemask(PersistentDataItem &item, df::map_block *block);
}
}
#endif