From a929585a44561922d612fede453d1bbaafcc6803 Mon Sep 17 00:00:00 2001 From: DevGeniusCode <136935333+DevGeniusCode@users.noreply.github.com> Date: Mon, 20 Apr 2026 19:34:18 +0300 Subject: [PATCH 1/7] style: Add Clang-Format configuration file --- .clang-format | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000000..86c8c5e0729 --- /dev/null +++ b/.clang-format @@ -0,0 +1,64 @@ +# ============================================================================== +# Minimalist Clang-Format Configuration (Baseline) +# ============================================================================== +Language: Cpp +Standard: c++03 + +# 1. Non-Destructive Core Setting +# ------------------------------------------------------------------------------ +# Completely disable automatic line wrapping to preserve manual formatting. +ColumnLimit: 0 + +# 2. Indentation & Tabs +# ------------------------------------------------------------------------------ +UseTab: ForIndentation +IndentWidth: 2 +TabWidth: 2 +ContinuationIndentWidth: 2 +AccessModifierOffset: -2 +IndentCaseLabels: true +AlignTrailingComments: true + +# 3. Braces Style: Allman +# ------------------------------------------------------------------------------ +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false +AllowShortEnumsOnASingleLine: false + +# 4. Pointers & Spaces +# ------------------------------------------------------------------------------ +PointerAlignment: Left +SpacesInParentheses: false +BreakConstructorInitializers: BeforeComma + +# 5. Legacy & Compatibility (VC6 / Custom Macros) +# ------------------------------------------------------------------------------ +# Prevent expanding/collapsing short blocks and functions to minimize diffs +AllowShortFunctionsOnASingleLine: All +AllowShortBlocksOnASingleLine: Always + +# Handle custom legacy macros so the parser doesn't break +Macros: + - CPP_11(x)= + - CPP_11(:x)= + - CPP_11(x=y)= + +IndentPPDirectives: BeforeHash +ConstructorInitializerIndentWidth: 2 + +# 6. Includes +# ------------------------------------------------------------------------------ +SortIncludes: false \ No newline at end of file From 9ddb58a4bc25520d7135e45aa7e2783150d5beef Mon Sep 17 00:00:00 2001 From: DevGeniusCode <136935333+DevGeniusCode@users.noreply.github.com> Date: Mon, 20 Apr 2026 19:35:41 +0300 Subject: [PATCH 2/7] style: Clean up whitespace and formatting across `\Core\GameEngine` files --- Core/GameEngine/Include/Common/ArchiveFile.h | 40 +- .../Include/Common/ArchiveFileSystem.h | 67 +- Core/GameEngine/Include/Common/AsciiString.h | 237 +- Core/GameEngine/Include/Common/AudioAffect.h | 3 +- .../Include/Common/AudioEventInfo.h | 3 +- .../GameEngine/Include/Common/AudioEventRTS.h | 7 +- .../Include/Common/AudioHandleSpecialValues.h | 3 +- .../Include/Common/AudioRandomValue.h | 8 +- Core/GameEngine/Include/Common/AudioRequest.h | 3 +- .../GameEngine/Include/Common/AudioSettings.h | 41 +- Core/GameEngine/Include/Common/CRCDebug.h | 123 +- Core/GameEngine/Include/Common/Debug.h | 230 +- .../Include/Common/DynamicAudioEventInfo.h | 91 +- Core/GameEngine/Include/Common/Errors.h | 11 +- Core/GameEngine/Include/Common/FileSystem.h | 86 +- Core/GameEngine/Include/Common/FramePacer.h | 5 +- .../Include/Common/FrameRateLimit.h | 6 +- Core/GameEngine/Include/Common/GameAudio.h | 5 +- Core/GameEngine/Include/Common/GameCommon.h | 17 +- Core/GameEngine/Include/Common/GameDefines.h | 50 +- Core/GameEngine/Include/Common/GameMemory.h | 996 +-- .../Include/Common/GameMemoryNull.h | 102 +- Core/GameEngine/Include/Common/GameMusic.h | 48 +- Core/GameEngine/Include/Common/GameSounds.h | 65 +- Core/GameEngine/Include/Common/GameType.h | 7 +- Core/GameEngine/Include/Common/GameUtility.h | 6 +- Core/GameEngine/Include/Common/INI.h | 5 +- Core/GameEngine/Include/Common/LocalFile.h | 92 +- .../Include/Common/LocalFileSystem.h | 14 +- Core/GameEngine/Include/Common/MapObject.h | 16 +- Core/GameEngine/Include/Common/MiniDumper.h | 5 +- Core/GameEngine/Include/Common/MiscAudio.h | 74 +- .../Include/Common/ObjectStatusTypes.h | 3 +- .../Include/Common/OptionPreferences.h | 2 +- Core/GameEngine/Include/Common/RAMFile.h | 99 +- Core/GameEngine/Include/Common/Radar.h | 11 +- Core/GameEngine/Include/Common/RandomValue.h | 6 +- .../Include/Common/ReplaySimulation.h | 11 +- Core/GameEngine/Include/Common/STLTypedefs.h | 8 +- Core/GameEngine/Include/Common/Snapshot.h | 15 +- .../Include/Common/StreamingArchiveFile.h | 92 +- .../Include/Common/SubsystemInterface.h | 116 +- .../GameEngine/Include/Common/UnicodeString.h | 231 +- .../Include/Common/UserPreferences.h | 24 +- Core/GameEngine/Include/Common/Xfer.h | 3 +- Core/GameEngine/Include/Common/XferCRC.h | 21 +- Core/GameEngine/Include/Common/XferDeepCRC.h | 16 +- Core/GameEngine/Include/Common/XferLoad.h | 23 +- Core/GameEngine/Include/Common/XferSave.h | 25 +- Core/GameEngine/Include/Common/crc.h | 121 +- Core/GameEngine/Include/Common/file.h | 279 +- Core/GameEngine/Include/Common/simpleplayer.h | 137 +- Core/GameEngine/Include/Common/urllaunch.h | 4 +- .../Include/GameClient/ChallengeGenerals.h | 69 +- .../Include/GameClient/ClientRandomValue.h | 27 +- Core/GameEngine/Include/GameClient/Color.h | 24 +- Core/GameEngine/Include/GameClient/Credits.h | 70 +- .../Include/GameClient/DisplayString.h | 61 +- .../Include/GameClient/DisplayStringManager.h | 27 +- .../Include/GameClient/DrawGroupInfo.h | 6 +- Core/GameEngine/Include/GameClient/FXList.h | 139 +- Core/GameEngine/Include/GameClient/GameFont.h | 49 +- Core/GameEngine/Include/GameClient/GameText.h | 63 +- .../Include/GameClient/GameWindow.h | 8 +- .../GameClient/GameWindowTransitions.h | 506 +- .../Include/GameClient/GlobalLanguage.h | 52 +- .../GameEngine/Include/GameClient/GraphDraw.h | 38 +- .../Include/GameClient/HeaderTemplate.h | 21 +- .../Include/GameClient/IMEManager.h | 65 +- Core/GameEngine/Include/GameClient/Keyboard.h | 3 +- .../Include/GameClient/LanguageFilter.h | 13 +- Core/GameEngine/Include/GameClient/Line2D.h | 44 +- .../Include/GameClient/LoadScreen.h | 240 +- Core/GameEngine/Include/GameClient/MapUtil.h | 62 +- Core/GameEngine/Include/GameClient/Mouse.h | 3 +- .../Include/GameClient/ParabolicEase.h | 32 +- .../Include/GameClient/ParticleSys.h | 10 +- .../Include/GameClient/ProcessAnimateWindow.h | 167 +- .../Include/GameClient/RadiusDecal.h | 3 +- .../Include/GameClient/SelectionInfo.h | 15 +- Core/GameEngine/Include/GameClient/Smudge.h | 79 +- Core/GameEngine/Include/GameClient/Snow.h | 134 +- .../Include/GameClient/Statistics.h | 1 - .../Include/GameClient/TerrainRoads.h | 4 +- .../Include/GameClient/TerrainVisual.h | 5 +- .../Include/GameClient/VideoPlayer.h | 327 +- Core/GameEngine/Include/GameClient/View.h | 5 +- Core/GameEngine/Include/GameClient/Water.h | 94 +- .../Include/GameClient/WinInstanceData.h | 129 +- .../Include/GameClient/WindowLayout.h | 87 +- .../Include/GameClient/WindowVideoManager.h | 4 +- .../GameEngine/Include/GameLogic/AIPathfind.h | 978 ++- .../Include/GameLogic/LogicRandomValue.h | 31 +- .../Include/GameNetwork/Connection.h | 38 +- .../Include/GameNetwork/ConnectionManager.h | 114 +- .../Include/GameNetwork/DisconnectManager.h | 5 +- .../Include/GameNetwork/DownloadManager.h | 14 +- .../Include/GameNetwork/FileTransfer.h | 22 +- .../Include/GameNetwork/FirewallHelper.h | 9 +- .../Include/GameNetwork/FrameData.h | 3 +- .../Include/GameNetwork/FrameDataManager.h | 8 +- .../Include/GameNetwork/FrameMetrics.h | 25 +- .../GameEngine/Include/GameNetwork/GameInfo.h | 3 +- .../Include/GameNetwork/GameMessageParser.h | 25 +- .../Include/GameNetwork/GameSpy/BuddyThread.h | 34 +- .../Include/GameNetwork/GameSpy/GSConfig.h | 2 +- .../GameNetwork/GameSpy/GameResultsThread.h | 10 +- .../Include/GameNetwork/GameSpy/LadderDefs.h | 10 +- .../Include/GameNetwork/GameSpy/LobbyUtils.h | 13 +- .../GameNetwork/GameSpy/MainMenuUtils.h | 5 +- .../Include/GameNetwork/GameSpy/PeerDefs.h | 3 +- .../GameSpy/PeerDefsImplementation.h | 121 +- .../Include/GameNetwork/GameSpy/PeerThread.h | 3 +- .../GameSpy/PersistentStorageDefs.h | 3 +- .../GameSpy/PersistentStorageThread.h | 34 +- .../Include/GameNetwork/GameSpy/PingThread.h | 14 +- .../GameNetwork/GameSpy/StagingRoomGameInfo.h | 50 +- .../Include/GameNetwork/GameSpy/ThreadUtils.h | 4 +- .../Include/GameNetwork/GameSpyOverlay.h | 13 +- .../Include/GameNetwork/GameSpyThread.h | 44 +- .../Include/GameNetwork/IPEnumeration.h | 27 +- Core/GameEngine/Include/GameNetwork/LANAPI.h | 384 +- .../Include/GameNetwork/LANAPICallbacks.h | 32 +- .../Include/GameNetwork/LANGameInfo.h | 94 +- .../Include/GameNetwork/LANPlayer.h | 38 +- Core/GameEngine/Include/GameNetwork/NAT.h | 3 +- .../Include/GameNetwork/NetCommandList.h | 34 +- .../Include/GameNetwork/NetCommandMsg.h | 90 +- .../Include/GameNetwork/NetCommandRef.h | 39 +- .../GameNetwork/NetCommandWrapperList.h | 25 +- .../Include/GameNetwork/NetPacket.h | 110 +- .../Include/GameNetwork/NetPacketStructs.h | 408 +- .../Include/GameNetwork/NetworkDefs.h | 3 +- .../Include/GameNetwork/NetworkInterface.h | 58 +- .../Include/GameNetwork/RankPointValue.h | 8 +- .../Include/GameNetwork/Transport.h | 34 +- Core/GameEngine/Include/GameNetwork/User.h | 7 +- .../GameNetwork/WOLBrowser/FEBDispatch.h | 30 +- .../GameNetwork/WOLBrowser/WebBrowser.h | 109 +- .../Include/GameNetwork/networkutil.h | 19 +- Core/GameEngine/Include/GameNetwork/udp.h | 63 +- .../Source/Common/Audio/AudioEventRTS.cpp | 591 +- .../Source/Common/Audio/AudioRequest.cpp | 5 +- .../Common/Audio/DynamicAudioEventInfo.cpp | 255 +- .../Source/Common/Audio/GameAudio.cpp | 713 +- .../Source/Common/Audio/GameMusic.cpp | 42 +- .../Source/Common/Audio/GameSounds.cpp | 66 +- .../Source/Common/Audio/simpleplayer.cpp | 1080 ++- .../Source/Common/Audio/urllaunch.cpp | 606 +- Core/GameEngine/Source/Common/CRCDebug.cpp | 141 +- .../Common/Diagnostic/SimulationMathCrc.cpp | 60 +- Core/GameEngine/Source/Common/FramePacer.cpp | 21 +- .../Source/Common/FrameRateLimit.cpp | 24 +- Core/GameEngine/Source/Common/GameUtility.cpp | 2 +- Core/GameEngine/Source/Common/INI/INI.cpp | 927 +- .../Source/Common/INI/INIAudioEventInfo.cpp | 184 +- .../Source/Common/INI/INIMiscAudio.cpp | 83 +- .../GameEngine/Source/Common/INI/INIVideo.cpp | 12 +- .../Source/Common/OptionPreferences.cpp | 124 +- Core/GameEngine/Source/Common/RandomValue.cpp | 163 +- .../Source/Common/ReplaySimulation.cpp | 43 +- .../Source/Common/System/ArchiveFile.cpp | 90 +- .../Common/System/ArchiveFileSystem.cpp | 64 +- .../Source/Common/System/AsciiString.cpp | 52 +- .../GameEngine/Source/Common/System/Debug.cpp | 326 +- Core/GameEngine/Source/Common/System/File.cpp | 94 +- .../Source/Common/System/FileSystem.cpp | 72 +- .../Source/Common/System/GameCommon.cpp | 39 +- .../Source/Common/System/GameMemory.cpp | 1673 ++-- .../Source/Common/System/GameMemoryInit.cpp | 23 +- .../Source/Common/System/GameMemoryNull.cpp | 67 +- .../Source/Common/System/GameType.cpp | 30 +- .../Source/Common/System/LocalFile.cpp | 201 +- .../Source/Common/System/LocalFileSystem.cpp | 22 +- .../Source/Common/System/MiniDumper.cpp | 129 +- .../Common/System/ObjectStatusTypes.cpp | 101 +- .../Source/Common/System/RAMFile.cpp | 215 +- .../GameEngine/Source/Common/System/Radar.cpp | 921 +- .../Source/Common/System/Snapshot.cpp | 6 +- .../Common/System/StreamingArchiveFile.cpp | 85 +- .../Common/System/SubsystemInterface.cpp | 100 +- .../Source/Common/System/UnicodeString.cpp | 46 +- Core/GameEngine/Source/Common/System/Xfer.cpp | 482 +- .../Source/Common/System/XferCRC.cpp | 143 +- .../Source/Common/System/XferLoad.cpp | 117 +- .../Source/Common/System/XferSave.cpp | 181 +- .../Source/Common/UserPreferences.cpp | 150 +- .../Source/Common/WorkerProcess.cpp | 25 +- Core/GameEngine/Source/Common/crc.cpp | 36 +- Core/GameEngine/Source/GameClient/Color.cpp | 83 +- Core/GameEngine/Source/GameClient/Credits.cpp | 284 +- .../Source/GameClient/DisplayString.cpp | 23 +- .../GameClient/DisplayStringManager.cpp | 33 +- .../Source/GameClient/DrawGroupInfo.cpp | 4 +- Core/GameEngine/Source/GameClient/FXList.cpp | 454 +- .../GameClient/GUI/ChallengeGenerals.cpp | 127 +- .../Source/GameClient/GUI/GameFont.cpp | 80 +- .../Source/GameClient/GUI/GameWindow.cpp | 795 +- .../GameClient/GUI/GameWindowGlobal.cpp | 118 +- .../GameClient/GUI/GameWindowTransitions.cpp | 285 +- .../Source/GameClient/GUI/HeaderTemplate.cpp | 91 +- .../Source/GameClient/GUI/IMEManager.cpp | 1450 ++- .../Source/GameClient/GUI/LoadScreen.cpp | 1268 ++- .../GameClient/GUI/ProcessAnimateWindow.cpp | 797 +- .../Source/GameClient/GUI/WinInstanceData.cpp | 81 +- .../Source/GameClient/GUI/WindowLayout.cpp | 132 +- .../GameClient/GUI/WindowVideoManager.cpp | 175 +- .../GameEngine/Source/GameClient/GameText.cpp | 681 +- .../Source/GameClient/GlobalLanguage.cpp | 207 +- .../Source/GameClient/GraphDraw.cpp | 18 +- .../Source/GameClient/Input/Keyboard.cpp | 988 +-- .../Source/GameClient/Input/Mouse.cpp | 813 +- .../Source/GameClient/LanguageFilter.cpp | 133 +- Core/GameEngine/Source/GameClient/Line2D.cpp | 194 +- Core/GameEngine/Source/GameClient/MapUtil.cpp | 567 +- .../Source/GameClient/ParabolicEase.cpp | 47 +- .../Source/GameClient/RadiusDecal.cpp | 96 +- .../Source/GameClient/SelectionInfo.cpp | 291 +- Core/GameEngine/Source/GameClient/Snow.cpp | 97 +- .../Source/GameClient/Statistics.cpp | 4 +- .../System/Debug/AudioDebugDisplay.cpp | 25 +- .../Source/GameClient/System/ParticleSys.cpp | 1494 ++-- .../Source/GameClient/System/Smudge.cpp | 103 +- .../GameClient/Terrain/TerrainRoads.cpp | 291 +- .../GameClient/Terrain/TerrainVisual.cpp | 170 +- .../Source/GameClient/VideoPlayer.cpp | 165 +- .../Source/GameClient/VideoStream.cpp | 16 - Core/GameEngine/Source/GameClient/View.cpp | 68 +- Core/GameEngine/Source/GameClient/Water.cpp | 72 +- .../Source/GameLogic/AI/AIPathfind.cpp | 7789 ++++++++++------- .../Source/GameNetwork/Connection.cpp | 219 +- .../Source/GameNetwork/ConnectionManager.cpp | 1487 ++-- .../Source/GameNetwork/DisconnectManager.cpp | 510 +- .../Source/GameNetwork/DownloadManager.cpp | 23 +- .../Source/GameNetwork/FileTransfer.cpp | 58 +- .../Source/GameNetwork/FirewallHelper.cpp | 737 +- .../Source/GameNetwork/FrameData.cpp | 74 +- .../Source/GameNetwork/FrameDataManager.cpp | 82 +- .../Source/GameNetwork/FrameMetrics.cpp | 62 +- .../Source/GameNetwork/GameInfo.cpp | 985 ++- .../Source/GameNetwork/GameMessageParser.cpp | 26 +- .../Source/GameNetwork/GameSpy/Chat.cpp | 217 +- .../Source/GameNetwork/GameSpy/GSConfig.cpp | 92 +- .../Source/GameNetwork/GameSpy/LadderDefs.cpp | 99 +- .../Source/GameNetwork/GameSpy/LobbyUtils.cpp | 553 +- .../GameNetwork/GameSpy/MainMenuUtils.cpp | 204 +- .../Source/GameNetwork/GameSpy/PeerDefs.cpp | 204 +- .../GameSpy/StagingRoomGameInfo.cpp | 253 +- .../GameSpy/Thread/BuddyThread.cpp | 454 +- .../GameSpy/Thread/GameResultsThread.cpp | 162 +- .../GameNetwork/GameSpy/Thread/PeerThread.cpp | 2204 ++--- .../Thread/PersistentStorageThread.cpp | 682 +- .../GameNetwork/GameSpy/Thread/PingThread.cpp | 522 +- .../GameSpy/Thread/ThreadUtils.cpp | 25 +- .../Source/GameNetwork/GameSpyOverlay.cpp | 139 +- .../Source/GameNetwork/IPEnumeration.cpp | 46 +- Core/GameEngine/Source/GameNetwork/LANAPI.cpp | 611 +- .../Source/GameNetwork/LANAPICallbacks.cpp | 279 +- .../Source/GameNetwork/LANAPIhandlers.cpp | 169 +- .../Source/GameNetwork/LANGameInfo.cpp | 85 +- Core/GameEngine/Source/GameNetwork/NAT.cpp | 875 +- .../Source/GameNetwork/NetCommandList.cpp | 239 +- .../Source/GameNetwork/NetCommandMsg.cpp | 551 +- .../Source/GameNetwork/NetCommandRef.cpp | 10 +- .../GameNetwork/NetCommandWrapperList.cpp | 133 +- .../Source/GameNetwork/NetMessageStream.cpp | 229 +- .../Source/GameNetwork/NetPacket.cpp | 1369 +-- .../Source/GameNetwork/NetPacketStructs.cpp | 404 +- .../GameEngine/Source/GameNetwork/Network.cpp | 518 +- .../Source/GameNetwork/NetworkUtil.cpp | 298 +- .../Source/GameNetwork/Transport.cpp | 156 +- Core/GameEngine/Source/GameNetwork/User.cpp | 14 +- .../GameNetwork/WOLBrowser/WebBrowser.cpp | 272 +- Core/GameEngine/Source/GameNetwork/udp.cpp | 441 +- 274 files changed, 29950 insertions(+), 27715 deletions(-) diff --git a/Core/GameEngine/Include/Common/ArchiveFile.h b/Core/GameEngine/Include/Common/ArchiveFile.h index 63987f9c9cb..fa2ff79b7b3 100644 --- a/Core/GameEngine/Include/Common/ArchiveFile.h +++ b/Core/GameEngine/Include/Common/ArchiveFile.h @@ -35,13 +35,13 @@ class File; /** - * An archive file is itself a collection of sub files. Each file inside the archive file - * has a unique name by which it can be accessed. The ArchiveFile object class is the - * runtime interface to the mix file and the sub files. Each file inside the mix - * file can be accessed by the openFile(). - * - * ArchiveFile interfaces can be created by the TheArchiveFileSystem object. - */ + * An archive file is itself a collection of sub files. Each file inside the archive file + * has a unique name by which it can be accessed. The ArchiveFile object class is the + * runtime interface to the mix file and the sub files. Each file inside the mix + * file can be accessed by the openFile(). + * + * ArchiveFile interfaces can be created by the TheArchiveFileSystem object. + */ //=============================== class ArchiveFile @@ -50,23 +50,23 @@ class ArchiveFile ArchiveFile(); virtual ~ArchiveFile(); - virtual Bool getFileInfo( const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested. - virtual File* openFile( const Char *filename, Int access = 0) = 0; ///< Open the specified file within the archive file - virtual void closeAllFiles() = 0; ///< Close all file opened in this archive file - virtual AsciiString getName() = 0; ///< Returns the name of the archive file - virtual AsciiString getPath() = 0; ///< Returns full path and name of archive file - virtual void setSearchPriority( Int new_priority ) = 0; ///< Set this archive file's search priority - virtual void close() = 0; ///< Close this archive file - void attachFile(File *file); + virtual Bool getFileInfo(const AsciiString& filename, FileInfo* fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested. + virtual File* openFile(const Char* filename, Int access = 0) = 0; ///< Open the specified file within the archive file + virtual void closeAllFiles() = 0; ///< Close all file opened in this archive file + virtual AsciiString getName() = 0; ///< Returns the name of the archive file + virtual AsciiString getPath() = 0; ///< Returns full path and name of archive file + virtual void setSearchPriority(Int new_priority) = 0; ///< Set this archive file's search priority + virtual void close() = 0; ///< Close this archive file + void attachFile(File* file); - void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; - void getFileListInDirectory(const DetailedArchivedDirectoryInfo *dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; + void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const; + void getFileListInDirectory(const DetailedArchivedDirectoryInfo* dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const; - void addFile(const AsciiString& path, const ArchivedFileInfo *fileInfo); ///< add this file to our directory tree. + void addFile(const AsciiString& path, const ArchivedFileInfo* fileInfo); ///< add this file to our directory tree. protected: - const ArchivedFileInfo * getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree. + const ArchivedFileInfo* getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree. - File *m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time. + File* m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time. DetailedArchivedDirectoryInfo m_rootDirectory; }; diff --git a/Core/GameEngine/Include/Common/ArchiveFileSystem.h b/Core/GameEngine/Include/Common/ArchiveFileSystem.h index 88c3e80170b..25abe9b568f 100644 --- a/Core/GameEngine/Include/Common/ArchiveFileSystem.h +++ b/Core/GameEngine/Include/Common/ArchiveFileSystem.h @@ -65,43 +65,42 @@ class ArchiveFile; // Type Defines //---------------------------------------------------------------------------- - //=============================== // ArchiveFileSystem //=============================== /** - * Creates and manages ArchiveFile interfaces. ArchiveFiles can be accessed - * by calling the openArchiveFile() member. ArchiveFiles can be accessed by - * name or by File interface. - * - * openFile() member searches all Archive files for the specified sub file. - */ + * Creates and manages ArchiveFile interfaces. ArchiveFiles can be accessed + * by calling the openArchiveFile() member. ArchiveFiles can be accessed by + * name or by File interface. + * + * openFile() member searches all Archive files for the specified sub file. + */ //=============================== class ArchivedDirectoryInfo; class DetailedArchivedDirectoryInfo; class ArchivedFileInfo; typedef std::map DetailedArchivedDirectoryInfoMap; // Archived directory name to detailed archived directory info -typedef std::map ArchivedDirectoryInfoMap; // Archived directory name to archived directory info -typedef std::map ArchivedFileInfoMap; // Archived file name to archived file info -typedef std::map ArchiveFileMap; // Archive file name to archive data -typedef std::multimap ArchivedFileLocationMap; // Archived file name to archive data +typedef std::map ArchivedDirectoryInfoMap; // Archived directory name to archived directory info +typedef std::map ArchivedFileInfoMap; // Archived file name to archived file info +typedef std::map ArchiveFileMap; // Archive file name to archive data +typedef std::multimap ArchivedFileLocationMap; // Archived file name to archive data class ArchivedDirectoryInfo { public: - AsciiString m_path; // The full path to this directory - AsciiString m_directoryName; // The current directory - ArchivedDirectoryInfoMap m_directories; // Contained leaf directories - ArchivedFileLocationMap m_files; // Contained files + AsciiString m_path; // The full path to this directory + AsciiString m_directoryName; // The current directory + ArchivedDirectoryInfoMap m_directories; // Contained leaf directories + ArchivedFileLocationMap m_files; // Contained files }; class DetailedArchivedDirectoryInfo { public: - AsciiString m_directoryName; - DetailedArchivedDirectoryInfoMap m_directories; - ArchivedFileInfoMap m_files; + AsciiString m_directoryName; + DetailedArchivedDirectoryInfoMap m_directories; + ArchivedFileInfoMap m_files; }; class ArchivedFileInfo @@ -113,13 +112,12 @@ class ArchivedFileInfo UnsignedInt m_size; ArchivedFileInfo() - : m_offset(0) - , m_size(0) + : m_offset(0) + , m_size(0) { } }; - class ArchiveFileSystem : public SubsystemInterface { public: @@ -132,19 +130,19 @@ class ArchiveFileSystem : public SubsystemInterface virtual void postProcessLoad() = 0; // ArchiveFile operations - virtual ArchiveFile* openArchiveFile( const Char *filename ) = 0; ///< Create new or return existing Archive file from file name - virtual void closeArchiveFile( const Char *filename ) = 0; ///< Close the one specified big file. - virtual void closeAllArchiveFiles() = 0; ///< Close all Archive files currently open + virtual ArchiveFile* openArchiveFile(const Char* filename) = 0; ///< Create new or return existing Archive file from file name + virtual void closeArchiveFile(const Char* filename) = 0; ///< Close the one specified big file. + virtual void closeAllArchiveFiles() = 0; ///< Close all Archive files currently open // File operations - virtual File* openFile( const Char *filename, Int access = 0, FileInstance instance = 0); ///< Search Archive files for specified file name and open it if found - virtual void closeAllFiles() = 0; ///< Close all files associated with Archive files - virtual Bool doesFileExist(const Char *filename, FileInstance instance = 0) const; ///< return true if that file exists in an archive file somewhere. + virtual File* openFile(const Char* filename, Int access = 0, FileInstance instance = 0); ///< Search Archive files for specified file name and open it if found + virtual void closeAllFiles() = 0; ///< Close all files associated with Archive files + virtual Bool doesFileExist(const Char* filename, FileInstance instance = 0) const; ///< return true if that file exists in an archive file somewhere. - void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. Scans each Archive file. - Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance = 0) const; ///< see FileSystem.h + void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. Scans each Archive file. + Bool getFileInfo(const AsciiString& filename, FileInfo* fileInfo, FileInstance instance = 0) const; ///< see FileSystem.h - virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE) = 0; + virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE) = 0; // Unprotected this for copy-protection routines ArchiveFile* getArchiveFile(const AsciiString& filename, FileInstance instance = 0) const; @@ -156,7 +154,9 @@ class ArchiveFileSystem : public SubsystemInterface protected: struct ArchivedDirectoryInfoResult { - ArchivedDirectoryInfoResult() : dirInfo(nullptr) {} + ArchivedDirectoryInfoResult() + : dirInfo(nullptr) + {} Bool valid() const { return dirInfo != nullptr; } ArchivedDirectoryInfo* dirInfo; @@ -165,14 +165,13 @@ class ArchiveFileSystem : public SubsystemInterface ArchivedDirectoryInfoResult getArchivedDirectoryInfo(const Char* directory); - virtual void loadIntoDirectoryTree(ArchiveFile *archiveFile, Bool overwrite = FALSE); ///< load the archive file's header information and apply it to the global archive directory tree. + virtual void loadIntoDirectoryTree(ArchiveFile* archiveFile, 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; }; - -extern ArchiveFileSystem *TheArchiveFileSystem; +extern ArchiveFileSystem* TheArchiveFileSystem; //---------------------------------------------------------------------------- // Inlining diff --git a/Core/GameEngine/Include/Common/AsciiString.h b/Core/GameEngine/Include/Common/AsciiString.h index f2cb2246021..c32af622e0c 100644 --- a/Core/GameEngine/Include/Common/AsciiString.h +++ b/Core/GameEngine/Include/Common/AsciiString.h @@ -54,190 +54,187 @@ class UnicodeString; // ----------------------------------------------------- /** - AsciiString is the fundamental single-byte string type used in the Generals - code base, and should be preferred over all other string constructions - (e.g., array of char, STL string<>, WWVegas StringClass, etc.) + AsciiString is the fundamental single-byte string type used in the Generals + code base, and should be preferred over all other string constructions + (e.g., array of char, STL string<>, WWVegas StringClass, etc.) - Of course, other string setups may be used when necessary or appropriate! + Of course, other string setups may be used when necessary or appropriate! - AsciiString is modeled after the MFC CString class, with some minor - syntactic differences to keep in line with our coding conventions. + AsciiString is modeled after the MFC CString class, with some minor + syntactic differences to keep in line with our coding conventions. - Basically, AsciiString allows you to treat a string as an intrinsic - type, rather analogous to 'int' -- when passed by value, a new string - is created, and modifying the new string doesn't modify the original. - This is done fairly efficiently, so that no new memory allocation is done - unless the string is actually modified. + Basically, AsciiString allows you to treat a string as an intrinsic + type, rather analogous to 'int' -- when passed by value, a new string + is created, and modifying the new string doesn't modify the original. + This is done fairly efficiently, so that no new memory allocation is done + unless the string is actually modified. - Naturally, AsciiString handles all memory issues, so there's no need - to do anything to free memory... just allow the AsciiString's - destructor to run. + Naturally, AsciiString handles all memory issues, so there's no need + to do anything to free memory... just allow the AsciiString's + destructor to run. - AsciiStrings are suitable for use as automatic, member, or static variables. + AsciiStrings are suitable for use as automatic, member, or static variables. */ class AsciiString { private: - // Note, this is a Plain Old Data Structure... don't // add a ctor/dtor, 'cuz they won't ever be called. struct AsciiStringData { #if defined(RTS_DEBUG) - const char* m_debugptr; // just makes it easier to read in the debugger + const char* m_debugptr; // just makes it easier to read in the debugger #endif - unsigned short m_refCount; // reference count - unsigned short m_numCharsAllocated; // length of data allocated + unsigned short m_refCount; // reference count + unsigned short m_numCharsAllocated; // length of data allocated // char m_stringdata[]; - char* peek() { return (char*)(this+1); } + char* peek() { return (char*)(this + 1); } }; - #ifdef RTS_DEBUG +#ifdef RTS_DEBUG void validate() const; - #else - void validate() const { } - #endif +#else + void validate() const {} +#endif protected: - AsciiStringData* m_data; // pointer to ref counted string data + AsciiStringData* m_data; // pointer to ref counted string data char* peek() const; void releaseBuffer(); void ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveData, const char* strToCpy, const char* strToCat); public: - typedef Char value_type; typedef value_type* pointer; typedef const value_type* const_pointer; enum { - MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va - MAX_LEN = 32767 ///< max total len of any AsciiString, in chars + MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va + MAX_LEN = 32767 ///< max total len of any AsciiString, in chars }; - /** - This is a convenient global used to indicate the empty - string, so we don't need to construct temporaries - for such a common thing. + This is a convenient global used to indicate the empty + string, so we don't need to construct temporaries + for such a common thing. */ static const AsciiString TheEmptyString; /** - Default constructor -- construct a new, empty AsciiString. + Default constructor -- construct a new, empty AsciiString. */ AsciiString(); /** - Copy constructor -- make this AsciiString identical to the - other AsciiString. (This is actually quite efficient, because - they will simply share the same string and increment the - refcount.) + Copy constructor -- make this AsciiString identical to the + other AsciiString. (This is actually quite efficient, because + they will simply share the same string and increment the + refcount.) */ AsciiString(const AsciiString& stringSrc); /** - Constructor -- from a literal string. Constructs an AsciiString - with the given string. Note that a copy of the string is made; - the input ptr is not saved. - Note that this is no longer explicit, as the conversion is almost - always wanted, anyhow. + Constructor -- from a literal string. Constructs an AsciiString + with the given string. Note that a copy of the string is made; + the input ptr is not saved. + Note that this is no longer explicit, as the conversion is almost + always wanted, anyhow. */ AsciiString(const char* s); /** - Constructs an AsciiString with the given string and length. - The length must not be larger than the actual string length. + Constructs an AsciiString with the given string and length. + The length must not be larger than the actual string length. */ AsciiString(const char* s, int len); /** - Destructor. Not too exciting... clean up the works and such. + Destructor. Not too exciting... clean up the works and such. */ ~AsciiString(); /** - Return the length, in characters, of the string up to the first zero or null terminator. + Return the length, in characters, of the string up to the first zero or null terminator. */ int getLength() const; /** - Return the number of bytes used by the string up to the first zero or null terminator. + Return the number of bytes used by the string up to the first zero or null terminator. */ int getByteCount() const; /** - Return true iff the length of the string is zero. Equivalent - to (getLength() == 0) but slightly more efficient. + Return true iff the length of the string is zero. Equivalent + to (getLength() == 0) but slightly more efficient. */ Bool isEmpty() const; /** - Make the string empty. Equivalent to (str = "") but slightly more efficient. + Make the string empty. Equivalent to (str = "") but slightly more efficient. */ void clear(); /** - Return the character and the given (zero-based) index into the string. - No range checking is done (except in debug mode). + Return the character and the given (zero-based) index into the string. + No range checking is done (except in debug mode). */ char getCharAt(int index) const; /** - Return a pointer to the (null-terminated) string. Note that this is - a const pointer: do NOT change this! It is imperative that it be - impossible (or at least, really difficuly) for someone to change our - private data, since it might be shared amongst other AsciiStrings. + Return a pointer to the (null-terminated) string. Note that this is + a const pointer: do NOT change this! It is imperative that it be + impossible (or at least, really difficuly) for someone to change our + private data, since it might be shared amongst other AsciiStrings. */ const char* str() const; /** - Makes sure there is room for a string of len+1 characters, and - returns a pointer to the string buffer. This ensures that the - string buffer is NOT shared. This is intended for the file reader, - that is reading new strings in from a file. jba. + Makes sure there is room for a string of len+1 characters, and + returns a pointer to the string buffer. This ensures that the + string buffer is NOT shared. This is intended for the file reader, + that is reading new strings in from a file. jba. */ char* getBufferForRead(Int len); /** - Replace the contents of self with the given string. - (This is actually quite efficient, because - they will simply share the same string and increment the - refcount.) + Replace the contents of self with the given string. + (This is actually quite efficient, because + they will simply share the same string and increment the + refcount.) */ void set(const AsciiString& stringSrc); /** - Replace the contents of self with the given string. - Note that a copy of the string is made; the input ptr is not saved. + Replace the contents of self with the given string. + Note that a copy of the string is made; the input ptr is not saved. */ void set(const char* s); /** - Replace the contents of self with the given string and length. - Note that a copy of the string is made; the input ptr is not saved. - The length must not be larger than the actual string length. + Replace the contents of self with the given string and length. + Note that a copy of the string is made; the input ptr is not saved. + The length must not be larger than the actual string length. */ void set(const char* s, int len); /** - replace contents of self with the given string. Note the - nomenclature is translate rather than set; this is because - not all single-byte strings translate one-for-one into - UnicodeStrings, so some data manipulation may be necessary, - and the resulting strings may not be equivalent. + replace contents of self with the given string. Note the + nomenclature is translate rather than set; this is because + not all single-byte strings translate one-for-one into + UnicodeStrings, so some data manipulation may be necessary, + and the resulting strings may not be equivalent. */ void translate(const UnicodeString& stringSrc); /** - Concatenate the given string onto self. + Concatenate the given string onto self. */ void concat(const AsciiString& stringSrc); /** - Concatenate the given string onto self. + Concatenate the given string onto self. */ void concat(const char* s); /** - Concatenate the given character onto self. + Concatenate the given character onto self. */ void concat(const char c); @@ -262,123 +259,122 @@ class AsciiString void toLower(); /** - Remove the final character in the string. If the string is empty, - do nothing. (This is a rather dorky method, but used a lot in - text editing, thus its presence here.) + Remove the final character in the string. If the string is empty, + do nothing. (This is a rather dorky method, but used a lot in + text editing, thus its presence here.) */ void removeLastChar(); /** - Remove the final charCount characters in the string. If the string is empty, - do nothing. + Remove the final charCount characters in the string. If the string is empty, + do nothing. */ void truncateBy(const Int charCount); /** - Truncate the string to a length of maxLength characters, not including null termination, - by removing from the end. If the string is empty or shorter than maxLength, do nothing. + Truncate the string to a length of maxLength characters, not including null termination, + by removing from the end. If the string is empty or shorter than maxLength, do nothing. */ void truncateTo(const Int maxLength); /** - Analogous to sprintf() -- this formats a string according to the - given sprintf-style format string (and the variable argument list) - and stores the result in self. + Analogous to sprintf() -- this formats a string according to the + given sprintf-style format string (and the variable argument list) + and stores the result in self. */ void format(AsciiString format, ...); void format(const char* format, ...); /** - Identical to format(), but takes a va_list rather than - a variable argument list. (i.e., analogous to vsprintf.) + Identical to format(), but takes a va_list rather than + a variable argument list. (i.e., analogous to vsprintf.) */ void format_va(const AsciiString& format, va_list args); void format_va(const char* format, va_list args); /** - Conceptually identical to strcmp(). + Conceptually identical to strcmp(). */ int compare(const AsciiString& stringSrc) const; /** - Conceptually identical to strcmp(). + Conceptually identical to strcmp(). */ int compare(const char* s) const; /** - Conceptually identical to _stricmp(). + Conceptually identical to _stricmp(). */ int compareNoCase(const AsciiString& stringSrc) const; /** - Conceptually identical to _stricmp(). + Conceptually identical to _stricmp(). */ int compareNoCase(const char* s) const; /** - Conceptually identical to strchr(). + Conceptually identical to strchr(). */ const char* find(char c) const; /** - Conceptually identical to strrchr(). + Conceptually identical to strrchr(). */ const char* reverseFind(char c) const; /** - return true iff self starts with the given string. + return true iff self starts with the given string. */ Bool startsWith(const char* p) const; Bool startsWith(const AsciiString& stringSrc) const { return startsWith(stringSrc.str()); } /** - return true iff self starts with the given string. (case insensitive) + return true iff self starts with the given string. (case insensitive) */ Bool startsWithNoCase(const char* p) const; Bool startsWithNoCase(const AsciiString& stringSrc) const { return startsWithNoCase(stringSrc.str()); } /** - return true iff self ends with the given string. + return true iff self ends with the given string. */ Bool endsWith(const char* p) const; Bool endsWith(const AsciiString& stringSrc) const { return endsWith(stringSrc.str()); } /** - return true iff self ends with the given string. (case insensitive) + return true iff self ends with the given string. (case insensitive) */ Bool endsWithNoCase(const char* p) const; Bool endsWithNoCase(const AsciiString& stringSrc) const { return endsWithNoCase(stringSrc.str()); } /** - conceptually similar to strtok(): + conceptually similar to strtok(): - extract the next seps-delimited token from the front - of 'this' and copy it into 'token', returning true if a nonempty - token was found. (note that this modifies 'this' as well, stripping - the token off!) + extract the next seps-delimited token from the front + of 'this' and copy it into 'token', returning true if a nonempty + token was found. (note that this modifies 'this' as well, stripping + the token off!) */ Bool nextToken(AsciiString* token, const char* seps = nullptr); /** - return true iff the string is "NONE" (case-insensitive). - Hey, hokey, but we use it a ton. + return true iff the string is "NONE" (case-insensitive). + Hey, hokey, but we use it a ton. */ Bool isNone() const; Bool isNotEmpty() const { return !isEmpty(); } Bool isNotNone() const { return !isNone(); } -// -// You might think it would be a good idea to overload the * operator -// to allow for an implicit conversion to an char*. This is -// (in theory) a good idea, but in practice, there's lots of code -// that assumes it should check text fields for null, which -// is meaningless for us, since we never return a null ptr. -// -// operator const char*() const { return str(); } -// + // + // You might think it would be a good idea to overload the * operator + // to allow for an implicit conversion to an char*. This is + // (in theory) a good idea, but in practice, there's lots of code + // that assumes it should check text fields for null, which + // is meaningless for us, since we never return a null ptr. + // + // operator const char*() const { return str(); } + // - AsciiString& operator=(const AsciiString& stringSrc); ///< the same as set() - AsciiString& operator=(const char* s); ///< the same as set() + AsciiString& operator=(const AsciiString& stringSrc); ///< the same as set() + AsciiString& operator=(const char* s); ///< the same as set() void debugIgnoreLeaks(); - }; // ----------------------------------------------------- @@ -390,7 +386,8 @@ inline char* AsciiString::peek() const } // ----------------------------------------------------- -inline AsciiString::AsciiString() : m_data(0) +inline AsciiString::AsciiString() + : m_data(0) { validate(); } @@ -478,7 +475,7 @@ inline void AsciiString::concat(const char c) { validate(); /// this can probably be made more efficient, if necessary - char tmp[2] = { c, 0 }; + char tmp[2] = {c, 0}; concat(tmp); validate(); } diff --git a/Core/GameEngine/Include/Common/AudioAffect.h b/Core/GameEngine/Include/Common/AudioAffect.h index f58cb9e18b2..a36913b6c2b 100644 --- a/Core/GameEngine/Include/Common/AudioAffect.h +++ b/Core/GameEngine/Include/Common/AudioAffect.h @@ -32,7 +32,8 @@ // if it is set by the options panel, use the system setting parameter. Otherwise, this will be // appended to whatever the current system volume is. -enum AudioAffect CPP_11(: Int) +enum AudioAffect +CPP_11( : Int) { AudioAffect_Music = 0x01, AudioAffect_Sound = 0x02, diff --git a/Core/GameEngine/Include/Common/AudioEventInfo.h b/Core/GameEngine/Include/Common/AudioEventInfo.h index 741ffeacc90..b8a8e633e38 100644 --- a/Core/GameEngine/Include/Common/AudioEventInfo.h +++ b/Core/GameEngine/Include/Common/AudioEventInfo.h @@ -39,7 +39,8 @@ struct FieldParse; // USEFUL DECLARATIONS //////////////////////////////////////////////////////////////////////////// -enum AudioType CPP_11(: Int) +enum AudioType +CPP_11( : Int) { AT_Music, AT_Streaming, diff --git a/Core/GameEngine/Include/Common/AudioEventRTS.h b/Core/GameEngine/Include/Common/AudioEventRTS.h index f38f1e5417a..40317c8a0d5 100644 --- a/Core/GameEngine/Include/Common/AudioEventRTS.h +++ b/Core/GameEngine/Include/Common/AudioEventRTS.h @@ -36,7 +36,8 @@ // forward declarations /////////////////////////////////////////////////////////////////////////// struct AudioEventInfo; -enum OwnerType CPP_11(: Int) +enum OwnerType +CPP_11( : Int) { OT_Positional, OT_Drawable, @@ -45,8 +46,8 @@ enum OwnerType CPP_11(: Int) OT_INVALID }; -enum PortionToPlay CPP_11(: Int) -{ +enum PortionToPlay +CPP_11(: Int){ PP_Attack, PP_Sound, PP_Decay, diff --git a/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h b/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h index 102f9ed860b..ec812029ee0 100644 --- a/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h +++ b/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h @@ -28,7 +28,8 @@ #pragma once -enum AudioHandleSpecialValues CPP_11(: Int) +enum AudioHandleSpecialValues +CPP_11( : Int) { AHSV_Error = 0x00, AHSV_NoSound, diff --git a/Core/GameEngine/Include/Common/AudioRandomValue.h b/Core/GameEngine/Include/Common/AudioRandomValue.h index 4efc9c26b3d..50687bc6212 100644 --- a/Core/GameEngine/Include/Common/AudioRandomValue.h +++ b/Core/GameEngine/Include/Common/AudioRandomValue.h @@ -32,11 +32,11 @@ #include "Lib/BaseType.h" // do NOT use these functions directly, rather use the macros below -extern Int GetGameAudioRandomValue( int lo, int hi, const char *file, int line ); -extern Real GetGameAudioRandomValueReal( Real lo, Real hi, const char *file, int line ); +extern Int GetGameAudioRandomValue(int lo, int hi, const char* file, int line); +extern Real GetGameAudioRandomValueReal(Real lo, Real hi, const char* file, int line); // use these macros to access the random value functions -#define GameAudioRandomValue( lo, hi ) GetGameAudioRandomValue( lo, hi, __FILE__, __LINE__ ) -#define GameAudioRandomValueReal( lo, hi ) GetGameAudioRandomValueReal( lo, hi, __FILE__, __LINE__ ) +#define GameAudioRandomValue(lo, hi) GetGameAudioRandomValue(lo, hi, __FILE__, __LINE__) +#define GameAudioRandomValueReal(lo, hi) GetGameAudioRandomValueReal(lo, hi, __FILE__, __LINE__) //-------------------------------------------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/AudioRequest.h b/Core/GameEngine/Include/Common/AudioRequest.h index a0321fdb481..d7a0eca91dc 100644 --- a/Core/GameEngine/Include/Common/AudioRequest.h +++ b/Core/GameEngine/Include/Common/AudioRequest.h @@ -33,7 +33,8 @@ class AudioEventRTS; -enum RequestType CPP_11(: Int) +enum RequestType +CPP_11( : Int) { AR_Play, AR_Pause, diff --git a/Core/GameEngine/Include/Common/AudioSettings.h b/Core/GameEngine/Include/Common/AudioSettings.h index f7f99628890..95bcaec8e17 100644 --- a/Core/GameEngine/Include/Common/AudioSettings.h +++ b/Core/GameEngine/Include/Common/AudioSettings.h @@ -30,17 +30,20 @@ #include "Common/AsciiString.h" -enum { MAX_HW_PROVIDERS = 4 }; +enum +{ + MAX_HW_PROVIDERS = 4 +}; struct AudioSettings { AudioSettings() - : m_use3DSoundRangeVolumeFade(true) // Enabled by default because it prevents audio cut off at the max range of 3D sounds - , m_3DSoundRangeVolumeFadeExponent(4.0f) // Exponent of 4 gives a nice balance between loud sounds and graceful fade + : m_use3DSoundRangeVolumeFade(true) // Enabled by default because it prevents audio cut off at the max range of 3D sounds + , m_3DSoundRangeVolumeFadeExponent(4.0f) // Exponent of 4 gives a nice balance between loud sounds and graceful fade #if RTS_GENERALS - , m_defaultMoneyTransactionVolume(1.0f) + , m_defaultMoneyTransactionVolume(1.0f) #elif RTS_ZEROHOUR - , m_defaultMoneyTransactionVolume(0.0f) // Uses zero volume by default because originally the money sounds did not work in Zero Hour + , m_defaultMoneyTransactionVolume(0.0f) // Uses zero volume by default because originally the money sounds did not work in Zero Hour #endif { } @@ -58,7 +61,7 @@ struct AudioSettings Int m_sampleCount2D; Int m_sampleCount3D; Int m_streamCount; - Bool m_use3DSoundRangeVolumeFade; // TheSuperHackers @feature Enables 3D sound range volume fade as originally intended + Bool m_use3DSoundRangeVolumeFade; // TheSuperHackers @feature Enables 3D sound range volume fade as originally intended Real m_3DSoundRangeVolumeFadeExponent; // TheSuperHackers @feature Sets 3D sound range volume fade exponent for non-linear fade. // The higher the exponent, the sharper the decline at the max range. Int m_globalMinRange; @@ -67,12 +70,12 @@ struct AudioSettings Int m_fadeAudioFrames; UnsignedInt m_maxCacheSize; - Real m_minVolume; // At volumes less than this, the sample will be culled. + Real m_minVolume; // At volumes less than this, the sample will be culled. AsciiString m_preferred3DProvider[MAX_HW_PROVIDERS + 1]; - //Defaults actually don't ever get changed! - Real m_relative2DVolume; //2D volume compared to 3D + // Defaults actually don't ever get changed! + Real m_relative2DVolume; // 2D volume compared to 3D Real m_defaultSoundVolume; Real m_default3DSoundVolume; Real m_defaultSpeechVolume; @@ -81,25 +84,25 @@ struct AudioSettings UnsignedInt m_defaultSpeakerType2D; UnsignedInt m_defaultSpeakerType3D; - //If you want to change a value, store it somewhere else (like here) + // If you want to change a value, store it somewhere else (like here) Real m_preferredSoundVolume; Real m_preferred3DSoundVolume; Real m_preferredSpeechVolume; Real m_preferredMusicVolume; Real m_preferredMoneyTransactionVolume; // TheSuperHackers @feature Modifies the volume of money deposit and withdraw sounds - //The desired altitude of the microphone to improve panning relative to terrain. + // The desired altitude of the microphone to improve panning relative to terrain. Real m_microphoneDesiredHeightAboveTerrain; - //When tracing a line between the ground look-at-point and the camera, we want - //to ensure a maximum percentage, so the microphone never goes behind the camera. + // When tracing a line between the ground look-at-point and the camera, we want + // to ensure a maximum percentage, so the microphone never goes behind the camera. Real m_microphoneMaxPercentageBetweenGroundAndCamera; - //Handles changing sound volume whenever the camera is close to the microphone. - Real m_zoomMinDistance; //If we're closer than the minimum distance, then apply the full bonus no matter how close. - Real m_zoomMaxDistance; //The maximum distance from microphone we need to be before benefiting from any bonus. + // Handles changing sound volume whenever the camera is close to the microphone. + Real m_zoomMinDistance; // If we're closer than the minimum distance, then apply the full bonus no matter how close. + Real m_zoomMaxDistance; // The maximum distance from microphone we need to be before benefiting from any bonus. - //NOTE: The higher this value is, the lower normal sounds will be! If you specify a sound volume value of 25%, then sounds will play - //between 75% and 100%, not 100% to 125%! - Real m_zoomSoundVolumePercentageAmount; //The amount of sound volume dedicated to zooming. + // NOTE: The higher this value is, the lower normal sounds will be! If you specify a sound volume value of 25%, then sounds will play + // between 75% and 100%, not 100% to 125%! + Real m_zoomSoundVolumePercentageAmount; // The amount of sound volume dedicated to zooming. }; diff --git a/Core/GameEngine/Include/Common/CRCDebug.h b/Core/GameEngine/Include/Common/CRCDebug.h index 5fee31b43d3..e66c9d53a17 100644 --- a/Core/GameEngine/Include/Common/CRCDebug.h +++ b/Core/GameEngine/Include/Common/CRCDebug.h @@ -38,13 +38,13 @@ #ifdef DEBUG_CRC -#include "Common/AsciiString.h" -#include "GameLogic/GameLogic.h" -#include "Lib/BaseType.h" -#include "WWMath/vector3.h" -#include "WWMath/matrix3d.h" + #include "Common/AsciiString.h" + #include "GameLogic/GameLogic.h" + #include "Lib/BaseType.h" + #include "WWMath/vector3.h" + #include "WWMath/matrix3d.h" - #define AS_INT(x) (*(Int *)(&x)) + #define AS_INT(x) (*(Int*)(&x)) #define DUMPVEL DUMPCOORD3DNAMED(&m_vel, "m_vel") #define DUMPACCEL DUMPCOORD3DNAMED(&m_accel, "m_accel") #define DUMPVECTOR3(x) DUMPVECTOR3NAMED(x, #x) @@ -56,70 +56,85 @@ #define DUMPREAL(x) DUMPREALNAMED(x, #x) #define DUMPREALNAMED(x, y) dumpReal(x, y, __FILE__, __LINE__) - extern Int TheCRCFirstFrameToLog; - extern UnsignedInt TheCRCLastFrameToLog; +extern Int TheCRCFirstFrameToLog; +extern UnsignedInt TheCRCLastFrameToLog; - void dumpVector3(const Vector3 *v, AsciiString name, AsciiString fname, Int line); - void dumpCoord3D(const Coord3D *c, AsciiString name, AsciiString fname, Int line); - void dumpMatrix3D(const Matrix3D *m, AsciiString name, AsciiString fname, Int line); - void dumpReal(Real r, AsciiString name, AsciiString fname, Int line); +void dumpVector3(const Vector3* v, AsciiString name, AsciiString fname, Int line); +void dumpCoord3D(const Coord3D* c, AsciiString name, AsciiString fname, Int line); +void dumpMatrix3D(const Matrix3D* m, AsciiString name, AsciiString fname, Int line); +void dumpReal(Real r, AsciiString name, AsciiString fname, Int line); - void outputCRCDebugLines(); - void CRCDebugStartNewGame(); - void outputCRCDumpLines(); +void outputCRCDebugLines(); +void CRCDebugStartNewGame(); +void outputCRCDumpLines(); - void addCRCDebugLine(const char *fmt, ...); - void addCRCDebugLineNoCounter(const char *fmt, ...); - void addCRCDumpLine(const char *fmt, ...); - void addCRCGenLine(const char *fmt, ...); +void addCRCDebugLine(const char* fmt, ...); +void addCRCDebugLineNoCounter(const char* fmt, ...); +void addCRCDumpLine(const char* fmt, ...); +void addCRCGenLine(const char* fmt, ...); #define CRCDEBUG_LOG(x) addCRCDebugLine x #define CRCDUMP_LOG(x) addCRCDumpLine x #define CRCGEN_LOG(x) addCRCGenLine x - class CRCVerification - { - public: - CRCVerification(); - ~CRCVerification(); - protected: - UnsignedInt m_startCRC; - }; +class CRCVerification +{ +public: + CRCVerification(); + ~CRCVerification(); + +protected: + UnsignedInt m_startCRC; +}; #define VERIFY_CRC CRCVerification crcVerification; - extern Int lastCRCDebugFrame; - extern Int lastCRCDebugIndex; +extern Int lastCRCDebugFrame; +extern Int lastCRCDebugIndex; - extern Bool g_verifyClientCRC; - extern Bool g_clientDeepCRC; +extern Bool g_verifyClientCRC; +extern Bool g_clientDeepCRC; - extern Bool g_crcModuleDataFromClient; - extern Bool g_crcModuleDataFromLogic; +extern Bool g_crcModuleDataFromClient; +extern Bool g_crcModuleDataFromLogic; - extern Bool g_keepCRCSaves; - extern Bool g_saveDebugCRCPerFrame; - extern AsciiString g_saveDebugCRCPerFrameDir; +extern Bool g_keepCRCSaves; +extern Bool g_saveDebugCRCPerFrame; +extern AsciiString g_saveDebugCRCPerFrameDir; - extern Bool g_logObjectCRCs; +extern Bool g_logObjectCRCs; #else // DEBUG_CRC - #define DUMPVEL {} - #define DUMPACCEL {} - #define DUMPVECTOR3(x) {} - #define DUMPVECTOR3NAMED(x, y) {} - #define DUMPCOORD3D(x) {} - #define DUMPCOORD3DNAMED(x, y) {} - #define DUMPMATRIX3D(x) {} - #define DUMPMATRIX3DNAMED(x, y) {} - - #define DUMPREAL(x) {} - #define DUMPREALNAMED(x, y) {} - - #define CRCDEBUG_LOG(x) {} - #define CRCDUMP_LOG(x) {} - #define CRCGEN_LOG(x) {} - - #define VERIFY_CRC {} + #define DUMPVEL \ + {} + #define DUMPACCEL \ + {} + #define DUMPVECTOR3(x) \ + {} + #define DUMPVECTOR3NAMED(x, y) \ + {} + #define DUMPCOORD3D(x) \ + {} + #define DUMPCOORD3DNAMED(x, y) \ + {} + #define DUMPMATRIX3D(x) \ + {} + #define DUMPMATRIX3DNAMED(x, y) \ + {} + + #define DUMPREAL(x) \ + {} + #define DUMPREALNAMED(x, y) \ + {} + + #define CRCDEBUG_LOG(x) \ + {} + #define CRCDUMP_LOG(x) \ + {} + #define CRCGEN_LOG(x) \ + {} + + #define VERIFY_CRC \ + {} #endif diff --git a/Core/GameEngine/Include/Common/Debug.h b/Core/GameEngine/Include/Common/Debug.h index 7288a753cda..0b614aa9e25 100644 --- a/Core/GameEngine/Include/Common/Debug.h +++ b/Core/GameEngine/Include/Common/Debug.h @@ -49,7 +49,7 @@ class AsciiString; #define NO_RELEASE_DEBUG_LOGGING -#ifdef RELEASE_DEBUG_LOGGING ///< Creates a DebugLogFile.txt (No I or D) with all the debug log goodness. Good for startup problems. +#ifdef RELEASE_DEBUG_LOGGING ///< Creates a DebugLogFile.txt (No I or D) with all the debug log goodness. Good for startup problems. #define ALLOW_DEBUG_UTILS 1 #define DEBUG_LOGGING 1 #define DISABLE_DEBUG_CRASHING 1 @@ -59,14 +59,14 @@ class AsciiString; // These are stolen from the WW3D Debug file. REALLY useful. :-) #define STRING_IT(a) #a -#define TOKEN_IT(a) STRING_IT(,##a) -#define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a) +#define TOKEN_IT(a) STRING_IT(, ##a) +#define MESSAGE(a) message(__FILE__ "(" TOKEN_IT(__LINE__) ") : " a) // by default, turn on ALLOW_DEBUG_UTILS if RTS_DEBUG is turned on. #if defined(RTS_DEBUG) && !defined(ALLOW_DEBUG_UTILS) && !defined(DISABLE_ALLOW_DEBUG_UTILS) #define ALLOW_DEBUG_UTILS 1 #elif defined(DEBUG_LOGGING) || defined(DEBUG_CRASHING) || defined(DEBUG_STACKTRACE) || defined(DEBUG_PROFILE) - // TheSuperHackers @tweak also turn on when any of the above options is already set. + // TheSuperHackers @tweak also turn on when any of the above options is already set. #define ALLOW_DEBUG_UTILS 1 #endif @@ -94,7 +94,6 @@ class AsciiString; #define DEBUG_EXTERN_C extern #endif - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -108,102 +107,152 @@ class AsciiString; // EXTERNALS ////////////////////////////////////////////////////////////////// /// @todo: the standard line-to-string trick isn't working correctly in vc6; figure out why -#define DEBUG_STRING_IT(b) #b -#define DEBUG_TOKEN_IT(a) DEBUG_STRING_IT(a) -#define DEBUG_FILENLINE __FILE__ ":" DEBUG_TOKEN_IT(__LINE__) +#define DEBUG_STRING_IT(b) #b +#define DEBUG_TOKEN_IT(a) DEBUG_STRING_IT(a) +#define DEBUG_FILENLINE __FILE__ ":" DEBUG_TOKEN_IT(__LINE__) #ifdef ALLOW_DEBUG_UTILS - enum - { - DEBUG_FLAG_LOG_TO_FILE = 0x01, - DEBUG_FLAG_LOG_TO_CONSOLE = 0x02, - DEBUG_FLAG_PREPEND_TIME = 0x04, - DEBUG_FLAGS_DEFAULT = (DEBUG_FLAG_LOG_TO_FILE | DEBUG_FLAG_LOG_TO_CONSOLE), - }; +enum +{ + DEBUG_FLAG_LOG_TO_FILE = 0x01, + DEBUG_FLAG_LOG_TO_CONSOLE = 0x02, + DEBUG_FLAG_PREPEND_TIME = 0x04, + DEBUG_FLAGS_DEFAULT = (DEBUG_FLAG_LOG_TO_FILE | DEBUG_FLAG_LOG_TO_CONSOLE), +}; - DEBUG_EXTERN_C void DebugInit(int flags); - DEBUG_EXTERN_C void DebugShutdown(); +DEBUG_EXTERN_C void DebugInit(int flags); +DEBUG_EXTERN_C void DebugShutdown(); - DEBUG_EXTERN_C int DebugGetFlags(); - DEBUG_EXTERN_C void DebugSetFlags(int flags); +DEBUG_EXTERN_C int DebugGetFlags(); +DEBUG_EXTERN_C void DebugSetFlags(int flags); - #define DEBUG_INIT(f) do { DebugInit(f); } while (0) - #define DEBUG_SHUTDOWN() do { DebugShutdown(); } while (0) + #define DEBUG_INIT(f) \ + do \ + { \ + DebugInit(f); \ + } while (0) + #define DEBUG_SHUTDOWN() \ + do \ + { \ + DebugShutdown(); \ + } while (0) #else - #define DEBUG_INIT(f) ((void)0) - #define DEBUG_SHUTDOWN() ((void)0) + #define DEBUG_INIT(f) ((void)0) + #define DEBUG_SHUTDOWN() ((void)0) #endif #ifdef DEBUG_LOGGING - DEBUG_EXTERN_C void DebugLog(const char *format, ...); - DEBUG_EXTERN_C void DebugLogRaw(const char *format, ...); - DEBUG_EXTERN_C const char* DebugGetLogFileName(); - DEBUG_EXTERN_C const char* DebugGetLogFileNamePrev(); - - // This defines a bitmask of log types that we care about, to allow some flexability - // in what gets logged. This should be extended to asserts, too, but the assert box - // is waiting to be rewritten. -MDC 3/19/2003 - extern unsigned int DebugLevelMask; - enum - { - DEBUG_LEVEL_NET = 0, // in-game network - DEBUG_LEVEL_MAX - }; - extern const char *TheDebugLevels[DEBUG_LEVEL_MAX]; - - #define DEBUG_LOG(m) do { { DebugLog m ; } } while (0) // Log message with trailing new line character (LF) - #define DEBUG_LOG_RAW(m) do { { DebugLogRaw m ; } } while (0) // Log message without trailing new line character (LF) - #define DEBUG_LOG_LEVEL(l, m) do { if (l & DebugLevelMask) { DebugLog m ; } } while (0) - #define DEBUG_LOG_LEVEL_RAW(l, m) do { if (l & DebugLevelMask) { DebugLogRaw m ; } } while (0) - #define DEBUG_ASSERTLOG(c, m) do { { if (!(c)) DebugLog m ; } } while (0) +DEBUG_EXTERN_C void DebugLog(const char* format, ...); +DEBUG_EXTERN_C void DebugLogRaw(const char* format, ...); +DEBUG_EXTERN_C const char* DebugGetLogFileName(); +DEBUG_EXTERN_C const char* DebugGetLogFileNamePrev(); + +// This defines a bitmask of log types that we care about, to allow some flexability +// in what gets logged. This should be extended to asserts, too, but the assert box +// is waiting to be rewritten. -MDC 3/19/2003 +extern unsigned int DebugLevelMask; +enum +{ + DEBUG_LEVEL_NET = 0, // in-game network + DEBUG_LEVEL_MAX +}; +extern const char* TheDebugLevels[DEBUG_LEVEL_MAX]; + + #define DEBUG_LOG(m) \ + do \ + { \ + { \ + DebugLog m; \ + } \ + } while (0) // Log message with trailing new line character (LF) + #define DEBUG_LOG_RAW(m) \ + do \ + { \ + { \ + DebugLogRaw m; \ + } \ + } while (0) // Log message without trailing new line character (LF) + #define DEBUG_LOG_LEVEL(l, m) \ + do \ + { \ + if (l & DebugLevelMask) \ + { \ + DebugLog m; \ + } \ + } while (0) + #define DEBUG_LOG_LEVEL_RAW(l, m) \ + do \ + { \ + if (l & DebugLevelMask) \ + { \ + DebugLogRaw m; \ + } \ + } while (0) + #define DEBUG_ASSERTLOG(c, m) \ + do \ + { \ + { \ + if (!(c)) \ + DebugLog m; \ + } \ + } while (0) #else - #define DEBUG_LOG(m) ((void)0) - #define DEBUG_LOG_RAW(m) ((void)0) - #define DEBUG_LOG_LEVEL(l, m) ((void)0) - #define DEBUG_LOG_LEVEL_RAW(l, m) ((void)0) - #define DEBUG_ASSERTLOG(c, m) ((void)0) + #define DEBUG_LOG(m) ((void)0) + #define DEBUG_LOG_RAW(m) ((void)0) + #define DEBUG_LOG_LEVEL(l, m) ((void)0) + #define DEBUG_LOG_LEVEL_RAW(l, m) ((void)0) + #define DEBUG_ASSERTLOG(c, m) ((void)0) #endif #ifdef DEBUG_CRASHING - DEBUG_EXTERN_C void DebugCrash(const char *format, ...); - - /* - Yeah, it's a sleazy global, since we can't reasonably add - any args to DebugCrash due to the varargs nature of it. - We'll just let it slide in this case... - */ - DEBUG_EXTERN_C char* TheCurrentIgnoreCrashPtr; +DEBUG_EXTERN_C void DebugCrash(const char* format, ...); - #define DEBUG_CRASH(m) \ - do { \ - { \ - static char ignoreCrash = 0; \ - if (!ignoreCrash) { \ +/* + Yeah, it's a sleazy global, since we can't reasonably add + any args to DebugCrash due to the varargs nature of it. + We'll just let it slide in this case... +*/ +DEBUG_EXTERN_C char* TheCurrentIgnoreCrashPtr; + + #define DEBUG_CRASH(m) \ + do \ + { \ + { \ + static char ignoreCrash = 0; \ + if (!ignoreCrash) \ + { \ TheCurrentIgnoreCrashPtr = &ignoreCrash; \ - DebugCrash m ; \ - TheCurrentIgnoreCrashPtr = nullptr; \ - } \ - } \ + DebugCrash m; \ + TheCurrentIgnoreCrashPtr = nullptr; \ + } \ + } \ } while (0) - #define DEBUG_ASSERTCRASH(c, m) do { { if (!(c)) DEBUG_CRASH(m); } } while (0) + #define DEBUG_ASSERTCRASH(c, m) \ + do \ + { \ + { \ + if (!(c)) \ + DEBUG_CRASH(m); \ + } \ + } while (0) - //Note: RELEASE_CRASH(m) is now always defined. - //#define RELEASE_CRASH(m) DEBUG_CRASH((m)) +// Note: RELEASE_CRASH(m) is now always defined. +// #define RELEASE_CRASH(m) DEBUG_CRASH((m)) #else - #define DEBUG_CRASH(m) ((void)0) - #define DEBUG_ASSERTCRASH(c, m) ((void)0) + #define DEBUG_CRASH(m) ((void)0) + #define DEBUG_ASSERTCRASH(c, m) ((void)0) // DEBUG_EXTERN_C void ReleaseCrash(const char* reason); @@ -214,9 +263,16 @@ class AsciiString; DEBUG_EXTERN_C void ReleaseCrash(const char* reason); DEBUG_EXTERN_C void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m); -#define RELEASE_CRASH(m) do { ReleaseCrash(m); } while (0) -#define RELEASE_CRASHLOCALIZED(p, m) do { ReleaseCrashLocalized(p, m); } while (0) - +#define RELEASE_CRASH(m) \ + do \ + { \ + ReleaseCrash(m); \ + } while (0) +#define RELEASE_CRASHLOCALIZED(p, m) \ + do \ + { \ + ReleaseCrashLocalized(p, m); \ + } while (0) #ifdef DEBUG_PROFILE @@ -227,32 +283,30 @@ class SimpleProfiler __int64 m_startThisSession; __int64 m_totalThisSession; __int64 m_totalAllSessions; - int m_numSessions; + int m_numSessions; public: - SimpleProfiler(); void start(); void stop(); - void stopAndLog(const char *msg, int howOftenToLog, int howOftenToResetAvg); - double getTime(); // of most recent session, in milliseconds + void stopAndLog(const char* msg, int howOftenToLog, int howOftenToResetAvg); + double getTime(); // of most recent session, in milliseconds int getNumSessions(); - double getTotalTime(); // total over all sessions, in milliseconds - double getAverageTime(); // averaged over all sessions, in milliseconds - + double getTotalTime(); // total over all sessions, in milliseconds + double getAverageTime(); // averaged over all sessions, in milliseconds }; -#define BEGIN_PROFILE(uniqueid) \ - static SimpleProfiler prof_##uniqueid; \ - prof_##uniqueid.start(); + #define BEGIN_PROFILE(uniqueid) \ + static SimpleProfiler prof_##uniqueid; \ + prof_##uniqueid.start(); -#define END_PROFILE(uniqueid, msg, howoftentolog, howoftentoreset) \ - prof_##uniqueid.stopAndLog(msg, howoftentolog, howoftentoreset); + #define END_PROFILE(uniqueid, msg, howoftentolog, howoftentoreset) \ + prof_##uniqueid.stopAndLog(msg, howoftentolog, howoftentoreset); #else -#define BEGIN_PROFILE(uniqueid) -#define END_PROFILE(uniqueid, msg, howoftentolog, howoftentoreset) + #define BEGIN_PROFILE(uniqueid) + #define END_PROFILE(uniqueid, msg, howoftentolog, howoftentoreset) #endif diff --git a/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h b/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h index 038ba2bbfff..c5bfe1c7b9a 100644 --- a/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h +++ b/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h @@ -39,51 +39,52 @@ class Xfer; *****************************************************************************/ class DynamicAudioEventInfo : public AudioEventInfo { - // NOTE: This implementation would be a lot cleaner & safer if AudioEventInfo was better - // written. Ideally, AudioEventInfo would be a class, not a struct, and provide only - // "get" functions, not "set" functions except for the INI parsing. Then we could - // force people to go through our override...() functions. - - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( DynamicAudioEventInfo, "DynamicAudioEventInfo" ) - - public: - DynamicAudioEventInfo(); - explicit DynamicAudioEventInfo( const AudioEventInfo & baseInfo ); - - // DynamicAudioEventInfo interfacing function overrides - virtual Bool isLevelSpecific() const override; - virtual DynamicAudioEventInfo * getDynamicAudioEventInfo() override; - virtual const DynamicAudioEventInfo * getDynamicAudioEventInfo() const override; - - // Change various fields from their default (INI) values - void overrideAudioName( const AsciiString & newName ); - void overrideLoopFlag( Bool newLoopFlag ); - void overrideLoopCount( Int newLoopCount ); - void overrideVolume( Real newVolume ); - void overrideMinVolume( Real newMinVolume ); - void overrideMinRange( Real newMinRange ); - void overrideMaxRange( Real newMaxRange ); - void overridePriority( AudioPriority newPriority ); - - // Query fields to see if they have been changed from their INI values - Bool wasAudioNameOverriden() const; - Bool wasLoopFlagOverriden() const; - Bool wasLoopCountOverriden() const; - Bool wasVolumeOverriden() const; - Bool wasMinVolumeOverriden() const; - Bool wasMinRangeOverriden() const; - Bool wasMaxRangeOverriden() const; - Bool wasPriorityOverriden() const; - - // Get the name of the audio event which this was based off of - const AsciiString & getOriginalName() const; - - // Transfer all overridden fields except the customized name - void xferNoName( Xfer * xfer ); - - private: - // List of fields we can override - enum OverriddenFields CPP_11(: Int) + // NOTE: This implementation would be a lot cleaner & safer if AudioEventInfo was better + // written. Ideally, AudioEventInfo would be a class, not a struct, and provide only + // "get" functions, not "set" functions except for the INI parsing. Then we could + // force people to go through our override...() functions. + + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DynamicAudioEventInfo, "DynamicAudioEventInfo") + +public: + DynamicAudioEventInfo(); + explicit DynamicAudioEventInfo(const AudioEventInfo& baseInfo); + + // DynamicAudioEventInfo interfacing function overrides + virtual Bool isLevelSpecific() const override; + virtual DynamicAudioEventInfo* getDynamicAudioEventInfo() override; + virtual const DynamicAudioEventInfo* getDynamicAudioEventInfo() const override; + + // Change various fields from their default (INI) values + void overrideAudioName(const AsciiString& newName); + void overrideLoopFlag(Bool newLoopFlag); + void overrideLoopCount(Int newLoopCount); + void overrideVolume(Real newVolume); + void overrideMinVolume(Real newMinVolume); + void overrideMinRange(Real newMinRange); + void overrideMaxRange(Real newMaxRange); + void overridePriority(AudioPriority newPriority); + + // Query fields to see if they have been changed from their INI values + Bool wasAudioNameOverriden() const; + Bool wasLoopFlagOverriden() const; + Bool wasLoopCountOverriden() const; + Bool wasVolumeOverriden() const; + Bool wasMinVolumeOverriden() const; + Bool wasMinRangeOverriden() const; + Bool wasMaxRangeOverriden() const; + Bool wasPriorityOverriden() const; + + // Get the name of the audio event which this was based off of + const AsciiString& getOriginalName() const; + + // Transfer all overridden fields except the customized name + void xferNoName(Xfer* xfer); + +private: + // List of fields we can override + enum OverriddenFields + CPP_11( : Int) { OVERRIDE_NAME = 0, OVERRIDE_LOOP_FLAG, diff --git a/Core/GameEngine/Include/Common/Errors.h b/Core/GameEngine/Include/Common/Errors.h index 4b8316b0876..adc324b1854 100644 --- a/Core/GameEngine/Include/Common/Errors.h +++ b/Core/GameEngine/Include/Common/Errors.h @@ -46,12 +46,13 @@ #pragma once /** - An ErrorCode is the repository for failure modes. In almost all situations, - these values will be THROWN, not returned as error codes. Feel free - to add to this list as necessary; however, there should generally be very - few codes needed. + An ErrorCode is the repository for failure modes. In almost all situations, + these values will be THROWN, not returned as error codes. Feel free + to add to this list as necessary; however, there should generally be very + few codes needed. */ -enum ErrorCode CPP_11(: UnsignedInt) +enum ErrorCode +CPP_11( : UnsignedInt) { ERROR_BASE = 0xdead0001, // a nice, distinctive value diff --git a/Core/GameEngine/Include/Common/FileSystem.h b/Core/GameEngine/Include/Common/FileSystem.h index 02a932f1313..c8c74f6c89d 100644 --- a/Core/GameEngine/Include/Common/FileSystem.h +++ b/Core/GameEngine/Include/Common/FileSystem.h @@ -70,44 +70,44 @@ typedef UnsignedByte FileInstance; //---------------------------------------------------------------------------- // Type Defines //---------------------------------------------------------------------------- -//#define W3D_DIR_PATH "../FinalArt/W3D/" ///< .w3d files live here -//#define TGA_DIR_PATH "../FinalArt/Textures/" ///< .tga texture files live here -//#define TERRAIN_TGA_DIR_PATH "../FinalArt/Terrain/" ///< terrain .tga texture files live here -#define W3D_DIR_PATH "Art/W3D/" ///< .w3d files live here -#define TGA_DIR_PATH "Art/Textures/" ///< .tga texture files live here -#define TERRAIN_TGA_DIR_PATH "Art/Terrain/" ///< terrain .tga texture files live here -#define MAP_PREVIEW_DIR_PATH "%sMapPreviews/" ///< We need a common place we can copy the map previews to at runtime. -#define USER_W3D_DIR_PATH "%sW3D/" ///< .w3d files live here -#define USER_TGA_DIR_PATH "%sTextures/" ///< User .tga texture files live here +// #define W3D_DIR_PATH "../FinalArt/W3D/" ///< .w3d files live here +// #define TGA_DIR_PATH "../FinalArt/Textures/" ///< .tga texture files live here +// #define TERRAIN_TGA_DIR_PATH "../FinalArt/Terrain/" ///< terrain .tga texture files live here +#define W3D_DIR_PATH "Art/W3D/" ///< .w3d files live here +#define TGA_DIR_PATH "Art/Textures/" ///< .tga texture files live here +#define TERRAIN_TGA_DIR_PATH "Art/Terrain/" ///< terrain .tga texture files live here +#define MAP_PREVIEW_DIR_PATH "%sMapPreviews/" ///< We need a common place we can copy the map previews to at runtime. +#define USER_W3D_DIR_PATH "%sW3D/" ///< .w3d files live here +#define USER_TGA_DIR_PATH "%sTextures/" ///< User .tga texture files live here // the following defines are only to be used while maintaining legacy compatibility // with old files until they are completely gone and in the regular art set #ifdef MAINTAIN_LEGACY_FILES -#define LEGACY_W3D_DIR_PATH "../LegacyArt/W3D/" ///< .w3d files live here -#define LEGACY_TGA_DIR_PATH "../LegacyArt/Textures/" ///< .tga texture files live here -#endif // MAINTAIN_LEGACY_FILES + #define LEGACY_W3D_DIR_PATH "../LegacyArt/W3D/" ///< .w3d files live here + #define LEGACY_TGA_DIR_PATH "../LegacyArt/Textures/" ///< .tga texture files live here +#endif // MAINTAIN_LEGACY_FILES // LOAD_TEST_ASSETS automatically loads w3d assets from the TEST_W3D_DIR_PATH // without having to add an INI entry. #if defined(RTS_DEBUG) -#define LOAD_TEST_ASSETS 1 + #define LOAD_TEST_ASSETS 1 #endif #ifdef LOAD_TEST_ASSETS - #define ROAD_DIRECTORY "../TestArt/TestRoad/" - #define TEST_STRING "***TESTING" - // the following directories will be used to look for test art + #define ROAD_DIRECTORY "../TestArt/TestRoad/" + #define TEST_STRING "***TESTING" + // the following directories will be used to look for test art #define LOOK_FOR_TEST_ART - #define TEST_W3D_DIR_PATH "../TestArt/" ///< .w3d files live here - #define TEST_TGA_DIR_PATH "../TestArt/" ///< .tga texture files live here + #define TEST_W3D_DIR_PATH "../TestArt/" ///< .w3d files live here + #define TEST_TGA_DIR_PATH "../TestArt/" ///< .tga texture files live here #endif #ifndef ENABLE_FILESYSTEM_LOGGING -#define ENABLE_FILESYSTEM_LOGGING (0) + #define ENABLE_FILESYSTEM_LOGGING (0) #endif - -struct FileInfo { +struct FileInfo +{ Int64 size() const { return (Int64)sizeHigh << 32 | sizeLow; } Int64 timestamp() const { return (Int64)timestampHigh << 32 | timestampLow; } @@ -122,23 +122,23 @@ struct FileInfo { // FileSystem //=============================== /** - * FileSystem is an interface class for creating specific FileSystem objects. - * - * A FileSystem object's implementation decides what derivative of File object needs to be - * created when FileSystem::Open() gets called. - */ + * FileSystem is an interface class for creating specific FileSystem objects. + * + * A FileSystem object's implementation decides what derivative of File object needs to be + * created when FileSystem::Open() gets called. + */ // TheSuperHackers @feature xezon 23/08/2025 Implements file instance access. // Can be used to access different versions of files in different archives under the same name. // Instance 0 refers to the top file that shadows all other files under the same name. -// +// // TheSuperHackers @bugfix xezon 26/10/2025 Adds a mutex to the file exist map to try prevent // application hangs during level load after the file exist map was corrupted because of writes // from multiple threads. //=============================== class FileSystem : public SubsystemInterface { - FileSystem(const FileSystem&); - FileSystem& operator=(const FileSystem&); + FileSystem(const FileSystem&); + FileSystem& operator=(const FileSystem&); public: FileSystem(); @@ -148,37 +148,39 @@ class FileSystem : public SubsystemInterface virtual void reset() override; virtual void update() override; - File* openFile( const Char *filename, Int access = File::NONE, size_t bufferSize = File::BUFFERSIZE, FileInstance instance = 0 ); ///< opens a File interface to the specified file - Bool doesFileExist(const Char *filename, FileInstance instance = 0) const; ///< returns TRUE if the file exists. filename should have no directory. - void getFileListInDirectory(const AsciiString& directory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. - Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance = 0) const; ///< fills in the FileInfo struct for the file given. returns TRUE if successful. + File* openFile(const Char* filename, Int access = File::NONE, size_t bufferSize = File::BUFFERSIZE, FileInstance instance = 0); ///< opens a File interface to the specified file + Bool doesFileExist(const Char* filename, FileInstance instance = 0) const; ///< returns TRUE if the file exists. filename should have no directory. + void getFileListInDirectory(const AsciiString& directory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. + Bool getFileInfo(const AsciiString& filename, FileInfo* fileInfo, FileInstance instance = 0) const; ///< fills in the FileInfo struct for the file given. returns TRUE if successful. Bool createDirectory(AsciiString directory); ///< create a directory of the given name. - static AsciiString normalizePath(const AsciiString& path); ///< normalizes a file path. The path can refer to a directory. File path must be absolute, but does not need to exist. Returns an empty string on failure. - static Bool isPathInDirectory(const AsciiString& testPath, const AsciiString& basePath); ///< determines if a file path is within a base path. Both paths must be absolute, but do not need to exist. + static AsciiString normalizePath(const AsciiString& path); ///< normalizes a file path. The path can refer to a directory. File path must be absolute, but does not need to exist. Returns an empty string on failure. + static Bool isPathInDirectory(const AsciiString& testPath, const AsciiString& basePath); ///< determines if a file path is within a base path. Both paths must be absolute, but do not need to exist. protected: #if ENABLE_FILESYSTEM_EXISTENCE_CACHE struct FileExistData { - FileExistData() : instanceExists(0), instanceDoesNotExist(~FileInstance(0)) {} + FileExistData() + : instanceExists(0) + , instanceDoesNotExist(~FileInstance(0)) + {} FileInstance instanceExists; FileInstance instanceDoesNotExist; }; typedef std::hash_map< - rts::string_key, FileExistData, - rts::string_key_hash, - rts::string_key_equal > FileExistMap; + rts::string_key, FileExistData, + rts::string_key_hash, + rts::string_key_equal > + FileExistMap; mutable FileExistMap m_fileExist; mutable FastCriticalSectionClass m_fileExistMutex; #endif }; -extern FileSystem* TheFileSystem; - - +extern FileSystem* TheFileSystem; //---------------------------------------------------------------------------- // Inlining diff --git a/Core/GameEngine/Include/Common/FramePacer.h b/Core/GameEngine/Include/Common/FramePacer.h index 5bba1a704e8..53a8ee22e93 100644 --- a/Core/GameEngine/Include/Common/FramePacer.h +++ b/Core/GameEngine/Include/Common/FramePacer.h @@ -20,16 +20,15 @@ #include "Common/FrameRateLimit.h" - // TheSuperHackers @todo Use unsigned integers for fps values // TheSuperHackers @todo Consolidate the GlobalData::m_useFpsLimit and FramePacer::m_enableFpsLimit // TheSuperHackers @todo Implement new fast forward in here class FramePacer { public: - typedef UnsignedInt LogicTimeQueryFlags; - enum LogicTimeQueryFlags_ CPP_11(: LogicTimeQueryFlags) + enum LogicTimeQueryFlags_ + CPP_11( : LogicTimeQueryFlags) { IgnoreFrozenTime = 1<<0, ///< Ignore frozen time for the query IgnoreHaltedGame = 1<<1, ///< Ignore halted game for the query diff --git a/Core/GameEngine/Include/Common/FrameRateLimit.h b/Core/GameEngine/Include/Common/FrameRateLimit.h index 5bb2b5fd3a7..132def6761c 100644 --- a/Core/GameEngine/Include/Common/FrameRateLimit.h +++ b/Core/GameEngine/Include/Common/FrameRateLimit.h @@ -20,7 +20,6 @@ #include "Common/GameCommon.h" - class FrameRateLimit { public: @@ -33,18 +32,17 @@ class FrameRateLimit Int64 m_start; }; - enum FpsValueChange { FpsValueChange_Increase, FpsValueChange_Decrease, }; - class RenderFpsPreset { public: - enum CPP_11(: UnsignedInt) + enum + CPP_11( : UnsignedInt) { UncappedFpsValue = 1000000, }; diff --git a/Core/GameEngine/Include/Common/GameAudio.h b/Core/GameEngine/Include/Common/GameAudio.h index dae9d7cd132..6dd34c6187e 100644 --- a/Core/GameEngine/Include/Common/GameAudio.h +++ b/Core/GameEngine/Include/Common/GameAudio.h @@ -46,7 +46,6 @@ #include "Common/STLTypedefs.h" #include "Common/SubsystemInterface.h" - // Forward Declarations class AsciiString; @@ -57,8 +56,8 @@ class MusicManager; class Object; class SoundManager; - -enum AudioAffect CPP_11(: Int); +enum AudioAffect +CPP_11( : Int); enum AudioType CPP_11(: Int); struct AudioEventInfo; diff --git a/Core/GameEngine/Include/Common/GameCommon.h b/Core/GameEngine/Include/Common/GameCommon.h index 62c6c3429f0..5f568a3f6e1 100644 --- a/Core/GameEngine/Include/Common/GameCommon.h +++ b/Core/GameEngine/Include/Common/GameCommon.h @@ -47,7 +47,7 @@ #pragma once -//#define _CAMPEA_DEMO +// #define _CAMPEA_DEMO // ---------------------------------------------------------------------------------------------- #include "Lib/BaseType.h" @@ -106,17 +106,17 @@ inline Real ConvertAngularVelocityInDegreesPerSecToRadsPerFrame(Real degPerSec) // ---------------------------------------------------------------------------------------------- enum { - MAX_PLAYER_COUNT = 16 ///< max number of Players. + MAX_PLAYER_COUNT = 16 ///< max number of Players. }; // ---------------------------------------------------------------------------------------------- /** - a bitmask that can uniquely represent each player. + a bitmask that can uniquely represent each player. */ #if MAX_PLAYER_COUNT <= 16 - typedef UnsignedShort PlayerMaskType; - const PlayerMaskType PLAYERMASK_ALL = 0xffff; - const PlayerMaskType PLAYERMASK_NONE = 0x0; +typedef UnsignedShort PlayerMaskType; +const PlayerMaskType PLAYERMASK_ALL = 0xffff; +const PlayerMaskType PLAYERMASK_NONE = 0x0; #else #error "this is the wrong size" #endif @@ -124,7 +124,7 @@ enum // ---------------------------------------------------------------------------------------------- enum { - MAX_GLOBAL_GENERAL_TYPES = 9, ///< number of playable General Types, not including the boss) + MAX_GLOBAL_GENERAL_TYPES = 9, ///< number of playable General Types, not including the boss) /// The start of the playable global generals playertemplates GLOBAL_GENERAL_BEGIN = 5, @@ -134,7 +134,8 @@ enum }; //------------------------------------------------------------------------------------------------- -enum GameDifficulty CPP_11(: Int) +enum GameDifficulty +CPP_11( : Int) { DIFFICULTY_EASY, DIFFICULTY_NORMAL, diff --git a/Core/GameEngine/Include/Common/GameDefines.h b/Core/GameEngine/Include/Common/GameDefines.h index 627e5c76eab..72a1e0c2b99 100644 --- a/Core/GameEngine/Include/Common/GameDefines.h +++ b/Core/GameEngine/Include/Common/GameDefines.h @@ -24,38 +24,38 @@ // Use RETAIL_COMPATIBLE_CRC and RETAIL_COMPATIBLE_XFER_SAVE to guard breaking changes. #ifndef PRESERVE_RETAIL_BEHAVIOR -#define PRESERVE_RETAIL_BEHAVIOR (1) // Retain behavior present in retail Generals 1.08 and Zero Hour 1.04 + #define PRESERVE_RETAIL_BEHAVIOR (1) // Retain behavior present in retail Generals 1.08 and Zero Hour 1.04 #endif #ifndef PRESERVE_RETAIL_SCRIPTED_CAMERA -#define PRESERVE_RETAIL_SCRIPTED_CAMERA (1) // Retain scripted camera behavior present in retail Generals 1.08 and Zero Hour 1.04 + #define PRESERVE_RETAIL_SCRIPTED_CAMERA (1) // Retain scripted camera behavior present in retail Generals 1.08 and Zero Hour 1.04 #endif #ifndef RETAIL_COMPATIBLE_CRC -#define RETAIL_COMPATIBLE_CRC (1) // Game is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04 + #define RETAIL_COMPATIBLE_CRC (1) // Game is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04 #endif #ifndef RETAIL_COMPATIBLE_XFER_SAVE -#define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04 + #define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04 #endif // This is here to easily toggle between the retail compatible with fixed pathfinding fallback and pure fixed pathfinding mode #ifndef RETAIL_COMPATIBLE_PATHFINDING -#define RETAIL_COMPATIBLE_PATHFINDING (1) + #define RETAIL_COMPATIBLE_PATHFINDING (1) #endif // This is here to easily toggle between the retail compatible pathfinding memory allocation and the new static allocated data mode #ifndef RETAIL_COMPATIBLE_PATHFINDING_ALLOCATION -#define RETAIL_COMPATIBLE_PATHFINDING_ALLOCATION (1) + #define RETAIL_COMPATIBLE_PATHFINDING_ALLOCATION (1) #endif #ifndef RETAIL_COMPATIBLE_CIRCLE_FILL_ALGORITHM -#define RETAIL_COMPATIBLE_CIRCLE_FILL_ALGORITHM (1) // Use the original circle fill algorithm, which is more efficient but less accurate + #define RETAIL_COMPATIBLE_CIRCLE_FILL_ALGORITHM (1) // Use the original circle fill algorithm, which is more efficient but less accurate #endif // Disable non retail fixes in the networking, such as putting more data per UDP packet #ifndef RETAIL_COMPATIBLE_NETWORKING -#define RETAIL_COMPATIBLE_NETWORKING (1) + #define RETAIL_COMPATIBLE_NETWORKING (1) #endif // This is essentially synonymous for RETAIL_COMPATIBLE_CRC. There is a lot wrong with AIGroup, such as use-after-free, double-free, leaks, @@ -63,60 +63,60 @@ // but put them behind this macro. #ifndef RETAIL_COMPATIBLE_AIGROUP -#define RETAIL_COMPATIBLE_AIGROUP (1) // AIGroup logic is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04 + #define RETAIL_COMPATIBLE_AIGROUP (1) // AIGroup logic is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04 #endif #ifndef ENABLE_GAMETEXT_SUBSTITUTES -#define ENABLE_GAMETEXT_SUBSTITUTES (1) // The code can provide substitute texts when labels and strings are missing in the STR or CSF translation file + #define ENABLE_GAMETEXT_SUBSTITUTES (1) // The code can provide substitute texts when labels and strings are missing in the STR or CSF translation file #endif // Previously the configurable shroud sat behind #if defined(RTS_DEBUG) // Enable the configurable shroud to properly draw the terrain in World Builder without RTS_DEBUG compiled in. // Disable the configurable shroud to make shroud hacking a bit less accessible in Release game builds. #ifndef ENABLE_CONFIGURABLE_SHROUD -#define ENABLE_CONFIGURABLE_SHROUD (1) // When enabled, the GlobalData contains a field to turn on/off the shroud, otherwise shroud is always enabled + #define ENABLE_CONFIGURABLE_SHROUD (1) // When enabled, the GlobalData contains a field to turn on/off the shroud, otherwise shroud is always enabled #endif // Enable buffered IO in File System. Was disabled in retail game. // Buffered IO generally is much faster than unbuffered for small reads and writes. #ifndef USE_BUFFERED_IO -#define USE_BUFFERED_IO (1) + #define USE_BUFFERED_IO (1) #endif // Enable cache for local file existence. Reduces amount of disk accesses for better performance, // but decreases file existence correctness and runtime stability, if a cached file is deleted on runtime. #ifndef ENABLE_FILESYSTEM_EXISTENCE_CACHE -#define ENABLE_FILESYSTEM_EXISTENCE_CACHE (1) + #define ENABLE_FILESYSTEM_EXISTENCE_CACHE (1) #endif // Enable prioritization of textures by size. This will improve the texture quality of 481 textures in Zero Hour // by using the larger resolution textures from Generals. Content wise these textures are identical. #ifndef PRIORITIZE_TEXTURES_BY_SIZE -#define PRIORITIZE_TEXTURES_BY_SIZE (1) + #define PRIORITIZE_TEXTURES_BY_SIZE (1) #endif // Enable obsolete code. This mainly refers to code that existed in Generals but was removed in GeneralsMD. // Disable and remove this when Generals and GeneralsMD are merged. #if RTS_GENERALS -#ifndef USE_OBSOLETE_GENERALS_CODE -#define USE_OBSOLETE_GENERALS_CODE (1) -#endif + #ifndef USE_OBSOLETE_GENERALS_CODE + #define USE_OBSOLETE_GENERALS_CODE (1) + #endif #endif // Overwrite window settings until wnd data files are adapted or fixed. #ifndef ENABLE_GUI_HACKS -#define ENABLE_GUI_HACKS (1) + #define ENABLE_GUI_HACKS (1) #endif // Tell our computer identity in the LAN lobby. Disable for privacy. // Was enabled in the retail game and exposed the computer login and host names. #ifdef RTS_DEBUG -#ifndef TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY -#define TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY (1) -#endif + #ifndef TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY + #define TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY (1) + #endif #endif -#define MIN_DISPLAY_BIT_DEPTH 16 -#define DEFAULT_DISPLAY_BIT_DEPTH 32 -#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for -#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for +#define MIN_DISPLAY_BIT_DEPTH 16 +#define DEFAULT_DISPLAY_BIT_DEPTH 32 +#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for +#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for diff --git a/Core/GameEngine/Include/Common/GameMemory.h b/Core/GameEngine/Include/Common/GameMemory.h index 0e901b9d4af..42cda7d12b8 100644 --- a/Core/GameEngine/Include/Common/GameMemory.h +++ b/Core/GameEngine/Include/Common/GameMemory.h @@ -54,7 +54,7 @@ #define MEMORYPOOL_DEBUG_CUSTOM_NEW #endif -//#if defined(RTS_DEBUG) && !defined(MEMORYPOOL_DEBUG) && !defined(DISABLE_MEMORYPOOL_DEBUG) +// #if defined(RTS_DEBUG) && !defined(MEMORYPOOL_DEBUG) && !defined(DISABLE_MEMORYPOOL_DEBUG) #if defined(RTS_DEBUG) && !defined(MEMORYPOOL_DEBUG) && !defined(DISABLE_MEMORYPOOL_DEBUG) #define MEMORYPOOL_DEBUG #endif @@ -77,12 +77,12 @@ #ifdef MEMORYPOOL_DEBUG - // by default, enable free-block-retention for checkpointing in debug mode + // by default, enable free-block-retention for checkpointing in debug mode #if !defined(DISABLE_MEMORYPOOL_CHECKPOINTING) || DISABLE_MEMORYPOOL_CHECKPOINTING == 0 #define MEMORYPOOL_CHECKPOINTING #endif - // by default, enable bounding walls in debug mode (unless we have specifically disabled them) + // by default, enable bounding walls in debug mode (unless we have specifically disabled them) #ifndef DISABLE_MEMORYPOOL_BOUNDINGWALL #define MEMORYPOOL_BOUNDINGWALL #endif @@ -91,88 +91,87 @@ #define MEMORYPOOL_STACKTRACE #endif - // flags for the memory-report options. - enum - { +// flags for the memory-report options. +enum +{ -#ifdef MEMORYPOOL_CHECKPOINTING - // ------------------------------------------------------ - // you usually won't use the _REPORT bits directly; see below for more convenient combinations. - - // you must set at least one of the 'allocate' bits. - _REPORT_CP_ALLOCATED_BEFORE = 0x0001, - _REPORT_CP_ALLOCATED_BETWEEN = 0x0002, - _REPORT_CP_ALLOCATED_DONTCARE = (_REPORT_CP_ALLOCATED_BEFORE|_REPORT_CP_ALLOCATED_BETWEEN), - - // you must set at least one of the 'freed' bits. - _REPORT_CP_FREED_BEFORE = 0x0010, - _REPORT_CP_FREED_BETWEEN = 0x0020, - _REPORT_CP_FREED_NEVER = 0x0040, // ie, still in existence - _REPORT_CP_FREED_DONTCARE = (_REPORT_CP_FREED_BEFORE|_REPORT_CP_FREED_BETWEEN|_REPORT_CP_FREED_NEVER), + #ifdef MEMORYPOOL_CHECKPOINTING + // ------------------------------------------------------ + // you usually won't use the _REPORT bits directly; see below for more convenient combinations. + + // you must set at least one of the 'allocate' bits. + _REPORT_CP_ALLOCATED_BEFORE = 0x0001, + _REPORT_CP_ALLOCATED_BETWEEN = 0x0002, + _REPORT_CP_ALLOCATED_DONTCARE = (_REPORT_CP_ALLOCATED_BEFORE | _REPORT_CP_ALLOCATED_BETWEEN), + + // you must set at least one of the 'freed' bits. + _REPORT_CP_FREED_BEFORE = 0x0010, + _REPORT_CP_FREED_BETWEEN = 0x0020, + _REPORT_CP_FREED_NEVER = 0x0040, // ie, still in existence + _REPORT_CP_FREED_DONTCARE = (_REPORT_CP_FREED_BEFORE | _REPORT_CP_FREED_BETWEEN | _REPORT_CP_FREED_NEVER), // ------------------------------------------------------ -#endif // MEMORYPOOL_CHECKPOINTING + #endif // MEMORYPOOL_CHECKPOINTING -#ifdef MEMORYPOOL_CHECKPOINTING - /** display the stacktrace for allocation location for all blocks found. - this bit may be mixed-n-matched with any other flag. - */ - REPORT_CP_STACKTRACE = 0x0100, -#endif + #ifdef MEMORYPOOL_CHECKPOINTING + /** display the stacktrace for allocation location for all blocks found. + this bit may be mixed-n-matched with any other flag. + */ + REPORT_CP_STACKTRACE = 0x0100, + #endif + + /** display stats for each pool, in addition to each block. + (this is useful for finding suitable allocation counts for the pools.) + this bit may be mixed-n-matched with any other flag. + */ + REPORT_POOLINFO = 0x0200, + + /** report on the overall memory situation (including all pools and dma's). + this bit may be mixed-n-matched with any other flag. + */ + REPORT_FACTORYINFO = 0x0400, + + /** report on pools that have overflowed their initial allocation. + this bit may be mixed-n-matched with any other flag. + */ + REPORT_POOL_OVERFLOW = 0x0800, + + /** simple-n-cheap leak checking */ + REPORT_SIMPLE_LEAKS = 0x1000, + + #ifdef MEMORYPOOL_CHECKPOINTING + /** report on blocks that were allocated between the checkpoints. + (don't care if they were freed or not.) + */ + REPORT_CP_ALLOCATES = (_REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_DONTCARE), + + /** report on blocks that were freed between the checkpoints. + (don't care when they were allocated.) + */ + REPORT_CP_FREES = (_REPORT_CP_ALLOCATED_DONTCARE | _REPORT_CP_FREED_BETWEEN), + + /** report on blocks that were allocated between the checkpoints, and still exist + (note that this reports *potential* leaks -- some such blocks may be desired) + */ + REPORT_CP_LEAKS = (_REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_NEVER), + + /** report on blocks that existed before checkpoint #1 and still exist now. + */ + REPORT_CP_LONGTERM = (_REPORT_CP_ALLOCATED_BEFORE | _REPORT_CP_FREED_NEVER), + + /** report on blocks that were allocated-and-freed between the checkpoints. + */ + REPORT_CP_TRANSIENT = (_REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_BETWEEN), + + /** report on all blocks that currently exist + */ + REPORT_CP_EXISTING = (_REPORT_CP_ALLOCATED_BEFORE | _REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_NEVER), - /** display stats for each pool, in addition to each block. - (this is useful for finding suitable allocation counts for the pools.) - this bit may be mixed-n-matched with any other flag. - */ - REPORT_POOLINFO = 0x0200, - - /** report on the overall memory situation (including all pools and dma's). - this bit may be mixed-n-matched with any other flag. - */ - REPORT_FACTORYINFO = 0x0400, - - /** report on pools that have overflowed their initial allocation. - this bit may be mixed-n-matched with any other flag. - */ - REPORT_POOL_OVERFLOW = 0x0800, - - /** simple-n-cheap leak checking */ - REPORT_SIMPLE_LEAKS = 0x1000, - -#ifdef MEMORYPOOL_CHECKPOINTING - /** report on blocks that were allocated between the checkpoints. - (don't care if they were freed or not.) - */ - REPORT_CP_ALLOCATES = (_REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_DONTCARE), - - /** report on blocks that were freed between the checkpoints. - (don't care when they were allocated.) - */ - REPORT_CP_FREES = (_REPORT_CP_ALLOCATED_DONTCARE | _REPORT_CP_FREED_BETWEEN), - - /** report on blocks that were allocated between the checkpoints, and still exist - (note that this reports *potential* leaks -- some such blocks may be desired) - */ - REPORT_CP_LEAKS = (_REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_NEVER), - - /** report on blocks that existed before checkpoint #1 and still exist now. - */ - REPORT_CP_LONGTERM = (_REPORT_CP_ALLOCATED_BEFORE | _REPORT_CP_FREED_NEVER), - - /** report on blocks that were allocated-and-freed between the checkpoints. - */ - REPORT_CP_TRANSIENT = (_REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_BETWEEN), - - /** report on all blocks that currently exist - */ - REPORT_CP_EXISTING = (_REPORT_CP_ALLOCATED_BEFORE | _REPORT_CP_ALLOCATED_BETWEEN | _REPORT_CP_FREED_NEVER), - - /** report on all blocks that have ever existed (!) (or at least, since the last call - to debugResetCheckpoints) - */ - REPORT_CP_ALL = (_REPORT_CP_ALLOCATED_DONTCARE | _REPORT_CP_FREED_DONTCARE) -#endif // MEMORYPOOL_CHECKPOINTING - - }; + /** report on all blocks that have ever existed (!) (or at least, since the last call + to debugResetCheckpoints) + */ + REPORT_CP_ALL = (_REPORT_CP_ALLOCATED_DONTCARE | _REPORT_CP_FREED_DONTCARE) + #endif // MEMORYPOOL_CHECKPOINTING +}; #endif // MEMORYPOOL_DEBUG @@ -180,40 +179,40 @@ // Useful for address sanitizer checks and other investigations. // Is included below the macros so that memory pool debug code can still be used. #ifdef DISABLE_GAMEMEMORY -#include "GameMemoryNull.h" + #include "GameMemoryNull.h" #else -#ifdef MEMORYPOOL_DEBUG + #ifdef MEMORYPOOL_DEBUG - #define DECLARE_LITERALSTRING_ARG1 const char * debugLiteralTagString - #define PASS_LITERALSTRING_ARG1 debugLiteralTagString - #define DECLARE_LITERALSTRING_ARG2 , const char * debugLiteralTagString - #define PASS_LITERALSTRING_ARG2 , debugLiteralTagString + #define DECLARE_LITERALSTRING_ARG1 const char* debugLiteralTagString + #define PASS_LITERALSTRING_ARG1 debugLiteralTagString + #define DECLARE_LITERALSTRING_ARG2 , const char* debugLiteralTagString + #define PASS_LITERALSTRING_ARG2 , debugLiteralTagString - #define MP_LOC_SUFFIX /*" [" DEBUG_FILENLINE "]"*/ + #define MP_LOC_SUFFIX /*" [" DEBUG_FILENLINE "]"*/ - #define allocateBlock(ARGLITERAL) allocateBlockImplementation(ARGLITERAL MP_LOC_SUFFIX) - #define allocateBlockDoNotZero(ARGLITERAL) allocateBlockDoNotZeroImplementation(ARGLITERAL MP_LOC_SUFFIX) - #define allocateBytes(ARGCOUNT,ARGLITERAL) allocateBytesImplementation(ARGCOUNT, ARGLITERAL MP_LOC_SUFFIX) - #define allocateBytesDoNotZero(ARGCOUNT,ARGLITERAL) allocateBytesDoNotZeroImplementation(ARGCOUNT, ARGLITERAL MP_LOC_SUFFIX) - #define newInstanceDesc(ARGCLASS,ARGLITERAL) new(ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED, ARGLITERAL MP_LOC_SUFFIX) ARGCLASS - #define newInstance(ARGCLASS) new(ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED, __FILE__) ARGCLASS + #define allocateBlock(ARGLITERAL) allocateBlockImplementation(ARGLITERAL MP_LOC_SUFFIX) + #define allocateBlockDoNotZero(ARGLITERAL) allocateBlockDoNotZeroImplementation(ARGLITERAL MP_LOC_SUFFIX) + #define allocateBytes(ARGCOUNT, ARGLITERAL) allocateBytesImplementation(ARGCOUNT, ARGLITERAL MP_LOC_SUFFIX) + #define allocateBytesDoNotZero(ARGCOUNT, ARGLITERAL) allocateBytesDoNotZeroImplementation(ARGCOUNT, ARGLITERAL MP_LOC_SUFFIX) + #define newInstanceDesc(ARGCLASS, ARGLITERAL) new (ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED, ARGLITERAL MP_LOC_SUFFIX) ARGCLASS + #define newInstance(ARGCLASS) new (ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED, __FILE__) ARGCLASS -#else + #else - #define DECLARE_LITERALSTRING_ARG1 - #define PASS_LITERALSTRING_ARG1 - #define DECLARE_LITERALSTRING_ARG2 - #define PASS_LITERALSTRING_ARG2 + #define DECLARE_LITERALSTRING_ARG1 + #define PASS_LITERALSTRING_ARG1 + #define DECLARE_LITERALSTRING_ARG2 + #define PASS_LITERALSTRING_ARG2 - #define allocateBlock(ARGLITERAL) allocateBlockImplementation() - #define allocateBlockDoNotZero(ARGLITERAL) allocateBlockDoNotZeroImplementation() - #define allocateBytes(ARGCOUNT,ARGLITERAL) allocateBytesImplementation(ARGCOUNT) - #define allocateBytesDoNotZero(ARGCOUNT,ARGLITERAL) allocateBytesDoNotZeroImplementation(ARGCOUNT) - #define newInstanceDesc(ARGCLASS,ARGLITERAL) new(ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED) ARGCLASS - #define newInstance(ARGCLASS) new(ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED) ARGCLASS + #define allocateBlock(ARGLITERAL) allocateBlockImplementation() + #define allocateBlockDoNotZero(ARGLITERAL) allocateBlockDoNotZeroImplementation() + #define allocateBytes(ARGCOUNT, ARGLITERAL) allocateBytesImplementation(ARGCOUNT) + #define allocateBytesDoNotZero(ARGCOUNT, ARGLITERAL) allocateBytesDoNotZeroImplementation(ARGCOUNT) + #define newInstanceDesc(ARGCLASS, ARGLITERAL) new (ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED) ARGCLASS + #define newInstance(ARGCLASS) new (ARGCLASS::ARGCLASS##_GLUE_NOT_IMPLEMENTED) ARGCLASS -#endif + #endif // FORWARD REFERENCES ///////////////////////////////////////////////////////// @@ -228,131 +227,126 @@ class BlockCheckpointInfo; // ---------------------------------------------------------------------------- /** - This class is purely a convenience used to pass optional arguments to initMemoryManager(), - and by extension, to createDynamicMemoryAllocator(). You can specify how many sub-pools you - want, what size each is, what the allocation counts are to be, etc. Most apps will - construct an array of these to pass to initMemoryManager() and never use it elsewhere. + This class is purely a convenience used to pass optional arguments to initMemoryManager(), + and by extension, to createDynamicMemoryAllocator(). You can specify how many sub-pools you + want, what size each is, what the allocation counts are to be, etc. Most apps will + construct an array of these to pass to initMemoryManager() and never use it elsewhere. */ struct PoolInitRec { - const char *poolName; ///< name of the pool; by convention, "dmaPool_XXX" where XXX is allocationSize - Int allocationSize; ///< size, in bytes, of the pool. - Int initialAllocationCount; ///< initial number of blocks to allocate. - Int overflowAllocationCount; ///< when the pool runs out of space, allocate more blocks in this increment + const char* poolName; ///< name of the pool; by convention, "dmaPool_XXX" where XXX is allocationSize + Int allocationSize; ///< size, in bytes, of the pool. + Int initialAllocationCount; ///< initial number of blocks to allocate. + Int overflowAllocationCount; ///< when the pool runs out of space, allocate more blocks in this increment }; enum { - MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS = 8 ///< The max number of subpools allowed in a DynamicMemoryAllocator + MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS = 8 ///< The max number of subpools allowed in a DynamicMemoryAllocator }; -#ifdef MEMORYPOOL_CHECKPOINTING + #ifdef MEMORYPOOL_CHECKPOINTING // ---------------------------------------------------------------------------- /** - This class exists purely for coding convenience, and should never be used by external code. - It simply allows MemoryPool and DynamicMemoryAllocator to share checkpoint-related - code in a seamless way. + This class exists purely for coding convenience, and should never be used by external code. + It simply allows MemoryPool and DynamicMemoryAllocator to share checkpoint-related + code in a seamless way. */ class Checkpointable { private: - BlockCheckpointInfo *m_firstCheckpointInfo; ///< head of the linked list of checkpoint infos for this pool/dma - Bool m_cpiEverFailed; ///< flag to detect if we ran out of memory accumulating checkpoint info. + BlockCheckpointInfo* m_firstCheckpointInfo; ///< head of the linked list of checkpoint infos for this pool/dma + Bool m_cpiEverFailed; ///< flag to detect if we ran out of memory accumulating checkpoint info. protected: - Checkpointable(); ~Checkpointable(); /// create a new checkpoint info and add it to the list. - BlockCheckpointInfo *debugAddCheckpointInfo( - const char *debugLiteralTagString, - Int allocCheckpoint, - Int blockSize - ); + BlockCheckpointInfo* debugAddCheckpointInfo( + const char* debugLiteralTagString, + Int allocCheckpoint, + Int blockSize); public: /// dump a checkpoint report to logfile - void debugCheckpointReport(Int flags, Int startCheckpoint, Int endCheckpoint, const char *poolName); + void debugCheckpointReport(Int flags, Int startCheckpoint, Int endCheckpoint, const char* poolName); /// reset all the checkpoints for this pool/dma void debugResetCheckpoints(); }; -#endif + #endif // ---------------------------------------------------------------------------- /** - A MemoryPool provides a way to efficiently allocate objects of the same (or similar) - size. We allocate large a large chunk of memory (a "blob") and subdivide it into - even-size chunks, doling these out as needed. If the first blob gets full, we allocate - additional blobs as necessary. A given pool can allocate blocks of only one size; - if you need a different size, you should use a different pool. + A MemoryPool provides a way to efficiently allocate objects of the same (or similar) + size. We allocate large a large chunk of memory (a "blob") and subdivide it into + even-size chunks, doling these out as needed. If the first blob gets full, we allocate + additional blobs as necessary. A given pool can allocate blocks of only one size; + if you need a different size, you should use a different pool. */ class MemoryPool -#ifdef MEMORYPOOL_CHECKPOINTING - : public Checkpointable -#endif + #ifdef MEMORYPOOL_CHECKPOINTING + : public Checkpointable + #endif { private: - - MemoryPoolFactory *m_factory; ///< the factory that created us - MemoryPool *m_nextPoolInFactory; ///< linked list node, managed by factory - const char *m_poolName; ///< name of this pool. (literal string; must not be freed) - Int m_allocationSize; ///< size of the blocks allocated by this pool, in bytes - Int m_initialAllocationCount; ///< number of blocks to be allocated in initial blob - Int m_overflowAllocationCount; ///< number of blocks to be allocated in any subsequent blob(s) - Int m_usedBlocksInPool; ///< total number of blocks in use in the pool. - Int m_totalBlocksInPool; ///< total number of blocks in all blobs of this pool (used or not). - Int m_peakUsedBlocksInPool; ///< high-water mark of m_usedBlocksInPool - MemoryPoolBlob *m_firstBlob; ///< head of linked list: first blob for this pool. - MemoryPoolBlob *m_lastBlob; ///< tail of linked list: last blob for this pool. (needed for efficiency) - MemoryPoolBlob *m_firstBlobWithFreeBlocks; ///< first blob in this pool that has at least one unallocated block. + MemoryPoolFactory* m_factory; ///< the factory that created us + MemoryPool* m_nextPoolInFactory; ///< linked list node, managed by factory + const char* m_poolName; ///< name of this pool. (literal string; must not be freed) + Int m_allocationSize; ///< size of the blocks allocated by this pool, in bytes + Int m_initialAllocationCount; ///< number of blocks to be allocated in initial blob + Int m_overflowAllocationCount; ///< number of blocks to be allocated in any subsequent blob(s) + Int m_usedBlocksInPool; ///< total number of blocks in use in the pool. + Int m_totalBlocksInPool; ///< total number of blocks in all blobs of this pool (used or not). + Int m_peakUsedBlocksInPool; ///< high-water mark of m_usedBlocksInPool + MemoryPoolBlob* m_firstBlob; ///< head of linked list: first blob for this pool. + MemoryPoolBlob* m_lastBlob; ///< tail of linked list: last blob for this pool. (needed for efficiency) + MemoryPoolBlob* m_firstBlobWithFreeBlocks; ///< first blob in this pool that has at least one unallocated block. private: /// create a new blob with the given number of blocks. MemoryPoolBlob* createBlob(Int allocationCount); /// destroy a blob. - Int freeBlob(MemoryPoolBlob *blob); + Int freeBlob(MemoryPoolBlob* blob); public: - // 'public' funcs that are really only for use by MemoryPoolFactory - MemoryPool *getNextPoolInList(); ///< return next pool in linked list - void addToList(MemoryPool **pHead); ///< add this pool to head of the linked list - void removeFromList(MemoryPool **pHead); ///< remove this pool from the linked list + MemoryPool* getNextPoolInList(); ///< return next pool in linked list + void addToList(MemoryPool** pHead); ///< add this pool to head of the linked list + void removeFromList(MemoryPool** pHead); ///< remove this pool from the linked list #ifdef MEMORYPOOL_DEBUG - static void debugPoolInfoReport( MemoryPool *pool, FILE *fp = nullptr ); ///< dump a report about this pool to the logfile - const char *debugGetBlockTagString(void *pBlock); ///< return the tagstring for the given block (assumed to belong to this pool) - void debugMemoryVerifyPool(); ///< perform internal consistency check on this pool. - Int debugPoolReportLeaks( const char* owner ); + static void debugPoolInfoReport(MemoryPool* pool, FILE* fp = nullptr); ///< dump a report about this pool to the logfile + const char* debugGetBlockTagString(void* pBlock); ///< return the tagstring for the given block (assumed to belong to this pool) + void debugMemoryVerifyPool(); ///< perform internal consistency check on this pool. + Int debugPoolReportLeaks(const char* owner); #endif #ifdef MEMORYPOOL_CHECKPOINTING - void debugResetCheckpoints(); ///< throw away all checkpoint information for this pool. + void debugResetCheckpoints(); ///< throw away all checkpoint information for this pool. #endif public: - MemoryPool(); /// initialize the given memory pool. - void init(MemoryPoolFactory *factory, const char *poolName, Int allocationSize, Int initialAllocationCount, Int overflowAllocationCount); + void init(MemoryPoolFactory* factory, const char* poolName, Int allocationSize, Int initialAllocationCount, Int overflowAllocationCount); ~MemoryPool(); /// allocate a block from this pool. (don't call directly; use allocateBlock() macro) - void *allocateBlockImplementation(DECLARE_LITERALSTRING_ARG1); + void* allocateBlockImplementation(DECLARE_LITERALSTRING_ARG1); /// same as allocateBlockImplementation, but memory returned is not zeroed - void *allocateBlockDoNotZeroImplementation(DECLARE_LITERALSTRING_ARG1); + void* allocateBlockDoNotZeroImplementation(DECLARE_LITERALSTRING_ARG1); /// free the block. it is OK to pass null. - void freeBlock(void *pMem); + void freeBlock(void* pMem); /// return the factory that created (and thus owns) this pool. - MemoryPoolFactory *getOwningFactory(); + MemoryPoolFactory* getOwningFactory(); /// return the name of this pool. the result is a literal string and must not be freed. - const char *getPoolName(); + const char* getPoolName(); /// return the block allocation size of this pool. Int getAllocationSize(); @@ -381,81 +375,79 @@ class MemoryPool void reset(); #ifdef MEMORYPOOL_DEBUG - /// return true iff this block was allocated by this pool. - Bool debugIsBlockInPool(void *pBlock); + /// return true iff this block was allocated by this pool. + Bool debugIsBlockInPool(void* pBlock); #endif }; // ---------------------------------------------------------------------------- /** - The DynamicMemoryAllocator class is used to handle unpredictably-sized - allocation requests. It basically allocates a number of (private) MemoryPools, - then routes request to the smallest-size pool that will satisfy the request. - (Requests too large for any of the pool are routed to the system memory allocator.) - You should normally use this in place of malloc/free or (global) new/delete. + The DynamicMemoryAllocator class is used to handle unpredictably-sized + allocation requests. It basically allocates a number of (private) MemoryPools, + then routes request to the smallest-size pool that will satisfy the request. + (Requests too large for any of the pool are routed to the system memory allocator.) + You should normally use this in place of malloc/free or (global) new/delete. */ class DynamicMemoryAllocator -#ifdef MEMORYPOOL_CHECKPOINTING - : public Checkpointable -#endif + #ifdef MEMORYPOOL_CHECKPOINTING + : public Checkpointable + #endif { private: - MemoryPoolFactory *m_factory; ///< the factory that created us - DynamicMemoryAllocator *m_nextDmaInFactory; ///< linked list node, managed by factory - Int m_numPools; ///< number of subpools (up to MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS) - Int m_usedBlocksInDma; ///< total number of blocks allocated, from subpools and "raw" - MemoryPool *m_pools[MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS]; ///< the subpools - MemoryPoolSingleBlock *m_rawBlocks; ///< linked list of "raw" blocks allocated directly from system + MemoryPoolFactory* m_factory; ///< the factory that created us + DynamicMemoryAllocator* m_nextDmaInFactory; ///< linked list node, managed by factory + Int m_numPools; ///< number of subpools (up to MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS) + Int m_usedBlocksInDma; ///< total number of blocks allocated, from subpools and "raw" + MemoryPool* m_pools[MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS]; ///< the subpools + MemoryPoolSingleBlock* m_rawBlocks; ///< linked list of "raw" blocks allocated directly from system /// return the best pool for the given allocSize, or null if none are suitable - MemoryPool *findPoolForSize(Int allocSize); + MemoryPool* findPoolForSize(Int allocSize); public: - // 'public' funcs that are really only for use by MemoryPoolFactory - DynamicMemoryAllocator *getNextDmaInList(); ///< return next dma in linked list - void addToList(DynamicMemoryAllocator **pHead); ///< add this dma to the list - void removeFromList(DynamicMemoryAllocator **pHead); ///< remove this dma from the list + DynamicMemoryAllocator* getNextDmaInList(); ///< return next dma in linked list + void addToList(DynamicMemoryAllocator** pHead); ///< add this dma to the list + void removeFromList(DynamicMemoryAllocator** pHead); ///< remove this dma from the list #ifdef MEMORYPOOL_DEBUG - Int debugCalcRawBlockBytes(Int *numBlocks); ///< calculate the number of bytes in "raw" (non-subpool) blocks - void debugMemoryVerifyDma(); ///< perform internal consistency check - const char *debugGetBlockTagString(void *pBlock); ///< return the tagstring for the given block (assumed to belong to this dma) - void debugDmaInfoReport( FILE *fp = nullptr ); ///< dump a report about this pool to the logfile - Int debugDmaReportLeaks(); + Int debugCalcRawBlockBytes(Int* numBlocks); ///< calculate the number of bytes in "raw" (non-subpool) blocks + void debugMemoryVerifyDma(); ///< perform internal consistency check + const char* debugGetBlockTagString(void* pBlock); ///< return the tagstring for the given block (assumed to belong to this dma) + void debugDmaInfoReport(FILE* fp = nullptr); ///< dump a report about this pool to the logfile + Int debugDmaReportLeaks(); #endif #ifdef MEMORYPOOL_CHECKPOINTING - void debugResetCheckpoints(); ///< toss all checkpoint information + void debugResetCheckpoints(); ///< toss all checkpoint information #endif public: - DynamicMemoryAllocator(); /// initialize the dma. pass 0/null for numSubPool/parms to get some reasonable default subpools. - void init(MemoryPoolFactory *factory, Int numSubPools, const PoolInitRec pParms[]); + void init(MemoryPoolFactory* factory, Int numSubPools, const PoolInitRec pParms[]); ~DynamicMemoryAllocator(); /// allocate bytes from this pool. (don't call directly; use allocateBytes() macro) - void *allocateBytesImplementation(Int numBytes DECLARE_LITERALSTRING_ARG2); + void* allocateBytesImplementation(Int numBytes DECLARE_LITERALSTRING_ARG2); /// like allocateBytesImplementation, but zeroes the memory before returning - void *allocateBytesDoNotZeroImplementation(Int numBytes DECLARE_LITERALSTRING_ARG2); + void* allocateBytesDoNotZeroImplementation(Int numBytes DECLARE_LITERALSTRING_ARG2); -#ifdef MEMORYPOOL_DEBUG + #ifdef MEMORYPOOL_DEBUG void debugIgnoreLeaksForThisBlock(void* pBlockPtr); -#endif + #endif /// free the bytes. (assumes allocated by this dma.) void freeBytes(void* pMem); /** - return the actual number of bytes that would be allocated - if you tried to allocate the given size. (It will generally be slightly - larger than you request.) This lets you use extra space if you're gonna get it anyway... - The idea is that you will call this before doing a memory allocation, to see if - you got any extra "bonus" space. + return the actual number of bytes that would be allocated + if you tried to allocate the given size. (It will generally be slightly + larger than you request.) This lets you use extra space if you're gonna get it anyway... + The idea is that you will call this before doing a memory allocation, to see if + you got any extra "bonus" space. */ Int getActualAllocationSize(Int numBytes); @@ -467,298 +459,311 @@ class DynamicMemoryAllocator #ifdef MEMORYPOOL_DEBUG - /// return true iff this block was allocated by this dma - Bool debugIsBlockInDma(void *pBlock); + /// return true iff this block was allocated by this dma + Bool debugIsBlockInDma(void* pBlock); - /// return true iff the pool is a subpool of this dma - Bool debugIsPoolInDma(MemoryPool *pool); + /// return true iff the pool is a subpool of this dma + Bool debugIsPoolInDma(MemoryPool* pool); - #endif // MEMORYPOOL_DEBUG + #endif // MEMORYPOOL_DEBUG }; -// ---------------------------------------------------------------------------- -#ifdef MEMORYPOOL_DEBUG -enum { MAX_SPECIAL_USED = 256 }; -#endif + // ---------------------------------------------------------------------------- + #ifdef MEMORYPOOL_DEBUG +enum +{ + MAX_SPECIAL_USED = 256 +}; + #endif // ---------------------------------------------------------------------------- /** - The class that manages all the MemoryPools and DynamicMemoryAllocators. - Usually you will create exactly one of these (TheMemoryPoolFactory) - and use it for everything. + The class that manages all the MemoryPools and DynamicMemoryAllocators. + Usually you will create exactly one of these (TheMemoryPoolFactory) + and use it for everything. */ class MemoryPoolFactory { private: - MemoryPool *m_firstPoolInFactory; ///< linked list of pools - DynamicMemoryAllocator *m_firstDmaInFactory; ///< linked list of dmas -#ifdef MEMORYPOOL_CHECKPOINTING - Int m_curCheckpoint; ///< most recent checkpoint value -#endif -#ifdef MEMORYPOOL_DEBUG - Int m_usedBytes; ///< total bytes in use - Int m_physBytes; ///< total bytes allocated to all pools (includes unused blocks) - Int m_peakUsedBytes; ///< high-water mark of m_usedBytes - Int m_peakPhysBytes; ///< high-water mark of m_physBytes - Int m_usedBytesSpecial[MAX_SPECIAL_USED]; - Int m_usedBytesSpecialPeak[MAX_SPECIAL_USED]; - Int m_physBytesSpecial[MAX_SPECIAL_USED]; - Int m_physBytesSpecialPeak[MAX_SPECIAL_USED]; -#endif + MemoryPool* m_firstPoolInFactory; ///< linked list of pools + DynamicMemoryAllocator* m_firstDmaInFactory; ///< linked list of dmas + #ifdef MEMORYPOOL_CHECKPOINTING + Int m_curCheckpoint; ///< most recent checkpoint value + #endif + #ifdef MEMORYPOOL_DEBUG + Int m_usedBytes; ///< total bytes in use + Int m_physBytes; ///< total bytes allocated to all pools (includes unused blocks) + Int m_peakUsedBytes; ///< high-water mark of m_usedBytes + Int m_peakPhysBytes; ///< high-water mark of m_physBytes + Int m_usedBytesSpecial[MAX_SPECIAL_USED]; + Int m_usedBytesSpecialPeak[MAX_SPECIAL_USED]; + Int m_physBytesSpecial[MAX_SPECIAL_USED]; + Int m_physBytesSpecialPeak[MAX_SPECIAL_USED]; + #endif public: - - // 'public' funcs that are really only for use by MemoryPool and friends + // 'public' funcs that are really only for use by MemoryPool and friends #ifdef MEMORYPOOL_DEBUG - /// adjust the usedBytes and physBytes variables by the given amoun ts. - void adjustTotals(const char* tagString, Int usedDelta, Int physDelta); + /// adjust the usedBytes and physBytes variables by the given amoun ts. + void adjustTotals(const char* tagString, Int usedDelta, Int physDelta); #endif #ifdef MEMORYPOOL_CHECKPOINTING - /// return the current checkpoint value. - Int getCurCheckpoint() { return m_curCheckpoint; } + /// return the current checkpoint value. + Int getCurCheckpoint() { return m_curCheckpoint; } #endif public: - MemoryPoolFactory(); void init(); ~MemoryPoolFactory(); /// create a new memory pool with the given settings. if a pool with the given name already exists, return it. - MemoryPool *createMemoryPool(const PoolInitRec *parms); + MemoryPool* createMemoryPool(const PoolInitRec* parms); /// overloaded version of createMemoryPool with explicit parms. - MemoryPool *createMemoryPool(const char *poolName, Int allocationSize, Int initialAllocationCount, Int overflowAllocationCount); + MemoryPool* createMemoryPool(const char* poolName, Int allocationSize, Int initialAllocationCount, Int overflowAllocationCount); /// return the pool with the given name. if no such pool exists, return null. - MemoryPool *findMemoryPool(const char *poolName); + MemoryPool* findMemoryPool(const char* poolName); /// destroy the given pool. - void destroyMemoryPool(MemoryPool *pMemoryPool); + void destroyMemoryPool(MemoryPool* pMemoryPool); /// create a DynamicMemoryAllocator with subpools with the given parms. - DynamicMemoryAllocator *createDynamicMemoryAllocator(Int numSubPools, const PoolInitRec pParms[]); + DynamicMemoryAllocator* createDynamicMemoryAllocator(Int numSubPools, const PoolInitRec pParms[]); /// destroy the given DynamicMemoryAllocator. - void destroyDynamicMemoryAllocator(DynamicMemoryAllocator *dma); + void destroyDynamicMemoryAllocator(DynamicMemoryAllocator* dma); /// destroy the contents of all pools and dmas. (the pools and dma's are not destroyed, just reset) void reset(); - void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = nullptr ); + void memoryPoolUsageReport(const char* filename, FILE* appendToFileInstead = nullptr); #ifdef MEMORYPOOL_DEBUG - /// perform internal consistency checking - void debugMemoryVerify(); + /// perform internal consistency checking + void debugMemoryVerify(); - /// return true iff the block was allocated by any pool or dma owned by this factory. - Bool debugIsBlockInAnyPool(void *pBlock); + /// return true iff the block was allocated by any pool or dma owned by this factory. + Bool debugIsBlockInAnyPool(void* pBlock); - /// return the tag string for the block. - const char *debugGetBlockTagString(void *pBlock); + /// return the tag string for the block. + const char* debugGetBlockTagString(void* pBlock); - /// dump a report with the given options to the logfile. - void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE *fp = nullptr ); + /// dump a report with the given options to the logfile. + void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE* fp = nullptr); - void debugSetInitFillerIndex(Int index); + void debugSetInitFillerIndex(Int index); #endif #ifdef MEMORYPOOL_CHECKPOINTING - /// set a new checkpoint. - Int debugSetCheckpoint(); + /// set a new checkpoint. + Int debugSetCheckpoint(); - /// reset all checkpoint information. - void debugResetCheckpoints(); + /// reset all checkpoint information. + void debugResetCheckpoints(); #endif }; -// how many bytes are we allowed to 'waste' per pool allocation before the debug code starts yelling at us... -#define MEMORY_POOL_OBJECT_ALLOCATION_SLOP 16 - -// ---------------------------------------------------------------------------- -#define GCMP_FIND(ARGCLASS, ARGPOOLNAME) \ -private: \ - static MemoryPool *getClassMemoryPool() \ - { \ - /* \ - Note that this static variable will be initialized exactly once: the first time \ - control flows over this section of code. This allows us to neatly resolve the \ - order-of-execution problem for static variables, ensuring this is not executed \ - prior to the initialization of TheMemoryPoolFactory. \ - */ \ - DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is null")); \ - static MemoryPool *The##ARGCLASS##Pool = TheMemoryPoolFactory->findMemoryPool(ARGPOOLNAME); \ - DEBUG_ASSERTCRASH(The##ARGCLASS##Pool, ("Pool \"%s\" not found (did you set it up in initMemoryPools?)", ARGPOOLNAME)); \ - DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() >= sizeof(ARGCLASS), ("Pool \"%s\" is too small for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ - DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() <= sizeof(ARGCLASS)+MEMORY_POOL_OBJECT_ALLOCATION_SLOP, ("Pool \"%s\" is too large for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ - return The##ARGCLASS##Pool; \ - } - -// ---------------------------------------------------------------------------- -#define GCMP_CREATE(ARGCLASS, ARGPOOLNAME, ARGINITIAL, ARGOVERFLOW) \ -private: \ - static MemoryPool *getClassMemoryPool() \ - { \ - /* \ - Note that this static variable will be initialized exactly once: the first time \ - control flows over this section of code. This allows us to neatly resolve the \ - order-of-execution problem for static variables, ensuring this is not executed \ - prior to the initialization of TheMemoryPoolFactory. \ - */ \ - DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is null")); \ - static MemoryPool *The##ARGCLASS##Pool = TheMemoryPoolFactory->createMemoryPool(ARGPOOLNAME, sizeof(ARGCLASS), ARGINITIAL, ARGOVERFLOW); \ - DEBUG_ASSERTCRASH(The##ARGCLASS##Pool, ("Pool \"%s\" not found (did you set it up in initMemoryPools?)", ARGPOOLNAME)); \ - DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() >= sizeof(ARGCLASS), ("Pool \"%s\" is too small for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ - DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() <= sizeof(ARGCLASS)+MEMORY_POOL_OBJECT_ALLOCATION_SLOP, ("Pool \"%s\" is too large for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ - return The##ARGCLASS##Pool; \ - } - -// ---------------------------------------------------------------------------- -#define MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ -protected: \ - virtual ~ARGCLASS(); \ -public: \ - enum ARGCLASS##MagicEnum { ARGCLASS##_GLUE_NOT_IMPLEMENTED = 0 }; \ -public: \ - inline void *operator new(size_t s, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ - { \ - DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ - return ARGCLASS::getClassMemoryPool()->allocateBlockImplementation(PASS_LITERALSTRING_ARG1); \ - } \ -public: \ - /* \ - Note that this delete operator can't be called directly; it is called \ - only if the analogous new operator is called, AND the constructor \ - throws an exception... \ - */ \ - inline void operator delete(void *p, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ - { \ - ARGCLASS::getClassMemoryPool()->freeBlock(p); \ - } \ -protected: \ - /* \ - Make normal new and delete protected, so they can't be called by the outside world. \ - Note that delete is funny, in that it can still be called by the class itself; \ - this is safe but not recommended, for consistency purposes. More problematically, \ - it can be called by another class that has declared itself 'friend' to us. \ - In theory, this shouldn't work, since it may not use the right operator-delete, \ - and thus the wrong memory pool; in practice, it seems the right delete IS called \ - in MSVC -- it seems to make operator delete virtual if the destructor is also virtual. \ - At any rate, this is undocumented behavior as far as I can tell, so we put a big old \ - crash into operator delete telling people to do the right thing and call deleteInstance \ - instead -- it'd be nice if we could catch this at compile time, but catching it at \ - runtime seems to be the best we can do... \ - */ \ - inline void *operator new(size_t s) \ - { \ - DEBUG_CRASH(("This operator new should normally never be called... please use new(char*) instead.")); \ - DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ - throw ERROR_BUG; \ - return 0; \ - } \ - inline void operator delete(void *p) \ - { \ - DEBUG_CRASH(("Please call deleteInstance instead of delete.")); \ - ARGCLASS::getClassMemoryPool()->freeBlock(p); \ - } \ -private: \ - virtual MemoryPool *getObjectMemoryPool() \ - { \ - return ARGCLASS::getClassMemoryPool(); \ - } \ -public: /* include this line at the end to reset visibility to 'public' */ - -// ---------------------------------------------------------------------------- -#define MEMORY_POOL_GLUE(ARGCLASS, ARGPOOLNAME) \ - MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ - GCMP_FIND(ARGCLASS, ARGPOOLNAME) - -// ---------------------------------------------------------------------------- -#define MEMORY_POOL_GLUE_WITH_EXPLICIT_CREATE(ARGCLASS, ARGPOOLNAME, ARGINITIAL, ARGOVERFLOW) \ - MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ - GCMP_CREATE(ARGCLASS, ARGPOOLNAME, ARGINITIAL, ARGOVERFLOW) - -// ---------------------------------------------------------------------------- -#define MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ARGCLASS, ARGPOOLNAME) \ - MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ - GCMP_CREATE(ARGCLASS, ARGPOOLNAME, -1, -1) + // how many bytes are we allowed to 'waste' per pool allocation before the debug code starts yelling at us... + #define MEMORY_POOL_OBJECT_ALLOCATION_SLOP 16 + + // ---------------------------------------------------------------------------- + #define GCMP_FIND(ARGCLASS, ARGPOOLNAME) \ + private: \ + static MemoryPool* getClassMemoryPool() \ + { \ + /* \ + Note that this static variable will be initialized exactly once: the first time \ + control flows over this section of code. This allows us to neatly resolve the \ + order-of-execution problem for static variables, ensuring this is not executed \ + prior to the initialization of TheMemoryPoolFactory. \ + */ \ + DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is null")); \ + static MemoryPool* The##ARGCLASS##Pool = TheMemoryPoolFactory->findMemoryPool(ARGPOOLNAME); \ + DEBUG_ASSERTCRASH(The##ARGCLASS##Pool, ("Pool \"%s\" not found (did you set it up in initMemoryPools?)", ARGPOOLNAME)); \ + DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() >= sizeof(ARGCLASS), ("Pool \"%s\" is too small for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ + DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() <= sizeof(ARGCLASS) + MEMORY_POOL_OBJECT_ALLOCATION_SLOP, ("Pool \"%s\" is too large for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ + return The##ARGCLASS##Pool; \ + } -// ---------------------------------------------------------------------------- -// this is the version for an Abstract Base Class, which will never be instantiated... -#define MEMORY_POOL_GLUE_ABC(ARGCLASS) \ -protected: \ - virtual ~ARGCLASS(); \ -public: \ - enum ARGCLASS##MagicEnum { ARGCLASS##_GLUE_NOT_IMPLEMENTED = 0 }; \ -protected: \ - inline void *operator new(size_t s, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ - { \ - DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ - DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ - throw ERROR_BUG; \ - return 0; \ - } \ -protected: \ - inline void operator delete(void *p, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ - { \ - DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ - } \ -protected: \ - inline void *operator new(size_t s) \ - { \ - DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ - DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ - throw ERROR_BUG; \ - return 0; \ - } \ - inline void operator delete(void *p) \ - { \ - DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ - } \ -private: \ - virtual MemoryPool *getObjectMemoryPool() \ - { \ - throw ERROR_BUG; \ - return 0; \ - } \ -public: /* include this line at the end to reset visibility to 'public' */ + // ---------------------------------------------------------------------------- + #define GCMP_CREATE(ARGCLASS, ARGPOOLNAME, ARGINITIAL, ARGOVERFLOW) \ + private: \ + static MemoryPool* getClassMemoryPool() \ + { \ + /* \ + Note that this static variable will be initialized exactly once: the first time \ + control flows over this section of code. This allows us to neatly resolve the \ + order-of-execution problem for static variables, ensuring this is not executed \ + prior to the initialization of TheMemoryPoolFactory. \ + */ \ + DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is null")); \ + static MemoryPool* The##ARGCLASS##Pool = TheMemoryPoolFactory->createMemoryPool(ARGPOOLNAME, sizeof(ARGCLASS), ARGINITIAL, ARGOVERFLOW); \ + DEBUG_ASSERTCRASH(The##ARGCLASS##Pool, ("Pool \"%s\" not found (did you set it up in initMemoryPools?)", ARGPOOLNAME)); \ + DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() >= sizeof(ARGCLASS), ("Pool \"%s\" is too small for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ + DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() <= sizeof(ARGCLASS) + MEMORY_POOL_OBJECT_ALLOCATION_SLOP, ("Pool \"%s\" is too large for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ + return The##ARGCLASS##Pool; \ + } + // ---------------------------------------------------------------------------- + #define MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ + protected: \ + virtual ~ARGCLASS(); \ + \ + public: \ + enum ARGCLASS##MagicEnum{ARGCLASS##_GLUE_NOT_IMPLEMENTED = 0}; \ + \ + public: \ + inline void* operator new(size_t s, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ + { \ + DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ + return ARGCLASS::getClassMemoryPool()->allocateBlockImplementation(PASS_LITERALSTRING_ARG1); \ + } \ + \ + public: \ + /* \ + Note that this delete operator can't be called directly; it is called \ + only if the analogous new operator is called, AND the constructor \ + throws an exception... \ + */ \ + inline void operator delete(void* p, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ + { \ + ARGCLASS::getClassMemoryPool()->freeBlock(p); \ + } \ + \ + protected: \ + /* \ + Make normal new and delete protected, so they can't be called by the outside world. \ + Note that delete is funny, in that it can still be called by the class itself; \ + this is safe but not recommended, for consistency purposes. More problematically, \ + it can be called by another class that has declared itself 'friend' to us. \ + In theory, this shouldn't work, since it may not use the right operator-delete, \ + and thus the wrong memory pool; in practice, it seems the right delete IS called \ + in MSVC -- it seems to make operator delete virtual if the destructor is also virtual. \ + At any rate, this is undocumented behavior as far as I can tell, so we put a big old \ + crash into operator delete telling people to do the right thing and call deleteInstance \ + instead -- it'd be nice if we could catch this at compile time, but catching it at \ + runtime seems to be the best we can do... \ + */ \ + inline void* operator new(size_t s) \ + { \ + DEBUG_CRASH(("This operator new should normally never be called... please use new(char*) instead.")); \ + DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ + throw ERROR_BUG; \ + return 0; \ + } \ + inline void operator delete(void* p) \ + { \ + DEBUG_CRASH(("Please call deleteInstance instead of delete.")); \ + ARGCLASS::getClassMemoryPool()->freeBlock(p); \ + } \ + \ + private: \ + virtual MemoryPool* getObjectMemoryPool() \ + { \ + return ARGCLASS::getClassMemoryPool(); \ + } \ + \ + public: /* include this line at the end to reset visibility to 'public' */ + + // ---------------------------------------------------------------------------- + #define MEMORY_POOL_GLUE(ARGCLASS, ARGPOOLNAME) \ + MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ + GCMP_FIND(ARGCLASS, ARGPOOLNAME) + + // ---------------------------------------------------------------------------- + #define MEMORY_POOL_GLUE_WITH_EXPLICIT_CREATE(ARGCLASS, ARGPOOLNAME, ARGINITIAL, ARGOVERFLOW) \ + MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ + GCMP_CREATE(ARGCLASS, ARGPOOLNAME, ARGINITIAL, ARGOVERFLOW) + + // ---------------------------------------------------------------------------- + #define MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ARGCLASS, ARGPOOLNAME) \ + MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ + GCMP_CREATE(ARGCLASS, ARGPOOLNAME, -1, -1) + + // ---------------------------------------------------------------------------- + // this is the version for an Abstract Base Class, which will never be instantiated... + #define MEMORY_POOL_GLUE_ABC(ARGCLASS) \ + protected: \ + virtual ~ARGCLASS(); \ + \ + public: \ + enum ARGCLASS##MagicEnum{ARGCLASS##_GLUE_NOT_IMPLEMENTED = 0}; \ + \ + protected: \ + inline void* operator new(size_t s, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ + { \ + DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ + DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ + throw ERROR_BUG; \ + return 0; \ + } \ + \ + protected: \ + inline void operator delete(void* p, ARGCLASS##MagicEnum e DECLARE_LITERALSTRING_ARG2) \ + { \ + DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ + } \ + \ + protected: \ + inline void* operator new(size_t s) \ + { \ + DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ + DEBUG_ASSERTCRASH(s == sizeof(ARGCLASS), ("The wrong operator new is being called; ensure all objects in the hierarchy have MemoryPoolGlue set up correctly")); \ + throw ERROR_BUG; \ + return 0; \ + } \ + inline void operator delete(void* p) \ + { \ + DEBUG_CRASH(("this should be impossible to call (abstract base class)")); \ + } \ + \ + private: \ + virtual MemoryPool* getObjectMemoryPool() \ + { \ + throw ERROR_BUG; \ + return 0; \ + } \ + \ + public: /* include this line at the end to reset visibility to 'public' */ // ---------------------------------------------------------------------------- /** - This class is provided as a simple and safe way to integrate C++ object allocation - into MemoryPool usage. To use it, you must have your class inherit from - MemoryPoolObject, then put the macro MEMORY_POOL_GLUE(MyClassName, "MyPoolName") - at the start of your class definition. (This does not create the pool itself -- you - must create that manually using MemoryPoolFactory::createMemoryPool) + This class is provided as a simple and safe way to integrate C++ object allocation + into MemoryPool usage. To use it, you must have your class inherit from + MemoryPoolObject, then put the macro MEMORY_POOL_GLUE(MyClassName, "MyPoolName") + at the start of your class definition. (This does not create the pool itself -- you + must create that manually using MemoryPoolFactory::createMemoryPool) */ class MemoryPoolObject { protected: - /** ensure that all destructors are virtual */ - virtual ~MemoryPoolObject() { } + virtual ~MemoryPoolObject() {} protected: - void *operator new(size_t s) { DEBUG_CRASH(("This should be impossible")); return 0; } - void operator delete(void *p) { DEBUG_CRASH(("This should be impossible")); } + void* operator new(size_t s) + { + DEBUG_CRASH(("This should be impossible")); + return 0; + } + void operator delete(void* p) { DEBUG_CRASH(("This should be impossible")); } protected: - - virtual MemoryPool *getObjectMemoryPool() = 0; + virtual MemoryPool* getObjectMemoryPool() = 0; public: - static void deleteInstanceInternal(MemoryPoolObject* mpo) { if (mpo) { - MemoryPool *pool = mpo->getObjectMemoryPool(); // save this, since the dtor will nuke our vtbl - mpo->~MemoryPoolObject(); // it's virtual, so the right one will be called. - pool->freeBlock((void *)mpo); + MemoryPool* pool = mpo->getObjectMemoryPool(); // save this, since the dtor will nuke our vtbl + mpo->~MemoryPoolObject(); // it's virtual, so the right one will be called. + pool->freeBlock((void*)mpo); } } }; @@ -768,13 +773,12 @@ inline void deleteInstance(MemoryPoolObject* mpo) MemoryPoolObject::deleteInstanceInternal(mpo); } - // INLINING /////////////////////////////////////////////////////////////////// // ---------------------------------------------------------------------------- -inline MemoryPoolFactory *MemoryPool::getOwningFactory() { return m_factory; } -inline MemoryPool *MemoryPool::getNextPoolInList() { return m_nextPoolInFactory; } -inline const char *MemoryPool::getPoolName() { return m_poolName; } +inline MemoryPoolFactory* MemoryPool::getOwningFactory() { return m_factory; } +inline MemoryPool* MemoryPool::getNextPoolInList() { return m_nextPoolInFactory; } +inline const char* MemoryPool::getPoolName() { return m_poolName; } inline Int MemoryPool::getAllocationSize() { return m_allocationSize; } inline Int MemoryPool::getFreeBlockCount() { return getTotalBlockCount() - getUsedBlockCount(); } inline Int MemoryPool::getUsedBlockCount() { return m_usedBlocksInPool; } @@ -783,105 +787,105 @@ inline Int MemoryPool::getPeakBlockCount() { return m_peakUsedBlocksInPool; } inline Int MemoryPool::getInitialBlockCount() { return m_initialAllocationCount; } // ---------------------------------------------------------------------------- -inline DynamicMemoryAllocator *DynamicMemoryAllocator::getNextDmaInList() { return m_nextDmaInFactory; } +inline DynamicMemoryAllocator* DynamicMemoryAllocator::getNextDmaInList() { return m_nextDmaInFactory; } // EXTERNALS ////////////////////////////////////////////////////////////////// /** - Initialize the memory manager. Construct a new MemoryPoolFactory and - DynamicMemoryAllocator and store 'em in the singletons of the relevant - names. + Initialize the memory manager. Construct a new MemoryPoolFactory and + DynamicMemoryAllocator and store 'em in the singletons of the relevant + names. */ extern void initMemoryManager(); /** - return true if initMemoryManager() has been called. - return false if only preMainInitMemoryManager() has been called. + return true if initMemoryManager() has been called. + return false if only preMainInitMemoryManager() has been called. */ extern Bool isMemoryManagerOfficiallyInited(); /** - similar to initMemoryManager, but this should be used if the memory manager must be initialized - prior to main() (e.g., from a static constructor). If preMainInitMemoryManager() is called prior - to initMemoryManager(), then subsequent calls to either are quietly ignored, AS IS any subsequent - call to shutdownMemoryManager() [since there's no safe way to ensure that shutdownMemoryManager - will execute after all static destructors]. + similar to initMemoryManager, but this should be used if the memory manager must be initialized + prior to main() (e.g., from a static constructor). If preMainInitMemoryManager() is called prior + to initMemoryManager(), then subsequent calls to either are quietly ignored, AS IS any subsequent + call to shutdownMemoryManager() [since there's no safe way to ensure that shutdownMemoryManager + will execute after all static destructors]. - (Note: this function is actually not externally visible, but is documented here for clarity.) + (Note: this function is actually not externally visible, but is documented here for clarity.) */ /* extern void preMainInitMemoryManager(); */ /** - Shut down the memory manager. Throw away TheMemoryPoolFactory and - TheDynamicMemoryAllocator. + Shut down the memory manager. Throw away TheMemoryPoolFactory and + TheDynamicMemoryAllocator. */ extern void shutdownMemoryManager(); -extern MemoryPoolFactory *TheMemoryPoolFactory; -extern DynamicMemoryAllocator *TheDynamicMemoryAllocator; +extern MemoryPoolFactory* TheMemoryPoolFactory; +extern DynamicMemoryAllocator* TheDynamicMemoryAllocator; /** - This function is declared in this header, but is not defined anywhere -- you must provide - it in your code. It is called by initMemoryManager() or preMainInitMemoryManager() in order - to get the specifics of the subpool for the dynamic memory allocator. (If you just want - some defaults, set both return arguments to zero.) The reason for this odd setup is that - we may need to init the memory manager prior to main() [due to static C++ ctors] and - this allows us a way to get the necessary parameters. + This function is declared in this header, but is not defined anywhere -- you must provide + it in your code. It is called by initMemoryManager() or preMainInitMemoryManager() in order + to get the specifics of the subpool for the dynamic memory allocator. (If you just want + some defaults, set both return arguments to zero.) The reason for this odd setup is that + we may need to init the memory manager prior to main() [due to static C++ ctors] and + this allows us a way to get the necessary parameters. */ -extern void userMemoryManagerGetDmaParms(Int *numSubPools, const PoolInitRec **pParms); +extern void userMemoryManagerGetDmaParms(Int* numSubPools, const PoolInitRec** pParms); /** - This function is declared in this header, but is not defined anywhere -- you must provide - it in your code. It is called by initMemoryManager() or preMainInitMemoryManager() in order - to initialize the pools to be used. (You can define an empty function if you like.) + This function is declared in this header, but is not defined anywhere -- you must provide + it in your code. It is called by initMemoryManager() or preMainInitMemoryManager() in order + to initialize the pools to be used. (You can define an empty function if you like.) */ extern void userMemoryManagerInitPools(); /** - This function is declared in this header, but is not defined anywhere -- you must provide - it in your code. It is called by createMemoryPool to adjust the allocation size(s) for a - given pool. Note that the counts are in-out parms! + This function is declared in this header, but is not defined anywhere -- you must provide + it in your code. It is called by createMemoryPool to adjust the allocation size(s) for a + given pool. Note that the counts are in-out parms! */ -extern void userMemoryAdjustPoolSize(const char *poolName, Int& initialAllocationCount, Int& overflowAllocationCount); +extern void userMemoryAdjustPoolSize(const char* poolName, Int& initialAllocationCount, Int& overflowAllocationCount); -#ifdef __cplusplus + #ifdef __cplusplus -#ifndef _OPERATOR_NEW_DEFINED_ + #ifndef _OPERATOR_NEW_DEFINED_ - #define _OPERATOR_NEW_DEFINED_ + #define _OPERATOR_NEW_DEFINED_ - extern void * __cdecl operator new (size_t size); - extern void __cdecl operator delete (void *p); +extern void* __cdecl operator new(size_t size); +extern void __cdecl operator delete(void* p); - extern void * __cdecl operator new[] (size_t size); - extern void __cdecl operator delete[] (void *p); +extern void* __cdecl operator new[](size_t size); +extern void __cdecl operator delete[](void* p); - // additional overloads to account for VC/MFC funky versions - extern void* __cdecl operator new(size_t nSize, const char *, int); - extern void __cdecl operator delete(void *, const char *, int); +// additional overloads to account for VC/MFC funky versions +extern void* __cdecl operator new(size_t nSize, const char*, int); +extern void __cdecl operator delete(void*, const char*, int); - extern void* __cdecl operator new[](size_t nSize, const char *, int); - extern void __cdecl operator delete[](void *, const char *, int); +extern void* __cdecl operator new[](size_t nSize, const char*, int); +extern void __cdecl operator delete[](void*, const char*, int); -#if defined(_MSC_VER) && _MSC_VER < 1300 - // additional overloads for 'placement new' - //inline void* __cdecl operator new (size_t s, void *p) { return p; } - //inline void __cdecl operator delete (void *, void *p) { } - inline void* __cdecl operator new[] (size_t s, void *p) { return p; } - inline void __cdecl operator delete[] (void *, void *p) { } -#endif + #if defined(_MSC_VER) && _MSC_VER < 1300 +// additional overloads for 'placement new' +// inline void* __cdecl operator new (size_t s, void *p) { return p; } +// inline void __cdecl operator delete (void *, void *p) { } +inline void* __cdecl operator new[](size_t s, void* p) { return p; } +inline void __cdecl operator delete[](void*, void* p) {} + #endif -#endif + #endif -#ifdef MEMORYPOOL_DEBUG_CUSTOM_NEW - #define MSGNEW(MSG) new(MSG, 0) - #define NEW new(__FILE__, __LINE__) -#else - #define MSGNEW(MSG) new - #define NEW new -#endif + #ifdef MEMORYPOOL_DEBUG_CUSTOM_NEW + #define MSGNEW(MSG) new (MSG, 0) + #define NEW new (__FILE__, __LINE__) + #else + #define MSGNEW(MSG) new + #define NEW new + #endif -#endif + #endif class STLSpecialAlloc { @@ -892,21 +896,27 @@ class STLSpecialAlloc #endif // DISABLE_GAMEMEMORY - /** - A simple utility class to ensure exception safety; this holds a MemoryPoolObject - and deletes it in its destructor. Especially useful for iterators! + A simple utility class to ensure exception safety; this holds a MemoryPoolObject + and deletes it in its destructor. Especially useful for iterators! */ class MemoryPoolObjectHolder { private: - MemoryPoolObject *m_mpo; + MemoryPoolObject* m_mpo; + public: - MemoryPoolObjectHolder(MemoryPoolObject *mpo = nullptr) : m_mpo(mpo) { } - void hold(MemoryPoolObject *mpo) { DEBUG_ASSERTCRASH(!m_mpo, ("already holding")); m_mpo = mpo; } + MemoryPoolObjectHolder(MemoryPoolObject* mpo = nullptr) + : m_mpo(mpo) + {} + void hold(MemoryPoolObject* mpo) + { + DEBUG_ASSERTCRASH(!m_mpo, ("already holding")); + m_mpo = mpo; + } void release() { m_mpo = nullptr; } ~MemoryPoolObjectHolder() { deleteInstance(m_mpo); } }; - -#define EMPTY_DTOR(CLASS) inline CLASS::~CLASS() { } +#define EMPTY_DTOR(CLASS) \ + inline CLASS::~CLASS() {} diff --git a/Core/GameEngine/Include/Common/GameMemoryNull.h b/Core/GameEngine/Include/Common/GameMemoryNull.h index 263f7a1dcb9..c02b0455bc2 100644 --- a/Core/GameEngine/Include/Common/GameMemoryNull.h +++ b/Core/GameEngine/Include/Common/GameMemoryNull.h @@ -18,27 +18,25 @@ #pragma once -#define allocateBytes(ARGCOUNT,ARGLITERAL) allocateBytesImplementation(ARGCOUNT) -#define allocateBytesDoNotZero(ARGCOUNT,ARGLITERAL) allocateBytesDoNotZeroImplementation(ARGCOUNT) -#define newInstanceDesc(ARGCLASS,ARGLITERAL) new ARGCLASS -#define newInstance(ARGCLASS) new ARGCLASS -#define MSGNEW(MSG) new -#define NEW new - +#define allocateBytes(ARGCOUNT, ARGLITERAL) allocateBytesImplementation(ARGCOUNT) +#define allocateBytesDoNotZero(ARGCOUNT, ARGLITERAL) allocateBytesDoNotZeroImplementation(ARGCOUNT) +#define newInstanceDesc(ARGCLASS, ARGLITERAL) new ARGCLASS +#define newInstance(ARGCLASS) new ARGCLASS +#define MSGNEW(MSG) new +#define NEW new /** - The DynamicMemoryAllocator class is used to handle unpredictably-sized - allocation requests. + The DynamicMemoryAllocator class is used to handle unpredictably-sized + allocation requests. */ class DynamicMemoryAllocator { public: - /// allocate bytes from this pool. (don't call directly; use allocateBytes() macro) - void *allocateBytesImplementation(Int numBytes); + void* allocateBytesImplementation(Int numBytes); /// like allocateBytesImplementation, but zeroes the memory before returning - void *allocateBytesDoNotZeroImplementation(Int numBytes); + void* allocateBytesDoNotZeroImplementation(Int numBytes); #ifdef MEMORYPOOL_DEBUG void debugIgnoreLeaksForThisBlock(void* pBlockPtr); @@ -48,66 +46,60 @@ class DynamicMemoryAllocator void freeBytes(void* pMem); /** - return the actual number of bytes that would be allocated - if you tried to allocate the given size. + return the actual number of bytes that would be allocated + if you tried to allocate the given size. */ Int getActualAllocationSize(Int numBytes); }; - /** - The class that manages all the MemoryPools and DynamicMemoryAllocators. - Usually you will create exactly one of these (TheMemoryPoolFactory) - and use it for everything. + The class that manages all the MemoryPools and DynamicMemoryAllocators. + Usually you will create exactly one of these (TheMemoryPoolFactory) + and use it for everything. */ class MemoryPoolFactory { public: - - void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = nullptr ); + void memoryPoolUsageReport(const char* filename, FILE* appendToFileInstead = nullptr); #ifdef MEMORYPOOL_DEBUG - void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE *fp = nullptr ); + void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE* fp = nullptr); void debugSetInitFillerIndex(Int index); #endif }; - #define MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) \ -protected: \ - virtual ~ARGCLASS(); \ +protected: \ + virtual ~ARGCLASS(); \ + \ public: /* include this line at the end to reset visibility to 'public' */ - #define MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ARGCLASS, ARGPOOLNAME) \ MEMORY_POOL_GLUE_WITHOUT_GCMP(ARGCLASS) - // this is the version for an Abstract Base Class, which will never be instantiated... #define MEMORY_POOL_GLUE_ABC(ARGCLASS) \ -protected: \ - virtual ~ARGCLASS(); \ +protected: \ + virtual ~ARGCLASS(); \ + \ public: /* include this line at the end to reset visibility to 'public' */ - /** - This class is provided as a simple and safe way to integrate C++ object allocation - into MemoryPool usage. To use it, you must have your class inherit from - MemoryPoolObject, then put the macro MEMORY_POOL_GLUE(MyClassName, "MyPoolName") - at the start of your class definition. (This does not create the pool itself -- you - must create that manually using MemoryPoolFactory::createMemoryPool) + This class is provided as a simple and safe way to integrate C++ object allocation + into MemoryPool usage. To use it, you must have your class inherit from + MemoryPoolObject, then put the macro MEMORY_POOL_GLUE(MyClassName, "MyPoolName") + at the start of your class definition. (This does not create the pool itself -- you + must create that manually using MemoryPoolFactory::createMemoryPool) */ class MemoryPoolObject { protected: - /** ensure that all destructors are virtual */ - virtual ~MemoryPoolObject() { } + virtual ~MemoryPoolObject() {} public: - static void deleteInstanceInternal(MemoryPoolObject* mpo) { delete mpo; @@ -119,29 +111,27 @@ inline void deleteInstance(MemoryPoolObject* mpo) MemoryPoolObject::deleteInstanceInternal(mpo); } - /** - Initialize the memory manager. Construct a new MemoryPoolFactory and - DynamicMemoryAllocator and store 'em in the singletons of the relevant - names. + Initialize the memory manager. Construct a new MemoryPoolFactory and + DynamicMemoryAllocator and store 'em in the singletons of the relevant + names. */ extern void initMemoryManager(); /** - return true if initMemoryManager() has been called. - return false if only preMainInitMemoryManager() has been called. + return true if initMemoryManager() has been called. + return false if only preMainInitMemoryManager() has been called. */ extern Bool isMemoryManagerOfficiallyInited(); /** - Shut down the memory manager. Throw away TheMemoryPoolFactory and - TheDynamicMemoryAllocator. + Shut down the memory manager. Throw away TheMemoryPoolFactory and + TheDynamicMemoryAllocator. */ extern void shutdownMemoryManager(); -extern MemoryPoolFactory *TheMemoryPoolFactory; -extern DynamicMemoryAllocator *TheDynamicMemoryAllocator; - +extern MemoryPoolFactory* TheMemoryPoolFactory; +extern DynamicMemoryAllocator* TheDynamicMemoryAllocator; // TheSuperHackers @info // The new operator overloads will zero all memory after allocation. @@ -149,18 +139,18 @@ extern DynamicMemoryAllocator *TheDynamicMemoryAllocator; // where data is not properly zero initialized. Disable these operators when fixing those issues. #ifndef DISABLE_GAMEMEMORY_NEW_OPERATORS -extern void * __cdecl operator new(size_t size); -extern void __cdecl operator delete(void *p); +extern void* __cdecl operator new(size_t size); +extern void __cdecl operator delete(void* p); -extern void * __cdecl operator new[](size_t size); -extern void __cdecl operator delete[](void *p); +extern void* __cdecl operator new[](size_t size); +extern void __cdecl operator delete[](void* p); // additional overloads to account for VC/MFC funky versions -extern void* __cdecl operator new(size_t size, const char *, int); -extern void __cdecl operator delete(void *p, const char *, int); +extern void* __cdecl operator new(size_t size, const char*, int); +extern void __cdecl operator delete(void* p, const char*, int); -extern void* __cdecl operator new[](size_t size, const char *, int); -extern void __cdecl operator delete[](void *p, const char *, int); +extern void* __cdecl operator new[](size_t size, const char*, int); +extern void __cdecl operator delete[](void* p, const char*, int); #endif diff --git a/Core/GameEngine/Include/Common/GameMusic.h b/Core/GameEngine/Include/Common/GameMusic.h index cd47a3f8ece..ab64577d479 100644 --- a/Core/GameEngine/Include/Common/GameMusic.h +++ b/Core/GameEngine/Include/Common/GameMusic.h @@ -48,7 +48,6 @@ #include "Common/GameAudio.h" #include "Common/GameMemory.h" - //---------------------------------------------------------------------------- // Forward References //---------------------------------------------------------------------------- @@ -60,53 +59,50 @@ struct FieldParse; // Type Defines //---------------------------------------------------------------------------- - //=============================== // MusicTrack //=============================== //------------------------------------------------------------------------------------------------- /** The MusicTrack struct holds all information about a music track. - * Place data in TrackInfo that is useful to the game code in determining - * what tracks to play. */ + * Place data in TrackInfo that is useful to the game code in determining + * what tracks to play. */ //------------------------------------------------------------------------------------------------- class MusicTrack : public MemoryPoolObject { - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( MusicTrack, "MusicTrack" ) + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(MusicTrack, "MusicTrack") public: + MusicTrack(); + // virtual destructor prototype defined by memory pool object - MusicTrack(); - // virtual destructor prototype defined by memory pool object - - const FieldParse *getFieldParse() const { return m_musicTrackFieldParseTable; } + const FieldParse* getFieldParse() const { return m_musicTrackFieldParseTable; } - Int index; ///< Track index - AsciiString name; ///< Logical name of track - AsciiString filename; ///< Filename with extension of music track - Real volume; ///< Mixing level for this track - Bool ambient; ///< Game info about this track(public) + Int index; ///< Track index + AsciiString name; ///< Logical name of track + AsciiString filename; ///< Filename with extension of music track + Real volume; ///< Mixing level for this track + Bool ambient; ///< Game info about this track(public) - MusicTrack *next; - MusicTrack *prev; - - static const FieldParse m_musicTrackFieldParseTable[]; ///< the parse table for INI definition + MusicTrack* next; + MusicTrack* prev; + static const FieldParse m_musicTrackFieldParseTable[]; ///< the parse table for INI definition }; class MusicManager { - public: - MusicManager(); - virtual ~MusicManager(); +public: + MusicManager(); + virtual ~MusicManager(); - void playTrack( AudioEventRTS *eventToUse ); - void stopTrack( AudioHandle eventToRemove ); + void playTrack(AudioEventRTS* eventToUse); + void stopTrack(AudioHandle eventToRemove); - virtual void addAudioEvent(AudioEventRTS *eventToAdd); // pre-copied - virtual void removeAudioEvent( AudioHandle eventToRemove ); + virtual void addAudioEvent(AudioEventRTS* eventToAdd); // pre-copied + virtual void removeAudioEvent(AudioHandle eventToRemove); - void setVolume( Real m_volume ); + void setVolume(Real m_volume); }; diff --git a/Core/GameEngine/Include/Common/GameSounds.h b/Core/GameEngine/Include/Common/GameSounds.h index 83c846957ac..e0862722d3e 100644 --- a/Core/GameEngine/Include/Common/GameSounds.h +++ b/Core/GameEngine/Include/Common/GameSounds.h @@ -50,49 +50,48 @@ class AudioEventRTS; class SoundManager : public SubsystemInterface { - public: - SoundManager(); - virtual ~SoundManager() override; +public: + SoundManager(); + virtual ~SoundManager() override; - virtual void init() override; ///< Initializes the sounds system - virtual void postProcessLoad() override; - virtual void update() override; ///< Services sounds tasks. Called by AudioInterface - virtual void reset() override; ///< Reset the sounds system + virtual void init() override; ///< Initializes the sounds system + virtual void postProcessLoad() override; + virtual void update() override; ///< Services sounds tasks. Called by AudioInterface + virtual void reset() override; ///< Reset the sounds system - virtual void loseFocus(); ///< Called when application loses focus - virtual void regainFocus(); ///< Called when application regains focus + virtual void loseFocus(); ///< Called when application loses focus + virtual void regainFocus(); ///< Called when application regains focus - virtual void setListenerPosition( const Coord3D *position ); ///< Set the listener position for map3DSound() calculations - virtual void setViewRadius( Real viewRadius );///< Sets the radius of the view from the center of the screen in world coordinate units - virtual void setCameraAudibleDistance( Real audibleDistance ); - virtual Real getCameraAudibleDistance(); + virtual void setListenerPosition(const Coord3D* position); ///< Set the listener position for map3DSound() calculations + virtual void setViewRadius(Real viewRadius); ///< Sets the radius of the view from the center of the screen in world coordinate units + virtual void setCameraAudibleDistance(Real audibleDistance); + virtual Real getCameraAudibleDistance(); - virtual void addAudioEvent(AudioEventRTS *&eventToAdd); // pre-copied + virtual void addAudioEvent(AudioEventRTS*& eventToAdd); // pre-copied - virtual void notifyOf2DSampleStart(); - virtual void notifyOf3DSampleStart(); + virtual void notifyOf2DSampleStart(); + virtual void notifyOf3DSampleStart(); - virtual void notifyOf2DSampleCompletion(); - virtual void notifyOf3DSampleCompletion(); + virtual void notifyOf2DSampleCompletion(); + virtual void notifyOf3DSampleCompletion(); - virtual Int getAvailableSamples(); - virtual Int getAvailable3DSamples(); + virtual Int getAvailableSamples(); + virtual Int getAvailable3DSamples(); - // empty string means that this sound wasn't found or some error occurred. CHECK FOR EMPTY STRING. - virtual AsciiString getFilenameForPlayFromAudioEvent( const AudioEventRTS *eventToGetFrom ); + // empty string means that this sound wasn't found or some error occurred. CHECK FOR EMPTY STRING. + virtual AsciiString getFilenameForPlayFromAudioEvent(const AudioEventRTS* eventToGetFrom); - // called by this class and MilesAudioManager to determine if a sound can still be played - virtual Bool canPlayNow( AudioEventRTS *event ); + // called by this class and MilesAudioManager to determine if a sound can still be played + virtual Bool canPlayNow(AudioEventRTS* event); - protected: - virtual Bool violatesVoice( AudioEventRTS *event ); - virtual Bool isInterrupting( AudioEventRTS *event ); +protected: + virtual Bool violatesVoice(AudioEventRTS* event); + virtual Bool isInterrupting(AudioEventRTS* event); +protected: + UnsignedInt m_num2DSamples; + UnsignedInt m_num3DSamples; - protected: - UnsignedInt m_num2DSamples; - UnsignedInt m_num3DSamples; - - UnsignedInt m_numPlaying2DSamples; - UnsignedInt m_numPlaying3DSamples; + UnsignedInt m_numPlaying2DSamples; + UnsignedInt m_numPlaying3DSamples; }; diff --git a/Core/GameEngine/Include/Common/GameType.h b/Core/GameEngine/Include/Common/GameType.h index eab2ec3e846..ddb85448da1 100644 --- a/Core/GameEngine/Include/Common/GameType.h +++ b/Core/GameEngine/Include/Common/GameType.h @@ -31,11 +31,12 @@ #include "Lib/BaseType.h" // the default size of the world map -#define DEFAULT_WORLD_WIDTH 64 -#define DEFAULT_WORLD_HEIGHT 64 +#define DEFAULT_WORLD_WIDTH 64 +#define DEFAULT_WORLD_HEIGHT 64 /// A unique, generic "identifier" used to access Objects. -enum ObjectID CPP_11(: Int) +enum ObjectID +CPP_11( : Int) { INVALID_ID = 0, FORCE_OBJECTID_TO_LONG_SIZE = 0x7ffffff diff --git a/Core/GameEngine/Include/Common/GameUtility.h b/Core/GameEngine/Include/Common/GameUtility.h index 86790ff4847..1ddc4b2f584 100644 --- a/Core/GameEngine/Include/Common/GameUtility.h +++ b/Core/GameEngine/Include/Common/GameUtility.h @@ -29,11 +29,11 @@ namespace rts { bool localPlayerHasRadar(); -Player* getObservedOrLocalPlayer(); ///< Get the current observed or local player. Is never null. -Player* getObservedOrLocalPlayer_Safe(); ///< Get the current observed or local player. Is never null, except when the application does not have players. +Player* getObservedOrLocalPlayer(); ///< Get the current observed or local player. Is never null. +Player* getObservedOrLocalPlayer_Safe(); ///< Get the current observed or local player. Is never null, except when the application does not have players. PlayerIndex getObservedOrLocalPlayerIndex_Safe(); ///< Get the current observed or local player index. Returns 0 when the application does not have players. -void changeLocalPlayer(Player* player); //< Change local player during game. Must not pass null. +void changeLocalPlayer(Player* player); //< Change local player during game. Must not pass null. void changeObservedPlayer(Player* player); ///< Change observed player during game. Can pass null: is identical to passing the "ReplayObserver" player. } // namespace rts diff --git a/Core/GameEngine/Include/Common/INI.h b/Core/GameEngine/Include/Common/INI.h index 746a2e60395..d49b4aaf28c 100644 --- a/Core/GameEngine/Include/Common/INI.h +++ b/Core/GameEngine/Include/Common/INI.h @@ -30,7 +30,7 @@ #pragma once // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include // for offsetof, which we don't use but everyone who includes us does +#include // for offsetof, which we don't use but everyone who includes us does #include "Common/STLTypedefs.h" #include "Common/AsciiString.h" #include "Common/GameCommon.h" @@ -39,7 +39,8 @@ class INI; class Xfer; class File; -enum ScienceType CPP_11(: Int); +enum ScienceType +CPP_11( : Int); //------------------------------------------------------------------------------------------------- /** These control the behavior of loading the INI data into items */ diff --git a/Core/GameEngine/Include/Common/LocalFile.h b/Core/GameEngine/Include/Common/LocalFile.h index 8f98ab50c9c..46afdd43861 100644 --- a/Core/GameEngine/Include/Common/LocalFile.h +++ b/Core/GameEngine/Include/Common/LocalFile.h @@ -50,14 +50,13 @@ #include "Common/file.h" #if USE_BUFFERED_IO -#include "Utility/stdio_adapter.h" + #include "Utility/stdio_adapter.h" #endif //---------------------------------------------------------------------------- // Forward References //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- // Type Defines //---------------------------------------------------------------------------- @@ -66,66 +65,59 @@ // LocalFile //=============================== /** - * File abstraction for standard C file operators: open, close, lseek, read, write - */ + * File abstraction for standard C file operators: open, close, lseek, read, write + */ //=============================== class LocalFile : public File { MEMORY_POOL_GLUE_ABC(LocalFile) - private: - +private: #if USE_BUFFERED_IO - // srj sez: this was purely an experiment in optimization. - // at the present time, it doesn't appear to be a good one. - // TheSuperHackers @info It is a good optimization and will be - // significantly faster than unbuffered IO with small reads and writes. - FILE* m_file; + // srj sez: this was purely an experiment in optimization. + // at the present time, it doesn't appear to be a good one. + // TheSuperHackers @info It is a good optimization and will be + // significantly faster than unbuffered IO with small reads and writes. + FILE* m_file; #else - int m_handle; ///< Local C file handle + int m_handle; ///< Local C file handle #endif - public: - - LocalFile(); - //virtual ~LocalFile(); - - - virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = BUFFERSIZE ) override; ///< Open a file for access - virtual void close() override; ///< Close the file - virtual Int read( void *buffer, Int bytes ) override; ///< Read the specified number of bytes in to buffer: See File::read - virtual Int readChar() override; ///< Read a character from the file - virtual Int readWideChar() override; ///< Read a wide character from the file - virtual Int write( const void *buffer, Int bytes ) override; ///< Write the specified number of bytes from the buffer: See File::write - virtual Int writeFormat( const Char* format, ... ) override; ///< Write an unterminated formatted string to the file - virtual Int writeFormat( const WideChar* format, ... ) override; ///< Write an unterminated formatted string to the file - virtual Int writeChar( const Char* character ) override; ///< Write a character to the file - virtual Int writeChar( const WideChar* character ) override; ///< Write a wide character to the file - virtual Int seek( Int new_pos, seekMode mode = CURRENT ) override; ///< Set file position: See File::seek - virtual Bool flush() override; ///< flush data to disk - virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) override; ///< moves file position to after the next new-line - virtual Bool scanInt(Int &newInt) override; ///< return what gets read in as an integer at the current file position. - virtual Bool scanReal(Real &newReal) override; ///< return what gets read in as a float at the current file position. - virtual Bool scanString(AsciiString &newString) override; ///< return what gets read in as a string at the current file position. - /** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. - */ - virtual char* readEntireAndClose() override; - virtual File* convertToRAMFile() override; - - protected: +public: + LocalFile(); + // virtual ~LocalFile(); + + virtual Bool open(const Char* filename, Int access = NONE, size_t bufferSize = BUFFERSIZE) override; ///< Open a file for access + virtual void close() override; ///< Close the file + virtual Int read(void* buffer, Int bytes) override; ///< Read the specified number of bytes in to buffer: See File::read + virtual Int readChar() override; ///< Read a character from the file + virtual Int readWideChar() override; ///< Read a wide character from the file + virtual Int write(const void* buffer, Int bytes) override; ///< Write the specified number of bytes from the buffer: See File::write + virtual Int writeFormat(const Char* format, ...) override; ///< Write an unterminated formatted string to the file + virtual Int writeFormat(const WideChar* format, ...) override; ///< Write an unterminated formatted string to the file + virtual Int writeChar(const Char* character) override; ///< Write a character to the file + virtual Int writeChar(const WideChar* character) override; ///< Write a wide character to the file + virtual Int seek(Int new_pos, seekMode mode = CURRENT) override; ///< Set file position: See File::seek + virtual Bool flush() override; ///< flush data to disk + virtual void nextLine(Char* buf = nullptr, Int bufSize = 0) override; ///< moves file position to after the next new-line + virtual Bool scanInt(Int& newInt) override; ///< return what gets read in as an integer at the current file position. + virtual Bool scanReal(Real& newReal) override; ///< return what gets read in as a float at the current file position. + virtual Bool scanString(AsciiString& newString) override; ///< return what gets read in as a string at the current file position. + /** + Allocate a buffer large enough to hold entire file, read + the entire file into the buffer, then close the file. + the buffer is owned by the caller, who is responsible + for freeing is (via delete[]). This is a Good Thing to + use because it minimizes memory copies for BIG files. + */ + virtual char* readEntireAndClose() override; + virtual File* convertToRAMFile() override; - void closeWithoutDelete(); - void closeFile(); +protected: + void closeWithoutDelete(); + void closeFile(); }; - - - //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/LocalFileSystem.h b/Core/GameEngine/Include/Common/LocalFileSystem.h index 837e8992287..155627af373 100644 --- a/Core/GameEngine/Include/Common/LocalFileSystem.h +++ b/Core/GameEngine/Include/Common/LocalFileSystem.h @@ -40,14 +40,14 @@ class LocalFileSystem : public SubsystemInterface virtual void reset() = 0; virtual void update() = 0; - virtual File * openFile(const Char *filename, Int access = File::NONE, size_t bufferSize = File::BUFFERSIZE) = 0; - virtual Bool doesFileExist(const Char *filename) const = 0; - virtual void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const = 0; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. - virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< see FileSystem.h - virtual Bool createDirectory(AsciiString directory) = 0; ///< see FileSystem.h - virtual AsciiString normalizePath(const AsciiString& filePath) const = 0; ///< see FileSystem.h + virtual File* openFile(const Char* filename, Int access = File::NONE, size_t bufferSize = File::BUFFERSIZE) = 0; + virtual Bool doesFileExist(const Char* filename) const = 0; + virtual void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const = 0; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. + virtual Bool getFileInfo(const AsciiString& filename, FileInfo* fileInfo) const = 0; ///< see FileSystem.h + virtual Bool createDirectory(AsciiString directory) = 0; ///< see FileSystem.h + virtual AsciiString normalizePath(const AsciiString& filePath) const = 0; ///< see FileSystem.h protected: }; -extern LocalFileSystem *TheLocalFileSystem; +extern LocalFileSystem* TheLocalFileSystem; diff --git a/Core/GameEngine/Include/Common/MapObject.h b/Core/GameEngine/Include/Common/MapObject.h index 0ef54835bbd..a1f7f2eac69 100644 --- a/Core/GameEngine/Include/Common/MapObject.h +++ b/Core/GameEngine/Include/Common/MapObject.h @@ -22,7 +22,6 @@ // // //////////////////////////////////////////////////////////////////////////////// - // MapObject.h // Class to encapsulate height map. // Author: John Ahlquist, April 2001 @@ -33,17 +32,13 @@ #include "Common/GameMemory.h" #include "GameClient/TerrainRoads.h" - - class WorldHeightMapInterfaceClass { public: - - virtual Int getBorderSize() = 0; - virtual Real getSeismicZVelocity(Int xIndex, Int yIndex) const = 0; - virtual void setSeismicZVelocity(Int xIndex, Int yIndex, Real value) = 0; - virtual Real getBilinearSampleSeismicZVelocity( Int x, Int y) = 0; - + virtual Int getBorderSize() = 0; + virtual Real getSeismicZVelocity(Int xIndex, Int yIndex) const = 0; + virtual void setSeismicZVelocity(Int xIndex, Int yIndex, Real value) = 0; + virtual Real getBilinearSampleSeismicZVelocity(Int x, Int y) = 0; }; /** MapObject class @@ -52,7 +47,8 @@ class WorldHeightMap; class RenderObjClass; class ThingTemplate; class Shadow; -enum WaypointID CPP_11(: Int); +enum WaypointID +CPP_11( : Int); #define MAP_XY_FACTOR (10.0f) //How wide and tall each height map square is in world space. #define MAP_HEIGHT_SCALE (MAP_XY_FACTOR/16.0f) //divide all map heights by 8. diff --git a/Core/GameEngine/Include/Common/MiniDumper.h b/Core/GameEngine/Include/Common/MiniDumper.h index 44c03e96ef1..43d506dc35a 100644 --- a/Core/GameEngine/Include/Common/MiniDumper.h +++ b/Core/GameEngine/Include/Common/MiniDumper.h @@ -19,9 +19,10 @@ #pragma once #ifdef RTS_ENABLE_CRASHDUMP -#include "DbgHelpLoader.h" + #include "DbgHelpLoader.h" -enum DumpType CPP_11(: Char) +enum DumpType +CPP_11( : Char) { // Smallest dump type with call stacks and some supporting variables DumpType_Minimal = 'M', diff --git a/Core/GameEngine/Include/Common/MiscAudio.h b/Core/GameEngine/Include/Common/MiscAudio.h index fa7b47f3c16..675e42503cc 100644 --- a/Core/GameEngine/Include/Common/MiscAudio.h +++ b/Core/GameEngine/Include/Common/MiscAudio.h @@ -22,7 +22,7 @@ // // //////////////////////////////////////////////////////////////////////////////// -///MiscAudio.h///////////////////////////////////////////////////////////////////////////////////// +/// MiscAudio.h///////////////////////////////////////////////////////////////////////////////////// // This file is for miscellaneous sound hooks that don't have another happy home. #pragma once @@ -33,40 +33,40 @@ struct MiscAudio { static const FieldParse m_fieldParseTable[]; - AudioEventRTS m_radarUnitUnderAttackSound; ///< radar sounds to play when unit under attack - AudioEventRTS m_radarHarvesterUnderAttackSound; ///< radar sounds to play when harvester under attack - AudioEventRTS m_radarStructureUnderAttackSound; ///< radar sounds to play when structure under attack - AudioEventRTS m_radarUnderAttackSound; ///< radar sounds to play when ? under attack - AudioEventRTS m_radarInfiltrationSound; ///< radar sounds to play when something is infiltrated - AudioEventRTS m_radarOnlineSound; ///< radar sounds to play when radar goes online - AudioEventRTS m_radarOfflineSound; ///< radar sounds to play when radar goes offline - AudioEventRTS m_defectorTimerTickSound; ///< snd to play during transient invulnerability while defecting // lorenzen - AudioEventRTS m_defectorTimerDingSound; ///< snd to play when you become vulnerable again // lorenzen - AudioEventRTS m_lockonTickSound; ///< snd to play during stealth-fighter-lockon period - AudioEventRTS m_allCheerSound; ///< snd to play when user presses 'cheer' key - AudioEventRTS m_battleCrySound; ///< snd to play when user presses 'battlecry' key - AudioEventRTS m_guiClickSound; ///< snd to play when user presses button in GUI - AudioEventRTS m_noCanDoSound; ///< Global "No Can Do" sound - AudioEventRTS m_stealthDiscoveredSound; ///< I have just discovered an enemy stealth unit - AudioEventRTS m_stealthNeutralizedSound; ///< One of my stealthed units has just been discovered by the enemy - AudioEventRTS m_moneyDepositSound; ///< Money was deposited in my bank - AudioEventRTS m_moneyWithdrawSound; ///< Money was withdrawn from my bank - AudioEventRTS m_buildingDisabled; ///< Building has lost power, been hit with an EMP, or disable hacked. - AudioEventRTS m_buildingReenabled; ///< Building has recovered from being disabled. - AudioEventRTS m_vehicleDisabled; ///< Vehicle has been disabled via EMP or hacker attack. - AudioEventRTS m_vehicleReenabled; ///< Vehicle has recovered from being disabled. - AudioEventRTS m_splatterVehiclePilotsBrain; ///< Pilot has been sniped by Jarmen Kell. - AudioEventRTS m_terroristInCarMoveVoice; ///< Terrorist issues a move order while in a car. - AudioEventRTS m_terroristInCarAttackVoice; ///< Terrorist issues attack order while in a car. - AudioEventRTS m_terroristInCarSelectVoice; ///< Terrorist is selected while in a car. - AudioEventRTS m_crateHeal; ///< When heal crate is picked up. - AudioEventRTS m_crateShroud; ///< When shroud crate is picked up. - AudioEventRTS m_crateSalvage; ///< When salvage crate is picked up. - AudioEventRTS m_crateFreeUnit; ///< When free unit crate is picked up. - AudioEventRTS m_crateMoney; ///< When money crate is picked up. - AudioEventRTS m_unitPromoted; ///< Unit is promoted. - AudioEventRTS m_repairSparks; ///< Battle drone repairs unit. - AudioEventRTS m_sabotageShutDownBuilding; ///< When Saboteur hits a building - AudioEventRTS m_sabotageResetTimerBuilding; ///< When Saboteur hits a building - AudioEventRTS m_aircraftWheelScreech; ///< When a jet lands on a runway. + AudioEventRTS m_radarUnitUnderAttackSound; ///< radar sounds to play when unit under attack + AudioEventRTS m_radarHarvesterUnderAttackSound; ///< radar sounds to play when harvester under attack + AudioEventRTS m_radarStructureUnderAttackSound; ///< radar sounds to play when structure under attack + AudioEventRTS m_radarUnderAttackSound; ///< radar sounds to play when ? under attack + AudioEventRTS m_radarInfiltrationSound; ///< radar sounds to play when something is infiltrated + AudioEventRTS m_radarOnlineSound; ///< radar sounds to play when radar goes online + AudioEventRTS m_radarOfflineSound; ///< radar sounds to play when radar goes offline + AudioEventRTS m_defectorTimerTickSound; ///< snd to play during transient invulnerability while defecting // lorenzen + AudioEventRTS m_defectorTimerDingSound; ///< snd to play when you become vulnerable again // lorenzen + AudioEventRTS m_lockonTickSound; ///< snd to play during stealth-fighter-lockon period + AudioEventRTS m_allCheerSound; ///< snd to play when user presses 'cheer' key + AudioEventRTS m_battleCrySound; ///< snd to play when user presses 'battlecry' key + AudioEventRTS m_guiClickSound; ///< snd to play when user presses button in GUI + AudioEventRTS m_noCanDoSound; ///< Global "No Can Do" sound + AudioEventRTS m_stealthDiscoveredSound; ///< I have just discovered an enemy stealth unit + AudioEventRTS m_stealthNeutralizedSound; ///< One of my stealthed units has just been discovered by the enemy + AudioEventRTS m_moneyDepositSound; ///< Money was deposited in my bank + AudioEventRTS m_moneyWithdrawSound; ///< Money was withdrawn from my bank + AudioEventRTS m_buildingDisabled; ///< Building has lost power, been hit with an EMP, or disable hacked. + AudioEventRTS m_buildingReenabled; ///< Building has recovered from being disabled. + AudioEventRTS m_vehicleDisabled; ///< Vehicle has been disabled via EMP or hacker attack. + AudioEventRTS m_vehicleReenabled; ///< Vehicle has recovered from being disabled. + AudioEventRTS m_splatterVehiclePilotsBrain; ///< Pilot has been sniped by Jarmen Kell. + AudioEventRTS m_terroristInCarMoveVoice; ///< Terrorist issues a move order while in a car. + AudioEventRTS m_terroristInCarAttackVoice; ///< Terrorist issues attack order while in a car. + AudioEventRTS m_terroristInCarSelectVoice; ///< Terrorist is selected while in a car. + AudioEventRTS m_crateHeal; ///< When heal crate is picked up. + AudioEventRTS m_crateShroud; ///< When shroud crate is picked up. + AudioEventRTS m_crateSalvage; ///< When salvage crate is picked up. + AudioEventRTS m_crateFreeUnit; ///< When free unit crate is picked up. + AudioEventRTS m_crateMoney; ///< When money crate is picked up. + AudioEventRTS m_unitPromoted; ///< Unit is promoted. + AudioEventRTS m_repairSparks; ///< Battle drone repairs unit. + AudioEventRTS m_sabotageShutDownBuilding; ///< When Saboteur hits a building + AudioEventRTS m_sabotageResetTimerBuilding; ///< When Saboteur hits a building + AudioEventRTS m_aircraftWheelScreech; ///< When a jet lands on a runway. }; diff --git a/Core/GameEngine/Include/Common/ObjectStatusTypes.h b/Core/GameEngine/Include/Common/ObjectStatusTypes.h index affa254c9e0..dc3c3c8b57c 100644 --- a/Core/GameEngine/Include/Common/ObjectStatusTypes.h +++ b/Core/GameEngine/Include/Common/ObjectStatusTypes.h @@ -37,7 +37,8 @@ //------------------------------------------------------------------------------------------------- /** Object status types */ //------------------------------------------------------------------------------------------------- -enum ObjectStatusTypes CPP_11(: Int) +enum ObjectStatusTypes +CPP_11( : Int) { //These are saved. Do not insert or remove any! diff --git a/Core/GameEngine/Include/Common/OptionPreferences.h b/Core/GameEngine/Include/Common/OptionPreferences.h index 2bacaa07105..4733b527acb 100644 --- a/Core/GameEngine/Include/Common/OptionPreferences.h +++ b/Core/GameEngine/Include/Common/OptionPreferences.h @@ -87,7 +87,7 @@ class OptionPreferences : public UserPreferences Int getIdealStaticGameDetail(); Real getGammaValue(); Int getTextureReduction(); - void getResolution(Int *xres, Int *yres); + void getResolution(Int* xres, Int* yres); Bool get3DShadowsEnabled(); Bool get2DShadowsEnabled(); Bool getCloudShadowsEnabled(); diff --git a/Core/GameEngine/Include/Common/RAMFile.h b/Core/GameEngine/Include/Common/RAMFile.h index b1f639f161e..9edd45e673b 100644 --- a/Core/GameEngine/Include/Common/RAMFile.h +++ b/Core/GameEngine/Include/Common/RAMFile.h @@ -53,8 +53,6 @@ // Forward References //---------------------------------------------------------------------------- - - //---------------------------------------------------------------------------- // Type Defines //---------------------------------------------------------------------------- @@ -63,64 +61,57 @@ // RAMFile //=============================== /** - * File abstraction for standard C file operators: open, close, lseek, read, write - */ + * File abstraction for standard C file operators: open, close, lseek, read, write + */ //=============================== class RAMFile : public File { MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(RAMFile, "RAMFile") - protected: - - Char *m_data; ///< File data in memory - Int m_pos; ///< current read position - Int m_size; ///< size of file in memory - - public: - - RAMFile(); - //virtual ~RAMFile(); - - - virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = 0 ) override; ///< Open a file for access - virtual void close() override; ///< Close the file - virtual Int read( void *buffer, Int bytes ) override; ///< Read the specified number of bytes in to buffer: See File::read - virtual Int readChar() override; ///< Read a character from the file - virtual Int readWideChar() override; ///< Read a wide character from the file - virtual Int write( const void *buffer, Int bytes ) override; ///< Write the specified number of bytes from the buffer: See File::write - virtual Int writeFormat( const Char* format, ... ) override; ///< Write the formatted string to the file - virtual Int writeFormat( const WideChar* format, ... ) override; ///< Write the formatted string to the file - virtual Int writeChar( const Char* character ) override; ///< Write a character to the file - virtual Int writeChar( const WideChar* character ) override; ///< Write a wide character to the file - virtual Int seek( Int new_pos, seekMode mode = CURRENT ) override; ///< Set file position: See File::seek - virtual Bool flush() override; ///< flush data to disk - virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) override; ///< moves current position to after the next new-line - - virtual Bool scanInt(Int &newInt) override; ///< return what gets read as an integer from the current memory position. - virtual Bool scanReal(Real &newReal) override; ///< return what gets read as a float from the current memory position. - virtual Bool scanString(AsciiString &newString) override; ///< return what gets read as a string from the current memory position. - - virtual Bool open( File *file ); ///< Open file for fast RAM access - virtual Bool openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size); ///< copy file data from the given file at the given offset for the given size. - virtual Bool copyDataToFile(File *localFile); ///< write the contents of the RAM file to the given local file. This could be REALLY slow. - - /** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. - */ - virtual char* readEntireAndClose() override; - virtual File* convertToRAMFile() override; - - protected: - - void closeFile(); -}; - - +protected: + Char* m_data; ///< File data in memory + Int m_pos; ///< current read position + Int m_size; ///< size of file in memory + +public: + RAMFile(); + // virtual ~RAMFile(); + + virtual Bool open(const Char* filename, Int access = NONE, size_t bufferSize = 0) override; ///< Open a file for access + virtual void close() override; ///< Close the file + virtual Int read(void* buffer, Int bytes) override; ///< Read the specified number of bytes in to buffer: See File::read + virtual Int readChar() override; ///< Read a character from the file + virtual Int readWideChar() override; ///< Read a wide character from the file + virtual Int write(const void* buffer, Int bytes) override; ///< Write the specified number of bytes from the buffer: See File::write + virtual Int writeFormat(const Char* format, ...) override; ///< Write the formatted string to the file + virtual Int writeFormat(const WideChar* format, ...) override; ///< Write the formatted string to the file + virtual Int writeChar(const Char* character) override; ///< Write a character to the file + virtual Int writeChar(const WideChar* character) override; ///< Write a wide character to the file + virtual Int seek(Int new_pos, seekMode mode = CURRENT) override; ///< Set file position: See File::seek + virtual Bool flush() override; ///< flush data to disk + virtual void nextLine(Char* buf = nullptr, Int bufSize = 0) override; ///< moves current position to after the next new-line + + virtual Bool scanInt(Int& newInt) override; ///< return what gets read as an integer from the current memory position. + virtual Bool scanReal(Real& newReal) override; ///< return what gets read as a float from the current memory position. + virtual Bool scanString(AsciiString& newString) override; ///< return what gets read as a string from the current memory position. + + virtual Bool open(File* file); ///< Open file for fast RAM access + virtual Bool openFromArchive(File* archiveFile, const AsciiString& filename, Int offset, Int size); ///< copy file data from the given file at the given offset for the given size. + virtual Bool copyDataToFile(File* localFile); ///< write the contents of the RAM file to the given local file. This could be REALLY slow. + + /** + Allocate a buffer large enough to hold entire file, read + the entire file into the buffer, then close the file. + the buffer is owned by the caller, who is responsible + for freeing is (via delete[]). This is a Good Thing to + use because it minimizes memory copies for BIG files. + */ + virtual char* readEntireAndClose() override; + virtual File* convertToRAMFile() override; +protected: + void closeFile(); +}; //---------------------------------------------------------------------------- // Inlining diff --git a/Core/GameEngine/Include/Common/Radar.h b/Core/GameEngine/Include/Common/Radar.h index 5e170c261fc..ffdde6457d9 100644 --- a/Core/GameEngine/Include/Common/Radar.h +++ b/Core/GameEngine/Include/Common/Radar.h @@ -33,7 +33,7 @@ #include "Lib/BaseType.h" #include "Common/SubsystemInterface.h" #include "Common/GameMemory.h" -#include "GameClient/Display.h" // for ShroudLevel +#include "GameClient/Display.h" // for ShroudLevel #include "GameClient/Color.h" // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// @@ -50,15 +50,16 @@ class TerrainLogic; // enum { - RADAR_CELL_WIDTH = 128, // radar created at this horz resolution - RADAR_CELL_HEIGHT = 128 // radar created at this vert resolution + RADAR_CELL_WIDTH = 128, // radar created at this horz resolution + RADAR_CELL_HEIGHT = 128 // radar created at this vert resolution }; //------------------------------------------------------------------------------------------------- /** These event types determine the colors radar events happen in to make it easier for us - * to play events with a consistent color scheme */ + * to play events with a consistent color scheme */ //------------------------------------------------------------------------------------------------- -enum RadarEventType CPP_11(: Int) +enum RadarEventType +CPP_11( : Int) { RADAR_EVENT_INVALID = 0, RADAR_EVENT_CONSTRUCTION, diff --git a/Core/GameEngine/Include/Common/RandomValue.h b/Core/GameEngine/Include/Common/RandomValue.h index 8cc97d5d844..a68ceb52cfe 100644 --- a/Core/GameEngine/Include/Common/RandomValue.h +++ b/Core/GameEngine/Include/Common/RandomValue.h @@ -31,8 +31,8 @@ #include "Lib/BaseType.h" extern void InitRandom(); -extern void InitRandom( UnsignedInt seed ); -extern UnsignedInt GetGameLogicRandomSeed(); ///< Get the seed (used for replays) -extern UnsignedInt GetGameLogicRandomSeedCRC();///< Get the seed (used for CRCs) +extern void InitRandom(UnsignedInt seed); +extern UnsignedInt GetGameLogicRandomSeed(); ///< Get the seed (used for replays) +extern UnsignedInt GetGameLogicRandomSeedCRC(); ///< Get the seed (used for CRCs) //-------------------------------------------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/ReplaySimulation.h b/Core/GameEngine/Include/Common/ReplaySimulation.h index 219f6233709..93774a8d069 100644 --- a/Core/GameEngine/Include/Common/ReplaySimulation.h +++ b/Core/GameEngine/Include/Common/ReplaySimulation.h @@ -21,12 +21,11 @@ class ReplaySimulation { public: - // TheSuperHackers @feature helmutbuhler 13/04/2025 // Simulate a list of replays without graphics. // Returns exit code 1 if mismatch or other error occurred // Returns exit code 0 if all replays were successfully simulated without mismatches - static int simulateReplays(const std::vector &filenames, int maxProcesses); + static int simulateReplays(const std::vector& filenames, int maxProcesses); static void stop() { s_isRunning = false; } @@ -35,13 +34,11 @@ class ReplaySimulation static UnsignedInt getReplayCount() { return s_replayCount; } private: - - static int simulateReplaysInThisProcess(const std::vector &filenames); - static int simulateReplaysInWorkerProcesses(const std::vector &filenames, int maxProcesses); - static std::vector resolveFilenameWildcards(const std::vector &filenames); + static int simulateReplaysInThisProcess(const std::vector& filenames); + static int simulateReplaysInWorkerProcesses(const std::vector& filenames, int maxProcesses); + static std::vector resolveFilenameWildcards(const std::vector& filenames); private: - static Bool s_isRunning; static UnsignedInt s_replayIndex; static UnsignedInt s_replayCount; diff --git a/Core/GameEngine/Include/Common/STLTypedefs.h b/Core/GameEngine/Include/Common/STLTypedefs.h index 0dc2ede1dc3..6985a299c50 100644 --- a/Core/GameEngine/Include/Common/STLTypedefs.h +++ b/Core/GameEngine/Include/Common/STLTypedefs.h @@ -46,8 +46,8 @@ //----------------------------------------------------------------------------- // srj sez: this must come first, first, first. -#define _STLP_USE_NEWALLOC 1 -//#define _STLP_USE_CUSTOM_NEWALLOC STLSpecialAlloc +#define _STLP_USE_NEWALLOC 1 +// #define _STLP_USE_CUSTOM_NEWALLOC STLSpecialAlloc class STLSpecialAlloc; //----------------------------------------------------------------------------- @@ -58,10 +58,10 @@ class STLSpecialAlloc; //----------------------------------------------------------------------------- - // FORWARD DECLARATIONS class Object; -enum NameKeyType CPP_11(: Int); +enum NameKeyType +CPP_11( : Int); enum ObjectID CPP_11(: Int); enum DrawableID CPP_11(: Int); enum ParticleSystemID CPP_11(: Int); diff --git a/Core/GameEngine/Include/Common/Snapshot.h b/Core/GameEngine/Include/Common/Snapshot.h index fa223c6802d..2aa47ffb330 100644 --- a/Core/GameEngine/Include/Common/Snapshot.h +++ b/Core/GameEngine/Include/Common/Snapshot.h @@ -41,27 +41,24 @@ class Xfer; class Snapshot { -friend class GameState; -friend class XferLoad; -friend class XferSave; -friend class XferCRC; + friend class GameState; + friend class XferLoad; + friend class XferSave; + friend class XferCRC; public: - Snapshot(); ~Snapshot(); protected: - /// run the "light" crc check on this data structure - virtual void crc( Xfer *xfer ) = 0; + virtual void crc(Xfer* xfer) = 0; /** run save, load, or deep CRC check on this data structure, the type depends on the setup of the Xfer pointer */ - virtual void xfer( Xfer *xfer ) = 0; + virtual void xfer(Xfer* xfer) = 0; /** post process phase for loading save games. All save systems have their xfer run using XferLoad mode, and then all systems each have their post process run */ virtual void loadPostProcess() = 0; - }; diff --git a/Core/GameEngine/Include/Common/StreamingArchiveFile.h b/Core/GameEngine/Include/Common/StreamingArchiveFile.h index 72e3057afef..262dbcc85fd 100644 --- a/Core/GameEngine/Include/Common/StreamingArchiveFile.h +++ b/Core/GameEngine/Include/Common/StreamingArchiveFile.h @@ -53,8 +53,6 @@ // Forward References //---------------------------------------------------------------------------- - - //---------------------------------------------------------------------------- // Type Defines //---------------------------------------------------------------------------- @@ -63,49 +61,67 @@ // StreamingArchiveFile //=============================== /** - * File abstraction for standard C file operators: open, close, lseek, read, write - */ + * File abstraction for standard C file operators: open, close, lseek, read, write + */ //=============================== class StreamingArchiveFile : public RAMFile { MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(StreamingArchiveFile, "StreamingArchiveFile") - protected: - - File *m_file; ///< The archive file that I came from - Int m_startingPos; ///< My starting position in the archive - Int m_size; ///< My length - Int m_curPos; ///< My current position. - - public: - - StreamingArchiveFile(); - //virtual ~StreamingArchiveFile(); - - - virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = BUFFERSIZE ) override; ///< Open a file for access - virtual void close() override; ///< Close the file - virtual Int read( void *buffer, Int bytes ) override; ///< Read the specified number of bytes in to buffer: See File::read - virtual Int write( const void *buffer, Int bytes ) override; ///< Write the specified number of bytes from the buffer: See File::write - virtual Int seek( Int new_pos, seekMode mode = CURRENT ) override; ///< Set file position: See File::seek - - // Ini's should not be parsed with streaming files, that's just dumb. - virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) override { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); } - virtual Bool scanInt(Int &newInt) override { DEBUG_CRASH(("Should not call scanInt on a streaming file.")); return FALSE; } - virtual Bool scanReal(Real &newReal) override { DEBUG_CRASH(("Should not call scanReal on a streaming file.")); return FALSE; } - virtual Bool scanString(AsciiString &newString) override { DEBUG_CRASH(("Should not call scanString on a streaming file.")); return FALSE; } - - virtual Bool open( File *file ) override; ///< Open file for fast RAM access - virtual Bool openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size) override; ///< copy file data from the given file at the given offset for the given size. - virtual Bool copyDataToFile(File *localFile) override { DEBUG_CRASH(("Are you sure you meant to copyDataToFile on a streaming file?")); return FALSE; } - - virtual char* readEntireAndClose() override { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return nullptr; } - virtual File* convertToRAMFile() override { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return this; } +protected: + File* m_file; ///< The archive file that I came from + Int m_startingPos; ///< My starting position in the archive + Int m_size; ///< My length + Int m_curPos; ///< My current position. + +public: + StreamingArchiveFile(); + // virtual ~StreamingArchiveFile(); + + virtual Bool open(const Char* filename, Int access = NONE, size_t bufferSize = BUFFERSIZE) override; ///< Open a file for access + virtual void close() override; ///< Close the file + virtual Int read(void* buffer, Int bytes) override; ///< Read the specified number of bytes in to buffer: See File::read + virtual Int write(const void* buffer, Int bytes) override; ///< Write the specified number of bytes from the buffer: See File::write + virtual Int seek(Int new_pos, seekMode mode = CURRENT) override; ///< Set file position: See File::seek + + // Ini's should not be parsed with streaming files, that's just dumb. + virtual void nextLine(Char* buf = nullptr, Int bufSize = 0) override { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); } + virtual Bool scanInt(Int& newInt) override + { + DEBUG_CRASH(("Should not call scanInt on a streaming file.")); + return FALSE; + } + virtual Bool scanReal(Real& newReal) override + { + DEBUG_CRASH(("Should not call scanReal on a streaming file.")); + return FALSE; + } + virtual Bool scanString(AsciiString& newString) override + { + DEBUG_CRASH(("Should not call scanString on a streaming file.")); + return FALSE; + } + + virtual Bool open(File* file) override; ///< Open file for fast RAM access + virtual Bool openFromArchive(File* archiveFile, const AsciiString& filename, Int offset, Int size) override; ///< copy file data from the given file at the given offset for the given size. + virtual Bool copyDataToFile(File* localFile) override + { + DEBUG_CRASH(("Are you sure you meant to copyDataToFile on a streaming file?")); + return FALSE; + } + + virtual char* readEntireAndClose() override + { + DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); + return nullptr; + } + virtual File* convertToRAMFile() override + { + DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); + return this; + } }; - - - //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/SubsystemInterface.h b/Core/GameEngine/Include/Common/SubsystemInterface.h index fba66ec1203..ae147d629b2 100644 --- a/Core/GameEngine/Include/Common/SubsystemInterface.h +++ b/Core/GameEngine/Include/Common/SubsystemInterface.h @@ -36,88 +36,87 @@ class Xfer; //------------------------------------------------------------------------------------------------- /** This is the abstract base class from which all game engine subsystems should derive from. - * In order to provide consistent behaviors across all these systems, any implementation - * must obey the rules defined in here - * - * Nothing about the subsystems is automatic, this interface does not wrap up automated - * functions, it is only here to provide a basic interface and rules for behavior - * all subsystems - */ + * In order to provide consistent behaviors across all these systems, any implementation + * must obey the rules defined in here + * + * Nothing about the subsystems is automatic, this interface does not wrap up automated + * functions, it is only here to provide a basic interface and rules for behavior + * all subsystems + */ class SubsystemInterface { public: - //----------------------------------------------------------------------------------------------- /** - Constructors should initialize any data to a valid state. That DOES NOT mean - * the data has default values (something done in the init() method), only that - * nothing is left pointing to garbage, un-initialized memory. In most cases - * this probably means just setting members to zero or nullptr. - */ + * the data has default values (something done in the init() method), only that + * nothing is left pointing to garbage, un-initialized memory. In most cases + * this probably means just setting members to zero or nullptr. + */ SubsystemInterface(); //----------------------------------------------------------------------------------------------- /** - Free any resources allocated for this class. - * - * - DO NOT throw exceptions during any destruction ever, and do not call other - * methods that have the possibility of throwing exceptions. Try to keep it - * simple and keep as much work actually inside the destructor as possible. - */ + * + * - DO NOT throw exceptions during any destruction ever, and do not call other + * methods that have the possibility of throwing exceptions. Try to keep it + * simple and keep as much work actually inside the destructor as possible. + */ virtual ~SubsystemInterface(); //----------------------------------------------------------------------------------------------- /** - Assign any default values to data required for the class - * - * - Allocate any memory and resources needed throughout the lifetime of the class - */ + * + * - Allocate any memory and resources needed throughout the lifetime of the class + */ virtual void init() = 0; //----------------------------------------------------------------------------------------------- /** - Called for all subsystems after all other Subsystems are inited. - * (allows for initializing inter-system dependencies) - */ - virtual void postProcessLoad() { } + * (allows for initializing inter-system dependencies) + */ + virtual void postProcessLoad() {} //----------------------------------------------------------------------------------------------- /** - Any system should be able to reset all data and go back to an empty state - * that is ready to accept a completely new set of data. Reset() can expect - * to be used in the context of resetting the engine in order to start or - * load a new game. - * - * - Do NOT free and re-allocate resources needed, where possible reorganize and - * re-initialize the resources already allocated. - * - * - After a reset, the system does not need to be in EXACTLY the same state as a - * fresh instantiation. If there are persistent state information for the - * system make sure you maintain it while restoring or re-initializing other - * transient parts. - */ + * that is ready to accept a completely new set of data. Reset() can expect + * to be used in the context of resetting the engine in order to start or + * load a new game. + * + * - Do NOT free and re-allocate resources needed, where possible reorganize and + * re-initialize the resources already allocated. + * + * - After a reset, the system does not need to be in EXACTLY the same state as a + * fresh instantiation. If there are persistent state information for the + * system make sure you maintain it while restoring or re-initializing other + * transient parts. + */ virtual void reset() = 0; //----------------------------------------------------------------------------------------------- /** - Update methods are the place to do system per frame processing. You - * should call the system update once each time through the game loop - * to service the system. - * - * - Note that currently the GameClient and GameLogic will be updating - * at different rates where the logic is running real time, and the - * client will adjust how many loops can be done during one server - * time slice in order to improve performance on low end machines. - */ + * should call the system update once each time through the game loop + * to service the system. + * + * - Note that currently the GameClient and GameLogic will be updating + * at different rates where the logic is running real time, and the + * client will adjust how many loops can be done during one server + * time slice in order to improve performance on low end machines. + */ virtual void update() = 0; - - virtual void draw(){DEBUG_CRASH(("Shouldn't call base class. jba."));} + virtual void draw() { DEBUG_CRASH(("Shouldn't call base class. jba.")); } #ifdef DUMP_PERF_STATS void UPDATE(); void DRAW(); - Real getUpdateTime() {return m_curUpdateTime;} - Real getDrawTime() {return m_curDrawTime;} - Bool doDumpUpdate() {return m_dumpUpdate;} - Bool doDumpDraw() {return m_dumpDraw;} - static Real getTotalTime() {return s_msConsumed;} - static void clearTotalTime() {s_msConsumed = 0;} + Real getUpdateTime() { return m_curUpdateTime; } + Real getDrawTime() { return m_curDrawTime; } + Bool doDumpUpdate() { return m_dumpUpdate; } + Bool doDumpDraw() { return m_dumpDraw; } + static Real getTotalTime() { return s_msConsumed; } + static void clearTotalTime() { s_msConsumed = 0; } + protected: static Real s_msConsumed; Real m_startTimeConsumed; @@ -128,26 +127,25 @@ class SubsystemInterface Bool m_dumpUpdate; Bool m_dumpDraw; #else - void UPDATE() {update();} - void DRAW() {draw();} + void UPDATE() { update(); } + void DRAW() { draw(); } #endif protected: AsciiString m_name; -public: - AsciiString getName() {return m_name;} - void setName(AsciiString name) {m_name = name;} +public: + AsciiString getName() { return m_name; } + void setName(AsciiString name) { m_name = name; } }; //------------------------------------------------------------------------------------------------- class SubsystemInterfaceList { public: - SubsystemInterfaceList(); ~SubsystemInterfaceList(); - void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer *pXfer, AsciiString name=""); + void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer* pXfer, AsciiString name = ""); void addSubsystem(SubsystemInterface* sys); void removeSubsystem(SubsystemInterface* sys); void postProcessLoadAll(); @@ -158,11 +156,9 @@ class SubsystemInterfaceList #endif private: - typedef std::vector SubsystemList; SubsystemList m_subsystems; SubsystemList m_allSubsystems; - }; extern SubsystemInterfaceList* TheSubsystemList; diff --git a/Core/GameEngine/Include/Common/UnicodeString.h b/Core/GameEngine/Include/Common/UnicodeString.h index a6fbcab367e..e4a3247bde7 100644 --- a/Core/GameEngine/Include/Common/UnicodeString.h +++ b/Core/GameEngine/Include/Common/UnicodeString.h @@ -54,190 +54,187 @@ class AsciiString; // ----------------------------------------------------- /** - UnicodeString is the fundamental double-byte string type used in the Generals - code base, and should be preferred over all other string constructions - (e.g., array of WideChar, STL string<>, WWVegas StringClass, etc.) + UnicodeString is the fundamental double-byte string type used in the Generals + code base, and should be preferred over all other string constructions + (e.g., array of WideChar, STL string<>, WWVegas StringClass, etc.) - Of course, other string setups may be used when necessary or appropriate! + Of course, other string setups may be used when necessary or appropriate! - UnicodeString is modeled after the MFC CString class, with some minor - syntactic differences to keep in line with our coding conventions. + UnicodeString is modeled after the MFC CString class, with some minor + syntactic differences to keep in line with our coding conventions. - Basically, UnicodeString allows you to treat a string as an intrinsic - type, rather analogous to 'int' -- when passed by value, a new string - is created, and modifying the new string doesn't modify the original. - This is done fairly efficiently, so that no new memory allocation is done - unless the string is actually modified. + Basically, UnicodeString allows you to treat a string as an intrinsic + type, rather analogous to 'int' -- when passed by value, a new string + is created, and modifying the new string doesn't modify the original. + This is done fairly efficiently, so that no new memory allocation is done + unless the string is actually modified. - Naturally, UnicodeString handles all memory issues, so there's no need - to do anything to free memory... just allow the UnicodeString's - destructor to run. + Naturally, UnicodeString handles all memory issues, so there's no need + to do anything to free memory... just allow the UnicodeString's + destructor to run. - UnicodeStrings are suitable for use as automatic, member, or static variables. + UnicodeStrings are suitable for use as automatic, member, or static variables. */ class UnicodeString { private: - // Note, this is a Plain Old Data Structure... don't // add a ctor/dtor, 'cuz they won't ever be called. struct UnicodeStringData { #if defined(RTS_DEBUG) - const WideChar* m_debugptr; // just makes it easier to read in the debugger + const WideChar* m_debugptr; // just makes it easier to read in the debugger #endif - unsigned short m_refCount; // reference count - unsigned short m_numCharsAllocated; // length of data allocated + unsigned short m_refCount; // reference count + unsigned short m_numCharsAllocated; // length of data allocated // WideChar m_stringdata[]; - WideChar* peek() { return (WideChar*)(this+1); } + WideChar* peek() { return (WideChar*)(this + 1); } }; - #ifdef RTS_DEBUG +#ifdef RTS_DEBUG void validate() const; - #else - void validate() const { } - #endif +#else + void validate() const {} +#endif protected: - UnicodeStringData* m_data; // pointer to ref counted string data + UnicodeStringData* m_data; // pointer to ref counted string data WideChar* peek() const; void releaseBuffer(); void ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveData, const WideChar* strToCpy, const WideChar* strToCat); public: - typedef WideChar value_type; typedef value_type* pointer; typedef const value_type* const_pointer; enum { - MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va - MAX_LEN = 32767 ///< max total len of any UnicodeString, in chars + MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va + MAX_LEN = 32767 ///< max total len of any UnicodeString, in chars }; - /** - This is a convenient global used to indicate the empty - string, so we don't need to construct temporaries - for such a common thing. + This is a convenient global used to indicate the empty + string, so we don't need to construct temporaries + for such a common thing. */ static const UnicodeString TheEmptyString; /** - Default constructor -- construct a new, empty UnicodeString. + Default constructor -- construct a new, empty UnicodeString. */ UnicodeString(); /** - Copy constructor -- make this UnicodeString identical to the - other UnicodeString. (This is actually quite efficient, because - they will simply share the same string and increment the - refcount.) + Copy constructor -- make this UnicodeString identical to the + other UnicodeString. (This is actually quite efficient, because + they will simply share the same string and increment the + refcount.) */ UnicodeString(const UnicodeString& stringSrc); /** - Constructor -- from a literal string. Constructs an UnicodeString - with the given string. Note that a copy of the string is made; - the input ptr is not saved. - Note that this is no longer explicit, as the conversion is almost - always wanted, anyhow. + Constructor -- from a literal string. Constructs an UnicodeString + with the given string. Note that a copy of the string is made; + the input ptr is not saved. + Note that this is no longer explicit, as the conversion is almost + always wanted, anyhow. */ UnicodeString(const WideChar* s); /** - Constructs an UnicodeString with the given string and length. - The length must not be larger than the actual string length. + Constructs an UnicodeString with the given string and length. + The length must not be larger than the actual string length. */ UnicodeString(const WideChar* s, int len); /** - Destructor. Not too exciting... clean up the works and such. + Destructor. Not too exciting... clean up the works and such. */ ~UnicodeString(); /** - Return the length, in characters, of the string up to the first zero or null terminator. + Return the length, in characters, of the string up to the first zero or null terminator. */ int getLength() const; /** - Return the number of bytes used by the string up to the first zero or null terminator. + Return the number of bytes used by the string up to the first zero or null terminator. */ int getByteCount() const; /** - Return true iff the length of the string is zero. Equivalent - to (getLength() == 0) but slightly more efficient. + Return true iff the length of the string is zero. Equivalent + to (getLength() == 0) but slightly more efficient. */ Bool isEmpty() const; /** - Make the string empty. Equivalent to (str = "") but slightly more efficient. + Make the string empty. Equivalent to (str = "") but slightly more efficient. */ void clear(); /** - Return the character and the given (zero-based) index into the string. - No range checking is done (except in debug mode). + Return the character and the given (zero-based) index into the string. + No range checking is done (except in debug mode). */ WideChar getCharAt(int index) const; /** - Return a pointer to the (null-terminated) string. Note that this is - a const pointer: do NOT change this! It is imperative that it be - impossible (or at least, really difficuly) for someone to change our - private data, since it might be shared amongst other UnicodeStrings. + Return a pointer to the (null-terminated) string. Note that this is + a const pointer: do NOT change this! It is imperative that it be + impossible (or at least, really difficuly) for someone to change our + private data, since it might be shared amongst other UnicodeStrings. */ const WideChar* str() const; /** - Makes sure there is room for a string of len+1 characters, and - returns a pointer to the string buffer. This ensures that the - string buffer is NOT shared. This is intended for the file reader, - that is reading new strings in from a file. jba. + Makes sure there is room for a string of len+1 characters, and + returns a pointer to the string buffer. This ensures that the + string buffer is NOT shared. This is intended for the file reader, + that is reading new strings in from a file. jba. */ WideChar* getBufferForRead(Int len); /** - Replace the contents of self with the given string. - (This is actually quite efficient, because - they will simply share the same string and increment the - refcount.) + Replace the contents of self with the given string. + (This is actually quite efficient, because + they will simply share the same string and increment the + refcount.) */ void set(const UnicodeString& stringSrc); /** - Replace the contents of self with the given string. - Note that a copy of the string is made; the input ptr is not saved. + Replace the contents of self with the given string. + Note that a copy of the string is made; the input ptr is not saved. */ void set(const WideChar* s); /** - Replace the contents of self with the given string and length. - Note that a copy of the string is made; the input ptr is not saved. - The length must not be larger than the actual string length. + Replace the contents of self with the given string and length. + Note that a copy of the string is made; the input ptr is not saved. + The length must not be larger than the actual string length. */ void set(const WideChar* s, int len); /** - replace contents of self with the given string. Note the - nomenclature is translate rather than set; this is because - not all single-byte strings translate one-for-one into - UnicodeStrings, so some data manipulation may be necessary, - and the resulting strings may not be equivalent. + replace contents of self with the given string. Note the + nomenclature is translate rather than set; this is because + not all single-byte strings translate one-for-one into + UnicodeStrings, so some data manipulation may be necessary, + and the resulting strings may not be equivalent. */ void translate(const AsciiString& stringSrc); /** - Concatenate the given string onto self. + Concatenate the given string onto self. */ void concat(const UnicodeString& stringSrc); /** - Concatenate the given string onto self. + Concatenate the given string onto self. */ void concat(const WideChar* s); /** - Concatenate the given character onto self. + Concatenate the given character onto self. */ void concat(const WideChar c); @@ -257,104 +254,103 @@ class UnicodeString void trimEnd(const WideChar c); /** - Remove the final character in the string. If the string is empty, - do nothing. (This is a rather dorky method, but used a lot in - text editing, thus its presence here.) + Remove the final character in the string. If the string is empty, + do nothing. (This is a rather dorky method, but used a lot in + text editing, thus its presence here.) */ void removeLastChar(); /** - Remove the final charCount characters in the string. If the string is empty, - do nothing. + Remove the final charCount characters in the string. If the string is empty, + do nothing. */ void truncateBy(const Int charCount); /** - Truncate the string to a length of maxLength characters, not including null termination, - by removing from the end. If the string is empty or shorter than maxLength, do nothing. + Truncate the string to a length of maxLength characters, not including null termination, + by removing from the end. If the string is empty or shorter than maxLength, do nothing. */ void truncateTo(const Int maxLength); /** - Analogous to sprintf() -- this formats a string according to the - given sprintf-style format string (and the variable argument list) - and stores the result in self. + Analogous to sprintf() -- this formats a string according to the + given sprintf-style format string (and the variable argument list) + and stores the result in self. */ void format(UnicodeString format, ...); void format(const WideChar* format, ...); /** - Identical to format(), but takes a va_list rather than - a variable argument list. (i.e., analogous to vsprintf.) + Identical to format(), but takes a va_list rather than + a variable argument list. (i.e., analogous to vsprintf.) */ void format_va(const UnicodeString& format, va_list args); void format_va(const WideChar* format, va_list args); /** - Conceptually identical to wsccmp(). + Conceptually identical to wsccmp(). */ int compare(const UnicodeString& stringSrc) const; /** - Conceptually identical to wsccmp(). + Conceptually identical to wsccmp(). */ int compare(const WideChar* s) const; /** - Conceptually identical to _wcsicmp(). + Conceptually identical to _wcsicmp(). */ int compareNoCase(const UnicodeString& stringSrc) const; /** - Conceptually identical to _wcsicmp(). + Conceptually identical to _wcsicmp(). */ int compareNoCase(const WideChar* s) const; /** - return true iff self starts with the given string. + return true iff self starts with the given string. */ Bool startsWith(const WideChar* p) const; Bool startsWith(const UnicodeString& stringSrc) const { return startsWith(stringSrc.str()); } /** - return true iff self starts with the given string. (case insensitive) + return true iff self starts with the given string. (case insensitive) */ Bool startsWithNoCase(const WideChar* p) const; Bool startsWithNoCase(const UnicodeString& stringSrc) const { return startsWithNoCase(stringSrc.str()); } /** - return true iff self ends with the given string. + return true iff self ends with the given string. */ Bool endsWith(const WideChar* p) const; Bool endsWith(const UnicodeString& stringSrc) const { return endsWith(stringSrc.str()); } /** - return true iff self ends with the given string. (case insensitive) + return true iff self ends with the given string. (case insensitive) */ Bool endsWithNoCase(const WideChar* p) const; Bool endsWithNoCase(const UnicodeString& stringSrc) const { return endsWithNoCase(stringSrc.str()); } /** - conceptually similar to strtok(): + conceptually similar to strtok(): - extract the next whitespace-delimited token from the front - of 'this' and copy it into 'token', returning true if a nonempty - token was found. (note that this modifies 'this' as well, stripping - the token off!) + extract the next whitespace-delimited token from the front + of 'this' and copy it into 'token', returning true if a nonempty + token was found. (note that this modifies 'this' as well, stripping + the token off!) */ Bool nextToken(UnicodeString* token, UnicodeString delimiters = UnicodeString::TheEmptyString); -// -// You might think it would be a good idea to overload the * operator -// to allow for an implicit conversion to an WideChar*. This is -// in theory a good idea, but in practice, there's lots of code -// that assumes it should check text fields for null, which -// is meaningless for us, since we never return a null ptr. -// -// operator const WideChar*() const { return str(); } -// - - UnicodeString& operator=(const UnicodeString& stringSrc); ///< the same as set() - UnicodeString& operator=(const WideChar* s); ///< the same as set() + // + // You might think it would be a good idea to overload the * operator + // to allow for an implicit conversion to an WideChar*. This is + // in theory a good idea, but in practice, there's lots of code + // that assumes it should check text fields for null, which + // is meaningless for us, since we never return a null ptr. + // + // operator const WideChar*() const { return str(); } + // + + UnicodeString& operator=(const UnicodeString& stringSrc); ///< the same as set() + UnicodeString& operator=(const WideChar* s); ///< the same as set() }; - // ----------------------------------------------------- inline WideChar* UnicodeString::peek() const { @@ -364,7 +360,8 @@ inline WideChar* UnicodeString::peek() const } // ----------------------------------------------------- -inline UnicodeString::UnicodeString() : m_data(0) +inline UnicodeString::UnicodeString() + : m_data(0) { validate(); } @@ -452,7 +449,7 @@ inline void UnicodeString::concat(const WideChar c) { validate(); /// this can probably be made more efficient, if necessary - WideChar tmp[2] = { c, 0 }; + WideChar tmp[2] = {c, 0}; concat(tmp); validate(); } diff --git a/Core/GameEngine/Include/Common/UserPreferences.h b/Core/GameEngine/Include/Common/UserPreferences.h index 541303f6866..df5dab6f29f 100644 --- a/Core/GameEngine/Include/Common/UserPreferences.h +++ b/Core/GameEngine/Include/Common/UserPreferences.h @@ -81,16 +81,16 @@ class LANPreferences : public UserPreferences Bool loadFromIniFile(); - UnicodeString getUserName(); // convenience function - Int getPreferredFaction(); // convenience function - Int getPreferredColor(); // convenience function - AsciiString getPreferredMap(); // convenience function - Bool usesSystemMapDir(); // convenience function - Int getNumRemoteIPs(); // convenience function - UnicodeString getRemoteIPEntry(Int i); // convenience function - - Bool getSuperweaponRestricted() const; - Money getStartingCash() const; - void setSuperweaponRestricted( Bool superweaponRestricted); - void setStartingCash( const Money & startingCash ); + UnicodeString getUserName(); // convenience function + Int getPreferredFaction(); // convenience function + Int getPreferredColor(); // convenience function + AsciiString getPreferredMap(); // convenience function + Bool usesSystemMapDir(); // convenience function + Int getNumRemoteIPs(); // convenience function + UnicodeString getRemoteIPEntry(Int i); // convenience function + + Bool getSuperweaponRestricted() const; + Money getStartingCash() const; + void setSuperweaponRestricted(Bool superweaponRestricted); + void setStartingCash(const Money& startingCash); }; diff --git a/Core/GameEngine/Include/Common/Xfer.h b/Core/GameEngine/Include/Common/Xfer.h index 617b8e75e38..a7d90cf856e 100644 --- a/Core/GameEngine/Include/Common/Xfer.h +++ b/Core/GameEngine/Include/Common/Xfer.h @@ -46,7 +46,8 @@ // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// class Snapshot; typedef Int Color; -enum ObjectID CPP_11(: Int); +enum ObjectID +CPP_11( : Int); enum DrawableID CPP_11(: Int); enum KindOfType CPP_11(: Int); enum ScienceType CPP_11(: Int); diff --git a/Core/GameEngine/Include/Common/XferCRC.h b/Core/GameEngine/Include/Common/XferCRC.h index 8a728048c78..7c822636a1d 100644 --- a/Core/GameEngine/Include/Common/XferCRC.h +++ b/Core/GameEngine/Include/Common/XferCRC.h @@ -41,28 +41,25 @@ class XferCRC : public Xfer { public: - XferCRC(); virtual ~XferCRC() override; // Xfer methods - virtual void open( AsciiString identifier ) override; ///< start a CRC session with this xfer instance - virtual void close() override; ///< stop CRC session - virtual Int beginBlock() override; ///< start block event - virtual void endBlock() override; ///< end block event - virtual void skip( Int dataSize ) override; ///< skip xfer event + virtual void open(AsciiString identifier) override; ///< start a CRC session with this xfer instance + virtual void close() override; ///< stop CRC session + virtual Int beginBlock() override; ///< start block event + virtual void endBlock() override; ///< end block event + virtual void skip(Int dataSize) override; ///< skip xfer event - virtual void xferSnapshot( Snapshot *snapshot ) override; ///< entry point for xfering a snapshot + virtual void xferSnapshot(Snapshot* snapshot) override; ///< entry point for xfering a snapshot // Xfer CRC methods - virtual UnsignedInt getCRC(); ///< get computed CRC in network byte order + virtual UnsignedInt getCRC(); ///< get computed CRC in network byte order protected: + virtual void xferImplementation(void* data, Int dataSize) override; - virtual void xferImplementation( void *data, Int dataSize ) override; - - inline void addCRC( UnsignedInt val ); ///< CRC a 4-byte block + inline void addCRC(UnsignedInt val); ///< CRC a 4-byte block UnsignedInt m_crc; - }; diff --git a/Core/GameEngine/Include/Common/XferDeepCRC.h b/Core/GameEngine/Include/Common/XferDeepCRC.h index 729e37bf1c8..c53c8e14a91 100644 --- a/Core/GameEngine/Include/Common/XferDeepCRC.h +++ b/Core/GameEngine/Include/Common/XferDeepCRC.h @@ -42,22 +42,20 @@ class XferDeepCRC : public XferCRC { public: - XferDeepCRC(); virtual ~XferDeepCRC() override; // Xfer methods - virtual void open( AsciiString identifier ) override; ///< start a CRC session with this xfer instance - virtual void close() override; ///< stop CRC session + virtual void open(AsciiString identifier) override; ///< start a CRC session with this xfer instance + virtual void close() override; ///< stop CRC session // xfer methods - virtual void xferMarkerLabel( AsciiString asciiStringData ) override; ///< xfer ascii string (need our own) - virtual void xferAsciiString( AsciiString *asciiStringData ) override; ///< xfer ascii string (need our own) - virtual void xferUnicodeString( UnicodeString *unicodeStringData ) override; ///< xfer unicode string (need our own); + virtual void xferMarkerLabel(AsciiString asciiStringData) override; ///< xfer ascii string (need our own) + virtual void xferAsciiString(AsciiString* asciiStringData) override; ///< xfer ascii string (need our own) + virtual void xferUnicodeString(UnicodeString* unicodeStringData) override; ///< xfer unicode string (need our own); protected: + virtual void xferImplementation(void* data, Int dataSize) override; - virtual void xferImplementation( void *data, Int dataSize ) override; - - FILE * m_fileFP; ///< pointer to file + FILE* m_fileFP; ///< pointer to file }; diff --git a/Core/GameEngine/Include/Common/XferLoad.h b/Core/GameEngine/Include/Common/XferLoad.h index 0a5505a388f..b00f4bf5299 100644 --- a/Core/GameEngine/Include/Common/XferLoad.h +++ b/Core/GameEngine/Include/Common/XferLoad.h @@ -41,26 +41,23 @@ class XferLoad : public Xfer { public: - XferLoad(); virtual ~XferLoad() override; - virtual void open( AsciiString identifier ) override; ///< open file for writing - virtual void close() override; ///< close file - virtual Int beginBlock() override; ///< read placeholder block size - virtual void endBlock() override; ///< reading an end block is a no-op - virtual void skip( Int dataSize ) override; ///< skip forward dataSize bytes in file + virtual void open(AsciiString identifier) override; ///< open file for writing + virtual void close() override; ///< close file + virtual Int beginBlock() override; ///< read placeholder block size + virtual void endBlock() override; ///< reading an end block is a no-op + virtual void skip(Int dataSize) override; ///< skip forward dataSize bytes in file - virtual void xferSnapshot( Snapshot *snapshot ) override; ///< entry point for xfering a snapshot + virtual void xferSnapshot(Snapshot* snapshot) override; ///< entry point for xfering a snapshot // xfer methods - virtual void xferAsciiString( AsciiString *asciiStringData ) override; ///< xfer ascii string (need our own) - virtual void xferUnicodeString( UnicodeString *unicodeStringData ) override; ///< xfer unicode string (need our own); + virtual void xferAsciiString(AsciiString* asciiStringData) override; ///< xfer ascii string (need our own) + virtual void xferUnicodeString(UnicodeString* unicodeStringData) override; ///< xfer unicode string (need our own); protected: + virtual void xferImplementation(void* data, Int dataSize) override; ///< the xfer implementation - virtual void xferImplementation( void *data, Int dataSize ) override; ///< the xfer implementation - - FILE * m_fileFP; ///< pointer to file - + FILE* m_fileFP; ///< pointer to file }; diff --git a/Core/GameEngine/Include/Common/XferSave.h b/Core/GameEngine/Include/Common/XferSave.h index 9cf6593bdd6..56b5bd107b4 100644 --- a/Core/GameEngine/Include/Common/XferSave.h +++ b/Core/GameEngine/Include/Common/XferSave.h @@ -45,28 +45,25 @@ class XferSave : public Xfer { public: - XferSave(); virtual ~XferSave() override; // Xfer methods - virtual void open( AsciiString identifier ) override; ///< open file for writing - virtual void close() override; ///< close file - virtual Int beginBlock() override; ///< write placeholder block size - virtual void endBlock() override; ///< backup to last begin block and write size - virtual void skip( Int dataSize ) override; ///< skipping during a write is a no-op + virtual void open(AsciiString identifier) override; ///< open file for writing + virtual void close() override; ///< close file + virtual Int beginBlock() override; ///< write placeholder block size + virtual void endBlock() override; ///< backup to last begin block and write size + virtual void skip(Int dataSize) override; ///< skipping during a write is a no-op - virtual void xferSnapshot( Snapshot *snapshot ) override; ///< entry point for xfering a snapshot + virtual void xferSnapshot(Snapshot* snapshot) override; ///< entry point for xfering a snapshot // xfer methods - virtual void xferAsciiString( AsciiString *asciiStringData ) override; ///< xfer ascii string (need our own) - virtual void xferUnicodeString( UnicodeString *unicodeStringData ) override; ///< xfer unicode string (need our own); + virtual void xferAsciiString(AsciiString* asciiStringData) override; ///< xfer ascii string (need our own) + virtual void xferUnicodeString(UnicodeString* unicodeStringData) override; ///< xfer unicode string (need our own); protected: + virtual void xferImplementation(void* data, Int dataSize) override; ///< the xfer implementation - virtual void xferImplementation( void *data, Int dataSize ) override; ///< the xfer implementation - - FILE * m_fileFP; ///< pointer to file - XferBlockData *m_blockStack; ///< stack of block data - + FILE* m_fileFP; ///< pointer to file + XferBlockData* m_blockStack; ///< stack of block data }; diff --git a/Core/GameEngine/Include/Common/crc.h b/Core/GameEngine/Include/Common/crc.h index 08db4af6757..1f9dc1b96f9 100644 --- a/Core/GameEngine/Include/Common/crc.h +++ b/Core/GameEngine/Include/Common/crc.h @@ -32,27 +32,27 @@ #ifdef RTS_DEBUG -//#include "winsock2.h" // for htonl +// #include "winsock2.h" // for htonl class CRC { public: CRC() { crc = 0; } - void computeCRC( const void *buf, Int len ); ///< Compute the CRC for a buffer, added into current CRC - void clear() { crc = 0; } ///< Clears the CRC to 0 -// UnsignedInt get() { return htonl(crc); } ///< Get the combined CRC + void computeCRC(const void* buf, Int len); ///< Compute the CRC for a buffer, added into current CRC + void clear() { crc = 0; } ///< Clears the CRC to 0 + // UnsignedInt get() { return htonl(crc); } ///< Get the combined CRC UnsignedInt get(); -#if (defined(_MSC_VER) && _MSC_VER < 1300) && RETAIL_COMPATIBLE_CRC - void set( UnsignedInt v ) - { - crc = v; - } -#endif + #if (defined(_MSC_VER) && _MSC_VER < 1300) && RETAIL_COMPATIBLE_CRC + void set(UnsignedInt v) + { + crc = v; + } + #endif private: - void addCRC( UnsignedByte val ); ///< CRC a 4-byte block + void addCRC(UnsignedByte val); ///< CRC a 4-byte block UnsignedInt crc; }; @@ -63,37 +63,37 @@ class CRC class CRC { public: - CRC() { 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 - { + CRC() { 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 @@ -108,28 +108,29 @@ class CRC dec ecx jns lp mov dword ptr [edi],ebx - }; -#endif - } + } + ; + #endif + } - /// Clears the CRC to 0 + /// Clears the CRC to 0 void clear() - { - crc = 0; - } + { + crc = 0; + } - ///< Get the combined CRC + ///< Get the combined CRC UnsignedInt get() const - { - return crc; - } - -#if (defined(_MSC_VER) && _MSC_VER < 1300) && RETAIL_COMPATIBLE_CRC - void set( UnsignedInt v ) - { - crc = v; - } -#endif + { + return crc; + } + + #if (defined(_MSC_VER) && _MSC_VER < 1300) && RETAIL_COMPATIBLE_CRC + void set(UnsignedInt v) + { + crc = v; + } + #endif private: UnsignedInt crc; diff --git a/Core/GameEngine/Include/Common/file.h b/Core/GameEngine/Include/Common/file.h index a88fddb51bb..8b95de5cd0c 100644 --- a/Core/GameEngine/Include/Common/file.h +++ b/Core/GameEngine/Include/Common/file.h @@ -55,8 +55,6 @@ // Forward References //---------------------------------------------------------------------------- - - //---------------------------------------------------------------------------- // Type Defines //---------------------------------------------------------------------------- @@ -65,160 +63,151 @@ // File //=============================== /** - * File is an interface class for basic file operations. - * - * All code should use the File class and not its derivatives, unless - * absolutely necessary. Also FS::Open should be used to create File objects and open files. - * - * TheSuperHackers @feature Adds LINEBUF and FULLBUF modes and buffer size argument for file open. - */ + * File is an interface class for basic file operations. + * + * All code should use the File class and not its derivatives, unless + * absolutely necessary. Also FS::Open should be used to create File objects and open files. + * + * TheSuperHackers @feature Adds LINEBUF and FULLBUF modes and buffer size argument for file open. + */ //=============================== class File : public MemoryPoolObject { MEMORY_POOL_GLUE_ABC(File) -// friend doesn't play well with MPO (srj) -// friend class FileSystem; - - public: - - enum access - { - NONE = 0x00000000, ///< Access file. Reading by default - - READ = 0x00000001, ///< Access file for reading - WRITE = 0x00000002, ///< Access file for writing - READWRITE = (READ | WRITE), - - APPEND = 0x00000004, ///< Seek to end of file on open - CREATE = 0x00000008, ///< Create file if it does not exist - TRUNCATE = 0x00000010, ///< Delete all data in file when opened - - // NOTE: accesses file as binary data if neither TEXT and BINARY are set - TEXT = 0x00000020, ///< Access file as text data - BINARY = 0x00000040, ///< Access file as binary data - - ONLYNEW = 0x00000080, ///< Only create file if it does not exist - - // NOTE: STREAMING is Mutually exclusive with WRITE - STREAMING = 0x00000100, ///< Do not read this file into a ram file, read it as requested. - - // NOTE: accesses file with full buffering if neither LINEBUF and FULLBUF are set - LINEBUF = 0x00000200, ///< Access file with line buffering - FULLBUF = 0x00000400, ///< Access file with full buffering - }; - - enum seekMode - { - START, ///< Seek position is relative to start of file - CURRENT, ///< Seek position is relative to current file position - END ///< Seek position is relative from the end of the file - }; - - enum - { - BUFFERSIZE = BUFSIZ, - }; - - protected: - - AsciiString m_nameStr; ///< Stores file name - Int m_access; ///< How the file was opened - Bool m_open; ///< Has the file been opened - Bool m_deleteOnClose; ///< delete File object on close() - - - File(); ///< This class can only used as a base class - //virtual ~File(); - - void closeWithoutDelete(); - - public: - - - Bool eof(); - virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = BUFFERSIZE ); ///< Open a file for access - virtual void close(); ///< Close the file !!! File object no longer valid after this call !!! - - virtual Int read( void *buffer, Int bytes ) = 0 ; /**< Read the specified number of bytes from the file in to the - * memory pointed at by buffer. Returns the number of bytes read. - * Returns -1 if an error occurred. - */ - virtual Int readChar() = 0 ; /**< Read a character from the file - * Returns the character converted to an integer. - * Returns EOF if an error occurred. - */ - virtual Int readWideChar() = 0 ; /**< Read a wide character from the file - * Returns the wide character converted to an integer. - * Returns wide EOF if an error occurred. - */ - virtual Int write( const void *buffer, Int bytes ) = 0 ; /**< Write the specified number of bytes from the - * memory pointed at by buffer to the file. Returns the number of bytes written. - * Returns -1 if an error occurred. - */ - virtual Int writeFormat( const Char* format, ... ) = 0 ; /**< Write an unterminated formatted string to the file - * Returns the number of bytes written. - * Returns -1 if an error occurred. - */ - virtual Int writeFormat( const WideChar* format, ... ) = 0 ; /**< Write an unterminated formatted wide character string to the file - * Returns the number of bytes written. - * Returns -1 if an error occurred. - */ - virtual Int writeChar( const Char* character ) = 0 ; /**< Write a character to the file - * Returns a copy of the character written. - * Returns EOF if an error occurred. - */ - virtual Int writeChar( const WideChar* character ) = 0 ; /**< Write a wide character to the file - * Returns a copy of the wide character written. - * Returns wide EOF if an error occurred. - */ - virtual Int seek( Int bytes, seekMode mode = CURRENT ) = 0; /**< Sets the file position of the next read/write operation. Returns the new file - * position as the number of bytes from the start of the file. - * Returns -1 if an error occurred. - * - * seekMode determines how the seek is done: - * - * START : means seek to the specified number of bytes from the start of the file - * CURRENT: means seek the specified the number of bytes from the current file position - * END: means seek the specified number of bytes back from the end of the file - */ - virtual Bool flush() = 0; ///< flush data to disk - virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) = 0; ///< reads until it reaches a new-line character - - virtual Bool scanInt(Int &newInt) = 0; ///< read an integer from the current file position. - virtual Bool scanReal(Real &newReal) = 0; ///< read a real number from the current file position. - virtual Bool scanString(AsciiString &newString) = 0; ///< read a string from the current file position. - - virtual Bool print ( const Char *format, ...); ///< Prints formatted string to text file - virtual Int size(); ///< Returns the size of the file - virtual Int position(); ///< Returns the current read/write position - - - void setName( const char *name ); ///< Set the name of the file - const char* getName() const; ///< Returns a pointer to the name of the file - Int getAccess() const; ///< Returns file's access flags - - void deleteOnClose (); ///< Causes the File object to delete itself when it closes - - /** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. - */ - virtual char* readEntireAndClose() = 0; - virtual File* convertToRAMFile() = 0; + // friend doesn't play well with MPO (srj) + // friend class FileSystem; + +public: + enum access + { + NONE = 0x00000000, ///< Access file. Reading by default + + READ = 0x00000001, ///< Access file for reading + WRITE = 0x00000002, ///< Access file for writing + READWRITE = (READ | WRITE), + + APPEND = 0x00000004, ///< Seek to end of file on open + CREATE = 0x00000008, ///< Create file if it does not exist + TRUNCATE = 0x00000010, ///< Delete all data in file when opened + + // NOTE: accesses file as binary data if neither TEXT and BINARY are set + TEXT = 0x00000020, ///< Access file as text data + BINARY = 0x00000040, ///< Access file as binary data + + ONLYNEW = 0x00000080, ///< Only create file if it does not exist + + // NOTE: STREAMING is Mutually exclusive with WRITE + STREAMING = 0x00000100, ///< Do not read this file into a ram file, read it as requested. + + // NOTE: accesses file with full buffering if neither LINEBUF and FULLBUF are set + LINEBUF = 0x00000200, ///< Access file with line buffering + FULLBUF = 0x00000400, ///< Access file with full buffering + }; + + enum seekMode + { + START, ///< Seek position is relative to start of file + CURRENT, ///< Seek position is relative to current file position + END ///< Seek position is relative from the end of the file + }; + + enum + { + BUFFERSIZE = BUFSIZ, + }; + +protected: + AsciiString m_nameStr; ///< Stores file name + Int m_access; ///< How the file was opened + Bool m_open; ///< Has the file been opened + Bool m_deleteOnClose; ///< delete File object on close() + + File(); ///< This class can only used as a base class + // virtual ~File(); + + void closeWithoutDelete(); + +public: + Bool eof(); + virtual Bool open(const Char* filename, Int access = NONE, size_t bufferSize = BUFFERSIZE); ///< Open a file for access + virtual void close(); ///< Close the file !!! File object no longer valid after this call !!! + + virtual Int read(void* buffer, Int bytes) = 0; /**< Read the specified number of bytes from the file in to the + * memory pointed at by buffer. Returns the number of bytes read. + * Returns -1 if an error occurred. + */ + virtual Int readChar() = 0; /**< Read a character from the file + * Returns the character converted to an integer. + * Returns EOF if an error occurred. + */ + virtual Int readWideChar() = 0; /**< Read a wide character from the file + * Returns the wide character converted to an integer. + * Returns wide EOF if an error occurred. + */ + virtual Int write(const void* buffer, Int bytes) = 0; /**< Write the specified number of bytes from the + * memory pointed at by buffer to the file. Returns the number of bytes written. + * Returns -1 if an error occurred. + */ + virtual Int writeFormat(const Char* format, ...) = 0; /**< Write an unterminated formatted string to the file + * Returns the number of bytes written. + * Returns -1 if an error occurred. + */ + virtual Int writeFormat(const WideChar* format, ...) = 0; /**< Write an unterminated formatted wide character string to the file + * Returns the number of bytes written. + * Returns -1 if an error occurred. + */ + virtual Int writeChar(const Char* character) = 0; /**< Write a character to the file + * Returns a copy of the character written. + * Returns EOF if an error occurred. + */ + virtual Int writeChar(const WideChar* character) = 0; /**< Write a wide character to the file + * Returns a copy of the wide character written. + * Returns wide EOF if an error occurred. + */ + virtual Int seek(Int bytes, seekMode mode = CURRENT) = 0; /**< Sets the file position of the next read/write operation. Returns the new file + * position as the number of bytes from the start of the file. + * Returns -1 if an error occurred. + * + * seekMode determines how the seek is done: + * + * START : means seek to the specified number of bytes from the start of the file + * CURRENT: means seek the specified the number of bytes from the current file position + * END: means seek the specified number of bytes back from the end of the file + */ + virtual Bool flush() = 0; ///< flush data to disk + virtual void nextLine(Char* buf = nullptr, Int bufSize = 0) = 0; ///< reads until it reaches a new-line character + + virtual Bool scanInt(Int& newInt) = 0; ///< read an integer from the current file position. + virtual Bool scanReal(Real& newReal) = 0; ///< read a real number from the current file position. + virtual Bool scanString(AsciiString& newString) = 0; ///< read a string from the current file position. + + virtual Bool print(const Char* format, ...); ///< Prints formatted string to text file + virtual Int size(); ///< Returns the size of the file + virtual Int position(); ///< Returns the current read/write position + + void setName(const char* name); ///< Set the name of the file + const char* getName() const; ///< Returns a pointer to the name of the file + Int getAccess() const; ///< Returns file's access flags + + void deleteOnClose(); ///< Causes the File object to delete itself when it closes + + /** + Allocate a buffer large enough to hold entire file, read + the entire file into the buffer, then close the file. + the buffer is owned by the caller, who is responsible + for freeing is (via delete[]). This is a Good Thing to + use because it minimizes memory copies for BIG files. + */ + virtual char* readEntireAndClose() = 0; + virtual File* convertToRAMFile() = 0; }; - - - //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- inline const char* File::getName() const { return m_nameStr.str(); } -inline void File::setName( const char *name ) { m_nameStr.set(name); } +inline void File::setName(const char* name) { m_nameStr.set(name); } inline Int File::getAccess() const { return m_access; } inline void File::deleteOnClose() { m_deleteOnClose = TRUE; } diff --git a/Core/GameEngine/Include/Common/simpleplayer.h b/Core/GameEngine/Include/Common/simpleplayer.h index f799458f5b6..200223bcadf 100644 --- a/Core/GameEngine/Include/Common/simpleplayer.h +++ b/Core/GameEngine/Include/Common/simpleplayer.h @@ -24,96 +24,95 @@ // we preserve a list of "ready-to-free" list of wave headers for the // caller to unprepare and free // -typedef struct WAVEHDR_LIST { - LPWAVEHDR pwh; - struct WAVEHDR_LIST *next; -} WAVEHDR_LIST; +typedef struct WAVEHDR_LIST +{ + LPWAVEHDR pwh; + struct WAVEHDR_LIST* next; +} WAVEHDR_LIST; -#define SIMPLE_PLAYER_OPEN_EVENT _T( "45ab58e0-382e-4d1c-ac50-88a5f9601851" ) +#define SIMPLE_PLAYER_OPEN_EVENT _T( "45ab58e0-382e-4d1c-ac50-88a5f9601851" ) #define SIMPLE_PLAYER_CLOSE_EVENT _T( "276095fa-a8e0-48e6-ac61-8b0002345607" ) -#define WMAPLAY_EVENT _T( "9e828a72-64f3-48f0-9de8-13dafd0cbd3a" ) +#define WMAPLAY_EVENT _T( "9e828a72-64f3-48f0-9de8-13dafd0cbd3a" ) /////////////////////////////////////////////////////////////////////////////// class CSimplePlayer : public IWMReaderCallback { public: - CSimplePlayer( HRESULT* phr ); - ~CSimplePlayer(); + CSimplePlayer(HRESULT* phr); + ~CSimplePlayer(); - virtual HRESULT Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hCompletionEvent, HRESULT *phrCompletion ); + virtual HRESULT Play(LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hCompletionEvent, HRESULT* phrCompletion); -// -// IUnknown Implemenation -// + // + // IUnknown Implemenation + // public: - virtual HRESULT STDMETHODCALLTYPE QueryInterface( - REFIID riid, - void **ppvObject ); + virtual HRESULT STDMETHODCALLTYPE QueryInterface( + REFIID riid, + void** ppvObject); - virtual ULONG STDMETHODCALLTYPE AddRef(); - virtual ULONG STDMETHODCALLTYPE Release(); + virtual ULONG STDMETHODCALLTYPE AddRef(); + virtual ULONG STDMETHODCALLTYPE Release(); -// -// IWMReaderCallback Implemenation -// + // + // IWMReaderCallback Implemenation + // public: - virtual HRESULT STDMETHODCALLTYPE OnSample( - /* [in] */ DWORD dwOutputNum, - /* [in] */ QWORD cnsSampleTime, - /* [in] */ QWORD cnsSampleDuration, - /* [in] */ DWORD dwFlags, - /* [in] */ INSSBuffer __RPC_FAR *pSample, - /* [in] */ void __RPC_FAR *pvContext); - - virtual HRESULT STDMETHODCALLTYPE OnStatus( - /* [in] */ WMT_STATUS Status, - /* [in] */ HRESULT hr, - /* [in] */ WMT_ATTR_DATATYPE dwType, - /* [in] */ BYTE __RPC_FAR *pValue, - /* [in] */ void __RPC_FAR *pvContext); - -// -// Helper Methods -// + virtual HRESULT STDMETHODCALLTYPE OnSample( + /* [in] */ DWORD dwOutputNum, + /* [in] */ QWORD cnsSampleTime, + /* [in] */ QWORD cnsSampleDuration, + /* [in] */ DWORD dwFlags, + /* [in] */ INSSBuffer __RPC_FAR* pSample, + /* [in] */ void __RPC_FAR* pvContext); + + virtual HRESULT STDMETHODCALLTYPE OnStatus( + /* [in] */ WMT_STATUS Status, + /* [in] */ HRESULT hr, + /* [in] */ WMT_ATTR_DATATYPE dwType, + /* [in] */ BYTE __RPC_FAR* pValue, + /* [in] */ void __RPC_FAR* pvContext); + + // + // Helper Methods + // protected: + HRESULT Close(); - HRESULT Close(); - - void OnWaveOutMsg( UINT uMsg, DWORD dwParam1, DWORD dwParam2 ); - - static void CALLBACK WaveProc( - HWAVEOUT hwo, - UINT uMsg, - DWORD dwInstance, - DWORD dwParam1, - DWORD dwParam2 ); + void OnWaveOutMsg(UINT uMsg, DWORD dwParam1, DWORD dwParam2); - HRESULT AddWaveHeader( LPWAVEHDR pwh ); - void RemoveWaveHeaders(); + static void CALLBACK WaveProc( + HWAVEOUT hwo, + UINT uMsg, + DWORD dwInstance, + DWORD dwParam1, + DWORD dwParam2); - CRITICAL_SECTION m_CriSec; - WAVEHDR_LIST *m_whdrHead; + HRESULT AddWaveHeader(LPWAVEHDR pwh); + void RemoveWaveHeaders(); - LONG m_cRef; - LONG m_cBuffersOutstanding; - BOOL m_fEof; - HANDLE m_hCompletionEvent; + CRITICAL_SECTION m_CriSec; + WAVEHDR_LIST* m_whdrHead; - IWMReader *m_pReader; - IWMHeaderInfo *m_pHeader; - HWAVEOUT m_hwo; + LONG m_cRef; + LONG m_cBuffersOutstanding; + BOOL m_fEof; + HANDLE m_hCompletionEvent; - HRESULT *m_phrCompletion; + IWMReader* m_pReader; + IWMHeaderInfo* m_pHeader; + HWAVEOUT m_hwo; - HRESULT m_hrOpen; - HANDLE m_hOpenEvent; - HANDLE m_hCloseEvent; + HRESULT* m_phrCompletion; - union - { - WAVEFORMATEX m_wfx; - BYTE m_WfxBuf[1024]; - }; + HRESULT m_hrOpen; + HANDLE m_hOpenEvent; + HANDLE m_hCloseEvent; - LPWSTR m_pszUrl; + union + { + WAVEFORMATEX m_wfx; + BYTE m_WfxBuf[1024]; + }; + LPWSTR m_pszUrl; }; diff --git a/Core/GameEngine/Include/Common/urllaunch.h b/Core/GameEngine/Include/Common/urllaunch.h index ca23690143d..e03d23b569d 100644 --- a/Core/GameEngine/Include/Common/urllaunch.h +++ b/Core/GameEngine/Include/Common/urllaunch.h @@ -18,6 +18,6 @@ #pragma once -HRESULT MakeEscapedURL( LPWSTR pszInURL, LPWSTR *ppszOutURL ); +HRESULT MakeEscapedURL(LPWSTR pszInURL, LPWSTR* ppszOutURL); -HRESULT LaunchURL( LPCWSTR pszURL ); +HRESULT LaunchURL(LPCWSTR pszURL); diff --git a/Core/GameEngine/Include/GameClient/ChallengeGenerals.h b/Core/GameEngine/Include/GameClient/ChallengeGenerals.h index 7952d67eb1c..959bb27f915 100644 --- a/Core/GameEngine/Include/GameClient/ChallengeGenerals.h +++ b/Core/GameEngine/Include/GameClient/ChallengeGenerals.h @@ -35,7 +35,7 @@ #include "Common/Overridable.h" // DEFINES //////////////////////////////////////////////////////////////////////////////////////// -//static const Int NUM_GENERALS = 12; // ChallengeMenu.wnd dependent +// static const Int NUM_GENERALS = 12; // ChallengeMenu.wnd dependent #define NUM_GENERALS (12) // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// @@ -55,14 +55,14 @@ class GeneralPersona AsciiString m_strBioRank; AsciiString m_strBioBranch; AsciiString m_strBioClassNumber; - Image *m_imageBioPortraitSmall; - Image *m_imageBioPortraitLarge; + Image* m_imageBioPortraitSmall; + Image* m_imageBioPortraitLarge; AsciiString m_strCampaign; AsciiString m_strPlayerTemplateName; AsciiString m_strPortraitMovieLeftName; AsciiString m_strPortraitMovieRightName; - Image *m_imageDefeated; - Image *m_imageVictorious; + Image* m_imageDefeated; + Image* m_imageVictorious; AsciiString m_strDefeated; AsciiString m_strVictorious; AsciiString m_strSelectionSound; @@ -72,16 +72,15 @@ class GeneralPersona AsciiString m_strWinSound; AsciiString m_strLossSound; AsciiString m_strPreviewSound; - AsciiString m_strNameSound ; - + AsciiString m_strNameSound; public: - GeneralPersona() : - m_imageBioPortraitSmall(nullptr), - m_imageBioPortraitLarge(nullptr) + GeneralPersona() + : m_imageBioPortraitSmall(nullptr) + , m_imageBioPortraitLarge(nullptr) { } -// ~GeneralPersona(); + // ~GeneralPersona(); Bool isStartingEnabled() const { return m_bStartsEnabled; } const AsciiString& getBioName() const { return m_strBioName; } @@ -91,22 +90,25 @@ class GeneralPersona const AsciiString& getBioRank() const { return m_strBioRank; } const AsciiString& getBioClassNumber() const { return m_strBioClassNumber; } const AsciiString& getBioBranch() const { return m_strBioBranch; } - const Image *getBioPortraitSmall() const { return m_imageBioPortraitSmall; } - const Image *getBioPortraitLarge() const { return m_imageBioPortraitLarge; } + const Image* getBioPortraitSmall() const { return m_imageBioPortraitSmall; } + const Image* getBioPortraitLarge() const { return m_imageBioPortraitLarge; } const AsciiString& getPortraitMovieLeftName() const { return m_strPortraitMovieLeftName; } const AsciiString& getPortraitMovieRightName() const { return m_strPortraitMovieRightName; } const AsciiString& getCampaign() const { return m_strCampaign; } - const AsciiString& getPlayerTemplateName() const { return m_strPlayerTemplateName; } // template name, as parsed in from ini - const Image *getImageDefeated() const { return m_imageDefeated; } - const Image *getImageVictorious() const { return m_imageVictorious; } + const AsciiString& getPlayerTemplateName() const { return m_strPlayerTemplateName; } // template name, as parsed in from ini + const Image* getImageDefeated() const { return m_imageDefeated; } + const Image* getImageVictorious() const { return m_imageVictorious; } const AsciiString& getStringDefeated() const { return m_strDefeated; } const AsciiString& getStringVictorious() const { return m_strVictorious; } const AsciiString& getSelectionSound() const { return m_strSelectionSound; } - const AsciiString& getRandomTauntSound() const { - switch (rand()%3) // don't care about distribution or exactly how random this is + const AsciiString& getRandomTauntSound() const + { + switch (rand() % 3) // don't care about distribution or exactly how random this is { - case 0: return m_strTauntSound1; - case 1: return m_strTauntSound2; + case 0: + return m_strTauntSound1; + case 1: + return m_strTauntSound2; } return m_strTauntSound3; } @@ -116,16 +118,15 @@ class GeneralPersona const AsciiString& getNameSound() const { return m_strNameSound; } }; - class ChallengeGenerals { private: - /*const*/ GeneralPersona m_position[ NUM_GENERALS ]; - Int m_PlayerTemplateNum; // the template number as ThePlayerTemplateStore has it + /*const*/ GeneralPersona m_position[NUM_GENERALS]; + Int m_PlayerTemplateNum; // the template number as ThePlayerTemplateStore has it GameDifficulty m_currentDifficulty; // the last selected game difficulty for the challenge generals - static void parseGeneralPersona( INI* ini, void *instance, void *store, const void *userData ); + static void parseGeneralPersona(INI* ini, void* instance, void* store, const void* userData); public: ChallengeGenerals(); @@ -133,23 +134,21 @@ class ChallengeGenerals void init(); const GeneralPersona* getChallengeGenerals() const { return m_position; } - const FieldParse* getFieldParse() const { return s_fieldParseTable; } // for INI file parsing - const GeneralPersona* getPlayerGeneralByCampaignName( AsciiString name ) const; - const GeneralPersona* getGeneralByGeneralName( AsciiString name ) const; - const GeneralPersona* getGeneralByTemplateName( AsciiString name ) const; + const FieldParse* getFieldParse() const { return s_fieldParseTable; } // for INI file parsing + const GeneralPersona* getPlayerGeneralByCampaignName(AsciiString name) const; + const GeneralPersona* getGeneralByGeneralName(AsciiString name) const; + const GeneralPersona* getGeneralByTemplateName(AsciiString name) const; - void setCurrentPlayerTemplateNum( Int playerTemplateNum) { m_PlayerTemplateNum = playerTemplateNum; } + void setCurrentPlayerTemplateNum(Int playerTemplateNum) { m_PlayerTemplateNum = playerTemplateNum; } Int getCurrentPlayerTemplateNum() { return m_PlayerTemplateNum; } - void setCurrentDifficulty( GameDifficulty diff ) { m_currentDifficulty = diff; } + void setCurrentDifficulty(GameDifficulty diff) { m_currentDifficulty = diff; } GameDifficulty getCurrentDifficulty() { return m_currentDifficulty; } + protected: static const FieldParse s_fieldParseTable[]; - }; - - // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern ChallengeGenerals *TheChallengeGenerals; -extern ChallengeGenerals *createChallengeGenerals(); +extern ChallengeGenerals* TheChallengeGenerals; +extern ChallengeGenerals* createChallengeGenerals(); diff --git a/Core/GameEngine/Include/GameClient/ClientRandomValue.h b/Core/GameEngine/Include/GameClient/ClientRandomValue.h index bd0842d22a8..76277e59733 100644 --- a/Core/GameEngine/Include/GameClient/ClientRandomValue.h +++ b/Core/GameEngine/Include/GameClient/ClientRandomValue.h @@ -32,12 +32,12 @@ #include "Lib/BaseType.h" // do NOT use these functions directly, rather use the macros below -extern Int GetGameClientRandomValue( int lo, int hi, const char *file, int line ); -extern Real GetGameClientRandomValueReal( Real lo, Real hi, const char *file, int line ); +extern Int GetGameClientRandomValue(int lo, int hi, const char* file, int line); +extern Real GetGameClientRandomValueReal(Real lo, Real hi, const char* file, int line); // use these macros to access the random value functions -#define GameClientRandomValue( lo, hi ) GetGameClientRandomValue( lo, hi, __FILE__, __LINE__ ) -#define GameClientRandomValueReal( lo, hi ) GetGameClientRandomValueReal( lo, hi, __FILE__, __LINE__ ) +#define GameClientRandomValue(lo, hi) GetGameClientRandomValue(lo, hi, __FILE__, __LINE__) +#define GameClientRandomValueReal(lo, hi) GetGameClientRandomValueReal(lo, hi, __FILE__, __LINE__) //-------------------------------------------------------------------------------------------------------------- class CColorAlphaDialog; @@ -65,27 +65,32 @@ class GameClientRandomVariable */ enum DistributionType { - CONSTANT, UNIFORM, GAUSSIAN, TRIANGULAR, LOW_BIAS, HIGH_BIAS, + CONSTANT, + UNIFORM, + GAUSSIAN, + TRIANGULAR, + LOW_BIAS, + HIGH_BIAS, DISTRIBUTION_COUNT }; - static const char *const DistributionTypeNames[]; + static const char* const DistributionTypeNames[]; /// define the range of random values, and the distribution of values - void setRange( Real low, Real high, DistributionType type = UNIFORM ); + void setRange(Real low, Real high, DistributionType type = UNIFORM); - Real getValue() const; ///< return a value from the random distribution + Real getValue() const; ///< return a value from the random distribution Real getMinimumValue() const { return m_low; } Real getMaximumValue() const { return m_high; } DistributionType getDistributionType() const { return m_type; } + protected: - DistributionType m_type; ///< the kind of random distribution - Real m_low, m_high; ///< the range of random values + DistributionType m_type; ///< the kind of random distribution + Real m_low, m_high; ///< the range of random values // These two friends are for particle editing. friend CColorAlphaDialog; friend DebugWindowDialog; - }; //-------------------------------------------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/GameClient/Color.h b/Core/GameEngine/Include/GameClient/Color.h index 3146f86fc26..6d391267a85 100644 --- a/Core/GameEngine/Include/GameClient/Color.h +++ b/Core/GameEngine/Include/GameClient/Color.h @@ -53,7 +53,10 @@ // FORWARD REFERENCES ///////////////////////////////////////////////////////// // TYPE DEFINES /////////////////////////////////////////////////////////////// -enum { GAME_COLOR_UNDEFINED = 0x00FFFFFF }; // this is white with zero alpha... safe to use! +enum +{ + GAME_COLOR_UNDEFINED = 0x00FFFFFF +}; // this is white with zero alpha... safe to use! /** @todo we need real color representation, this is just placeholder so we can more easily identify sections of the code that need it */ @@ -63,25 +66,24 @@ typedef Int Color; // EXTERNALS ////////////////////////////////////////////////////////////////// -inline Color GameMakeColor( UnsignedByte red, UnsignedByte green, UnsignedByte blue, UnsignedByte alpha ) +inline Color GameMakeColor(UnsignedByte red, UnsignedByte green, UnsignedByte blue, UnsignedByte alpha) { return (alpha << 24) | (red << 16) | (green << 8) | (blue); } -extern void GameGetColorComponents( Color color, - UnsignedByte *red, - UnsignedByte *green, - UnsignedByte *blue, - UnsignedByte *alpha ); +extern void GameGetColorComponents(Color color, + UnsignedByte* red, + UnsignedByte* green, + UnsignedByte* blue, + UnsignedByte* alpha); // Put on ice until later - M Lorenzen -//extern void GameGetColorComponentsWithCheatSpy( Color color, +// 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 void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha ); - -extern Color GameDarkenColor( Color color, Int percent = 10 ); +extern Color GameDarkenColor(Color color, Int percent = 10); diff --git a/Core/GameEngine/Include/GameClient/Credits.h b/Core/GameEngine/Include/GameClient/Credits.h index 2a9f19952e6..0fd4e086bfe 100644 --- a/Core/GameEngine/Include/GameClient/Credits.h +++ b/Core/GameEngine/Include/GameClient/Credits.h @@ -63,28 +63,29 @@ class DisplayString; //----------------------------------------------------------------------------- enum { -CREDIT_STYLE_TITLE = 0, -CREDIT_STYLE_POSITION, -CREDIT_STYLE_NORMAL, -CREDIT_STYLE_COLUMN, -CREDIT_STYLE_BLANK, ///< Keep this second to last + CREDIT_STYLE_TITLE = 0, + CREDIT_STYLE_POSITION, + CREDIT_STYLE_NORMAL, + CREDIT_STYLE_COLUMN, + CREDIT_STYLE_BLANK, ///< Keep this second to last -MAX_CREDIT_STYLES + MAX_CREDIT_STYLES }; -enum{ CREDIT_SPACE_OFFSET = 2 }; - -static const LookupListRec CreditStyleNames[] = +enum { - { "TITLE", CREDIT_STYLE_TITLE }, - { "MINORTITLE", CREDIT_STYLE_POSITION }, - { "NORMAL", CREDIT_STYLE_NORMAL }, - { "COLUMN", CREDIT_STYLE_COLUMN }, - // CREDIT_STYLE_BLANK - { nullptr, 0 } + CREDIT_SPACE_OFFSET = 2 }; -static_assert(ARRAY_SIZE(CreditStyleNames) == MAX_CREDIT_STYLES, "Incorrect array size"); +static const LookupListRec CreditStyleNames[] = + { + {"TITLE", CREDIT_STYLE_TITLE}, + {"MINORTITLE", CREDIT_STYLE_POSITION}, + {"NORMAL", CREDIT_STYLE_NORMAL}, + {"COLUMN", CREDIT_STYLE_COLUMN}, + // CREDIT_STYLE_BLANK + {nullptr, 0}}; +static_assert(ARRAY_SIZE(CreditStyleNames) == MAX_CREDIT_STYLES, "Incorrect array size"); class CreditsLine { @@ -92,22 +93,22 @@ class CreditsLine CreditsLine(); ~CreditsLine(); -// parsing variables + // parsing variables Int m_style; UnicodeString m_text; UnicodeString m_secondText; Bool m_useSecond; Bool m_done; -// drawing variables - DisplayString *m_displayString; - DisplayString *m_secondDisplayString; + // drawing variables + DisplayString* m_displayString; + DisplayString* m_secondDisplayString; ICoord2D m_pos; Int m_height; Int m_color; }; -class CreditsManager: public SubsystemInterface +class CreditsManager : public SubsystemInterface { public: CreditsManager(); @@ -119,19 +120,19 @@ class CreditsManager: public SubsystemInterface virtual void update() override; virtual void draw() override; - const FieldParse *getFieldParse() const { return m_creditsFieldParseTable; } ///< returns the parsing fields - static const FieldParse m_creditsFieldParseTable[]; ///< the parse table - static void parseBlank( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file - static void parseText( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file + const FieldParse* getFieldParse() const { return m_creditsFieldParseTable; } ///< returns the parsing fields + static const FieldParse m_creditsFieldParseTable[]; ///< the parse table + static void parseBlank(INI* ini, void* instance, void* store, const void* userData); ///< Parse the image part of the INI file + static void parseText(INI* ini, void* instance, void* store, const void* userData); ///< Parse the image part of the INI file - Bool isFinished() { return m_isFinished; } + Bool isFinished() { return m_isFinished; } void addBlank(); - void addText( AsciiString text ); -private: + void addText(AsciiString text); +private: UnicodeString getUnicodeString(AsciiString str); - typedef std::list CreditsLineList; + typedef std::list CreditsLineList; CreditsLineList m_creditLineList; CreditsLineList::iterator m_creditLineListIt; @@ -139,11 +140,11 @@ class CreditsManager: public SubsystemInterface Int m_scrollRate; // in pixels Int m_scrollRatePerFrames; - Bool m_scrollDown; // if TRUE text will come from the top to the bottom if False, it will go from the bottom up + Bool m_scrollDown; // if TRUE text will come from the top to the bottom if False, it will go from the bottom up - Color m_titleColor; - Color m_positionColor; - Color m_normalColor; + Color m_titleColor; + Color m_positionColor; + Color m_normalColor; Int m_currentStyle; @@ -153,7 +154,6 @@ class CreditsManager: public SubsystemInterface Int m_normalFontHeight; }; - //----------------------------------------------------------------------------- // INLINING /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -161,4 +161,4 @@ class CreditsManager: public SubsystemInterface //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- -extern CreditsManager *TheCredits; +extern CreditsManager* TheCredits; diff --git a/Core/GameEngine/Include/GameClient/DisplayString.h b/Core/GameEngine/Include/GameClient/DisplayString.h index 042ab1e6963..2576fa2a541 100644 --- a/Core/GameEngine/Include/GameClient/DisplayString.h +++ b/Core/GameEngine/Include/GameClient/DisplayString.h @@ -63,55 +63,52 @@ class DisplayStringManager; // DisplayString -------------------------------------------------------------- /** String representation that can also has additional information and - * methods for drawing to the screen */ + * methods for drawing to the screen */ //----------------------------------------------------------------------------- class DisplayString : public MemoryPoolObject { - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( DisplayString, "DisplayString" ) + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DisplayString, "DisplayString") public: - friend DisplayStringManager; DisplayString(); // virtual ~DisplayString(); // destructor defined by memory pool - virtual void setText( UnicodeString text ); ///< set text for this string - virtual UnicodeString getText(); ///< get text for this string - virtual Int getTextLength(); ///< return number of chars in string - virtual void notifyTextChanged(); ///< called when text has changed - virtual void reset(); ///< reset all contents of string + virtual void setText(UnicodeString text); ///< set text for this string + virtual UnicodeString getText(); ///< get text for this string + virtual Int getTextLength(); ///< return number of chars in string + virtual void notifyTextChanged(); ///< called when text has changed + virtual void reset(); ///< reset all contents of string - virtual void setFont( GameFont *font ); ///< set a font for display - virtual GameFont *getFont(); ///< return font in string - virtual void setWordWrap( Int wordWrap ) = 0; ///< Set the width that we want to start wrapping text - virtual void setWordWrapCentered( Bool isCentered ) = 0; ///< If this is set to true, the text on a new line is centered - virtual void draw( Int x, Int y, Color color, Color dropColor ) = 0; ///< render text - virtual void draw( Int x, Int y, Color color, Color dropColor, Int xDrop, Int yDrop ) = 0; ///< render text with the drop shadow being at the offsets passed in - virtual void getSize( Int *width, Int *height ) = 0; ///< get render size - virtual Int getWidth( Int charPos = -1 ) = 0; ///< get text with up to charPos characters, 1- = all characters + virtual void setFont(GameFont* font); ///< set a font for display + virtual GameFont* getFont(); ///< return font in string + virtual void setWordWrap(Int wordWrap) = 0; ///< Set the width that we want to start wrapping text + virtual void setWordWrapCentered(Bool isCentered) = 0; ///< If this is set to true, the text on a new line is centered + virtual void draw(Int x, Int y, Color color, Color dropColor) = 0; ///< render text + virtual void draw(Int x, Int y, Color color, Color dropColor, Int xDrop, Int yDrop) = 0; ///< render text with the drop shadow being at the offsets passed in + virtual void getSize(Int* width, Int* height) = 0; ///< get render size + virtual Int getWidth(Int charPos = -1) = 0; ///< get text with up to charPos characters, 1- = all characters - virtual void setUseHotkey( Bool useHotkey, Color hotKeyColor ) = 0; + virtual void setUseHotkey(Bool useHotkey, Color hotKeyColor) = 0; - virtual void setClipRegion( IRegion2D *region ); ///< clip text in this region + virtual void setClipRegion(IRegion2D* region); ///< clip text in this region - virtual void removeLastChar(); ///< remove the last character - virtual void truncateBy(const Int charCount); ///< remove the last charCount characters - virtual void truncateTo(const Int maxLength); ///< remove characters, if needed, until the string is maxLength long excluding null terminator + virtual void removeLastChar(); ///< remove the last character + virtual void truncateBy(const Int charCount); ///< remove the last charCount characters + virtual void truncateTo(const Int maxLength); ///< remove characters, if needed, until the string is maxLength long excluding null terminator - virtual void appendChar( WideChar c ); ///< append character to end + virtual void appendChar(WideChar c); ///< append character to end - DisplayString *next(); ///< return next string + DisplayString* next(); ///< return next string protected: - UnicodeString m_textString; - GameFont *m_font; ///< font to display this string with - - DisplayString *m_next; ///< for the display string factory list ONLY - DisplayString *m_prev; ///< for the display string factory list ONLY + GameFont* m_font; ///< font to display this string with + DisplayString* m_next; ///< for the display string factory list ONLY + DisplayString* m_prev; ///< for the display string factory list ONLY }; /////////////////////////////////////////////////////////////////////////////// @@ -119,10 +116,10 @@ class DisplayString : public MemoryPoolObject /////////////////////////////////////////////////////////////////////////////// inline UnicodeString DisplayString::getText() { return m_textString; } inline Int DisplayString::getTextLength() { return m_textString.getLength(); } -inline void DisplayString::setFont( GameFont *font ) { m_font = font; } -inline GameFont *DisplayString::getFont() { return m_font; } -inline void DisplayString::setClipRegion( IRegion2D *region ) {} +inline void DisplayString::setFont(GameFont* font) { m_font = font; } +inline GameFont* DisplayString::getFont() { return m_font; } +inline void DisplayString::setClipRegion(IRegion2D* region) {} inline void DisplayString::notifyTextChanged() {} -inline DisplayString *DisplayString::next() { return m_next; } +inline DisplayString* DisplayString::next() { return m_next; } // EXTERNALS ////////////////////////////////////////////////////////////////// diff --git a/Core/GameEngine/Include/GameClient/DisplayStringManager.h b/Core/GameEngine/Include/GameClient/DisplayStringManager.h index bca43f0214f..6ab4db5cf16 100644 --- a/Core/GameEngine/Include/GameClient/DisplayStringManager.h +++ b/Core/GameEngine/Include/GameClient/DisplayStringManager.h @@ -39,27 +39,26 @@ class DisplayStringManager : public SubsystemInterface { public: - DisplayStringManager(); virtual ~DisplayStringManager() override; - virtual void init() override {} ///< initialize the factory - virtual void reset() override {} ///< reset system - virtual void update() override {}; ///< update anything we need to in our strings + virtual void init() override {} ///< initialize the factory + virtual void reset() override {} ///< reset system + virtual void update() override {}; ///< update anything we need to in our strings - virtual DisplayString *newDisplayString() = 0; ///< allocate new display string - virtual void freeDisplayString( DisplayString *string ) = 0; ///< free string + virtual DisplayString* newDisplayString() = 0; ///< allocate new display string + virtual void freeDisplayString(DisplayString* string) = 0; ///< free string - virtual DisplayString *getGroupNumeralString( Int numeral ) = 0; - virtual DisplayString *getFormationLetterString() = 0; -protected: + virtual DisplayString* getGroupNumeralString(Int numeral) = 0; + virtual DisplayString* getFormationLetterString() = 0; - void link( DisplayString *string ); ///< link display string to list - void unLink( DisplayString *string ); ///< unlink display string from list +protected: + void link(DisplayString* string); ///< link display string to list + void unLink(DisplayString* string); ///< unlink display string from list - DisplayString *m_stringList; ///< list of all display strings - DisplayString *m_currentCheckpoint; ///< current checkpoint of strings to be freed + DisplayString* m_stringList; ///< list of all display strings + DisplayString* m_currentCheckpoint; ///< current checkpoint of strings to be freed }; // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern DisplayStringManager *TheDisplayStringManager; ///< singleton extern +extern DisplayStringManager* TheDisplayStringManager; ///< singleton extern diff --git a/Core/GameEngine/Include/GameClient/DrawGroupInfo.h b/Core/GameEngine/Include/GameClient/DrawGroupInfo.h index 1ece4db4b5c..d3aa1049649 100644 --- a/Core/GameEngine/Include/GameClient/DrawGroupInfo.h +++ b/Core/GameEngine/Include/GameClient/DrawGroupInfo.h @@ -57,8 +57,8 @@ struct DrawGroupInfo DrawGroupInfo(); - static const FieldParse s_fieldParseTable[]; ///< the parse table for INI definition - const FieldParse *getFieldParse() const { return s_fieldParseTable; } + static const FieldParse s_fieldParseTable[]; ///< the parse table for INI definition + const FieldParse* getFieldParse() const { return s_fieldParseTable; } }; -extern DrawGroupInfo *TheDrawGroupInfo; +extern DrawGroupInfo* TheDrawGroupInfo; diff --git a/Core/GameEngine/Include/GameClient/FXList.h b/Core/GameEngine/Include/GameClient/FXList.h index 2d08f0335ec..37b3bd6fdc8 100644 --- a/Core/GameEngine/Include/GameClient/FXList.h +++ b/Core/GameEngine/Include/GameClient/FXList.h @@ -44,104 +44,102 @@ class Matrix3D; //------------------------------------------------------------------------------------------------- /** - An FXNugget encapsulates a particular type of audio/video effect. FXNuggets are virtually - never used on their own, but rather, as a component of an FXList (see below). + An FXNugget encapsulates a particular type of audio/video effect. FXNuggets are virtually + never used on their own, but rather, as a component of an FXList (see below). - Important notes: + Important notes: - -- FXNugget is an ABC; all the implementations are (currently) located in FXList.cpp, - thought they will probably be spread out more as we add more implementations. + -- FXNugget is an ABC; all the implementations are (currently) located in FXList.cpp, + thought they will probably be spread out more as we add more implementations. - -- As part of an FXList, an FXNugget is shared between multiple units. The implication is that - an FXNugget should not require private data storage to do what it needs to do, aside from stuff - initialized at FXNugget instantiation time (eg, parameters from an INI file). To help - enforce this, all it's methods are declared 'const'. If you can't implement what you - need within this framework, please *don't* simply de-const things, because it could lead to very - strange side-effects. Instead, the system will have to be enhanced to allow for multiple instances - of each FXNugget. + -- As part of an FXList, an FXNugget is shared between multiple units. The implication is that + an FXNugget should not require private data storage to do what it needs to do, aside from stuff + initialized at FXNugget instantiation time (eg, parameters from an INI file). To help + enforce this, all it's methods are declared 'const'. If you can't implement what you + need within this framework, please *don't* simply de-const things, because it could lead to very + strange side-effects. Instead, the system will have to be enhanced to allow for multiple instances + of each FXNugget. - -- an individual FXNugget is generally not directly accessible to anyone outside of the - FXList system; in fact, it could probably be a private class, but isn't, mainly for coding convenience. + -- an individual FXNugget is generally not directly accessible to anyone outside of the + FXList system; in fact, it could probably be a private class, but isn't, mainly for coding convenience. - -- Unlike most other game systems, FXNuggets can't be overridden by subsequent INI file - loads. This isn't really a problem, because all you really need to do to "override" one is to - specify a different one. + -- Unlike most other game systems, FXNuggets can't be overridden by subsequent INI file + loads. This isn't really a problem, because all you really need to do to "override" one is to + specify a different one. */ class FXNugget : public MemoryPoolObject { MEMORY_POOL_GLUE_ABC(FXNugget) public: - - FXNugget() { } - //virtual ~FXNugget() { } + FXNugget() {} + // virtual ~FXNugget() { } /** - The main guts of the system: actually perform the sound and/or video effects - needed. Note that primary and/or secondary can be null, so you must check for this. + The main guts of the system: actually perform the sound and/or video effects + needed. Note that primary and/or secondary can be null, so you must check for this. */ - virtual void doFXPos(const Coord3D *primary, const Matrix3D* primaryMtx = nullptr, const Real primarySpeed = 0.0f, const Coord3D *secondary = nullptr, const Real overrideRadius = 0.0f) const = 0; + virtual void doFXPos(const Coord3D* primary, const Matrix3D* primaryMtx = nullptr, const Real primarySpeed = 0.0f, const Coord3D* secondary = nullptr, const Real overrideRadius = 0.0f) const = 0; /** - the object-based version... by default, just call the location-based implementation. - Note that primary and/or secondary can be null, so you must check for this. + the object-based version... by default, just call the location-based implementation. + Note that primary and/or secondary can be null, so you must check for this. */ virtual void doFXObj(const Object* primary, const Object* secondary = nullptr) const; private: - }; EMPTY_DTOR(FXNugget) //------------------------------------------------------------------------------------------------- /** - An FXList is a way of encapsulating a particular set of audio/video effect(s). - Lots of other game systems (eg, DamageFX) use FXLists to abstract AV effects into data files - (rather than hardcoding them, which would be suboptimal). + An FXList is a way of encapsulating a particular set of audio/video effect(s). + Lots of other game systems (eg, DamageFX) use FXLists to abstract AV effects into data files + (rather than hardcoding them, which would be suboptimal). - Important notes: + Important notes: - -- an FXList is specified solely by name, and the only parameters it receives when performing - its AV effects are a primary (and optional secondary) object position. + -- an FXList is specified solely by name, and the only parameters it receives when performing + its AV effects are a primary (and optional secondary) object position. - -- There is no inheritance or overriding of FXLists; if you need an FXList that is nearly-but-not-quite - identical to an existing one, you must simply make an entirely new FXList. Realistically, this shouldn't - be a problem, since they are pretty simple to specify, and don't consume a lot of memory. + -- There is no inheritance or overriding of FXLists; if you need an FXList that is nearly-but-not-quite + identical to an existing one, you must simply make an entirely new FXList. Realistically, this shouldn't + be a problem, since they are pretty simple to specify, and don't consume a lot of memory. - -- an FXList is shared between multiple units. To help - enforce this, all it's methods are declared 'const'. If you can't implement the stuff you - need within this framework, please *don't* simply de-const things, because it could lead to very - strange side-effects. Instead, the system will have to be enhanced to allow for multiple instances - of each FXNugget. + -- an FXList is shared between multiple units. To help + enforce this, all it's methods are declared 'const'. If you can't implement the stuff you + need within this framework, please *don't* simply de-const things, because it could lead to very + strange side-effects. Instead, the system will have to be enhanced to allow for multiple instances + of each FXNugget. - -- Unlike most other game systems, FXList can't be overridden by subsequent INI file - loads. This isn't really a problem, because all you really need to do to "override" one is to - specify a different one. + -- Unlike most other game systems, FXList can't be overridden by subsequent INI file + loads. This isn't really a problem, because all you really need to do to "override" one is to + specify a different one. */ class FXList { public: - FXList(); virtual ~FXList(); /** - Toss the contents. + Toss the contents. */ void clear(); /** - add a nugget to the list. It belongs to the FXList, who is responsible for freeing it. + add a nugget to the list. It belongs to the FXList, who is responsible for freeing it. */ - void addFXNugget(FXNugget *fxn) + void addFXNugget(FXNugget* fxn) { m_nuggets.push_back(fxn); } /// inline convenience method to avoid having to check for null. - inline static void doFXPos(const FXList* fx, const Coord3D *primary, const Matrix3D* primaryMtx = nullptr, const Real primarySpeed = 0.0f, const Coord3D *secondary = nullptr, const Real overrideRadius = 0.0f) + inline static void doFXPos(const FXList* fx, const Coord3D* primary, const Matrix3D* primaryMtx = nullptr, const Real primarySpeed = 0.0f, const Coord3D* secondary = nullptr, const Real overrideRadius = 0.0f) { - if (fx) fx->doFXPos(primary, primaryMtx, primarySpeed, secondary, overrideRadius); + if (fx) + fx->doFXPos(primary, primaryMtx, primarySpeed, secondary, overrideRadius); } /// inline convenience method to avoid having to check for null. @@ -151,69 +149,58 @@ class FXList { fx->doFXObj(primary, secondary); - //if (fx->) // here we need to cal doFXRicochet, if fx calls for it - + // if (fx->) // here we need to cal doFXRicochet, if fx calls for it } - } - - protected: - - /** - The main guts of the system: actually perform the sound and/or video effects - needed. Note that primary and/or secondary can be null, so you must check for this. + The main guts of the system: actually perform the sound and/or video effects + needed. Note that primary and/or secondary can be null, so you must check for this. */ - void doFXPos(const Coord3D *primary, const Matrix3D* primaryMtx = nullptr, const Real primarySpeed = 0.0f, const Coord3D *secondary = nullptr, const Real overrideRadius = 0.0f) const; + void doFXPos(const Coord3D* primary, const Matrix3D* primaryMtx = nullptr, const Real primarySpeed = 0.0f, const Coord3D* secondary = nullptr, const Real overrideRadius = 0.0f) const; /** - the object-based version... by default, just call the location-based implementation. - Note that primary and/or secondary can be null, so you must check for this. + the object-based version... by default, just call the location-based implementation. + Note that primary and/or secondary can be null, so you must check for this. */ void doFXObj(const Object* primary, const Object* secondary = nullptr) const; private: - - typedef std::list< FXNugget* > FXNuggetList; + typedef std::list FXNuggetList; FXNuggetList m_nuggets; - }; //------------------------------------------------------------------------------------------------- /** - The "store" used to hold all the FXLists in existence. + The "store" used to hold all the FXLists in existence. */ class FXListStore : public SubsystemInterface { public: - FXListStore(); virtual ~FXListStore() override; - virtual void init() override { } - virtual void reset() override { } - virtual void update() override { } + virtual void init() override {} + virtual void reset() override {} + virtual void update() override {} /** - return the FXList with the given namekey. - return nullptr if no such FXList exists. + return the FXList with the given namekey. + return nullptr if no such FXList exists. */ - const FXList *findFXList( const char* name ) const; + const FXList* findFXList(const char* name) const; static void parseFXListDefinition(INI* ini); private: - // use the hashing function for Ints. - typedef std::hash_map< NameKeyType, FXList, rts::hash, rts::equal_to > FXListMap; + typedef std::hash_map, rts::equal_to > FXListMap; FXListMap m_fxmap; - }; // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern FXListStore *TheFXListStore; +extern FXListStore* TheFXListStore; diff --git a/Core/GameEngine/Include/GameClient/GameFont.h b/Core/GameEngine/Include/GameClient/GameFont.h index 3b67bd19bb6..ff33e99fcf4 100644 --- a/Core/GameEngine/Include/GameClient/GameFont.h +++ b/Core/GameEngine/Include/GameClient/GameFont.h @@ -41,12 +41,12 @@ class GameFont : public MemoryPoolObject { MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(GameFont, "GameFont") public: - GameFont* next; ///< for library use - AsciiString nameString; - Int pointSize; ///< point size of font - Int height; ///< pixel height of font - void* fontData; ///< font data to be filled out for device specific font - Bool bold; ///< is this font bold + GameFont* next; ///< for library use + AsciiString nameString; + Int pointSize; ///< point size of font + Int height; ///< pixel height of font + void* fontData; ///< font data to be filled out for device specific font + Bool bold; ///< is this font bold }; EMPTY_DTOR(GameFont) @@ -57,49 +57,44 @@ class FontLibrary : public SubsystemInterface { public: - - public: - FontLibrary(); virtual ~FontLibrary() override; virtual void init() override; virtual void reset() override; - virtual void update() override { } + virtual void update() override {} - GameFont *getFont( AsciiString name, Int pointSize, Bool bold ); ///< get a font pointer + GameFont* getFont(AsciiString name, Int pointSize, Bool bold); ///< get a font pointer - GameFont *firstFont(); ///< return first font - GameFont *nextFont( GameFont *font ); ///< get next font in library + GameFont* firstFont(); ///< return first font + GameFont* nextFont(GameFont* font); ///< get next font in library - Int getCount(); ///< return how many fonts are loaded in this lib + Int getCount(); ///< return how many fonts are loaded in this lib protected: - - void deleteAllFonts(); ///< delete all fonts in this library - void linkFont( GameFont *font ); ///< add to font list - void unlinkFont( GameFont *font ); ///< remove font from list + void deleteAllFonts(); ///< delete all fonts in this library + void linkFont(GameFont* font); ///< add to font list + void unlinkFont(GameFont* font); ///< remove font from list /// load the font data pointer based on everything else we already have set - virtual Bool loadFontData( GameFont *font ) = 0; + virtual Bool loadFontData(GameFont* font) = 0; /// release the font data pointer - virtual void releaseFontData( GameFont *font ) { }; - - GameFont *m_fontList; ///< list of fonts we have loaded - Int m_count; ///< number of unique fonts loaded in this lib + virtual void releaseFontData(GameFont* font) {}; + GameFont* m_fontList; ///< list of fonts we have loaded + Int m_count; ///< number of unique fonts loaded in this lib }; // INLINING /////////////////////////////////////////////////////////////////////////////////////// inline Int FontLibrary::getCount() { return m_count; } -inline GameFont *FontLibrary::firstFont() { return m_fontList; } -inline GameFont *FontLibrary::nextFont( GameFont *font ) +inline GameFont* FontLibrary::firstFont() { return m_fontList; } +inline GameFont* FontLibrary::nextFont(GameFont* font) { - if( font ) + if (font) return font->next; return nullptr; } // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern FontLibrary *TheFontLibrary; ///< font library external +extern FontLibrary* TheFontLibrary; ///< font library external diff --git a/Core/GameEngine/Include/GameClient/GameText.h b/Core/GameEngine/Include/GameClient/GameText.h index e7f6be21017..73adbb83ab8 100644 --- a/Core/GameEngine/Include/GameClient/GameText.h +++ b/Core/GameEngine/Include/GameClient/GameText.h @@ -22,7 +22,6 @@ // // //////////////////////////////////////////////////////////////////////////////// - //---------------------------------------------------------------------------- // // Westwood Studios Pacific. @@ -62,44 +61,42 @@ typedef std::vector AsciiStringVec; // GameTextInterface //=============================== /** Game text interface object for localised text. - */ + */ //=============================== class GameTextInterface : public SubsystemInterface { - public: - - virtual ~GameTextInterface() override {}; +public: + virtual ~GameTextInterface() override {}; - virtual UnicodeString fetch( const Char *label, Bool *exists = nullptr ) = 0; ///< Returns the associated labeled unicode text - virtual UnicodeString fetch( AsciiString label, Bool *exists = nullptr ) = 0; ///< Returns the associated labeled unicode text ; TheSuperHackers @todo Remove - virtual UnicodeString fetchFormat( const Char *label, ... ) = 0; + virtual UnicodeString fetch(const Char* label, Bool* exists = nullptr) = 0; ///< Returns the associated labeled unicode text + virtual UnicodeString fetch(AsciiString label, Bool* exists = nullptr) = 0; ///< Returns the associated labeled unicode text ; TheSuperHackers @todo Remove + virtual UnicodeString fetchFormat(const Char* label, ...) = 0; - // Do not call this directly, but use the FETCH_OR_SUBSTITUTE macro - virtual UnicodeString fetchOrSubstitute( const Char *label, const WideChar *substituteText ) = 0; - virtual UnicodeString fetchOrSubstituteFormat( const Char *label, const WideChar *substituteFormat, ... ) = 0; - virtual UnicodeString fetchOrSubstituteFormatVA( const Char *label, const WideChar *substituteFormat, va_list args ) = 0; + // Do not call this directly, but use the FETCH_OR_SUBSTITUTE macro + virtual UnicodeString fetchOrSubstitute(const Char* label, const WideChar* substituteText) = 0; + virtual UnicodeString fetchOrSubstituteFormat(const Char* label, const WideChar* substituteFormat, ...) = 0; + virtual UnicodeString fetchOrSubstituteFormatVA(const Char* label, const WideChar* substituteFormat, va_list args) = 0; - // This function is not performance tuned.. Its really only for Worldbuilder. jkmcd - virtual AsciiStringVec& getStringsWithLabelPrefix(AsciiString label) = 0; + // This function is not performance tuned.. Its really only for Worldbuilder. jkmcd + virtual AsciiStringVec& getStringsWithLabelPrefix(AsciiString label) = 0; - virtual void initMapStringFile( const AsciiString& filename ) = 0; + virtual void initMapStringFile(const AsciiString& filename) = 0; #if __cplusplus < 201103L // TheSuperHackers @todo Remove function when abandoning VC6 - inline UnicodeString FETCH_OR_SUBSTITUTE_FORMAT( const Char *label, const WideChar *substituteFormat, ... ) - { - va_list args; - va_start(args, substituteFormat); - UnicodeString str = fetchOrSubstituteFormatVA(label, substituteFormat, args); - va_end(args); - return str; - } + inline UnicodeString FETCH_OR_SUBSTITUTE_FORMAT(const Char* label, const WideChar* substituteFormat, ...) + { + va_list args; + va_start(args, substituteFormat); + UnicodeString str = fetchOrSubstituteFormatVA(label, substituteFormat, args); + va_end(args); + return str; + } #endif }; - -extern GameTextInterface *TheGameText; +extern GameTextInterface* TheGameText; extern GameTextInterface* CreateGameTextInterface(); //---------------------------------------------------------------------------- @@ -118,16 +115,16 @@ extern GameTextInterface* CreateGameTextInterface(); // alternative, but ##__VA_ARGS__ is simpler and compatible across C++11/14/17/20. #if ENABLE_GAMETEXT_SUBSTITUTES -#define FETCH_OR_SUBSTITUTE(labelA, substituteTextW) fetchOrSubstitute(labelA, substituteTextW) -#if __cplusplus >= 201103L // TheSuperHackers @todo Remove condition when abandoning VC6 -#define FETCH_OR_SUBSTITUTE_FORMAT(labelA, substituteFormatW, ...) fetchOrSubstituteFormat(labelA, substituteFormatW, ##__VA_ARGS__) -#endif + #define FETCH_OR_SUBSTITUTE(labelA, substituteTextW) fetchOrSubstitute(labelA, substituteTextW) + #if __cplusplus >= 201103L // TheSuperHackers @todo Remove condition when abandoning VC6 + #define FETCH_OR_SUBSTITUTE_FORMAT(labelA, substituteFormatW, ...) fetchOrSubstituteFormat(labelA, substituteFormatW, ##__VA_ARGS__) + #endif #else -#define FETCH_OR_SUBSTITUTE(labelA, substituteTextW) fetch(labelA) -#if __cplusplus >= 201103L // TheSuperHackers @todo Remove condition when abandoning VC6 -#define FETCH_OR_SUBSTITUTE_FORMAT(labelA, substituteFormatW, ...) fetchFormat(labelA, ##__VA_ARGS__) -#endif + #define FETCH_OR_SUBSTITUTE(labelA, substituteTextW) fetch(labelA) + #if __cplusplus >= 201103L // TheSuperHackers @todo Remove condition when abandoning VC6 + #define FETCH_OR_SUBSTITUTE_FORMAT(labelA, substituteFormatW, ...) fetchFormat(labelA, ##__VA_ARGS__) + #endif #endif // ENABLE_GAMETEXT_SUBSTITUTES diff --git a/Core/GameEngine/Include/GameClient/GameWindow.h b/Core/GameEngine/Include/GameClient/GameWindow.h index e96c94c96a0..aa1970566c7 100644 --- a/Core/GameEngine/Include/GameClient/GameWindow.h +++ b/Core/GameEngine/Include/GameClient/GameWindow.h @@ -69,14 +69,18 @@ struct GameWindowEditData; // TYPE DEFINES /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -enum { WIN_COLOR_UNDEFINED = GAME_COLOR_UNDEFINED }; +enum +{ + WIN_COLOR_UNDEFINED = GAME_COLOR_UNDEFINED +}; // WindowMsgData -------------------------------------------------------------- //----------------------------------------------------------------------------- typedef UnsignedInt WindowMsgData; //----------------------------------------------------------------------------- -enum WindowMsgHandledType CPP_11(: Int) { MSG_IGNORED, MSG_HANDLED }; +enum WindowMsgHandledType +CPP_11( : Int) { MSG_IGNORED, MSG_HANDLED }; // callback types ------------------------------------------------------------- typedef void (*GameWinMsgBoxFunc)(); //used for the Message box callbacks. diff --git a/Core/GameEngine/Include/GameClient/GameWindowTransitions.h b/Core/GameEngine/Include/GameClient/GameWindowTransitions.h index 6f6af4a69c9..5cffd51bb35 100644 --- a/Core/GameEngine/Include/GameClient/GameWindowTransitions.h +++ b/Core/GameEngine/Include/GameClient/GameWindowTransitions.h @@ -67,44 +67,43 @@ class DisplayString; enum { -TRANSITION_FLASH = 0, -BUTTON_TRANSITION_FLASH, -WIN_FADE_TRANSITION, -WIN_SCALE_UP_TRANSITION, -MAINMENU_SCALE_UP_TRANSITION, -TEXT_TYPE_TRANSITION, -SCREEN_FADE_TRANSITION, -COUNT_UP_TRANSITION, -FULL_FADE_TRANSITION, -TEXT_ON_FRAME_TRANSITION, -MAINMENU_MEDIUM_SCALE_UP_TRANSITION, -MAINMENU_SMALL_SCALE_DOWN_TRANSITION, -CONTROL_BAR_ARROW_TRANSITION, -SCORE_SCALE_UP_TRANSITION, -REVERSE_SOUND_TRANSITION, - -MAX_TRANSITION_WINDOW_STYLES + TRANSITION_FLASH = 0, + BUTTON_TRANSITION_FLASH, + WIN_FADE_TRANSITION, + WIN_SCALE_UP_TRANSITION, + MAINMENU_SCALE_UP_TRANSITION, + TEXT_TYPE_TRANSITION, + SCREEN_FADE_TRANSITION, + COUNT_UP_TRANSITION, + FULL_FADE_TRANSITION, + TEXT_ON_FRAME_TRANSITION, + MAINMENU_MEDIUM_SCALE_UP_TRANSITION, + MAINMENU_SMALL_SCALE_DOWN_TRANSITION, + CONTROL_BAR_ARROW_TRANSITION, + SCORE_SCALE_UP_TRANSITION, + REVERSE_SOUND_TRANSITION, + + MAX_TRANSITION_WINDOW_STYLES }; static const LookupListRec TransitionStyleNames[] = -{ - { "FLASH", TRANSITION_FLASH }, - { "BUTTONFLASH", BUTTON_TRANSITION_FLASH }, - { "WINFADE", WIN_FADE_TRANSITION }, - { "WINSCALEUP", WIN_SCALE_UP_TRANSITION }, - { "MAINMENUSCALEUP", MAINMENU_SCALE_UP_TRANSITION }, - { "TYPETEXT", TEXT_TYPE_TRANSITION }, - { "SCREENFADE", SCREEN_FADE_TRANSITION }, - { "COUNTUP", COUNT_UP_TRANSITION }, - { "FULLFADE", FULL_FADE_TRANSITION }, - { "TEXTONFRAME", TEXT_ON_FRAME_TRANSITION }, - { "MAINMENUMEDIUMSCALEUP", MAINMENU_MEDIUM_SCALE_UP_TRANSITION }, - { "MAINMENUSMALLSCALEDOWN", MAINMENU_SMALL_SCALE_DOWN_TRANSITION }, - { "CONTROLBARARROW", CONTROL_BAR_ARROW_TRANSITION }, - { "SCORESCALEUP", SCORE_SCALE_UP_TRANSITION }, - { "REVERSESOUND", REVERSE_SOUND_TRANSITION }, - { nullptr, 0 } -}; + { + {"FLASH", TRANSITION_FLASH}, + {"BUTTONFLASH", BUTTON_TRANSITION_FLASH}, + {"WINFADE", WIN_FADE_TRANSITION}, + {"WINSCALEUP", WIN_SCALE_UP_TRANSITION}, + {"MAINMENUSCALEUP", MAINMENU_SCALE_UP_TRANSITION}, + {"TYPETEXT", TEXT_TYPE_TRANSITION}, + {"SCREENFADE", SCREEN_FADE_TRANSITION}, + {"COUNTUP", COUNT_UP_TRANSITION}, + {"FULLFADE", FULL_FADE_TRANSITION}, + {"TEXTONFRAME", TEXT_ON_FRAME_TRANSITION}, + {"MAINMENUMEDIUMSCALEUP", MAINMENU_MEDIUM_SCALE_UP_TRANSITION}, + {"MAINMENUSMALLSCALEDOWN", MAINMENU_SMALL_SCALE_DOWN_TRANSITION}, + {"CONTROLBARARROW", CONTROL_BAR_ARROW_TRANSITION}, + {"SCORESCALEUP", SCORE_SCALE_UP_TRANSITION}, + {"REVERSESOUND", REVERSE_SOUND_TRANSITION}, + {nullptr, 0}}; static_assert(ARRAY_SIZE(TransitionStyleNames) == MAX_TRANSITION_WINDOW_STYLES + 1, "Incorrect array size"); // base class for the transitions @@ -112,117 +111,122 @@ static_assert(ARRAY_SIZE(TransitionStyleNames) == MAX_TRANSITION_WINDOW_STYLES + class Transition { public: - Transition (); + Transition(); virtual ~Transition(); - virtual void init( GameWindow *win ) = 0; - virtual void update( Int frame ) = 0; + virtual void init(GameWindow* win) = 0; + virtual void update(Int frame) = 0; virtual void reverse() = 0; virtual void draw() = 0; virtual void skip() = 0; - void unlinkGameWindow(GameWindow* win) { if ( m_win == win ) m_win = nullptr; } - Bool isFinished() { return m_isFinished; } - Int getFrameLength(){ return m_frameLength; } -protected: + void unlinkGameWindow(GameWindow* win) + { + if (m_win == win) + m_win = nullptr; + } + Bool isFinished() { return m_isFinished; } + Int getFrameLength() { return m_frameLength; } - Int m_frameLength; // how many frames does this thing take. - Bool m_isFinished; // when we finish we set this +protected: + Int m_frameLength; // how many frames does this thing take. + Bool m_isFinished; // when we finish we set this Bool m_isForward; - Bool m_isReversed; // when we reverse we set this - GameWindow *m_win; + Bool m_isReversed; // when we reverse we set this + GameWindow* m_win; }; //----------------------------------------------------------------------------- class TextOnFrameTransition : public Transition { public: - TextOnFrameTransition (); + TextOnFrameTransition(); virtual ~TextOnFrameTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - TEXTONFRAMETRANSITION_START = 0, - TEXTONFRAMETRANSITION_END = 1 // Max text type we'll allow. + enum + { + TEXTONFRAMETRANSITION_START = 0, + TEXTONFRAMETRANSITION_END = 1 // Max text type we'll allow. }; - }; //----------------------------------------------------------------------------- class ReverseSoundTransition : public Transition { public: - ReverseSoundTransition (); + ReverseSoundTransition(); virtual ~ReverseSoundTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - REVERSESOUNDTRANSITION_START = 0, - REVERSESOUNDTRANSITION_FIRESOUND = 1, - REVERSESOUNDTRANSITION_END = 2 // Max text type we'll allow. + enum + { + REVERSESOUNDTRANSITION_START = 0, + REVERSESOUNDTRANSITION_FIRESOUND = 1, + REVERSESOUNDTRANSITION_END = 2 // Max text type we'll allow. }; - }; //----------------------------------------------------------------------------- class FullFadeTransition : public Transition { public: - FullFadeTransition (); + FullFadeTransition(); virtual ~FullFadeTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - FULLFADETRANSITION_START = 0, - FULLFADETRANSITION_END = 10 // Max text type we'll allow. + enum + { + FULLFADETRANSITION_START = 0, + FULLFADETRANSITION_END = 10 // Max text type we'll allow. }; ICoord2D m_pos; ICoord2D m_size; Real m_percent; Int m_drawState; - }; //----------------------------------------------------------------------------- class ControlBarArrowTransition : public Transition { public: - ControlBarArrowTransition (); + ControlBarArrowTransition(); virtual ~ControlBarArrowTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - CONTROLBARARROWTRANSITION_START = 0, - CONTROLBARARROWTRANSITION_BEGIN_FADE = 16, - CONTROLBARARROWTRANSITION_END = 22 // Max text type we'll allow. + enum + { + CONTROLBARARROWTRANSITION_START = 0, + CONTROLBARARROWTRANSITION_BEGIN_FADE = 16, + CONTROLBARARROWTRANSITION_END = 22 // Max text type we'll allow. }; ICoord2D m_pos; ICoord2D m_incrementPos; @@ -231,51 +235,51 @@ class ControlBarArrowTransition : public Transition Real m_fadePercent; Int m_drawState; const Image* m_arrowImage; - }; //----------------------------------------------------------------------------- class ScreenFadeTransition : public Transition { public: - ScreenFadeTransition (); + ScreenFadeTransition(); virtual ~ScreenFadeTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - SCREENFADETRANSITION_START = 0, - SCREENFADETRANSITION_END = 30 // Max text type we'll allow. + enum + { + SCREENFADETRANSITION_START = 0, + SCREENFADETRANSITION_END = 30 // Max text type we'll allow. }; ICoord2D m_pos; ICoord2D m_size; Real m_percent; Int m_drawState; - }; //----------------------------------------------------------------------------- class CountUpTransition : public Transition { public: - CountUpTransition (); + CountUpTransition(); virtual ~CountUpTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - COUNTUPTRANSITION_START = 0, - COUNTUPTRANSITION_END = 30 // Max text type we'll allow. + enum + { + COUNTUPTRANSITION_START = 0, + COUNTUPTRANSITION_END = 30 // Max text type we'll allow. }; ICoord2D m_pos; ICoord2D m_size; @@ -284,7 +288,8 @@ class CountUpTransition : public Transition UnicodeString m_partialText; Int m_intValue; Int m_currentValue; - enum{ + enum + { COUNT_ONES = 1, COUNT_100S = 100, COUNT_1000S = 1000 @@ -296,47 +301,49 @@ class CountUpTransition : public Transition class TextTypeTransition : public Transition { public: - TextTypeTransition (); + TextTypeTransition(); virtual ~TextTypeTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - TEXTTYPETRANSITION_START = 0, - TEXTTYPETRANSITION_END = 30 // Max text type we'll allow. + enum + { + TEXTTYPETRANSITION_START = 0, + TEXTTYPETRANSITION_END = 30 // Max text type we'll allow. }; ICoord2D m_pos; ICoord2D m_size; Int m_drawState; UnicodeString m_fullText; UnicodeString m_partialText; - DisplayString *m_dStr; + DisplayString* m_dStr; }; //----------------------------------------------------------------------------- class MainMenuScaleUpTransition : public Transition { public: - MainMenuScaleUpTransition (); + MainMenuScaleUpTransition(); virtual ~MainMenuScaleUpTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - MAINMENUSCALEUPTRANSITION_START = 0, - MAINMENUSCALEUPTRANSITION_END = 5 + enum + { + MAINMENUSCALEUPTRANSITION_START = 0, + MAINMENUSCALEUPTRANSITION_END = 5 }; ICoord2D m_pos; ICoord2D m_size; @@ -345,28 +352,28 @@ class MainMenuScaleUpTransition : public Transition ICoord2D m_growSize; ICoord2D m_incrementPos; ICoord2D m_incrementSize; - GameWindow *m_growWin; + GameWindow* m_growWin; }; - //----------------------------------------------------------------------------- class MainMenuMediumScaleUpTransition : public Transition { public: - MainMenuMediumScaleUpTransition (); + MainMenuMediumScaleUpTransition(); virtual ~MainMenuMediumScaleUpTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - MAINMENUMEDIUMSCALEUPTRANSITION_START = 0, - MAINMENUMEDIUMSCALEUPTRANSITION_END = 3 + enum + { + MAINMENUMEDIUMSCALEUPTRANSITION_START = 0, + MAINMENUMEDIUMSCALEUPTRANSITION_END = 3 }; ICoord2D m_pos; ICoord2D m_size; @@ -374,32 +381,33 @@ class MainMenuMediumScaleUpTransition : public Transition ICoord2D m_growPos; ICoord2D m_growSize; ICoord2D m_incrementSize; - GameWindow *m_growWin; + GameWindow* m_growWin; }; //----------------------------------------------------------------------------- class MainMenuSmallScaleDownTransition : public Transition { public: - MainMenuSmallScaleDownTransition (); + MainMenuSmallScaleDownTransition(); virtual ~MainMenuSmallScaleDownTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - MAINMENUSMALLSCALEDOWNTRANSITION_START = 0, - MAINMENUSMALLSCALEDOWNTRANSITION_1 = 1, - MAINMENUSMALLSCALEDOWNTRANSITION_2 = 2, - MAINMENUSMALLSCALEDOWNTRANSITION_3 = 3, - MAINMENUSMALLSCALEDOWNTRANSITION_4 = 4, - MAINMENUSMALLSCALEDOWNTRANSITION_5 = 5, - MAINMENUSMALLSCALEDOWNTRANSITION_END + enum + { + MAINMENUSMALLSCALEDOWNTRANSITION_START = 0, + MAINMENUSMALLSCALEDOWNTRANSITION_1 = 1, + MAINMENUSMALLSCALEDOWNTRANSITION_2 = 2, + MAINMENUSMALLSCALEDOWNTRANSITION_3 = 3, + MAINMENUSMALLSCALEDOWNTRANSITION_4 = 4, + MAINMENUSMALLSCALEDOWNTRANSITION_5 = 5, + MAINMENUSMALLSCALEDOWNTRANSITION_END }; ICoord2D m_pos; ICoord2D m_size; @@ -407,46 +415,47 @@ class MainMenuSmallScaleDownTransition : public Transition ICoord2D m_growPos; ICoord2D m_growSize; ICoord2D m_incrementSize; - GameWindow *m_growWin; + GameWindow* m_growWin; }; //----------------------------------------------------------------------------- class ScaleUpTransition : public Transition { public: - ScaleUpTransition (); + ScaleUpTransition(); virtual ~ScaleUpTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - SCALEUPTRANSITION_START = 0, - SCALEUPTRANSITION_1 = 1, - SCALEUPTRANSITION_2 = 2, - SCALEUPTRANSITION_3 = 3, - SCALEUPTRANSITION_4 = 4, - SCALEUPTRANSITION_5 = 5, -// SCALEUPTRANSITION_6 = 6, -// SCALEUPTRANSITION_7 = 7, -// SCALEUPTRANSITION_8 = 8, -// SCALEUPTRANSITION_9 = 9, -// SCALEUPTRANSITION_10 = 10, -// SCALEUPTRANSITION_11 = 11, -// SCALEUPTRANSITION_12 = 12, -// SCALEUPTRANSITION_13 = 13, -// SCALEUPTRANSITION_14 = 14, -// SCALEUPTRANSITION_15 = 15, -// SCALEUPTRANSITION_16 = 16, -// SCALEUPTRANSITION_17 = 17, -// SCALEUPTRANSITION_18 = 18, -// SCALEUPTRANSITION_19 = 19, - SCALEUPTRANSITION_END + enum + { + SCALEUPTRANSITION_START = 0, + SCALEUPTRANSITION_1 = 1, + SCALEUPTRANSITION_2 = 2, + SCALEUPTRANSITION_3 = 3, + SCALEUPTRANSITION_4 = 4, + SCALEUPTRANSITION_5 = 5, + // SCALEUPTRANSITION_6 = 6, + // SCALEUPTRANSITION_7 = 7, + // SCALEUPTRANSITION_8 = 8, + // SCALEUPTRANSITION_9 = 9, + // SCALEUPTRANSITION_10 = 10, + // SCALEUPTRANSITION_11 = 11, + // SCALEUPTRANSITION_12 = 12, + // SCALEUPTRANSITION_13 = 13, + // SCALEUPTRANSITION_14 = 14, + // SCALEUPTRANSITION_15 = 15, + // SCALEUPTRANSITION_16 = 16, + // SCALEUPTRANSITION_17 = 17, + // SCALEUPTRANSITION_18 = 18, + // SCALEUPTRANSITION_19 = 19, + SCALEUPTRANSITION_END }; ICoord2D m_pos; ICoord2D m_size; @@ -459,26 +468,27 @@ class ScaleUpTransition : public Transition class ScoreScaleUpTransition : public Transition { public: - ScoreScaleUpTransition (); + ScoreScaleUpTransition(); virtual ~ScoreScaleUpTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - SCORESCALEUPTRANSITION_START = 0, - SCORESCALEUPTRANSITION_1 = 1, - SCORESCALEUPTRANSITION_2 = 2, - SCORESCALEUPTRANSITION_3 = 3, - SCORESCALEUPTRANSITION_4 = 4, - SCORESCALEUPTRANSITION_5 = 5, - - SCORESCALEUPTRANSITION_END + enum + { + SCORESCALEUPTRANSITION_START = 0, + SCORESCALEUPTRANSITION_1 = 1, + SCORESCALEUPTRANSITION_2 = 2, + SCORESCALEUPTRANSITION_3 = 3, + SCORESCALEUPTRANSITION_4 = 4, + SCORESCALEUPTRANSITION_5 = 5, + + SCORESCALEUPTRANSITION_END }; ICoord2D m_pos; ICoord2D m_size; @@ -489,66 +499,66 @@ class ScoreScaleUpTransition : public Transition //----------------------------------------------------------------------------- - class FadeTransition : public Transition { public: - FadeTransition (); + FadeTransition(); virtual ~FadeTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - FADETRANSITION_START = 0, - FADETRANSITION_FADE_IN_1 = 1, - FADETRANSITION_FADE_IN_2 = 2, - FADETRANSITION_FADE_IN_3 = 3, - FADETRANSITION_FADE_IN_4 = 4, - FADETRANSITION_FADE_IN_5 = 5, - FADETRANSITION_FADE_IN_6 = 6, - FADETRANSITION_FADE_IN_7 = 7, - FADETRANSITION_FADE_IN_8 = 8, - FADETRANSITION_FADE_IN_9 = 9, - FADETRANSITION_END + enum + { + FADETRANSITION_START = 0, + FADETRANSITION_FADE_IN_1 = 1, + FADETRANSITION_FADE_IN_2 = 2, + FADETRANSITION_FADE_IN_3 = 3, + FADETRANSITION_FADE_IN_4 = 4, + FADETRANSITION_FADE_IN_5 = 5, + FADETRANSITION_FADE_IN_6 = 6, + FADETRANSITION_FADE_IN_7 = 7, + FADETRANSITION_FADE_IN_8 = 8, + FADETRANSITION_FADE_IN_9 = 9, + FADETRANSITION_END }; ICoord2D m_pos; ICoord2D m_size; Int m_drawState; }; - //----------------------------------------------------------------------------- class FlashTransition : public Transition { public: - FlashTransition (); + FlashTransition(); virtual ~FlashTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - FLASHTRANSITION_START = 0, - FLASHTRANSITION_FADE_IN_1 = 1, - FLASHTRANSITION_FADE_IN_2 = 2, - FLASHTRANSITION_FADE_IN_3 = 3, - FLASHTRANSITION_FADE_TO_BACKGROUND_1 = 4, - FLASHTRANSITION_FADE_TO_BACKGROUND_2 = 5, - FLASHTRANSITION_FADE_TO_BACKGROUND_3 = 6, - FLASHTRANSITION_FADE_TO_BACKGROUND_4 = 7, - FLASHTRANSITION_END + enum + { + FLASHTRANSITION_START = 0, + FLASHTRANSITION_FADE_IN_1 = 1, + FLASHTRANSITION_FADE_IN_2 = 2, + FLASHTRANSITION_FADE_IN_3 = 3, + FLASHTRANSITION_FADE_TO_BACKGROUND_1 = 4, + FLASHTRANSITION_FADE_TO_BACKGROUND_2 = 5, + FLASHTRANSITION_FADE_TO_BACKGROUND_3 = 6, + FLASHTRANSITION_FADE_TO_BACKGROUND_4 = 7, + FLASHTRANSITION_END }; ICoord2D m_pos; ICoord2D m_size; @@ -559,39 +569,40 @@ class FlashTransition : public Transition class ButtonFlashTransition : public Transition { public: - ButtonFlashTransition (); + ButtonFlashTransition(); virtual ~ButtonFlashTransition() override; - virtual void init( GameWindow *win ) override; - virtual void update( Int frame ) override; + virtual void init(GameWindow* win) override; + virtual void update(Int frame) override; virtual void reverse() override; virtual void draw() override; virtual void skip() override; protected: - enum{ - BUTTONFLASHTRANSITION_START = 0, - BUTTONFLASHTRANSITION_FADE_IN_1 = 1, - BUTTONFLASHTRANSITION_FADE_IN_2 = 2, - BUTTONFLASHTRANSITION_FADE_IN_3 = 3, - BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_1 =4, - BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_2 = 5, - BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_3 = 6, - BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4 = 7, - BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1 = 11, - BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1 +1, - BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2 +1, - BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1 +1, - BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2 +1, - BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_4 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3 + 1, - BUTTONFLASHTRANSITION_END, // this is the end of the sequence, we need some special defines... well put them below here - BUTTONFLASHTRANSITION_SHOW_BACKGROUND + enum + { + BUTTONFLASHTRANSITION_START = 0, + BUTTONFLASHTRANSITION_FADE_IN_1 = 1, + BUTTONFLASHTRANSITION_FADE_IN_2 = 2, + BUTTONFLASHTRANSITION_FADE_IN_3 = 3, + BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_1 = 4, + BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_2 = 5, + BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_3 = 6, + BUTTONFLASHTRANSITION_FADE_TO_BACKGROUND_4 = 7, + BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1 = 11, + BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_1 + 1, + BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_IN_2 + 1, + BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_1 + 1, + BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_2 + 1, + BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_4 = BUTTONFLASHTRANSITION_FADE_TO_GRADE_OUT_3 + 1, + BUTTONFLASHTRANSITION_END, // this is the end of the sequence, we need some special defines... well put them below here + BUTTONFLASHTRANSITION_SHOW_BACKGROUND }; ICoord2D m_pos; ICoord2D m_size; Int m_drawState; - Image *m_gradient; + Image* m_gradient; }; //----------------------------------------------------------------------------- @@ -602,25 +613,25 @@ class TransitionWindow ~TransitionWindow(); Bool init(); - void update( Int frame ); + void update(Int frame); Bool isFinished(); - void reverse( Int totalFrames ); - Int getTotalFrames(); + void reverse(Int totalFrames); + Int getTotalFrames(); void skip(); void draw(); - void unlinkGameWindow( GameWindow* win ); + void unlinkGameWindow(GameWindow* win); -// INI parsed vars + // INI parsed vars AsciiString m_winName; - Int m_frameDelay; // what frame number we start on - Int m_style; // the style we'll be using - -// standard vars - NameKeyType m_winID; - GameWindow *m_win; - Transition *m_transition; // each window is allowed one transition - Int m_currentFrameDelay; // this will change based on if we're going forward or backwards + Int m_frameDelay; // what frame number we start on + Int m_style; // the style we'll be using + + // standard vars + NameKeyType m_winID; + GameWindow* m_win; + Transition* m_transition; // each window is allowed one transition + Int m_currentFrameDelay; // this will change based on if we're going forward or backwards }; //----------------------------------------------------------------------------- @@ -636,15 +647,16 @@ class TransitionGroup void reverse(); void draw(); - void skip (); + void skip(); AsciiString getName() { return m_name; } - void setName( AsciiString name){ m_name = name; } - void addWindow( TransitionWindow *transWin ); + void setName(AsciiString name) { m_name = name; } + void addWindow(TransitionWindow* transWin); Bool isReversed(); Bool isFireOnce() { return m_fireOnce; } Bool m_fireOnce; + private: - typedef std::list TransitionWindowList; + typedef std::list TransitionWindowList; TransitionWindowList m_transitionWindowList; Int m_directionMultiplier; Int m_currentFrame; ///< maintain how long we've spent on this transition; @@ -652,7 +664,7 @@ class TransitionGroup }; //----------------------------------------------------------------------------- -class GameWindowTransitionsHandler: public SubsystemInterface +class GameWindowTransitionsHandler : public SubsystemInterface { public: GameWindowTransitionsHandler(); @@ -664,26 +676,26 @@ class GameWindowTransitionsHandler: public SubsystemInterface virtual void update() override; virtual void draw() override; Bool isFinished(); - const FieldParse *getFieldParse() const { return m_gameWindowTransitionsFieldParseTable; } ///< returns the parsing fields - static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table - static void parseWindow( INI* ini, void *instance, void *store, const void *userData ); - - void setGroup(AsciiString groupName, Bool immediate = FALSE); // THis will be the next group to fire off. - void reverse( AsciiString groupName );// reverse the animations for the current group. - void remove( AsciiString groupName, Bool skipPending = FALSE );// remove the animation from the current or pending groups. - TransitionGroup *getNewGroup( AsciiString name ); + const FieldParse* getFieldParse() const { return m_gameWindowTransitionsFieldParseTable; } ///< returns the parsing fields + static const FieldParse m_gameWindowTransitionsFieldParseTable[]; ///< the parse table + static void parseWindow(INI* ini, void* instance, void* store, const void* userData); + + void setGroup(AsciiString groupName, Bool immediate = FALSE); // THis will be the next group to fire off. + void reverse(AsciiString groupName); // reverse the animations for the current group. + void remove(AsciiString groupName, Bool skipPending = FALSE); // remove the animation from the current or pending groups. + TransitionGroup* getNewGroup(AsciiString name); + private: - TransitionGroup *findGroup( AsciiString groupName ); - typedef std::list TransitionGroupList; + TransitionGroup* findGroup(AsciiString groupName); + typedef std::list TransitionGroupList; TransitionGroupList m_transitionGroupList; - TransitionGroup *m_currentGroup; - TransitionGroup *m_pendingGroup; - TransitionGroup *m_drawGroup; - TransitionGroup *m_secondaryDrawGroup; // needed to draw the last frame of the previous draw group once more. + TransitionGroup* m_currentGroup; + TransitionGroup* m_pendingGroup; + TransitionGroup* m_drawGroup; + TransitionGroup* m_secondaryDrawGroup; // needed to draw the last frame of the previous draw group once more. }; -void PushButtonImageDrawThree(GameWindow *window, Int alpha ); - +void PushButtonImageDrawThree(GameWindow* window, Int alpha); //----------------------------------------------------------------------------- // INLINING /////////////////////////////////////////////////////////////////// @@ -692,4 +704,4 @@ void PushButtonImageDrawThree(GameWindow *window, Int alpha ); //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- -extern GameWindowTransitionsHandler *TheTransitionHandler; +extern GameWindowTransitionsHandler* TheTransitionHandler; diff --git a/Core/GameEngine/Include/GameClient/GlobalLanguage.h b/Core/GameEngine/Include/GameClient/GlobalLanguage.h index b256c6d6259..6ac64b6b4c7 100644 --- a/Core/GameEngine/Include/GameClient/GlobalLanguage.h +++ b/Core/GameEngine/Include/GameClient/GlobalLanguage.h @@ -66,13 +66,12 @@ class AsciiString; class GlobalLanguage : public SubsystemInterface { public: - enum ResolutionFontSizeMethod { - ResolutionFontSizeMethod_Classic, // Uses the original scaling method. Scales poorly on wide screens and large resolutions. + ResolutionFontSizeMethod_Classic, // Uses the original scaling method. Scales poorly on wide screens and large resolutions. ResolutionFontSizeMethod_ClassicNoCeiling, // Uses the original scaling method, but without ceiling. Works ok for the original Game UI and with large resolutions. Scales poorly on very wide screens. - ResolutionFontSizeMethod_Strict, // Uses a strict scaling method. Width and height are strictly bounded on upscales. Works well for accurate UI layouts and with large resolutions. - ResolutionFontSizeMethod_Balanced, // Uses a balanced scaling method. Width and height are evenly weighted for upscales. Works well for the original Game UI and with large resolutions. + ResolutionFontSizeMethod_Strict, // Uses a strict scaling method. Width and height are strictly bounded on upscales. Works well for accurate UI layouts and with large resolutions. + ResolutionFontSizeMethod_Balanced, // Uses a balanced scaling method. Width and height are evenly weighted for upscales. Works well for the original Game UI and with large resolutions. ResolutionFontSizeMethod_Default = ResolutionFontSizeMethod_ClassicNoCeiling, }; @@ -80,7 +79,6 @@ class GlobalLanguage : public SubsystemInterface typedef std::list StringList; // Used for our font file names that we want to load public: - GlobalLanguage(); virtual ~GlobalLanguage() override; @@ -97,33 +95,33 @@ class GlobalLanguage : public SubsystemInterface // Defaults to a scaler of 1 for a uniform resolution scale. static Real getResolutionFontSizeScale(ResolutionFontSizeMethod method, Real scaler = 1.0f); - static void parseFontFileName(INI *ini, void *instance, void *store, const void *userData); - static void parseFontDesc(INI *ini, void *instance, void *store, const void *userData); + static void parseFontFileName(INI* ini, void* instance, void* store, const void* userData); + static void parseFontDesc(INI* ini, void* instance, void* store, const void* userData); AsciiString m_unicodeFontName; AsciiString m_unicodeFontFileName; Bool m_useHardWrap; Int m_militaryCaptionSpeed; Int m_militaryCaptionDelayMS; - FontDesc m_copyrightFont; - FontDesc m_messageFont; - FontDesc m_militaryCaptionTitleFont; - FontDesc m_militaryCaptionFont; - FontDesc m_superweaponCountdownNormalFont; - FontDesc m_superweaponCountdownReadyFont; - FontDesc m_namedTimerCountdownNormalFont; - FontDesc m_namedTimerCountdownReadyFont; - FontDesc m_drawableCaptionFont; - FontDesc m_defaultWindowFont; - FontDesc m_defaultDisplayStringFont; - FontDesc m_tooltipFontName; - FontDesc m_nativeDebugDisplay; - FontDesc m_drawGroupInfoFont; - FontDesc m_creditsTitleFont; - FontDesc m_creditsPositionFont; - FontDesc m_creditsNormalFont; - Real m_resolutionFontSizeAdjustment; - Real m_userResolutionFontSizeAdjustment; + FontDesc m_copyrightFont; + FontDesc m_messageFont; + FontDesc m_militaryCaptionTitleFont; + FontDesc m_militaryCaptionFont; + FontDesc m_superweaponCountdownNormalFont; + FontDesc m_superweaponCountdownReadyFont; + FontDesc m_namedTimerCountdownNormalFont; + FontDesc m_namedTimerCountdownReadyFont; + FontDesc m_drawableCaptionFont; + FontDesc m_defaultWindowFont; + FontDesc m_defaultDisplayStringFont; + FontDesc m_tooltipFontName; + FontDesc m_nativeDebugDisplay; + FontDesc m_drawGroupInfoFont; + FontDesc m_creditsTitleFont; + FontDesc m_creditsPositionFont; + FontDesc m_creditsNormalFont; + Real m_resolutionFontSizeAdjustment; + Real m_userResolutionFontSizeAdjustment; ResolutionFontSizeMethod m_resolutionFontSizeMethod; StringList m_localFonts; // List of the font filenames that are in our local directory }; @@ -135,4 +133,4 @@ class GlobalLanguage : public SubsystemInterface //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- -extern GlobalLanguage *TheGlobalLanguageData; +extern GlobalLanguage* TheGlobalLanguageData; diff --git a/Core/GameEngine/Include/GameClient/GraphDraw.h b/Core/GameEngine/Include/GameClient/GraphDraw.h index 12ab92af412..9d2c2cb43b2 100644 --- a/Core/GameEngine/Include/GameClient/GraphDraw.h +++ b/Core/GameEngine/Include/GameClient/GraphDraw.h @@ -57,29 +57,37 @@ typedef std::pair PairAsciiStringReal; typedef std::vector VecGraphEntries; typedef VecGraphEntries::iterator VecGraphEntriesIt; -enum { MAX_GRAPH_VALUES = 36 }; -enum { BAR_HEIGHT = 14 }; -enum { BAR_SPACE = 2 }; +enum +{ + MAX_GRAPH_VALUES = 36 +}; +enum +{ + BAR_HEIGHT = 14 +}; +enum +{ + BAR_SPACE = 2 +}; class DisplayString; class GraphDraw { - public: - GraphDraw(); - virtual ~GraphDraw(); +public: + GraphDraw(); + virtual ~GraphDraw(); - void addEntry(AsciiString str, Real val); - // Called during begin/end - void render(); - void clear(); + void addEntry(AsciiString str, Real val); + // Called during begin/end + void render(); + void clear(); - protected: - VecGraphEntries m_graphEntries; - DisplayString *m_displayStrings[MAX_GRAPH_VALUES]; +protected: + VecGraphEntries m_graphEntries; + DisplayString* m_displayStrings[MAX_GRAPH_VALUES]; }; -extern GraphDraw *TheGraphDraw; - +extern GraphDraw* TheGraphDraw; #endif /* PERF_TIMERS */ diff --git a/Core/GameEngine/Include/GameClient/HeaderTemplate.h b/Core/GameEngine/Include/GameClient/HeaderTemplate.h index f07e9edca1b..19efa75f9d0 100644 --- a/Core/GameEngine/Include/GameClient/HeaderTemplate.h +++ b/Core/GameEngine/Include/GameClient/HeaderTemplate.h @@ -68,12 +68,11 @@ class HeaderTemplate HeaderTemplate(); ~HeaderTemplate(); - GameFont *m_font; + GameFont* m_font; AsciiString m_name; AsciiString m_fontName; Int m_point; Bool m_bold; - }; class HeaderTemplateManager @@ -84,27 +83,25 @@ class HeaderTemplateManager void init(); - const FieldParse *getFieldParse() const { return m_headerFieldParseTable; } ///< Return the field parse info + const FieldParse* getFieldParse() const { return m_headerFieldParseTable; } ///< Return the field parse info static const FieldParse m_headerFieldParseTable[]; - HeaderTemplate *findHeaderTemplate( AsciiString name ); - HeaderTemplate *newHeaderTemplate( AsciiString name ); + HeaderTemplate* findHeaderTemplate(AsciiString name); + HeaderTemplate* newHeaderTemplate(AsciiString name); - GameFont *getFontFromTemplate( AsciiString name ); - HeaderTemplate *getFirstHeader(); - HeaderTemplate *getNextHeader( HeaderTemplate *ht ); + GameFont* getFontFromTemplate(AsciiString name); + HeaderTemplate* getFirstHeader(); + HeaderTemplate* getNextHeader(HeaderTemplate* ht); void onResolutionChanged(); private: void populateGameFonts(); - typedef std::list< HeaderTemplate* > HeaderTemplateList; + typedef std::list HeaderTemplateList; typedef HeaderTemplateList::iterator HeaderTemplateListIt; HeaderTemplateList m_headerTemplateList; - }; - //----------------------------------------------------------------------------- // INLINING /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -112,4 +109,4 @@ class HeaderTemplateManager //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- -extern HeaderTemplateManager *TheHeaderTemplateManager; +extern HeaderTemplateManager* TheHeaderTemplateManager; diff --git a/Core/GameEngine/Include/GameClient/IMEManager.h b/Core/GameEngine/Include/GameClient/IMEManager.h index 91543cff654..e280ce08911 100644 --- a/Core/GameEngine/Include/GameClient/IMEManager.h +++ b/Core/GameEngine/Include/GameClient/IMEManager.h @@ -62,7 +62,6 @@ class UnicodeString; // Type Defines //---------------------------------------------------------------------------- - //=============================== // IMEManagerInterface //=============================== @@ -70,43 +69,37 @@ class UnicodeString; class IMEManagerInterface : public SubsystemInterface { - public: - - virtual ~IMEManagerInterface() override {}; - - virtual void attach( GameWindow *window ) = 0; ///< attach IME to specified window - virtual void detach() = 0; ///< detach IME from current window - virtual void enable() = 0; ///< Enable IME - virtual void disable() = 0; ///< Disable IME - virtual Bool isEnabled() = 0; ///< Is IME enabled - virtual Bool isAttachedTo( GameWindow *window ) = 0; ///< Is the manager currently attached to the window - virtual GameWindow* getWindow() = 0; ///< Returns the window we are currently attached to - virtual Bool isComposing() = 0; ///< Manager is currently composing new input string - virtual void getCompositionString( UnicodeString &string ) = 0; ///< Return the current composition string - virtual Int getCompositionCursorPosition() =0; ///< Returns the composition cursor position - virtual Int getIndexBase() = 0; ///< Get index base for candidate list - - - virtual Int getCandidateCount() = 0; ///< Returns the total number of candidates - virtual const UnicodeString* getCandidate( Int index ) = 0; ///< Returns the candidate string - virtual Int getSelectedCandidateIndex() = 0; ///< Returns the indexed of the currently selected candidate - virtual Int getCandidatePageSize() = 0; ///< Returns the page size for the candidates list - virtual Int getCandidatePageStart() = 0; ///< Returns the index of the first visibel candidate - - - - /// Checks for and service IME messages. Returns TRUE if message serviced - virtual Bool serviceIMEMessage( void *windowsHandle, - UnsignedInt message, - Int wParam, - Int lParam ) = 0; - virtual Int result() = 0; ///< result return value of last serviced IME message +public: + virtual ~IMEManagerInterface() override {}; + + virtual void attach(GameWindow* window) = 0; ///< attach IME to specified window + virtual void detach() = 0; ///< detach IME from current window + virtual void enable() = 0; ///< Enable IME + virtual void disable() = 0; ///< Disable IME + virtual Bool isEnabled() = 0; ///< Is IME enabled + virtual Bool isAttachedTo(GameWindow* window) = 0; ///< Is the manager currently attached to the window + virtual GameWindow* getWindow() = 0; ///< Returns the window we are currently attached to + virtual Bool isComposing() = 0; ///< Manager is currently composing new input string + virtual void getCompositionString(UnicodeString& string) = 0; ///< Return the current composition string + virtual Int getCompositionCursorPosition() = 0; ///< Returns the composition cursor position + virtual Int getIndexBase() = 0; ///< Get index base for candidate list + + virtual Int getCandidateCount() = 0; ///< Returns the total number of candidates + virtual const UnicodeString* getCandidate(Int index) = 0; ///< Returns the candidate string + virtual Int getSelectedCandidateIndex() = 0; ///< Returns the indexed of the currently selected candidate + virtual Int getCandidatePageSize() = 0; ///< Returns the page size for the candidates list + virtual Int getCandidatePageStart() = 0; ///< Returns the index of the first visibel candidate + + /// Checks for and service IME messages. Returns TRUE if message serviced + virtual Bool serviceIMEMessage(void* windowsHandle, + UnsignedInt message, + Int wParam, + Int lParam) = 0; + virtual Int result() = 0; ///< result return value of last serviced IME message }; - -extern IMEManagerInterface *TheIMEManager; -extern IMEManagerInterface *CreateIMEManagerInterface(); - +extern IMEManagerInterface* TheIMEManager; +extern IMEManagerInterface* CreateIMEManagerInterface(); //---------------------------------------------------------------------------- // Inlining diff --git a/Core/GameEngine/Include/GameClient/Keyboard.h b/Core/GameEngine/Include/GameClient/Keyboard.h index 8c21aae40b0..53469c9ac8d 100644 --- a/Core/GameEngine/Include/GameClient/Keyboard.h +++ b/Core/GameEngine/Include/GameClient/Keyboard.h @@ -65,7 +65,8 @@ struct KeyboardIO { - enum StatusType CPP_11(: UnsignedByte) + enum StatusType + CPP_11( : UnsignedByte) { STATUS_UNUSED = 0x00, // Key has not been used STATUS_USED = 0x01 // Key has been eaten diff --git a/Core/GameEngine/Include/GameClient/LanguageFilter.h b/Core/GameEngine/Include/GameClient/LanguageFilter.h index cf83d64ce03..64bdcceefda 100644 --- a/Core/GameEngine/Include/GameClient/LanguageFilter.h +++ b/Core/GameEngine/Include/GameClient/LanguageFilter.h @@ -62,7 +62,8 @@ typedef std::map::iterator LangMapIt static const int LANGUAGE_XOR_KEY = 0x5555; static const char BadWordFileName[] = "langdata.dat"; -class LanguageFilter : public SubsystemInterface { +class LanguageFilter : public SubsystemInterface +{ public: LanguageFilter(); virtual ~LanguageFilter() override; @@ -70,14 +71,14 @@ class LanguageFilter : public SubsystemInterface { virtual void init() override; virtual void reset() override; virtual void update() override; - void filterLine(UnicodeString &line); + void filterLine(UnicodeString& line); protected: - Bool readWord(File *file1, WideChar *buf); - void unHaxor(UnicodeString &word); + Bool readWord(File* file1, WideChar* buf); + void unHaxor(UnicodeString& word); LangMap m_wordList; LangMap m_subWordList; }; -extern LanguageFilter *TheLanguageFilter; -LanguageFilter * createLanguageFilter(); +extern LanguageFilter* TheLanguageFilter; +LanguageFilter* createLanguageFilter(); diff --git a/Core/GameEngine/Include/GameClient/Line2D.h b/Core/GameEngine/Include/GameClient/Line2D.h index 8e2217a9601..cba70e1b733 100644 --- a/Core/GameEngine/Include/GameClient/Line2D.h +++ b/Core/GameEngine/Include/GameClient/Line2D.h @@ -32,53 +32,51 @@ typedef std::vector Coord2DVector; typedef std::vector Coord3DVector; - // PROTOTYPES ///////////////////////////////////////////////////////////////////////////////////// -extern Bool ClipLine2D( ICoord2D *p1, ICoord2D *p2, ICoord2D *c1, ICoord2D *c2, - IRegion2D *clipRegion ); +extern Bool ClipLine2D(ICoord2D* p1, ICoord2D* p2, ICoord2D* c1, ICoord2D* c2, + IRegion2D* clipRegion); ///< IntersectLine2D will take two segments delimited by ab and cd and will return whether ///< they intersect within the length of ab. They will also return the intersection point out ///< intersection if it is non-null. -extern Bool IntersectLine2D( const Coord2D *a, const Coord2D *b, - const Coord2D *c, const Coord2D *d, - Coord2D *intersection = nullptr); +extern Bool IntersectLine2D(const Coord2D* a, const Coord2D* b, + const Coord2D* c, const Coord2D* d, + Coord2D* intersection = nullptr); ///< PointInsideRect2D will return true iff inputPoint lies iside of the rectangle specified ///< by bl, tl, br, tr. -extern Bool PointInsideRect2D( const Coord2D *bl, const Coord2D *tl, - const Coord2D *br, const Coord2D *tr, - const Coord2D *inputPoint); +extern Bool PointInsideRect2D(const Coord2D* bl, const Coord2D* tl, + const Coord2D* br, const Coord2D* tr, + const Coord2D* inputPoint); ///< Checks if a point is inside a perfect rectangle (top left and bottom right) -extern Bool Coord3DInsideRect2D( const Coord3D *inputPoint, const Coord2D *tl, const Coord2D *br ); +extern Bool Coord3DInsideRect2D(const Coord3D* inputPoint, const Coord2D* tl, const Coord2D* br); ///< Scales a rect by a factor either growing or shrinking it. -extern void ScaleRect2D( Coord2D *tl, Coord2D *br, Real scaleFactor ); +extern void ScaleRect2D(Coord2D* tl, Coord2D* br, Real scaleFactor); /** PointInsideRect3D will return true iff inputPoint lies iside of the rectangle specified by bl, tl, br, tr. It does not actually consider the Z value, it is merely a convenience function for calling PointInsideRect2D */ -extern Bool PointInsideRect3D( const Coord3D *bl, const Coord3D *tl, - const Coord3D *br, const Coord3D *tr, - const Coord3D *inputPoint); - +extern Bool PointInsideRect3D(const Coord3D* bl, const Coord3D* tl, + const Coord3D* br, const Coord3D* tr, + const Coord3D* inputPoint); ///< This function will take the ptToTest and will perform even-odd checking against the area. ///< If the area is not closed, it will be closed for this check. -extern Bool PointInsideArea2D( const Coord2D *ptToTest, - const Coord2D *area, - Int numPointsInArea); +extern Bool PointInsideArea2D(const Coord2D* ptToTest, + const Coord2D* area, + Int numPointsInArea); ///< This function will take the ptToTest and will perform even-odd checking against the area. ///< The area and the ptToTest will be flattened first, so a 2-D check will be sufficient. ///< This function is only for convenience so that points do not need to first be flattened. -extern Bool PointInsideArea2D( const Coord3D *ptToTest, - const Coord3D *area, - Int numPointsInArea); +extern Bool PointInsideArea2D(const Coord3D* ptToTest, + const Coord3D* area, + Int numPointsInArea); ///< This function will find the shortest distance between the given segment (ab) and the pt. ///< It will also give the intersection points on the segment (ab) if desired. ///< outU will return the U value determined. This is a shortcut for panning -extern void ShortestDistancePointToSegment2D( const Coord2D *a, const Coord2D *b, const Coord2D *pt, - Real *outDistance, Coord2D *outPosition, Real *outU ); +extern void ShortestDistancePointToSegment2D(const Coord2D* a, const Coord2D* b, const Coord2D* pt, + Real* outDistance, Coord2D* outPosition, Real* outU); diff --git a/Core/GameEngine/Include/GameClient/LoadScreen.h b/Core/GameEngine/Include/GameClient/LoadScreen.h index b6afb7a101e..760fe2062ab 100644 --- a/Core/GameEngine/Include/GameClient/LoadScreen.h +++ b/Core/GameEngine/Include/GameClient/LoadScreen.h @@ -46,8 +46,6 @@ class VideoBuffer; class VideoStreamInterface; class WindowVideoManager; - - /////////////////////////////////////////////////////////////////////////////////////////////////// // Class LoadScreen is the parent class for each other kind of load screen /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -57,18 +55,18 @@ class LoadScreen LoadScreen(); virtual ~LoadScreen(); - virtual void init( GameInfo *game ) = 0; ///< Init the loadscreen - virtual void reset() = 0; ///< Reset the system - virtual void update() = 0; ///< Update the state of the slider bars - virtual void update( Int percent ); ///< Update the state of the slider bars + virtual void init(GameInfo* game) = 0; ///< Init the loadscreen + virtual void reset() = 0; ///< Reset the system + virtual void update() = 0; ///< Update the state of the slider bars + virtual void update(Int percent); ///< Update the state of the slider bars virtual void processProgress(Int playerId, Int percentage) = 0; - virtual void setProgressRange( Int min, Int max ) = 0; + virtual void setProgressRange(Int min, Int max) = 0; + protected: - void setLoadScreen( GameWindow *g ) { m_loadScreen = g; } - GameWindow *m_loadScreen; ///< The GameWindow that is our loadscreen + void setLoadScreen(GameWindow* g) { m_loadScreen = g; } + GameWindow* m_loadScreen; ///< The GameWindow that is our loadscreen private: - }; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -80,28 +78,28 @@ class SinglePlayerLoadScreen : public LoadScreen SinglePlayerLoadScreen(); virtual ~SinglePlayerLoadScreen() override; - virtual void init( GameInfo *game ) override; ///< Init the loadscreen - virtual void reset() override; ///< Reset the system + virtual void init(GameInfo* game) override; ///< Init the loadscreen + virtual void reset() override; ///< Reset the system virtual void update() { DEBUG_CRASH(("Call update(Int) instead. This update isn't supported")); }; - virtual void update(Int percent) override; ///< Update the state of the progress bar + virtual void update(Int percent) override; ///< Update the state of the progress bar virtual void processProgress(Int playerId, Int percentage) override { DEBUG_CRASH(("We Got to a single player load screen throw the Network...")); } - virtual void setProgressRange( Int min, Int max ) override; + virtual void setProgressRange(Int min, Int max) override; private: - GameWindow *m_progressBar; ///< Pointer to the Progress Bar on the window - GameWindow *m_percent; + GameWindow* m_progressBar; ///< Pointer to the Progress Bar on the window + GameWindow* m_percent; - GameWindow *m_objectiveWin; - GameWindow *m_objectiveLines[MAX_OBJECTIVE_LINES]; - GameWindow *m_unitDesc[MAX_DISPLAYED_UNITS]; - GameWindow *m_location; + GameWindow* m_objectiveWin; + GameWindow* m_objectiveLines[MAX_OBJECTIVE_LINES]; + GameWindow* m_unitDesc[MAX_DISPLAYED_UNITS]; + GameWindow* m_location; Int m_currentObjectiveLine; Int m_currentObjectiveLineCharacter; @@ -110,17 +108,15 @@ class SinglePlayerLoadScreen : public LoadScreen UnicodeString m_unicodeObjectiveLines[MAX_OBJECTIVE_LINES]; - VideoBuffer *m_videoBuffer; - VideoStreamInterface *m_videoStream; + VideoBuffer* m_videoBuffer; + VideoStreamInterface* m_videoStream; - void moveWindows( Int frame ); + void moveWindows(Int frame); AudioEventRTS m_ambientLoop; AudioHandle m_ambientLoopHandle; }; - - /////////////////////////////////////////////////////////////////////////////////////////////////// // class ChallengeLoadScreen is to be used only when we're loading a Generals' Challenge mission /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -130,69 +126,67 @@ class ChallengeLoadScreen : public LoadScreen ChallengeLoadScreen(); virtual ~ChallengeLoadScreen() override; - virtual void init( GameInfo *game ) override; ///< Init the loadscreen - virtual void reset() override; ///< Reset the system + virtual void init(GameInfo* game) override; ///< Init the loadscreen + virtual void reset() override; ///< Reset the system virtual void update() { DEBUG_CRASH(("Call update(Int) instead. This update isn't supported")); }; - virtual void update(Int percent) override; ///< Update the state of the progress bar + virtual void update(Int percent) override; ///< Update the state of the progress bar virtual void processProgress(Int playerId, Int percentage) override { DEBUG_CRASH(("We Got to a single player load screen throw the Network...")); } - virtual void setProgressRange( Int min, Int max ) override; + virtual void setProgressRange(Int min, Int max) override; private: - GameWindow *m_progressBar; ///< Pointer to the Progress Bar on the window + GameWindow* m_progressBar; ///< Pointer to the Progress Bar on the window - VideoBuffer *m_videoBuffer; - VideoStreamInterface *m_videoStream; + VideoBuffer* m_videoBuffer; + VideoStreamInterface* m_videoStream; - WindowVideoManager *m_wndVideoManager; + WindowVideoManager* m_wndVideoManager; AudioEventRTS m_ambientLoop; AudioHandle m_ambientLoopHandle; - GameWindow *m_bioNameLeft; - GameWindow *m_bioAgeLeft; - GameWindow *m_bioBirthplaceLeft; - GameWindow *m_bioStrategyLeft; - GameWindow *m_bioBigNameEntryLeft; - GameWindow *m_bioNameEntryLeft; - GameWindow *m_bioAgeEntryLeft; - GameWindow *m_bioBirthplaceEntryLeft; - GameWindow *m_bioStrategyEntryLeft; - GameWindow *m_bioNameRight; - GameWindow *m_bioAgeRight; - GameWindow *m_bioBirthplaceRight; - GameWindow *m_bioStrategyRight; - GameWindow *m_bioBigNameEntryRight; - GameWindow *m_bioNameEntryRight; - GameWindow *m_bioAgeEntryRight; - GameWindow *m_bioBirthplaceEntryRight; - GameWindow *m_bioStrategyEntryRight; - - GameWindow *m_portraitLeft; - GameWindow *m_portraitRight; - GameWindow *m_portraitMovieLeft; - GameWindow *m_portraitMovieRight; - -// GameWindow *m_overlayReticleCrosshairs; - GameWindow *m_overlayReticleCircleLineOuter; - GameWindow *m_overlayReticleCircleLineInner; - GameWindow *m_overlayReticleCircleAlphaOuter; - GameWindow *m_overlayReticleCircleAlphaInner; - GameWindow *m_overlayVsBackdrop; - GameWindow *m_overlayVs; - - void activatePieces( Int frame, const GeneralPersona *generalPlayer, const GeneralPersona *generalOpponent ); - void activatePiecesMinSpec(const GeneralPersona *generalPlayer, const GeneralPersona *generalOpponent); + GameWindow* m_bioNameLeft; + GameWindow* m_bioAgeLeft; + GameWindow* m_bioBirthplaceLeft; + GameWindow* m_bioStrategyLeft; + GameWindow* m_bioBigNameEntryLeft; + GameWindow* m_bioNameEntryLeft; + GameWindow* m_bioAgeEntryLeft; + GameWindow* m_bioBirthplaceEntryLeft; + GameWindow* m_bioStrategyEntryLeft; + GameWindow* m_bioNameRight; + GameWindow* m_bioAgeRight; + GameWindow* m_bioBirthplaceRight; + GameWindow* m_bioStrategyRight; + GameWindow* m_bioBigNameEntryRight; + GameWindow* m_bioNameEntryRight; + GameWindow* m_bioAgeEntryRight; + GameWindow* m_bioBirthplaceEntryRight; + GameWindow* m_bioStrategyEntryRight; + + GameWindow* m_portraitLeft; + GameWindow* m_portraitRight; + GameWindow* m_portraitMovieLeft; + GameWindow* m_portraitMovieRight; + + // GameWindow *m_overlayReticleCrosshairs; + GameWindow* m_overlayReticleCircleLineOuter; + GameWindow* m_overlayReticleCircleLineInner; + GameWindow* m_overlayReticleCircleAlphaOuter; + GameWindow* m_overlayReticleCircleAlphaInner; + GameWindow* m_overlayVsBackdrop; + GameWindow* m_overlayVs; + + void activatePieces(Int frame, const GeneralPersona* generalPlayer, const GeneralPersona* generalOpponent); + void activatePiecesMinSpec(const GeneralPersona* generalPlayer, const GeneralPersona* generalOpponent); }; - - /////////////////////////////////////////////////////////////////////////////////////////////////// // class ShellGameLoadScreen is to be used for the Shell Game loadscreen //// /////////////////////////////////////////////////////////////////////////////////////////////// @@ -202,25 +196,23 @@ class ShellGameLoadScreen : public LoadScreen ShellGameLoadScreen(); virtual ~ShellGameLoadScreen() override; - virtual void init( GameInfo *game ) override; ///< Init the loadscreen - virtual void reset() override; ///< Reset the system + virtual void init(GameInfo* game) override; ///< Init the loadscreen + virtual void reset() override; ///< Reset the system virtual void update() { DEBUG_CRASH(("Call update(Int) instead. This update isn't supported")); }; - virtual void update(Int percent) override; ///< Update the state of the progress bar + virtual void update(Int percent) override; ///< Update the state of the progress bar virtual void processProgress(Int playerId, Int percentage) override { DEBUG_CRASH(("We Got to a single player load screen throw the Network...")); } - virtual void setProgressRange( Int min, Int max ) override { } + virtual void setProgressRange(Int min, Int max) override {} private: - GameWindow *m_progressBar ; ///< Pointer to the Progress Bar on the window - + GameWindow* m_progressBar; ///< Pointer to the Progress Bar on the window }; - /////////////////////////////////////////////////////////////////////////////////////////////////// // class MultiPlayerLoadScreen is to be used for multiplayer communication on the loadscreens //// /////////////////////////////////////////////////////////////////////////////////////////////// @@ -230,26 +222,26 @@ class MultiPlayerLoadScreen : public LoadScreen MultiPlayerLoadScreen(); virtual ~MultiPlayerLoadScreen() override; - virtual void init( GameInfo *game ) override; ///< Init the loadscreen - virtual void reset() override; ///< Reset the system + virtual void init(GameInfo* game) override; ///< Init the loadscreen + virtual void reset() override; ///< Reset the system virtual void update() { DEBUG_CRASH(("Call update(Int) instead. This update isn't supported")); }; - virtual void update(Int percent) override; ///< Update the state of the progress bar + virtual void update(Int percent) override; ///< Update the state of the progress bar virtual void processProgress(Int playerId, Int percentage) override; - virtual void setProgressRange( Int min, Int max ) override { } -private: - GameWindow *m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window - GameWindow *m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window - GameWindow *m_playerSide[MAX_SLOTS]; ///< pointer array to all the static text player sides - Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list) - GameWindow *m_mapPreview; - GameWindow *m_buttonMapStartPosition[MAX_SLOTS]; - GameWindow *m_portraitLocalGeneral; - GameWindow *m_featuresLocalGeneral; - GameWindow *m_nameLocalGeneral; + virtual void setProgressRange(Int min, Int max) override {} +private: + GameWindow* m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window + GameWindow* m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window + GameWindow* m_playerSide[MAX_SLOTS]; ///< pointer array to all the static text player sides + Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list) + GameWindow* m_mapPreview; + GameWindow* m_buttonMapStartPosition[MAX_SLOTS]; + GameWindow* m_portraitLocalGeneral; + GameWindow* m_featuresLocalGeneral; + GameWindow* m_nameLocalGeneral; }; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -261,33 +253,34 @@ class GameSpyLoadScreen : public LoadScreen GameSpyLoadScreen(); virtual ~GameSpyLoadScreen() override; - virtual void init( GameInfo *game ) override; ///< Init the loadscreen - virtual void reset() override; ///< Reset the system + virtual void init(GameInfo* game) override; ///< Init the loadscreen + virtual void reset() override; ///< Reset the system virtual void update() { DEBUG_CRASH(("Call update(Int) instead. This update isn't supported")); }; - virtual void update(Int percent) override; ///< Update the state of the progress bar + virtual void update(Int percent) override; ///< Update the state of the progress bar virtual void processProgress(Int playerId, Int percentage) override; - virtual void setProgressRange( Int min, Int max ) override { } + virtual void setProgressRange(Int min, Int max) override {} + private: - GameWindow *m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window - GameWindow *m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window - GameWindow *m_playerSide[MAX_SLOTS]; ///< pointer array to all the static text player sides - GameWindow *m_playerFavoriteFactions[MAX_SLOTS]; ///< pointer array to all the static text player sides - GameWindow *m_playerTotalDisconnects[MAX_SLOTS]; ///< pointer array to all the static text player sides - GameWindow *m_playerWin[MAX_SLOTS]; ///< pointer array to all the static text player sides - GameWindow *m_playerWinLosses[MAX_SLOTS]; ///< pointer array to all the static text player sides - GameWindow *m_playerRank[MAX_SLOTS]; ///< pointer array to all the static text player sides - GameWindow *m_playerOfficerMedal[MAX_SLOTS]; ///< pointer array to all the static text player munkees - GameWindow *m_mapPreview; - GameWindow *m_buttonMapStartPosition[MAX_SLOTS]; - - Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list) - - GameWindow *m_portraitLocalGeneral; - GameWindow *m_featuresLocalGeneral; - GameWindow *m_nameLocalGeneral; + GameWindow* m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window + GameWindow* m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window + GameWindow* m_playerSide[MAX_SLOTS]; ///< pointer array to all the static text player sides + GameWindow* m_playerFavoriteFactions[MAX_SLOTS]; ///< pointer array to all the static text player sides + GameWindow* m_playerTotalDisconnects[MAX_SLOTS]; ///< pointer array to all the static text player sides + GameWindow* m_playerWin[MAX_SLOTS]; ///< pointer array to all the static text player sides + GameWindow* m_playerWinLosses[MAX_SLOTS]; ///< pointer array to all the static text player sides + GameWindow* m_playerRank[MAX_SLOTS]; ///< pointer array to all the static text player sides + GameWindow* m_playerOfficerMedal[MAX_SLOTS]; ///< pointer array to all the static text player munkees + GameWindow* m_mapPreview; + GameWindow* m_buttonMapStartPosition[MAX_SLOTS]; + + Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list) + + GameWindow* m_portraitLocalGeneral; + GameWindow* m_featuresLocalGeneral; + GameWindow* m_nameLocalGeneral; }; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -299,28 +292,29 @@ class MapTransferLoadScreen : public LoadScreen MapTransferLoadScreen(); virtual ~MapTransferLoadScreen() override; - virtual void init( GameInfo *game ) override; ///< Init the loadscreen - virtual void reset() override; ///< Reset the system + virtual void init(GameInfo* game) override; ///< Init the loadscreen + virtual void reset() override; ///< Reset the system virtual void update() { DEBUG_CRASH(("Call update(Int) instead. This update isn't supported")); }; - virtual void update(Int percent) override; ///< Update the state of the progress bar + virtual void update(Int percent) override; ///< Update the state of the progress bar virtual void processProgress(Int playerId, Int percentage) override { DEBUG_CRASH(("Call processProgress(Int, Int, AsciiString) instead.")); } void processProgress(Int playerId, Int percentage, AsciiString stateStr); - virtual void setProgressRange( Int min, Int max ) override { } + virtual void setProgressRange(Int min, Int max) override {} void processTimeout(Int secondsLeft); void setCurrentFilename(AsciiString filename); + private: - GameWindow *m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window - GameWindow *m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window - GameWindow *m_progressText[MAX_SLOTS]; ///< pointer array to all the static text player sides - Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list) - Int m_oldProgress[MAX_SLOTS]; ///< old vals, so we can call processProgress() every frame and not touch the GUI - GameWindow *m_fileNameText; - GameWindow *m_timeoutText; - Int m_oldTimeout; ///< old val, so we can call processTimeout() every frame and not touch the GUI + GameWindow* m_progressBars[MAX_SLOTS]; ///< pointer array to all the progress bars on the window + GameWindow* m_playerNames[MAX_SLOTS]; ///< pointer array to all the static text player names on the window + GameWindow* m_progressText[MAX_SLOTS]; ///< pointer array to all the static text player sides + Int m_playerLookup[MAX_SLOTS]; ///< lookup table to translate network slot info screen slot (to account for holes in the slot list) + Int m_oldProgress[MAX_SLOTS]; ///< old vals, so we can call processProgress() every frame and not touch the GUI + GameWindow* m_fileNameText; + GameWindow* m_timeoutText; + Int m_oldTimeout; ///< old val, so we can call processTimeout() every frame and not touch the GUI }; diff --git a/Core/GameEngine/Include/GameClient/MapUtil.h b/Core/GameEngine/Include/GameClient/MapUtil.h index 7cb5c71b9db..87568301190 100644 --- a/Core/GameEngine/Include/GameClient/MapUtil.h +++ b/Core/GameEngine/Include/GameClient/MapUtil.h @@ -42,8 +42,11 @@ class Image; class DataChunkInput; struct DataChunkInfo; // This matches the windows timestamp. -enum { SUPPLY_TECH_SIZE = 15}; -typedef std::list ICoord2DList; +enum +{ + SUPPLY_TECH_SIZE = 15 +}; +typedef std::list ICoord2DList; class TechAndSupplyImages { @@ -58,15 +61,14 @@ struct WinTimeStamp UnsignedInt m_highTimeStamp; }; - class WaypointMap : public std::map { public: - void update(); ///< returns the number of multiplayer start spots found + void update(); ///< returns the number of multiplayer start spots found Int m_numStartSpots; }; -typedef std::list Coord3DList; +typedef std::list Coord3DList; class MapMetaData { @@ -99,9 +101,9 @@ class MapCache : public std::map public: MapCache() - : m_doCreateStandardMapCacheINI(TRUE) - , m_doLoadStandardMapCacheINI(TRUE) - , m_doLoadUserMapCacheINI(TRUE) + : m_doCreateStandardMapCacheINI(TRUE) + , m_doLoadStandardMapCacheINI(TRUE) + , m_doLoadUserMapCacheINI(TRUE) {} void updateCache(); @@ -110,20 +112,24 @@ class MapCache : public std::map AsciiString getUserMapDir() const; AsciiString getMapExtension() const; - const MapMetaData *findMap(AsciiString mapName); + const MapMetaData* findMap(AsciiString mapName); // allow us to create a set of shippable maps to be in mapcache.ini. For use with -buildMapCache. - void addShippingMap(AsciiString mapName) { mapName.toLower(); m_allowedMaps.insert(mapName); } + void addShippingMap(AsciiString mapName) + { + mapName.toLower(); + m_allowedMaps.insert(mapName); + } private: - void prepareUnseenMaps(const AsciiString &mapDir); - Bool clearUnseenMaps(const AsciiString &mapDir); - void loadMapsFromMapCacheINI(const AsciiString &mapDir); - Bool loadMapsFromDisk(const AsciiString &mapDir, Bool isOfficial, Bool filterByAllowedMaps = FALSE); // returns true if we needed to (re)parse a map - Bool addMap(const AsciiString &mapDir, const AsciiString &fname, const AsciiString &lowerFname, FileInfo &fileInfo, Bool isOfficial); ///< returns true if it had to (re)parse the map - void writeCacheINI(const AsciiString &mapDir); + void prepareUnseenMaps(const AsciiString& mapDir); + Bool clearUnseenMaps(const AsciiString& mapDir); + void loadMapsFromMapCacheINI(const AsciiString& mapDir); + Bool loadMapsFromDisk(const AsciiString& mapDir, Bool isOfficial, Bool filterByAllowedMaps = FALSE); // returns true if we needed to (re)parse a map + Bool addMap(const AsciiString& mapDir, const AsciiString& fname, const AsciiString& lowerFname, FileInfo& fileInfo, Bool isOfficial); ///< returns true if it had to (re)parse the map + void writeCacheINI(const AsciiString& mapDir); - static const char *const m_mapCacheName; + static const char* const m_mapCacheName; MapNameSet m_allowedMaps; Bool m_doCreateStandardMapCacheINI; @@ -131,20 +137,20 @@ class MapCache : public std::map Bool m_doLoadUserMapCacheINI; }; -extern MapCache *TheMapCache; +extern MapCache* TheMapCache; extern TechAndSupplyImages TheSupplyAndTechImageLocations; // TheSuperHackers @refactor xezon 28/11/2025 Refactors the map list population implementation // by breaking it into smaller pieces to make it more maintainable. -Int populateMapListbox( GameWindow *listbox, Bool useSystemMaps, Bool isMultiplayer, AsciiString mapToSelect = AsciiString::TheEmptyString ); /// Read a list of maps from the run directory and fill in the listbox. Return the selected index -Int populateMapListboxNoReset( GameWindow *listbox, Bool useSystemMaps, Bool isMultiplayer, AsciiString mapToSelect = AsciiString::TheEmptyString ); /// Read a list of maps from the run directory and fill in the listbox. Return the selected index -Bool isValidMap( AsciiString mapName, Bool isMultiplayer ); /// Validate a map -Image *getMapPreviewImage( AsciiString mapName ); -AsciiString getDefaultMap( Bool isMultiplayer ); /// Find a valid map +Int populateMapListbox(GameWindow* listbox, Bool useSystemMaps, Bool isMultiplayer, AsciiString mapToSelect = AsciiString::TheEmptyString); /// Read a list of maps from the run directory and fill in the listbox. Return the selected index +Int populateMapListboxNoReset(GameWindow* listbox, Bool useSystemMaps, Bool isMultiplayer, AsciiString mapToSelect = AsciiString::TheEmptyString); /// Read a list of maps from the run directory and fill in the listbox. Return the selected index +Bool isValidMap(AsciiString mapName, Bool isMultiplayer); /// Validate a map +Image* getMapPreviewImage(AsciiString mapName); +AsciiString getDefaultMap(Bool isMultiplayer); /// Find a valid map AsciiString getDefaultOfficialMap(); -Bool isOfficialMap( AsciiString mapName ); -Bool parseMapPreviewChunk(DataChunkInput &file, DataChunkInfo *info, void *userData); -void findDrawPositions( Int startX, Int startY, Int width, Int height, Region3D extent, - ICoord2D *ul, ICoord2D *lr ); -Bool WouldMapTransfer( const AsciiString& mapName ); +Bool isOfficialMap(AsciiString mapName); +Bool parseMapPreviewChunk(DataChunkInput& file, DataChunkInfo* info, void* userData); +void findDrawPositions(Int startX, Int startY, Int width, Int height, Region3D extent, + ICoord2D* ul, ICoord2D* lr); +Bool WouldMapTransfer(const AsciiString& mapName); diff --git a/Core/GameEngine/Include/GameClient/Mouse.h b/Core/GameEngine/Include/GameClient/Mouse.h index 849a933f37f..a1d398ac076 100644 --- a/Core/GameEngine/Include/GameClient/Mouse.h +++ b/Core/GameEngine/Include/GameClient/Mouse.h @@ -56,7 +56,8 @@ // FORWARD REFERENCES ///////////////////////////////////////////////////////// -enum GameMode CPP_11(: Int); +enum GameMode +CPP_11( : Int); // TYPE DEFINES /////////////////////////////////////////////////////////////// diff --git a/Core/GameEngine/Include/GameClient/ParabolicEase.h b/Core/GameEngine/Include/GameClient/ParabolicEase.h index 3334def572b..4c13587ac6e 100644 --- a/Core/GameEngine/Include/GameClient/ParabolicEase.h +++ b/Core/GameEngine/Include/GameClient/ParabolicEase.h @@ -67,25 +67,25 @@ */ class ParabolicEase { - public: - explicit ParabolicEase(Real easeInTime = 0.0f, Real easeOutTime = 0.0f) - { setEaseTimes(easeInTime, easeOutTime); } +public: + explicit ParabolicEase(Real easeInTime = 0.0f, Real easeOutTime = 0.0f) + { setEaseTimes(easeInTime, easeOutTime); } - /// Initialize the ease-in/ease-out function. - /** - * \param easeInTime/\param easeOutTime is the amount of time to - * accomplish the transition. The time is normalized from 0 to 1. - */ - void setEaseTimes(Real easeInTime, Real easeOutTime); + /// Initialize the ease-in/ease-out function. + /** + * \param easeInTime/\param easeOutTime is the amount of time to + * accomplish the transition. The time is normalized from 0 to 1. + */ + void setEaseTimes(Real easeInTime, Real easeOutTime); - /// Evaluate the ease-in/ease-out function at time \param param. - /** - * \param param is normalized from 0 to 1. - */ - Real operator ()(Real param) const; + /// Evaluate the ease-in/ease-out function at time \param param. + /** + * \param param is normalized from 0 to 1. + */ + Real operator()(Real param) const; - private: - Real m_in, m_out; +private: + Real m_in, m_out; }; // ============================================================================ diff --git a/Core/GameEngine/Include/GameClient/ParticleSys.h b/Core/GameEngine/Include/GameClient/ParticleSys.h index 5054cd2b8f8..9a073e12105 100644 --- a/Core/GameEngine/Include/GameClient/ParticleSys.h +++ b/Core/GameEngine/Include/GameClient/ParticleSys.h @@ -36,10 +36,9 @@ #include "Common/SubsystemInterface.h" #include "GameClient/ClientRandomValue.h" -#include "WWMath/matrix3d.h" ///< @todo Replace with our own matrix library +#include "WWMath/matrix3d.h" ///< @todo Replace with our own matrix library #include "Common/STLTypedefs.h" - /// @todo Once the client framerate is decoupled, the frame counters within will have to become time-based class Particle; @@ -49,10 +48,11 @@ class Drawable; class Object; struct FieldParse; class INI; -class DebugWindowDialog; // really ParticleEditorDialog -class RenderInfoClass; // ick +class DebugWindowDialog; // really ParticleEditorDialog +class RenderInfoClass; // ick -enum ParticleSystemID CPP_11(: Int) +enum ParticleSystemID +CPP_11( : Int) { INVALID_PARTICLE_SYSTEM_ID = 0 }; diff --git a/Core/GameEngine/Include/GameClient/ProcessAnimateWindow.h b/Core/GameEngine/Include/GameClient/ProcessAnimateWindow.h index 42ebcbcd245..1eb84e50dfe 100644 --- a/Core/GameEngine/Include/GameClient/ProcessAnimateWindow.h +++ b/Core/GameEngine/Include/GameClient/ProcessAnimateWindow.h @@ -73,15 +73,14 @@ class GameWindow; class ProcessAnimateWindow { public: - - ProcessAnimateWindow(){}; - virtual ~ProcessAnimateWindow(){}; - - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) = 0; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) = 0; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) = 0; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) = 0; - virtual void setMaxDuration(UnsignedInt maxDuration) { } + ProcessAnimateWindow() {}; + virtual ~ProcessAnimateWindow() {}; + + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) = 0; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) = 0; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) = 0; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) = 0; + virtual void setMaxDuration(UnsignedInt maxDuration) {} }; //----------------------------------------------------------------------------- @@ -89,111 +88,103 @@ class ProcessAnimateWindow class ProcessAnimateWindowSlideFromRight : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromRight(); virtual ~ProcessAnimateWindowSlideFromRight() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; -private: -Coord2D m_maxVel; // top speed windows travel in x and y -Int m_slowDownThreshold; // when windows get this close to their resting - // positions they start to slow down -Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) -Real m_speedUpRatio; // how fast the windows speed up + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; +private: + Coord2D m_maxVel; // top speed windows travel in x and y + Int m_slowDownThreshold; // when windows get this close to their resting + // positions they start to slow down + Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) + Real m_speedUpRatio; // how fast the windows speed up }; - //----------------------------------------------------------------------------- class ProcessAnimateWindowSlideFromLeft : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromLeft(); virtual ~ProcessAnimateWindowSlideFromLeft() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; -private: -Coord2D m_maxVel; // top speed windows travel in x and y -Int m_slowDownThreshold; // when windows get this close to their resting - // positions they start to slow down -Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) -Real m_speedUpRatio; // how fast the windows speed up + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; +private: + Coord2D m_maxVel; // top speed windows travel in x and y + Int m_slowDownThreshold; // when windows get this close to their resting + // positions they start to slow down + Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) + Real m_speedUpRatio; // how fast the windows speed up }; - //----------------------------------------------------------------------------- class ProcessAnimateWindowSlideFromTop : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromTop(); virtual ~ProcessAnimateWindowSlideFromTop() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; -private: -Coord2D m_maxVel; // top speed windows travel in x and y -Int m_slowDownThreshold; // when windows get this close to their resting - // positions they start to slow down -Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) -Real m_speedUpRatio; // how fast the windows speed up + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; +private: + Coord2D m_maxVel; // top speed windows travel in x and y + Int m_slowDownThreshold; // when windows get this close to their resting + // positions they start to slow down + Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) + Real m_speedUpRatio; // how fast the windows speed up }; //----------------------------------------------------------------------------- class ProcessAnimateWindowSlideFromTopFast : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromTopFast(); virtual ~ProcessAnimateWindowSlideFromTopFast() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; -private: -Coord2D m_maxVel; // top speed windows travel in x and y -Int m_slowDownThreshold; // when windows get this close to their resting - // positions they start to slow down -Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) -Real m_speedUpRatio; // how fast the windows speed up + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; +private: + Coord2D m_maxVel; // top speed windows travel in x and y + Int m_slowDownThreshold; // when windows get this close to their resting + // positions they start to slow down + Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) + Real m_speedUpRatio; // how fast the windows speed up }; - //----------------------------------------------------------------------------- class ProcessAnimateWindowSlideFromBottom : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromBottom(); virtual ~ProcessAnimateWindowSlideFromBottom() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; -private: -Coord2D m_maxVel; // top speed windows travel in x and y -Int m_slowDownThreshold; // when windows get this close to their resting - // positions they start to slow down -Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) -Real m_speedUpRatio; // how fast the windows speed up + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; +private: + Coord2D m_maxVel; // top speed windows travel in x and y + Int m_slowDownThreshold; // when windows get this close to their resting + // positions they start to slow down + Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) + Real m_speedUpRatio; // how fast the windows speed up }; //----------------------------------------------------------------------------- @@ -201,14 +192,14 @@ Real m_speedUpRatio; // how fast the windows speed up class ProcessAnimateWindowSpiral : public ProcessAnimateWindow { public: - ProcessAnimateWindowSpiral(); virtual ~ProcessAnimateWindowSpiral() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; + private: Real m_deltaTheta; Int m_maxR; @@ -219,42 +210,38 @@ class ProcessAnimateWindowSpiral : public ProcessAnimateWindow class ProcessAnimateWindowSlideFromBottomTimed : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromBottomTimed(); virtual ~ProcessAnimateWindowSlideFromBottomTimed() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; virtual void setMaxDuration(UnsignedInt maxDuration) override { m_maxDuration = maxDuration; } private: UnsignedInt m_maxDuration; - }; class ProcessAnimateWindowSlideFromRightFast : public ProcessAnimateWindow { public: - ProcessAnimateWindowSlideFromRightFast(); virtual ~ProcessAnimateWindowSlideFromRightFast() override; - virtual void initAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual void initReverseAnimateWindow( wnd::AnimateWindow *animWin, UnsignedInt maxDelay = 0 ) override; - virtual Bool updateAnimateWindow( wnd::AnimateWindow *animWin ) override; - virtual Bool reverseAnimateWindow( wnd::AnimateWindow *animWin ) override; -private: -Coord2D m_maxVel; // top speed windows travel in x and y -Int m_slowDownThreshold; // when windows get this close to their resting - // positions they start to slow down -Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) -Real m_speedUpRatio; // how fast the windows speed up + virtual void initAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual void initReverseAnimateWindow(wnd::AnimateWindow* animWin, UnsignedInt maxDelay = 0) override; + virtual Bool updateAnimateWindow(wnd::AnimateWindow* animWin) override; + virtual Bool reverseAnimateWindow(wnd::AnimateWindow* animWin) override; +private: + Coord2D m_maxVel; // top speed windows travel in x and y + Int m_slowDownThreshold; // when windows get this close to their resting + // positions they start to slow down + Real m_slowDownRatio; // how fast the windows slow down (smaller slows quicker) + Real m_speedUpRatio; // how fast the windows speed up }; - //----------------------------------------------------------------------------- // INLINING /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/GameClient/RadiusDecal.h b/Core/GameEngine/Include/GameClient/RadiusDecal.h index 6a434dc3998..c7fd653578b 100644 --- a/Core/GameEngine/Include/GameClient/RadiusDecal.h +++ b/Core/GameEngine/Include/GameClient/RadiusDecal.h @@ -31,7 +31,8 @@ #include "Common/GameType.h" #include "GameClient/Color.h" -enum ShadowType CPP_11(: Int); +enum ShadowType +CPP_11( : Int); class Player; class Shadow; class RadiusDecalTemplate; diff --git a/Core/GameEngine/Include/GameClient/SelectionInfo.h b/Core/GameEngine/Include/GameClient/SelectionInfo.h index 509c5923571..6cf82b98c21 100644 --- a/Core/GameEngine/Include/GameClient/SelectionInfo.h +++ b/Core/GameEngine/Include/GameClient/SelectionInfo.h @@ -55,7 +55,6 @@ struct SelectionInfo Bool selectMineBuildings; Bool selectFriends; - SelectionInfo(); }; @@ -63,7 +62,7 @@ struct SelectionInfo struct PickDrawableStruct { // List to fill with Drawables. This should be provided by the caller. - DrawableList *drawableListToFill; + DrawableList* drawableListToFill; Bool isPointSelection; Bool forceAttackMode; @@ -75,11 +74,10 @@ struct PickDrawableStruct }; //------------------------------------------------------------------------------------------------- -extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedDrawables, - const DrawableList *newlySelectedDrawables, - SelectionInfo *outSelectionInfo, - Bool selectionIsPoint); - +extern Bool contextCommandForNewSelection(const DrawableList* currentlySelectedDrawables, + const DrawableList* newlySelectedDrawables, + SelectionInfo* outSelectionInfo, + Bool selectionIsPoint); //------------------------------------------------------------------------------------------------- // Returns ORed picktypes. @@ -89,7 +87,6 @@ extern UnsignedInt getPickTypesForContext(Bool forceAttackMode); // Returns ORed picktypes based on the current selection. extern UnsignedInt getPickTypesForCurrentSelection(Bool forceAttackMode); - //------------------------------------------------------------------------------------------------- // expects ORed picktypes. extern void translatePickTypesToKindof(UnsignedInt pickTypes, KindOfMaskType& outmask); @@ -98,4 +95,4 @@ extern void translatePickTypesToKindof(UnsignedInt pickTypes, KindOfMaskType& ou // Given a drawable, add it to an stl list. Useful for iterateDrawablesInRegion. // userData should be a pointer to a PickDrawableStruct, which is defined in // above. -extern Bool addDrawableToList( Drawable *draw, void *userData ); +extern Bool addDrawableToList(Drawable* draw, void* userData); diff --git a/Core/GameEngine/Include/GameClient/Smudge.h b/Core/GameEngine/Include/GameClient/Smudge.h index f36e12c857d..6a6c87d0ea6 100644 --- a/Core/GameEngine/Include/GameClient/Smudge.h +++ b/Core/GameEngine/Include/GameClient/Smudge.h @@ -24,37 +24,38 @@ #include "WWMath/vector2.h" #include "WWMath/vector3.h" -#define SET_SMUDGE_PARAMETERS(smudge,pos,offset,size,opacity) (smudge->m_pos=pos;smudge->m_offset=offset;smudge->m_size=size;smudge->m_opacity=opacity;) +#define SET_SMUDGE_PARAMETERS(smudge, pos, offset, size, opacity) (smudge->m_pos = pos; smudge->m_offset = offset; smudge->m_size = size; smudge->m_opacity = opacity;) struct Smudge : public DLNodeClass { - typedef void *Identifier; + typedef void* Identifier; W3DMPO_GLUE(Smudge) - Identifier m_identifier; //a number or pointer to identify this smudge - Vector3 m_pos; //position of smudge center - Vector2 m_offset; // difference in position between "texture" extraction and re-insertion for center vertex - Real m_size; //size of smudge in world space. - Real m_opacity; //alpha of center vertex, corners are assumed at 0 - Bool m_draw; //whether this smudge needs to be drawn + Identifier m_identifier; // a number or pointer to identify this smudge + Vector3 m_pos; // position of smudge center + Vector2 m_offset; // difference in position between "texture" extraction and re-insertion for center vertex + Real m_size; // size of smudge in world space. + Real m_opacity; // alpha of center vertex, corners are assumed at 0 + Bool m_draw; // whether this smudge needs to be drawn struct smudgeVertex { - Vector3 pos; //world-space position of vertex - Vector2 uv; //uv coordinates of vertex + Vector3 pos; // world-space position of vertex + Vector2 uv; // uv coordinates of vertex }; - smudgeVertex m_verts[5]; //5 vertices of this smudge (in counter-clockwise order, starting at top-left, ending in center.) + smudgeVertex m_verts[5]; // 5 vertices of this smudge (in counter-clockwise order, starting at top-left, ending in center.) }; #ifdef USING_STLPORT namespace std { - template<> struct hash - { - size_t operator()(Smudge::Identifier id) const { return reinterpret_cast(id); } - }; -} +template <> +struct hash +{ + size_t operator()(Smudge::Identifier id) const { return reinterpret_cast(id); } +}; +} // namespace std #endif // USING_STLPORT struct SmudgeSet : public DLNodeClass @@ -69,19 +70,19 @@ struct SmudgeSet : public DLNodeClass void reset(); void resetDraw(); - Smudge *addSmudgeToSet(Smudge::Identifier identifier); ///< add and return a smudge to the set with the given identifier - void removeSmudgeFromSet(Smudge *&smudge); ///< remove and invalidate the given smudge - Smudge *findSmudge(Smudge::Identifier identifier); ///< find the smudge that belongs to this identifier + Smudge* addSmudgeToSet(Smudge::Identifier identifier); ///< add and return a smudge to the set with the given identifier + void removeSmudgeFromSet(Smudge*& smudge); ///< remove and invalidate the given smudge + Smudge* findSmudge(Smudge::Identifier identifier); ///< find the smudge that belongs to this identifier - DLListClass &getUsedSmudgeList() { return m_usedSmudgeList;} - Int getUsedSmudgeCount() { return m_usedSmudgeCount; } ///& getUsedSmudgeList() { return m_usedSmudgeList; } + Int getUsedSmudgeCount() { return m_usedSmudgeCount; } ///< active smudges that need rendering. private: - typedef std::hash_map SmudgeIdToPtrMap; + typedef std::hash_map SmudgeIdToPtrMap; - DLListClass m_usedSmudgeList; /// m_usedSmudgeList; ///< list of smudges in this set. SmudgeIdToPtrMap m_usedSmudgeMap; - static DLListClass m_freeSmudgeList; /// m_freeSmudgeList; ///< list of unused smudges for use by SmudgeSets. Int m_usedSmudgeCount; }; @@ -92,27 +93,31 @@ class SmudgeManager virtual ~SmudgeManager(); virtual void init(); - virtual void reset (); + virtual void reset(); virtual void ReleaseResources() {} virtual void ReAcquireResources() {} void resetDraw(); ///< reset whether all smudges need to be drawn - SmudgeSet *addSmudgeSet(); ///< add and return a new smudge set - void removeSmudgeSet(SmudgeSet *&smudgeSet); ///< remove and invalidate the given smudge set - Smudge *findSmudge(Smudge::Identifier identifier); ///< find the smudge from any smudge set - Int getSmudgeCountLastFrame() {return m_smudgeCountLastFrame;} /// m_usedSmudgeSetList; /// m_freeSmudgeSetList; /// m_usedSmudgeSetList; ///< used SmudgeSets + DLListClass m_freeSmudgeSetList; ///< unused SmudgeSets ready for re-use. + Int m_smudgeCountLastFrame; // number of total smudges in manager last frame. }; -extern SmudgeManager *TheSmudgeManager; /// TheWeatherSetting; class SnowManager : public SubsystemInterface { - public : - enum{ - SNOW_NOISE_X=64, //dimensions table holding noise function used for initial snow positions. - SNOW_NOISE_Y=64, //dimensions table holding noise function used for initial snow positions. - }; - - SnowManager(); +public: + enum + { + SNOW_NOISE_X = 64, // dimensions table holding noise function used for initial snow positions. + SNOW_NOISE_Y = 64, // dimensions table holding noise function used for initial snow positions. + }; + + SnowManager(); virtual ~SnowManager() override; virtual void init() override; virtual void reset() override; - virtual void updateIniSettings (); - void setVisible(Bool showWeather); /// VecVideo; -typedef std::vector