forked from metin2/server
Removed MIN/MAX/MINMAX functions, upgraded to C++17, code cleanup
This commit is contained in:
parent
3a74dac29e
commit
148223340c
|
@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.12)
|
||||||
# Build mode debug/release?
|
# Build mode debug/release?
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
# Set C++ standard to C++11
|
# Set C++ standard to C++17
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
project("Metin2 Server")
|
project("Metin2 Server")
|
||||||
|
|
||||||
|
|
18
common/stl.h
18
common/stl.h
|
@ -96,24 +96,6 @@ namespace std
|
||||||
a.clear();
|
a.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> T MIN(T a, T b)
|
|
||||||
{
|
|
||||||
return a < b ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> T MAX(T a, T b)
|
|
||||||
{
|
|
||||||
return a > b ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> T MINMAX(T min, T value, T max)
|
|
||||||
{
|
|
||||||
T tv;
|
|
||||||
|
|
||||||
tv = (min > value ? min : value);
|
|
||||||
return (max < tv) ? max : tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class _Ty>
|
template <class _Ty>
|
||||||
class void_mem_fun_t : public unary_function<_Ty *, void>
|
class void_mem_fun_t : public unary_function<_Ty *, void>
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,7 @@ const int auctionMinFlushSec = 1800;
|
||||||
|
|
||||||
CItemCache::CItemCache()
|
CItemCache::CItemCache()
|
||||||
{
|
{
|
||||||
m_expireTime = MIN(1800, g_iItemCacheFlushSeconds);
|
m_expireTime = std::min(1800, g_iItemCacheFlushSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
CItemCache::~CItemCache()
|
CItemCache::~CItemCache()
|
||||||
|
@ -158,7 +158,7 @@ void CItemCache::OnFlush()
|
||||||
//
|
//
|
||||||
CPlayerTableCache::CPlayerTableCache()
|
CPlayerTableCache::CPlayerTableCache()
|
||||||
{
|
{
|
||||||
m_expireTime = MIN(1800, g_iPlayerCacheFlushSeconds);
|
m_expireTime = std::min(1800, g_iPlayerCacheFlushSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlayerTableCache::~CPlayerTableCache()
|
CPlayerTableCache::~CPlayerTableCache()
|
||||||
|
@ -184,7 +184,7 @@ const int CItemPriceListTableCache::s_nMinFlushSec = 1800;
|
||||||
|
|
||||||
CItemPriceListTableCache::CItemPriceListTableCache()
|
CItemPriceListTableCache::CItemPriceListTableCache()
|
||||||
{
|
{
|
||||||
m_expireTime = MIN(s_nMinFlushSec, g_iItemPriceListTableCacheFlushSeconds);
|
m_expireTime = std::min(s_nMinFlushSec, g_iItemPriceListTableCacheFlushSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList)
|
void CItemPriceListTableCache::UpdateList(const TItemPriceListTable* pUpdateList)
|
||||||
|
|
|
@ -702,7 +702,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg)
|
||||||
if (pSet && !m_vec_itemTable.empty())
|
if (pSet && !m_vec_itemTable.empty())
|
||||||
{
|
{
|
||||||
|
|
||||||
CGrid grid(5, MAX(1, pi->pSafebox->bSize) * 9);
|
CGrid grid(5, std::max<int>(1, pi->pSafebox->bSize) * 9);
|
||||||
bool bEscape = false;
|
bool bEscape = false;
|
||||||
|
|
||||||
for (DWORD i = 0; i < s_items.size(); ++i)
|
for (DWORD i = 0; i < s_items.size(); ++i)
|
||||||
|
@ -1624,7 +1624,7 @@ void CClientManager::UpdatePlayerCache()
|
||||||
|
|
||||||
void CClientManager::SetCacheFlushCountLimit(int iLimit)
|
void CClientManager::SetCacheFlushCountLimit(int iLimit)
|
||||||
{
|
{
|
||||||
m_iCacheFlushCountLimit = MAX(10, iLimit);
|
m_iCacheFlushCountLimit = std::max(10, iLimit);
|
||||||
sys_log(0, "CACHE_FLUSH_LIMIT_PER_SECOND: %d", m_iCacheFlushCountLimit);
|
sys_log(0, "CACHE_FLUSH_LIMIT_PER_SECOND: %d", m_iCacheFlushCountLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3065,8 +3065,8 @@ int CClientManager::Process()
|
||||||
//30ºÐ¸¶´Ù º¯°æ
|
//30ºÐ¸¶´Ù º¯°æ
|
||||||
if (((thecore_pulse() % (60 * 30 * 10)) == 0))
|
if (((thecore_pulse() % (60 * 30 * 10)) == 0))
|
||||||
{
|
{
|
||||||
g_iPlayerCacheFlushSeconds = MAX(60, rand() % 180);
|
g_iPlayerCacheFlushSeconds = std::max(60, rand() % 180);
|
||||||
g_iItemCacheFlushSeconds = MAX(60, rand() % 180);
|
g_iItemCacheFlushSeconds = std::max(60, rand() % 180);
|
||||||
sys_log(0, "[SAVE_TIME]Change saving time item %d player %d", g_iPlayerCacheFlushSeconds, g_iItemCacheFlushSeconds);
|
sys_log(0, "[SAVE_TIME]Change saving time item %d player %d", g_iPlayerCacheFlushSeconds, g_iItemCacheFlushSeconds);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -3130,7 +3130,7 @@ int CClientManager::Process()
|
||||||
DWORD dwCount = CClientManager::instance().GetUserCount();
|
DWORD dwCount = CClientManager::instance().GetUserCount();
|
||||||
|
|
||||||
g_dwUsageAvg += dwCount;
|
g_dwUsageAvg += dwCount;
|
||||||
g_dwUsageMax = MAX(g_dwUsageMax, dwCount);
|
g_dwUsageMax = std::max(g_dwUsageMax, dwCount);
|
||||||
|
|
||||||
memset(&thecore_profiler[0], 0, sizeof(thecore_profiler));
|
memset(&thecore_profiler[0], 0, sizeof(thecore_profiler));
|
||||||
|
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ void parse_pair_number_string(const char * c_pszString, std::vector<std::pair<in
|
||||||
{
|
{
|
||||||
if (isdigit(*t))
|
if (isdigit(*t))
|
||||||
{
|
{
|
||||||
strncpy(szNum, t, MIN(sizeof(szNum), (p-t)+1));
|
strncpy(szNum, t, std::min<size_t>(sizeof(szNum), (p-t)+1));
|
||||||
|
|
||||||
comma = strchr(szNum, ',');
|
comma = strchr(szNum, ',');
|
||||||
|
|
||||||
|
@ -1236,7 +1236,7 @@ bool CClientManager::InitializeObjectProto()
|
||||||
m_vec_kObjectProto.clear();
|
m_vec_kObjectProto.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vec_kObjectProto.reserve(MAX(0, pRes->uiNumRows));
|
m_vec_kObjectProto.reserve(std::max<size_t>(0, pRes->uiNumRows));
|
||||||
|
|
||||||
MYSQL_ROW data;
|
MYSQL_ROW data;
|
||||||
|
|
||||||
|
@ -1277,7 +1277,7 @@ bool CClientManager::InitializeObjectProto()
|
||||||
str_to_number(t.dwDependOnGroupVnum, data[col++]);
|
str_to_number(t.dwDependOnGroupVnum, data[col++]);
|
||||||
|
|
||||||
t.lNPCX = 0;
|
t.lNPCX = 0;
|
||||||
t.lNPCY = MAX(t.lRegion[1], t.lRegion[3])+300;
|
t.lNPCY = std::max(t.lRegion[1], t.lRegion[3])+300;
|
||||||
// END_OF_ADD_BUILDING_NPC
|
// END_OF_ADD_BUILDING_NPC
|
||||||
|
|
||||||
sys_log(0, "OBJ_PROTO: vnum %lu price %lu mat %lu %lu",
|
sys_log(0, "OBJ_PROTO: vnum %lu price %lu mat %lu %lu",
|
||||||
|
|
|
@ -531,11 +531,11 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab)
|
||||||
int max_point = pkTab->level - 9;
|
int max_point = pkTab->level - 9;
|
||||||
|
|
||||||
int skill_point =
|
int skill_point =
|
||||||
MIN(20, pkTab->skills[121].bLevel) + // SKILL_LEADERSHIP 통솔력
|
std::min<int>(20, pkTab->skills[121].bLevel) + // SKILL_LEADERSHIP 통솔력
|
||||||
MIN(20, pkTab->skills[124].bLevel) + // SKILL_MINING 채광
|
std::min<int>(20, pkTab->skills[124].bLevel) + // SKILL_MINING 채광
|
||||||
MIN(10, pkTab->skills[131].bLevel) + // SKILL_HORSE_SUMMON 말소환
|
std::min<int>(10, pkTab->skills[131].bLevel) + // SKILL_HORSE_SUMMON 말소환
|
||||||
MIN(20, pkTab->skills[141].bLevel) + // SKILL_ADD_HP HP보강
|
std::min<int>(20, pkTab->skills[141].bLevel) + // SKILL_ADD_HP HP보강
|
||||||
MIN(20, pkTab->skills[142].bLevel); // SKILL_RESIST_PENETRATE 관통저항
|
std::min<int>(20, pkTab->skills[142].bLevel); // SKILL_RESIST_PENETRATE 관통저항
|
||||||
|
|
||||||
pkTab->sub_skill_point = max_point - skill_point;
|
pkTab->sub_skill_point = max_point - skill_point;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ int CGuildManager::GetRanking(DWORD dwGID)
|
||||||
if (it == map_kLadderPointRankingByGID.end())
|
if (it == map_kLadderPointRankingByGID.end())
|
||||||
return GUILD_RANK_MAX_NUM;
|
return GUILD_RANK_MAX_NUM;
|
||||||
|
|
||||||
return MINMAX(0, it->second, GUILD_RANK_MAX_NUM);
|
return std::clamp(it->second, 0, GUILD_RANK_MAX_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuildManager::ResultRanking(MYSQL_RES * pRes)
|
void CGuildManager::ResultRanking(MYSQL_RES * pRes)
|
||||||
|
@ -1013,7 +1013,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
|
||||||
// ÆÄ¿ö °è»ê
|
// ÆÄ¿ö °è»ê
|
||||||
TGuild & k1 = TouchGuild(GID1);
|
TGuild & k1 = TouchGuild(GID1);
|
||||||
|
|
||||||
lvp = c_aiScoreByLevel[MIN(GUILD_MAX_LEVEL, k1.level)];
|
lvp = c_aiScoreByLevel[std::min<size_t>(GUILD_MAX_LEVEL, k1.level)];
|
||||||
rkp = c_aiScoreByRanking[GetRanking(GID1)];
|
rkp = c_aiScoreByRanking[GetRanking(GID1)];
|
||||||
alv = GetAverageGuildMemberLevel(GID1);
|
alv = GetAverageGuildMemberLevel(GID1);
|
||||||
mc = GetGuildMemberCount(GID1);
|
mc = GetGuildMemberCount(GID1);
|
||||||
|
@ -1029,7 +1029,7 @@ bool CGuildManager::ReserveWar(TPacketGuildWar * p)
|
||||||
// ÆÄ¿ö °è»ê
|
// ÆÄ¿ö °è»ê
|
||||||
TGuild & k2 = TouchGuild(GID2);
|
TGuild & k2 = TouchGuild(GID2);
|
||||||
|
|
||||||
lvp = c_aiScoreByLevel[MIN(GUILD_MAX_LEVEL, k2.level)];
|
lvp = c_aiScoreByLevel[std::min<size_t>(GUILD_MAX_LEVEL, k2.level)];
|
||||||
rkp = c_aiScoreByRanking[GetRanking(GID2)];
|
rkp = c_aiScoreByRanking[GetRanking(GID2)];
|
||||||
alv = GetAverageGuildMemberLevel(GID2);
|
alv = GetAverageGuildMemberLevel(GID2);
|
||||||
mc = GetGuildMemberCount(GID2);
|
mc = GetGuildMemberCount(GID2);
|
||||||
|
|
|
@ -169,7 +169,7 @@ int Start()
|
||||||
|
|
||||||
if (CConfig::instance().GetValue("LOG_KEEP_DAYS", &tmpValue))
|
if (CConfig::instance().GetValue("LOG_KEEP_DAYS", &tmpValue))
|
||||||
{
|
{
|
||||||
tmpValue = MINMAX(3, tmpValue, 30);
|
tmpValue = std::clamp(tmpValue, 3, 30);
|
||||||
log_set_expiration_days(tmpValue);
|
log_set_expiration_days(tmpValue);
|
||||||
fprintf(stderr, "Setting log keeping days to %d\n", tmpValue);
|
fprintf(stderr, "Setting log keeping days to %d\n", tmpValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h)
|
||||||
CGrid::CGrid(CGrid * pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h)
|
CGrid::CGrid(CGrid * pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h)
|
||||||
{
|
{
|
||||||
m_pGrid = new char[m_iWidth * m_iHeight];
|
m_pGrid = new char[m_iWidth * m_iHeight];
|
||||||
int iSize = std::MIN(w * h, pkGrid->m_iWidth * pkGrid->m_iHeight);
|
int iSize = std::min(w * h, pkGrid->m_iWidth * pkGrid->m_iHeight);
|
||||||
memcpy(m_pGrid, pkGrid->m_pGrid, sizeof(char) * iSize);
|
memcpy(m_pGrid, pkGrid->m_pGrid, sizeof(char) * iSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ bool DSManager::RefreshItemAttributes(LPITEM pDS)
|
||||||
}
|
}
|
||||||
fWeight /= 100.f;
|
fWeight /= 100.f;
|
||||||
|
|
||||||
int n = MIN(basic_apply_num, vec_basic_applys.size());
|
int n = std::min<int>(basic_apply_num, vec_basic_applys.size());
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
const SApply& basic_apply = vec_basic_applys[i];
|
const SApply& basic_apply = vec_basic_applys[i];
|
||||||
|
@ -253,7 +253,7 @@ bool DSManager::PutAttributes(LPITEM pDS)
|
||||||
}
|
}
|
||||||
fWeight /= 100.f;
|
fWeight /= 100.f;
|
||||||
|
|
||||||
int n = MIN(basic_apply_num, vec_basic_applys.size());
|
int n = std::min<int>(basic_apply_num, vec_basic_applys.size());
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
const SApply& basic_apply = vec_basic_applys[i];
|
const SApply& basic_apply = vec_basic_applys[i];
|
||||||
|
@ -263,7 +263,7 @@ bool DSManager::PutAttributes(LPITEM pDS)
|
||||||
pDS->SetForceAttribute(i, bType, sValue);
|
pDS->SetForceAttribute(i, bType, sValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE additional_attr_num = MIN(Random::get(add_min, add_max), 3);
|
BYTE additional_attr_num = std::min(Random::get(add_min, add_max), 3);
|
||||||
|
|
||||||
std::vector <int> random_set;
|
std::vector <int> random_set;
|
||||||
if (additional_attr_num > 0)
|
if (additional_attr_num > 0)
|
||||||
|
@ -355,7 +355,7 @@ bool DSManager::ExtractDragonHeart(LPCHARACTER ch, LPITEM pItem, LPITEM pExtract
|
||||||
}
|
}
|
||||||
|
|
||||||
float fCharge = vec_chargings[idx] * (100 + iBonus) / 100.f;
|
float fCharge = vec_chargings[idx] * (100 + iBonus) / 100.f;
|
||||||
fCharge = std::MINMAX <float> (0.f, fCharge, 100.f);
|
fCharge = std::clamp<float>(fCharge, 0.f, 100.f);
|
||||||
|
|
||||||
if (fCharge < FLT_EPSILON)
|
if (fCharge < FLT_EPSILON)
|
||||||
{
|
{
|
||||||
|
|
|
@ -206,11 +206,11 @@ bool ANI::load_one_race(int race, const char *dir_name)
|
||||||
{
|
{
|
||||||
// 말 안탔을 때
|
// 말 안탔을 때
|
||||||
m_speed[race][0][weapon][combo] = load_one_weapon(dir_name, weapon, combo, false);
|
m_speed[race][0][weapon][combo] = load_one_weapon(dir_name, weapon, combo, false);
|
||||||
m_speed[race][0][weapon][0] = MIN(m_speed[race][0][weapon][0], m_speed[race][0][weapon][combo]); // 최소값
|
m_speed[race][0][weapon][0] = std::min(m_speed[race][0][weapon][0], m_speed[race][0][weapon][combo]); // 최소값
|
||||||
|
|
||||||
// 말 탔을 때
|
// 말 탔을 때
|
||||||
m_speed[race][1][weapon][combo] = load_one_weapon(dir_name, weapon, combo, true);
|
m_speed[race][1][weapon][combo] = load_one_weapon(dir_name, weapon, combo, true);
|
||||||
m_speed[race][1][weapon][0] = MIN(m_speed[race][1][weapon][0], m_speed[race][1][weapon][combo]); // 최소값
|
m_speed[race][1][weapon][0] = std::min(m_speed[race][1][weapon][0], m_speed[race][1][weapon][combo]); // 최소값
|
||||||
|
|
||||||
dev_log(LOG_DEB0, "combo%02d speed=%d horse=%d",
|
dev_log(LOG_DEB0, "combo%02d speed=%d horse=%d",
|
||||||
combo, m_speed[race][0][weapon][combo], m_speed[race][1][weapon][combo]);
|
combo, m_speed[race][0][weapon][combo], m_speed[race][1][weapon][combo]);
|
||||||
|
|
|
@ -135,7 +135,7 @@ int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim)
|
||||||
{
|
{
|
||||||
// PC일 경우 상대가 melee 몹일 경우 몹의 공격 거리가 최대 공격 거리
|
// PC일 경우 상대가 melee 몹일 경우 몹의 공격 거리가 최대 공격 거리
|
||||||
if (false == victim->IsPC() && BATTLE_TYPE_MELEE == victim->GetMobBattleType())
|
if (false == victim->IsPC() && BATTLE_TYPE_MELEE == victim->GetMobBattleType())
|
||||||
max = MAX(300, (int) (victim->GetMobAttackRange() * 1.15f));
|
max = std::max(300, (int) (victim->GetMobAttackRange() * 1.15f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (distance > max)
|
if (distance > max)
|
||||||
|
@ -211,8 +211,8 @@ float CalcAttackRating(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnor
|
||||||
|
|
||||||
if (LC_IsYMIR()) // 천마
|
if (LC_IsYMIR()) // 천마
|
||||||
{
|
{
|
||||||
iARSrc = MIN(90, pkAttacker->GetPolymorphPoint(POINT_DX));
|
iARSrc = std::min(90, pkAttacker->GetPolymorphPoint(POINT_DX));
|
||||||
iERSrc = MIN(90, pkVictim->GetPolymorphPoint(POINT_DX));
|
iERSrc = std::min(90, pkVictim->GetPolymorphPoint(POINT_DX));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -222,8 +222,8 @@ float CalcAttackRating(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnor
|
||||||
int victim_dx = pkVictim->GetPolymorphPoint(POINT_DX);
|
int victim_dx = pkVictim->GetPolymorphPoint(POINT_DX);
|
||||||
int victim_lv = pkAttacker->GetLevel();
|
int victim_lv = pkAttacker->GetLevel();
|
||||||
|
|
||||||
iARSrc = MIN(90, (attacker_dx * 4 + attacker_lv * 2) / 6);
|
iARSrc = std::min(90, (attacker_dx * 4 + attacker_lv * 2) / 6);
|
||||||
iERSrc = MIN(90, (victim_dx * 4 + victim_lv * 2) / 6);
|
iERSrc = std::min(90, (victim_dx * 4 + victim_lv * 2) / 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
float fAR = ((float) iARSrc + 210.0f) / 300.0f; // fAR = 0.7 ~ 1.0
|
float fAR = ((float) iARSrc + 210.0f) / 300.0f; // fAR = 0.7 ~ 1.0
|
||||||
|
@ -479,7 +479,7 @@ int CalcMeleeDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, bool bIgnoreDe
|
||||||
if (pkAttacker->IsNPC())
|
if (pkAttacker->IsNPC())
|
||||||
iAtk = (int) (iAtk * pkAttacker->GetMobDamageMultiply());
|
iAtk = (int) (iAtk * pkAttacker->GetMobDamageMultiply());
|
||||||
|
|
||||||
iDam = MAX(0, iAtk - iDef);
|
iDam = std::max(0, iAtk - iDef);
|
||||||
|
|
||||||
if (test_server)
|
if (test_server)
|
||||||
{
|
{
|
||||||
|
@ -592,7 +592,7 @@ int CalcArrowDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, LPITEM pkBow,
|
||||||
if (pkAttacker->IsNPC())
|
if (pkAttacker->IsNPC())
|
||||||
iAtk = (int) (iAtk * pkAttacker->GetMobDamageMultiply());
|
iAtk = (int) (iAtk * pkAttacker->GetMobDamageMultiply());
|
||||||
|
|
||||||
iDam = MAX(0, iAtk - iDef);
|
iDam = std::max(0, iAtk - iDef);
|
||||||
|
|
||||||
int iPureDam = iDam;
|
int iPureDam = iDam;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ TEMP_BUFFER::TEMP_BUFFER(int Size, bool bForceDelete)
|
||||||
forceDelete = bForceDelete;
|
forceDelete = bForceDelete;
|
||||||
|
|
||||||
if (forceDelete)
|
if (forceDelete)
|
||||||
Size = MAX(Size, 1024 * 128);
|
Size = std::max(Size, 1024 * 128);
|
||||||
|
|
||||||
buf = buffer_new(Size);
|
buf = buffer_new(Size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -786,7 +786,7 @@ bool castle_spawn_tower(int empire, int tower_count)
|
||||||
GET_TOWER(empire, i) = NULL;
|
GET_TOWER(empire, i) = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spawn_count = MINMAX(MIN_CASTLE_TOWER, tower_count, MAX_CASTLE_TOWER); // 5 ~ 10마리
|
int spawn_count = std::clamp(tower_count, MIN_CASTLE_TOWER, MAX_CASTLE_TOWER); // 5 ~ 10마리
|
||||||
|
|
||||||
for (int j = 0; j < spawn_count; ++j)
|
for (int j = 0; j < spawn_count; ++j)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2411,7 +2411,7 @@ EVENTFUNC(recovery_event)
|
||||||
// 몬스터 회복
|
// 몬스터 회복
|
||||||
//
|
//
|
||||||
if (ch->IsAffectFlag(AFF_POISON))
|
if (ch->IsAffectFlag(AFF_POISON))
|
||||||
return PASSES_PER_SEC(MAX(1, ch->GetMobTable().bRegenCycle));
|
return PASSES_PER_SEC(std::max<int>(1, ch->GetMobTable().bRegenCycle));
|
||||||
|
|
||||||
if (2493 == ch->GetMobTable().dwVnum)
|
if (2493 == ch->GetMobTable().dwVnum)
|
||||||
{
|
{
|
||||||
|
@ -2432,12 +2432,12 @@ EVENTFUNC(recovery_event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ch->PointChange(POINT_HP, MAX(1, (ch->GetMaxHP() * regenPct) / 100));
|
ch->PointChange(POINT_HP, std::max(1, (ch->GetMaxHP() * regenPct) / 100));
|
||||||
}
|
}
|
||||||
else if (!ch->IsDoor())
|
else if (!ch->IsDoor())
|
||||||
{
|
{
|
||||||
ch->MonsterLog("HP_REGEN +%d", MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
|
ch->MonsterLog("HP_REGEN +%d", std::max(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
|
||||||
ch->PointChange(POINT_HP, MAX(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
|
ch->PointChange(POINT_HP, std::max(1, (ch->GetMaxHP() * ch->GetMobTable().bRegenPercent) / 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch->GetHP() >= ch->GetMaxHP())
|
if (ch->GetHP() >= ch->GetMaxHP())
|
||||||
|
@ -2456,12 +2456,12 @@ EVENTFUNC(recovery_event)
|
||||||
size_t val = BlueDragon_GetIndexFactor("DragonStone", i, "val");
|
size_t val = BlueDragon_GetIndexFactor("DragonStone", i, "val");
|
||||||
size_t cnt = SECTREE_MANAGER::instance().GetMonsterCountInMap( ch->GetMapIndex(), dwDragonStoneID );
|
size_t cnt = SECTREE_MANAGER::instance().GetMonsterCountInMap( ch->GetMapIndex(), dwDragonStoneID );
|
||||||
|
|
||||||
return PASSES_PER_SEC(MAX(1, (ch->GetMobTable().bRegenCycle - (val*cnt))));
|
return PASSES_PER_SEC(std::max<int>(1, (ch->GetMobTable().bRegenCycle - (val*cnt))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PASSES_PER_SEC(MAX(1, ch->GetMobTable().bRegenCycle));
|
return PASSES_PER_SEC(std::max<int>(1, ch->GetMobTable().bRegenCycle));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2492,7 +2492,7 @@ EVENTFUNC(recovery_event)
|
||||||
int iAmount = 0;
|
int iAmount = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
iPercent = aiRecoveryPercents[MIN(9, iSec)];
|
iPercent = aiRecoveryPercents[std::min(9, iSec)];
|
||||||
iAmount = 15 + (ch->GetMaxHP() * iPercent) / 100;
|
iAmount = 15 + (ch->GetMaxHP() * iPercent) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2520,7 +2520,7 @@ void CHARACTER::StartRecoveryEvent()
|
||||||
|
|
||||||
info->ch = this;
|
info->ch = this;
|
||||||
|
|
||||||
int iSec = IsPC() ? 3 : (MAX(1, GetMobTable().bRegenCycle));
|
int iSec = IsPC() ? 3 : (std::max<int>(1, GetMobTable().bRegenCycle));
|
||||||
m_pkRecoveryEvent = event_create(recovery_event, info, PASSES_PER_SEC(iSec));
|
m_pkRecoveryEvent = event_create(recovery_event, info, PASSES_PER_SEC(iSec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3210,7 +3210,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||||
|
|
||||||
int prev_hp = GetHP();
|
int prev_hp = GetHP();
|
||||||
|
|
||||||
amount = MIN(GetMaxHP() - GetHP(), amount);
|
amount = std::min(GetMaxHP() - GetHP(), amount);
|
||||||
SetHP(GetHP() + amount);
|
SetHP(GetHP() + amount);
|
||||||
val = GetHP();
|
val = GetHP();
|
||||||
|
|
||||||
|
@ -3226,7 +3226,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||||
if (IsDead() || IsStun())
|
if (IsDead() || IsStun())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
amount = MIN(GetMaxSP() - GetSP(), amount);
|
amount = std::min(GetMaxSP() - GetSP(), amount);
|
||||||
SetSP(GetSP() + amount);
|
SetSP(GetSP() + amount);
|
||||||
val = GetSP();
|
val = GetSP();
|
||||||
}
|
}
|
||||||
|
@ -3238,7 +3238,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int prev_val = GetStamina();
|
int prev_val = GetStamina();
|
||||||
amount = MIN(GetMaxStamina() - GetStamina(), amount);
|
amount = std::min(GetMaxStamina() - GetStamina(), amount);
|
||||||
SetStamina(GetStamina() + amount);
|
SetStamina(GetStamina() + amount);
|
||||||
val = GetStamina();
|
val = GetStamina();
|
||||||
|
|
||||||
|
@ -3265,7 +3265,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||||
//SetMaxHP(GetMaxHP() + amount);
|
//SetMaxHP(GetMaxHP() + amount);
|
||||||
// 최대 생명력 = (기본 최대 생명력 + 추가) * 최대생명력%
|
// 최대 생명력 = (기본 최대 생명력 + 추가) * 최대생명력%
|
||||||
int hp = GetRealPoint(POINT_MAX_HP);
|
int hp = GetRealPoint(POINT_MAX_HP);
|
||||||
int add_hp = MIN(3500, hp * GetPoint(POINT_MAX_HP_PCT) / 100);
|
int add_hp = std::min(3500, hp * GetPoint(POINT_MAX_HP_PCT) / 100);
|
||||||
add_hp += GetPoint(POINT_MAX_HP);
|
add_hp += GetPoint(POINT_MAX_HP);
|
||||||
add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);
|
add_hp += GetPoint(POINT_PARTY_TANKER_BONUS);
|
||||||
|
|
||||||
|
@ -3282,7 +3282,7 @@ void CHARACTER::PointChange(BYTE type, int amount, bool bAmount, bool bBroadcast
|
||||||
//SetMaxSP(GetMaxSP() + amount);
|
//SetMaxSP(GetMaxSP() + amount);
|
||||||
// 최대 정신력 = (기본 최대 정신력 + 추가) * 최대정신력%
|
// 최대 정신력 = (기본 최대 정신력 + 추가) * 최대정신력%
|
||||||
int sp = GetRealPoint(POINT_MAX_SP);
|
int sp = GetRealPoint(POINT_MAX_SP);
|
||||||
int add_sp = MIN(800, sp * GetPoint(POINT_MAX_SP_PCT) / 100);
|
int add_sp = std::min(800, sp * GetPoint(POINT_MAX_SP_PCT) / 100);
|
||||||
add_sp += GetPoint(POINT_MAX_SP);
|
add_sp += GetPoint(POINT_MAX_SP);
|
||||||
add_sp += GetPoint(POINT_PARTY_SKILL_MASTER_BONUS);
|
add_sp += GetPoint(POINT_PARTY_SKILL_MASTER_BONUS);
|
||||||
|
|
||||||
|
@ -5105,7 +5105,7 @@ void CHARACTER::SetTarget(LPCHARACTER pkChrTarget)
|
||||||
int iHorseMaxHealth = owner->GetHorseMaxHealth();
|
int iHorseMaxHealth = owner->GetHorseMaxHealth();
|
||||||
|
|
||||||
if (iHorseMaxHealth)
|
if (iHorseMaxHealth)
|
||||||
p.bHPPercent = MINMAX(0, iHorseHealth * 100 / iHorseMaxHealth, 100);
|
p.bHPPercent = std::clamp(iHorseHealth * 100 / iHorseMaxHealth, 0, 100);
|
||||||
else
|
else
|
||||||
p.bHPPercent = 100;
|
p.bHPPercent = 100;
|
||||||
}
|
}
|
||||||
|
@ -5113,7 +5113,7 @@ void CHARACTER::SetTarget(LPCHARACTER pkChrTarget)
|
||||||
p.bHPPercent = 100;
|
p.bHPPercent = 100;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
p.bHPPercent = MINMAX(0, (m_pkChrTarget->GetHP() * 100) / m_pkChrTarget->GetMaxHP(), 100);
|
p.bHPPercent = std::clamp((m_pkChrTarget->GetHP() * 100) / m_pkChrTarget->GetMaxHP(), 0, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -5138,7 +5138,7 @@ void CHARACTER::BroadcastTargetPacket()
|
||||||
if (IsPC())
|
if (IsPC())
|
||||||
p.bHPPercent = 0;
|
p.bHPPercent = 0;
|
||||||
else
|
else
|
||||||
p.bHPPercent = MINMAX(0, (GetHP() * 100) / GetMaxHP(), 100);
|
p.bHPPercent = std::clamp((GetHP() * 100) / GetMaxHP(), 0, 100);
|
||||||
|
|
||||||
CHARACTER_SET::iterator it = m_set_pkChrTargetedBy.begin();
|
CHARACTER_SET::iterator it = m_set_pkChrTargetedBy.begin();
|
||||||
|
|
||||||
|
@ -5727,7 +5727,7 @@ bool CHARACTER::BuildUpdatePartyPacket(TPacketGCPartyUpdate & out)
|
||||||
|
|
||||||
out.header = HEADER_GC_PARTY_UPDATE;
|
out.header = HEADER_GC_PARTY_UPDATE;
|
||||||
out.pid = GetPlayerID();
|
out.pid = GetPlayerID();
|
||||||
out.percent_hp = MINMAX(0, GetHP() * 100 / GetMaxHP(), 100);
|
out.percent_hp = std::clamp(GetHP() * 100 / GetMaxHP(), 0, 100);
|
||||||
out.role = GetParty()->GetRole(GetPlayerID());
|
out.role = GetParty()->GetRole(GetPlayerID());
|
||||||
|
|
||||||
sys_log(1, "PARTY %s role is %d", GetName(), out.role);
|
sys_log(1, "PARTY %s role is %d", GetName(), out.role);
|
||||||
|
@ -5881,8 +5881,8 @@ void CHARACTER::ResetPoint(int iLv)
|
||||||
SetRandomHP((iLv - 1) * Random::get(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end));
|
SetRandomHP((iLv - 1) * Random::get(JobInitialPoints[GetJob()].hp_per_lv_begin, JobInitialPoints[GetJob()].hp_per_lv_end));
|
||||||
SetRandomSP((iLv - 1) * Random::get(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end));
|
SetRandomSP((iLv - 1) * Random::get(JobInitialPoints[GetJob()].sp_per_lv_begin, JobInitialPoints[GetJob()].sp_per_lv_end));
|
||||||
|
|
||||||
//PointChange(POINT_STAT, ((MINMAX(1, iLv, 99) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT));
|
//PointChange(POINT_STAT, ((std::clamp(iLv, 1, 99) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT));
|
||||||
PointChange(POINT_STAT, ((MINMAX(1, iLv, 90) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT));
|
PointChange(POINT_STAT, ((std::clamp(iLv, 1, 90) - 1) * 3) + GetPoint(POINT_LEVEL_STEP) - GetPoint(POINT_STAT));
|
||||||
|
|
||||||
ComputePoints();
|
ComputePoints();
|
||||||
|
|
||||||
|
@ -6126,7 +6126,7 @@ int CHARACTER::GetPolymorphPower() const
|
||||||
if (value)
|
if (value)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return aiPolymorphPowerByLevel[MINMAX(0, GetSkillLevel(SKILL_POLYMORPH), 40)];
|
return aiPolymorphPowerByLevel[std::clamp(GetSkillLevel(SKILL_POLYMORPH), 0, 40)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHARACTER::SetPolymorph(DWORD dwRaceNum, bool bMaintainStat)
|
void CHARACTER::SetPolymorph(DWORD dwRaceNum, bool bMaintainStat)
|
||||||
|
@ -7204,5 +7204,5 @@ DWORD CHARACTER::GetNextExp() const
|
||||||
|
|
||||||
int CHARACTER::GetSkillPowerByLevel(int level, bool bMob) const
|
int CHARACTER::GetSkillPowerByLevel(int level, bool bMob) const
|
||||||
{
|
{
|
||||||
return CTableBySkill::instance().GetSkillPowerByLevelFromType(GetJob(), GetSkillGroup(), MINMAX(0, level, SKILL_MAX_LEVEL), bMob);
|
return CTableBySkill::instance().GetSkillPowerByLevelFromType(GetJob(), GetSkillGroup(), std::clamp<int>(level, 0, SKILL_MAX_LEVEL), bMob);
|
||||||
}
|
}
|
|
@ -103,11 +103,11 @@ bool CHARACTER::UpdateAffect()
|
||||||
|
|
||||||
if (LC_IsYMIR())
|
if (LC_IsYMIR())
|
||||||
{
|
{
|
||||||
iVal = MIN(GetPoint(POINT_HP_RECOVERY), GetMaxHP() * 9 / 100);
|
iVal = std::min(GetPoint(POINT_HP_RECOVERY), GetMaxHP() * 9 / 100);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iVal = MIN(GetPoint(POINT_HP_RECOVERY), GetMaxHP() * 7 / 100);
|
iVal = std::min(GetPoint(POINT_HP_RECOVERY), GetMaxHP() * 7 / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointChange(POINT_HP, iVal);
|
PointChange(POINT_HP, iVal);
|
||||||
|
@ -124,9 +124,9 @@ bool CHARACTER::UpdateAffect()
|
||||||
int iVal;
|
int iVal;
|
||||||
|
|
||||||
if (!g_iUseLocale)
|
if (!g_iUseLocale)
|
||||||
iVal = MIN(GetPoint(POINT_SP_RECOVERY), GetMaxSP() * 7 / 100);
|
iVal = std::min(GetPoint(POINT_SP_RECOVERY), GetMaxSP() * 7 / 100);
|
||||||
else
|
else
|
||||||
iVal = MIN(GetPoint(POINT_SP_RECOVERY), GetMaxSP() * 7 / 100);
|
iVal = std::min(GetPoint(POINT_SP_RECOVERY), GetMaxSP() * 7 / 100);
|
||||||
|
|
||||||
PointChange(POINT_SP, iVal);
|
PointChange(POINT_SP, iVal);
|
||||||
PointChange(POINT_SP_RECOVERY, -iVal);
|
PointChange(POINT_SP_RECOVERY, -iVal);
|
||||||
|
|
|
@ -328,22 +328,22 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||||
}
|
}
|
||||||
// END_OF_NO_DEATH_PENALTY_BUG_FIX
|
// END_OF_NO_DEATH_PENALTY_BUG_FIX
|
||||||
|
|
||||||
int iLoss = ((GetNextExp() * aiExpLossPercents[MINMAX(1, GetLevel(), PLAYER_EXP_TABLE_MAX)]) / 100);
|
int iLoss = ((GetNextExp() * aiExpLossPercents[std::clamp<int>(GetLevel(), 1, PLAYER_EXP_TABLE_MAX)]) / 100);
|
||||||
|
|
||||||
if (true == LC_IsYMIR())
|
if (true == LC_IsYMIR())
|
||||||
{
|
{
|
||||||
if (PLAYER_EXP_TABLE_MAX < GetLevel())
|
if (PLAYER_EXP_TABLE_MAX < GetLevel())
|
||||||
{
|
{
|
||||||
iLoss = MIN(500000, iLoss);
|
iLoss = std::min(500000, iLoss);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iLoss = MIN(200000, iLoss);
|
iLoss = std::min(200000, iLoss);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (true == LC_IsEurope())
|
else if (true == LC_IsEurope())
|
||||||
{
|
{
|
||||||
iLoss = MIN(800000, iLoss);
|
iLoss = std::min(800000, iLoss);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bTown)
|
if (bTown)
|
||||||
|
@ -361,7 +361,7 @@ void CHARACTER::DeathPenalty(BYTE bTown)
|
||||||
if (IsEquipUniqueItem(UNIQUE_ITEM_TEARDROP_OF_GODNESS))
|
if (IsEquipUniqueItem(UNIQUE_ITEM_TEARDROP_OF_GODNESS))
|
||||||
iLoss /= 2;
|
iLoss /= 2;
|
||||||
|
|
||||||
sys_log(0, "DEATH_PENALTY(%s) EXP_LOSS: %d percent %d%%", GetName(), iLoss, aiExpLossPercents[MIN(gPlayerMaxLevel, GetLevel())]);
|
sys_log(0, "DEATH_PENALTY(%s) EXP_LOSS: %d percent %d%%", GetName(), iLoss, aiExpLossPercents[std::min(gPlayerMaxLevel, GetLevel())]);
|
||||||
|
|
||||||
PointChange(POINT_EXP, -iLoss, true);
|
PointChange(POINT_EXP, -iLoss, true);
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1054,7 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
|
||||||
{
|
{
|
||||||
random_shuffle(vec_bSlots.begin(), vec_bSlots.end());
|
random_shuffle(vec_bSlots.begin(), vec_bSlots.end());
|
||||||
|
|
||||||
int iQty = MIN(vec_bSlots.size(), r.iInventoryQty);
|
int iQty = std::min<int>(vec_bSlots.size(), r.iInventoryQty);
|
||||||
|
|
||||||
if (iQty)
|
if (iQty)
|
||||||
iQty = Random::get(1, iQty);
|
iQty = Random::get(1, iQty);
|
||||||
|
@ -1090,7 +1090,7 @@ void CHARACTER::ItemDropPenalty(LPCHARACTER pkKiller)
|
||||||
if (isDropAllEquipments)
|
if (isDropAllEquipments)
|
||||||
iQty = vec_bSlots.size();
|
iQty = vec_bSlots.size();
|
||||||
else
|
else
|
||||||
iQty = MIN(vec_bSlots.size(), Random::get(1, r.iEquipmentQty));
|
iQty = std::min<int>(vec_bSlots.size(), Random::get(1, r.iEquipmentQty));
|
||||||
|
|
||||||
if (iQty)
|
if (iQty)
|
||||||
iQty = Random::get(1, iQty);
|
iQty = Random::get(1, iQty);
|
||||||
|
@ -1306,7 +1306,7 @@ void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead)
|
||||||
|
|
||||||
if (GetEmpire() != pkKiller->GetEmpire())
|
if (GetEmpire() != pkKiller->GetEmpire())
|
||||||
{
|
{
|
||||||
int iEP = MIN(GetPoint(POINT_EMPIRE_POINT), pkKiller->GetPoint(POINT_EMPIRE_POINT));
|
int iEP = std::min(GetPoint(POINT_EMPIRE_POINT), pkKiller->GetPoint(POINT_EMPIRE_POINT));
|
||||||
|
|
||||||
PointChange(POINT_EMPIRE_POINT, -(iEP / 10));
|
PointChange(POINT_EMPIRE_POINT, -(iEP / 10));
|
||||||
pkKiller->PointChange(POINT_EMPIRE_POINT, iEP / 5);
|
pkKiller->PointChange(POINT_EMPIRE_POINT, iEP / 5);
|
||||||
|
@ -1916,7 +1916,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
|
|
||||||
if (Random::get(1, 10) <= pct)
|
if (Random::get(1, 10) <= pct)
|
||||||
{
|
{
|
||||||
int iHP = MIN(dam, MAX(0, iCurHP)) * pAttacker->GetPoint(POINT_STEAL_HP) / 100;
|
int iHP = std::min(dam, std::max(0, iCurHP)) * pAttacker->GetPoint(POINT_STEAL_HP) / 100;
|
||||||
|
|
||||||
if (iHP > 0 && GetHP() >= iHP)
|
if (iHP > 0 && GetHP() >= iHP)
|
||||||
{
|
{
|
||||||
|
@ -1941,7 +1941,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
else
|
else
|
||||||
iCur = iCurHP;
|
iCur = iCurHP;
|
||||||
|
|
||||||
int iSP = MIN(dam, MAX(0, iCur)) * pAttacker->GetPoint(POINT_STEAL_SP) / 100;
|
int iSP = std::min(dam, std::max(0, iCur)) * pAttacker->GetPoint(POINT_STEAL_SP) / 100;
|
||||||
|
|
||||||
if (iSP > 0 && iCur >= iSP)
|
if (iSP > 0 && iCur >= iSP)
|
||||||
{
|
{
|
||||||
|
@ -1968,7 +1968,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
// 칠 때마다 HP회복
|
// 칠 때마다 HP회복
|
||||||
if (pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) && Random::get(0, 4) > 0) // 80% 확률
|
if (pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) && Random::get(0, 4) > 0) // 80% 확률
|
||||||
{
|
{
|
||||||
int i = MIN(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) / 100;
|
int i = std::min(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_HP_RECOVERY) / 100;
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
|
@ -1980,7 +1980,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
// 칠 때마다 SP회복
|
// 칠 때마다 SP회복
|
||||||
if (pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) && Random::get(0, 4) > 0) // 80% 확률
|
if (pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) && Random::get(0, 4) > 0) // 80% 확률
|
||||||
{
|
{
|
||||||
int i = MIN(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) / 100;
|
int i = std::min(dam, iCurHP) * pAttacker->GetPoint(POINT_HIT_SP_RECOVERY) / 100;
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
|
@ -2009,7 +2009,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
if (pAttacker->GetPoint(POINT_NORMAL_HIT_DAMAGE_BONUS))
|
if (pAttacker->GetPoint(POINT_NORMAL_HIT_DAMAGE_BONUS))
|
||||||
dam = dam * (100 + pAttacker->GetPoint(POINT_NORMAL_HIT_DAMAGE_BONUS)) / 100;
|
dam = dam * (100 + pAttacker->GetPoint(POINT_NORMAL_HIT_DAMAGE_BONUS)) / 100;
|
||||||
|
|
||||||
dam = dam * (100 - MIN(99, GetPoint(POINT_NORMAL_HIT_DEFEND_BONUS))) / 100;
|
dam = dam * (100 - std::min(99, GetPoint(POINT_NORMAL_HIT_DEFEND_BONUS))) / 100;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DAMAGE_TYPE_MELEE:
|
case DAMAGE_TYPE_MELEE:
|
||||||
|
@ -2022,7 +2022,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
if (pAttacker->GetPoint(POINT_SKILL_DAMAGE_BONUS))
|
if (pAttacker->GetPoint(POINT_SKILL_DAMAGE_BONUS))
|
||||||
dam = dam * (100 + pAttacker->GetPoint(POINT_SKILL_DAMAGE_BONUS)) / 100;
|
dam = dam * (100 + pAttacker->GetPoint(POINT_SKILL_DAMAGE_BONUS)) / 100;
|
||||||
|
|
||||||
dam = dam * (100 - MIN(99, GetPoint(POINT_SKILL_DEFEND_BONUS))) / 100;
|
dam = dam * (100 - std::min(99, GetPoint(POINT_SKILL_DEFEND_BONUS))) / 100;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2049,7 +2049,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
{
|
{
|
||||||
// 정신력이 모자라서 피가 더 깍여야할??
|
// 정신력이 모자라서 피가 더 깍여야할??
|
||||||
PointChange(POINT_SP, -GetSP());
|
PointChange(POINT_SP, -GetSP());
|
||||||
dam -= iSP * 100 / MAX(GetPoint(POINT_MANASHIELD), 1);
|
dam -= iSP * 100 / std::max(GetPoint(POINT_MANASHIELD), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2058,7 +2058,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
//
|
//
|
||||||
if (GetPoint(POINT_MALL_DEFBONUS) > 0)
|
if (GetPoint(POINT_MALL_DEFBONUS) > 0)
|
||||||
{
|
{
|
||||||
int dec_dam = MIN(200, dam * GetPoint(POINT_MALL_DEFBONUS) / 100);
|
int dec_dam = std::min(200, dam * GetPoint(POINT_MALL_DEFBONUS) / 100);
|
||||||
dam -= dec_dam;
|
dam -= dec_dam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2069,7 +2069,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu
|
||||||
//
|
//
|
||||||
if (pAttacker->GetPoint(POINT_MALL_ATTBONUS) > 0)
|
if (pAttacker->GetPoint(POINT_MALL_ATTBONUS) > 0)
|
||||||
{
|
{
|
||||||
int add_dam = MIN(300, dam * pAttacker->GetLimitPoint(POINT_MALL_ATTBONUS) / 100);
|
int add_dam = std::min(300, dam * pAttacker->GetLimitPoint(POINT_MALL_ATTBONUS) / 100);
|
||||||
dam += add_dam;
|
dam += add_dam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2484,7 +2484,7 @@ static void GiveExp(LPCHARACTER from, LPCHARACTER to, int iExp)
|
||||||
iExp = iExp * CHARACTER_MANAGER::instance().GetMobExpRate(to) / 100;
|
iExp = iExp * CHARACTER_MANAGER::instance().GetMobExpRate(to) / 100;
|
||||||
|
|
||||||
// 경험치 한번 획득량 제한
|
// 경험치 한번 획득량 제한
|
||||||
iExp = MIN(to->GetNextExp() / 10, iExp);
|
iExp = std::min<int>(to->GetNextExp() / 10, iExp);
|
||||||
|
|
||||||
if (test_server)
|
if (test_server)
|
||||||
{
|
{
|
||||||
|
@ -2821,7 +2821,7 @@ int CHARACTER::GetArrowAndBow(LPITEM * ppkBow, LPITEM * ppkArrow, int iArrowCoun
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
iArrowCount = MIN(iArrowCount, pkArrow->GetCount());
|
iArrowCount = std::min<int>(iArrowCount, pkArrow->GetCount());
|
||||||
|
|
||||||
*ppkBow = pkBow;
|
*ppkBow = pkBow;
|
||||||
*ppkArrow = pkArrow;
|
*ppkArrow = pkArrow;
|
||||||
|
@ -2833,7 +2833,7 @@ void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
|
||||||
{
|
{
|
||||||
int iCount = pkArrow->GetCount();
|
int iCount = pkArrow->GetCount();
|
||||||
DWORD dwVnum = pkArrow->GetVnum();
|
DWORD dwVnum = pkArrow->GetVnum();
|
||||||
iCount = iCount - MIN(iCount, dwArrowCount);
|
iCount = iCount - std::min<int>(iCount, dwArrowCount);
|
||||||
pkArrow->SetCount(iCount);
|
pkArrow->SetCount(iCount);
|
||||||
|
|
||||||
if (iCount == 0)
|
if (iCount == 0)
|
||||||
|
@ -3303,7 +3303,7 @@ void CHARACTER::UpdateAlignment(int iAmount)
|
||||||
|
|
||||||
int i = m_iAlignment / 10;
|
int i = m_iAlignment / 10;
|
||||||
|
|
||||||
m_iRealAlignment = MINMAX(-200000, m_iRealAlignment + iAmount, 200000);
|
m_iRealAlignment = std::clamp(m_iRealAlignment + iAmount, -200000, 200000);
|
||||||
|
|
||||||
if (bShow)
|
if (bShow)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1129,16 +1129,16 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item)
|
||||||
if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
|
if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
|
||||||
{
|
{
|
||||||
if (LC_IsYMIR() == true || LC_IsKorea() == true)
|
if (LC_IsYMIR() == true || LC_IsKorea() == true)
|
||||||
success_prob = hyuniron_prob_euckr[MINMAX(0, item->GetRefineLevel(), 8)];
|
success_prob = hyuniron_prob_euckr[std::clamp(item->GetRefineLevel(), 0, 8)];
|
||||||
else
|
else
|
||||||
success_prob = hyuniron_prob[MINMAX(0, item->GetRefineLevel(), 8)];
|
success_prob = hyuniron_prob[std::clamp(item->GetRefineLevel(), 0, 8)];
|
||||||
}
|
}
|
||||||
else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
|
else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
|
||||||
{
|
{
|
||||||
if (LC_IsYMIR() == true || LC_IsKorea() == true)
|
if (LC_IsYMIR() == true || LC_IsKorea() == true)
|
||||||
success_prob = yagong_prob_euckr[MINMAX(0, item->GetRefineLevel(), 8)];
|
success_prob = yagong_prob_euckr[std::clamp(item->GetRefineLevel(), 0, 8)];
|
||||||
else
|
else
|
||||||
success_prob = yagong_prob[MINMAX(0, item->GetRefineLevel(), 8)];
|
success_prob = yagong_prob[std::clamp(item->GetRefineLevel(), 0, 8)];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3144,7 +3144,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
|
|
||||||
}
|
}
|
||||||
DWORD dwSkillVnum = item->GetValue(0);
|
DWORD dwSkillVnum = item->GetValue(0);
|
||||||
int iPct = MINMAX(0, item->GetValue(1), 100);
|
int iPct = std::clamp(item->GetValue(1), 0, 100);
|
||||||
if (GetSkillLevel(dwSkillVnum)>=20 || dwSkillVnum-SKILL_LANGUAGE1+1 == GetEmpire())
|
if (GetSkillLevel(dwSkillVnum)>=20 || dwSkillVnum-SKILL_LANGUAGE1+1 == GetEmpire())
|
||||||
{
|
{
|
||||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 완벽하게 알아들을 수 있는 언어이다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("이미 완벽하게 알아들을 수 있는 언어이다."));
|
||||||
|
@ -3172,7 +3172,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
|
|
||||||
}
|
}
|
||||||
DWORD dwSkillVnum = item->GetValue(0);
|
DWORD dwSkillVnum = item->GetValue(0);
|
||||||
int iPct = MINMAX(0, item->GetValue(1), 100);
|
int iPct = std::clamp(item->GetValue(1), 0, 100);
|
||||||
|
|
||||||
if (GetSkillLevel(dwSkillVnum) >= 10)
|
if (GetSkillLevel(dwSkillVnum) >= 10)
|
||||||
{
|
{
|
||||||
|
@ -3204,7 +3204,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
|
|
||||||
int iSkillLevelLowLimit = item->GetValue(0);
|
int iSkillLevelLowLimit = item->GetValue(0);
|
||||||
int iSkillLevelHighLimit = item->GetValue(1);
|
int iSkillLevelHighLimit = item->GetValue(1);
|
||||||
int iPct = MINMAX(0, item->GetValue(2), 100);
|
int iPct = std::clamp(item->GetValue(2), 0, 100);
|
||||||
int iLevelLimit = item->GetValue(3);
|
int iLevelLimit = item->GetValue(3);
|
||||||
DWORD dwSkillVnum = 0;
|
DWORD dwSkillVnum = 0;
|
||||||
|
|
||||||
|
@ -3276,7 +3276,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
|
|
||||||
}
|
}
|
||||||
DWORD dwSkillVnum = SKILL_CREATE;
|
DWORD dwSkillVnum = SKILL_CREATE;
|
||||||
int iPct = MINMAX(0, item->GetValue(1), 100);
|
int iPct = std::clamp(item->GetValue(1), 0, 100);
|
||||||
|
|
||||||
if (GetSkillLevel(dwSkillVnum)>=40)
|
if (GetSkillLevel(dwSkillVnum)>=40)
|
||||||
{
|
{
|
||||||
|
@ -3318,7 +3318,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
|
|
||||||
}
|
}
|
||||||
DWORD dwSkillVnum = SKILL_MINING;
|
DWORD dwSkillVnum = SKILL_MINING;
|
||||||
int iPct = MINMAX(0, item->GetValue(1), 100);
|
int iPct = std::clamp(item->GetValue(1), 0, 100);
|
||||||
|
|
||||||
if (GetSkillLevel(dwSkillVnum)>=40)
|
if (GetSkillLevel(dwSkillVnum)>=40)
|
||||||
{
|
{
|
||||||
|
@ -3348,7 +3348,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
|
|
||||||
}
|
}
|
||||||
DWORD dwSkillVnum = SKILL_HORSE;
|
DWORD dwSkillVnum = SKILL_HORSE;
|
||||||
int iPct = MINMAX(0, item->GetValue(1), 100);
|
int iPct = std::clamp(item->GetValue(1), 0, 100);
|
||||||
|
|
||||||
if (GetLevel() < 50)
|
if (GetLevel() < 50)
|
||||||
{
|
{
|
||||||
|
@ -3406,7 +3406,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
if (GetAlignment() >= 0)
|
if (GetAlignment() >= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int delta = MIN(-GetAlignment(), item->GetValue(0));
|
int delta = std::min(-GetAlignment(), item->GetValue(0));
|
||||||
|
|
||||||
sys_log(0, "%s ALIGNMENT ITEM %d", GetName(), delta);
|
sys_log(0, "%s ALIGNMENT ITEM %d", GetName(), delta);
|
||||||
|
|
||||||
|
@ -4232,7 +4232,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointChange(POINT_SP_RECOVERY, item->GetValue(1) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
|
PointChange(POINT_SP_RECOVERY, item->GetValue(1) * std::min(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
|
||||||
StartAffectEvent();
|
StartAffectEvent();
|
||||||
EffectPacket(SE_SPUP_BLUE);
|
EffectPacket(SE_SPUP_BLUE);
|
||||||
}
|
}
|
||||||
|
@ -4244,7 +4244,7 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointChange(POINT_HP_RECOVERY, item->GetValue(0) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
|
PointChange(POINT_HP_RECOVERY, item->GetValue(0) * std::min(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
|
||||||
StartAffectEvent();
|
StartAffectEvent();
|
||||||
EffectPacket(SE_HPUP_RED);
|
EffectPacket(SE_HPUP_RED);
|
||||||
}
|
}
|
||||||
|
@ -5597,7 +5597,7 @@ bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||||
sys_log(0, "%s: ITEM_STACK %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
|
sys_log(0, "%s: ITEM_STACK %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
|
||||||
DestCell.window_type, DestCell.cell, count);
|
DestCell.window_type, DestCell.cell, count);
|
||||||
|
|
||||||
count = MIN(200 - item2->GetCount(), count);
|
count = std::min<BYTE>(200 - item2->GetCount(), count);
|
||||||
|
|
||||||
item->SetCount(item->GetCount() - count);
|
item->SetCount(item->GetCount() - count);
|
||||||
item2->SetCount(item2->GetCount() + count);
|
item2->SetCount(item2->GetCount() + count);
|
||||||
|
@ -5815,7 +5815,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||||
if (j != ITEM_SOCKET_MAX_NUM)
|
if (j != ITEM_SOCKET_MAX_NUM)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BYTE bCount2 = MIN(200 - item2->GetCount(), bCount);
|
BYTE bCount2 = std::min<BYTE>(200 - item2->GetCount(), bCount);
|
||||||
bCount -= bCount2;
|
bCount -= bCount2;
|
||||||
|
|
||||||
item2->SetCount(item2->GetCount() + bCount2);
|
item2->SetCount(item2->GetCount() + bCount2);
|
||||||
|
@ -6541,7 +6541,7 @@ LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, BYTE bCount, int iRarePct, bool
|
||||||
bCount = p->alValues[1];
|
bCount = p->alValues[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE bCount2 = MIN(200 - item->GetCount(), bCount);
|
BYTE bCount2 = std::min<BYTE>(200 - item->GetCount(), bCount);
|
||||||
bCount -= bCount2;
|
bCount -= bCount2;
|
||||||
|
|
||||||
item->SetCount(item->GetCount() + bCount2);
|
item->SetCount(item->GetCount() + bCount2);
|
||||||
|
@ -7037,7 +7037,7 @@ bool CHARACTER::GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector<DWORD
|
||||||
{
|
{
|
||||||
int iDropHP = GetMaxHP()*dwCount/100;
|
int iDropHP = GetMaxHP()*dwCount/100;
|
||||||
sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
|
sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
|
||||||
iDropHP = MIN(iDropHP, GetHP()-1);
|
iDropHP = std::min(iDropHP, GetHP()-1);
|
||||||
sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
|
sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
|
||||||
PointChange(POINT_HP, -iDropHP);
|
PointChange(POINT_HP, -iDropHP);
|
||||||
bSuccess = true;
|
bSuccess = true;
|
||||||
|
@ -7183,7 +7183,7 @@ bool CHARACTER::ItemProcess_Polymorph(LPITEM item)
|
||||||
sys_log(0, "USE_POLYMORPH_BALL PID(%d) vnum(%d)", GetPlayerID(), dwVnum);
|
sys_log(0, "USE_POLYMORPH_BALL PID(%d) vnum(%d)", GetPlayerID(), dwVnum);
|
||||||
|
|
||||||
// 레벨 제한 체크
|
// 레벨 제한 체크
|
||||||
int iPolymorphLevelLimit = MAX(0, 20 - GetLevel() * 3 / 10);
|
int iPolymorphLevelLimit = std::max(0, 20 - GetLevel() * 3 / 10);
|
||||||
if (pMob->m_table.bLevel >= GetLevel() + iPolymorphLevelLimit)
|
if (pMob->m_table.bLevel >= GetLevel() + iPolymorphLevelLimit)
|
||||||
{
|
{
|
||||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("나보다 너무 높은 레벨의 몬스터로는 변신 할 수 없습니다."));
|
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("나보다 너무 높은 레벨의 몬스터로는 변신 할 수 없습니다."));
|
||||||
|
|
|
@ -26,7 +26,7 @@ int GetPoisonDamageRate(LPCHARACTER ch)
|
||||||
else
|
else
|
||||||
iRate = poison_damage_rate[ch->GetMobRank()];
|
iRate = poison_damage_rate[ch->GetMobRank()];
|
||||||
|
|
||||||
iRate = MAX(0, iRate - ch->GetPoint(POINT_POISON_REDUCE));
|
iRate = std::max(0, iRate - ch->GetPoint(POINT_POISON_REDUCE));
|
||||||
return iRate;
|
return iRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ bool TSkillUseInfo::UseSkill(bool isGrandMaster, DWORD vid, DWORD dwCooltime, in
|
||||||
|
|
||||||
int CHARACTER::GetChainLightningMaxCount() const
|
int CHARACTER::GetChainLightningMaxCount() const
|
||||||
{
|
{
|
||||||
return aiChainLightningCountBySkillLevel[MIN(SKILL_MAX_LEVEL, GetSkillLevel(SKILL_CHAIN))];
|
return aiChainLightningCountBySkillLevel[std::min<int>(SKILL_MAX_LEVEL, GetSkillLevel(SKILL_CHAIN))];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHARACTER::SetAffectedEunhyung()
|
void CHARACTER::SetAffectedEunhyung()
|
||||||
|
@ -178,7 +178,7 @@ void CHARACTER::SetSkillLevel(DWORD dwVnum, BYTE bLev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pSkillLevels[dwVnum].bLevel = MIN(40, bLev);
|
m_pSkillLevels[dwVnum].bLevel = std::min<BYTE>(40, bLev);
|
||||||
|
|
||||||
if (bLev >= 40)
|
if (bLev >= 40)
|
||||||
m_pSkillLevels[dwVnum].bMasterType = SKILL_PERFECT_MASTER;
|
m_pSkillLevels[dwVnum].bMasterType = SKILL_PERFECT_MASTER;
|
||||||
|
@ -320,7 +320,7 @@ bool CHARACTER::LearnGrandMasterSkill(DWORD dwSkillVnum)
|
||||||
// 여기서 확률을 계산합니다.
|
// 여기서 확률을 계산합니다.
|
||||||
BYTE bLastLevel = GetSkillLevel(dwSkillVnum);
|
BYTE bLastLevel = GetSkillLevel(dwSkillVnum);
|
||||||
|
|
||||||
int idx = MIN(9, GetSkillLevel(dwSkillVnum) - 30);
|
int idx = std::min(9, GetSkillLevel(dwSkillVnum) - 30);
|
||||||
|
|
||||||
sys_log(0, "LearnGrandMasterSkill %s table idx %d value %d", GetName(), idx, aiGrandMasterSkillBookCountForLevelUp[idx]);
|
sys_log(0, "LearnGrandMasterSkill %s table idx %d value %d", GetName(), idx, aiGrandMasterSkillBookCountForLevelUp[idx]);
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ bool CHARACTER::LearnSkillByBook(DWORD dwSkillVnum, BYTE bProb)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int idx = MIN(9, GetSkillLevel(dwSkillVnum) - 20);
|
int idx = std::min(9, GetSkillLevel(dwSkillVnum) - 20);
|
||||||
|
|
||||||
sys_log(0, "LearnSkillByBook %s table idx %d value %d", GetName(), idx, aiSkillBookCountForLevelUp[idx]);
|
sys_log(0, "LearnSkillByBook %s table idx %d value %d", GetName(), idx, aiSkillBookCountForLevelUp[idx]);
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ void CHARACTER::SkillLevelUp(DWORD dwVnum, BYTE bMethod)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Random::get(1, 21 - MIN(20, GetSkillLevel(pkSk->dwVnum))) == 1)
|
if (Random::get(1, 21 - std::min(20, GetSkillLevel(pkSk->dwVnum))) == 1)
|
||||||
SetSkillLevel(pkSk->dwVnum, 20);
|
SetSkillLevel(pkSk->dwVnum, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -827,7 +827,7 @@ void CHARACTER::SkillLevelUp(DWORD dwVnum, BYTE bMethod)
|
||||||
case SKILL_MASTER:
|
case SKILL_MASTER:
|
||||||
if (GetSkillLevel(pkSk->dwVnum) >= 30)
|
if (GetSkillLevel(pkSk->dwVnum) >= 30)
|
||||||
{
|
{
|
||||||
if (Random::get(1, 31 - MIN(30, GetSkillLevel(pkSk->dwVnum))) == 1)
|
if (Random::get(1, 31 - std::min(30, GetSkillLevel(pkSk->dwVnum))) == 1)
|
||||||
SetSkillLevel(pkSk->dwVnum, 30);
|
SetSkillLevel(pkSk->dwVnum, 30);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2648,7 +2648,7 @@ int CHARACTER::GetUsedSkillMasterType(DWORD dwVnum)
|
||||||
if (rInfo.isGrandMaster)
|
if (rInfo.isGrandMaster)
|
||||||
return GetSkillMasterType(dwVnum);
|
return GetSkillMasterType(dwVnum);
|
||||||
|
|
||||||
return MIN(GetSkillMasterType(dwVnum), SKILL_MASTER);
|
return std::min<int>(GetSkillMasterType(dwVnum), SKILL_MASTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CHARACTER::GetSkillMasterType(DWORD dwVnum) const
|
int CHARACTER::GetSkillMasterType(DWORD dwVnum) const
|
||||||
|
@ -2708,7 +2708,7 @@ int CHARACTER::GetSkillLevel(DWORD dwVnum) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MIN(SKILL_MAX_LEVEL, m_pSkillLevels ? m_pSkillLevels[dwVnum].bLevel : 0);
|
return std::min<int>(SKILL_MAX_LEVEL, m_pSkillLevels ? m_pSkillLevels[dwVnum].bLevel : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENTFUNC(skill_muyoung_event)
|
EVENTFUNC(skill_muyoung_event)
|
||||||
|
|
|
@ -390,7 +390,7 @@ void CHARACTER::__StateIdle_Stone()
|
||||||
m_dwStateDuration = PASSES_PER_SEC(1);
|
m_dwStateDuration = PASSES_PER_SEC(1);
|
||||||
|
|
||||||
int iPercent = (GetHP() * 100) / GetMaxHP();
|
int iPercent = (GetHP() * 100) / GetMaxHP();
|
||||||
DWORD dwVnum = Random::get(MIN(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed ), MAX(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed));
|
DWORD dwVnum = Random::get(std::min(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed ), std::max(GetMobTable().sAttackSpeed, GetMobTable().sMovingSpeed));
|
||||||
|
|
||||||
if (iPercent <= 10 && GetMaxSP() < 10)
|
if (iPercent <= 10 && GetMaxSP() < 10)
|
||||||
{
|
{
|
||||||
|
@ -1069,7 +1069,7 @@ void CHARACTER::StateBattle()
|
||||||
|
|
||||||
if ((dwCurTime - m_dwLastAttackTime) < dwDuration) // 2초 마다 공격해야 한다.
|
if ((dwCurTime - m_dwLastAttackTime) < dwDuration) // 2초 마다 공격해야 한다.
|
||||||
{
|
{
|
||||||
m_dwStateDuration = MAX(1, (passes_per_sec * (dwDuration - (dwCurTime - m_dwLastAttackTime)) / 1000));
|
m_dwStateDuration = std::max<int>(1, (passes_per_sec * (dwDuration - (dwCurTime - m_dwLastAttackTime)) / 1000));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2133,8 +2133,8 @@ ACMD(do_inventory)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str_to_number(index, arg1); index = MIN(index, INVENTORY_MAX_NUM);
|
str_to_number(index, arg1); index = std::min<int>(index, INVENTORY_MAX_NUM);
|
||||||
str_to_number(count, arg2); count = MIN(count, INVENTORY_MAX_NUM);
|
str_to_number(count, arg2); count = std::min<int>(count, INVENTORY_MAX_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
|
@ -2374,8 +2374,8 @@ ACMD(do_dice)
|
||||||
end = atoi(arg1);
|
end = atoi(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
end = MAX(start, end);
|
end = std::max(start, end);
|
||||||
start = MIN(start, end);
|
start = std::min(start, end);
|
||||||
|
|
||||||
int n = Random::get(start, end);
|
int n = Random::get(start, end);
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ bool FindInString(const char * c_pszFind, const char * c_pszIn)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
strncpy(sz, c, MIN(sizeof(sz), (p - c) + 1));
|
strncpy(sz, c, std::min<size_t>(sizeof(sz), (p - c) + 1));
|
||||||
|
|
||||||
if (!strncasecmp(c_pszFind, sz, strlen(c_pszFind)))
|
if (!strncasecmp(c_pszFind, sz, strlen(c_pszFind)))
|
||||||
return true;
|
return true;
|
||||||
|
@ -391,7 +391,7 @@ ACMD(do_goto)
|
||||||
if (*arg2 && isdigit(*arg2))
|
if (*arg2 && isdigit(*arg2))
|
||||||
{
|
{
|
||||||
str_to_number(empire, arg2);
|
str_to_number(empire, arg2);
|
||||||
empire = MINMAX(1, empire, 3);
|
empire = std::clamp<BYTE>(empire, 1, 3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
empire = ch->GetEmpire();
|
empire = ch->GetEmpire();
|
||||||
|
@ -513,7 +513,7 @@ ACMD(do_item)
|
||||||
if (*arg2)
|
if (*arg2)
|
||||||
{
|
{
|
||||||
str_to_number(iCount, arg2);
|
str_to_number(iCount, arg2);
|
||||||
iCount = MINMAX(1, iCount, ITEM_MAX_COUNT);
|
iCount = std::clamp<int>(iCount, 1, ITEM_MAX_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD dwVnum;
|
DWORD dwVnum;
|
||||||
|
@ -655,7 +655,7 @@ ACMD(do_mob_coward)
|
||||||
else
|
else
|
||||||
iCount = 1;
|
iCount = 1;
|
||||||
|
|
||||||
iCount = MIN(20, iCount);
|
iCount = std::min(20, iCount);
|
||||||
|
|
||||||
while (iCount--)
|
while (iCount--)
|
||||||
{
|
{
|
||||||
|
@ -737,7 +737,7 @@ ACMD(do_mob_aggresive)
|
||||||
else
|
else
|
||||||
iCount = 1;
|
iCount = 1;
|
||||||
|
|
||||||
iCount = MIN(20, iCount);
|
iCount = std::min(20, iCount);
|
||||||
|
|
||||||
while (iCount--)
|
while (iCount--)
|
||||||
{
|
{
|
||||||
|
@ -798,9 +798,9 @@ ACMD(do_mob)
|
||||||
iCount = 1;
|
iCount = 1;
|
||||||
|
|
||||||
if (test_server)
|
if (test_server)
|
||||||
iCount = MIN(40, iCount);
|
iCount = std::min(40, iCount);
|
||||||
else
|
else
|
||||||
iCount = MIN(20, iCount);
|
iCount = std::min(20, iCount);
|
||||||
|
|
||||||
while (iCount--)
|
while (iCount--)
|
||||||
{
|
{
|
||||||
|
@ -1547,7 +1547,7 @@ ACMD(do_advance)
|
||||||
int level = 0;
|
int level = 0;
|
||||||
str_to_number(level, arg2);
|
str_to_number(level, arg2);
|
||||||
|
|
||||||
tch->ResetPoint(MINMAX(0, level, PLAYER_MAX_LEVEL_CONST));
|
tch->ResetPoint(std::clamp<int>(level, 0, PLAYER_MAX_LEVEL_CONST));
|
||||||
}
|
}
|
||||||
|
|
||||||
ACMD(do_respawn)
|
ACMD(do_respawn)
|
||||||
|
@ -1730,7 +1730,7 @@ ACMD(do_event_flag)
|
||||||
!strcmp(arg1, "mob_gold_buyer") ||
|
!strcmp(arg1, "mob_gold_buyer") ||
|
||||||
!strcmp(arg1, "mob_gold_pct_buyer")
|
!strcmp(arg1, "mob_gold_pct_buyer")
|
||||||
)
|
)
|
||||||
value = MINMAX(0, value, 1000);
|
value = std::clamp(value, 0, 1000);
|
||||||
|
|
||||||
//quest::CQuestManager::instance().SetEventFlag(arg1, atoi(arg2));
|
//quest::CQuestManager::instance().SetEventFlag(arg1, atoi(arg2));
|
||||||
quest::CQuestManager::instance().RequestSetEventFlag(arg1, value);
|
quest::CQuestManager::instance().RequestSetEventFlag(arg1, value);
|
||||||
|
@ -2158,7 +2158,7 @@ ACMD(do_level)
|
||||||
|
|
||||||
int level = 0;
|
int level = 0;
|
||||||
str_to_number(level, arg2);
|
str_to_number(level, arg2);
|
||||||
ch->ResetPoint(MINMAX(1, level, PLAYER_MAX_LEVEL_CONST));
|
ch->ResetPoint(std::clamp<int>(level, 1, PLAYER_MAX_LEVEL_CONST));
|
||||||
|
|
||||||
ch->ClearSkill();
|
ch->ClearSkill();
|
||||||
ch->ClearSubSkill();
|
ch->ClearSubSkill();
|
||||||
|
@ -2513,7 +2513,7 @@ ACMD(do_priv_empire)
|
||||||
str_to_number(empire, arg1);
|
str_to_number(empire, arg1);
|
||||||
str_to_number(type, arg2);
|
str_to_number(type, arg2);
|
||||||
str_to_number(value, arg3);
|
str_to_number(value, arg3);
|
||||||
value = MINMAX(0, value, 1000);
|
value = std::clamp(value, 0, 1000);
|
||||||
str_to_number(duration, arg4);
|
str_to_number(duration, arg4);
|
||||||
|
|
||||||
if (empire < 0 || 3 < empire)
|
if (empire < 0 || 3 < empire)
|
||||||
|
@ -3159,7 +3159,7 @@ ACMD(do_horse_level)
|
||||||
}
|
}
|
||||||
|
|
||||||
str_to_number(level, arg2);
|
str_to_number(level, arg2);
|
||||||
level = MINMAX(0, level, HORSE_MAX_LEVEL);
|
level = std::clamp(level, 0, HORSE_MAX_LEVEL);
|
||||||
|
|
||||||
ch->ChatPacket(CHAT_TYPE_INFO, "horse level set (%s: %d)", victim->GetName(), level);
|
ch->ChatPacket(CHAT_TYPE_INFO, "horse level set (%s: %d)", victim->GetName(), level);
|
||||||
|
|
||||||
|
@ -3172,7 +3172,7 @@ ACMD(do_horse_level)
|
||||||
char arg1[256];
|
char arg1[256];
|
||||||
one_argument(argument, arg1, sizeof(arg1));
|
one_argument(argument, arg1, sizeof(arg1));
|
||||||
|
|
||||||
int level = MINMAX(0, atoi(arg1), HORSE_MAX_LEVEL);
|
int level = std::clamp<int>(atoi(arg1), 0, HORSE_MAX_LEVEL);
|
||||||
|
|
||||||
ch->ChatPacket(CHAT_TYPE_INFO, "horse level set to %d.", level);
|
ch->ChatPacket(CHAT_TYPE_INFO, "horse level set to %d.", level);
|
||||||
ch->SetHorseLevel(level);
|
ch->SetHorseLevel(level);
|
||||||
|
|
|
@ -695,7 +695,7 @@ void config_init(const string& st_localeServiceName)
|
||||||
TOKEN("mark_min_level")
|
TOKEN("mark_min_level")
|
||||||
{
|
{
|
||||||
str_to_number(guild_mark_min_level, value_string);
|
str_to_number(guild_mark_min_level, value_string);
|
||||||
guild_mark_min_level = MINMAX(0, guild_mark_min_level, GUILD_MAX_LEVEL);
|
guild_mark_min_level = std::clamp<BYTE>(guild_mark_min_level, 0, GUILD_MAX_LEVEL);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +709,7 @@ void config_init(const string& st_localeServiceName)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
str_to_number(i, value_string);
|
str_to_number(i, value_string);
|
||||||
log_set_expiration_days(MINMAX(1, i, 90));
|
log_set_expiration_days(std::clamp(i, 1, 90));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -988,13 +988,13 @@ void config_init(const string& st_localeServiceName)
|
||||||
TOKEN("spam_block_score")
|
TOKEN("spam_block_score")
|
||||||
{
|
{
|
||||||
str_to_number(g_uiSpamBlockScore, value_string);
|
str_to_number(g_uiSpamBlockScore, value_string);
|
||||||
g_uiSpamBlockScore = MAX(1, g_uiSpamBlockScore);
|
g_uiSpamBlockScore = std::max<int>(1, g_uiSpamBlockScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
TOKEN("spam_block_reload_cycle")
|
TOKEN("spam_block_reload_cycle")
|
||||||
{
|
{
|
||||||
str_to_number(g_uiSpamReloadCycle, value_string);
|
str_to_number(g_uiSpamReloadCycle, value_string);
|
||||||
g_uiSpamReloadCycle = MAX(60, g_uiSpamReloadCycle); // ĂÖźŇ 1şĐ
|
g_uiSpamReloadCycle = std::max<int>(60, g_uiSpamReloadCycle); // ÃÖ¼Ò 1ºÐ
|
||||||
}
|
}
|
||||||
|
|
||||||
TOKEN("check_multihack")
|
TOKEN("check_multihack")
|
||||||
|
@ -1025,7 +1025,7 @@ void config_init(const string& st_localeServiceName)
|
||||||
{
|
{
|
||||||
str_to_number(gPlayerMaxLevel, value_string);
|
str_to_number(gPlayerMaxLevel, value_string);
|
||||||
|
|
||||||
gPlayerMaxLevel = MINMAX(1, gPlayerMaxLevel, PLAYER_MAX_LEVEL_CONST);
|
gPlayerMaxLevel = std::clamp<int>(gPlayerMaxLevel, 1, PLAYER_MAX_LEVEL_CONST);
|
||||||
|
|
||||||
fprintf(stderr, "PLAYER_MAX_LEVEL: %d\n", gPlayerMaxLevel);
|
fprintf(stderr, "PLAYER_MAX_LEVEL: %d\n", gPlayerMaxLevel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,8 +107,8 @@ extern const DWORD guild_exp_table[GUILD_MAX_LEVEL + 1];
|
||||||
extern const DWORD guild_exp_table2[GUILD_MAX_LEVEL + 1];
|
extern const DWORD guild_exp_table2[GUILD_MAX_LEVEL + 1];
|
||||||
|
|
||||||
#define MAX_EXP_DELTA_OF_LEV 31
|
#define MAX_EXP_DELTA_OF_LEV 31
|
||||||
#define PERCENT_LVDELTA(me, victim) aiPercentByDeltaLev[MINMAX(0, (victim + 15) - me, MAX_EXP_DELTA_OF_LEV - 1)]
|
#define PERCENT_LVDELTA(me, victim) aiPercentByDeltaLev[std::clamp<int>((victim + 15) - me, 0, MAX_EXP_DELTA_OF_LEV - 1)]
|
||||||
#define PERCENT_LVDELTA_BOSS(me, victim) aiPercentByDeltaLevForBoss[MINMAX(0, (victim + 15) - me, MAX_EXP_DELTA_OF_LEV - 1)]
|
#define PERCENT_LVDELTA_BOSS(me, victim) aiPercentByDeltaLevForBoss[std::clamp<int>((victim + 15) - me, 0, MAX_EXP_DELTA_OF_LEV - 1)]
|
||||||
#define CALCULATE_VALUE_LVDELTA(me, victim, val) ((val * PERCENT_LVDELTA(me, victim)) / 100)
|
#define CALCULATE_VALUE_LVDELTA(me, victim, val) ((val * PERCENT_LVDELTA(me, victim)) / 100)
|
||||||
extern const int aiPercentByDeltaLev_euckr[MAX_EXP_DELTA_OF_LEV];
|
extern const int aiPercentByDeltaLev_euckr[MAX_EXP_DELTA_OF_LEV];
|
||||||
extern const int aiPercentByDeltaLevForBoss_euckr[MAX_EXP_DELTA_OF_LEV];
|
extern const int aiPercentByDeltaLevForBoss_euckr[MAX_EXP_DELTA_OF_LEV];
|
||||||
|
|
|
@ -209,7 +209,7 @@ void DBManager::PushBilling(CLoginData * pkLD)
|
||||||
|
|
||||||
pkLD->SetLogonTime();
|
pkLD->SetLogonTime();
|
||||||
int lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec;
|
int lRemainSecs = pkLD->GetRemainSecs() - t.dwUseSec;
|
||||||
pkLD->SetRemainSecs(MAX(0, lRemainSecs));
|
pkLD->SetRemainSecs(std::max(0, lRemainSecs));
|
||||||
|
|
||||||
t.dwLoginKey = pkLD->GetKey();
|
t.dwLoginKey = pkLD->GetKey();
|
||||||
t.bBillType = pkLD->GetBillType();
|
t.bBillType = pkLD->GetBillType();
|
||||||
|
@ -614,7 +614,7 @@ void SendBillingExpire(const char * c_pszLogin, BYTE bBillType, int iSecs, CLogi
|
||||||
|
|
||||||
strncpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin));
|
strncpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin));
|
||||||
ptod.bBillType = bBillType;
|
ptod.bBillType = bBillType;
|
||||||
ptod.dwRemainSeconds = MAX(0, iSecs);
|
ptod.dwRemainSeconds = std::max(0, iSecs);
|
||||||
db_clientdesc->DBPacket(HEADER_GD_BILLING_EXPIRE, 0, &ptod, sizeof(TPacketBillingExpire));
|
db_clientdesc->DBPacket(HEADER_GD_BILLING_EXPIRE, 0, &ptod, sizeof(TPacketBillingExpire));
|
||||||
sys_log(0, "BILLING: EXPIRE %s type %d sec %d ptr %p", c_pszLogin, bBillType, iSecs, pkLD);
|
sys_log(0, "BILLING: EXPIRE %s type %d sec %d ptr %p", c_pszLogin, bBillType, iSecs, pkLD);
|
||||||
}
|
}
|
||||||
|
@ -927,7 +927,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendBillingExpire(pinfo->szLogin, pinfo->bBillType, MAX(0, iRemainSecs), pkLD);
|
SendBillingExpire(pinfo->szLogin, pinfo->bBillType, std::max(0, iRemainSecs), pkLD);
|
||||||
M2_DELETE(pinfo);
|
M2_DELETE(pinfo);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -248,7 +248,7 @@ void Initialize()
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
strncpy(szCol2, start, MIN(sizeof(szCol2), (tab - start) + 1));
|
strncpy(szCol2, start, std::min<size_t>(sizeof(szCol2), (tab - start) + 1));
|
||||||
szCol2[tab-start] = '\0';
|
szCol2[tab-start] = '\0';
|
||||||
|
|
||||||
trim_and_lower(szCol2, szCol, sizeof(szCol));
|
trim_and_lower(szCol2, szCol, sizeof(szCol));
|
||||||
|
@ -378,7 +378,7 @@ int DetermineFish(LPCHARACTER ch)
|
||||||
int adjust = 0;
|
int adjust = 0;
|
||||||
if (quest::CQuestManager::instance().GetEventFlag("fish_miss_pct") != 0)
|
if (quest::CQuestManager::instance().GetEventFlag("fish_miss_pct") != 0)
|
||||||
{
|
{
|
||||||
int fish_pct_value = MINMAX(0, quest::CQuestManager::instance().GetEventFlag("fish_miss_pct"), 200);
|
int fish_pct_value = std::clamp(quest::CQuestManager::instance().GetEventFlag("fish_miss_pct"), 0, 200);
|
||||||
adjust = (100-fish_pct_value) * fish_info[0].prob[prob_idx] / 100;
|
adjust = (100-fish_pct_value) * fish_info[0].prob[prob_idx] / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ int Compute(DWORD fish_id, DWORD ms, DWORD* item, int level)
|
||||||
if (ms > 6000)
|
if (ms > 6000)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int time_step = MINMAX(0,((ms + 99) / 200), MAX_FISHING_TIME_COUNT - 1);
|
int time_step = std::clamp<int>(((ms + 99) / 200), 0, MAX_FISHING_TIME_COUNT - 1);
|
||||||
|
|
||||||
if (Random::get(1, 100) <= aFishingTime[fish_info[fish_id].time_type][time_step])
|
if (Random::get(1, 100) <= aFishingTime[fish_info[fish_id].time_type][time_step])
|
||||||
{
|
{
|
||||||
|
|
|
@ -446,7 +446,7 @@ void CGuild::SendListPacket(LPCHARACTER ch)
|
||||||
|
|
||||||
buf.write(&(it->second), sizeof(DWORD)*3+1);
|
buf.write(&(it->second), sizeof(DWORD)*3+1);
|
||||||
|
|
||||||
strncpy(c, it->second.name.c_str(), MIN(sizeof(c), it->second.name.length() + 1));
|
strncpy(c, it->second.name.c_str(), std::min(sizeof(c), it->second.name.length() + 1));
|
||||||
|
|
||||||
buf.write(c, CHARACTER_NAME_MAX_LEN+1 );
|
buf.write(c, CHARACTER_NAME_MAX_LEN+1 );
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ void CGuild::LoadGuildData(SQLMsg* pmsg)
|
||||||
else
|
else
|
||||||
memset(m_data.abySkill, 0, sizeof(BYTE) * GUILD_SKILL_COUNT);
|
memset(m_data.abySkill, 0, sizeof(BYTE) * GUILD_SKILL_COUNT);
|
||||||
|
|
||||||
m_data.power = MAX(0, strtoul(row[6], (char **) NULL, 10));
|
m_data.power = std::max<int>(0, strtoul(row[6], (char **) NULL, 10));
|
||||||
|
|
||||||
str_to_number(m_data.ladder_point, row[7]);
|
str_to_number(m_data.ladder_point, row[7]);
|
||||||
|
|
||||||
|
@ -1411,7 +1411,7 @@ void CGuild::ComputeGuildPoints()
|
||||||
{
|
{
|
||||||
m_data.max_power = GUILD_BASE_POWER + (m_data.level-1) * GUILD_POWER_PER_LEVEL;
|
m_data.max_power = GUILD_BASE_POWER + (m_data.level-1) * GUILD_POWER_PER_LEVEL;
|
||||||
|
|
||||||
m_data.power = MINMAX(0, m_data.power, m_data.max_power);
|
m_data.power = std::clamp(m_data.power, 0, m_data.max_power);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGuild::GetSkillLevel(DWORD vnum)
|
int CGuild::GetSkillLevel(DWORD vnum)
|
||||||
|
@ -1489,7 +1489,7 @@ void CGuild::GuildPointChange(BYTE type, int amount, bool save)
|
||||||
case POINT_SP:
|
case POINT_SP:
|
||||||
m_data.power += amount;
|
m_data.power += amount;
|
||||||
|
|
||||||
m_data.power = MINMAX(0, m_data.power, m_data.max_power);
|
m_data.power = std::clamp(m_data.power, 0, m_data.max_power);
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
|
@ -1800,7 +1800,7 @@ void CGuild::AdvanceLevel(int iLevel)
|
||||||
if (m_data.level == iLevel)
|
if (m_data.level == iLevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_data.level = MIN(GUILD_MAX_LEVEL, iLevel);
|
m_data.level = std::min<BYTE>(GUILD_MAX_LEVEL, iLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuild::RequestDepositMoney(LPCHARACTER ch, int iGold)
|
void CGuild::RequestDepositMoney(LPCHARACTER ch, int iGold)
|
||||||
|
|
|
@ -166,7 +166,7 @@ void CHorseRider::UpdateHorseStamina(int iStamina, bool bSend)
|
||||||
{
|
{
|
||||||
int level = GetHorseLevel();
|
int level = GetHorseLevel();
|
||||||
|
|
||||||
m_Horse.sStamina = MINMAX(0, m_Horse.sStamina + iStamina, c_aHorseStat[level].iMaxStamina);
|
m_Horse.sStamina = std::clamp(m_Horse.sStamina + iStamina, 0, c_aHorseStat[level].iMaxStamina);
|
||||||
|
|
||||||
if (GetHorseStamina() == 0 && IsHorseRiding())
|
if (GetHorseStamina() == 0 && IsHorseRiding())
|
||||||
{
|
{
|
||||||
|
@ -347,7 +347,7 @@ void CHorseRider::UpdateHorseHealth(int iHealth, bool bSend)
|
||||||
{
|
{
|
||||||
int level = GetHorseLevel();
|
int level = GetHorseLevel();
|
||||||
|
|
||||||
m_Horse.sHealth = MINMAX(0, m_Horse.sHealth + iHealth, c_aHorseStat[level].iMaxHealth);
|
m_Horse.sHealth = std::clamp(m_Horse.sHealth + iHealth, 0, c_aHorseStat[level].iMaxHealth);
|
||||||
|
|
||||||
if (level && m_Horse.sHealth == 0)
|
if (level && m_Horse.sHealth == 0)
|
||||||
HorseDie();
|
HorseDie();
|
||||||
|
@ -366,7 +366,7 @@ void CHorseRider::HorseDie()
|
||||||
|
|
||||||
void CHorseRider::SetHorseLevel(int iLevel)
|
void CHorseRider::SetHorseLevel(int iLevel)
|
||||||
{
|
{
|
||||||
m_Horse.bLevel = iLevel = MINMAX(0, iLevel, HORSE_MAX_LEVEL);
|
m_Horse.bLevel = iLevel = std::clamp(iLevel, 0, HORSE_MAX_LEVEL);
|
||||||
|
|
||||||
m_Horse.sStamina = c_aHorseStat[iLevel].iMaxStamina;
|
m_Horse.sStamina = c_aHorseStat[iLevel].iMaxStamina;
|
||||||
m_Horse.sHealth = c_aHorseStat[iLevel].iMaxHealth;
|
m_Horse.sHealth = c_aHorseStat[iLevel].iMaxHealth;
|
||||||
|
|
|
@ -526,7 +526,7 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str());
|
||||||
is >> strPrivEmpire >> empire >> type >> value >> duration;
|
is >> strPrivEmpire >> empire >> type >> value >> duration;
|
||||||
|
|
||||||
// 최대치 10배
|
// 최대치 10배
|
||||||
value = MINMAX(0, value, 1000);
|
value = std::clamp(value, 0, 1000);
|
||||||
stResult = "PRIV_EMPIRE FAIL";
|
stResult = "PRIV_EMPIRE FAIL";
|
||||||
|
|
||||||
if (!is.fail())
|
if (!is.fail())
|
||||||
|
|
|
@ -1875,7 +1875,7 @@ void CInputDB::BillingExpire(const char * c_pData)
|
||||||
|
|
||||||
if (p->dwRemainSeconds <= 60)
|
if (p->dwRemainSeconds <= 60)
|
||||||
{
|
{
|
||||||
int i = MAX(5, p->dwRemainSeconds);
|
int i = std::max<int>(5, p->dwRemainSeconds);
|
||||||
sys_log(0, "BILLING_EXPIRE: %s %u", p->szLogin, p->dwRemainSeconds);
|
sys_log(0, "BILLING_EXPIRE: %s %u", p->szLogin, p->dwRemainSeconds);
|
||||||
d->DelayedDisconnect(i);
|
d->DelayedDisconnect(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -395,7 +395,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes)
|
||||||
BYTE bType = WHISPER_TYPE_NORMAL;
|
BYTE bType = WHISPER_TYPE_NORMAL;
|
||||||
|
|
||||||
char buf[CHAT_MAX_LEN + 1];
|
char buf[CHAT_MAX_LEN + 1];
|
||||||
strncpy(buf, data + sizeof(TPacketCGWhisper), MIN(iExtraLen + 1, sizeof(buf)));
|
strncpy(buf, data + sizeof(TPacketCGWhisper), std::min<size_t>(iExtraLen + 1, sizeof(buf)));
|
||||||
const size_t buflen = strlen(buf);
|
const size_t buflen = strlen(buf);
|
||||||
|
|
||||||
if (true == SpamBlockCheck(ch, buf, buflen))
|
if (true == SpamBlockCheck(ch, buf, buflen))
|
||||||
|
@ -654,7 +654,7 @@ int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[CHAT_MAX_LEN - (CHARACTER_NAME_MAX_LEN + 3) + 1];
|
char buf[CHAT_MAX_LEN - (CHARACTER_NAME_MAX_LEN + 3) + 1];
|
||||||
strncpy(buf, data + sizeof(TPacketCGChat), MIN(iExtraLen + 1, sizeof(buf)));
|
strncpy(buf, data + sizeof(TPacketCGChat), std::min<size_t>(iExtraLen + 1, sizeof(buf)));
|
||||||
const size_t buflen = strlen(buf);
|
const size_t buflen = strlen(buf);
|
||||||
|
|
||||||
if (buflen > 1 && *buf == '/')
|
if (buflen > 1 && *buf == '/')
|
||||||
|
@ -1359,7 +1359,7 @@ bool CheckComboHack(LPCHARACTER ch, BYTE bArg, DWORD dwTime, bool CheckSpeedHack
|
||||||
}
|
}
|
||||||
else if (bArg > 14 && bArg < 22)
|
else if (bArg > 14 && bArg < 22)
|
||||||
{
|
{
|
||||||
int idx = MIN(2, ch->GetComboIndex());
|
int idx = std::min<int>(2, ch->GetComboIndex());
|
||||||
|
|
||||||
if (ch->GetComboSequence() > 5) // 현재 6콤보 이상은 없다.
|
if (ch->GetComboSequence() > 5) // 현재 6콤보 이상은 없다.
|
||||||
{
|
{
|
||||||
|
@ -2561,7 +2561,7 @@ int CInputMain::Guild(LPCHARACTER ch, const char * data, size_t uiBytes)
|
||||||
// by mhh : 길드자금은 당분간 넣을 수 없다.
|
// by mhh : 길드자금은 당분간 넣을 수 없다.
|
||||||
return SubPacketLen;
|
return SubPacketLen;
|
||||||
|
|
||||||
const int gold = MIN(*reinterpret_cast<const int*>(c_pData), __deposit_limit());
|
const int gold = std::min(*reinterpret_cast<const int*>(c_pData), __deposit_limit());
|
||||||
|
|
||||||
if (gold < 0)
|
if (gold < 0)
|
||||||
{
|
{
|
||||||
|
@ -2584,7 +2584,7 @@ int CInputMain::Guild(LPCHARACTER ch, const char * data, size_t uiBytes)
|
||||||
// by mhh : 길드자금은 당분간 뺄 수 없다.
|
// by mhh : 길드자금은 당분간 뺄 수 없다.
|
||||||
return SubPacketLen;
|
return SubPacketLen;
|
||||||
|
|
||||||
const int gold = MIN(*reinterpret_cast<const int*>(c_pData), 500000);
|
const int gold = std::min(*reinterpret_cast<const int*>(c_pData), 500000);
|
||||||
|
|
||||||
if (gold < 0)
|
if (gold < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ int CInputP2P::Relay(LPDESC d, const char * c_pData, size_t uiBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
memcpy(buf, c_pbData, MIN(p->lSize, sizeof(buf)));
|
memcpy(buf, c_pbData, std::min<size_t>(p->lSize, sizeof(buf)));
|
||||||
|
|
||||||
TPacketGCWhisper* p2 = (TPacketGCWhisper*) buf;
|
TPacketGCWhisper* p2 = (TPacketGCWhisper*) buf;
|
||||||
// bType 상위 4비트: Empire 번호
|
// bType 상위 4비트: Empire 번호
|
||||||
|
@ -117,7 +117,7 @@ int CInputP2P::Notice(LPDESC d, const char * c_pData, size_t uiBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
char szBuf[256+1];
|
char szBuf[256+1];
|
||||||
strncpy(szBuf, c_pData + sizeof(TPacketGGNotice), MIN(p->lSize + 1, sizeof(szBuf)));
|
strncpy(szBuf, c_pData + sizeof(TPacketGGNotice), std::min<size_t>(p->lSize + 1, sizeof(szBuf)));
|
||||||
SendNotice(szBuf);
|
SendNotice(szBuf);
|
||||||
return (p->lSize);
|
return (p->lSize);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ int CInputP2P::MonarchNotice(LPDESC d, const char * c_pData, size_t uiBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
char szBuf[256+1];
|
char szBuf[256+1];
|
||||||
strncpy(szBuf, c_pData + sizeof(TPacketGGMonarchNotice), MIN(p->lSize + 1, sizeof(szBuf)));
|
strncpy(szBuf, c_pData + sizeof(TPacketGGMonarchNotice), std::min<size_t>(p->lSize + 1, sizeof(szBuf)));
|
||||||
SendMonarchNotice(p->bEmpire, szBuf);
|
SendMonarchNotice(p->bEmpire, szBuf);
|
||||||
return (p->lSize);
|
return (p->lSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,10 +224,10 @@ void CItem::UpdatePacket()
|
||||||
|
|
||||||
DWORD CItem::GetCount()
|
DWORD CItem::GetCount()
|
||||||
{
|
{
|
||||||
if (GetType() == ITEM_ELK) return MIN(m_dwCount, INT_MAX);
|
if (GetType() == ITEM_ELK) return std::min<DWORD>(m_dwCount, INT_MAX);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return MIN(m_dwCount, 200);
|
return std::min<DWORD>(m_dwCount, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,11 +235,11 @@ bool CItem::SetCount(DWORD count)
|
||||||
{
|
{
|
||||||
if (GetType() == ITEM_ELK)
|
if (GetType() == ITEM_ELK)
|
||||||
{
|
{
|
||||||
m_dwCount = MIN(count, INT_MAX);
|
m_dwCount = std::min<DWORD>(count, INT_MAX);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_dwCount = MIN(count, ITEM_MAX_COUNT);
|
m_dwCount = std::min<DWORD>(count, ITEM_MAX_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0 && m_pOwner)
|
if (count == 0 && m_pOwner)
|
||||||
|
@ -630,7 +630,7 @@ void CItem::ModifyPoints(bool bAdd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
accessoryGrade = MIN(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM);
|
accessoryGrade = std::min<int>(GetAccessorySocketGrade(), ITEM_ACCESSORY_SOCKET_MAX_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
|
for (int i = 0; i < ITEM_APPLY_MAX_NUM; ++i)
|
||||||
|
@ -647,7 +647,7 @@ void CItem::ModifyPoints(bool bAdd)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (0 != accessoryGrade)
|
if (0 != accessoryGrade)
|
||||||
value += MAX(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100);
|
value += std::max(accessoryGrade, value * aiAccessorySocketEffectivePct[accessoryGrade] / 100);
|
||||||
|
|
||||||
m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : -value);
|
m_pOwner->ApplyPoint(m_pProto->aApplies[i].bType, bAdd ? value : -value);
|
||||||
}
|
}
|
||||||
|
@ -1340,7 +1340,7 @@ EVENTFUNC(timer_based_on_wear_expire_event)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pkItem->SetSocket(ITEM_SOCKET_REMAIN_SEC, remain_time);
|
pkItem->SetSocket(ITEM_SOCKET_REMAIN_SEC, remain_time);
|
||||||
return PASSES_PER_SEC (MIN (60, remain_time));
|
return PASSES_PER_SEC (std::min<int>(60, remain_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItem::SetUniqueExpireEvent(LPEVENT pkEvent)
|
void CItem::SetUniqueExpireEvent(LPEVENT pkEvent)
|
||||||
|
@ -1433,7 +1433,7 @@ void CItem::StartUniqueExpireEvent()
|
||||||
if (iSec == 0)
|
if (iSec == 0)
|
||||||
iSec = 60;
|
iSec = 60;
|
||||||
else
|
else
|
||||||
iSec = MIN(iSec, 60);
|
iSec = std::min(iSec, 60);
|
||||||
|
|
||||||
SetSocket(ITEM_SOCKET_UNIQUE_SAVE_TIME, 0);
|
SetSocket(ITEM_SOCKET_UNIQUE_SAVE_TIME, 0);
|
||||||
|
|
||||||
|
@ -1525,7 +1525,7 @@ bool CItem::IsAccessoryForSocket()
|
||||||
|
|
||||||
void CItem::SetAccessorySocketGrade(int iGrade)
|
void CItem::SetAccessorySocketGrade(int iGrade)
|
||||||
{
|
{
|
||||||
SetSocket(0, MINMAX(0, iGrade, GetAccessorySocketMaxGrade()));
|
SetSocket(0, std::clamp(iGrade, 0, GetAccessorySocketMaxGrade()));
|
||||||
|
|
||||||
int iDownTime = aiAccessorySocketDegradeTime[GetAccessorySocketGrade()];
|
int iDownTime = aiAccessorySocketDegradeTime[GetAccessorySocketGrade()];
|
||||||
|
|
||||||
|
@ -1537,7 +1537,7 @@ void CItem::SetAccessorySocketGrade(int iGrade)
|
||||||
|
|
||||||
void CItem::SetAccessorySocketMaxGrade(int iMaxGrade)
|
void CItem::SetAccessorySocketMaxGrade(int iMaxGrade)
|
||||||
{
|
{
|
||||||
SetSocket(1, MINMAX(0, iMaxGrade, ITEM_ACCESSORY_SOCKET_MAX_NUM));
|
SetSocket(1, std::clamp<int>(iMaxGrade, 0, ITEM_ACCESSORY_SOCKET_MAX_NUM));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItem::SetAccessorySocketDownGradeTime(DWORD time)
|
void CItem::SetAccessorySocketDownGradeTime(DWORD time)
|
||||||
|
@ -1603,7 +1603,7 @@ void CItem::StartAccessorySocketExpireEvent()
|
||||||
if (iSec <= 1)
|
if (iSec <= 1)
|
||||||
iSec = 5;
|
iSec = 5;
|
||||||
else
|
else
|
||||||
iSec = MIN(iSec, 60);
|
iSec = std::min(iSec, 60);
|
||||||
|
|
||||||
item_vid_event_info* info = AllocEventInfo<item_vid_event_info>();
|
item_vid_event_info* info = AllocEventInfo<item_vid_event_info>();
|
||||||
info->item_vid = GetVID();
|
info->item_vid = GetVID();
|
||||||
|
@ -1881,17 +1881,17 @@ void CItem::CopySocketTo(LPITEM pItem)
|
||||||
|
|
||||||
int CItem::GetAccessorySocketGrade()
|
int CItem::GetAccessorySocketGrade()
|
||||||
{
|
{
|
||||||
return MINMAX(0, GetSocket(0), GetAccessorySocketMaxGrade());
|
return std::clamp<int>(GetSocket(0), 0, GetAccessorySocketMaxGrade());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CItem::GetAccessorySocketMaxGrade()
|
int CItem::GetAccessorySocketMaxGrade()
|
||||||
{
|
{
|
||||||
return MINMAX(0, GetSocket(1), ITEM_ACCESSORY_SOCKET_MAX_NUM);
|
return std::clamp<int>(GetSocket(1), 0, ITEM_ACCESSORY_SOCKET_MAX_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CItem::GetAccessorySocketDownGradeTime()
|
int CItem::GetAccessorySocketDownGradeTime()
|
||||||
{
|
{
|
||||||
return MINMAX(0, GetSocket(2), aiAccessorySocketDegradeTime[GetAccessorySocketGrade()]);
|
return std::clamp<int>(GetSocket(2), 0, aiAccessorySocketDegradeTime[GetAccessorySocketGrade()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CItem::AttrLog()
|
void CItem::AttrLog()
|
||||||
|
|
|
@ -22,7 +22,7 @@ void CItemAddonManager::ApplyAddonTo(int iAddonType, LPITEM pItem)
|
||||||
|
|
||||||
// TODO 일단 하드코딩으로 평타 스킬 수치 변경만 경우만 적용받게한다.
|
// TODO 일단 하드코딩으로 평타 스킬 수치 변경만 경우만 적용받게한다.
|
||||||
|
|
||||||
int iSkillBonus = MINMAX(-30, (int) (Random::get<std::normal_distribution<>>(0, 5) + 0.5f), 30);
|
int iSkillBonus = std::clamp((int) (Random::get<std::normal_distribution<>>(0, 5) + 0.5f), -30, 30);
|
||||||
int iNormalHitBonus = 0;
|
int iNormalHitBonus = 0;
|
||||||
if (abs(iSkillBonus) <= 20)
|
if (abs(iSkillBonus) <= 20)
|
||||||
iNormalHitBonus = -2 * iSkillBonus + abs(Random::get(-8, 8) + Random::get(-8, 8)) + Random::get(1, 4);
|
iNormalHitBonus = -2 * iSkillBonus + abs(Random::get(-8, 8) + Random::get(-8, 8)) + Random::get(1, 4);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void CItem::AddAttr(BYTE bApply, BYTE bLevel)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const TItemAttrTable & r = g_map_itemAttr[bApply];
|
const TItemAttrTable & r = g_map_itemAttr[bApply];
|
||||||
int lVal = r.lValues[MIN(4, bLevel - 1)];
|
int lVal = r.lValues[std::min(4, bLevel - 1)];
|
||||||
|
|
||||||
if (lVal)
|
if (lVal)
|
||||||
SetAttribute(i, bApply, lVal);
|
SetAttribute(i, bApply, lVal);
|
||||||
|
|
|
@ -263,7 +263,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
|
||||||
;
|
;
|
||||||
else if (item->IsStackable()) // 합칠 수 있는 아이템의 경우
|
else if (item->IsStackable()) // 합칠 수 있는 아이템의 경우
|
||||||
{
|
{
|
||||||
count = MINMAX(1, count, ITEM_MAX_COUNT);
|
count = std::clamp<int>(count, 1, ITEM_MAX_COUNT);
|
||||||
|
|
||||||
if (bTryMagic && count <= 1 && IS_SET(item->GetFlag(), ITEM_FLAG_MAKECOUNT))
|
if (bTryMagic && count <= 1 && IS_SET(item->GetFlag(), ITEM_FLAG_MAKECOUNT))
|
||||||
count = item->GetValue(1);
|
count = item->GetValue(1);
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool ITEM_MANAGER::ReadCommonDropItemFile(const char * c_pszFileName)
|
||||||
if (!p2)
|
if (!p2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
strncpy(szTemp, p, MIN(sizeof(szTemp), (p2 - p) + 1));
|
strncpy(szTemp, p, std::min<size_t>(sizeof(szTemp), (p2 - p) + 1));
|
||||||
p = p2 + 1;
|
p = p2 + 1;
|
||||||
|
|
||||||
switch (j)
|
switch (j)
|
||||||
|
@ -610,7 +610,7 @@ bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)
|
||||||
|
|
||||||
int iRarePct = 0;
|
int iRarePct = 0;
|
||||||
str_to_number(iRarePct, pTok->at(3).c_str());
|
str_to_number(iRarePct, pTok->at(3).c_str());
|
||||||
iRarePct = MINMAX(0, iRarePct, 100);
|
iRarePct = std::clamp(iRarePct, 0, 100);
|
||||||
|
|
||||||
sys_log(0," %s count %d rare %d", name.c_str(), iCount, iRarePct);
|
sys_log(0," %s count %d rare %d", name.c_str(), iCount, iRarePct);
|
||||||
pkGroup->AddItem(dwVnum, iCount, iPartPct, iRarePct);
|
pkGroup->AddItem(dwVnum, iCount, iPartPct, iRarePct);
|
||||||
|
|
|
@ -268,7 +268,7 @@ void heartbeat(LPHEART ht, int pulse)
|
||||||
|
|
||||||
if (save_idx < g_vec_save.size())
|
if (save_idx < g_vec_save.size())
|
||||||
{
|
{
|
||||||
count = MIN(100, g_vec_save.size() - save_idx);
|
count = std::min<int>(100, g_vec_save.size() - save_idx);
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i, ++save_idx)
|
for (int i = 0; i < count; ++i, ++save_idx)
|
||||||
db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE, 0, &g_vec_save[save_idx], sizeof(TPlayerTable));
|
db_clientdesc->DBPacket(HEADER_GD_PLAYER_SAVE, 0, &g_vec_save[save_idx], sizeof(TPlayerTable));
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace marriage
|
||||||
|
|
||||||
int TMarriage::GetMarriageGrade()
|
int TMarriage::GetMarriageGrade()
|
||||||
{
|
{
|
||||||
int point = MINMAX(50, GetMarriagePoint(), 100);
|
int point = std::clamp(GetMarriagePoint(), 50, 100);
|
||||||
if (point < 65)
|
if (point < 65)
|
||||||
return 0;
|
return 0;
|
||||||
else if (point < 80)
|
else if (point < 80)
|
||||||
|
@ -80,7 +80,7 @@ namespace marriage
|
||||||
{
|
{
|
||||||
int value = quest::CQuestManager::instance().GetEventFlag("lovepoint");
|
int value = quest::CQuestManager::instance().GetEventFlag("lovepoint");
|
||||||
if (value)
|
if (value)
|
||||||
return MINMAX(0, value, 100);
|
return std::clamp(value, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
int point_per_day = MARRIAGE_POINT_PER_DAY;
|
int point_per_day = MARRIAGE_POINT_PER_DAY;
|
||||||
|
@ -112,7 +112,7 @@ namespace marriage
|
||||||
// 날짜에 의한 영향 60% 하루당 6%
|
// 날짜에 의한 영향 60% 하루당 6%
|
||||||
// 전투에 의한 영향 60%
|
// 전투에 의한 영향 60%
|
||||||
// 토탈 100%
|
// 토탈 100%
|
||||||
return MIN(50 + MIN(days * point_per_day, max_limit) + MIN(love_point / 1000000, max_limit), 100);
|
return std::min(50 + std::min(days * point_per_day, max_limit) + std::min(love_point / 1000000, max_limit), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TMarriage::IsNear()
|
bool TMarriage::IsNear()
|
||||||
|
@ -433,7 +433,7 @@ namespace marriage
|
||||||
bSave = true;
|
bSave = true;
|
||||||
love_point += point;
|
love_point += point;
|
||||||
|
|
||||||
love_point = MIN( love_point, 2000000000 );
|
love_point = std::min( love_point, 2000000000 );
|
||||||
|
|
||||||
if (test_server)
|
if (test_server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace mining
|
||||||
if (!pick || pick->GetType() != ITEM_PICK)
|
if (!pick || pick->GetType() != ITEM_PICK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return defaultPct + SkillLevelAddPct[MINMAX(0, iSkillLevel, 40)] + PickGradeAddPct[MINMAX(0, pick->GetRefineLevel(), 9)];
|
return defaultPct + SkillLevelAddPct[std::clamp(iSkillLevel, 0, 40)] + PickGradeAddPct[std::clamp(pick->GetRefineLevel(), 0, 9)];
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENTINFO(mining_event_info)
|
EVENTINFO(mining_event_info)
|
||||||
|
|
|
@ -1220,8 +1220,8 @@ void CParty::ComputeRolePoint(LPCHARACTER ch, BYTE bRole, bool bAdd)
|
||||||
}
|
}
|
||||||
|
|
||||||
//SKILL_POWER_BY_LEVEL
|
//SKILL_POWER_BY_LEVEL
|
||||||
float k = (float) ch->GetSkillPowerByLevel( MIN(SKILL_MAX_LEVEL, m_iLeadership ) )/ 100.0f;
|
float k = (float) ch->GetSkillPowerByLevel(std::min<int>(SKILL_MAX_LEVEL, m_iLeadership)) / 100.0f;
|
||||||
//float k = (float) aiSkillPowerByLevel[MIN(SKILL_MAX_LEVEL, m_iLeadership)] / 100.0f;
|
//float k = (float) aiSkillPowerByLevel[std::min<int>(SKILL_MAX_LEVEL, m_iLeadership)] / 100.0f;
|
||||||
//
|
//
|
||||||
//sys_log(0,"ComputeRolePoint %fi %d, %d ", k, SKILL_MAX_LEVEL, m_iLeadership );
|
//sys_log(0,"ComputeRolePoint %fi %d, %d ", k, SKILL_MAX_LEVEL, m_iLeadership );
|
||||||
//END_SKILL_POWER_BY_LEVEL
|
//END_SKILL_POWER_BY_LEVEL
|
||||||
|
@ -1646,7 +1646,7 @@ BYTE CParty::GetMemberMaxLevel()
|
||||||
if (!bMax)
|
if (!bMax)
|
||||||
bMax = it->second.bLevel;
|
bMax = it->second.bLevel;
|
||||||
else if (it->second.bLevel)
|
else if (it->second.bLevel)
|
||||||
bMax = MAX(bMax, it->second.bLevel);
|
bMax = std::max(bMax, it->second.bLevel);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
return bMax;
|
return bMax;
|
||||||
|
@ -1668,7 +1668,7 @@ BYTE CParty::GetMemberMinLevel()
|
||||||
if (!bMin)
|
if (!bMin)
|
||||||
bMin = it->second.bLevel;
|
bMin = it->second.bLevel;
|
||||||
else if (it->second.bLevel)
|
else if (it->second.bLevel)
|
||||||
bMin = MIN(bMin, it->second.bLevel);
|
bMin = std::min(bMin, it->second.bLevel);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
return bMin;
|
return bMin;
|
||||||
|
@ -1684,7 +1684,7 @@ int CParty::ComputePartyBonusExpPercent()
|
||||||
int iBonusPartyExpFromItem = 0;
|
int iBonusPartyExpFromItem = 0;
|
||||||
|
|
||||||
// UPGRADE_PARTY_BONUS
|
// UPGRADE_PARTY_BONUS
|
||||||
int iMemberCount=MIN(8, GetNearMemberCount());
|
int iMemberCount = std::min<int>(8, GetNearMemberCount());
|
||||||
|
|
||||||
if (leader && (leader->IsEquipUniqueItem(UNIQUE_ITEM_PARTY_BONUS_EXP) || leader->IsEquipUniqueItem(UNIQUE_ITEM_PARTY_BONUS_EXP_MALL)
|
if (leader && (leader->IsEquipUniqueItem(UNIQUE_ITEM_PARTY_BONUS_EXP) || leader->IsEquipUniqueItem(UNIQUE_ITEM_PARTY_BONUS_EXP_MALL)
|
||||||
|| leader->IsEquipUniqueItem(UNIQUE_ITEM_PARTY_BONUS_EXP_GIFT) || leader->IsEquipUniqueGroup(10010)))
|
|| leader->IsEquipUniqueItem(UNIQUE_ITEM_PARTY_BONUS_EXP_GIFT) || leader->IsEquipUniqueGroup(10010)))
|
||||||
|
|
|
@ -32,8 +32,8 @@ void CPrivManager::RequestGiveGuildPriv(DWORD guild_id, BYTE type, int value, ti
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = MINMAX(0, value, 50);
|
value = std::clamp(value, 0, 50);
|
||||||
duration_sec = MINMAX(0, duration_sec, 60*60*24*7);
|
duration_sec = std::clamp<time_t>(duration_sec, 0, 60*60*24*7);
|
||||||
|
|
||||||
TPacketGiveGuildPriv p;
|
TPacketGiveGuildPriv p;
|
||||||
p.type = type;
|
p.type = type;
|
||||||
|
@ -52,8 +52,8 @@ void CPrivManager::RequestGiveEmpirePriv(BYTE empire, BYTE type, int value, time
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = MINMAX(0, value, 200);
|
value = std::clamp(value, 0, 200);
|
||||||
duration_sec = MINMAX(0, duration_sec, 60*60*24*7);
|
duration_sec = std::clamp<time_t>(duration_sec, 0, 60*60*24*7);
|
||||||
|
|
||||||
TPacketGiveEmpirePriv p;
|
TPacketGiveEmpirePriv p;
|
||||||
p.type = type;
|
p.type = type;
|
||||||
|
@ -72,7 +72,7 @@ void CPrivManager::RequestGiveCharacterPriv(DWORD pid, BYTE type, int value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = MINMAX(0, value, 100);
|
value = std::clamp(value, 0, 100);
|
||||||
|
|
||||||
TPacketGiveCharacterPriv p;
|
TPacketGiveCharacterPriv p;
|
||||||
p.type = type;
|
p.type = type;
|
||||||
|
@ -92,8 +92,8 @@ void CPrivManager::GiveGuildPriv(DWORD guild_id, BYTE type, int value, BYTE bLog
|
||||||
|
|
||||||
sys_log(0,"Set Guild Priv: guild_id(%u) type(%d) value(%d) duration_sec(%d)", guild_id, type, value, end_time_sec - get_global_time());
|
sys_log(0,"Set Guild Priv: guild_id(%u) type(%d) value(%d) duration_sec(%d)", guild_id, type, value, end_time_sec - get_global_time());
|
||||||
|
|
||||||
value = MINMAX(0, value, 50);
|
value = std::clamp(value, 0, 50);
|
||||||
end_time_sec = MINMAX(0, end_time_sec, get_global_time()+60*60*24*7);
|
end_time_sec = std::clamp<time_t>(end_time_sec, 0, get_global_time()+60*60*24*7);
|
||||||
|
|
||||||
m_aPrivGuild[type][guild_id].value = value;
|
m_aPrivGuild[type][guild_id].value = value;
|
||||||
m_aPrivGuild[type][guild_id].end_time_sec = end_time_sec;
|
m_aPrivGuild[type][guild_id].end_time_sec = end_time_sec;
|
||||||
|
@ -132,7 +132,7 @@ void CPrivManager::GiveCharacterPriv(DWORD pid, BYTE type, int value, BYTE bLog)
|
||||||
|
|
||||||
sys_log(0,"Set Character Priv %u %d %d", pid, type, value);
|
sys_log(0,"Set Character Priv %u %d %d", pid, type, value);
|
||||||
|
|
||||||
value = MINMAX(0, value, 100);
|
value = std::clamp(value, 0, 100);
|
||||||
|
|
||||||
m_aPrivChar[type][pid] = value;
|
m_aPrivChar[type][pid] = value;
|
||||||
|
|
||||||
|
@ -150,8 +150,8 @@ void CPrivManager::GiveEmpirePriv(BYTE empire, BYTE type, int value, BYTE bLog,
|
||||||
|
|
||||||
sys_log(0, "Set Empire Priv: empire(%d) type(%d) value(%d) duration_sec(%d)", empire, type, value, end_time_sec-get_global_time());
|
sys_log(0, "Set Empire Priv: empire(%d) type(%d) value(%d) duration_sec(%d)", empire, type, value, end_time_sec-get_global_time());
|
||||||
|
|
||||||
value = MINMAX(0, value, 200);
|
value = std::clamp(value, 0, 200);
|
||||||
end_time_sec = MINMAX(0, end_time_sec, get_global_time()+60*60*24*7);
|
end_time_sec = std::clamp<time_t>(end_time_sec, 0, get_global_time()+60*60*24*7);
|
||||||
|
|
||||||
SPrivEmpireData& rkPrivEmpireData=m_aakPrivEmpireData[type][empire];
|
SPrivEmpireData& rkPrivEmpireData=m_aakPrivEmpireData[type][empire];
|
||||||
rkPrivEmpireData.m_value = value;
|
rkPrivEmpireData.m_value = value;
|
||||||
|
@ -235,11 +235,11 @@ int CPrivManager::GetPriv(LPCHARACTER ch, BYTE type)
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
// 개인, 제국, 길드, 전체 중 큰 값을 취한다.
|
// 개인, 제국, 길드, 전체 중 큰 값을 취한다.
|
||||||
val = MAX(val_ch, GetPrivByEmpire(0, type));
|
val = std::max(val_ch, GetPrivByEmpire(0, type));
|
||||||
val = MAX(val, GetPrivByEmpire(ch->GetEmpire(), type));
|
val = std::max(val, GetPrivByEmpire(ch->GetEmpire(), type));
|
||||||
|
|
||||||
if (ch->GetGuild())
|
if (ch->GetGuild())
|
||||||
val = MAX(val, GetPrivByGuild(ch->GetGuild()->GetID(), type));
|
val = std::max(val, GetPrivByGuild(ch->GetGuild()->GetID(), type));
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ void CPVPManager::Insert(LPCHARACTER pkChr, LPCHARACTER pkVictim)
|
||||||
{
|
{
|
||||||
TPacketGCWhisper pack;
|
TPacketGCWhisper pack;
|
||||||
|
|
||||||
int len = MIN(CHAT_MAX_LEN, strlen(msg) + 1);
|
int len = std::min<int>(CHAT_MAX_LEN, strlen(msg) + 1);
|
||||||
|
|
||||||
pack.bHeader = HEADER_GC_WHISPER;
|
pack.bHeader = HEADER_GC_WHISPER;
|
||||||
pack.wSize = sizeof(TPacketGCWhisper) + len;
|
pack.wSize = sizeof(TPacketGCWhisper) + len;
|
||||||
|
|
|
@ -1133,7 +1133,7 @@ namespace quest
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWORD dwVnum = static_cast<DWORD>(lua_tonumber(L, 1));
|
const DWORD dwVnum = static_cast<DWORD>(lua_tonumber(L, 1));
|
||||||
const size_t count = MINMAX(1, static_cast<size_t>(lua_tonumber(L, 2)), 10);
|
const size_t count = std::clamp<size_t>(static_cast<size_t>(lua_tonumber(L, 2)), 1, 10);
|
||||||
const bool isAggresive = static_cast<bool>(lua_toboolean(L, 3));
|
const bool isAggresive = static_cast<bool>(lua_toboolean(L, 3));
|
||||||
size_t SpawnCount = 0;
|
size_t SpawnCount = 0;
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace quest
|
||||||
if (!lua_isnumber(L, 1))
|
if (!lua_isnumber(L, 1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int newlevel = MINMAX(0, (int)lua_tonumber(L, 1), HORSE_MAX_LEVEL);
|
int newlevel = std::clamp((int)lua_tonumber(L, 1), 0, HORSE_MAX_LEVEL);
|
||||||
ch->SetHorseLevel(newlevel);
|
ch->SetHorseLevel(newlevel);
|
||||||
ch->ComputePoints();
|
ch->ComputePoints();
|
||||||
ch->SkillLevelPacket();
|
ch->SkillLevelPacket();
|
||||||
|
@ -145,7 +145,7 @@ namespace quest
|
||||||
{
|
{
|
||||||
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
|
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
|
||||||
|
|
||||||
int pct = MINMAX(0, ch->GetHorseHealth() * 100 / ch->GetHorseMaxHealth(), 100);
|
int pct = std::clamp(ch->GetHorseHealth() * 100 / ch->GetHorseMaxHealth(), 0, 100);
|
||||||
sys_log(1, "horse.get_health_pct %d", pct);
|
sys_log(1, "horse.get_health_pct %d", pct);
|
||||||
|
|
||||||
if (ch->GetHorseLevel())
|
if (ch->GetHorseLevel())
|
||||||
|
@ -171,7 +171,7 @@ namespace quest
|
||||||
int horse_get_stamina_pct(lua_State* L)
|
int horse_get_stamina_pct(lua_State* L)
|
||||||
{
|
{
|
||||||
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
|
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
|
||||||
int pct = MINMAX(0, ch->GetHorseStamina() * 100 / ch->GetHorseMaxStamina(), 100);
|
int pct = std::clamp(ch->GetHorseStamina() * 100 / ch->GetHorseMaxStamina(), 0, 100);
|
||||||
sys_log(1, "horse.get_stamina_pct %d", pct);
|
sys_log(1, "horse.get_stamina_pct %d", pct);
|
||||||
|
|
||||||
if (ch->GetHorseLevel())
|
if (ch->GetHorseLevel())
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace quest
|
||||||
lua_pushnumber(L, 0);
|
lua_pushnumber(L, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
lua_pushnumber(L, MAX(0, npc->GetPoint(POINT_ATT_GRADE_BONUS)));
|
lua_pushnumber(L, std::max(0, npc->GetPoint(POINT_ATT_GRADE_BONUS)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ namespace quest
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
npc->SetPoint(POINT_ATT_GRADE_BONUS, MAX(0, npc->GetPoint(POINT_ATT_GRADE_BONUS)-1));
|
npc->SetPoint(POINT_ATT_GRADE_BONUS, std::max(0, npc->GetPoint(POINT_ATT_GRADE_BONUS)-1));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ namespace quest
|
||||||
lua_pushnumber(L, 0);
|
lua_pushnumber(L, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
lua_pushnumber(L, MAX(0, npc->GetPoint(POINT_DEF_GRADE_BONUS)));
|
lua_pushnumber(L, std::max(0, npc->GetPoint(POINT_DEF_GRADE_BONUS)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace quest
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
npc->SetPoint(POINT_DEF_GRADE_BONUS, MAX(0, npc->GetPoint(POINT_DEF_GRADE_BONUS)-1));
|
npc->SetPoint(POINT_DEF_GRADE_BONUS, std::max(0, npc->GetPoint(POINT_DEF_GRADE_BONUS)-1));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -865,8 +865,8 @@ namespace quest
|
||||||
|
|
||||||
//포인트 : 스킬, 서브스킬, 스탯
|
//포인트 : 스킬, 서브스킬, 스탯
|
||||||
ch->PointChange(POINT_SKILL, newLevel - ch->GetLevel());
|
ch->PointChange(POINT_SKILL, newLevel - ch->GetLevel());
|
||||||
ch->PointChange(POINT_SUB_SKILL, newLevel < 10 ? 0 : newLevel - MAX(ch->GetLevel(), 9));
|
ch->PointChange(POINT_SUB_SKILL, newLevel < 10 ? 0 : newLevel - std::max(ch->GetLevel(), 9));
|
||||||
ch->PointChange(POINT_STAT, ((MINMAX(1, newLevel, 90) - ch->GetLevel()) * 3) + ch->GetPoint(POINT_LEVEL_STEP));
|
ch->PointChange(POINT_STAT, ((std::clamp(newLevel, 1, 90) - ch->GetLevel()) * 3) + ch->GetPoint(POINT_LEVEL_STEP));
|
||||||
//레벨
|
//레벨
|
||||||
ch->PointChange(POINT_LEVEL, newLevel - ch->GetLevel());
|
ch->PointChange(POINT_LEVEL, newLevel - ch->GetLevel());
|
||||||
//HP, SP
|
//HP, SP
|
||||||
|
@ -1149,7 +1149,7 @@ namespace quest
|
||||||
|
|
||||||
sys_log(0, "QUEST [REWARD] %s give exp %s lev %d percent %g%%", ch->GetName(), lua_tostring(L, 1), lev, proc);
|
sys_log(0, "QUEST [REWARD] %s give exp %s lev %d percent %g%%", ch->GetName(), lua_tostring(L, 1), lev, proc);
|
||||||
|
|
||||||
DWORD exp = (DWORD)((exp_table[MINMAX(0, lev, PLAYER_EXP_TABLE_MAX)] * proc) / 100);
|
DWORD exp = (DWORD)((exp_table[std::clamp<int>(lev, 0, PLAYER_EXP_TABLE_MAX)] * proc) / 100);
|
||||||
PC * pPC = CQuestManager::instance().GetCurrentPC();
|
PC * pPC = CQuestManager::instance().GetCurrentPC();
|
||||||
|
|
||||||
LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), exp, 0);
|
LogManager::instance().QuestRewardLog(pPC->GetCurrentQuestName().c_str(), ch->GetPlayerID(), ch->GetLevel(), exp, 0);
|
||||||
|
|
|
@ -159,7 +159,7 @@ namespace quest
|
||||||
|
|
||||||
istreambuf_iterator<char> ib(inf), ie;
|
istreambuf_iterator<char> ib(inf), ie;
|
||||||
|
|
||||||
m_mapOwnArgQuest[event_index][quest_index][state_index].resize(MAX(index + 1, m_mapOwnArgQuest[event_index][quest_index][state_index].size()));
|
m_mapOwnArgQuest[event_index][quest_index][state_index].resize(std::max<size_t>(index + 1, m_mapOwnArgQuest[event_index][quest_index][state_index].size()));
|
||||||
|
|
||||||
if (type_name == "when")
|
if (type_name == "when")
|
||||||
{
|
{
|
||||||
|
|
|
@ -198,7 +198,7 @@ bool CSafebox::MoveItem(BYTE bCell, BYTE bDestCell, BYTE count)
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
count = item->GetCount();
|
count = item->GetCount();
|
||||||
|
|
||||||
count = MIN(200 - item2->GetCount(), count);
|
count = std::min<BYTE>(200 - item2->GetCount(), count);
|
||||||
|
|
||||||
if (item->GetCount() >= count)
|
if (item->GetCount() >= count)
|
||||||
Remove(bCell);
|
Remove(bCell);
|
||||||
|
|
|
@ -1295,9 +1295,6 @@ bool SECTREE_MANAGER::ForAttrRegionRightAngle( int lMapIndex, int lCX, int lCY,
|
||||||
return mode == ATTR_REGION_MODE_CHECK ? false : true;
|
return mode == ATTR_REGION_MODE_CHECK ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define min( l, r ) ((l) < (r) ? (l) : (r))
|
|
||||||
#define max( l, r ) ((l) < (r) ? (r) : (l))
|
|
||||||
|
|
||||||
bool SECTREE_MANAGER::ForAttrRegionFreeAngle( int lMapIndex, int lCX, int lCY, int lCW, int lCH, int lRotate, DWORD dwAttr, EAttrRegionMode mode )
|
bool SECTREE_MANAGER::ForAttrRegionFreeAngle( int lMapIndex, int lCX, int lCY, int lCW, int lCH, int lRotate, DWORD dwAttr, EAttrRegionMode mode )
|
||||||
{
|
{
|
||||||
float fx1 = (-lCW/2) * sinf(float(lRotate)/180.0f*3.14f) + (-lCH/2) * cosf(float(lRotate)/180.0f*3.14f);
|
float fx1 = (-lCW/2) * sinf(float(lRotate)/180.0f*3.14f) + (-lCH/2) * cosf(float(lRotate)/180.0f*3.14f);
|
||||||
|
@ -1330,15 +1327,15 @@ bool SECTREE_MANAGER::ForAttrRegionFreeAngle( int lMapIndex, int lCX, int lCY, i
|
||||||
float fb3 = fy4 - fTilt1*fx4;
|
float fb3 = fy4 - fTilt1*fx4;
|
||||||
float fb4 = fy4 - fTilt2*fx4;
|
float fb4 = fy4 - fTilt2*fx4;
|
||||||
|
|
||||||
float fxMin = min(fx1, min(fx2, min(fx3, fx4)));
|
float fxMin = std::min(fx1, std::min(fx2, std::min(fx3, fx4)));
|
||||||
float fxMax = max(fx1, max(fx2, max(fx3, fx4)));
|
float fxMax = std::max(fx1, std::max(fx2, std::max(fx3, fx4)));
|
||||||
for (int i = int(fxMin); i < int(fxMax); ++i)
|
for (int i = int(fxMin); i < int(fxMax); ++i)
|
||||||
{
|
{
|
||||||
float fyValue1 = fTilt1*i + min(fb1, fb3);
|
float fyValue1 = fTilt1*i + std::min(fb1, fb3);
|
||||||
float fyValue2 = fTilt2*i + min(fb2, fb4);
|
float fyValue2 = fTilt2*i + std::min(fb2, fb4);
|
||||||
|
|
||||||
float fyValue3 = fTilt1*i + max(fb1, fb3);
|
float fyValue3 = fTilt1*i + std::max(fb1, fb3);
|
||||||
float fyValue4 = fTilt2*i + max(fb2, fb4);
|
float fyValue4 = fTilt2*i + std::max(fb2, fb4);
|
||||||
|
|
||||||
float fMinValue;
|
float fMinValue;
|
||||||
float fMaxValue;
|
float fMaxValue;
|
||||||
|
@ -1351,7 +1348,7 @@ bool SECTREE_MANAGER::ForAttrRegionFreeAngle( int lMapIndex, int lCX, int lCY, i
|
||||||
else
|
else
|
||||||
fMinValue = fyValue4;
|
fMinValue = fyValue4;
|
||||||
|
|
||||||
for (int j = int(min(fMinValue, fMaxValue)); j < int(max(fMinValue, fMaxValue)); ++j) {
|
for (int j = int(std::min(fMinValue, fMaxValue)); j < int(std::max(fMinValue, fMaxValue)); ++j) {
|
||||||
if ( ForAttrRegionCell( lMapIndex, lCX + (lCW / 2) + i, lCY + (lCH / 2) + j, dwAttr, mode ) )
|
if ( ForAttrRegionCell( lMapIndex, lCX + (lCW / 2) + i, lCY + (lCH / 2) + j, dwAttr, mode ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ EVENTFUNC(target_event)
|
||||||
int iDist = 5000;
|
int iDist = 5000;
|
||||||
|
|
||||||
if (info->iMapIndex != pkChr->GetMapIndex())
|
if (info->iMapIndex != pkChr->GetMapIndex())
|
||||||
return MINMAX(passes_per_sec / 2, iDist / (1500 / passes_per_sec), passes_per_sec * 5);
|
return std::clamp(iDist / (1500 / passes_per_sec), passes_per_sec / 2, passes_per_sec * 5);
|
||||||
|
|
||||||
switch (info->iType)
|
switch (info->iType)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ EVENTFUNC(target_event)
|
||||||
if (!bRet)
|
if (!bRet)
|
||||||
return passes_per_sec;
|
return passes_per_sec;
|
||||||
else
|
else
|
||||||
return MINMAX(passes_per_sec / 2, iDist / (1500 / passes_per_sec), passes_per_sec * 5);
|
return std::clamp(iDist / (1500 / passes_per_sec), passes_per_sec / 2, passes_per_sec * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTargetManager::CreateTarget(DWORD dwPID,
|
void CTargetManager::CreateTarget(DWORD dwPID,
|
||||||
|
|
|
@ -12,7 +12,7 @@ CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h)
|
||||||
CGrid::CGrid(CGrid * pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h)
|
CGrid::CGrid(CGrid * pkGrid, int w, int h) : m_iWidth(w), m_iHeight(h)
|
||||||
{
|
{
|
||||||
m_pGrid = new char[m_iWidth * m_iHeight];
|
m_pGrid = new char[m_iWidth * m_iHeight];
|
||||||
int iSize = std::MIN(w * h, pkGrid->m_iWidth * pkGrid->m_iHeight);
|
int iSize = std::min(w * h, pkGrid->m_iWidth * pkGrid->m_iHeight);
|
||||||
memcpy(m_pGrid, pkGrid->m_pGrid, sizeof(char) * iSize);
|
memcpy(m_pGrid, pkGrid->m_pGrid, sizeof(char) * iSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,12 @@
|
||||||
#include "effolkronium/random.hpp"
|
#include "effolkronium/random.hpp"
|
||||||
using Random = effolkronium::random_static;
|
using Random = effolkronium::random_static;
|
||||||
|
|
||||||
#define SAFE_FREE(p) { if (p) { free( (void *) p); (p) = NULL; } }
|
#include <algorithm>
|
||||||
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
|
|
||||||
#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } }
|
|
||||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
|
||||||
|
|
||||||
#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c))
|
#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c))
|
||||||
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c))
|
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c))
|
||||||
|
|
||||||
#define str_cmp strcasecmp
|
#define str_cmp strcasecmp
|
||||||
#define STRNCPY(dst, src, len) do {strncpy(dst, src, len); dst[len] = '\0'; } while(0)
|
|
||||||
|
|
||||||
extern char * str_dup(const char * source); // 메모리 할당 해서 source 복사 한거 리턴
|
|
||||||
extern void printdata(const unsigned char * data, int bytes); // data를 hex랑 ascii로 출력 (패킷 분석 등에 쓰임)
|
|
||||||
extern int filesize(FILE * fp); // 파일 크기 리턴
|
|
||||||
|
|
||||||
#define core_dump() core_dump_unix(__FILE__, __LINE__)
|
#define core_dump() core_dump_unix(__FILE__, __LINE__)
|
||||||
extern void core_dump_unix(const char *who, WORD line); // 코어를 강제로 덤프
|
extern void core_dump_unix(const char *who, WORD line); // 코어를 강제로 덤프
|
||||||
|
@ -29,12 +21,6 @@ using Random = effolkronium::random_static;
|
||||||
|
|
||||||
extern void trim_and_lower(const char * src, char * dest, size_t dest_size);
|
extern void trim_and_lower(const char * src, char * dest, size_t dest_size);
|
||||||
|
|
||||||
// 문자열을 소문자로
|
|
||||||
extern void lower_string(const char * src, char * dest, size_t dest_len);
|
|
||||||
|
|
||||||
// arg1이 arg2로 시작하는가? (대소문자 구별하지 않음)
|
|
||||||
extern int is_abbrev(char *arg1, char *arg2);
|
|
||||||
|
|
||||||
// a와 b의 시간이 얼마나 차이나는지 리턴
|
// a와 b의 시간이 얼마나 차이나는지 리턴
|
||||||
extern struct timeval * timediff(const struct timeval *a, const struct timeval *b);
|
extern struct timeval * timediff(const struct timeval *a, const struct timeval *b);
|
||||||
|
|
||||||
|
@ -44,10 +30,6 @@ using Random = effolkronium::random_static;
|
||||||
// 현재 시간 curr_tm으로 부터 days가 지난 날을 리턴
|
// 현재 시간 curr_tm으로 부터 days가 지난 날을 리턴
|
||||||
extern struct tm * tm_calc(const struct tm *curr_tm, int days);
|
extern struct tm * tm_calc(const struct tm *curr_tm, int days);
|
||||||
|
|
||||||
extern int MAX(int a, int b); // 둘중에 큰 값을 리턴
|
|
||||||
extern int MIN(int a, int b); // 둘중에 작은 값을 리턴
|
|
||||||
extern int MINMAX(int min, int value, int max); // 최소 최대 값을 함께 비교해서 리턴
|
|
||||||
|
|
||||||
extern void thecore_sleep(struct timeval * timeout); // timeout만큼 프로세스 쉬기
|
extern void thecore_sleep(struct timeval * timeout); // timeout만큼 프로세스 쉬기
|
||||||
|
|
||||||
extern float get_float_time();
|
extern float get_float_time();
|
||||||
|
|
|
@ -162,7 +162,7 @@ void buffer_reset(LPBUFFER buffer)
|
||||||
void buffer_write(LPBUFFER& buffer, const void *src, int length)
|
void buffer_write(LPBUFFER& buffer, const void *src, int length)
|
||||||
{
|
{
|
||||||
if (buffer->write_point_pos + length >= buffer->mem_size)
|
if (buffer->write_point_pos + length >= buffer->mem_size)
|
||||||
buffer_realloc(buffer, buffer->mem_size + length + MIN(10240, length));
|
buffer_realloc(buffer, buffer->mem_size + length + std::min(10240, length));
|
||||||
|
|
||||||
memcpy(buffer->write_point, src, length);
|
memcpy(buffer->write_point, src, length);
|
||||||
buffer_write_proceed(buffer, length);
|
buffer_write_proceed(buffer, length);
|
||||||
|
|
|
@ -10,56 +10,6 @@
|
||||||
|
|
||||||
static struct timeval null_time = { 0, 0 };
|
static struct timeval null_time = { 0, 0 };
|
||||||
|
|
||||||
#define ishprint(x) ((((x) & 0xE0) > 0x90) || isprint(x))
|
|
||||||
|
|
||||||
void printdata(const unsigned char *data, int bytes)
|
|
||||||
{
|
|
||||||
int i, j, k;
|
|
||||||
const unsigned char *p;
|
|
||||||
|
|
||||||
fprintf(stderr, "------------------------------------------------------------------\n");
|
|
||||||
j = bytes;
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
k = j >= 16 ? 16 : j;
|
|
||||||
|
|
||||||
p = data;
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
if (i >= k)
|
|
||||||
fprintf(stderr, " ");
|
|
||||||
else
|
|
||||||
fprintf(stderr, "%02x ", *p);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "| ");
|
|
||||||
|
|
||||||
p = data;
|
|
||||||
for (i = 0; i < k; i++)
|
|
||||||
{
|
|
||||||
if (i >= k)
|
|
||||||
fprintf(stderr, " ");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%c", ishprint(*p) && ishprint(*(p+1)) ? *p : '.');
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
|
|
||||||
j -= 16;
|
|
||||||
data += 16;
|
|
||||||
|
|
||||||
if (j <= 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "------------------------------------------------------------------\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct timeval * timediff(const struct timeval *a, const struct timeval *b)
|
struct timeval * timediff(const struct timeval *a, const struct timeval *b)
|
||||||
{
|
{
|
||||||
static struct timeval rslt;
|
static struct timeval rslt;
|
||||||
|
@ -166,73 +116,6 @@ void trim_and_lower(const char * src, char * dest, size_t dest_size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void lower_string(const char *src, char *dest, size_t dest_size)
|
|
||||||
{
|
|
||||||
const char* tmp = src;
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
if (!dest || dest_size == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!src)
|
|
||||||
{
|
|
||||||
*dest = '\0';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// \0 확보
|
|
||||||
--dest_size;
|
|
||||||
|
|
||||||
while (*tmp && len < dest_size)
|
|
||||||
{
|
|
||||||
*(dest++) = LOWER(*tmp); // LOWER는 매크로라 ++ 쓰면 안됨
|
|
||||||
++tmp;
|
|
||||||
++len;
|
|
||||||
}
|
|
||||||
|
|
||||||
*dest = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
char *str_dup(const char *source)
|
|
||||||
{
|
|
||||||
char *new_line;
|
|
||||||
|
|
||||||
CREATE(new_line, char, strlen(source) + 1);
|
|
||||||
return (strcpy(new_line, source));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* arg1 이 arg2 의 앞단과 같을 때 1 을 리턴한다. */
|
|
||||||
int is_abbrev(char *arg1, char *arg2)
|
|
||||||
{
|
|
||||||
if (!*arg1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (; *arg1 && *arg2; arg1++, arg2++)
|
|
||||||
if (LOWER(*arg1) != LOWER(*arg2))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!*arg1)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int filesize(FILE *fp)
|
|
||||||
{
|
|
||||||
int pos;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
pos = ftell(fp);
|
|
||||||
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
size = ftell(fp);
|
|
||||||
fseek(fp, pos, SEEK_SET);
|
|
||||||
|
|
||||||
return (size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* "Name : 비엽" 과 같이 "항목 : 값" 으로 이루어진 문자열에서
|
/* "Name : 비엽" 과 같이 "항목 : 값" 으로 이루어진 문자열에서
|
||||||
항목을 token 으로, 값을 value 로 복사하여 리턴한다. */
|
항목을 token 으로, 값을 value 로 복사하여 리턴한다. */
|
||||||
void parse_token(char *src, char *token, char *value)
|
void parse_token(char *src, char *token, char *value)
|
||||||
|
@ -327,24 +210,6 @@ struct tm * tm_calc(const struct tm * curr_tm, int days)
|
||||||
return (&new_tm);
|
return (&new_tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MIN(int a, int b)
|
|
||||||
{
|
|
||||||
return a < b ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MAX(int a, int b)
|
|
||||||
{
|
|
||||||
return a > b ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MINMAX(int min, int value, int max)
|
|
||||||
{
|
|
||||||
register int tv;
|
|
||||||
|
|
||||||
tv = (min > value ? min : value);
|
|
||||||
return (max < tv) ? max : tv;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
void thecore_sleep(struct timeval* timeout)
|
void thecore_sleep(struct timeval* timeout)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue