2025-07-18 04:40 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001751Spring engineGeneralpublic2009-12-11 01:41
ReporterSirMaverick 
Assigned ToAuswaschbar 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
Product Version0.80.5+git 
Target VersionFixed in Version 
Summary0001751: Patch: add PlayerRemoved callin
DescriptionAdds PlayerRemoved callin in case a player left the game (NETMSG_PLAYERLEFT).

http://github.com/1231e7b84a5de93a/spring/commits/playerremoved
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • txt file icon diff.txt (4,703 bytes) 2009-12-10 18:47 -
    diff --git a/rts/Game/Game.cpp b/rts/Game/Game.cpp
    index 2d30beb..8d5f531 100644
    --- a/rts/Game/Game.cpp
    +++ b/rts/Game/Game.cpp
    @@ -3580,6 +3580,7 @@ void CGame::ClientReadNet()
     					logOutput.Print("Got invalid player num (%i) in NETMSG_PLAYERLEFT", player);
     				} else {
     					playerHandler->PlayerLeft(player, inbuf[2]);
    +					eventHandler.PlayerRemoved(player, (int) inbuf[2]);
     				}
     				AddTraffic(player, packetCode, dataLength);
     				break;
    diff --git a/rts/Lua/LuaHandle.cpp b/rts/Lua/LuaHandle.cpp
    index f7eb2ae..2a20241 100644
    --- a/rts/Lua/LuaHandle.cpp
    +++ b/rts/Lua/LuaHandle.cpp
    @@ -426,6 +426,29 @@ void CLuaHandle::PlayerChanged(int playerID)
     }
     
     
    +void CLuaHandle::PlayerRemoved(int playerID, int reason)
    +{
    +	LUA_CALL_IN_CHECK(L);
    +	lua_checkstack(L, 5);
    +
    +	int errfunc = SetupTraceback();
    +
    +	static const LuaHashString cmdStr("PlayerRemoved");
    +	if (!cmdStr.GetGlobalFunc(L)) {
    +		// remove error handler
    +		if (errfunc) lua_pop(L, 1);
    +		return; // the call is not defined	}
    +	}
    +
    +	lua_pushnumber(L, playerID);
    +	lua_pushnumber(L, reason);
    +
    +	// call the routine
    +	RunCallInTraceback(cmdStr, 2, 0, errfunc);
    +	return;
    +}
    +
    +
     /******************************************************************************/
     
     inline void CLuaHandle::UnitCallIn(const LuaHashString& hs, const CUnit* unit)
    diff --git a/rts/Lua/LuaHandle.h b/rts/Lua/LuaHandle.h
    index aef8e63..7dc19cc 100644
    --- a/rts/Lua/LuaHandle.h
    +++ b/rts/Lua/LuaHandle.h
    @@ -100,6 +100,7 @@ class CLuaHandle : public CEventClient
     		void TeamDied(int teamID);
     		void TeamChanged(int teamID);
     		void PlayerChanged(int playerID);
    +		void PlayerRemoved(int playerID, int reason);
     
     		void UnitCreated(const CUnit* unit, const CUnit* builder);
     		void UnitFinished(const CUnit* unit);
    diff --git a/rts/System/EventClient.cpp b/rts/System/EventClient.cpp
    index 75f03f4..7b31e53 100644
    --- a/rts/System/EventClient.cpp
    +++ b/rts/System/EventClient.cpp
    @@ -34,7 +34,7 @@ void CEventClient::GameOver() { return; }
     void CEventClient::TeamDied(int teamID) { return; }
     void CEventClient::TeamChanged(int teamID) { return; }
     void CEventClient::PlayerChanged(int playerID) { return; }
    -void CEventClient::PlayerRemoved(int playerID) { return; }
    +void CEventClient::PlayerRemoved(int playerID, int reason) { return; }
     
     void CEventClient::UnitCreated(const CUnit* unit, const CUnit* builder) { return; }
     void CEventClient::UnitFinished(const CUnit* unit) { return; }
    diff --git a/rts/System/EventClient.h b/rts/System/EventClient.h
    index 0f0568f..0815014 100644
    --- a/rts/System/EventClient.h
    +++ b/rts/System/EventClient.h
    @@ -64,7 +64,7 @@ class CEventClient
     		virtual void TeamDied(int teamID);
     		virtual void TeamChanged(int teamID);
     		virtual void PlayerChanged(int playerID);
    -		virtual void PlayerRemoved(int playerID);
    +		virtual void PlayerRemoved(int playerID, int reason);
     
     		virtual void UnitCreated(const CUnit* unit, const CUnit* builder);
     		virtual void UnitFinished(const CUnit* unit);
    diff --git a/rts/System/EventHandler.cpp b/rts/System/EventHandler.cpp
    index 99b737f..e0d43e6 100644
    --- a/rts/System/EventHandler.cpp
    +++ b/rts/System/EventHandler.cpp
    @@ -40,6 +40,7 @@ CEventHandler::CEventHandler()
     	SETUP_EVENT(TeamDied,      MANAGED_BIT);
     	SETUP_EVENT(TeamChanged,   MANAGED_BIT);
     	SETUP_EVENT(PlayerChanged, MANAGED_BIT);
    +	SETUP_EVENT(PlayerRemoved, MANAGED_BIT);
     
     	SETUP_EVENT(UnitCreated,     MANAGED_BIT);
     	SETUP_EVENT(UnitFinished,    MANAGED_BIT);
    @@ -343,6 +344,16 @@ void CEventHandler::PlayerChanged(int playerID)
     }
     
     
    +void CEventHandler::PlayerRemoved(int playerID, int reason)
    +{
    +	const int count = listPlayerRemoved.size();
    +	for (int i = 0; i < count; i++) {
    +		CEventClient* ec = listPlayerRemoved[i];
    +		ec->PlayerRemoved(playerID, reason);
    +	}
    +}
    +
    +
     /******************************************************************************/
     /******************************************************************************/
     
    diff --git a/rts/System/EventHandler.h b/rts/System/EventHandler.h
    index 6bc6f99..9d864b3 100644
    --- a/rts/System/EventHandler.h
    +++ b/rts/System/EventHandler.h
    @@ -49,7 +49,7 @@ class CEventHandler
     		void TeamDied(int teamID);
     		void TeamChanged(int teamID);
     		void PlayerChanged(int playerID);
    -		void PlayerRemoved(int playerID);
    +		void PlayerRemoved(int playerID, int reason);
     
     		void UnitCreated(const CUnit* unit, const CUnit* builder);
     		void UnitFinished(const CUnit* unit);
    @@ -196,6 +196,7 @@ class CEventHandler
     		EventClientList listTeamDied;
     		EventClientList listTeamChanged;
     		EventClientList listPlayerChanged;
    +		EventClientList listPlayerRemoved;
     
     		EventClientList listUnitCreated;
     		EventClientList listUnitFinished;
    
    txt file icon diff.txt (4,703 bytes) 2009-12-10 18:47 +

-Relationships
+Relationships

-Notes

~0004409

Auswaschbar (reporter)

Imho it would be usefull to give a reason for the removal, e.g. dropped, left or kicked.

~0004410

SirMaverick (reporter)

Reason added.

~0004423

Auswaschbar (reporter)

Has anyone else problems fetching from his repo?

~0004424

SirMaverick (reporter)

Yes, no idea what is broken. Attached diff.
+Notes

-Issue History
Date Modified Username Field Change
2009-12-05 01:28 SirMaverick New Issue
2009-12-06 18:52 Auswaschbar Note Added: 0004409
2009-12-06 23:21 SirMaverick Note Added: 0004410
2009-12-10 16:50 Auswaschbar Note Added: 0004423
2009-12-10 18:47 SirMaverick File Added: diff.txt
2009-12-10 18:47 SirMaverick Note Added: 0004424
2009-12-11 01:41 Auswaschbar Status new => resolved
2009-12-11 01:41 Auswaschbar Resolution open => fixed
2009-12-11 01:41 Auswaschbar Assigned To => Auswaschbar
+Issue History