diff --git a/polymer/eduke32/build/include/mmulti_unstable.h b/polymer/eduke32/build/include/mmulti_unstable.h index 9a4e5373d..b5803e33c 100644 --- a/polymer/eduke32/build/include/mmulti_unstable.h +++ b/polymer/eduke32/build/include/mmulti_unstable.h @@ -4,7 +4,6 @@ #include "compat.h" void callcommit(void); -void initcrc(void); int32_t getcrc(char *buffer, int32_t bufleng); void mmulti_initmultiplayers(int32_t argc, char **argv); void mmulti_sendpacket(int32_t other, char *bufptr, int32_t messleng); diff --git a/polymer/eduke32/build/include/osd.h b/polymer/eduke32/build/include/osd.h index cc248b919..4edb3bc63 100644 --- a/polymer/eduke32/build/include/osd.h +++ b/polymer/eduke32/build/include/osd.h @@ -23,8 +23,34 @@ typedef struct _symbol } symbol_t; symbol_t *symbols; + const char *stripcolorcodes(char *out, const char *in); +enum cvartypes +{ + CVAR_FLOAT, + CVAR_INT, + CVAR_UNSIGNEDINT, + CVAR_BOOL, + CVAR_STRING, + CVAR_NOMULTI = 128, + CVAR_MULTI = 256, + CVAR_NOSAVE = 512, + CVAR_FUNCPTR = 1024, +}; + +typedef struct +{ + char *name; + char *helpstr; + void *var; + int32_t type; // 0 = integer, 1 = unsigned integer, 2 = boolean, 3 = string, |128 = not in multiplayer, |256 = update multi + int32_t extra; // for string, is the length + int32_t min; + int32_t max; +} cvar_t; + + #define OSD_ALIAS 1337 #define OSD_UNALIASED 1338 @@ -109,6 +135,11 @@ int32_t OSD_Dispatch(const char *cmd); // func = the entry point to the function int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func)(const osdfuncparm_t*)); +int32_t osdcmd_cvar_set(const osdfuncparm_t *parm); +int32_t OSD_RegisterCvar(const cvar_t *cvar); + +cvar_t *cvars; + // these correspond to the Duke palettes, so they shouldn't really be here // ...but I don't care diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index 07f47b017..7eebb3171 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -229,6 +229,24 @@ static int32_t osdcmd_vars(const osdfuncparm_t *parm) int32_t baselayer_init(void) { + uint32_t i; + + cvar_t cvars_engine[] = + { +#ifdef SUPERBUILD + { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars, CVAR_FUNCPTR, 0, 0,0 }, + { "r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",osdcmd_vars, CVAR_FUNCPTR, 0, 0,0 }, + { "r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars, CVAR_FUNCPTR, 0, 0,0 }, +#endif + }; + + for (i=0; i: sets the engine's rendering mode.\n" "Mode numbers are:\n" @@ -241,18 +259,15 @@ int32_t baselayer_init(void) #endif , osdfunc_setrendermode); -#endif - OSD_RegisterFunction("r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars); -#ifdef SUPERBUILD - OSD_RegisterFunction("r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars); - OSD_RegisterFunction("r_voxels","r_voxels: enable/disable automatic sprite->voxel rendering",osdcmd_vars); -#endif -#if defined(POLYMOST) && defined(USE_OPENGL) + #ifdef DEBUGGINGAIDS OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint); #endif + OSD_RegisterFunction("glinfo","glinfo: shows OpenGL information about the current OpenGL mode",osdcmd_glinfo); + polymost_initosdfuncs(); #endif + return 0; } diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index de432eba2..f7cfdc340 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -5652,10 +5652,6 @@ int32_t initengine(void) clearbuf(&voxscale[0],sizeof(voxscale)>>2,65536L); #endif -#ifdef POLYMOST - polymost_initosdfuncs(); -#endif - paletteloaded = 0; searchit = 0; searchstat = -1; diff --git a/polymer/eduke32/build/src/mmulti_unstable.c b/polymer/eduke32/build/src/mmulti_unstable.c index 887d3c943..3ada3b74a 100644 --- a/polymer/eduke32/build/src/mmulti_unstable.c +++ b/polymer/eduke32/build/src/mmulti_unstable.c @@ -142,7 +142,7 @@ void deinit_network_transport(gcomtype *gcom); void mmulti_dosendpackets(int32_t other); -void initcrc(void) +static void initcrc(void) { int32_t i, j, k, a; diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index 62cf508ff..213d61667 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -8,6 +8,7 @@ #include "baselayer.h" #include "cache1d.h" #include "pragmas.h" +#include "mmulti.h" symbol_t *symbols = NULL; static symbol_t *addnewsymbol(const char *name); @@ -123,11 +124,63 @@ static void (*_drawosdcursor)(int32_t, int32_t, int32_t, int32_t) = _internal_dr static int32_t (*_getcolumnwidth)(int32_t) = _internal_getcolumnwidth; static int32_t (*_getrowheight)(int32_t) = _internal_getrowheight; +cvar_t *cvars = NULL; +static uint32_t osdnumcvars = 0; +static hashtable_t osdcvarsH = { MAXSYMBOLS<<1, NULL }; + // color code format is as follows: // ^## sets a color, where ## is the palette number // ^S# sets a shade, range is 0-7 equiv to shades 0-14 // ^O resets formatting to defaults +int32_t OSD_RegisterCvar(const cvar_t *cvar) +{ + const char *cp; + + if (!osdinited) OSD_Init(); + + if (!cvar->name) + { + OSD_Printf("OSD_RegisterCvar(): may not register a cvar with a null name\n"); + return -1; + } + if (!cvar->name[0]) + { + OSD_Printf("OSD_RegisterCvar(): may not register a cvar with no name\n"); + return -1; + } + + // check for illegal characters in name + for (cp = cvar->name; *cp; cp++) + { + if ((cp == cvar->name) && (*cp >= '0') && (*cp <= '9')) + { + OSD_Printf("OSD_RegisterCvar(): first character of cvar name \"%s\" must not be a numeral\n", cvar->name); + return -1; + } + if ((*cp < '0') || + (*cp > '9' && *cp < 'A') || + (*cp > 'Z' && *cp < 'a' && *cp != '_') || + (*cp > 'z')) + { + OSD_Printf("OSD_RegisterCvar(): illegal character in cvar name \"%s\"\n", cvar->name); + return -1; + } + } + + if (!cvar->var) + { + OSD_Printf("OSD_RegisterCvar(): may not register a null cvar\n"); + return -1; + } + + cvars = Brealloc(cvars, (osdnumcvars + 1) * sizeof(cvar_t)); + hash_add(&osdcvarsH, cvar->name, osdnumcvars); + Bmemcpy(&cvars[osdnumcvars++], cvar, sizeof(cvar_t)); + + return 0; +} + const char *stripcolorcodes(char *out, const char *in) { char *ptr = out; @@ -624,6 +677,7 @@ void OSD_Cleanup(void) symbol_t *s; hash_free(&osdsymbolsH); + hash_free(&osdcvarsH); for (; symbols; symbols=s) { @@ -634,6 +688,12 @@ void OSD_Cleanup(void) if (osdlog) Bfclose(osdlog); osdlog = NULL; + if (cvars) + { + Bfree(cvars); + cvars = NULL; + } + osdinited=0; } @@ -647,9 +707,10 @@ void OSD_Init(void) Bmemset(osdfmt, osdtextpal+(osdtextshade<<5), TEXTSIZE); Bmemset(osdsymbptrs, 0, sizeof(osdsymbptrs)); - osdnumsymbols = 0; + osdnumsymbols = osdnumcvars = 0; hash_init(&osdsymbolsH); + hash_init(&osdcvarsH); osdlines=1; @@ -1874,3 +1935,94 @@ static symbol_t *findexactsymbol(const char *name) return NULL; } +int32_t osdcmd_cvar_set(const osdfuncparm_t *parm) +{ + int32_t showval = (parm->numparms == 0); + int32_t i; + + i = hash_find(&osdcvarsH, parm->name); + + + if (i < 0) + for (i = osdnumcvars-1; i >= 0; i--) + if (!Bstrcasecmp(parm->name, cvars[i].name)) break; + + if (i > -1) + { + if ((cvars[i].type & CVAR_NOMULTI) && numplayers > 1) + { + // sound the alarm + OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvars[i].name); + return OSDCMD_OK; + } + else + switch (cvars[i].type&0x7f) + { + case CVAR_FLOAT: + { + float val; + if (showval) + { + OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(float*)cvars[i].var,(char*)cvars[i].helpstr); + return OSDCMD_OK; + } + + sscanf(parm->parms[0], "%f", &val); + + if (val < cvars[i].min || val > cvars[i].max) + { + OSD_Printf("%s value out of range\n",cvars[i].name); + return OSDCMD_OK; + } + *(float*)cvars[i].var = val; + OSD_Printf("%s %f",cvars[i].name,val); + } + break; + case CVAR_INT: + case CVAR_UNSIGNEDINT: + case CVAR_BOOL: + { + int32_t val; + if (showval) + { + OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t*)cvars[i].var,(char*)cvars[i].helpstr); + return OSDCMD_OK; + } + + val = atoi(parm->parms[0]); + if (cvars[i].type == CVAR_BOOL) val = val != 0; + + if (val < cvars[i].min || val > cvars[i].max) + { + OSD_Printf("%s value out of range\n",cvars[i].name); + return OSDCMD_OK; + } + *(int32_t*)cvars[i].var = val; + OSD_Printf("%s %d",cvars[i].name,val); + } + break; + case CVAR_STRING: + { + if (showval) + { + OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char*)cvars[i].var,(char*)cvars[i].helpstr); + return OSDCMD_OK; + } + else + { + Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1); + ((char*)cvars[i].var)[cvars[i].extra-1] = 0; + OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var); + } + } + break; + default: + break; + } + // if (cvars[i].type&CVAR_MULTI) + // G_UpdatePlayerFromMenu(); + } + OSD_Printf("\n"); + return OSDCMD_OK; +} + diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 21d4e4736..d0393dbd0 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -6140,35 +6140,74 @@ static int32_t dumptexturedefs(const osdfuncparm_t *parm) void polymost_initosdfuncs(void) { + uint32_t i; + + cvar_t cvars_polymost[] = + { #ifdef USE_OPENGL - OSD_RegisterFunction("r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",osdcmd_polymostvars); - OSD_RegisterFunction("r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",osdcmd_polymostvars); - OSD_RegisterFunction("r_detailmapping","r_detailmapping: enable/disable detail mapping",osdcmd_polymostvars); - OSD_RegisterFunction("r_downsize","r_downsize: controls downsizing factor for hires textures",osdcmd_polymostvars); - OSD_RegisterFunction("r_fullbrights","r_fullbrights: enable/disable fullbright textures",osdcmd_polymostvars); - OSD_RegisterFunction("r_glowmapping","r_glowmapping: enable/disable glow mapping",osdcmd_polymostvars); - OSD_RegisterFunction("r_multisample","r_multisample: sets the number of samples used for antialiasing (0 = off)",osdcmd_polymostvars); - OSD_RegisterFunction("r_nvmultisamplehint","r_nvmultisamplehint: enable/disable Nvidia multisampling hinting",osdcmd_polymostvars); - OSD_RegisterFunction("r_parallaxskyclamping","r_parallaxskyclamping: enable/disable parallaxed floor/ceiling sky texture clamping",osdcmd_polymostvars); - OSD_RegisterFunction("r_parallaxskypanning","r_parallaxskypanning: enable/disable parallaxed floor/ceiling panning when drawing a parallaxed sky",osdcmd_polymostvars); - OSD_RegisterFunction("r_polygonmode","r_polygonmode: debugging feature",osdcmd_polymostvars); //FUK - OSD_RegisterFunction("r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",osdcmd_polymostvars); - OSD_RegisterFunction("r_shadescale","r_shadescale: multiplier for lighting",osdcmd_polymostvars); - OSD_RegisterFunction("r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",osdcmd_polymostvars); - OSD_RegisterFunction("r_texcachecompression","r_texcachecompression: enable/disable compression of files in the OpenGL compressed texture cache",osdcmd_polymostvars); - OSD_RegisterFunction("r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",osdcmd_polymostvars); - OSD_RegisterFunction("r_texcompr","r_texcompr: enable/disable OpenGL texture compression",osdcmd_polymostvars); - OSD_RegisterFunction("r_textureanisotropy", "r_textureanisotropy: changes the OpenGL texture anisotropy setting", gltextureanisotropy); - OSD_RegisterFunction("r_texturemaxsize","r_texturemaxsize: changes the maximum OpenGL texture size limit",osdcmd_polymostvars); - OSD_RegisterFunction("r_texturemiplevel","r_texturemiplevel: changes the highest OpenGL mipmap level used",osdcmd_polymostvars); - OSD_RegisterFunction("r_texturemode", "r_texturemode: changes the texture filtering settings", gltexturemode); - OSD_RegisterFunction("r_vbocount","r_vbocount: sets the number of Vertex Buffer Objects to use when drawing models",osdcmd_polymostvars); - OSD_RegisterFunction("r_vbos","r_vbos: enable/disable using Vertex Buffer Objects when drawing models",osdcmd_polymostvars); - OSD_RegisterFunction("r_vertexarrays","r_vertexarrays: enable/disable using vertex arrays when drawing models",osdcmd_polymostvars); + { "r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_detailmapping","r_detailmapping: enable/disable detail mapping",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_downsize","r_downsize: controls downsizing factor for hires textures",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_fullbrights","r_fullbrights: enable/disable fullbright textures",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_glowmapping","r_glowmapping: enable/disable glow mapping",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_multisample","r_multisample: sets the number of samples used for antialiasing (0 = off)",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_nvmultisamplehint","r_nvmultisamplehint: enable/disable Nvidia multisampling hinting",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_parallaxskyclamping","r_parallaxskyclamping: enable/disable parallaxed floor/ceiling sky texture clamping",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_parallaxskypanning","r_parallaxskypanning: enable/disable parallaxed floor/ceiling panning when drawing a parallaxed sky",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_polygonmode","r_polygonmode: debugging feature",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, //FUK + { "r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_shadescale","r_shadescale: multiplier for lighting",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_texcachecompression","r_texcachecompression: enable/disable compression of files in the OpenGL compressed texture cache",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_texcompr","r_texcompr: enable/disable OpenGL texture compression",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_textureanisotropy", "r_textureanisotropy: changes the OpenGL texture anisotropy setting", gltextureanisotropy, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_texturemaxsize","r_texturemaxsize: changes the maximum OpenGL texture size limit",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_texturemiplevel","r_texturemiplevel: changes the highest OpenGL mipmap level used",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_texturemode", "r_texturemode: changes the texture filtering settings", gltexturemode, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_vbocount","r_vbocount: sets the number of Vertex Buffer Objects to use when drawing models",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_vbos","r_vbos: enable/disable using Vertex Buffer Objects when drawing models",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_vertexarrays","r_vertexarrays: enable/disable using vertex arrays when drawing models",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 0, 1 }, + { "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_INT, 0, 0, 2 }, + +#ifdef POLYMER + // polymer cvars + { "r_pr_lighting", "r_pr_lighting: enable/disable dynamic lights", (void*)&pr_lighting, CVAR_BOOL, 0, 0, 1 }, + { "r_pr_normalmapping", "r_pr_normalmapping: enable/disable virtual displacement mapping", (void*)&pr_normalmapping, CVAR_BOOL, 0, 0, 1 }, + { "r_pr_specularmapping", "r_pr_specularmapping: enable/disable specular mapping", (void*)&pr_specularmapping, CVAR_BOOL, 0, 0, 1 }, + { "r_pr_shadows", "r_pr_shadows: enable/disable dynamic shadows", (void*)&pr_shadows, CVAR_BOOL, 0, 0, 1 }, + { "r_pr_shadowcount", "r_pr_shadowcount: maximal amount of shadow emitting lights on screen - you need to restart the renderer for it to take effect", (void*)&pr_shadowcount, CVAR_INT, 0, 0, 64 }, + { "r_pr_shadowdetail", "r_pr_shadowdetail: sets the shadow map resolution - you need to restart the renderer for it to take effect", (void*)&pr_shadowdetail, CVAR_INT, 0, 0, 5 }, + { "r_pr_maxlightpasses", "r_pr_maxlightpasses: the maximal amount of lights a single object can by affected by", (void*)&pr_maxlightpasses, CVAR_INT, 0, 0, 512 }, + { "r_pr_maxlightpriority", "r_pr_maxlightpriority: lowering that value removes less meaningful lights from the scene", (void*)&pr_maxlightpriority, CVAR_INT, 0, 0, PR_MAXLIGHTPRIORITY }, + { "r_pr_fov", "r_pr_fov: sets the field of vision in build angle", (void*)&pr_fov, CVAR_INT, 0, 0, 1023}, + { "r_pr_billboardingmode", "r_pr_billboardingmode: face sprite display method. 0: classic mode; 1: polymost mode", (void*)&pr_billboardingmode, CVAR_INT, 0, 0, 1 }, + { "r_pr_verbosity", "r_pr_verbosity: verbosity level of the polymer renderer", (void*)&pr_verbosity, CVAR_INT, 0, 0, 3 }, + { "r_pr_wireframe", "r_pr_wireframe: toggles wireframe mode", (void*)&pr_wireframe, CVAR_INT, 0, 0, 1 }, + { "r_pr_vbos", "r_pr_vbos: contols Vertex Buffer Object usage. 0: no VBOs. 1: VBOs for map data. 2: VBOs for model data.", (void*)&pr_vbos, CVAR_INT, 0, 0, 2 }, + { "r_pr_gpusmoothing", "r_pr_gpusmoothing: toggles model animation interpolation", (void*)&pr_gpusmoothing, CVAR_INT, 0, 0, 1 }, + { "r_pr_overrideparallax", "r_pr_overrideparallax: overrides parallax mapping scale and bias values with values from the pr_parallaxscale and pr_parallaxbias cvars; use it to fine-tune DEF tokens", (void*)&pr_overrideparallax, CVAR_BOOL, 0, 0, 1 }, + { "r_pr_parallaxscale", "r_pr_parallaxscale: overriden parallax mapping offset scale", (void*)&pr_parallaxscale, CVAR_FLOAT, 0, -10, 10 }, + { "r_pr_parallaxbias", "r_pr_parallaxbias: overriden parallax mapping offset bias", (void*)&pr_parallaxbias, CVAR_FLOAT, 0, -10, 10 }, + { "r_pr_overridespecular", "r_pr_overridespecular: overrides specular material power and factor values with values from the pr_specularpower and pr_specularfactor cvars; use it to fine-tune DEF tokens", (void*)&pr_overridespecular, CVAR_BOOL, 0, 0, 1 }, + { "r_pr_specularpower", "r_pr_specularpower: overriden specular material power", (void*)&pr_specularpower, CVAR_FLOAT, 0, -10, 1000 }, + { "r_pr_specularfactor", "r_pr_specularfactor: overriden specular material factor", (void*)&pr_specularfactor, CVAR_FLOAT, 0, -10, 1000 }, #endif - OSD_RegisterFunction("r_models","r_models: enable/disable model rendering in >8-bit mode",osdcmd_polymostvars); - OSD_RegisterFunction("r_hightile","r_hightile: enable/disable hightile texture rendering in >8-bit mode",osdcmd_polymostvars); - //OSD_RegisterFunction("dumptexturedefs","dumptexturedefs: dumps all texture definitions in the new style",dumptexturedefs); + + { "r_models","r_models: enable/disable model rendering in >8-bit mode",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, + { "r_hightile","r_hightile: enable/disable hightile texture rendering in >8-bit mode",osdcmd_polymostvars, CVAR_FUNCPTR, 0, 0, 0 }, +#endif + }; + + for (i=0; inumparms == 0); - uint32_t i; - - for (i = 0; i < sizeof(cvars)/sizeof(cvar_t); i++) + if (parm->numparms == 0) { - if (!Bstrcasecmp(parm->name, cvars[i].name)) - { - if ((cvars[i].type & CVAR_NOMULTI) && numplayers > 1) - { - // sound the alarm - OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvars[i].name); - return OSDCMD_OK; - } - else - switch (cvars[i].type&0x7f) - { - case CVAR_FLOAT: - { - float val; - if (showval) - { - OSD_Printf("\"%s\" is \"%f\"\n%s\n",cvars[i].name,*(float*)cvars[i].var,(char*)cvars[i].helpstr); - return OSDCMD_OK; - } - - sscanf(parm->parms[0], "%f", &val); - - if (val < cvars[i].min || val > cvars[i].max) - { - OSD_Printf("%s value out of range\n",cvars[i].name); - return OSDCMD_OK; - } - *(float*)cvars[i].var = val; - OSD_Printf("%s %f",cvars[i].name,val); - } - break; - case CVAR_INT: - case CVAR_UNSIGNEDINT: - case CVAR_BOOL: - { - int32_t val; - if (showval) - { - OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvars[i].name,*(int32_t*)cvars[i].var,(char*)cvars[i].helpstr); - return OSDCMD_OK; - } - - val = atoi(parm->parms[0]); - if (cvars[i].type == CVAR_BOOL) val = val != 0; - - if (val < cvars[i].min || val > cvars[i].max) - { - OSD_Printf("%s value out of range\n",cvars[i].name); - return OSDCMD_OK; - } - *(int32_t*)cvars[i].var = val; - OSD_Printf("%s %d",cvars[i].name,val); - } - break; - case CVAR_STRING: - { - if (showval) - { - OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvars[i].name,(char*)cvars[i].var,(char*)cvars[i].helpstr); - return OSDCMD_OK; - } - else - { - Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1); - ((char*)cvars[i].var)[cvars[i].extra-1] = 0; - OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var); - } - } - break; - default: - break; - } - if (cvars[i].type&CVAR_MULTI) - G_UpdatePlayerFromMenu(); - } + OSD_Printf("\"crosshairscale\" is \"%d\"\n", ud.crosshairscale); + return OSDCMD_SHOWHELP; } - OSD_Printf("\n"); + else if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + ud.crosshairscale = min(100,max(10,Batol(parm->parms[0]))); + OSD_Printf("%s\n", parm->raw); + return OSDCMD_OK; +} + +extern void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b); +extern palette_t CrosshairColors; + +static int32_t osdcmd_crosshaircolor(const osdfuncparm_t *parm) +{ + int32_t r, g, b; + + if (parm->numparms != 3) + { + OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); + return OSDCMD_SHOWHELP; + } + r = atol(parm->parms[0]); + g = atol(parm->parms[1]); + b = atol(parm->parms[2]); + G_SetCrosshairColor(r,g,b); + OSD_Printf("%s\n", parm->raw); return OSDCMD_OK; } @@ -1404,40 +1273,6 @@ static int32_t osdcmd_vid_contrast(const osdfuncparm_t *parm) return OSDCMD_OK; } -static int32_t osdcmd_setcrosshairscale(const osdfuncparm_t *parm) -{ - if (parm->numparms == 0) - { - OSD_Printf("\"crosshairscale\" is \"%d\"\n", ud.crosshairscale); - return OSDCMD_SHOWHELP; - } - else if (parm->numparms != 1) return OSDCMD_SHOWHELP; - - ud.crosshairscale = min(100,max(10,Batol(parm->parms[0]))); - OSD_Printf("%s\n", parm->raw); - return OSDCMD_OK; -} - -extern void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b); -extern palette_t CrosshairColors; - -static int32_t osdcmd_crosshaircolor(const osdfuncparm_t *parm) -{ - int32_t r, g, b; - - if (parm->numparms != 3) - { - OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b); - return OSDCMD_SHOWHELP; - } - r = atol(parm->parms[0]); - g = atol(parm->parms[1]); - b = atol(parm->parms[2]); - G_SetCrosshairColor(r,g,b); - OSD_Printf("%s\n", parm->raw); - return OSDCMD_OK; -} - static int32_t osdcmd_visibility(const osdfuncparm_t *parm) { float f; @@ -1495,12 +1330,83 @@ static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) int32_t registerosdcommands(void) { uint32_t i; - osdcmd_cheatsinfo_stat.cheatnum = -1; - for (i=0; i: changes the mouse sensitivity", osdcmd_sensitivity, CVAR_FUNCPTR, 0, 0, 0 }, + + { "snd_ambience", "snd_ambience: enables/disables ambient sounds", (void*)&ud.config.AmbienceToggle, CVAR_BOOL, 0, 0, 1 }, + { "snd_duketalk", "snd_duketalk: enables/disables Duke's speech", (void*)&ud.config.VoiceToggle, CVAR_INT, 0, 0, 5 }, + { "snd_fxvolume", "snd_fxvolume: volume of sound effects", (void*)&ud.config.FXVolume, CVAR_INT, 0, 0, 255 }, + { "snd_mixrate", "snd_mixrate: sound mixing rate", (void*)&ud.config.MixRate, CVAR_INT, 0, 0, 48000 }, + { "snd_musvolume", "snd_musvolume: volume of midi music", (void*)&ud.config.MusicVolume, CVAR_INT, 0, 0, 255 }, + { "snd_numbits", "snd_numbits: sound bits", (void*)&ud.config.NumBits, CVAR_INT, 0, 8, 16 }, + { "snd_numchannels", "snd_numchannels: the number of sound channels", (void*)&ud.config.NumChannels, CVAR_INT, 0, 0, 2 }, + { "snd_numvoices", "snd_numvoices: the number of concurrent sounds", (void*)&ud.config.NumVoices, CVAR_INT, 0, 0, 32 }, + { "snd_reversestereo", "snd_reversestereo: reverses the stereo channels", (void*)&ud.config.ReverseStereo, CVAR_BOOL, 0, 0, 16 }, + { "vid_gamma","vid_gamma : adjusts gamma ramp",osdcmd_vid_gamma, CVAR_FUNCPTR, 0, 0, 0 }, + { "vid_contrast","vid_contrast : adjusts gamma ramp",osdcmd_vid_contrast, CVAR_FUNCPTR, 0, 0, 0 }, + { "vid_brightness","vid_brightness : adjusts gamma ramp",osdcmd_vid_brightness, CVAR_FUNCPTR, 0, 0, 0 }, + + }; + + for (i=0; i: adds path to game filesystem", osdcmd_addpath); - OSD_RegisterFunction("bind","bind : associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind); - - OSD_RegisterFunction("hud_scale","hud_scale: changes the hud scale", osdcmd_setstatusbarscale); - OSD_RegisterFunction("hud_weaponscale","hud_weaponscale: changes the weapon scale", osdcmd_setweaponscale); - OSD_RegisterFunction("crosshairscale","crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale); - OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes crosshair color", osdcmd_crosshaircolor); OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu); - OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo); - OSD_RegisterFunction("fileinfo","fileinfo : gets a file's information", osdcmd_fileinfo); for (i=0; i: gives requested item", osdcmd_give); OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); - OSD_RegisterFunction("in_joystick","in_joystick: enables input from the joystick if it is present",osdcmd_usemousejoy); - OSD_RegisterFunction("in_mouse","in_mouse: enables input from the mouse if it is present",osdcmd_usemousejoy); OSD_RegisterFunction("initgroupfile","initgroupfile : adds a grp file into the game filesystem", osdcmd_initgroupfile); OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer); @@ -1557,14 +1453,10 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit); OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit); - OSD_RegisterFunction("rate","rate: sets the multiplayer packet send rate, in packets/sec",osdcmd_rate); +// OSD_RegisterFunction("rate","rate: sets the multiplayer packet send rate, in packets/sec",osdcmd_rate); OSD_RegisterFunction("restartsound","restartsound: reinitializes the sound system",osdcmd_restartsound); OSD_RegisterFunction("restartvid","restartvid: reinitializes the video mode",osdcmd_restartvid); - OSD_RegisterFunction("r_ambientlight", "r_ambientlight: sets the global map light level",osdcmd_visibility); - OSD_RegisterFunction("r_maxfps", "r_maxfps: sets a framerate cap",osdcmd_maxfps); - - OSD_RegisterFunction("sensitivity","sensitivity : changes the mouse sensitivity", osdcmd_sensitivity); OSD_RegisterFunction("addlogvar","addlogvar : prints the value of a gamevar", osdcmd_addlogvar); OSD_RegisterFunction("setvar","setvar : sets the value of a gamevar", osdcmd_setvar); OSD_RegisterFunction("setvarvar","setvarvar : sets the value of to ", osdcmd_setvar); @@ -1577,9 +1469,6 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall); OSD_RegisterFunction("vidmode","vidmode : change the video mode",osdcmd_vidmode); - OSD_RegisterFunction("vid_gamma","vid_gamma : adjusts gamma ramp",osdcmd_vid_gamma); - OSD_RegisterFunction("vid_contrast","vid_contrast : adjusts gamma ramp",osdcmd_vid_contrast); - OSD_RegisterFunction("vid_brightness","vid_brightness : adjusts gamma ramp",osdcmd_vid_brightness); // OSD_RegisterFunction("savestate","",osdcmd_savestate); // OSD_RegisterFunction("restorestate","",osdcmd_restorestate); //baselayer_onvideomodechange = onvideomodechange; diff --git a/polymer/eduke32/source/osdcmds.h b/polymer/eduke32/source/osdcmds.h index 821411490..04203458b 100644 --- a/polymer/eduke32/source/osdcmds.h +++ b/polymer/eduke32/source/osdcmds.h @@ -12,30 +12,5 @@ int32_t registerosdcommands(void); extern float r_ambientlight,r_ambientlightrecip; -enum cvartypes -{ - CVAR_FLOAT, - CVAR_INT, - CVAR_UNSIGNEDINT, - CVAR_BOOL, - CVAR_STRING, - CVAR_NOMULTI = 128, - CVAR_MULTI = 256, - CVAR_NOSAVE = 512 -}; - -typedef struct -{ - char *name; - char *helpstr; - void *var; - int32_t type; // 0 = integer, 1 = unsigned integer, 2 = boolean, 3 = string, |128 = not in multiplayer, |256 = update multi - int32_t extra; // for string, is the length - int32_t min; - int32_t max; -} cvar_t; - -extern cvar_t cvars[]; - #endif // __osdcmds_h__