Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
ConsoleCmd.cpp
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2013-2020 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "Application.h"
23#include "Actor.h"
24#include "ActorManager.h"
25#include "CameraManager.h"
26#include "Character.h"
27#include "Console.h"
28#include "GameContext.h"
29#include "GfxScene.h"
30#include "GUIManager.h"
31#include "IGfxWater.h"
32#include "Language.h"
33#include "Network.h"
34#include "OverlayWrapper.h"
35#include "RoRnet.h"
36#include "RoRVersion.h"
37#include "ScriptEngine.h"
38#include "Terrain.h"
40#include "Utils.h"
41
42#include <algorithm>
43#include <Ogre.h>
44#include <fmt/core.h>
45
47
48using namespace RoR;
49
52
53// -------------------------------------------------------------------------------------
54// Builtin console commands.
55
58
60{
61public:
62 GravityCmd(): ConsoleCmd("gravity", "[<number> or <constant>]", _L("Get or set terrain gravity. Constants: earth/moon/mars/jupiter.")) {}
63
64 void Run(Ogre::StringVector const& args) override
65 {
66 if (!this->CheckAppState(AppState::SIMULATION))
67 return;
68
69 Str<200> reply;
70 if (args.size() == 1)
71 {
72 reply << _L("Current gravity is: ") << App::GetGameContext()->GetTerrain()->getGravity();
73 }
74 else
75 {
76 if (args[1] == "earth") { App::GetGameContext()->GetTerrain()->setGravity(DEFAULT_GRAVITY); }
77 else if (args[1] == "moon") { App::GetGameContext()->GetTerrain()->setGravity(-1.62f); }
78 else if (args[1] == "mars") { App::GetGameContext()->GetTerrain()->setGravity(-3.711f); }
79 else if (args[1] == "jupiter") { App::GetGameContext()->GetTerrain()->setGravity(-24.8f); }
80 else { App::GetGameContext()->GetTerrain()->setGravity(PARSEREAL(args[1])); }
81
82 reply << _L("Gravity set to: ") << App::GetGameContext()->GetTerrain()->getGravity();
83 }
84
86 }
87};
88
90{
91public:
92 WaterlevelCmd(): ConsoleCmd("waterlevel", "[<number>]", _L("Get or set water level.")) {}
93
94 void Run(Ogre::StringVector const& args) override
95 {
96 if (!this->CheckAppState(AppState::SIMULATION))
97 return;
98
99 Str<200> reply;
100 Console::MessageType reply_type;
101 reply << m_name << ": ";
102 if (!App::GetGameContext()->GetTerrain()->getWater())
103 {
105 reply << _L("This terrain does not have water.");
106 }
107 else
108 {
110 if (args.size() > 1)
111 {
112 auto water = App::GetGameContext()->GetTerrain()->getWater();
113 float height = (args[1] == "default") ? App::GetGameContext()->GetTerrain()->getWaterHeight() : PARSEREAL(args[1]);
114 water->SetStaticWaterHeight(height);
115 }
116 reply << _L ("Water level set to: ") << App::GetGameContext()->GetTerrain()->getWater()->GetStaticWaterHeight();
117 }
119 }
120};
121
123{
124public:
125 TerrainheightCmd(): ConsoleCmd("terrainheight", "[]", _L("Get elevation of terrain at current position")) {}
126
127 void Run(Ogre::StringVector const& args) override
128 {
129 if (!this->CheckAppState(AppState::SIMULATION))
130 return;
131
132 ROR_ASSERT(App::GetGameContext()->GetTerrain());
133
134 Str<200> reply;
135 reply << m_name << ": ";
137 Ogre::Vector3 pos;
139 if (actor)
140 {
141 pos = actor->getPosition();
142
143 }
144 else
145 {
146 ROR_ASSERT(App::GetGameContext()->GetPlayerCharacter());
148 }
149 reply << _L("Terrain height at position: ")
150 << "x: " << pos.x << " z: " << pos.z << " = "
151 << App::GetGameContext()->GetTerrain()->getHeightAt(pos.x, pos.z);
153 }
154};
155
157{
158public:
159 SpawnobjectCmd(): ConsoleCmd("spawnobject", "<odef name>", _L("spawnobject - spawn a object at the player position")) {}
160
161 void Run(Ogre::StringVector const& args) override
162 {
163 if (!this->CheckAppState(AppState::SIMULATION))
164 return;
165
166 ROR_ASSERT(App::GetGameContext()->GetPlayerCharacter());
167 ROR_ASSERT(App::GetGameContext()->GetTerrain());
168
169 Str<200> reply;
170 reply << m_name << ": ";
171 Console::MessageType reply_type;
172
173 try
174 {
175 if (args.size() == 1)
176 {
178 reply << _L("Missing parameter: ") << m_usage;
179 }
180 else
181 {
182 Ogre::Vector3 pos = App::GetGameContext()->GetPlayerCharacter()->getPosition();
183 if (App::GetGameContext()->GetTerrain()->getObjectManager()->LoadTerrainObject(args[1], pos, Ogre::Vector3::ZERO, "Console", ""))
184 {
186 reply << _L("Spawned object at position: ") << "x: " << pos.x << " z: " << pos.z;
187 }
188 else
189 {
191 reply << _L("Could not spawn object");
192 }
193 }
194 }
195 catch (std::exception& e)
196 {
198 reply << e.what();
199 }
201 }
202};
203
204class LogCmd: public ConsoleCmd
205{
206public:
207 LogCmd(): ConsoleCmd("log", "[]", _L("log - toggles log output on the console")) {}
208
209 void Run(Ogre::StringVector const& args) override
210 {
211 Str<200> reply;
212 reply << m_name << ": ";
214
215 // switch to console logging
216 bool now_logging = !App::diag_log_console_echo->getBool();
217 const char* msg = (now_logging) ? " logging to console enabled" : " logging to console disabled";
218 reply << _L(msg);
220
222 }
223};
224
225class VerCmd: public ConsoleCmd
226{
227public:
228 VerCmd(): ConsoleCmd("ver", "[]", _L("ver - shows the Rigs of Rods version")) {}
229
230 void Run(Ogre::StringVector const& args) override
231 {
232 Str<200> reply;
233 reply << m_name << ": ";
235
236 reply << "Rigs of Rods " << ROR_VERSION_STRING
237 << " (" << RORNET_VERSION << ") ["
238 << ROR_BUILD_DATE << ", " << ROR_BUILD_TIME << "]";
239
241 }
242};
243
244class PosCmd: public ConsoleCmd
245{
246public:
247 PosCmd(): ConsoleCmd("pos", "[]", _L("pos - outputs the current position")) {}
248
249 void Run(Ogre::StringVector const& args) override
250 {
251 if (!this->CheckAppState(AppState::SIMULATION))
252 return;
253
254 Str<200> reply;
255 reply << m_name << ": ";
257
259 if (!b && App::GetGameContext()->GetPlayerCharacter())
260 {
261 Ogre::Vector3 pos = App::GetGameContext()->GetPlayerCharacter()->getPosition();
262 reply << _L("Character position: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
263 }
264 else if (b)
265 {
266 Ogre::Vector3 pos = b->getPosition();
267 reply << _L("Vehicle position: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
268 }
269
271 }
272};
273
274class GotoCmd: public ConsoleCmd
275{
276public:
277 GotoCmd(): ConsoleCmd("goto", "<x> <y> <z>", _L("goto <x> <y> <z> - jumps to the mentioned position")) {}
278
279 void Run(Ogre::StringVector const& args) override
280 {
281 if (!this->CheckAppState(AppState::SIMULATION))
282 return;
283
284 Str<200> reply;
285 reply << m_name << ": ";
286 Console::MessageType reply_type;
287
288 if (args.size() != 4)
289 {
290 reply_type = Console::CONSOLE_HELP;
291 reply <<_L("usage: goto x y z");
292 }
293 else
294 {
296 Ogre::Vector3 pos(PARSEREAL(args[1]), PARSEREAL(args[2]), PARSEREAL(args[3]));
297
299 if (!b && App::GetGameContext()->GetPlayerCharacter())
300 {
302 reply << _L("Character position set to: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
303 }
304 else if (b)
305 {
306 b->resetPosition(pos, false);
308 reply << _L("Vehicle position set to: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
309 }
310 }
311
313 }
314};
315
316
317class AsCmd: public ConsoleCmd
318{
319public:
320 AsCmd(): ConsoleCmd("as", "<code>", _L("Run AngelScript code snippet")) {}
321
322 void Run(Ogre::StringVector const& args) override
323 {
324 if (!this->CheckAppState(AppState::SIMULATION))
325 return;
326
327 Str<200> reply;
328 reply << m_name << ": ";
329 Console::MessageType reply_type;
330
331#ifdef USE_ANGELSCRIPT
332 // we want to notify any running scripts that we might change something (prevent cheating)
334
335 // Re-compose the code snippet
336 Str<1000> code;
337 for (int i = 1; i < args.size(); ++i)
338 {
339 code << " " << args[i];
340 }
341
342 // Echo the code back to console user.
344 reply << " >>> " << code.ToCStr();
346
347 // Run the code - will output script messages/AngelScript errors.
349#else
351 reply << _L("Scripting disabled in this build");
353#endif
354 }
355};
356
358{
359public:
360 SpeedOfSoundCmd(): ConsoleCmd("speedofsound", "[]", _L("speedofsound - outputs the current speed of sound")) {}
361
362 void Run(Ogre::StringVector const& args) override
363 {
364 if (!this->CheckAppState(AppState::SIMULATION))
365 return;
366
367 Str<200> reply;
368 reply << m_name << ": ";
370
372 if (sound_manager == nullptr)
373 {
374 reply << _L("unable to get sound manager");
375 }
376 else
377 {
378 reply << _L("Current speed of sound: ") << sound_manager->GetSpeedOfSound();
379 }
380
382 }
383};
384
385class QuitCmd: public ConsoleCmd
386{
387public:
388 QuitCmd(): ConsoleCmd("quit", "[]", _L("quit - exit Rigs of Rods")) {}
389
390 void Run(Ogre::StringVector const& args) override
391 {
393 }
394};
395
396class HelpCmd: public ConsoleCmd
397{
398public:
399 HelpCmd(): ConsoleCmd("help", "[]", _L("help - information on commands (this)")) {}
400
401 void Run(Ogre::StringVector const& args) override
402 {
404 Console::CONSOLE_TITLE, _L("Available commands:"));
405
406 Str<500> line;
407 for (auto& cmd_pair: App::GetConsole()->getCommands())
408 {
409 line.Clear() << cmd_pair.second->getName() << " "
410 << cmd_pair.second->GetUsage() << " - " << cmd_pair.second->GetDoc();
411
414 }
415
417 Console::CONSOLE_TITLE, _L("Tips:"));
419 Console::CONSOLE_HELP, _L("- use Arrow Up/Down Keys in the InputBox to reuse old messages"));
420 }
421};
422
424{
425public:
426 LoadScriptCmd() : ConsoleCmd("loadscript", "[filename]", _L("Runs an AngelScript file")) {}
427
428 void Run(Ogre::StringVector const& args) override
429 {
430 Str<200> reply;
431 reply << m_name << ": ";
432 Console::MessageType reply_type;
433
434#ifdef USE_ANGELSCRIPT
435 if (args.size() == 1)
436 {
438 reply << _L("Missing parameter: ") << m_usage;
439 }
440 else
441 {
442 ScriptUnitID_t id = App::GetScriptEngine()->loadScript(args[1], ScriptCategory::CUSTOM);
443 if (id == SCRIPTUNITID_INVALID)
444 {
446 reply << _L("Failed to load script. See 'Angelscript.log' or use console command `log` and retry.");
447 }
448 else
449 {
451 reply << fmt::format(_L("Script '{}' running with ID '{}'"), args[1], id);
452 }
453 }
454#else
456 reply << _L("Scripting disabled in this build");
457#endif
458
460 }
461};
462
463// -------------------------------------------------------------------------------------
464// CVar (builtin) console commmands
465
466class VarsCmd: public ConsoleCmd
467{
468public:
469 VarsCmd(): ConsoleCmd("vars", "[<expr> ...]", _L("Print cvars with one of <expr> in name")) {}
470
471 void Run(Ogre::StringVector const& args) override
472 {
473 for (auto& pair: App::GetConsole()->getCVars())
474 {
475 bool match = args.size() == 1;
476 for (size_t i = 1; i < args.size(); ++i)
477 {
478 if (pair.first.find(args[i]) != std::string::npos)
479 {
480 match = true;
481 break;
482 }
483 }
484
485 if (match)
486 {
487 Str<200> reply;
488 reply << "vars: " << pair.first << "=" << pair.second->getStr() << " (";
489
490 if (pair.second->hasFlag(CVAR_TYPE_BOOL)) { reply << "bool"; }
491 else if (pair.second->hasFlag(CVAR_TYPE_INT)) { reply << "int"; }
492 else if (pair.second->hasFlag(CVAR_TYPE_FLOAT)) { reply << "float"; }
493 else { reply << "string"; }
494
495 if (pair.second->hasFlag(CVAR_ARCHIVE)) { reply << ", archive"; }
496 if (pair.second->hasFlag(CVAR_NO_LOG)) { reply << ", no log"; }
497
498 reply << ")";
500 }
501 }
502 }
503};
504
505class SetCmd: public ConsoleCmd
506{
507public:
508 SetCmd(): ConsoleCmd("set", "<cvar> [<flags>] [<value>]", _L("Get or set value of existing CVar")) {}
509
510 void Run(Ogre::StringVector const& args) override
511 {
512 Str<200> reply;
513 reply << m_name << ": ";
515
516 if (args.size() == 1)
517 {
518 reply_type = Console::CONSOLE_HELP;
519 reply << this->GetUsage() << " - " << this->GetDoc();
520 }
521 else
522 {
523 CVar* cvar = App::GetConsole()->cVarFind(args[1]);
524 if (cvar)
525 {
526 if (args.size() > 2)
527 {
528 App::GetConsole()->cVarAssign(cvar, args[2]);
529 }
531 reply << cvar->getName() << " = " << cvar->getStr();
532 }
533 else
534 {
536 reply << _L("No such CVar: ") << args[1];
537 }
538 }
539
541 }
542};
543
544class SetCVarCmd: public ConsoleCmd // Generic
545{
546public:
547 SetCVarCmd(std::string const& name, std::string const& usage, std::string const& doc, int flag):
548 ConsoleCmd(name, usage, doc), m_cvar_flag(flag)
549 {}
550
551 void Run(Ogre::StringVector const& args) override
552 {
553 Str<200> reply;
554 reply << m_name << ": ";
555 Console::MessageType reply_type;
556
557 if (args.size() == 1)
558 {
559 reply_type = Console::CONSOLE_HELP;
560 reply << this->GetUsage() << " - " << this->GetDoc() << "Switches: --autoapply/--allowstore/--autostore";
561 }
562 else
563 {
564 int flags = m_cvar_flag;
565 size_t i;
566 for (i = 1; i < args.size(); ++i)
567 {
568 if (args[i] == "--archive") { flags |= CVAR_ARCHIVE; }
569 else break; // Exit loop on first non-switch arg!
570 }
571
572 if (i == args.size()) // Only switches but no cvar?
573 {
574 reply_type = Console::CONSOLE_HELP;
575 reply << this->GetUsage() << " - " << this->GetDoc() << "Switches: --archive";
576 }
577 else
578 {
579 CVar* cvar = App::GetConsole()->cVarGet(args[i], flags);
580 if (args.size() > (i+1))
581 {
582 App::GetConsole()->cVarAssign(cvar, args[i+1]);
583 }
585 reply << cvar->getName() << " = " << cvar->getStr();
586 }
587 }
588
590 }
591private:
593};
594
596{
597public:
598 SetstringCmd(): SetCVarCmd("setstring", "<cvar> [<value>]", _L("Set or create string CVar"), /*flag=*/0) {}
599};
600
602{
603public:
604 SetboolCmd(): SetCVarCmd("setbool", "<cvar> [<value>]", _L("Set or create boolean CVar"), CVAR_TYPE_BOOL) {}
605};
606
608{
609public:
610 SetintCmd(): SetCVarCmd("setint", "<cvar> [<value>]", _L("Set or create integer CVar"), CVAR_TYPE_INT) {}
611};
612
614{
615public:
616 SetfloatCmd(): SetCVarCmd("setfloat", "<cvar> [<value>]", _L("Set or create real-number CVar"), CVAR_TYPE_FLOAT) {}
617};
618
619class ClearCmd: public ConsoleCmd
620{
621public:
622 ClearCmd(): ConsoleCmd("clear", "[<type>]", _L("Clear console history. Types: all/info/net/chat/terrn/actor/script")) {}
623
624 void Run(Ogre::StringVector const& args) override
625 {
626 if (args.size() < 2 || args[1] == "all")
627 {
629 lock.messages.clear();
630 }
631 else
632 {
633 // Create a predicate function
634 std::function<bool(Console::Message const& m)> filter_fn;
635 if (args[1] == "chat")
636 {
637 filter_fn = [](Console::Message const& m){ return m.cm_type == Console::CONSOLE_SYSTEM_NETCHAT; };
638 }
639 else if (args[1] == "net") // Chat and user notifications
640 {
641 filter_fn = [](Console::Message const& m){ return m.cm_net_userid != 0; };
642 }
643 else
644 {
646 bool valid = false;
647 if (args[1] == "info") { area = Console::CONSOLE_MSGTYPE_INFO; valid = true; }
648 else if (args[1] == "terrn") { area = Console::CONSOLE_MSGTYPE_TERRN; valid = true; }
649 else if (args[1] == "actor") { area = Console::CONSOLE_MSGTYPE_ACTOR; valid = true; }
650 else if (args[1] == "script") { area = Console::CONSOLE_MSGTYPE_SCRIPT; valid = true; }
651
652 if (valid)
653 {
654 filter_fn = [area](Console::Message const& m) { return m.cm_area == area; };
655 }
656 else
657 {
659 fmt::format(_L("No such message type: {}"), args[1]));
660 }
661 }
662
664 // Shove unwanted entries to the end
665 auto erase_begin = std::remove_if(lock.messages.begin(), lock.messages.end(), filter_fn);
666 // Erase unwanted
667 lock.messages.erase(erase_begin, lock.messages.end());
668 }
669 }
670};
671
673
674// -------------------------------------------------------------------------------------
675// Console integration
676
678{
679 ConsoleCmd* cmd = nullptr;
680
681 // Classics
682 cmd = new GravityCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
683 cmd = new WaterlevelCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
684 cmd = new TerrainheightCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
685 cmd = new SpawnobjectCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
686 cmd = new LogCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
687 cmd = new VerCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
688 cmd = new PosCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
689 cmd = new GotoCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
690 cmd = new AsCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
691 cmd = new QuitCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
692 cmd = new HelpCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
693 // Additions
694 cmd = new ClearCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
695 cmd = new LoadScriptCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
696 cmd = new SpeedOfSoundCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
697 // CVars
698 cmd = new SetCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
699 cmd = new SetstringCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
700 cmd = new SetboolCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
701 cmd = new SetintCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
702 cmd = new SetfloatCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
703 cmd = new VarsCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
704}
705
706void Console::doCommand(std::string msg)
707{
708 if (msg[0] == '/' || msg[0] == '\\')
709 {
711 _L("Using slashes before commands are deprecated, you can now type command without any slashes"));
712 msg.erase(msg.begin());
713 }
714
715 if (msg[0] == '!')
716 {
717 // Server commands - pass through to multiplayer chat
718 App::GetNetwork()->BroadcastChatMsg(msg.c_str());
719 return;
720 }
721
722 Ogre::StringVector args = Ogre::StringUtil::split(msg, " ");
723
724 auto found = m_commands.find(args[0]);
725 if (found != m_commands.end())
726 {
727 found->second->Run(args);
728 return;
729 }
730
731 CVar* cvar = this->cVarFind(args[0]);
732 if (cvar)
733 {
734 Str<200> reply;
735 reply << cvar->getName() << " = " << cvar->getStr();
737 return;
738 }
739
740 Str<200> reply;
741 reply << _L("unknown command: ") << msg;
743}
744
745// -------------------------------------------------------------------------------------
746// Helpers
747
749{
750 if (App::app_state->getEnum<AppState>() == state)
751 return true;
752
753 Str<200> reply;
754 reply << m_name << ": ";
755 if (state == AppState::SIMULATION)
756 {
757 reply << _L("Only allowed when simulation is running");
758 }
759 else
760 {
761 reply << _L("Not allowed in current app state");
762 }
764 return false;
765}
766
767 // Currently unused: _L("Please enter a correct value. ")
768
Central state/object manager and communications hub.
#define ROR_ASSERT(_EXPR)
Definition Application.h:40
#define PARSEREAL(x)
Definition Application.h:59
#define _L
Game state manager and message-queue provider.
const char *const ROR_BUILD_DATE
const char *const ROR_VERSION_STRING
const char *const ROR_BUILD_TIME
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
Ogre::Vector3 getPosition()
Definition Actor.cpp:370
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
Definition Actor.h:429
void resetPosition(Ogre::Vector3 translation, bool setInitPosition)
Moves the actor to given world coords (pivot point is node 0).
Definition Actor.cpp:1351
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition CVar.h:53
std::string const & getName() const
Definition CVar.h:103
std::string const & getStr() const
Definition CVar.h:95
bool getBool() const
Definition CVar.h:98
void setVal(T val)
Definition CVar.h:72
void setPosition(Ogre::Vector3 position)
Definition Character.cpp:85
Ogre::Vector3 getPosition()
Definition Character.cpp:92
Base (abstract) console command.
Definition ConsoleCmd.h:38
std::string const & GetDoc() const
Definition ConsoleCmd.h:49
std::string const & GetUsage() const
Definition ConsoleCmd.h:48
std::string const & getName() const
Definition ConsoleCmd.h:47
std::string m_name
Definition ConsoleCmd.h:54
std::string m_usage
Definition ConsoleCmd.h:55
void cVarAssign(CVar *cvar, std::string const &value)
Parse value by cvar type.
Definition CVar.cpp:249
CommandPtrMap & getCommands()
Definition Console.h:134
CommandPtrMap m_commands
Definition Console.h:162
@ CONSOLE_MSGTYPE_ACTOR
Parsing/spawn/simulation messages for actors.
Definition Console.h:63
@ CONSOLE_MSGTYPE_SCRIPT
Messages sent from scripts.
Definition Console.h:62
@ CONSOLE_MSGTYPE_INFO
Generic message.
Definition Console.h:60
@ CONSOLE_MSGTYPE_TERRN
Parsing/spawn/simulation messages for terrain.
Definition Console.h:64
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
Definition Console.cpp:103
CVar * cVarFind(std::string const &input_name)
Find cvar by short/long name.
Definition CVar.cpp:267
@ CONSOLE_SYSTEM_ERROR
Definition Console.h:52
@ CONSOLE_SYSTEM_REPLY
Success.
Definition Console.h:54
@ CONSOLE_SYSTEM_NETCHAT
Definition Console.h:55
@ CONSOLE_TITLE
Definition Console.h:49
CVar * cVarGet(std::string const &input_name, int flags)
Get cvar by short/long name, or create new one using input as short name.
Definition CVar.cpp:295
CVarPtrMap & getCVars()
Definition Console.h:132
Character * GetPlayerCharacter()
const ActorPtr & GetPlayerActor()
const TerrainPtr & GetTerrain()
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
void BroadcastChatMsg(const char *msg)
Definition Network.cpp:838
ScriptUnitID_t loadScript(Ogre::String filename, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, std::string buffer="")
Loads a script.
ScriptRetCode_t executeString(Ogre::String command)
executes a string (useful for the console)
void triggerEvent(scriptEvents eventnum, int arg1=0, int arg2ex=0, int arg3ex=0, int arg4ex=0, std::string arg5ex="", std::string arg6ex="", std::string arg7ex="", std::string arg8ex="")
triggers an event; Not to be used by the end-user.
float GetSpeedOfSound() const
SoundManager * getSoundManager()
Wrapper for classic c-string (local buffer) Refresher: strlen() excludes '\0' terminator; strncat() A...
Definition Str.h:36
const char * ToCStr() const
Definition Str.h:46
Str & Clear()
Definition Str.h:54
void setGravity(float value)
Definition Terrain.cpp:490
float getWaterHeight() const
Definition Terrain.cpp:598
float getHeightAt(float x, float z)
Definition Terrain.cpp:512
Wavefield * getWater()
Definition Terrain.h:87
float getGravity() const
Definition Terrain.h:101
float GetStaticWaterHeight()
Returns static water level configured in 'terrn2'.
Definition Wavefield.cpp:75
void Run(Ogre::StringVector const &args) override
SetCVarCmd(std::string const &name, std::string const &usage, std::string const &doc, int flag)
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void Run(Ogre::StringVector const &args) override
void regBuiltinCommands()
Register builtin commands.
void doCommand(std::string msg)
Identify and execute any console line.
bool CheckAppState(AppState state)
@ CVAR_ARCHIVE
Will be written to RoR.cfg.
Definition CVar.h:41
@ CVAR_TYPE_INT
Definition CVar.h:39
@ CVAR_NO_LOG
Will not be written to RoR.log.
Definition CVar.h:42
@ CVAR_TYPE_FLOAT
Definition CVar.h:40
@ CVAR_TYPE_BOOL
Definition CVar.h:38
@ MSG_APP_SHUTDOWN_REQUESTED
Definition Application.h:86
static const float DEFAULT_GRAVITY
earth gravity
void TRIGGER_EVENT_ASYNC(scriptEvents type, int arg1, int arg2ex=0, int arg3ex=0, int arg4ex=0, std::string arg5ex="", std::string arg6ex="", std::string arg7ex="", std::string arg8ex="")
Asynchronously (via MSG_SIM_SCRIPT_EVENT_TRIGGERED) invoke script function eventCallbackEx(),...
SoundScriptManager * GetSoundScriptManager()
GameContext * GetGameContext()
CVar * app_state
Console * GetConsole()
ScriptEngine * GetScriptEngine()
Network * GetNetwork()
CVar * diag_log_console_echo
@ ASMANIP_CONSOLE_SNIPPET_EXECUTED
int ScriptUnitID_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
static const ScriptUnitID_t SCRIPTUNITID_INVALID
@ SE_ANGELSCRIPT_MANIPULATIONS
triggered when the user tries to dynamically use the scripting capabilities (prevent cheating) args: ...
@ SE_TRUCK_TELEPORT
triggered when the user teleports the truck, the argument refers to the actor ID of the vehicle
#define RORNET_VERSION
Definition RoRnet.h:35
MessageType cm_type
Definition Console.h:75
uint32_t cm_net_userid
Definition Console.h:77
MessageArea cm_area
Definition Console.h:74
std::vector< Message > & messages
Definition Console.h:91
Unified game event system - all requests and state changes are reported using a message.
Definition GameContext.h:52