chore(style): fix style nits

This commit is contained in:
fallenoak 2025-09-03 22:15:59 -05:00
parent 473a2cb044
commit 5121638c27
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
13 changed files with 88 additions and 86 deletions

View file

@ -78,9 +78,9 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber) {
void SErrSetLastError(uint32_t errorcode) {
s_lasterror = errorcode;
#if defined(WHOA_SYSTEM_WIN)
#if defined(WHOA_SYSTEM_WIN)
SetLastError(errorcode);
#endif
#endif
}
uint32_t SErrGetLastError() {

View file

@ -14,14 +14,12 @@
#define ERROR_INVALID_PARAMETER 0x57
#endif
#ifdef _DEBUG
#ifndef ASSERTIONS_ENABLED
#define ASSERTIONS_ENABLED
#endif
#endif
#if defined(ASSERTIONS_ENABLED)
#define STORM_ASSERT(x) \
if (!(x)) { \
@ -38,7 +36,6 @@
#define STORM_ASSERT_FATAL(x)
#endif
#if defined(NDEBUG)
#define STORM_VALIDATE_BEGIN { bool __storm_result = true
#define STORM_VALIDATE(x) __storm_result &= !!(x); STORM_ASSERT(x)
@ -59,7 +56,6 @@
#define STORM_VALIDATE_END_VOID }
#endif
#define STORM_ERROR_ASSERTION 0x85100000
#define STORM_ERROR_BAD_ARGUMENT 0x85100065
#define STORM_ERROR_GAME_ALREADY_STARTED 0x85100066
@ -96,14 +92,12 @@
#define STORM_ERROR_GAME_TYPE_UNAVAILABLE 0x85100085
#define STORM_ERROR_FATAL_CONDITION 0x85100086
#define SERR_LINECODE_FUNCTION -1
#define SERR_LINECODE_OBJECT -2
#define SERR_LINECODE_HANDLE -3
#define SERR_LINECODE_FILE -4
#define SERR_LINECODE_EXCEPTION -5 // exception handler
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...);
int32_t SErrDisplayError(uint32_t errorcode, const char* filename, int32_t linenumber, const char* description, int32_t recoverable, uint32_t exitcode, uint32_t a7);

View file

@ -2,10 +2,8 @@
#include <cstring>
constexpr size_t ALIGNMENT = 8;
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags) {
size_t alignedBytes = (bytes + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1);

View file

@ -4,9 +4,7 @@
#include <cstdint>
#include <cstdlib>
#define SMEM_FLAG_ZEROMEMORY 8
#define SMEM_FLAG_ZEROMEMORY 0x8
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags = 0);

View file

@ -5,16 +5,13 @@
#include "storm/Thread.hpp"
#include <limits>
static TSExportTableSyncReuse<RGN, HSRGN, HLOCKEDRGN, CCritSect> s_rgntable;
void DeleteCombinedRect(TSGrowableArray<RECTF>* combinedArray, uint32_t index);
void DeleteRect(RECTF* rect);
void DeleteSourceRect(TSGrowableArray<SOURCE>* sourceArray, uint32_t index);
int32_t IsNullRect(const RECTF* rect);
void AddCombinedRect(TSGrowableArray<RECTF>* combinedArray, const RECTF* rect) {
RECTF* newRect = combinedArray->New();
*newRect = *rect;
@ -115,14 +112,18 @@ int SortFoundParamsCallback(const void* elem1, const void* elem2) {
}
void FindSourceParams(RGN* rgnptr, const RECTF* rect) {
if (CompareRects(rect, &rgnptr->foundparamsrect)) return;
if (CompareRects(rect, &rgnptr->foundparamsrect)) {
return;
}
rgnptr->foundparams.SetCount(0);
uint32_t sourceRects = rgnptr->source.Count();
uint32_t params = 0;
for (uint32_t i = 0; i < sourceRects; i++) {
if (!CheckForIntersection(rect, &rgnptr->source[i].rect)) continue;
if (!CheckForIntersection(rect, &rgnptr->source[i].rect)) {
continue;
}
int32_t sequence = rgnptr->source[i].sequence;
int32_t found = 0;
@ -366,8 +367,14 @@ int SortRectCallback(const void* elem1, const void* elem2) {
double result = rct1->top == rct2->top ? rct1->left - rct2->left : rct1->top - rct2->top;
if (result > 0.0) return 1;
if (result < 0.0) return -1;
if (result > 0.0) {
return 1;
}
if (result < 0.0) {
return -1;
}
return 0;
}
@ -387,7 +394,10 @@ void ProduceCombinedRectangles(RGN* rgn) {
std::qsort(rgn->combined.Ptr(), rgn->combined.Count(), sizeof(RECTF), SortRectCallback);
for (uint32_t i = rgn->combined.Count(); i > 0; i = rgn->combined.Count()) {
if (!IsNullRect(&rgn->combined[i-1])) break;
if (!IsNullRect(&rgn->combined[i-1])) {
break;
}
rgn->combined.SetCount(i - 1);
}
}
@ -402,7 +412,9 @@ void SRgnCombineRectf(HSRGN handle, const RECTF* rect, void* param, int32_t comb
HLOCKEDRGN lockedHandle;
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
if (!rgn) return;
if (!rgn) {
return;
}
if (combineMode == SRGN_OR || combineMode == SRGN_PARAMONLY) {
if (!IsNullRect(rect)) {
@ -502,7 +514,9 @@ void SRgnGetBoundingRectf(HSRGN handle, RECTF* rect) {
HLOCKEDRGN lockedHandle;
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
if (!rgn) return;
if (!rgn) {
return;
}
for (uint32_t i = 0; i < rgn->source.Count(); i++) {
auto source = &rgn->source[i];
@ -602,7 +616,9 @@ int32_t SRgnIsPointInRegionf(HSRGN handle, float x, float y) {
HLOCKEDRGN lockedHandle;
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
if (!rgn) return 0;
if (!rgn) {
return 0;
}
int32_t result = 0;
@ -630,7 +646,9 @@ int32_t SRgnIsRectInRegionf(HSRGN handle, const RECTF* rect) {
HLOCKEDRGN lockedHandle;
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
if (!rgn) return 0;
if (!rgn) {
return 0;
}
int32_t result = 0;
@ -656,7 +674,9 @@ void SRgnOffsetf(HSRGN handle, float xoffset, float yoffset) {
HLOCKEDRGN lockedHandle;
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
if (!rgn) return;
if (!rgn) {
return;
}
SOURCE* sourceArray = rgn->source.Ptr();
uint32_t sourceRects = rgn->source.Count();

View file

@ -5,13 +5,11 @@
#include <cstdint>
#include <cstdlib>
#define STORM_MAX_PATH 260
#define STORM_MAX_STR 0x7FFFFFFF
#define SSTR_HASH_CASESENSITIVE 1
char* SStrChr(char* string, char search);
const char* SStrChr(const char* string, char search);

View file

@ -6,7 +6,7 @@
#include "storm/Hash.hpp"
#include <cstdint>
// region flgs
// Region flags
#define SF_NONE 0x00000000
#define SF_ADDING 0x00000001
#define SF_OVERLAPS 0x00000002

View file

@ -8,7 +8,7 @@
SSyncObject::SSyncObject() {
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
pthread_mutex_init(&this->m_mutex, 0);
pthread_mutex_init(&this->m_mutex, nullptr);
#endif
}

View file

@ -5,7 +5,6 @@
#include <numeric>
#include <vector>
TEST_CASE("SMemAlloc", "[memory]") {
SECTION("allocates memory") {
void* ptr = SMemAlloc(16, __FILE__, __LINE__);

View file

@ -1,7 +1,6 @@
#include "RegionTest.hpp"
#include <cfloat>
TEST_CASE("SRgnClear", "[region]") {
RgnDataTest region;

View file

@ -28,23 +28,23 @@ std::ostream& operator <<(std::ostream& os, RECTF const& value) {
template <class T>
class RECTMatcher : public Catch::MatcherBase<T> {
private:
T cmp;
private:
T cmp;
public:
RECTMatcher(T arg) : cmp(arg) {}
public:
RECTMatcher(T arg) : cmp(arg) {}
bool match(T const& in) const override {
return cmp.left == in.left && cmp.bottom == in.bottom && cmp.right == in.right && cmp.top == in.top;
}
bool match(T const& in) const override {
return cmp.left == in.left && cmp.bottom == in.bottom && cmp.right == in.right && cmp.top == in.top;
}
std::string describe() const override {
std::ostringstream ss;
ss << "equals " << cmp;
return ss.str();
}
std::string describe() const override {
std::ostringstream ss;
ss << "equals " << cmp;
return ss.str();
}
};
RECTMatcher<RECTF> MatchesRect(RECTF arg) {
return { arg };
return { arg };
}

View file

@ -2,11 +2,9 @@
#include "storm/Memory.hpp"
#include "test/Test.hpp"
#include <cfloat>
#include <cstdarg>
#include <type_traits>
TEST_CASE("SStrChr const", "[string]") {
const char* string = "foobar";

View file

@ -2,7 +2,5 @@
#include "test/Test.hpp"
#include "storm/Big.hpp"
BigDataTest::BigDataTest() { SBigNew(&num); }
BigDataTest::~BigDataTest() { SBigDel(num); }