RigsofRods
Soft-body Physics Simulation
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 "IWater.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"
39 #include "TerrainObjectManager.h"
40 #include "Utils.h"
41 
42 #include <algorithm>
43 #include <Ogre.h>
44 #include <fmt/core.h>
45 
47 
48 using namespace RoR;
49 
52 
53 // -------------------------------------------------------------------------------------
54 // Builtin console commands.
55 
58 
59 class GravityCmd: public ConsoleCmd
60 {
61 public:
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 {
91 public:
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  {
104  reply_type = Console::CONSOLE_SYSTEM_ERROR;
105  reply << _L("This terrain does not have water.");
106  }
107  else
108  {
109  reply_type = Console::CONSOLE_SYSTEM_REPLY;
110  if (args.size() > 1)
111  {
113  float height = (args[1] == "default") ? App::GetGameContext()->GetTerrain()->getWaterHeight() : PARSEREAL(args[1]);
114  water->SetStaticWaterHeight(height);
115  water->UpdateWater();
116  }
117  reply << _L ("Water level set to: ") << App::GetGameContext()->GetTerrain()->getWater()->GetStaticWaterHeight();
118  }
120  }
121 };
122 
124 {
125 public:
126  TerrainheightCmd(): ConsoleCmd("terrainheight", "[]", _L("Get elevation of terrain at current position")) {}
127 
128  void Run(Ogre::StringVector const& args) override
129  {
130  if (!this->CheckAppState(AppState::SIMULATION))
131  return;
132 
133  ROR_ASSERT(App::GetGameContext()->GetTerrain());
134 
135  Str<200> reply;
136  reply << m_name << ": ";
138  Ogre::Vector3 pos;
139  ActorPtr const actor = App::GetGameContext()->GetPlayerActor();
140  if (actor)
141  {
142  pos = actor->getPosition();
143 
144  }
145  else
146  {
147  ROR_ASSERT(App::GetGameContext()->GetPlayerCharacter());
149  }
150  reply << _L("Terrain height at position: ")
151  << "x: " << pos.x << " z: " << pos.z << " = "
152  << App::GetGameContext()->GetTerrain()->GetHeightAt(pos.x, pos.z);
154  }
155 };
156 
158 {
159 public:
160  SpawnobjectCmd(): ConsoleCmd("spawnobject", "<odef name>", _L("spawnobject - spawn a object at the player position")) {}
161 
162  void Run(Ogre::StringVector const& args) override
163  {
164  if (!this->CheckAppState(AppState::SIMULATION))
165  return;
166 
167  ROR_ASSERT(App::GetGameContext()->GetPlayerCharacter());
168  ROR_ASSERT(App::GetGameContext()->GetTerrain());
169 
170  Str<200> reply;
171  reply << m_name << ": ";
172  Console::MessageType reply_type;
173 
174  try
175  {
176  if (args.size() == 1)
177  {
178  reply_type = Console::CONSOLE_SYSTEM_ERROR;
179  reply << _L("Missing parameter: ") << m_usage;
180  }
181  else
182  {
183  Ogre::Vector3 pos = App::GetGameContext()->GetPlayerCharacter()->getPosition();
184  if (App::GetGameContext()->GetTerrain()->getObjectManager()->LoadTerrainObject(args[1], pos, Ogre::Vector3::ZERO, "Console", ""))
185  {
186  reply_type = Console::CONSOLE_SYSTEM_REPLY;
187  reply << _L("Spawned object at position: ") << "x: " << pos.x << " z: " << pos.z;
188  }
189  else
190  {
191  reply_type = Console::CONSOLE_SYSTEM_ERROR;
192  reply << _L("Could not spawn object");
193  }
194  }
195  }
196  catch (std::exception& e)
197  {
198  reply_type = Console::CONSOLE_SYSTEM_ERROR;
199  reply << e.what();
200  }
202  }
203 };
204 
205 class LogCmd: public ConsoleCmd
206 {
207 public:
208  LogCmd(): ConsoleCmd("log", "[]", _L("log - toggles log output on the console")) {}
209 
210  void Run(Ogre::StringVector const& args) override
211  {
212  Str<200> reply;
213  reply << m_name << ": ";
215 
216  // switch to console logging
217  bool now_logging = !App::diag_log_console_echo->getBool();
218  const char* msg = (now_logging) ? " logging to console enabled" : " logging to console disabled";
219  reply << _L(msg);
220  App::diag_log_console_echo->setVal(now_logging);
221 
223  }
224 };
225 
226 class VerCmd: public ConsoleCmd
227 {
228 public:
229  VerCmd(): ConsoleCmd("ver", "[]", _L("ver - shows the Rigs of Rods version")) {}
230 
231  void Run(Ogre::StringVector const& args) override
232  {
233  Str<200> reply;
234  reply << m_name << ": ";
236 
237  reply << "Rigs of Rods " << ROR_VERSION_STRING
238  << " (" << RORNET_VERSION << ") ["
239  << ROR_BUILD_DATE << ", " << ROR_BUILD_TIME << "]";
240 
242  }
243 };
244 
245 class PosCmd: public ConsoleCmd
246 {
247 public:
248  PosCmd(): ConsoleCmd("pos", "[]", _L("pos - outputs the current position")) {}
249 
250  void Run(Ogre::StringVector const& args) override
251  {
252  if (!this->CheckAppState(AppState::SIMULATION))
253  return;
254 
255  Str<200> reply;
256  reply << m_name << ": ";
258 
260  if (!b && App::GetGameContext()->GetPlayerCharacter())
261  {
262  Ogre::Vector3 pos = App::GetGameContext()->GetPlayerCharacter()->getPosition();
263  reply << _L("Character position: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
264  }
265  else if (b)
266  {
267  Ogre::Vector3 pos = b->getPosition();
268  reply << _L("Vehicle position: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
269  }
270 
272  }
273 };
274 
275 class GotoCmd: public ConsoleCmd
276 {
277 public:
278  GotoCmd(): ConsoleCmd("goto", "<x> <y> <z>", _L("goto <x> <y> <z> - jumps to the mentioned position")) {}
279 
280  void Run(Ogre::StringVector const& args) override
281  {
282  if (!this->CheckAppState(AppState::SIMULATION))
283  return;
284 
285  Str<200> reply;
286  reply << m_name << ": ";
287  Console::MessageType reply_type;
288 
289  if (args.size() != 4)
290  {
291  reply_type = Console::CONSOLE_HELP;
292  reply <<_L("usage: goto x y z");
293  }
294  else
295  {
296  reply_type = Console::CONSOLE_SYSTEM_REPLY;
297  Ogre::Vector3 pos(PARSEREAL(args[1]), PARSEREAL(args[2]), PARSEREAL(args[3]));
298 
300  if (!b && App::GetGameContext()->GetPlayerCharacter())
301  {
303  reply << _L("Character position set to: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
304  }
305  else if (b)
306  {
307  b->resetPosition(pos, false);
309  reply << _L("Vehicle position set to: ") << "x: " << pos.x << " y: " << pos.y << " z: " << pos.z;
310  }
311  }
312 
314  }
315 };
316 
317 
318 class AsCmd: public ConsoleCmd
319 {
320 public:
321  AsCmd(): ConsoleCmd("as", "<code>", _L("Run AngelScript code snippet")) {}
322 
323  void Run(Ogre::StringVector const& args) override
324  {
325  if (!this->CheckAppState(AppState::SIMULATION))
326  return;
327 
328  Str<200> reply;
329  reply << m_name << ": ";
330  Console::MessageType reply_type;
331 
332 #ifdef USE_ANGELSCRIPT
333  // we want to notify any running scripts that we might change something (prevent cheating)
335 
336  // Re-compose the code snippet
337  Str<1000> code;
338  for (int i = 1; i < args.size(); ++i)
339  {
340  code << " " << args[i];
341  }
342 
343  // Echo the code back to console user.
344  reply_type = Console::CONSOLE_SYSTEM_REPLY;
345  reply << " >>> " << code.ToCStr();
347 
348  // Run the code - will output script messages/AngelScript errors.
350 #else
351  reply_type = Console::CONSOLE_SYSTEM_ERROR;
352  reply << _L("Scripting disabled in this build");
354 #endif
355  }
356 };
357 
358 class QuitCmd: public ConsoleCmd
359 {
360 public:
361  QuitCmd(): ConsoleCmd("quit", "[]", _L("quit - exit Rigs of Rods")) {}
362 
363  void Run(Ogre::StringVector const& args) override
364  {
366  }
367 };
368 
369 class HelpCmd: public ConsoleCmd
370 {
371 public:
372  HelpCmd(): ConsoleCmd("help", "[]", _L("help - information on commands (this)")) {}
373 
374  void Run(Ogre::StringVector const& args) override
375  {
377  Console::CONSOLE_TITLE, _L("Available commands:"));
378 
379  Str<500> line;
380  for (auto& cmd_pair: App::GetConsole()->getCommands())
381  {
382  line.Clear() << cmd_pair.second->getName() << " "
383  << cmd_pair.second->GetUsage() << " - " << cmd_pair.second->GetDoc();
384 
386  Console::CONSOLE_HELP, line.ToCStr());
387  }
388 
390  Console::CONSOLE_TITLE, _L("Tips:"));
392  Console::CONSOLE_HELP, _L("- use Arrow Up/Down Keys in the InputBox to reuse old messages"));
393  }
394 };
395 
396 class LoadScriptCmd : public ConsoleCmd
397 {
398 public:
399  LoadScriptCmd() : ConsoleCmd("loadscript", "[filename]", _L("Runs an AngelScript file")) {}
400 
401  void Run(Ogre::StringVector const& args) override
402  {
403  Str<200> reply;
404  reply << m_name << ": ";
405  Console::MessageType reply_type;
406 
407 #ifdef USE_ANGELSCRIPT
408  if (args.size() == 1)
409  {
410  reply_type = Console::CONSOLE_SYSTEM_ERROR;
411  reply << _L("Missing parameter: ") << m_usage;
412  }
413  else
414  {
416  if (id == SCRIPTUNITID_INVALID)
417  {
418  reply_type = Console::CONSOLE_SYSTEM_ERROR;
419  reply << _L("Failed to load script. See 'Angelscript.log' or use console command `log` and retry.");
420  }
421  else
422  {
423  reply_type = Console::CONSOLE_SYSTEM_REPLY;
424  reply << fmt::format(_L("Script '{}' running with ID '{}'"), args[1], id);
425  }
426  }
427 #else
428  reply_type = Console::CONSOLE_SYSTEM_ERROR;
429  reply << _L("Scripting disabled in this build");
430 #endif
431 
433  }
434 };
435 
436 // -------------------------------------------------------------------------------------
437 // CVar (builtin) console commmands
438 
439 class VarsCmd: public ConsoleCmd
440 {
441 public:
442  VarsCmd(): ConsoleCmd("vars", "[<expr> ...]", _L("Print cvars with one of <expr> in name")) {}
443 
444  void Run(Ogre::StringVector const& args) override
445  {
446  for (auto& pair: App::GetConsole()->getCVars())
447  {
448  bool match = args.size() == 1;
449  for (size_t i = 1; i < args.size(); ++i)
450  {
451  if (pair.first.find(args[i]) != std::string::npos)
452  {
453  match = true;
454  break;
455  }
456  }
457 
458  if (match)
459  {
460  Str<200> reply;
461  reply << "vars: " << pair.first << "=" << pair.second->getStr() << " (";
462 
463  if (pair.second->hasFlag(CVAR_TYPE_BOOL)) { reply << "bool"; }
464  else if (pair.second->hasFlag(CVAR_TYPE_INT)) { reply << "int"; }
465  else if (pair.second->hasFlag(CVAR_TYPE_FLOAT)) { reply << "float"; }
466  else { reply << "string"; }
467 
468  if (pair.second->hasFlag(CVAR_ARCHIVE)) { reply << ", archive"; }
469  if (pair.second->hasFlag(CVAR_NO_LOG)) { reply << ", no log"; }
470 
471  reply << ")";
473  }
474  }
475  }
476 };
477 
478 class SetCmd: public ConsoleCmd
479 {
480 public:
481  SetCmd(): ConsoleCmd("set", "<cvar> [<flags>] [<value>]", _L("Get or set value of existing CVar")) {}
482 
483  void Run(Ogre::StringVector const& args) override
484  {
485  Str<200> reply;
486  reply << m_name << ": ";
488 
489  if (args.size() == 1)
490  {
491  reply_type = Console::CONSOLE_HELP;
492  reply << this->GetUsage() << " - " << this->GetDoc();
493  }
494  else
495  {
496  CVar* cvar = App::GetConsole()->cVarFind(args[1]);
497  if (cvar)
498  {
499  if (args.size() > 2)
500  {
501  App::GetConsole()->cVarAssign(cvar, args[2]);
502  }
503  reply_type = Console::CONSOLE_SYSTEM_REPLY;
504  reply << cvar->getName() << " = " << cvar->getStr();
505  }
506  else
507  {
508  reply_type = Console::CONSOLE_SYSTEM_ERROR;
509  reply << _L("No such CVar: ") << args[1];
510  }
511  }
512 
514  }
515 };
516 
517 class SetCVarCmd: public ConsoleCmd // Generic
518 {
519 public:
520  SetCVarCmd(std::string const& name, std::string const& usage, std::string const& doc, int flag):
521  ConsoleCmd(name, usage, doc), m_cvar_flag(flag)
522  {}
523 
524  void Run(Ogre::StringVector const& args) override
525  {
526  Str<200> reply;
527  reply << m_name << ": ";
528  Console::MessageType reply_type;
529 
530  if (args.size() == 1)
531  {
532  reply_type = Console::CONSOLE_HELP;
533  reply << this->GetUsage() << " - " << this->GetDoc() << "Switches: --autoapply/--allowstore/--autostore";
534  }
535  else
536  {
537  int flags = m_cvar_flag;
538  size_t i;
539  for (i = 1; i < args.size(); ++i)
540  {
541  if (args[i] == "--archive") { flags |= CVAR_ARCHIVE; }
542  else break; // Exit loop on first non-switch arg!
543  }
544 
545  if (i == args.size()) // Only switches but no cvar?
546  {
547  reply_type = Console::CONSOLE_HELP;
548  reply << this->GetUsage() << " - " << this->GetDoc() << "Switches: --archive";
549  }
550  else
551  {
552  CVar* cvar = App::GetConsole()->cVarGet(args[i], flags);
553  if (args.size() > (i+1))
554  {
555  App::GetConsole()->cVarAssign(cvar, args[i+1]);
556  }
557  reply_type = Console::CONSOLE_SYSTEM_REPLY;
558  reply << cvar->getName() << " = " << cvar->getStr();
559  }
560  }
561 
563  }
564 private:
566 };
567 
569 {
570 public:
571  SetstringCmd(): SetCVarCmd("setstring", "<cvar> [<value>]", _L("Set or create string CVar"), /*flag=*/0) {}
572 };
573 
574 class SetboolCmd: public SetCVarCmd
575 {
576 public:
577  SetboolCmd(): SetCVarCmd("setbool", "<cvar> [<value>]", _L("Set or create boolean CVar"), CVAR_TYPE_BOOL) {}
578 };
579 
580 class SetintCmd: public SetCVarCmd
581 {
582 public:
583  SetintCmd(): SetCVarCmd("setint", "<cvar> [<value>]", _L("Set or create integer CVar"), CVAR_TYPE_INT) {}
584 };
585 
586 class SetfloatCmd: public SetCVarCmd
587 {
588 public:
589  SetfloatCmd(): SetCVarCmd("setfloat", "<cvar> [<value>]", _L("Set or create real-number CVar"), CVAR_TYPE_FLOAT) {}
590 };
591 
592 class ClearCmd: public ConsoleCmd
593 {
594 public:
595  ClearCmd(): ConsoleCmd("clear", "[<type>]", _L("Clear console history. Types: all/info/net/chat/terrn/actor/script")) {}
596 
597  void Run(Ogre::StringVector const& args) override
598  {
599  if (args.size() < 2 || args[1] == "all")
600  {
602  lock.messages.clear();
603  }
604  else
605  {
606  // Create a predicate function
607  std::function<bool(Console::Message const& m)> filter_fn;
608  if (args[1] == "chat")
609  {
610  filter_fn = [](Console::Message const& m){ return m.cm_type == Console::CONSOLE_SYSTEM_NETCHAT; };
611  }
612  else if (args[1] == "net") // Chat and user notifications
613  {
614  filter_fn = [](Console::Message const& m){ return m.cm_net_userid != 0; };
615  }
616  else
617  {
619  bool valid = false;
620  if (args[1] == "info") { area = Console::CONSOLE_MSGTYPE_INFO; valid = true; }
621  else if (args[1] == "terrn") { area = Console::CONSOLE_MSGTYPE_TERRN; valid = true; }
622  else if (args[1] == "actor") { area = Console::CONSOLE_MSGTYPE_ACTOR; valid = true; }
623  else if (args[1] == "script") { area = Console::CONSOLE_MSGTYPE_SCRIPT; valid = true; }
624 
625  if (valid)
626  {
627  filter_fn = [area](Console::Message const& m) { return m.cm_area == area; };
628  }
629  else
630  {
632  fmt::format(_L("No such message type: {}"), args[1]));
633  }
634  }
635 
637  // Shove unwanted entries to the end
638  auto erase_begin = std::remove_if(lock.messages.begin(), lock.messages.end(), filter_fn);
639  // Erase unwanted
640  lock.messages.erase(erase_begin, lock.messages.end());
641  }
642  }
643 };
644 
646 
647 // -------------------------------------------------------------------------------------
648 // Console integration
649 
651 {
652  ConsoleCmd* cmd = nullptr;
653 
654  // Classics
655  cmd = new GravityCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
656  cmd = new WaterlevelCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
657  cmd = new TerrainheightCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
658  cmd = new SpawnobjectCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
659  cmd = new LogCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
660  cmd = new VerCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
661  cmd = new PosCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
662  cmd = new GotoCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
663  cmd = new AsCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
664  cmd = new QuitCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
665  cmd = new HelpCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
666  // Additions
667  cmd = new ClearCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
668  cmd = new LoadScriptCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
669  // CVars
670  cmd = new SetCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
671  cmd = new SetstringCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
672  cmd = new SetboolCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
673  cmd = new SetintCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
674  cmd = new SetfloatCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
675  cmd = new VarsCmd(); m_commands.insert(std::make_pair(cmd->getName(), cmd));
676 }
677 
678 void Console::doCommand(std::string msg)
679 {
680  if (msg[0] == '/' || msg[0] == '\\')
681  {
683  _L("Using slashes before commands are deprecated, you can now type command without any slashes"));
684  msg.erase(msg.begin());
685  }
686 
687  if (msg[0] == '!')
688  {
689  // Server commands - pass through to multiplayer chat
690  App::GetNetwork()->BroadcastChatMsg(msg.c_str());
691  return;
692  }
693 
694  Ogre::StringVector args = Ogre::StringUtil::split(msg, " ");
695 
696  auto found = m_commands.find(args[0]);
697  if (found != m_commands.end())
698  {
699  found->second->Run(args);
700  return;
701  }
702 
703  CVar* cvar = this->cVarFind(args[0]);
704  if (cvar)
705  {
706  Str<200> reply;
707  reply << cvar->getName() << " = " << cvar->getStr();
709  return;
710  }
711 
712  Str<200> reply;
713  reply << _L("unknown command: ") << msg;
715 }
716 
717 // -------------------------------------------------------------------------------------
718 // Helpers
719 
721 {
722  if (App::app_state->getEnum<AppState>() == state)
723  return true;
724 
725  Str<200> reply;
726  reply << m_name << ": ";
727  if (state == AppState::SIMULATION)
728  {
729  reply << _L("Only allowed when simulation is running");
730  }
731  else
732  {
733  reply << _L("Not allowed in current app state");
734  }
736  return false;
737 }
738 
739  // Currently unused: _L("Please enter a correct value. ")
740 
ROR_ASSERT
#define ROR_ASSERT(_EXPR)
Definition: Application.h:40
GameContext.h
Game state manager and message-queue provider.
RoR::CVAR_NO_LOG
@ CVAR_NO_LOG
Will not be written to RoR.log.
Definition: CVar.h:42
RoR::IWater::GetStaticWaterHeight
virtual float GetStaticWaterHeight()=0
Returns static water level configured in 'terrn2'.
RoR::Actor::resetPosition
void resetPosition(Ogre::Vector3 translation, bool setInitPosition)
Moves the actor to given world coords.
Definition: Actor.cpp:1315
SpawnobjectCmd::SpawnobjectCmd
SpawnobjectCmd()
Definition: ConsoleCmd.cpp:160
RoR::App::GetNetwork
Network * GetNetwork()
Definition: Application.cpp:284
SpawnobjectCmd
Definition: ConsoleCmd.cpp:157
VarsCmd
Definition: ConsoleCmd.cpp:439
RoR::Character::setPosition
void setPosition(Ogre::Vector3 position)
Definition: Character.cpp:85
SetfloatCmd
Definition: ConsoleCmd.cpp:586
RoR::Console::cVarGet
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:276
SetCVarCmd
Definition: ConsoleCmd.cpp:517
ClearCmd::ClearCmd
ClearCmd()
Definition: ConsoleCmd.cpp:595
RoR::Console::Message::cm_net_userid
uint32_t cm_net_userid
Definition: Console.h:77
SetCVarCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:524
RoR::SE_ANGELSCRIPT_MANIPULATIONS
@ SE_ANGELSCRIPT_MANIPULATIONS
triggered when the user tries to dynamically use the scripting capabilities (prevent cheating) args: ...
Definition: ScriptEvents.h:54
PARSEREAL
#define PARSEREAL(x)
Definition: Application.h:58
GravityCmd
Definition: ConsoleCmd.cpp:59
RoR::ConsoleCmd::m_name
std::string m_name
Definition: ConsoleCmd.h:54
OverlayWrapper.h
GotoCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:280
QuitCmd::QuitCmd
QuitCmd()
Definition: ConsoleCmd.cpp:361
RoR::Console::CONSOLE_MSGTYPE_TERRN
@ CONSOLE_MSGTYPE_TERRN
Parsing/spawn/simulation messages for terrain.
Definition: Console.h:64
AsCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:323
HelpCmd
Definition: ConsoleCmd.cpp:369
LogCmd
Definition: ConsoleCmd.cpp:205
SetintCmd
Definition: ConsoleCmd.cpp:580
AsCmd::AsCmd
AsCmd()
Definition: ConsoleCmd.cpp:321
LogCmd::LogCmd
LogCmd()
Definition: ConsoleCmd.cpp:208
RoR::Actor::ar_instance_id
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
Definition: Actor.h:376
RoR::ConsoleCmd::getName
std::string const & getName() const
Definition: ConsoleCmd.h:47
RORNET_VERSION
#define RORNET_VERSION
Definition: RoRnet.h:35
PosCmd::PosCmd
PosCmd()
Definition: ConsoleCmd.cpp:248
format
Truck file format(technical spec)
SetCVarCmd::SetCVarCmd
SetCVarCmd(std::string const &name, std::string const &usage, std::string const &doc, int flag)
Definition: ConsoleCmd.cpp:520
RoR::GameContext::GetPlayerCharacter
Character * GetPlayerCharacter()
Definition: GameContext.cpp:872
RoR::Terrain::setGravity
void setGravity(float value)
Definition: Terrain.cpp:481
RoR::CVar::getBool
bool getBool() const
Definition: CVar.h:98
RoR::TRIGGER_EVENT_ASYNC
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(),...
Definition: ScriptEngine.h:51
RoR::AppState
AppState
Definition: Application.h:159
RoR::IWater
< TODO: Mixed gfx+physics (waves) - must be separated ~ only_a_ptr, 02/2018
Definition: IWater.h:32
RoR::Console::cVarFind
CVar * cVarFind(std::string const &input_name)
Find cvar by short/long name.
Definition: CVar.cpp:248
PosCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:250
VerCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:231
CameraManager.h
SetfloatCmd::SetfloatCmd
SetfloatCmd()
Definition: ConsoleCmd.cpp:589
SetCmd
Definition: ConsoleCmd.cpp:478
ClearCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:597
WaterlevelCmd
Definition: ConsoleCmd.cpp:89
Console.h
RoR::ScriptEngine::executeString
int executeString(Ogre::String command)
executes a string (useful for the console)
Definition: ScriptEngine.cpp:483
RoR::Console::putMessage
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
Definition: Console.cpp:97
RoR::Console::CONSOLE_TITLE
@ CONSOLE_TITLE
Definition: Console.h:49
RoR::Console::CONSOLE_SYSTEM_NETCHAT
@ CONSOLE_SYSTEM_NETCHAT
Definition: Console.h:55
SetCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:483
GotoCmd::GotoCmd
GotoCmd()
Definition: ConsoleCmd.cpp:278
TerrainheightCmd::TerrainheightCmd
TerrainheightCmd()
Definition: ConsoleCmd.cpp:126
RoR::ScriptEngine::loadScript
ScriptUnitId_t loadScript(Ogre::String scriptname, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, std::string buffer="")
Loads a script.
Definition: ScriptEngine.cpp:759
Utils.h
Language.h
TerrainObjectManager.h
RefCountingObjectPtr< Actor >
LoadScriptCmd
Definition: ConsoleCmd.cpp:396
RoR::CVAR_ARCHIVE
@ CVAR_ARCHIVE
Will be written to RoR.cfg.
Definition: CVar.h:41
SetintCmd::SetintCmd
SetintCmd()
Definition: ConsoleCmd.cpp:583
RoR::Console::CONSOLE_SYSTEM_ERROR
@ CONSOLE_SYSTEM_ERROR
Definition: Console.h:52
GUIManager.h
SetboolCmd
Definition: ConsoleCmd.cpp:574
ActorManager.h
Actor.h
RoR::Console::MsgLockGuard::messages
std::vector< Message > & messages
Definition: Console.h:91
GravityCmd::GravityCmd
GravityCmd()
Definition: ConsoleCmd.cpp:62
RoR::App::GetScriptEngine
ScriptEngine * GetScriptEngine()
Definition: Application.cpp:279
GotoCmd
Definition: ConsoleCmd.cpp:275
TerrainheightCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:128
QuitCmd
Definition: ConsoleCmd.cpp:358
RoR::Terrain::GetHeightAt
float GetHeightAt(float x, float z)
Definition: Terrain.cpp:503
RoR::IWater::UpdateWater
virtual void UpdateWater()=0
RoR::Console::Message
Definition: Console.h:67
RoR::Terrain::getWaterHeight
float getWaterHeight() const
Definition: Terrain.h:65
RoR::SCRIPTUNITID_INVALID
static const ScriptUnitId_t SCRIPTUNITID_INVALID
Definition: ForwardDeclarations.h:41
RoR::Console::MsgLockGuard
Definition: Console.h:82
VerCmd
Definition: ConsoleCmd.cpp:226
RoR::CVar::getStr
std::string const & getStr() const
Definition: CVar.h:95
RoR::Str< 200 >
TerrainheightCmd
Definition: ConsoleCmd.cpp:123
RoR::Console::cVarAssign
void cVarAssign(CVar *cvar, std::string const &value)
Parse value by cvar type.
Definition: CVar.cpp:230
RoR::ASMANIP_CONSOLE_SNIPPET_EXECUTED
@ ASMANIP_CONSOLE_SNIPPET_EXECUTED
Definition: ScriptEvents.h:74
PosCmd
Definition: ConsoleCmd.cpp:245
LogCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:210
ScriptEngine.h
WaterlevelCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:94
RoR::GameContext::PushMessage
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
Definition: GameContext.cpp:65
RoR::App::app_state
CVar * app_state
Definition: Application.cpp:79
RoR::ScriptUnitId_t
int ScriptUnitId_t
Unique sequentially generated ID of a loaded and running scriptin session. Use ScriptEngine::getScrip...
Definition: ForwardDeclarations.h:40
RoR::Network::BroadcastChatMsg
void BroadcastChatMsg(const char *msg)
Definition: Network.cpp:773
RoR::Str::ToCStr
const char * ToCStr() const
Definition: Str.h:46
RoR::Console::MessageType
MessageType
Definition: Console.h:46
RoR::Actor::getPosition
Ogre::Vector3 getPosition()
Definition: Actor.cpp:424
GfxScene.h
Character.h
Application.h
Central state/object manager and communications hub.
RoR::App::GetConsole
Console * GetConsole()
Definition: Application.cpp:270
RoR::App::GetGameContext
GameContext * GetGameContext()
Definition: Application.cpp:280
GravityCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:64
RoR::Console::doCommand
void doCommand(std::string msg)
Identify and execute any console line.
Definition: ConsoleCmd.cpp:678
RoR::Character::getPosition
Ogre::Vector3 getPosition()
Definition: Character.cpp:92
RoR::AppState::SIMULATION
@ SIMULATION
RoR::ScriptEngine::triggerEvent
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.
Definition: ScriptEngine.cpp:712
RoRVersion.h
RoR::Console::CONSOLE_SYSTEM_REPLY
@ CONSOLE_SYSTEM_REPLY
Success.
Definition: Console.h:54
SetCVarCmd::m_cvar_flag
int m_cvar_flag
Definition: ConsoleCmd.cpp:565
ROR_VERSION_STRING
const char *const ROR_VERSION_STRING
VarsCmd::VarsCmd
VarsCmd()
Definition: ConsoleCmd.cpp:442
SetstringCmd
Definition: ConsoleCmd.cpp:568
RoR::CVar
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition: CVar.h:52
RoR::App::diag_log_console_echo
CVar * diag_log_console_echo
Definition: Application.cpp:146
RoR::ConsoleCmd::CheckAppState
bool CheckAppState(AppState state)
Definition: ConsoleCmd.cpp:720
RoR::Console::Message::cm_area
MessageArea cm_area
Definition: Console.h:74
SetstringCmd::SetstringCmd
SetstringCmd()
Definition: ConsoleCmd.cpp:571
AsCmd
Definition: ConsoleCmd.cpp:318
HelpCmd::HelpCmd
HelpCmd()
Definition: ConsoleCmd.cpp:372
RoR::CVar::getName
std::string const & getName() const
Definition: CVar.h:103
RoR::ConsoleCmd
Base (abstract) console command.
Definition: ConsoleCmd.h:37
IWater.h
RoR::Message
Unified game event system - all requests and state changes are reported using a message.
Definition: GameContext.h:51
RoR::SE_TRUCK_TELEPORT
@ SE_TRUCK_TELEPORT
triggered when the user teleports the truck, the argument refers to the actor ID of the vehicle
Definition: ScriptEvents.h:51
RoR::CVar::setVal
void setVal(T val)
Definition: CVar.h:72
_L
#define _L
Definition: ErrorUtils.cpp:34
RoR::CVAR_TYPE_BOOL
@ CVAR_TYPE_BOOL
Definition: CVar.h:38
RoR::Console::regBuiltinCommands
void regBuiltinCommands()
Register builtin commands.
Definition: ConsoleCmd.cpp:650
RoR::Console::Message::cm_type
MessageType cm_type
Definition: Console.h:75
RoR::Terrain::getGravity
float getGravity() const
Definition: Terrain.h:96
Terrain.h
VerCmd::VerCmd
VerCmd()
Definition: ConsoleCmd.cpp:229
RoR::CVAR_TYPE_INT
@ CVAR_TYPE_INT
Definition: CVar.h:39
QuitCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:363
RoR::Console::CONSOLE_MSGTYPE_ACTOR
@ CONSOLE_MSGTYPE_ACTOR
Parsing/spawn/simulation messages for actors.
Definition: Console.h:63
DEFAULT_GRAVITY
static const float DEFAULT_GRAVITY
earth gravity
Definition: SimConstants.h:50
RoR::Console::m_commands
CommandPtrMap m_commands
Definition: Console.h:161
RoR::Console::CONSOLE_MSGTYPE_INFO
@ CONSOLE_MSGTYPE_INFO
Generic message.
Definition: Console.h:60
RoR::Console::CONSOLE_MSGTYPE_SCRIPT
@ CONSOLE_MSGTYPE_SCRIPT
Messages sent from scripts.
Definition: Console.h:62
RoR::IWater::SetStaticWaterHeight
virtual void SetStaticWaterHeight(float value)=0
VarsCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:444
ROR_BUILD_DATE
const char *const ROR_BUILD_DATE
RoR::Console::CONSOLE_HELP
@ CONSOLE_HELP
Definition: Console.h:48
RoR::GameContext::GetPlayerActor
const ActorPtr & GetPlayerActor()
Definition: GameContext.h:134
SetboolCmd::SetboolCmd
SetboolCmd()
Definition: ConsoleCmd.cpp:577
SetCmd::SetCmd
SetCmd()
Definition: ConsoleCmd.cpp:481
RoR::CVAR_TYPE_FLOAT
@ CVAR_TYPE_FLOAT
Definition: CVar.h:40
HelpCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:374
RoR
Definition: AppContext.h:36
Network.h
RoR::Str::Clear
Str & Clear()
Definition: Str.h:54
ROR_BUILD_TIME
const char *const ROR_BUILD_TIME
LoadScriptCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:401
ClearCmd
Definition: ConsoleCmd.cpp:592
RoR::ScriptCategory::CUSTOM
@ CUSTOM
Loaded by user via either: A) ingame console 'loadscript'; B) RoR.cfg 'app_custom_scripts'; C) comman...
RoR::MSG_APP_SHUTDOWN_REQUESTED
@ MSG_APP_SHUTDOWN_REQUESTED
Definition: Application.h:85
RoR::Terrain::getWater
IWater * getWater()
Definition: Terrain.h:84
WaterlevelCmd::WaterlevelCmd
WaterlevelCmd()
Definition: ConsoleCmd.cpp:92
SpawnobjectCmd::Run
void Run(Ogre::StringVector const &args) override
Definition: ConsoleCmd.cpp:162
RoR::Console::MessageArea
MessageArea
Definition: Console.h:58
RoR::GameContext::GetTerrain
const TerrainPtr & GetTerrain()
Definition: GameContext.h:117
LoadScriptCmd::LoadScriptCmd
LoadScriptCmd()
Definition: ConsoleCmd.cpp:399