Skip to content
Permalink
Browse files

Make vm.cgame.type a cheat cvar

It was possible to play on a remote server with a DLL or whatever cgame
which is bad in a lot of ways. Hopefully all devs are in the habit of
using /devmap when testing or they're going to have a hard time :)
  • Loading branch information...
slipher committed Apr 12, 2019
1 parent f58dc1b commit ff8c35f70f03efae265e7057d7f0c0dc4514cd71
Showing with 10 additions and 7 deletions.
  1. +1 −1 src/engine/client/cl_cgame.cpp
  2. +8 −5 src/engine/framework/VirtualMachine.h
  3. +1 −1 src/engine/server/sv_sgame.cpp
@@ -1004,7 +1004,7 @@ void CL_OnTeamChanged( int newTeam )
Cmd::BufferCommandText( "exec -f " TEAMCONFIG_NAME );
}

CGameVM::CGameVM(): VM::VMBase("cgame"), services(nullptr), cmdBuffer("client")
CGameVM::CGameVM(): VM::VMBase("cgame", Cvar::CHEAT), services(nullptr), cmdBuffer("client")
{
}

@@ -65,6 +65,9 @@ namespace VM {
* provide sandboxing like the nacl executable but the OS will still clean up any
* leak for us.
*
* When setting the cgame VM type to non-default values, make sure to use /devmap
* (rather than /map) as it is a 'CHEAT' cvar.
*
* TL;DR
* - Native DLL: no sandboxing, no cleaning up but debugger support. Use for dev.
* - NaCl exe: sandboxing, no leaks, slightly slower, hard to debug. Use for regular players.
@@ -89,10 +92,10 @@ enum vmType_t {


struct VMParams {
VMParams(std::string name)
VMParams(std::string name, int vmTypeFlags)
: logSyscalls("vm." + name + ".logSyscalls", "dump all the syscalls in the " + name + ".syscallLog file", Cvar::NONE, false),
vmType("vm." + name + ".type", "how the vm should be loaded for " + name, Cvar::NONE,
Util::ordinal(vmType_t::TYPE_NACL), 0, Util::ordinal(vmType_t::TYPE_END) - 1),
vmType("vm." + name + ".type", "how the vm should be loaded for " + name, vmTypeFlags,
Util::ordinal(vmType_t::TYPE_NACL), 0, Util::ordinal(vmType_t::TYPE_END) - 1),
debug("vm." + name + ".debug", "run a gdbserver on localhost:4014 to debug the VM", Cvar::NONE, false),
debugLoader("vm." + name + ".debugLoader", "make nacl_loader dump information to " + name + "-nacl_loader.log", Cvar::NONE, 0, 0, 5) {
}
@@ -106,8 +109,8 @@ struct VMParams {
// Base class for a virtual machine instance
class VMBase {
public:
VMBase(std::string name)
: processHandle(Sys::INVALID_HANDLE), name(name), params(name) {}
VMBase(std::string name, int vmTypeCvarFlags)
: processHandle(Sys::INVALID_HANDLE), name(name), params(name, vmTypeCvarFlags) {}

// Create the VM for the named module. Returns the ABI version reported
// by the module. This will automatically free any existing VM.
@@ -336,7 +336,7 @@ void SV_InitGameProgs()
SV_InitGameVM();
}

GameVM::GameVM(): VM::VMBase("sgame"), services(nullptr){
GameVM::GameVM(): VM::VMBase("sgame", Cvar::NONE), services(nullptr) {
}

void GameVM::Start()

0 comments on commit ff8c35f

Please sign in to comment.
You can’t perform that action at this time.