Skip to content

Commit 88bdc16

Browse files
committed
[GEN] Backports ZH additions
1 parent 1597a1d commit 88bdc16

File tree

126 files changed

+2337
-275
lines changed

Some content is hidden

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

126 files changed

+2337
-275
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/DisabledTypes.h

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
3636
#include "Lib/BaseType.h"
3737
#include "Common/BitFlags.h"
38+
#include "Common/BitFlagsIO.h"
3839

3940
//-------------------------------------------------------------------------------------------------
4041
/** Kind of flags for determining groups of things that belong together
@@ -56,6 +57,8 @@ enum DisabledType CPP_11(: Int)
5657
DISABLED_SCRIPT_UNDERPOWERED,
5758

5859
DISABLED_COUNT,
60+
61+
DISABLED_ANY = 65535 ///< Do not use this value for setting disabled types (read-only)
5962
};
6063

6164
typedef BitFlags<DISABLED_COUNT> DisabledMaskType;

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/FileSystem.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,13 @@ struct FileInfo {
116116
* created when FileSystem::Open() gets called.
117117
*/
118118
//===============================
119+
#include <map>
119120

120121
class FileSystem : public SubsystemInterface
121122
{
123+
FileSystem(const FileSystem&);
124+
FileSystem& operator=(const FileSystem&);
125+
122126
public:
123127
FileSystem();
124128
virtual ~FileSystem();
@@ -138,8 +142,7 @@ class FileSystem : public SubsystemInterface
138142
void loadMusicFilesFromCD();
139143
void unloadMusicFilesFromCD();
140144
protected:
141-
142-
145+
mutable std::map<unsigned,bool> m_fileExist;
143146
};
144147

145148
extern FileSystem* TheFileSystem;

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

+7
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class AudioManager : public SubsystemInterface
257257
virtual void processRequestList( void );
258258

259259
virtual AudioEventInfo *newAudioEventInfo( AsciiString newEventName );
260+
virtual void addAudioEventInfo( AudioEventInfo * newEventInfo );
260261
virtual AudioEventInfo *findAudioEventInfo( AsciiString eventName ) const;
261262

262263
const AudioSettings *getAudioSettings( void ) const;
@@ -298,6 +299,7 @@ class AudioManager : public SubsystemInterface
298299

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

302304
Real getZoomVolume() const { return m_zoomVolume; }
303305
protected:
@@ -317,6 +319,11 @@ class AudioManager : public SubsystemInterface
317319
// For tracking purposes
318320
virtual AudioHandle allocateNewHandle( void );
319321

322+
// Remove all AudioEventInfo's with the m_isLevelSpecific flag
323+
virtual void removeLevelSpecificAudioEventInfos( void );
324+
325+
void removeAllAudioRequests( void );
326+
320327
protected:
321328
AudioSettings *m_audioSettings;
322329
MiscAudio *m_miscAudio;

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ private: \
730730
public: /* include this line at the end to reset visibility to 'public' */
731731

732732

733-
734733
// ----------------------------------------------------------------------------
735734
/**
736735
This class is provided as a simple and safe way to integrate C++ object allocation
@@ -768,7 +767,6 @@ class MemoryPoolObject
768767
};
769768

770769

771-
772770
// INLINING ///////////////////////////////////////////////////////////////////
773771

774772
// ----------------------------------------------------------------------------
@@ -890,10 +888,9 @@ class STLSpecialAlloc
890888
static void deallocate(void* __p, size_t);
891889
};
892890

893-
#endif //DISABLE_GAMEMEMORY
891+
#endif // DISABLE_GAMEMEMORY
894892

895893

896-
// ----------------------------------------------------------------------------
897894
/**
898895
A simple utility class to ensure exception safety; this holds a MemoryPoolObject
899896
and deletes it in its destructor. Especially useful for iterators!
@@ -910,7 +907,6 @@ class MemoryPoolObjectHolder
910907
};
911908

912909

913-
// ----------------------------------------------------------------------------
914910
/**
915911
Sometimes you want to make a class's destructor protected so that it can only
916912
be destroyed under special circumstances. MemoryPoolObject short-circuits this
@@ -924,4 +920,5 @@ ARGVIS: void deleteInstance() { MemoryPoolObject::deleteInstance(); } public:
924920

925921
#define EMPTY_DTOR(CLASS) inline CLASS::~CLASS() { }
926922

923+
927924
#endif // _GAME_MEMORY_H_

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/MapObject.h

+13
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636
#include "Common/GameMemory.h"
3737
#include "GameClient/TerrainRoads.h"
3838

39+
40+
41+
class WorldHeightMapInterfaceClass
42+
{
43+
public:
44+
45+
virtual Int getBorderSize() = 0;
46+
virtual Real getSeismicZVelocity(Int xIndex, Int yIndex) const = 0;
47+
virtual void setSeismicZVelocity(Int xIndex, Int yIndex, Real value) = 0;
48+
virtual Real getBilinearSampleSeismicZVelocity( Int x, Int y) = 0;
49+
50+
};
51+
3952
/** MapObject class
4053
Not ref counted. Do not store pointers to this class. */
4154
class WorldHeightMap;

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/PerfTimer.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ __forceinline void GetPrecisionTimer(Int64* t)
8888
class PerfGather
8989
{
9090
public:
91-
PerfGather( const char *identifier );
91+
// If net only (default), subtract perf timers running inside. [8/12/2003]
92+
PerfGather( const char *identifier, Bool netOnly=true );
9293
virtual ~PerfGather( );
9394

9495
__forceinline void startTimer();
@@ -129,6 +130,7 @@ class PerfGather
129130
PerfGather* m_next;
130131
PerfGather* m_prev;
131132
Bool m_ignore;
133+
Bool m_netTimeOnly;
132134
};
133135

134136
//-------------------------------------------------------------------------------------------------
@@ -164,7 +166,9 @@ void PerfGather::stopTimer()
164166
{
165167
// don't add the time it took for us to actually get the ticks (in startTimer) to our parent...
166168
(*m_activeHead)->m_runningTimeGross -= (s_stopStartOverhead);
167-
(*m_activeHead)->m_runningTimeNet -= (runTime + s_stopStartOverhead);
169+
if ((*m_activeHead)->m_netTimeOnly) {
170+
(*m_activeHead)->m_runningTimeNet -= (runTime + s_stopStartOverhead);
171+
}
168172
}
169173
}
170174

@@ -227,6 +231,7 @@ AutoPerfGatherIgnore::~AutoPerfGatherIgnore()
227231
}
228232

229233
//-------------------------------------------------------------------------------------------------
234+
#define DECLARE_TOTAL_PERF_TIMER(id) static PerfGather s_##id(#id, false);
230235
#define DECLARE_PERF_TIMER(id) static PerfGather s_##id(#id);
231236
#define USE_PERF_TIMER(id) AutoPerfGather a_##id(s_##id);
232237
#define IGNORE_PERF_TIMER(id) AutoPerfGatherIgnore a_##id(s_##id);
@@ -311,6 +316,7 @@ extern void StatMetricsDisplay( DebugDisplayInterface *dd, void *, FILE *fp );
311316
#else // PERF_TIMERS
312317

313318
#define DECLARE_PERF_TIMER(id)
319+
#define DECLARE_TOTAL_PERF_TIMER(id)
314320
#define USE_PERF_TIMER(id)
315321
#define IGNORE_PERF_TIMER(id)
316322

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ class Player : public Snapshot
316316
void toggleFreeBuild(){ m_DEMO_freeBuild = !m_DEMO_freeBuild; }
317317
Bool buildsForFree() const { return m_DEMO_freeBuild; }
318318

319+
#endif
320+
321+
#if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
319322
/// No time building cheat key
320323
void toggleInstantBuild(){ m_DEMO_instantBuild = !m_DEMO_instantBuild; }
321324
Bool buildsInstantly() const { return m_DEMO_instantBuild; }
@@ -502,7 +505,7 @@ class Player : public Snapshot
502505
/**
503506
* Iterate all objects that this player has
504507
*/
505-
void iterateObjects( ObjectIterateFunc func, void *userData );
508+
void iterateObjects( ObjectIterateFunc func, void *userData ) const;
506509

507510
/**
508511
return this player's "default" team.
@@ -770,6 +773,9 @@ class Player : public Snapshot
770773
#if defined(_DEBUG) || defined(_INTERNAL)
771774
Bool m_DEMO_ignorePrereqs; ///< Can I ignore prereq checks?
772775
Bool m_DEMO_freeBuild; ///< Can I build everything for no money?
776+
#endif
777+
778+
#if defined(_DEBUG) || defined(_INTERNAL) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
773779
Bool m_DEMO_instantBuild; ///< Can I build anything in one frame?
774780
#endif
775781

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

+3
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
@@ -249,6 +250,8 @@ class Radar : public Snapshot,
249250
RadarObject *m_localObjectList; /** list of objects for the local player, sorted
250251
* in exactly the same priority as the regular
251252
* object list for all other objects */
253+
// typedef std::list<Object*> HeroList;
254+
// HeroList m_heroList; //< list of pointers to objects with radar icon representations
252255

253256
Real m_terrainAverageZ; ///< average Z for terrain samples
254257
Real m_waterAverageZ; ///< average Z for water samples

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

+21
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

@@ -80,6 +100,7 @@ class SparseMatchFinder
80100
//-------------------------------------------------------------------------------------------------
81101

82102
mutable MatchMap m_bestMatches;
103+
//mutable HashMatchMap m_bestHashMatches;
83104

84105
//-------------------------------------------------------------------------------------------------
85106
// METHODS

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;

0 commit comments

Comments
 (0)