From eae0c144dfad8245bc4a3259e3abddd3ccc7ca92 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:40:22 -0400 Subject: [PATCH 1/3] aiUpdateRepair_handleEvents: Reset REPAIR_FACILITY.psObj --- src/structure.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/structure.cpp b/src/structure.cpp index 5857c08eb7b..2fe90849eff 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -2918,6 +2918,7 @@ RepairState aiUpdateRepair_handleEvents(STRUCTURE &station, RepairEvents ev, DRO if (bMultiPlayer && psStructure->resistance < (int)structureResistance(psStructure->pStructureType, psStructure->player)) { objTrace(psStructure->id, "Resistance too low for repair"); + psRepairFac->psObj = nullptr; return RepairState::Idle; } switch (ev) From 7c2ad1b48f5c8fe9f51cc6b1d96f1cbc2afda93b Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sat, 6 Jul 2024 11:52:36 -0400 Subject: [PATCH 2/3] Tweak checkReferences logging --- src/objmem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/objmem.cpp b/src/objmem.cpp index 4eb5da00363..af86063a757 100644 --- a/src/objmem.cpp +++ b/src/objmem.cpp @@ -41,6 +41,7 @@ #include "combat.h" #include "visibility.h" #include "qtscript.h" +#include "order.h" #include "wzcrashhandlingproviders.h" #include @@ -183,7 +184,7 @@ static bool _checkStructReferences(BASE_OBJECT *psVictim, const StructureList& p case REF_REPAIR_FACILITY: { REPAIR_FACILITY *psRepairFac = &psStruct->pFunctionality->repairFacility; - ASSERT_OR_RETURN_REPORT(false, psRepairFac->psObj != psVictim, "Illegal reference to p%d:%s:%" PRIu32 " (%s) in REPAIR_FACILITY.psObj in %s[%u]", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player); + ASSERT_OR_RETURN_REPORT(false, psRepairFac->psObj != psVictim, "Illegal reference to p%d:%s:%" PRIu32 " (%s) in REPAIR_FACILITY.psObj in %s[%u] (state=%d)", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player, (int)psRepairFac->state); break; } case REF_REARM_PAD: @@ -209,9 +210,9 @@ static bool _checkDroidReferences(BASE_OBJECT *psVictim, const DroidList& psPlay continue; // Don't worry about self references. } - ASSERT_OR_RETURN_REPORT(false, psDroid->order.psObj != psVictim, "Illegal reference to p%d:%s:%d (%s) in order.psObj in %s[%u]", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player); + ASSERT_OR_RETURN_REPORT(false, psDroid->order.psObj != psVictim, "Illegal reference to p%d:%s:%d (%s) in order.psObj in %s[%u] (%s:%d - %s) (order.type: %s)", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player, objTypeToStr(psDroid->type), psDroid->id, getObjDebugDescriptiveName(psDroid), getDroidOrderName(psDroid->order.type)); - ASSERT_OR_RETURN_REPORT(false, psDroid->psBaseStruct != psVictim, "Illegal reference to p%d:%s:%d (%s) in psBaseStruct in %s[%u]", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player); + ASSERT_OR_RETURN_REPORT(false, psDroid->psBaseStruct != psVictim, "Illegal reference to p%d:%s:%d (%s) in psBaseStruct in %s[%u] (%s:%d - %s)", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player, objTypeToStr(psDroid->type), psDroid->id, getObjDebugDescriptiveName(psDroid)); for (unsigned i = 0; i < psDroid->numWeaps; ++i) { From a8902bee5e7301cad1c744288695d2d59b9f1aaf Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Sat, 6 Jul 2024 12:20:03 -0400 Subject: [PATCH 3/3] pie_AssignTexture: Sanity check --- lib/ivis_opengl/tex.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ivis_opengl/tex.cpp b/lib/ivis_opengl/tex.cpp index 39c235d575f..a566a903b7e 100644 --- a/lib/ivis_opengl/tex.cpp +++ b/lib/ivis_opengl/tex.cpp @@ -106,6 +106,12 @@ size_t pie_ReserveTexture(const char *filename, const size_t& width, const size_ void pie_AssignTexture(size_t page, gfx_api::texture* texture) { + if (page >= _TEX_PAGE.size()) + { + debug(LOG_ERROR, "Invalid page (%zu), number of texpages=%zu", page, _TEX_PAGE.size()); + delete texture; + return; + } if (_TEX_PAGE[page].id) delete _TEX_PAGE[page].id; _TEX_PAGE[page].id = texture;