Skip to content

Commit

Permalink
net: Send mission data once and let clients change active player
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed May 30, 2024
1 parent a19528f commit 603ad76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Source/Network/P2P_interface1Th.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,10 @@ void PNetCenter::HandlerInputNetCommand()
//Transfer mission from packet
clientMissionDescription = nc4c_sl.missionDescription_;
nc4c_sl.missionDescription_ = nullptr;


//Set active player as ourselves
clientMissionDescription->activePlayerID = clientMissionDescription->findPlayer(m_localNETID);

m_bStarted = true;

if (!isHost()) {
Expand Down
19 changes: 5 additions & 14 deletions Source/Network/P2P_interface2Th_Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void PNetCenter::UpdateBattleData() {
}
mission->packPlayerIDs();

LogMsg("Battle info ready\n");
LogMsg("Mission info ready\n");
}

void PNetCenter::SendBattleData() {
Expand All @@ -287,19 +287,10 @@ void PNetCenter::SendBattleData() {
}

//Send data
//Don't change player data here or prev players will have outdated info about next players
for (int i=0; i<mission->playerAmountScenarioMax; i++) {
const PlayerData& pd = mission->playersData[i];
if (pd.realPlayerType == REAL_PLAYER_TYPE_PLAYER) {
mission->activePlayerID = pd.playerID;
netCommand4C_StartLoadGame nccsl(mission);
printf("Sending mission to idx %d id %d netid 0x%" PRIX64 "\n", i, pd.playerID, pd.netid);
SendEvent(nccsl, pd.netid);
}
}
mission->activePlayerID = mission->findPlayer(m_localNETID);

LogMsg("Sent battle info\n");
printf("Sending mission\n");
netCommand4C_StartLoadGame nccsl(mission);
SendEvent(nccsl, NETID_ALL);
LogMsg("Sent mission\n");
}

void PNetCenter::UpdateCurrentMissionOnRelayRoom() {
Expand Down

0 comments on commit 603ad76

Please sign in to comment.