too many stuff to write but the idea is to implement the telelayer&speed thnx to Redix and Sushi Tee

also FrontLayer is ready to be implemented soon

Signed-off-by: GreYFoXGTi <GreYFoXGTi@Gmail.com>
This commit is contained in:
GreYFoXGTi 2010-08-10 07:28:17 +03:00
parent 60b5acbb15
commit 20930ce68b
19 changed files with 518 additions and 530 deletions

View file

@ -7,6 +7,7 @@
//===============================
/* DDRace */
//MACRO_CONFIG_STR(SvEntities, sv_entities, 64, "Latest", CFGFLAG_SERVER, "The type of entities used") still need to think of a way
MACRO_CONFIG_INT(SvReconnectTime,sv_reconnect_time,5,0,9999,CFGFLAG_SERVER,"how much time between leaves and joins")
MACRO_CONFIG_INT(SvVoteKickTimeDelay,sv_vote_kick_delay,0,0,9999,CFGFLAG_SERVER,"how much time between kick votes")
MACRO_CONFIG_INT(SvVoteKickBanTime,sv_vote_kick_bantime, 300, 0, 9999, CFGFLAG_SERVER," ")

View file

@ -14,11 +14,12 @@
CCollision::CCollision()
{
m_pTiles = 0;
m_pFTiles = 0;
m_Width = 0;
m_Height = 0;
m_pLayers = 0;
isOneLayer = false;
m_pTele = 0;
m_pSpeedup = 0;
m_pFront = 0;
}
int CCollision::IsSolid(int x, int y)
{
@ -31,50 +32,18 @@ void CCollision::Init(class CLayers *pLayers)
m_Width = m_pLayers->GameLayer()->m_Width;
m_Height = m_pLayers->GameLayer()->m_Height;
m_pTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->GameLayer()->m_Data));
if(m_pLayers->FGameLayer() != 0) {
m_pFTiles = static_cast<CTile *>(m_pLayers->Map()->GetData(m_pLayers->FGameLayer()->m_Data));
isOneLayer = false;
} else {
m_pFTiles = 0;
isOneLayer = true;
}
//DDRace
mem_zero(&m_Len, sizeof(m_Len));
mem_zero(&m_Tele, sizeof(m_Tele));
m_pTeleporter = new int[m_Width * m_Height];
m_pFTeleporter = new int[m_Width * m_Height];
for(int i = m_Width * m_Height - 1; i >= 0; i--)
{
if(m_pTiles[i].m_Index > 34 && m_pTiles[i].m_Index < 190)
{
if(m_pTiles[i].m_Index & 1)
m_Len[m_pTiles[i].m_Index >> 1]++;
else if(!(m_pTiles[i].m_Index & 1))
m_Tele[(m_pTiles[i].m_Index - 1) >> 1]++;
}
}
for(int i = 0; i < 95; i++)
{
m_pDest[i] = new int[m_Len[i]];
m_Len[i] = 0;
}
for(int i = m_Width * m_Height - 1; i >= 0; i--)
{
if(m_pTiles[i].m_Index & 1 && m_pTiles[i].m_Index > 34 && m_pTiles[i].m_Index < 190)
m_pDest[m_pTiles[i].m_Index >> 1][m_Len[m_pTiles[i].m_Index >> 1]++] = i;
}
if(m_pLayers->TeleLayer())
m_pTele = static_cast<CTeleTile *>(m_pLayers->Map()->GetData(m_pLayers->TeleLayer()->m_Tele));
if(m_pLayers->SpeedupLayer())
m_pSpeedup = static_cast<CSpeedupTile *>(m_pLayers->Map()->GetData(m_pLayers->SpeedupLayer()->m_Speedup));
if(m_pLayers->FrontLayer())
m_pFront = static_cast<CFrontTile *>(m_pLayers->Map()->GetData(m_pLayers->FrontLayer()->m_Front));
for(int i = 0; i < m_Width*m_Height; i++)
{
int Index = m_pTiles[i].m_Index;
int FIndex = 0;
if(!isOneLayer)
FIndex = m_pFTiles[i].m_Index;
//if (FIndex!=0)
// dbg_msg ("flayer", "tile found at (%d, %d)",(i - (i/ m_Width) * m_Width) ,(i / m_Width));
if(Index > 190)
if(Index > 191)
continue;
switch(Index)
@ -93,31 +62,93 @@ void CCollision::Init(class CLayers *pLayers)
break;
default:
m_pTiles[i].m_Index = 0;
m_pTeleporter[i] = Index;
}
m_pFTeleporter[i] = FIndex;
// DDRace tiles
if(Index >= 5 && Index <= 59 || Index>=64 && Index<=191)
m_pTiles[i].m_Index = Index;
}
}
int CCollision::GetIndex(int x, int y, bool flayer) {
CTile *tiles = (flayer) ? m_pFTiles: m_pTiles;
int index = tiles[y*m_Width+x].m_Index;
return index-ENTITY_OFFSET;
}
int CCollision::GetIndex(vec2 PrevPos, vec2 Pos)
{
int Index = 0;
float d = distance(PrevPos, Pos);
if(!d)
{
int nx = clamp((int)Pos.x/32, 0, m_Width-1);
int ny = clamp((int)Pos.y/32, 0, m_Height-1);
if (m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN)) dbg_msg("m_pTele && TELEIN","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE
else if (m_pTele && m_pTele[ny*m_Width+nx].m_Type==TILE_TELEOUT) dbg_msg("TELEOUT","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE
else dbg_msg("GetIndex","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_BOOSTV && m_pTiles[ny*m_Width+nx].m_Index <= TILE_STOPT) ||
((m_pTiles[ny*m_Width+nx].m_Index >=TILE_STOPV)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
{
return ny*m_Width+nx;
}
}
float a = 0.0f;
vec2 Tmp = vec2(0, 0);
int nx = 0;
int ny = 0;
for(float f = 0; f < d; f++)
{
a = f/d;
Tmp = mix(PrevPos, Pos, a);
nx = clamp((int)Tmp.x/32, 0, m_Width-1);
ny = clamp((int)Tmp.y/32, 0, m_Height-1);
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_BOOSTV && m_pTiles[ny*m_Width+nx].m_Index <= TILE_STOPT) ||
((m_pTiles[ny*m_Width+nx].m_Index >=TILE_STOPV)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
(m_pTele && (m_pTele[ny*m_Width+nx].m_Type == TILE_TELEIN || m_pTele[ny*m_Width+nx].m_Type == TILE_TELEOUT)) ||
(m_pSpeedup && m_pSpeedup[ny*m_Width+nx].m_Force > 0))
{
return ny*m_Width+nx;
}
}
return -1;
}
vec2 CCollision::GetPos(int Index)
{
int x = Index%m_Width;
int y = Index/m_Width;
return vec2(x, y);
}
int CCollision::GetCollisionDDRace(int Index)
{
if(Index < 0)
return 0;
//dbg_msg("GetCollisionDDRace","m_pTiles[%d].m_Index = %d",Index,m_pTiles[Index].m_Index);//Remove
return m_pTiles[Index].m_Index;
}
int CCollision::GetTile(int x, int y)
{
int nx = clamp(x/32, 0, m_Width-1);
int ny = clamp(y/32, 0, m_Height-1);
return m_pTiles[ny*m_Width+nx].m_Index > 128 ? 0 : m_pTiles[ny*m_Width+nx].m_Index;
//dbg_msg("GetTile","m_Index %d",m_pTiles[ny*m_Width+nx].m_Index);
if(m_pTiles[ny*m_Width+nx].m_Index == COLFLAG_SOLID || m_pTiles[ny*m_Width+nx].m_Index == (COLFLAG_SOLID|COLFLAG_NOHOOK) || m_pTiles[ny*m_Width+nx].m_Index == COLFLAG_DEATH)
return m_pTiles[ny*m_Width+nx].m_Index;
else
return 0;
}
bool CCollision::IsTileSolid(int x, int y)
{
return (GetTile(x,y)&COLFLAG_SOLID);
}
void CCollision::SetCollisionAt(float x, float y, int flag)
{
int nx = clamp(round(x)/32, 0, m_Width-1);
int ny = clamp(round(y)/32, 0, m_Height-1);
m_pTiles[ny * m_Width + nx].m_Index = flag;
}
// TODO: rewrite this smarter!
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
@ -145,6 +176,61 @@ int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *p
*pOutBeforeCollision = Pos1;
return 0;
}
int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 Pos = mix(Pos0, Pos1, a);
if(IsSolid(round(Pos.x), round(Pos.y)) || IsNoLaser(round(Pos.x), round(Pos.y)))
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return GetCollisionAt(Pos.x, Pos.y);
}
Last = Pos;
}
if(pOutCollision)
*pOutCollision = Pos1;
if(pOutBeforeCollision)
*pOutBeforeCollision = Pos1;
return 0;
}
int CCollision::IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
{
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 Pos = mix(Pos0, Pos1, a);
if(IsSolid(round(Pos.x), round(Pos.y)) || !GetTile(round(Pos.x), round(Pos.y)))
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
if(!GetTile(round(Pos.x), round(Pos.y)))
return -1;
else
return GetTile(round(Pos.x), round(Pos.y));
}
Last = Pos;
}
if(pOutCollision)
*pOutCollision = Pos1;
if(pOutBeforeCollision)
*pOutBeforeCollision = Pos1;
return 0;
}
// TODO: OPT: rewrite this smarter!
void CCollision::MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *pBounces)
@ -185,20 +271,6 @@ void CCollision::MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, i
}
}
bool CCollision::TestBox(vec2 Pos, vec2 Size)
{
Size *= 0.5f;
if(CheckPoint(Pos.x-Size.x, Pos.y-Size.y))
return true;
if(CheckPoint(Pos.x+Size.x, Pos.y-Size.y))
return true;
if(CheckPoint(Pos.x-Size.x, Pos.y+Size.y))
return true;
if(CheckPoint(Pos.x+Size.x, Pos.y+Size.y))
return true;
return false;
}
void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity)
{
// do the move
@ -257,101 +329,122 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
*pInoutVel = Vel;
}
int CCollision::IsNolaser(int x, int y)
bool CCollision::TestBox(vec2 Pos, vec2 Size)
{
Size *= 0.5f;
if(CheckPoint(Pos.x-Size.x, Pos.y-Size.y))
return true;
if(CheckPoint(Pos.x+Size.x, Pos.y-Size.y))
return true;
if(CheckPoint(Pos.x-Size.x, Pos.y+Size.y))
return true;
if(CheckPoint(Pos.x+Size.x, Pos.y+Size.y))
return true;
return false;
}
int CCollision::IsNoLaser(int x, int y)
{
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);
}
//DDRace
int CCollision::IsTeleport(int x, int y)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
int z = m_pTeleporter[ny * m_Width + nx]-1;
if(z > 34 && z < 190 && z & 1)
return z >> 1;
return 0;
}
int CCollision::IsBegin(int x, int y)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
return m_pTeleporter[ny*m_Width+nx] == TILE_BEGIN;
int CCollision::IsTeleport(int x, int y)
{
if(!m_pTele)
return 0;
int nx = clamp(x/32, 0, m_pLayers->TeleLayer()->m_Width-1);
int ny = clamp(y/32, 0, m_pLayers->TeleLayer()->m_Height-1);
/*int z = m_pTiles[ny*m_Width+nx].m_Index-1;
if(z > 34 && z <= 34 + 50 && z&1)
return z;
return 0;*/
int Tele = 0;
if(m_pTele[ny*m_pLayers->TeleLayer()->m_Width+nx].m_Type == TILE_TELEIN)
Tele = m_pTele[ny*m_pLayers->TeleLayer()->m_Width+nx].m_Number;
return Tele;
}
int CCollision::IsEnd(int x, int y)
bool CCollision::IsSpeedup(int x, int y)
{
if(!m_pSpeedup)
return false;
dbg_msg("test", "test");
int nx = clamp(x/32, 0, m_pLayers->SpeedupLayer()->m_Width-1);
int ny = clamp(y/32, 0, m_pLayers->SpeedupLayer()->m_Height-1);
if(m_pSpeedup[ny*m_pLayers->SpeedupLayer()->m_Width+nx].m_Force > 0)
return true;
return false;
}
void CCollision::GetSpeedup(int x, int y, vec2 *Dir, int *Force)
{
int nx = clamp(x/32, 0, m_pLayers->SpeedupLayer()->m_Width-1);
int ny = clamp(y/32, 0, m_pLayers->SpeedupLayer()->m_Height-1);
vec2 Direction = vec2(1, 0);
float Angle = m_pSpeedup[ny*m_pLayers->SpeedupLayer()->m_Width+nx].m_Angle * (3.14159265f/180.0f);
*Force = m_pSpeedup[ny*m_pLayers->SpeedupLayer()->m_Width+nx].m_Force;
vec2 TmpDir;
TmpDir.x = (Direction.x*cos(Angle)) - (Direction.y*sin(Angle));
TmpDir.y = (Direction.x*sin(Angle)) + (Direction.y*cos(Angle));
*Dir = TmpDir;
}
int CCollision::IsBegin(int Index)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
return m_pTeleporter[ny * m_Width + nx] == TILE_END;
return Index == TILE_BEGIN;
}
int CCollision::IsEnd(int Index)
{
return Index == TILE_END;
}
int CCollision::IsFreeze(int x, int y)
int CCollision::IsFreeze(int Index)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
return (m_pTeleporter[ny * m_Width + nx] == TILE_FREEZE) || (m_pFTeleporter[ny * m_Width + nx] == TILE_FREEZE);
return Index == TILE_FREEZE;
}
int CCollision::IsUnfreeze(int x, int y)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
return (m_pTeleporter[ny * m_Width + nx] == TILE_UNFREEZE) || (m_pFTeleporter[ny * m_Width + nx] == TILE_UNFREEZE);
int CCollision::IsUnfreeze(int Index)
{
return Index == TILE_UNFREEZE;
}
int CCollision::IsKick(int x, int y)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
return (m_pTeleporter[ny * m_Width + nx] == TILE_KICK) || (m_pFTeleporter[ny * m_Width + nx] == TILE_KICK);
}
int CCollision::IsCp(int x, int y)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
{
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;
if (Index >= TILE_CP_D && Index <= TILE_CP_L_F)
return Index;
else
return 0;
int ind = m_pTeleporter[ny * m_Width + nx];
if (ind >= TILE_CP_D && ind <= TILE_CP_L_F)
return ind;
return 0;
}
int CCollision::IsBoost(int x, int y)
int CCollision::IsBoost(int Index)
{
int nx = x/32;
int ny = y/32;
if(y < 0 || nx < 0 || nx >= m_Width || ny >= m_Height)
return 0;
if ((m_pTeleporter[ny * m_Width + nx] >= TILE_BOOST_L && m_pTeleporter[ny * m_Width + nx] <= TILE_BOOST_U) || (m_pTeleporter[ny * m_Width + nx] >= TILE_BOOST_L2 && m_pTeleporter[ny * m_Width + nx] <= TILE_BOOST_U2))
return m_pTeleporter[ny * m_Width + nx];
else if ((m_pFTeleporter[ny * m_Width + nx] >= TILE_BOOST_L && m_pFTeleporter[ny * m_Width + nx]<= TILE_BOOST_U) || (m_pFTeleporter[ny * m_Width + nx] >= TILE_BOOST_L2 && m_pFTeleporter[ny * m_Width + nx] <= TILE_BOOST_U2))
return m_pFTeleporter[ny * m_Width + nx];
return 0;
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)
vec2 CCollision::CpSpeed(int Index)
{
vec2 target;
switch(index)
switch(Index)
{
case TILE_CP_U:
case TILE_CP_U_F:
@ -377,136 +470,31 @@ vec2 CCollision::CpSpeed(int index)
target=vec2(0,0);
break;
}
if (index>=TILE_CP_D_F && index<=TILE_CP_L_F)
if (Index>=TILE_CP_D_F && Index<=TILE_CP_L_F)
target*=4;
return target;
}
vec2 CCollision::BoostAccel(int index)
vec2 CCollision::BoostAccelerator(int Index)
{
if (index==TILE_BOOST_L)
if (Index==TILE_BOOST_L)
return vec2(-3,0);
else if(index==TILE_BOOST_R)
else if(Index==TILE_BOOST_R)
return vec2(3,0);
else if(index==TILE_BOOST_D)
else if(Index==TILE_BOOST_D)
return vec2(0,2);
else if(index==TILE_BOOST_U)
else if(Index==TILE_BOOST_U)
return vec2(0,-2);
else if(index==TILE_BOOST_L2)
else if(Index==TILE_BOOST_L2)
return vec2(-15,0);
else if(index==TILE_BOOST_R2)
else if(Index==TILE_BOOST_R2)
return vec2(15,0);
else if(index==TILE_BOOST_D2)
else if(Index==TILE_BOOST_D2)
return vec2(0,15);
else if(index==TILE_BOOST_U2)
else if(Index==TILE_BOOST_U2)
return vec2(0,-15);
return vec2(0,0);
}
vec2 CCollision::Teleport(int a)
{
if(m_Len[a] > 0)
{
int r = rand()%m_Len[a];
int x = (m_pDest[a][r] % m_Width)<<5;
int y = (m_pDest[a][r] / m_Width)<<5;
return vec2((float)x+16.0, (float)y+16.0);
}
else
return vec2(0, 0);
}
void CCollision::Set(int x, int y, int flag)
{
int nx = clamp(x/32, 0, m_Width-1);
int ny = clamp(y/32, 0, m_Height-1);
m_pTiles[ny * m_Width + nx].m_Index = flag;
}
int CCollision::IntersectNolaser2(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision)
{
float d = distance(pos0, pos1);
vec2 last = pos0;
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 pos = mix(pos0, pos1, a);
if(CCollision::IsNolaser(round(pos.x), round(pos.y)))
{
if(out_collision)
*out_collision = pos;
if(out_before_collision)
*out_before_collision = last;
return GetTile(round(pos.x), round(pos.y));
}
last = pos;
}
if(out_collision)
*out_collision = pos1;
if(out_before_collision)
*out_before_collision = pos1;
return 0;
}
int CCollision::IntersectNolaser(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision)
{
float d = distance(pos0, pos1);
vec2 last = pos0;
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 pos = mix(pos0, pos1, a);
if(IsNolaser(round(pos.x), round(pos.y)) || IsSolid(round(pos.x), round(pos.y)))
{
if(out_collision)
*out_collision = pos;
if(out_before_collision)
*out_before_collision = last;
return GetTile(round(pos.x), round(pos.y));
}
last = pos;
}
if(out_collision)
*out_collision = pos1;
if(out_before_collision)
*out_before_collision = pos1;
return 0;
}
int CCollision::IntersectAir(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision)
{
float d = distance(pos0, pos1);
vec2 last = pos0;
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 pos = mix(pos0, pos1, a);
if(IsSolid(round(pos.x), round(pos.y)) || !GetTile(round(pos.x), round(pos.y)))
{
if(out_collision)
*out_collision = pos;
if(out_before_collision)
*out_before_collision = last;
if(!GetTile(round(pos.x), round(pos.y)))
return -1;
else
return GetTile(round(pos.x), round(pos.y));
}
last = pos;
}
if(out_collision)
*out_collision = pos1;
if(out_before_collision)
*out_before_collision = pos1;
return 0;
}
}

View file

@ -6,24 +6,10 @@
class CCollision
{
class CTile *m_pTiles;
class CTile *m_pFTiles;
int m_Width;
int m_Height;
bool isOneLayer;
int *m_pDest[95];
int m_Len[95];
int m_Tele[95];
int *m_pTeleporter;
int *m_pFTeleporter;
class CLayers *m_pLayers;
bool IsTileSolid(int x, int y);
public:
enum
{
@ -31,42 +17,48 @@ public:
COLFLAG_DEATH=2,
COLFLAG_NOHOOK=4,
COLFLAG_NOLASER=8,
COLFLAG_THROUGH=16
};
int GetTile(int x, int y);
CCollision();
void Init(class CLayers *pLayers);
bool CheckPoint(float x, float y) { return IsTileSolid(round(x), round(y)); }
bool CheckPoint(float x, float y) { return IsSolid(round(x), round(y)); }
bool CheckPoint(vec2 p) { return CheckPoint(p.x, p.y); }
void SetCollisionAt(float x, float y, int flag);
int GetCollisionAt(float x, float y) { return GetTile(round(x), round(y)); }
int GetWidth() { return m_Width; };
int GetHeight() { return m_Height; };
int IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
int IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
int IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision);
void MovePoint(vec2 *pInoutPos, vec2 *pInoutVel, float Elasticity, int *Bpounces);
void MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elasticity);
bool TestBox(vec2 Pos, vec2 Size);
void Set(int x, int y, int flags);
int IntersectNolaser(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision);
int IntersectNolaser2(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision);
int IntersectAir(vec2 pos0, vec2 pos1, vec2 *out_collision, vec2 *out_before_collision);
int GetTile(int x, int y);
//DDRace
int IsSolid(int x, int y);
int GetIndex(vec2 PrevPos, vec2 Pos);
vec2 GetPos(int Index);
int GetCollisionDDRace(int Index);
int IsTeleport(int x, int y);
int IsBegin(int x, int y);
int IsNolaser(int x, int y);
int IsEnd(int x, int y);
int IsBoost(int x, int y);
int IsFreeze(int x, int y);
int IsUnfreeze(int x, int y);
int IsKick(int x, int y);
int IsCheckpoint(int Index);
bool IsSpeedup(int x, int y);
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);
int GetIndex(int x, int y, bool flayer);
vec2 Speed(int index);
vec2 BoostAccel(int index);
vec2 Teleport(int z);
vec2 BoostAccelerator(int Index);
vec2 CpSpeed(int index);
class CTeleTile *m_pTele;
class CSpeedupTile *m_pSpeedup;
class CFrontTile *m_pFront;
class CLayers *Layers() { return m_pLayers; }
};
#endif

View file

@ -1,5 +1,4 @@
#include "layers.h"
#include <string.h>
CLayers::CLayers()
{
@ -9,7 +8,9 @@ CLayers::CLayers()
m_LayersStart = 0;
m_pGameGroup = 0;
m_pGameLayer = 0;
m_pFGameLayer = 0;
m_pTeleLayer = 0;
m_pSpeedupLayer = 0;
m_pFrontLayer = 0;
m_pMap = 0;
}
@ -46,10 +47,13 @@ void CLayers::Init(class IKernel *pKernel)
m_pGameGroup->m_ClipH = 0;
//break;
} else if(g == 0 && l == 0) {
m_pFGameLayer = new CMapItemLayerTilemap;
memcpy(m_pFGameLayer, pTilemap, sizeof(CMapItemLayerTilemap));
}
if(pTilemap->m_Flags&2)
m_pTeleLayer = pTilemap;
if(pTilemap->m_Flags&4)
m_pSpeedupLayer = pTilemap;
if(pTilemap->m_Flags&8)
m_pFrontLayer = pTilemap;
}
}
}

View file

@ -12,7 +12,9 @@ class CLayers
int m_LayersStart;
CMapItemGroup *m_pGameGroup;
CMapItemLayerTilemap *m_pGameLayer;
CMapItemLayerTilemap *m_pFGameLayer;
CMapItemLayerTilemap *m_pTeleLayer;
CMapItemLayerTilemap *m_pSpeedupLayer;
CMapItemLayerTilemap *m_pFrontLayer;
class IMap *m_pMap;
public:
@ -22,7 +24,9 @@ public:
class IMap *Map() const { return m_pMap; };
CMapItemGroup *GameGroup() const { return m_pGameGroup; };
CMapItemLayerTilemap *GameLayer() const { return m_pGameLayer; };
CMapItemLayerTilemap *FGameLayer() const { return m_pFGameLayer; };
CMapItemLayerTilemap *TeleLayer() const { return m_pTeleLayer; }
CMapItemLayerTilemap *SpeedupLayer() const { return m_pSpeedupLayer; }
CMapItemLayerTilemap *FrontLayer() const { return m_pFrontLayer; }
CMapItemGroup *GetGroup(int Index) const;
CMapItemLayer *GetLayer(int Index) const;
};

View file

@ -38,81 +38,109 @@ enum
ENTITY_WEAPON_GRENADE,
ENTITY_POWERUP_NINJA,
ENTITY_WEAPON_RIFLE,
//DDRace
ENTITY_LASER_FAST_CW, //M&F
ENTITY_LASER_NORMAL_CW, //M&F
ENTITY_LASER_SLOW_CW, //M&F
ENTITY_LASER_STOP, //M&F
ENTITY_LASER_SLOW_CCW, //M&F
ENTITY_LASER_NORMAL_CCW,//M&F
ENTITY_LASER_FAST_CCW, //M&F
ENTITY_LASER_SHORT, //M&F
ENTITY_LASER_MIDDLE, //M&F
ENTITY_LASER_LONG, //M&F
ENTITY_LASER_C_SLOW, //M&F
ENTITY_LASER_C_NORMAL, //M&F
ENTITY_LASER_C_FAST, //M&F
ENTITY_LASER_O_SLOW, //M&F
ENTITY_LASER_O_NORMAL, //M&F
ENTITY_LASER_O_FAST, //M&F
ENTITY_DRAGER_WEAK, //M&F
ENTITY_DRAGER_NORMAL, //M&F
ENTITY_DRAGER_STRONG, //M&F
ENTITY_PLASMA, //M&F
ENTITY_NOTHING1,
ENTITY_NOTHING2,
ENTITY_NOTHING3,
ENTITY_NOTHING4,
ENTITY_NOTHING5,
ENTITY_NOTHING6,
ENTITY_NOTHING7,
ENTITY_NOTHING8,
ENTITY_NOTHING9,
ENTITY_NOTHING10,
ENTITY_NOTHING11,
ENTITY_NOTHING12,
ENTITY_DRAGER_WEAK_NW, //M&F
ENTITY_DRAGER_NORMAL_NW, //M&F
ENTITY_DRAGER_STRONG_NW, //M&F
//DDRace - Main Lasers
ENTITY_LASER_FAST_CW,
ENTITY_LASER_NORMAL_CW,
ENTITY_LASER_SLOW_CW,
ENTITY_LASER_STOP,
ENTITY_LASER_SLOW_CCW,
ENTITY_LASER_NORMAL_CCW,
ENTITY_LASER_FAST_CCW,
//DDRace - Laser Modifiers
ENTITY_LASER_SHORT,
ENTITY_LASER_MIDDLE,
ENTITY_LASER_LONG,
ENTITY_LASER_C_SLOW,
ENTITY_LASER_C_NORMAL,
ENTITY_LASER_C_FAST,
ENTITY_LASER_O_SLOW,
ENTITY_LASER_O_NORMAL,
ENTITY_LASER_O_FAST,
//DDRace - Shotgun
ENTITY_CRAZY_SHOTGUN_U_EX,
ENTITY_CRAZY_SHOTGUN_R_EX,
ENTITY_CRAZY_SHOTGUN_D_EX,
ENTITY_CRAZY_SHOTGUN_L_EX,
ENTITY_CRAZY_SHOTGUN_U,
ENTITY_CRAZY_SHOTGUN_R,
ENTITY_CRAZY_SHOTGUN_D,
ENTITY_CRAZY_SHOTGUN_L,
//DDrace - Doors
ENTITY_DOOR,
ENTITY_CONNECTOR_D,
ENTITY_CONNECTOR_DR,
ENTITY_CONNECTOR_R,
ENTITY_CONNECTOR_RU,
ENTITY_CONNECTOR_U,
ENTITY_CONNECTOR_UL,
ENTITY_CONNECTOR_L,
ENTITY_CONNECTOR_LD,
ENTITY_TRIGGER,
//DDRace - Draggers
ENTITY_DRAGGER_WEAK,
ENTITY_DRAGGER_NORMAL,
ENTITY_DRAGGER_STRONG,
//Draggers Behind Walls
ENTITY_DRAGGER_WEAK_NW,
ENTITY_DRAGGER_NORMAL_NW,
ENTITY_DRAGGER_STRONG_NW,
//DDRace - Plasma
ENTITY_PLASMA,
ENTITY_PLASMAF,
//End Of Lower Tiles
NUM_ENTITIES,
//Start From Top Left
//Tile Controllers
TILE_AIR=0,
TILE_SOLID,
TILE_DEATH,
TILE_NOHOOK,
TILE_NOLASER, //M
TILE_BOOST_L, //M
TILE_BOOST_R, //M
TILE_BOOST_D, //M
TILE_BOOST_U, //M
TILE_FREEZE, //M&F
TILE_KICK, //M&F
TILE_UNFREEZE, //M&F
TILE_BOOST_L2, //M
TILE_BOOST_R2, //M
TILE_BOOST_D2, //M
TILE_BOOST_U2, //M
TILE_NOTHING, //M&F
TILE_CP_D, //M //no collision
TILE_CP_U, //M //endless hook
TILE_CP_R, //M
TILE_CP_L, //M
TILE_CP_D_F, //M
TILE_CP_U_F, //M
TILE_CP_R_F, //M
TILE_CP_L_F, //M
TILE_BEGIN=33, //M
TILE_END, //M
TILE_NOLASER,
TILE_AIRNOHOOK,
TILE_THROUGH,
TILE_THROUGHS,
TILE_FREEZE=9,
TILE_UNFREEZE=11,
TILE_BOOSTH,
TILE_BOOSTV,
TILE_BOOSTA,
TILE_BOOSTH2,
TILE_BOOSTV2,
TILE_BOOSTA2,
TILE_BOOST_L,
TILE_BOOST_R,
TILE_BOOST_D,
TILE_BOOST_U,
TILE_BOOST_L2,
TILE_BOOST_R2,
TILE_BOOST_D2,
TILE_BOOST_U2,
TILE_TELEIN,
TILE_TELEOUT,
TILE_BOOST,
TILE_STOPL,
TILE_STOPR,
TILE_STOPB,
TILE_STOPT,
TILE_BEGIN,
TILE_END,
TILE_STOPH=60,
TILE_STOPV,
TILE_STOPA,
TILE_CP_D=64,
TILE_CP_U,
TILE_CP_R,
TILE_CP_L,
TILE_CP_D_F,
TILE_CP_U_F,
TILE_CP_R_F,
TILE_CP_L_F,
TILE_NPC,
TILE_EHOOK,
TILE_NOHIT,
TILE_NPH,
//End of higher tiles
//Untouchable Elements
TILEFLAG_VFLIP=1,
TILEFLAG_HFLIP=2,
TILEFLAG_OPAQUE=4,
@ -154,6 +182,20 @@ public:
unsigned char m_Reserved;
};
class CTeleTile
{
public:
unsigned char m_Number;
unsigned char m_Type;
};
class CSpeedupTile
{
public:
unsigned char m_Force;
short m_Angle;
};
struct CMapItemImage
{
int m_Version;
@ -210,6 +252,10 @@ struct CMapItemLayerTilemap
int m_Image;
int m_Data;
int m_Tele;
int m_Speedup;
int m_Front;
} ;
struct CMapItemLayerQuads
@ -242,7 +288,7 @@ struct CMapItemEnvelope
int m_Channels;
int m_StartPoint;
int m_NumPoints;
int m_aName[8];
char m_aName[32];
} ;
#endif

View file

@ -557,7 +557,7 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
void CCharacter::Tick()
{
int TileIndex = GameServer()->Collision()->GetIndex(m_PrevPos, m_Pos);
if(m_RaceState == RACE_PAUSE) {
m_Input.m_Direction = 0;
@ -600,7 +600,7 @@ 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
//DDRace
char aBuftime[128];
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
@ -618,13 +618,13 @@ void CCharacter::Tick()
}
m_RefreshTime = Server()->Tick();
}
if(GameServer()->Collision()->IsBegin(m_Pos.x,m_Pos.y) && m_RaceState == RACE_NONE)
if(GameServer()->Collision()->IsBegin(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && m_RaceState == RACE_NONE)
{
m_StartTime = Server()->Tick();
m_RefreshTime = Server()->Tick();
m_RaceState = RACE_STARTED;
}
if(GameServer()->Collision()->IsEnd(m_Pos.x, m_Pos.y) && m_RaceState == RACE_STARTED)
if(GameServer()->Collision()->IsEnd(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && m_RaceState == RACE_STARTED)
{
char aBuf[128];
if ((int)time / 60 != 0)
@ -648,31 +648,34 @@ 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()->IsKick(m_Pos.x, m_Pos.y) && !m_Super)
{
if (m_pPlayer->m_Authed > 0)
Die(-1, WEAPON_WORLD);
else
((CServer*)GameServer()->Server())->Kick(m_pPlayer->GetCID(), "You was kicked by kick zone");
}
if(GameServer()->Collision()->IsFreeze(m_Pos.x, m_Pos.y) && !m_Super)
if(GameServer()->Collision()->IsFreeze(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && !m_Super)
{
Freeze(Server()->TickSpeed()*3);
}
if(GameServer()->Collision()->IsUnfreeze(m_Pos.x, m_Pos.y) && !m_Super)
if(GameServer()->Collision()->IsUnfreeze(GameServer()->Collision()->GetCollisionDDRace(TileIndex)) && !m_Super)
{
UnFreeze();
}
int booster = GameServer()->Collision()->IsBoost(m_Pos.x, m_Pos.y);
m_Core.m_Vel += GameServer()->Collision()->BoostAccel(booster);
int z = GameServer()->Collision()->IsTeleport(m_Pos.x, m_Pos.y);
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))
{
vec2 Direction;
int Force;
GameServer()->Collision()->GetSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y, &Direction, &Force);
m_Core.m_Vel += Direction*Force;
}
int z = GameServer()->Collision()->IsTeleport(m_Pos.x, m_Pos.y);
if(z)
{
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
m_Core.m_HookPos = m_Core.m_Pos;
m_Core.m_Pos = GameServer()->Collision()->Teleport(z);
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;
m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
m_Core.m_HookState = HOOK_RETRACTED;
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[z-1];
m_Core.m_HookPos = m_Core.m_Pos;
}
// handle death-tiles
@ -703,6 +706,7 @@ void CCharacter::Tick()
m_OlderPos = m_OldPos;
m_OldPos = m_Core.m_Pos;
}
m_PrevPos = m_Core.m_Pos;
return;
}

View file

@ -160,6 +160,9 @@ public:
// DDRace var
int m_StartTime;
int m_RefreshTime;
int m_LastSpeedup;
vec2 m_PrevPos;
// checkpoints
int m_CpTick;

View file

@ -35,9 +35,7 @@ void CDrager::move()
target = ents[i];
int res=0;
if (!nw)
res = GameServer()->Collision()->IntersectNolaser(m_Pos, target->m_Pos, 0, 0);
else
res = GameServer()->Collision()->IntersectNolaser2(m_Pos, target->m_Pos, 0, 0);
res = GameServer()->Collision()->IntersectNoLaser(m_Pos, target->m_Pos, 0, 0);
if (res==0)
{
@ -66,9 +64,7 @@ void CDrager::drag()
int res = 0;
if (!nw)
res = GameServer()->Collision()->IntersectNolaser(m_Pos, target->m_Pos, 0, 0);
else
res = GameServer()->Collision()->IntersectNolaser2(m_Pos, target->m_Pos, 0, 0);
res = GameServer()->Collision()->IntersectNoLaser(m_Pos, target->m_Pos, 0, 0);
if (res || length(m_Pos-target->m_Pos)>700)
{

View file

@ -72,11 +72,11 @@ void CLaser::DoBounce()
int f;
if(res == -1) {
f = GameServer()->Collision()->GetTile(round(Coltile.x), round(Coltile.y));
GameServer()->Collision()->Set(round(Coltile.x), round(Coltile.y), CCollision::COLFLAG_SOLID);
GameServer()->Collision()->SetCollisionAt(round(Coltile.x), round(Coltile.y), CCollision::COLFLAG_SOLID);
}
GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0);
if(res == -1) {
GameServer()->Collision()->Set(round(Coltile.x), round(Coltile.y), f);
GameServer()->Collision()->SetCollisionAt(round(Coltile.x), round(Coltile.y), f);
}
m_Pos = TempPos;
m_Dir = normalize(TempDir);

View file

@ -68,7 +68,7 @@ void CLight::step()
move();
vec2 dir(sin(rotation), cos(rotation));
vec2 to2 = m_Pos + normalize(dir)*cur_length;
GameServer()->Collision()->IntersectNolaser(m_Pos, to2, &to,0 );
GameServer()->Collision()->IntersectNoLaser(m_Pos, to2, &to,0 );
}
void CLight::Reset()

View file

@ -55,7 +55,7 @@ void CPlasma::Tick()
hit_character();
int res=0;
res = GameServer()->Collision()->IntersectNolaser(m_Pos, m_Pos+core,0, 0);
res = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos+core,0, 0);
if(res)
{
GameServer()->CreateExplosion(m_Pos, -1, WEAPON_GRENADE, false);

View file

@ -1583,8 +1583,7 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
// create all entities from the game layer
CMapItemLayerTilemap *pTileMap = m_Layers.GameLayer();
CTile *pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
if (!m_Layers.FGameLayer()) dbg_msg("fglayer","Everything is Alright");
//windows usually crshes here
for(int y = 0; y < pTileMap->m_Height; y++)
{
@ -1594,36 +1593,11 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
if(Index >= ENTITY_OFFSET)
{
//vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
m_pController->OnEntity(Index-ENTITY_OFFSET, x, y, false);
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
m_pController->OnEntity(Index-ENTITY_OFFSET, Pos);
}
}
}
//****************FRONT GAME LAYER********************
pTileMap = m_Layers.FGameLayer();
if (pTileMap!=0)
{
pTiles = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Data);
for(int y = 0; y < pTileMap->m_Height; y++)
{
for(int x = 0; x < pTileMap->m_Width; x++)
{
int Index = pTiles[y*pTileMap->m_Width+x].m_Index;
if(Index >= ENTITY_OFFSET)
{
//vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
m_pController->OnEntity(Index-ENTITY_OFFSET, x, y, true);
} else {
m_pController->MapConfig(Index);
}
}
}
}
#ifdef CONF_DEBUG
if(g_Config.m_DbgDummies)

View file

@ -115,95 +115,30 @@ bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
return Eval.m_Got;
}
bool IGameController::MapConfig(int index)
{
if (index == TILE_CP_D)
{
//g_Config.m_SvNpc = true;
return true;
}
else if (index == TILE_CP_U)
{
g_Config.m_SvEndlessDrag = true;
return true;
}
return false;
}
bool IGameController::OnEntity(int Index, vec2 Pos)
{
int Type = -1;
int SubType = 0;
//vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
int sides[8];
sides[0]=GameServer()->Collision()->GetIndex(vec2(Pos.x,Pos.y+1),vec2(Pos.x,Pos.y+1));
sides[1]=GameServer()->Collision()->GetIndex(vec2(Pos.x+1,Pos.y+1),vec2(Pos.x+1,Pos.y+1));
sides[2]=GameServer()->Collision()->GetIndex(vec2(Pos.x+1,Pos.y),vec2(Pos.x+1,Pos.y));
sides[3]=GameServer()->Collision()->GetIndex(vec2(Pos.x+1,Pos.y-1),vec2(Pos.x+1,Pos.y-1));
sides[4]=GameServer()->Collision()->GetIndex(vec2(Pos.x,Pos.y-1),vec2(Pos.x,Pos.y-1));
sides[5]=GameServer()->Collision()->GetIndex(vec2(Pos.x-1,Pos.y-1),vec2(Pos.x-1,Pos.y-1));
sides[6]=GameServer()->Collision()->GetIndex(vec2(Pos.x-1,Pos.y),vec2(Pos.x-1,Pos.y));
sides[7]=GameServer()->Collision()->GetIndex(vec2(Pos.x-1,Pos.y+1),vec2(Pos.x-1,Pos.y+1));
if(Index == ENTITY_SPAWN)
m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos;
else if(Index == ENTITY_SPAWN_RED)
m_aaSpawnPoints[1][m_aNumSpawnPoints[1]++] = Pos;
else if(Index == ENTITY_SPAWN_BLUE)
m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos;
else if(Index == ENTITY_ARMOR_1)
Type = POWERUP_ARMOR;
else if(Index == ENTITY_HEALTH_1)
Type = POWERUP_HEALTH;
else if(Index == ENTITY_WEAPON_SHOTGUN)
{
Type = POWERUP_WEAPON;
SubType = WEAPON_SHOTGUN;
}
else if(Index == ENTITY_WEAPON_GRENADE)
{
Type = POWERUP_WEAPON;
SubType = WEAPON_GRENADE;
}
else if(Index == ENTITY_WEAPON_RIFLE)
{
Type = POWERUP_WEAPON;
SubType = WEAPON_RIFLE;
}
else if(Index == ENTITY_POWERUP_NINJA)
{
Type = POWERUP_NINJA;
SubType = WEAPON_NINJA;
}
if(Type != -1)
{
CPickup *pPickup = new CPickup(&GameServer()->m_World, Type, SubType);
pPickup->m_Pos = Pos;
return true;
}
return false;
}
bool IGameController::OnEntity(int Index, int x, int y, bool flayer)
{
int Type = -1;
int SubType = 0;
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
int sides[8];
sides[0]=GameServer()->Collision()->GetIndex(x,y+1,flayer);
sides[1]=GameServer()->Collision()->GetIndex(x+1,y+1,flayer);
sides[2]=GameServer()->Collision()->GetIndex(x+1,y,flayer);
sides[3]=GameServer()->Collision()->GetIndex(x+1,y-1,flayer);
sides[4]=GameServer()->Collision()->GetIndex(x,y-1,flayer);
sides[5]=GameServer()->Collision()->GetIndex(x-1,y-1,flayer);
sides[6]=GameServer()->Collision()->GetIndex(x-1,y,flayer);
sides[7]=GameServer()->Collision()->GetIndex(x-1,y+1,flayer);
if (!flayer)
{
if(Index == ENTITY_SPAWN)
m_aaSpawnPoints[0][m_aNumSpawnPoints[0]++] = Pos;
else if(Index == ENTITY_SPAWN_RED)
m_aaSpawnPoints[1][m_aNumSpawnPoints[1]++] = Pos;
else if(Index == ENTITY_SPAWN_BLUE)
m_aaSpawnPoints[2][m_aNumSpawnPoints[2]++] = Pos;
}
if(Index == ENTITY_ARMOR_1)
Type = POWERUP_ARMOR;
else if(Index == ENTITY_HEALTH_1)
@ -231,14 +166,14 @@ bool IGameController::OnEntity(int Index, int x, int y, bool flayer)
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
{
int sides2[8];
sides2[0]=GameServer()->Collision()->GetIndex(x,y+2,flayer);
sides2[1]=GameServer()->Collision()->GetIndex(x+2,y+2,flayer);
sides2[2]=GameServer()->Collision()->GetIndex(x+2,y,flayer);
sides2[3]=GameServer()->Collision()->GetIndex(x+2,y-2,flayer);
sides2[4]=GameServer()->Collision()->GetIndex(x,y-2,flayer);
sides2[5]=GameServer()->Collision()->GetIndex(x-2,y-2,flayer);
sides2[6]=GameServer()->Collision()->GetIndex(x-2,y,flayer);
sides2[7]=GameServer()->Collision()->GetIndex(x-2,y+2,flayer);
sides2[0]=GameServer()->Collision()->GetIndex(vec2(Pos.x,Pos.y+2),vec2(Pos.x,Pos.y+2));
sides2[1]=GameServer()->Collision()->GetIndex(vec2(Pos.x+2,Pos.y+2),vec2(Pos.x+2,Pos.y+2));
sides2[2]=GameServer()->Collision()->GetIndex(vec2(Pos.x+2,Pos.y),vec2(Pos.x+2,Pos.y));
sides2[3]=GameServer()->Collision()->GetIndex(vec2(Pos.x+2,Pos.y-2),vec2(Pos.x+2,Pos.y-2));
sides2[4]=GameServer()->Collision()->GetIndex(vec2(Pos.x,Pos.y-2),vec2(Pos.x,Pos.y-2));
sides2[5]=GameServer()->Collision()->GetIndex(vec2(Pos.x-2,Pos.y-2),vec2(Pos.x-2,Pos.y-2));
sides2[6]=GameServer()->Collision()->GetIndex(vec2(Pos.x-2,Pos.y),vec2(Pos.x-2,Pos.y));
sides2[7]=GameServer()->Collision()->GetIndex(vec2(Pos.x-2,Pos.y+2),vec2(Pos.x-2,Pos.y+2));
float ang_speed;
int ind=Index-ENTITY_LASER_STOP;
@ -287,13 +222,13 @@ bool IGameController::OnEntity(int Index, int x, int y, bool flayer)
}
else if(Index>=ENTITY_DRAGER_WEAK && Index <=ENTITY_DRAGER_STRONG)
else if(Index>=ENTITY_DRAGGER_WEAK && Index <=ENTITY_DRAGGER_STRONG)
{
new CDrager(&GameServer()->m_World,Pos,Index-ENTITY_DRAGER_WEAK+1);
new CDrager(&GameServer()->m_World,Pos,Index-ENTITY_DRAGGER_WEAK+1);
}
else if(Index>=ENTITY_DRAGER_WEAK_NW && Index <=ENTITY_DRAGER_STRONG_NW)
else if(Index>=ENTITY_DRAGGER_WEAK_NW && Index <=ENTITY_DRAGGER_STRONG_NW)
{
new CDrager(&GameServer()->m_World, Pos,Index-ENTITY_DRAGER_WEAK_NW+1,true);
new CDrager(&GameServer()->m_World, Pos,Index-ENTITY_DRAGGER_WEAK_NW+1,true);
}
else if(Index==ENTITY_PLASMA)
{
@ -867,4 +802,4 @@ int IGameController::ClampTeam(int Team)
//if(IsTeamplay())
// return Team&1;
return 0;
}
}

View file

@ -68,7 +68,6 @@ public:
//void DoTeamScoreWincheck();
//void DoPlayerScoreWincheck();
bool MapConfig(int index);
void DoWarmup(int Seconds);
void StartRound();
@ -101,7 +100,6 @@ public:
bool?
*/
virtual bool OnEntity(int Index, vec2 Pos);
virtual bool OnEntity(int Index, int x, int y, bool flayer);
/*
Function: on_CCharacter_spawn

View file

@ -6,15 +6,49 @@
#include <game/server/gamecontext.h>
#include "DDRace.h"
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer)
: IGameController(pGameServer), m_Score(pGameServer)
CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) : IGameController(pGameServer)
{
m_pGameType = "DDRace";
InitTeleporter();
}
CGameControllerDDRace::~CGameControllerDDRace()
{
delete[] m_pTeleporter;
}
void CGameControllerDDRace::Tick()
{
IGameController::Tick();
}
void CGameControllerDDRace::InitTeleporter()
{
int ArraySize = 0;
if(GameServer()->Collision()->Layers()->TeleLayer())
{
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
{
// get the array size
if(GameServer()->Collision()->m_pTele[i].m_Number > ArraySize)
ArraySize = GameServer()->Collision()->m_pTele[i].m_Number;
}
}
if(!ArraySize)
{
m_pTeleporter = 0x0;
return;
}
m_pTeleporter = new vec2[ArraySize];
mem_zero(m_pTeleporter, ArraySize*sizeof(vec2));
// assign the values
for(int i = 0; i < GameServer()->Collision()->Layers()->TeleLayer()->m_Width*GameServer()->Collision()->Layers()->TeleLayer()->m_Height; i++)
{
if(GameServer()->Collision()->m_pTele[i].m_Number > 0 && GameServer()->Collision()->m_pTele[i].m_Type == TILE_TELEOUT)
m_pTeleporter[GameServer()->Collision()->m_pTele[i].m_Number-1] = vec2(i%GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16, i/GameServer()->Collision()->Layers()->TeleLayer()->m_Width*32+16);
}
}

View file

@ -1,18 +1,22 @@
/* copyright (c) 2007 rajh and gregwar. Score stuff */
#ifndef RACE_H
#define RACE_H
#ifndef DDRACE_H
#define DDRACE_H
#include <game/server/gamecontroller.h>
#include <game/server/score.h>
class CGameControllerDDRace : public IGameController
{
public:
CGameControllerDDRace(class CGameContext *pGameServer);
~CGameControllerDDRace();
vec2 *m_pTeleporter;
void InitTeleporter();
CScore m_Score;
virtual void Tick();
};
#endif
#endif

View file

@ -26,6 +26,11 @@ CScore::CScore(class CGameContext *pGameServer)
Load();
}
CScore::CScore()
{
Load();
}
std::string CScore::SaveFile()
{
std::ostringstream oss;

View file

@ -24,7 +24,7 @@ class CScore
std::string SaveFile();
public:
CScore(class CGameContext *pGameServer);
CScore();
void Save();
void Load();
CPlayerScore *SearchName(const char *name, int &pos);