|
@@ -46,24 +46,16 @@ Game::Game() {
|
46
|
46
|
mTextureStart = 0;
|
47
|
47
|
mTextureLevelOffset = 0;
|
48
|
48
|
mTextureOffset = 0;
|
49
|
|
-
|
50
|
|
- mRender = NULL;
|
51
|
49
|
}
|
52
|
50
|
|
53
|
51
|
Game::~Game() {
|
54
|
52
|
destroy();
|
55
|
|
-
|
56
|
|
- if (mRender)
|
57
|
|
- delete mRender;
|
58
|
53
|
}
|
59
|
54
|
|
60
|
55
|
int Game::initialize() {
|
61
|
|
- // Set up Renderer
|
62
|
|
- mRender = new Render();
|
63
|
|
- mRender->initTextures(getOpenRaider().mDataDir, &mTextureStart, &mTextureLevelOffset);
|
64
|
|
-
|
65
|
56
|
// Enable Renderer
|
66
|
|
- mRender->setMode(Render::modeLoadScreen);
|
|
57
|
+ getRender().initTextures(getOpenRaider().mDataDir, &mTextureStart, &mTextureLevelOffset);
|
|
58
|
+ getRender().setMode(Render::modeLoadScreen);
|
67
|
59
|
|
68
|
60
|
// Enable World Hopping
|
69
|
61
|
getWorld().setFlag(World::fEnableHopping);
|
|
@@ -76,10 +68,10 @@ void Game::destroy() {
|
76
|
68
|
delete [] mName;
|
77
|
69
|
|
78
|
70
|
mLoaded = false;
|
79
|
|
- mRender->setMode(Render::modeDisabled);
|
|
71
|
+ getRender().setMode(Render::modeDisabled);
|
80
|
72
|
|
81
|
73
|
getWorld().destroy();
|
82
|
|
- mRender->ClearWorld();
|
|
74
|
+ getRender().ClearWorld();
|
83
|
75
|
getSound().clear(); // Remove all previously loaded sounds
|
84
|
76
|
}
|
85
|
77
|
|
|
@@ -134,7 +126,7 @@ int Game::loadLevel(const char *level) {
|
134
|
126
|
}
|
135
|
127
|
|
136
|
128
|
mLoaded = true;
|
137
|
|
- mRender->setMode(Render::modeVertexLight);
|
|
129
|
+ getRender().setMode(Render::modeVertexLight);
|
138
|
130
|
|
139
|
131
|
return 0;
|
140
|
132
|
}
|
|
@@ -178,7 +170,7 @@ void Game::handleMouseMotion(int xrel, int yrel) {
|
178
|
170
|
}
|
179
|
171
|
|
180
|
172
|
void Game::display() {
|
181
|
|
- mRender->Display();
|
|
173
|
+ getRender().Display();
|
182
|
174
|
}
|
183
|
175
|
|
184
|
176
|
int Game::command(std::vector<char *> *args) {
|
|
@@ -193,7 +185,7 @@ int Game::command(std::vector<char *> *args) {
|
193
|
185
|
char *mode = args->at(1);
|
194
|
186
|
if (strcmp(mode, "wireframe") == 0) {
|
195
|
187
|
if (mLoaded) {
|
196
|
|
- mRender->setMode(Render::modeWireframe);
|
|
188
|
+ getRender().setMode(Render::modeWireframe);
|
197
|
189
|
getConsole().print("Wireframe mode");
|
198
|
190
|
} else {
|
199
|
191
|
getConsole().print("Load a level to set this mode!");
|
|
@@ -201,7 +193,7 @@ int Game::command(std::vector<char *> *args) {
|
201
|
193
|
}
|
202
|
194
|
} else if (strcmp(mode, "solid") == 0) {
|
203
|
195
|
if (mLoaded) {
|
204
|
|
- mRender->setMode(Render::modeSolid);
|
|
196
|
+ getRender().setMode(Render::modeSolid);
|
205
|
197
|
getConsole().print("Solid mode");
|
206
|
198
|
} else {
|
207
|
199
|
getConsole().print("Load a level to set this mode!");
|
|
@@ -209,7 +201,7 @@ int Game::command(std::vector<char *> *args) {
|
209
|
201
|
}
|
210
|
202
|
} else if (strcmp(mode, "texture") == 0) {
|
211
|
203
|
if (mLoaded) {
|
212
|
|
- mRender->setMode(Render::modeTexture);
|
|
204
|
+ getRender().setMode(Render::modeTexture);
|
213
|
205
|
getConsole().print("Texture mode");
|
214
|
206
|
} else {
|
215
|
207
|
getConsole().print("Load a level to set this mode!");
|
|
@@ -217,14 +209,14 @@ int Game::command(std::vector<char *> *args) {
|
217
|
209
|
}
|
218
|
210
|
} else if (strcmp(mode, "vertexlight") == 0) {
|
219
|
211
|
if (mLoaded) {
|
220
|
|
- mRender->setMode(Render::modeVertexLight);
|
|
212
|
+ getRender().setMode(Render::modeVertexLight);
|
221
|
213
|
getConsole().print("Vertexlight mode");
|
222
|
214
|
} else {
|
223
|
215
|
getConsole().print("Load a level to set this mode!");
|
224
|
216
|
return -5;
|
225
|
217
|
}
|
226
|
218
|
} else if (strcmp(mode, "titlescreen") == 0) {
|
227
|
|
- mRender->setMode(Render::modeLoadScreen);
|
|
219
|
+ getRender().setMode(Render::modeLoadScreen);
|
228
|
220
|
getConsole().print("Titlescreen mode");
|
229
|
221
|
} else {
|
230
|
222
|
getConsole().print("Invalid use of mode command (%s)!", mode);
|
|
@@ -271,9 +263,9 @@ int Game::command(std::vector<char *> *args) {
|
271
|
263
|
char c = args->at(1)[0];
|
272
|
264
|
if (c == 'n') {
|
273
|
265
|
// Step all skeletal models to their next animation
|
274
|
|
- if (mRender->getFlags() & Render::fAnimateAllModels) {
|
275
|
|
- for (unsigned int i = 0; i < mRender->mModels.size(); i++) {
|
276
|
|
- SkeletalModel *m = mRender->mModels[i];
|
|
266
|
+ if (getRender().getFlags() & Render::fAnimateAllModels) {
|
|
267
|
+ for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
|
|
268
|
+ SkeletalModel *m = getRender().mModels[i];
|
277
|
269
|
if (m->getAnimation() < ((int)m->model->animation.size() - 1))
|
278
|
270
|
m->setAnimation(m->getAnimation() + 1);
|
279
|
271
|
else
|
|
@@ -285,9 +277,9 @@ int Game::command(std::vector<char *> *args) {
|
285
|
277
|
}
|
286
|
278
|
} else if (c == 'p') {
|
287
|
279
|
// Step all skeletal models to their previous animation
|
288
|
|
- if (mRender->getFlags() & Render::fAnimateAllModels) {
|
289
|
|
- for (unsigned int i = 0; i < mRender->mModels.size(); i++) {
|
290
|
|
- SkeletalModel *m = mRender->mModels[i];
|
|
280
|
+ if (getRender().getFlags() & Render::fAnimateAllModels) {
|
|
281
|
+ for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
|
|
282
|
+ SkeletalModel *m = getRender().mModels[i];
|
291
|
283
|
if (m->getAnimation() > 0)
|
292
|
284
|
m->setAnimation(m->getAnimation() - 1);
|
293
|
285
|
else
|
|
@@ -305,9 +297,9 @@ int Game::command(std::vector<char *> *args) {
|
305
|
297
|
return -12;
|
306
|
298
|
}
|
307
|
299
|
if (b)
|
308
|
|
- mRender->setFlags(Render::fAnimateAllModels);
|
|
300
|
+ getRender().setFlags(Render::fAnimateAllModels);
|
309
|
301
|
else
|
310
|
|
- mRender->clearFlags(Render::fAnimateAllModels);
|
|
302
|
+ getRender().clearFlags(Render::fAnimateAllModels);
|
311
|
303
|
getConsole().print(b ? "Animating all models" : "No longer animating all models");
|
312
|
304
|
}
|
313
|
305
|
} else {
|
|
@@ -364,9 +356,9 @@ int Game::command(std::vector<char *> *args) {
|
364
|
356
|
return -15;
|
365
|
357
|
}
|
366
|
358
|
if (b)
|
367
|
|
- mRender->setFlags(Render::fGL_Lights);
|
|
359
|
+ getRender().setFlags(Render::fGL_Lights);
|
368
|
360
|
else
|
369
|
|
- mRender->clearFlags(Render::fGL_Lights);
|
|
361
|
+ getRender().clearFlags(Render::fGL_Lights);
|
370
|
362
|
getConsole().print("GL-Lights are now %s", b ? "on" : "off");
|
371
|
363
|
} else {
|
372
|
364
|
getConsole().print("Invalid use of game-light-command!");
|
|
@@ -380,9 +372,9 @@ int Game::command(std::vector<char *> *args) {
|
380
|
372
|
return -17;
|
381
|
373
|
}
|
382
|
374
|
if (b)
|
383
|
|
- mRender->setFlags(Render::fFog);
|
|
375
|
+ getRender().setFlags(Render::fFog);
|
384
|
376
|
else
|
385
|
|
- mRender->clearFlags(Render::fFog);
|
|
377
|
+ getRender().clearFlags(Render::fFog);
|
386
|
378
|
getConsole().print("Fog is now %s", b ? "on" : "off");
|
387
|
379
|
} else {
|
388
|
380
|
getConsole().print("Invalid use of game-fog-command!");
|
|
@@ -459,7 +451,7 @@ void Game::processTextures()
|
459
|
451
|
mTombRaider.Texture(i, &image, &bumpmap);
|
460
|
452
|
|
461
|
453
|
// Overwrite any previous level textures on load
|
462
|
|
- mRender->loadTexture(image, 256, 256, mTextureLevelOffset + i);
|
|
454
|
+ getRender().loadTexture(image, 256, 256, mTextureLevelOffset + i);
|
463
|
455
|
|
464
|
456
|
#ifdef MULTITEXTURE
|
465
|
457
|
gMapTex2Bump[mTextureLevelOffset + i] = -1;
|
|
@@ -471,7 +463,7 @@ void Game::processTextures()
|
471
|
463
|
gMapTex2Bump[mTextureLevelOffset + i] = mTextureLevelOffset + i +
|
472
|
464
|
mTombRaider.NumTextures();
|
473
|
465
|
#endif
|
474
|
|
- mRender->loadTexture(bumpmap, 256, 256, mTextureLevelOffset + i +
|
|
466
|
+ getRender().loadTexture(bumpmap, 256, 256, mTextureLevelOffset + i +
|
475
|
467
|
mTombRaider.NumTextures());
|
476
|
468
|
}
|
477
|
469
|
|
|
@@ -754,7 +746,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
754
|
746
|
thing->animate = false;
|
755
|
747
|
|
756
|
748
|
sModel = new SkeletalModel();
|
757
|
|
- mRender->addSkeletalModel(sModel);
|
|
749
|
+ getRender().addSkeletalModel(sModel);
|
758
|
750
|
thing->tmpHook = sModel; // temp hack to keep a running version during refactoring
|
759
|
751
|
|
760
|
752
|
if (mTombRaider.Engine() == TR_VERSION_1)
|
|
@@ -773,7 +765,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
773
|
765
|
//! \fixme Check here and see if we already have one for object_id later
|
774
|
766
|
// if (getWorld().isCachedSkeletalModel(moveable[index].object_id))
|
775
|
767
|
// {
|
776
|
|
- // thing->modelId = mRender->add(sModel);
|
|
768
|
+ // thing->modelId = getRender().add(sModel);
|
777
|
769
|
// return;
|
778
|
770
|
// }
|
779
|
771
|
|
|
@@ -901,7 +893,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
901
|
893
|
r_model->ponytail[1] -= 32;
|
902
|
894
|
}
|
903
|
895
|
|
904
|
|
- mRender->setFlags(Render::fRenderPonytail);
|
|
896
|
+ getRender().setFlags(Render::fRenderPonytail);
|
905
|
897
|
getConsole().print("Found known ponytail");
|
906
|
898
|
}
|
907
|
899
|
break; // ?
|
|
@@ -923,7 +915,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
923
|
915
|
r_model->ponyOff = 40;
|
924
|
916
|
r_model->ponyOff2 = 0;
|
925
|
917
|
|
926
|
|
- mRender->setFlags(Render::fRenderPonytail);
|
|
918
|
+ getRender().setFlags(Render::fRenderPonytail);
|
927
|
919
|
getConsole().print("Found ponytail?");
|
928
|
920
|
}
|
929
|
921
|
break;
|
|
@@ -1105,7 +1097,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
1105
|
1097
|
|
1106
|
1098
|
if (i == skyMesh)
|
1107
|
1099
|
{
|
1108
|
|
- mRender->setSkyMesh(i, //moveable[i].starting_mesh,
|
|
1100
|
+ getRender().setSkyMesh(i, //moveable[i].starting_mesh,
|
1109
|
1101
|
(mTombRaider.Engine() == TR_VERSION_2));
|
1110
|
1102
|
}
|
1111
|
1103
|
|
|
@@ -1152,7 +1144,7 @@ void Game::setupTextureColor(texture_tri_t *r_tri, float *colorf)
|
1152
|
1144
|
gColorTextureHACK.push_back(colorI);
|
1153
|
1145
|
r_tri->texture = mTextureOffset + gColorTextureHACK.size();
|
1154
|
1146
|
|
1155
|
|
- mRender->loadTexture(Texture::generateColorTexture(color, 32, 32),
|
|
1147
|
+ getRender().loadTexture(Texture::generateColorTexture(color, 32, 32),
|
1156
|
1148
|
32, 32,
|
1157
|
1149
|
r_tri->texture);
|
1158
|
1150
|
|
|
@@ -1393,7 +1385,7 @@ void Game::processRooms()
|
1393
|
1385
|
{
|
1394
|
1386
|
getConsole().print("WARNING: Handling invalid vertex array in room");
|
1395
|
1387
|
getWorld().addRoom(0x0);
|
1396
|
|
- mRender->addRoom(0x0);
|
|
1388
|
+ getRender().addRoom(0x0);
|
1397
|
1389
|
|
1398
|
1390
|
//printf("x");
|
1399
|
1391
|
//fflush(stdout);
|
|
@@ -1936,7 +1928,7 @@ void Game::processRooms()
|
1936
|
1928
|
getWorld().addRoom(r_mesh);
|
1937
|
1929
|
|
1938
|
1930
|
rRoom->room = r_mesh;
|
1939
|
|
- mRender->addRoom(rRoom);
|
|
1931
|
+ getRender().addRoom(rRoom);
|
1940
|
1932
|
|
1941
|
1933
|
//printf(".");
|
1942
|
1934
|
//fflush(stdout);
|