Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): use portable string and sleep names for Linux builds

Olcay Seygand4ad1692c109
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a48ea6a7b..ac95d04d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ found and fixed — EA's own, not port damage.**
- One game on every machine. A replay recorded on a Mac plays back on Linux and on Windows to the same checksum, and the other way round, and a Mac and a Linux PC have played a LAN match together without once disagreeing. A Mac or Linux game could not join a Windows one: the check every machine runs before a network game failed, because the Mac and Linux copies of the game's data files ended each line differently from Windows'. They agree now. A match between Windows and a Mac has not been played yet.
- Text on the Linux menus is as wide as on Windows. Linux has no Arial, and the font standing in for it reports a wider average letter, so every menu font the game sets to a fixed width came out a quarter narrower than it should, the "Generals" lettering and the menu buttons among them. Each is measured against Arial's own figure now, and lands within one percent of Windows.
- The game no longer crashes on some Linux PCs as its window opens. The game hands out memory its own way, and on Linux the graphics driver gets its memory from the game too. Some drivers, AMD's on Debian 12 among them, need every piece lined up on a 16-byte boundary, and the game's lined up on 4, so the start died or went through depending on where the pieces happened to fall. On Linux everything outside the game's own pools now comes from the system, which lines it up as the driver expects.
+- `./build-linux.sh` stopped on Linux Mint and Arch after the centred Classic interface went in: the new code compared layout names with a Windows-only spelling that GCC on Linux has never heard of. It uses the name every platform knows now, and so do the two debug-build spots with the same habit. Nobody has rebuilt on Linux since, so whether anything else stands in the way is not known yet.
- Windows on Arm laptops, the Snapdragon ones, get a build made for them. Microsoft never shipped those machines the library the game loads its textures and shaders through, so the game brings its own, the texture code the Mac and Linux versions already run. Switched on in place of Microsoft's library on an ordinary Windows PC, it draws the same battlefields, with no tree, house or patch of ground going missing. Nobody has played it on a Snapdragon laptop yet.
- Thanks to ilyasakin, whose port this is.
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index 949a98009..c85a11e90 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -2957,7 +2957,7 @@ void GameEngine::execute( void )
// I'm disabling this in internal because many people need alt-tab capability. If you happen to be
// doing performance tuning, please just change this on your local system. -MDC
if (TheTacticalView->getTimeMultiplier()<=1 && !TheScriptEngine->isTimeFast())
- ::Sleep(1); // give everyone else a tiny time slice.
+ sleepMilliseconds(1); // give everyone else a tiny time slice.
#endif
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
index e96485168..bd49f574a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp
@@ -538,7 +538,7 @@ static Bool barLaysOutItself( const char *filename )
{
static const char *const own[] = { "controlbar.wnd", "generalsexppoints.wnd", "genpowersshortcutbar" };
for( Int i = 0; i < (Int)ARRAY_SIZE( own ); i++ )
- if( strnicmp( filename, own[ i ], strlen( own[ i ] ) ) == 0 )
+ if( strncasecmp( filename, own[ i ], strlen( own[ i ] ) ) == 0 )
return TRUE;
return FALSE;
}
@@ -564,7 +564,7 @@ static Coord2D classicLayoutAnchor( const char *filename )
};
Coord2D anchor = { 0.5f, 0.5f };
for( Int i = 0; i < (Int)ARRAY_SIZE( anchors ); i++ )
- if( stricmp( name, anchors[ i ].name ) == 0 )
+ if( strcasecmp( name, anchors[ i ].name ) == 0 )
{
anchor.x = anchors[ i ].x;
anchor.y = anchors[ i ].y;
@@ -582,7 +582,7 @@ static Bool layoutIsShellScreen( const char *filename )
if( !startsWithFolder( filename, "menus" ) )
return FALSE;
for( const char *c = filename; *c; c++ )
- if( strnicmp( c, "loadscreen", 10 ) == 0 || strnicmp( c, "scorescreen", 11 ) == 0 )
+ if( strncasecmp( c, "loadscreen", 10 ) == 0 || strncasecmp( c, "scorescreen", 11 ) == 0 )
return TRUE;
// not the shell's own flag: a match's options screen is pushed onto the shell, over the battlefield
return !( TheGameLogic && TheGameLogic->isInGame() && !TheGameLogic->isInShellGame() );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 80ae1fb68..11ac736c0 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -5613,8 +5613,8 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
//-----------------------------------------------------------------------------------------
case GameMessage::MSG_META_DEBUG_OBJECT_ID_PERFORMANCE:
{
- static __int64 startTime64;
- static __int64 endTime64,freq64;
+ static Int64 startTime64;
+ static Int64 endTime64,freq64;
startTime64 = Clock_Ticks();
freq64 = Clock_Ticks_Per_Second();
Int numberLookups = 10000;
@@ -5663,8 +5663,8 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
//-----------------------------------------------------------------------------------------
case GameMessage::MSG_META_DEBUG_DRAWABLE_ID_PERFORMANCE:
{
- static __int64 startTime64;
- static __int64 endTime64,freq64;
+ static Int64 startTime64;
+ static Int64 endTime64,freq64;
startTime64 = Clock_Ticks();
freq64 = Clock_Ticks_Per_Second();
Int numberLookups = 10000;