Skip to content

Commit

Permalink
cmdinterface: Add new WZEVENT output for movedPlayerToSpec & movedSpe…
Browse files Browse the repository at this point in the history
…cToPlayer
  • Loading branch information
past-due committed Jul 6, 2024
1 parent 043d0a2 commit c31d32f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/netplay/netplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,17 @@ bool NETmovePlayerToSpectatorOnlySlot(uint32_t playerIdx, bool hostOverride /*=

playerManagementRecord.movedPlayerToSpectators(NetPlay.players[availableSpectatorIndex.value()], playerPublicKeyIdentity, hostOverride);

if (wz_command_interface_enabled())
{
uint32_t newSpecIdx = availableSpectatorIndex.value();
std::string playerPublicKeyB64 = base64Encode(getMultiStats(newSpecIdx).identity.toBytes(EcKey::Public));
std::string playerIdentityHash = getMultiStats(newSpecIdx).identity.publicHashString();
std::string playerVerifiedStatus = (ingame.VerifiedIdentity[newSpecIdx]) ? "V" : "?";
std::string playerName = NetPlay.players[newSpecIdx].name;
std::string playerNameB64 = base64Encode(std::vector<unsigned char>(playerName.begin(), playerName.end()));
wz_command_interface_output("WZEVENT: movedPlayerToSpec: %" PRIu32 " -> %" PRIu32 " %s %s %s %s %s\n", playerIdx, newSpecIdx, playerPublicKeyB64.c_str(), playerIdentityHash.c_str(), playerVerifiedStatus.c_str(), playerNameB64.c_str(), NetPlay.players[newSpecIdx].IPtextAddress);
}

// Broadcast the swapped player info
NETBroadcastTwoPlayerInfo(playerIdx, availableSpectatorIndex.value());

Expand Down Expand Up @@ -2136,6 +2147,16 @@ SpectatorToPlayerMoveResult NETmoveSpectatorToPlayerSlot(uint32_t playerIdx, opt

playerManagementRecord.movedSpectatorToPlayers(NetPlay.players[newPlayerIdx.value()], spectatorPublicKeyIdentity, hostOverride);

if (wz_command_interface_enabled())
{
std::string playerPublicKeyB64 = base64Encode(getMultiStats(newPlayerIdx.value()).identity.toBytes(EcKey::Public));
std::string playerIdentityHash = getMultiStats(newPlayerIdx.value()).identity.publicHashString();
std::string playerVerifiedStatus = (ingame.VerifiedIdentity[newPlayerIdx.value()]) ? "V" : "?";
std::string playerName = NetPlay.players[newPlayerIdx.value()].name;
std::string playerNameB64 = base64Encode(std::vector<unsigned char>(playerName.begin(), playerName.end()));
wz_command_interface_output("WZEVENT: movedSpecToPlayer: %" PRIu32 " -> %" PRIu32 " %s %s %s %s %s\n", playerIdx, newPlayerIdx.value(), playerPublicKeyB64.c_str(), playerIdentityHash.c_str(), playerVerifiedStatus.c_str(), playerNameB64.c_str(), NetPlay.players[newPlayerIdx.value()].IPtextAddress);
}

// Broadcast the swapped player info
NETBroadcastTwoPlayerInfo(playerIdx, newPlayerIdx.value());

Expand Down

0 comments on commit c31d32f

Please sign in to comment.