This commit is contained in:
btd 2010-08-14 13:40:40 +04:00
commit dfa60a65d2
3 changed files with 56 additions and 50 deletions

View file

@ -125,7 +125,7 @@ vec2 CCollision::GetPos(int Index)
int CCollision::GetCollisionDDRace(int Index)
{
dbg_msg("GetCollisionDDRace","m_pTiles[%d].m_Index = %d",Index,m_pTiles[Index].m_Index);//Remove*/
/*dbg_msg("GetCollisionDDRace","m_pTiles[%d].m_Index = %d",Index,m_pTiles[Index].m_Index);//Remove*/
if(Index < 0)
return 0;
return m_pTiles[Index].m_Index;
@ -403,27 +403,6 @@ void CCollision::GetSpeedup(int x, int y, vec2 *Dir, int *Force)
*Dir = TmpDir;
}
int CCollision::IsBegin(int Index)
{
return Index == TILE_BEGIN;
}
int CCollision::IsEnd(int Index)
{
return Index == TILE_END;
}
int CCollision::IsFreeze(int Index)
{
return Index == TILE_FREEZE;
}
int CCollision::IsUnfreeze(int Index)
{
return Index == TILE_UNFREEZE;
}
int CCollision::IsCp(int x, int y)
{
int nx = clamp(x/32, 0, m_Width-1);
@ -435,14 +414,6 @@ int CCollision::IsCp(int x, int y)
return 0;
}
int CCollision::IsBoost(int Index)
{
if ((Index >= TILE_BOOST_L && Index <= TILE_BOOST_U) || (Index >= TILE_BOOST_L2 && Index <= TILE_BOOST_U2))
return Index;
else
return 0;
}
vec2 CCollision::CpSpeed(int Index)
{

View file

@ -45,12 +45,7 @@ public:
void GetSpeedup(int x, int y, vec2 *Dir, int *Force);
int IsSolid(int x, int y);
int IsBegin(int Index);
int IsNoLaser(int x, int y);
int IsEnd(int Index);
int IsBoost(int Index);
int IsFreeze(int Index);
int IsUnfreeze(int Index);
int IsCp(int x, int y);
vec2 BoostAccelerator(int Index);

View file

@ -67,7 +67,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_OlderPos = Pos;
m_OldPos = Pos;
m_RaceState = RACE_NONE;
m_PrevPos = Pos;
m_Core.Reset();
m_Core.Init(&GameServer()->m_World.m_Core, GameServer()->Collision());
m_Core.m_Pos = m_Pos;
@ -557,8 +557,8 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
void CCharacter::Tick()
{
int TileIndex = GameServer()->Collision()->GetIndex(m_PrevPos, m_Pos);
int MapIndex = GameServer()->Collision()->GetIndex(m_PrevPos, m_Pos);
int TileIndex = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
if(m_RaceState == RACE_PAUSE) {
m_Input.m_Direction = 0;
m_Input.m_Jump = 0;
@ -600,10 +600,11 @@ void CCharacter::Tick()
m_Core.m_HookTick = 0;
if (m_Super && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1;
dbg_msg("character","TileIndex%d",TileIndex); //REMOVE*/
/*dbg_msg("character","TileIndex%d",TileIndex); //REMOVE*/
//DDRace
char aBuftime[128];
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
int z = GameServer()->Collision()->IsTeleport(m_Pos.x, m_Pos.y);
if(Server()->Tick() - m_RefreshTime >= Server()->TickSpeed())
{
//GameServer()->SendBroadcast("FIRST_IF", m_pPlayer->GetCID());
@ -618,13 +619,13 @@ void CCharacter::Tick()
}
m_RefreshTime = Server()->Tick();
}
if(GameServer()->Collision()->IsBegin(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && m_RaceState == RACE_NONE)
else if((TileIndex == TILE_BEGIN) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
{
m_StartTime = Server()->Tick();
m_RefreshTime = Server()->Tick();
m_RaceState = RACE_STARTED;
}
if(GameServer()->Collision()->IsEnd(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && m_RaceState == RACE_STARTED)
else if((TileIndex == TILE_END) && m_RaceState == RACE_STARTED)
{
char aBuf[128];
if ((int)time / 60 != 0)
@ -648,18 +649,58 @@ void CCharacter::Tick()
if(strncmp(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
((CGameControllerDDRace*)GameServer()->m_pController)->m_Score.ParsePlayer(Server()->ClientName(m_pPlayer->GetCID()), (float)time);
}
if(GameServer()->Collision()->IsFreeze(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && !m_Super)
else if((TileIndex == TILE_FREEZE) && !m_Super)
{
Freeze(Server()->TickSpeed()*3);
}
if(GameServer()->Collision()->IsUnfreeze(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && !m_Super)
else if(TileIndex == TILE_UNFREEZE)
{
UnFreeze();
}
int booster = GameServer()->Collision()->IsBoost(GameServer()->Collision()->GetCollisionDDRace(TileIndex));
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
//
if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
else if ((TileIndex >= TILE_BOOST_L && TileIndex <= TILE_BOOST_U) || (TileIndex >= TILE_BOOST_L2 && TileIndex <= TILE_BOOST_U2))
{
int booster = TileIndex;
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
}
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPL)
{
if(m_Core.m_Vel.x > 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).x < (int)m_Core.m_Pos.x)
m_Core.m_Pos.x = m_PrevPos.x;
m_Core.m_Vel.x = 0;
}
}
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPR)
{
if(m_Core.m_Vel.x < 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).x > (int)m_Core.m_Pos.x)
m_Core.m_Pos.x = m_PrevPos.x;
m_Core.m_Vel.x = 0;
}
}
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPB)
{
if(m_Core.m_Vel.y < 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).y > (int)m_Core.m_Pos.y)
m_Core.m_Pos.y = m_PrevPos.y;
m_Core.m_Vel.y = 0;
}
}
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPT)
{
if(m_Core.m_Vel.y > 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).y < (int)m_Core.m_Pos.y)
m_Core.m_Pos.y = m_PrevPos.y;
if(m_Jumped&3 && m_Core.m_Jumped != m_Jumped) // check double jump
m_Core.m_Jumped = m_Jumped;
m_Core.m_Vel.y = 0;
}
}
else if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
{
vec2 Direction;
int Force;
@ -667,8 +708,7 @@ void CCharacter::Tick()
m_Core.m_Vel += Direction*Force;
}
int z = GameServer()->Collision()->IsTeleport(m_Pos.x, m_Pos.y);
if(z)
else if(z)
{
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;