Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/Upgrade.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class UpgradeCenter : public SubsystemInterface
void reset( void ); ///< subsystem interface
void update( void ) { } ///< subsystem interface

void deleteAllUpgrades();
UpgradeTemplate *firstUpgradeTemplate( void ); ///< return the first upgrade template
const UpgradeTemplate *findUpgradeByKey( NameKeyType key ) const; ///< find upgrade by name key
const UpgradeTemplate *findUpgrade( const AsciiString& name ) const; ///< find and return upgrade by name
Expand Down
50 changes: 33 additions & 17 deletions GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Common/Upgrade.h"
#include "Common/Player.h"
#include "Common/Xfer.h"
#include "Common/XferCRC.h"
#include "GameClient/InGameUI.h"
#include "GameClient/Image.h"

Expand Down Expand Up @@ -236,23 +237,7 @@ UpgradeCenter::UpgradeCenter( void )
//-------------------------------------------------------------------------------------------------
UpgradeCenter::~UpgradeCenter( void )
{

// delete all the upgrades loaded from the INI database
UpgradeTemplate *next;
while( m_upgradeList )
{

// get next
next = m_upgradeList->friend_getNext();

// delete head of list
deleteInstance(m_upgradeList);

// set head to next element
m_upgradeList = next;

}

deleteAllUpgrades();
}

//-------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -284,6 +269,17 @@ void UpgradeCenter::init( void )
//-------------------------------------------------------------------------------------------------
void UpgradeCenter::reset( void )
{
// TheSuperHackers @bugfix helmutbuhler 26/10/2025
// When a custom map with a map.ini overrides some upgrades, we need to undo that here
// to avoid mismatches. For now we just reload the original ini files.
deleteAllUpgrades();
init();
XferCRC xferCRC;
xferCRC.open("lightCRC");
INI ini;
ini.loadFileDirectory("Data\\INI\\Default\\Upgrade", INI_LOAD_OVERWRITE, &xferCRC);
ini.loadFileDirectory("Data\\INI\\Upgrade", INI_LOAD_OVERWRITE, &xferCRC);

if( TheMappedImageCollection && !buttonImagesCached )
{
UpgradeTemplate *upgrade;
Expand All @@ -295,6 +291,26 @@ void UpgradeCenter::reset( void )
}
}

void UpgradeCenter::deleteAllUpgrades()
{
// delete all the upgrades loaded from the INI database
UpgradeTemplate *next;
while( m_upgradeList )
{
// get next
next = m_upgradeList->friend_getNext();

// delete head of list
deleteInstance(m_upgradeList);

// set head to next element
m_upgradeList = next;
}
m_upgradeList = NULL;
m_nextTemplateMaskBit = 0;
buttonImagesCached = FALSE;
}

//-------------------------------------------------------------------------------------------------
/** Find upgrade matching name key */
//-------------------------------------------------------------------------------------------------
Expand Down
Loading