mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 00:49:08 +00:00
chore(style): fix style nits
This commit is contained in:
parent
473a2cb044
commit
5121638c27
13 changed files with 88 additions and 86 deletions
|
|
@ -78,9 +78,9 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber) {
|
||||||
|
|
||||||
void SErrSetLastError(uint32_t errorcode) {
|
void SErrSetLastError(uint32_t errorcode) {
|
||||||
s_lasterror = errorcode;
|
s_lasterror = errorcode;
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
SetLastError(errorcode);
|
SetLastError(errorcode);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SErrGetLastError() {
|
uint32_t SErrGetLastError() {
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,12 @@
|
||||||
#define ERROR_INVALID_PARAMETER 0x57
|
#define ERROR_INVALID_PARAMETER 0x57
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#ifndef ASSERTIONS_ENABLED
|
#ifndef ASSERTIONS_ENABLED
|
||||||
#define ASSERTIONS_ENABLED
|
#define ASSERTIONS_ENABLED
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(ASSERTIONS_ENABLED)
|
#if defined(ASSERTIONS_ENABLED)
|
||||||
#define STORM_ASSERT(x) \
|
#define STORM_ASSERT(x) \
|
||||||
if (!(x)) { \
|
if (!(x)) { \
|
||||||
|
|
@ -38,7 +36,6 @@
|
||||||
#define STORM_ASSERT_FATAL(x)
|
#define STORM_ASSERT_FATAL(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(NDEBUG)
|
#if defined(NDEBUG)
|
||||||
#define STORM_VALIDATE_BEGIN { bool __storm_result = true
|
#define STORM_VALIDATE_BEGIN { bool __storm_result = true
|
||||||
#define STORM_VALIDATE(x) __storm_result &= !!(x); STORM_ASSERT(x)
|
#define STORM_VALIDATE(x) __storm_result &= !!(x); STORM_ASSERT(x)
|
||||||
|
|
@ -59,7 +56,6 @@
|
||||||
#define STORM_VALIDATE_END_VOID }
|
#define STORM_VALIDATE_END_VOID }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define STORM_ERROR_ASSERTION 0x85100000
|
#define STORM_ERROR_ASSERTION 0x85100000
|
||||||
#define STORM_ERROR_BAD_ARGUMENT 0x85100065
|
#define STORM_ERROR_BAD_ARGUMENT 0x85100065
|
||||||
#define STORM_ERROR_GAME_ALREADY_STARTED 0x85100066
|
#define STORM_ERROR_GAME_ALREADY_STARTED 0x85100066
|
||||||
|
|
@ -96,14 +92,12 @@
|
||||||
#define STORM_ERROR_GAME_TYPE_UNAVAILABLE 0x85100085
|
#define STORM_ERROR_GAME_TYPE_UNAVAILABLE 0x85100085
|
||||||
#define STORM_ERROR_FATAL_CONDITION 0x85100086
|
#define STORM_ERROR_FATAL_CONDITION 0x85100086
|
||||||
|
|
||||||
|
|
||||||
#define SERR_LINECODE_FUNCTION -1
|
#define SERR_LINECODE_FUNCTION -1
|
||||||
#define SERR_LINECODE_OBJECT -2
|
#define SERR_LINECODE_OBJECT -2
|
||||||
#define SERR_LINECODE_HANDLE -3
|
#define SERR_LINECODE_HANDLE -3
|
||||||
#define SERR_LINECODE_FILE -4
|
#define SERR_LINECODE_FILE -4
|
||||||
#define SERR_LINECODE_EXCEPTION -5 // exception handler
|
#define SERR_LINECODE_EXCEPTION -5 // exception handler
|
||||||
|
|
||||||
|
|
||||||
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...);
|
[[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);
|
int32_t SErrDisplayError(uint32_t errorcode, const char* filename, int32_t linenumber, const char* description, int32_t recoverable, uint32_t exitcode, uint32_t a7);
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
constexpr size_t ALIGNMENT = 8;
|
constexpr size_t ALIGNMENT = 8;
|
||||||
|
|
||||||
|
|
||||||
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags) {
|
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags) {
|
||||||
size_t alignedBytes = (bytes + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1);
|
size_t alignedBytes = (bytes + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#define SMEM_FLAG_ZEROMEMORY 0x8
|
||||||
#define SMEM_FLAG_ZEROMEMORY 8
|
|
||||||
|
|
||||||
|
|
||||||
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags = 0);
|
void* SMemAlloc(size_t bytes, const char* filename, int32_t linenumber, uint32_t flags = 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,13 @@
|
||||||
#include "storm/Thread.hpp"
|
#include "storm/Thread.hpp"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
static TSExportTableSyncReuse<RGN, HSRGN, HLOCKEDRGN, CCritSect> s_rgntable;
|
static TSExportTableSyncReuse<RGN, HSRGN, HLOCKEDRGN, CCritSect> s_rgntable;
|
||||||
|
|
||||||
|
|
||||||
void DeleteCombinedRect(TSGrowableArray<RECTF>* combinedArray, uint32_t index);
|
void DeleteCombinedRect(TSGrowableArray<RECTF>* combinedArray, uint32_t index);
|
||||||
void DeleteRect(RECTF* rect);
|
void DeleteRect(RECTF* rect);
|
||||||
void DeleteSourceRect(TSGrowableArray<SOURCE>* sourceArray, uint32_t index);
|
void DeleteSourceRect(TSGrowableArray<SOURCE>* sourceArray, uint32_t index);
|
||||||
int32_t IsNullRect(const RECTF* rect);
|
int32_t IsNullRect(const RECTF* rect);
|
||||||
|
|
||||||
|
|
||||||
void AddCombinedRect(TSGrowableArray<RECTF>* combinedArray, const RECTF* rect) {
|
void AddCombinedRect(TSGrowableArray<RECTF>* combinedArray, const RECTF* rect) {
|
||||||
RECTF* newRect = combinedArray->New();
|
RECTF* newRect = combinedArray->New();
|
||||||
*newRect = *rect;
|
*newRect = *rect;
|
||||||
|
|
@ -115,14 +112,18 @@ int SortFoundParamsCallback(const void* elem1, const void* elem2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindSourceParams(RGN* rgnptr, const RECTF* rect) {
|
void FindSourceParams(RGN* rgnptr, const RECTF* rect) {
|
||||||
if (CompareRects(rect, &rgnptr->foundparamsrect)) return;
|
if (CompareRects(rect, &rgnptr->foundparamsrect)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rgnptr->foundparams.SetCount(0);
|
rgnptr->foundparams.SetCount(0);
|
||||||
uint32_t sourceRects = rgnptr->source.Count();
|
uint32_t sourceRects = rgnptr->source.Count();
|
||||||
uint32_t params = 0;
|
uint32_t params = 0;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < sourceRects; i++) {
|
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 sequence = rgnptr->source[i].sequence;
|
||||||
int32_t found = 0;
|
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;
|
double result = rct1->top == rct2->top ? rct1->left - rct2->left : rct1->top - rct2->top;
|
||||||
|
|
||||||
if (result > 0.0) return 1;
|
if (result > 0.0) {
|
||||||
if (result < 0.0) return -1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result < 0.0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -387,7 +394,10 @@ void ProduceCombinedRectangles(RGN* rgn) {
|
||||||
std::qsort(rgn->combined.Ptr(), rgn->combined.Count(), sizeof(RECTF), SortRectCallback);
|
std::qsort(rgn->combined.Ptr(), rgn->combined.Count(), sizeof(RECTF), SortRectCallback);
|
||||||
|
|
||||||
for (uint32_t i = rgn->combined.Count(); i > 0; i = rgn->combined.Count()) {
|
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);
|
rgn->combined.SetCount(i - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -402,7 +412,9 @@ void SRgnCombineRectf(HSRGN handle, const RECTF* rect, void* param, int32_t comb
|
||||||
|
|
||||||
HLOCKEDRGN lockedHandle;
|
HLOCKEDRGN lockedHandle;
|
||||||
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
||||||
if (!rgn) return;
|
if (!rgn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (combineMode == SRGN_OR || combineMode == SRGN_PARAMONLY) {
|
if (combineMode == SRGN_OR || combineMode == SRGN_PARAMONLY) {
|
||||||
if (!IsNullRect(rect)) {
|
if (!IsNullRect(rect)) {
|
||||||
|
|
@ -502,7 +514,9 @@ void SRgnGetBoundingRectf(HSRGN handle, RECTF* rect) {
|
||||||
|
|
||||||
HLOCKEDRGN lockedHandle;
|
HLOCKEDRGN lockedHandle;
|
||||||
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
||||||
if (!rgn) return;
|
if (!rgn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < rgn->source.Count(); i++) {
|
for (uint32_t i = 0; i < rgn->source.Count(); i++) {
|
||||||
auto source = &rgn->source[i];
|
auto source = &rgn->source[i];
|
||||||
|
|
@ -602,7 +616,9 @@ int32_t SRgnIsPointInRegionf(HSRGN handle, float x, float y) {
|
||||||
|
|
||||||
HLOCKEDRGN lockedHandle;
|
HLOCKEDRGN lockedHandle;
|
||||||
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
||||||
if (!rgn) return 0;
|
if (!rgn) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
|
|
@ -630,7 +646,9 @@ int32_t SRgnIsRectInRegionf(HSRGN handle, const RECTF* rect) {
|
||||||
|
|
||||||
HLOCKEDRGN lockedHandle;
|
HLOCKEDRGN lockedHandle;
|
||||||
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
||||||
if (!rgn) return 0;
|
if (!rgn) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
|
|
@ -656,7 +674,9 @@ void SRgnOffsetf(HSRGN handle, float xoffset, float yoffset) {
|
||||||
|
|
||||||
HLOCKEDRGN lockedHandle;
|
HLOCKEDRGN lockedHandle;
|
||||||
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
||||||
if (!rgn) return;
|
if (!rgn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SOURCE* sourceArray = rgn->source.Ptr();
|
SOURCE* sourceArray = rgn->source.Ptr();
|
||||||
uint32_t sourceRects = rgn->source.Count();
|
uint32_t sourceRects = rgn->source.Count();
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,11 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
#define STORM_MAX_PATH 260
|
#define STORM_MAX_PATH 260
|
||||||
#define STORM_MAX_STR 0x7FFFFFFF
|
#define STORM_MAX_STR 0x7FFFFFFF
|
||||||
|
|
||||||
#define SSTR_HASH_CASESENSITIVE 1
|
#define SSTR_HASH_CASESENSITIVE 1
|
||||||
|
|
||||||
|
|
||||||
char* SStrChr(char* string, char search);
|
char* SStrChr(char* string, char search);
|
||||||
|
|
||||||
const char* SStrChr(const char* string, char search);
|
const char* SStrChr(const char* string, char search);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
#include "storm/Hash.hpp"
|
#include "storm/Hash.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
// region flgs
|
// Region flags
|
||||||
#define SF_NONE 0x00000000
|
#define SF_NONE 0x00000000
|
||||||
#define SF_ADDING 0x00000001
|
#define SF_ADDING 0x00000001
|
||||||
#define SF_OVERLAPS 0x00000002
|
#define SF_OVERLAPS 0x00000002
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
SSyncObject::SSyncObject() {
|
SSyncObject::SSyncObject() {
|
||||||
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
||||||
pthread_mutex_init(&this->m_mutex, 0);
|
pthread_mutex_init(&this->m_mutex, nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("SMemAlloc", "[memory]") {
|
TEST_CASE("SMemAlloc", "[memory]") {
|
||||||
SECTION("allocates memory") {
|
SECTION("allocates memory") {
|
||||||
void* ptr = SMemAlloc(16, __FILE__, __LINE__);
|
void* ptr = SMemAlloc(16, __FILE__, __LINE__);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include "RegionTest.hpp"
|
#include "RegionTest.hpp"
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("SRgnClear", "[region]") {
|
TEST_CASE("SRgnClear", "[region]") {
|
||||||
RgnDataTest region;
|
RgnDataTest region;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,23 +28,23 @@ std::ostream& operator <<(std::ostream& os, RECTF const& value) {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class RECTMatcher : public Catch::MatcherBase<T> {
|
class RECTMatcher : public Catch::MatcherBase<T> {
|
||||||
private:
|
private:
|
||||||
T cmp;
|
T cmp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RECTMatcher(T arg) : cmp(arg) {}
|
RECTMatcher(T arg) : cmp(arg) {}
|
||||||
|
|
||||||
bool match(T const& in) const override {
|
bool match(T const& in) const override {
|
||||||
return cmp.left == in.left && cmp.bottom == in.bottom && cmp.right == in.right && cmp.top == in.top;
|
return cmp.left == in.left && cmp.bottom == in.bottom && cmp.right == in.right && cmp.top == in.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string describe() const override {
|
std::string describe() const override {
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "equals " << cmp;
|
ss << "equals " << cmp;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RECTMatcher<RECTF> MatchesRect(RECTF arg) {
|
RECTMatcher<RECTF> MatchesRect(RECTF arg) {
|
||||||
return { arg };
|
return { arg };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,9 @@
|
||||||
#include "storm/Memory.hpp"
|
#include "storm/Memory.hpp"
|
||||||
#include "test/Test.hpp"
|
#include "test/Test.hpp"
|
||||||
|
|
||||||
#include <cfloat>
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("SStrChr const", "[string]") {
|
TEST_CASE("SStrChr const", "[string]") {
|
||||||
const char* string = "foobar";
|
const char* string = "foobar";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,5 @@
|
||||||
#include "test/Test.hpp"
|
#include "test/Test.hpp"
|
||||||
#include "storm/Big.hpp"
|
#include "storm/Big.hpp"
|
||||||
|
|
||||||
|
|
||||||
BigDataTest::BigDataTest() { SBigNew(&num); }
|
BigDataTest::BigDataTest() { SBigNew(&num); }
|
||||||
BigDataTest::~BigDataTest() { SBigDel(num); }
|
BigDataTest::~BigDataTest() { SBigDel(num); }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue