Improved Reconnection Reload

Signed-off-by: GreYFoXGTi <GreYFoXGTi@GMaiL.CoM>
This commit is contained in:
GreYFoXGTi 2010-09-17 12:58:54 +03:00
parent e061d84f20
commit b7d5a3f7d2
2 changed files with 40 additions and 38 deletions

View file

@ -27,7 +27,10 @@ void CGameContext::Construct(int Resetting)
m_pServer = 0; m_pServer = 0;
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
{
m_apPlayers[i] = 0; m_apPlayers[i] = 0;
mem_zero(m_pReconnectInfo[i].Ip,sizeof(m_pReconnectInfo[i].Ip));
}
m_pController = 0; m_pController = 0;
m_VoteCloseTime = 0; m_VoteCloseTime = 0;
@ -2420,36 +2423,48 @@ IGameServer *CreateGameServer() { return new CGameContext; }
bool CGameContext::ClientLeave(int ClientId) bool CGameContext::ClientLeave(int ClientId)
{ {
Server()->GetClientIP(ClientId,m_pReconnectInfo[ClientId].Ip,sizeof(m_pReconnectInfo[ClientId].Ip));
CCharacter *pChr = GetPlayerChar(ClientId); CCharacter *pChr = GetPlayerChar(ClientId);
for(int i =0;i<MAX_CLIENTS;i++)
{
dbg_msg("","%d %d %s ",i,m_pReconnectInfo[i].Ip[0],m_pReconnectInfo[i].Ip);
if (m_pReconnectInfo[i].Ip[0] == 0)
{
Server()->GetClientIP(i,m_pReconnectInfo[i].Ip,sizeof(m_pReconnectInfo[i].Ip));
if(pChr) if(pChr)
{ {
m_pReconnectInfo[ClientId].m_PlayerInfo.m_Core = pChr->m_Core; m_pReconnectInfo[i].m_PlayerInfo.m_Core = pChr->m_Core;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_StartTime = pChr->m_StartTime; m_pReconnectInfo[i].m_PlayerInfo.m_StartTime = pChr->m_StartTime;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_RaceState = pChr->m_RaceState; m_pReconnectInfo[i].m_PlayerInfo.m_RaceState = pChr->m_RaceState;
for(int i = 0; i < WEAPON_NINJA; ++i) for(int j = 0; j < WEAPON_NINJA; ++j)
{ {
m_pReconnectInfo[ClientId].m_PlayerInfo.m_aHasWeapon[i] = pChr->m_aWeapons[i].m_Got; m_pReconnectInfo[i].m_PlayerInfo.m_aHasWeapon[j] = pChr->m_aWeapons[j].m_Got;
} }
m_pReconnectInfo[ClientId].m_PlayerInfo.m_FreezeTime=pChr->m_FreezeTime; m_pReconnectInfo[i].m_PlayerInfo.m_FreezeTime=pChr->m_FreezeTime;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_Doored = pChr->m_Doored; m_pReconnectInfo[i].m_PlayerInfo.m_Doored = pChr->m_Doored;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_OldPos = pChr->m_OldPos; m_pReconnectInfo[i].m_PlayerInfo.m_OldPos = pChr->m_OldPos;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_OlderPos = pChr->m_OlderPos; m_pReconnectInfo[i].m_PlayerInfo.m_OlderPos = pChr->m_OlderPos;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_LastAction = pChr->m_LastAction; m_pReconnectInfo[i].m_PlayerInfo.m_LastAction = pChr->m_LastAction;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_Jumped = pChr->m_Jumped; m_pReconnectInfo[i].m_PlayerInfo.m_Jumped = pChr->m_Jumped;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_Health = pChr->m_Health; m_pReconnectInfo[i].m_PlayerInfo.m_Health = pChr->m_Health;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_Armor = pChr->m_Armor; m_pReconnectInfo[i].m_PlayerInfo.m_Armor = pChr->m_Armor;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_PlayerState = pChr->m_PlayerState; m_pReconnectInfo[i].m_PlayerInfo.m_PlayerState = pChr->m_PlayerState;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_LastMove = pChr->m_LastMove; m_pReconnectInfo[i].m_PlayerInfo.m_LastMove = pChr->m_LastMove;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_PrevPos = pChr->m_PrevPos; m_pReconnectInfo[i].m_PlayerInfo.m_PrevPos = pChr->m_PrevPos;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_ActiveWeapon = pChr->m_ActiveWeapon; m_pReconnectInfo[i].m_PlayerInfo.m_ActiveWeapon = pChr->m_ActiveWeapon;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_LastWeapon = pChr->m_LastWeapon; m_pReconnectInfo[i].m_PlayerInfo.m_LastWeapon = pChr->m_LastWeapon;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_HammerType = pChr->m_HammerType; m_pReconnectInfo[i].m_PlayerInfo.m_HammerType = pChr->m_HammerType;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_Super = pChr->m_Super; m_pReconnectInfo[i].m_PlayerInfo.m_Super = pChr->m_Super;
m_pReconnectInfo[ClientId].m_PlayerInfo.m_PauseTime = Server()->Tick(); m_pReconnectInfo[i].m_PlayerInfo.m_PauseTime = Server()->Tick();
} m_pReconnectInfo[i].m_DisconnectTick = Server()->Tick();
m_pReconnectInfo[ClientId].m_DisconnectTick = Server()->Tick();
return true; return true;
}
else
{
mem_zero(m_pReconnectInfo[i].Ip,sizeof(m_pReconnectInfo[i].Ip));
return false;
}
}
}
} }
bool CGameContext::ClientEnter(int ClientId) bool CGameContext::ClientEnter(int ClientId)
@ -2496,15 +2511,3 @@ bool CGameContext::ClientEnter(int ClientId)
mem_zero(m_pReconnectInfo[i].Ip,sizeof(m_pReconnectInfo[i].Ip)); mem_zero(m_pReconnectInfo[i].Ip,sizeof(m_pReconnectInfo[i].Ip));
return false; return false;
} }
bool CGameContext::SearchInfo(int ClientId)
{
char Temp[64];
Server()->GetClientIP(ClientId,Temp,sizeof(Temp));
if (!str_comp(Temp,m_pReconnectInfo[ClientId].Ip))
{
return true;
}
return false;
}

View file

@ -212,7 +212,6 @@ public:
int m_ClientId; int m_ClientId;
int m_DisconnectTick; int m_DisconnectTick;
}m_pReconnectInfo[MAX_CLIENTS]; }m_pReconnectInfo[MAX_CLIENTS];
bool SearchInfo(int ClientId);
enum enum
{ {
CHAT_ALL=-2, CHAT_ALL=-2,