@@ -40,8 +40,23 @@ bool __stdcall SidebarExt::AresTabCameo_RemoveCameo(BuildType* pItem)
40
40
return false ;
41
41
}
42
42
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))
45
60
{
46
61
const EventClass event
47
62
(
@@ -54,15 +69,46 @@ bool __stdcall SidebarExt::AresTabCameo_RemoveCameo(BuildType* pItem)
54
69
EventClass::AddEvent (event);
55
70
}
56
71
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
+
57
89
if (pItem->ItemType == AbstractType::BuildingType || pItem->ItemType == AbstractType::Building)
58
90
{
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;
64
96
}
65
97
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
+ */
66
112
return true ;
67
113
}
68
114
0 commit comments