Skip to content
Open
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
36 changes: 36 additions & 0 deletions Core/GameEngine/Include/Common/GameDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@
#define PRESERVE_RETAIL_PARTICLES (1) // Preserve original look of particles present in retail Generals 1.08 and Zero Hour 1.04
#endif

// Whether to preserve the 1.41x speed discrepancy between straight and diagonal movements of all objects that move via a Locomotor.
// Set this to 0 when world objects need to move at consistent speed in all directions.
#ifndef PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY
#define PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY (1)
#endif

// Whether to preserve the arithmetic mean speed based on the original forward speed discrepancy bug.
// The locomotor speeds from the INI files are effectively scaled up a bit so that on average the world objects travel at comparable speeds.
// Set this to 0 when speeds are set correctly by INI settings (recommended).
#ifndef PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE
#define PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE (1)
#endif

// Whether to preserve the 1.41x speed discrepancy between straight and diagonal movements of all objects during cinematics.
// Is mostly relevant for the original campaign missions.
#ifndef PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY_IN_CINEMATICS
#define PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY_IN_CINEMATICS (1)
#endif


#ifndef RETAIL_COMPATIBLE_CRC
#define RETAIL_COMPATIBLE_CRC (1) // Game is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04
#endif
Expand Down Expand Up @@ -184,3 +204,19 @@
#define DEFAULT_DISPLAY_BIT_DEPTH 32
#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for
#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for


// NON-TWEAKABLE DEFINES ARE DOWN HERE

// Whether the retail forward speed is used unconditionally, for every object at all times.
#define USE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY() \
(PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY || RETAIL_COMPATIBLE_CRC)

// Whether the forward speed is scaled to a former averaged value.
#define USE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE() \
(PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE && !USE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY())

// Whether the retail forward speed is used for the duration of a cinematic event.
// Is only meaningful when the retail forward speed discrepancy is not preserved and the forward speed is scaled.
#define USE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY_IN_CINEMATICS() \
(PRESERVE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY_IN_CINEMATICS && !USE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY() && USE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE())
2 changes: 2 additions & 0 deletions Core/GameEngine/Include/Common/GameUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ PlayerIndex getObservedOrLocalPlayerIndex_Safe(); ///< Get the current observed
void changeLocalPlayer(Player* player); //< Change local player during game. Must not pass null.
void changeObservedPlayer(Player* player); ///< Change observed player during game. Can pass null: is identical to passing the "ReplayObserver" player.

void enableLetterBox(Bool enable); ///< Enable or disable the letter box for cinematics. Hides the control bar.

} // namespace rts
16 changes: 16 additions & 0 deletions Core/GameEngine/Source/Common/GameUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "Common/Radar.h"

#include "GameClient/ControlBar.h"
#include "GameClient/Display.h"
#include "GameClient/GameClient.h"
#include "GameClient/GUICallbacks.h"
#include "GameClient/InGameUI.h"
#include "GameClient/ParticleSys.h"

Expand Down Expand Up @@ -130,4 +132,18 @@ void changeObservedPlayer(Player* player)
}
}

void enableLetterBox(Bool enable)
{
if (enable)
{
HideControlBar(TRUE);
TheDisplay->enableLetterBox(TRUE);
}
else
{
ShowControlBar(FALSE);
TheDisplay->enableLetterBox(FALSE);
}
}

} // namespace rts
34 changes: 30 additions & 4 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,21 @@ class LocomotorTemplate : public Overridable

void validate();

protected:
private:

/// TheSuperHackers @bugfix Speeds authored in INI are understated by the forward speed the Locomotor measures

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment

/// itself with, by up to 1/sqrt(2) in 2d and 1/sqrt(3) in 3d, which is what made objects move faster on diagonal
/// headings than on axis aligned ones. Each authored speed therefore also gets a "scaled" twin, in world distance
/// per logic frame, computed once at INI load. These accessors hand out whichever of the two the mover should be
/// commanded with. They all return the authored value in retail compatible builds.
Real getActualMaxSpeed() const;
Real getActualMaxSpeedDamaged() const;
Real getActualMinSpeed() const;
Real getActualMinTurnSpeed() const;

/// Scale a speed that has no stored counterpart because it was not authored on this template.
Real scaleSpeed(Real speed) const;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This maybe should be behind macro.


private:
/**
Units check:

Expand All @@ -163,6 +174,12 @@ class LocomotorTemplate : public Overridable
Real m_liftDamaged; ///< max lift when damaged
Real m_braking; ///< max braking (deceleration)
Real m_minTurnSpeed; ///< we must be going >= this speed in order to turn
#if USE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE()
Real m_maxSpeedScaled; ///< compensated max speed
Real m_maxSpeedDamagedScaled;///< compensated speed when "damaged"
Real m_minSpeedScaled; ///< compensated min speed; we should never brake past this
Real m_minTurnSpeedScaled; ///< compensated min turn speed; we must be going >= this speed in order to turn
#endif
Real m_preferredHeight; ///< our preferred height (if flying)
Real m_preferredHeightDamping; ///< how aggressively to adjust to preferred height: 1.0 = very much so, 0.1 = gradually, etc
Real m_circlingRadius; ///< for flying things, the radius at which they circle their "maintain" destination. (pos = cw, neg = ccw, 0 = smallest possible)
Expand Down Expand Up @@ -258,7 +275,8 @@ class Locomotor : public MemoryPoolObject, public Snapshot
LocomotorSurfaceTypeMask getLegalSurfaces() const { return m_template->m_surfaces; }

AsciiString getTemplateName() const { return m_template->m_name;}
Real getMinSpeed() const { return m_template->m_minSpeed;}
Real getMinSpeed() const;
Real getMinTurnSpeed() const;
Real getAccelPitchLimit() const { return m_template->m_accelPitchLimit;} ///< Maximum amount we will pitch up or down under acceleration (including recoil.)
Real getDecelPitchLimit() const { return m_template->m_decelPitchLimit;} ///< Maximum amount we will pitch down under deceleration (including recoil.)
Real getBounceKick() const { return m_template->m_bounceKick;} ///< How much simulating rough terrain "bounces" a wheel up.
Expand Down Expand Up @@ -310,7 +328,11 @@ class Locomotor : public MemoryPoolObject, public Snapshot
{
DEBUG_ASSERTCRASH(!(speed <= 0.0f && m_template->m_appearance == LOCO_THRUST), ("THRUST locos may not have zero speeds!"));
m_maxSpeed = speed;
#if USE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE()
m_maxSpeedScaled = m_template->scaleSpeed(speed);
#endif
}
void setMaxSpeedToMinSpeed() { setMaxSpeed(m_template->m_minSpeed); }
void setMaxAcceleration(Real accel) { m_maxAccel = accel; }
void setMaxBraking(Real braking) { m_maxBraking = braking; }
void setMaxTurnRate(Real turn) { m_maxTurnRate = turn; }
Expand Down Expand Up @@ -367,8 +389,9 @@ class Locomotor : public MemoryPoolObject, public Snapshot
void startMove(); ///< Indicates that a move is starting, primarily to reset the donut timer. jba.

protected:
Real getMaxSpeedOverride() const;

void moveTowardsPositionLegs(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
void moveTowardsPositionLegsWander(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
void moveTowardsPositionClimb(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
void moveTowardsPositionWheels(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
void moveTowardsPositionTreads(Object* obj, PhysicsBehavior *physics, const Coord3D& goalPos, Real onPathDistToGoal, Real desiredSpeed);
Expand Down Expand Up @@ -445,6 +468,9 @@ class Locomotor : public MemoryPoolObject, public Snapshot
Real m_brakingFactor;
Real m_maxLift;
Real m_maxSpeed;
#if USE_RETAIL_PHYSICS_FORWARD_SPEED_AVERAGE()
Real m_maxSpeedScaled;
#endif
Real m_maxAccel;
Real m_maxBraking;
Real m_maxTurnRate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ class PhysicsBehavior : public UpdateModule,
Real getForwardSpeed2D() const; ///< compute speed along object's 2d direction vector
Real getForwardSpeed3D() const; ///< compute speed along object's 3d direction vector

#if USE_RETAIL_PHYSICS_FORWARD_SPEED_DISCREPANCY_IN_CINEMATICS()
static Bool useLegacyForwardSpeed();
#endif

ObjectID getCurrentOverlap() const; ///< return object(s) being overlapped
ObjectID getPreviousOverlap() const; ///< return object(s) that were overlapped last frame
ObjectID getLastCollidee() const; ///< return object that was last collided with... can be quite old
Expand Down
4 changes: 4 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/ScriptEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ class ScriptEngine : public SubsystemInterface,
void doFreezeTime();
void doUnfreezeTime();

void friend_notifyLetterBoxActive(Bool active);
Bool isLetterBoxActive() const; ///< Ask whether the letterbox has been activated by a script; indicates an active cinematic

/// The following functions are used to update and query the debug window
Bool isTimeFrozenDebug(); ///< Ask whether the debug window has requested a pause.
Bool isTimeFast(); ///< Ask whether the debug window has requested a fast forward.
Expand Down Expand Up @@ -433,6 +436,7 @@ class ScriptEngine : public SubsystemInterface,
Int m_numAttackInfo;
Int m_endGameTimer;
Int m_closeWindowTimer;
Bool m_letterBoxActive; ///< A scripted letterbox sequence is running
Team *m_callingTeam; ///< Team that is calling script, used for THIS_TEAM
Object *m_callingObject; ///< Object that is calling script, used for THIS_OBJECT
Team *m_conditionTeam; ///< Team that is being used to evaluate conditions, used for THIS_TEAM
Expand Down
Loading
Loading