Merge remote-tracking branch 'timakro/new_hookthrough'

This commit is contained in:
def 2016-04-27 18:59:51 +02:00
commit 67bff95a72
17 changed files with 221 additions and 216 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 KiB

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 KiB

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

After

Width:  |  Height:  |  Size: 232 KiB

View file

@ -576,10 +576,10 @@ void CPlayers::RenderPlayer(
}
int teleNr = 0;
Hit = Collision()->IntersectLineTeleHook(OldPos, NewPos, &finishPos, 0x0, &teleNr, true);
Hit = Collision()->IntersectLineTeleHook(OldPos, NewPos, &finishPos, 0x0, &teleNr);
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);
}

View file

@ -2118,7 +2118,7 @@ void CLocalProjectile::Tick(int CurrentTick, int GameTickSpeed, int LocalClientI
vec2 NewPos;
int Collide = 0;
if(m_pCollision)
Collide = m_pCollision->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos, false);
Collide = m_pCollision->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos);
int Target = m_pGameClient->IntersectCharacter(PrevPos, ColPos, m_Freeze ? 1.0f : 6.0f, &ColPos, m_Owner, m_pWorld);
bool isWeaponCollide = false;

View file

@ -108,59 +108,17 @@ void CCollision::Init(class CLayers *pLayers)
}
if(m_pFront)
{
// remove unused tiles from front layer
Index = m_pFront[i].m_Index;
if(Index <= TILE_NPH_START)
{
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:
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_THROUGH_DIR) || (Index >= TILE_OLDLASER && Index <= TILE_UNLOCK_TEAM) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START)))
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_UNLOCK_TEAM) || (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;
if(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:
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_THROUGH_DIR) || (Index >= TILE_OLDLASER && Index <= TILE_UNLOCK_TEAM) || (Index >= TILE_NPC_END && Index <= TILE_NPH_END) || (Index >= TILE_NPC_START && Index <= TILE_NPH_START)))
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_UNLOCK_TEAM) || (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)
{
m_pSwitchers = new SSwitchers[m_NumSwitchers+1];
@ -187,31 +145,18 @@ int CCollision::GetTile(int x, int y)
int Ny = clamp(y/32, 0, m_Height-1);
int pos = Ny * m_Width + Nx;
if(m_pTiles[pos].m_Index == COLFLAG_SOLID
|| m_pTiles[pos].m_Index == (COLFLAG_SOLID|COLFLAG_NOHOOK)
|| m_pTiles[pos].m_Index == COLFLAG_DEATH
|| m_pTiles[pos].m_Index == TILE_NOLASER)
if(m_pTiles[pos].m_Index >= TILE_SOLID && m_pTiles[pos].m_Index <= TILE_NOLASER)
return m_pTiles[pos].m_Index;
return 0;
}
/*
bool CCollision::IsTileSolid(int x, int y)
{
return GetTile(x, y)&COLFLAG_SOLID;
}
*/
// 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)
{
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
vec2 Last = Pos0;
int ix = 0, iy = 0; // Temporary position for checking collision
int dx = 0, dy = 0; // Offset for checking the "through" tile
if (AllowThrough)
{
ThroughOffset(Pos0, Pos1, &dx, &dy);
}
for(int i = 0; i <= End; i++)
{
float a = i/(float)End;
@ -219,7 +164,7 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p
ix = round_to_int(Pos.x);
iy = round_to_int(Pos.y);
if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))))
if(CheckPoint(ix, iy))
{
if(pOutCollision)
*pOutCollision = Pos;
@ -237,17 +182,14 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p
return 0;
}
int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough)
int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr)
{
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
vec2 Last = Pos0;
int ix = 0, iy = 0; // Temporary position for checking collision
int dx = 0, dy = 0; // Offset for checking the "through" tile
if (AllowThrough)
{
ThroughOffset(Pos0, Pos1, &dx, &dy);
}
for(int i = 0; i <= End; i++)
{
float a = i/(float)End;
@ -255,28 +197,37 @@ int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision,
ix = round_to_int(Pos.x);
iy = round_to_int(Pos.y);
int Nx = clamp(ix/32, 0, m_Width-1);
int Ny = clamp(iy/32, 0, m_Height-1);
int Index = GetPureMapIndex(Pos);
if (g_Config.m_SvOldTeleportHook)
*pTeleNr = IsTeleport(Ny*m_Width+Nx);
*pTeleNr = IsTeleport(Index);
else
*pTeleNr = IsTeleportHook(Ny*m_Width+Nx);
*pTeleNr = IsTeleportHook(Index);
if(*pTeleNr)
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return COLFLAG_TELE;
return TILE_TELEINHOOK;
}
if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))))
int hit = 0;
if(CheckPoint(ix, iy))
{
if(!IsThrough(ix, iy, dx, dy, Pos0, Pos1))
hit = GetCollisionAt(ix, iy);
}
else if(IsHookBlocker(ix, iy, Pos0, Pos1))
{
hit = TILE_NOHOOK;
}
if(hit)
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return GetCollisionAt(ix, iy);
return hit;
}
Last = Pos;
@ -288,17 +239,12 @@ int CCollision::IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision,
return 0;
}
int CCollision::IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough)
int CCollision::IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr)
{
float Distance = distance(Pos0, Pos1);
int End(Distance+1);
vec2 Last = Pos0;
int ix = 0, iy = 0; // Temporary position for checking collision
int dx = 0, dy = 0; // Offset for checking the "through" tile
if (AllowThrough)
{
ThroughOffset(Pos0, Pos1, &dx, &dy);
}
for(int i = 0; i <= End; i++)
{
float a = i/(float)End;
@ -306,22 +252,21 @@ int CCollision::IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollisio
ix = round_to_int(Pos.x);
iy = round_to_int(Pos.y);
int Nx = clamp(ix/32, 0, m_Width-1);
int Ny = clamp(iy/32, 0, m_Height-1);
int Index = GetPureMapIndex(Pos);
if (g_Config.m_SvOldTeleportWeapons)
*pTeleNr = IsTeleport(Ny*m_Width+Nx);
*pTeleNr = IsTeleport(Index);
else
*pTeleNr = IsTeleportWeapon(Ny*m_Width+Nx);
*pTeleNr = IsTeleportWeapon(Index);
if(*pTeleNr)
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return COLFLAG_TELE;
return TILE_TELEINWEAPON;
}
if((CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy))))
if(CheckPoint(ix, iy))
{
if(pOutCollision)
*pOutCollision = Pos;
@ -473,22 +418,45 @@ void CCollision::Dest()
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)
bool CCollision::IsThrough(int x, int y, int xoff, int yoff, vec2 pos0, vec2 pos1)
{
int Nx = clamp(x/32, 0, m_Width-1);
int Ny = clamp(y/32, 0, m_Height-1);
int Index = m_pTiles[Ny*m_Width+Nx].m_Index;
int Findex = 0;
if (m_pFront)
Findex = m_pFront[Ny*m_Width+Nx].m_Index;
if (Index == TILE_THROUGH)
return Index;
if (Findex == TILE_THROUGH)
return Findex;
return 0;
int pos = GetPureMapIndex(x, y);
if(m_pFront && (m_pFront[pos].m_Index == TILE_THROUGH_ALL || m_pFront[pos].m_Index == TILE_THROUGH_CUT))
return true;
if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && (
(m_pFront[pos].m_Flags == ROTATION_0 && pos0.y > pos1.y) ||
(m_pFront[pos].m_Flags == ROTATION_90 && pos0.x < pos1.x) ||
(m_pFront[pos].m_Flags == ROTATION_180 && pos0.y < pos1.y) ||
(m_pFront[pos].m_Flags == ROTATION_270 && pos0.x > pos1.x) ))
return true;
int offpos = GetPureMapIndex(x+xoff, y+yoff);
if(m_pTiles[offpos].m_Index == TILE_THROUGH || (m_pFront && m_pFront[offpos].m_Index == TILE_THROUGH))
return true;
return false;
}
bool CCollision::IsHookBlocker(int x, int y, vec2 pos0, vec2 pos1)
{
int pos = GetPureMapIndex(x, y);
if(m_pTiles[pos].m_Index == TILE_THROUGH_ALL || (m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_ALL))
return true;
if(m_pTiles[pos].m_Index == TILE_THROUGH_DIR && (
(m_pTiles[pos].m_Flags == ROTATION_0 && pos0.y < pos1.y) ||
(m_pTiles[pos].m_Flags == ROTATION_90 && pos0.x > pos1.x) ||
(m_pTiles[pos].m_Flags == ROTATION_180 && pos0.y > pos1.y) ||
(m_pTiles[pos].m_Flags == ROTATION_270 && pos0.x < pos1.x) ))
return true;
if(m_pFront && m_pFront[pos].m_Index == TILE_THROUGH_DIR && (
(m_pFront[pos].m_Flags == ROTATION_0 && pos0.y < pos1.y) ||
(m_pFront[pos].m_Flags == ROTATION_90 && pos0.x > pos1.x) ||
(m_pFront[pos].m_Flags == ROTATION_180 && pos0.y > pos1.y) ||
(m_pFront[pos].m_Flags == ROTATION_270 && pos0.x < pos1.x) ))
return true;
return false;
}
int CCollision::IsWallJump(int Index)
@ -712,10 +680,10 @@ vec2 CCollision::CpSpeed(int Index, int Flags)
return target;
}
int CCollision::GetPureMapIndex(vec2 Pos)
int CCollision::GetPureMapIndex(float x, float y)
{
int Nx = clamp((int)Pos.x/32, 0, m_Width-1);
int Ny = clamp((int)Pos.y/32, 0, m_Height-1);
int Nx = clamp((int)x/32, 0, m_Width-1);
int Ny = clamp((int)y/32, 0, m_Height-1);
return Ny*m_Width+Nx;
}
@ -899,14 +867,6 @@ int CCollision::GetIndex(int Nx, int Ny)
return m_pTiles[Ny*m_Width+Nx].m_Index;
}
int CCollision::GetIndex(vec2 Pos)
{
int nx = clamp((int)Pos.x/32, 0, m_Width-1);
int ny = clamp((int)Pos.y/32, 0, m_Height-1);
return ny*m_Width+nx;
}
int CCollision::GetIndex(vec2 PrevPos, vec2 Pos)
{
float Distance = distance(PrevPos, Pos);
@ -957,7 +917,7 @@ int CCollision::GetFTile(int x, int y)
int Nx = clamp(x/32, 0, m_Width-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 */
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)
return m_pFront[Ny*m_Width+Nx].m_Index;
else
@ -1015,12 +975,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 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)
@ -1100,8 +1060,8 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2
vec2 Pos = mix(Pos0, Pos1, a);
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);
if(GetIndex(Nx, Ny) == COLFLAG_SOLID
|| GetIndex(Nx, Ny) == (COLFLAG_SOLID|COLFLAG_NOHOOK)
if(GetIndex(Nx, Ny) == TILE_SOLID
|| GetIndex(Nx, Ny) == TILE_NOHOOK
|| GetIndex(Nx, Ny) == TILE_NOLASER
|| GetFIndex(Nx, Ny) == TILE_NOLASER)
{

View file

@ -15,21 +15,7 @@ class CCollision
int m_Height;
class CLayers *m_pLayers;
//bool IsTileSolid(int x, int y);
//int GetTile(int x, int y);
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();
void Init(class CLayers *pLayers);
bool CheckPoint(float x, float y) { return IsSolid(round_to_int(x), round_to_int(y)); }
@ -37,9 +23,9 @@ public:
int GetCollisionAt(float x, float y) { return GetTile(round_to_int(x), round_to_int(y)); }
int GetWidth() { return m_Width; };
int GetHeight() { return m_Height; };
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough);
int IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough);
int IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr, bool AllowThrough);
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
int IntersectLineTeleWeapon(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr);
int IntersectLineTeleHook(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, int *pTeleNr);
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *pBounces);
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
bool TestBox(vec2 Pos, vec2 Size);
@ -47,7 +33,7 @@ public:
// DDRace
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 SetDCollisionAt(float x, float y, int Type, int Flags, int Number);
int GetDTileIndex(int Index);
@ -58,14 +44,14 @@ public:
int IntersectNoLaserNW(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
int IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
int GetIndex(int x, int y);
int GetIndex(vec2 Pos);
int GetIndex(vec2 PrevPos, vec2 Pos);
int GetFIndex(int x, int y);
int GetTile(int x, int y);
int GetFTile(int x, int y);
int Entity(int x, int y, int Layer);
int GetPureMapIndex(vec2 Pos);
int GetPureMapIndex(float x, float y);
int GetPureMapIndex(vec2 Pos) { return GetPureMapIndex(Pos.x, Pos.y); }
std::list<int> GetMapIndices(vec2 PrevPos, vec2 Pos, unsigned MaxIndices = 0);
int GetMapIndex(vec2 Pos);
bool TileExists(int Index);
@ -82,7 +68,6 @@ public:
int IsTeleportWeapon(int Index);
int IsTeleportHook(int Index);
int IsTCheckpoint(int Index);
//int IsCheckpoint(int Index);
int IsSpeedup(int Index);
int IsTune(int Index);
void GetSpeedup(int Index, vec2 *Dir, int *Force, int *MaxSpeed);
@ -91,7 +76,8 @@ public:
int GetSwitchDelay(int Index);
int IsSolid(int x, int y);
int IsThrough(int x, int y);
bool IsThrough(int x, int y, int xoff, int yoff, vec2 pos0, vec2 pos1);
bool IsHookBlocker(int x, int y, vec2 pos0, vec2 pos1);
int IsWallJump(int Index);
int IsNoLaser(int x, int y);
int IsFNoLaser(int x, int y);

View file

@ -507,6 +507,9 @@ public:
CLayerTiles(int w, int h);
~CLayerTiles();
virtual CTile GetTile(int x, int y, bool force=false);
virtual void SetTile(int x, int y, CTile tile, bool force=false);
virtual void Resize(int NewW, int NewH);
virtual void Shift(int Direction);
@ -590,6 +593,9 @@ public:
CLayerGame(int w, int h);
~CLayerGame();
virtual CTile GetTile(int x, int y, bool force=false);
virtual void SetTile(int x, int y, CTile tile, bool force=false);
virtual int RenderProperties(CUIRect *pToolbox);
};
@ -1080,6 +1086,8 @@ public:
virtual void Resize(int NewW, int NewH);
virtual void Shift(int Direction);
virtual CTile GetTile(int x, int y, bool force=false);
virtual void SetTile(int x, int y, CTile tile, bool force=false);
virtual void BrushDraw(CLayer *pBrush, float wx, float wy);
};

View file

@ -14,6 +14,38 @@ CLayerGame::~CLayerGame()
{
}
CTile CLayerGame::GetTile(int x, int y, bool force)
{
if(!force && m_pEditor->m_Map.m_pFrontLayer && GetTile(x, y, true).m_Index == TILE_NOHOOK && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT)
{
CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0};
return throughcut;
} else {
return m_pTiles[y*m_Width+x];
}
}
void CLayerGame::SetTile(int x, int y, CTile tile, bool force)
{
if(!force && tile.m_Index == TILE_THROUGH_CUT) {
if(!m_pEditor->m_Map.m_pFrontLayer) {
CLayer *l = new CLayerFront(m_Width, m_Height);
m_pEditor->m_Map.MakeFrontLayer(l);
m_pEditor->m_Map.m_lGroups[m_pEditor->m_SelectedGroup]->AddLayer(l);
}
CTile nohook = {TILE_NOHOOK, 0, 0, 0};
SetTile(x, y, nohook, true);
CTile throughcut = {TILE_THROUGH_CUT, 0, 0, 0};
m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, throughcut, true);
} else {
if(!force && m_pEditor->m_Map.m_pFrontLayer && m_pEditor->m_Map.m_pFrontLayer->GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) {
CTile air = {TILE_AIR, 0, 0, 0};
m_pEditor->m_Map.m_pFrontLayer->SetTile(x, y, air, true);
}
m_pTiles[y*m_Width+x] = tile;
}
}
int CLayerGame::RenderProperties(CUIRect *pToolbox)
{
int r = CLayerTiles::RenderProperties(pToolbox);

View file

@ -46,6 +46,16 @@ CLayerTiles::~CLayerTiles()
delete [] m_pTiles;
}
CTile CLayerTiles::GetTile(int x, int y, bool force)
{
return m_pTiles[y*m_Width+x];
}
void CLayerTiles::SetTile(int x, int y, CTile tile, bool force)
{
m_pTiles[y*m_Width+x] = tile;
}
void CLayerTiles::PrepareForSave()
{
for(int y = 0; y < m_Height; y++)
@ -175,7 +185,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
// copy the tiles
for(int y = 0; y < r.h; y++)
for(int x = 0; x < r.w; x++)
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
// copy the tele data
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
@ -202,7 +212,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
// copy the tiles
for(int y = 0; y < r.h; y++)
for(int x = 0; x < r.w; x++)
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
// copy the speedup data
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
@ -235,7 +245,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
// copy the tiles
for(int y = 0; y < r.h; y++)
for(int x = 0; x < r.w; x++)
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
// copy the switch data
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
@ -266,7 +276,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
// copy the tiles
for(int y = 0; y < r.h; y++)
for(int x = 0; x < r.w; x++)
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
// copy the tiles
if(!m_pEditor->Input()->KeyPressed(KEY_SPACE))
@ -294,7 +304,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
// copy the tiles
for(int y = 0; y < r.h; y++)
for(int x = 0; x < r.w; x++)
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
}
else
@ -309,7 +319,7 @@ int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)
// copy the tiles
for(int y = 0; y < r.h; y++)
for(int x = 0; x < r.w; x++)
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = m_pTiles[(r.y+y)*m_Width+(r.x+x)];
pGrabbed->m_pTiles[y*pGrabbed->m_Width+x] = GetTile(r.x+x, r.y+y);
str_copy(pGrabbed->m_aFileName, m_pEditor->m_aFileName, sizeof(pGrabbed->m_aFileName));
}
@ -343,7 +353,7 @@ void CLayerTiles::FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect)
if(Empty)
m_pTiles[fy*m_Width+fx].m_Index = 1;
else
m_pTiles[fy*m_Width+fx] = pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)];
SetTile(fx, fy, pLt->m_pTiles[(y*pLt->m_Width + x%pLt->m_Width) % (pLt->m_Width*pLt->m_Height)]);
}
}
m_pEditor->m_Map.m_Modified = true;
@ -367,7 +377,7 @@ void CLayerTiles::BrushDraw(CLayer *pBrush, float wx, float wy)
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
continue;
m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
SetTile(fx, fy, l->m_pTiles[y*l->m_Width+x]);
}
m_pEditor->m_Map.m_Modified = true;
}
@ -1290,6 +1300,22 @@ CLayerFront::CLayerFront(int w, int h)
m_Front = 1;
}
CTile CLayerFront::GetTile(int x, int y, bool force)
{
if(!force && GetTile(x, y, true).m_Index == TILE_THROUGH_CUT) {
CTile air = {TILE_AIR, 0, 0, 0};
return air;
} else {
return m_pTiles[y*m_Width+x];
}
}
void CLayerFront::SetTile(int x, int y, CTile tile, bool force)
{
if(force || (GetTile(x, y, true).m_Index != TILE_THROUGH_CUT && tile.m_Index != TILE_THROUGH_CUT))
m_pTiles[y*m_Width+x] = tile;
}
void CLayerFront::Resize(int NewW, int NewH)
{
// resize tile data
@ -1323,7 +1349,7 @@ void CLayerFront::BrushDraw(CLayer *pBrush, float wx, float wy)
if(fx<0 || fx >= m_Width || fy < 0 || fy >= m_Height)
continue;
m_pTiles[fy*m_Width+fx] = l->m_pTiles[y*l->m_Width+x];
SetTile(fx, fy, l->m_pTiles[y*l->m_Width+x]);
}
m_pEditor->m_Map.m_Modified = true;
}

View file

@ -273,15 +273,15 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient)
bool GoingToRetract = false;
bool GoingThroughTele = false;
int teleNr = 0;
int Hit = m_pCollision->IntersectLineTeleHook(m_HookPos, NewPos, &NewPos, 0, &teleNr, true);
int Hit = m_pCollision->IntersectLineTeleHook(m_HookPos, NewPos, &NewPos, 0, &teleNr);
//m_NewHook = false;
if(Hit)
{
if(Hit&CCollision::COLFLAG_NOHOOK)
if(Hit == TILE_NOHOOK)
GoingToRetract = true;
else if (Hit&CCollision::COLFLAG_TELE)
else if (Hit == TILE_TELEINHOOK)
GoingThroughTele = true;
else
GoingToHitGround = true;

View file

@ -97,7 +97,8 @@ enum
TILE_DEATH,
TILE_NOHOOK,
TILE_NOLASER,
TILE_THROUGH = 6,
TILE_THROUGH_CUT,
TILE_THROUGH,
TILE_JUMP,
TILE_FREEZE = 9,
TILE_TELEINEVIL,
@ -130,10 +131,12 @@ enum
TILE_STOP = 60,
TILE_STOPS,
TILE_STOPA,
TILE_TELECHECKINEVIL = 63,
TILE_CP = 64,
TILE_TELECHECKINEVIL,
TILE_CP,
TILE_CP_F,
TILE_TUNE1 = 68,
TILE_THROUGH_ALL,
TILE_THROUGH_DIR,
TILE_TUNE1,
TILE_OLDLASER = 71,
TILE_NPC,
TILE_EHOOK,

View file

@ -742,16 +742,6 @@ void CCharacter::Tick()
m_Core.m_Input = m_Input;
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
HandleWeapons();
@ -1237,13 +1227,13 @@ void CCharacter::HandleBroadcast()
void CCharacter::HandleSkippableTiles(int Index)
{
// 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()->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)&CCollision::COLFLAG_DEATH ||
GameServer()->Collision()->GetFCollisionAt(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) &&
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) == TILE_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) == TILE_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) == TILE_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())))
{
Die(m_pPlayer->GetCID(), WEAPON_WORLD);

View file

@ -48,7 +48,7 @@ void CGun::Fire()
continue;
if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[Target->Team()])
continue;
int res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0,false);
int res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0);
if (!res)
{
int Len = length(Target->m_Pos - m_Pos);
@ -75,7 +75,7 @@ void CGun::Fire()
{
if (IdInTeam[Target->Team()] != i)
{
int res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0,false);
int res = GameServer()->Collision()->IntersectLine(m_Pos, Target->m_Pos,0,0);
if (!res)
{
new CPlasma(&GameServer()->m_World, m_Pos, normalize(Target->m_Pos - m_Pos), m_Freeze, m_Explosive, Target->Team());

View file

@ -99,7 +99,7 @@ void CLaser::DoBounce()
vec2 To = m_Pos + m_Dir * m_Energy;
Res = GameServer()->Collision()->IntersectLineTeleWeapon(m_Pos, To, &Coltile, &To, &z, false);
Res = GameServer()->Collision()->IntersectLineTeleWeapon(m_Pos, To, &Coltile, &To, &z);
if(Res)
{
@ -116,7 +116,7 @@ void CLaser::DoBounce()
if(Res == -1)
{
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);
if(Res == -1)
@ -131,7 +131,7 @@ void CLaser::DoBounce()
else
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();
m_TelePos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts[z-1][(!Num)?Num:rand() % Num];

View file

@ -114,7 +114,7 @@ void CProjectile::Tick()
vec2 CurPos = GetPos(Ct);
vec2 ColPos;
vec2 NewPos;
int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos, false);
int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos);
CCharacter *pOwnerChar = 0;
if(m_Owner >= 0)