From bbee101844a62f76a7f4b1b83991f2679049a728 Mon Sep 17 00:00:00 2001 From: tomsons26 Date: Mon, 28 Apr 2025 14:50:13 +0300 Subject: [PATCH 1/3] [GEN] Backports ZH additions --- .../Include/Common/ArchiveFileSystem.h | 3 +- .../GameEngine/Include/Common/BitFlagsIO.h | 12 ++ .../GameEngine/Include/Common/DataChunk.h | 3 + .../Code/GameEngine/Include/Common/Energy.h | 4 +- .../GameEngine/Include/Common/GameAudio.h | 8 +- .../Code/GameEngine/Include/Common/GameType.h | 2 + .../Code/GameEngine/Include/Common/Geometry.h | 1 + .../Code/GameEngine/Include/Common/Money.h | 9 +- .../Include/Common/MultiplayerSettings.h | 6 +- .../Include/Common/NameKeyGenerator.h | 5 + .../Code/GameEngine/Include/Common/Radar.h | 1 + .../GameEngine/Include/Common/ScopedMutex.h | 5 +- .../Include/Common/SparseMatchFinder.h | 20 +++ .../Include/Common/SpecialPowerMaskType.h | 1 + .../GameEngine/Include/Common/StateMachine.h | 3 +- .../Code/GameEngine/Include/Common/Xfer.h | 2 +- Generals/Code/GameEngine/Include/Common/crc.h | 76 +++++++++ .../GameEngine/Include/GameClient/Color.h | 9 + .../Include/GameClient/ControlBar.h | 18 +- .../Include/GameClient/GadgetCheckBox.h | 1 + .../Include/GameClient/GameWindow.h | 1 + .../GameEngine/Include/GameClient/Mouse.h | 2 +- .../Include/GameLogic/Module/AIUpdate.h | 3 + .../GameLogic/Module/AutoDepositUpdate.h | 7 + .../GameLogic/Module/FireWeaponUpdate.h | 2 + .../GameLogic/Module/HackInternetAIUpdate.h | 6 +- .../Include/GameNetwork/networkutil.h | 2 + .../Source/Common/Audio/GameAudio.cpp | 30 ++++ .../Source/Common/Audio/GameMusic.cpp | 5 + .../Source/Common/INI/INICommandButton.cpp | 16 ++ .../Source/Common/INI/INIMapCache.cpp | 6 + .../Source/Common/MessageStream.cpp | 9 + .../Source/Common/NameKeyGenerator.cpp | 67 ++++++++ .../GameEngine/Source/Common/RTS/Energy.cpp | 20 +++ .../GameEngine/Source/Common/RTS/Money.cpp | 10 ++ .../GameEngine/Source/Common/StateMachine.cpp | 74 +++++++++ .../Source/Common/System/DataChunk.cpp | 24 +++ .../Source/Common/System/GameCommon.cpp | 2 +- .../Source/Common/System/Geometry.cpp | 47 ++++++ .../GameEngine/Source/Common/System/Radar.cpp | 26 ++- .../GameEngine/Source/Common/System/Xfer.cpp | 63 +++++++ .../GameEngine/Source/Common/Thing/Module.cpp | 6 + .../Source/Common/Thing/ThingTemplate.cpp | 16 +- .../Code/GameEngine/Source/Common/crc.cpp | 2 + .../GameEngine/Source/GameClient/Color.cpp | 42 ++++- .../GameClient/GUI/ControlBar/ControlBar.cpp | 70 ++++++++ .../GUICallbacks/Menus/WOLBuddyOverlay.cpp | 3 - .../GameClient/GUI/Gadget/GadgetCheckBox.cpp | 23 +++ .../Source/GameClient/GUI/GameWindow.cpp | 10 ++ .../GUI/GameWindowManagerScript.cpp | 7 + .../GameEngine/Source/GameClient/GameText.cpp | 5 + .../Source/GameClient/Input/Mouse.cpp | 5 + .../Source/GameClient/LanguageFilter.cpp | 2 +- .../GameClient/System/CampaignManager.cpp | 8 + .../GameClient/Terrain/TerrainVisual.cpp | 9 + .../Source/GameLogic/AI/AIGroup.cpp | 96 +++++++++++ .../Object/Behavior/AutoHealBehavior.cpp | 6 + .../Collide/CrateCollide/CrateCollide.cpp | 6 + .../Object/Contain/OverlordContain.cpp | 8 + .../GameLogic/Object/Die/CreateObjectDie.cpp | 6 + .../GameLogic/Object/Die/DestroyDie.cpp | 6 + .../Object/SpecialPower/SpecialAbility.cpp | 5 + .../GameLogic/Object/Update/AIUpdate.cpp | 12 ++ .../Update/AIUpdate/HackInternetAIUpdate.cpp | 19 +++ .../Object/Update/AssistedTargetingUpdate.cpp | 9 + .../Object/Update/AutoDepositUpdate.cpp | 31 +++- .../FireOCLAfterWeaponCooldownUpdate.cpp | 6 + .../Object/Update/FireWeaponUpdate.cpp | 16 +- .../GameSpy/StagingRoomGameInfo.cpp | 6 +- .../MilesAudioDevice/MilesAudioManager.h | 4 + .../GameClient/W3DDisplayStringManager.h | 10 +- .../W3DDevice/GameClient/W3DProjectedShadow.h | 40 ++++- .../W3DDevice/GameClient/W3DWaypointBuffer.h | 2 + .../MilesAudioDevice/MilesAudioManager.cpp | 39 +++++ .../W3DDevice/Common/System/W3DRadar.cpp | 151 +++++++++++++++++ .../Drawable/Draw/W3DDependencyModelDraw.cpp | 9 + .../GameClient/Shadow/W3DProjectedShadow.cpp | 134 +++++++++++---- .../GameClient/W3DDisplayStringManager.cpp | 21 ++- .../Source/W3DDevice/GameClient/W3DScene.cpp | 157 ++++++++++++++++++ .../GameClient/W3dWaypointBuffer.cpp | 28 ++-- .../Code/Tools/GUIEdit/Source/GUIEdit.cpp | 8 +- .../Tools/WorldBuilder/src/MapPreview.cpp | 16 +- 82 files changed, 1573 insertions(+), 97 deletions(-) diff --git a/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h b/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h index e9695e0c17..b1f75e7411 100644 --- a/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h +++ b/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h @@ -172,11 +172,10 @@ class ArchiveFileSystem : public SubsystemInterface // Unprotected this for copy-protection routines AsciiString getArchiveFilenameForFile(const AsciiString& filename) const; - void loadMods( void ); protected: - virtual void loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite = FALSE); ///< load the archive file's header information and apply it to the global archive directory tree. + virtual void loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite = FALSE ); ///< load the archive file's header information and apply it to the global archive directory tree. ArchiveFileMap m_archiveFileMap; ArchivedDirectoryInfo m_rootDirectory; diff --git a/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h b/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h index da4a1e3cb1..5911362b0a 100644 --- a/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h +++ b/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h @@ -138,6 +138,18 @@ template ((BitFlags*)store)->parse(ini, NULL); } +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +template +/*static*/ void BitFlags::parseSingleBitFromINI(INI* ini, void* /*instance*/, void *store, const void* /*userData*/) +{ + const char *token = ini->getNextToken(); + Int bitIndex = INI::scanIndexList(token, s_bitNameList); // this throws if the token is not found + + Int *storeAsInt = (Int*)store; + *storeAsInt = bitIndex; +} + //------------------------------------------------------------------------------------------------- /** Xfer method * Version Info: diff --git a/Generals/Code/GameEngine/Include/Common/DataChunk.h b/Generals/Code/GameEngine/Include/Common/DataChunk.h index 3fe923efda..a1130f184c 100644 --- a/Generals/Code/GameEngine/Include/Common/DataChunk.h +++ b/Generals/Code/GameEngine/Include/Common/DataChunk.h @@ -136,6 +136,7 @@ class DataChunkOutput void writeUnicodeString(UnicodeString string); void writeArrayOfBytes(char *ptr, Int len); void writeDict(const Dict& d); + void writeNameKey(const NameKeyType key); }; //---------------------------------------------------------------------- @@ -228,6 +229,8 @@ class DataChunkInput UnicodeString readUnicodeString(void); Dict readDict(void); void readArrayOfBytes(char *ptr, Int len); + + NameKeyType readNameKey(void); }; diff --git a/Generals/Code/GameEngine/Include/Common/Energy.h b/Generals/Code/GameEngine/Include/Common/Energy.h index a6faacd27c..aea2740367 100644 --- a/Generals/Code/GameEngine/Include/Common/Energy.h +++ b/Generals/Code/GameEngine/Include/Common/Energy.h @@ -66,7 +66,7 @@ class Energy : public Snapshot public: - inline Energy() : m_energyProduction(0), m_energyConsumption(0), m_owner(NULL) { } + Energy(); // reset energy information to base values. void init( Player *owner) @@ -77,7 +77,7 @@ class Energy : public Snapshot } /// return current energy production in kilowatts - Int getProduction() const { return m_energyProduction; } + Int getProduction() const; /// return current energy consumption in kilowatts Int getConsumption() const { return m_energyConsumption; } diff --git a/Generals/Code/GameEngine/Include/Common/GameAudio.h b/Generals/Code/GameEngine/Include/Common/GameAudio.h index a9254cdca6..642f0e9005 100644 --- a/Generals/Code/GameEngine/Include/Common/GameAudio.h +++ b/Generals/Code/GameEngine/Include/Common/GameAudio.h @@ -240,6 +240,8 @@ class AudioManager : public SubsystemInterface // on zoom. virtual void set3DVolumeAdjustment( Real volumeAdjustment ); + virtual Bool has3DSensitiveStreamsPlaying( void ) const = 0; + virtual void *getHandleForBink( void ) = 0; virtual void releaseHandleForBink( void ) = 0; @@ -257,6 +259,7 @@ class AudioManager : public SubsystemInterface virtual void processRequestList( void ); virtual AudioEventInfo *newAudioEventInfo( AsciiString newEventName ); + virtual void addAudioEventInfo( AudioEventInfo * newEventInfo ); virtual AudioEventInfo *findAudioEventInfo( AsciiString eventName ) const; const AudioSettings *getAudioSettings( void ) const; @@ -298,6 +301,7 @@ class AudioManager : public SubsystemInterface // For Worldbuilder, to build lists from which to select virtual void findAllAudioEventsOfType( AudioType audioType, std::vector& allEvents ); + virtual const AudioEventInfoHash & getAllAudioEvents() const { return m_allAudioEventInfo; } Real getZoomVolume() const { return m_zoomVolume; } protected: @@ -316,7 +320,9 @@ class AudioManager : public SubsystemInterface // For tracking purposes virtual AudioHandle allocateNewHandle( void ); - + + void removeAllAudioRequests( void ); + protected: AudioSettings *m_audioSettings; MiscAudio *m_miscAudio; diff --git a/Generals/Code/GameEngine/Include/Common/GameType.h b/Generals/Code/GameEngine/Include/Common/GameType.h index 566f560f7c..b793738073 100644 --- a/Generals/Code/GameEngine/Include/Common/GameType.h +++ b/Generals/Code/GameEngine/Include/Common/GameType.h @@ -58,6 +58,8 @@ enum FormationID CPP_11(: Int) FORCE_FORMATIONID_TO_LONG_SIZE = 0x7ffffff }; +#define INVALID_ANGLE -100.0f + class INI; //------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/Geometry.h b/Generals/Code/GameEngine/Include/Common/Geometry.h index ec3e436fdb..765376a96e 100644 --- a/Generals/Code/GameEngine/Include/Common/Geometry.h +++ b/Generals/Code/GameEngine/Include/Common/Geometry.h @@ -179,6 +179,7 @@ class GeometryInfo : public Snapshot /// note that the pt is generated using game logic random, not game client random! void makeRandomOffsetWithinFootprint(Coord3D& pt) const; + void makeRandomOffsetOnPerimeter(Coord3D& pt) const; //Chooses a random point on the extent border. void clipPointToFootprint(const Coord3D& geomCenter, Coord3D& ptToClip) const; diff --git a/Generals/Code/GameEngine/Include/Common/Money.h b/Generals/Code/GameEngine/Include/Common/Money.h index 2af2524424..c8b13e9d0c 100644 --- a/Generals/Code/GameEngine/Include/Common/Money.h +++ b/Generals/Code/GameEngine/Include/Common/Money.h @@ -82,8 +82,15 @@ class Money : public Snapshot void setPlayerIndex(Int ndx) { m_playerIndex = ndx; } -protected: + static void parseMoneyAmount( INI *ini, void *instance, void *store, const void* userData ); + + // Does the amount of this == the amount of that (compare everything except m_playerIndex) + Bool amountEqual( const Money & that ) const + { + return m_money == that.m_money; + } +protected: // snapshot methods virtual void crc( Xfer *xfer ); virtual void xfer( Xfer *xfer ); diff --git a/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h b/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h index 1d93377754..8cc00ebb40 100644 --- a/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h +++ b/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h @@ -79,9 +79,9 @@ class MultiplayerSettings : public SubsystemInterface MultiplayerSettings( void ); - void init() { } - void update() { } - void reset() { } + virtual void init() { } + virtual void update() { } + virtual void reset() { } //----------------------------------------------------------------------------------------------- static const FieldParse m_multiplayerSettingsFieldParseTable[]; ///< the parse table for INI definition diff --git a/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h b/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h index 1363a4b5b6..583f42d658 100644 --- a/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h +++ b/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h @@ -96,9 +96,11 @@ class NameKeyGenerator : public SubsystemInterface /// Given a string, convert into a unique integer key. NameKeyType nameToKey(const AsciiString& name) { return nameToKey(name.str()); } + NameKeyType nameToLowercaseKey(const AsciiString& name) { return nameToLowercaseKey(name.str()); } /// Given a string, convert into a unique integer key. NameKeyType nameToKey(const char* name); + NameKeyType nameToLowercaseKey(const char *name); /** given a key, return the name. this is almost never needed, @@ -108,6 +110,9 @@ class NameKeyGenerator : public SubsystemInterface */ AsciiString keyToName(NameKeyType key); + // Get a string out of the INI. Store it into a NameKeyType + static void parseStringAsNameKeyType( INI *ini, void *instance, void *store, const void* userData ); + private: enum diff --git a/Generals/Code/GameEngine/Include/Common/Radar.h b/Generals/Code/GameEngine/Include/Common/Radar.h index 33d61a0069..fb1b65547a 100644 --- a/Generals/Code/GameEngine/Include/Common/Radar.h +++ b/Generals/Code/GameEngine/Include/Common/Radar.h @@ -169,6 +169,7 @@ class Radar : public Snapshot, Bool isRadarWindow( GameWindow *window ) { return (m_radarWindow == window) && (m_radarWindow != NULL); } Bool radarToWorld( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point on terrain + Bool radarToWorld2D( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point (x,y only!) Bool worldToRadar( const Coord3D *world, ICoord2D *radar ); ///< translate world point to radar (x,y) Bool localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ); ///< translate pixel (with UL of radar being (0,0)) to logical radar coords Bool screenPixelToWorld( const ICoord2D *pixel, Coord3D *world ); ///< translate pixel (with UL of the screen being (0,0)) to world position in the world diff --git a/Generals/Code/GameEngine/Include/Common/ScopedMutex.h b/Generals/Code/GameEngine/Include/Common/ScopedMutex.h index ffac55a025..0aea5e2859 100644 --- a/Generals/Code/GameEngine/Include/Common/ScopedMutex.h +++ b/Generals/Code/GameEngine/Include/Common/ScopedMutex.h @@ -34,7 +34,10 @@ class ScopedMutex public: ScopedMutex(HANDLE mutex) : m_mutex(mutex) { - WaitForSingleObject(m_mutex, INFINITE); + DWORD status = WaitForSingleObject(m_mutex, 500); + if (status != WAIT_OBJECT_0) { + DEBUG_LOG(("ScopedMutex WaitForSingleObject timed out - status %d\n", status)); + } } ~ScopedMutex() diff --git a/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h b/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h index 7ea1c91cb3..fcd66610a0 100644 --- a/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h +++ b/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h @@ -72,6 +72,26 @@ class SparseMatchFinder } }; + struct MapHelper + { + bool operator()(const BITSET& a, const BITSET& b) const + { + int i; + if (a.size() < b.size()) { + return true; + } + for (i = 0; i < a.size(); ++i) { + bool aVal = a.test(i); + bool bVal = b.test(i); + if (aVal && bVal) continue; + if (!aVal && !bVal) continue; + if (!aVal) return true; + return false; + } + return false; // all bits match. + } + }; + //------------------------------------------------------------------------------------------------- typedef std::hash_map< BITSET, const MATCHABLE*, HashMapHelper, HashMapHelper > MatchMap; diff --git a/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h b/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h index f350a2ea45..ffabd68f9c 100644 --- a/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h +++ b/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h @@ -31,6 +31,7 @@ #define __SPECIALPOWERMASKTYPE_H__ #include "Common/BitFlags.h" +#include "Common/BitFlagsIO.h" #include "Common/SpecialPowerType.h" typedef BitFlags SpecialPowerMaskType; diff --git a/Generals/Code/GameEngine/Include/Common/StateMachine.h b/Generals/Code/GameEngine/Include/Common/StateMachine.h index 25cb7eb145..97d4419977 100644 --- a/Generals/Code/GameEngine/Include/Common/StateMachine.h +++ b/Generals/Code/GameEngine/Include/Common/StateMachine.h @@ -45,7 +45,7 @@ class State; class StateMachine; class Object; -#undef STATE_MACHINE_DEBUG +//#undef STATE_MACHINE_DEBUG #if defined(_DEBUG) #define STATE_MACHINE_DEBUG #endif @@ -169,6 +169,7 @@ class State : public MemoryPoolObject, public Snapshot #ifdef STATE_MACHINE_DEBUG virtual AsciiString getName() const {return m_name;} + std::vector *getTransitions(void); #endif // for internal use by the StateMachine class --------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/Xfer.h b/Generals/Code/GameEngine/Include/Common/Xfer.h index 7b0eabd307..cdfa7c0f16 100644 --- a/Generals/Code/GameEngine/Include/Common/Xfer.h +++ b/Generals/Code/GameEngine/Include/Common/Xfer.h @@ -43,7 +43,6 @@ #define __XFER_H_ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "Common/ModelState.h" #include "Common/Science.h" #include "Common/Upgrade.h" @@ -171,6 +170,7 @@ class Xfer virtual void xferRGBAColorInt( RGBAColorInt *rgbaColorInt ); virtual void xferObjectID( ObjectID *objectID ); virtual void xferDrawableID( DrawableID *drawableID ); + virtual void xferSTLObjectIDVector( std::vector *objectIDVectorData ); virtual void xferSTLObjectIDList( std::list< ObjectID > *objectIDListData ); virtual void xferSTLIntList( std::list< Int > *intListData ); virtual void xferScienceType( ScienceType *science ); diff --git a/Generals/Code/GameEngine/Include/Common/crc.h b/Generals/Code/GameEngine/Include/Common/crc.h index 8547351f09..855dc2d520 100644 --- a/Generals/Code/GameEngine/Include/Common/crc.h +++ b/Generals/Code/GameEngine/Include/Common/crc.h @@ -32,6 +32,9 @@ #define _CRC_H_ #include "Lib/BaseType.h" + +#ifdef _DEBUG + //#include "winsock2.h" // for htonl class CRC @@ -50,4 +53,77 @@ class CRC UnsignedInt crc; }; +#else + +// optimized inline only version +class CRC +{ +public: + CRC(void) { crc=0; } + + /// Compute the CRC for a buffer, added into current CRC + __forceinline void computeCRC( const void *buf, Int len ) + { + if (!buf||len<1) + return; + +#if !(defined(_MSC_VER) && _MSC_VER < 1300) + // C++ version left in for reference purposes + for (UnsignedByte *uintPtr=(UnsignedByte *)buf;len>0;len--,uintPtr++) + { + int hibit; + if (crc & 0x80000000) + { + hibit = 1; + } + else + { + hibit = 0; + } + + crc <<= 1; + crc += *uintPtr; + crc += hibit; + } +#else + // ASM version, verified by comparing resulting data with C++ version data + unsigned *crcPtr=&crc; + _asm + { + mov esi,[buf] + mov ecx,[len] + dec ecx + mov edi,[crcPtr] + mov ebx,dword ptr [edi] + xor eax,eax + lp: + mov al,byte ptr [esi] + shl ebx,1 + inc esi + adc ebx,eax + dec ecx + jns lp + mov dword ptr [edi],ebx + }; +#endif + } + + /// Clears the CRC to 0 + void clear( void ) + { + crc = 0; + } + + ///< Get the combined CRC + UnsignedInt get( void ) const + { + return crc; + } + +private: + UnsignedInt crc; +}; + +#endif + #endif // _CRC_H_ diff --git a/Generals/Code/GameEngine/Include/GameClient/Color.h b/Generals/Code/GameEngine/Include/GameClient/Color.h index 2c512e7986..94d952790c 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Color.h +++ b/Generals/Code/GameEngine/Include/GameClient/Color.h @@ -76,6 +76,15 @@ extern void GameGetColorComponents( Color color, UnsignedByte *green, UnsignedByte *blue, UnsignedByte *alpha ); + +// Put on ice until later - M Lorenzen +//extern void GameGetColorComponentsWithCheatSpy( Color color, +// UnsignedByte *red, +// UnsignedByte *green, +// UnsignedByte *blue, +// UnsignedByte *alpha ); + + extern void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha ); extern Color GameDarkenColor( Color color, Int percent = 10 ); diff --git a/Generals/Code/GameEngine/Include/GameClient/ControlBar.h b/Generals/Code/GameEngine/Include/GameClient/ControlBar.h index c25dd7fccf..7d30a219bf 100644 --- a/Generals/Code/GameEngine/Include/GameClient/ControlBar.h +++ b/Generals/Code/GameEngine/Include/GameClient/ControlBar.h @@ -341,6 +341,10 @@ class CommandButton : public Overridable // bleah. shouldn't be const, but is. sue me. (srj) void copyImagesFrom( const CommandButton *button, Bool markUIDirtyIfChanged ) const; + + // bleah. shouldn't be const, but is. sue me. (Kris) -snork! + void copyButtonTextFrom( const CommandButton *button, Bool shortcutButton, Bool markUIDirtyIfChanged ) const; + // bleah. shouldn't be const, but is. sue me. (srj) void setFlashCount(Int c) const { m_flashCount = c; } @@ -359,8 +363,11 @@ class CommandButton : public Overridable RadiusCursorType m_radiusCursor; ///< radius cursor, if any AsciiString m_cursorName; ///< cursor name for placement (NEED_TARGET_POS) or valid version (CONTEXTMODE_COMMAND) AsciiString m_invalidCursorName; ///< cursor name for invalid version - AsciiString m_textLabel; ///< string manager text label - AsciiString m_descriptionLabel; ///< The description of the current command, read in from the ini + + // bleah. shouldn't be mutable, but is. sue me. (Kris) -snork! + mutable AsciiString m_textLabel; ///< string manager text label + mutable AsciiString m_descriptionLabel; ///< The description of the current command, read in from the ini + AsciiString m_purchasedLabel; ///< Description for the current command if it has already been purchased. AsciiString m_conflictingLabel; ///< Description for the current command if it can't be selected due to multually-exclusive choice. WeaponSlotType m_weaponSlot; ///< for commands that refer to a weapon slot @@ -640,7 +647,7 @@ class ControlBar : public SubsystemInterface virtual void update( void ); ///< from subsystem interface /// mark the UI as dirty so the context of everything is re-evaluated - void markUIDirty( void ) { m_UIDirty = TRUE; } + void markUIDirty( void ); /// a drawable has just become selected void onDrawableSelected( Drawable *draw ); @@ -999,6 +1006,11 @@ class ControlBar : public SubsystemInterface Bool m_radarAttackGlowOn; Int m_remainingRadarAttackGlowFrames; GameWindow *m_radarAttackGlowWindow; + +#if defined( _INTERNAL ) || defined( _DEBUG ) + UnsignedInt m_lastFrameMarkedDirty; + UnsignedInt m_consecutiveDirtyFrames; +#endif // ControlBarResizer *m_controlBarResizer; }; diff --git a/Generals/Code/GameEngine/Include/GameClient/GadgetCheckBox.h b/Generals/Code/GameEngine/Include/GameClient/GadgetCheckBox.h index 0545f14e47..f801752f62 100644 --- a/Generals/Code/GameEngine/Include/GameClient/GadgetCheckBox.h +++ b/Generals/Code/GameEngine/Include/GameClient/GadgetCheckBox.h @@ -80,6 +80,7 @@ extern void GadgetCheckBoxSetText( GameWindow *g, UnicodeString text ); extern Bool GadgetCheckBoxIsChecked( GameWindow *g ); extern void GadgetCheckBoxSetChecked( GameWindow *g, Bool isChecked); +extern void GadgetCheckBoxToggle( GameWindow *g); inline void GadgetCheckBoxSetEnabledImage( GameWindow *g, const Image *image ) { g->winSetEnabledImage( 0, image ); } inline void GadgetCheckBoxSetEnabledColor( GameWindow *g, Color color ) { g->winSetEnabledColor( 0, color ); } diff --git a/Generals/Code/GameEngine/Include/GameClient/GameWindow.h b/Generals/Code/GameEngine/Include/GameClient/GameWindow.h index e5c427436b..c1204631d5 100644 --- a/Generals/Code/GameEngine/Include/GameClient/GameWindow.h +++ b/Generals/Code/GameEngine/Include/GameClient/GameWindow.h @@ -248,6 +248,7 @@ friend class GameWindowManager; Int winBringToTop( void ); ///< bring this window to the top of the win list Int winEnable( Bool enable ); /**< enable/disable a window, a disbled window can be seen but accepts no input */ + Bool winGetEnabled( void ); ///< Is window enabled? Int winHide( Bool hide ); ///< hide/unhide a window Bool winIsHidden( void ); ///< is this window hidden/ UnsignedInt winSetStatus( UnsignedInt status ); ///< set status bits diff --git a/Generals/Code/GameEngine/Include/GameClient/Mouse.h b/Generals/Code/GameEngine/Include/GameClient/Mouse.h index a055538b23..6010c529af 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Mouse.h +++ b/Generals/Code/GameEngine/Include/GameClient/Mouse.h @@ -281,7 +281,7 @@ class Mouse : public SubsystemInterface void mouseNotifyResolutionChange(void); Bool isClick(const ICoord2D *anchor, const ICoord2D *dest, UnsignedInt previousMouseClick, UnsignedInt currentMouseClick); - + AsciiString m_tooltipFontName; ///< tooltip font Int m_tooltipFontSize; ///< tooltip font Bool m_tooltipFontIsBold; ///< tooltip font diff --git a/Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h b/Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h index 5c779f4f94..b01357434c 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h @@ -412,6 +412,8 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface Real getLocomotorDistanceToGoal(); const Locomotor *getCurLocomotor() const {return m_curLocomotor;} Locomotor *getCurLocomotor() { return m_curLocomotor; } + LocomotorSetType getCurLocomotorSetType() const { return m_curLocomotorSet; } + Bool hasLocomotorForSurface(LocomotorSurfaceType surfaceType); // turret stuff. WhichTurretType getWhichTurretForWeaponSlot(WeaponSlotType wslot, Real* turretAngle, Real* turretPitch = NULL) const; @@ -476,6 +478,7 @@ class AIUpdateInterface : public UpdateModule, public AICommandInterface void friend_endingMove(void); void friend_setPath(Path *newPath); + Path* friend_getPath() { return m_path; } void friend_setGoalObject(Object *obj); diff --git a/Generals/Code/GameEngine/Include/GameLogic/Module/AutoDepositUpdate.h b/Generals/Code/GameEngine/Include/GameLogic/Module/AutoDepositUpdate.h index 976d891cac..f5c77dfe91 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Module/AutoDepositUpdate.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Module/AutoDepositUpdate.h @@ -61,6 +61,13 @@ //----------------------------------------------------------------------------- class Player; class Thing; +void parseUpgradePair( INI *ini, void *instance, void *store, const void *userData ); +struct upgradePair +{ + std::string type; + Int amount; +}; + //----------------------------------------------------------------------------- // TYPE DEFINES /////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/GameLogic/Module/FireWeaponUpdate.h b/Generals/Code/GameEngine/Include/GameLogic/Module/FireWeaponUpdate.h index 8839ffe235..dff6cc6a0a 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Module/FireWeaponUpdate.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Module/FireWeaponUpdate.h @@ -65,6 +65,8 @@ class FireWeaponUpdate : public UpdateModule virtual UpdateSleepTime update(); protected: + + Bool isOkayToFire(); Weapon* m_weapon; diff --git a/Generals/Code/GameEngine/Include/GameLogic/Module/HackInternetAIUpdate.h b/Generals/Code/GameEngine/Include/GameLogic/Module/HackInternetAIUpdate.h index 6259f6b938..6fc04c6096 100644 --- a/Generals/Code/GameEngine/Include/GameLogic/Module/HackInternetAIUpdate.h +++ b/Generals/Code/GameEngine/Include/GameLogic/Module/HackInternetAIUpdate.h @@ -197,10 +197,10 @@ class HackInternetAIUpdate : public AIUpdateInterface, public HackInternetAIInte virtual void aiDoCommand(const AICommandParms* parms); - UnsignedInt getUnpackTime() const { return getHackInternetAIUpdateModuleData()->m_unpackTime; } - UnsignedInt getPackTime() const { return getHackInternetAIUpdateModuleData()->m_packTime; } Real getPackUnpackVariationFactor() const { return getHackInternetAIUpdateModuleData()->m_packUnpackVariationFactor; } - UnsignedInt getCashUpdateDelay() const { return getHackInternetAIUpdateModuleData()->m_cashUpdateDelay; } + UnsignedInt getUnpackTime() const; + UnsignedInt getPackTime() const; + UnsignedInt getCashUpdateDelay() const; UnsignedInt getRegularCashAmount() const { return getHackInternetAIUpdateModuleData()->m_regularCashAmount; } UnsignedInt getVeteranCashAmount() const { return getHackInternetAIUpdateModuleData()->m_veteranCashAmount; } UnsignedInt getEliteCashAmount() const { return getHackInternetAIUpdateModuleData()->m_eliteCashAmount; } diff --git a/Generals/Code/GameEngine/Include/GameNetwork/networkutil.h b/Generals/Code/GameEngine/Include/GameNetwork/networkutil.h index 760a6f640a..9272705623 100644 --- a/Generals/Code/GameEngine/Include/GameNetwork/networkutil.h +++ b/Generals/Code/GameEngine/Include/GameNetwork/networkutil.h @@ -39,7 +39,9 @@ Bool IsCommandSynchronized(NetCommandType type); AsciiString GetAsciiNetCommandType(NetCommandType type); #ifdef DEBUG_LOGGING +extern "C" { void dumpBufferToLog(const void *vBuf, Int len, const char *fname, Int line); +}; #define LOGBUFFER(buf, len) dumpBufferToLog(buf, len, __FILE__, __LINE__) #else #define LOGBUFFER(buf, len) {} diff --git a/Generals/Code/GameEngine/Source/Common/Audio/GameAudio.cpp b/Generals/Code/GameEngine/Source/Common/Audio/GameAudio.cpp index e6102e5753..113bb03ba1 100644 --- a/Generals/Code/GameEngine/Source/Common/Audio/GameAudio.cpp +++ b/Generals/Code/GameEngine/Source/Common/Audio/GameAudio.cpp @@ -390,6 +390,7 @@ void AudioManager::update() m_zoomVolume = 1.0f - scalar * maxBoostScalar; } } + set3DVolumeAdjustment( m_zoomVolume ); } @@ -820,6 +821,18 @@ void AudioManager::appendAudioRequest( AudioRequest *m_request ) m_audioRequests.push_back(m_request); } +//------------------------------------------------------------------------------------------------- +// Remove all pending audio requests +void AudioManager::removeAllAudioRequests( void ) +{ + std::list::iterator it; + for ( it = m_audioRequests.begin(); it != m_audioRequests.end(); it++ ) { + releaseAudioRequest( *it ); + } + + m_audioRequests.clear(); +} + //------------------------------------------------------------------------------------------------- void AudioManager::processRequestList( void ) { @@ -839,6 +852,23 @@ AudioEventInfo *AudioManager::newAudioEventInfo( AsciiString audioName ) return m_allAudioEventInfo[audioName]; } +//------------------------------------------------------------------------------------------------- +// Add an AudioEventInfo structure allocated elsewhere to the audio event list +void AudioManager::addAudioEventInfo( AudioEventInfo * newEvent ) +{ + // Warning: Don't try to copy the structure. It may be a derived class + AudioEventInfo *eventInfo = findAudioEventInfo( newEvent->m_audioName ); + if (eventInfo) + { + DEBUG_CRASH(("Requested add of '%s' multiple times. Is this intentional? - jkmcd\n", newEvent->m_audioName.str())); + *eventInfo = *newEvent; + } + else + { + m_allAudioEventInfo[newEvent->m_audioName] = newEvent; + } +} + //------------------------------------------------------------------------------------------------- AudioEventInfo *AudioManager::findAudioEventInfo( AsciiString eventName ) const { diff --git a/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp b/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp index 28159bff6d..7f6abd3a66 100644 --- a/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp +++ b/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp @@ -52,6 +52,11 @@ #include "Common/GameAudio.h" #include "Common/INI.h" +#ifdef _INTERNAL +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + //---------------------------------------------------------------------------- // Externals //---------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Source/Common/INI/INICommandButton.cpp b/Generals/Code/GameEngine/Source/Common/INI/INICommandButton.cpp index 836294a36f..178463c103 100644 --- a/Generals/Code/GameEngine/Source/Common/INI/INICommandButton.cpp +++ b/Generals/Code/GameEngine/Source/Common/INI/INICommandButton.cpp @@ -32,6 +32,7 @@ #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine #include "Common/INI.h" +#include "Common/SpecialPower.h" #include "GameClient/ControlBar.h" //------------------------------------------------------------------------------------------------- @@ -72,6 +73,21 @@ void ControlBar::parseCommandButtonDefinition( INI *ini ) // parse the ini definition ini->initFromINI( button, button->getFieldParse() ); + + + //Make sure buttons with special power templates also have the appropriate option set. + const SpecialPowerTemplate *spTemplate = button->getSpecialPowerTemplate(); + Bool needsTemplate = BitIsSet( button->getOptions(), NEED_SPECIAL_POWER_SCIENCE ); + if( spTemplate && !needsTemplate ) + { + DEBUG_CRASH( ("[LINE: %d in '%s'] CommandButton %s has SpecialPower = %s but the button also requires Options = NEED_SPECIAL_POWER_SCIENCE. Failure to do so will cause bugs such as invisible side shortcut buttons", + ini->getLineNum(), ini->getFilename().str(), name.str(), spTemplate->getName().str() ) ); + } + else if( !spTemplate && needsTemplate ) + { + DEBUG_CRASH( ("[LINE: %d in '%s'] CommandButton %s has Options = NEED_SPECIAL_POWER_SCIENCE but doesn't specify a SpecialPower = xxxx. Please evaluate INI.", + ini->getLineNum(), ini->getFilename().str(), name.str() ) ); + } } // end parseCommandButtonDefinition diff --git a/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp b/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp index f294a5b0bc..557a220fd3 100644 --- a/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp +++ b/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp @@ -38,6 +38,12 @@ #include "Common/WellKnownKeys.h" #include "Common/QuotedPrintable.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + class MapMetaDataReader { public: diff --git a/Generals/Code/GameEngine/Source/Common/MessageStream.cpp b/Generals/Code/GameEngine/Source/Common/MessageStream.cpp index f1dcfecb07..729dd40000 100644 --- a/Generals/Code/GameEngine/Source/Common/MessageStream.cpp +++ b/Generals/Code/GameEngine/Source/Common/MessageStream.cpp @@ -41,6 +41,15 @@ MessageStream *TheMessageStream = NULL; CommandList *TheCommandList = NULL; + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + + //------------------------------------------------------------------------------------------------ // GameMessage // diff --git a/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp b/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp index dca57a0e6f..506b55714a 100644 --- a/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp +++ b/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp @@ -98,6 +98,16 @@ inline UnsignedInt calcHashForString(const char* p) return result; } +/* ------------------------------------------------------------------------ */ +inline UnsignedInt calcHashForLowercaseString(const char* p) +{ + UnsignedInt result = 0; + Byte *pp = (Byte*)p; + while (*pp) + result = (result << 5) + result + tolower(*pp++); + return result; +} + //------------------------------------------------------------------------------------------------- AsciiString NameKeyGenerator::keyToName(NameKeyType key) { @@ -160,6 +170,63 @@ NameKeyType NameKeyGenerator::nameToKey(const char* nameString) } // end nameToKey +//------------------------------------------------------------------------------------------------- +NameKeyType NameKeyGenerator::nameToLowercaseKey(const char* nameString) +{ + Bucket *b; + + UnsignedInt hash = calcHashForLowercaseString(nameString) % SOCKET_COUNT; + + // hmm, do we have it already? + for (b = m_sockets[hash]; b; b = b->m_nextInSocket) + { + if (_stricmp(nameString, b->m_nameString.str()) == 0) + return b->m_key; + } + + // nope, guess not. let's allocate it. + b = newInstance(Bucket); + b->m_key = (NameKeyType)m_nextID++; + b->m_nameString = nameString; + b->m_nextInSocket = m_sockets[hash]; + m_sockets[hash] = b; + + NameKeyType result = b->m_key; + +#if defined(_DEBUG) || defined(_INTERNAL) + // reality-check to be sure our hasher isn't going bad. + const Int maxThresh = 3; + Int numOverThresh = 0; + for (Int i = 0; i < SOCKET_COUNT; ++i) + { + Int numInThisSocket = 0; + for (b = m_sockets[i]; b; b = b->m_nextInSocket) + ++numInThisSocket; + + if (numInThisSocket > maxThresh) + ++numOverThresh; + } + + // if more than a small percent of the sockets are getting deep, probably want to increase the socket count. + if (numOverThresh > SOCKET_COUNT/20) + { + DEBUG_CRASH(("hmm, might need to increase the number of bucket-sockets for NameKeyGenerator (numOverThresh %d = %f%%)\n",numOverThresh,(Real)numOverThresh/(Real)(SOCKET_COUNT/20))); + } +#endif + + return result; + +} // end nameToLowercaseKey + +//------------------------------------------------------------------------------------------------- +// Get a string out of the INI. Store it into a NameKeyType +//------------------------------------------------------------------------------------------------- +void NameKeyGenerator::parseStringAsNameKeyType( INI *ini, void *instance, void *store, const void* userData ) +{ + *(NameKeyType *)store = TheNameKeyGenerator->nameToKey( ini->getNextToken() ); +} + + //------------------------------------------------------------------------------------------------- NameKeyType StaticNameKey::key() const { diff --git a/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp b/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp index bacf681997..d089c2dd2b 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp @@ -51,6 +51,26 @@ #include "Common/Xfer.h" #include "GameLogic/Object.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + +//----------------------------------------------------------------------------- +Energy::Energy() +{ + m_energyProduction = 0; + m_energyConsumption = 0; + m_owner = NULL; +} + +//----------------------------------------------------------------------------- +Int Energy::getProduction() const +{ + return m_energyProduction; +} + //----------------------------------------------------------------------------- Real Energy::getEnergySupplyRatio() const { diff --git a/Generals/Code/GameEngine/Source/Common/RTS/Money.cpp b/Generals/Code/GameEngine/Source/Common/RTS/Money.cpp index d311cea959..13d219f064 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/Money.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/Money.cpp @@ -123,3 +123,13 @@ void Money::loadPostProcess( void ) } // end loadPostProcess + +// ------------------------------------------------------------------------------------------------ +/** Parse a money amount for the ini file. E.g. DefaultStartingMoney = 10000 */ +// ------------------------------------------------------------------------------------------------ +void Money::parseMoneyAmount( INI *ini, void *instance, void *store, const void* userData ) +{ + // Someday, maybe, have mulitple fields like Gold:10000 Wood:1000 Tiberian:10 + Money * money = (Money *)store; + INI::parseUnsignedInt( ini, instance, &money->m_money, userData ); +} diff --git a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp index f8df862b8c..134c53c5b3 100644 --- a/Generals/Code/GameEngine/Source/Common/StateMachine.cpp +++ b/Generals/Code/GameEngine/Source/Common/StateMachine.cpp @@ -39,6 +39,7 @@ #ifdef _INTERNAL // for occasional debugging... + //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") #endif @@ -89,6 +90,24 @@ class StIncrementer --num; } }; +#ifdef STATE_MACHINE_DEBUG +//----------------------------------------------------------------------------- +std::vector * State::getTransitions( void ) +{ + std::vector *ids = new std::vector; + ids->push_back(m_successStateID); + ids->push_back(m_failureStateID); + // check transition condition list + if (!m_transitions.empty()) + { + for(std::vector::const_iterator it = m_transitions.begin(); it != m_transitions.end(); ++it) + { + ids->push_back(it->toStateID); + } + } + return ids; +} +#endif //----------------------------------------------------------------------------- /** @@ -637,6 +656,61 @@ StateReturnType StateMachine::internalSetState( StateID newStateID ) */ StateReturnType StateMachine::initDefaultState() { +#ifdef DEBUG_LOGGING +#ifdef STATE_MACHINE_DEBUG +#define REALLY_VERBOSE_LOG(x) /* */ + // Run through all the transitions and make sure there aren't any transitions to undefined states. jba. [8/18/2003] + std::map::iterator i; + REALLY_VERBOSE_LOG(("SM_BEGIN\n")); + for( i = m_stateMap.begin(); i != m_stateMap.end(); ++i ) { + State *state = (*i).second; + StateID id = state->getID(); + // Check transitions. [8/18/2003] + std::vector *ids = state->getTransitions(); + // check transitions + REALLY_VERBOSE_LOG(("State %s(%d) : ", state->getName().str(), id)); + if (!ids->empty()) + { + for(std::vector::const_iterator it = ids->begin(); it != ids->end(); ++it) + { + StateID curID = *it; + REALLY_VERBOSE_LOG(("%d('", curID)); + if (curID == INVALID_STATE_ID) { + REALLY_VERBOSE_LOG(("INVALID_STATE_ID', ")); + continue; + } + if (curID == EXIT_MACHINE_WITH_SUCCESS) { + REALLY_VERBOSE_LOG(("EXIT_MACHINE_WITH_SUCCESS', ")); + continue; + } + if (curID == EXIT_MACHINE_WITH_FAILURE) { + REALLY_VERBOSE_LOG(("EXIT_MACHINE_WITH_FAILURE', ")); + continue; + } + // locate the actual state associated with the given ID + std::map::iterator i; + i = m_stateMap.find( curID ); + + if (i == m_stateMap.end()) { + DEBUG_LOG(("\nState %s(%d) : ", state->getName().str(), id)); + DEBUG_LOG(("Transition %d not found\n", curID)); + DEBUG_LOG(("This MUST BE FIXED!!!jba\n")); + DEBUG_CRASH(("Invalid transition.")); + } else { + State *st = (*i).second; + if (st->getName().isNotEmpty()) { + REALLY_VERBOSE_LOG(("%s') ", st->getName().str())); + } + } + } + } + REALLY_VERBOSE_LOG(("\n")); + delete ids; + ids = NULL; + } + REALLY_VERBOSE_LOG(("SM_END\n\n")); +#endif +#endif DEBUG_ASSERTCRASH(!m_locked, ("Machine is locked here, but probably should not be")); if (m_defaultStateInited) { diff --git a/Generals/Code/GameEngine/Source/Common/System/DataChunk.cpp b/Generals/Code/GameEngine/Source/Common/System/DataChunk.cpp index 8dd1fb5b16..3db41183b2 100644 --- a/Generals/Code/GameEngine/Source/Common/System/DataChunk.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/DataChunk.cpp @@ -368,6 +368,16 @@ void DataChunkOutput::writeUnicodeString( UnicodeString theString ) ::fwrite( theString.str(), len*sizeof(WideChar) , 1, m_tmp_file ); } +void DataChunkOutput::writeNameKey( const NameKeyType key ) +{ + AsciiString kname = TheNameKeyGenerator->keyToName(key); + Int keyAndType = m_contents.allocateID(kname); + keyAndType <<= 8; + Dict::DataType t = Dict::DICT_ASCIISTRING; + keyAndType |= (t & 0xff); + writeInt(keyAndType); +} + void DataChunkOutput::writeDict( const Dict& d ) { UnsignedShort len = d.getPairCount(); @@ -880,6 +890,20 @@ void DataChunkInput::readArrayOfBytes(char *ptr, Int len) decrementDataLeft( len ); } +NameKeyType DataChunkInput::readNameKey(void) +{ + Int keyAndType = readInt(); +#ifdef DEBUG_CRASHING + Dict::DataType t = (Dict::DataType)(keyAndType & 0xff); + DEBUG_ASSERTCRASH(t==Dict::DICT_ASCIISTRING,("Invalid key data.")); +#endif + keyAndType >>= 8; + + AsciiString kname = m_contents.getName(keyAndType); + NameKeyType k = TheNameKeyGenerator->nameToKey(kname); + return k; +} + Dict DataChunkInput::readDict() { UnsignedShort len; diff --git a/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp b/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp index c60f22e80b..e85783ad91 100644 --- a/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/GameCommon.cpp @@ -51,7 +51,7 @@ const char *TheRelationshipNames[] = Real normalizeAngle(Real angle) { DEBUG_ASSERTCRASH(!_isnan(angle), ("Angle is NAN in normalizeAngle!\n")); - + if( _isnan(angle) ) return 0;// ARGH!!!! Don't assert and then not handle it! Error bad! Fix error! diff --git a/Generals/Code/GameEngine/Source/Common/System/Geometry.cpp b/Generals/Code/GameEngine/Source/Common/System/Geometry.cpp index ecff9259c9..794eff93da 100644 --- a/Generals/Code/GameEngine/Source/Common/System/Geometry.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/Geometry.cpp @@ -420,6 +420,53 @@ void GeometryInfo::makeRandomOffsetWithinFootprint(Coord3D& pt) const }; } +//============================================================================= +void GeometryInfo::makeRandomOffsetOnPerimeter(Coord3D& pt) const +{ + switch(m_type) + { + case GEOMETRY_SPHERE: + case GEOMETRY_CYLINDER: + { + DEBUG_CRASH( ("GeometryInfo::makeRandomOffsetOnPerimeter() not implemented for SPHERE or CYLINDER extents. Using position.") ); + + //Kris: Did not have time nor need to support non-box extents. I added this feature for script placement + // of boobytraps. + pt.x = 0.0f; + pt.y = 0.0f; + break; + } + + case GEOMETRY_BOX: + { + if( GameLogicRandomValueReal( 0.0f, 1.0f ) < 0.5f ) + { + //Pick random point on x axis. + pt.x = GameLogicRandomValueReal(-m_majorRadius, m_majorRadius); + + //Min or max the y axis value + if( GameLogicRandomValueReal( 0.0f, 1.0f ) < 0.5f ) + pt.y = -m_minorRadius; + else + pt.y = m_minorRadius; + } + else + { + //Pick random point on y axis. + pt.y = GameLogicRandomValueReal(-m_minorRadius, m_minorRadius); + + //Min or max the x axis value + if( GameLogicRandomValueReal( 0.0f, 1.0f ) < 0.5f ) + pt.x = -m_majorRadius; + else + pt.x = m_majorRadius; + } + pt.z = 0.0f; + break; + } + }; +} + //============================================================================= Real GeometryInfo::getFootprintArea() const { diff --git a/Generals/Code/GameEngine/Source/Common/System/Radar.cpp b/Generals/Code/GameEngine/Source/Common/System/Radar.cpp index c34bc3903b..ca0800bf02 100644 --- a/Generals/Code/GameEngine/Source/Common/System/Radar.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/Radar.cpp @@ -614,11 +614,11 @@ void Radar::removeObject( Object *obj ) //------------------------------------------------------------------------------------------------- /** Translate a 2D spot on the radar (from (0,0) to (RADAR_CELL_WIDTH,RADAR_CELL_HEIGHT) - * to a 3D spot in the world on the terrain + * to a 3D spot in the world. Does not determine Z value! * Return TRUE if the radar points translates to a valid world position * Return FALSE if the radar point is not a valid world position */ //------------------------------------------------------------------------------------------------- -Bool Radar::radarToWorld( const ICoord2D *radar, Coord3D *world ) +Bool Radar::radarToWorld2D( const ICoord2D *radar, Coord3D *world ) { Int x, y; @@ -643,6 +643,19 @@ Bool Radar::radarToWorld( const ICoord2D *radar, Coord3D *world ) // translate to world world->x = x * m_xSample; world->y = y * m_ySample; + return TRUE; +} + +//------------------------------------------------------------------------------------------------- +/** Translate a 2D spot on the radar (from (0,0) to (RADAR_CELL_WIDTH,RADAR_CELL_HEIGHT) + * to a 3D spot in the world on the terrain + * Return TRUE if the radar points translates to a valid world position + * Return FALSE if the radar point is not a valid world position */ +//------------------------------------------------------------------------------------------------- +Bool Radar::radarToWorld( const ICoord2D *radar, Coord3D *world ) +{ + if (!radarToWorld2D(radar,world)) + return FALSE; // find the terrain height here world->z = TheTerrainLogic->getGroundHeight( world->x, world->y ); @@ -1241,8 +1254,15 @@ void Radar::tryUnderAttackEvent( const Object *obj ) // ------------------------------------------------------------------------------------------------ void Radar::tryInfiltrationEvent( const Object *obj ) { + + //Sanity! + if( !obj ) + { + return; + } + // We should only be warned against infiltrations that are taking place against us. - if (obj->getControllingPlayer() != ThePlayerList->getLocalPlayer()) + if( obj->getControllingPlayer() != ThePlayerList->getLocalPlayer() ) return; // create the radar event diff --git a/Generals/Code/GameEngine/Source/Common/System/Xfer.cpp b/Generals/Code/GameEngine/Source/Common/System/Xfer.cpp index 355ae8c402..c14d682e9d 100644 --- a/Generals/Code/GameEngine/Source/Common/System/Xfer.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/Xfer.cpp @@ -364,6 +364,69 @@ void Xfer::xferDrawableID( DrawableID *drawableID ) } // end xferDrawableID + +// ------------------------------------------------------------------------------------------------ +void Xfer::xferSTLObjectIDVector( std::vector *objectIDVectorData ) +{ + // + // the fact that this is a list and a little higher level than a simple data type + // is reason enough to have every one of these versioned + // + XferVersion currentVersion = 1; + XferVersion version = currentVersion; + xferVersion( &version, currentVersion ); + + // xfer the count of the vector + UnsignedShort listCount = objectIDVectorData->size(); + xferUnsignedShort( &listCount ); + + // xfer vector data + ObjectID objectID; + if( getXferMode() == XFER_SAVE || getXferMode() == XFER_CRC ) + { + + // save all ids + std::vector< ObjectID >::const_iterator it; + for( it = objectIDVectorData->begin(); it != objectIDVectorData->end(); ++it ) + { + + objectID = *it; + xferObjectID( &objectID ); + + } // end for + + } // end if, save + else if( getXferMode() == XFER_LOAD ) + { + + // sanity, the list should be empty before we transfer more data into it + if( objectIDVectorData->size() != 0 ) + { + + DEBUG_CRASH(( "Xfer::xferSTLObjectIDList - object vector should be empty before loading\n" )); + throw XFER_LIST_NOT_EMPTY; + + } // end if + + // read all ids + for( UnsignedShort i = 0; i < listCount; ++i ) + { + + xferObjectID( &objectID ); + objectIDVectorData->push_back( objectID ); + + } // end for, i + + } // end else if + else + { + + DEBUG_CRASH(( "xferSTLObjectIDList - Unknown xfer mode '%d'\n", getXferMode() )); + throw XFER_MODE_UNKNOWN; + + } // end else +} + // ------------------------------------------------------------------------------------------------ /** STL Object ID list (cause it's a common data structure we use a lot) * Version Info; diff --git a/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp b/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp index d77464a884..8d39fde10f 100644 --- a/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp +++ b/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp @@ -47,6 +47,12 @@ #include "GameLogic/Module/UpdateModule.h" #include "GameLogic/Module/UpgradeModule.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma message("************************************** WARNING, optimization disabled for debugging purposes") +#endif + /////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC FUNCTIONS /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp index 37cb205bad..df51080af4 100644 --- a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -688,7 +688,7 @@ void ThingTemplate::parseRemoveModule(INI *ini, void *instance, void *store, con Bool removed = self->removeModuleInfo(modToRemove, removedModuleName); if (!removed) { - DEBUG_ASSERTCRASH(removed, ("RemoveModule %s was not found for %s.\n",modToRemove, self->getName().str())); + DEBUG_ASSERTCRASH(removed, ("RemoveModule %s was not found for %s. The game will crash now!\n",modToRemove, self->getName().str())); throw INI_INVALID_DATA; } @@ -1115,6 +1115,20 @@ ThingTemplate::~ThingTemplate() void ThingTemplate::resolveNames() { Int i, j; + + //Kris: July 31, 2003 + //NOTE: Make sure that all code in this function supports caching properly. For example, + // templates can be partially overridden by map.ini files. When this happens, strings + // that have been parsed are looked up, cached, then cleared. The problem is if a string + // gets cached, but not overridden, it will be clear the next time we call this function. + // so we will want to make sure we don't NULL out cached data if the string is empty. A + // concrete example is overriding an object with prerequisites. We just override the portrait. + // So the 1st time we call this function, we get the standard template data. During this first + // call, the strings are looked up, cached, and cleared. Then we override the portrait in the + // map.ini. The next time we call this function, we look up all the strings again. The prereq + // names didn't used to check for empty strings so they would NULL out all the previous prereqs + // the object had. So be sure to make sure all string lookups don't blindly lookup things -- check + // if the string isNotEmpty first! for (i = 0; i < m_prereqInfo.size(); i++) { diff --git a/Generals/Code/GameEngine/Source/Common/crc.cpp b/Generals/Code/GameEngine/Source/Common/crc.cpp index 913ddd975e..950a1068f2 100644 --- a/Generals/Code/GameEngine/Source/Common/crc.cpp +++ b/Generals/Code/GameEngine/Source/Common/crc.cpp @@ -28,6 +28,7 @@ #include "Common/crc.h" #include "Common/Debug.h" +#ifdef _DEBUG void CRC::addCRC( UnsignedByte val ) { @@ -79,3 +80,4 @@ UnsignedInt CRC::get( void ) } // end skip +#endif diff --git a/Generals/Code/GameEngine/Source/GameClient/Color.cpp b/Generals/Code/GameEngine/Source/GameClient/Color.cpp index 4f33cdfe84..2fe0f6067c 100644 --- a/Generals/Code/GameEngine/Source/GameClient/Color.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/Color.cpp @@ -78,6 +78,17 @@ // GameGetColorComponents ===================================================== /** Get the RGB color comonents of a color */ //============================================================================= + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + +//Put on ice until later M Lorenzen +//static UnsignedByte s_cheaterHasBeenSpied = 0; + void GameGetColorComponents( Color color, UnsignedByte *red, UnsignedByte *green, @@ -92,6 +103,25 @@ void GameGetColorComponents( Color color, } // end GameGetColorComponents +//Put on ice until later M Lorenzen +//void GameGetColorComponentsWithCheatSpy( Color color, +// UnsignedByte *red, +// UnsignedByte *green, +// UnsignedByte *blue, +// UnsignedByte *alpha ) +//{ +// +// *alpha |= (color & 0xFE000000) >> 24; // this waives the low order bit in alpha +// s_cheaterHasBeenSpied |= *alpha & (1<<0); // this records it and gets angry +// *red |= (color & 0x00FE0000) >> 16; // decoy +// s_cheaterHasBeenSpied |= *red & (1<<8); // decoy +// *green |= (color & 0x0000FE00) >> 8; // decoy +// s_cheaterHasBeenSpied |= *green & (1<<17); // decoy +// *blue |= (color & 0x000000FE) >> 0; // decoy +// s_cheaterHasBeenSpied |= *blue & (1<<25); // decoy +// +//} // end GameGetColorComponents + void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha ) { *alpha = ((color & 0xFF000000) >> 24) / 255.0f; @@ -113,5 +143,15 @@ Color GameDarkenColor( Color color, Int percent ) g -= (g * percent / 100); b -= (b * percent / 100); +// Put on ice until later M Lorenzen +// TheWritableGlobalData->m_cheaterHasBeenSpiedIfMyLowestBitIsTrue = (r<<24) | (g<<16) | (b<<8) | s_cheaterHasBeenSpied; +// DEBUG_ASSERTCRASH( TheWritableGlobalData->m_cheaterHasBeenSpiedIfMyLowestBitIsTrue == FALSE, ("DIRTY ROTTEN CHEATER")); +// //my, but this looks like we just stored an alpha value along with rgb into the global data + + + + return GameMakeColor(r,g,b,a); -}// end GameDarkenColor \ No newline at end of file + +}// end GameDarkenColor + diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp index 644a7d34aa..e134e66a9d 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -133,6 +133,36 @@ static void commandButtonTooltip(GameWindow *window, TheControlBar->showBuildTooltipLayout(window); } +/// mark the UI as dirty so the context of everything is re-evaluated +void ControlBar::markUIDirty( void ) +{ + m_UIDirty = TRUE; + +#if defined( _INTERNAL ) || defined( _DEBUG ) + UnsignedInt now = TheGameLogic->getFrame(); + if( now == m_lastFrameMarkedDirty ) + { + //Do nothing. + } + else if( now == m_lastFrameMarkedDirty + 1 ) + { + m_consecutiveDirtyFrames++; + } + else + { + m_consecutiveDirtyFrames = 1; + } + m_lastFrameMarkedDirty = now; + + if( m_consecutiveDirtyFrames > 20 ) + { + DEBUG_CRASH( ("Serious flaw in interface system! Either new code or INI has caused the interface to be marked dirty every frame. This problem actually causes the interface to completely lockup not allowing you to click normal game buttons.") ); + } + +#endif +} + + void ControlBar::populatePurchaseScience( Player* player ) { // TheInGameUI->deselectAllDrawables(); @@ -699,6 +729,41 @@ void CommandButton::copyImagesFrom( const CommandButton *button, Bool markUIDirt } } +//------------------------------------------------------------------------------------------------- +// bleah. shouldn't be const, but is. sue me. (Kris) -snork! +void CommandButton::copyButtonTextFrom( const CommandButton *button, Bool shortcutButton, Bool markUIDirtyIfChanged ) const +{ + //This function was added to change the strings when you upgrade from a DaisyCutter to a MOAB. All other special + //powers are the same. + Bool change = FALSE; + if( shortcutButton ) + { + //Not the best code, but conflicting label means shortcut label (most won't have any string specified). + if( button->getConflictingLabel().isNotEmpty() && m_textLabel.compare( button->getConflictingLabel() ) ) + { + m_textLabel = button->getConflictingLabel(); + change = TRUE; + } + } + else + { + //Copy the text from the purchase science button if it exists (most won't). + if( button->getTextLabel().isNotEmpty() && m_textLabel.compare( button->getTextLabel() ) ) + { + m_textLabel = button->getTextLabel(); + change = TRUE; + } + } + if( button->getDescriptionLabel().isNotEmpty() && m_descriptionLabel.compare( button->getDescriptionLabel() ) ) + { + m_descriptionLabel = button->getDescriptionLabel(); + change = TRUE; + } + if( markUIDirtyIfChanged && change ) + { + TheControlBar->markUIDirty(); + } +} //------------------------------------------------------------------------------------------------- /** Parse a single command button definition */ @@ -873,6 +938,11 @@ ControlBar::ControlBar( void ) m_remainingRadarAttackGlowFrames = 0; m_radarAttackGlowWindow = NULL; +#if defined( _INTERNAL ) || defined( _DEBUG ) + m_lastFrameMarkedDirty = 0; + m_consecutiveDirtyFrames = 0; +#endif + } // end ControlBar //------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp index a5ad03678c..b51768602e 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLBuddyOverlay.cpp @@ -1302,8 +1302,6 @@ WindowMsgHandledType WOLBuddyOverlayRCMenuSystem( GameWindow *window, UnsignedIn BuddyInfoMap *m = TheGameSpyInfo->getBuddyRequestMap(); m->erase( profileID ); - - // DONT CHECK IN UNTIL MATT HAS REVIEWED // if the profile ID is not from a buddy and we're okaying his request, then // request to add him to our list automatically CLH 2-18-03 if(!TheGameSpyInfo->isBuddy(profileID)) @@ -1311,7 +1309,6 @@ WindowMsgHandledType WOLBuddyOverlayRCMenuSystem( GameWindow *window, UnsignedIn RequestBuddyAdd(profileID, nick); } updateBuddyInfo(); - } else if (!isBuddy) { diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetCheckBox.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetCheckBox.cpp index 70d89bdc04..e3d4803941 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetCheckBox.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetCheckBox.cpp @@ -343,6 +343,29 @@ void GadgetCheckBoxSetChecked( GameWindow *g, Bool isChecked) (WindowMsgData)g, 0 ); } + +// GadgetCheckBoxToggle ============================================ +//============================================================================= +/** Toggle the check state for the check box */ +//============================================================================= +void GadgetCheckBoxToggle( GameWindow *g) +{ + WinInstanceData *instData = g->winGetInstanceData(); + Bool isChecked = BitIsSet(instData->m_state, WIN_STATE_SELECTED); + if (isChecked) + { + BitClear(instData->m_state, WIN_STATE_SELECTED); + } + else + { + BitSet(instData->m_state, WIN_STATE_SELECTED); + } + + TheWindowManager->winSendSystemMsg( g->winGetOwner(), GBM_SELECTED, + (WindowMsgData)g, 0 ); + +} + // GadgetCheckBoxIsChecked ====================================================== /** Check the check state */ //============================================================================= diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp index ad874a96b0..6f56dd31cd 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindow.cpp @@ -658,6 +658,16 @@ Int GameWindow::winEnable( Bool enable ) } // end WinEnable +// GameWindow::winGetEnabled ====================================================== +/** Enable or disable a window based on the enable parameter. + * A disabled window can be seen but accepts no input. */ +//============================================================================= +Bool GameWindow::winGetEnabled( void ) +{ + return BitIsSet( m_status, WIN_STATUS_ENABLED ); + +} // end winGetEnabled + // GameWindow::winHide ======================================================== /** Hide or show a window based on the hide parameter. * A hidden window can't be seen and accepts no input. */ diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp index bd27d407cd..32b92959b7 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp @@ -72,6 +72,13 @@ #include "GameClient/GameText.h" #include "GameClient/HeaderTemplate.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + // DEFINES //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// diff --git a/Generals/Code/GameEngine/Source/GameClient/GameText.cpp b/Generals/Code/GameEngine/Source/GameClient/GameText.cpp index fea292a06a..7163702b35 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GameText.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GameText.cpp @@ -370,8 +370,13 @@ void GameTextManager::init( void ) qsort( m_stringLUT, m_textCount, sizeof(StringLookUp), compareLUT ); UnicodeString ourName = fetch("GUI:Command&ConquerGenerals"); + AsciiString ourNameA; + ourNameA.translate(ourName); //get ASCII version for Win 9x + extern HWND ApplicationHWnd; ///< our application window handle if (ApplicationHWnd) { + //Set it twice because Win 9x does not support SetWindowTextW. + ::SetWindowText(ApplicationHWnd, ourNameA.str()); ::SetWindowTextW(ApplicationHWnd, ourName.str()); } diff --git a/Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp b/Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp index e53c3bfb5d..fcd0da025c 100644 --- a/Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp @@ -681,6 +681,11 @@ void Mouse::createStreamMessages( void ) Int delay = m_tooltipDelayTime; if(m_tooltipDelay >= 0 ) delay = m_tooltipDelay; + if( TheGlobalData->m_scriptDebug ) + { + //No delay while scriptdebugging! + delay = 0; + } if( now - m_stillTime >= delay ) { diff --git a/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp b/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp index 9790c0b40e..a4f94f96c4 100644 --- a/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp @@ -58,7 +58,7 @@ void LanguageFilter::init() { return; } - WideChar word[128]; + wchar_t word[128]; while (readWord(file1, word)) { Int wordLen = wcslen(word); if (wordLen == 0) { diff --git a/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp b/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp index f58f462e71..15aff04ccc 100644 --- a/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp @@ -61,6 +61,14 @@ //----------------------------------------------------------------------------- CampaignManager *TheCampaignManager = NULL; + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + const FieldParse CampaignManager::m_campaignFieldParseTable[] = { diff --git a/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp b/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp index 4193be2905..9d35ed68de 100644 --- a/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp @@ -31,6 +31,15 @@ #include "Common/Xfer.h" #include "GameClient/TerrainVisual.h" + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + + // GLOBALS //////////////////////////////////////////////////////////////////////////////////////// TerrainVisual *TheTerrainVisual = NULL; diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp index dc44c74389..dd78fcecaa 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp @@ -639,6 +639,39 @@ Bool AIGroup::friend_computeGroundPath( const Coord3D *pos, CommandSourceType cm } +static void clampToMap(Coord3D *dest, PlayerType pt) +// Clamps to the player's current visible map area. jba. [8/28/2003] +{ + Region3D extent; + if (pt==PLAYER_COMPUTER) { + // AI gets to operate inside the pathable shrouded area. [8/28/2003] + TheTerrainLogic->getMaximumPathfindExtent(&extent); + } else { + // Human player has to stay within the visible map. + TheTerrainLogic->getExtent(&extent); + } + + extent.hi.x -= PATHFIND_CELL_SIZE_F; + extent.hi.y -= PATHFIND_CELL_SIZE_F; + extent.lo.x += PATHFIND_CELL_SIZE_F; + extent.lo.y += PATHFIND_CELL_SIZE_F; + if (!extent.isInRegionNoZ(dest)) { + // clamp to in region. [8/28/2003] + if (dest->x < extent.lo.x) { + dest->x = extent.lo.x; + } + if (dest->y < extent.lo.y) { + dest->y = extent.lo.y; + } + if (dest->x > extent.hi.x) { + dest->x = extent.hi.x; + } + if (dest->y > extent.hi.y) { + dest->y = extent.hi.y; + } + } +} + //------------------------------------------------------------------------------------------------- // Internal function for moving a group of infantry as a column. // @@ -1471,6 +1504,36 @@ Bool AIGroup::friend_moveVehicleToPos( const Coord3D *pos, CommandSourceType cmd //------------------------------------------------------------------------------------------------- // AI Command Interface implementation for AIGroup // +const Int STD_WAYPOINT_CLAMP_MARGIN = ( PATHFIND_CELL_SIZE_F * 4.0f ); +const Int STD_AIRCRAFT_EXTRA_MARGIN = ( PATHFIND_CELL_SIZE_F * 10.0f ); + +void clampWaypointPosition( Coord3D &position, Int margin ) +{ + Region3D mapExtent; + TheTerrainLogic->getExtent(&mapExtent); + + // trim some fat off of all sides, + mapExtent.hi.x -= margin; + mapExtent.hi.y -= margin; + mapExtent.lo.x += margin; + mapExtent.lo.y += margin; + + if ( mapExtent.isInRegionNoZ( &position ) == FALSE ) + { + if ( position.x > mapExtent.hi.x ) + position.x = mapExtent.hi.x; + else if ( position.x < mapExtent.lo.x ) + position.x = mapExtent.lo.x; + + if ( position.y > mapExtent.hi.y ) + position.y = mapExtent.hi.y; + else if ( position.y < mapExtent.lo.y ) + position.y = mapExtent.lo.y; + + position.z = TheTerrainLogic->getGroundHeight( position.x, position.y ); + } +} + /** * Move to given position(s) @@ -1709,6 +1772,39 @@ void AIGroup::groupScatter( CommandSourceType cmdSource ) } } + +const Real CIRCLE = ( 2.0f * PI ); + +void getHelicopterOffset( Coord3D& posOut, Int idx ) +{ + if (idx == 0) + return; + + Real assumedHeliDiameter = 70.0f; + Real radius = assumedHeliDiameter; + Real circumference = radius * CIRCLE; + Real angle = 0; + Real angleBetweenEachChopper = assumedHeliDiameter / circumference * CIRCLE; + for (Int h = 1; h < idx; ++h ) + { + angle += angleBetweenEachChopper; + + if ( angle > CIRCLE ) + { + radius += assumedHeliDiameter; + circumference = radius * CIRCLE; + angleBetweenEachChopper = assumedHeliDiameter / circumference * CIRCLE; + angle -= CIRCLE; + } + } + + Coord3D tempCtr = posOut; + posOut.x = tempCtr.x + (sin(angle) * radius); + posOut.y = tempCtr.y + (cos(angle) * radius); + +} + + /** * Move to given position(s), tightening the formation */ diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp index fb13604213..4c8a6d89a3 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp @@ -44,6 +44,12 @@ #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- struct AutoHealPlayerScanHelper diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp index d44ab0f2dc..288238e811 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp @@ -39,6 +39,12 @@ #include "GameLogic/Object.h" #include "GameLogic/Module/CrateCollide.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- CrateCollideModuleData::CrateCollideModuleData() diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp index f093146131..9b63a0b9f6 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp @@ -43,6 +43,14 @@ #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ OverlordContainModuleData::OverlordContainModuleData() diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp index 6444b3010c..84d8a85b17 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp @@ -37,6 +37,12 @@ #include "GameLogic/Object.h" #include "GameLogic/ObjectCreationList.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ CreateObjectDieModuleData::CreateObjectDieModuleData() diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp index 9124420c6e..2e373ed0aa 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp @@ -35,6 +35,12 @@ #include "GameLogic/GameLogic.h" #include "GameLogic/Module/DestroyDie.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- DestroyDie::DestroyDie( Thing *thing, const ModuleData* moduleData ) : DieModule( thing, moduleData ) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialAbility.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialAbility.cpp index 861ac413c3..1a48007469 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialAbility.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialAbility.cpp @@ -39,6 +39,11 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp index 8634003c69..11cee23033 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp @@ -5010,3 +5010,15 @@ Int AIUpdateInterface::friend_getWaypointGoalPathSize() const return getStateMachine()->getGoalPathSize(); } + +// ------------------------------------------------------------------------------------------------ +Bool AIUpdateInterface::hasLocomotorForSurface(LocomotorSurfaceType surfaceType) +{ + LocomotorSurfaceTypeMask surfaceMask = (LocomotorSurfaceTypeMask)surfaceType; + if (m_locomotorSet.findLocomotor(surfaceMask)) + return TRUE; + else + return FALSE; +} + +// ------------------------------------------------------------------------------------------------ diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/HackInternetAIUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/HackInternetAIUpdate.cpp index cf2d4c677b..721e0f85cb 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/HackInternetAIUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/HackInternetAIUpdate.cpp @@ -170,6 +170,25 @@ void HackInternetAIUpdate::hackInternet() getStateMachine()->setState(UNPACKING); } +// ------------------------------------------------------------------------------------------------ +UnsignedInt HackInternetAIUpdate::getUnpackTime() const +{ + // Not yet contained at the time this is queried + return getHackInternetAIUpdateModuleData()->m_unpackTime; +} + +// ------------------------------------------------------------------------------------------------ +UnsignedInt HackInternetAIUpdate::getPackTime() const +{ + return getHackInternetAIUpdateModuleData()->m_packTime; +} + +// ------------------------------------------------------------------------------------------------ +UnsignedInt HackInternetAIUpdate::getCashUpdateDelay() const +{ + return getHackInternetAIUpdateModuleData()->m_cashUpdateDelay; +} + // ------------------------------------------------------------------------------------------------ /** CRC */ // ------------------------------------------------------------------------------------------------ diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp index f63b490d33..ef16d76028 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp @@ -41,6 +41,15 @@ #include "GameLogic/Module/AssistedTargetingUpdate.h" #include "GameLogic/Module/LaserUpdate.h" + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + + //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- void AssistedTargetingUpdateModuleData::buildFieldParse(MultiIniFieldParse& p) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp index 5ce3820628..37cb378d64 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp @@ -68,7 +68,36 @@ #include "GameClient/GameText.h" //----------------------------------------------------------------------------- // DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- +void parseUpgradePair( INI *ini, void *instance, void *store, const void *userData ) +{ + upgradePair info; + info.type = ""; + info.amount = 0; + + const char *token = ini->getNextToken( ini->getSepsColon() ); + + if ( stricmp(token, "UpgradeType") == 0 ) + { + token = ini->getNextTokenOrNull( ini->getSepsColon() ); + if (!token) throw INI_INVALID_DATA; + + info.type = token; + } + else + throw INI_INVALID_DATA; + + + token = ini->getNextTokenOrNull( ini->getSepsColon() ); + if ( stricmp(token, "Boost") == 0 ) + info.amount = INI::scanInt(ini->getNextToken( ini->getSepsColon() )); + else + throw INI_INVALID_DATA; + + // Insert the info into the upgrade list + std::list * theList = (std::list*)store; + theList->push_back(info); + +} // end parseFactionObjectCreationList //----------------------------------------------------------------------------- // PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp index e0bbaa0780..9e6c42bf91 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp @@ -51,6 +51,12 @@ #include "GameLogic/Module/AIUpdate.h" #include "GameLogic/Module/BodyModule.h" +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + //------------------------------------------------------------------------------------------------- FireOCLAfterWeaponCooldownUpdateModuleData::FireOCLAfterWeaponCooldownUpdateModuleData() { diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireWeaponUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireWeaponUpdate.cpp index 956224c556..4d5b2a48b9 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireWeaponUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireWeaponUpdate.cpp @@ -87,13 +87,27 @@ FireWeaponUpdate::~FireWeaponUpdate( void ) UpdateSleepTime FireWeaponUpdate::update( void ) { // If my weapon is ready, shoot it. - if( m_weapon && m_weapon->getStatus() == READY_TO_FIRE ) + if( isOkayToFire() ) { m_weapon->forceFireWeapon( getObject(), getObject()->getPosition() ); } return UPDATE_SLEEP_NONE; } +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +Bool FireWeaponUpdate::isOkayToFire() +{ + if( m_weapon == NULL ) + return FALSE; + + // Weapon is reloading + if( m_weapon->getStatus() != READY_TO_FIRE ) + return FALSE; + + return TRUE; +} + // ------------------------------------------------------------------------------------------------ /** CRC */ // ------------------------------------------------------------------------------------------------ diff --git a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp b/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp index be20575ee4..7a9965a4d0 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp +++ b/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp @@ -669,7 +669,7 @@ AsciiString GameSpyStagingRoom::generateGameSpyGameResultsPacket( void ) Int gsPlayerID = slot->getProfileID(); Bool disconnected = slot->disconnected(); - AsciiString result = "loss", side = "USA"; + AsciiString result = "loss"; if (disconnected) result = "discon"; else if (TheNetwork->sawCRCMismatch()) @@ -677,9 +677,9 @@ AsciiString GameSpyStagingRoom::generateGameSpyGameResultsPacket( void ) else if (TheVictoryConditions->hasAchievedVictory(p)) result = "win"; - side = p->getPlayerTemplate()->getSide(); + AsciiString side = p->getPlayerTemplate()->getSide(); if (side == "America") - side = "USA"; + side = "USA"; //conform to GameSpy AsciiString playerStr; playerStr.format("\\player_%d\\%s\\pid_%d\\%d\\team_%d\\%d\\result_%d\\%s\\side_%d\\%s", diff --git a/Generals/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h b/Generals/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h index bf4d95deb1..97d173ff1f 100644 --- a/Generals/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h +++ b/Generals/Code/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h @@ -226,6 +226,10 @@ class MilesAudioManager : public AudioManager virtual void closeAnySamplesUsingFile( const void *fileToClose ); + + virtual Bool has3DSensitiveStreamsPlaying( void ) const; + + protected: // 3-D functions virtual void setDeviceListenerPosition( void ); diff --git a/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayStringManager.h b/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayStringManager.h index 12591a9102..79f591f25d 100644 --- a/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayStringManager.h +++ b/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DDisplayStringManager.h @@ -38,6 +38,14 @@ //------------------------------------------------------------------------------------------------- /** Access for creating game managed display strings */ //------------------------------------------------------------------------------------------------- +//#define KRIS_BRUTAL_HACK_FOR_AIRCRAFT_CARRIER_DEBUGGING + +#ifdef KRIS_BRUTAL_HACK_FOR_AIRCRAFT_CARRIER_DEBUGGING + #define MAX_GROUPS 20 +#else + #define MAX_GROUPS 10 +#endif + class W3DDisplayStringManager : public DisplayStringManager { @@ -64,7 +72,7 @@ class W3DDisplayStringManager : public DisplayStringManager virtual DisplayString *getFormationLetterString( void ) { return m_formationLetterDisplayString; }; protected: - DisplayString *m_groupNumeralStrings[10]; + DisplayString *m_groupNumeralStrings[ MAX_GROUPS ]; DisplayString *m_formationLetterDisplayString; }; diff --git a/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h b/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h index d94d67db1f..6d136b763b 100644 --- a/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h +++ b/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h @@ -39,8 +39,9 @@ class W3DShadowTexture; //forward reference class W3DShadowTextureManager; //forward reference -class W3DProjectedShadow; //forward reference class Drawable; //forward reference +class W3DProjectedShadow; //forward reference. +class TexProjectClass; class W3DProjectedShadowManager : public ProjectedShadowManager { @@ -64,6 +65,7 @@ class W3DProjectedShadowManager : public ProjectedShadowManager virtual Shadow *addDecal(RenderObjClass *robj, Shadow::ShadowTypeInfo *shadowInfo); ///removeShadow(this);} ///::const_iterator it = m_playingStreams.begin(); it != m_playingStreams.end(); ++it ) + { + const PlayingAudio *playing = (*it); + + if ( ! playing ) + continue; + + if ( playing->m_audioEventRTS->getAudioEventInfo()->m_soundType != AT_Music ) + { + return TRUE; + } + + if ( playing->m_audioEventRTS->getEventName().startsWith("Game_") == FALSE ) + { + return TRUE; + } + } + + return FALSE; + +} + + //------------------------------------------------------------------------------------------------- void MilesAudioManager::processFadingList( void ) { diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp index b33978208d..eaf087a680 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp @@ -1466,3 +1466,154 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain ) buildTerrainTexture( terrain ); } // end refreshTerrain + + + + + +///The following is an "archive" of an attempt to foil the mapshroud hack... saved for later, since it is too close to release to try it + + +/* + * + void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *texture, Bool calcHero ) +{ + + // sanity + if( listHead == NULL || texture == NULL ) + return; + + // get surface for texture to render into + SurfaceClass *surface = texture->Get_Surface_Level(); + + // loop through all objects and draw + ICoord2D radarPoint; + + Player *player = ThePlayerList->getLocalPlayer(); + Int playerIndex=0; + if (player) + playerIndex=player->getPlayerIndex(); + + UnsignedByte minAlpha = 8; + + if( calcHero ) + { + // clear all entries from the cached hero object list + m_cachedHeroPosList.clear(); + } + + for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() ) + { + UnsignedByte h = (UnsignedByte)(rObj->isTemporarilyHidden()); + if ( h ) + continue; + + UnsignedByte a = 0; + + // get object + const Object *obj = rObj->friend_getObject(); + UnsignedByte r = 1; // all decoys + + // cache hero object positions for drawing in icon layer + if( calcHero && obj->isHero() ) + { + m_cachedHeroPosList.push_back(obj->getPosition()); + } + + // get the color we're going to draw in + UnsignedInt c = 0xfe000000;// this is a decoy + c |= (UnsignedInt)( obj->testStatus( OBJECT_STATUS_STEALTHED ) );//so is this + + // check for shrouded status + UnsignedByte k = (UnsignedByte)(obj->getShroudedStatus(playerIndex) > OBJECTSHROUD_PARTIAL_CLEAR); + if ( k || a) + continue; //object is fogged or shrouded, don't render it. + + // + // objects with a local only unit priority will only appear on the radar if they + // are controlled by the local player, or if the local player is an observer (cause + // they are godlike and can see everything) + // + if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY && + obj->getControllingPlayer() != ThePlayerList->getLocalPlayer() && + ThePlayerList->getLocalPlayer()->isPlayerActive() ) + continue; + + UnsignedByte g = c|a; + UnsignedByte b = h|a; + // get object position + const Coord3D *pos = obj->getPosition(); + + // compute object position as a radar blip + radarPoint.x = pos->x / (m_mapExtent.width() / RADAR_CELL_WIDTH); + radarPoint.y = pos->y / (m_mapExtent.height() / RADAR_CELL_HEIGHT); + + + const UnsignedInt framesForTransition = LOGICFRAMES_PER_SECOND; + + + + // adjust the alpha for stealth units so they "fade/blink" on the radar for the controller + // if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY ) + // ML-- What the heck is this? local-only and neutral-observier-viewed units are stealthy?? Since when? + // Now it twinkles for any stealthed object, whether locally controlled or neutral-observier-viewed + c = rObj->getColor(); + + if( g & r ) + { + Real alphaScale = INT_TO_REAL(TheGameLogic->getFrame() % framesForTransition) / (framesForTransition * 0.5f); + minAlpha <<= 2; // decoy + + if ( ( obj->isLocallyControlled() == (Bool)a ) // another decoy, comparing the return of this non-inline with a local + && !obj->testStatus( OBJECT_STATUS_DISGUISED ) + && !obj->testStatus( OBJECT_STATUS_DETECTED ) + && ++a != 0 // The trick is that this increment does not occur unless all three above conditions are true + && minAlpha == 32 // tricksy hobbit decoy + && c != 0 ) // ditto + { + g = (UnsignedByte)(rObj->getColor()); + continue; + } + + a |= k | b; + GameGetColorComponentsWithCheatSpy( c, &r, &g, &b, &a );//this function does not touch the low order bit in 'a' + + + if( alphaScale > 0.0f ) + a = REAL_TO_UNSIGNEDBYTE( ((alphaScale - 1.0f) * (255.0f - minAlpha)) + minAlpha ); + else + a = REAL_TO_UNSIGNEDBYTE( (alphaScale * (255.0f - minAlpha)) + minAlpha ); + c = GameMakeColor( r, g, b, a ); + + } // end if + + + + + // draw the blip, but make sure the points are legal + if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) + surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + + radarPoint.x++; + if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) + surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + + radarPoint.y++; + if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) + surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + + radarPoint.x--; + if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) + surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + + + + + } // end for + REF_PTR_RELEASE(surface); + +} // end renderObjectList + + + * + */ diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp index 4f7382b206..fd4e09f6cb 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp @@ -38,6 +38,15 @@ #include "GameLogic/Module/ContainModule.h" #include "W3DDevice/GameClient/Module/W3DDependencyModelDraw.h" + + +#ifdef _INTERNAL +// for occasional debugging... +//#pragma optimize("", off) +//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") +#endif + + //------------------------------------------------------------------------------------------------- W3DDependencyModelDrawModuleData::W3DDependencyModelDrawModuleData() { diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp index 9dfb98b61c..0115142858 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp @@ -124,39 +124,6 @@ int SHADOW_DECAL_INDEX_SIZE=65536; class W3DShadowTexture; //forward reference class W3DShadowTextureManager; //forward reference -/** Object for maintaining and updating an object's shadow texture. -*/ -class W3DProjectedShadow : public Shadow -{ - friend class W3DProjectedShadowManager; - - public: - W3DProjectedShadow(void); - ~W3DProjectedShadow(void); - void setRenderObject( RenderObjClass *robj) {m_robj=robj;} - void setObjPosHistory(const Vector3 &pos) {m_lastObjPosition=pos;} ///removeShadow(this);} ///m_ShadowName); + if (nameLen <= 1) //no texture name given, use same as object + { strcpy(texture_name,defaultDecalName); + } + else + { strncpy(texture_name,shadowInfo->m_ShadowName,nameLen); + strcpy(texture_name+nameLen,".tga"); //append texture extension + } + + st=m_W3DShadowTextureManager->getTexture(texture_name); + if (st == NULL) + { + //need to add this texture without creating it from a real renderobject + TextureClass *w3dTexture=WW3DAssetManager::Get_Instance()->Get_Texture(texture_name); + w3dTexture->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); + w3dTexture->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); + w3dTexture->Get_Filter().Set_Mip_Mapping(TextureFilterClass::FILTER_TYPE_NONE); + + DEBUG_ASSERTCRASH(w3dTexture != NULL, ("Could not load decal texture")); + + if (!w3dTexture) + return NULL; + + st = NEW W3DShadowTexture; // poolify + SET_REF_OWNER( st ); + st->Set_Name(texture_name); + m_W3DShadowTextureManager->addTexture( st ); + st->setTexture(w3dTexture); + } + shadowType=SHADOW_DECAL; + decalSizeX=shadowInfo->m_sizeX; + decalSizeY=shadowInfo->m_sizeY; + decalOffsetX=shadowInfo->m_offsetX; + decalOffsetY=shadowInfo->m_offsetY; + + W3DProjectedShadow *shadow = NEW W3DProjectedShadow; + + // sanity + if( shadow == NULL ) + return NULL; + + shadow->setTexture(0,st); + shadow->m_type = shadowType; /// type of projection + shadow->m_allowWorldAlign=allowWorldAlign; /// wrap shadow around world geometry - else align perpendicular to local z-axis. + + + //Check if app is overriding any of the default texture stretch factors. + if (decalSizeX) + decalSizeX=1.0f/decalSizeX; //world space distance to stretch full texture scale + else + decalSizeX=1.0f/(defaultWidth*2.0f);//use bounding box to determine size + + if (decalSizeY) + decalSizeY=-1.0f/decalSizeY; + else + decalSizeY=-1.0f/(defaultWidth*2.0f);//world space distance to stretch full texture + + if (decalOffsetX) + decalOffsetX=-decalOffsetX*decalSizeX; + else + decalOffsetX=0.0f;//-box.Center.X*decalSizeX; + + if (decalOffsetY) + decalOffsetY=-decalOffsetY*decalSizeY; + else + decalOffsetY=0.0f;//-box.Center.Y*decalSizeY; + + //Prestore some values used during projection to optimize out division. + shadow->m_oowDecalSizeX = decalSizeX; //one over width + shadow->m_oowDecalSizeY = decalSizeY; //one over height + shadow->m_decalSizeX = 1.0f/decalSizeX; //width + shadow->m_decalSizeY = 1.0f/decalSizeY; //height + + shadow->m_decalOffsetU= decalOffsetX; + shadow->m_decalOffsetV= decalOffsetY; + + shadow->m_flags = 0; + + shadow->init(); + + return shadow; +} + void W3DProjectedShadowManager::removeShadow (W3DProjectedShadow *shadow) { W3DProjectedShadow *prev_shadow=NULL; diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp index cd56ba06f0..6728c86599 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp @@ -44,7 +44,7 @@ //------------------------------------------------------------------------------------------------- W3DDisplayStringManager::W3DDisplayStringManager( void ) { - for (Int i = 0; i < 10; ++i) + for (Int i = 0; i < MAX_GROUPS; ++i) { m_groupNumeralStrings[i] = NULL; } @@ -56,7 +56,7 @@ W3DDisplayStringManager::W3DDisplayStringManager( void ) //------------------------------------------------------------------------------------------------- W3DDisplayStringManager::~W3DDisplayStringManager( void ) { - for (Int i = 0; i < 10; ++i) + for (Int i = 0; i < MAX_GROUPS; ++i) { if (m_groupNumeralStrings[i]) freeDisplayString(m_groupNumeralStrings[i]); @@ -79,14 +79,20 @@ void W3DDisplayStringManager::postProcessLoad( void ) TheDrawGroupInfo->m_fontSize, TheDrawGroupInfo->m_fontIsBold ); - for (Int i = 0; i < 10; ++i) + for (Int i = 0; i < MAX_GROUPS; ++i) { m_groupNumeralStrings[i] = newDisplayString(); m_groupNumeralStrings[i]->setFont(font); - AsciiString displayNumber; - displayNumber.format("NUMBER:%d", i); - m_groupNumeralStrings[i]->setText(TheGameText->fetch(displayNumber)); +#ifdef KRIS_BRUTAL_HACK_FOR_AIRCRAFT_CARRIER_DEBUGGING + UnicodeString displayNumber; + displayNumber.format( L"%d", i); + m_groupNumeralStrings[i]->setText( displayNumber ); +#else + AsciiString displayNumber; + displayNumber.format("NUMBER:%d", i); + m_groupNumeralStrings[i]->setText(TheGameText->fetch(displayNumber)); +#endif } m_formationLetterDisplayString = newDisplayString(); @@ -225,7 +231,8 @@ void W3DDisplayStringManager::update( void ) //------------------------------------------------------------------------------------------------- DisplayString *W3DDisplayStringManager::getGroupNumeralString( Int numeral ) { - if (numeral < 0 || numeral > 9) { + if (numeral < 0 || numeral > MAX_GROUPS - 1 ) + { DEBUG_CRASH(("Numeral '%d' out of range.\n", numeral)); return m_groupNumeralStrings[0]; } diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp index 4c5905b029..cfa304bf40 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp @@ -1771,3 +1771,160 @@ void RTS3DInterfaceScene::Customized_Render( RenderInfoClass &rinfo ) } // end Customized_Render + + +/// The following is an :archive" of a partial attempt at detecting the mapshroud hack +/* + * + +void RTS3DScene::Visibility_Check(CameraClass * camera) +{ +#ifdef DIRTY_CONDITION_FLAGS + StDrawableDirtyStuffLocker lockDirtyStuff; +#endif + + RefRenderObjListIterator it(&RenderList); + DrawableInfo *drawInfo = NULL; + Drawable *draw = NULL; + RenderObjClass * robj; + + m_numPotentialOccluders=0; + m_numPotentialOccludees=0; + m_translucentObjectsCount=0; + m_numNonOccluderOrOccludee=0; + + Int currentFrame=0; + if (TheGameLogic) currentFrame = TheGameLogic->getFrame(); + if (currentFrame <= TheGlobalData->m_defaultOcclusionDelay) + currentFrame = TheGlobalData->m_defaultOcclusionDelay+1; //make sure occlusion is enabled when game starts (frame 0). + + + if (ShaderClass::Is_Backface_Culling_Inverted()) + { //we are rendering reflections + ///@todo: Have better flag to detect reflection pass + + // Loop over all top-level RenderObjects in this scene. If the bounding sphere is not in front + // of all the frustum planes, it is invisible. + for (it.First(); !it.Is_Done(); it.Next()) { + + robj = it.Peek_Obj(); + + draw=NULL; + drawInfo = (DrawableInfo *)robj->Get_User_Data(); + if (drawInfo) + draw=drawInfo->m_drawable; + + if( draw ) + { + if (robj->Is_Force_Visible()) { + robj->Set_Visible(true); + } else { + robj->Set_Visible(draw->getDrawsInMirror() && !camera->Cull_Sphere(robj->Get_Bounding_Sphere())); + } + } + else + { //perform normal culling on non-drawables + if (robj->Is_Force_Visible()) { + robj->Set_Visible(true); + } else { + robj->Set_Visible(!camera->Cull_Sphere(robj->Get_Bounding_Sphere())); + } + } + } + } + else + { + + // Loop over all top-level RenderObjects in this scene. If the bounding sphere is not in front + // of all the frustum planes, it is invisible. + for (it.First(); !it.Is_Done(); it.Next()) { + + robj = it.Peek_Obj(); + + if (robj->Is_Force_Visible()) { + robj->Set_Visible(true); + } else if (robj->Is_Hidden()) { + robj->Set_Visible(false); + } else { + + UnsignedByte isVisible = 0; + + + //Cheater Foil + isVisible |= (UnsignedByte)(camera->Cull_Sphere(robj->Get_Bounding_Sphere()) == FALSE); + isVisible |= (UnsignedByte)(draw->isDrawableEffectivelyHidden()); + isVisible |= (draw->getFullyObscuredByShroudWithCheatSpy()); + robj->Set_VisibleWithCheatSpy(isVisible); + if (robj->Is_VisibleWithCheatSpy())//this will clear for the bit set above + + { //need to keep track of occluders and ocludees for subsequent code. + drawInfo = (DrawableInfo *)robj->Get_User_Data(); + if (drawInfo && (draw=drawInfo->m_drawable) != NULL) + { + +// now handled above in the cheater foil <<<<<<<<<<<< +// if (draw->isDrawableEffectivelyHidden() || draw->getFullyObscuredByShroud()) +// { robj->Set_Visible(false); +// continue; +// } + //assume normal rendering. + drawInfo->m_flags = DrawableInfo::ERF_IS_NORMAL; //clear any rendering flags that may be in effect. + + + if (draw->getEffectiveOpacity() != 1.0f && m_translucentObjectsCount < TheGlobalData->m_maxVisibleTranslucentObjects) + { drawInfo->m_flags |= DrawableInfo::ERF_IS_TRANSLUCENT; //object is translucent + m_translucentObjectsBuffer[m_translucentObjectsCount++] = robj; + } + if (TheGlobalData->m_enableBehindBuildingMarkers && TheGameLogic->getShowBehindBuildingMarkers()) + { + //visible drawable. Check if it's either an occluder or occludee + if (draw->isKindOf(KINDOF_STRUCTURE) && m_numPotentialOccluders < TheGlobalData->m_maxVisibleOccluderObjects) + { //object which could occlude other objects that need to be visible. + //Make sure this object is not translucent so it's not rendered twice (from m_potentialOccluders and m_translucentObjectsBuffer) + if (drawInfo->m_flags ^ DrawableInfo::ERF_IS_TRANSLUCENT) + m_potentialOccluders[m_numPotentialOccluders++]=robj; + drawInfo->m_flags |= DrawableInfo::ERF_POTENTIAL_OCCLUDER; + } + else + if (draw->getObject() && + (draw->isKindOf(KINDOF_SCORE) || draw->isKindOf(KINDOF_SCORE_CREATE) || draw->isKindOf(KINDOF_SCORE_DESTROY) || draw->isKindOf(KINDOF_MP_COUNT_FOR_VICTORY)) && + (draw->getObject()->getSafeOcclusionFrame()) <= currentFrame && m_numPotentialOccludees < TheGlobalData->m_maxVisibleOccludeeObjects) + { //object which could be occluded but still needs to be visible. + //We process transucent units twice (also in m_translucentObjectsBuffer) because we need to see them when occluded. + m_potentialOccludees[m_numPotentialOccludees++]=robj; + drawInfo->m_flags |= DrawableInfo::ERF_POTENTIAL_OCCLUDEE; + } + else + if (drawInfo->m_flags == DrawableInfo::ERF_IS_NORMAL && m_numNonOccluderOrOccludee < TheGlobalData->m_maxVisibleNonOccluderOrOccludeeObjects) + { //regular object with no custom effects but still needs to be delayed to get the occlusion feature to work correctly. + //Make sure this object is not translucent so it's not rendered twice (from m_potentialOccluders and m_translucentObjectsBuffer) + if (drawInfo->m_flags ^ DrawableInfo::ERF_IS_TRANSLUCENT) //make sure not translucent + m_nonOccludersOrOccludees[m_numNonOccluderOrOccludee++]=robj; + drawInfo->m_flags |= DrawableInfo::ERF_IS_NON_OCCLUDER_OR_OCCLUDEE; + } + } + + + } + } + +// robj->Set_Visible(isVisible); //now handled above in the cheater foil + } + + ///@todo: We're not using LOD yet so I disabled this code. MW + // Also, should check how multiple passes (reflections) get along + // with the LOD manager - we're rendering double the load it thinks we are. + // Prepare visible objects for LOD: + // if (robj->Is_Really_Visible()) { + // robj->Prepare_LOD(*camera); + // } + } + } + + Visibility_Checked = true; +} + + + * + */ + diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp index 9dd10b11df..ec7118ef4c 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp @@ -105,16 +105,9 @@ W3DWaypointBuffer::W3DWaypointBuffer(void) m_line = new SegmentedLineClass; m_texture = WW3DAssetManager::Get_Instance()->Get_Texture( "EXLaser.tga" ); - if( m_texture ) - { - m_line->Set_Texture( m_texture ); - } - ShaderClass lineShader=ShaderClass::_PresetAdditiveShader; - lineShader.Set_Depth_Compare(ShaderClass::PASS_ALWAYS); - m_line->Set_Shader( lineShader ); //pick the alpha blending mode you want - see shader.h for others. - m_line->Set_Width( 1.5f ); - m_line->Set_Color( Vector3( 0.25f, 0.5f, 1.0f ) ); - m_line->Set_Texture_Mapping_Mode( SegLineRendererClass::TILED_TEXTURE_MAP ); //this tiles the texture across the line + + + setDefaultLineStyle(); } //============================================================================= @@ -139,6 +132,21 @@ void W3DWaypointBuffer::freeWaypointBuffers() } +void W3DWaypointBuffer::setDefaultLineStyle( void ) +{ + if( m_texture ) + { + m_line->Set_Texture( m_texture ); + } + ShaderClass lineShader=ShaderClass::_PresetAdditiveShader; + lineShader.Set_Depth_Compare(ShaderClass::PASS_ALWAYS); + m_line->Set_Shader( lineShader ); //pick the alpha blending mode you want - see shader.h for others. + m_line->Set_Width( 1.5f ); + m_line->Set_Color( Vector3( 0.25f, 0.5f, 1.0f ) ); + m_line->Set_Texture_Mapping_Mode( SegLineRendererClass::TILED_TEXTURE_MAP ); //this tiles the texture across the line +} + + //============================================================================= // W3DWaypointBuffer::drawWaypoints //============================================================================= diff --git a/Generals/Code/Tools/GUIEdit/Source/GUIEdit.cpp b/Generals/Code/Tools/GUIEdit/Source/GUIEdit.cpp index a9c3981816..7b4e2c8cfb 100644 --- a/Generals/Code/Tools/GUIEdit/Source/GUIEdit.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/GUIEdit.cpp @@ -488,6 +488,10 @@ void GUIEdit::init( void ) // add status bar to the bottom createStatusBar(); + // create the name key generator + TheNameKeyGenerator = new NameKeyGenerator; + TheNameKeyGenerator->init(); + // create file system TheFileSystem = new FileSystem; TheLocalFileSystem = new Win32LocalFileSystem; @@ -522,10 +526,6 @@ void GUIEdit::init( void ) TheWritableGlobalData = new GlobalData; TheWritableGlobalData->init(); - // create the name key generator - TheNameKeyGenerator = new NameKeyGenerator; - TheNameKeyGenerator->init(); - // create the message stream TheMessageStream = new MessageStream; TheMessageStream->init(); diff --git a/Generals/Code/Tools/WorldBuilder/src/MapPreview.cpp b/Generals/Code/Tools/WorldBuilder/src/MapPreview.cpp index 52b48c76e5..1ce0db6cb0 100644 --- a/Generals/Code/Tools/WorldBuilder/src/MapPreview.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/MapPreview.cpp @@ -411,13 +411,15 @@ void MapPreview::buildMapPreviewTexture( CString tgaName ) } // end for x } // end for y - Targa tga; - tga.Header.Width = MAP_PREVIEW_WIDTH; - tga.Header.Height = MAP_PREVIEW_HEIGHT; - tga.Header.PixelDepth = 32; - tga.Header.ImageType = TGA_TRUECOLOR; - tga.SetImage((char *)m_pixelBuffer); - tga.Save(tgaName,TGAF_IMAGE, FALSE); + { + Targa tga; + tga.Header.Width = MAP_PREVIEW_WIDTH; + tga.Header.Height = MAP_PREVIEW_HEIGHT; + tga.Header.PixelDepth = 32; + tga.Header.ImageType = TGA_TRUECOLOR; + tga.SetImage((char *)m_pixelBuffer); + tga.Save(tgaName,TGAF_IMAGE, FALSE); + } } // end buildTerrainTexture From c5e48162dee4f94f054549e4c7b66d5eed4128aa Mon Sep 17 00:00:00 2001 From: xezon <4720891+xezon@users.noreply.github.com> Date: Sat, 3 May 2025 17:10:23 +0200 Subject: [PATCH 2/3] Fix _DEBUG, _INTERNAL names --- Generals/Code/GameEngine/Include/Common/crc.h | 2 +- Generals/Code/GameEngine/Include/GameClient/ControlBar.h | 2 +- Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp | 2 +- Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp | 2 +- Generals/Code/GameEngine/Source/Common/MessageStream.cpp | 2 +- Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp | 2 +- Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp | 2 +- Generals/Code/GameEngine/Source/Common/Thing/Module.cpp | 2 +- Generals/Code/GameEngine/Source/Common/crc.cpp | 2 +- Generals/Code/GameEngine/Source/GameClient/Color.cpp | 2 +- .../Source/GameClient/GUI/ControlBar/ControlBar.cpp | 4 ++-- .../Source/GameClient/GUI/GameWindowManagerScript.cpp | 2 +- .../GameEngine/Source/GameClient/System/CampaignManager.cpp | 2 +- .../GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp | 2 +- .../Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp | 2 +- .../GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp | 2 +- .../Source/GameLogic/Object/Contain/OverlordContain.cpp | 2 +- .../Source/GameLogic/Object/Die/CreateObjectDie.cpp | 2 +- .../GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp | 2 +- .../GameLogic/Object/Update/AssistedTargetingUpdate.cpp | 2 +- .../Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp | 2 +- .../Include/W3DDevice/GameClient/W3DProjectedShadow.h | 2 +- .../GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp | 2 +- 23 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Generals/Code/GameEngine/Include/Common/crc.h b/Generals/Code/GameEngine/Include/Common/crc.h index 855dc2d520..2bc5ef495e 100644 --- a/Generals/Code/GameEngine/Include/Common/crc.h +++ b/Generals/Code/GameEngine/Include/Common/crc.h @@ -33,7 +33,7 @@ #include "Lib/BaseType.h" -#ifdef _DEBUG +#ifdef RTS_DEBUG //#include "winsock2.h" // for htonl diff --git a/Generals/Code/GameEngine/Include/GameClient/ControlBar.h b/Generals/Code/GameEngine/Include/GameClient/ControlBar.h index 7d30a219bf..47e96c62fc 100644 --- a/Generals/Code/GameEngine/Include/GameClient/ControlBar.h +++ b/Generals/Code/GameEngine/Include/GameClient/ControlBar.h @@ -1007,7 +1007,7 @@ class ControlBar : public SubsystemInterface Int m_remainingRadarAttackGlowFrames; GameWindow *m_radarAttackGlowWindow; -#if defined( _INTERNAL ) || defined( _DEBUG ) +#if defined( RTS_INTERNAL ) || defined( RTS_DEBUG ) UnsignedInt m_lastFrameMarkedDirty; UnsignedInt m_consecutiveDirtyFrames; #endif diff --git a/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp b/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp index 7f6abd3a66..d9adae2520 100644 --- a/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp +++ b/Generals/Code/GameEngine/Source/Common/Audio/GameMusic.cpp @@ -52,7 +52,7 @@ #include "Common/GameAudio.h" #include "Common/INI.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") #endif diff --git a/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp b/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp index 557a220fd3..abc56997d5 100644 --- a/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp +++ b/Generals/Code/GameEngine/Source/Common/INI/INIMapCache.cpp @@ -38,7 +38,7 @@ #include "Common/WellKnownKeys.h" #include "Common/QuotedPrintable.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/Common/MessageStream.cpp b/Generals/Code/GameEngine/Source/Common/MessageStream.cpp index 5ba2f12976..06356b4e82 100644 --- a/Generals/Code/GameEngine/Source/Common/MessageStream.cpp +++ b/Generals/Code/GameEngine/Source/Common/MessageStream.cpp @@ -42,7 +42,7 @@ CommandList *TheCommandList = NULL; -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp b/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp index 9a6a5c3303..9e84fb0a2c 100644 --- a/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp +++ b/Generals/Code/GameEngine/Source/Common/NameKeyGenerator.cpp @@ -193,7 +193,7 @@ NameKeyType NameKeyGenerator::nameToLowercaseKey(const char* nameString) NameKeyType result = b->m_key; -#if defined(_DEBUG) || defined(_INTERNAL) +#if defined(RTS_DEBUG) || defined(RTS_INTERNAL) // reality-check to be sure our hasher isn't going bad. const Int maxThresh = 3; Int numOverThresh = 0; diff --git a/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp b/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp index d089c2dd2b..711568b020 100644 --- a/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp +++ b/Generals/Code/GameEngine/Source/Common/RTS/Energy.cpp @@ -51,7 +51,7 @@ #include "Common/Xfer.h" #include "GameLogic/Object.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp b/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp index 8d39fde10f..34ef9d96f6 100644 --- a/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp +++ b/Generals/Code/GameEngine/Source/Common/Thing/Module.cpp @@ -47,7 +47,7 @@ #include "GameLogic/Module/UpdateModule.h" #include "GameLogic/Module/UpgradeModule.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma message("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/Common/crc.cpp b/Generals/Code/GameEngine/Source/Common/crc.cpp index 950a1068f2..f3cbc369e2 100644 --- a/Generals/Code/GameEngine/Source/Common/crc.cpp +++ b/Generals/Code/GameEngine/Source/Common/crc.cpp @@ -28,7 +28,7 @@ #include "Common/crc.h" #include "Common/Debug.h" -#ifdef _DEBUG +#ifdef RTS_DEBUG void CRC::addCRC( UnsignedByte val ) { diff --git a/Generals/Code/GameEngine/Source/GameClient/Color.cpp b/Generals/Code/GameEngine/Source/GameClient/Color.cpp index 2fe0f6067c..36943ff01e 100644 --- a/Generals/Code/GameEngine/Source/GameClient/Color.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/Color.cpp @@ -79,7 +79,7 @@ /** Get the RGB color comonents of a color */ //============================================================================= -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp index f241d1339d..5e1d32956e 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -138,7 +138,7 @@ void ControlBar::markUIDirty( void ) { m_UIDirty = TRUE; -#if defined( _INTERNAL ) || defined( _DEBUG ) +#if defined( RTS_INTERNAL ) || defined( RTS_DEBUG ) UnsignedInt now = TheGameLogic->getFrame(); if( now == m_lastFrameMarkedDirty ) { @@ -938,7 +938,7 @@ ControlBar::ControlBar( void ) m_remainingRadarAttackGlowFrames = 0; m_radarAttackGlowWindow = NULL; -#if defined( _INTERNAL ) || defined( _DEBUG ) +#if defined( RTS_INTERNAL ) || defined( RTS_DEBUG ) m_lastFrameMarkedDirty = 0; m_consecutiveDirtyFrames = 0; #endif diff --git a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp index 32b92959b7..84fef3f297 100644 --- a/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/GUI/GameWindowManagerScript.cpp @@ -72,7 +72,7 @@ #include "GameClient/GameText.h" #include "GameClient/HeaderTemplate.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp b/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp index 15aff04ccc..3fb63c252b 100644 --- a/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/System/CampaignManager.cpp @@ -62,7 +62,7 @@ CampaignManager *TheCampaignManager = NULL; -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp b/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp index 9d35ed68de..f6bec5e353 100644 --- a/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp @@ -32,7 +32,7 @@ #include "GameClient/TerrainVisual.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp index 4c8a6d89a3..7e2ea1e227 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/AutoHealBehavior.cpp @@ -44,7 +44,7 @@ #include "GameLogic/Object.h" #include "GameLogic/PartitionManager.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp index 288238e811..49945919ba 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp @@ -39,7 +39,7 @@ #include "GameLogic/Object.h" #include "GameLogic/Module/CrateCollide.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp index 9b63a0b9f6..e84213ce62 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OverlordContain.cpp @@ -44,7 +44,7 @@ #include "GameLogic/PartitionManager.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp index 84d8a85b17..583b0dea93 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp @@ -37,7 +37,7 @@ #include "GameLogic/Object.h" #include "GameLogic/ObjectCreationList.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp index 2e373ed0aa..9cd6452976 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Die/DestroyDie.cpp @@ -35,7 +35,7 @@ #include "GameLogic/GameLogic.h" #include "GameLogic/Module/DestroyDie.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp index ef16d76028..2526e17f4c 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp @@ -42,7 +42,7 @@ #include "GameLogic/Module/LaserUpdate.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp index 9e6c42bf91..df413ad986 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/FireOCLAfterWeaponCooldownUpdate.cpp @@ -51,7 +51,7 @@ #include "GameLogic/Module/AIUpdate.h" #include "GameLogic/Module/BodyModule.h" -#ifdef _INTERNAL +#ifdef RTS_INTERNAL // for occasional debugging... //#pragma optimize("", off) //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") diff --git a/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h b/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h index 6d136b763b..a384b6e177 100644 --- a/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h +++ b/Generals/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DProjectedShadow.h @@ -108,7 +108,7 @@ class W3DProjectedShadow : public Shadow void updateTexture(Vector3 &lightPos); /// Date: Sat, 3 May 2025 18:43:05 +0200 Subject: [PATCH 3/3] Revert the ScopedMutex change --- Generals/Code/GameEngine/Include/Common/ScopedMutex.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Generals/Code/GameEngine/Include/Common/ScopedMutex.h b/Generals/Code/GameEngine/Include/Common/ScopedMutex.h index 0aea5e2859..ffac55a025 100644 --- a/Generals/Code/GameEngine/Include/Common/ScopedMutex.h +++ b/Generals/Code/GameEngine/Include/Common/ScopedMutex.h @@ -34,10 +34,7 @@ class ScopedMutex public: ScopedMutex(HANDLE mutex) : m_mutex(mutex) { - DWORD status = WaitForSingleObject(m_mutex, 500); - if (status != WAIT_OBJECT_0) { - DEBUG_LOG(("ScopedMutex WaitForSingleObject timed out - status %d\n", status)); - } + WaitForSingleObject(m_mutex, INFINITE); } ~ScopedMutex()