forked from metin-server/m2dev-client-src
Merge pull request #19 from mq1n/main
crash fixes, ASan support and setup GitHub actions workflow
This commit is contained in:
35
.github/workflows/main.yml
vendored
Normal file
35
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
win:
|
||||||
|
name: "Windows Build"
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build project
|
||||||
|
id: build_project
|
||||||
|
shell: pwsh
|
||||||
|
working-directory: ${{ github.workspace }}
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
cmake --build . --config RelWithDebInfo
|
||||||
|
|
||||||
|
- name: Collect outputs
|
||||||
|
run: |
|
||||||
|
mkdir _output
|
||||||
|
cp build/bin/* _output
|
||||||
|
|
||||||
|
- name: Upload
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: output_win
|
||||||
|
path: _output
|
||||||
@@ -5,6 +5,9 @@ project(m2dev-client-src)
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# ASan support
|
||||||
|
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH
|
set(CMAKE_MODULE_PATH
|
||||||
${CMAKE_MODULE_PATH}
|
${CMAKE_MODULE_PATH}
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/buildtool"
|
"${CMAKE_CURRENT_SOURCE_DIR}/buildtool"
|
||||||
@@ -28,6 +31,19 @@ add_compile_options(
|
|||||||
$<$<CXX_COMPILER_ID:MSVC>:/wd4996>
|
$<$<CXX_COMPILER_ID:MSVC>:/wd4996>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ASan flags
|
||||||
|
if(ENABLE_ASAN)
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(/fsanitize=address)
|
||||||
|
add_link_options(/fsanitize=address)
|
||||||
|
add_definitions(-D_DISABLE_VECTOR_ANNOTATION)
|
||||||
|
add_definitions(-D_DISABLE_STRING_ANNOTATION)
|
||||||
|
else()
|
||||||
|
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
||||||
|
add_link_options(-fsanitize=address)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_definitions(-DNOMINMAX)
|
add_definitions(-DNOMINMAX)
|
||||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
|||||||
@@ -90,6 +90,14 @@ void CEffectElementBaseInstance::Destroy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CEffectElementBaseInstance::CEffectElementBaseInstance()
|
CEffectElementBaseInstance::CEffectElementBaseInstance()
|
||||||
|
: mc_pmatLocal(nullptr)
|
||||||
|
, m_isActive(false)
|
||||||
|
, m_fLocalTime(0.0f)
|
||||||
|
, m_dwStartTime(0)
|
||||||
|
, m_fElapsedTime(0.0f)
|
||||||
|
, m_fRemainingTime(0.0f)
|
||||||
|
, m_bStart(false)
|
||||||
|
, m_pBase(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
CEffectElementBaseInstance::~CEffectElementBaseInstance()
|
CEffectElementBaseInstance::~CEffectElementBaseInstance()
|
||||||
|
|||||||
@@ -216,22 +216,14 @@ public:
|
|||||||
public:
|
public:
|
||||||
DecryptBuffer(unsigned size)
|
DecryptBuffer(unsigned size)
|
||||||
{
|
{
|
||||||
static unsigned count = 0;
|
|
||||||
static unsigned sum = 0;
|
|
||||||
static unsigned maxSize = 0;
|
|
||||||
|
|
||||||
sum += size;
|
|
||||||
count++;
|
|
||||||
|
|
||||||
maxSize = std::max(size, maxSize);
|
|
||||||
if (size >= LOCAL_BUF_SIZE)
|
if (size >= LOCAL_BUF_SIZE)
|
||||||
{
|
{
|
||||||
m_buf = new char[size];
|
m_buf = new char[size];
|
||||||
dbg_printf("DecryptBuffer - AllocHeap %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count);
|
dbg_printf("DecryptBuffer - AllocHeap %d\n", size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbg_printf("DecryptBuffer - AllocStack %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count);
|
dbg_printf("DecryptBuffer - AllocStack %d\n", size);
|
||||||
m_buf = m_local_buf;
|
m_buf = m_local_buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,12 +231,12 @@ public:
|
|||||||
{
|
{
|
||||||
if (m_local_buf != m_buf)
|
if (m_local_buf != m_buf)
|
||||||
{
|
{
|
||||||
dbg_printf("DecruptBuffer - FreeHeap\n");
|
dbg_printf("DecryptBuffer - FreeHeap\n");
|
||||||
delete [] m_buf;
|
delete [] m_buf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbg_printf("DecruptBuffer - FreeStack\n");
|
dbg_printf("DecryptBuffer - FreeStack\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void* GetBufferPtr()
|
void* GetBufferPtr()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ void CGraphicObjectInstance::Clear()
|
|||||||
m_isVisible = TRUE;
|
m_isVisible = TRUE;
|
||||||
|
|
||||||
m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f;
|
m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f;
|
||||||
m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 0.0f;
|
m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 1.0f;
|
||||||
//m_fRotation = 0.0f;
|
//m_fRotation = 0.0f;
|
||||||
m_fYaw = m_fPitch = m_fRoll = 0.0f;
|
m_fYaw = m_fPitch = m_fRoll = 0.0f;
|
||||||
D3DXMatrixIdentity(&m_worldMatrix);
|
D3DXMatrixIdentity(&m_worldMatrix);
|
||||||
@@ -278,12 +278,22 @@ void CGraphicObjectInstance::Initialize()
|
|||||||
m_BlockCamera = false;
|
m_BlockCamera = false;
|
||||||
|
|
||||||
m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f;
|
m_v3Position.x = m_v3Position.y = m_v3Position.z = 0.0f;
|
||||||
m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 0.0f;
|
m_v3Scale.x = m_v3Scale.y = m_v3Scale.z = 1.0f;
|
||||||
m_fYaw = m_fPitch = m_fRoll = 0.0f;
|
m_fYaw = m_fPitch = m_fRoll = 0.0f;
|
||||||
|
|
||||||
D3DXMatrixIdentity(&m_worldMatrix);
|
D3DXMatrixIdentity(&m_worldMatrix);
|
||||||
D3DXMatrixIdentity(&m_mRotation);
|
D3DXMatrixIdentity(&m_mRotation);
|
||||||
|
|
||||||
|
m_v3TBBoxMin = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||||
|
m_v3TBBoxMax = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||||
|
m_v3BBoxMin = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||||
|
m_v3BBoxMax = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; ++i)
|
||||||
|
m_v4TBBox[i] = D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
memset(m_abyPortalID, 0, sizeof(m_abyPortalID));
|
||||||
|
|
||||||
ClearCollision();
|
ClearCollision();
|
||||||
OnInitialize();
|
OnInitialize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -830,7 +830,8 @@ void CIME::DelCurPos()
|
|||||||
if (ms_curpos < ms_lastpos)
|
if (ms_curpos < ms_lastpos)
|
||||||
{
|
{
|
||||||
int eraseCount = FindColorTagEndPosition(m_wText + ms_curpos, ms_lastpos - ms_curpos) + 1;
|
int eraseCount = FindColorTagEndPosition(m_wText + ms_curpos, ms_lastpos - ms_curpos) + 1;
|
||||||
wcscpy(m_wText + ms_curpos, m_wText + ms_curpos + eraseCount);
|
size_t remainingChars = ms_lastpos - ms_curpos - eraseCount + 1; // +1 for null terminator
|
||||||
|
wmemmove(m_wText + ms_curpos, m_wText + ms_curpos + eraseCount, remainingChars); // wcscpy > wmemmove to handle overlapping memory
|
||||||
ms_lastpos -= eraseCount;
|
ms_lastpos -= eraseCount;
|
||||||
ms_curpos = std::min(ms_lastpos, ms_curpos);
|
ms_curpos = std::min(ms_lastpos, ms_curpos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ void string_replace_word(const char* base, int base_len, const char* src, int sr
|
|||||||
int cur = 0;
|
int cur = 0;
|
||||||
while (cur < base_len)
|
while (cur < base_len)
|
||||||
{
|
{
|
||||||
if (memcmp(base + cur, src, src_len) == 0)
|
if (cur + src_len <= base_len && memcmp(base + cur, src, src_len) == 0)
|
||||||
{
|
{
|
||||||
result.append(base + prev, cur - prev);
|
result.append(base + prev, cur - prev);
|
||||||
result.append(dst, dst_len);
|
result.append(dst, dst_len);
|
||||||
|
|||||||
Reference in New Issue
Block a user