remove colflags

This commit is contained in:
timgame 2015-11-08 10:20:10 +01:00
parent d99660f20e
commit 988a8f591a
8 changed files with 31 additions and 105 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 KiB

After

Width:  |  Height:  |  Size: 293 KiB

View file

@ -583,7 +583,7 @@ void CPlayers::RenderPlayer(
Hit = Collision()->IntersectLineTeleHook(OldPos, NewPos, &finishPos, 0x0, &teleNr, true); Hit = Collision()->IntersectLineTeleHook(OldPos, NewPos, &finishPos, 0x0, &teleNr, true);
if(!doBreak && Hit) { if(!doBreak && Hit) {
if (!(Hit&CCollision::COLFLAG_NOHOOK)) if (Hit != TILE_NOHOOK)
Graphics()->SetColor(130.0f/255.0f, 232.0f/255.0f, 160.0f/255.0f, Alpha); Graphics()->SetColor(130.0f/255.0f, 232.0f/255.0f, 160.0f/255.0f, Alpha);
} }

View file

@ -108,59 +108,17 @@ void CCollision::Init(class CLayers *pLayers)
} }
if(m_pFront) if(m_pFront)
{ {
// remove unused tiles from front layer
Index = m_pFront[i].m_Index; Index = m_pFront[i].m_Index;
if(Index <= TILE_NPH_START && !(Index == TILE_DEATH || Index == TILE_NOLASER || Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START)))
if(Index <= TILE_NPH_START) m_pFront[i].m_Index = 0;
{
switch(Index)
{
case TILE_DEATH:
m_pFront[i].m_Index = COLFLAG_DEATH;
break;
case TILE_SOLID:
m_pFront[i].m_Index = 0;
break;
case TILE_NOHOOK:
m_pFront[i].m_Index = 0;
break;
case TILE_NOLASER:
m_pFront[i].m_Index = TILE_NOLASER;
break;
default:
m_pFront[i].m_Index = 0;
}
// DDRace tiles
if(Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START))
m_pFront[i].m_Index = Index;
}
} }
// remove unused tiles from game layer
Index = m_pTiles[i].m_Index; Index = m_pTiles[i].m_Index;
if(Index <= TILE_NPH_START) if(Index <= TILE_NPH_START && !((Index >= TILE_SOLID && Index <= TILE_NOLASER) || Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START)))
{
switch(Index)
{
case TILE_DEATH:
m_pTiles[i].m_Index = COLFLAG_DEATH;
break;
case TILE_SOLID:
m_pTiles[i].m_Index = COLFLAG_SOLID;
break;
case TILE_NOHOOK:
m_pTiles[i].m_Index = COLFLAG_SOLID|COLFLAG_NOHOOK;
break;
case TILE_NOLASER:
m_pTiles[i].m_Index = TILE_NOLASER;
break;
default:
m_pTiles[i].m_Index = 0; m_pTiles[i].m_Index = 0;
}
// DDRace tiles
if(Index == TILE_THROUGH || Index == TILE_FREEZE || (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) || (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_END) || (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) || Index == TILE_CP || Index == TILE_CP_F || (Index >= TILE_OLDLASER && Index <= TILE_NPH) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START))
m_pTiles[i].m_Index = Index;
}
} }
if(m_NumSwitchers) if(m_NumSwitchers)
{ {
m_pSwitchers = new SSwitchers[m_NumSwitchers+1]; m_pSwitchers = new SSwitchers[m_NumSwitchers+1];
@ -187,19 +145,11 @@ int CCollision::GetTile(int x, int y)
int Ny = clamp(y/32, 0, m_Height-1); int Ny = clamp(y/32, 0, m_Height-1);
int pos = Ny * m_Width + Nx; int pos = Ny * m_Width + Nx;
if(m_pTiles[pos].m_Index == COLFLAG_SOLID if(m_pTiles[pos].m_Index >= TILE_SOLID && m_pTiles[pos].m_Index <= TILE_NOLASER)
|| m_pTiles[pos].m_Index == (COLFLAG_SOLID|COLFLAG_NOHOOK)
|| m_pTiles[pos].m_Index == COLFLAG_DEATH
|| m_pTiles[pos].m_Index == TILE_NOLASER)
return m_pTiles[pos].m_Index; return m_pTiles[pos].m_Index;
return 0; return 0;
} }
/*
bool CCollision::IsTileSolid(int x, int y)
{
return GetTile(x, y)&COLFLAG_SOLID;
}
*/
// TODO: rewrite this smarter! // TODO: rewrite this smarter!
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough) int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough)
{ {
@ -267,7 +217,7 @@ int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision,
*pOutCollision = Pos; *pOutCollision = Pos;
if(pOutBeforeCollision) if(pOutBeforeCollision)
*pOutBeforeCollision = Last; *pOutBeforeCollision = Last;
return COLFLAG_TELE; return TILE_TELEINHOOK;
} }
if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy)))) if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))))
@ -318,7 +268,7 @@ int CCollision::IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollisio
*pOutCollision = Pos; *pOutCollision = Pos;
if(pOutBeforeCollision) if(pOutBeforeCollision)
*pOutBeforeCollision = Last; *pOutBeforeCollision = Last;
return COLFLAG_TELE; return TILE_TELEINWEAPON;
} }
if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy)))) if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))))
@ -473,7 +423,8 @@ void CCollision::Dest()
int CCollision::IsSolid(int x, int y) int CCollision::IsSolid(int x, int y)
{ {
return (GetTile(x,y)&COLFLAG_SOLID); int index = GetTile(x,y);
return index == TILE_SOLID || index == TILE_NOHOOK;
} }
int CCollision::IsThrough(int x, int y) int CCollision::IsThrough(int x, int y)
@ -957,7 +908,7 @@ int CCollision::GetFTile(int x, int y)
int Nx = clamp(x/32, 0, m_Width-1); int Nx = clamp(x/32, 0, m_Width-1);
int Ny = clamp(y/32, 0, m_Height-1); int Ny = clamp(y/32, 0, m_Height-1);
/*dbg_msg("GetFTile","m_Index %d",m_pFront[Ny*m_Width+Nx].m_Index);//Remove */ /*dbg_msg("GetFTile","m_Index %d",m_pFront[Ny*m_Width+Nx].m_Index);//Remove */
if(m_pFront[Ny*m_Width+Nx].m_Index == COLFLAG_DEATH if(m_pFront[Ny*m_Width+Nx].m_Index == TILE_DEATH
|| m_pFront[Ny*m_Width+Nx].m_Index == TILE_NOLASER) || m_pFront[Ny*m_Width+Nx].m_Index == TILE_NOLASER)
return m_pFront[Ny*m_Width+Nx].m_Index; return m_pFront[Ny*m_Width+Nx].m_Index;
else else
@ -1015,12 +966,12 @@ int CCollision::Entity(int x, int y, int Layer)
} }
} }
void CCollision::SetCollisionAt(float x, float y, int flag) void CCollision::SetCollisionAt(float x, float y, int id)
{ {
int Nx = clamp(round_to_int(x)/32, 0, m_Width-1); int Nx = clamp(round_to_int(x)/32, 0, m_Width-1);
int Ny = clamp(round_to_int(y)/32, 0, m_Height-1); int Ny = clamp(round_to_int(y)/32, 0, m_Height-1);
m_pTiles[Ny * m_Width + Nx].m_Index = flag; m_pTiles[Ny * m_Width + Nx].m_Index = id;
} }
void CCollision::SetDCollisionAt(float x, float y, int Type, int Flags, int Number) void CCollision::SetDCollisionAt(float x, float y, int Type, int Flags, int Number)
@ -1100,8 +1051,8 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2
vec2 Pos = mix(Pos0, Pos1, a); vec2 Pos = mix(Pos0, Pos1, a);
int Nx = clamp(round_to_int(Pos.x)/32, 0, m_Width-1); int Nx = clamp(round_to_int(Pos.x)/32, 0, m_Width-1);
int Ny = clamp(round_to_int(Pos.y)/32, 0, m_Height-1); int Ny = clamp(round_to_int(Pos.y)/32, 0, m_Height-1);
if(GetIndex(Nx, Ny) == COLFLAG_SOLID if(GetIndex(Nx, Ny) == TILE_SOLID
|| GetIndex(Nx, Ny) == (COLFLAG_SOLID|COLFLAG_NOHOOK) || GetIndex(Nx, Ny) == TILE_NOHOOK
|| GetIndex(Nx, Ny) == TILE_NOLASER || GetIndex(Nx, Ny) == TILE_NOLASER
|| GetFIndex(Nx, Ny) == TILE_NOLASER) || GetFIndex(Nx, Ny) == TILE_NOLASER)
{ {

View file

@ -15,21 +15,7 @@ class CCollision
int m_Height; int m_Height;
class CLayers *m_pLayers; class CLayers *m_pLayers;
//bool IsTileSolid(int x, int y);
//int GetTile(int x, int y);
public: public:
enum
{
COLFLAG_SOLID=1,
COLFLAG_DEATH=2,
COLFLAG_NOHOOK=4,
// DDRace
//COLFLAG_NOLASER=8, // Unused, now used for TimedSwitchActivation
//COLFLAG_THROUGH=16, // Unused, now used for WallJump
COLFLAG_TELE=32
};
CCollision(); CCollision();
void Init(class CLayers *pLayers); void Init(class CLayers *pLayers);
bool CheckPoint(float x, float y) { return IsSolid(round_to_int(x), round_to_int(y)); } bool CheckPoint(float x, float y) { return IsSolid(round_to_int(x), round_to_int(y)); }
@ -47,7 +33,7 @@ public:
// DDRace // DDRace
void Dest(); void Dest();
void SetCollisionAt(float x, float y, int Flag); void SetCollisionAt(float x, float y, int id);
void SetDTile(float x, float y, bool State); void SetDTile(float x, float y, bool State);
void SetDCollisionAt(float x, float y, int Type, int Flags, int Number); void SetDCollisionAt(float x, float y, int Type, int Flags, int Number);
int GetDTileIndex(int Index); int GetDTileIndex(int Index);
@ -82,7 +68,6 @@ public:
int IsTeleportWeapon(int Index); int IsTeleportWeapon(int Index);
int IsTeleportHook(int Index); int IsTeleportHook(int Index);
int IsTCheckpoint(int Index); int IsTCheckpoint(int Index);
//int IsCheckpoint(int Index);
int IsSpeedup(int Index); int IsSpeedup(int Index);
int IsTune(int Index); int IsTune(int Index);
void GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed); void GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed);

View file

@ -279,9 +279,9 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
if(Hit) if(Hit)
{ {
if(Hit&CCollision::COLFLAG_NOHOOK) if(Hit == TILE_NOHOOK)
GoingToRetract = true; GoingToRetract = true;
else if (Hit&CCollision::COLFLAG_TELE) else if (Hit == TILE_TELEINHOOK)
GoingThroughTele = true; GoingThroughTele = true;
else else
GoingToHitGround = true; GoingToHitGround = true;

View file

@ -742,16 +742,6 @@ void CCharacter::Tick()
m_Core.m_Input = m_Input; m_Core.m_Input = m_Input;
m_Core.Tick(true, false); m_Core.Tick(true, false);
/*// handle death-tiles and leaving gamelayer
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 ||
GameLayerClipped(m_Pos))
{
Die(m_pPlayer->GetCID(), WEAPON_WORLD);
}*/
// handle Weapons // handle Weapons
HandleWeapons(); HandleWeapons();
@ -1239,13 +1229,13 @@ void CCharacter::HandleBroadcast()
void CCharacter::HandleSkippableTiles(int Index) void CCharacter::HandleSkippableTiles(int Index)
{ {
// handle death-tiles and leaving gamelayer // handle death-tiles and leaving gamelayer
if((GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || if((GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f) == TILE_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) == TILE_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) == TILE_DEATH ||
GameServer()->Collision()->GetFCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetFCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f) == TILE_DEATH||
GameServer()->Collision()->GetFCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetFCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f) == TILE_DEATH ||
GameServer()->Collision()->GetFCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || GameServer()->Collision()->GetFCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f) == TILE_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) == TILE_DEATH) &&
!m_Super && !(Team() && Teams()->TeeFinished(m_pPlayer->GetCID()))) !m_Super && !(Team() && Teams()->TeeFinished(m_pPlayer->GetCID())))
{ {
Die(m_pPlayer->GetCID(), WEAPON_WORLD); Die(m_pPlayer->GetCID(), WEAPON_WORLD);

View file

@ -116,7 +116,7 @@ void CLaser::DoBounce()
if(Res == -1) if(Res == -1)
{ {
f = GameServer()->Collision()->GetTile(round_to_int(Coltile.x), round_to_int(Coltile.y)); f = GameServer()->Collision()->GetTile(round_to_int(Coltile.x), round_to_int(Coltile.y));
GameServer()->Collision()->SetCollisionAt(round_to_int(Coltile.x), round_to_int(Coltile.y), CCollision::COLFLAG_SOLID); GameServer()->Collision()->SetCollisionAt(round_to_int(Coltile.x), round_to_int(Coltile.y), TILE_SOLID);
} }
GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0); GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0);
if(Res == -1) if(Res == -1)
@ -131,7 +131,7 @@ void CLaser::DoBounce()
else else
m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost; m_Energy -= distance(m_From, m_Pos) + GameServer()->TuningList()[m_TuneZone].m_LaserBounceCost;
if (Res&CCollision::COLFLAG_TELE && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size()) if (Res == TILE_TELEINWEAPON && ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size())
{ {
int Num = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size(); int Num = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1].size();
m_TelePos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1][(!Num)?Num:rand() % Num]; m_TelePos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1][(!Num)?Num:rand() % Num];

View file

@ -156,7 +156,7 @@ void CGameControllerCTF::Tick()
continue; continue;
// flag hits death-tile or left the game layer, reset it // flag hits death-tile or left the game layer, reset it
if(GameServer()->Collision()->GetCollisionAt(F->m_Pos.x, F->m_Pos.y)&CCollision::COLFLAG_DEATH || F->GameLayerClipped(F->m_Pos)) if(GameServer()->Collision()->GetCollisionAt(F->m_Pos.x, F->m_Pos.y) == TILE_DEATH || F->GameLayerClipped(F->m_Pos))
{ {
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "flag_return"); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", "flag_return");
GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN); GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);