|
@@ -13,7 +13,6 @@
|
13
|
13
|
|
14
|
14
|
#include <algorithm>
|
15
|
15
|
#include <map>
|
16
|
|
-#include <vector>
|
17
|
16
|
#include <cstdlib>
|
18
|
17
|
|
19
|
18
|
#include "main.h"
|
|
@@ -34,7 +33,6 @@ Game::Game() {
|
34
|
33
|
mLoaded = false;
|
35
|
34
|
mName = NULL;
|
36
|
35
|
mLara = NULL;
|
37
|
|
- mFlags = 0;
|
38
|
36
|
|
39
|
37
|
mTextureStart = 0;
|
40
|
38
|
mTextureLevelOffset = 0;
|
|
@@ -70,7 +68,7 @@ int Game::initialize() {
|
70
|
68
|
mRender->setMode(Render::modeLoadScreen);
|
71
|
69
|
|
72
|
70
|
// Enable World Hopping
|
73
|
|
- mWorld.setFlag(World::fEnableHopping);
|
|
71
|
+ getWorld().setFlag(World::fEnableHopping);
|
74
|
72
|
|
75
|
73
|
return 0;
|
76
|
74
|
}
|
|
@@ -82,7 +80,7 @@ void Game::destroy() {
|
82
|
80
|
mLoaded = false;
|
83
|
81
|
mRender->setMode(Render::modeDisabled);
|
84
|
82
|
|
85
|
|
- mWorld.destroy();
|
|
83
|
+ getWorld().destroy();
|
86
|
84
|
mRender->ClearWorld();
|
87
|
85
|
getSound().clear(); // Remove all previously loaded sounds
|
88
|
86
|
}
|
|
@@ -146,13 +144,13 @@ int Game::loadLevel(const char *level) {
|
146
|
144
|
void Game::handleAction(ActionEvents action, bool isFinished) {
|
147
|
145
|
if (mLoaded) {
|
148
|
146
|
if (action == forwardAction) {
|
149
|
|
- mWorld.moveEntity(mLara, 'f');
|
|
147
|
+ getWorld().moveEntity(mLara, 'f');
|
150
|
148
|
} else if (action == backwardAction) {
|
151
|
|
- mWorld.moveEntity(mLara, 'b');
|
|
149
|
+ getWorld().moveEntity(mLara, 'b');
|
152
|
150
|
} else if (action == leftAction) {
|
153
|
|
- mWorld.moveEntity(mLara, 'l');
|
|
151
|
+ getWorld().moveEntity(mLara, 'l');
|
154
|
152
|
} else if (action == rightAction) {
|
155
|
|
- mWorld.moveEntity(mLara, 'r');
|
|
153
|
+ getWorld().moveEntity(mLara, 'r');
|
156
|
154
|
}
|
157
|
155
|
}
|
158
|
156
|
}
|
|
@@ -493,7 +491,7 @@ void Game::processSprites()
|
493
|
491
|
s_index = sprite_sequence[j].offset;
|
494
|
492
|
|
495
|
493
|
r_mesh = new sprite_seq_t;
|
496
|
|
- mWorld.addSprite(r_mesh);
|
|
494
|
+ getWorld().addSprite(r_mesh);
|
497
|
495
|
r_mesh->num_sprites = -sprite_sequence[j].negative_length;
|
498
|
496
|
r_mesh->sprite = new sprite_t[r_mesh->num_sprites];
|
499
|
497
|
|
|
@@ -737,7 +735,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
737
|
735
|
}
|
738
|
736
|
|
739
|
737
|
//! \fixme Check here and see if we already have one for object_id later
|
740
|
|
- // if (mWorld.isCachedSkeletalModel(moveable[index].object_id))
|
|
738
|
+ // if (getWorld().isCachedSkeletalModel(moveable[index].object_id))
|
741
|
739
|
// {
|
742
|
740
|
// thing->modelId = mRender->add(sModel);
|
743
|
741
|
// return;
|
|
@@ -835,9 +833,9 @@ void Game::processMoveable(int index, int i, int *ent,
|
835
|
833
|
if (!found)
|
836
|
834
|
{
|
837
|
835
|
sModel->model = r_model;
|
838
|
|
- mWorld.addEntity(thing);
|
|
836
|
+ getWorld().addEntity(thing);
|
839
|
837
|
|
840
|
|
- k = mWorld.addModel(r_model);
|
|
838
|
+ k = getWorld().addModel(r_model);
|
841
|
839
|
|
842
|
840
|
cache.push_back(j);
|
843
|
841
|
cache2.push_back(r_model);
|
|
@@ -901,22 +899,19 @@ void Game::processMoveable(int index, int i, int *ent,
|
901
|
899
|
delete r_model;
|
902
|
900
|
c_model = cache2[foundIndex];
|
903
|
901
|
sModel->model = c_model;
|
904
|
|
- mWorld.addEntity(thing);
|
905
|
|
- mWorld.addModel(c_model);
|
|
902
|
+ getWorld().addEntity(thing);
|
|
903
|
+ getWorld().addModel(c_model);
|
906
|
904
|
printf("c");
|
907
|
905
|
return;
|
908
|
906
|
}
|
909
|
907
|
|
910
|
908
|
int aloop = mTombRaider.getNumAnimsForMoveable(index);
|
911
|
909
|
|
912
|
|
-#ifdef DEBUG
|
913
|
|
- if (mFlags & Flag_DebugModel)
|
914
|
|
- {
|
915
|
|
- printf("\nanimation = %i, num_animations = %i\n",
|
916
|
|
- moveable[index].animation, aloop);
|
917
|
|
- printf("\nitem[%i].flags = %i\nentity[%i]\n",
|
918
|
|
- i, item[i].flags, thing->id);
|
919
|
|
- }
|
|
910
|
+#ifdef DEBUG_MOVEABLE
|
|
911
|
+ printf("\nanimation = %i, num_animations = %i\n",
|
|
912
|
+ moveable[index].animation, aloop);
|
|
913
|
+ printf("\nitem[%i].flags = %i\nentity[%i]\n",
|
|
914
|
+ i, item[i].flags, thing->id);
|
920
|
915
|
#endif
|
921
|
916
|
|
922
|
917
|
//a = moveable[index].animation;
|
|
@@ -933,28 +928,25 @@ void Game::processMoveable(int index, int i, int *ent,
|
933
|
928
|
frame_count = (animation[a].frame_end - animation[a].frame_start) + 1;
|
934
|
929
|
animation_frame->rate = animation[a].frame_rate;
|
935
|
930
|
|
936
|
|
-#ifdef DEBUG
|
937
|
|
- if (mFlags & Flag_DebugModel)
|
938
|
|
- {
|
939
|
|
- printf("animation[%i] state and unknowns = %i, %i, %i, %i, %i\n",
|
940
|
|
- a, animation[a].state_id, animation[a].unknown1,
|
941
|
|
- animation[a].unknown2, animation[a].unknown3,
|
942
|
|
- animation[a].unknown4);
|
943
|
|
- printf("animation[%i].frame_rate = %i\n",
|
944
|
|
- a, animation[a].frame_rate);
|
945
|
|
- printf("animation[%i].next_animation = %i\n",
|
946
|
|
- a, animation[a].next_animation);
|
947
|
|
- printf("animation[%i].frame_offset = %u\n",
|
948
|
|
- a, animation[a].frame_offset);
|
949
|
|
- printf("animation[%i].anim_command = %i\n",
|
950
|
|
- a, animation[a].anim_command);
|
951
|
|
- printf("animation[%i].num_anim_commands = %i\n",
|
952
|
|
- a, animation[a].num_anim_commands);
|
953
|
|
- printf("animation[%i].state_change_offset = %i\n",
|
954
|
|
- a, animation[a].state_change_offset);
|
955
|
|
- printf(" frame_offset = %u\n",
|
956
|
|
- frame_offset);
|
957
|
|
- }
|
|
931
|
+#ifdef DEBUG_MOVEABLE
|
|
932
|
+ printf("animation[%i] state and unknowns = %i, %i, %i, %i, %i\n",
|
|
933
|
+ a, animation[a].state_id, animation[a].unknown1,
|
|
934
|
+ animation[a].unknown2, animation[a].unknown3,
|
|
935
|
+ animation[a].unknown4);
|
|
936
|
+ printf("animation[%i].frame_rate = %i\n",
|
|
937
|
+ a, animation[a].frame_rate);
|
|
938
|
+ printf("animation[%i].next_animation = %i\n",
|
|
939
|
+ a, animation[a].next_animation);
|
|
940
|
+ printf("animation[%i].frame_offset = %u\n",
|
|
941
|
+ a, animation[a].frame_offset);
|
|
942
|
+ printf("animation[%i].anim_command = %i\n",
|
|
943
|
+ a, animation[a].anim_command);
|
|
944
|
+ printf("animation[%i].num_anim_commands = %i\n",
|
|
945
|
+ a, animation[a].num_anim_commands);
|
|
946
|
+ printf("animation[%i].state_change_offset = %i\n",
|
|
947
|
+ a, animation[a].state_change_offset);
|
|
948
|
+ printf(" frame_offset = %u\n",
|
|
949
|
+ frame_offset);
|
958
|
950
|
#endif
|
959
|
951
|
|
960
|
952
|
// Get all the frames for aniamtion
|
|
@@ -997,12 +989,9 @@ void Game::processMoveable(int index, int i, int *ent,
|
997
|
989
|
}
|
998
|
990
|
}
|
999
|
991
|
|
1000
|
|
-#ifdef DEBUG
|
1001
|
|
- if (mFlags & Flag_DebugModel)
|
1002
|
|
- {
|
1003
|
|
- printf("animation[%i].boneframe[%u] = offset %u, step %i\n",
|
1004
|
|
- a, f, frame_offset, frame_step);
|
1005
|
|
- }
|
|
992
|
+#ifdef DEBUG_MOVEABLE
|
|
993
|
+ printf("animation[%i].boneframe[%u] = offset %u, step %i\n",
|
|
994
|
+ a, f, frame_offset, frame_step);
|
1006
|
995
|
#endif
|
1007
|
996
|
|
1008
|
997
|
// Mongoose 2002.08.15, Was
|
|
@@ -1165,7 +1154,7 @@ void Game::processModels()
|
1165
|
1154
|
if (index < 0 || !mTombRaider.isMeshValid(index))
|
1166
|
1155
|
{
|
1167
|
1156
|
//! \fixme allow sparse lists with matching ids instead?
|
1168
|
|
- mWorld.addMesh(NULL); // Filler, to make meshes array ids align
|
|
1157
|
+ getWorld().addMesh(NULL); // Filler, to make meshes array ids align
|
1169
|
1158
|
//printf("x");
|
1170
|
1159
|
//fflush(stdout);
|
1171
|
1160
|
return;
|
|
@@ -1347,7 +1336,7 @@ void Game::processModels()
|
1347
|
1336
|
std::sort(mesh->texturedRectangles.begin(), mesh->texturedRectangles.end(), compareFaceTextureId);
|
1348
|
1337
|
std::sort(mesh->coloredRectangles.begin(), mesh->coloredRectangles.end(), compareFaceTextureId);
|
1349
|
1338
|
|
1350
|
|
- mWorld.addMesh(mesh);
|
|
1339
|
+ getWorld().addMesh(mesh);
|
1351
|
1340
|
//printf(".");
|
1352
|
1341
|
//fflush(stdout);
|
1353
|
1342
|
}
|
|
@@ -1367,7 +1356,7 @@ void Game::processRooms()
|
1367
|
1356
|
if (!mTombRaider.isRoomValid(index))
|
1368
|
1357
|
{
|
1369
|
1358
|
getConsole().print("WARNING: Handling invalid vertex array in room");
|
1370
|
|
- mWorld.addRoom(0x0);
|
|
1359
|
+ getWorld().addRoom(0x0);
|
1371
|
1360
|
mRender->addRoom(0x0);
|
1372
|
1361
|
|
1373
|
1362
|
//printf("x");
|
|
@@ -1908,7 +1897,7 @@ void Game::processRooms()
|
1908
|
1897
|
r_mesh->sprites.push_back(sprite);
|
1909
|
1898
|
}
|
1910
|
1899
|
|
1911
|
|
- mWorld.addRoom(r_mesh);
|
|
1900
|
+ getWorld().addRoom(r_mesh);
|
1912
|
1901
|
|
1913
|
1902
|
rRoom->room = r_mesh;
|
1914
|
1903
|
mRender->addRoom(rRoom);
|