Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 3 additions & 9 deletions Core/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2383,15 +2383,9 @@ bool GameLogic::onLogicCrc(MAYBE_UNUSED GameMessage *msg)
Player *msgPlayer = getMessagePlayer(msg);
if (TheNetwork)
{
Int slotIndex = -1;
for (Int i=0; i<MAX_SLOTS; ++i)
{
if (msgPlayer->getPlayerType() == PLAYER_HUMAN && TheNetwork->getPlayerName(i) == msgPlayer->getPlayerDisplayName())
{
slotIndex = i;
break;
}
}
const Int slotIndex = msgPlayer->getPlayerType() == PLAYER_HUMAN
? ThePlayerList->getSlotIndex(msgPlayer->getPlayerIndex())
: -1;

if (slotIndex < 0 || !TheNetwork->isPlayerConnected(slotIndex))
return false;
Expand Down
7 changes: 2 additions & 5 deletions Generals/Code/GameEngine/Source/Common/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,9 @@ void RecorderClass::handleCRCMessage(UnsignedInt newCRC, Int playerIndex, Bool f
}

Int localPlayerIndex = m_crcInfo.getLocalPlayer();
Bool samePlayer = FALSE;
AsciiString playerName;
playerName.format("player%d", localPlayerIndex);
const Player *p = ThePlayerList->getNthPlayer(playerIndex);
if (!p || (p->getPlayerNameKey() == NAMEKEY(playerName)))
samePlayer = TRUE;
const Int slotIndex = ThePlayerList->getSlotIndex(playerIndex);
const Bool samePlayer = !p || slotIndex == localPlayerIndex;
if (samePlayer || (localPlayerIndex < 0))
{
UnsignedInt playbackCRC = m_crcInfo.readCRC();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,12 @@ void VictoryConditions::update()
TheAudio->addAudioEvent(&leftGameSound);
}

for (Int idx = 0; idx < MAX_SLOTS; ++idx)
const Int slotIndex = ThePlayerList->getSlotIndex(p->getPlayerIndex());
GameSlot *slot = TheGameInfo && slotIndex >= 0 ? TheGameInfo->getSlot(slotIndex) : nullptr;
if (slot && slot->isAI())
{
AsciiString pName;
pName.format("player%d", idx);
if (p->getPlayerNameKey() == NAMEKEY(pName))
{
GameSlot *slot = (TheGameInfo)?TheGameInfo->getSlot(idx):nullptr;
if (slot && slot->isAI())
{
DEBUG_LOG(("Marking AI player %s as defeated", pName.str()));
slot->setLastFrameInGame(TheGameLogic->getFrame());
}
}
DEBUG_LOG(("Marking AI player %s as defeated", TheNameKeyGenerator->keyToName(p->getPlayerNameKey()).str()));
slot->setLastFrameInGame(TheGameLogic->getFrame());
}

// destroy any remaining units (infantry if its a short game, for example)
Expand Down
7 changes: 2 additions & 5 deletions GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,9 @@ void RecorderClass::handleCRCMessage(UnsignedInt newCRC, Int playerIndex, Bool f
}

Int localPlayerIndex = m_crcInfo.getLocalPlayer();
Bool samePlayer = FALSE;
AsciiString playerName;
playerName.format("player%d", localPlayerIndex);
const Player *p = ThePlayerList->getNthPlayer(playerIndex);
if (!p || (p->getPlayerNameKey() == NAMEKEY(playerName)))
samePlayer = TRUE;
const Int slotIndex = ThePlayerList->getSlotIndex(playerIndex);
const Bool samePlayer = !p || slotIndex == localPlayerIndex;
if (samePlayer || (localPlayerIndex < 0))
{
UnsignedInt playbackCRC = m_crcInfo.readCRC();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,12 @@ void VictoryConditions::update()
TheAudio->addAudioEvent(&leftGameSound);
}

for (Int idx = 0; idx < MAX_SLOTS; ++idx)
const Int slotIndex = ThePlayerList->getSlotIndex(p->getPlayerIndex());
GameSlot *slot = TheGameInfo && slotIndex >= 0 ? TheGameInfo->getSlot(slotIndex) : nullptr;
if (slot && slot->isAI())
{
AsciiString pName;
pName.format("player%d", idx);
if (p->getPlayerNameKey() == NAMEKEY(pName))
{
GameSlot *slot = (TheGameInfo)?TheGameInfo->getSlot(idx):nullptr;
if (slot && slot->isAI())
{
DEBUG_LOG(("Marking AI player %s as defeated", pName.str()));
slot->setLastFrameInGame(TheGameLogic->getFrame());
}
}
DEBUG_LOG(("Marking AI player %s as defeated", TheNameKeyGenerator->keyToName(p->getPlayerNameKey()).str()));
slot->setLastFrameInGame(TheGameLogic->getFrame());
}

// destroy any remaining units (infantry if its a short game, for example)
Expand Down
Loading