diff options
author | Jack Palevich <jackpal@google.com> | 2009-09-29 14:35:06 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2009-09-29 14:35:06 -0700 |
commit | 7fab267913a64aad55cedfcf1fca21cc09516a43 (patch) | |
tree | 533173befa1f2d10756c0351d3ebf29ddfecd9d9 | |
parent | e4723ae3fe42a079a6f74f3a91c2c6081440d881 (diff) | |
download | quake-7fab267913a64aad55cedfcf1fca21cc09516a43.tar.gz |
Hijack the "Help" menu to run TimeDemo demo1, for easy perf monitoring
-rw-r--r-- | quake/src/WinQuake/cl_demo.cpp | 444 | ||||
-rw-r--r-- | quake/src/WinQuake/cmd.cpp | 770 | ||||
-rw-r--r-- | quake/src/WinQuake/cmd.h | 30 | ||||
-rw-r--r-- | quake/src/WinQuake/menu.cpp | 419 |
4 files changed, 838 insertions, 825 deletions
diff --git a/quake/src/WinQuake/cl_demo.cpp b/quake/src/WinQuake/cl_demo.cpp index f3cbf5b..2208001 100644 --- a/quake/src/WinQuake/cl_demo.cpp +++ b/quake/src/WinQuake/cl_demo.cpp @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -44,16 +44,16 @@ Called when a demo file runs out, or the user starts a game */ void CL_StopPlayback (void) { - if (!cls.demoplayback) - return; + if (!cls.demoplayback) + return; - fclose (cls.demofile); - cls.demoplayback = false; - cls.demofile = NULL; - cls.state = ca_disconnected; + fclose (cls.demofile); + cls.demoplayback = false; + cls.demofile = NULL; + cls.state = ca_disconnected; - if (cls.timedemo) - CL_FinishTimeDemo (); + if (cls.timedemo) + CL_FinishTimeDemo (); } /* @@ -65,19 +65,19 @@ Dumps the current net message, prefixed by the length and view angles */ void CL_WriteDemoMessage (void) { - int len; - int i; - float f; - - len = LittleLong (net_message.cursize); - fwrite (&len, 4, 1, cls.demofile); - for (i=0 ; i<3 ; i++) - { - f = LittleFloat (cl.viewangles[i]); - fwrite (&f, 4, 1, cls.demofile); - } - fwrite (net_message.data, net_message.cursize, 1, cls.demofile); - fflush (cls.demofile); + int len; + int i; + float f; + + len = LittleLong (net_message.cursize); + fwrite (&len, 4, 1, cls.demofile); + for (i=0 ; i<3 ; i++) + { + f = LittleFloat (cl.viewangles[i]); + fwrite (&f, 4, 1, cls.demofile); + } + fwrite (net_message.data, net_message.cursize, 1, cls.demofile); + fflush (cls.demofile); } /* @@ -89,70 +89,70 @@ Handles recording and playback of demos, on top of NET_ code */ int CL_GetMessage (void) { - int r, i; - float f; - - if (cls.demoplayback) - { - // decide if it is time to grab the next message - if (cls.signon == SIGNONS) // allways grab until fully connected - { - if (cls.timedemo) - { - if (host_framecount == cls.td_lastframe) - return 0; // allready read this frame's message - cls.td_lastframe = host_framecount; - // if this is the second frame, grab the real td_starttime - // so the bogus time on the first frame doesn't count - if (host_framecount == cls.td_startframe + 1) - cls.td_starttime = realtime; - } - else if ( /* cl.time > 0 && */ cl.time <= cl.mtime[0]) - { - return 0; // don't need another message yet - } - } - - // get the next message - fread (&net_message.cursize, 4, 1, cls.demofile); - VectorCopy (cl.mviewangles[0], cl.mviewangles[1]); - for (i=0 ; i<3 ; i++) - { - r = fread (&f, 4, 1, cls.demofile); - cl.mviewangles[0][i] = LittleFloat (f); - } - - net_message.cursize = LittleLong (net_message.cursize); - if (net_message.cursize > MAX_MSGLEN) - Sys_Error ("Demo message > MAX_MSGLEN"); - r = fread (net_message.data, net_message.cursize, 1, cls.demofile); - if (r != 1) - { - CL_StopPlayback (); - return 0; - } - - return 1; - } - - while (1) - { - r = NET_GetMessage (cls.netcon); - - if (r != 1 && r != 2) - return r; - - // discard nop keepalive message - if (net_message.cursize == 1 && net_message.data[0] == svc_nop) - Con_Printf ("<-- server to client keepalive\n"); - else - break; - } - - if (cls.demorecording) - CL_WriteDemoMessage (); - - return r; + int r, i; + float f; + + if (cls.demoplayback) + { + // decide if it is time to grab the next message + if (cls.signon == SIGNONS) // allways grab until fully connected + { + if (cls.timedemo) + { + if (host_framecount == cls.td_lastframe) + return 0; // allready read this frame's message + cls.td_lastframe = host_framecount; + // if this is the second frame, grab the real td_starttime + // so the bogus time on the first frame doesn't count + if (host_framecount == cls.td_startframe + 1) + cls.td_starttime = realtime; + } + else if ( /* cl.time > 0 && */ cl.time <= cl.mtime[0]) + { + return 0; // don't need another message yet + } + } + + // get the next message + fread (&net_message.cursize, 4, 1, cls.demofile); + VectorCopy (cl.mviewangles[0], cl.mviewangles[1]); + for (i=0 ; i<3 ; i++) + { + r = fread (&f, 4, 1, cls.demofile); + cl.mviewangles[0][i] = LittleFloat (f); + } + + net_message.cursize = LittleLong (net_message.cursize); + if (net_message.cursize > MAX_MSGLEN) + Sys_Error ("Demo message > MAX_MSGLEN"); + r = fread (net_message.data, net_message.cursize, 1, cls.demofile); + if (r != 1) + { + CL_StopPlayback (); + return 0; + } + + return 1; + } + + while (1) + { + r = NET_GetMessage (cls.netcon); + + if (r != 1 && r != 2) + return r; + + // discard nop keepalive message + if (net_message.cursize == 1 && net_message.data[0] == svc_nop) + Con_Printf ("<-- server to client keepalive\n"); + else + break; + } + + if (cls.demorecording) + CL_WriteDemoMessage (); + + return r; } @@ -165,25 +165,25 @@ stop recording a demo */ void CL_Stop_f (void) { - if (cmd_source != src_command) - return; + if (cmd_source != src_command) + return; - if (!cls.demorecording) - { - Con_Printf ("Not recording a demo.\n"); - return; - } + if (!cls.demorecording) + { + Con_Printf ("Not recording a demo.\n"); + return; + } // write a disconnect message to the demo file - SZ_Clear (&net_message); - MSG_WriteByte (&net_message, svc_disconnect); - CL_WriteDemoMessage (); + SZ_Clear (&net_message); + MSG_WriteByte (&net_message, svc_disconnect); + CL_WriteDemoMessage (); // finish up - fclose (cls.demofile); - cls.demofile = NULL; - cls.demorecording = false; - Con_Printf ("Completed demo\n"); + fclose (cls.demofile); + cls.demofile = NULL; + cls.demorecording = false; + Con_Printf ("Completed demo\n"); } /* @@ -195,66 +195,66 @@ record <demoname> <map> [cd track] */ void CL_Record_f (void) { - int c; - char name[MAX_OSPATH]; - int track; - - if (cmd_source != src_command) - return; - - c = Cmd_Argc(); - if (c != 2 && c != 3 && c != 4) - { - Con_Printf ("record <demoname> [<map> [cd track]]\n"); - return; - } - - if (strstr(Cmd_Argv(1), "..")) - { - Con_Printf ("Relative pathnames are not allowed.\n"); - return; - } - - if (c == 2 && cls.state == ca_connected) - { - Con_Printf("Can not record - already connected to server\nClient demo recording must be started before connecting\n"); - return; - } + int c; + char name[MAX_OSPATH]; + int track; + + if (cmd_source != src_command) + return; + + c = Cmd_Argc(); + if (c != 2 && c != 3 && c != 4) + { + Con_Printf ("record <demoname> [<map> [cd track]]\n"); + return; + } + + if (strstr(Cmd_Argv(1), "..")) + { + Con_Printf ("Relative pathnames are not allowed.\n"); + return; + } + + if (c == 2 && cls.state == ca_connected) + { + Con_Printf("Can not record - already connected to server\nClient demo recording must be started before connecting\n"); + return; + } // write the forced cd track number, or -1 - if (c == 4) - { - track = atoi(Cmd_Argv(3)); - Con_Printf ("Forcing CD track to %i\n", cls.forcetrack); - } - else - track = -1; - - sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1)); - + if (c == 4) + { + track = atoi(Cmd_Argv(3)); + Con_Printf ("Forcing CD track to %i\n", cls.forcetrack); + } + else + track = -1; + + sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1)); + // // start the map up // - if (c > 2) - Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command); - + if (c > 2) + Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command); + // // open the demo file // - COM_DefaultExtension (name, ".dem"); - - Con_Printf ("recording to %s.\n", name); - cls.demofile = fopen (name, "wb"); - if (!cls.demofile) - { - Con_Printf ("ERROR: couldn't open.\n"); - return; - } - - cls.forcetrack = track; - fprintf (cls.demofile, "%i\n", cls.forcetrack); - - cls.demorecording = true; + COM_DefaultExtension (name, ".dem"); + + Con_Printf ("recording to %s.\n", name); + cls.demofile = fopen (name, "wb"); + if (!cls.demofile) + { + Con_Printf ("ERROR: couldn't open.\n"); + return; + } + + cls.forcetrack = track; + fprintf (cls.demofile, "%i\n", cls.forcetrack); + + cls.demorecording = true; } @@ -267,53 +267,57 @@ play [demoname] */ void CL_PlayDemo_f (void) { - char name[256]; - int c; - qboolean neg = false; + char name[256]; + int c; + qboolean neg = false; - if (cmd_source != src_command) - return; + if (cmd_source != src_command) + return; - if (Cmd_Argc() != 2) - { - Con_Printf ("play <demoname> : plays a demo\n"); - return; - } + if (Cmd_Argc() > 2) + { + Con_Printf ("play <demoname> : plays a demo\n"); + return; + } // // disconnect from server // - CL_Disconnect (); - + CL_Disconnect (); + // // open the demo file // - strcpy (name, Cmd_Argv(1)); - COM_DefaultExtension (name, ".dem"); - - Con_Printf ("Playing demo from %s.\n", name); - COM_FOpenFile (name, &cls.demofile); - if (!cls.demofile) - { - Con_Printf ("ERROR: couldn't open.\n"); - cls.demonum = -1; // stop demo loop - return; - } - - cls.demoplayback = true; - cls.state = ca_connected; - cls.forcetrack = 0; - - while ((c = getc(cls.demofile)) != '\n') - if (c == '-') - neg = true; - else - cls.forcetrack = cls.forcetrack * 10 + (c - '0'); - - if (neg) - cls.forcetrack = -cls.forcetrack; + const char* cmdName = "demo1"; + if (Cmd_Argc() == 2) { + cmdName = Cmd_Argv(1); + } + strcpy (name, cmdName); + COM_DefaultExtension (name, ".dem"); + + Con_Printf ("Playing demo from %s.\n", name); + COM_FOpenFile (name, &cls.demofile); + if (!cls.demofile) + { + Con_Printf ("ERROR: couldn't open.\n"); + cls.demonum = -1; // stop demo loop + return; + } + + cls.demoplayback = true; + cls.state = ca_connected; + cls.forcetrack = 0; + + while ((c = getc(cls.demofile)) != '\n') + if (c == '-') + neg = true; + else + cls.forcetrack = cls.forcetrack * 10 + (c - '0'); + + if (neg) + cls.forcetrack = -cls.forcetrack; // ZOID, fscanf is evil -// fscanf (cls.demofile, "%i\n", &cls.forcetrack); +// fscanf (cls.demofile, "%i\n", &cls.forcetrack); } // The timedemo numbers are very important to testing, so log them even if normal console printing is disabled. @@ -328,23 +332,23 @@ CL_FinishTimeDemo */ void CL_FinishTimeDemo (void) { - int frames; - float time; - - cls.timedemo = false; - + int frames; + float time; + + cls.timedemo = false; + // the first frame didn't count - frames = (host_framecount - cls.td_startframe) - 1; - time = realtime - cls.td_starttime; - if (!time) - time = 1; - LOGANDPRINT(("%i frames %5.3f seconds %5.3f fps\n", frames, time, frames/time)); - if (frames > 0) - { - LOGANDPRINT(("Fastest: %5.1f ms on frame %d\n", fastestFrame.time * 1000.0, fastestFrame.frame)); - LOGANDPRINT(("Average: %5.1f ms\n", (time / frames) * 1000.0)); - LOGANDPRINT(("Slowest: %5.1f ms on frame %d\n", slowestFrame.time * 1000.0, slowestFrame.frame)); - } + frames = (host_framecount - cls.td_startframe) - 1; + time = realtime - cls.td_starttime; + if (!time) + time = 1; + LOGANDPRINT(("%i frames %5.3f seconds %5.3f fps\n", frames, time, frames/time)); + if (frames > 0) + { + LOGANDPRINT(("Fastest: %5.1f ms on frame %d\n", fastestFrame.time * 1000.0, fastestFrame.frame)); + LOGANDPRINT(("Average: %5.1f ms\n", (time / frames) * 1000.0)); + LOGANDPRINT(("Slowest: %5.1f ms on frame %d\n", slowestFrame.time * 1000.0, slowestFrame.frame)); + } } /* @@ -356,24 +360,24 @@ timedemo [demoname] */ void CL_TimeDemo_f (void) { - if (cmd_source != src_command) - return; + if (cmd_source != src_command) + return; - if (Cmd_Argc() != 2) - { - Con_Printf ("timedemo <demoname> : gets demo speeds\n"); - return; - } + if (Cmd_Argc() > 2) + { + Con_Printf ("timedemo <demoname> : gets demo speeds\n"); + return; + } + + CL_PlayDemo_f (); - CL_PlayDemo_f (); - // cls.td_starttime will be grabbed at the second frame of the demo, so // all the loading time doesn't get counted - - cls.timedemo = true; - cls.td_startframe = host_framecount; - cls.td_lastframe = -1; // get a new message this frame - - InitFrameTimes(); + + cls.timedemo = true; + cls.td_startframe = host_framecount; + cls.td_lastframe = -1; // get a new message this frame + + InitFrameTimes(); } diff --git a/quake/src/WinQuake/cmd.cpp b/quake/src/WinQuake/cmd.cpp index 8c938fe..2c0954e 100644 --- a/quake/src/WinQuake/cmd.cpp +++ b/quake/src/WinQuake/cmd.cpp @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -23,21 +23,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void Cmd_ForwardToServer (void); -#define MAX_ALIAS_NAME 32 +#define MAX_ALIAS_NAME 32 typedef struct cmdalias_s { - struct cmdalias_s *next; - char name[MAX_ALIAS_NAME]; - char *value; + struct cmdalias_s *next; + char name[MAX_ALIAS_NAME]; + char *value; } cmdalias_t; -cmdalias_t *cmd_alias; +cmdalias_t *cmd_alias; int trashtest; int *trashspot; -qboolean cmd_wait; +qboolean cmd_wait; //============================================================================= @@ -52,18 +52,18 @@ bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2" */ void Cmd_Wait_f (void) { - cmd_wait = true; + cmd_wait = true; } /* ============================================================================= - COMMAND BUFFER + COMMAND BUFFER ============================================================================= */ -sizebuf_t cmd_text; +sizebuf_t cmd_text; /* ============ @@ -72,7 +72,7 @@ Cbuf_Init */ void Cbuf_Init (void) { - SZ_Alloc (&cmd_text, 8192); // space for commands and script files + SZ_Alloc (&cmd_text, 8192); // space for commands and script files } @@ -85,17 +85,17 @@ Adds command text at the end of the buffer */ void Cbuf_AddText (const char *text) { - int l; - - l = Q_strlen (text); + int l; - if (cmd_text.cursize + l >= cmd_text.maxsize) - { - Con_Printf ("Cbuf_AddText: overflow\n"); - return; - } + l = Q_strlen (text); - SZ_Write (&cmd_text, text, Q_strlen (text)); + if (cmd_text.cursize + l >= cmd_text.maxsize) + { + Con_Printf ("Cbuf_AddText: overflow\n"); + return; + } + + SZ_Write (&cmd_text, text, Q_strlen (text)); } @@ -110,29 +110,29 @@ FIXME: actually change the command buffer to do less copying */ void Cbuf_InsertText (const char *text) { - char *temp; - int templen; + char *temp; + int templen; // copy off any commands still remaining in the exec buffer - templen = cmd_text.cursize; - if (templen) - { - temp = (char*) Z_Malloc (templen); - Q_memcpy (temp, cmd_text.data, templen); - SZ_Clear (&cmd_text); - } - else - temp = NULL; // shut up compiler - + templen = cmd_text.cursize; + if (templen) + { + temp = (char*) Z_Malloc (templen); + Q_memcpy (temp, cmd_text.data, templen); + SZ_Clear (&cmd_text); + } + else + temp = NULL; // shut up compiler + // add the entire text of the file - Cbuf_AddText (text); - + Cbuf_AddText (text); + // add the copied off data - if (templen) - { - SZ_Write (&cmd_text, temp, templen); - Z_Free (temp); - } + if (templen) + { + SZ_Write (&cmd_text, temp, templen); + Z_Free (temp); + } } /* @@ -142,60 +142,60 @@ Cbuf_Execute */ void Cbuf_Execute (void) { - int i; - char *text; - char line[1024]; - int quotes; - - while (cmd_text.cursize) - { + int i; + char *text; + char line[1024]; + int quotes; + + while (cmd_text.cursize) + { // find a \n or ; line break - text = (char *)cmd_text.data; - - quotes = 0; - for (i=0 ; i< cmd_text.cursize ; i++) - { - if (text[i] == '"') - quotes++; - if ( !(quotes&1) && text[i] == ';') - break; // don't break if inside a quoted string - if (text[i] == '\n' || text[i] == '\r') - break; - } - - - memcpy (line, text, i); - line[i] = 0; - + text = (char *)cmd_text.data; + + quotes = 0; + for (i=0 ; i< cmd_text.cursize ; i++) + { + if (text[i] == '"') + quotes++; + if ( !(quotes&1) && text[i] == ';') + break; // don't break if inside a quoted string + if (text[i] == '\n' || text[i] == '\r') + break; + } + + + memcpy (line, text, i); + line[i] = 0; + // delete the text from the command buffer and move remaining commands down // this is necessary because commands (exec, alias) can insert data at the // beginning of the text buffer - if (i == cmd_text.cursize) - cmd_text.cursize = 0; - else - { - i++; - cmd_text.cursize -= i; - Q_memcpy (text, text+i, cmd_text.cursize); - } + if (i == cmd_text.cursize) + cmd_text.cursize = 0; + else + { + i++; + cmd_text.cursize -= i; + Q_memcpy (text, text+i, cmd_text.cursize); + } // execute the command line - Cmd_ExecuteString (line, src_command); - - if (cmd_wait) - { // skip out while text still remains in buffer, leaving it - // for next frame - cmd_wait = false; - break; - } - } + Cmd_ExecuteString (line, src_command); + + if (cmd_wait) + { // skip out while text still remains in buffer, leaving it + // for next frame + cmd_wait = false; + break; + } + } } /* ============================================================================== - SCRIPT COMMANDS + SCRIPT COMMANDS ============================================================================== */ @@ -212,66 +212,66 @@ quake -nosound +cmd amlev1 */ void Cmd_StuffCmds_f (void) { - int i, j; - int s; - char *text, *build, c; - - if (Cmd_Argc () != 1) - { - Con_Printf ("stuffcmds : execute command line parameters\n"); - return; - } + int i, j; + int s; + char *text, *build, c; + + if (Cmd_Argc () != 1) + { + Con_Printf ("stuffcmds : execute command line parameters\n"); + return; + } // build the combined string to parse from - s = 0; - for (i=1 ; i<com_argc ; i++) - { - if (!com_argv[i]) - continue; // NEXTSTEP nulls out -NXHost - s += Q_strlen (com_argv[i]) + 1; - } - if (!s) - return; - - text = (char*) Z_Malloc (s+1); - text[0] = 0; - for (i=1 ; i<com_argc ; i++) - { - if (!com_argv[i]) - continue; // NEXTSTEP nulls out -NXHost - Q_strcat (text,com_argv[i]); - if (i != com_argc-1) - Q_strcat (text, " "); - } - + s = 0; + for (i=1 ; i<com_argc ; i++) + { + if (!com_argv[i]) + continue; // NEXTSTEP nulls out -NXHost + s += Q_strlen (com_argv[i]) + 1; + } + if (!s) + return; + + text = (char*) Z_Malloc (s+1); + text[0] = 0; + for (i=1 ; i<com_argc ; i++) + { + if (!com_argv[i]) + continue; // NEXTSTEP nulls out -NXHost + Q_strcat (text,com_argv[i]); + if (i != com_argc-1) + Q_strcat (text, " "); + } + // pull out the commands - build = (char*) Z_Malloc (s+1); - build[0] = 0; - - for (i=0 ; i<s-1 ; i++) - { - if (text[i] == '+') - { - i++; - - for (j=i ; (text[j] != '+') && (text[j] != '-') && (text[j] != 0) ; j++) - ; - - c = text[j]; - text[j] = 0; - - Q_strcat (build, text+i); - Q_strcat (build, "\n"); - text[j] = c; - i = j-1; - } - } - - if (build[0]) - Cbuf_InsertText (build); - - Z_Free (text); - Z_Free (build); + build = (char*) Z_Malloc (s+1); + build[0] = 0; + + for (i=0 ; i<s-1 ; i++) + { + if (text[i] == '+') + { + i++; + + for (j=i ; (text[j] != '+') && (text[j] != '-') && (text[j] != 0) ; j++) + ; + + c = text[j]; + text[j] = 0; + + Q_strcat (build, text+i); + Q_strcat (build, "\n"); + text[j] = c; + i = j-1; + } + } + + if (build[0]) + Cbuf_InsertText (build); + + Z_Free (text); + Z_Free (build); } @@ -282,26 +282,26 @@ Cmd_Exec_f */ void Cmd_Exec_f (void) { - char *f; - int mark; - - if (Cmd_Argc () != 2) - { - Con_Printf ("exec <filename> : execute a script file\n"); - return; - } - - mark = Hunk_LowMark (); - f = (char *)COM_LoadHunkFile (Cmd_Argv(1)); - if (!f) - { - Con_Printf ("couldn't exec %s\n",Cmd_Argv(1)); - return; - } - Con_Printf ("execing %s\n",Cmd_Argv(1)); - - Cbuf_InsertText (f); - Hunk_FreeToLowMark (mark); + char *f; + int mark; + + if (Cmd_Argc () != 2) + { + Con_Printf ("exec <filename> : execute a script file\n"); + return; + } + + mark = Hunk_LowMark (); + f = (char *)COM_LoadHunkFile (Cmd_Argv(1)); + if (!f) + { + Con_Printf ("couldn't exec %s\n",Cmd_Argv(1)); + return; + } + Con_Printf ("execing %s\n",Cmd_Argv(1)); + + Cbuf_InsertText (f); + Hunk_FreeToLowMark (mark); } @@ -314,11 +314,11 @@ Just prints the rest of the line to the console */ void Cmd_Echo_f (void) { - int i; - - for (i=1 ; i<Cmd_Argc() ; i++) - Con_Printf ("%s ",Cmd_Argv(i)); - Con_Printf ("\n"); + int i; + + for (i=1 ; i<Cmd_Argc() ; i++) + Con_Printf ("%s ",Cmd_Argv(i)); + Con_Printf ("\n"); } /* @@ -331,94 +331,94 @@ Creates a new command that executes a command string (possibly ; seperated) char *CopyString (const char *in) { - char *out; - - out = (char*) Z_Malloc (strlen(in)+1); - strcpy (out, in); - return out; + char *out; + + out = (char*) Z_Malloc (strlen(in)+1); + strcpy (out, in); + return out; } void Cmd_Alias_f (void) { - cmdalias_t *a; - char cmd[1024]; - int i, c; - const char *s; - - if (Cmd_Argc() == 1) - { - Con_Printf ("Current alias commands:\n"); - for (a = cmd_alias ; a ; a=a->next) - Con_Printf ("%s : %s\n", a->name, a->value); - return; - } - - s = Cmd_Argv(1); - if (strlen(s) >= MAX_ALIAS_NAME) - { - Con_Printf ("Alias name is too long\n"); - return; - } - - // if the alias allready exists, reuse it - for (a = cmd_alias ; a ; a=a->next) - { - if (!strcmp(s, a->name)) - { - Z_Free (a->value); - break; - } - } - - if (!a) - { - a = (cmdalias_t*) Z_Malloc (sizeof(cmdalias_t)); - a->next = cmd_alias; - cmd_alias = a; - } - strcpy (a->name, s); + cmdalias_t *a; + char cmd[1024]; + int i, c; + const char *s; + + if (Cmd_Argc() == 1) + { + Con_Printf ("Current alias commands:\n"); + for (a = cmd_alias ; a ; a=a->next) + Con_Printf ("%s : %s\n", a->name, a->value); + return; + } + + s = Cmd_Argv(1); + if (strlen(s) >= MAX_ALIAS_NAME) + { + Con_Printf ("Alias name is too long\n"); + return; + } + + // if the alias allready exists, reuse it + for (a = cmd_alias ; a ; a=a->next) + { + if (!strcmp(s, a->name)) + { + Z_Free (a->value); + break; + } + } + + if (!a) + { + a = (cmdalias_t*) Z_Malloc (sizeof(cmdalias_t)); + a->next = cmd_alias; + cmd_alias = a; + } + strcpy (a->name, s); // copy the rest of the command line - cmd[0] = 0; // start out with a null string - c = Cmd_Argc(); - for (i=2 ; i< c ; i++) - { - strcat (cmd, Cmd_Argv(i)); - if (i != c) - strcat (cmd, " "); - } - strcat (cmd, "\n"); - - a->value = CopyString (cmd); + cmd[0] = 0; // start out with a null string + c = Cmd_Argc(); + for (i=2 ; i< c ; i++) + { + strcat (cmd, Cmd_Argv(i)); + if (i != c) + strcat (cmd, " "); + } + strcat (cmd, "\n"); + + a->value = CopyString (cmd); } /* ============================================================================= - COMMAND EXECUTION + COMMAND EXECUTION ============================================================================= */ typedef struct cmd_function_s { - struct cmd_function_s *next; - char *name; - xcommand_t function; + struct cmd_function_s *next; + char *name; + xcommand_t function; } cmd_function_t; -#define MAX_ARGS 80 +#define MAX_ARGS 80 -static int cmd_argc; -static char *cmd_argv[MAX_ARGS]; -static char *cmd_null_string = (char*) ""; -static char *cmd_args = NULL; +static int cmd_argc; +static char *cmd_argv[MAX_ARGS]; +static char *cmd_null_string = (char*) ""; +static char *cmd_args = NULL; -cmd_source_t cmd_source; +cmd_source_t cmd_source; -static cmd_function_t *cmd_functions; // possible commands to execute +static cmd_function_t *cmd_functions; // possible commands to execute /* ============ @@ -430,12 +430,12 @@ void Cmd_Init (void) // // register our commands // - Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f); - Cmd_AddCommand ("exec",Cmd_Exec_f); - Cmd_AddCommand ("echo",Cmd_Echo_f); - Cmd_AddCommand ("alias",Cmd_Alias_f); - Cmd_AddCommand ("cmd", Cmd_ForwardToServer); - Cmd_AddCommand ("wait", Cmd_Wait_f); + Cmd_AddCommand ("stuffcmds",Cmd_StuffCmds_f); + Cmd_AddCommand ("exec",Cmd_Exec_f); + Cmd_AddCommand ("echo",Cmd_Echo_f); + Cmd_AddCommand ("alias",Cmd_Alias_f); + Cmd_AddCommand ("cmd", Cmd_ForwardToServer); + Cmd_AddCommand ("wait", Cmd_Wait_f); } /* @@ -443,9 +443,9 @@ void Cmd_Init (void) Cmd_Argc ============ */ -int Cmd_Argc (void) +int Cmd_Argc (void) { - return cmd_argc; + return cmd_argc; } /* @@ -453,11 +453,11 @@ int Cmd_Argc (void) Cmd_Argv ============ */ -char *Cmd_Argv (int arg) +char *Cmd_Argv (int arg) { - if ( arg >= cmd_argc ) - return cmd_null_string; - return cmd_argv[arg]; + if ( arg >= cmd_argc ) + return cmd_null_string; + return cmd_argv[arg]; } /* @@ -465,9 +465,9 @@ char *Cmd_Argv (int arg) Cmd_Args ============ */ -char *Cmd_Args (void) +char *Cmd_Args (void) { - return cmd_args; + return cmd_args; } @@ -480,47 +480,47 @@ Parses the given string into command line tokens. */ void Cmd_TokenizeString (char *text) { - int i; - + int i; + // clear the args from the last string - for (i=0 ; i<cmd_argc ; i++) - Z_Free (cmd_argv[i]); - - cmd_argc = 0; - cmd_args = NULL; - - while (1) - { + for (i=0 ; i<cmd_argc ; i++) + Z_Free (cmd_argv[i]); + + cmd_argc = 0; + cmd_args = NULL; + + while (1) + { // skip whitespace up to a /n - while (*text && *text <= ' ' && *text != '\n') - { - text++; - } - - if (*text == '\n') - { // a newline seperates commands in the buffer - text++; - break; - } - - if (!*text) - return; - - if (cmd_argc == 1) - cmd_args = text; - - text = COM_Parse (text); - if (!text) - return; - - if (cmd_argc < MAX_ARGS) - { - cmd_argv[cmd_argc] = (char*) Z_Malloc (Q_strlen(com_token)+1); - Q_strcpy (cmd_argv[cmd_argc], com_token); - cmd_argc++; - } - } - + while (*text && *text <= ' ' && *text != '\n') + { + text++; + } + + if (*text == '\n') + { // a newline seperates commands in the buffer + text++; + break; + } + + if (!*text) + return; + + if (cmd_argc == 1) + cmd_args = text; + + text = COM_Parse (text); + if (!text) + return; + + if (cmd_argc < MAX_ARGS) + { + cmd_argv[cmd_argc] = (char*) Z_Malloc (Q_strlen(com_token)+1); + Q_strcpy (cmd_argv[cmd_argc], com_token); + cmd_argc++; + } + } + } @@ -529,35 +529,35 @@ void Cmd_TokenizeString (char *text) Cmd_AddCommand ============ */ -void Cmd_AddCommand (const char *cmd_name, xcommand_t function) +void Cmd_AddCommand (const char *cmd_name, xcommand_t function) { - cmd_function_t *cmd; - - if (host_initialized) // because hunk allocation would get stomped - Sys_Error ("Cmd_AddCommand after host_initialized"); - + cmd_function_t *cmd; + + if (host_initialized) // because hunk allocation would get stomped + Sys_Error ("Cmd_AddCommand after host_initialized"); + // fail if the command is a variable name - if (Cvar_VariableString(cmd_name)[0]) - { - Con_Printf ("Cmd_AddCommand: %s already defined as a var\n", cmd_name); - return; - } - + if (Cvar_VariableString(cmd_name)[0]) + { + Con_Printf ("Cmd_AddCommand: %s already defined as a var\n", cmd_name); + return; + } + // fail if the command already exists - for (cmd=cmd_functions ; cmd ; cmd=cmd->next) - { - if (!Q_strcmp (cmd_name, cmd->name)) - { - Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name); - return; - } - } - - cmd = (cmd_function_t*) Hunk_Alloc (sizeof(cmd_function_t)); - cmd->name = (char*) cmd_name; - cmd->function = function; - cmd->next = cmd_functions; - cmd_functions = cmd; + for (cmd=cmd_functions ; cmd ; cmd=cmd->next) + { + if (!Q_strcmp (cmd_name, cmd->name)) + { + Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name); + return; + } + } + + cmd = (cmd_function_t*) Hunk_Alloc (sizeof(cmd_function_t)); + cmd->name = (char*) cmd_name; + cmd->function = function; + cmd->next = cmd_functions; + cmd_functions = cmd; } /* @@ -565,17 +565,17 @@ void Cmd_AddCommand (const char *cmd_name, xcommand_t function) Cmd_Exists ============ */ -qboolean Cmd_Exists (const char *cmd_name) +qboolean Cmd_Exists (const char *cmd_name) { - cmd_function_t *cmd; + cmd_function_t *cmd; - for (cmd=cmd_functions ; cmd ; cmd=cmd->next) - { - if (!Q_strcmp (cmd_name,cmd->name)) - return true; - } + for (cmd=cmd_functions ; cmd ; cmd=cmd->next) + { + if (!Q_strcmp (cmd_name,cmd->name)) + return true; + } - return false; + return false; } @@ -587,20 +587,20 @@ Cmd_CompleteCommand */ const char *Cmd_CompleteCommand (const char *partial) { - cmd_function_t *cmd; - int len; - - len = Q_strlen(partial); - - if (!len) - return NULL; - + cmd_function_t *cmd; + int len; + + len = Q_strlen(partial); + + if (!len) + return NULL; + // check functions - for (cmd=cmd_functions ; cmd ; cmd=cmd->next) - if (!Q_strncmp (partial,cmd->name, len)) - return cmd->name; + for (cmd=cmd_functions ; cmd ; cmd=cmd->next) + if (!Q_strncmp (partial,cmd->name, len)) + return cmd->name; - return NULL; + return NULL; } /* @@ -611,42 +611,42 @@ A complete command line has been parsed, so try to execute it FIXME: lookupnoadd the token to speed search? ============ */ -void Cmd_ExecuteString (char *text, cmd_source_t src) -{ - cmd_function_t *cmd; - cmdalias_t *a; - - cmd_source = src; - Cmd_TokenizeString (text); - +void Cmd_ExecuteString (char *text, cmd_source_t src) +{ + cmd_function_t *cmd; + cmdalias_t *a; + + cmd_source = src; + Cmd_TokenizeString (text); + // execute the command line - if (!Cmd_Argc()) - return; // no tokens + if (!Cmd_Argc()) + return; // no tokens // check functions - for (cmd=cmd_functions ; cmd ; cmd=cmd->next) - { - if (!Q_strcasecmp (cmd_argv[0],cmd->name)) - { - cmd->function (); - return; - } - } + for (cmd=cmd_functions ; cmd ; cmd=cmd->next) + { + if (!Q_strcasecmp (cmd_argv[0],cmd->name)) + { + cmd->function (); + return; + } + } // check alias - for (a=cmd_alias ; a ; a=a->next) - { - if (!Q_strcasecmp (cmd_argv[0], a->name)) - { - Cbuf_InsertText (a->value); - return; - } - } - + for (a=cmd_alias ; a ; a=a->next) + { + if (!Q_strcasecmp (cmd_argv[0], a->name)) + { + Cbuf_InsertText (a->value); + return; + } + } + // check cvars - if (!Cvar_Command ()) - Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0)); - + if (!Cvar_Command ()) + Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0)); + } void Cmd_ExecuteString2 (const char *text, cmd_source_t src) @@ -666,25 +666,25 @@ Sends the entire command line over to the server */ void Cmd_ForwardToServer (void) { - if (cls.state != ca_connected) - { - Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); - return; - } - - if (cls.demoplayback) - return; // not really connected - - MSG_WriteByte (&cls.message, clc_stringcmd); - if (Q_strcasecmp(Cmd_Argv(0), "cmd") != 0) - { - SZ_Print (&cls.message, Cmd_Argv(0)); - SZ_Print (&cls.message, " "); - } - if (Cmd_Argc() > 1) - SZ_Print (&cls.message, Cmd_Args()); - else - SZ_Print (&cls.message, "\n"); + if (cls.state != ca_connected) + { + Con_Printf ("Can't \"%s\", not connected\n", Cmd_Argv(0)); + return; + } + + if (cls.demoplayback) + return; // not really connected + + MSG_WriteByte (&cls.message, clc_stringcmd); + if (Q_strcasecmp(Cmd_Argv(0), "cmd") != 0) + { + SZ_Print (&cls.message, Cmd_Argv(0)); + SZ_Print (&cls.message, " "); + } + if (Cmd_Argc() > 1) + SZ_Print (&cls.message, Cmd_Args()); + else + SZ_Print (&cls.message, "\n"); } @@ -699,14 +699,14 @@ where the given parameter apears, or 0 if not present int Cmd_CheckParm (const char *parm) { - int i; - - if (!parm) - Sys_Error ("Cmd_CheckParm: NULL"); - - for (i = 1; i < Cmd_Argc (); i++) - if (! Q_strcasecmp (parm, Cmd_Argv (i))) - return i; - - return 0; + int i; + + if (!parm) + Sys_Error ("Cmd_CheckParm: NULL"); + + for (i = 1; i < Cmd_Argc (); i++) + if (! Q_strcasecmp (parm, Cmd_Argv (i))) + return i; + + return 0; } diff --git a/quake/src/WinQuake/cmd.h b/quake/src/WinQuake/cmd.h index c463163..9481399 100644 --- a/quake/src/WinQuake/cmd.h +++ b/quake/src/WinQuake/cmd.h @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -70,17 +70,17 @@ typedef void (*xcommand_t) (void); typedef enum { - src_client, // came in over a net connection as a clc_stringcmd - // host_client will be valid during this state. - src_command, // from the command buffer - cmd_src_t_max = 1 << 30 + src_client, // came in over a net connection as a clc_stringcmd + // host_client will be valid during this state. + src_command, // from the command buffer + cmd_src_t_max = 1 << 30 } cmd_source_t; -extern cmd_source_t cmd_source; +extern cmd_source_t cmd_source; -void Cmd_Init (void); +void Cmd_Init (void); -void Cmd_AddCommand (const char *cmd_name, xcommand_t function); +void Cmd_AddCommand (const char *cmd_name, xcommand_t function); // called by the init functions of other parts of the program to // register commands and functions to call for them. // The cmd_name is referenced later, so it should not be in temp memory @@ -88,13 +88,13 @@ void Cmd_AddCommand (const char *cmd_name, xcommand_t function); qboolean Cmd_Exists (const char *cmd_name); // used by the cvar code to check for cvar / command name overlap -const char *Cmd_CompleteCommand (const char *partial); +const char *Cmd_CompleteCommand (const char *partial); // attempts to match a partial command for automatic command line completion // returns NULL if nothing fits -int Cmd_Argc (void); -char *Cmd_Argv (int arg); -char *Cmd_Args (void); +int Cmd_Argc (void); +char *Cmd_Argv (int arg); +char *Cmd_Args (void); // The functions that execute commands get their parameters with these // functions. Cmd_Argv () will return an empty string, not a NULL // if arg > argc, so string operations are allways safe. @@ -107,7 +107,7 @@ void Cmd_TokenizeString (char *text); // Takes a null terminated string. Does not need to be /n terminated. // breaks the string up into arg tokens. -void Cmd_ExecuteString (char *text, cmd_source_t src); +void Cmd_ExecuteString (char *text, cmd_source_t src); // Same as Cmd_ExecuteString, but for string constants. void Cmd_ExecuteString2 (const char *text, cmd_source_t src); @@ -115,12 +115,12 @@ void Cmd_ExecuteString2 (const char *text, cmd_source_t src); // Parses a single line of text into arguments and tries to execute it. // The text can come from the command buffer, a remote client, or stdin. -void Cmd_ForwardToServer (void); +void Cmd_ForwardToServer (void); // adds the current command line as a clc_stringcmd to the client message. // things like godmode, noclip, etc, are commands directed to the server, // so when they are typed in at the console, they will need to be forwarded. -void Cmd_Print (const char *text); +void Cmd_Print (const char *text); // used by command functions to send output to either the graphics console or // passed as a print message to the client diff --git a/quake/src/WinQuake/menu.cpp b/quake/src/WinQuake/menu.cpp index b23a394..02bb876 100644 --- a/quake/src/WinQuake/menu.cpp +++ b/quake/src/WinQuake/menu.cpp @@ -85,20 +85,20 @@ void M_GameOptions_Key (int key); void M_Search_Key (int key); void M_ServerList_Key (int key); -qboolean m_entersound; // play after drawing a frame, so caching +qboolean m_entersound; // play after drawing a frame, so caching // won't disrupt the sound -qboolean m_recursiveDraw; +qboolean m_recursiveDraw; -int m_return_state; -qboolean m_return_onerror; -char m_return_reason [32]; +int m_return_state; +qboolean m_return_onerror; +char m_return_reason [32]; -#define StartingGame (m_multiplayer_cursor == 1) -#define JoiningGame (m_multiplayer_cursor == 0) -#define SerialConfig (m_net_cursor == 0) -#define DirectConfig (m_net_cursor == 1) -#define IPXConfig (m_net_cursor == 2) -#define TCPIPConfig (m_net_cursor == 3) +#define StartingGame (m_multiplayer_cursor == 1) +#define JoiningGame (m_multiplayer_cursor == 0) +#define SerialConfig (m_net_cursor == 0) +#define DirectConfig (m_net_cursor == 1) +#define IPXConfig (m_net_cursor == 2) +#define TCPIPConfig (m_net_cursor == 3) void M_ConfigureNetSubsystem(void); @@ -149,8 +149,8 @@ byte translationTable[256]; void M_BuildTranslationTable(int top, int bottom) { - int j; - byte *dest, *source; + int j; + byte *dest, *source; for (j = 0; j < 256; j++) identityTable[j] = j; @@ -158,7 +158,7 @@ void M_BuildTranslationTable(int top, int bottom) source = identityTable; memcpy (dest, source, 256); - if (top < 128) // the artists made some backwards ranges. sigh. + if (top < 128) // the artists made some backwards ranges. sigh. memcpy (dest + TOP_RANGE, source + top, 16); else for (j=0 ; j<16 ; j++) @@ -180,9 +180,9 @@ void M_DrawTransPicTranslate (int x, int y, qpic_t *pic) void M_DrawTextBox (int x, int y, int width, int lines) { - qpic_t *p; - int cx, cy; - int n; + qpic_t *p; + int cx, cy; + int n; // draw left side cx = x; @@ -271,8 +271,8 @@ void M_ToggleMenu_f (void) //============================================================================= /* MAIN MENU */ -int m_main_cursor; -#define MAIN_ITEMS 5 +int m_main_cursor; +#define MAIN_ITEMS 5 void M_Menu_Main_f (void) @@ -290,8 +290,8 @@ void M_Menu_Main_f (void) void M_Main_Draw (void) { - int f; - qpic_t *p; + int f; + qpic_t *p; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/ttl_main.lmp"); @@ -359,8 +359,8 @@ void M_Main_Key (int key) //============================================================================= /* SINGLE PLAYER MENU */ -int m_singleplayer_cursor; -#define SINGLEPLAYER_ITEMS 3 +int m_singleplayer_cursor; +#define SINGLEPLAYER_ITEMS 3 void M_Menu_SinglePlayer_f (void) @@ -373,8 +373,8 @@ void M_Menu_SinglePlayer_f (void) void M_SinglePlayer_Draw (void) { - int f; - qpic_t *p; + int f; + qpic_t *p; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/ttl_sgl.lmp"); @@ -437,18 +437,18 @@ void M_SinglePlayer_Key (int key) //============================================================================= /* LOAD/SAVE MENU */ -int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES +int load_cursor; // 0 < load_cursor < MAX_SAVEGAMES -#define MAX_SAVEGAMES 12 -char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1]; -int loadable[MAX_SAVEGAMES]; +#define MAX_SAVEGAMES 12 +char m_filenames[MAX_SAVEGAMES][SAVEGAME_COMMENT_LENGTH+1]; +int loadable[MAX_SAVEGAMES]; void M_ScanSaves (void) { - int i, j; - char name[MAX_OSPATH]; - FILE *f; - int version; + int i, j; + char name[MAX_OSPATH]; + FILE *f; + int version; for (i=0 ; i<MAX_SAVEGAMES ; i++) { @@ -497,8 +497,8 @@ void M_Menu_Save_f (void) void M_Load_Draw (void) { - int i; - qpic_t *p; + int i; + qpic_t *p; p = Draw_CachePic ("gfx/p_load.lmp"); M_DrawPic ( (320-p->width)/2, 4, p); @@ -513,8 +513,8 @@ void M_Load_Draw (void) void M_Save_Draw (void) { - int i; - qpic_t *p; + int i; + qpic_t *p; p = Draw_CachePic ("gfx/p_save.lmp"); M_DrawPic ( (320-p->width)/2, 4, p); @@ -604,8 +604,8 @@ void M_Save_Key (int k) //============================================================================= /* MULTIPLAYER MENU */ -int m_multiplayer_cursor; -#define MULTIPLAYER_ITEMS 3 +int m_multiplayer_cursor; +#define MULTIPLAYER_ITEMS 3 void M_Menu_MultiPlayer_f (void) @@ -618,8 +618,8 @@ void M_Menu_MultiPlayer_f (void) void M_MultiPlayer_Draw (void) { - int f; - qpic_t *p; + int f; + qpic_t *p; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -680,17 +680,17 @@ void M_MultiPlayer_Key (int key) //============================================================================= /* SETUP MENU */ -int setup_cursor = 4; -int setup_cursor_table[] = {40, 56, 80, 104, 140}; +int setup_cursor = 4; +int setup_cursor_table[] = {40, 56, 80, 104, 140}; -char setup_hostname[16]; -char setup_myname[16]; -int setup_oldtop; -int setup_oldbottom; -int setup_top; -int setup_bottom; +char setup_hostname[16]; +char setup_myname[16]; +int setup_oldtop; +int setup_oldbottom; +int setup_top; +int setup_bottom; -#define NUM_SETUP_CMDS 5 +#define NUM_SETUP_CMDS 5 void M_Menu_Setup_f (void) { @@ -706,7 +706,7 @@ void M_Menu_Setup_f (void) void M_Setup_Draw (void) { - qpic_t *p; + qpic_t *p; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -744,7 +744,7 @@ void M_Setup_Draw (void) void M_Setup_Key (int k) { - int l; + int l; switch (k) { @@ -854,7 +854,7 @@ forward: //============================================================================= /* NET MENU */ -int m_net_cursor; +int m_net_cursor; int m_net_items; int m_net_saveHeight; @@ -898,8 +898,8 @@ void M_Menu_Net_f (void) void M_Net_Draw (void) { - int f; - qpic_t *p; + int f; + qpic_t *p; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -955,7 +955,7 @@ void M_Net_Draw (void) p = Draw_CachePic ("gfx/dim_tcp.lmp"); M_DrawTransPic (72, f, p); - if (m_net_items == 5) // JDC, could just be removed + if (m_net_items == 5) // JDC, could just be removed { f += 19; p = Draw_CachePic ("gfx/netmen5.lmp"); @@ -1037,14 +1037,14 @@ again: /* OPTIONS MENU */ #ifdef _WIN32 -#define OPTIONS_ITEMS 14 +#define OPTIONS_ITEMS 14 #else -#define OPTIONS_ITEMS 13 +#define OPTIONS_ITEMS 13 #endif -#define SLIDER_RANGE 10 +#define SLIDER_RANGE 10 -int options_cursor; +int options_cursor; void M_Menu_Options_f (void) { @@ -1067,7 +1067,7 @@ void M_AdjustSliders (int dir) switch (options_cursor) { - case 3: // screen size + case 3: // screen size scr_viewsize.value += dir * 10; if (scr_viewsize.value < 30) scr_viewsize.value = 30; @@ -1075,7 +1075,7 @@ void M_AdjustSliders (int dir) scr_viewsize.value = 120; Cvar_SetValue ("viewsize", scr_viewsize.value); break; - case 4: // gamma + case 4: // gamma v_gamma.value -= dir * 0.05; if (v_gamma.value < 0.5) v_gamma.value = 0.5; @@ -1083,7 +1083,7 @@ void M_AdjustSliders (int dir) v_gamma.value = 1; Cvar_SetValue ("gamma", v_gamma.value); break; - case 5: // mouse speed + case 5: // mouse speed sensitivity.value += dir * 0.5; if (sensitivity.value < 1) sensitivity.value = 1; @@ -1091,7 +1091,7 @@ void M_AdjustSliders (int dir) sensitivity.value = 11; Cvar_SetValue ("sensitivity", sensitivity.value); break; - case 6: // music volume + case 6: // music volume #ifdef _WIN32 bgmvolume.value += dir * 1.0; #else @@ -1103,7 +1103,7 @@ void M_AdjustSliders (int dir) bgmvolume.value = 1; Cvar_SetValue ("bgmvolume", bgmvolume.value); break; - case 7: // sfx volume + case 7: // sfx volume volume.value += dir * 0.1; if (volume.value < 0) volume.value = 0; @@ -1112,7 +1112,7 @@ void M_AdjustSliders (int dir) Cvar_SetValue ("volume", volume.value); break; - case 8: // allways run + case 8: // allways run if (cl_forwardspeed.value > 200) { Cvar_SetValue ("cl_forwardspeed", 200); @@ -1125,20 +1125,20 @@ void M_AdjustSliders (int dir) } break; - case 9: // invert mouse + case 9: // invert mouse Cvar_SetValue ("m_pitch", -m_pitch.value); break; - case 10: // lookspring + case 10: // lookspring Cvar_SetValue ("lookspring", !lookspring.value); break; - case 11: // lookstrafe + case 11: // lookstrafe Cvar_SetValue ("lookstrafe", !lookstrafe.value); break; #ifdef _WIN32 - case 13: // _windowed_mouse + case 13: // _windowed_mouse Cvar_SetValue ("_windowed_mouse", !_windowed_mouse.value); break; #endif @@ -1148,7 +1148,7 @@ void M_AdjustSliders (int dir) void M_DrawSlider (int x, int y, float range) { - int i; + int i; if (range < 0) range = 0; @@ -1177,8 +1177,8 @@ void M_DrawCheckbox (int x, int y, int on) void M_Options_Draw (void) { - float r; - qpic_t *p; + float r; + qpic_t *p; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_option.lmp"); @@ -1314,30 +1314,30 @@ void M_Options_Key (int k) const 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])) +#define NUMCOMMANDS (sizeof(bindnames)/sizeof(bindnames[0])) -int keys_cursor; -int bind_grab; +int keys_cursor; +int bind_grab; void M_Menu_Keys_f (void) { @@ -1349,10 +1349,10 @@ void M_Menu_Keys_f (void) void M_FindKeysForCommand (const char *command, int *twokeys) { - int count; - int j; - int l; - char *b; + int count; + int j; + int l; + char *b; twokeys[0] = twokeys[1] = -1; l = strlen(command); @@ -1375,9 +1375,9 @@ void M_FindKeysForCommand (const char *command, int *twokeys) void M_UnbindCommand (const char *command) { - int j; - int l; - char *b; + int j; + int l; + char *b; l = strlen(command); @@ -1394,11 +1394,11 @@ void M_UnbindCommand (const char *command) void M_Keys_Draw (void) { - int i, l; - int keys[2]; - const char *name; - int x, y; - qpic_t *p; + int i, l; + int keys[2]; + const char *name; + int x, y; + qpic_t *p; p = Draw_CachePic ("gfx/ttl_cstm.lmp"); M_DrawPic ( (320-p->width)/2, 4, p); @@ -1445,11 +1445,11 @@ void M_Keys_Draw (void) void M_Keys_Key (int k) { - char cmd[80]; - int keys[2]; + char cmd[80]; + int keys[2]; if (bind_grab) - { // defining a key + { // defining a key S_LocalSound ("misc/menu1.wav"); if (k == K_ESCAPE) { @@ -1487,7 +1487,7 @@ void M_Keys_Key (int k) keys_cursor = 0; break; - case K_ENTER: // go into bind mode + case K_ENTER: // go into bind mode M_FindKeysForCommand (bindnames[keys_cursor][0], keys); S_LocalSound ("misc/menu2.wav"); if (keys[1] != -1) @@ -1495,8 +1495,8 @@ void M_Keys_Key (int k) bind_grab = true; break; - case K_BACKSPACE: // delete bindings - case K_DEL: // delete bindings + case K_BACKSPACE: // delete bindings + case K_DEL: // delete bindings S_LocalSound ("misc/menu2.wav"); M_UnbindCommand (bindnames[keys_cursor][0]); break; @@ -1528,16 +1528,25 @@ void M_Video_Key (int key) //============================================================================= /* HELP MENU */ -int help_page; -#define NUM_HELP_PAGES 6 +int help_page; +#define NUM_HELP_PAGES 6 void M_Menu_Help_f (void) { +#if 1 // Hijack menu for timedemo + key_dest = key_menu; + m_state = m_none; + char buf[50]; + strcpy(buf, "timedemo demo1"); + Cmd_TokenizeString(buf); + CL_TimeDemo_f(); +#else key_dest = key_menu; m_state = m_help; m_entersound = true; help_page = 0; +#endif } @@ -1576,11 +1585,11 @@ void M_Help_Key (int key) //============================================================================= /* QUIT MENU */ -int msgNumber; -int m_quit_prevstate; -qboolean wasInMenus; +int msgNumber; +int m_quit_prevstate; +qboolean wasInMenus; -#ifndef _WIN32 +#ifndef _WIN32 const char *quitMessage [] = { /* .........1.........2.... */ @@ -1722,25 +1731,25 @@ void M_Quit_Draw (void) /* SERIAL CONFIG MENU */ -int serialConfig_cursor; -int serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132}; -#define NUM_SERIALCONFIG_CMDS 6 +int serialConfig_cursor; +int serialConfig_cursor_table[] = {48, 64, 80, 96, 112, 132}; +#define NUM_SERIALCONFIG_CMDS 6 -static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8}; -static int ISA_IRQs[] = {4,3,4,3}; +static int ISA_uarts[] = {0x3f8,0x2f8,0x3e8,0x2e8}; +static int ISA_IRQs[] = {4,3,4,3}; int serialConfig_baudrate[] = {9600,14400,19200,28800,38400,57600}; -int serialConfig_comport; -int serialConfig_irq ; -int serialConfig_baud; -char serialConfig_phone[16]; +int serialConfig_comport; +int serialConfig_irq ; +int serialConfig_baud; +char serialConfig_phone[16]; void M_Menu_SerialConfig_f (void) { - int n; - int port; - int baudrate; - qboolean useModem; + int n; + int port; + int baudrate; + qboolean useModem; key_dest = key_menu; m_state = m_serialconfig; @@ -1778,10 +1787,10 @@ void M_Menu_SerialConfig_f (void) void M_SerialConfig_Draw (void) { - qpic_t *p; - int basex; - const char *startJoin; - const char *directModem; + qpic_t *p; + int basex; + const char *startJoin; + const char *directModem; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -1845,7 +1854,7 @@ void M_SerialConfig_Draw (void) void M_SerialConfig_Key (int key) { - int l; + int l; switch (key) { @@ -2013,14 +2022,14 @@ forward: //============================================================================= /* MODEM CONFIG MENU */ -int modemConfig_cursor; -int modemConfig_cursor_table [] = {40, 56, 88, 120, 156}; -#define NUM_MODEMCONFIG_CMDS 5 +int modemConfig_cursor; +int modemConfig_cursor_table [] = {40, 56, 88, 120, 156}; +#define NUM_MODEMCONFIG_CMDS 5 -char modemConfig_dialing; -char modemConfig_clear [16]; -char modemConfig_init [32]; -char modemConfig_hangup [16]; +char modemConfig_dialing; +char modemConfig_clear [16]; +char modemConfig_init [32]; +char modemConfig_hangup [16]; void M_Menu_ModemConfig_f (void) { @@ -2033,8 +2042,8 @@ void M_Menu_ModemConfig_f (void) void M_ModemConfig_Draw (void) { - qpic_t *p; - int basex; + qpic_t *p; + int basex; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -2074,7 +2083,7 @@ void M_ModemConfig_Draw (void) void M_ModemConfig_Key (int key) { - int l; + int l; switch (key) { @@ -2185,13 +2194,13 @@ void M_ModemConfig_Key (int key) //============================================================================= /* LAN CONFIG MENU */ -int lanConfig_cursor = -1; -int lanConfig_cursor_table [] = {72, 92, 124}; -#define NUM_LANCONFIG_CMDS 3 +int lanConfig_cursor = -1; +int lanConfig_cursor_table [] = {72, 92, 124}; +#define NUM_LANCONFIG_CMDS 3 -int lanConfig_port; -char lanConfig_portname[6]; -char lanConfig_joinname[22]; +int lanConfig_port; +char lanConfig_portname[6]; +char lanConfig_joinname[22]; void M_Menu_LanConfig_f (void) { @@ -2217,10 +2226,10 @@ void M_Menu_LanConfig_f (void) void M_LanConfig_Draw (void) { - qpic_t *p; - int basex; - const char *startJoin; - const char *protocol; + qpic_t *p; + int basex; + const char *startJoin; + const char *protocol; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -2276,7 +2285,7 @@ void M_LanConfig_Draw (void) void M_LanConfig_Key (int key) { - int l; + int l; switch (key) { @@ -2391,15 +2400,15 @@ void M_LanConfig_Key (int key) typedef struct { - const char *name; - const char *description; + const char *name; + const char *description; } level_t; -level_t levels[] = +level_t levels[] = { - {"start", "Entrance"}, // 0 + {"start", "Entrance"}, // 0 - {"e1m1", "Slipgate Complex"}, // 1 + {"e1m1", "Slipgate Complex"}, // 1 {"e1m2", "Castle of the Damned"}, {"e1m3", "The Necropolis"}, {"e1m4", "The Grisly Grotto"}, @@ -2408,7 +2417,7 @@ level_t levels[] = {"e1m7", "The House of Chthon"}, {"e1m8", "Ziggurat Vertigo"}, - {"e2m1", "The Installation"}, // 9 + {"e2m1", "The Installation"}, // 9 {"e2m2", "Ogre Citadel"}, {"e2m3", "Crypt of Decay"}, {"e2m4", "The Ebon Fortress"}, @@ -2416,7 +2425,7 @@ level_t levels[] = {"e2m6", "The Dismal Oubliette"}, {"e2m7", "Underearth"}, - {"e3m1", "Termination Central"}, // 16 + {"e3m1", "Termination Central"}, // 16 {"e3m2", "The Vaults of Zin"}, {"e3m3", "The Tomb of Terror"}, {"e3m4", "Satan's Dark Delight"}, @@ -2424,7 +2433,7 @@ level_t levels[] = {"e3m6", "Chambers of Torment"}, {"e3m7", "The Haunted Halls"}, - {"e4m1", "The Sewage System"}, // 23 + {"e4m1", "The Sewage System"}, // 23 {"e4m2", "The Tower of Despair"}, {"e4m3", "The Elder God Shrine"}, {"e4m4", "The Palace of Hate"}, @@ -2433,9 +2442,9 @@ level_t levels[] = {"e4m7", "Azure Agony"}, {"e4m8", "The Nameless City"}, - {"end", "Shub-Niggurath's Pit"}, // 31 + {"end", "Shub-Niggurath's Pit"}, // 31 - {"dm1", "Place of Two Deaths"}, // 32 + {"dm1", "Place of Two Deaths"}, // 32 {"dm2", "Claustrophobopolis"}, {"dm3", "The Abandoned Base"}, {"dm4", "The Bad Place"}, @@ -2473,35 +2482,35 @@ level_t hipnoticlevels[] = //PGM 01/07/97 added rogue levels //PGM 03/02/97 added dmatch level -level_t roguelevels[] = -{ - {"start", "Split Decision"}, - {"r1m1", "Deviant's Domain"}, - {"r1m2", "Dread Portal"}, - {"r1m3", "Judgement Call"}, - {"r1m4", "Cave of Death"}, - {"r1m5", "Towers of Wrath"}, - {"r1m6", "Temple of Pain"}, - {"r1m7", "Tomb of the Overlord"}, - {"r2m1", "Tempus Fugit"}, - {"r2m2", "Elemental Fury I"}, - {"r2m3", "Elemental Fury II"}, - {"r2m4", "Curse of Osiris"}, - {"r2m5", "Wizard's Keep"}, - {"r2m6", "Blood Sacrifice"}, - {"r2m7", "Last Bastion"}, - {"r2m8", "Source of Evil"}, +level_t roguelevels[] = +{ + {"start", "Split Decision"}, + {"r1m1", "Deviant's Domain"}, + {"r1m2", "Dread Portal"}, + {"r1m3", "Judgement Call"}, + {"r1m4", "Cave of Death"}, + {"r1m5", "Towers of Wrath"}, + {"r1m6", "Temple of Pain"}, + {"r1m7", "Tomb of the Overlord"}, + {"r2m1", "Tempus Fugit"}, + {"r2m2", "Elemental Fury I"}, + {"r2m3", "Elemental Fury II"}, + {"r2m4", "Curse of Osiris"}, + {"r2m5", "Wizard's Keep"}, + {"r2m6", "Blood Sacrifice"}, + {"r2m7", "Last Bastion"}, + {"r2m8", "Source of Evil"}, {"ctf1", "Division of Change"} }; typedef struct { - const char *description; - int firstLevel; - int levels; + const char *description; + int firstLevel; + int levels; } episode_t; -episode_t episodes[] = +episode_t episodes[] = { {"Welcome to Quake", 0, 1}, {"Doomed Dimension", 1, 8}, @@ -2525,7 +2534,7 @@ episode_t hipnoticepisodes[] = //PGM 01/07/97 added rogue episodes //PGM 03/02/97 added dmatch episode -episode_t rogueepisodes[] = +episode_t rogueepisodes[] = { {"Introduction", 0, 1}, {"Hell's Fortress", 1, 7}, @@ -2533,8 +2542,8 @@ episode_t rogueepisodes[] = {"Deathmatch Arena", 16, 1} }; -int startepisode; -int startlevel; +int startepisode; +int startlevel; int maxplayers; qboolean m_serverInfoMessage = false; double m_serverInfoMessageTime; @@ -2552,13 +2561,13 @@ void M_Menu_GameOptions_f (void) int gameoptions_cursor_table[] = {40, 56, 64, 72, 80, 88, 96, 112, 120}; -#define NUM_GAMEOPTIONS 9 -int gameoptions_cursor; +#define NUM_GAMEOPTIONS 9 +int gameoptions_cursor; void M_GameOptions_Draw (void) { - qpic_t *p; - int x; + qpic_t *p; + int x; M_DrawTransPic (16, 4, Draw_CachePic ("gfx/qplaque.lmp") ); p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -2824,7 +2833,7 @@ void M_GameOptions_Key (int key) { if (sv.active) Cbuf_AddText ("disconnect\n"); - Cbuf_AddText ("listen 0\n"); // so host_netport will be re-examined + Cbuf_AddText ("listen 0\n"); // so host_netport will be re-examined Cbuf_AddText ( va ("maxplayers %u\n", maxplayers) ); SCR_BeginLoadingPlaque (); @@ -2846,8 +2855,8 @@ void M_GameOptions_Key (int key) //============================================================================= /* SEARCH MENU */ -qboolean searchComplete = false; -double searchCompleteTime; +qboolean searchComplete = false; +double searchCompleteTime; void M_Menu_Search_f (void) { @@ -2864,7 +2873,7 @@ void M_Menu_Search_f (void) void M_Search_Draw (void) { - qpic_t *p; + qpic_t *p; int x; p = Draw_CachePic ("gfx/p_multi.lmp"); @@ -2906,7 +2915,7 @@ void M_Search_Key (int key) //============================================================================= /* SLIST MENU */ -int slist_cursor; +int slist_cursor; qboolean slist_sorted; void M_Menu_ServerList_f (void) @@ -2923,15 +2932,15 @@ void M_Menu_ServerList_f (void) void M_ServerList_Draw (void) { - int n; - char string [64]; - qpic_t *p; + int n; + char string [64]; + qpic_t *p; if (!slist_sorted) { if (hostCacheCount > 1) { - int i,j; + int i,j; hostcache_t temp; for (i = 0; i < hostCacheCount; i++) for (j = i+1; j < hostCacheCount; j++) |