Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 019a63d

Browse files
authored
Second memory leak fix
1 parent f23a450 commit 019a63d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

game/server/wcedit.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
1+
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
22
//
33
// Purpose: Namespace for functions having to do with WC Edit mode
44
//
@@ -450,6 +450,19 @@ Vector *g_EntityPositions = NULL;
450450
QAngle *g_EntityOrientations = NULL;
451451
string_t *g_EntityClassnames = NULL;
452452

453+
// Secton: memory leak fix (https://developer.valvesoftware.com/wiki/Memory_Leak_Fixes#WCEdit)
454+
455+
class GlobalCleanUp : public CAutoGameSystem
456+
{
457+
void Shutdown()
458+
{
459+
delete [] g_EntityPositions;
460+
delete [] g_EntityOrientations;
461+
delete [] g_EntityClassnames;
462+
delete this;
463+
}
464+
};
465+
453466
//-----------------------------------------------------------------------------
454467
// Purpose: Saves the entity's position for future communication with Hammer
455468
//-----------------------------------------------------------------------------
@@ -460,6 +473,7 @@ void NWCEdit::RememberEntityPosition( CBaseEntity *pEntity )
460473

461474
if ( !g_EntityPositions )
462475
{
476+
new GlobalCleanUp();
463477
g_EntityPositions = new Vector[NUM_ENT_ENTRIES];
464478
g_EntityOrientations = new QAngle[NUM_ENT_ENTRIES];
465479
// have to save these too because some entities change the classname on spawn (e.g. prop_physics_override, physics_prop)

0 commit comments

Comments
 (0)