From: bones_was_here Date: Sun, 2 Apr 2023 20:25:35 +0000 (+1000) Subject: Fix null ptr deref when starting map dfwc2017-6 X-Git-Tag: xonotic-v0.8.6~138 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f4fd90837a0f7b2c40e05fc883bba5b63afd0ecb;p=xonotic%2Fxonotic-data.pk3dir.git Fix null ptr deref when starting map dfwc2017-6 Caused by 9b8502fe368052b4b81985084542548e6992cf72 which was needed for b95beb262077d8f733bbee7cb0d5f4c05b7b3e2f --- diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 6562e5753..9d53f7a28 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -949,12 +949,6 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default if(def.m_iteminit) def.m_iteminit(def, this); - if(!this.respawntime) // both need to be set - { - this.respawntime = defaultrespawntime; - this.respawntimejitter = defaultrespawntimejitter; - } - if(!this.pickup_anyway && def.m_pickupanyway) this.pickup_anyway = def.m_pickupanyway(); @@ -1017,6 +1011,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default } else { + // must be done after def.m_iteminit() as that may set ITEM_FLAG_MUTATORBLOCKED if(!have_pickup_item(this)) { startitem_failed = true; @@ -1024,6 +1019,13 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default return; } + // must be done before Item_Reset() and after MUTATORBLOCKED check (blocked items may have null func ptrs) + if(!this.respawntime) // both need to be set + { + this.respawntime = defaultrespawntime ? defaultrespawntime : def.m_respawntime(); + this.respawntimejitter = defaultrespawntimejitter ? defaultrespawntimejitter : def.m_respawntimejitter(); + } + if(this.angles != '0 0 0') this.SendFlags |= ISF_ANGLES; @@ -1173,8 +1175,8 @@ void StartItem(entity this, GameItem def) _StartItem( this, this.itemdef = def, - def.m_respawntime(), // defaultrespawntime - def.m_respawntimejitter() // defaultrespawntimejitter + 0, // call def.m_respawntime() to get defaultrespawntime + 0 // call def.m_respawntimejitter() to get defaultrespawntimejitter ); } diff --git a/qcsrc/server/items/items.qh b/qcsrc/server/items/items.qh index 95e27f836..8af67c8de 100644 --- a/qcsrc/server/items/items.qh +++ b/qcsrc/server/items/items.qh @@ -19,8 +19,6 @@ void StartItem(entity this, entity a); float autocvar_sv_simple_items; bool ItemSend(entity this, entity to, int sf); -bool have_pickup_item(entity this); - const float ITEM_RESPAWN_TICKS = 10; // string overrides entity