From 151abcad30a0e1582b91b58b4a42343f5686979c Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 18 Jul 2006 15:52:42 +0000 Subject: Updated the updating system. It will now only load those updates specified in the downloaded resources.txt file, and in the order in which they are mentioned (the top one being the most significant). --- src/main.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 20a1771c..a4ef390e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -163,10 +163,6 @@ void init_engine() // Add the main data directory to our PhysicsFS search path resman->addToSearchPath("data", true); resman->addToSearchPath(TMW_DATADIR "data", true); - // 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"); @@ -391,6 +387,22 @@ void parseOptions(int argc, char *argv[], Options &options) } } +/** + * Reads the file "updates/resources.txt" and attempts to load each update + * mentioned in it. + */ +void loadUpdates() +{ + const std::string updatesFile = "updates/resources.txt"; + ResourceManager *resman = ResourceManager::getInstance(); + std::vector lines = resman->loadTextFile(updatesFile); + + for (unsigned int i = 0; i < lines.size(); ++i) + { + resman->addToSearchPath(lines[i], false); + } +} + CharServerHandler charServerHandler; LoginData loginData; LoginHandler loginHandler; @@ -503,14 +515,17 @@ int main(int argc, char *argv[]) SDL_Event event; - if (options.skipUpdate && state != ERROR_STATE) - { + if (options.skipUpdate && state != ERROR_STATE) { + loadUpdates(); state = LOGIN_STATE; } + else { + state = UPDATE_STATE; + } unsigned int oldstate = !state; // We start with a status change. - Window *currentDialog = NULL; + Window *currentDialog = NULL; Image *login_wallpaper = NULL; Game *game = NULL; @@ -581,8 +596,7 @@ int main(int argc, char *argv[]) switch (oldstate) { case UPDATE_STATE: - ResourceManager::getInstance()-> - searchAndAddArchives("/updates", ".zip", 0); + loadUpdates(); break; // Those states don't cause a network disconnect -- cgit v1.2.3-70-g09d2