From 29efe17506ef4985e6d232ea0fb72b71092b7deb Mon Sep 17 00:00:00 2001 From: gered Date: Tue, 5 Nov 2019 19:19:23 -0500 Subject: [PATCH] add palette loading when a "palfile:" directive is found in a desc file otherwise it wasn't actually doing anything with it. palette loading was done as part of bitmap loading only, but this allows a specific palette to be set which may make it easier to notice bitmap palette mismatches in some scenarios --- map_edit/m1read.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/map_edit/m1read.c b/map_edit/m1read.c index e30499e..6cbfd9b 100644 --- a/map_edit/m1read.c +++ b/map_edit/m1read.c @@ -15,6 +15,7 @@ #include "ackeng.h" #include "m1.h" +extern UCHAR colordat[]; extern UCHAR *Bitmaps[]; extern UCHAR *ObjBitmaps[]; extern UCHAR ObjbmNum[]; @@ -38,6 +39,20 @@ e++; return(e); } +short LoadPalette(char *paletteName) { + FILE *fp; + + GetCombinedPath(assetsPath, paletteName); + fp = fopen(tempFilename, "rb"); + if (fp == NULL) + return -1; + + fread(colordat, 768, 1, fp); + + fclose(fp); + return 0; +} + /**************************************************************************** ** ** ****************************************************************************/ @@ -275,6 +290,10 @@ while (1) if (!strnicmp(LineBuf,"PALFILE:",8)) { strcpy(PalName,SkipSpaces(&LineBuf[8])); + if (LoadPalette(PalName)) { + printf("Error loading palette \"%s\".\n",PalName); + result = -1; + } continue; }