]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up some self uses in demo code
authorMario <mario@smbclan.net>
Sat, 21 May 2016 23:20:35 +0000 (09:20 +1000)
committerMario <mario@smbclan.net>
Sat, 21 May 2016 23:20:35 +0000 (09:20 +1000)
qcsrc/common/state.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/playerdemo.qc
qcsrc/server/playerdemo.qh
qcsrc/server/portals.qc
qcsrc/server/race.qc
qcsrc/server/scores.qc

index 1d96923ed0fe314b643e8dd510421c5615b34476..0ffe55eb4fa50ba77a3c0c22ddb5c2b4defa2812 100644 (file)
@@ -59,7 +59,7 @@ void ClientState_attach(entity this)
 void bot_clientdisconnect(entity this);
 void W_HitPlotClose(entity this);
 void anticheat_report(entity this);
-void playerdemo_shutdown();
+void playerdemo_shutdown(entity this);
 void entcs_detach(entity this);
 void accuracy_free(entity this);
 void ClientData_Detach(entity this);
@@ -76,9 +76,9 @@ void ClientState_detach(entity this)
 
     W_HitPlotClose(this);
     anticheat_report(this);
-    playerdemo_shutdown();
+    playerdemo_shutdown(this);
     entcs_detach(this);
-    accuracy_free(self);
+    accuracy_free(this);
     ClientData_Detach(this);
-    PlayerScore_Detach(self);
+    PlayerScore_Detach(this);
 }
index 02e984e3c587e5eec84957cf6c628014c64e110c..63733e1c652ab7fcb7a121d667ae2b4f195c9cac 100644 (file)
@@ -1178,7 +1178,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               WITHSELF(client, playerdemo_open_read(argv(next_token)));
+                                               playerdemo_open_read(client, argv(next_token));
                                                return;
                                        }
 
@@ -1193,7 +1193,7 @@ void GameCommand_playerdemo(float request, float argc)
                                                        return;
                                                }
 
-                                               WITHSELF(client, playerdemo_open_write(argv(next_token)));
+                                               playerdemo_open_write(client, argv(next_token));
                                                return;
                                        }
 
index 9f3fd6d28f952db4ffa59fb5983e605825cfb5a7..3a01cb0756d93fbae542494e99e49948d6677783 100644 (file)
@@ -17,33 +17,33 @@ void playerdemo_init(entity this)
 {
        this.playerdemo_mode = PLAYERDEMO_MODE_OFF;
 }
-void playerdemo_shutdown()
-{SELFPARAM();
-       if(self.playerdemo_mode != PLAYERDEMO_MODE_OFF)
+void playerdemo_shutdown(entity this)
+{
+       if(this.playerdemo_mode != PLAYERDEMO_MODE_OFF)
        {
-               LOG_INFO("playerdemo: ", self.netname, " closed\n");
-               fclose(self.playerdemo_fh);
+               LOG_INFO("playerdemo: ", this.netname, " closed\n");
+               fclose(this.playerdemo_fh);
        }
-       self.playerdemo_mode = 0;
+       this.playerdemo_mode = 0;
 }
-void playerdemo_open_read(string f)
-{SELFPARAM();
-       playerdemo_shutdown();
-       self.playerdemo_mode = PLAYERDEMO_MODE_READING;
-       self.playerdemo_fh = fopen(f, FILE_READ);
-       self.playerdemo_starttime = time - 1;
-       self.playerdemo_time = stof(fgets(self.playerdemo_fh));
-       self.playerdemo_time += self.playerdemo_starttime;
-       self.movetype = MOVETYPE_NONE;
-       LOG_INFO("playerdemo: ", self.netname, " reading from ", f, "\n");
-}
-void playerdemo_open_write(string f)
-{SELFPARAM();
-       playerdemo_shutdown();
-       self.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
-       self.playerdemo_fh = fopen(f, FILE_WRITE);
-       self.playerdemo_starttime = time - 1;
-       LOG_INFO("playerdemo: ", self.netname, " writing to ", f, "\n");
+void playerdemo_open_read(entity this, string f)
+{
+       playerdemo_shutdown(this);
+       this.playerdemo_mode = PLAYERDEMO_MODE_READING;
+       this.playerdemo_fh = fopen(f, FILE_READ);
+       this.playerdemo_starttime = time - 1;
+       this.playerdemo_time = stof(fgets(this.playerdemo_fh));
+       this.playerdemo_time += this.playerdemo_starttime;
+       this.movetype = MOVETYPE_NONE;
+       LOG_INFO("playerdemo: ", this.netname, " reading from ", f, "\n");
+}
+void playerdemo_open_write(entity this, string f)
+{
+       playerdemo_shutdown(this);
+       this.playerdemo_mode = PLAYERDEMO_MODE_WRITING;
+       this.playerdemo_fh = fopen(f, FILE_WRITE);
+       this.playerdemo_starttime = time - 1;
+       LOG_INFO("playerdemo: ", this.netname, " writing to ", f, "\n");
        LOG_INFO("WARNING: playerdemo file format is incomplete and not stable yet. DO NOT RELY ON IT!\n");
 }
 #define PLAYERDEMO_FIELD(func,t,f) func##t(f,#f);
index 0fd42dca6b24257fad827cae16124d3edc8156cc..c44f414f97e18e39a6e32575c444f113b00150bd 100644 (file)
@@ -1,9 +1,9 @@
 #pragma once
 
 void playerdemo_init(entity this);
-void playerdemo_shutdown();
+void playerdemo_shutdown(entity this);
 void playerdemo_write();
 float playerdemo_read(entity this);
 
-void playerdemo_open_read(string f);
-void playerdemo_open_write(string f);
+void playerdemo_open_read(entity this, string f);
+void playerdemo_open_write(entity this, string f);
index 00cc50238dd86833cee339cfe3a307c3fbb38c1a..b6f1576d266cdcd29b6982d0d2accb9694751648 100644 (file)
@@ -255,7 +255,7 @@ void Portal_Touch()
 
 #ifdef PORTALS_ARE_NOT_SOLID
        // portal is being removed?
-       if(self.solid != SOLID_TRIGGER)
+       if(this.solid != SOLID_TRIGGER)
                return; // possibly engine bug
 
        if(IS_PLAYER(other))
@@ -272,7 +272,7 @@ void Portal_Touch()
        if(other.vehicle_flags & VHF_ISVEHICLE)
                return; // no teleporting vehicles?
 
-       if(!self.enemy)
+       if(!this.enemy)
                error("Portal_Touch called for a broken portal\n");
 
 #ifdef PORTALS_ARE_NOT_SOLID
@@ -285,26 +285,26 @@ void Portal_Touch()
 
        if(other.classname == "porto")
        {
-               if(other.portal_id == self.portal_id)
+               if(other.portal_id == this.portal_id)
                        return;
        }
-       if(time < self.portal_activatetime)
-               if(other == self.aiment)
+       if(time < this.portal_activatetime)
+               if(other == this.aiment)
                {
-                       self.portal_activatetime = time + 0.1;
+                       this.portal_activatetime = time + 0.1;
                        return;
                }
-       if(other != self.aiment)
+       if(other != this.aiment)
                if(IS_PLAYER(other))
-                       if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
+                       if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(this.aiment))
                                return; // cannot go through someone else's portal
-       if(other.aiment != self.aiment)
+       if(other.aiment != this.aiment)
                if(IS_PLAYER(other.aiment))
-                       if(IS_INDEPENDENT_PLAYER(other.aiment) || IS_INDEPENDENT_PLAYER(self.aiment))
+                       if(IS_INDEPENDENT_PLAYER(other.aiment) || IS_INDEPENDENT_PLAYER(this.aiment))
                                return; // cannot go through someone else's portal
-       fixedmakevectors(self.mangle);
+       fixedmakevectors(this.mangle);
        g = frametime * '0 0 -1' * autocvar_sv_gravity;
-       if(!Portal_WillHitPlane(other.origin, other.mins, other.maxs, other.velocity + g, self.origin, v_forward, self.maxs.x))
+       if(!Portal_WillHitPlane(other.origin, other.mins, other.maxs, other.velocity + g, this.origin, v_forward, this.maxs.x))
                return;
 
        /*
@@ -316,7 +316,7 @@ void Portal_Touch()
        }
        */
 
-       if(Portal_TeleportPlayer(self, other))
+       if(Portal_TeleportPlayer(this, other))
                if(other.classname == "porto")
                        if(other.effects & EF_RED)
                                other.effects += EF_BLUE - EF_RED;
@@ -459,56 +459,56 @@ void Portal_Think()
 
 #ifdef PORTALS_ARE_NOT_SOLID
        // portal is being removed?
-       if(self.solid != SOLID_TRIGGER)
+       if(this.solid != SOLID_TRIGGER)
                return; // possibly engine bug
 
-       if(!self.enemy)
+       if(!this.enemy)
                error("Portal_Think called for a broken portal\n");
 
-       o = self.aiment;
-       self.solid = SOLID_BBOX;
-       self.aiment = world;
+       o = this.aiment;
+       this.solid = SOLID_BBOX;
+       this.aiment = world;
 
        g = frametime * '0 0 -1' * autocvar_sv_gravity;
 
-       fixedmakevectors(self.mangle);
+       fixedmakevectors(this.mangle);
 
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                if(it != o)
                        if(IS_INDEPENDENT_PLAYER(it) || IS_INDEPENDENT_PLAYER(o))
                                continue; // cannot go through someone else's portal
 
-               if(it != o || time >= self.portal_activatetime)
-                       Portal_Think_TryTeleportPlayer(self, it, g);
+               if(it != o || time >= this.portal_activatetime)
+                       Portal_Think_TryTeleportPlayer(this, it, g);
 
                if(it.hook)
-                       Portal_Think_TryTeleportPlayer(self, it.hook, g);
+                       Portal_Think_TryTeleportPlayer(this, it.hook, g);
        ));
-       self.solid = SOLID_TRIGGER;
-       self.aiment = o;
+       this.solid = SOLID_TRIGGER;
+       this.aiment = o;
 #endif
 
-       self.nextthink = time;
+       this.nextthink = time;
 
-       if(time > self.fade_time)
-               Portal_Remove(self, 0);
+       if(time > this.fade_time)
+               Portal_Remove(this, 0);
 }
 
 float Portal_Customize()
 {SELFPARAM();
        if(IS_SPEC(other))
                other = other.enemy;
-       if(other == self.aiment)
+       if(other == this.aiment)
        {
-               self.modelindex = self.savemodelindex;
+               this.modelindex = this.savemodelindex;
        }
-       else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(self.aiment))
+       else if(IS_INDEPENDENT_PLAYER(other) || IS_INDEPENDENT_PLAYER(this.aiment))
        {
-               self.modelindex = 0;
+               this.modelindex = 0;
        }
        else
        {
-               self.modelindex = self.savemodelindex;
+               this.modelindex = this.savemodelindex;
        }
        return true;
 }
@@ -576,7 +576,7 @@ void Portal_ClearAll(entity own)
 }
 void Portal_RemoveLater_Think()
 {SELFPARAM();
-       Portal_Remove(self, self.cnt);
+       Portal_Remove(this, this.cnt);
 }
 void Portal_RemoveLater(entity portal, float kill)
 {
index 6fb39f6ce71cac1007025543fc982cbf2a9f8258..bb956105182f28c725f98912c428cf9ebd117106 100644 (file)
@@ -1096,10 +1096,10 @@ void race_ImposePenaltyTime(entity pl, float penalty, string reason)
 void penalty_touch()
 {SELFPARAM();
        EXACTTRIGGER_TOUCH;
-       if(other.race_lastpenalty != self)
+       if(other.race_lastpenalty != this)
        {
-               other.race_lastpenalty = self;
-               race_ImposePenaltyTime(other, self.race_penalty, self.race_penalty_reason);
+               other.race_lastpenalty = this;
+               race_ImposePenaltyTime(other, this.race_penalty, this.race_penalty_reason);
        }
 }
 
index df6a611d8af900c808b3019b40cb7bcb55b4402a..efefcd17aaa26cf16897100a0123270dba7eba42 100644 (file)
@@ -65,7 +65,7 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
 
        longflags = 0;
        for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
-               if(self.(teamscores[i]) > 127 || self.(teamscores[i]) <= -128)
+               if(this.(teamscores[i]) > 127 || this.(teamscores[i]) <= -128)
                        longflags |= p;
 
 #if MAX_TEAMSCORE <= 8
@@ -79,9 +79,9 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
                if(sendflags & p)
                {
                        if(longflags & p)
-                               WriteInt24_t(MSG_ENTITY, self.(teamscores[i]));
+                               WriteInt24_t(MSG_ENTITY, this.(teamscores[i]));
                        else
-                               WriteChar(MSG_ENTITY, self.(teamscores[i]));
+                               WriteChar(MSG_ENTITY, this.(teamscores[i]));
                }
 
        return true;
@@ -406,7 +406,7 @@ void WinningConditionHelper()
        s = GetGametype();
        s = strcat(s, ":", autocvar_g_xonoticversion);
        s = strcat(s, ":P", ftos(cvar_purechanges_count));
-       s = strcat(s, ":S", ftos(nJoinAllowed(self, world)));
+       s = strcat(s, ":S", ftos(nJoinAllowed(this, world))); // note: self/this is most likely world in this case
        s = strcat(s, ":F", ftos(serverflags));
        s = strcat(s, ":M", modname);
        s = strcat(s, "::", GetPlayerScoreString(world, (fullstatus ? 1 : 2)));