|
@@ -16,6 +16,7 @@
|
16
|
16
|
#include <algorithm>
|
17
|
17
|
#include <map>
|
18
|
18
|
#include <vector>
|
|
19
|
+#include <cstdlib>
|
19
|
20
|
|
20
|
21
|
#include "main.h"
|
21
|
22
|
#include "Console.h"
|
|
@@ -111,7 +112,8 @@ int Game::loadLevel(const char *level) {
|
111
|
112
|
break;
|
112
|
113
|
}
|
113
|
114
|
}
|
114
|
|
- strcpy(tmp + dir, "MAIN.SFX\0"); // overwrite the name itself with MAIN.SFX
|
|
115
|
+ strcpy(tmp + dir, "MAIN.SFX"); // overwrite the name itself with MAIN.SFX
|
|
116
|
+ tmp[dir + 8] = '\0';
|
115
|
117
|
error = mTombRaider.loadSFX(tmp);
|
116
|
118
|
if (error != 0) {
|
117
|
119
|
gOpenRaider->mConsole->print("Could not load %s", tmp);
|
|
@@ -130,6 +132,12 @@ int Game::loadLevel(const char *level) {
|
130
|
132
|
// Free pak file
|
131
|
133
|
mTombRaider.reset();
|
132
|
134
|
|
|
135
|
+ // Check if the level contains Lara
|
|
136
|
+ if (mLara == NULL) {
|
|
137
|
+ gOpenRaider->mConsole->print("Can't find Lara entity in level pak!");
|
|
138
|
+ return -1;
|
|
139
|
+ }
|
|
140
|
+
|
133
|
141
|
mLoaded = true;
|
134
|
142
|
mRender->setMode(Render::modeVertexLight);
|
135
|
143
|
return 0;
|
|
@@ -151,6 +159,7 @@ void Game::handleAction(ActionEvents action, bool isFinished) {
|
151
|
159
|
|
152
|
160
|
void Game::handleMouseMotion(int xrel, int yrel) {
|
153
|
161
|
if (mLoaded) {
|
|
162
|
+ // Move Camera on X Axis
|
154
|
163
|
if (xrel > 0)
|
155
|
164
|
while (xrel-- > 0)
|
156
|
165
|
mCamera->command(CAMERA_ROTATE_RIGHT);
|
|
@@ -158,6 +167,7 @@ void Game::handleMouseMotion(int xrel, int yrel) {
|
158
|
167
|
while (xrel++ < 0)
|
159
|
168
|
mCamera->command(CAMERA_ROTATE_LEFT);
|
160
|
169
|
|
|
170
|
+ // Move Camera on Y Axis
|
161
|
171
|
if (yrel > 0)
|
162
|
172
|
while (yrel-- > 0)
|
163
|
173
|
mCamera->command(CAMERA_ROTATE_UP);
|
|
@@ -165,6 +175,7 @@ void Game::handleMouseMotion(int xrel, int yrel) {
|
165
|
175
|
while (yrel++ < 0)
|
166
|
176
|
mCamera->command(CAMERA_ROTATE_DOWN);
|
167
|
177
|
|
|
178
|
+ // Fix Laras rotation
|
168
|
179
|
if (mLara) {
|
169
|
180
|
mLara->angles[1] = mCamera->getRadianYaw();
|
170
|
181
|
mLara->angles[2] = mCamera->getRadianPitch();
|
|
@@ -176,6 +187,54 @@ void Game::display() {
|
176
|
187
|
mRender->Display();
|
177
|
188
|
}
|
178
|
189
|
|
|
190
|
+int Game::command(std::vector<char *> *args) {
|
|
191
|
+ if (args->size() < 1) {
|
|
192
|
+ gOpenRaider->mConsole->print("Invalid use of game-command!");
|
|
193
|
+ return -1;
|
|
194
|
+ }
|
|
195
|
+
|
|
196
|
+ char *cmd = args->at(0);
|
|
197
|
+ if (strcmp(cmd, "noclip") == 0) {
|
|
198
|
+ mLara->moveType = worldMoveType_noClipping;
|
|
199
|
+ gOpenRaider->mConsole->print("Lara is noclipping...");
|
|
200
|
+ } else if (strcmp(cmd, "fly") == 0) {
|
|
201
|
+ mLara->moveType = worldMoveType_fly;
|
|
202
|
+ gOpenRaider->mConsole->print("Lara is flying...");
|
|
203
|
+ } else if (strcmp(cmd, "walk") == 0) {
|
|
204
|
+ mLara->moveType = worldMoveType_walk;
|
|
205
|
+ gOpenRaider->mConsole->print("Lara is walking...");
|
|
206
|
+ } else if (strcmp(cmd, "sound") == 0) {
|
|
207
|
+ if (args->size() > 1) {
|
|
208
|
+ gOpenRaider->mSound->play(atoi(args->at(1)));
|
|
209
|
+ } else {
|
|
210
|
+ gOpenRaider->mConsole->print("Invalid use of sound command!");
|
|
211
|
+ return -2;
|
|
212
|
+ }
|
|
213
|
+ } else if (strcmp(cmd, "help") == 0) {
|
|
214
|
+ if (args->size() < 2) {
|
|
215
|
+ gOpenRaider->mConsole->print("game-command Usage:");
|
|
216
|
+ gOpenRaider->mConsole->print(" game COMMAND");
|
|
217
|
+ gOpenRaider->mConsole->print("Available commands:");
|
|
218
|
+ gOpenRaider->mConsole->print(" walk");
|
|
219
|
+ gOpenRaider->mConsole->print(" fly");
|
|
220
|
+ gOpenRaider->mConsole->print(" noclip");
|
|
221
|
+ gOpenRaider->mConsole->print(" sound INT");
|
|
222
|
+ } else if (strcmp(args->at(1), "sound") == 0) {
|
|
223
|
+ gOpenRaider->mConsole->print("game-sound-command Usage:");
|
|
224
|
+ gOpenRaider->mConsole->print(" game sound INT");
|
|
225
|
+ gOpenRaider->mConsole->print("Where INT is a valid sound ID integer");
|
|
226
|
+ } else {
|
|
227
|
+ gOpenRaider->mConsole->print("No help available for game %s.", args->at(1));
|
|
228
|
+ return -3;
|
|
229
|
+ }
|
|
230
|
+ } else {
|
|
231
|
+ gOpenRaider->mConsole->print("Invalid use of game-command (%s)!", cmd);
|
|
232
|
+ return -4;
|
|
233
|
+ }
|
|
234
|
+
|
|
235
|
+ return 0;
|
|
236
|
+}
|
|
237
|
+
|
179
|
238
|
void Game::processPakSounds()
|
180
|
239
|
{
|
181
|
240
|
unsigned char *riff;
|
|
@@ -700,7 +759,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
700
|
759
|
r_model->ponyOff2 = 0;
|
701
|
760
|
|
702
|
761
|
mRender->setFlags(Render::fRenderPonytail);
|
703
|
|
- gOpenRaider->mConsole->print("Found ponytail?\n");
|
|
762
|
+ gOpenRaider->mConsole->print("Found ponytail?");
|
704
|
763
|
}
|
705
|
764
|
break;
|
706
|
765
|
}
|
|
@@ -822,7 +881,7 @@ void Game::processMoveable(int index, int i, int *ent,
|
822
|
881
|
// if (frame_offset + 8 > _tombraider.NumFrames())
|
823
|
882
|
if (frame_offset > mTombRaider.NumFrames())
|
824
|
883
|
{
|
825
|
|
- gOpenRaider->mConsole->print("WARNING: Bad animation frame %i > %i\n",
|
|
884
|
+ gOpenRaider->mConsole->print("WARNING: Bad animation frame %i > %i",
|
826
|
885
|
frame_offset, mTombRaider.NumFrames());
|
827
|
886
|
|
828
|
887
|
// Mongoose 2002.08.15, Attempt to skip more likely bad animation data
|