Skip to content

Commit 921f829

Browse files
committed
[GEN] Backports ZH additions
1 parent 3feb3fc commit 921f829

File tree

82 files changed

+1573
-101
lines changed

Some content is hidden

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

82 files changed

+1573
-101
lines changed

Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,10 @@ class ArchiveFileSystem : public SubsystemInterface
172172

173173
// Unprotected this for copy-protection routines
174174
AsciiString getArchiveFilenameForFile(const AsciiString& filename) const;
175-
176175
void loadMods( void );
177176

178177
protected:
179-
virtual void loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite = FALSE); ///< load the archive file's header information and apply it to the global archive directory tree.
178+
virtual void loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite = FALSE ); ///< load the archive file's header information and apply it to the global archive directory tree.
180179

181180
ArchiveFileMap m_archiveFileMap;
182181
ArchivedDirectoryInfo m_rootDirectory;

Generals/Code/GameEngine/Include/Common/BitFlagsIO.h

+12
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ template <size_t NUMBITS>
138138
((BitFlags*)store)->parse(ini, NULL);
139139
}
140140

141+
//-------------------------------------------------------------------------------------------------
142+
//-------------------------------------------------------------------------------------------------
143+
template <size_t NUMBITS>
144+
/*static*/ void BitFlags<NUMBITS>::parseSingleBitFromINI(INI* ini, void* /*instance*/, void *store, const void* /*userData*/)
145+
{
146+
const char *token = ini->getNextToken();
147+
Int bitIndex = INI::scanIndexList(token, s_bitNameList); // this throws if the token is not found
148+
149+
Int *storeAsInt = (Int*)store;
150+
*storeAsInt = bitIndex;
151+
}
152+
141153
//-------------------------------------------------------------------------------------------------
142154
/** Xfer method
143155
* Version Info:

Generals/Code/GameEngine/Include/Common/DataChunk.h

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class DataChunkOutput
136136
void writeUnicodeString(UnicodeString string);
137137
void writeArrayOfBytes(char *ptr, Int len);
138138
void writeDict(const Dict& d);
139+
void writeNameKey(const NameKeyType key);
139140
};
140141

141142
//----------------------------------------------------------------------
@@ -228,6 +229,8 @@ class DataChunkInput
228229
UnicodeString readUnicodeString(void);
229230
Dict readDict(void);
230231
void readArrayOfBytes(char *ptr, Int len);
232+
233+
NameKeyType readNameKey(void);
231234
};
232235

233236

Generals/Code/GameEngine/Include/Common/Energy.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Energy : public Snapshot
6666

6767
public:
6868

69-
inline Energy() : m_energyProduction(0), m_energyConsumption(0), m_owner(NULL) { }
69+
Energy();
7070

7171
// reset energy information to base values.
7272
void init( Player *owner)
@@ -77,7 +77,7 @@ class Energy : public Snapshot
7777
}
7878

7979
/// return current energy production in kilowatts
80-
Int getProduction() const { return m_energyProduction; }
80+
Int getProduction() const;
8181

8282
/// return current energy consumption in kilowatts
8383
Int getConsumption() const { return m_energyConsumption; }

Generals/Code/GameEngine/Include/Common/GameAudio.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ class AudioManager : public SubsystemInterface
152152
virtual void resumeAudio( AudioAffect which ) = 0;
153153
virtual void pauseAmbient( Bool shouldPause ) = 0;
154154

155-
// device dependent stops.
156-
virtual void stopAllAmbientsBy( Object* obj ) = 0;
157-
virtual void stopAllAmbientsBy( Drawable* draw ) = 0;
158-
159155
// for focus issues
160156
virtual void loseFocus( void );
161157
virtual void regainFocus( void );
@@ -240,6 +236,8 @@ class AudioManager : public SubsystemInterface
240236
// on zoom.
241237
virtual void set3DVolumeAdjustment( Real volumeAdjustment );
242238

239+
virtual Bool has3DSensitiveStreamsPlaying( void ) const = 0;
240+
243241
virtual void *getHandleForBink( void ) = 0;
244242
virtual void releaseHandleForBink( void ) = 0;
245243

@@ -257,6 +255,7 @@ class AudioManager : public SubsystemInterface
257255
virtual void processRequestList( void );
258256

259257
virtual AudioEventInfo *newAudioEventInfo( AsciiString newEventName );
258+
virtual void addAudioEventInfo( AudioEventInfo * newEventInfo );
260259
virtual AudioEventInfo *findAudioEventInfo( AsciiString eventName ) const;
261260

262261
const AudioSettings *getAudioSettings( void ) const;
@@ -298,6 +297,7 @@ class AudioManager : public SubsystemInterface
298297

299298
// For Worldbuilder, to build lists from which to select
300299
virtual void findAllAudioEventsOfType( AudioType audioType, std::vector<AudioEventInfo*>& allEvents );
300+
virtual const AudioEventInfoHash & getAllAudioEvents() const { return m_allAudioEventInfo; }
301301

302302
Real getZoomVolume() const { return m_zoomVolume; }
303303
protected:
@@ -316,7 +316,9 @@ class AudioManager : public SubsystemInterface
316316

317317
// For tracking purposes
318318
virtual AudioHandle allocateNewHandle( void );
319-
319+
320+
void removeAllAudioRequests( void );
321+
320322
protected:
321323
AudioSettings *m_audioSettings;
322324
MiscAudio *m_miscAudio;

Generals/Code/GameEngine/Include/Common/GameType.h

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ enum FormationID CPP_11(: Int)
5858
FORCE_FORMATIONID_TO_LONG_SIZE = 0x7ffffff
5959
};
6060

61+
#define INVALID_ANGLE -100.0f
62+
6163
class INI;
6264

6365
//-------------------------------------------------------------------------------------------------

Generals/Code/GameEngine/Include/Common/Geometry.h

+1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class GeometryInfo : public Snapshot
179179

180180
/// note that the pt is generated using game logic random, not game client random!
181181
void makeRandomOffsetWithinFootprint(Coord3D& pt) const;
182+
void makeRandomOffsetOnPerimeter(Coord3D& pt) const; //Chooses a random point on the extent border.
182183

183184
void clipPointToFootprint(const Coord3D& geomCenter, Coord3D& ptToClip) const;
184185

Generals/Code/GameEngine/Include/Common/Money.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,15 @@ class Money : public Snapshot
8282

8383
void setPlayerIndex(Int ndx) { m_playerIndex = ndx; }
8484

85-
protected:
85+
static void parseMoneyAmount( INI *ini, void *instance, void *store, const void* userData );
86+
87+
// Does the amount of this == the amount of that (compare everything except m_playerIndex)
88+
Bool amountEqual( const Money & that ) const
89+
{
90+
return m_money == that.m_money;
91+
}
8692

93+
protected:
8794
// snapshot methods
8895
virtual void crc( Xfer *xfer );
8996
virtual void xfer( Xfer *xfer );

Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ class MultiplayerSettings : public SubsystemInterface
7979

8080
MultiplayerSettings( void );
8181

82-
void init() { }
83-
void update() { }
84-
void reset() { }
82+
virtual void init() { }
83+
virtual void update() { }
84+
virtual void reset() { }
8585

8686
//-----------------------------------------------------------------------------------------------
8787
static const FieldParse m_multiplayerSettingsFieldParseTable[]; ///< the parse table for INI definition

Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h

+5
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,11 @@ class NameKeyGenerator : public SubsystemInterface
9696

9797
/// Given a string, convert into a unique integer key.
9898
NameKeyType nameToKey(const AsciiString& name) { return nameToKey(name.str()); }
99+
NameKeyType nameToLowercaseKey(const AsciiString& name) { return nameToLowercaseKey(name.str()); }
99100

100101
/// Given a string, convert into a unique integer key.
101102
NameKeyType nameToKey(const char* name);
103+
NameKeyType nameToLowercaseKey(const char *name);
102104

103105
/**
104106
given a key, return the name. this is almost never needed,
@@ -108,6 +110,9 @@ class NameKeyGenerator : public SubsystemInterface
108110
*/
109111
AsciiString keyToName(NameKeyType key);
110112

113+
// Get a string out of the INI. Store it into a NameKeyType
114+
static void parseStringAsNameKeyType( INI *ini, void *instance, void *store, const void* userData );
115+
111116
private:
112117

113118
enum

Generals/Code/GameEngine/Include/Common/Radar.h

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class Radar : public Snapshot,
169169
Bool isRadarWindow( GameWindow *window ) { return (m_radarWindow == window) && (m_radarWindow != NULL); }
170170

171171
Bool radarToWorld( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point on terrain
172+
Bool radarToWorld2D( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point (x,y only!)
172173
Bool worldToRadar( const Coord3D *world, ICoord2D *radar ); ///< translate world point to radar (x,y)
173174
Bool localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ); ///< translate pixel (with UL of radar being (0,0)) to logical radar coords
174175
Bool screenPixelToWorld( const ICoord2D *pixel, Coord3D *world ); ///< translate pixel (with UL of the screen being (0,0)) to world position in the world

Generals/Code/GameEngine/Include/Common/ScopedMutex.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class ScopedMutex
3434
public:
3535
ScopedMutex(HANDLE mutex) : m_mutex(mutex)
3636
{
37-
WaitForSingleObject(m_mutex, INFINITE);
37+
DWORD status = WaitForSingleObject(m_mutex, 500);
38+
if (status != WAIT_OBJECT_0) {
39+
DEBUG_LOG(("ScopedMutex WaitForSingleObject timed out - status %d\n", status));
40+
}
3841
}
3942

4043
~ScopedMutex()

Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h

+20
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ class SparseMatchFinder
7272
}
7373
};
7474

75+
struct MapHelper
76+
{
77+
bool operator()(const BITSET& a, const BITSET& b) const
78+
{
79+
int i;
80+
if (a.size() < b.size()) {
81+
return true;
82+
}
83+
for (i = 0; i < a.size(); ++i) {
84+
bool aVal = a.test(i);
85+
bool bVal = b.test(i);
86+
if (aVal && bVal) continue;
87+
if (!aVal && !bVal) continue;
88+
if (!aVal) return true;
89+
return false;
90+
}
91+
return false; // all bits match.
92+
}
93+
};
94+
7595
//-------------------------------------------------------------------------------------------------
7696
typedef std::hash_map< BITSET, const MATCHABLE*, HashMapHelper, HashMapHelper > MatchMap;
7797

Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define __SPECIALPOWERMASKTYPE_H__
3232

3333
#include "Common/BitFlags.h"
34+
#include "Common/BitFlagsIO.h"
3435
#include "Common/SpecialPowerType.h"
3536

3637
typedef BitFlags<SPECIALPOWER_COUNT> SpecialPowerMaskType;

Generals/Code/GameEngine/Include/Common/StateMachine.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class State;
4545
class StateMachine;
4646
class Object;
4747

48-
#undef STATE_MACHINE_DEBUG
48+
//#undef STATE_MACHINE_DEBUG
4949
#if defined(_DEBUG)
5050
#define STATE_MACHINE_DEBUG
5151
#endif
@@ -169,6 +169,7 @@ class State : public MemoryPoolObject, public Snapshot
169169

170170
#ifdef STATE_MACHINE_DEBUG
171171
virtual AsciiString getName() const {return m_name;}
172+
std::vector<StateID> *getTransitions(void);
172173
#endif
173174

174175
// for internal use by the StateMachine class ---------------------------------------------------------

Generals/Code/GameEngine/Include/Common/Xfer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#define __XFER_H_
4444

4545
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
46-
#include "Common/ModelState.h"
4746
#include "Common/Science.h"
4847
#include "Common/Upgrade.h"
4948

@@ -171,6 +170,7 @@ class Xfer
171170
virtual void xferRGBAColorInt( RGBAColorInt *rgbaColorInt );
172171
virtual void xferObjectID( ObjectID *objectID );
173172
virtual void xferDrawableID( DrawableID *drawableID );
173+
virtual void xferSTLObjectIDVector( std::vector<ObjectID> *objectIDVectorData );
174174
virtual void xferSTLObjectIDList( std::list< ObjectID > *objectIDListData );
175175
virtual void xferSTLIntList( std::list< Int > *intListData );
176176
virtual void xferScienceType( ScienceType *science );

Generals/Code/GameEngine/Include/Common/crc.h

+76
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#define _CRC_H_
3333

3434
#include "Lib/BaseType.h"
35+
36+
#ifdef _DEBUG
37+
3538
//#include "winsock2.h" // for htonl
3639

3740
class CRC
@@ -50,4 +53,77 @@ class CRC
5053
UnsignedInt crc;
5154
};
5255

56+
#else
57+
58+
// optimized inline only version
59+
class CRC
60+
{
61+
public:
62+
CRC(void) { crc=0; }
63+
64+
/// Compute the CRC for a buffer, added into current CRC
65+
__forceinline void computeCRC( const void *buf, Int len )
66+
{
67+
if (!buf||len<1)
68+
return;
69+
70+
#if !(defined(_MSC_VER) && _MSC_VER < 1300)
71+
// C++ version left in for reference purposes
72+
for (UnsignedByte *uintPtr=(UnsignedByte *)buf;len>0;len--,uintPtr++)
73+
{
74+
int hibit;
75+
if (crc & 0x80000000)
76+
{
77+
hibit = 1;
78+
}
79+
else
80+
{
81+
hibit = 0;
82+
}
83+
84+
crc <<= 1;
85+
crc += *uintPtr;
86+
crc += hibit;
87+
}
88+
#else
89+
// ASM version, verified by comparing resulting data with C++ version data
90+
unsigned *crcPtr=&crc;
91+
_asm
92+
{
93+
mov esi,[buf]
94+
mov ecx,[len]
95+
dec ecx
96+
mov edi,[crcPtr]
97+
mov ebx,dword ptr [edi]
98+
xor eax,eax
99+
lp:
100+
mov al,byte ptr [esi]
101+
shl ebx,1
102+
inc esi
103+
adc ebx,eax
104+
dec ecx
105+
jns lp
106+
mov dword ptr [edi],ebx
107+
};
108+
#endif
109+
}
110+
111+
/// Clears the CRC to 0
112+
void clear( void )
113+
{
114+
crc = 0;
115+
}
116+
117+
///< Get the combined CRC
118+
UnsignedInt get( void ) const
119+
{
120+
return crc;
121+
}
122+
123+
private:
124+
UnsignedInt crc;
125+
};
126+
127+
#endif
128+
53129
#endif // _CRC_H_

Generals/Code/GameEngine/Include/GameClient/Color.h

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ extern void GameGetColorComponents( Color color,
7676
UnsignedByte *green,
7777
UnsignedByte *blue,
7878
UnsignedByte *alpha );
79+
80+
// Put on ice until later - M Lorenzen
81+
//extern void GameGetColorComponentsWithCheatSpy( Color color,
82+
// UnsignedByte *red,
83+
// UnsignedByte *green,
84+
// UnsignedByte *blue,
85+
// UnsignedByte *alpha );
86+
87+
7988
extern void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha );
8089

8190
extern Color GameDarkenColor( Color color, Int percent = 10 );

0 commit comments

Comments
 (0)