Skip to content

Commit 035624e

Browse files
authored
[GEN] Backport several GameEngine additions from Zero Hour (#752)
1 parent 7d884ad commit 035624e

File tree

74 files changed

+1418
-95
lines changed

Some content is hidden

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

74 files changed

+1418
-95
lines changed

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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ class AudioManager : public SubsystemInterface
316316

317317
// For tracking purposes
318318
virtual AudioHandle allocateNewHandle( void );
319-
320319
// Remove all AudioEventInfo's with the m_isLevelSpecific flag
321320
virtual void removeLevelSpecificAudioEventInfos( void );
322321

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 8 additions & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

0 commit comments

Comments
 (0)