From bf5ec76badb71a74be635e6b84e3f5d6754a3a24 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 18 Aug 2018 14:19:07 +0100 Subject: [PATCH] other approach ... loading the full data if possible bu trying to initialise data at best --- src/editor.cpp | 2 +- src/game.cpp | 4 +++- src/init_game.cpp | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/editor.cpp b/src/editor.cpp index e631dfb22..e697b5dbb 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -6670,4 +6670,4 @@ void reselectEntityGroup() int generateDungeon(char* levelset, Uint32 seed, std::tuple mapParameters) { return 0; // dummy function -} \ No newline at end of file +} diff --git a/src/game.cpp b/src/game.cpp index 8e372a387..038f05acf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -38,12 +38,14 @@ #include "player.hpp" #include +#if defined(LINUX) || defined(APPLE) +#include +#endif #ifdef LINUX //Sigsegv catching stuff. #include #include #include -#include const unsigned STACK_SIZE = 10; diff --git a/src/init_game.cpp b/src/init_game.cpp index 88844a3e9..ce9da1505 100644 --- a/src/init_game.cpp +++ b/src/init_game.cpp @@ -156,7 +156,7 @@ int initGame() std::string itemsDirectory = PHYSFS_getRealDir("items/items.txt"); itemsDirectory.append(PHYSFS_getDirSeparator()).append("items/items.txt"); fp = openDataFile(itemsDirectory.c_str(), "r"); - for ( c = 0; !feof(fp); ++c ) + for ( c = 0; c < NUMITEMS; ++c ) { if ( c > ARTIFACT_BOW ) { @@ -169,6 +169,10 @@ int initGame() items[c].name_identified = language[1545 + c * 2]; items[c].name_unidentified = language[1546 + c * 2]; } + items[c].index = items[c].fpindex = items[c].variations = 1; + + if (feof(fp)) + continue; fscanf(fp, "%d", &items[c].index); while ( fgetc(fp) != '\n' ) if ( feof(fp) ) {