This commit is contained in:
btd 2010-08-24 19:47:55 +04:00
commit d1f5bd4431
14 changed files with 395 additions and 412 deletions

View file

@ -252,7 +252,7 @@ Messages = [
NetIntRange("m_Pass", 0, 'MAX_CLIENTS'), NetIntRange("m_Pass", 0, 'MAX_CLIENTS'),
NetIntRange("m_Total", 0, 'MAX_CLIENTS'), NetIntRange("m_Total", 0, 'MAX_CLIENTS'),
]), ]),
### Client messages ### Client messages
NetMessage("Cl_Say", [ NetMessage("Cl_Say", [
NetBool("m_Team"), NetBool("m_Team"),

View file

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

View file

@ -8,6 +8,7 @@
//=============================== //===============================
/* DDRace */ /* 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_STR(SvEntities, sv_entities, 64, "Latest", CFGFLAG_SERVER, "The type of entities used") still need to think of a way
MACRO_CONFIG_INT(SvShotgunBulletSound, sv_shotgun_bullet_sound, 1, 0, 1, CFGFLAG_SERVER, "Annoying Shotgun sound on/off")
MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off") MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off")
MACRO_CONFIG_INT(SvEmotionalTees, sv_emotional_tees, 1, 0, 1, CFGFLAG_SERVER, "Emotional Tees on/off") MACRO_CONFIG_INT(SvEmotionalTees, sv_emotional_tees, 1, 0, 1, CFGFLAG_SERVER, "Emotional Tees on/off")
MACRO_CONFIG_INT(SvOldShotgun, sv_old_shotgun, 0, 0, 1, CFGFLAG_SERVER, "Makes Shotgun laser pull towards the shooter, rather than the last bounce origin") MACRO_CONFIG_INT(SvOldShotgun, sv_old_shotgun, 0, 0, 1, CFGFLAG_SERVER, "Makes Shotgun laser pull towards the shooter, rather than the last bounce origin")

View file

@ -27,7 +27,7 @@ CInputCount CountInput(int Prev, int Cur)
Prev &= INPUT_STATE_MASK; Prev &= INPUT_STATE_MASK;
Cur &= INPUT_STATE_MASK; Cur &= INPUT_STATE_MASK;
int i = Prev; int i = Prev;
while(i != Cur) while(i != Cur)
{ {
i = (i+1)&INPUT_STATE_MASK; i = (i+1)&INPUT_STATE_MASK;
@ -65,7 +65,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_ActiveWeapon = WEAPON_GUN; m_ActiveWeapon = WEAPON_GUN;
m_LastWeapon = WEAPON_HAMMER; m_LastWeapon = WEAPON_HAMMER;
m_QueuedWeapon = -1; m_QueuedWeapon = -1;
m_pPlayer = pPlayer; m_pPlayer = pPlayer;
m_Pos = Pos; m_Pos = Pos;
m_OlderPos = Pos; m_OlderPos = Pos;
@ -80,10 +80,10 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
m_ReckoningTick = 0; m_ReckoningTick = 0;
mem_zero(&m_SendCore, sizeof(m_SendCore)); mem_zero(&m_SendCore, sizeof(m_SendCore));
mem_zero(&m_ReckoningCore, sizeof(m_ReckoningCore)); mem_zero(&m_ReckoningCore, sizeof(m_ReckoningCore));
GameServer()->m_World.InsertEntity(this); GameServer()->m_World.InsertEntity(this);
m_Alive = true; m_Alive = true;
if(m_pPlayer->m_RconFreeze) Freeze(-1);
GameServer()->m_pController->OnCharacterSpawn(this); GameServer()->m_pController->OnCharacterSpawn(this);
return true; return true;
@ -99,12 +99,12 @@ void CCharacter::SetWeapon(int W)
{ {
if(W == m_ActiveWeapon) if(W == m_ActiveWeapon)
return; return;
m_LastWeapon = m_ActiveWeapon; m_LastWeapon = m_ActiveWeapon;
m_QueuedWeapon = -1; m_QueuedWeapon = -1;
m_ActiveWeapon = W; m_ActiveWeapon = W;
GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SWITCH); GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SWITCH);
if(m_ActiveWeapon < 0 || m_ActiveWeapon >= NUM_WEAPONS) if(m_ActiveWeapon < 0 || m_ActiveWeapon >= NUM_WEAPONS)
m_ActiveWeapon = 0; m_ActiveWeapon = 0;
} }
@ -123,7 +123,7 @@ void CCharacter::HandleNinja()
{ {
if(m_ActiveWeapon != WEAPON_NINJA) if(m_ActiveWeapon != WEAPON_NINJA)
return; return;
vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000)) if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
@ -137,7 +137,7 @@ void CCharacter::HandleNinja()
SetWeapon(m_ActiveWeapon); SetWeapon(m_ActiveWeapon);
return; return;
} }
// force ninja Weapon // force ninja Weapon
SetWeapon(WEAPON_NINJA); SetWeapon(WEAPON_NINJA);
@ -155,7 +155,7 @@ void CCharacter::HandleNinja()
m_Core.m_Vel = m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity; m_Core.m_Vel = m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
vec2 OldPos = m_Pos; vec2 OldPos = m_Pos;
GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f); GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(m_ProximityRadius, m_ProximityRadius), 0.f);
// reset velocity so the client doesn't predict stuff // reset velocity so the client doesn't predict stuff
m_Core.m_Vel = vec2(0.f, 0.f); m_Core.m_Vel = vec2(0.f, 0.f);
@ -171,7 +171,7 @@ void CCharacter::HandleNinja()
{ {
if (aEnts[i] == this) if (aEnts[i] == this)
continue; continue;
// make sure we haven't Hit this object before // make sure we haven't Hit this object before
bool bAlreadyHit = false; bool bAlreadyHit = false;
for (int j = 0; j < m_NumObjectsHit; j++) for (int j = 0; j < m_NumObjectsHit; j++)
@ -191,11 +191,11 @@ void CCharacter::HandleNinja()
// set his velocity to fast upward (for now) // set his velocity to fast upward (for now)
if(m_NumObjectsHit < 10) if(m_NumObjectsHit < 10)
m_apHitObjects[m_NumObjectsHit++] = aEnts[i]; m_apHitObjects[m_NumObjectsHit++] = aEnts[i];
aEnts[i]->TakeDamage(vec2(0, 10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA); aEnts[i]->TakeDamage(vec2(0, 10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA);
} }
} }
return; return;
} }
@ -218,7 +218,7 @@ void CCharacter::HandleWeaponSwitch()
int WantedWeapon = m_ActiveWeapon; int WantedWeapon = m_ActiveWeapon;
if(m_QueuedWeapon != -1) if(m_QueuedWeapon != -1)
WantedWeapon = m_QueuedWeapon; WantedWeapon = m_QueuedWeapon;
// select Weapon // select Weapon
int Next = CountInput(m_LatestPrevInput.m_NextWeapon, m_LatestInput.m_NextWeapon).m_Presses; int Next = CountInput(m_LatestPrevInput.m_NextWeapon, m_LatestInput.m_NextWeapon).m_Presses;
int Prev = CountInput(m_LatestPrevInput.m_PrevWeapon, m_LatestInput.m_PrevWeapon).m_Presses; int Prev = CountInput(m_LatestPrevInput.m_PrevWeapon, m_LatestInput.m_PrevWeapon).m_Presses;
@ -250,7 +250,7 @@ void CCharacter::HandleWeaponSwitch()
// check for insane values // check for insane values
if(WantedWeapon >= 0 && WantedWeapon < NUM_WEAPONS && WantedWeapon != m_ActiveWeapon && m_aWeapons[WantedWeapon].m_Got) if(WantedWeapon >= 0 && WantedWeapon < NUM_WEAPONS && WantedWeapon != m_ActiveWeapon && m_aWeapons[WantedWeapon].m_Got)
m_QueuedWeapon = WantedWeapon; m_QueuedWeapon = WantedWeapon;
DoWeaponSwitch(); DoWeaponSwitch();
} }
@ -258,10 +258,10 @@ void CCharacter::FireWeapon()
{ {
if(m_ReloadTimer != 0 /*|| m_FreezeTime > 0*/) if(m_ReloadTimer != 0 /*|| m_FreezeTime > 0*/)
return; return;
DoWeaponSwitch(); DoWeaponSwitch();
vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
bool FullAuto = false; bool FullAuto = false;
if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE) if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE)
FullAuto = true; FullAuto = true;
@ -271,13 +271,13 @@ void CCharacter::FireWeapon()
bool WillFire = false; bool WillFire = false;
if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses) if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses)
WillFire = true; WillFire = true;
if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo) if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo)
WillFire = true; WillFire = true;
if(!WillFire) if(!WillFire)
return; return;
// check for ammo // check for ammo
if(!m_aWeapons[m_ActiveWeapon].m_Ammo) if(!m_aWeapons[m_ActiveWeapon].m_Ammo)
{ {
@ -286,7 +286,7 @@ void CCharacter::FireWeapon()
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG); GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG);
return; return;
} }
vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f; vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f;
switch(m_ActiveWeapon) switch(m_ActiveWeapon)
{ {
@ -295,18 +295,18 @@ void CCharacter::FireWeapon()
// reset objects Hit // reset objects Hit
m_NumObjectsHit = 0; m_NumObjectsHit = 0;
GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE); GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);
if (!g_Config.m_SvHit) break; if (!g_Config.m_SvHit) break;
CCharacter *aEnts[64]; CCharacter *aEnts[64];
int Hits = 0; int Hits = 0;
int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)aEnts, int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)aEnts,
64, NETOBJTYPE_CHARACTER); 64, NETOBJTYPE_CHARACTER);
for (int i = 0; i < Num; ++i) for (int i = 0; i < Num; ++i)
{ {
CCharacter *Target = aEnts[i]; CCharacter *Target = aEnts[i];
//for DDRace mod or any other mod, which needs hammer hits through the wall remove second condition //for DDRace mod or any other mod, which needs hammer hits through the wall remove second condition
if ((Target == this) /*|| GameServer()->Collision()->IntersectLine(ProjStartPos, Target->m_Pos, NULL, NULL)*/) if ((Target == this) /*|| GameServer()->Collision()->IntersectLine(ProjStartPos, Target->m_Pos, NULL, NULL)*/)
continue; continue;
@ -314,22 +314,22 @@ void CCharacter::FireWeapon()
// set his velocity to fast upward (for now) // set his velocity to fast upward (for now)
GameServer()->CreateHammerHit(m_Pos); GameServer()->CreateHammerHit(m_Pos);
aEnts[i]->TakeDamage(vec2(0.f, -1.f), g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon); aEnts[i]->TakeDamage(vec2(0.f, -1.f), g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon);
vec2 Dir; vec2 Dir;
if (length(Target->m_Pos - m_Pos) > 0.0f) if (length(Target->m_Pos - m_Pos) > 0.0f)
Dir = normalize(Target->m_Pos - m_Pos); Dir = normalize(Target->m_Pos - m_Pos);
else else
Dir = vec2(0.f, -1.f); Dir = vec2(0.f, -1.f);
Target->m_Core.m_Vel += normalize(Dir + vec2(0.f, -1.1f)) * 10.0f * (m_HammerType + 1); Target->m_Core.m_Vel += normalize(Dir + vec2(0.f, -1.1f)) * 10.0f * (m_HammerType + 1);
Target->UnFreeze(); Target->UnFreeze();
Hits++; Hits++;
} }
// if we Hit anything, we have to wait for the reload // if we Hit anything, we have to wait for the reload
if(Hits) if(Hits)
m_ReloadTimer = Server()->TickSpeed()/3; m_ReloadTimer = Server()->TickSpeed()/3;
} break; } break;
case WEAPON_GUN: case WEAPON_GUN:
@ -339,26 +339,26 @@ void CCharacter::FireWeapon()
ProjStartPos, ProjStartPos,
Direction, Direction,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime), (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
0, 0,
0, 0,
0, 0,
-1, -1,
WEAPON_GUN); WEAPON_GUN);
// pack the Projectile and send it to the client Directly // pack the Projectile and send it to the client Directly
CNetObj_Projectile p; CNetObj_Projectile p;
Proj->FillInfo(&p); Proj->FillInfo(&p);
CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE); CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
Msg.AddInt(1); Msg.AddInt(1);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++) for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]); Msg.AddInt(((int *)&p)[i]);
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID()); Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE); GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE);
} break; } break;
case WEAPON_SHOTGUN: case WEAPON_SHOTGUN:
{ {
new CLaser(&GameServer()->m_World, m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID(), 1); new CLaser(&GameServer()->m_World, m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID(), 1);
@ -367,7 +367,7 @@ void CCharacter::FireWeapon()
CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE); CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
Msg.AddInt(ShotSpread*2+1); Msg.AddInt(ShotSpread*2+1);
for(int i = -ShotSpread; i <= ShotSpread; ++i) for(int i = -ShotSpread; i <= ShotSpread; ++i)
{ {
float Spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f}; float Spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
@ -381,17 +381,17 @@ void CCharacter::FireWeapon()
vec2(cosf(a), sinf(a))*Speed, vec2(cosf(a), sinf(a))*Speed,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_Shotm_GunLifetime), (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_Shotm_GunLifetime),
1, 0, 0, -1, WEAPON_SHOTGUN); 1, 0, 0, -1, WEAPON_SHOTGUN);
// pack the Projectile and send it to the client Directly // pack the Projectile and send it to the client Directly
CNetObj_Projectile p; CNetObj_Projectile p;
Proj->FillInfo(&p); Proj->FillInfo(&p);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++) for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]); Msg.AddInt(((int *)&p)[i]);
} }
Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID()); Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);*/ GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);*/
} break; } break;
@ -402,44 +402,44 @@ void CCharacter::FireWeapon()
ProjStartPos, ProjStartPos,
Direction, Direction,
(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime), (int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime),
0, 0,
true, true,
0, 0,
SOUND_GRENADE_EXPLODE, WEAPON_GRENADE); SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);
// pack the Projectile and send it to the client Directly // pack the Projectile and send it to the client Directly
CNetObj_Projectile p; CNetObj_Projectile p;
Proj->FillInfo(&p); Proj->FillInfo(&p);
CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE); CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
Msg.AddInt(1); Msg.AddInt(1);
for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++) for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
Msg.AddInt(((int *)&p)[i]); Msg.AddInt(((int *)&p)[i]);
Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID()); Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE); GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE);
} break; } break;
case WEAPON_RIFLE: case WEAPON_RIFLE:
{ {
new CLaser(GameWorld(), m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID(), 0); new CLaser(GameWorld(), m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID(), 0);
//GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE); //GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
} break; } break;
case WEAPON_NINJA: case WEAPON_NINJA:
{ {
// reset Hit objects // reset Hit objects
m_NumObjectsHit = 0; m_NumObjectsHit = 0;
m_AttackTick = Server()->Tick(); m_AttackTick = Server()->Tick();
m_Ninja.m_ActivationDir = Direction; m_Ninja.m_ActivationDir = Direction;
//m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000; //m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000;
m_Ninja.m_CurrentMoveTime = 10; m_Ninja.m_CurrentMoveTime = 10;
//GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE); //GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE);
} break; } break;
} }
m_AttackTick = Server()->Tick(); m_AttackTick = Server()->Tick();
/* /*
if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0) // -1 == unlimited if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0) // -1 == unlimited
@ -453,7 +453,7 @@ void CCharacter::HandleWeapons()
{ {
//ninja //ninja
HandleNinja(); HandleNinja();
vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY)); vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
// check reload timer // check reload timer
@ -495,9 +495,9 @@ void CCharacter::HandleWeapons()
bool CCharacter::GiveWeapon(int Weapon, int Ammo) bool CCharacter::GiveWeapon(int Weapon, int Ammo)
{ {
if(m_aWeapons[Weapon].m_Ammo < g_pData->m_Weapons.m_aId[Weapon].m_Maxammo || !m_aWeapons[Weapon].m_Got) if(m_aWeapons[Weapon].m_Ammo < g_pData->m_Weapons.m_aId[Weapon].m_Maxammo || !m_aWeapons[Weapon].m_Got)
{ {
m_aWeapons[Weapon].m_Got = true; m_aWeapons[Weapon].m_Got = true;
m_aWeapons[Weapon].m_Ammo = min(g_pData->m_Weapons.m_aId[Weapon].m_Maxammo, Ammo); if(!m_FreezeTime) m_aWeapons[Weapon].m_Ammo = min(g_pData->m_Weapons.m_aId[Weapon].m_Maxammo, Ammo);
return true; return true;
} }
return false; return false;
@ -509,7 +509,7 @@ void CCharacter::GiveNinja()
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA); GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA);
m_Ninja.m_ActivationTick = Server()->Tick(); m_Ninja.m_ActivationTick = Server()->Tick();
m_aWeapons[WEAPON_NINJA].m_Got = true; m_aWeapons[WEAPON_NINJA].m_Got = true;
m_aWeapons[WEAPON_NINJA].m_Ammo = -1; if (!m_FreezeTime) m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
m_LastWeapon = m_ActiveWeapon; m_LastWeapon = m_ActiveWeapon;
m_ActiveWeapon = WEAPON_NINJA; m_ActiveWeapon = WEAPON_NINJA;
} }
@ -525,27 +525,27 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
// check for changes // check for changes
if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0) if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0)
m_LastAction = Server()->Tick(); m_LastAction = Server()->Tick();
// copy new input // copy new input
mem_copy(&m_Input, pNewInput, sizeof(m_Input)); mem_copy(&m_Input, pNewInput, sizeof(m_Input));
m_NumInputs++; m_NumInputs++;
// or are not allowed to aim in the center // or are not allowed to aim in the center
if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0) if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0)
m_Input.m_TargetY = -1; m_Input.m_TargetY = -1;
} }
void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput) void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
{ {
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput)); mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput));
if(m_NumInputs > 2 && m_pPlayer->GetTeam() != -1) if(m_NumInputs > 2 && m_pPlayer->GetTeam() != -1)
{ {
HandleWeaponSwitch(); HandleWeaponSwitch();
FireWeapon(); FireWeapon();
} }
mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
} }
@ -560,22 +560,27 @@ void CCharacter::Tick()
char Buf[128]; char Buf[128];
str_format(Buf, sizeof(Buf), "You were moved to %s due to team balancing", GameServer()->m_pController->GetTeamName(m_pPlayer->GetTeam())); str_format(Buf, sizeof(Buf), "You were moved to %s due to team balancing", GameServer()->m_pController->GetTeamName(m_pPlayer->GetTeam()));
GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID()); GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID());
m_pPlayer->m_ForceBalanced = false; m_pPlayer->m_ForceBalanced = false;
} }
m_Armor=10-(m_FreezeTime/15); m_Armor=(m_FreezeTime != -1)?10-(m_FreezeTime/15):0;
if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0) if(m_Input.m_Direction != 0 || m_Input.m_Jump != 0)
m_LastMove = Server()->Tick(); m_LastMove = Server()->Tick();
if(m_FreezeTime > 0) { if(m_FreezeTime > 0 || m_FreezeTime == -1)
if (m_FreezeTime % Server()->TickSpeed() == 0) {
if (m_FreezeTime % Server()->TickSpeed() == 0 || m_FreezeTime == -1)
{ {
GameServer()->CreateDamageInd(m_Pos, 0, m_FreezeTime / Server()->TickSpeed()); GameServer()->CreateDamageInd(m_Pos, 0, m_FreezeTime / Server()->TickSpeed());
} }
m_FreezeTime--; if(m_FreezeTime != -1)
m_FreezeTime--;
else
m_Ninja.m_ActivationTick = Server()->Tick();
m_Input.m_Direction = 0; m_Input.m_Direction = 0;
m_Input.m_Jump = 0; m_Input.m_Jump = 0;
m_Input.m_Hook = 0; m_Input.m_Hook = 0;
//m_Input.m_Fire = 0; //m_Input.m_Fire = 0;
if (m_FreezeTime == 1) { if (m_FreezeTime == 1) {
UnFreeze(); UnFreeze();
@ -583,21 +588,21 @@ void CCharacter::Tick()
} }
m_Core.m_Input = m_Input; m_Core.m_Input = m_Input;
m_Core.Tick(true); m_Core.Tick(true);
m_DoSplash = false; m_DoSplash = false;
if (g_Config.m_SvEndlessDrag) if (g_Config.m_SvEndlessDrag)
m_Core.m_HookTick = 0; m_Core.m_HookTick = 0;
if (m_Super && m_Core.m_Jumped > 1) if (m_Super && m_Core.m_Jumped > 1)
m_Core.m_Jumped = 1; m_Core.m_Jumped = 1;
if (m_Super && g_Config.m_SvEndlessSuperHook) if (m_Super && g_Config.m_SvEndlessSuperHook)
m_Core.m_HookTick = 0; m_Core.m_HookTick = 0;
/*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/ /*dbg_msg("character","TileIndex1=%d , TileIndex2=%d",TileIndex1,TileIndex2); //REMOVE*/
//DDRace //DDRace
char aBuftime[128]; char aBuftime[128];
float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed()); float time = (float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed());
CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID()); CPlayerData *pData = GameServer()->Score()->PlayerData(m_pPlayer->GetCID());
if(Server()->Tick() - m_RefreshTime >= Server()->TickSpeed()) if(Server()->Tick() - m_RefreshTime >= Server()->TickSpeed())
{ {
if (m_RaceState == RACE_STARTED) { if (m_RaceState == RACE_STARTED) {
int IntTime = (int)time; int IntTime = (int)time;
@ -606,7 +611,7 @@ void CCharacter::Tick()
CNetMsg_Sv_RaceTime Msg; CNetMsg_Sv_RaceTime Msg;
Msg.m_Time = IntTime; Msg.m_Time = IntTime;
Msg.m_Check = 0; Msg.m_Check = 0;
if(m_CpActive != -1 && m_CpTick > Server()->Tick()) if(m_CpActive != -1 && m_CpTick > Server()->Tick())
{ {
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0) if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
@ -615,11 +620,11 @@ void CCharacter::Tick()
Msg.m_Check = (int)Diff; Msg.m_Check = (int)Diff;
} }
} }
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID()); Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, m_pPlayer->GetCID());
} else { } else {
str_format(aBuftime, sizeof(aBuftime), "Current Time: %d min %d sec", IntTime/60, IntTime%60); str_format(aBuftime, sizeof(aBuftime), "Current Time: %d min %d sec", IntTime/60, IntTime%60);
if(m_CpActive != -1 && m_CpTick > Server()->Tick()) if(m_CpActive != -1 && m_CpTick > Server()->Tick())
{ {
if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0) if(pData->m_BestTime && pData->m_aBestCpTime[m_CpActive] != 0)
@ -630,7 +635,7 @@ void CCharacter::Tick()
strcat(aBuftime, aTmp); strcat(aBuftime, aTmp);
} }
} }
if( g_Config.m_SvBroadcast[0] != 0) { if( g_Config.m_SvBroadcast[0] != 0) {
char aTmp[128]; char aTmp[128];
str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast); str_format(aTmp, sizeof(aTmp), "\n%s\n", g_Config.m_SvBroadcast);
@ -645,12 +650,12 @@ void CCharacter::Tick()
strcat(aBuftime, aTmp); strcat(aBuftime, aTmp);
GameServer()->SendBroadcast(g_Config.m_SvBroadcast, m_pPlayer->GetCID()); GameServer()->SendBroadcast(g_Config.m_SvBroadcast, m_pPlayer->GetCID());
} }
} }
m_RefreshTime = Server()->Tick(); m_RefreshTime = Server()->Tick();
} }
int cp = GameServer()->Collision()->IsCheckpoint(MapIndex); int cp = GameServer()->Collision()->IsCheckpoint(MapIndex);
if(cp != -1 && m_RaceState == RACE_STARTED) if(cp != -1 && m_RaceState == RACE_STARTED)
{ {
@ -673,7 +678,7 @@ void CCharacter::Tick()
GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf); GameServer()->SendChatTarget(m_pPlayer->GetCID(), aBuf);
else else
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
if(time - pData->m_BestTime < 0) if(time - pData->m_BestTime < 0)
{ {
// new record \o/ // new record \o/
@ -683,16 +688,16 @@ void CCharacter::Tick()
else else
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf); GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
} }
if(!pData->m_BestTime || time < pData->m_BestTime) if(!pData->m_BestTime || time < pData->m_BestTime)
{ {
// update the score // update the score
pData->Set(time, m_CpCurrent); pData->Set(time, m_CpCurrent);
if(str_comp_num(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0) if(str_comp_num(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
GameServer()->Score()->SaveScore(m_pPlayer->GetCID(), time, this); GameServer()->Score()->SaveScore(m_pPlayer->GetCID(), time, this);
} }
// update server best time // update server best time
if(!GameServer()->m_pController->m_CurrentRecord || time < GameServer()->m_pController->m_CurrentRecord) if(!GameServer()->m_pController->m_CurrentRecord || time < GameServer()->m_pController->m_CurrentRecord)
{ {
@ -700,13 +705,13 @@ void CCharacter::Tick()
if(str_comp_num(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0) if(str_comp_num(Server()->ClientName(m_pPlayer->GetCID()), "nameless tee", 12) != 0)
GameServer()->m_pController->m_CurrentRecord = time; GameServer()->m_pController->m_CurrentRecord = time;
} }
m_RaceState = RACE_NONE; m_RaceState = RACE_NONE;
// set player score // set player score
if(!GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime || GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime > time) if(!GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime || GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime > time)
{ {
GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime = time; GameServer()->Score()->PlayerData(m_pPlayer->GetCID())->m_CurrentTime = time;
// send it to all players // send it to all players
for(int i = 0; i < MAX_CLIENTS; i++) for(int i = 0; i < MAX_CLIENTS; i++)
{ {
@ -726,11 +731,11 @@ void CCharacter::Tick()
} }
} }
} }
int TTime = 0-(int)time; int TTime = 0-(int)time;
if(m_pPlayer->m_Score < TTime) if(m_pPlayer->m_Score < TTime)
m_pPlayer->m_Score = TTime; m_pPlayer->m_Score = TTime;
} }
if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super) if(((TileIndex1 == TILE_FREEZE) || (TileIndex2 == TILE_FREEZE)) && !m_Super)
{ {
@ -819,64 +824,67 @@ void CCharacter::Tick()
{ {
if(m_PrevPos.x-m_Pos.x<0) if(m_PrevPos.x-m_Pos.x<0)
m_Core.m_Vel.x += m_Core.m_Vel.x *-0.5; m_Core.m_Vel.x += m_Core.m_Vel.x *-0.5;
else else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)
m_Core.m_Vel.x += m_Core.m_Vel.x*0.5; m_Core.m_Vel.x += m_Core.m_Vel.x*0.5;
} }
if (TileIndex1 == TILE_BOOST_R || TileIndex2 == TILE_BOOST_R) if (TileIndex1 == TILE_BOOST_R || TileIndex2 == TILE_BOOST_R)
{ {
if(m_PrevPos.x-m_Pos.x>0) if(m_PrevPos.x-m_Pos.x>0)
m_Core.m_Vel.x += m_Core.m_Vel.x *-0.5; m_Core.m_Vel.x += m_Core.m_Vel.x *-0.5;
else else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)
m_Core.m_Vel.x += m_Core.m_Vel.x*0.5; m_Core.m_Vel.x += m_Core.m_Vel.x*0.5;
} }
if (TileIndex1 == TILE_BOOST_D || TileIndex2 == TILE_BOOST_D) if (TileIndex1 == TILE_BOOST_D || TileIndex2 == TILE_BOOST_D)
{ {
if(m_PrevPos.y-m_Pos.y>0) if(m_PrevPos.y-m_Pos.y>0)
m_Core.m_Vel.y += m_Core.m_Vel.y *-0.5; m_Core.m_Vel.y += m_Core.m_Vel.y *-0.5;
else else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)
m_Core.m_Vel.y += m_Core.m_Vel.y*0.5; m_Core.m_Vel.y += m_Core.m_Vel.y*0.5;
} }
if (TileIndex1 == TILE_BOOST_U || TileIndex2 == TILE_BOOST_U) if (TileIndex1 == TILE_BOOST_U || TileIndex2 == TILE_BOOST_U)
{ {
if(m_PrevPos.y-m_Pos.y<0) if(m_PrevPos.y-m_Pos.y<0)
m_Core.m_Vel.y += m_Core.m_Vel.y *-0.5; m_Core.m_Vel.y += m_Core.m_Vel.y *-0.5;
else else if(m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2)
m_Core.m_Vel.y += m_Core.m_Vel.y*0.5; m_Core.m_Vel.y += m_Core.m_Vel.y*0.5;
} }
if (TileIndex1 == TILE_BOOST_L2 || TileIndex2 == TILE_BOOST_L2) if ((TileIndex1 == TILE_BOOST_L2 || TileIndex2 == TILE_BOOST_L2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2))
{ {
if(m_PrevPos.x-m_Pos.x<0) if(m_PrevPos.x-m_Pos.x<0)
m_Core.m_Vel.x = m_Core.m_Vel.x *-1.1; m_Core.m_Vel.x = m_Core.m_Vel.x *-1.1;
else else
m_Core.m_Vel.x += m_Core.m_Vel.x*1.1; m_Core.m_Vel.x += m_Core.m_Vel.x*1.1;
} }
if (TileIndex1 == TILE_BOOST_R2|| TileIndex2 == TILE_BOOST_R2) if ((TileIndex1 == TILE_BOOST_R2|| TileIndex2 == TILE_BOOST_R2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2))
{ {
if(m_PrevPos.x-m_Pos.x>0) if(m_PrevPos.x-m_Pos.x>0)
m_Core.m_Vel.x = m_Core.m_Vel.x *-1.1; m_Core.m_Vel.x = m_Core.m_Vel.x *-1.1;
else else
m_Core.m_Vel.x += m_Core.m_Vel.x*1.1; m_Core.m_Vel.x += m_Core.m_Vel.x*1.1;
} }
if (TileIndex1 == TILE_BOOST_D2 || TileIndex2 == TILE_BOOST_D2) if ((TileIndex1 == TILE_BOOST_D2 || TileIndex2 == TILE_BOOST_D2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2))
{ {
if(m_PrevPos.y-m_Pos.y>0) if(m_PrevPos.y-m_Pos.y>0)
m_Core.m_Vel.y = m_Core.m_Vel.y *-1.1; m_Core.m_Vel.y = m_Core.m_Vel.y *-1.1;
else else
m_Core.m_Vel.y += m_Core.m_Vel.y*1.1; m_Core.m_Vel.y += m_Core.m_Vel.y*1.1;
} }
if (TileIndex1 == TILE_BOOST_U2 || TileIndex2 == TILE_BOOST_U2) if ((TileIndex1 == TILE_BOOST_U2 || TileIndex2 == TILE_BOOST_U2) && (m_LastBooster != TileIndex1 || m_LastFBooster != TileIndex2))
{ {
if(m_PrevPos.y-m_Pos.y<0) if(m_PrevPos.y-m_Pos.y<0)
m_Core.m_Vel.y = m_Core.m_Vel.y *-1.1; m_Core.m_Vel.y = m_Core.m_Vel.y *-1.1;
else else
m_Core.m_Vel.y += m_Core.m_Vel.y*1.1; m_Core.m_Vel.y += m_Core.m_Vel.y*1.1;
} }
m_LastBooster = TileIndex1;
m_LastFBooster = TileIndex2;
// handle speedup tiles
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; vec2 Direction;
int Force; int Force;
GameServer()->Collision()->GetSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y, &Direction, &Force); GameServer()->Collision()->GetSpeedup((int)m_Core.m_Pos.x, (int)m_Core.m_Pos.y, &Direction, &Force);
m_Core.m_Vel += Direction*Force; m_Core.m_Vel += Direction*Force;
} }
if(z) if(z)
@ -888,7 +896,7 @@ void CCharacter::Tick()
m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[z-1]; m_Core.m_Pos = ((CGameControllerDDRace*)GameServer()->m_pController)->m_pTeleporter[z-1];
m_Core.m_HookPos = m_Core.m_Pos; m_Core.m_HookPos = m_Core.m_Pos;
} }
// handle death-tiles // handle death-tiles
if((GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH || if((GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&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 ||
@ -909,7 +917,7 @@ void CCharacter::Tick()
{ {
Die(m_pPlayer->GetCID(), WEAPON_WORLD); Die(m_pPlayer->GetCID(), WEAPON_WORLD);
} }
// handle Weapons // handle Weapons
HandleWeapons(); HandleWeapons();
@ -920,36 +928,36 @@ void CCharacter::Tick()
if (!m_Doored) if (!m_Doored)
{ {
m_OlderPos = m_OldPos; m_OlderPos = m_OldPos;
m_OldPos = m_Core.m_Pos; m_OldPos = m_Core.m_Pos;
} }
m_PrevPos = m_Core.m_Pos; m_PrevPos = m_Core.m_Pos;
return; return;
} }
float point_distance(vec2 point, vec2 line_start, vec2 line_end) float point_distance(vec2 point, vec2 line_start, vec2 line_end)
{ {
float res = -1.0f; float res = -1.0f;
vec2 dir = normalize(line_end-line_start); vec2 dir = normalize(line_end-line_start);
for(int i = 0; i < length(line_end-line_start); i++) for(int i = 0; i < length(line_end-line_start); i++)
{ {
vec2 step = dir; vec2 step = dir;
step.x *= i; step.x *= i;
step.y *= i; step.y *= i;
float dist = distance(step+line_start, point); float dist = distance(step+line_start, point);
if(res < 0 || dist < res) if(res < 0 || dist < res)
res = dist; res = dist;
} }
return res; return res;
} }
void CCharacter::ResetPos() void CCharacter::ResetPos()
{ {
m_Core.m_Pos = m_OlderPos; m_Core.m_Pos = m_OlderPos;
//core.pos-=core.vel; //core.pos-=core.vel;
m_Core.m_Vel = vec2(0,0); m_Core.m_Vel = vec2(0,0);
if(m_Core.m_Jumped >= 2) if(m_Core.m_Jumped >= 2)
m_Core.m_Jumped = 1; m_Core.m_Jumped = 1;
} }
void CCharacter::TickDefered() void CCharacter::TickDefered()
{ {
@ -961,12 +969,12 @@ void CCharacter::TickDefered()
m_ReckoningCore.Move(); m_ReckoningCore.Move();
m_ReckoningCore.Quantize(); m_ReckoningCore.Quantize();
} }
//lastsentcore //lastsentcore
vec2 StartPos = m_Core.m_Pos; vec2 StartPos = m_Core.m_Pos;
vec2 StartVel = m_Core.m_Vel; vec2 StartVel = m_Core.m_Vel;
bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f)); bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
m_Core.Move(); m_Core.Move();
if(m_Doored) if(m_Doored)
{ {
@ -977,7 +985,7 @@ void CCharacter::TickDefered()
m_Core.Quantize(); m_Core.Quantize();
bool StuckAfterQuant = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f)); bool StuckAfterQuant = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
m_Pos = m_Core.m_Pos; m_Pos = m_Core.m_Pos;
if(!StuckBefore && (StuckAfterMove || StuckAfterQuant)) if(!StuckBefore && (StuckAfterMove || StuckAfterQuant))
{ {
// Hackish solution to get rid of strict-aliasing warning // Hackish solution to get rid of strict-aliasing warning
@ -992,7 +1000,7 @@ void CCharacter::TickDefered()
StartVelX.f = StartVel.x; StartVelX.f = StartVel.x;
StartVelY.f = StartVel.y; StartVelY.f = StartVel.y;
dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x",
StuckBefore, StuckBefore,
StuckAfterMove, StuckAfterMove,
StuckAfterQuant, StuckAfterQuant,
@ -1004,20 +1012,20 @@ void CCharacter::TickDefered()
int Events = m_Core.m_TriggeredEvents; int Events = m_Core.m_TriggeredEvents;
int Mask = CmaskAllExceptOne(m_pPlayer->GetCID()); int Mask = CmaskAllExceptOne(m_pPlayer->GetCID());
if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Mask); if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Mask);
if(Events&COREEVENT_HOOK_ATTACH_PLAYER) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, CmaskAll()); if(Events&COREEVENT_HOOK_ATTACH_PLAYER) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, CmaskAll());
if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Mask); if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Mask);
if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Mask); if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Mask);
if(m_pPlayer->GetTeam() == -1) if(m_pPlayer->GetTeam() == -1)
{ {
m_Pos.x = m_Input.m_TargetX; m_Pos.x = m_Input.m_TargetX;
m_Pos.y = m_Input.m_TargetY; m_Pos.y = m_Input.m_TargetY;
} }
// update the m_SendCore if needed // update the m_SendCore if needed
{ {
CNetObj_Character Predicted; CNetObj_Character Predicted;
@ -1039,80 +1047,71 @@ void CCharacter::TickDefered()
} }
bool CCharacter::Freeze(int Time) bool CCharacter::Freeze(int Time)
{ {
if (Time <= 1 || m_Super) if ((Time <= 1 || m_Super || m_FreezeTime == -1) && Time != -1)
return false; return false;
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed()) if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed())
{ {
for(int i=0;i<NUM_WEAPONS;i++)
if(m_aWeapons[i].m_Got)
{
m_aWeapons[i].m_Ammo = 0;
}
m_Armor=0; m_Armor=0;
m_Ninja.m_ActivationTick = Server()->Tick();
m_aWeapons[WEAPON_NINJA].m_Got = true;
m_aWeapons[WEAPON_NINJA].m_Ammo = 0;
m_LastWeapon = m_ActiveWeapon;
m_ActiveWeapon = WEAPON_NINJA;
m_FreezeTick=Server()->Tick();
m_FreezeTime=Time; m_FreezeTime=Time;
m_FreezeTick=Server()->Tick();
return true; return true;
} }
return false; return false;
} }
bool CCharacter::Freeze() bool CCharacter::Freeze()
{ {
int Time = Server()->TickSpeed()*3; int Time = Server()->TickSpeed()*3;
if (Time <= 1 || m_Super) if (Time <= 1 || m_Super || m_FreezeTime == -1)
return false; return false;
if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed()) if (m_FreezeTick < Server()->Tick() - Server()->TickSpeed())
{ {
for(int i=0;i<NUM_WEAPONS;i++)
if(m_aWeapons[i].m_Got)
{
m_aWeapons[i].m_Ammo = 0;
}
m_Armor=0; m_Armor=0;
m_Ninja.m_ActivationTick = Server()->Tick(); m_Ninja.m_ActivationTick = Server()->Tick();
m_aWeapons[WEAPON_NINJA].m_Got = true;
m_aWeapons[WEAPON_NINJA].m_Ammo = 0;
m_LastWeapon = m_ActiveWeapon;
m_ActiveWeapon = WEAPON_NINJA;
m_FreezeTick=Server()->Tick();
m_FreezeTime=Time; m_FreezeTime=Time;
m_FreezeTick=Server()->Tick();
return true; return true;
} }
return false; return false;
} }
bool CCharacter::UnFreeze() bool CCharacter::UnFreeze()
{ {
if (m_FreezeTime>0) if (m_FreezeTime>0)
{ {
m_Armor=10; m_Armor=10;
m_FreezeTick=0; for(int i=0;i<NUM_WEAPONS;i++)
if(m_aWeapons[i].m_Got)
{
m_aWeapons[i].m_Ammo = -1;
}
if(!m_aWeapons[m_ActiveWeapon].m_Got) m_ActiveWeapon=WEAPON_GUN;
m_FreezeTime=0; m_FreezeTime=0;
m_aWeapons[WEAPON_NINJA].m_Got = false; return true;
m_ActiveWeapon = m_LastWeapon;
if(m_ActiveWeapon == WEAPON_NINJA)
m_ActiveWeapon = WEAPON_GUN;
SetWeapon(m_ActiveWeapon);
m_Ninja.m_ActivationDir=vec2(0,0);
m_Ninja.m_ActivationTick=0;
m_Ninja.m_CurrentMoveTime=0;
for(int i=0;i<WEAPON_NINJA;i++)
{
if (m_aWeapons[i].m_Got)
{
m_aWeapons[i].m_Ammo = -1;
}
}
return true;
} }
return false; return false;
} }
void CCharacter::GiveAllWeapons() void CCharacter::GiveAllWeapons()
{ {
for(int i=1;i<NUM_WEAPONS-1;i++) for(int i=1;i<NUM_WEAPONS-1;i++)
{ {
m_aWeapons[i].m_Got = true; m_aWeapons[i].m_Got = true;
m_aWeapons[i].m_Ammo = -1; if(!m_FreezeTime) m_aWeapons[i].m_Ammo = -1;
} }
return; return;
} }
bool CCharacter::IncreaseHealth(int Amount) bool CCharacter::IncreaseHealth(int Amount)
{ {
@ -1148,15 +1147,15 @@ void CCharacter::Die(int Killer, int Weapon)
// a nice sound // a nice sound
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE); GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE);
// this is for auto respawn after 3 secs // this is for auto respawn after 3 secs
m_pPlayer->m_DieTick = Server()->Tick(); m_pPlayer->m_DieTick = Server()->Tick();
m_Alive = false; m_Alive = false;
GameServer()->m_World.RemoveEntity(this); GameServer()->m_World.RemoveEntity(this);
GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0; GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID()); GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID());
// we got to wait 0.5 secs before respawning // we got to wait 0.5 secs before respawning
m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2; m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
} }
@ -1195,7 +1194,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
m_Health--; m_Health--;
Dmg--; Dmg--;
} }
if(Dmg > m_Armor) if(Dmg > m_Armor)
{ {
Dmg -= m_Armor; Dmg -= m_Armor;
@ -1207,7 +1206,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
Dmg = 0; Dmg = 0;
} }
} }
m_Health -= Dmg; m_Health -= Dmg;
} }
@ -1221,9 +1220,9 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
if(m_Health <= 0) if(m_Health <= 0)
{ {
Die(From, Weapon); Die(From, Weapon);
return false; return false;
} }
@ -1255,9 +1254,9 @@ void CCharacter::Snap(int SnappingClient)
{ {
if(NetworkClipped(SnappingClient)) if(NetworkClipped(SnappingClient))
return; return;
CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character))); CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character)));
// write down the m_Core // write down the m_Core
if(!m_ReckoningTick || GameServer()->m_World.m_Paused) if(!m_ReckoningTick || GameServer()->m_World.m_Paused)
{ {
@ -1271,7 +1270,7 @@ void CCharacter::Snap(int SnappingClient)
Character->m_Tick = m_ReckoningTick; Character->m_Tick = m_ReckoningTick;
m_SendCore.Write(Character); m_SendCore.Write(Character);
} }
if(m_DoSplash) { if(m_DoSplash) {
Character->m_Jumped = 3; Character->m_Jumped = 3;
} }
@ -1287,13 +1286,14 @@ void CCharacter::Snap(int SnappingClient)
Character->m_AmmoCount = 0; Character->m_AmmoCount = 0;
Character->m_Health = 0; Character->m_Health = 0;
Character->m_Armor = 0; Character->m_Armor = 0;
if (m_FreezeTime > 0) if (m_FreezeTime > 0 || m_FreezeTime == -1)
{ {
Character->m_Emote = EMOTE_PAIN; Character->m_Emote = EMOTE_PAIN;
Character->m_Weapon = WEAPON_NINJA; Character->m_Weapon = WEAPON_NINJA;
Character->m_AmmoCount = 0;
} }
else else
Character->m_Weapon = m_ActiveWeapon; Character->m_Weapon = m_ActiveWeapon;
Character->m_AttackTick = m_AttackTick; Character->m_AttackTick = m_AttackTick;
@ -1304,7 +1304,7 @@ void CCharacter::Snap(int SnappingClient)
Character->m_Health = m_Health; Character->m_Health = m_Health;
Character->m_Armor = m_Armor; Character->m_Armor = m_Armor;
if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0) if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0)
Character->m_AmmoCount = m_aWeapons[m_ActiveWeapon].m_Ammo; Character->m_AmmoCount = (!m_FreezeTime)?m_aWeapons[m_ActiveWeapon].m_Ammo:0;
} }
if (Character->m_Emote == EMOTE_NORMAL) if (Character->m_Emote == EMOTE_NORMAL)

View file

@ -161,7 +161,8 @@ public:
int m_StartTime; int m_StartTime;
int m_RefreshTime; int m_RefreshTime;
int m_LastSpeedup; int m_LastBooster;
int m_LastFBooster;
vec2 m_PrevPos; vec2 m_PrevPos;
// checkpoints // checkpoints

View file

@ -72,30 +72,28 @@ void CPickup::Tick()
{ {
if (pChr->m_aWeapons[i].m_Got) if (pChr->m_aWeapons[i].m_Got)
{ {
pChr->m_aWeapons[i].m_Got = false; if(!(pChr->m_FreezeTime && i == WEAPON_NINJA))
pChr->m_aWeapons[i].m_Ammo = 0; {
sound = true; pChr->m_aWeapons[i].m_Got = false;
pChr->m_aWeapons[i].m_Ammo = 0;
sound = true;
}
} }
if(pChr->m_FreezeTime)
{
pChr->m_aWeapons[WEAPON_GUN].m_Ammo = 0;
pChr->m_aWeapons[WEAPON_HAMMER].m_Ammo =0;
}
pChr->m_Ninja.m_ActivationDir=vec2(0,0);
pChr->m_Ninja.m_ActivationTick=0;
pChr->m_Ninja.m_CurrentMoveTime=0;
} }
pChr->m_Ninja.m_ActivationDir=vec2(0,0);
pChr->m_Ninja.m_ActivationTick=-500;
pChr->m_Ninja.m_CurrentMoveTime=0;
if (sound) if (sound)
{ {
pChr->m_LastWeapon = WEAPON_GUN; pChr->m_LastWeapon = WEAPON_GUN;
GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR); GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
} }
pChr->m_ActiveWeapon = WEAPON_HAMMER; if(!pChr->m_FreezeTime) pChr->m_ActiveWeapon = WEAPON_HAMMER;
break; break;
case POWERUP_WEAPON: case POWERUP_WEAPON:
if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->m_aWeapons[m_Subtype].m_Got || pChr->m_aWeapons[m_Subtype].m_Ammo != -1)) if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->m_aWeapons[m_Subtype].m_Got || (pChr->m_aWeapons[m_Subtype].m_Ammo != -1 && !pChr->m_FreezeTime)))
{ {
if(pChr->GiveWeapon(m_Subtype, -1)) if(pChr->GiveWeapon(m_Subtype, -1))
{ {
@ -117,7 +115,7 @@ void CPickup::Tick()
case POWERUP_NINJA: case POWERUP_NINJA:
{ {
// activate ninja on target player // activate ninja on target player
pChr->GiveNinja(); if(!pChr->m_FreezeTime) pChr->GiveNinja();
//RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime; //RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
break; break;

View file

@ -3,8 +3,18 @@
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include "projectile.h" #include "projectile.h"
CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos, vec2 Dir, int Span, CProjectile::CProjectile(
bool Freeze, bool Explosive, float Force, int SoundImpact, int Weapon) CGameWorld *pGameWorld,
int Type,
int Owner,
vec2 Pos,
vec2 Dir,
int Span,
bool Freeze,
bool Explosive,
float Force,
int SoundImpact,
int Weapon)
: CEntity(pGameWorld, NETOBJTYPE_PROJECTILE) : CEntity(pGameWorld, NETOBJTYPE_PROJECTILE)
{ {
m_Type = Type; m_Type = Type;
@ -19,6 +29,11 @@ CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos,
m_Weapon = Weapon; m_Weapon = Weapon;
m_StartTick = Server()->Tick(); m_StartTick = Server()->Tick();
m_Explosive = Explosive; m_Explosive = Explosive;
m_BouncePos=vec2(0,0);
m_ReBouncePos=vec2(0,0);
m_AvgPos=vec2(0,0);
m_LastBounce=vec2(0,0);
m_PrevLastBounce=vec2(0,0);
GameWorld()->InsertEntity(this); GameWorld()->InsertEntity(this);
} }
@ -55,7 +70,8 @@ vec2 CProjectile::GetPos(float Time)
return CalcPos(m_Pos, m_Direction, Curvature, Speed, Time); return CalcPos(m_Pos, m_Direction, Curvature, Speed, Time);
} }
void CProjectile::SetBouncing(int Value) { void CProjectile::SetBouncing(int Value)
{
m_Bouncing = Value; m_Bouncing = Value;
} }
@ -96,9 +112,62 @@ void CProjectile::Tick()
m_StartTick = Server()->Tick(); m_StartTick = Server()->Tick();
m_Pos = NewPos; m_Pos = NewPos;
if (m_Bouncing == 1) if (m_Bouncing == 1)
m_Direction.x = -m_Direction.x; {
m_PrevLastBounce.x = m_LastBounce.x;
m_LastBounce.x = m_Pos.x;
if(!m_BouncePos.x)
m_BouncePos.x=m_Pos.x;
else if (!m_ReBouncePos.x)
m_ReBouncePos.x=m_Pos.x;
else if(!m_AvgPos.x)
m_AvgPos = vec2((m_BouncePos.x+m_ReBouncePos.x)/2,(m_BouncePos.y+m_ReBouncePos.y)/2);
if (m_AvgPos.x)
if(!((m_PrevLastBounce.x+1 == m_BouncePos.x || m_PrevLastBounce.x-1 == m_BouncePos.x || m_PrevLastBounce.x == m_BouncePos.x) && (m_LastBounce.x == m_ReBouncePos.x || m_LastBounce.x+1 == m_ReBouncePos.x || m_LastBounce.x-1 == m_ReBouncePos.x)) && !((m_LastBounce.x == m_BouncePos.x || m_LastBounce.x+1 == m_BouncePos.x || m_LastBounce.x-1 == m_BouncePos.x) && (m_PrevLastBounce.x+1 == m_ReBouncePos.x || m_PrevLastBounce.x-1 == m_ReBouncePos.x || m_PrevLastBounce.x == m_ReBouncePos.x)))
{
/*int bx=(int)m_BouncePos.x;
int rbx=(int)m_ReBouncePos.x;
int lbx=(int)m_LastBounce.x;
int plbx=(int)m_PrevLastBounce.x;
dbg_msg("m_BouncePos","%d",bx);
dbg_msg("m_ReBouncePos","%d",rbx);
dbg_msg("m_LastBounce","%d",lbx);
dbg_msg("m_PrevLastBounce","%d",plbx);
m_Pos.x=m_AvgPos.x;*/
dbg_msg("CrazyShotgun","Warning Horizontal Crazy Shotgun Out of bounds");
/*int x=(int)m_Pos.x;
dbg_msg("RePos","%d",x);*/
}
m_Direction.x =- m_Direction.x;
}
else if (m_Bouncing == 2) else if (m_Bouncing == 2)
{
m_PrevLastBounce.y = m_LastBounce.y;
m_LastBounce.y = m_Pos.y;
if(!m_BouncePos.y)
m_BouncePos.y=m_Pos.y;
else if (!m_ReBouncePos.y)
m_ReBouncePos.y=m_Pos.y;
else if(!m_AvgPos.y)
m_AvgPos = vec2((m_BouncePos.x+m_ReBouncePos.x)/2,(m_BouncePos.y+m_ReBouncePos.y)/2);
m_Direction.y =- m_Direction.y; m_Direction.y =- m_Direction.y;
if (m_AvgPos.y)
if(!((m_PrevLastBounce.y+1 == m_BouncePos.y || m_PrevLastBounce.y-1 == m_BouncePos.y || m_PrevLastBounce.y == m_BouncePos.y) && (m_LastBounce.y == m_ReBouncePos.y || m_LastBounce.y+1 == m_ReBouncePos.y || m_LastBounce.y-1 == m_ReBouncePos.y)) && !((m_LastBounce.y == m_BouncePos.y || m_LastBounce.y+1 == m_BouncePos.y || m_LastBounce.y-1 == m_BouncePos.y) && (m_PrevLastBounce.y+1 == m_ReBouncePos.y || m_PrevLastBounce.y-1 == m_ReBouncePos.y || m_PrevLastBounce.y == m_ReBouncePos.y)))
{
/*int by=(int)m_BouncePos.y;
int rby=(int)m_ReBouncePos.y;
int lby=(int)m_LastBounce.y;
int plby=(int)m_PrevLastBounce.y;
dbg_msg("m_BouncePos","%d",by);
dbg_msg("m_ReBouncePos","%d",rby);
dbg_msg("m_LastBounce","%d",lby);
dbg_msg("m_PrevLastBounce","%d",plby);*/
m_Pos=m_AvgPos;
dbg_msg("CrazyShotgun","Warning Vertical Crazy Shotgun Out of bounds");
/*int y=(int)m_Pos.y;
dbg_msg("RePos","%d",y);*/
}
}
m_Pos += m_Direction; m_Pos += m_Direction;
} }
else if (m_Weapon == WEAPON_GUN) else if (m_Weapon == WEAPON_GUN)
@ -114,6 +183,9 @@ void CProjectile::Tick()
{ {
GameServer()->m_World.DestroyEntity(this); GameServer()->m_World.DestroyEntity(this);
} }
} }
void CProjectile::FillInfo(CNetObj_Projectile *pProj) void CProjectile::FillInfo(CNetObj_Projectile *pProj)

View file

@ -29,6 +29,11 @@ private:
int m_Bouncing; int m_Bouncing;
bool m_Freeze; bool m_Freeze;
bool m_Collised; bool m_Collised;
vec2 m_AvgPos;
vec2 m_BouncePos;
vec2 m_ReBouncePos;
vec2 m_LastBounce;
vec2 m_PrevLastBounce;
}; };
#endif #endif

View file

@ -1374,7 +1374,7 @@ void CGameContext::ConSetlvl(IConsole::IResult *pResult, void *pUserData, int c
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
int level = clamp(pResult->GetInteger(1), 0, 3); int level = clamp(pResult->GetInteger(1), 0, 3);
if (pSelf->m_apPlayers[cid1] && (pSelf->m_apPlayers[cid1]->m_Authed > level) && (compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))) if (pSelf->m_apPlayers[cid1] && (pSelf->m_apPlayers[cid1]->m_Authed > level) && (compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]) || cid == cid1))
{ {
pSelf->m_apPlayers[cid1]->m_Authed = level; pSelf->m_apPlayers[cid1]->m_Authed = level;
} }
@ -1412,10 +1412,14 @@ void CGameContext::ConNinja(IConsole::IResult *pResult, void *pUserData, int cid
if(!pSelf->CheatsAvailable(cid)) return; if(!pSelf->CheatsAvailable(cid)) return;
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1); int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
CCharacter* chr = pSelf->GetPlayerChar(cid1); CCharacter* chr = pSelf->GetPlayerChar(cid1);
if(chr) { if(chr)
chr->GiveNinja(); {
if(!g_Config.m_SvCheatTime) if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
chr->m_RaceState = RACE_CHEAT; {
chr->GiveNinja();
if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT;
}
} }
} }
@ -1438,11 +1442,14 @@ void CGameContext::ConHammer(IConsole::IResult *pResult, void *pUserData, int ci
} }
else else
{ {
chr->m_HammerType = type; if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
if(!g_Config.m_SvCheatTime) {
chr->m_RaceState = RACE_CHEAT; chr->m_HammerType = type;
str_format(buf, sizeof(buf), "Hammer of cid=%d setted to %d",cid1,type); if(!g_Config.m_SvCheatTime)
serv->SendRconLine(cid1, buf); chr->m_RaceState = RACE_CHEAT;
str_format(buf, sizeof(buf), "Hammer of cid=%d setted to %d",cid1,type);
serv->SendRconLine(cid1, buf);
}
} }
} }
@ -1482,6 +1489,7 @@ void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData, int cid
if(chr) if(chr)
{ {
chr->m_Super = true; chr->m_Super = true;
chr->UnFreeze();
if(!g_Config.m_SvCheatTime) if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT; chr->m_RaceState = RACE_CHEAT;
} }
@ -1513,6 +1521,7 @@ void CGameContext::ConSuperMe(IConsole::IResult *pResult, void *pUserData, int c
if(chr) if(chr)
{ {
chr->m_Super = true; chr->m_Super = true;
chr->UnFreeze();
if(!g_Config.m_SvCheatTime) if(!g_Config.m_SvCheatTime)
chr->m_RaceState = RACE_CHEAT; chr->m_RaceState = RACE_CHEAT;
} }
@ -1597,9 +1606,12 @@ void CGameContext::ConTimerStop(IConsole::IResult *pResult, void *pUserData, int
CCharacter* chr = pSelf->GetPlayerChar(cid1); CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr) if (!chr)
return; return;
chr->m_RaceState=RACE_CHEAT; if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
str_format(buf, sizeof(buf), "Cid=%d Hasn't time now (Timer Stopped)",cid1); {
serv->SendRconLine(cid1, buf); chr->m_RaceState=RACE_CHEAT;
str_format(buf, sizeof(buf), "Cid=%d Hasn't time now (Timer Stopped)",cid1);
serv->SendRconLine(cid1, buf);
}
} }
else else
{ {
@ -1620,9 +1632,12 @@ void CGameContext::ConTimerStart(IConsole::IResult *pResult, void *pUserData, in
CCharacter* chr = pSelf->GetPlayerChar(cid1); CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr) if (!chr)
return; return;
chr->m_RaceState = RACE_STARTED; if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
str_format(buf, sizeof(buf), "Cid=%d Has time now (Timer Started)",cid1); {
serv->SendRconLine(cid1, buf); chr->m_RaceState = RACE_STARTED;
str_format(buf, sizeof(buf), "Cid=%d Has time now (Timer Started)",cid1);
serv->SendRconLine(cid1, buf);
}
} }
else else
{ {
@ -1642,12 +1657,15 @@ void CGameContext::ConTimerZero(IConsole::IResult *pResult, void *pUserData, int
CCharacter* chr = pSelf->GetPlayerChar(cid1); CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr) if (!chr)
return; return;
chr->m_StartTime = pSelf->Server()->Tick(); if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
chr->m_RefreshTime = pSelf->Server()->Tick(); {
chr->m_RaceState=RACE_CHEAT; chr->m_StartTime = pSelf->Server()->Tick();
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1); chr->m_RefreshTime = pSelf->Server()->Tick();
CServer* serv = (CServer*)pSelf->Server(); chr->m_RaceState=RACE_CHEAT;
serv->SendRconLine(cid1, buf); str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
}
} }
@ -1662,10 +1680,53 @@ void CGameContext::ConTimerReStart(IConsole::IResult *pResult, void *pUserData,
CCharacter* chr = pSelf->GetPlayerChar(cid1); CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr) if (!chr)
return; return;
chr->m_StartTime = pSelf->Server()->Tick(); if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
chr->m_RefreshTime = pSelf->Server()->Tick(); {
chr->m_RaceState=RACE_STARTED; chr->m_StartTime = pSelf->Server()->Tick();
str_format(buf, sizeof(buf), "Cid=%d time has been reset & stopped.",cid1); 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);
}
}
void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData, int cid)
{
CGameContext *pSelf = (CGameContext *)pUserData;
//if(!pSelf->CheatsAvailable(cid)) return;
char buf[128];
int time=-1;
int cid1 = clamp(pResult->GetInteger(0), 0, (int)MAX_CLIENTS-1);
if(pResult->NumArguments()>1)
time = clamp(pResult->GetInteger(1), -1, 29999);
CCharacter* chr = pSelf->GetPlayerChar(cid1);
if (!chr)
return;
if (pSelf->m_apPlayers[cid1] && compare_players(pSelf->m_apPlayers[cid],pSelf->m_apPlayers[cid1]))
{
chr->Freeze(((time!=0&&time!=-1)?(pSelf->Server()->TickSpeed()*time):(-1)));
chr->m_pPlayer->m_RconFreeze = true;
str_format(buf, sizeof(buf), "Cid=%d has been Frozen.",cid1);
CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf);
}
}
void CGameContext::ConUnFreeze(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_FreezeTime=2;
chr->m_pPlayer->m_RconFreeze = false;
str_format(buf, sizeof(buf), "Cid=%d has been UnFreezed.",cid1);
CServer* serv = (CServer*)pSelf->Server(); CServer* serv = (CServer*)pSelf->Server();
serv->SendRconLine(cid1, buf); serv->SendRconLine(cid1, buf);
@ -1675,7 +1736,8 @@ void CGameContext::OnConsoleInit()
{ {
m_pServer = Kernel()->RequestInterface<IServer>(); m_pServer = Kernel()->RequestInterface<IServer>();
m_pConsole = Kernel()->RequestInterface<IConsole>(); m_pConsole = Kernel()->RequestInterface<IConsole>();
Console()->Register("freeze", "i?i", CFGFLAG_SERVER, ConFreeze, this, "Freezes Player i1 for i2 seconds Default Infinity",2);
Console()->Register("unfreeze", "i", CFGFLAG_SERVER, ConUnFreeze, this, "UnFreezes Player i",2);
Console()->Register("timerstop", "i", CFGFLAG_SERVER, ConTimerStop, this, "Stops The Timer of Player i",2); 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("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("timerrestart", "i", CFGFLAG_SERVER, ConTimerReStart, this, "Starts The Timer of Player i with the time of 00:00:00",2);

View file

@ -70,6 +70,8 @@ class CGameContext : public IGameServer
static void ConPhook(IConsole::IResult *pResult, void *pUserData, int cid); static void ConPhook(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConFreeze(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConUnFreeze(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerStop(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 ConTimerStart(IConsole::IResult *pResult, void *pUserData, int cid);
static void ConTimerReStart(IConsole::IResult *pResult, void *pUserData, int cid); static void ConTimerReStart(IConsole::IResult *pResult, void *pUserData, int cid);

View file

@ -179,7 +179,7 @@ bool IGameController::OnEntity(int Index, vec2 Pos, bool Front)
true, //Freeze true, //Freeze
true, //Explosive true, //Explosive
0, 0,
SOUND_GRENADE_EXPLODE, (g_Config.m_SvShotgunBulletSound)?SOUND_GRENADE_EXPLODE:-1,
WEAPON_SHOTGUN); WEAPON_SHOTGUN);
bullet->SetBouncing(2 - (i % 2)); bullet->SetBouncing(2 - (i % 2));

View file

@ -265,7 +265,6 @@ void CPlayer::LoadCharacter() {
Character->m_Armor = m_PauseInfo.m_Armor; Character->m_Armor = m_PauseInfo.m_Armor;
Character->m_PlayerState = m_PauseInfo.m_PlayerState; Character->m_PlayerState = m_PauseInfo.m_PlayerState;
Character->m_LastMove = m_PauseInfo.m_LastMove; Character->m_LastMove = m_PauseInfo.m_LastMove;
Character->m_LastSpeedup = m_PauseInfo.m_LastSpeedup;
Character->m_PrevPos = m_PauseInfo.m_PrevPos; Character->m_PrevPos = m_PauseInfo.m_PrevPos;
Character->m_ActiveWeapon = m_PauseInfo.m_ActiveWeapon; Character->m_ActiveWeapon = m_PauseInfo.m_ActiveWeapon;
Character->m_LastWeapon = m_PauseInfo.m_LastWeapon; Character->m_LastWeapon = m_PauseInfo.m_LastWeapon;
@ -293,7 +292,6 @@ void CPlayer::SaveCharacter()
m_PauseInfo.m_Armor = Character->m_Armor; m_PauseInfo.m_Armor = Character->m_Armor;
m_PauseInfo.m_PlayerState = Character->m_PlayerState; m_PauseInfo.m_PlayerState = Character->m_PlayerState;
m_PauseInfo.m_LastMove = Character->m_LastMove; m_PauseInfo.m_LastMove = Character->m_LastMove;
m_PauseInfo.m_LastSpeedup = Character->m_LastSpeedup;
m_PauseInfo.m_PrevPos = Character->m_PrevPos; m_PauseInfo.m_PrevPos = Character->m_PrevPos;
m_PauseInfo.m_ActiveWeapon = Character->m_ActiveWeapon; m_PauseInfo.m_ActiveWeapon = Character->m_ActiveWeapon;
m_PauseInfo.m_LastWeapon = Character->m_LastWeapon; m_PauseInfo.m_LastWeapon = Character->m_LastWeapon;

View file

@ -47,7 +47,6 @@ public:
int m_Armor; int m_Armor;
int m_PlayerState; int m_PlayerState;
int m_LastMove; int m_LastMove;
int m_LastSpeedup;
vec2 m_PrevPos; vec2 m_PrevPos;
int m_ActiveWeapon; int m_ActiveWeapon;
int m_LastWeapon; int m_LastWeapon;
@ -127,7 +126,7 @@ public:
int m_SentAfkWarning; // afk timer's 1st warning after 50% of sv_max_afk_time int m_SentAfkWarning; // afk timer's 1st warning after 50% of sv_max_afk_time
int m_SentAfkWarning2; // afk timer's 2nd warning after 90% of sv_max_afk_time int m_SentAfkWarning2; // afk timer's 2nd warning after 90% of sv_max_afk_time
char m_pAfkMsg[160]; char m_pAfkMsg[160];
bool m_RconFreeze;
private: private:
CCharacter *Character; CCharacter *Character;
CGameContext *m_pGameServer; CGameContext *m_pGameServer;

View file

@ -1,155 +0,0 @@
/* copyright (c) 2008 rajh and gregwar. Score stuff */
#include "score.h"
#include "gamecontext.h"
#include <string.h>
#include <sstream>
#include <fstream>
#include <list>
#include <engine/config.h>
#include <engine/shared/config.h>
#include <engine/storage.h>
#include <engine/server/server.h>
#include <engine/server.h>
CPlayerScore::CPlayerScore(const char *name, float score)
{
str_copy(this->name, name, sizeof(this->name));
this->m_Score = score;
}
std::list<CPlayerScore> top;
CScore::CScore(class CGameContext *pGameServer)
{
m_pGameServer = pGameServer;
Load();
}
CScore::CScore()
{
Load();
}
std::string CScore::SaveFile()
{
std::ostringstream oss;
if(!g_Config.m_SvExternalRecords) {
oss << g_Config.m_SvMap << "_record.dtb";
} else {
char buf[512];
CServer* server = static_cast<CServer*>(m_pGameServer->Server());
oss << server->Storage()->ApplicationSavePath() << "/records/" << g_Config.m_SvMap << "_record.dtb";
}
return oss.str();
}
void CScore::Save()
{
std::fstream f;
f.open(SaveFile().c_str(), std::ios::out);
if(!f.fail()) {
for(std::list<CPlayerScore>::iterator i=top.begin(); i!=top.end(); i++)
{
f << i->name << std::endl << i->m_Score << std::endl;
}
}
f.close();
}
void CScore::Load()
{
std::fstream f;
f.open(SaveFile().c_str(), std::ios::in);
top.clear();
while (!f.eof() && !f.fail())
{
std::string tmpname, tmpscore;
std::getline(f, tmpname);
if(!f.eof() && tmpname != "")
{
std::getline(f, tmpscore);
top.push_back(*new CPlayerScore(tmpname.c_str(), atof(tmpscore.c_str())));
}
}
f.close();
}
CPlayerScore *CScore::SearchName(const char *name, int &pos)
{
pos=0;
for (std::list<CPlayerScore>::iterator i = top.begin(); i!=top.end(); i++)
{
pos++;
if (!strcmp(i->name, name))
{
return & (*i);
}
}
pos=-1;
return 0;
}
CPlayerScore *CScore::SearchName(const char *name)
{
for (std::list<CPlayerScore>::iterator i = top.begin(); i!=top.end(); i++)
{
if (!strcmp(i->name, name))
{
return & (*i);
}
}
return 0;
}
void CScore::ParsePlayer(const char *name, float score)
{
CPlayerScore *player = SearchName(name);
if (player)
{
if (player->m_Score > score)
{
player->m_Score = score;
top.sort();
Save();
}
}
else
{
top.push_back(*new CPlayerScore(name, score));
top.sort();
Save();
}
}
std::list<std::string> CScore::Top5Draw(int id, int debut) //Thanks nevi
{
std::list<std::string> res;
int pos = 1;
//char buf[512];
res.push_back("----------- Top 5 -----------");
for (std::list<CPlayerScore>::iterator i = top.begin(); i != top.end() && pos <= 5+debut; i++)
{
if(i->m_Score < 0)
continue;
if(pos >= debut)
{
std::ostringstream oss;
oss << pos << ". " << i->name << " Time: ";
if ((int)(i->m_Score)/60 != 0)
oss << (int)(i->m_Score)/60 << ":";
if (i->m_Score-((int)i->m_Score/60)*60 != 0)
oss << i->m_Score-((int)i->m_Score/60)*60 <<" ";
res.push_back(oss.str());
}
pos++;
}
res.push_back("-----------------------------");
return res;
}