Pārlūkot izejas kodu

Moved Command code into own file

Thomas Buck 10 gadus atpakaļ
vecāks
revīzija
0e4a874e40
8 mainītis faili ar 625 papildinājumiem un 652 dzēšanām
  1. 0
    18
      include/World.h
  2. 1
    0
      src/CMakeLists.txt
  3. 615
    0
      src/Command.cpp
  4. 1
    3
      src/Game.cpp
  5. 0
    608
      src/OpenRaider.cpp
  6. 2
    4
      src/Render.cpp
  7. 4
    1
      src/WindowSDL.cpp
  8. 2
    18
      src/World.cpp

+ 0
- 18
include/World.h Parādīt failu

@@ -26,10 +26,6 @@
26 26
 class World {
27 27
 public:
28 28
 
29
-    enum WorldFlag {
30
-        fEnableHopping = (1 << 0)
31
-    };
32
-
33 29
     /*!
34 30
      * \brief Constructs an object of World
35 31
      */
@@ -120,18 +116,6 @@ public:
120 116
 #endif
121 117
 
122 118
     /*!
123
-     * \brief Set an option flag
124
-     * \param flag flag to set
125
-     */
126
-    void setFlag(WorldFlag flag);
127
-
128
-    /*!
129
-     * \brief Clear an option flag
130
-     * \param flag flag to clear
131
-     */
132
-    void clearFlag(WorldFlag flag);
133
-
134
-    /*!
135 119
      * \brief Clears all data in world
136 120
      * \todo in future will check if data is in use before clearing
137 121
      */
@@ -177,8 +161,6 @@ public:
177 161
 
178 162
 private:
179 163
 
180
-    unsigned int mFlags;                     //!< World flags
181
-
182 164
     std::vector<entity_t *> mEntities;       //!< World entities
183 165
     std::vector<room_mesh_t *> mRooms;       //!< Map data and meshes
184 166
     std::vector<model_mesh_t *> mMeshes;     //!< Unanimated meshes

+ 1
- 0
src/CMakeLists.txt Parādīt failu

@@ -32,6 +32,7 @@ set (LIBS ${LIBS} ${ZLIB_LIBRARIES})
32 32
 
33 33
 # Set Source files
34 34
 set (SRCS ${SRCS} "Camera.cpp")
35
+set (SRCS ${SRCS} "Command.cpp")
35 36
 set (SRCS ${SRCS} "Console.cpp")
36 37
 set (SRCS ${SRCS} "Game.cpp")
37 38
 set (SRCS ${SRCS} "main.cpp")

+ 615
- 0
src/Command.cpp Parādīt failu

@@ -0,0 +1,615 @@
1
+/*!
2
+ * \file src/Command.cpp
3
+ * \brief OpenRaider command implementation
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include <cstdio>
9
+#include <cstring>
10
+#include <assert.h>
11
+
12
+#include "WindowSDL.h"
13
+
14
+#include "config.h"
15
+#include "Console.h"
16
+#include "Game.h"
17
+#include "main.h"
18
+#include "math/math.h"
19
+#include "Menu.h"
20
+#include "Sound.h"
21
+#include "TombRaider.h"
22
+#include "utils/strings.h"
23
+#include "utils/time.h"
24
+#include "OpenRaider.h"
25
+
26
+int OpenRaider::command(const char *command, std::vector<char *> *args) {
27
+    assert(command != NULL);
28
+    assert(command[0] != '\0');
29
+    assert(args != NULL);
30
+
31
+    if (strcmp(command, "set") == 0) {
32
+        if (args->size() != 2) {
33
+            getConsole().print("Invalid use of set-command");
34
+            return -1;
35
+        } else {
36
+            return set(args->at(0), args->at(1));
37
+        }
38
+    } else if (strcmp(command, "bind") == 0) {
39
+        if (args->size() != 2) {
40
+            getConsole().print("Invalid use of bind-command");
41
+            return -2;
42
+        } else {
43
+            return bind(args->at(0), args->at(1));
44
+        }
45
+    } else if (strcmp(command, "quit") == 0) {
46
+        exit(0);
47
+    } else if (strcmp(command, "load") == 0) {
48
+        if (!mRunning) {
49
+            getConsole().print("Use load command interactively!");
50
+            return -999;
51
+        }
52
+        char *tmp = bufferString("%s/%s", mPakDir, args->at(0));
53
+        int error = getGame().loadLevel(tmp);
54
+        delete [] tmp;
55
+        return error;
56
+    } else if (strcmp(command, "sshot") == 0) {
57
+        if (!mRunning) {
58
+            getConsole().print("Use sshot command interactively!");
59
+            return -999;
60
+        }
61
+        char *filename = bufferString("%s/sshots/%s", mBaseDir, VERSION);
62
+        bool console = (args->size() > 0) && (strcmp(args->at(0), "console") == 0);
63
+        bool menu = (args->size() > 0) && (strcmp(args->at(0), "menu") == 0);
64
+        if (!console) {
65
+            getConsole().setVisible(false);
66
+            if (menu)
67
+                getMenu().setVisible(true);
68
+            frame();
69
+            frame(); // Double buffered
70
+        }
71
+        getRender().screenShot(filename);
72
+        if (!console) {
73
+            getConsole().setVisible(true);
74
+            if (menu)
75
+                getMenu().setVisible(false);
76
+        }
77
+        getConsole().print("Screenshot stored...");
78
+        delete filename;
79
+    } else if (strcmp(command, "mode") == 0) {
80
+        if (args->size() > 0) {
81
+            char *mode = args->at(0);
82
+            if (strcmp(mode, "wireframe") == 0) {
83
+                if (getGame().isLoaded()) {
84
+                    getRender().setMode(Render::modeWireframe);
85
+                    getConsole().print("Wireframe mode");
86
+                } else {
87
+                    getConsole().print("Load a level to set this mode!");
88
+                    return -3;
89
+                }
90
+            } else if (strcmp(mode, "solid") == 0) {
91
+                if (getGame().isLoaded()) {
92
+                    getRender().setMode(Render::modeSolid);
93
+                    getConsole().print("Solid mode");
94
+                } else {
95
+                    getConsole().print("Load a level to set this mode!");
96
+                    return -4;
97
+                }
98
+            } else if (strcmp(mode, "texture") == 0) {
99
+                if (getGame().isLoaded()) {
100
+                    getRender().setMode(Render::modeTexture);
101
+                    getConsole().print("Texture mode");
102
+                } else {
103
+                    getConsole().print("Load a level to set this mode!");
104
+                    return -5;
105
+                }
106
+            } else if (strcmp(mode, "vertexlight") == 0) {
107
+                if (getGame().isLoaded()) {
108
+                    getRender().setMode(Render::modeVertexLight);
109
+                    getConsole().print("Vertexlight mode");
110
+                } else {
111
+                    getConsole().print("Load a level to set this mode!");
112
+                    return -6;
113
+                }
114
+            } else if (strcmp(mode, "titlescreen") == 0) {
115
+                getRender().setMode(Render::modeLoadScreen);
116
+                getConsole().print("Titlescreen mode");
117
+            } else {
118
+                getConsole().print("Invalid use of mode command (%s)!", mode);
119
+                return -7;
120
+            }
121
+        } else {
122
+            getConsole().print("Invalid use of mode command!");
123
+            return -8;
124
+        }
125
+    } else if (strcmp(command, "move") == 0) {
126
+        if (!mRunning) {
127
+            getConsole().print("Use move command interactively!");
128
+            return -999;
129
+        }
130
+        if (args->size() > 0) {
131
+            if (getGame().isLoaded()) {
132
+                char *move = args->at(0);
133
+                if (strcmp(move, "walk") == 0) {
134
+                    getGame().mLara->moveType = worldMoveType_walk;
135
+                    getConsole().print("Lara is walking...");
136
+                } else if (strcmp(move, "fly") == 0) {
137
+                    getGame().mLara->moveType = worldMoveType_fly;
138
+                    getConsole().print("Lara is flying...");
139
+                } else if (strcmp(move, "noclip") == 0) {
140
+                    getGame().mLara->moveType = worldMoveType_noClipping;
141
+                    getConsole().print("Lara is noclipping...");
142
+                } else {
143
+                    getConsole().print("Invalid use of move command (%s)!", move);
144
+                    return -9;
145
+                }
146
+            } else {
147
+                getConsole().print("Load a level to change the movement type!");
148
+                return -10;
149
+            }
150
+        } else {
151
+            getConsole().print("Invalid use of move command!");
152
+            return -11;
153
+        }
154
+    } else if (strcmp(command, "sound") == 0) {
155
+        if ((!mRunning) || (!getGame().isLoaded())) {
156
+            getConsole().print("Use sound command interactively!");
157
+            return -999;
158
+        }
159
+        if (args->size() > 0) {
160
+            getSound().play(atoi(args->at(0)));
161
+        } else {
162
+            getConsole().print("Invalid use of sound command!");
163
+            return -12;
164
+        }
165
+    } else if (strcmp(command, "animate") == 0) {
166
+        if ((!mRunning) || (!getGame().isLoaded())) {
167
+            getConsole().print("Use animate command interactively!");
168
+            return -999;
169
+        }
170
+        if (args->size() > 0) {
171
+            char c = args->at(0)[0];
172
+            if (c == 'n') {
173
+                // Step all skeletal models to their next animation
174
+                if (getRender().getFlags() & Render::fAnimateAllModels) {
175
+                    for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
176
+                        SkeletalModel *m = getRender().mModels[i];
177
+                        if (m->getAnimation() < ((int)m->model->animation.size() - 1))
178
+                            m->setAnimation(m->getAnimation() + 1);
179
+                        else
180
+                            if (m->getAnimation() != 0)
181
+                                m->setAnimation(0);
182
+                    }
183
+                } else {
184
+                    getConsole().print("Animations need to be enabled!");
185
+                }
186
+            } else if (c == 'p') {
187
+                // Step all skeletal models to their previous animation
188
+                if (getRender().getFlags() & Render::fAnimateAllModels) {
189
+                    for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
190
+                        SkeletalModel *m = getRender().mModels[i];
191
+                        if (m->getAnimation() > 0)
192
+                            m->setAnimation(m->getAnimation() - 1);
193
+                        else
194
+                            if (m->model->animation.size() > 0)
195
+                                m->setAnimation(m->model->animation.size() - 1);
196
+                    }
197
+                } else {
198
+                    getConsole().print("Animations need to be enabled!");
199
+                }
200
+            } else {
201
+                // Enable or disable animating all skeletal models
202
+                bool b;
203
+                if (readBool(args->at(0), &b) < 0) {
204
+                    getConsole().print("Pass BOOL to animate command!");
205
+                    return -13;
206
+                }
207
+                if (b)
208
+                    getRender().setFlags(Render::fAnimateAllModels);
209
+                else
210
+                    getRender().clearFlags(Render::fAnimateAllModels);
211
+                getConsole().print(b ? "Animating all models" : "No longer animating all models");
212
+            }
213
+        } else {
214
+            getConsole().print("Invalid use of animate command!");
215
+            return -14;
216
+        }
217
+    } else if (strcmp(command, "light") == 0) {
218
+        if (args->size() > 0) {
219
+            bool b;
220
+            if (readBool(args->at(0), &b) < 0) {
221
+                getConsole().print("Pass BOOL to light command!");
222
+                return -15;
223
+            }
224
+            if (b)
225
+                getRender().setFlags(Render::fGL_Lights);
226
+            else
227
+                getRender().clearFlags(Render::fGL_Lights);
228
+            getConsole().print("GL-Lights are now %s", b ? "on" : "off");
229
+        } else {
230
+            getConsole().print("Invalid use of light-command!");
231
+            return -16;
232
+        }
233
+    } else if (strcmp(command, "fog") == 0) {
234
+        if (args->size() > 0) {
235
+            bool b;
236
+            if (readBool(args->at(0), &b) < 0) {
237
+                getConsole().print("Pass BOOL to fog command!");
238
+                return -17;
239
+            }
240
+            if (b)
241
+                getRender().setFlags(Render::fFog);
242
+            else
243
+                getRender().clearFlags(Render::fFog);
244
+            getConsole().print("Fog is now %s", b ? "on" : "off");
245
+        } else {
246
+            getConsole().print("Invalid use of fog-command!");
247
+            return -18;
248
+        }
249
+    } else if (strcmp(command, "viewmodel") == 0) {
250
+        if ((!mRunning) || (!getGame().isLoaded())) {
251
+            getConsole().print("Use viewmodel command interactively!");
252
+            return -999;
253
+        }
254
+        if (getGame().mLara) {
255
+            SkeletalModel *smdl = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
256
+            skeletal_model_t *mdl = getWorld().getModel(atoi(args->at(0)));
257
+            if (smdl)
258
+                smdl->setModel(mdl);
259
+        }
260
+        //m_render.ViewModel(LARA, atoi(cmd));
261
+    } else if (strcmp(command, "pos") == 0) {
262
+        if (getGame().mLara) {
263
+            getConsole().print("Position:");
264
+            getConsole().print("  Room %i (0x%X)", getGame().mLara->room, getWorld().getRoomInfo(getGame().mLara->room));
265
+            getConsole().print("  %.1fx %.1fy %.1fz", getGame().mLara->pos[0], getGame().mLara->pos[1], getGame().mLara->pos[2]);
266
+            getConsole().print("  %.1f Yaw %.1f Pitch", OR_RAD_TO_DEG(getGame().mLara->angles[1]), OR_RAD_TO_DEG(getGame().mLara->angles[2]));
267
+        } else {
268
+            getConsole().print("Load a level to get Laras position!");
269
+            return -21;
270
+        }
271
+    } else if (strcmp(command, "vmodel") == 0) {
272
+        if (args->size() > 0) {
273
+            bool b;
274
+            if (readBool(args->at(0), &b) < 0) {
275
+                getConsole().print("Pass BOOL to vmodel command!");
276
+                return -22;
277
+            }
278
+            if (b)
279
+                getRender().setFlags(Render::fViewModel);
280
+            else
281
+                getRender().clearFlags(Render::fViewModel);
282
+            getConsole().print("Viewmodel is now %s", b ? "on" : "off");
283
+        } else {
284
+            getConsole().print("Invalid use of vmodel-command!");
285
+            return -23;
286
+        }
287
+    } else if (strcmp(command, "ralpha") == 0) {
288
+        if (args->size() > 0) {
289
+            bool b;
290
+            if (readBool(args->at(0), &b) < 0) {
291
+                getConsole().print("Pass BOOL to ralpha command!");
292
+                return -24;
293
+            }
294
+            if (b)
295
+                getRender().setFlags(Render::fRoomAlpha);
296
+            else
297
+                getRender().clearFlags(Render::fRoomAlpha);
298
+            getConsole().print("Room Alpha is now %s", b ? "on" : "off");
299
+        } else {
300
+            getConsole().print("Invalid use of ralpha-command!");
301
+            return -25;
302
+        }
303
+    } else if (strcmp(command, "portal") == 0) {
304
+        if (args->size() > 0) {
305
+            bool b;
306
+            if (readBool(args->at(0), &b) < 0) {
307
+                getConsole().print("Pass BOOL to portal command!");
308
+                return -26;
309
+            }
310
+            if (b)
311
+                getRender().setFlags(Render::fPortals);
312
+            else
313
+                getRender().clearFlags(Render::fPortals);
314
+            getConsole().print("Portals are now %s", b ? "on" : "off");
315
+        } else {
316
+            getConsole().print("Invalid use of portal-command!");
317
+            return -27;
318
+        }
319
+    } else if (strcmp(command, "vis") == 0) {
320
+        if (args->size() > 0) {
321
+            bool b;
322
+            if (readBool(args->at(0), &b) < 0) {
323
+                getConsole().print("Pass BOOL to vis command!");
324
+                return -28;
325
+            }
326
+            if (b)
327
+                getRender().setFlags(Render::fUsePortals);
328
+            else
329
+                getRender().clearFlags(Render::fUsePortals);
330
+            getConsole().print("Portals are now %s", b ? "on" : "off");
331
+        } else {
332
+            getConsole().print("Invalid use of vis-command!");
333
+            return -29;
334
+        }
335
+    } else if (strcmp(command, "upf") == 0) {
336
+        if (args->size() > 0) {
337
+            bool b;
338
+            if (readBool(args->at(0), &b) < 0) {
339
+                getConsole().print("Pass BOOL to upf command!");
340
+                return -30;
341
+            }
342
+            if (b)
343
+                getRender().setFlags(Render::fUpdateRoomListPerFrame);
344
+            else
345
+                getRender().clearFlags(Render::fUpdateRoomListPerFrame);
346
+            getConsole().print("URLPF is now %s", b ? "on" : "off");
347
+        } else {
348
+            getConsole().print("Invalid use of upf-command!");
349
+            return -31;
350
+        }
351
+    } else if (strcmp(command, "sprite") == 0) {
352
+        if (args->size() > 0) {
353
+            bool b;
354
+            if (readBool(args->at(0), &b) < 0) {
355
+                getConsole().print("Pass BOOL to sprite command!");
356
+                return -34;
357
+            }
358
+            if (b)
359
+                getRender().setFlags(Render::fSprites);
360
+            else
361
+                getRender().clearFlags(Render::fSprites);
362
+            getConsole().print("Sprites are now %s", b ? "on" : "off");
363
+        } else {
364
+            getConsole().print("Invalid use of sprite-command!");
365
+            return -35;
366
+        }
367
+    } else if (strcmp(command, "roommodel") == 0) {
368
+        if (args->size() > 0) {
369
+            bool b;
370
+            if (readBool(args->at(0), &b) < 0) {
371
+                getConsole().print("Pass BOOL to roommodel command!");
372
+                return -36;
373
+            }
374
+            if (b)
375
+                getRender().setFlags(Render::fRoomModels);
376
+            else
377
+                getRender().clearFlags(Render::fRoomModels);
378
+            getConsole().print("Roommodels are now %s", b ? "on" : "off");
379
+        } else {
380
+            getConsole().print("Invalid use of roommodel-command!");
381
+            return -37;
382
+        }
383
+    } else if (strcmp(command, "entmodel") == 0) {
384
+        if (args->size() > 0) {
385
+            bool b;
386
+            if (readBool(args->at(0), &b) < 0) {
387
+                getConsole().print("Pass BOOL to entmodel command!");
388
+                return -38;
389
+            }
390
+            if (b)
391
+                getRender().setFlags(Render::fEntityModels);
392
+            else
393
+                getRender().clearFlags(Render::fEntityModels);
394
+            getConsole().print("Entmodels are now %s", b ? "on" : "off");
395
+        } else {
396
+            getConsole().print("Invalid use of entmodel-command!");
397
+            return -39;
398
+        }
399
+    } else if (strcmp(command, "oneroom") == 0) {
400
+        if (args->size() > 0) {
401
+            bool b;
402
+            if (readBool(args->at(0), &b) < 0) {
403
+                getConsole().print("Pass BOOL to oneroom command!");
404
+                return -40;
405
+            }
406
+            if (b)
407
+                getRender().setFlags(Render::fOneRoom);
408
+            else
409
+                getRender().clearFlags(Render::fOneRoom);
410
+            getConsole().print("Rendering one room is now %s", b ? "on" : "off");
411
+        } else {
412
+            getConsole().print("Invalid use of oneroom-command!");
413
+            return -41;
414
+        }
415
+    } else if (strcmp(command, "allrooms") == 0) {
416
+        if (args->size() > 0) {
417
+            bool b;
418
+            if (readBool(args->at(0), &b) < 0) {
419
+                getConsole().print("Pass BOOL to allrooms command!");
420
+                return -42;
421
+            }
422
+            if (b)
423
+                getRender().setFlags(Render::fAllRooms);
424
+            else
425
+                getRender().clearFlags(Render::fAllRooms);
426
+            getConsole().print("Rendering all rooms is now %s", b ? "on" : "off");
427
+        } else {
428
+            getConsole().print("Invalid use of allrooms-command!");
429
+            return -43;
430
+        }
431
+    } else if (strcmp(command, "ponytail") == 0) {
432
+        if (args->size() > 0) {
433
+            bool b;
434
+            if (readBool(args->at(0), &b) < 0) {
435
+                getConsole().print("Pass BOOL to ponytail command!");
436
+                return -44;
437
+            }
438
+            if (b)
439
+                getRender().setFlags(Render::fRenderPonytail);
440
+            else
441
+                getRender().clearFlags(Render::fRenderPonytail);
442
+            getConsole().print("Ponytail is now %s", b ? "on" : "off");
443
+        } else {
444
+            getConsole().print("Invalid use of ponytail-command!");
445
+            return -45;
446
+        }
447
+    } else if (strcmp(command, "pigtail") == 0) {
448
+        if ((!mRunning) || (!getGame().isLoaded())) {
449
+            getConsole().print("Use pigtail command interactively!");
450
+            return -999;
451
+        }
452
+        if (args->size() > 0) {
453
+            bool b;
454
+            if (readBool(args->at(0), &b) < 0) {
455
+                getConsole().print("Pass BOOL to pigtail command!");
456
+                return -46;
457
+            }
458
+            SkeletalModel *tmp = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
459
+            tmp->model->pigtails = b;
460
+            if (b) {
461
+                tmp->model->ponyOff -= 20;
462
+                tmp->model->ponytail[1] -= 32;
463
+            } else {
464
+                tmp->model->ponyOff += 20;
465
+                tmp->model->ponytail[1] += 32;
466
+            }
467
+            getConsole().print("Pigtail is now %s", b ? "on" : "off");
468
+        } else {
469
+            getConsole().print("Invalid use of pigtail-command!");
470
+            return -47;
471
+        }
472
+    } else if (strcmp(command, "ponypos") == 0) {
473
+        if ((!mRunning) || (!getGame().isLoaded())) {
474
+            getConsole().print("Use ponypos command interactively!");
475
+            return -999;
476
+        }
477
+        if (args->size() > 3) {
478
+            SkeletalModel *tmp = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
479
+            tmp->model->ponytail[0] = (float)atof(args->at(0));
480
+            tmp->model->ponytail[1] = (float)atof(args->at(1));
481
+            tmp->model->ponytail[2] = (float)atof(args->at(2));
482
+            tmp->model->ponytailAngle = (float)atof(args->at(3));
483
+        } else {
484
+            getConsole().print("Invalid use of ponypos-command!");
485
+            return -48;
486
+        }
487
+    } else if (strcmp(command, "help") == 0) {
488
+        if (args->size() == 0) {
489
+            getConsole().print("Available commands:");
490
+            getConsole().print("  load      - load a level");
491
+            getConsole().print("  set       - set a parameter");
492
+            getConsole().print("  bind      - bind a keyboard/mouse action");
493
+            getConsole().print("  sshot     - make a screenshot");
494
+            getConsole().print("  move      - [walk|fly|noclip]");
495
+            getConsole().print("  sound     - INT - Test play sound");
496
+            getConsole().print("  mode      - MODE - Render mode");
497
+            getConsole().print("  animate   - [BOOL|n|p] - Animate models");
498
+            getConsole().print("  light     - BOOL - GL Lights");
499
+            getConsole().print("  fog       - BOOL - GL Fog");
500
+            getConsole().print("  viewmodel - INT - Change Laras model");
501
+            getConsole().print("  pos       - Print position info");
502
+            getConsole().print("  vmodel    - BOOL - View Model");
503
+            getConsole().print("  ralpha    - BOOL - Room Alpha");
504
+            getConsole().print("  portal    - BOOL");
505
+            getConsole().print("  vis       - BOOL - Use Portals");
506
+            getConsole().print("  upf       - BOOL - Update Room List Per Frame");
507
+            getConsole().print("  sprite    - BOOL");
508
+            getConsole().print("  roommodel - BOOL");
509
+            getConsole().print("  entmodel  - BOOL");
510
+            getConsole().print("  oneroom   - BOOL");
511
+            getConsole().print("  allrooms  - BOOL");
512
+            getConsole().print("  ponytail  - BOOL");
513
+            getConsole().print("  pigtail   - BOOL");
514
+            getConsole().print("  ponypos   - FLOAT FLOAT FLOAT FLOAT - x y z angle");
515
+            getConsole().print("  help      - print command help");
516
+            getConsole().print("  quit      - exit OpenRaider");
517
+            getConsole().print("Use help COMMAND to get additional info");
518
+        } else if (args->size() == 1) {
519
+            return help(args->at(0));
520
+        } else {
521
+            getConsole().print("Invalid use of help-command");
522
+            return -49;
523
+        }
524
+    } else {
525
+        getConsole().print("Unknown command: %s ", command);
526
+        return -50;
527
+    }
528
+
529
+    return 0;
530
+}
531
+
532
+int OpenRaider::help(const char *cmd) {
533
+    assert(cmd != NULL);
534
+    assert(cmd[0] != '\0');
535
+
536
+    if (strcmp(cmd, "set") == 0) {
537
+        getConsole().print("set-Command Usage:");
538
+        getConsole().print("  set VAR VAL");
539
+        getConsole().print("Available Variables:");
540
+        getConsole().print("  basedir    STRING");
541
+        getConsole().print("  pakdir     STRING");
542
+        getConsole().print("  audiodir   STRING");
543
+        getConsole().print("  datadir    STRING");
544
+        getConsole().print("  font       STRING");
545
+        getConsole().print("  gldriver   STRING");
546
+        getConsole().print("  size       \"INTxINT\"");
547
+        getConsole().print("  fullscreen BOOL");
548
+        getConsole().print("  audio      BOOL");
549
+        getConsole().print("  volume     BOOL");
550
+        getConsole().print("  mouse_x    FLOAT");
551
+        getConsole().print("  mouse_y    FLOAT");
552
+        getConsole().print("  fps        BOOL");
553
+        getConsole().print("Enclose STRINGs with \"\"!");
554
+        getConsole().print("size expects a STRING in the specified format");
555
+    } else if (strcmp(cmd, "bind") == 0) {
556
+        getConsole().print("bind-Command Usage:");
557
+        getConsole().print("  bind ACTION KEY");
558
+        getConsole().print("Available Actions:");
559
+        getConsole().print("  menu");
560
+        getConsole().print("  console");
561
+        getConsole().print("  forward");
562
+        getConsole().print("  backward");
563
+        getConsole().print("  left");
564
+        getConsole().print("  right");
565
+        getConsole().print("  jump");
566
+        getConsole().print("  crouch");
567
+        getConsole().print("  use");
568
+        getConsole().print("  holster");
569
+        getConsole().print("Key-Format:");
570
+        getConsole().print("  'a' or '1'    for character/number keys");
571
+        getConsole().print("  \"leftctrl\"  for symbols and special keys");
572
+    } else if (strcmp(cmd, "load") == 0) {
573
+        getConsole().print("load-Command Usage:");
574
+        getConsole().print("  load levelfile.name");
575
+    } else if (strcmp(cmd, "game") == 0) {
576
+        getConsole().print("Use \"game help\" for more info");
577
+    } else if (strcmp(cmd, "sshot") == 0) {
578
+        getConsole().print("sshot-Command Usage:");
579
+        getConsole().print("  sshot [console|menu]");
580
+        getConsole().print("Add console/menu to capture them too");
581
+    } else if (strcmp(cmd, "sound") == 0) {
582
+        getConsole().print("sound-Command Usage:");
583
+        getConsole().print("  sound INT");
584
+        getConsole().print("Where INT is a valid sound ID integer");
585
+    } else if (strcmp(cmd, "move") == 0) {
586
+        getConsole().print("move-Command Usage:");
587
+        getConsole().print("  move COMMAND");
588
+        getConsole().print("Where COMMAND is one of the following:");
589
+        getConsole().print("  walk");
590
+        getConsole().print("  fly");
591
+        getConsole().print("  noclip");
592
+    } else if (strcmp(cmd, "mode") == 0) {
593
+        getConsole().print("mode-Command Usage:");
594
+        getConsole().print("  mode MODE");
595
+        getConsole().print("Where MODE is one of the following:");
596
+        getConsole().print("  wireframe");
597
+        getConsole().print("  solid");
598
+        getConsole().print("  texture");
599
+        getConsole().print("  vertexlight");
600
+        getConsole().print("  titlescreen");
601
+    } else if (strcmp(cmd, "animate") == 0) {
602
+        getConsole().print("animate-Command Usage:");
603
+        getConsole().print("  animate [n|p|BOOL]");
604
+        getConsole().print("Where the commands have the following meaning:");
605
+        getConsole().print("  BOOL to (de)activate animating all models");
606
+        getConsole().print("  n to step all models to their next animation");
607
+        getConsole().print("  p to step all models to their previous animation");
608
+    } else {
609
+        getConsole().print("No help available for %s", cmd);
610
+        return -1;
611
+    }
612
+
613
+    return 0;
614
+}
615
+

+ 1
- 3
src/Game.cpp Parādīt failu

@@ -55,9 +55,6 @@ int Game::initialize() {
55 55
     mTextureStart = getRender().initTextures(getOpenRaider().mDataDir);
56 56
     getRender().setMode(Render::modeLoadScreen);
57 57
 
58
-    // Enable World Hopping
59
-    getWorld().setFlag(World::fEnableHopping);
60
-
61 58
     return 0;
62 59
 }
63 60
 
@@ -66,6 +63,7 @@ void Game::destroy() {
66 63
         delete [] mName;
67 64
 
68 65
     mLoaded = false;
66
+    mLara = NULL;
69 67
     getRender().setMode(Render::modeDisabled);
70 68
 
71 69
     getWorld().destroy();

+ 0
- 608
src/OpenRaider.cpp Parādīt failu

@@ -154,614 +154,6 @@ int OpenRaider::command(const char *command) {
154 154
     return returnValue;
155 155
 }
156 156
 
157
-int OpenRaider::command(const char *command, std::vector<char *> *args) {
158
-    assert(command != NULL);
159
-    assert(command[0] != '\0');
160
-    assert(args != NULL);
161
-
162
-    if (strcmp(command, "set") == 0) {
163
-        if (args->size() != 2) {
164
-            getConsole().print("Invalid use of set-command");
165
-            return -1;
166
-        } else {
167
-            return set(args->at(0), args->at(1));
168
-        }
169
-    } else if (strcmp(command, "bind") == 0) {
170
-        if (args->size() != 2) {
171
-            getConsole().print("Invalid use of bind-command");
172
-            return -2;
173
-        } else {
174
-            return bind(args->at(0), args->at(1));
175
-        }
176
-    } else if (strcmp(command, "quit") == 0) {
177
-        exit(0);
178
-    } else if (strcmp(command, "load") == 0) {
179
-        if (!mRunning) {
180
-            getConsole().print("Use load command interactively!");
181
-            return -999;
182
-        }
183
-        char *tmp = bufferString("%s/%s", mPakDir, args->at(0));
184
-        int error = getGame().loadLevel(tmp);
185
-        delete [] tmp;
186
-        return error;
187
-    } else if (strcmp(command, "sshot") == 0) {
188
-        if (!mRunning) {
189
-            getConsole().print("Use sshot command interactively!");
190
-            return -999;
191
-        }
192
-        char *filename = bufferString("%s/sshots/%s", mBaseDir, VERSION);
193
-        bool console = (args->size() > 0) && (strcmp(args->at(0), "console") == 0);
194
-        bool menu = (args->size() > 0) && (strcmp(args->at(0), "menu") == 0);
195
-        if (!console) {
196
-            getConsole().setVisible(false);
197
-            if (menu)
198
-                getMenu().setVisible(true);
199
-            frame();
200
-            frame(); // Double buffered
201
-        }
202
-        getRender().screenShot(filename);
203
-        if (!console) {
204
-            getConsole().setVisible(true);
205
-            if (menu)
206
-                getMenu().setVisible(false);
207
-        }
208
-        getConsole().print("Screenshot stored...");
209
-        delete filename;
210
-    } else if (strcmp(command, "mode") == 0) {
211
-        if (args->size() > 0) {
212
-            char *mode = args->at(0);
213
-            if (strcmp(mode, "wireframe") == 0) {
214
-                if (getGame().isLoaded()) {
215
-                    getRender().setMode(Render::modeWireframe);
216
-                    getConsole().print("Wireframe mode");
217
-                } else {
218
-                    getConsole().print("Load a level to set this mode!");
219
-                    return -3;
220
-                }
221
-            } else if (strcmp(mode, "solid") == 0) {
222
-                if (getGame().isLoaded()) {
223
-                    getRender().setMode(Render::modeSolid);
224
-                    getConsole().print("Solid mode");
225
-                } else {
226
-                    getConsole().print("Load a level to set this mode!");
227
-                    return -4;
228
-                }
229
-            } else if (strcmp(mode, "texture") == 0) {
230
-                if (getGame().isLoaded()) {
231
-                    getRender().setMode(Render::modeTexture);
232
-                    getConsole().print("Texture mode");
233
-                } else {
234
-                    getConsole().print("Load a level to set this mode!");
235
-                    return -5;
236
-                }
237
-            } else if (strcmp(mode, "vertexlight") == 0) {
238
-                if (getGame().isLoaded()) {
239
-                    getRender().setMode(Render::modeVertexLight);
240
-                    getConsole().print("Vertexlight mode");
241
-                } else {
242
-                    getConsole().print("Load a level to set this mode!");
243
-                    return -6;
244
-                }
245
-            } else if (strcmp(mode, "titlescreen") == 0) {
246
-                getRender().setMode(Render::modeLoadScreen);
247
-                getConsole().print("Titlescreen mode");
248
-            } else {
249
-                getConsole().print("Invalid use of mode command (%s)!", mode);
250
-                return -7;
251
-            }
252
-        } else {
253
-            getConsole().print("Invalid use of mode command!");
254
-            return -8;
255
-        }
256
-    } else if (strcmp(command, "move") == 0) {
257
-        if (!mRunning) {
258
-            getConsole().print("Use move command interactively!");
259
-            return -999;
260
-        }
261
-        if (args->size() > 0) {
262
-            if (getGame().isLoaded()) {
263
-                char *move = args->at(0);
264
-                if (strcmp(move, "walk") == 0) {
265
-                    getGame().mLara->moveType = worldMoveType_walk;
266
-                    getConsole().print("Lara is walking...");
267
-                } else if (strcmp(move, "fly") == 0) {
268
-                    getGame().mLara->moveType = worldMoveType_fly;
269
-                    getConsole().print("Lara is flying...");
270
-                } else if (strcmp(move, "noclip") == 0) {
271
-                    getGame().mLara->moveType = worldMoveType_noClipping;
272
-                    getConsole().print("Lara is noclipping...");
273
-                } else {
274
-                    getConsole().print("Invalid use of move command (%s)!", move);
275
-                    return -9;
276
-                }
277
-            } else {
278
-                getConsole().print("Load a level to change the movement type!");
279
-                return -10;
280
-            }
281
-        } else {
282
-            getConsole().print("Invalid use of move command!");
283
-            return -11;
284
-        }
285
-    } else if (strcmp(command, "sound") == 0) {
286
-        if ((!mRunning) || (!getGame().isLoaded())) {
287
-            getConsole().print("Use sound command interactively!");
288
-            return -999;
289
-        }
290
-        if (args->size() > 0) {
291
-            getSound().play(atoi(args->at(0)));
292
-        } else {
293
-            getConsole().print("Invalid use of sound command!");
294
-            return -12;
295
-        }
296
-    } else if (strcmp(command, "animate") == 0) {
297
-        if ((!mRunning) || (!getGame().isLoaded())) {
298
-            getConsole().print("Use animate command interactively!");
299
-            return -999;
300
-        }
301
-        if (args->size() > 0) {
302
-            char c = args->at(0)[0];
303
-            if (c == 'n') {
304
-                // Step all skeletal models to their next animation
305
-                if (getRender().getFlags() & Render::fAnimateAllModels) {
306
-                    for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
307
-                        SkeletalModel *m = getRender().mModels[i];
308
-                        if (m->getAnimation() < ((int)m->model->animation.size() - 1))
309
-                            m->setAnimation(m->getAnimation() + 1);
310
-                        else
311
-                            if (m->getAnimation() != 0)
312
-                                m->setAnimation(0);
313
-                    }
314
-                } else {
315
-                    getConsole().print("Animations need to be enabled!");
316
-                }
317
-            } else if (c == 'p') {
318
-                // Step all skeletal models to their previous animation
319
-                if (getRender().getFlags() & Render::fAnimateAllModels) {
320
-                    for (unsigned int i = 0; i < getRender().mModels.size(); i++) {
321
-                        SkeletalModel *m = getRender().mModels[i];
322
-                        if (m->getAnimation() > 0)
323
-                            m->setAnimation(m->getAnimation() - 1);
324
-                        else
325
-                            if (m->model->animation.size() > 0)
326
-                                m->setAnimation(m->model->animation.size() - 1);
327
-                    }
328
-                } else {
329
-                    getConsole().print("Animations need to be enabled!");
330
-                }
331
-            } else {
332
-                // Enable or disable animating all skeletal models
333
-                bool b;
334
-                if (readBool(args->at(0), &b) < 0) {
335
-                    getConsole().print("Pass BOOL to animate command!");
336
-                    return -13;
337
-                }
338
-                if (b)
339
-                    getRender().setFlags(Render::fAnimateAllModels);
340
-                else
341
-                    getRender().clearFlags(Render::fAnimateAllModels);
342
-                getConsole().print(b ? "Animating all models" : "No longer animating all models");
343
-            }
344
-        } else {
345
-            getConsole().print("Invalid use of animate command!");
346
-            return -14;
347
-        }
348
-
349
-    } else if (strcmp(command, "light") == 0) {
350
-        if (args->size() > 0) {
351
-            bool b;
352
-            if (readBool(args->at(0), &b) < 0) {
353
-                getConsole().print("Pass BOOL to light command!");
354
-                return -15;
355
-            }
356
-            if (b)
357
-                getRender().setFlags(Render::fGL_Lights);
358
-            else
359
-                getRender().clearFlags(Render::fGL_Lights);
360
-            getConsole().print("GL-Lights are now %s", b ? "on" : "off");
361
-        } else {
362
-            getConsole().print("Invalid use of light-command!");
363
-            return -16;
364
-        }
365
-    } else if (strcmp(command, "fog") == 0) {
366
-        if (args->size() > 0) {
367
-            bool b;
368
-            if (readBool(args->at(0), &b) < 0) {
369
-                getConsole().print("Pass BOOL to fog command!");
370
-                return -17;
371
-            }
372
-            if (b)
373
-                getRender().setFlags(Render::fFog);
374
-            else
375
-                getRender().clearFlags(Render::fFog);
376
-            getConsole().print("Fog is now %s", b ? "on" : "off");
377
-        } else {
378
-            getConsole().print("Invalid use of fog-command!");
379
-            return -18;
380
-        }
381
-    } else if (strcmp(command, "hop") == 0) {
382
-        if (args->size() > 0) {
383
-            bool b;
384
-            if (readBool(args->at(0), &b) < 0) {
385
-                getConsole().print("Pass BOOL to hop command!");
386
-                return -19;
387
-            }
388
-            if (b)
389
-                getWorld().setFlag(World::fEnableHopping);
390
-            else
391
-                getWorld().clearFlag(World::fEnableHopping);
392
-            getConsole().print("Room hopping is now %s", b ? "on" : "off");
393
-        } else {
394
-            getConsole().print("Invalid use of hop-command!");
395
-            return -20;
396
-        }
397
-    } else if (strcmp(command, "viewmodel") == 0) {
398
-        if ((!mRunning) || (!getGame().isLoaded())) {
399
-            getConsole().print("Use viewmodel command interactively!");
400
-            return -999;
401
-        }
402
-        if (getGame().mLara) {
403
-            SkeletalModel *smdl = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
404
-            skeletal_model_t *mdl = getWorld().getModel(atoi(args->at(0)));
405
-            if (smdl)
406
-                smdl->setModel(mdl);
407
-        }
408
-        //m_render.ViewModel(LARA, atoi(cmd));
409
-    } else if (strcmp(command, "pos") == 0) {
410
-        if (getGame().mLara) {
411
-            getConsole().print("Position:");
412
-            getConsole().print("  Room %i (0x%X)", getGame().mLara->room, getWorld().getRoomInfo(getGame().mLara->room));
413
-            getConsole().print("  %.1fx %.1fy %.1fz", getGame().mLara->pos[0], getGame().mLara->pos[1], getGame().mLara->pos[2]);
414
-            getConsole().print("  %.1f Yaw %.1f Pitch", OR_RAD_TO_DEG(getGame().mLara->angles[1]), OR_RAD_TO_DEG(getGame().mLara->angles[2]));
415
-        } else {
416
-            getConsole().print("Load a level to get Laras position!");
417
-            return -21;
418
-        }
419
-    } else if (strcmp(command, "vmodel") == 0) {
420
-        if (args->size() > 0) {
421
-            bool b;
422
-            if (readBool(args->at(0), &b) < 0) {
423
-                getConsole().print("Pass BOOL to vmodel command!");
424
-                return -22;
425
-            }
426
-            if (b)
427
-                getRender().setFlags(Render::fViewModel);
428
-            else
429
-                getRender().clearFlags(Render::fViewModel);
430
-            getConsole().print("Viewmodel is now %s", b ? "on" : "off");
431
-        } else {
432
-            getConsole().print("Invalid use of vmodel-command!");
433
-            return -23;
434
-        }
435
-    } else if (strcmp(command, "ralpha") == 0) {
436
-        if (args->size() > 0) {
437
-            bool b;
438
-            if (readBool(args->at(0), &b) < 0) {
439
-                getConsole().print("Pass BOOL to ralpha command!");
440
-                return -24;
441
-            }
442
-            if (b)
443
-                getRender().setFlags(Render::fRoomAlpha);
444
-            else
445
-                getRender().clearFlags(Render::fRoomAlpha);
446
-            getConsole().print("Room Alpha is now %s", b ? "on" : "off");
447
-        } else {
448
-            getConsole().print("Invalid use of ralpha-command!");
449
-            return -25;
450
-        }
451
-    } else if (strcmp(command, "portal") == 0) {
452
-        if (args->size() > 0) {
453
-            bool b;
454
-            if (readBool(args->at(0), &b) < 0) {
455
-                getConsole().print("Pass BOOL to portal command!");
456
-                return -26;
457
-            }
458
-            if (b)
459
-                getRender().setFlags(Render::fPortals);
460
-            else
461
-                getRender().clearFlags(Render::fPortals);
462
-            getConsole().print("Portals are now %s", b ? "on" : "off");
463
-        } else {
464
-            getConsole().print("Invalid use of portal-command!");
465
-            return -27;
466
-        }
467
-    } else if (strcmp(command, "vis") == 0) {
468
-        if (args->size() > 0) {
469
-            bool b;
470
-            if (readBool(args->at(0), &b) < 0) {
471
-                getConsole().print("Pass BOOL to vis command!");
472
-                return -28;
473
-            }
474
-            if (b)
475
-                getRender().setFlags(Render::fUsePortals);
476
-            else
477
-                getRender().clearFlags(Render::fUsePortals);
478
-            getConsole().print("Portals are now %s", b ? "on" : "off");
479
-        } else {
480
-            getConsole().print("Invalid use of vis-command!");
481
-            return -29;
482
-        }
483
-    } else if (strcmp(command, "upf") == 0) {
484
-        if (args->size() > 0) {
485
-            bool b;
486
-            if (readBool(args->at(0), &b) < 0) {
487
-                getConsole().print("Pass BOOL to upf command!");
488
-                return -30;
489
-            }
490
-            if (b)
491
-                getRender().setFlags(Render::fUpdateRoomListPerFrame);
492
-            else
493
-                getRender().clearFlags(Render::fUpdateRoomListPerFrame);
494
-            getConsole().print("URLPF is now %s", b ? "on" : "off");
495
-        } else {
496
-            getConsole().print("Invalid use of upf-command!");
497
-            return -31;
498
-        }
499
-    } else if (strcmp(command, "sprite") == 0) {
500
-        if (args->size() > 0) {
501
-            bool b;
502
-            if (readBool(args->at(0), &b) < 0) {
503
-                getConsole().print("Pass BOOL to sprite command!");
504
-                return -34;
505
-            }
506
-            if (b)
507
-                getRender().setFlags(Render::fSprites);
508
-            else
509
-                getRender().clearFlags(Render::fSprites);
510
-            getConsole().print("Sprites are now %s", b ? "on" : "off");
511
-        } else {
512
-            getConsole().print("Invalid use of sprite-command!");
513
-            return -35;
514
-        }
515
-    } else if (strcmp(command, "roommodel") == 0) {
516
-        if (args->size() > 0) {
517
-            bool b;
518
-            if (readBool(args->at(0), &b) < 0) {
519
-                getConsole().print("Pass BOOL to roommodel command!");
520
-                return -36;
521
-            }
522
-            if (b)
523
-                getRender().setFlags(Render::fRoomModels);
524
-            else
525
-                getRender().clearFlags(Render::fRoomModels);
526
-            getConsole().print("Roommodels are now %s", b ? "on" : "off");
527
-        } else {
528
-            getConsole().print("Invalid use of roommodel-command!");
529
-            return -37;
530
-        }
531
-    } else if (strcmp(command, "entmodel") == 0) {
532
-        if (args->size() > 0) {
533
-            bool b;
534
-            if (readBool(args->at(0), &b) < 0) {
535
-                getConsole().print("Pass BOOL to entmodel command!");
536
-                return -38;
537
-            }
538
-            if (b)
539
-                getRender().setFlags(Render::fEntityModels);
540
-            else
541
-                getRender().clearFlags(Render::fEntityModels);
542
-            getConsole().print("Entmodels are now %s", b ? "on" : "off");
543
-        } else {
544
-            getConsole().print("Invalid use of entmodel-command!");
545
-            return -39;
546
-        }
547
-    } else if (strcmp(command, "oneroom") == 0) {
548
-        if (args->size() > 0) {
549
-            bool b;
550
-            if (readBool(args->at(0), &b) < 0) {
551
-                getConsole().print("Pass BOOL to oneroom command!");
552
-                return -40;
553
-            }
554
-            if (b)
555
-                getRender().setFlags(Render::fOneRoom);
556
-            else
557
-                getRender().clearFlags(Render::fOneRoom);
558
-            getConsole().print("Rendering one room is now %s", b ? "on" : "off");
559
-        } else {
560
-            getConsole().print("Invalid use of oneroom-command!");
561
-            return -41;
562
-        }
563
-    } else if (strcmp(command, "allrooms") == 0) {
564
-        if (args->size() > 0) {
565
-            bool b;
566
-            if (readBool(args->at(0), &b) < 0) {
567
-                getConsole().print("Pass BOOL to allrooms command!");
568
-                return -42;
569
-            }
570
-            if (b)
571
-                getRender().setFlags(Render::fAllRooms);
572
-            else
573
-                getRender().clearFlags(Render::fAllRooms);
574
-            getConsole().print("Rendering all rooms is now %s", b ? "on" : "off");
575
-        } else {
576
-            getConsole().print("Invalid use of allrooms-command!");
577
-            return -43;
578
-        }
579
-    } else if (strcmp(command, "ponytail") == 0) {
580
-        if (args->size() > 0) {
581
-            bool b;
582
-            if (readBool(args->at(0), &b) < 0) {
583
-                getConsole().print("Pass BOOL to ponytail command!");
584
-                return -44;
585
-            }
586
-            if (b)
587
-                getRender().setFlags(Render::fRenderPonytail);
588
-            else
589
-                getRender().clearFlags(Render::fRenderPonytail);
590
-            getConsole().print("Ponytail is now %s", b ? "on" : "off");
591
-        } else {
592
-            getConsole().print("Invalid use of ponytail-command!");
593
-            return -45;
594
-        }
595
-    } else if (strcmp(command, "pigtail") == 0) {
596
-        if ((!mRunning) || (!getGame().isLoaded())) {
597
-            getConsole().print("Use pigtail command interactively!");
598
-            return -999;
599
-        }
600
-        if (args->size() > 0) {
601
-            bool b;
602
-            if (readBool(args->at(0), &b) < 0) {
603
-                getConsole().print("Pass BOOL to pigtail command!");
604
-                return -46;
605
-            }
606
-            SkeletalModel *tmp = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
607
-            tmp->model->pigtails = b;
608
-            if (b) {
609
-                tmp->model->ponyOff -= 20;
610
-                tmp->model->ponytail[1] -= 32;
611
-            } else {
612
-                tmp->model->ponyOff += 20;
613
-                tmp->model->ponytail[1] += 32;
614
-            }
615
-            getConsole().print("Pigtail is now %s", b ? "on" : "off");
616
-        } else {
617
-            getConsole().print("Invalid use of pigtail-command!");
618
-            return -47;
619
-        }
620
-    } else if (strcmp(command, "ponypos") == 0) {
621
-        if ((!mRunning) || (!getGame().isLoaded())) {
622
-            getConsole().print("Use ponypos command interactively!");
623
-            return -999;
624
-        }
625
-        if (args->size() > 3) {
626
-            SkeletalModel *tmp = static_cast<SkeletalModel *>(getGame().mLara->tmpHook);
627
-            tmp->model->ponytail[0] = (float)atof(args->at(0));
628
-            tmp->model->ponytail[1] = (float)atof(args->at(1));
629
-            tmp->model->ponytail[2] = (float)atof(args->at(2));
630
-            tmp->model->ponytailAngle = (float)atof(args->at(3));
631
-        } else {
632
-            getConsole().print("Invalid use of ponypos-command!");
633
-            return -48;
634
-        }
635
-    } else if (strcmp(command, "help") == 0) {
636
-        if (args->size() == 0) {
637
-            getConsole().print("Available commands:");
638
-            getConsole().print("  load      - load a level");
639
-            getConsole().print("  set       - set a parameter");
640
-            getConsole().print("  bind      - bind a keyboard/mouse action");
641
-            getConsole().print("  sshot     - make a screenshot");
642
-            getConsole().print("  move      - [walk|fly|noclip]");
643
-            getConsole().print("  sound     - INT - Test play sound");
644
-            getConsole().print("  mode      - MODE - Render mode");
645
-            getConsole().print("  animate   - [BOOL|n|p] - Animate models");
646
-            getConsole().print("  light     - BOOL - GL Lights");
647
-            getConsole().print("  fog       - BOOL - GL Fog");
648
-            getConsole().print("  hop       - BOOL - Room hop");
649
-            getConsole().print("  viewmodel - INT - Change Laras model");
650
-            getConsole().print("  pos       - Print position info");
651
-            getConsole().print("  vmodel    - BOOL - View Model");
652
-            getConsole().print("  ralpha    - BOOL - Room Alpha");
653
-            getConsole().print("  portal    - BOOL");
654
-            getConsole().print("  vis       - BOOL - Use Portals");
655
-            getConsole().print("  upf       - BOOL - Update Room List Per Frame");
656
-            getConsole().print("  sprite    - BOOL");
657
-            getConsole().print("  roommodel - BOOL");
658
-            getConsole().print("  entmodel  - BOOL");
659
-            getConsole().print("  oneroom   - BOOL");
660
-            getConsole().print("  allrooms  - BOOL");
661
-            getConsole().print("  ponytail  - BOOL");
662
-            getConsole().print("  pigtail   - BOOL");
663
-            getConsole().print("  ponypos   - FLOAT FLOAT FLOAT FLOAT - x y z angle");
664
-            getConsole().print("  help      - print command help");
665
-            getConsole().print("  quit      - exit OpenRaider");
666
-            getConsole().print("Use help COMMAND to get additional info");
667
-        } else if (args->size() == 1) {
668
-            return help(args->at(0));
669
-        } else {
670
-            getConsole().print("Invalid use of help-command");
671
-            return -49;
672
-        }
673
-    } else {
674
-        getConsole().print("Unknown command: %s ", command);
675
-        return -50;
676
-    }
677
-
678
-    return 0;
679
-}
680
-
681
-int OpenRaider::help(const char *cmd) {
682
-    assert(cmd != NULL);
683
-    assert(cmd[0] != '\0');
684
-
685
-    if (strcmp(cmd, "set") == 0) {
686
-        getConsole().print("set-Command Usage:");
687
-        getConsole().print("  set VAR VAL");
688
-        getConsole().print("Available Variables:");
689
-        getConsole().print("  basedir    STRING");
690
-        getConsole().print("  pakdir     STRING");
691
-        getConsole().print("  audiodir   STRING");
692
-        getConsole().print("  datadir    STRING");
693
-        getConsole().print("  font       STRING");
694
-        getConsole().print("  gldriver   STRING");
695
-        getConsole().print("  size       \"INTxINT\"");
696
-        getConsole().print("  fullscreen BOOL");
697
-        getConsole().print("  audio      BOOL");
698
-        getConsole().print("  volume     BOOL");
699
-        getConsole().print("  mouse_x    FLOAT");
700
-        getConsole().print("  mouse_y    FLOAT");
701
-        getConsole().print("  fps        BOOL");
702
-        getConsole().print("Enclose STRINGs with \"\"!");
703
-        getConsole().print("size expects a STRING in the specified format");
704
-    } else if (strcmp(cmd, "bind") == 0) {
705
-        getConsole().print("bind-Command Usage:");
706
-        getConsole().print("  bind ACTION KEY");
707
-        getConsole().print("Available Actions:");
708
-        getConsole().print("  menu");
709
-        getConsole().print("  console");
710
-        getConsole().print("  forward");
711
-        getConsole().print("  backward");
712
-        getConsole().print("  left");
713
-        getConsole().print("  right");
714
-        getConsole().print("  jump");
715
-        getConsole().print("  crouch");
716
-        getConsole().print("  use");
717
-        getConsole().print("  holster");
718
-        getConsole().print("Key-Format:");
719
-        getConsole().print("  'a' or '1'    for character/number keys");
720
-        getConsole().print("  \"leftctrl\"  for symbols and special keys");
721
-    } else if (strcmp(cmd, "load") == 0) {
722
-        getConsole().print("load-Command Usage:");
723
-        getConsole().print("  load levelfile.name");
724
-    } else if (strcmp(cmd, "game") == 0) {
725
-        getConsole().print("Use \"game help\" for more info");
726
-    } else if (strcmp(cmd, "sshot") == 0) {
727
-        getConsole().print("sshot-Command Usage:");
728
-        getConsole().print("  sshot [console|menu]");
729
-        getConsole().print("Add console/menu to capture them too");
730
-    } else if (strcmp(cmd, "sound") == 0) {
731
-        getConsole().print("sound-Command Usage:");
732
-        getConsole().print("  sound INT");
733
-        getConsole().print("Where INT is a valid sound ID integer");
734
-    } else if (strcmp(cmd, "move") == 0) {
735
-        getConsole().print("move-Command Usage:");
736
-        getConsole().print("  move COMMAND");
737
-        getConsole().print("Where COMMAND is one of the following:");
738
-        getConsole().print("  walk");
739
-        getConsole().print("  fly");
740
-        getConsole().print("  noclip");
741
-    } else if (strcmp(cmd, "mode") == 0) {
742
-        getConsole().print("mode-Command Usage:");
743
-        getConsole().print("  mode MODE");
744
-        getConsole().print("Where MODE is one of the following:");
745
-        getConsole().print("  wireframe");
746
-        getConsole().print("  solid");
747
-        getConsole().print("  texture");
748
-        getConsole().print("  vertexlight");
749
-        getConsole().print("  titlescreen");
750
-    } else if (strcmp(cmd, "animate") == 0) {
751
-        getConsole().print("animate-Command Usage:");
752
-        getConsole().print("  animate [n|p|BOOL]");
753
-        getConsole().print("Where the commands have the following meaning:");
754
-        getConsole().print("  BOOL to (de)activate animating all models");
755
-        getConsole().print("  n to step all models to their next animation");
756
-        getConsole().print("  p to step all models to their previous animation");
757
-    } else {
758
-        getConsole().print("No help available for %s", cmd);
759
-        return -1;
760
-    }
761
-
762
-    return 0;
763
-}
764
-
765 157
 char *OpenRaider::expandDirectoryNames(const char *s) {
766 158
     assert(s != NULL);
767 159
     assert(s[0] != '\0');

+ 2
- 4
src/Render.cpp Parādīt failu

@@ -165,8 +165,6 @@ int Render::initTextures(char *textureDir) {
165 165
 
166 166
 void Render::ClearWorld()
167 167
 {
168
-    getGame().mLara = NULL;
169
-
170 168
     mRoomRenderList.clear();
171 169
 
172 170
     for (unsigned int i = 0; i < mRooms.size(); i++) {
@@ -492,7 +490,7 @@ void Render::display()
492 490
     // Let's see the LoS -- should be event controled
493 491
     if (getGame().mLara)
494 492
     {
495
-        //      SkeletalModel *mdl = (SkeletalModel *)getGame().mLara->tmpHook;
493
+        // SkeletalModel *mdl = (SkeletalModel *)getGame().mLara->tmpHook;
496 494
 
497 495
         // Draw in solid colors
498 496
         glDisable(GL_TEXTURE_2D);
@@ -586,7 +584,7 @@ void Render::display()
586 584
             if (!isVisible(e->pos[0], e->pos[1], e->pos[2], 512.0f))
587 585
                 continue;
588 586
 
589
-            // Is it in a room we're rendering?
587
+            //! \fixme Is it in a room we're rendering?
590 588
             //if (mRoomRenderList[e->room] == 0x0)
591 589
             //{
592 590
             //  continue;

+ 4
- 1
src/WindowSDL.cpp Parādīt failu

@@ -567,7 +567,10 @@ void WindowSDL::writeString(WindowString *s) {
567 567
         else
568 568
             textureFormat = GL_BGRA_EXT;
569 569
     } else {
570
-        textureFormat = GL_RGB;
570
+        if (surface->format->Rmask == 0x000000FF)
571
+            textureFormat = GL_RGB;
572
+        else
573
+            textureFormat = GL_BGR;
571 574
     }
572 575
 
573 576
     glBindTexture(GL_TEXTURE_2D, mFontTexture);

+ 2
- 18
src/World.cpp Parādīt failu

@@ -17,7 +17,6 @@
17 17
 
18 18
 World::World()
19 19
 {
20
-    mFlags = 0;
21 20
 }
22 21
 
23 22
 
@@ -75,10 +74,8 @@ int World::getRoomByLocation(float x, float y, float z)
75 74
     }
76 75
 
77 76
     // Room is -1?  Must be in void, try to hop to room with same X,Z
78
-    if (mFlags & fEnableHopping)
79
-        return hop;
80
-
81
-    return -1;
77
+    return hop;
78
+    //return -1;
82 79
 }
83 80
 
84 81
 
@@ -267,19 +264,6 @@ std::vector<room_mesh_t *> *World::getRooms()
267 264
 #endif
268 265
 
269 266
 
270
-void World::setFlag(WorldFlag flag)
271
-{
272
-    mFlags |= flag;
273
-}
274
-
275
-
276
-
277
-void World::clearFlag(WorldFlag flag)
278
-{
279
-    mFlags &= ~flag;
280
-}
281
-
282
-
283 267
 void World::destroy()
284 268
 {
285 269
     room_mesh_t *room;

Notiek ielāde…
Atcelt
Saglabāt