Skip to content

Commit

Permalink
std::string in model object
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Sep 30, 2023
1 parent 95cca2f commit ada15e3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/engine/model/animmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ void animmodel::part::setanim(int animpart, int num, int frame, int range, float
}
if(frame<0 || range<=0 || !meshes || !meshes->hasframes(frame, range))
{
conoutf("invalid frame %d, range %d in model %s", frame, range, model->name);
conoutf("invalid frame %d, range %d in model %s", frame, range, model->name.c_str());
return;
}
if(!anims[animpart])
Expand Down
6 changes: 3 additions & 3 deletions src/engine/model/animmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ struct modelloader : BASE

bool loadconfig()
{
formatstring(dir, "media/model/%s", BASE::name);
DEF_FORMAT_STRING(cfgname, "media/model/%s/%s.cfg", BASE::name, MDL::formatname());
formatstring(dir, "media/model/%s", BASE::name.c_str());
DEF_FORMAT_STRING(cfgname, "media/model/%s/%s.cfg", BASE::name.c_str(), MDL::formatname());

identflags &= ~Idf_Persist;
bool success = execfile(cfgname, false);
Expand Down Expand Up @@ -809,7 +809,7 @@ struct modelcommands
}
if(!MDL::loading->parts[*parent]->link(MDL::loading->parts[*child], tagname, vec(*x, *y, *z)))
{
conoutf("could not link model %s", MDL::loading->name);
conoutf("could not link model %s", MDL::loading->name.c_str());
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/engine/model/md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ md5::skelmeshgroup *md5::newmeshes()
bool md5::loaddefaultparts()
{
skelpart &mdl = addpart();
const char *fname = name + std::strlen(name);
const char *fname = name.c_str() + std::strlen(name.c_str());
do
{
--fname;
} while(fname >= name && *fname!='/' && *fname!='\\');
fname++;
DEF_FORMAT_STRING(meshname, "media/model/%s/%s.md5mesh", name, fname);
DEF_FORMAT_STRING(meshname, "media/model/%s/%s.md5mesh", name.c_str(), fname);
mdl.meshes = sharemeshes(path(meshname));
if(!mdl.meshes)
{
return false;
}
mdl.initanimparts();
mdl.initskins();
DEF_FORMAT_STRING(animname, "media/model/%s/%s.md5anim", name, fname);
DEF_FORMAT_STRING(animname, "media/model/%s/%s.md5anim", name.c_str(), fname);
static_cast<md5meshgroup *>(mdl.meshes)->loadanim(path(animname));
return true;
}
Expand Down
4 changes: 1 addition & 3 deletions src/engine/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum
class model
{
public:
const char *name;
std::string name;
float spinyaw, spinpitch, spinroll, offsetyaw, offsetpitch, offsetroll;
bool shadow, alphashadow, depthoffset;
float scale;
Expand All @@ -32,8 +32,6 @@ class model

virtual ~model()
{
delete[] name;
name = nullptr;
if(bih)
{
delete bih;
Expand Down
6 changes: 3 additions & 3 deletions src/engine/model/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ void obj::objmeshgroup::flushmesh(const string meshname,
bool obj::loaddefaultparts()
{
part &mdl = addpart();
const char *pname = parentdir(name);
DEF_FORMAT_STRING(name1, "media/model/%s/tris.obj", name);
const char *pname = parentdir(name.c_str());
DEF_FORMAT_STRING(name1, "media/model/%s/tris.obj", name.c_str());
mdl.meshes = sharemeshes(path(name1));
if(!mdl.meshes)
{
Expand All @@ -301,7 +301,7 @@ bool obj::loaddefaultparts()
}
}
Texture *tex, *masks;
loadskin(name, pname, tex, masks);
loadskin(name.c_str(), pname, tex, masks);
mdl.initskins(tex, masks);
if(tex==notexture)
{
Expand Down
2 changes: 1 addition & 1 deletion src/engine/render/rendermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static void mdlname()
{
return;
}
result(loadingmodel->name);
result(loadingmodel->name.c_str());
}

// if a skeletal model is being loaded, and meets the criteria for a ragdoll,
Expand Down

0 comments on commit ada15e3

Please sign in to comment.