Skip to content

Commit 555193a

Browse files
authored
Merge pull request #503 from GeneralsOnlineDevelopmentTeam/plugins
Plugins branch back into mainline
2 parents 5794d5c + 2ec0d99 commit 555193a

37 files changed

Lines changed: 1240 additions & 98 deletions

Core/GameEngine/Source/Common/System/AsciiString.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ inline char* skipNonSeps(char* p, const char* seps)
7070
//-----------------------------------------------------------------------------
7171
inline char* skipWhitespace(char* p)
7272
{
73-
while (*p && isspace(*p))
73+
while (*p && isspace((unsigned char)*p))
7474
++p;
7575
return p;
7676
}
7777

7878
//-----------------------------------------------------------------------------
7979
inline char* skipNonWhitespace(char* p)
8080
{
81-
while (*p && !isspace(*p))
81+
while (*p && !isspace((unsigned char)*p))
8282
++p;
8383
return p;
8484
}
@@ -330,7 +330,7 @@ void AsciiString::trimEnd()
330330
// Clip trailing white space from the string.
331331
const int len = strlen(peek());
332332
int index = len;
333-
while (index > 0 && isspace(getCharAt(index - 1)))
333+
while (index > 0 && isspace((unsigned char)getCharAt(index - 1)))
334334
{
335335
--index;
336336
}
@@ -378,7 +378,7 @@ void AsciiString::toLower()
378378
char* c = buf;
379379
while (c && *c)
380380
{
381-
*c = tolower(*c);
381+
*c = (char)tolower((unsigned char)*c);
382382
c++;
383383
}
384384
set(buf);

Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include "../OnlineServices_Init.h"
5757
#include "Common/GameEngine.h"
5858
#include "Common/GlobalData.h"
59+
#include "../PluginInterfaces.h"
5960

6061

6162
///////////////////////////////////////////////////////////////////////////////////////
@@ -649,15 +650,15 @@ static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result,
649650
message.nextToken(&totalLine, "\n");
650651
message.nextToken(&winsLine, "\n");
651652
message.nextToken(&lossesLine, "\n");
652-
while (totalLine.isNotEmpty() && !isdigit(totalLine.getCharAt(0)))
653+
while (totalLine.isNotEmpty() && !isdigit((unsigned char)totalLine.getCharAt(0)))
653654
{
654655
totalLine = totalLine.str()+1;
655656
}
656-
while (winsLine.isNotEmpty() && !isdigit(winsLine.getCharAt(0)))
657+
while (winsLine.isNotEmpty() && !isdigit((unsigned char)winsLine.getCharAt(0)))
657658
{
658659
winsLine = winsLine.str()+1;
659660
}
660-
while (lossesLine.isNotEmpty() && !isdigit(lossesLine.getCharAt(0)))
661+
while (lossesLine.isNotEmpty() && !isdigit((unsigned char)lossesLine.getCharAt(0)))
661662
{
662663
lossesLine = lossesLine.str()+1;
663664
}
@@ -865,19 +866,45 @@ void StartPatchCheck()
865866
// GENERALS ONLINE
866867
NGMP_OnlineServicesManager::CreateInstance();
867868

868-
onlineCancelWindow = MessageBoxCancel(TheGameText->fetch("GUI:CheckingForPatches"),
869-
TheGameText->fetch("GUI:CheckingForPatches"), CancelPatchCheckCallbackAndReopenDropdown);
870-
871869
// online services must be initialized
872870
// TODO_NGMP: Uninit this when leaving MP, waste of resources and cycles
873871
NGMP_OnlineServicesManager::GetInstance()->Init();
874872

873+
// if we have an AC plugin loaded but the AC external process isnt running, show an error message
874+
if (AnticheatPlugInterface::IsPluginLoaded())
875+
{
876+
if (!AnticheatPlugInterface::IsExternalProcessRunning())
877+
{
878+
MessageBoxOk(TheGameText->fetchOrSubstitute("GUI:ACErrorHeader", L"AntiCheat Error"),
879+
TheGameText->fetchOrSubstitute("GUI:ACExternalProcessNotRunning", L"The AntiCheat external process is not running"),
880+
CancelPatchCheckCallbackAndReopenDropdown);
881+
882+
return;
883+
}
884+
}
885+
else if (AnticheatPlugInterface::DidPluginFailToLoad()) // Did we have something to load but it failed?
886+
{
887+
std::string strPlugin = NGMP_OnlineServicesManager::Settings.GetAnticheatPlugin();
888+
std::string pluginPath = std::format("plugins/{}/{}.dll", strPlugin.c_str(), strPlugin.c_str());
889+
890+
UnicodeString strErrorMssage;
891+
strErrorMssage.format(L"Failed to load the AntiCheat plugin from path: %hs. Please make sure the plugin is installed correctly.", pluginPath.c_str());
892+
893+
MessageBoxOk(TheGameText->fetchOrSubstitute("GUI:ACErrorHeader", L"AntiCheat Error"),
894+
strErrorMssage,
895+
CancelPatchCheckCallbackAndReopenDropdown);
896+
897+
return;
898+
}
899+
900+
onlineCancelWindow = MessageBoxCancel(TheGameText->fetch("GUI:CheckingForPatches"),
901+
TheGameText->fetch("GUI:CheckingForPatches"), CancelPatchCheckCallbackAndReopenDropdown);
902+
875903
NGMP_OnlineServicesManager::GetInstance()->StartVersionCheck([](bool bSuccess, bool bNeedsUpdate)
876904
{
877905
#if defined(USE_TEST_ENV) || defined(USE_DEBUG_ON_LIVE_SERVER)
878906
bNeedsUpdate = false;
879907
#endif
880-
881908
cantConnectBeforeOnline = !bSuccess;
882909
mustDownloadPatch = bNeedsUpdate;
883910

Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void GameResultsThreadClass::Thread_Function()
224224
// resolve the hostname
225225
const char *hostnameBuffer = req.hostname.c_str();
226226
UnsignedInt IP = 0xFFFFFFFF;
227-
if (isdigit(hostnameBuffer[0]))
227+
if (isdigit((unsigned char)hostnameBuffer[0]))
228228
{
229229
IP = inet_addr(hostnameBuffer);
230230
in_addr hostNode;

Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void PingThreadClass::Thread_Function()
262262
// resolve the hostname
263263
const char *hostnameBuffer = req.hostname.c_str();
264264
UnsignedInt IP = 0xFFFFFFFF;
265-
if (isdigit(hostnameBuffer[0]))
265+
if (isdigit((unsigned char)hostnameBuffer[0]))
266266
{
267267
IP = inet_addr(hostnameBuffer);
268268
in_addr hostNode;

Core/GameEngine/Source/GameNetwork/NAT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ void NAT::sendMangledPortNumberToTarget(UnsignedShort mangledPort, GameSlot *tar
11671167
void NAT::processGlobalMessage(Int slotNum, const char *options) {
11681168
const char *ptr = options;
11691169
// skip preceding whitespace.
1170-
while (isspace(*ptr)) {
1170+
while (isspace((unsigned char)*ptr)) {
11711171
++ptr;
11721172
}
11731173
DEBUG_LOG(("NAT::processGlobalMessage - got message from slot %d, message is \"%s\"", slotNum, ptr));

Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void dumpBufferToLog(const void *vBuf, Int len, const char *fname, Int line)
8080
for (dumpindex2 = 0; dumpindex2 < numBytesThisLine; ++dumpindex2)
8181
{
8282
char c = buf[offset + dumpindex2];
83-
DEBUG_LOG_RAW(("%c", (isprint(c)?c:'.')));
83+
DEBUG_LOG_RAW(("%c", (isprint((unsigned char)c)?c:'.')));
8484
}
8585
DEBUG_LOG_RAW(("\n"));
8686
}
@@ -105,7 +105,7 @@ UnsignedInt ResolveIP(AsciiString host)
105105
}
106106

107107
// String such as "127.0.0.1"
108-
if (isdigit(host.getCharAt(0)))
108+
if (isdigit((unsigned char)host.getCharAt(0)))
109109
{
110110
return ( ntohl(inet_addr(host.str())) );
111111
}

Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ void MilesAudioManager::reset()
480480
void MilesAudioManager::update()
481481
{
482482
AudioManager::update();
483+
484+
// Check audio device is initialized before updating
485+
if (m_digitalHandle == nullptr)
486+
{
487+
return; // Audio device not ready, skip update
488+
}
489+
483490
setDeviceListenerPosition();
484491
processRequestList();
485492
processPlayingList();
@@ -1193,15 +1200,21 @@ void MilesAudioManager::freeAllMilesHandles()
11931200
std::list<HSAMPLE>::iterator it;
11941201
for ( it = m_availableSamples.begin(); it != m_availableSamples.end(); /* empty */ ) {
11951202
HSAMPLE sample = *it;
1196-
AIL_release_sample_handle(sample);
1203+
if (sample != nullptr)
1204+
{
1205+
AIL_release_sample_handle(sample);
1206+
}
11971207
it = m_availableSamples.erase(it);
11981208
}
11991209
m_num2DSamples = 0;
12001210

12011211
std::list<H3DSAMPLE>::iterator it3D;
12021212
for ( it3D = m_available3DSamples.begin(); it3D != m_available3DSamples.end(); /* empty */ ) {
12031213
H3DSAMPLE sample3D = *it3D;
1204-
AIL_release_3D_sample_handle(sample3D);
1214+
if (sample3D != nullptr)
1215+
{
1216+
AIL_release_3D_sample_handle(sample3D);
1217+
}
12051218
it3D = m_available3DSamples.erase(it3D);
12061219
}
12071220
m_num3DSamples = 0;
@@ -1440,9 +1453,13 @@ AsciiString MilesAudioManager::getMusicTrackName() const
14401453
void MilesAudioManager::openDevice()
14411454
{
14421455
if (!TheGlobalData->m_audioOn) {
1456+
m_digitalHandle = nullptr;
14431457
return;
14441458
}
14451459

1460+
// Always clear handle at start - only set if initialization succeeds
1461+
m_digitalHandle = nullptr;
1462+
14461463
AIL_set_redist_directory("MSS\\");
14471464
AIL_startup();
14481465
Int retval = 0;
@@ -1453,22 +1470,31 @@ void MilesAudioManager::openDevice()
14531470

14541471
retval = AIL_quick_startup(audioSettings->m_useDigital, audioSettings->m_useMidi, audioSettings->m_outputRate, audioSettings->m_outputBits, audioSettings->m_outputChannels);
14551472

1456-
// Quick handles tells us where to store the various devices. For now, we're only interested in the digital handle.
1473+
if (!retval) {
1474+
// Initialization failed - ensure m_digitalHandle stays nullptr and audio is disabled
1475+
m_digitalHandle = nullptr;
1476+
setOn(false, AudioAffect_All);
1477+
return; // EXIT EARLY - don't continue with invalid device
1478+
}
1479+
1480+
// Only get handles if initialization succeeded
14571481
AIL_quick_handles(&m_digitalHandle, nullptr, nullptr);
14581482

1459-
if (retval) {
1460-
buildProviderList();
1461-
} else {
1462-
// if we couldn't initialize any devices, turn sound off (fail silently)
1463-
setOn( false, AudioAffect_All );
1483+
// If we still don't have a valid handle, disable audio
1484+
if (m_digitalHandle == nullptr) {
1485+
setOn(false, AudioAffect_All);
1486+
return;
14641487
}
14651488

1489+
// Device initialized successfully - proceed with setup
1490+
buildProviderList();
14661491
selectProvider(TheAudio->getProviderIndex(m_pref3DProvider));
14671492

14681493
// Now that we're all done, update the cached variables so that everything is in sync.
14691494
TheAudio->refreshCachedVariables();
14701495

14711496
if (!isValidProvider()) {
1497+
m_digitalHandle = nullptr; // Mark as invalid if provider check fails
14721498
return;
14731499
}
14741500

@@ -1478,9 +1504,13 @@ void MilesAudioManager::openDevice()
14781504
//-------------------------------------------------------------------------------------------------
14791505
void MilesAudioManager::closeDevice()
14801506
{
1481-
freeAllMilesHandles();
1482-
unselectProvider();
1483-
AIL_shutdown();
1507+
if (m_digitalHandle != nullptr)
1508+
{
1509+
freeAllMilesHandles();
1510+
unselectProvider();
1511+
AIL_shutdown();
1512+
m_digitalHandle = nullptr;
1513+
}
14841514
}
14851515

14861516
//-------------------------------------------------------------------------------------------------

Generals/Code/GameEngine/Source/Common/INI/INIWebpageURL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ AsciiString encodeURL(AsciiString source)
5555
const char *ptr = source.str();
5656
while (*ptr)
5757
{
58-
if (isalnum(*ptr) || allowedChars.find(*ptr))
58+
if (isalnum((unsigned char)*ptr) || allowedChars.find(*ptr))
5959
{
6060
target.concat(*ptr);
6161
}

Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static void readUntilSemicolon( File *fp, char *buffer, int maxBufLen )
260260
fp->read(buffer + i, 1);
261261

262262
// make all whitespace characters spaces
263-
if( isspace( buffer[ i ] ) )
263+
if( isspace( (unsigned char)buffer[ i ] ) )
264264
{
265265

266266
if( start == FALSE )

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ set(GAMEENGINE_SRC
11571157
Include/GameNetwork/GeneralsOnline/HTTP/HTTPManager.h
11581158
Include/GameNetwork/GeneralsOnline/HTTP/HTTPRequest.h
11591159
Include/GameNetwork/GeneralsOnline/NextGenTransport.h
1160+
Include/GameNetwork/GeneralsOnline/PluginInterfaces.h
11601161
Include/GameNetwork/GeneralsOnline/Vendor/ValveNetworkingSockets/steam/isteamnetworkingmessages.h
11611162
Include/GameNetwork/GeneralsOnline/Vendor/ValveNetworkingSockets/steam/isteamnetworkingsockets.h
11621163
Include/GameNetwork/GeneralsOnline/Vendor/ValveNetworkingSockets/steam/isteamnetworkingutils.h
@@ -1196,6 +1197,7 @@ set(GAMEENGINE_SRC
11961197
Source/GameNetwork/GeneralsOnline/OnlineServices_MatchmakingInterface.cpp
11971198
Source/GameNetwork/GeneralsOnline/NextGenTransport.cpp
11981199
Source/GameNetwork/GeneralsOnline/NetworkBitstream.cpp
1200+
Source/GameNetwork/GeneralsOnline/PluginInterfaces.cpp
11991201
)
12001202

12011203
if(RTS_GAMEMEMORY_ENABLE)

0 commit comments

Comments
 (0)