Skip to content

Commit 0215e09

Browse files
committed
2 parents c7891b2 + 471dc26 commit 0215e09

654 files changed

Lines changed: 4269 additions & 5821 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/INI.h

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,11 @@ typedef void (*BuildMultiIniFieldProc)(MultiIniFieldParse& p);
160160
//-------------------------------------------------------------------------------------------------
161161
class INI
162162
{
163-
INI(const INI&);
164-
INI& operator=(const INI&);
163+
INI(const INI&) CPP_11(= delete);
164+
INI& operator=(const INI&) CPP_11(= delete);
165165

166166
public:
167-
168167
INI();
169-
~INI();
170168

171169
// TheSuperHackers @feature xezon 19/08/2025
172170
// Load a specific INI file by name and/or INI files from a directory (and its subdirectories).
@@ -251,11 +249,12 @@ class INI
251249
AsciiString getFilename() const { return m_filename; }
252250
INILoadType getLoadType() const { return m_loadType; }
253251
UnsignedInt getLineNum() const { return m_lineNum; }
254-
const char *getSeps() const { return m_seps; }
255-
const char *getSepsPercent() const { return m_sepsPercent; }
256-
const char *getSepsColon() const { return m_sepsColon; }
257-
const char *getSepsQuote() { return m_sepsQuote; }
258252
Bool isEOF() const { return m_endOfFile; }
253+
static const char *getSeps() { return " \n\r\t="; } ///< default delimiters for strtok parsing
254+
static const char *getSepsPercent() { return " \n\r\t=%%"; } ///< default delimiters & percent delimiter
255+
static const char *getSepsColon() { return " \n\r\t=:"; } ///< default delimiters & colon delimiter
256+
static const char *getSepsQuote() { return "\"\n="; } ///< delimiters to represent a quoted ascii string
257+
static const char *getEndToken() { return "End"; } ///< token to represent an end of data block
259258

260259
void initFromINI( void *what, const FieldParse* parseTable );
261260
void initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList );
@@ -321,20 +320,19 @@ class INI
321320
static void parseVeterancyLevelFlags(INI* ini, void* instance, void* store, const void* userData);
322321
static void parseSoundsList( INI* ini, void *instance, void *store, const void* /*userData*/ );
323322

324-
325323
/**
326-
return the next token. if seps is null (or omitted), the standard seps are used.
324+
return the next token. if seps is not specified, the standard seps are used.
327325
328326
this will *never* return null; if there are no more tokens, an exception will be thrown.
329327
*/
330-
const char* getNextToken(const char* seps = nullptr);
328+
static const char* getNextToken(const char* seps = getSeps());
331329

332330
/**
333331
just like getNextToken(), except that null is returned if no more tokens are present
334332
(rather than throwing an exception). usually you should call getNextToken(),
335333
but for some cases this is handier (ie, parsing a variable-length number of tokens).
336334
*/
337-
const char* getNextTokenOrNull(const char* seps = nullptr);
335+
static const char* getNextTokenOrNull(const char* seps = getSeps());
338336

339337
/**
340338
This is called when the next thing you expect is something like:
@@ -346,7 +344,7 @@ class INI
346344
347345
If "Tag" is not the next token, an error is thrown.
348346
*/
349-
const char* getNextSubToken(const char* expected);
347+
static const char* getNextSubToken(const char* expected);
350348

351349
/**
352350
return the next ascii string. this is usually the same the result of getNextToken(),
@@ -400,14 +398,9 @@ class INI
400398
unsigned m_readBufferUsed; ///< number of bytes in read buffer
401399

402400
AsciiString m_filename; ///< filename of file currently loading
403-
INILoadType m_loadType; ///< load time for current file
401+
INILoadType m_loadType; ///< load type for current file
404402
UnsignedInt m_lineNum; ///< current line number that's been read
405403
char m_buffer[ INI_MAX_CHARS_PER_LINE+1 ];///< buffer to read file contents into
406-
const char *m_seps; ///< for strtok parsing
407-
const char *m_sepsPercent; ///< m_seps with percent delimiter as well
408-
const char *m_sepsColon; ///< m_seps with colon delimiter as well
409-
const char *m_sepsQuote; ///< token to represent a quoted ascii string
410-
const char *m_blockEndToken; ///< token to represent end of data block
411404
Bool m_endOfFile; ///< TRUE when we've hit EOF
412405
#ifdef DEBUG_CRASHING
413406
char m_curBlockStart[ INI_MAX_CHARS_PER_LINE+1 ]; ///< first line of cur block

Core/GameEngine/Include/GameClient/View.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ class View : public Snapshot
187187
virtual Real getDefaultPitch() { return m_defaultPitch; } ///< Return current default camera pitch
188188
virtual void setAngleToDefault(); ///< Set the view angle back to default
189189
virtual void setPitchToDefault(); ///< Set the view pitch back to default
190-
void setPosition( const Coord3D *pos ) { m_pos = *pos; }
191-
void getPosition(Coord3D *pos) { *pos = m_pos;} ///< Returns position camera is looking at (z will be zero)
190+
void setPosition( const Coord3D &pos ) { m_pos = pos; }
191+
void setPosition2D( const Coord2D &pos ) { m_pos.x = pos.x; m_pos.y = pos.y; }
192+
const Coord3D &getPosition() const { return m_pos; } ///< Returns position camera is looking at
193+
Coord2D getPosition2D() const { Coord2D c = { m_pos.x, m_pos.y }; return c; } ///< Returns position camera is looking at
192194

193195
virtual const Coord3D& get3DCameraPosition() const = 0; ///< Returns the actual camera position
194196

@@ -201,7 +203,7 @@ class View : public Snapshot
201203
virtual void setOkToAdjustHeight( Bool val ) { m_okToAdjustHeight = val; } ///< Set this to adjust camera height
202204

203205
// TheSuperHackers @info Functions to call for user camera controls, not by the scripted camera.
204-
Bool userSetPosition(const Coord3D *pos) { return doUserAction(&View::setPosition, pos); }
206+
Bool userSetPosition(const Coord3D &pos) { return doUserAction(&View::setPosition, pos); }
205207
Bool userSetAngle(Real radians) { return doUserAction(&View::setAngle, radians); }
206208
Bool userSetAngleToDefault() { return doUserAction(&View::setAngleToDefault); }
207209
Bool userSetPitch(Real radians) { return doUserAction(&View::setPitch, radians); }
@@ -219,6 +221,8 @@ class View : public Snapshot
219221
Bool userSetCameraLockDrawable(Drawable *drawable) { return doUserAction(&View::setCameraLockDrawable, drawable); }
220222

221223
void lockUserControlUntilFrame(UnsignedInt frame) { m_userControlLockedUntilFrame = frame; } ///< Locks the user control over camera until the given frame is reached.
224+
225+
virtual void setUserControlled(Bool value) { m_isUserControlled = value; }
222226
Bool isUserControlLocked() const;
223227

224228
// for debugging
@@ -268,13 +272,9 @@ class View : public Snapshot
268272
virtual void xfer( Xfer *xfer ) override;
269273
virtual void loadPostProcess() override { }
270274

271-
const Coord3D *getPosition() const { return &m_pos; }
272-
273275
virtual View *prependViewToList( View *list ); ///< Prepend this view to the given list, return the new list
274276
virtual View *getNextView() { return m_next; } ///< Return next view in the set
275277

276-
virtual void setUserControlled(Bool value) { m_isUserControlled = value; }
277-
278278
private:
279279

280280
template<typename Function>
@@ -309,7 +309,7 @@ class View : public Snapshot
309309
UnsignedInt m_userControlLockedUntilFrame; ///< Locks the user control over camera until the given frame is reached
310310
Bool m_isUserControlled; ///< True if the user moved the camera last, false if the scripted camera moved the camera last
311311

312-
Coord3D m_pos; ///< Pivot of the camera, in world coordinates // TheSuperHackers @todo Make this Coord2D or use the Z component
312+
Coord3D m_pos; ///< Pivot of the camera, in world coordinates
313313
Int m_width, m_height; ///< Dimensions of the view
314314
Int m_originX, m_originY; ///< Location of top/left view corner
315315

@@ -363,12 +363,10 @@ class ViewLocation
363363
Real getPitch() const { return m_pitch; }
364364
Real getZoom() const { return m_zoom; }
365365

366-
void init(Real x, Real y, Real z, Real angle, Real pitch, Real zoom)
366+
void init(Coord3D pos, Real angle, Real pitch, Real zoom)
367367
{
368368
m_valid = true;
369-
m_pos.x = x;
370-
m_pos.y = y;
371-
m_pos.z = z;
369+
m_pos = pos;
372370
m_angle = angle;
373371
m_pitch = pitch;
374372
m_zoom = zoom;
@@ -408,8 +406,8 @@ class ViewDummy : public View
408406
}
409407
virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world ) override {}
410408
virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ) override {}
411-
virtual void drawView( void ) override {}
412-
virtual void updateView(void) override {}
409+
virtual void drawView() override {}
410+
virtual void updateView() override {}
413411
virtual void stepView() override {}
414412
virtual void setGuardBandBias( const Coord2D *gb ) override {}
415413
virtual Bool isDoingScriptedCamera() override { return false; }

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,16 @@ void AudioManager::reset()
282282
//-------------------------------------------------------------------------------------------------
283283
void AudioManager::update()
284284
{
285-
Coord3D groundPos, microphonePos;
286-
TheTacticalView->getPosition( &groundPos );
285+
Coord3D cameraPivot = TheTacticalView->getPosition();
287286
Real angle = TheTacticalView->getAngle();
288287
Matrix3D rot = Matrix3D::Identity;
289288
rot.Rotate_Z( angle );
290289
Vector3 forward( 0, 1, 0 );
291290
rot.mulVector3( forward );
292291

293-
Real desiredHeight = m_audioSettings->m_microphoneDesiredHeightAboveTerrain;
294-
Real maxPercentage = m_audioSettings->m_microphoneMaxPercentageBetweenGroundAndCamera;
292+
const Real desiredHeightRel = m_audioSettings->m_microphoneDesiredHeightAboveTerrain;
293+
const Real desiredHeightAbs = desiredHeightRel + cameraPivot.z;
294+
const Real maxPercentage = m_audioSettings->m_microphoneMaxPercentageBetweenGroundAndCamera;
295295

296296
Coord3D lookTo;
297297
lookTo.set(forward.X, forward.Y, forward.Z);
@@ -303,18 +303,18 @@ void AudioManager::update()
303303
Coord3D cameraPos = TheTacticalView->get3DCameraPosition();
304304
Coord3D groundToCameraVector;
305305
groundToCameraVector.set( &cameraPos );
306-
groundToCameraVector.sub( &groundPos );
306+
groundToCameraVector.sub( &cameraPivot );
307307
Real bestScaleFactor;
308308

309-
if( cameraPos.z <= desiredHeight || groundToCameraVector.z <= 0.0f )
309+
if( cameraPos.z <= desiredHeightAbs || groundToCameraVector.z <= 0.0f )
310310
{
311311
//Use the percentage calculation!
312312
bestScaleFactor = maxPercentage;
313313
}
314314
else
315315
{
316316
//Calculate the stopping position of the groundToCameraVector when we force z to be m_microphoneDesiredHeightAboveTerrain
317-
Real zScale = desiredHeight / groundToCameraVector.z;
317+
Real zScale = desiredHeightRel / groundToCameraVector.z;
318318

319319
//Use the smallest of the two scale calculations
320320
bestScaleFactor = MIN( maxPercentage, zScale );
@@ -324,8 +324,8 @@ void AudioManager::update()
324324
groundToCameraVector.scale( bestScaleFactor );
325325

326326
//Set the microphone to be the ground position adjusted for terrain plus the vector we just calculated.
327-
groundPos.z = TheTerrainLogic->getGroundHeight( groundPos.x, groundPos.y );
328-
microphonePos.set( &groundPos );
327+
Coord3D microphonePos;
328+
microphonePos.set( &cameraPivot );
329329
microphonePos.add( &groundToCameraVector );
330330

331331
//Viola! A properly placed microphone.

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

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,14 @@ INI::INI()
180180
m_filename = "None";
181181
m_loadType = INI_LOAD_INVALID;
182182
m_lineNum = 0;
183-
m_seps = " \n\r\t="; ///< make sure you update m_sepsPercent/m_sepsColon as well
184-
m_sepsPercent = " \n\r\t=%%";
185-
m_sepsColon = " \n\r\t=:";
186-
m_sepsQuote = "\"\n="; ///< stop at " = EOL
187-
m_blockEndToken = "END";
188-
m_endOfFile = FALSE;
189183
m_buffer[0] = 0;
184+
m_endOfFile = FALSE;
190185
#ifdef DEBUG_CRASHING
191186
m_curBlockStart[0] = 0;
192187
#endif
193188

194189
}
195190

196-
//-------------------------------------------------------------------------------------------------
197-
//-------------------------------------------------------------------------------------------------
198-
INI::~INI()
199-
{
200-
201-
}
202-
203191
//-------------------------------------------------------------------------------------------------
204192
UnsignedInt INI::loadFileDirectory( AsciiString fileDirName, INILoadType loadType, Xfer *pXfer, Bool subdirs )
205193
{
@@ -397,7 +385,7 @@ UnsignedInt INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer )
397385
AsciiString currentLine = m_buffer;
398386

399387
// the first word is the type of data we're processing
400-
const char *token = strtok( m_buffer, m_seps );
388+
const char *token = strtok( m_buffer, getSeps() );
401389
if( token )
402390
{
403391
INIBlockParse parse = findBlockParse(token);
@@ -710,7 +698,7 @@ void INI::parseAsciiStringVector( INI* ini, void * /*instance*/, void *store, co
710698
{
711699
std::vector<AsciiString>* asv = (std::vector<AsciiString>*)store;
712700
asv->clear();
713-
for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
701+
for (const char *token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
714702
{
715703
asv->push_back(token);
716704
}
@@ -723,7 +711,7 @@ void INI::parseAsciiStringVectorAppend( INI* ini, void * /*instance*/, void *sto
723711
std::vector<AsciiString>* asv = (std::vector<AsciiString>*)store;
724712
// nope, don't clear. duh.
725713
// asv->clear();
726-
for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
714+
for (const char *token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
727715
{
728716
asv->push_back(token);
729717
}
@@ -735,7 +723,7 @@ void INI::parseAsciiStringVectorAppend( INI* ini, void * /*instance*/, void *sto
735723
{
736724
ScienceVec* asv = (ScienceVec*)store;
737725
asv->clear();
738-
for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
726+
for (const char *token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
739727
{
740728
if (stricmp(token, "None") == 0)
741729
{
@@ -952,7 +940,7 @@ void INI::parseBitString32( INI* ini, void * /*instance*/, void *store, const vo
952940
Bool foundAddOrSub = false;
953941

954942
// loop through all tokens
955-
for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull())
943+
for (const char *token = ini->getNextTokenOrNull(); token; token = ini->getNextTokenOrNull())
956944
{
957945
if (stricmp(token, "NONE") == 0)
958946
{
@@ -1528,7 +1516,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList
15281516
if( field )
15291517
{
15301518

1531-
if( stricmp( field, m_blockEndToken ) == 0 )
1519+
if( stricmp( field, getEndToken() ) == 0 )
15321520
{
15331521
done = TRUE;
15341522
}
@@ -1580,7 +1568,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList
15801568

15811569
done = TRUE;
15821570
DEBUG_CRASH( ("Error parsing block '%s', in INI file '%s'. Missing '%s' token",
1583-
m_curBlockStart, getFilename().str(), m_blockEndToken) );
1571+
m_curBlockStart, getFilename().str(), getEndToken()) );
15841572
throw INI_MISSING_END_TOKEN;
15851573

15861574
}
@@ -1592,7 +1580,6 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList
15921580
//-------------------------------------------------------------------------------------------------
15931581
/*static*/ const char* INI::getNextToken(const char* seps)
15941582
{
1595-
if (!seps) seps = getSeps();
15961583
const char *token = ::strtok(nullptr, seps);
15971584
if (!token)
15981585
throw INI_INVALID_DATA;
@@ -1602,7 +1589,6 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList
16021589
//-------------------------------------------------------------------------------------------------
16031590
/*static*/ const char* INI::getNextTokenOrNull(const char* seps)
16041591
{
1605-
if (!seps) seps = getSeps();
16061592
const char *token = ::strtok(nullptr, seps);
16071593
return token;
16081594
}
@@ -1876,12 +1862,10 @@ void INI::parseSoundsList( INI* ini, void *instance, void *store, const void* /*
18761862
std::vector<AsciiString> *vec = (std::vector<AsciiString>*) store;
18771863
vec->clear();
18781864

1879-
const char* SEPS = " \t,=";
1880-
const char *c = ini->getNextTokenOrNull(SEPS);
1881-
while ( c )
1865+
constexpr const char* Seps = " \t,=";
1866+
for (const char* token = ini->getNextTokenOrNull(Seps); token; token = ini->getNextTokenOrNull(Seps))
18821867
{
1883-
vec->push_back( c );
1884-
c = ini->getNextTokenOrNull(SEPS);
1868+
vec->push_back(token);
18851869
}
18861870
}
18871871

Core/GameEngine/Source/GameClient/GUI/GameWindow.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,6 @@ void GameWinDefaultTooltip( GameWindow *window,
15791579
WinInstanceData *instData,
15801580
UnsignedInt mouse )
15811581
{
1582-
return;
15831582

15841583
}
15851584

@@ -1589,8 +1588,6 @@ void GameWinDefaultTooltip( GameWindow *window,
15891588
void GameWinDefaultDraw( GameWindow *window, WinInstanceData *instData )
15901589
{
15911590

1592-
return;
1593-
15941591
}
15951592

15961593
// GameWindow::winSetEnabledImage =============================================

Core/GameEngine/Source/GameClient/Input/Mouse.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ void Mouse::createStreamMessages()
824824
{
825825
msg = TheMessageStream->appendMessage( GameMessage::MSG_RAW_MOUSE_WHEEL );
826826
msg->appendPixelArgument( m_currMouse.pos );
827-
msg->appendIntegerArgument( m_currMouse.wheelPos / 120 ); // wheel delta
827+
// TheSuperHackers @bugfix Use float wheel delta to preserve fractional values from touchpad input
828+
msg->appendRealArgument( m_currMouse.wheelPos / (Real)MOUSE_WHEEL_DELTA );
828829
msg->appendIntegerArgument( TheKeyboard->getModifierFlags() );
829830
}
830831

Core/GameEngine/Source/GameClient/System/ParticleSys.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,6 +3384,8 @@ void ParticleSystemManager::xfer( Xfer *xfer )
33843384
}
33853385
else
33863386
{
3387+
DEBUG_ASSERTCRASH(m_allParticleSystemList.empty(), ("ParticleSystemManager: particle systems list is expected empty at start of xfer-load."));
3388+
33873389
const ParticleSystemTemplate *systemTemplate;
33883390

33893391
// read each particle system

0 commit comments

Comments
 (0)