Cleanup and Added All Left Masks

This commit is contained in:
GreYFoXGTi 2011-01-29 02:59:50 +02:00
parent e16bd4d000
commit 832bad08e6
19 changed files with 1298 additions and 1345 deletions

View file

@ -48,8 +48,8 @@ void CGameContext::MoveCharacter(int ClientId, int Victim, int X, int Y, bool Ra
if(!pChr)
return;
pChr->m_Core.m_Pos.x += ((Raw) ? 1 : 32) * X;
pChr->m_Core.m_Pos.y += ((Raw) ? 1 : 32) * Y;
pChr->Core()->m_Pos.x += ((Raw) ? 1 : 32) * X;
pChr->Core()->m_Pos.y += ((Raw) ? 1 : 32) * Y;
if(!g_Config.m_SvCheatTime)
pChr->m_DDRaceState = DDRACE_CHEAT;
@ -304,25 +304,25 @@ void CGameContext::ModifyWeapons(int ClientId, int Victim, int Weapon, bool Remo
if(Weapon == -1)
{
if(Remove && (pChr->m_ActiveWeapon == WEAPON_SHOTGUN || pChr->m_ActiveWeapon == WEAPON_GRENADE || pChr->m_ActiveWeapon == WEAPON_RIFLE))
pChr->m_ActiveWeapon = WEAPON_GUN;
if(Remove && (pChr->GetActiveWeapon() == WEAPON_SHOTGUN || pChr->GetActiveWeapon() == WEAPON_GRENADE || pChr->GetActiveWeapon() == WEAPON_RIFLE))
pChr->SetActiveWeapon(WEAPON_GUN);
if(Remove)
{
pChr->m_aWeapons[WEAPON_SHOTGUN].m_Got = false;
pChr->m_aWeapons[WEAPON_GRENADE].m_Got = false;
pChr->m_aWeapons[WEAPON_RIFLE].m_Got = false;
pChr->SetWeaponGot(WEAPON_SHOTGUN, false);
pChr->SetWeaponGot(WEAPON_GRENADE, false);
pChr->SetWeaponGot(WEAPON_RIFLE, false);
}
else
pChr->GiveAllWeapons();
}
else if(Weapon != WEAPON_NINJA)
{
if(Remove && pChr->m_ActiveWeapon == Weapon)
pChr->m_ActiveWeapon = WEAPON_GUN;
if(Remove && pChr->GetActiveWeapon() == Weapon)
pChr->SetActiveWeapon(WEAPON_GUN);
if(Remove)
pChr->m_aWeapons[Weapon].m_Got = false;
pChr->SetWeaponGot(Weapon, false);
else
pChr->GiveWeapon(Weapon, -1);
}
@ -352,7 +352,7 @@ void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData, int
CCharacter* pChr = pSelf->GetPlayerChar(Victim);
if(pChr)
{
pChr->m_Core.m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
pChr->Core()->m_Pos = pSelf->m_apPlayers[TeleTo]->m_ViewPos;
if(!g_Config.m_SvCheatTime)
pChr->m_DDRaceState = DDRACE_CHEAT;
}
@ -455,7 +455,7 @@ void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData, int Cl
if(pSelf->m_apPlayers[Victim])
{
pChr->Freeze(Seconds);
pChr->m_pPlayer->m_RconFreeze = Seconds != -2;
pChr->GetPlayer()->m_RconFreeze = Seconds != -2;
CServer* pServ = (CServer*)pSelf->Server();
if(Seconds >= 0)
str_format(aBuf, sizeof(aBuf), "'%s' ClientId=%d has been Frozen for %d.", pServ->ClientName(ClientId), Victim, Seconds);
@ -492,7 +492,7 @@ void CGameContext::ConUnFreeze(IConsole::IResult *pResult, void *pUserData, int
Warning = false;
}
pChr->m_FreezeTime = 2;
pChr->m_pPlayer->m_RconFreeze = false;
pChr->GetPlayer()->m_RconFreeze = false;
CServer* pServ = (CServer*)pSelf->Server();
str_format(aBuf, sizeof(aBuf), "'%s' ClientId=%d has been defrosted.", pServ->ClientName(ClientId), Victim);
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
@ -752,7 +752,7 @@ void CGameContext::ConTogglePause(IConsole::IResult *pResult, void *pUserData, i
if(g_Config.m_SvPauseable)
{
CCharacter* pChr = pPlayer->GetCharacter();
if(!pPlayer->GetTeam() && pChr && (!pChr->m_aWeapons[WEAPON_NINJA].m_Got || pChr->m_FreezeTime) && pChr->IsGrounded() && pChr->m_Pos==pChr->m_PrevPos && !pChr->Team() && !pPlayer->m_InfoSaved)
if(!pPlayer->GetTeam() && pChr && (!pChr->GetWeaponGot(WEAPON_NINJA) || pChr->m_FreezeTime) && pChr->IsGrounded() && pChr->m_Pos==pChr->m_PrevPos && !pChr->Team() && !pPlayer->m_InfoSaved)
{
if(pPlayer->m_Last_Pause + pSelf->Server()->TickSpeed() * g_Config.m_SvPauseFrequency <= pSelf->Server()->Tick()) {
pPlayer->SaveCharacter();
@ -771,7 +771,7 @@ void CGameContext::ConTogglePause(IConsole::IResult *pResult, void *pUserData, i
//pPlayer->LoadCharacter();//TODO:Check if this system Works
}
else if(pChr)
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", (pChr->Team())?"You can't pause while you are in a team":(pChr->m_aWeapons[WEAPON_NINJA].m_Got)?"You can't use /pause while you are a ninja":(!pChr->IsGrounded())?"You can't use /pause while you are a in air":"You can't use /pause while you are moving");
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", (pChr->Team())?"You can't pause while you are in a team":pChr->GetWeaponGot(WEAPON_NINJA)?"You can't use /pause while you are a ninja":(!pChr->IsGrounded())?"You can't use /pause while you are a in air":"You can't use /pause while you are moving");
else
pSelf->Console()->PrintResponse(IConsole::OUTPUT_LEVEL_STANDARD, "info", "No pause data saved.");
}

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,7 @@
#include <game/server/entity.h>
#include <game/generated/server_data.h>
#include <game/generated/protocol.h>
#include <game/gamecore.h>
class CGameTeams;
@ -17,21 +18,10 @@ enum
WEAPON_WORLD = -1, // death tiles etc
};
enum
{
DDRACE_NONE = 0,
DDRACE_STARTED,
DDRACE_CHEAT, // no time and won't start again unless ordered by a mod or death
DDRACE_FINISHED
};
class CCharacter : public CEntity
{
MACRO_ALLOC_POOL_ID()
void HandleFly();
void HandleTiles(int Index);
float m_Time;
int m_LastBroadcast;
public:
//character's size
static const int ms_PhysSize = 28;
@ -45,10 +35,7 @@ public:
virtual void Snap(int SnappingClient);
bool IsGrounded();
//bool m_Paused;
CGameTeams* Teams();
void SetWeapon(int W);
void HandleWeaponSwitch();
void DoWeaponSwitch();
@ -72,20 +59,21 @@ public:
bool GiveWeapon(int Weapon, int Ammo);
void GiveNinja();
void ResetPos();
bool Freeze(int Time);
bool Freeze();
bool UnFreeze();
void GiveAllWeapons();
void SetEmote(int Emote, int Tick);
bool IsAlive() const { return m_Alive; }
class CPlayer *GetPlayer() { return m_pPlayer; }
// the player core for the physics
CCharacterCore m_Core;
private:
// player controlling this character
class CPlayer *m_pPlayer;
bool m_Alive;
// weapon info
CEntity *m_apHitObjects[10];
int m_NumObjectsHit;
struct WeaponStat
{
int m_AmmoRegenStart;
@ -94,53 +82,12 @@ public:
bool m_Got;
} m_aWeapons[NUM_WEAPONS];
int m_ActiveWeapon;
int m_LastWeapon;
// player controlling this character
class CPlayer *m_pPlayer;
int m_DDRaceState;
void OnFinish();
int Team();
bool CanCollide(int Cid);
bool SameTeam(int Cid);
struct
{
vec2 m_ActivationDir;
int m_ActivationTick;
int m_CurrentMoveTime;
} m_Ninja;
int m_HammerType;
bool m_Super;
int m_TeamBeforeSuper;
bool m_Fly;
//DDRace
int m_FreezeTime;
int m_FreezeTick;
bool m_DeepFreeze;
bool m_EndlessHook;
int m_Doored;
vec2 m_OldPos;
vec2 m_OlderPos;
bool m_Alive;
// weapon info
CEntity *m_apHitObjects[10];
int m_NumObjectsHit;
int m_QueuedWeapon;
int m_ReloadTimer;
int m_PainSoundTimer;
int m_AttackTick;
int m_DamageTaken;
@ -148,9 +95,6 @@ public:
int m_EmoteType;
int m_EmoteStop;
int m_DefEmote; //used to override the default emote through /emote
int m_DefEmoteReset; //tick when it gets reset
// last tick that the player took any action ie some input
int m_LastAction;
@ -170,26 +114,63 @@ public:
int m_Armor;
// ninja
struct
{
vec2 m_ActivationDir;
int m_ActivationTick;
int m_CurrentMoveTime;
} m_Ninja;
int m_PlayerState;// if the client is chatting, accessing a menu or so
// the player core for the physics
CCharacterCore m_Core;
bool m_IsWater;
bool m_DoSplash;
// info for dead reckoning
int m_ReckoningTick; // tick that we are performing dead reckoning From
CCharacterCore m_SendCore; // core that we should send
CCharacterCore m_ReckoningCore; // the dead reckoning core
//DDRace
void HandleFly();
void HandleTiles(int Index);
float m_Time;
int m_LastBroadcast;
void DDRaceInit();
void HandleSkippableTiles(int Index);
void DDRaceTick();
void HandleBroadcast();
public:
CGameTeams* Teams();
bool Freeze(int Time);
bool Freeze();
bool UnFreeze();
void GiveAllWeapons();
int m_DDRaceState;
void OnFinish();
int Team();
bool CanCollide(int Cid);
bool SameTeam(int Cid);
int m_HammerType;
bool m_Super;
int m_TeamBeforeSuper;
bool m_Fly;
int m_FreezeTime;
int m_FreezeTick;
bool m_DeepFreeze;
bool m_EndlessHook;
int m_PainSoundTimer;
int m_DefEmote;
int m_DefEmoteReset;
int m_LastMove;
// DDRace var
int m_StartTime;
int m_RefreshTime;
vec2 m_PrevPos;
// checkpoints
int m_CpTick;
int m_CpActive;
float m_CpCurrent[25];
int m_BroadCast;
bool m_BroadCast;
int m_TileIndex;
int m_TileFlags;
int m_TileFIndex;
@ -220,13 +201,39 @@ public:
int m_TileFFlagsB;
int m_TileSIndexB;
int m_TileSFlagsB;
vec2 m_Intersection;
bool m_EyeEmote;
// info for dead reckoning
int m_ReckoningTick; // tick that we are performing dead reckoning From
CCharacterCore m_SendCore; // core that we should send
CCharacterCore m_ReckoningCore; // the dead reckoning core
// Setters/Getters because i don't want to modify vanilla vars access modifiers
int GetLastWeapon() { return m_LastWeapon; };
void SetLastWeapon(int LastWeap) {m_LastWeapon = LastWeap; };
int GetActiveWeapon() { return m_ActiveWeapon; };
void SetActiveWeapon(int ActiveWeap) {m_ActiveWeapon = ActiveWeap; };
int GetPlayerState() { return m_PlayerState; };
void SetPlayerState(int PlayerState) {m_PlayerState = PlayerState; };
void SetLastAction(int LastAction) {m_LastAction = LastAction; };
int GetArmor() { return m_Armor; };
void SetArmor(int Armor) {m_Armor = Armor; };
CCharacterCore GetCore() { return m_Core; };
void SetCore(CCharacterCore Core) {m_Core = Core; };
CCharacterCore* Core() { return &m_Core; };
bool GetWeaponGot(int Type) { return m_aWeapons[Type].m_Got; };
void SetWeaponGot(int Type, bool Value) { m_aWeapons[Type].m_Got = Value; };
int GetWeaponAmmo(int Type) { return m_aWeapons[Type].m_Ammo; };
void SetWeaponAmmo(int Type, int Value) { m_aWeapons[Type].m_Ammo = Value; };
bool IsAlive() { return m_Alive; };
void SetEmoteType(int EmoteType) { m_EmoteType = EmoteType; };
void SetEmoteStop(int EmoteStop) { m_EmoteStop = EmoteStop; };
void SetNinjaActivationDir(vec2 ActivationDir) { m_Ninja.m_ActivationDir = ActivationDir; };
void SetNinjaActivationTick(int ActivationTick) { m_Ninja.m_ActivationTick = ActivationTick; };
void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Ninja.m_CurrentMoveTime = CurrentMoveTime; };
};
enum
{
DDRACE_NONE = 0,
DDRACE_STARTED,
DDRACE_CHEAT, // no time and won't start again unless ordered by a mod or death
DDRACE_FINISHED
};
#endif

View file

@ -70,7 +70,7 @@ void CDoor::Snap(int SnappingClient)
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if(Char == 0) return;
if(Char->m_Alive && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (!Tick)) return;
if(Char->IsAlive() && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (!Tick)) return;
if(Char->Team() == TEAM_SUPER)
{

View file

@ -26,7 +26,7 @@ CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool NW, in
void CDragger::Move()
{
if(m_Target && m_Target->m_Alive && (m_Target->m_Super || (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()])))
if(m_Target && m_Target->IsAlive() && (m_Target->m_Super || (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[m_Target->Team()])))
m_Target = 0;
if(m_Target)
return;
@ -72,7 +72,7 @@ void CDragger::Drag()
else
if (length(m_Pos-m_Target->m_Pos)>28)
{
vec2 Temp = m_Target->m_Core.m_Vel +(normalize(m_Pos-m_Target->m_Pos)*m_Strength);
vec2 Temp = m_Target->Core()->m_Vel +(normalize(m_Pos-m_Target->m_Pos)*m_Strength);
if(Temp.x > 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_270) || (m_Target->m_TileIndexL == TILE_STOP && m_Target->m_TileFlagsL == ROTATION_270) || (m_Target->m_TileIndexL == TILE_STOPS && (m_Target->m_TileFlagsL == ROTATION_90 || m_Target->m_TileFlagsL ==ROTATION_270)) || (m_Target->m_TileIndexL == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_270) || (m_Target->m_TileFIndexL == TILE_STOP && m_Target->m_TileFFlagsL == ROTATION_270) || (m_Target->m_TileFIndexL == TILE_STOPS && (m_Target->m_TileFFlagsL == ROTATION_90 || m_Target->m_TileFFlagsL == ROTATION_270)) || (m_Target->m_TileFIndexL == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_270) || (m_Target->m_TileSIndexL == TILE_STOP && m_Target->m_TileSFlagsL == ROTATION_270) || (m_Target->m_TileSIndexL == TILE_STOPS && (m_Target->m_TileSFlagsL == ROTATION_90 || m_Target->m_TileSFlagsL == ROTATION_270)) || (m_Target->m_TileSIndexL == TILE_STOPA)))
Temp.x = 0;
if(Temp.x < 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_90) || (m_Target->m_TileIndexR == TILE_STOP && m_Target->m_TileFlagsR == ROTATION_90) || (m_Target->m_TileIndexR == TILE_STOPS && (m_Target->m_TileFlagsR == ROTATION_90 || m_Target->m_TileFlagsR == ROTATION_270)) || (m_Target->m_TileIndexR == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_90) || (m_Target->m_TileFIndexR == TILE_STOP && m_Target->m_TileFFlagsR == ROTATION_90) || (m_Target->m_TileFIndexR == TILE_STOPS && (m_Target->m_TileFFlagsR == ROTATION_90 || m_Target->m_TileFFlagsR == ROTATION_270)) || (m_Target->m_TileFIndexR == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_90) || (m_Target->m_TileSIndexR == TILE_STOP && m_Target->m_TileSFlagsR == ROTATION_90) || (m_Target->m_TileSIndexR == TILE_STOPS && (m_Target->m_TileSFlagsR == ROTATION_90 || m_Target->m_TileSFlagsR == ROTATION_270)) || (m_Target->m_TileSIndexR == TILE_STOPA)))
@ -81,7 +81,7 @@ void CDragger::Drag()
Temp.y = 0;
if(Temp.y > 0 && ((m_Target->m_TileIndex == TILE_STOP && m_Target->m_TileFlags == ROTATION_0) || (m_Target->m_TileIndexT == TILE_STOP && m_Target->m_TileFlagsT == ROTATION_0) || (m_Target->m_TileIndexT == TILE_STOPS && (m_Target->m_TileFlagsT == ROTATION_0 || m_Target->m_TileFlagsT == ROTATION_180)) || (m_Target->m_TileIndexT == TILE_STOPA) || (m_Target->m_TileFIndex == TILE_STOP && m_Target->m_TileFFlags == ROTATION_0) || (m_Target->m_TileFIndexT == TILE_STOP && m_Target->m_TileFFlagsT == ROTATION_0) || (m_Target->m_TileFIndexT == TILE_STOPS && (m_Target->m_TileFFlagsT == ROTATION_0 || m_Target->m_TileFFlagsT == ROTATION_180)) || (m_Target->m_TileFIndexT == TILE_STOPA) || (m_Target->m_TileSIndex == TILE_STOP && m_Target->m_TileSFlags == ROTATION_0) || (m_Target->m_TileSIndexT == TILE_STOP && m_Target->m_TileSFlagsT == ROTATION_0) || (m_Target->m_TileSIndexT == TILE_STOPS && (m_Target->m_TileSFlagsT == ROTATION_0 || m_Target->m_TileSFlagsT == ROTATION_180)) || (m_Target->m_TileSIndexT == TILE_STOPA)))
Temp.y = 0;
m_Target->m_Core.m_Vel = Temp;
m_Target->Core()->m_Vel = Temp;
}
}
}
@ -124,8 +124,8 @@ void CDragger::Snap(int SnappingClient)
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if (Char && Char->m_Alive && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (!Tick))) return;
if(Char && Char->m_Alive && m_Target && m_Target->m_Alive && Char->Team() != m_Target->Team()) return;
if (Char && Char->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (!Tick))) return;
if(Char && Char->IsAlive() && m_Target && m_Target->IsAlive() && Char->Team() != m_Target->Team()) return;
CNetObj_Laser *obj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));

View file

@ -95,7 +95,7 @@ void CGun::Snap(int SnappingClient)
CCharacter * SnapChar = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if (SnapChar && SnapChar->m_Alive && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) return;
if (SnapChar && SnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) 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

@ -3,6 +3,7 @@
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include <engine/shared/config.h>
#include <game/server/teams.h>
#include "laser.h"
CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner, int Type)
@ -34,9 +35,9 @@ bool CLaser::HitCharacter(vec2 From, vec2 To)
{
vec2 Temp;
if(!g_Config.m_SvOldLaser)
Temp = Hit->m_Core.m_Vel + normalize(m_PrevPos - Hit->m_Core.m_Pos) * 10;
Temp = Hit->Core()->m_Vel + normalize(m_PrevPos - Hit->Core()->m_Pos) * 10;
else
Temp = Hit->m_Core.m_Vel + normalize(OwnerChar->m_Core.m_Pos-Hit->m_Core.m_Pos)*10;
Temp = Hit->Core()->m_Vel + normalize(OwnerChar->Core()->m_Pos - Hit->Core()->m_Pos) * 10;
if(Temp.x > 0 && ((Hit->m_TileIndex == TILE_STOP && Hit->m_TileFlags == ROTATION_270) || (Hit->m_TileIndexL == TILE_STOP && Hit->m_TileFlagsL == ROTATION_270) || (Hit->m_TileIndexL == TILE_STOPS && (Hit->m_TileFlagsL == ROTATION_90 || Hit->m_TileFlagsL ==ROTATION_270)) || (Hit->m_TileIndexL == TILE_STOPA) || (Hit->m_TileFIndex == TILE_STOP && Hit->m_TileFFlags == ROTATION_270) || (Hit->m_TileFIndexL == TILE_STOP && Hit->m_TileFFlagsL == ROTATION_270) || (Hit->m_TileFIndexL == TILE_STOPS && (Hit->m_TileFFlagsL == ROTATION_90 || Hit->m_TileFFlagsL == ROTATION_270)) || (Hit->m_TileFIndexL == TILE_STOPA) || (Hit->m_TileSIndex == TILE_STOP && Hit->m_TileSFlags == ROTATION_270) || (Hit->m_TileSIndexL == TILE_STOP && Hit->m_TileSFlagsL == ROTATION_270) || (Hit->m_TileSIndexL == TILE_STOPS && (Hit->m_TileSFlagsL == ROTATION_90 || Hit->m_TileSFlagsL == ROTATION_270)) || (Hit->m_TileSIndexL == TILE_STOPA)))
Temp.x = 0;
if(Temp.x < 0 && ((Hit->m_TileIndex == TILE_STOP && Hit->m_TileFlags == ROTATION_90) || (Hit->m_TileIndexR == TILE_STOP && Hit->m_TileFlagsR == ROTATION_90) || (Hit->m_TileIndexR == TILE_STOPS && (Hit->m_TileFlagsR == ROTATION_90 || Hit->m_TileFlagsR == ROTATION_270)) || (Hit->m_TileIndexR == TILE_STOPA) || (Hit->m_TileFIndex == TILE_STOP && Hit->m_TileFFlags == ROTATION_90) || (Hit->m_TileFIndexR == TILE_STOP && Hit->m_TileFFlagsR == ROTATION_90) || (Hit->m_TileFIndexR == TILE_STOPS && (Hit->m_TileFFlagsR == ROTATION_90 || Hit->m_TileFFlagsR == ROTATION_270)) || (Hit->m_TileFIndexR == TILE_STOPA) || (Hit->m_TileSIndex == TILE_STOP && Hit->m_TileSFlags == ROTATION_90) || (Hit->m_TileSIndexR == TILE_STOP && Hit->m_TileSFlagsR == ROTATION_90) || (Hit->m_TileSIndexR == TILE_STOPS && (Hit->m_TileSFlagsR == ROTATION_90 || Hit->m_TileSFlagsR == ROTATION_270)) || (Hit->m_TileSIndexR == TILE_STOPA)))
@ -45,7 +46,7 @@ bool CLaser::HitCharacter(vec2 From, vec2 To)
Temp.y = 0;
if(Temp.y > 0 && ((Hit->m_TileIndex == TILE_STOP && Hit->m_TileFlags == ROTATION_0) || (Hit->m_TileIndexT == TILE_STOP && Hit->m_TileFlagsT == ROTATION_0) || (Hit->m_TileIndexT == TILE_STOPS && (Hit->m_TileFlagsT == ROTATION_0 || Hit->m_TileFlagsT == ROTATION_180)) || (Hit->m_TileIndexT == TILE_STOPA) || (Hit->m_TileFIndex == TILE_STOP && Hit->m_TileFFlags == ROTATION_0) || (Hit->m_TileFIndexT == TILE_STOP && Hit->m_TileFFlagsT == ROTATION_0) || (Hit->m_TileFIndexT == TILE_STOPS && (Hit->m_TileFFlagsT == ROTATION_0 || Hit->m_TileFFlagsT == ROTATION_180)) || (Hit->m_TileFIndexT == TILE_STOPA) || (Hit->m_TileSIndex == TILE_STOP && Hit->m_TileSFlags == ROTATION_0) || (Hit->m_TileSIndexT == TILE_STOP && Hit->m_TileSFlagsT == ROTATION_0) || (Hit->m_TileSIndexT == TILE_STOPS && (Hit->m_TileSFlagsT == ROTATION_0 || Hit->m_TileSFlagsT == ROTATION_180)) || (Hit->m_TileSIndexT == TILE_STOPA)))
Temp.y = 0;
Hit->m_Core.m_Vel = Temp;
Hit->Core()->m_Vel = Temp;
}
else if (m_Type == 0)
{
@ -56,6 +57,7 @@ bool CLaser::HitCharacter(vec2 From, vec2 To)
void CLaser::DoBounce()
{
CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
m_EvalTick = Server()->Tick();
if(m_Energy < 0)
@ -100,7 +102,7 @@ void CLaser::DoBounce()
if(m_Bounces > GameServer()->Tuning()->m_LaserBounceNum)
m_Energy = -1;
GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE);
GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE, OwnerChar->Teams()->TeamMask(OwnerChar->Team()));
}
}
else
@ -136,7 +138,7 @@ void CLaser::Snap(int SnappingClient)
OwnerChar = GameServer()->GetPlayerChar(m_Owner);
if(!SnappingChar || !OwnerChar)
return;
if(SnappingChar->m_Alive && OwnerChar->m_Alive && SnappingChar->Team() != OwnerChar->Team())
if(SnappingChar->IsAlive() && OwnerChar->IsAlive() && SnappingChar->Team() != OwnerChar->Team())
return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
if(!pObj)

View file

@ -109,7 +109,7 @@ void CLight::Snap(int SnappingClient)
CCharacter * Char = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%6;
if(!Char) return;
if (!Char->m_Alive) return;
if (!Char->IsAlive()) return;
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Char->Team()] && (Tick)) return;

View file

@ -2,6 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include <game/server/teams.h>
#include "pickup.h"
CPickup::CPickup(CGameWorld *pGameWorld, int Type, int SubType, int Layer, int Number)
@ -72,37 +73,37 @@ void CPickup::Tick()
switch (m_Type)
{
case POWERUP_HEALTH:
if(pChr->Freeze()) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
if(pChr->Freeze()) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH, pChr->Teams()->TeamMask(pChr->Team()));
break;
case POWERUP_ARMOR:
if(pChr->Team() == TEAM_SUPER) continue;
for(int i=WEAPON_SHOTGUN;i<NUM_WEAPONS;i++)
for(int i = WEAPON_SHOTGUN; i < NUM_WEAPONS; i++)
{
if (pChr->m_aWeapons[i].m_Got)
if(pChr->GetWeaponGot(i))
{
if(!(pChr->m_FreezeTime && i == WEAPON_NINJA))
{
pChr->m_aWeapons[i].m_Got = false;
pChr->m_aWeapons[i].m_Ammo = 0;
pChr->SetWeaponGot(i, false);
pChr->SetWeaponAmmo(i, 0);
sound = true;
}
}
}
pChr->m_Ninja.m_ActivationDir=vec2(0,0);
pChr->m_Ninja.m_ActivationTick=-500;
pChr->m_Ninja.m_CurrentMoveTime=0;
pChr->SetNinjaActivationDir(vec2(0,0));
pChr->SetNinjaActivationTick(-500);
pChr->SetNinjaCurrentMoveTime(0);
if (sound)
{
pChr->m_LastWeapon = WEAPON_GUN;
pChr->SetLastWeapon(WEAPON_GUN);
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
}
if(!pChr->m_FreezeTime) pChr->m_ActiveWeapon = WEAPON_HAMMER;
if(!pChr->m_FreezeTime) pChr->SetActiveWeapon(WEAPON_HAMMER);
break;
case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->m_aWeapons[m_Subtype].m_Got || (pChr->m_aWeapons[m_Subtype].m_Ammo != -1 && !pChr->m_FreezeTime)))
if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->GetWeaponGot(m_Subtype) || (pChr->GetWeaponAmmo(m_Subtype) != -1 && !pChr->m_FreezeTime)))
{
if(pChr->GiveWeapon(m_Subtype, -1))
{
@ -161,7 +162,7 @@ void CPickup::Snap(int SnappingClient)
*/
CCharacter * SnapChar = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if (SnapChar && SnapChar->m_Alive && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) return;
if (SnapChar && SnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) return;
CNetObj_Pickup *pP = static_cast<CNetObj_Pickup *>(Server()->SnapNewItem(NETOBJTYPE_PICKUP, m_Id, sizeof(CNetObj_Pickup)));
if(!pP)
return;

View file

@ -4,6 +4,7 @@
#include <game/generated/protocol.h>
#include <game/server/gamecontext.h>
#include <game/server/teams.h>
#include <game/server/gamemodes/DDRace.h>
#include "plasma.h"
const float ACCEL=1.1f;
@ -68,7 +69,7 @@ void CPlasma::Tick()
if(Res)
{
if(m_Explosive)
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true, m_ResponsibleTeam, -1);//TODO: Fix mask
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, true, m_ResponsibleTeam, ((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.TeamMask(m_ResponsibleTeam));
Reset();
}
@ -81,7 +82,7 @@ void CPlasma::Snap(int SnappingClient)
CCharacter* SnapChar = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%11;
if(!SnapChar) return;
if (SnapChar->m_Alive && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) return;
if (SnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()]) && (!Tick)) return;
if((SnapChar->Team() != m_ResponsibleTeam) && (!SnapChar->GetPlayer()->m_IsUsingDDRaceClient || (GameServer()->m_apPlayers[SnappingClient]->m_IsUsingDDRaceClient && !GameServer()->m_apPlayers[SnappingClient]->m_ShowOthers))) return;
CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
pObj->m_X = (int)m_Pos.x;

View file

@ -107,16 +107,15 @@ void CProjectile::Tick()
(
OwnerChar &&
TargetChr &&
OwnerChar->m_Alive &&
TargetChr->m_Alive &&
OwnerChar->IsAlive() &&
TargetChr->IsAlive() &&
!TargetChr->CanCollide(m_Owner)
)
{
isWeaponCollide = true;
//TeamMask = OwnerChar->Teams()->TeamMask( OwnerChar->Team());
}
if (OwnerChar &&
OwnerChar->m_Alive)
if (OwnerChar && OwnerChar->IsAlive())
{
TeamMask = OwnerChar->Teams()->TeamMask( OwnerChar->Team());
}
@ -174,7 +173,7 @@ void CProjectile::Snap(int SnappingClient)
return;
CCharacter * SnapChar = GameServer()->GetPlayerChar(SnappingClient);
int Tick = (Server()->Tick()%Server()->TickSpeed())%((m_Explosive)?6:20);
if (SnapChar && SnapChar->m_Alive && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()] && (!Tick))) return;
if (SnapChar && SnapChar->IsAlive() && (m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[SnapChar->Team()] && (!Tick))) return;
if
(

View file

@ -77,11 +77,6 @@ public:
class CGameContext *GameServer() { return GameWorld()->GameServer(); }
class IServer *Server() { return GameWorld()->Server(); }
void MarkDestroy() {
m_MarkedForDestroy = true;
}
CEntity *TypeNext() { return m_pNextTypeEntity; }
CEntity *TypePrev() { return m_pPrevTypeEntity; }
@ -154,6 +149,11 @@ public:
Contains the current posititon of the entity.
*/
vec2 m_Pos;
void MarkDestroy()
{
m_MarkedForDestroy = true;
}
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -44,7 +44,6 @@ class CGameContext : public IGameServer
CCollision m_Collision;
CNetObjHandler m_NetObjHandler;
CTuningParams m_Tuning;
class IScore *m_pScore;
static void ConTuneParam(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConTuneReset(IConsole::IResult *pResult, void *pUserData, int ClientId);
@ -60,6 +59,119 @@ class CGameContext : public IGameServer
static void ConVote(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
CGameContext(int Resetting);
void Construct(int Resetting);
bool m_Resetting;
public:
IServer *Server() const { return m_pServer; }
class IConsole *Console() { return m_pConsole; }
CCollision *Collision() { return &m_Collision; }
CTuningParams *Tuning() { return &m_Tuning; }
CGameContext();
~CGameContext();
void Clear();
CEventHandler m_Events;
CPlayer *m_apPlayers[MAX_CLIENTS];
IGameController *m_pController;
CGameWorld m_World;
// helper functions
class CCharacter *GetPlayerChar(int ClientId);
// voting
void StartVote(const char *pDesc, const char *pCommand);
void EndVote();
void SendVoteSet(int ClientId);
void SendVoteStatus(int ClientId, int Total, int Yes, int No);
void AbortVoteKickOnDisconnect(int ClientId);
int m_VoteCreator;
int64 m_VoteCloseTime;
bool m_VoteUpdate;
int m_VotePos;
char m_aVoteDescription[512];
char m_aVoteCommand[512];
int m_VoteEnforce;
enum
{
VOTE_ENFORCE_UNKNOWN=0,
VOTE_ENFORCE_NO,
VOTE_ENFORCE_YES,
};
struct CVoteOption
{
CVoteOption *m_pNext;
CVoteOption *m_pPrev;
char m_aCommand[1];
};
CHeap *m_pVoteOptionHeap;
CVoteOption *m_pVoteOptionFirst;
CVoteOption *m_pVoteOptionLast;
// helper functions
void CreateDamageInd(vec2 Pos, float AngleMod, int Amount, int Mask=-1);
void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int Mask);
void CreateSmoke(vec2 Pos, int Mask=-1);
void CreateHammerHit(vec2 Pos, int Mask=-1);
void CreatePlayerSpawn(vec2 Pos, int Mask=-1);
void CreateDeath(vec2 Pos, int Who, int Mask=-1);
void CreateSound(vec2 Pos, int Sound, int Mask=-1);
void CreateSoundGlobal(int Sound, int Target=-1);
enum
{
CHAT_ALL=-2,
CHAT_SPEC=-1,
CHAT_RED=0,
CHAT_BLUE=1
};
// network
void SendChatTarget(int To, const char *pText);
void SendChat(int ClientId, int Team, const char *pText, int SpamProtectionClientId = -1);
void SendEmoticon(int ClientId, int Emoticon);
void SendWeaponPickup(int ClientId, int Weapon);
void SendBroadcast(const char *pText, int ClientId);
//
void CheckPureTuning();
void SendTuningParams(int ClientId);
// engine events
virtual void OnInit();
virtual void OnConsoleInit();
virtual void OnShutdown();
virtual void OnTick();
virtual void OnPreSnap();
virtual void OnSnap(int ClientId);
virtual void OnPostSnap();
virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId);
virtual void OnClientConnected(int ClientId);
virtual void OnClientEnter(int ClientId);
virtual void OnClientDrop(int ClientId);
virtual void OnClientDirectInput(int ClientId, void *pInput);
virtual void OnClientPredictedInput(int ClientId, void *pInput);
virtual const char *Version();
virtual const char *NetVersion();
//DDRace
private:
class IScore *m_pScore;
int m_VoteEnforcer;
//DDRace Console Commands
static void ConMute(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConUnmute(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConLogOut(IConsole::IResult *pResult, void *pUserData, int ClientId);
@ -67,7 +179,7 @@ class CGameContext : public IGameServer
static void ConSetlvl2(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConSetlvl3(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConKillPlayer(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConNinja(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConHammer(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConUnSuper(IConsole::IResult *pResult, void *pUserData, int ClientId);
@ -82,13 +194,13 @@ class CGameContext : public IGameServer
static void ConUnWeapons(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConAddWeapon(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConRemoveWeapon(IConsole::IResult *pResult, void *pUserData, int ClientId);
void ModifyWeapons(int ClientId, int Victim, int Weapon, bool Remove);
void MoveCharacter(int ClientId, int Victim, int X, int Y, bool Raw = false);
static void ConTeleport(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConPhook(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConFreeze(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConUnFreeze(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConTimerStop(IConsole::IResult *pResult, void *pUserData, int ClientId);
@ -99,7 +211,7 @@ class CGameContext : public IGameServer
static void ConGoRight(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConGoUp(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConGoDown(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConMove(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConMoveRaw(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConInvisMe(IConsole::IResult *pResult, void *pUserData, int ClientId);
@ -124,165 +236,31 @@ class CGameContext : public IGameServer
static void ConToggleBroadcast(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConEyeEmote(IConsole::IResult *pResult, void *pUserData, int ClientId);
static void ConShowOthers(IConsole::IResult *pResult, void *pUserData, int ClientId);
CGameContext(int Resetting);
void Construct(int Resetting);
int m_VoteEnforcer;
bool m_Resetting;
public:
IServer *Server() const { return m_pServer; }
class IConsole *Console() { return m_pConsole; }
CCollision *Collision() { return &m_Collision; }
CLayers *Layers() { return &m_Layers; }
CTuningParams *Tuning() { return &m_Tuning; }
class IScore *Score() { return m_pScore; }
CGameContext();
~CGameContext();
void Clear();
CEventHandler m_Events;
CPlayer *m_apPlayers[MAX_CLIENTS];
IGameController *m_pController;
CGameWorld m_World;
//CTeleTile *m_pSwitch;
// helper functions
class CCharacter *GetPlayerChar(int ClientId);
// voting
void StartVote(const char *pDesc, const char *pCommand);
void EndVote();
void SendVoteSet(int ClientId);
void SendVoteStatus(int ClientId, int Total, int Yes, int No);
void AbortVoteKickOnDisconnect(int ClientId);
bool m_VoteKick;
int m_VoteCreator;
int64 m_VoteCloseTime;
bool m_VoteUpdate;
int m_VotePos;
char m_aVoteDescription[512];
char m_aVoteCommand[512];
int m_VoteEnforce;
enum
{
VOTE_ENFORCE_UNKNOWN=0,
VOTE_ENFORCE_NO,
VOTE_ENFORCE_YES,
VOTE_ENFORCE_NO_ADMIN,
VOTE_ENFORCE_NO_ADMIN = VOTE_ENFORCE_YES + 1,
VOTE_ENFORCE_YES_ADMIN
};
struct CVoteOption
{
CVoteOption *m_pNext;
CVoteOption *m_pPrev;
char m_aCommand[1];
};
CHeap *m_pVoteOptionHeap;
CVoteOption *m_pVoteOptionFirst;
CVoteOption *m_pVoteOptionLast;
// helper functions
void CreateDamageInd(vec2 Pos, float AngleMod, int Amount, int Mask=-1);
void CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamage, int ActivatedTeam, int Mask);
void CreateSmoke(vec2 Pos, int Mask=-1);
void CreateHammerHit(vec2 Pos, int Mask=-1);
void CreatePlayerSpawn(vec2 Pos, int Mask=-1);
void CreateDeath(vec2 Pos, int Who, int Mask=-1);
void CreateSound(vec2 Pos, int Sound, int Mask=-1);
void CreateSoundGlobal(int Sound, int Target=-1);
struct ReconnectInfo
{
struct PlayerInfo {
CCharacterCore m_Core;
int m_StartTime;
int m_DDRaceState;
//int m_RefreshTime;
int m_FreezeTime;
bool m_Doored;
vec2 m_OldPos;
vec2 m_OlderPos;
int m_LastAction;
int m_Jumped;
int m_Health;
int m_Armor;
int m_PlayerState;
int m_LastMove;
vec2 m_PrevPos;
int m_ActiveWeapon;
int m_LastWeapon;
bool m_aHasWeapon[NUM_WEAPONS];
int m_HammerType;
bool m_Super;
int m_PauseTime;
} m_PlayerInfo;
char Ip[64];
int m_ClientId;
int m_DisconnectTick;
}m_pReconnectInfo[MAX_CLIENTS];
enum
{
CHAT_ALL=-2,
CHAT_SPEC=-1,
CHAT_RED=0,
CHAT_BLUE=1
};
// network
void SendChatTarget(int To, const char *pText);
void SendChat(int ClientId, int Team, const char *pText, int SpamProtectionClientId = -1);
void SendEmoticon(int ClientId, int Emoticon);
void SendWeaponPickup(int ClientId, int Weapon);
void SendBroadcast(const char *pText, int ClientId);
void SendRecord(int ClientId);
static void SendChatResponse(const char *pLine, void *pUser);
static void SendChatResponseAll(const char *pLine, void *pUser);
struct ChatResponseInfo
{
CGameContext *m_GameContext;
int m_To;
CGameContext *m_GameContext;
int m_To;
};
//
void CheckPureTuning();
void SendTuningParams(int ClientId);
// engine events
virtual void OnInit();
virtual void OnConsoleInit();
virtual void OnShutdown();
virtual void OnTick();
virtual void OnPreSnap();
virtual void OnSnap(int ClientId);
virtual void OnPostSnap();
virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId);
virtual void OnClientConnected(int ClientId);
virtual void OnClientEnter(int ClientId);
virtual void OnClientDrop(int ClientId);
virtual void OnClientDirectInput(int ClientId, void *pInput);
virtual void OnClientPredictedInput(int ClientId, void *pInput);
virtual void OnSetAuthed(int ClientId,int Level);
virtual bool PlayerCollision();
virtual bool PlayerHooking();
virtual const char *Version();
virtual const char *NetVersion();
};
bool ComparePlayers(CPlayer *pl1, CPlayer *pl2);
inline int CmaskAll() { return -1; }
inline int CmaskOne(int ClientId) { return 1<<ClientId; }
inline int CmaskAllExceptOne(int ClientId) { return 0x7fffffff^CmaskOne(ClientId); }
inline bool CmaskIsSet(int Mask, int ClientId) { return (Mask&CmaskOne(ClientId)) != 0; }
#endif
#endif

View file

@ -3,14 +3,12 @@
#include <engine/shared/config.h>
#include <game/mapitems.h>
#include <game/generated/protocol.h>
#include "entities/pickup.h"
#include "gamecontroller.h"
#include "gamecontext.h"
#include "entities/pickup.h"
#include "entities/light.h"
#include "entities/dragger.h"
#include "entities/gun.h"
@ -20,13 +18,12 @@
#include <game/layers.h>
IGameController::IGameController(class CGameContext *pGameServer)
{
m_pGameServer = pGameServer;
m_pServer = m_pGameServer->Server();
m_pGameType = "unknown";
//
DoWarmup(g_Config.m_SvWarmup);
m_GameOverTick = -1;
@ -37,10 +34,10 @@ IGameController::IGameController(class CGameContext *pGameServer)
//m_aTeamscore[TEAM_RED] = 0;
//m_aTeamscore[TEAM_BLUE] = 0;
m_aMapWish[0] = 0;
m_UnbalancedTick = -1;
m_ForceBalanced = false;
m_aNumSpawnPoints[0] = 0;
m_aNumSpawnPoints[1] = 0;
m_aNumSpawnPoints[2] = 0;
@ -51,7 +48,6 @@ IGameController::IGameController(class CGameContext *pGameServer)
IGameController::~IGameController()
{
}
float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos)
@ -64,11 +60,11 @@ float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos)
float Scoremod = 1.0f;
if(pEval->m_FriendlyTeam != -1 && pC->GetPlayer()->GetTeam() == pEval->m_FriendlyTeam)
Scoremod = 0.5f;
float d = distance(Pos, pC->m_Pos);
Score += Scoremod * (d == 0 ? 1000000000.0f : 1.0f/d);
}
return Score;
}
@ -91,15 +87,15 @@ void IGameController::EvaluateSpawnType(CSpawnEval *pEval, int T)
bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
{
CSpawnEval Eval;
// spectators can't spawn
if(pPlayer->GetTeam() == TEAM_SPECTATORS)
return false;
/*if(IsTeamplay())
{
Eval.m_FriendlyTeam = pPlayer->GetTeam();
// try first try own team spawn, then normal spawn and then enemy
EvaluateSpawnType(&Eval, 1+(pPlayer->GetTeam()&1));
if(!Eval.m_Got)
@ -115,18 +111,20 @@ bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
EvaluateSpawnType(&Eval, 1);
EvaluateSpawnType(&Eval, 2);
//}
*pOutPos = Eval.m_Pos;
return Eval.m_Got;
}
bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number)
{
if (Index<0)
if (Index < 0)
return false;
int Type = -1;
int SubType = 0;
int x,y;
x=(Pos.x-16.0f)/32.0f;
y=(Pos.y-16.0f)/32.0f;
@ -140,8 +138,6 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
sides[6]=GameServer()->Collision()->Entity(x-1,y, Layer);
sides[7]=GameServer()->Collision()->Entity(x-1,y+1, Layer);
if(Index == ENTITY_SPAWN)
m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos;
else if(Index == ENTITY_SPAWN_RED)
@ -150,17 +146,17 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos;
else if(Index == ENTITY_DOOR)
{
for(int i=0; i<8;i++)
for(int i = 0; i < 8;i++)
{
if (sides[i] >= ENTITY_LASER_SHORT && sides[i] <= ENTITY_LASER_LONG)
{
new CDoor
(
&GameServer()->m_World,//GameWorld
Pos,//Pos
pi/4*i,//Rotation
32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3,//Length
Number//Number
&GameServer()->m_World, //GameWorld
Pos, //Pos
pi / 4 * i, //Rotation
32 * 3 + 32 *(sides[i] - ENTITY_LASER_SHORT) * 3, //Length
Number //Number
);
}
}
@ -176,18 +172,18 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
Dir = 2;
else
Dir = 3;
float Deg = Dir*(pi/2);
float Deg = Dir * (pi / 2);
CProjectile *bullet = new CProjectile
(
&GameServer()->m_World,
WEAPON_SHOTGUN, //Type
-1, //Owner
Pos, //Pos
vec2(sin(Deg),cos(Deg)), //Dir
vec2(sin(Deg), cos(Deg)), //Dir
-2, //Span
true, //Freeze
true, //Explosive
0,//Force
0, //Force
(g_Config.m_SvShotgunBulletSound)?SOUND_GRENADE_EXPLODE:-1,//SoundImpact
WEAPON_SHOTGUN,//Weapon
Layer,
@ -206,20 +202,20 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
Dir = 2;
else
Dir = 3;
float Deg = Dir*(pi/2);
float Deg = Dir * ( pi / 2);
CProjectile *bullet = new CProjectile
(
&GameServer()->m_World,
WEAPON_SHOTGUN, //Type
-1, //Owner
Pos, //Pos
vec2(sin(Deg),cos(Deg)), //Dir
vec2(sin(Deg), cos(Deg)), //Dir
-2, //Span
true, //Freeze
false, //Explosive
0,
SOUND_GRENADE_EXPLODE,
WEAPON_SHOTGUN,//Weapon
WEAPON_SHOTGUN, //Weapon
Layer,
Number
);
@ -253,85 +249,85 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
{
int sides2[8];
sides2[0]=GameServer()->Collision()->Entity(x,y+2, Layer);
sides2[1]=GameServer()->Collision()->Entity(x+2,y+2, Layer);
sides2[2]=GameServer()->Collision()->Entity(x+2,y, Layer);
sides2[3]=GameServer()->Collision()->Entity(x+2,y-2, Layer);
sides2[4]=GameServer()->Collision()->Entity(x,y-2, Layer);
sides2[5]=GameServer()->Collision()->Entity(x-2,y-2, Layer);
sides2[6]=GameServer()->Collision()->Entity(x-2,y, Layer);
sides2[7]=GameServer()->Collision()->Entity(x-2,y+2, Layer);
sides2[0]=GameServer()->Collision()->Entity(x, y + 2, Layer);
sides2[1]=GameServer()->Collision()->Entity(x + 2, y + 2, Layer);
sides2[2]=GameServer()->Collision()->Entity(x + 2, y, Layer);
sides2[3]=GameServer()->Collision()->Entity(x + 2, y - 2, Layer);
sides2[4]=GameServer()->Collision()->Entity(x,y - 2, Layer);
sides2[5]=GameServer()->Collision()->Entity(x - 2, y - 2, Layer);
sides2[6]=GameServer()->Collision()->Entity(x - 2, y, Layer);
sides2[7]=GameServer()->Collision()->Entity(x - 2, y + 2, Layer);
float AngularSpeed = 0.0;
int Ind=Index-ENTITY_LASER_STOP;
int M;
if (Ind<0)
if( Ind < 0)
{
Ind=-Ind;
M=1;
Ind = -Ind;
M = 1;
}
else if(Ind==0)
M=0;
else if(Ind == 0)
M = 0;
else
M=-1;
M = -1;
if (Ind==0)
AngularSpeed=0.0f;
else if (Ind==1)
AngularSpeed=pi/360;
else if (Ind==2)
AngularSpeed=pi/180;
else if (Ind==3)
AngularSpeed=pi/90;
AngularSpeed*=M;
if(Ind == 0)
AngularSpeed = 0.0f;
else if(Ind == 1)
AngularSpeed = pi / 360;
else if(Ind == 2)
AngularSpeed = pi / 180;
else if(Ind == 3)
AngularSpeed = pi / 90;
AngularSpeed *= M;
for(int i=0; i<8;i++)
{
if (sides[i] >= ENTITY_LASER_SHORT && sides[i] <= ENTITY_LASER_LONG)
{
CLight *Lgt = new CLight(&GameServer()->m_World, Pos, pi/4*i,32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3, Layer, Number);
Lgt->m_AngularSpeed=AngularSpeed;
if (sides2[i]>=ENTITY_LASER_C_SLOW && sides2[i]<=ENTITY_LASER_C_FAST)
{
Lgt->m_Speed=1+(sides2[i]-ENTITY_LASER_C_SLOW)*2;
Lgt->m_CurveLength=Lgt->m_Length;
}
else if(sides2[i]>=ENTITY_LASER_O_SLOW && sides2[i]<=ENTITY_LASER_O_FAST)
{
Lgt->m_Speed=1+(sides2[i]-ENTITY_LASER_O_SLOW)*2;
Lgt->m_CurveLength=0;
}
else
Lgt->m_CurveLength=Lgt->m_Length;
}
if(sides[i] >= ENTITY_LASER_SHORT && sides[i] <= ENTITY_LASER_LONG)
{
CLight *Lgt = new CLight(&GameServer()->m_World, Pos, pi / 4 * i, 32 * 3 + 32 * (sides[i] - ENTITY_LASER_SHORT) * 3, Layer, Number);
Lgt->m_AngularSpeed = AngularSpeed;
if(sides2[i] >= ENTITY_LASER_C_SLOW && sides2[i] <= ENTITY_LASER_C_FAST)
{
Lgt->m_Speed = 1 + (sides2[i] - ENTITY_LASER_C_SLOW) * 2;
Lgt->m_CurveLength = Lgt->m_Length;
}
else if(sides2[i] >= ENTITY_LASER_O_SLOW && sides2[i] <= ENTITY_LASER_O_FAST)
{
Lgt->m_Speed = 1 + (sides2[i] - ENTITY_LASER_O_SLOW) * 2;
Lgt->m_CurveLength = 0;
}
else
Lgt->m_CurveLength = Lgt->m_Length;
}
}
}
else if(Index>=ENTITY_DRAGGER_WEAK && Index <=ENTITY_DRAGGER_STRONG)
{
new CDraggerTeam(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1, false, Layer, Number);
}
else if(Index>=ENTITY_DRAGGER_WEAK_NW && Index <=ENTITY_DRAGGER_STRONG_NW)
{
new CDraggerTeam(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true, Layer, Number);
}
else if(Index==ENTITY_PLASMAE)
{
new CGun(&GameServer()->m_World, Pos, false, true, Layer, Number);
}
else if(Index==ENTITY_PLASMAF)
{
new CGun(&GameServer()->m_World, Pos, true, false, Layer, Number);
}
else if(Index==ENTITY_PLASMA)
{
new CGun(&GameServer()->m_World, Pos, true, true, Layer, Number);
}
else if(Index==ENTITY_PLASMAU)
{
new CGun(&GameServer()->m_World, Pos, false, false, Layer, Number);
}
else if(Index >= ENTITY_DRAGGER_WEAK && Index <= ENTITY_DRAGGER_STRONG)
{
new CDraggerTeam(&GameServer()->m_World, Pos, Index - ENTITY_DRAGGER_WEAK + 1, false, Layer, Number);
}
else if(Index >= ENTITY_DRAGGER_WEAK_NW && Index <= ENTITY_DRAGGER_STRONG_NW)
{
new CDraggerTeam(&GameServer()->m_World, Pos, Index - ENTITY_DRAGGER_WEAK_NW + 1, true, Layer, Number);
}
else if(Index == ENTITY_PLASMAE)
{
new CGun(&GameServer()->m_World, Pos, false, true, Layer, Number);
}
else if(Index == ENTITY_PLASMAF)
{
new CGun(&GameServer()->m_World, Pos, true, false, Layer, Number);
}
else if(Index == ENTITY_PLASMA)
{
new CGun(&GameServer()->m_World, Pos, true, true, Layer, Number);
}
else if(Index == ENTITY_PLASMAU)
{
new CGun(&GameServer()->m_World, Pos, false, false, Layer, Number);
}
if(Type != -1)
{
CPickup *pPickup = new CPickup(&GameServer()->m_World, Type, SubType, Layer, Number);
@ -342,27 +338,11 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
return false;
}
vec2 GetSidePos(int side) {
switch(side)
{
case 0: return vec2(0, 1);
case 1: return vec2(1, 1);
case 2: return vec2(1, 0);
case 3: return vec2(1, -1);
case 4: return vec2(0, -1);
case 5: return vec2(-1, -1);
case 6: return vec2(-1, 0);
case 7: return vec2(-1, 1);
}
return vec2(0, 0);
}
void IGameController::EndRound()
{
if(m_Warmup) // game can't end when we are running warmup
return;
GameServer()->m_World.m_Paused = true;
m_GameOverTick = Server()->Tick();
m_SuddenDeath = 0;
@ -374,27 +354,32 @@ void IGameController::ResetGame()
}
const char *IGameController::GetTeamName(int Team)
{
/*
if(Team == TEAM_RED)
return "red team";
else if(Team == TEAM_BLUE)
return "blue team";
{/*
if(IsTeamplay())
{
if(Team == TEAM_RED)
return "red team";
else if(Team == TEAM_BLUE)
return "blue team";
}
else
{*/
{
if(Team == 0)
return "game";
}
*/
if(Team == 0)
return "game";
return "spectators";
}
bool IsSeparator(char c) { return c == ';' || c == ' ' || c == ',' || c == '\t'; }
static bool IsSeparator(char c) { return c == ';' || c == ' ' || c == ',' || c == '\t'; }
void IGameController::StartRound()
{
ResetGame();
m_RoundStartTick = Server()->Tick();
m_SuddenDeath = 0;
m_GameOverTick = -1;
@ -431,11 +416,11 @@ void IGameController::CycleMap()
if(m_RoundCount < g_Config.m_SvRoundsPerMap-1)
return;
// handle maprotation
const char *pMapRotation = g_Config.m_SvMaprotation;
const char *pCurrentMap = g_Config.m_SvMap;
int CurrentMapLen = str_length(pCurrentMap);
const char *pNextMap = pMapRotation;
while(*pNextMap)
@ -443,25 +428,25 @@ void IGameController::CycleMap()
int WordLen = 0;
while(pNextMap[WordLen] && !IsSeparator(pNextMap[WordLen]))
WordLen++;
if(WordLen == CurrentMapLen && str_comp_num(pNextMap, pCurrentMap, CurrentMapLen) == 0)
{
// map found
pNextMap += CurrentMapLen;
while(*pNextMap && IsSeparator(*pNextMap))
pNextMap++;
break;
}
pNextMap++;
}
// restart rotation
if(pNextMap[0] == 0)
pNextMap = pMapRotation;
// cut out the next map
// cut out the next map
char aBuf[512];
for(int i = 0; i < 512; i++)
{
@ -472,14 +457,14 @@ void IGameController::CycleMap()
break;
}
}
// skip spaces
int i = 0;
while(IsSeparator(aBuf[i]))
i++;
m_RoundCount = 0;
char aBufMsg[256];
str_format(aBufMsg, sizeof(aBufMsg), "rotating map to %s", &aBuf[i]);
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
@ -515,6 +500,7 @@ void IGameController::OnPlayerInfoChange(class CPlayer *pP)
}
*/
int IGameController::OnCharacterDeath(class CCharacter *pVictim, class CPlayer *pKiller, int Weapon)
{
/*
@ -537,9 +523,8 @@ void IGameController::OnCharacterSpawn(class CCharacter *pChr)
{
// default health
pChr->IncreaseHealth(10);
// give default weapons
//pChr->GiveAllWeapons();
pChr->GiveWeapon(WEAPON_HAMMER, -1);
pChr->GiveWeapon(WEAPON_GUN, -1);
}
@ -556,16 +541,16 @@ bool IGameController::IsFriendlyFire(int Cid1, int Cid2)
{
if(Cid1 == Cid2)
return false;
if(IsTeamplay())
{
if(!GameServer()->m_apPlayers[Cid1] || !GameServer()->m_apPlayers[Cid2])
return false;
if(GameServer()->m_apPlayers[Cid1]->GetTeam() == GameServer()->m_apPlayers[Cid2]->GetTeam())
return true;
}
return false;
}
*/
@ -594,7 +579,7 @@ void IGameController::Tick()
if(!m_Warmup)
StartRound();
}
if(m_GameOverTick != -1)
{
// game over.. wait for restart
@ -610,7 +595,7 @@ void IGameController::Tick()
if (IsTeamplay() && m_UnbalancedTick != -1 && Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60)
{
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "Balancing teams");
int aT[2] = {0,0};
float aTScore[2] = {0,0};
float aPScore[MAX_CLIENTS] = {0.0f};
@ -624,13 +609,13 @@ void IGameController::Tick()
aTScore[GameServer()->m_apPlayers[i]->GetTeam()] += aPScore[i];
}
}
// are teams unbalanced?
if(absolute(aT[0]-aT[1]) >= 2)
{
int M = (aT[0] > aT[1]) ? 0 : 1;
int NumBalance = absolute(aT[0]-aT[1]) / 2;
do
{
CPlayer *pP = 0;
@ -646,7 +631,7 @@ void IGameController::Tick()
PD = absolute((aTScore[M^1]+aPScore[i]) - (aTScore[M]-aPScore[i]));
}
}
// move the player to the other team
int Temp = pP->m_LastActionTick;
pP->SetTeam(M^1);
@ -655,7 +640,7 @@ void IGameController::Tick()
pP->Respawn();
pP->m_ForceBalanced = true;
} while (--NumBalance);
m_ForceBalanced = true;
}
m_UnbalancedTick = -1;
@ -746,24 +731,22 @@ void IGameController::Snap(int SnappingClient)
pGameObj->m_Paused = GameServer()->m_World.m_Paused;
pGameObj->m_GameOver = m_GameOverTick==-1?0:1;
pGameObj->m_SuddenDeath = m_SuddenDeath;
//pGameObj->m_ScoreLimit = g_Config.m_SvScorelimit;
//pGameObj->m_TimeLimit = g_Config.m_SvTimelimit;
CCharacter *pChar;
CPlayer *pPlayer;
if ((pPlayer = GameServer()->m_apPlayers[SnappingClient]))
if((pChar = pPlayer->GetCharacter()))
pGameObj->m_RoundStartTick = (pChar->m_DDRaceState == DDRACE_STARTED)?pChar->m_StartTime:Server()->Tick();
pGameObj->m_Flags = m_GameFlags;
pGameObj->m_Warmup = m_Warmup;
pGameObj->m_RoundNum = /*(str_length(g_Config.m_SvMaprotation) && g_Config.m_SvRoundsPerMap) ? g_Config.m_SvRoundsPerMap :*/ 0;
pGameObj->m_RoundCurrent = m_RoundCount+1;
if(SnappingClient == -1)
{
// we are recording a demo, just set the scores
@ -783,7 +766,7 @@ int IGameController::GetAutoTeam(int Notthisid)
// this will force the auto balancer to work overtime aswell
if(g_Config.m_DbgStress)
return 0;
int aNumplayers[2] = {0,0};
for(int i = 0; i < MAX_CLIENTS; i++)
{
@ -817,7 +800,7 @@ bool IGameController::CanJoinTeam(int Team, int Notthisid)
aNumplayers[GameServer()->m_apPlayers[i]->GetTeam()]++;
}
}
return (aNumplayers[0] + aNumplayers[1]) < g_Config.m_SvMaxClients-g_Config.m_SvSpectatorSlots;
}
/*
@ -825,7 +808,7 @@ bool IGameController::CheckTeamBalance()
{
if(!IsTeamplay() || !g_Config.m_SvTeambalanceTime)
return true;
int aT[2] = {0, 0};
for(int i = 0; i < MAX_CLIENTS; i++)
{
@ -833,7 +816,7 @@ bool IGameController::CheckTeamBalance()
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
aT[pP->GetTeam()]++;
}
char aBuf[256];
if(absolute(aT[0]-aT[1]) >= 2)
{
@ -851,26 +834,26 @@ bool IGameController::CheckTeamBalance()
return true;
}
}
*//*
bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
{
int aT[2] = {0, 0};
if (!IsTeamplay() || JoinTeam == TEAM_SPECTATORS || !g_Config.m_SvTeambalanceTime)
return true;
for(int i = 0; i < MAX_CLIENTS; i++)
{
CPlayer *pP = GameServer()->m_apPlayers[i];
if(pP && pP->GetTeam() != TEAM_SPECTATORS)
aT[pP->GetTeam()]++;
}
// simulate what would happen if changed team
aT[JoinTeam]++;
if (pPlayer->GetTeam() != TEAM_SPECTATORS)
aT[JoinTeam^1]--;
// there is a player-difference of at least 2
if(absolute(aT[0]-aT[1]) >= 2)
{
@ -883,7 +866,7 @@ bool IGameController::CanChangeTeam(CPlayer *pPlayer, int JoinTeam)
else
return true;
}
*//*
void IGameController::DoPlayerScoreWincheck()
{
if(m_GameOverTick == -1 && !m_Warmup)
@ -904,7 +887,7 @@ void IGameController::DoPlayerScoreWincheck()
TopscoreCount++;
}
}
// check score win condition
if((g_Config.m_SvScorelimit > 0 && Topscore >= g_Config.m_SvScorelimit) ||
(g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60))
@ -934,13 +917,12 @@ void IGameController::DoTeamScoreWincheck()
}
*/
int IGameController::ClampTeam(int Team)
{
if(Team < 0)
return TEAM_SPECTATORS;
//if(IsTeamplay())
// return Team&1;
//return Team&1;
return 0;
}

View file

@ -4,7 +4,6 @@
#define GAME_SERVER_GAMECONTROLLER_H
#include <base/vmath.h>
//#include <game/server/teams.h>
class CDoor;
/*
@ -48,7 +47,6 @@ protected:
char m_aMapWish[128];
int m_RoundStartTick;
int m_GameOverTick;
@ -66,17 +64,14 @@ protected:
public:
const char *m_pGameType;
float m_CurrentRecord;
//bool IsTeamplay() const;
IGameController(class CGameContext *pGameServer);
virtual ~IGameController();
//void DoTeamScoreWincheck();
//void DoPlayerScoreWincheck();
void DoWarmup(int Seconds);
void StartRound();
@ -110,7 +105,6 @@ public:
*/
virtual bool OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number = 0);
/*
Function: on_CCharacter_spawn
Called when a CCharacter spawns into the game world.
@ -149,6 +143,9 @@ public:
int ClampTeam(int Team);
virtual void PostReset();
//DDRace
float m_CurrentRecord;
};
#endif
#endif

View file

@ -240,18 +240,18 @@ std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2
// Find other players
vec2 LineDir = normalize(Pos1-Pos0);
CCharacter *p = (CCharacter *)FindFirst(CGameWorld::ENTTYPE_CHARACTER);
for(; p; p = (CCharacter *)p->TypeNext())
CCharacter *pChr = (CCharacter *)FindFirst(CGameWorld::ENTTYPE_CHARACTER);
for(; pChr; pChr = (CCharacter *)pChr->TypeNext())
{
if(p == pNotThis)
if(pChr == pNotThis)
continue;
vec2 IntersectPos = closest_point_on_line(Pos0, Pos1, p->m_Pos);
float Len = distance(p->m_Pos, IntersectPos);
if(Len < p->m_ProximityRadius+Radius)
vec2 IntersectPos = closest_point_on_line(Pos0, Pos1, pChr->m_Pos);
float Len = distance(pChr->m_Pos, IntersectPos);
if(Len < pChr->m_ProximityRadius+Radius)
{
p->m_Intersection = IntersectPos;
listOfChars.push_back(p);
pChr->m_Intersection = IntersectPos;
listOfChars.push_back(pChr);
}
}
return listOfChars;
@ -259,13 +259,16 @@ std::list<class CCharacter *> CGameWorld::IntersectedCharacters(vec2 Pos0, vec2
void CGameWorld::ReleaseHooked(int ClientId)
{
CCharacter *p = (CCharacter *)CGameWorld::FindFirst(CGameWorld::ENTTYPE_CHARACTER);
for(; p; p = (CCharacter *)p->TypeNext())
if(p->m_Core.m_HookedPlayer == ClientId && !p->m_Super)
CCharacter *pChr = (CCharacter *)CGameWorld::FindFirst(CGameWorld::ENTTYPE_CHARACTER);
for(; pChr; pChr = (CCharacter *)pChr->TypeNext())
{
CCharacterCore* Core = pChr->Core();
if(Core->m_HookedPlayer == ClientId && !pChr->m_Super)
{
p->m_Core.m_HookedPlayer = -1;
p->m_Core.m_HookState = HOOK_RETRACTED;
p->m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
p->m_Core.m_HookState = HOOK_RETRACTED;
Core->m_HookedPlayer = -1;
Core->m_HookState = HOOK_RETRACTED;
Core->m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
Core->m_HookState = HOOK_RETRACTED;
}
}
}

View file

@ -9,6 +9,7 @@
#include <game/gamecore.h>
#include "gamemodes/DDRace.h"
MACRO_ALLOC_POOL_ID_IMPL(CPlayer, MAX_CLIENTS)
IServer *CPlayer::Server() const { return m_pGameServer->Server(); }
@ -20,11 +21,11 @@ CPlayer::CPlayer(CGameContext *pGameServer, int CID, int Team)
m_DieTick = Server()->Tick();
m_ScoreStartTick = Server()->Tick();
Character = 0;
m_Muted = 0;
this->m_ClientID = CID;
m_Team = GameServer()->m_pController->ClampTeam(Team);
m_LastActionTick = Server()->Tick();
m_Muted = 0;
m_PauseInfo.m_Respawn = false;
GameServer()->Score()->PlayerData(CID)->Reset();
@ -53,7 +54,6 @@ void CPlayer::Tick()
Server()->SetClientScore(m_ClientID, m_Score);
if(m_Muted > 0) m_Muted--;
// do latency stuff
{
IServer::CClientInfo Info;
@ -92,6 +92,7 @@ void CPlayer::Tick()
}
else if(m_Spawning && m_RespawnTick <= Server()->Tick())
TryRespawn();
if(m_Muted > 0) m_Muted--;
}
void CPlayer::Snap(int SnappingClient)
@ -148,6 +149,7 @@ void CPlayer::OnDisconnect()
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(m_ClientID));
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);
}
@ -233,18 +235,20 @@ void CPlayer::TryRespawn()
{
Character = new(m_ClientID) CCharacter(&GameServer()->m_World);
Character->Spawn(this, m_PauseInfo.m_Core.m_Pos);
GameServer()->CreatePlayerSpawn(m_PauseInfo.m_Core.m_Pos);
GameServer()->CreatePlayerSpawn(m_PauseInfo.m_Core.m_Pos, ((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.TeamMask((m_PauseInfo.m_Team > 0 && m_PauseInfo.m_Team < TEAM_SUPER) ? m_PauseInfo.m_Team : 0));
LoadCharacter();
}
else
{
vec2 SpawnPos = vec2(100.0f, -60.0f);
if(!GameServer()->m_pController->CanSpawn(this, &SpawnPos))
return;
// check if the position is occupado
CEntity *apEnts[2] = {0};
int NumEnts = GameServer()->m_World.FindEntities(SpawnPos, 64, apEnts, 2, CGameWorld::ENTTYPE_CHARACTER);
if(NumEnts < 3)
{
m_Spawning = false;
@ -257,7 +261,7 @@ void CPlayer::TryRespawn()
void CPlayer::LoadCharacter()
{
Character->m_Core = m_PauseInfo.m_Core;
Character->SetCore(m_PauseInfo.m_Core);
if(g_Config.m_SvPauseTime)
Character->m_StartTime = Server()->Tick() - (m_PauseInfo.m_PauseTime - m_PauseInfo.m_StartTime);
else
@ -275,18 +279,12 @@ void CPlayer::LoadCharacter()
}
}
Character->m_FreezeTime = m_PauseInfo.m_FreezeTime;
Character->m_Doored = m_PauseInfo.m_Doored;
Character->m_OldPos = m_PauseInfo.m_OldPos;
Character->m_OlderPos = m_PauseInfo.m_OlderPos;
Character->m_LastAction = m_PauseInfo.m_LastAction;
Character->m_Jumped = m_PauseInfo.m_Jumped;
Character->m_Health = m_PauseInfo.m_Health;
Character->m_Armor = m_PauseInfo.m_Armor;
Character->m_PlayerState = m_PauseInfo.m_PlayerState;
Character->SetLastAction(Server()->Tick());
Character->SetArmor(m_PauseInfo.m_Armor);
Character->m_LastMove = m_PauseInfo.m_LastMove;
Character->m_PrevPos = m_PauseInfo.m_PrevPos;
Character->m_ActiveWeapon = m_PauseInfo.m_ActiveWeapon;
Character->m_LastWeapon = m_PauseInfo.m_LastWeapon;
Character->SetActiveWeapon(m_PauseInfo.m_ActiveWeapon);
Character->SetLastWeapon(m_PauseInfo.m_LastWeapon);
Character->m_HammerType = m_PauseInfo.m_HammerType;
Character->m_Super = m_PauseInfo.m_Super;
Character->m_DeepFreeze = m_PauseInfo.m_DeepFreeze;
@ -299,26 +297,19 @@ void CPlayer::LoadCharacter()
void CPlayer::SaveCharacter()
{
m_PauseInfo.m_Core = Character->m_Core;
m_PauseInfo.m_Core = Character->GetCore();
m_PauseInfo.m_StartTime = Character->m_StartTime;
m_PauseInfo.m_DDRaceState = Character->m_DDRaceState;
for(int i = 0; i < WEAPON_NINJA; ++i)
{
m_PauseInfo.m_aHasWeapon[i] = Character->m_aWeapons[i].m_Got;
m_PauseInfo.m_aHasWeapon[i] = Character->GetWeaponGot(i);
}
m_PauseInfo.m_FreezeTime=Character->m_FreezeTime;
m_PauseInfo.m_Doored = Character->m_Doored;
m_PauseInfo.m_OldPos = Character->m_OldPos;
m_PauseInfo.m_OlderPos = Character->m_OlderPos;
m_PauseInfo.m_LastAction = Character->m_LastAction;
m_PauseInfo.m_Jumped = Character->m_Jumped;
m_PauseInfo.m_Health = Character->m_Health;
m_PauseInfo.m_Armor = Character->m_Armor;
m_PauseInfo.m_PlayerState = Character->m_PlayerState;
m_PauseInfo.m_Armor = Character->GetArmor();
m_PauseInfo.m_LastMove = Character->m_LastMove;
m_PauseInfo.m_PrevPos = Character->m_PrevPos;
m_PauseInfo.m_ActiveWeapon = Character->m_ActiveWeapon;
m_PauseInfo.m_LastWeapon = Character->m_LastWeapon;
m_PauseInfo.m_ActiveWeapon = Character->GetActiveWeapon();
m_PauseInfo.m_LastWeapon = Character->GetLastWeapon();
m_PauseInfo.m_HammerType = Character->m_HammerType;
m_PauseInfo.m_Super = Character->m_Super;
m_PauseInfo.m_DeepFreeze = Character->m_DeepFreeze;

View file

@ -16,7 +16,7 @@ public:
CPlayer(CGameContext *pGameServer, int CID, int Team);
~CPlayer();
//void Init(int CID); idk what this does or where it is so i commented it. GreYFoXWas Here
void Init(int CID);
void TryRespawn();
void Respawn();
@ -24,7 +24,6 @@ public:
int GetTeam() const { return m_Team; };
int GetCID() const { return m_ClientID; };
void Tick();
void Snap(int SnappingClient);
@ -35,37 +34,6 @@ public:
void KillCharacter(int Weapon = WEAPON_GAME);
CCharacter *GetCharacter();
struct PauseInfo {
CCharacterCore m_Core;
int m_StartTime;
int m_DDRaceState;
//int m_RefreshTime;
int m_FreezeTime;
bool m_Doored;
vec2 m_OldPos;
vec2 m_OlderPos;
int m_LastAction;
int m_Jumped;
int m_Health;
int m_Armor;
int m_PlayerState;
int m_LastMove;
vec2 m_PrevPos;
int m_ActiveWeapon;
int m_LastWeapon;
bool m_Respawn;
bool m_aHasWeapon[NUM_WEAPONS];
int m_HammerType;
bool m_Super;
bool m_DeepFreeze;
bool m_EndlessHook;
int m_PauseTime;
int m_Team;
} m_PauseInfo;
bool m_InfoSaved;
void LoadCharacter();
void SaveCharacter();
//---------------------------------------------------------
// this is used for snapping so we know how we can clip the view for the player
vec2 m_ViewPos;
@ -74,35 +42,13 @@ public:
int m_Vote;
int m_VotePos;
//
int64 m_Last_KickVote;
int64 m_Last_VoteCall;
int64 m_Last_VoteTry;
int64 m_Last_Chat;
int64 m_Last_SetTeam;
int64 m_Last_ChangeInfo;
int64 m_Last_Emote;
int64 m_Last_Kill;
int64 m_Last_Pause;
int64 m_Last_Team;
bool m_Invisible;
int m_Muted;
//int hammer_ type;
// TODO: clean this up
int m_Authed;
bool m_IsUsingDDRaceClient;
bool m_ShowOthers;
int m_Starttime;
int m_Refreshtime;
int m_DDRaceState;
int m_Besttick;
int m_Lasttick;
float m_BestLap;
int m_Last_VoteCall;
int m_Last_VoteTry;
int m_Last_Chat;
int m_Last_SetTeam;
int m_Last_ChangeInfo;
int m_Last_Emote;
int m_Last_Kill;
// TODO: clean this up
struct
@ -125,12 +71,6 @@ public:
int m_TargetY;
} m_LatestActivity;
float m_BestTime;
float m_aBestCpTime[25];
bool m_ResetPickups;
bool m_RconFreeze;
private:
CCharacter *Character;
CGameContext *m_pGameServer;
@ -138,8 +78,6 @@ private:
CGameContext *GameServer() const { return m_pGameServer; }
IServer *Server() const;
//
bool m_Spawning;
int m_ClientID;
@ -155,6 +93,42 @@ private:
int m_Min;
int m_Max;
} m_Latency;
//DDRace
public:
struct PauseInfo
{
CCharacterCore m_Core;
int m_StartTime;
int m_DDRaceState;
//int m_RefreshTime;
int m_FreezeTime;
int m_Armor;
int m_LastMove;
vec2 m_PrevPos;
int m_ActiveWeapon;
int m_LastWeapon;
bool m_Respawn;
bool m_aHasWeapon[NUM_WEAPONS];
int m_HammerType;
bool m_Super;
bool m_DeepFreeze;
bool m_EndlessHook;
int m_PauseTime;
int m_Team;
} m_PauseInfo;
bool m_InfoSaved;
void LoadCharacter();
void SaveCharacter();
int64 m_Last_Pause;
int64 m_Last_KickVote;
int64 m_Last_Team;
bool m_Invisible;
int m_Muted;
int m_Authed;
bool m_IsUsingDDRaceClient;
bool m_ShowOthers;
bool m_RconFreeze;
};
#endif