diff --git a/source/build/include/palette.h b/source/build/include/palette.h index 9a249f3bd..30e485547 100644 --- a/source/build/include/palette.h +++ b/source/build/include/palette.h @@ -79,7 +79,7 @@ extern void setup_blend(int32_t blend, int32_t doreverse); extern uint8_t basepalreset; extern int32_t curbrightness; -extern int32_t paletteLoadLookupTable(buildvfs_kfd fp); +extern int32_t paletteLoadLookupTable(FileReader &fp); extern void paletteSetupDefaultFog(void); extern void palettePostLoadLookups(void); extern void paletteFixTranslucencyMask(void); diff --git a/source/build/src/palette.cpp b/source/build/src/palette.cpp index 35c47328c..ff357042a 100644 --- a/source/build/src/palette.cpp +++ b/source/build/src/palette.cpp @@ -462,19 +462,19 @@ void paletteFixTranslucencyMask(void) // - on success, 0 // - on error, -1 (didn't read enough data) // - -2: error, we already wrote an error message ourselves -int32_t paletteLoadLookupTable(buildvfs_kfd fp) +int32_t paletteLoadLookupTable(FileReader &fp) { uint8_t numlookups; char remapbuf[256]; - if (kread_and_test(fp, &numlookups, 1)) + if (1 != fp.Read(&numlookups, 1)) return -1; for (bssize_t j=0; j= 256-RESERVEDPALS) @@ -483,7 +483,7 @@ int32_t paletteLoadLookupTable(buildvfs_kfd fp) return -2; } - if (kread_and_test(fp, remapbuf, 256)) + if (256 != fp.Read(remapbuf, 256)) return -1; paletteMakeLookupTable(palnum, remapbuf, 0, 0, 0, 0); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index eca268cd7..03162211c 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -121,7 +121,6 @@ int32_t r_yshearing = 0; // used for fogcalc static float fogresult, fogresult2; -coltypef fogcol, fogtable[MAXPALOOKUPS]; int32_t r_useindexedcolortextures = -1; @@ -245,14 +244,6 @@ static void calcmat(vec3f_t a0, const vec2f_t *offset, float f, float mat[16], i void polymost_glreset() { - for (bssize_t i=0; i<=MAXPALOOKUPS-1; i++) - { - fogtable[i].r = palookupfog[i].r * (1.f/255.f); - fogtable[i].g = palookupfog[i].g * (1.f/255.f); - fogtable[i].b = palookupfog[i].b * (1.f/255.f); - fogtable[i].a = 0; - } - //Reset if this is -1 (meaning 1st texture call ever), or > 0 (textures in memory) if (gltexcacnum < 0) { diff --git a/source/duke3d/src/common.cpp b/source/duke3d/src/common.cpp index 78efa4e5e..ebb7c394f 100644 --- a/source/duke3d/src/common.cpp +++ b/source/duke3d/src/common.cpp @@ -1022,20 +1022,19 @@ void G_DoAutoload(const char *dirname) void G_LoadLookups(void) { int32_t j; - buildvfs_kfd fp; - if ((fp=kopen4loadfrommod("lookup.dat",0)) == buildvfs_kfd_invalid) - if ((fp=kopen4loadfrommod("lookup.dat",1)) == buildvfs_kfd_invalid) - return; + auto fr = kopenFileReader("lookup.dat", 0); + if (!fr.isOpen()) + return; - j = paletteLoadLookupTable(fp); + j = paletteLoadLookupTable(fr); if (j < 0) { if (j == -1) initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n"); - return kclose(fp); + return; } uint8_t paldata[768]; @@ -1045,16 +1044,14 @@ void G_LoadLookups(void) // Account for TITLE and REALMS swap between basepal number and on-disk order. int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j; - if (kread_and_test(fp, paldata, 768)) - return kclose(fp); + if (fr.Read(paldata, 768) != 768) + return; for (unsigned char & k : paldata) k <<= 2; paletteSetColorTable(basepalnum, paldata); } - - kclose(fp); } ////////// diff --git a/source/rr/src/common.cpp b/source/rr/src/common.cpp index cf0e11b1a..f485612cb 100644 --- a/source/rr/src/common.cpp +++ b/source/rr/src/common.cpp @@ -992,20 +992,20 @@ void G_DoAutoload(const char *dirname) void G_LoadLookups(void) { - int32_t fp, j; + int32_t j; - if ((fp=kopen4loadfrommod("lookup.dat",0)) == -1) - if ((fp=kopen4loadfrommod("lookup.dat",1)) == -1) - return; + auto fr = kopenFileReader("lookup.dat", 0); + if (!fr.isOpen()) + return; - j = paletteLoadLookupTable(fp); + j = paletteLoadLookupTable(fr); if (j < 0) { if (j == -1) initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n"); - return kclose(fp); + return; } uint8_t paldata[768]; @@ -1015,8 +1015,8 @@ void G_LoadLookups(void) // Account for TITLE and REALMS swap between basepal number and on-disk order. int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j; - if (kread_and_test(fp, paldata, 768)) - return kclose(fp); + if (fr.Read(paldata, 768) != 768) + return; for (bssize_t k = 0; k < 768; k++) paldata[k] <<= 2; @@ -1028,8 +1028,6 @@ void G_LoadLookups(void) paldata[767] = palette[767]; paletteSetColorTable(DRUGPAL, paldata); - kclose(fp); - if (RR) { char table[256]; diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index be175b145..d626323d9 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -28,8 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "cmdline.h" -extern coltypef fogtable[MAXPALOOKUPS]; - BEGIN_RR_NS static int32_t g_whichPalForPlayer = 9; @@ -2646,13 +2644,6 @@ void G_SetFog(int fogtype) #ifdef USE_OPENGL if (videoGetRenderMode() >= REND_POLYMOST) { - for (bssize_t i=0; i<=MAXPALOOKUPS-1; i++) - { - fogtable[i].r = palookupfog[i].r * (1.f/255.f); - fogtable[i].g = palookupfog[i].g * (1.f/255.f); - fogtable[i].b = palookupfog[i].b * (1.f/255.f); - fogtable[i].a = 0; - } //gltexinvalidatetype(INVALIDATE_ALL_NON_INDEXED); static int swaps[] = { 0, 30, 33, 23, 8 }; uploadpalswaps(5, swaps);