diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp index 151e330a..8a37a007 100644 --- a/source/src/bot/bot_util.cpp +++ b/source/src/bot/bot_util.cpp @@ -190,11 +190,11 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult entity &e = ents[i]; if(e.type!=MAPMODEL) continue; // Only check map models for now - mapmodelinfo &mmi = getmminfo(e.attr2); - if(!&mmi || !mmi.h) continue; + mapmodelinfo *mmi = getmminfo(e.attr2); + if(!mmi || !mmi->h) continue; - float lo = (float)(S(e.x, e.y)->floor+mmi.zoff+e.attr3); - float hi = lo+mmi.h; + float lo = (float)(S(e.x, e.y)->floor+mmi->zoff+e.attr3); + float hi = lo+mmi->h; float z = (fabs(from.z-lo) < fabs(from.z-hi)) ? lo : hi; makevec(&v, e.x, e.y, z); flDist = GetDistance(from, v); diff --git a/source/src/entities.cpp b/source/src/entities.cpp index d61491b0..41dbcdc8 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -65,9 +65,9 @@ void rendermapmodels() entity &e = ents[i]; if(e.type==MAPMODEL) { - mapmodelinfo &mmi = getmminfo(e.attr2); - if(!&mmi) continue; - rendermodel(mmi.name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor+mmi.zoff+e.attr3), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 10.0f); + mapmodelinfo *mmi = getmminfo(e.attr2); + if(!mmi) continue; + rendermodel(mmi->name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, (float)S(e.x, e.y)->floor+mmi->zoff+e.attr3), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 10.0f); } } } @@ -223,14 +223,14 @@ void renderentities() else if((e.type == CLIP || e.type == PLCLIP) && showclips && !stenciling) renderclip(e); else if(e.type == MAPMODEL && showclips && showmodelclipping && !stenciling) { - mapmodelinfo &mmi = getmminfo(e.attr2); - if(&mmi && mmi.h) + mapmodelinfo *mmi = getmminfo(e.attr2); + if(mmi && mmi->h) { entity ce = e; ce.type = MAPMODEL; - ce.attr1 = mmi.zoff+e.attr3; - ce.attr2 = ce.attr3 = mmi.rad; - ce.attr4 = mmi.h; + ce.attr1 = mmi->zoff+e.attr3; + ce.attr2 = ce.attr3 = mmi->rad; + ce.attr4 = mmi->h; renderclip(ce); } } @@ -291,13 +291,13 @@ void pickupeffects(int n, playerent *d) if(!d) return; d->pickup(e.type); if (m_lss && e.type == I_GRENADE) d->pickup(e.type); // get 2 - itemstat &is = d->itemstats(e.type); + itemstat *is = d->itemstats(e.type); if(d!=player1 && d->type!=ENT_BOT) return; - if(&is) + if(is) { if(d==player1) { - audiomgr.playsoundc(is.sound); + audiomgr.playsoundc(is->sound); /* onPickup arg1 legend: @@ -331,7 +331,7 @@ void pickupeffects(int n, playerent *d) } } } - else audiomgr.playsound(is.sound, d); + else audiomgr.playsound(is->sound, d); } weapon *w = NULL; @@ -627,8 +627,8 @@ void entstats(void) { case MAPMODEL: { - mapmodelinfo &mmi = getmminfo(e.attr2); - if(&mmi && mmi.h) clipents++; + mapmodelinfo *mmi = getmminfo(e.attr2); + if(mmi && mmi->h) clipents++; break; } case PLAYERSTART: diff --git a/source/src/entity.h b/source/src/entity.h index 15ac37c4..e51c94bb 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -261,20 +261,20 @@ public: void resetstats() { loopi(NUMGUNS) pstatshots[i] = pstatdamage[i] = 0; } - itemstat &itemstats(int type) + itemstat *itemstats(int type) { switch(type) { - case I_CLIPS: return ammostats[GUN_PISTOL]; - case I_AMMO: return ammostats[primary]; - case I_GRENADE: return ammostats[GUN_GRENADE]; - case I_AKIMBO: return ammostats[GUN_AKIMBO]; + case I_CLIPS: return &ammostats[GUN_PISTOL]; + case I_AMMO: return &ammostats[primary]; + case I_GRENADE: return &ammostats[GUN_GRENADE]; + case I_AKIMBO: return &ammostats[GUN_AKIMBO]; case I_HEALTH: case I_HELMET: case I_ARMOUR: - return powerupstats[type-I_HEALTH]; + return &powerupstats[type-I_HEALTH]; default: - return *(itemstat *)0; + return NULL; } } @@ -672,4 +672,4 @@ struct package package() : name(NULL), type(-1), number(0), pending(false), source(NULL), curl(NULL) {} }; -#endif \ No newline at end of file +#endif diff --git a/source/src/physics.cpp b/source/src/physics.cpp index febd1955..4cfb59ba 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -130,15 +130,15 @@ bool mmcollide(physent *d, float &hi, float &lo) // collide with a map } else if(e.type==MAPMODEL) { - mapmodelinfo &mmi = getmminfo(e.attr2); - if(!&mmi || !mmi.h) continue; - const float r = mmi.rad+d->radius; + mapmodelinfo *mmi = getmminfo(e.attr2); + if(!mmi || !mmi->h) continue; + const float r = mmi->rad+d->radius; if(fabs(e.x-d->o.x)o.y)floor+mmi.zoff+e.attr3); + const float mmz = float(S(e.x, e.y)->floor+mmi->zoff+e.attr3); const float dz = d->o.z-eyeheight; if(dzlo) lo = mmz+mmi.h; + else if(mmz+mmi->h>lo) lo = mmz+mmi->h; if(hi-lo < playerheight) return true; } } diff --git a/source/src/protos.h b/source/src/protos.h index c11bbe16..2ce8ce39 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -710,7 +710,7 @@ extern void rendermodel(const char *mdl, int anim, int tex, float rad, const vec extern void startmodelbatches(); extern void endmodelbatches(bool flush = true); extern void clearmodelbatches(); -extern mapmodelinfo &getmminfo(int i); +extern mapmodelinfo *getmminfo(int i); extern int findanim(const char *name); extern void loadskin(const char *dir, const char *altdir, Texture *&skin); extern model *nomodel; diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 671bb3d2..3e8c305a 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -103,7 +103,7 @@ void mapmodelreset() if(execcontext==IEXC_MAPCFG) mapmodels.shrink(0); } -mapmodelinfo &getmminfo(int i) { return mapmodels.inrange(i) ? mapmodels[i] : *(mapmodelinfo *)0; } +mapmodelinfo *getmminfo(int i) { return mapmodels.inrange(i) ? &mapmodels[i] : NULL; } COMMAND(mapmodel, "iiiss"); COMMAND(mapmodelreset, ""); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 92428d57..23b017db 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -334,11 +334,11 @@ int intersect(playerent *d, const vec &from, const vec &to, vec *end) bool intersect(entity *e, const vec &from, const vec &to, vec *end) { - mapmodelinfo &mmi = getmminfo(e->attr2); - if(!&mmi || !mmi.h) return false; + mapmodelinfo *mmi = getmminfo(e->attr2); + if(!mmi || !mmi->h) return false; - float lo = float(S(e->x, e->y)->floor+mmi.zoff+e->attr3); - return intersectbox(vec(e->x, e->y, lo+mmi.h/2.0f), vec(mmi.rad, mmi.rad, mmi.h/2.0f), from, to, end); + float lo = float(S(e->x, e->y)->floor+mmi->zoff+e->attr3); + return intersectbox(vec(e->x, e->y, lo+mmi->h/2.0f), vec(mmi->rad, mmi->rad, mmi->h/2.0f), from, to, end); } playerent *intersectclosest(const vec &from, const vec &to, playerent *at, float &bestdist, int &hitzone, bool aiming = true)