diff options
author | redruin1 <tfschaefer222@gmail.com> | 2022-10-19 08:35:06 +0300 |
---|---|---|
committer | redruin1 <tfschaefer222@gmail.com> | 2022-10-19 08:35:06 +0300 |
commit | 230509f4335a9bb4ac06e0553dc2ab873915570c (patch) | |
tree | 80d9a52f5e816d1be466bd17e657b9baebf9baf8 | |
parent | 29ab984d5fcc4aff6796de591c448f354e5d92c3 (diff) |
fixed object message bug caused on level reset
Bug would appear only during the death menu that pops up when you die, seems someone got so hasty changing all the for loops to iterators the neglected to heed their own comments above them
also removed incorrect `unzClose` call as well, leads to a double free due to my misunderstanding
-rw-r--r-- | Source/Internal/zip_util.cpp | 8 | ||||
-rw-r--r-- | Source/Main/scenegraph.cpp | 10 | ||||
-rw-r--r-- | Source/Objects/object.cpp | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/Source/Internal/zip_util.cpp b/Source/Internal/zip_util.cpp index b71be2b3..784cc1ff 100644 --- a/Source/Internal/zip_util.cpp +++ b/Source/Internal/zip_util.cpp @@ -416,8 +416,10 @@ void UnZipFile::ExtractAll(ExpandedZipFile& expanded_zip_file) { expanded_zip_file.SetFilename(filename_offset, filename_buf, file_info.size_filename + 1); filename_offset += file_info.size_filename + 1; - LOGI << uf << std::endl; - LOGI << scoped_buf.ptr << std::endl; + /* + LOGI << ZLIB_VERSION << std::endl; + LOGI << zlibVersion() << std::endl; + */ result = unzOpenCurrentFile(uf); if (result != UNZ_OK) { @@ -442,8 +444,6 @@ void UnZipFile::ExtractAll(ExpandedZipFile& expanded_zip_file) { unzCloseCurrentFile(uf); } while (unzGoToNextFile(uf) == UNZ_OK); } - // Don't forget to clean up afterwards! - unzClose(uf); } void UnZip(const std::string& zip_file_path, diff --git a/Source/Main/scenegraph.cpp b/Source/Main/scenegraph.cpp index 92559c4e..7724302c 100644 --- a/Source/Main/scenegraph.cpp +++ b/Source/Main/scenegraph.cpp @@ -1624,7 +1624,8 @@ void SceneGraph::SendMessageToAllObjects(OBJECT_MSG::Type type) { // passing way past the end. Likely because objects_ is sometimes changed as a result of this call. // This solution means that most objects get called, some might not if they are first destroyed. // New objects will also be called assuming they are added last to the list. - for (auto obj : objects_) { + for (unsigned int i = 0; i < objects_.size(); i++) { + Object* obj = objects_[i]; if (obj) { obj->ReceiveObjectMessage(type); } else { @@ -1634,11 +1635,14 @@ void SceneGraph::SendMessageToAllObjects(OBJECT_MSG::Type type) { } void SceneGraph::SendScriptMessageToAllObjects(std::string& msg) { - for (auto obj : objects_) { + // For consistency, I'm going to also make this a simple loop in case the same iterator problems affect + // This function as well. + for (unsigned int i = 0; i < objects_.size(); i++) { + Object* obj = objects_[i]; if (obj) { obj->ReceiveObjectMessage(OBJECT_MSG::SCRIPT, &msg); } else { - LOGE << "One of the objects is NULL when trying to SendMessageToAllObjects." << std::endl; + LOGE << "One of the objects is NULL when trying to SendScriptMessageToAllObjects." << std::endl; } } } diff --git a/Source/Objects/object.cpp b/Source/Objects/object.cpp index 11dfbf9d..60d1c37e 100644 --- a/Source/Objects/object.cpp +++ b/Source/Objects/object.cpp @@ -312,7 +312,7 @@ void Object::GetDesc(EntityDescription &desc) const { void Object::ReceiveObjectMessage(OBJECT_MSG::Type type, ...) { va_list args; - va_start(args, type); + va_start(args, type); // FIXME: this is kinda grotesque; there's gotta be a better way! ReceiveObjectMessageVAList(type, args); va_end(args); } |