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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
build(gameengine): port GameEngine to CMake with a boot self-check
Olcay Seygan159469c9deb2
diff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txtindex c14ec913e..a0e0dc56d 100644--- a/GeneralsMD/Code/CMakeLists.txt+++ b/GeneralsMD/Code/CMakeLists.txt@@ -225,6 +225,17 @@ target_link_libraries(debug PUBLIC dbghelp comctl32 ws2_32)# passed as a plain library name. Link this alias instead.add_library(debuglib ALIAS debug)+# ---- profile --------------------------------------------------------------+# EA's in-repo sampling/function profiler. GameEngine includes profile.h, whose+# #pragma comment(lib, "profile.lib") makes this a hard link dependency even+# though almost nothing calls into it.+add_library(profile STATIC+ ${LIBSRC}/profile/profile.cpp ${LIBSRC}/profile/profile_cmd.cpp+ ${LIBSRC}/profile/profile_funclevel.cpp ${LIBSRC}/profile/profile_highlevel.cpp+ ${LIBSRC}/profile/profile_result.cpp)+target_include_directories(profile PUBLIC ${LIBSRC}/profile)+target_link_libraries(profile PUBLIC debuglib)+# ---- wwdownload -----------------------------------------------------------# FTP patch downloader. Its wlib/resource.h includes are all commented out in# the shipped source, so it needs nothing but winsock.@@ -280,6 +291,57 @@ set(GS_BUILD_TESTS OFF CACHE BOOL "" FORCE)set(GS_INCLUDE_VOICE OFF CACHE BOOL "" FORCE)add_subdirectory(${LIBSRC}/GameSpy ${CMAKE_CURRENT_BINARY_DIR}/gamespy)+# ===========================================================================+# Phase 3 - GameEngine. ~580 files of game logic; no DX8, no device code.+# ===========================================================================+set(GE ${CMAKE_CURRENT_SOURCE_DIR}/GameEngine)++# The source tree is a frozen 2003 snapshot, so a glob cannot go stale the way+# it would in a live project - and 580 explicit paths would drown this file.+file(GLOB_RECURSE GAMEENGINE_SOURCES ${GE}/Source/*.cpp)+# On disk but absent from GameEngine.dsp, i.e. never in the shipping build:+# dead experiments (SimplePlayer, urlLaunch, VideoStream), an older copy of+# DrawableManager that GameClient/Drawable/ supersedes, and GameSpeech, whose+# hash uses std::hash<const char*> on strings that outlive nothing.+list(REMOVE_ITEM GAMEENGINE_SOURCES+ ${GE}/Source/Common/Audio/GameSpeech.cpp+ ${GE}/Source/Common/Audio/simpleplayer.cpp+ ${GE}/Source/Common/Audio/urllaunch.cpp+ ${GE}/Source/GameClient/DrawableManager.cpp+ ${GE}/Source/GameClient/VideoStream.cpp)+# GameNetwork/GameSpy.h and the two .cpp files that owned it were stripped from+# the release, and these two are all that include it. Multiplayer is out of+# scope (PLAN.md), so they stay out until the exe link says otherwise.+list(REMOVE_ITEM GAMEENGINE_SOURCES+ ${GE}/Source/GameNetwork/GameSpyChat.cpp+ ${GE}/Source/GameNetwork/GameSpyGP.cpp)+# EA's own header says "#error this file is obsolete", and this .cpp is its only+# includer - the live code went to GameNetwork/GameSpy/ instead.+list(REMOVE_ITEM GAMEENGINE_SOURCES+ ${GE}/Source/GameNetwork/GameSpyGameInfo.cpp)++add_library(gameengine STATIC ${GAMEENGINE_SOURCES})+target_include_directories(gameengine PUBLIC+ ${GE}/Include ${GE}/Include/Precompiled+ ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/Include+ ${WW} ${WW}/WWLib+ # The game includes "GameSpy/Peer/Peer.h", the SDK's own headers include each+ # other as "gscommon.h", so both levels have to be on the path.+ ${LIBSRC}/GameSpy/include ${LIBSRC}/GameSpy/include/gamespy ${COMP}+ ${CMAKE_CURRENT_SOURCE_DIR}/Libraries/DirectX/Include)+# _RELEASE/_DEBUG pick the game's own build flavour; IG_DEBUG_STACKTRACE and+# Z_PREFIX are what GameEngine.dsp sets.+target_compile_definitions(gameengine PUBLIC+ IG_DEBUG_STACKTRACE Z_PREFIX+ $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:_RELEASE>)+# C++17 for the std::hash_map -> unordered_map alias and string_view hashing in+# STLTypedefs.h.+set_target_properties(gameengine PROPERTIES CXX_STANDARD 17)+target_link_libraries(gameengine PUBLIC+ ww3d2 wwlib wwmath wwsaveload wwdebug wwutil compression debuglib wwdownload+ benchmark eabrowserdispatch profile gamespy+ dinput8 wininet imagehlp imm32)+# ===========================================================================# Tests. Run with: ctest --test-dir build -C Release --output-on-failure# ===========================================================================@@ -328,6 +390,14 @@ add_lib_test(test_debug debuglib)add_lib_test(test_support benchmark eabrowserdispatch)+# Phase 3 checkpoint: boots the memory manager, name keys and file system, then+# runs a real INI file through the parser.+add_lib_test(test_gameengine gameengine)+# the well-known Dict keys and a handful of device/exe entry points live in+# GameEngineDevice, which Phase 4 ports; stand-ins until then.+target_sources(test_gameengine PRIVATE ${TESTS}/test_gameengine_stubs.cpp)+set_target_properties(test_gameengine PROPERTIES CXX_STANDARD 17)+# The three hand-written self-checks predate the harness; run them from ctest# too so one command covers everything.add_test(NAME wwmath_selfcheck COMMAND wwmath_selfcheck)diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h b/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.hindex 3fa8540c4..63f89c593 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h@@ -318,7 +318,7 @@ public: \inline DLINK_ITERATOR<OBJCLASS> iterate_##LISTNAME() const \{ \DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \- return DLINK_ITERATOR<OBJCLASS>(m_dlinkhead_##LISTNAME.m_head, OBJCLASS::dlink_next_##LISTNAME); \+ return DLINK_ITERATOR<OBJCLASS>(m_dlinkhead_##LISTNAME.m_head, &OBJCLASS::dlink_next_##LISTNAME); \} \inline OBJCLASS *getFirstItemIn_##LISTNAME() const \{ \diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameMemory.h b/GeneralsMD/Code/GameEngine/Include/Common/GameMemory.hindex 94e790679..0c3fe4804 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GameMemory.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GameMemory.h@@ -878,8 +878,12 @@ extern void userMemoryAdjustPoolSize(const char *poolName, Int& initialAllocatio// additional overloads for 'placement new'//inline void* __cdecl operator new (size_t s, void *p) { return p; }//inline void __cdecl operator delete (void *, void *p) { }+ #if _MSC_VER < 1300+ // vcruntime declares the placement array forms itself now, exactly as+ // WWLib/always.h already had to work around.inline void* __cdecl operator new[] (size_t s, void *p) { return p; }inline void __cdecl operator delete[] (void *, void *p) { }+ #endif#endifdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h b/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.hindex f2178b21a..03539408c 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h@@ -70,15 +70,27 @@ enum DrawableID;#include <algorithm>#include <bitset>-#include <hash_map>#include <list>#include <map>#include <queue>#include <set>#include <stack>#include <string>+#include <string_view>+#include <unordered_map>#include <vector>+// STLport put the SGI hash_map in namespace std as+// hash_map<Key, Val, HashFcn, EqualKey, Alloc>, which is unordered_map's+// parameter list. MSVC's own <hash_map> is not a substitute: stdext::hash_map+// takes a single traits class where this code passes a hasher and a comparator.+// Aliasing it here keeps the ~12 call sites unchanged.+namespace std+{+ template <class K, class V, class H, class E>+ using hash_map = unordered_map<K, V, H, E>;+}+// List of AsciiStrings to allow list of ThingTemplate names from INI and suchtypedef std::list< AsciiString > AsciiStringList;typedef std::list< AsciiString >::iterator AsciiStringListIterator;@@ -191,9 +203,13 @@ namespace rtstemplate<> struct hash<AsciiString>{size_t operator()(AsciiString ast) const- {- std::hash<const char *> tmp;- return tmp((const char *) ast.str());+ {+ // STLport's std::hash<const char*> was the SGI string hash, i.e. it+ // hashed the characters. The standard one hashes the pointer, which+ // with equal_to<AsciiString> comparing by value would make every+ // lookup on a differently-allocated copy of the same string miss.+ std::hash<std::string_view> tmp;+ return tmp(std::string_view(ast.str()));}};diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Display.hindex b0cd8ba35..1a6a0aa31 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Display.h@@ -67,7 +67,9 @@ public:DRAW_IMAGE_ADDITIVE //additive blend the image into frame buffer};- typedef void (DebugDisplayCallback)( DebugDisplayInterface *debugDisplay, void *userData, FILE *fp = NULL );+ // No default argument here: a function *type* cannot carry one, and nothing+ // ever calls through this pointer with fewer than three arguments.+ typedef void (DebugDisplayCallback)( DebugDisplayInterface *debugDisplay, void *userData, FILE *fp );Display();virtual ~Display();diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/LanguageFilter.h b/GeneralsMD/Code/GameEngine/Include/GameClient/LanguageFilter.hindex a81a29eef..669932809 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/LanguageFilter.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/LanguageFilter.h@@ -82,7 +82,7 @@ public:void filterLine(UnicodeString &line);protected:- Bool readWord(File *file1, UnsignedShort *buf);+ Bool readWord(File *file1, WideChar *buf);void unHaxor(UnicodeString &word);LangMap m_wordList;LangMap m_subWordList;diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.hindex bbbbaa7c5..9fbd8094f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h@@ -311,7 +311,13 @@ class Waypoint;class Team;class Weapon;-// Note - written out in save/load xfer and .map files, don't change these numbers.+// ws2def.h (pulled in by winsock2.h) defines AI_PASSIVE as a getaddrinfo hint+// flag, which turns the enumerator below into 0x00000001=-1. Nothing here calls+// getaddrinfo, and the enumerator's value is written into save games and .map+// files, so the macro is what gives way.+#undef AI_PASSIVE++// Note - written out in save/load xfer and .map files, don't change these numbers.enum AttitudeType { AI_SLEEP = -2, AI_PASSIVE=-1, AI_NORMAL=0, AI_ALERT=1, AI_AGGRESSIVE=2, AI_INVALID=3 }; ///< AI "attitude" behavior modifiersenum CommandSourceType;diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.hindex 2e5c8f0bc..d571e3846 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h@@ -517,7 +517,11 @@ public:inline Int wasSeenByAnyPlayers() const ///<check if a player in the game has seen the object but is now looking at fogged version.{- for (Int i=0; i<MAX_PLAYER_COUNT; i++)+ // i is declared outside the loop because the trailing return reads it:+ // under VC6 for-scope that was MAX_PLAYER_COUNT, and callers treat any+ // value >= MAX_PLAYER_COUNT as "nobody".+ Int i;+ for (i=0; i<MAX_PLAYER_COUNT; i++)if (m_everSeenByPlayer[i] && m_shroudedness[i] == OBJECTSHROUD_FOGGED)return i;return i;diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptEngine.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptEngine.hindex 7a7e49673..1cc7602a8 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptEngine.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptEngine.h@@ -127,7 +127,10 @@ class AttackPriorityInfo : public MemoryPoolObject, public SnapshotMEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(AttackPriorityInfo, "AttackPriorityInfo")// friend bad for MPOs. (srj)-//friend class ScriptEngine;+// ...but ScriptEngine holds a whole array of these by value, and the pool glue+// makes the destructor protected, so its own ctor/dtor cannot see it otherwise.+// The array members never go through the pool, so this grants nothing new.+friend class ScriptEngine;public:diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.hindex fa76db2b9..d08f027fa 100644--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h@@ -112,9 +112,12 @@ class WebBrowser :// IUnknown methods//---------------------------------------------------------------------------protected:- HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);- ULONG STDMETHODCALLTYPE AddRef(void);- ULONG STDMETHODCALLTYPE Release(void);+ // noexcept is part of the function type from C++17 on, and the modern SDK+ // declares IUnknown's three methods noexcept - without it these no longer+ // override, they just clash.+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) noexcept;+ ULONG STDMETHODCALLTYPE AddRef(void) noexcept;+ ULONG STDMETHODCALLTYPE Release(void) noexcept;//---------------------------------------------------------------------------// IBrowserDispatch methodsdiff --git a/GeneralsMD/Code/GameEngine/Include/Precompiled/PreRTS.h b/GeneralsMD/Code/GameEngine/Include/Precompiled/PreRTS.hindex 97c95443b..5b9ad9fe8 100644--- a/GeneralsMD/Code/GameEngine/Include/Precompiled/PreRTS.h+++ b/GeneralsMD/Code/GameEngine/Include/Precompiled/PreRTS.h@@ -41,20 +41,29 @@ class STLSpecialAlloc;// PLEASE DO NOT ABUSE WINDOWS OR IT WILL BE REMOVED ENTIRELY. :-)//--------------------------------------------------------------------------------- System Includes#define WIN32_LEAN_AND_MEAN+// winuser.h declares AnimateWindow() only for WINVER >= 0x0500, which VC6 never+// reached, so GameClient could name a class AnimateWindow. A modern SDK always+// declares it, and the function name then hides the class at every use. Rename+// the API on the way in - the game never calls it - instead of renaming a class+// that GameMemory.ini looks up by name.+#define AnimateWindow AnimateWindow_Win32Unused#include <atlbase.h>#include <windows.h>+#undef AnimateWindow#include <assert.h>#include <ctype.h>#include <direct.h>#include <EXCPT.H>#include <float.h>-#include <fstream.h>+// <fstream.h> (pre-standard iostream) was dropped from MSVC long ago. Nothing+// in GameEngine uses a stream, so it goes rather than becoming <fstream>.#include <imagehlp.h>#include <io.h>#include <limits.h>#include <lmcons.h>-#include <mapicode.h>+// <mapicode.h> came with the MAPI SDK, which no Windows SDK carries any more.+// Nothing here references a MAPI symbol.#include <math.h>#include <memory.h>#include <mmsystem.h>diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cppindex 318d36af1..1b871d6e9 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp@@ -323,7 +323,10 @@ static INIBlockParse findBlockParse(const char* token)//-------------------------------------------------------------------------------------------------static INIFieldParseProc findFieldParse(const FieldParse* parseTable, const char* token, int& offset, const void*& userData){- for (const FieldParse* parse = parseTable; parse->token; ++parse)+ // parse is read after the loop (the catch-all entry with a null token), so+ // it cannot live in the for-scope the way VC6 let it.+ const FieldParse* parse;+ for (parse = parseTable; parse->token; ++parse){if (strcmp( parse->token, token ) == 0){@@ -1504,7 +1507,9 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableListfor (int ptIdx = 0; ptIdx < parseTableList.getCount(); ++ptIdx){int offset = 0;- void* userData = 0;+ // findFieldParse takes this by non-const reference and the+ // parse procs take it as const void*, so const it is.+ const void* userData = 0;INIFieldParseProc parse = findFieldParse(parseTableList.getNthFieldParse(ptIdx), field, offset, userData);if (parse){diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cppindex 58f10de57..77339a362 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp@@ -113,7 +113,8 @@ GameMessageArgumentDataType GameMessage::getArgumentDataType( Int argIndex )return ARGUMENTDATATYPE_UNKNOWN;}int i=0;- for (GameMessageArgument *a = m_argList; a && (i < argIndex); a=a->m_next, ++i );+ GameMessageArgument *a;+ for (a = m_argList; a && (i < argIndex); a=a->m_next, ++i );if (a != NULL){diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cppindex 59959f24f..e2ff27fa3 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp@@ -2066,7 +2066,7 @@ void Player::killPlayer(void)m_isPlayerDead = TRUE; // this is so OCLs don't ever again spawn useful units for us.- for (it = m_playerTeamPrototypes.begin(); it != m_playerTeamPrototypes.end(); ++it) {+ for (PlayerTeamList::iterator it = m_playerTeamPrototypes.begin(); it != m_playerTeamPrototypes.end(); ++it) {for (DLINK_ITERATOR<Team> iter = (*it)->iterate_TeamInstanceList(); !iter.done(); iter.advance()) {Team *team = iter.cur();if (!team) {diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cppindex 7a72776a9..c387f9e91 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp@@ -1165,7 +1165,9 @@ Bool RecorderClass::playbackFile(AsciiString filename)* Read a unicode string from the current file position. The string is assumed to be 0-terminated.*/UnicodeString RecorderClass::readUnicodeString() {- UnsignedShort str[1024] = L"";+ // Was UnsignedShort: VC6's wchar_t was a typedef for it, so L"" initialised it+ // and UnicodeString took it. wchar_t is its own type now.+ WideChar str[1024] = L"";Int index = 0;Int c = fgetwc(m_file);@@ -1174,7 +1176,9 @@ UnicodeString RecorderClass::readUnicodeString() {}str[index] = c;- while (index < 1024 && str[index] != 0) {+ // Was index < 1024: the body pre-increments and then writes str[index], so the+ // last iteration stored one element past the end of the buffer.+ while (index < 1023 && str[index] != 0) {++index;Int c = fgetwc(m_file);if (c == EOF) {@@ -1202,7 +1206,9 @@ AsciiString RecorderClass::readAsciiString() {}str[index] = c;- while (index < 1024 && str[index] != 0) {+ // Was index < 1024: the body pre-increments and then writes str[index], so the+ // last iteration stored one element past the end of the buffer.+ while (index < 1023 && str[index] != 0) {++index;Int c = fgetc(m_file);if (c == EOF) {diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/GameMemory.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/GameMemory.cppindex 3a7528fe2..057ee6d04 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/GameMemory.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/GameMemory.cpp@@ -1635,7 +1635,9 @@ void* MemoryPool::allocateBlockDoNotZeroImplementation(DECLARE_LITERALSTRING_ARG{// hmm... the current 'free' blob has nothing available. look and see if there// are any other existing blobs with freespace.- for (MemoryPoolBlob *blob = m_firstBlob; blob != NULL; blob = blob->getNextInList())+ // blob is read after the loop, so it outlives the for-scope.+ MemoryPoolBlob *blob;+ for (blob = m_firstBlob; blob != NULL; blob = blob->getNextInList()){if (blob->hasAnyFreeBlocks())break;@@ -3450,7 +3452,10 @@ void initMemoryManager()linktest = new char[8];delete [] linktest;- linktest = new char("",1);+ // Was new char("",1): VC6 read the parentheses as an initializer with a comma+ // operator, i.e. a third plain scalar new, which is what theLinkTester == 6+ // counts. Modern C++ reads it as a two-argument initializer and rejects it.+ linktest = new char(1);delete linktest;#ifdef MEMORYPOOL_OVERRIDE_MALLOCdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cppindex 15e9ac9a5..c8841883c 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp@@ -159,7 +159,8 @@ UnicodeString QuotedPrintableToUnicodeString(AsciiString original)*c = 0;- UnicodeString out(dest);+ // VC6's wchar_t was a typedef for unsigned short; it is a distinct type now.+ UnicodeString out((const WideChar *)dest);return out;}diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cppindex 8362cea50..c940c9e15 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp@@ -1025,7 +1025,10 @@ void Radar::createEvent( const Coord3D *world, RadarEventType type, Real seconds// lookup the colors we are to used based on the eventRGBAColorInt color[ 2 ];- for( Int i = 0; radarColorLookupTable[ i ].event != RADAR_EVENT_INVALID; ++i )+ // i is read after the loop to tell "found" from "ran off the end", so it+ // outlives the for-scope VC6 gave it.+ Int i;+ for( i = 0; radarColorLookupTable[ i ].event != RADAR_EVENT_INVALID; ++i ){if( radarColorLookupTable[ i ].event == type )diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cppindex 5e0b3a45b..a388bccaf 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp@@ -789,7 +789,7 @@ Bool GameState::isInSaveDirectory(const AsciiString& path) const// ------------------------------------------------------------------------------------------------AsciiString GameState::getMapLeafName(const AsciiString& in) const{- char* p = strrchr(in.str(), '\\');+ const char* p = strrchr(in.str(), '\\');if (p){//diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cppindex 1627301f4..b9e696e1b 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp@@ -560,7 +560,10 @@ void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info )/*** Match the exception type with the error string and print it out*/- for ( int i=0 ; _codes[i] != 0xffffffff ; i++ )+ // i indexes _code_txt after the loop, so it outlives the for-scope; the last+ // _code_txt entry is the catch-all that pairs with the 0xffffffff sentinel.+ int i;+ for ( i=0 ; _codes[i] != 0xffffffff ; i++ ){if ( _codes[i] == e_info->ExceptionRecord->ExceptionCode ){diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cppindex 370d1d7e4..b36648a76 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp@@ -111,7 +111,9 @@ ThingFactory::ThingFactory()m_firstTemplate = NULL;m_nextTemplateID = 1; // not zero!- m_templateHashMap.resize( TEMPLATE_HASH_SIZE );+ // SGI hash_map::resize(n) sized the bucket array; unordered_map spells that+ // reserve(), which takes an element count and sizes buckets from it.+ m_templateHashMap.reserve( TEMPLATE_HASH_SIZE );} // end ThingFactory//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cppindex 1a481a9ff..cf1c628e9 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp@@ -1322,7 +1322,10 @@ void ThingTemplate::initForLTA(const AsciiString& name)char buffer[1024];strncpy(buffer, name.str(), sizeof(buffer));- for (int i=0; buffer[i]; i++) {+ // i indexes buffer after the loop: it is the character past the first '/', or+ // the terminator when the name has none.+ int i;+ for (i=0; buffer[i]; i++) {if (buffer[i] == '/') {i++;break;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp b/GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cppindex efd4c7004..3d57f3b85 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp@@ -904,7 +904,8 @@ Bool LadderPreferences::loadProfile( Int profileID )continue;p.port = atoi( ptr + 1 );- for (Int i=0; i<strlen(ptr); ++i)+ Int i; // second loop below reuses this under VC6 for-scope+ for (i=0; i<strlen(ptr); ++i){ladName.removeLastChar();}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 2185a84a0..b487e33d7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -3222,7 +3222,9 @@ void ControlBar::updateRadarAttackGlow ( void )void ControlBar::initSpecialPowershortcutBar( Player *player){- for( Int i = 0; i < MAX_SPECIAL_POWER_SHORTCUTS; ++i )+ // Second loop further down reuses this i under VC6 for-scope.+ Int i;+ for( i = 0; i < MAX_SPECIAL_POWER_SHORTCUTS; ++i ){m_specialPowerShortcutButtonParents[i] = NULL;m_specialPowerShortcutButtons[i] = NULL;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cppindex 3fcf00974..9923c809b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp@@ -235,8 +235,8 @@ void GameInfoWindowInit( WindowLayout *layout, void *userData )winSuperWeapons = TheWindowManager->winGetWindowFromId( parent, winSuperWeaponsID );winFreeForAll = TheWindowManager->winGetWindowFromId( parent, winFreeForAllID );- GadgetStaticTextSetText(staticTextGameName,UnicodeString.TheEmptyString);- GadgetStaticTextSetText(staticTextMapName,UnicodeString.TheEmptyString);+ GadgetStaticTextSetText(staticTextGameName,UnicodeString::TheEmptyString);+ GadgetStaticTextSetText(staticTextMapName,UnicodeString::TheEmptyString);GadgetListBoxReset(listBoxPlayers);} // end MapSelectMenuInitdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cppindex 92d48f524..c40a2c5f9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp@@ -203,7 +203,9 @@ static void playerTooltip(GameWindow *window,UnsignedInt mouse){Int idx = -1;- for (Int i=0; i<MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<MAX_SLOTS; ++i){if (window && window == GadgetComboBoxGetEditBox(comboBoxPlayer[i])){@@ -214,7 +216,9 @@ static void playerTooltip(GameWindow *window,if (idx == -1)return;- LANGameSlot *slot = TheLAN->GetMyGame()->getLANSlot(i);+ // was i, the loop counter above: it only escaped its scope under VC6, and the+ // loop breaks the instant it sets idx = i, so the two are the same value here.+ LANGameSlot *slot = TheLAN->GetMyGame()->getLANSlot(idx);if (!slot)return;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cppindex e838ac650..2583124f1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp@@ -197,7 +197,7 @@ enumSHOW_FRAMES_LIMIT = 20};-static showFade = FALSE;+static Bool showFade = FALSE;static Int dropDown = DROPDOWN_NONE;static Int pendingDropDown = DROPDOWN_NONE;static AnimateWindowManager *localAnimateWindowManager = NULL;@@ -214,7 +214,7 @@ static Bool launchChallengeMenu = FALSE;static Bool dontAllowTransitions = FALSE;//Added by Saad-const /*Int TIME_OUT = 15,*/ CORNER = 10;+const Int /*TIME_OUT = 15,*/ CORNER = 10;void AcceptResolution();void DeclineResolution();GameWindow *resAcceptMenu = NULL;@@ -546,6 +546,8 @@ void MainMenuInit( WindowLayout *layout, void *userData )dropDownWindows[DROPDOWN_MAIN] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder2") ) );dropDownWindows[DROPDOWN_LOADREPLAY] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder3") ) );dropDownWindows[DROPDOWN_DIFFICULTY] = TheWindowManager->winGetWindowFromId( parentMainMenu, TheNameKeyGenerator->nameToKey( AsciiString("MainMenu.wnd:MapBorder4") ) );+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;for(i = 1; i < DROPDOWN_COUNT; ++i)dropDownWindows[i]->winHide(TRUE);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cppindex a5bfec7e6..9dbd6b37b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp@@ -1613,6 +1613,8 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )// populate resolution modesGadgetComboBoxReset(comboBoxResolution);Int numResolutions = TheDisplay->getDisplayModeCount();+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;for( i = 0; i < numResolutions; ++i ){ Int xres,yres,bitDepth;TheDisplay->getDisplayModeDescription(i,&xres,&yres,&bitDepth);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupLadderSelect.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupLadderSelect.cppindex 1c57a852b..10b665ba9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupLadderSelect.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupLadderSelect.cpp@@ -576,6 +576,8 @@ static void updateLadderDetails( Int selID, GameWindow *staticTextLadderName, Ga// mapsAsciiStringList validMaps = info->validMaps;+ // it is used after the loop; VC6 for-scope let it escape.+ AsciiStringList::iterator it;for (it = validMaps.begin(); it != validMaps.end(); ++it){const MapMetaData *md = TheMapCache->findMap(*it);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cppindex e4600d2dc..5f2436873 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp@@ -1686,7 +1686,9 @@ winName.format("ScoreScreen.wnd:StaticTextScore%d", pos);}}DEBUG_LOG(("Game ended on frame %d - TheGameLogic->getFrame()=%d\n", lastFrameOfGame-1, TheGameLogic->getFrame()-1));- for (i=0; i<MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<MAX_SLOTS; ++i){const GameSlot *slot = TheGameInfo->getConstSlot(i);DEBUG_LOG(("latestHumanInGame=%d, slot->isOccupied()=%d, slot->disconnected()=%d, slot->isAI()=%d, slot->lastFrameInGame()=%d\n",@@ -1923,7 +1925,7 @@ winName.format("ScoreScreen.wnd:StaticTextScore%d", pos);stats.lastGeneral = ptIdx;Int gameSize = 0;- for (i=0; i<MAX_SLOTS; ++i)+ for (Int i=0; i<MAX_SLOTS; ++i){if (TheGameSpyGame->getConstSlot(i)->isOccupied() && TheGameSpyGame->getConstSlot(i)->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER)++gameSize;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cppindex b4fd6598e..043b19d79 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp@@ -737,7 +737,9 @@ void positionStartSpots( AsciiString mapName, GameWindow *buttonMapStartPosition}positionAdditionalImages(NULL, mapWindow, TRUE);- for (Int i = 0; i < MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i){if (buttonMapStartPositions[i] != NULL){@@ -777,7 +779,10 @@ void positionStartSpots( AsciiString mapName, GameWindow *buttonMapStartPositionpositionAdditionalImages(&mmd, mapWindow, TRUE);AsciiString waypointName;- for(Int i = 0; i < mmd.m_numPlayers && mmd.m_isMultiplayer; ++i )+ // The "hide the rest" loop below picks up where this one stopped, so i has+ // to outlive the VC6 for-scope.+ Int i;+ for(i = 0; i < mmd.m_numPlayers && mmd.m_isMultiplayer; ++i ){waypointName.format("Player_%d_Start", i+1); // start pos waypoints are 1-basedWaypointMap::iterator wmIt = mmd.m_waypoints.find(waypointName);@@ -854,7 +859,7 @@ void updateMapStartSpots( GameInfo *myGame, GameWindow *buttonMapStartPositions[}}}- for( i = 0; i < MAX_SLOTS; ++i)+ for( Int i = 0; i < MAX_SLOTS; ++i){if ( buttonMapStartPositions[i] == NULL )continue;@@ -1173,7 +1178,7 @@ void InitSkirmishGameGadgets( void )DEBUG_ASSERTCRASH(buttonMapStartPosition[i], ("Could not find the ButtonMapStartPosition[%d]",i ));}- for (i = 0; i < MAX_SLOTS; ++i)+ for (Int i = 0; i < MAX_SLOTS; ++i){PopulateColorComboBox(i, comboBoxColor, TheSkirmishGameInfo );GadgetComboBoxSetSelectedPos(comboBoxColor[i], 0);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cppindex be7280dec..978f002a5 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp@@ -177,7 +177,7 @@ void InitBuddyControls(Int type)buddyControls.listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLBuddyOverlay.wnd:ListboxBuddyChat" ) );buddyControls.listboxBuddies = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxBuddiesID );buddyControls.listboxChat = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxChatID);- GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString.TheEmptyString);+ GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString::TheEmptyString);buddyControls.isInit = TRUE;break;case BUDDY_WINDOW_DIPLOMACY:@@ -187,7 +187,7 @@ void InitBuddyControls(Int type)buddyControls.listboxChatID = TheNameKeyGenerator->nameToKey( AsciiString( "Diplomacy.wnd:ListboxBuddyChat" ) );buddyControls.listboxBuddies = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxBuddiesID );buddyControls.listboxChat = TheWindowManager->winGetWindowFromId( NULL, buddyControls.listboxChatID);- GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString.TheEmptyString);+ GadgetTextEntrySetText(buddyControls.textEntryEdit, UnicodeString::TheEmptyString);buddyControls.isInit = TRUE;break;case BUDDY_WINDOW_WELCOME_SCREEN:@@ -754,7 +754,7 @@ void WOLBuddyOverlayInit( WindowLayout *layout, void *userData )parentBuddies->winHide(FALSE);parentIgnore->winHide(TRUE);- //GadgetTextEntrySetText(textEntry, UnicodeString.TheEmptyString);+ //GadgetTextEntrySetText(textEntry, UnicodeString::TheEmptyString);PopulateOldBuddyMessages();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cppindex 28bb0e1ea..76fae2d36 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp@@ -898,7 +898,9 @@ static void StartPressed(void)// Check for too few teamsint numRandom = 0;std::set<Int> teams;- for (i=0; i<MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<MAX_SLOTS; ++i){GameSlot *slot = myGame->getSlot(i);if (slot && slot->isOccupied() && slot->getPlayerTemplate() != PLAYERTEMPLATE_OBSERVER)@@ -2582,7 +2584,7 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msgWindowMsgData mData1, WindowMsgData mData2 ){UnicodeString txtInput;- static buttonCommunicatorID = NAMEKEY_INVALID;+ static NameKeyType buttonCommunicatorID = NAMEKEY_INVALID;switch( msg ){//-------------------------------------------------------------------------------------------------@@ -2690,7 +2692,7 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msgGameWindow *control = (GameWindow *)mData1;Int controlID = control->winGetWindowId();- static buttonCommunicatorID = NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator");+ static NameKeyType buttonCommunicatorID = NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator");if ( controlID == buttonBackID ){savePlayerInfo();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cppindex e342b6064..32ef39bf6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp@@ -586,6 +586,7 @@ void PopulateLobbyPlayerListbox(void){std::set<Int>::const_iterator indexIt;Int *newIndices = NEW Int[indicesToSelect.size()];+ Int i; // used after the loop; VC6 for-scope let it escapefor (i=0, indexIt = indicesToSelect.begin(); indexIt != indicesToSelect.end(); ++i, ++indexIt){newIndices[i] = *indexIt;@@ -656,7 +657,7 @@ void WOLLobbyMenuInit( WindowLayout *layout, void *userData )comboLobbyGroupRoomsID = TheNameKeyGenerator->nameToKey(AsciiString("WOLCustomLobby.wnd:ComboBoxGroupRooms"));comboLobbyGroupRooms = TheWindowManager->winGetWindowFromId(parent, comboLobbyGroupRoomsID);- GadgetTextEntrySetText(textEntryChat, UnicodeString.TheEmptyString);+ GadgetTextEntrySetText(textEntryChat, UnicodeString::TheEmptyString);populateGroupRoomListbox(comboLobbyGroupRooms);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cppindex 42c14f6ac..4cf1bafc3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp@@ -589,7 +589,7 @@ void WOLLoginMenuInit( WindowLayout *layout, void *userData )#endif // ALLOW_NON_PROFILED_LOGIN// Read login names from registry...GadgetComboBoxReset(comboBoxEmail);- GadgetTextEntrySetText(textEntryPassword, UnicodeString.TheEmptyString);+ GadgetTextEntrySetText(textEntryPassword, UnicodeString::TheEmptyString);// look for cached nicks to addAsciiString lastName;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cppindex cdd0981ec..60f6eaac9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp@@ -317,7 +317,7 @@ static float s_totalWinPercent = 0;static const char* FindNextNumber( const char* pStart ){- char* pNum = strchr( pStart, '\n' ); //go to next line+ const char* pNum = strchr( pStart, '\n' ); //go to next lineif( !pNum )return pStart; //error@@ -364,7 +364,7 @@ void HandleOverallStats( const char* szHTTPStats, unsigned len )// we want win% = team's wins / total # games played by all teamsconst char* pTotal = FindNextNumber(pSide);const char* pWins = FindNextNumber(pTotal);- float percent = atof(pWins) / max(1,atof(pTotal)); //max prevents divide by zero+ float percent = atof(pWins) / max(1.0,atof(pTotal)); //max prevents divide by zeros_totalWinPercent += percent;s_winStats.insert(std::make_pair( side, percent ));diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetComboBox.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetComboBox.cppindex c5cba897c..c288e5cb6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetComboBox.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetComboBox.cpp@@ -471,7 +471,7 @@ WindowMsgHandledType GadgetComboBoxSystem( GameWindow *window, UnsignedInt msg,if ( comboData->listBox )GadgetListBoxReset(comboData->listBox);if ( comboData->editBox )- GadgetTextEntrySetText(comboData->editBox, UnicodeString.TheEmptyString );+ GadgetTextEntrySetText(comboData->editBox, UnicodeString::TheEmptyString );comboData->entryCount = 0;//HideListBox(window);break;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cppindex 0f0ef851d..c25f1f29f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetListBox.cpp@@ -716,7 +716,9 @@ WindowMsgHandledType GadgetListBoxInput( GameWindow *window, UnsignedInt msg,ListEntryCell *cell = NULL;// go through the columns until we find a column with text- for(Int j = 0; j < list->columns; ++j)+ // j is used after the loop; VC6 for-scope let it escape.+ Int j;+ for(j = 0; j < list->columns; ++j){cell = &list->listData[position].cell[j];if(cell && cell->cellType == LISTBOX_TEXT && cell->data)@@ -1290,7 +1292,7 @@ WindowMsgHandledType GadgetListBoxSystem( GameWindow *window, UnsignedInt msg,if(pos->x >= list->columns || pos->y >= list->listLength ||list->listData[pos->y].cell[pos->x].cellType != LISTBOX_TEXT){- tAndC->string = UnicodeString.TheEmptyString;+ tAndC->string = UnicodeString::TheEmptyString;tAndC->color = 0;}else@@ -1633,7 +1635,9 @@ WindowMsgHandledType GadgetListBoxSystem( GameWindow *window, UnsignedInt msg,if( list->multiSelect ){// forced selections override the entire selection list.- for (Int i=0; i<selectCount && i<list->endPos; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<selectCount && i<list->endPos; ++i){// don't select off the endif (list->listLength <= selectList[i])@@ -1716,7 +1720,9 @@ WindowMsgHandledType GadgetListBoxSystem( GameWindow *window, UnsignedInt msg,// the position mData1 contains//ListEntryCell *cells = NULL;- for (Int i = 0; i < (Int)mData1; i++)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < (Int)mData1; i++){cells = list->listData[i].cell;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cppindex d62815a27..c05db181d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp@@ -416,7 +416,9 @@ void SinglePlayerLoadScreen::init( GameInfo *game )Mission *mission = TheCampaignManager->getCurrentMission();AsciiString lineName;- for(Int i = 0; i < MAX_OBJECTIVE_LINES; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for(i = 0; i < MAX_OBJECTIVE_LINES; ++i){lineName.format("SinglePlayerLoadScreen.wnd:StaticTextLine%d",i);m_objectiveLines[i] = TheWindowManager->winGetWindowFromId( m_loadScreen,TheNameKeyGenerator->nameToKey( lineName ));@@ -1388,7 +1390,9 @@ void MultiPlayerLoadScreen::init( GameInfo *game )//DEBUG_LOG(("NumPlayers %d\n", TheNetwork->getNumPlayers()));GameWindow *teamWin[MAX_SLOTS];- for (Int i = 0; i < MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i){teamWin[i] = NULL;}@@ -1640,7 +1644,9 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());GadgetStaticTextSetText( m_nameLocalGeneral, localName );GameWindow *teamWin[MAX_SLOTS];- for (Int i = 0; i < MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i){teamWin[i] = NULL;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cppindex e6d7a8e01..02ec0c69c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp@@ -1120,7 +1120,9 @@ void GameClient::preloadAssets( TimeOfDay timeOfDay )GlobalMemoryStatus(&before);extern std::vector<AsciiString> debrisModelNamesGlobalHack;- for (Int i=0; i<debrisModelNamesGlobalHack.size(); ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<debrisModelNamesGlobalHack.size(); ++i){TheDisplay->preloadModelAssets(debrisModelNamesGlobalHack[i]);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cppindex c0d68ce76..5b49309c3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp@@ -447,8 +447,8 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'1', L'!', L'\0', KEY_1 );_set_keyname_(L'2', L'\"', L'\0', KEY_2 );- _set_keyname_(L'3', 0x00A3, L'\0', KEY_3 ); //�- _set_keyname_(L'4', L'$', L'�', KEY_4 );+ _set_keyname_(L'3', 0x00A3, L'\0', KEY_3 ); //�+ _set_keyname_(L'4', L'$', L'�', KEY_4 );_set_keyname_(L'5', L'%', L'\0', KEY_5 );_set_keyname_(L'6', L'^', L'\0', KEY_6 );_set_keyname_(L'7', L'&', L'\0', KEY_7 );@@ -465,7 +465,7 @@ void Keyboard::initKeyNames( void )_set_keyname_(L';', L':', L'\0', KEY_SEMICOLON );_set_keyname_(L'\'', L'@', L'\0', KEY_APOSTROPHE );- _set_keyname_(L'`', 0x00AC, 0x00A6, KEY_TICK ); //��+ _set_keyname_(L'`', 0x00AC, 0x00A6, KEY_TICK ); //��_set_keyname_(L'#', L'~', L'\0', KEY_BACKSLASH );_set_keyname_(L'-', L'_', L'\0', KEY_MINUS );@@ -496,7 +496,7 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'j', L'J', L'\0', KEY_J );_set_keyname_(L'k', L'K', L'\0', KEY_K );_set_keyname_(L'l', L'L', L'\0', KEY_L );- _set_keyname_(L'm', L'M', 0x00B5, KEY_M ); //�+ _set_keyname_(L'm', L'M', 0x00B5, KEY_M ); //�_set_keyname_(L'n', L'N', L'\0', KEY_N );_set_keyname_(L'o', L'O', L'\0', KEY_O );_set_keyname_(L'p', L'P', L'\0', KEY_P );@@ -512,8 +512,8 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'y', L'Y', L'\0', KEY_Z );_set_keyname_(L'1', L'!', L'\0', KEY_1 );- _set_keyname_(L'2', L'"', 0x00B2, KEY_2 ); //�- _set_keyname_(L'3', 0x00A7, 0x00B3, KEY_3 ); //��+ _set_keyname_(L'2', L'"', 0x00B2, KEY_2 ); //�+ _set_keyname_(L'3', 0x00A7, 0x00B3, KEY_3 ); //��_set_keyname_(L'4', L'$', L'\0', KEY_4 );_set_keyname_(L'5', L'%', L'\0', KEY_5 );_set_keyname_(L'6', L'&', L'\0', KEY_6 );@@ -526,16 +526,16 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'.', L':', L'\0', KEY_PERIOD );_set_keyname_(L'-', L'_', L'\0', KEY_SLASH );- _set_keyname_(0x00FC, 0x00DC, L'\0', KEY_LBRACKET ); //��+ _set_keyname_(0x00FC, 0x00DC, L'\0', KEY_LBRACKET ); //��_set_keyname_(L'+', L'*', L'~', KEY_RBRACKET );- _set_keyname_(0x00F6, 0x00D6, L'\0', KEY_SEMICOLON ); //��- _set_keyname_(0x00E4, 0x00C4, L'\0', KEY_APOSTROPHE ); //��- _set_keyname_(L'^', 0x00B0, L'\0', KEY_TICK ); //�+ _set_keyname_(0x00F6, 0x00D6, L'\0', KEY_SEMICOLON ); //��+ _set_keyname_(0x00E4, 0x00C4, L'\0', KEY_APOSTROPHE ); //��+ _set_keyname_(L'^', 0x00B0, L'\0', KEY_TICK ); //�_set_keyname_(L'#', L'\'', L'\0', KEY_BACKSLASH );- _set_keyname_(0x00DF, L'?', L'\\', KEY_MINUS ); //�- _set_keyname_(0x00B4, L'`', L'\0', KEY_EQUAL ); //�+ _set_keyname_(0x00DF, L'?', L'\\', KEY_MINUS ); //�+ _set_keyname_(0x00B4, L'`', L'\0', KEY_EQUAL ); //�_set_keyname_(L'<', L'>', L'|', KEY_102 );@@ -578,29 +578,29 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'w', L'W', L'\0', KEY_Z );_set_keyname_(L'&', L'1', L'\0', KEY_1 );- _set_keyname_(0x00E9, L'2', L'~', KEY_2 ); //�+ _set_keyname_(0x00E9, L'2', L'~', KEY_2 ); //�_set_keyname_(L'"', L'3', L'#', KEY_3 );_set_keyname_(L'\'', L'4', L'{', KEY_4 );_set_keyname_(L'(', L'5', L'[', KEY_5 );_set_keyname_(L'-', L'6', L'|', KEY_6 );- _set_keyname_(0x00E8, L'7', L'`', KEY_7 ); //�+ _set_keyname_(0x00E8, L'7', L'`', KEY_7 ); //�_set_keyname_(L'_', L'8', L'\\', KEY_8 );- _set_keyname_(0x00E7, L'9', L'\0', KEY_9 ); //�- _set_keyname_(0x00E0, L'0', L'@', KEY_0 ); //�+ _set_keyname_(0x00E7, L'9', L'\0', KEY_9 ); //�+ _set_keyname_(0x00E0, L'0', L'@', KEY_0 ); //�_set_keyname_(L';', L'.', L'\0', KEY_COMMA );_set_keyname_(L':', L'/', L'\0', KEY_PERIOD );- _set_keyname_(L'!', 0x00A7, L'\0', KEY_SLASH ); //�+ _set_keyname_(L'!', 0x00A7, L'\0', KEY_SLASH ); //�- _set_keyname_(L'^', 0x00A8, L'\0', KEY_LBRACKET ); //�- _set_keyname_(L'$', 0x00A3, 0x00A4, KEY_RBRACKET ); //��+ _set_keyname_(L'^', 0x00A8, L'\0', KEY_LBRACKET ); //�+ _set_keyname_(L'$', 0x00A3, 0x00A4, KEY_RBRACKET ); //��_set_keyname_(L'm', L'M', L'\0', KEY_SEMICOLON );- _set_keyname_(0x00F9, L'%', L'\0', KEY_APOSTROPHE ); //�- _set_keyname_(0x00B2, L'\0', L'\0', KEY_TICK ); //�- _set_keyname_(L'*', 0x00B5, L'\0', KEY_BACKSLASH ); //�+ _set_keyname_(0x00F9, L'%', L'\0', KEY_APOSTROPHE ); //�+ _set_keyname_(0x00B2, L'\0', L'\0', KEY_TICK ); //�+ _set_keyname_(L'*', 0x00B5, L'\0', KEY_BACKSLASH ); //�- _set_keyname_(L')', 0x00B0, L']', KEY_MINUS ); //�+ _set_keyname_(L')', 0x00B0, L']', KEY_MINUS ); //�_set_keyname_(L'=', L'+', L'}', KEY_EQUAL );_set_keyname_(L'<', L'>', L'\0', KEY_102 );@@ -645,7 +645,7 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'1', L'!', L'\0', KEY_1 );_set_keyname_(L'2', L'"', L'\0', KEY_2 );- _set_keyname_(L'3', 0x00A3, L'\0', KEY_3 ); //�+ _set_keyname_(L'3', 0x00A3, L'\0', KEY_3 ); //�_set_keyname_(L'4', L'$', L'\0', KEY_4 );_set_keyname_(L'5', L'%', L'\0', KEY_5 );_set_keyname_(L'6', L'&', L'\0', KEY_6 );@@ -658,16 +658,16 @@ void Keyboard::initKeyNames( void )_set_keyname_(L'.', L':', L'\0', KEY_PERIOD );_set_keyname_(L'-', L'_', L'\0', KEY_SLASH );- _set_keyname_(0x00E8, 0x00E9, L'[', KEY_LBRACKET ); //��+ _set_keyname_(0x00E8, 0x00E9, L'[', KEY_LBRACKET ); //��_set_keyname_(L'+', L'*', L']', KEY_RBRACKET );- _set_keyname_(0x00F2, 0x00E7, L'@', KEY_SEMICOLON ); //��- _set_keyname_(0x00E0, 0x00B0, L'#', KEY_APOSTROPHE ); //�+ _set_keyname_(0x00F2, 0x00E7, L'@', KEY_SEMICOLON ); //��+ _set_keyname_(0x00E0, 0x00B0, L'#', KEY_APOSTROPHE ); //�_set_keyname_(L'\\', L'|', L'\0', KEY_TICK );- _set_keyname_(0x00F9, 0x00A7, L'\0', KEY_BACKSLASH ); //��+ _set_keyname_(0x00F9, 0x00A7, L'\0', KEY_BACKSLASH ); //��_set_keyname_(L'\'', L'?', L'\0', KEY_MINUS );- _set_keyname_(0x00EC, L'^', L'\0', KEY_EQUAL ); //�+ _set_keyname_(0x00EC, L'^', L'\0', KEY_EQUAL ); //�_set_keyname_(L'<', L'>', L'\0', KEY_102 );@@ -976,7 +976,7 @@ Bool Keyboard::isAlt()WideChar Keyboard::getPrintableKey( UnsignedByte key, Int state ){if((key < 0 || key >=KEY_NAMES_COUNT) || ( state < 0 || state >= MAX_KEY_STATES))- return L'';+ return L'\0';if(state == 0)return m_keyNames[key].stdKey;else if(state == 1)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/LanguageFilter.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/LanguageFilter.cppindex 9dc7274a2..d02341747 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/LanguageFilter.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/LanguageFilter.cpp@@ -159,7 +159,7 @@ void LanguageFilter::unHaxor(UnicodeString &word) {}// returning true means that there are more words in the file.-Bool LanguageFilter::readWord(File *file1, UnsignedShort *buf) {+Bool LanguageFilter::readWord(File *file1, WideChar *buf) {Int index = 0;Bool retval = TRUE;Int val = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cppindex 4d07a7326..49f25fb47 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp@@ -291,7 +291,9 @@ Particle::Particle( ParticleSystem *system, const ParticleInfo *info )m_sizeRateDamping = info->m_sizeRateDamping;// set up alpha- for( int i=0; i<MAX_KEYFRAMES; i++ )+ // i is used after the loop; VC6 for-scope let it escape.+ int i;+ for( i =0; i<MAX_KEYFRAMES; i++ )m_alphaKey[i] = info->m_alphaKey[i];m_alpha = m_alphaKey[0].value;@@ -1087,7 +1089,9 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate,m_sizeRate = sysTemplate->m_sizeRate;m_sizeRateDamping = sysTemplate->m_sizeRateDamping;- for( int i=0; i<MAX_KEYFRAMES; i++ )+ // i is used after the loop; VC6 for-scope let it escape.+ int i;+ for( i =0; i<MAX_KEYFRAMES; i++ )m_alphaKey[i] = sysTemplate->m_alphaKey[i];for( i=0; i<MAX_KEYFRAMES; i++ )@@ -2324,7 +2328,9 @@ ParticleInfo ParticleSystem::mergeRelatedParticleSystems( ParticleSystem *mastermergeInfo.m_angularRateZ = info->m_angularRateZ;mergeInfo.m_angularDamping = info->m_angularDamping;- for( int i=0; i<MAX_KEYFRAMES; i++ )+ // i is used after the loop; VC6 for-scope let it escape.+ int i;+ for( i =0; i<MAX_KEYFRAMES; i++ )mergeInfo.m_alphaKey[i] = info->m_alphaKey[i];for( i=0; i<MAX_KEYFRAMES; i++ )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cppindex b48701380..1f7522cc8 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp@@ -170,7 +170,9 @@ SeismicSimulationFilterBase::SeismicSimStatusCode DomeStyleSeismicFilter::filterfor ( Real *t = workspace; t < workspaceEnd; ++t ) *t = 0.0f;// clear the workspace- for (Int x = 0; x < radius; ++x)+ // x is used after the loop; VC6 for-scope let it escape.+ Int x;+ for (x = 0; x < radius; ++x){for (Int y = 0; y < radius; ++y){diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cppindex 34d57dfae..96a21dc5c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp@@ -1201,7 +1201,7 @@ PathfindCell::~PathfindCell( void ){if (m_info) PathfindCellInfo::releaseACellInfo(m_info);m_info = NULL;- static warn = true;+ static bool warn = true;if (warn) {warn = false;DEBUG_LOG( ("PathfindCell::~PathfindCell m_info Allocated."));diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cppindex 2279fc030..19b6170eb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp@@ -721,7 +721,7 @@ UpdateSleepTime TurretAI::updateTurretAI()if (m_didFire){// if we fired, enable sweeping for a few frames.- const ENABLE_SWEEP_FRAME_COUNT = 3;+ const Int ENABLE_SWEEP_FRAME_COUNT = 3;m_enableSweepUntil = now + ENABLE_SWEEP_FRAME_COUNT;m_continuousFireExpirationFrame = now + ENABLE_SWEEP_FRAME_COUNT;// so the recent firing will not interrupt the moving sound}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cppindex 1bd0ff34c..c7238f091 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/PolygonTrigger.cpp@@ -310,7 +310,9 @@ void PolygonTrigger::addPolygonTrigger(PolygonTrigger *pTrigger)void PolygonTrigger::removePolygonTrigger(PolygonTrigger *pTrigger){PolygonTrigger *pPrev = NULL;- for (PolygonTrigger *pTrig=getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) {+ // pTrig is used after the loop; VC6 for-scope let it escape.+ PolygonTrigger *pTrig;+ for (pTrig=getFirstPolygonTrigger(); pTrig; pTrig = pTrig->getNext()) {if (pTrig==pTrigger) break;pPrev = pTrig;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cppindex e5b62206b..c18e65726 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp@@ -1185,7 +1185,7 @@ void TerrainLogic::enableWaterGrid( Bool enable )//AsciiString strippedMapNameOnly;AsciiString strippedCompareMapNameOnly;- char *c;+ const char *c;// create stripped map namec = strrchr( TheGlobalData->m_mapName.str(), '\\' );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cppindex ee6846fb0..d7152af41 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp@@ -167,7 +167,9 @@ ObjectID CountermeasuresBehavior::calculateCountermeasureToDivertTo( const Objec//Start at the end of the list and go towards the beginning.CountermeasuresVec::iterator it = m_counterMeasures.end();//end is actually the end so advance the iterator.- if( it )+ // was if(it): STLport's vector iterator was a bare pointer, and an untouched+ // vector's end() was null. Non-empty is what that actually tested.+ if( !m_counterMeasures.empty() ){--it;while( iteratorMax-- )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cppindex 54ac0a3bf..3e4fb6e30 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp@@ -405,7 +405,7 @@ FlightDeckBehavior::FlightDeckInfo* FlightDeckBehavior::findPPI(ObjectID id)for (std::vector<FlightDeckInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); ++it){if (it->m_objectInSpace == id)- return it;+ return &*it;}return NULL;@@ -420,7 +420,7 @@ FlightDeckBehavior::FlightDeckInfo* FlightDeckBehavior::findEmptyPPI()for (std::vector<FlightDeckInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); ++it){if( it->m_objectInSpace == INVALID_ID )- return it;+ return &*it;}return NULL;@@ -853,7 +853,9 @@ Bool FlightDeckBehavior::calcBestParkingAssignment( ObjectID id, Coord3D *pos, I//Find the runway the object is assigned to.Int runway = -1;Int myIndex = 0;- for( std::vector<FlightDeckInfo>::iterator myIt = m_spaces.begin(); myIt != m_spaces.end(); myIt++, myIndex++ )+ // myIt is used after the loop; VC6 for-scope let it escape.+ std::vector<FlightDeckInfo>::iterator myIt;+ for( myIt = m_spaces.begin(); myIt != m_spaces.end(); myIt++, myIndex++ ){if( myIt->m_objectInSpace == id ){@@ -879,7 +881,9 @@ Bool FlightDeckBehavior::calcBestParkingAssignment( ObjectID id, Coord3D *pos, I//the back and keep looking at empty spaces until we find one with a plane blocking.Bool checkForPlaneInWay = FALSE;- std::vector<FlightDeckInfo>::iterator bestIt = NULL;+ // was a vector iterator initialised to NULL, which only compiled while STLport's+ // iterator was a bare pointer.+ FlightDeckInfo *bestIt = NULL;Object *bestJet = NULL;Int bestIndex = 0, index = 0;for( std::vector<FlightDeckInfo>::iterator thatIt = m_spaces.begin(); thatIt != m_spaces.end(); thatIt++, index++ )@@ -923,7 +927,7 @@ Bool FlightDeckBehavior::calcBestParkingAssignment( ObjectID id, Coord3D *pos, Iif( !checkForPlaneInWay ){//We can take this spot! But first find the flight deck info entry for it.Now handle assignment swap.- bestIt = thatIt;+ bestIt = &*thatIt;bestJet = nonIdleJet;bestIndex = index;checkForPlaneInWay = TRUE;@@ -1193,7 +1197,9 @@ UpdateSleepTime FlightDeckBehavior::update()m_startedProductionFrame = FOREVER;}- for( std::vector<FlightDeckInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); it++ )+ // it is used after the loop; VC6 for-scope let it escape.+ std::vector<FlightDeckInfo>::iterator it;+ for( it = m_spaces.begin(); it != m_spaces.end(); it++ ){//Unassigned space?... so we can build a replacement.if( it->m_objectInSpace == INVALID_ID )@@ -1354,7 +1360,8 @@ void FlightDeckBehavior::exitObjectViaDoor( Object *newObj, ExitDoorType exitDooreturn;}- newObj->setPosition( pCreationLocations->begin() );+ // begin() was a Coord3D* under STLport; setPosition still wants the pointer.+ newObj->setPosition( &pCreationLocations->front() );newObj->setOrientation( m_runways[ ppi->m_runway ].m_startOrient );TheAI->pathfinder()->addObjectToPathfindMap( newObj );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cppindex eef13a518..352146a33 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp@@ -511,7 +511,7 @@ void SlowDeathBehavior::onDie( const DamageInfo *damageInfo )// this returns a value from 1...total, inclusiveInt roll = GameLogicRandomValue(1, total);- for (/* UpdateModuleInterface** */ update = obj->getBehaviorModules(); *update; ++update)+ for (BehaviorModule** update = obj->getBehaviorModules(); *update; ++update){SlowDeathBehaviorInterface* sdu = (*update)->getSlowDeathBehaviorInterface();if (sdu != NULL && sdu->isDieApplicable(damageInfo))diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cppindex adce0978a..aca3d6ef4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp@@ -113,7 +113,9 @@ void UndeadBody::startSecondLife(DamageInfo *damageInfo)// Fire the Slow Death module. The fact that this is not the result of an onDie will cause the special behaviorInt total = 0;- for( BehaviorModule** update = getObject()->getBehaviorModules(); *update; ++update )+ // update is used after the loop; VC6 for-scope let it escape.+ BehaviorModule** update;+ for( update = getObject()->getBehaviorModules(); *update; ++update ){SlowDeathBehaviorInterface* sdu = (*update)->getSlowDeathBehaviorInterface();if (sdu != NULL && sdu->isDieApplicable(damageInfo) )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cppindex 7a9508659..a85be9e6a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp@@ -2013,7 +2013,9 @@ void GarrisonContain::loadStationGarrisonPoints( void )Coord3D tempBuffer[MAX_GARRISON_POINTS];- for( int t = 0; t < MAX_GARRISON_POINTS; ++t )+ // t is used after the loop; VC6 for-scope let it escape.+ int t;+ for( t = 0; t < MAX_GARRISON_POINTS; ++t )tempBuffer[ t ] = *(structure->getPosition());count = structure->getMultiLogicalBonePosition("STATION", modData->m_containMax, tempBuffer, NULL);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cppindex 9a34363ab..74145d654 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp@@ -549,7 +549,7 @@ public:std::vector<Coord3D>::const_iterator it;for( it = pTaxiLocations->begin(); it != pTaxiLocations->end(); it++ ){- movePath->appendNode( it, LAYER_GROUND );+ movePath->appendNode( &*it, LAYER_GROUND );}}@@ -617,7 +617,7 @@ public:firstNode = FALSE;continue;}- movePath->appendNode( it, LAYER_GROUND );+ movePath->appendNode( &*it, LAYER_GROUND );}movePath->appendNode( &ppinfo.runwayPrep, LAYER_GROUND );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cppindex f1c9d0677..b48bb89b0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp@@ -107,7 +107,9 @@ RailroadBehavior::RailroadBehavior( Thing *thing, const ModuleData *moduleData ){const RailroadBehaviorModuleData *modData = getRailroadBehaviorModuleData();- m_carriageTemplateNameIterator = 0;+ // was = 0: STLport's const_iterator was a bare pointer. Nothing reads this+ // before hitchNewCarriagebyTemplate() reseats it, so default-construct.+ m_carriageTemplateNameIterator = TemplateNameIterator();m_nextStationTask = DO_NOTHING;m_trailerID = INVALID_ID;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cppindex 77d3bc49d..432d756cd 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cpp@@ -146,7 +146,9 @@ Bool DockUpdate::reserveApproachPosition( Object* docker, Coord3D *position, IntObjectID dockerID = docker->getID();- for( Int positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex )+ // positionIndex is used after the loop; VC6 for-scope let it escape.+ Int positionIndex;+ for( positionIndex = 0; positionIndex < m_approachPositionOwners.size(); ++positionIndex ){if( m_approachPositionOwners[positionIndex] == dockerID ){@@ -583,7 +585,9 @@ void DockUpdate::xfer( Xfer *xfer )Int vectorSize = m_approachPositions.size();xfer->xferInt( &vectorSize );m_approachPositions.resize(vectorSize);- for( Int vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex )+ // vectorIndex is used after the loop; VC6 for-scope let it escape.+ Int vectorIndex;+ for( vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex ){// Okay, this is cool. On save, the size and a bunch of coords will be written.// on load, vectorSize will be at 0 from the .size, but will then get setdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SpawnPointProductionExitUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SpawnPointProductionExitUpdate.cppindex 524b3f2f3..e6526b002 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SpawnPointProductionExitUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SpawnPointProductionExitUpdate.cpp@@ -71,7 +71,9 @@ void SpawnPointProductionExitUpdate::exitObjectViaDoor( Object *newObj, ExitDoorObject *creationObject = getObject();if (creationObject){- for( Int positionIndex = 0; positionIndex < m_spawnPointCount; positionIndex++ )+ // positionIndex is used after the loop; VC6 for-scope let it escape.+ Int positionIndex;+ for( positionIndex = 0; positionIndex < m_spawnPointCount; positionIndex++ ){if( m_spawnPointOccupier[positionIndex] == INVALID_ID )break;@@ -149,7 +151,9 @@ void SpawnPointProductionExitUpdate::initializeBonePositions()return;Matrix3D boneTransforms[MAX_SPAWN_POINTS];- for( Int matrixIndex = 0; matrixIndex < MAX_SPAWN_POINTS; matrixIndex++ )+ // matrixIndex is used after the loop; VC6 for-scope let it escape.+ Int matrixIndex;+ for( matrixIndex = 0; matrixIndex < MAX_SPAWN_POINTS; matrixIndex++ )boneTransforms[matrixIndex].Make_Identity();// Get all the bones of the right namediff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cppindex 38e7231ca..de00b2c7f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cpp@@ -403,7 +403,9 @@ void StructureToppleUpdate::applyCrushingDamage(Real theta)Real jcos;Real jsin;// Coord3D target;- for (Real j = m_lastCrushedLocation; j < maxDistance; j += WEAPON_SPACING_PERPENDICULAR) {+ // j is used after the loop; VC6 for-scope let it escape.+ Real j;+ for (j = m_lastCrushedLocation; j < maxDistance; j += WEAPON_SPACING_PERPENDICULAR) {jcos = j * Cos(toppleAngle);jsin = j * Sin(toppleAngle);doDamageLine(building, wt, jcos, jsin, facingWidth, toppleAngle);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cppindex 24d69f33d..8d921ee74 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -1618,7 +1618,7 @@ void WeaponStore::update()if (curFrame >= ddi->m_delayDamageFrame){// we never do projectile-detonation-damage via this code path.- const isProjectileDetonation = false;+ const Bool isProjectileDetonation = false;ddi->m_delayedWeapon->dealDamageInternal(ddi->m_delaySourceID, ddi->m_delayIntendedVictimID, &ddi->m_delayDamagePos, ddi->m_bonus, isProjectileDetonation);ddi = m_weaponDDI.erase(ddi);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cppindex 65b8fd6ac..f39ff57e1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp@@ -5316,7 +5316,9 @@ void ScriptActions::doMoveTeamTowardsNearest( const AsciiString& teamName, const}}}- for( iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() )+ // re-declared rather than hoisted above the first loop: DLINK_ITERATOR has+ // no default constructor, and both walks start from the head anyway.+ for( DLINK_ITERATOR<Object> iter = team->iterate_TeamMemberList(); !iter.done(); iter.advance() ){Object *obj = iter.cur();if( !obj )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cppindex 2e2719bde..632d43fbc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp@@ -1788,7 +1788,9 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, void *userData )if (msg->getArgument(0)->boolean){// transfer control to any living ally- for (Int i=0; i<ThePlayerList->getPlayerCount(); ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<ThePlayerList->getPlayerCount(); ++i){if (i != msg->getPlayerIndex()){diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cppindex a9fcf3bd8..e1c6b006c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp@@ -75,7 +75,9 @@ ConnectionManager::~ConnectionManager(void)m_transport = NULL;}- for (Int i = 0; i < MAX_SLOTS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i) {if (m_frameData[i] != NULL) {m_frameData[i]->deleteInstance();m_frameData[i] = NULL;@@ -151,7 +153,9 @@ void ConnectionManager::init()// }// m_transport->reset();- for (UnsignedInt i = 0; i < NUM_CONNECTIONS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ UnsignedInt i;+ for (i = 0; i < NUM_CONNECTIONS; ++i) {m_connections[i] = NULL;}@@ -229,7 +233,9 @@ void ConnectionManager::reset()m_transport = NULL;}- for (Int i = 0; i < NUM_CONNECTIONS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < NUM_CONNECTIONS; ++i) {if (m_connections[i] != NULL) {m_connections[i]->deleteInstance();m_connections[i] = NULL;@@ -1553,7 +1559,9 @@ Bool ConnectionManager::allCommandsReady(UnsignedInt frame, Bool justTesting /*Bool retval = TRUE;FrameDataReturnType frameRetVal;// retval = FALSE; // ****for testing purposes only!!!!!!****- for (Int i = 0; (i < MAX_SLOTS) && retval; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; (i < MAX_SLOTS) && retval; ++i) {if ((m_frameData[i] != NULL) && (m_frameData[i]->getIsQuitting() == FALSE)) {/*if (!(m_frameData[i]->allCommandsReady(frame, (frame != commandsReadyDebugSpewage) && (justTesting == FALSE)))) {diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cppindex 4918b61fb..a9bc389df 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp@@ -82,7 +82,9 @@ void DisconnectManager::init() {m_currentPacketRouterIndex = 0;m_timeOfDisconnectScreenOn = 0;- for (Int i = 0; i < MAX_SLOTS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i) {for (Int j = 0; j < MAX_SLOTS; ++j) {m_playerVotes[i][j].vote = FALSE;m_playerVotes[i][j].frame = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cppindex 5c2169f6f..902a9b388 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cpp@@ -102,7 +102,9 @@ FirewallHelperClass::FirewallHelperClass(void)m_lastBehavior = FIREWALL_TYPE_UNKNOWN;m_sourcePortAllocationDelta = 0;m_lastSourcePortAllocationDelta = 0;- for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SPARE_SOCKETS; ++i) {m_spareSockets[i].port = 0;m_messages[i].length = 0;m_mangledPorts[i] = 0;@@ -446,7 +448,9 @@ UnsignedShort FirewallHelperClass::getManglerResponse(UnsignedShort packetID, Insockaddr_in addr;- for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SPARE_SOCKETS; ++i) {if (m_spareSockets[i].udp != NULL) {ManglerMessage *message = findEmptyMessage();if (message == NULL) {@@ -909,7 +913,9 @@ Bool FirewallHelperClass::detectionTest3Update() {** We should use a non-linear set of source ports so we can detect the NAT32 relative offset** case.*/- for (Int i=0 ; i<NUM_TEST_PORTS ; i++) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0 ; i<NUM_TEST_PORTS ; i++) {m_sparePorts[i] = getNextTemporarySourcePort(i);if (!openSpareSocket(m_sparePorts[i])) {@@ -956,7 +962,9 @@ Bool FirewallHelperClass::detectionTest3Update() {}Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() {- for (Int i = 0; i < NUM_TEST_PORTS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < NUM_TEST_PORTS; ++i) {if (m_mangledPorts[i] == 0) {m_mangledPorts[i] = getManglerResponse(m_packetID + i);if (m_mangledPorts[i] != 0) {@@ -1525,7 +1533,9 @@ Int FirewallHelperClass::getFirewallRetries(FirewallBehaviorType behavior)* returns TRUE if successful, FALSE otherwise.*/Bool FirewallHelperClass::openSpareSocket(UnsignedShort port) {- for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SPARE_SOCKETS; ++i) {if (m_spareSockets[i].port == 0) {break;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cppindex 374c28c58..0149a6703 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp@@ -72,7 +72,9 @@ void FrameMetrics::init() {m_averageLatency = (Real)0.2;m_minimumCushion = -1;- for (Int i = 0; i < TheGlobalData->m_networkFPSHistoryLength; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < TheGlobalData->m_networkFPSHistoryLength; ++i) {m_fpsList[i] = 30.0;}m_fpsListIndex = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cppindex 5515394ed..ebc359b1f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp@@ -192,7 +192,9 @@ void PopulateColorComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGUnicodeString colorName;std::vector<bool> availableColors;- for (Int i = 0; i < numColors; i++)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < numColors; i++)availableColors.push_back(true);for (i = 0; i < MAX_SLOTS; i++)@@ -338,7 +340,9 @@ void PopulateStartingCashComboBox(GameWindow *comboBox, GameInfo *myGame)const MultiplayerStartingMoneyList & startingCashMap = TheMultiplayerSettings->getStartingMoneyList();Int currentSelectionIndex = -1;- for ( MultiplayerStartingMoneyList::const_iterator it = startingCashMap.begin(); it != startingCashMap.end(); it++ )+ // it is used after the loop; VC6 for-scope let it escape.+ MultiplayerStartingMoneyList::const_iterator it;+ for ( it = startingCashMap.begin(); it != startingCashMap.end(); it++ ){Int newIndex = GadgetComboBoxAddEntry(comboBox, formatMoneyForStartingCashComboBox( *it ),comboBox->winGetEnabled() ? comboBox->winGetEnabledTextColor() : comboBox->winGetDisabledTextColor());diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cppindex e1d757227..04eb50bf4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp@@ -770,7 +770,9 @@ void GameInfo::adjustSlotsForMap()Int numPlayerSlots = 0;// first get the number of occupied slots.- for (Int i = 0; i < MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i){GameSlot *tempSlot = getSlot(i);if (tempSlot->isOccupied())diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cppindex bcba368a0..8f0353c46 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp@@ -473,7 +473,8 @@ static void clearBuddyGames(void)struct GameSortStruct{- bool operator()(GameSpyStagingRoom *g1, GameSpyStagingRoom *g2)+ // multiset calls its comparator through a const reference.+ bool operator()(GameSpyStagingRoom *g1, GameSpyStagingRoom *g2) const{// sort CRC mismatches to the bottomBool g1Good = (g1->getExeCRC() != TheGlobalData->m_exeCRC || g1->getIniCRC() != TheGlobalData->m_iniCRC);diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cppindex b85c1222b..6745de8f6 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp@@ -316,8 +316,11 @@ static void queuePatch(Bool mandatory, AsciiString downloadURL)///////////////////////////////////////////////////////////////////////////////////////static GHTTPBool motdCallback( GHTTPRequest request, GHTTPResult result,- char * buffer, int bufferLen, void * param )+ char * buffer, GHTTPByteCount bufferLen64, void * param ){+ // the SDK widened its byte count to 64 bits; the body wants the old Int.+ Int bufferLen = (Int)bufferLen64;+ (void)bufferLen; // only read by DEBUG_LOG in some of these, which Release compiles outInt run = (Int)param;if (run != timeThroughOnline){@@ -356,8 +359,11 @@ static GHTTPBool motdCallback( GHTTPRequest request, GHTTPResult result,///////////////////////////////////////////////////////////////////////////////////////static GHTTPBool configCallback( GHTTPRequest request, GHTTPResult result,- char * buffer, int bufferLen, void * param )+ char * buffer, GHTTPByteCount bufferLen64, void * param ){+ // the SDK widened its byte count to 64 bits; the body wants the old Int.+ Int bufferLen = (Int)bufferLen64;+ (void)bufferLen; // only read by DEBUG_LOG in some of these, which Release compiles outInt run = (Int)param;if (run != timeThroughOnline){@@ -421,8 +427,11 @@ static GHTTPBool configCallback( GHTTPRequest request, GHTTPResult result,///////////////////////////////////////////////////////////////////////////////////////static GHTTPBool configHeadCallback( GHTTPRequest request, GHTTPResult result,- char * buffer, int bufferLen, void * param )+ char * buffer, GHTTPByteCount bufferLen64, void * param ){+ // the SDK widened its byte count to 64 bits; the body wants the old Int.+ Int bufferLen = (Int)bufferLen64;+ (void)bufferLen; // only read by DEBUG_LOG in some of these, which Release compiles outInt run = (Int)param;if (run != timeThroughOnline){@@ -508,8 +517,11 @@ static GHTTPBool configHeadCallback( GHTTPRequest request, GHTTPResult result,///////////////////////////////////////////////////////////////////////////////////////-static GHTTPBool gamePatchCheckCallback( GHTTPRequest request, GHTTPResult result, char * buffer, int bufferLen, void * param )+static GHTTPBool gamePatchCheckCallback( GHTTPRequest request, GHTTPResult result, char * buffer, GHTTPByteCount bufferLen64, void * param ){+ // the SDK widened its byte count to 64 bits; the body wants the old Int.+ Int bufferLen = (Int)bufferLen64;+ (void)bufferLen; // only read by DEBUG_LOG in some of these, which Release compiles outInt run = (Int)param;if (run != timeThroughOnline){@@ -598,8 +610,11 @@ void CancelPatchCheckCallback( void )///////////////////////////////////////////////////////////////////////////////////////-static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result, char * buffer, int bufferLen, void * param )+static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result, char * buffer, GHTTPByteCount bufferLen64, void * param ){+ // the SDK widened its byte count to 64 bits; the body wants the old Int.+ Int bufferLen = (Int)bufferLen64;+ (void)bufferLen; // only read by DEBUG_LOG in some of these, which Release compiles outDEBUG_LOG(("overallStatsCallback() - Result=%d, len=%d\n", result, bufferLen));if (result != GHTTPSuccess){@@ -612,8 +627,11 @@ static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result,///////////////////////////////////////////////////////////////////////////////////////-static GHTTPBool numPlayersOnlineCallback( GHTTPRequest request, GHTTPResult result, char * buffer, int bufferLen, void * param )+static GHTTPBool numPlayersOnlineCallback( GHTTPRequest request, GHTTPResult result, char * buffer, GHTTPByteCount bufferLen64, void * param ){+ // the SDK widened its byte count to 64 bits; the body wants the old Int.+ Int bufferLen = (Int)bufferLen64;+ (void)bufferLen; // only read by DEBUG_LOG in some of these, which Release compiles outDEBUG_LOG(("numPlayersOnlineCallback() - Result=%d, buffer=[%s], len=%d\n", result, buffer, bufferLen));if (result != GHTTPSuccess){diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cppindex 9fa610cd0..36445af3d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp@@ -270,7 +270,9 @@ void BuddyThreadClass::Thread_Function()_set_se_translator( DumpExceptionInfo ); // Hook that allows stack trace.GPConnection gpCon;GPConnection *con = &gpCon;- gpInitialize( con, 0 );+ // the vendored SDK is newer than the 2003 one and wants namespace/partner ids+ // too; 0/0 is "no namespace, default partner", i.e. what the old call meant.+ gpInitialize( con, 0, 0, 0 );m_isConnected = m_isConnecting = false;gpSetCallback( con, GP_ERROR, callbackWrapper, (void *)CALLBACK_ERROR );@@ -308,7 +310,9 @@ void BuddyThreadClass::Thread_Function()break;case BuddyRequest::BUDDYREQUEST_DELETEACCT:m_isdeleting = true;- gpDeleteProfile( con );+ // newer SDK takes a completion callback; nothing here watched the+ // result, so pass none.+ gpDeleteProfile( con, NULL, NULL );break;case BuddyRequest::BUDDYREQUEST_LOGOUT:m_isConnecting = m_isConnected = false;@@ -328,8 +332,11 @@ void BuddyThreadClass::Thread_Function()m_email = incomingRequest.arg.login.email;m_pass = incomingRequest.arg.login.password;m_isNewAccount = TRUE;- m_isConnected = (gpConnectNewUser( con, incomingRequest.arg.login.nick, incomingRequest.arg.login.email,- incomingRequest.arg.login.password, (incomingRequest.arg.login.hasFirewall)?GP_FIREWALL:GP_NO_FIREWALL,+ // newer SDK grew uniquenick and cdkey params; the game never had+ // either, so reuse the nick and leave the cdkey empty.+ m_isConnected = (gpConnectNewUser( con, incomingRequest.arg.login.nick, incomingRequest.arg.login.nick,+ incomingRequest.arg.login.email, incomingRequest.arg.login.password, "",+ (incomingRequest.arg.login.hasFirewall)?GP_FIREWALL:GP_NO_FIREWALL,GP_BLOCKING, callbackWrapper, (void *)CALLBACK_CONNECT ) == GP_NO_ERROR);if (m_isNewAccount) // if we didn't re-login{diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cppindex 3c3bdb25d..40909ac8d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp@@ -523,7 +523,8 @@ static enum CallbackTypeCALLBACK_MAX};-void connectCallbackWrapper( PEER peer, PEERBool success, void *param )+// the newer SDK passes a failure reason as well; nothing here reports it.+void connectCallbackWrapper( PEER peer, PEERBool success, Int failureReason, void *param ){#ifdef SERVER_DEBUGGINGDEBUG_LOG(("In connectCallbackWrapper()\n"));@@ -535,7 +536,9 @@ void connectCallbackWrapper( PEER peer, PEERBool success, void *param )}}-void nickErrorCallbackWrapper( PEER peer, Int type, const char *nick, void *param )+// the newer SDK hands the nick-error callback a list of suggested nicks too;+// nothing here offers them to the user, so they are ignored.+void nickErrorCallbackWrapper( PEER peer, Int type, const char *nick, Int numSuggestedNicks, const char **suggestedNicks, void *param ){if (param != NULL){@@ -662,7 +665,7 @@ static void playerFlagsChangedCallback(PEER peer, RoomType roomType, const charstatic void listingGamesCallback(PEER peer, PEERBool success, const char * name, SBServer server, PEERBool staging, int msg, Int percentListed, void * param);static void roomUTMCallback(PEER peer, RoomType roomType, const char * nick, const char * command, const char * parameters, PEERBool authenticated, void * param);static void playerUTMCallback(PEER peer, const char * nick, const char * command, const char * parameters, PEERBool authenticated, void * param);-static void gameStartedCallback(PEER peer, UnsignedInt IP, const char *message, void *param);+static void gameStartedCallback(PEER peer, SBServer server, const char *message, void *param);static void globalKeyChangedCallback(PEER peer, const char *nick, const char *key, const char *val, void *param);static void roomKeyChangedCallback(PEER peer, RoomType roomType, const char *nick, const char *key, const char *val, void *param);@@ -1831,7 +1834,9 @@ void PeerThreadClass::handleQMMatch(PEER peer, Int mapIndex, Int seed,m_qmStatus = QM_MATCHED;peerLeaveRoom(peer, GroupRoom, "");- for (Int i=0; i<MAX_SLOTS; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i =0; i<MAX_SLOTS; ++i){if (playerName[i] && stricmp(playerName[i], m_loginName.c_str())){@@ -2421,7 +2426,9 @@ void roomMessageCallback(PEER peer, RoomType roomType, const char * nick, const}}-void gameStartedCallback( PEER peer, UnsignedInt IP, const char *message, void *param )+// the newer SDK passes the host's server object where the 2003 one passed a raw+// IP; this callback never looked at it.+void gameStartedCallback( PEER peer, SBServer server, const char *message, void *param ){PeerResponse resp;resp.peerResponseType = PeerResponse::PEERRESPONSE_GAMESTART;diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cppindex e94c55f7e..b2ff5e9a9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp@@ -646,7 +646,9 @@ Bool PSThreadClass::tryLogin( Int id, std::string nick, std::string password, streturn m_loginOK;}-static void getPersistentDataCallback(int localid, int profileid, persisttype_t type, int index, int success, char *data, int len, void *instance)+// the newer SDK feeds these callbacks a modification time as well; nothing+// here tracks staleness, so it is ignored.+static void getPersistentDataCallback(int localid, int profileid, persisttype_t type, int index, int success, time_t modified, char *data, int len, void *instance){DEBUG_LOG(("Data get callback: localid: %d profileid: %d success: %d len: %d data: %s\n",localid, profileid, success, len, data));PSThreadClass *t = (PSThreadClass *)instance;@@ -738,7 +740,7 @@ static void getPersistentDataCallback(int localid, int profileid, persisttype_tTheGameSpyPSMessageQueue->addResponse(resp);}-static void setPersistentDataLocaleCallback(int localid, int profileid, persisttype_t type, int index, int success, void *instance)+static void setPersistentDataLocaleCallback(int localid, int profileid, persisttype_t type, int index, int success, time_t modified, void *instance){DEBUG_LOG(("Data save callback: localid: %d profileid: %d success: %d\n", localid, profileid, success));@@ -749,7 +751,7 @@ static void setPersistentDataLocaleCallback(int localid, int profileid, persisttt->decrOpCount();}-static void setPersistentDataCallback(int localid, int profileid, persisttype_t type, int index, int success, void *instance)+static void setPersistentDataCallback(int localid, int profileid, persisttype_t type, int index, int success, time_t modified, void *instance){DEBUG_LOG(("Data save callback: localid: %d profileid: %d success: %d\n", localid, profileid, success));@@ -787,7 +789,7 @@ void preAuthCDCallback(int localid, int profileid, int authenticated, char *errmauthInfo->id = profileid;}-static void getPreorderCallback(int localid, int profileid, persisttype_t type, int index, int success, char *data, int len, void *instance)+static void getPreorderCallback(int localid, int profileid, persisttype_t type, int index, int success, time_t modified, char *data, int len, void *instance){PSThreadClass *t = (PSThreadClass *)instance;if (!t)@@ -875,7 +877,7 @@ void PSThreadClass::Thread_Function()if (tryConnect()){incrOpCount();- GetPersistDataValues(0, req.player.id, pd_public_rw, 0, "", getPersistentDataCallback, this);+ GetPersistDataValues(0, req.player.id, pd_public_rw, 0, (char *)"", getPersistentDataCallback, this);}}break;@@ -1034,7 +1036,7 @@ void PSThreadClass::Thread_Function()DEBUG_LOG(("Looking for preorder status for %d (success=%d, done=%d) from CDKey %s with hash %s\n",cdAuthInfo.id, cdAuthInfo.success, cdAuthInfo.done, req.cdkey.c_str(), cdkeyHash));if (cdAuthInfo.done && cdAuthInfo.success)- GetPersistDataValues(0, cdAuthInfo.id, pd_public_ro, 0, "\\preorder", getPreorderCallback, this);+ GetPersistDataValues(0, cdAuthInfo.id, pd_public_ro, 0, (char *)"\\preorder", getPreorderCallback, this);elsedecrOpCount();}diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cppindex dcbc19785..0e1e22707 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp@@ -105,7 +105,9 @@ void LANAPI::OnAccept( UnsignedInt playerIP, Bool status )if( AmIHost() ){- for (Int i = 0; i < MAX_SLOTS; i++)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; i++){if (m_currentGame->getIP(i) == playerIP){@@ -139,7 +141,9 @@ void LANAPI::OnHasMap( UnsignedInt playerIP, Bool status )if( AmIHost() ){- for (Int i = 0; i < MAX_SLOTS; i++)+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; i++){if (m_currentGame->getIP(i) == playerIP){diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cppindex 36765359a..e29851a45 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cpp@@ -245,7 +245,7 @@ void LANDisplayGameList( GameWindow *gameListbox, LANGameInfo *gameList )AsciiString GenerateGameOptionsString( void ){if(!TheLAN->GetMyGame() || !TheLAN->GetMyGame()->amIHost())- return AsciiString.TheEmptyString;+ return AsciiString::TheEmptyString;return GameInfoToAsciiString(TheLAN->GetMyGame());}diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cppindex 49b57c8c1..c113291e1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp@@ -480,7 +480,9 @@ void NAT::establishConnectionPaths() {// determine how many nodes we have.m_numNodes = 0;- for (Int i = 0; i < MAX_SLOTS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i) {if (m_slotList[i] != NULL) {if (m_slotList[i]->isHuman()) {DEBUG_LOG(("NAT::establishConnectionPaths - slot %d is %ls\n", i, m_slotList[i]->getName().str()));@@ -659,7 +661,9 @@ void NAT::doThisConnectionRound() {// clear out the states from the last round.m_targetNodeNumber = -1;- for (Int i = 0; i < MAX_SLOTS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i) {setConnectionState(i, NATCONNECTIONSTATE_NOSTATE);}@@ -1305,7 +1309,9 @@ void NAT::setConnectionState(Int nodeNumber, NATConnectionState state) {// find the menu slot of the target node.Int slotIndex = m_connectionNodes[m_targetNodeNumber].m_slotIndex;Int slot = 0;- for (Int i = 0; i < MAX_SLOTS; ++i) {+ // i is used after the loop; VC6 for-scope let it escape.+ Int i;+ for (i = 0; i < MAX_SLOTS; ++i) {if (m_slotList[i] != NULL) {if (m_slotList[i]->isHuman()) {if (i != m_connectionNodes[m_localNodeNumber].m_slotIndex) {diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cppindex 43dc4f80a..0982e1d9d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cpp@@ -158,7 +158,7 @@ NetPacketList NetPacket::ConstructBigCommandPacketList(NetCommandRef *ref) {if (!DoesCommandRequireACommandID(msg->getNetCommandType())) {DEBUG_CRASH(("Trying to wrap a command that doesn't have a unique command ID"));- return NULL;+ return NetPacketList();}UnsignedInt bufferSize = GetBufferSizeNeededForCommand(msg); // need to implement. I have a drinking problem.@@ -5219,7 +5219,9 @@ NetCommandMsg * NetPacket::readGameMessage(UnsignedByte *data, Int &i)// Get the types and the number of arguments of those types.Int totalArgCount = 0;GameMessageParser *parser = newInstance(GameMessageParser)();- for (Int j = 0; j < numArgTypes; ++j) {+ // j is used after the loop; VC6 for-scope let it escape.+ Int j;+ for (j = 0; j < numArgTypes; ++j) {UnsignedByte type = (UnsignedByte)ARGUMENTDATATYPE_UNKNOWN;memcpy(&type, data + i, sizeof(type));i += sizeof(type);@@ -5560,7 +5562,10 @@ NetCommandMsg * NetPacket::readPacketRouterAckMessage(UnsignedByte *data, Int &iNetCommandMsg * NetPacket::readDisconnectChatMessage(UnsignedByte *data, Int &i) {NetDisconnectChatCommandMsg *msg = newInstance(NetDisconnectChatCommandMsg);- UnsignedShort text[256];+ // was UnsignedShort: VC6 typedef'd wchar_t to it, so UnicodeString::set took+ // the buffer directly. wchar_t is its own type now; the byte counts below+ // still use sizeof(UnsignedShort), which is the same two bytes.+ WideChar text[256];UnsignedByte length;memcpy(&length, data + i, sizeof(UnsignedByte));++i;@@ -5583,7 +5588,10 @@ NetCommandMsg * NetPacket::readDisconnectChatMessage(UnsignedByte *data, Int &i)NetCommandMsg * NetPacket::readChatMessage(UnsignedByte *data, Int &i) {NetChatCommandMsg *msg = newInstance(NetChatCommandMsg);- UnsignedShort text[256];+ // was UnsignedShort: VC6 typedef'd wchar_t to it, so UnicodeString::set took+ // the buffer directly. wchar_t is its own type now; the byte counts below+ // still use sizeof(UnsignedShort), which is the same two bytes.+ WideChar text[256];UnsignedByte length;Int playerMask;memcpy(&length, data + i, sizeof(UnsignedByte));diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cppindex 182ccb276..faed62ff4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp@@ -131,7 +131,9 @@ Bool Transport::init( UnsignedInt ip, UnsignedShort port )}// ------- Clear buffers --------- for (int i=0; i<MAX_MESSAGES; ++i)+ // i is used after the loop; VC6 for-scope let it escape.+ int i;+ for (i =0; i<MAX_MESSAGES; ++i){m_outBuffer[i].length = 0;m_inBuffer[i].length = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cppindex 34466e796..c677de5e0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp@@ -237,7 +237,7 @@ WebBrowserURL * WebBrowser::makeNewURL(AsciiString tag)*******************************************************************************/-STDMETHODIMP WebBrowser::QueryInterface(REFIID iid, void** ppv)+HRESULT STDMETHODCALLTYPE WebBrowser::QueryInterface(REFIID iid, void** ppv) noexcept{*ppv = NULL;@@ -270,7 +270,7 @@ STDMETHODIMP WebBrowser::QueryInterface(REFIID iid, void** ppv)*******************************************************************************/-ULONG STDMETHODCALLTYPE WebBrowser::AddRef(void)+ULONG STDMETHODCALLTYPE WebBrowser::AddRef(void) noexcept{return ++mRefCount;}@@ -290,7 +290,7 @@ ULONG STDMETHODCALLTYPE WebBrowser::AddRef(void)*******************************************************************************/-ULONG STDMETHODCALLTYPE WebBrowser::Release(void)+ULONG STDMETHODCALLTYPE WebBrowser::Release(void) noexcept{DEBUG_ASSERTCRASH(mRefCount > 0, ("Negative reference count"));--mRefCount;diff --git a/GeneralsMD/Code/Libraries/Source/profile/profile.cpp b/GeneralsMD/Code/Libraries/Source/profile/profile.cppindex fa2b8aa77..d6e82d969 100644--- a/GeneralsMD/Code/Libraries/Source/profile/profile.cpp+++ b/GeneralsMD/Code/Libraries/Source/profile/profile.cpp@@ -165,7 +165,9 @@ void Profile::StartRange(const char *range)range="frame";// known name?- for (unsigned k=0;k<m_names;++k)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;k<m_names;++k)if (!strcmp(range,m_frameNames[k].name))break;if (k==m_names)@@ -219,7 +221,9 @@ void Profile::AppendRange(const char *range)range="frame";// known name?- for (unsigned k=0;k<m_names;++k)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;k<m_names;++k)if (!strcmp(range,m_frameNames[k].name))break;if (k==m_names)@@ -269,7 +273,9 @@ void Profile::StopRange(const char *range)range="frame";// known name?- for (unsigned k=0;k<m_names;++k)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;k<m_names;++k)if (!strcmp(range,m_frameNames[k].name))break;DFAIL_IF(k==m_names) return;diff --git a/GeneralsMD/Code/Libraries/Source/profile/profile_cmd.cpp b/GeneralsMD/Code/Libraries/Source/profile/profile_cmd.cppindex beb693307..7db8955c9 100644--- a/GeneralsMD/Code/Libraries/Source/profile/profile_cmd.cpp+++ b/GeneralsMD/Code/Libraries/Source/profile/profile_cmd.cpp@@ -135,7 +135,9 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode}else{- for (unsigned k=0;k<numResIf;k++)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;k<numResIf;k++)if (!strcmp(argv[0],resIf[k].name))break;if (k==numResIf)@@ -203,7 +205,9 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode// must fixup lastPatternEntry nowif (Profile::firstPatternEntry){- for (Profile::PatternListEntry *cur=Profile::firstPatternEntry;cur->next;cur=cur->next);+ // cur is used after the loop; VC6 for-scope let it escape.+ Profile::PatternListEntry * cur;+ for (cur =Profile::firstPatternEntry;cur->next;cur=cur->next);Profile::lastPatternEntry=cur;}elsediff --git a/GeneralsMD/Code/Libraries/Source/profile/profile_highlevel.cpp b/GeneralsMD/Code/Libraries/Source/profile/profile_highlevel.cppindex cae1f7e6d..33b5945b7 100644--- a/GeneralsMD/Code/Libraries/Source/profile/profile_highlevel.cpp+++ b/GeneralsMD/Code/Libraries/Source/profile/profile_highlevel.cpp@@ -217,7 +217,9 @@ int ProfileId::FrameStart(void){ProfileFastCS::Lock lock(cs);- for (unsigned i=0;i<MAX_FRAME_RECORDS;i++)+ // i is used after the loop; VC6 for-scope let it escape.+ unsigned i;+ for (i =0;i<MAX_FRAME_RECORDS;i++)if (!(frameRecordMask&(1<<i)))break;if (i==MAX_FRAME_RECORDS)@@ -311,7 +313,9 @@ ProfileHighLevel::Id ProfileHighLevel::AddProfile(const char *name, const char *bool ProfileHighLevel::EnumProfile(unsigned index, Id &id){ProfileFastCS::Lock lock(cs);- for (ProfileId *cur=ProfileId::GetFirst();cur&&index--;cur=cur->GetNext());+ // cur is used after the loop; VC6 for-scope let it escape.+ ProfileId * cur;+ for (cur =ProfileId::GetFirst();cur&&index--;cur=cur->GetNext());id.m_idPtr=cur;return cur!=NULL;}diff --git a/GeneralsMD/Code/Libraries/Source/profile/profile_result.cpp b/GeneralsMD/Code/Libraries/Source/profile/profile_result.cppindex 7c1fca759..7c68cfd49 100644--- a/GeneralsMD/Code/Libraries/Source/profile/profile_result.cpp+++ b/GeneralsMD/Code/Libraries/Source/profile/profile_result.cpp@@ -48,7 +48,9 @@ void ProfileResultFileCSV::WriteThread(ProfileFuncLevel::Thread &thread)// CSV file headerfprintf(f,"Function\tFile\tCall count\tPTT (all)\tGTT (all)\tPT/C (all)\tGT/C (all)\tCaller (all)");- for (unsigned k=0;k<Profile::GetFrameCount();k++)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;k<Profile::GetFrameCount();k++){const char *s=Profile::GetFrameName(k);fprintf(f,"\tCall (%s)\tPTT (%s)\tGTT (%s)\tPT/C (%s)\tGT/C (%s)\tCaller (%s)",s,s,s,s,s,s);@@ -103,7 +105,9 @@ void ProfileResultFileCSV::WriteThread(ProfileFuncLevel::Thread &thread)void ProfileResultFileCSV::WriteResults(void){ProfileFuncLevel::Thread t;- for (unsigned k=0;ProfileFuncLevel::EnumThreads(k,t);k++)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;ProfileFuncLevel::EnumThreads(k,t);k++)WriteThread(t);FILE *f=fopen("profile-high.csv","wt");@@ -171,7 +175,9 @@ void ProfileResultFileDOT::WriteResults(void)return;unsigned curMax=0;- for (unsigned k=1;ProfileFuncLevel::EnumThreads(k,t);k++)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =1;ProfileFuncLevel::EnumThreads(k,t);k++){for (;curMax++;){@@ -191,7 +197,9 @@ void ProfileResultFileDOT::WriteResults(void)unsigned frame=ProfileFuncLevel::Id::Total;if (m_frameName){- for (unsigned k=0;k<Profile::GetFrameCount();k++)+ // k is used after the loop; VC6 for-scope let it escape.+ unsigned k;+ for (k =0;k<Profile::GetFrameCount();k++)if (!strcmp(Profile::GetFrameName(k),m_frameName)){frame=k;@@ -226,7 +234,9 @@ void ProfileResultFileDOT::WriteResults(void)for (k=0;tMax.EnumProfile(k,id);k++){const char *source=id.GetSource();- for (FoldHelper *cur=fold;cur;cur=cur->next)+ // cur is used after the loop; VC6 for-scope let it escape.+ FoldHelper * cur;+ for (cur =fold;cur;cur=cur->next)if (!strcmp(source,cur->source)){if (cur->numId<MAX_FUNCTIONS_PER_FILE)@@ -257,7 +267,9 @@ void ProfileResultFileDOT::WriteResults(void)for (unsigned i=0;idlist.Enum(i,caller);i++){const char *s=caller.GetSource();- for (FoldHelper *cur2=fold;cur2;cur2=cur2->next)+ // cur2 is used after the loop; VC6 for-scope let it escape.+ FoldHelper * cur2;+ for (cur2 =fold;cur2;cur2=cur2->next)if (!strcmp(cur2->source,s))break;if (!cur2||cur2->mark)diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppnew file mode 100644index 000000000..b7a40016a--- /dev/null+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -0,0 +1,312 @@+/*+ * GameEngine boot coverage: the Phase 3 checkpoint.+ *+ * Linking gameengine.lib proves nothing on its own, so this brings up the+ * pieces the engine boots first - the memory manager, the name key generator,+ * the file system - and then drives a real INI file through INI::load() and+ * checks the values that came out the other side.+ *+ * TheLocalFileSystem normally lives in GameEngineDevice (Win32LocalFile), which+ * is not ported yet, so the test supplies its own out of LocalFile, which is+ * plain CRT _open/_read and does live in gameengine.+ */+#include "test_harness.h"++#include "Common/AsciiString.h"+#include "Common/UnicodeString.h"+#include "Common/GameMemory.h"+#include "Common/NameKeyGenerator.h"+#include "Common/FileSystem.h"+#include "Common/LocalFileSystem.h"+#include "Common/LocalFile.h"+#include "Common/INI.h"+#include "Common/INIException.h"+#include "Common/STLTypedefs.h"+#include "GameClient/Water.h"++#include <stdio.h>+#include <string.h>++//////////////////////////////////////////////////////////////////////////////+// Boot scaffolding+//////////////////////////////////////////////////////////////////////////////++/* LocalFile carries the abstract-base flavour of the pool glue, so it cannot be+ instantiated directly - the device layer subclasses it (Win32LocalFile) purely+ to get a pool. Same trick here; the base does all the work. */+class TestLocalFile : public LocalFile+{+ /* The pool name has to be one MemoryInit.cpp's size table knows, or+ createMemoryPool throws ERROR_OUT_OF_MEMORY on the -1 sizes; borrow the+ device class' entry, since that is the class this stands in for. */+ MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(TestLocalFile, "Win32LocalFile")+public:+ TestLocalFile() : LocalFile() {}+};++TestLocalFile::~TestLocalFile() {}++/* Just enough LocalFileSystem to let INI::load() find a file on disk. */+class TestLocalFileSystem : public LocalFileSystem+{+public:+ virtual void init( void ) {}+ virtual void reset( void ) {}+ virtual void update( void ) {}++ virtual File *openFile( const Char *filename, Int access = 0 )+ {+ TestLocalFile *file = newInstance( TestLocalFile );+ if( file->open( filename, access ) == FALSE )+ {+ file->close();+ return NULL;+ }+ file->deleteOnClose();+ return file;+ }++ virtual Bool doesFileExist( const Char *filename ) const+ {+ FILE *fp = fopen( filename, "rb" );+ if( fp == NULL )+ return FALSE;+ fclose( fp );+ return TRUE;+ }++ virtual void getFileListInDirectory( const AsciiString&, const AsciiString&,+ const AsciiString&, FilenameList&, Bool ) const {}+ virtual Bool getFileInfo( const AsciiString&, FileInfo* ) const { return FALSE; }+ virtual Bool createDirectory( AsciiString ) { return FALSE; }+};++/* The subsystems below are globals the engine owns; bring them up once and+ leave them up for the whole run, exactly as GameEngine::init() would. */+static Bool bootOnce( void )+{+ static Bool booted = FALSE;+ if( booted )+ return TRUE;++ initMemoryManager();++ TheNameKeyGenerator = NEW NameKeyGenerator;+ TheNameKeyGenerator->init();++ TheLocalFileSystem = NEW TestLocalFileSystem;+ TheFileSystem = NEW FileSystem;++ booted = TRUE;+ return TRUE;+}++static const char *TEST_INI = "test_gameengine_tmp.ini";++/* INI reports every failure by throwing - either an INIException carrying a+ message or a bare enum code - so run the load behind something that turns+ that back into a check failure with the message attached. */+static Bool loadIni( const char *name )+{+ INI ini;+ try+ {+ ini.load( AsciiString( name ), INI_LOAD_OVERWRITE, NULL );+ return TRUE;+ }+ catch( INIException &e )+ {+ printf( " INI threw: %s\n", e.mFailureMessage ? e.mFailureMessage : "(no message)" );+ }+ catch( ... )+ {+ /* the enum error codes (INI_UNKNOWN_TOKEN et al) come through here */+ printf( " INI threw an error code\n" );+ }+ return FALSE;+}++static void writeFile( const char *name, const char *text )+{+ FILE *fp = fopen( name, "wb" );+ CHECK( fp != NULL );+ fwrite( text, 1, strlen( text ), fp );+ fclose( fp );+}++//////////////////////////////////////////////////////////////////////////////+// Memory manager and the string types it hands out+//////////////////////////////////////////////////////////////////////////////++TEST(boot_memory_manager)+{+ CHECK( bootOnce() );++ AsciiString a( "Command & Conquer" );+ CHECK_EQ( a.getLength(), 17 );+ a.concat( ": Generals" );+ CHECK_STR( a.str(), "Command & Conquer: Generals" );++ /* AsciiString is refcounted and copy-on-write; a mutation through one+ handle must not reach the other. */+ AsciiString b = a;+ b.set( "Zero Hour" );+ CHECK_STR( a.str(), "Command & Conquer: Generals" );+ CHECK_STR( b.str(), "Zero Hour" );++ UnicodeString u;+ u.translate( a );+ CHECK( wcscmp( u.str(), L"Command & Conquer: Generals" ) == 0 );+}++TEST(name_key_generator_round_trips)+{+ CHECK( bootOnce() );++ NameKeyType k1 = TheNameKeyGenerator->nameToKey( "TankGeneralUSA" );+ NameKeyType k2 = TheNameKeyGenerator->nameToKey( "TankGeneralUSA" );+ NameKeyType k3 = TheNameKeyGenerator->nameToKey( "TankGeneralChina" );++ CHECK_EQ( (Int)k1, (Int)k2 );+ CHECK_NE( (Int)k1, (Int)k3 );+ CHECK_STR( TheNameKeyGenerator->keyToName( k1 ).str(), "TankGeneralUSA" );++ /* nameToKey is case sensitive, nameToLowercaseKey is not. */+ CHECK_NE( (Int)k1, (Int)TheNameKeyGenerator->nameToKey( "tankgeneralusa" ) );+ CHECK_EQ( (Int)TheNameKeyGenerator->nameToLowercaseKey( "TankGeneralUSA" ),+ (Int)TheNameKeyGenerator->nameToLowercaseKey( "tankgeneralusa" ) );+}++/* The port aliased hash_map onto unordered_map, which meant supplying+ rts::hash<AsciiString>. STLport's default hashed the pointer, so equal+ strings in different buffers have to land in the same bucket now. */+TEST(asciistring_hash_is_by_content)+{+ CHECK( bootOnce() );++ char buf[ 32 ];+ strcpy( buf, "AmericaTankCrusader" );++ AsciiString fromLiteral( "AmericaTankCrusader" );+ AsciiString fromBuffer( buf );+ CHECK( fromLiteral.str() != fromBuffer.str() ); // genuinely different storage++ rts::hash<AsciiString> hasher;+ CHECK_EQ( (Int)hasher( fromLiteral ), (Int)hasher( fromBuffer ) );+ CHECK_NE( (Int)hasher( fromLiteral ), (Int)hasher( AsciiString( "AmericaTankPaladin" ) ) );++ std::hash_map< AsciiString, Int, rts::hash<AsciiString>, rts::equal_to<AsciiString> > m;+ m[ fromLiteral ] = 7;+ CHECK_EQ( (Int)m.size(), 1 );+ CHECK_EQ( m[ fromBuffer ], 7 ); // same key, not a second entry+ CHECK_EQ( (Int)m.size(), 1 );+}++//////////////////////////////////////////////////////////////////////////////+// The INI parser+//////////////////////////////////////////////////////////////////////////////++/* A WaterSet block exercises four of the field parsers (AsciiString, Real, Int,+ RGBAColorInt) and needs no subsystem beyond the ones booted above. */+TEST(ini_loads_a_waterset_block)+{+ CHECK( bootOnce() );++ writeFile( TEST_INI,+ "; a comment line\r\n"+ "WaterSet NIGHT\r\n"+ " SkyTexture = TSNightSky.tga\r\n"+ " WaterTexture = TWWater01.tga\r\n"+ " WaterRepeatCount = 5\r\n"+ " SkyTexelsPerUnit = 0.25\r\n"+ " UScrollPerMS = 0.5\r\n"+ " VScrollPerMS = -0.5\r\n"+ " DiffuseColor = R:12 G:34 B:56 A:78\r\n"+ "End\r\n" );++ WaterSetting &night = WaterSettings[ TIME_OF_DAY_NIGHT ];+ night.m_waterRepeatCount = -1;++ CHECK( loadIni( TEST_INI ) );++ CHECK_STR( night.m_skyTextureFile.str(), "TSNightSky.tga" );+ CHECK_STR( night.m_waterTextureFile.str(), "TWWater01.tga" );+ CHECK_EQ( night.m_waterRepeatCount, 5 );+ CHECK_NEAR( night.m_skyTexelsPerUnit, 0.25f, 0.0001f );+ CHECK_NEAR( night.m_uScrollPerMs, 0.5f, 0.0001f );+ CHECK_NEAR( night.m_vScrollPerMs, -0.5f, 0.0001f );+ CHECK_EQ( (Int)night.m_waterDiffuseColor.red, 12 );+ CHECK_EQ( (Int)night.m_waterDiffuseColor.green, 34 );+ CHECK_EQ( (Int)night.m_waterDiffuseColor.blue, 56 );+ CHECK_EQ( (Int)night.m_waterDiffuseColor.alpha, 78 );++ remove( TEST_INI );+}++/* Blocks are keyed by name, so a second load of the same block has to land on+ the same record - that is how the game's override files work. */+TEST(ini_second_load_overwrites_the_same_record)+{+ CHECK( bootOnce() );++ writeFile( TEST_INI,+ "WaterSet MORNING\r\n"+ " WaterRepeatCount = 3\r\n"+ "End\r\n" );++ CHECK( loadIni( TEST_INI ) );+ CHECK_EQ( WaterSettings[ TIME_OF_DAY_MORNING ].m_waterRepeatCount, 3 );++ writeFile( TEST_INI,+ "WaterSet MORNING\r\n"+ " WaterRepeatCount = 9\r\n"+ "End\r\n" );++ CHECK( loadIni( TEST_INI ) );+ CHECK_EQ( WaterSettings[ TIME_OF_DAY_MORNING ].m_waterRepeatCount, 9 );++ remove( TEST_INI );+}++/* A missing file throws rather than returning; the loader has no other way to+ report it. */+TEST(ini_missing_file_throws)+{+ CHECK( bootOnce() );++ Bool threw = FALSE;+ INI ini;+ try+ {+ ini.load( AsciiString( "no_such_file_anywhere.ini" ), INI_LOAD_OVERWRITE, NULL );+ }+ catch( ... )+ {+ threw = TRUE;+ }+ CHECK( threw );+}++/* An unknown block name aborts the whole file - INI::load throws+ INI_UNKNOWN_TOKEN and the blocks after it never get read. Worth pinning:+ nothing in the loader skips unknown blocks, so an INI written for a newer+ build breaks an older one outright. */+TEST(ini_unknown_block_aborts_the_file)+{+ CHECK( bootOnce() );++ WaterSettings[ TIME_OF_DAY_EVENING ].m_waterRepeatCount = -1;++ writeFile( TEST_INI,+ "ThisBlockTypeDoesNotExist SomeName\r\n"+ " Whatever = 1\r\n"+ "End\r\n"+ "WaterSet EVENING\r\n"+ " WaterRepeatCount = 4\r\n"+ "End\r\n" );++ CHECK( loadIni( TEST_INI ) == FALSE );+ CHECK_EQ( WaterSettings[ TIME_OF_DAY_EVENING ].m_waterRepeatCount, -1 );++ remove( TEST_INI );+}diff --git a/GeneralsMD/Code/Tests/test_gameengine_stubs.cpp b/GeneralsMD/Code/Tests/test_gameengine_stubs.cppnew file mode 100644index 000000000..dff58520f--- /dev/null+++ b/GeneralsMD/Code/Tests/test_gameengine_stubs.cpp@@ -0,0 +1,113 @@+/*+ * Link-time stand-ins for the pieces of the game that do not live in+ * gameengine.lib.+ *+ * Two kinds of thing end up here:+ *+ * - The well-known Dict keys and the MapObject list. Both are *defined* in+ * GameEngineDevice's WorldHeightMap.cpp (it is the one file that defines+ * INSTANTIATE_WELL_KNOWN_KEYS), which is DX8 code and not ported yet, so the+ * keys are instantiated here instead - same macro, same one definition.+ *+ * - Device/exe callbacks the engine calls out to: the W3D shader manager, the+ * CD manager, the Win32 message boxes, WinMain. None of them are reachable+ * from the tests, so they are stubs; when GameEngineDevice lands in Phase 4+ * the real definitions take over and this file shrinks.+ */++// must come before anything else that might pull the header in transitively+#define INSTANTIATE_WELL_KNOWN_KEYS+#include "Common/WellKnownKeys.h"++#include "Common/MapObject.h"+#include "Common/OSDisplay.h"+#include "Common/CDManager.h"+#include "Common/GameLOD.h"+#include "GameClient/GUICallbacks.h"+#include "GameClient/Shadow.h"+#include "GameLogic/TerrainLogic.h"++#include <windows.h>++//////////////////////////////////////////////////////////////////////////////+// MapObject - the map file's object list, owned by WorldHeightMap.cpp+//////////////////////////////////////////////////////////////////////////////++MapObject *MapObject::TheMapObjectListPtr = NULL;+Dict MapObject::TheWorldDict;++MapObject::MapObject( Coord3D loc, AsciiString name, Real angle, Int flags,+ const Dict *props, const ThingTemplate *thingTemplate ) :+ m_location(loc), m_objectName(name), m_thingTemplate(thingTemplate), m_angle(angle),+ m_nextMapObject(NULL), m_flags(flags), m_color(0), m_renderObj(NULL),+ m_shadowObj(NULL), m_runtimeFlags(0)+{+ if( props )+ m_properties = *props;+ for( Int i = 0; i < BRIDGE_MAX_TOWERS; i++ )+ m_bridgeTowers[ i ] = NULL;+}++MapObject::~MapObject() {}++void MapObject::setName( AsciiString name ) { m_objectName = name; }+void MapObject::setThingTemplate( const ThingTemplate *thing ) { m_thingTemplate = thing; }+const ThingTemplate *MapObject::getThingTemplate( void ) const { return m_thingTemplate; }++WaypointID MapObject::getWaypointID( void )+{+ Bool exists;+ return (WaypointID)m_properties.getInt( TheKey_waypointID, &exists );+}++AsciiString MapObject::getWaypointName( void )+{+ Bool exists;+ return m_properties.getAsciiString( TheKey_waypointName, &exists );+}++//////////////////////////////////////////////////////////////////////////////+// Device layer+//////////////////////////////////////////////////////////////////////////////++HWND ApplicationHWnd = NULL;+ProjectedShadowManager *TheProjectedShadowManager = NULL;++const Char *g_strFile = "data\\Generals.str";+const Char *g_csfFile = "data\\%s\\Generals.csf";++CDManagerInterface *CreateCDManager( void ) { return NULL; }++OSDisplayButtonType OSDisplayWarningBox( AsciiString, AsciiString, UnsignedInt, UnsignedInt )+{+ return OSDBT_ERROR;+}++WindowMsgHandledType MOTDSystem( GameWindow *, UnsignedInt, WindowMsgData, WindowMsgData )+{+ return MSG_IGNORED;+}++Bool testMinimumRequirements( ChipsetType *videoChipType, CpuType *cpuType, Int *cpuFreq,+ Int *numRAM, Real *intBenchIndex, Real *floatBenchIndex,+ Real *memBenchIndex )+{+ if( videoChipType ) *videoChipType = DC_UNKNOWN;+ if( cpuType ) *cpuType = XX;+ if( cpuFreq ) *cpuFreq = 0;+ if( numRAM ) *numRAM = 0;+ if( intBenchIndex ) *intBenchIndex = 0.0f;+ if( floatBenchIndex ) *floatBenchIndex = 0.0f;+ if( memBenchIndex ) *memBenchIndex = 0.0f;+ return FALSE;+}++void ReloadAllTextures( void ) {}+void oversizeTheTerrain( Int ) {}+void doSkyBoxSet( Bool ) {}++int getQR2HostingStatus( void ) { return 0; }++/* StackDump takes WinMain's address to work out where the exe's own code+ starts; the test is a console app and never gets here. */+int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { return 0; }