Skip to content

Commit

Permalink
Properly display kicked status
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Jun 3, 2024
1 parent 1015306 commit af63cfe
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Source/Game/Texts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ void qdTextDB::load_supplementary_texts(const std::string& locale) {
"Interface.Menu.Messages.Multiplayer.HostTerminated=Хост прекратил игру или отключился",
"Interface.Menu.Messages.Multiplayer.StartingGame=Игра начинается...",
"Interface.Menu.Messages.Multiplayer.ChatTip=Нажмите &00FFFF\"Insert\"&FFFFFF чтобы написать игрокам из своего клана, &00FFFF\"Control + Insert\"&FFFFFF или &00FFFF\"Control + Space\"&FFFFFF чтобы написать всем игрокам.",
"Interface.Menu.Messages.Multiplayer.Kicked=Вас кикнули.",
"Interface.Menu.Messages.Confirmations.PendingChanges=Отложенные изменения не будут применены, вернуться в главное меню?",
"Interface.Menu.Messages.Confirmations.ApplyChangesRestart=Чтобы применить изменения, требуется перезапуск игры, вы уверены?",
"Interface.Menu.Messages.Confirmations.OpenWeb=Открыть сайт?",
Expand Down Expand Up @@ -913,6 +914,7 @@ void qdTextDB::load_supplementary_texts(const std::string& locale) {
"Interface.Menu.Messages.Multiplayer.HostTerminated=Host has terminated session or disconnected",
"Interface.Menu.Messages.Multiplayer.StartingGame=Starting the game...",
"Interface.Menu.Messages.Multiplayer.ChatTip=Press &00FFFF\"Insert\"&FFFFFF to chat with your clan players, &00FFFF\"Control + Insert\"&FFFFFF or &00FFFF\"Control + Space\"&FFFFFF to chat with all players.",
"Interface.Menu.Messages.Multiplayer.Kicked=You got kicked.",
"Interface.Menu.Messages.Confirmations.PendingChanges=Pending changes will not be applied, return to main menu?",
"Interface.Menu.Messages.Confirmations.ApplyChangesRestart=Game restart is required to apply changes, are you sure?",
"Interface.Menu.Messages.Confirmations.OpenWeb=Open the website?",
Expand Down
3 changes: 2 additions & 1 deletion Source/Network/P2P_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ struct PClientData
enum e_PNCInterfaceCommands {
PNC_INTERFACE_COMMAND_NONE,
PNC_INTERFACE_COMMAND_CONNECTION_FAILED,
PNC_INTERFACE_COMMAND_CONNECTION_DROPPED,
PNC_INTERFACE_COMMAND_KICKED,
PNC_INTERFACE_COMMAND_INFO_PLAYER_EXIT,
PNC_INTERFACE_COMMAND_INFO_PLAYER_DISCONNECTED,
PNC_INTERFACE_COMMAND_INFO_MESSAGE,
Expand Down Expand Up @@ -531,6 +531,7 @@ class PNetCenter {

bool Init();
void SetConnectionTimeout(int ms);
void KickPlayer(NETID netid);
void RemovePlayer(NETID netid);

bool isConnected() const;
Expand Down
11 changes: 8 additions & 3 deletions Source/Network/P2P_interface1Th.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,12 @@ void PNetCenter::HandlerInputNetCommand()
netCommand4G_Exit nc4g_exit(in_ClientBuf);
//Host already does this before relaying to itself
if (!isHost()) {
ExitClient(nc4g_exit.netid);
if (nc4g_exit.netid == m_localNETID) {
ExecuteInternalCommand(PNC_COMMAND__RESET, false);
ExecuteInterfaceCommand(PNC_INTERFACE_COMMAND_KICKED);
} else {
ExitClient(nc4g_exit.netid);
}
}
break;
}
Expand Down Expand Up @@ -533,8 +538,8 @@ void PNetCenter::P2PIQuant()
gameShell->generalErrorOccured(GameShell::GENERAL_CONNECTION_FAILED);
end_game = true;
break;
case PNC_INTERFACE_COMMAND_CONNECTION_DROPPED:
gameShell->generalErrorOccured(GameShell::CLIENT_DROPPED);
case PNC_INTERFACE_COMMAND_KICKED:
gameShell->generalErrorOccured(GameShell::KICKED);
end_game = true;
break;
case PNC_INTERFACE_COMMAND_HOST_TERMINATED_GAME:
Expand Down
6 changes: 3 additions & 3 deletions Source/Network/P2P_interface2Th_Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void PNetCenter::CheckClients()
{
LogMsg("Client NID 0x%" PRIX64 " is not ready. removing.\n", (*i)->netidPlayer);

RemovePlayer((*i)->netidPlayer);
KickPlayer((*i)->netidPlayer);

delete *i;
m_clients.erase(i++);
Expand Down Expand Up @@ -523,7 +523,7 @@ void PNetCenter::hostProcessPlayerClientPackets(PClientData* client) {
pd.realPlayerType = ncChRT.newRealPlayerType_;
}
}
RemovePlayer(delPlayerNETID);
KickPlayer(delPlayerNETID);
} else if (pd.realPlayerType==REAL_PLAYER_TYPE_PLAYER_AI) {
if (ncChRT.newRealPlayerType_ == REAL_PLAYER_TYPE_OPEN) {
mission.disconnect2PlayerData(ncChRT.idxPlayerData_);
Expand Down Expand Up @@ -679,7 +679,7 @@ void PNetCenter::hostProcessPlayerClientPackets(PClientData* client) {
NETID delPlayerNETID=hostMissionDescription->playersData[i].netid;
hostMissionDescription->disconnect2PlayerData(i);
//hostMissionDescription->playersData[i].realPlayerType=REAL_PLAYER_TYPE_CLOSE;
RemovePlayer(delPlayerNETID); //Полное удаление по DPN_MSGID_DESTROY_PLAYER
KickPlayer(delPlayerNETID); //Полное удаление по DPN_MSGID_DESTROY_PLAYER
}
}
*hostMissionDescription = nc_changeMap.missionDescription_;
Expand Down
12 changes: 11 additions & 1 deletion Source/Network/P2P_interface2Th_NetConn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
#include "ServerList.h"

void PNetCenter::SetConnectionTimeout(int _ms) {
//Unused since SDL_net doesn't have any way to set connect or send timeouts
//Unused since SDL_net doesn't have any way to set connect or send timeouts
//TODO we do have timeout now but is hardcoded as constant, remove it and use this
//connectionHandler->connection_timeout = ms;
}

void PNetCenter::KickPlayer(NETID netid) {
fprintf(stdout, "KickPlayer: 0x%" PRIX64 "\n", netid);

netCommand4G_Exit ex(netid);
SendEvent(ex, netid);

RemovePlayer(netid);
}

void PNetCenter::RemovePlayer(NETID netid)
{
fprintf(stdout, "RemovePlayer: 0x%" PRIX64 "\n", netid);
Expand Down
2 changes: 1 addition & 1 deletion Source/UserInterface/GameShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class GameShell

enum GeneralErrorType {
GENERAL_CONNECTION_FAILED,
CLIENT_DROPPED,
KICKED,
HOST_TERMINATED,
DESYNC
};
Expand Down
4 changes: 2 additions & 2 deletions Source/UserInterface/Menu/MultiplayerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ int showGeneralErrorMessageQuant(float, float ) {
case GameShell::GENERAL_CONNECTION_FAILED:
textID = "Interface.Menu.Messages.Multiplayer.ConnectionFailed";
break;
case GameShell::CLIENT_DROPPED:
textID = "Interface.Menu.Messages.Multiplayer.ClientDropped";
case GameShell::KICKED:
textID = "Interface.Menu.Messages.Multiplayer.Kicked";
break;
case GameShell::HOST_TERMINATED:
textID = "Interface.Menu.Messages.Multiplayer.HostTerminated";
Expand Down

0 comments on commit af63cfe

Please sign in to comment.