commit 80d791b8bcdf6dacfc5436f651b4969ca984e5fd Author: devhc Date: Sun May 8 23:36:28 2011 +0200 REFACTOR diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 23a2289..c4368dd 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -225,7 +225,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 ) @@ -248,7 +248,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 98f7280..e7eb0ed 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 a133355..c5ba9ee 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -359,7 +359,7 @@ static cvarTable_t cvarTable[ ] = { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE} }; -static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); +static int cvarTableSize = ARRAY_LEN( cvarTable ); /* ================= @@ -1740,7 +1740,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_players.c b/src/cgame/cg_players.c index 54bd1b8..0e4bbbb 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -619,7 +619,7 @@ static int CG_GetCorpseNum( class_t class ) if( !Q_stricmp( modelName, match->modelName ) && !Q_stricmp( skinName, match->skinName ) ) { - // this clientinfo is identical, so use it's handles + // this clientinfo is identical, so use its handles return i; } } diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 358c16d..1404e71 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -1276,9 +1276,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 8c3da0c..e53ab26 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 int numBindings = ARRAY_LEN( bindings ); /* ================= diff --git a/src/client/snd_main.c b/src/client/snd_main.c index 22213cc..d0290e9 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_local.h b/src/game/bg_local.h index 6a3fd72..4ebae00 100644 --- a/src/game/bg_local.h +++ b/src/game/bg_local.h @@ -65,10 +65,8 @@ extern pml_t pml; extern float pm_stopspeed; extern float pm_duckScale; extern float pm_swimScale; -extern float pm_wadeScale; extern float pm_accelerate; -extern float pm_airaccelerate; extern float pm_wateraccelerate; extern float pm_flyaccelerate; diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index d2d76b2..88116bf 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 ] ); +int 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 ] ); +int 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 ] ); +int 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 ] ); +int 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/bg_pmove.c b/src/game/bg_pmove.c index 16c4972..5c40aea 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -35,10 +35,8 @@ pml_t pml; float pm_stopspeed = 100.0f; float pm_duckScale = 0.25f; float pm_swimScale = 0.50f; -float pm_wadeScale = 0.70f; float pm_accelerate = 10.0f; -float pm_airaccelerate = 1.0f; float pm_wateraccelerate = 4.0f; float pm_flyaccelerate = 4.0f; @@ -3632,7 +3630,7 @@ void PmoveSingle( pmove_t *pmove ) pm = pmove; // this counter lets us debug movement problems with a journal - // by setting a conditional breakpoint fot the previous frame + // by setting a conditional breakpoint for the previous frame c_pmove++; // clear results diff --git a/src/game/g_admin.c b/src/game/g_admin.c index ef6c9bf..3035bfd 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -12,7 +12,7 @@ and Travis Maurer. The functionality of this code mimics the behaviour of the currently inactive project shrubet (http://www.etstats.com/shrubet/index.php?ver=2) by Ryan Mannion. However, shrubet was a closed-source project and -none of it's code has been copied, only it's functionality. +none of its code has been copied, only its functionality. Tremulous is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -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 c20e2d0..ca95775 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -47,7 +47,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * CANPERMBAN - does not need to specify a duration for a ban * 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 */ @@ -68,16 +68,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 6db8008..1e4095f 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( self->usesBuildPointZone && level.buildPointZones[ ent->buildPointZone ].active ) @@ -596,7 +586,7 @@ qboolean G_FindCreep( gentity_t *self ) if( self->s.groundEntityNum == -1 ) return qtrue; - //if self does not have a parentNode or it's parentNode is invalid find a new one + //if self does not have a parentNode or its parentNode is invalid, then find a new one if( self->client || self->parentNode == NULL || !self->parentNode->inuse || self->parentNode->health <= 0 ) { @@ -1477,7 +1467,6 @@ void ATrapper_FindEnemy( gentity_t *ent, int range ) int start; // iterate through entities - // note that if we exist then level.num_entities != 0 start = rand( ) % level.num_entities; for( i = start; i < level.num_entities + start; i++ ) { @@ -1605,7 +1594,6 @@ think function */ void HSpawn_Disappear( gentity_t *self ) { - self->s.eFlags |= EF_NODRAW; //don't draw the model once its destroyed self->timestamp = level.time; G_QueueBuildPoints( self ); G_RewardAttackers( self ); @@ -2954,7 +2942,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; @@ -3683,7 +3671,6 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, break; } - built->s.number = built - g_entities; built->r.contents = CONTENTS_BODY; built->clipmask = MASK_PLAYERSOLID; built->enemy = NULL; @@ -3889,7 +3876,7 @@ static gentity_t *G_FinishSpawningBuildable( gentity_t *ent, qboolean force ) ============ G_SpawnBuildableThink -Complete spawning a buildable using it's placeholder +Complete spawning a buildable using its placeholder ============ */ static void G_SpawnBuildableThink( gentity_t *ent ) diff --git a/src/game/g_client.c b/src/game/g_client.c index 88e75d0..619f9eb 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -466,7 +466,6 @@ static void SpawnCorpse( gentity_t *ent ) VectorCopy( ent->s.apos.trBase, body->s.angles ); body->s.eFlags = EF_DEAD; body->s.eType = ET_CORPSE; - body->s.number = body - g_entities; body->timestamp = level.time; body->s.event = 0; body->r.contents = CONTENTS_CORPSE; @@ -1145,9 +1144,9 @@ char *ClientConnect( int clientNum, qboolean firstTime ) =========== ClientBegin -called when a client has finished connecting, and is ready -to be placed into the level. This will happen every level load, -and on transition between teams, but doesn't happen on respawns +Called when a client has finished connecting, and is ready +to be placed into the level. This will happen on every +level load and level restart, but doesn't happen on respawns. ============ */ void ClientBegin( int clientNum ) diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 6b35037..f908b1f 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 ); @@ -1794,7 +1794,6 @@ void Cmd_Class_f( gentity_t *ent ) return; } - //guard against selling the HBUILD weapons exploit if( ent->client->sess.spectatorState == SPECTATOR_NOT && ( currentClass == PCL_ALIEN_BUILDER0 || currentClass == PCL_ALIEN_BUILDER0_UPG ) && @@ -3146,7 +3145,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 29b635d..287c7ad 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -264,7 +264,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int killerName = ""; } - 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 7ea873c..9fa46ae 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -540,7 +540,7 @@ typedef struct struct gentity_s *gentities; int gentitySize; - int num_entities; // current number, <= MAX_GENTITIES + int num_entities; // MAX_CLIENTS <= num_entities <= ENTITYNUM_MAX_NORMAL int warmupTime; // restart match at this time @@ -923,7 +923,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 6f4d425..507a5d6 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -277,7 +277,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_tag, "g_tag", "gpp", CVAR_INIT, 0, qfalse } }; -static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] ); +static int gameCvarTableSize = ARRAY_LEN( gameCvarTable ); void G_InitGame( int levelTime, int randomSeed, int restart ); diff --git a/src/game/g_mover.c b/src/game/g_mover.c index ad660d0..c081e9e 100644 --- a/src/game/g_mover.c +++ b/src/game/g_mover.c @@ -285,7 +285,7 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t ** listedEntities = trap_EntitiesInBox( totalMins, totalMaxs, entityList, MAX_GENTITIES ); - // move the pusher to it's final position + // move the pusher to its final position VectorAdd( pusher->r.currentOrigin, move, pusher->r.currentOrigin ); VectorAdd( pusher->r.currentAngles, amove, pusher->r.currentAngles ); trap_LinkEntity( pusher ); @@ -1237,7 +1237,7 @@ static void manualDoorTriggerSpectator( gentity_t *door, gentity_t *player ) ================ manualTriggerSpectator -Trip to skip the closest door targetted by trigger +Trip to skip the closest door targeted by trigger ================ */ void manualTriggerSpectator( gentity_t *trigger, gentity_t *player ) @@ -1916,7 +1916,7 @@ void Touch_Button( gentity_t *ent, gentity_t *other, trace_t *trace ) /*QUAKED func_button (0 .5 .8) ? -When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again. +When a button is touched, it moves some distance in the direction of its angle, triggers all of its targets, waits some time, then returns to its original position where it can be triggered again. "model2" .md3 model to also draw "angle" determines the opening direction diff --git a/src/game/g_public.h b/src/game/g_public.h index 312a5e5..29335ee 100644 --- a/src/game/g_public.h +++ b/src/game/g_public.h @@ -75,8 +75,8 @@ typedef struct { // when a trace call is made and passEntityNum != ENTITYNUM_NONE, // an ent will be excluded from testing if: // ent->s.number == passEntityNum (don't interact with self) - // ent->s.ownerNum = passEntityNum (don't interact with your own missiles) - // entity[ent->s.ownerNum].ownerNum = passEntityNum (don't interact with other missiles from owner) + // ent->r.ownerNum == passEntityNum (don't interact with your own missiles) + // entity[ent->r.ownerNum].r.ownerNum == passEntityNum (don't interact with other missiles from owner) int ownerNum; } entityShared_t; diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 0bdb366..bdb5ff7 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -96,23 +96,17 @@ typedef enum { F_INT, F_FLOAT, - F_LSTRING, // string on disk, pointer in memory, TAG_LEVEL - F_GSTRING, // string on disk, pointer in memory, TAG_GAME + F_STRING, F_VECTOR, F_VECTOR4, - F_ANGLEHACK, - F_ENTITY, // index on disk, pointer in memory - F_ITEM, // index on disk, pointer in memory - F_CLIENT, // index on disk, pointer in memory - F_IGNORE + F_ANGLEHACK } fieldtype_t; typedef struct { char *name; - int ofs; + size_t ofs; fieldtype_t type; - int flags; } field_t; field_t fields[ ] = @@ -123,25 +117,24 @@ field_t fields[ ] = {"angles", FOFS(s.angles), F_VECTOR}, {"animation", FOFS(animation), F_VECTOR4}, {"bounce", FOFS(physicsBounce), F_FLOAT}, - {"classname", FOFS(classname), F_LSTRING}, + {"classname", FOFS(classname), F_STRING}, {"count", FOFS(count), F_INT}, {"dmg", FOFS(damage), F_INT}, {"health", FOFS(health), F_INT}, - {"light", 0, F_IGNORE}, - {"message", FOFS(message), F_LSTRING}, - {"model", FOFS(model), F_LSTRING}, - {"model2", FOFS(model2), F_LSTRING}, + {"message", FOFS(message), F_STRING}, + {"model", FOFS(model), F_STRING}, + {"model2", FOFS(model2), F_STRING}, {"origin", FOFS(s.origin), F_VECTOR}, {"radius", FOFS(pos2), F_VECTOR}, {"random", FOFS(random), F_FLOAT}, {"rotatorAngle", FOFS(rotatorAngle), F_FLOAT}, {"spawnflags", FOFS(spawnflags), F_INT}, {"speed", FOFS(speed), F_FLOAT}, - {"target", FOFS(target), F_LSTRING}, - {"targetname", FOFS(targetname), F_LSTRING}, - {"targetShaderName", FOFS(targetShaderName), F_LSTRING}, - {"targetShaderNewName", FOFS(targetShaderNewName), F_LSTRING}, - {"team", FOFS(team), F_LSTRING}, + {"target", FOFS(target), F_STRING}, + {"targetname", FOFS(targetname), F_STRING}, + {"targetShaderName", FOFS(targetShaderName), F_STRING}, + {"targetShaderNewName", FOFS(targetShaderNewName), F_STRING}, + {"team", FOFS(team), F_STRING}, {"wait", FOFS(wait), F_FLOAT} }; @@ -159,11 +152,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 +181,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 +196,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 +203,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 +316,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 +385,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; @@ -411,7 +393,7 @@ void G_ParseField( const char *key, const char *value, gentity_t *ent ) switch( f->type ) { - case F_LSTRING: + case F_STRING: *(char **)( b + f->ofs ) = G_NewString( value ); break; @@ -446,10 +428,6 @@ void G_ParseField( const char *key, const char *value, gentity_t *ent ) ( (float *)( b + f->ofs ) )[ 1 ] = v; ( (float *)( b + f->ofs ) )[ 2 ] = 0; break; - - default: - case F_IGNORE: - break; } } diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 16cb6b8..b9b913a 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 38e5203..0566ef8 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/game/g_weapon.c b/src/game/g_weapon.c index 1c227ff..6bb365e 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -1302,7 +1302,7 @@ qboolean CheckPounceAttack( gentity_t *ent ) if( ent->client->pmext.pouncePayload <= 0 ) return qfalse; - // In case the goon lands on his target, he get's one shot after landing + // In case the goon lands on his target, he gets one shot after landing payload = ent->client->pmext.pouncePayload; if( !( ent->client->ps.pm_flags & PMF_CHARGE ) ) ent->client->pmext.pouncePayload = 0; diff --git a/src/master/messages.c b/src/master/messages.c index a86e795..a41ef4d 100644 --- a/src/master/messages.c +++ b/src/master/messages.c @@ -510,7 +510,7 @@ void HandleMessage (const char* msg, size_t length, { server_t* server; - // If it's an heartbeat + // If it's a heartbeat if (!strncmp (S2M_HEARTBEAT, msg, strlen (S2M_HEARTBEAT))) { char gameId [64]; diff --git a/src/qcommon/cmd.c b/src/qcommon/cmd.c index 8ea761e..4ab4c08 100644 --- a/src/qcommon/cmd.c +++ b/src/qcommon/cmd.c @@ -819,7 +819,6 @@ void Cmd_ExecuteString( const char *text ) { } // send it as a server command if we are connected - // this will usually result in a chat message CL_ForwardCommandToServer ( text ); } diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c index 0d50e28..6c0d8ca 100644 --- a/src/ui/ui_atoms.c +++ b/src/ui/ui_atoms.c @@ -218,7 +218,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 b4ae543..37d6010 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -41,7 +41,7 @@ static const char *netSources[ ] = "Favorites" }; -static const int numNetSources = sizeof( netSources ) / sizeof( const char* ); +static const int numNetSources = ARRAY_LEN( netSources ); static const char *netnames[ ] = { @@ -119,7 +119,7 @@ static cvarTable_t cvarTable[ ] = { &ui_chatCommands, "ui_chatCommands", "1", CVAR_ARCHIVE } }; -static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); +static int cvarTableSize = ARRAY_LEN( cvarTable ); /* ================ @@ -2688,11 +2688,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 ba61cff..c20e15f 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -2360,7 +2360,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 ) @@ -4973,7 +4973,7 @@ static bind_t g_bindings[] = }; -static const int g_bindCount = sizeof( g_bindings ) / sizeof( bind_t ); +static const int g_bindCount = ARRAY_LEN( g_bindings ); /* =================