mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
In loadlookups(), look for gap of 4 consecutive unused pals for fog pals.
As opposed to the previous way, where the first fog pals was <numlookups>+1, where <numlookups> is the first byte value of LOOKUP.DAT. This allows to pack e.g. lookups [1 .. 25] and [30 .. <lastpal>] into LOOKUP.DAT and have fog pals be generated at pals [26 .. 29] (i.e. the additional lookups don't shift the fog pals, making user maps depending on these numbers not look as intended.) git-svn-id: https://svn.eduke32.com/eduke32@4335 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7e7507746d
commit
df25e3cd7c
8 changed files with 44 additions and 23 deletions
|
@ -173,7 +173,6 @@ extern int32_t g_iReturnVar;
|
|||
extern int32_t g_doScreenShot;
|
||||
extern int32_t m32_sortvar1, m32_sortvar2;
|
||||
|
||||
//extern int32_t g_numRealPalettes;
|
||||
//extern int32_t g_scriptDebug;
|
||||
|
||||
extern int32_t g_numQuoteRedefinitions;
|
||||
|
|
|
@ -8150,37 +8150,36 @@ static int32_t loadpalette(void)
|
|||
//
|
||||
// Returns:
|
||||
// - if generated fog shade tables, their first palnum P (fog pals are [P .. P+3])
|
||||
// - if didn't (no room), 0
|
||||
// - on error, -1
|
||||
int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr)
|
||||
{
|
||||
uint8_t numlookups;
|
||||
char remapbuf[256];
|
||||
int32_t j;
|
||||
int32_t j, firstfogpal=0;
|
||||
|
||||
if (kread(fp, &numlookups, 1) != 1)
|
||||
return -1;
|
||||
|
||||
for (j=numlookups+1; j<MAXPALOOKUPS; j++)
|
||||
makepalookup(j, NULL, 0,0,0, 1);
|
||||
|
||||
for (j=0; j<numlookups; j++)
|
||||
{
|
||||
uint8_t palnum;
|
||||
|
||||
if (kread(fp, &palnum, 1) != 1)
|
||||
return -1;
|
||||
|
||||
if (palnum == 0)
|
||||
{
|
||||
initprintf("ERROR: attempt to load lookup at pal 0\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (kread(fp, remapbuf, 256) != 256)
|
||||
return -1;
|
||||
|
||||
makepalookup(palnum, remapbuf, 0,0,0, 1);
|
||||
}
|
||||
|
||||
numlookups++;
|
||||
makepalookup(numlookups, NULL, 15, 15, 15, 1);
|
||||
makepalookup(numlookups + 1, NULL, 15, 0, 0, 1);
|
||||
makepalookup(numlookups + 2, NULL, 0, 15, 0, 1);
|
||||
makepalookup(numlookups + 3, NULL, 0, 0, 15, 1);
|
||||
|
||||
for (j=1; j<=5; j++)
|
||||
{
|
||||
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
||||
|
@ -8191,7 +8190,25 @@ int32_t loadlookups(int32_t fp, uint8_t **basepaltabptr)
|
|||
return -1;
|
||||
}
|
||||
|
||||
return numlookups;
|
||||
// Find a gap of four consecutive unused pal numbers to generate fog shade tables.
|
||||
for (j=1; j<=255-3; j++)
|
||||
if (!palookup[j] && !palookup[j+1] && !palookup[j+2] && !palookup[j+3])
|
||||
{
|
||||
makepalookup(j, NULL, 15, 15, 15, 1);
|
||||
makepalookup(j+1, NULL, 15, 0, 0, 1);
|
||||
makepalookup(j+2, NULL, 0, 15, 0, 1);
|
||||
makepalookup(j+3, NULL, 0, 0, 15, 1);
|
||||
|
||||
firstfogpal = j;
|
||||
break;
|
||||
}
|
||||
|
||||
// Alias remaining unused pal numbers to the base shade table.
|
||||
for (j=1; j<MAXPALOOKUPS; j++)
|
||||
if (!palookup[j])
|
||||
makepalookup(j, NULL, 0,0,0, 1);
|
||||
|
||||
return firstfogpal;
|
||||
}
|
||||
|
||||
// Finds a color index in [0 .. lastokcol] closest to (r, g, b).
|
||||
|
|
|
@ -2856,10 +2856,10 @@ static int32_t ReadPaletteTable(void)
|
|||
}
|
||||
}
|
||||
|
||||
num_tables = loadlookups(fp, basepaltable);
|
||||
g_firstFogPal = loadlookups(fp, basepaltable);
|
||||
kclose(fp);
|
||||
|
||||
if (num_tables < 0)
|
||||
if (g_firstFogPal < 0)
|
||||
{
|
||||
initprintf("ERROR loading PALOOKUP.DAT: failed reading enough data\n");
|
||||
return 1;
|
||||
|
@ -10938,13 +10938,17 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr
|
|||
if (shadepreview)
|
||||
{
|
||||
int32_t wallaligned = (tspr->cstat & 16);
|
||||
int32_t fpal;
|
||||
|
||||
if (tspr->sectnum<0)
|
||||
continue;
|
||||
|
||||
fpal = sector[tspr->sectnum].floorpal;
|
||||
|
||||
// 1st rule
|
||||
if (sector[tspr->sectnum].floorpal > 0 && sector[tspr->sectnum].floorpal < num_tables)
|
||||
tspr->pal = sector[tspr->sectnum].floorpal;
|
||||
// Compare with game.c:G_MaybeTakeOnFloorPal()
|
||||
if (fpal > 0 && g_firstFogPal > 0 && !(fpal >= g_firstFogPal && fpal <= g_firstFogPal+3))
|
||||
tspr->pal = fpal;
|
||||
|
||||
// 2nd and 3rd rule minus "actor condition"
|
||||
if (!wallaligned && (tspr->cstat&2048)==0)
|
||||
|
|
|
@ -6979,11 +6979,14 @@ SPAWN_END:
|
|||
return i;
|
||||
}
|
||||
|
||||
static int32_t g_firstFogPal;
|
||||
|
||||
static int32_t G_MaybeTakeOnFloorPal(spritetype *datspr, int32_t sect)
|
||||
{
|
||||
int32_t dapal = sector[sect].floorpal;
|
||||
|
||||
if (dapal && !g_noFloorPal[dapal] && dapal < g_numRealPalettes
|
||||
if (dapal && g_firstFogPal && !(dapal >= g_firstFogPal && dapal <= g_firstFogPal+3)
|
||||
&& !g_noFloorPal[dapal]
|
||||
&& !A_CheckSpriteFlags(datspr->owner,SPRITE_NOPAL))
|
||||
{
|
||||
datspr->pal = dapal;
|
||||
|
@ -10637,10 +10640,10 @@ static void G_LoadExtraPalettes(void)
|
|||
if (fp == -1)
|
||||
G_GameExit("\nERROR: File 'lookup.dat' not found.");
|
||||
|
||||
g_numRealPalettes = loadlookups(fp, basepaltable);
|
||||
g_firstFogPal = loadlookups(fp, basepaltable);
|
||||
kclose(fp);
|
||||
|
||||
if (g_numRealPalettes < 0)
|
||||
if (g_firstFogPal < 0)
|
||||
G_GameExit("\nERROR loading 'lookup.dat': failed reading enough data.");
|
||||
|
||||
// Make color index 255 of default/water/slime palette black.
|
||||
|
|
|
@ -96,7 +96,6 @@ G_EXTERN int32_t g_groupFileHandle;
|
|||
G_EXTERN int32_t g_impactDamage,g_maxPlayerHealth;
|
||||
G_EXTERN int32_t g_musicSize;
|
||||
G_EXTERN int32_t g_numLabels,g_numDefaultLabels;
|
||||
G_EXTERN int32_t g_numRealPalettes;
|
||||
G_EXTERN int32_t g_scriptDebug;
|
||||
G_EXTERN int32_t g_showShareware;
|
||||
G_EXTERN int8_t g_numPlayerSprites;
|
||||
|
|
|
@ -84,7 +84,7 @@ static uint8_t *basepaltable[BASEPALCOUNT] = {
|
|||
};
|
||||
|
||||
|
||||
static int32_t num_tables;
|
||||
static int32_t g_firstFogPal;
|
||||
|
||||
static int32_t updownunits=1024;
|
||||
|
||||
|
|
|
@ -1467,7 +1467,7 @@ int32_t registerosdcommands(void)
|
|||
{ "cl_weaponsway", "enable/disable player weapon swaying", (void *)&ud.weaponsway, CVAR_BOOL, 0, 1 },
|
||||
{ "cl_weaponswitch", "enable/disable auto weapon switching", (void *)&ud.weaponswitch, CVAR_INT|CVAR_MULTI, 0, 7 },
|
||||
|
||||
{ "color", "changes player palette", (void *)&ud.color, CVAR_INT|CVAR_MULTI, 0, g_numRealPalettes },
|
||||
{ "color", "changes player palette", (void *)&ud.color, CVAR_INT|CVAR_MULTI, 0, MAXPALOOKUPS-1 },
|
||||
|
||||
{ "crosshairscale","changes the size of the crosshair", (void *)&ud.crosshairscale, CVAR_INT, 10, 100 },
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ extern halfdimen_t g_halfScreen;
|
|||
extern int32_t g_halveScreenArea;
|
||||
|
||||
extern int32_t g_levelTextTime;
|
||||
extern int32_t g_numRealPalettes;
|
||||
extern int32_t voting,vote_map,vote_episode;
|
||||
extern palette_t CrosshairColors;
|
||||
void G_SetupFilenameBasedMusic(char *levnamebuf, const char *boardfilename, int32_t level_number);
|
||||
|
|
Loading…
Reference in a new issue