Thomas Buck преди 9 години
родител
ревизия
dc2e6b69a0

+ 3
- 0
ChangeLog.md Целия файл

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20140827 ]
6
+    * Rewrote command system. Each command is now a unique class.
7
+
5 8
     [ 20140817 ]
6 9
     * Completed the file reading part of the new TR2 level loader
7 10
 

+ 4
- 0
TODO.md Целия файл

@@ -9,6 +9,10 @@
9 9
 * Don’t use float everywhere just because (eg. float colors)
10 10
 * Add verbose command line flag for debug output also in release builds
11 11
 
12
+## Bugs
13
+
14
+* Screenshots are sometimes not written, sometimes distorted?
15
+
12 16
 ## Cmake
13 17
 
14 18
 * Support SSE with other compilers than Clang (src/CMakeLists.txt)

+ 7
- 11
include/OpenRaider.h Целия файл

@@ -8,8 +8,11 @@
8 8
 #ifndef _OPENRAIDER_H_
9 9
 #define _OPENRAIDER_H_
10 10
 
11
-#include <istream>
11
+#include <memory>
12 12
 #include <string>
13
+#include <vector>
14
+
15
+#include "commands/Command.h"
13 16
 
14 17
 /*!
15 18
  * \brief Main Game Singleton
@@ -51,19 +54,12 @@ public:
51 54
     char *mPakDir;
52 55
     char *mAudioDir;
53 56
     char *mDataDir;
54
-
55
-private:
56
-
57
-    char *expandDirectoryNames(const char *s);
58
-    int set(std::istream &command);
59
-    int bind(const char *action, const char *key);
60
-
61
-    static int help(std::string &cmd);
62
-
57
+    KeyboardButton keyBindings[ActionEventCount];
63 58
     bool mRunning;
64 59
     bool mFPS;
65 60
 
66
-    KeyboardButton keyBindings[ActionEventCount];
61
+private:
62
+    std::vector<std::shared_ptr<Command>> commands;
67 63
 };
68 64
 
69 65
 OpenRaider &getOpenRaider();

+ 43
- 0
include/commands/Command.h Целия файл

@@ -0,0 +1,43 @@
1
+/*!
2
+ * \file include/commands/Command.h
3
+ * \brief Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_H_
9
+#define _COMMAND_H_
10
+
11
+#include <istream>
12
+#include <memory>
13
+#include <string>
14
+#include <vector>
15
+
16
+class Command {
17
+public:
18
+    virtual ~Command();
19
+    virtual std::string name() = 0;
20
+    virtual std::string brief() = 0;
21
+    virtual void printHelp();
22
+    virtual int execute(std::istream& args) = 0;
23
+};
24
+
25
+#define DECLARE_SIMPLE_CMD(x) \
26
+    class x : public Command { \
27
+    public: \
28
+        virtual std::string name(); \
29
+        virtual std::string brief(); \
30
+        virtual void printHelp(); \
31
+        virtual int execute(std::istream& args); \
32
+    }
33
+
34
+#define DECLARE_SIMPLE_CMD_NO_HELP(x) \
35
+    class x : public Command { \
36
+    public: \
37
+        virtual std::string name(); \
38
+        virtual std::string brief(); \
39
+        virtual int execute(std::istream& args); \
40
+    }
41
+
42
+#endif
43
+

+ 16
- 0
include/commands/CommandAnimate.h Целия файл

@@ -0,0 +1,16 @@
1
+/*!
2
+ * \file include/commands/CommandAnimate.h
3
+ * \brief Animate Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_ANIMATE_H_
9
+#define _COMMAND_ANIMATE_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandAnimate);
14
+
15
+#endif
16
+

+ 16
- 0
include/commands/CommandBind.h Целия файл

@@ -0,0 +1,16 @@
1
+/*!
2
+ * \file include/commands/CommandBind.h
3
+ * \brief Bind Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_BIND_H_
9
+#define _COMMAND_BIND_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandBind);
14
+
15
+#endif
16
+

+ 20
- 0
include/commands/CommandEngine.h Целия файл

@@ -0,0 +1,20 @@
1
+/*!
2
+ * \file include/commands/CommandEngine.h
3
+ * \brief Engine Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_ENGINE_H_
9
+#define _COMMAND_ENGINE_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandLoad);
14
+
15
+DECLARE_SIMPLE_CMD(CommandScreenshot);
16
+
17
+DECLARE_SIMPLE_CMD_NO_HELP(CommandQuit);
18
+
19
+#endif
20
+

+ 18
- 0
include/commands/CommandGame.h Целия файл

@@ -0,0 +1,18 @@
1
+/*!
2
+ * \file include/commands/CommandGame.h
3
+ * \brief Game Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_GAME_H_
9
+#define _COMMAND_GAME_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD_NO_HELP(CommandPos);
14
+
15
+DECLARE_SIMPLE_CMD_NO_HELP(CommandViewmodel);
16
+
17
+#endif
18
+

+ 16
- 0
include/commands/CommandMove.h Целия файл

@@ -0,0 +1,16 @@
1
+/*!
2
+ * \file include/commands/CommandMove.h
3
+ * \brief Move Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_MOVE_H_
9
+#define _COMMAND_MOVE_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandMove);
14
+
15
+#endif
16
+

+ 20
- 0
include/commands/CommandRender.h Целия файл

@@ -0,0 +1,20 @@
1
+/*!
2
+ * \file include/commands/CommandRender.h
3
+ * \brief Render Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_RENDER_H_
9
+#define _COMMAND_RENDER_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandMode);
14
+
15
+DECLARE_SIMPLE_CMD_NO_HELP(CommandFog);
16
+
17
+DECLARE_SIMPLE_CMD_NO_HELP(CommandLight);
18
+
19
+#endif
20
+

+ 16
- 0
include/commands/CommandSet.h Целия файл

@@ -0,0 +1,16 @@
1
+/*!
2
+ * \file include/commands/CommandSet.h
3
+ * \brief Set Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_SET_H_
9
+#define _COMMAND_SET_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandSet);
14
+
15
+#endif
16
+

+ 16
- 0
include/commands/CommandSound.h Целия файл

@@ -0,0 +1,16 @@
1
+/*!
2
+ * \file include/commands/CommandSound.h
3
+ * \brief Sound Command interface
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _COMMAND_SOUND_H_
9
+#define _COMMAND_SOUND_H_
10
+
11
+#include "commands/Command.h"
12
+
13
+DECLARE_SIMPLE_CMD(CommandSound);
14
+
15
+#endif
16
+

+ 4
- 4
src/CMakeLists.txt Целия файл

@@ -48,7 +48,6 @@ endif (PNG_FOUND)
48 48
 
49 49
 # Set Source files
50 50
 set (SRCS ${SRCS} "Camera.cpp")
51
-set (SRCS ${SRCS} "Command.cpp")
52 51
 set (SRCS ${SRCS} "Console.cpp")
53 52
 set (SRCS ${SRCS} "Entity.cpp")
54 53
 set (SRCS ${SRCS} "Exception.cpp")
@@ -213,6 +212,7 @@ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OpenRaider_CXX_FLAGS} ${O
213 212
 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OpenRaider_CXX_FLAGS} ${OpenRaider_CXX_FLAGS_RELEASE}")
214 213
 
215 214
 # Add subdirectories
215
+add_subdirectory ("commands")
216 216
 add_subdirectory ("deps")
217 217
 add_subdirectory ("loader")
218 218
 add_subdirectory ("math")
@@ -221,9 +221,9 @@ add_subdirectory ("utils")
221 221
 # Add Executable
222 222
 add_library (OpenRaider_all OBJECT ${SRCS})
223 223
 add_executable (OpenRaider MACOSX_BUNDLE ${RESRCS}
224
-    $<TARGET_OBJECTS:OpenRaider_all> $<TARGET_OBJECTS:OpenRaider_deps>
225
-    $<TARGET_OBJECTS:OpenRaider_math> $<TARGET_OBJECTS:OpenRaider_utils>
226
-    $<TARGET_OBJECTS:OpenRaider_loader>
224
+    $<TARGET_OBJECTS:OpenRaider_all> $<TARGET_OBJECTS:OpenRaider_commands>
225
+    $<TARGET_OBJECTS:OpenRaider_deps> $<TARGET_OBJECTS:OpenRaider_math>
226
+    $<TARGET_OBJECTS:OpenRaider_utils> $<TARGET_OBJECTS:OpenRaider_loader>
227 227
 )
228 228
 
229 229
 #################################################################

+ 0
- 631
src/Command.cpp Целия файл

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

+ 112
- 0
src/OpenRaider.cpp Целия файл

@@ -7,9 +7,19 @@
7 7
 
8 8
 #include <cstdio>
9 9
 #include <cstring>
10
+#include <fstream>
11
+#include <iomanip>
10 12
 #include <sstream>
11 13
 
12 14
 #include "global.h"
15
+#include "commands/CommandAnimate.h"
16
+#include "commands/CommandBind.h"
17
+#include "commands/CommandEngine.h"
18
+#include "commands/CommandGame.h"
19
+#include "commands/CommandMove.h"
20
+#include "commands/CommandRender.h"
21
+#include "commands/CommandSet.h"
22
+#include "commands/CommandSound.h"
13 23
 #include "Console.h"
14 24
 #include "Font.h"
15 25
 #include "Game.h"
@@ -33,6 +43,20 @@ OpenRaider::OpenRaider() {
33 43
 
34 44
     for (int i = 0; i < ActionEventCount; i++)
35 45
         keyBindings[i] = unknownKey;
46
+
47
+    commands.push_back(std::shared_ptr<Command>(new CommandLoad()));
48
+    commands.push_back(std::shared_ptr<Command>(new CommandBind()));
49
+    commands.push_back(std::shared_ptr<Command>(new CommandSet()));
50
+    commands.push_back(std::shared_ptr<Command>(new CommandScreenshot()));
51
+    commands.push_back(std::shared_ptr<Command>(new CommandAnimate()));
52
+    commands.push_back(std::shared_ptr<Command>(new CommandMove()));
53
+    commands.push_back(std::shared_ptr<Command>(new CommandMode()));
54
+    commands.push_back(std::shared_ptr<Command>(new CommandFog()));
55
+    commands.push_back(std::shared_ptr<Command>(new CommandLight()));
56
+    commands.push_back(std::shared_ptr<Command>(new CommandSound()));
57
+    commands.push_back(std::shared_ptr<Command>(new CommandPos()));
58
+    commands.push_back(std::shared_ptr<Command>(new CommandViewmodel()));
59
+    commands.push_back(std::shared_ptr<Command>(new CommandQuit()));
36 60
 }
37 61
 
38 62
 OpenRaider::~OpenRaider() {
@@ -49,6 +73,94 @@ OpenRaider::~OpenRaider() {
49 73
     mDataDir = NULL;
50 74
 }
51 75
 
76
+int OpenRaider::loadConfig(const char *config) {
77
+    assert(config != NULL);
78
+    assert(config[0] != '\0');
79
+
80
+    char *configFile = fullPath(config, 0);
81
+    getConsole() << "Loading config from \"" << configFile << "\"..." << Console::endl;
82
+
83
+    std::ifstream file(configFile);
84
+    if (!file) {
85
+        getConsole() << "Could not open file!" << Console::endl;
86
+        return -1;
87
+    }
88
+
89
+    for (std::string line; std::getline(file, line);) {
90
+        if (line.length() == 0)
91
+            continue;
92
+
93
+        int error = command(line);
94
+        if (error != 0)
95
+            getConsole() << "Error Code: " << error << Console::endl;
96
+    }
97
+
98
+    file.close();
99
+
100
+    return 0;
101
+}
102
+
103
+int OpenRaider::command(std::string c) {
104
+    // Remove comment, if any
105
+    size_t comment = c.find_first_of('#');
106
+    if (comment != std::string::npos)
107
+        c.erase(comment);
108
+
109
+    // Execute command
110
+    std::stringstream command(c);
111
+    std::string cmd;
112
+    command >> cmd;
113
+    command >> std::boolalpha >> std::ws;
114
+
115
+    if (cmd.length() == 0)
116
+        return 0;
117
+
118
+    // Print help
119
+    if (cmd.compare("help") == 0) {
120
+        std::string arg;
121
+        command >> arg;
122
+        if (arg.length() == 0) {
123
+            // List all available commands
124
+            getConsole() << "Available commands:" << Console::endl;
125
+            getConsole() << std::right << std::setw(11);
126
+            getConsole() << "help" << " - print command help" << Console::endl;
127
+            for (auto &x : commands) {
128
+                if (x) {
129
+                    getConsole() << std::right << std::setw(11);
130
+                    getConsole() << x->name() << " - " << x->brief() << Console::endl;
131
+                }
132
+            }
133
+            getConsole() << "Use help COMMAND to get additional info" << Console::endl;
134
+            getConsole() << "Pass BOOLs as true or false" << Console::endl;
135
+            return 0;
136
+        } else {
137
+            // Show help for a specific command
138
+            for (auto &x : commands) {
139
+                if (x) {
140
+                    if (x->name().compare(arg) == 0) {
141
+                        x->printHelp();
142
+                        return 0;
143
+                    }
144
+                }
145
+            }
146
+            getConsole() << "Unknown command: \"" << arg << "\"" << Console::endl;
147
+            return -1;
148
+        }
149
+    }
150
+
151
+    // Execute command
152
+    for (auto &x : commands) {
153
+        if (x) {
154
+            if (x->name().compare(cmd) == 0) {
155
+                return x->execute(command);
156
+            }
157
+        }
158
+    }
159
+
160
+    getConsole() << "Unknown command: \"" << cmd << "\"" << Console::endl;
161
+    return -1;
162
+}
163
+
52 164
 int OpenRaider::initialize() {
53 165
     // Initialize Windowing
54 166
     int error = getWindow().initialize();

+ 14
- 0
src/commands/CMakeLists.txt Целия файл

@@ -0,0 +1,14 @@
1
+# Source files
2
+set (CMD_SRCS ${CMD_SRCS} "Command.cpp")
3
+set (CMD_SRCS ${CMD_SRCS} "CommandAnimate.cpp")
4
+set (CMD_SRCS ${CMD_SRCS} "CommandBind.cpp")
5
+set (CMD_SRCS ${CMD_SRCS} "CommandEngine.cpp")
6
+set (CMD_SRCS ${CMD_SRCS} "CommandGame.cpp")
7
+set (CMD_SRCS ${CMD_SRCS} "CommandMove.cpp")
8
+set (CMD_SRCS ${CMD_SRCS} "CommandRender.cpp")
9
+set (CMD_SRCS ${CMD_SRCS} "CommandSet.cpp")
10
+set (CMD_SRCS ${CMD_SRCS} "CommandSound.cpp")
11
+
12
+# Add library
13
+add_library (OpenRaider_commands OBJECT ${CMD_SRCS})
14
+

+ 19
- 0
src/commands/Command.cpp Целия файл

@@ -0,0 +1,19 @@
1
+/*!
2
+ * \file src/commands/Command.cpp
3
+ * \brief Commands
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "commands/Command.h"
11
+
12
+Command::~Command() {
13
+
14
+}
15
+
16
+void Command::printHelp() {
17
+    getConsole() << "No help available!" << Console::endl;
18
+}
19
+

+ 84
- 0
src/commands/CommandAnimate.cpp Целия файл

@@ -0,0 +1,84 @@
1
+/*!
2
+ * \file src/commands/CommandAnimate.cpp
3
+ * \brief Animate command
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "Game.h"
11
+#include "OpenRaider.h"
12
+#include "Render.h"
13
+#include "World.h"
14
+#include "commands/CommandAnimate.h"
15
+
16
+std::string CommandAnimate::name() {
17
+    return "animate";
18
+}
19
+
20
+std::string CommandAnimate::brief() {
21
+    return "[BOOL|n|p] - Animate models";
22
+}
23
+
24
+void CommandAnimate::printHelp() {
25
+    getConsole() << "animate-Command Usage:" << Console::endl;
26
+    getConsole() << "  animate [n|p|BOOL]" << Console::endl;
27
+    getConsole() << "Where the commands have the following meaning:" << Console::endl;
28
+    getConsole() << "  BOOL to (de)activate animating all models" << Console::endl;
29
+    getConsole() << "  n to step all models to their next animation" << Console::endl;
30
+    getConsole() << "  p to step all models to their previous animation" << Console::endl;
31
+}
32
+
33
+int CommandAnimate::execute(std::istream& args) {
34
+    if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
35
+        getConsole() << "Use animate command interactively!" << Console::endl;
36
+        return -1;
37
+    }
38
+
39
+    if (args.peek() == 'n') {
40
+        // Step all skeletal models to their next animation
41
+        if (getRender().getFlags() & Render::fAnimateAllModels) {
42
+            for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
43
+                Entity &e = getWorld().getEntity(i);
44
+                SkeletalModel &m = e.getModel();
45
+                if (e.getAnimation() < (m.size() - 1))
46
+                    e.setAnimation(e.getAnimation() + 1);
47
+                else
48
+                    e.setAnimation(0);
49
+            }
50
+        } else {
51
+            getConsole() << "Animations need to be enabled!" << Console::endl;
52
+        }
53
+    } else if (args.peek() == 'p') {
54
+        // Step all skeletal models to their previous animation
55
+        if (getRender().getFlags() & Render::fAnimateAllModels) {
56
+            for (unsigned int i = 0; i < getWorld().sizeEntity(); i++) {
57
+                Entity &e = getWorld().getEntity(i);
58
+                SkeletalModel &m = e.getModel();
59
+                if (e.getAnimation() > 0)
60
+                    e.setAnimation(e.getAnimation() - 1);
61
+                else
62
+                    if (m.size() > 0)
63
+                        e.setAnimation(m.size() - 1);
64
+            }
65
+        } else {
66
+            getConsole() << "Animations need to be enabled!" << Console::endl;
67
+        }
68
+    } else {
69
+        // Enable or disable animating all skeletal models
70
+        bool b = false;
71
+        if (!(args >> b)) {
72
+            getConsole() << "Pass BOOL to animate command!" << Console::endl;
73
+            return -2;
74
+        }
75
+        if (b)
76
+            getRender().setFlags(Render::fAnimateAllModels);
77
+        else
78
+            getRender().clearFlags(Render::fAnimateAllModels);
79
+        getConsole() << (b ? "Animating all models" : "No longer animating all models") << Console::endl;
80
+    }
81
+
82
+    return 0;
83
+}
84
+

+ 63
- 0
src/commands/CommandBind.cpp Целия файл

@@ -0,0 +1,63 @@
1
+/*!
2
+ * \file src/commands/CommandBind.cpp
3
+ * \brief Bind command
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "OpenRaider.h"
11
+#include "commands/CommandBind.h"
12
+
13
+std::string CommandBind::name() {
14
+    return "bind";
15
+}
16
+
17
+std::string CommandBind::brief() {
18
+    return "bind a keyboard/mouse action";
19
+}
20
+
21
+void CommandBind::printHelp() {
22
+    getConsole() << "bind-Command Usage:" << Console::endl;
23
+    getConsole() << "  bind ACTION KEY" << Console::endl;
24
+    getConsole() << "Available Actions:" << Console::endl;
25
+    getConsole() << "  menu" << Console::endl;
26
+    getConsole() << "  console" << Console::endl;
27
+    getConsole() << "  forward" << Console::endl;
28
+    getConsole() << "  backward" << Console::endl;
29
+    getConsole() << "  left" << Console::endl;
30
+    getConsole() << "  right" << Console::endl;
31
+    getConsole() << "  jump" << Console::endl;
32
+    getConsole() << "  crouch" << Console::endl;
33
+    getConsole() << "  use" << Console::endl;
34
+    getConsole() << "  holster" << Console::endl;
35
+    getConsole() << "  walk" << Console::endl;
36
+    getConsole() << "Key-Format:" << Console::endl;
37
+    getConsole() << "  'a' or '1'    for character/number keys" << Console::endl;
38
+    getConsole() << "  \"leftctrl\"  for symbols and special keys" << Console::endl;
39
+}
40
+
41
+int CommandBind::execute(std::istream& args) {
42
+    std::string a, b;
43
+    if (!(args >> a >> b)) {
44
+        getConsole() << "Invalid use of bind-command" << Console::endl;
45
+        return -1;
46
+    } else {
47
+        ActionEvents e = stringToActionEvent(a.c_str());
48
+        if (e == ActionEventCount) {
49
+            getConsole() << "bind-Error: Unknown action (" << a << ")" << Console::endl;
50
+            return -2;
51
+        }
52
+
53
+        KeyboardButton c = stringToKeyboardButton(b.c_str());
54
+        if (c == unknownKey) {
55
+            getConsole() << "bind-Error: Unknown key (" << b << ")" << Console::endl;
56
+            return -3;
57
+        }
58
+
59
+        getOpenRaider().keyBindings[e] = c;
60
+        return 0;
61
+    }
62
+}
63
+

+ 109
- 0
src/commands/CommandEngine.cpp Целия файл

@@ -0,0 +1,109 @@
1
+/*!
2
+ * \file src/commands/CommandEngine.cpp
3
+ * \brief Engine commands
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "Game.h"
11
+#include "Menu.h"
12
+#include "OpenRaider.h"
13
+#include "Render.h"
14
+#include "commands/CommandEngine.h"
15
+
16
+std::string CommandLoad::name() {
17
+    return "load";
18
+}
19
+
20
+std::string CommandLoad::brief() {
21
+    return "load a level file";
22
+}
23
+
24
+void CommandLoad::printHelp() {
25
+    getConsole() << "load-Command Usage:" << Console::endl;
26
+    getConsole() << "  load /path/to/level" << Console::endl;
27
+}
28
+
29
+int CommandLoad::execute(std::istream& args) {
30
+    if (!getOpenRaider().mRunning) {
31
+        getConsole() << "Use load command interactively!" << Console::endl;
32
+        return -1;
33
+    }
34
+
35
+    std::string map;
36
+    args >> map;
37
+    int error = getGame().loadLevel(map.c_str());
38
+    return error;
39
+}
40
+
41
+// --------------------------------------
42
+
43
+std::string CommandScreenshot::name() {
44
+    return "sshot";
45
+}
46
+
47
+std::string CommandScreenshot::brief() {
48
+    return "make a screenshot";
49
+}
50
+
51
+void CommandScreenshot::printHelp() {
52
+    getConsole() << "sshot-Command Usage:" << Console::endl;
53
+    getConsole() << "  sshot [console|menu]" << Console::endl;
54
+    getConsole() << "Add console/menu to capture them too" << Console::endl;
55
+}
56
+
57
+int CommandScreenshot::execute(std::istream& args) {
58
+    if (!getOpenRaider().mRunning) {
59
+        getConsole() << "Use sshot command interactively!" << Console::endl;
60
+        return -1;
61
+    }
62
+
63
+    std::string filename(getOpenRaider().mBaseDir);
64
+    filename += "/sshots/";
65
+    filename += VERSION_SHORT;
66
+
67
+    bool console = false, menu = false;
68
+    std::string temp;
69
+    args >> temp;
70
+    if (temp.compare("console") == 0)
71
+        console = true;
72
+    if (temp.compare("menu") == 0)
73
+        menu = true;
74
+
75
+    if (!console) {
76
+        getConsole().setVisible(false);
77
+        if (menu)
78
+            getMenu().setVisible(true);
79
+        getOpenRaider().frame();
80
+        getOpenRaider().frame(); // Double buffered
81
+    }
82
+
83
+    getRender().screenShot(filename.c_str());
84
+
85
+    if (!console) {
86
+        getConsole().setVisible(true);
87
+        if (menu)
88
+            getMenu().setVisible(false);
89
+    }
90
+
91
+    getConsole() << "Screenshot stored..." << Console::endl;
92
+    return 0;
93
+}
94
+
95
+// --------------------------------------
96
+
97
+std::string CommandQuit::name() {
98
+    return "quit";
99
+}
100
+
101
+std::string CommandQuit::brief() {
102
+    return "exit OpenRaider";
103
+}
104
+
105
+int CommandQuit::execute(std::istream& args) {
106
+    exit(0);
107
+    return 0;
108
+}
109
+

+ 63
- 0
src/commands/CommandGame.cpp Целия файл

@@ -0,0 +1,63 @@
1
+/*!
2
+ * \file src/commands/CommandGame.cpp
3
+ * \brief Game meta-commands
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "Game.h"
11
+#include "OpenRaider.h"
12
+#include "World.h"
13
+#include "commands/CommandGame.h"
14
+
15
+std::string CommandPos::name() {
16
+    return "pos";
17
+}
18
+
19
+std::string CommandPos::brief() {
20
+    return "Print position info";
21
+}
22
+
23
+int CommandPos::execute(std::istream& args) {
24
+    if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
25
+        getConsole() << "Use pos command interactively!" << Console::endl;
26
+        return -1;
27
+    }
28
+
29
+    getGame().getLara().print();
30
+    return 0;
31
+}
32
+
33
+// --------------------------------------
34
+
35
+std::string CommandViewmodel::name() {
36
+    return "viewmodel";
37
+}
38
+
39
+std::string CommandViewmodel::brief() {
40
+    return "INT - Change Laras model";
41
+}
42
+
43
+int CommandViewmodel::execute(std::istream& args) {
44
+    if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
45
+        getConsole() << "Use viewmodel command interactively!" << Console::endl;
46
+        return -1;
47
+    }
48
+
49
+    //! \fixme Validate input
50
+
51
+    std::string s;
52
+    args >> s;
53
+    unsigned int n = atoi(s.c_str());
54
+
55
+    if (n < getWorld().sizeSkeletalModel()) {
56
+        getGame().getLara().setSkeletalModel(n);
57
+        return 0;
58
+    } else {
59
+        getConsole() << "Invalid SkeletalModel index!" << Console::endl;
60
+        return -2;
61
+    }
62
+}
63
+

+ 53
- 0
src/commands/CommandMove.cpp Целия файл

@@ -0,0 +1,53 @@
1
+/*!
2
+ * \file src/commands/CommandMove.cpp
3
+ * \brief Move command
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "Game.h"
11
+#include "OpenRaider.h"
12
+#include "commands/CommandMove.h"
13
+
14
+std::string CommandMove::name() {
15
+    return "move";
16
+}
17
+
18
+std::string CommandMove::brief() {
19
+    return "[walk|fly|noclip]";
20
+}
21
+
22
+void CommandMove::printHelp() {
23
+    getConsole() << "move-Command Usage:" << Console::endl;
24
+    getConsole() << "  move COMMAND" << Console::endl;
25
+    getConsole() << "Where COMMAND is one of the following:" << Console::endl;
26
+    getConsole() << "  walk" << Console::endl;
27
+    getConsole() << "  fly" << Console::endl;
28
+    getConsole() << "  noclip" << Console::endl;
29
+}
30
+
31
+int CommandMove::execute(std::istream& args) {
32
+    if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
33
+        getConsole() << "Use move command interactively!" << Console::endl;
34
+        return -1;
35
+    }
36
+
37
+    std::string s;
38
+    args >> s;
39
+    if (s.compare("walk") == 0) {
40
+        getGame().getLara().setMoveType(Entity::MoveTypeWalk);
41
+    } else if (s.compare("fly") == 0) {
42
+        getGame().getLara().setMoveType(Entity::MoveTypeFly);
43
+    } else if (s.compare("noclip") == 0) {
44
+        getGame().getLara().setMoveType(Entity::MoveTypeNoClipping);
45
+    } else {
46
+        getConsole() << "Invalid use of move command (" << s << ")!" << Console::endl;
47
+        return -2;
48
+    }
49
+
50
+    getConsole() << s  << "ing" << Console::endl;
51
+    return 0;
52
+}
53
+

+ 119
- 0
src/commands/CommandRender.cpp Целия файл

@@ -0,0 +1,119 @@
1
+/*!
2
+ * \file src/commands/CommandRender.cpp
3
+ * \brief Renderer commands
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "Game.h"
11
+#include "Render.h"
12
+#include "commands/CommandRender.h"
13
+
14
+std::string CommandMode::name() {
15
+    return "mode";
16
+}
17
+
18
+std::string CommandMode::brief() {
19
+    return "MODE - Render mode";
20
+}
21
+
22
+void CommandMode::printHelp() {
23
+    getConsole() << "mode-Command Usage:" << Console::endl;
24
+    getConsole() << "  mode MODE" << Console::endl;
25
+    getConsole() << "Where MODE is one of the following:" << Console::endl;
26
+    getConsole() << "  wireframe" << Console::endl;
27
+    getConsole() << "  solid" << Console::endl;
28
+    getConsole() << "  texture" << Console::endl;
29
+    getConsole() << "  vertexlight" << Console::endl;
30
+    getConsole() << "  titlescreen" << Console::endl;
31
+
32
+}
33
+
34
+int CommandMode::execute(std::istream& args) {
35
+    if (!getGame().isLoaded()) {
36
+        getConsole() << "Load a level to set the mode!" << Console::endl;
37
+        return -1;
38
+    }
39
+
40
+    std::string s;
41
+    args >> s;
42
+
43
+    if (s.compare("wireframe") == 0) {
44
+        getRender().setMode(Render::modeWireframe);
45
+        getConsole() << "Wireframe mode" << Console::endl;
46
+    } else if (s.compare("solid") == 0) {
47
+        getRender().setMode(Render::modeSolid);
48
+        getConsole() << "Solid mode" << Console::endl;
49
+    } else if (s.compare("texture") == 0) {
50
+        getRender().setMode(Render::modeTexture);
51
+        getConsole() << "Texture mode" << Console::endl;
52
+    } else if (s.compare("vertexlight") == 0) {
53
+        getRender().setMode(Render::modeVertexLight);
54
+        getConsole() << "Vertexlight mode" << Console::endl;
55
+    } else if (s.compare("titlescreen") == 0) {
56
+        getRender().setMode(Render::modeLoadScreen);
57
+        getConsole() << "Titlescreen mode" << Console::endl;
58
+    } else {
59
+        getConsole() << "Invalid use of mode command (" << s << ")!" << Console::endl;
60
+        return -2;
61
+    }
62
+
63
+    return 0;
64
+}
65
+
66
+// --------------------------------------
67
+
68
+std::string CommandFog::name() {
69
+    return "fog";
70
+}
71
+
72
+std::string CommandFog::brief() {
73
+    return "BOOL - GL Fog";
74
+}
75
+
76
+int CommandFog::execute(std::istream& args) {
77
+    bool b;
78
+    args >> b;
79
+    if (!args) {
80
+        getConsole() << "Pass BOOL to fog command!" << Console::endl;
81
+        return -1;
82
+    }
83
+
84
+    if (b)
85
+        getRender().setFlags(Render::fFog);
86
+    else
87
+        getRender().clearFlags(Render::fFog);
88
+
89
+    getConsole() << "Fog is now " << (b ? "on" : "off") << Console::endl;
90
+    return 0;
91
+}
92
+
93
+// --------------------------------------
94
+
95
+std::string CommandLight::name() {
96
+    return "light";
97
+}
98
+
99
+std::string CommandLight::brief() {
100
+    return "BOOL - GL Lights";
101
+}
102
+
103
+int CommandLight::execute(std::istream& args) {
104
+    bool b;
105
+    args >> b;
106
+    if (!args) {
107
+        getConsole() << "Pass BOOL to light command!" << Console::endl;
108
+        return -1;
109
+    }
110
+
111
+    if (b)
112
+        getRender().setFlags(Render::fGL_Lights);
113
+    else
114
+        getRender().clearFlags(Render::fGL_Lights);
115
+
116
+    getConsole() << "GL-Lights are now " << (b ? "on" : "off") << Console::endl;
117
+    return 0;
118
+}
119
+

+ 168
- 0
src/commands/CommandSet.cpp Целия файл

@@ -0,0 +1,168 @@
1
+/*!
2
+ * \file src/commands/CommandSet.cpp
3
+ * \brief Set command
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Camera.h"
10
+#include "Console.h"
11
+#include "Font.h"
12
+#include "OpenRaider.h"
13
+#include "Sound.h"
14
+#include "Window.h"
15
+#include "utils/strings.h"
16
+#include "commands/CommandSet.h"
17
+
18
+std::string CommandSet::name() {
19
+    return "set";
20
+}
21
+
22
+std::string CommandSet::brief() {
23
+    return "set a parameter";
24
+}
25
+
26
+void CommandSet::printHelp() {
27
+    getConsole() << "set-Command Usage:" << Console::endl;
28
+    getConsole() << "  set VAR VAL" << Console::endl;
29
+    getConsole() << "Available Variables:" << Console::endl;
30
+    getConsole() << "  basedir    STRING" << Console::endl;
31
+    getConsole() << "  pakdir     STRING" << Console::endl;
32
+    getConsole() << "  audiodir   STRING" << Console::endl;
33
+    getConsole() << "  datadir    STRING" << Console::endl;
34
+    getConsole() << "  font       STRING" << Console::endl;
35
+    getConsole() << "  size       INT INT" << Console::endl;
36
+    getConsole() << "  fullscreen BOOL" << Console::endl;
37
+    getConsole() << "  audio      BOOL" << Console::endl;
38
+    getConsole() << "  volume     BOOL" << Console::endl;
39
+    getConsole() << "  mouse_x    FLOAT" << Console::endl;
40
+    getConsole() << "  mouse_y    FLOAT" << Console::endl;
41
+    getConsole() << "  fps        BOOL" << Console::endl;
42
+    getConsole() << "Enclose STRINGs with \"\"!" << Console::endl;
43
+}
44
+
45
+namespace {
46
+    char *expandDirectoryNames(const char *s) {
47
+        assert(s != NULL);
48
+        assert(s[0] != '\0');
49
+
50
+        char *result = bufferString("%s", s);
51
+
52
+        if (getOpenRaider().mPakDir != NULL) {
53
+            char *tmp = stringReplace(s, "$(pakdir)", getOpenRaider().mPakDir);
54
+            delete [] result;
55
+            result = tmp;
56
+        }
57
+
58
+        if (getOpenRaider().mAudioDir != NULL) {
59
+            char *tmp = stringReplace(s, "$(audiodir)", getOpenRaider().mAudioDir);
60
+            delete [] result;
61
+            result = tmp;
62
+        }
63
+
64
+        if (getOpenRaider().mDataDir != NULL) {
65
+            char *tmp = stringReplace(s, "$(datadir)", getOpenRaider().mDataDir);
66
+            delete [] result;
67
+            result = tmp;
68
+        }
69
+
70
+        if (getOpenRaider().mBaseDir != NULL) {
71
+            char *tmp = stringReplace(result, "$(basedir)", getOpenRaider().mBaseDir);
72
+            delete [] result;
73
+            result = tmp;
74
+        }
75
+
76
+        return result;
77
+    }
78
+}
79
+
80
+#define CHANGE_DIR_WITH_EXPANSION(a) do {     \
81
+    std::string temp;                         \
82
+    args >> temp;                             \
83
+    const char *value = temp.c_str();         \
84
+    char *quotes = stringRemoveQuotes(value); \
85
+    char *tmp = expandDirectoryNames(quotes); \
86
+    a = fullPath(tmp, 0);                     \
87
+    delete [] tmp;                            \
88
+    delete [] quotes;                         \
89
+} while(false)
90
+
91
+int CommandSet::execute(std::istream& args) {
92
+    std::string var;
93
+    args >> var;
94
+
95
+    if (var.compare("size") == 0) {
96
+        unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;
97
+        if (!(args >> w >> h)) {
98
+            getConsole() << "set-size-Error: Invalid value(s)" << Console::endl;
99
+            return -2;
100
+        }
101
+        getWindow().setSize(w, h);
102
+    } else if (var.compare("fullscreen") == 0) {
103
+        bool fullscreen = false;
104
+        if (!(args >> fullscreen)) {
105
+            getConsole() << "set-fullscreen-Error: Invalid value" << Console::endl;
106
+            return -3;
107
+        }
108
+        getWindow().setFullscreen(fullscreen);
109
+    } else if (var.compare("audio") == 0) {
110
+        bool audio = false;
111
+        if (!(args >> audio)) {
112
+            getConsole() << "set-audio-Error: Invalid value" << Console::endl;
113
+            return -4;
114
+        }
115
+        getSound().setEnabled(audio);
116
+    } else if (var.compare("volume") == 0) {
117
+        float vol = 1.0f;
118
+        if (!(args >> vol)) {
119
+            getConsole() << "set-volume-Error: Invalid value" << Console::endl;
120
+            return -5;
121
+        }
122
+        getSound().setVolume(vol);
123
+    } else if (var.compare("mouse_x") == 0) {
124
+        float sense = 1.0f;
125
+        if (!(args >> sense)) {
126
+            getConsole() << "set-mouse_x-Error: Invalid value" << Console::endl;
127
+            return -6;
128
+        }
129
+        getCamera().setSensitivityX(OR_DEG_TO_RAD(sense));
130
+    } else if (var.compare("mouse_y") == 0) {
131
+        float sense = 1.0f;
132
+        if (!(args >> sense)) {
133
+            getConsole() << "set-mouse_y-Error: Invalid value" << Console::endl;
134
+            return -7;
135
+        }
136
+        getCamera().setSensitivityY(OR_DEG_TO_RAD(sense));
137
+    } else if (var.compare("fps") == 0) {
138
+        bool fps = false;
139
+        if (!(args >> fps)) {
140
+            getConsole() << "set-fps-Error: Invalid value" << Console::endl;
141
+            return -8;
142
+        }
143
+        getOpenRaider().mFPS = fps;
144
+    } else if (var.compare("basedir") == 0) {
145
+        CHANGE_DIR_WITH_EXPANSION(getOpenRaider().mBaseDir);
146
+    } else if (var.compare("pakdir") == 0) {
147
+        CHANGE_DIR_WITH_EXPANSION(getOpenRaider().mPakDir);
148
+    } else if (var.compare("audiodir") == 0) {
149
+        CHANGE_DIR_WITH_EXPANSION(getOpenRaider().mAudioDir);
150
+    } else if (var.compare("datadir") == 0) {
151
+        CHANGE_DIR_WITH_EXPANSION(getOpenRaider().mDataDir);
152
+    } else if (var.compare("font") == 0) {
153
+        std::string temp;
154
+        args >> temp;
155
+        const char *value = temp.c_str();
156
+        char *quotes = stringReplace(value, "\"", "");
157
+        char *tmp = expandDirectoryNames(quotes);
158
+        getFont().setFont(tmp);
159
+        delete [] tmp;
160
+        delete [] quotes;
161
+    } else {
162
+        getConsole() << "set-Error: Unknown variable (" << var.c_str() << ")" << Console::endl;
163
+        return -1;
164
+    }
165
+
166
+    return 0;
167
+}
168
+

+ 42
- 0
src/commands/CommandSound.cpp Целия файл

@@ -0,0 +1,42 @@
1
+/*!
2
+ * \file src/commands/CommandSound.cpp
3
+ * \brief Sound command
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Console.h"
10
+#include "Game.h"
11
+#include "OpenRaider.h"
12
+#include "Sound.h"
13
+#include "commands/CommandSound.h"
14
+
15
+std::string CommandSound::name() {
16
+    return "sound";
17
+}
18
+
19
+std::string CommandSound::brief() {
20
+    return "INT - Test play sound";
21
+}
22
+
23
+void CommandSound::printHelp() {
24
+    getConsole() << "sound-Command Usage:" << Console::endl;
25
+    getConsole() << "sound-Command Usage:" << Console::endl;
26
+    getConsole() << "  sound INT" << Console::endl;
27
+    getConsole() << "Where INT is a valid sound ID integer" << Console::endl;
28
+}
29
+
30
+int CommandSound::execute(std::istream& args) {
31
+    if ((!getOpenRaider().mRunning) || (!getGame().isLoaded())) {
32
+        getConsole() << "Use sound command interactively!" << Console::endl;
33
+        return -1;
34
+    }
35
+
36
+    std::string s;
37
+    args >> s;
38
+
39
+    getSound().play(atoi(s.c_str()));
40
+    return 0;
41
+}
42
+

+ 161
- 0
src/commands/OldCommands.cpp Целия файл

@@ -0,0 +1,161 @@
1
+/*!
2
+ * \file src/Command.cpp
3
+ * \brief OpenRaider command implementation
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include <fstream>
9
+#include <sstream>
10
+
11
+#include "global.h"
12
+#include "Camera.h"
13
+#include "Console.h"
14
+#include "Entity.h"
15
+#include "Font.h"
16
+#include "Game.h"
17
+#include "math/math.h"
18
+#include "Menu.h"
19
+#include "Render.h"
20
+#include "Sound.h"
21
+#include "TombRaider.h"
22
+#include "Window.h"
23
+#include "World.h"
24
+#include "utils/strings.h"
25
+#include "utils/time.h"
26
+#include "OpenRaider.h"
27
+
28
+int OpenRaider::command(std::string c) {
29
+    // Remove comment, if any
30
+    size_t comment = c.find_first_of('#');
31
+    if (comment != std::string::npos)
32
+        c.erase(comment);
33
+
34
+    // Execute command
35
+    std::stringstream command(c);
36
+    std::string cmd;
37
+    command >> cmd;
38
+    command >> std::boolalpha >> std::ws;
39
+
40
+    if (cmd.length() == 0)
41
+        return 0;
42
+
43
+    if (cmd.compare("help") == 0) {
44
+        std::string tmp;
45
+        if (!(command >> tmp)) {
46
+/*
47
+            getConsole() << "  ralpha    - BOOL - Room Alpha" << Console::endl;
48
+            getConsole() << "  upf       - BOOL - Update Room List Per Frame" << Console::endl;
49
+            getConsole() << "  entmodel  - BOOL" << Console::endl;
50
+            getConsole() << "  ponytail  - BOOL" << Console::endl;
51
+            getConsole() << "  pigtail   - BOOL" << Console::endl;
52
+            getConsole() << "  ponypos   - FLOAT FLOAT FLOAT FLOAT - x y z angle" << Console::endl;
53
+*/
54
+        } else {
55
+            return help(tmp);
56
+        }
57
+/*
58
+    } else if (cmd.compare("ralpha") == 0) {
59
+        if (args->size() > 0) {
60
+            bool b;
61
+            if (readBool(args->at(0), &b) < 0) {
62
+                getConsole().print("Pass BOOL to ralpha command!");
63
+                return -24;
64
+            }
65
+            if (b)
66
+                getRender().setFlags(Render::fRoomAlpha);
67
+            else
68
+                getRender().clearFlags(Render::fRoomAlpha);
69
+            getConsole().print("Room Alpha is now %s", b ? "on" : "off");
70
+        } else {
71
+            getConsole().print("Invalid use of ralpha-command!");
72
+            return -25;
73
+        }
74
+    } else if (cmd.compare("upf") == 0) {
75
+        if (args->size() > 0) {
76
+            bool b;
77
+            if (readBool(args->at(0), &b) < 0) {
78
+                getConsole().print("Pass BOOL to upf command!");
79
+                return -30;
80
+            }
81
+            if (b)
82
+                getRender().setFlags(Render::fUpdateRoomListPerFrame);
83
+            else
84
+                getRender().clearFlags(Render::fUpdateRoomListPerFrame);
85
+            getConsole().print("URLPF is now %s", b ? "on" : "off");
86
+        } else {
87
+            getConsole().print("Invalid use of upf-command!");
88
+            return -31;
89
+        }
90
+    } else if (cmd.compare("entmodel") == 0) {
91
+        if (args->size() > 0) {
92
+            bool b;
93
+            if (readBool(args->at(0), &b) < 0) {
94
+                getConsole().print("Pass BOOL to entmodel command!");
95
+                return -38;
96
+            }
97
+            if (b)
98
+                getRender().setFlags(Render::fEntityModels);
99
+            else
100
+                getRender().clearFlags(Render::fEntityModels);
101
+            getConsole().print("Entmodels are now %s", b ? "on" : "off");
102
+        } else {
103
+            getConsole().print("Invalid use of entmodel-command!");
104
+            return -39;
105
+        }
106
+    } else if (cmd.compare("ponytail") == 0) {
107
+        if (args->size() > 0) {
108
+            bool b;
109
+            if (readBool(args->at(0), &b) < 0) {
110
+                getConsole().print("Pass BOOL to ponytail command!");
111
+                return -44;
112
+            }
113
+            if (b)
114
+                getRender().setFlags(Render::fRenderPonytail);
115
+            else
116
+                getRender().clearFlags(Render::fRenderPonytail);
117
+            getConsole().print("Ponytail is now %s", b ? "on" : "off");
118
+        } else {
119
+            getConsole().print("Invalid use of ponytail-command!");
120
+            return -45;
121
+        }
122
+    } else if (cmd.compare("pigtail") == 0) {
123
+        if ((!mRunning) || (!getGame().isLoaded())) {
124
+            getConsole().print("Use pigtail command interactively!");
125
+            return -999;
126
+        }
127
+        if (args->size() > 0) {
128
+            bool b;
129
+            if (readBool(args->at(0), &b) < 0) {
130
+                getConsole().print("Pass BOOL to pigtail command!");
131
+                return -46;
132
+            }
133
+            SkeletalModel &tmp = getGame().getLara().getModel();
134
+            tmp.setPigTail(b);
135
+            getConsole().print("Pigtail is now %s", b ? "on" : "off");
136
+        } else {
137
+            getConsole().print("Invalid use of pigtail-command!");
138
+            return -47;
139
+        }
140
+    } else if (cmd.compare("ponypos") == 0) {
141
+        if ((!mRunning) || (!getGame().isLoaded())) {
142
+            getConsole().print("Use ponypos command interactively!");
143
+            return -999;
144
+        }
145
+        if (args->size() > 3) {
146
+            SkeletalModel &tmp = getGame().getLara().getModel();
147
+            tmp.setPonyPos((float)atof(args->at(0)), (float)atof(args->at(1)),
148
+                    (float)atof(args->at(2)), (float)atof(args->at(3)));
149
+        } else {
150
+            getConsole().print("Invalid use of ponypos-command!");
151
+            return -48;
152
+        }
153
+*/
154
+    } else {
155
+        getConsole() << "Unknown command: " << cmd.c_str() << Console::endl;
156
+        return -50;
157
+    }
158
+
159
+    return 0;
160
+}
161
+

Loading…
Отказ
Запис