mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Fixes for super player. Still dont work collision
This commit is contained in:
parent
a75ab04d21
commit
d195d5c7bc
|
@ -215,11 +215,10 @@ void CCharacterCore::Tick(bool UseInput)
|
|||
float Dist = 0.0f;
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(i != m_Id && !m_pTeams->SameTeam(i, m_Id) && m_pTeams->Team(m_Id) != TEAM_SUPER) continue;
|
||||
CCharacterCore *p = m_pWorld->m_apCharacters[i];
|
||||
|
||||
|
||||
if(!p || p == this)
|
||||
if(!p || p == this || !m_pTeams->SameTeam(i, m_Id))
|
||||
continue;
|
||||
//char aBuf[512];
|
||||
//str_format(aBuf, sizeof(aBuf), "ThisId = %d Id = %d TheSameTeam? = %d", ThisId, i, m_pTeams->SameTeam(i, ThisId));
|
||||
|
@ -318,13 +317,12 @@ void CCharacterCore::Tick(bool UseInput)
|
|||
{
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(i != m_Id && !m_pTeams->SameTeam(i, m_Id) && m_pTeams->Team(m_Id) != TEAM_SUPER) continue;
|
||||
CCharacterCore *p = m_pWorld->m_apCharacters[i];
|
||||
if(!p)
|
||||
continue;
|
||||
|
||||
//player *p = (player*)ent;
|
||||
if(p == this) { // || !(p->flags&FLAG_ALIVE)
|
||||
if(p == this || (m_Id != -1 && !m_pTeams->SameTeam(m_Id, i))) { // || !(p->flags&FLAG_ALIVE)
|
||||
continue; // make sure that we don't nudge our self
|
||||
}
|
||||
// handle player <-> player collision
|
||||
|
@ -421,4 +419,3 @@ void CCharacterCore::Quantize()
|
|||
Write(&Core);
|
||||
Read(&Core);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
|
|||
m_Core.m_Pos = m_Pos;
|
||||
m_Core.m_Id = GetPlayer()->GetCID();
|
||||
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = &m_Core;
|
||||
|
||||
|
||||
m_ReckoningTick = 0;
|
||||
mem_zero(&m_SendCore, sizeof(m_SendCore));
|
||||
mem_zero(&m_ReckoningCore, sizeof(m_ReckoningCore));
|
||||
|
|
|
@ -1011,6 +1011,8 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
else if(MsgId == NETMSGTYPE_CL_ISRACE)
|
||||
{
|
||||
p->m_IsUsingRaceClient = true;
|
||||
p->m_ShowOthers = true;
|
||||
((CGameControllerDDRace*)m_pController)->m_Teams.SendAllInfo(p->GetCID());
|
||||
// send time of all players
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
|
@ -1036,9 +1038,6 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
|||
p->m_Last_ShowOthers = Server()->Tick();
|
||||
CNetMsg_Cl_RaceShowOthers *pMsg = (CNetMsg_Cl_RaceShowOthers *)pRawMsg;
|
||||
p->m_ShowOthers = (bool)pMsg->m_Active;
|
||||
if(p->m_ShowOthers) {
|
||||
((CGameControllerDDRace*)m_pController)->m_Teams.SendAllInfo(p->GetCID());
|
||||
}
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_CL_CALLVOTE)
|
||||
{
|
||||
|
@ -1672,7 +1671,7 @@ void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData, int cid
|
|||
{
|
||||
chr->m_Super = true;
|
||||
chr->UnFreeze();
|
||||
chr->Teams()->m_Core.Team(cid1, TEAM_SUPER);
|
||||
chr->Teams()->SetCharacterTeam(cid1, TEAM_SUPER);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
|
@ -1705,7 +1704,7 @@ void CGameContext::ConSuperMe(IConsole::IResult *pResult, void *pUserData, int c
|
|||
{
|
||||
chr->m_Super = true;
|
||||
chr->UnFreeze();
|
||||
chr->Teams()->m_Core.Team(cid, TEAM_SUPER);
|
||||
chr->Teams()->SetCharacterTeam(cid, TEAM_SUPER);
|
||||
if(!g_Config.m_SvCheatTime)
|
||||
chr->m_RaceState = RACE_CHEAT;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ void CGameTeams::OnCharacterStart(int id) {
|
|||
ChangeTeamState(m_Core.Team(id), STARTED);
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
if(m_Core.SameTeam(i, id)) {
|
||||
if(m_Core.Team(id) == m_Core.Team(i)) {
|
||||
CCharacter* Char = Character(i);
|
||||
|
||||
Char->m_RaceState = RACE_STARTED;
|
||||
|
@ -40,7 +40,7 @@ void CGameTeams::OnCharacterFinish(int id) {
|
|||
if(TeamFinished(m_Core.Team(id))) {
|
||||
ChangeTeamState(m_Core.Team(id), FINISHED);//TODO: Make it better
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
if(m_Core.SameTeam(i, id)) {
|
||||
if(m_Core.Team(id) == m_Core.Team(i)) {
|
||||
CCharacter * Char = Character(i);
|
||||
if(Char != 0) {
|
||||
Char->OnFinish();
|
||||
|
@ -56,17 +56,23 @@ void CGameTeams::OnCharacterFinish(int id) {
|
|||
}
|
||||
|
||||
bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
||||
//TODO: Send error message
|
||||
//Check on wrong parameters. +1 for TEAM_SUPER
|
||||
if(id < 0 || id >= MAX_CLIENTS || Team < 0 || Team >= MAX_CLIENTS + 1) {
|
||||
return false;
|
||||
}
|
||||
//You can join to TEAM_SUPER at any time, but any other group you cannot if it started
|
||||
if(Team != TEAM_SUPER && m_TeamState[Team] >= CLOSED) {
|
||||
return false;
|
||||
}
|
||||
if(m_Core.Team(id) == TEAM_SUPER) {
|
||||
//No need to switch team if you there
|
||||
if(m_Core.Team(id) == Team) {
|
||||
return false;
|
||||
}
|
||||
//You cannot be in TEAM_SUPER if you not super
|
||||
if(Team == TEAM_SUPER && !Character(id)->m_Super) return false;
|
||||
//if you begin race
|
||||
if(Character(id)->m_RaceState != RACE_NONE) {
|
||||
//you will be killed if you try to join FLOCK
|
||||
if(Team == TEAM_FLOCK && m_Core.Team(id) != TEAM_FLOCK) {
|
||||
Character(id)->GetPlayer()->KillCharacter(WEAPON_GAME);
|
||||
} else {
|
||||
|
@ -76,7 +82,7 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
|||
if(m_Core.Team(id) != TEAM_FLOCK && m_Core.Team(id) != TEAM_SUPER && m_TeamState[m_Core.Team(id)] != EMPTY) {
|
||||
bool NoOneInOldTeam = true;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
if(i != id && m_Core.SameTeam(i, id)) {
|
||||
if(i != id && m_Core.Team(id) == m_Core.Team(i)) {
|
||||
NoOneInOldTeam = false;//all good exists someone in old team
|
||||
break;
|
||||
}
|
||||
|
@ -89,6 +95,9 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
|||
if(Team != TEAM_SUPER && m_TeamState[Team] == EMPTY) {
|
||||
ChangeTeamState(Team, OPEN);
|
||||
}
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "Id = %d Team = %d", id, Team);
|
||||
dbg_msg("Teams", aBuf);
|
||||
//GameServer()->CreatePlayerSpawn(Character(id)->m_Core.m_Pos, TeamMask());
|
||||
if(Character(id)->GetPlayer()->m_IsUsingRaceClient)
|
||||
{
|
||||
|
@ -96,9 +105,7 @@ bool CGameTeams::SetCharacterTeam(int id, int Team) {
|
|||
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);
|
||||
//dbg_msg("Teams", "Sended all");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -119,11 +126,14 @@ bool CGameTeams::TeamFinished(int Team) {
|
|||
}
|
||||
|
||||
int CGameTeams::TeamMask(int Team) {
|
||||
if(Team == TEAM_SUPER) return -1;
|
||||
int Mask = 0;
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i) {
|
||||
if(m_Core.Team(i) == Team || (Character(i)
|
||||
if(m_Core.Team(i) == Team
|
||||
|| (Character(i)
|
||||
&& Character(i)->GetPlayer()
|
||||
&& Character(i)->GetPlayer()->m_ShowOthers)) {
|
||||
&& Character(i)->GetPlayer()->m_ShowOthers)
|
||||
) {
|
||||
Mask |= 1 << i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ CTeamsCore::CTeamsCore() {
|
|||
}
|
||||
|
||||
bool CTeamsCore::SameTeam(int Cid1, int Cid2) {
|
||||
if(m_Team[Cid1] == TEAM_SUPER || m_Team[Cid2] == TEAM_SUPER) return true;
|
||||
return m_Team[Cid1] == m_Team[Cid2];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue