Skip to content
Merged
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
10 changes: 2 additions & 8 deletions Core/GameEngine/Source/Common/System/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,9 @@ void DebugInit(int flags)

char dirbuf[ _MAX_PATH ];
::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) );
char *pEnd = dirbuf + strlen( dirbuf );
while( pEnd != dirbuf )
if (char *pEnd = strrchr(dirbuf, '\\'))
{
if( *pEnd == '\\' )
{
*(pEnd + 1) = 0;
break;
}
pEnd--;
*(pEnd + 1) = 0;
}

strcpy(theLogFileNamePrev, dirbuf);
Expand Down
10 changes: 2 additions & 8 deletions Core/GameEngine/Source/Common/System/GameMemoryInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,9 @@ void userMemoryManagerInitPools()
// we expect. so do it the hard way.
char buf[_MAX_PATH];
::GetModuleFileName(NULL, buf, sizeof(buf));
char* pEnd = buf + strlen(buf);
while (pEnd != buf)
if (char* pEnd = strrchr(buf, '\\'))
{
if (*pEnd == '\\')
{
*pEnd = 0;
break;
}
--pEnd;
*pEnd = 0;
}
strlcat(buf, "\\Data\\INI\\MemoryPools.ini", ARRAY_SIZE(buf));

Expand Down
9 changes: 2 additions & 7 deletions Core/Tools/MapCacheBuilder/Source/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,8 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
// Set the current directory to the app directory.
char buf[_MAX_PATH];
GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
::SetCurrentDirectory(buf);

Expand Down
10 changes: 2 additions & 8 deletions Generals/Code/GameEngine/Source/Common/MiniLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,9 @@ LogClass::LogClass(const char *fname)
{
char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
// TheSuperHackers @fix Caball009 03/06/2025 Don't use AsciiString here anymore because its memory allocator may not have been initialized yet.
const std::string fullPath = std::string(buffer) + "\\" + fname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,9 @@ LogClass::LogClass(const char *fname)
{
char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
// TheSuperHackers @fix Caball009 03/06/2025 Don't use AsciiString here anymore because its memory allocator may not have been initialized yet.
const std::string fullPath = std::string(buffer) + "\\" + fname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,9 @@ StatDumpClass::StatDumpClass( const char *fname )
{
char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
// TheSuperHackers @fix Caball009 03/06/2025 Don't use AsciiString here anymore because its memory allocator may not have been initialized yet.
const std::string fullPath = std::string(buffer) + "\\" + fname;
Expand Down
10 changes: 2 additions & 8 deletions Generals/Code/Main/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,15 +774,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
Char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (Char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
::SetCurrentDirectory(buffer);

Expand Down
10 changes: 2 additions & 8 deletions Generals/Code/Tools/GUIEdit/Source/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,9 @@ Int APIENTRY WinMain(HINSTANCE hInstance,
/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
Char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (Char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
::SetCurrentDirectory(buffer);

Expand Down
10 changes: 2 additions & 8 deletions Generals/Code/Tools/WorldBuilder/src/BuildList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,9 @@ void BuildList::OnExport()
try {
char dirbuf[ _MAX_PATH ];
::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) );
char *pEnd = dirbuf + strlen( dirbuf );
while( pEnd != dirbuf )
if (char *pEnd = strrchr(dirbuf, '\\'))
{
if( *pEnd == '\\' )
{
*(pEnd + 1) = 0;
break;
}
pEnd--;
*(pEnd + 1) = 0;
}

char curbuf[ _MAX_PATH ];
Expand Down
18 changes: 4 additions & 14 deletions Generals/Code/Tools/WorldBuilder/src/ScriptDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,13 +1140,8 @@ void ScriptDialog::OnSave()
// change it back.
char buf[_MAX_PATH];
::GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
::SetCurrentDirectory(buf);
if (IDCANCEL==result) {
Expand Down Expand Up @@ -1357,13 +1352,8 @@ void ScriptDialog::OnLoad()
// change it back.
char buf[_MAX_PATH];
::GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc();
::SetCurrentDirectory(buf);
Expand Down
9 changes: 2 additions & 7 deletions Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,8 @@ BOOL CWorldBuilderApp::InitInstance()
// Set the current directory to the app directory.
char buf[_MAX_PATH];
GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
::SetCurrentDirectory(buf);

Expand Down
19 changes: 4 additions & 15 deletions Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1359,13 +1359,8 @@ BOOL CWorldBuilderDoc::OnOpenDocument(LPCTSTR lpszPathName)

WbApp()->setCurrentDirectory(AsciiString(buf));
::GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
::SetCurrentDirectory(buf);

Expand Down Expand Up @@ -2105,15 +2100,9 @@ void CWorldBuilderDoc::OnDumpDocToText(void)
try {
char dirbuf[ _MAX_PATH ];
::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) );
char *pEnd = dirbuf + strlen( dirbuf );
while( pEnd != dirbuf )
if (char *pEnd = strrchr(dirbuf, '\\'))
{
if( *pEnd == '\\' )
{
*(pEnd + 1) = 0;
break;
}
pEnd--;
*(pEnd + 1) = 0;
}

char curbuf[ _MAX_PATH ];
Expand Down
10 changes: 2 additions & 8 deletions GeneralsMD/Code/GameEngine/Source/Common/MiniLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,9 @@ LogClass::LogClass(const char *fname)
{
char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
// TheSuperHackers @fix Caball009 03/06/2025 Don't use AsciiString here anymore because its memory allocator may not have been initialized yet.
const std::string fullPath = std::string(buffer) + "\\" + fname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,9 @@ LogClass::LogClass(const char *fname)
{
char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
// TheSuperHackers @fix Caball009 03/06/2025 Don't use AsciiString here anymore because its memory allocator may not have been initialized yet.
const std::string fullPath = std::string(buffer) + "\\" + fname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,9 @@ StatDumpClass::StatDumpClass( const char *fname )
{
char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
// TheSuperHackers @fix Caball009 03/06/2025 Don't use AsciiString here anymore because its memory allocator may not have been initialized yet.
const std::string fullPath = std::string(buffer) + "\\" + fname;
Expand Down
10 changes: 2 additions & 8 deletions GeneralsMD/Code/Main/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,15 +801,9 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
Char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (Char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
::SetCurrentDirectory(buffer);

Expand Down
10 changes: 2 additions & 8 deletions GeneralsMD/Code/Tools/GUIEdit/Source/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,9 @@ Int APIENTRY WinMain(HINSTANCE hInstance,
/// @todo remove this force set of working directory later
Char buffer[ _MAX_PATH ];
GetModuleFileName( NULL, buffer, sizeof( buffer ) );
Char *pEnd = buffer + strlen( buffer );
while( pEnd != buffer )
if (Char *pEnd = strrchr(buffer, '\\'))
{
if( *pEnd == '\\' )
{
*pEnd = 0;
break;
}
pEnd--;
*pEnd = 0;
}
::SetCurrentDirectory(buffer);

Expand Down
10 changes: 2 additions & 8 deletions GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,15 +739,9 @@ void BuildList::OnExport()
try {
char dirbuf[ _MAX_PATH ];
::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) );
char *pEnd = dirbuf + strlen( dirbuf );
while( pEnd != dirbuf )
if (char *pEnd = strrchr(dirbuf, '\\'))
{
if( *pEnd == '\\' )
{
*(pEnd + 1) = 0;
break;
}
pEnd--;
*(pEnd + 1) = 0;
}

char curbuf[ _MAX_PATH ];
Expand Down
18 changes: 4 additions & 14 deletions GeneralsMD/Code/Tools/WorldBuilder/src/ScriptDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,13 +1295,8 @@ void ScriptDialog::OnSave()
// change it back.
char buf[_MAX_PATH];
::GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
::SetCurrentDirectory(buf);
if (IDCANCEL==result) {
Expand Down Expand Up @@ -1519,13 +1514,8 @@ void ScriptDialog::OnLoad()
// change it back.
char buf[_MAX_PATH];
::GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
CWorldBuilderDoc* pDoc = CWorldBuilderDoc::GetActiveDoc();
::SetCurrentDirectory(buf);
Expand Down
9 changes: 2 additions & 7 deletions GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,8 @@ BOOL CWorldBuilderApp::InitInstance()
// Set the current directory to the app directory.
char buf[_MAX_PATH];
GetModuleFileName(NULL, buf, sizeof(buf));
char *pEnd = buf + strlen(buf);
while (pEnd != buf) {
if (*pEnd == '\\') {
*pEnd = 0;
break;
}
pEnd--;
if (char *pEnd = strrchr(buf, '\\')) {
*pEnd = 0;
}
::SetCurrentDirectory(buf);

Expand Down
Loading
Loading