From: Stephen Sweeney Date: Mon, 8 Mar 2010 08:29:27 +0000 (+0000) Subject: 1.17 Medal Support X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6d93c744add4c06b85cf6c6d7e6317536a5c8ec1;p=quix0rs-blobwars.git 1.17 Medal Support --- diff --git a/gfx/main/CircuitBoard.jpg b/gfx/main/CircuitBoard.jpg old mode 100644 new mode 100755 diff --git a/gfx/main/alienDevice.png b/gfx/main/alienDevice.png old mode 100644 new mode 100755 diff --git a/gfx/main/areaClear.png b/gfx/main/areaClear.png old mode 100644 new mode 100755 diff --git a/gfx/main/areaClearBackGround.jpg b/gfx/main/areaClearBackGround.jpg old mode 100644 new mode 100755 diff --git a/gfx/main/areaPerfect.png b/gfx/main/areaPerfect.png old mode 100644 new mode 100755 diff --git a/gfx/main/cheats.png b/gfx/main/cheats.png old mode 100644 new mode 100755 diff --git a/gfx/main/creditsBack.png b/gfx/main/creditsBack.png old mode 100644 new mode 100755 diff --git a/gfx/main/creditsDevice.png b/gfx/main/creditsDevice.png old mode 100644 new mode 100755 diff --git a/gfx/main/cursor1.png b/gfx/main/cursor1.png old mode 100644 new mode 100755 diff --git a/gfx/main/cursor2.png b/gfx/main/cursor2.png old mode 100644 new mode 100755 diff --git a/gfx/main/cursor3.png b/gfx/main/cursor3.png old mode 100644 new mode 100755 diff --git a/gfx/main/cursor4.png b/gfx/main/cursor4.png old mode 100644 new mode 100755 diff --git a/gfx/main/cursor5.png b/gfx/main/cursor5.png old mode 100644 new mode 100755 diff --git a/gfx/main/cursor6.png b/gfx/main/cursor6.png old mode 100644 new mode 100755 diff --git a/gfx/main/gameover.png b/gfx/main/gameover.png old mode 100644 new mode 100755 index 3001db7..c08c596 Binary files a/gfx/main/gameover.png and b/gfx/main/gameover.png differ diff --git a/gfx/main/hubArrowLeft.png b/gfx/main/hubArrowLeft.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubArrowLeft2.png b/gfx/main/hubArrowLeft2.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubArrowRight.png b/gfx/main/hubArrowRight.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubArrowRight2.png b/gfx/main/hubArrowRight2.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubIcon1.png b/gfx/main/hubIcon1.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubIcon2.png b/gfx/main/hubIcon2.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubIcon3.png b/gfx/main/hubIcon3.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubIcon4.png b/gfx/main/hubIcon4.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubIcon5.png b/gfx/main/hubIcon5.png old mode 100644 new mode 100755 diff --git a/gfx/main/hubIcon6.png b/gfx/main/hubIcon6.png old mode 100644 new mode 100755 diff --git a/gfx/main/joystickConfig.png b/gfx/main/joystickConfig.png old mode 100644 new mode 100755 diff --git a/gfx/main/keyConfig.png b/gfx/main/keyConfig.png old mode 100644 new mode 100755 diff --git a/gfx/main/licensePic.png b/gfx/main/licensePic.png old mode 100644 new mode 100755 diff --git a/gfx/main/mapBackground.png b/gfx/main/mapBackground.png old mode 100644 new mode 100755 diff --git a/gfx/main/options.png b/gfx/main/options.png old mode 100644 new mode 100755 diff --git a/gfx/main/optionsBackground.png b/gfx/main/optionsBackground.png old mode 100644 new mode 100755 diff --git a/gfx/main/prlogo.gif b/gfx/main/prlogo.gif old mode 100644 new mode 100755 diff --git a/gfx/main/title.png b/gfx/main/title.png old mode 100644 new mode 100755 diff --git a/gfx/main/worldMap.jpg b/gfx/main/worldMap.jpg old mode 100644 new mode 100755 diff --git a/locale/ca.mo b/locale/ca.mo index 0b532b5..77d6487 100644 Binary files a/locale/ca.mo and b/locale/ca.mo differ diff --git a/locale/nl.mo b/locale/nl.mo index 0bf83ef..3f20013 100644 Binary files a/locale/nl.mo and b/locale/nl.mo differ diff --git a/makefile b/makefile old mode 100644 new mode 100755 index 1af900d..3232b1d --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ PAKNAME = blobwars.pak DOCS = doc/* ICONS = icons/ -VERSION = 1.14 +VERSION = 1.17 RELEASE = 1 USEPAK = 1 @@ -14,12 +14,15 @@ DOCDIR = $(PREFIX)/share/doc/$(PROG)/ 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 @@ -33,7 +36,7 @@ OBJS += CKeyboard.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 @@ -89,7 +92,7 @@ mapeditor: $(MAPOBJS) clean: $(RM) $(GAMEOBJS) mapEditor.o pak.o $(PROG) $(PAKNAME) pak mapeditor $(LOCALE_MO) -buildpak: pak +buildpak: ./pak data gfx music sound $(PAKNAME) # install diff --git a/makefile.windows b/makefile.windows old mode 100644 new mode 100755 index 0f0e694..8e8281b --- a/makefile.windows +++ b/makefile.windows @@ -3,7 +3,7 @@ PAKNAME = blobwars.pak DOCS = doc/* ICONS = icons/ -VERSION = 1.14 +VERSION = 1.17 RELEASE = 1 USEPAK = 1 @@ -14,14 +14,16 @@ DOCDIR = $(PREFIX)/share/doc/$(PROG)/ 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 @@ -35,7 +37,7 @@ OBJS += CKeyboard.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 diff --git a/src/CAudio.cpp b/src/CAudio.cpp old mode 100644 new mode 100755 diff --git a/src/CAudio.h b/src/CAudio.h old mode 100644 new mode 100755 diff --git a/src/CBoss.cpp b/src/CBoss.cpp old mode 100644 new mode 100755 diff --git a/src/CBoss.h b/src/CBoss.h old mode 100644 new mode 100755 diff --git a/src/CCollision.cpp b/src/CCollision.cpp old mode 100644 new mode 100755 diff --git a/src/CCollision.h b/src/CCollision.h old mode 100644 new mode 100755 diff --git a/src/CConfig.cpp b/src/CConfig.cpp old mode 100644 new mode 100755 index cbeb334..5507f0f --- a/src/CConfig.cpp +++ b/src/CConfig.cpp @@ -1,197 +1,188 @@ -#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" + +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; + } + + 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(); +} diff --git a/src/CConfig.h b/src/CConfig.h old mode 100644 new mode 100755 index 6a6f5f7..3a288cd --- a/src/CConfig.h +++ b/src/CConfig.h @@ -1,30 +1,30 @@ -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 +{ + 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(); +}; diff --git a/src/CCutscene.cpp b/src/CCutscene.cpp old mode 100644 new mode 100755 diff --git a/src/CCutscene.h b/src/CCutscene.h old mode 100644 new mode 100755 diff --git a/src/CData.cpp b/src/CData.cpp old mode 100644 new mode 100755 diff --git a/src/CData.h b/src/CData.h old mode 100644 new mode 100755 diff --git a/src/CEffect.cpp b/src/CEffect.cpp old mode 100644 new mode 100755 diff --git a/src/CEffect.h b/src/CEffect.h old mode 100644 new mode 100755 diff --git a/src/CEngine.cpp b/src/CEngine.cpp old mode 100644 new mode 100755 index 57105a2..13a5409 --- a/src/CEngine.cpp +++ b/src/CEngine.cpp @@ -84,6 +84,11 @@ Engine::Engine() // Cheats memset(lastKeyEvents, ' ', 25); + #if USEPAK + cheats = false; + #else + cheats = true; + #endif cheatHealth = cheatExtras = cheatFuel = cheatLevels = false; cheatBlood = cheatInvulnerable = cheatReload = cheatSpeed = cheatSkipLevel = false; diff --git a/src/CEngine.h b/src/CEngine.h old mode 100644 new mode 100755 diff --git a/src/CEntity.cpp b/src/CEntity.cpp old mode 100644 new mode 100755 diff --git a/src/CEntity.h b/src/CEntity.h old mode 100644 new mode 100755 diff --git a/src/CFileData.cpp b/src/CFileData.cpp old mode 100644 new mode 100755 diff --git a/src/CFileData.h b/src/CFileData.h old mode 100644 new mode 100755 diff --git a/src/CGame.cpp b/src/CGame.cpp old mode 100644 new mode 100755 diff --git a/src/CGame.h b/src/CGame.h old mode 100644 new mode 100755 diff --git a/src/CGameData.cpp b/src/CGameData.cpp old mode 100644 new mode 100755 diff --git a/src/CGameData.h b/src/CGameData.h old mode 100644 new mode 100755 diff --git a/src/CGameObject.cpp b/src/CGameObject.cpp old mode 100644 new mode 100755 diff --git a/src/CGameObject.h b/src/CGameObject.h old mode 100644 new mode 100755 diff --git a/src/CGraphics.cpp b/src/CGraphics.cpp old mode 100644 new mode 100755 index 7c63193..e93d324 --- a/src/CGraphics.cpp +++ b/src/CGraphics.cpp @@ -31,6 +31,9 @@ Graphics::Graphics() infoMessage = NULL; fontSize = 0; + + medalMessageTimer = 0; + medalType = 0; currentLoading = 0; @@ -88,7 +91,11 @@ void Graphics::destroy() TTF_CloseFont(font[i]); } } - + + if (medalMessage != NULL) + { + SDL_FreeSurface(medalMessage); + } if (fadeBlack) { @@ -99,6 +106,15 @@ void Graphics::destroy() { 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) @@ -129,6 +145,8 @@ void Graphics::mapColors() fadeBlack = alphaRect(640, 480, 0x00, 0x00, 0x00); infoBar = alphaRect(640, 25, 0x00, 0x00, 0x00); + + medalMessage = NULL; } Sprite *Graphics::getSpriteHead() @@ -141,8 +159,34 @@ void Graphics::setTransparent(SDL_Surface *sprite) 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); @@ -923,6 +967,54 @@ void Graphics::drawChatString(SDL_Surface *surface, int y) } } +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); diff --git a/src/CGraphics.h b/src/CGraphics.h old mode 100644 new mode 100755 index b965d90..5b1a5b5 --- a/src/CGraphics.h +++ b/src/CGraphics.h @@ -40,6 +40,10 @@ class Graphics { int screenShotNumber; char screenshot[100]; char chatString[1024]; + + SDL_Surface *medalMessage; + int medalMessageTimer; + int medalType; SDL_Surface *fadeBlack; SDL_Surface *infoMessage; @@ -51,6 +55,8 @@ class Graphics { 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; @@ -63,6 +69,7 @@ class Graphics { 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); @@ -95,6 +102,7 @@ class Graphics { 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); diff --git a/src/CHashtable.cpp b/src/CHashtable.cpp old mode 100644 new mode 100755 diff --git a/src/CHashtable.h b/src/CHashtable.h old mode 100644 new mode 100755 diff --git a/src/CHub.cpp b/src/CHub.cpp old mode 100644 new mode 100755 diff --git a/src/CHub.h b/src/CHub.h old mode 100644 new mode 100755 diff --git a/src/CJoystick.cpp b/src/CJoystick.cpp old mode 100644 new mode 100755 diff --git a/src/CJoystick.h b/src/CJoystick.h old mode 100644 new mode 100755 diff --git a/src/CKeyboard.cpp b/src/CKeyboard.cpp old mode 100644 new mode 100755 diff --git a/src/CKeyboard.h b/src/CKeyboard.h old mode 100644 new mode 100755 diff --git a/src/CLineDef.cpp b/src/CLineDef.cpp old mode 100644 new mode 100755 diff --git a/src/CLineDef.h b/src/CLineDef.h old mode 100644 new mode 100755 diff --git a/src/CList.cpp b/src/CList.cpp old mode 100644 new mode 100755 diff --git a/src/CList.h b/src/CList.h old mode 100644 new mode 100755 diff --git a/src/CMap.cpp b/src/CMap.cpp old mode 100644 new mode 100755 diff --git a/src/CMap.h b/src/CMap.h old mode 100644 new mode 100755 diff --git a/src/CMath.cpp b/src/CMath.cpp old mode 100644 new mode 100755 diff --git a/src/CMath.h b/src/CMath.h old mode 100644 new mode 100755 diff --git a/src/CObjective.cpp b/src/CObjective.cpp old mode 100644 new mode 100755 diff --git a/src/CObjective.h b/src/CObjective.h old mode 100644 new mode 100755 diff --git a/src/CPak.cpp b/src/CPak.cpp old mode 100644 new mode 100755 diff --git a/src/CPak.h b/src/CPak.h old mode 100644 new mode 100755 diff --git a/src/CParticle.cpp b/src/CParticle.cpp old mode 100644 new mode 100755 diff --git a/src/CParticle.h b/src/CParticle.h old mode 100644 new mode 100755 diff --git a/src/CPersistData.cpp b/src/CPersistData.cpp old mode 100644 new mode 100755 diff --git a/src/CPersistData.h b/src/CPersistData.h old mode 100644 new mode 100755 diff --git a/src/CPersistant.cpp b/src/CPersistant.cpp old mode 100644 new mode 100755 diff --git a/src/CPersistant.h b/src/CPersistant.h old mode 100644 new mode 100755 diff --git a/src/CRadarBlip.cpp b/src/CRadarBlip.cpp old mode 100644 new mode 100755 diff --git a/src/CRadarBlip.h b/src/CRadarBlip.h old mode 100644 new mode 100755 diff --git a/src/CReference.cpp b/src/CReference.cpp old mode 100644 new mode 100755 diff --git a/src/CReference.h b/src/CReference.h old mode 100644 new mode 100755 diff --git a/src/CReplayData.cpp b/src/CReplayData.cpp old mode 100644 new mode 100755 diff --git a/src/CReplayData.h b/src/CReplayData.h old mode 100644 new mode 100755 diff --git a/src/CReplayDataHeader.h b/src/CReplayDataHeader.h old mode 100644 new mode 100755 diff --git a/src/CSpawnPoint.cpp b/src/CSpawnPoint.cpp old mode 100644 new mode 100755 diff --git a/src/CSpawnPoint.h b/src/CSpawnPoint.h old mode 100644 new mode 100755 diff --git a/src/CSprite.cpp b/src/CSprite.cpp old mode 100644 new mode 100755 diff --git a/src/CSprite.h b/src/CSprite.h old mode 100644 new mode 100755 diff --git a/src/CString.cpp b/src/CString.cpp old mode 100644 new mode 100755 diff --git a/src/CString.h b/src/CString.h old mode 100644 new mode 100755 diff --git a/src/CSwitch.cpp b/src/CSwitch.cpp old mode 100644 new mode 100755 diff --git a/src/CSwitch.h b/src/CSwitch.h old mode 100644 new mode 100755 diff --git a/src/CTeleporter.cpp b/src/CTeleporter.cpp old mode 100644 new mode 100755 diff --git a/src/CTeleporter.h b/src/CTeleporter.h old mode 100644 new mode 100755 diff --git a/src/CTrain.cpp b/src/CTrain.cpp old mode 100644 new mode 100755 diff --git a/src/CTrain.h b/src/CTrain.h old mode 100644 new mode 100755 diff --git a/src/CTrap.cpp b/src/CTrap.cpp old mode 100644 new mode 100755 diff --git a/src/CTrap.h b/src/CTrap.h old mode 100644 new mode 100755 diff --git a/src/CWeapon.cpp b/src/CWeapon.cpp old mode 100644 new mode 100755 diff --git a/src/CWeapon.h b/src/CWeapon.h old mode 100644 new mode 100755 diff --git a/src/CWidget.cpp b/src/CWidget.cpp old mode 100644 new mode 100755 diff --git a/src/CWidget.h b/src/CWidget.h old mode 100644 new mode 100755 diff --git a/src/aquaBoss.cpp b/src/aquaBoss.cpp old mode 100644 new mode 100755 diff --git a/src/aquaBoss.h b/src/aquaBoss.h old mode 100644 new mode 100755 diff --git a/src/bosses.cpp b/src/bosses.cpp old mode 100644 new mode 100755 diff --git a/src/bosses.h b/src/bosses.h old mode 100644 new mode 100755 diff --git a/src/bullets.cpp b/src/bullets.cpp old mode 100644 new mode 100755 index 1405476..b7ad722 --- a/src/bullets.cpp +++ b/src/bullets.cpp @@ -113,6 +113,11 @@ void addBullet(Entity *owner, float dx, float dy) { owner->reload = 4; } + + if (game.bulletsFired[game.currentWeapon] == 10000) + { + presentPlayerMedal("10000_Bullets"); + } } } diff --git a/src/bullets.h b/src/bullets.h old mode 100644 new mode 100755 index 6524f83..1059e24 --- a/src/bullets.h +++ b/src/bullets.h @@ -32,6 +32,7 @@ extern void addFireParticles(float x, float y, int amount); 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; diff --git a/src/cutscene.cpp b/src/cutscene.cpp old mode 100644 new mode 100755 diff --git a/src/cutscene.h b/src/cutscene.h old mode 100644 new mode 100755 diff --git a/src/defines.h b/src/defines.h old mode 100644 new mode 100755 diff --git a/src/defs.h b/src/defs.h old mode 100644 new mode 100755 index 1758ffb..a18a110 --- a/src/defs.h +++ b/src/defs.h @@ -359,6 +359,12 @@ enum { #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 { @@ -371,10 +377,10 @@ 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 diff --git a/src/droidBoss.cpp b/src/droidBoss.cpp old mode 100644 new mode 100755 diff --git a/src/droidBoss.h b/src/droidBoss.h old mode 100644 new mode 100755 diff --git a/src/effects.cpp b/src/effects.cpp old mode 100644 new mode 100755 diff --git a/src/effects.h b/src/effects.h old mode 100644 new mode 100755 diff --git a/src/enemies.cpp b/src/enemies.cpp old mode 100644 new mode 100755 index 4ee1595..9179ebc --- a/src/enemies.cpp +++ b/src/enemies.cpp @@ -268,9 +268,8 @@ void doAI(Entity *enemy) // 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; @@ -344,6 +343,18 @@ void doAI(Entity *enemy) 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) @@ -439,12 +450,12 @@ void enemyBulletCollisions(Entity *bullet) { 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); @@ -494,7 +505,7 @@ void enemyBulletCollisions(Entity *bullet) { if (player.currentWeapon != &weapon[WP_LASER]) { - game.doCombo(); + checkCombo(); checkObjectives(comboString, false); } } diff --git a/src/enemies.h b/src/enemies.h old mode 100644 new mode 100755 index 231ca69..5353d13 --- a/src/enemies.h +++ b/src/enemies.h @@ -34,6 +34,8 @@ extern void addSmokeAndFire(Entity *ent, float dx, float dy, int amount); 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); diff --git a/src/entities.cpp b/src/entities.cpp old mode 100644 new mode 100755 diff --git a/src/entities.h b/src/entities.h old mode 100644 new mode 100755 diff --git a/src/explosions.cpp b/src/explosions.cpp old mode 100644 new mode 100755 index c5df00f..6e0ac98 --- a/src/explosions.cpp +++ b/src/explosions.cpp @@ -90,7 +90,7 @@ void addExplosion(float x, float y, int radius, Entity *owner) if (owner == &player) { - game.score += enemy->value; + addPlayerScore(enemy->value); } } diff --git a/src/explosions.h b/src/explosions.h old mode 100644 new mode 100755 index 760d0b3..fbdd416 --- a/src/explosions.h +++ b/src/explosions.h @@ -25,6 +25,7 @@ extern void throwAndDamageEntity(Entity *ent, int damage, int minDX, int maxDX, 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; diff --git a/src/finalBattle.cpp b/src/finalBattle.cpp old mode 100644 new mode 100755 index c6d1564..cf06372 --- a/src/finalBattle.cpp +++ b/src/finalBattle.cpp @@ -230,6 +230,7 @@ void galdovFinalDie() self->react = NULL; Math::removeBit(&self->flags, ENT_FLIES); Math::removeBit(&self->flags, ENT_FIRETRAIL); + presentPlayerMedal("Final_Battle"); } self->setActionFinished(1); diff --git a/src/finalBattle.h b/src/finalBattle.h old mode 100644 new mode 100755 index 9e8895a..8278d70 --- a/src/finalBattle.h +++ b/src/finalBattle.h @@ -33,6 +33,7 @@ extern Weapon *getRandomGaldovWeapon(); 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; diff --git a/src/galdov.cpp b/src/galdov.cpp old mode 100644 new mode 100755 diff --git a/src/galdov.h b/src/galdov.h old mode 100644 new mode 100755 diff --git a/src/game.cpp b/src/game.cpp old mode 100644 new mode 100755 index 8fa42b2..cff9414 --- a/src/game.cpp +++ b/src/game.cpp @@ -296,6 +296,7 @@ int gameover() } SDL_Surface *gameover = graphics.quickSprite("Game Over", graphics.loadImage("gfx/main/gameover.png")); + graphics.setTransparent(gameover); audio.loadGameOverMusic(); audio.playMusic(); @@ -568,7 +569,7 @@ int doGame() Uint32 then, frames, frameLimit, millis, frameCounter; - #if DEBUG + #if !USEPAK Uint32 now; char fps[10]; strcpy(fps, "fps"); @@ -584,10 +585,12 @@ int doGame() { player.health = -99; + //#if USEPAK if ((!map.isBossMission) && (replayData.replayMode == REPLAY_MODE::NONE)) { showMissionInformation(); } + //#endif game.levelsStarted++; } @@ -805,10 +808,11 @@ int doGame() 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); @@ -835,7 +839,7 @@ int doGame() 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) diff --git a/src/game.h b/src/game.h old mode 100644 new mode 100755 index 134873e..787e23b --- a/src/game.h +++ b/src/game.h @@ -67,6 +67,8 @@ extern void processPostMissionData(); extern void clearAllMissionData(); extern void saveGame(); +extern void presentPlayerMedal(const char *tname); + extern Audio audio; extern Config config; extern Engine engine; diff --git a/src/graphics.cpp b/src/graphics.cpp old mode 100644 new mode 100755 diff --git a/src/graphics.h b/src/graphics.h old mode 100644 new mode 100755 diff --git a/src/headers.h b/src/headers.h old mode 100644 new mode 100755 index 728ce02..f850159 --- a/src/headers.h +++ b/src/headers.h @@ -39,6 +39,7 @@ extern DECLSPEC int SDLCALL SDL_GetGamma(float *red, float *green, float *blue); #include "SDL/SDL_image.h" #include "SDL/SDL_mixer.h" #include "SDL/SDL_ttf.h" +#include "SDL/SDL_net.h" #endif #include @@ -96,3 +97,4 @@ extern DECLSPEC int SDLCALL SDL_GetGamma(float *red, float *green, float *blue); #include "CReplayDataHeader.h" #include "CReplayData.h" #include "CConfig.h" +#include "CMedalServer.h" diff --git a/src/hub.cpp b/src/hub.cpp old mode 100644 new mode 100755 index 6e34265..f6540ef --- a/src/hub.cpp +++ b/src/hub.cpp @@ -405,16 +405,6 @@ void createMIAPanel(int start, int max) bool requirementMet(const char *requiredLevel) { - if (engine.cheatLevels) - { - return true; - } - - if (strcmp(requiredLevel, "@none@") == 0) - { - return true; - } - if (strstr(requiredLevel, "Stages")) { int stages = 0; @@ -422,9 +412,20 @@ bool requirementMet(const char *requiredLevel) if (game.stagesCleared >= stages) { + presentPlayerMedal(requiredLevel); return true; } } + + if (engine.cheatLevels) + { + return true; + } + + if (strcmp(requiredLevel, "@none@") == 0) + { + return true; + } return gameData.requiredLevelCleared(requiredLevel); } @@ -440,6 +441,9 @@ int doHub() 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")); @@ -491,7 +495,7 @@ int doHub() char name[50], level[50], requiredLevel[50]; int x, y; - #if DEBUG + #if !USEPAK char pos[50]; #endif @@ -583,6 +587,8 @@ int doHub() hubList.clear(); return SECTION_EASYOVER; } + + presentPlayerMedal("World_Complete"); } audio.playMusic(); @@ -609,7 +615,7 @@ int doHub() 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 diff --git a/src/hub.h b/src/hub.h old mode 100644 new mode 100755 index 7fbdf83..3c48939 --- a/src/hub.h +++ b/src/hub.h @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h" extern void showOptions(); +extern void presentPlayerMedal(const char *tname); extern Audio audio; extern Config config; diff --git a/src/info.cpp b/src/info.cpp old mode 100644 new mode 100755 index cdf365c..6945f46 --- a/src/info.cpp +++ b/src/info.cpp @@ -213,8 +213,10 @@ void doPauseInfo() 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); diff --git a/src/info.h b/src/info.h old mode 100644 new mode 100755 diff --git a/src/init.cpp b/src/init.cpp old mode 100644 new mode 100755 index 66e0949..cf555ca --- a/src/init.cpp +++ b/src/init.cpp @@ -195,6 +195,51 @@ void saveConfig() 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! ;) @@ -255,7 +300,7 @@ void initSystem() { 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; } @@ -317,6 +362,11 @@ void initSystem() 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"); @@ -342,6 +392,23 @@ void initSystem() 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")); @@ -408,6 +475,9 @@ void cleanup() debug(("Closing TTF...\n")); TTF_Quit(); + + debug(("Closing NET...\n")); + SDLNet_Quit(); debug(("Closing SDL Sub System...\n")); SDL_Quit(); diff --git a/src/init.h b/src/init.h old mode 100644 new mode 100755 index 04e8221..2b6baaa --- a/src/init.h +++ b/src/init.h @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #include #include "headers.h" +#include "SDL_thread.h" extern SDL_Surface *loadImage(const char *filename); @@ -36,3 +37,4 @@ extern Game game; extern Graphics graphics; extern Map map; extern ReplayData replayData; +extern MedalServer medalServer; diff --git a/src/intro.cpp b/src/intro.cpp old mode 100644 new mode 100755 diff --git a/src/intro.h b/src/intro.h old mode 100644 new mode 100755 diff --git a/src/items.cpp b/src/items.cpp old mode 100644 new mode 100755 index 0a54e67..4db5fc8 --- a/src/items.cpp +++ b/src/items.cpp @@ -243,7 +243,7 @@ void pickUpItem(Entity *item) 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: @@ -289,6 +289,11 @@ void pickUpItem(Entity *item) engine.setInfoMessage(string, 0, INFO_NORMAL); checkObjectives(item->name, true); + + if (strcmp(item->name, "LRTS") == 0) + { + presentPlayerMedal("LRTS_PART"); + } } } diff --git a/src/items.h b/src/items.h old mode 100644 new mode 100755 index 45909ce..962c555 --- a/src/items.h +++ b/src/items.h @@ -27,6 +27,8 @@ extern bool checkBrickContact(Entity *object); 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; diff --git a/src/lineDefs.cpp b/src/lineDefs.cpp old mode 100644 new mode 100755 index ee55f84..81c5f48 --- a/src/lineDefs.cpp +++ b/src/lineDefs.cpp @@ -64,7 +64,7 @@ void doLineDefs() if ((absX < 800) && (absY < 600)) { - #if DEBUG + #if !USEPAK graphics.drawRect(x, y, lineDef->width, lineDef->height, graphics.red, graphics.screen); #endif diff --git a/src/lineDefs.h b/src/lineDefs.h old mode 100644 new mode 100755 diff --git a/src/loadSave.cpp b/src/loadSave.cpp old mode 100644 new mode 100755 index 1bb3e5a..cfb509d --- a/src/loadSave.cpp +++ b/src/loadSave.cpp @@ -328,6 +328,7 @@ void saveGame() 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(); diff --git a/src/loadSave.h b/src/loadSave.h old mode 100644 new mode 100755 diff --git a/src/main.cpp b/src/main.cpp old mode 100644 new mode 100755 index 00bdcf9..020724c --- a/src/main.cpp +++ b/src/main.cpp @@ -94,7 +94,7 @@ void showVersion() 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[]) @@ -131,7 +131,7 @@ 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; diff --git a/src/main.h b/src/main.h old mode 100644 new mode 100755 index be6d7f4..b5697d3 --- a/src/main.h +++ b/src/main.h @@ -44,6 +44,8 @@ extern void showMissionClear(); extern void checkStartCutscene(); extern void easyGameFinished(); +extern void presentPlayerMedal(const char *tname); + Audio audio; Config config; Engine engine; @@ -52,6 +54,7 @@ GameData gameData; Graphics graphics; Map map; ReplayData replayData; +MedalServer medalServer; Entity defEnemy[MAX_ENEMIES]; Entity defItem[MAX_ITEMS]; diff --git a/src/map.cpp b/src/map.cpp old mode 100644 new mode 100755 index 70279d9..e7083c8 --- a/src/map.cpp +++ b/src/map.cpp @@ -51,7 +51,7 @@ void drawMap() { 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); diff --git a/src/map.h b/src/map.h old mode 100644 new mode 100755 diff --git a/src/mapData.cpp b/src/mapData.cpp old mode 100644 new mode 100755 index 7696363..1ccef79 --- a/src/mapData.cpp +++ b/src/mapData.cpp @@ -247,7 +247,8 @@ void getMapTokens() 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) { diff --git a/src/mapData.h b/src/mapData.h old mode 100644 new mode 100755 diff --git a/src/mapEditor.cpp b/src/mapEditor.cpp old mode 100644 new mode 100755 index e8096de..5810419 --- a/src/mapEditor.cpp +++ b/src/mapEditor.cpp @@ -20,9 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "mapEditor.h" -Config config; -ReplayData replayData; - void drawMap(int mapX, int mapY) { SDL_Rect r; @@ -434,10 +431,6 @@ int main(int argc, char *argv[]) exit(1); } - config.engine = &engine; - - replayData.reset(); - atexit(cleanup); engine.useAudio = 0; @@ -476,7 +469,7 @@ int main(int argc, char *argv[]) { engine.getInput(); config.populate(); - config.doPause(); + engine.doPause(); engine.doFrameLoop(); graphics.updateScreen(); diff --git a/src/mapEditor.h b/src/mapEditor.h old mode 100644 new mode 100755 diff --git a/src/mias.cpp b/src/mias.cpp old mode 100644 new mode 100755 index d9de863..5936f9b --- a/src/mias.cpp +++ b/src/mias.cpp @@ -153,6 +153,24 @@ void doMIAs() 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); } diff --git a/src/mias.h b/src/mias.h old mode 100644 new mode 100755 index 07e3244..55fed7c --- a/src/mias.h +++ b/src/mias.h @@ -30,3 +30,4 @@ extern Map map; extern Entity player; extern void moveEntity(Entity *ent); +extern void presentPlayerMedal(const char *tname); diff --git a/src/mission.cpp b/src/mission.cpp old mode 100644 new mode 100755 index 1bf4670..4d6e989 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -66,6 +66,7 @@ void processPostMissionData() if (!gameData.stagePreviouslyCleared(game.stageName)) { + presentPlayerMedal(game.stageName); game.stagesCleared++; } @@ -110,6 +111,16 @@ void processPostMissionData() } game.totalUpStats(); + + if (game.totalEnemiesDefeated >= 1000) + { + presentPlayerMedal("1000_Enemies"); + } + + if (game.totalEnemiesDefeated >= 2500) + { + presentPlayerMedal("2500_Enemies"); + } } void clearAllMissionData() diff --git a/src/mission.h b/src/mission.h old mode 100644 new mode 100755 index eee869a..5ec0db5 --- a/src/mission.h +++ b/src/mission.h @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern bool perfectlyCompleted(); extern void doParticles(); extern void saveGame(); +extern void presentPlayerMedal(const char *tname); extern Audio audio; extern Config config; diff --git a/src/objectives.cpp b/src/objectives.cpp old mode 100644 new mode 100755 index 7d78fbc..edc5ad4 --- a/src/objectives.cpp +++ b/src/objectives.cpp @@ -281,12 +281,14 @@ void checkObjectives(const char *name, bool alwaysInform) { 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); diff --git a/src/objectives.h b/src/objectives.h old mode 100644 new mode 100755 index 0df33f6..a6a57ee --- a/src/objectives.h +++ b/src/objectives.h @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "headers.h" +extern void presentPlayerMedal(const char *tname); + extern Audio audio; extern Engine engine; extern Game game; diff --git a/src/obstacles.cpp b/src/obstacles.cpp old mode 100644 new mode 100755 diff --git a/src/obstacles.h b/src/obstacles.h old mode 100644 new mode 100755 diff --git a/src/options.cpp b/src/options.cpp old mode 100644 new mode 100755 diff --git a/src/options.h b/src/options.h old mode 100644 new mode 100755 diff --git a/src/pak.cpp b/src/pak.cpp old mode 100644 new mode 100755 diff --git a/src/pak.h b/src/pak.h old mode 100644 new mode 100755 diff --git a/src/particles.cpp b/src/particles.cpp old mode 100644 new mode 100755 diff --git a/src/particles.h b/src/particles.h old mode 100644 new mode 100755 diff --git a/src/player.cpp b/src/player.cpp old mode 100644 new mode 100755 index ac33957..4ce9892 --- a/src/player.cpp +++ b/src/player.cpp @@ -20,6 +20,83 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #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); @@ -352,7 +429,7 @@ void doPlayer() } } - #if DEBUG + #if !USEPAK if (engine.keyState[SDLK_1]) player.currentWeapon = &weapon[WP_PISTOL]; else if (engine.keyState[SDLK_2]) diff --git a/src/player.h b/src/player.h old mode 100644 new mode 100755 index a2f997e..9d5a43e --- a/src/player.h +++ b/src/player.h @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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); @@ -36,6 +37,7 @@ extern Engine engine; extern Game game; extern Graphics graphics; extern Map map; +extern MedalServer medalServer; extern Entity player; extern Weapon weapon[MAX_WEAPONS]; diff --git a/src/resources.cpp b/src/resources.cpp old mode 100644 new mode 100755 index 5308eff..51a516a --- a/src/resources.cpp +++ b/src/resources.cpp @@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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); } diff --git a/src/resources.h b/src/resources.h old mode 100644 new mode 100755 diff --git a/src/spawnPoints.cpp b/src/spawnPoints.cpp old mode 100644 new mode 100755 diff --git a/src/spawnPoints.h b/src/spawnPoints.h old mode 100644 new mode 100755 diff --git a/src/switches.cpp b/src/switches.cpp old mode 100644 new mode 100755 diff --git a/src/switches.h b/src/switches.h old mode 100644 new mode 100755 diff --git a/src/tankBoss.cpp b/src/tankBoss.cpp old mode 100644 new mode 100755 diff --git a/src/tankBoss.h b/src/tankBoss.h old mode 100644 new mode 100755 diff --git a/src/teleporters.cpp b/src/teleporters.cpp old mode 100644 new mode 100755 diff --git a/src/teleporters.h b/src/teleporters.h old mode 100644 new mode 100755 diff --git a/src/title.cpp b/src/title.cpp old mode 100644 new mode 100755 diff --git a/src/title.h b/src/title.h old mode 100644 new mode 100755 diff --git a/src/trains.cpp b/src/trains.cpp old mode 100644 new mode 100755 diff --git a/src/trains.h b/src/trains.h old mode 100644 new mode 100755 diff --git a/src/traps.cpp b/src/traps.cpp old mode 100644 new mode 100755 diff --git a/src/traps.h b/src/traps.h old mode 100644 new mode 100755 diff --git a/src/triggers.cpp b/src/triggers.cpp old mode 100644 new mode 100755 diff --git a/src/triggers.h b/src/triggers.h old mode 100644 new mode 100755 diff --git a/src/weapons.cpp b/src/weapons.cpp old mode 100644 new mode 100755 diff --git a/src/weapons.h b/src/weapons.h old mode 100644 new mode 100755 diff --git a/src/widgets.cpp b/src/widgets.cpp old mode 100644 new mode 100755 diff --git a/src/widgets.h b/src/widgets.h old mode 100644 new mode 100755