From b9895ca0788860ce0726cb7a07cbf507183bc709 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 7 Aug 2008 23:32:18 +0000 Subject: [PATCH] CON access to hittype[].flags, better crosshair coloring code git-svn-id: https://svn.eduke32.com/eduke32@939 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/config.c | 2 +- polymer/eduke32/source/game.c | 38 +++++++++++++++++++++++++------ polymer/eduke32/source/gamedef.c | 2 ++ polymer/eduke32/source/gamedef.h | 1 + polymer/eduke32/source/gameexec.c | 9 ++++++++ polymer/eduke32/source/osdcmds.c | 6 ++--- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 569dc0bc8..763fb09b1 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -246,7 +246,7 @@ void CONFIG_SetDefaults(void) ud.screen_tilting = 1; ud.shadows = 1; ud.statusbarmode = 0; - ud.statusbarscale = 100; + ud.statusbarscale = 50; ud.team = 0; ud.viewbob = 1; ud.weaponsway = 1; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index d8b6cb950..aa317e4cf 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2019,8 +2019,8 @@ static void coolgaugetext(int snum) // rotatesprite(sbarx(5+1),sbary(200-25+1),sbarsc(49152L),0,SIXPAK,0,4,10+16+1+32,0,0,xdim-1,ydim-1); // rotatesprite(sbarx(5),sbary(200-25),sbarsc(49152L),0,SIXPAK,0,0,10+16,0,0,xdim-1,ydim-1); - rotatesprite(sbarx(2+1),sbary(200-22+1),sbarsc(49152L),0,COLA,0,4,10+16+1+32,0,0,xdim-1,ydim-1); - rotatesprite(sbarx(2),sbary(200-22),sbarsc(49152L),0,COLA,0,0,10+16,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(2+1),sbary(200-21+1),sbarsc(49152L),0,COLA,0,4,10+16+1+32,0,0,xdim-1,ydim-1); + rotatesprite(sbarx(2),sbary(200-21),sbarsc(49152L),0,COLA,0,0,10+16,0,0,xdim-1,ydim-1); if (sprite[p->i].pal == 1 && p->last_extra < 2) altdigitalnumber(40,-(200-22),1,-16,10+16); @@ -3363,6 +3363,7 @@ static void drawoverheadmap(int cposx, int cposy, int czoom, short cang) } } +extern int getclosestcol(int r, int g, int b); int crosshair_red = 255; int crosshair_green = 255; int crosshair_blue = 0; @@ -3373,24 +3374,47 @@ void SetCrosshairColor(int r, int g, int b) /* TODO: turn this into something useful */ char *ptr = (char *)waloff[CROSSHAIR]; int i, ii; - extern int getclosestcol(int r, int g, int b); + static int crosshair_red_default = -1; + static int crosshair_green_default = -1; + static int crosshair_blue_default = -1; hictinting[CROSSHAIR_PAL].r = crosshair_red = r; hictinting[CROSSHAIR_PAL].g = crosshair_green = g; hictinting[CROSSHAIR_PAL].b = crosshair_blue = b; - hictinting[CROSSHAIR_PAL].f = 0; + hictinting[CROSSHAIR_PAL].f = 1; invalidatetile(CROSSHAIR, -1, -1); if (waloff[CROSSHAIR] == 0) return; - ii = 0; + if (crosshair_red_default == -1) + { + // use the brightest color in the original 8-bit tile + int bri = 0, j = 0; + ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; + while (ii > 0) + { + if (*ptr != 255) + { + i = curpalette[(int)*ptr].r+curpalette[(int)*ptr].g+curpalette[(int)*ptr].b; + if (i > j) { j = i; bri = *ptr; } + } + ptr++; + ii--; + } + OSD_Printf("brightest color index: %d\n",bri); + crosshair_red_default = crosshair_red = curpalette[bri].r; + crosshair_green_default = crosshair_green = curpalette[bri].g; + crosshair_blue_default = crosshair_blue = curpalette[bri].b; + } + i = getclosestcol(crosshair_red>>2, crosshair_green>>2, crosshair_blue>>2); - while (ii < tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]) + ii = tilesizx[CROSSHAIR]*tilesizy[CROSSHAIR]; + while (ii > 0) { if (*ptr != 255) *ptr = i; ptr++; - ii++; + ii--; } for (i = 0; i < 256; i++) tempbuf[i] = i; diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 6a59384b7..b6a0e8087 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -576,6 +576,8 @@ const memberlabel_t actorlabels[]= { "xpanning", ACTOR_XPANNING, 0, 0 }, { "ypanning", ACTOR_YPANNING, 0, 0 }, + { "htflags", ACTOR_HTFLAGS, 0, 0 }, + { "", -1, 0, 0 } // END OF LIST }; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index bddcf0b82..22bcedc86 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -446,6 +446,7 @@ enum actorlabels ACTOR_MDFLAGS, ACTOR_XPANNING, ACTOR_YPANNING, + ACTOR_HTFLAGS, }; enum tsprlabels diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index d40c67e7b..b982b95f1 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -3480,6 +3480,15 @@ static void DoActor(int iSet, int lVar1, int lLabelID, int lVar2, int lParm2) SetGameVarID(lVar2, spriteext[iActor].ypanning,g_i,g_p); return; + case ACTOR_HTFLAGS: + if (iSet) + { + hittype[iActor].flags=lValue; + return; + } + SetGameVarID(lVar2,hittype[iActor].flags, g_i, g_p); + return; + default: return; } diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 1a0638c59..cf777b552 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1310,13 +1310,13 @@ static int osdcmd_setcrosshairscale(const osdfuncparm_t *parm) { if (parm->numparms == 0) { - OSD_Printf("\"cl_crosshairscale\" is \"%d\"\n", ud.crosshairscale); + 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("cl_statusbarscale %d\n", ud.crosshairscale); + OSD_Printf("statusbarscale %d\n", ud.crosshairscale); return OSDCMD_OK; } @@ -1381,7 +1381,7 @@ int registerosdcommands(void) 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("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale); - OSD_RegisterFunction("cl_crosshairscale","cl_crosshairscale: changes the crosshair scale", osdcmd_setcrosshairscale); + 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);