-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDriver.cpp
210 lines (160 loc) · 5.8 KB
/
Driver.cpp
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
/* WorldSim: Driver
Main file for WorldSim. Created by Ryan Babij (https://github.com/RyanBabij/WorldSim)
All code and binaries in WorldSim repo are copyrighted.
Wildcat code is public domain.
*/
// Global vars and strings (should eventually be ported into globalSettings object)
#include "Driver_Settings.cpp"
#include "Driver_GlobalSettings.cpp"
GlobalSettings globalSettings;
// OpenGL includes go here because some global objects depend on OpenGL defines.
#define GLEW_STATIC // static link GLEW
// Need to figure out which of this is better. I think GLEW is more supported.
#include <Graphics/OpenGL/glew.h> // THIS CURRENTLY FIXES LINKER CRAP. Also allows RGBA_COMPRESSED, it would seem.
#define FREEGLUT_STATIC // static link freeGLUT
#include <Graphics/OpenGL/freeglut.h> //
// Global objects declared after OpenGL because some objects depend on OpenGL defines.
#include "Driver_GlobalObjects.hpp"
// This is a huge mess and should be cleaned up by making sure headers include all files they need.
#include "Creature_Species.cpp" // Not sure why this needs to be here.
#include "TextureInterface.cpp"
#include "Driver_LoadTextures.hpp"
#include "World.hpp"
#include "World_Local.hpp"
/* Instead of having a global worldViewer, I think it would be better to have lots of local worldviewers, as currently I have a problem with the various menus interfering with the global worldViewer. */
#include "World_Viewer.hpp"
WorldViewer worldViewer;
#include "World_Viewer_Minimap.hpp"
#include "World_Viewer_Rain_Manager.cpp"
#include <Graphics/Render/Renderer.cpp>
#include <Graphics/Texture/Texture.hpp>
#include <Graphics/Texture/TextureLoader.hpp>
// Moving world to global context means that we don't need to create millions of World pointers. */
#include "World.cpp"
World world;
// Being lazy and just having menus as global objects. These could definitely go somewhere better.
/* Title Menu / Main Menu */
#include "Menu_Title.hpp"
Menu_Title menuTitle;
/* Options menu */
#include "Menu_Options.hpp"
Menu_Options menuOptions;
/* Load game menu */
#include "Menu_LoadGame.hpp"
Menu_LoadGame menuLoadGame;
/* Title menu */
#include "Menu_WorldGenerator.hpp"
Menu_WorldGenerator menuWorldGenerator;
#include "Menu_WorldSimulator.hpp"
Menu_WorldSimulator menuWorldSimulator;
#include "Menu_AdventureMode.hpp"
Menu_AdventureMode menuAdventureMode;
// Implementation headers. I think they probably should be going somewhere else, aka the headers that actually need
// the implementations. But there's so many pointers that many of them basically don't need them.
#include "World_Biome.cpp"
#include "Pathing.hpp"
#include "World_Local.cpp"
World_Local * worldLocal;
#include "LocalTile.cpp"
#include "Creature.cpp"
#include "Creature_Knowledge.cpp"
#include "Creature_All.cpp"
#include "Creature_Deer.cpp"
#include "Character.cpp"
#include "Character_Knowledge.cpp"
#include "Civ.cpp"
#include "Civ_Dwarven.cpp"
#include "Settlement.cpp"
#include "Settlement_Dwarven.cpp"
#include "Tribe.cpp"
#include "Tribe_Dwarven.cpp"
#include "Tribe_Human.cpp"
#include "Tribe_Elf.cpp"
#include "WorldObject.cpp"
#include "WorldObject_Tree.cpp"
#include "WorldObject_Flora.cpp"
#include "WorldObject_Rock.cpp"
#include "WorldObject_Sign.cpp"
#include "WorldObjectGlobal.cpp"
#include "WorldObjectGlobal_TribalArtifact.cpp"
#include "Item.cpp"
#include "Recipe.cpp"
#include "Item_Attributes.cpp"
#include "ItemFactory.cpp"
#include "Location.cpp"
#include "Stockpile.cpp"
/* Game initialization goes here. */
#include "Driver_Init.hpp"
/* OpenGL function hooks go here. */
#include "Driver_GLHooks.hpp"
// Main dependencies.
#include <Data/ArgReader.hpp>
#include <signal.h> // for catching CTRL+C
#include <iostream>
inline void printHelp()
{
std::cout<<"\nWorldSim"<<VERSION<<".\n";
std::cout<<" Warning: This is not a stable release.\n";
std::cout<<" WorldSim is a 2D tile-based sandbox RPG with procedurally generated fantasy world.\n";
std::cout<<" License: Public domain. This program uses a modified version of LodePNG.\n";
std::cout<<" This is a pre-alpha release, and is not fully functional.\n";
std::cout<<"Options:\n";
std::cout<<"None.\n";
std::cout<<"\n";
std::cout<<"Version "<<VERSION<<".\n";
std::cout<<"Compiled: "<<__DATE__<<". "<<__TIME__<<".\n";
std::cout<<"Compile count: "<<COMPILE_COUNT<<".\n";
std::cout<<"\n";
}
void pauseGame()
{
std::cout<<"pauseGame() called.\n";
PAUSE_LOGIC=true;
}
/* Tidies up the game and shuts down. */
void shutDown(int signal /*=0*/)
{
std::cout<<"Driver::shutDown().\n";
QUIT_FLAG=true;
exit(1);
}
int main(int nArgs, char ** arg)
{
ArgReader argReader;
argReader.feed(nArgs,arg);
if (argReader.hasTag("-help") || argReader.hasTag("--help") || argReader.hasTag("-h"))
{
printHelp();
return 0;
}
std::cout<<"\nWorldSim "<<VERSION<<". Warning: This is not a stable release.\n";
std::cout<<"Warning: This program writes a lot of data to disk, which may wear out SSDs.\n";
GL_init(nArgs, arg);
/* Initialise game. Load textures, fonts etc. */
init();
// Catch CTRL+C signals
// CTRL+C from the CMD seems to terminate threads before they
// can shutdown properly, leaving the shutdown process hanging
// fortunately this shouldn't happen in normal builds
// This function works by intercepting the normal
// CTRL+C shutdown and replaces it with a safer shutdown.
// If CTRL+C is signalled a second time it will hard exit,
// and therefore I also have a time on thread shutdown checks.
#ifdef WILDCAT_THREADING
signal (SIGINT,shutDown);
#endif
#if defined WILDCAT_THREADING
// std::thread testThread( []
// {
// Sleep(1000);
// while(true)
// {
// std::cout<<"Hello, I'm a thread\n";
// Sleep(1000);
// }
// });
#endif
/* Reshape is called here. */
glutMainLoop();
return 0;
}