diff options
author | M. Kristall <mkpdev@gmail.com> | 2012-07-12 02:46:19 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:18:16 +0000 |
commit | 8d448680f5b3bcd2a67a3684308bb948e4d3ddad (patch) | |
tree | 8ec357b00c06d7b2e851680270690ad8e5ee3504 | |
parent | 156289dcdd27a31e77afb36147d456bac9be72a3 (diff) |
* (bug 5000) refactor: use ARRAY_LEN; remove undefined functions; more size_t
(/dev/humancontroller)
-rw-r--r-- | src/cgame/cg_consolecmds.c | 4 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 3 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 5 | ||||
-rw-r--r-- | src/cgame/cg_tutorial.c | 2 | ||||
-rw-r--r-- | src/client/snd_main.c | 2 | ||||
-rw-r--r-- | src/game/bg_misc.c | 10 | ||||
-rw-r--r-- | src/game/g_admin.c | 2 | ||||
-rw-r--r-- | src/game/g_admin.h | 8 | ||||
-rw-r--r-- | src/game/g_buildable.c | 16 | ||||
-rw-r--r-- | src/game/g_cmds.c | 4 | ||||
-rw-r--r-- | src/game/g_combat.c | 2 | ||||
-rw-r--r-- | src/game/g_local.h | 1 | ||||
-rw-r--r-- | src/game/g_main.c | 2 | ||||
-rw-r--r-- | src/game/g_spawn.c | 17 | ||||
-rw-r--r-- | src/game/g_svcmds.c | 6 | ||||
-rw-r--r-- | src/game/g_syscalls.c | 2 | ||||
-rw-r--r-- | src/ui/ui_atoms.c | 2 | ||||
-rw-r--r-- | src/ui/ui_main.c | 8 | ||||
-rw-r--r-- | src/ui/ui_shared.c | 4 |
20 files changed, 37 insertions, 65 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 19216eea..5dab9757 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -211,7 +211,7 @@ qboolean CG_ConsoleCommand( void ) consoleCommand_t *cmd; cmd = bsearch( CG_Argv( 0 ), commands, - sizeof( commands ) / sizeof( commands[ 0 ]), sizeof( commands[ 0 ] ), + ARRAY_LEN( commands ), sizeof( commands[ 0 ] ), cmdcmp ); if( !cmd ) @@ -234,7 +234,7 @@ void CG_InitConsoleCommands( void ) { int i; - for( i = 0 ; i < sizeof( commands ) / sizeof( commands[ 0 ] ) ; i++ ) + for( i = 0; i < ARRAY_LEN( commands ); i++ ) trap_AddCommand( commands[ i ].cmd ); // diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 36d7a870..797d0c2c 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -722,7 +722,7 @@ typedef struct { qboolean infoValid; - char name[ MAX_QPATH ]; + char name[ MAX_NAME_LENGTH ]; team_t team; int score; // updated by score servercmds diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 3972097e..fd2d258f 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -357,7 +357,7 @@ static cvarTable_t cvarTable[ ] = { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE} }; -static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); +static size_t cvarTableSize = ARRAY_LEN( cvarTable ); /* ================= @@ -1738,7 +1738,6 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) // clear everything memset( &cgs, 0, sizeof( cgs ) ); memset( &cg, 0, sizeof( cg ) ); - memset( &cg.pmext, 0, sizeof( cg.pmext ) ); memset( cg_entities, 0, sizeof( cg_entities ) ); cg.clientNum = clientNum; diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index e1da8399..64ef7985 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -1292,9 +1292,8 @@ static void CG_ServerCommand( void ) consoleCommand_t *command; cmd = CG_Argv( 0 ); - command = bsearch( cmd, svcommands, sizeof( svcommands ) / - sizeof( svcommands[ 0 ]), sizeof( svcommands[ 0 ] ), - cmdcmp ); + command = bsearch( cmd, svcommands, ARRAY_LEN( svcommands ), + sizeof( svcommands[ 0 ] ), cmdcmp ); if( command ) { diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c index 6839c3a1..7820f4fa 100644 --- a/src/cgame/cg_tutorial.c +++ b/src/cgame/cg_tutorial.c @@ -50,7 +50,7 @@ static bind_t bindings[ ] = { "weapnext", "Next Upgrade", { -1, -1 } } }; -static const int numBindings = sizeof( bindings ) / sizeof( bind_t ); +static const size_t numBindings = ARRAY_LEN( bindings ); /* ================= diff --git a/src/client/snd_main.c b/src/client/snd_main.c index 22213cc9..d0290e94 100644 --- a/src/client/snd_main.c +++ b/src/client/snd_main.c @@ -17,7 +17,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Foobar; if not, write to the Free Software +along with Tremulous; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 83b35ebb..c6412327 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -563,7 +563,7 @@ static const buildableAttributes_t bg_buildableList[ ] = } }; -int bg_numBuildables = sizeof( bg_buildableList ) / sizeof( bg_buildableList[ 0 ] ); +size_t bg_numBuildables = ARRAY_LEN( bg_buildableList ); static const buildableAttributes_t nullBuildable = { 0 }; @@ -1210,7 +1210,7 @@ static const classAttributes_t bg_classList[ ] = } }; -int bg_numClasses = sizeof( bg_classList ) / sizeof( bg_classList[ 0 ] ); +size_t bg_numClasses = ARRAY_LEN( bg_classList ); static const classAttributes_t nullClass = { 0 }; @@ -2365,7 +2365,7 @@ static const weaponAttributes_t bg_weapons[ ] = } }; -int bg_numWeapons = sizeof( bg_weapons ) / sizeof( bg_weapons[ 0 ] ); +size_t bg_numWeapons = ARRAY_LEN( bg_weapons ); static const weaponAttributes_t nullWeapon = { 0 }; @@ -2531,7 +2531,7 @@ static const upgradeAttributes_t bg_upgrades[ ] = } }; -int bg_numUpgrades = sizeof( bg_upgrades ) / sizeof( bg_upgrades[ 0 ] ); +size_t bg_numUpgrades = ARRAY_LEN( bg_upgrades ); static const upgradeAttributes_t nullUpgrade = { 0 }; @@ -2803,7 +2803,7 @@ BG_EventName */ const char *BG_EventName( int num ) { - if( num < 0 || num >= sizeof( eventnames ) / sizeof( char * ) ) + if( num < 0 || num >= ARRAY_LEN( eventnames ) ) return "UNKNOWN"; return eventnames[ num ]; diff --git a/src/game/g_admin.c b/src/game/g_admin.c index eef4f1ad..085b394c 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -209,7 +209,7 @@ g_admin_cmd_t g_admin_cmds[ ] = } }; -static size_t adminNumCmds = sizeof( g_admin_cmds ) / sizeof( g_admin_cmds[ 0 ] ); +static size_t adminNumCmds = ARRAY_LEN( g_admin_cmds ); static int admin_level_maxname = 0; g_admin_level_t *g_admin_levels = NULL; diff --git a/src/game/g_admin.h b/src/game/g_admin.h index fe057939..c684ae1e 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -48,7 +48,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * CANIPBAN - allows banning not-necessarily-connected players with CIDR notation * ACTIVITY - inactivity rules do not apply to them * IMMUTABLE - admin commands cannot be used on them - * INCOGNITO - does not show up as an admin in !listplayers + * INCOGNITO - does not show up as an admin in /listplayers * ALLFLAGS - all flags (including command flags) apply to this player * ADMINCHAT - receieves and can send /a admin messages */ @@ -70,16 +70,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_ADMIN_LISTITEMS 20 #define MAX_ADMIN_SHOWBANS 10 -// important note: QVM does not seem to allow a single char to be a -// member of a struct at init time. flag has been converted to char* typedef struct { char *keyword; qboolean ( * handler ) ( gentity_t *ent ); qboolean silent; char *flag; - char *function; // used for !help - char *syntax; // used for !help + char *function; // used in /adminhelp + char *syntax; // used in /adminhelp } g_admin_cmd_t; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 0f7ec7e6..f1bb1c12 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -172,17 +172,13 @@ qboolean G_FindPower( gentity_t *self, qboolean searchUnspawned ) // Scan the buildables in the reactor zone for( j = MAX_CLIENTS, ent2 = g_entities + j; j < level.num_entities; j++, ent2++ ) { - gentity_t *powerEntity; - if( ent2->s.eType != ET_BUILDABLE ) continue; if( ent2 == self ) continue; - powerEntity = ent2->parentNode; - - if( powerEntity && powerEntity->s.modelindex == BA_H_REACTOR && ( powerEntity == ent ) ) + if( ent2->parentNode == ent ) { buildPoints -= BG_Buildable( ent2->s.modelindex )->buildPoints; } @@ -224,20 +220,14 @@ qboolean G_FindPower( gentity_t *self, qboolean searchUnspawned ) // Scan the buildables in the repeater zone for( j = MAX_CLIENTS, ent2 = g_entities + j; j < level.num_entities; j++, ent2++ ) { - gentity_t *powerEntity; - if( ent2->s.eType != ET_BUILDABLE ) continue; if( ent2 == self ) continue; - powerEntity = ent2->parentNode; - - if( powerEntity && powerEntity->s.modelindex == BA_H_REPEATER && ( powerEntity == ent ) ) - { + if( ent2->parentNode == ent ) buildPoints -= BG_Buildable( ent2->s.modelindex )->buildPoints; - } } if( ent->usesBuildPointZone && level.buildPointZones[ ent->buildPointZone ].active ) @@ -2956,7 +2946,7 @@ static int G_CompareBuildablesForRemoval( const void *a, const void *b ) } // Resort to preference list - for( i = 0; i < sizeof( precedence ) / sizeof( precedence[ 0 ] ); i++ ) + for( i = 0; i < ARRAY_LEN( precedence ); i++ ) { if( buildableA->s.modelindex == precedence[ i ] ) aPrecedence = i; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 7b2b9948..664df9fa 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -279,7 +279,7 @@ void ScoreboardMessage( gentity_t *ent ) j = strlen( entry ); - if( stringlength + j >= 1024 ) + if( stringlength + j >= sizeof( string ) ) break; strcpy( string + stringlength, entry ); @@ -3138,7 +3138,7 @@ commands_t cmds[ ] = { { "vsay_team", CMD_MESSAGE|CMD_INTERMISSION, Cmd_VSay_f }, { "where", 0, Cmd_Where_f } }; -static size_t numCmds = sizeof( cmds ) / sizeof( cmds[ 0 ] ); +static size_t numCmds = ARRAY_LEN( cmds ); /* ================= diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 46657322..fcdc2ee2 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -263,7 +263,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int killerName = "<world>"; } - if( meansOfDeath < 0 || meansOfDeath >= sizeof( modNames ) / sizeof( modNames[0] ) ) + if( meansOfDeath < 0 || meansOfDeath >= ARRAY_LEN( modNames ) ) // fall back on the number obit = va( "%d", meansOfDeath ); else diff --git a/src/game/g_local.h b/src/game/g_local.h index 727c280b..81700620 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -924,7 +924,6 @@ void G_Checktrigger_stages( team_t team, stage_t stage ); // g_misc.c // void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ); -void ShineTorch( gentity_t *self ); // // g_weapon.c diff --git a/src/game/g_main.c b/src/game/g_main.c index fda51ebd..2380a334 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -274,7 +274,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_tag, "g_tag", "main", CVAR_INIT, 0, qfalse } }; -static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] ); +static size_t gameCvarTableSize = ARRAY_LEN( gameCvarTable ); void G_InitGame( int levelTime, int randomSeed, int restart ); diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 1ebc04d0..5cbc643f 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -110,7 +110,7 @@ typedef enum typedef struct { char *name; - int ofs; + size_t ofs; fieldtype_t type; int flags; } field_t; @@ -159,11 +159,6 @@ void SP_info_player_intermission( gentity_t *ent ); void SP_info_alien_intermission( gentity_t *ent ); void SP_info_human_intermission( gentity_t *ent ); -void SP_info_firstplace( gentity_t *ent ); -void SP_info_secondplace( gentity_t *ent ); -void SP_info_thirdplace( gentity_t *ent ); -void SP_info_podium( gentity_t *ent ); - void SP_func_plat( gentity_t *ent ); void SP_func_static( gentity_t *ent ); void SP_func_rotating( gentity_t *ent ); @@ -193,7 +188,6 @@ void SP_trigger_ammo( gentity_t *ent ); void SP_target_delay( gentity_t *ent ); void SP_target_speaker( gentity_t *ent ); void SP_target_print( gentity_t *ent ); -void SP_target_character( gentity_t *ent ); void SP_target_score( gentity_t *ent ); void SP_target_teleporter( gentity_t *ent ); void SP_target_relay( gentity_t *ent ); @@ -209,7 +203,6 @@ void SP_target_hurt( gentity_t *ent ); void SP_light( gentity_t *self ); void SP_info_null( gentity_t *self ); void SP_info_notnull( gentity_t *self ); -void SP_info_camp( gentity_t *self ); void SP_path_corner( gentity_t *self ); void SP_misc_teleporter_dest( gentity_t *self ); @@ -217,10 +210,6 @@ void SP_misc_model( gentity_t *ent ); void SP_misc_portal_camera( gentity_t *ent ); void SP_misc_portal_surface( gentity_t *ent ); -void SP_shooter_rocket( gentity_t *ent ); -void SP_shooter_plasma( gentity_t *ent ); -void SP_shooter_grenade( gentity_t *ent ); - void SP_misc_particle_system( gentity_t *ent ); void SP_misc_anim_model( gentity_t *ent ); void SP_misc_light_flare( gentity_t *ent ); @@ -334,7 +323,7 @@ qboolean G_CallSpawn( gentity_t *ent ) } // check normal spawn functions - s = bsearch( ent->classname, spawns, sizeof( spawns ) / sizeof( spawn_t ), + s = bsearch( ent->classname, spawns, ARRAY_LEN( spawns ), sizeof( spawn_t ), cmdcmp ); if( s ) { @@ -403,7 +392,7 @@ void G_ParseField( const char *key, const char *value, gentity_t *ent ) vec3_t vec; vec4_t vec4; - f = bsearch( key, fields, sizeof( fields ) / sizeof( field_t ), + f = bsearch( key, fields, ARRAY_LEN( fields ), sizeof( field_t ), cmdcmp ); if( !f ) return; diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 9211033b..db14a917 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -588,7 +588,7 @@ qboolean ConsoleCommand( void ) trap_Argv( 0, cmd, sizeof( cmd ) ); - command = bsearch( cmd, svcmds, sizeof( svcmds ) / sizeof( struct svcmd ), + command = bsearch( cmd, svcmds, ARRAY_LEN( svcmds ), sizeof( struct svcmd ), cmdcmp ); if( !command ) @@ -614,7 +614,7 @@ void G_RegisterCommands( void ) { int i; - for( i = 0; i < sizeof( svcmds ) / sizeof( svcmds[ 0 ] ); i++ ) + for( i = 0; i < ARRAY_LEN( svcmds ); i++ ) { if( svcmds[ i ].dedicated && !g_dedicated.integer ) continue; @@ -628,7 +628,7 @@ void G_UnregisterCommands( void ) { int i; - for( i = 0; i < sizeof( svcmds ) / sizeof( svcmds[ 0 ] ); i++ ) + for( i = 0; i < ARRAY_LEN( svcmds ); i++ ) { if( svcmds[ i ].dedicated && !g_dedicated.integer ) continue; diff --git a/src/game/g_syscalls.c b/src/game/g_syscalls.c index 38e52039..0566ef86 100644 --- a/src/game/g_syscalls.c +++ b/src/game/g_syscalls.c @@ -253,13 +253,11 @@ int trap_RealTime( qtime_t *qtime ) void trap_SnapVector( float *v ) { syscall( G_SNAPVECTOR, v ); - return; } void trap_SendGameStat( const char *data ) { syscall( G_SEND_GAMESTAT, data ); - return; } int trap_Parse_AddGlobalDefine( char *define ) diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c index af3a3ef8..fd52fdaa 100644 --- a/src/ui/ui_atoms.c +++ b/src/ui/ui_atoms.c @@ -213,7 +213,7 @@ UI_ConsoleCommand qboolean UI_ConsoleCommand( int realTime ) { struct uicmd *cmd = bsearch( UI_Argv( 0 ), commands, - sizeof( commands ) / sizeof( commands[ 0 ] ), sizeof( commands[ 0 ] ), + ARRAY_LEN( commands ), sizeof( commands[ 0 ] ), cmdcmp ); uiInfo.uiDC.frameTime = realTime - uiInfo.uiDC.realTime; diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index 8edcccae..eb96c4c5 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -49,7 +49,7 @@ static const char *netSources[ ] = "Favorites" }; -static const int numNetSources = sizeof( netSources ) / sizeof( const char* ); +static const size_t numNetSources = ARRAY_LEN( netSources ); static const char *netnames[ ] = { @@ -127,7 +127,7 @@ static cvarTable_t cvarTable[ ] = { &ui_chatCommands, "ui_chatCommands", "1", CVAR_ARCHIVE } }; -static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); +static size_t cvarTableSize = ARRAY_LEN( cvarTable ); /* ================ @@ -2689,11 +2689,11 @@ static void UI_LoadDemos( void ) char *demoname; int i, len; - Com_sprintf( demoExt, sizeof( demoExt ), "dm_%d", ( int )trap_Cvar_VariableValue( "protocol" ) ); + Com_sprintf( demoExt, sizeof( demoExt ), "%s%d", DEMOEXT, (int)trap_Cvar_VariableValue( "protocol" ) ); uiInfo.demoCount = trap_FS_GetFileList( "demos", demoExt, demolist, 4096 ); - Com_sprintf( demoExt, sizeof( demoExt ), ".dm_%d", ( int )trap_Cvar_VariableValue( "protocol" ) ); + Com_sprintf( demoExt, sizeof( demoExt ), ".%s%d", DEMOEXT, (int)trap_Cvar_VariableValue( "protocol" ) ); if( uiInfo.demoCount ) { diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index 24dc201e..1cd922ad 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -2364,7 +2364,7 @@ commandDef_t commandList[] = {"transition", &Script_Transition}, // group/name }; -static size_t scriptCommandCount = sizeof( commandList ) / sizeof( commandDef_t ); +static size_t scriptCommandCount = ARRAY_LEN( commandList ); // despite what lcc thinks, we do not get cmdcmp here static int commandComp( const void *a, const void *b ) @@ -4977,7 +4977,7 @@ static bind_t g_bindings[] = }; -static const int g_bindCount = sizeof( g_bindings ) / sizeof( bind_t ); +static const size_t g_bindCount = ARRAY_LEN( g_bindings ); /* ================= |