forked from metin2/server
Merge branch 'memory-fixes' into 'master'
Memory fixes & improvements See merge request metin2/server!1
This commit is contained in:
commit
d188b4d53f
@ -63,12 +63,19 @@ void CPeer::SetUserCount(DWORD dwCount)
|
|||||||
|
|
||||||
bool CPeer::PeekPacket(int & iBytesProceed, BYTE & header, DWORD & dwHandle, DWORD & dwLength, const char ** data)
|
bool CPeer::PeekPacket(int & iBytesProceed, BYTE & header, DWORD & dwHandle, DWORD & dwLength, const char ** data)
|
||||||
{
|
{
|
||||||
|
// Return if not enough data was received to read the header
|
||||||
if (GetRecvLength() < iBytesProceed + 9)
|
if (GetRecvLength() < iBytesProceed + 9)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const char * buf = (const char *) GetRecvBuffer(iBytesProceed + 9);
|
const char * buf = (const char *) GetRecvBuffer(iBytesProceed + 9);
|
||||||
|
if (!buf) {
|
||||||
|
sys_err("PeekPacket: Failed to get network buffer!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
buf += iBytesProceed;
|
buf += iBytesProceed;
|
||||||
|
|
||||||
|
// Read the header data
|
||||||
header = *(buf++);
|
header = *(buf++);
|
||||||
|
|
||||||
dwHandle = *((DWORD *) buf);
|
dwHandle = *((DWORD *) buf);
|
||||||
@ -77,7 +84,7 @@ bool CPeer::PeekPacket(int & iBytesProceed, BYTE & header, DWORD & dwHandle, DWO
|
|||||||
dwLength = *((DWORD *) buf);
|
dwLength = *((DWORD *) buf);
|
||||||
buf += sizeof(DWORD);
|
buf += sizeof(DWORD);
|
||||||
|
|
||||||
//sys_log(0, "%d header %d handle %u length %u", GetRecvLength(), header, dwHandle, dwLength);
|
// Ensure that all the data was fully received
|
||||||
if (iBytesProceed + dwLength + 9 > (DWORD) GetRecvLength())
|
if (iBytesProceed + dwLength + 9 > (DWORD) GetRecvLength())
|
||||||
{
|
{
|
||||||
sys_log(0, "PeekPacket: not enough buffer size: len %u, recv %d",
|
sys_log(0, "PeekPacket: not enough buffer size: len %u, recv %d",
|
||||||
@ -85,6 +92,17 @@ bool CPeer::PeekPacket(int & iBytesProceed, BYTE & header, DWORD & dwHandle, DWO
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that all the required data is available in a contiguous area
|
||||||
|
buf = (const char *) GetRecvBuffer(iBytesProceed + dwLength + 9);
|
||||||
|
if (!buf) {
|
||||||
|
sys_err("PeekPacket: Failed to get network buffer!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip the header
|
||||||
|
buf += iBytesProceed + 9;
|
||||||
|
|
||||||
|
// Set the data pointer
|
||||||
*data = buf;
|
*data = buf;
|
||||||
iBytesProceed += dwLength + 9;
|
iBytesProceed += dwLength + 9;
|
||||||
return true;
|
return true;
|
||||||
|
@ -49,4 +49,3 @@ find_package (Threads REQUIRED)
|
|||||||
target_link_libraries (${PROJECT_NAME} Threads::Threads)
|
target_link_libraries (${PROJECT_NAME} Threads::Threads)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME} libgame libpoly libsql libthecore liblua)
|
target_link_libraries(${PROJECT_NAME} libgame libpoly libsql libthecore liblua)
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include "ani.h"
|
#include "ani.h"
|
||||||
#include "locale_service.h"
|
#include "locale_service.h"
|
||||||
|
|
||||||
int battle_hit(LPCHARACTER ch, LPCHARACTER victim, int & iRetDam);
|
|
||||||
|
|
||||||
bool battle_distance_valid_by_xy(int x, int y, int tx, int ty)
|
bool battle_distance_valid_by_xy(int x, int y, int tx, int ty)
|
||||||
{
|
{
|
||||||
int distance = DISTANCE_APPROX(x - tx, y - ty);
|
int distance = DISTANCE_APPROX(x - tx, y - ty);
|
||||||
@ -161,9 +159,7 @@ int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim)
|
|||||||
const PIXEL_POSITION & vpos = victim->GetXYZ();
|
const PIXEL_POSITION & vpos = victim->GetXYZ();
|
||||||
ch->SetRotationToXY(vpos.x, vpos.y);
|
ch->SetRotationToXY(vpos.x, vpos.y);
|
||||||
|
|
||||||
int dam;
|
return battle_hit(ch, victim);
|
||||||
int ret = battle_hit(ch, victim, dam);
|
|
||||||
return (ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 실제 GET_BATTLE_VICTIM을 NULL로 만들고 이벤트를 캔슬 시킨다.
|
// 실제 GET_BATTLE_VICTIM을 NULL로 만들고 이벤트를 캔슬 시킨다.
|
||||||
@ -633,12 +629,8 @@ void NormalAttackAffect(LPCHARACTER pkAttacker, LPCHARACTER pkVictim)
|
|||||||
AttackAffect(pkAttacker, pkVictim, POINT_SLOW_PCT, IMMUNE_SLOW, AFFECT_SLOW, POINT_MOV_SPEED, -30, AFF_SLOW, 20, "SLOW");
|
AttackAffect(pkAttacker, pkVictim, POINT_SLOW_PCT, IMMUNE_SLOW, AFFECT_SLOW, POINT_MOV_SPEED, -30, AFF_SLOW, 20, "SLOW");
|
||||||
}
|
}
|
||||||
|
|
||||||
int battle_hit(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int & iRetDam)
|
int battle_hit(LPCHARACTER pkAttacker, LPCHARACTER pkVictim)
|
||||||
{
|
{
|
||||||
//PROF_UNIT puHit("Hit");
|
|
||||||
if (test_server)
|
|
||||||
sys_log(0, "battle_hit : [%s] attack to [%s] : dam :%d type :%d", pkAttacker->GetName(), pkVictim->GetName(), iRetDam);
|
|
||||||
|
|
||||||
int iDam = CalcMeleeDamage(pkAttacker, pkVictim);
|
int iDam = CalcMeleeDamage(pkAttacker, pkVictim);
|
||||||
|
|
||||||
if (iDam <= 0)
|
if (iDam <= 0)
|
||||||
@ -684,7 +676,9 @@ int battle_hit(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int & iRetDam)
|
|||||||
float tempIDam = iDam;
|
float tempIDam = iDam;
|
||||||
iDam = attMul * tempIDam + 0.5f;
|
iDam = attMul * tempIDam + 0.5f;
|
||||||
|
|
||||||
iRetDam = iDam;
|
//PROF_UNIT puHit("Hit");
|
||||||
|
if (test_server)
|
||||||
|
sys_log(0, "battle_hit : [%s] attack to [%s] : dam: %d", pkAttacker->GetName(), pkVictim->GetName(), iDam);
|
||||||
|
|
||||||
//PROF_UNIT puDam("Dam");
|
//PROF_UNIT puDam("Dam");
|
||||||
if (pkVictim->Damage(pkAttacker, iDam, DAMAGE_TYPE_NORMAL))
|
if (pkVictim->Damage(pkAttacker, iDam, DAMAGE_TYPE_NORMAL))
|
||||||
|
@ -28,6 +28,8 @@ extern int battle_count_attackers(LPCHARACTER ch);
|
|||||||
|
|
||||||
extern void NormalAttackAffect(LPCHARACTER pkAttacker, LPCHARACTER pkVictim);
|
extern void NormalAttackAffect(LPCHARACTER pkAttacker, LPCHARACTER pkVictim);
|
||||||
|
|
||||||
|
extern int battle_hit(LPCHARACTER ch, LPCHARACTER victim);
|
||||||
|
|
||||||
// 특성 공격
|
// 특성 공격
|
||||||
inline void AttackAffect(LPCHARACTER pkAttacker,
|
inline void AttackAffect(LPCHARACTER pkAttacker,
|
||||||
LPCHARACTER pkVictim,
|
LPCHARACTER pkVictim,
|
||||||
|
@ -1982,8 +1982,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
|||||||
|
|
||||||
//독일 선물 기능 패킷 임시 저장
|
//독일 선물 기능 패킷 임시 저장
|
||||||
private:
|
private:
|
||||||
unsigned int itemAward_vnum;
|
unsigned int itemAward_vnum = 0;
|
||||||
char itemAward_cmd[20];
|
char itemAward_cmd[20] = "";
|
||||||
//bool itemAward_flag;
|
//bool itemAward_flag;
|
||||||
public:
|
public:
|
||||||
unsigned int GetItemAward_vnum() { return itemAward_vnum; }
|
unsigned int GetItemAward_vnum() { return itemAward_vnum; }
|
||||||
|
@ -169,18 +169,16 @@ void map_allow_add(int index)
|
|||||||
s_set_map_allows.insert(index);
|
s_set_map_allows.insert(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_allow_copy(LONG * pl, int size)
|
void map_allow_copy(int * pl, int size)
|
||||||
{
|
{
|
||||||
int iCount = 0;
|
int iCount = 0;
|
||||||
std::set<int>::iterator it = s_set_map_allows.begin();
|
|
||||||
|
|
||||||
while (it != s_set_map_allows.end())
|
for (auto mapId: s_set_map_allows)
|
||||||
{
|
{
|
||||||
int i = *(it++);
|
if (iCount >= size)
|
||||||
*(pl++) = i;
|
|
||||||
|
|
||||||
if (++iCount > size)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
pl[iCount++] = mapId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ extern bool g_bTrafficProfileOn; ///< true
|
|||||||
extern BYTE g_bChannel;
|
extern BYTE g_bChannel;
|
||||||
|
|
||||||
extern bool map_allow_find(int index);
|
extern bool map_allow_find(int index);
|
||||||
extern void map_allow_copy(LONG * pl, int size);
|
extern void map_allow_copy(int * pl, int size);
|
||||||
extern bool no_wander;
|
extern bool no_wander;
|
||||||
|
|
||||||
extern int g_iUserLimit;
|
extern int g_iUserLimit;
|
||||||
|
Loading…
Reference in New Issue
Block a user