]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_client.qc
s/make_pure/new_pure/
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_client.qc
index 3bc33a92c12189ae2bc5a8c91f82d7b8b2d803fd..f2e075c4da2ceba2eca0ece4204f166868723a5a 100644 (file)
@@ -86,8 +86,7 @@ bool ClientData_Send(entity this, entity to, int sf)
 
 void ClientData_Attach(entity this)
 {
-       Net_LinkEntity(this.clientdata = new(clientdata), false, 0, ClientData_Send);
-       make_pure(this.clientdata);
+       Net_LinkEntity(this.clientdata = new_pure(clientdata), false, 0, ClientData_Send);
        self.clientdata.drawonlytoclient = this;
        self.clientdata.owner = this;
 }
@@ -161,145 +160,135 @@ void setplayermodel(entity e, string modelname)
        player_setupanimsformodel();
 }
 
-/*
-=============
-PutObserverInServer
-
-putting a client as observer in the server
-=============
-*/
 void FixPlayermodel(entity player);
+/** putting a client as observer in the server */
 void PutObserverInServer()
 {
        SELFPARAM();
+    bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver);
        PlayerState_detach(this);
-       entity  spot;
-    self.hud = HUD_NORMAL;
-
-       if(IS_PLAYER(self)) { Send_Effect(EFFECT_SPAWN_NEUTRAL, self.origin, '0 0 0', 1); }
-
-       spot = SelectSpawnPoint (true);
-       if(!spot)
-               error("No spawnpoints for observers?!?\n");
-       RemoveGrapplingHook(self); // Wazat's Grappling Hook
-
-       if(IS_REAL_CLIENT(self))
-       {
-               msg_entity = self;
-               WriteByte(MSG_ONE, SVC_SETVIEW);
-               WriteEntity(MSG_ONE, self);
-       }
 
-       self.frags = FRAGS_SPECTATOR;
-       self.bot_attack = false;
+       if (IS_PLAYER(this)) Send_Effect(EFFECT_SPAWN_NEUTRAL, this.origin, '0 0 0', 1);
 
-       bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver);
+    {
+        entity spot = SelectSpawnPoint(true);
+        if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
+        this.angles = spot.angles;
+        this.angles_z = 0;
+        this.fixangle = true;
+        // offset it so that the spectator spawns higher off the ground, looks better this way
+        setorigin(this, spot.origin + STAT(PL_VIEW_OFS, NULL));
+        this.prevorigin = this.origin;
+        if (IS_REAL_CLIENT(this))
+        {
+            msg_entity = this;
+            WriteByte(MSG_ONE, SVC_SETVIEW);
+            WriteEntity(MSG_ONE, this);
+        }
+        // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
+        // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
+        setsize(this, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL));
+        this.view_ofs = '0 0 0';
+    }
 
-       Portal_ClearAll(self);
+    RemoveGrapplingHook(this);
+       Portal_ClearAll(this);
+       Unfreeze(this);
 
-       Unfreeze(self);
-
-       if(self.alivetime)
+       if (this.alivetime)
        {
-               if(!warmup_stage)
-                       PS_GR_P_ADDVAL(self, PLAYERSTATS_ALIVETIME, time - self.alivetime);
-               self.alivetime = 0;
+               if (!warmup_stage)
+                       PS_GR_P_ADDVAL(this, PLAYERSTATS_ALIVETIME, time - this.alivetime);
+               this.alivetime = 0;
        }
 
-       if(self.vehicle)
-               vehicles_exit(VHEF_RELEASE);
+       if (this.vehicle) vehicles_exit(VHEF_RELEASE);
 
-       WaypointSprite_PlayerDead(self);
+       WaypointSprite_PlayerDead(this);
 
-       if(!mutator_returnvalue)  // mutator prevents resetting teams
-               self.team = -1;  // move this as it is needed to log the player spectating in eventlog
+       if (!mutator_returnvalue)  // mutator prevents resetting teams
+               this.team = -1;  // move this as it is needed to log the player spectating in eventlog
 
-       if(self.killcount != FRAGS_SPECTATOR)
+       if (this.killcount != FRAGS_SPECTATOR)
        {
-               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, self.netname);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_SPECTATE, this.netname);
                if(!intermission_running)
                if(autocvar_g_chat_nospectators == 1 || (!(warmup_stage || gameover) && autocvar_g_chat_nospectators == 2))
-                       Send_Notification(NOTIF_ONE_ONLY, self, MSG_INFO, INFO_CHAT_NOSPECTATORS);
+                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS);
 
-               if(self.just_joined == false) {
-                       LogTeamchange(self.playerid, -1, 4);
+               if(this.just_joined == false) {
+                       LogTeamchange(this.playerid, -1, 4);
                } else
-                       self.just_joined = false;
+                       this.just_joined = false;
        }
 
-       PlayerScore_Clear(self); // clear scores when needed
+       PlayerScore_Clear(this); // clear scores when needed
 
-       accuracy_resend(self);
+       accuracy_resend(this);
 
-       self.spectatortime = time;
-
-       self.classname = STR_OBSERVER;
-       self.iscreature = false;
-       self.teleportable = TELEPORT_SIMPLE;
-       self.damagedbycontents = false;
-       self.health = FRAGS_SPECTATOR;
-       self.takedamage = DAMAGE_NO;
-       self.solid = SOLID_NOT;
-       self.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink
-       self.flags = FL_CLIENT | FL_NOTARGET;
-       self.armorvalue = 666;
-       self.effects = 0;
-       self.armorvalue = autocvar_g_balance_armor_start;
-       self.pauserotarmor_finished = 0;
-       self.pauserothealth_finished = 0;
-       self.pauseregen_finished = 0;
-       self.damageforcescale = 0;
-       self.death_time = 0;
-       self.respawn_flags = 0;
-       self.respawn_time = 0;
-       self.stat_respawn_time = 0;
-       self.alpha = 0;
-       self.scale = 0;
-       self.fade_time = 0;
-       self.pain_frame = 0;
-       self.pain_finished = 0;
-       self.strength_finished = 0;
-       self.invincible_finished = 0;
-       self.superweapons_finished = 0;
-       self.pushltime = 0;
-       self.istypefrag = 0;
-       self.think = func_null;
-       self.nextthink = 0;
-       self.hook_time = 0;
-       self.deadflag = DEAD_NO;
-       self.angles = spot.angles;
-       self.angles_z = 0;
-       self.fixangle = true;
-       self.crouch = false;
-       self.revival_time = 0;
-
-       setorigin (self, (spot.origin + STAT(PL_VIEW_OFS, NULL))); // offset it so that the spectator spawns higher off the ground, looks better this way
-       self.prevorigin = self.origin;
-       self.items = 0;
-       self.weapons = '0 0 0';
-       self.model = "";
-       FixPlayermodel(self);
-       setmodel(self, MDL_Null);
-       self.drawonlytoclient = self;
-
-       setsize (self, STAT(PL_CROUCH_MIN, NULL), STAT(PL_CROUCH_MAX, NULL)); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY
-       self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS"
-
-       self.weaponname = "";
-       self.weaponmodel = "";
+       this.spectatortime = time;
+    this.frags = FRAGS_SPECTATOR;
+       this.bot_attack = false;
+    this.hud = HUD_NORMAL;
+       this.classname = STR_OBSERVER;
+       this.iscreature = false;
+       this.teleportable = TELEPORT_SIMPLE;
+       this.damagedbycontents = false;
+       this.health = FRAGS_SPECTATOR;
+       this.takedamage = DAMAGE_NO;
+       this.solid = SOLID_NOT;
+       this.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink
+       this.flags = FL_CLIENT | FL_NOTARGET;
+       this.armorvalue = 666;
+       this.effects = 0;
+       this.armorvalue = autocvar_g_balance_armor_start;
+       this.pauserotarmor_finished = 0;
+       this.pauserothealth_finished = 0;
+       this.pauseregen_finished = 0;
+       this.damageforcescale = 0;
+       this.death_time = 0;
+       this.respawn_flags = 0;
+       this.respawn_time = 0;
+       this.stat_respawn_time = 0;
+       this.alpha = 0;
+       this.scale = 0;
+       this.fade_time = 0;
+       this.pain_frame = 0;
+       this.pain_finished = 0;
+       this.strength_finished = 0;
+       this.invincible_finished = 0;
+       this.superweapons_finished = 0;
+       this.pushltime = 0;
+       this.istypefrag = 0;
+       this.think = func_null;
+       this.nextthink = 0;
+       this.hook_time = 0;
+       this.deadflag = DEAD_NO;
+       this.crouch = false;
+       this.revival_time = 0;
+
+       this.items = 0;
+       this.weapons = '0 0 0';
+       this.model = "";
+       FixPlayermodel(this);
+       setmodel(this, MDL_Null);
+       this.drawonlytoclient = this;
+
+       this.weaponname = "";
+       this.weaponmodel = "";
        for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
        {
-               self.weaponentities[slot] = NULL;
-       }
-       self.exteriorweaponentity = world;
-       self.killcount = FRAGS_SPECTATOR;
-       self.velocity = '0 0 0';
-       self.avelocity = '0 0 0';
-       self.punchangle = '0 0 0';
-       self.punchvector = '0 0 0';
-       self.oldvelocity = self.velocity;
-       self.fire_endtime = -1;
-       self.event_damage = func_null;
+               this.weaponentities[slot] = NULL;
+       }
+       this.exteriorweaponentity = NULL;
+       this.killcount = FRAGS_SPECTATOR;
+       this.velocity = '0 0 0';
+       this.avelocity = '0 0 0';
+       this.punchangle = '0 0 0';
+       this.punchvector = '0 0 0';
+       this.oldvelocity = this.velocity;
+       this.fire_endtime = -1;
+       this.event_damage = func_null;
 }
 
 int player_getspecies(entity this)
@@ -527,8 +516,7 @@ void PutClientInServer()
                this.revival_time = 0;
                this.air_finished = time + 12;
 
-               entity spawnevent = new(spawnevent);
-               make_pure(spawnevent);
+               entity spawnevent = new_pure(spawnevent);
                spawnevent.owner = this;
                Net_LinkEntity(spawnevent, false, 0.5, SpawnEvent_Send);
 
@@ -668,8 +656,7 @@ void ClientInit_CheckUpdate()
 void ClientInit_Spawn()
 {SELFPARAM();
 
-       entity e = new(clientinit);
-       make_pure(e);
+       entity e = new_pure(clientinit);
        e.think = ClientInit_CheckUpdate;
        Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
 
@@ -904,7 +891,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
                        self.killindicator.colormod = Team_ColorRGB(targetteam);
                        if(IS_REAL_CLIENT(self))
                        if(self.killindicator.cnt > 0)
-                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM_4(targetteam, CENTER_TEAMCHANGE_), self.killindicator.cnt);
+                               Send_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, APP_TEAM_NUM(targetteam, CENTER_TEAMCHANGE), self.killindicator.cnt);
                }
        }
 
@@ -1061,7 +1048,7 @@ void ClientConnect()
 
        this.netname_previous = strzone(this.netname);
 
-       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT_4(this, INFO_JOIN_CONNECT_TEAM_) : INFO_JOIN_CONNECT), this.netname);
+       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, ((teamplay && IS_PLAYER(this)) ? APP_TEAM_ENT(this, INFO_JOIN_CONNECT_TEAM) : INFO_JOIN_CONNECT), this.netname);
 
        stuffcmd(this, clientstuff, "\n");
        stuffcmd(this, "cl_particles_reloadeffects\n"); // TODO do we still need this?
@@ -1758,11 +1745,11 @@ void LeaveSpectatorMode()
                        if(autocvar_g_campaign)
                                { campaign_bots_may_start = 1; }
 
-                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_PREVENT_JOIN);
+                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_PREVENT_JOIN);
 
                        PutClientInServer();
 
-                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT_4(this, INFO_JOIN_PLAY_TEAM_) : INFO_JOIN_PLAY), self.netname); }
+                       if(IS_PLAYER(self)) { Send_Notification(NOTIF_ALL, world, MSG_INFO, ((teamplay && this.team != -1) ? APP_TEAM_ENT(this, INFO_JOIN_PLAY_TEAM) : INFO_JOIN_PLAY), self.netname); }
                }
                else
                        stuffcmd(self, "menu_showteamselect\n");
@@ -1855,14 +1842,14 @@ void PrintWelcomeMessage()
                                self.motd_actived_time = time;
                        else if ((time - self.motd_actived_time > 2) && IS_PLAYER(self)) { // hide it some seconds after BUTTON_INFO has been released
                                self.motd_actived_time = 0;
-                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_MOTD);
                        }
                } else {
                        if (PHYS_INPUT_BUTTON_INFO(self))
                                self.motd_actived_time = time;
                        else if (time - self.motd_actived_time > 2) { // hide it some seconds after BUTTON_INFO has been released
                                self.motd_actived_time = 0;
-                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_MOTD);
                        }
                }
        }
@@ -1874,7 +1861,7 @@ void PrintWelcomeMessage()
                {
                        // instanctly hide MOTD
                        self.motd_actived_time = 0;
-                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_MOTD);
+                       Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_MOTD);
                }
        }
 }
@@ -2439,7 +2426,7 @@ void PlayerPostThink ()
                        if(self.idlekick_lasttimeleft)
                        {
                                self.idlekick_lasttimeleft = 0;
-                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER_CPID, CPID_IDLING);
+                               Kill_Notification(NOTIF_ONE_ONLY, self, MSG_CENTER, CPID_IDLING);
                        }
                }
                else