]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
fix suicide
authorRudolf Polzer <divverent@alientrap.org>
Tue, 20 Dec 2011 21:50:52 +0000 (22:50 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 20 Dec 2011 21:50:52 +0000 (22:50 +0100)
qcsrc/client/csqcmodel_hooks.qc
qcsrc/csqcmodel/settings.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc

index 26299d36974f0205cd7b5ff46f2acf41a6b1ae8c..5f24f0744f0fd682b622918b3acbed51f90033a5 100644 (file)
@@ -258,6 +258,23 @@ void CSQCModel_AutoTagIndex_Apply(void)
        }
 }
 
+// FEATURE: EF_NODRAW workalike
+.float invisible_effects;
+void CSQCModel_Invisible_PreUpdate(void)
+{
+       self.effects = self.invisible_effects;
+}
+void CSQCModel_Invisible_PostUpdate(void)
+{
+       self.invisible_effects = self.effects;
+       self.effects &~= CSQCMODEL_EF_INVISIBLE;
+}
+void CSQCModel_Invisible_Apply(void)
+{
+       if(self.invisible_effects & CSQCMODEL_EF_INVISIBLE)
+               self.drawmask = 0;
+}
+
 // general functions
 void CSQCModel_Hook_PreDraw(float isplayer, float islocalplayer)
 {
@@ -283,11 +300,12 @@ void CSQCModel_Hook_PreDraw(float isplayer, float islocalplayer)
 
 void CSQCModel_Hook_PreUpdate(float isplayer, float islocalplayer)
 {
+       CSQCModel_Invisible_PreUpdate();
        if(isplayer)
        {
                // revert to values from server
-               CSQCPlayer_ForceModel_PreUpdate();
                CSQCPlayer_FallbackFrame_PreUpdate();
+               CSQCPlayer_ForceModel_PreUpdate();
        }
 }
 
@@ -299,4 +317,5 @@ void CSQCModel_Hook_PostUpdate(float isplayer, float islocalplayer)
                CSQCPlayer_ForceModel_PostUpdate();
                CSQCPlayer_FallbackFrame_PostUpdate();
        }
+       CSQCModel_Invisible_PostUpdate();
 }
index a91385aff61a5f5c3745ad29950df1e5b0ba307f..a687dfb909e6678a04e2bed669519fdaad3ebad4 100644 (file)
@@ -78,3 +78,5 @@ float autocvar_sv_use_csqc_players;
                CSQCModel_CheckUpdate()
 # endif
 #endif
+
+#define CSQCMODEL_EF_INVISIBLE EF_SELECTABLE
index d34a0c28756c05e966a1ff986dd41dc54b43addc..a5d0a22294b40f916b1a816cabcc0a3103a4a960 100644 (file)
@@ -584,13 +584,6 @@ void FixPlayermodel()
                }
        }
 
-       if(self.modelindex == 0 && self.deadflag == DEAD_NO)
-       {
-               if(self.model != "")
-                       bprint("\{1}^1Player ", self.netname, "^1 has a zero modelindex, trying to fix...\n");
-               self.model = ""; // force the != checks to return true
-       }
-
        if(defaultmodel != "")
        {
                if (defaultmodel != self.model)
@@ -1123,7 +1116,7 @@ void KillIndicator_Think()
                return;
        }
 
-       if (!self.owner.modelindex)
+       if (self.owner.effects & CSQCMODEL_EF_INVISIBLE)
        {
                self.owner.killindicator = world;
                remove(self);
@@ -1183,7 +1176,7 @@ void ClientKill_TeamChange (float targetteam) // 0 = don't change, -1 = auto, -2
 
     if(!self.killindicator)
        {
-               if(self.modelindex && self.deadflag == DEAD_NO)
+               if(self.deadflag == DEAD_NO)
                {
                        killtime = max(killtime, self.clientkill_nexttime - time);
                        self.clientkill_nexttime = time + killtime + autocvar_g_balance_kill_antispam;
@@ -1707,7 +1700,7 @@ void ClientDisconnect (void)
 void ChatBubbleThink()
 {
        self.nextthink = time;
-       if (!self.owner.modelindex || self.owner.chatbubbleentity != self)
+       if ((self.owner.effects & CSQCMODEL_EF_INVISIBLE) || self.owner.chatbubbleentity != self)
        {
                if(self.owner) // but why can that ever be world?
                        self.owner.chatbubbleentity = world;
@@ -1726,7 +1719,7 @@ void ChatBubbleThink()
 
 void UpdateChatBubble()
 {
-       if (!self.modelindex)
+       if (self.effects & CSQCMODEL_EF_INVISIBLE)
                return;
        // spawn a chatbubble entity if needed
        if (!self.chatbubbleentity)
@@ -1766,7 +1759,7 @@ void UpdateChatBubble()
 .float oldcolormap;
 void respawn(void)
 {
-       if(self.modelindex != 0 && autocvar_g_respawn_ghosts)
+       if(!(self.effects & CSQCMODEL_EF_INVISIBLE) && autocvar_g_respawn_ghosts)
        {
                self.solid = SOLID_NOT;
                self.takedamage = DAMAGE_NO;
@@ -1817,7 +1810,7 @@ void player_powerups (void)
 
        self.effects &~= (EF_DIMLIGHT | EF_RED | EF_BLUE | EF_ADDITIVE | EF_FULLBRIGHT | EF_FLAME | EF_NODEPTHTEST);
 
-       if(!self.modelindex || self.deadflag) // don't apply the flags if the player is gibbed
+       if((self.effects & CSQCMODEL_EF_INVISIBLE) || self.deadflag) // don't apply the flags if the player is gibbed
                return;
 
        Fire_ApplyDamage(self);
index 8ff9fe7b2a17a0e726dd8a2fede7e5b7040f0fec..5907b7e8fda3491b77f3996b144aed58a4e18b3b 100644 (file)
@@ -400,7 +400,7 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float
        self.dmg_take = self.dmg_take + take;//max(take - 10, 0);
        self.dmg_inflictor = inflictor;
 
-       if (self.health <= -autocvar_sv_gibhealth && self.modelindex != 0)
+       if (self.health <= -autocvar_sv_gibhealth && !(self.effects & CSQCMODEL_EF_INVISIBLE))
        {
                // don't use any animations as a gib
                self.frame = 0;
@@ -409,7 +409,7 @@ void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float
                self.view_ofs = '0 0 4';
 
                Violence_GibSplash(self, 1, 1, attacker);
-               self.modelindex = 0; // restore later
+               self.effects |= CSQCMODEL_EF_INVISIBLE;
                self.solid = SOLID_NOT; // restore later
        }
 }