git add src/*git add src/*! Fix character collision bug with additional protocol message, begin to finish ShowOthers

This commit is contained in:
btd 2010-09-12 00:45:56 +04:00
parent 7ed685ee11
commit edbef086c1
5 changed files with 28 additions and 5 deletions

View file

@ -600,6 +600,14 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
CNetMsg_Sv_PlayerTime *pMsg = (CNetMsg_Sv_PlayerTime *)pRawMsg;
m_aClients[pMsg->m_Cid].m_Score = (float)pMsg->m_Time/100;
}
else if(MsgId == NETMSGTYPE_SV_PLAYERTEAM)
{
CNetMsg_Sv_PlayerTeam *pMsg = (CNetMsg_Sv_PlayerTeam *)pRawMsg;
m_Teams.Team(pMsg->m_Cid, pMsg->m_Team);
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d",pMsg->m_Cid, pMsg->m_Team);
dbg_msg("Teams", aBuf);
}
}
void CGameClient::OnStateChange(int NewState, int OldState)
@ -946,6 +954,7 @@ void CGameClient::OnPredict()
g_GameClient.m_aClients[i].m_Predicted.Init(&World, Collision(), &m_Teams);
World.m_apCharacters[i] = &g_GameClient.m_aClients[i].m_Predicted;
World.m_apCharacters[i]->m_Id = m_Snap.m_LocalCid;
g_GameClient.m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur);
}

View file

@ -1290,6 +1290,8 @@ void CCharacter::Snap(int SnappingClient)
if(NetworkClipped(SnappingClient))
return;
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
if(!SnapChar || (!SnapChar->GetPlayer()->m_ShowOthers && SnapChar->Team() != Team())) return;
CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character)));
// write down the m_Core

View file

@ -22,8 +22,8 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner
bool CLaser::HitCharacter(vec2 From, vec2 To)
{
vec2 At;
CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, m_Bounces > 0 ? 0 : OwnerChar);
CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);//TODO: Find all and get closest non in Team
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, m_Bounces != 0 ? 0: OwnerChar);
if(!Hit)
return false;
if(OwnerChar != 0 && OwnerChar->Team() != Hit->Team()) return false;

View file

@ -34,7 +34,7 @@ bool CPlasma::HitCharacter()
return false;
if(Hit->Team() != m_ResponsibleTeam) return false;
if(m_Freeze== -1)
if(m_Freeze == -1) //TODO: bool m_Freeze; need to fix this is unsafe
Hit->UnFreeze();
else if (m_Freeze)
Hit->Freeze(Server()->TickSpeed()*3);
@ -81,7 +81,8 @@ void CPlasma::Snap(int SnappingClient)
{
if(NetworkClipped(SnappingClient))
return;
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
if(!SnapChar || (!SnapChar->GetPlayer()->m_ShowOthers && SnapChar->Team() != m_ResponsibleTeam)) return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
pObj->m_X = (int)m_Pos.x;
pObj->m_Y = (int)m_Pos.y;

View file

@ -63,10 +63,11 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
if(m_TeamState[Team] >= CLOSED) {
return false;
}
if(Character(id)->m_RaceState != RACE_NONE) return false;
if(m_Core.Team(id) != 0 && m_TeamState[m_Core.Team(id)] != EMPTY) {
bool NoOneInOldTeam = true;
for(int i = 0; i < MAX_CLIENTS; ++i) {
if(m_Core.SameTeam(i, id)) {
if(i != id && m_Core.SameTeam(i, id)) {
NoOneInOldTeam = false;//all good exists someone in old team
break;
}
@ -79,6 +80,16 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
if(m_TeamState[Team] == EMPTY) {
ChangeTeamState(Team, OPEN);
}
if(Character(id)->GetPlayer()->m_IsUsingRaceClient)
{
CNetMsg_Sv_PlayerTeam Msg;
Msg.m_Team = Team;
Msg.m_Cid = id;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d", id, Team);
dbg_msg("Teams", aBuf);
}
return true;
}