diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index e3179bbb93c..26006607221 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -144,28 +144,28 @@ set(GAMEENGINE_SRC # Include/GameClient/AnimateWindowManager.h # Include/GameClient/CampaignManager.h Include/GameClient/ChallengeGenerals.h -# Include/GameClient/ClientInstance.h + Include/GameClient/ClientInstance.h Include/GameClient/ClientRandomValue.h -# Include/GameClient/Color.h + Include/GameClient/Color.h # Include/GameClient/CommandXlat.h # Include/GameClient/ControlBar.h # Include/GameClient/ControlBarResizer.h # Include/GameClient/ControlBarScheme.h -# Include/GameClient/Credits.h + Include/GameClient/Credits.h # Include/GameClient/DebugDisplay.h # Include/GameClient/Diplomacy.h # Include/GameClient/DisconnectMenu.h # Include/GameClient/Display.h -# Include/GameClient/DisplayString.h -# Include/GameClient/DisplayStringManager.h + Include/GameClient/DisplayString.h + Include/GameClient/DisplayStringManager.h # Include/GameClient/Drawable.h # Include/GameClient/DrawableInfo.h -# Include/GameClient/DrawGroupInfo.h + Include/GameClient/DrawGroupInfo.h # Include/GameClient/EstablishConnectionsMenu.h # Include/GameClient/Eva.h # Include/GameClient/ExtendedMessageBox.h # Include/GameClient/FontDesc.h -# Include/GameClient/FXList.h + Include/GameClient/FXList.h # Include/GameClient/Gadget.h # Include/GameClient/GadgetCheckBox.h # Include/GameClient/GadgetComboBox.h @@ -180,14 +180,14 @@ set(GAMEENGINE_SRC # Include/GameClient/GameClient.h Include/GameClient/GameFont.h # Include/GameClient/GameInfoWindow.h -# Include/GameClient/GameText.h + Include/GameClient/GameText.h Include/GameClient/GameWindow.h Include/GameClient/GameWindowGlobal.h # Include/GameClient/GameWindowID.h # Include/GameClient/GameWindowManager.h Include/GameClient/GameWindowTransitions.h -# Include/GameClient/GlobalLanguage.h -# Include/GameClient/GraphDraw.h + Include/GameClient/GlobalLanguage.h + Include/GameClient/GraphDraw.h # Include/GameClient/GUICallbacks.h # Include/GameClient/GUICommandTranslator.h Include/GameClient/HeaderTemplate.h @@ -198,8 +198,8 @@ set(GAMEENGINE_SRC # Include/GameClient/InGameUI.h Include/GameClient/Keyboard.h # Include/GameClient/KeyDefs.h -# Include/GameClient/LanguageFilter.h -# Include/GameClient/Line2D.h + Include/GameClient/LanguageFilter.h + Include/GameClient/Line2D.h Include/GameClient/LoadScreen.h # Include/GameClient/LookAtXlat.h Include/GameClient/MapUtil.h @@ -213,9 +213,9 @@ set(GAMEENGINE_SRC Include/GameClient/ParticleSys.h # Include/GameClient/PlaceEventTranslator.h Include/GameClient/ProcessAnimateWindow.h -# Include/GameClient/RadiusDecal.h + Include/GameClient/RadiusDecal.h # Include/GameClient/RayEffect.h -# Include/GameClient/SelectionInfo.h + Include/GameClient/SelectionInfo.h # Include/GameClient/SelectionXlat.h # Include/GameClient/Shadow.h # Include/GameClient/Shell.h @@ -223,7 +223,7 @@ set(GAMEENGINE_SRC # Include/GameClient/ShellMenuScheme.h Include/GameClient/Smudge.h Include/GameClient/Snow.h -# Include/GameClient/Statistics.h + Include/GameClient/Statistics.h Include/GameClient/TerrainRoads.h Include/GameClient/TerrainVisual.h Include/GameClient/VideoPlayer.h @@ -688,24 +688,24 @@ set(GAMEENGINE_SRC Source/Common/UserPreferences.cpp # Source/Common/version.cpp Source/Common/WorkerProcess.cpp -# Source/GameClient/ClientInstance.cpp -# Source/GameClient/Color.cpp -# Source/GameClient/Credits.cpp + Source/GameClient/ClientInstance.cpp + Source/GameClient/Color.cpp + Source/GameClient/Credits.cpp # Source/GameClient/Display.cpp -# Source/GameClient/DisplayString.cpp -# Source/GameClient/DisplayStringManager.cpp + Source/GameClient/DisplayString.cpp + Source/GameClient/DisplayStringManager.cpp # Source/GameClient/Drawable.cpp # Source/GameClient/Drawable/Update/AnimatedParticleSysBoneClientUpdate.cpp # Source/GameClient/Drawable/Update/BeaconClientUpdate.cpp # Source/GameClient/Drawable/Update/SwayClientUpdate.cpp -# Source/GameClient/DrawGroupInfo.cpp + Source/GameClient/DrawGroupInfo.cpp # Source/GameClient/Eva.cpp -# Source/GameClient/FXList.cpp + Source/GameClient/FXList.cpp # Source/GameClient/GameClient.cpp # Source/GameClient/GameClientDispatch.cpp -# Source/GameClient/GameText.cpp -# Source/GameClient/GlobalLanguage.cpp -# Source/GameClient/GraphDraw.cpp + Source/GameClient/GameText.cpp + Source/GameClient/GlobalLanguage.cpp + Source/GameClient/GraphDraw.cpp # Source/GameClient/GUI/AnimateWindowManager.cpp Source/GameClient/GUI/ChallengeGenerals.cpp # Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -803,8 +803,8 @@ set(GAMEENGINE_SRC # Source/GameClient/InGameUI.cpp Source/GameClient/Input/Keyboard.cpp Source/GameClient/Input/Mouse.cpp -# Source/GameClient/LanguageFilter.cpp -# Source/GameClient/Line2D.cpp + Source/GameClient/LanguageFilter.cpp + Source/GameClient/Line2D.cpp Source/GameClient/MapUtil.cpp # Source/GameClient/MessageStream/CommandXlat.cpp # Source/GameClient/MessageStream/GUICommandTranslator.cpp @@ -816,10 +816,10 @@ set(GAMEENGINE_SRC # Source/GameClient/MessageStream/SelectionXlat.cpp # Source/GameClient/MessageStream/WindowXlat.cpp Source/GameClient/ParabolicEase.cpp -# Source/GameClient/RadiusDecal.cpp -# Source/GameClient/SelectionInfo.cpp + Source/GameClient/RadiusDecal.cpp + Source/GameClient/SelectionInfo.cpp Source/GameClient/Snow.cpp -# Source/GameClient/Statistics.cpp + Source/GameClient/Statistics.cpp # Source/GameClient/System/Anim2D.cpp # Source/GameClient/System/CampaignManager.cpp Source/GameClient/System/Debug/AudioDebugDisplay.cpp diff --git a/Generals/Code/GameEngine/Include/GameClient/ClientInstance.h b/Core/GameEngine/Include/GameClient/ClientInstance.h similarity index 100% rename from Generals/Code/GameEngine/Include/GameClient/ClientInstance.h rename to Core/GameEngine/Include/GameClient/ClientInstance.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Color.h b/Core/GameEngine/Include/GameClient/Color.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/Color.h rename to Core/GameEngine/Include/GameClient/Color.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Credits.h b/Core/GameEngine/Include/GameClient/Credits.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/Credits.h rename to Core/GameEngine/Include/GameClient/Credits.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/DisplayString.h b/Core/GameEngine/Include/GameClient/DisplayString.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/DisplayString.h rename to Core/GameEngine/Include/GameClient/DisplayString.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/DisplayStringManager.h b/Core/GameEngine/Include/GameClient/DisplayStringManager.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/DisplayStringManager.h rename to Core/GameEngine/Include/GameClient/DisplayStringManager.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/DrawGroupInfo.h b/Core/GameEngine/Include/GameClient/DrawGroupInfo.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/DrawGroupInfo.h rename to Core/GameEngine/Include/GameClient/DrawGroupInfo.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/FXList.h b/Core/GameEngine/Include/GameClient/FXList.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/FXList.h rename to Core/GameEngine/Include/GameClient/FXList.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GameText.h b/Core/GameEngine/Include/GameClient/GameText.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/GameText.h rename to Core/GameEngine/Include/GameClient/GameText.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GlobalLanguage.h b/Core/GameEngine/Include/GameClient/GlobalLanguage.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/GlobalLanguage.h rename to Core/GameEngine/Include/GameClient/GlobalLanguage.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/GraphDraw.h b/Core/GameEngine/Include/GameClient/GraphDraw.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/GraphDraw.h rename to Core/GameEngine/Include/GameClient/GraphDraw.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/LanguageFilter.h b/Core/GameEngine/Include/GameClient/LanguageFilter.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/LanguageFilter.h rename to Core/GameEngine/Include/GameClient/LanguageFilter.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Line2D.h b/Core/GameEngine/Include/GameClient/Line2D.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/Line2D.h rename to Core/GameEngine/Include/GameClient/Line2D.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h b/Core/GameEngine/Include/GameClient/RadiusDecal.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h rename to Core/GameEngine/Include/GameClient/RadiusDecal.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/SelectionInfo.h b/Core/GameEngine/Include/GameClient/SelectionInfo.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/SelectionInfo.h rename to Core/GameEngine/Include/GameClient/SelectionInfo.h diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Statistics.h b/Core/GameEngine/Include/GameClient/Statistics.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/GameClient/Statistics.h rename to Core/GameEngine/Include/GameClient/Statistics.h diff --git a/Generals/Code/GameEngine/Source/GameClient/ClientInstance.cpp b/Core/GameEngine/Source/GameClient/ClientInstance.cpp similarity index 100% rename from Generals/Code/GameEngine/Source/GameClient/ClientInstance.cpp rename to Core/GameEngine/Source/GameClient/ClientInstance.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Color.cpp b/Core/GameEngine/Source/GameClient/Color.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Color.cpp rename to Core/GameEngine/Source/GameClient/Color.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Credits.cpp b/Core/GameEngine/Source/GameClient/Credits.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Credits.cpp rename to Core/GameEngine/Source/GameClient/Credits.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/DisplayString.cpp b/Core/GameEngine/Source/GameClient/DisplayString.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/DisplayString.cpp rename to Core/GameEngine/Source/GameClient/DisplayString.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/DisplayStringManager.cpp b/Core/GameEngine/Source/GameClient/DisplayStringManager.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/DisplayStringManager.cpp rename to Core/GameEngine/Source/GameClient/DisplayStringManager.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/DrawGroupInfo.cpp b/Core/GameEngine/Source/GameClient/DrawGroupInfo.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/DrawGroupInfo.cpp rename to Core/GameEngine/Source/GameClient/DrawGroupInfo.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp b/Core/GameEngine/Source/GameClient/FXList.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp rename to Core/GameEngine/Source/GameClient/FXList.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp b/Core/GameEngine/Source/GameClient/GameText.cpp similarity index 99% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp rename to Core/GameEngine/Source/GameClient/GameText.cpp index 97a2c9d5dfa..0015e3a3fc9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp +++ b/Core/GameEngine/Source/GameClient/GameText.cpp @@ -266,7 +266,6 @@ GameTextManager::GameTextManager() m_buffer2[i] = 0; m_buffer3[i] = 0; } - // } //============================================================================ @@ -1459,4 +1458,3 @@ static int __cdecl compareLUT ( const void *i1, const void*i2) return stricmp( lut1->label->str(), lut2->label->str()); } - diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp b/Core/GameEngine/Source/GameClient/GlobalLanguage.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp rename to Core/GameEngine/Source/GameClient/GlobalLanguage.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GraphDraw.cpp b/Core/GameEngine/Source/GameClient/GraphDraw.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/GraphDraw.cpp rename to Core/GameEngine/Source/GameClient/GraphDraw.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/LanguageFilter.cpp b/Core/GameEngine/Source/GameClient/LanguageFilter.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/LanguageFilter.cpp rename to Core/GameEngine/Source/GameClient/LanguageFilter.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Line2D.cpp b/Core/GameEngine/Source/GameClient/Line2D.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Line2D.cpp rename to Core/GameEngine/Source/GameClient/Line2D.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/Core/GameEngine/Source/GameClient/RadiusDecal.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp rename to Core/GameEngine/Source/GameClient/RadiusDecal.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp b/Core/GameEngine/Source/GameClient/SelectionInfo.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp rename to Core/GameEngine/Source/GameClient/SelectionInfo.cpp index cfb37555f6f..7558cf9380c 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/SelectionInfo.cpp +++ b/Core/GameEngine/Source/GameClient/SelectionInfo.cpp @@ -35,8 +35,8 @@ #include "GameClient/SelectionInfo.h" #include "GameClient/CommandXlat.h" #include "GameClient/ControlBar.h" -#include "GameClient/GameClient.h" #include "GameClient/Drawable.h" +#include "GameClient/GameClient.h" #include "GameClient/KeyDefs.h" @@ -202,7 +202,7 @@ extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedD if (outSelectionInfo->newCountMine > 0) { if (outSelectionInfo->newCountMine == 1 && selectionIsPoint && !TheInGameUI->isInPreferSelectionMode()) { - return TheGameClient->evaluateContextCommand(newMine, newMine->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID; + return TheGameClient->evaluateContextCommand(newMine, newMine->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID; } return FALSE; @@ -346,6 +346,10 @@ Bool addDrawableToList( Drawable *draw, void *userData ) return FALSE; #if !RTS_GENERALS || !PRESERVE_RETAIL_BEHAVIOR + // TheSuperHackers @info + // In retail, drag-selecting allows the player to select stealthed objects and objects through the + // fog. Some players exploit this bug to determine where an opponent's units are and consider this + // an important feature and an advanced skill to pull off, so we must leave the exploit. if (draw->getFullyObscuredByShroud()) return FALSE; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Statistics.cpp b/Core/GameEngine/Source/GameClient/Statistics.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Statistics.cpp rename to Core/GameEngine/Source/GameClient/Statistics.cpp diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index e6720304e31..044a2ec6952 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -133,28 +133,28 @@ set(GAMEENGINE_SRC Include/GameClient/AnimateWindowManager.h # Include/GameClient/ChallengeGenerals.h Include/GameClient/CampaignManager.h - Include/GameClient/ClientInstance.h +# Include/GameClient/ClientInstance.h # Include/GameClient/ClientRandomValue.h - Include/GameClient/Color.h +# Include/GameClient/Color.h Include/GameClient/CommandXlat.h Include/GameClient/ControlBar.h Include/GameClient/ControlBarResizer.h Include/GameClient/ControlBarScheme.h - Include/GameClient/Credits.h +# Include/GameClient/Credits.h Include/GameClient/DebugDisplay.h Include/GameClient/Diplomacy.h Include/GameClient/DisconnectMenu.h Include/GameClient/Display.h - Include/GameClient/DisplayString.h - Include/GameClient/DisplayStringManager.h +# Include/GameClient/DisplayString.h +# Include/GameClient/DisplayStringManager.h Include/GameClient/Drawable.h Include/GameClient/DrawableInfo.h - Include/GameClient/DrawGroupInfo.h +# Include/GameClient/DrawGroupInfo.h Include/GameClient/EstablishConnectionsMenu.h Include/GameClient/Eva.h Include/GameClient/ExtendedMessageBox.h Include/GameClient/FontDesc.h - Include/GameClient/FXList.h +# Include/GameClient/FXList.h Include/GameClient/Gadget.h Include/GameClient/GadgetCheckBox.h Include/GameClient/GadgetComboBox.h @@ -169,14 +169,14 @@ set(GAMEENGINE_SRC Include/GameClient/GameClient.h # Include/GameClient/GameFont.h Include/GameClient/GameInfoWindow.h - Include/GameClient/GameText.h +# Include/GameClient/GameText.h # Include/GameClient/GameWindow.h # Include/GameClient/GameWindowGlobal.h Include/GameClient/GameWindowID.h Include/GameClient/GameWindowManager.h # Include/GameClient/GameWindowTransitions.h - Include/GameClient/GlobalLanguage.h - Include/GameClient/GraphDraw.h +# Include/GameClient/GlobalLanguage.h +# Include/GameClient/GraphDraw.h Include/GameClient/GUICallbacks.h Include/GameClient/GUICommandTranslator.h # Include/GameClient/HeaderTemplate.h @@ -187,8 +187,8 @@ set(GAMEENGINE_SRC Include/GameClient/InGameUI.h # Include/GameClient/Keyboard.h Include/GameClient/KeyDefs.h - Include/GameClient/LanguageFilter.h - Include/GameClient/Line2D.h +# Include/GameClient/LanguageFilter.h +# Include/GameClient/Line2D.h # Include/GameClient/LoadScreen.h Include/GameClient/LookAtXlat.h # Include/GameClient/MapUtil.h @@ -201,15 +201,15 @@ set(GAMEENGINE_SRC # Include/GameClient/ParticleSys.h Include/GameClient/PlaceEventTranslator.h # Include/GameClient/ProcessAnimateWindow.h - Include/GameClient/RadiusDecal.h +# Include/GameClient/RadiusDecal.h Include/GameClient/RayEffect.h - Include/GameClient/SelectionInfo.h +# Include/GameClient/SelectionInfo.h Include/GameClient/SelectionXlat.h Include/GameClient/Shadow.h Include/GameClient/Shell.h Include/GameClient/ShellHooks.h Include/GameClient/ShellMenuScheme.h - Include/GameClient/Statistics.h +# Include/GameClient/Statistics.h # Include/GameClient/TerrainRoads.h # Include/GameClient/TerrainVisual.h # Include/GameClient/VideoPlayer.h @@ -636,24 +636,24 @@ set(GAMEENGINE_SRC # Source/Common/UserPreferences.cpp Source/Common/version.cpp # Source/Common/WorkerProcess.cpp - Source/GameClient/ClientInstance.cpp - Source/GameClient/Color.cpp - Source/GameClient/Credits.cpp +# Source/GameClient/ClientInstance.cpp +# Source/GameClient/Color.cpp +# Source/GameClient/Credits.cpp Source/GameClient/Display.cpp - Source/GameClient/DisplayString.cpp - Source/GameClient/DisplayStringManager.cpp +# Source/GameClient/DisplayString.cpp +# Source/GameClient/DisplayStringManager.cpp Source/GameClient/Drawable.cpp Source/GameClient/Drawable/Update/AnimatedParticleSysBoneClientUpdate.cpp Source/GameClient/Drawable/Update/BeaconClientUpdate.cpp Source/GameClient/Drawable/Update/SwayClientUpdate.cpp - Source/GameClient/DrawGroupInfo.cpp +# Source/GameClient/DrawGroupInfo.cpp Source/GameClient/Eva.cpp - Source/GameClient/FXList.cpp +# Source/GameClient/FXList.cpp Source/GameClient/GameClient.cpp Source/GameClient/GameClientDispatch.cpp - Source/GameClient/GameText.cpp - Source/GameClient/GlobalLanguage.cpp - Source/GameClient/GraphDraw.cpp +# Source/GameClient/GameText.cpp +# Source/GameClient/GlobalLanguage.cpp +# Source/GameClient/GraphDraw.cpp Source/GameClient/GUI/AnimateWindowManager.cpp # Source/GameClient/GUI/ChallengeGenerals.cpp Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -750,8 +750,8 @@ set(GAMEENGINE_SRC Source/GameClient/InGameUI.cpp # Source/GameClient/Input/Keyboard.cpp # Source/GameClient/Input/Mouse.cpp - Source/GameClient/LanguageFilter.cpp - Source/GameClient/Line2D.cpp +# Source/GameClient/LanguageFilter.cpp +# Source/GameClient/Line2D.cpp # Source/GameClient/MapUtil.cpp Source/GameClient/MessageStream/CommandXlat.cpp Source/GameClient/MessageStream/GUICommandTranslator.cpp @@ -762,9 +762,9 @@ set(GAMEENGINE_SRC Source/GameClient/MessageStream/PlaceEventTranslator.cpp Source/GameClient/MessageStream/SelectionXlat.cpp Source/GameClient/MessageStream/WindowXlat.cpp - Source/GameClient/RadiusDecal.cpp - Source/GameClient/SelectionInfo.cpp - Source/GameClient/Statistics.cpp +# Source/GameClient/RadiusDecal.cpp +# Source/GameClient/SelectionInfo.cpp +# Source/GameClient/Statistics.cpp Source/GameClient/System/Anim2D.cpp Source/GameClient/System/CampaignManager.cpp # "Source/GameClient/System/Debug Displayers/AudioDebugDisplay.cpp" diff --git a/Generals/Code/GameEngine/Include/GameClient/Color.h b/Generals/Code/GameEngine/Include/GameClient/Color.h deleted file mode 100644 index 842827c3028..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/Color.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Color.h ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: Color.h -// -// Created: Colin Day, July 2001 -// -// Desc: Management of color representations -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "Lib/BaseType.h" - -// FORWARD REFERENCES ///////////////////////////////////////////////////////// - -// TYPE DEFINES /////////////////////////////////////////////////////////////// -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 */ -typedef Int Color; - -// INLINING /////////////////////////////////////////////////////////////////// - -// EXTERNALS ////////////////////////////////////////////////////////////////// - -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 ); - -// Put on ice until later - M Lorenzen -//extern void GameGetColorComponentsWithCheatSpy( Color color, -// UnsignedByte *red, -// UnsignedByte *green, -// UnsignedByte *blue, -// UnsignedByte *alpha ); - - -extern void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha ); - -extern Color GameDarkenColor( Color color, Int percent = 10 ); diff --git a/Generals/Code/GameEngine/Include/GameClient/Credits.h b/Generals/Code/GameEngine/Include/GameClient/Credits.h deleted file mode 100644 index 5055907b0dd..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/Credits.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Credits.h ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Dec 2002 -// -// Filename: Credits.h -// -// author: Chris Huybregts -// -// purpose: header file for the credits -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "GameClient/FontDesc.h" - -//----------------------------------------------------------------------------- -// FORWARD REFERENCES ///////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -class DisplayString; -//----------------------------------------------------------------------------- -// TYPE DEFINES /////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -enum -{ -CREDIT_STYLE_TITLE = 0, -CREDIT_STYLE_POSITION, -CREDIT_STYLE_NORMAL, -CREDIT_STYLE_COLUMN, -CREDIT_STYLE_BLANK, ///< Keep this second to last - -MAX_CREDIT_STYLES -}; - -enum{ CREDIT_SPACE_OFFSET = 2 }; - -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 -{ -public: - CreditsLine(); - ~CreditsLine(); - -// 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; - ICoord2D m_pos; - Int m_height; - Int m_color; -}; - -class CreditsManager: public SubsystemInterface -{ -public: - CreditsManager(void); - ~CreditsManager(void); - - void init(void ); - void load(void ); - void reset( void ); - void update( void ); - void draw( void ); - - 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( void ) { return m_isFinished; } - void addBlank( void ); - void addText( AsciiString text ); -private: - - UnicodeString getUnicodeString(AsciiString str); - - typedef std::list CreditsLineList; - CreditsLineList m_creditLineList; - CreditsLineList::iterator m_creditLineListIt; - - CreditsLineList m_displayedCreditLineList; - - 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 - - Color m_titleColor; - Color m_positionColor; - Color m_normalColor; - - Int m_currentStyle; - - Bool m_isFinished; - - Int m_framesSinceStarted; - Int m_normalFontHeight; -}; - - -//----------------------------------------------------------------------------- -// INLINING /////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// EXTERNALS ////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -extern CreditsManager *TheCredits; diff --git a/Generals/Code/GameEngine/Include/GameClient/DisplayString.h b/Generals/Code/GameEngine/Include/GameClient/DisplayString.h deleted file mode 100644 index 164ad25bbb2..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/DisplayString.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: DisplayString.h ////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: DisplayString.h -// -// Created: Colin Day, July 2001 -// -// Desc: Contstuct for holding double byte game string data and being -// able to draw that text to the screen. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "Lib/BaseType.h" -#include "GameClient/GameFont.h" -#include "GameClient/Color.h" -#include "Common/AsciiString.h" -#include "Common/UnicodeString.h" -#include "Common/GameMemory.h" - -// FORWARD REFERENCES ///////////////////////////////////////////////////////// -class DisplayStringManager; - -// TYPE DEFINES /////////////////////////////////////////////////////////////// - -// DisplayString -------------------------------------------------------------- -/** String representation that can also has additional information and - * methods for drawing to the screen */ -//----------------------------------------------------------------------------- -class DisplayString : public MemoryPoolObject -{ - - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( DisplayString, "DisplayString" ) - -public: - - friend DisplayStringManager; - - DisplayString( void ); - // virtual ~DisplayString( void ); // destructor defined by memory pool - - virtual void setText( UnicodeString text ); ///< set text for this string - virtual UnicodeString getText( void ); ///< get text for this string - virtual Int getTextLength( void ); ///< return number of chars in string - virtual void notifyTextChanged( void ); ///< called when text has changed - virtual void reset( void ); ///< reset all contents of string - - virtual void setFont( GameFont *font ); ///< set a font for display - virtual GameFont *getFont( void ); ///< 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 setClipRegion( IRegion2D *region ); ///< clip text in this region - - virtual void removeLastChar( void ); ///< 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 - - DisplayString *next( void ); ///< 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 - -}; - -/////////////////////////////////////////////////////////////////////////////// -// INLINING /////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -inline UnicodeString DisplayString::getText( void ) { return m_textString; } -inline Int DisplayString::getTextLength( void ) { return m_textString.getLength(); } -inline void DisplayString::setFont( GameFont *font ) { m_font = font; } -inline GameFont *DisplayString::getFont( void ) { return m_font; } -inline void DisplayString::setClipRegion( IRegion2D *region ) {} -inline void DisplayString::notifyTextChanged( void ) {} -inline DisplayString *DisplayString::next( void ) { return m_next; } - -// EXTERNALS ////////////////////////////////////////////////////////////////// diff --git a/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h b/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h deleted file mode 100644 index 6ce394d3fe5..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: DisplayStringManager.h /////////////////////////////////////////////////////////////////// -// Created: Colin Day, July 2001 -// Desc: Access for creating game managed display strings -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/SubsystemInterface.h" -#include "GameClient/DisplayString.h" - -//------------------------------------------------------------------------------------------------- -/** Factory for managing and creating display strings */ -//------------------------------------------------------------------------------------------------- -class DisplayStringManager : public SubsystemInterface -{ - -public: - - DisplayStringManager( void ); - virtual ~DisplayStringManager( void ); - - virtual void init( void ) {} ///< initialize the factory - virtual void reset( void ) {} ///< reset system - virtual void update( void ) {}; ///< update anything we need to in our strings - - virtual DisplayString *newDisplayString( void ) = 0; ///< allocate new display string - virtual void freeDisplayString( DisplayString *string ) = 0; ///< free string - - virtual DisplayString *getGroupNumeralString( Int numeral ) = 0; - virtual DisplayString *getFormationLetterString( void ) = 0; -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 -}; - -// EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern DisplayStringManager *TheDisplayStringManager; ///< singleton extern diff --git a/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h b/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h deleted file mode 100644 index 0637bd8ec4b..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: DrawGroupInfo.h ////////////////////////////////////////////////////////////////////////// -// AudioEventRTS structure -// Author: John K. McDonald, March 2002 - -#pragma once - -struct DrawGroupInfo -{ - AsciiString m_fontName; - Int m_fontSize; - Bool m_fontIsBold; - - Bool m_usePlayerColor; - Color m_colorForText; - Color m_colorForTextDropShadow; - - Int m_dropShadowOffsetX; - Int m_dropShadowOffsetY; - - union - { - Int m_pixelOffsetX; - Real m_percentOffsetX; - }; - Bool m_usingPixelOffsetX; - - union - { - Int m_pixelOffsetY; - Real m_percentOffsetY; - }; - Bool m_usingPixelOffsetY; - - DrawGroupInfo(); - - static const FieldParse s_fieldParseTable[]; ///< the parse table for INI definition - const FieldParse *getFieldParse( void ) const { return s_fieldParseTable; } -}; - -extern DrawGroupInfo *TheDrawGroupInfo; diff --git a/Generals/Code/GameEngine/Include/GameClient/FXList.h b/Generals/Code/GameEngine/Include/GameClient/FXList.h deleted file mode 100644 index 4d1204c19ea..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/FXList.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: FXList.h ///////////////////////////////////////////////////////////////////////////////// -// Author: Steven Johnson, December 2001 -// Desc: General Effects Descriptions -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "Common/GameMemory.h" -#include "Common/NameKeyGenerator.h" -#include "Common/STLTypedefs.h" - -// FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// -class FXNugget; -class FXList; -class FXListStore; -class INI; -class Object; -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). - - 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. - - -- 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. - - -- 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() { } - - /** - 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; - - /** - 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). - - 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. - - -- 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. - - -- 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. - */ - void clear(); - - /** - add a nugget to the list. It belongs to the FXList, who is responsible for freeing it. - */ - 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) - { - if (fx) fx->doFXPos(primary, primaryMtx, primarySpeed, secondary, overrideRadius); - } - - /// inline convenience method to avoid having to check for null. - inline static void doFXObj(const FXList* fx, const Object* primary, const Object* secondary = nullptr) - { - if (fx) - { - fx->doFXObj(primary, secondary); - - //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. - */ - 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. - */ - void doFXObj(const Object* primary, const Object* secondary = nullptr) const; - -private: - - typedef std::list< FXNugget* > FXNuggetList; - - FXNuggetList m_nuggets; - -}; - -//------------------------------------------------------------------------------------------------- -/** - The "store" used to hold all the FXLists in existence. -*/ -class FXListStore : public SubsystemInterface -{ - -public: - - FXListStore(); - ~FXListStore(); - - void init() { } - void reset() { } - void update() { } - - /** - return the FXList with the given namekey. - return nullptr if no such FXList exists. - */ - 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; - - FXListMap m_fxmap; - -}; - -// EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern FXListStore *TheFXListStore; diff --git a/Generals/Code/GameEngine/Include/GameClient/GameText.h b/Generals/Code/GameEngine/Include/GameClient/GameText.h deleted file mode 100644 index bf8c94fb88c..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/GameText.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: RTS 3 -// -// File name: GameClient/GameText.h -// -// Created: 11/07/01 -// -//---------------------------------------------------------------------------- - -#pragma once - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - -class AsciiString; -class UnicodeString; - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- -typedef std::vector AsciiStringVec; - -//=============================== -// GameTextInterface -//=============================== -/** Game text interface object for localised text. - */ -//=============================== - -class GameTextInterface : public SubsystemInterface -{ - - public: - - virtual ~GameTextInterface() {}; - - 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; - - // 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; - -#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; - } -#endif -}; - - -extern GameTextInterface *TheGameText; -extern GameTextInterface* CreateGameTextInterface( void ); - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - -// TheSuperHackers @info This is meant to be used like: -// TheGameText->FETCH_OR_SUBSTITUTE("GUI:LabelName", L"Substitute Fallback Text") -// TheGameText->FETCH_OR_SUBSTITUTE_FORMAT("GUI:LabelName", L"Substitute Fallback Text %d %d", 1, 2) -// The substitute text will be compiled out if ENABLE_GAMETEXT_SUBSTITUTES is not defined. -// -// Note: ##__VA_ARGS__ handles zero variadic arguments by removing the preceding comma when empty. -// Example: FETCH_OR_SUBSTITUTE_FORMAT("Label", L"Text") expands correctly without trailing comma. -// Without ##, it would expand to fetchOrSubstituteFormat("Label", L"Text",) causing a syntax error. -// This extension is widely supported (GCC, Clang, MSVC 2015+). C++20 __VA_OPT__ is the standard -// 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 - -#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 - -#endif // ENABLE_GAMETEXT_SUBSTITUTES diff --git a/Generals/Code/GameEngine/Include/GameClient/GlobalLanguage.h b/Generals/Code/GameEngine/Include/GameClient/GlobalLanguage.h deleted file mode 100644 index 9ceb7abe0fa..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/GlobalLanguage.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GlobalLanguage.h ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Aug 2002 -// -// Filename: GlobalLanguage.h -// -// author: Chris Huybregts -// -// purpose: With workingwith different languages, we need some options that -// change. Essentially, this is the global data that's unique to languages -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "Common/SubsystemInterface.h" -#include "Common/STLTypedefs.h" -#include "GameClient/FontDesc.h" -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -class AsciiString; -//----------------------------------------------------------------------------- -// FORWARD REFERENCES ///////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// TYPE DEFINES /////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -class GlobalLanguage : public SubsystemInterface -{ -public: - - enum ResolutionFontSizeMethod - { - 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_Default = ResolutionFontSizeMethod_ClassicNoCeiling, - }; - -public: - - GlobalLanguage(); - virtual ~GlobalLanguage(); - - void init(); - void reset(); - void update() { } - - AsciiString m_unicodeFontName; - AsciiString m_unicodeFontFileName; - Bool m_useHardWrap; - Int m_militaryCaptionSpeed; - 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; - - float getResolutionFontSizeAdjustment() const; - Int adjustFontSize(Int theFontSize); // Adjusts font size for resolution. jba. - - void parseCustomDefinition(); - - typedef std::list StringList; // Used for our font file names that we want to load - typedef StringList::iterator StringListIt; - - StringList m_localFonts; // List of the font filenames that are in our local directory - static void parseFontFileName( INI *ini, void *instance, void *store, const void* userData ); - static void parseFontDesc(INI *ini, void *instance, void *store, const void* userData); -}; -//----------------------------------------------------------------------------- -// INLINING /////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// EXTERNALS ////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -extern GlobalLanguage *TheGlobalLanguageData; diff --git a/Generals/Code/GameEngine/Include/GameClient/GraphDraw.h b/Generals/Code/GameEngine/Include/GameClient/GraphDraw.h deleted file mode 100644 index 97cc938851b..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/GraphDraw.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GraphDraw.h ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Aug 2002 -// -// Filename: GraphDraw.h -// -// author: John McDonald -// -// purpose: Contains the functions to queue up and display a single graph for -// each frame. Note: This class is presently only intended for use by -// the Performance timers, all though it could be easily adapted for -// other purposes. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/PerfTimer.h" -#include "Common/STLTypedefs.h" - -#ifdef PERF_TIMERS - -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 }; - -class DisplayString; - -class GraphDraw -{ - public: - GraphDraw(); - virtual ~GraphDraw(); - - void addEntry(AsciiString str, Real val); - // Called during begin/end - void render(); - void clear(); - - protected: - VecGraphEntries m_graphEntries; - DisplayString *m_displayStrings[MAX_GRAPH_VALUES]; -}; - -extern GraphDraw *TheGraphDraw; - - -#endif /* PERF_TIMERS */ diff --git a/Generals/Code/GameEngine/Include/GameClient/LanguageFilter.h b/Generals/Code/GameEngine/Include/GameClient/LanguageFilter.h deleted file mode 100644 index da533ce974d..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/LanguageFilter.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/STLTypedefs.h" -#include "Common/AsciiString.h" -#include "Common/UnicodeString.h" - -class File; - -struct AsciiStringLessThan -{ - Bool operator()(AsciiString a, AsciiString b) const - { - return (a.compareNoCase(b) < 0); - } -}; - -struct UnicodeStringLessThan -{ - Bool operator()(UnicodeString a, UnicodeString b) const - { - return (a.compareNoCase(b) < 0); - } -}; - -struct UnicodeStringsEqual -{ - Bool operator()(UnicodeString a, UnicodeString b) const - { - Bool retval = (a.compareNoCase(b) == 0); - DEBUG_LOG(("Comparing %ls with %ls, return value is %s.", a.str(), b.str(), retval ? "true" : "false")); - return retval; - } -}; - -typedef std::map LangMap; -typedef std::map::iterator LangMapIter; - -static const int LANGUAGE_XOR_KEY = 0x5555; -static const char BadWordFileName[] = "langdata.dat"; - -class LanguageFilter : public SubsystemInterface { -public: - LanguageFilter(); - ~LanguageFilter(); - - void init(); - void reset(); - void update(); - void filterLine(UnicodeString &line); - -protected: - Bool readWord(File *file1, WideChar *buf); - void unHaxor(UnicodeString &word); - LangMap m_wordList; - LangMap m_subWordList; -}; - -extern LanguageFilter *TheLanguageFilter; -LanguageFilter * createLanguageFilter(); diff --git a/Generals/Code/GameEngine/Include/GameClient/Line2D.h b/Generals/Code/GameEngine/Include/GameClient/Line2D.h deleted file mode 100644 index e212d4b2b07..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/Line2D.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Line2D.h ///////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, January 2002 -// Desc: 2D line helping stuff -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -typedef std::vector Coord2DVector; -typedef std::vector Coord3DVector; - - -// PROTOTYPES ///////////////////////////////////////////////////////////////////////////////////// -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); - -///< 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); - -///< 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 ); - -///< Scales a rect by a factor either growing or shrinking it. -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); - - -///< 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); - -///< 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); - -///< 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 ); diff --git a/Generals/Code/GameEngine/Include/GameClient/RadiusDecal.h b/Generals/Code/GameEngine/Include/GameClient/RadiusDecal.h deleted file mode 100644 index c1b3bd5ad12..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/RadiusDecal.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: RadiusDecal.h /////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/GameCommon.h" -#include "Common/GameType.h" -#include "GameClient/Color.h" - -enum ShadowType CPP_11(: Int); -class Player; -class Shadow; -class RadiusDecalTemplate; - -// ------------------------------------------------------------------------------------------------ -class RadiusDecal -{ - friend class RadiusDecalTemplate; -private: - const RadiusDecalTemplate* m_template; - Shadow* m_decal; - Bool m_empty; -public: - RadiusDecal(); - RadiusDecal(const RadiusDecal& that); - RadiusDecal& operator=(const RadiusDecal& that); - ~RadiusDecal(); - - void xferRadiusDecal( Xfer *xfer ); - - // please note: it is very important, for game/net sync reasons, to ensure that - // isEmpty() returns the same value, regardless of whether this decal will - // be visible to the local player or not. - Bool isEmpty() const { return m_empty; } - void clear(); - void update(); - void setPosition(const Coord3D& pos); - void setOpacity( const Real o ); -}; - -// ------------------------------------------------------------------------------------------------ -class RadiusDecalTemplate -{ - friend class RadiusDecal; -private: - AsciiString m_name; - ShadowType m_shadowType; - Real m_minOpacity; - Real m_maxOpacity; - UnsignedInt m_opacityThrobTime; - Color m_color; - Bool m_onlyVisibleToOwningPlayer; - -public: - RadiusDecalTemplate(); - - Bool valid() const { return m_name.isNotEmpty(); } - void xferRadiusDecalTemplate( Xfer *xfer ); - - // please note: it is very important, for game/net sync reasons, to ensure that - // a valid radiusdecal is created, even if will not be visible to the local player, - // since some logic makes decisions based on this. - void createRadiusDecal(const Coord3D& pos, Real radius, const Player* owningPlayer, RadiusDecal& result) const; - - static void parseRadiusDecalTemplate(INI* ini, void *instance, void * store, const void* /*userData*/); -}; diff --git a/Generals/Code/GameEngine/Include/GameClient/SelectionInfo.h b/Generals/Code/GameEngine/Include/GameClient/SelectionInfo.h deleted file mode 100644 index e0d07c059a4..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/SelectionInfo.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GameClient/ContextSensitiveTranslator.h ////////////////////////////////////////////////// -// Contains the SelectionInfo structure and the contextCommandForNewSelection -// Author: John McDonald, Jr, October 2002 - -#pragma once - -#include "GameClient/InGameUI.h" - -// This structure gives you a rough idea about the counts of the kinds of guys in the -// current selection, and in the selection that would be made. -struct SelectionInfo -{ - Int currentCountEnemies; - Int currentCountCivilians; - Int currentCountMine; - Int currentCountMineInfantry; - Int currentCountMineBuildings; - Int currentCountFriends; - - Int newCountEnemies; - Int newCountCivilians; - Int newCountMine; - Int newCountMineBuildings; - Int newCountFriends; - Int newCountGarrisonableBuildings; - Int newCountCrates; - - Bool selectEnemies; - Bool selectCivilians; - Bool selectMine; - Bool selectMineBuildings; - Bool selectFriends; - - - SelectionInfo(); -}; - -//------------------------------------------------------------------------------------------------- -struct PickDrawableStruct -{ - // List to fill with Drawables. This should be provided by the caller. - DrawableList *drawableListToFill; - Bool forceAttackMode; - - // Note, this is OR'd with the things we are attempting to select. - KindOfMaskType kindofsToMatch; - - PickDrawableStruct(); -}; - -//------------------------------------------------------------------------------------------------- -extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedDrawables, - const DrawableList *newlySelectedDrawables, - SelectionInfo *outSelectionInfo, - Bool selectionIsPoint); - - -//------------------------------------------------------------------------------------------------- -// Returns ORed picktypes. -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); - -//------------------------------------------------------------------------------------------------- -// 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 ); diff --git a/Generals/Code/GameEngine/Include/GameClient/Statistics.h b/Generals/Code/GameEngine/Include/GameClient/Statistics.h deleted file mode 100644 index 8031fe35fde..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/Statistics.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Statistics.h -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: Statistics.h */ -/* Created: John K. McDonald, Jr., 4/2/2002 */ -/* Desc: Common statistical functions */ -/* Revision History: */ -/* 4/2/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////// -#include "Lib/BaseType.h" - -// DEFINES //////////////////////////////////////////////////////////////////// -// TYPE DEFINES /////////////////////////////////////////////////////////////// -// FORWARD DECLARATIONS /////////////////////////////////////////////////////// - - -// valueToRun is the value (between 0 and maxValueForVal) to test. -// mu is designates the steepness of the curve. -// The return value is a value in [-1, 1] -extern Real MuLaw(Real valueToRun, Real maxValueForVal, Real mu); - -// valueToNormalize is a value in minRange..maxRange -// minRange is the smallest value the range contains -// maxRange is the largest value the range contains -// the return is a value in [0, 1]. -extern Real Normalize(Real valueToNormalize, Real minRange, Real maxRange); - -// same as Normalize, except that output will be in the range [outRangeMin, outRangeMax] -extern Real NormalizeToRange(Real valueToNormalize, Real minRange, Real maxRange, Real outRangeMin, Real outRangeMax); diff --git a/Generals/Code/GameEngine/Source/GameClient/Color.cpp b/Generals/Code/GameEngine/Source/GameClient/Color.cpp deleted file mode 100644 index deb83281ed9..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/Color.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Color.cpp //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: Color.cpp -// -// Created: Colin Day, July 2001 -// -// Desc: Management of color representations -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/Color.h" - -// DEFINES //////////////////////////////////////////////////////////////////// - -// PRIVATE TYPES ////////////////////////////////////////////////////////////// - -// PRIVATE DATA /////////////////////////////////////////////////////////////// - -// PUBLIC DATA //////////////////////////////////////////////////////////////// - -// PRIVATE PROTOTYPES ///////////////////////////////////////////////////////// - -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -// GameMakeColor ============================================================== -/** Create a color representation given red, green, blue, and - * alpha components - * - * NOTE: pure solid white (255, 255, 255, 255) will translate - * intoa -1 which is GAME_COLOR_UNDEFINED - */ -//============================================================================= - -// GameGetColorComponents ===================================================== -/** Get the RGB color components of a color */ -//============================================================================= - - - -//Put on ice until later M Lorenzen -//static UnsignedByte s_cheaterHasBeenSpied = 0; - -void GameGetColorComponents( Color color, - UnsignedByte *red, - UnsignedByte *green, - UnsignedByte *blue, - UnsignedByte *alpha ) -{ - - *alpha = (color & 0xFF000000) >> 24; - *red = (color & 0x00FF0000) >> 16; - *green = (color & 0x0000FF00) >> 8; - *blue = (color & 0x000000FF); - -} - -//Put on ice until later M Lorenzen -//void GameGetColorComponentsWithCheatSpy( Color color, -// UnsignedByte *red, -// UnsignedByte *green, -// UnsignedByte *blue, -// UnsignedByte *alpha ) -//{ -// -// *alpha |= (color & 0xFE000000) >> 24; // this waives the low order bit in alpha -// s_cheaterHasBeenSpied |= *alpha & (1<<0); // this records it and gets angry -// *red |= (color & 0x00FE0000) >> 16; // decoy -// s_cheaterHasBeenSpied |= *red & (1<<8); // decoy -// *green |= (color & 0x0000FE00) >> 8; // decoy -// s_cheaterHasBeenSpied |= *green & (1<<17); // decoy -// *blue |= (color & 0x000000FE) >> 0; // decoy -// s_cheaterHasBeenSpied |= *blue & (1<<25); // decoy -// -//} // end GameGetColorComponents - -void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha ) -{ - *alpha = ((color & 0xFF000000) >> 24) / 255.0f; - *red = ((color & 0x00FF0000) >> 16) / 255.0f; - *green = ((color & 0x0000FF00) >> 8) / 255.0f; - *blue = (color & 0x000000FF) / 255.0f; -} - - -Color GameDarkenColor( Color color, Int percent ) -{ - // if they try to go to dark, just return their old color - if(percent >= 90 || percent <= 0) - return color; - - UnsignedByte r, g, b, a; - GameGetColorComponents(color,&r,&g,&b,&a); - r -= (r * percent / 100); - g -= (g * percent / 100); - b -= (b * percent / 100); - -// Put on ice until later M Lorenzen -// TheWritableGlobalData->m_cheaterHasBeenSpiedIfMyLowestBitIsTrue = (r<<24) | (g<<16) | (b<<8) | s_cheaterHasBeenSpied; -// DEBUG_ASSERTCRASH( TheWritableGlobalData->m_cheaterHasBeenSpiedIfMyLowestBitIsTrue == FALSE, ("DIRTY ROTTEN CHEATER")); -// //my, but this looks like we just stored an alpha value along with rgb into the global data - - - - - return GameMakeColor(r,g,b,a); - -} - diff --git a/Generals/Code/GameEngine/Source/GameClient/Credits.cpp b/Generals/Code/GameEngine/Source/GameClient/Credits.cpp deleted file mode 100644 index 21eafbbd786..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/Credits.cpp +++ /dev/null @@ -1,485 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Credits.cpp ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Dec 2002 -// -// Filename: Credits.cpp -// -// author: Chris Huybregts -// -// purpose: This is where all the credit texts is going to be held. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "Common/INI.h" -#include "GameClient/Credits.h" -#include "GameClient/DisplayStringManager.h" -#include "GameClient/Display.h" -#include "GameClient/GameText.h" -#include "GameClient/GlobalLanguage.h" - - -//----------------------------------------------------------------------------- -// DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -CreditsManager *TheCredits = nullptr; - -const FieldParse CreditsManager::m_creditsFieldParseTable[] = -{ - - { "ScrollRate", INI::parseInt, nullptr, offsetof( CreditsManager, m_scrollRate ) }, - { "ScrollRateEveryFrames", INI::parseInt, nullptr, offsetof( CreditsManager, m_scrollRatePerFrames ) }, - { "ScrollDown", INI::parseBool, nullptr, offsetof( CreditsManager, m_scrollDown ) }, - { "TitleColor", INI::parseColorInt, nullptr, offsetof( CreditsManager, m_titleColor ) }, - { "MinorTitleColor", INI::parseColorInt, nullptr, offsetof( CreditsManager, m_positionColor ) }, - { "NormalColor", INI::parseColorInt, nullptr, offsetof( CreditsManager, m_normalColor ) }, - { "Style", INI::parseLookupList, CreditStyleNames, offsetof( CreditsManager, m_currentStyle ) }, - { "Blank", CreditsManager::parseBlank, nullptr, 0 }, - { "Text", CreditsManager::parseText, nullptr, 0 }, - - { nullptr, nullptr, nullptr, 0 } - -}; - -//----------------------------------------------------------------------------- -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -void INI::parseCredits( INI *ini ) -{ - // find existing item if present - DEBUG_ASSERTCRASH( TheCredits, ("parseCredits: TheCredits has not been ininialized yet.") ); - if( !TheCredits ) - return; - - // parse the ini definition - ini->initFromINI( TheCredits, TheCredits->getFieldParse() ); - -} - - -CreditsLine::CreditsLine() -{ - m_useSecond = FALSE; - m_done = FALSE; - m_style = CREDIT_STYLE_BLANK; - m_displayString = nullptr; - m_secondDisplayString = nullptr; -} - -CreditsLine::~CreditsLine() -{ - if(m_displayString) - TheDisplayStringManager->freeDisplayString(m_displayString); - if(m_secondDisplayString) - TheDisplayStringManager->freeDisplayString(m_secondDisplayString); - - m_displayString = nullptr; - m_secondDisplayString = nullptr; -} - - -CreditsManager::CreditsManager(void) -{ - m_scrollRate = 1; // in pixels - m_scrollRatePerFrames = 1; - m_scrollDown = TRUE; // if TRUE text will come from the top to the bottom if False, it will go from the bottom up - m_framesSinceStarted = 0; - m_titleColor = m_positionColor = m_normalColor = GameMakeColor(255,255,255,255); - - m_currentStyle = CREDIT_STYLE_NORMAL; - m_isFinished = FALSE; - m_normalFontHeight = 10; -} - -CreditsManager::~CreditsManager(void) -{ - - m_displayedCreditLineList.clear(); - CreditsLineList::iterator it =m_creditLineList.begin(); - while (it != m_creditLineList.end()) - { - CreditsLine *cLine = *it; - delete cLine; - it = m_creditLineList.erase(it); - } -} - -void CreditsManager::init(void ) -{ - m_isFinished = FALSE; - m_creditLineListIt = m_creditLineList.begin(); - m_framesSinceStarted = 0; -} - -void CreditsManager::load(void ) -{ - INI ini; - // Read from INI all the ControlBarSchemes - ini.loadFileDirectory( "Data\\INI\\Credits", INI_LOAD_OVERWRITE, nullptr ); - - if(m_scrollRatePerFrames <=0) - m_scrollRatePerFrames = 1; - if(m_scrollRate <=0) - m_scrollRate = 1; - - GameFont *font = TheFontLibrary->getFont(TheGlobalLanguageData->m_creditsNormalFont.name, - TheGlobalLanguageData->adjustFontSize(TheGlobalLanguageData->m_creditsNormalFont.size), - TheGlobalLanguageData->m_creditsNormalFont.bold); - - m_normalFontHeight = font ? font->height : 0; -} - -void CreditsManager::reset( void ) -{ - m_displayedCreditLineList.clear(); - m_isFinished = FALSE; - m_creditLineListIt = m_creditLineList.begin(); - m_framesSinceStarted = 0; - -} - -void CreditsManager::update( void ) -{ - if(m_isFinished) - return; - m_framesSinceStarted++; - - if(m_framesSinceStarted%m_scrollRatePerFrames != 0) - return; - - - Int y = 0; - Int yTest = 0; - Int lastHeight = 0; - Int start = m_scrollDown? 0:TheDisplay->getHeight(); - Int end =m_scrollDown? TheDisplay->getHeight():0; - Int offsetStartMultiplier = m_scrollDown? -1:0; // if we're scrolling from the top, we need to subtract the height - Int offsetEndMultiplier = m_scrollDown? 0:1; - Int directionMultiplier = m_scrollDown? 1:-1; - CreditsLineList::iterator drawIt = m_displayedCreditLineList.begin(); - while (drawIt != m_displayedCreditLineList.end()) - { - CreditsLine *cLine = *drawIt; - y = cLine->m_pos.y = cLine->m_pos.y + (m_scrollRate * directionMultiplier); - lastHeight = cLine->m_height; - yTest = y + ((lastHeight + CREDIT_SPACE_OFFSET) * offsetEndMultiplier); - if(((m_scrollDown && (yTest > end)) || (!m_scrollDown && (yTest < end)))) - { - TheDisplayStringManager->freeDisplayString(cLine->m_displayString); - TheDisplayStringManager->freeDisplayString(cLine->m_secondDisplayString); - cLine->m_displayString = nullptr; - cLine->m_secondDisplayString = nullptr; - drawIt = m_displayedCreditLineList.erase(drawIt); - } - else - drawIt++; - } - - y= y + ((lastHeight + CREDIT_SPACE_OFFSET) * offsetStartMultiplier); - - // is it time to add a new string? - if(!((m_scrollDown && (yTest >= start)) || (!m_scrollDown && (yTest <= start)))) - return; - - if(m_displayedCreditLineList.empty() && m_creditLineListIt == m_creditLineList.end()) - m_isFinished = TRUE; - - if(m_creditLineListIt == m_creditLineList.end()) - return; - - CreditsLine *cLine = *m_creditLineListIt; - ICoord2D pos; - switch (cLine->m_style) - { - case CREDIT_STYLE_TITLE: - { - cLine->m_color = m_titleColor; - - if(TheGlobalLanguageData&& !cLine->m_text.isEmpty()) - { - DisplayString *ds = TheDisplayStringManager->newDisplayString(); - if(!ds) - return; - ds->setFont(TheFontLibrary->getFont(TheGlobalLanguageData->m_creditsTitleFont.name, - TheGlobalLanguageData->adjustFontSize(TheGlobalLanguageData->m_creditsTitleFont.size), - TheGlobalLanguageData->m_creditsTitleFont.bold)); - ds->setText(cLine->m_text); - ds->getSize(&pos.x,&pos.y); - cLine->m_height = pos.y; - cLine->m_pos.x = TheDisplay->getWidth()/2 - pos.x/2 ; - cLine->m_pos.y = start + (cLine->m_height * offsetStartMultiplier); - cLine->m_displayString = ds; - } - } - break; - case CREDIT_STYLE_POSITION: - { - cLine->m_color = m_positionColor; - - if(TheGlobalLanguageData && !cLine->m_text.isEmpty()) - { - DisplayString *ds = TheDisplayStringManager->newDisplayString(); - if(!ds) - return; - ds->setFont(TheFontLibrary->getFont(TheGlobalLanguageData->m_creditsPositionFont.name, - TheGlobalLanguageData->adjustFontSize(TheGlobalLanguageData->m_creditsPositionFont.size), - TheGlobalLanguageData->m_creditsPositionFont.bold)); - ds->setText(cLine->m_text); - ds->getSize(&pos.x,&pos.y); - cLine->m_height = pos.y; - cLine->m_pos.x = TheDisplay->getWidth()/2 - pos.x/2 ; - cLine->m_pos.y = start + (cLine->m_height * offsetStartMultiplier); - cLine->m_displayString = ds; - } - } - break; - case CREDIT_STYLE_NORMAL: - { - cLine->m_color = m_normalColor; - - if(TheGlobalLanguageData && !cLine->m_text.isEmpty()) - { - DisplayString *ds = TheDisplayStringManager->newDisplayString(); - if(!ds) - return; - ds->setFont(TheFontLibrary->getFont(TheGlobalLanguageData->m_creditsNormalFont.name, - TheGlobalLanguageData->adjustFontSize(TheGlobalLanguageData->m_creditsNormalFont.size), - TheGlobalLanguageData->m_creditsNormalFont.bold)); - ds->setText(cLine->m_text); - ds->getSize(&pos.x,&pos.y); - cLine->m_height = pos.y; - cLine->m_pos.x = TheDisplay->getWidth()/2 - pos.x/2 ; - cLine->m_pos.y = start + (cLine->m_height * offsetStartMultiplier); - cLine->m_displayString = ds; - } - } - break; - case CREDIT_STYLE_COLUMN: - { - cLine->m_color = m_normalColor; - - if(TheGlobalLanguageData && !cLine->m_text.isEmpty()) - { - DisplayString *ds = TheDisplayStringManager->newDisplayString(); - if(!ds) - return; - ds->setFont(TheFontLibrary->getFont(TheGlobalLanguageData->m_creditsNormalFont.name, - TheGlobalLanguageData->adjustFontSize(TheGlobalLanguageData->m_creditsNormalFont.size), - TheGlobalLanguageData->m_creditsNormalFont.bold)); - ds->setText(cLine->m_text); - ds->getSize(&pos.x,&pos.y); - cLine->m_height = pos.y; - cLine->m_pos.x = TheDisplay->getWidth()/2 - pos.x/2 ; - cLine->m_pos.y = start + (cLine->m_height * offsetStartMultiplier); - cLine->m_displayString = ds; - } - if(TheGlobalLanguageData && !cLine->m_secondText.isEmpty()) - { - DisplayString *ds = TheDisplayStringManager->newDisplayString(); - if(!ds) - return; - ds->setFont(TheFontLibrary->getFont(TheGlobalLanguageData->m_creditsNormalFont.name, - TheGlobalLanguageData->adjustFontSize(TheGlobalLanguageData->m_creditsNormalFont.size), - TheGlobalLanguageData->m_creditsNormalFont.bold)); - ds->setText(cLine->m_secondText); - ds->getSize(&pos.x,&pos.y); - cLine->m_height = pos.y; - cLine->m_pos.x = TheDisplay->getWidth()/2 - pos.x/2 ; - cLine->m_pos.y = start + (cLine->m_height * offsetStartMultiplier); - cLine->m_secondDisplayString = ds; - - } - } - break; - case CREDIT_STYLE_BLANK: - { - cLine->m_height = m_normalFontHeight; - cLine->m_pos.y = start + (cLine->m_height * offsetStartMultiplier); - } - break; - } - - m_displayedCreditLineList.push_back(cLine); - - if(m_creditLineListIt != m_creditLineList.end()) - m_creditLineListIt++; - -} - -void CreditsManager::draw( void ) -{ - CreditsLineList::iterator drawIt = m_displayedCreditLineList.begin(); - while (drawIt != m_displayedCreditLineList.end()) - { - CreditsLine *cLine = *drawIt; - Int heightChunk = TheDisplay->getHeight()/3; - Real perc = 0.0f; - if(cLine->m_pos.y < heightChunk || cLine->m_pos.y > heightChunk * 2) - { - // adjust the color - if( cLine->m_pos.y < 0 || cLine->m_pos.y > TheDisplay->getHeight()) - perc = 0.0f; - else if( cLine->m_pos.y < heightChunk) - perc = INT_TO_REAL(cLine->m_pos.y) / heightChunk; - else - perc = 1 - INT_TO_REAL(cLine->m_pos.y - 2*heightChunk) / heightChunk; - } - else - perc = 1.0f; - UnsignedByte r,g,b,a; - GameGetColorComponents(cLine->m_color, &r, &g, &b, &a); - Int color = GameMakeColor( r,g,b, a * perc); - Int bColor= GameMakeColor( 0,0,0, a * perc); - - switch (cLine->m_style) { - case CREDIT_STYLE_TITLE: - case CREDIT_STYLE_POSITION: - case CREDIT_STYLE_NORMAL: - { - if(cLine->m_displayString) - cLine->m_displayString->draw(cLine->m_pos.x,cLine->m_pos.y,color, bColor, 1,1 ); - } - break; - case CREDIT_STYLE_COLUMN: - { - Int chunk = TheDisplay->getWidth()/3; - ICoord2D pos; - if(cLine->m_displayString) - { - cLine->m_displayString->getSize(&pos.x, &pos.y); - cLine->m_displayString->draw(chunk - (pos.x/2),cLine->m_pos.y,color, bColor, 1,1 ); - } - if(cLine->m_secondDisplayString) - { - cLine->m_secondDisplayString->getSize(&pos.x, &pos.y); - cLine->m_secondDisplayString->draw(2*chunk - (pos.x/2),cLine->m_pos.y,color, bColor, 1,1 ); - } - } - break; - } - - drawIt++; - } -} -void CreditsManager::addBlank( void ) -{ - CreditsLine *cLine = new CreditsLine; - cLine->m_style = CREDIT_STYLE_BLANK; - m_creditLineList.push_back(cLine); -} - - - -void CreditsManager::parseBlank( INI* ini, void *instance, void *store, const void *userData ) -{ - CreditsManager *cManager = (CreditsManager *)instance; - cManager->addBlank(); -} - -void CreditsManager::parseText( INI* ini, void *instance, void *store, const void *userData ) -{ - - AsciiString asciiString = ini->getNextQuotedAsciiString(); - CreditsManager *cManager = (CreditsManager *)instance; - cManager->addText(asciiString); -} -void CreditsManager::addText( AsciiString text ) -{ - CreditsLine *cLine = new CreditsLine; - - switch (m_currentStyle) - { - case CREDIT_STYLE_TITLE: - case CREDIT_STYLE_POSITION: - case CREDIT_STYLE_NORMAL: - { - cLine->m_text = getUnicodeString(text); - cLine->m_style = m_currentStyle; - m_creditLineList.push_back(cLine); - } - break; - case CREDIT_STYLE_COLUMN: - { - CreditsLineList::reverse_iterator rIt = m_creditLineList.rbegin(); - CreditsLine *rcLine = *rIt; - if(rIt == m_creditLineList.rend() || rcLine->m_style != CREDIT_STYLE_COLUMN - || (rcLine->m_style == CREDIT_STYLE_COLUMN && rcLine->m_done == TRUE)) - { - cLine->m_text = getUnicodeString(text); - cLine->m_style = CREDIT_STYLE_COLUMN; - cLine->m_useSecond = TRUE; - m_creditLineList.push_back(cLine); - } - else - { - rcLine->m_secondText = getUnicodeString(text); - rcLine->m_done = TRUE; - delete cLine; - } - - } - break; - default: - DEBUG_ASSERTCRASH( FALSE, ("CreditsManager::addText we tried to add a credit text with the wrong style before it. Style is %d", m_currentStyle) ); - delete cLine; - } - -} - -//----------------------------------------------------------------------------- -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -UnicodeString CreditsManager::getUnicodeString(AsciiString str) -{ - UnicodeString uStr; - if(str.compare("") == 0) - return UnicodeString::TheEmptyString; - - if(str.find(':')) - uStr = TheGameText->fetch(str); - else - uStr.translate(str); - - return uStr; -} diff --git a/Generals/Code/GameEngine/Source/GameClient/DisplayString.cpp b/Generals/Code/GameEngine/Source/GameClient/DisplayString.cpp deleted file mode 100644 index 2367de67984..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/DisplayString.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: DisplayString.cpp //////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: DisplayString.cpp -// -// Created: Colin Day, July 2001 -// -// Desc: Contstuct for holding double byte game string data and being -// able to draw that text to the screen. -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -// USER INCLUDES ////////////////////////////////////////////////////////////// -#include "Common/Debug.h" -#include "Common/Language.h" -#include "GameClient/DisplayString.h" - -// DEFINES //////////////////////////////////////////////////////////////////// - -// PRIVATE TYPES ////////////////////////////////////////////////////////////// - -// PRIVATE DATA /////////////////////////////////////////////////////////////// - -// PUBLIC DATA //////////////////////////////////////////////////////////////// - -// PRIVATE PROTOTYPES ///////////////////////////////////////////////////////// - -// PRIVATE FUNCTIONS ////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -// DisplayString::DisplayString =============================================== -/** */ -//============================================================================= -DisplayString::DisplayString( void ) -{ - // m_textString = ""; // not necessary, done by default - m_font = nullptr; - - m_next = nullptr; - m_prev = nullptr; - -} - -// DisplayString::~DisplayString ============================================== -/** */ -//============================================================================= -DisplayString::~DisplayString( void ) -{ - - // free any data - reset(); - -} - -// DisplayString::setText ===================================================== -/** Copy the text to this instance */ -//============================================================================= -void DisplayString::setText( UnicodeString text ) -{ - if (text == m_textString) - return; - - m_textString = text; - - // our text has now changed - notifyTextChanged(); - -} - -// DisplayString::reset ======================================================= -/** Free and reset all the data for this string, effectively making this - * instance like brand new */ -//============================================================================= -void DisplayString::reset( void ) -{ - - m_textString.clear(); - - // no font - m_font = nullptr; - -} - -// DisplayString::removeLastChar ============================================== -/** Remove the last character from the string text */ -//============================================================================= -void DisplayString::removeLastChar( void ) -{ - m_textString.removeLastChar(); - - // our text has now changed - notifyTextChanged(); - -} - -// DisplayString::truncateBy ================================================== -/** Remove the last charCount characters from the string text */ -//============================================================================= -void DisplayString::truncateBy(const Int charCount) -{ - m_textString.truncateBy(charCount); - - // our text has now changed - notifyTextChanged(); - -} - -// DisplayString::truncateTo ================================================== -/** Remove the last characters from the string text so it's at the most - * maxLength characters long */ - //============================================================================= -void DisplayString::truncateTo(const Int maxLength) -{ - m_textString.truncateTo(maxLength); - - // our text has now changed - notifyTextChanged(); - -} - -// DisplayString::appendChar ================================================== -/** Append character to the end of the string */ -//============================================================================= -void DisplayString::appendChar( WideChar c ) -{ - m_textString.concat(c); - - // text has now changed - notifyTextChanged(); - -} - diff --git a/Generals/Code/GameEngine/Source/GameClient/DisplayStringManager.cpp b/Generals/Code/GameEngine/Source/GameClient/DisplayStringManager.cpp deleted file mode 100644 index 7f55378fd24..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/DisplayStringManager.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: DisplayStringManager.cpp ///////////////////////////////////////////////////////////////// -// Created: Colin Day, July 2001 -// Desc: Access for creating game managed display strings -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/DisplayStringManager.h" - -// PUBLIC DATA //////////////////////////////////////////////////////////////////////////////////// -DisplayStringManager *TheDisplayStringManager = nullptr; - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC FUNCTIONS -/////////////////////////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -DisplayStringManager::DisplayStringManager( void ) -{ - - m_stringList = nullptr; - m_currentCheckpoint = nullptr; - -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -DisplayStringManager::~DisplayStringManager( void ) -{ - - // - // we only keep track of the strings, we do NOT de-allocate them, our - // list better be cleaned out before we destroy ourselves - // - assert( m_stringList == nullptr ); - -} - -//------------------------------------------------------------------------------------------------- -/** Link a display string to the master list */ -//------------------------------------------------------------------------------------------------- -void DisplayStringManager::link( DisplayString *string ) -{ - - assert( string ); - assert( string->m_next == nullptr ); - assert( string->m_prev == nullptr ); - - string->m_next = m_stringList; - if( m_stringList ) - m_stringList->m_prev = string; - - m_stringList = string; - -} - -//------------------------------------------------------------------------------------------------- -/** Unlink a display string from the master list */ -//------------------------------------------------------------------------------------------------- -void DisplayStringManager::unLink( DisplayString *string ) -{ - - assert( string ); - assert( m_stringList ); - - if( string->m_next ) - string->m_next->m_prev = string->m_prev; - if( string->m_prev ) - string->m_prev->m_next = string->m_next; - else - { - - assert( string == m_stringList ); - m_stringList = string->m_next; - - } - -} diff --git a/Generals/Code/GameEngine/Source/GameClient/DrawGroupInfo.cpp b/Generals/Code/GameEngine/Source/GameClient/DrawGroupInfo.cpp deleted file mode 100644 index 65742a9f76a..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/DrawGroupInfo.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// DrawGroupInfo.cpp ////////////////////////////////////////////////////////////////////////////// -// Author: John McDonald, October 2002 -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/DrawGroupInfo.h" - -// Useful defaults. - -DrawGroupInfo::DrawGroupInfo() -{ - m_fontName = "Arial"; - m_fontSize = 10; - m_fontIsBold = FALSE; - - m_usePlayerColor = TRUE; - m_colorForText = GameMakeColor(255, 255, 255, 255); - m_colorForTextDropShadow = GameMakeColor(0, 0, 0, 255); - - m_dropShadowOffsetX = -1; - m_dropShadowOffsetY = -1; - - m_percentOffsetX = -0.05f; - m_usingPixelOffsetX = FALSE; - - m_pixelOffsetY = -10; - m_usingPixelOffsetY = TRUE; -} - -DrawGroupInfo *TheDrawGroupInfo = nullptr; diff --git a/Generals/Code/GameEngine/Source/GameClient/FXList.cpp b/Generals/Code/GameEngine/Source/GameClient/FXList.cpp deleted file mode 100644 index 6290a3ddaac..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/FXList.cpp +++ /dev/null @@ -1,880 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: FXList.cpp /////////////////////////////////////////////////////////////////////////////// -// Author: Steven Johnson, December 2001 -// Desc: FXList descriptions -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/FXList.h" - -#include "Common/DrawModule.h" -#include "Common/GameAudio.h" -#include "Common/GameUtility.h" -#include "Common/INI.h" -#include "Common/Player.h" -#include "Common/PlayerList.h" -#include "Common/RandomValue.h" -#include "Common/ThingTemplate.h" -#include "Common/ThingFactory.h" - -#include "GameLogic/Object.h" -#include "GameLogic/GameLogic.h" -#include "GameLogic/TerrainLogic.h" -#include "GameClient/Display.h" -#include "GameClient/GameClient.h" -#include "GameClient/Drawable.h" -#include "GameClient/ParticleSys.h" -#include "GameLogic/PartitionManager.h" - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PUBLIC DATA //////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - - -FXListStore *TheFXListStore = nullptr; ///< the FXList store definition - -//------------------------------------------------------------------------------------------------- -static void adjustVector(Coord3D *vec, const Matrix3D* mtx) -{ - if (mtx) - { - Vector3 vectmp; - vectmp.X = vec->x; - vectmp.Y = vec->y; - vectmp.Z = vec->z; - vectmp = mtx->Rotate_Vector(vectmp); - vec->x = vectmp.X; - vec->y = vectmp.Y; - vec->z = vectmp.Z; - } -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// -// PRIVATE CLASSES /////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -void FXNugget::doFXObj(const Object* primary, const Object* secondary) const -{ - const Coord3D* p = primary ? primary->getPosition() : nullptr; - const Matrix3D* mtx = primary ? primary->getTransformMatrix() : nullptr; - const Real speed = 0.0f; // yes, that's right -- NOT the object's speed. - const Coord3D* s = secondary ? secondary->getPosition() : nullptr; - doFXPos(p, mtx, speed, s); -} - -//------------------------------------------------------------------------------------------------- -class SoundFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(SoundFXNugget, "SoundFXNugget") - -public: - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* /*primaryMtx*/, const Real /*primarySpeed*/, const Coord3D * /*secondary*/, const Real /*overrideRadius*/ ) const - { - AudioEventRTS sound(m_soundName); - - if (primary) - { - sound.setPosition(primary); - } - - TheAudio->addAudioEvent(&sound); - } - - virtual void doFXObj(const Object* primary, const Object* secondary = nullptr) const - { - AudioEventRTS sound(m_soundName); - if (primary) - { - sound.setPlayerIndex(primary->getControllingPlayer()->getPlayerIndex()); - sound.setPosition(primary->getPosition()); - } - - TheAudio->addAudioEvent(&sound); - } - - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "Name", INI::parseAsciiString, nullptr, offsetof( SoundFXNugget, m_soundName ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - SoundFXNugget* nugget = newInstance(SoundFXNugget); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -private: - AsciiString m_soundName; -}; -EMPTY_DTOR(SoundFXNugget) - -//------------------------------------------------------------------------------------------------- -static Real calcDist(const Coord3D& src, const Coord3D& dst) -{ - Real dx = dst.x - src.x; - Real dy = dst.y - src.y; - Real dz = dst.z - src.z; - return sqrt(dx*dx + dy*dy + dz*dz); -} - -//------------------------------------------------------------------------------------------------- -class TracerFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(TracerFXNugget, "TracerFXNugget") -public: - - TracerFXNugget() - { - m_tracerName.set("GenericTracer"); - m_boneName.clear(); - m_speed = 0.0f; // means "use passed-in speed" - m_decayAt = 1.0f; - m_length = 10.0f; - m_width = 1.0f; - m_color.red = m_color.green = m_color.blue = 1.0f; - m_probability = 1.0f; - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* primaryMtx, const Real primarySpeed, const Coord3D *secondary, const Real /*overrideRadius*/ ) const - { - if (m_probability <= GameClientRandomValueReal(0, 1)) - return; - - if (primary && secondary) - { - Drawable *tracer = TheThingFactory->newDrawable(TheThingFactory->findTemplate(m_tracerName)); - if(!tracer) - return; - - //Kris -- Redid this section Sept 18, 2002 - //Calculate tracer orientations to face from primary to secondary position. This - //should be the direction that the projectile is being fired towards. It doesn't make - //sense that the old stuff made use of the muzzle fx bone orientation (because it's a - //subobject). It had other problems because of elevation variations the tracers would - //stay on the ground. - //tracer->setTransformMatrix(primaryMtx); - Matrix3D tracerMtx; - Vector3 pos( primary->x, primary->y, primary->z ); - Vector3 dir( secondary->x - primary->x, secondary->y - primary->y, secondary->z - primary->z ); - dir.Normalize(); //This is fantastically crucial for calling buildTransformMatrix!!!!! - tracerMtx.buildTransformMatrix( pos, dir ); - tracer->setTransformMatrix( &tracerMtx ); - tracer->setPosition(primary); - - Real speed = m_speed; - if (speed == 0.0f) - { - speed = primarySpeed; - } - - TracerDrawInterface* tdi = nullptr; - for (DrawModule** d = tracer->getDrawModules(); *d; ++d) - { - if ((tdi = (*d)->getTracerDrawInterface()) != nullptr) - { - tdi->setTracerParms(speed, m_length, m_width, m_color, 1.0f); - } - } - - // estimate how long it will take us to get to the destination - Real dist = calcDist(*primary, *secondary) - m_length; - Real frames = (dist >= 0.0f && speed >= 0.0f) ? (dist / speed) : 1; - Int framesAdjusted = REAL_TO_INT_CEIL(frames * m_decayAt); - tracer->setExpirationDate(TheGameLogic->getFrame() + framesAdjusted); - } - else - { - DEBUG_CRASH(("You must have a primary and secondary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "TracerName", INI::parseAsciiString, nullptr, offsetof( TracerFXNugget, m_tracerName ) }, - { "BoneName", INI::parseAsciiString, nullptr, offsetof( TracerFXNugget, m_boneName ) }, - { "Speed", INI::parseVelocityReal, nullptr, offsetof( TracerFXNugget, m_speed ) }, - { "DecayAt", INI::parseReal, nullptr, offsetof( TracerFXNugget, m_decayAt ) }, - { "Length", INI::parseReal, nullptr, offsetof( TracerFXNugget, m_length ) }, - { "Width", INI::parseReal, nullptr, offsetof( TracerFXNugget, m_width ) }, - { "Color", INI::parseRGBColor, nullptr, offsetof( TracerFXNugget, m_color ) }, - { "Probability", INI::parseReal, nullptr, offsetof( TracerFXNugget, m_probability ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - TracerFXNugget* nugget = newInstance( TracerFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -private: - AsciiString m_tracerName; - AsciiString m_boneName; - Real m_speed; - Real m_decayAt; - Real m_length; - Real m_width; - RGBColor m_color; - Real m_probability; -}; -EMPTY_DTOR(TracerFXNugget) - -//------------------------------------------------------------------------------------------------- -class RayEffectFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(RayEffectFXNugget, "RayEffectFXNugget") -public: - - RayEffectFXNugget() - { - m_templateName.clear(); - m_primaryOffset.x = m_primaryOffset.y = m_primaryOffset.z = 0; - m_secondaryOffset.x = m_secondaryOffset.y = m_secondaryOffset.z = 0; - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* /*primaryMtx*/, const Real /*primarySpeed*/, const Coord3D * secondary, const Real /*overrideRadius*/ ) const - { - const ThingTemplate* tmpl = TheThingFactory->findTemplate(m_templateName); - DEBUG_ASSERTCRASH(tmpl, ("RayEffect %s not found",m_templateName.str())); - if (primary && secondary && tmpl) - { - Coord3D sourcePos = *primary; - sourcePos.x += m_primaryOffset.x; - sourcePos.y += m_primaryOffset.y; - sourcePos.z += m_primaryOffset.z; - - Coord3D targetPos = *secondary; - targetPos.x += m_secondaryOffset.x; - targetPos.y += m_secondaryOffset.y; - targetPos.z += m_secondaryOffset.z; - - TheGameClient->createRayEffectByTemplate(&sourcePos, &targetPos, tmpl); - } - else - { - DEBUG_CRASH(("You must have a primary AND secondary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "Name", INI::parseAsciiString, nullptr, offsetof( RayEffectFXNugget, m_templateName ) }, - { "PrimaryOffset", INI::parseCoord3D, nullptr, offsetof( RayEffectFXNugget, m_primaryOffset ) }, - { "SecondaryOffset", INI::parseCoord3D, nullptr, offsetof( RayEffectFXNugget, m_secondaryOffset ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - RayEffectFXNugget* nugget = newInstance( RayEffectFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -private: - AsciiString m_templateName; - Coord3D m_primaryOffset; - Coord3D m_secondaryOffset; -}; -EMPTY_DTOR(RayEffectFXNugget) - -//------------------------------------------------------------------------------------------------- -class LightPulseFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(LightPulseFXNugget, "LightPulseFXNugget") -public: - - LightPulseFXNugget() : m_radius(0), m_increaseFrames(0), m_decreaseFrames(0), m_boundingCirclePct(0) - { - m_color.red = m_color.green = m_color.blue = 0; - } - - virtual void doFXObj(const Object* primary, const Object* /*secondary*/) const - { - if (primary) - { - Real radius = m_radius; - - if (m_boundingCirclePct > 0) - radius = (primary->getGeometryInfo().getBoundingCircleRadius() * m_boundingCirclePct); - - TheDisplay->createLightPulse(primary->getPosition(), &m_color, 1, radius, m_increaseFrames, m_decreaseFrames); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* /*primaryMtx*/, const Real /*primarySpeed*/, const Coord3D * /*secondary*/, const Real /*overrideRadius*/ ) const - { - if (primary) - { - TheDisplay->createLightPulse(primary, &m_color, 1, m_radius, m_increaseFrames, m_decreaseFrames); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "Color", INI::parseRGBColor, nullptr, offsetof( LightPulseFXNugget, m_color ) }, - { "Radius", INI::parseReal, nullptr, offsetof( LightPulseFXNugget, m_radius ) }, - { "RadiusAsPercentOfObjectSize", INI::parsePercentToReal, nullptr, offsetof( LightPulseFXNugget, m_boundingCirclePct ) }, - { "IncreaseTime", INI::parseDurationUnsignedInt, nullptr, offsetof( LightPulseFXNugget, m_increaseFrames ) }, - { "DecreaseTime", INI::parseDurationUnsignedInt, nullptr, offsetof( LightPulseFXNugget, m_decreaseFrames ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - LightPulseFXNugget* nugget = newInstance( LightPulseFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -private: - RGBColor m_color; - Real m_radius; - Real m_boundingCirclePct; - UnsignedInt m_increaseFrames; - UnsignedInt m_decreaseFrames; -}; -EMPTY_DTOR(LightPulseFXNugget) - -//------------------------------------------------------------------------------------------------- -class ViewShakeFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ViewShakeFXNugget, "ViewShakeFXNugget") -public: - - ViewShakeFXNugget() : m_shake(View::SHAKE_NORMAL) - { - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* /*primaryMtx*/, const Real /*primarySpeed*/, const Coord3D * /*secondary*/, const Real /*overrideRadius*/ ) const - { - if (primary) - { - if (TheTacticalView) - TheTacticalView->shake(primary, m_shake); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "Type", parseShakeType, nullptr, offsetof( ViewShakeFXNugget, m_shake ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - ViewShakeFXNugget* nugget = newInstance( ViewShakeFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -protected: - static void parseShakeType( INI* ini, void *instance, void *store, const void* /*userData*/ ) - { - static const LookupListRec shakeTypeNames[] = - { - { "SUBTLE", View::SHAKE_SUBTLE }, - { "NORMAL", View::SHAKE_NORMAL }, - { "STRONG", View::SHAKE_STRONG }, - { "SEVERE", View::SHAKE_SEVERE }, - { "CINE_EXTREME", View::SHAKE_CINE_EXTREME }, - { "CINE_INSANE", View::SHAKE_CINE_INSANE }, - { nullptr, 0 } - }; - static_assert(ARRAY_SIZE(shakeTypeNames) == View::SHAKE_COUNT + 1, "Incorrect array size"); - - *(Int *)store = INI::scanLookupList(ini->getNextToken(), shakeTypeNames); - } - -private: - View::CameraShakeType m_shake; - -}; -EMPTY_DTOR(ViewShakeFXNugget) - -//------------------------------------------------------------------------------------------------- -class TerrainScorchFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(TerrainScorchFXNugget, "TerrainScorchFXNugget") -public: - - TerrainScorchFXNugget() : m_scorch(-1), m_radius(0) - { - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* /*primaryMtx*/, const Real /*primarySpeed*/, const Coord3D * /*secondary*/, const Real /*overrideRadius*/ ) const - { - if (primary) - { - Int scorch = m_scorch; - if (scorch < 0) - { - scorch = GameClientRandomValue( SCORCH_1, SCORCH_4 ); - } - TheGameClient->addScorch(primary, m_radius, (Scorches)scorch); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "Type", parseScorchType, nullptr, offsetof( TerrainScorchFXNugget, m_scorch ) }, - { "Radius", INI::parseReal, nullptr, offsetof( TerrainScorchFXNugget, m_radius ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - TerrainScorchFXNugget* nugget = newInstance( TerrainScorchFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -protected: - - static void parseScorchType( INI* ini, void *instance, void *store, const void* /*userData*/ ) - { - static const LookupListRec scorchTypeNames[] = - { - { "SCORCH_1", SCORCH_1 }, - { "SCORCH_2", SCORCH_2 }, - { "SCORCH_3", SCORCH_3 }, - { "SCORCH_4", SCORCH_4 }, - { "SHADOW_SCORCH", SHADOW_SCORCH }, - { "RANDOM", -1 }, - { nullptr, 0 } - }; - static_assert(ARRAY_SIZE(scorchTypeNames) == SCORCH_COUNT + 2, "Incorrect array size"); - - *(Int *)store = INI::scanLookupList(ini->getNextToken(), scorchTypeNames); - } - -private: - Int m_scorch; - Real m_radius; -}; -EMPTY_DTOR(TerrainScorchFXNugget) - -//------------------------------------------------------------------------------------------------- -class ParticleSystemFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(ParticleSystemFXNugget, "ParticleSystemFXNugget") -public: - - ParticleSystemFXNugget() - { - m_name.clear(); - m_count = 1; - m_radius.setRange(0, 0, GameClientRandomVariable::CONSTANT); - m_height.setRange(0, 0, GameClientRandomVariable::CONSTANT); - // -1 means "don't mess with it, just accept the particle-system's defaults" - m_delay.setRange(-1, -1, GameClientRandomVariable::CONSTANT); - m_offset.x = m_offset.y = m_offset.z = 0; - m_orientToObject = false; - m_attachToObject = false; - m_createAtGroundHeight = FALSE; - m_useCallersRadius = FALSE; - m_rotateX = m_rotateY = m_rotateZ = 0; - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* primaryMtx, const Real /*primarySpeed*/, const Coord3D * /*secondary*/, const Real overrideRadius ) const - { - if (primary) - { - reallyDoFX(primary, primaryMtx, nullptr, overrideRadius); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - virtual void doFXObj(const Object* primary, const Object* secondary) const - { - if (primary) - { - - if (m_ricochet && secondary) - { - // HERE WE MUST BUILD A MATRIX WHICH WILL ORIENT THE NEW PARTICLE SYSTEM TO FACE AWAY FROM THE SECONDARY OBJECT - // THE RESULT SHOULD LOOK LIKE THE DIRECTION OF THE "ATTACK" IS CARRIED THROUGH LIKE A RICOCHET - Real deltaX = primary->getPosition()->x - secondary->getPosition()->x; - Real deltaY = primary->getPosition()->y - secondary->getPosition()->y; - Real aimingAngle = atan2(deltaY, deltaX); - Matrix3D aimingMatrix(1); - aimingMatrix.Rotate_Z( aimingAngle ); - - reallyDoFX(primary->getPosition(), &aimingMatrix, primary, 0.0f); - } - else - // if we have an object, then adjust the offset and direction by the object's transformation - // matrix, so that (say) an offset of +10 in the z axis "follows" the orientation of the object. - reallyDoFX(primary->getPosition(), primary->getTransformMatrix(), primary, 0.0f); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "Name", INI::parseAsciiString, nullptr, offsetof( ParticleSystemFXNugget, m_name ) }, - { "Count", INI::parseInt, nullptr, offsetof( ParticleSystemFXNugget, m_count ) }, - { "Offset", INI::parseCoord3D, nullptr, offsetof( ParticleSystemFXNugget, m_offset ) }, - { "Radius", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemFXNugget, m_radius ) }, - { "Height", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemFXNugget, m_height ) }, - { "InitialDelay", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemFXNugget, m_delay ) }, - { "RotateX", INI::parseAngleReal, nullptr, offsetof( ParticleSystemFXNugget, m_rotateX ) }, - { "RotateY", INI::parseAngleReal, nullptr, offsetof( ParticleSystemFXNugget, m_rotateY ) }, - { "RotateZ", INI::parseAngleReal, nullptr, offsetof( ParticleSystemFXNugget, m_rotateZ ) }, - { "OrientToObject", INI::parseBool, nullptr, offsetof( ParticleSystemFXNugget, m_orientToObject ) }, - { "Ricochet", INI::parseBool, nullptr, offsetof( ParticleSystemFXNugget, m_ricochet ) }, - { "AttachToObject", INI::parseBool, nullptr, offsetof( ParticleSystemFXNugget, m_attachToObject ) }, - { "CreateAtGroundHeight", INI::parseBool, nullptr, offsetof( ParticleSystemFXNugget, m_createAtGroundHeight ) }, - { "UseCallersRadius", INI::parseBool, nullptr, offsetof( ParticleSystemFXNugget, m_useCallersRadius ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - ParticleSystemFXNugget* nugget = newInstance( ParticleSystemFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -protected: - - void reallyDoFX(const Coord3D *primary, const Matrix3D* mtx, const Object* thingToAttachTo, Real overrideRadius ) const - { - Coord3D offset = m_offset; - if (mtx) - { - adjustVector(&offset, mtx); - } - - const ParticleSystemTemplate *tmp = TheParticleSystemManager->findTemplate(m_name); - DEBUG_ASSERTCRASH(tmp, ("ParticleSystem %s not found",m_name.str())); - if (tmp) - { - for (Int i = 0; i < m_count; i++ ) - { - ParticleSystem *sys = TheParticleSystemManager->createParticleSystem(tmp); - if (sys) - { - Coord3D newPos; - Real radius = m_radius.getValue(); - Real angle = GameClientRandomValueReal( 0.0f, 2.0f * PI ); - - newPos.x = primary->x + offset.x + radius * cos(angle); - newPos.y = primary->y + offset.y + radius * sin(angle); - if( m_createAtGroundHeight && TheTerrainLogic ) - { - //old way: - //newPos.z = TheTerrainLogic->getGrsoundHeight( newPos.x, newPos.y ) + 1;// The plus one prevents scissoring with terrain - - //new way: now we allow bridges in the GroundHeight. - PathfindLayerEnum layer = TheTerrainLogic->getLayerForDestination(&newPos); - newPos.z = TheTerrainLogic->getLayerHeight( newPos.x, newPos.y, layer ); - } - else - newPos.z = primary->z + offset.z + m_height.getValue(); - - - if (m_orientToObject && mtx) - { - sys->setLocalTransform(mtx); - } - if (m_rotateX != 0.0f) - sys->rotateLocalTransformX(m_rotateX); - if (m_rotateY != 0.0f) - sys->rotateLocalTransformY(m_rotateY); - if (m_rotateZ != 0.0f) - sys->rotateLocalTransformZ(m_rotateZ); - - if (m_attachToObject && thingToAttachTo) - sys->attachToObject(thingToAttachTo); - else - sys->setPosition( &newPos ); - - Real delayInMsec = m_delay.getValue(); - if (delayInMsec >= 0.0f) - { - UnsignedInt delayInFrames = REAL_TO_INT_CEIL(ConvertDurationFromMsecsToFrames(delayInMsec)); - sys->setInitialDelay(delayInFrames); - } - - if( m_useCallersRadius && overrideRadius ) - { - ParticleSystemInfo::EmissionVolumeType type = sys->getEmisionVolumeType(); - - if( type == ParticleSystemInfo::EmissionVolumeType::SPHERE ) - sys->setEmissionVolumeSphereRadius( overrideRadius ); - else if( type == ParticleSystemInfo::EmissionVolumeType::CYLINDER ) - sys->setEmissionVolumeCylinderRadius( overrideRadius ); - } - } - } - } - } - - -private: - AsciiString m_name; - Int m_count; - Coord3D m_offset; - GameClientRandomVariable m_radius; - GameClientRandomVariable m_height; - GameClientRandomVariable m_delay; - Real m_rotateX, m_rotateY, m_rotateZ; - Bool m_orientToObject; - Bool m_attachToObject; - Bool m_createAtGroundHeight; - Bool m_useCallersRadius; - Bool m_ricochet; -}; -EMPTY_DTOR(ParticleSystemFXNugget) - -//------------------------------------------------------------------------------------------------- -class FXListAtBonePosFXNugget : public FXNugget -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(FXListAtBonePosFXNugget, "FXListAtBonePosFXNugget") -public: - - FXListAtBonePosFXNugget() - { - m_fx = nullptr; - m_boneName.clear(); - m_orientToBone = true; - } - - virtual void doFXPos(const Coord3D *primary, const Matrix3D* primaryMtx, const Real /*primarySpeed*/, const Coord3D * /*secondary*/, const Real /*overrideRadius*/ ) const - { - DEBUG_CRASH(("You must use the object form for this effect")); - } - - virtual void doFXObj(const Object* primary, const Object* /*secondary*/) const - { - if (primary) - { - // first, try the unadorned name. - doFxAtBones(primary, 0); - - // then, try the 01,02,03...etc names. - doFxAtBones(primary, 1); - } - else - { - DEBUG_CRASH(("You must have a primary source for this effect")); - } - } - - static void parse(INI *ini, void *instance, void* /*store*/, const void* /*userData*/) - { - static const FieldParse myFieldParse[] = - { - { "FX", INI::parseFXList, nullptr, offsetof( FXListAtBonePosFXNugget, m_fx ) }, - { "BoneName", INI::parseAsciiString, nullptr, offsetof( FXListAtBonePosFXNugget, m_boneName ) }, - { "OrientToBone", INI::parseBool, nullptr, offsetof( FXListAtBonePosFXNugget, m_orientToBone ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - FXListAtBonePosFXNugget* nugget = newInstance( FXListAtBonePosFXNugget ); - ini->initFromINI(nugget, myFieldParse); - ((FXList*)instance)->addFXNugget(nugget); - } - -protected: - - void doFxAtBones(const Object* obj, Int start) const - { - Coord3D bonePos[MAX_BONE_POINTS]; - Matrix3D boneMtx[MAX_BONE_POINTS]; - - Drawable* draw = obj->getDrawable(); - if (draw) - { - // yes, BONEPOS_CURRENT_CLIENT_ONLY -- this is client-only, so should be safe to do. - Int count = draw->getCurrentClientBonePositions(m_boneName.str(), start, bonePos, boneMtx, MAX_BONE_POINTS); - for (Int i = 0; i < count; ++i) - { - Coord3D p; - Matrix3D m; - obj->convertBonePosToWorldPos(&bonePos[i], &boneMtx[i], &p, &m); - FXList::doFXPos(m_fx, &p, &m, 0.0f, nullptr, 0.0f); - } - } - } - -private: - - enum { MAX_BONE_POINTS = 40 }; - - const FXList* m_fx; - AsciiString m_boneName; - Bool m_orientToBone; -}; -EMPTY_DTOR(FXListAtBonePosFXNugget) - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- - -static const FieldParse TheFXListFieldParse[] = -{ - { "Sound", SoundFXNugget::parse, nullptr, 0}, - { "RayEffect", RayEffectFXNugget::parse, nullptr, 0}, - { "Tracer", TracerFXNugget::parse, nullptr, 0}, - { "LightPulse", LightPulseFXNugget::parse, nullptr, 0}, - { "ViewShake", ViewShakeFXNugget::parse, nullptr, 0}, - { "TerrainScorch", TerrainScorchFXNugget::parse, nullptr, 0}, - { "ParticleSystem", ParticleSystemFXNugget::parse, nullptr, 0}, - { "FXListAtBonePos", FXListAtBonePosFXNugget::parse, nullptr, 0}, - { nullptr, nullptr, nullptr, 0 } -}; - -//------------------------------------------------------------------------------------------------- -FXList::FXList() -{ -} - -//------------------------------------------------------------------------------------------------- -FXList::~FXList() -{ - clear(); -} - -//------------------------------------------------------------------------------------------------- -void FXList::clear() -{ - for (FXNuggetList::iterator it = m_nuggets.begin(); it != m_nuggets.end(); ++it) - { - deleteInstance(*it); - } - m_nuggets.clear(); -} - -//------------------------------------------------------------------------------------------------- -void FXList::doFXPos(const Coord3D *primary, const Matrix3D* primaryMtx, const Real primarySpeed, const Coord3D *secondary, const Real overrideRadius ) const -{ - const Int playerIndex = rts::getObservedOrLocalPlayer()->getPlayerIndex(); - - if (ThePartitionManager->getShroudStatusForPlayer(playerIndex, primary) != CELLSHROUD_CLEAR) - return; - - for (FXNuggetList::const_iterator it = m_nuggets.begin(); it != m_nuggets.end(); ++it) - { - (*it)->doFXPos(primary, primaryMtx, primarySpeed, secondary, overrideRadius); - } -} - -//------------------------------------------------------------------------------------------------- -void FXList::doFXObj(const Object* primary, const Object* secondary) const -{ - const Int playerIndex = rts::getObservedOrLocalPlayer()->getPlayerIndex(); - - if (primary && primary->getShroudedStatus(playerIndex) > OBJECTSHROUD_PARTIAL_CLEAR) - return; //the primary object is fogged or shrouded so don't bother with the effect. - - for (FXNuggetList::const_iterator it = m_nuggets.begin(); it != m_nuggets.end(); ++it) - { - - // HERE THE PRIMARY IS THE GUY RECEIVING THE FX, AND SECONDARY MIGHT BE THE GUY DEALING IT - (*it)->doFXObj(primary, secondary); - } -} - - - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- - -//------------------------------------------------------------------------------------------------- -FXListStore::FXListStore() -{ -} - -//------------------------------------------------------------------------------------------------- -FXListStore::~FXListStore() -{ - m_fxmap.clear(); -} - -//------------------------------------------------------------------------------------------------- -const FXList *FXListStore::findFXList(const char* name) const -{ - if (stricmp(name, "None") == 0) - return nullptr; - - FXListMap::const_iterator it = m_fxmap.find(NAMEKEY(name)); - if (it != m_fxmap.end()) - { - return &(*it).second; - } - return nullptr; -} - -//------------------------------------------------------------------------------------------------- -/*static */ void FXListStore::parseFXListDefinition(INI *ini) -{ - // read the FXList name - const char *c = ini->getNextToken(); - NameKeyType key = TheNameKeyGenerator->nameToKey(c); - FXList& fxl = TheFXListStore->m_fxmap[key]; - fxl.clear(); - ini->initFromINI(&fxl, TheFXListFieldParse); -} - -//------------------------------------------------------------------------------------------------- -/*static*/ void INI::parseFXListDefinition(INI *ini) -{ - FXListStore::parseFXListDefinition(ini); -} diff --git a/Generals/Code/GameEngine/Source/GameClient/GameText.cpp b/Generals/Code/GameEngine/Source/GameClient/GameText.cpp deleted file mode 100644 index e0ecde33a31..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GameText.cpp +++ /dev/null @@ -1,1460 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: GameText.cpp -// -// Created: 11/07/01 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/GameText.h" -#include "Common/Language.h" -#include "Common/Registry.h" -#include "GameClient/LanguageFilter.h" -#include "Common/Debug.h" -#include "Common/UnicodeString.h" -#include "Common/AsciiString.h" -#include "Common/GlobalData.h" -#include "Common/file.h" -#include "Common/FileSystem.h" -#include "Common/version.h" - - - - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - -#if defined(RTS_DEBUG) -Bool g_useStringFile = TRUE; -#endif - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - -#define CSF_ID ( ('C'<<24) | ('S'<<16) | ('F'<<8) | (' ') ) -#define CSF_LABEL ( ('L'<<24) | ('B'<<16) | ('L'<<8) | (' ') ) -#define CSF_STRING ( ('S'<<24) | ('T'<<16) | ('R'<<8) | (' ') ) -#define CSF_STRINGWITHWAVE ( ('S'<<24) | ('T'<<16) | ('R'<<8) | ('W') ) -#define CSF_VERSION 3 - -#define STRING_FILE 0 -#define CSF_FILE 1 -#define MAX_UITEXT_LENGTH (10*1024) -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - -//=============================== -// StringInfo -//=============================== - -struct StringInfo -{ - AsciiString label; - UnicodeString text; - AsciiString speech; -}; - -struct StringLookUp -{ - AsciiString *label; - StringInfo *info; -}; - -//=============================== -// CSFHeader -//=============================== - -struct CSFHeader -{ - Int id; - Int version; - Int num_labels; - Int num_strings; - Int skip; - Int langid; - -}; - -//=============================== -// struct NoString -//=============================== - -struct NoString -{ - struct NoString *next; - UnicodeString text; -}; - - -//=============================== -// GameTextManager -//=============================== - -class GameTextManager : public GameTextInterface -{ - public: - - GameTextManager(); - virtual ~GameTextManager(); - - virtual void init( void ); ///< Initializes the text system - virtual void deinit( void ); ///< Shuts down the text system - virtual void update( void ) {}; ///< update text manager - virtual void reset( void ); ///< Resets the text system - - virtual UnicodeString fetch( const Char *label, Bool *exists = nullptr ); ///< Returns the associated labeled unicode text - virtual UnicodeString fetch( AsciiString label, Bool *exists = nullptr ); ///< Returns the associated labeled unicode text - virtual UnicodeString fetchFormat( const Char *label, ... ); - virtual UnicodeString fetchOrSubstitute( const Char *label, const WideChar *substituteText ); - virtual UnicodeString fetchOrSubstituteFormat( const Char *label, const WideChar *substituteFormat, ... ); - virtual UnicodeString fetchOrSubstituteFormatVA( const Char *label, const WideChar *substituteFormat, va_list args ); - - virtual AsciiStringVec& getStringsWithLabelPrefix(AsciiString label); - - virtual void initMapStringFile( const AsciiString& filename ); - - protected: - - Int m_textCount; - Int m_maxLabelLen; - Char m_buffer[MAX_UITEXT_LENGTH]; - Char m_buffer2[MAX_UITEXT_LENGTH]; - Char m_buffer3[MAX_UITEXT_LENGTH]; - WideChar m_tbuffer[MAX_UITEXT_LENGTH*2]; - - StringInfo *m_stringInfo; - StringLookUp *m_stringLUT; - Bool m_initialized; -#if defined(RTS_DEBUG) - Bool m_jabberWockie; - Bool m_munkee; -#endif - NoString *m_noStringList; - Int m_useStringFile; - LanguageID m_language; - UnicodeString m_failed; - - StringInfo *m_mapStringInfo; - StringLookUp *m_mapStringLUT; - Int m_mapTextCount; - - /// m_asciiStringVec will be altered every time that getStringsWithLabelPrefix is called, - /// so don't simply store a pointer to it. - AsciiStringVec m_asciiStringVec; - - void stripSpaces ( WideChar *string ); - void removeLeadingAndTrailing ( Char *m_buffer ); - void readToEndOfQuote( File *file, Char *in, Char *out, Char *wavefile, Int maxBufLen ); - void reverseWord ( Char *file, Char *lp ); - void translateCopy( WideChar *outbuf, Char *inbuf ); - Bool getStringCount( const Char *filename, Int& textCount ); - Bool getCSFInfo ( const Char *filename ); - Bool parseCSF( const Char *filename ); - Bool parseStringFile( const char *filename ); - Bool parseMapStringFile( const char *filename ); - Bool readLine( char *buffer, Int max, File *file ); - Char readChar( File *file ); -}; - -static int __cdecl compareLUT ( const void *, const void*); -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - -GameTextInterface *TheGameText = nullptr; - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - -//============================================================================ -// CreateGameTextInterface -//============================================================================ - -GameTextInterface* CreateGameTextInterface( void ) -{ - return NEW GameTextManager; -} - - -//============================================================================ -// GameTextManager::GameTextManager -//============================================================================ - -GameTextManager::GameTextManager() -: m_textCount(0), - m_maxLabelLen(0), - m_stringInfo(nullptr), - m_stringLUT(nullptr), - m_initialized(FALSE), - m_noStringList(nullptr), -#if defined(RTS_DEBUG) - m_jabberWockie(FALSE), - m_munkee(FALSE), - m_useStringFile(g_useStringFile), -#else - m_useStringFile(TRUE), -#endif - m_mapStringInfo(nullptr), - m_mapStringLUT(nullptr), - m_failed(L"***FATAL*** String Manager failed to initialize properly") -{ - for(Int i=0; i < MAX_UITEXT_LENGTH; i++) - { - m_buffer[i] = 0; - m_buffer2[i] = 0; - m_buffer3[i] = 0; - } -} - -//============================================================================ -// GameTextManager::~GameTextManager -//============================================================================ - -GameTextManager::~GameTextManager() -{ - deinit(); -} - -//============================================================================ -// GameTextManager::init -//============================================================================ - -extern const Char *g_strFile; -extern const Char *g_csfFile; - -void GameTextManager::init( void ) -{ - AsciiString csfFile; - csfFile.format(g_csfFile, GetRegistryLanguage().str()); - Int format; - - if ( m_initialized ) - { - return; - } - - m_initialized = TRUE; - - m_maxLabelLen = 0; -#if defined(RTS_DEBUG) - if(TheGlobalData) - { - m_jabberWockie = TheGlobalData->m_jabberOn; - m_munkee = TheGlobalData->m_munkeeOn; - } -#endif - - if ( m_useStringFile && getStringCount( g_strFile, m_textCount ) ) - { - format = STRING_FILE; - } - else if ( getCSFInfo ( csfFile.str() ) ) - { - format = CSF_FILE; - } - else - { - return; - } - - if( m_textCount == 0 ) - { - return; - } - - //Allocate StringInfo Array - - m_stringInfo = NEW StringInfo[m_textCount]; - - if( m_stringInfo == nullptr ) - { - deinit(); - return; - } - - if ( format == STRING_FILE ) - { - if( parseStringFile( g_strFile ) == FALSE ) - { - deinit(); - return; - } - } - else - { - if ( !parseCSF ( csfFile.str() ) ) - { - deinit(); - return; - } - } - - m_stringLUT = NEW StringLookUp[m_textCount]; - - StringLookUp *lut = m_stringLUT; - StringInfo *info = m_stringInfo; - - for ( Int i = 0; i < m_textCount; i++ ) - { - lut->info = info; - lut->label = &info->label; - lut++; - info++; - } - - qsort( m_stringLUT, m_textCount, sizeof(StringLookUp), compareLUT ); - -} - -//============================================================================ -// GameTextManager::deinit -//============================================================================ - -void GameTextManager::deinit( void ) -{ - - delete [] m_stringInfo; - m_stringInfo = nullptr; - - delete [] m_stringLUT; - m_stringLUT = nullptr; - - m_textCount = 0; - - NoString *noString = m_noStringList; - - DEBUG_LOG_RAW(("\n")); - DEBUG_LOG(("*** Missing strings ***")); - while ( noString ) - { - DEBUG_LOG(("*** %ls ***", noString->text.str())); - NoString *next = noString->next; - delete noString; - noString = next; - } - DEBUG_LOG(("*** End missing strings ***")); - DEBUG_LOG_RAW(("\n")); - - m_noStringList = nullptr; - - m_initialized = FALSE; -} - -//============================================================================ -// GameTextManager::reset -//============================================================================ - -void GameTextManager::reset( void ) -{ - delete [] m_mapStringInfo; - m_mapStringInfo = nullptr; - - delete [] m_mapStringLUT; - m_mapStringLUT = nullptr; -} - - -//============================================================================ -// GameTextManager::stripSpaces -//============================================================================ - -void GameTextManager::stripSpaces ( WideChar *string ) -{ - WideChar *str, *ptr; - WideChar ch, last = 0; - Int skipall = TRUE; - - str = ptr = string; - - while ( (ch = *ptr++) != 0 ) - { - if ( ch == ' ' ) - { - if ( last == ' ' || skipall ) - { - continue; - } - } - - if ( ch == '\n' || ch == '\t' ) - { - // remove last space - if ( last == ' ' ) - { - str--; - } - - skipall = TRUE; // skip all spaces - last = *str++ = ch; - continue; - } - - last = *str++ = ch; - skipall = FALSE; - } - - if ( last == ' ' ) - { - str--; - } - - *str = 0; -} - -//============================================================================ -// GameTextManager::removeLeadingAndTrailing -//============================================================================ - -void GameTextManager::removeLeadingAndTrailing ( Char *buffer ) -{ - Char *first, *ptr; - Char ch; - - ptr = first = buffer; - - while ( (ch = *first) != 0 && iswspace ( ch )) - { - first++; - } - - while ( (*ptr++ = *first++) != 0 ); - - ptr -= 2; - - while ( (ptr > buffer) && (ch = *ptr) != 0 && iswspace ( ch ) ) - { - ptr--; - } - - ptr++; - *ptr = 0; -} - -//============================================================================ -// GameTextManager::readToEndOfQuote -//============================================================================ - -void GameTextManager::readToEndOfQuote( File *file, Char *in, Char *out, Char *wavefile, Int maxBufLen ) -{ - Int slash = FALSE; - Int state = 0; - Int line_start = FALSE; - Char ch; - Int ccount = 0; - Int len = 0; - Int done = FALSE; - - while ( maxBufLen ) - { - // get next Char - - if ( in ) - { - if ( (ch = *in++) == 0 ) - { - in = nullptr; // have exhausted the input m_buffer - ch = readChar ( file ); - } - } - else - { - ch = readChar ( file ); - } - - if ( ch == EOF ) - { - return ; - } - - if ( ch == '\n' ) - { - line_start = TRUE; - slash = FALSE; - ccount = 0; - ch = ' '; - } - else if ( ch == '\\' && !slash) - { - slash = TRUE; - } - else if ( ch == '\\' && slash) - { - slash = FALSE; - } - else if ( ch == '"' && !slash ) - { - break; // done - } - else - { - slash = FALSE; - } - - if ( iswspace ( ch )) - { - ch = ' '; - } - - *out++ = ch; - maxBufLen--; - } - - *out = 0; - - while ( !done ) - { - // get next Char - - if ( in ) - { - if ( (ch = *in++) == 0 ) - { - in = nullptr; // have exhausted the input m_buffer - ch = readChar ( file ); - } - } - else - { - ch = readChar ( file ); - } - - if ( ch == '\n' || ch == EOF ) - { - break; - } - - switch ( state ) - { - - case 0: - if ( iswspace ( ch ) || ch == '=' ) - { - break; - } - - state = 1; - FALLTHROUGH; - case 1: - if ( ( ch >= 'a' && ch <= 'z') || ( ch >= 'A' && ch <='Z') || (ch >= '0' && ch <= '9') || ch == '_' ) - { - *wavefile++ = ch; - len++; - break; - } - state = 2; - FALLTHROUGH; - case 2: - break; - } - } - - *wavefile = 0; - - if ( len ) - { - if ( ( ch = *(wavefile-1)) >= '0' && ch <= '9' ) - { - *wavefile++ = 'e'; - *wavefile = 0; - } - } - -} - - -//============================================================================ -// GameTextManager::reverseWord -//============================================================================ - -void GameTextManager::reverseWord ( Char *file, Char *lp ) -{ - Int first = TRUE; - Char f, l; - Int ok = TRUE ; - - while ( ok ) - { - if ( file >= lp ) - { - return; - } - - f = *file; - l = *lp; - - if ( first ) - { - if ( f >= 'A' && f <= 'Z' ) - { - if ( l >= 'a' && l <= 'z' ) - { - f = (f - 'A') + 'a'; - l = (l - 'a') + 'A'; - } - } - - first = FALSE; - } - - *lp-- = f; - *file++ = l; - - } - -} - -//============================================================================ -// GameTextManager::translateCopy -//============================================================================ - -void GameTextManager::translateCopy( WideChar *outbuf, Char *inbuf ) -{ - Int slash = FALSE; - -#if defined(RTS_DEBUG) - if ( m_jabberWockie ) - { - static Char buffer[MAX_UITEXT_LENGTH*2]; - Char *firstLetter = nullptr, *lastLetter; - Char *b = buffer; - Int formatWord = FALSE; - Char ch; - - while ( (ch = *inbuf++) != 0 ) - { - if ( ! (( ch >= 'a' && ch <= 'z') || ( ch >= 'A' && ch <= 'Z' ))) - { - if ( firstLetter ) - { - if ( !formatWord ) - { - lastLetter = b-1; - reverseWord ( firstLetter, lastLetter ); - } - firstLetter = nullptr; - formatWord = FALSE; - } - *b++ = ch; - if ( ch == '\\' ) - { - *b++ = *inbuf++; - } - if ( ch == '%' ) - { - while ( (ch = *inbuf++) != 0 && !( (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))) - { - *b++ = ch; - } - *b++ = ch; - } - } - else - { - if ( !firstLetter ) - { - firstLetter = b; - } - - *b++ = ch; - - } - } - - if ( firstLetter ) - { - lastLetter = b-1; - reverseWord ( firstLetter, lastLetter ); - } - - *b++ = 0; - inbuf = buffer; - } - else if( m_munkee ) - { - wcscpy(outbuf, L"Munkee"); - return; - } -#endif - - while( *inbuf != '\0' ) - { - if( slash == TRUE ) - { - slash = FALSE; - - switch( *inbuf ) - { - // in case end of string is reached - // should never happen!!! - case '\0': - return; - - case '\\': - *outbuf++ = '\\'; - break; - - case '\'': - *outbuf++ = '\''; - break; - - case '\"': - *outbuf++ = '\"'; - break; - - case '\?': - *outbuf++ = '\?'; - break; - - case 't': - *outbuf++ = '\t'; - break; - - case 'n': - *outbuf++ = '\n'; - break; - - default: - *outbuf++ = *inbuf & 0x00FF; - break; - } - } - else if( *inbuf != '\\' ) - { - *outbuf++ = *inbuf & 0x00FF; - } - else - slash = TRUE; - - inbuf++; - } - *outbuf= 0; -} - -//============================================================================ -// GameTextManager::getStringCount -//============================================================================ - -Bool GameTextManager::getStringCount( const char *filename, Int& textCount ) -{ - Int ok = TRUE; - - textCount = 0; - - File *file; - file = TheFileSystem->openFile(filename, File::READ | File::TEXT); - DEBUG_LOG(("Looking in %s for string file", filename)); - - if ( file == nullptr ) - { - return FALSE; - } - - while(ok) - { - if( !readLine( m_buffer, sizeof( m_buffer) -1, file ) ) - break; - removeLeadingAndTrailing ( m_buffer ); - - if( m_buffer[0] == '"' ) - { - Int len = strlen(m_buffer); - m_buffer[ len ] = '\n'; - m_buffer[ len+1] = 0; - readToEndOfQuote( file, &m_buffer[1], m_buffer2, m_buffer3, MAX_UITEXT_LENGTH ); - } - else if( stricmp( m_buffer, "END") == 0 ) - { - textCount++; - } - } - - textCount += 500; - file->close(); - file = nullptr; - return TRUE; -} - -//============================================================================ -// GameTextManager::getCSFInfo -//============================================================================ - -Bool GameTextManager::getCSFInfo ( const Char *filename ) -{ - CSFHeader header; - Int ok = FALSE; - File *file = TheFileSystem->openFile(filename, File::READ | File::BINARY); - DEBUG_LOG(("Looking in %s for compiled string file", filename)); - - if ( file != nullptr ) - { - if ( file->read( &header, sizeof ( header )) == sizeof ( header ) ) - { - if ( header.id == CSF_ID ) - { - m_textCount = header.num_labels; - - if ( header.version >= 2 ) - { - m_language = (LanguageID) header.langid; - } - else - { - m_language = LANGUAGE_ID_US; - } - - ok = TRUE; - } - } - - file->close(); - file = nullptr; - } - - return ok; -} - -//============================================================================ -// GameTextManager::parseCSF -//============================================================================ - -Bool GameTextManager::parseCSF( const Char *filename ) -{ - File *file; - Int id; - Int len; - Int listCount = 0; - Bool ok = FALSE; - CSFHeader header; - - file = TheFileSystem->openFile(filename, File::READ | File::BINARY); - - if ( file == nullptr ) - { - return FALSE; - } - - if ( file->read ( &header, sizeof ( CSFHeader)) != sizeof ( CSFHeader) ) - { - return FALSE; - } - - while( file->read ( &id, sizeof (id)) == sizeof ( id) ) - { - Int num; - Int num_strings; - - if ( id != CSF_LABEL ) - { - goto quit; - } - - file->read ( &num_strings, sizeof ( Int )); - - file->read ( &len, sizeof ( Int ) ); - - if ( len ) - { - file->read ( m_buffer, len ); - } - - m_buffer[len] = 0; - - m_stringInfo[listCount].label = m_buffer; - - - if ( len > m_maxLabelLen ) - { - m_maxLabelLen = len; - } - - num = 0; - - while ( num < num_strings ) - { - file->read ( &id, sizeof ( Int ) ); - - if ( id != CSF_STRING && id != CSF_STRINGWITHWAVE ) - { - goto quit; - } - - file->read ( &len, sizeof ( Int ) ); - - if ( len ) - { - file->read ( m_tbuffer, len*sizeof(WideChar) ); - } - - if ( num == 0 ) - { - // only use the first string found - m_tbuffer[len] = 0; - - { - WideChar *ptr; - - ptr = m_tbuffer; - - while ( *ptr ) - { - *ptr = ~*ptr; - ptr++; - } - } - - stripSpaces ( m_tbuffer ); - m_stringInfo[listCount].text = m_tbuffer; - } - - if ( id == CSF_STRINGWITHWAVE ) - { - file->read ( &len, sizeof ( Int ) ); - if ( len ) - { - file->read ( m_buffer, len ); - } - m_buffer[len] = 0; - - if ( num == 0 && len ) - { - // only use the first string found - m_stringInfo[listCount].speech = m_buffer; - } - - } - - num++; - } - - listCount++; - } - - ok = TRUE; - -quit: - - file->close(); - file = nullptr; - - return ok; -} - - -//============================================================================ -// GameTextManager::parseStringFile -//============================================================================ - -Bool GameTextManager::parseStringFile( const char *filename ) -{ - Int listCount = 0; - Int ok = TRUE; - - File *file = TheFileSystem->openFile(filename, File::READ | File::TEXT); - - if ( file == nullptr ) - { - return FALSE; - } - - while( ok ) - { - Int len; - if( !readLine( m_buffer, MAX_UITEXT_LENGTH, file )) - { - break; - } - - removeLeadingAndTrailing ( m_buffer ); - - if( ( *(unsigned short *)m_buffer == 0x2F2F) || !m_buffer[0]) // 0x2F2F is Hex for // - continue; - - // make sure label is unique - - for ( Int i = 0; i < listCount; i++ ) - { - if ( stricmp ( m_stringInfo[i].label.str(), m_buffer ) == 0) - { - DEBUG_ASSERTCRASH ( FALSE, ("String label '%s' multiply defined!", m_buffer )); - } - } - - m_stringInfo[listCount].label = m_buffer; - len = strlen ( m_buffer ); - - - if ( len > m_maxLabelLen ) - { - m_maxLabelLen = len; - } - - Bool readString = FALSE; - while( ok ) - { - if (!readLine ( m_buffer, sizeof(m_buffer)-1, file )) - { - DEBUG_ASSERTCRASH (FALSE, ("Unexpected end of string file")); - ok = FALSE; - goto quit; - } - - removeLeadingAndTrailing ( m_buffer ); - - if( m_buffer[0] == '"' ) - { - len = strlen(m_buffer); - m_buffer[ len ] = '\n'; - m_buffer[ len+1] = 0; - readToEndOfQuote( file, &m_buffer[1], m_buffer2, m_buffer3, MAX_UITEXT_LENGTH ); - - - if ( readString ) - { - // only one string per label allows - DEBUG_ASSERTCRASH ( FALSE, ("String label '%s' has more than one string defined!", m_stringInfo[listCount].label.str())); - } - else - { - // Copy string into new home - translateCopy( m_tbuffer, m_buffer2 ); - stripSpaces ( m_tbuffer ); - - m_stringInfo[listCount].text = m_tbuffer ; - m_stringInfo[listCount].speech = m_buffer3; - readString = TRUE; - } - } - else if ( stricmp ( m_buffer, "END" ) == 0) - { - break; - } - } - - listCount++; - } - -quit: - - file->close(); - file = nullptr; - - return ok; -} - -//============================================================================ -// GameTextManager::initMapStringFile -//============================================================================ - -void GameTextManager::initMapStringFile( const AsciiString& filename ) -{ - m_mapTextCount = 0; - getStringCount( filename.str(), m_mapTextCount ); - - m_mapStringInfo = NEW StringInfo[m_mapTextCount]; - - parseMapStringFile( filename.str() ); - - m_mapStringLUT = NEW StringLookUp[m_mapTextCount]; - - StringLookUp *lut = m_mapStringLUT; - StringInfo *info = m_mapStringInfo; - - for ( Int i = 0; i < m_mapTextCount; i++ ) - { - lut->info = info; - lut->label = &info->label; - lut++; - info++; - } - - qsort( m_mapStringLUT, m_mapTextCount, sizeof(StringLookUp), compareLUT ); -} - -//============================================================================ -// GameTextManager::parseMapStringFile -//============================================================================ - -Bool GameTextManager::parseMapStringFile( const char *filename ) -{ - Int listCount = 0; - Int ok = TRUE; - - File *file; - - file = TheFileSystem->openFile(filename, File::READ | File::TEXT); - if ( file == nullptr ) - { - return FALSE; - } - - while( ok ) - { - Int len; - if( !readLine( m_buffer, MAX_UITEXT_LENGTH, file )) - { - break; - } - - removeLeadingAndTrailing ( m_buffer ); - - if( ( *(unsigned short *)m_buffer == 0x2F2F) || !m_buffer[0]) // 0x2F2F is Hex for // - continue; - - // make sure label is unique - - for ( Int i = 0; i < listCount; i++ ) - { - if ( stricmp ( m_mapStringInfo[i].label.str(), m_buffer ) == 0) - { - DEBUG_ASSERTCRASH ( FALSE, ("String label '%s' multiply defined!", m_buffer )); - } - } - - m_mapStringInfo[listCount].label = m_buffer; - len = strlen ( m_buffer ); - - - if ( len > m_maxLabelLen ) - { - m_maxLabelLen = len; - } - - Bool readString = FALSE; - while( ok ) - { - if (!readLine ( m_buffer, sizeof(m_buffer)-1, file )) - { - DEBUG_ASSERTCRASH (FALSE, ("Unexpected end of string file")); - ok = FALSE; - goto quit; - } - - removeLeadingAndTrailing ( m_buffer ); - - if( m_buffer[0] == '"' ) - { - len = strlen(m_buffer); - m_buffer[ len ] = '\n'; - m_buffer[ len+1] = 0; - readToEndOfQuote( file, &m_buffer[1], m_buffer2, m_buffer3, MAX_UITEXT_LENGTH ); - - - if ( readString ) - { - // only one string per label allowed - DEBUG_ASSERTCRASH ( FALSE, ("String label '%s' has more than one string defined!", m_stringInfo[listCount].label.str())); - } - else - { - // Copy string into new home - translateCopy( m_tbuffer, m_buffer2 ); - stripSpaces ( m_tbuffer ); - - UnicodeString text = UnicodeString(m_tbuffer); - if (TheLanguageFilter) - TheLanguageFilter->filterLine(text); - - m_mapStringInfo[listCount].text = text; - m_mapStringInfo[listCount].speech = m_buffer3; - readString = TRUE; - } - } - else if ( stricmp ( m_buffer, "END" ) == 0) - { - break; - } - } - - listCount++; - } - -quit: - - file->close(); - file = nullptr; - - return ok; -} - -//============================================================================ -// *GameTextManager::fetch -//============================================================================ - -UnicodeString GameTextManager::fetch( const Char *label, Bool *exists ) -{ - DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); - - if( m_stringInfo == nullptr ) - { - if( exists ) - *exists = FALSE; - return m_failed; - } - - StringLookUp *lookUp; - StringLookUp key; - AsciiString lb; - lb = label; - key.info = nullptr; - key.label = &lb; - - lookUp = (StringLookUp *) bsearch( &key, (void*) m_stringLUT, m_textCount, sizeof(StringLookUp), compareLUT ); - - if ( lookUp == nullptr && m_mapStringLUT && m_mapTextCount ) - { - lookUp = (StringLookUp *) bsearch( &key, (void*) m_mapStringLUT, m_mapTextCount, sizeof(StringLookUp), compareLUT ); - } - - if( lookUp == nullptr ) - { - - // string not found - if( exists ) - *exists = FALSE; - - // See if we already have the missing string - UnicodeString missingString; - missingString.format(L"MISSING: '%hs'", label); - - NoString *noString = m_noStringList; - - while ( noString ) - { - if (noString->text == missingString) - return missingString; - - noString = noString->next; - } - - //DEBUG_LOG(("*** MISSING:'%s' ***", label)); - // Remember file could have been altered at this point. - noString = NEW NoString; - noString->text = missingString; - noString->next = m_noStringList; - m_noStringList = noString; - return noString->text; - } - if( exists ) - *exists = TRUE; - return lookUp->info->text; -} - -//============================================================================ -// *GameTextManager::fetch -//============================================================================ - -UnicodeString GameTextManager::fetch( AsciiString label, Bool *exists ) -{ - return fetch(label.str(), exists); -} - -//============================================================================ -// *GameTextManager::fetchFormat -//============================================================================ - -UnicodeString GameTextManager::fetchFormat( const Char *label, ... ) -{ - Bool exists; - UnicodeString str = fetch(label, &exists); - if (exists) - { - UnicodeString strFormat; - - va_list args; - va_start(args, label); - strFormat.format_va(str.str(), args); - va_end(args); - - str = strFormat; - } - return str; -} - -//============================================================================ -// GameTextManager::fetchOrSubstitute -//============================================================================ - -UnicodeString GameTextManager::fetchOrSubstitute( const Char *label, const WideChar *substituteText ) -{ - Bool exists; - UnicodeString str = fetch(label, &exists); - if (!exists) - str = substituteText; - return str; -} - -//============================================================================ -// GameTextManager::fetchOrSubstituteFormat -//============================================================================ - -UnicodeString GameTextManager::fetchOrSubstituteFormat( const Char *label, const WideChar *substituteFormat, ... ) -{ - va_list args; - va_start(args, substituteFormat); - UnicodeString str = fetchOrSubstituteFormatVA(label, substituteFormat, args); - va_end(args); - - return str; -} - -//============================================================================ -// GameTextManager::fetchOrSubstituteFormatVA -//============================================================================ - -UnicodeString GameTextManager::fetchOrSubstituteFormatVA( const Char *label, const WideChar *substituteFormat, va_list args ) -{ - Bool exists; - UnicodeString str = fetch(label, &exists); - if (exists) - { - UnicodeString strFormat; - strFormat.format_va(strFormat.str(), args); - str = strFormat; - } - else - { - str.format_va(substituteFormat, args); - } - - return str; -} - -//============================================================================ -// GameTextManager::getStringsWithLabelPrefix -//============================================================================ - -AsciiStringVec& GameTextManager::getStringsWithLabelPrefix(AsciiString label) -{ - m_asciiStringVec.clear(); - if (m_stringLUT) { - for (int i = 0; i < m_textCount; ++i) { - if (strstr(m_stringLUT[i].label->str(), label.str()) == m_stringLUT[i].label->str()) { - m_asciiStringVec.push_back(*m_stringLUT[i].label); - } - } - } - if (m_mapStringLUT) { - for (int i = 0; i < m_mapTextCount; ++i) { - if (strstr(m_mapStringLUT[i].label->str(), label.str()) == m_mapStringLUT[i].label->str()) { - m_asciiStringVec.push_back(*m_mapStringLUT[i].label); - } - } - } - return m_asciiStringVec; -} - -//============================================================================ -// GameTextManager::readLine -//============================================================================ - -Bool GameTextManager::readLine( char *buffer, Int max, File *file ) -{ - Int ok = FALSE; - - while ( max && file->read( buffer, 1 ) == 1 ) - { - ok = TRUE; - - if ( *buffer == '\n' ) - { - break; - } - - buffer++; - max--; - } - - *buffer = 0; - - return ok; -} - -//============================================================================ -// GameTextManager::readChar -//============================================================================ - -Char GameTextManager::readChar( File *file ) -{ - Char ch; - - if ( file->read( &ch, 1 ) == 1 ) - { - return ch; - } - - return 0; -} - -//============================================================================ -// compareLUT -//============================================================================ - -static int __cdecl compareLUT ( const void *i1, const void*i2) -{ - StringLookUp *lut1 = (StringLookUp*) i1; - StringLookUp *lut2 = (StringLookUp*) i2; - - return stricmp( lut1->label->str(), lut2->label->str()); -} diff --git a/Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp b/Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp deleted file mode 100644 index 63322480af8..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/GlobalLanguage.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GlobalLanguage.cpp ///////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Aug 2002 -// -// Filename: GlobalLanguage.cpp -// -// author: Chris Huybregts -// -// purpose: Contains the member functions for the language munkee -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------- -// SYSTEM INCLUDES //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "PreRTS.h" - -#include "Common/AddonCompat.h" -#include "Common/INI.h" -#include "Common/Registry.h" -#include "Common/FileSystem.h" -#include "Common/UserPreferences.h" - -#include "GameClient/Display.h" -#include "GameClient/GlobalLanguage.h" - -//----------------------------------------------------------------------------- -// DEFINES //////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -GlobalLanguage *TheGlobalLanguageData = nullptr; ///< The global language singleton - -static const LookupListRec ResolutionFontSizeMethodNames[] = -{ - { "CLASSIC", GlobalLanguage::ResolutionFontSizeMethod_Classic }, - { "CLASSIC_NO_CEILING", GlobalLanguage::ResolutionFontSizeMethod_ClassicNoCeiling }, - { "STRICT", GlobalLanguage::ResolutionFontSizeMethod_Strict }, - { "BALANCED", GlobalLanguage::ResolutionFontSizeMethod_Balanced }, - { nullptr, 0 } -}; - -static const FieldParse TheGlobalLanguageDataFieldParseTable[] = -{ - { "UnicodeFontName", INI::parseAsciiString,nullptr, offsetof( GlobalLanguage, m_unicodeFontName ) }, - //{ "UnicodeFontFileName", INI::parseAsciiString,nullptr, offsetof( GlobalLanguage, m_unicodeFontFileName ) }, - { "LocalFontFile", GlobalLanguage::parseFontFileName, nullptr, 0}, - { "MilitaryCaptionSpeed", INI::parseInt, nullptr, offsetof( GlobalLanguage, m_militaryCaptionSpeed ) }, - { "UseHardWordWrap", INI::parseBool, nullptr, offsetof( GlobalLanguage, m_useHardWrap) }, - { "ResolutionFontAdjustment", INI::parseReal, nullptr, offsetof( GlobalLanguage, m_resolutionFontSizeAdjustment) }, - { "ResolutionFontSizeMethod", INI::parseLookupList, ResolutionFontSizeMethodNames, offsetof( GlobalLanguage, m_resolutionFontSizeMethod) }, - { "CopyrightFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_copyrightFont ) }, - { "MessageFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_messageFont) }, - { "MilitaryCaptionTitleFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_militaryCaptionTitleFont) }, - { "MilitaryCaptionFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_militaryCaptionFont) }, - { "SuperweaponCountdownNormalFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_superweaponCountdownNormalFont) }, - { "SuperweaponCountdownReadyFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_superweaponCountdownReadyFont) }, - { "NamedTimerCountdownNormalFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_namedTimerCountdownNormalFont) }, - { "NamedTimerCountdownReadyFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_namedTimerCountdownReadyFont) }, - { "DrawableCaptionFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_drawableCaptionFont) }, - { "DefaultWindowFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_defaultWindowFont) }, - { "DefaultDisplayStringFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_defaultDisplayStringFont) }, - { "TooltipFontName", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_tooltipFontName) }, - { "NativeDebugDisplay", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_nativeDebugDisplay) }, - { "DrawGroupInfoFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_drawGroupInfoFont) }, - { "CreditsTitleFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_creditsTitleFont) }, - { "CreditsMinorTitleFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_creditsPositionFont) }, - { "CreditsNormalFont", GlobalLanguage::parseFontDesc, nullptr, offsetof( GlobalLanguage, m_creditsNormalFont) }, - - { nullptr, nullptr, nullptr, 0 } -}; - -//----------------------------------------------------------------------------- -// PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -void INI::parseLanguageDefinition( INI *ini ) -{ - if( !TheGlobalLanguageData ) - { - DEBUG_ASSERTCRASH(TheGlobalLanguageData, ("INI::parseLanguageDefinition - TheGlobalLanguage Data is not around, please create it before trying to parse the ini file.")); - return; - } - // parse the ini weapon definition - ini->initFromINI( TheGlobalLanguageData, TheGlobalLanguageDataFieldParseTable ); -} - -GlobalLanguage::GlobalLanguage() -{ - m_unicodeFontName.clear(); - m_unicodeFontFileName.clear(); - m_unicodeFontName.clear(); - m_militaryCaptionSpeed = 0; - m_useHardWrap = FALSE; - m_resolutionFontSizeAdjustment = 0.7f; - m_resolutionFontSizeMethod = ResolutionFontSizeMethod_Default; - - m_userResolutionFontSizeAdjustment = -1.0f; -} - -GlobalLanguage::~GlobalLanguage() -{ - StringListIt it = m_localFonts.begin(); - while( it != m_localFonts.end()) - { - AsciiString font = *it; - RemoveFontResource(font.str()); - //SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0); - ++it; - } -} - -void GlobalLanguage::init( void ) -{ - { - AsciiString fname; - fname.format("Data\\%s\\Language", GetRegistryLanguage().str()); - - INI ini; - ini.loadFileDirectory( fname, INI_LOAD_OVERWRITE, nullptr ); - } - - StringListIt it = m_localFonts.begin(); - while( it != m_localFonts.end()) - { - AsciiString font = *it; - if(AddFontResource(font.str()) == 0) - { - DEBUG_ASSERTCRASH(FALSE,("GlobalLanguage::init Failed to add font %s", font.str())); - } - else - { - //SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0); - } - ++it; - } - - // override values with user preferences - OptionPreferences optionPref; - m_userResolutionFontSizeAdjustment = optionPref.getResolutionFontAdjustment(); - -} -void GlobalLanguage::reset( void ) {} - - -void GlobalLanguage::parseFontDesc(INI *ini, void *instance, void *store, const void* userData) -{ - FontDesc *fontDesc = (FontDesc *)store; - fontDesc->name = ini->getNextQuotedAsciiString(); - fontDesc->size = ini->scanInt(ini->getNextToken()); - fontDesc->bold = ini->scanBool(ini->getNextToken()); -} - -void GlobalLanguage::parseFontFileName( INI *ini, void * instance, void *store, const void* userData ) -{ - GlobalLanguage *monkey = (GlobalLanguage *)instance; - AsciiString asciiString = ini->getNextAsciiString(); - monkey->m_localFonts.push_front(asciiString); -} - -float GlobalLanguage::getResolutionFontSizeAdjustment( void ) const -{ - if (m_userResolutionFontSizeAdjustment >= 0.0f) - return m_userResolutionFontSizeAdjustment; - else - return m_resolutionFontSizeAdjustment; -} - -Int GlobalLanguage::adjustFontSize(Int theFontSize) -{ - // TheSuperHackers @todo This function is called very often. - // Therefore cache the adjustFactor on resolution change to not recompute it on every call. - Real adjustFactor; - - switch (m_resolutionFontSizeMethod) - { - default: - case ResolutionFontSizeMethod_Classic: - { - // TheSuperHackers @info The original font scaling for this game. - // Useful for not breaking legacy Addons and Mods. Scales poorly with large resolutions. - adjustFactor = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH; - adjustFactor = 1.0f + (adjustFactor - 1.0f) * getResolutionFontSizeAdjustment(); - if (adjustFactor > 2.0f) - adjustFactor = 2.0f; - break; - } - case ResolutionFontSizeMethod_ClassicNoCeiling: - { - // TheSuperHackers @feature The original font scaling, but without ceiling. - // Useful for not changing the original look of the game. Scales alright with large resolutions. - adjustFactor = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH; - adjustFactor = 1.0f + (adjustFactor - 1.0f) * getResolutionFontSizeAdjustment(); - break; - } - case ResolutionFontSizeMethod_Strict: - { - // TheSuperHackers @feature The strict method scales fonts based on the smallest screen - // dimension so they scale independent of aspect ratio. - const Real wScale = TheDisplay->getWidth() / (Real)DEFAULT_DISPLAY_WIDTH; - const Real hScale = TheDisplay->getHeight() / (Real)DEFAULT_DISPLAY_HEIGHT; - adjustFactor = min(wScale, hScale); - adjustFactor = 1.0f + (adjustFactor - 1.0f) * getResolutionFontSizeAdjustment(); - break; - } - case ResolutionFontSizeMethod_Balanced: - { - // TheSuperHackers @feature The balanced method evenly weighs the display width and height - // for a balanced rescale on non 4:3 resolutions. The aspect ratio scaling is clamped to - // prevent oversizing. - constexpr const Real maxAspect = 1.8f; - constexpr const Real minAspect = 1.0f; - Real w = TheDisplay->getWidth(); - Real h = TheDisplay->getHeight(); - const Real aspect = w / h; - Real wScale = w / (Real)DEFAULT_DISPLAY_WIDTH; - Real hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT; - - if (aspect > maxAspect) - { - // Recompute width at max aspect - w = maxAspect * h; - wScale = w / (Real)DEFAULT_DISPLAY_WIDTH; - } - else if (aspect < minAspect) - { - // Recompute height at min aspect - h = minAspect * w; - hScale = h / (Real)DEFAULT_DISPLAY_HEIGHT; - } - adjustFactor = (wScale + hScale) * 0.5f; - adjustFactor = 1.0f + (adjustFactor - 1.0f) * getResolutionFontSizeAdjustment(); - break; - } - } - - if (adjustFactor < 1.0f) - adjustFactor = 1.0f; - Int pointSize = REAL_TO_INT_FLOOR(theFontSize*adjustFactor); - return pointSize; -} - -void GlobalLanguage::parseCustomDefinition() -{ - if (addon::HasFullviewportDat()) - { - // TheSuperHackers @tweak xezon 19/08/2025 Force the classic font size adjustment for the old - // 'Control Bar Pro' Addons because they use manual font upscaling in higher resolution packages. - m_resolutionFontSizeMethod = ResolutionFontSizeMethod_Classic; - } -} - -FontDesc::FontDesc(void) -{ - name = "Arial Unicode MS"; ///. -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: GraphDraw.cpp //////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Electronic Arts Pacific. -// -// Confidential Information -// Copyright (C) 2002 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// created: Aug 2002 -// -// Filename: GraphDraw.cpp -// -// author: John McDonald -// -// purpose: Contains the functions to queue up and display a single graph for -// each frame -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" -#include "GameClient/GraphDraw.h" - -#include "GameClient/Display.h" -#include "GameClient/DisplayString.h" -#include "GameClient/DisplayStringManager.h" - -#ifdef PERF_TIMERS - -//------------------------------------------------------------------------------------------------- -GraphDraw::GraphDraw() -{ - for (Int i = 0; i < MAX_GRAPH_VALUES; ++i) { - m_displayStrings[i] = TheDisplayStringManager->newDisplayString(); - m_displayStrings[i]->setFont(TheFontLibrary->getFont("Courier", 10, false)); - } -} - -//------------------------------------------------------------------------------------------------- -GraphDraw::~GraphDraw() -{ - for (Int i = 0; i < MAX_GRAPH_VALUES; ++i) { - TheDisplayStringManager->freeDisplayString(m_displayStrings[i]); - } -} - -//------------------------------------------------------------------------------------------------- -void GraphDraw::addEntry(AsciiString str, Real val) -{ - m_graphEntries.push_back(std::make_pair(str, val)); -} - -//------------------------------------------------------------------------------------------------- -void GraphDraw::render() -{ - Int width = TheDisplay->getWidth(); - - // divide the width by two because we're going to use the left half of the screen for labels. - //width /= 2; - - // give more to bars than labels. (srj) - Int start = width * 0.33f; - width -= start; - - Int height = TheDisplay->getHeight(); - - Int totalCount = m_graphEntries.size(); - DEBUG_ASSERTCRASH(totalCount < MAX_GRAPH_VALUES, ("MAX_GRAPH_VALUES must be increased, not all labels will appear (max %d, cur %d).",MAX_GRAPH_VALUES,totalCount)); - DEBUG_ASSERTCRASH(BAR_HEIGHT * totalCount < height, ("BAR_HEIGHT must be reduced, as bars are being drawn off-screen.")); - VecGraphEntriesIt it; - - Int count = 0; - for (it = m_graphEntries.begin(); it != m_graphEntries.end(); ++it) { - - if (count < MAX_GRAPH_VALUES) { - // draw the label. - UnicodeString uniStr; - uniStr.translate(it->first); - - m_displayStrings[count]->setText(uniStr); - m_displayStrings[count]->draw(5, count * BAR_HEIGHT, 0xFFFFFFFF, 0x00000000, 1, 1); - } - - TheDisplay->drawFillRect(start, count * BAR_HEIGHT - (BAR_SPACE / 2), it->second / 100000.0f * width, BAR_HEIGHT - BAR_SPACE, 0x7FFFFFFF); - - ++count; - } -} - -//------------------------------------------------------------------------------------------------- -void GraphDraw::clear() -{ - m_graphEntries.clear(); -} - -GraphDraw *TheGraphDraw = nullptr; - -#endif /* PERF_TIMERS */ diff --git a/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp b/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp deleted file mode 100644 index f2e0af373ad..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/LanguageFilter.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/LanguageFilter.h" -#include "Common/FileSystem.h" -#include "Common/file.h" - - - -LanguageFilter *TheLanguageFilter = nullptr; - -LanguageFilter::LanguageFilter() -{ -} - -LanguageFilter::~LanguageFilter() { - m_wordList.clear(); -} - -void LanguageFilter::init() { - m_wordList.clear(); - - // read in the file already. - File *file1 = TheFileSystem->openFile(BadWordFileName, File::READ | File::BINARY); - if (file1 == nullptr) { - return; - } - - wchar_t word[128]; - while (readWord(file1, word)) { - Int wordLen = wcslen(word); - if (wordLen == 0) { - continue; - } - for (Int i = 0; i < wordLen; ++i) { - word[i] = word[i] ^ LANGUAGE_XOR_KEY; - } - UnicodeString uniword(word); - unHaxor(uniword); - //DEBUG_LOG(("Just read %ls from the bad word file. Entered as %ls", word, uniword.str())); - m_wordList[uniword] = true; - } - - file1->close(); - file1 = nullptr; -} - -void LanguageFilter::reset() { - init(); -} - -void LanguageFilter::update() { -} - -wchar_t ignoredChars[] = L"-_*'\""; - -void LanguageFilter::filterLine(UnicodeString &line) -{ - WideChar *buf = NEW WideChar[line.getLength()+1]; - wcscpy(buf, line.str()); - - UnicodeString newLine(line); - UnicodeString token; - - while (newLine.nextToken(&token, L" ;,.!?:=\\/><`~()&^%#\n\t")) { - wchar_t *pos = wcsstr(buf, token.str()); - if (pos == nullptr) { - DEBUG_CRASH(("Couldn't find the token in its own string.")); - continue; - } - - Int len = token.getLength(); // need to get the length of the original word, not the unhaxor'd word. - - unHaxor(token); - LangMapIter iter = m_wordList.find(token); - if (iter != m_wordList.end()) { - DEBUG_LOG(("Found word %ls in bad word list. Token was %ls", (*iter).first.str(), token.str())); - for (Int i = 0; i < len; ++i) { - *pos = L'*'; - ++pos; - } - } - } - - line.set(buf); - delete[] buf; -} - -void LanguageFilter::unHaxor(UnicodeString &word) { - Int len = word.getLength(); - UnicodeString newWord; - for (Int i = 0; i < len; ++i) { - wchar_t c = word.getCharAt(i); - if ((c == L'p') || (c == L'P')) { - if (((i + 1) < len) && ((word.getCharAt(i+1) == L'h') || (word.getCharAt(i+1) == L'H'))) { - newWord.concat(L'f'); - ++i; // skip the h - } else { - // not a problem at all. - newWord.concat(c); - } - } else if (c == L'1') { - newWord.concat(L'l'); - } else if (c == L'3') { - newWord.concat(L'e'); - } else if (c == L'4') { - newWord.concat(L'a'); - } else if (c == L'5') { - newWord.concat(L's'); - } else if (c == L'6') { - newWord.concat(L'b'); - } else if (c == L'7') { - newWord.concat(L't'); - } else if (c == L'0') { - newWord.concat(L'o'); - } else if (c == L'@') { - newWord.concat(L'a'); - } else if (c == L'$') { - newWord.concat(L's'); - } else if (c == L'+') { - newWord.concat(L't'); - } else if (wcsrchr(ignoredChars, c) == nullptr) { - newWord.concat(c); - } - } - word.set(newWord); -} - -// returning true means that there are more words in the file. -Bool LanguageFilter::readWord(File *file1, WideChar *buf) { - Int index = 0; - Bool retval = TRUE; - Int val = 0; - - WideChar c; - - val = file1->read(&c, sizeof(WideChar)); - if ((val == -1) || (val == 0)) { - buf[index] = 0; - return FALSE; - } - buf[index] = c; - - while (buf[index] != L' ') { - ++index; - val = file1->read(&c, sizeof(WideChar)); - if ((val == -1) || (val == 0)) { - c = WEOF; - } - - if ((c == WEOF) || (c == L' ')) { - buf[index] = 0; - if (c == WEOF) { - retval = FALSE; - } - break; - } - buf[index] = c; - } - return retval; -} - -LanguageFilter * createLanguageFilter() -{ - return NEW LanguageFilter; -} diff --git a/Generals/Code/GameEngine/Source/GameClient/Line2D.cpp b/Generals/Code/GameEngine/Source/GameClient/Line2D.cpp deleted file mode 100644 index 30e558df9dc..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/Line2D.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Line2D.cpp /////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, January 2002 -// Desc: Some helpful 2D stuff -/////////////////////////////////////////////////////////////////////////////////////////////////// - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "Lib/BaseType.h" -#include "GameClient/Line2D.h" - -// PRIVATE //////////////////////////////////////////////////////////////////////////////////////// -#define CLIP_LEFT 0x01 -#define CLIP_RIGHT 0x02 -#define CLIP_BOTTOM 0x04 -#define CLIP_TOP 0x08 - -// PUBLIC ///////////////////////////////////////////////////////////////////////////////////////// - - -// STATIC ///////////////////////////////////////////////////////////////////////////////////////// -const static Coord2D reallyFarPoint = { 1000000.0, 1000000.0 }; - -//------------------------------------------------------------------------------------------------- -/** Clip a line to the region provided. The source line runs from p1 to p2, and is clipped - * using the clipRegion. The resulting line goes from c1 to c2 - * - * Return values: - * TRUE - Line is visible - * FALSE - Line is not visible - */ -//------------------------------------------------------------------------------------------------- -Bool ClipLine2D( ICoord2D *p1, ICoord2D *p2, ICoord2D *c1, ICoord2D *c2, - IRegion2D *clipRegion ) -{ - Int x1, y1, x2, y2; - Int clipLeft; - Int clipRight; - Int clipTop; - Int clipBottom; - Int clipCode1; - Int clipCode2; - Int diff; - - // Use clip window that includes bottom right pixel - clipLeft = clipRegion->lo.x; - clipRight = clipRegion->hi.x; - clipTop = clipRegion->lo.y; - clipBottom = clipRegion->hi.y; -/* - clipLeft = gfxCurrentContext->clipRect1.left; - clipRight = gfxCurrentContext->clipRect1.right; - clipTop = gfxCurrentContext->clipRect1.top; - clipBottom = gfxCurrentContext->clipRect1.bottom; - - x1 = *px1; - y1 = *py1; - x2 = *px2; - y2 = *py2; -*/ - - x1 = p1->x; - y1 = p1->y; - x2 = p2->x; - y2 = p2->y; - - // Test first point - clipCode1 = 0; - - if (x1 < clipLeft) - clipCode1 = CLIP_LEFT; - else - if (x1 > clipRight) - clipCode1 = CLIP_RIGHT; - - if (y1 < clipTop) - clipCode1 |= CLIP_TOP; - else - if (y1 > clipBottom) - clipCode1 |= CLIP_BOTTOM; - - - // Test second point - clipCode2 = 0; - - if (x2 < clipLeft) - clipCode2 = CLIP_LEFT; - else - if (x2 > clipRight) - clipCode2 = CLIP_RIGHT; - - if (y2 < clipTop) - clipCode2 |= CLIP_TOP; - else - if (y2 > clipBottom) - clipCode2 |= CLIP_BOTTOM; - - - // Both points inside window? - if ((clipCode1 | clipCode2) == 0) - { - - *c1 = *p1; - *c2 = *p2; - return TRUE; - - } - - // Both points outside window? - if (clipCode1 & clipCode2) - return FALSE; - - // First point outside window? - if (clipCode1) - { - if (clipCode1 & CLIP_TOP) - { - if ((diff = (y2 - y1)) == 0) - return FALSE; - x1 += (x2 - x1) * (clipTop - y1) / diff; - y1 = clipTop; - } - else - if (clipCode1 & CLIP_BOTTOM) - { - if ((diff = (y2 - y1)) == 0) - return FALSE; - x1 += (x2 - x1) * (clipBottom - y1) / diff; - y1 = clipBottom; - } - - if (x1 > clipRight) - { - if ((diff = (x2 - x1)) == 0) - return FALSE; - y1 += (y2 - y1) * (clipRight - x1) / diff; - x1 = clipRight; - } - else - if (x1 < clipLeft) - { - if ((diff = (x2 - x1)) == 0) - return FALSE; - y1 += (y2 - y1) * (clipLeft - x1) / diff; - x1 = clipLeft; - } - } - - // Second point outside window? - if (clipCode2) - { - if (clipCode2 & CLIP_TOP) - { - if ((diff = (y2 - y1)) == 0) - return FALSE; - x2 += (x2 - x1) * (clipTop - y2) / diff; - y2 = clipTop; - } - else - if (clipCode2 & CLIP_BOTTOM) - { - if ((diff = (y2 - y1)) == 0) - return FALSE; - x2 += (x2 - x1) * (clipBottom - y2) / diff; - y2 = clipBottom; - } - - if (x2 > clipRight) - { - if ((diff = (x2 - x1)) == 0) - return FALSE; - y2 += (y2 - y1) * (clipRight - x2) / diff; - x2 = clipRight; - } - else - if (x2 < clipLeft) - { - if ((diff = (x2 - x1)) == 0) - return FALSE; - y2 += (y2 - y1) * (clipLeft - x2) / diff; - x2 = clipLeft; - } - } - - c1->x = x1; - c1->y = y1; - c2->x = x2; - c2->y = y2; - -/* - *px1 = x1; - *py1 = y1; - *px2 = x2; - *py2 = y2; -*/ - - // Line is visible - return (x1 >= clipLeft && x1 <= clipRight && - y1 >= clipTop && y1 <= clipBottom && - x2 >= clipLeft && x2 <= clipRight && - y2 >= clipTop && y2 <= clipBottom); - -} - - -// This solution uses the -// http://www.faqs.org/faqs/graphics/algorithms-faq/ -// Subject 1.03 -Bool IntersectLine2D( const Coord2D *a, const Coord2D *b, - const Coord2D *c, const Coord2D *d, - Coord2D *intersection) -{ - if (!a || !b || !c || !d) { - // sanity. Lines that do not have endpoints do not intersect. - return false; - } - - Real r, s, denom; - - denom = ((b->x - a->x) * (d->y - c->y) - (b->y - a->y) * (d->x - c->x)); - if (denom == 0) { - // the lines are parallel. - return false; - } - - r = ((a->y - c->y) * (d->x - c->x) - (a->x - c->x) * (d->y - c->y) ) / denom; - s = ((a->y - c->y) * (b->x - a->x) - (a->x - c->x) * (b->y - a->y) ) / denom; - - if (0 <= r && r <= 1 && 0 <= s && s <= 1) { - // The lines intersect. - if (intersection) { - intersection->x = a->x + r * (b->x - a->x); - intersection->y = a->y + r * (b->y - a->y); - } - - return true; - } - - return false; -} - -// determines whether a point lies within a rectangle. Doesn't determine whether the shape is -// actually a rectangle or not. -Bool PointInsideRect2D(const Coord2D *bl, const Coord2D *tl, const Coord2D *br, const Coord2D *tr, - const Coord2D *inputPoint) -{ - if (!(bl && br && tl && tr && inputPoint)) { - return FALSE; - } - - Real uVal; - // we're actually only interested in if the U value is (0,1) - ShortestDistancePointToSegment2D(bl, tl, inputPoint, nullptr, nullptr, &uVal); - if (uVal <= 0.0f || uVal >= 1.0f) { - return false; - } - - ShortestDistancePointToSegment2D(bl, br, inputPoint, nullptr, nullptr, &uVal); - - return (uVal > 0.0f && uVal < 1.0f); -} - -// convenience. Just prunes out the Z coordinate for a call to PointInsideRect2D -Bool PointInsideRect3D(const Coord3D *bl, const Coord3D *tl, const Coord3D *br, const Coord3D *tr, - const Coord3D *inputPoint) -{ - Coord2D bl2d, tl2d, br2d, tr2d, pt; - bl2d.x = bl->x; - bl2d.y = bl->y; - tl2d.x = tl->x; - tl2d.y = tl->y; - br2d.x = br->x; - br2d.y = br->y; - tr2d.x = tr->x; - tr2d.y = tr->y; - - pt.x = inputPoint->x; - pt.y = inputPoint->y; - - return PointInsideRect2D(&bl2d, &br2d, &tl2d, &tr2d, &pt); -} - - -// This function uses even-odd winding to determine whether a point is inside an area. -Bool PointInsideArea2D(const Coord2D *ptToTest, const Coord2D *area, const Int numPointsInArea) -{ - int numIntersections = 0; - for (int i = 0; i < numPointsInArea; ++i) { - if (IntersectLine2D(ptToTest, &reallyFarPoint, &area[i], &area[(i + 1) % numPointsInArea])) { - ++numIntersections; - } - } - return (numIntersections % 2 == 1); -} - -// This function uses even-odd winding to determine whether a point is inside an area. -Bool PointInsideArea2D( const Coord3D *ptToTest, const Coord3D *area, Int numPointsInArea) -{ - int numIntersections = 0; - Coord2D pt2D, area2D1, area2D2; - pt2D.x = ptToTest->x; - pt2D.y = ptToTest->y; - - for (int i = 0; i < numPointsInArea; ++i) { - area2D1.x = area[i].x; - area2D1.y = area[i].y; - area2D2.x = area[(i + 1) % numPointsInArea].x; - area2D2.y = area[(i + 1) % numPointsInArea].y; - if (IntersectLine2D(&pt2D, &reallyFarPoint, &area2D1, &area2D2)) { - ++numIntersections; - } - } - return (numIntersections % 2 == 1); -} - -///< Checks if a point is inside a perfect rectangle (top left and bottom right) -Bool Coord3DInsideRect2D( const Coord3D *inputPoint, const Coord2D *tl, const Coord2D *br ) -{ - if( inputPoint->x >= tl->x && inputPoint->x <= br->x ) - { - if( inputPoint->y >= tl->y && inputPoint->y <= br->y ) - { - return TRUE; - } - } - return FALSE; -} - -///< Scales a rect by a factor either growing or shrinking it. -void ScaleRect2D( Coord2D *tl, Coord2D *br, Real scaleFactor ) -{ - scaleFactor = scaleFactor-1.0f; // We are starting with tl,br, so scaling it by 1 means adding 0 to it. - - Real deltaWidth = (br->x - tl->x) * scaleFactor * 0.5f; - Real deltaHeight = (br->y - tl->y) * scaleFactor * 0.5f; - - tl->x -= deltaWidth; - tl->y -= deltaHeight; - - br->x += deltaWidth; - br->y += deltaHeight; -} - - -// Solution taken from http://astronomy.swin.edu.au/~pbourke/geometry/pointline/ -void ShortestDistancePointToSegment2D( const Coord2D *a, const Coord2D *b, const Coord2D *pt, - Real *outDistance, Coord2D *outPosition, Real *outU ) -{ - if (!a || !b || !pt) { - return; - } - - if (a->x == b->x && a->y == b->y) { - // special case, its simply pt to pt. - Coord2D segment; - segment.x = pt->x - a->x; - segment.y = pt->y - a->y; - if (outDistance) { - (*outDistance) = segment.length(); - } - - if (outPosition) { - (*outPosition).x = a->x; - (*outPosition).y = a->y; - } - - if (outU) { - (*outU) = 0.5; - } - return; - } - - Coord2D segAB; - segAB.x = b->x - a->x; - segAB.y = b->y - a->y; - - // General case - Real u = ((pt->x - a->x) * (b->x - a->x) + (pt->y - a->y) * (b->y - a->y)) / - sqr(segAB.length()); - - Coord2D intersectSegment; - - intersectSegment.x = a->x + u * (b->x - a->x); - intersectSegment.y = a->y + u * (b->y - a->y); - - - if (outPosition) { - (*outPosition) = intersectSegment; - } - - if (outDistance) { - (*outDistance) = intersectSegment.length(); - } - - if (outU) { - (*outU) = u; - } - -} diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp index fb8302f8900..b2eed26c3f9 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp @@ -596,6 +596,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa DrawableList drawablesThatWillSelect; PickDrawableStruct pds; pds.drawableListToFill = &drawablesThatWillSelect; + pds.isPointSelection = isPoint; TheTacticalView->iterateDrawablesInRegion(&selectionRegion, addDrawableToList, &pds); if (drawablesThatWillSelect.empty()) diff --git a/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp deleted file mode 100644 index 645c8845b47..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/RadiusDecal.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// RadiusDecal.cpp /////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#define DEFINE_SHADOW_NAMES - -#include "Common/Player.h" -#include "Common/PlayerList.h" -#include "Common/Xfer.h" -#include "GameClient/RadiusDecal.h" -#include "GameClient/Shadow.h" -#include "GameLogic/GameLogic.h" - - -// ------------------------------------------------------------------------------------------------ -RadiusDecalTemplate::RadiusDecalTemplate() : - m_shadowType(SHADOW_ALPHA_DECAL), - m_minOpacity(1.0f), - m_maxOpacity(1.0f), - m_opacityThrobTime(LOGICFRAMES_PER_SECOND), - m_color(0), - m_onlyVisibleToOwningPlayer(true), - m_name(AsciiString::TheEmptyString) -{ -} - -// ------------------------------------------------------------------------------------------------ -void RadiusDecalTemplate::createRadiusDecal(const Coord3D& pos, Real radius, const Player* owningPlayer, RadiusDecal& result) const -{ - result.clear(); - - if (owningPlayer == nullptr) - { - DEBUG_CRASH(("You MUST specify a non-null owningPlayer to createRadiusDecal. (srj)")); - return; - } - - if (m_name.isEmpty() || radius <= 0.0f) - return; - - // it is now considered nonEmpty, regardless of the state of m_decal, etc - result.m_empty = false; - - if (!m_onlyVisibleToOwningPlayer || - owningPlayer->getPlayerIndex() == ThePlayerList->getLocalPlayer()->getPlayerIndex()) - { - Shadow::ShadowTypeInfo decalInfo; - decalInfo.allowUpdates = FALSE; // shadow texture will never update - decalInfo.allowWorldAlign = TRUE; // shadow image will wrap around world objects - decalInfo.m_type = m_shadowType; - strlcpy(decalInfo.m_ShadowName, m_name.str(), ARRAY_SIZE(decalInfo.m_ShadowName)); // name of your texture - decalInfo.m_sizeX = radius*2; // world space dimensions - decalInfo.m_sizeY = radius*2; // world space dimensions - - result.m_decal = TheProjectedShadowManager->addDecal(&decalInfo); - if (result.m_decal) - { - result.m_decal->setAngle(0.0f); - result.m_decal->setColor(m_color == 0 ? owningPlayer->getPlayerColor() : m_color); - result.m_decal->setPosition(pos.x, pos.y, pos.z); - result.m_template = this; - } - else - { - DEBUG_CRASH(("Unable to add decal %s",decalInfo.m_ShadowName)); - } - } -} - -// ------------------------------------------------------------------------------------------------ -void RadiusDecalTemplate::xferRadiusDecalTemplate( Xfer *xfer ) -{ - // version - XferVersion currentVersion = 1; - XferVersion version = currentVersion; - xfer->xferVersion( &version, currentVersion ); - - xfer->xferAsciiString(&m_name); - xfer->xferUser(&m_shadowType, sizeof(m_shadowType)); - xfer->xferReal(&m_minOpacity); - xfer->xferReal(&m_maxOpacity); - xfer->xferUnsignedInt(&m_opacityThrobTime); - xfer->xferColor(&m_color); - xfer->xferBool(&m_onlyVisibleToOwningPlayer); -} - -// ------------------------------------------------------------------------------------------------ -/*static*/ void RadiusDecalTemplate::parseRadiusDecalTemplate(INI* ini, void *instance, void * store, const void* /*userData*/) -{ - static const FieldParse dataFieldParse[] = - { - { "Texture", INI::parseAsciiString, nullptr, offsetof( RadiusDecalTemplate, m_name ) }, - { "Style", INI::parseBitString32, TheShadowNames, offsetof( RadiusDecalTemplate, m_shadowType ) }, - { "OpacityMin", INI::parsePercentToReal, nullptr, offsetof( RadiusDecalTemplate, m_minOpacity ) }, - { "OpacityMax", INI::parsePercentToReal, nullptr, offsetof( RadiusDecalTemplate, m_maxOpacity) }, - { "OpacityThrobTime", INI::parseDurationUnsignedInt,nullptr, offsetof( RadiusDecalTemplate, m_opacityThrobTime ) }, - { "Color", INI::parseColorInt, nullptr, offsetof( RadiusDecalTemplate, m_color ) }, - { "OnlyVisibleToOwningPlayer", INI::parseBool, nullptr, offsetof( RadiusDecalTemplate, m_onlyVisibleToOwningPlayer ) }, - { nullptr, nullptr, nullptr, 0 } - }; - - ini->initFromINI(store, dataFieldParse); -} - -// ------------------------------------------------------------------------------------------------ -RadiusDecal::RadiusDecal() : - m_template(nullptr), - m_decal(nullptr), - m_empty(true) -{ -} - -// ------------------------------------------------------------------------------------------------ -RadiusDecal::RadiusDecal(const RadiusDecal& that) : - m_template(nullptr), - m_decal(nullptr), - m_empty(true) -{ - DEBUG_CRASH(("not fully implemented")); -} - -// ------------------------------------------------------------------------------------------------ -RadiusDecal& RadiusDecal::operator=(const RadiusDecal& that) -{ - if (this != &that) - { - m_template = nullptr; - if (m_decal) - m_decal->release(); - m_decal = nullptr; - m_empty = true; - DEBUG_CRASH(("not fully implemented")); - } - return *this; -} - -// ------------------------------------------------------------------------------------------------ -void RadiusDecal::xferRadiusDecal( Xfer *xfer ) -{ - /// @todo implement me - if (xfer->getXferMode() == XFER_LOAD) - { - clear(); - } -} - -// ------------------------------------------------------------------------------------------------ -void RadiusDecal::clear() -{ - m_template = nullptr; - if (m_decal) - { - m_decal->release(); - } - m_decal = nullptr; - m_empty = true; -} - -// ------------------------------------------------------------------------------------------------ -RadiusDecal::~RadiusDecal() -{ - clear(); -} - -// ------------------------------------------------------------------------------------------------ -void RadiusDecal::update() -{ - if (m_decal && m_template) - { - UnsignedInt now = TheGameLogic->getFrame(); - Real theta = (2*PI) * (Real)(now % m_template->m_opacityThrobTime) / (Real)m_template->m_opacityThrobTime; - Real percent = 0.5f * (Sin(theta) + 1.0f); - Int opac; - if( TheGameLogic->getDrawIconUI() ) - { - opac = REAL_TO_INT((m_template->m_minOpacity + percent * (m_template->m_maxOpacity - m_template->m_minOpacity)) * 255.0f); - } - else - { - //Scripts turned this off, so don't show them! - opac = 0; - } - m_decal->setOpacity(opac); - } -} - - - -void RadiusDecal::setOpacity( Real o ) -{ - if (m_decal) - { - m_decal->setOpacity(REAL_TO_INT(255.0f * o)); - } -} - -// ------------------------------------------------------------------------------------------------ -void RadiusDecal::setPosition(const Coord3D& pos) -{ - if (m_decal) - { - m_decal->setPosition(pos.x, pos.y, pos.z); //world space position of center of decal - } -} diff --git a/Generals/Code/GameEngine/Source/GameClient/SelectionInfo.cpp b/Generals/Code/GameEngine/Source/GameClient/SelectionInfo.cpp deleted file mode 100644 index 38e75a017f2..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/SelectionInfo.cpp +++ /dev/null @@ -1,367 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -#include "PreRTS.h" -#include "GameClient/SelectionInfo.h" - -#include "Common/ActionManager.h" -#include "GameLogic/Damage.h" -#include "Common/Player.h" -#include "Common/PlayerList.h" -#include "Common/ThingTemplate.h" - -#include "GameClient/CommandXlat.h" -#include "GameClient/ControlBar.h" -#include "GameClient/Drawable.h" -#include "GameClient/GameClient.h" -#include "GameClient/KeyDefs.h" - - -//------------------------------------------------------------------------------------------------- -SelectionInfo::SelectionInfo() : - currentCountEnemies(0), - currentCountCivilians(0), - currentCountMine(0), - currentCountMineInfantry(0), - currentCountMineBuildings(0), - currentCountFriends(0), - newCountEnemies(0), - newCountCivilians(0), - newCountCrates(0), - newCountMine(0), - newCountMineBuildings(0), - newCountFriends(0), - newCountGarrisonableBuildings(0), - selectEnemies(FALSE), - selectCivilians(FALSE), - selectMine(FALSE), - selectMineBuildings(FALSE), - selectFriends(FALSE) -{ } - -//------------------------------------------------------------------------------------------------- -PickDrawableStruct::PickDrawableStruct() : drawableListToFill(nullptr) -{ - drawableListToFill = FALSE; - forceAttackMode = TheInGameUI->isInForceAttackMode(); - UnsignedInt pickType = getPickTypesForContext(forceAttackMode); - translatePickTypesToKindof(pickType, kindofsToMatch); - if (!forceAttackMode) - { - kindofsToMatch.set(KINDOF_ALWAYS_SELECTABLE); - } -} - -//------------------------------------------------------------------------------------------------- -/** - * Given a list of currently selected things and a list of things that are currently under - * the selection (pointer or drag), generate some useful information about each. - */ -extern Bool contextCommandForNewSelection(const DrawableList *currentlySelectedDrawables, - const DrawableList *newlySelectedDrawables, - SelectionInfo *outSelectionInfo, - Bool selectionIsPoint) -{ - if (!(currentlySelectedDrawables && newlySelectedDrawables && outSelectionInfo)) - return FALSE; - - Bool forceFire = TheInGameUI->isInForceAttackMode(); - Bool forceMove = TheInGameUI->isInForceMoveToMode(); - - if (forceFire || forceMove) { - return FALSE; - } - - - Player *localPlayer = ThePlayerList->getLocalPlayer(); - DrawableListCIt it; - for (it = currentlySelectedDrawables->begin(); it != currentlySelectedDrawables->end(); ++it) { - if (!(*it)) { - continue; - } - - Object *obj = (*it)->getObject(); - if (!obj) { - continue; - } - - if (obj->isLocallyControlled()) { - ++outSelectionInfo->currentCountMine; - if (obj->isKindOf(KINDOF_INFANTRY)) { - ++outSelectionInfo->currentCountMineInfantry; - } else if (obj->isKindOf(KINDOF_STRUCTURE)) { - ++outSelectionInfo->currentCountMineBuildings; - } - } else { - Relationship rel = localPlayer->getRelationship(obj->getTeam()); - if (rel == ALLIES) { - ++outSelectionInfo->currentCountFriends; - } else if (rel == ENEMIES) { - ++outSelectionInfo->currentCountEnemies; - } else if (rel == NEUTRAL) { - ++outSelectionInfo->currentCountCivilians; - } - } - } - - Drawable *newMine = nullptr; - Drawable *newFriendly = nullptr; - Drawable *newEnemy = nullptr; - Drawable *newCivilian = nullptr; - - for (it = newlySelectedDrawables->begin(); it != newlySelectedDrawables->end(); ++it) { - if (!(*it)) { - continue; - } - - Object *obj = (*it)->getObject(); - if (!obj) { - continue; - } - - if (TheActionManager->canPlayerGarrison(localPlayer, obj, CMD_FROM_PLAYER)) { - ++outSelectionInfo->newCountGarrisonableBuildings; - } - if (obj->isKindOf(KINDOF_CRATE)) { - ++outSelectionInfo->newCountCrates; - } - - if (obj->isLocallyControlled()) { - ++outSelectionInfo->newCountMine; - newMine = *it; - if (obj->isKindOf(KINDOF_STRUCTURE)) { - ++outSelectionInfo->newCountMineBuildings; - } - } else { - Relationship rel = localPlayer->getRelationship(obj->getTeam()); - if (rel == ALLIES) { - newFriendly = *it; - ++outSelectionInfo->newCountFriends; - } else if (rel == ENEMIES) { - newEnemy = *it; - ++outSelectionInfo->newCountEnemies; - } else if (rel == NEUTRAL) { - newCivilian = *it; - ++outSelectionInfo->newCountCivilians; - } - } - } - - DEBUG_ASSERTCRASH(outSelectionInfo->currentCountEnemies <= 1, ("Selection bug. jkmcd")); - DEBUG_ASSERTCRASH(outSelectionInfo->currentCountFriends <= 1, ("Selection bug. jkmcd")); - DEBUG_ASSERTCRASH(outSelectionInfo->currentCountCivilians <= 1, ("Selection bug. jkmcd")); - - if (outSelectionInfo->currentCountEnemies > 0) { - // If we have an enemy selected, there are no context sensitive commands - return FALSE; - } - - if (outSelectionInfo->currentCountFriends > 0) { - return FALSE; - } - - if (outSelectionInfo->currentCountCivilians > 0) { - return FALSE; - } - - if (TheGlobalData->m_useAlternateMouse) { - // context sensitive commands never apply when selecting in alternate mouse mode - return FALSE; - } - - if (outSelectionInfo->currentCountMine > 0) { - if (outSelectionInfo->newCountEnemies > 0) { - if (outSelectionInfo->newCountEnemies == 1 && selectionIsPoint) { - return TheGameClient->evaluateContextCommand(newEnemy, newEnemy->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID; - } - - return selectionIsPoint; - } - - if (outSelectionInfo->newCountMine > 0) { - if (outSelectionInfo->newCountMine == 1 && selectionIsPoint && !TheInGameUI->isInPreferSelectionMode()) { - return TheGameClient->evaluateContextCommand(newMine, newMine->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID; - } - - return FALSE; - } - - if (outSelectionInfo->newCountFriends > 0) { - if (outSelectionInfo->newCountFriends == 1 && selectionIsPoint) { - return TheGameClient->evaluateContextCommand(newFriendly, newFriendly->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID; - } - return FALSE; - } - - if (outSelectionInfo->currentCountMineInfantry > 0 && outSelectionInfo->newCountGarrisonableBuildings == 1) { - return TRUE; - } - - if (outSelectionInfo->newCountCivilians > 0) { - if (outSelectionInfo->newCountCivilians == 1 && selectionIsPoint) { - return TheGameClient->evaluateContextCommand(newCivilian, newCivilian->getPosition(), CommandTranslator::EVALUATE_ONLY) != GameMessage::MSG_INVALID; - } - return FALSE; - } - - if (outSelectionInfo->newCountCrates > 0) { - return (outSelectionInfo->newCountCrates == 1 && selectionIsPoint); - } - } - - if (outSelectionInfo->currentCountMine == 0) { - return FALSE; - } - - return selectionIsPoint; -} - -//------------------------------------------------------------------------------------------------- -UnsignedInt getPickTypesForContext( Bool forceAttackMode ) -{ - UnsignedInt types = PICK_TYPE_SELECTABLE; - - if (forceAttackMode) - types |= PICK_TYPE_FORCEATTACKABLE; - - // - // if we have a gui context command that allows for a shrubbery target then we want to - // pick that type too (generally shrubbery aren't pickable cause it would get in - // the way with movement and general selection) - // - const CommandButton *command = TheInGameUI->getGUICommand(); - - if (command != nullptr) { - if (BitIsSet( command->getOptions(), ALLOW_MINE_TARGET)) { - types |= PICK_TYPE_MINES; - } - - if (BitIsSet( command->getOptions(), ALLOW_SHRUBBERY_TARGET ) ) { - types |= PICK_TYPE_SHRUBBERY; - } - } else { - types |= getPickTypesForCurrentSelection(forceAttackMode); - } - - return types; - -} - -//------------------------------------------------------------------------------------------------- -UnsignedInt getPickTypesForCurrentSelection( Bool forceAttackMode ) -{ - UnsignedInt retVal = 0; - if (!TheInGameUI->areSelectedObjectsControllable()) { - return retVal; - } - - const DrawableList *allSelectedDrawables = TheInGameUI->getAllSelectedDrawables(); - - for (DrawableListCIt cit = allSelectedDrawables->begin(); cit != allSelectedDrawables->end(); ++cit) { - Drawable *draw = *cit; - if (!draw) { - continue; - } - - Object *obj = draw->getObject(); - if (!obj) { - continue; - } - -// srj sez: thanks to new, area-effect disarming, we NO LONGER want to do this... -// if (obj->hasWeaponToDealDamageType(DAMAGE_DISARM)) { -// retVal |= PICK_TYPE_MINES; -// } - - if (obj->hasWeaponToDealDamageType(DAMAGE_FLAME) && forceAttackMode ) { - retVal |= PICK_TYPE_SHRUBBERY; - } - - // For efficiency. - if (BitIsSet(retVal, PICK_TYPE_MINES | PICK_TYPE_SHRUBBERY)) { - break; - } - } - - return retVal; - -} - -//------------------------------------------------------------------------------------------------- -void translatePickTypesToKindof(UnsignedInt pickTypes, KindOfMaskType& outMask) -{ - if (BitIsSet(pickTypes, PICK_TYPE_SELECTABLE)) { - outMask.set(KINDOF_SELECTABLE); - } - - if (BitIsSet(pickTypes, PICK_TYPE_SHRUBBERY)) { - outMask.set(KINDOF_SHRUBBERY); - } - - if (BitIsSet(pickTypes, PICK_TYPE_MINES)) { - outMask.set(KINDOF_MINE); - } - - if (BitIsSet(pickTypes, PICK_TYPE_FORCEATTACKABLE)) { - outMask.set(KINDOF_FORCEATTACKABLE); - } -} - -//------------------------------------------------------------------------------------------------- -// Given a drawable, add it to an stl list specified by userData. -// Useful for iterateDrawablesInRegion. -Bool addDrawableToList( Drawable *draw, void *userData ) -{ - PickDrawableStruct *pds = (PickDrawableStruct *) userData; -#if defined(RTS_DEBUG) - if (TheGlobalData->m_allowUnselectableSelection) { - pds->drawableListToFill->push_back(draw); - return TRUE; - } -#endif - - if (!pds->drawableListToFill) - return FALSE; - -#if !RTS_GENERALS || !PRESERVE_RETAIL_BEHAVIOR - // TheSuperHackers @info - // In retail, drag-selecting allows the player to select stealthed objects and objects through the - // fog. Some players exploit this bug to determine where an opponent's units are and consider this - // an important feature and an advanced skill to pull off, so we must leave the exploit. - if (draw->getFullyObscuredByShroud()) - return FALSE; - - if (draw->isDrawableEffectivelyHidden()) - return FALSE; -#endif - - if (!draw->getTemplate()->isAnyKindOf(pds->kindofsToMatch)) - return FALSE; - - if (!draw->isSelectable()) - return FALSE; - - pds->drawableListToFill->push_back(draw); - return TRUE; -} diff --git a/Generals/Code/GameEngine/Source/GameClient/Statistics.cpp b/Generals/Code/GameEngine/Source/GameClient/Statistics.cpp deleted file mode 100644 index 3290a581a96..00000000000 --- a/Generals/Code/GameEngine/Source/GameClient/Statistics.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Statistics.cpp -/*---------------------------------------------------------------------------*/ -/* EA Pacific */ -/* Confidential Information */ -/* Copyright (C) 2001 - All Rights Reserved */ -/* DO NOT DISTRIBUTE */ -/*---------------------------------------------------------------------------*/ -/* Project: RTS3 */ -/* File name: Statistics.cpp */ -/* Created: John K. McDonald, Jr., 4/2/2002 */ -/* Desc: Statistical functions should live here */ -/* Revision History: */ -/* 4/2/2002 : Initial creation */ -/*---------------------------------------------------------------------------*/ - -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine - -#include "GameClient/Statistics.h" - -// Solution taken from http://www.epanorama.net/documents/telecom/ulaw_alaw.html -Real MuLaw(Real valueToRun, Real maxValueForVal, Real mu) -{ - Real testVal = (valueToRun - maxValueForVal / 2) / (maxValueForVal / 2); - return (sign(testVal) * log(1 + mu * fabs(testVal)) / - log(1 + mu)); -} - -// from my head. jkmcd -Real Normalize(Real valueToNormalize, Real minRange, Real maxRange) -{ - return ((valueToNormalize - minRange) / (maxRange - minRange)); -} - -// from my head again. jkmcd -Real NormalizeToRange(Real valueToNormalize, Real minRange, Real maxRange, Real outRangeMin, Real outRangeMax) -{ - return (Normalize(valueToNormalize, minRange, maxRange) * (outRangeMax - outRangeMin)) + outRangeMin; -} diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index 37281a7db18..85aa9ff8db0 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -139,28 +139,28 @@ set(GAMEENGINE_SRC Include/GameClient/AnimateWindowManager.h Include/GameClient/CampaignManager.h # Include/GameClient/ChallengeGenerals.h - Include/GameClient/ClientInstance.h +# Include/GameClient/ClientInstance.h # Include/GameClient/ClientRandomValue.h - Include/GameClient/Color.h +# Include/GameClient/Color.h Include/GameClient/CommandXlat.h Include/GameClient/ControlBar.h Include/GameClient/ControlBarResizer.h Include/GameClient/ControlBarScheme.h - Include/GameClient/Credits.h +# Include/GameClient/Credits.h Include/GameClient/DebugDisplay.h Include/GameClient/Diplomacy.h Include/GameClient/DisconnectMenu.h Include/GameClient/Display.h - Include/GameClient/DisplayString.h - Include/GameClient/DisplayStringManager.h +# Include/GameClient/DisplayString.h +# Include/GameClient/DisplayStringManager.h Include/GameClient/Drawable.h Include/GameClient/DrawableInfo.h - Include/GameClient/DrawGroupInfo.h +# Include/GameClient/DrawGroupInfo.h Include/GameClient/EstablishConnectionsMenu.h Include/GameClient/Eva.h Include/GameClient/ExtendedMessageBox.h Include/GameClient/FontDesc.h - Include/GameClient/FXList.h +# Include/GameClient/FXList.h Include/GameClient/Gadget.h Include/GameClient/GadgetCheckBox.h Include/GameClient/GadgetComboBox.h @@ -175,14 +175,14 @@ set(GAMEENGINE_SRC Include/GameClient/GameClient.h # Include/GameClient/GameFont.h Include/GameClient/GameInfoWindow.h - Include/GameClient/GameText.h +# Include/GameClient/GameText.h # Include/GameClient/GameWindow.h # Include/GameClient/GameWindowGlobal.h Include/GameClient/GameWindowID.h Include/GameClient/GameWindowManager.h # Include/GameClient/GameWindowTransitions.h - Include/GameClient/GlobalLanguage.h - Include/GameClient/GraphDraw.h +# Include/GameClient/GlobalLanguage.h +# Include/GameClient/GraphDraw.h Include/GameClient/GUICallbacks.h Include/GameClient/GUICommandTranslator.h # Include/GameClient/HeaderTemplate.h @@ -193,8 +193,8 @@ set(GAMEENGINE_SRC Include/GameClient/InGameUI.h # Include/GameClient/Keyboard.h Include/GameClient/KeyDefs.h - Include/GameClient/LanguageFilter.h - Include/GameClient/Line2D.h +# Include/GameClient/LanguageFilter.h +# Include/GameClient/Line2D.h # Include/GameClient/LoadScreen.h Include/GameClient/LookAtXlat.h # Include/GameClient/MapUtil.h @@ -208,9 +208,9 @@ set(GAMEENGINE_SRC # Include/GameClient/ParticleSys.h Include/GameClient/PlaceEventTranslator.h # Include/GameClient/ProcessAnimateWindow.h - Include/GameClient/RadiusDecal.h +# Include/GameClient/RadiusDecal.h Include/GameClient/RayEffect.h - Include/GameClient/SelectionInfo.h +# Include/GameClient/SelectionInfo.h Include/GameClient/SelectionXlat.h Include/GameClient/Shadow.h Include/GameClient/Shell.h @@ -218,7 +218,7 @@ set(GAMEENGINE_SRC Include/GameClient/ShellMenuScheme.h # Include/GameClient/Smudge.h # Include/GameClient/Snow.h - Include/GameClient/Statistics.h +# Include/GameClient/Statistics.h # Include/GameClient/TerrainRoads.h # Include/GameClient/TerrainVisual.h # Include/GameClient/VideoPlayer.h @@ -677,24 +677,24 @@ set(GAMEENGINE_SRC # Source/Common/UserPreferences.cpp Source/Common/version.cpp # Source/Common/WorkerProcess.cpp - Source/GameClient/ClientInstance.cpp - Source/GameClient/Color.cpp - Source/GameClient/Credits.cpp +# Source/GameClient/ClientInstance.cpp +# Source/GameClient/Color.cpp +# Source/GameClient/Credits.cpp Source/GameClient/Display.cpp - Source/GameClient/DisplayString.cpp - Source/GameClient/DisplayStringManager.cpp +# Source/GameClient/DisplayString.cpp +# Source/GameClient/DisplayStringManager.cpp Source/GameClient/Drawable.cpp Source/GameClient/Drawable/Update/AnimatedParticleSysBoneClientUpdate.cpp Source/GameClient/Drawable/Update/BeaconClientUpdate.cpp Source/GameClient/Drawable/Update/SwayClientUpdate.cpp - Source/GameClient/DrawGroupInfo.cpp +# Source/GameClient/DrawGroupInfo.cpp Source/GameClient/Eva.cpp - Source/GameClient/FXList.cpp +# Source/GameClient/FXList.cpp Source/GameClient/GameClient.cpp Source/GameClient/GameClientDispatch.cpp - Source/GameClient/GameText.cpp - Source/GameClient/GlobalLanguage.cpp - Source/GameClient/GraphDraw.cpp +# Source/GameClient/GameText.cpp +# Source/GameClient/GlobalLanguage.cpp +# Source/GameClient/GraphDraw.cpp Source/GameClient/GUI/AnimateWindowManager.cpp # Source/GameClient/GUI/ChallengeGenerals.cpp Source/GameClient/GUI/ControlBar/ControlBar.cpp @@ -792,8 +792,8 @@ set(GAMEENGINE_SRC Source/GameClient/InGameUI.cpp # Source/GameClient/Input/Keyboard.cpp # Source/GameClient/Input/Mouse.cpp - Source/GameClient/LanguageFilter.cpp - Source/GameClient/Line2D.cpp +# Source/GameClient/LanguageFilter.cpp +# Source/GameClient/Line2D.cpp # Source/GameClient/MapUtil.cpp Source/GameClient/MessageStream/CommandXlat.cpp Source/GameClient/MessageStream/GUICommandTranslator.cpp @@ -805,10 +805,10 @@ set(GAMEENGINE_SRC Source/GameClient/MessageStream/SelectionXlat.cpp Source/GameClient/MessageStream/WindowXlat.cpp # Source/GameClient/ParabolicEase.cpp - Source/GameClient/RadiusDecal.cpp - Source/GameClient/SelectionInfo.cpp +# Source/GameClient/RadiusDecal.cpp +# Source/GameClient/SelectionInfo.cpp # Source/GameClient/Snow.cpp - Source/GameClient/Statistics.cpp +# Source/GameClient/Statistics.cpp Source/GameClient/System/Anim2D.cpp Source/GameClient/System/CampaignManager.cpp # "Source/GameClient/System/Debug Displayers/AudioDebugDisplay.cpp" diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ClientInstance.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ClientInstance.h deleted file mode 100644 index 1f1ada1daca..00000000000 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ClientInstance.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 TheSuperHackers -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ -#include "Lib/BaseType.h" - -namespace rts -{ - -// TheSuperHackers @feature Adds support for launching multiple game clients and keeping track of their instance id. - -class ClientInstance -{ -public: - // Can be called N times, but is initialized just once. - static bool initialize(); - - static bool isInitialized(); - - static bool isMultiInstance(); - - // Change multi instance on runtime. Must be called before initialize. - static void setMultiInstance(bool v); - - // Skips using the primary instance. Must be called before initialize. - // Useful when the new process is not meant to collide with another normal Generals process. - static void skipPrimaryInstance(); - - // Returns the instance index of this game client. Starts at 0. - static UnsignedInt getInstanceIndex(); - - // Returns the instance id of this game client. Starts at 1. - static UnsignedInt getInstanceId(); - - // Returns the instance name of the first game client. - static const char* getFirstInstanceName(); - -private: - static HANDLE s_mutexHandle; - static UnsignedInt s_instanceIndex; - static Bool s_isMultiInstance; -}; - -} // namespace rts diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ClientInstance.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/ClientInstance.cpp deleted file mode 100644 index 7b06108866a..00000000000 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/ClientInstance.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 TheSuperHackers -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ -#include "PreRTS.h" -#include "GameClient/ClientInstance.h" - -#define GENERALS_GUID "685EAFF2-3216-4265-B047-251C5F4B82F3" - -namespace rts -{ -HANDLE ClientInstance::s_mutexHandle = nullptr; -UnsignedInt ClientInstance::s_instanceIndex = 0; - -#if defined(RTS_MULTI_INSTANCE) -Bool ClientInstance::s_isMultiInstance = true; -#else -Bool ClientInstance::s_isMultiInstance = false; -#endif - -bool ClientInstance::initialize() -{ - if (isInitialized()) - { - return true; - } - - // Create a mutex with a unique name to Generals in order to determine if our app is already running. - // WARNING: DO NOT use this number for any other application except Generals. - while (true) - { - if (isMultiInstance()) - { - std::string guidStr = getFirstInstanceName(); - if (s_instanceIndex > 0u) - { - char idStr[33]; - itoa(s_instanceIndex, idStr, 10); - guidStr.push_back('-'); - guidStr.append(idStr); - } - s_mutexHandle = CreateMutex(nullptr, FALSE, guidStr.c_str()); - if (GetLastError() == ERROR_ALREADY_EXISTS) - { - if (s_mutexHandle != nullptr) - { - CloseHandle(s_mutexHandle); - s_mutexHandle = nullptr; - } - // Try again with a new instance. - ++s_instanceIndex; - continue; - } - } - else - { - s_mutexHandle = CreateMutex(nullptr, FALSE, getFirstInstanceName()); - if (GetLastError() == ERROR_ALREADY_EXISTS) - { - if (s_mutexHandle != nullptr) - { - CloseHandle(s_mutexHandle); - s_mutexHandle = nullptr; - } - return false; - } - } - break; - } - - return true; -} - -bool ClientInstance::isInitialized() -{ - return s_mutexHandle != nullptr; -} - -bool ClientInstance::isMultiInstance() -{ - return s_isMultiInstance; -} - -void ClientInstance::setMultiInstance(bool v) -{ - if (isInitialized()) - { - DEBUG_CRASH(("ClientInstance::setMultiInstance(%d) - cannot set multi instance after initialization", (int)v)); - return; - } - s_isMultiInstance = v; -} - -void ClientInstance::skipPrimaryInstance() -{ - if (isInitialized()) - { - DEBUG_CRASH(("ClientInstance::skipPrimaryInstance() - cannot skip primary instance after initialization")); - return; - } - s_instanceIndex = 1; -} - -UnsignedInt ClientInstance::getInstanceIndex() -{ - DEBUG_ASSERTLOG(isInitialized(), ("ClientInstance::isInitialized() failed")); - return s_instanceIndex; -} - -UnsignedInt ClientInstance::getInstanceId() -{ - return getInstanceIndex() + 1; -} - -const char* ClientInstance::getFirstInstanceName() -{ - return GENERALS_GUID; -} - -} // namespace rts diff --git a/scripts/cpp/unify_move_files.py b/scripts/cpp/unify_move_files.py index 7180244f56f..009fe4f7dab 100644 --- a/scripts/cpp/unify_move_files.py +++ b/scripts/cpp/unify_move_files.py @@ -378,6 +378,37 @@ def main(): #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/WindowLayout.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/WindowLayout.cpp") #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GUI/WinInstanceData.cpp", Game.CORE, "GameEngine/Source/GameClient/GUI/WinInstanceData.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/ClientInstance.h", Game.CORE, "GameEngine/Include/GameClient/ClientInstance.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/Color.h", Game.CORE, "GameEngine/Include/GameClient/Color.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/Credits.h", Game.CORE, "GameEngine/Include/GameClient/Credits.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/DisplayString.h", Game.CORE, "GameEngine/Include/GameClient/DisplayString.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/DisplayStringManager.h", Game.CORE, "GameEngine/Include/GameClient/DisplayStringManager.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/DrawGroupInfo.h", Game.CORE, "GameEngine/Include/GameClient/DrawGroupInfo.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/FXList.h", Game.CORE, "GameEngine/Include/GameClient/FXList.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GameText.h", Game.CORE, "GameEngine/Include/GameClient/GameText.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GlobalLanguage.h", Game.CORE, "GameEngine/Include/GameClient/GlobalLanguage.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/GraphDraw.h", Game.CORE, "GameEngine/Include/GameClient/GraphDraw.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/LanguageFilter.h", Game.CORE, "GameEngine/Include/GameClient/LanguageFilter.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/Line2D.h", Game.CORE, "GameEngine/Include/GameClient/Line2D.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/RadiusDecal.h", Game.CORE, "GameEngine/Include/GameClient/RadiusDecal.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/SelectionInfo.h", Game.CORE, "GameEngine/Include/GameClient/SelectionInfo.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Include/GameClient/Statistics.h", Game.CORE, "GameEngine/Include/GameClient/Statistics.h") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/ClientInstance.cpp", Game.CORE, "GameEngine/Source/GameClient/ClientInstance.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/Color.cpp", Game.CORE, "GameEngine/Source/GameClient/Color.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/Credits.cpp", Game.CORE, "GameEngine/Source/GameClient/Credits.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/DisplayString.cpp", Game.CORE, "GameEngine/Source/GameClient/DisplayString.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/DisplayStringManager.cpp", Game.CORE, "GameEngine/Source/GameClient/DisplayStringManager.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/DrawGroupInfo.cpp", Game.CORE, "GameEngine/Source/GameClient/DrawGroupInfo.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/FXList.cpp", Game.CORE, "GameEngine/Source/GameClient/FXList.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GameText.cpp", Game.CORE, "GameEngine/Source/GameClient/GameText.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GlobalLanguage.cpp", Game.CORE, "GameEngine/Source/GameClient/GlobalLanguage.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/GraphDraw.cpp", Game.CORE, "GameEngine/Source/GameClient/GraphDraw.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/LanguageFilter.cpp", Game.CORE, "GameEngine/Source/GameClient/LanguageFilter.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/Line2D.cpp", Game.CORE, "GameEngine/Source/GameClient/Line2D.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/RadiusDecal.cpp", Game.CORE, "GameEngine/Source/GameClient/RadiusDecal.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/SelectionInfo.cpp", Game.CORE, "GameEngine/Source/GameClient/SelectionInfo.cpp") + #unify_file(Game.ZEROHOUR, "GameEngine/Source/GameClient/Statistics.cpp", Game.CORE, "GameEngine/Source/GameClient/Statistics.cpp") + return