DOCS = doc/*
ICONS = icons/
-VERSION = 1.14
+VERSION = 1.17
RELEASE = 1
USEPAK = 1
ICONDIR = $(PREFIX)/share/icons/hicolor/
DESKTOPDIR = $(PREFIX)/share/applications/
LOCALEDIR = $(PREFIX)/share/locale/
+MEDAL_SERVER_HOST = www.parallelrealities.co.uk
+#MEDAL_SERVER_HOST = localhost
+MEDAL_SERVER_PORT = 80
CXXFLAGS += `sdl-config --cflags` -DVERSION=$(VERSION) -DRELEASE=$(RELEASE) -DUSEPAK=$(USEPAK)
CXXFLAGS += -DPAKNAME=\"$(PAKNAME)\" -DPAKLOCATION=\"$(DATADIR)\" -DUNIX -DGAMEPLAYMANUAL=\"$(DOCDIR)index.html\" -Wall
-CXXFLAGS += -DLOCALEDIR=\"$(LOCALEDIR)\"
+CXXFLAGS += -DLOCALEDIR=\"$(LOCALEDIR)\" -DMEDAL_SERVER_HOST=\"$(MEDAL_SERVER_HOST)\" -DMEDAL_SERVER_PORT=$(MEDAL_SERVER_PORT)
CXXFLAGS += $(CFLAGS) -Werror
-LIBS = `sdl-config --libs` -lSDL_mixer -lSDL_image -lSDL_ttf -lz
+LIBS = `sdl-config --libs` -lSDL_mixer -lSDL_image -lSDL_ttf -lSDL_net -lz
OBJS += CAudio.o
OBJS += CBoss.o
OBJS += CJoystick.o
OBJS += CLineDef.o
OBJS += CList.o
-OBJS += CMap.o CMath.o
+OBJS += CMap.o CMath.o CMedalServer.o
OBJS += CObjective.o
OBJS += CPak.o CParticle.o CPersistant.o CPersistData.o
OBJS += CRadarBlip.o CReplayData.o
clean:
$(RM) $(GAMEOBJS) mapEditor.o pak.o $(PROG) $(PAKNAME) pak mapeditor $(LOCALE_MO)
-buildpak: pak
+buildpak:
./pak data gfx music sound $(PAKNAME)
# install
DOCS = doc/*
ICONS = icons/
-VERSION = 1.14
+VERSION = 1.17
RELEASE = 1
USEPAK = 1
ICONDIR = $(PREFIX)/share/icons/hicolor/
DESKTOPDIR = $(PREFIX)/share/applications/
LOCALEDIR = $(PREFIX)/share/locale/
+MEDAL_SERVER_HOST = www.parallelrealities.co.uk
+MEDAL_SERVER_PORT = 80
CXX=i586-mingw32msvc-g++
SDLC=/home/steve/Windows/bin/sdl-config
CXXFLAGS += `$(SDLC) --cflags` -DVERSION=$(VERSION) -DRELEASE=$(RELEASE) -DUSEPAK=$(USEPAK)
CXXFLAGS += -DPAKNAME=\"$(PAKNAME)\" -DPAKLOCATION=\"\" -DGAMEPLAYMANUAL=\"doc/index.html\" -Wall
-CXXFLAGS += -DLOCALEDIR=\"\" $(CFLAGS) -pg -Werror
-LIBS = `$(SDLC) --libs` -lintl -lz -lSDL_mixer -lSDL_image -lSDL_ttf -pg -lSDLmain
+CXXFLAGS += -DLOCALEDIR=\"\" $(CFLAGS) -DMEDAL_SERVER_HOST=\"$(MEDAL_SERVER_HOST)\" -DMEDAL_SERVER_PORT=$(MEDAL_SERVER_PORT) -pg -Werror
+LIBS = `$(SDLC) --libs` -lintl -lz -lSDL_mixer -lSDL_image -lSDL_ttf -lSDL_net -pg -lSDLmain
OBJS += CAudio.o
OBJS += CBoss.o
OBJS += CJoystick.o
OBJS += CLineDef.o
OBJS += CList.o
-OBJS += CMap.o CMath.o
+OBJS += CMap.o CMath.o CMedalServer.o
OBJS += CObjective.o
OBJS += CPak.o CParticle.o CPersistant.o CPersistData.o
OBJS += CRadarBlip.o CReplayData.o
-#include "headers.h"
-
-Config::Config()
-{
- sdlJoystick = NULL;
-
- for (int i = 0 ; i < CONTROL::MAX ; i++)
- {
- command[i] = 0;
- }
-}
-
-Config::~Config()
-{
-}
-
-void Config::populate()
-{
- for (int i = 0 ; i < CONTROL::MAX ; i++)
- {
- command[i] = (engine->keyState[keyboard.control[i]]);
-
- if (joystick.control[i] >= 0)
- {
- command[i] = (command[i] || (engine->joystickState[joystick.control[i]]));
- }
- }
-
- if (engine->joyX < -joystick.sensitivity) command[CONTROL::LEFT] = 1;
- if (engine->joyX > joystick.sensitivity) command[CONTROL::RIGHT] = 1;
- if (engine->joyY < -joystick.sensitivity) command[CONTROL::UP] = 1;
- if (engine->joyY > joystick.sensitivity) command[CONTROL::DOWN] = 1;
-}
-
-void Config::populate(int *data)
-{
- for (int i = 0 ; i < CONTROL::MAX ; i++)
- {
- command[i] = data[i];
- }
-
- command[CONTROL::MAP] = 0;
- command[CONTROL::PAUSE] = 0;
-}
-
-bool Config::isControl(CONTROL::TYPE type)
-{
- return command[type];
-}
-
-void Config::resetControl(CONTROL::TYPE type)
-{
- engine->keyState[keyboard.control[type]] = 0;
-
- command[type] = 0;
-
- if (joystick.control[type] >= 0)
- {
- engine->joystickState[joystick.control[type]] = 0;
- }
-
- if (type == CONTROL::LEFT) engine->joyX = 0;
- if (type == CONTROL::RIGHT) engine->joyX = 0;
- if (type == CONTROL::UP) engine->joyY = 0;
- if (type == CONTROL::DOWN) engine->joyY = 0;
-}
-
-void Config::doPause()
-{
- if (!engine->paused)
- {
- if (engine->keyState[keyboard.control[CONTROL::PAUSE]])
- {
- engine->paused = true;
- engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;
- }
- }
- else
- {
- if ((engine->keyState[keyboard.control[CONTROL::PAUSE]]) || (engine->keyState[SDLK_ESCAPE]))
- {
- engine->paused = false;
- engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;
- engine->keyState[SDLK_ESCAPE] = 0;
- }
- }
-}
-
-bool Config::loadJoystickConfig()
-{
- char filename[PATH_MAX];
- sprintf(filename, "%sjoystick.cfg", engine->userHomeDirectory);
-
- debug(("Loading joystick config from %s\n", filename));
-
- FILE *fp = fopen(filename, "rb");
-
- if (!fp)
- {
- return false;
- }
-
- if (fread(&joystick, sizeof(Joystick), 1, fp) != 1)
- {
- fclose(fp);
- return false;
- }
-
- fclose(fp);
-
- return true;
-}
-
-bool Config::saveJoystickConfig()
-{
- char filename[PATH_MAX];
- sprintf(filename, "%sjoystick.cfg", engine->userHomeDirectory);
-
- debug(("Saving joystick config to %s\n", filename));
-
- FILE *fp = fopen(filename, "wb");
-
- if (!fp)
- {
- debug(("WARNING: Couldn't save joystick config\n"));
- return false;
- }
-
- fwrite(&joystick, sizeof(Joystick), 1, fp);
-
- fclose(fp);
-
- return true;
-}
-
-bool Config::loadKeyConfig()
-{
- char filename[PATH_MAX];
- sprintf(filename, "%skeyboard.cfg", engine->userHomeDirectory);
-
- debug(("Loading keyboard config from %s\n", filename));
-
- FILE *fp = fopen(filename, "rb");
-
- if (!fp)
- {
- return false;
- }
-
- if (fread(&keyboard, sizeof(Keyboard), 1, fp) != 1)
- {
- fclose(fp);
- return false;
- }
-
- for (int i = 0; i < CONTROL::MAX; i++)
- {
- if (keyboard.control[i] < 0 || keyboard.control[i] >= 350)
- {
- fclose(fp);
- return false;
- }
- }
-
- fclose(fp);
-
- // Keyboard break fix - Feb 09
- keyboard.control[CONTROL::UP] = 0;
-
- return true;
-}
-
-bool Config::saveKeyConfig()
-{
- char filename[PATH_MAX];
- sprintf(filename, "%skeyboard.cfg", engine->userHomeDirectory);
-
- debug(("Saving keyboard config to %s\n", filename));
-
- FILE *fp = fopen(filename, "wb");
-
- if (!fp)
- {
- return false;
- }
-
- fwrite(&keyboard, sizeof(keyboard), 1, fp);
-
- fclose(fp);
-
- return true;
-}
-
-void Config::restoreKeyDefaults()
-{
- keyboard.setDefaultKeys();
-}
+#include "headers.h"\r
+\r
+Config::Config()\r
+{\r
+ sdlJoystick = NULL;\r
+ \r
+ for (int i = 0 ; i < CONTROL::MAX ; i++)\r
+ {\r
+ command[i] = 0;\r
+ }\r
+}\r
+\r
+Config::~Config()\r
+{\r
+}\r
+\r
+void Config::populate()\r
+{\r
+ for (int i = 0 ; i < CONTROL::MAX ; i++)\r
+ {\r
+ command[i] = (engine->keyState[keyboard.control[i]]); \r
+ \r
+ if (joystick.control[i] >= 0)\r
+ {\r
+ command[i] = (command[i] || (engine->joystickState[joystick.control[i]]));\r
+ }\r
+ }\r
+ \r
+ if (engine->joyX < -joystick.sensitivity) command[CONTROL::LEFT] = 1;\r
+ if (engine->joyX > joystick.sensitivity) command[CONTROL::RIGHT] = 1;\r
+ if (engine->joyY < -joystick.sensitivity) command[CONTROL::UP] = 1;\r
+ if (engine->joyY > joystick.sensitivity) command[CONTROL::DOWN] = 1;\r
+}\r
+\r
+void Config::populate(int *data)\r
+{\r
+ for (int i = 0 ; i < CONTROL::MAX ; i++)\r
+ {\r
+ command[i] = data[i];\r
+ }\r
+ \r
+ command[CONTROL::MAP] = 0;\r
+ command[CONTROL::PAUSE] = 0;\r
+}\r
+\r
+bool Config::isControl(CONTROL::TYPE type)\r
+{\r
+ return command[type];\r
+}\r
+\r
+void Config::resetControl(CONTROL::TYPE type)\r
+{\r
+ engine->keyState[keyboard.control[type]] = 0;\r
+ \r
+ command[type] = 0;\r
+ \r
+ if (joystick.control[type] >= 0)\r
+ {\r
+ engine->joystickState[joystick.control[type]] = 0;\r
+ }\r
+ \r
+ if (type == CONTROL::LEFT) engine->joyX = 0;\r
+ if (type == CONTROL::RIGHT) engine->joyX = 0;\r
+ if (type == CONTROL::UP) engine->joyY = 0;\r
+ if (type == CONTROL::DOWN) engine->joyY = 0;\r
+}\r
+\r
+void Config::doPause()\r
+{\r
+ if (!engine->paused)\r
+ {\r
+ if (engine->keyState[keyboard.control[CONTROL::PAUSE]])\r
+ {\r
+ engine->paused = true;\r
+ engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if ((engine->keyState[keyboard.control[CONTROL::PAUSE]]) || (engine->keyState[SDLK_ESCAPE]))\r
+ {\r
+ engine->paused = false;\r
+ engine->keyState[keyboard.control[CONTROL::PAUSE]] = 0;\r
+ engine->keyState[SDLK_ESCAPE] = 0;\r
+ }\r
+ }\r
+}\r
+\r
+bool Config::loadJoystickConfig()\r
+{\r
+ char filename[PATH_MAX];\r
+ sprintf(filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
+ \r
+ debug(("Loading joystick config from %s\n", filename));\r
+ \r
+ FILE *fp = fopen(filename, "rb");\r
+ \r
+ if (!fp)\r
+ {\r
+ return false;\r
+ }\r
+ \r
+ if (fread(&joystick, sizeof(Joystick), 1, fp) != 1)\r
+ {\r
+ fclose(fp);\r
+ return false;\r
+ }\r
+ \r
+ fclose(fp);\r
+ \r
+ return true;\r
+}\r
+\r
+bool Config::saveJoystickConfig()\r
+{\r
+ char filename[PATH_MAX];\r
+ sprintf(filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
+ \r
+ debug(("Saving joystick config to %s\n", filename));\r
+ \r
+ FILE *fp = fopen(filename, "wb");\r
+ \r
+ if (!fp)\r
+ {\r
+ debug(("WARNING: Couldn't save joystick config\n"));\r
+ return false;\r
+ }\r
+ \r
+ fwrite(&joystick, sizeof(Joystick), 1, fp);\r
+ \r
+ fclose(fp);\r
+ \r
+ return true;\r
+}\r
+\r
+bool Config::loadKeyConfig()\r
+{\r
+ char filename[PATH_MAX];\r
+ sprintf(filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
+ \r
+ debug(("Loading keyboard config from %s\n", filename));\r
+ \r
+ FILE *fp = fopen(filename, "rb");\r
+ \r
+ if (!fp)\r
+ {\r
+ return false;\r
+ }\r
+ \r
+ if (fread(&keyboard, sizeof(Keyboard), 1, fp) != 1)\r
+ {\r
+ fclose(fp);\r
+ return false;\r
+ }\r
+ \r
+ fclose(fp);\r
+ \r
+ // Keyboard break fix - Feb 09\r
+ keyboard.control[CONTROL::UP] = 0;\r
+ \r
+ return true;\r
+}\r
+\r
+bool Config::saveKeyConfig()\r
+{\r
+ char filename[PATH_MAX];\r
+ sprintf(filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
+ \r
+ debug(("Saving keyboard config to %s\n", filename));\r
+ \r
+ FILE *fp = fopen(filename, "wb");\r
+ \r
+ if (!fp)\r
+ {\r
+ return false;\r
+ }\r
+ \r
+ fwrite(&keyboard, sizeof(keyboard), 1, fp);\r
+ \r
+ fclose(fp);\r
+ \r
+ return true;\r
+}\r
+\r
+void Config::restoreKeyDefaults()\r
+{\r
+ keyboard.setDefaultKeys();\r
+}\r
-class Config
-{
- public:
-
- Engine *engine;
-
- int command[CONTROL::MAX];
-
- SDL_Joystick *sdlJoystick;
-
- Joystick joystick;
- Keyboard keyboard;
-
- Config();
- ~Config();
-
- void populate();
- void populate(int *data);
-
- bool isControl(CONTROL::TYPE type);
- void resetControl(CONTROL::TYPE type);
-
- void doPause();
-
- bool loadJoystickConfig();
- bool saveJoystickConfig();
- bool loadKeyConfig();
- bool saveKeyConfig();
- void restoreKeyDefaults();
-};
+class Config\r
+{\r
+ public:\r
+ \r
+ Engine *engine;\r
+\r
+ int command[CONTROL::MAX];\r
+ \r
+ SDL_Joystick *sdlJoystick;\r
+ \r
+ Joystick joystick;\r
+ Keyboard keyboard;\r
+\r
+ Config();\r
+ ~Config();\r
+ \r
+ void populate();\r
+ void populate(int *data);\r
+ \r
+ bool isControl(CONTROL::TYPE type);\r
+ void resetControl(CONTROL::TYPE type);\r
+ \r
+ void doPause();\r
+ \r
+ bool loadJoystickConfig();\r
+ bool saveJoystickConfig();\r
+ bool loadKeyConfig();\r
+ bool saveKeyConfig();\r
+ void restoreKeyDefaults();\r
+};\r
// Cheats
memset(lastKeyEvents, ' ', 25);
+ #if USEPAK
+ cheats = false;
+ #else
+ cheats = true;
+ #endif
cheatHealth = cheatExtras = cheatFuel = cheatLevels = false;
cheatBlood = cheatInvulnerable = cheatReload = cheatSpeed = cheatSkipLevel = false;
infoMessage = NULL;
fontSize = 0;
+
+ medalMessageTimer = 0;
+ medalType = 0;
currentLoading = 0;
TTF_CloseFont(font[i]);
}
}
-
+
+ if (medalMessage != NULL)
+ {
+ SDL_FreeSurface(medalMessage);
+ }
if (fadeBlack)
{
{
SDL_FreeSurface(infoBar);
}
+
+ for (int i = 0 ; i < 4 ; i++)
+ {
+ if (medal[i] != NULL)
+ {
+ SDL_FreeSurface(medal[i]);
+ medal[i] = NULL;
+ }
+ }
}
void Graphics::registerEngine(Engine *engine)
fadeBlack = alphaRect(640, 480, 0x00, 0x00, 0x00);
infoBar = alphaRect(640, 25, 0x00, 0x00, 0x00);
+
+ medalMessage = NULL;
}
Sprite *Graphics::getSpriteHead()
SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(sprite->format, 0, 0, 0));
}
+bool Graphics::canShowMedalMessage()
+{
+ return (medalMessageTimer <= 0);
+}
+
void Graphics::updateScreen()
{
+ if (medalMessageTimer > 0)
+ {
+ int padding = 0;
+
+ medalMessageTimer--;
+
+ if (medalType >= 0)
+ {
+ padding = 18;
+ }
+
+ drawRect(screen->w - (medalMessage->w + 5 + padding), 5, medalMessage->w + padding - 2, 20, grey, screen);
+ drawRect(screen->w - (medalMessage->w + 5 + padding - 1), 6, medalMessage->w + padding - 4, 18, black, screen);
+ blit(medalMessage, screen->w - (medalMessage->w + 5), 7, screen, false);
+
+ if (medalType >= 0)
+ {
+ blit(medal[medalType], screen->w - (medalMessage->w + 5 + 16), 7, screen, false);
+ }
+ }
+
SDL_Flip(screen);
SDL_Delay(1);
}
}
+void Graphics::showMedalMessage(int type, const char *in)
+{
+ char message[1024];
+
+ if (medalMessage != NULL)
+ {
+ SDL_FreeSurface(medalMessage);
+ }
+
+ setFontSize(0);
+
+ switch (type)
+ {
+ // Bronze
+ case 1:
+ setFontColor(0xA6, 0x7D, 0x3D, 0x00, 0x00, 0x00);
+ break;
+
+ // Silver
+ case 2:
+ setFontColor(0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00);
+ break;
+
+ // Gold
+ case 3:
+ setFontColor(0xFF, 0xCC, 0x33, 0x00, 0x00, 0x00);
+ break;
+
+ // Ruby
+ case 4:
+ setFontColor(0xFF, 0x11, 0x55, 0x00, 0x00, 0x00);
+ break;
+ }
+
+ medalType = type - 1; // for indexing on the image
+ if (type != -1)
+ {
+ sprintf(message, " Medal Earned - %s ", in);
+ medalMessage = getString(message, true);
+ }
+ else
+ {
+ sprintf(message, " %s ", in);
+ medalMessage = getString(message, true);
+ }
+ medalMessageTimer = (5 * 60);
+}
+
void Graphics::drawWidgetRect(int x, int y, int w, int h)
{
drawRect(x - 5, y - 4, w + 10, h + 8, white, screen);
int screenShotNumber;
char screenshot[100];
char chatString[1024];
+
+ SDL_Surface *medalMessage;
+ int medalMessageTimer;
+ int medalType;
SDL_Surface *fadeBlack;
SDL_Surface *infoMessage;
SDL_Surface *screen, *background;
SDL_Surface *tile[MAX_TILES];
+ SDL_Surface *medal[4];
+
SDL_Surface *infoBar;
int red, yellow, green, darkGreen, skyBlue, blue, cyan, white, lightGrey, grey, darkGrey, black;
Sprite *getSpriteHead();
void setTransparent(SDL_Surface *sprite);
void updateScreen();
+ bool canShowMedalMessage();
void delay(int time);
void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v);
void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v);
void drawString(const char *in, int x, int y, int alignment, SDL_Surface *dest);
void clearChatString();
void createChatString(const char *in);
+ void showMedalMessage(int type, const char *in);
void drawChatString(SDL_Surface *surface, int y);
void drawWidgetRect(int x, int y, int w, int h);
SDL_Surface *createSurface(int width, int height);
{
owner->reload = 4;
}
+
+ if (game.bulletsFired[game.currentWeapon] == 10000)
+ {
+ presentPlayerMedal("10000_Bullets");
+ }
}
}
extern void checkSwitchContact(Entity *ent);
extern void throwBrickParticles(float x, float y);
extern void throwStalagParticles(float x, float y);
+extern void presentPlayerMedal(const char *tname);
extern Audio audio;
extern Engine engine;
#ifndef GAMEPLAYMANUAL
#define GAMEPLAYMANUAL "manual.html"
#endif
+#ifndef MEDAL_SERVER_HOST
+ #define MEDAL_SERVER_HOST "localhost"
+#endif
+#ifndef MEDAL_SERVER_PORT
+ #define MEDAL_SERVER_PORT 80
+#endif
enum {
/* ############# debug ################## */
-#if DEBUG
- #define debug(x) {printf("*** DEBUG: "); printf x;}
-#else
+#if USEPAK
#define debug(x) {}
+#else
+ #define debug(x) {printf("*** DEBUG: "); printf x;}
#endif
#ifndef IGNORE_FLAGTOKEN_ERRORS
// Don't enter areas you're not supposed to
if (enemy->tx != (int)enemy->x)
{
- if (!(enemy->flags & ENT_FLIES))
+ if (!(enemy->flags & (ENT_FLIES|ENT_SWIMS)))
{
- //if ((map.data[x][y] == MAP_AIR) || (map.data[x][y] >= MAP_DECORATION))
if (!map.isSolid(x, y))
{
enemy->tx = (int)enemy->x;
lookForPlayer(enemy);
}
+void checkCombo()
+{
+ int old = game.currentComboHits;
+
+ game.doCombo();
+
+ if (old == 24 && game.currentComboHits == 25)
+ {
+ presentPlayerMedal("25_Hit_Combo");
+ }
+}
+
void enemyBulletCollisions(Entity *bullet)
{
if (bullet->health < 1)
{
if (bullet->owner == &player)
{
- game.score += enemy->value;
+ addPlayerScore(enemy->value);
game.currentMissionEnemiesDefeated++;
if (player.currentWeapon != &weapon[WP_LASER])
{
- game.doCombo();
+ checkCombo();
}
checkObjectives(comboString, false);
{
if (player.currentWeapon != &weapon[WP_LASER])
{
- game.doCombo();
+ checkCombo();
checkObjectives(comboString, false);
}
}
extern void checkObjectives(const char *name, bool alwaysInform);
extern Weapon *getWeaponByName(const char *name);
extern void addFireTrailParticle(float x, float y);
+extern void addPlayerScore(int score);
+extern void presentPlayerMedal(const char *tname);
extern void doGaldovAI(Entity *galdov);
extern void addTeleportParticles(float x, float y, int amount, int soundToPlay);
if (owner == &player)
{
- game.score += enemy->value;
+ addPlayerScore(enemy->value);
}
}
extern void addSmokeAndFire(Entity *ent, float dx, float dy, int amount);
extern void addBlood(Entity *ent, float dx, float dy, int amount);
extern void gibPlayer();
+extern void addPlayerScore(int score);
extern Audio audio;
extern Engine engine;
self->react = NULL;
Math::removeBit(&self->flags, ENT_FLIES);
Math::removeBit(&self->flags, ENT_FIRETRAIL);
+ presentPlayerMedal("Final_Battle");
}
self->setActionFinished(1);
extern Weapon *getRandomAimedWeapon();
extern void dropItems(int x, int y);
extern void addItem(int itemType, const char *name, int x, int y, const char *spriteName, int health, int value, int flags, bool randomMovement);
+extern void presentPlayerMedal(const char *tname);
extern Audio audio;
extern Engine engine;
}
SDL_Surface *gameover = graphics.quickSprite("Game Over", graphics.loadImage("gfx/main/gameover.png"));
+ graphics.setTransparent(gameover);
audio.loadGameOverMusic();
audio.playMusic();
Uint32 then, frames, frameLimit, millis, frameCounter;
- #if DEBUG
+ #if !USEPAK
Uint32 now;
char fps[10];
strcpy(fps, "fps");
{
player.health = -99;
+ //#if USEPAK
if ((!map.isBossMission) && (replayData.replayMode == REPLAY_MODE::NONE))
{
showMissionInformation();
}
+ //#endif
game.levelsStarted++;
}
if ((engine.keyState[SDLK_F3]) && (engine.cheatSkipLevel))
{
autoCompleteAllObjectives(true);
+ engine.keyState[SDLK_F3] = 0;
engine.setInfoMessage("Skipping Mission...", 2, INFO_OBJECTIVE);
}
- #if DEBUG
+ #if !USEPAK
if (engine.keyState[SDLK_F1])
{
autoCompleteAllObjectives(false);
if (game.missionOverReason == MIS_GAMECOMPLETE)
frameLimit = SDL_GetTicks() + 64;
- #if DEBUG
+ #if !USEPAK
graphics.drawString(fps, 600, 30, true, graphics.screen);
if (SDL_GetTicks() > frameCounter + 500)
extern void clearAllMissionData();
extern void saveGame();
+extern void presentPlayerMedal(const char *tname);
+
extern Audio audio;
extern Config config;
extern Engine engine;
#include "SDL/SDL_image.h"
#include "SDL/SDL_mixer.h"
#include "SDL/SDL_ttf.h"
+#include "SDL/SDL_net.h"
#endif
#include <libintl.h>
#include "CReplayDataHeader.h"
#include "CReplayData.h"
#include "CConfig.h"
+#include "CMedalServer.h"
bool requirementMet(const char *requiredLevel)
{
- if (engine.cheatLevels)
- {
- return true;
- }
-
- if (strcmp(requiredLevel, "@none@") == 0)
- {
- return true;
- }
-
if (strstr(requiredLevel, "Stages"))
{
int stages = 0;
if (game.stagesCleared >= stages)
{
+ presentPlayerMedal(requiredLevel);
return true;
}
}
+
+ if (engine.cheatLevels)
+ {
+ return true;
+ }
+
+ if (strcmp(requiredLevel, "@none@") == 0)
+ {
+ return true;
+ }
return gameData.requiredLevelCleared(requiredLevel);
}
graphics.loadBackground("gfx/main/worldMap.jpg");
audio.loadMusic("music/forAFriend.mod");
+ // we might want this now, for medals
+ audio.loadSound(SND_ITEM, "sound/item.wav");
+
graphics.quickSprite("cheatHeader", graphics.loadImage("gfx/main/cheats.png"));
graphics.quickSprite("optionsHeader", graphics.loadImage("gfx/main/options.png"));
graphics.quickSprite("keyHeader", graphics.loadImage("gfx/main/keyConfig.png"));
char name[50], level[50], requiredLevel[50];
int x, y;
- #if DEBUG
+ #if !USEPAK
char pos[50];
#endif
hubList.clear();
return SECTION_EASYOVER;
}
+
+ presentPlayerMedal("World_Complete");
}
audio.playMusic();
graphics.drawRect(10, 430, 620, 40, graphics.black, graphics.white, graphics.screen);
- #if DEBUG
+ #if !USEPAK
sprintf(pos, "%.3d:%.3d", engine.getMouseX(), engine.getMouseY());
graphics.drawString(pos, 320, 15, true, graphics.screen);
#endif
#include "headers.h"
extern void showOptions();
+extern void presentPlayerMedal(const char *tname);
extern Audio audio;
extern Config config;
graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
+ //#if !USEPAK
sprintf(string, _("Position = %d:%d"), (int)player.x, (int)player.y);
graphics.drawString(string, 5, 25, false, graphics.screen);
+ //#endif
graphics.drawString(_("*** PAUSED ***"), 320, y, TXT_CENTERED, graphics.screen);
debug(("Output Type = %d\n", game.output));
}
+//
+// see if we can load the private keyState
+//
+int initMedalService(void *data)
+{
+ SDL_mutexP(medalServer.lock);
+
+ char connectMessage[1024];
+ sprintf(connectMessage, "Contacting Medal Server - %s:%d", MEDAL_SERVER_HOST, MEDAL_SERVER_PORT);
+
+ graphics.showMedalMessage(-1, connectMessage);
+
+ char keyPath[PATH_MAX];
+ char privateKey[20];
+
+ sprintf(keyPath, "%smedalKey", engine.userHomeDirectory);
+
+ debug(("Loading private key from %s\n", keyPath));
+
+ FILE *fp = fopen(keyPath, "rb");
+
+ if (!fp)
+ {
+ graphics.showMedalMessage(-1, "No Medal Key found - Online functions disabled");
+ SDL_mutexV(medalServer.lock);
+ return 0;
+ }
+
+ fscanf(fp, "%s", privateKey);
+
+ fclose(fp);
+
+ if (!medalServer.connect(privateKey))
+ {
+ graphics.showMedalMessage(-1, "Medal Server Connection Failed - Online functions disabled");
+ return 0;
+ }
+
+ graphics.showMedalMessage(-1, "Connected to Medal Server");
+
+ SDL_mutexV(medalServer.lock);
+
+ return 1;
+}
+
/*
Chugg chugg chugg.... brrr... chugg chugg chugg...brrrrrr... chugg ch..
BRRRRRRRRRRRRRRRRRMMMMMMMMMMMMMMMMMMM!! Well, hopefully anyway! ;)
{
if (Mix_OpenAudio(22050, AUDIO_S16, engine.useAudio, 1024) < 0)
{
- printf("Warning: Couldn't set 22050 Hz 16-bit audio - Reason: %s\n", Mix_GetError());
+ printf("Warning: Couldn't set 44100 Hz 16-bit audio - Reason: %s\n", Mix_GetError());
printf("Sound and Music will be disabled\n");
engine.useAudio = 0;
}
audio.loadSound(SND_CHEAT, "sound/Lock And Load!!!");
audio.loadSound(SND_HIGHLIGHT, "sound/menu.wav");
audio.loadSound(SND_SELECT, "sound/select.wav");
+
+ graphics.medal[0] = graphics.loadImage("gfx/main/medal_bronze_1.png");
+ graphics.medal[1] = graphics.loadImage("gfx/main/award_star_silver_3.png");
+ graphics.medal[2] = graphics.loadImage("gfx/main/shield.png");
+ graphics.medal[3] = graphics.loadImage("gfx/main/ruby.png");
SDL_Surface *device = graphics.loadImage("gfx/main/alienDevice.png");
checkForLicense();
}
+ if (SDLNet_Init() < 0)
+ {
+ printf("SDLNet_Init: %s\n", SDLNet_GetError());
+ }
+ else
+ {
+ SDL_Thread *thread = SDL_CreateThread(initMedalService, NULL);
+
+ if (thread == NULL)
+ {
+ printf("Unable to create thread: %s\n", SDL_GetError());
+ printf("Calling medal server directly\n");
+ initMedalService(NULL);
+ return;
+ }
+ }
+
engine.saveConfig = true;
debug(("Init Complete...\n"));
debug(("Closing TTF...\n"));
TTF_Quit();
+
+ debug(("Closing NET...\n"));
+ SDLNet_Quit();
debug(("Closing SDL Sub System...\n"));
SDL_Quit();
#endif
#include <time.h>
#include "headers.h"
+#include "SDL_thread.h"
extern SDL_Surface *loadImage(const char *filename);
extern Graphics graphics;
extern Map map;
extern ReplayData replayData;
+extern MedalServer medalServer;
case ITEM_POINTS5:
case ITEM_POINTS6:
case ITEM_POINTS7:
- game.score += item->value;
+ addPlayerScore(item->value);
audio.playSound(SND_ITEM, CH_ITEM);
break;
case ITEM_CHERRY:
engine.setInfoMessage(string, 0, INFO_NORMAL);
checkObjectives(item->name, true);
+
+ if (strcmp(item->name, "LRTS") == 0)
+ {
+ presentPlayerMedal("LRTS_PART");
+ }
}
}
extern void moveEntity(Entity *ent);
extern void checkObjectives(const char *name, bool alwaysInform);
extern void addTeleportParticles(float x, float y, int amount, int soundToPlay);
+extern void addPlayerScore(int score);
+extern void presentPlayerMedal(const char *tname);
extern Audio audio;
extern Engine engine;
if ((absX < 800) && (absY < 600))
{
- #if DEBUG
+ #if !USEPAK
graphics.drawRect(x, y, lineDef->width, lineDef->height, graphics.red, graphics.screen);
#endif
return;
graphics.setFontSize(1);
+ graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
sprintf(message, _("Saving Game to Save Slot #%d. Please Wait..."), slot + 1);
graphics.drawString(message, 320, 220, true, graphics.screen);
graphics.updateScreen();
printf("Blob Wars, Episode I - Metal Blob Solid (Version %.2f, Release %d)\n", VERSION, RELEASE);
printf("Copyright (C) 2004 Parallel Realities\n");
printf("Licensed under the GNU General Public License (GPL)\n\n");
- exit(0);
+// exit(0);
}
int main(int argc, char *argv[])
else if (strcmp(argv[i], "-map") == 0) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}
else if (strcmp(argv[i], "-listmaps") == 0) listMaps();
- #if DEBUG
+ #if !USEPAK
else if (strcmp(argv[i], "-showsprites") == 0) showSprites = true;
else if (strcmp(argv[i], "-hub") == 0) hub = true;
else if (strcmp(argv[i], "-randomscreens") == 0) graphics.takeRandomScreenShots = true;
extern void checkStartCutscene();
extern void easyGameFinished();
+extern void presentPlayerMedal(const char *tname);
+
Audio audio;
Config config;
Engine engine;
Graphics graphics;
Map map;
ReplayData replayData;
+MedalServer medalServer;
Entity defEnemy[MAX_ENEMIES];
Entity defItem[MAX_ITEMS];
{
graphics.blit(graphics.tile[brick], r.x, r.y, graphics.screen, false);
- #if DEBUG
+ #if !USEPAK
if ((brick >= MAP_NORESET) && (brick < MAP_DECORATION))
{
graphics.drawRect(r.x, r.y, 32, 4, graphics.yellow, graphics.screen);
else if (strcmp("AMBIENCE", mapEntity) == 0)
{
sscanf(token, "%*s %*s %s", string[0]);
- audio.loadSound(SND_AMBIANCE, string[0]);
+ if (!audio.loadSound(SND_AMBIANCE, string[0]))
+ graphics.showErrorAndExit(ERR_FILE, string[0]);
}
else if (strcmp("WATERLEVEL", mapEntity) == 0)
{
#include "mapEditor.h"
-Config config;
-ReplayData replayData;
-
void drawMap(int mapX, int mapY)
{
SDL_Rect r;
exit(1);
}
- config.engine = &engine;
-
- replayData.reset();
-
atexit(cleanup);
engine.useAudio = 0;
{
engine.getInput();
config.populate();
- config.doPause();
+ engine.doPause();
engine.doFrameLoop();
graphics.updateScreen();
sprintf(message, _("Rescue %d MIAs - Objective Complete - Checkpoint Reached!"), map.requiredMIAs);
game.setObjectiveCheckPoint();
}
+
+ // MIA Medals
+ if (game.totalMIAsRescued == 50)
+ {
+ presentPlayerMedal("50_MIA");
+ }
+ else if (game.totalMIAsRescued == 100)
+ {
+ presentPlayerMedal("100_MIA");
+ }
+ else if (game.totalMIAsRescued == 200)
+ {
+ presentPlayerMedal("200_MIA");
+ }
+ else if (game.totalMIAsRescued == 227)
+ {
+ presentPlayerMedal("ALL_MIA");
+ }
engine.setInfoMessage(message, 1, INFO_OBJECTIVE);
}
extern Entity player;
extern void moveEntity(Entity *ent);
+extern void presentPlayerMedal(const char *tname);
if (!gameData.stagePreviouslyCleared(game.stageName))
{
+ presentPlayerMedal(game.stageName);
game.stagesCleared++;
}
}
game.totalUpStats();
+
+ if (game.totalEnemiesDefeated >= 1000)
+ {
+ presentPlayerMedal("1000_Enemies");
+ }
+
+ if (game.totalEnemiesDefeated >= 2500)
+ {
+ presentPlayerMedal("2500_Enemies");
+ }
}
void clearAllMissionData()
extern bool perfectlyCompleted();
extern void doParticles();
extern void saveGame();
+extern void presentPlayerMedal(const char *tname);
extern Audio audio;
extern Config config;
{
sprintf(message, "Got the Aqua Lung! You can now swim forever!");
game.hasAquaLung = true;
+ presentPlayerMedal("Aqua_Lung");
}
if (strcmp(objective->description, "Get the Jetpack") == 0)
{
sprintf(message, "Got the Jetpack! Press SPACE to Activate!");
game.hasJetPack = true;
+ presentPlayerMedal("Jetpack");
}
engine.setInfoMessage(message, 9, INFO_OBJECTIVE);
#include "headers.h"
+extern void presentPlayerMedal(const char *tname);
+
extern Audio audio;
extern Engine engine;
extern Game game;
#include "player.h"
+int medalWorker(void *data)
+{
+ char *tname = (char*)data;
+
+ SDL_mutexP(medalServer.lock);
+
+ int type = medalServer.postMedal(tname);
+
+ while (!graphics.canShowMedalMessage())
+ {
+ SDL_Delay(100);
+ }
+
+ SDL_Delay(100);
+
+ if (type >= 1 && type <= 3)
+ {
+ audio.playSound(SND_ITEM, CH_ANY);
+ graphics.showMedalMessage(type, medalServer.getMessage());
+
+ if (medalServer.hasRuby())
+ {
+ while (!graphics.canShowMedalMessage())
+ {
+ SDL_Delay(100);
+ }
+
+ SDL_Delay(100);
+
+ audio.playSound(SND_ITEM, CH_ANY);
+ graphics.showMedalMessage(4, medalServer.getRubyMessage());
+ }
+ }
+
+ SDL_mutexV(medalServer.lock);
+
+ delete tname;
+
+ return type;
+}
+
+void presentPlayerMedal(const char *tname)
+{
+ // Copy the input, so that threading
+ // doesn't trip us up!
+ char *data = new char[128];
+ strcpy(data, tname);
+
+ SDL_Thread *thread = SDL_CreateThread(medalWorker, (void*)data);
+
+ if (thread == NULL)
+ {
+ printf("Unable to create thread: %s\n", SDL_GetError());
+ printf("Calling medal server directly\n");
+ medalWorker((void*)data);
+ return;
+ }
+}
+
+void addPlayerScore(int score)
+{
+ if (game.score < 100000 && game.score + score >= 100000)
+ {
+ presentPlayerMedal("Score_100000");
+ }
+ else if (game.score < 250000 && game.score + score >= 250000)
+ {
+ presentPlayerMedal("Score_250000");
+ }
+ else if (game.score < 500000 && game.score + score >= 500000)
+ {
+ presentPlayerMedal("Score_500000");
+ }
+
+ game.score += score;
+}
+
void resetPlayer()
{
game.getCheckPoint(&player.x, &player.y);
}
}
- #if DEBUG
+ #if !USEPAK
if (engine.keyState[SDLK_1])
player.currentWeapon = &weapon[WP_PISTOL];
else if (engine.keyState[SDLK_2])
*/
#include "headers.h"
+#include "SDL_thread.h"
extern void throwAndDamageEntity(Entity *ent, int damage, int minDX, int maxDX, int DY);
extern void moveEntity(Entity *ent);
extern Game game;
extern Graphics graphics;
extern Map map;
+extern MedalServer medalServer;
extern Entity player;
extern Weapon weapon[MAX_WEAPONS];
void loadSound(int index, const char *filename)
{
- audio.loadSound(index, filename);
+ if (!audio.loadSound(index, filename))
+ graphics.showErrorAndExit(ERR_FILE, filename);
graphics.showLoading(1, 30);
}