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

@ -62,22 +62,22 @@ void Host_Quit_f (void)
// Declarations shared with common.c: // Declarations shared with common.c:
typedef struct typedef struct
{ {
char name[MAX_QPATH]; char name[MAX_QPATH];
int filepos, filelen; int filepos, filelen;
} packfile_t; } packfile_t;
typedef struct pack_s typedef struct pack_s
{ {
char filename[MAX_OSPATH]; char filename[MAX_OSPATH];
int handle; int handle;
int numfiles; int numfiles;
packfile_t *files; packfile_t *files;
} pack_t; } pack_t;
typedef struct searchpath_s typedef struct searchpath_s
{ {
char filename[MAX_OSPATH]; char filename[MAX_OSPATH];
pack_t *pack; // only one of filename / pack will be used pack_t *pack; // only one of filename / pack will be used
struct searchpath_s *next; struct searchpath_s *next;
} searchpath_t; } searchpath_t;
@ -184,7 +184,7 @@ void Host_Game_f (void)
sprintf (pakfile, "%s/pak%i.pak", com_gamedir, i); sprintf (pakfile, "%s/pak%i.pak", com_gamedir, i);
pak = COM_LoadPackFile (pakfile); pak = COM_LoadPackFile (pakfile);
if (!pak) if (!pak)
break; break;
search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t)); search = (searchpath_t *) Z_Malloc(sizeof(searchpath_t));
search->pack = pak; search->pack = pak;
search->next = com_searchpaths; search->next = com_searchpaths;
@ -215,7 +215,7 @@ void Host_Game_f (void)
typedef struct extralevel_s typedef struct extralevel_s
{ {
char name[32]; char name[32];
struct extralevel_s *next; struct extralevel_s *next;
} extralevel_t; } extralevel_t;
@ -225,49 +225,53 @@ void ExtraMaps_Add (char *name)
{ {
extralevel_t *level,*cursor,*prev; extralevel_t *level,*cursor,*prev;
//ingore duplicate // ignore duplicate
for (level = extralevels; level; level = level->next) for (level = extralevels; level; level = level->next)
{
if (!Q_strcmp (name, level->name)) if (!Q_strcmp (name, level->name))
return; return;
}
level = (extralevel_t *) Z_Malloc(sizeof(extralevel_t)); level = (extralevel_t *) Z_Malloc(sizeof(extralevel_t));
strcpy (level->name, name); strcpy (level->name, name);
//insert each entry in alphabetical order // insert each entry in alphabetical order
if (extralevels == NULL || Q_strcasecmp(level->name, extralevels->name) < 0) //insert at front if (extralevels == NULL ||
Q_strcasecmp(level->name, extralevels->name) < 0) //insert at front
{ {
level->next = extralevels; level->next = extralevels;
extralevels = level; extralevels = level;
} }
else //insert later else //insert later
{ {
prev = extralevels; prev = extralevels;
cursor = extralevels->next; cursor = extralevels->next;
while (cursor && (Q_strcasecmp(level->name, cursor->name) > 0)) while (cursor && (Q_strcasecmp(level->name, cursor->name) > 0))
{ {
prev = cursor; prev = cursor;
cursor = cursor->next; cursor = cursor->next;
} }
level->next = prev->next; level->next = prev->next;
prev->next = level; prev->next = level;
} }
} }
void ExtraMaps_Init (void) void ExtraMaps_Init (void)
{ {
DIR *dir_p; DIR *dir_p;
struct dirent *dir_t; struct dirent *dir_t;
char filestring[MAX_OSPATH]; char filestring[MAX_OSPATH];
char mapname[32]; char mapname[32];
char ignorepakdir[32]; char ignorepakdir[32];
searchpath_t *search; searchpath_t *search;
pack_t *pak; pack_t *pak;
int i; 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); sprintf (ignorepakdir, "/%s/", GAMENAME);
for (search = com_searchpaths ; search ; search = search->next) for (search = com_searchpaths; search; search = search->next)
{ {
if (*search->filename) //directory if (*search->filename) //directory
{ {
@ -286,14 +290,14 @@ void ExtraMaps_Init (void)
} }
else //pakfile else //pakfile
{ {
if (!strstr(search->pack->filename, ignorepakdir)) //don't list standard id maps if (!strstr(search->pack->filename, ignorepakdir))
{ { //don't list standard id maps
for (i=0, pak=search->pack; i<pak->numfiles ; i++) for (i = 0, pak = search->pack; i < pak->numfiles; i++)
{ {
if (strstr(pak->files[i].name, ".bsp")) 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); COM_StripExtension(pak->files[i].name + 5, mapname);
ExtraMaps_Add (mapname); ExtraMaps_Add (mapname);
} }
@ -332,7 +336,7 @@ void Host_Maps_f (void)
int i; int i;
extralevel_t *level; 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); Con_SafePrintf (" %s\n", level->name);
if (i) if (i)
@ -347,7 +351,7 @@ void Host_Maps_f (void)
typedef struct mod_s typedef struct mod_s
{ {
char name[MAX_OSPATH]; char name[MAX_OSPATH];
struct mod_s *next; struct mod_s *next;
} mod_t; } mod_t;
@ -359,30 +363,33 @@ void Modlist_Add (char *name)
//ingore duplicate //ingore duplicate
for (mod = modlist; mod; mod = mod->next) for (mod = modlist; mod; mod = mod->next)
{
if (!Q_strcmp (name, mod->name)) if (!Q_strcmp (name, mod->name))
return; return;
}
mod = (mod_t *) Z_Malloc(sizeof(mod_t)); mod = (mod_t *) Z_Malloc(sizeof(mod_t));
strcpy (mod->name, name); strcpy (mod->name, name);
//insert each entry in alphabetical order //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; mod->next = modlist;
modlist = mod; modlist = mod;
} }
else //insert later else //insert later
{ {
prev = modlist; prev = modlist;
cursor = modlist->next; cursor = modlist->next;
while (cursor && (Q_strcasecmp(mod->name, cursor->name) > 0)) while (cursor && (Q_strcasecmp(mod->name, cursor->name) > 0))
{ {
prev = cursor; prev = cursor;
cursor = cursor->next; cursor = cursor->next;
} }
mod->next = prev->next; mod->next = prev->next;
prev->next = mod; prev->next = mod;
} }
} }
void Modlist_Init (void) void Modlist_Init (void)
@ -390,7 +397,7 @@ void Modlist_Init (void)
DIR *dir_p, *mod_dir_p; DIR *dir_p, *mod_dir_p;
struct dirent *dir_t, *mod_dir_t; struct dirent *dir_t, *mod_dir_t;
qboolean progs_found, pak_found; qboolean progs_found, pak_found;
char dir_string[MAX_OSPATH], mod_dir_string[MAX_OSPATH]; char dir_string[MAX_OSPATH], mod_dir_string[MAX_OSPATH];
int i; int i;
i = COM_CheckParm ("-basedir"); i = COM_CheckParm ("-basedir");
@ -513,7 +520,7 @@ void Host_Status_f (void)
print_fn ("ipx: %s\n", my_ipx_address); print_fn ("ipx: %s\n", my_ipx_address);
print_fn ("map: %s\n", sv.name); print_fn ("map: %s\n", sv.name);
print_fn ("players: %i active (%i max)\n\n", net_activeconnections, svs.maxclients); 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) if (!client->active)
continue; continue;
@ -743,7 +750,7 @@ Host_Ping_f
void Host_Ping_f (void) void Host_Ping_f (void)
{ {
int i, j; int i, j;
float total; float total;
client_t *client; client_t *client;
if (cmd_source == src_command) if (cmd_source == src_command)
@ -753,12 +760,12 @@ void Host_Ping_f (void)
} }
SV_ClientPrintf ("Client ping times:\n"); 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) if (!client->active)
continue; continue;
total = 0; total = 0;
for (j=0 ; j<NUM_PING_TIMES ; j++) for (j = 0; j < NUM_PING_TIMES; j++)
total+=client->ping_times[j]; total+=client->ping_times[j];
total /= NUM_PING_TIMES; total /= NUM_PING_TIMES;
SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name); SV_ClientPrintf ("%4i %s\n", (int)(total*1000), client->name);
@ -822,7 +829,7 @@ void Host_Map_f (void)
SCR_BeginLoadingPlaque (); SCR_BeginLoadingPlaque ();
cls.mapstring[0] = 0; 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, Cmd_Argv(i));
strcat (cls.mapstring, " "); strcat (cls.mapstring, " ");
@ -839,7 +846,7 @@ void Host_Map_f (void)
{ {
strcpy (cls.spawnparms, ""); 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, Cmd_Argv(i));
strcat (cls.spawnparms, " "); strcat (cls.spawnparms, " ");
@ -966,15 +973,17 @@ void Host_SavegameComment (char *text)
int i; int i;
char kills[20]; char kills[20];
for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++) for (i = 0; i < SAVEGAME_COMMENT_LENGTH; i++)
text[i] = ' '; text[i] = ' ';
memcpy (text, cl.levelname, min(strlen(cl.levelname),22)); //johnfitz -- only copy 22 chars. 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]); sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
memcpy (text+22, kills, strlen(kills)); memcpy (text+22, kills, strlen(kills));
// convert space to _ to make stdio happy // 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] == ' ') if (text[i] == ' ')
text[i] = '_'; text[i] = '_';
}
text[SAVEGAME_COMMENT_LENGTH] = '\0'; text[SAVEGAME_COMMENT_LENGTH] = '\0';
} }
@ -988,7 +997,7 @@ void Host_Savegame_f (void)
{ {
char name[256]; char name[256];
FILE *f; FILE *f;
int i; int i;
char comment[SAVEGAME_COMMENT_LENGTH+1]; char comment[SAVEGAME_COMMENT_LENGTH+1];
if (cmd_source != src_command) if (cmd_source != src_command)
@ -1047,7 +1056,7 @@ void Host_Savegame_f (void)
fprintf (f, "%i\n", SAVEGAME_VERSION); fprintf (f, "%i\n", SAVEGAME_VERSION);
Host_SavegameComment (comment); Host_SavegameComment (comment);
fprintf (f, "%s\n", 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, "%f\n", svs.clients->spawn_parms[i]);
fprintf (f, "%d\n", current_skill); fprintf (f, "%d\n", current_skill);
fprintf (f, "%s\n", sv.name); fprintf (f, "%s\n", sv.name);
@ -1055,7 +1064,7 @@ void Host_Savegame_f (void)
// write the light styles // write the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++) for (i = 0; i < MAX_LIGHTSTYLES; i++)
{ {
if (sv.lightstyles[i]) if (sv.lightstyles[i])
fprintf (f, "%s\n", sv.lightstyles[i]); fprintf (f, "%s\n", sv.lightstyles[i]);
@ -1065,7 +1074,7 @@ void Host_Savegame_f (void)
ED_WriteGlobals (f); 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)); ED_Write (f, EDICT_NUM(i));
fflush (f); fflush (f);
@ -1087,11 +1096,11 @@ void Host_Loadgame_f (void)
char mapname[MAX_QPATH]; char mapname[MAX_QPATH];
float time, tfloat; float time, tfloat;
char str[32768], *start; char str[32768], *start;
int i, r; int i, r;
edict_t *ent; edict_t *ent;
int entnum; int entnum;
int version; int version;
float spawn_parms[NUM_SPAWN_PARMS]; float spawn_parms[NUM_SPAWN_PARMS];
if (cmd_source != src_command) if (cmd_source != src_command)
return; return;
@ -1127,7 +1136,7 @@ void Host_Loadgame_f (void)
return; return;
} }
fscanf (f, "%s\n", str); 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]); fscanf (f, "%f\n", &spawn_parms[i]);
// this silliness is so we can load 1.06 save files, which have float skill values // this silliness is so we can load 1.06 save files, which have float skill values
fscanf (f, "%f\n", &tfloat); fscanf (f, "%f\n", &tfloat);
@ -1151,7 +1160,7 @@ void Host_Loadgame_f (void)
// load the light styles // load the light styles
for (i=0 ; i<MAX_LIGHTSTYLES ; i++) for (i = 0; i < MAX_LIGHTSTYLES; i++)
{ {
fscanf (f, "%s\n", str); fscanf (f, "%s\n", str);
sv.lightstyles[i] = (char *) Hunk_Alloc (strlen(str)+1); sv.lightstyles[i] = (char *) Hunk_Alloc (strlen(str)+1);
@ -1162,7 +1171,7 @@ void Host_Loadgame_f (void)
entnum = -1; // -1 is the globals entnum = -1; // -1 is the globals
while (!feof(f)) while (!feof(f))
{ {
for (i=0 ; i<sizeof(str)-1 ; i++) for (i = 0; i < sizeof(str) - 1; i++)
{ {
r = fgetc (f); r = fgetc (f);
if (r == EOF || !r) if (r == EOF || !r)
@ -1174,7 +1183,7 @@ void Host_Loadgame_f (void)
break; break;
} }
} }
if (i == sizeof(str)-1) if (i == sizeof(str) - 1)
Sys_Error ("Loadgame buffer overflow"); Sys_Error ("Loadgame buffer overflow");
str[i] = 0; str[i] = 0;
start = str; start = str;
@ -1209,7 +1218,7 @@ void Host_Loadgame_f (void)
fclose (f); 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]; svs.clients->spawn_parms[i] = spawn_parms[i];
if (cls.state != ca_dedicated) 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 (host_client->name[0] && strcmp(host_client->name, "unconnected") )
{
if (Q_strcmp(host_client->name, newName) != 0) if (Q_strcmp(host_client->name, newName) != 0)
Con_Printf ("%s renamed to %s\n", host_client->name, newName); Con_Printf ("%s renamed to %s\n", host_client->name, newName);
}
Q_strcpy (host_client->name, newName); Q_strcpy (host_client->name, newName);
host_client->edict->v.netname = PR_SetEngineString(host_client->name); host_client->edict->v.netname = PR_SetEngineString(host_client->name);
@ -1353,7 +1364,7 @@ void Host_Tell_f(void)
{ {
client_t *client; client_t *client;
client_t *save; client_t *save;
int j; int j;
char *p; char *p;
char text[MAXCMDLINE]; char text[MAXCMDLINE];
@ -1603,7 +1614,7 @@ void Host_Spawn_f (void)
MSG_WriteByte (&host_client->message, svc_time); MSG_WriteByte (&host_client->message, svc_time);
MSG_WriteFloat (&host_client->message, sv.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, svc_updatename);
MSG_WriteByte (&host_client->message, i); MSG_WriteByte (&host_client->message, i);
@ -1617,7 +1628,7 @@ void Host_Spawn_f (void)
} }
// send all current light styles // 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, svc_lightstyle);
MSG_WriteByte (&host_client->message, (char)i); MSG_WriteByte (&host_client->message, (char)i);
@ -1652,7 +1663,7 @@ void Host_Spawn_f (void)
// with a permanent head tilt // with a permanent head tilt
ent = EDICT_NUM( 1 + (host_client - svs.clients) ); ent = EDICT_NUM( 1 + (host_client - svs.clients) );
MSG_WriteByte (&host_client->message, svc_setangle); 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, ent->v.angles[i] );
MSG_WriteAngle (&host_client->message, 0 ); MSG_WriteAngle (&host_client->message, 0 );
@ -1694,7 +1705,7 @@ void Host_Kick_f (void)
char *who; char *who;
char *message = NULL; char *message = NULL;
client_t *save; client_t *save;
int i; int i;
qboolean byNumber = false; qboolean byNumber = false;
if (cmd_source == src_command) if (cmd_source == src_command)
@ -1784,7 +1795,7 @@ Host_Give_f
void Host_Give_f (void) void Host_Give_f (void)
{ {
char *t; char *t;
int v; int v;
eval_t *val; eval_t *val;
if (cmd_source == src_command) if (cmd_source == src_command)
@ -1801,160 +1812,173 @@ void Host_Give_f (void)
switch (t[0]) switch (t[0])
{ {
case '0': case '0':
case '1': case '1':
case '2': case '2':
case '3': case '3':
case '4': case '4':
case '5': case '5':
case '6': case '6':
case '7': case '7':
case '8': case '8':
case '9': case '9':
// MED 01/04/97 added hipnotic give stuff // MED 01/04/97 added hipnotic give stuff
if (hipnotic) if (hipnotic)
{ {
if (t[0] == '6') if (t[0] == '6')
{ {
if (t[1] == 'a') if (t[1] == 'a')
sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN; sv_player->v.items = (int)sv_player->v.items | HIT_PROXIMITY_GUN;
else else
sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER; sv_player->v.items = (int)sv_player->v.items | IT_GRENADE_LAUNCHER;
} }
else if (t[0] == '9') else if (t[0] == '9')
sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON; sv_player->v.items = (int)sv_player->v.items | HIT_LASER_CANNON;
else if (t[0] == '0') else if (t[0] == '0')
sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR; sv_player->v.items = (int)sv_player->v.items | HIT_MJOLNIR;
else if (t[0] >= '2') else if (t[0] >= '2')
sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
} }
else else
{ {
if (t[0] >= '2') if (t[0] >= '2')
sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2')); sv_player->v.items = (int)sv_player->v.items | (IT_SHOTGUN << (t[0] - '2'));
} }
break; break;
case 's': case 's':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_shells1"); val = GetEdictFieldValue(sv_player, "ammo_shells1");
if (val) if (val)
val->_float = v; val->_float = v;
} }
sv_player->v.ammo_shells = v;
break;
sv_player->v.ammo_shells = v; case 'n':
break;
case 'n':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_nails1"); val = GetEdictFieldValue(sv_player, "ammo_nails1");
if (val) if (val)
{ {
val->_float = v; val->_float = v;
if (sv_player->v.weapon <= IT_LIGHTNING) if (sv_player->v.weapon <= IT_LIGHTNING)
sv_player->v.ammo_nails = v; sv_player->v.ammo_nails = v;
} }
} }
else else
{ {
sv_player->v.ammo_nails = v; sv_player->v.ammo_nails = v;
} }
break; break;
case 'l':
case 'l':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_lava_nails"); val = GetEdictFieldValue(sv_player, "ammo_lava_nails");
if (val) if (val)
{ {
val->_float = v; val->_float = v;
if (sv_player->v.weapon > IT_LIGHTNING) if (sv_player->v.weapon > IT_LIGHTNING)
sv_player->v.ammo_nails = v; sv_player->v.ammo_nails = v;
} }
} }
break; break;
case 'r':
case 'r':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_rockets1"); val = GetEdictFieldValue(sv_player, "ammo_rockets1");
if (val) if (val)
{ {
val->_float = v; val->_float = v;
if (sv_player->v.weapon <= IT_LIGHTNING) if (sv_player->v.weapon <= IT_LIGHTNING)
sv_player->v.ammo_rockets = v; sv_player->v.ammo_rockets = v;
} }
} }
else else
{ {
sv_player->v.ammo_rockets = v; sv_player->v.ammo_rockets = v;
} }
break; break;
case 'm':
case 'm':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_multi_rockets"); val = GetEdictFieldValue(sv_player, "ammo_multi_rockets");
if (val) if (val)
{ {
val->_float = v; val->_float = v;
if (sv_player->v.weapon > IT_LIGHTNING) if (sv_player->v.weapon > IT_LIGHTNING)
sv_player->v.ammo_rockets = v; sv_player->v.ammo_rockets = v;
} }
} }
break; break;
case 'h':
sv_player->v.health = v; case 'h':
break; sv_player->v.health = v;
case 'c': break;
case 'c':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_cells1"); val = GetEdictFieldValue(sv_player, "ammo_cells1");
if (val) if (val)
{ {
val->_float = v; val->_float = v;
if (sv_player->v.weapon <= IT_LIGHTNING) if (sv_player->v.weapon <= IT_LIGHTNING)
sv_player->v.ammo_cells = v; sv_player->v.ammo_cells = v;
} }
} }
else else
{ {
sv_player->v.ammo_cells = v; sv_player->v.ammo_cells = v;
} }
break; break;
case 'p':
case 'p':
if (rogue) if (rogue)
{ {
val = GetEdictFieldValue(sv_player, "ammo_plasma"); val = GetEdictFieldValue(sv_player, "ammo_plasma");
if (val) if (val)
{ {
val->_float = v; val->_float = v;
if (sv_player->v.weapon > IT_LIGHTNING) if (sv_player->v.weapon > IT_LIGHTNING)
sv_player->v.ammo_cells = v; sv_player->v.ammo_cells = v;
} }
} }
break; break;
//johnfitz -- give armour //johnfitz -- give armour
case 'a': case 'a':
if (v > 150) if (v > 150)
{ {
sv_player->v.armortype = 0.8; sv_player->v.armortype = 0.8;
sv_player->v.armorvalue = v; 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) else if (v > 100)
{ {
sv_player->v.armortype = 0.6; sv_player->v.armortype = 0.6;
sv_player->v.armorvalue = v; 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) else if (v >= 0)
{ {
sv_player->v.armortype = 0.3; sv_player->v.armortype = 0.3;
sv_player->v.armorvalue = v; 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; break;
//johnfitz //johnfitz
} }
//johnfitz -- update currentammo to match new ammo (so statusbar updates correctly) //johnfitz -- update currentammo to match new ammo (so statusbar updates correctly)
switch ((int)(sv_player->v.weapon)) switch ((int)(sv_player->v.weapon))
@ -2051,7 +2075,7 @@ void Host_Viewframe_f (void)
f = atoi(Cmd_Argv(1)); f = atoi(Cmd_Argv(1));
if (f >= m->numframes) if (f >= m->numframes)
f = m->numframes-1; f = m->numframes - 1;
e->v.frame = f; e->v.frame = f;
} }
@ -2144,7 +2168,7 @@ void Host_Startdemos_f (void)
} }
Con_Printf ("%i demo(s) in loop\n", c); 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); strncpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])-1);
if (!sv.active && cls.demonum != -1 && !cls.demoplayback) if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
@ -2254,3 +2278,4 @@ void Host_InitCommands (void)
Cmd_AddCommand ("mcache", Mod_Print); Cmd_AddCommand ("mcache", Mod_Print);
} }

View File

@ -422,18 +422,18 @@ void M_SinglePlayer_Key (int key)
int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES 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]; char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1];
int loadable[MAX_SAVEGAMES]; int loadable[MAX_SAVEGAMES];
void M_ScanSaves (void) void M_ScanSaves (void)
{ {
int i, j; int i, j;
char name[MAX_OSPATH]; char name[MAX_OSPATH];
FILE *f; FILE *f;
int version; int version;
for (i=0 ; i<MAX_SAVEGAMES ; i++) for (i = 0; i < MAX_SAVEGAMES; i++)
{ {
strcpy (m_filenames[i], "--- UNUSED SLOT ---"); strcpy (m_filenames[i], "--- UNUSED SLOT ---");
loadable[i] = false; loadable[i] = false;
@ -446,9 +446,11 @@ void M_ScanSaves (void)
strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1); strncpy (m_filenames[i], name, sizeof(m_filenames[i])-1);
// change _ back to space // 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] == '_') if (m_filenames[i][j] == '_')
m_filenames[i][j] = ' '; m_filenames[i][j] = ' ';
}
loadable[i] = true; loadable[i] = true;
fclose (f); fclose (f);
} }
@ -490,7 +492,7 @@ void M_Load_Draw (void)
p = Draw_CachePic ("gfx/p_load.lmp"); p = Draw_CachePic ("gfx/p_load.lmp");
M_DrawPic ( (320-p->width)/2, 4, p); 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]); M_Print (16, 32 + 8*i, m_filenames[i]);
// line cursor // line cursor
@ -506,7 +508,7 @@ void M_Save_Draw (void)
p = Draw_CachePic ("gfx/p_save.lmp"); p = Draw_CachePic ("gfx/p_save.lmp");
M_DrawPic ( (320-p->width)/2, 4, p); 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]); M_Print (16, 32 + 8*i, m_filenames[i]);
// line cursor // line cursor
@ -1172,7 +1174,7 @@ void M_DrawSlider (int x, int y, float range)
if (range > 1) if (range > 1)
range = 1; range = 1;
M_DrawCharacter (x-8, y, 128); 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, 129);
M_DrawCharacter (x+i*8, y, 130); M_DrawCharacter (x+i*8, y, 130);
M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131); M_DrawCharacter (x + (SLIDER_RANGE-1)*8 * range, y, 131);
@ -1337,24 +1339,24 @@ void M_Options_Key (int k)
char *bindnames[][2] = char *bindnames[][2] =
{ {
{"+attack", "attack"}, {"+attack", "attack"},
{"impulse 10", "change weapon"}, {"impulse 10", "change weapon"},
{"+jump", "jump / swim up"}, {"+jump", "jump / swim up"},
{"+forward", "walk forward"}, {"+forward", "walk forward"},
{"+back", "backpedal"}, {"+back", "backpedal"},
{"+left", "turn left"}, {"+left", "turn left"},
{"+right", "turn right"}, {"+right", "turn right"},
{"+speed", "run"}, {"+speed", "run"},
{"+moveleft", "step left"}, {"+moveleft", "step left"},
{"+moveright", "step right"}, {"+moveright", "step right"},
{"+strafe", "sidestep"}, {"+strafe", "sidestep"},
{"+lookup", "look up"}, {"+lookup", "look up"},
{"+lookdown", "look down"}, {"+lookdown", "look down"},
{"centerview", "center view"}, {"centerview", "center view"},
{"+mlook", "mouse look"}, {"+mlook", "mouse look"},
{"+klook", "keyboard look"}, {"+klook", "keyboard look"},
{"+moveup", "swim up"}, {"+moveup", "swim up"},
{"+movedown", "swim down"} {"+movedown", "swim down"}
}; };
#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0])) #define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0]))
@ -1382,7 +1384,7 @@ void M_FindKeysForCommand (char *command, int *twokeys)
l = strlen(command); l = strlen(command);
count = 0; count = 0;
for (j=0 ; j<256 ; j++) for (j = 0; j < 256; j++)
{ {
b = keybindings[j]; b = keybindings[j];
if (!b) if (!b)
@ -1405,7 +1407,7 @@ void M_UnbindCommand (char *command)
l = strlen(command); l = strlen(command);
for (j=0 ; j<256 ; j++) for (j = 0; j < 256; j++)
{ {
b = keybindings[j]; b = keybindings[j];
if (!b) if (!b)
@ -1420,7 +1422,7 @@ void M_Keys_Draw (void)
{ {
int i, l; int i, l;
int keys[2]; int keys[2];
char *name; char *name;
int x, y; int x, y;
qpic_t *p; qpic_t *p;
@ -1433,7 +1435,7 @@ void M_Keys_Draw (void)
M_Print (18, 32, "Enter to change, backspace to clear"); M_Print (18, 32, "Enter to change, backspace to clear");
// search for known bindings // search for known bindings
for (i=0 ; i<NUMCOMMANDS ; i++) for (i = 0; i < NUMCOMMANDS; i++)
{ {
y = 48 + 8*i; y = 48 + 8*i;
@ -1715,8 +1717,10 @@ void M_Menu_SerialConfig_f (void)
// map uart's port to COMx // map uart's port to COMx
for (n = 0; n < 4; n++) for (n = 0; n < 4; n++)
{
if (ISA_uarts[n] == port) if (ISA_uarts[n] == port)
break; break;
}
if (n == 4) if (n == 4)
{ {
n = 0; n = 0;
@ -1726,8 +1730,10 @@ void M_Menu_SerialConfig_f (void)
// map baudrate to index // map baudrate to index
for (n = 0; n < 6; n++) for (n = 0; n < 6; n++)
{
if (serialConfig_baudrate[n] == baudrate) if (serialConfig_baudrate[n] == baudrate)
break; break;
}
if (n == 6) if (n == 6)
n = 5; n = 5;
serialConfig_baud = n; serialConfig_baud = n;
@ -1740,7 +1746,7 @@ void M_Menu_SerialConfig_f (void)
void M_SerialConfig_Draw (void) void M_SerialConfig_Draw (void)
{ {
qpic_t *p; qpic_t *p;
int basex; int basex;
char *startJoin; char *startJoin;
char *directModem; char *directModem;
@ -2412,29 +2418,29 @@ level_t levels[] =
//MED 01/06/97 added hipnotic levels //MED 01/06/97 added hipnotic levels
level_t hipnoticlevels[] = level_t hipnoticlevels[] =
{ {
{"start", "Command HQ"}, // 0 {"start", "Command HQ"}, // 0
{"hip1m1", "The Pumping Station"}, // 1 {"hip1m1", "The Pumping Station"}, // 1
{"hip1m2", "Storage Facility"}, {"hip1m2", "Storage Facility"},
{"hip1m3", "The Lost Mine"}, {"hip1m3", "The Lost Mine"},
{"hip1m4", "Research Facility"}, {"hip1m4", "Research Facility"},
{"hip1m5", "Military Complex"}, {"hip1m5", "Military Complex"},
{"hip2m1", "Ancient Realms"}, // 6 {"hip2m1", "Ancient Realms"}, // 6
{"hip2m2", "The Black Cathedral"}, {"hip2m2", "The Black Cathedral"},
{"hip2m3", "The Catacombs"}, {"hip2m3", "The Catacombs"},
{"hip2m4", "The Crypt"}, {"hip2m4", "The Crypt"},
{"hip2m5", "Mortum's Keep"}, {"hip2m5", "Mortum's Keep"},
{"hip2m6", "The Gremlin's Domain"}, {"hip2m6", "The Gremlin's Domain"},
{"hip3m1", "Tur Torment"}, // 12 {"hip3m1", "Tur Torment"}, // 12
{"hip3m2", "Pandemonium"}, {"hip3m2", "Pandemonium"},
{"hip3m3", "Limbo"}, {"hip3m3", "Limbo"},
{"hip3m4", "The Gauntlet"}, {"hip3m4", "The Gauntlet"},
{"hipend", "Armagon's Lair"}, // 16 {"hipend", "Armagon's Lair"}, // 16
{"hipdm1", "The Edge of Oblivion"} // 17 {"hipdm1", "The Edge of Oblivion"} // 17
}; };
//PGM 01/07/97 added rogue levels //PGM 01/07/97 added rogue levels
@ -2481,12 +2487,12 @@ episode_t episodes[] =
//MED 01/06/97 added hipnotic episodes //MED 01/06/97 added hipnotic episodes
episode_t hipnoticepisodes[] = episode_t hipnoticepisodes[] =
{ {
{"Scourge of Armagon", 0, 1}, {"Scourge of Armagon", 0, 1},
{"Fortress of the Dead", 1, 5}, {"Fortress of the Dead", 1, 5},
{"Dominion of Darkness", 6, 6}, {"Dominion of Darkness", 6, 6},
{"The Rift", 12, 4}, {"The Rift", 12, 4},
{"Final Level", 16, 1}, {"Final Level", 16, 1},
{"Deathmatch Arena", 17, 1} {"Deathmatch Arena", 17, 1}
}; };
//PGM 01/07/97 added rogue episodes //PGM 01/07/97 added rogue episodes
@ -2596,33 +2602,33 @@ void M_GameOptions_Draw (void)
M_Print (160, 96, va("%i minutes", (int)timelimit.value)); M_Print (160, 96, va("%i minutes", (int)timelimit.value));
M_Print (0, 112, " Episode"); M_Print (0, 112, " Episode");
//MED 01/06/97 added hipnotic episodes // MED 01/06/97 added hipnotic episodes
if (hipnotic) if (hipnotic)
M_Print (160, 112, hipnoticepisodes[startepisode].description); M_Print (160, 112, hipnoticepisodes[startepisode].description);
//PGM 01/07/97 added rogue episodes // PGM 01/07/97 added rogue episodes
else if (rogue) else if (rogue)
M_Print (160, 112, rogueepisodes[startepisode].description); M_Print (160, 112, rogueepisodes[startepisode].description);
else else
M_Print (160, 112, episodes[startepisode].description); M_Print (160, 112, episodes[startepisode].description);
M_Print (0, 120, " Level"); M_Print (0, 120, " Level");
//MED 01/06/97 added hipnotic episodes // MED 01/06/97 added hipnotic episodes
if (hipnotic) if (hipnotic)
{ {
M_Print (160, 120, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].description); M_Print (160, 120, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].description);
M_Print (160, 128, hipnoticlevels[hipnoticepisodes[startepisode].firstLevel + startlevel].name); 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) else if (rogue)
{ {
M_Print (160, 120, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].description); M_Print (160, 120, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].description);
M_Print (160, 128, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name); M_Print (160, 128, roguelevels[rogueepisodes[startepisode].firstLevel + startlevel].name);
} }
else else
{ {
M_Print (160, 120, levels[episodes[startepisode].firstLevel + startlevel].description); M_Print (160, 120, levels[episodes[startepisode].firstLevel + startlevel].description);
M_Print (160, 128, levels[episodes[startepisode].firstLevel + startlevel].name); M_Print (160, 128, levels[episodes[startepisode].firstLevel + startlevel].name);
} }
// line cursor // line cursor
M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1)); M_DrawCharacter (144, gameoptions_cursor_table[gameoptions_cursor], 12+((int)(realtime*4)&1));
@ -2731,7 +2737,7 @@ void M_NetStart_Change (int dir)
case 8: case 8:
startlevel += dir; startlevel += dir;
//MED 01/06/97 added hipnotic episodes //MED 01/06/97 added hipnotic episodes
if (hipnotic) if (hipnotic)
count = hipnoticepisodes[startepisode].levels; count = hipnoticepisodes[startepisode].levels;
//PGM 01/06/97 added hipnotic episodes //PGM 01/06/97 added hipnotic episodes
@ -2903,13 +2909,17 @@ void M_ServerList_Draw (void)
int i,j; int i,j;
hostcache_t temp; hostcache_t temp;
for (i = 0; i < hostCacheCount; i++) 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) if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
{ {
Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t)); Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t)); Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t)); Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
} }
}
}
} }
slist_sorted = true; slist_sorted = true;
} }
@ -3199,7 +3209,6 @@ void M_Keydown (int key)
void M_ConfigureNetSubsystem(void) void M_ConfigureNetSubsystem(void)
{ {
// enable/disable net systems to match desired config // enable/disable net systems to match desired config
Cbuf_AddText ("stopdemo\n"); Cbuf_AddText ("stopdemo\n");
if (SerialConfig || DirectConfig) if (SerialConfig || DirectConfig)
{ {
@ -3209,3 +3218,4 @@ void M_ConfigureNetSubsystem(void)
if (IPXConfig || TCPIPConfig) if (IPXConfig || TCPIPConfig)
net_hostport = lanConfig_port; net_hostport = lanConfig_port;
} }