]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/sandbox.qc
various mutator system fixes; add proper rollback of failed add, fixes #1145
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / sandbox.qc
index ce66b233f33289b2439349216bf4e3e5bca2af6d..391e317423dffd4dd37e628effe9a988b452267f 100644 (file)
@@ -205,7 +205,7 @@ string port_string[MAX_STORAGE_ATTACHMENTS]; // fteqcc crashes if this isn't def
 string sandbox_ObjectPort_Save(entity e, float database)
 {
        // save object properties, and return them as a string
-       float i;
+       float i = 0;
        string s;
        entity head;
 
@@ -268,6 +268,7 @@ string sandbox_ObjectPort_Save(entity e, float database)
        }
 
        // now apply the array to a simple string, with the ; symbol separating objects
+       s = "";
        for(i = 0; i <= MAX_STORAGE_ATTACHMENTS; ++i)
        {
                if(port_string[i])
@@ -282,7 +283,7 @@ entity sandbox_ObjectPort_Load(string s, float database)
 {
        // load object properties, and spawn a new object with them
        float n, i;
-       entity e, parent;
+       entity e = world, parent = world;
 
        // separate objects between the ; symbols
        n = tokenizebyseparator(s, "; ");
@@ -293,7 +294,7 @@ entity sandbox_ObjectPort_Load(string s, float database)
        for(i = 0; i < n; ++i)
        {
                float argv_num;
-               string tagname;
+               string tagname = string_null;
                argv_num = 0;
                tokenize_console(port_string[i]);
                e = sandbox_ObjectSpawn(database);
@@ -816,6 +817,16 @@ MUTATOR_DEFINITION(sandbox)
                        sandbox_Database_Load();
        }
 
+       MUTATOR_ONROLLBACK_OR_REMOVE
+       {
+               // nothing to roll back
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               // nothing to remove
+       }
+
        return FALSE;
 }