mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
git add src/*git add src/*! Fix character collision bug with additional protocol message, begin to finish ShowOthers
This commit is contained in:
parent
7ed685ee11
commit
edbef086c1
|
@ -600,6 +600,14 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
||||||
CNetMsg_Sv_PlayerTime *pMsg = (CNetMsg_Sv_PlayerTime *)pRawMsg;
|
CNetMsg_Sv_PlayerTime *pMsg = (CNetMsg_Sv_PlayerTime *)pRawMsg;
|
||||||
m_aClients[pMsg->m_Cid].m_Score = (float)pMsg->m_Time/100;
|
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)
|
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);
|
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] = &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);
|
g_GameClient.m_aClients[i].m_Predicted.Read(&m_Snap.m_aCharacters[i].m_Cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1290,6 +1290,8 @@ void CCharacter::Snap(int SnappingClient)
|
||||||
if(NetworkClipped(SnappingClient))
|
if(NetworkClipped(SnappingClient))
|
||||||
return;
|
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)));
|
CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character)));
|
||||||
|
|
||||||
// write down the m_Core
|
// write down the m_Core
|
||||||
|
|
|
@ -22,8 +22,8 @@ CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEner
|
||||||
bool CLaser::HitCharacter(vec2 From, vec2 To)
|
bool CLaser::HitCharacter(vec2 From, vec2 To)
|
||||||
{
|
{
|
||||||
vec2 At;
|
vec2 At;
|
||||||
CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
|
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);
|
CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, m_Bounces != 0 ? 0: OwnerChar);
|
||||||
if(!Hit)
|
if(!Hit)
|
||||||
return false;
|
return false;
|
||||||
if(OwnerChar != 0 && OwnerChar->Team() != Hit->Team()) return false;
|
if(OwnerChar != 0 && OwnerChar->Team() != Hit->Team()) return false;
|
||||||
|
|
|
@ -34,7 +34,7 @@ bool CPlasma::HitCharacter()
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(Hit->Team() != m_ResponsibleTeam) 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();
|
Hit->UnFreeze();
|
||||||
else if (m_Freeze)
|
else if (m_Freeze)
|
||||||
Hit->Freeze(Server()->TickSpeed()*3);
|
Hit->Freeze(Server()->TickSpeed()*3);
|
||||||
|
@ -81,7 +81,8 @@ void CPlasma::Snap(int SnappingClient)
|
||||||
{
|
{
|
||||||
if(NetworkClipped(SnappingClient))
|
if(NetworkClipped(SnappingClient))
|
||||||
return;
|
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)));
|
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_X = (int)m_Pos.x;
|
||||||
pObj->m_Y = (int)m_Pos.y;
|
pObj->m_Y = (int)m_Pos.y;
|
||||||
|
|
|
@ -63,10 +63,11 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
||||||
if(m_TeamState[Team] >= CLOSED) {
|
if(m_TeamState[Team] >= CLOSED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(Character(id)->m_RaceState != RACE_NONE) return false;
|
||||||
if(m_Core.Team(id) != 0 && m_TeamState[m_Core.Team(id)] != EMPTY) {
|
if(m_Core.Team(id) != 0 && m_TeamState[m_Core.Team(id)] != EMPTY) {
|
||||||
bool NoOneInOldTeam = true;
|
bool NoOneInOldTeam = true;
|
||||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
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
|
NoOneInOldTeam = false;//all good exists someone in old team
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,16 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
||||||
if(m_TeamState[Team] == EMPTY) {
|
if(m_TeamState[Team] == EMPTY) {
|
||||||
ChangeTeamState(Team, OPEN);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue