From 14ac3acc1753b0e8a18574ad52989ed6bfde22e1 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 20 Jan 2002 03:09:03 +0000 Subject: [PATCH] add a builtin (gametype) for detecting the, well, game type (ie, netquake or quakeworld) which just returns the apprproate string. the single player menu is now acessable in nq but not qw :) --- cs-code/menu.qc | 25 +++++++++++++++++++------ include/QF/progs.h | 2 ++ libs/gamecode/builtins/pr_cmds.c | 9 +++++++++ nq/source/host.c | 2 ++ qw/source/cl_main.c | 2 ++ qw/source/sv_progs.c | 1 + 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/cs-code/menu.qc b/cs-code/menu.qc index 106586857..4afbab13c 100644 --- a/cs-code/menu.qc +++ b/cs-code/menu.qc @@ -15,6 +15,7 @@ void (integer x, integer y, string name) Draw_Pic = #0; void (integer x, integer y, string text) Draw_String = #0; float () random = #0; +string () gametype = #0; float time; entity self; @@ -22,6 +23,8 @@ entity self; .float frame; .void () think; +integer do_single_player; + string [6] dot = { "gfx/menudot1.lmp", "gfx/menudot2.lmp", @@ -156,22 +159,22 @@ void () quit_draw = void () single_player_menu = { - Menu_Item (54, 32, "", NIL); + Menu_Item (54, 32, "", quit_f); }; void () multi_player_menu = { - Menu_Item (54, 52, "", NIL); + Menu_Item (54, 52, "", quit_f); }; void () options_menu = { - Menu_Item (54, 72, "", NIL); + Menu_Item (54, 72, "", quit_f); }; void () help_menu = { - Menu_Item (54, 92, "", NIL); + Menu_Item (54, 92, "", quit_f); }; void () main_menu = @@ -181,8 +184,8 @@ void () main_menu = Menu_CenterPic (160, 4, "gfx/ttl_main.lmp"); Menu_Pic (71,32, "gfx/mainmenu.lmp"); Menu_Cursor (spinner); - //if (do_single_player) - // single_player_menu (); + if (do_single_player) + single_player_menu (); multi_player_menu (); options_menu (); help_menu (); @@ -200,6 +203,16 @@ void () quit_menu = void () menu_init = { + switch (gametype ()) { + case "netquake": + do_single_player = 1; + break; + case "quakeworld": + do_single_player = 0; + break; + default: + break; + } main_menu (); quit_menu (); Menu_TopMenu ("main"); diff --git a/include/QF/progs.h b/include/QF/progs.h index 1a6b28f7e..1df9856d8 100644 --- a/include/QF/progs.h +++ b/include/QF/progs.h @@ -199,6 +199,8 @@ extern struct cvar_s *pr_debug; extern struct cvar_s *pr_deadbeef_locals; extern struct cvar_s *pr_boundscheck; +extern const char *pr_gametype; + // // PR Cmds stuff // diff --git a/libs/gamecode/builtins/pr_cmds.c b/libs/gamecode/builtins/pr_cmds.c index 7fb98c440..65ffc4ae0 100644 --- a/libs/gamecode/builtins/pr_cmds.c +++ b/libs/gamecode/builtins/pr_cmds.c @@ -58,6 +58,8 @@ static const char rcsid[] = #define RETURN_STRING(p, s) ((p)->pr_globals[OFS_RETURN].integer_var = PR_SetString((p), s)) #define RETURN_VECTOR(p, v) (VectorCopy (v, G_VECTOR (p, OFS_RETURN))) +const char *pr_gametype = ""; + /* BUILT-IN FUNCTIONS */ // FIXME: Hunk_TempAlloc, Sys_Printf, Cvar_*, PR_SetString, PR_RunError, ED_PrintEdicts, PF_traceon, PF_traceoff, ED_PrintNum, PR_FindBuiltin isn't threadsafe/reentrant @@ -832,6 +834,12 @@ PF_sprintf (progs_t *pr) PR_Error (pr, "PF_sprintf: argument limit exceeded\n"); } +void +PR_gametype (progs_t *pr) +{ + RETURN_STRING (pr, pr_gametype); +} + void PR_Cmds_Init (progs_t *pr) { @@ -870,4 +878,5 @@ PR_Cmds_Init (progs_t *pr) PR_AddBuiltin (pr, "stoi", PF_stoi, 113); // integer (string s) stoi PR_AddBuiltin (pr, "stov", PF_stov, 114); // vector (string s) stov PR_AddBuiltin (pr, "vtos", PF_vtos, 27); // string (vector v) vtos + PR_AddBuiltin (pr, "gametype", PR_gametype, 115); // string () gametype }; diff --git a/nq/source/host.c b/nq/source/host.c index 0c074e6e3..2fbe33a9c 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -914,6 +914,8 @@ Host_Init (quakeparms_t *parms) Memory_Init (parms->membase, parms->memsize); + pr_gametype = "netquake"; + PI_Init (); Chase_Init_Cvars (); diff --git a/qw/source/cl_main.c b/qw/source/cl_main.c index 03ccf6fc9..8bc147beb 100644 --- a/qw/source/cl_main.c +++ b/qw/source/cl_main.c @@ -1652,6 +1652,8 @@ Host_Init (void) PI_Init (); + pr_gametype = "quakeworld"; + CL_Cam_Init_Cvars (); CL_Input_Init_Cvars (); CL_Skin_Init_Cvars (); diff --git a/qw/source/sv_progs.c b/qw/source/sv_progs.c index abd6a815f..a8ff42bb9 100644 --- a/qw/source/sv_progs.c +++ b/qw/source/sv_progs.c @@ -348,6 +348,7 @@ SV_LoadProgs (void) void SV_Progs_Init (void) { + pr_gametype = "quakeworld"; sv_pr_state.edicts = &sv.edicts; sv_pr_state.num_edicts = &sv.num_edicts; sv_pr_state.time = &sv.time;