diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-02-20 23:45:51 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-02-20 23:45:51 +0000 |
commit | 7cb624d0e6a2844360f28fdb8390f866aa3393c7 (patch) | |
tree | 1444fa899a8266072472cc1045ffb503bcab5ee1 | |
parent | 6f4c416887d2a006a13dbd4e54932d46b59b0b17 (diff) | |
download | Mana-7cb624d0e6a2844360f28fdb8390f866aa3393c7.tar.gz Mana-7cb624d0e6a2844360f28fdb8390f866aa3393c7.tar.bz2 Mana-7cb624d0e6a2844360f28fdb8390f866aa3393c7.tar.xz Mana-7cb624d0e6a2844360f28fdb8390f866aa3393c7.zip |
Added support for customdata directory.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 2 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 18 | ||||
-rw-r--r-- | src/main.h | 1 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 27 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 8 |
7 files changed, 65 insertions, 6 deletions
@@ -1,4 +1,15 @@ -2007-02-20 Bjørn Lindeijer <bjorn@lindeijer.nl> +2007-02-21 Philipp Sehmisch <tmw@crushnet.org> + + * src/gui/char-server.cpp, src/gui/updatewindow.cpp, src/gui/main.cpp, + src/gui/main.h: Added a new state "LOADDATA_STATE" that loads the XML + databases. + * src/resourcemanager.cpp, src/resourcemanager.h, src/main.cpp, customdata/: + Added a customdata dir that allows to add custom user data easily. Just + create a zip file with the same structure like the update archives and drop + it in the customdata folder and the files in it override the default data + and the updates. + +2007-02-20 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/log.cpp: Applied patch by trapdoor to fix the usage of a deprecated function on MacOS X 10.4 and later. diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index cccdcff1..a5fda25f 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -108,7 +108,7 @@ ServerSelectDialog::action(const gcn::ActionEvent &event) state = CHAR_CONNECT_STATE; } else if (event.getId() == "cancel") { - state = LOGIN_STATE; + state = LOADDATA_STATE; } } diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 24084fe4..b66bcfbd 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -179,7 +179,7 @@ void UpdaterWindow::action(const gcn::ActionEvent &event) } else if (event.getId() == "play") { - state = LOGIN_STATE; + state = LOADDATA_STATE; } } diff --git a/src/main.cpp b/src/main.cpp index a9bcd077..383e7f39 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -535,7 +535,7 @@ int main(int argc, char *argv[]) SDL_Event event; if (options.skipUpdate && state != ERROR_STATE) { - state = LOGIN_STATE; + state = LOADDATA_STATE; } else { state = UPDATE_STATE; @@ -623,6 +623,7 @@ int main(int argc, char *argv[]) break; // Those states don't cause a network disconnect + case LOADDATA_STATE: case ACCOUNT_STATE: case CHAR_CONNECT_STATE: case CONNECTING_STATE: @@ -643,13 +644,24 @@ int main(int argc, char *argv[]) } switch (state) { - case LOGIN_STATE: - logger->log("State: LOGIN"); + case LOADDATA_STATE: + logger->log("State: LOADDATA"); + + //add customdata directory + ResourceManager::getInstance()->searchAndAddArchives( + "customdata/", + "zip", + false); // Load XML databases EquipmentDB::load(); ItemDB::load(); MonsterDB::load(); + state = LOGIN_STATE; + break; + + case LOGIN_STATE: + logger->log("State: LOGIN"); if (!loginData.password.empty()) { state = ACCOUNT_STATE; @@ -39,6 +39,7 @@ enum { EXIT_STATE, + LOADDATA_STATE, LOGIN_STATE, ACCOUNT_STATE, REGISTER_STATE, diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 4ed316cf..37a82b0c 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -109,6 +109,33 @@ ResourceManager::addToSearchPath(const std::string &path, bool append) PHYSFS_addToSearchPath(path.c_str(), append ? 1 : 0); } +void +ResourceManager::searchAndAddArchives(const std::string &path, + const std::string &ext, + bool append) +{ + const char *dirSep = PHYSFS_getDirSeparator(); + char **list = PHYSFS_enumerateFiles(path.c_str()); + + for (char **i = list; *i != NULL; i++) + { + size_t len = strlen(*i); + + if (len > ext.length() && !ext.compare((*i)+(len - ext.length()))) + { + std::string file, realPath, archive; + + file = path + (*i); + realPath = std::string(PHYSFS_getRealDir(file.c_str())); + archive = realPath + dirSep + file; + + addToSearchPath(archive, append); + } + } + + PHYSFS_freeList(list); +} + bool ResourceManager::mkdir(const std::string &path) { diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index d458f96e..e176e337 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -83,6 +83,14 @@ class ResourceManager addToSearchPath(const std::string &path, bool append); /** + * Searches for zip files and adds them to the search path. + */ + void + searchAndAddArchives(const std::string &path, + const std::string &ext, + bool append); + + /** * Creates a directory in the write path */ bool |