From df25e3cd7c4eec741ba839672abe5062c3684586 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 16 Feb 2014 19:16:05 +0000 Subject: [PATCH] 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 +1, where is the first byte value of LOOKUP.DAT. This allows to pack e.g. lookups [1 .. 25] and [30 .. ] 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 --- polymer/eduke32/build/include/m32script.h | 1 - polymer/eduke32/build/src/engine.c | 39 ++++++++++++++++------- polymer/eduke32/source/astub.c | 12 ++++--- polymer/eduke32/source/game.c | 9 ++++-- polymer/eduke32/source/global.h | 1 - polymer/eduke32/source/mapster32.h | 2 +- polymer/eduke32/source/osdcmds.c | 2 +- polymer/eduke32/source/premap.h | 1 - 8 files changed, 44 insertions(+), 23 deletions(-) diff --git a/polymer/eduke32/build/include/m32script.h b/polymer/eduke32/build/include/m32script.h index f1b9d59f4..2a094fae6 100644 --- a/polymer/eduke32/build/include/m32script.h +++ b/polymer/eduke32/build/include/m32script.h @@ -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; diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index a535bccea..e707eefdf 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -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; jcstat & 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) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 546673e38..81d7e6479 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -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. diff --git a/polymer/eduke32/source/global.h b/polymer/eduke32/source/global.h index 29a41b774..7f29f6036 100644 --- a/polymer/eduke32/source/global.h +++ b/polymer/eduke32/source/global.h @@ -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; diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index e6491894f..24503ceb2 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -84,7 +84,7 @@ static uint8_t *basepaltable[BASEPALCOUNT] = { }; -static int32_t num_tables; +static int32_t g_firstFogPal; static int32_t updownunits=1024; diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 6bb27ec0b..c7482f1dd 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -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 }, diff --git a/polymer/eduke32/source/premap.h b/polymer/eduke32/source/premap.h index cc5569dfc..8256205e2 100644 --- a/polymer/eduke32/source/premap.h +++ b/polymer/eduke32/source/premap.h @@ -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);