]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Properly strunzone the clipboard, fixing the bug in the last commit
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Tue, 25 Oct 2011 12:25:01 +0000 (15:25 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Tue, 25 Oct 2011 12:25:01 +0000 (15:25 +0300)
qcsrc/server/mutators/sandbox.qc

index 65fa4e0c444908216d27ad13ca9807268b0f1dba..e5e2799fc924046a05170bf58582b4adb51d0915 100644 (file)
@@ -131,6 +131,8 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
                        e = sandbox_EditObject(); // you can only copy objects you can edit, so this works
                        if(e != world)
                        {
+                               if(self.object_clipboard != "") // unzone the player's clipboard if it's not empty
+                                       strunzone(self.object_clipboard);
                                self.object_clipboard = strzone(strcat(e.model, " ", ftos(e.movetype)));
 
                                print_to(self, "Object copied to clipboard");
@@ -152,8 +154,6 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
 
                        e = sandbox_SpawnObject();
                        tokenize_console(self.object_clipboard);
-                       strunzone(self.object_clipboard);
-                       self.object_clipboard = string_null;
 
                        setmodel(e, argv(0));
                        e.movetype = stof(argv(1));
@@ -202,10 +202,21 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerPreThink)
        return FALSE;
 }
 
+MUTATOR_HOOKFUNCTION(sandbox_ClientDisconnect)
+{
+       // unzone the player's clipboard if it's not empty
+       if(self.object_clipboard != "")
+       {
+               strunzone(self.object_clipboard);
+               self.object_clipboard = string_null;
+       }
+}
+
 MUTATOR_DEFINITION(sandbox)
 {
        MUTATOR_HOOK(SV_ParseClientCommand, sandbox_PlayerCommand, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, sandbox_PlayerPreThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(ClientDisconnect, sandbox_ClientDisconnect, CBC_ORDER_ANY);
 
        return 0;
 }