63 GravityCmd():
ConsoleCmd(
"gravity",
"[<number> or <constant>]",
_L(
"Get or set terrain gravity. Constants: earth/moon/mars/jupiter.")) {}
65 void Run(Ogre::StringVector
const& args)
override
95 void Run(Ogre::StringVector
const& args)
override
106 reply <<
_L(
"This terrain does not have water.");
115 water->SetStaticWaterHeight(height);
128 void Run(Ogre::StringVector
const& args)
override
150 reply <<
_L(
"Terrain height at position: ")
151 <<
"x: " << pos.x <<
" z: " << pos.z <<
" = "
162 void Run(Ogre::StringVector
const& args)
override
176 if (args.size() == 1)
179 reply <<
_L(
"Missing parameter: ") <<
m_usage;
184 if (
App::GetGameContext()->GetTerrain()->getObjectManager()->LoadTerrainObject(args[1], pos, Ogre::Vector3::ZERO,
"Console",
""))
187 reply <<
_L(
"Spawned object at position: ") <<
"x: " << pos.x <<
" z: " << pos.z;
192 reply <<
_L(
"Could not spawn object");
196 catch (std::exception& e)
210 void Run(Ogre::StringVector
const& args)
override
218 const char* msg = (now_logging) ?
" logging to console enabled" :
" logging to console disabled";
231 void Run(Ogre::StringVector
const& args)
override
250 void Run(Ogre::StringVector
const& args)
override
263 reply <<
_L(
"Character position: ") <<
"x: " << pos.x <<
" y: " << pos.y <<
" z: " << pos.z;
268 reply <<
_L(
"Vehicle position: ") <<
"x: " << pos.x <<
" y: " << pos.y <<
" z: " << pos.z;
280 void Run(Ogre::StringVector
const& args)
override
289 if (args.size() != 4)
292 reply <<
_L(
"usage: goto x y z");
303 reply <<
_L(
"Character position set to: ") <<
"x: " << pos.x <<
" y: " << pos.y <<
" z: " << pos.z;
309 reply <<
_L(
"Vehicle position set to: ") <<
"x: " << pos.x <<
" y: " << pos.y <<
" z: " << pos.z;
323 void Run(Ogre::StringVector
const& args)
override
332#ifdef USE_ANGELSCRIPT
338 for (
int i = 1; i < args.size(); ++i)
340 code <<
" " << args[i];
345 reply <<
" >>> " << code.
ToCStr();
352 reply <<
_L(
"Scripting disabled in this build");
363 void Run(Ogre::StringVector
const& args)
override
373 if (sound_manager ==
nullptr)
375 reply <<
_L(
"unable to get sound manager");
391 void Run(Ogre::StringVector
const& args)
override
402 void Run(Ogre::StringVector
const& args)
override
410 line.
Clear() << cmd_pair.second->getName() <<
" "
411 << cmd_pair.second->GetUsage() <<
" - " << cmd_pair.second->GetDoc();
429 void Run(Ogre::StringVector
const& args)
override
435#ifdef USE_ANGELSCRIPT
436 if (args.size() == 1)
439 reply <<
_L(
"Missing parameter: ") <<
m_usage;
447 reply <<
_L(
"Failed to load script. See 'Angelscript.log' or use console command `log` and retry.");
452 reply << fmt::format(
_L(
"Script '{}' running with ID '{}'"), args[1],
id);
457 reply <<
_L(
"Scripting disabled in this build");
469 void Run(Ogre::StringVector
const& args)
override
475#ifdef USE_ANGELSCRIPT
476 if (args.size() == 1)
479 reply <<
_L(
"Missing parameter: ") <<
m_usage;
481 else if (
App::mp_state->getEnum<MpState>() == MpState::CONNECTED)
484 reply <<
_L(
"Not allowed while connected to network.");
489 reply <<
_L(
"Server script is already running.");
497 reply <<
_L(
"Failed to load server script. See 'RoRServerScript.log'.");
511 strncpy(c.
language, (language + std::string(
"_") + country).c_str(), 5);
522 reply << fmt::format(
_L(
"Server script '{}' started"), args[1]);
527 reply <<
_L(
"Scripting disabled in this build");
539 void Run(Ogre::StringVector
const& args)
override
545#ifdef USE_ANGELSCRIPT
549 reply <<
_L(
"Server script was not running.");
556 reply <<
_L(
"Server script stopped.");
560 reply <<
_L(
"Scripting disabled in this build");
575 void Run(Ogre::StringVector
const& args)
override
579 bool match = args.size() == 1;
580 for (
size_t i = 1; i < args.size(); ++i)
582 if (pair.first.find(args[i]) != std::string::npos)
592 reply <<
"vars: " << pair.first <<
"=" << pair.second->getStr() <<
" (";
595 else if (pair.second->hasFlag(
CVAR_TYPE_INT)) { reply <<
"int"; }
597 else { reply <<
"string"; }
599 if (pair.second->hasFlag(
CVAR_ARCHIVE)) { reply <<
", archive"; }
600 if (pair.second->hasFlag(
CVAR_NO_LOG)) { reply <<
", no log"; }
612 SetCmd():
ConsoleCmd(
"set",
"<cvar> [<flags>] [<value>]",
_L(
"Get or set value of existing CVar")) {}
614 void Run(Ogre::StringVector
const& args)
override
620 if (args.size() == 1)
640 reply <<
_L(
"No such CVar: ") << args[1];
651 SetCVarCmd(std::string
const& name, std::string
const& usage, std::string
const& doc,
int flag):
655 void Run(Ogre::StringVector
const& args)
override
661 if (args.size() == 1)
664 reply << this->
GetUsage() <<
" - " << this->
GetDoc() <<
"Switches: --autoapply/--allowstore/--autostore";
670 for (i = 1; i < args.size(); ++i)
676 if (i == args.size())
679 reply << this->
GetUsage() <<
" - " << this->
GetDoc() <<
"Switches: --archive";
684 if (args.size() > (i+1))
726 ClearCmd():
ConsoleCmd(
"clear",
"[<type>]",
_L(
"Clear console history. Types: all/info/net/chat/terrn/actor/script")) {}
728 void Run(Ogre::StringVector
const& args)
override
730 if (args.size() < 2 || args[1] ==
"all")
739 if (args[1] ==
"chat")
743 else if (args[1] ==
"net")
763 fmt::format(
_L(
"No such message type: {}"), args[1]));
769 auto erase_begin = std::remove_if(lock.
messages.begin(), lock.
messages.end(), filter_fn);
814 if (msg[0] ==
'/' || msg[0] ==
'\\')
817 _L(
"Using slashes before commands are deprecated, you can now type command without any slashes"));
818 msg.erase(msg.begin());
828 Ogre::StringVector args = Ogre::StringUtil::split(msg,
" ");
833 found->second->Run(args);
847 reply <<
_L(
"unknown command: ") << msg;
863 reply <<
_L(
"Only allowed when simulation is running");
867 reply <<
_L(
"Not allowed in current app state");
Central state/object manager and communications hub.
#define ROR_ASSERT(_EXPR)
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
void Run(Ogre::StringVector const &args) override
Ogre::Vector3 getPosition()
ActorInstanceID_t ar_instance_id
Static attr; session-unique ID.
void resetPosition(Ogre::Vector3 translation, bool setInitPosition)
Moves the actor to given world coords (pivot point is node 0).
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
std::string const & getName() const
std::string const & getStr() const
void setPosition(Ogre::Vector3 position)
Ogre::Vector3 getPosition()
Base (abstract) console command.
std::string const & GetDoc() const
std::string const & GetUsage() const
std::string const & getName() const
void cVarAssign(CVar *cvar, std::string const &value)
Parse value by cvar type.
CommandPtrMap & getCommands()
@ CONSOLE_MSGTYPE_ACTOR
Parsing/spawn/simulation messages for actors.
@ CONSOLE_MSGTYPE_SCRIPT
Messages sent from scripts.
@ CONSOLE_MSGTYPE_INFO
Generic message.
@ CONSOLE_MSGTYPE_TERRN
Parsing/spawn/simulation messages for terrain.
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
CVar * cVarFind(std::string const &input_name)
Find cvar by short/long name.
@ CONSOLE_SYSTEM_REPLY
Success.
CVar * cVarGet(std::string const &input_name, int flags)
Get cvar by short/long name, or create new one using input as short name.
Character * GetPlayerCharacter()
const ActorPtr & GetPlayerActor()
const TerrainPtr & GetTerrain()
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
void SetLocalUserData(RoRnet::UserInfo const &user)
void BroadcastChatMsg(const char *msg)
ScriptUnitID_t loadScript(Ogre::String filename, ScriptCategory category=ScriptCategory::TERRAIN, ActorPtr associatedActor=nullptr, int32_t associatedNetUid=-1, 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.
int Initialize(const std::string &script_filename)
void createClient(RoRnet::UserInfo &user)
float GetSpeedOfSound() const
SoundManager * getSoundManager()
Wrapper for classic c-string (local buffer) Refresher: strlen() excludes '\0' terminator; strncat() A...
const char * ToCStr() const
void setGravity(float value)
float getWaterHeight() const
float getHeightAt(float x, float z)
float GetStaticWaterHeight()
Returns static water level configured in 'terrn2'.
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 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.
@ CVAR_NO_LOG
Will not be written to RoR.log.
@ MSG_GUI_MP_CLIENTS_REFRESH
@ MSG_APP_SHUTDOWN_REQUESTED
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(),...
ServerScriptSequencer * GetServerScript()
SoundScriptManager * GetSoundScriptManager()
GameContext * GetGameContext()
ScriptEngine * GetScriptEngine()
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
@ AUTH_ADMIN
admin on the server
#define RORNET_MAX_USERNAME_LEN
bytes.
std::vector< Message > & messages
Unified game event system - all requests and state changes are reported using a message.
int32_t authstatus
auth status set by server: AUTH_*
char clientname[10]
the name and version of the client. For exmaple: "ror" or "gamebot"
char language[10]
user's language. For example "de-DE" or "en-US"
char username[RORNET_MAX_USERNAME_LEN]
the nickname of the user (UTF-8)
char sessiontype[10]
the requested session type. For example "normal", "bot", "rcon"
char clientversion[25]
a version number of the client. For example 1 for RoR 0.35