]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bound the minimum and maximum scale of objects server-side, to avoid griefers being...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 26 Oct 2011 12:24:47 +0000 (15:24 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 26 Oct 2011 12:24:47 +0000 (15:24 +0300)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/sandbox.qc

index 4b9b5a45a4e49a23ec32e419f9e05760a37d9087..21de2f373e580af9a603221bc2155e9196c0f014 100644 (file)
@@ -545,6 +545,8 @@ set g_sandbox 0 "allow players to spawn and edit objects around the map"
 set g_sandbox_info 1 "print non-critical information to the server"
 set g_sandbox_editor_distance_spawn 200 "distance at which objects spawn in front of the player"
 set g_sandbox_editor_distance_edit 350 "distance at which players can edit or remove objects they are looking at"
+set g_sandbox_object_scale_min 0.1 "minimum scale that objects can be set to"
+set g_sandbox_object_scale_max 2 "maximum scale that objects can be set to"
 
 seta menu_sandbox_spawn_model "" // used to store the model in the input field
 set menu_sandbox_edit_skin 0
index 18f3b6ba0b9889b1fc506cdd75f10b8c2d043603..9082b2d25ef645f4c3b7a892c3d9ad756cbf8bd2 100644 (file)
@@ -1202,3 +1202,5 @@ float autocvar_g_loituma;
 float autocvar_g_sandbox_info;
 float autocvar_g_sandbox_editor_distance_spawn;
 float autocvar_g_sandbox_editor_distance_edit;
+float autocvar_g_sandbox_object_scale_min;
+float autocvar_g_sandbox_object_scale_max;
index a0d4c56dfea6ba1e9941393f8de47346ee97826f..6aa97b6960f9aedb87e63114ec216348f1e0ce8a 100644 (file)
@@ -1,6 +1,6 @@
 .string object_clipboard;
 
-entity sandbox_EditObject()
+entity sandbox_EditObject_Get()
 {
        // returns the traced entity if the player can edit it, and world if not
 
@@ -12,6 +12,16 @@ entity sandbox_EditObject()
                return world;
 }
 
+void sandbox_EditObject_Scale(entity e, float f)
+{
+       e.scale = f;
+       if(e.scale)
+       {
+               e.scale = bound(autocvar_g_sandbox_object_scale_min, e.scale, autocvar_g_sandbox_object_scale_max);
+               setsize(e, e.mins * e.scale, e.maxs * e.scale); // adapt bounding box size to model size
+       }
+}
+
 entity sandbox_SpawnObject()
 {
        // spawn a new object with default properties
@@ -127,7 +137,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
                        // ---------------- COMMAND: REMOVE OBJECT ----------------
                        case "remove_object":
-                               e = sandbox_EditObject();
+                               e = sandbox_EditObject_Get();
                                if(e != world)
                                {
                                        if(autocvar_g_sandbox_info)
@@ -144,7 +154,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                        case "duplicate_object_copy":
                                // copies customizable properties of the selected object to the clipboard
 
-                               e = sandbox_EditObject(); // you can only copy objects you can edit, so this works
+                               e = sandbox_EditObject_Get(); // you can only copy objects you can edit, so this works
                                if(e != world)
                                {
                                        if(self.object_clipboard)
@@ -189,7 +199,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                e.colormod = stov(argv(3));
                                e.glowmod = stov(argv(4));
                                e.frame = stof(argv(5));
-                               e.scale = stof(argv(6));        if(self.scale)  setsize(e, e.mins * e.scale, e.maxs * e.scale); // adapt bounding box size to model size
+                               sandbox_EditObject_Scale(e, stof(argv(6)));
                                e.movetype = stof(argv(7));
                                e.damageforcescale = stof(argv(8));
 
@@ -207,7 +217,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                        return TRUE;
                                }
 
-                               e = sandbox_EditObject();
+                               e = sandbox_EditObject_Get();
                                if(e != world)
                                {
                                        switch(argv(2))
@@ -228,9 +238,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                                                        e.frame = stof(argv(3));
                                                        break;
                                                case "scale":
-                                                       e.scale = stof(argv(3));
-                                                       if(self.scale)
-                                                               setsize(e, e.mins * e.scale, e.maxs * e.scale); // adapt bounding box size to model size
+                                                       sandbox_EditObject_Scale(e, stof(argv(3)));
                                                        break;
                                                case "physics":
                                                        switch(argv(3))
@@ -286,7 +294,7 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerPreThink)
        entity e;
        float grab;
 
-       e = sandbox_EditObject();
+       e = sandbox_EditObject_Get();
        if(e != world && vlen(e.origin - self.origin) <= autocvar_g_sandbox_editor_distance_edit)
                grab = TRUE;