]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Rid more bot files of self
authorMario <mario@smbclan.net>
Tue, 22 Mar 2016 10:16:03 +0000 (20:16 +1000)
committerMario <mario@smbclan.net>
Tue, 22 Mar 2016 10:16:03 +0000 (20:16 +1000)
qcsrc/common/physics/player.qc
qcsrc/common/state.qc
qcsrc/server/bot/bot.qc
qcsrc/server/bot/bot.qh
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/havocbot.qh
qcsrc/server/bot/navigation.qc
qcsrc/server/bot/navigation.qh
qcsrc/server/bot/waypoints.qc

index 545d71a21fff7d711e93da7f2df3c8115f15aed6..c9942a66770b92a74002b3953155120ded8a305f 100644 (file)
@@ -1358,7 +1358,7 @@ void PM_Main(entity this)
        {
                if (playerdemo_read(this))
                        return;
-               WITH(entity, self, this, bot_think());
+               bot_think(this);
        }
 #endif
 
index 0d05f195fc41c67722f51238909c3ac076bd2c3e..1e7582d79f673fe863fa809dd67af42670d18c41 100644 (file)
@@ -55,7 +55,7 @@ void ClientState_attach(entity this)
        bot_clientconnect(this);
 }
 
-void bot_clientdisconnect();
+void bot_clientdisconnect(entity this);
 void W_HitPlotClose(entity this);
 void anticheat_report(entity this);
 void playerdemo_shutdown();
@@ -71,7 +71,7 @@ void ClientState_detach(entity this)
 
     GetCvars(-1);  // free cvars
 
-    bot_clientdisconnect();
+    bot_clientdisconnect(this);
 
     W_HitPlotClose(this);
     anticheat_report(this);
index 0b905dbbe6667fa604ee0d98aefe1bce6d07056b..1b69658245781cc202cf826382145e21b6945f13 100644 (file)
 #include <lib/warpzone/util_server.qh>
 
 entity bot_spawn()
-{SELFPARAM();
+{
        entity bot = spawnclient();
        if (bot)
        {
                currentbots = currentbots + 1;
-               setself(bot);
-               bot_setnameandstuff();
-               ClientConnect();
-               PutClientInServer();
-               setself(this);
+               bot_setnameandstuff(bot);
+               WITH(entity, self, bot, ClientConnect());
+               WITH(entity, self, bot, PutClientInServer());
        }
        return bot;
 }
 
-void bot_think()
-{SELFPARAM();
-       if (self.bot_nextthink > time)
+void bot_think(entity this)
+{
+       if (this.bot_nextthink > time)
                return;
 
-       self.flags &= ~FL_GODMODE;
+       this.flags &= ~FL_GODMODE;
        if(autocvar_bot_god)
-               self.flags |= FL_GODMODE;
+               this.flags |= FL_GODMODE;
 
-       self.bot_nextthink = self.bot_nextthink + autocvar_bot_ai_thinkinterval * pow(0.5, self.bot_aiskill);
-       //if (self.bot_painintensity > 0)
-       //      self.bot_painintensity = self.bot_painintensity - (skill + 1) * 40 * frametime;
+       this.bot_nextthink = this.bot_nextthink + autocvar_bot_ai_thinkinterval * pow(0.5, this.bot_aiskill);
+       //if (this.bot_painintensity > 0)
+       //      this.bot_painintensity = this.bot_painintensity - (skill + 1) * 40 * frametime;
 
-       //self.bot_painintensity = self.bot_painintensity + self.bot_oldhealth - self.health;
-       //self.bot_painintensity = bound(0, self.bot_painintensity, 100);
+       //this.bot_painintensity = this.bot_painintensity + this.bot_oldhealth - this.health;
+       //this.bot_painintensity = bound(0, this.bot_painintensity, 100);
 
-       if (!IS_PLAYER(self) || (autocvar_g_campaign && !campaign_bots_may_start))
+       if (!IS_PLAYER(this) || (autocvar_g_campaign && !campaign_bots_may_start))
        {
-               self.bot_nextthink = time + 0.5;
+               this.bot_nextthink = time + 0.5;
                return;
        }
 
-       if (self.fixangle)
+       if (this.fixangle)
        {
-               self.v_angle = self.angles;
-               self.v_angle_z = 0;
-               self.fixangle = false;
+               this.v_angle = this.angles;
+               this.v_angle_z = 0;
+               this.fixangle = false;
        }
 
-       self.dmg_take = 0;
-       self.dmg_save = 0;
-       self.dmg_inflictor = world;
+       this.dmg_take = 0;
+       this.dmg_save = 0;
+       this.dmg_inflictor = world;
 
        // calculate an aiming latency based on the skill setting
        // (simulated network latency + naturally delayed reflexes)
-       //self.ping = 0.7 - bound(0, 0.05 * skill, 0.5); // moved the reflexes to bot_aimdir (under the name 'think')
+       //this.ping = 0.7 - bound(0, 0.05 * skill, 0.5); // moved the reflexes to bot_aimdir (under the name 'think')
        // minimum ping 20+10 random
-       self.ping = bound(0,0.07 - bound(0, (skill + self.bot_pingskill) * 0.005,0.05)+random()*0.01,0.65); // Now holds real lag to server, and higer skill players take a less laggy server
+       this.ping = bound(0,0.07 - bound(0, (skill + this.bot_pingskill) * 0.005,0.05)+random()*0.01,0.65); // Now holds real lag to server, and higer skill players take a less laggy server
        // skill 10 = ping 0.2 (adrenaline)
        // skill 0 = ping 0.7 (slightly drunk)
 
        // clear buttons
-       PHYS_INPUT_BUTTON_ATCK(self) = false;
-       PHYS_INPUT_BUTTON_JUMP(self) = false;
-       PHYS_INPUT_BUTTON_ATCK2(self) = false;
-       PHYS_INPUT_BUTTON_ZOOM(self) = false;
-       PHYS_INPUT_BUTTON_CROUCH(self) = false;
-       PHYS_INPUT_BUTTON_HOOK(self) = false;
-       PHYS_INPUT_BUTTON_INFO(self) = false;
-       PHYS_INPUT_BUTTON_DRAG(self) = false;
-       PHYS_INPUT_BUTTON_CHAT(self) = false;
-       PHYS_INPUT_BUTTON_USE(self) = false;
+       PHYS_INPUT_BUTTON_ATCK(this) = false;
+       PHYS_INPUT_BUTTON_JUMP(this) = false;
+       PHYS_INPUT_BUTTON_ATCK2(this) = false;
+       PHYS_INPUT_BUTTON_ZOOM(this) = false;
+       PHYS_INPUT_BUTTON_CROUCH(this) = false;
+       PHYS_INPUT_BUTTON_HOOK(this) = false;
+       PHYS_INPUT_BUTTON_INFO(this) = false;
+       PHYS_INPUT_BUTTON_DRAG(this) = false;
+       PHYS_INPUT_BUTTON_CHAT(this) = false;
+       PHYS_INPUT_BUTTON_USE(this) = false;
 
        if (time < game_starttime)
        {
                // block the bot during the countdown to game start
-               self.movement = '0 0 0';
-               self.bot_nextthink = game_starttime;
+               this.movement = '0 0 0';
+               this.bot_nextthink = game_starttime;
                return;
        }
 
        // if dead, just wait until we can respawn
-       if (IS_DEAD(self))
+       if (IS_DEAD(this))
        {
-               if (self.deadflag == DEAD_DEAD)
+               if (this.deadflag == DEAD_DEAD)
                {
-                       PHYS_INPUT_BUTTON_JUMP(self) = true; // press jump to respawn
-                       self.bot_strategytime = 0;
+                       PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn
+                       this.bot_strategytime = 0;
                }
        }
-       else if(self.aistatus & AI_STATUS_STUCK)
-               navigation_unstuck();
+       else if(this.aistatus & AI_STATUS_STUCK)
+               navigation_unstuck(this);
 
        // now call the current bot AI (havocbot for example)
-       self.bot_ai(self);
+       this.bot_ai(this);
 }
 
-void bot_setnameandstuff()
-{SELFPARAM();
+void bot_setnameandstuff(entity this)
+{
        string readfile, s;
        float file, tokens, prio;
 
@@ -197,11 +195,11 @@ void bot_setnameandstuff()
        if(argv(4) != "" && stof(argv(4)) >= 0) bot_pants = argv(4);
        else bot_pants = ftos(floor(random() * 15));
 
-       self.bot_forced_team = stof(argv(5));
+       this.bot_forced_team = stof(argv(5));
 
        prio = 6;
 
-       #define READSKILL(f,w,r) if(argv(prio) != "") self.f = stof(argv(prio)) * (w); else self.f = (!autocvar_g_campaign) * (2 * random() - 1) * (r) * (w); ++prio
+       #define READSKILL(f,w,r) if(argv(prio) != "") this.f = stof(argv(prio)) * (w); else this.f = (!autocvar_g_campaign) * (2 * random() - 1) * (r) * (w); ++prio
        //print(bot_name, ": ping=", argv(9), "\n");
 
        READSKILL(havocbot_keyboardskill, 0.5, 0.5); // keyboard skill
@@ -221,11 +219,11 @@ void bot_setnameandstuff()
        READSKILL(bot_thinkskill, 1, 0.5); // think skill
        READSKILL(bot_aiskill, 2, 0); // "ai" skill
 
-       self.bot_config_loaded = true;
+       this.bot_config_loaded = true;
 
        // this is really only a default, JoinBestTeam is called later
-       setcolor(self, stof(bot_shirt) * 16 + stof(bot_pants));
-       self.bot_preferredcolors = self.clientcolors;
+       setcolor(this, stof(bot_shirt) * 16 + stof(bot_pants));
+       this.bot_preferredcolors = this.clientcolors;
 
        // pick the name
        if (autocvar_bot_usemodelnames)
@@ -240,20 +238,20 @@ void bot_setnameandstuff()
                        ++j;
        ));
        if (j)
-               self.netname = self.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
+               this.netname = this.netname_freeme = strzone(strcat(prefix, name, "(", ftos(j), ")", suffix));
        else
-               self.netname = self.netname_freeme = strzone(strcat(prefix, name, suffix));
+               this.netname = this.netname_freeme = strzone(strcat(prefix, name, suffix));
 
-       self.cleanname = strzone(name);
+       this.cleanname = strzone(name);
 
        // pick the model and skin
        if(substring(bot_model, -4, 1) != ".")
                bot_model = strcat(bot_model, ".iqm");
-       self.playermodel = self.playermodel_freeme = strzone(strcat("models/player/", bot_model));
-       self.playerskin = self.playerskin_freeme = strzone(bot_skin);
+       this.playermodel = this.playermodel_freeme = strzone(strcat("models/player/", bot_model));
+       this.playerskin = this.playerskin_freeme = strzone(bot_skin);
 
-       self.cvar_cl_accuracy_data_share = 1;  // share the bots weapon accuracy data with the world
-       self.cvar_cl_accuracy_data_receive = 0;  // don't receive any weapon accuracy data
+       this.cvar_cl_accuracy_data_share = 1;  // share the bots weapon accuracy data with the world
+       this.cvar_cl_accuracy_data_receive = 0;  // don't receive any weapon accuracy data
 }
 
 void bot_custom_weapon_priority_setup()
@@ -378,53 +376,53 @@ void bot_relinkplayerlist()
        bot_strategytoken_taken = true;
 }
 
-void bot_clientdisconnect()
-{SELFPARAM();
-       if (!IS_BOT_CLIENT(self))
+void bot_clientdisconnect(entity this)
+{
+       if (!IS_BOT_CLIENT(this))
                return;
-       bot_clearqueue(self);
-       if(self.cleanname)
-               strunzone(self.cleanname);
-       if(self.netname_freeme)
-               strunzone(self.netname_freeme);
-       if(self.playermodel_freeme)
-               strunzone(self.playermodel_freeme);
-       if(self.playerskin_freeme)
-               strunzone(self.playerskin_freeme);
-       self.cleanname = string_null;
-       self.netname_freeme = string_null;
-       self.playermodel_freeme = string_null;
-       self.playerskin_freeme = string_null;
-       if(self.bot_cmd_current)
-               remove(self.bot_cmd_current);
-       if(bot_waypoint_queue_owner==self)
+       bot_clearqueue(this);
+       if(this.cleanname)
+               strunzone(this.cleanname);
+       if(this.netname_freeme)
+               strunzone(this.netname_freeme);
+       if(this.playermodel_freeme)
+               strunzone(this.playermodel_freeme);
+       if(this.playerskin_freeme)
+               strunzone(this.playerskin_freeme);
+       this.cleanname = string_null;
+       this.netname_freeme = string_null;
+       this.playermodel_freeme = string_null;
+       this.playerskin_freeme = string_null;
+       if(this.bot_cmd_current)
+               remove(this.bot_cmd_current);
+       if(bot_waypoint_queue_owner==this)
                bot_waypoint_queue_owner = world;
 }
 
 void bot_clientconnect(entity this)
 {
        if (!IS_BOT_CLIENT(this)) return;
-       self.bot_preferredcolors = self.clientcolors;
-       self.bot_nextthink = time - random();
-       self.lag_func = bot_lagfunc;
-       self.isbot = true;
-       self.createdtime = self.bot_nextthink;
-
-       if(!self.bot_config_loaded) // This is needed so team overrider doesn't break between matches
-               bot_setnameandstuff();
-
-       if(self.bot_forced_team==1)
-               self.team = NUM_TEAM_1;
-       else if(self.bot_forced_team==2)
-               self.team = NUM_TEAM_2;
-       else if(self.bot_forced_team==3)
-               self.team = NUM_TEAM_3;
-       else if(self.bot_forced_team==4)
-               self.team = NUM_TEAM_4;
+       this.bot_preferredcolors = this.clientcolors;
+       this.bot_nextthink = time - random();
+       this.lag_func = bot_lagfunc;
+       this.isbot = true;
+       this.createdtime = this.bot_nextthink;
+
+       if(!this.bot_config_loaded) // This is needed so team overrider doesn't break between matches
+               bot_setnameandstuff(this);
+
+       if(this.bot_forced_team==1)
+               this.team = NUM_TEAM_1;
+       else if(this.bot_forced_team==2)
+               this.team = NUM_TEAM_2;
+       else if(this.bot_forced_team==3)
+               this.team = NUM_TEAM_3;
+       else if(this.bot_forced_team==4)
+               this.team = NUM_TEAM_4;
        else
-               JoinBestTeam(self, false, true);
+               JoinBestTeam(this, false, true);
 
-       havocbot_setupbot();
+       havocbot_setupbot(this);
 }
 
 void bot_removefromlargestteam()
index b52651904a2e046b7b4f0f947c5ff99411031126..a28c94b7f729a8744241489008dc324caae6f51d 100644 (file)
@@ -92,12 +92,12 @@ float bot_ignore_bots; // let bots not attack other bots (only works in non-team
 entity bot_spawn();
 float bot_fixcount();
 
-void bot_think();
-void bot_setnameandstuff();
+void bot_think(entity this);
+void bot_setnameandstuff(entity this);
 void bot_custom_weapon_priority_setup();
 void bot_endgame();
 void bot_relinkplayerlist();
-void bot_clientdisconnect();
+void bot_clientdisconnect(entity this);
 void bot_clientconnect(entity this);
 void bot_removefromlargestteam();
 void bot_removenewest();
@@ -111,6 +111,6 @@ void bot_serverframe();
  * Imports
  */
 
-void() havocbot_setupbot;
+void(entity this) havocbot_setupbot;
 
 void bot_calculate_stepheightvec();
index 56b9017583fd4a98d0eeebe76acbbccb3c71adfd..5e8dc36e3d4058e97da48e4aa7ce9be6609c9dd6 100644 (file)
@@ -1259,13 +1259,13 @@ float havocbot_resetgoal(entity this)
        return CMD_STATUS_FINISHED;
 }
 
-void havocbot_setupbot()
-{SELFPARAM();
-       self.bot_ai = havocbot_ai;
-       self.cmd_moveto = havocbot_moveto;
-       self.cmd_resetgoal = havocbot_resetgoal;
+void havocbot_setupbot(entity this)
+{
+       this.bot_ai = havocbot_ai;
+       this.cmd_moveto = havocbot_moveto;
+       this.cmd_resetgoal = havocbot_resetgoal;
 
-       havocbot_chooserole();
+       WITH(entity, self, this, havocbot_chooserole());
 }
 
 vector havocbot_dodge()
index 4f017f0048d60ca1387028162b6446522520501f..8beb687ebd29d43fda70e87daa43ea5ffe88b09c 100644 (file)
@@ -35,7 +35,7 @@
 
 void havocbot_ai(entity this);
 void havocbot_aim(entity this);
-void havocbot_setupbot();
+void havocbot_setupbot(entity this);
 void havocbot_movetogoal(entity this);
 void havocbot_chooserole();
 void havocbot_chooseenemy(entity this);
index 03d3f1e89935094a4c4bece706c948d8a1fce9f8..ab74732e60d0dc3ca265db5a978a3e96149f0e5f 100644 (file)
@@ -1060,8 +1060,8 @@ void botframe_updatedangerousobjects(float maxupdate)
        }
 }
 
-void navigation_unstuck()
-{SELFPARAM();
+void navigation_unstuck(entity this)
+{
        float search_radius = 1000;
 
        if (!autocvar_bot_wander_enable)
@@ -1069,21 +1069,23 @@ void navigation_unstuck()
 
        if (!bot_waypoint_queue_owner)
        {
-               LOG_DEBUG(strcat(self.netname, " sutck, taking over the waypoints queue\n"));
-               bot_waypoint_queue_owner = self;
+               LOG_DEBUG(strcat(this.netname, " sutck, taking over the waypoints queue\n"));
+               bot_waypoint_queue_owner = this;
                bot_waypoint_queue_bestgoal = world;
                bot_waypoint_queue_bestgoalrating = 0;
        }
 
-       if(bot_waypoint_queue_owner!=self)
+       if(bot_waypoint_queue_owner!=this)
                return;
 
        if (bot_waypoint_queue_goal)
        {
                // evaluate the next goal on the queue
-               float d = vlen(self.origin - bot_waypoint_queue_goal.origin);
-               LOG_DEBUG(strcat(self.netname, " evaluating ", bot_waypoint_queue_goal.classname, " with distance ", ftos(d), "\n"));
-               if(tracewalk(bot_waypoint_queue_goal, self.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), bot_waypoint_queue_goal.origin, bot_navigation_movemode))
+               float d = vlen(this.origin - bot_waypoint_queue_goal.origin);
+               LOG_DEBUG(strcat(this.netname, " evaluating ", bot_waypoint_queue_goal.classname, " with distance ", ftos(d), "\n"));
+               entity oldself = self;
+               setself(this); // tracewalk has questionable use of self
+               if(tracewalk(bot_waypoint_queue_goal, this.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), bot_waypoint_queue_goal.origin, bot_navigation_movemode))
                {
                        if( d > bot_waypoint_queue_bestgoalrating)
                        {
@@ -1091,20 +1093,21 @@ void navigation_unstuck()
                                bot_waypoint_queue_bestgoal = bot_waypoint_queue_goal;
                        }
                }
+               setself(oldself);
                bot_waypoint_queue_goal = bot_waypoint_queue_goal.bot_waypoint_queue_nextgoal;
 
                if (!bot_waypoint_queue_goal)
                {
                        if (bot_waypoint_queue_bestgoal)
                        {
-                               LOG_DEBUG(strcat(self.netname, " stuck, reachable waypoint found, heading to it\n"));
-                               navigation_routetogoal(self, bot_waypoint_queue_bestgoal, self.origin);
-                               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-                               self.aistatus &= ~AI_STATUS_STUCK;
+                               LOG_DEBUG(strcat(this.netname, " stuck, reachable waypoint found, heading to it\n"));
+                               navigation_routetogoal(this, bot_waypoint_queue_bestgoal, this.origin);
+                               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+                               this.aistatus &= ~AI_STATUS_STUCK;
                        }
                        else
                        {
-                               LOG_DEBUG(strcat(self.netname, " stuck, cannot walk to any waypoint at all\n"));
+                               LOG_DEBUG(strcat(this.netname, " stuck, cannot walk to any waypoint at all\n"));
                        }
 
                        bot_waypoint_queue_owner = world;
@@ -1112,16 +1115,16 @@ void navigation_unstuck()
        }
        else
        {
-               if(bot_strategytoken!=self)
+               if(bot_strategytoken!=this)
                        return;
 
                // build a new queue
-               LOG_DEBUG(strcat(self.netname, " stuck, scanning reachable waypoints within ", ftos(search_radius)," qu\n"));
+               LOG_DEBUG(strcat(this.netname, " stuck, scanning reachable waypoints within ", ftos(search_radius)," qu\n"));
 
                entity head, first;
 
                first = world;
-               head = findradius(self.origin, search_radius);
+               head = findradius(this.origin, search_radius);
 
                while(head)
                {
@@ -1144,7 +1147,7 @@ void navigation_unstuck()
                        bot_waypoint_queue_goal = first;
                else
                {
-                       LOG_DEBUG(strcat(self.netname, " stuck, cannot walk to any waypoint at all\n"));
+                       LOG_DEBUG(strcat(this.netname, " stuck, cannot walk to any waypoint at all\n"));
                        bot_waypoint_queue_owner = world;
                }
        }
index 2d0f2d6dd6cb7a6050b36691251a9cce00029fa0..e3da4bb6a300846fed6af85bfd516cb89db090dd 100644 (file)
@@ -70,7 +70,7 @@ void navigation_routerating(entity e, float f, float rangebias);
 void navigation_poptouchedgoals();
 void navigation_goalrating_start();
 void navigation_goalrating_end();
-void navigation_unstuck();
+void navigation_unstuck(entity this);
 
 void botframe_updatedangerousobjects(float maxupdate);
 
index 049d7236f3e161b7a2716afd04ef729b91749ebb..184710818c1aac266a32e620695cd97fbbd66b1f 100644 (file)
@@ -296,10 +296,10 @@ void waypoint_schedulerelink(entity wp)
 // spawnfunc_waypoint map entity
 spawnfunc(waypoint)
 {
-       setorigin(self, self.origin);
+       setorigin(this, this.origin);
        // schedule a relink after other waypoints have had a chance to spawn
-       waypoint_clearlinks(self);
-       //waypoint_schedulerelink(self);
+       waypoint_clearlinks(this);
+       //waypoint_schedulerelink(this);
 }
 
 // remove a spawnfunc_waypoint, and schedule all neighbors to relink