Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Core/GameEngine/Include/Common/GameDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#pragma once

#include "WWDefines.h"

// Note: Retail compatibility must not be broken before this project officially does.
// Use RETAIL_COMPATIBLE_CRC and RETAIL_COMPATIBLE_XFER_SAVE to guard breaking changes.

Expand Down
1 change: 1 addition & 0 deletions Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ set(WWLIB_SRC
widestring.h
win.h
WWCommon.h
WWDefines.h
wwfile.cpp
WWFILE.H
wwstring.cpp
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WWLib/WWCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#pragma once

#include <stringex.h>
#include "stringex.h"

#if defined(_MSC_VER) && _MSC_VER < 1300
typedef unsigned MemValueType;
Expand Down
25 changes: 25 additions & 0 deletions Core/Libraries/Source/WWVegas/WWLib/WWDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
** 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 <http://www.gnu.org/licenses/>.
*/

#pragma once

// The WW3D Sync time. This was originally 33 ms, ~30 fps, integer.
// Changing or removing this will require tweaking all Drawable code that concerns logic time step, including locomotion physics.
#ifndef MSEC_PER_WWSYNC_FRAME
#define MSEC_PER_WWSYNC_FRAME (33)
#endif
1 change: 1 addition & 0 deletions Core/Libraries/Source/WWVegas/WWLib/always.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#define ALWAYS_H

#include "WWCommon.h"
#include "WWDefines.h"

#include <assert.h>
#include <new>
Expand Down
33 changes: 25 additions & 8 deletions Generals/Code/GameEngine/Include/Common/GameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,16 @@ class Radar;
class WebBrowser;
class ParticleSystemManager;

/**
* The implementation of the game engine
*/
class GameEngine : public SubsystemInterface
{
public:

typedef UnsignedInt LogicTimeQueryFlags;
enum LogicTimeQueryFlags_ CPP_11(: LogicTimeQueryFlags)
{
IgnoreFrozenTime = 1<<0, // Ignore frozen time for the query
IgnoreHaltedGame = 1<<1, // Ignore halted game for the query
};

public:

Expand All @@ -76,13 +81,18 @@ class GameEngine : public SubsystemInterface
Real getUpdateTime(); ///< Get the last engine update delta time.
Real getUpdateFps(); ///< Get the last engine update fps.

static Bool isTimeFrozen(); ///< Returns true if a script has frozen time.
static Bool isGameHalted(); ///< Returns true if the game is paused or the network is stalling.

virtual void setLogicTimeScaleFps( Int fps ); ///< Set the logic time scale fps and therefore scale the simulation time. Is capped by the max render fps and does not apply to network matches.
virtual Int getLogicTimeScaleFps(); ///< Get the raw logic time scale fps value.
virtual void enableLogicTimeScale( Bool enable ); ///< Enable the logic time scale setup. If disabled, the simulation time scale is bound to the render frame time or network update time.
virtual Bool isLogicTimeScaleEnabled(); ///< Check whether the logic time scale setup is enabled.
Int getActualLogicTimeScaleFps(); ///< Get the real logic time scale fps, depending on the max render fps, network state and enabled state.
Real getActualLogicTimeScaleRatio(); ///< Get the real logic time scale ratio, depending on the max render fps, network state and enabled state.
Real getActualLogicTimeScaleOverFpsRatio(); ///< Get the real logic time scale over render fps ratio, used to scale down steps in render updates to match logic updates.
Int getActualLogicTimeScaleFps(LogicTimeQueryFlags flags = 0); ///< Get the real logic time scale fps, depending on the max render fps, network state and enabled state.
Real getActualLogicTimeScaleRatio(LogicTimeQueryFlags flags = 0); ///< Get the real logic time scale ratio, depending on the max render fps, network state and enabled state.
Real getActualLogicTimeScaleOverFpsRatio(LogicTimeQueryFlags flags = 0); ///< Get the real logic time scale over render fps ratio, used to scale down steps in render updates to match logic updates.
Real getLogicTimeStepSeconds(LogicTimeQueryFlags flags = 0); ///< Get the logic time step in seconds
Real getLogicTimeStepMilliseconds(LogicTimeQueryFlags flags = 0); ///< Get the logic time step in milliseconds

virtual void setQuitting( Bool quitting ); ///< set quitting status
virtual Bool getQuitting(void); ///< is app getting ready to quit.
Expand All @@ -97,6 +107,10 @@ class GameEngine : public SubsystemInterface

virtual void resetSubsystems( void );

Bool canUpdateGameLogic();
Bool canUpdateNetworkGameLogic();
Bool canUpdateRegularGameLogic();

virtual FileSystem *createFileSystem( void ); ///< Factory for FileSystem classes
virtual LocalFileSystem *createLocalFileSystem( void ) = 0; ///< Factory for LocalFileSystem classes
virtual ArchiveFileSystem *createArchiveFileSystem( void ) = 0; ///< Factory for ArchiveFileSystem classes
Expand All @@ -117,11 +131,14 @@ class GameEngine : public SubsystemInterface
Real m_updateTime; ///< Last engine update delta time
Real m_logicTimeAccumulator; ///< Frame time accumulated towards submitting a new logic frame

Bool m_quitting; ///< true when we need to quit the game
Bool m_isActive; ///< app has OS focus.
Bool m_quitting; ///< true when we need to quit the game
Bool m_isActive; ///< app has OS focus.
Bool m_enableLogicTimeScale;
Bool m_isTimeFrozen;
Bool m_isGameHalted;

};

inline void GameEngine::setQuitting( Bool quitting ) { m_quitting = quitting; }
inline Bool GameEngine::getQuitting(void) { return m_quitting; }

Expand Down
6 changes: 5 additions & 1 deletion Generals/Code/GameEngine/Include/GameClient/Drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class Drawable : public Thing,

const Matrix3D *getTransformMatrix( void ) const; ///< return the world transform

void draw( View *view ); ///< render the drawable to the given view
void draw(); ///< render the drawable to the given view
void updateDrawable(); ///< update the drawable

void drawIconUI( void ); ///< draw "icon"(s) needed on drawable (health bars, veterency, etc)
Expand Down Expand Up @@ -600,6 +600,8 @@ class Drawable : public Thing,

private:

const Locomotor* getLocomotor() const;

// note, these are lazily allocated!
TintEnvelope* m_selectionFlashEnvelope; ///< used for selection flash, works WITH m_colorTintEnvelope
TintEnvelope* m_colorTintEnvelope; ///< house color flashing, etc... works WITH m_selectionFlashEnvelope
Expand Down Expand Up @@ -644,6 +646,8 @@ class Drawable : public Thing,

DrawableLocoInfo* m_locoInfo; // lazily allocated

PhysicsXformInfo* m_physicsXform;

DynamicAudioEventRTS* m_ambientSound; ///< sound module for ambient sound (lazily allocated)
Bool m_ambientSoundEnabled;

Expand Down
4 changes: 3 additions & 1 deletion Generals/Code/GameEngine/Include/GameLogic/GameLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ class GameLogic : public SubsystemInterface, public Snapshot
void updateObjectsChangedTriggerAreas(void) {m_frameObjectsChangedTriggerAreas = m_frame;}
UnsignedInt getFrameObjectsChangedTriggerAreas(void) {return m_frameObjectsChangedTriggerAreas;}

void exitGame();
void clearGameData(Bool showScoreScreen = TRUE); ///< Clear the game data
void closeWindows( void );

Expand All @@ -205,7 +206,7 @@ class GameLogic : public SubsystemInterface, public Snapshot

void bindObjectAndDrawable(Object* obj, Drawable* draw);

void setGamePausedInFrame( UnsignedInt frame );
void setGamePausedInFrame( UnsignedInt frame, Bool disableLogicTimeScale );
UnsignedInt getGamePauseFrame() const { return m_pauseFrame; }
void setGamePaused( Bool paused, Bool pauseMusic = TRUE, Bool pauseInput = TRUE );
Bool isGamePaused( void );
Expand Down Expand Up @@ -352,6 +353,7 @@ class GameLogic : public SubsystemInterface, public Snapshot
Bool m_pauseInput;
Bool m_inputEnabledMemory;// Latches used to remember what to restore to after we unpause
Bool m_mouseVisibleMemory;
Bool m_logicTimeScaleEnabledMemory;

Bool m_progressComplete[MAX_SLOTS];
enum { PROGRESS_COMPLETE_TIMEOUT = 60000 }; ///< Timeout we wait for when we've completed our Load
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class NetworkInterface : public SubsystemInterface

virtual void setLocalAddress(UnsignedInt ip, UnsignedInt port) = 0; ///< Tell the network what local ip and port to bind to.
virtual Bool isFrameDataReady( void ) = 0; ///< Are the commands for the next frame available?
virtual Bool isStalling() = 0;
virtual void parseUserList( const GameInfo *game ) = 0; ///< Parse a userlist, creating connections
virtual void startGame(void) = 0; ///< Sets the network game frame counter to -1
virtual UnsignedInt getRunAhead(void) = 0; ///< Get the current RunAhead value
Expand Down
Loading
Loading