Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ZoneTool/zonetool into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
RektInator committed Jan 9, 2020
2 parents b8d3390 + bc7c1a0 commit a0b4dcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
7 changes: 3 additions & 4 deletions src/IW4/Assets/AddonMapEnts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ namespace ZoneTool
auto ents = mem->Alloc<AddonMapEnts>();

ents->name = mem->StrDup(name);
ents->numEntityChars = FileSystem::FileSize(file);
ents->numEntityChars = FileSystem::FileSize(file) + 1;

ents->entityString = mem->Alloc<char>(ents->numEntityChars + 1);
ents->entityString = mem->Alloc<char>(ents->numEntityChars);
memset((char*)ents->entityString, 0, ents->numEntityChars);
fread((char*)ents->entityString, ents->numEntityChars, 1, file);
ents->numEntityChars++;
fread((char*)ents->entityString, ents->numEntityChars - 1, 1, file);

// convert the mapents!
IMapEnts::ConvertEnts(reinterpret_cast<MapEnts*>(ents), mem);
Expand Down
13 changes: 5 additions & 8 deletions src/IW4/Assets/MapEnts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,11 @@ namespace ZoneTool
// replace mapents if needed
if (!newEntsString.empty())
{
ents->numEntityChars = newEntsString.size();
ents->entityString = mem->Alloc<char>(ents->numEntityChars + 1);
memcpy((void*)ents->entityString, &newEntsString[0], ents->numEntityChars);
ents->numEntityChars = newEntsString.size() + 1;
ents->entityString = mem->Alloc<char>(ents->numEntityChars);
memset((void*)ents->entityString, 0, ents->numEntityChars);
memcpy((void*)ents->entityString, &newEntsString[0], ents->numEntityChars - 1);
}

//auto fp_ = fopen("output.d3dbsp.ents", "wb");
//fwrite(ents->entityString, ents->numEntityChars, 1, fp_);
//fclose(fp_);
}

/*legacy zonetool code, refactor me!*/
Expand Down Expand Up @@ -281,7 +278,7 @@ namespace ZoneTool

void IMapEnts::init(const std::string& name, ZoneMemory* mem)
{
this->name_ = "maps/mp/" + currentzone + ".d3dbsp"; // name;
this->name_ = "maps/"s + (currentzone.substr(0, 3) == "mp_" ? "mp/" : "") + currentzone + ".d3dbsp"; // name;
this->asset_ = this->parse(name, mem);

if (!this->asset_)
Expand Down

0 comments on commit a0b4dcd

Please sign in to comment.