Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/Misc/Observers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,30 @@ DEFINE_HOOK(0x5C98E5, MultiplayerScore__5C98A0_SkipObserverScore, 0x6)
}

// Use correct colors in diplomacy menu for all observers
DEFINE_HOOK(0x65838B, RadarClass__658330_SetObserverColorScheme, 0x5)
DEFINE_HOOK(0x6583B2, RadarClass__658330_SetObserverColorScheme, 0x5)
{
if (!Spawner::Enabled)
return 0;

enum { SelectLightGrey = 0x658397 };
GET(HouseClass*, pHouse, EBX);
R->EAX<HouseClass*>(pHouse->IsInitiallyObserver() ? HouseClass::CurrentPlayer : (HouseClass*) nullptr);
return 0x65838B + 0x5;

if (pHouse->IsHumanPlayer && pHouse->IsInitiallyObserver())
return SelectLightGrey;

return 0;
}

// Use correct flag icon in diplomacy menu for all observers
DEFINE_HOOK(0x65846D, RadarClass__658330_SetObserverFlag, 0x6)
DEFINE_HOOK(0x658473, RadarClass__658330_SetObserverFlag, 0x5)
{
if (!Spawner::Enabled)
return 0;

GET(HouseClass*, pHouse, EBX);
R->ECX(pHouse->IsInitiallyObserver() ? -3 : pHouse->Type->ArrayIndex);
if (pHouse->IsHumanPlayer && pHouse->Defeated && pHouse->IsInitiallyObserver())
R->ECX(-3);

return 0x658485;
}

Expand Down
22 changes: 19 additions & 3 deletions src/Spawner/Spawner.Hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ DEFINE_HOOK(0x4FC262, HouseClass__MPlayerDefeated_SkipObserver, 0x6)
if (!MPlayerDefeated::pThis)
return 0;

return MPlayerDefeated::pThis->IsObserver()
return MPlayerDefeated::pThis->IsInitiallyObserver()
? ProcEpilogue
: 0;
}
Expand Down Expand Up @@ -166,8 +166,24 @@ DEFINE_HOOK(0x4FC57C, HouseClass__MPlayerDefeated_CheckAliveAndHumans, 0x7)
GET_STACK(int, numHumans, STACK_OFFSET(0xC0, -0xA8));
GET_STACK(int, numAlive, STACK_OFFSET(0xC0, -0xAC));

bool continueWithoutHumans = Spawner::GetConfig()->ContinueWithoutHumans ||
(SessionClass::IsSkirmish() && HouseClass::CurrentPlayer->IsInitiallyObserver());
bool continueWithoutHumans = Spawner::GetConfig()->ContinueWithoutHumans
|| MPlayerDefeated::pThis->IsInitiallyObserver();

if (!continueWithoutHumans && !MPlayerDefeated::pThis->IsHumanPlayer)
{
bool isHasAliveHumanPlayers = false;
for (const auto pHouse : HouseClass::Array)
{
if (pHouse->IsHumanPlayer && !pHouse->Defeated)
{
isHasAliveHumanPlayers = true;
break;
}
}

if (!isHasAliveHumanPlayers)
continueWithoutHumans = true;
}

if (numAlive > 1 && (numHumans != 0 || continueWithoutHumans))
{
Expand Down
6 changes: 1 addition & 5 deletions src/Spawner/Spawner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ void Spawner::AssignHouses()

const auto pHousesConfig = &Spawner::Config->Houses[indexOfHouseArray];
const int nSpawnLocations = pHousesConfig->SpawnLocations;
const bool isObserver = pHouse->IsHumanPlayer && (
pHousesConfig->IsObserver
|| nSpawnLocations == -1
|| nSpawnLocations == 90
);
const bool isObserver = pHouse->IsHumanPlayer &&pHousesConfig->IsObserver;

// Set Alliances
for (char i = 0; i < (char)std::size(pHousesConfig->Alliances); ++i)
Expand Down
Loading