]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Flood protection of object spawning and pasting. Defaulted to 1 second
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 6 Nov 2011 13:17:21 +0000 (15:17 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 6 Nov 2011 13:17:21 +0000 (15:17 +0200)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/sandbox.qc

index 78a22858147170c0ebed14975dc56e5e24919324..c5d5e24b9f54102b034f7176b00d072915347b81 100644 (file)
@@ -552,6 +552,7 @@ set g_sandbox_info 1 "print object information to the server. 1 prints info abou
 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"
+set g_sandbox_editor_flood 1 "players must wait this many seconds between spawning objects"
 set g_sandbox_editor_maxobjects 1000 "maximum number of objects that may exist at a time"
 set g_sandbox_editor_free 1 "0 = players can only copy or edit their own objects, 1 = players can copy but not edit other objects, 2 = players can copy and edit all object"
 set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in front of the player"
index 38c11fc4f9f93f67b2739b0455a5a5d496b83d7d..12952390ba4fa0bf8918ae4627a78dca0cea6a6c 100644 (file)
@@ -1209,6 +1209,7 @@ float autocvar_g_sandbox_info;
 string autocvar_g_sandbox_storage_name;
 float autocvar_g_sandbox_storage_autosave;
 float autocvar_g_sandbox_storage_autoload;
+float autocvar_g_sandbox_editor_flood;
 float autocvar_g_sandbox_editor_maxobjects;
 float autocvar_g_sandbox_editor_free;
 float autocvar_g_sandbox_editor_distance_spawn;
index 2f33f841c5647bed235c7f84338bf7e003e3d981..1700964e48ed6eba72db934a7333116d3e4b1aac 100644 (file)
@@ -1,5 +1,6 @@
 const float MAX_STORAGE_ATTACHMENTS = 16;
 float object_count;
+.float object_flood;
 .entity object_attach;
 .string material;
 
@@ -443,6 +444,12 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
                        // ---------------- COMMAND: OBJECT, SPAWN ----------------
                        case "object_spawn":
+                               if(time < self.object_flood)
+                               {
+                                       print_to(self, strcat("^1SANDBOX - WARNING: ^7Flood protection active. Please wait ^3", ftos(self.object_flood - time), " ^7seconds beofore spawning another object"));
+                                       return TRUE;
+                               }
+                               self.object_flood = time + autocvar_g_sandbox_editor_flood;
                                if(object_count >= autocvar_g_sandbox_editor_maxobjects)
                                {
                                        print_to(self, strcat("^1SANDBOX - WARNING: ^7Cannot spawn any more objects. Up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects may exist at a time"));
@@ -453,7 +460,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                        print_to(self, "^1SANDBOX - WARNING: ^7Attempted to spawn an object without specifying a model. Please specify the path to your model file after the 'object_spawn' command");
                                        return TRUE;
                                }
-                               else if not(fexists(argv(2)))
+                               if not(fexists(argv(2)))
                                {
                                        print_to(self, "^1SANDBOX - WARNING: ^7Attempted to spawn an object with a non-existent model. Make sure the path to your model file is correct");
                                        return TRUE;
@@ -501,6 +508,12 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
                                        case "paste":
                                                // spawns a new object using the properties in the player's clipboard cvar
+                                               if(time < self.object_flood)
+                                               {
+                                                       print_to(self, strcat("^1SANDBOX - WARNING: ^7Flood protection active. Please wait ^3", ftos(self.object_flood - time), " ^7seconds beofore spawning another object"));
+                                                       return TRUE;
+                                               }
+                                               self.object_flood = time + autocvar_g_sandbox_editor_flood;
                                                if(!argv(3)) // no object in clipboard
                                                {
                                                        print_to(self, "^1SANDBOX - WARNING: ^7No object in clipboard. You must copy an object before you can paste it");