Have gone through a few files change a thing or two.

This commit is contained in:
Walter Julius Hennecke 2013-07-06 18:19:28 +02:00
parent 1b808f208e
commit e849b1c516
23 changed files with 507 additions and 533 deletions

View file

@ -6,6 +6,7 @@
#include "cg_local.h"
#include "cg_screenfx.h"
#include "fx_local.h"
#include "../game/bg_misc.h"
//#include "cg_anims.h" //RPG-X: J2J - Added for animation string table.
const char *cg_customSoundNames[MAX_CUSTOM_SOUNDS] = {
@ -40,7 +41,6 @@ int timeParam;
//int beamTimeParam; //RPG-X : TiM - Beaming
int entNum;
extern char* BG_RegisterRace( const char *name );
/*
================

View file

@ -2,5 +2,6 @@
#define _BG_MISC_H
void BG_LanguageFilename(char *baseName,char *baseExtension,char *finalName);
char* BG_RegisterRace( const char *name );
#endif /* _BG_MISC_H */

View file

@ -2,6 +2,7 @@
//
#include "g_local.h"
#include "g_client.h"
extern void SP_misc_ammo_station( gentity_t *ent );
extern void ammo_station_finish_spawning ( gentity_t *self );

View file

@ -404,7 +404,7 @@ void Svcmd_AbortPodium_f( void ) {
return;
}
if( podium1 ) {
if( podium1 != NULL ) {
podium1->nextthink = level.time;
podium1->think = CelebrateStop;
}

View file

@ -4,34 +4,34 @@
#include "g_local.h"
#include "g_main.h"
#include "g_client.h"
static int g_numBots;
static char *g_botInfos[MAX_BOTS];
static int32_t g_numBots;
static char* g_botInfos[MAX_BOTS];
int g_numArenas;
static char *g_arenaInfos[MAX_ARENAS];
int32_t g_numArenas;
static char* g_arenaInfos[MAX_ARENAS];
#define BOT_BEGIN_DELAY_BASE 2000
#define BOT_BEGIN_DELAY_INCREMENT 2000
#define BOT_SPAWN_QUEUE_DEPTH 16
#define BOT_SPAWN_QUEUE_DEPTH 16
typedef struct {
int clientNum;
int spawnTime;
int32_t clientNum;
int32_t spawnTime;
} botSpawnQueue_t;
static int botBeginDelay;
static int32_t botBeginDelay;
static botSpawnQueue_t botSpawnQueue[BOT_SPAWN_QUEUE_DEPTH];
vmCvar_t bot_minplayers;
extern gentity_t *podium1;
extern gentity_t *podium2;
extern gentity_t *podium3;
extern gentity_t* podium1;
extern gentity_t* podium2;
extern gentity_t* podium3;
/*
@ -39,20 +39,21 @@ extern gentity_t *podium3;
G_ParseInfos
===============
*/
int G_ParseInfos( char *buf, int max, char *infos[] ) {
char *token;
int count;
int32_t G_ParseInfos( char* buf, int32_t max, char* infos[] ) {
char* token = NULL;
int32_t count = 0;
char key[MAX_TOKEN_CHARS];
char info[MAX_INFO_STRING];
count = 0;
while ( 1 ) {
while ( qtrue ) {
token = COM_Parse( &buf );
if ( !token[0] ) {
if ( token == NULL || token[0] == 0 ) {
break;
}
if ( strcmp( token, "{" ) ) {
if ( strcmp( token, "{" ) != 0 ) {
Com_Printf( "Missing { in info file\n" );
break;
}
@ -63,26 +64,27 @@ int G_ParseInfos( char *buf, int max, char *infos[] ) {
}
info[0] = '\0';
while ( 1 ) {
while ( qtrue ) {
token = COM_ParseExt( &buf, qtrue );
if ( !token[0] ) {
if ( token == NULL || token[0] == 0 ) {
Com_Printf( "Unexpected end of info file\n" );
break;
}
if ( !strcmp( token, "}" ) ) {
if ( strcmp( token, "}" ) == 0 ) {
break;
}
Q_strncpyz( key, token, sizeof( key ) );
strncpy(key, token, sizeof(key));
token = COM_ParseExt( &buf, qfalse );
if ( !token[0] ) {
if ( token == NULL || token[0] == 0 ) {
strcpy( token, "<NULL>" );
}
Info_SetValueForKey( info, key, token );
}
//NOTE: extra space for arena number
infos[count] = G_Alloc(strlen(info) + strlen("\\num\\") + strlen(va("%d", MAX_ARENAS)) + 1);
if (infos[count]) {
if (infos[count] != NULL) {
strcpy(infos[count], info);
count++;
}
@ -95,16 +97,17 @@ int G_ParseInfos( char *buf, int max, char *infos[] ) {
G_LoadArenasFromFile
===============
*/
static void G_LoadArenasFromFile( char *filename ) {
int len;
fileHandle_t f;
static void G_LoadArenasFromFile( char* filename ) {
int32_t len = 0;
fileHandle_t f = 0;
char buf[MAX_ARENAS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
if ( f == 0 ) {
trap_Printf( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
if ( len >= MAX_ARENAS_TEXT ) {
trap_Printf( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT ) );
trap_FS_FCloseFile( f );
@ -124,21 +127,21 @@ G_LoadArenas
===============
*/
static void G_LoadArenas( void ) {
int numdirs;
int32_t numdirs = 0;
vmCvar_t arenasFile;
char filename[128];
char dirlist[4096];
char* dirptr;
int i, n;
int dirlen;
char* dirptr = NULL;
int32_t i = 0;
int32_t n = 0;
int32_t dirlen = 0;
g_numArenas = 0;
trap_Cvar_Register( &arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM );
if( *arenasFile.string ) {
G_LoadArenasFromFile(arenasFile.string);
}
else {
} else {
G_LoadArenasFromFile("scripts/arenas.txt");
}
@ -165,8 +168,8 @@ static void G_LoadArenas( void ) {
G_GetArenaInfoByNumber
===============
*/
const char *G_GetArenaInfoByMap( const char *map ) {
int n;
const char* G_GetArenaInfoByMap( const char* map ) {
int32_t n = 0;
for( n = 0; n < g_numArenas; n++ ) {
if( Q_stricmp( Info_ValueForKey( g_arenaInfos[n], "map" ), map ) == 0 ) {
@ -183,16 +186,15 @@ const char *G_GetArenaInfoByMap( const char *map ) {
PlayerIntroSound
=================
*/
static void PlayerIntroSound( const char *modelAndSkin ) {
static void PlayerIntroSound( const char* modelAndSkin ) {
char model[MAX_QPATH];
char *skin;
char* skin = NULL;
Q_strncpyz( model, modelAndSkin, sizeof(model) );
skin = Q_strrchr( model, '/' );
if ( skin ) {
strncpy(model, modelAndSkin, sizeof(model));
skin = strchr(model, '/');
if ( skin != NULL ) {
*skin++ = '\0';
}
else {
} else {
skin = model;
}
@ -214,10 +216,15 @@ static void PlayerIntroSound( const char *modelAndSkin ) {
G_AddRandomBot
===============
*/
void G_AddRandomBot( int team ) {
int i, n, num, skill;
char *value, netname[36], *teamstr;
gclient_t *cl;
void G_AddRandomBot( int32_t team ) {
int32_t i = 0;
int32_t n = 0;
int32_t num = 0;
int32_t skill = 0;
char* value = NULL;
char netname[36];
char* teamstr = NULL;
gclient_t* cl = NULL;
num = 0;
for ( n = 0; n < g_numBots ; n++ ) {
@ -228,13 +235,13 @@ void G_AddRandomBot( int team ) {
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
if ( (g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) == 0 ) {
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
if ( !Q_stricmp( value, cl->pers.netname ) ) {
if ( Q_stricmp( value, cl->pers.netname ) == 0 ) {
break;
}
}
@ -251,13 +258,13 @@ void G_AddRandomBot( int team ) {
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
if ( (g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) == 0 ) {
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
if ( !Q_stricmp( value, cl->pers.netname ) ) {
if ( Q_stricmp( value, cl->pers.netname ) == 0 ) {
break;
}
}
@ -265,13 +272,20 @@ void G_AddRandomBot( int team ) {
num--;
if (num <= 0) {
skill = trap_Cvar_VariableIntegerValue( "g_spSkill" );
if (team == TEAM_RED) teamstr = "red";
else if (team == TEAM_BLUE) teamstr = "blue";
else teamstr = "";
if (team == TEAM_RED) {
teamstr = "red";
} else if (team == TEAM_BLUE) {
teamstr = "blue";
} else {
teamstr = "";
}
strncpy(netname, value, sizeof(netname)-1);
netname[sizeof(netname)-1] = '\0';
Q_CleanStr(netname);
trap_SendConsoleCommand( EXEC_INSERT, va("addbot %s %i %s %i\n", netname, skill, teamstr, 0) );
return;
}
}
@ -283,25 +297,30 @@ void G_AddRandomBot( int team ) {
G_RemoveRandomBot
===============
*/
int G_RemoveRandomBot( int team ) {
int i;
char netname[36];
gclient_t *cl;
qboolean G_RemoveRandomBot( int32_t team ) {
int32_t i = 0;
char netname[36];
gclient_t* cl = NULL;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
strcpy(netname, cl->pers.netname);
Q_CleanStr(netname);
trap_SendConsoleCommand( EXEC_INSERT, va("kick \"%s\"\n", netname) );
return qtrue;
}
return qfalse;
@ -312,24 +331,29 @@ int G_RemoveRandomBot( int team ) {
G_CountHumanPlayers
===============
*/
int G_CountHumanPlayers( int team ) {
int i, num;
gclient_t *cl;
int32_t G_CountHumanPlayers( int32_t team ) {
int32_t i = 0;
int32_t num = 0;
gclient_t* cl = NULL;
num = 0;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
if ( g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT ) {
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
num++;
}
return num;
}
@ -338,26 +362,32 @@ int G_CountHumanPlayers( int team ) {
G_CountBotPlayers
===============
*/
int G_CountBotPlayers( int team ) {
int i, n, num;
gclient_t *cl;
int32_t G_CountBotPlayers( int32_t team ) {
int32_t i = 0;
int32_t n = 0;
int32_t num = 0;
gclient_t* cl = NULL;
num = 0;
for ( i=0 ; i< g_maxclients.integer ; i++ ) {
for ( ; i< g_maxclients.integer ; i++ ) {
cl = level.clients + i;
if ( cl->pers.connected != CON_CONNECTED ) {
continue;
}
if ( !(g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) ) {
if ( (g_entities[cl->ps.clientNum].r.svFlags & SVF_BOT) == 0 ) {
continue;
}
if ( team >= 0 && cl->sess.sessionTeam != team ) {
continue;
}
num++;
}
for( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( !botSpawnQueue[n].spawnTime ) {
for( ; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( botSpawnQueue[n].spawnTime == 0 ) {
continue;
}
if ( botSpawnQueue[n].spawnTime > level.time ) {
@ -374,11 +404,15 @@ G_CheckMinimumPlayers
===============
*/
void G_CheckMinimumPlayers( void ) {
int minplayers;
int humanplayers, botplayers;
static int checkminimumplayers_time;
int32_t minplayers = 0;
int32_t humanplayers = 0;
int32_t botplayers = 0;
static int32_t checkminimumplayers_time = 0;
if(level.intermissiontime != 0) {
return;
}
if (level.intermissiontime) return;
//only check once each 10 seconds
if (checkminimumplayers_time > level.time - 10000) {
return;
@ -387,13 +421,13 @@ void G_CheckMinimumPlayers( void ) {
checkminimumplayers_time = level.time;
trap_Cvar_Update(&bot_minplayers);
minplayers = bot_minplayers.integer;
if (minplayers <= 0) return;
if (minplayers <= 0) {
return;
}
if (g_gametype.integer != GT_TOURNAMENT)
{
if (g_gametype.integer != GT_TOURNAMENT) {
botplayers = G_CountBotPlayers( TEAM_SPECTATOR );
if ( botplayers > 0 )
{
if ( botplayers > 0 ) {
G_RemoveRandomBot( TEAM_SPECTATOR );
}
}
@ -419,8 +453,7 @@ void G_CheckMinimumPlayers( void ) {
} else if (humanplayers + botplayers > minplayers && botplayers) {
G_RemoveRandomBot( TEAM_BLUE );
}
}
else if (g_gametype.integer == GT_TOURNAMENT) {
} else if (g_gametype.integer == GT_TOURNAMENT) {
if (minplayers >= g_maxclients.integer) {
minplayers = g_maxclients.integer-1;
}
@ -436,8 +469,7 @@ void G_CheckMinimumPlayers( void ) {
G_RemoveRandomBot( -1 );
}
}
}
else if (g_gametype.integer == GT_FFA) {
} else if (g_gametype.integer == GT_FFA) {
if (minplayers >= g_maxclients.integer) {
minplayers = g_maxclients.integer-1;
}
@ -458,18 +490,20 @@ G_CheckBotSpawn
===============
*/
void G_CheckBotSpawn( void ) {
int n;
int32_t n = 0;
char userinfo[MAX_INFO_VALUE];
G_CheckMinimumPlayers();
for( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( !botSpawnQueue[n].spawnTime ) {
for( ; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( botSpawnQueue[n].spawnTime == 0 ) {
continue;
}
if ( botSpawnQueue[n].spawnTime > level.time ) {
continue;
}
G_Client_Begin( botSpawnQueue[n].clientNum, qfalse, qtrue, qfalse );
botSpawnQueue[n].spawnTime = 0;
@ -486,11 +520,11 @@ void G_CheckBotSpawn( void ) {
AddBotToSpawnQueue
===============
*/
static void AddBotToSpawnQueue( int clientNum, int delay ) {
int n;
static void AddBotToSpawnQueue( int32_t clientNum, int32_t delay ) {
int32_t n = 0;
for( n = 0; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( !botSpawnQueue[n].spawnTime ) {
for( ; n < BOT_SPAWN_QUEUE_DEPTH; n++ ) {
if( botSpawnQueue[n].spawnTime == 0 ) {
botSpawnQueue[n].spawnTime = level.time + delay;
botSpawnQueue[n].clientNum = clientNum;
return;
@ -507,7 +541,7 @@ static void AddBotToSpawnQueue( int clientNum, int delay ) {
G_QueueBotBegin
===============
*/
void G_QueueBotBegin( int clientNum ) {
void G_QueueBotBegin( int32_t clientNum ) {
AddBotToSpawnQueue( clientNum, botBeginDelay );
botBeginDelay += BOT_BEGIN_DELAY_INCREMENT;
}
@ -518,26 +552,25 @@ void G_QueueBotBegin( int clientNum ) {
G_BotConnect
===============
*/
qboolean G_BotConnect( int clientNum, qboolean restart ) {
qboolean G_BotConnect( int32_t clientNum, qboolean restart ) {
bot_settings_t settings;
char userinfo[MAX_INFO_STRING];
trap_GetUserinfo( clientNum, userinfo, sizeof(userinfo) );
Q_strncpyz( settings.characterfile, Info_ValueForKey( userinfo, "characterfile" ), sizeof(settings.characterfile) );
strncpy(settings.characterfile, Info_ValueForKey(userinfo, "characterfile"), sizeof(settings.characterfile));
settings.skill = atoi( Info_ValueForKey( userinfo, "skill" ) );
Q_strncpyz( settings.team, Info_ValueForKey( userinfo, "team" ), sizeof(settings.team) );
Q_strncpyz( settings.pclass, Info_ValueForKey( userinfo, "class" ), sizeof(settings.pclass) );
strncpy( settings.team, Info_ValueForKey( userinfo, "team" ), sizeof(settings.team) );
strncpy( settings.pclass, Info_ValueForKey( userinfo, "class" ), sizeof(settings.pclass) );
if (!BotAISetupClient( clientNum, &settings )) {
if (BotAISetupClient( clientNum, &settings ) == 0) {
trap_DropClient( clientNum, "BotAISetupClient failed" );
return qfalse;
}
if( restart && g_gametype.integer == GT_SINGLE_PLAYER ) {
if( restart && (g_gametype.integer == GT_SINGLE_PLAYER) ) {
g_entities[clientNum].botDelayBegin = qtrue;
}
else {
} else {
g_entities[clientNum].botDelayBegin = qfalse;
}
@ -550,20 +583,20 @@ qboolean G_BotConnect( int clientNum, qboolean restart ) {
G_AddBot
===============
*/
static void G_AddBot( const char *name, float skill, const char *team, const char *pclass, int delay, char *altname) {
int clientNum;
char *botinfo;
gentity_t *bot;
char *key;
char *s;
char *botname;
char *model;
static void G_AddBot( const char* name, double skill, const char* team, const char* pclass, int32_t delay, char* altname) {
int32_t clientNum = 0;
char* botinfo = NULL;
gentity_t* bot = NULL;
char* key = NULL;
char* s = NULL;
char* botname = NULL;
char* model = NULL;
char userinfo[MAX_INFO_STRING];
int preTeam = 0;
int32_t preTeam = 0;
// get the botinfo from bots.txt
botinfo = G_GetBotInfoByName( name );
if ( !botinfo ) {
if ( botinfo == NULL || botinfo[0] == 0 ) {
G_Printf( S_COLOR_RED "Error: Bot '%s' not defined\n", name );
return;
}
@ -572,11 +605,11 @@ static void G_AddBot( const char *name, float skill, const char *team, const cha
userinfo[0] = '\0';
botname = Info_ValueForKey( botinfo, "funname" );
if( !botname[0] ) {
if( botname == NULL || botname[0] == 0 ) {
botname = Info_ValueForKey( botinfo, "name" );
}
// check for an alternative name
if (altname && altname[0]) {
if ((altname != NULL) && (altname[0] != 0)) {
botname = altname;
}
Info_SetValueForKey( userinfo, "name", botname );
@ -584,19 +617,9 @@ static void G_AddBot( const char *name, float skill, const char *team, const cha
Info_SetValueForKey( userinfo, "snaps", "20" );
Info_SetValueForKey( userinfo, "skill", va("%1.2f", skill) );
/* if ( skill >= 1 && skill < 2 ) {
Info_SetValueForKey( userinfo, "handicap", "50" );
}
else if ( skill >= 2 && skill < 3 ) {
Info_SetValueForKey( userinfo, "handicap", "70" );
}
else if ( skill >= 3 && skill < 4 ) {
Info_SetValueForKey( userinfo, "handicap", "90" );
} */
key = "model";
model = Info_ValueForKey( botinfo, key );
if ( !*model ) {
if ( *model ) {
model = "munro/main/default"; //RPG-X MODEL SYSTEM
}
Info_SetValueForKey( userinfo, key, model );
@ -630,7 +653,7 @@ static void G_AddBot( const char *name, float skill, const char *team, const cha
}
// initialize the bot settings
if( !team || !*team ) {
if( team == NULL || !*team ) {
if( g_gametype.integer >= GT_TEAM ) {
if( G_Client_PickTeam(clientNum) == TEAM_RED) {
team = "red";
@ -720,8 +743,8 @@ Svcmd_AddBot_f
===============
*/
void Svcmd_AddBot_f( void ) {
int skill;
int delay;
int32_t skill = 0;
int32_t delay = 0;
char name[MAX_TOKEN_CHARS];
char altname[MAX_TOKEN_CHARS];
char string[MAX_TOKEN_CHARS];
@ -729,23 +752,28 @@ void Svcmd_AddBot_f( void ) {
char pclass[MAX_TOKEN_CHARS];
// are bots enabled?
if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
if ( trap_Cvar_VariableIntegerValue( "bot_enable" ) == 0 ) {
return;
}
memset(name, 0, sizeof(name));
memset(altname, 0, sizeof(altname));
memset(string, 0, sizeof(string));
memset(team, 0, sizeof(team));
memset(pclass, 0, sizeof(pclass));
// name
trap_Argv( 1, name, sizeof( name ) );
if ( !name[0] ) {
if ( name[0] == 0 ) {
trap_Printf( "Usage: Addbot <botname> [skill 1-4] [team] [class] [msec delay] [altname]\n" );
return;
}
// skill
trap_Argv( 2, string, sizeof( string ) );
if ( !string[0] ) {
if ( string[0] == 0 ) {
skill = 4;
}
else {
} else {
skill = atoi( string );
}
@ -757,10 +785,9 @@ void Svcmd_AddBot_f( void ) {
// delay
trap_Argv( 5, string, sizeof( string ) );
if ( !string[0] ) {
if ( string[0] == 0 ) {
delay = 0;
}
else {
} else {
delay = atoi( string );
}
@ -771,7 +798,7 @@ void Svcmd_AddBot_f( void ) {
// if this was issued during gameplay and we are playing locally,
// go ahead and load the bot's media immediately
if ( level.time - level.startTime > 1000 &&
if ( (level.time - level.startTime > 1000) &&
trap_Cvar_VariableIntegerValue( "cl_running" ) ) {
trap_SendServerCommand( -1, "loaddeferred\n" ); // FIXME: spelled wrong, but not changing for demo
}
@ -783,11 +810,16 @@ Svcmd_BotList_f
===============
*/
void Svcmd_BotList_f( void ) {
int i;
char name[MAX_TOKEN_CHARS];
char funname[MAX_TOKEN_CHARS];
char model[MAX_TOKEN_CHARS];
char aifile[MAX_TOKEN_CHARS];
int32_t i = 0;
char name[MAX_TOKEN_CHARS];
char funname[MAX_TOKEN_CHARS];
char model[MAX_TOKEN_CHARS];
char aifile[MAX_TOKEN_CHARS];
memset(name, 0, sizeof(name));
memset(funname, 0, sizeof(funname));
memset(model, 0, sizeof(model));
memset(aifile, 0, sizeof(aifile));
trap_Printf("^1name model aifile funname\n");
for (i = 0; i < g_numBots; i++) {
@ -817,16 +849,17 @@ void Svcmd_BotList_f( void ) {
G_SpawnBots
===============
*/
static void G_SpawnBots( char *botList, int baseDelay ) {
char *bot;
char *p;
int skill;
int delay;
static void G_SpawnBots( char* botList, int32_t baseDelay ) {
char* bot;
char* p;
int32_t skill = 0;
int32_t delay = 0;
char bots[MAX_INFO_VALUE];
podium1 = NULL;
podium2 = NULL;
podium3 = NULL;
memset(bots, 0, sizeof(bots));
skill = trap_Cvar_VariableIntegerValue( "g_spSkill" );
if( skill < 1 || skill > 5 ) {
@ -834,7 +867,7 @@ static void G_SpawnBots( char *botList, int baseDelay ) {
skill = 2;
}
Q_strncpyz( bots, botList, sizeof(bots) );
strncpy(bots, botList, sizeof(bots));
p = &bots[0];
delay = baseDelay;
while( *p ) {
@ -871,13 +904,13 @@ static void G_SpawnBots( char *botList, int baseDelay ) {
G_LoadBotsFromFile
===============
*/
static void G_LoadBotsFromFile( char *filename ) {
int len;
fileHandle_t f;
static void G_LoadBotsFromFile( char* filename ) {
int32_t len = 0;
fileHandle_t f = 0;
char buf[MAX_BOTS_TEXT];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( !f ) {
if ( f == 0 ) {
trap_Printf( va( S_COLOR_RED "file not found: %s\n", filename ) );
return;
}
@ -887,6 +920,7 @@ static void G_LoadBotsFromFile( char *filename ) {
return;
}
memset(buf, 0, sizeof(buf));
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
@ -902,17 +936,19 @@ G_LoadBots
*/
static void G_LoadBots( void ) {
vmCvar_t botsFile;
int numdirs;
int32_t numdirs = 0;
char filename[128];
char dirlist[4096];
char* dirptr;
int i;
int dirlen;
char* dirptr = NULL;
int32_t i = 0;
int32_t dirlen = 0;
if ( !trap_Cvar_VariableIntegerValue( "bot_enable" ) ) {
if ( trap_Cvar_VariableIntegerValue( "bot_enable" ) == 0 ) {
return;
}
memset(filename, 0, sizeof(filename));
memset(dirlist, 0, sizeof(dirlist));
g_numBots = 0;
trap_Cvar_Register( &botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM );
@ -943,7 +979,7 @@ static void G_LoadBots( void ) {
G_GetBotInfoByNumber
===============
*/
char *G_GetBotInfoByNumber( int num ) {
char* G_GetBotInfoByNumber( int32_t num ) {
if( num < 0 || num >= g_numBots ) {
trap_Printf( va( S_COLOR_RED "Invalid bot number: %i\n", num ) );
return NULL;
@ -957,13 +993,13 @@ char *G_GetBotInfoByNumber( int num ) {
G_GetBotInfoByName
===============
*/
char *G_GetBotInfoByName( const char *name ) {
int n;
char *value;
char* G_GetBotInfoByName( const char* name ) {
int32_t n = 0;
char* value = NULL;
for ( n = 0; n < g_numBots ; n++ ) {
value = Info_ValueForKey( g_botInfos[n], "name" );
if ( !Q_stricmp( value, name ) ) {
if ( Q_stricmp( value, name ) == 0 ) {
return g_botInfos[n];
}
}
@ -972,14 +1008,17 @@ char *G_GetBotInfoByName( const char *name ) {
}
void G_InitBots( qboolean restart ) {
int fragLimit;
int timeLimit;
const char *arenainfo;
char *strValue;
int basedelay;
int32_t fragLimit = 0;
int32_t timeLimit = 0;
const char* arenainfo = NULL;
char* strValue = NULL;
int32_t basedelay = 0;
char map[MAX_QPATH];
char serverinfo[MAX_INFO_STRING];
memset(map, 0, sizeof(map));
memset(serverinfo, 0, sizeof(serverinfo));
G_LoadBots();
G_LoadArenas();
@ -989,39 +1028,35 @@ void G_InitBots( qboolean restart ) {
trap_GetServerinfo( serverinfo, sizeof(serverinfo) );
Q_strncpyz( map, Info_ValueForKey( serverinfo, "mapname" ), sizeof(map) );
arenainfo = G_GetArenaInfoByMap( map );
if ( !arenainfo ) {
if ( arenainfo == NULL ) {
return;
}
strValue = Info_ValueForKey( arenainfo, "fraglimit" );
fragLimit = atoi( strValue );
if ( fragLimit ) {
if ( fragLimit != 0 ) {
trap_Cvar_Set( "fraglimit", strValue );
}
else {
} else {
trap_Cvar_Set( "fraglimit", "0" );
}
strValue = Info_ValueForKey( arenainfo, "timelimit" );
timeLimit = atoi( strValue );
if ( timeLimit ) {
if ( timeLimit != 0 ) {
trap_Cvar_Set( "timelimit", strValue );
}
else {
} else {
trap_Cvar_Set( "timelimit", "0" );
}
if ( !fragLimit && !timeLimit ) {
if ( fragLimit == 0 && timeLimit == 0 ) {
trap_Cvar_Set( "fraglimit", "10" );
trap_Cvar_Set( "timelimit", "0" );
}
if (g_holoIntro.integer)
if (g_holoIntro.integer != 0)
{ // The player will be looking at the holodeck doors for the first five seconds, so take that into account.
basedelay = BOT_BEGIN_DELAY_BASE + TIME_INTRO;
}
else
{
} else {
basedelay = BOT_BEGIN_DELAY_BASE;
}
strValue = Info_ValueForKey( arenainfo, "special" );

View file

@ -7,15 +7,17 @@
* Removes entity entirely blow chunks.
* If it is repairable it's not removed but made invisible.
*/
void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath )
void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int32_t damage, int32_t meansOfDeath )
{
vec3_t size, org, dir;
gentity_t *te = NULL;
entityState_t *eState = &self->s;
entityShared_t *eShared = &self->r;
vec3_t size;
vec3_t org;
vec3_t dir;
gentity_t* te = NULL;
entityState_t* eState = &self->s;
entityShared_t* eShared = &self->r;
//RPG-X | GSIO01 | 09/05/2009:
if(!(self->spawnflags & 256)) {
if((self->spawnflags & 256) == 0) {
eState->frame = 0;
self->health = 0;
}
@ -26,30 +28,27 @@ void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker,
self->takedamage = qfalse;
if( self->target )
if( self->target != NULL )
{
G_UseTargets(self, attacker);
}
if ( !(self->spawnflags & 4) )
{//We don't want to stay solid
if ((self->spawnflags & 4) == 0) {
//We don't want to stay solid
eState->solid = 0;
eShared->contents = 0;
self->clipmask = 0;
if(self->spawnflags & 256 && !strcmp(self->classname, "func_breakable")) {
if(((self->spawnflags & 256) != 0) && (strcmp(self->classname, "func_breakable") == 0)) {
eShared->svFlags |= SVF_NOCLIENT;
eState->eFlags |= EF_NODRAW;
}
trap_LinkEntity(self);
}
if ( eShared->bmodel )
{
if ( eShared->bmodel ) {
VectorSubtract( eShared->absmax, eShared->absmin, size );
VectorMA( eShared->absmin, 0.5, size, org );
}
else
{
} else {
VectorSubtract( eShared->maxs, eShared->mins, size );
VectorCopy( eShared->currentOrigin, org );
}
@ -61,8 +60,7 @@ void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker,
te->s.powerups = eState->powerups;
// Ok, we are allowed to explode, so do it now!
if ( self->splashDamage > 0 && self->splashRadius > 0 )
{
if ( (self->splashDamage > 0) && (self->splashRadius > 0) ) {
//fixme: what about chain reactions?
G_RadiusDamage( org, attacker, self->splashDamage, self->splashRadius, self, DAMAGE_RADIUS|DAMAGE_ALL_TEAMS, MOD_EXPLOSION );
@ -73,39 +71,34 @@ void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker,
te->s.weapon = WP_8;
}
if ( eShared->bmodel )
{
if ( eShared->bmodel ) {
trap_AdjustAreaPortalState( self, qtrue );
}
else if ( eState->modelindex2 != -1 && !(self->spawnflags & 8) )
{
} else if ( (eState->modelindex2 != -1) && ((self->spawnflags & 8) == 0) ) {
eState->modelindex = self->s.modelindex2;
return;
}
if(!(self->spawnflags & 256))
if((self->spawnflags & 256) == 0) {
G_FreeEntity( self );
if(self->spawnflags & 256)
} else {
self->count = 0;
}
}
/**
* Called when a breakable takes damage
*/
void breakable_pain ( gentity_t *self, gentity_t *attacker, int damage )
void breakable_pain ( gentity_t *self, gentity_t *attacker, int32_t damage )
{
if ( self->pain_debounce_time > level.time )
{
if ( self->pain_debounce_time > level.time ) {
return;
}
if ( self->paintarget )
{
if ( self->paintarget ) {
G_UseTargets2 ( self, self->activator, self->paintarget );
}
if(self->wait == -1)
{
if(self->wait <= -1.0f) {
self->pain = 0;
return;
}
@ -126,10 +119,11 @@ void breakable_use (gentity_t *self, gentity_t *other, gentity_t *activator)
*/
void InitBBrush ( gentity_t *ent )
{
float light;
vec3_t color;
qboolean lightSet, colorSet;
entityState_t *eState = &ent->s;
double light = 0.0f;
vec3_t color;
qboolean lightSet;
qboolean colorSet;
entityState_t* eState = &ent->s;
VectorCopy( eState->origin, ent->pos1 );
@ -139,8 +133,7 @@ void InitBBrush ( gentity_t *ent )
// if the "model2" key is set, use a seperate model
// for drawing, but clip against the brushes
if ( ent->model2 )
{
if ( ent->model2 != NULL ) {
eState->modelindex2 = G_ModelIndex( ent->model2 );
}
@ -196,10 +189,12 @@ void Touch_breakable_trigger(gentity_t *ent, gentity_t *other, trace_t *trace) {
* Only gets called if the breakable is repairable.
*/
void breakable_spawn_trigger(gentity_t *ent) {
vec3_t maxs, mins;
gentity_t *other;
int best, i;
entityShared_t *eShared;
vec3_t maxs;
vec3_t mins;
gentity_t* other = NULL;
int32_t best = 0;
int32_t i = 1;
entityShared_t* eShared = NULL;
VectorCopy(ent->r.absmin, mins);
VectorCopy(ent->r.absmax, maxs);
@ -212,7 +207,7 @@ void breakable_spawn_trigger(gentity_t *ent) {
best = 0;
for(i = 1; i < 3; i++) {
for( ; i < 3; i++) {
if(maxs[i] - mins[i] < maxs[best] - mins[best])
best = i;
}
@ -221,8 +216,7 @@ void breakable_spawn_trigger(gentity_t *ent) {
mins[best] -= 48;
other = G_Spawn();
if(!other) {
if(other == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] Unable to spawn trigger for func_breakable at %s!\n", vtos(ent->s.origin)););
G_FreeEntity(ent);
return;
@ -321,16 +315,13 @@ In the unlikely event that we do have an origin brush this is the code:
*/
void SP_func_breakable( gentity_t *self )
{
if(!(self->spawnflags & 1))
{
if(!self->health)
{
if((self->spawnflags & 1) == 0) {
if(self->health == 0) {
self->health = 10;
}
}
if (self->health)
{
if (self->health != 0) {
self->takedamage = qtrue; //RPG-X - TiM: qtrue
}
@ -341,12 +332,11 @@ void SP_func_breakable( gentity_t *self )
self->use = breakable_use;
self->count = 1; // GSIO01
if ( self->paintarget )
{
if ( self->paintarget != NULL ) {
self->pain = breakable_pain;
}
if (!self->model) {
if (self->model == NULL) {
G_Error("func_breakable with NULL model\n");
}
VectorCopy(self->s.origin, self->pos1);
@ -431,20 +421,19 @@ custom explosion effect/sound?
*/
void SP_misc_model_breakable( gentity_t *ent )
{
char damageModel[MAX_QPATH];
int len;
entityShared_t *eShared = &ent->r;
entityState_t *eState = &ent->s;
char damageModel[MAX_QPATH];
int32_t len = 0;
entityShared_t* eShared = &ent->r;
entityState_t* eState = &ent->s;
//Main model
eState->modelindex = ent->sound2to1 = G_ModelIndex( ent->model );
if ( ent->spawnflags & 1 )
{//Blocks movement
if ( (ent->spawnflags & 1) != 0 ) {
//Blocks movement
eShared->contents = CONTENTS_BODY; //Was CONTENTS_SOLID, but only architecture should be this
}
else if ( ent->health )
{//Can only be shot
} else if ( ent->health != 0 ) {
//Can only be shot
eShared->contents = CONTENTS_SHOTCLIP;
}
@ -452,8 +441,7 @@ void SP_misc_model_breakable( gentity_t *ent )
ent->use = breakable_use;
if ( ent->health )
{
if ( ent->health != 0 ) {
G_SoundIndex("sound/weapons/explosions/cargoexplode.wav");
ent->takedamage = qtrue;
ent->pain = breakable_pain;
@ -461,7 +449,7 @@ void SP_misc_model_breakable( gentity_t *ent )
}
if(!ent->model2) {
if(ent->model2 == NULL) {
len = strlen( ent->model ) - 4;
strncpy( damageModel, ent->model, len );
damageModel[len] = 0; //chop extension
@ -469,8 +457,8 @@ void SP_misc_model_breakable( gentity_t *ent )
if (ent->takedamage) {
//Dead/damaged model
if( !(ent->spawnflags & 8) ) { //no dmodel
if(ent->model2) {
if( (ent->spawnflags & 8) == 0 ) { //no dmodel
if(ent->model2 != NULL) {
eState->modelindex2 = G_ModelIndex( ent->model2 );
} else {
strcat( damageModel, "_d1.md3" );
@ -510,14 +498,13 @@ void SP_misc_model_breakable( gentity_t *ent )
void ammo_use( gentity_t *self, gentity_t *other, gentity_t *activator);
//!give a player ammo for a weapon
static int Add_Ammo2 (gentity_t *ent, int weapon, int count)
static int32_t Add_Ammo2 (gentity_t *ent, int32_t weapon, int32_t count)
{
playerState_t *ps = &ent->client->ps;
ps->ammo[weapon] += count;
if ( ps->ammo[weapon] > Max_Weapon(weapon) )
{
if ( ps->ammo[weapon] > Max_Weapon(weapon) ) {
ps->ammo[weapon] = Max_Weapon(weapon);
return qfalse;
}
@ -527,7 +514,7 @@ static int Add_Ammo2 (gentity_t *ent, int weapon, int count)
//!Shuts down a ammo station
void ammo_shutdown( gentity_t *self )
{
if (!(self->s.eFlags & EF_ANIM_ONCE))
if ((self->s.eFlags & EF_ANIM_ONCE) == 0)
{
self->s.eFlags &= ~ EF_ANIM_ALLFAST;
self->s.eFlags |= EF_ANIM_ONCE;
@ -549,8 +536,8 @@ void ammo_fade_out( gentity_t *ent )
//! Think function for the ammo station
void ammo_think( gentity_t *ent )
{
int dif = 0;
int i;
int32_t dif = 0;
int32_t i = 0;
// Still has ammo to give
if ( ent->enemy && ent->enemy->client )
@ -559,41 +546,34 @@ void ammo_think( gentity_t *ent )
ent->use = ammo_use;
ent->think = 0;//qvm complains about using NULL
ent->nextthink = -1;
for ( i = 0; i < WP_NUM_WEAPONS && ent->count > 0; i++ )
{//go through all weapons
if ( (ent->enemy->client->ps.stats[STAT_WEAPONS]&( 1 << i )) )
{//has this weapon
for ( ; i < WP_NUM_WEAPONS && ent->count > 0; i++ ) {
//go through all weapons
if ( (ent->enemy->client->ps.stats[STAT_WEAPONS]&( 1 << i )) ) {
//has this weapon
dif = Max_Weapon(i) - ent->enemy->client->ps.ammo[i];//needs ammo?
if (dif > 2 )
{
if (dif > 2 ) {
dif= 2;
}
else if (dif < 0)
{
} else if (dif < 0) {
dif= 0;
}
if (ent->count < dif) // Can't give more than count
{
if (ent->count < dif) {
// Can't give more than count
dif = ent->count;
}
// Give player ammo
if (Add_Ammo2(ent->enemy,i,dif) && (dif!=0))
{
if (Add_Ammo2(ent->enemy,i,dif) && (dif!=0)) {
ent->count-=dif;
if ( ent->splashDamage )
{
if ( ent->splashDamage != 0 ) {
ent->splashDamage = floor((float)ent->count/10);
}
ent->use = 0; /*NULL*/
ent->think = ammo_think;
ent->nextthink = level.time + 10;
}
else // User has taken all ammo he can hold
{
}
}
}
}
@ -610,52 +590,44 @@ void ammo_think( gentity_t *ent )
//! use function for a ammo station
void ammo_use( gentity_t *self, gentity_t *other, gentity_t *activator)
{
int dif = 0;
int i;
int32_t dif = 0;
int32_t i = 0;
if (self->think != NULL)
{
if (self->use != NULL)
{
if (self->think != NULL) {
if (self->use != NULL) {
self->think = 0; /*NULL*/
self->nextthink = -1;
}
}
else
{
if ( other && other->client )
{
for ( i = 0; i < WP_NUM_WEAPONS && dif == 0; i++ )
{//go through all weapons
if ( (other->client->ps.stats[STAT_WEAPONS]&( 1 << i )) )
{//has this weapon
} else {
if ( other && other->client ) {
for ( ; i < WP_NUM_WEAPONS && dif == 0; i++ ) {
//go through all weapons
if ( (other->client->ps.stats[STAT_WEAPONS]&( 1 << i )) ) {
//has this weapon
dif = Max_Weapon(i) - other->client->ps.ammo[i];//needs ammo?
}
}
}
else
{ // Being triggered to be used up
} else {
// Being triggered to be used up
dif = 1;
self->count = 0;
}
// Does player already have full ammo?
if ( dif > 0 )
{
if ( dif > 0 ) {
G_Sound(self, G_SoundIndex("sound/player/suitenergy.wav") );
if ((dif >= self->count) || (self->count<1)) // use it all up?
{
if ((dif >= self->count) || (self->count<1)) {
// use it all up?
ammo_shutdown(self);
}
}
else
{
} else {
G_Sound(self, G_SoundIndex("sound/weapons/noammo.wav") );
}
// Use target when used
if (self->spawnflags & 8)
{
if ((self->spawnflags & 8) != 0) {
G_UseTargets( self, activator );
}
@ -699,24 +671,19 @@ none
*/
void SP_misc_ammo_station( gentity_t *ent )
{
if (!ent->health)
{
if (ent->health == 0) {
ent->health = 60;
}
if ( !ent->count )
{
if ( ent->count == 0 ) {
ent->count = 1000;
}
ent->s.powerups = 3;//material
if ( ent->team && atoi(ent->team) == 1 )
{
if ( ent->team != NULL && atoi(ent->team) == 1 ) {
ent->s.modelindex = G_ModelIndex( "models/mapobjects/dn/powercell2.md3" );
}
else
{
} else {
ent->s.modelindex = G_ModelIndex( "models/mapobjects/dn/powercell.md3" );
}
ent->r.contents = CONTENTS_CORPSE;
@ -725,8 +692,7 @@ void SP_misc_ammo_station( gentity_t *ent )
ent->use = ammo_use;
G_SoundIndex( "sound/player/suitenergy.wav" );
if ( ent->health )
{
if ( ent->health != 0 ) {
ent->takedamage = qtrue;
ent->pain = breakable_pain;
ent->die = breakable_die;
@ -761,11 +727,13 @@ none
* if it is damaged.
*/
void target_repair_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
gentity_t *target;
gentity_t* target = ent->lastEnemy;
target = ent->lastEnemy;
if(target == NULL) {
return;
}
if(!(target->spawnflags & 256)) {
if((target->spawnflags & 256) == 0) {
return;
}
@ -781,8 +749,9 @@ void target_repair_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
target->takedamage = qtrue;
target->use = breakable_use;
if(target->paintarget)
if(target->paintarget != NULL) {
target->pain = breakable_pain;
}
target->clipmask = 0;
target->count = 1;
@ -792,14 +761,14 @@ void target_repair_use(gentity_t *ent, gentity_t *other, gentity_t *activator) {
* Link function finishes off spawning of the entity.
*/
void target_repair_link(gentity_t *ent) {
gentity_t *target;
gentity_t *target = NULL;
ent->nextthink = -1;
target = G_Find(NULL, FOFS(targetname), ent->target);
if(!target) {
if(target == NULL) {
target = G_Find(NULL, FOFS(targetname2), ent->target);
if(!target) {
if(target == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_repair at %s with an unfound target: %s\n", vtos(ent->s.origin), ent->target););
return;
}
@ -807,7 +776,7 @@ void target_repair_link(gentity_t *ent) {
ent->lastEnemy = target;
if(Q_stricmp(target->classname, "func_breakable")) {
if(Q_stricmp(target->classname, "func_breakable") != 0) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_repair at %s with an invalid target entity %s\n", vtos(ent->s.origin), target->classname););
return;
}
@ -819,7 +788,7 @@ void target_repair_link(gentity_t *ent) {
* Spawn function of target_repair entity
*/
void SP_target_repair(gentity_t *ent) {
if(!ent->target) {
if(ent->target == NULL) {
DEVELOPER(G_Printf(S_COLOR_YELLOW "[Entity-Error] target_repair without target at %s\n", vtos(ent->s.origin)););
return;
}

View file

@ -1,5 +1,4 @@
void breakable_use(gentity_t *self, gentity_t *other, gentity_t *activator);
void breakable_pain( gentity_t *self, gentity_t *attacker, int damage );
void breakable_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath );
void breakable_pain( gentity_t *self, gentity_t *attacker, int32_t damage );
//static void InitBBrush ( gentity_t *ent );

View file

@ -1,5 +1,6 @@
#include "g_local.h"
#include "g_cinematic.h"
#include "g_client.h"
extern void InitMover( gentity_t *ent );

View file

@ -1,5 +1,6 @@
// Copyright (C) 1999-2000 Id Software, Inc.
//
#include "g_client.h"
#include "g_local.h"
#include "g_groups.h"
#include "g_main.h"
@ -7,15 +8,7 @@
#include "g_main.h"
reconData_t g_reconData[MAX_RECON_NAMES]; //!< recon data for a limited ammount of clients
int g_reconNum;
extern char* BG_RegisterRace( const char *name );
extern void SetPlayerClassCvar(gentity_t *ent);
extern void BroadcastClassChange( gclient_t *client, pclass_t oldPClass );
//RPG-X: TiM
extern char* correlateRanks( const char* strArg, int intArg );
extern pclass_t ValueNameForClass ( /*gentity_t *ent,*/ char* s );
int32_t g_reconNum;
// g_client.c -- client functions that don't happen every frame
@ -33,17 +26,15 @@ clInitStatus_t clientInitialStatus[MAX_CLIENTS];
* Function that makes transport setup easier
* \author Ubergames - TiM
*/
void G_InitTransport( int clientNum, vec3_t origin, vec3_t angles ) {
gentity_t *tent;
void G_InitTransport( int32_t clientNum, vec3_t origin, vec3_t angles ) {
gentity_t* tent = NULL;
TransDat[clientNum].beamTime = level.time + 8000;
g_entities[clientNum].client->ps.powerups[PW_BEAM_OUT] = level.time + 8000;
//Transfer stored data to active beamer
VectorCopy( origin,
TransDat[clientNum].currentCoord.origin );
VectorCopy( angles,
TransDat[clientNum].currentCoord.angles );
VectorCopy( origin, TransDat[clientNum].currentCoord.origin );
VectorCopy( angles, TransDat[clientNum].currentCoord.angles );
tent = G_TempEntity( g_entities[clientNum].client->ps.origin, EV_PLAYER_TRANSPORT_OUT );
tent->s.clientNum = clientNum;
@ -65,18 +56,18 @@ potential spawning position for deathmatch games.
* Spawn function for deathmatch spawnpoint
*/
void SP_info_player_deathmatch( gentity_t *ent ) {
int i;
int32_t i = 0;
if(strcmp(ent->classname, "info_player_deathmatch")) {
if(strcmp(ent->classname, "info_player_deathmatch") != 0) {
ent->classname = G_NewString("info_player_deathmatch");
}
G_SpawnInt( "nobots", "0", &i);
if ( i ) {
if ( i != 0 ) {
ent->flags |= FL_NO_BOTS;
}
G_SpawnInt( "nohumans", "0", &i );
if ( i ) {
if ( i != 0 ) {
ent->flags |= FL_NO_HUMANS;
}
@ -98,40 +89,29 @@ none
/**
* Spawn function for intermission entity.
*/
void SP_info_player_intermission( gentity_t *ent ) {
void SP_info_player_intermission( gentity_t *ent ) { }
}
/*
=======================================================================
G_Client_SelectSpawnPoint
=======================================================================
*/
/*
================
G_Client_SpotWouldTelefrag
================
*/
/**
* Check if beaming to a point will result in a teleporter frag.
*/
qboolean G_Client_SpotWouldTelefrag( gentity_t *spot ) {
int i, num;
* Determine whether spot would telefrag.
*
* \param spot Spot to check.
* \return Whether this spot would telefrag.
*/
static qboolean G_Client_SpotWouldTelefrag( gentity_t *spot ) {
int32_t i = 0;
int32_t num = 0;
int touch[MAX_GENTITIES];
gentity_t *hit;
vec3_t mins, maxs;
gentity_t* hit = NULL;
vec3_t mins;
vec3_t maxs;
memset(touch, 0, sizeof(touch));
VectorAdd( spot->s.origin, playerMins, mins );
VectorAdd( spot->s.origin, playerMaxs, maxs );
num = trap_EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
for (i=0 ; i<num ; i++) {
for ( ; i<num ; i++) {
hit = &g_entities[touch[i]];
if ( hit && hit->client && hit->client->ps.stats[STAT_HEALTH] > 0 ) {
return qtrue;
@ -157,15 +137,12 @@ Find the spot that we DON'T want to use
/**
* Find the spot that we DON'T want to use
*/
static gentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from ) {
gentity_t *spot;
static gentity_t* SelectNearestDeathmatchSpawnPoint( vec3_t from ) {
gentity_t* spot = NULL;
vec3_t delta;
float dist, nearestDist;
gentity_t *nearestSpot;
nearestDist = 999999;
nearestSpot = NULL;
spot = NULL;
double dist = 0.0;
double nearestDist = 999999.0;
gentity_t* nearestSpot = NULL;
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
@ -192,14 +169,13 @@ go to a random point that doesn't telefrag
/**
* go to a random point that doesn't telefrag
*/
static gentity_t *SelectRandomDeathmatchSpawnPoint( void ) {
gentity_t *spot;
int count;
int selection;
gentity_t *spots[MAX_SPAWN_POINTS];
static gentity_t* SelectRandomDeathmatchSpawnPoint( void ) {
gentity_t* spot = NULL;
int32_t count = 0;
int32_t selection = 0;
gentity_t* spots[MAX_SPAWN_POINTS];
count = 0;
spot = NULL;
memset(spots, 0, sizeof(spots));
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
if ( G_Client_SpotWouldTelefrag( spot ) ) {
@ -209,7 +185,7 @@ static gentity_t *SelectRandomDeathmatchSpawnPoint( void ) {
count++;
}
if ( !count ) { // no spots that won't telefrag
if ( count == 0 ) { // no spots that won't telefrag
return G_Find( NULL, FOFS(classname), "info_player_deathmatch");
}
@ -218,21 +194,9 @@ static gentity_t *SelectRandomDeathmatchSpawnPoint( void ) {
}
/*
===========
G_Client_SelectSpawnPoint
Chooses a player start, deathmatch start, etc
============
*/
/**
* Chooses a player start, deathmatch start, etc
*/
gentity_t* G_Client_SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles ) {
gentity_t *spot;
gentity_t *nearestSpot;
nearestSpot = SelectNearestDeathmatchSpawnPoint( avoidPoint );
gentity_t* spot = NULL;
gentity_t* nearestSpot = SelectNearestDeathmatchSpawnPoint( avoidPoint );
spot = SelectRandomDeathmatchSpawnPoint ( );
if ( spot == nearestSpot ) {
@ -245,7 +209,7 @@ gentity_t* G_Client_SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t
}
// find a single player start spot
if (!spot) {
if (spot == NULL) {
G_Error( "Couldn't find a spawn point" );
return spot;
}
@ -269,8 +233,8 @@ use normal spawn selection.
* Try to find a spawn point marked 'initial', otherwise
* use normal spawn selection.
*/
static gentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles ) {
gentity_t *spot;
static gentity_t* SelectInitialSpawnPoint( vec3_t origin, vec3_t angles ) {
gentity_t* spot = NULL;
spot = NULL;
while ((spot = G_Find (spot, FOFS(classname), "info_player_deathmatch")) != NULL) {
@ -279,7 +243,7 @@ static gentity_t *SelectInitialSpawnPoint( vec3_t origin, vec3_t angles ) {
}
}
if ( !spot || G_Client_SpotWouldTelefrag( spot ) ) {
if ( spot == NULL || G_Client_SpotWouldTelefrag( spot ) ) {
return G_Client_SelectSpawnPoint( vec3_origin, origin, angles );
}
@ -296,7 +260,7 @@ SelectSpectatorSpawnPoint
============
*/
static gentity_t *SelectSpectatorSpawnPoint( vec3_t origin, vec3_t angles ) {
static gentity_t* SelectSpectatorSpawnPoint( vec3_t origin, vec3_t angles ) {
FindIntermissionPoint();
VectorCopy( level.intermission_origin, origin );
@ -313,7 +277,7 @@ BODYQUE
=======================================================================
*/
static int bodyFadeSound=0;
static int32_t bodyFadeSound=0;
/*
@ -322,12 +286,18 @@ G_Client_InitBodyQue
===============
*/
void G_Client_InitBodyQue (void) {
int i;
gentity_t *ent;
int32_t i = 0;
gentity_t* ent = NULL;
level.bodyQueIndex = 0;
for (i=0; i<BODY_QUEUE_SIZE ; i++) {
for ( ; i<BODY_QUEUE_SIZE ; i++) {
ent = G_Spawn();
if(ent == NULL) {
// TODO print error?
return;
}
ent->classname = "bodyque";
ent->neverFree = qtrue;
level.bodyQue[i] = ent;
@ -349,8 +319,7 @@ After sitting around for five seconds, fade out.
/**
* After sitting around for five seconds, fade out.
*/
void BodyRezOut( gentity_t *ent )
{
static void BodyRezOut( gentity_t *ent ) {
if ( level.time - ent->timestamp >= 7500 ) {
// the body ques are never actually freed, they are just unlinked
trap_UnlinkEntity( ent );
@ -377,15 +346,15 @@ just like the existing corpse to leave behind.
* just like the existing corpse to leave behind.
*/
static void CopyToBodyQue( gentity_t *ent ) {
gentity_t *body;
int contents;
entityState_t *eState;
gentity_t* body = NULL;
int32_t contents = 0;
entityState_t* eState = NULL;
trap_UnlinkEntity (ent);
// if client is in a nodrop area, don't leave the body
contents = trap_PointContents( ent->s.origin, -1 );
if ( contents & CONTENTS_NODROP ) {
if ( (contents & CONTENTS_NODROP) != 0 ) {
ent->s.eFlags &= ~EF_NODRAW; // Just in case we died from a bottomless pit, reset EF_NODRAW
return;
}
@ -445,7 +414,7 @@ static void CopyToBodyQue( gentity_t *ent ) {
body->die = body_die;
// if there shouldn't be a body, don't show one.
if (ent->client &&
if (ent->client != NULL &&
((level.time - ent->client->ps.powerups[PW_DISINTEGRATE]) < 10000 ||
(level.time - ent->client->ps.powerups[PW_EXPLODE]) < 10000))
{
@ -460,7 +429,7 @@ static void CopyToBodyQue( gentity_t *ent ) {
} else {
body->takedamage = qtrue;
}
}else{
} else {
body->takedamage = qfalse;
}
@ -498,9 +467,9 @@ G_Client_Respawn
*/
extern char *ClassNameForValue( pclass_t pClass );
void G_Client_Respawn( gentity_t *ent ) {
qboolean borg = qfalse;
gentity_t *tent;
playerState_t *ps;
qboolean borg = qfalse;
gentity_t* tent = NULL;
playerState_t* ps = NULL;
CopyToBodyQue (ent);
@ -509,10 +478,9 @@ void G_Client_Respawn( gentity_t *ent ) {
ps = &ent->client->ps;
// add a teleportation effect
if ( borg )
if ( borg ) {
tent = G_TempEntity( ps->origin, EV_BORG_TELEPORT );
else
{
} else {
tent = G_TempEntity( ps->origin, EV_PLAYER_TRANSPORT_IN );
ps->powerups[PW_QUAD] = level.time + 4000;
}
@ -520,7 +488,14 @@ void G_Client_Respawn( gentity_t *ent ) {
tent->s.clientNum = ent->s.clientNum;
}
team_t G_Client_TeamCount( int ignoreClientNum, int team ) {
/**
* Get number of clients in team.
*
* \param ignoreClientNum Client to ignore.
* \param team Team.
* \reutrn Number of clients in team.
*/
static team_t G_Client_TeamCount( int ignoreClientNum, int team ) {
int i;
int count = 0;
@ -575,38 +550,34 @@ Player Model system :P
* HEAVILY modified for the RPG-X
* Player Model system
*/
static void ForceClientSkin(char *model, const char *skin ) {
char *p;
char *q;
static void ForceClientSkin(char* model, const char* skin ) {
char* p = NULL;
char* q = NULL;
//we expect model to equal 'char/model/skin'
p = strchr(model, '/');
//if no slashes at all
if ( !p || !p[0] || !p[1] ) {
if ( p == NULL || p[0] == 0 || p[1] == 0 ) {
//input everything
Q_strcat(model, MAX_QPATH, "/");
Q_strcat(model, MAX_QPATH, "main");
Q_strcat(model, MAX_QPATH, "/");
Q_strcat(model, MAX_QPATH, skin);
}
else { //ie we got a slash (which should be the first of two
strncat(model, "/", MAX_QPATH);
strncat(model, "main", MAX_QPATH);
strncat(model, "/", MAX_QPATH);
strncat(model, skin, MAX_QPATH);
} else { //ie we got a slash (which should be the first of two
p++;
q = strchr(p, '/'); //okay, we should get another one if one was already found
if (!q || !q[0] || !q[1] )
if (q == NULL || q[0] == 0 || q[1] == 0 )
{ //no slashes were found?? >.<
//okay, let's assume they specified the .model file, no skin
//so just add the skin to the end :P
Q_strcat(model, MAX_QPATH, "/");
Q_strcat(model, MAX_QPATH, skin);
}
else
{
strncat(model, "/", MAX_QPATH);
strncat(model, skin, MAX_QPATH);
} else {
q++;
*q= '\0';
Q_strcat(model, MAX_QPATH, skin);
strncat(model, skin, MAX_QPATH);
}
}
}
@ -616,24 +587,23 @@ static void ForceClientSkin(char *model, const char *skin ) {
ClientCheckName
============
*/
void ClientCleanName( const char *in, char *out, int outSize ) {
int len, colorlessLen;
char ch;
char *p;
int spaces;
static void ClientCleanName( const char* in, char* out, int outSize ) {
int32_t len = 0;
int32_t colorlessLen = 0;
char ch = 0;
char* p = NULL;
int32_t spaces = 0;
//save room for trailing null byte
outSize--;
len = 0;
colorlessLen = 0;
p = out;
*p = 0;
spaces = 0;
while( 1 ) {
ch = *in++;
if( !ch ) {
if( ch == 0 ) {
break;
}
@ -706,12 +676,12 @@ Used to decide if in a CTF game where a race is specified for a given team if a
* Compare a list of races with an incoming race name.
* Used to decide if in a CTF game where a race is specified for a given team if a skin is actually already legal.
*/
static qboolean legalSkin(const char *race_list, const char *race)
static qboolean legalSkin(const char*race_list, const char* race)
{
char current_race_name[125];
const char *s = race_list;
const char *max_place = race_list + strlen(race_list);
const char *marker;
const char *marker = NULL;
memset(current_race_name, 0, sizeof(current_race_name));
// look through the list till it's empty
@ -725,13 +695,13 @@ static qboolean legalSkin(const char *race_list, const char *race)
}
// copy just that name
Q_strncpyz(current_race_name, marker, (s-marker)+1);
strncpy(current_race_name, marker, (s-marker)+1);
// avoid the comma or increment us past the end of the string so we fail the main while loop
s++;
// compare and see if this race is the same as the one we want
if (!Q_stricmp(current_race_name, race))
if (Q_stricmp(current_race_name, race) == 0)
{
return qtrue;
}
@ -750,26 +720,29 @@ given a race name, go find all the skins that use it, and randomly select one
/**
* given a race name, go find all the skins that use it, and randomly select one
*/
static void randomSkin(const char* race, char* model, int current_team, int clientNum)
static void randomSkin(const char* race, char* model, int32_t current_team, int32_t clientNum)
{
char **skinsForRace;
int howManySkins = 0;
int i,x;
int temp;
int skin_count_check;
char **skinNamesAlreadyUsed;
int current_skin_count = 0;
gentity_t *ent = NULL;
char *userinfo;
char temp_model[MAX_QPATH];
char** skinsForRace = NULL;
int32_t howManySkins = 0;
int32_t i = 0;
int32_t x = 0;
int32_t temp = 0;
int32_t skin_count_check = 0;
char** skinNamesAlreadyUsed = NULL;
int32_t current_skin_count = 0;
gentity_t* ent = NULL;
char* userinfo = NULL;
char temp_model[MAX_QPATH];
skinsForRace = (char **)malloc(MAX_SKINS_FOR_RACE * 128 * sizeof(char));
if(!skinsForRace) {
memset(temp_model, 0, sizeof(temp_model));
skinsForRace = malloc(MAX_SKINS_FOR_RACE * 128 * sizeof(char));
if(skinsForRace == NULL) {
G_Error("Was unable to allocate %i bytes.\n", MAX_SKINS_FOR_RACE * 128 * sizeof(char));
return;
}
skinNamesAlreadyUsed = (char **)malloc(16 * 128 * sizeof(char));
if(!skinNamesAlreadyUsed) {
skinNamesAlreadyUsed = malloc(16 * 128 * sizeof(char));
if(skinNamesAlreadyUsed == NULL) {
G_Error("Was unable to allocate %i bytes.\n", 16 * 128 * sizeof(char));
return;
}
@ -779,17 +752,14 @@ static void randomSkin(const char* race, char* model, int current_team, int clie
// first up, check to see if we want to select a skin from someone that's already playing on this guys team
skin_count_check = g_random_skin_limit.integer;
if (skin_count_check)
{
if (skin_count_check != 0) {
// sanity check the skins to compare against count
if (skin_count_check > 16)
{
if (skin_count_check > 16) {
skin_count_check = 16;
}
// now construct an array of the names already used
for (i=0; i<g_maxclients.integer; i++)
{
for ( ; i<g_maxclients.integer; i++) {
// did we find enough skins to grab a random one from yet?
if (current_skin_count == skin_count_check)
{
@ -797,13 +767,13 @@ static void randomSkin(const char* race, char* model, int current_team, int clie
}
ent = g_entities + i;
if (!ent->inuse || i == clientNum)
if (!ent->inuse || i == clientNum) {
continue;
}
// no, so look at the next one, and see if it's in the list we are constructing
// same team?
if (ent->client && ent->client->sess.sessionTeam == current_team)
{
if (ent->client && ent->client->sess.sessionTeam == current_team) {
userinfo = (char *)malloc(MAX_INFO_STRING * sizeof(char));
if(!userinfo) {
G_Error("Was unable to allocate %i bytes.\n", MAX_INFO_STRING * sizeof(char));

46
code/game/g_client.h Normal file
View file

@ -0,0 +1,46 @@
#ifndef _G_CLIENT_H
#define _G_CLIENT_H
#include "g_local.h"
/**
* Select a spawnpoint.
*
* \param avoidPoint Point to avoid.
* \param origin Origin.
* \param angles Angles.
*/
/*@shared@*/ /*@null@*/ gentity_t* G_Client_SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
/**
* Set the clients view angle.
*
* \param ent Entity for which to set view angle.
* \param angle New view angle.
*/
void G_Client_SetViewAngle( gentity_t* ent, vec3_t angle );
/**
* Respawn client.
*
* \param ent Client to respawn.
*/
void G_Client_Respawn(gentity_t *ent);
/**
* Init the body que.
*/
void G_Client_InitBodyQue(void);
//TiM - Delayed Transport Beam
void G_InitTransport( int32_t clientNum, vec3_t origin, vec3_t angles );
/**
* Pick a random team.
*
* \param ignoreClientNum Client to ignore.
* \return Random team.
*/
team_t G_Client_PickTeam( int ignoreClientNum );
#endif /* _G_CLIENT_H */

View file

@ -5,6 +5,7 @@
#include "g_local.h"
#include "g_sql.h"
#include "g_main.h"
#include "g_client.h"
//#include <windows.h>

View file

@ -5,5 +5,7 @@
qboolean SetClass( gentity_t *ent, char *s, /*@null@*/ char *teamName, qboolean SaveToCvar );
void DragCheck( void );
pclass_t ValueNameForClass ( char* s );
void BroadcastClassChange( gclient_t *client, pclass_t oldPClass );
#endif

View file

@ -12,7 +12,6 @@ typedef struct
extern group_list_t group_list[MAX_GROUP_MEMBERS];
extern int group_count;
extern char* BG_RegisterRace( const char *name );
/*@shared@*/ /*@null@*/ extern char *G_searchGroupList(const char *name);
#define MAX_SKINS_FOR_RACE 128

View file

@ -1612,57 +1612,12 @@ void G_Weapon_SnapVectorTowards( vec3_t v, vec3_t to );
//
// g_client.c
//
/**
* Get number of clients in team.
*
* \param ignoreClientNum Client to ignore.
* \param team Team.
* \reutrn Number of clients in team.
*/
team_t G_Client_TeamCount( int ignoreClientNum, int team );
/**
* Pick a random team.
*
* \param ignoreClientNum Client to ignore.
* \return Random team.
*/
team_t G_Client_PickTeam( int ignoreClientNum );
/**
* Set the clients view angle.
*
* \param ent Entity for which to set view angle.
* \param angle New view angle.
*/
void G_Client_SetViewAngle( gentity_t* ent, vec3_t angle );
/**
* Select a spawnpoint.
*
* \param avoidPoint Point to avoid.
* \param origin Origin.
* \param angles Angles.
*/
/*@shared@*/ /*@null@*/ gentity_t* G_Client_SelectSpawnPoint ( vec3_t avoidPoint, vec3_t origin, vec3_t angles );
/**
* Respawn client.
*
* \param ent Client to respawn.
*/
void G_Client_Respawn(gentity_t *ent);
/**
* Begin intermission.
*/
void G_Client_BeginIntermission(void);
/**
* Init the body que.
*/
void G_Client_InitBodyQue(void);
/**
* Spawn client.
*
@ -1698,14 +1653,6 @@ void G_Client_AddScore( gentity_t* ent, int score );
*/
void G_Client_CalculateRanks( qboolean fromExit );
/**
* Determine whether spot would telefrag.
*
* \param spot Spot to check.
* \return Whether this spot would telefrag.
*/
qboolean G_Client_SpotWouldTelefrag( gentity_t* spot );
/**
* Get weapons for a class.
*
@ -2164,9 +2111,6 @@ void QDECL G_ClearClientLog(int client);
/*----------------------------------------------------------------------------------------*/
//TiM - Delayed Transport Beam
void G_InitTransport( int clientNum, vec3_t origin, vec3_t angles );
/** \struct clInitStatus_t
*
*/
@ -2333,7 +2277,7 @@ void G_InitBots( qboolean restart );
*
* \todo Remove? We don't support bots.
*/
char* G_GetBotInfoByNumber( int num );
char* G_GetBotInfoByNumber( int32_t num );
/**
* Get bot info by name.
@ -2368,7 +2312,7 @@ void G_QueueBotBegin( int clientNum );
*
* \todo Remove? We don't support bots.
*/
qboolean G_BotConnect( int clientNum, qboolean restart );
qboolean G_BotConnect( int32_t clientNum, qboolean restart );
/**
* Server command. Add bot.

View file

@ -4,6 +4,7 @@
#include "g_main.h"
#include "g_local.h"
#include "g_groups.h"
#include "g_client.h"
#include "bg_lex.h"
#include "g_cmds.h"
#include "bg_misc.h"

View file

@ -3,6 +3,7 @@
// g_misc.c
#include "g_local.h"
#include "g_client.h"
/*QUAKED func_group (0 0 0) ?

View file

@ -5,7 +5,6 @@
#include "g_local.h"
/*
==============================================================================
@ -385,8 +384,6 @@ void G_ProcessIDBans( void )
Svcmd_BanUser_f
=================
*/
extern void ClientCleanName( const char *in, char *out, int outSize );
void Svcmd_BanUser_f( void )
{
char str[MAX_TOKEN_CHARS];

View file

@ -4,6 +4,7 @@
#include "list.h"
#include "bg_misc.h"
#include "g_spawn.h"
#include "g_client.h"
//#include <windows.h> //TiM : WTF?

View file

@ -3,6 +3,7 @@
*/
#include "g_local.h"
#include "g_client.h"
/*these look weired... I'd rather replace them with streight numbers.
#define SF_SPECTATOR (1<<0)

View file

@ -6,6 +6,7 @@
#include "g_local.h"
#include "g_weapon.h"
#include "g_client.h"
extern void G_MissileImpact( gentity_t *ent, trace_t *trace);

View file

@ -500,6 +500,7 @@
<ClInclude Include="chars.h" />
<ClInclude Include="g_breakable.h" />
<ClInclude Include="g_cinematic.h" />
<ClInclude Include="g_client.h" />
<ClInclude Include="g_cmds.h" />
<ClInclude Include="g_groups.h" />
<ClInclude Include="g_local.h" />

View file

@ -482,6 +482,9 @@
<ClInclude Include="bg_misc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="g_client.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="game.def">

View file

@ -8,6 +8,7 @@ START SERVER MENU *****
=============================================================================
*/
#include "ui_local.h"
#include "../game/bg_misc.h"
#define GAMESERVER_SELECT "menu/art/maps_select"
#define GAMESERVER_SELECTED "menu/art/maps_selected"
@ -4384,7 +4385,6 @@ void UI_ServerAdvancedOptions(int fromMenu)
// Giving credit where credit is due - I stole most of this from Jake's code.
extern char* BG_RegisterRace( const char *name );
void UI_BuildGroupTable(void)
{
int howManySkins = 0;