GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-986611-asserts into lp:widelands.
Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #986611 in widelands: "Issues reported by cppcheck" https://bugs.launchpad.net/widelands/+bug/986611 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-986611-asserts/+merge/275642 Replaced some assert statements with exceptions. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-986611-asserts into lp:widelands.
=== modified file 'src/economy/routeastar.cc' --- src/economy/routeastar.cc 2013-07-26 20:19:36 +0000 +++ src/economy/routeastar.cc 2015-10-25 15:47:27 +0000 @@ -19,6 +19,7 @@ #include "economy/routeastar.h" +#include "base/wexception.h" #include "economy/iroute.h" #include "economy/router.h" @@ -37,7 +38,9 @@ */ void BaseRouteAStar::routeto(RoutingNode & to, IRoute & route) { - assert(!to.cookie().is_active()); + if (to.cookie().is_active()) { + throw wexception("BaseRouteAStar::routeto should not have an active cookie."); + } assert(to.mpf_cycle == mpf_cycle); route.init(to.mpf_realcost); === modified file 'src/io/filesystem/zip_filesystem.cc' --- src/io/filesystem/zip_filesystem.cc 2014-10-27 10:14:10 +0000 +++ src/io/filesystem/zip_filesystem.cc 2015-10-25 15:47:27 +0000 @@ -182,8 +182,12 @@ FileSystem * ZipFilesystem::make_sub_file_system(const std::string & path) { m_open_unzip(); - assert(file_exists(path)); - assert(is_directory(path)); + if (!file_exists(path)) { + throw wexception("ZipFilesystem::make_sub_file_system: The path does not exist."); + } + if (!is_directory(path)) { + throw wexception("ZipFilesystem::make_sub_file_system: The path needs to be a directory."); + } m_close(); @@ -206,7 +210,9 @@ // see Filesystem::create FileSystem * ZipFilesystem::create_sub_file_system(const std::string & path, Type const type) { - assert(!file_exists(path)); + if (file_exists(path)) { + throw wexception("ZipFilesystem::create_sub_file_system: Sub file system already exists."); + } if (type != FileSystem::DIR) throw ZipOperationError === modified file 'src/network/internet_gaming.cc' --- src/network/internet_gaming.cc 2015-07-30 07:16:09 +0000 +++ src/network/internet_gaming.cc 2015-10-25 15:47:27 +0000 @@ -184,7 +184,9 @@ /// Relogin to metaserver after loosing connection bool InternetGaming::relogin() { - assert(error()); + if (!error()) { + throw wexception("InternetGaming::relogin: This only makes sense if there was an error."); + } initialize_connection();
_______________________________________________ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp