forked from metin-server/m2dev-client-src
fixed some crashes
This commit is contained in:
@@ -90,6 +90,14 @@ void CEffectElementBaseInstance::Destroy()
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
@@ -216,22 +216,14 @@ public:
|
||||
public:
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -239,12 +231,12 @@ public:
|
||||
{
|
||||
if (m_local_buf != m_buf)
|
||||
{
|
||||
dbg_printf("DecruptBuffer - FreeHeap\n");
|
||||
dbg_printf("DecryptBuffer - FreeHeap\n");
|
||||
delete [] m_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_printf("DecruptBuffer - FreeStack\n");
|
||||
dbg_printf("DecryptBuffer - FreeStack\n");
|
||||
}
|
||||
}
|
||||
void* GetBufferPtr()
|
||||
|
||||
@@ -20,7 +20,7 @@ void CGraphicObjectInstance::Clear()
|
||||
m_isVisible = TRUE;
|
||||
|
||||
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_fYaw = m_fPitch = m_fRoll = 0.0f;
|
||||
D3DXMatrixIdentity(&m_worldMatrix);
|
||||
@@ -278,12 +278,22 @@ void CGraphicObjectInstance::Initialize()
|
||||
m_BlockCamera = false;
|
||||
|
||||
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;
|
||||
|
||||
D3DXMatrixIdentity(&m_worldMatrix);
|
||||
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();
|
||||
OnInitialize();
|
||||
}
|
||||
|
||||
@@ -830,7 +830,8 @@ void CIME::DelCurPos()
|
||||
if (ms_curpos < ms_lastpos)
|
||||
{
|
||||
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_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;
|
||||
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(dst, dst_len);
|
||||
|
||||
Reference in New Issue
Block a user