Skip to content

Commit e8152ed

Browse files
committed
Fixed GetArea fuckery in the laziest way I know how
1 parent 58a8809 commit e8152ed

File tree

8 files changed

+26
-31
lines changed

8 files changed

+26
-31
lines changed

Source/Activities/AreaEditor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,15 @@ void AreaEditor::Update() {
289289
// Make sure we're not trying to create a noname area
290290
if (!m_pNewAreaName->GetText().empty()) {
291291
// Check if name is already taken, and if so, select the taken one instead of creating a new
292-
if (Scene::Area* pArea = pCurrentScene->GetArea2(m_pNewAreaName->GetText())) {
292+
if (Scene::Area* pArea = pCurrentScene->GetArea(m_pNewAreaName->GetText())) {
293293
m_pEditorGUI->SetCurrentArea(pArea);
294294
m_pEditorGUI->SetEditorGUIMode(AreaEditorGUI::PREADDMOVEBOX);
295295
} else {
296296
// Make and name new Area
297297
Scene::Area newArea(m_pNewAreaName->GetText());
298298
pCurrentScene->m_AreaList.push_back(newArea);
299299
// Set the new area as the active one in the GUI, note we're getting the correct one from the scene, it's a copy of the one passed in
300-
m_pEditorGUI->SetCurrentArea(pCurrentScene->GetArea2(newArea.GetName()));
300+
m_pEditorGUI->SetCurrentArea(pCurrentScene->GetArea(newArea.GetName()));
301301
// Update teh picker list of the GUI so we can mousewheel between all the Areas, incl the new one
302302
m_pEditorGUI->UpdatePickerList(newArea.GetName());
303303
}

Source/Activities/GATutorial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int GATutorial::Start() {
170170
// See if there are specified landing zone areas defined in the scene
171171
char str[64];
172172
std::snprintf(str, sizeof(str), "LZ Team %d", team + 1);
173-
Scene::Area* pArea = g_SceneMan.GetScene()->GetArea1(str);
173+
Scene::Area* pArea = g_SceneMan.GetScene()->GetArea(str);
174174
// pArea = pArea ? pArea : g_SceneMan.GetScene()->GetArea("Landing Zone");
175175
// If area is defined, save a copy so we can lock the LZ selection to within its boxes
176176
if (pArea && !pArea->HasNoArea())

Source/Entities/HDFirearm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ void HDFirearm::Update() {
938938
m_FireSound->Play(m_Pos);
939939
}
940940
if (m_FireEchoSound) {
941-
Scene::Area* noEchoArea = g_SceneMan.GetScene()->GetArea1("IndoorArea");
941+
Scene::Area* noEchoArea = g_SceneMan.GetScene()->GetArea("IndoorArea");
942942
if (noEchoArea == nullptr || !noEchoArea->IsInside(m_Pos)) {
943943
m_FireEchoSound->Play(m_Pos);
944944
}

Source/Entities/Scene.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,15 +1848,15 @@ bool Scene::SetArea(Area& newArea) {
18481848
return false;
18491849
}
18501850

1851-
bool Scene::HasArea(std::string areaName) {
1851+
bool Scene::HasArea(const std::string& areaName) {
18521852
for (std::list<Area>::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
18531853
if ((*aItr).GetName() == areaName)
18541854
return true;
18551855
}
18561856
return false;
18571857
}
18581858

1859-
Scene::Area* Scene::GetArea1(const std::string_view& areaName) {
1859+
Scene::Area* Scene::GetArea(const std::string& areaName) {
18601860
for (Scene::Area& area: m_AreaList) {
18611861
if (area.GetName() == areaName) {
18621862
return &area;
@@ -1866,7 +1866,7 @@ Scene::Area* Scene::GetArea1(const std::string_view& areaName) {
18661866
return nullptr;
18671867
}
18681868

1869-
bool Scene::RemoveArea(std::string areaName) {
1869+
bool Scene::RemoveArea(const std::string& areaName) {
18701870
for (std::list<Area>::iterator aItr = m_AreaList.begin(); aItr != m_AreaList.end(); ++aItr) {
18711871
if ((*aItr).GetName() == areaName) {
18721872
m_AreaList.erase(aItr);
@@ -1876,7 +1876,7 @@ bool Scene::RemoveArea(std::string areaName) {
18761876
return false;
18771877
}
18781878

1879-
bool Scene::WithinArea(std::string areaName, const Vector& point) const {
1879+
bool Scene::WithinArea(const std::string& areaName, const Vector& point) const {
18801880
if (areaName.empty())
18811881
return false;
18821882

@@ -2219,7 +2219,7 @@ float Scene::ApplyBuildBudget(int player, int* pObjectsBuilt) {
22192219
TerrainObject* pTO = dynamic_cast<TerrainObject*>(pObjectToPlace);
22202220
if (pTO) {
22212221
if (HasArea(METABASE_AREA_NAME)) {
2222-
Scene::Area* metaBase = GetArea1(METABASE_AREA_NAME);
2222+
Scene::Area* metaBase = GetArea(METABASE_AREA_NAME);
22232223
if (metaBase) {
22242224
float x1 = pTO->GetPos().m_X + pTO->GetBitmapOffset().m_X;
22252225
float y1 = pTO->GetPos().m_Y + pTO->GetBitmapOffset().m_Y;
@@ -2447,7 +2447,7 @@ void Scene::Update() {
24472447

24482448
for (const std::string& navigableArea: m_NavigableAreas) {
24492449
if (HasArea(navigableArea)) {
2450-
for (const Box& navigableBox: GetArea2(navigableArea)->GetBoxes()) {
2450+
for (const Box& navigableBox: GetArea(navigableArea)->GetBoxes()) {
24512451
pathFinder.MarkBoxNavigable(navigableBox, true);
24522452
}
24532453
}

Source/Entities/Scene.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,12 @@ namespace RTE {
501501
/// This won't throw any errors to the console if the Area isn't found.
502502
/// @param areaName The name of the Area to try to find in this Scene.
503503
/// @return Whether the specified area is defined in this Scene.
504-
bool HasArea(std::string areaName);
504+
bool HasArea(const std::string& areaName);
505505

506506
/// Gets a specified Area identified by name. Ownership is NOT transferred!
507507
/// @param areaName The name of the Area to try to get.
508508
/// @return A pointer to the Area asked for, or nullptr if no Area of that name was found.
509-
Area* GetArea1(const std::string_view& areaName);
510-
511-
/// Gets a specified Area identified by name. Ownership is NOT transferred!
512-
/// @param areaName The name of the Area to try to get.
513-
/// @return A pointer to the Area asked for, or nullptr if no Area of that name was found.
514-
Area* GetArea2(const std::string& areaName) { return GetArea1(areaName); }
509+
Area* GetArea(const std::string& areaName);
515510

516511
void AddNavigableArea(const std::string& areaName) {
517512
m_NavigableAreas.push_back(areaName);
@@ -525,14 +520,14 @@ namespace RTE {
525520
/// Removes a specific Area identified by a name.
526521
/// @param areaName The name of the Area to try to remove.
527522
/// @return Whether an Area of that name was found, and subsequently removed.
528-
bool RemoveArea(std::string areaName);
523+
bool RemoveArea(const std::string& areaName);
529524

530525
/// Checks if a point is within a specific named Area of this Scene. If
531526
/// no Area of the name is found, this just returns false without error.
532527
/// @param areaName The name of the Area to try to check against.
533528
/// @param point The point to see if it's within the specified Area.
534529
/// @return Whether any Area of that name was found, AND the point falls within it.
535-
bool WithinArea(std::string areaName, const Vector& point) const;
530+
bool WithinArea(const std::string& areaName, const Vector& point) const;
536531

537532
/// Gets the global acceleration (in m/s^2) that is applied to all movable
538533
/// objects' velocities during every frame. Typically models gravity.

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Scene) {
11971197
.def_readwrite("Areas", &Scene::m_AreaList, luabind::return_stl_iterator)
11981198
.def("SetArea", &Scene::SetArea)
11991199
.def("HasArea", &Scene::HasArea)
1200-
.def("GetArea", (Scene::Area * (Scene::*)(const std::string& areaName)) & Scene::GetArea2)
1200+
.def("GetArea", &Scene::GetArea)
12011201
.def("WithinArea", &Scene::WithinArea)
12021202
.def("AddNavigableArea", &Scene::AddNavigableArea)
12031203
.def("ClearNavigableAreas", &Scene::ClearNavigableAreas)

Source/Managers/SceneMan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,7 +2240,7 @@ bool SceneMan::OverAltitude(const Vector& point, int threshold, int accuracy) {
22402240
bool SceneMan::IsPointInNoGravArea(const Vector& point) const {
22412241
// Todo, instead of a nograv area maybe best to tag certain areas as NoGrav. As otherwise it's tricky to keep track of when things are removed
22422242
if (m_pCurrentScene) {
2243-
Scene::Area* noGravArea = m_pCurrentScene->GetArea1("NoGravityArea");
2243+
Scene::Area* noGravArea = m_pCurrentScene->GetArea("NoGravityArea");
22442244
if (noGravArea && noGravArea->IsInside(point)) {
22452245
return true;
22462246
}
@@ -2648,7 +2648,7 @@ void SceneMan::Draw(BITMAP* targetBitmap, BITMAP* targetGUIBitmap, const Vector&
26482648

26492649
static bool s_drawNoGravBoxes = false;
26502650
if (s_drawNoGravBoxes) {
2651-
if (Scene::Area* noGravArea = m_pCurrentScene->GetArea1("NoGravityArea")) {
2651+
if (Scene::Area* noGravArea = m_pCurrentScene->GetArea("NoGravityArea")) {
26522652
const std::vector<Box>& boxList = noGravArea->GetBoxes();
26532653
g_FrameMan.SetTransTableFromPreset(TransparencyPreset::MoreTrans);
26542654
drawing_mode(DRAW_MODE_TRANS, 0, 0, 0);

Source/Menus/AreaPickerGUI.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Scene::Area* AreaPickerGUI::GetNextArea() {
173173
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
174174
if (pItem) {
175175
g_GUISound.SelectionChangeSound()->Play();
176-
return g_SceneMan.GetScene()->GetArea2(pItem->m_Name);
176+
return g_SceneMan.GetScene()->GetArea(pItem->m_Name);
177177
}
178178
return 0;
179179
}
@@ -189,7 +189,7 @@ Scene::Area* AreaPickerGUI::GetPrevArea() {
189189
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
190190
if (pItem) {
191191
g_GUISound.SelectionChangeSound()->Play();
192-
return g_SceneMan.GetScene()->GetArea2(pItem->m_Name);
192+
return g_SceneMan.GetScene()->GetArea(pItem->m_Name);
193193
}
194194
return 0;
195195
}
@@ -215,7 +215,7 @@ void AreaPickerGUI::UpdateAreasList(std::string selectAreaName) {
215215
// Set the picked area to be the one now selected at the top
216216
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
217217
if (pItem)
218-
m_pPickedArea = pScene->GetArea2(pItem->m_Name);
218+
m_pPickedArea = pScene->GetArea(pItem->m_Name);
219219
}
220220
}
221221

@@ -329,7 +329,7 @@ void AreaPickerGUI::Update() {
329329
// Report the newly selected item as being 'picked', but don't close the picker
330330
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
331331
if (pItem)
332-
m_pPickedArea = g_SceneMan.GetScene()->GetArea2(pItem->m_Name);
332+
m_pPickedArea = g_SceneMan.GetScene()->GetArea(pItem->m_Name);
333333
g_GUISound.SelectionChangeSound()->Play();
334334
} else if (pressUp) {
335335
m_SelectedAreaIndex--;
@@ -341,7 +341,7 @@ void AreaPickerGUI::Update() {
341341
// Report the newly selected item as being 'picked', but don't close the picker
342342
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
343343
if (pItem)
344-
m_pPickedArea = g_SceneMan.GetScene()->GetArea2(pItem->m_Name);
344+
m_pPickedArea = g_SceneMan.GetScene()->GetArea(pItem->m_Name);
345345

346346
g_GUISound.SelectionChangeSound()->Play();
347347
}
@@ -351,7 +351,7 @@ void AreaPickerGUI::Update() {
351351
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
352352
if (pItem) {
353353
// User has made final selection, so close the Picker
354-
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea2(pItem->m_Name)) {
354+
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea(pItem->m_Name)) {
355355
g_GUISound.AreaPickedSound()->Play();
356356
SetEnabled(false);
357357
}
@@ -363,7 +363,7 @@ void AreaPickerGUI::Update() {
363363
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
364364
if (pItem) {
365365
// User has made final selection, so close the Picker
366-
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea2(pItem->m_Name)) {
366+
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea(pItem->m_Name)) {
367367
g_GUISound.AreaPickedSound()->Play();
368368
SetEnabled(false);
369369
}
@@ -412,7 +412,7 @@ void AreaPickerGUI::Update() {
412412
if (pItem) {
413413
m_SelectedAreaIndex = m_pAreasList->GetSelectedIndex();
414414
// User has made final selection, so close the Picker
415-
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea2(pItem->m_Name)) {
415+
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea(pItem->m_Name)) {
416416
g_GUISound.AreaPickedSound()->Play();
417417
SetEnabled(false);
418418
}
@@ -429,7 +429,7 @@ void AreaPickerGUI::Update() {
429429
GUIListPanel::Item* pItem = m_pAreasList->GetSelected();
430430
if (pItem) {
431431
// User has made final selection, so close the Picker
432-
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea2(pItem->m_Name)) {
432+
if (m_pPickedArea = g_SceneMan.GetScene()->GetArea(pItem->m_Name)) {
433433
g_GUISound.AreaPickedSound()->Play();
434434
SetEnabled(false);
435435
}

0 commit comments

Comments
 (0)