Skip to content

Commit

Permalink
Merge branch 'dev' into Resistance_tickfix2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhobean committed Feb 4, 2025
2 parents 36a1f10 + 0128420 commit 66e37a9
Show file tree
Hide file tree
Showing 48 changed files with 1,499 additions and 837 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_aux_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- 'master'
- 'main'
- 'dev'
paths-ignore:
- '*.txt'
- '*.md'

jobs:
upload_github_release:
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/build_linux_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@ name: Linux x86

on:
push:
branches:
- 'master'
- 'main'
- 'dev'
# branches:
# - 'master'
# - 'main'
# - 'dev'
paths-ignore:
- '.gitignore'
- '.gitattributes'
- '**.txt'
- '**.md'
- '**.rc'
pull_request:
branches:
- 'master'
- 'main'
- 'dev'
paths-ignore:
- '*.txt'
- '*.md'

jobs:
linux-x86:
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/build_linux_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: Linux x86_64

on:
push:
branches:
- 'master'
- 'main'
- 'dev'
# branches:
# - 'master'
# - 'main'
# - 'dev'
paths-ignore:
- '.gitignore'
- '.gitattributes'
- '**.txt'
- '**.md'
- '**.rc'
pull_request:
branches:
- 'master'
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/build_osx_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: MacOS ARM

on:
push:
branches:
- 'master'
- 'main'
- 'dev'
# branches:
# - 'master'
# - 'main'
# - 'dev'
paths-ignore:
- '.gitignore'
- '.gitattributes'
- '**.txt'
- '**.md'
- '**.rc'
pull_request:
branches:
- 'master'
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/build_osx_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: MacOS x86_64

on:
push:
branches:
- 'master'
- 'main'
- 'dev'
# branches:
# - 'master'
# - 'main'
# - 'dev'
paths-ignore:
- '.gitignore'
- '.gitattributes'
- '**.txt'
- '**.md'
- '**.rc'
pull_request:
branches:
- 'master'
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/build_win_x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: Windows x86

on:
push:
branches:
- 'master'
- 'main'
- 'dev'
# branches:
# - 'master'
# - 'main'
# - 'dev'
paths-ignore:
- '.gitignore'
- '.gitattributes'
- '**.txt'
- '**.md'
- '**.rc'
pull_request:
branches:
- 'master'
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/build_win_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ name: Windows x86_64

on:
push:
branches:
- 'master'
- 'main'
- 'dev'
# branches:
# - 'master'
# - 'main'
# - 'dev'
paths-ignore:
- '.gitignore'
- '.gitattributes'
- '**.txt'
- '**.md'
- '**.rc'
pull_request:
branches:
- 'master'
Expand Down
1 change: 1 addition & 0 deletions src/common/CException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ bool CWinStructuredException::GetErrorMessage(lptstr lpszError, uint uiMaxError)
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------

[[noreturn]]
void Assert_Fail( lpctstr pExp, lpctstr pFile, long long llLine )
{
EXC_NOTIFY_DEBUGGER;
Expand Down
26 changes: 13 additions & 13 deletions src/common/CException.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ class CAssert : public CSError
/*--- Main (non SUB) macros ---*/

// EXC_TRY
#define EXC_TRY(a) \
#define EXC_TRY(ptcMethodName) \
lpctstr inLocalBlock = ""; \
lpctstr inLocalArgs = a; \
lpctstr inLocalArgs = ptcMethodName; \
uint inLocalBlockCnt = 0; /* NOLINT(misc-const-correctness) */ \
bool fCATCHExcept = false; \
UnreferencedParameter(fCATCHExcept); \
try \
{

// EXC_SET_BLOCK
#define EXC_SET_BLOCK(a) \
inLocalBlock = a; \
#define EXC_SET_BLOCK(ptcBlockName) \
inLocalBlock = ptcBlockName; \
++inLocalBlockCnt

// _EXC_CATCH_EXCEPTION_GENERIC (used inside other macros! don't use it manually!)
Expand Down Expand Up @@ -217,18 +217,18 @@ class CAssert : public CSError
/*--- SUB macros ---*/

// EXC_TRYSUB
#define EXC_TRYSUB(a) \
#define EXC_TRYSUB(ptcMethodName) \
lpctstr inLocalSubBlock = ""; \
lpctstr inLocalSubArgs = a; \
lpctstr inLocalSubArgs = ptcMethodName; \
uint inLocalSubBlockCnt = 0; \
bool fCATCHExceptSub = false; \
UnreferencedParameter(fCATCHExceptSub); \
try \
{

// EXC_SETSUB_BLOCK
#define EXC_SETSUB_BLOCK(a) \
inLocalSubBlock = a; \
#define EXC_SETSUB_BLOCK(ptcBlockName) \
inLocalSubBlock = ptcBlockName; \
++inLocalSubBlockCnt

// _EXC_CATCH_SUB_EXCEPTION_GENERIC(a,b, "ExceptionType") (used inside other macros! don't use it manually!)
Expand All @@ -252,28 +252,28 @@ class CAssert : public CSError
_EXC_CAUGHT

// EXC_CATCHSUB(a)
#define EXC_CATCHSUB(a) \
#define EXC_CATCHSUB(ptcCatchContext) \
} \
catch ( const CAssert& e ) \
{ \
_EXC_CATCH_SUB_EXCEPTION_GENERIC(&e, a, "CAssert"); \
_EXC_CATCH_SUB_EXCEPTION_GENERIC(&e, ptcCatchContext, "CAssert"); \
GetCurrentProfileData().Count(PROFILE_STAT_FAULTS, 1); \
} \
catch ( const CSError& e ) \
{ \
_EXC_CATCH_SUB_EXCEPTION_GENERIC(&e, a, "CSError"); \
_EXC_CATCH_SUB_EXCEPTION_GENERIC(&e, ptcCatchContext, "CSError"); \
GetCurrentProfileData().Count(PROFILE_STAT_FAULTS, 1); \
EXC_NOTIFY_DEBUGGER; \
} \
catch ( const std::exception& e ) \
{ \
_EXC_CATCH_SUB_EXCEPTION_STD(&e, a); \
_EXC_CATCH_SUB_EXCEPTION_STD(&e, ptcCatchContext); \
GetCurrentProfileData().Count(PROFILE_STAT_FAULTS, 1); \
EXC_NOTIFY_DEBUGGER; \
} \
catch (...) \
{ \
_EXC_CATCH_SUB_EXCEPTION_GENERIC(nullptr, a, "pure"); \
_EXC_CATCH_SUB_EXCEPTION_GENERIC(nullptr, ptcCatchContext, "pure"); \
GetCurrentProfileData().Count(PROFILE_STAT_FAULTS, 1); \
EXC_NOTIFY_DEBUGGER; \
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/CPointBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ DIR_TYPE GetDirTurn( DIR_TYPE dir, int offset )
lpctstr CPointBase::sm_szDirs[] {"\0"};
void CPointBase::InitRuntimeDefaultValues()
{
AssignInitlistToCSizedArray(
sl::AssignInitlistToCSizedArray(
CPointBase::sm_szDirs, ARRAY_COUNT(CPointBase::sm_szDirs),
{
g_Cfg.GetDefaultMsg(DEFMSG_MAP_DIR_0),
Expand Down
4 changes: 2 additions & 2 deletions src/common/CScriptObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ bool CScriptObj::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command f
pChar->m_Act_UID = g_World.m_uidNew;
else
{
const CClient *pClient = dynamic_cast<CClient *>(this);
CClient *pClient = dynamic_cast<CClient *>(this);
if ( pClient && pClient->GetChar() )
pClient->GetChar()->m_Act_UID = g_World.m_uidNew;
}
Expand Down Expand Up @@ -1465,7 +1465,7 @@ bool CScriptObj::r_Verb( CScript & s, CTextConsole * pSrc ) // Execute command f
pCharSrc->m_Act_UID = g_World.m_uidNew;
else
{
const CClient *pClient = dynamic_cast<CClient *>(this);
CClient *pClient = dynamic_cast<CClient *>(this);
if (pClient && pClient->GetChar())
pClient->GetChar()->m_Act_UID = g_World.m_uidNew;
}
Expand Down
9 changes: 7 additions & 2 deletions src/common/CTextConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@

extern CSStringList g_AutoComplete;

CChar * CTextConsole::GetChar() const
CChar * CTextConsole::GetChar()
{
return const_cast <CChar *>( dynamic_cast <const CChar *>( this ));
return dynamic_cast <CChar *>( this );
}
const CChar * CTextConsole::GetChar() const
{
return dynamic_cast <const CChar *>( this );
}


int CTextConsole::OnConsoleKey( CSString & sText, tchar nChar, bool fEcho )
{
Expand Down
3 changes: 2 additions & 1 deletion src/common/CTextConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class CTextConsole
// What privs do i have ?
virtual PLEVEL_TYPE GetPrivLevel() const = 0;
virtual lpctstr GetName() const = 0; // ( every object must have at least a type name )
virtual CChar * GetChar() const; // are we also a CChar ? dynamic_cast ?
virtual CChar * GetChar(); // are we also a CChar ? dynamic_cast ?
virtual const CChar * GetChar() const;

virtual void SysMessage( lpctstr pszMessage ) const = 0; // Feed back message.
void VSysMessage( lpctstr pszFormat, va_list args ) const;
Expand Down
1 change: 1 addition & 0 deletions src/common/assertion.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#endif
#endif

[[noreturn]]
extern void Assert_Fail(const char * pExp, const char *pFile, long long llLine);

#define ASSERT_ALWAYS(exp) if ( !(exp) ) [[unlikely]] Assert_Fail(#exp, __FILE__, __LINE__)
Expand Down
53 changes: 53 additions & 0 deletions src/common/sphere_library/scontainer_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
#include <cstddef>
#include <initializer_list>

namespace sl
{

// Define a concept for STL containers
template <typename T>
concept ConceptBasicContainer = requires(T t)
{
// Type must have an iterator type
typename T::iterator;

// Must have a begin() method returning an iterator
{ t.begin() } -> std::same_as<typename T::iterator>;

// Must have an end() method returning an iterator
{ t.end() } -> std::same_as<typename T::iterator>;
};


template<typename inT, typename outT>
void AssignInitlistToCSizedArray(outT* dest, const size_t dest_size, std::initializer_list<inT> initializer) noexcept
{
Expand All @@ -17,4 +35,39 @@ void AssignInitlistToCSizedArray(outT* dest, const size_t dest_size, std::initia
}
}

template <ConceptBasicContainer T>
bool ContainerIsSorted(T const& cont)
{
return std::is_sorted(cont.begin(), cont.end());
}

template <ConceptBasicContainer T>
bool SortedContainerHasDuplicates(T const& cont)
{
return std::adjacent_find(cont.begin(), cont.end()) != cont.end();
}

/*
template <ConceptBasicContainer ContT, typename PredT>
bool SortedContainerHasDuplicatesPred(ContT const& cont, PredT const& predicate)
{
return std::adjacent_find(cont.begin(), cont.end(), predicate) == cont.end();
}
*/

template <ConceptBasicContainer T>
bool UnsortedContainerHasDuplicates(const T& cont) noexcept
{
for (size_t i = 0; i < cont.size(); ++i) {
for (size_t j = i + 1; j < cont.size(); ++j) {
if ((i != j) && (cont[i] == cont[j])) {
return true; // Found a duplicate
}
}
}
return false; // No duplicates found
}

} // namespace sl

#endif // INC_CONTAINER_OPS_H
Loading

0 comments on commit 66e37a9

Please sign in to comment.