Commit 6b2a8919 authored by pickle136's avatar pickle136

Cleaned up warnings

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