2008-09-23 07:43:41 +00:00
# include <new>
2010-08-23 19:37:27 +00:00
# include <stdio.h>
2010-09-21 23:13:08 +00:00
# include <string.h>
2010-05-29 07:25:38 +00:00
# include <base/math.h>
# include <engine/shared/config.h>
2010-07-29 05:21:18 +00:00
# include <engine/server/server.h>
2010-05-29 07:25:38 +00:00
# include <engine/map.h>
# include <engine/console.h>
# include "gamecontext.h"
# include <game/version.h>
# include <game/collision.h>
# include <game/gamecore.h>
2010-07-29 14:53:25 +00:00
# include "gamemodes/DDRace.h"
2008-08-14 18:42:47 +00:00
2010-08-23 19:37:27 +00:00
# include "score.h"
# include "score/file_score.h"
2010-08-26 13:27:36 +00:00
# include "score/sql_score.h"
2010-08-23 19:37:27 +00:00
2010-05-29 07:25:38 +00:00
enum
{
RESET ,
NO_RESET
} ;
2008-08-14 18:42:47 +00:00
2010-05-29 07:25:38 +00:00
void CGameContext : : Construct ( int Resetting )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
m_Resetting = 0 ;
m_pServer = 0 ;
2010-08-20 20:40:12 +00:00
2008-09-23 07:43:41 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
2010-09-17 09:58:54 +00:00
{
2010-05-29 07:25:38 +00:00
m_apPlayers [ i ] = 0 ;
2010-09-17 09:58:54 +00:00
mem_zero ( m_pReconnectInfo [ i ] . Ip , sizeof ( m_pReconnectInfo [ i ] . Ip ) ) ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
m_pController = 0 ;
m_VoteCloseTime = 0 ;
m_pVoteOptionFirst = 0 ;
m_pVoteOptionLast = 0 ;
if ( Resetting = = NO_RESET )
m_pVoteOptionHeap = new CHeap ( ) ;
2010-08-23 19:37:27 +00:00
m_pScore = 0 ;
2010-05-29 07:25:38 +00:00
}
CGameContext : : CGameContext ( int Resetting )
{
Construct ( Resetting ) ;
}
CGameContext : : CGameContext ( )
{
Construct ( NO_RESET ) ;
2008-09-23 07:43:41 +00:00
}
2010-05-29 07:25:38 +00:00
CGameContext : : ~ CGameContext ( )
2008-09-23 07:43:41 +00:00
{
2008-09-24 09:03:49 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
2010-05-29 07:25:38 +00:00
delete m_apPlayers [ i ] ;
if ( ! m_Resetting )
delete m_pVoteOptionHeap ;
2008-08-14 18:42:47 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : Clear ( )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
CHeap * pVoteOptionHeap = m_pVoteOptionHeap ;
CVoteOption * pVoteOptionFirst = m_pVoteOptionFirst ;
CVoteOption * pVoteOptionLast = m_pVoteOptionLast ;
CTuningParams Tuning = m_Tuning ;
2010-07-29 05:21:18 +00:00
//bool cheats = m_Cheats;
2010-05-29 07:25:38 +00:00
m_Resetting = true ;
this - > ~ CGameContext ( ) ;
2008-09-23 07:43:41 +00:00
mem_zero ( this , sizeof ( * this ) ) ;
2010-05-29 07:25:38 +00:00
new ( this ) CGameContext ( RESET ) ;
2010-08-20 20:40:12 +00:00
//this->m_Cheats = cheats;
2010-05-29 07:25:38 +00:00
m_pVoteOptionHeap = pVoteOptionHeap ;
m_pVoteOptionFirst = pVoteOptionFirst ;
m_pVoteOptionLast = pVoteOptionLast ;
m_Tuning = Tuning ;
2008-08-14 18:42:47 +00:00
}
2010-05-29 07:25:38 +00:00
class CCharacter * CGameContext : : GetPlayerChar ( int ClientId )
2008-10-20 23:00:46 +00:00
{
2010-05-29 07:25:38 +00:00
if ( ClientId < 0 | | ClientId > = MAX_CLIENTS | | ! m_apPlayers [ ClientId ] )
2008-10-20 23:00:46 +00:00
return 0 ;
2010-05-29 07:25:38 +00:00
return m_apPlayers [ ClientId ] - > GetCharacter ( ) ;
2008-10-20 23:00:46 +00:00
}
2010-09-17 11:35:53 +00:00
void CGameContext : : CreateDamageInd ( vec2 P , float Angle , int Amount , int Mask )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
float a = 3 * 3.14159f / 2 + Angle ;
2008-08-14 18:42:47 +00:00
//float a = get_angle(dir);
float s = a - pi / 3 ;
float e = a + pi / 3 ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < Amount ; i + + )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
float f = mix ( s , e , float ( i + 1 ) / float ( Amount + 2 ) ) ;
2010-09-08 16:22:11 +00:00
NETEVENT_DAMAGEIND * ev = ( NETEVENT_DAMAGEIND * ) m_Events . Create ( NETEVENTTYPE_DAMAGEIND , sizeof ( NETEVENT_DAMAGEIND ) , Mask ) ;
2008-08-14 18:42:47 +00:00
if ( ev )
{
2010-09-17 11:35:53 +00:00
ev - > m_X = ( int ) P . x ;
ev - > m_Y = ( int ) P . y ;
2010-05-29 07:25:38 +00:00
ev - > m_Angle = ( int ) ( f * 256.0f ) ;
2008-08-14 18:42:47 +00:00
}
}
}
2010-09-17 11:35:53 +00:00
void CGameContext : : CreateHammerHit ( vec2 P , int Mask )
2008-10-17 11:23:21 +00:00
{
// create the event
2010-09-08 16:22:11 +00:00
NETEVENT_HAMMERHIT * ev = ( NETEVENT_HAMMERHIT * ) m_Events . Create ( NETEVENTTYPE_HAMMERHIT , sizeof ( NETEVENT_HAMMERHIT ) , Mask ) ;
2008-10-17 11:23:21 +00:00
if ( ev )
{
2010-09-17 11:35:53 +00:00
ev - > m_X = ( int ) P . x ;
ev - > m_Y = ( int ) P . y ;
2008-10-17 11:23:21 +00:00
}
}
2010-09-17 11:35:53 +00:00
void CGameContext : : CreateExplosion ( vec2 P , int Owner , int Weapon , bool NoDamage , int Mask )
2008-08-14 18:42:47 +00:00
{
// create the event
2010-09-08 16:22:11 +00:00
NETEVENT_EXPLOSION * ev = ( NETEVENT_EXPLOSION * ) m_Events . Create ( NETEVENTTYPE_EXPLOSION , sizeof ( NETEVENT_EXPLOSION ) , Mask ) ;
2008-08-14 18:42:47 +00:00
if ( ev )
{
2010-09-17 11:35:53 +00:00
ev - > m_X = ( int ) P . x ;
ev - > m_Y = ( int ) P . y ;
2008-08-14 18:42:47 +00:00
}
2010-10-10 22:40:07 +00:00
/*if(!NoDamage)
2010-08-29 02:00:21 +00:00
{ */
2008-08-14 18:42:47 +00:00
// deal damage
2010-05-29 07:25:38 +00:00
CCharacter * apEnts [ 64 ] ;
float Radius = 135.0f ;
float InnerRadius = 48.0f ;
2010-09-17 11:35:53 +00:00
int Num = m_World . FindEntities ( P , Radius , ( CEntity * * ) apEnts , 64 , NETOBJTYPE_CHARACTER ) ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < Num ; i + + )
2008-08-14 18:42:47 +00:00
{
2010-09-17 11:35:53 +00:00
vec2 Diff = apEnts [ i ] - > m_Pos - P ;
2010-09-16 22:40:44 +00:00
vec2 ForceDir ( 0 , 1 ) ;
2010-05-29 07:25:38 +00:00
float l = length ( Diff ) ;
2008-08-14 18:42:47 +00:00
if ( l )
2010-05-29 07:25:38 +00:00
ForceDir = normalize ( Diff ) ;
l = 1 - clamp ( ( l - InnerRadius ) / ( Radius - InnerRadius ) , 0.0f , 1.0f ) ;
float Dmg = 6 * l ;
if ( ( int ) Dmg )
2010-08-29 02:00:21 +00:00
if ( ( g_Config . m_SvHit | | NoDamage ) | | Owner = = apEnts [ i ] - > m_pPlayer - > GetCID ( ) )
{
2010-09-21 19:09:11 +00:00
if ( Owner ! = - 1 & & apEnts [ i ] - > m_Alive & & ! apEnts [ i ] - > CanCollide ( Owner ) ) continue ;
2010-07-29 05:21:18 +00:00
apEnts [ i ] - > TakeDamage ( ForceDir * Dmg * 2 , ( int ) Dmg , Owner , Weapon ) ;
2010-08-29 02:00:21 +00:00
if ( ! g_Config . m_SvHit | | NoDamage ) break ;
2010-07-29 05:21:18 +00:00
}
2010-08-20 20:40:12 +00:00
2008-08-14 18:42:47 +00:00
}
2010-08-29 02:00:21 +00:00
//}
2008-08-14 18:42:47 +00:00
}
/*
2010-09-17 11:35:53 +00:00
void create_smoke ( vec2 P )
2008-08-14 18:42:47 +00:00
{
// create the event
EV_EXPLOSION * ev = ( EV_EXPLOSION * ) events . create ( EVENT_SMOKE , sizeof ( EV_EXPLOSION ) ) ;
if ( ev )
{
2010-09-17 11:35:53 +00:00
ev - > x = ( int ) P . x ;
ev - > y = ( int ) P . y ;
2008-08-14 18:42:47 +00:00
}
} */
2010-09-17 11:35:53 +00:00
void CGameContext : : CreatePlayerSpawn ( vec2 P , int Mask )
2008-08-14 18:42:47 +00:00
{
// create the event
2010-09-08 16:22:11 +00:00
NETEVENT_SPAWN * ev = ( NETEVENT_SPAWN * ) m_Events . Create ( NETEVENTTYPE_SPAWN , sizeof ( NETEVENT_SPAWN ) , Mask ) ;
2008-08-14 18:42:47 +00:00
if ( ev )
{
2010-09-17 11:35:53 +00:00
ev - > m_X = ( int ) P . x ;
ev - > m_Y = ( int ) P . y ;
2008-08-14 18:42:47 +00:00
}
}
2010-09-17 11:35:53 +00:00
void CGameContext : : CreateDeath ( vec2 P , int ClientId , int Mask )
2008-08-14 18:42:47 +00:00
{
// create the event
2010-09-08 16:22:11 +00:00
NETEVENT_DEATH * ev = ( NETEVENT_DEATH * ) m_Events . Create ( NETEVENTTYPE_DEATH , sizeof ( NETEVENT_DEATH ) , Mask ) ;
2008-08-14 18:42:47 +00:00
if ( ev )
{
2010-09-17 11:35:53 +00:00
ev - > m_X = ( int ) P . x ;
ev - > m_Y = ( int ) P . y ;
2010-05-29 07:25:38 +00:00
ev - > m_ClientId = ClientId ;
2008-08-14 18:42:47 +00:00
}
}
2010-05-29 07:25:38 +00:00
void CGameContext : : CreateSound ( vec2 Pos , int Sound , int Mask )
2008-08-14 18:42:47 +00:00
{
2010-10-10 22:40:07 +00:00
if ( Sound < 0 )
2008-08-14 18:42:47 +00:00
return ;
// create a sound
2010-05-29 07:25:38 +00:00
NETEVENT_SOUNDWORLD * ev = ( NETEVENT_SOUNDWORLD * ) m_Events . Create ( NETEVENTTYPE_SOUNDWORLD , sizeof ( NETEVENT_SOUNDWORLD ) , Mask ) ;
2008-08-14 18:42:47 +00:00
if ( ev )
{
2010-05-29 07:25:38 +00:00
ev - > m_X = ( int ) Pos . x ;
ev - > m_Y = ( int ) Pos . y ;
ev - > m_SoundId = Sound ;
2008-08-14 18:42:47 +00:00
}
}
2010-05-29 07:25:38 +00:00
void CGameContext : : CreateSoundGlobal ( int Sound , int Target )
2008-08-14 18:42:47 +00:00
{
2010-10-10 22:40:07 +00:00
if ( Sound < 0 )
2008-08-14 18:42:47 +00:00
return ;
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_SoundGlobal Msg ;
Msg . m_Soundid = Sound ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , Target ) ;
2008-08-14 18:42:47 +00:00
}
2009-01-11 14:28:35 +00:00
2010-05-29 07:25:38 +00:00
void CGameContext : : SendChatTarget ( int To , const char * pText )
2009-01-11 14:28:35 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_Chat Msg ;
Msg . m_Team = 0 ;
Msg . m_Cid = - 1 ;
Msg . m_pMessage = pText ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , To ) ;
2009-01-11 14:28:35 +00:00
}
2010-10-10 22:40:07 +00:00
void CGameContext : : SendChatResponseAll ( const char * pLine , void * pUser )
{
CGameContext * pSelf = ( CGameContext * ) pUser ;
static volatile int ReentryGuard = 0 ;
if ( ReentryGuard )
return ;
ReentryGuard + + ;
if ( * pLine = = ' [ ' )
do
pLine + + ;
while ( * ( pLine - 2 ) ! = ' : ' & & * pLine ! = 0 ) ; //remove the category (e.g. [Console]: No Such Command)
pSelf - > SendChat ( - 1 , CHAT_ALL , pLine ) ;
ReentryGuard - - ;
}
void CGameContext : : SendChatResponse ( const char * pLine , void * pUser )
{
ChatResponseInfo * pInfo = ( ChatResponseInfo * ) pUser ;
static volatile int ReentryGuard = 0 ;
if ( ReentryGuard )
return ;
ReentryGuard + + ;
if ( * pLine = = ' [ ' )
do
pLine + + ;
while ( * ( pLine - 2 ) ! = ' : ' & & * pLine ! = 0 ) ; // remove the category (e.g. [Console]: No Such Command)
pInfo - > m_GameContext - > SendChatTarget ( pInfo - > m_To , pLine ) ;
ReentryGuard - - ;
}
2009-01-11 14:28:35 +00:00
2010-05-29 07:25:38 +00:00
void CGameContext : : SendChat ( int ChatterClientId , int Team , const char * pText )
2008-08-14 18:42:47 +00:00
{
2010-08-17 22:06:00 +00:00
char aBuf [ 256 ] ;
2010-05-29 07:25:38 +00:00
if ( ChatterClientId > = 0 & & ChatterClientId < MAX_CLIENTS )
2010-08-17 22:06:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %d:%d:%s: %s " , ChatterClientId , Team , Server ( ) - > ClientName ( ChatterClientId ) , pText ) ;
2008-08-14 18:42:47 +00:00
else
2010-08-17 22:06:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " *** %s " , pText ) ;
Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " chat " , aBuf ) ;
2008-08-14 18:42:47 +00:00
2010-05-29 07:25:38 +00:00
if ( Team = = CHAT_ALL )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_Chat Msg ;
Msg . m_Team = 0 ;
Msg . m_Cid = ChatterClientId ;
Msg . m_pMessage = pText ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , - 1 ) ;
2008-08-14 18:42:47 +00:00
}
else
{
2010-10-06 20:35:19 +00:00
CTeamsCore * Teams = & ( ( CGameControllerDDRace * ) m_pController ) - > m_Teams . m_Core ;
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_Chat Msg ;
Msg . m_Team = 1 ;
Msg . m_Cid = ChatterClientId ;
Msg . m_pMessage = pText ;
2010-08-20 20:40:12 +00:00
2009-06-15 13:01:04 +00:00
// pack one for the recording only
2010-05-29 07:25:38 +00:00
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL | MSGFLAG_NOSEND , - 1 ) ;
2010-10-06 20:35:19 +00:00
//char aBuf[512];
//str_format(aBuf, sizeof(aBuf), "Chat Team = %d", Team);
//dbg_msg("Chat", aBuf);
2009-06-15 13:01:04 +00:00
// send to the clients
2008-08-14 18:42:47 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2010-10-06 20:35:19 +00:00
if ( m_apPlayers [ i ] ! = 0 ) {
if ( Team = = CHAT_SPEC ) {
if ( m_apPlayers [ i ] - > GetTeam ( ) = = CHAT_SPEC ) {
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL | MSGFLAG_NORECORD , i ) ;
}
} else {
if ( Teams - > Team ( i ) = = Team ) {
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL | MSGFLAG_NORECORD , i ) ;
}
}
}
2008-08-14 18:42:47 +00:00
}
}
}
2010-05-29 07:25:38 +00:00
void CGameContext : : SendEmoticon ( int ClientId , int Emoticon )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_Emoticon Msg ;
Msg . m_Cid = ClientId ;
Msg . m_Emoticon = Emoticon ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , - 1 ) ;
2008-08-14 18:42:47 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : SendWeaponPickup ( int ClientId , int Weapon )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_WeaponPickup Msg ;
Msg . m_Weapon = Weapon ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , ClientId ) ;
2008-08-14 18:42:47 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : SendBroadcast ( const char * pText , int ClientId )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_Broadcast Msg ;
Msg . m_pMessage = pText ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , ClientId ) ;
2008-08-14 18:42:47 +00:00
}
2010-08-20 20:40:12 +00:00
//
2010-05-29 07:25:38 +00:00
void CGameContext : : StartVote ( const char * pDesc , const char * pCommand )
2008-09-24 14:47:03 +00:00
{
// check if a vote is already running
2010-05-29 07:25:38 +00:00
if ( m_VoteCloseTime )
2008-09-24 14:47:03 +00:00
return ;
// reset votes
2010-05-29 07:25:38 +00:00
m_VoteEnforce = VOTE_ENFORCE_UNKNOWN ;
2008-09-24 14:47:03 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2010-05-29 07:25:38 +00:00
if ( m_apPlayers [ i ] )
{
m_apPlayers [ i ] - > m_Vote = 0 ;
m_apPlayers [ i ] - > m_VotePos = 0 ;
}
2008-09-24 14:47:03 +00:00
}
2010-08-20 20:40:12 +00:00
2008-09-24 14:47:03 +00:00
// start vote
2010-05-29 07:25:38 +00:00
m_VoteCloseTime = time_get ( ) + time_freq ( ) * 25 ;
str_copy ( m_aVoteDescription , pDesc , sizeof ( m_aVoteDescription ) ) ;
str_copy ( m_aVoteCommand , pCommand , sizeof ( m_aVoteCommand ) ) ;
SendVoteSet ( - 1 ) ;
m_VoteUpdate = true ;
2008-09-24 14:47:03 +00:00
}
2008-09-25 12:41:37 +00:00
2010-05-29 07:25:38 +00:00
void CGameContext : : EndVote ( )
2008-09-25 12:41:37 +00:00
{
2010-05-29 07:25:38 +00:00
m_VoteCloseTime = 0 ;
SendVoteSet ( - 1 ) ;
2008-09-25 12:41:37 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : SendVoteSet ( int ClientId )
2008-09-24 14:47:03 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_VoteSet Msg ;
if ( m_VoteCloseTime )
2008-09-24 14:47:03 +00:00
{
2010-05-29 07:25:38 +00:00
Msg . m_Timeout = ( m_VoteCloseTime - time_get ( ) ) / time_freq ( ) ;
Msg . m_pDescription = m_aVoteDescription ;
Msg . m_pCommand = " " ;
2008-09-24 14:47:03 +00:00
}
else
{
2010-05-29 07:25:38 +00:00
Msg . m_Timeout = 0 ;
Msg . m_pDescription = " " ;
Msg . m_pCommand = " " ;
2008-09-24 14:47:03 +00:00
}
2010-05-29 07:25:38 +00:00
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , ClientId ) ;
2008-09-24 14:47:03 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : SendVoteStatus ( int ClientId , int Total , int Yes , int No )
2008-09-24 14:47:03 +00:00
{
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_VoteStatus Msg = { 0 } ;
Msg . m_Total = Total ;
Msg . m_Yes = Yes ;
Msg . m_No = No ;
Msg . m_Pass = Total - ( Yes + No ) ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , ClientId ) ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
}
void CGameContext : : AbortVoteKickOnDisconnect ( int ClientId )
{
if ( m_VoteCloseTime & & ! str_comp_num ( m_aVoteCommand , " kick " , 5 ) & & str_toint ( & m_aVoteCommand [ 5 ] ) = = ClientId )
m_VoteCloseTime = - 1 ;
}
void CGameContext : : CheckPureTuning ( )
{
// might not be created yet during start up
if ( ! m_pController )
return ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( str_comp ( m_pController - > m_pGameType , " DM " ) = = 0 | |
str_comp ( m_pController - > m_pGameType , " TDM " ) = = 0 | |
str_comp ( m_pController - > m_pGameType , " CTF " ) = = 0 )
2008-09-24 14:47:03 +00:00
{
2010-09-17 11:35:53 +00:00
CTuningParams P ;
if ( mem_comp ( & P , & m_Tuning , sizeof ( P ) ) ! = 0 )
2008-09-24 14:47:03 +00:00
{
2010-08-17 22:06:00 +00:00
Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , " resetting tuning due to pure server " ) ;
2010-09-17 11:35:53 +00:00
m_Tuning = P ;
2008-09-24 14:47:03 +00:00
}
2010-08-20 20:40:12 +00:00
}
2008-09-24 14:47:03 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : SendTuningParams ( int Cid )
2008-10-21 17:26:32 +00:00
{
2010-05-29 07:25:38 +00:00
CheckPureTuning ( ) ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
CMsgPacker Msg ( NETMSGTYPE_SV_TUNEPARAMS ) ;
int * pParams = ( int * ) & m_Tuning ;
for ( unsigned i = 0 ; i < sizeof ( m_Tuning ) / sizeof ( int ) ; i + + )
Msg . AddInt ( pParams [ i ] ) ;
Server ( ) - > SendMsg ( & Msg , MSGFLAG_VITAL , Cid ) ;
2008-10-21 17:26:32 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : OnTick ( )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
// check tuning
CheckPureTuning ( ) ;
// copy tuning
m_World . m_Core . m_Tuning = m_Tuning ;
m_World . Tick ( ) ;
2008-08-14 18:42:47 +00:00
//if(world.paused) // make sure that the game object always updates
2010-05-29 07:25:38 +00:00
m_pController - > Tick ( ) ;
2010-08-20 20:40:12 +00:00
2008-08-14 18:42:47 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2010-05-29 07:25:38 +00:00
if ( m_apPlayers [ i ] )
m_apPlayers [ i ] - > Tick ( ) ;
2008-08-14 18:42:47 +00:00
}
2010-08-20 20:40:12 +00:00
2008-09-24 14:47:03 +00:00
// update voting
2010-05-29 07:25:38 +00:00
if ( m_VoteCloseTime )
2008-09-24 14:47:03 +00:00
{
2008-10-21 17:26:32 +00:00
// abort the kick-vote on player-leave
2010-05-29 07:25:38 +00:00
if ( m_VoteCloseTime = = - 1 )
2008-09-24 14:47:03 +00:00
{
2010-05-29 07:25:38 +00:00
SendChat ( - 1 , CGameContext : : CHAT_ALL , " Vote aborted " ) ;
EndVote ( ) ;
2008-10-21 17:26:32 +00:00
}
else
{
2010-05-29 07:25:38 +00:00
int Total = 0 , Yes = 0 , No = 0 ;
if ( m_VoteUpdate )
2008-09-24 14:47:03 +00:00
{
2010-05-29 07:25:38 +00:00
// count votes
char aaBuf [ MAX_CLIENTS ] [ 64 ] = { { 0 } } ;
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
if ( m_apPlayers [ i ] )
Server ( ) - > GetClientIP ( i , aaBuf [ i ] , 64 ) ;
bool aVoteChecked [ MAX_CLIENTS ] = { 0 } ;
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
2008-10-21 17:26:32 +00:00
{
2010-05-29 07:25:38 +00:00
if ( ! m_apPlayers [ i ] | | m_apPlayers [ i ] - > GetTeam ( ) = = - 1 | | aVoteChecked [ i ] ) // don't count in votes by spectators
continue ;
2010-09-08 16:22:11 +00:00
if ( m_VoteKick & &
2010-09-14 16:58:18 +00:00
GetPlayerChar ( m_VoteCreator ) & & GetPlayerChar ( i ) & &
2010-09-08 16:22:11 +00:00
GetPlayerChar ( m_VoteCreator ) - > Team ( ) ! = GetPlayerChar ( i ) - > Team ( ) ) continue ;
2010-05-29 07:25:38 +00:00
int ActVote = m_apPlayers [ i ] - > m_Vote ;
int ActVotePos = m_apPlayers [ i ] - > m_VotePos ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
// check for more players with the same ip (only use the vote of the one who voted first)
for ( int j = i + 1 ; j < MAX_CLIENTS ; + + j )
{
if ( ! m_apPlayers [ j ] | | aVoteChecked [ j ] | | str_comp ( aaBuf [ j ] , aaBuf [ i ] ) )
continue ;
aVoteChecked [ j ] = true ;
if ( m_apPlayers [ j ] - > m_Vote & & ( ! ActVote | | ActVotePos > m_apPlayers [ j ] - > m_VotePos ) )
{
ActVote = m_apPlayers [ j ] - > m_Vote ;
ActVotePos = m_apPlayers [ j ] - > m_VotePos ;
}
}
Total + + ;
if ( ActVote > 0 )
Yes + + ;
else if ( ActVote < 0 )
No + + ;
2008-10-21 17:26:32 +00:00
}
2010-05-29 07:25:38 +00:00
2010-09-17 19:40:37 +00:00
if ( Yes > = ( Total / ( 100 / g_Config . m_SvVotePercentage ) ) + 1 )
2010-05-29 07:25:38 +00:00
m_VoteEnforce = VOTE_ENFORCE_YES ;
2010-09-17 19:40:37 +00:00
else if ( No > = ( Total + 1 ) / ( ( 1.0 / g_Config . m_SvVotePercentage ) * 100.0 ) )
2010-05-29 07:25:38 +00:00
m_VoteEnforce = VOTE_ENFORCE_NO ;
2008-09-24 14:47:03 +00:00
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( m_VoteEnforce = = VOTE_ENFORCE_YES )
{
2010-10-11 17:43:29 +00:00
Console ( ) - > ExecuteLine ( m_aVoteCommand , 4 , - 1 , CServer : : SendRconLineAuthed , Server ( ) , SendChatResponseAll , this ) ;
2010-10-11 11:10:39 +00:00
EndVote ( ) ;
SendChat ( - 1 , CGameContext : : CHAT_ALL , " Vote passed " ) ;
2010-05-29 07:25:38 +00:00
if ( m_apPlayers [ m_VoteCreator ] )
m_apPlayers [ m_VoteCreator ] - > m_Last_VoteCall = 0 ;
}
2010-10-11 11:10:39 +00:00
else if ( m_VoteEnforce = = VOTE_ENFORCE_YES_ADMIN )
{
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " Vote passed enforced by '%s' " , Server ( ) - > ClientName ( m_VoteEnforcer ) ) ;
Console ( ) - > ExecuteLine ( m_aVoteCommand , 3 , - 1 , CServer : : SendRconLineAuthed , Server ( ) , SendChatResponseAll , this ) ;
SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
dbg_msg ( " Vote " , " Due to vote enforcing, vote level has been set to 3 " ) ;
EndVote ( ) ;
m_VoteEnforcer = - 1 ;
}
else if ( m_VoteEnforce = = VOTE_ENFORCE_NO_ADMIN )
{
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " Vote failed enforced by '%s' " , Server ( ) - > ClientName ( m_VoteEnforcer ) ) ;
EndVote ( ) ;
SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
}
2010-05-29 07:25:38 +00:00
else if ( m_VoteEnforce = = VOTE_ENFORCE_NO | | time_get ( ) > m_VoteCloseTime )
{
EndVote ( ) ;
SendChat ( - 1 , CGameContext : : CHAT_ALL , " Vote failed " ) ;
}
else if ( m_VoteUpdate )
{
m_VoteUpdate = false ;
SendVoteStatus ( - 1 , Total , Yes , No ) ;
}
}
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
# ifdef CONF_DEBUG
if ( g_Config . m_DbgDummies )
{
for ( int i = 0 ; i < g_Config . m_DbgDummies ; i + + )
{
CNetObj_PlayerInput Input = { 0 } ;
Input . m_Direction = ( i & 1 ) ? - 1 : 1 ;
m_apPlayers [ MAX_CLIENTS - i - 1 ] - > OnPredictedInput ( & Input ) ;
}
}
2010-08-20 20:40:12 +00:00
# endif
2010-05-29 07:25:38 +00:00
}
// Server hooks
void CGameContext : : OnClientDirectInput ( int ClientID , void * pInput )
{
if ( ! m_World . m_Paused )
m_apPlayers [ ClientID ] - > OnDirectInput ( ( CNetObj_PlayerInput * ) pInput ) ;
}
void CGameContext : : OnClientPredictedInput ( int ClientID , void * pInput )
{
if ( ! m_World . m_Paused )
m_apPlayers [ ClientID ] - > OnPredictedInput ( ( CNetObj_PlayerInput * ) pInput ) ;
}
void CGameContext : : OnClientEnter ( int ClientId )
{
//world.insert_entity(&players[client_id]);
m_apPlayers [ ClientId ] - > Respawn ( ) ;
2010-09-26 15:18:56 +00:00
// init the player
2010-09-26 21:31:33 +00:00
2010-09-26 15:18:56 +00:00
Score ( ) - > PlayerData ( ClientId ) - > Reset ( ) ;
Score ( ) - > LoadScore ( ClientId ) ;
2010-09-26 21:31:33 +00:00
Score ( ) - > PlayerData ( ClientId ) - > m_CurrentTime = Score ( ) - > PlayerData ( ClientId ) - > m_BestTime ;
m_apPlayers [ ClientId ] - > m_Score = ( Score ( ) - > PlayerData ( ClientId ) - > m_BestTime ) ? Score ( ) - > PlayerData ( ClientId ) - > m_BestTime : - 9999 ;
2010-05-29 07:25:38 +00:00
char aBuf [ 512 ] ;
2010-09-12 11:34:30 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' entered and joined the %s " , Server ( ) - > ClientName ( ClientId ) , m_pController - > GetTeamName ( m_apPlayers [ ClientId ] - > GetTeam ( ) ) ) ;
2010-05-29 07:25:38 +00:00
SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
2010-09-26 15:18:56 +00:00
2010-07-29 19:51:58 +00:00
SendChatTarget ( ClientId , " DDRace Mod. Version: " DDRACE_VERSION ) ;
SendChatTarget ( ClientId , " Official site: DDRace.info " ) ;
SendChatTarget ( ClientId , " For more Info /CMDList " ) ;
SendChatTarget ( ClientId , " Or visit DDRace.info " ) ;
SendChatTarget ( ClientId , " To see this again say /info " ) ;
2010-10-19 00:03:59 +00:00
SendChatTarget ( ClientId , " Note This is an Alpha release, just for testing, your feedback is important!! " ) ;
2010-10-12 07:31:47 +00:00
2010-10-10 22:40:07 +00:00
if ( g_Config . m_SvWelcome [ 0 ] ! = 0 ) SendChatTarget ( ClientId , g_Config . m_SvWelcome ) ;
2010-10-24 10:47:25 +00:00
//str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), m_apPlayers[ClientId]->GetTeam());
2010-09-26 15:18:56 +00:00
2010-08-17 22:06:00 +00:00
Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_DEBUG , " game " , aBuf ) ;
2010-05-29 07:25:38 +00:00
m_VoteUpdate = true ;
}
2010-08-20 20:40:12 +00:00
bool compare_players ( CPlayer * pl1 , CPlayer * pl2 )
{
2010-10-11 08:37:33 +00:00
if ( ( ( pl1 - > m_Authed > = 0 ) ? pl1 - > m_Authed : 0 ) > ( ( pl2 - > m_Authed > = 0 ) ? pl2 - > m_Authed : 0 ) )
2010-10-10 22:40:07 +00:00
return true ;
else
return false ;
2010-08-20 20:40:12 +00:00
}
2010-07-29 05:21:18 +00:00
2010-08-20 20:40:12 +00:00
void CGameContext : : OnSetAuthed ( int client_id , int Level )
2010-07-29 19:55:33 +00:00
{
if ( m_apPlayers [ client_id ] )
{
2010-08-07 18:49:57 +00:00
m_apPlayers [ client_id ] - > m_Authed = Level ;
2010-07-29 19:55:33 +00:00
char buf [ 11 ] ;
2010-10-14 06:42:29 +00:00
str_format ( buf , sizeof ( buf ) , " ban %d %d " , client_id , g_Config . m_SvVoteKickBantime ) ;
2010-10-10 22:40:07 +00:00
if ( ! strcmp ( m_aVoteCommand , buf ) )
2010-07-29 19:55:33 +00:00
{
m_VoteEnforce = CGameContext : : VOTE_ENFORCE_NO ;
dbg_msg ( " hooks " , " Aborting vote " ) ;
}
}
2010-08-20 20:40:12 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : OnClientConnected ( int ClientId )
{
// Check which team the player should be on
const int StartTeam = g_Config . m_SvTournamentMode ? - 1 : m_pController - > GetAutoTeam ( ClientId ) ;
m_apPlayers [ ClientId ] = new ( ClientId ) CPlayer ( this , ClientId , StartTeam ) ;
//players[client_id].init(client_id);
//players[client_id].client_id = client_id;
2010-08-20 20:40:12 +00:00
2010-07-29 05:21:18 +00:00
//(void)m_pController->CheckTeamBalance();
2010-05-29 07:25:38 +00:00
# ifdef CONF_DEBUG
if ( g_Config . m_DbgDummies )
{
if ( ClientId > = MAX_CLIENTS - g_Config . m_DbgDummies )
return ;
}
# endif
// send active vote
if ( m_VoteCloseTime )
SendVoteSet ( ClientId ) ;
// send motd
CNetMsg_Sv_Motd Msg ;
Msg . m_pMessage = g_Config . m_SvMotd ;
Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , ClientId ) ;
}
void CGameContext : : OnClientDrop ( int ClientId )
{
AbortVoteKickOnDisconnect ( ClientId ) ;
m_apPlayers [ ClientId ] - > OnDisconnect ( ) ;
delete m_apPlayers [ ClientId ] ;
m_apPlayers [ ClientId ] = 0 ;
2010-08-20 20:40:12 +00:00
2010-07-29 05:21:18 +00:00
//(void)m_pController->CheckTeamBalance();
2010-05-29 07:25:38 +00:00
m_VoteUpdate = true ;
}
void CGameContext : : OnMessage ( int MsgId , CUnpacker * pUnpacker , int ClientId )
{
void * pRawMsg = m_NetObjHandler . SecureUnpackMsg ( MsgId , pUnpacker ) ;
2010-09-17 11:35:53 +00:00
CPlayer * pPlayer = m_apPlayers [ ClientId ] ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( ! pRawMsg )
{
2010-08-17 22:06:00 +00:00
char aBuf [ 256 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " dropped weird message '%s' (%d), failed on '%s' " , m_NetObjHandler . GetMsgName ( MsgId ) , MsgId , m_NetObjHandler . FailedMsgOn ( ) ) ;
Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " server " , aBuf ) ;
2010-05-29 07:25:38 +00:00
return ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( MsgId = = NETMSGTYPE_CL_SAY )
{
CNetMsg_Cl_Say * pMsg = ( CNetMsg_Cl_Say * ) pRawMsg ;
2010-10-07 12:10:49 +00:00
int Team = pMsg - > m_Team ;
2010-10-06 20:35:19 +00:00
//if(Team)
int GameTeam = ( ( CGameControllerDDRace * ) m_pController ) - > m_Teams . m_Core . Team ( pPlayer - > GetCID ( ) ) ;
2010-10-07 12:10:49 +00:00
if ( Team ) {
Team = ( pPlayer - > GetTeam ( ) = = - 1 ) ? CHAT_SPEC : ( GameTeam = = 0 ? CHAT_ALL : GameTeam ) ;
} else {
Team = CHAT_ALL ;
}
2010-08-20 20:40:12 +00:00
2010-09-16 21:26:03 +00:00
if ( str_length ( pMsg - > m_pMessage ) > 370 )
{
2010-07-30 12:50:09 +00:00
SendChatTarget ( ClientId , " Your Message is too long " ) ;
return ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
// check for invalid chars
unsigned char * pMessage = ( unsigned char * ) pMsg - > m_pMessage ;
while ( * pMessage )
{
if ( * pMessage < 32 )
* pMessage = ' ' ;
pMessage + + ;
}
2010-09-09 13:32:14 +00:00
if ( pMsg - > m_pMessage [ 0 ] = = ' / ' )
{
2010-10-10 22:40:07 +00:00
ChatResponseInfo Info ;
Info . m_GameContext = this ;
Info . m_To = ClientId ;
2010-08-20 20:40:12 +00:00
2010-10-10 22:40:07 +00:00
Console ( ) - > ExecuteLine ( pMsg - > m_pMessage + 1 , ( ( CServer * ) Server ( ) ) - > m_aClients [ ClientId ] . m_Authed , ClientId , CServer : : SendRconLineAuthed , Server ( ) , SendChatResponse , & Info ) ;
2010-09-09 13:32:14 +00:00
}
else if ( ! str_comp_nocase ( pMsg - > m_pMessage , " kill " ) )
2010-09-25 15:51:26 +00:00
SendChatTarget ( ClientId , " kill does nothing, say /kill if you want to die, also you can press f1 and type kill " ) ;
2010-09-16 21:26:03 +00:00
else
{
2010-10-10 22:40:07 +00:00
if ( m_apPlayers [ ClientId ] - > m_Muted = = 0 )
2010-10-11 08:37:33 +00:00
{
2010-10-14 06:42:29 +00:00
if ( /*g_Config.m_SvSpamprotection && */ pPlayer - > m_Last_Chat & & pPlayer - > m_Last_Chat + Server ( ) - > TickSpeed ( ) + g_Config . m_SvChatDelay > Server ( ) - > Tick ( ) )
2010-10-11 08:37:33 +00:00
return ;
2010-07-29 05:21:18 +00:00
SendChat ( ClientId , Team , pMsg - > m_pMessage ) ;
2010-10-14 06:42:29 +00:00
2010-10-11 08:37:33 +00:00
pPlayer - > m_Last_Chat = Server ( ) - > Tick ( ) ;
}
2010-07-29 05:21:18 +00:00
else
2010-09-25 15:51:26 +00:00
{
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " You are muted, Please wait for %d second(s) " , m_apPlayers [ ClientId ] - > m_Muted / Server ( ) - > TickSpeed ( ) ) ;
SendChatTarget ( ClientId , aBuf ) ;
}
2010-07-29 05:21:18 +00:00
}
2010-08-20 20:40:12 +00:00
2010-09-08 16:22:11 +00:00
}
2010-05-29 07:25:38 +00:00
else if ( MsgId = = NETMSGTYPE_CL_CALLVOTE )
{
2010-09-17 11:35:53 +00:00
if ( /*g_Config.m_SvSpamprotection && */ pPlayer - > m_Last_VoteTry & & pPlayer - > m_Last_VoteTry + Server ( ) - > TickSpeed ( ) * g_Config . m_SvVoteDelay > Server ( ) - > Tick ( ) )
2010-05-29 07:25:38 +00:00
return ;
int64 Now = Server ( ) - > Tick ( ) ;
2010-09-17 11:35:53 +00:00
pPlayer - > m_Last_VoteTry = Now ;
if ( pPlayer - > GetTeam ( ) = = - 1 )
2010-08-06 19:03:38 +00:00
{
SendChatTarget ( ClientId , " Spectators aren't allowed to start a vote. " ) ;
return ;
}
2010-05-29 07:25:38 +00:00
if ( m_VoteCloseTime )
{
SendChatTarget ( ClientId , " Wait for current vote to end before calling a new one. " ) ;
return ;
}
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
int Timeleft = pPlayer - > m_Last_VoteCall + Server ( ) - > TickSpeed ( ) * 60 - Now ;
if ( pPlayer - > m_Last_VoteCall & & Timeleft > 0 )
2010-05-29 07:25:38 +00:00
{
char aChatmsg [ 512 ] = { 0 } ;
str_format ( aChatmsg , sizeof ( aChatmsg ) , " You must wait %d seconds before making another vote " , ( Timeleft / Server ( ) - > TickSpeed ( ) ) + 1 ) ;
SendChatTarget ( ClientId , aChatmsg ) ;
return ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
char aChatmsg [ 512 ] = { 0 } ;
char aDesc [ 512 ] = { 0 } ;
char aCmd [ 512 ] = { 0 } ;
CNetMsg_Cl_CallVote * pMsg = ( CNetMsg_Cl_CallVote * ) pRawMsg ;
if ( str_comp_nocase ( pMsg - > m_Type , " option " ) = = 0 )
{
CVoteOption * pOption = m_pVoteOptionFirst ;
2010-07-29 19:55:33 +00:00
static int64 last_mapvote = 0 ; //floff
2010-05-29 07:25:38 +00:00
while ( pOption )
2008-10-21 17:26:32 +00:00
{
2010-05-29 07:25:38 +00:00
if ( str_comp_nocase ( pMsg - > m_Value , pOption - > m_aCommand ) = = 0 )
{
2010-09-13 04:49:01 +00:00
//str_format(aChatmsg, sizeof(aChatmsg), "'%s' called vote to change server option '%s'", Server()->ClientName(ClientId), pOption->m_aCommand);
2010-10-11 00:39:08 +00:00
if ( m_apPlayers [ ClientId ] - > m_Authed < = 0 & & strncmp ( pOption - > m_aCommand , " sv_map " , 7 ) = = 0 & & time_get ( ) < last_mapvote + ( time_freq ( ) * g_Config . m_SvVoteMapTimeDelay ) )
2010-08-20 20:40:12 +00:00
{
2010-07-29 19:55:33 +00:00
char chatmsg [ 512 ] = { 0 } ;
2010-07-30 12:50:09 +00:00
str_format ( chatmsg , sizeof ( chatmsg ) , " There's a %d second delay between map-votes,Please wait %d Second(s) " , g_Config . m_SvVoteMapTimeDelay , ( ( last_mapvote + ( g_Config . m_SvVoteMapTimeDelay * time_freq ( ) ) ) / time_freq ( ) ) - ( time_get ( ) / time_freq ( ) ) ) ;
2010-07-29 19:55:33 +00:00
SendChatTarget ( ClientId , chatmsg ) ;
2010-08-20 20:40:12 +00:00
2010-07-29 19:55:33 +00:00
return ;
}
2010-09-12 11:34:30 +00:00
str_format ( aChatmsg , sizeof ( aChatmsg ) , " '%s' called vote to change server option '%s' " , Server ( ) - > ClientName ( ClientId ) , pOption - > m_aCommand ) ;
2010-05-29 07:25:38 +00:00
str_format ( aDesc , sizeof ( aDesc ) , " %s " , pOption - > m_aCommand ) ;
str_format ( aCmd , sizeof ( aCmd ) , " %s " , pOption - > m_aCommand ) ;
2010-07-29 19:55:33 +00:00
last_mapvote = time_get ( ) ;
2010-05-29 07:25:38 +00:00
break ;
}
pOption = pOption - > m_pNext ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( ! pOption )
{
2010-10-11 09:18:44 +00:00
if ( pPlayer - > m_Authed < 3 ) // allow admins to call any vote they want
{
str_format ( aChatmsg , sizeof ( aChatmsg ) , " '%s' isn't an option on this server " , pMsg - > m_Value ) ;
SendChatTarget ( ClientId , aChatmsg ) ;
return ;
}
else
{
str_format ( aChatmsg , sizeof ( aChatmsg ) , " '%s' called vote to change server option '%s' " , Server ( ) - > ClientName ( ClientId ) , pMsg - > m_Value ) ;
str_format ( aDesc , sizeof ( aDesc ) , " %s " , pMsg - > m_Value ) ;
str_format ( aCmd , sizeof ( aCmd ) , " %s " , pMsg - > m_Value ) ;
}
2008-10-21 17:26:32 +00:00
}
2010-10-11 09:18:44 +00:00
2010-07-29 19:55:33 +00:00
last_mapvote = time_get ( ) ;
2010-09-08 16:22:11 +00:00
m_VoteKick = false ;
2010-05-29 07:25:38 +00:00
}
else if ( str_comp_nocase ( pMsg - > m_Type , " kick " ) = = 0 )
{
2010-08-20 20:40:12 +00:00
if ( m_apPlayers [ ClientId ] - > m_Authed = = 0 & & time_get ( ) < m_apPlayers [ ClientId ] - > m_Last_KickVote + ( time_freq ( ) * 5 ) )
2010-07-29 19:55:33 +00:00
return ;
2010-08-20 20:40:12 +00:00
else if ( m_apPlayers [ ClientId ] - > m_Authed = = 0 & & time_get ( ) < m_apPlayers [ ClientId ] - > m_Last_KickVote + ( time_freq ( ) * g_Config . m_SvVoteKickTimeDelay ) )
2010-07-29 19:55:33 +00:00
{
char chatmsg [ 512 ] = { 0 } ;
2010-09-16 22:38:39 +00:00
str_format ( chatmsg , sizeof ( chatmsg ) , " There's a %d second wait time between kick votes for each player please wait %d second(s) " ,
2010-07-30 12:50:09 +00:00
g_Config . m_SvVoteKickTimeDelay ,
( ( m_apPlayers [ ClientId ] - > m_Last_KickVote + ( m_apPlayers [ ClientId ] - > m_Last_KickVote * time_freq ( ) ) ) / time_freq ( ) ) - ( time_get ( ) / time_freq ( ) )
2010-07-29 19:55:33 +00:00
) ;
2010-07-30 12:50:09 +00:00
SendChatTarget ( ClientId , chatmsg ) ;
m_apPlayers [ ClientId ] - > m_Last_KickVote = time_get ( ) ;
2010-07-29 19:55:33 +00:00
return ;
}
2010-10-20 16:07:44 +00:00
else if ( ! g_Config . m_SvVoteKick & & pPlayer - > m_Authed < 2 ) // allow admins to call kick votes even if they are forbidden
2008-10-21 17:26:32 +00:00
{
2010-05-29 07:25:38 +00:00
SendChatTarget ( ClientId , " Server does not allow voting to kick players " ) ;
2010-07-30 12:50:09 +00:00
m_apPlayers [ ClientId ] - > m_Last_KickVote = time_get ( ) ;
2010-05-29 07:25:38 +00:00
return ;
2008-10-21 17:26:32 +00:00
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
int KickId = str_toint ( pMsg - > m_Value ) ;
if ( KickId < 0 | | KickId > = MAX_CLIENTS | | ! m_apPlayers [ KickId ] )
{
SendChatTarget ( ClientId , " Invalid client id to kick " ) ;
return ;
}
2010-06-02 02:42:17 +00:00
if ( KickId = = ClientId )
{
2010-10-11 08:37:33 +00:00
SendChatTarget ( ClientId , " You can't kick yourself " ) ;
2010-06-02 02:42:17 +00:00
return ;
}
2010-10-20 16:07:44 +00:00
if ( compare_players ( m_apPlayers [ KickId ] , pPlayer ) )
2010-06-02 02:42:17 +00:00
{
2010-09-16 22:38:39 +00:00
SendChatTarget ( ClientId , " You can't kick admins " ) ;
2010-07-30 12:50:09 +00:00
m_apPlayers [ ClientId ] - > m_Last_KickVote = time_get ( ) ;
2010-06-02 02:42:17 +00:00
char aBufKick [ 128 ] ;
2010-09-12 11:34:30 +00:00
str_format ( aBufKick , sizeof ( aBufKick ) , " '%s' called for vote to kick you " , Server ( ) - > ClientName ( ClientId ) ) ;
2010-06-02 02:42:17 +00:00
SendChatTarget ( KickId , aBufKick ) ;
return ;
}
2010-09-16 21:26:03 +00:00
if ( GetPlayerChar ( ClientId ) & & GetPlayerChar ( KickId ) & & GetPlayerChar ( ClientId ) - > Team ( ) ! = GetPlayerChar ( KickId ) - > Team ( ) )
{
2010-09-08 16:22:11 +00:00
SendChatTarget ( ClientId , " You can kick only your team member " ) ;
m_apPlayers [ ClientId ] - > m_Last_KickVote = time_get ( ) ;
return ;
}
2010-10-09 18:34:17 +00:00
const char * pReason = " No reason given " ;
2010-10-10 23:06:44 +00:00
for ( const char * p = pMsg - > m_Value ; * p ; + + p )
2010-10-09 18:34:17 +00:00
{
2010-10-10 23:06:44 +00:00
if ( * p = = ' ' )
{
pReason = p + 1 ;
break ;
}
2010-10-09 18:34:17 +00:00
}
str_format ( aChatmsg , sizeof ( aChatmsg ) , " '%s' called for vote to kick '%s' (%s) " , Server ( ) - > ClientName ( ClientId ) , Server ( ) - > ClientName ( KickId ) , pReason ) ;
2010-05-29 07:25:38 +00:00
str_format ( aDesc , sizeof ( aDesc ) , " Kick '%s' " , Server ( ) - > ClientName ( KickId ) ) ;
2010-10-10 22:40:07 +00:00
if ( ! g_Config . m_SvVoteKickBantime )
2010-10-13 18:31:21 +00:00
str_format ( aCmd , sizeof ( aCmd ) , " kick %d Kicked by vote " , KickId ) ;
2010-05-29 07:25:38 +00:00
else
{
char aBuf [ 64 ] = { 0 } ;
Server ( ) - > GetClientIP ( KickId , aBuf , sizeof ( aBuf ) ) ;
2010-10-13 18:31:21 +00:00
str_format ( aCmd , sizeof ( aCmd ) , " ban %s %d Banned by vote " , aBuf , g_Config . m_SvVoteKickBantime ) ;
2010-05-29 07:25:38 +00:00
}
2010-07-30 12:50:09 +00:00
m_apPlayers [ ClientId ] - > m_Last_KickVote = time_get ( ) ;
2010-09-08 16:22:11 +00:00
m_VoteKick = true ;
2010-05-29 07:25:38 +00:00
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( aCmd [ 0 ] )
{
SendChat ( - 1 , CGameContext : : CHAT_ALL , aChatmsg ) ;
StartVote ( aDesc , aCmd ) ;
2010-09-17 11:35:53 +00:00
pPlayer - > m_Vote = 1 ;
pPlayer - > m_VotePos = m_VotePos = 1 ;
2010-05-29 07:25:38 +00:00
m_VoteCreator = ClientId ;
2010-09-17 11:35:53 +00:00
pPlayer - > m_Last_VoteCall = Now ;
2010-05-29 07:25:38 +00:00
}
}
else if ( MsgId = = NETMSGTYPE_CL_VOTE )
{
if ( ! m_VoteCloseTime )
return ;
2010-09-17 11:35:53 +00:00
if ( pPlayer - > m_Vote = = 0 )
2010-05-29 07:25:38 +00:00
{
CNetMsg_Cl_Vote * pMsg = ( CNetMsg_Cl_Vote * ) pRawMsg ;
if ( ! pMsg - > m_Vote )
return ;
2010-09-17 11:35:53 +00:00
pPlayer - > m_Vote = pMsg - > m_Vote ;
pPlayer - > m_VotePos = + + m_VotePos ;
2010-05-29 07:25:38 +00:00
m_VoteUpdate = true ;
2008-09-25 12:23:44 +00:00
}
2008-09-24 14:47:03 +00:00
}
2010-10-10 22:40:07 +00:00
else if ( MsgId = = NETMSGTYPE_CL_SETTEAM & & ! m_World . m_Paused )
2010-05-29 07:25:38 +00:00
{
CNetMsg_Cl_SetTeam * pMsg = ( CNetMsg_Cl_SetTeam * ) pRawMsg ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
if ( pPlayer - > GetTeam ( ) = = pMsg - > m_Team | | ( /*g_Config.m_SvSpamprotection &&*/ pPlayer - > m_Last_SetTeam & & pPlayer - > m_Last_SetTeam + Server ( ) - > TickSpeed ( ) * g_Config . m_SvTeamChangeDelay > Server ( ) - > Tick ( ) ) )
2010-05-29 07:25:38 +00:00
return ;
// Switch team on given client and kill/respawn him
if ( m_pController - > CanJoinTeam ( pMsg - > m_Team , ClientId ) )
{
2010-09-17 11:35:53 +00:00
//if(m_pController->CanChangeTeam(pPlayer, pMsg->m_Team))
2010-07-29 05:21:18 +00:00
//{
2010-08-22 06:24:29 +00:00
//CCharacter* pChr=GetPlayerChar(ClientId);
2010-10-11 18:19:13 +00:00
if ( pPlayer - > GetTeam ( ) = = - 1 & & pPlayer - > m_InfoSaved )
SendChatTarget ( ClientId , " Use /pause first then you can kill " ) ;
else {
2010-09-17 11:35:53 +00:00
pPlayer - > m_Last_SetTeam = Server ( ) - > Tick ( ) ;
if ( pPlayer - > GetTeam ( ) = = - 1 | | pMsg - > m_Team = = - 1 )
2010-05-29 07:25:38 +00:00
m_VoteUpdate = true ;
2010-09-17 11:35:53 +00:00
pPlayer - > SetTeam ( pMsg - > m_Team ) ;
2010-10-11 00:49:20 +00:00
}
2010-10-11 18:19:13 +00:00
2010-08-22 06:24:29 +00:00
//if(pChr && pMsg->m_Team!=-1 && pChr->m_Paused)
//pChr->LoadPauseData();
//TODO:Check if this system Works
2010-07-29 05:21:18 +00:00
//(void)m_pController->CheckTeamBalance();
//}
//else
//SendBroadcast("Teams must be balanced, please join other team", ClientId);
2010-05-29 07:25:38 +00:00
}
else
{
char aBuf [ 128 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " Only %d active players are allowed " , g_Config . m_SvMaxClients - g_Config . m_SvSpectatorSlots ) ;
SendBroadcast ( aBuf , ClientId ) ;
}
}
2010-10-29 21:28:15 +00:00
else if ( MsgId = = NETMSGTYPE_CL_ISDDRACE )
2010-10-23 19:26:10 +00:00
{
2010-10-29 21:28:15 +00:00
pPlayer - > m_IsUsingDDRaceClient = true ;
2010-10-24 10:47:25 +00:00
char aBuf [ 128 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %d use DDRace Client " , pPlayer - > GetCID ( ) ) ;
dbg_msg ( " DDRace " , aBuf ) ;
( ( CGameControllerDDRace * ) m_pController ) - > m_Teams . SendTeamsState ( ClientId ) ;
2010-10-23 19:26:10 +00:00
}
2010-10-10 22:40:07 +00:00
else if ( MsgId = = NETMSGTYPE_CL_CHANGEINFO | | MsgId = = NETMSGTYPE_CL_STARTINFO )
2010-05-29 07:25:38 +00:00
{
CNetMsg_Cl_ChangeInfo * pMsg = ( CNetMsg_Cl_ChangeInfo * ) pRawMsg ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
if ( /*g_Config.m_SvSpamprotection &&*/ pPlayer - > m_Last_ChangeInfo & & pPlayer - > m_Last_ChangeInfo + Server ( ) - > TickSpeed ( ) * g_Config . m_SvInfoChangeDelay > Server ( ) - > Tick ( ) )
2010-05-29 07:25:38 +00:00
return ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
pPlayer - > m_Last_ChangeInfo = time_get ( ) ;
2010-10-10 22:40:07 +00:00
if ( ! pPlayer - > m_ColorSet | | g_Config . m_SvAllowColorChange )
2010-07-29 15:02:29 +00:00
{
2010-09-17 11:35:53 +00:00
pPlayer - > m_TeeInfos . m_UseCustomColor = pMsg - > m_UseCustomColor ;
pPlayer - > m_TeeInfos . m_ColorBody = pMsg - > m_ColorBody ;
pPlayer - > m_TeeInfos . m_ColorFeet = pMsg - > m_ColorFeet ;
2010-07-29 15:02:29 +00:00
}
2010-05-29 07:25:38 +00:00
// copy old name
char aOldName [ MAX_NAME_LENGTH ] ;
str_copy ( aOldName , Server ( ) - > ClientName ( ClientId ) , MAX_NAME_LENGTH ) ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
Server ( ) - > SetClientName ( ClientId , pMsg - > m_pName ) ;
if ( MsgId = = NETMSGTYPE_CL_CHANGEINFO & & str_comp ( aOldName , Server ( ) - > ClientName ( ClientId ) ) ! = 0 )
{
char aChatText [ 256 ] ;
2010-09-12 11:34:30 +00:00
str_format ( aChatText , sizeof ( aChatText ) , " '%s' changed name to '%s' " , aOldName , Server ( ) - > ClientName ( ClientId ) ) ;
2010-05-29 07:25:38 +00:00
SendChat ( - 1 , CGameContext : : CHAT_ALL , aChatText ) ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
// set skin
2010-09-17 11:35:53 +00:00
str_copy ( pPlayer - > m_TeeInfos . m_SkinName , pMsg - > m_pSkin , sizeof ( pPlayer - > m_TeeInfos . m_SkinName ) ) ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
//m_pController->OnPlayerInfoChange(pPlayer);
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
if ( MsgId = = NETMSGTYPE_CL_STARTINFO )
{
// send vote options
CNetMsg_Sv_VoteClearOptions ClearMsg ;
Server ( ) - > SendPackMsg ( & ClearMsg , MSGFLAG_VITAL , ClientId ) ;
CVoteOption * pCurrent = m_pVoteOptionFirst ;
while ( pCurrent )
{
CNetMsg_Sv_VoteOption OptionMsg ;
OptionMsg . m_pCommand = pCurrent - > m_aCommand ;
Server ( ) - > SendPackMsg ( & OptionMsg , MSGFLAG_VITAL , ClientId ) ;
pCurrent = pCurrent - > m_pNext ;
}
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
// send tuning parameters to client
SendTuningParams ( ClientId ) ;
//
CNetMsg_Sv_ReadyToEnter m ;
Server ( ) - > SendPackMsg ( & m , MSGFLAG_VITAL | MSGFLAG_FLUSH , ClientId ) ;
}
}
2010-10-10 22:40:07 +00:00
else if ( MsgId = = NETMSGTYPE_CL_EMOTICON & & ! m_World . m_Paused )
2010-05-29 07:25:38 +00:00
{
CNetMsg_Cl_Emoticon * pMsg = ( CNetMsg_Cl_Emoticon * ) pRawMsg ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
if ( /*g_Config.m_SvSpamprotection &&*/ pPlayer - > m_Last_Emote & & pPlayer - > m_Last_Emote + Server ( ) - > TickSpeed ( ) * g_Config . m_SvEmoticonDelay > Server ( ) - > Tick ( ) )
2010-05-29 07:25:38 +00:00
return ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
pPlayer - > m_Last_Emote = Server ( ) - > Tick ( ) ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
SendEmoticon ( ClientId , pMsg - > m_Emoticon ) ;
2010-09-17 11:35:53 +00:00
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
2010-10-10 22:40:07 +00:00
if ( pChr & & g_Config . m_SvEmotionalTees & & pChr - > m_EyeEmote )
2010-08-22 02:23:18 +00:00
{
switch ( pMsg - > m_Emoticon )
{
case EMOTICON_2 :
2010-08-22 12:32:52 +00:00
case EMOTICON_8 :
2010-08-22 02:23:18 +00:00
pChr - > m_EmoteType = EMOTE_SURPRISE ;
break ;
2010-08-27 07:09:47 +00:00
case EMOTICON_1 :
case EMOTICON_4 :
2010-08-22 12:32:52 +00:00
case EMOTICON_7 :
2010-08-27 07:09:47 +00:00
case EMOTICON_13 :
2010-08-22 02:23:18 +00:00
pChr - > m_EmoteType = EMOTE_BLINK ;
break ;
case EMOTICON_3 :
case EMOTICON_6 :
pChr - > m_EmoteType = EMOTE_HAPPY ;
break ;
case EMOTICON_9 :
2010-08-22 12:32:52 +00:00
case EMOTICON_15 :
2010-08-22 02:23:18 +00:00
pChr - > m_EmoteType = EMOTE_PAIN ;
break ;
case EMOTICON_10 :
case EMOTICON_11 :
case EMOTICON_12 :
pChr - > m_EmoteType = EMOTE_ANGRY ;
break ;
default :
break ;
}
pChr - > m_EmoteStop = Server ( ) - > Tick ( ) + 2 * Server ( ) - > TickSpeed ( ) ;
}
2010-05-29 07:25:38 +00:00
}
2010-08-23 19:37:27 +00:00
2010-10-10 22:40:07 +00:00
else if ( MsgId = = NETMSGTYPE_CL_KILL & & ! m_World . m_Paused )
2010-05-29 07:25:38 +00:00
{
2010-10-08 16:56:56 +00:00
if ( pPlayer - > m_Last_Kill & & pPlayer - > m_Last_Kill + Server ( ) - > TickSpeed ( ) * g_Config . m_SvKillDelay > Server ( ) - > Tick ( ) )
2010-05-29 07:25:38 +00:00
return ;
2010-08-20 20:40:12 +00:00
2010-09-17 11:35:53 +00:00
pPlayer - > m_Last_Kill = Server ( ) - > Tick ( ) ;
pPlayer - > KillCharacter ( WEAPON_SELF ) ;
2010-10-08 16:52:26 +00:00
pPlayer - > m_RespawnTick = Server ( ) - > Tick ( ) + Server ( ) - > TickSpeed ( ) * g_Config . m_SvSuicidePenalty ;
2010-05-29 07:25:38 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTuneParam ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
const char * pParamName = pResult - > GetString ( 0 ) ;
float NewValue = pResult - > GetFloat ( 1 ) ;
if ( pSelf - > Tuning ( ) - > Set ( pParamName , NewValue ) )
{
2010-09-12 11:06:43 +00:00
char aBuf [ 256 ] ;
2010-08-17 22:06:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s changed to %.2f " , pParamName , NewValue ) ;
2010-09-12 11:06:43 +00:00
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " tuning " , aBuf ) ;
2010-05-29 07:25:38 +00:00
pSelf - > SendTuningParams ( - 1 ) ;
}
else
2010-09-12 11:06:43 +00:00
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " tuning " , " No such tuning parameter " ) ;
2010-05-29 07:25:38 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTuneReset ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-17 11:35:53 +00:00
CTuningParams P ;
* pSelf - > Tuning ( ) = P ;
2010-05-29 07:25:38 +00:00
pSelf - > SendTuningParams ( - 1 ) ;
2010-08-17 22:06:00 +00:00
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " tuning " , " Tuning reset " ) ;
2010-05-29 07:25:38 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTuneDump ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-08-17 22:06:00 +00:00
char aBuf [ 256 ] ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < pSelf - > Tuning ( ) - > Num ( ) ; i + + )
{
float v ;
pSelf - > Tuning ( ) - > Get ( i , & v ) ;
2010-08-17 22:06:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s %.2f " , pSelf - > Tuning ( ) - > m_apNames [ i ] , v ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " tuning " , aBuf ) ;
2010-05-29 07:25:38 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConChangeMap ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > m_pController - > ChangeMap ( pResult - > GetString ( 0 ) ) ;
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConRestart ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
if ( pResult - > NumArguments ( ) )
pSelf - > m_pController - > DoWarmup ( pResult - > GetInteger ( 0 ) ) ;
else
pSelf - > m_pController - > StartRound ( ) ;
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConBroadcast ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > SendBroadcast ( pResult - > GetString ( 0 ) , - 1 ) ;
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConSay ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , pResult - > GetString ( 0 ) ) ;
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConSetTeam ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:57:50 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-05-29 07:25:38 +00:00
int Team = clamp ( pResult - > GetInteger ( 1 ) , - 1 , 1 ) ;
2010-08-17 22:06:00 +00:00
char aBuf [ 256 ] ;
2010-09-16 21:57:50 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " moved client %d to team %d " , Victim , Team ) ;
2010-08-17 22:06:00 +00:00
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , aBuf ) ;
2010-09-16 21:57:50 +00:00
if ( ! pSelf - > m_apPlayers [ Victim ] | | ! compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
if ( ! pSelf - > m_apPlayers [ Victim ] )
2010-05-29 07:25:38 +00:00
return ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
pSelf - > m_apPlayers [ ClientId ] - > SetTeam ( Team ) ;
2010-07-29 05:21:18 +00:00
//(void)pSelf->m_pController->CheckTeamBalance();
2010-05-29 07:25:38 +00:00
}
2010-07-29 05:21:18 +00:00
void CGameContext : : ConAddVote ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-25 16:30:35 +00:00
// check for valid option
if ( ! pSelf - > Console ( ) - > LineIsValid ( pResult - > GetString ( 0 ) ) )
{
char aBuf [ 256 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " skipped invalid option '%s' " , pResult - > GetString ( 0 ) ) ;
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , aBuf ) ;
return ;
}
2010-05-29 07:25:38 +00:00
int Len = str_length ( pResult - > GetString ( 0 ) ) ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
CGameContext : : CVoteOption * pOption = ( CGameContext : : CVoteOption * ) pSelf - > m_pVoteOptionHeap - > Allocate ( sizeof ( CGameContext : : CVoteOption ) + Len ) ;
pOption - > m_pNext = 0 ;
pOption - > m_pPrev = pSelf - > m_pVoteOptionLast ;
if ( pOption - > m_pPrev )
pOption - > m_pPrev - > m_pNext = pOption ;
pSelf - > m_pVoteOptionLast = pOption ;
if ( ! pSelf - > m_pVoteOptionFirst )
pSelf - > m_pVoteOptionFirst = pOption ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
mem_copy ( pOption - > m_aCommand , pResult - > GetString ( 0 ) , Len + 1 ) ;
2010-08-17 22:06:00 +00:00
char aBuf [ 256 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " added option '%s' " , pOption - > m_aCommand ) ;
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , aBuf ) ;
2010-05-29 07:25:38 +00:00
CNetMsg_Sv_VoteOption OptionMsg ;
OptionMsg . m_pCommand = pOption - > m_aCommand ;
pSelf - > Server ( ) - > SendPackMsg ( & OptionMsg , MSGFLAG_VITAL , - 1 ) ;
}
2010-10-14 10:11:17 +00:00
void CGameContext : : ConClearVotes ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > m_pVoteOptionHeap - > Reset ( ) ;
pSelf - > m_pVoteOptionFirst = 0 ;
pSelf - > m_pVoteOptionLast = 0 ;
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , " cleared vote options " ) ;
CNetMsg_Sv_VoteClearOptions ClearOptionsMsg ;
pSelf - > Server ( ) - > SendPackMsg ( & ClearOptionsMsg , MSGFLAG_VITAL , - 1 ) ;
}
2010-07-29 05:21:18 +00:00
void CGameContext : : ConVote ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-05-29 07:25:38 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-09 20:20:15 +00:00
char aBuf [ 64 ] ;
2010-05-29 07:25:38 +00:00
if ( str_comp_nocase ( pResult - > GetString ( 0 ) , " yes " ) = = 0 )
2010-10-11 11:10:39 +00:00
pSelf - > m_VoteEnforce = CGameContext : : VOTE_ENFORCE_YES_ADMIN ;
2010-05-29 07:25:38 +00:00
else if ( str_comp_nocase ( pResult - > GetString ( 0 ) , " no " ) = = 0 )
2010-10-11 11:10:39 +00:00
pSelf - > m_VoteEnforce = CGameContext : : VOTE_ENFORCE_NO_ADMIN ;
2010-09-09 20:20:15 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " vote forced to %s by %s " , pResult - > GetString ( 0 ) , pSelf - > Server ( ) - > ClientName ( ClientID ) ) ;
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
2010-08-17 22:06:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " forcing vote %s " , pResult - > GetString ( 0 ) ) ;
pSelf - > Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , aBuf ) ;
2010-10-11 11:10:39 +00:00
pSelf - > m_VoteEnforcer = ClientID ;
2010-05-29 07:25:38 +00:00
}
void CGameContext : : ConchainSpecialMotdupdate ( IConsole : : IResult * pResult , void * pUserData , IConsole : : FCommandCallback pfnCallback , void * pCallbackUserData )
{
2010-07-29 05:21:18 +00:00
pfnCallback ( pResult , pCallbackUserData , - 1 ) ;
2010-05-29 07:25:38 +00:00
if ( pResult - > NumArguments ( ) )
{
CNetMsg_Sv_Motd Msg ;
Msg . m_pMessage = g_Config . m_SvMotd ;
CGameContext * pSelf = ( CGameContext * ) pUserData ;
for ( int i = 0 ; i < MAX_CLIENTS ; + + i )
if ( pSelf - > m_apPlayers [ i ] )
pSelf - > Server ( ) - > SendPackMsg ( & Msg , MSGFLAG_VITAL , i ) ;
}
}
2010-07-29 05:21:18 +00:00
2010-10-10 22:40:07 +00:00
bool CGameContext : : CheatsAvailable ( IConsole * pConsole , int ClientId )
2010-09-16 21:26:03 +00:00
{
if ( ! g_Config . m_SvCheats )
{
2010-10-10 22:40:07 +00:00
pConsole - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " cheats " , " Cheats are not available on this server. " ) ;
2010-07-29 05:21:18 +00:00
}
return g_Config . m_SvCheats ;
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConGoLeft ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-08-20 20:40:12 +00:00
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) )
2010-07-29 05:21:18 +00:00
return ;
2010-09-16 21:27:44 +00:00
int Victim = - 1 ;
2010-09-16 21:22:00 +00:00
if ( pResult - > NumArguments ( ) )
2010-09-16 21:27:44 +00:00
Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
if ( Victim = = - 1 | | Victim = = ClientId )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . x - = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
2010-10-10 22:40:07 +00:00
else if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . x - = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
else
{
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pSelf - > m_apPlayers [ ClientId ] - > m_Authed > 1 ) ? " You can't move a player with the same or higher rank " : " You can't move others as a helper " ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:22:00 +00:00
2010-10-10 22:40:07 +00:00
void CGameContext : : ConGoRight ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:22:00 +00:00
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) )
2010-07-29 05:21:18 +00:00
return ;
2010-09-16 21:27:44 +00:00
int Victim = - 1 ;
2010-09-16 21:22:00 +00:00
if ( pResult - > NumArguments ( ) )
2010-09-16 21:27:44 +00:00
Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
if ( Victim = = - 1 | | Victim = = ClientId )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . x + = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
2010-10-10 22:40:07 +00:00
else if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . x + = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
else
{
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pSelf - > m_apPlayers [ ClientId ] - > m_Authed > 1 ) ? " You can't move a player with the same or higher rank " : " You can't move others as a helper " ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:22:00 +00:00
2010-10-10 22:40:07 +00:00
void CGameContext : : ConGoDown ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:22:00 +00:00
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) )
2010-07-29 05:21:18 +00:00
return ;
2010-09-16 21:27:44 +00:00
int Victim = - 1 ;
2010-09-16 21:22:00 +00:00
if ( pResult - > NumArguments ( ) )
2010-09-16 21:27:44 +00:00
Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
if ( Victim = = - 1 | | Victim = = ClientId )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . y + = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
2010-10-10 22:40:07 +00:00
else if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . y + = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
else
{
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pSelf - > m_apPlayers [ ClientId ] - > m_Authed > 1 ) ? " You can't move a player with the same or higher rank " : " You can't move others as a helper " ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:22:00 +00:00
2010-10-10 22:40:07 +00:00
void CGameContext : : ConGoUp ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:22:00 +00:00
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) )
2010-07-29 05:21:18 +00:00
return ;
2010-09-16 21:27:44 +00:00
int Victim = - 1 ;
2010-09-16 21:22:00 +00:00
if ( pResult - > NumArguments ( ) )
2010-09-16 21:27:44 +00:00
Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
if ( Victim = = - 1 | | Victim = = ClientId )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . y - = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
2010-10-10 22:40:07 +00:00
else if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-09-16 21:22:00 +00:00
if ( chr )
{
chr - > m_Core . m_Pos . y - = 32 ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-16 21:22:00 +00:00
}
}
else
{
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pSelf - > m_apPlayers [ ClientId ] - > m_Authed > 1 ) ? " You can't move a player with the same or higher rank " : " You can't move others as a helper " ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-10-10 22:40:07 +00:00
void CGameContext : : ConMute ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-07-29 05:21:18 +00:00
int Seconds = pResult - > GetInteger ( 1 ) ;
char buf [ 512 ] ;
2010-10-10 22:40:07 +00:00
if ( Seconds < 10 )
2010-07-29 05:21:18 +00:00
Seconds = 10 ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) ) )
2010-07-29 05:21:18 +00:00
{
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] - > m_Muted < Seconds * pSelf - > Server ( ) - > TickSpeed ( ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Muted = Seconds * pSelf - > Server ( ) - > TickSpeed ( ) ;
2010-07-29 05:21:18 +00:00
}
else
2010-09-16 21:27:44 +00:00
Seconds = pSelf - > m_apPlayers [ Victim ] - > m_Muted / pSelf - > Server ( ) - > TickSpeed ( ) ;
str_format ( buf , sizeof ( buf ) , " %s muted by %s for %d seconds " , pSelf - > Server ( ) - > ClientName ( Victim ) , pSelf - > Server ( ) - > ClientName ( ClientId ) , Seconds ) ;
2010-07-29 05:21:18 +00:00
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , buf ) ;
}
}
2010-10-10 22:40:07 +00:00
void CGameContext : : ConSetlvl3 ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-09-17 13:47:31 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) | | ClientId = = Victim ) )
2010-07-29 05:21:18 +00:00
{
2010-09-17 14:23:07 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Authed = 3 ;
2010-10-11 00:39:08 +00:00
pServ - > SetRconLevel ( Victim , 3 ) ;
2010-09-17 14:23:07 +00:00
}
}
2010-10-10 22:40:07 +00:00
void CGameContext : : ConSetlvl2 ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-17 14:23:07 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) | | ClientId = = Victim ) )
2010-09-17 14:23:07 +00:00
{
pSelf - > m_apPlayers [ Victim ] - > m_Authed = 2 ;
2010-10-11 00:39:08 +00:00
pServ - > SetRconLevel ( Victim , 2 ) ;
2010-09-17 14:23:07 +00:00
}
}
2010-10-10 22:40:07 +00:00
void CGameContext : : ConSetlvl1 ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-17 14:23:07 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) | | ClientId = = Victim ) )
2010-09-17 14:23:07 +00:00
{
pSelf - > m_apPlayers [ Victim ] - > m_Authed = 1 ;
2010-10-11 00:39:08 +00:00
pServ - > SetRconLevel ( Victim , 1 ) ;
2010-09-17 14:23:07 +00:00
}
}
2010-10-10 22:40:07 +00:00
void CGameContext : : ConLogOut ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-17 14:23:07 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = ClientId ;
2010-10-11 00:39:08 +00:00
if ( pResult - > NumArguments ( ) & & pSelf - > m_apPlayers [ Victim ] - > m_Authed > 1 )
2010-09-17 14:23:07 +00:00
Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) | | ClientId = = Victim ) )
2010-09-17 14:23:07 +00:00
{
2010-10-11 00:39:08 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Authed = - 1 ;
pServ - > SetRconLevel ( Victim , - 1 ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConKillPlayer ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
if ( ! pSelf - > m_apPlayers [ Victim ] )
2010-07-29 05:21:18 +00:00
return ;
2010-08-20 20:40:12 +00:00
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:27:44 +00:00
pSelf - > m_apPlayers [ Victim ] - > KillCharacter ( WEAPON_GAME ) ;
2010-07-29 05:21:18 +00:00
char buf [ 512 ] ;
2010-09-16 21:27:44 +00:00
str_format ( buf , sizeof ( buf ) , " %s killed by %s " , pSelf - > Server ( ) - > ClientName ( Victim ) , pSelf - > Server ( ) - > ClientName ( ClientId ) ) ;
2010-07-29 05:21:18 +00:00
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , buf ) ;
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConNinjaMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-08-20 20:40:12 +00:00
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
if ( chr )
{
2010-07-29 05:21:18 +00:00
chr - > GiveNinja ( ) ;
2010-07-29 14:53:25 +00:00
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConNinja ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-08-23 21:40:23 +00:00
if ( chr )
{
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-23 21:40:23 +00:00
{
chr - > GiveNinja ( ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-23 21:40:23 +00:00
}
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConHammer ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-07-29 05:21:18 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-07-29 05:21:18 +00:00
char buf [ 128 ] ;
2010-08-20 20:40:12 +00:00
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-07-29 05:21:18 +00:00
int type = pResult - > GetInteger ( 1 ) ;
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-07-29 05:21:18 +00:00
return ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
if ( type > 3 | | type < 0 )
2010-07-29 05:21:18 +00:00
{
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Select hammer between 0 and 3 " ) ;
2010-07-29 05:21:18 +00:00
}
else
{
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-23 21:40:23 +00:00
{
chr - > m_HammerType = type ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-17 14:37:03 +00:00
str_format ( buf , sizeof ( buf ) , " Hammer of '%s' ClientId=%d setted to %d " , pServ - > ClientName ( ClientId ) , Victim , type ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-08-23 21:40:23 +00:00
}
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConHammerMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-20 20:40:12 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-07-29 05:21:18 +00:00
char buf [ 128 ] ;
2010-08-20 14:57:42 +00:00
int type = pResult - > GetInteger ( 0 ) ;
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-07-29 05:21:18 +00:00
return ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-10-10 22:40:07 +00:00
if ( type > 3 | | type < 0 )
2010-07-29 05:21:18 +00:00
{
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Select hammer between 0 and 3 " ) ;
2010-07-29 05:21:18 +00:00
}
else
{
chr - > m_HammerType = type ;
2010-07-29 14:53:25 +00:00
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
str_format ( buf , sizeof ( buf ) , " Hammer setted to %d " , type ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConSuper ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-20 20:40:12 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-07 02:02:24 +00:00
if ( chr & & ! chr - > m_Super )
2010-07-29 05:21:18 +00:00
{
chr - > m_Super = true ;
2010-08-23 21:40:23 +00:00
chr - > UnFreeze ( ) ;
2010-10-02 00:06:42 +00:00
chr - > m_TeamBeforeSuper = chr - > Team ( ) ;
dbg_msg ( " Teamb4super " , " %d " , chr - > m_TeamBeforeSuper = chr - > Team ( ) ) ;
2010-09-21 23:41:23 +00:00
chr - > Teams ( ) - > SetCharacterTeam ( Victim , TEAM_SUPER ) ;
2010-07-29 14:53:25 +00:00
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConUnSuper ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-20 20:40:12 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-02 00:07:59 +00:00
if ( chr & & chr - > m_Super )
2010-07-29 05:21:18 +00:00
{
chr - > m_Super = false ;
2010-10-02 00:06:42 +00:00
chr - > Teams ( ) - > SetForceCharacterTeam ( Victim , chr - > m_TeamBeforeSuper ) ;
2010-07-29 05:21:18 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConSuperMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-20 20:40:12 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
if ( pSelf - > m_apPlayers [ ClientId ] )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-10-07 02:02:24 +00:00
if ( chr & & ! chr - > m_Super )
2010-07-29 05:21:18 +00:00
{
chr - > m_Super = true ;
2010-08-23 21:40:23 +00:00
chr - > UnFreeze ( ) ;
2010-10-02 00:06:42 +00:00
chr - > m_TeamBeforeSuper = chr - > Team ( ) ;
dbg_msg ( " Teamb4super " , " %d " , chr - > m_TeamBeforeSuper = chr - > Team ( ) ) ;
2010-09-21 23:41:23 +00:00
chr - > Teams ( ) - > SetCharacterTeam ( ClientId , TEAM_SUPER ) ;
2010-07-29 14:53:25 +00:00
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConUnSuperMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-20 20:40:12 +00:00
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
if ( pSelf - > m_apPlayers [ ClientId ] )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-10-02 00:07:59 +00:00
if ( chr & & chr - > m_Super )
2010-07-29 05:21:18 +00:00
{
chr - > m_Super = false ;
2010-10-02 00:06:42 +00:00
chr - > Teams ( ) - > SetForceCharacterTeam ( ClientId , chr - > m_TeamBeforeSuper ) ;
2010-07-29 05:21:18 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConShotgun ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-27 07:09:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-27 07:09:47 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-08-27 07:09:47 +00:00
if ( chr )
{
chr - > GiveWeapon ( WEAPON_SHOTGUN , - 1 ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-27 07:09:47 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConShotgunMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-27 07:09:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-08-27 07:09:47 +00:00
if ( chr )
{
chr - > GiveWeapon ( WEAPON_SHOTGUN , - 1 ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-27 07:09:47 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConGrenade ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-27 07:09:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-27 07:09:47 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-08-27 07:09:47 +00:00
if ( chr )
{
chr - > GiveWeapon ( WEAPON_GRENADE , - 1 ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-27 07:09:47 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConGrenadeMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-27 07:09:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-08-27 07:09:47 +00:00
if ( chr )
{
chr - > GiveWeapon ( WEAPON_GRENADE , - 1 ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-27 07:09:47 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConLaser ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-27 07:09:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-27 07:09:47 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-08-27 07:09:47 +00:00
if ( chr )
{
chr - > GiveWeapon ( WEAPON_RIFLE , - 1 ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-27 07:09:47 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConLaserMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-27 07:09:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-08-27 07:09:47 +00:00
if ( chr )
{
chr - > GiveWeapon ( WEAPON_RIFLE , - 1 ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-08-27 07:09:47 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConWeapons ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-07-29 05:21:18 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-07-29 05:21:18 +00:00
if ( chr )
{
chr - > GiveAllWeapons ( ) ;
2010-07-29 14:53:25 +00:00
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConWeaponsMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-07-29 05:21:18 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:26:03 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( ClientId ) ;
2010-08-20 17:06:49 +00:00
if ( chr )
2010-07-29 05:21:18 +00:00
{
2010-08-20 17:06:49 +00:00
chr - > GiveAllWeapons ( ) ;
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTeleport ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
2010-07-29 05:21:18 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
int cid2 = clamp ( pResult - > GetInteger ( 1 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-09-16 21:27:44 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & pSelf - > m_apPlayers [ cid2 ] )
2010-07-29 05:21:18 +00:00
{
2010-10-10 22:40:07 +00:00
if ( ClientId = = Victim
| | ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ cid2 ] ) )
2010-09-16 21:27:44 +00:00
| | ( compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) & & cid2 = = ClientId ) )
2010-07-29 05:21:18 +00:00
{
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-07-29 05:21:18 +00:00
if ( chr )
{
chr - > m_Core . m_Pos = pSelf - > m_apPlayers [ cid2 ] - > m_ViewPos ;
2010-07-29 14:53:25 +00:00
if ( ! g_Config . m_SvCheatTime )
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-07-29 05:21:18 +00:00
}
}
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTimerStop ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-07-29 05:21:18 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
char buf [ 128 ] ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-08-21 03:19:47 +00:00
if ( ! g_Config . m_SvTimer )
{
2010-08-20 20:40:12 +00:00
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-08-21 03:19:47 +00:00
return ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-23 21:40:23 +00:00
{
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-17 14:37:03 +00:00
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d Hasn't time now (Timer Stopped) " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-08-23 21:40:23 +00:00
}
2010-08-21 03:19:47 +00:00
}
else
{
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Timer commands are disabled " ) ;
2010-08-21 03:19:47 +00:00
}
}
2010-08-20 20:40:12 +00:00
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTimerStart ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-21 03:19:47 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
char buf [ 128 ] ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-08-21 03:19:47 +00:00
if ( ! g_Config . m_SvTimer )
{
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-08-20 17:06:49 +00:00
return ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-23 21:40:23 +00:00
{
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_STARTED ;
2010-09-17 14:37:03 +00:00
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d Has time now (Timer Started) " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-08-23 21:40:23 +00:00
}
2010-08-21 03:19:47 +00:00
}
else
{
2010-08-20 20:40:12 +00:00
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Timer commands are disabled " ) ;
2010-07-29 05:21:18 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTimerZero ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-21 03:19:47 +00:00
{
2010-09-17 00:59:43 +00:00
2010-08-21 03:19:47 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-08-21 03:19:47 +00:00
char buf [ 128 ] ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-09-17 00:59:43 +00:00
if ( ! g_Config . m_SvTimer )
2010-08-23 21:40:23 +00:00
{
2010-09-17 00:59:43 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-09-17 00:59:43 +00:00
return ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-17 00:59:43 +00:00
{
chr - > m_StartTime = pSelf - > Server ( ) - > Tick ( ) ;
chr - > m_RefreshTime = pSelf - > Server ( ) - > Tick ( ) ;
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_CHEAT ;
2010-09-17 14:37:03 +00:00
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d time has been reset & stopped. " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-09-17 00:59:43 +00:00
}
2010-08-23 21:40:23 +00:00
}
2010-09-17 00:59:43 +00:00
else
{
2010-08-21 03:19:47 +00:00
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Timer commands are disabled " ) ;
2010-09-17 00:59:43 +00:00
}
2010-08-21 03:19:47 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConTimerReStart ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-07-29 05:21:18 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > CheatsAvailable ( pSelf - > Console ( ) , ClientId ) ) return ;
2010-07-29 05:21:18 +00:00
char buf [ 128 ] ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2010-09-17 00:59:43 +00:00
if ( ! g_Config . m_SvTimer )
2010-08-23 21:40:23 +00:00
{
2010-09-17 00:59:43 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-09-17 00:59:43 +00:00
return ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-17 00:59:43 +00:00
{
chr - > m_StartTime = pSelf - > Server ( ) - > Tick ( ) ;
chr - > m_RefreshTime = pSelf - > Server ( ) - > Tick ( ) ;
2010-10-29 21:28:15 +00:00
chr - > m_DDRaceState = DDRACE_STARTED ;
2010-09-17 14:37:03 +00:00
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d time has been reset & stopped. " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-09-17 00:59:43 +00:00
}
2010-08-23 21:40:23 +00:00
}
2010-09-17 00:59:43 +00:00
else
{
2010-08-23 21:40:23 +00:00
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Timer commands are disabled " ) ;
2010-09-17 00:59:43 +00:00
}
2010-08-23 21:40:23 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConFreeze ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-23 21:40:23 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
//if(!pSelf->CheatsAvailable(pSelf->Console(), ClientId)) return;
2010-08-23 21:40:23 +00:00
char buf [ 128 ] ;
int time = - 1 ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-08-23 21:40:23 +00:00
if ( pResult - > NumArguments ( ) > 1 )
time = clamp ( pResult - > GetInteger ( 1 ) , - 1 , 29999 ) ;
2010-09-16 21:27:44 +00:00
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-08-23 21:40:23 +00:00
return ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-08-23 21:40:23 +00:00
{
chr - > Freeze ( ( ( time ! = 0 & & time ! = - 1 ) ? ( pSelf - > Server ( ) - > TickSpeed ( ) * time ) : ( - 1 ) ) ) ;
chr - > m_pPlayer - > m_RconFreeze = true ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d has been Frozen. " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-08-23 21:40:23 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConUnFreeze ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-08-23 21:40:23 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
//if(!pSelf->CheatsAvailable(pSelf->Console(), ClientId)) return;
2010-08-23 21:40:23 +00:00
char buf [ 128 ] ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
CCharacter * chr = pSelf - > GetPlayerChar ( Victim ) ;
2010-10-10 22:40:07 +00:00
if ( ! chr )
2010-08-23 21:40:23 +00:00
return ;
chr - > m_FreezeTime = 2 ;
chr - > m_pPlayer - > m_RconFreeze = false ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d has been UnFreezed. " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-08-20 20:40:12 +00:00
2010-07-29 05:21:18 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConInvisMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-14 16:56:28 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
//if(!pSelf->CheatsAvailable(pSelf->Console(), ClientId)) return;
if ( ! pSelf - > m_apPlayers [ ClientId ] )
2010-09-14 16:56:28 +00:00
return ;
2010-09-16 21:26:03 +00:00
pSelf - > m_apPlayers [ ClientId ] - > m_Invisible = true ;
2010-09-14 16:56:28 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConVisMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 20:44:59 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
//if(!pSelf->CheatsAvailable(pSelf->Console(), ClientId)) return;
if ( ! pSelf - > m_apPlayers [ ClientId ] )
2010-09-16 20:44:59 +00:00
return ;
2010-09-16 21:26:03 +00:00
pSelf - > m_apPlayers [ ClientId ] - > m_Invisible = false ;
2010-09-16 20:44:59 +00:00
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConInvis ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > m_apPlayers [ ClientId ] )
2010-09-16 21:22:00 +00:00
return ;
char buf [ 128 ] ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Invisible = true ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d is now invisible. " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-09-16 21:22:00 +00:00
}
}
2010-09-16 21:26:03 +00:00
void CGameContext : : ConVis ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-09-16 21:22:00 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-10 22:40:07 +00:00
if ( ! pSelf - > m_apPlayers [ ClientId ] )
2010-09-16 21:22:00 +00:00
return ;
char buf [ 128 ] ;
2010-09-16 21:27:44 +00:00
int Victim = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
2010-10-10 22:40:07 +00:00
if ( pSelf - > m_apPlayers [ Victim ] & & compare_players ( pSelf - > m_apPlayers [ ClientId ] , pSelf - > m_apPlayers [ Victim ] ) )
2010-09-16 21:22:00 +00:00
{
2010-09-16 21:27:44 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Invisible = false ;
2010-09-17 14:37:03 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
str_format ( buf , sizeof ( buf ) , " '%s' ClientId=%d is visible. " , pServ - > ClientName ( ClientId ) , Victim ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
2010-09-16 21:22:00 +00:00
}
}
2010-10-10 22:40:07 +00:00
void CGameContext : : ConCredits ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " This mod was originally created by 3DA " ) ;
2010-10-19 00:03:59 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Now it is maintained & coded by: " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " [Egypt]GreYFoX@GTi and [BlackTee]den among others: " ) ;
2010-10-18 23:53:00 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Code: heinrich5991 " ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Documentation: Zeta-Hoernchen " ) ;
2010-10-18 23:53:00 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Code (in the past): LemonFace, noother and Fluxid " ) ;
2010-10-10 22:40:07 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Please check the changelog on DDRace.info. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Also the commit log on github.com/GreYFoXGTi/DDRace. " ) ;
}
void CGameContext : : ConInfo ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " DDRace Mod. Version: " DDRACE_VERSION ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Official site: DDRace.info " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " For more Info /CMDList " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Or visit DDRace.info " ) ;
}
void CGameContext : : ConCmdList ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-10-12 09:48:45 +00:00
if ( pSelf - > m_apPlayers [ ClientId ] - > m_Authed = = 3 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " O Really!!, You call yourself an admin!! " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " check the documentation on DDRace.info " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " leave cmdlist for others.. too many commands to show you here " ) ;
}
else
pSelf - > Console ( ) - > List ( pSelf - > m_apPlayers [ ClientId ] - > m_Authed , CFGFLAG_SERVER ) ;
2010-10-10 22:40:07 +00:00
}
void CGameContext : : ConHelp ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
if ( pResult - > NumArguments ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " /cmdlist will show a list of all chat commands " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " /help + any command will show you the help for this command " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Example /help flags will display the help about " ) ;
}
else
{
2010-10-12 08:44:24 +00:00
const char * pArg = pResult - > GetString ( 0 ) ;
IConsole : : CCommandInfo * pCmdInfo = pSelf - > Console ( ) - > GetCommandInfo ( pArg , CFGFLAG_SERVER ) ;
if ( pCmdInfo & & pCmdInfo - > m_pHelp )
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , pCmdInfo - > m_pHelp ) ;
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Command is either unknown or you have given a blank command without any parameters. " ) ;
2010-10-10 22:40:07 +00:00
}
}
void CGameContext : : ConFlags ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
char buf [ 64 ] ;
float temp1 ;
float temp2 ;
pSelf - > m_Tuning . Get ( " player_collision " , & temp1 ) ;
pSelf - > m_Tuning . Get ( " player_hooking " , & temp2 ) ;
str_format ( buf , sizeof ( buf ) , " Flags: cheats[%s]%s%s collision[%s] hooking[%s] " ,
g_Config . m_SvCheats ? " yes " : " no " ,
( g_Config . m_SvCheats ) ? " w/Time " : " " ,
( g_Config . m_SvCheats ) ? ( g_Config . m_SvCheatTime ) ? " [yes] " : " [no] " : " " ,
temp1 ? " yes " : " no " ,
temp2 ? " yes " : " no " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
str_format ( buf , sizeof ( buf ) , " endless hook[%s] weapons effect others[%s] " , g_Config . m_SvEndlessDrag ? " yes " : " no " , g_Config . m_SvHit ? " yes " : " no " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
if ( g_Config . m_SvPauseable )
{
str_format ( buf , sizeof ( buf ) , " Server Allows /pause with%s " , g_Config . m_SvPauseTime ? " time pause. " : " out time pause. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , buf ) ;
}
}
void CGameContext : : ConRules ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
bool printed = false ;
if ( g_Config . m_SvDDRaceRules )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No blocking. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No insulting / spamming. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No fun voting / vote spamming. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Breaking any of these rules will result in a penalty, decided by server admins. " ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine1 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine1 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine2 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine2 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine3 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine3 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine4 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine4 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine5 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine5 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine6 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine6 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine7 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine7 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine8 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine8 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine9 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine9 ) ;
printed = true ;
}
if ( g_Config . m_SvRulesLine10 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine10 ) ;
printed = true ;
}
if ( ! printed )
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No Rules Defined, Kill em all!! " ) ;
}
void CGameContext : : ConKill ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientId ] ;
if ( pPlayer - > m_Last_Kill & & pPlayer - > m_Last_Kill + pSelf - > Server ( ) - > TickSpeed ( ) * g_Config . m_SvKillDelay > pSelf - > Server ( ) - > Tick ( ) )
return ;
pPlayer - > m_Last_Kill = pSelf - > Server ( ) - > Tick ( ) ;
pPlayer - > KillCharacter ( WEAPON_SELF ) ;
pPlayer - > m_RespawnTick = pSelf - > Server ( ) - > Tick ( ) + pSelf - > Server ( ) - > TickSpeed ( ) * g_Config . m_SvSuicidePenalty ;
}
void CGameContext : : ConTogglePause ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientId ] ;
if ( g_Config . m_SvPauseable )
{
CCharacter * chr = pPlayer - > GetCharacter ( ) ;
if ( ! pPlayer - > GetTeam ( ) & & chr & & ( ! chr - > m_aWeapons [ WEAPON_NINJA ] . m_Got | | chr - > m_FreezeTime ) & & chr - > IsGrounded ( ) & & chr - > m_Pos = = chr - > m_PrevPos & & ! pPlayer - > m_InfoSaved )
{
pPlayer - > SaveCharacter ( ) ;
pPlayer - > SetTeam ( - 1 ) ;
pPlayer - > m_InfoSaved = true ;
}
else if ( pPlayer - > GetTeam ( ) = = - 1 & & pPlayer - > m_InfoSaved )
{
pPlayer - > m_InfoSaved = false ;
pPlayer - > m_PauseInfo . m_Respawn = true ;
pPlayer - > SetTeam ( 0 ) ;
//pPlayer->LoadCharacter();//TODO:Check if this system Works
}
else if ( chr )
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( chr - > m_aWeapons [ WEAPON_NINJA ] . m_Got ) ? " You can't use /pause while you are a ninja " : ( ! chr - > IsGrounded ( ) ) ? " You can't use /pause while you are a in air " : " You can't use /pause while you are moving " ) ;
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No pause data saved. " ) ;
}
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Pause isn't allowed on this server. " ) ;
}
void CGameContext : : ConTop5 ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientId ] ;
if ( g_Config . m_SvHideScore )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Showing the top 5 is not allowed on this server. " ) ;
return ;
}
if ( pResult - > NumArguments ( ) > 0 )
pSelf - > Score ( ) - > ShowTop5 ( pPlayer - > GetCID ( ) , pResult - > GetInteger ( 0 ) ) ;
else
pSelf - > Score ( ) - > ShowTop5 ( pPlayer - > GetCID ( ) ) ;
}
void CGameContext : : ConRank ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientId ] ;
if ( pResult - > NumArguments ( ) > 0 )
if ( ! g_Config . m_SvHideScore )
pSelf - > Score ( ) - > ShowRank ( pPlayer - > GetCID ( ) , pResult - > GetString ( 0 ) , true ) ;
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Showing the rank of other players is not allowed on this server. " ) ;
else
pSelf - > Score ( ) - > ShowRank ( pPlayer - > GetCID ( ) , pSelf - > Server ( ) - > ClientName ( ClientId ) ) ;
}
void CGameContext : : ConBroadTime ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CCharacter * pChr = pSelf - > m_apPlayers [ ClientId ] - > GetCharacter ( ) ;
if ( pChr )
pChr - > m_BroadTime = ! pChr - > m_BroadTime ;
}
void CGameContext : : ConJoinTeam ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientId ] ;
if ( pResult - > NumArguments ( ) > 0 )
{
if ( pPlayer - > GetCharacter ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You can't change teams while you are dead/a spectator. " ) ;
}
else
{
if ( ( ( CGameControllerDDRace * ) pSelf - > m_pController ) - > m_Teams . SetCharacterTeam ( pPlayer - > GetCID ( ) , pResult - > GetInteger ( 0 ) ) )
{
char aBuf [ 512 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %s joined team %d " , pSelf - > Server ( ) - > ClientName ( pPlayer - > GetCID ( ) ) , pResult - > GetInteger ( 0 ) ) ;
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
}
else
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You cannot join this team " ) ;
}
}
}
else
{
char aBuf [ 512 ] ;
if ( pPlayer - > GetCharacter ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You can't check your team while you are dead/a spectator. " ) ;
}
else
{
str_format ( aBuf , sizeof ( aBuf ) , " You are in team %d " , pPlayer - > GetCharacter ( ) - > Team ( ) ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
}
}
}
void CGameContext : : ConToggleFly ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CCharacter * pChr = pSelf - > m_apPlayers [ ClientId ] - > GetCharacter ( ) ;
if ( pChr & & pChr - > m_Super )
{
pChr - > m_Fly = ! pChr - > m_Fly ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pChr - > m_Fly ) ? " Fly enabled " : " Fly disabled " ) ;
}
}
2010-10-11 08:37:33 +00:00
void CGameContext : : ConMe ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
char aBuf [ 256 + 24 ] ;
str_format ( aBuf , 256 + 24 , " %s %s " , pSelf - > Server ( ) - > ClientName ( ClientId ) , pResult - > GetString ( 0 ) ) ;
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
}
2010-10-10 22:40:07 +00:00
2010-10-11 08:37:33 +00:00
void CGameContext : : ConToggleEyeEmote ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CCharacter * pChr = pSelf - > m_apPlayers [ ClientId ] - > GetCharacter ( ) ;
2010-10-10 22:40:07 +00:00
2010-10-11 08:37:33 +00:00
if ( pChr )
{
pChr - > m_EyeEmote = ! pChr - > m_EyeEmote ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pChr - > m_EyeEmote ) ? " You can now use the preset eye emotes. " : " You don't have any eye emotes, remember to bind some. (until you die) " ) ;
}
}
2010-10-10 22:40:07 +00:00
2010-10-12 08:02:46 +00:00
void CGameContext : : ConToggleBroadcast ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
2010-10-11 08:37:33 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CCharacter * pChr = pSelf - > m_apPlayers [ ClientId ] - > GetCharacter ( ) ;
if ( pChr )
pChr - > m_BroadCast = ! pChr - > m_BroadCast ;
}
void CGameContext : : ConEyeEmote ( IConsole : : IResult * pResult , void * pUserData , int ClientId )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CCharacter * pChr = pSelf - > m_apPlayers [ ClientId ] - > GetCharacter ( ) ;
if ( pResult - > NumArguments ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Emote commands are: /emote surprise /emote blink /emote close /emote angry /emote happy /emote pain " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Example: /emote surprise 10 for 10 seconds or /emote surprise (default 1 second) " ) ;
}
else
{
if ( pChr )
{
if ( ! str_comp ( pResult - > GetString ( 0 ) , " angry " ) )
pChr - > m_EmoteType = EMOTE_ANGRY ;
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " blink " ) )
pChr - > m_EmoteType = EMOTE_BLINK ;
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " close " ) )
pChr - > m_EmoteType = EMOTE_BLINK ;
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " happy " ) )
pChr - > m_EmoteType = EMOTE_HAPPY ;
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " pain " ) )
pChr - > m_EmoteType = EMOTE_PAIN ;
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " surprise " ) )
pChr - > m_EmoteType = EMOTE_SURPRISE ;
else
2010-10-10 22:40:07 +00:00
{
2010-10-11 08:37:33 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Unkown emote... Say /emote " ) ;
2010-10-10 22:40:07 +00:00
}
2010-10-11 08:37:33 +00:00
int Duration = 1 ;
if ( pResult - > NumArguments ( ) > 1 )
Duration = pResult - > GetInteger ( 1 ) ;
pChr - > m_EmoteStop = pSelf - > Server ( ) - > Tick ( ) + Duration * pSelf - > Server ( ) - > TickSpeed ( ) ;
}
}
}
2010-10-10 22:40:07 +00:00
2010-05-29 07:25:38 +00:00
void CGameContext : : OnConsoleInit ( )
{
m_pServer = Kernel ( ) - > RequestInterface < IServer > ( ) ;
m_pConsole = Kernel ( ) - > RequestInterface < IConsole > ( ) ;
2010-09-16 22:40:44 +00:00
Console ( ) - > Register ( " change_map " , " r " , CFGFLAG_SERVER , ConChangeMap , this , " Changes the map to r " , 3 ) ;
2010-09-16 21:22:00 +00:00
Console ( ) - > Register ( " restart " , " ?i " , CFGFLAG_SERVER , ConRestart , this , " Kills all players " , 3 ) ;
2010-09-16 22:40:44 +00:00
Console ( ) - > Register ( " broadcast " , " r " , CFGFLAG_SERVER , ConBroadcast , this , " Changes the broadcast message for a moment " , 3 ) ;
2010-09-16 22:58:54 +00:00
Console ( ) - > Register ( " say " , " r " , CFGFLAG_SERVER , ConSay , this , " Sends a server message to all players " , 3 ) ;
2010-09-16 21:22:00 +00:00
Console ( ) - > Register ( " set_team " , " ii " , CFGFLAG_SERVER , ConSetTeam , this , " Changes the team of player i1 to team i2 " , 2 ) ;
2010-10-14 10:11:17 +00:00
Console ( ) - > Register ( " addvote " , " r " , CFGFLAG_SERVER , ConAddVote , this , " Adds a vote entry to the clients " , 4 ) ;
Console ( ) - > Register ( " clear_votes " , " " , CFGFLAG_SERVER , ConClearVotes , this , " Clears the vote list " , 4 ) ;
2010-09-16 21:22:00 +00:00
2010-09-16 22:40:44 +00:00
Console ( ) - > Register ( " tune " , " si " , CFGFLAG_SERVER , ConTuneParam , this , " Modifies tune parameter s to value i " , 4 ) ;
Console ( ) - > Register ( " tune_reset " , " " , CFGFLAG_SERVER , ConTuneReset , this , " Resets all tuning " , 4 ) ;
Console ( ) - > Register ( " tune_dump " , " " , CFGFLAG_SERVER , ConTuneDump , this , " Shows all tuning options " , 4 ) ;
Console ( ) - > Register ( " kill_pl " , " i " , CFGFLAG_SERVER , ConKillPlayer , this , " Kills player i and announces the kill " , 2 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " logout " , " ?i " , CFGFLAG_SERVER , ConLogOut , this , " If you are a helper or didn't specify [i] it logs you out, otherwise it logs player i out " , 0 ) ;
2010-09-17 14:23:07 +00:00
Console ( ) - > Register ( " helper " , " i " , CFGFLAG_SERVER , ConSetlvl1 , this , " Authenticates player i to the Level of 1 " , 2 ) ;
Console ( ) - > Register ( " moder " , " i " , CFGFLAG_SERVER , ConSetlvl2 , this , " Authenticates player i to the Level of 2 " , 3 ) ;
2010-10-10 22:40:07 +00:00
Console ( ) - > Register ( " admin " , " i " , CFGFLAG_SERVER , ConSetlvl3 , this , " Authenticates player i to the Level of 3 (CAUTION: Irreversible, once he is an admin you can't control him) " , 3 ) ;
2010-09-16 22:40:44 +00:00
Console ( ) - > Register ( " mute " , " ii " , CFGFLAG_SERVER , ConMute , this , " Mutes player i1 for i2 seconds " , 2 ) ;
2010-09-16 22:58:54 +00:00
Console ( ) - > Register ( " vote " , " r " , CFGFLAG_SERVER , ConVote , this , " Forces the current vote to result in r (Yes/No) " , 3 ) ;
2010-09-16 22:40:44 +00:00
Console ( ) - > Register ( " invis_me " , " " , CFGFLAG_SERVER , ConInvisMe , this , " Makes you invisible " , 1 ) ;
Console ( ) - > Register ( " vis_me " , " " , CFGFLAG_SERVER , ConVisMe , this , " Makes you visible again " , 1 ) ;
Console ( ) - > Register ( " invis " , " i " , CFGFLAG_SERVER , ConInvis , this , " Makes player i invisible " , 2 ) ;
Console ( ) - > Register ( " vis " , " i " , CFGFLAG_SERVER , ConVis , this , " Makes player i visible again " , 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 ( " timerrestart " , " i " , CFGFLAG_SERVER , ConTimerReStart , this , " Sets the timer of player i to 0 and starts it " , 2 ) ;
Console ( ) - > Register ( " timerzero " , " i " , CFGFLAG_SERVER , ConTimerZero , this , " Sets the timer of player i to 0 and stops it " , 2 ) ;
Console ( ) - > Register ( " tele " , " ii " , CFGFLAG_SERVER , ConTeleport , this , " Teleports player i1 to player i2 " , 2 ) ;
Console ( ) - > Register ( " freeze " , " i?i " , CFGFLAG_SERVER , ConFreeze , this , " Freezes player i1 for i2 seconds (infinity by default) " , 2 ) ;
Console ( ) - > Register ( " unfreeze " , " i " , CFGFLAG_SERVER , ConUnFreeze , this , " Unfreezes player i " , 2 ) ;
Console ( ) - > Register ( " shotgun " , " i " , CFGFLAG_SERVER , ConShotgun , this , " Gives a shotgun to player i " , 2 ) ;
Console ( ) - > Register ( " shotgun_me " , " " , CFGFLAG_SERVER , ConShotgunMe , this , " Gives shotgun to yourself " , 1 ) ;
Console ( ) - > Register ( " grenade " , " i " , CFGFLAG_SERVER , ConGrenade , this , " Gives a grenade launcher to player i " , 2 ) ;
Console ( ) - > Register ( " grenade_me " , " " , CFGFLAG_SERVER , ConGrenadeMe , this , " Gives grenade launcher to yourself " , 1 ) ;
Console ( ) - > Register ( " laser " , " i " , CFGFLAG_SERVER , ConLaser , this , " Gives a lasergun to player i " , 2 ) ;
Console ( ) - > Register ( " laser_me " , " " , CFGFLAG_SERVER , ConLaserMe , this , " Gives lasergun to yourself " , 1 ) ;
Console ( ) - > Register ( " weapons " , " i " , CFGFLAG_SERVER , ConWeapons , this , " Gives all weapons to player i " , 2 ) ;
Console ( ) - > Register ( " weapons_me " , " " , CFGFLAG_SERVER , ConWeaponsMe , this , " Gives all weapons to yourself " , 1 ) ;
Console ( ) - > Register ( " ninja " , " i " , CFGFLAG_SERVER , ConNinja , this , " Makes player i a ninja " , 2 ) ;
Console ( ) - > Register ( " ninja_me " , " " , CFGFLAG_SERVER , ConNinjaMe , this , " Makes yourself a ninja " , 1 ) ;
Console ( ) - > Register ( " hammer_me " , " i " , CFGFLAG_SERVER , ConHammerMe , this , " Sets your hammer power to i " , 1 ) ;
Console ( ) - > Register ( " hammer " , " ii " , CFGFLAG_SERVER , ConHammer , this , " Sets the hammer power of player i1 to i2 " , 2 ) ;
Console ( ) - > Register ( " super " , " i " , CFGFLAG_SERVER , ConSuper , this , " Makes player i super " , 2 ) ;
Console ( ) - > Register ( " unsuper " , " i " , CFGFLAG_SERVER , ConUnSuper , this , " Removes super from player i " , 2 ) ;
Console ( ) - > Register ( " super_me " , " " , CFGFLAG_SERVER , ConSuperMe , this , " Makes yourself super " , 1 ) ;
2010-10-11 00:39:08 +00:00
Console ( ) - > Register ( " unsuper_me " , " " , CFGFLAG_SERVER , ConUnSuperMe , this , " Removes super from yourself " , 1 ) ;
2010-09-16 22:40:44 +00:00
Console ( ) - > Register ( " left " , " ?i " , CFGFLAG_SERVER , ConGoLeft , this , " Makes you or player i move 1 tile left " , 1 ) ;
Console ( ) - > Register ( " right " , " ?i " , CFGFLAG_SERVER , ConGoRight , this , " Makes you or player i move 1 tile right " , 1 ) ;
Console ( ) - > Register ( " up " , " ?i " , CFGFLAG_SERVER , ConGoUp , this , " Makes you or player i move 1 tile up " , 1 ) ;
Console ( ) - > Register ( " down " , " ?i " , CFGFLAG_SERVER , ConGoDown , this , " Makes you or player i move 1 tile down " , 1 ) ;
2010-05-29 07:25:38 +00:00
2010-10-12 08:02:46 +00:00
Console ( ) - > Register ( " broadtime " , " " , CFGFLAG_SERVER , ConBroadTime , this , " Toggles Showing the time string in race " , - 1 ) ;
2010-10-11 00:39:08 +00:00
Console ( ) - > Register ( " cmdlist " , " " , CFGFLAG_SERVER , ConCmdList , this , " Shows the list of all commands " , - 1 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " credits " , " " , CFGFLAG_SERVER , ConCredits , this , " Shows the credits of the DDRace mod " , - 1 ) ;
Console ( ) - > Register ( " emote " , " ?s?i " , CFGFLAG_SERVER , ConEyeEmote , this , " Sets your tee's eye emote " , - 1 ) ;
2010-10-12 08:02:46 +00:00
Console ( ) - > Register ( " broadmsg " , " " , CFGFLAG_SERVER , ConToggleBroadcast , this , " Toggle Showing the Server's Broadcast message during race " , - 1 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " eyeemote " , " " , CFGFLAG_SERVER , ConEyeEmote , this , " Toggles whether you automatically use eyeemotes with standard emotes " , - 1 ) ;
2010-10-11 00:39:08 +00:00
Console ( ) - > Register ( " flags " , " " , CFGFLAG_SERVER , ConFlags , this , " Shows gameplay information for this server " , - 1 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " fly " , " " , CFGFLAG_SERVER , ConToggleFly , this , " Toggles whether you fly by pressing jump " , 1 ) ;
Console ( ) - > Register ( " help " , " ?r " , CFGFLAG_SERVER , ConHelp , this , " Helps you with commands " , - 1 ) ;
Console ( ) - > Register ( " info " , " " , CFGFLAG_SERVER , ConInfo , this , " Shows info about this server " , - 1 ) ;
2010-10-11 00:39:08 +00:00
Console ( ) - > Register ( " kill " , " " , CFGFLAG_SERVER , ConKill , this , " Kills you " , - 1 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " me " , " s " , CFGFLAG_SERVER , ConMe , this , " " , - 1 ) ; // TODO: add help text, cause idk how to describe this (heinrich5991)
2010-10-11 00:39:08 +00:00
Console ( ) - > Register ( " pause " , " " , CFGFLAG_SERVER , ConTogglePause , this , " If enabled on this server it pauses the game for you " , - 1 ) ;
Console ( ) - > Register ( " rank " , " ?r " , CFGFLAG_SERVER , ConRank , this , " Shows either your rank or the rank of the given player " , - 1 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " rules " , " " , CFGFLAG_SERVER , ConRules , this , " Shows the rules of this server " , - 1 ) ;
2010-10-11 00:39:08 +00:00
Console ( ) - > Register ( " team " , " ?i " , CFGFLAG_SERVER , ConJoinTeam , this , " Lets you join the specified team " , - 1 ) ;
2010-10-11 08:37:33 +00:00
Console ( ) - > Register ( " top5 " , " ?i " , CFGFLAG_SERVER , ConTop5 , this , " Shows the top 5 from the 1st, or starting at the specified number " , - 1 ) ;
2010-10-10 22:40:07 +00:00
2010-05-29 07:25:38 +00:00
Console ( ) - > Chain ( " sv_motd " , ConchainSpecialMotdupdate , this ) ;
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
}
void CGameContext : : OnInit ( /*class IKernel *pKernel*/ )
{
m_pServer = Kernel ( ) - > RequestInterface < IServer > ( ) ;
m_pConsole = Kernel ( ) - > RequestInterface < IConsole > ( ) ;
m_World . SetGameServer ( this ) ;
m_Events . SetGameServer ( this ) ;
//if(!data) // only load once
//data = load_data_from_memory(internal_data);
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < NUM_NETOBJTYPES ; i + + )
Server ( ) - > SnapSetStaticsize ( i , m_NetObjHandler . GetObjSize ( i ) ) ;
m_Layers . Init ( Kernel ( ) ) ;
m_Collision . Init ( & m_Layers ) ;
// reset everything here
//world = new GAMEWORLD;
//players = new CPlayer[MAX_CLIENTS];
2010-08-28 20:53:42 +00:00
//TODO: No need any more?
2010-08-20 20:40:12 +00:00
char buf [ 512 ] ;
2010-10-07 13:22:03 +00:00
str_format ( buf , sizeof ( buf ) , " data/maps/%s.cfg " , g_Config . m_SvMap ) ;
2010-07-29 05:21:18 +00:00
Console ( ) - > ExecuteFile ( buf ) ;
2010-08-20 20:40:12 +00:00
str_format ( buf , sizeof ( buf ) , " data/maps/%s.map.cfg " , g_Config . m_SvMap ) ;
2010-07-29 05:21:18 +00:00
Console ( ) - > ExecuteFile ( buf ) ;
2010-10-07 13:22:03 +00:00
2010-05-29 07:25:38 +00:00
// select gametype
2010-07-29 14:53:25 +00:00
m_pController = new CGameControllerDDRace ( this ) ;
2010-09-24 13:37:13 +00:00
( ( CGameControllerDDRace * ) m_pController ) - > m_Teams . Reset ( ) ;
2010-08-20 20:40:12 +00:00
2010-06-07 11:34:47 +00:00
Server ( ) - > SetBrowseInfo ( m_pController - > m_pGameType , - 1 ) ;
2010-08-23 19:37:27 +00:00
// delete old score object
if ( m_pScore )
delete m_pScore ;
// create score object (add sql later)
2010-08-26 13:27:36 +00:00
if ( g_Config . m_SvUseSQL )
m_pScore = new CSqlScore ( this ) ;
else
2010-08-23 19:37:27 +00:00
m_pScore = new CFileScore ( this ) ;
2010-05-29 07:25:38 +00:00
// setup core world
//for(int i = 0; i < MAX_CLIENTS; i++)
// game.players[i].core.world = &game.world.core;
// create all entities from the game layer
CMapItemLayerTilemap * pTileMap = m_Layers . GameLayer ( ) ;
CTile * pTiles = ( CTile * ) Kernel ( ) - > RequestInterface < IMap > ( ) - > GetData ( pTileMap - > m_Data ) ;
2010-08-20 20:40:12 +00:00
CTile * pFront = 0 ;
2010-10-10 22:40:07 +00:00
if ( m_Layers . FrontLayer ( ) )
2010-10-04 19:17:56 +00:00
pFront = ( CTile * ) Kernel ( ) - > RequestInterface < IMap > ( ) - > GetData ( pTileMap - > m_Front ) ;
2010-10-04 18:37:39 +00:00
2010-08-20 20:40:12 +00:00
2010-05-29 07:25:38 +00:00
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 ;
2010-08-28 19:34:21 +00:00
if ( Index = = TILE_NPC )
2010-09-06 02:36:53 +00:00
m_Tuning . Set ( " player_collision " , 0 ) ;
2010-10-10 22:40:07 +00:00
else if ( Index = = TILE_EHOOK )
2010-08-28 19:34:21 +00:00
g_Config . m_SvEndlessDrag = 1 ;
2010-10-10 22:40:07 +00:00
else if ( Index = = TILE_NOHIT )
2010-08-28 19:34:21 +00:00
g_Config . m_SvHit = 0 ;
2010-10-10 22:40:07 +00:00
else if ( Index = = TILE_NPH )
2010-09-06 02:36:53 +00:00
m_Tuning . Set ( " player_hooking " , 0 ) ;
2010-05-29 07:25:38 +00:00
if ( Index > = ENTITY_OFFSET )
{
2010-08-10 04:28:17 +00:00
vec2 Pos ( x * 32.0f + 16.0f , y * 32.0f + 16.0f ) ;
2010-08-20 20:40:12 +00:00
m_pController - > OnEntity ( Index - ENTITY_OFFSET , Pos , false ) ;
}
2010-10-10 22:40:07 +00:00
if ( pFront )
2010-08-20 20:40:12 +00:00
{
2010-08-27 23:30:50 +00:00
int Index = pFront [ y * pTileMap - > m_Width + x ] . m_Index ;
2010-08-28 19:34:21 +00:00
if ( Index = = TILE_NPC )
2010-09-06 02:36:53 +00:00
m_Tuning . Set ( " player_collision " , 0 ) ;
2010-10-10 22:40:07 +00:00
else if ( Index = = TILE_EHOOK )
2010-08-28 19:34:21 +00:00
g_Config . m_SvEndlessDrag = 1 ;
2010-10-10 22:40:07 +00:00
else if ( Index = = TILE_NOHIT )
2010-08-28 19:34:21 +00:00
g_Config . m_SvHit = 0 ;
2010-10-10 22:40:07 +00:00
else if ( Index = = TILE_NPH )
2010-09-06 02:36:53 +00:00
m_Tuning . Set ( " player_hooking " , 0 ) ;
2010-08-27 23:30:50 +00:00
if ( Index > = ENTITY_OFFSET )
2010-08-20 20:40:12 +00:00
{
vec2 Pos ( x * 32.0f + 16.0f , y * 32.0f + 16.0f ) ;
2010-08-27 23:30:50 +00:00
m_pController - > OnEntity ( Index - ENTITY_OFFSET , Pos , true ) ;
2010-08-20 20:40:12 +00:00
}
2010-05-29 07:25:38 +00:00
}
}
}
# ifdef CONF_DEBUG
if ( g_Config . m_DbgDummies )
{
for ( int i = 0 ; i < g_Config . m_DbgDummies ; i + + )
{
OnClientConnected ( MAX_CLIENTS - i - 1 ) ;
}
}
# endif
}
void CGameContext : : OnShutdown ( )
{
2010-10-27 10:14:26 +00:00
Layers ( ) - > Dest ( ) ;
Collision ( ) - > Dest ( ) ;
2010-05-29 07:25:38 +00:00
delete m_pController ;
m_pController = 0 ;
Clear ( ) ;
2008-08-14 18:42:47 +00:00
}
2010-05-29 07:25:38 +00:00
void CGameContext : : OnSnap ( int ClientId )
2008-08-14 18:42:47 +00:00
{
2010-05-29 07:25:38 +00:00
m_World . Snap ( ClientId ) ;
m_pController - > Snap ( ClientId ) ;
m_Events . Snap ( ClientId ) ;
2010-08-20 20:40:12 +00:00
2008-08-14 18:42:47 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2010-05-29 07:25:38 +00:00
if ( m_apPlayers [ i ] )
m_apPlayers [ i ] - > Snap ( ClientId ) ;
2008-08-14 18:42:47 +00:00
}
}
2010-05-29 07:25:38 +00:00
void CGameContext : : OnPreSnap ( ) { }
void CGameContext : : OnPostSnap ( )
{
m_Events . Clear ( ) ;
}
const char * CGameContext : : Version ( ) { return GAME_VERSION ; }
const char * CGameContext : : NetVersion ( ) { return GAME_NETVERSION ; }
IGameServer * CreateGameServer ( ) { return new CGameContext ; }
2010-09-17 09:34:13 +00:00