- Code: Select all
#define WORD unsigned short int
#define DWORD unsigned long int
#define LONG signed long int
#define M7_ERROR_NONE 0
#define M7_ERROR_SIZE 1
#define M7_ERROR_FORMAT 2
#define M7_ERROR_UNKNOWN 3
#define M7_TEX_NUMBER 256
#define M7_TEX_WIDTH 32
#define M7_TEX_HEIGHT 32
#define M7_MAP_WIDTH 256
#define M7_MAP_HEIGHT 256
int tex[M7_TEX_NUMBER][M7_TEX_WIDTH][M7_TEX_HEIGHT];
int map[M7_MAP_WIDTH][M7_MAP_HEIGHT];
int textotal = 0;
int mode7_loadBitmap(char *fname)
{
FILE *fp = fopen(fname, "r");
int err = 0, err2 = 0;
char *bfType;
fgets(bfType, 2, fp);
if(strcmp(bfType, "BM")) err = M7_ERROR_FORMAT;
DWORD bfSize, bfReserved, bfOffBits;
fread(bfSize, 4, 1, fp);
if(fread(bfReserved, 4, 1, fp)) err = M7_ERROR_FORMAT;
fread(bfOffBits, 4, 1, fp);
if(!err)
{
DWORD biSize;
LONG biWidth, biHeight;
WORD biPlanes, biBitCount;
DWORD biCompression, biSizeImage;
LONG biXPelsPerMeter, biYPelsPerMeter;
DWORD biCrlUsed, biCrlImportant;
if(fread(biSize, 4, 1, fp)!=40) err = M7_ERROR_FORMAT;
fread(biWidth, 4, 1, fp); fread(biHeight, 4, 1, fp);
if(biWidth!=M7_TEX_WIDTH||biHeight!=M7_TEX_HEIGHT) err2 = M7_ERROR_SIZE;
fread(biPlanes, 2, 1, fp); fread(biBitCount, 2, 1, fp);
if(biBitCount!=24) err = M7_ERROR_FORMAT;
if(biPlanes!=1) err = M7_ERROR_FORMAT;
fread(biCompression, 4, 1, fp); fread(biSizeImage, 4, 1, fp);
if(biCompression) err = M7_ERROR_FORMAT;
fread(biXPelsPerMeter, 4, 1, fp); fread(biYPelsPerMeter, 4, 1, fp);
fread(biCrlUsed, 4, 1, fp); fread(biCrlImportant, 4, 1, fp);
if(!err)
{
int xi, yi;
unsigned int col;
int ind = textotal;
textotal++;
for(yi=M7_TEX_HEIGHT-1;yi>=0;yi--) for(xi=0;xi<M7_TEX_WIDTH;xi++)
{
if(!feof(fp)) fread(col, 3, 1, fp);
else break;
tex[ind][xi][yi] = col;
}
if(yi>=0||xi<M7_TEX_WIDTH)
{
for(yi=yi;yi>=0;yi--) for(xi=xi;xi<M7_TEX_WIDTH;xi++) tex[ind][xi][yi] = 0;
}
}
}
fclose(fp);
if(err) return err;
else return err2;
}
GE says:
Error
Error line 27: Unexpected declaration err
Warning line 28: Suspicious pointer conversion
Warning line 29: Suspicious pointer conversion
Warning line 30: Suspicious pointer conversion
Warning line 39: Suspicious pointer conversion
Warning line 40: Suspicious pointer conversion
Warning line 42: Suspicious pointer conversion
Warning line 45: Suspicious pointer conversion
Warning line 47: Suspicious pointer conversion
Warning line 48: Suspicious pointer conversion
Warning line 57: Suspicious pointer conversion
Why unexpected declartion on line 27? There isn't any declaration.