Commit 6b2a8919 authored by pickle136's avatar pickle136

Cleaned up warnings

parent e5e4e12c
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
// Files // Files
#ifdef __SYMBIAN32__ #ifdef __SYMBIAN32__
#ifdef UIQ3 #ifdef UIQ3
#define CONFIG_FILE "c:\\shared\\openjazz\\openjazz.cfg"" #define CONFIG_FILE "c:\\shared\\openjazz\\openjazz.cfg"
#else #else
#define CONFIG_FILE "c:\\data\\openjazz\\openjazz.cfg" #define CONFIG_FILE "c:\\data\\openjazz\\openjazz.cfg"
#endif #endif
...@@ -189,11 +189,11 @@ typedef int fixed; ...@@ -189,11 +189,11 @@ typedef int fixed;
// Variable // Variable
// Time // Time
EXTERN unsigned int globalTicks; EXTERN unsigned int globalTicks;
// Trigonometric function look-up tables // Trigonometric function look-up tables
EXTERN fixed sinLut[1024]; EXTERN fixed sinLut[1024];
EXTERN fixed tanLut[1024]; EXTERN fixed tanLut[1024];
// Functions in main.cpp // Functions in main.cpp
...@@ -213,15 +213,15 @@ EXTERN char * createEditableString (const char *string); ...@@ -213,15 +213,15 @@ EXTERN char * createEditableString (const char *string);
EXTERN void log (const char *message); EXTERN void log (const char *message);
EXTERN void log (const char *message, const char *detail); EXTERN void log (const char *message, const char *detail);
EXTERN void log (const char *message, int number); EXTERN void log (const char *message, int number);
EXTERN void logError (const char *message, const char *detail); EXTERN void logError (const char *message, const char *detail);
EXTERN fixed fSin (fixed angle); EXTERN fixed fSin (fixed angle);
EXTERN fixed fCos (fixed angle); EXTERN fixed fCos (fixed angle);
EXTERN fixed fTan (fixed angle); EXTERN fixed fTan (fixed angle);
#ifdef VERBOSE #ifdef VERBOSE
#define LOG(x, y) log(x, y) #define LOG(x, y) log(x, y)
#else #else
#define LOG(x, y) x; y #define LOG(x, y)
#endif #endif
#endif #endif
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "file.h" #include "file.h"
#include "io/gfx/video.h" #include "io/gfx/video.h"
File::File (const char* name, bool write) { File::File (const char* name, bool write) {
...@@ -51,9 +51,9 @@ File::~File () { ...@@ -51,9 +51,9 @@ File::~File () {
fclose(file); fclose(file);
#ifdef VERBOSE #ifdef VERBOSE
log("Closed file", filePath); log("Closed file", filePath);
#endif #endif
delete[] filePath; delete[] filePath;
...@@ -66,15 +66,15 @@ bool File::open (const char* path, const char* name, bool write) { ...@@ -66,15 +66,15 @@ bool File::open (const char* path, const char* name, bool write) {
// Create the file path for the given directory // Create the file path for the given directory
filePath = createString(path, name); filePath = createString(path, name);
// Open the file from the path // Open the file from the path
file = fopen(filePath, write ? "wb": "rb"); file = fopen(filePath, write ? "wb": "rb");
if (file) { if (file) {
#ifdef VERBOSE #ifdef VERBOSE
log("Opened file", filePath); log("Opened file", filePath);
#endif #endif
return true; return true;
...@@ -88,19 +88,19 @@ bool File::open (const char* path, const char* name, bool write) { ...@@ -88,19 +88,19 @@ bool File::open (const char* path, const char* name, bool write) {
int File::getSize () { int File::getSize () {
int pos, size; int pos, size;
pos = ftell(file); pos = ftell(file);
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
size = ftell(file); size = ftell(file);
fseek(file, pos, SEEK_SET); fseek(file, pos, SEEK_SET);
return size; return size;
} }
int File::tell () { int File::tell () {
...@@ -111,7 +111,7 @@ int File::tell () { ...@@ -111,7 +111,7 @@ int File::tell () {
void File::seek (int offset, bool reset) { void File::seek (int offset, bool reset) {
fseek(file, offset, reset ? SEEK_SET: SEEK_CUR); fseek(file, offset, reset ? SEEK_SET: SEEK_CUR);
return; return;
...@@ -137,8 +137,8 @@ unsigned short int File::loadShort () { ...@@ -137,8 +137,8 @@ unsigned short int File::loadShort () {
unsigned short int val; unsigned short int val;
val = fgetc(file); val = fgetc(file);
val += fgetc(file) << 8; val += fgetc(file) << 8;
return val; return val;
...@@ -147,22 +147,22 @@ unsigned short int File::loadShort () { ...@@ -147,22 +147,22 @@ unsigned short int File::loadShort () {
void File::storeShort (unsigned short int val) { void File::storeShort (unsigned short int val) {
fputc(val & 255, file); fputc(val & 255, file);
fputc(val >> 8, file); fputc(val >> 8, file);
return; return;
} }
signed long int File::loadInt () { signed long int File::loadInt () {
unsigned long int val; unsigned long int val;
val = fgetc(file); val = fgetc(file);
val += fgetc(file) << 8; val += fgetc(file) << 8;
val += fgetc(file) << 16; val += fgetc(file) << 16;
val += fgetc(file) << 24; val += fgetc(file) << 24;
return *((signed long int *)&val); return *((signed long int *)&val);
...@@ -175,23 +175,23 @@ void File::storeInt (signed long int val) { ...@@ -175,23 +175,23 @@ void File::storeInt (signed long int val) {
uval = *((unsigned long int *)&val); uval = *((unsigned long int *)&val);
fputc(uval & 255, file); fputc(uval & 255, file);
fputc((uval >> 8) & 255, file); fputc((uval >> 8) & 255, file);
fputc((uval >> 16) & 255, file); fputc((uval >> 16) & 255, file);
fputc(uval >> 24, file); fputc(uval >> 24, file);
return; return;
} }
unsigned char * File::loadBlock (int length) { unsigned char * File::loadBlock (int length) {
unsigned char *buffer; unsigned char *buffer;
buffer = new unsigned char[length]; buffer = new unsigned char[length];
fread(buffer, 1, length, file); fread(buffer, 1, length, file);
return buffer; return buffer;
...@@ -204,9 +204,9 @@ unsigned char* File::loadRLE (int length) { ...@@ -204,9 +204,9 @@ unsigned char* File::loadRLE (int length) {
int rle, pos, byte, count, next; int rle, pos, byte, count, next;
// Determine the offset that follows the block // Determine the offset that follows the block
next = fgetc(file); next = fgetc(file);
next += fgetc(file) << 8; next += fgetc(file) << 8;
next += ftell(file); next += ftell(file);
buffer = new unsigned char[length]; buffer = new unsigned char[length];
...@@ -251,36 +251,36 @@ void File::skipRLE () { ...@@ -251,36 +251,36 @@ void File::skipRLE () {
int next; int next;
next = fgetc(file); next = fgetc(file);
next += fgetc(file) << 8; next += fgetc(file) << 8;
fseek(file, next, SEEK_CUR); fseek(file, next, SEEK_CUR);
return; return;
} }
char * File::loadString () { char * File::loadString () {
char *string; char *string;
int length, count; int length, count;
length = fgetc(file); length = fgetc(file);
if (length) { if (length) {
string = new char[length + 1]; string = new char[length + 1];
fread(string, 1, length, file); fread(string, 1, length, file);
} else { } else {
// If the length is not given, assume it is an 8.3 file name // If the length is not given, assume it is an 8.3 file name
string = new char[13]; string = new char[13];
for (count = 0; count < 9; count++) { for (count = 0; count < 9; count++) {
string[count] = fgetc(file); string[count] = fgetc(file);
if (string[count] == '.') { if (string[count] == '.') {
...@@ -294,7 +294,7 @@ char * File::loadString () { ...@@ -294,7 +294,7 @@ char * File::loadString () {
} }
} }
length = count; length = count;
} }
...@@ -306,106 +306,106 @@ char * File::loadString () { ...@@ -306,106 +306,106 @@ char * File::loadString () {
} }
SDL_Surface* File::loadSurface (int width, int height) { SDL_Surface* File::loadSurface (int width, int height) {
SDL_Surface* surface; SDL_Surface* surface;
unsigned char* pixels; unsigned char* pixels;
pixels = loadRLE(width * height); pixels = loadRLE(width * height);
surface = createSurface(pixels, width, height); surface = createSurface(pixels, width, height);
delete[] pixels; delete[] pixels;
return surface; return surface;
}
unsigned char* File::loadPixels (int length) {
unsigned char* pixels;
unsigned char* sorted;
int count;
sorted = new unsigned char[length];
pixels = loadBlock(length);
// Rearrange pixels in correct order
for (count = 0; count < length; count++) {
sorted[count] = pixels[(count >> 2) + ((count & 3) * (length >> 2))];
}
delete[] pixels;
return sorted;
}
unsigned char* File::loadPixels (int length, int key) {
unsigned char* pixels;
unsigned char* sorted;
unsigned char mask = 0;
int count;
sorted = new unsigned char[length];
pixels = new unsigned char[length];
// Read the mask
// Each mask pixel is either 0 or 1
// Four pixels are packed into the lower end of each byte
for (count = 0; count < length; count++) {
if (!(count & 3)) mask = fgetc(file);
pixels[count] = (mask >> (count & 3)) & 1;
}
// Pixels are loaded if the corresponding mask pixel is 1, otherwise
// the transparent index is used. Pixels are scrambled, so the mask
// has to be scrambled the same way.
for (count = 0; count < length; count++) {
sorted[(count >> 2) + ((count & 3) * (length >> 2))] = pixels[count];
}
// Read pixels according to the scrambled mask
for (count = 0; count < length; count++) {
// Use the transparent pixel
pixels[count] = key;
if (sorted[count] == 1) {
// The unmasked portions are transparent, so no masked
// portion should be transparent.
while (pixels[count] == key) pixels[count] = fgetc(file);
}
}
// Rearrange pixels in correct order
for (count = 0; count < length; count++) {
sorted[count] = pixels[(count >> 2) + ((count & 3) * (length >> 2))];
}
delete[] pixels;
return sorted;
} }
unsigned char* File::loadPixels (int length) {
unsigned char* pixels;
unsigned char* sorted;
int count;
sorted = new unsigned char[length];
pixels = loadBlock(length);
// Rearrange pixels in correct order
for (count = 0; count < length; count++) {
sorted[count] = pixels[(count >> 2) + ((count & 3) * (length >> 2))];
}
delete[] pixels;
return sorted;
}
unsigned char* File::loadPixels (int length, int key) {
unsigned char* pixels;
unsigned char* sorted;
unsigned char mask;
int count;
sorted = new unsigned char[length];
pixels = new unsigned char[length];
// Read the mask
// Each mask pixel is either 0 or 1
// Four pixels are packed into the lower end of each byte
for (count = 0; count < length; count++) {
if (!(count & 3)) mask = fgetc(file);
pixels[count] = (mask >> (count & 3)) & 1;
}
// Pixels are loaded if the corresponding mask pixel is 1, otherwise
// the transparent index is used. Pixels are scrambled, so the mask
// has to be scrambled the same way.
for (count = 0; count < length; count++) {
sorted[(count >> 2) + ((count & 3) * (length >> 2))] = pixels[count];
}
// Read pixels according to the scrambled mask
for (count = 0; count < length; count++) {
// Use the transparent pixel
pixels[count] = key;
if (sorted[count] == 1) {
// The unmasked portions are transparent, so no masked
// portion should be transparent.
while (pixels[count] == key) pixels[count] = fgetc(file);
}
}
// Rearrange pixels in correct order
for (count = 0; count < length; count++) {
sorted[count] = pixels[(count >> 2) + ((count & 3) * (length >> 2))];
}
delete[] pixels;
return sorted;
}
void File::loadPalette (SDL_Color* palette) { void File::loadPalette (SDL_Color* palette) {
unsigned char* buffer; unsigned char* buffer;
......
...@@ -29,20 +29,20 @@ pixel_t pixel_get(int x, int y, const unsigned char* pix, unsigned slice, unsign ...@@ -29,20 +29,20 @@ pixel_t pixel_get(int x, int y, const unsigned char* pix, unsigned slice, unsign
if (opt_tes) { if (opt_tes) {
if (x < 0) if (x < 0)
x += dx; x += dx;
if (x >= dx) if ((unsigned int)x >= dx)
x -= dx; x -= dx;
if (y < 0) if (y < 0)
y += dy; y += dy;
if (y >= dy) if ((unsigned int)y >= dy)
y -= dy; y -= dy;
} else { } else {
if (x < 0) if (x < 0)
x = 0; x = 0;
if (x >= dx) if ((unsigned int)x >= dx)
x = dx - 1; x = dx - 1;
if (y < 0) if (y < 0)
y = 0; y = 0;
if (y >= dy) if ((unsigned int)y >= dy)
y = dy - 1; y = dy - 1;
} }
......
...@@ -183,7 +183,7 @@ SDL_Color* Video::getPalette () { ...@@ -183,7 +183,7 @@ SDL_Color* Video::getPalette () {
} }
void Video::changePalette (SDL_Color *palette, unsigned char first, unsigned char amount) { void Video::changePalette (SDL_Color *palette, unsigned char first, unsigned int amount) {
SDL_SetPalette(screen, SDL_PHYSPAL, palette, first, amount); SDL_SetPalette(screen, SDL_PHYSPAL, palette, first, amount);
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
// Constants // Constants
// Original screen dimensions // Original screen dimensions
#define SW 320 #define SW 320
#define SH 200 #define SH 200
#define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE) #define WINDOWED_FLAGS (SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#if defined(WIZ) || defined(GP2X) #if defined(WIZ) || defined(GP2X)
...@@ -42,76 +42,76 @@ ...@@ -42,76 +42,76 @@
#else #else
#define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE) #define FULLSCREEN_FLAGS (SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE)
#endif #endif
#ifdef SCALE #ifdef SCALE
#define MIN_SCALE 1 #define MIN_SCALE 1
#define MAX_SCALE 4 #define MAX_SCALE 4
#endif #endif
// Class // Class
class Video { class Video {
private: private:
SDL_Surface* screen; SDL_Surface* screen;
// Palettes // Palettes
SDL_Color* currentPalette; SDL_Color* currentPalette;
SDL_Color logicalPalette[256]; SDL_Color logicalPalette[256];
bool fakePalette; bool fakePalette;
int screenW, screenH; int screenW, screenH;
#ifdef SCALE #ifdef SCALE
int scaleFactor; int scaleFactor;
#endif #endif
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
bool fullscreen; bool fullscreen;
#endif #endif
public: public:
Video (); Video ();
bool create (int width, int height); bool create (int width, int height);
void setPalette (SDL_Color *palette); void setPalette (SDL_Color *palette);
SDL_Color* getPalette (); SDL_Color* getPalette ();
void changePalette (SDL_Color *palette, unsigned char first, unsigned char amount); void changePalette (SDL_Color *palette, unsigned char first, unsigned int amount);
void restoreSurfacePalette (SDL_Surface *surface); void restoreSurfacePalette (SDL_Surface *surface);
int getWidth (); int getWidth ();
int getHeight (); int getHeight ();
#ifdef SCALE #ifdef SCALE
int getScaleFactor (); int getScaleFactor ();
void setScaleFactor (int newScaleFactor); void setScaleFactor (int newScaleFactor);
#endif #endif
#ifndef FULLSCREEN_ONLY #ifndef FULLSCREEN_ONLY
bool isFullscreen (); bool isFullscreen ();
void flipFullscreen (); void flipFullscreen ();
#endif #endif
void expose (); void expose ();
void flip (int mspf); void flip (int mspf);
}; };
// Variables // Variables
EXTERN SDL_Surface* canvas; EXTERN SDL_Surface* canvas;
EXTERN int viewH, canvasW, canvasH; EXTERN int viewH, canvasW, canvasH;
#define viewW canvasW #define viewW canvasW
// Panel // Panel
EXTERN SDL_Surface* panel; EXTERN SDL_Surface* panel;
EXTERN SDL_Surface* panelAmmo[5]; EXTERN SDL_Surface* panelAmmo[5];
EXTERN Video video; EXTERN Video video;
// Functions // Functions
EXTERN SDL_Surface* createSurface (unsigned char* pixels, int width, int height); EXTERN SDL_Surface* createSurface (unsigned char* pixels, int width, int height);
EXTERN void clearScreen (int index); EXTERN void clearScreen (int index);
EXTERN void drawRect (int x, int y, int width, int height, int index); EXTERN void drawRect (int x, int y, int width, int height, int index);
......
...@@ -47,70 +47,70 @@ ...@@ -47,70 +47,70 @@
#include <string.h> #include <string.h>
#define SKEY 254 /* Sprite colour key */ #define SKEY 254 /* Sprite colour key */
void Level::loadSprite (File* file, Sprite* sprite) { void Level::loadSprite (File* file, Sprite* sprite) {
unsigned char* pixels; unsigned char* pixels;
int pos, maskOffset; int pos, maskOffset;
int width, height; int width, height;
// Load dimensions // Load dimensions
width = file->loadShort() << 2; width = file->loadShort() << 2;
height = file->loadShort(); height = file->loadShort();
file->seek(2, false); file->seek(2, false);
maskOffset = file->loadShort(); maskOffset = file->loadShort();
pos = file->loadShort() << 2; pos = file->loadShort() << 2;
// Sprites can be either masked or not masked. // Sprites can be either masked or not masked.
if (maskOffset) { if (maskOffset) {
// Masked // Masked
height++; height++;
// Skip to mask // Skip to mask
file->seek(maskOffset, false); file->seek(maskOffset, false);
// Find the end of the data // Find the end of the data
pos += file->tell() + ((width >> 2) * height); pos += file->tell() + ((width >> 2) * height);
// Read scrambled, masked pixel data // Read scrambled, masked pixel data
pixels = file->loadPixels(width * height, SKEY); pixels = file->loadPixels(width * height, SKEY);
sprite->setPixels(pixels, width, height, SKEY); sprite->setPixels(pixels, width, height, SKEY);
delete[] pixels; delete[] pixels;
file->seek(pos, true); file->seek(pos, true);
} else if (width) { } else if (width) {
// Not masked // Not masked
// Read scrambled pixel data // Read scrambled pixel data
pixels = file->loadPixels(width * height); pixels = file->loadPixels(width * height);
sprite->setPixels(pixels, width, height, SKEY); sprite->setPixels(pixels, width, height, SKEY);
delete[] pixels; delete[] pixels;
} }
return; return;
} }
int Level::loadSprites (char * fileName) { int Level::loadSprites (char * fileName) {
File* mainFile = NULL; File* mainFile = NULL;
File* specFile = NULL; File* specFile = NULL;
int count; int count;
// Open fileName // Open fileName
try { try {
...@@ -150,52 +150,52 @@ int Level::loadSprites (char * fileName) { ...@@ -150,52 +150,52 @@ int Level::loadSprites (char * fileName) {
// Read vertical offsets // Read vertical offsets
for (count = 0; count < sprites; count++) for (count = 0; count < sprites; count++)
spriteSet[count].yOffset = specFile->loadChar(); spriteSet[count].yOffset = specFile->loadChar();
// Skip to where the sprites start in mainchar.000 // Skip to where the sprites start in mainchar.000
mainFile->seek(2, true); mainFile->seek(2, true);
// Loop through all the sprites to be loaded // Loop through all the sprites to be loaded
for (count = 0; count < sprites; count++) { for (count = 0; count < sprites; count++) {
if (specFile->loadChar() == 0xFF) { if (specFile->loadChar() == 0xFF) {
// Go to the next sprite/file indicator // Go to the next sprite/file indicator
specFile->seek(1, false); specFile->seek(1, false);
if (mainFile->loadChar() == 0xFF) { if (mainFile->loadChar() == 0xFF) {
// Go to the next sprite/file indicator // Go to the next sprite/file indicator
mainFile->seek(1, false); mainFile->seek(1, false);
/* Both fileName and mainchar.000 have file indicators, so /* Both fileName and mainchar.000 have file indicators, so
create a blank sprite */ create a blank sprite */
spriteSet[count].clearPixels(); spriteSet[count].clearPixels();
continue; continue;
} else { } else {
// Return to the start of the sprite // Return to the start of the sprite
mainFile->seek(-1, false); mainFile->seek(-1, false);
// Load the individual sprite data // Load the individual sprite data
loadSprite(mainFile, spriteSet + count); loadSprite(mainFile, spriteSet + count);
} }
} else { } else {
// Return to the start of the sprite // Return to the start of the sprite
specFile->seek(-1, false); specFile->seek(-1, false);
// Go to the main file's next sprite/file indicator // Go to the main file's next sprite/file indicator
mainFile->seek(2, false); mainFile->seek(2, false);
// Load the individual sprite data // Load the individual sprite data
loadSprite(specFile, spriteSet + count); loadSprite(specFile, spriteSet + count);
} }
...@@ -310,8 +310,8 @@ int Level::loadTiles (char * fileName) { ...@@ -310,8 +310,8 @@ int Level::loadTiles (char * fileName) {
tileSet = createSurface(buffer, TTOI(1), TTOI(tiles)); tileSet = createSurface(buffer, TTOI(1), TTOI(tiles));
SDL_SetColorKey(tileSet, SDL_SRCCOLORKEY, TKEY); SDL_SetColorKey(tileSet, SDL_SRCCOLORKEY, TKEY);
delete[] buffer; delete[] buffer;
return tiles; return tiles;
...@@ -322,7 +322,8 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) { ...@@ -322,7 +322,8 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
File *file; File *file;
unsigned char *buffer; unsigned char *buffer;
char *string, *ext; const char *ext;
char *string;
int tiles; int tiles;
int count, x, y, type; int count, x, y, type;
...@@ -924,7 +925,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) { ...@@ -924,7 +925,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
endTime = (5 - difficulty) * 2 * 60 * 1000; endTime = (5 - difficulty) * 2 * 60 * 1000;
events = NULL; events = NULL;
bullets = NULL; bullets = NULL;
energyBar = 0; energyBar = 0;
......
...@@ -253,7 +253,7 @@ int Scene::play () { ...@@ -253,7 +253,7 @@ int Scene::play () {
SDL_Rect dst; SDL_Rect dst;
unsigned int sceneIndex = 0; unsigned int sceneIndex = 0;
SceneImage *image; SceneImage *image;
SceneAnimation* animation; SceneAnimation* animation = NULL;
SceneFrame* currentFrame = NULL; SceneFrame* currentFrame = NULL;
SceneFrame* lastFrame = NULL; SceneFrame* lastFrame = NULL;
int frameDelay = 0; int frameDelay = 0;
......
...@@ -483,7 +483,7 @@ void Scene::loadScripts (File *f) { ...@@ -483,7 +483,7 @@ void Scene::loadScripts (File *f) {
int textPosY = -1; int textPosY = -1;
int extraheight = -1; int extraheight = -1;
SDL_Rect textRect; SDL_Rect textRect = { 0,0,0,0 };
bool textRectValid = false; bool textRectValid = false;
f->seek(scriptStarts[loop], true); // Seek to data start f->seek(scriptStarts[loop], true); // Seek to data start
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment