Skip to content

Commit bd94964

Browse files
Fixes
1 parent a6eb796 commit bd94964

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

src/bsp/Bsp.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ Bsp::~Bsp()
382382
{
383383
delete ents[i];
384384
}
385+
ents.clear();
385386

386387
delete[] pvsFaces;
387388
//if (mdl)

src/bsp/bsptypes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ std::vector<int> getDiffModels(LumpState& oldLump, LumpState& newLump)
136136
if (newLump.lumps[LUMP_MODELS].size() > oldLump.lumps[LUMP_MODELS].size())
137137
{
138138
int curModelCount = (int)(oldLump.lumps[LUMP_MODELS].size() / sizeof(BSPMODEL));
139-
int addModelCount = (int)((newLump.lumps[LUMP_MODELS].size() - newLump.lumps[LUMP_MODELS].size()) / sizeof(BSPMODEL));
139+
int addModelCount = (int)((newLump.lumps[LUMP_MODELS].size() - oldLump.lumps[LUMP_MODELS].size()) / sizeof(BSPMODEL));
140140
for (int i = curModelCount; i < curModelCount + addModelCount; i++)
141141
{
142142
updateModels.push_back(i);

src/editor/Gui.cpp

+9-18
Original file line numberDiff line numberDiff line change
@@ -5347,6 +5347,7 @@ void Gui::drawMenuBar()
53475347

53485348
int aaatriggerIdx = map->GetTriggerTexture();
53495349
unsigned int dupLumps = FL_MARKSURFACES | FL_EDGES | FL_FACES | FL_NODES | FL_PLANES | FL_CLIPNODES | FL_SURFEDGES | FL_TEXINFO | FL_VERTICES | FL_LIGHTING | FL_MODELS | FL_LEAVES | FL_ENTITIES;
5350+
53505351
if (aaatriggerIdx == -1)
53515352
{
53525353
dupLumps |= FL_TEXTURES;
@@ -5357,23 +5358,15 @@ void Gui::drawMenuBar()
53575358
vec3 maxs = vec3(mdl_size, mdl_size, mdl_size);
53585359
int modelIdx = map->create_solid(mins, maxs, aaatriggerIdx, true);
53595360
newEnt->addKeyvalue("model", "*" + std::to_string(modelIdx));
5361+
map->ents.push_back(newEnt);
53605362

5361-
if (map->ents.size())
5363+
BSPMODEL& model = map->models[modelIdx];
5364+
for (int i = 0; i < model.nFaces; i++)
53625365
{
5363-
newEnt = map->ents[map->ents.size() - 1];
5364-
if (newEnt && newEnt->getBspModelIdx() >= 0)
5365-
{
5366-
BSPMODEL& model = map->models[newEnt->getBspModelIdx()];
5367-
for (int i = 0; i < model.nFaces; i++)
5368-
{
5369-
map->faces[model.iFirstFace + i].nStyles[0] = 0;
5370-
}
5371-
}
5366+
map->faces[model.iFirstFace + i].nStyles[0] = 0;
53725367
}
5373-
map->resize_all_lightmaps();
5374-
53755368

5376-
map->ents.push_back(newEnt);
5369+
map->resize_all_lightmaps();
53775370
rend->pushUndoState(get_localized_string(LANG_0589), dupLumps);
53785371
}
53795372

@@ -5390,7 +5383,7 @@ void Gui::drawMenuBar()
53905383
float mdl_size = 64.0f;
53915384

53925385
int aaatriggerIdx = map->GetTriggerTexture();
5393-
unsigned int dupLumps = FL_MARKSURFACES | FL_EDGES | FL_FACES | FL_NODES | FL_PLANES | FL_CLIPNODES | FL_SURFEDGES | FL_TEXINFO | FL_VERTICES | FL_LIGHTING | FL_MODELS | FL_LEAVES;
5386+
unsigned int dupLumps = FL_MARKSURFACES | FL_EDGES | FL_FACES | FL_NODES | FL_PLANES | FL_CLIPNODES | FL_SURFEDGES | FL_TEXINFO | FL_VERTICES | FL_LIGHTING | FL_MODELS | FL_LEAVES | FL_ENTITIES;
53945387
if (aaatriggerIdx == -1)
53955388
{
53965389
dupLumps |= FL_TEXTURES;
@@ -5401,6 +5394,7 @@ void Gui::drawMenuBar()
54015394
vec3 maxs = vec3(mdl_size, mdl_size, mdl_size);
54025395
int modelIdx = map->create_solid(mins, maxs, aaatriggerIdx, false);
54035396
newEnt->addKeyvalue("model", "*" + std::to_string(modelIdx));
5397+
map->ents.push_back(newEnt);
54045398

54055399
BSPMODEL& model = map->models[modelIdx];
54065400
for (int i = 0; i < model.nFaces; i++)
@@ -5409,8 +5403,7 @@ void Gui::drawMenuBar()
54095403
}
54105404

54115405
map->resize_all_lightmaps();
5412-
map->ents.push_back(newEnt);
5413-
rend->pushUndoState(get_localized_string(LANG_0589), dupLumps);
5406+
rend->pushUndoState(get_localized_string(LANG_0591), dupLumps);
54145407
}
54155408

54165409
if (ImGui::MenuItem(get_localized_string(LANG_0590).c_str(), 0, false, !app->isLoading && map))
@@ -5446,7 +5439,6 @@ void Gui::drawMenuBar()
54465439

54475440

54485441
map->resize_all_lightmaps();
5449-
map->ents.push_back(newEnt);
54505442
rend->pushUndoState(get_localized_string(LANG_0590), dupLumps);
54515443
}
54525444

@@ -5483,7 +5475,6 @@ void Gui::drawMenuBar()
54835475

54845476

54855477
map->resize_all_lightmaps();
5486-
map->ents.push_back(newEnt);
54875478
rend->pushUndoState("BSP Clip model", dupLumps);
54885479
}
54895480

0 commit comments

Comments
 (0)