This commit is contained in:
btd 2010-08-21 10:30:50 +04:00
commit 01dd26d750
15 changed files with 530 additions and 363 deletions

View file

@ -933,13 +933,15 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
if(level != -1)
{
char buf[128]="Authentication successful. Remote console access granted, with level=%d";
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS);
Msg.AddInt(1);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientId, true);
m_aClients[ClientId].m_Authed = level;
GameServer()->OnSetAuthed(ClientId, m_aClients[ClientId].m_Authed);
SendRconLine(ClientId, "Authentication successful. Remote console access granted.");
str_format(buf,sizeof(buf),buf,level);
SendRconLine(ClientId, buf);
dbg_msg("server", "ClientId=%d authed with Level=%d", ClientId, level);
m_aClients[ClientId].m_PwTries = 0;
}

View file

@ -21,10 +21,6 @@ CCollision::CCollision()
m_pSpeedup = 0;
m_pFront = 0;
}
int CCollision::IsSolid(int x, int y)
{
return (GetTile(x,y)&COLFLAG_SOLID);
}
void CCollision::Init(class CLayers *pLayers)
{
@ -113,7 +109,9 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
else dbg_msg("GetMapIndex(","ny*m_Width+nx %d",ny*m_Width+nx);//REMOVE */
if((m_pTiles[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[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))
{
@ -133,9 +131,11 @@ int CCollision::GetMapIndex(vec2 PrevPos, vec2 Pos)
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_THROUGH && m_pTiles[ny*m_Width+nx].m_Index < TILE_TELEIN) ||
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(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))
((m_pTiles[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pTiles[ny*m_Width+nx].m_Index <= TILE_NPH) ) ||
(m_pFront && (m_pFront[ny*m_Width+nx].m_Index >= TILE_THROUGH && m_pFront[ny*m_Width+nx].m_Index < TILE_TELEIN)) ||
(m_pFront && ((m_pFront[ny*m_Width+nx].m_Index >TILE_BOOST)&&(m_pFront[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;
}
@ -159,6 +159,14 @@ int CCollision::GetCollisionDDRace(int Index)
return 0;
return m_pTiles[Index].m_Index;
}
int CCollision::GetCollisionDDRace2(int Index)
{
/*dbg_msg("GetCollisionDDRace2","m_pFront[%d].m_Index = %d",Index,m_pFront[Index].m_Index);//Remove*/
if(Index < 0 || !m_pFront)
return 0;
return m_pFront[Index].m_Index;
}
int CCollision::GetTile(int x, int y)
{
@ -173,9 +181,9 @@ int CCollision::GetTile(int x, int y)
else
return 0;
}
int CCollision::Entitiy(int x, int y)
int CCollision::Entity(int x, int y, bool Front)
{
int Index = m_pTiles[y*m_Width+x].m_Index;
int Index = Front?m_pFront[y*m_Width+x].m_Index:m_pTiles[y*m_Width+x].m_Index;
return Index-ENTITY_OFFSET;
}
void CCollision::SetCollisionAt(float x, float y, int flag)
@ -187,22 +195,61 @@ void CCollision::SetCollisionAt(float x, float y, int flag)
}
// TODO: rewrite this smarter!
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision)
void ThroughOffset(vec2 Pos0, vec2 Pos1, int *Ox, int *Oy)
{
float x = Pos0.x - Pos1.x;
float y = Pos0.y - Pos1.y;
if (fabs(x) > fabs(y))
{
if (x < 0)
{
*Ox = -32;
*Oy = 0;
}
else
{
*Ox = 32;
*Oy = 0;
}
}
else
{
if (y < 0)
{
*Ox = 0;
*Oy = -32;
}
else
{
*Ox = 0;
*Oy = 32;
}
}
}
int CCollision::IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough)
{
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
int ix, iy; // Temporary position for checking collision
int dx, dy; // Offset for checking the "through" tile
if (AllowThrough)
{
ThroughOffset(Pos0, Pos1, &dx, &dy);
}
for(float f = 0; f < d; f++)
{
float a = f/d;
vec2 Pos = mix(Pos0, Pos1, a);
if(CheckPoint(Pos.x, Pos.y))
ix = round(Pos.x);
iy = round(Pos.y);
if(CheckPoint(ix, iy) && !(AllowThrough && IsThrough(ix + dx, iy + dy)))
{
if(pOutCollision)
*pOutCollision = Pos;
if(pOutBeforeCollision)
*pOutBeforeCollision = Last;
return GetCollisionAt(Pos.x, Pos.y);
return GetCollisionAt(ix, iy);
}
Last = Pos;
}
@ -379,6 +426,27 @@ bool CCollision::TestBox(vec2 Pos, vec2 Size)
return false;
}
int CCollision::IsSolid(int x, int y)
{
return (GetTile(x,y)&COLFLAG_SOLID);
}
int CCollision::IsThrough(int x, int y)
{
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;
if (m_pFront)
Findex = m_pFront[ny*m_Width+nx].m_Index;
if (Index == TILE_THROUGH)
return Index;
else if (Findex == TILE_THROUGH)
return Findex;
else
return 0;
}
int CCollision::IsNoLaser(int x, int y)
{
return (CCollision::GetTile(x,y) & COLFLAG_NOLASER);
@ -444,10 +512,11 @@ bool CCollision::IsFront(int x, int y)
if(m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index > 0)
{
dbg_msg("IsFront","True m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
/*dbg_msg("IsFront","True m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
return true;
}
else dbg_msg("IsFront","Welcome to the front layer m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
/*else dbg_msg("IsFront","Welcome to the front layer m_Index=%d",m_pFront[ny*m_pLayers->FrontLayer()->m_Width+nx].m_Index);//Remove*/
return false;
}
int CCollision::IsCp(int x, int y)

View file

@ -27,18 +27,19 @@ public:
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 IntersectLine(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pOutBeforeCollision, bool AllowThrough);
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);
int GetTile(int x, int y);
int Entitiy(int x, int y);
int Entity(int x, int y, bool Front);
//DDRace
int GetMapIndex(vec2 PrevPos, vec2 Pos);
vec2 GetPos(int Index);
int GetCollisionDDRace(int Index);
int GetCollisionDDRace2(int Index);
int IsTeleport(int x, int y);
int IsCheckpoint(int Index);
bool IsSpeedup(int x, int y);
@ -46,6 +47,7 @@ public:
bool IsFront(int x, int y);
int IsSolid(int x, int y);
int IsThrough(int x, int y);
int IsNoLaser(int x, int y);
int IsCp(int x, int y);

View file

@ -192,18 +192,20 @@ void CCharacterCore::Tick(bool UseInput)
{
m_HookState = HOOK_RETRACT_START;
NewPos = m_Pos + normalize(NewPos-m_Pos) * m_pWorld->m_Tuning.m_HookLength;
m_pReset = true;
}
// make sure that the hook doesn't go though the ground
bool GoingToHitGround = false;
bool GoingToRetract = false;
int Hit = m_pCollision->IntersectLine(m_HookPos, NewPos, &NewPos, 0);
int Hit = m_pCollision->IntersectLine(m_HookPos, NewPos, &NewPos, 0,true);
if(Hit)
{
if(Hit&CCollision::COLFLAG_NOHOOK)
GoingToRetract = true;
else
GoingToHitGround = true;
m_pReset = true;
}
// Check against other players first

View file

@ -190,6 +190,7 @@ public:
int m_Angle;
CNetObj_PlayerInput m_Input;
bool m_pReset;
int m_TriggeredEvents;
void Init(CWorldCore *pWorld, CCollision *pCollision);

View file

@ -558,7 +558,8 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
void CCharacter::Tick()
{
int MapIndex = GameServer()->Collision()->GetMapIndex(m_PrevPos, m_Pos);
int TileIndex = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
int TileIndex1 = GameServer()->Collision()->GetCollisionDDRace(MapIndex);
int TileIndex2 = GameServer()->Collision()->GetCollisionDDRace2(MapIndex);
if(m_RaceState == RACE_PAUSE) {
m_Input.m_Direction = 0;
m_Input.m_Jump = 0;
@ -600,7 +601,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*/
/*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/
//DDRace
char aBuftime[128];
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
@ -619,13 +620,13 @@ void CCharacter::Tick()
}
m_RefreshTime = Server()->Tick();
}
else if((TileIndex == TILE_BEGIN) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
if(((TileIndex1 == TILE_BEGIN) || (TileIndex2 == TILE_BEGIN)) && (m_RaceState == RACE_NONE || m_RaceState == RACE_STARTED))
{
m_StartTime = Server()->Tick();
m_RefreshTime = Server()->Tick();
m_RaceState = RACE_STARTED;
}
else if((TileIndex == TILE_END) && m_RaceState == RACE_STARTED)
if(((TileIndex1 == TILE_END) || (TileIndex2 == TILE_END)) && m_RaceState == RACE_STARTED)
{
char aBuf[128];
if ((int)time / 60 != 0)
@ -649,60 +650,103 @@ 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);
}
else if((TileIndex == TILE_FREEZE) && !m_Super)
if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super)
{
Freeze(Server()->TickSpeed()*3);
}
else if(TileIndex == TILE_UNFREEZE)
else if((TileIndex1 == TILE_UNFREEZE) || (TileIndex2 == TILE_UNFREEZE))
{
UnFreeze();
}
else if ((TileIndex >= TILE_BOOST_L && TileIndex <= TILE_BOOST_U) || (TileIndex >= TILE_BOOST_L2 && TileIndex <= TILE_BOOST_U2))
if (((TileIndex1 >= TILE_BOOST_L && TileIndex1 <= TILE_BOOST_U) || (TileIndex1 >= TILE_BOOST_L2 && TileIndex1 <= TILE_BOOST_U2)))
{
int booster = TileIndex;
int booster = TileIndex1;
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
}
else if(GameServer()->Collision()->GetCollisionDDRace(TileIndex) == TILE_STOPL)
if ((TileIndex2 >= TILE_BOOST_L && TileIndex2 <= TILE_BOOST_U) || (TileIndex2 >= TILE_BOOST_L2 && TileIndex2 <= TILE_BOOST_U2))
{
int booster = TileIndex2;
m_Core.m_Vel += GameServer()->Collision()->BoostAccelerator(booster);
}
if(TileIndex1 == TILE_STOPL)
{
if(m_Core.m_Vel.x > 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).x < (int)m_Core.m_Pos.x)
if((int)GameServer()->Collision()->GetPos(TileIndex1).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(TileIndex2 == TILE_STOPL)
{
if(m_Core.m_Vel.x > 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex2).x < (int)m_Core.m_Pos.x)
m_Core.m_Pos.x = m_PrevPos.x;
m_Core.m_Vel.x = 0;
}
}
if(TileIndex1 == TILE_STOPR)
{
if(m_Core.m_Vel.x < 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).x > (int)m_Core.m_Pos.x)
if((int)GameServer()->Collision()->GetPos(TileIndex1).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(TileIndex1 == TILE_STOPB)
{
if(m_Core.m_Vel.y < 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).y > (int)m_Core.m_Pos.y)
if((int)GameServer()->Collision()->GetPos(TileIndex1).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(TileIndex1 == TILE_STOPT)
{
if(m_Core.m_Vel.y > 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex).y < (int)m_Core.m_Pos.y)
if((int)GameServer()->Collision()->GetPos(TileIndex1).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()->IsFront((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
if(TileIndex2 == TILE_STOPR)
{
if(m_Core.m_Vel.x < 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex2).x > (int)m_Core.m_Pos.x)
m_Core.m_Pos.x = m_PrevPos.x;
m_Core.m_Vel.x = 0;
}
}
if(TileIndex2 == TILE_STOPB)
{
if(m_Core.m_Vel.y < 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex2).y > (int)m_Core.m_Pos.y)
m_Core.m_Pos.y = m_PrevPos.y;
m_Core.m_Vel.y = 0;
}
}
if(TileIndex2 == TILE_STOPT)
{
if(m_Core.m_Vel.y > 0)
{
if((int)GameServer()->Collision()->GetPos(TileIndex2).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;
}
}
if(GameServer()->Collision()->IsFront((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
;
else if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
if(GameServer()->Collision()->IsSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y))
{
vec2 Direction;
int Force;
@ -710,7 +754,7 @@ void CCharacter::Tick()
m_Core.m_Vel += Direction*Force;
}
else if(z)
if(z)
{
m_Core.m_HookedPlayer = -1;
m_Core.m_HookState = HOOK_RETRACTED;
@ -854,11 +898,12 @@ void CCharacter::TickDefered()
m_Core.Write(&Current);
// only allow dead reackoning for a top of 3 seconds
if(m_ReckoningTick+Server()->TickSpeed()*3 < Server()->Tick() || mem_comp(&Predicted, &Current, sizeof(CNetObj_Character)) != 0)
if(m_Core.m_pReset || m_ReckoningTick+Server()->TickSpeed()*3 < Server()->Tick() || mem_comp(&Predicted, &Current, sizeof(CNetObj_Character)) != 0)
{
m_ReckoningTick = Server()->Tick();
m_SendCore = m_Core;
m_ReckoningCore = m_Core;
m_Core.m_pReset = false;
}
}
}

View file

@ -35,7 +35,7 @@ void CGun::fire()
CCharacter *target = ents[i];
int res=0;
vec2 coltile;
res = GameServer()->Collision()->IntersectLine(m_Pos, target->m_Pos,0,0);
res = GameServer()->Collision()->IntersectLine(m_Pos, target->m_Pos,0,0,false);
if (!res)
{
int len=length(ents[i]->m_Pos - m_Pos);

View file

@ -56,7 +56,7 @@ void CLaser::DoBounce()
vec2 Coltile;
int res;
res = GameServer()->Collision()->IntersectLine(m_Pos, To, &Coltile, &To);
res = GameServer()->Collision()->IntersectLine(m_Pos, To, &Coltile, &To,false);
if(res)
{

View file

@ -68,7 +68,7 @@ void CProjectile::Tick()
vec2 ColPos;
vec2 NewPos;
vec2 Speed = CurPos - PrevPos;
int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos);
int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos,false);
CCharacter *OwnerChar;

View file

@ -547,7 +547,6 @@ void CGameContext::OnSetAuthed(int client_id, int Level)
m_apPlayers[client_id]->m_Authed = Level;
char buf[11];
str_format(buf, sizeof(buf), "ban %d %d", client_id, g_Config.m_SvVoteKickBanTime);
//dbg_msg("hooks","%d", m_aVoteCommand == buf);//???
if ( !strcmp(m_aVoteCommand,buf))
{
m_VoteEnforce = CGameContext::VOTE_ENFORCE_NO;
@ -1419,44 +1418,53 @@ void CGameContext::ConTeleport(IConsole::IResult *pResult, void *pUserData, int
}
}
void CGameContext::ConTimer(IConsole::IResult *pResult, void *pUserData, int cid)
void CGameContext::ConTimerStop(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
char buf[128];
CServer* serv = (CServer*)pSelf->Server();
if(!g_Config.m_SvTimer) {
if(!g_Config.m_SvTimer)
{
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
int type = pResult->GetInteger(1);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
if (type>1 || type<0)
{
serv->SendRconLine(cid, "Select 0 for no time & 1 for with time");
}
else
{
if(type)
{
chr->m_RaceState = RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d Has time now",cid1);
}
else if(!type)
{
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d Hasn't time now",cid1);
}
serv->SendRconLine(cid1, buf);
}
} else {
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d Hasn't time now (Timer Stopped)",cid1);
serv->SendRconLine(cid1, buf);
}
else
{
serv->SendRconLine(cid, "Command timer does't allowed");
}
}
void CGameContext::ConTimerReset(IConsole::IResult *pResult, void *pUserData, int cid)
void CGameContext::ConTimerStart(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
char buf[128];
CServer* serv = (CServer*)pSelf->Server();
if(!g_Config.m_SvTimer)
{
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_RaceState = RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d Has time now (Timer Started)",cid1);
serv->SendRconLine(cid1, buf);
}
else
{
serv->SendRconLine(cid, "Command timer does't allowed");
}
}
void CGameContext::ConTimerZero(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!pSelf->CheatsAvailable(cid)) return;
@ -1469,7 +1477,28 @@ void CGameContext::ConTimerReset(IConsole::IResult *pResult, void *pUserData, in
return;
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();
str_format(buf, sizeof(buf), "Cid=%d time resetted.",cid1);
chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
}
void CGameContext::ConTimerReStart(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
if(!pSelf->CheatsAvailable(cid)) return;
char buf[128];
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
chr->m_StartTime = pSelf->Server()->Tick();
chr->m_RefreshTime = pSelf->Server()->Tick();
chr->m_RaceState=RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
@ -1480,29 +1509,31 @@ void CGameContext::OnConsoleInit()
m_pServer = Kernel()->RequestInterface<IServer>();
m_pConsole = Kernel()->RequestInterface<IConsole>();
Console()->Register("timer", "ii", CFGFLAG_SERVER, ConTimer, this, "Sets the timer of player i1 to i2 0/1 on/off",2);
Console()->Register("timerreset", "i", CFGFLAG_SERVER, ConTimerReset, this, "resets the timer of player i (to start count again timer cid 1)",1);
Console()->Register("timerstop", "i", CFGFLAG_SERVER, ConTimerStop, this, "Stops The Timer of Player i",2);
Console()->Register("timerstart", "i", CFGFLAG_SERVER, ConTimerStart, this, "Starts The Timer of Player i",2);
Console()->Register("timerrestart", "i", CFGFLAG_SERVER, ConTimerReStart, this, "Starts The Timer of Player i with the time of 00:00:00",2);
Console()->Register("timerzero", "i", CFGFLAG_SERVER, ConTimerZero, this, "00:00:00 the timer of Player i and Stops it",1);
Console()->Register("tele", "ii", CFGFLAG_SERVER, ConTeleport, this, "",2);
Console()->Register("tele", "ii", CFGFLAG_SERVER, ConTeleport, this, "Teleports Player i1 to i2",2);
Console()->Register("weapons", "i", CFGFLAG_SERVER, ConWeapons, this, "",2);
Console()->Register("weapons_me", "", CFGFLAG_SERVER, ConWeaponsMe, this, "",1);
Console()->Register("weapons", "i", CFGFLAG_SERVER, ConWeapons, this, "Give all weapons to player i",2);
Console()->Register("weapons_me", "", CFGFLAG_SERVER, ConWeaponsMe, this, "Give all weapons to self",1);
Console()->Register("super", "i", CFGFLAG_SERVER, ConSuper, this, "",2);
Console()->Register("unsuper", "i", CFGFLAG_SERVER, ConUnSuper, this, "",2);
Console()->Register("super_me", "", CFGFLAG_SERVER, ConSuperMe, this, "",1);
Console()->Register("unsuper_me", "", CFGFLAG_SERVER, ConUnSuperMe, this, "",1);// Mo
Console()->Register("super", "i", CFGFLAG_SERVER, ConSuper, this, "Make player i super",2);
Console()->Register("unsuper", "i", CFGFLAG_SERVER, ConUnSuper, this, "Remove super from player i",2);
Console()->Register("super_me", "", CFGFLAG_SERVER, ConSuperMe, this, "Make player self super",1);
Console()->Register("unsuper_me", "", CFGFLAG_SERVER, ConUnSuperMe, this, "Remove super from self",1);// Mo
Console()->Register("hammer_me", "i", CFGFLAG_SERVER, ConHammerMe, this, "",1);
Console()->Register("hammer", "ii", CFGFLAG_SERVER, ConHammer, this, "",2);
Console()->Register("hammer_me", "i", CFGFLAG_SERVER, ConHammerMe, this, "Sets the hammer of self to the power of i",1);
Console()->Register("hammer", "ii", CFGFLAG_SERVER, ConHammer, this, "Sets the hammer of player i1 to the power of i2",2);
Console()->Register("ninja", "i", CFGFLAG_SERVER, ConNinja, this, "",2);
Console()->Register("ninja_me", "", CFGFLAG_SERVER, ConNinjaMe, this, "",1);
Console()->Register("ninja", "i", CFGFLAG_SERVER, ConNinja, this, "Makes Player i have ninja power-up",2);
Console()->Register("ninja_me", "", CFGFLAG_SERVER, ConNinjaMe, this, "Makes self have ninja power-up",1);
Console()->Register("kill_pl", "i", CFGFLAG_SERVER, ConKillPlayer, this, "",2);
Console()->Register("auth", "ii", CFGFLAG_SERVER, ConSetlvl, this, "",3);
Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "", 2);
Console()->Register("kill_pl", "i", CFGFLAG_SERVER, ConKillPlayer, this, "Kills player with id i and announces the kill",2);
Console()->Register("auth", "ii", CFGFLAG_SERVER, ConSetlvl, this, "Authenticates player i1 to the level of i2 ( warining he can use sv_rcon_password_XXXX and get the passwords ) level 0 = logout",3);
Console()->Register("mute", "ii", CFGFLAG_SERVER, ConMute, this, "mutes player i1 for i2 seconds", 2);
Console()->Register("tune", "si", CFGFLAG_SERVER, ConTuneParam, this, "", 4);
Console()->Register("tune_reset", "", CFGFLAG_SERVER, ConTuneReset, this, "", 4);
@ -1571,18 +1602,29 @@ 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);
//CMapItemLayerTilemap *pFrontMap = m_Layers.FrontLayer(); not needed game layer and front layer are always the same size
CTile *pFront=0;
if (m_Layers.FrontLayer())
pFront = (CTile *)Kernel()->RequestInterface<IMap>()->GetData(pTileMap->m_Front);
//windows usually crshes here
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, Pos);
m_pController->OnEntity(Index-ENTITY_OFFSET, Pos,false);
}
if (pFront)
{
int FIndex = pFront[y*pTileMap->m_Width+x].m_Index;
if(FIndex >= ENTITY_OFFSET)
{
vec2 Pos(x*32.0f+16.0f, y*32.0f+16.0f);
m_pController->OnEntity(FIndex-ENTITY_OFFSET, Pos,true);
}
}
}
}

View file

@ -68,9 +68,10 @@ class CGameContext : public IGameServer
static void ConPhook(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerReset(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimer(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerStop(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerStart(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerReStart(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerZero(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConChangeMap(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConRestart(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConBroadcast(IConsole::IResult *pResult, void *pUserData, int cid);

View file

@ -117,23 +117,26 @@ bool IGameController::CanSpawn(CPlayer *pPlayer, vec2 *pOutPos)
return Eval.m_Got;
}
bool IGameController::OnEntity(int Index, vec2 Pos)
bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
{
if (Index<0)
return false;
dbg_msg("OnEntity","Index=%d Front=%d",Index,Front);//Remove*/
int Type = -1;
int SubType = 0;
int x,y;
x=(Pos.x-16.0f)/32.0f;
y=(Pos.y-16.0f)/32.0f;
dbg_msg("OnEntity","Pos(%d,%d)",x,y);
/*dbg_msg("OnEntity","Pos(%d,%d)",x,y);//Remove*/
int sides[8];
sides[0]=GameServer()->Collision()->Entitiy(x,y+1);
sides[1]=GameServer()->Collision()->Entitiy(x+1,y+1);
sides[2]=GameServer()->Collision()->Entitiy(x+1,y);
sides[3]=GameServer()->Collision()->Entitiy(x+1,y-1);
sides[4]=GameServer()->Collision()->Entitiy(x,y-1);
sides[5]=GameServer()->Collision()->Entitiy(x-1,y-1);
sides[6]=GameServer()->Collision()->Entitiy(x-1,y);
sides[7]=GameServer()->Collision()->Entitiy(x-1,y+1);
sides[0]=GameServer()->Collision()->Entity(x,y+1, Front);
sides[1]=GameServer()->Collision()->Entity(x+1,y+1, Front);
sides[2]=GameServer()->Collision()->Entity(x+1,y, Front);
sides[3]=GameServer()->Collision()->Entity(x+1,y-1, Front);
sides[4]=GameServer()->Collision()->Entity(x,y-1, Front);
sides[5]=GameServer()->Collision()->Entity(x-1,y-1, Front);
sides[6]=GameServer()->Collision()->Entity(x-1,y, Front);
sides[7]=GameServer()->Collision()->Entity(x-1,y+1, Front);
if(Index == ENTITY_SPAWN)
@ -152,7 +155,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
CDoor * door = new CDoor(&GameServer()->m_World, Pos, pi/4*i, 32*3 + 32*(sides[i] - ENTITY_LASER_SHORT)*3, false);
//for (int j = 0; j < 8; j++)
// if (j != i)
Connector(vec2(x, y), door);
Connector(vec2(x, y), door, Front);
}
}
}
@ -229,14 +232,14 @@ bool IGameController::OnEntity(int Index, vec2 Pos)
else if(Index >= ENTITY_LASER_FAST_CW && Index <= ENTITY_LASER_FAST_CCW)
{
int sides2[8];
sides2[0]=GameServer()->Collision()->Entitiy(x,y+2);
sides2[1]=GameServer()->Collision()->Entitiy(x+2,y+2);
sides2[2]=GameServer()->Collision()->Entitiy(x+2,y);
sides2[3]=GameServer()->Collision()->Entitiy(x+2,y-2);
sides2[4]=GameServer()->Collision()->Entitiy(x,y-2);
sides2[5]=GameServer()->Collision()->Entitiy(x-2,y-2);
sides2[6]=GameServer()->Collision()->Entitiy(x-2,y);
sides2[7]=GameServer()->Collision()->Entitiy(x-2,y+2);
sides2[0]=GameServer()->Collision()->Entity(x,y+2, Front);
sides2[1]=GameServer()->Collision()->Entity(x+2,y+2, Front);
sides2[2]=GameServer()->Collision()->Entity(x+2,y, Front);
sides2[3]=GameServer()->Collision()->Entity(x+2,y-2, Front);
sides2[4]=GameServer()->Collision()->Entity(x,y-2, Front);
sides2[5]=GameServer()->Collision()->Entity(x-2,y-2, Front);
sides2[6]=GameServer()->Collision()->Entity(x-2,y, Front);
sides2[7]=GameServer()->Collision()->Entity(x-2,y+2, Front);
float ang_speed;
int ind=Index-ENTITY_LASER_STOP;
@ -322,21 +325,21 @@ vec2 GetSidePos(int side) {
return vec2(0, 0);
}
void IGameController::Connector(vec2 Pos, CDoor* Door) {
void IGameController::Connector(vec2 Pos, CDoor* Door, bool Front) {
int sides[8];
sides[0] = GameServer()->Collision()->Entitiy(Pos.x, Pos.y + 1);
sides[1] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y + 1);
sides[2] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y);
sides[3] = GameServer()->Collision()->Entitiy(Pos.x + 1, Pos.y - 1);
sides[4] = GameServer()->Collision()->Entitiy(Pos.x, Pos.y - 1);
sides[5] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y - 1);
sides[6] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y);
sides[7] = GameServer()->Collision()->Entitiy(Pos.x - 1, Pos.y + 1);
sides[0] = GameServer()->Collision()->Entity(Pos.x, Pos.y + 1, Front);
sides[1] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y + 1, Front);
sides[2] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y, Front);
sides[3] = GameServer()->Collision()->Entity(Pos.x + 1, Pos.y - 1, Front);
sides[4] = GameServer()->Collision()->Entity(Pos.x, Pos.y - 1, Front);
sides[5] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y - 1, Front);
sides[6] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y, Front);
sides[7] = GameServer()->Collision()->Entity(Pos.x - 1, Pos.y + 1, Front);
for (int i=0;i<8;i++)
{
vec2 shift = GetSidePos(i);
if (sides[i]==ENTITY_CONNECTOR_D+(i+4) % 8)
Connector(Pos + shift, Door);
Connector(Pos + shift, Door, Front);
else if(sides[i]==ENTITY_TRIGGER)
{
vec2 pos((Pos.x + shift.x)*32.0f + 16.0f, (Pos.y + shift.y)*32.0f + 16.0f);

View file

@ -101,9 +101,9 @@ public:
Returns:
bool?
*/
virtual bool OnEntity(int Index, vec2 Pos);
virtual bool OnEntity(int Index, vec2 Pos, bool Front);
virtual void Connector(vec2 Pos, CDoor* Door);
virtual void Connector(vec2 Pos, CDoor* Door, bool Front);
/*
Function: on_CCharacter_spawn