From: Mircea Kitsune Date: Sun, 6 Nov 2011 13:30:20 +0000 (+0200) Subject: Read-only mode. When enabled, no sandbox commands can be used, and objects cannot... X-Git-Tag: xonotic-v0.6.0~35^2~18^2~10 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=a0b81c8a4bac14f23744b8fa2d3e0fd3ecd0730d Read-only mode. When enabled, no sandbox commands can be used, and objects cannot be spawned, removed, or edited. Useful if a server admin uses the sandbox to place objects on a map and modify gameplay, without wanting to recompile the map itself. --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index c5d5e24b9f..e3daefac7b 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -549,6 +549,7 @@ seta g_balance_cloaked_alpha 0.25 set g_sandbox 0 "allow players to spawn and edit objects around the map" set g_sandbox_info 1 "print object information to the server. 1 prints info about spawned / removed objects, 2 also prints info about edited objects" +set g_sandbox_readonly 0 "when this mode is active, players cannot modify objects or use any sandbox commands" set g_sandbox_storage_name default "name of the selected storage to use" set g_sandbox_storage_autosave 5 "storage is automatically saved every specified number of seconds" set g_sandbox_storage_autoload 1 "if a storage file exists for the given map, automatically load it at startup" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 12952390ba..a8aa591790 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -1206,6 +1206,7 @@ float autocvar_g_loituma; float autocvar_g_grab; float autocvar_g_grab_range; float autocvar_g_sandbox_info; +float autocvar_g_sandbox_readonly; string autocvar_g_sandbox_storage_name; float autocvar_g_sandbox_storage_autosave; float autocvar_g_sandbox_storage_autoload; diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 1700964e48..264aa83a7d 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -35,10 +35,12 @@ void sandbox_ObjectFunction_Think() entity e; // decide if and how this object can be grabbed - if(autocvar_g_sandbox_editor_free < 2 && self.crypto_idfp) - self.grab = 1; + if(autocvar_g_sandbox_readonly) + self.grab = 0; // no grabbing + else if(autocvar_g_sandbox_editor_free < 2 && self.crypto_idfp) + self.grab = 1; // owner only else - self.grab = 3; + self.grab = 3; // anyone // Object owner is stored via player UID, but we also need the owner as an entity (if the player is available on the server). // Therefore, scan for all players, and update the owner as long as the player is present. We must always do this, @@ -400,9 +402,14 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) return FALSE; if(cmd_name == "g_sandbox") { + if(autocvar_g_sandbox_readonly) + { + print_to(self, "^2SANDBOX - INFO: ^7Sandbox mode is active, but in read-only mode. Sandbox commands cannot be used"); + return TRUE; + } if(cmd_argc < 2) { - print_to(self, "Sandbox mode is active. For usage information, type 'sandbox help'"); + print_to(self, "^2SANDBOX - INFO: ^7Sandbox mode is active. For usage information, type 'sandbox help'"); return TRUE; }