/*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
{
if (!engine.loadWidgets(_("data/inGameWidgets")))
{
- graphics.showErrorAndExit(ERR_FILE, _("data/inGameWidgets"));
+ return graphics.showErrorAndExit(ERR_FILE, _("data/inGameWidgets"));
}
graphics.drawRect(120, 100, 400, 300, graphics.black, graphics.white, graphics.screen);
engine.getInput();
config.populate();
- if ((config.isControl(CONTROL::PAUSE)) || (engine.keyState[SDLK_ESCAPE]))
+ if ((config.isControl(CONTROL::PAUSE)) || (engine.keyState[SDL_SCANCODE_ESCAPE]))
{
- engine.keyState[SDLK_ESCAPE] = 0;
+ engine.keyState[SDL_SCANCODE_ESCAPE] = 0;
config.resetControl(CONTROL::PAUSE);
break;
}
doParticles();
- if ((SDL_GetAppState() & SDL_APPINPUTFOCUS) == 0)
- {
- engine.paused = true;
- }
-
replayData.set(config.command);
replayData.commit();
}
if (!engine.loadWidgets(_("data/gameOverWidgets")))
{
- graphics.showErrorAndExit(ERR_FILE, _("data/gameOverWidgets"));
+ return graphics.showErrorAndExit(ERR_FILE, _("data/gameOverWidgets")), SECTION_GAME;
}
SDL_Surface *gameover = graphics.quickSprite("Game Over", graphics.loadImage("gfx/main/gameover.png"));
Widget *widget = engine.getWidgetByName("gameOverNo");
char postfix[100];
snprintf(postfix, sizeof postfix, " (%d)", game.canContinue);
- strncat(widget->label, postfix, sizeof widget->label);
+ strlcat(widget->label, postfix, sizeof widget->label);
}
while (true)
SDL_Surface *panel = graphics.createSurface(400, 300);
SDL_Surface *panelBack = graphics.alphaRect(400, 300, 0x00, 0x00, 0x00);
- SDL_SetColorKey(panel, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(panel->format, 0, 0, 0));
+ SDL_SetColorKey(panel, SDL_TRUE, SDL_MapRGB(panel->format, 0, 0, 0));
graphics.drawRect(1, 1, 398, 298, graphics.black, graphics.white, panelBack);
- char message[100];
+ char message[256];
int col1 = 25;
int col2 = 375;
int y = 30;
unsigned int frameLimit = SDL_GetTicks() + 16;
- audio.playSound(SND_TELEPORT1, CH_ANY);
+ audio.playSound(SND_TELEPORT1, CH_ANY, player.x);
engine.setPlayerPosition((int)player.x, (int)player.y, map.limitLeft, map.limitRight, map.limitUp, map.limitDown);
SDL_FillRect(graphics.screen, NULL, graphics.black);
graphics.delay(1000);
- Uint32 then, frames, frameLimit, millis, frameCounter;
+ Uint32 frames, frameLimit, millis;
+ Uint32 start, cur;
#if DEBUG
- Uint32 now;
+ Uint32 now, then, frameCounter;
char fps[10];
- strncpy(fps, "fps", sizeof fps);
+ strlcpy(fps, "fps", sizeof fps);
#endif
engine.messageTime = -1;
frameLimit = SDL_GetTicks() + 16;
frames = millis = 0;
- then = SDL_GetTicks();
- frameCounter = SDL_GetTicks();
+ start = SDL_GetTicks();
+#ifdef DEBUG
+ then = frameCounter = start;
+#endif
if ((strcmp(map.name, "Space Station") == 0) && (!game.continueFromCheckPoint))
{
{
++frames;
++millis;
+ cur = SDL_GetTicks();
if (game.missionOverReason != MIS_PLAYEROUT)
{
drawMapTopLayer();
doStatusBar();
+ doMusicInfo(cur - start);
- if ((engine.keyState[SDLK_ESCAPE]) && (game.missionOver == 0))
+ if ((engine.keyState[SDL_SCANCODE_ESCAPE]) && (game.missionOver == 0))
{
if (replayData.replayMode == REPLAY_MODE::NONE)
{
config.populate();
config.doPause();
graphics.updateScreen();
+ #ifdef DEBUG
then = SDL_GetTicks();
+ #endif
frames = 0;
if (!engine.paused)
SDL_Delay(16);
}
- if ((engine.keyState[SDLK_F3]) && (engine.cheatSkipLevel))
+ if ((engine.keyState[SDL_SCANCODE_F3]) && (engine.cheatSkipLevel))
{
autoCompleteAllObjectives(true);
- engine.keyState[SDLK_F3] = 0;
+ engine.keyState[SDL_SCANCODE_F3] = 0;
engine.setInfoMessage("Skipping Mission...", 2, INFO_OBJECTIVE);
}
#if DEBUG
- if (engine.keyState[SDLK_F1])
+ if (engine.keyState[SDL_SCANCODE_F1])
{
autoCompleteAllObjectives(false);
}
engine.delay(frameLimit);
}
- if (engine.keyState[SDLK_F5])
+ if (engine.keyState[SDL_SCANCODE_F5])
{
replayData.fast = !replayData.fast;
- engine.keyState[SDLK_F5] = 0;
+ engine.keyState[SDL_SCANCODE_F5] = 0;
}
frameLimit = SDL_GetTicks() + 16;
frameLimit = SDL_GetTicks() + 64;
#if DEBUG
- graphics.drawString(fps, 600, 30, true, graphics.screen);
+ static Graphics::SurfaceCache fpsCache;
+ graphics.drawString(fps, 600, 30, true, graphics.screen, fpsCache);
if (SDL_GetTicks() > frameCounter + 500)
{