-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDriver_Settings.cpp
More file actions
328 lines (247 loc) · 13.6 KB
/
Driver_Settings.cpp
File metadata and controls
328 lines (247 loc) · 13.6 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#pragma once
#ifndef WORLDSIM_DRIVER_SETTINGS_CPP
#define WORLDSIM_DRIVER_SETTINGS_CPP
/* WorldSim: Driver_Settings
#include "Driver_Settings.cpp"
Gameplay settings and other global settings go here. Some of this stuff will probably end up in an .ini file.
Should probably be encapsulated in a GlobalSettings:: object
Note that global objects such as RNG should be declared elsewhere to avoid dependency hell. This header should only
be for variables, strings and defines.
*/
#include <string>
// OS ///////////////////////////////////////////////////////////////////////////////////////////////////////
#define WILDCAT_USE_OPENGL
//#define WILDCAT_USE_DIRECT3D
// What OS we are compiling for. Currently only Windows and Linux are supported cos I don't got a Mac.
// 32-bit Windows defines _WIN32; 64-bit Windows defines _WIN32 and _WIN64
// Note that threading is disabled on Linux until I can figure out how to get it compiling
#ifdef _WIN32
#include <System/Windows.hpp> //#define WILDCAT_WINDOWS
#define WILDCAT_THREADING
#elif defined(__linux__)
#define WILDCAT_LINUX
#undef WILDCAT_THREADING // disable threading
#else
#error Unknown OS!
#endif
//#define WILDCAT_AUDIO
// MAKES COUT MUCH FASTER BUT DOES NOT GUARANTEE ORDER OR COMPLETION BEFORE EXIT/CRASH.
const bool FAST_COUT = false;
/* If CPU isn't relinquished, then OpenGL tends to run at 100% CPU for some reason. */
/* This uses MsgWaitForMultipleObjects, which will let the OS do other things until any kind of input event occurs */
const bool RELINQUISH_CPU = true;
const unsigned int RELINQUISH_CPU_TIMEOUT = 1; /* 10-100 seems to be okay. Maximum amount of time to relinquish */
// THREADING ////////////////////////////////////////////////////////////////////////////////////////////////
// Threading will not be optional in the future,
// it's way too complex to maintain a non-threaded version of the same code.
#ifdef WILDCAT_THREADING
// Threading libraries
#include <atomic>
#include <mutex>
#include <shared_mutex>
#endif
// I believe these require MingW-W64
// They do nothing if WILDCAT_THREADING is not defined
#include <System/Thread/Mutex.hpp>
#include <System/Thread/Atomic.hpp>
#define AUTO_SET_CORES // The number of cores will be set to the OS reported number of cores
unsigned short int N_CORES = 1; // can be changed in init if threads are enabled
const unsigned short int MAX_CORES = 4; // The number of cores will never exceed this value even if the OS has more.
// PATHS ////////////////////////////////////////////////////////////////////////////////////////////////////
// This needs to error if path is bad
//const std::string SAVE_FOLDER_PATH = "C:\\Users\\Lenovo\\Desktop\\WorldSim-savedata";
std::string currentSavePath = "";
// Program will save data to file. It saves a lot of data and it can end up taking up a lot of space,
// not good for your SSD.
#define SAVE_DATA
// WINDOW ///////////////////////////////////////////////////////////////////////////////////////////////////
// SYSTEM STRINGS
const std::string VERSION_NUMBER = "0.0.205indev";
#ifdef WILDCAT_THREADING
const std::string THREAD_STATUS = "threaded";
#else
const std::string THREAD_STATUS = "unthreaded";
#endif
#ifdef WILDCAT_WINDOWS
const std::string VERSION = VERSION_NUMBER+" Win32 "+THREAD_STATUS;
#else
const std::string VERSION = VERSION_NUMBER+" Lin32 "+THREAD_STATUS;
#endif
const std::string G_WINDOW_TITLE = "WorldSim";
unsigned int RESOLUTIONX=1024, RESOLUTIONY=900;
const bool MAXIMISE_WINDOW = false;
// GAME /////////////////////////////////////////////////////////////////////////////////////////////////////
// Player stuff.
// The player is a character object, however he has a few special attributes which are handled differently.
// For efficiency these are handled globally to prevent making a class which is only inherited by a single
// character.
// This probably should be somewhere else
class Character;
Character * playerCharacter = 0; /* Global link to the player character (null if player hasn't selected a character) */
class Item;
Item * inventoryGrid [10][10];
#include "Driver_Settings_Enums.hpp"
//DEBUG SETTINGS ///////////////////////////////////////////////////////////////////////////////////////////////////////
bool FOG_OF_WAR = true; // Enable/disable fog rendering
bool QUICKSTART_GENERATOR = true; // Skip menu stuff and immediately generate a default world.
//Quickly go straight into the simulator.
const bool QUICKSTART_SIMULATOR = false; // Skip menu stuff and jump right into the game. (Will use defaults).
const bool ENABLE_BACKGROUND_SIMULATION = false; /* Can cause choppy performance when debugging */
int worldPop = 0;
int lastline = 0;
// DEFAULT WORLD SETTINGS //////////////////////////////////////////////////////////////////////////////////////////////
const int QUICKSTART_WORLD_SIZE = 129; /* Please set to (power of 2)+1. */
long long int INITIAL_YEARS_SIMULATE = 0;
// Default setting on the GUI
const int DEFAULT_WORLD_SIZE_SLOT = 1; /* 0 = 33, 1 = 65, 129, 257, 513, 1025. Set it lower for easier debugging. */
const int DEFAULT_NUMBER_TRIBES_DWARVEN = 1;
const int DEFAULT_NUMBER_TRIBES_HUMAN = 1;
const int DEFAULT_NUMBER_TRIBES_ELVEN = 0;
const int DEFAULT_NUMBER_CIVS = 0;
const int STARTING_TRIBE_SIZE_HUMAN = 1;
const int STARTING_TRIBE_SIZE_DWARVEN = 20;
const int STARTING_TRIBE_SIZE_ELVEN = 1;
/* Size of each local map in tiles. Size is LOCAL_MAP_SIZE * LOCAL_MAP_SIZE.
Should be (n^2+1).
Realistically it should be 2049, however I might need to reduce it
depending on scaling and performance considerations.
It will likely be set to low values during development.
The final value will probably be fixed, because changing it will probably significantly change gameplay.
Right now I'm thinking 1025 might be a good balanced value, making each local map a square kilometer.
*/
//const int LOCAL_MAP_SIZE = 65;
// 129 is good for testing, but we will probably want to go much higher for release.
// ideally I would like a decent-sized town to fit in a single local map.
// but large cities might spill into multiple tiles.
// Initial plan was each tile to be 4,097 but I think this is simply not going to be workable, and even
// 1,025 might make travelling too boring.
const int LOCAL_MAP_SIZE = 257;
// TIME SCALING ////////////////////////////////////////////////////////////////////////////////////////////////////////
// Used to determine simulation speed.
int TIME_SCALE = 0; /* How many seconds of gametime pass per logic tick. */
/*
How many seconds pass per standard game turn. Realtime will be 60.
One option is 1 second per minute, which some games go with.
Each month is 24 days because it breaks it up neatly into 4 weeks
Each year is 4 months, one month for each season. This way the player can reasonably expect to experience
the seasons without it dragging on too long.
Another option is reducing the number of hours in the day, we could even make a single hour correspond to a time
of day: hour 1 = dawn, hour 2 = morning, etc. And could make night 1 hour.
Dawn, morning, day, afternoon, dusk, night.
*/
const int SECONDS_PER_MINUTE = 1;
const int MINUTES_PER_HOUR = 60;
const int HOURS_PER_DAY = 24;
const int DAYS_PER_MONTH = 28;
const int MONTHS_PER_YEAR = 4;
const int DAYS_PER_YEAR = DAYS_PER_MONTH*MONTHS_PER_YEAR;
int TICKS_PER_MINUTE = SECONDS_PER_MINUTE;
const int TICKS_PER_HOUR = TICKS_PER_MINUTE*MINUTES_PER_HOUR;
const int TICKS_PER_DAY = TICKS_PER_HOUR*HOURS_PER_DAY;
const int TICKS_PER_MONTH = TICKS_PER_DAY*DAYS_PER_MONTH;
const int TICKS_PER_YEAR = TICKS_PER_MONTH*MONTHS_PER_YEAR;
/* Calendar setting when new game is started. */
const int CALENDAR_INITIAL_HOUR = 8;
const int CALENDAR_INITIAL_MINUTE = 0;
/* Determines speed of day/night cycle and other time scaling */
/* In future there might just be some time speed multiplier */
/* Or less hours in a day */
//const int CALENDAR_SECONDS_PER_MINUTE = TICKS_PER_MINUTE;
// Timescale should be based on distances between cells.
// At 1:1 scale a cell is 5km*5km. Such a cell should take about 1 hour to walk across.
// Final local map size will probably be 513, and therefore timescale is 3600/512, or 7 seconds per tile.
// We can round this up to 10 for simplicity.
const int MAX_VIEW_RANGE = 20;
// CHARACTER STUFF
const int MAX_HUNGER = 1000;
const int MAX_THIRST = 300;
const double RESEARCH_SPEED_MODIFIER = 1000;
// RENDERING ////////////////////////////////////////////////////////////////////////////////////////////////
const bool OUTPUT_FRAMERATE = false; /* Will output the framerate. */
const int OUTPUT_FRAMERATE_SAMPLE_SIZE = 50;
const bool LIMIT_FRAMERATE = false;
const double FRAMERATE = 120; // SETTING IT TO A REASONABLE VALUE CAN GREATLY REDUCE STRESS ON GPU
const double POLLSPERSECOND = 30; // NOT CURRENTLY IMPLEMENTED
double LOGIC_PER_SECOND = 1;
const double PHYSICS_PER_SECOND = 10;
double ANIMATION_PER_SECOND = 10; // SETS SPEED OF ANIMATIONS
// SLOW FRAMERATE CAN BE ACTIVATED TO GET EXTRA CYCLES FOR GAMEPLAY.
int SLOW_FRAMERATE = 1000000/2;
// TURNS ON SLOW FRAMERATE
bool SLOW_FRAMERATE_ACTIVE = false;
int UFRAMERATE = 1000000/FRAMERATE;
const int UPOLLSPERSECOND = 1000000/POLLSPERSECOND;
int U_LOGIC_PER_SECOND = 1000000/LOGIC_PER_SECOND;
const int U_PHYSICS_PER_SECOND = 1000000/PHYSICS_PER_SECOND;
const int UANIMATIONSPERSECOND = 1000000/ANIMATION_PER_SECOND;
int CURRENT_ANIMATION_FRAME = 0; /* 0 - 99 */
/* Double buffering will make the frame transitions smoother, but it is slower. */
const bool DOUBLE_BUFFERING = false;
/* BUSY_WAIT: program will enter a busy wait if rendering is almost ready. Not sure if it works very well. */
const bool BUSY_WAIT = false;
const int BUSY_WAIT_USEC = 2000;
const bool LAZY_RENDERING=false; /* Only render if something happened */
bool RENDER_NEXT_FRAME=true; /* If there has been no input or state change, there's no need to render */
const bool COMPRESS_TEXTURES = false; /* May save graphics memory. Seems to significantly slow rendering */
// MISC /////////////////////////////////////////////////////////////////////////////////////////////////////
#include <limits.h> // We need ULONG_MAX for absolute coords.
#define ABSOLUTE_COORDINATE_NULL ULONG_MAX // Used as null-value for absolute coordinates
// I think this is probably pointless because any normal Windows/Linux/Mac system is going to use 4 bytes for int.
// Also such a thing may be specified explicitly with somthing like uint32_t. I need to move over to this system.
#define PORTABLE_INT_MAX 32767
// program will not do any garbage collection during shutdown
// makes testing easier but should be disabled for builds
#define FAST_EXIT
// The number of local maps to hold in memory at once. Minimum should be 4.
// (One for the player's current map, and three neighboring maps).
// However additional maps should be allocated for background processing.
// This should be set and adjusted based on the amount of RAM the user has.
// Not currently functional
// For rippling we'll probably want a minimum of 25 cells around the player permanently loaded.
const int MAX_LOCAL_MAPS_IN_MEMORY = 20;
const int MAX_LOCAL_MAPS_IN_BACKGROUND_MEMORY = 3;
// Coordinates of the map loaded for debugging.
int DEBUG_X=-1;
int DEBUG_Y=-1;
bool RESET=false;
bool HOTKEYS_ENABLED = true;
bool CLEAN_SAVES_ON_EXIT = true;
bool NO_BACKLOG=false;
// GLOBAL FLAGS
// increments each time a local map is accessed
// this allows us to cache the oldest maps
// only update when touching a new map.
// when this reaches overflow the IDs must be rebuilt
unsigned long int CACHE_ID=0;
Mutex mutexCout;
Mutex mutexCacheID; // lock to increment cache ID.
#ifdef WILDCAT_THREADING
std::atomic <bool> QUIT_FLAG=false;
// game will delay shutting down until the shutdown
// manager can lock this mutex
std::shared_mutex MUTEX_SHUTDOWN;
std::shared_mutex MUTEX_TEST;
//std::mutex mutexCout;
// The maximum number of maps that may be cached in memory. This is set based on the amount
// of free RAM, but has a minimum value of 12.
// Currently it seems a local map requires about 2MB of RAM, but that will likely increase
// in the future.
// If the user has a fast swap file then it might be better to just cache everything
// in virtual RAM and let the OS handle it. In this case it might be best to let
// the user set the cache size.
std::atomic <int> MAP_CACHE_SIZE = 12;
#else
bool QUIT_FLAG = false;
unsigned int MAP_CACHE_SIZE = 12;
#endif
bool DONT_RENDER = false; /* In debugging, rendering can be disabled by pressing R. */
bool LIMIT_LOGIC = true; /* Press S. */
bool FORCE_LOGIC_FRAME = false; /* True will trigger next logic frame immediately. */
bool PAUSE_LOGIC = false; /* True will suspend logic. */
bool EMULATE_2_BUTTON_MIDDLE_CLICK = true; // mmiddle click without middle mouse button by pressing left and right click
// MORE STRINGS
const char THOUSANDS_DELIMITER = ',';
const char DECIMAL_DELIMITER = '.';
std::string NYA;
const std::string ADVENTURE_MODE_MANUAL = "Adventure mode manual. Click MAN again or press ESC to close it.\nWelcome to Adventure Mode. This manual will be used to explain some basic stuff you can do in the game.\n\nButtons:\nINV - Access inventory and equipment. (not currently implemented)\n SNK - Sneak. Your line of sight will increase and allow you to see around corners. However your movement speed will be halved. Sneaking will also reduce your visibility so that if you are next to fog (from the NPC's view), you can't be seen.\nSPT - Sprint (not implemented). You will travel twice as fast but will have low view distance.\n\nHotkeys:\nE - use equipped item. Click on a tile to use your item there. Use mousewheel to scroll through options. Left click to select an option. Right-click to exit menu.\nSPACE - Talk to adjacent NPC.";
#endif // WORLDSIM_DRIVER_SETTINGS_CPP