#include "stdafx.h"
#include "../xrEngine/xr_ioc_cmd.h"
#include "../xrEngine/xr_ioc_cmd.h"
#include "../xrEngine/customhud.h"
#include "../xrEngine/fdemorecord.h"
#include "../xrEngine/fdemoplay.h"
#include "xrMessages.h"
#include "xrserver.h"
#include "level.h"
#include "game_cl_base.h"
#include "hit.h"
#include "PHDestroyable.h"
#include "actor.h"
#include "Actor_Flags.h"
#include "customzone.h"
#include "xrServer_Objects.h"
#include "ui/UIMainIngameWnd.h"
#include "../xrphysics/iphworld.h"
#include "string_table.h"
#include "date_time.h"
#include "ui/UIActorMenu.h"
#include "ui/UIStatic.h"
#include "zone_effector.h"
#include "lobby_menu.h"
#include "../xrEngine/doug_lea_memory_allocator.h"
#include "cameralook.h"
#include "character_hit_animations_params.h"
#include "../xrengine/cameramanager.h"
#include "../include/xrrender/kinematics.h"
#include "../xrengine/xrServerInfo.h"

//#include "GameSpy/GameSpy_Full.h"
//#include "GameSpy/GameSpy_Patching.h"

#include "../xrphysics/console_vars.h"
#ifdef DEBUG
#	include "PHDebug.h"
#	include "ui/UIDebugFonts.h" 
#	include "CharacterPhysicsSupport.h"
#endif // DEBUG

string_path		g_last_saved_game;

#ifdef DEBUG
	extern float air_resistance_epsilon;
#endif // #ifdef DEBUG

extern void show_smart_cast_stats		();
extern void clear_smart_cast_stats		();
extern void release_smart_cast_stats	();

extern	u64		g_qwStartGameTime;
extern	u64		g_qwEStartGameTime;

ENGINE_API
extern	float	psHUD_FOV;
extern	float	psSqueezeVelocity;
extern	int		psLUA_GCSTEP;

extern	int		x_m_x;
extern	int		x_m_z;
extern	BOOL	net_cl_inputguaranteed	;
extern	BOOL	net_sv_control_hit		;
extern	int		g_dwInputUpdateDelta	;
#ifdef DEBUG
extern	BOOL	g_ShowAnimationInfo		;
#endif // DEBUG
extern	BOOL	g_bShowHitSectors		;
//extern	BOOL	g_bDebugDumpPhysicsStep	;
extern	BOOL	g_show_wnd_rect2			;
//-----------------------------------------------------------
extern	float	g_fTimeFactor;
extern	BOOL	b_toggle_weapon_aim;
//extern  BOOL	g_old_style_ui_hud;

extern float	g_smart_cover_factor;
extern int		g_upgrades_log;

float			g_aim_predict_time = 0.44f;
int				g_keypress_on_start	= 1;

ENGINE_API extern float	g_console_sensitive;

void register_mp_console_commands();
//-----------------------------------------------------------

		BOOL	g_bCheckTime			= FALSE;
		int		net_cl_inputupdaterate	= 50;
#ifdef DEBUG
		Flags32	dbg_net_Draw_Flags		= {0};
#endif

#ifdef DEBUG
		BOOL	g_bDebugNode			= FALSE;
		u32		g_dwDebugNodeSource		= 0;
		u32		g_dwDebugNodeDest		= 0;
extern	BOOL	g_bDrawBulletHit;
extern	BOOL	g_bDrawFirstBulletCrosshair;

		float	debug_on_frame_gather_stats_frequency	= 0.f;
#endif
#ifdef DEBUG 
extern LPSTR	dbg_stalker_death_anim;
extern BOOL		b_death_anim_velocity;
extern BOOL		death_anim_debug;
extern BOOL		dbg_imotion_draw_skeleton;
extern BOOL		dbg_imotion_draw_velocity;
extern BOOL		dbg_imotion_collide_debug;
extern float	dbg_imotion_draw_velocity_scale;
#endif

Flags32 g_uCommonFlags;
enum E_COMMON_FLAGS{
	flAiUseTorchDynamicLights = 1
};

#ifndef PURE_ALLOC
//#	ifndef USE_MEMORY_MONITOR
#		define SEVERAL_ALLOCATORS
//#	endif // USE_MEMORY_MONITOR
#endif // PURE_ALLOC

typedef void (*full_memory_stats_callback_type) ( );
XRCORE_API full_memory_stats_callback_type g_full_memory_stats_callback;

static void full_memory_stats	( )
{
	Memory.mem_compact		();
	u32		_crt_heap		= mem_usage_impl((HANDLE)_get_heap_handle(),0,0);
	u32		_process_heap	= mem_usage_impl(GetProcessHeap(),0,0);
#ifdef SEVERAL_ALLOCATORS
	u32		_render			= ::Render->memory_usage();
#endif // SEVERAL_ALLOCATORS
	int		_eco_strings	= (int)g_pStringContainer->stat_economy			();
	int		_eco_smem		= (int)g_pSharedMemoryContainer->stat_economy	();
	u32		m_base=0,c_base=0,m_lmaps=0,c_lmaps=0;


	//if (Device.Resources)	Device.Resources->_GetMemoryUsage	(m_base,c_base,m_lmaps,c_lmaps);
	//	Resource check moved to m_pRender
	if (Device.m_pRender) Device.m_pRender->ResourcesGetMemoryUsage(m_base,c_base,m_lmaps,c_lmaps);

	log_vminfo	();

	Msg		("* [ D3D ]: textures[%d K]", (m_base+m_lmaps)/1024);

#ifndef SEVERAL_ALLOCATORS
	Msg		("* [x-ray]: crt heap[%d K], process heap[%d K]",_crt_heap/1024,_process_heap/1024);
#else // SEVERAL_ALLOCATORS
	Msg		("* [x-ray]: crt heap[%d K], process heap[%d K], render[%d K]",_crt_heap/1024,_process_heap/1024,_render/1024);
#endif // SEVERAL_ALLOCATORS

	Msg		("* [x-ray]: economy: strings[%d K], smem[%d K]",_eco_strings/1024,_eco_smem);

#ifdef DEBUG
	Msg		("* [x-ray]: file mapping: memory[%d K], count[%d]",g_file_mapped_memory/1024,g_file_mapped_count);
	dump_file_mappings	();
#endif // DEBUG
}

class CCC_MemStats : public IConsole_Command
{
public:
	CCC_MemStats(LPCSTR N) : IConsole_Command(N)  {
		bEmptyArgsHandled = TRUE;
		g_full_memory_stats_callback	= &full_memory_stats;
	};
	virtual void Execute(LPCSTR args) {
		full_memory_stats( );
	}
};

class CCC_ServerInfo : public IConsole_Command
{
public:
	CCC_ServerInfo(LPCSTR N) : IConsole_Command(N)  {	
		bEmptyArgsHandled = TRUE;
	};
	virtual void Execute(LPCSTR args) {
		CServerInfo server_info;
		server_info.ResetData();
		g_pGameLevel->GetLevelInfo( &server_info );
		SHORT server_info_size = (SHORT)server_info.Size();
		Msg("===================================================");
		for( SHORT i=0; i<server_info_size; ++i )
		{			
			Msg(server_info[i].name);
		}
		Msg("===================================================");
	}
};

#ifdef DEBUG
class CCC_MemCheckpoint : public IConsole_Command
{
public:
	CCC_MemCheckpoint(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = FALSE; };
	virtual void Execute(LPCSTR args) 
	{
		memory_monitor::make_checkpoint(args);
	}
	virtual void	Save	(IWriter *F)	{}
};

#endif // #ifdef DEBUG
// console commands

//-----------------------------------------------------------------------
class CCC_DemoRecord : public IConsole_Command
{
public:

	CCC_DemoRecord(LPCSTR N) : IConsole_Command(N) {};
	virtual void Execute(LPCSTR args) {

		LPSTR			fn_; 
		STRCONCAT		(fn_, args, ".xrdemo");
		string_path		fn;
		FS.update_path	(fn, "$app_data_root$", fn_);

		g_pGameLevel->Cameras().AddCamEffector(xr_new<CDemoRecord> (fn));
	}
};

class CCC_DemoRecordSetPos : public CCC_Vector3
{
	static Fvector p;
public:

	CCC_DemoRecordSetPos(LPCSTR N) : CCC_Vector3( N, &p, Fvector().set( -FLT_MAX, -FLT_MAX, -FLT_MAX ),Fvector().set( FLT_MAX, FLT_MAX, FLT_MAX ) ) {};
	virtual void Execute(LPCSTR args) {
		CDemoRecord::GetGlobalPosition( p );
		CCC_Vector3::Execute(args);
		CDemoRecord::SetGlobalPosition( p );
	}
	virtual void	Save	(IWriter *F)	{;}

};
Fvector CCC_DemoRecordSetPos::p = {0,0,0};

class CCC_DemoPlay : public IConsole_Command
{
public:
	CCC_DemoPlay(LPCSTR N) : 
	  IConsole_Command(N) 
	  { bEmptyArgsHandled = TRUE; };
	  virtual void Execute(LPCSTR args) {
		  if (0==g_pGameLevel)
		  {
			  Msg	("! There are no level(s) started");
		  } else {
			  string_path			fn;
			  u32		loops	=	0;
			  LPSTR		comma	=	strchr(const_cast<LPSTR>(args),',');
			  if (comma)	{
				  loops			=	atoi	(comma+1);
				  *comma		=	0;	//. :)
			  }
			  strconcat			(sizeof(fn),fn, args, ".xrdemo");
			  FS.update_path	(fn, "$app_data_root$", fn);
			  g_pGameLevel->Cameras().AddCamEffector(xr_new<CDemoPlay> (fn, 1.0f, loops));
		  }
	  }
};

// helper functions --------------------------------------------

bool valid_saved_game_name(LPCSTR file_name)
{
	LPCSTR		I = file_name;
	LPCSTR		E = file_name + xr_strlen(file_name);
	for ( ; I != E; ++I) {
		if (!strchr("/\\:*?\"<>|^()[]%",*I))
			continue;

		return	(false);
	};

	return		(true);
}

void get_files_list( xr_vector<shared_str>& files, LPCSTR dir, LPCSTR file_ext )
{
	VERIFY( dir && file_ext );
	files.clear_not_free();

	FS_Path* P = FS.get_path( dir );
	P->m_Flags.set( FS_Path::flNeedRescan, TRUE );
	FS.m_Flags.set( CLocatorAPI::flNeedCheck, TRUE );
	FS.rescan_pathes();

	LPCSTR fext;
	STRCONCAT( fext, "*", file_ext );

	FS_FileSet  files_set;
	FS.file_list( files_set, dir, FS_ListFiles, fext );
	u32 len_str_ext = xr_strlen( file_ext );

	FS_FileSetIt itb = files_set.begin();
	FS_FileSetIt ite = files_set.end();

	for( ; itb != ite; ++itb )
	{
		LPCSTR fn_ext = (*itb).name.c_str();
		VERIFY( xr_strlen(fn_ext) > len_str_ext );
		string_path fn;
		strncpy_s( fn, sizeof(fn), fn_ext, xr_strlen(fn_ext)-len_str_ext );
		files.push_back( fn );
	}
	FS.m_Flags.set( CLocatorAPI::flNeedCheck, FALSE );
}

#include "UIGameCustom.h"

class CCC_FlushLog : public IConsole_Command {
public:
	CCC_FlushLog(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR /**args/**/) {
		FlushLog();
		Msg		("* Log file has been saved successfully!");
	}
};

class CCC_ClearLog : public IConsole_Command {
public:
	CCC_ClearLog(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR) {
		LogFile->clear_not_free	();
		FlushLog				();
		Msg						("* Log file has been cleaned successfully!");
	}
};

class CCC_Net_CL_InputUpdateRate : public CCC_Integer {
protected:
	int		*value_blin;
public:
	CCC_Net_CL_InputUpdateRate(LPCSTR N, int* V, int _min=0, int _max=999) :
	  CCC_Integer(N,V,_min,_max),
		  value_blin(V)
	  {};

	  virtual void	Execute	(LPCSTR args)
	  {
		  CCC_Integer::Execute(args);
		  if ((*value_blin > 0) && g_pGameLevel)
		  {
			  g_dwInputUpdateDelta = 1000/(*value_blin);
		  };
	  }
};

#ifdef DEBUG
class CCC_DebugFonts : public IConsole_Command {
public:
	CCC_DebugFonts (LPCSTR N) : IConsole_Command(N) {bEmptyArgsHandled = true; }
	virtual void Execute				(LPCSTR args) 
	{
		xr_new<CUIDebugFonts>()->ShowDialog(true);		
	}
};

class CCC_DebugNode : public IConsole_Command {
public:
	CCC_DebugNode(LPCSTR N) : IConsole_Command(N)  { };

	virtual void Execute(LPCSTR args) {

		string128 param1, param2;
		VERIFY( xr_strlen(args) < sizeof(string128) );

		_GetItem(args,0,param1,' ');
		_GetItem(args,1,param2,' ');

		u32 value1;
		u32 value2;
		
		sscanf(param1,"%u",&value1);
		sscanf(param2,"%u",&value2);
		
		if ((value1 > 0) && (value2 > 0)) {
			g_bDebugNode		= TRUE;
			g_dwDebugNodeSource	= value1;
			g_dwDebugNodeDest	= value2;
		} else {
			g_bDebugNode = FALSE;
		}
	}
};

void PH_DBG_SetTrackObject();
extern string64 s_dbg_trace_obj_name;
class CCC_DbgPhTrackObj : public CCC_String {
public:
	CCC_DbgPhTrackObj( LPCSTR N ) : CCC_String( N, s_dbg_trace_obj_name, sizeof(s_dbg_trace_obj_name) )  { };
	virtual void Execute(LPCSTR args/**/) {
		CCC_String::Execute( args );
			if(!xr_strcmp(args,"none"))
			{
				ph_dbg_draw_mask1.set(ph_m1_DbgTrackObject,FALSE);
				return;
			}
			ph_dbg_draw_mask1.set(ph_m1_DbgTrackObject,TRUE);
			PH_DBG_SetTrackObject();
			//CObject* O= Level().Objects.FindObjectByName(args);
			//if(O)
			//{
			//	PH_DBG_SetTrackObject(*(O->cName()));
			//	ph_dbg_draw_mask1.set(ph_m1_DbgTrackObject,TRUE);
			//}

		}
	
	//virtual void	Info	(TInfo& I)		
	//{
	//	xr_strcpy(I,"restart game fast"); 
	//}
};
#endif

class CCC_PHIterations : public CCC_Integer {
public:
		CCC_PHIterations(LPCSTR N) :
		CCC_Integer(N,&phIterations,15,50)
		{};
	  virtual void	Execute	(LPCSTR args)
	  {
		  CCC_Integer::Execute	(args);
		 // dWorldSetQuickStepNumIterations(NULL,phIterations);
		  if( physics_world() )
				 physics_world()->StepNumIterations( phIterations );
	  }
};

#ifdef DEBUG
class CCC_PHGravity : public IConsole_Command {
public:
		CCC_PHGravity(LPCSTR N) :
		IConsole_Command(N)
		{};
	  virtual void	Execute	(LPCSTR args)
	  {
		  if( !physics_world() )	
			  return;
#ifndef DEBUG
		  if (g_pGameLevel && Level().game )
		  {
			  Msg("Command is not available in Multiplayer");
			  return;
		  }
#endif
		  physics_world()->SetGravity(float(atof(args)));
	  }
	  virtual void	Status	(TStatus& S)
	{	
		if(physics_world())
			xr_sprintf	(S,"%3.5f",physics_world()->Gravity());
		else
			xr_sprintf	(S,"%3.5f",default_world_gravity);
		while	(xr_strlen(S) && ('0'==S[xr_strlen(S)-1]))	S[xr_strlen(S)-1] = 0;
	}
	
};
#endif // DEBUG

class CCC_PHFps : public IConsole_Command {
public:
	CCC_PHFps(LPCSTR N) :
	  IConsole_Command(N)
	  {};
	  virtual void	Execute	(LPCSTR args)
	  {
		  float				step_count = (float)atof(args);
#ifndef		DEBUG
		  clamp				(step_count,50.f,200.f);
#endif
		  //IPHWorld::SetStep(1.f/step_count);
		  ph_console::ph_step_time = 1.f/step_count;
		  //physics_world()->SetStep(1.f/step_count);
		  if(physics_world())
			 physics_world()->SetStep(ph_console::ph_step_time);
	  }
	  virtual void	Status	(TStatus& S)
	  {	
		 	xr_sprintf	(S,"%3.5f",1.f/ph_console::ph_step_time);	  
	  }

};

#ifdef DEBUG

struct CCC_ShowSmartCastStats : public IConsole_Command {
	CCC_ShowSmartCastStats(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };

	virtual void Execute(LPCSTR args) {
		show_smart_cast_stats();
	}
};

struct CCC_ClearSmartCastStats : public IConsole_Command {
	CCC_ClearSmartCastStats(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };

	virtual void Execute(LPCSTR args) {
		clear_smart_cast_stats();
	}
};
/*
struct CCC_NoClip : public CCC_Mask 
{
public:
	CCC_NoClip(LPCSTR N, Flags32* V, u32 M):CCC_Mask(N,V,M){};
	virtual	void Execute(LPCSTR args)
	{
		CCC_Mask::Execute(args);
		if (EQ(args,"on") || EQ(args,"1"))
		{
			if(g_pGameLevel && Level().CurrentViewEntity())
			{
				CActor* actor = smart_cast<CActor*>(Level().CurrentViewEntity());
				actor->character_physics_support()->SetRemoved();
			}
		}
	};
};
*/
#endif

#include "GamePersistent.h"

class CCC_MainMenu : public IConsole_Command {
public:
	CCC_MainMenu(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR args) {

		bool bWhatToDo = TRUE;
		if( 0==xr_strlen(args) ){
			bWhatToDo = !MainMenu()->IsActive();
		};

		if( EQ(args,"on")||EQ(args,"1") )
			bWhatToDo = TRUE;

		if( EQ(args,"off")||EQ(args,"0") )
			bWhatToDo = FALSE;

		MainMenu()->Activate( bWhatToDo );
	}
};

#ifdef DEBUG
class CCC_RadioGroupMask2;
class CCC_RadioMask :public CCC_Mask
{
	CCC_RadioGroupMask2		*group;
public:
	CCC_RadioMask(LPCSTR N, Flags32* V, u32 M):
	  CCC_Mask(N,V,M)
	 {
		group=NULL;
	 }
		void	SetGroup	(CCC_RadioGroupMask2		*G)
	{
		group=G													;
	}
virtual	void	Execute		(LPCSTR args)						;
	
IC		void	Set			(BOOL V)
	  {
		  value->set(mask,V)									;
	  }

};

class CCC_RadioGroupMask2 
{
	CCC_RadioMask *mask0;
	CCC_RadioMask *mask1;
public:
	CCC_RadioGroupMask2(CCC_RadioMask *m0,CCC_RadioMask *m1)
	  {
		mask0=m0;mask1=m1;
		mask0->SetGroup(this);
		mask1->SetGroup(this);
	  }
	void	Execute	(CCC_RadioMask& m,LPCSTR args)
	{
		BOOL value=m.GetValue();
		if(value)
		{
			mask0->Set(!value);mask1->Set(!value);
		}
		m.Set(value);
	}
};


void	CCC_RadioMask::Execute	(LPCSTR args)
{
	CCC_Mask::Execute(args);
	VERIFY2(group,"CCC_RadioMask: group not set");
	group->Execute(*this,args);
}

#define CMD_RADIOGROUPMASK2(p1,p2,p3,p4,p5,p6)		\
{\
static CCC_RadioMask x##CCC_RadioMask1(p1,p2,p3);		pConsoleCommands->AddCommand(&x##CCC_RadioMask1);\
static CCC_RadioMask x##CCC_RadioMask2(p4,p5,p6);		pConsoleCommands->AddCommand(&x##CCC_RadioMask2);\
static CCC_RadioGroupMask2 x##CCC_RadioGroupMask2(&x##CCC_RadioMask1,&x##CCC_RadioMask2);\
}

struct CCC_DbgBullets : public CCC_Integer {
	CCC_DbgBullets(LPCSTR N, int* V, int _min=0, int _max=999) : CCC_Integer(N,V,_min,_max) {};

	virtual void	Execute	(LPCSTR args)
	{
		extern FvectorVec g_hit[];
		g_hit[0].clear();
		g_hit[1].clear();
		g_hit[2].clear();
		CCC_Integer::Execute	(args);
	}
};

#include "attachable_item.h"
#include "attachment_owner.h"
#include "InventoryOwner.h"
#include "Inventory.h"
class CCC_TuneAttachableItem : public IConsole_Command
{
public		:
	CCC_TuneAttachableItem(LPCSTR N):IConsole_Command(N){};
	virtual void	Execute	(LPCSTR args)
	{
		if( CAttachableItem::m_dbgItem){
			CAttachableItem::m_dbgItem = NULL;	
			Msg("CCC_TuneAttachableItem switched to off");
			return;
		};

		CObject* obj			= Level().CurrentViewActor();	VERIFY(obj);
		shared_str ssss			= args;

		CAttachmentOwner* owner = smart_cast<CAttachmentOwner*>(obj);
		CAttachableItem* itm	= owner->attachedItem(ssss);
		if(itm)
		{
			CAttachableItem::m_dbgItem = itm;
		}else
		{
			CInventoryOwner* iowner = smart_cast<CInventoryOwner*>(obj);
			PIItem active_item = iowner->m_inventory->ActiveItem();
			if(active_item && active_item->object().cNameSect()==ssss )
				CAttachableItem::m_dbgItem = active_item->cast_attachable_item();
		}

		if(CAttachableItem::m_dbgItem)
			Msg("CCC_TuneAttachableItem switched to ON for [%s]",args);
		else
			Msg("CCC_TuneAttachableItem cannot find attached item [%s]",args);
	}

	virtual void	Info	(TInfo& I)
	{	
		xr_sprintf(I,"allows to change bind rotation and position offsets for attached item, <section_name> given as arguments");
	}
};

class CCC_Crash : public IConsole_Command {
public:
	CCC_Crash(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR /**args/**/) {
		VERIFY3					(false,"This is a test crash","Do not post it as a bug");
		int						*pointer = 0;
		*pointer				= 0;
	}
};

#ifdef DEBUG_MEMORY_MANAGER

class CCC_MemAllocShowStats : public IConsole_Command {
public:
	CCC_MemAllocShowStats(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR) {
		mem_alloc_show_stats	();
	}
};

class CCC_MemAllocClearStats : public IConsole_Command {
public:
	CCC_MemAllocClearStats(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR) {
		mem_alloc_clear_stats	();
	}
};

#endif // DEBUG_MEMORY_MANAGER

class CCC_DumpModelBones : public IConsole_Command {
public:
	CCC_DumpModelBones	(LPCSTR N) : IConsole_Command(N)
	{
	}
	
	virtual void Execute(LPCSTR arguments)
	{
		if (!arguments || !*arguments) {
			Msg					("! no arguments passed");
			return;
		}

		LPCSTR					name;

		if (0==strext(arguments))
			STRCONCAT			(name, arguments, ".ogf");
		else
			STRCONCAT			(name, arguments);

		string_path				fn;

		if (!FS.exist(arguments) && !FS.exist(fn, "$level$", name) && !FS.exist(fn, "$game_meshes$", name)) {
			Msg					("! Cannot find visual \"%s\"",arguments);
			return;
		}

		IRenderVisual			*visual = Render->model_Create(arguments);
		IKinematics				*kinematics = smart_cast<IKinematics*>(visual);
		if (!kinematics) {
			Render->model_Delete(visual);
			Msg					("! Invalid visual type \"%s\" (not a IKinematics)",arguments);
			return;
		}

		Msg						("bones for model \"%s\"",arguments);
		for (u16 i=0, n=kinematics->LL_BoneCount(); i<n; ++i)
			Msg					("%s",*kinematics->LL_GetData(i).name);
		
		Render->model_Delete	(visual);
	}
};


#endif // DEBUG

class CCC_DumpObjects : public IConsole_Command {
public:
	CCC_DumpObjects(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
	virtual void Execute(LPCSTR)
	{
		Level().Objects.dump_all_objects();
	}
};

//class CCC_GSCheckForUpdates : public IConsole_Command {
//public:
//	CCC_GSCheckForUpdates(LPCSTR N) : IConsole_Command(N)  { bEmptyArgsHandled = true; };
//	virtual void Execute(LPCSTR arguments)
//	{
//		if (!MainMenu()) return;
//		/*
//		CGameSpy_Available GSA;
//		shared_str result_string;
//		if (!GSA.CheckAvailableServices(result_string))
//		{
//			Msg(*result_string);
////			return;
//		};
//		CGameSpy_Patching GameSpyPatching;
//		*/
//		bool InformOfNoPatch = true;
//		if (arguments && *arguments) {
//			int bInfo = 1;
//			sscanf	(arguments,"%d", &bInfo);
//			InformOfNoPatch = (bInfo != 0);
//		}
//		
////		GameSpyPatching.CheckForPatch(InformOfNoPatch);
//		
//		MainMenu()->GetGS()->GetGameSpyPatching()->CheckForPatch(InformOfNoPatch);
//	}
//};



class CCC_Net_SV_GuaranteedPacketMode : public CCC_Integer {
protected:
	int		*value_blin;
public:
	CCC_Net_SV_GuaranteedPacketMode(LPCSTR N, int* V, int _min=0, int _max=2) :
	  CCC_Integer(N,V,_min,_max),
		  value_blin(V)
	  {};

	  virtual void	Execute	(LPCSTR args)
	  {
		  CCC_Integer::Execute(args);
	  }
};
#ifdef	DEBUG
void DBG_CashedClear();
class CCC_DBGDrawCashedClear : public IConsole_Command {
public:
	CCC_DBGDrawCashedClear(LPCSTR N) :IConsole_Command(N)  { bEmptyArgsHandled =true; }
private:
	 virtual void	Execute	(LPCSTR args)
	 {
		
		 DBG_CashedClear();
	 }
};

#endif

void CCC_RegisterCommands()
{

	CMD1(CCC_MemStats,			"stat_memory"			);
	CMD1(CCC_ServerInfo,		"server_info"			);

#ifdef DEBUG
	CMD1(CCC_MemCheckpoint,		"stat_memory_checkpoint");
#endif //#ifdef DEBUG	
	// game
	CMD3(CCC_Mask,				"g_crouch_toggle",		&psActorFlags,	AF_CROUCH_TOGGLE);

	CMD3(CCC_Mask,				"g_backrun",			&psActorFlags,	AF_RUN_BACKWARD);

	CMD1(CCC_FlushLog,			"flush"					);		// flush log
	CMD1(CCC_ClearLog,			"clear_log"					);

	CMD3(CCC_Mask,				"hud_weapon",			&psHUD_Flags,	HUD_WEAPON);
	CMD3(CCC_Mask,				"hud_info",				&psHUD_Flags,	HUD_INFO);
	CMD3(CCC_Mask,				"hud_draw",				&psHUD_Flags,	HUD_DRAW);

	// hud
	psHUD_Flags.set(HUD_CROSSHAIR,		true);
	psHUD_Flags.set(HUD_WEAPON,			true);
	psHUD_Flags.set(HUD_DRAW,			true);
	psHUD_Flags.set(HUD_INFO,			true);

	CMD3(CCC_Mask,				"hud_crosshair",		&psHUD_Flags,	HUD_CROSSHAIR);
	CMD3(CCC_Mask,				"hud_crosshair_dist",	&psHUD_Flags,	HUD_CROSSHAIR_DIST);

#ifdef DEBUG
	CMD4(CCC_Float,				"hud_fov",				&psHUD_FOV,		0.1f,	1.0f);
	CMD4(CCC_Float,				"fov",					&g_fov,			5.0f,	180.0f);
#endif // DEBUG

	// Demo
#if 1//ndef MASTER_GOLD
	CMD1(CCC_DemoPlay,			"demo_play"				);
	CMD1(CCC_DemoRecord,		"demo_record"			);
	CMD1(CCC_DemoRecordSetPos,	"demo_set_cam_position"	);
#endif // #ifndef MASTER_GOLD

#ifdef DEBUG

/////////////////////////////////////////////HIT ANIMATION////////////////////////////////////////////////////
//float						power_factor				= 2.f;
//float						rotational_power_factor		= 3.f;
//float						side_sensitivity_threshold	= 0.2f;
//float						anim_channel_factor			= 3.f;

CMD4(CCC_Float,				"hit_anims_power",						&ghit_anims_params.power_factor,					0.0f, 100.0f);
CMD4(CCC_Float,				"hit_anims_rotational_power",			&ghit_anims_params.rotational_power_factor,			0.0f, 100.0f);
CMD4(CCC_Float,				"hit_anims_side_sensitivity_threshold",	&ghit_anims_params.side_sensitivity_threshold,		0.0f, 10.0f);
CMD4(CCC_Float,				"hit_anims_channel_factor",				&ghit_anims_params.anim_channel_factor,				0.0f, 100.0f);
//float	block_blend					= 0.1f;
//float	reduce_blend				= 0.5f;
//float	reduce_power_factor			= 0.5f;
CMD4(CCC_Float,				"hit_anims_block_blend",				&ghit_anims_params.block_blend,			0.f,	1.f);
CMD4(CCC_Float,				"hit_anims_reduce_blend",				&ghit_anims_params.reduce_blend,		0.f, 1.f);
CMD4(CCC_Float,				"hit_anims_reduce_blend_factor",		&ghit_anims_params.reduce_power_factor, 0.0f,	1.0f);
CMD4(CCC_Integer,			"hit_anims_tune",						&tune_hit_anims,		0, 1);
/////////////////////////////////////////////HIT ANIMATION END////////////////////////////////////////////////////

#ifdef DEBUG_MEMORY_MANAGER
	CMD3(CCC_Mask,				"debug_on_frame_gather_stats",				&psAI_Flags,	aiDebugOnFrameAllocs);
	CMD4(CCC_Float,				"debug_on_frame_gather_stats_frequency",	&debug_on_frame_gather_stats_frequency, 0.f, 1.f);
	CMD1(CCC_MemAllocShowStats,	"debug_on_frame_show_stats");
	CMD1(CCC_MemAllocClearStats,"debug_on_frame_clear_stats");
#endif // DEBUG_MEMORY_MANAGER

	CMD1(CCC_DumpModelBones,	"debug_dump_model_bones");
	
	CMD1(CCC_DebugFonts,		"debug_fonts");
	CMD1(CCC_TuneAttachableItem,"dbg_adjust_attachable_item");
#endif // DEBUG

	// Physics
	CMD1(CCC_PHFps,				"ph_frequency"																					);
	CMD1(CCC_PHIterations,		"ph_iterations"																					);

#ifdef DEBUG
	CMD1(CCC_PHGravity,			"ph_gravity"																					);
	CMD4(CCC_Float,		"ph_timefactor",				&phTimefactor				,			0.000001f	,1000.f			);
	CMD4(CCC_Float,		"ph_break_common_factor",		&ph_console::phBreakCommonFactor		,			0.f		,1000000000.f	);
	CMD4(CCC_Float,		"ph_rigid_break_weapon_factor",	&ph_console::phRigidBreakWeaponFactor	,			0.f		,1000000000.f	);
	CMD4(CCC_Integer,			"ph_tri_clear_disable_count",	&ph_console::ph_tri_clear_disable_count	,			0,		255				);
	CMD4(CCC_Float,		"ph_tri_query_ex_aabb_rate",	&ph_console::ph_tri_query_ex_aabb_rate	,			1.01f	,3.f			);
	CMD3(CCC_Mask,				"g_no_clip",					&psActorFlags,	AF_NO_CLIP	);
#endif // DEBUG

#ifndef MASTER_GOLD
	CMD3(CCC_Mask,			"g_god",			&psActorFlags,	AF_GODMODE	);
	CMD3(CCC_Mask,			"g_unlimitedammo",	&psActorFlags,	AF_UNLIMITEDAMMO);
#endif // MASTER_GOLD

	CMD3(CCC_Mask,		"g_autopickup",			&psActorFlags,	AF_AUTOPICKUP);
	CMD3(CCC_Mask,		"g_dynamic_music",		&psActorFlags,	AF_DYNAMIC_MUSIC);
	
#ifdef DEBUG
	CMD1(CCC_ShowSmartCastStats,	"show_smart_cast_stats");
	CMD1(CCC_ClearSmartCastStats,	"clear_smart_cast_stats");

	CMD3(CCC_Mask,		"dbg_draw_actor_alive",		&dbg_net_Draw_Flags,	dbg_draw_actor_alive);
	CMD3(CCC_Mask,		"dbg_draw_actor_dead",		&dbg_net_Draw_Flags,	dbg_draw_actor_dead );
	CMD3(CCC_Mask,		"dbg_draw_customzone",		&dbg_net_Draw_Flags,	dbg_draw_customzone );
	CMD3(CCC_Mask,		"dbg_draw_teamzone",		&dbg_net_Draw_Flags,	dbg_draw_teamzone);
	CMD3(CCC_Mask,		"dbg_draw_invitem",			&dbg_net_Draw_Flags,	dbg_draw_invitem);
	CMD3(CCC_Mask,		"dbg_draw_actor_phys",		&dbg_net_Draw_Flags,	dbg_draw_actor_phys);
	CMD3(CCC_Mask,		"dbg_draw_customdetector",	&dbg_net_Draw_Flags,	dbg_draw_customdetector);
	CMD3(CCC_Mask,		"dbg_destroy",				&dbg_net_Draw_Flags,	dbg_destroy);
	CMD3(CCC_Mask,		"dbg_draw_autopickupbox",	&dbg_net_Draw_Flags,	dbg_draw_autopickupbox);
	CMD3(CCC_Mask,		"dbg_draw_rp",				&dbg_net_Draw_Flags,	dbg_draw_rp);
	CMD3(CCC_Mask,		"dbg_draw_climbable",		&dbg_net_Draw_Flags,	dbg_draw_climbable);
	CMD3(CCC_Mask,		"dbg_draw_skeleton",		&dbg_net_Draw_Flags,	dbg_draw_skeleton);


	CMD3(CCC_Mask,		"dbg_draw_ph_contacts",			&ph_dbg_draw_mask,	phDbgDrawContacts);
	CMD3(CCC_Mask,		"dbg_draw_ph_enabled_aabbs",	&ph_dbg_draw_mask,	phDbgDrawEnabledAABBS);
	CMD3(CCC_Mask,		"dbg_draw_ph_intersected_tries",&ph_dbg_draw_mask,	phDBgDrawIntersectedTries);
	CMD3(CCC_Mask,		"dbg_draw_ph_saved_tries",		&ph_dbg_draw_mask,	phDbgDrawSavedTries);
	CMD3(CCC_Mask,		"dbg_draw_ph_tri_trace",		&ph_dbg_draw_mask,	phDbgDrawTriTrace);
	CMD3(CCC_Mask,		"dbg_draw_ph_positive_tries",	&ph_dbg_draw_mask,	phDBgDrawPositiveTries);
	CMD3(CCC_Mask,		"dbg_draw_ph_negative_tries",	&ph_dbg_draw_mask,	phDBgDrawNegativeTries);
	CMD3(CCC_Mask,		"dbg_draw_ph_tri_test_aabb",	&ph_dbg_draw_mask,	phDbgDrawTriTestAABB);
	CMD3(CCC_Mask,		"dbg_draw_ph_tries_changes_sign",&ph_dbg_draw_mask,	phDBgDrawTriesChangesSign);
	CMD3(CCC_Mask,		"dbg_draw_ph_tri_point"			,&ph_dbg_draw_mask,	phDbgDrawTriPoint);
	CMD3(CCC_Mask,		"dbg_draw_ph_explosion_position",&ph_dbg_draw_mask,	phDbgDrawExplosionPos);
	CMD3(CCC_Mask,		"dbg_draw_ph_statistics"		,&ph_dbg_draw_mask,	phDbgDrawObjectStatistics);
	CMD3(CCC_Mask,		"dbg_draw_ph_mass_centres"		,&ph_dbg_draw_mask,	phDbgDrawMassCenters);
	CMD3(CCC_Mask,		"dbg_draw_ph_death_boxes"		,&ph_dbg_draw_mask,	phDbgDrawDeathActivationBox);
	CMD3(CCC_Mask,		"dbg_draw_ph_hit_app_pos"		,&ph_dbg_draw_mask,	phHitApplicationPoints);
	CMD3(CCC_Mask,		"dbg_draw_ph_cashed_tries_stats",&ph_dbg_draw_mask,	phDbgDrawCashedTriesStat);
	CMD3(CCC_Mask,		"dbg_draw_ph_car_dynamics"		,&ph_dbg_draw_mask,	phDbgDrawCarDynamics);
	CMD3(CCC_Mask,		"dbg_draw_ph_car_plots"			,&ph_dbg_draw_mask,	phDbgDrawCarPlots);
	CMD3(CCC_Mask,		"dbg_ph_ladder"					,&ph_dbg_draw_mask,	phDbgLadder);
	CMD3(CCC_Mask,		"dbg_draw_ph_explosions"		,&ph_dbg_draw_mask,	phDbgDrawExplosions);
	CMD3(CCC_Mask,		"dbg_draw_car_plots_all_trans"	,&ph_dbg_draw_mask,	phDbgDrawCarAllTrnsm);
	CMD3(CCC_Mask,		"dbg_draw_ph_zbuffer_disable"	,&ph_dbg_draw_mask,	phDbgDrawZDisable);
	CMD3(CCC_Mask,		"dbg_ph_obj_collision_damage"	,&ph_dbg_draw_mask,	phDbgDispObjCollisionDammage);
	CMD_RADIOGROUPMASK2("dbg_ph_ai_always_phmove",&ph_dbg_draw_mask,phDbgAlwaysUseAiPhMove,"dbg_ph_ai_never_phmove",&ph_dbg_draw_mask,phDbgNeverUseAiPhMove);
	CMD3(CCC_Mask,		"dbg_ph_ik"						,&ph_dbg_draw_mask,	phDbgIK);
	CMD3(CCC_Mask,		"dbg_ph_ik_off"					,&ph_dbg_draw_mask1,phDbgIKOff);
	CMD3(CCC_Mask,		"dbg_draw_ph_ik_goal"			,&ph_dbg_draw_mask,	phDbgDrawIKGoal);
	CMD3(CCC_Mask,		"dbg_ph_ik_limits"				,&ph_dbg_draw_mask,	phDbgIKLimits);
	CMD3(CCC_Mask,		"dbg_ph_character_control"		,&ph_dbg_draw_mask,	phDbgCharacterControl);
	CMD3(CCC_Mask,		"dbg_draw_ph_ray_motions"		,&ph_dbg_draw_mask,	phDbgDrawRayMotions);
	CMD4(CCC_Float,		"dbg_ph_vel_collid_damage_to_display",&dbg_vel_collid_damage_to_display,	0.f, 1000.f);
	CMD4(CCC_DbgBullets,"dbg_draw_bullet_hit",			&g_bDrawBulletHit,	0, 1)	;
	CMD4(CCC_Integer,	"dbg_draw_fb_crosshair",		&g_bDrawFirstBulletCrosshair, 0, 1);
	CMD1(CCC_DbgPhTrackObj,"dbg_track_obj");
	CMD3(CCC_Mask,		"dbg_ph_actor_restriction"		,&ph_dbg_draw_mask1, ph_m1_DbgActorRestriction);
	CMD3(CCC_Mask,		"dbg_draw_ph_hit_anims"			,&ph_dbg_draw_mask1, phDbgHitAnims);
	CMD3(CCC_Mask,		"dbg_draw_ph_ik_limits"			,&ph_dbg_draw_mask1, phDbgDrawIKLimits);
	CMD3(CCC_Mask,		"dbg_draw_ph_ik_predict"		,&ph_dbg_draw_mask1, phDbgDrawIKPredict);
	CMD3(CCC_Mask,		"dbg_draw_ph_ik_collision"		,&ph_dbg_draw_mask1, phDbgDrawIKCollision);
	CMD3(CCC_Mask,		"dbg_draw_ph_ik_shift_object"	,&ph_dbg_draw_mask1, phDbgDrawIKSHiftObject);
	CMD3(CCC_Mask,		"dbg_draw_ph_ik_blending"		,&ph_dbg_draw_mask1, phDbgDrawIKBlending);
	CMD1(CCC_DBGDrawCashedClear, "dbg_ph_cashed_clear");
extern BOOL dbg_draw_character_bones			;
extern BOOL dbg_draw_character_physics			;
extern BOOL dbg_draw_character_binds			;
extern BOOL dbg_draw_character_physics_pones	;
extern BOOL ik_cam_shift ;
	CMD4(CCC_Integer,	"dbg_draw_character_bones"			,&dbg_draw_character_bones,	FALSE,	TRUE );
	CMD4(CCC_Integer,	"dbg_draw_character_physics"		,&dbg_draw_character_physics,	FALSE,	TRUE );
	CMD4(CCC_Integer,	"dbg_draw_character_binds"			,&dbg_draw_character_binds,	FALSE,	TRUE );
	CMD4(CCC_Integer,	"dbg_draw_character_physics_pones"	,&dbg_draw_character_physics_pones,	FALSE,	TRUE );

	CMD4(CCC_Integer,	"ik_cam_shift"	,&ik_cam_shift,	FALSE,	TRUE );

extern	float ik_cam_shift_tolerance ;
CMD4(CCC_Float,		"ik_cam_shift_tolerance",&ik_cam_shift_tolerance,	0.f, 2.f);
float ik_cam_shift_speed ;
CMD4(CCC_Float,		"ik_cam_shift_speed",&ik_cam_shift_speed,	0.f, 1.f);
extern	BOOL dbg_draw_doors ;
CMD4(CCC_Integer,	"dbg_draw_doors"	,&dbg_draw_doors,	FALSE,	TRUE );

/*
extern int ik_allign_free_foot;
extern int ik_local_blending;
extern int ik_blend_free_foot;
extern int ik_collide_blend;
	CMD4(CCC_Integer,	"ik_allign_free_foot"			,&ik_allign_free_foot,	0,	1);
	CMD4(CCC_Integer,	"ik_local_blending"				,&ik_local_blending,	0,	1);
	CMD4(CCC_Integer,	"ik_blend_free_foot"			,&ik_blend_free_foot,	0,	1);
	CMD4(CCC_Integer,	"ik_collide_blend"				,&ik_collide_blend,	0,	1);
*/
extern 	BOOL dbg_draw_ragdoll_spawn;
	CMD4(CCC_Integer,	"dbg_draw_ragdoll_spawn"	,&dbg_draw_ragdoll_spawn,	FALSE,	TRUE );
extern BOOL debug_step_info;
extern BOOL debug_step_info_load;
	CMD4(CCC_Integer,	"debug_step_info"		,&debug_step_info,	FALSE,	TRUE );
	CMD4(CCC_Integer,	"debug_step_info_load"	,&debug_step_info_load,	FALSE,	TRUE );
extern BOOL debug_character_material_load;
	CMD4(CCC_Integer,	"debug_character_material_load"	,&debug_character_material_load,	FALSE,	TRUE );
extern XRPHYSICS_API BOOL dbg_draw_camera_collision;
	CMD4(CCC_Integer,	"dbg_draw_camera_collision"	,&dbg_draw_camera_collision,	FALSE,	TRUE );
extern XRPHYSICS_API float	camera_collision_character_skin_depth ;
extern XRPHYSICS_API float	camera_collision_character_shift_z ;
	CMD4(CCC_Float,"camera_collision_character_shift_z", &camera_collision_character_shift_z,	0.f, 1.f );
	CMD4(CCC_Float,"camera_collision_character_skin_depth", &camera_collision_character_skin_depth, 0.f, 1.f	);
extern BOOL	dbg_draw_animation_movement_controller;
	CMD4(CCC_Integer,	"dbg_draw_animation_movement_controller"	,&dbg_draw_animation_movement_controller,	FALSE,	TRUE );

/*
enum 
{
	dbg_track_obj_blends_bp_0			= 1<< 0,
	dbg_track_obj_blends_bp_1			= 1<< 1,
	dbg_track_obj_blends_bp_2			= 1<< 2,
	dbg_track_obj_blends_bp_3			= 1<< 3,
	dbg_track_obj_blends_motion_name	= 1<< 4,
	dbg_track_obj_blends_time			= 1<< 5,
	dbg_track_obj_blends_ammount		= 1<< 6,
	dbg_track_obj_blends_mix_params		= 1<< 7,
	dbg_track_obj_blends_flags			= 1<< 8,
	dbg_track_obj_blends_state			= 1<< 9,
	dbg_track_obj_blends_dump			= 1<< 10
};
*/
extern Flags32	dbg_track_obj_flags	;
CMD3(CCC_Mask,		"dbg_track_obj_blends_bp_0"			,&dbg_track_obj_flags, dbg_track_obj_blends_bp_0);
CMD3(CCC_Mask,		"dbg_track_obj_blends_bp_1"			,&dbg_track_obj_flags, dbg_track_obj_blends_bp_1);
CMD3(CCC_Mask,		"dbg_track_obj_blends_bp_2"			,&dbg_track_obj_flags, dbg_track_obj_blends_bp_2);
CMD3(CCC_Mask,		"dbg_track_obj_blends_bp_3"			,&dbg_track_obj_flags, dbg_track_obj_blends_bp_3);
CMD3(CCC_Mask,		"dbg_track_obj_blends_motion_name"	,&dbg_track_obj_flags, dbg_track_obj_blends_motion_name);
CMD3(CCC_Mask,		"dbg_track_obj_blends_time"			,&dbg_track_obj_flags, dbg_track_obj_blends_time);

CMD3(CCC_Mask,		"dbg_track_obj_blends_ammount"		,&dbg_track_obj_flags	,dbg_track_obj_blends_ammount		);
CMD3(CCC_Mask,		"dbg_track_obj_blends_mix_params"	,&dbg_track_obj_flags	,dbg_track_obj_blends_mix_params	);
CMD3(CCC_Mask,		"dbg_track_obj_blends_flags"		,&dbg_track_obj_flags	,dbg_track_obj_blends_flags			);
CMD3(CCC_Mask,		"dbg_track_obj_blends_state"		,&dbg_track_obj_flags	,dbg_track_obj_blends_state			);
CMD3(CCC_Mask,		"dbg_track_obj_blends_dump"			,&dbg_track_obj_flags	,dbg_track_obj_blends_dump			);

extern float	dbg_text_height_scale;													
CMD4(CCC_Float,		"dbg_text_height_scale",	&dbg_text_height_scale	,			0.2f	,5.f	);
#endif



#ifdef DEBUG
	CMD4(CCC_Integer,	"string_table_error_msg",	&CStringTable::m_bWriteErrorsToLog,	0,	1);
#endif

	CMD3(CCC_Mask,			"cl_dynamiccrosshair",	&psHUD_Flags,	HUD_CROSSHAIR_DYNAMIC);
	CMD1(CCC_MainMenu,		"main_menu"				);

	g_uCommonFlags.zero();
	g_uCommonFlags.set(flAiUseTorchDynamicLights, TRUE);

#ifdef DEBUG
	CMD1(CCC_Crash,		"crash"						);
	CMD1(CCC_DumpObjects,"dump_all_objects"			);
	CMD3(CCC_String,    "stalker_death_anim",				dbg_stalker_death_anim, 32);
	CMD4(CCC_Integer,   "death_anim_debug",					&death_anim_debug, FALSE,	TRUE );
	CMD4(CCC_Integer,   "death_anim_velocity",				&b_death_anim_velocity, FALSE,	TRUE );
	CMD4(CCC_Integer,   "dbg_imotion_draw_velocity",		&dbg_imotion_draw_velocity, FALSE,	TRUE );
	CMD4(CCC_Integer,   "dbg_imotion_collide_debug",		&dbg_imotion_collide_debug, FALSE,	TRUE );

	CMD4(CCC_Integer,   "dbg_imotion_draw_skeleton",		&dbg_imotion_draw_skeleton, FALSE,	TRUE );
	CMD4(CCC_Float,		"dbg_imotion_draw_velocity_scale",	&dbg_imotion_draw_velocity_scale, 0.0001f, 100.0f );

	CMD4(CCC_Integer,	"show_wnd_rect_all",		&g_show_wnd_rect2, 0, 1);
	CMD4(CCC_Integer,	"dbg_show_ani_info",		&g_ShowAnimationInfo,	0, 1)	;
	CMD4(CCC_Integer,	"dbg_dump_physics_step",	&ph_console::g_bDebugDumpPhysicsStep, 0, 1);

extern BOOL dbg_moving_bones_snd_player;
	CMD4(CCC_Integer,   "dbg_bones_snd_player",		&dbg_moving_bones_snd_player, FALSE, TRUE );
#endif
	CMD4(CCC_Float,		"con_sensitive",			&g_console_sensitive,	0.01f, 1.0f );
	CMD4(CCC_Integer,	"wpn_aim_toggle",			&b_toggle_weapon_aim, 0, 1);
//	CMD4(CCC_Integer,	"hud_old_style",			&g_old_style_ui_hud, 0, 1);

#ifdef DEBUG
	CMD4(CCC_Float,		"air_resistance_epsilon",	&air_resistance_epsilon,	.0f, 1.f);
#endif // #ifdef DEBUG

	CMD4(CCC_Float,		"ai_aim_predict_time",	&g_aim_predict_time, 0.f, 10.f);

#ifdef DEBUG
	//extern BOOL g_use_new_ballistics;
	//CMD4(CCC_Integer,	"use_new_ballistics",	&g_use_new_ballistics, 0, 1);
	extern float g_bullet_time_factor;
	CMD4(CCC_Float,	"g_bullet_time_factor",	&g_bullet_time_factor, 0.f, 10.f);
#endif

	

	*g_last_saved_game	= 0;

	CMD3(CCC_String,    "slot_0",				g_quick_use_slots[0], 32);
	CMD3(CCC_String,    "slot_1",				g_quick_use_slots[1], 32);
	CMD3(CCC_String,    "slot_2",				g_quick_use_slots[2], 32);
	CMD3(CCC_String,    "slot_3",				g_quick_use_slots[3], 32);

	CMD4(CCC_Integer,	"keypress_on_start",	&g_keypress_on_start, 0, 1);
	register_mp_console_commands				();
}