From: Mircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Date: Thu, 27 Oct 2011 20:52:22 +0000 (+0300)
Subject: Unfortunately, my previous change makes it impossible to track the object count of... 
X-Git-Tag: xonotic-v0.6.0~35^2~18^2~100
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a38bd26ab63d03aa74bd96fbbae0dd3d38794cda;p=xonotic%2Fxonotic-data.pk3dir.git

Unfortunately, my previous change makes it impossible to track the object count of each player. Therefore, turn the object limit into a global float, and default it to 1000. My only concern about this is that a griefer can spawn objects up to the limit, and prevent other players from building on the server due to that. Not an urgent problem, but to be given thought.
---

diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg
index 0f6827eab..5969527c0 100644
--- a/defaultXonotic.cfg
+++ b/defaultXonotic.cfg
@@ -543,7 +543,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 non-critical information to the server"
-set g_sandbox_editor_maxobjects 100 "maximum number of objects a player can have at a time"
+set g_sandbox_editor_maxobjects 1000 "maximum number of objects that may exist at a time"
 set g_sandbox_editor_free 0 "when enabled, players can edit any object on the map, not just the objects they've spawned"
 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"
diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc
index f094c4d6e..3c2f7f42b 100644
--- a/qcsrc/server/mutators/sandbox.qc
+++ b/qcsrc/server/mutators/sandbox.qc
@@ -1,6 +1,6 @@
+float object_count;
 .string object_clipboard;
 .entity object_attach;
-.float object_count;
 .string material;
 
 .float touch_timer;
@@ -123,15 +123,12 @@ entity sandbox_SpawnObject()
 	setorigin(e, trace_endpos);
 	e.angles_y = self.v_angle_y;
 
-	self.object_count += 1; // TODO: Adapt this to crypto_idfp based players!
-
+	object_count += 1;
 	return e;
 }
 
 void sandbox_RemoveObject(entity e)
 {
-	self.object_count -= 1; // TODO: Adapt this to crypto_idfp based players!
-
 	if(e.material)
 	{
 		strunzone(e.material);
@@ -144,6 +141,8 @@ void sandbox_RemoveObject(entity e)
 	}
 	remove(e);
 	e = world;
+
+	object_count -= 1;
 }
 
 string sandbox_Storage_Save(entity e)
@@ -257,9 +256,9 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
 			// ---------------- COMMAND: SPAWN OBJECT ----------------
 			case "spawn_object":
-				if(self.object_count >= autocvar_g_sandbox_editor_maxobjects)
+				if(object_count >= autocvar_g_sandbox_editor_maxobjects)
 				{
-					print_to(self, strcat("WARNING: Cannot spawn any more objects. Each player may have up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects at a time"));
+					print_to(self, strcat("WARNING: Cannot spawn any more objects. Up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects may exist at a time"));
 					return TRUE;
 				}
 				if(cmd_argc < 3)
@@ -322,9 +321,9 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 					print_to(self, "WARNING: No object in clipboard. You must copy an object before you can paste it");
 					return TRUE;
 				}
-				if(self.object_count >= autocvar_g_sandbox_editor_maxobjects)
+				if(object_count >= autocvar_g_sandbox_editor_maxobjects)
 				{
-					print_to(self, strcat("WARNING: Cannot spawn any more objects. Each player may have up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects at a time"));
+					print_to(self, strcat("WARNING: Cannot spawn any more objects. Up to ^3", ftos(autocvar_g_sandbox_editor_maxobjects), " ^7objects may exist at a time"));
 					return TRUE;
 				}