]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Monsters: resolve assertion failures
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 21 Dec 2015 07:19:51 +0000 (18:19 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 21 Dec 2015 07:19:51 +0000 (18:19 +1100)
qcsrc/lib/spawnfunc.qh
qcsrc/server/weapons/tracing.qc
qcsrc/server/weapons/weaponsystem.qc

index 3f9ca0e948a33c1d02ada7ee9f83f19fdfefb1a6..ef0d68f008d2cdc66b0ab2a1c815df416521f996 100644 (file)
@@ -140,7 +140,9 @@ noref bool require_spawnfunc_prefix;
                FIELD_SCALAR(fld, modelindex) \
                FIELD_SCALAR(fld, modelscale) \
                FIELD_SCALAR(fld, model) \
+               FIELD_SCALAR(fld, monsterid) \
                FIELD_SCALAR(fld, monster_moveflags) \
+               FIELD_SCALAR(fld, monster_name) \
                FIELD_SCALAR(fld, movetype) \
                FIELD_SCALAR(fld, netname) \
                FIELD_SCALAR(fld, nextthink) \
index 2d9dd23886b99e8f472fb46509252b29d54bf7e6..a9dc4bd28a3d0158f4e0ee6dd612cd578b483182 100644 (file)
@@ -25,7 +25,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        float oldsolid;
        vector vecs, dv;
        oldsolid = ent.dphitcontentsmask;
-       if(PS(ent).m_weapon == WEP_RIFLE)
+       if (IS_PLAYER(ent) && PS(ent).m_weapon == WEP_RIFLE)
                ent.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
        else
                ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
@@ -50,7 +50,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
                w_shotend = ent.origin + ent.view_ofs + s_forward * autocvar_g_trueaim_minrange;
 
        // track max damage
-       if(accuracy_canbegooddamage(ent))
+       if (IS_PLAYER(ent) && accuracy_canbegooddamage(ent))
                accuracy_add(ent, PS(ent).m_weapon.m_id, maxdamage, 0);
 
        W_HitPlotAnalysis(ent, v_forward, v_right, v_up);
index 919c88809c3dd80709f5d7abffde4a4d566190a4..2aa11b2c962d4521ddf2ad69abd3cdf20edf2d26 100644 (file)
@@ -256,6 +256,7 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary
 .float race_penalty;
 bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime)
 {
+       if (actor.weaponentity == NULL) return true;
        if (!weapon_prepareattack_checkammo(thiswep, actor, secondary)) return false;
 
        // if sv_ready_restart_after_countdown is set, don't allow the player to shoot
@@ -283,6 +284,7 @@ bool weapon_prepareattack_check(Weapon thiswep, entity actor, .entity weaponenti
 void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary, float attacktime)
 {
        entity this = actor.(weaponentity);
+       if (this == NULL) return;
        this.state = WS_INUSE;
 
        actor.spawnshieldtime = min(actor.spawnshieldtime, time);  // kill spawn shield when you fire
@@ -322,6 +324,7 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(
        .entity weaponentity, int fire) func)
 {
        entity this = actor.(weaponentity);
+       if (this == NULL) return;
        bool restartanim;
        if (fr == WFRAME_DONTCHANGE)
        {
@@ -338,16 +341,13 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(
        vector ou = v_up;
 
        vector a = '0 0 0';
-       if (this)
-       {
-               this.wframe = fr;
-               if (fr == WFRAME_IDLE) a = this.anim_idle;
-               else if (fr == WFRAME_FIRE1) a = this.anim_fire1;
-               else if (fr == WFRAME_FIRE2) a = this.anim_fire2;
-               else  // if (fr == WFRAME_RELOAD)
-                       a = this.anim_reload;
-               a.z *= g_weaponratefactor;
-       }
+    this.wframe = fr;
+    if (fr == WFRAME_IDLE) a = this.anim_idle;
+    else if (fr == WFRAME_FIRE1) a = this.anim_fire1;
+    else if (fr == WFRAME_FIRE2) a = this.anim_fire2;
+    else  // if (fr == WFRAME_RELOAD)
+        a = this.anim_reload;
+    a.z *= g_weaponratefactor;
 
        v_forward = of;
        v_right = or;