- removed the complete crosshair color hackery.

The code needs to be refactored anyway to allow better crosshair control but this also seemed to affect global render state, considering how poorly it was all implemented.
This commit is contained in:
Christoph Oelckers 2020-01-18 16:13:39 +01:00
parent 8cd9775513
commit 2bc1708870
23 changed files with 13 additions and 343 deletions

View File

@ -1223,7 +1223,6 @@ RESTART:
UpdateNetworkMenus();
if (!gDemo.at0 && gDemo.at59ef > 0 && gGameOptions.nGameType == 0 && !bNoDemo)
gDemo.SetupPlayback(NULL);
viewSetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
gQuitGame = 0;
gRestartGame = 0;
if (gGameOptions.nGameType > 0)

View File

@ -102,35 +102,6 @@ static int osdcmd_demo(osdcmdptr_t parm)
}
static int osdcmd_crosshaircolor(osdcmdptr_t parm)
{
if (parm->numparms != 3)
{
OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b);
return OSDCMD_SHOWHELP;
}
uint8_t const r = Batol(parm->parms[0]);
uint8_t const g = Batol(parm->parms[1]);
uint8_t const b = Batol(parm->parms[2]);
g_isAlterDefaultCrosshair = true;
viewSetCrosshairColor(r,g,b);
OSD_Printf("%s\n", parm->raw);
return OSDCMD_OK;
}
static int osdcmd_resetcrosshair(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
g_isAlterDefaultCrosshair = false;
viewResetCrosshairToDefault();
return OSDCMD_OK;
}
static int osdcmd_give(osdcmdptr_t parm)
{
if (numplayers != 1 || !gGameStarted || gMe->pXSprite->health == 0)
@ -236,8 +207,6 @@ int32_t registerosdcommands(void)
{
OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
OSD_RegisterFunction("crosshairreset", "crosshairreset: restores the original crosshair", osdcmd_resetcrosshair);
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);

View File

@ -1857,7 +1857,6 @@ void viewResizeView(int size)
}
videoSetViewableArea(gViewX0, gViewY0, gViewX1, gViewY1);
gGameMessageMgr.SetCoordinates(gViewX0S + 1, gViewY0S + 1);
viewSetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
viewUpdatePages();
}
@ -3484,7 +3483,7 @@ void viewDrawScreen(bool sceneonly)
{
if (cl_crosshair)
{
rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, g_isAlterDefaultCrosshair ? CROSSHAIR_PAL : 0, 2, gViewX0, gViewY0, gViewX1, gViewY1);
rotatesprite(160<<16, defaultHoriz<<16, 65536, 0, kCrosshairTile, 0, 0, 2, gViewX0, gViewY0, gViewX1, gViewY1);
}
cX = (v4c >> 8) + 160;
cY = (v48 >> 8) + 220 + (zDelta >> 7);
@ -3689,55 +3688,6 @@ void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const c
viewLoadingScreenUpdate(NULL, -1);
}
palette_t CrosshairColors = { 255, 255, 255, 0 };
bool g_isAlterDefaultCrosshair = false;
void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b)
{
if (!g_isAlterDefaultCrosshair)
return;
CrosshairColors.r = r;
CrosshairColors.g = g;
CrosshairColors.b = b;
auto ptr = TileFiles.tileMakeWritable(kCrosshairTile);
if (!ptr) return;
int32_t ii = tilesiz[kCrosshairTile].x * tilesiz[kCrosshairTile].y;
dassert(ii > 0);
int32_t i = (videoGetRenderMode() == REND_CLASSIC)
? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b)
: paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color
do
{
if (*ptr != 255)
*ptr = i;
ptr++;
} while (--ii);
paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1);
#ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL];
crosshairtint.tint.r = CrosshairColors.r;
crosshairtint.tint.g = CrosshairColors.g;
crosshairtint.tint.b = CrosshairColors.b;
crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE;
#endif
tileInvalidate(kCrosshairTile, -1, -1);
}
void viewResetCrosshairToDefault(void)
{
paletteFreeLookupTable(CROSSHAIR_PAL);
tileLoad(kCrosshairTile);
}
#define COLOR_RED redcol
#define COLOR_WHITE whitecol

View File

@ -63,7 +63,6 @@ enum INTERPOLATE_TYPE {
INTERPOLATE_TYPE_SHORT,
};
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
#define kCrosshairTile 2319
#define kLoadScreen 2049
#define kLoadScreenCRC -2051908571
@ -98,8 +97,6 @@ extern CGameMessageMgr gGameMessageMgr;
extern int gViewXCenter, gViewYCenter;
extern int gViewX0, gViewY0, gViewX1, gViewY1;
extern int gViewX0S, gViewY0S, gViewX1S, gViewY1S;
extern palette_t CrosshairColors;
extern bool g_isAlterDefaultCrosshair;
extern int gLastPal;
@ -150,8 +147,6 @@ void viewLoadingScreenUpdate(const char *pzText4 = NULL, int nPercent = -1);
void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3);
void viewUpdateDelirium(void);
void viewUpdateShake(void);
void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b);
void viewResetCrosshairToDefault(void);
void viewSetSystemMessage(const char* pMessage, ...);
void viewPrecacheTiles(void);

View File

@ -1792,8 +1792,8 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
VSMatrix identity(0);
GLInterface.SetIdentityMatrix(Matrix_ModelView);
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255));
GLInterface.SetClamp(prevClamp);
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
GLInterface.SetClamp(prevClamp);
globalnoeffect=0;
return 1;

View File

@ -601,8 +601,8 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
}
GLInterface.DrawIm(DT_TRIANGLE_FAN, data.first, npoints);
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255));
GLInterface.UseDetailMapping(false);
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
GLInterface.UseDetailMapping(false);
GLInterface.UseGlowMapping(false);
GLInterface.SetNpotEmulation(false, 1.f, 0.f);

View File

@ -1194,8 +1194,8 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
VSMatrix identity(0);
GLInterface.SetIdentityMatrix(Matrix_ModelView);
GLInterface.SetFadeDisable(false);
GLInterface.SetTinting(0, 0, PalEntry(255, 255, 255));
return 1;
GLInterface.SetTinting(-1, 0xffffff, 0xffffff);
return 1;
}
#endif

View File

@ -655,14 +655,16 @@ bool ParseDrawTextureTags(FTexture *img, double x, double y, uint32_t tag, Va_Li
parms->style = STYLE_Stencil;
}
}
else if (parms->Alpha < 1.f)
else //if (parms->Alpha < 1.f)
{
parms->style = STYLE_Translucent;
}
/*
else
{
parms->style = STYLE_Normal;
}
*/
}
return true;
}

View File

@ -305,9 +305,6 @@ int32_t Anim_Play(const char *fn)
GLInterface.EnableNonTransparent255(true);
// Dummy rotatesprite call. Without this the movie won't render. Apparently some state isn't initialized properly and gets reset by this.
// Needs to be investigated. Leave this in as a workaround for now...
rotatesprite_fs(int(160 * 65536), int(100 * 65536) + ((28) << 16), 65536L, 0, 2499, 0, 0, 10);
do
{
nextframetime += msecsperframe;

View File

@ -5880,12 +5880,6 @@ MAIN_LOOP_RESTART:
}
if (g_networkMode != NET_DEDICATED_SERVER)
{
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
}
if (ud.warp_on == 1)
{
G_NewGame_EnterLevel();

View File

@ -236,11 +236,6 @@ extern int32_t voting;
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
extern palette_t CrosshairColors;
extern palette_t DefaultCrosshairColors;
int32_t A_CheckInventorySprite(spritetype *s);
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss);
@ -282,12 +277,10 @@ void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
void G_GameQuit(void);
void G_GetCrosshairColor(void);
void G_HandleLocalKeys(void);
void G_HandleSpecialKeys(void);
void G_PrintGameQuotes(int32_t snum);
//void G_SE40(int32_t smoothratio);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_Shutdown(void);
void G_UpdatePlayerFromMenu(void);
void P_DoQuote(int32_t q,DukePlayer_t *p);

View File

@ -370,27 +370,6 @@ static int osdcmd_setactorvar(osdcmdptr_t parm)
}
static int osdcmd_crosshaircolor(osdcmdptr_t parm)
{
if (parm->numparms != 3)
{
OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b);
return OSDCMD_SHOWHELP;
}
uint8_t const r = Batol(parm->parms[0]);
uint8_t const g = Batol(parm->parms[1]);
uint8_t const b = Batol(parm->parms[2]);
G_SetCrosshairColor(r,g,b);
OSD_Printf("%s\n", parm->raw);
return OSDCMD_OK;
}
static int osdcmd_give(osdcmdptr_t parm)
{
int32_t i;
@ -739,8 +718,6 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
}
OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
OSD_RegisterFunction("activatecheat","activatecheat <id>: activates a cheat code", osdcmd_activatecheat);

View File

@ -534,9 +534,6 @@ void G_UpdateScreenArea(void)
videoSetViewableArea(v1.x, v1.y, v2.x-1, v2.y-1);
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
pub = NUMPAGES;
pus = NUMPAGES;
}

View File

@ -27,7 +27,6 @@ BEGIN_DUKE_NS
extern int32_t g_levelTextTime;
extern int32_t voting,vote_map,vote_episode;
extern palette_t CrosshairColors;
void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName);
int G_EnterLevel(int gameMode);
int G_FindLevelByFile(const char *fileName);
@ -35,7 +34,6 @@ void G_CacheMapData(void);
void G_FreeMapState(int levelNum);
void G_NewGame(int volumeNum, int levelNum, int skillNum);
void G_ResetTimers(bool saveMoveCnt);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_UpdateScreenArea(void);
void P_MoveToRandomSpawnPoint(int playerNum);
void P_ResetInventory(int playerNum);

View File

@ -43,8 +43,6 @@ BEGIN_DUKE_NS
#define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11)
palette_t CrosshairColors = { 255, 255, 255, 0 };
palette_t DefaultCrosshairColors = { 0, 0, 0, 0 };
int32_t g_crosshairSum = -1;
// yxaspect and viewingrange just before the 'main' drawrooms call
int32_t dr_yxaspect, dr_viewingrange;
@ -93,86 +91,6 @@ void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set)
videoSetPalette(0, palid, set);
}
void G_GetCrosshairColor(void)
{
if (FURY)
return;
if (DefaultCrosshairColors.f)
return;
tileLoad(CROSSHAIR);
auto ptr = tilePtr(CROSSHAIR);
if (!ptr) return;
// find the brightest color in the original 8-bit tile
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
int32_t bri = 0, j = 0, i;
Bassert(ii > 0);
do
{
if (*ptr != 255)
{
i = curpalette[(int32_t) *ptr].r+curpalette[(int32_t) *ptr].g+curpalette[(int32_t) *ptr].b;
if (i > j) { j = i; bri = *ptr; }
}
ptr++;
} while (--ii);
Bmemcpy(&CrosshairColors, &curpalette[bri], sizeof(palette_t));
Bmemcpy(&DefaultCrosshairColors, &curpalette[bri], sizeof(palette_t));
DefaultCrosshairColors.f = 1; // this flag signifies that the color has been detected
}
void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
{
if (FURY)
return;
if (g_crosshairSum == r+(g<<8)+(b<<16))
return;
auto ptr = TileFiles.tileMakeWritable(CROSSHAIR);
if (!ptr) return;
if (!DefaultCrosshairColors.f)
G_GetCrosshairColor();
g_crosshairSum = r+(g<<8)+(b<<16);
CrosshairColors.r = r;
CrosshairColors.g = g;
CrosshairColors.b = b;
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
Bassert(ii > 0);
int32_t i = (videoGetRenderMode() == REND_CLASSIC)
? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b)
: paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color
do
{
if (*ptr != 255)
*ptr = i;
ptr++;
} while (--ii);
paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1);
#ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL];
crosshairtint.tint.r = CrosshairColors.r;
crosshairtint.tint.g = CrosshairColors.g;
crosshairtint.tint.b = CrosshairColors.b;
crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE;
#endif
tileInvalidate(CROSSHAIR, -1, -1);
}
#define SCORESHEETOFFSET -20
static void G_ShowScores(void)
@ -956,7 +874,6 @@ void G_DisplayRest(int32_t smoothratio)
if ((unsigned) a < MAXTILES)
{
vec2_t crosshairpos = { ud.returnvar[0], ud.returnvar[1] };
uint8_t crosshair_pal = CROSSHAIR_PAL;
uint32_t crosshair_o = 1|2;
uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100);
@ -966,12 +883,11 @@ void G_DisplayRest(int32_t smoothratio)
crosshairpos.x = scale(crosshairpos.x - (320<<15), ydim << 2, xdim * 3) + (320<<15);
crosshairpos.y = scale(crosshairpos.y - (200<<15), (ydim << 2) * 6, (xdim * 3) * 5) + (200<<15);
crosshair_scale = scale(crosshair_scale, ydim << 2, xdim * 3) >> 1;
crosshair_pal = 0;
crosshair_o |= 1024;
renderSetAspect(viewingrange, 65536);
}
rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o);
rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, 0, crosshair_o);
if (FURY)
renderSetAspect(viewingrange, oyxaspect);

View File

@ -105,7 +105,6 @@ int32_t registerosdcommands(void)
//}
//OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
//OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
//OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);

View File

@ -69,7 +69,7 @@ struct PolymostRenderState
bool AlphaTest = true;
float Color[4] = { 1,1,1,1 };
short matrixIndex[NUMMATRICES] = { -1,-1,-1,-1,-1 };
PalEntry fullscreenTint = 0xffffff, hictint = 0, hictint_overlay = 0xffffff;
PalEntry fullscreenTint = 0xffffff, hictint = 0xffffff, hictint_overlay = 0xffffff;
int hictint_flags = 0;
int StateFlags = STF_COLORMASK|STF_DEPTHMASK;

View File

@ -7332,12 +7332,6 @@ MAIN_LOOP_RESTART:
for (int & q : user_quote_time)
q = 0;
//if (g_networkMode != NET_DEDICATED_SERVER)
{
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
}
if (ud.warp_on == 1)
{
G_NewGame_EnterLevel();

View File

@ -235,11 +235,6 @@ extern int32_t voting;
//extern int8_t cheatbuf[MAXCHEATLEN],cheatbuflen;
#define CROSSHAIR_PAL (MAXPALOOKUPS-RESERVEDPALS-1)
extern palette_t CrosshairColors;
extern palette_t DefaultCrosshairColors;
int32_t A_CheckInventorySprite(spritetype *s);
int32_t A_InsertSprite(int16_t whatsect, int32_t s_x, int32_t s_y, int32_t s_z, int16_t s_pn, int8_t s_s, uint8_t s_xr,
uint8_t s_yr, int16_t s_a, int16_t s_ve, int16_t s_zv, int16_t s_ow, int16_t s_ss);
@ -280,12 +275,10 @@ void G_DrawRooms(int32_t playerNum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
void G_GameExit(const char *msg) ATTRIBUTE((noreturn));
void G_GameQuit(void);
void G_GetCrosshairColor(void);
void G_HandleLocalKeys(void);
void G_HandleSpecialKeys(void);
void G_PrintGameQuotes(int32_t snum);
//void G_SE40(int32_t smoothratio);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_Shutdown(void);
void G_UpdatePlayerFromMenu(void);
void P_DoQuote(int32_t q,DukePlayer_t *p);

View File

@ -274,25 +274,6 @@ static int osdcmd_spawn(osdcmdptr_t parm)
}
static int osdcmd_crosshaircolor(osdcmdptr_t parm)
{
if (parm->numparms != 3)
{
OSD_Printf("crosshaircolor: r:%d g:%d b:%d\n",CrosshairColors.r,CrosshairColors.g,CrosshairColors.b);
return OSDCMD_SHOWHELP;
}
uint8_t const r = Batol(parm->parms[0]);
uint8_t const g = Batol(parm->parms[1]);
uint8_t const b = Batol(parm->parms[2]);
G_SetCrosshairColor(r,g,b);
OSD_Printf("%s\n", parm->raw);
return OSDCMD_OK;
}
static int osdcmd_give(osdcmdptr_t parm)
{
int32_t i;
@ -577,8 +558,6 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("demo","demo <demofile or demonum>: starts the given demo", osdcmd_demo);
}
OSD_RegisterFunction("crosshaircolor","crosshaircolor: changes the crosshair color", osdcmd_crosshaircolor);
#if !defined NETCODE_DISABLE
OSD_RegisterFunction("connect","connect: connects to a multiplayer game", osdcmd_connect);
OSD_RegisterFunction("disconnect","disconnect: disconnects from the local multiplayer game", osdcmd_disconnect);

View File

@ -720,9 +720,6 @@ void G_UpdateScreenArea(void)
videoSetViewableArea(x1,y1,x2-1,y2-1);
}
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
pub = NUMPAGES;
pus = NUMPAGES;
}

View File

@ -29,7 +29,6 @@ extern int16_t g_ambientLotag[64];
extern int16_t g_ambientHitag[64];
extern int32_t g_levelTextTime;
extern int32_t voting,vote_map,vote_episode;
extern palette_t CrosshairColors;
void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum);
int G_EnterLevel(int gameMode);
int G_FindLevelByFile(const char *fileName);
@ -37,7 +36,6 @@ void G_CacheMapData(void);
void G_FreeMapState(int levelNum);
void G_NewGame(int volumeNum, int levelNum, int skillNum);
void G_ResetTimers(uint8_t keepgtics);
void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
void G_UpdateScreenArea(void);
void P_RandomSpawnPoint(int playerNum);
void P_ResetInventory(int playerNum);

View File

@ -43,8 +43,6 @@ BEGIN_RR_NS
#define quotepulseshade (sintable[((uint32_t)totalclock<<5)&2047]>>11)
palette_t CrosshairColors = { 255, 255, 255, 0 };
palette_t DefaultCrosshairColors = { 0, 0, 0, 0 };
int32_t g_crosshairSum = -1;
// yxaspect and viewingrange just before the 'main' drawrooms call
int32_t dr_yxaspect, dr_viewingrange;
@ -92,80 +90,6 @@ void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set)
videoSetPalette(0, palid, set);
}
void G_GetCrosshairColor(void)
{
if (DefaultCrosshairColors.f)
return;
tileLoad(CROSSHAIR);
auto ptr = tilePtr(CROSSHAIR);
if (!ptr) return;
// find the brightest color in the original 8-bit tile
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
int32_t bri = 0, j = 0, i;
Bassert(ii > 0);
do
{
if (*ptr != 255)
{
i = curpalette[(int32_t) *ptr].r+curpalette[(int32_t) *ptr].g+curpalette[(int32_t) *ptr].b;
if (i > j) { j = i; bri = *ptr; }
}
ptr++;
} while (--ii);
Bmemcpy(&CrosshairColors, &curpalette[bri], sizeof(palette_t));
Bmemcpy(&DefaultCrosshairColors, &curpalette[bri], sizeof(palette_t));
DefaultCrosshairColors.f = 1; // this flag signifies that the color has been detected
}
void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b)
{
if (g_crosshairSum == r+(g<<8)+(b<<16))
return;
auto ptr = TileFiles.tileMakeWritable(CROSSHAIR);
if (!ptr) return;
if (!DefaultCrosshairColors.f)
G_GetCrosshairColor();
g_crosshairSum = r+(g<<8)+(b<<16);
CrosshairColors.r = r;
CrosshairColors.g = g;
CrosshairColors.b = b;
int32_t ii = tilesiz[CROSSHAIR].x * tilesiz[CROSSHAIR].y;
Bassert(ii > 0);
int32_t i = (videoGetRenderMode() == REND_CLASSIC)
? paletteGetClosestColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b)
: paletteGetClosestColor(255, 255, 255); // use white in GL so we can tint it to the right color
do
{
if (*ptr != 255)
*ptr = i;
ptr++;
} while (--ii);
paletteMakeLookupTable(CROSSHAIR_PAL, NULL, CrosshairColors.r, CrosshairColors.g, CrosshairColors.b, 1);
#ifdef USE_OPENGL
// XXX: this makes us also load all hightile textures tinted with the crosshair color!
polytint_t & crosshairtint = hictinting[CROSSHAIR_PAL];
crosshairtint.tint.r = CrosshairColors.r;
crosshairtint.tint.g = CrosshairColors.g;
crosshairtint.tint.b = CrosshairColors.b;
crosshairtint.f = HICTINT_USEONART | HICTINT_GRAYSCALE;
#endif
tileInvalidate(CROSSHAIR, -1, -1);
}
#define SCORESHEETOFFSET -20
static void G_ShowScores(void)
@ -979,13 +903,12 @@ void G_DisplayRest(int32_t smoothratio)
if ((unsigned) a < MAXTILES)
{
vec2_t crosshairpos = { (160<<16) - (g_player[myconnectindex].ps->look_ang<<15), 100<<16 };
uint8_t crosshair_pal = CROSSHAIR_PAL;
uint32_t crosshair_o = 1|2;
uint32_t crosshair_scale = divscale16(cl_crosshairscale, 100);
if (RR)
crosshair_scale >>= 1;
rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, crosshair_pal, crosshair_o);
rotatesprite_win(crosshairpos.x, crosshairpos.y, crosshair_scale, 0, a, 0, 0, crosshair_o);
}
}