]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/scripting.qc
Merge remote-tracking branch 'origin/master' into samual/notification_rewrite
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / scripting.qc
index 63a6cb336d4054c90d3aa0283be057005139bed0..a1c00d0409183fb32e5cea864b7ff3764a5d9c94 100644 (file)
@@ -6,7 +6,7 @@
 void bot_clearqueue(entity bot)
 {
        if(!bot.bot_cmdqueuebuf_allocated)
-               error("clearqueue but no queue allocated");
+               return;
        buf_del(bot.bot_cmdqueuebuf);
        bot.bot_cmdqueuebuf_allocated = FALSE;
        dprint("bot ", bot.netname, " queue cleared\n");
@@ -18,6 +18,8 @@ void bot_queuecommand(entity bot, string cmdstring)
        {
                bot.bot_cmdqueuebuf = buf_create();
                bot.bot_cmdqueuebuf_allocated = TRUE;
+               bot.bot_cmdqueuebuf_start = 0;
+               bot.bot_cmdqueuebuf_end = 0;
        }
 
        bufstr_set(bot.bot_cmdqueuebuf, bot.bot_cmdqueuebuf_end, cmdstring);
@@ -38,9 +40,9 @@ void bot_queuecommand(entity bot, string cmdstring)
                {
                        parm = substring(cmdstr, sp + 1, -1);
                        cmdstr = substring(cmdstr, 0, sp);
+                       if(cmdstr == "sound")
+                               precache_sound(cmdstr);
                }
-               if(cmdstr == "sound")
-                       precache_sound(cmdstr);
        }
 
        bot.bot_cmdqueuebuf_end += 1;
@@ -292,7 +294,7 @@ entity find_bot_by_name(string name)
 entity find_bot_by_number(float number)
 {
        entity bot;
-       float c;
+       float c = 0;
 
        if(!number)
                return world;
@@ -1194,8 +1196,8 @@ void bot_resetqueues()
 
        FOR_EACH_CLIENT(cl) if(cl.isbot)
        {
-               if(cl.bot_cmdqueuebuf_allocated)
-                       bot_clearqueue(cl);
+               cl.bot_cmd_execution_index = 0;
+               bot_clearqueue(cl);
                // also, cancel all barriers
                cl.bot_barrier = 0;
                for(i = 0; i < cl.bot_places_count; ++i)