host_cmd.c, menu.c: sanitize whitespace/formatting.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@252 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2010-08-02 19:45:16 +00:00
parent 7a618b80cb
commit 79c16e7f0a
2 changed files with 309 additions and 274 deletions

View file

@ -225,16 +225,19 @@ void ExtraMaps_Add (char *name)
{
extralevel_t *level,*cursor,*prev;
//ingore duplicate
// ignore duplicate
for (level = extralevels; level; level = level->next)
{
if (!Q_strcmp (name, level->name))
return;
}
level = (extralevel_t *) Z_Malloc(sizeof(extralevel_t));
strcpy (level->name, name);
//insert each entry in alphabetical order
if (extralevels == NULL || Q_strcasecmp(level->name, extralevels->name) < 0) //insert at front
// insert each entry in alphabetical order
if (extralevels == NULL ||
Q_strcasecmp(level->name, extralevels->name) < 0) //insert at front
{
level->next = extralevels;
extralevels = level;
@ -264,10 +267,11 @@ void ExtraMaps_Init (void)
pack_t *pak;
int i;
//we don't want to list the maps in id1 pakfiles, becuase these are not "add-on" levels
// we don't want to list the maps in id1 pakfiles,
// because these are not "add-on" levels
sprintf (ignorepakdir, "/%s/", GAMENAME);
for (search = com_searchpaths ; search ; search = search->next)
for (search = com_searchpaths; search; search = search->next)
{
if (*search->filename) //directory
{
@ -286,14 +290,14 @@ void ExtraMaps_Init (void)
}
else //pakfile
{
if (!strstr(search->pack->filename, ignorepakdir)) //don't list standard id maps
{
for (i=0, pak=search->pack; i<pak->numfiles ; i++)
if (!strstr(search->pack->filename, ignorepakdir))
{ //don't list standard id maps
for (i = 0, pak = search->pack; i < pak->numfiles; i++)
{
if (strstr(pak->files[i].name, ".bsp"))
{
if (pak->files[i].filelen > 32*1024) // don't list files under 32k (ammo boxes etc)
{
if (pak->files[i].filelen > 32*1024)
{ // don't list files under 32k (ammo boxes etc)
COM_StripExtension(pak->files[i].name + 5, mapname);
ExtraMaps_Add (mapname);
}
@ -332,7 +336,7 @@ void Host_Maps_f (void)
int i;
extralevel_t *level;
for (level=extralevels, i=0; level; level=level->next, i++)
for (level = extralevels, i = 0; level; level = level->next, i++)
Con_SafePrintf (" %s\n", level->name);
if (i)
@ -359,14 +363,17 @@ void Modlist_Add (char *name)
//ingore duplicate
for (mod = modlist; mod; mod = mod->next)
{
if (!Q_strcmp (name, mod->name))
return;
}
mod = (mod_t *) Z_Malloc(sizeof(mod_t));
strcpy (mod->name, name);
//insert each entry in alphabetical order
if (modlist == NULL || Q_strcasecmp(mod->name, modlist->name) < 0) //insert at front
if (modlist == NULL ||
Q_strcasecmp(mod->name, modlist->name) < 0) //insert at front
{
mod->next = modlist;
modlist = mod;
@ -513,7 +520,7 @@ void Host_Status_f (void)
print_fn ("ipx: %s\n", my_ipx_address);
print_fn ("map: %s\n", sv.name);
print_fn ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients);
for (j=0, client = svs.clients ; j<svs.maxclients ; j++, client++)
for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++)
{
if (!client->active)
continue;
@ -753,12 +760,12 @@ void Host_Ping_f (void)
}
SV_ClientPrintf ("Client ping times:\n");
for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++)
{
if (!client->active)
continue;
total = 0;
for (j=0 ; j<NUM_PING_TIMES ; j++)
for (j = 0; j < NUM_PING_TIMES; j++)
total+=client->ping_times[j];
total /= NUM_PING_TIMES;
SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
@ -822,7 +829,7 @@ void Host_Map_f (void)
SCR_BeginLoadingPlaque ();
cls.mapstring[0] = 0;
for (i=0 ; i<Cmd_Argc() ; i++)
for (i = 0; i < Cmd_Argc(); i++)
{
strcat (cls.mapstring, Cmd_Argv(i));
strcat (cls.mapstring, " ");
@ -839,7 +846,7 @@ void Host_Map_f (void)
{
strcpy (cls.spawnparms, "");
for (i=2 ; i<Cmd_Argc() ; i++)
for (i = 2; i < Cmd_Argc(); i++)
{
strcat (cls.spawnparms, Cmd_Argv(i));
strcat (cls.spawnparms, " ");
@ -966,15 +973,17 @@ void Host_SavegameComment (char *text)
int i;
char kills[20];
for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
for (i = 0; i < SAVEGAME_COMMENT_LENGTH; i++)
text[i] = ' ';
memcpy (text, cl.levelname, min(strlen(cl.levelname),22)); //johnfitz -- only copy 22 chars.
sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
memcpy (text+22, kills, strlen(kills));
// convert space to _ to make stdio happy
for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
for (i = 0; i < SAVEGAME_COMMENT_LENGTH; i++)
{
if (text[i] == ' ')
text[i] = '_';
}
text[SAVEGAME_COMMENT_LENGTH] = '\0';
}
@ -1047,7 +1056,7 @@ void Host_Savegame_f (void)
fprintf (f, "%i\n", SAVEGAME_VERSION);
Host_SavegameComment (comment);
fprintf (f, "%s\n", comment);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
for (i = 0; i < NUM_SPAWN_PARMS; i++)
fprintf (f, "%f\n", svs.clients->spawn_parms[i]);
fprintf (f, "%d\n", current_skill);
fprintf (f, "%s\n", sv.name);
@ -1055,7 +1064,7 @@ void Host_Savegame_f (void)
// write the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
for (i = 0; i < MAX_LIGHTSTYLES; i++)
{
if (sv.lightstyles[i])
fprintf (f, "%s\n", sv.lightstyles[i]);
@ -1065,7 +1074,7 @@ void Host_Savegame_f (void)
ED_WriteGlobals (f);
for (i=0 ; i<sv.num_edicts ; i++)
for (i = 0; i < sv.num_edicts; i++)
{
ED_Write (f, EDICT_NUM(i));
fflush (f);
@ -1127,7 +1136,7 @@ void Host_Loadgame_f (void)
return;
}
fscanf (f, "%s\n", str);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
for (i = 0; i < NUM_SPAWN_PARMS; i++)
fscanf (f, "%f\n", &spawn_parms[i]);
// this silliness is so we can load 1.06 save files, which have float skill values
fscanf (f, "%f\n", &tfloat);
@ -1151,7 +1160,7 @@ void Host_Loadgame_f (void)
// load the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
for (i = 0; i < MAX_LIGHTSTYLES; i++)
{
fscanf (f, "%s\n", str);
sv.lightstyles[i] = (char *) Hunk_Alloc (strlen(str)+1);
@ -1162,7 +1171,7 @@ void Host_Loadgame_f (void)
entnum = -1; // -1 is the globals
while (!feof(f))
{
for (i=0 ; i<sizeof(str)-1 ; i++)
for (i = 0; i < sizeof(str) - 1; i++)
{
r = fgetc (f);
if (r == EOF || !r)
@ -1174,7 +1183,7 @@ void Host_Loadgame_f (void)
break;
}
}
if (i == sizeof(str)-1)
if (i == sizeof(str) - 1)
Sys_Error ("Loadgame buffer overflow");
str[i] = 0;
start = str;
@ -1209,7 +1218,7 @@ void Host_Loadgame_f (void)
fclose (f);
for (i=0 ; i<NUM_SPAWN_PARMS ; i++)
for (i = 0; i < NUM_SPAWN_PARMS; i++)
svs.clients->spawn_parms[i] = spawn_parms[i];
if (cls.state != ca_dedicated)
@ -1252,8 +1261,10 @@ void Host_Name_f (void)
}
if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
{
if (Q_strcmp(host_client->name, newName) != 0)
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
}
Q_strcpy (host_client->name, newName);
host_client->edict->v.netname = PR_SetEngineString(host_client->name);
@ -1603,7 +1614,7 @@ void Host_Spawn_f (void)
MSG_WriteByte (&host_client->message, svc_time);
MSG_WriteFloat (&host_client->message, sv.time);
for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
for (i = 0, client = svs.clients; i < svs.maxclients; i++, client++)
{
MSG_WriteByte (&host_client->message, svc_updatename);
MSG_WriteByte (&host_client->message, i);
@ -1617,7 +1628,7 @@ void Host_Spawn_f (void)
}
// send all current light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
for (i = 0; i < MAX_LIGHTSTYLES; i++)
{
MSG_WriteByte (&host_client->message, svc_lightstyle);
MSG_WriteByte (&host_client->message, (char)i);
@ -1652,7 +1663,7 @@ void Host_Spawn_f (void)
// with a permanent head tilt
ent = EDICT_NUM( 1 + (host_client - svs.clients) );
MSG_WriteByte (&host_client->message, svc_setangle);
for (i=0 ; i < 2 ; i++)
for (i = 0; i < 2; i++)
MSG_WriteAngle (&host_client->message, ent->v.angles[i] );
MSG_WriteAngle (&host_client->message, 0 );
@ -1842,9 +1853,9 @@ void Host_Give_f (void)
if (val)
val->_float = v;
}
sv_player->v.ammo_shells = v;
break;
case 'n':
if (rogue)
{
@ -1861,6 +1872,7 @@ void Host_Give_f (void)
sv_player->v.ammo_nails = v;
}
break;
case 'l':
if (rogue)
{
@ -1873,6 +1885,7 @@ void Host_Give_f (void)
}
}
break;
case 'r':
if (rogue)
{
@ -1889,6 +1902,7 @@ void Host_Give_f (void)
sv_player->v.ammo_rockets = v;
}
break;
case 'm':
if (rogue)
{
@ -1901,9 +1915,11 @@ void Host_Give_f (void)
}
}
break;
case 'h':
sv_player->v.health = v;
break;
case 'c':
if (rogue)
{
@ -1920,6 +1936,7 @@ void Host_Give_f (void)
sv_player->v.ammo_cells = v;
}
break;
case 'p':
if (rogue)
{
@ -1932,25 +1949,32 @@ void Host_Give_f (void)
}
}
break;
//johnfitz -- give armour
case 'a':
if (v > 150)
{
sv_player->v.armortype = 0.8;
sv_player->v.armorvalue = v;
sv_player->v.items = sv_player->v.items - ((int)(sv_player->v.items) & (int)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3;
sv_player->v.items = sv_player->v.items -
((int)(sv_player->v.items) & (int)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) +
IT_ARMOR3;
}
else if (v > 100)
{
sv_player->v.armortype = 0.6;
sv_player->v.armorvalue = v;
sv_player->v.items = sv_player->v.items - ((int)(sv_player->v.items) & (int)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR2;
sv_player->v.items = sv_player->v.items -
((int)(sv_player->v.items) & (int)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) +
IT_ARMOR2;
}
else if (v >= 0)
{
sv_player->v.armortype = 0.3;
sv_player->v.armorvalue = v;
sv_player->v.items = sv_player->v.items - ((int)(sv_player->v.items) & (int)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR1;
sv_player->v.items = sv_player->v.items -
((int)(sv_player->v.items) & (int)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) +
IT_ARMOR1;
}
break;
//johnfitz
@ -2051,7 +2075,7 @@ void Host_Viewframe_f (void)
f = atoi(Cmd_Argv(1));
if (f >= m->numframes)
f = m->numframes-1;
f = m->numframes - 1;
e->v.frame = f;
}
@ -2144,7 +2168,7 @@ void Host_Startdemos_f (void)
}
Con_Printf ("%i demo(s) in loop\n", c);
for (i=1 ; i<c+1 ; i++)
for (i = 1; i < c + 1; i++)
strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
@ -2254,3 +2278,4 @@ void Host_InitCommands (void)
Cmd_AddCommand ("mcache", Mod_Print);
}

View file

@ -422,7 +422,7 @@ void M_SinglePlayer_Key (int key)
int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES
#define MAX_SAVEGAMES 20 //johnfitz -- increased from 12
#define MAX_SAVEGAMES 20 /* johnfitz -- increased from 12 */
char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
int loadable[MAX_SAVEGAMES];
@ -433,7 +433,7 @@ void M_ScanSaves (void)
FILE *f;
int version;
for (i=0 ; i<MAX_SAVEGAMES ; i++)
for (i = 0; i < MAX_SAVEGAMES; i++)
{
strcpy (m_filenames[i], "--- UNUSED SLOT ---");
loadable[i] = false;
@ -446,9 +446,11 @@ void M_ScanSaves (void)
strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
// change _ back to space
for (j=0 ; j<SAVEGAME_COMMENT_LENGTH ; j++)
for (j = 0; j < SAVEGAME_COMMENT_LENGTH; j++)
{
if (m_filenames[i][j] == '_')
m_filenames[i][j] = ' ';
}
loadable[i] = true;
fclose (f);
}
@ -490,7 +492,7 @@ void M_Load_Draw (void)
p = Draw_CachePic ("gfx/p_load.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
for (i=0 ; i< MAX_SAVEGAMES; i++)
for (i = 0; i < MAX_SAVEGAMES; i++)
M_Print (16, 32 + 8*i, m_filenames[i]);
// line cursor
@ -506,7 +508,7 @@ void M_Save_Draw (void)
p = Draw_CachePic ("gfx/p_save.lmp");
M_DrawPic ( (320-p->width)/2, 4, p);
for (i=0 ; i<MAX_SAVEGAMES ; i++)
for (i = 0; i < MAX_SAVEGAMES; i++)
M_Print (16, 32 + 8*i, m_filenames[i]);
// line cursor
@ -1172,7 +1174,7 @@ void M_DrawSlider (int x, int y, float range)
if (range > 1)
range = 1;
M_DrawCharacter (x-8, y, 128);
for (i=0 ; i<SLIDER_RANGE ; i++)
for (i = 0; i < SLIDER_RANGE; i++)
M_DrawCharacter (x + i*8, y, 129);
M_DrawCharacter (x+i*8, y, 130);
M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
@ -1337,24 +1339,24 @@ void M_Options_Key (int k)
char *bindnames[][2] =
{
{"+attack", "attack"},
{"impulse 10", "change weapon"},
{"+jump", "jump / swim up"},
{"+forward", "walk forward"},
{"+back", "backpedal"},
{"+left", "turn left"},
{"+right", "turn right"},
{"+speed", "run"},
{"+moveleft", "step left"},
{"+moveright", "step right"},
{"+strafe", "sidestep"},
{"+lookup", "look up"},
{"+lookdown", "look down"},
{"centerview", "center view"},
{"+mlook", "mouse look"},
{"+klook", "keyboard look"},
{"+moveup", "swim up"},
{"+movedown", "swim down"}
{"+attack", "attack"},
{"impulse 10", "change weapon"},
{"+jump", "jump / swim up"},
{"+forward", "walk forward"},
{"+back", "backpedal"},
{"+left", "turn left"},
{"+right", "turn right"},
{"+speed", "run"},
{"+moveleft", "step left"},
{"+moveright", "step right"},
{"+strafe", "sidestep"},
{"+lookup", "look up"},
{"+lookdown", "look down"},
{"centerview", "center view"},
{"+mlook", "mouse look"},
{"+klook", "keyboard look"},
{"+moveup", "swim up"},
{"+movedown", "swim down"}
};
#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
@ -1382,7 +1384,7 @@ void M_FindKeysForCommand (char *command, int *twokeys)
l = strlen(command);
count = 0;
for (j=0 ; j<256 ; j++)
for (j = 0; j < 256; j++)
{
b = keybindings[j];
if (!b)
@ -1405,7 +1407,7 @@ void M_UnbindCommand (char *command)
l = strlen(command);
for (j=0 ; j<256 ; j++)
for (j = 0; j < 256; j++)
{
b = keybindings[j];
if (!b)
@ -1433,7 +1435,7 @@ void M_Keys_Draw (void)
M_Print (18, 32, "Enter to change, backspace to clear");
// search for known bindings
for (i=0 ; i<NUMCOMMANDS ; i++)
for (i = 0; i < NUMCOMMANDS; i++)
{
y = 48 + 8*i;
@ -1715,8 +1717,10 @@ void M_Menu_SerialConfig_f (void)
// map uart's port to COMx
for (n = 0; n < 4; n++)
{
if (ISA_uarts[n] == port)
break;
}
if (n == 4)
{
n = 0;
@ -1726,8 +1730,10 @@ void M_Menu_SerialConfig_f (void)
// map baudrate to index
for (n = 0; n < 6; n++)
{
if (serialConfig_baudrate[n] == baudrate)
break;
}
if (n == 6)
n = 5;
serialConfig_baud = n;
@ -2596,23 +2602,23 @@ void M_GameOptions_Draw (void)
M_Print (160, 96, va("%i minutes", (int)timelimit.value));
M_Print (0, 112, " Episode");
//MED 01/06/97 added hipnotic episodes
// MED 01/06/97 added hipnotic episodes
if (hipnotic)
M_Print (160, 112, hipnoticepisodes[startepisode].description);
//PGM 01/07/97 added rogue episodes
// PGM 01/07/97 added rogue episodes
else if (rogue)
M_Print (160, 112, rogueepisodes[startepisode].description);
else
M_Print (160, 112, episodes[startepisode].description);
M_Print (0, 120, " Level");
//MED 01/06/97 added hipnotic episodes
// MED 01/06/97 added hipnotic episodes
if (hipnotic)
{
M_Print (160, 120, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].description);
M_Print (160, 128, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name);
}
//PGM 01/07/97 added rogue episodes
// PGM 01/07/97 added rogue episodes
else if (rogue)
{
M_Print (160, 120, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].description);
@ -2903,7 +2909,9 @@ void M_ServerList_Draw (void)
int i,j;
hostcache_t temp;
for (i = 0; i < hostCacheCount; i++)
for (j = i+1; j < hostCacheCount; j++)
{
for (j = i + 1; j < hostCacheCount; j++)
{
if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
{
Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
@ -2911,6 +2919,8 @@ void M_ServerList_Draw (void)
Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
}
}
}
}
slist_sorted = true;
}
@ -3199,7 +3209,6 @@ void M_Keydown (int key)
void M_ConfigureNetSubsystem(void)
{
// enable/disable net systems to match desired config
Cbuf_AddText ("stopdemo\n");
if (SerialConfig || DirectConfig)
{
@ -3209,3 +3218,4 @@ void M_ConfigureNetSubsystem(void)
if (IPXConfig || TCPIPConfig)
net_hostport = lanConfig_port;
}