From 680284d785c0f8c15ee8d7586116b38d7a467d73 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Mon, 20 Dec 2021 12:16:18 +0800 Subject: [PATCH] Fixed crashes in HRP code Reverted the version string on the main menu. --- sfall/Game/tilemap.cpp | 7 ++++--- sfall/HRP/ViewMap/EdgeBorder.cpp | 1 + sfall/HRP/ViewMap/EdgeBorder.h | 9 +++++---- sfall/Modules/MainMenu.cpp | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/sfall/Game/tilemap.cpp b/sfall/Game/tilemap.cpp index 2a050c0c..1d580d54 100644 --- a/sfall/Game/tilemap.cpp +++ b/sfall/Game/tilemap.cpp @@ -220,7 +220,7 @@ static __inline long DistanceFromPositions(long sX, long sY, long tX, long tY) { } // optimized version with added args -// type: 1 - tile path, 0 - rotation path +// type: 0 - rotation path, 1 - tile path // maxNodes: limiting the building of a path long __fastcall Tilemap::make_path_func(fo::GameObject* srcObject, long sourceTile, long targetTile, long type, long maxNodes, void* arrayRef, long checkTargetTile, void* blockFunc) { if (checkTargetTile && fo::func::obj_blocking_at_wrapper(srcObject, targetTile, srcObject->elevation, blockFunc)) return 0; @@ -256,7 +256,7 @@ long __fastcall Tilemap::make_path_func(fo::GameObject* srcObject, long sourceTi // Tweak for NumPathNodes option if (maxNodes > 10000 && srcObject != fo::var::obj_dude && maxNodes == maxPathNodes) { - maxNodes = 10000; // limit for NPCs (maybe need less) + maxNodes = 10000; // limit for NPCs } // search path tiles @@ -357,7 +357,8 @@ long __fastcall Tilemap::make_path_func(fo::GameObject* srcObject, long sourceTi *arrayR++ = childData.rotation; } } - while (childData.from_tile != dadData->tile) --dadData; // search a linked tile 'from -> tile' + // search a linked tile 'from -> tile' + while (dadData->from_tile != -1 && childData.from_tile != dadData->tile) --dadData; childData = *dadData; } while (++pathLen < 800); diff --git a/sfall/HRP/ViewMap/EdgeBorder.cpp b/sfall/HRP/ViewMap/EdgeBorder.cpp index b2f06319..89be2067 100644 --- a/sfall/HRP/ViewMap/EdgeBorder.cpp +++ b/sfall/HRP/ViewMap/EdgeBorder.cpp @@ -197,6 +197,7 @@ static fo::DbFile* LoadMapEdgeFileSub(char* mapName) { if (getValue != mapLevel) break; // next level EdgeBorder::Edge *edge = new EdgeBorder::Edge; + edge->clipData = 0; edge->prevEdgeData = edgeData; edge->nextEdgeData = nullptr; edge->squareRect = edgeData->squareRect; // rect copy diff --git a/sfall/HRP/ViewMap/EdgeBorder.h b/sfall/HRP/ViewMap/EdgeBorder.h index 1d861251..49eb5f22 100644 --- a/sfall/HRP/ViewMap/EdgeBorder.h +++ b/sfall/HRP/ViewMap/EdgeBorder.h @@ -17,10 +17,10 @@ public: RECT borderRect; // right is less than left RECT rect_2; RECT tileRect; - RECT squareRect; // angel clipping - long clipData; // angel clip type - Edge* prevEdgeData; // unused (used in 3.06) - Edge* nextEdgeData; + RECT squareRect; // angel clipping + long clipData; // angel clip type + Edge* prevEdgeData = nullptr; // unused (used in 3.06) + Edge* nextEdgeData = nullptr; void Release() { Edge* edge = nextEdgeData; @@ -28,6 +28,7 @@ public: Edge* edgeNext = edge->nextEdgeData; delete edge; edge = edgeNext; + nextEdgeData = nullptr; }; } diff --git a/sfall/Modules/MainMenu.cpp b/sfall/Modules/MainMenu.cpp index 4eac0ea8..c9d47673 100644 --- a/sfall/Modules/MainMenu.cpp +++ b/sfall/Modules/MainMenu.cpp @@ -28,9 +28,9 @@ namespace sfall { #ifdef NDEBUG -static const char* VerString1 = "SFALL w/ HRP " VERSION_STRING; +static const char* VerString1 = "SFALL " VERSION_STRING; #else -static const char* VerString1 = "SFALL w/ HRP " VERSION_STRING " Debug Build"; +static const char* VerString1 = "SFALL " VERSION_STRING " Debug Build"; #endif long MainMenu::mXOffset;