From: Mario Date: Sat, 21 May 2016 23:20:35 +0000 (+1000) Subject: Clean up some self uses in demo code X-Git-Tag: xonotic-v0.8.2~913 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=3fe0e96f23a0b424cbdfe8ca9e8252d578457ed0;p=xonotic%2Fxonotic-data.pk3dir.git Clean up some self uses in demo code --- diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc index 1d96923ed..0ffe55eb4 100644 --- a/qcsrc/common/state.qc +++ b/qcsrc/common/state.qc @@ -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); } diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 02e984e3c..63733e1c6 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -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; } diff --git a/qcsrc/server/playerdemo.qc b/qcsrc/server/playerdemo.qc index 9f3fd6d28..3a01cb075 100644 --- a/qcsrc/server/playerdemo.qc +++ b/qcsrc/server/playerdemo.qc @@ -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); diff --git a/qcsrc/server/playerdemo.qh b/qcsrc/server/playerdemo.qh index 0fd42dca6..c44f414f9 100644 --- a/qcsrc/server/playerdemo.qh +++ b/qcsrc/server/playerdemo.qh @@ -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); diff --git a/qcsrc/server/portals.qc b/qcsrc/server/portals.qc index 00cc50238..b6f1576d2 100644 --- a/qcsrc/server/portals.qc +++ b/qcsrc/server/portals.qc @@ -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) { diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index 6fb39f6ce..bb9561051 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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); } } diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index df6a611d8..efefcd17a 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -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)));