Skip to content

Commit ebb624c

Browse files
committed
Revert remove cameo modifications in 57a1c58
Restore the original optimization methods Add some comments Retain original code
1 parent 6659518 commit ebb624c

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

src/Ext/Sidebar/Body.cpp

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,23 @@ bool __stdcall SidebarExt::AresTabCameo_RemoveCameo(BuildType* pItem)
4040
return false;
4141
}
4242

43-
// Here we just raise AbandonAll without find factory, rather than check factory and Abandon then find factory and AbandonAll
44-
if (pTechnoType)
43+
// The following sections have been modified
44+
auto buildCat = BuildCat::DontCare;
45+
46+
if (pItem->ItemType == AbstractType::BuildingType || pItem->ItemType == AbstractType::Building)
47+
{
48+
buildCat = static_cast<BuildingTypeClass*>(pTechnoType)->BuildCat;
49+
const auto pDisplay = DisplayClass::Instance();
50+
pDisplay->SetActiveFoundation(nullptr);
51+
pDisplay->CurrentBuilding = nullptr;
52+
pDisplay->CurrentBuildingType = nullptr;
53+
pDisplay->CurrentBuildingOwnerArrayIndex = -1;
54+
}
55+
56+
// AbandonAll contains Abandon, if the factory cannot be found, it will also cannot be found when respont to this event.
57+
// The original version added two events, I think it's to solve the problem of BuildCat::Combat because of the hardcode.
58+
// Here make correction to the hardcoded BuildCat::DontCare.
59+
if (pTechnoType && pCurrent->GetPrimaryFactory(pItem->ItemType, pTechnoType->Naval, buildCat))
4560
{
4661
const EventClass event
4762
(
@@ -54,15 +69,46 @@ bool __stdcall SidebarExt::AresTabCameo_RemoveCameo(BuildType* pItem)
5469
EventClass::AddEvent(event);
5570
}
5671

72+
// The original code is as follows
73+
/*
74+
if (pItem->CurrentFactory)
75+
{
76+
const EventClass event
77+
(
78+
pCurrent->ArrayIndex,
79+
EventType::Abandon,
80+
static_cast<int>(pItem->ItemType),
81+
pItem->ItemIndex,
82+
pTechnoType && pTechnoType->Naval
83+
);
84+
EventClass::AddEvent(event);
85+
}
86+
87+
auto buildCat = BuildCat::DontCare;
88+
5789
if (pItem->ItemType == AbstractType::BuildingType || pItem->ItemType == AbstractType::Building)
5890
{
59-
const auto pDisplay = DisplayClass::Instance();
60-
pDisplay->SetActiveFoundation(nullptr);
61-
pDisplay->CurrentBuilding = nullptr;
62-
pDisplay->CurrentBuildingType = nullptr;
63-
pDisplay->CurrentBuildingOwnerArrayIndex = -1;
91+
buildCat = static_cast<BuildingTypeClass*>(pTechnoType)->BuildCat;
92+
DisplayClass::Instance->SetActiveFoundation(nullptr);
93+
DisplayClass::Instance->CurrentBuilding = nullptr;
94+
DisplayClass::Instance->CurrentBuildingType = nullptr;
95+
DisplayClass::Instance->CurrentBuildingOwnerArrayIndex = -1;
6496
}
6597
98+
// Here make correction to the hardcoded BuildCat::DontCare.
99+
if (pTechnoType && pCurrent->GetPrimaryFactory(pItem->ItemType, pTechnoType->Naval, buildCat))
100+
{
101+
const EventClass event
102+
(
103+
pCurrent->ArrayIndex,
104+
EventType::AbandonAll,
105+
static_cast<int>(pItem->ItemType),
106+
pItem->ItemIndex,
107+
pTechnoType->Naval
108+
);
109+
EventClass::AddEvent(event);
110+
}
111+
*/
66112
return true;
67113
}
68114

0 commit comments

Comments
 (0)