Skip to content

Commit 70e5c06

Browse files
committed
2 parents 9a748c9 + 6317722 commit 70e5c06

45 files changed

Lines changed: 377 additions & 7472 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Core/GameEngine/Include/Common/GameAudio.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -383,55 +383,4 @@ class AudioManager : public SubsystemInterface
383383
Bool m_disallowSpeech : 1;
384384
};
385385

386-
// TheSuperHackers @feature helmutbuhler 17/05/2025
387-
// AudioManager that does nothing. Used for Headless Mode.
388-
class AudioManagerDummy : public AudioManager
389-
{
390-
#if defined(RTS_DEBUG)
391-
virtual void audioDebugDisplay(DebugDisplayInterface* dd, void* userData, FILE* fp) {}
392-
#endif
393-
virtual void stopAudio(AudioAffect which) override {}
394-
virtual void pauseAudio(AudioAffect which) override {}
395-
virtual void resumeAudio(AudioAffect which) override {}
396-
virtual void pauseAmbient(Bool shouldPause) override {}
397-
virtual void killAudioEventImmediately(AudioHandle audioEvent) override {}
398-
virtual void nextMusicTrack() override {}
399-
virtual void prevMusicTrack() override {}
400-
virtual Bool isMusicPlaying() const override { return false; }
401-
virtual Bool hasMusicTrackCompleted(const AsciiString& trackName, Int numberOfTimes) const override { return false; }
402-
virtual AsciiString getMusicTrackName() const override { return ""; }
403-
virtual void openDevice() override {}
404-
virtual void closeDevice() override {}
405-
virtual void* getDevice() override { return nullptr; }
406-
virtual void notifyOfAudioCompletion(UnsignedInt audioCompleted, UnsignedInt flags) override {}
407-
virtual UnsignedInt getProviderCount() const override { return 0; };
408-
virtual AsciiString getProviderName(UnsignedInt providerNum) const override { return ""; }
409-
virtual UnsignedInt getProviderIndex(AsciiString providerName) const override { return 0; }
410-
virtual void selectProvider(UnsignedInt providerNdx) override {}
411-
virtual void unselectProvider() override {}
412-
virtual UnsignedInt getSelectedProvider() const override { return 0; }
413-
virtual void setSpeakerType(UnsignedInt speakerType) override {}
414-
virtual UnsignedInt getSpeakerType() override { return 0; }
415-
virtual UnsignedInt getNum2DSamples() const override { return 0; }
416-
virtual UnsignedInt getNum3DSamples() const override { return 0; }
417-
virtual UnsignedInt getNumStreams() const override { return 0; }
418-
virtual Bool doesViolateLimit(AudioEventRTS* event) const override { return false; }
419-
virtual Bool isPlayingLowerPriority(AudioEventRTS* event) const override { return false; }
420-
virtual Bool isPlayingAlready(AudioEventRTS* event) const override { return false; }
421-
virtual Bool isObjectPlayingVoice(UnsignedInt objID) const override { return false; }
422-
virtual void adjustVolumeOfPlayingAudio(AsciiString eventName, Real newVolume) override {}
423-
virtual void removePlayingAudio(AsciiString eventName) override {}
424-
virtual void removeAllDisabledAudio() override {}
425-
virtual Bool has3DSensitiveStreamsPlaying() const override { return false; }
426-
virtual void* getHandleForBink() override { return nullptr; }
427-
virtual void releaseHandleForBink() override {}
428-
virtual void friend_forcePlayAudioEventRTS(const AudioEventRTS* eventToPlay) override {}
429-
virtual void setPreferredProvider(AsciiString providerNdx) override {}
430-
virtual void setPreferredSpeaker(AsciiString speakerType) override {}
431-
virtual Real getFileLengthMS(AsciiString strToLoad) const override { return -1; }
432-
virtual void closeAnySamplesUsingFile(const void* fileToClose) override {}
433-
virtual void setDeviceListenerPosition() override {}
434-
};
435-
436-
437386
extern AudioManager *TheAudio;

Core/GameEngine/Include/GameClient/View.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "Common/Snapshot.h"
3535
#include "Lib/BaseType.h"
3636
#include "WW3D2/coltype.h" ///< we don't generally do this, but we need the W3D collision types
37+
#include "WWMath/wwmath.h"
3738

3839
#define DEFAULT_VIEW_WIDTH 640
3940
#define DEFAULT_VIEW_HEIGHT 480
@@ -50,7 +51,9 @@ enum FilterTypes CPP_11(: Int);
5051
enum FilterModes CPP_11(: Int);
5152

5253
// ------------------------------------------------------------------------------------------------
53-
// ------------------------------------------------------------------------------------------------
54+
constexpr const Real ViewDefaultPitchRadians = DEG_TO_RADF(37.5f);
55+
constexpr const Real ViewDefaultYawRadians = DEG_TO_RADF(0.0f);
56+
5457
// ------------------------------------------------------------------------------------------------
5558
enum PickType CPP_11(: Int)
5659
{
@@ -177,8 +180,11 @@ class View : public Snapshot
177180

178181
virtual void setAngle( Real radians ); ///< Rotate the view around the vertical axis to the given angle (yaw)
179182
virtual Real getAngle() { return m_angle; } ///< Return current camera angle
183+
virtual Real getDefaultAngle() { return m_defaultAngle; } ///< Return current default camera angle
180184
virtual void setPitch( Real radians ); ///< Rotate the view around the horizontal axis to the given angle (pitch)
181185
virtual Real getPitch() { return m_pitch; } ///< Return current camera pitch
186+
virtual void setDefaultPitch( Real radians ); ///< Set new default camera pitch. It affects the camera distance to the ground
187+
virtual Real getDefaultPitch() { return m_defaultPitch; } ///< Return current default camera pitch
182188
virtual void setAngleToDefault(); ///< Set the view angle back to default
183189
virtual void setPitchToDefault(); ///< Set the view pitch back to default
184190
void setPosition( const Coord3D *pos ) { m_pos = *pos; }
@@ -199,6 +205,7 @@ class View : public Snapshot
199205
Bool userSetAngle(Real radians) { return doUserAction(&View::setAngle, radians); }
200206
Bool userSetAngleToDefault() { return doUserAction(&View::setAngleToDefault); }
201207
Bool userSetPitch(Real radians) { return doUserAction(&View::setPitch, radians); }
208+
Bool userSetDefaultPitch(Real radians) { return doUserAction(&View::setDefaultPitch, radians); }
202209
Bool userSetPitchToDefault() { return doUserAction(&View::setPitchToDefault); }
203210
Bool userZoom(Real height) { return doUserAction(&View::zoom, height); }
204211
Bool userSetZoom(Real z) { return doUserAction(&View::setZoom, z); }

Core/GameEngine/Source/Common/INI/INI.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,8 +1618,17 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList
16181618
template <typename Type>
16191619
Type scanType(std::string_view token)
16201620
{
1621-
// TheSuperHackers @info std::from_chars cannot parse "-1" as uint32 so the result needs to be int64 for integers.
1622-
std::conditional_t<std::is_integral_v<Type>, Int64, Real> result{};
1621+
DEBUG_ASSERTCRASH(!token.empty(), ("token is not expected to be empty"));
1622+
1623+
// Unlike sscanf, std::from_chars cannot parse "+".
1624+
// Consume the plus symbol to accommodate custom ini files that have numbers prefixed with a plus.
1625+
if (token[0] == '+')
1626+
{
1627+
token.remove_prefix(1);
1628+
}
1629+
1630+
// Unlike sscanf, std::from_chars cannot parse "-" as unsigned integer.
1631+
std::conditional_t<std::is_integral_v<Type>, Int64, Type> result{};
16231632
const auto [ptr, ec] = std::from_chars(token.data(), token.data() + token.size(), result);
16241633

16251634
if (ec != std::errc{})

Core/GameEngine/Source/GameClient/View.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ void View::init()
102102
m_minHeightAboveGround = TheGlobalData->m_minCameraHeight;
103103
m_okToAdjustHeight = FALSE;
104104

105-
m_defaultAngle = 0.0f;
106-
m_defaultPitch = 0.0f;
105+
m_defaultAngle = DEG_TO_RADF(TheGlobalData->m_cameraYaw);
106+
m_defaultPitch = DEG_TO_RADF(TheGlobalData->m_cameraPitch);
107+
m_angle = m_defaultAngle;
108+
m_pitch = m_defaultPitch;
107109
}
108110

109111
void View::reset()
@@ -160,13 +162,26 @@ void View::setAngle( Real radians )
160162
m_angle = WWMath::Normalize_Angle(radians);
161163
}
162164

165+
#define CLAMP_VIEW_PITCH 1
163166
/**
164167
* Rotate the view around the horizontal (X) axis to the given angle.
165168
*/
166169
void View::setPitch( Real radians )
167170
{
168-
constexpr Real limit = PI/5.0f;
169-
m_pitch = clamp(-limit, radians, limit);
171+
#if CLAMP_VIEW_PITCH
172+
m_pitch = clamp(DEG_TO_RADF(0.1f), radians, DEG_TO_RADF(89.9f));
173+
#else
174+
m_pitch = WWMath::Normalize_Angle(radians);
175+
#endif
176+
}
177+
178+
void View::setDefaultPitch( Real radians )
179+
{
180+
#if CLAMP_VIEW_PITCH
181+
m_defaultPitch = clamp(DEG_TO_RADF(0.1f), radians, DEG_TO_RADF(89.9f));
182+
#else
183+
m_defaultPitch = WWMath::Normalize_Angle(radians);
184+
#endif
170185
}
171186

172187
/**

Core/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ class MilesAudioManager : public AudioManager
137137

138138
public:
139139
#if defined(RTS_DEBUG)
140-
virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *, FILE *fp = nullptr );
141-
virtual AudioHandle addAudioEvent( const AudioEventRTS *eventToAdd ); ///< Add an audio event (event must be declared in an INI file)
140+
virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *, FILE *fp = nullptr ) override;
141+
virtual AudioHandle addAudioEvent( const AudioEventRTS *eventToAdd ) override; ///< Add an audio event (event must be declared in an INI file)
142142
#endif
143143

144144
// from AudioDevice
@@ -330,3 +330,53 @@ class MilesAudioManager : public AudioManager
330330

331331
};
332332

333+
// TheSuperHackers @feature helmutbuhler 17/05/2025 AudioManager that does almost nothing. Useful for headless mode.
334+
// @bugfix Caball009 26/03/2026 Scripts may require the actual audio file length to function properly, which is important for the CRC computation.
335+
// The Miles AudioManager handles the device opening / closure, so that getFileLengthMS can function as intended.
336+
class MilesAudioManagerDummy : public MilesAudioManager
337+
{
338+
#if defined(RTS_DEBUG)
339+
virtual void audioDebugDisplay(DebugDisplayInterface* dd, void* userData, FILE* fp) override {}
340+
#endif
341+
virtual void stopAudio(AudioAffect which) override {}
342+
virtual void pauseAudio(AudioAffect which) override {}
343+
virtual void resumeAudio(AudioAffect which) override {}
344+
virtual void pauseAmbient(Bool shouldPause) override {}
345+
virtual void killAudioEventImmediately(AudioHandle audioEvent) override {}
346+
virtual void nextMusicTrack() override {}
347+
virtual void prevMusicTrack() override {}
348+
virtual Bool isMusicPlaying() const override { return false; }
349+
virtual Bool hasMusicTrackCompleted(const AsciiString& trackName, Int numberOfTimes) const override { return false; }
350+
virtual AsciiString getMusicTrackName() const override { return ""; }
351+
//virtual void openDevice() override {}
352+
//virtual void closeDevice() override {}
353+
//virtual void* getDevice() override { return nullptr; }
354+
virtual void notifyOfAudioCompletion(UnsignedInt audioCompleted, UnsignedInt flags) override {}
355+
virtual UnsignedInt getProviderCount() const override { return 0; };
356+
virtual AsciiString getProviderName(UnsignedInt providerNum) const override { return ""; }
357+
virtual UnsignedInt getProviderIndex(AsciiString providerName) const override { return 0; }
358+
virtual void selectProvider(UnsignedInt providerNdx) override {}
359+
virtual void unselectProvider() override {}
360+
virtual UnsignedInt getSelectedProvider() const override { return 0; }
361+
virtual void setSpeakerType(UnsignedInt speakerType) override {}
362+
virtual UnsignedInt getSpeakerType() override { return 0; }
363+
virtual UnsignedInt getNum2DSamples() const override { return 0; }
364+
virtual UnsignedInt getNum3DSamples() const override { return 0; }
365+
virtual UnsignedInt getNumStreams() const override { return 0; }
366+
virtual Bool doesViolateLimit(AudioEventRTS* event) const override { return false; }
367+
virtual Bool isPlayingLowerPriority(AudioEventRTS* event) const override { return false; }
368+
virtual Bool isPlayingAlready(AudioEventRTS* event) const override { return false; }
369+
virtual Bool isObjectPlayingVoice(UnsignedInt objID) const override { return false; }
370+
virtual void adjustVolumeOfPlayingAudio(AsciiString eventName, Real newVolume) override {}
371+
virtual void removePlayingAudio(AsciiString eventName) override {}
372+
virtual void removeAllDisabledAudio() override {}
373+
virtual Bool has3DSensitiveStreamsPlaying() const override { return false; }
374+
virtual void* getHandleForBink() override { return nullptr; }
375+
virtual void releaseHandleForBink() override {}
376+
virtual void friend_forcePlayAudioEventRTS(const AudioEventRTS* eventToPlay) override {}
377+
virtual void setPreferredProvider(AsciiString providerNdx) override {}
378+
virtual void setPreferredSpeaker(AsciiString speakerType) override {}
379+
//virtual Real getFileLengthMS(AsciiString strToLoad) const override { return 0.0f; }
380+
virtual void closeAnySamplesUsingFile(const void* fileToClose) override {}
381+
virtual void setDeviceListenerPosition() override {}
382+
};

Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class W3DView : public View, public SubsystemInterface
171171

172172
virtual void setAngle( Real radians ) override; ///< Rotate the view around the vertical axis to the given angle (yaw)
173173
virtual void setPitch( Real radians ) override; ///< Rotate the view around the horizontal axis to the given angle (pitch)
174+
virtual void setDefaultPitch( Real radians ) override; ///< Set new default camera pitch. It affects the camera distance to the ground
174175
virtual void setAngleToDefault() override; ///< Set the view angle back to default
175176
virtual void setPitchToDefault() override; ///< Set the view pitch back to default
176177

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ void W3DView::buildCameraPosition( Vector3& sourcePos, Vector3& targetPos )
264264
// TheSuperHackers @info The default pitch affects the look-at distance to the target.
265265
// This is strange math which would need special attention when changed.
266266
sourcePos.Z = getCameraOffsetZ();
267-
sourcePos.Y = -(sourcePos.Z / tan(TheGlobalData->m_cameraPitch * (PI / 180.0)));
268-
sourcePos.X = -(sourcePos.Y * tan(TheGlobalData->m_cameraYaw * (PI / 180.0)));
267+
sourcePos.Y = -(sourcePos.Z / tan(ViewDefaultPitchRadians));
268+
sourcePos.X = -(sourcePos.Y * tan(ViewDefaultYawRadians));
269269

270270
// set position of camera itself
271271
if (m_useRealZoomCam) //WST 10/10/2002 Real Zoom using FOV
@@ -285,13 +285,15 @@ void W3DView::buildCameraPosition( Vector3& sourcePos, Vector3& targetPos )
285285
targetPos.Y = 0;
286286
targetPos.Z = 0;
287287

288+
// TheSuperHackers @info Scales the source position later by this much
289+
// to achieve the intended camera height. Must not scale before pitching!
288290
const Real heightScale = 1.0f - (groundLevel / sourcePos.Z);
289291

290292
// construct a matrix to rotate around the up vector by the given angle
291-
const Matrix3D angleTransform( Vector3( 0.0f, 0.0f, 1.0f ), angle );
293+
const Matrix3D angleTransform( Vector3( 0.0f, 0.0f, 1.0f ), angle - ViewDefaultYawRadians );
292294

293295
// construct a matrix to rotate around the left vector by the given angle
294-
const Matrix3D pitchTransform( Vector3( -1.0f, 0.0f, 0.0f ), pitch );
296+
const Matrix3D pitchTransform( Vector3( -1.0f, 0.0f, 0.0f ), pitch - ViewDefaultPitchRadians );
295297

296298
// rotate camera position (pitch, then angle)
297299
#ifdef ALLOW_TEMPORARIES
@@ -2067,6 +2069,16 @@ void W3DView::setPitch( Real radians )
20672069
m_recalcCamera = true;
20682070
}
20692071

2072+
//-------------------------------------------------------------------------------------------------
2073+
//-------------------------------------------------------------------------------------------------
2074+
void W3DView::setDefaultPitch( Real radians )
2075+
{
2076+
View::setDefaultPitch( radians );
2077+
2078+
m_cameraAreaConstraintsValid = false;
2079+
m_recalcCamera = true;
2080+
}
2081+
20702082
//-------------------------------------------------------------------------------------------------
20712083
/** Set the view angle back to default */
20722084
//-------------------------------------------------------------------------------------------------
@@ -2098,7 +2110,7 @@ void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight)
20982110
{
20992111
// MDC - we no longer want to rotate maps (design made all of them right to begin with)
21002112
// m_defaultAngle = angle * M_PI/180.0f;
2101-
m_defaultPitch = pitch;
2113+
setDefaultPitch(pitch);
21022114
m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight*maxHeight;
21032115
if (m_minHeightAboveGround > m_maxHeightAboveGround)
21042116
m_maxHeightAboveGround = m_minHeightAboveGround;

Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ set(WW3D2_SRC
4343
distlod.cpp
4444
distlod.h
4545
dllist.h
46-
#dx8caps.cpp
47-
#dx8caps.h
46+
dx8caps.cpp
47+
dx8caps.h
4848
#dx8fvf.cpp
4949
#dx8fvf.h
5050
#dx8indexbuffer.cpp
@@ -62,8 +62,8 @@ set(WW3D2_SRC
6262
#dx8vertexbuffer.h
6363
dx8webbrowser.cpp
6464
dx8webbrowser.h
65-
#dx8wrapper.cpp
66-
#dx8wrapper.h
65+
dx8wrapper.cpp
66+
dx8wrapper.h
6767
dynamesh.cpp
6868
dynamesh.h
6969
font3d.cpp
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)