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

Commit 2cc2712

Browse files
committed
Review changes
1 parent 85ab9af commit 2cc2712

File tree

16 files changed

+128
-197
lines changed

16 files changed

+128
-197
lines changed

Main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ int g_DifficultySetting = 4;
133133
int g_StationOffsetX;
134134
int g_StationOffsetY;
135135

136+
LoadingGUI *g_LoadingGUI;
136137
MainMenuGUI *g_pMainMenuGUI = 0;
137138
ScenarioGUI *g_pScenarioGUI = 0;
138139
Controller *g_pMainMenuController = 0;
@@ -1957,7 +1958,7 @@ int main(int argc, char *argv[]) {
19571958
g_AudioMan.SetMusicVolume(0);
19581959
}
19591960

1960-
g_LoadingGUI.InitLoadingScreen();
1961+
g_LoadingGUI->InitLoadingScreen();
19611962
InitMainMenu();
19621963

19631964
if (g_LaunchIntoEditor) {

Managers/ConsoleMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void ConsoleMan::PrintString(std::string toPrint)
241241
// Add the input line to the console
242242
m_pConsoleText->SetText(m_pConsoleText->GetText() + "\n" + toPrint);
243243
// Print the input line to the command-line
244-
if (g_System.GetLogToCLI()) { g_System.PrintConsoleToCLI(toPrint); }
244+
if (g_System.GetLogToCLI()) { g_System.PrintToCLI(toPrint); }
245245
}
246246

247247

Managers/PresetMan.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,9 @@ bool PresetMan::LoadAllDataModules() {
208208
if (strlen(moduleInfo.name) > 0 && (moduleID < 0 || moduleID >= GetOfficialModuleCount()) && string(moduleInfo.name) != "Metagames.rte" && string(moduleInfo.name) != "Scenes.rte") {
209209
// Actually load the unofficial data module
210210
if (!LoadDataModule(string(moduleInfo.name), false, &LoadingGUI::LoadingSplashProgressReport)) {
211+
// LoadDataModule can return false (esp since it may try to load already loaded modules, and that's ok) and shouldn't cause stop
211212
// TODO: Report error and skip loading module.
212213
}
213-
} else {
214-
// LoadDataModule can return false (esp since it may try to load already loaded modules, and that's ok) and shouldn't cause stop
215-
// TODO: Log this and continue gracefully instead
216-
// char error[512];
217-
// sprintf_s(error, sizeof(error), "Failed to load Data Module: %s\n\nMake sure it contains an Index.ini file that defines a \"DataModule\"!", moduleInfo.name);
218-
// RTEAbort(error);
219-
// return false;
220214
}
221215
}
222216
}

Menus/LoadingGUI.cpp

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,22 @@ extern volatile bool g_Quit;
2020

2121
namespace RTE {
2222

23-
LoadingGUI g_LoadingGUI;
24-
25-
GUIControlManager *LoadingGUI::m_LoadingGUI = 0;
26-
27-
AllegroInput *LoadingGUI::m_GUIInput = 0;
28-
AllegroScreen *LoadingGUI::m_GUIScreen = 0;
29-
BITMAP *LoadingGUI::m_LoadingGUIBitmap = 0;
30-
int LoadingGUI::m_LoadingGUIPosX = 0;
31-
int LoadingGUI::m_LoadingGUIPosY = 0;
32-
33-
Writer *LoadingGUI::m_LoadingLogWriter = 0;
23+
GUIControlManager *LoadingGUI::s_LoadingGUI = 0;
24+
AllegroInput *LoadingGUI::s_GUIInput = 0;
25+
AllegroScreen *LoadingGUI::s_GUIScreen = 0;
26+
Writer *LoadingGUI::s_LoadingLogWriter = 0;
27+
BITMAP *LoadingGUI::s_LoadingGUIBitmap = 0;
28+
int LoadingGUI::s_LoadingGUIPosX = 0;
29+
int LoadingGUI::s_LoadingGUIPosY = 0;
3430

3531
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3632

3733
void LoadingGUI::InitLoadingScreen() {
3834
g_FrameMan.LoadPalette("Base.rte/palette.bmp");
3935

4036
// Create the main GUI
41-
m_GUIInput = new AllegroInput(-1);
42-
m_GUIScreen = new AllegroScreen(g_FrameMan.GetBackBuffer32());
37+
s_GUIInput = new AllegroInput(-1);
38+
s_GUIScreen = new AllegroScreen(g_FrameMan.GetBackBuffer32());
4339

4440
// Loading splash screen
4541
g_FrameMan.ClearBackBuffer32();
@@ -59,22 +55,22 @@ namespace RTE {
5955
g_FrameMan.FlipFrameBuffers();
6056

6157
// Set up the loading GUI
62-
if (!m_LoadingGUI) {
63-
m_LoadingGUI = new GUIControlManager();
58+
if (!s_LoadingGUI) {
59+
s_LoadingGUI = new GUIControlManager();
6460

6561
// TODO: This should be using the 32bpp main menu skin, but isn't because it needs the config of the base for its listbox
6662
// Can get away with this hack for now because the list box that the loading menu uses displays ok when drawn on a 32bpp buffer,
6763
// when it's 8bpp internally, since it does not use any masked_blit calls to draw list boxes.
6864
// Note also how the GUIScreen passed in here has been created with an 8bpp bitmap, since that is what determines what the GUI manager uses internally
69-
if (!m_LoadingGUI->Create(m_GUIScreen, m_GUIInput, "Base.rte/GUIs/Skins/MainMenu", "LoadingSkin.ini")) {
65+
if (!s_LoadingGUI->Create(s_GUIScreen, s_GUIInput, "Base.rte/GUIs/Skins/MainMenu", "LoadingSkin.ini")) {
7066
RTEAbort("Failed to create GUI Control Manager and load it from Base.rte/GUIs/Skins/MainMenu/LoadingSkin.ini");
7167
}
72-
m_LoadingGUI->Load("Base.rte/GUIs/LoadingGUI.ini");
68+
s_LoadingGUI->Load("Base.rte/GUIs/LoadingGUI.ini");
7369
}
7470

7571
// Place and clear the sectionProgress box
76-
dynamic_cast<GUICollectionBox *>(m_LoadingGUI->GetControl("root"))->SetSize(g_FrameMan.GetResX(), g_FrameMan.GetResY());
77-
GUIListBox *pBox = dynamic_cast<GUIListBox *>(m_LoadingGUI->GetControl("ProgressBox"));
72+
dynamic_cast<GUICollectionBox *>(s_LoadingGUI->GetControl("root"))->SetSize(g_FrameMan.GetResX(), g_FrameMan.GetResY());
73+
GUIListBox *pBox = dynamic_cast<GUIListBox *>(s_LoadingGUI->GetControl("ProgressBox"));
7874
// Make the box a bit bigger if there's room in higher, HD resolutions
7975
if (g_FrameMan.GetResX() >= 960) {
8076
// Make the loading progress box fill the right third of the screen
@@ -87,17 +83,17 @@ namespace RTE {
8783
pBox->ClearList();
8884

8985
// New mechanism to speed up loading times as it turned out that a massive amount of time is spent to update GUI control.
90-
if (!g_SettingsMan.DisableLoadingScreen() && !m_LoadingGUIBitmap) {
86+
if (!g_SettingsMan.DisableLoadingScreen() && !s_LoadingGUIBitmap) {
9187
pBox->SetVisible(false);
92-
m_LoadingGUIBitmap = create_bitmap_ex(8, pBox->GetWidth(), pBox->GetHeight());
93-
clear_to_color(m_LoadingGUIBitmap, 54);
94-
rect(m_LoadingGUIBitmap, 0, 0, pBox->GetWidth() - 1, pBox->GetHeight() - 1, 33);
95-
rect(m_LoadingGUIBitmap, 1, 1, pBox->GetWidth() - 2, pBox->GetHeight() - 2, 33);
96-
m_LoadingGUIPosX = pBox->GetXPos();
97-
m_LoadingGUIPosY = pBox->GetYPos();
88+
s_LoadingGUIBitmap = create_bitmap_ex(8, pBox->GetWidth(), pBox->GetHeight());
89+
clear_to_color(s_LoadingGUIBitmap, 54);
90+
rect(s_LoadingGUIBitmap, 0, 0, pBox->GetWidth() - 1, pBox->GetHeight() - 1, 33);
91+
rect(s_LoadingGUIBitmap, 1, 1, pBox->GetWidth() - 2, pBox->GetHeight() - 2, 33);
92+
s_LoadingGUIPosX = pBox->GetXPos();
93+
s_LoadingGUIPosY = pBox->GetYPos();
9894
}
9995
// Create the loading log writer
100-
if (!m_LoadingLogWriter) { m_LoadingLogWriter = new Writer("LogLoading.txt"); }
96+
if (!s_LoadingLogWriter) { s_LoadingLogWriter = new Writer("LogLoading.txt"); }
10197

10298
// Load all the data modules
10399
LoadDataModules();
@@ -108,26 +104,26 @@ namespace RTE {
108104
void LoadingGUI::LoadingSplashProgressReport(std::string reportString, bool newItem) {
109105
if (g_System.GetLogToCLI()) { g_System.PrintLoadingToCLI(reportString, newItem); }
110106

111-
if (m_LoadingGUI) {
107+
if (s_LoadingGUI) {
112108
g_UInputMan.Update();
113109
if (newItem) {
114110
// Write out the last line to the log file before starting a new one
115-
if (m_LoadingLogWriter->WriterOK()) { *m_LoadingLogWriter << reportString << "\n"; }
111+
if (s_LoadingLogWriter->WriterOK()) { *s_LoadingLogWriter << reportString << "\n"; }
116112
// Scroll bitmap upwards
117-
if (m_LoadingGUIBitmap) { blit(m_LoadingGUIBitmap, m_LoadingGUIBitmap, 2, 12, 2, 2, m_LoadingGUIBitmap->w - 3, m_LoadingGUIBitmap->h - 12); }
113+
if (s_LoadingGUIBitmap) { blit(s_LoadingGUIBitmap, s_LoadingGUIBitmap, 2, 12, 2, 2, s_LoadingGUIBitmap->w - 3, s_LoadingGUIBitmap->h - 12); }
118114
}
119-
if (m_LoadingGUIBitmap) {
120-
AllegroBitmap bmp(m_LoadingGUIBitmap);
115+
if (s_LoadingGUIBitmap) {
116+
AllegroBitmap bmp(s_LoadingGUIBitmap);
121117
// Clear current line
122-
rectfill(m_LoadingGUIBitmap, 2, m_LoadingGUIBitmap->h - 12, m_LoadingGUIBitmap->w - 3, m_LoadingGUIBitmap->h - 3, 54);
118+
rectfill(s_LoadingGUIBitmap, 2, s_LoadingGUIBitmap->h - 12, s_LoadingGUIBitmap->w - 3, s_LoadingGUIBitmap->h - 3, 54);
123119
// Print new line
124-
g_FrameMan.GetSmallFont()->DrawAligned(&bmp, 5, m_LoadingGUIBitmap->h - 12, reportString.c_str(), GUIFont::Left);
120+
g_FrameMan.GetSmallFont()->DrawAligned(&bmp, 5, s_LoadingGUIBitmap->h - 12, reportString.c_str(), GUIFont::Left);
125121
// DrawAligned - MaxWidth is useless here, so we're just drawing lines manually
126-
vline(m_LoadingGUIBitmap, m_LoadingGUIBitmap->w - 2, m_LoadingGUIBitmap->h - 12, m_LoadingGUIBitmap->h - 2, 33);
127-
vline(m_LoadingGUIBitmap, m_LoadingGUIBitmap->w - 1, m_LoadingGUIBitmap->h - 12, m_LoadingGUIBitmap->h - 2, 33);
122+
vline(s_LoadingGUIBitmap, s_LoadingGUIBitmap->w - 2, s_LoadingGUIBitmap->h - 12, s_LoadingGUIBitmap->h - 2, 33);
123+
vline(s_LoadingGUIBitmap, s_LoadingGUIBitmap->w - 1, s_LoadingGUIBitmap->h - 12, s_LoadingGUIBitmap->h - 2, 33);
128124

129125
// Draw onto current frame buffer
130-
blit(m_LoadingGUIBitmap, g_FrameMan.GetBackBuffer32(), 0, 0, m_LoadingGUIPosX, m_LoadingGUIPosY, m_LoadingGUIBitmap->w, m_LoadingGUIBitmap->h);
126+
blit(s_LoadingGUIBitmap, g_FrameMan.GetBackBuffer32(), 0, 0, s_LoadingGUIPosX, s_LoadingGUIPosY, s_LoadingGUIBitmap->w, s_LoadingGUIBitmap->h);
131127

132128
g_FrameMan.FlipFrameBuffers();
133129
}

Menus/LoadingGUI.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ namespace RTE {
1010
class GUIControlManager;
1111
class Writer;
1212

13+
/// <summary>
14+
/// Represents the loading screen GUI when starting the game.
15+
/// </summary>
1316
class LoadingGUI {
1417

1518
public:
@@ -40,20 +43,18 @@ namespace RTE {
4043

4144
protected:
4245

43-
static GUIControlManager *m_LoadingGUI; //!< Manager of the whole LoadingGUI.
44-
45-
static AllegroInput *m_GUIInput; //!< Input interface of this.
46-
static AllegroScreen *m_GUIScreen; //!< Screen interface of this.
47-
static BITMAP *m_LoadingGUIBitmap; //!< BITMAP that the progress report will be drawn into.
48-
static int m_LoadingGUIPosX; //!< Position of the progress report box on X axis.
49-
static int m_LoadingGUIPosY; //!< Position of the progress report box on Y axis.
50-
51-
static Writer *m_LoadingLogWriter; //!< The Writer that generates the loading log.
52-
5346
static const unsigned int s_MaxFileName = 256; //!< Maximum length of output file directory + name string.
5447
static const unsigned int s_FileBufferSize = 8192; //!< Buffer to hold data read from the zip file.
5548
static const unsigned int s_MaxUnzippedFileSize = 104857600; //!< Maximum size of single file being extracted from zip archive (100MiB).
49+
50+
static GUIControlManager *s_LoadingGUI; //!< Manager of the whole LoadingGUI.
51+
static AllegroInput *s_GUIInput; //!< Input interface of this.
52+
static AllegroScreen *s_GUIScreen; //!< Screen interface of this.
53+
static Writer *s_LoadingLogWriter; //!< The Writer that generates the loading log.
54+
55+
static BITMAP *s_LoadingGUIBitmap; //!< BITMAP that the progress report will be drawn into.
56+
static int s_LoadingGUIPosX; //!< Position of the progress report box on X axis.
57+
static int s_LoadingGUIPosY; //!< Position of the progress report box on Y axis.
5658
};
57-
extern LoadingGUI g_LoadingGUI;
5859
}
5960
#endif

System/Box.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ namespace RTE {
9090
#pragma endregion
9191

9292
#pragma region Destruction
93-
/// <summary>
94-
/// Destructor method used to clean up a Box object before deletion.
95-
/// </summary>
96-
virtual ~Box() { ; }
97-
9893
/// <summary>
9994
/// Resets the entire Box object to the default settings or values.
10095
/// </summary>

System/Color.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace RTE {
2727
Color() { Clear(); }
2828

2929
/// <summary>
30-
/// Constructor method used to instantiate a Color object from RGB values
30+
/// Constructor method used to instantiate a Color object from RGB values.
3131
/// </summary>
3232
/// <param name="R">Initial Red value of this color.</param>
3333
/// <param name="G">Initial Green value of this color.</param>
@@ -63,11 +63,6 @@ namespace RTE {
6363
#pragma endregion
6464

6565
#pragma region Destruction
66-
/// <summary>
67-
/// Destructor method used to clean up a Color object before deletion.
68-
/// </summary>
69-
virtual ~Color() { ; }
70-
7166
/// <summary>
7267
/// Sets RGB of this Color to zero.
7368
/// </summary>

System/DataModule.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ namespace RTE {
1919
m_PresetList.clear();
2020
m_EntityList.clear();
2121
m_TypeMap.clear();
22-
for (int i = 0; i < c_PaletteEntriesNumber; ++i) { m_MaterialMappings[i] = 0; }
23-
22+
for (int i = 0; i < c_PaletteEntriesNumber; ++i) {
23+
m_MaterialMappings[i] = 0;
24+
}
2425
m_ScanFolderContents = false;
2526
m_IgnoreMissingItems = false;
2627
m_CrabToHumanSpawnRatio = 0;
@@ -51,14 +52,8 @@ namespace RTE {
5152
if (std::experimental::filesystem::exists(indexPath.c_str()) && reader.Create(indexPath.c_str(), true, fpProgressCallback) >= 0) {
5253
int result = Serializable::Create(reader);
5354

54-
// Report loading result
55+
// Print an empty line to separate the end of a module from the beginning of the next one in the loading progress log.
5556
if (fpProgressCallback) {
56-
// TODO: more info here?
57-
/*
58-
char report[512];
59-
sprintf_s(report, sizeof(report), "%s loading:", m_FileName.c_str());
60-
fpProgressCallback(std::string(report), true);
61-
*/
6257
fpProgressCallback(std::string(" "), true);
6358
}
6459

@@ -152,7 +147,6 @@ namespace RTE {
152147
// Check for required dependencies if we're not load properties
153148
std::string requiredModule;
154149
reader >> requiredModule;
155-
156150
if (!reader.GetSkipIncludes() && g_PresetMan.GetModuleID(requiredModule) == -1) {
157151
reader.ReportError("\"" + m_FileName + "\" requires \"" + requiredModule + "\" in order to load!\n");
158152
}
@@ -216,7 +210,7 @@ namespace RTE {
216210
return 0;
217211
}
218212

219-
map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator classItr = m_TypeMap.find(exactType);
213+
std::map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator classItr = m_TypeMap.find(exactType);
220214
if (classItr != m_TypeMap.end()) {
221215
// Find an instance of that EXACT type and name; derived types are not matched
222216
for (std::list<std::pair<std::string, Entity *>>::iterator instItr = (*classItr).second.begin(); instItr != (*classItr).second.end(); ++instItr) {
@@ -289,14 +283,15 @@ namespace RTE {
289283
if (withType == "All" || withType.empty()) {
290284
for (std::list<std::string>::const_iterator gItr = m_GroupRegister.begin(); gItr != m_GroupRegister.end(); ++gItr) {
291285
groupList.push_back(*gItr);
292-
//TODO it seems weird that foundAny isn't set to true here, given that the list gets filled. But I suppose no actual finding is done. Investigate this and see where it's called, maybe this should be changed
286+
// TODO: it seems weird that foundAny isn't set to true here, given that the list gets filled.
287+
// But I suppose no actual finding is done. Investigate this and see where it's called, maybe this should be changed
293288
}
294289
} else {
295-
map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator clsItr = m_TypeMap.find(withType);
296-
if (clsItr != m_TypeMap.end()) {
290+
std::map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator classItr = m_TypeMap.find(withType);
291+
if (classItr != m_TypeMap.end()) {
297292
const std::list<std::string> *pGroupList = 0;
298293
// Go through all the entities of that type, adding the groups they belong to
299-
for (std::list<std::pair<std::string, Entity *>>::iterator instItr = clsItr->second.begin(); instItr != clsItr->second.end(); ++instItr) {
294+
for (std::list<std::pair<std::string, Entity *>>::iterator instItr = classItr->second.begin(); instItr != classItr->second.end(); ++instItr) {
300295
pGroupList = instItr->second->GetGroupList();
301296

302297
for (std::list<std::string>::const_iterator gItr = pGroupList->begin(); gItr != pGroupList->end(); ++gItr) {
@@ -385,13 +380,14 @@ namespace RTE {
385380

386381
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
387382

388-
//TODO This method is almost identical to GetEntityPreset, except it doesn't return a const Entity *. Investigate if the latter needs to return const (based on what's using it) and if not, get rid of this and replace its uses. At the very least, consider renaming this
383+
// TODO: This method is almost identical to GetEntityPreset, except it doesn't return a const Entity *.
384+
// Investigate if the latter needs to return const (based on what's using it) and if not, get rid of this and replace its uses. At the very least, consider renaming this
389385
Entity * DataModule::GetEntityIfExactType(const std::string &exactType, const std::string &instanceName) {
390386
if (exactType.empty() || instanceName == "None" || instanceName.empty()) {
391387
return 0;
392388
}
393389

394-
map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator classItr = m_TypeMap.find(exactType);
390+
std::map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator classItr = m_TypeMap.find(exactType);
395391
if (classItr != m_TypeMap.end()) {
396392
// Find an instance of that EXACT type and name; derived types are not matched
397393
for (std::list<std::pair<std::string, Entity *>>::iterator instItr = (*classItr).second.begin(); instItr != (*classItr).second.end(); ++instItr) {
@@ -412,15 +408,15 @@ namespace RTE {
412408

413409
// Walk up the class hierarchy till we reach the top, adding an entry of the passed in entity into each typelist as we go along
414410
for (const Entity::ClassInfo *pClass = &(pEntToAdd->GetClass()); pClass != 0; pClass = pClass->GetParent()) {
415-
map<string, list<pair<string, Entity *> > >::iterator clsItr = m_TypeMap.find(pClass->GetName());
411+
std::map<std::string, std::list<std::pair<std::string, Entity *>>>::iterator classItr = m_TypeMap.find(pClass->GetName());
416412

417413
// No instances of this entity have been added yet so add a class category for it
418-
if (clsItr == m_TypeMap.end()) {
419-
clsItr = (m_TypeMap.insert(pair<string, list<pair<string, Entity *> > >(pClass->GetName(), list<pair<string, Entity *> >()))).first;
414+
if (classItr == m_TypeMap.end()) {
415+
classItr = (m_TypeMap.insert(std::pair<std::string, std::list<std::pair<std::string, Entity *>>>(pClass->GetName(), std::list<std::pair<std::string, Entity *>>()))).first;
420416
}
421417

422-
// NOTE We're adding the entity to the class category list but not transfering ownership. Also, we're not checking for collisions as they're assumed to have been checked for already
423-
(*clsItr).second.push_back(pair<string, Entity *>(pEntToAdd->GetPresetName(), pEntToAdd));
418+
// NOTE We're adding the entity to the class category list but not transferring ownership. Also, we're not checking for collisions as they're assumed to have been checked for already
419+
(*classItr).second.push_back(std::pair<std::string, Entity *>(pEntToAdd->GetPresetName(), pEntToAdd));
424420
}
425421
return true;
426422
}

0 commit comments

Comments
 (0)