]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
bot_cmd sound: precache the sound when the command is queued
authorRudolf Polzer <divverent@xonotic.org>
Sun, 18 Sep 2011 13:43:54 +0000 (15:43 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Sun, 18 Sep 2011 13:43:54 +0000 (15:43 +0200)
qcsrc/server/bot/scripting.qc

index e540a438d55f07e88cccb96126ed3830290d46bd..485433e1dc27378dc4583fa1fcbf70fcc3c6224d 100644 (file)
@@ -21,6 +21,28 @@ void bot_queuecommand(entity bot, string cmdstring)
        }
 
        bufstr_set(bot.bot_cmdqueuebuf, bot.bot_cmdqueuebuf_end, cmdstring);
+
+       // if the command was a "sound" command, precache the sound NOW
+       // this prevents lagging!
+       {
+               float sp;
+               string parm;
+               string cmdstring;
+
+               sp = strstrofs(cmdstring, " ", 0);
+               if(sp < 0)
+               {
+                       parm = "";
+               }
+               else
+               {
+                       parm = substring(cmdstring, sp + 1, -1);
+                       cmdstring = substring(cmdstring, 0, sp);
+               }
+               if(cmdstring == "sound")
+                       precache_sound(cmdstring);
+       }
+
        bot.bot_cmdqueuebuf_end += 1;
 }