Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More checkReferences-related tweaks / fixes, and sanity checks #3976

Merged
merged 3 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/ivis_opengl/tex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/objmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "combat.h"
#include "visibility.h"
#include "qtscript.h"
#include "order.h"
#include "wzcrashhandlingproviders.h"

#include <algorithm>
Expand Down Expand Up @@ -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:
Expand All @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading