Merge branch 'master' of git://github.com/matricks/teeworlds

Conflicts:
	src/game/server/gamemodes/ctf.cpp
This commit is contained in:
Fujnky 2010-06-03 17:47:32 +02:00
commit 5849aeb86c
4 changed files with 22 additions and 20 deletions

View file

@ -40,7 +40,7 @@ MACRO_ALLOC_POOL_ID_IMPL(CCharacter, MAX_CLIENTS)
CCharacter::CCharacter(CGameWorld *pWorld)
: CEntity(pWorld, NETOBJTYPE_CHARACTER)
{
m_ProximityRadius = g_CharPhysSize;
m_ProximityRadius = ms_PhysSize;
m_Health = 0;
m_Armor = 0;
}
@ -101,9 +101,9 @@ void CCharacter::SetWeapon(int W)
bool CCharacter::IsGrounded()
{
if(GameServer()->Collision()->CheckPoint(m_Pos.x+g_CharPhysSize/2, m_Pos.y+g_CharPhysSize/2+5))
if(GameServer()->Collision()->CheckPoint(m_Pos.x+m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5))
return true;
if(GameServer()->Collision()->CheckPoint(m_Pos.x-g_CharPhysSize/2, m_Pos.y+g_CharPhysSize/2+5))
if(GameServer()->Collision()->CheckPoint(m_Pos.x-m_ProximityRadius/2, m_Pos.y+m_ProximityRadius/2+5))
return true;
return false;
}
@ -144,7 +144,7 @@ void CCharacter::HandleNinja()
// Set velocity
m_Core.m_Vel = m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
vec2 OldPos = m_Pos;
GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(g_CharPhysSize, g_CharPhysSize), 0.f);
GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f);
// reset velocity so the client doesn't predict stuff
m_Core.m_Vel = vec2(0.f, 0.f);
@ -153,7 +153,7 @@ void CCharacter::HandleNinja()
{
CCharacter *aEnts[64];
vec2 Dir = m_Pos - OldPos;
float Radius = g_CharPhysSize * 2.0f;
float Radius = m_ProximityRadius * 2.0f;
vec2 Center = OldPos + Dir * 0.5f;
int Num = GameServer()->m_World.FindEntities(Center, Radius, (CEntity**)aEnts, 64, NETOBJTYPE_CHARACTER);
@ -173,7 +173,7 @@ void CCharacter::HandleNinja()
continue;
// check so we are sufficiently close
if (distance(aEnts[i]->m_Pos, m_Pos) > (g_CharPhysSize * 2.0f))
if (distance(aEnts[i]->m_Pos, m_Pos) > (m_ProximityRadius * 2.0f))
continue;
// Hit a player, give him damage and stuffs...
@ -277,7 +277,7 @@ void CCharacter::FireWeapon()
return;
}
vec2 ProjStartPos = m_Pos+Direction*g_CharPhysSize*0.75f;
vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f;
switch(m_ActiveWeapon)
{
@ -289,7 +289,7 @@ void CCharacter::FireWeapon()
CCharacter *aEnts[64];
int Hits = 0;
int Num = GameServer()->m_World.FindEntities(ProjStartPos, g_CharPhysSize*0.5f, (CEntity**)aEnts,
int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)aEnts,
64, NETOBJTYPE_CHARACTER);
for (int i = 0; i < Num; ++i)
@ -543,10 +543,10 @@ void CCharacter::Tick()
m_Core.Tick(true);
// handle death-tiles
if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+g_CharPhysSize/3.f, m_Pos.y-g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x+g_CharPhysSize/3.f, m_Pos.y+g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-g_CharPhysSize/3.f, m_Pos.y-g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-g_CharPhysSize/3.f, m_Pos.y+g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH)
if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH)
{
Die(m_pPlayer->GetCID(), WEAPON_WORLD);
}

View file

@ -7,9 +7,6 @@
#include <game/gamecore.h>
//character's size
const int g_CharPhysSize = 28;
enum
{
WEAPON_GAME = -3, // team switching etc
@ -22,6 +19,9 @@ class CCharacter : public CEntity
MACRO_ALLOC_POOL_ID()
public:
//character's size
static const int ms_PhysSize = 28;
CCharacter(CGameWorld *pWorld);
virtual void Reset();

View file

@ -105,7 +105,7 @@ void CGameControllerCTF::Tick()
if(m_apFlags[fi^1] && m_apFlags[fi^1]->m_AtStand)
{
if(distance(F->m_Pos, m_apFlags[fi^1]->m_Pos) < 28)
if(distance(F->m_Pos, m_apFlags[fi^1]->m_Pos) < CFlag::ms_PhysSize + CCharacter::ms_PhysSize)
{
// CAPTURE! \o/
m_aTeamscore[fi^1] += 100;
@ -136,7 +136,7 @@ void CGameControllerCTF::Tick()
else
{
CCharacter *apCloseCCharacters[MAX_CLIENTS];
int Num = GameServer()->m_World.FindEntities(F->m_Pos, 7.0f, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER);
int Num = GameServer()->m_World.FindEntities(F->m_Pos, CFlag::ms_PhysSize, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER);
for(int i = 0; i < Num; i++)
{
if(!apCloseCCharacters[i]->IsAlive() || apCloseCCharacters[i]->GetPlayer()->GetTeam() == -1 || GameServer()->Collision()->IntersectLine(F->m_Pos, apCloseCCharacters[i]->m_Pos, NULL, NULL))
@ -199,7 +199,7 @@ void CGameControllerCTF::Tick()
else
{
F->m_Vel.y += GameServer()->m_World.m_Core.m_Tuning.m_Gravity;
GameServer()->Collision()->MoveBox(&F->m_Pos, &F->m_Vel, vec2(F->m_PhysSize, F->m_PhysSize), 0.5f);
GameServer()->Collision()->MoveBox(&F->m_Pos, &F->m_Vel, vec2(F->ms_PhysSize, F->ms_PhysSize), 0.5f);
}
}
}
@ -211,7 +211,7 @@ CFlag::CFlag(CGameWorld *pGameWorld, int Team)
: CEntity(pGameWorld, NETOBJTYPE_FLAG)
{
m_Team = Team;
m_ProximityRadius = m_PhysSize;
m_ProximityRadius = ms_PhysSize;
m_pCarryingCharacter = 0x0;
m_GrabTick = 0;
@ -240,3 +240,4 @@ void CFlag::Snap(int SnappingClient)
else if(m_pCarryingCharacter && m_pCarryingCharacter->GetPlayer())
pFlag->m_CarriedBy = m_pCarryingCharacter->GetPlayer()->GetCID();
}

View file

@ -20,7 +20,7 @@ public:
class CFlag : public CEntity
{
public:
static const int m_PhysSize = 14;
static const int ms_PhysSize = 14;
CCharacter *m_pCarryingCharacter;
vec2 m_Vel;
vec2 m_StandPos;
@ -36,3 +36,4 @@ public:
virtual void Snap(int SnappingClient);
};
#endif