Skip to content

Commit

Permalink
multistat: Store verified host identity
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jan 12, 2025
1 parent f2d9215 commit 46e7e2e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/multiopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ bool hostCampaign(const char *SessionName, char *hostPlayerName, bool spectatorH
setMultiStats(selectedPlayer, playerStats, true);
lookupRatingAsync(selectedPlayer);

multiStatsSetVerifiedHostIdentityFromJoin(playerStats.identity.toBytes(EcKey::Public));

ActivityManager::instance().updateMultiplayGameData(game, ingame, NETGameIsLocked());
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/multistat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,12 @@ void multiStatsSetVerifiedIdentityFromJoin(uint32_t playerIndex, const EcKey::Ke
}
}

void multiStatsSetVerifiedHostIdentityFromJoin(const EcKey::Key &identity)
{
ASSERT_OR_RETURN(, NetPlay.isHost || NetPlay.isHostAlive, "Unexpected state when called");
hostVerifiedJoinIdentities[NetPlay.hostPlayer].fromBytes(identity, EcKey::Public);
}

// ////////////////////////////////////////////////////////////////////////////
// Load Player Stats

Expand Down
1 change: 1 addition & 0 deletions src/multistat.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ bool recvMultiStats(NETQUEUE queue);
void lookupRatingAsync(uint32_t playerIndex);

void multiStatsSetVerifiedIdentityFromJoin(uint32_t playerIndex, const EcKey::Key &identity);
void multiStatsSetVerifiedHostIdentityFromJoin(const EcKey::Key &identity);

bool swapPlayerMultiStatsLocal(uint32_t playerIndexA, uint32_t playerIndexB);

Expand Down
5 changes: 5 additions & 0 deletions src/screens/joiningscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,11 @@ void WzJoiningGameScreen_HandlerRoot::processJoining()
// tmpJoiningQueuePair is now "owned" by NetPlay.hostPlayer's netQueue - do not delete it here!
tmpJoiningQueuePair = nullptr;

if ((game.blindMode == BLIND_MODE::NONE) || (NetPlay.hostPlayer >= MAX_PLAYER_SLOTS))
{
multiStatsSetVerifiedHostIdentityFromJoin(hostIdentity.toBytes(EcKey::Public));
}

handleSuccess();
return;
}
Expand Down

0 comments on commit 46e7e2e

Please sign in to comment.