diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp index aa966c69..8d34eec9 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/editing.cpp b/source/src/editing.cpp index cd7e04bc..c3f7c963 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -110,8 +110,8 @@ char *editinfo() const char *slotinfo = "unassigned slot"; if(t == MAPMODEL) { - mapmodelinfo &mmi = getmminfo(c.attr2); - if(&mmi) slotinfo = mmshortname(mmi.name); + mapmodelinfo *mmi = getmminfo(c.attr2); + if(mmi) slotinfo = mmshortname(mmi->name); } else if(t == SOUND) { diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 16a0934b..f7d84850 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -76,9 +76,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, S(e.x, e.y)->floor + mmi.zoff + float(e.attr3) / ENTSCALE5), e.attr6, float(e.attr1) / ENTSCALE10, float(e.attr5) / ENTSCALE10, 10.0f, 0, NULL, NULL, mmi.scale); + mapmodelinfo *mmi = getmminfo(e.attr2); + if(!mmi) continue; + rendermodel(mmi->name, ANIM_MAPMODEL|ANIM_LOOP, e.attr4, 0, vec(e.x, e.y, S(e.x, e.y)->floor + mmi->zoff + float(e.attr3) / ENTSCALE5), e.attr6, float(e.attr1) / ENTSCALE10, float(e.attr5) / ENTSCALE10, 10.0f, 0, NULL, NULL, mmi->scale); } } } @@ -234,14 +234,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 + float(e.attr3) / ENTSCALE5) * ENTSCALE10; - ce.attr2 = ce.attr3 = mmi.rad * ENTSCALE5; - ce.attr4 = mmi.h * ENTSCALE5; + ce.attr1 = (mmi->zoff + float(e.attr3) / ENTSCALE5) * ENTSCALE10; + ce.attr2 = ce.attr3 = mmi->rad * ENTSCALE5; + ce.attr4 = mmi->h * ENTSCALE5; ce.attr5 = ce.attr6 = ce.attr7 = 0; renderclip(ce); } @@ -316,13 +316,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: @@ -351,7 +351,7 @@ void pickupeffects(int n, playerent *d) if(tmp) exechook(HOOK_SP, "onPickup", "%d %d", e.type - 3, m_lss && e.type == I_GRENADE ? 2 : tmp->add); } } - else audiomgr.playsound(is.sound, d); + else audiomgr.playsound(is->sound, d); } weapon *w = NULL; @@ -645,8 +645,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 ef5a933b..c3aa260e 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -263,20 +263,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; } } diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 216ed3c9..3394cd53 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -168,15 +168,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 + float(e.attr3) / ENTSCALE5); + const float mmz = float(S(e.x, e.y)->floor + mmi->zoff + float(e.attr3) / ENTSCALE5); const float dz = d->o.z-eyeheight; if(dz < mmz - 0.42) { if(mmz < hi) hi = mmz; } - else if(mmz+mmi.h>lo) 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 fb527146..cce4a0ef 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -747,7 +747,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 *loadmodel(const char *name, int i = -1, bool trydl = false); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index a5df34ca..ede3e1af 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -140,7 +140,7 @@ void mapmodelreset() } COMMAND(mapmodelreset, ""); -mapmodelinfo &getmminfo(int i) { return mapmodels.inrange(i) ? mapmodels[i] : *(mapmodelinfo *)0; } +mapmodelinfo *getmminfo(int i) { return mapmodels.inrange(i) ? &mapmodels[i] : NULL; } COMMANDF(mapmodelslotname, "i", (int *idx) { result(mapmodels.inrange(*idx) ? mmshortname(mapmodels[*idx].name) : ""); }); // returns the model name that is configured in a certain slot COMMANDF(mapmodelslotbyname, "s", (char *name) // returns the slot(s) that a certain mapmodel is configured in diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 9330ed8f..815a0794 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -330,11 +330,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, const playerent *at, float &bestdist, int &hitzone, bool aiming = true) diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index e00fa572..1b0a0b14 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -425,9 +425,9 @@ void getcurrentmapconfig(vector &f, bool onlysounds) cvecprintf(f, "%smapmodelreset\n", f.length() ? "\n" : ""); loopi(256) { - mapmodelinfo &mmi = getmminfo(i); - if(!&mmi) break; - cvecprintf(f, "mapmodel %d %d %d %s \"%s\"\n", mmi.rad, mmi.h, mmi.zoff, mmi.scale == 1.0f ? "0" : floatstr(mmi.scale, true), mmshortname(mmi.name)); + mapmodelinfo *mmi = getmminfo(i); + if(!mmi) break; + cvecprintf(f, "mapmodel %d %d %d %s \"%s\"\n", mmi->rad, mmi->h, mmi->zoff, mmi->scale == 1.0f ? "0" : floatstr(mmi->scale, true), mmshortname(mmi->name)); } cvecprintf(f, "\ntexturereset\n"); loopi(256)