@@ -29,7 +29,7 @@ bool __stdcall SidebarExt::AresTabCameo_RemoveCameo(BuildType* pItem)
29
29
{
30
30
const auto pFactory = pTechnoType->FindFactory (true , false , false , pCurrent);
31
31
32
- if (pFactory && pFactory-> Owner ->CanBuild (pTechnoType, false , true ) != CanBuildResult::Unbuildable)
32
+ if (pFactory && pCurrent ->CanBuild (pTechnoType, false , true ) != CanBuildResult::Unbuildable)
33
33
return false ;
34
34
}
35
35
else
@@ -40,32 +40,27 @@ bool __stdcall SidebarExt::AresTabCameo_RemoveCameo(BuildType* pItem)
40
40
return false ;
41
41
}
42
42
43
- if (pItem->CurrentFactory )
43
+ // Here we just raise AbandonAll without find factory, rather than check factory and Abandon then find factory and AbandonAll
44
+ if (pTechnoType)
44
45
{
45
- EventClass event = EventClass (pCurrent->ArrayIndex , EventType::Abandon, static_cast <int >(pItem->ItemType ), pItem->ItemIndex , pTechnoType && pTechnoType->Naval );
46
+ const EventClass event
47
+ (
48
+ pCurrent->ArrayIndex ,
49
+ EventType::AbandonAll,
50
+ static_cast <int >(pItem->ItemType ),
51
+ pItem->ItemIndex ,
52
+ pTechnoType->Naval
53
+ );
46
54
EventClass::AddEvent (event);
47
55
}
48
56
49
57
if (pItem->ItemType == AbstractType::BuildingType || pItem->ItemType == AbstractType::Building)
50
58
{
51
- DisplayClass::Instance->CurrentBuilding = nullptr ;
52
- DisplayClass::Instance->CurrentBuildingType = nullptr ;
53
- DisplayClass::Instance->CurrentBuildingOwnerArrayIndex = -1 ;
54
- DisplayClass::Instance->SetActiveFoundation (nullptr );
55
- }
56
-
57
- if (pTechnoType)
58
- {
59
- const auto absType = pTechnoType->WhatAmI ();
60
-
61
- // Here we make correction to the hardcoded BuildCat::DontCare
62
- const auto buildCat = absType == AbstractType::BuildingType ? static_cast <BuildingTypeClass*>(pTechnoType)->BuildCat : BuildCat::DontCare;
63
-
64
- if (pCurrent->GetPrimaryFactory (absType, pTechnoType->Naval , buildCat))
65
- {
66
- EventClass event = EventClass (pCurrent->ArrayIndex , EventType::AbandonAll, static_cast <int >(pItem->ItemType ), pItem->ItemIndex , pTechnoType->Naval );
67
- EventClass::AddEvent (event);
68
- }
59
+ const auto pDisplay = DisplayClass::Instance ();
60
+ pDisplay->SetActiveFoundation (nullptr );
61
+ pDisplay->CurrentBuilding = nullptr ;
62
+ pDisplay->CurrentBuildingType = nullptr ;
63
+ pDisplay->CurrentBuildingOwnerArrayIndex = -1 ;
69
64
}
70
65
71
66
return true ;
0 commit comments