Bazaar developer reference

CvPlayer::disconnected()

Defined in
CvPlayer.cpp, line 27757
Class
CvPlayer
Hook name
CivHooks::CvPlayer_disconnected

Hooks

static bool BeforeCvPlayer_disconnected(CvPlayer* self);static void AfterCvPlayer_disconnected(CvPlayer* self);static void ReplaceCvPlayer_disconnected(void (*original)(CvPlayer*), CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_disconnected>(host, &BeforeCvPlayer_disconnected);CivRegisterAfter<CivHooks::CvPlayer_disconnected>(host, &AfterCvPlayer_disconnected);CivRegisterReplace<CivHooks::CvPlayer_disconnected>(host, &ReplaceCvPlayer_disconnected);

Code

27757void CvPlayer::disconnected()27758{27759	bool isMultiplayer = GC.getGame().isGameMultiPlayer();27760	if(isMultiplayer && isHuman() && !isLocalPlayer())27761	{27762			//log message for debugging the occasional lack of disconnect notification when Steam p2p connections timeout. - bolson 1/10/1327763			FILogFile* logFile = LOGFILEMGR.GetLog("net_message_debug.log", 0);27764			if(logFile)27765			{27766				logFile->DebugMsg("Attempted to post notification for player disconnect event.  Player(%i)", GetID());27767			}2776827769			CvNotifications* pNotifications = GET_PLAYER(GC.getGame().getActivePlayer()).GetNotifications();27770			if(pNotifications){27771				if(gDLL->IsPlayerKicked(GetID())){27772					Localization::String kickedMsg = Localization::Lookup("TXT_KEY_PLAYER_KICKED");27773					kickedMsg << getNameKey();27774					pNotifications->Add(NOTIFICATION_PLAYER_KICKED, kickedMsg.toUTF8(), kickedMsg.toUTF8(), -1, -1, GetID());27775				}27776				else{27777					Localization::String disconnectString = Localization::Lookup("TXT_KEY_PLAYER_DISCONNECTED");27778					disconnectString << getNameKey();2777927780					if(CvPreGame::isPitBoss()){27781						disconnectString = Localization::Lookup("TXT_KEY_PLAYER_DISCONNECTED_PITBOSS");27782						disconnectString << getNameKey();	27783					}2778427785					pNotifications->Add(NOTIFICATION_PLAYER_DISCONNECTED, disconnectString.toUTF8(), disconnectString.toUTF8(), -1, -1, GetID());27786				}27787			}2778827789		if(!isObserver() && (!CvPreGame::isPitBoss() || gDLL->IsPlayerKicked(GetID())))27790		{27791			// JAR : First pass, automatically fall back to CPU so the27792			// game can continue. Todo : add popup on host asking whether27793			// the AI should take over or everyone should wait for the27794			// player to reconnect27795			CvPreGame::setSlotStatus(GetID(), SS_COMPUTER);27796			CvPreGame::VerifyHandicap(GetID());	//Changing the handicap because we're switching to AI2779727798			// Load leaderhead for this new AI player27799			gDLL->NotifySpecificAILeaderInGame(GetID());27800			27801			if(!GC.getGame().isOption(GAMEOPTION_DYNAMIC_TURNS) && GC.getGame().isOption(GAMEOPTION_SIMULTANEOUS_TURNS))27802			{//When in fully simultaneous turn mode, having a player disconnect might trigger the automove phase for all human players.27803				checkRunAutoMovesForEveryone();27804			}27805		}27806	}27807}

Calls

Called by