Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5146d14
bugfix(savegame): Handle both separators in fallback map labels
bobtista Sep 25, 2026
32ce749
bugfix(generals): Handle both separators in fallback map labels
bobtista Sep 25, 2026
62dc016
refactor(savegame): Reuse the filename helper for fallback labels
bobtista Sep 27, 2026
655853c
refactor(generals): Reuse the filename helper for fallback labels
bobtista Sep 27, 2026
303b904
bugfix(savegame): Handle both separators wherever a file name is take…
bobtista Sep 29, 2026
eb6cd71
bugfix(generals): Handle both separators wherever a file name is take…
bobtista Sep 29, 2026
a1adbbf
bugfix(terrain): Compare water map filenames without separators
bobtista Sep 29, 2026
85d83f9
bugfix(generals): Compare water map filenames without separators
bobtista Sep 29, 2026
4ced5cf
refactor(pathutil): Apply filename review cleanup
bobtista Sep 30, 2026
de34e9d
refactor(generals): Align filename review cleanup
bobtista Sep 30, 2026
afd4bfc
refactor(pathutil): Simplify filename helpers and avoid string copies
bobtista Sep 30, 2026
dd372f0
refactor(generals): Align filename helper cleanup
bobtista Sep 30, 2026
f8aad45
bugfix(core): Handle both separators in remaining path checks
bobtista Oct 3, 2026
012ad70
bugfix(gui): Keep the window prefix for relative layout paths
bobtista Oct 5, 2026
af57a8e
bugfix(pathutil): Handle both separators in remaining engine path checks
bobtista Oct 7, 2026
252eec1
bugfix(generals): Handle both separators in remaining engine path checks
bobtista Oct 7, 2026
3816b16
refactor(pathutil): Use separator helpers for Windows API paths
bobtista Oct 7, 2026
88f6efa
refactor(debug): Use separator helpers in the debug library
bobtista Oct 7, 2026
b641008
bugfix(worldbuilder): Handle both separators in WorldBuilder paths
bobtista Oct 7, 2026
0792b21
bugfix(generals): Handle both separators in WorldBuilder paths
bobtista Oct 7, 2026
8af3d62
bugfix(tools): Handle both separators in tool paths
bobtista Oct 7, 2026
d9cc923
bugfix(generals): Handle both separators in tool paths
bobtista Oct 7, 2026
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
2 changes: 0 additions & 2 deletions Core/GameEngine/Include/GameNetwork/FileTransfer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class GameInfo;

// Convenience functions
AsciiString GetBasePathFromPath( AsciiString path );
AsciiString GetFileFromPath( AsciiString path );
AsciiString GetExtensionFromFile( AsciiString fname );
AsciiString GetBaseFileFromFile( AsciiString fname );
AsciiString GetPreviewFromMap( AsciiString path );
AsciiString GetINIFromMap( AsciiString path );
Expand Down
7 changes: 1 addition & 6 deletions Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,7 @@ AsciiString AudioEventRTS::generateFilenameExtension( AudioType audioTypeToPlay
//-------------------------------------------------------------------------------------------------
void AudioEventRTS::adjustForLocalization(AsciiString &strToAdjust)
{
const char *filename = strToAdjust.reverseFind('\\');
if (filename) {
filename += 1;
} else {
filename = strToAdjust.str();
}
const char *filename = getFileName(strToAdjust.str());

// try the localized version first so that we're guaranteed to get it
// even if the generic data directory holds a version of the file
Expand Down
21 changes: 8 additions & 13 deletions Core/GameEngine/Source/Common/CRCDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ void outputCRCDumpLines()
*/
}

static AsciiString getFname(AsciiString path)
{
return path.reverseFind('\\') + 1;
}

static void addCRCDebugLineInternal(bool count, const char *fmt, va_list args)
{
if (TheGameLogic == nullptr || !(IS_FRAME_OK_TO_LOG))
Expand Down Expand Up @@ -278,30 +273,30 @@ void dumpVector3(const Vector3 *v, AsciiString name, AsciiString fname, Int line
{
if (!(IS_FRAME_OK_TO_LOG)) return;
fname.toLower();
fname = getFname(fname);
const char* fileName = getFileName(fname.str());
addCRCDebugLine("dumpVector3() %s:%d %s %8.8X %8.8X %8.8X",
fname.str(), line, name.str(),
fileName, line, name.str(),
AS_INT(v->X), AS_INT(v->Y), AS_INT(v->Z));
}

void dumpCoord3D(const Coord3D *c, AsciiString name, AsciiString fname, Int line)
{
if (!(IS_FRAME_OK_TO_LOG)) return;
fname.toLower();
fname = getFname(fname);
const char* fileName = getFileName(fname.str());
addCRCDebugLine("dumpCoord3D() %s:%d %s %8.8X %8.8X %8.8X",
fname.str(), line, name.str(),
fileName, line, name.str(),
AS_INT(c->x), AS_INT(c->y), AS_INT(c->z));
}

void dumpMatrix3D(const Matrix3D *m, AsciiString name, AsciiString fname, Int line)
{
if (!(IS_FRAME_OK_TO_LOG)) return;
fname.toLower();
fname = getFname(fname);
const char* fileName = getFileName(fname.str());
const Real *matrix = (const Real *)m;
addCRCDebugLine("dumpMatrix3D() %s:%d %s",
fname.str(), line, name.str());
fileName, line, name.str());
for (Int i=0; i<3; ++i)
addCRCDebugLine(" 0x%08X 0x%08X 0x%08X 0x%08X",
AS_INT(matrix[(i<<2)+0]), AS_INT(matrix[(i<<2)+1]), AS_INT(matrix[(i<<2)+2]), AS_INT(matrix[(i<<2)+3]));
Expand All @@ -311,9 +306,9 @@ void dumpReal(Real r, AsciiString name, AsciiString fname, Int line)
{
if (!(IS_FRAME_OK_TO_LOG)) return;
fname.toLower();
fname = getFname(fname);
const char* fileName = getFileName(fname.str());
addCRCDebugLine("dumpReal() %s:%d %s %8.8X (%f)",
fname.str(), line, name.str(), AS_INT(r), r);
fileName, line, name.str(), AS_INT(r), r);
}

#endif // DEBUG_CRC
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/INI/INIMapCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void INI::parseMapCacheDefinition( INI* ini )
{
// maps without localized name tags
AsciiString tempdisplayname;
tempdisplayname = name.reverseFind('\\') + 1;
tempdisplayname = getFileName(name.str());
md.m_displayName.translate(tempdisplayname);
if (md.m_numPlayers >= 2)
{
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/MiniLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LogClass::LogClass(const char *fname)
{
char buffer[ _MAX_PATH ];
GetModuleFileName( nullptr, buffer, sizeof( buffer ) );
if (char *pEnd = strrchr(buffer, '\\'))
if (char *pEnd = getLastPathSeparator(buffer))
{
*pEnd = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void DebugInit(int flags)

char dirbuf[ _MAX_PATH ];
::GetModuleFileName( nullptr, dirbuf, sizeof( dirbuf ) );
if (char *pEnd = strrchr(dirbuf, '\\'))
if (char *pEnd = getLastPathSeparator(dirbuf))
{
*(pEnd + 1) = 0;
}
Expand Down
1 change: 0 additions & 1 deletion Core/GameEngine/Source/Common/System/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#include "Common/LocalFileSystem.h"
#include "Common/PerfTimer.h"

#include "Lib/PathUtil.h"


DECLARE_PERF_TIMER(FileSystem)
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/System/GameMemoryInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void userMemoryManagerInitPools()
// we expect. so do it the hard way.
char buf[_MAX_PATH];
::GetModuleFileName(nullptr, buf, sizeof(buf));
if (char* pEnd = strrchr(buf, '\\'))
if (char* pEnd = getLastPathSeparator(buf))
{
*pEnd = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/GameEngine/Source/Common/WorkingDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Bool WorkingDirectory::setExecutableWorkingDirectory()
return FALSE;
}

Char *pEnd = strrchr(buffer, '\\');
Char *pEnd = getLastPathSeparator(buffer);
if (pEnd == nullptr)
{
DEBUG_LOG(("Executable path has no directory: '%s'", buffer));
Expand Down
8 changes: 4 additions & 4 deletions Core/GameEngine/Source/GameClient/MapUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ Bool MapCache::loadMapsFromDisk( const AsciiString &mapDir, Bool isOfficial, Boo
AsciiString filepathLower = *filepathIt;
filepathLower.toLower();

const char *szFilenameLower = filepathLower.reverseFind('\\');
const char *szFilenameLower = getLastPathSeparator(filepathLower.str());
if (!szFilenameLower)
{
DEBUG_CRASH(("Couldn't find \\ in map name!"));
Expand Down Expand Up @@ -592,7 +592,7 @@ Bool MapCache::addMap(
{
// unofficial maps or maps without names
AsciiString tempdisplayname;
tempdisplayname = fname.reverseFind('\\') + 1;
tempdisplayname = getFileName(fname.str());
(*this)[lowerFname].m_displayName.translate(tempdisplayname);
if (md.m_numPlayers >= 2)
{
Expand Down Expand Up @@ -654,7 +654,7 @@ Bool MapCache::addMap(
{
DEBUG_LOG(("Missing TheKey_mapName!"));
AsciiString tempdisplayname;
tempdisplayname = fname.reverseFind('\\') + 1;
tempdisplayname = getFileName(fname.str());
md.m_displayName.translate(tempdisplayname);
if (md.m_numPlayers >= 2)
{
Expand Down Expand Up @@ -1156,7 +1156,7 @@ Image *getMapPreviewImage( AsciiString mapName )
for(Int i = 0; i < portableName.getLength(); ++i)
{
char c = portableName.getCharAt(i);
if (c == '\\' || c == ':')
if (isPathSeparator(c) || c == ':')
tempName.concat('_');
else
tempName.concat(c);
Expand Down
21 changes: 3 additions & 18 deletions Core/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,26 +1140,11 @@ void TerrainLogic::enableWaterGrid( Bool enable )
// the fact that the map Data\CHI01\CHI01.map will turn into Save\CHI01.map when
// loading the map from a save game file
//
AsciiString strippedMapNameOnly;
AsciiString strippedCompareMapNameOnly;
const char *c;

// create stripped map name
c = strrchr( TheGlobalData->m_mapName.str(), '\\' );
if( c )
strippedMapNameOnly.set( c );
else
strippedMapNameOnly = TheGlobalData->m_mapName;

// create stripped compare name
c = strrchr( TheGlobalData->m_vertexWaterAvailableMaps[ i ].str(), '\\' );
if( c )
strippedCompareMapNameOnly.set( c );
else
strippedCompareMapNameOnly = TheGlobalData->m_vertexWaterAvailableMaps[ i ];
const char* strippedMapNameOnly = getFileName( TheGlobalData->m_mapName.str() );
const char* strippedCompareMapNameOnly = getFileName( TheGlobalData->m_vertexWaterAvailableMaps[ i ].str() );

// now try this compare
if( strippedMapNameOnly.compareNoCase( strippedCompareMapNameOnly.str() ) == 0 )
if( stricmp( strippedMapNameOnly, strippedCompareMapNameOnly ) == 0 )
{

waterSettingIndex = i;
Expand Down
38 changes: 5 additions & 33 deletions Core/GameEngine/Source/GameNetwork/FileTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,55 +137,27 @@ static Bool doFileTransfer( AsciiString filename, MapTransferLoadScreen *ls, Int

AsciiString GetBasePathFromPath( AsciiString path )
{
const char *s = path.reverseFind('\\');
const char *s = getLastPathSeparator(path.str());
if (s)
{
Int len = s - path.str();

AsciiString base;
char *buf = base.getBufferForRead(len + 1);
memcpy(buf, path.str(), len);
buf[len] = 0;
return buf;
return AsciiString(path.str(), s - path.str());
}
return AsciiString::TheEmptyString;
}

AsciiString GetFileFromPath( AsciiString path )
{
const char *s = path.reverseFind('\\');
if (s)
return s+1;
return path;
}

AsciiString GetExtensionFromFile( AsciiString fname )
{
const char *s = fname.reverseFind('.');
if (s)
return s+1;
return fname;
}

AsciiString GetBaseFileFromFile( AsciiString fname )
{
const char *s = fname.reverseFind('.');
const char *s = getExtension(fname.str());
if (s)
{
Int len = s - fname.str();

AsciiString base;
char *buf = base.getBufferForRead(len + 1);
memcpy(buf, fname.str(), len);
buf[len] = 0;
return buf;
return AsciiString(fname.str(), s - fname.str());
}
return AsciiString::TheEmptyString;
}

AsciiString GetPreviewFromMap( AsciiString path )
{
AsciiString fname = GetBaseFileFromFile(GetFileFromPath(path));
AsciiString fname = GetBaseFileFromFile(getFileName(path.str()));
AsciiString base = GetBasePathFromPath(path);

AsciiString out;
Expand Down
4 changes: 2 additions & 2 deletions Core/GameEngine/Source/GameNetwork/GameInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void GameInfo::setMap( AsciiString mapName )
// directory name, we can do this since the filename
// is just the directory name with the file extention
// added onto it.
while (mapName.find('\\') != nullptr)
while (getLastPathSeparator(mapName.str()) != nullptr)
{
if (!newMapName.isEmpty())
{
Expand Down Expand Up @@ -973,7 +973,7 @@ static AsciiString buildGameInfoAsciiString(const GameInfo& game, const AsciiStr
// directory name, we can do this since the filename
// is just the directory name with the file extention
// added onto it.
while (mapName.find('\\') != nullptr)
while (getLastPathSeparator(mapName.str()) != nullptr)
{
if (!newMapName.isEmpty())
{
Expand Down
22 changes: 2 additions & 20 deletions Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,7 @@ static void gameTooltip(GameWindow *window,
}
else
{
const char *start = room->getMap().reverseFind('\\');
if (start)
{
++start;
}
else
{
start = room->getMap().str();
}
mapName.translate( start );
mapName.translate( getFileName(room->getMap().str()) );
}
UnicodeString tmp;
tooltip.format(TheGameText->fetch("TOOLTIP:GameInfoGameName"), room->getGameName().str());
Expand Down Expand Up @@ -584,16 +575,7 @@ static Int insertGame( GameWindow *win, GameSpyStagingRoom *game, Bool showMap )
}
else
{
const char *start = game->getMap().reverseFind('\\');
if (start)
{
++start;
}
else
{
start = game->getMap().str();
}
mapName.translate( start );
mapName.translate( getFileName(game->getMap().str()) );
}
GadgetListBoxAddEntryText(win, mapName, gameColor, index, COLUMN_MAP);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL

AudioEventRTS *event = playing->m_audioEventRTS.Peek();
filenameNoSlashes = event->getFilename();
filenameNoSlashes = filenameNoSlashes.reverseFind('\\') + 1;
filenameNoSlashes = getFileName(filenameNoSlashes.str());

// Calculate Sample volume
volume = 100.0f;
Expand All @@ -265,7 +265,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
playing = *it;
AudioEventRTS *event = playing->m_audioEventRTS.Peek();
filenameNoSlashes = event->getFilename();
filenameNoSlashes = filenameNoSlashes.reverseFind( '\\' ) + 1;
filenameNoSlashes = getFileName(filenameNoSlashes.str());

// Calculate Sample volume
volume = 100.0f;
Expand Down Expand Up @@ -302,7 +302,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL

AudioEventRTS *event = playing->m_audioEventRTS.Peek();
filenameNoSlashes = event->getFilename();
filenameNoSlashes = filenameNoSlashes.reverseFind('\\') + 1;
filenameNoSlashes = getFileName(filenameNoSlashes.str());

// Calculate Sample volume
volume = 100.0f;
Expand Down Expand Up @@ -354,7 +354,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
playing = *it;
AudioEventRTS *event = playing->m_audioEventRTS.Peek();
filenameNoSlashes = event->getFilename();
filenameNoSlashes = filenameNoSlashes.reverseFind('\\') + 1;
filenameNoSlashes = getFileName(filenameNoSlashes.str());

// Calculate Sample volume
volume = 100.0f;
Expand All @@ -378,7 +378,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
playing = *it;
AudioEventRTS *event = playing->m_audioEventRTS.Peek();
filenameNoSlashes = event->getFilename();
filenameNoSlashes = filenameNoSlashes.reverseFind('\\') + 1;
filenameNoSlashes = getFileName(filenameNoSlashes.str());

// Calculate Sample volume
volume = 100.0f;
Expand All @@ -402,7 +402,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL
playing = *it;
AudioEventRTS *event = playing->m_audioEventRTS.Peek();
filenameNoSlashes = event->getFilename();
filenameNoSlashes = filenameNoSlashes.reverseFind('\\') + 1;
filenameNoSlashes = getFileName(filenameNoSlashes.str());

// Calculate Sample volume
volume = 100.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ LogClass::LogClass(const char *fname)
{
char buffer[ _MAX_PATH ];
GetModuleFileName( nullptr, buffer, sizeof( buffer ) );
if (char *pEnd = strrchr(buffer, '\\'))
if (char *pEnd = getLastPathSeparator(buffer))
{
*pEnd = 0;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ void LogClass::log(const char *fmt, ...)
void LogClass::dumpMatrix3D(const Matrix3D *m, AsciiString name, AsciiString fname, Int line)
{
fname.toLower();
fname = fname.reverseFind('\\') + 1;
fname = getFileName(fname.str());
const Real *matrix = (const Real *)m;
log("dumpMatrix3D() %s:%d %s",
fname.str(), line, name.str());
Expand All @@ -166,7 +166,7 @@ void LogClass::dumpReal(Real r, AsciiString name, AsciiString fname, Int line)
if (!m_fp || !isValidTimeToCalcLogicStuff())
return;
fname.toLower();
fname = fname.reverseFind('\\') + 1;
fname = getFileName(fname.str());
log("dumpReal() %s:%d %s %8.8X (%f)",
fname.str(), line, name.str(), AS_INT(r), r);
}
Expand Down
Loading
Loading