From 25d4e1e3fe393ee845c868a9e5c163de52748379 Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Sat, 30 Jul 2005 11:55:28 +0000 Subject: Fixed check for updates directory. Moved search/write path setup from resourcemanager to main initialization. --- src/main.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 219df488..b0608c9a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -162,21 +162,33 @@ void init_engine() } #endif - if (!PHYSFS_setWriteDir(homeDir.c_str())) { + // Initialize logger + logger = new Logger(homeDir + std::string("/tmw.log")); + + ResourceManager *resman = ResourceManager::getInstance(); + + if (!resman->setWriteDir(homeDir)) { std::cout << homeDir << " couldn't be set as home directory! Exitting." << std::endl; exit(1); } + // Add the user's homedir to PhysicsFS search path + resman->addToSearchPath(homeDir, false); // Creating and checking the updates folder existence and rights. - if (!PHYSFS_exists("/updates")) { - if (!PHYSFS_mkdir("/updates")) { + if (!resman->isDirectory("/updates")) { + if (!resman->mkdir("/updates")) { std::cout << homeDir << "/updates can't be made, but it doesn't exist! Exitting." << std::endl; exit(1); } } - // Initialize logger - logger = new Logger(homeDir + std::string("/tmw.log")); + // Add the main data directory to our PhysicsFS search path + resman->addToSearchPath("data", true); + resman->addToSearchPath(TMW_DATADIR "data", 1); + // Add zip files to PhysicsFS + resman->searchAndAddArchives("/", ".zip", true); + // Updates, these override other files + resman->searchAndAddArchives("/updates", ".zip", false); // Fill configuration with defaults config.setValue("host", "animesites.de"); @@ -297,8 +309,6 @@ void init_engine() // Create the graphics context graphics = new Graphics(screen); - ResourceManager *resman = ResourceManager::getInstance(); - login_wallpaper = resman->getImage( "graphics/images/login_wallpaper.png"); Image *playerImg = resman->getImage( @@ -389,7 +399,6 @@ int main(int argc, char *argv[]) init_engine(); - SDL_Event event; while (state != EXIT) -- cgit v1.2.3-70-g09d2