From e6c59d2a241ebf2a2acbca9b593acb9aedfc5093 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Fri, 27 Feb 2015 14:53:23 -0500 Subject: [PATCH] Some cleanup, bumped version number. --- Makefile | 2 +- src/Starfighter.cpp | 3 ++- src/Starfighter.h | 1 - src/defs.h | 3 --- src/intermission.cpp | 16 ++++++++++++---- src/version.h | 1 - 6 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 src/version.h diff --git a/Makefile b/Makefile index 309c399..577b9b7 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer` -DLINUX LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer` OBJS = ai.o aliens.o audio.o bullets.o cargo.o collectable.o comms.o debris.o events.o explosions.o game.o globals.o graphics.o init.o intermission.o loadSave.o messages.o misc.o missions.o player.o resources.o script.o shop.o Starfighter.o title.o weapons.o -VERSION = 1.2-SDL2 +VERSION = 1.3 PROG = starfighter DOCS = docs/* DATA = data gfx sound diff --git a/src/Starfighter.cpp b/src/Starfighter.cpp index e6a90d9..8c1de83 100644 --- a/src/Starfighter.cpp +++ b/src/Starfighter.cpp @@ -21,7 +21,8 @@ along with this program. If not, see . int main(int argc, char *argv[]) { - chdir(DATADIR); + if (chdir(DATADIR) == -1) + printf("Warning: failed to change directory to \"%s\"\n", DATADIR); defineGlobals(); // Must do this first! diff --git a/src/Starfighter.h b/src/Starfighter.h index 16b6354..5599180 100644 --- a/src/Starfighter.h +++ b/src/Starfighter.h @@ -58,7 +58,6 @@ along with this program. If not, see . #include "script.h" #include "shop.h" #include "title.h" -#include "version.h" #include "weapons.h" #endif diff --git a/src/defs.h b/src/defs.h index 2558bff..f417052 100644 --- a/src/defs.h +++ b/src/defs.h @@ -289,9 +289,6 @@ enum { #define SHIP_HIT_INDEX 60 -#ifndef PACKLOCATION -#define PACKLOCATION "starfighter.pak" -#endif #ifndef PATH_MAX #define PATH_MAX 4096 #endif diff --git a/src/intermission.cpp b/src/intermission.cpp index c141da7..1bb9efb 100644 --- a/src/intermission.cpp +++ b/src/intermission.cpp @@ -202,7 +202,11 @@ static void setSystemPlanets() for (int i = 0 ; i < 10 ; i++) { - fscanf(fp, "%d %s %d", &distance, name, &image); + if (fscanf(fp, "%d %s %d", &distance, name, &image) < 3) + { + printf("Warning: Data file \"%s\" is not correctly formatted\n", string); + break; + } systemPlanet[i].y = distance; strcpy(systemPlanet[i].name, name); @@ -217,9 +221,13 @@ static void setSystemPlanets() for (int i = 0 ; i < 10 ; i++) { - fscanf(fp, "%d %d %s%*c", &messageMission, &messageSlot, face); - fscanf(fp, "%[^\n]%*c", from); - fscanf(fp, "%[^\n]%*c", subject); + if ((fscanf(fp, "%d %d %s%*c", &messageMission, &messageSlot, face) < 3) || + (fscanf(fp, "%[^\n]%*c", from) < 1) || + (fscanf(fp, "%[^\n]%*c", subject) < 1)) + { + printf("Warning: Data file \"%s\" is not correctly formatted\n", string); + break; + } systemPlanet[i].messageMission = messageMission; systemPlanet[i].messageSlot = messageSlot; diff --git a/src/version.h b/src/version.h deleted file mode 100644 index 8b13789..0000000 --- a/src/version.h +++ /dev/null @@ -1 +0,0 @@ -