From a8a675634e5711bd919bfc1f482fce6c46e320dc Mon Sep 17 00:00:00 2001 From: plagman Date: Fri, 4 Jan 2008 01:04:35 +0000 Subject: [PATCH] Patch from hunter_rus. Adds: - maximal log line count and OSD variable "logcutoff" - ability to define different models for each palette - "bind" OSD command to bind keys so that they run command batch files git-svn-id: https://svn.eduke32.com/eduke32@591 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/src/mdsprite.c | 9 +- polymer/build/src/osd.c | 31 ++++++- polymer/eduke32/source/duke3d.h | 18 ++++ polymer/eduke32/source/game.c | 138 +++++++++++++++++++++++++++---- polymer/eduke32/source/osdcmds.c | 27 ++++++ 5 files changed, 200 insertions(+), 23 deletions(-) diff --git a/polymer/build/src/mdsprite.c b/polymer/build/src/mdsprite.c index 3074c8177..38e872e72 100644 --- a/polymer/build/src/mdsprite.c +++ b/polymer/build/src/mdsprite.c @@ -201,8 +201,13 @@ static tile2model_t tile2model[MAXTILES+EXTRATILES]; int addtileP(int model,int tile,int pallet) { if (curextra==MAXTILES+EXTRATILES-2)return curextra; - if (tile2model[tile].modelid==-1)return tile; - while (tile2model[tile].next!=-1)tile=tile2model[tile].next; + if (tile2model[tile].modelid==-1){tile2model[tile].pal=pallet;return tile;} + if (tile2model[tile].pal==pallet)return tile; + while(tile2model[tile].next!=-1) + { + tile=tile2model[tile].next; + if(tile2model[tile].pal==pallet)return tile; + } tile2model[tile].next=curextra; tile2model[curextra].pal=pallet; return curextra++; diff --git a/polymer/build/src/osd.c b/polymer/build/src/osd.c index aae79f2a7..00daf0fdf 100644 --- a/polymer/build/src/osd.c +++ b/polymer/build/src/osd.c @@ -88,6 +88,10 @@ static int osdhistorysize=0; // number of entries in history // the execution buffer works from the command history static int osdexeccount=0; // number of lines from the head of the history buffer to execute +// maximal log line count +int logcutoff=120000; +int linecnt; + // presentation parameters static int osdpromptshade=0; static int osdpromptpal=0; @@ -210,7 +214,14 @@ static int _internal_osdfunc_vars(const osdfuncparm_t *parm) osdrows = atoi(parm->parms[0]); if (osdrows < 1) osdrows = 1; else if (osdrows > osdmaxrows) osdrows = osdmaxrows; - osdrowscur = osdrows; + if(osdrowscur!=-1)osdrowscur = osdrows; + return OSDCMD_OK; + } + } else + if (!Bstrcasecmp(parm->name, "logcutoff")) { + if (showval) { OSD_Printf("logcutoff is %d\n", logcutoff); return OSDCMD_OK; } + else { + logcutoff = atoi(parm->parms[0]); return OSDCMD_OK; } } @@ -289,6 +300,7 @@ void OSD_Init(void) OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols); OSD_RegisterFunction("help","help: displays help on the named symbol",_internal_osdfunc_help); OSD_RegisterFunction("osdrows","osdrows: sets the number of visible lines of the OSD",_internal_osdfunc_vars); + OSD_RegisterFunction("logcutoff","logcutoff: sets the maximal line count of the log file",_internal_osdfunc_vars); OSD_RegisterFunction("clear","clear: clears the console text buffer",_internal_osdfunc_clear); atexit(OSD_Cleanup); @@ -861,7 +873,7 @@ void OSD_Draw(void) while (j > -1) { osdrowscur++; - j -= 10; + j -= 200/osdrows; if (osdrowscur > osdrows-1) break; } @@ -872,7 +884,7 @@ void OSD_Draw(void) while (j > -1) { osdrowscur--; - j -= 10; + j -= 200/osdrows; if (osdrowscur < 1) break; } @@ -937,7 +949,17 @@ void OSD_Printf(const char *fmt, ...) Bvsnprintf(tmpstr, 1024, fmt, va); va_end(va); - if (osdlog) Bfputs(tmpstr, osdlog); + if(linecntnumparms==1&&!strcmpi(parm->parms[0],"showkeys")) + { + for(i=0;keynames[i].name;i++)OSD_Printf("%s\n",keynames[i].name); + return OSDCMD_OK; + } + if (parm->numparms==0) + { + OSD_Printf("Keybindings:\n"); + for(i=0;inumparms < 2) return OSDCMD_SHOWHELP; + for(i=0;keynames[i].name;i++)if(!strcmpi(parm->parms[0],keynames[i].name))break; + if (!keynames[i].name) return OSDCMD_SHOWHELP; + + Bstrncpy(boundkeys[keynames[i].id].name,parm->parms[1], MAXSCRIPTFILENAMELENGTH-1); + boundkeys[keynames[i].id].key=keynames[i].name; + return OSDCMD_OK; +} + int registerosdcommands(void) { unsigned int i; @@ -998,6 +1024,7 @@ int registerosdcommands(void) OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode); + OSD_RegisterFunction("bind","bind : executes a command script when gets pressed. Type \"bind showkeys\" for a list of keys.", osdcmd_bind); //baselayer_onvideomodechange = onvideomodechange; return 0;