]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Basic implementation for reading sandbox storage files. Currently, it just prints...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 28 Oct 2011 13:51:14 +0000 (16:51 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Fri, 28 Oct 2011 13:51:14 +0000 (16:51 +0300)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/sandbox.qc

index ff90731aad59c24614c6179fd5721b265fda1c0d..15d89491fec083675db18c178fd4379018bf366d 100644 (file)
@@ -547,6 +547,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 object information to the server. 1 prints info about spawned / removed objects, 2 also prints info about edited objects"
 set g_sandbox_storage_autosave 10 "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_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"
index 3641d07b59e65cae992d465a095e6acbd13bcd1a..c33203bddc748bbdc15342c7bcb0b68ff00e5d5a 100644 (file)
@@ -1201,6 +1201,7 @@ float autocvar_g_debug_defaultsounds;
 float autocvar_g_loituma;
 float autocvar_g_sandbox_info;
 float autocvar_g_sandbox_storage_autosave;
+float autocvar_g_sandbox_storage_autoload;
 float autocvar_g_sandbox_editor_maxobjects;
 float autocvar_g_sandbox_editor_free;
 float autocvar_g_sandbox_editor_distance_spawn;
index 173faee9b55f35109d18d2aa8ab597f15af603e3..4a1a522417a90e4b69d6de22aac8df79939f7785 100644 (file)
@@ -228,7 +228,28 @@ void sandbox_Storage_DatabaseSave()
 
 void sandbox_Storage_DatabaseLoad()
 {
+       // loads all objects from the database file
+       string fn, rf;
+       float fh;
 
+       fn = strcat("sandbox/storage_", GetMapname(), ".txt");
+       fh = fopen(fn, FILE_READ);
+       if(fh < 0)
+               { } // message comes here
+       else
+       {
+               for(;;)
+               {
+                       rf = fgets(fh);
+                       if(!rf)
+                               break;
+                       if(substring(rf, 0, 2) == "//")
+                               continue;
+                       if(substring(rf, 0, 1) == "#")
+                               continue;
+                       dprint(strcat(rf, " --------\n"));
+               }
+       }
 }
 
 MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
@@ -572,6 +593,12 @@ MUTATOR_DEFINITION(sandbox)
        MUTATOR_HOOK(PlayerPreThink, sandbox_PlayerPreThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(ClientDisconnect, sandbox_ClientDisconnect, CBC_ORDER_ANY);
 
+       MUTATOR_ONADD
+       {
+               if(autocvar_g_sandbox_storage_autoload)
+                       sandbox_Storage_DatabaseLoad();
+       }
+
        return FALSE;
 }