Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 55c4380

Browse files
committed
Review changes, misc cleanup and changes
1 parent e8c8d25 commit 55c4380

File tree

14 files changed

+72
-82
lines changed

14 files changed

+72
-82
lines changed

System/Box.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,11 @@ namespace RTE {
139139
if (IsEmpty() || rhs.IsEmpty()) {
140140
return false;
141141
}
142-
143142
Box box1 = *this;
144143
Box box2 = rhs;
145144
box1.Unflip();
146145
box2.Unflip();
147146
return (box1.m_Corner.m_X < box2.m_Corner.m_X + box2.m_Width) && (box1.m_Corner.m_X + box1.m_Width > box2.m_Corner.m_X) &&
148147
(box1.m_Corner.m_Y < box2.m_Corner.m_Y + box2.m_Height) && (box1.m_Corner.m_Y + box1.m_Height > box2.m_Corner.m_Y);
149148
}
150-
151-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
152-
153-
Box & Box::operator=(const Box &rhs) {
154-
if (*this != rhs) { Create(rhs); }
155-
return *this;
156-
}
157149
}

System/Box.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ namespace RTE {
249249
/// </summary>
250250
/// <param name="rhs">A Box reference.</param>
251251
/// <returns>A reference to the changed Box.</returns>
252-
Box & operator=(const Box &rhs);
252+
Box & operator=(const Box &rhs) { if (*this != rhs) { Create(rhs); } return *this; }
253253

254254
/// <summary>
255255
/// An equality operator for testing if any two Boxes are equal.

System/ContentFile.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "PresetMan.h"
33

44
namespace RTE {
5+
56
const std::string ContentFile::m_ClassName = "ContentFile";
67

78
std::map<std::string, BITMAP *> ContentFile::m_sLoadedBitmaps[BitDepthCount];
@@ -16,7 +17,7 @@ namespace RTE {
1617
//m_DataModified = false;
1718
//m_pLoadedData = 0;
1819
//m_LoadedDataSize = 0;
19-
m_pDataFile = 0;
20+
//m_pDataFile = 0;
2021
}
2122

2223
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,10 +46,14 @@ namespace RTE {
4546

4647
void ContentFile::FreeAllLoaded() {
4748
for (int depth = Eight; depth < BitDepthCount; ++depth) {
48-
for (std::map<std::string, BITMAP *>::iterator lbItr = m_sLoadedBitmaps[depth].begin(); lbItr != m_sLoadedBitmaps[depth].end(); ++lbItr) { destroy_bitmap((*lbItr).second); }
49+
for (std::map<std::string, BITMAP *>::iterator lbItr = m_sLoadedBitmaps[depth].begin(); lbItr != m_sLoadedBitmaps[depth].end(); ++lbItr) {
50+
destroy_bitmap((*lbItr).second);
51+
}
4952
}
5053
#ifdef __USE_SOUND_FMOD
51-
for (std::map<std::string, FSOUND_SAMPLE *>::iterator lcItr = m_sLoadedSamples.begin(); lcItr != m_sLoadedSamples.end(); ++lcItr) { FSOUND_Sample_Free((*lcItr).second); }
54+
for (std::map<std::string, FSOUND_SAMPLE *>::iterator lcItr = m_sLoadedSamples.begin(); lcItr != m_sLoadedSamples.end(); ++lcItr) {
55+
FSOUND_Sample_Free((*lcItr).second);
56+
}
5257
#endif
5358
}
5459

@@ -75,7 +80,6 @@ namespace RTE {
7580
writer.NewProperty("FilePath");
7681
writer << m_DataPath;
7782
}
78-
7983
return 0;
8084
}
8185

@@ -100,7 +104,6 @@ namespace RTE {
100104
if (m_DataPath.empty()) {
101105
return 0;
102106
}
103-
104107
BITMAP *pReturnBitmap = 0;
105108

106109
// Determine the bit depth this bitmap will be loaded as
@@ -117,7 +120,6 @@ namespace RTE {
117120
// Insert the bitmap into the map, PASSING OVER OWNERSHIP OF THE LOADED DATAFILE
118121
m_sLoadedBitmaps[bitDepth].insert(std::pair<std::string, BITMAP *>(m_DataPath, pReturnBitmap));
119122
}
120-
121123
return pReturnBitmap;
122124
}
123125

@@ -128,10 +130,10 @@ namespace RTE {
128130
return 0;
129131
}
130132
BITMAP *pReturnBitmap = 0;
131-
132133
set_color_conversion(conversionMode == 0 ? COLORCONV_MOST : conversionMode);
133134

134-
int separatorPos = m_DataPath.find('#'); // Used for handling separators between the datafile name and the object name in .dat datafiles. NOTE: Not currently used
135+
// Used for handling separators between the datafile name and the object name in .dat datafiles. NOTE: Not currently used
136+
int separatorPos = m_DataPath.find('#');
135137

136138
if (separatorPos == m_DataPath.length()) {
137139
RTEAbort("There was no object name following first pound sign in the ContentFile's datafile path, which means there was no actual object defined. The path was:\n\n" + m_DataPath);
@@ -147,22 +149,24 @@ namespace RTE {
147149
pFile = pack_fopen((pathWithoutExtension + "000.bmp").c_str(), F_READ);
148150
RTEAssert(pFile, "Failed to load datafile object with following path and name:\n\n" + m_DataPath);
149151
}
150-
151-
// Load the bitmap then close the filestream to clean up
152+
// Load the bitmap then close the file stream to clean up
152153
PALETTE currentPalette;
153154
get_palette(currentPalette);
154155

155156
pReturnBitmap = load_bmp_pf(pFile, (RGB *)currentPalette);
156157
pack_fclose(pFile);
157158
} else if (separatorPos != m_DataPath.length() - 1) {
159+
RTEAbort("Loading bitmaps from allegro datafiles isn't supported yet!");
160+
// Used for loading from DataFiles, disabled because we don't have this properly implemented right now.
161+
/*
158162
// Split the datapath into the path and the object name and load the datafile from them
159163
m_pDataFile = load_datafile_object(m_DataPath.substr(0, separatorPos).c_str(), m_DataPath.substr(separatorPos + 1).c_str());
160164
RTEAssert(m_pDataFile && m_pDataFile->dat && m_pDataFile->type == DAT_BITMAP, "Failed to load datafile object with following path and name:\n\n" + m_DataPath);
161165
162166
pReturnBitmap = (BITMAP *)m_pDataFile->dat;
167+
*/
163168
}
164169
RTEAssert(pReturnBitmap, "Failed to load datafile object with following path and name:\n\n" + m_DataPath);
165-
166170
return pReturnBitmap;
167171
}
168172

@@ -172,7 +176,6 @@ namespace RTE {
172176
if (m_DataPath.empty()) {
173177
return 0;
174178
}
175-
176179
// Create the array of as many BITMAP pointers as requested frames
177180
BITMAP **aReturnBitmaps = new BITMAP *[frameCount];
178181

@@ -181,9 +184,9 @@ namespace RTE {
181184
aReturnBitmaps[0] = GetAsBitmap(conversionMode);
182185
return aReturnBitmaps;
183186
}
184-
185187
std::string extension = "";
186-
int separatorPos = m_DataPath.find('#'); // Used for handling separators between the datafile name and the object name in .dat datafiles. NOTE: Not currently used
188+
// Used for handling separators between the datafile name and the object name in .dat datafiles. NOTE: Not currently used
189+
int separatorPos = m_DataPath.find('#');
187190
int extensionPos = 0;
188191

189192
// No separator, need to separate file extension from datapath
@@ -193,7 +196,6 @@ namespace RTE {
193196
extension.assign(m_DataPath, extensionPos, m_DataPath.length() - extensionPos);
194197
m_DataPath.resize(extensionPos);
195198
}
196-
197199
std::string originalDataPath = m_DataPath;
198200
char framePath[1024];
199201
// For each frame in the animation, temporarily assign it to the datapath member var so that GetAsBitmap and then load it with GetBitmap
@@ -205,7 +207,6 @@ namespace RTE {
205207
RTEAssert(aReturnBitmaps[i], "Could not get a frame of animation with path and name:\n\n" + m_DataPath);
206208
}
207209
m_DataPath = originalDataPath + (extensionPos > 0 ? extension : "");
208-
209210
return aReturnBitmaps;
210211
}
211212

@@ -264,7 +265,6 @@ namespace RTE {
264265
pReturnSample = (FSOUND_SAMPLE *)m_pDataFile->dat;
265266
*/
266267
}
267-
268268
RTEAssert(pReturnSample, "Failed to load datafile object with following path and name:\n\n" + m_DataPath);
269269

270270
// Insert the Sound object into the map, PASSING OVER OWNERSHIP OF THE LOADED DATAFILE

System/ContentFile.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct FSOUND_STREAM;
1616
struct ga_Handle;
1717
#endif
1818

19-
struct DATAFILE;
19+
//struct DATAFILE; // DataFile loading not implemented.
2020
struct BITMAP;
2121

2222
namespace RTE {
@@ -183,10 +183,10 @@ namespace RTE {
183183
virtual BITMAP *LoadAndReleaseBitmap(int conversionMode = 0);
184184

185185
/// <summary>
186-
/// Gets the data represented by this ContentFile object as an array of Allegro BITMAPs, each represting a frame in the animation. It loads the BITMAPs into the static maps if they're not already loaded.
186+
/// Gets the data represented by this ContentFile object as an array of Allegro BITMAPs, each representing a frame in the animation. It loads the BITMAPs into the static maps if they're not already loaded.
187187
/// Note that ownership of the BITMAPS ARE NOT TRANSFERRED, BUT THE ARRAY ITSELF, IS!
188188
/// </summary>
189-
/// <param name="frameCount">The number of frames to attempt to load, more than 1 frmae will mean 00# is appended to datapath to handle naming conventions.</param>
189+
/// <param name="frameCount">The number of frames to attempt to load, more than 1 frame will mean 00# is appended to datapath to handle naming conventions.</param>
190190
/// <param name="conversionMode">
191191
/// The Allegro color conversion mode to use when loading this bitmap.
192192
/// Note it will only apply the first time you get a bitmap since it is only loaded from disk the first time. See allegro docs for the modes.
@@ -219,10 +219,11 @@ namespace RTE {
219219
#pragma endregion
220220

221221
protected:
222-
enum BitDepths { Eight = 0, ThirtyTwo, BitDepthCount }; //!< Enumeration for loading BITMAPs by bit depth. NOTE: This can't be lower down because m_sLoadedBitmaps relies on its definition
223222

224223
static const std::string m_ClassName; //!< A string with the friendly-formatted type name of this object.01, 002 etc.
225224

225+
enum BitDepths { Eight = 0, ThirtyTwo, BitDepthCount }; //!< Enumeration for loading BITMAPs by bit depth. NOTE: This can't be lower down because m_sLoadedBitmaps relies on its definition.
226+
226227
//TODO all of these could probably be replaced with unordered_maps and decrease lookup time.
227228
static std::map<size_t, std::string> m_PathHashes; //!< Hash value of the path to this ContentFile's Datafile Object.
228229
static std::map<std::string, BITMAP *> m_sLoadedBitmaps[BitDepthCount]; //!< Static map containing all the already loaded BITMAPs and their paths, and there's two maps, for each bit depth.
@@ -238,7 +239,7 @@ namespace RTE {
238239
//long m_LoadedDataSize; //!< Size of loaded data.
239240
//bool m_DataModified; //!< Whether the data itself has been modified since load, and should be saved out again to the path on write.
240241

241-
DATAFILE *m_pDataFile; //!< This is only if the data is loaded from a datafile; needs to be saved so that it can be unloaded as some point.
242+
//DATAFILE *m_pDataFile; //!< This is only if the data is loaded from a datafile; needs to be saved so that it can be unloaded as some point.
242243

243244
private:
244245

System/Controller.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55

66
namespace RTE {
77

8-
const int Controller::m_ReleaseDelay = 250;
9-
108
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
119

1210
void Controller::Clear() {
13-
for (int i = 0; i < CONTROLSTATECOUNT; ++i) { m_ControlStates[i] = false; }
14-
11+
for (int i = 0; i < CONTROLSTATECOUNT; ++i) {
12+
m_ControlStates[i] = false;
13+
}
1514
m_AnalogMove.Reset();
1615
m_AnalogAim.Reset();
1716
m_AnalogCursor.Reset();
@@ -47,8 +46,9 @@ namespace RTE {
4746
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4847

4948
int Controller::Create(const Controller &reference) {
50-
for (int i = 0; i < CONTROLSTATECOUNT; ++i) { m_ControlStates[i] = reference.m_ControlStates[i]; }
51-
49+
for (int i = 0; i < CONTROLSTATECOUNT; ++i) {
50+
m_ControlStates[i] = reference.m_ControlStates[i];
51+
}
5252
m_AnalogMove = reference.m_AnalogMove;
5353
m_AnalogAim = reference.m_AnalogAim;
5454
m_AnalogCursor = reference.m_AnalogCursor;
@@ -122,7 +122,7 @@ namespace RTE {
122122
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
123123

124124
int Controller::GetTeam() const {
125-
return (m_pControlled) ? m_pControlled->GetTeam() : m_Team;
125+
return m_pControlled ? m_pControlled->GetTeam() : m_Team;
126126
}
127127

128128
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -136,8 +136,9 @@ namespace RTE {
136136

137137
void Controller::Update() {
138138
// Reset all command states.
139-
for (int i = 0; i < CONTROLSTATECOUNT; ++i) { m_ControlStates[i] = false; }
140-
139+
for (int i = 0; i < CONTROLSTATECOUNT; ++i) {
140+
m_ControlStates[i] = false;
141+
}
141142
m_AnalogMove.Reset();
142143
m_AnalogAim.Reset();
143144
m_AnalogCursor.Reset();
@@ -334,7 +335,7 @@ namespace RTE {
334335
m_KeyAccelTimer.Reset();
335336
}
336337

337-
// Translate analog aim input into sharp aim constrol state
338+
// Translate analog aim input into sharp aim control state
338339
m_ControlStates[AIM_SHARP] = m_AnalogAim.GetMagnitude() > 0.1 && !m_ControlStates[PIE_MENU_ACTIVE];
339340

340341
// Disable sharp aim while moving - this also helps with keyboard vs mouse fighting when moving and aiming in opposite directions

System/Controller.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ namespace RTE {
6969
Vector m_AnalogAim; //!< Analog values for aiming.
7070
Vector m_AnalogCursor; //!< Analog values for Pie Menu operation.
7171

72-
// Enumerate different input modes.
72+
//!< Enumerate different input modes.
7373
enum InputMode {
7474
CIM_DISABLED = 0,
7575
CIM_PLAYER,
@@ -301,6 +301,8 @@ namespace RTE {
301301

302302
protected:
303303

304+
static constexpr int m_ReleaseDelay = 250; //!< The delay between releasing a menu button and activating the regular controls, to avoid accidental input.
305+
304306
bool m_ControlStates[CONTROLSTATECOUNT]; //!< Control states.
305307
bool m_Disabled; //!< Quick and easy disable to prevent updates from being made.
306308

@@ -330,7 +332,6 @@ namespace RTE {
330332
bool m_WeaponDropIgnore;
331333
bool m_WeaponReloadIgnore;
332334

333-
static const int m_ReleaseDelay; //!< The delay between releasing a menu button and activating the regular controls, to avoid accidental input.
334335
Timer m_ReleaseTimer; //!< Timer for measuring release delays.
335336
Timer m_JoyAccelTimer; //!< Timer for measuring analog joystick-controlled cursor acceleration.
336337
Timer m_KeyAccelTimer; //!< Timer for measuring keyboard-controlled cursor acceleration.

System/DataModule.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
#include "ContentFile.h"
55
#include "Constants.h"
66

7-
struct DATAFILE;
7+
//struct DATAFILE; // DataFile loading not implemented.
88
struct BITMAP;
99

1010
namespace RTE {
1111

1212
class Entity;
1313

1414
/// <summary>
15-
/// A representation of a Data Module containing zero or many Material, Effect, Ammo, Device, Actor, or Scene definitions.
15+
/// A representation of a DataModule containing zero or many Material, Effect, Ammo, Device, Actor, or Scene definitions.
1616
/// </summary>
1717
class DataModule : public Serializable {
1818
friend class LuaMan;
@@ -46,7 +46,7 @@ namespace RTE {
4646
/// Makes the DataModule object ready for use. This needs to be called after PresetMan is created.
4747
/// This looks for an "index.ini" within the specified .rte directory and loads all the defined objects in that index file.
4848
/// </summary>
49-
/// <param name="moduleName">A string defining the name of this Data Module, e.g. "MyModule.rte".</param>
49+
/// <param name="moduleName">A string defining the name of this DataModule, e.g. "MyModule.rte".</param>
5050
/// <param name="fpProgressCallback">A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation.</param>
5151
/// <returns>An error return value signaling success or any particular failure. Anything below 0 is an error signal.</returns>
5252
virtual int Create(std::string moduleName, ProgressCallback fpProgressCallback = 0);
@@ -74,7 +74,7 @@ namespace RTE {
7474
/// <summary>
7575
/// Read module specific properties from index.ini without processing IncludeFiles and loading the whole module.
7676
/// </summary>
77-
/// <param name="moduleName">A string defining the name of this Data Module, e.g. "MyModule.rte".</param>
77+
/// <param name="moduleName">A string defining the name of this DataModule, e.g. "MyModule.rte".</param>
7878
/// <param name="fpProgressCallback">A function pointer to a function that will be called and sent a string with information about the progress of this DataModule's creation.</param>
7979
/// <returns>An error return value signaling success or any particular failure. Anything below 0 is an error signal.</returns>
8080
virtual int ReadModuleProperties(std::string moduleName, ProgressCallback fpProgressCallback = 0);
@@ -107,37 +107,37 @@ namespace RTE {
107107

108108
#pragma region Module Information Getters
109109
/// <summary>
110-
/// Gets the file name of this Data Module, e.g. "MyMod.rte".
110+
/// Gets the file name of this DataModule, e.g. "MyMod.rte".
111111
/// </summary>
112112
/// <returns>A string with the data module file name.</returns>
113113
virtual const std::string & GetFileName() const { return m_FileName; }
114114

115115
/// <summary>
116-
/// Gets the friendly name of this Data Module, e.g. "My Great Mod".
116+
/// Gets the friendly name of this DataModule, e.g. "My Great Mod".
117117
/// </summary>
118118
/// <returns>A string with the data module's friendly name.</returns>
119119
virtual const std::string & GetFriendlyName() const { return m_FriendlyName; }
120120

121121
/// <summary>
122-
/// Gets the author name of this Data Module, e.g. "Data Realms, LLC".
122+
/// Gets the author name of this DataModule, e.g. "Data Realms, LLC".
123123
/// </summary>
124124
/// <returns>A string with the author's name.</returns>
125125
virtual const std::string & GetAuthor() const { return m_Author; }
126126

127127
/// <summary>
128-
/// Gets the description of this Data Module's contents.
128+
/// Gets the description of this DataModule's contents.
129129
/// </summary>
130130
/// <returns>A string with the description.</returns>
131131
virtual const std::string & GetDescription() const { return m_Description; }
132132

133133
/// <summary>
134-
/// Gets the version number of this Data Module.
134+
/// Gets the version number of this DataModule.
135135
/// </summary>
136136
/// <returns>An int with the version number, starting at 1.</returns>
137137
virtual int GetVersionNumber() const { return m_Version; }
138138

139139
/// <summary>
140-
/// Gets the BITMAP that visually represents this Data Module, for use in menus.
140+
/// Gets the BITMAP that visually represents this DataModule, for use in menus.
141141
/// </summary>
142142
/// <returns>BITMAP pointer that might have the icon. 0 is very possible.</returns>
143143
BITMAP * GetIcon() const { return m_pIcon; }

0 commit comments

Comments
 (0)