Skip to content

Commit

Permalink
expand mapmodel namespace to all occurences
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Sep 1, 2024
1 parent a0325f8 commit 3bf65c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/engine/render/rendermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ std::vector<std::string> animnames; //set by game at runtime

model *loadmapmodel(int n)
{
if(static_cast<int>(mapmodels.size()) > n)
if(static_cast<int>(mapmodel::mapmodels.size()) > n)
{
model *m = mapmodels[n].m;
model *m = mapmodel::mapmodels[n].m;
return m ? m : loadmodel("", n);
}
return nullptr;
Expand Down Expand Up @@ -176,15 +176,15 @@ void preloadusedmapmodels(bool msg, bool bih)
{
loadprogress = static_cast<float>(i+1)/used.size();
int mmindex = used[i];
if(!(static_cast<int>(mapmodels.size()) > (mmindex)))
if(!(static_cast<int>(mapmodel::mapmodels.size()) > (mmindex)))
{
if(msg)
{
conoutf(Console_Warn, "could not find map model: %d", mmindex);
}
continue;
}
const mapmodelinfo &mmi = mapmodels[mmindex];
const mapmodelinfo &mmi = mapmodel::mapmodels[mmindex];
if(mmi.name.empty())
{
continue;
Expand Down Expand Up @@ -250,11 +250,11 @@ model *loadmodel(std::string_view name, int i, bool msg)

if(!name.size())
{
if(!(static_cast<int>(mapmodels.size()) > i))
if(!(static_cast<int>(mapmodel::mapmodels.size()) > i))
{
return nullptr;
}
const mapmodelinfo &mmi = mapmodels[i];
const mapmodelinfo &mmi = mapmodel::mapmodels[i];
if(mmi.m)
{
return mmi.m;
Expand Down Expand Up @@ -304,9 +304,9 @@ model *loadmodel(std::string_view name, int i, bool msg)
models[m->modelname()] = m;
}
}
if((mapmodels.size() > static_cast<uint>(i)) && !mapmodels[i].m)
if((mapmodel::mapmodels.size() > static_cast<uint>(i)) && !mapmodel::mapmodels[i].m)
{
mapmodels[i].m = m;
mapmodel::mapmodels[i].m = m;
}
return m;
}
Expand Down Expand Up @@ -341,7 +341,7 @@ static void clearmodel(const char *name)
conoutf("model %s is not loaded", name);
return;
}
for(mapmodelinfo &mmi : mapmodels)
for(mapmodelinfo &mmi : mapmodel::mapmodels)
{
if(mmi.m == m)
{
Expand Down Expand Up @@ -851,11 +851,11 @@ void clearbatchedmapmodels()

void rendermapmodel(int idx, int anim, const vec &o, float yaw, float pitch, float roll, int flags, int basetime, float size)
{
if(!(static_cast<int>(mapmodels.size()) > idx))
if(!(static_cast<int>(mapmodel::mapmodels.size()) > idx))
{
return;
}
const mapmodelinfo &mmi = mapmodels[idx];
const mapmodelinfo &mmi = mapmodel::mapmodels[idx];
model *m = mmi.m ? mmi.m : loadmodel(mmi.name.c_str());
if(!m)
{
Expand Down
6 changes: 5 additions & 1 deletion src/engine/render/rendermodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ struct mapmodelinfo
*collide;
};

extern std::vector<mapmodelinfo> mapmodels;
namespace mapmodel
{
extern std::vector<mapmodelinfo> mapmodels;
}

extern std::vector<std::string> animnames; //set by game at runtime

extern void loadskin(const std::string &dir, const std::string &altdir, Texture *&skin, Texture *&masks);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/world/physics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,11 @@ static bool mmcollide(const physent *d, const vec &dir, float cutoff, const octa
for(const int &i : oc.mapmodels)
{
extentity &e = *ents[i];
if(e.flags&EntFlag_NoCollide || !(static_cast<int>(mapmodels.size()) > e.attr1))
if(e.flags&EntFlag_NoCollide || !(static_cast<int>(mapmodel::mapmodels.size()) > e.attr1))
{
continue;
}
mapmodelinfo &mmi = mapmodels[e.attr1];
mapmodelinfo &mmi = mapmodel::mapmodels[e.attr1];
model *m = mmi.collide;
if(!m)
{
Expand Down

0 comments on commit 3bf65c5

Please sign in to comment.