[openjk] 115/130: JK2: Merge in improved g_svcmds.cpp specialized for JK2

Simon McVittie smcv at debian.org
Fri Oct 28 11:09:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit 3df77749b0ca5c354d952103a6161182bd237f2b
Author: Ensiform <ensiform at gmail.com>
Date:   Sun Oct 23 19:04:32 2016 -0500

    JK2: Merge in improved g_svcmds.cpp specialized for JK2
    
    Some changes were made to accomodate for JK2 version of these commands
    which is different of course.
---
 codeJK2/cgame/cg_servercmds.cpp |   2 +-
 codeJK2/game/g_ICARUS.cpp       |   2 +-
 codeJK2/game/g_svcmds.cpp       | 451 ++++++++++++++++++++--------------------
 3 files changed, 225 insertions(+), 230 deletions(-)

diff --git a/codeJK2/cgame/cg_servercmds.cpp b/codeJK2/cgame/cg_servercmds.cpp
index 9a85982..d4ddc0e 100644
--- a/codeJK2/cgame/cg_servercmds.cpp
+++ b/codeJK2/cgame/cg_servercmds.cpp
@@ -256,7 +256,7 @@ typedef struct serverCommand_s {
 	void( *func )(void);
 } serverCommand_t;
 
-int svcmdcmp( const void *a, const void *b ) {
+static int svcmdcmp( const void *a, const void *b ) {
 	return Q_stricmp( (const char *)a, ((serverCommand_t*)b)->cmd );
 }
 
diff --git a/codeJK2/game/g_ICARUS.cpp b/codeJK2/game/g_ICARUS.cpp
index 6adf2e0..e89ff76 100644
--- a/codeJK2/game/g_ICARUS.cpp
+++ b/codeJK2/game/g_ICARUS.cpp
@@ -638,7 +638,7 @@ Svcmd_ICARUS_f
 
 void Svcmd_ICARUS_f( void )
 {
-	char	*cmd = gi.argv( 1 );
+	const char *cmd = gi.argv( 1 );
 
 	if ( Q_stricmp( cmd, "log" ) == 0 )
 	{
diff --git a/codeJK2/game/g_svcmds.cpp b/codeJK2/game/g_svcmds.cpp
index 83b28a2..40d4580 100644
--- a/codeJK2/game/g_svcmds.cpp
+++ b/codeJK2/game/g_svcmds.cpp
@@ -49,25 +49,46 @@ void	Svcmd_EntityList_f (void) {
 		gi.Printf("%3i:", e);
 		switch ( check->s.eType ) {
 		case ET_GENERAL:
-			gi.Printf("ET_GENERAL ");
+			gi.Printf( "ET_GENERAL          " );
 			break;
 		case ET_PLAYER:
-			gi.Printf("ET_PLAYER  ");
+			gi.Printf( "ET_PLAYER           " );
 			break;
 		case ET_ITEM:
-			gi.Printf("ET_ITEM    ");
+			gi.Printf( "ET_ITEM             " );
 			break;
 		case ET_MISSILE:
-			gi.Printf("ET_MISSILE ");
+			gi.Printf( "ET_MISSILE          " );
 			break;
 		case ET_MOVER:
-			gi.Printf("ET_MOVER   ");
+			gi.Printf( "ET_MOVER            " );
 			break;
 		case ET_BEAM:
-			gi.Printf("ET_BEAM    ");
+			gi.Printf( "ET_BEAM             " );
+			break;
+		case ET_PORTAL:
+			gi.Printf( "ET_PORTAL           " );
+			break;
+		case ET_SPEAKER:
+			gi.Printf( "ET_SPEAKER          " );
+			break;
+		case ET_PUSH_TRIGGER:
+			gi.Printf( "ET_PUSH_TRIGGER     " );
+			break;
+		case ET_TELEPORT_TRIGGER:
+			gi.Printf( "ET_TELEPORT_TRIGGER " );
+			break;
+		case ET_INVISIBLE:
+			gi.Printf( "ET_INVISIBLE        " );
+			break;
+		case ET_THINKER:
+			gi.Printf( "ET_THINKER          " );
+			break;
+		case ET_CLOUD:
+			gi.Printf( "ET_CLOUD            " );
 			break;
 		default:
-			gi.Printf("#%i", check->s.eType);
+			gi.Printf( "%-3i                ", check->s.eType );
 			break;
 		}
 
@@ -328,306 +349,280 @@ void Svcmd_SaberAttackCycle_f( void )
 	switch ( saberAnimLevel )
 	{
 	case FORCE_LEVEL_1:
-		gi.Printf( S_COLOR_BLUE"Lightsaber Combat Style: Fast\n" );
+		gi.Printf( S_COLOR_BLUE "Lightsaber Combat Style: Fast\n" );
 		//LIGHTSABERCOMBATSTYLE_FAST
 		break;
 	case FORCE_LEVEL_2:
-		gi.Printf( S_COLOR_YELLOW"Lightsaber Combat Style: Medium\n" );
+		gi.Printf( S_COLOR_YELLOW "Lightsaber Combat Style: Medium\n" );
 		//LIGHTSABERCOMBATSTYLE_MEDIUM
 		break;
 	case FORCE_LEVEL_3:
-		gi.Printf( S_COLOR_RED"Lightsaber Combat Style: Strong\n" );
+		gi.Printf( S_COLOR_RED "Lightsaber Combat Style: Strong\n" );
 		//LIGHTSABERCOMBATSTYLE_STRONG
 		break;
 	case FORCE_LEVEL_4:
-		gi.Printf( S_COLOR_CYAN"Lightsaber Combat Style: Desann\n" );
+		gi.Printf( S_COLOR_CYAN "Lightsaber Combat Style: Desann\n" );
 		//LIGHTSABERCOMBATSTYLE_DESANN
 		break;
 	case FORCE_LEVEL_5:
-		gi.Printf( S_COLOR_MAGENTA"Lightsaber Combat Style: Tavion\n" );
+		gi.Printf( S_COLOR_MAGENTA "Lightsaber Combat Style: Tavion\n" );
 		//LIGHTSABERCOMBATSTYLE_TAVION
 		break;
 	}
 	//gi.Printf("\n");
 #endif
 }
-/*
-=================
-ConsoleCommand
 
-=================
-*/
-qboolean	ConsoleCommand( void ) {
-	const char	*cmd;
-
-	cmd = gi.argv(0);
+template <int32_t power>
+static void Svcmd_ForceSetLevel_f(void)
+{
+	Svcmd_ForceSetLevel_f(power);
+}
 
-	if ( Q_stricmp (cmd, "entitylist") == 0 ) 
+static void Svcmd_SetForceAll_f(void)
+{
+	for ( int i = FP_HEAL; i <= FP_SABER_OFFENSE; i++ )
 	{
-		Svcmd_EntityList_f();
-		return qtrue;
+		Svcmd_ForceSetLevel_f( i );
 	}
+}
 
-	if (Q_stricmp (cmd, "game_memory") == 0) {
-		Svcmd_GameMem_f();
-		return qtrue;
-	}
+static void Svcmd_SetSaberAll_f(void)
+{
+	Svcmd_ForceSetLevel_f( FP_SABERTHROW );
+	Svcmd_ForceSetLevel_f( FP_SABER_DEFENSE );
+	Svcmd_ForceSetLevel_f( FP_SABER_OFFENSE );
+}
 
-//	if (Q_stricmp (cmd, "addbot") == 0) {
-//		Svcmd_AddBot_f();
-//		return qtrue;
-//	}
+static void Svcmd_RunScript_f(void)
+{
+	const char *cmd2 = gi.argv(1);
 
-	if (Q_stricmp (cmd, "nav") == 0) 
+	if ( cmd2 && cmd2[0] )
 	{
-		if ( !g_cheats->integer ) 
+		const char *cmd3 = gi.argv(2);
+		if ( cmd3 && cmd3[0] )
 		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
+			gentity_t *found = NULL;
+			if ( (found = G_Find(NULL, FOFS(targetname), cmd2 ) ) != NULL )
+			{
+				ICARUS_RunScript( found, cmd3 );
+			}
+			else
+			{
+				//can't find cmd2
+				gi.Printf( S_COLOR_RED "runscript: can't find targetname %s\n", cmd2 );
+			}
 		}
-		Svcmd_Nav_f ();
-		return qtrue;
-	}
-
-	if (Q_stricmp (cmd, "npc") == 0) 
-	{
-		if ( !g_cheats->integer ) 
+		else
 		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
+			ICARUS_RunScript( &g_entities[0], cmd2 );
 		}
-		Svcmd_NPC_f ();
-		return qtrue;
 	}
-
-	if (Q_stricmp (cmd, "use") == 0) 
+	else
 	{
-		if ( !g_cheats->integer ) 
-		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
-		}
-		Svcmd_Use_f ();
-		return qtrue;
+		gi.Printf( S_COLOR_RED "usage: runscript <ent targetname> scriptname\n" );
 	}
+}
+
+static void Svcmd_PlayerTeam_f(void)
+{
+	const char *cmd2 = gi.argv(1);
 
-	if ( Q_stricmp( cmd, "ICARUS" ) == 0 )	
+	if ( !*cmd2 || !cmd2[0] )
 	{
-		if ( !g_cheats->integer ) 
+		gi.Printf( S_COLOR_RED "'playerteam' - change player team, requires a team name!\n" );
+		gi.Printf( S_COLOR_RED "Current team is: %s\n", TeamNames[g_entities[0].client->playerTeam] );
+		gi.Printf( S_COLOR_RED "Valid team names are:\n");
+		for ( int n = (TEAM_FREE + 1); n < TEAM_NUM_TEAMS; n++ )
 		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
+			gi.Printf( S_COLOR_RED "%s\n", TeamNames[n] );
 		}
-		Svcmd_ICARUS_f();
-		return qtrue;
 	}
-
-	if ( Q_stricmp( cmd, "saberColor" ) == 0 )	
+	else
 	{
-		if ( !g_cheats->integer ) 
+		team_t team = TranslateTeamName( cmd2 );
+
+		if ( team == TEAM_FREE )
 		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
+			gi.Printf( S_COLOR_RED "'playerteam' unrecognized team name %s!\n", cmd2 );
+			gi.Printf( S_COLOR_RED "Current team is: %s\n", TeamNames[g_entities[0].client->playerTeam] );
+			gi.Printf( S_COLOR_RED "Valid team names are:\n");
+			for ( int n = TEAM_FREE; n < TEAM_NUM_TEAMS; n++ )
+			{
+				gi.Printf( S_COLOR_RED "%s\n", TeamNames[n] );
+			}
+		}
+		else
+		{
+			g_entities[0].client->playerTeam = team;
+			//FIXME: convert Imperial, Malon, Hirogen and Klingon to Scavenger?
 		}
-		Svcmd_SaberColor_f();
-		return qtrue;
 	}
+}
 
-	if ( Q_stricmp( cmd, "setForceJump" ) == 0 )
-	{
-		Svcmd_ForceSetLevel_f( FP_LEVITATION );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setSaberThrow" ) == 0 )
-	{
-		Svcmd_ForceSetLevel_f( FP_SABERTHROW );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setForceHeal" ) == 0 )
-	{
-		Svcmd_ForceSetLevel_f( FP_HEAL );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setForcePush" ) == 0 )
-	{
-		Svcmd_ForceSetLevel_f( FP_PUSH );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setForcePull" ) == 0 )
-	{
-		Svcmd_ForceSetLevel_f( FP_PULL );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setForceSpeed" ) == 0 )
-	{
-		Svcmd_ForceSetLevel_f( FP_SPEED );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setForceGrip" ) == 0 )
+static void Svcmd_Control_f(void)
+{
+	const char	*cmd2 = gi.argv(1);
+	if ( !*cmd2 || !cmd2[0] )
 	{
-		Svcmd_ForceSetLevel_f( FP_GRIP );
-		return qtrue;
+		if ( !G_ClearViewEntity( &g_entities[0] ) )
+		{
+			gi.Printf( S_COLOR_RED "control <NPC_targetname>\n", cmd2 );
+		}
 	}
-	if ( Q_stricmp( cmd, "setForceLightning" ) == 0 )
+	else
 	{
-		Svcmd_ForceSetLevel_f( FP_LIGHTNING );
-		return qtrue;
+		Q3_SetViewEntity( 0, cmd2 );
 	}
-	if ( Q_stricmp( cmd, "setMindTrick" ) == 0 )
+}
+
+static void Svcmd_Secrets_f(void)
+{
+	const gentity_t *pl = &g_entities[0];
+	if(pl->client->sess.missionStats.totalSecrets < 1)
 	{
-		Svcmd_ForceSetLevel_f( FP_TELEPATHY );
-		return qtrue;
+		gi.Printf( "There are" S_COLOR_RED " NO " S_COLOR_WHITE "secrets on this map!\n" );
 	}
-	if ( Q_stricmp( cmd, "setSaberDefense" ) == 0 )
+	else if(pl->client->sess.missionStats.secretsFound == pl->client->sess.missionStats.totalSecrets)
 	{
-		Svcmd_ForceSetLevel_f( FP_SABER_DEFENSE );
-		return qtrue;
+		gi.Printf( "You've found all " S_COLOR_GREEN "%i" S_COLOR_WHITE " secrets on this map!\n", pl->client->sess.missionStats.secretsFound );
 	}
-	if ( Q_stricmp( cmd, "setSaberOffense" ) == 0 )
+	else
 	{
-		Svcmd_ForceSetLevel_f( FP_SABER_OFFENSE );
-		return qtrue;
+		gi.Printf( "You've found " S_COLOR_GREEN "%i" S_COLOR_WHITE " out of " S_COLOR_GREEN "%i" S_COLOR_WHITE " secrets!\n", pl->client->sess.missionStats.secretsFound, pl->client->sess.missionStats.totalSecrets );
 	}
-	if ( Q_stricmp( cmd, "setForceAll" ) == 0 )
-	{
-		if ( !g_cheats->integer )
-		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"" );
-			return qtrue;
-		}
+}
 
-		for ( int i = FP_HEAL; i <= FP_SABER_OFFENSE; i++ )
-		{
-			Svcmd_ForceSetLevel_f( i );
-		}
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "setSaberAll" ) == 0 )
+// PADAWAN - g_spskill 0 + cg_crosshairForceHint 1 + handicap 100
+// JEDI - g_spskill 1 + cg_crosshairForceHint 1 + handicap 100
+// JEDI KNIGHT - g_spskill 2 + cg_crosshairForceHint 0 + handicap 100
+// JEDI MASTER - g_spskill 2 + cg_crosshairForceHint 0 + handicap 50
+
+extern cvar_t *g_spskill;
+static void Svcmd_Difficulty_f(void)
+{
+	if(gi.argc() == 1)
 	{
-		if ( !g_cheats->integer )
+		if(g_spskill->integer == 0)
 		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"" );
-			return qtrue;
+			gi.Printf( S_COLOR_GREEN "Current Difficulty: Padawan" S_COLOR_WHITE "\n" );
 		}
-
-		Svcmd_ForceSetLevel_f( FP_SABERTHROW );
-		Svcmd_ForceSetLevel_f( FP_SABER_DEFENSE );
-		Svcmd_ForceSetLevel_f( FP_SABER_OFFENSE );
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "saberAttackCycle" ) == 0 )	
-	{
-		Svcmd_SaberAttackCycle_f();
-		return qtrue;
-	}
-	if ( Q_stricmp( cmd, "runscript" ) == 0 ) 
-	{
-		if ( !g_cheats->integer ) 
+		else if(g_spskill->integer == 1)
 		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
+			gi.Printf( S_COLOR_GREEN "Current Difficulty: Jedi" S_COLOR_WHITE "\n" );
 		}
-		const char *cmd2 = gi.argv(1);
-
-		if ( cmd2 && cmd2[0] )
+		else if(g_spskill->integer == 2)
 		{
-			const char *cmd3 = gi.argv(2);
-			if ( cmd3 && cmd3[0] )
+			int crosshairHint = gi.Cvar_VariableIntegerValue("cg_crosshairForceHint");
+			int handicap = gi.Cvar_VariableIntegerValue("handicap");
+			if(handicap == 100 && crosshairHint == 0)
+			{
+				gi.Printf( S_COLOR_GREEN "Current Difficulty: Jedi Knight" S_COLOR_WHITE "\n" );
+			}
+			else if(handicap == 50 && crosshairHint == 0)
 			{
-				gentity_t *found = NULL;
-				if ( (found = G_Find(NULL, FOFS(targetname), cmd2 ) ) != NULL )
-				{
-					ICARUS_RunScript( found, va( "%s/%s", Q3_SCRIPT_DIR, cmd3 ) );
-				}
-				else
-				{
-					//can't find cmd2
-					gi.Printf( S_COLOR_RED"runscript: can't find targetname %s\n", cmd2 );
-				}
+				gi.Printf( S_COLOR_GREEN "Current Difficulty: Jedi Master" S_COLOR_WHITE "\n" );
 			}
 			else
 			{
-				ICARUS_RunScript( &g_entities[0], va( "%s/%s", Q3_SCRIPT_DIR, cmd2 ) );
+				gi.Printf( S_COLOR_GREEN "Current Difficulty: Jedi Knight (Custom)" S_COLOR_WHITE "\n" );
+				gi.Printf( S_COLOR_GREEN "Crosshair Force Hint: %i" S_COLOR_WHITE "\n", crosshairHint != 0 ? 1 : 0 );
+				gi.Printf( S_COLOR_GREEN "Handicap: %i" S_COLOR_WHITE "\n", handicap );
 			}
 		}
 		else
 		{
-			gi.Printf( S_COLOR_RED"usage: runscript <ent targetname> scriptname\n" );
+			gi.Printf( S_COLOR_RED "Invalid difficulty cvar set! g_spskill (%i) [0-2] is valid range only" S_COLOR_WHITE "\n", g_spskill->integer );
 		}
-		//FIXME: else warning
-		return qtrue;
 	}
+}
 
-	if ( Q_stricmp( cmd, "playerteam" ) == 0 ) 
-	{
-		if ( !g_cheats->integer ) 
-		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
-		}
-		const char	*cmd2 = gi.argv(1);
-		int		n;
+#define CMD_NONE				(0x00000000u)
+#define CMD_CHEAT				(0x00000001u)
+#define CMD_ALIVE				(0x00000002u)
 
-		if ( !*cmd2 || !cmd2[0] )
-		{
-			gi.Printf( S_COLOR_RED"'playerteam' - change player team, requires a team name!\n" );
-			gi.Printf( S_COLOR_RED"Valid team names are:\n");
-			for ( n = (TEAM_FREE + 1); n < TEAM_NUM_TEAMS; n++ )
-			{
-				gi.Printf( S_COLOR_RED"%s\n", TeamNames[n] );
-			}
-		}
-		else
-		{
-			team_t	team;
+typedef struct svcmd_s {
+	const char	*name;
+	void		(*func)(void);
+	uint32_t	flags;
+} svcmd_t;
 
-			team = TranslateTeamName( cmd2 );
-			if ( team == TEAM_FREE )
-			{
-				gi.Printf( S_COLOR_RED"'playerteam' unrecognized team name %s!\n", cmd2 );
-				gi.Printf( S_COLOR_RED"Valid team names are:\n");
-				for ( n = (TEAM_FREE + 1); n < TEAM_NUM_TEAMS; n++ )
-				{
-					gi.Printf( S_COLOR_RED"%s\n", TeamNames[n] );
-				}
-			}
-			else
-			{
-				g_entities[0].client->playerTeam = team;
-				//FIXME: convert Imperial, Malon, Hirogen and Klingon to Scavenger?
-			}
-		}
-		return qtrue;
-	}
+static int svcmdcmp( const void *a, const void *b ) {
+	return Q_stricmp( (const char *)a, ((svcmd_t*)b)->name );
+}
+
+// FIXME some of these should be made CMD_ALIVE too!
+static svcmd_t svcmds[] = {
+	{ "entitylist",					Svcmd_EntityList_f,							CMD_NONE },
+	{ "game_memory",				Svcmd_GameMem_f,							CMD_NONE },
+
+	{ "nav",						Svcmd_Nav_f,								CMD_CHEAT },
+	{ "npc",						Svcmd_NPC_f,								CMD_CHEAT },
+	{ "use",						Svcmd_Use_f,								CMD_CHEAT },
+	{ "ICARUS",						Svcmd_ICARUS_f,								CMD_CHEAT },
+
+	{ "saberColor",					Svcmd_SaberColor_f,							CMD_CHEAT },
+	
+	{ "setForceJump",				Svcmd_ForceSetLevel_f<FP_LEVITATION>,		CMD_CHEAT },
+	{ "setSaberThrow",				Svcmd_ForceSetLevel_f<FP_SABERTHROW>,		CMD_CHEAT },
+	{ "setForceHeal",				Svcmd_ForceSetLevel_f<FP_HEAL>,				CMD_CHEAT },
+	{ "setForcePush",				Svcmd_ForceSetLevel_f<FP_PUSH>,				CMD_CHEAT },
+	{ "setForcePull",				Svcmd_ForceSetLevel_f<FP_PULL>,				CMD_CHEAT },
+	{ "setForceSpeed",				Svcmd_ForceSetLevel_f<FP_SPEED>,			CMD_CHEAT },
+	{ "setForceGrip",				Svcmd_ForceSetLevel_f<FP_GRIP>,				CMD_CHEAT },
+	{ "setForceLightning",			Svcmd_ForceSetLevel_f<FP_LIGHTNING>,		CMD_CHEAT },
+	{ "setMindTrick",				Svcmd_ForceSetLevel_f<FP_TELEPATHY>,		CMD_CHEAT },
+	{ "setSaberDefense",			Svcmd_ForceSetLevel_f<FP_SABER_DEFENSE>,	CMD_CHEAT },
+	{ "setSaberOffense",			Svcmd_ForceSetLevel_f<FP_SABER_OFFENSE>,	CMD_CHEAT },
+	{ "setForceAll",				Svcmd_SetForceAll_f,						CMD_CHEAT },
+	{ "setSaberAll",				Svcmd_SetSaberAll_f,						CMD_CHEAT },
+	
+	{ "saberAttackCycle",			Svcmd_SaberAttackCycle_f,					CMD_NONE },
+	
+	{ "runscript",					Svcmd_RunScript_f,							CMD_CHEAT },
+	
+	{ "playerTeam",					Svcmd_PlayerTeam_f,							CMD_CHEAT },
+	
+	{ "control",					Svcmd_Control_f,							CMD_CHEAT },
 
-	if ( Q_stricmp( cmd, "control" ) == 0 )
+	{ "exitview",					Svcmd_ExitView_f,							CMD_NONE },
+	
+	{ "secrets",					Svcmd_Secrets_f,							CMD_NONE },
+	{ "difficulty",					Svcmd_Difficulty_f,							CMD_NONE },
+	
+	//{ "say",						Svcmd_Say_f,						qtrue },
+	//{ "toggleallowvote",			Svcmd_ToggleAllowVote_f,			qfalse },
+	//{ "toggleuserinfovalidation",	Svcmd_ToggleUserinfoValidation_f,	qfalse },
+};
+static const size_t numsvcmds = ARRAY_LEN( svcmds );
+
+/*
+=================
+ConsoleCommand
+=================
+*/
+qboolean	ConsoleCommand( void ) {
+	const char *cmd = gi.argv(0);
+	const svcmd_t *command = (const svcmd_t *)Q_LinearSearch( cmd, svcmds, numsvcmds, sizeof( svcmds[0] ), svcmdcmp );
+
+	if ( !command )
+		return qfalse;
+	
+	if ( (command->flags & CMD_CHEAT)
+		&& !g_cheats->integer )
 	{
-		if ( !g_cheats->integer ) 
-		{
-			gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
-			return qtrue;
-		}
-		const char	*cmd2 = gi.argv(1);
-		if ( !*cmd2 || !cmd2[0] )
-		{
-			if ( !G_ClearViewEntity( &g_entities[0] ) )
-			{
-				gi.Printf( S_COLOR_RED"control <NPC_targetname>\n", cmd2 );
-			}
-		}
-		else
-		{
-			Q3_SetViewEntity( 0, cmd2 );
-		}
+		gi.Printf( "Cheats are not enabled on this server.\n" );
 		return qtrue;
 	}
-
-	if ( Q_stricmp( cmd, "exitview" ) == 0 )
+	else if ( (command->flags & CMD_ALIVE)
+		&& (g_entities[0].health <= 0) )
 	{
-		Svcmd_ExitView_f();
+		gi.Printf( "You must be alive to use this command.\n" );
 		return qtrue;
 	}
-	
-	return qfalse;
+	else
+		command->func();
+	return qtrue;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list