diff --git a/storm/Core.cpp b/storm/Core.cpp index 5e85d02..0a4df63 100644 --- a/storm/Core.cpp +++ b/storm/Core.cpp @@ -1,7 +1,8 @@ #include "Core.hpp" #include "Event.hpp" -#include "Transparency.hpp" +#include "Region.hpp" #include "String.hpp" +#include "Transparency.hpp" int32_t STORMAPI StormDestroy() { // Combined list of all destroy calls found in every game (as documentation) @@ -11,7 +12,7 @@ int32_t STORMAPI StormDestroy() { // SGdiDestroy(); // SC 1.17 // SVidDestroy(); // SC 1.17 // SDrawDestroy(); // SC 1.17 - // SRgnDestroy(); // WoW 3.3.5 (win), SC 1.17 + SRgnDestroy(); // WoW 3.3.5 (win), SC 1.17 // SMsgDestroy(); // WoW 3.3.5 (win), SC 1.17 // SNetDestroy(); // SC 1.17 SEvtDestroy(); // WoW 3.3.5 (win) diff --git a/storm/Region.cpp b/storm/Region.cpp index 7fc986a..cbf1054 100644 --- a/storm/Region.cpp +++ b/storm/Region.cpp @@ -578,6 +578,10 @@ void STORMAPI SRgnDelete(HSRGN handle) { s_rgntable.Delete(handle); } +void STORMAPI SRgnDestroy() { + s_rgntable.Destroy(); +} + void STORMAPI SRgnDuplicate(HSRGN origHandle, HSRGN* handle, uint32_t reserved) { STORM_VALIDATE_BEGIN; STORM_VALIDATE(handle); diff --git a/storm/Region.hpp b/storm/Region.hpp index 125fc75..020bb7a 100644 --- a/storm/Region.hpp +++ b/storm/Region.hpp @@ -14,6 +14,8 @@ void STORMAPI SRgnCreate(HSRGN* handlePtr, uint32_t reserved = 0); void STORMAPI SRgnDelete(HSRGN handle); +void STORMAPI SRgnDestroy(); + void STORMAPI SRgnDuplicate(HSRGN origHandle, HSRGN* handle, uint32_t reserved = 0); void STORMAPI SRgnGetBoundingRectf(HSRGN handle, RECTF* rect); diff --git a/test/Core.cpp b/test/Core.cpp index c3382b4..36ef277 100644 --- a/test/Core.cpp +++ b/test/Core.cpp @@ -1,6 +1,7 @@ #include "test/Test.hpp" #include "EventTest.hpp" #include "storm/Core.hpp" +#include "storm/Region.hpp" TEST_CASE("StormDestroy", "[core]") { SECTION("always returns 1") { @@ -36,4 +37,19 @@ TEST_CASE("StormDestroy", "[core]") { CHECK(SEvtDispatch(0, 0, 0, nullptr) == 1); } } + + SECTION("SRgn") { + SECTION("destroys region handles") { + HSRGN rgn = nullptr; + SRgnCreate(&rgn); + REQUIRE(rgn != nullptr); // valid handle + + CHECK(StormDestroy() == 1); + + // fails to duplicate because handle is invalid + HSRGN newrgn; + SRgnDuplicate(rgn, &newrgn); + CHECK(newrgn == nullptr); + } + } } diff --git a/test/Region.cpp b/test/Region.cpp index e58a213..7f0f54a 100644 --- a/test/Region.cpp +++ b/test/Region.cpp @@ -691,6 +691,36 @@ TEST_CASE("SRgnDelete", "[region]") { } } +#if !defined(WHOA_TEST_STORMDLL) +TEST_CASE("SRgnDestroy", "[event]") { + SECTION("destroys all region handles") { + HSRGN rgn1 = nullptr, rgn2 = nullptr, rgn3 = nullptr; + HSRGN newrgn1, newrgn2, newrgn3, testrgn1, newtestrgn1; + + SRgnCreate(&rgn1); + SRgnCreate(&rgn2); + SRgnCreate(&rgn3); + REQUIRE(rgn1 != nullptr); + REQUIRE(rgn2 != nullptr); + REQUIRE(rgn3 != nullptr); + + SRgnDuplicate(rgn1, &testrgn1); + CHECK(testrgn1 != nullptr); + + SRgnDestroy(); + + SRgnDuplicate(rgn1, &newrgn1); + SRgnDuplicate(rgn2, &newrgn2); + SRgnDuplicate(rgn3, &newrgn3); + SRgnDuplicate(testrgn1, &newtestrgn1); + CHECK(newrgn1 == nullptr); + CHECK(newrgn2 == nullptr); + CHECK(newrgn3 == nullptr); + CHECK(newtestrgn1 == nullptr); + } +} +#endif + TEST_CASE("SRgnDuplicate", "[region]") { RgnDataTest region; RECTF baseRect = { -1.0f, 1.0f, 1.0f, 2.0f };