| 1 |
|
| 2 |
// pengine.h [pengine] |
| 3 |
|
| 4 |
// Copyright 2004-2006 Jasmine Langridge, [email protected] |
| 5 |
// License: GPL version 2 (see included gpl.txt) |
| 6 |
|
| 7 |
|
| 8 |
#ifndef PENGINE_H_INCLUDED |
| 9 |
#define PENGINE_H_INCLUDED |
| 10 |
|
| 11 |
#include <stdlib.h> |
| 12 |
|
| 13 |
#include <iostream> |
| 14 |
|
| 15 |
#include <vector> |
| 16 |
#include <list> |
| 17 |
#include <string> |
| 18 |
#include <utility> |
| 19 |
|
| 20 |
|
| 21 |
// "SDL.h" is supposed to be the portable way, but it |
| 22 |
// doesn't seem to work in some circumstances... |
| 23 |
//#include "SDL.h" |
| 24 |
#include <SDL2/SDL.h> |
| 25 |
|
| 26 |
|
| 27 |
// The PhysicsFS game file system |
| 28 |
#include <physfs.h> |
| 29 |
|
| 30 |
#include <GL/glew.h> |
| 31 |
//#include <GL/glext.h> |
| 32 |
|
| 33 |
#include <tinyxml2.h> |
| 34 |
using namespace tinyxml2; |
| 35 |
|
| 36 |
// Some maths utils and macros |
| 37 |
#include "vmath.h" |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
class PUtil; |
| 42 |
|
| 43 |
class PApp; |
| 44 |
class PSubsystem; |
| 45 |
class PSSRender; |
| 46 |
class PParticleType; |
| 47 |
struct PParticle_s; |
| 48 |
class PSSTexture; |
| 49 |
class PImage; |
| 50 |
class PTexture; |
| 51 |
class PSSAudio; |
| 52 |
class PAudioSample; |
| 53 |
class PAudioInstance; |
| 54 |
class PSSEffect; |
| 55 |
class PEffect; |
| 56 |
class PSSModel; |
| 57 |
class PFace; |
| 58 |
class PMesh; |
| 59 |
class PModel; |
| 60 |
class PTerrain; |
| 61 |
|
| 62 |
class PException; |
| 63 |
class PUserException; |
| 64 |
class PFileException; |
| 65 |
class PParseException; |
| 66 |
|
| 67 |
class PCodriverVoice; |
| 68 |
|
| 69 |
#include "exception.h" |
| 70 |
|
| 71 |
|
| 72 |
// Utility |
| 73 |
|
| 74 |
#define DEBUGLEVEL_CRITICAL 0 |
| 75 |
#define DEBUGLEVEL_ENDUSER 10 |
| 76 |
#define DEBUGLEVEL_TEST 20 |
| 77 |
#define DEBUGLEVEL_DEVELOPER 30 |
| 78 |
|
| 79 |
/// Enables an MS-style macro for use with unused function parameters. |
| 80 |
#ifndef UNREFERENCED_PARAMETER |
| 81 |
#define UNREFERENCED_PARAMETER(p) static_cast<void> (p) |
| 82 |
#endif |
| 83 |
|
| 84 |
/// |
| 85 |
/// @brief Helper structure for storing dirt information. |
| 86 |
/// |
| 87 |
struct dirtinfo |
| 88 |
{ |
| 89 |
float startsize = 0.1f; |
| 90 |
float endsize = 0.5f; |
| 91 |
float decay = 6.0f; |
| 92 |
|
| 93 |
dirtinfo() = default; |
| 94 |
|
| 95 |
dirtinfo(float startsize, float endsize, float decay): |
| 96 |
startsize(startsize), |
| 97 |
endsize(endsize), |
| 98 |
decay(decay) |
| 99 |
{ |
| 100 |
} |
| 101 |
}; |
| 102 |
|
| 103 |
/// |
| 104 |
/// @brief Helper structure for storing RGB colors. |
| 105 |
/// |
| 106 |
struct rgbcolor |
| 107 |
{ |
| 108 |
uint8_t r=0; ///< Red. |
| 109 |
uint8_t g=0; ///< Green. |
| 110 |
uint8_t b=0; ///< Blue. |
| 111 |
|
| 112 |
rgbcolor() = default; |
| 113 |
|
| 114 |
rgbcolor(uint8_t r, uint8_t g, uint8_t b): |
| 115 |
r(r), |
| 116 |
g(g), |
| 117 |
b(b) |
| 118 |
{ |
| 119 |
} |
| 120 |
|
| 121 |
bool operator == (const rgbcolor &rhs) const |
| 122 |
{ |
| 123 |
if (r == rhs.r && |
| 124 |
g == rhs.g && |
| 125 |
b == rhs.b) |
| 126 |
return true; |
| 127 |
|
| 128 |
return false; |
| 129 |
} |
| 130 |
|
| 131 |
bool operator != (const rgbcolor &rhs) const |
| 132 |
{ |
| 133 |
if (r != rhs.r || |
| 134 |
g != rhs.g || |
| 135 |
b != rhs.b) |
| 136 |
return true; |
| 137 |
|
| 138 |
return false; |
| 139 |
} |
| 140 |
}; |
| 141 |
|
| 142 |
#include "terrainmap.h" |
| 143 |
|
| 144 |
/// |
| 145 |
/// @brief Class which contains helper functions |
| 146 |
/// @todo maybe set these functions in a more ordered way? |
| 147 |
/// |
| 148 |
class PUtil { |
| 149 |
private: |
| 150 |
PUtil() { } // cannot be constructed |
| 151 |
|
| 152 |
static int deblev; |
| 153 |
|
| 154 |
public: |
| 155 |
// Output streams |
| 156 |
static std::ostream &outLog() { return std::cout; } |
| 157 |
|
| 158 |
// Debug level |
| 159 |
static bool isDebugLevel(int debugLevel) { return deblev >= debugLevel; } |
| 160 |
static void setDebugLevel(int debugLevel) { deblev = debugLevel; } |
| 161 |
|
| 162 |
// TODO: these two functions are probably misplaced here |
| 163 |
static TerrainType decideRoadSurface(const rgbcolor &c); |
| 164 |
static float decideFrictionCoef(TerrainType tt); |
| 165 |
static float decideResistance(TerrainType tt); |
| 166 |
static const char * getTerrainInfo(TerrainType tt); |
| 167 |
static dirtinfo getDirtInfo(TerrainType tt); |
| 168 |
static rgbcolor getTerrainColor(TerrainType tt); |
| 169 |
|
| 170 |
/*! Get token and value from a string line. The token is the string |
| 171 |
* before first space. The value, is the remaining string |
| 172 |
* \return true if could extract token and value */ |
| 173 |
static bool getToken(std::string line, std::string& tok, std::string& value); |
| 174 |
|
| 175 |
static char* fgets2(char *s, int size, PHYSFS_file *pfile); |
| 176 |
|
| 177 |
// Given "data/blah/pic.jpg" will return "data/blah/" |
| 178 |
static std::string extractPathFromFilename(const std::string &filename); |
| 179 |
|
| 180 |
static std::string assemblePath(const std::string &relativefile, const std::string &parentfile); |
| 181 |
|
| 182 |
// Load XML file and return the root element of given name (failure: null) |
| 183 |
static XMLElement *loadRootElement(XMLDocument &doc, const std::string &filename, const char *rootName); |
| 184 |
|
| 185 |
static bool copyFile(const std::string &fileFrom, const std::string &fileTo); |
| 186 |
static std::list<std::string> findFiles(const std::string &basedir, const std::string &extension); |
| 187 |
|
| 188 |
static std::string formatInt(int value, int width); |
| 189 |
static std::string formatInt(int value); |
| 190 |
|
| 191 |
static std::string formatTime(float seconds); |
| 192 |
static std::string formatTimeShort(float seconds); |
| 193 |
|
| 194 |
// RWops created must be freed by using SDL freesrc on load |
| 195 |
static SDL_RWops *allocPhysFSops(PHYSFS_file *pfile); |
| 196 |
}; |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
#include "hiscore1.h" |
| 201 |
#include "app.h" |
| 202 |
#include "subsys.h" |
| 203 |
#include "audio.h" |
| 204 |
#include "render.h" |
| 205 |
#include "codriver.h" |
| 206 |
|
| 207 |
|
| 208 |
#endif // PENGINE_H_INCLUDED |
| 209 |
|
| 210 |
|