diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index d63668c50..0bb1301ad 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -342,8 +342,7 @@ static int32_t defsparser(scriptfile *script) break; case T_FOGPAL: { - int32_t p,r,g,b,j; - char tempbuf[256]; + int32_t p,r,g,b; if (scriptfile_getnumber(script,&p)) break; if (scriptfile_getnumber(script,&r)) break; @@ -354,9 +353,7 @@ static int32_t defsparser(scriptfile *script) g = clamp(g, 0, 63); b = clamp(b, 0, 63); - for (j = 0; j < 256; j++) - tempbuf[j] = j; - makepalookup(p, tempbuf, r, g, b, 1); + makepalookup(p, NULL, r, g, b, 1); } break; case T_LOADGRP: @@ -1655,9 +1652,9 @@ static int32_t defsparser(scriptfile *script) initprintf("Error: missing 'palette number' %s\n", msgend); break; } - else if ((unsigned)pal >= MAXPALOOKUPS-RESERVEDPALS) + else if (pal==0 || (unsigned)pal >= MAXPALOOKUPS-RESERVEDPALS) { - initprintf("Error: 'palette number' out of range (max=%d) %s\n", + initprintf("Error: 'palette number' out of range (1 .. %d) %s\n", MAXPALOOKUPS-RESERVEDPALS-1, msgend); break; } diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index a76d29a9c..95025d59e 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -13414,11 +13414,23 @@ void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8 const char *ptr; char *ptr2; - if (paletteloaded == 0) return; + static char idmap[256] = {1}; - if ((unsigned)palnum >= MAXPALOOKUPS) + if (paletteloaded == 0) return; + if (palnum==0 || (unsigned)palnum >= MAXPALOOKUPS) + return; + + if (remapbuf==NULL) + { + if (idmap[0]==1) // init identity map + for (i=0; i<256; i++) + idmap[i] = i; + + remapbuf = idmap; + } + if (palookup[palnum] == NULL) { //Allocate palookup buffer diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 0b2028d63..89e3bf9a0 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -2975,11 +2975,8 @@ static void ReadPaletteTable(void) int32_t i,j,fp; char lookup_num; - for (j = 0; j < 256; j++) - tempbuf[j] = j; - for (i=1; i= 0; i--) - tempbuf[i] = i; - - makepalookup(CROSSHAIR_PAL,tempbuf,CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1); + makepalookup(CROSSHAIR_PAL, NULL, CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1); #ifdef USE_OPENGL // XXX: this makes us also load all hightile textures tinted with the crosshair color! @@ -9457,11 +9454,8 @@ static void G_LoadExtraPalettes(void) // g_numRealPalettes = ((g_numRealPalettes * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32; #endif - for (j = 0; j < 256; j++) - tempbuf[j] = j; - for (j=g_numRealPalettes+1; j=0; j--) { @@ -9472,13 +9466,11 @@ static void G_LoadExtraPalettes(void) makepalookup(look_pos, tempbuf, 0,0,0, 1); } - for (j = 255; j>=0; j--) - tempbuf[j] = j; g_numRealPalettes++; - makepalookup(g_numRealPalettes, tempbuf, 15, 15, 15, 1); - makepalookup(g_numRealPalettes + 1, tempbuf, 15, 0, 0, 1); - makepalookup(g_numRealPalettes + 2, tempbuf, 0, 15, 0, 1); - makepalookup(g_numRealPalettes + 3, tempbuf, 0, 0, 15, 1); + makepalookup(g_numRealPalettes, NULL, 15, 15, 15, 1); + makepalookup(g_numRealPalettes + 1, NULL, 15, 0, 0, 1); + makepalookup(g_numRealPalettes + 2, NULL, 0, 15, 0, 1); + makepalookup(g_numRealPalettes + 3, NULL, 0, 0, 15, 1); kread(fp,&water_pal[0],768); kread(fp,&slime_pal[0],768);