From 5521e7654d2a28551f0fda60e120be77f0a56a7c Mon Sep 17 00:00:00 2001 From: smallmodel <15067410+smallmodel@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:29:36 +0200 Subject: [PATCH] Fixed number of script classes being replaced by the number of threads, causing archive read to go wrong --- code/fgame/scriptmaster.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/code/fgame/scriptmaster.cpp b/code/fgame/scriptmaster.cpp index 2f77eacf..ff4d0713 100644 --- a/code/fgame/scriptmaster.cpp +++ b/code/fgame/scriptmaster.cpp @@ -893,38 +893,39 @@ void ScriptMaster::Archive(Archiver& arc) ScriptClass *scr; ScriptVM *m_current; ScriptThread *m_thread; - int num; + int numClasses; + int numThreads; int i, j; if (arc.Saving()) { - num = (int)ScriptClass_allocator.Count(); - arc.ArchiveInteger(&num); + numClasses = (int)ScriptClass_allocator.Count(); + arc.ArchiveInteger(&numClasses); MEM_BlockAlloc_enum en = ScriptClass_allocator; for (scr = en.NextElement(); scr != NULL; scr = en.NextElement()) { scr->ArchiveInternal(arc); - num = 0; + numThreads = 0; for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next) { - num++; + numThreads++; } - arc.ArchiveInteger(&num); + arc.ArchiveInteger(&numThreads); for (m_current = scr->m_Threads; m_current != NULL; m_current = m_current->next) { m_current->m_Thread->ArchiveInternal(arc); } } } else { - arc.ArchiveInteger(&num); + arc.ArchiveInteger(&numClasses); - for (i = 0; i < num; i++) { + for (i = 0; i < numClasses; i++) { scr = new ScriptClass(); scr->ArchiveInternal(arc); - arc.ArchiveInteger(&num); + arc.ArchiveInteger(&numThreads); - for (j = 0; j < num; j++) { + for (j = 0; j < numThreads; j++) { m_thread = new ScriptThread(scr, NULL); m_thread->ArchiveInternal(arc); }