Browse Source

Guarded interactive commands

Thomas Buck 11 years ago
parent
commit
46acd107ba
2 changed files with 32 additions and 17 deletions
  1. 0
    17
      include/WorldData.h
  2. 32
    0
      src/OpenRaider.cpp

+ 0
- 17
include/WorldData.h View File

@@ -193,22 +193,5 @@ typedef struct {
193 193
 
194 194
 } actor_entity_t;
195 195
 
196
-enum OpenRaiderEvent {
197
-    eNone = 0,
198
-    eWeaponDischarge,
199
-    eDying,
200
-    eDead,
201
-    eWounded,
202
-    eRunForward,
203
-    eRunBackward,
204
-    eJump,
205
-    eCrouchWalk,
206
-    eIdle,
207
-    eTaunt,
208
-    eTurn,
209
-    eRespawn,
210
-    eLand
211
-};
212
-
213 196
 #endif
214 197
 

+ 32
- 0
src/OpenRaider.cpp View File

@@ -141,11 +141,19 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
141 141
     } else if (strcmp(command, "quit") == 0) {
142 142
         exit(0);
143 143
     } else if (strcmp(command, "load") == 0) {
144
+        if (!mRunning) {
145
+            getConsole().print("Use load command interactively!");
146
+            return -999;
147
+        }
144 148
         char *tmp = bufferString("%s/%s", mPakDir, args->at(0));
145 149
         int error = getGame().loadLevel(tmp);
146 150
         delete [] tmp;
147 151
         return error;
148 152
     } else if (strcmp(command, "sshot") == 0) {
153
+        if (!mRunning) {
154
+            getConsole().print("Use sshot command interactively!");
155
+            return -999;
156
+        }
149 157
         char *filename = bufferString("%s/sshots/%s", mBaseDir, VERSION);
150 158
         bool console = (args->size() > 0) && (strcmp(args->at(0), "console") == 0);
151 159
         bool menu = (args->size() > 0) && (strcmp(args->at(0), "menu") == 0);
@@ -211,6 +219,10 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
211 219
             return -8;
212 220
         }
213 221
     } else if (strcmp(command, "move") == 0) {
222
+        if (!mRunning) {
223
+            getConsole().print("Use move command interactively!");
224
+            return -999;
225
+        }
214 226
         if (args->size() > 0) {
215 227
             if (getGame().mLoaded) {
216 228
                 char *move = args->at(0);
@@ -236,6 +248,10 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
236 248
             return -11;
237 249
         }
238 250
     } else if (strcmp(command, "sound") == 0) {
251
+        if ((!mRunning) || (!getGame().mLoaded)) {
252
+            getConsole().print("Use sound command interactively!");
253
+            return -999;
254
+        }
239 255
         if (args->size() > 0) {
240 256
             getSound().play(atoi(args->at(0)));
241 257
         } else {
@@ -243,6 +259,10 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
243 259
             return -12;
244 260
         }
245 261
     } else if (strcmp(command, "animate") == 0) {
262
+        if ((!mRunning) || (!getGame().mLoaded)) {
263
+            getConsole().print("Use animate command interactively!");
264
+            return -999;
265
+        }
246 266
         if (args->size() > 0) {
247 267
             char c = args->at(0)[0];
248 268
             if (c == 'n') {
@@ -340,6 +360,10 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
340 360
             return -20;
341 361
         }
342 362
     } else if (strcmp(command, "viewmodel") == 0) {
363
+        if ((!mRunning) || (!getGame().mLoaded)) {
364
+            getConsole().print("Use viewmodel command interactively!");
365
+            return -999;
366
+        }
343 367
         if (getGame().mLara) {
344 368
             SkeletalModel *smdl = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
345 369
             skeletal_model_t *mdl = getWorld().getModel(atoi(args->at(0)));
@@ -550,6 +574,10 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
550 574
             return -45;
551 575
         }
552 576
     } else if (strcmp(command, "pigtail") == 0) {
577
+        if ((!mRunning) || (!getGame().mLoaded)) {
578
+            getConsole().print("Use pigtail command interactively!");
579
+            return -999;
580
+        }
553 581
         if (args->size() > 0) {
554 582
             bool b;
555 583
             if (readBool(args->at(0), &b) < 0) {
@@ -571,6 +599,10 @@ int OpenRaider::command(const char *command, std::vector<char *> *args) {
571 599
             return -47;
572 600
         }
573 601
     } else if (strcmp(command, "ponypos") == 0) {
602
+        if ((!mRunning) || (!getGame().mLoaded)) {
603
+            getConsole().print("Use ponypos command interactively!");
604
+            return -999;
605
+        }
574 606
         if (args->size() > 3) {
575 607
             SkeletalModel *tmp = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
576 608
             tmp->model->ponytail[0] = (float)atof(args->at(0));

Loading…
Cancel
Save