Some more cvar stuff

git-svn-id: https://svn.eduke32.com/eduke32@1355 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-04-29 19:43:51 +00:00
parent c222341417
commit 30a649c86f
16 changed files with 233 additions and 285 deletions

View file

@ -49,6 +49,13 @@ extern "C" {
#define TSPR_TEMP 99
#define TSPR_MIRROR 100
#define PR_LIGHT_PRIO_MAX 0
#define PR_LIGHT_PRIO_MAX_GAME 1
#define PR_LIGHT_PRIO_HIGH 2
#define PR_LIGHT_PRIO_HIGH_GAME 3
#define PR_LIGHT_PRIO_LOW 4
#define PR_LIGHT_PRIO_LOW_GAME 5
#define CLIPMASK0 (((1L)<<16)+1L)
#define CLIPMASK1 (((256L)<<16)+64L)

View file

@ -137,8 +137,7 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func)
int32_t osdcmd_cvar_set(const osdfuncparm_t *parm);
int32_t OSD_RegisterCvar(const cvar_t *cvar);
cvar_t *cvars;
void OSD_WriteCvars(const char *setupfilename);
// these correspond to the Duke palettes, so they shouldn't really be here
// ...but I don't care

View file

@ -150,13 +150,6 @@ typedef struct s_prprogrambit {
#define SHADOW_DEPTH_OFFSET 30
#define PR_MAXLIGHTPRIORITY 6
#define PR_LIGHT_PRIO_MAX 0
#define PR_LIGHT_PRIO_MAX_GAME 1
#define PR_LIGHT_PRIO_HIGH 2
#define PR_LIGHT_PRIO_HIGH_GAME 3
#define PR_LIGHT_PRIO_LOW 4
#define PR_LIGHT_PRIO_LOW_GAME 5
typedef struct s_prlight {
int32_t x, y, z, horiz, range;
int16_t angle, faderadius, radius, sector;

View file

@ -765,7 +765,9 @@ void editinput(void)
{
memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES);
memset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID));
#ifdef POLYMER
staticlightcount = 0;
#endif
mhk=0;
initprintf("Maphacks disabled\n");
keystatus[0x44] = 0;

View file

@ -137,7 +137,9 @@ int32_t loadsetup(const char *fn)
if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; }
if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val);
if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(524288,Batoi(val)),65536);
#ifdef POLYMER
if (readconfig(fp, "rendmode", val, VL) > 0) { i = Batoi(val); glrendmode = i; }
#endif
if (readconfig(fp, "brightness", val, VL) > 0)
{
brightness = min(max(Batoi(val),0),15);
@ -296,9 +298,11 @@ int32_t writesetup(const char *fn)
"; 3D-mode colour depth\n"
"bpp = %d\n"
"\n"
#ifdef POLYMER
"; Rendering mode\n"
"rendmode = %d\n"
"\n"
#endif
"; Grid limits\n"
"editorgridextent = %d\n"
"\n"
@ -441,7 +445,10 @@ int32_t writesetup(const char *fn)
"; remap = 10-3A,31-B8\n"
"remap = ",
forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, glrendmode,
forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame,
#ifdef POLYMER
glrendmode,
#endif
editorgridextent,
#if defined(POLYMOST) && defined(USE_OPENGL)
glusetexcache, glusetexcachecompression, gltexfiltermode, glanisotropy,

View file

@ -124,7 +124,7 @@ 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 cvar_t *cvars = NULL;
static uint32_t osdnumcvars = 0;
static hashtable_t osdcvarsH = { MAXSYMBOLS<<1, NULL };
@ -1975,7 +1975,8 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
*(float*)cvars[i].var = val;
OSD_Printf("%s %f",cvars[i].name,val);
if (!OSD_ParsingScript())
OSD_Printf("%s %f",cvars[i].name,val);
}
break;
case CVAR_INT:
@ -1998,7 +1999,8 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
*(int32_t*)cvars[i].var = val;
OSD_Printf("%s %d",cvars[i].name,val);
if (!OSD_ParsingScript())
OSD_Printf("%s %d",cvars[i].name,val);
}
break;
case CVAR_STRING:
@ -2008,12 +2010,11 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
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;
Bstrncpy((char*)cvars[i].var, parm->parms[0], cvars[i].extra-1);
((char*)cvars[i].var)[cvars[i].extra-1] = 0;
if (!OSD_ParsingScript())
OSD_Printf("%s %s",cvars[i].name,(char*)cvars[i].var);
}
}
break;
default:
@ -2022,7 +2023,54 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
// if (cvars[i].type&CVAR_MULTI)
// G_UpdatePlayerFromMenu();
}
OSD_Printf("\n");
if (!OSD_ParsingScript())
OSD_Printf("\n");
return OSDCMD_OK;
}
void OSD_WriteCvars(const char *setupfilename)
{
uint32_t i;
FILE *fp;
char *ptr = Bstrdup(setupfilename);
char tempbuf[128];
Bsprintf(tempbuf, "%s_cvars.cfg", strtok(ptr, "."));
fp = fopen(tempbuf, "wt");
if (fp)
{
fprintf(fp,"// this file automatically generated by EDuke32\n// do not modify if you lack common sense\n");
for (i=0; i<osdnumcvars; i++)
{
if (!(cvars[i].type & CVAR_NOSAVE) && cvars[i].type != CVAR_FUNCPTR)
switch (cvars[i].type&0x7f)
{
case CVAR_FLOAT:
fprintf(fp,"%s \"%f\"\n",cvars[i].name,*(float*)cvars[i].var);
break;
case CVAR_INT:
case CVAR_UNSIGNEDINT:
case CVAR_BOOL:
fprintf(fp,"%s \"%d\"\n",cvars[i].name,*(int32_t *)cvars[i].var);
break;
case CVAR_STRING:
fprintf(fp,"%s \"%s\"\n",cvars[i].name,(char*)cvars[i].var);
break;
default:
break;
}
}
fclose(fp);
Bsprintf(tempbuf,"Wrote %s_cvars.cfg\n",ptr);
OSD_Printf(tempbuf);
Bfree(ptr);
return;
}
Bsprintf(tempbuf,"Error writing %s_cvars.cfg: %s\n",ptr,strerror(errno));
OSD_Printf(tempbuf);
Bfree(ptr);
}

View file

@ -5874,43 +5874,13 @@ static int32_t gltexturemode(const osdfuncparm_t *parm)
else if (m >= (int32_t)numglfiltermodes) m = numglfiltermodes - 1;
}
if (m != gltexfiltermode)
{
gltexfiltermode = m;
gltexapplyprops();
}
gltexfiltermode = m;
gltexapplyprops();
OSD_Printf("Texture filtering mode changed to %s\n", glfiltermodes[gltexfiltermode].name);
return OSDCMD_OK;
}
static int32_t gltextureanisotropy(const osdfuncparm_t *parm)
{
int32_t l;
const char *p;
if (parm->numparms != 1)
{
OSD_Printf("Current texture anisotropy is %d\n", glanisotropy);
OSD_Printf(" Maximum is %d\n", (int32_t)glinfo.maxanisotropy);
return OSDCMD_OK;
}
l = Bstrtoul(parm->parms[0], (char **)&p, 10);
if (l < 0 || l > (int32_t)glinfo.maxanisotropy) l = 0;
if (l != gltexfiltermode)
{
glanisotropy = l;
gltexapplyprops();
}
OSD_Printf("Texture anisotropy changed to %d\n", glanisotropy);
return OSDCMD_OK;
}
#endif
static int32_t osdcmd_cvar_set_polymost(const osdfuncparm_t *parm)
@ -5931,6 +5901,17 @@ static int32_t osdcmd_cvar_set_polymost(const osdfuncparm_t *parm)
OSD_Printf("restartvid: Reset failed...\n");
return r;
}
else if (!Bstrcasecmp(parm->name, "r_textureanisotropy"))
{
gltexapplyprops();
return r;
}
else if (!Bstrcasecmp(parm->name, "r_texturemode"))
{
gltexturemode(parm);
return r;
}
#endif
return r;
}
@ -5963,10 +5944,10 @@ void polymost_initosdfuncs(void)
{ "r_texcachecompression","r_texcachecompression: enable/disable compression of files in the OpenGL compressed texture cache",(void *)&glusetexcachecompression, CVAR_BOOL, 0, 0, 1 },
{ "r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",(void *)&glusetexcache, CVAR_BOOL, 0, 0, 1 },
{ "r_texcompr","r_texcompr: enable/disable OpenGL texture compression",(void *)&glusetexcompr, CVAR_BOOL, 0, 0, 1 },
{ "r_textureanisotropy", "r_textureanisotropy: changes the OpenGL texture anisotropy setting", (void *)&gltextureanisotropy, CVAR_INT, 0, 0, 16 },
{ "r_textureanisotropy", "r_textureanisotropy: changes the OpenGL texture anisotropy setting", (void *)&glanisotropy, CVAR_INT|CVAR_FUNCPTR, 0, 0, 16 },
{ "r_texturemaxsize","r_texturemaxsize: changes the maximum OpenGL texture size limit",(void *)&gltexmaxsize, CVAR_INT, 0, 0, 4096 },
{ "r_texturemiplevel","r_texturemiplevel: changes the highest OpenGL mipmap level used",(void *)&gltexmiplevel, CVAR_INT, 0, 0, 6 },
{ "r_texturemode", "r_texturemode: changes the texture filtering settings", (void *)&gltexturemode, CVAR_INT, 0, 0, 5 },
{ "r_texturemode", "r_texturemode: changes the texture filtering settings", (void *)&gltexfiltermode, CVAR_INT|CVAR_FUNCPTR, 0, 0, 5 },
{ "r_vbocount","r_vbocount: sets the number of Vertex Buffer Objects to use when drawing models",(void *)&r_vbocount, CVAR_INT, 0, 1, 256 },
{ "r_vbos","r_vbos: enable/disable using Vertex Buffer Objects when drawing models",(void *)&r_vbos, CVAR_BOOL, 0, 0, 1 },
{ "r_vertexarrays","r_vertexarrays: enable/disable using vertex arrays when drawing models",(void *)&r_vertexarrays, CVAR_BOOL, 0, 0, 1 },

View file

@ -5160,7 +5160,7 @@ static void G_MoveMisc(void) // STATNUM 5
case EXPLOSION2__STATIC:
G_AddGameLight(0, s->sectnum, s->x, s->y, s->z-((s->yrepeat*tilesizy[s->picnum])<<1),
(512 * s->yrepeat) / (ActorExtra[i].temp_data[2]+1), 255+(80<<8),PR_LIGHT_PRIO_HIGH_GAME);
(512 * s->yrepeat) / (ActorExtra[i].temp_data[2]+1), 255+(80<<8),PR_LIGHT_PRIO_HIGH_GAME);
break;
case FORCERIPPLE__STATIC:
// case TRANSPORTERSTAR__STATIC:
@ -7519,7 +7519,7 @@ static void G_MoveEffectors(void) //STATNUM 3
A_SetSprite(k,CLIPMASK0);
}
break;
#if 1 // POLYMER
#ifdef POLYMER
case 49:
{
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = SECT;
@ -7551,7 +7551,8 @@ static void G_MoveEffectors(void) //STATNUM 3
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_LOW;
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_HIGH;
} else
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX;
if (gamelightcount < PR_MAXLIGHTS)
@ -7590,7 +7591,8 @@ static void G_MoveEffectors(void) //STATNUM 3
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_LOW;
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_HIGH;
} else
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX;
if (gamelightcount < PR_MAXLIGHTS)

View file

@ -9780,6 +9780,7 @@ void ExtAnalyzeSprites(void)
spritetype *tspr;
int32_t frames=0, l;
#ifdef POLYMER
gamelightcount = 0;
for (i=numsprites-1; i>=0; i--)
@ -9816,7 +9817,8 @@ void ExtAnalyzeSprites(void)
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_LOW;
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_HIGH;
} else
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX;
gamelightcount++;
@ -9853,13 +9855,14 @@ void ExtAnalyzeSprites(void)
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_LOW;
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_HIGH;
} else
}
else
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX;
gamelightcount++;
}
}
#endif
for (i=0,tspr=&tsprite[0]; i<spritesortcnt; i++,tspr++)
{
frames=0;

View file

@ -305,7 +305,7 @@ void CONFIG_SetDefaults(void)
ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]);
CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
}
CONTROL_SetMouseSensitivity(DEFAULTMOUSESENSITIVITY);
CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions));
for (i=0; i<MAXJOYBUTTONS; i++)
@ -447,7 +447,7 @@ void CONFIG_SetupMouse(void)
int32_t i;
char str[80];
char temp[80];
int32_t function, scale;
int32_t scale;
if (ud.config.scripthandle < 0) return;
@ -491,9 +491,11 @@ void CONFIG_SetupMouse(void)
ud.config.MouseAnalogueScale[i] = scale;
}
function = DEFAULTMOUSESENSITIVITY;
SCRIPT_GetNumber(ud.config.scripthandle, "Controls","Mouse_Sensitivity",&function);
CONTROL_SetMouseSensitivity(function);
{
tempbuf[0] = 0;
SCRIPT_GetString(ud.config.scripthandle, "Controls","Mouse_Sensitivity",&tempbuf[0]);
if (tempbuf[0]) CONTROL_MouseSensitivity = atof(tempbuf);
}
for (i=0; i<MAXMOUSEBUTTONS; i++)
{
@ -1197,8 +1199,9 @@ void CONFIG_WriteSetup(void)
Bsprintf(buf,"MouseAnalogScale%d",dummy);
SCRIPT_PutNumber(ud.config.scripthandle, "Controls", buf, ud.config.MouseAnalogueScale[dummy], FALSE, FALSE);
}
dummy = CONTROL_GetMouseSensitivity();
SCRIPT_PutNumber(ud.config.scripthandle, "Controls","Mouse_Sensitivity",dummy,FALSE,FALSE);
Bsprintf(tempbuf,"%.2f",CONTROL_MouseSensitivity);
SCRIPT_PutString(ud.config.scripthandle, "Controls","Mouse_Sensitivity",tempbuf);
for (dummy=0; dummy<MAXJOYBUTTONS; dummy++)
{
@ -1259,6 +1262,7 @@ void CONFIG_WriteSetup(void)
SCRIPT_Free(ud.config.scripthandle);
OSD_Printf("Wrote %s\n",setupfilename);
CONFIG_WriteBinds();
OSD_WriteCvars(setupfilename);
}

View file

@ -7045,6 +7045,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio)
t->sectnum = mycursectnum;
}
else t->ang = g_player[p].ps->ang+mulscale16((int32_t)(((g_player[p].ps->ang+1024- g_player[p].ps->oang)&2047)-1024),smoothratio);
#if defined(POLYMOST) && defined(USE_OPENGL)
if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0)
{
static int32_t targetang = 0;
@ -7067,7 +7068,9 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio)
targetang = clamp(targetang, -128, 128);
t->ang += targetang;
}
else t->cstat |= 2;
else
#endif
t->cstat |= 2;
}
if (ud.multimode > 1 && (display_mirror || screenpeek != p || s->owner == -1))
@ -11512,6 +11515,23 @@ CLEAN_DIRECTORY:
for (i=0; i<joynumaxes; i++)
setjoydeadzone(i,ud.config.JoystickAnalogueDead[i],ud.config.JoystickAnalogueSaturate[i]);
/* if (VOLUMEONE)
{
if (numplayers > 4 || ud.multimode > 4)
G_GameExit(" The full version of Duke Nukem 3D supports 5 or more players.");
} */
{
char *ptr = Bstrdup(setupfilename), *p = strtok(ptr,".");
Bsprintf(tempbuf,"%s_binds.cfg",p);
OSD_Exec(tempbuf);
Bsprintf(tempbuf,"%s_cvars.cfg",p);
OSD_Exec(tempbuf);
Bfree(ptr);
}
OSD_Exec("autoexec.cfg");
if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0)
{
int32_t i = 0;
@ -11550,35 +11570,14 @@ CLEAN_DIRECTORY:
ud.config.ScreenBPP = bpp[i];
}
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
initprintf("Initializing music...\n");
S_MusicStartup();
initprintf("Initializing sound...\n");
S_SoundStartup();
loadtmb();
/* if (VOLUMEONE)
{
if (numplayers > 4 || ud.multimode > 4)
G_GameExit(" The full version of Duke Nukem 3D supports 5 or more players.");
} */
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
// if(KB_KeyPressed( sc_Escape ) ) G_GameExit(" ");
FX_StopAllSounds();
S_ClearSoundLocks();
OSD_Exec("autoexec.cfg");
{
char *ptr = Bstrdup(setupfilename);
Bsprintf(tempbuf,"%s_binds.cfg",strtok(ptr,"."));
Bfree(ptr);
}
OSD_Exec(tempbuf);
if (ud.warp_on > 1 && ud.multimode < 2)
{
clearview(0L);
@ -11593,6 +11592,11 @@ CLEAN_DIRECTORY:
ud.warp_on = 0;
}
// if(KB_KeyPressed( sc_Escape ) ) G_GameExit(" ");
FX_StopAllSounds();
S_ClearSoundLocks();
// getpackets();
MAIN_LOOP_RESTART:

View file

@ -27,7 +27,7 @@ uint64 CONTROL_ButtonState = 0;
uint64 CONTROL_ButtonHeldState = 0;
// static int32_t CONTROL_UserInputDelay = -1;
static int32_t CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
float CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
static int32_t CONTROL_NumMouseButtons = 0;
static int32_t CONTROL_NumMouseAxes = 0;
static int32_t CONTROL_NumJoyButtons = 0;
@ -69,25 +69,15 @@ void CONTROL_GetMouseDelta(void)
{
static int32_t lastx = 0, lasty = 0;
CONTROL_MouseAxes[0].analog = (((x + lastx) / 2) * (CONTROL_MouseSensitivity<<1));
CONTROL_MouseAxes[1].analog = (((y + lasty) / 2) * (CONTROL_MouseSensitivity<<1))<<1;
CONTROL_MouseAxes[0].analog = (((x + lastx) / 2.0f) * 4.0f * CONTROL_MouseSensitivity);
CONTROL_MouseAxes[1].analog = (((y + lasty) / 2.0f) * 4.0f * CONTROL_MouseSensitivity) * 2.0f;
lastx = x;
lasty = y;
return;
}
CONTROL_MouseAxes[0].analog = (x * (CONTROL_MouseSensitivity<<1));
CONTROL_MouseAxes[1].analog = (y * (CONTROL_MouseSensitivity<<1))<<1;
}
int32_t CONTROL_GetMouseSensitivity(void)
{
return (CONTROL_MouseSensitivity);
}
void CONTROL_SetMouseSensitivity(int32_t newsensitivity)
{
CONTROL_MouseSensitivity = newsensitivity;
CONTROL_MouseAxes[0].analog = (x * 4.0f * CONTROL_MouseSensitivity);
CONTROL_MouseAxes[1].analog = (y * 4.0f * CONTROL_MouseSensitivity) * 2.0f;
}
int32_t CONTROL_StartMouse(void)

View file

@ -163,8 +163,7 @@ void CONTROL_ClearButton( int32_t whichbutton );
void CONTROL_ClearUserInput( UserInput *info );
void CONTROL_WaitRelease( void );
void CONTROL_Ack( void );
int32_t CONTROL_GetMouseSensitivity( void );
void CONTROL_SetMouseSensitivity( int32_t newsensitivity );
float CONTROL_MouseSensitivity;
int32_t CONTROL_Startup
(
controltype which,

View file

@ -107,9 +107,7 @@ static int16_t mi, mii;
static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n)
{
int16_t centre, s;
s = 1+(CONTROL_GetMouseSensitivity()>>4);
int16_t centre;
{
CONTROL_GetInput(&minfo);
@ -3720,10 +3718,9 @@ cheat_for_port_credits:
mgametextpal(40,118+9+9+9+9,"Advanced mouse setup",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2+2),10);
{
int32_t sense;
sense = CONTROL_GetMouseSensitivity()-1;
int32_t sense = CONTROL_MouseSensitivity * 2;
barsm(248,126,&sense,2,x==(MAXMOUSEBUTTONS-2)*2+2,MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2),PHX(-7));
CONTROL_SetMouseSensitivity(sense+1);
CONTROL_MouseSensitivity = sense / 2.0f;
}
if (!ud.mouseaiming) modval(0,1,(int32_t *)&g_myAimMode,1,probey == (MAXMOUSEBUTTONS-2)*2+2+1);

View file

@ -38,6 +38,7 @@ float r_ambientlight = 1.0, r_ambientlightrecip = 1.0;
extern int32_t althud_numbertile, althud_numberpal, althud_shadows, althud_flashing, hud_glowingquotes;
extern int32_t hud_showmapname;
extern int32_t r_maxfps;
extern int32_t g_frameDelay;
static inline int32_t osdcmd_quit(const osdfuncparm_t *parm)
{
@ -488,33 +489,6 @@ static int32_t osdcmd_vidmode(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
static int32_t osdcmd_setstatusbarscale(const osdfuncparm_t *parm)
{
if (parm->numparms == 0)
{
OSD_Printf("\"hud_scale\" is \"%d\"\n", ud.statusbarscale);
return OSDCMD_SHOWHELP;
}
else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
G_SetStatusBarScale(Batol(parm->parms[0]));
OSD_Printf("hud_scale %d\n", ud.statusbarscale);
return OSDCMD_OK;
}
static int32_t osdcmd_setweaponscale(const osdfuncparm_t *parm)
{
if (parm->numparms == 0)
{
OSD_Printf("\"hud_weaponscale\" is \"%d\"\n", ud.weaponscale);
return OSDCMD_SHOWHELP;
}
else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
ud.weaponscale = min(100,max(10,Batol(parm->parms[0])));
OSD_Printf("hud_weaponscale %d\n", ud.weaponscale);
return OSDCMD_OK;
}
static int32_t osdcmd_spawn(const osdfuncparm_t *parm)
{
uint16_t cstat=0,picnum=0;
@ -719,20 +693,6 @@ static int32_t osdcmd_cmenu(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;
@ -753,18 +713,6 @@ static int32_t osdcmd_crosshaircolor(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
static int32_t osdcmd_sensitivity(const osdfuncparm_t *parm)
{
if (parm->numparms != 1)
{
OSD_Printf("\"sensitivity\" is \"%d\"\n",CONTROL_GetMouseSensitivity());
return OSDCMD_SHOWHELP;
}
CONTROL_SetMouseSensitivity(atoi(parm->parms[0]));
OSD_Printf("sensitivity %d\n",CONTROL_GetMouseSensitivity());
return OSDCMD_OK;
}
/*
static int32_t osdcmd_setbrightness(const osdfuncparm_t *parm)
{
@ -860,38 +808,6 @@ void onvideomodechange(int32_t newmode)
g_crosshairSum = 0;
}
static int32_t osdcmd_usemousejoy(const osdfuncparm_t *parm)
{
int32_t showval = (parm->numparms < 1);
if (!Bstrcasecmp(parm->name, "in_mouse"))
{
if (showval)
{
OSD_Printf("in_mouse is %d\n", ud.config.UseMouse);
}
else
{
ud.config.UseMouse = (atoi(parm->parms[0]) != 0);
CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent);
}
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->name, "in_joystick"))
{
if (showval)
{
OSD_Printf("in_joystick is %d\n", ud.config.UseJoystick);
}
else
{
ud.config.UseJoystick = (atoi(parm->parms[0]) != 0);
CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent);
}
return OSDCMD_OK;
}
return OSDCMD_SHOWHELP;
}
static int32_t osdcmd_name(const osdfuncparm_t *parm)
{
char namebuf[32];
@ -1232,79 +1148,6 @@ static int32_t osdcmd_restorestate(const osdfuncparm_t *parm)
}
*/
static int32_t osdcmd_vid_gamma(const osdfuncparm_t *parm)
{
if (parm->numparms != 1)
{
OSD_Printf("\"vid_gamma\" is \"%.1f\"\n",vid_gamma);
return OSDCMD_SHOWHELP;
}
vid_gamma = atof(parm->parms[0]);
ud.brightness = (int32_t)(min(max((float)((vid_gamma-1.0)*10.0),0),15));
ud.brightness <<= 2;
OSD_Printf("%s\n",parm->raw);
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
return OSDCMD_OK;
}
static int32_t osdcmd_vid_brightness(const osdfuncparm_t *parm)
{
if (parm->numparms != 1)
{
OSD_Printf("\"vid_brightness\" is \"%.1f\"\n",vid_brightness);
return OSDCMD_SHOWHELP;
}
vid_brightness = atof(parm->parms[0]);
OSD_Printf("%s\n",parm->raw);
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
return OSDCMD_OK;
}
static int32_t osdcmd_vid_contrast(const osdfuncparm_t *parm)
{
if (parm->numparms != 1)
{
OSD_Printf("\"vid_contrast\" is \"%.1f\"\n",vid_contrast);
return OSDCMD_SHOWHELP;
}
vid_contrast = atof(parm->parms[0]);
OSD_Printf("%s\n",parm->raw);
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
return OSDCMD_OK;
}
static int32_t osdcmd_visibility(const osdfuncparm_t *parm)
{
float f;
if (parm->numparms != 1)
{
OSD_Printf("\"r_ambientlight\" is \"%.1f\"\n",r_ambientlight);
return OSDCMD_SHOWHELP;
}
f = max(0.05f,min(10.f,atof(parm->parms[0])));
r_ambientlight = f;
r_ambientlightrecip = 1.f/r_ambientlight;
OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK;
}
static int32_t osdcmd_maxfps(const osdfuncparm_t *parm)
{
extern int32_t g_frameDelay;
if (parm->numparms != 1)
{
OSD_Printf("\"r_maxfps\" is \"%d\"\n",r_maxfps);
return OSDCMD_SHOWHELP;
}
r_maxfps = max(0,min(1000,atol(parm->parms[0])));
if (r_maxfps) g_frameDelay = (1000/r_maxfps);
else g_frameDelay = 0;
OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK;
}
static int32_t osdcmd_inittimer(const osdfuncparm_t *parm)
{
int32_t j;
@ -1334,6 +1177,72 @@ static int32_t osdcmd_cvar_set_multi(const osdfuncparm_t *parm)
return r;
}
static int32_t osdcmd_cvar_set_game(const osdfuncparm_t *parm)
{
int32_t r = osdcmd_cvar_set(parm);
#ifdef USE_OPENGL
if (r == OSDCMD_OK)
{
if (!Bstrcasecmp(parm->name, "r_maxfps"))
{
if (r_maxfps) g_frameDelay = (1000/r_maxfps);
else g_frameDelay = 0;
return r;
}
else if (!Bstrcasecmp(parm->name, "r_ambientlight"))
{
r_ambientlightrecip = 1.f/r_ambientlight;
return r;
}
else if (!Bstrcasecmp(parm->name, "in_mouse"))
{
CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent);
return r;
}
else if (!Bstrcasecmp(parm->name, "in_joystick"))
{
CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent);
return r;
}
else if (!Bstrcasecmp(parm->name, "vid_gamma"))
{
ud.brightness = (int32_t)(min(max((float)((vid_gamma-1.0)*10.0),0),15));
ud.brightness <<= 2;
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
return r;
}
else if (!Bstrcasecmp(parm->name, "vid_brightness"))
{
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
return r;
}
else if (!Bstrcasecmp(parm->name, "vid_contrast"))
{
setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0);
return r;
}
else if (!Bstrcasecmp(parm->name, "hud_scale"))
{
G_UpdateScreenArea();
return r;
}
}
#endif
return r;
}
int32_t registerosdcommands(void)
{
uint32_t i;
@ -1350,11 +1259,11 @@ int32_t registerosdcommands(void)
{ "hud_shadows", "hud_shadows: enable/disable althud shadows", (void*)&althud_shadows, CVAR_BOOL, 0, 0, 1 },
{ "hud_flashing", "hud_flashing: enable/disable althud flashing", (void*)&althud_flashing, CVAR_BOOL, 0, 0, 1 },
{ "hud_glowingquotes", "hud_glowingquotes: enable/disable \"glowing\" quote text", (void*)&hud_glowingquotes, CVAR_BOOL, 0, 0, 1 },
{ "hud_scale","hud_scale: changes the hud scale", osdcmd_setstatusbarscale, CVAR_FUNCPTR, 0, 0, 0 },
{ "hud_scale","hud_scale: changes the hud scale", (void*)&ud.statusbarscale, CVAR_INT|CVAR_FUNCPTR, 0, 10, 100 },
{ "hud_showmapname", "hud_showmapname: enable/disable map name display on load", (void*)&hud_showmapname, CVAR_BOOL, 0, 0, 1 },
{ "hud_stats", "hud_stats: enable/disable level statistics display", (void*)&ud.levelstats, CVAR_BOOL, 0, 0, 1 },
{ "hud_textscale", "hud_textscale: sets multiplayer chat message size", (void*)&ud.textscale, CVAR_INT, 0, 100, 400 },
{ "hud_weaponscale","hud_scale: changes the weapon scale", osdcmd_setweaponscale, CVAR_FUNCPTR, 0, 0, 0 },
{ "hud_weaponscale","hud_weaponscale: changes the weapon scale", (void*)&ud.weaponscale, CVAR_INT, 0, 10, 100 },
{ "cl_autoaim", "cl_autoaim: enable/disable weapon autoaim", (void*)&ud.config.AutoAim, CVAR_INT|CVAR_MULTI, 0, 0, 2 },
{ "cl_automsg", "cl_automsg: enable/disable automatically sending messages to all players", (void*)&ud.automsg, CVAR_BOOL, 0, 0, 1 },
@ -1373,11 +1282,10 @@ int32_t registerosdcommands(void)
{ "cl_weaponswitch", "cl_weaponswitch: enable/disable auto weapon switching", (void*)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 0, 3 },
{ "cl_angleinterpolation", "cl_angleinterpolation: enable/disable angle interpolation", (void*)&ud.angleinterpolation, CVAR_INT, 0, 0, 256 },
{ "crosshairscale","crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale, CVAR_FUNCPTR, 0, 0, 0 },
{ "crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor, CVAR_FUNCPTR, 0, 0, 0 },
{ "crosshairscale","crosshairscale: changes the crosshair scale", (void*)&ud.crosshairscale, CVAR_INT, 0, 10, 100 },
{ "in_joystick","in_joystick: enables input from the joystick if it is present",osdcmd_usemousejoy, CVAR_FUNCPTR, 0, 0, 0 },
{ "in_mouse","in_mouse: enables input from the mouse if it is present",osdcmd_usemousejoy, CVAR_FUNCPTR, 0, 0, 0 },
{ "in_joystick","in_joystick: enables input from the joystick if it is present",(void*)&ud.config.UseJoystick, CVAR_BOOL|CVAR_FUNCPTR, 0, 0, 1 },
{ "in_mouse","in_mouse: enables input from the mouse if it is present",(void*)&ud.config.UseMouse, CVAR_BOOL|CVAR_FUNCPTR, 0, 0, 1 },
{ "in_mousebias", "in_mousebias: emulates the original mouse code's weighting of input towards whichever axis is moving the most at any given time", (void*)&ud.config.MouseBias, CVAR_INT, 0, 0, 32 },
{ "in_mousedeadzone", "in_mousedeadzone: amount of mouse movement to filter out", (void*)&ud.config.MouseDeadZone, CVAR_INT, 0, 0, 512 },
@ -1389,10 +1297,10 @@ int32_t registerosdcommands(void)
{ "r_shadows", "r_shadows: enable/disable sprite and model shadows", (void*)&ud.shadows, CVAR_BOOL, 0, 0, 1 },
{ "r_precache", "r_precache: enable/disable the pre-level caching routine", (void*)&ud.config.useprecache, CVAR_BOOL, 0, 0, 1 },
{ "r_ambientlight", "r_ambientlight: sets the global map light level",osdcmd_visibility, CVAR_FUNCPTR, 0, 0, 0 },
{ "r_maxfps", "r_maxfps: sets a framerate cap",osdcmd_maxfps, CVAR_FUNCPTR, 0, 0, 0 },
{ "r_ambientlight", "r_ambientlight: sets the global map light level",(void*)&r_ambientlight, CVAR_FLOAT|CVAR_FUNCPTR, 0, 0, 10 },
{ "r_maxfps", "r_maxfps: sets a framerate cap",(void *)&r_maxfps, CVAR_INT|CVAR_FUNCPTR, 0, 0, 1000 },
{ "sensitivity","sensitivity <value>: changes the mouse sensitivity", osdcmd_sensitivity, CVAR_FUNCPTR, 0, 0, 0 },
{ "sensitivity","sensitivity <value>: changes the mouse sensitivity", (void*)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 0, 25 },
{ "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 },
@ -1403,16 +1311,16 @@ int32_t registerosdcommands(void)
{ "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 <gamma>: adjusts gamma ramp",osdcmd_vid_gamma, CVAR_FUNCPTR, 0, 0, 0 },
{ "vid_contrast","vid_contrast <gamma>: adjusts gamma ramp",osdcmd_vid_contrast, CVAR_FUNCPTR, 0, 0, 0 },
{ "vid_brightness","vid_brightness <gamma>: adjusts gamma ramp",osdcmd_vid_brightness, CVAR_FUNCPTR, 0, 0, 0 },
{ "vid_gamma","vid_gamma <gamma>: adjusts gamma ramp",(void*)&vid_gamma, CVAR_FLOAT|CVAR_FUNCPTR, 0, 0, 10 },
{ "vid_contrast","vid_contrast <gamma>: adjusts gamma ramp",(void*)&vid_contrast, CVAR_FLOAT|CVAR_FUNCPTR, 0, 0, 10 },
{ "vid_brightness","vid_brightness <gamma>: adjusts gamma ramp",(void*)&vid_brightness, CVAR_FLOAT|CVAR_FUNCPTR, 0, 0, 10 },
};
for (i=0; i<sizeof(cvars_game)/sizeof(cvars_game[0]); i++)
{
OSD_RegisterCvar(&cvars_game[i]);
if (cvars_game[i].type == CVAR_FUNCPTR) OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].helpstr, cvars_game[i].var);
if (cvars_game[i].type & CVAR_FUNCPTR) OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].helpstr, osdcmd_cvar_set_game);
else if (cvars_game[i].type & CVAR_MULTI) OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].helpstr, osdcmd_cvar_set_multi);
else OSD_RegisterFunction(cvars_game[i].name, cvars_game[i].helpstr, osdcmd_cvar_set);
}
@ -1428,6 +1336,8 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
OSD_RegisterFunction("bind","bind <key> <string>: 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("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo);
OSD_RegisterFunction("fileinfo","fileinfo <file>: gets a file's information", osdcmd_fileinfo);

View file

@ -543,6 +543,8 @@ void G_UpdateScreenArea(void)
{
int32_t i, j, ss, x1, x2, y1, y2;
if (qsetmode != 200) return;
if (ud.screen_size < 0) ud.screen_size = 0;
if (ud.screen_size > 64) ud.screen_size = 64;
if (ud.screen_size == 0) flushperms();