Commit 4bca7986 authored by alistert's avatar alistert

Some overdue C++ising. Fixed multiplayer starting position.

parent ec9b06cc
......@@ -29,14 +29,6 @@
#include <SDL/SDL.h>
// Constants
// Displayed statistics
#define S_NONE 0
#define S_PLAYERS 1
#define S_SCREEN 2
// Macros
// For converting between tile positions and int/fixed values
......@@ -46,7 +38,13 @@
#define TTOI(x) ((x) << 5)
// Enum
// Enums
enum LevelStats {
S_PLAYERS = 1, S_SCREEN = 2
};
enum LevelStage {
......@@ -60,14 +58,14 @@ enum LevelStage {
class BaseLevel {
protected:
SDL_Surface *tileSet;
SDL_Color palette[256];
unsigned int tickOffset, prevStepTicks, prevTicks, ticks;
unsigned int endTime;
float smoothfps;
int items;
bool paused;
LevelStage stage;
SDL_Surface* tileSet;
SDL_Color palette[256];
unsigned int tickOffset, prevStepTicks, prevTicks, ticks;
unsigned int endTime;
float smoothfps;
int items;
bool paused;
LevelStage stage;
void timeCalcs ();
void drawStats (int stats);
......
......@@ -453,7 +453,7 @@ int Bonus::play () {
pmessage = pmenu = false;
option = 0;
stats = S_NONE;
stats = 0;
returnTime = 0;
......
......@@ -32,11 +32,12 @@
#include "level/level.h"
#include "menu/menu.h"
#include "player/player.h"
#include <iostream>
#include <string.h>
ClientGame::ClientGame (char *address) {
ClientGame::ClientGame (char* address) {
unsigned char buffer[BUFFER_LENGTH];
unsigned int timeout;
......@@ -106,7 +107,7 @@ ClientGame::ClientGame (char *address) {
}
printf("Connected to server (version %d).\n", buffer[2]);
std::cout << "Connected to server (version " << int(buffer[2]) << ").\n";
// Copy game parameters
mode = GameModeType(buffer[3]);
......@@ -115,8 +116,8 @@ ClientGame::ClientGame (char *address) {
nPlayers = buffer[6];
clientID = buffer[7];
printf("Game mode %d, difficulty %d, %d of %d players.\n", mode,
difficulty, nPlayers, maxPlayers);
std::cout << "Game mode " << mode << ", difficulty " << difficulty << ", " <<
nPlayers << " of " << maxPlayers << " players.\n";
if (nPlayers > maxPlayers) {
......@@ -243,7 +244,7 @@ ClientGame::~ClientGame () {
}
int ClientGame::setLevel (char *fileName) {
int ClientGame::setLevel (char* fileName) {
int ret;
......@@ -300,7 +301,7 @@ int ClientGame::setLevel (char *fileName) {
}
void ClientGame::send (unsigned char *buffer) {
void ClientGame::send (unsigned char* buffer) {
net->send(sock, buffer);
......@@ -397,33 +398,32 @@ int ClientGame::step (unsigned int ticks) {
if ((recvBuffer[1] == MT_G_PJOIN) &&
(recvBuffer[3] < maxPlayers)) {
printf("Player %d joined the game.\n", recvBuffer[3]);
std::cout << "Player " << int(recvBuffer[3]) << " joined the game.\n";
// Add the new player, and any that have been missed
for (count = nPlayers; count <= recvBuffer[3]; count++)
{
for (count = nPlayers; count <= recvBuffer[3]; count++) {
players[count].init((char *)recvBuffer + 9,
recvBuffer + 5, recvBuffer[4]);
players[count].reset();
resetPlayer(players + count, false);
printf("Player %d joined team %d.\n",
count, recvBuffer[4]);
std::cout << "Player " << count << " joined team " <<
recvBuffer[4] << ".\n";
}
nPlayers = count;
if (recvBuffer[2] == clientID)
localPlayer = players + recvBuffer[3];
localPlayer = players + recvBuffer[3];
}
if ((recvBuffer[1] == MT_G_PQUIT) &&
(recvBuffer[2] < nPlayers)) {
printf("Player %d left the game.\n", recvBuffer[2]);
std::cout << "Player " << int(recvBuffer[2]) << " left the game.\n";
// Remove the player
......
......@@ -107,7 +107,7 @@ int Game::setBonus (int ext) {
if (bonusFile) delete[] bonusFile;
if (level != NULL) bonusFile = createFileName(F_BONUSMAP, ext);
if (ext >= 0) bonusFile = createFileName(F_BONUSMAP, ext);
else bonusFile = NULL;
return E_NONE;
......
......@@ -31,11 +31,12 @@
#include "io/network.h"
#include "level/level.h"
#include "player/player.h"
#include <iostream>
#include <string.h>
#include <string.h>
ServerGame::ServerGame (GameModeType mode, char *firstLevel, int gameDifficulty) {
ServerGame::ServerGame (GameModeType mode, char* firstLevel, int gameDifficulty) {
int count;
......@@ -104,9 +105,9 @@ ServerGame::~ServerGame () {
}
int ServerGame::setLevel (char *fileName) {
int ServerGame::setLevel (char* fileName) {
File *file;
File* file;
int count;
if (levelFile) delete[] levelFile;
......@@ -161,7 +162,7 @@ int ServerGame::setLevel (char *fileName) {
}
void ServerGame::send (unsigned char *buffer) {
void ServerGame::send (unsigned char* buffer) {
int count;
......@@ -247,8 +248,8 @@ int ServerGame::step (unsigned int ticks) {
if ((recvBuffers[count][1] == MT_G_PJOIN) &&
(clientPlayer[count] == -1)) {
printf("Player %d (client %d) joined the game.\n",
nPlayers, count);
std::cout << "Player " << nPlayers << " (client " <<
count <<") joined the game.\n";
// Set up the new player
......@@ -260,8 +261,8 @@ int ServerGame::step (unsigned int ticks) {
recvBuffers[count][4]);
players[nPlayers].reset();
printf("Player %d joined team %d.\n",
nPlayers, recvBuffers[count][4]);
std::cout << "Player " << nPlayers << " joined team " <<
recvBuffers[count][4] << ".\n";
recvBuffers[count][3] = clientPlayer[count] =
nPlayers;
......@@ -329,7 +330,7 @@ int ServerGame::step (unsigned int ticks) {
if (clientSock[count] != -1) {
printf("Client %d connected.\n", count);
std::cout << "Client " << count << " connected.\n";
clientPlayer[count] = -1;
received[count] = 0;
......@@ -349,7 +350,14 @@ int ServerGame::step (unsigned int ticks) {
// Initiate sending of level data
clientStatus[count] = 0;
// Inform the new client of the checkpoint
sendBuffer[0] = MTL_G_CHECK;
sendBuffer[1] = MT_G_CHECK;
sendBuffer[2] = checkX;
sendBuffer[3] = checkY;
net->send(clientSock[count], sendBuffer);
// Inform the new client of the existing players
sendBuffer[1] = MT_G_PJOIN;
......@@ -377,8 +385,8 @@ int ServerGame::step (unsigned int ticks) {
if (!(net->isConnected(clientSock[count]))) {
printf("Client %d disconnected (code: %d).\n", count,
net->getError());
std::cout << "Client " << count << " disconnected (code: " <<
net->getError() << ").\n";
// Disconnect client
net->close(clientSock[count]);
......@@ -388,8 +396,8 @@ int ServerGame::step (unsigned int ticks) {
// Remove the client's player
printf("Player %d (client %d) left the game.\n",
clientPlayer[count], count);
std::cout << "Player " << clientPlayer[count] <<
" (client " << count << ") left the game.\n";
nPlayers--;
......@@ -475,15 +483,11 @@ void ServerGame::setCheckpoint (unsigned char gridX, unsigned char gridY) {
unsigned char buffer[MTL_G_CHECK];
if (gameMode) {
buffer[0] = MTL_G_CHECK;
buffer[1] = MT_G_CHECK;
buffer[2] = gridX;
buffer[3] = gridY;
send(buffer);
}
buffer[0] = MTL_G_CHECK;
buffer[1] = MT_G_CHECK;
buffer[2] = gridX;
buffer[3] = gridY;
send(buffer);
checkX = gridX;
checkY = gridY;
......
......@@ -23,11 +23,11 @@
#include "file.h"
#include "io/gfx/video.h"
File::File (const char* name, bool write) {
File::File (const char * name, bool write) {
Path *path;
Path* path;
// Try opening the file from all the available directories
......@@ -49,9 +49,11 @@ File::File (const char * name, bool write) {
File::~File () {
fclose(f);
stream.close();
LOG("Closed file", filePath);
#ifdef VERBOSE
log("Closed file", filePath);
#endif
delete[] filePath;
......@@ -60,17 +62,20 @@ File::~File () {
}
bool File::open (const char * path, const char * name, bool write) {
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
f = fopen(filePath, write ? "wb": "rb");
if (f) {
LOG("Opened file", filePath);
// Open the file from the path
stream.clear();
stream.open(filePath, (write ? std::ios::out: std::ios::in) | std::ios::binary);
if (stream.is_open() && stream.good()) {
#ifdef VERBOSE
log("Opened file", filePath);
#endif
return true;
......@@ -87,27 +92,27 @@ int File::getSize () {
int pos, size;
pos = ftell(f);
fseek(f, 0, SEEK_END);
size = ftell(f);
pos = stream.tellg();
stream.seekg(0, std::ios::end);
fseek(f, pos, SEEK_SET);
size = stream.tellg();
stream.seekg(pos, std::ios::beg);
return size;
}
int File::tell () {
return ftell(f);
return stream.tellg();
}
void File::seek (int offset, bool reset) {
fseek(f, offset, reset ? SEEK_SET: SEEK_CUR);
stream.seekg(offset, reset ? std::ios::beg: std::ios::cur);
return;
......@@ -115,14 +120,14 @@ void File::seek (int offset, bool reset) {
unsigned char File::loadChar () {
return fgetc(f);
return stream.get();
}
void File::storeChar (unsigned char val) {
fputc(val, f);
stream.put(val);
return;
......@@ -133,8 +138,8 @@ unsigned short int File::loadShort () {
unsigned short int val;
val = fgetc(f);
val += fgetc(f) << 8;
val = stream.get();
val += stream.get() << 8;
return val;
......@@ -143,8 +148,8 @@ unsigned short int File::loadShort () {
void File::storeShort (unsigned short int val) {
fputc(val & 255, f);
fputc(val >> 8, f);
stream.put(val & 255);
stream.put(val >> 8);
return;
......@@ -155,10 +160,10 @@ signed long int File::loadInt () {
unsigned long int val;
val = fgetc(f);
val += fgetc(f) << 8;
val += fgetc(f) << 16;
val += fgetc(f) << 24;
val = stream.get();
val += stream.get() << 8;
val += stream.get() << 16;
val += stream.get() << 24;
return *((signed long int *)&val);
......@@ -171,38 +176,38 @@ void File::storeInt (signed long int val) {
uval = *((unsigned long int *)&val);
fputc(uval & 255, f);
fputc((uval >> 8) & 255, f);
fputc((uval >> 16) & 255, f);
fputc(uval >> 24, f);
stream.put(uval & 255);
stream.put((uval >> 8) & 255);
stream.put((uval >> 16) & 255);
stream.put(uval >> 24);
return;
}
unsigned char * File::loadBlock (int length) {
unsigned char* File::loadBlock (int length) {
unsigned char *buffer;
buffer = new unsigned char[length];
fread(buffer, 1, length, f);
stream.read((char *)buffer, length);
return buffer;
}
unsigned char * File::loadRLE (int length) {
unsigned char* File::loadRLE (int length) {
unsigned char *buffer;
unsigned char* buffer;
int rle, pos, byte, count, next;
// Determine the offset that follows the block
next = fgetc(f);
next += fgetc(f) << 8;
next += ftell(f);
next = stream.get();
next += stream.get() << 8;
next += stream.tellg();
buffer = new unsigned char[length];
......@@ -210,11 +215,11 @@ unsigned char * File::loadRLE (int length) {
while (pos < length) {
rle = fgetc(f);
rle = stream.get();
if (rle & 128) {
byte = fgetc(f);
byte = stream.get();
for (count = 0; count < (rle & 127); count++) {
......@@ -227,16 +232,16 @@ unsigned char * File::loadRLE (int length) {
for (count = 0; count < rle; count++) {
buffer[pos++] = fgetc(f);
buffer[pos++] = stream.get();
if (pos >= length) break;
}
} else buffer[pos++] = fgetc(f);
} else buffer[pos++] = stream.get();
}
fseek(f, next, SEEK_SET);
stream.seekg(next, std::ios::beg);
return buffer;
......@@ -247,27 +252,27 @@ void File::skipRLE () {
int next;
next = fgetc(f);
next += fgetc(f) << 8;
next = stream.get();
next += stream.get() << 8;
fseek(f, next, SEEK_CUR);
stream.seekg(next, std::ios::cur);
return;
}
char * File::loadString () {
char* File::loadString () {
char *string;
char* string;
int length, count;
length = fgetc(f);
length = stream.get();
if (length) {
string = new char[length + 1];
fread(string, 1, length, f);
stream.read(string, length);
} else {
......@@ -276,13 +281,13 @@ char * File::loadString () {
for (count = 0; count < 9; count++) {
string[count] = fgetc(f);
string[count] = stream.get();
if (string[count] == '.') {
string[++count] = fgetc(f);
string[++count] = fgetc(f);
string[++count] = fgetc(f);
string[++count] = stream.get();
string[++count] = stream.get();
string[++count] = stream.get();
count++;
break;
......@@ -301,10 +306,10 @@ char * File::loadString () {
}
SDL_Surface * File::loadSurface (int width, int height) {
SDL_Surface* File::loadSurface (int width, int height) {
SDL_Surface *surface;
unsigned char *pixels;
SDL_Surface* surface;
unsigned char* pixels;
pixels = loadRLE(width * height);
......@@ -317,9 +322,9 @@ SDL_Surface * File::loadSurface (int width, int height) {
}
void File::loadPalette (SDL_Color *palette) {
void File::loadPalette (SDL_Color* palette) {
unsigned char *buffer;
unsigned char* buffer;
int count;
buffer = loadRLE(768);
......@@ -341,7 +346,7 @@ void File::loadPalette (SDL_Color *palette) {
}
Path::Path (Path *newNext, char *newPath) {
Path::Path (Path* newNext, char* newPath) {
next = newNext;
path = newPath;
......
......@@ -26,22 +26,22 @@
#include "OpenJazz.h"
#include <SDL/SDL.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <fstream>
// Class
// Classes
class File {
private:
FILE *f;
char *filePath;
std::fstream stream;
char* filePath;
bool open (const char * path, const char * name, bool write);
bool open (const char* path, const char* name, bool write);
public:
File (const char * name, bool write);
File (const char* name, bool write);
~File ();
int getSize ();
......@@ -53,11 +53,11 @@ class File {
void storeShort (unsigned short int val);
signed long int loadInt ();
void storeInt (signed long int val);
unsigned char * loadBlock (int length);
unsigned char * loadRLE (int length);
unsigned char* loadBlock (int length);
unsigned char* loadRLE (int length);
void skipRLE ();
char * loadString ();
SDL_Surface * loadSurface (int width, int height);
char* loadString ();
SDL_Surface* loadSurface (int width, int height);
void loadPalette (SDL_Color *palette);
};
......@@ -65,10 +65,10 @@ class File {
class Path {
public:
Path *next;
char *path;
Path* next;
char* path;
Path (Path *newNext, char *newPath);
Path (Path* newNext, char* newPath);
~Path ();
};
......@@ -77,7 +77,7 @@ class Path {
// Variable
// Paths to files
EXTERN Path *firstPath;
EXTERN Path* firstPath;
#endif
......@@ -30,13 +30,14 @@
#include "font.h"
#include "video.h"
#include <string.h>
#include <string.h>
Font::Font (const char * fileName) {
Font::Font (const char* fileName) {
File *file;
unsigned char *pixels, *blank;
File* file;
unsigned char* pixels;
unsigned char* blank;
int fileSize;
int count, size, width, height;
......@@ -70,8 +71,6 @@ Font::Font (const char * fileName) {
// Load characters
for (count = 0; count < 128; count++) {
size = file->loadShort();
if (file->tell() >= fileSize) {
......@@ -81,6 +80,8 @@ Font::Font (const char * fileName) {
}
size = file->loadShort();
if (size) {
pixels = file->loadRLE(size);
......@@ -147,9 +148,9 @@ Font::Font (const char * fileName) {
}
Font::Font (unsigned char *pixels, bool big) {
Font::Font (unsigned char* pixels, bool big) {
unsigned char *chrPixels;
unsigned char* chrPixels;
int count, y;
if (big) lineHeight = 8;
......@@ -207,8 +208,9 @@ Font::Font (unsigned char *pixels, bool big) {
Font::Font () {
File *file;
unsigned char *pixels, *sorted;
File* file;
unsigned char* pixels;
unsigned char* sorted;
int fileSize;
int count, width, height;
......@@ -234,11 +236,6 @@ Font::Font () {
for (count = 0; count < nCharacters; count++) {
width = file->loadShort() << 2;
height = file->loadShort();
file->seek(4, false);
if (file->tell() >= fileSize) {
nCharacters = count;
......@@ -247,6 +244,11 @@ Font::Font () {
}
width = file->loadShort() << 2;
height = file->loadShort();
file->seek(4, false);
pixels = file->loadBlock(width * height);
sorted = sortPixels(pixels, width * height);
......@@ -308,9 +310,9 @@ Font::~Font () {
}
int Font::showString (const char *string, int x, int y) {
int Font::showString (const char* string, int x, int y) {
SDL_Surface *surface;
SDL_Surface* surface;
SDL_Rect dst;
unsigned int count;
int xOffset, yOffset;
......@@ -350,9 +352,9 @@ int Font::showString (const char *string, int x, int y) {
}
int Font::showSceneString (const unsigned char *string, int x, int y) {
int Font::showSceneString (const unsigned char* string, int x, int y) {
SDL_Surface *surface;
SDL_Surface* surface;
SDL_Rect dst;
unsigned int count;
int offset;
......
......@@ -37,10 +37,10 @@
#include "player/player.h"
DemoLevel::DemoLevel (const char *fileName) {
DemoLevel::DemoLevel (const char* fileName) {
File *file;
char *levelFile;
File* file;
char* levelFile;
int lNum, wNum, diff, ret;
gameMode = NULL;
......@@ -101,7 +101,7 @@ int DemoLevel::play () {
ticks = 16;
prevStepTicks = 0;
stats = S_NONE;
stats = 0;
usePalette(palette);
......
......@@ -53,7 +53,7 @@
#include "player/player.h"
#include "scene/scene.h"
#include <string.h>
#include <string.h>
Level::Level () {
......@@ -65,7 +65,7 @@ Level::Level () {
}
Level::Level (char *fileName, unsigned char diff, bool checkpoint) {
Level::Level (char* fileName, unsigned char diff, bool checkpoint) {
int ret;
......@@ -228,7 +228,7 @@ void Level::setTile (unsigned char gridX, unsigned char gridY,
}
signed char * Level::getEvent (unsigned char gridX, unsigned char gridY) {
signed char* Level::getEvent (unsigned char gridX, unsigned char gridY) {
int event = grid[gridY][gridX].event;
......@@ -281,9 +281,9 @@ void Level::clearEvent (unsigned char gridX, unsigned char gridY) {
}
int Level::hitEvent (unsigned char gridX, unsigned char gridY, Player *source) {
int Level::hitEvent (unsigned char gridX, unsigned char gridY, Player* source) {
GridElement *ge;
GridElement* ge;
unsigned char buffer[MTL_L_GRID];
int hitsToKill;
......@@ -341,28 +341,28 @@ void Level::setEventTime (unsigned char gridX, unsigned char gridY,
}
signed char * Level::getBullet (unsigned char bullet) {
signed char* Level::getBullet (unsigned char bullet) {
return bulletSet[bullet];
}
Sprite * Level::getSprite (unsigned char sprite) {
Sprite* Level::getSprite (unsigned char sprite) {
return spriteSet + sprite;
}
Anim * Level::getAnim (unsigned char anim) {
Anim* Level::getAnim (unsigned char anim) {
return animSet + anim;
}
Anim * Level::getMiscAnim (unsigned char anim) {
Anim* Level::getMiscAnim (unsigned char anim) {
return animSet + miscAnims[anim];
......@@ -437,7 +437,7 @@ LevelStage Level::getStage () {
}
Scene * Level::createScene () {
Scene* Level::createScene () {
try {
......@@ -452,7 +452,7 @@ Scene * Level::createScene () {
}
void Level::receive (unsigned char *buffer) {
void Level::receive (unsigned char* buffer) {
// Interpret data received from client/server
......@@ -503,7 +503,7 @@ void Level::receive (unsigned char *buffer) {
int Level::play () {
const char *options[5] =
const char* options[5] =
{"continue game", "save game", "load game", "setup options", "quit game"};
PaletteEffect *levelPE;
char *string;
......@@ -521,7 +521,7 @@ int Level::play () {
pmessage = pmenu = false;
option = 0;
stats = S_NONE;
stats = 0;
returnTime = 0;
timeBonus = -1;
......
......@@ -344,7 +344,7 @@ int Menu::joinGame () {
int ret;
ret = textInput("ip address:", &netAddress);
ret = textInput("ip address:", netAddress);
if (ret < 0) return ret;
......
......@@ -78,7 +78,7 @@ int Menu::main () {
#if (defined USE_SOCKETS) || (defined USE_SDL_NET)
while (true) {
ret = generic(newGameOptions, 6, &suboption);
ret = generic(newGameOptions, 6, suboption);
if (ret == E_QUIT) return E_QUIT;
if (ret < 0) break;
......
......@@ -41,13 +41,13 @@
class Menu {
private:
SDL_Surface *screens[15];
int episodes;
unsigned char difficulty;
SDL_Surface* screens[15];
int episodes;
unsigned char difficulty;
int message (const char *text);
int generic (const char **optionNames, int options, int *chosen);
int textInput (const char *request, char **text);
int message (const char* text);
int generic (const char** optionNames, int options, int& chosen);
int textInput (const char* request, char*& text);
int newGameDifficulty (GameModeType mode, int levelNum, int worldNum);
int newGameLevel (GameModeType mode);
int newGameEpisode (GameModeType mode);
......@@ -75,7 +75,7 @@ class Menu {
// Variable
EXTERN Menu *menu;
EXTERN Menu* menu;
#endif
......@@ -35,7 +35,7 @@
#include <string.h>
int Menu::message (const char *text) {
int Menu::message (const char* text) {
// Display a message to the user
......@@ -62,7 +62,7 @@ int Menu::message (const char *text) {
}
int Menu::generic (const char **optionNames, int options, int *chosen) {
int Menu::generic (const char** optionNames, int options, int& chosen) {
// Let the user select from a menu of the given options
......@@ -70,7 +70,7 @@ int Menu::generic (const char **optionNames, int options, int *chosen) {
usePalette(palettes[1]);
if (*chosen >= options) *chosen = 0;
if (chosen >= options) chosen = 0;
while (true) {
......@@ -84,18 +84,18 @@ int Menu::generic (const char **optionNames, int options, int *chosen) {
for (count = 0; count < options; count++) {
if (count == *chosen) fontmn2->mapPalette(240, 8, 114, 16);
if (count == chosen) fontmn2->mapPalette(240, 8, 114, 16);
fontmn2->showString(optionNames[count], canvasW >> 2,
(canvasH >> 1) + (count << 4) - (options << 3));
if (count == *chosen) fontmn2->restorePalette();
if (count == chosen) fontmn2->restorePalette();
}
if (controls.release(C_UP)) *chosen = (*chosen + options - 1) % options;
if (controls.release(C_UP)) chosen = (chosen + options - 1) % options;
if (controls.release(C_DOWN)) *chosen = (*chosen + 1) % options;
if (controls.release(C_DOWN)) chosen = (chosen + 1) % options;
if (controls.release(C_ENTER)) {
......@@ -112,7 +112,7 @@ int Menu::generic (const char **optionNames, int options, int *chosen) {
}
int Menu::textInput (const char *request, char **text) {
int Menu::textInput (const char* request, char*& text) {
// Let the user to edit a text string
......@@ -121,7 +121,7 @@ int Menu::textInput (const char *request, char **text) {
unsigned int cursor;
// Create input string
input = createEditableString(*text);
input = createEditableString(text);
cursor = strlen(input);
......@@ -218,8 +218,8 @@ int Menu::textInput (const char *request, char **text) {
playSound(S_ORB);
// Replace the original string with the input string
delete[] *text;
*text = input;
delete[] text;
text = input;
return E_NONE;
......
......@@ -511,7 +511,7 @@ int Menu::setup () {
while (true) {
ret = generic(setupOptions, 6, &option);
ret = generic(setupOptions, 6, option);
if (ret == E_UNUSED) return E_NONE;
if (ret < 0) return ret;
......@@ -524,7 +524,7 @@ int Menu::setup () {
while (true) {
ret = generic(setupCharacterOptions, 5, &suboption);
ret = generic(setupCharacterOptions, 5, suboption);
if (ret == E_QUIT) return E_QUIT;
if (ret < 0) break;
......@@ -533,15 +533,14 @@ int Menu::setup () {
case 0: // Character name
textInput("character name:", &characterName);
textInput("character name:", characterName);
break;
default: // Character colour
subsuboption = 0;
ret = generic(setupCharacterColOptions, 8,
&subsuboption);
ret = generic(setupCharacterColOptions, 8, subsuboption);
if (ret == E_QUIT) return E_QUIT;
......
......@@ -24,7 +24,7 @@
#define _SCENE_H
#include <io/file.h>
#include "io/file.h"
#include <SDL/SDL.h>
......@@ -67,7 +67,7 @@ class Font;
class SceneText {
public:
unsigned char *text;
unsigned char* text;
int alignment;
int fontId;
int x;
......@@ -83,17 +83,17 @@ class SceneText {
class ScenePage {
public:
int backgrounds;
int bgIndex[30];
unsigned short int bgX[30];
unsigned short int bgY[30];
int backgrounds;
int bgIndex[30];
unsigned short int bgX[30];
unsigned short int bgY[30];
// Length of the scene in seconds, or if zero = anim complete, or 256 = user interaction
int pageTime;
SceneText texts[100];
int nTexts;
char *musicFile;
int paletteIndex;
int pageTime;
SceneText texts[100];
int nTexts;
char* musicFile;
int paletteIndex;
ScenePage();
~ScenePage();
......@@ -103,11 +103,11 @@ class ScenePage {
class SceneImage {
public:
SceneImage *next;
SDL_Surface *image;
SceneImage* next;
SDL_Surface* image;
int id;
SceneImage (SceneImage *newNext);
SceneImage (SceneImage* newNext);
~SceneImage ();
};
......@@ -119,7 +119,7 @@ class ScenePalette {
SDL_Color palette[256];
int id;
ScenePalette (ScenePalette *newNext);
ScenePalette (ScenePalette* newNext);
~ScenePalette ();
};
......@@ -135,25 +135,25 @@ class SceneFont {
class Scene {
private:
SDL_Surface *background;
SceneImage *images;
ScenePalette *palettes;
SceneFont fonts[5];
int nFonts;
unsigned short int scriptItems;
unsigned short int dataItems;
signed long int *scriptStarts;
signed long int *dataOffsets;
SDL_Surface* background;
SceneImage* images;
ScenePalette* palettes;
SceneFont fonts[5];
int nFonts;
unsigned short int scriptItems;
unsigned short int dataItems;
signed long int* scriptStarts;
signed long int* dataOffsets;
// Scripts all information needed to render script pages, text etc
ScenePage *pages;
ScenePage* pages;
void loadScripts (File *f);
void loadData (File *f);
void loadScripts (File* f);
void loadData (File* f);
void loadAni (File* f, int dataIndex);
public:
Scene (const char * fileName);
Scene (const char* fileName);
~Scene ();
int play ();
......
......@@ -12,7 +12,7 @@
* Part of the OpenJazz project
*
*
* Copyright (c) 2005-2009 Alister Thomson
* Copyright (c) 2005-2010 Alister Thomson
*
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
......@@ -31,14 +31,17 @@
#include "io/file.h"
#include <string.h>
#include <iostream>
#include <string.h>
bool fileExists (const char * fileName) {
File *file;
//printf("Check: ");
#ifdef VERBOSE
std::cout << "Check: ";
#endif
try {
......@@ -151,7 +154,7 @@ char * createEditableString (const char *string) {
void log (const char *message) {
printf("%s\n", message);
std::cout << message << std::endl;
return;
......@@ -160,7 +163,7 @@ void log (const char *message) {
void log (const char *message, const char *detail) {
printf("%s: %s\n", message, detail);
std::cout << message << ": " << detail << std::endl;
return;
......@@ -169,7 +172,7 @@ void log (const char *message, const char *detail) {
void log (const char *message, int number) {
printf("%s: %d\n", message, number);
std::cout << message << ": " << number << std::endl;
return;
......@@ -178,7 +181,7 @@ void log (const char *message, int number) {
void logError (const char *message, const char *detail) {
fprintf(stderr, "%s: %s\n", message, detail);
std::cerr << message << ": " << detail << std::endl;
return;
......
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