diff --git a/.gitignore b/.gitignore index 9491a2f..2ba7ded 100644 --- a/.gitignore +++ b/.gitignore @@ -360,4 +360,7 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd \ No newline at end of file +FodyWeavers.xsd + +# Debug folder +test/ diff --git a/db/src/AuctionManager.h b/db/src/AuctionManager.h index 76f65f6..5643e99 100644 --- a/db/src/AuctionManager.h +++ b/db/src/AuctionManager.h @@ -5,7 +5,7 @@ #include #include "Cache.h" -#include "../../common/auction_table.h" +#include class CItemCache; class CAuctionItemInfoCache; diff --git a/db/src/BlockCountry.cpp b/db/src/BlockCountry.cpp index d28cc52..4a05025 100644 --- a/db/src/BlockCountry.cpp +++ b/db/src/BlockCountry.cpp @@ -61,7 +61,7 @@ bool CBlockCountry::Load() BLOCK_IP *block_ip = new BLOCK_IP; block_ip->ip_from = strtoul(row[0], NULL, 10); block_ip->ip_to = strtoul(row[1], NULL, 10); - strlcpy(block_ip->country, row[2], sizeof(block_ip->country)); + strncpy(block_ip->country, row[2], sizeof(block_ip->country)); m_block_ip.push_back(block_ip); sys_log(0, "BLOCKED_IP : %u - %u", block_ip->ip_from, block_ip->ip_to); @@ -174,7 +174,7 @@ void CBlockCountry::SendBlockExceptionOne(CPeer *peer, const char *login, BYTE c TPacketBlockException packet; packet.cmd = cmd; - strlcpy(packet.login, login, sizeof(packet.login)); + strncpy(packet.login, login, sizeof(packet.login)); peer->EncodeHeader(HEADER_DG_BLOCK_EXCEPTION, 0, sizeof(TPacketBlockException)); peer->Encode(&packet, sizeof(packet)); diff --git a/db/src/Cache.h b/db/src/Cache.h index 2548143..5347937 100644 --- a/db/src/Cache.h +++ b/db/src/Cache.h @@ -2,8 +2,8 @@ #ifndef __INC_DB_CACHE_H__ #define __INC_DB_CACHE_H__ -#include "../../common/cache.h" -#include "../../common/auction_table.h" +#include +#include class CItemCache : public cache { diff --git a/db/src/ClientManager.cpp b/db/src/ClientManager.cpp index 223e53f..6d09043 100644 --- a/db/src/ClientManager.cpp +++ b/db/src/ClientManager.cpp @@ -1,9 +1,9 @@ #include "stdafx.h" -#include "../../common/billing.h" -#include "../../common/building.h" -#include "../../common/VnumHelper.h" +#include +#include +#include #include "../../libgame/include/grid.h" #include "ClientManager.h" @@ -122,7 +122,7 @@ bool CClientManager::Initialize() char szBindIP[128]; if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128)) - strlcpy(szBindIP, "0", sizeof(szBindIP)); + strncpy(szBindIP, "0", sizeof(szBindIP)); m_fdAccept = socket_tcp_bind(szBindIP, tmpValue); @@ -483,11 +483,11 @@ void CClientManager::QUERY_QUEST_SAVE(CPeer * pkPeer, TQuestTable * pTable, DWOR void CClientManager::QUERY_SAFEBOX_LOAD(CPeer * pkPeer, DWORD dwHandle, TSafeboxLoadPacket * packet, bool bMall) { ClientHandleInfo * pi = new ClientHandleInfo(dwHandle); - strlcpy(pi->safebox_password, packet->szPassword, sizeof(pi->safebox_password)); + strncpy(pi->safebox_password, packet->szPassword, sizeof(pi->safebox_password)); pi->account_id = packet->dwID; pi->account_index = 0; pi->ip[0] = bMall ? 1 : 0; - strlcpy(pi->login, packet->szLogin, sizeof(pi->login)); + strncpy(pi->login, packet->szLogin, sizeof(pi->login)); char szQuery[QUERY_MAX_LEN]; snprintf(szQuery, sizeof(szQuery), @@ -513,7 +513,7 @@ void CClientManager::RESULT_SAFEBOX_LOAD(CPeer * pkPeer, SQLMsg * msg) if (pi->account_index == 0) { char szSafeboxPassword[SAFEBOX_PASSWORD_MAX_LEN + 1]; - strlcpy(szSafeboxPassword, pi->safebox_password, sizeof(szSafeboxPassword)); + strncpy(szSafeboxPassword, pi->safebox_password, sizeof(szSafeboxPassword)); TSafeboxTable * pSafebox = new TSafeboxTable; memset(pSafebox, 0, sizeof(TSafeboxTable)); @@ -853,8 +853,8 @@ void CClientManager::RESULT_SAFEBOX_CHANGE_SIZE(CPeer * pkPeer, SQLMsg * msg) void CClientManager::QUERY_SAFEBOX_CHANGE_PASSWORD(CPeer * pkPeer, DWORD dwHandle, TSafeboxChangePasswordPacket * p) { ClientHandleInfo * pi = new ClientHandleInfo(dwHandle); - strlcpy(pi->safebox_password, p->szNewPassword, sizeof(pi->safebox_password)); - strlcpy(pi->login, p->szOldPassword, sizeof(pi->login)); + strncpy(pi->safebox_password, p->szNewPassword, sizeof(pi->safebox_password)); + strncpy(pi->login, p->szOldPassword, sizeof(pi->login)); pi->account_id = p->dwID; char szQuery[QUERY_MAX_LEN]; @@ -1081,7 +1081,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD // TMapLocation kMapLocations; - strlcpy(kMapLocations.szHost, peer->GetPublicIP(), sizeof(kMapLocations.szHost)); + strncpy(kMapLocations.szHost, peer->GetPublicIP(), sizeof(kMapLocations.szHost)); kMapLocations.wPort = peer->GetListenPort(); thecore_memcpy(kMapLocations.alMaps, peer->GetMaps(), sizeof(kMapLocations.alMaps)); @@ -1104,7 +1104,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD if (tmp->GetChannel() == GUILD_WARP_WAR_CHANNEL || tmp->GetChannel() == peer->GetChannel()) { TMapLocation kMapLocation2; - strlcpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost)); + strncpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost)); kMapLocation2.wPort = tmp->GetListenPort(); thecore_memcpy(kMapLocation2.alMaps, tmp->GetMaps(), sizeof(kMapLocation2.alMaps)); vec_kMapLocations.push_back(kMapLocation2); @@ -1131,7 +1131,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD if (tmp->GetChannel() == 1 || tmp->GetChannel() == peer->GetChannel()) { TMapLocation kMapLocation2; - strlcpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost)); + strncpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost)); kMapLocation2.wPort = tmp->GetListenPort(); thecore_memcpy(kMapLocation2.alMaps, tmp->GetMaps(), sizeof(kMapLocation2.alMaps)); vec_kMapLocations.push_back(kMapLocation2); @@ -1159,7 +1159,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD { TMapLocation kMapLocation2; - strlcpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost)); + strncpy(kMapLocation2.szHost, tmp->GetPublicIP(), sizeof(kMapLocation2.szHost)); kMapLocation2.wPort = tmp->GetListenPort(); thecore_memcpy(kMapLocation2.alMaps, tmp->GetMaps(), sizeof(kMapLocation2.alMaps)); @@ -1191,7 +1191,7 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD TPacketDGP2P p2pSetupPacket; p2pSetupPacket.wPort = peer->GetP2PPort(); p2pSetupPacket.bChannel = peer->GetChannel(); - strlcpy(p2pSetupPacket.szHost, peer->GetPublicIP(), sizeof(p2pSetupPacket.szHost)); + strncpy(p2pSetupPacket.szHost, peer->GetPublicIP(), sizeof(p2pSetupPacket.szHost)); for (itertype(m_peerList) i = m_peerList.begin(); i != m_peerList.end();++i) { @@ -1226,8 +1226,8 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD r.id = pck->dwID; trim_and_lower(pck->szLogin, r.login, sizeof(r.login)); - strlcpy(r.social_id, pck->szSocialID, sizeof(r.social_id)); - strlcpy(r.passwd, "TEMP", sizeof(r.passwd)); + strncpy(r.social_id, pck->szSocialID, sizeof(r.social_id)); + strncpy(r.passwd, "TEMP", sizeof(r.passwd)); InsertLoginData(pkLD); @@ -1240,8 +1240,8 @@ void CClientManager::QUERY_SETUP(CPeer * peer, DWORD dwHandle, const char * c_pD { TPacketBillingRepair pck_repair; pck_repair.dwLoginKey = pkLD->GetKey(); - strlcpy(pck_repair.szLogin, pck->szLogin, sizeof(pck_repair.szLogin)); - strlcpy(pck_repair.szHost, pck->szHost, sizeof(pck_repair.szHost)); + strncpy(pck_repair.szLogin, pck->szLogin, sizeof(pck_repair.szLogin)); + strncpy(pck_repair.szHost, pck->szHost, sizeof(pck_repair.szHost)); vec_repair.push_back(pck_repair); } } @@ -1791,8 +1791,8 @@ void CClientManager::QUERY_AUTH_LOGIN(CPeer * pkPeer, DWORD dwHandle, TPacketGDA r.id = p->dwID; trim_and_lower(p->szLogin, r.login, sizeof(r.login)); - strlcpy(r.social_id, p->szSocialID, sizeof(r.social_id)); - strlcpy(r.passwd, "TEMP", sizeof(r.passwd)); + strncpy(r.social_id, p->szSocialID, sizeof(r.social_id)); + strncpy(r.passwd, "TEMP", sizeof(r.passwd)); sys_log(0, "AUTH_LOGIN id(%u) login(%s) social_id(%s) login_key(%u), client_key(%u %u %u %u)", p->dwID, p->szLogin, p->szSocialID, p->dwLoginKey, @@ -1832,7 +1832,7 @@ void CClientManager::BillingExpire(TPacketBillingExpire * p) if (pkPeer) { - strlcpy(p->szLogin, pkLD->GetAccountRef().login, sizeof(p->szLogin)); + strncpy(p->szLogin, pkLD->GetAccountRef().login, sizeof(p->szLogin)); pkPeer->EncodeHeader(HEADER_DG_BILLING_EXPIRE, 0, sizeof(TPacketBillingExpire)); pkPeer->Encode(p, sizeof(TPacketBillingExpire)); } @@ -1945,8 +1945,8 @@ void CClientManager::SendAllLoginToBilling() CLoginData * pkLD = (it++)->second; p.dwLoginKey = pkLD->GetKey(); - strlcpy(p.szLogin, pkLD->GetAccountRef().login, sizeof(p.szLogin)); - strlcpy(p.szHost, pkLD->GetIP(), sizeof(p.szHost)); + strncpy(p.szLogin, pkLD->GetAccountRef().login, sizeof(p.szLogin)); + strncpy(p.szHost, pkLD->GetIP(), sizeof(p.szHost)); sys_log(0, "SendAllLoginToBilling %s %s", pkLD->GetAccountRef().login, pkLD->GetIP()); vec.push_back(p); } @@ -3332,8 +3332,8 @@ bool CClientManager::InitializeLocalization() int col = 0; tLocale locale; - strlcpy(locale.szValue, row[col++], sizeof(locale.szValue)); - strlcpy(locale.szKey, row[col++], sizeof(locale.szKey)); + strncpy(locale.szValue, row[col++], sizeof(locale.szValue)); + strncpy(locale.szKey, row[col++], sizeof(locale.szKey)); //DB_NAME_COLUMN Setting if (strcmp(locale.szKey, "LOCALE") == 0) @@ -3731,9 +3731,9 @@ bool CClientManager::__GetAdminInfo(const char *szIP, std::vector & str_to_number(Info.m_ID, row[idx++]); trim_and_lower(row[idx++], Info.m_szAccount, sizeof(Info.m_szAccount)); - strlcpy(Info.m_szName, row[idx++], sizeof(Info.m_szName)); - strlcpy(Info.m_szContactIP, row[idx++], sizeof(Info.m_szContactIP)); - strlcpy(Info.m_szServerIP, row[idx++], sizeof(Info.m_szServerIP)); + strncpy(Info.m_szName, row[idx++], sizeof(Info.m_szName)); + strncpy(Info.m_szContactIP, row[idx++], sizeof(Info.m_szContactIP)); + strncpy(Info.m_szServerIP, row[idx++], sizeof(Info.m_szServerIP)); std::string stAuth = row[idx++]; if (!stAuth.compare("IMPLEMENTOR")) @@ -4054,7 +4054,7 @@ void CClientManager::RMCandidacy(CPeer * peer, DWORD dwHandle, const char * data { char szName[32]; - strlcpy(szName, data, sizeof(szName)); + strncpy(szName, data, sizeof(szName)); sys_log(0, "[MONARCH_GM] Remove candidacy name(%s)", szName); int iRet = CMonarch::instance().DelCandidacy(szName) ? 1 : 0; @@ -4095,7 +4095,7 @@ void CClientManager::SetMonarch(CPeer * peer, DWORD dwHandle, const char * data) { char szName[32]; - strlcpy(szName, data, sizeof(szName)); + strncpy(szName, data, sizeof(szName)); if (g_test_server) sys_log(0, "[MONARCH_GM] Set Monarch name(%s)", szName); @@ -4138,7 +4138,7 @@ void CClientManager::RMMonarch(CPeer * peer, DWORD dwHandle, const char * data) { char szName[32]; - strlcpy(szName, data, sizeof(szName)); + strncpy(szName, data, sizeof(szName)); if (g_test_server) sys_log(0, "[MONARCH_GM] Remove Monarch name(%s)", szName); @@ -4197,8 +4197,8 @@ void CClientManager::ChangeMonarchLord(CPeer * peer, DWORD dwHandle, TPacketChan ack.dwPID = info->dwPID; MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); - strlcpy(ack.szName, row[0], sizeof(ack.szName)); - strlcpy(ack.szDate, row[1], sizeof(ack.szDate)); + strncpy(ack.szName, row[0], sizeof(ack.szName)); + strncpy(ack.szDate, row[1], sizeof(ack.szDate)); snprintf(szQuery, sizeof(szQuery), "UPDATE monarch SET pid=%u, windate=NOW() WHERE empire=%d", ack.dwPID, ack.bEmpire); SQLMsg* pMsg2 = CDBManager::instance().DirectQuery(szQuery, SQL_PLAYER); diff --git a/db/src/ClientManager.h b/db/src/ClientManager.h index be64265..b5db23c 100644 --- a/db/src/ClientManager.h +++ b/db/src/ClientManager.h @@ -5,9 +5,9 @@ #include #include -#include "../../common/stl.h" -#include "../../common/building.h" -#include "../../common/auction_table.h" +#include +#include +#include #include "Peer.h" #include "DBManager.h" diff --git a/db/src/ClientManagerBoot.cpp b/db/src/ClientManagerBoot.cpp index 1707df6..eb5b021 100644 --- a/db/src/ClientManagerBoot.cpp +++ b/db/src/ClientManagerBoot.cpp @@ -312,8 +312,8 @@ bool CClientManager::InitializeMobTable() TMobTable *tempTable = it_map_mobTable->second; mob_table->dwVnum = tempTable->dwVnum; - strlcpy(mob_table->szName, tempTable->szName, sizeof(tempTable->szName)); - strlcpy(mob_table->szLocaleName, tempTable->szLocaleName, sizeof(tempTable->szName)); + strncpy(mob_table->szName, tempTable->szName, sizeof(tempTable->szName)); + strncpy(mob_table->szLocaleName, tempTable->szLocaleName, sizeof(tempTable->szName)); mob_table->bRank = tempTable->bRank; mob_table->bType = tempTable->bType; mob_table->bBattleType = tempTable->bBattleType; @@ -323,7 +323,7 @@ bool CClientManager::InitializeMobTable() mob_table->dwRaceFlag = tempTable->dwRaceFlag; mob_table->dwImmuneFlag = tempTable->dwImmuneFlag; mob_table->bEmpire = tempTable->bEmpire; - strlcpy(mob_table->szFolder, tempTable->szFolder, sizeof(tempTable->szName)); + strncpy(mob_table->szFolder, tempTable->szFolder, sizeof(tempTable->szName)); mob_table->bOnClickType = tempTable->bOnClickType; mob_table->bStr = tempTable->bStr; mob_table->bDex = tempTable->bDex; @@ -545,12 +545,12 @@ bool CClientManager::InitializeQuestItemTable() str_to_number(tbl.dwVnum, row[col++]); if (row[col]) - strlcpy(tbl.szName, row[col], sizeof(tbl.szName)); + strncpy(tbl.szName, row[col], sizeof(tbl.szName)); col++; if (row[col]) - strlcpy(tbl.szLocaleName, row[col], sizeof(tbl.szLocaleName)); + strncpy(tbl.szLocaleName, row[col], sizeof(tbl.szLocaleName)); col++; @@ -724,8 +724,8 @@ bool CClientManager::InitializeItemTable() TItemTable *tempTable = it_map_itemTable->second; item_table->dwVnum = tempTable->dwVnum; - strlcpy(item_table->szName, tempTable->szName, sizeof(item_table->szName)); - strlcpy(item_table->szLocaleName, tempTable->szLocaleName, sizeof(item_table->szLocaleName)); + strncpy(item_table->szName, tempTable->szName, sizeof(item_table->szName)); + strncpy(item_table->szLocaleName, tempTable->szLocaleName, sizeof(item_table->szLocaleName)); item_table->bType = tempTable->bType; item_table->bSubType = tempTable->bSubType; item_table->bSize = tempTable->bSize; @@ -888,33 +888,33 @@ bool CClientManager::InitializeSkillTable() col = 0; str_to_number(t.dwVnum, data[col++]); - strlcpy(t.szName, data[col++], sizeof(t.szName)); + strncpy(t.szName, data[col++], sizeof(t.szName)); str_to_number(t.bType, data[col++]); str_to_number(t.bMaxLevel, data[col++]); str_to_number(t.dwSplashRange, data[col++]); - strlcpy(t.szPointOn, data[col++], sizeof(t.szPointOn)); - strlcpy(t.szPointPoly, data[col++], sizeof(t.szPointPoly)); - strlcpy(t.szSPCostPoly, data[col++], sizeof(t.szSPCostPoly)); - strlcpy(t.szDurationPoly, data[col++], sizeof(t.szDurationPoly)); - strlcpy(t.szDurationSPCostPoly, data[col++], sizeof(t.szDurationSPCostPoly)); - strlcpy(t.szCooldownPoly, data[col++], sizeof(t.szCooldownPoly)); - strlcpy(t.szMasterBonusPoly, data[col++], sizeof(t.szMasterBonusPoly)); + strncpy(t.szPointOn, data[col++], sizeof(t.szPointOn)); + strncpy(t.szPointPoly, data[col++], sizeof(t.szPointPoly)); + strncpy(t.szSPCostPoly, data[col++], sizeof(t.szSPCostPoly)); + strncpy(t.szDurationPoly, data[col++], sizeof(t.szDurationPoly)); + strncpy(t.szDurationSPCostPoly, data[col++], sizeof(t.szDurationSPCostPoly)); + strncpy(t.szCooldownPoly, data[col++], sizeof(t.szCooldownPoly)); + strncpy(t.szMasterBonusPoly, data[col++], sizeof(t.szMasterBonusPoly)); str_to_number(t.dwFlag, data[col++]); str_to_number(t.dwAffectFlag, data[col++]); - strlcpy(t.szPointOn2, data[col++], sizeof(t.szPointOn2)); - strlcpy(t.szPointPoly2, data[col++], sizeof(t.szPointPoly2)); - strlcpy(t.szDurationPoly2, data[col++], sizeof(t.szDurationPoly2)); + strncpy(t.szPointOn2, data[col++], sizeof(t.szPointOn2)); + strncpy(t.szPointPoly2, data[col++], sizeof(t.szPointPoly2)); + strncpy(t.szDurationPoly2, data[col++], sizeof(t.szDurationPoly2)); str_to_number(t.dwAffectFlag2, data[col++]); // ADD_GRANDMASTER_SKILL - strlcpy(t.szPointOn3, data[col++], sizeof(t.szPointOn3)); - strlcpy(t.szPointPoly3, data[col++], sizeof(t.szPointPoly3)); - strlcpy(t.szDurationPoly3, data[col++], sizeof(t.szDurationPoly3)); + strncpy(t.szPointOn3, data[col++], sizeof(t.szPointOn3)); + strncpy(t.szPointPoly3, data[col++], sizeof(t.szPointPoly3)); + strncpy(t.szDurationPoly3, data[col++], sizeof(t.szDurationPoly3)); - strlcpy(t.szGrandMasterAddSPCostPoly, data[col++], sizeof(t.szGrandMasterAddSPCostPoly)); + strncpy(t.szGrandMasterAddSPCostPoly, data[col++], sizeof(t.szGrandMasterAddSPCostPoly)); // END_OF_ADD_GRANDMASTER_SKILL str_to_number(t.bLevelStep, data[col++]); @@ -924,7 +924,7 @@ bool CClientManager::InitializeSkillTable() str_to_number(t.lMaxHit, data[col++]); - strlcpy(t.szSplashAroundDamageAdjustPoly, data[col++], sizeof(t.szSplashAroundDamageAdjustPoly)); + strncpy(t.szSplashAroundDamageAdjustPoly, data[col++], sizeof(t.szSplashAroundDamageAdjustPoly)); str_to_number(t.bSkillAttrType, data[col++]); str_to_number(t.dwTargetRange, data[col++]); @@ -956,7 +956,7 @@ bool CClientManager::InitializeBanwordTable() if (data[0]) { - strlcpy(t.szWord, data[0], sizeof(t.szWord)); + strncpy(t.szWord, data[0], sizeof(t.szWord)); m_vec_banwordTable.push_back(t); } } @@ -999,7 +999,7 @@ bool CClientManager::InitializeItemAttrTable() int col = 0; - strlcpy(t.szApply, data[col++], sizeof(t.szApply)); + strncpy(t.szApply, data[col++], sizeof(t.szApply)); str_to_number(t.dwApplyIndex, data[col++]); str_to_number(t.dwProb, data[col++]); str_to_number(t.lValues[0], data[col++]); @@ -1073,7 +1073,7 @@ bool CClientManager::InitializeItemRareTable() int col = 0; - strlcpy(t.szApply, data[col++], sizeof(t.szApply)); + strncpy(t.szApply, data[col++], sizeof(t.szApply)); str_to_number(t.dwApplyIndex, data[col++]); str_to_number(t.dwProb, data[col++]); str_to_number(t.lValues[0], data[col++]); @@ -1178,7 +1178,7 @@ void parse_pair_number_string(const char * c_pszString, std::vector(t), ','); diff --git a/db/src/ClientManagerEventFlag.cpp b/db/src/ClientManagerEventFlag.cpp index e25a868..c0fcf22 100644 --- a/db/src/ClientManagerEventFlag.cpp +++ b/db/src/ClientManagerEventFlag.cpp @@ -19,7 +19,7 @@ void CClientManager::LoadEventFlag() while ((row = mysql_fetch_row(pRes->pSQLResult))) { TPacketSetEventFlag p; - strlcpy(p.szFlagName, row[0], sizeof(p.szFlagName)); + strncpy(p.szFlagName, row[0], sizeof(p.szFlagName)); str_to_number(p.lValue, row[1]); sys_log(0, "EventFlag Load %s %d", p.szFlagName, p.lValue); m_map_lEventFlag.insert(std::make_pair(std::string(p.szFlagName), p.lValue)); @@ -68,7 +68,7 @@ void CClientManager::SendEventFlagsOnSetup(CPeer* peer) for (it = m_map_lEventFlag.begin(); it != m_map_lEventFlag.end(); ++it) { TPacketSetEventFlag p; - strlcpy(p.szFlagName, it->first.c_str(), sizeof(p.szFlagName)); + strncpy(p.szFlagName, it->first.c_str(), sizeof(p.szFlagName)); p.lValue = it->second; peer->EncodeHeader(HEADER_DG_SET_EVENT_FLAG, 0, sizeof(TPacketSetEventFlag)); peer->Encode(&p, sizeof(TPacketSetEventFlag)); diff --git a/db/src/ClientManagerGuild.cpp b/db/src/ClientManagerGuild.cpp index a6bdfe0..1b6c9f0 100644 --- a/db/src/ClientManagerGuild.cpp +++ b/db/src/ClientManagerGuild.cpp @@ -60,7 +60,7 @@ void CClientManager::GuildAddMember(CPeer* peer, TPacketGDGuildAddMember * p) str_to_number(dg.dwOffer, row[3]); str_to_number(dg.bLevel, row[4]); str_to_number(dg.bJob, row[5]); - strlcpy(dg.szName, row[6], sizeof(dg.szName)); + strncpy(dg.szName, row[6], sizeof(dg.szName)); ForwardPacket(HEADER_DG_GUILD_ADD_MEMBER, &dg, sizeof(TPacketDGGuildMember)); } diff --git a/db/src/ClientManagerHorseName.cpp b/db/src/ClientManagerHorseName.cpp index b346ab2..f66d8dc 100644 --- a/db/src/ClientManagerHorseName.cpp +++ b/db/src/ClientManagerHorseName.cpp @@ -31,7 +31,7 @@ void CClientManager::AckHorseName(DWORD dwPID, CPeer* peer) else { MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult); - strlcpy(packet.szHorseName, row[0], sizeof(packet.szHorseName)); + strncpy(packet.szHorseName, row[0], sizeof(packet.szHorseName)); } peer->EncodeHeader(HEADER_DG_ACK_HORSE_NAME, 0, sizeof(TPacketUpdateHorseName)); diff --git a/db/src/ClientManagerLogin.cpp b/db/src/ClientManagerLogin.cpp index affc48e..2621e4b 100644 --- a/db/src/ClientManagerLogin.cpp +++ b/db/src/ClientManagerLogin.cpp @@ -116,7 +116,7 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG { sys_log(0, "LOGIN_BY_KEY already login %s %lu", r.login, p->dwLoginKey); TPacketDGLoginAlready ptog; - strlcpy(ptog.szLogin, szLogin, sizeof(ptog.szLogin)); + strncpy(ptog.szLogin, szLogin, sizeof(ptog.szLogin)); pkPeer->EncodeHeader(HEADER_DG_LOGIN_ALREADY, dwHandle, sizeof(TPacketDGLoginAlready)); pkPeer->Encode(&ptog, sizeof(TPacketDGLoginAlready)); return; @@ -147,13 +147,13 @@ void CClientManager::QUERY_LOGIN_BY_KEY(CPeer * pkPeer, DWORD dwHandle, TPacketG pkTab->id = r.id; trim_and_lower(r.login, pkTab->login, sizeof(pkTab->login)); - strlcpy(pkTab->passwd, r.passwd, sizeof(pkTab->passwd)); - strlcpy(pkTab->social_id, r.social_id, sizeof(pkTab->social_id)); - strlcpy(pkTab->status, "OK", sizeof(pkTab->status)); + strncpy(pkTab->passwd, r.passwd, sizeof(pkTab->passwd)); + strncpy(pkTab->social_id, r.social_id, sizeof(pkTab->social_id)); + strncpy(pkTab->status, "OK", sizeof(pkTab->status)); ClientHandleInfo * info = new ClientHandleInfo(dwHandle); info->pAccountTable = pkTab; - strlcpy(info->ip, p->szIP, sizeof(info->ip)); + strncpy(info->ip, p->szIP, sizeof(info->ip)); sys_log(0, "LOGIN_BY_KEY success %s %lu %s", r.login, p->dwLoginKey, info->ip); char szQuery[QUERY_MAX_LEN]; @@ -250,17 +250,17 @@ TAccountTable * CreateAccountTableFromRes(MYSQL_RES * res) memset(pkTab, 0, sizeof(TAccountTable)); // ù¹ø° Ä÷³ °Í¸¸ Âü°í ÇÑ´Ù (JOIN QUERY¸¦ À§ÇÑ °Í ÀÓ) - strlcpy(input_pwd, row[col++], sizeof(input_pwd)); + strncpy(input_pwd, row[col++], sizeof(input_pwd)); str_to_number(pkTab->id, row[col++]); - strlcpy(pkTab->login, row[col++], sizeof(pkTab->login)); - strlcpy(pkTab->passwd, row[col++], sizeof(pkTab->passwd)); - strlcpy(pkTab->social_id, row[col++], sizeof(pkTab->social_id)); + strncpy(pkTab->login, row[col++], sizeof(pkTab->login)); + strncpy(pkTab->passwd, row[col++], sizeof(pkTab->passwd)); + strncpy(pkTab->social_id, row[col++], sizeof(pkTab->social_id)); str_to_number(pkTab->bEmpire, row[col++]); for (int j = 0; j < PLAYER_PER_ACCOUNT; ++j) str_to_number(pkTab->players[j].dwID, row[col++]); - strlcpy(pkTab->status, row[col++], sizeof(pkTab->status)); + strncpy(pkTab->status, row[col++], sizeof(pkTab->status)); if (strcmp(pkTab->passwd, input_pwd)) { @@ -298,7 +298,7 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab) if (pt) { - strlcpy(pkTab->players[j].szName, pt->name, sizeof(pkTab->players[j].szName)); + strncpy(pkTab->players[j].szName, pt->name, sizeof(pkTab->players[j].szName)); pkTab->players[j].byJob = pt->job; pkTab->players[j].byLevel = pt->level; @@ -319,7 +319,7 @@ void CreateAccountPlayerDataFromRes(MYSQL_RES * pRes, TAccountTable * pkTab) if (!row[col++]) *pkTab->players[j].szName = '\0'; else - strlcpy(pkTab->players[j].szName, row[col - 1], sizeof(pkTab->players[j].szName)); + strncpy(pkTab->players[j].szName, row[col - 1], sizeof(pkTab->players[j].szName)); pkTab->players[j].byJob = 0; pkTab->players[j].byLevel = 0; @@ -428,7 +428,7 @@ void CClientManager::RESULT_LOGIN(CPeer * peer, SQLMsg * msg) sys_log(0, "RESULT_LOGIN: already logon %s", info->pAccountTable->login); TPacketDGLoginAlready p; - strlcpy(p.szLogin, info->pAccountTable->login, sizeof(p.szLogin)); + strncpy(p.szLogin, info->pAccountTable->login, sizeof(p.szLogin)); peer->EncodeHeader(HEADER_DG_LOGIN_ALREADY, info->dwHandle, sizeof(TPacketDGLoginAlready)); peer->Encode(&p, sizeof(p)); @@ -538,7 +538,7 @@ void CClientManager::QUERY_CHANGE_NAME(CPeer * peer, DWORD dwHandle, TPacketGDCh TPacketDGChangeName pdg; peer->EncodeHeader(HEADER_DG_CHANGE_NAME, dwHandle, sizeof(TPacketDGChangeName)); pdg.pid = p->pid; - strlcpy(pdg.name, p->name, sizeof(pdg.name)); + strncpy(pdg.name, p->name, sizeof(pdg.name)); peer->Encode(&pdg, sizeof(TPacketDGChangeName)); } diff --git a/db/src/ClientManagerPlayer.cpp b/db/src/ClientManagerPlayer.cpp index c93c5f9..3c51b2b 100644 --- a/db/src/ClientManagerPlayer.cpp +++ b/db/src/ClientManagerPlayer.cpp @@ -405,7 +405,7 @@ void CClientManager::QUERY_PLAYER_LOAD(CPeer * peer, DWORD dwHandle, TPlayerLoad void CClientManager::ItemAward(CPeer * peer,char* login) { char login_t[LOGIN_MAX_LEN + 1] = ""; - strlcpy(login_t,login,LOGIN_MAX_LEN + 1); + strncpy(login_t,login,LOGIN_MAX_LEN + 1); std::set * pSet = ItemAwardManager::instance().GetByLogin(login_t); if(pSet == NULL) return; @@ -458,7 +458,7 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab) // "stat_point,skill_point,sub_skill_point,stat_reset_count,part_base,part_hair," // "skill_level,quickslot,skill_group,alignment,mobile,horse_level,horse_riding,horse_hp,horse_stamina FROM player%s WHERE id=%d", str_to_number(pkTab->id, row[col++]); - strlcpy(pkTab->name, row[col++], sizeof(pkTab->name)); + strncpy(pkTab->name, row[col++], sizeof(pkTab->name)); str_to_number(pkTab->job, row[col++]); str_to_number(pkTab->voice, row[col++]); str_to_number(pkTab->dir, row[col++]); @@ -509,7 +509,7 @@ bool CreatePlayerTableFromRes(MYSQL_RES * res, TPlayerTable * pkTab) if (row[col]) { - strlcpy(pkTab->szMobile, row[col], sizeof(pkTab->szMobile)); + strncpy(pkTab->szMobile, row[col], sizeof(pkTab->szMobile)); } col++; @@ -759,8 +759,8 @@ void CClientManager::RESULT_QUEST_LOAD(CPeer * peer, MYSQL_RES * pRes, DWORD dwH row = mysql_fetch_row(pRes); str_to_number(r.dwPID, row[0]); - strlcpy(r.szName, row[1], sizeof(r.szName)); - strlcpy(r.szState, row[2], sizeof(r.szState)); + strncpy(r.szName, row[1], sizeof(r.szName)); + strncpy(r.szState, row[2], sizeof(r.szState)); str_to_number(r.lValue, row[3]); } @@ -939,7 +939,7 @@ void CClientManager::__QUERY_PLAYER_CREATE(CPeer *peer, DWORD dwHandle, TPlayerC pack.bAccountCharacterIndex = packet->account_index; pack.player.dwID = player_id; - strlcpy(pack.player.szName, packet->player_table.name, sizeof(pack.player.szName)); + strncpy(pack.player.szName, packet->player_table.name, sizeof(pack.player.szName)); pack.player.byJob = packet->player_table.job; pack.player.byLevel = 1; pack.player.dwPlayMinutes = 0; @@ -1045,7 +1045,7 @@ void CClientManager::__RESULT_PLAYER_DELETE(CPeer *peer, SQLMsg* msg) str_to_number(deletedLevelLimit, row[1]); char szName[64]; - strlcpy(szName, row[2], sizeof(szName)); + strncpy(szName, row[2], sizeof(szName)); if (deletedLevelLimit >= m_iPlayerDeleteLevelLimit && !IsChinaEventServer()) { @@ -1220,7 +1220,7 @@ void CClientManager::QUERY_HIGHSCORE_REGISTER(CPeer* peer, TPacketGDHighscore * sys_log(0, "HEADER_GD_HIGHSCORE_REGISTER: PID %u", data->dwPID); ClientHandleInfo * pi = new ClientHandleInfo(0); - strlcpy(pi->login, data->szBoard, sizeof(pi->login)); + strncpy(pi->login, data->szBoard, sizeof(pi->login)); pi->account_id = (DWORD)data->lValue; pi->player_id = data->dwPID; pi->account_index = (data->cDir > 0); @@ -1235,7 +1235,7 @@ void CClientManager::RESULT_HIGHSCORE_REGISTER(CPeer * pkPeer, SQLMsg * msg) //DWORD dwHandle = pi->dwHandle; char szBoard[21]; - strlcpy(szBoard, pi->login, sizeof(szBoard)); + strncpy(szBoard, pi->login, sizeof(szBoard)); int value = (int)pi->account_id; SQLResult * res = msg->Get(); diff --git a/db/src/Config.cpp b/db/src/Config.cpp index d35633b..2b68e66 100644 --- a/db/src/Config.cpp +++ b/db/src/Config.cpp @@ -117,7 +117,7 @@ bool CConfig::LoadFile(const char* filename) switch (mode) { case 0: - strlcpy(comment, szTmp, sizeof(comment)); + strncpy(comment, szTmp, sizeof(comment)); ++mode; break; @@ -229,7 +229,7 @@ bool CConfig::GetValue(const char * key, char *dest, size_t destSize) if (!Search(key)) return false; - strlcpy(dest, Get(key), destSize); + strncpy(dest, Get(key), destSize); if (!*dest) return false; diff --git a/db/src/DBManager.h b/db/src/DBManager.h index b7b544d..be4b314 100644 --- a/db/src/DBManager.h +++ b/db/src/DBManager.h @@ -7,7 +7,7 @@ // ÄÚµå by ²¿ºØ Èķα׷¡¸Ó ¾Æ³ë¾Æ~ = _=)b #include -#include "../../libsql/AsyncSQL.h" +#include #define SQL_SAFE_LENGTH(size) (size * 2 + 1) #define QUERY_SAFE_LENGTH(size) (1024 + SQL_SAFE_LENGTH(size)) diff --git a/db/src/GuildManager.cpp b/db/src/GuildManager.cpp index c2b73f8..1a0a3b8 100644 --- a/db/src/GuildManager.cpp +++ b/db/src/GuildManager.cpp @@ -137,7 +137,7 @@ void CGuildManager::ParseResult(SQLResult * pRes) TGuild & r_info = TouchGuild(GID); - strlcpy(r_info.szName, row[1], sizeof(r_info.szName)); + strncpy(r_info.szName, row[1], sizeof(r_info.szName)); str_to_number(r_info.ladder_point, row[2]); str_to_number(r_info.win, row[3]); str_to_number(r_info.draw, row[4]); @@ -1228,7 +1228,7 @@ void CGuildWarReserve::Initialize() while ((row = mysql_fetch_row(res))) { dwGuild = dwGold = 0; - strlcpy(szLogin, row[0], sizeof(szLogin)); + strncpy(szLogin, row[0], sizeof(szLogin)); str_to_number(dwGuild, row[1]); str_to_number(dwGold, row[2]); @@ -1254,7 +1254,7 @@ void CGuildWarReserve::OnSetup(CPeer * peer) while (it != mapBet.end()) { - strlcpy(pckBet.szLogin, it->first.c_str(), sizeof(pckBet.szLogin)); + strncpy(pckBet.szLogin, it->first.c_str(), sizeof(pckBet.szLogin)); pckBet.dwGuild = it->second.first; pckBet.dwGold = it->second.second; @@ -1316,7 +1316,7 @@ bool CGuildWarReserve::Bet(const char * pszLogin, DWORD dwGold, DWORD dwGuild) TPacketGDGuildWarBet pckBet; pckBet.dwWarID = m_data.dwID; - strlcpy(pckBet.szLogin, pszLogin, sizeof(pckBet.szLogin)); + strncpy(pckBet.szLogin, pszLogin, sizeof(pckBet.szLogin)); pckBet.dwGuild = dwGuild; pckBet.dwGold = dwGold; diff --git a/db/src/GuildManager.h b/db/src/GuildManager.h index fe99e1a..fc91079 100644 --- a/db/src/GuildManager.h +++ b/db/src/GuildManager.h @@ -5,8 +5,8 @@ #include "Peer.h" #include #include -#include "../../libsql/libsql.h" -#include "../../libpoly/Poly.h" +#include +#include enum { diff --git a/db/src/ItemAwardManager.cpp b/db/src/ItemAwardManager.cpp index 54f4b1a..a258b73 100644 --- a/db/src/ItemAwardManager.cpp +++ b/db/src/ItemAwardManager.cpp @@ -53,7 +53,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg) if (row[col]) { - strlcpy(kData->szWhy, row[col], sizeof(kData->szWhy)); + strncpy(kData->szWhy, row[col], sizeof(kData->szWhy)); //°ÔÀÓ Áß¿¡ whyÄÝ·ë¿¡ º¯µ¿ÀÌ »ý±â¸é char* whyStr = kData->szWhy; //why ÄÝ·ë Àбâ char cmdStr[100] = ""; //whyÄÝ·ë¿¡¼­ ÀÐÀº °ªÀ» Àӽà ¹®ÀÚ¿­¿¡ º¹»çÇØµÒ diff --git a/db/src/LoginData.cpp b/db/src/LoginData.cpp index 3bba1c5..e1655e0 100644 --- a/db/src/LoginData.cpp +++ b/db/src/LoginData.cpp @@ -66,7 +66,7 @@ DWORD CLoginData::GetLogonTime() void CLoginData::SetIP(const char * c_pszIP) { - strlcpy(m_szIP, c_pszIP, sizeof(m_szIP)); + strncpy(m_szIP, c_pszIP, sizeof(m_szIP)); } const char * CLoginData::GetIP() diff --git a/db/src/Marriage.cpp b/db/src/Marriage.cpp index ef429f6..3c70aa6 100644 --- a/db/src/Marriage.cpp +++ b/db/src/Marriage.cpp @@ -121,8 +121,8 @@ namespace marriage p.dwPID1 = dwPID1; p.dwPID2 = dwPID2; p.tMarryTime = now; - strlcpy(p.szName1, szName1, sizeof(p.szName1)); - strlcpy(p.szName2, szName2, sizeof(p.szName2)); + strncpy(p.szName1, szName1, sizeof(p.szName1)); + strncpy(p.szName2, szName2, sizeof(p.szName2)); CClientManager::instance().ForwardPacket(HEADER_DG_MARRIAGE_ADD, &p, sizeof(p)); } @@ -263,8 +263,8 @@ namespace marriage p.dwPID1 = pMarriage->pid1; p.dwPID2 = pMarriage->pid2; p.tMarryTime = pMarriage->time; - strlcpy(p.szName1, pMarriage->name1.c_str(), sizeof(p.szName1)); - strlcpy(p.szName2, pMarriage->name2.c_str(), sizeof(p.szName2)); + strncpy(p.szName1, pMarriage->name1.c_str(), sizeof(p.szName1)); + strncpy(p.szName2, pMarriage->name2.c_str(), sizeof(p.szName2)); peer->EncodeHeader(HEADER_DG_MARRIAGE_ADD, 0, sizeof(p)); peer->Encode(&p, sizeof(p)); } diff --git a/db/src/Monarch.cpp b/db/src/Monarch.cpp index 1eace36..984c5aa 100644 --- a/db/src/Monarch.cpp +++ b/db/src/Monarch.cpp @@ -1,5 +1,5 @@ #include "Monarch.h" -#include "../../common/utils.h" +#include #include "Main.h" #include "ClientManager.h" @@ -81,7 +81,7 @@ bool CMonarch::AddCandidacy(DWORD pid, const char * name) MonarchCandidacy info; info.pid = pid; - strlcpy(info.name, name, sizeof(info.name)); + strncpy(info.name, name, sizeof(info.name)); m_vec_MonarchCandidacy.push_back(info); char szQuery[256]; @@ -192,10 +192,10 @@ bool CMonarch::LoadMonarch() int Empire = 0; str_to_number(Empire, row[idx++]); str_to_number(p->pid[Empire], row[idx++]); - strlcpy(p->name[Empire], row[idx++], sizeof(p->name[Empire])); + strncpy(p->name[Empire], row[idx++], sizeof(p->name[Empire])); str_to_number(p->money[Empire], row[idx++]); - strlcpy(p->date[Empire], row[idx++], sizeof(p->date[Empire])); + strncpy(p->date[Empire], row[idx++], sizeof(p->date[Empire])); if (g_test_server) sys_log(0, "[LOAD_MONARCH] Empire %d pid %d money %lld windate %s", Empire, p->pid[Empire], p->money[Empire], p->date[Empire]); @@ -227,7 +227,7 @@ bool CMonarch::SetMonarch(const char * name) str_to_number(Empire, row[idx++]); str_to_number(p->pid[Empire], row[idx++]); - strlcpy(p->name[Empire], row[idx++], sizeof(p->name[Empire])); + strncpy(p->name[Empire], row[idx++], sizeof(p->name[Empire])); p->money[Empire] = atoll(row[idx++]); if (g_test_server) diff --git a/db/src/Monarch.h b/db/src/Monarch.h index 81e7a6e..06560c3 100644 --- a/db/src/Monarch.h +++ b/db/src/Monarch.h @@ -5,8 +5,8 @@ #include "../../libthecore/include/stdafx.h" #include #include -#include "../../common/singleton.h" -#include "../../common/tables.h" +#include +#include class CMonarch : public singleton { diff --git a/db/src/PeerBase.cpp b/db/src/PeerBase.cpp index 151a1d3..a936f41 100644 --- a/db/src/PeerBase.cpp +++ b/db/src/PeerBase.cpp @@ -52,7 +52,7 @@ bool CPeerBase::Accept(socket_t fd_accept) socket_sndbuf(m_fd, 233016); socket_rcvbuf(m_fd, 233016); - strlcpy(m_host, inet_ntoa(peer.sin_addr), sizeof(m_host)); + strncpy(m_host, inet_ntoa(peer.sin_addr), sizeof(m_host)); m_outBuffer = buffer_new(DEFAULT_PACKET_BUFFER_SIZE); m_inBuffer = buffer_new(MAX_INPUT_LEN); @@ -71,7 +71,7 @@ bool CPeerBase::Accept(socket_t fd_accept) bool CPeerBase::Connect(const char* host, WORD port) { - strlcpy(m_host, host, sizeof(m_host)); + strncpy(m_host, host, sizeof(m_host)); if ((m_fd = socket_connect(host, port)) == INVALID_SOCKET) return false; diff --git a/db/src/ProtoReader.cpp b/db/src/ProtoReader.cpp index 859215f..cc5d80e 100644 --- a/db/src/ProtoReader.cpp +++ b/db/src/ProtoReader.cpp @@ -586,16 +586,16 @@ bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable,std::mapdwVnum, csvTable.AsStringByIndex(col++)); - strlcpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName)); + strncpy(mobTable->szName, csvTable.AsStringByIndex(col++), sizeof(mobTable->szName)); //3. Áö¿ªº° À̸§ ³Ö¾îÁÖ±â. map::iterator it; it = nameMap.find(mobTable->dwVnum); if (it != nameMap.end()) { const char * localeName = it->second; - strlcpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName)); + strncpy(mobTable->szLocaleName, localeName, sizeof (mobTable->szLocaleName)); } else { - strlcpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName)); + strncpy(mobTable->szLocaleName, mobTable->szName, sizeof (mobTable->szLocaleName)); } //RANK @@ -626,7 +626,7 @@ bool Set_Proto_Mob_Table(TMobTable *mobTable, cCsvTable &csvTable,std::mapbEmpire, csvTable.AsStringByIndex(col++)); //col = 11 - strlcpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder)); + strncpy(mobTable->szFolder, csvTable.AsStringByIndex(col++), sizeof(mobTable->szFolder)); str_to_number(mobTable->bOnClickType, csvTable.AsStringByIndex(col++)); @@ -776,15 +776,15 @@ bool Set_Proto_Item_Table(TItemTable *itemTable, cCsvTable &csvTable,std::mapszName, csvTable.AsStringByIndex(1), sizeof(itemTable->szName)); + strncpy(itemTable->szName, csvTable.AsStringByIndex(1), sizeof(itemTable->szName)); //Áö¿ªº° À̸§ ³Ö¾îÁÖ±â. map::iterator it; it = nameMap.find(itemTable->dwVnum); if (it != nameMap.end()) { const char * localeName = it->second; - strlcpy(itemTable->szLocaleName, localeName, sizeof (itemTable->szLocaleName)); + strncpy(itemTable->szLocaleName, localeName, sizeof (itemTable->szLocaleName)); } else { - strlcpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName)); + strncpy(itemTable->szLocaleName, itemTable->szName, sizeof (itemTable->szLocaleName)); } itemTable->bType = dataArray[2]; itemTable->bSubType = dataArray[3]; diff --git a/db/src/grid.cpp b/db/src/grid.cpp index bb94831..681ff2a 100644 --- a/db/src/grid.cpp +++ b/db/src/grid.cpp @@ -1,7 +1,7 @@ #include #include #include "../../libthecore/include/memcpy.h" -#include "../../common/stl.h" +#include #include "grid.h" CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h) diff --git a/db/src/stdafx.h b/db/src/stdafx.h index c36c862..3a801ad 100644 --- a/db/src/stdafx.h +++ b/db/src/stdafx.h @@ -1,7 +1,7 @@ #ifndef __INC_METiN_II_DBSERV_STDAFX_H__ #define __INC_METiN_II_DBSERV_STDAFX_H__ -#include "../../libthecore/include/stdafx.h" +#include #ifndef __WIN32__ #include @@ -10,11 +10,11 @@ #define isspace iswspace #endif -#include "../../common/length.h" -#include "../../common/tables.h" -#include "../../common/singleton.h" -#include "../../common/utils.h" -#include "../../common/stl.h" -#include "../../common/service.h" +#include +#include +#include +#include +#include +#include #endif diff --git a/db/src/version.cpp b/db/src/version.cpp index f4bb8b9..c9b82c1 100644 --- a/db/src/version.cpp +++ b/db/src/version.cpp @@ -8,8 +8,7 @@ void WriteVersion() if (NULL != fp) { - fprintf(fp, "game perforce revision: %s\n", __P4_VERSION__); - fprintf(fp, "%s@%s:%s\n", __USER__, __HOSTNAME__, __PWD__); + fprintf(fp, "db\n"); fclose(fp); } else diff --git a/game/src/ClientPackageCryptInfo.cpp b/game/src/ClientPackageCryptInfo.cpp index eb7ea0b..96c635d 100644 --- a/game/src/ClientPackageCryptInfo.cpp +++ b/game/src/ClientPackageCryptInfo.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" #include "ClientPackageCryptInfo.h" -#include "../../common/stl.h" +#include #ifndef __FreeBSD__ #include "../../libthecore/include/xdirent.h" diff --git a/game/src/DragonLair.h b/game/src/DragonLair.h index 081b1a5..b8f9b76 100644 --- a/game/src/DragonLair.h +++ b/game/src/DragonLair.h @@ -1,7 +1,7 @@ #include -#include "../../common/stl.h" +#include class CDragonLair { diff --git a/game/src/DragonSoul.h b/game/src/DragonSoul.h index 4d8b9d9..b7e5e35 100644 --- a/game/src/DragonSoul.h +++ b/game/src/DragonSoul.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_GAME_DRAGON_SOUL_H__ #define __INC_METIN_II_GAME_DRAGON_SOUL_H__ -#include "../../common/length.h" +#include class CHARACTER; class CItem; diff --git a/game/src/OXEvent.cpp b/game/src/OXEvent.cpp index 02cb6e4..d9e4903 100644 --- a/game/src/OXEvent.cpp +++ b/game/src/OXEvent.cpp @@ -140,7 +140,7 @@ bool COXEventManager::AddQuiz(unsigned char level, const char* pszQuestion, bool struct tag_Quiz tmpQuiz; tmpQuiz.level = level; - strlcpy(tmpQuiz.Quiz, pszQuestion, sizeof(tmpQuiz.Quiz)); + strncpy(tmpQuiz.Quiz, pszQuestion, sizeof(tmpQuiz.Quiz)); tmpQuiz.answer = answer; m_vec_quiz[level].push_back(tmpQuiz); diff --git a/game/src/PetSystem.cpp b/game/src/PetSystem.cpp index 892d4e2..4dfcb9e 100644 --- a/game/src/PetSystem.cpp +++ b/game/src/PetSystem.cpp @@ -6,7 +6,7 @@ #include "char_manager.h" #include "mob_manager.h" #include "PetSystem.h" -#include "../../common/VnumHelper.h" +#include #include "packet.h" #include "item_manager.h" #include "item.h" diff --git a/game/src/SpeedServer.h b/game/src/SpeedServer.h index 69c4bda..f4f61e6 100644 --- a/game/src/SpeedServer.h +++ b/game/src/SpeedServer.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_GAME_SPEEDSERVER_H__ #define __INC_METIN_II_GAME_SPEEDSERVER_H__ -#include "../../common/length.h" +#include #include // castle.cpp ¿¡ ÀÖ´Â °ÍÀ» º¹ºÙ ÇÏ¿´´Ù diff --git a/game/src/ani.cpp b/game/src/ani.cpp index 3f15084..e231298 100644 --- a/game/src/ani.cpp +++ b/game/src/ani.cpp @@ -157,27 +157,27 @@ DWORD ANI::load_one_weapon(const char *dir_name, int weapon, BYTE combo, bool ho switch (weapon) { case WEAPON_SWORD: - strlcpy(format, "%s/%sonehand_sword/combo_%02d.msa", sizeof(format)); + strncpy(format, "%s/%sonehand_sword/combo_%02d.msa", sizeof(format)); break; case WEAPON_DAGGER: - strlcpy(format, "%s/%sdualhand_sword/combo_%02d.msa", sizeof(format)); + strncpy(format, "%s/%sdualhand_sword/combo_%02d.msa", sizeof(format)); break; case WEAPON_BOW: - strlcpy(format, "%s/%sbow/attack.msa", sizeof(format)); + strncpy(format, "%s/%sbow/attack.msa", sizeof(format)); break; case WEAPON_TWO_HANDED: - strlcpy(format, "%s/%stwohand_sword/combo_%02d.msa", sizeof(format)); + strncpy(format, "%s/%stwohand_sword/combo_%02d.msa", sizeof(format)); break; case WEAPON_BELL: - strlcpy(format, "%s/%sbell/combo_%02d.msa", sizeof(format)); + strncpy(format, "%s/%sbell/combo_%02d.msa", sizeof(format)); break; case WEAPON_FAN: - strlcpy(format, "%s/%sfan/combo_%02d.msa", sizeof(format)); + strncpy(format, "%s/%sfan/combo_%02d.msa", sizeof(format)); break; default: diff --git a/game/src/auction_manager.cpp b/game/src/auction_manager.cpp index ffd3994..56a49f3 100644 --- a/game/src/auction_manager.cpp +++ b/game/src/auction_manager.cpp @@ -13,7 +13,7 @@ #include #include "item.h" #include "desc_client.h" -#include "../../common/tables.h" +#include #include "protocol.h" #include "auction_manager.h" extern int auction_server; diff --git a/game/src/auction_manager.h b/game/src/auction_manager.h index 248dd80..9b4a95a 100644 --- a/game/src/auction_manager.h +++ b/game/src/auction_manager.h @@ -1,8 +1,8 @@ #ifndef __INC_AUCTION_MANAGER_H #define __INC_AUCTION_MANAGER_H -#include "../../libsql/AsyncSQL.h" -#include "../../common/auction_table.h" +#include +#include #include #include diff --git a/game/src/auth_brazil.cpp b/game/src/auth_brazil.cpp index dec588f..3ab5d16 100644 --- a/game/src/auth_brazil.cpp +++ b/game/src/auth_brazil.cpp @@ -57,7 +57,7 @@ static int FN_make_request(const char *login, const char *password, /*out*/ char static int FN_parse_reply(char *reply) { char buffer[2048]; - strlcpy(buffer, reply, sizeof(buffer)); + strncpy(buffer, reply, sizeof(buffer)); const char *delim = "\r\n"; char *last = 0; diff --git a/game/src/buff_on_attributes.cpp b/game/src/buff_on_attributes.cpp index 64366a4..ae24d68 100644 --- a/game/src/buff_on_attributes.cpp +++ b/game/src/buff_on_attributes.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/tables.h" +#include #include "item.h" #include "char.h" #include "buff_on_attributes.h" diff --git a/game/src/building.h b/game/src/building.h index 90b9d61..2adda9a 100644 --- a/game/src/building.h +++ b/game/src/building.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_BUILDING_H__ #define __INC_METIN_II_BUILDING_H__ -#include "../../common/building.h" +#include namespace building { diff --git a/game/src/char.cpp b/game/src/char.cpp index 2f16362..a7db90d 100644 --- a/game/src/char.cpp +++ b/game/src/char.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "../../common/teen_packet.h" -#include "../../common/VnumHelper.h" +#include +#include #include "char.h" @@ -612,7 +612,7 @@ void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE } char szSign[SHOP_SIGN_MAX_LEN+1]; - strlcpy(szSign, c_pszSign, sizeof(szSign)); + strncpy(szSign, c_pszSign, sizeof(szSign)); m_stShopSign = szSign; @@ -713,7 +713,7 @@ void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE p.bHeader = HEADER_GC_SHOP_SIGN; p.dwVID = GetVID(); - strlcpy(p.szSign, c_pszSign, sizeof(p.szSign)); + strncpy(p.szSign, c_pszSign, sizeof(p.szSign)); PacketAround(&p, sizeof(TPacketGCShopSign)); @@ -909,7 +909,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity) else { show_all_info: - strlcpy(addPacket.name, GetName(), sizeof(addPacket.name)); + strncpy(addPacket.name, GetName(), sizeof(addPacket.name)); if (GetGuild() != NULL) { @@ -959,7 +959,7 @@ void CHARACTER::EncodeInsertPacket(LPENTITY entity) p.bHeader = HEADER_GC_SHOP_SIGN; p.dwVID = GetVID(); - strlcpy(p.szSign, m_stShopSign.c_str(), sizeof(p.szSign)); + strncpy(p.szSign, m_stShopSign.c_str(), sizeof(p.szSign)); d->Packet(&p, sizeof(TPacketGCShopSign)); } @@ -1142,14 +1142,14 @@ void CHARACTER::CreatePlayerProto(TPlayerTable & tab) if (GetNewName().empty()) { - strlcpy(tab.name, GetName(), sizeof(tab.name)); + strncpy(tab.name, GetName(), sizeof(tab.name)); } else { - strlcpy(tab.name, GetNewName().c_str(), sizeof(tab.name)); + strncpy(tab.name, GetNewName().c_str(), sizeof(tab.name)); } - strlcpy(tab.ip, GetDesc()->GetHostName(), sizeof(tab.ip)); + strncpy(tab.ip, GetDesc()->GetHostName(), sizeof(tab.ip)); tab.id = m_dwPlayerID; tab.voice = GetPoint(POINT_VOICE); @@ -1239,7 +1239,7 @@ void CHARACTER::CreatePlayerProto(TPlayerTable & tab) tab.quickslot[i] = m_quickslot[i]; if (m_stMobile.length() && !*m_szMobileAuth) - strlcpy(tab.szMobile, m_stMobile.c_str(), sizeof(tab.szMobile)); + strncpy(tab.szMobile, m_stMobile.c_str(), sizeof(tab.szMobile)); thecore_memcpy(tab.parts, m_pointsInstant.parts, sizeof(tab.parts)); @@ -1318,7 +1318,7 @@ void CHARACTER::Disconnect(const char * c_pszReason) // P2P Logout TPacketGGLogout p; p.bHeader = HEADER_GG_LOGOUT; - strlcpy(p.szName, GetName(), sizeof(p.szName)); + strncpy(p.szName, GetName(), sizeof(p.szName)); P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGLogout)); char buf[51]; snprintf(buf, sizeof(buf), "%s %d %d %ld %d", @@ -1551,10 +1551,10 @@ void CHARACTER::MainCharacterPacket() mainChrPacket.lz = GetZ(); mainChrPacket.empire = GetDesc()->GetEmpire(); mainChrPacket.skill_group = GetSkillGroup(); - strlcpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName)); + strncpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName)); mainChrPacket.fBGMVol = bgmInfo.vol; - strlcpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName)); + strncpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName)); GetDesc()->Packet(&mainChrPacket, sizeof(TPacketGCMainCharacter4_BGM_VOL)); } else @@ -1569,8 +1569,8 @@ void CHARACTER::MainCharacterPacket() mainChrPacket.lz = GetZ(); mainChrPacket.empire = GetDesc()->GetEmpire(); mainChrPacket.skill_group = GetSkillGroup(); - strlcpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName)); - strlcpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName)); + strncpy(mainChrPacket.szChrName, GetName(), sizeof(mainChrPacket.szChrName)); + strncpy(mainChrPacket.szBGMName, bgmInfo.name.c_str(), sizeof(mainChrPacket.szBGMName)); GetDesc()->Packet(&mainChrPacket, sizeof(TPacketGCMainCharacter3_BGM)); } //if (m_stMobile.length()) @@ -1590,7 +1590,7 @@ void CHARACTER::MainCharacterPacket() pack.lz = GetZ(); pack.empire = GetDesc()->GetEmpire(); pack.skill_group = GetSkillGroup(); - strlcpy(pack.szName, GetName(), sizeof(pack.szName)); + strncpy(pack.szName, GetName(), sizeof(pack.szName)); GetDesc()->Packet(&pack, sizeof(TPacketGCMainCharacter)); if (m_stMobile.length()) @@ -5323,7 +5323,7 @@ void CHARACTER::WarpEnd() TPacketGGLogin p; p.bHeader = HEADER_GG_LOGIN; - strlcpy(p.szName, GetName(), sizeof(p.szName)); + strncpy(p.szName, GetName(), sizeof(p.szName)); p.dwPID = GetPlayerID(); p.bEmpire = GetEmpire(); p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(GetX(), GetY()); @@ -5569,8 +5569,8 @@ void CHARACTER::ReqSafeboxLoad(const char* pszPassword) TSafeboxLoadPacket p; p.dwID = GetDesc()->GetAccountTable().id; - strlcpy(p.szLogin, GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); - strlcpy(p.szPassword, pszPassword, sizeof(p.szPassword)); + strncpy(p.szLogin, GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); + strncpy(p.szPassword, pszPassword, sizeof(p.szPassword)); db_clientdesc->DBPacket(HEADER_GD_SAFEBOX_LOAD, GetDesc()->GetHandle(), &p, sizeof(p)); } @@ -6517,7 +6517,7 @@ void CHARACTER::ConfirmWithMsg(const char* szMsg, int iTimeout, DWORD dwRequestP p.header = HEADER_GC_QUEST_CONFIRM; p.requestPID = dwRequestPID; p.timeout = iTimeout; - strlcpy(p.msg, szMsg, sizeof(p.msg)); + strncpy(p.msg, szMsg, sizeof(p.msg)); GetDesc()->Packet(&p, sizeof(p)); } diff --git a/game/src/char.h b/game/src/char.h index c9d8677..c1bf38a 100644 --- a/game/src/char.h +++ b/game/src/char.h @@ -3,7 +3,7 @@ #include -#include "../../common/stl.h" +#include #include "entity.h" #include "FSM.h" #include "horse_rider.h" diff --git a/game/src/char_horse.cpp b/game/src/char_horse.cpp index 6617c75..aafd0cc 100644 --- a/game/src/char_horse.cpp +++ b/game/src/char_horse.cpp @@ -11,7 +11,7 @@ #include "locale_service.h" #include "arena.h" -#include "../../common/VnumHelper.h" +#include bool CHARACTER::StartRiding() { diff --git a/game/src/char_item.cpp b/game/src/char_item.cpp index cfd9f65..19220d4 100644 --- a/game/src/char_item.cpp +++ b/game/src/char_item.cpp @@ -41,7 +41,7 @@ #include "safebox.h" #include "shop.h" -#include "../../common/VnumHelper.h" +#include #include "DragonSoul.h" #include "buff_on_attributes.h" #include "belt_inventory_helper.h" diff --git a/game/src/char_manager.h b/game/src/char_manager.h index 26a4e05..8609ff9 100644 --- a/game/src/char_manager.h +++ b/game/src/char_manager.h @@ -5,8 +5,8 @@ #include "pool.h" #endif -#include "../../common/stl.h" -#include "../../common/length.h" +#include +#include #include "vid.h" diff --git a/game/src/char_state.cpp b/game/src/char_state.cpp index bdfdb94..9414569 100644 --- a/game/src/char_state.cpp +++ b/game/src/char_state.cpp @@ -22,7 +22,7 @@ #include "locale_service.h" #include "BlueDragon.h" -#include "../../common/VnumHelper.h" +#include BOOL g_test_server; extern LPCHARACTER FindVictim(LPCHARACTER pkChr, int iMaxDistance); diff --git a/game/src/cmd_general.cpp b/game/src/cmd_general.cpp index 1729218..8672abf 100644 --- a/game/src/cmd_general.cpp +++ b/game/src/cmd_general.cpp @@ -33,7 +33,7 @@ #include "unique_item.h" #include "threeway_war.h" #include "log.h" -#include "../../common/VnumHelper.h" +#include #ifdef __AUCTION__ #include "auction_manager.h" #endif @@ -390,7 +390,7 @@ ACMD(do_cmd) info->ch = ch; info->subcmd = subcmd; - strlcpy(info->szReason, argument, sizeof(info->szReason)); + strncpy(info->szReason, argument, sizeof(info->szReason)); ch->m_pkTimedEvent = event_create(timed_event, info, 1); } @@ -928,8 +928,8 @@ ACMD(do_safebox_change_password) TSafeboxChangePasswordPacket p; p.dwID = ch->GetDesc()->GetAccountTable().id; - strlcpy(p.szOldPassword, arg1, sizeof(p.szOldPassword)); - strlcpy(p.szNewPassword, arg2, sizeof(p.szNewPassword)); + strncpy(p.szOldPassword, arg1, sizeof(p.szOldPassword)); + strncpy(p.szNewPassword, arg2, sizeof(p.szNewPassword)); db_clientdesc->DBPacket(HEADER_GD_SAFEBOX_CHANGE_PASSWORD, ch->GetDesc()->GetHandle(), &p, sizeof(p)); } @@ -963,8 +963,8 @@ ACMD(do_mall_password) TSafeboxLoadPacket p; p.dwID = ch->GetDesc()->GetAccountTable().id; - strlcpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); - strlcpy(p.szPassword, arg1, sizeof(p.szPassword)); + strncpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); + strncpy(p.szPassword, arg1, sizeof(p.szPassword)); db_clientdesc->DBPacket(HEADER_GD_MALL_LOAD, ch->GetDesc()->GetHandle(), &p, sizeof(p)); } @@ -1635,7 +1635,7 @@ ACMD(do_monarch_transfer) TPacketGGTransfer pgg; pgg.bHeader = HEADER_GG_TRANSFER; - strlcpy(pgg.szName, arg1, sizeof(pgg.szName)); + strncpy(pgg.szName, arg1, sizeof(pgg.szName)); pgg.lX = ch->GetX(); pgg.lY = ch->GetY(); diff --git a/game/src/cmd_gm.cpp b/game/src/cmd_gm.cpp index ad22c34..e67bfb3 100644 --- a/game/src/cmd_gm.cpp +++ b/game/src/cmd_gm.cpp @@ -165,7 +165,7 @@ ACMD(do_transfer) TPacketGGTransfer pgg; pgg.bHeader = HEADER_GG_TRANSFER; - strlcpy(pgg.szName, arg1, sizeof(pgg.szName)); + strncpy(pgg.szName, arg1, sizeof(pgg.szName)); pgg.lX = ch->GetX(); pgg.lY = ch->GetY(); @@ -258,7 +258,7 @@ bool FindInString(const char * c_pszFind, const char * c_pszIn) do { - strlcpy(sz, c, MIN(sizeof(sz), (p - c) + 1)); + strncpy(sz, c, MIN(sizeof(sz), (p - c) + 1)); if (!strncasecmp(c_pszFind, sz, strlen(c_pszFind))) return true; @@ -266,7 +266,7 @@ bool FindInString(const char * c_pszFind, const char * c_pszIn) c = p + 1; } while ((p = strchr(c, '|'))); - strlcpy(sz, c, sizeof(sz)); + strncpy(sz, c, sizeof(sz)); if (!strncasecmp(c_pszFind, sz, strlen(c_pszFind))) return true; @@ -1599,7 +1599,7 @@ ACMD(do_makeguild) memset(&cp, 0, sizeof(cp)); cp.master = ch; - strlcpy(cp.name, arg1, sizeof(cp.name)); + strncpy(cp.name, arg1, sizeof(cp.name)); if (!check_name(cp.name)) { @@ -2719,7 +2719,7 @@ ACMD(do_vote_block_chat) TPacketGGBlockChat p; p.bHeader = HEADER_GG_BLOCK_CHAT; - strlcpy(p.szName, name, sizeof(p.szName)); + strncpy(p.szName, name, sizeof(p.szName)); p.lBlockDuration = lBlockDuration; P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGBlockChat)); } @@ -2727,7 +2727,7 @@ ACMD(do_vote_block_chat) { TPacketBlockChat p; - strlcpy(p.szName, name, sizeof(p.szName)); + strncpy(p.szName, name, sizeof(p.szName)); p.lDuration = lBlockDuration; db_clientdesc->DBPacket(HEADER_GD_BLOCK_CHAT, ch ? ch->GetDesc()->GetHandle() : 0, &p, sizeof(p)); @@ -2789,7 +2789,7 @@ ACMD(do_block_chat) TPacketGGBlockChat p; p.bHeader = HEADER_GG_BLOCK_CHAT; - strlcpy(p.szName, name, sizeof(p.szName)); + strncpy(p.szName, name, sizeof(p.szName)); p.lBlockDuration = lBlockDuration; P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGBlockChat)); } @@ -2797,7 +2797,7 @@ ACMD(do_block_chat) { TPacketBlockChat p; - strlcpy(p.szName, name, sizeof(p.szName)); + strncpy(p.szName, name, sizeof(p.szName)); p.lDuration = lBlockDuration; db_clientdesc->DBPacket(HEADER_GD_BLOCK_CHAT, ch ? ch->GetDesc()->GetHandle() : 0, &p, sizeof(p)); } diff --git a/game/src/config.cpp b/game/src/config.cpp index 3000666..ae56716 100644 --- a/game/src/config.cpp +++ b/game/src/config.cpp @@ -267,7 +267,7 @@ bool GetIPInfo() if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192 { - strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP)); + strncpy(g_szInternalIP, netip, sizeof(g_szInternalIP)); #ifndef __WIN32__ fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name); #else @@ -276,7 +276,7 @@ bool GetIPInfo() } else if (!strncmp(netip, "10.", 3)) { - strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP)); + strncpy(g_szInternalIP, netip, sizeof(g_szInternalIP)); #ifndef __WIN32__ fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name); #else @@ -285,7 +285,7 @@ bool GetIPInfo() } else if (g_szPublicIP[0] == '0') { - strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP)); + strncpy(g_szPublicIP, netip, sizeof(g_szPublicIP)); #ifndef __WIN32__ fprintf(stderr, "PUBLIC_IP: %s interface %s\n", netip, ifap->ifa_name); #else @@ -768,7 +768,7 @@ void config_init(const string& st_localeServiceName) TOKEN("db_addr") { - strlcpy(db_addr, value_string, sizeof(db_addr)); + strncpy(db_addr, value_string, sizeof(db_addr)); for (int n =0; n < ADDRESS_MAX_LEN; ++n) { @@ -966,7 +966,7 @@ void config_init(const string& st_localeServiceName) TOKEN("teen_addr") { - strlcpy(teen_addr, value_string, sizeof(teen_addr)); + strncpy(teen_addr, value_string, sizeof(teen_addr)); for (int n =0; n < ADDRESS_MAX_LEN; ++n) { @@ -1009,7 +1009,7 @@ void config_init(const string& st_localeServiceName) TOKEN("bind_ip") { - strlcpy(g_szPublicIP, value_string, sizeof(g_szPublicIP)); + strncpy(g_szPublicIP, value_string, sizeof(g_szPublicIP)); } TOKEN("view_range") diff --git a/game/src/constants.cpp b/game/src/constants.cpp index cc64479..4102516 100644 --- a/game/src/constants.cpp +++ b/game/src/constants.cpp @@ -1181,7 +1181,7 @@ const int aiAccessorySocketPutPct[ITEM_ACCESSORY_SOCKET_MAX_NUM + 1] = }; // END_OF_ACCESSORY_REFINE -#include "../../common/length.h" +#include // from import_item_proto.c typedef struct SValueName { diff --git a/game/src/constants.h b/game/src/constants.h index 7dd2488..8c9cf0f 100644 --- a/game/src/constants.h +++ b/game/src/constants.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_GAME_CONSTANTS_H__ #define __INC_METIN_II_GAME_CONSTANTS_H__ -#include "../../common/tables.h" +#include enum EMonsterChatState { diff --git a/game/src/db.cpp b/game/src/db.cpp index a456465..7cdc68f 100644 --- a/game/src/db.cpp +++ b/game/src/db.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include -#include "../../common/billing.h" -#include "../../common/length.h" +#include +#include #include "db.h" @@ -253,9 +253,9 @@ void DBManager::PushBilling(CLoginData * pkLD) if (t.bBillType == BILLING_IP_FREE || t.bBillType == BILLING_IP_TIME || t.bBillType == BILLING_IP_DAY) snprintf(t.szLogin, sizeof(t.szLogin), "%u", pkLD->GetBillID()); else - strlcpy(t.szLogin, pkLD->GetLogin(), sizeof(t.szLogin)); + strncpy(t.szLogin, pkLD->GetLogin(), sizeof(t.szLogin)); - strlcpy(t.szIP, pkLD->GetIP(), sizeof(t.szIP)); + strncpy(t.szIP, pkLD->GetIP(), sizeof(t.szIP)); m_vec_kUseTime.push_back(t); } @@ -460,7 +460,7 @@ void DBManager::SendLoginPing(const char * c_pszLogin) TPacketGGLoginPing ptog; ptog.bHeader = HEADER_GG_LOGIN_PING; - strlcpy(ptog.szLogin, c_pszLogin, sizeof(ptog.szLogin)); + strncpy(ptog.szLogin, c_pszLogin, sizeof(ptog.szLogin)); if (!g_pkAuthMasterDesc) // If I am master, broadcast to others { @@ -485,7 +485,7 @@ void DBManager::SendAuthLogin(LPDESC d) ptod.dwID = r.id; trim_and_lower(r.login, ptod.szLogin, sizeof(ptod.szLogin)); - strlcpy(ptod.szSocialID, r.social_id, sizeof(ptod.szSocialID)); + strncpy(ptod.szSocialID, r.social_id, sizeof(ptod.szSocialID)); ptod.dwLoginKey = d->GetLoginKey(); ptod.bBillType = pkLD->GetBillType(); ptod.dwBillID = pkLD->GetBillID(); @@ -598,7 +598,7 @@ bool GetGameTimeIP(MYSQL_RES * pRes, BYTE & bBillType, DWORD & dwBillID, int & s str_to_number(day_seconds, row[col++]); char szIP[MAX_HOST_LENGTH + 1]; - strlcpy(szIP, c_pszIP, sizeof(szIP)); + strncpy(szIP, c_pszIP, sizeof(szIP)); char * p = strrchr(szIP, '.'); ++p; @@ -668,7 +668,7 @@ void SendBillingExpire(const char * c_pszLogin, BYTE bBillType, int iSecs, CLogi { TPacketBillingExpire ptod; - strlcpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin)); + strncpy(ptod.szLogin, c_pszLogin, sizeof(ptod.szLogin)); ptod.bBillType = bBillType; ptod.dwRemainSeconds = MAX(0, iSecs); db_clientdesc->DBPacket(HEADER_GD_BILLING_EXPIRE, 0, &ptod, sizeof(TPacketBillingExpire)); @@ -735,7 +735,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword)); + strncpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword)); if (!row[col]) { @@ -744,7 +744,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szPassword, row[col++], sizeof(szPassword)); + strncpy(szPassword, row[col++], sizeof(szPassword)); if (!row[col]) { @@ -753,7 +753,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) } else { - strlcpy(szMatrixCode, row[col++], sizeof(szMatrixCode)); + strncpy(szMatrixCode, row[col++], sizeof(szMatrixCode)); } if (!row[col]) @@ -763,7 +763,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szSocialID, row[col++], sizeof(szSocialID)); + strncpy(szSocialID, row[col++], sizeof(szSocialID)); if (!row[col]) { @@ -781,7 +781,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szStatus, row[col++], sizeof(szStatus)); + strncpy(szStatus, row[col++], sizeof(szStatus)); BYTE bNotAvail = 0; str_to_number(bNotAvail, row[col++]); @@ -879,8 +879,8 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) r.id = dwID; trim_and_lower(pinfo->login, r.login, sizeof(r.login)); - strlcpy(r.passwd, pinfo->passwd, sizeof(r.passwd)); - strlcpy(r.social_id, szSocialID, sizeof(r.social_id)); + strncpy(r.passwd, pinfo->passwd, sizeof(r.passwd)); + strncpy(r.social_id, szSocialID, sizeof(r.social_id)); DESC_MANAGER::instance().ConnectAccount(r.login, d); d->SetMatrixCode(szMatrixCode); @@ -961,7 +961,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword)); + strncpy(szEncrytPassword, row[col++], sizeof(szEncrytPassword)); if (!row[col]) { @@ -970,7 +970,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szPassword, row[col++], sizeof(szPassword)); + strncpy(szPassword, row[col++], sizeof(szPassword)); if (!row[col]) { @@ -979,7 +979,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) } else { - strlcpy(szMatrixCode, row[col++], sizeof(szMatrixCode)); + strncpy(szMatrixCode, row[col++], sizeof(szMatrixCode)); } if (!row[col]) @@ -989,7 +989,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szSocialID, row[col++], sizeof(szSocialID)); + strncpy(szSocialID, row[col++], sizeof(szSocialID)); if (!row[col]) { @@ -1007,7 +1007,7 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) break; } - strlcpy(szStatus, row[col++], sizeof(szStatus)); + strncpy(szStatus, row[col++], sizeof(szStatus)); BYTE bNotAvail = 0; str_to_number(bNotAvail, row[col++]); @@ -1111,8 +1111,8 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg) r.id = dwID; trim_and_lower(pinfo->login, r.login, sizeof(r.login)); - strlcpy(r.passwd, pinfo->passwd, sizeof(r.passwd)); - strlcpy(r.social_id, szSocialID, sizeof(r.social_id)); + strncpy(r.passwd, pinfo->passwd, sizeof(r.passwd)); + strncpy(r.social_id, szSocialID, sizeof(r.social_id)); DESC_MANAGER::instance().ConnectAccount(r.login, d); d->SetMatrixCode(szMatrixCode); @@ -1542,10 +1542,10 @@ void VCardUse(LPCHARACTER CardOwner, LPCHARACTER CardTaker, LPITEM item) TPacketGDVCard p; p.dwID = item->GetSocket(0); - strlcpy(p.szSellCharacter, CardOwner->GetName(), sizeof(p.szSellCharacter)); - strlcpy(p.szSellAccount, CardOwner->GetDesc()->GetAccountTable().login, sizeof(p.szSellAccount)); - strlcpy(p.szBuyCharacter, CardTaker->GetName(), sizeof(p.szBuyCharacter)); - strlcpy(p.szBuyAccount, CardTaker->GetDesc()->GetAccountTable().login, sizeof(p.szBuyAccount)); + strncpy(p.szSellCharacter, CardOwner->GetName(), sizeof(p.szSellCharacter)); + strncpy(p.szSellAccount, CardOwner->GetDesc()->GetAccountTable().login, sizeof(p.szSellAccount)); + strncpy(p.szBuyCharacter, CardTaker->GetName(), sizeof(p.szBuyCharacter)); + strncpy(p.szBuyAccount, CardTaker->GetDesc()->GetAccountTable().login, sizeof(p.szBuyAccount)); db_clientdesc->DBPacket(HEADER_GD_VCARD, 0, &p, sizeof(TPacketGDVCard)); @@ -1573,7 +1573,7 @@ void DBManager::RequestBlockException(const char *login, int cmd) TPacketBlockException packet; packet.cmd = cmd; - strlcpy(packet.login, login, sizeof(packet.login)); + strncpy(packet.login, login, sizeof(packet.login)); db_clientdesc->DBPacket(HEADER_GD_BLOCK_EXCEPTION, 0, &packet, sizeof(packet)); } diff --git a/game/src/db.h b/game/src/db.h index 76f818d..8d93d0b 100644 --- a/game/src/db.h +++ b/game/src/db.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_DB_MANAGER_H__ #define __INC_METIN_II_DB_MANAGER_H__ -#include "../../libsql/AsyncSQL.h" +#include #include "any_function.h" enum diff --git a/game/src/desc.cpp b/game/src/desc.cpp index f365abd..90310b4 100644 --- a/game/src/desc.cpp +++ b/game/src/desc.cpp @@ -144,8 +144,8 @@ void DESC::Destroy() { TLogoutPacket pack; - strlcpy(pack.login, m_accountTable.login, sizeof(pack.login)); - strlcpy(pack.passwd, m_accountTable.passwd, sizeof(pack.passwd)); + strncpy(pack.login, m_accountTable.login, sizeof(pack.login)); + strncpy(pack.passwd, m_accountTable.passwd, sizeof(pack.passwd)); db_clientdesc->DBPacket(HEADER_GD_LOGOUT, m_dwHandle, &pack, sizeof(TLogoutPacket)); } @@ -441,7 +441,7 @@ void DESC::Packet(const void * c_pvData, int iSize) TPacketGGRelay p; p.bHeader = HEADER_GG_RELAY; - strlcpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName)); + strncpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName)); p.lSize = iSize; if (!packet_encode(m_lpOutputBuffer, &p, sizeof(p))) @@ -941,7 +941,7 @@ void DESC::SendLoginSuccessPacket() if (g) { p.guild_id[i] = g->GetID(); - strlcpy(p.guild_name[i], g->GetName(), sizeof(p.guild_name[i])); + strncpy(p.guild_name[i], g->GetName(), sizeof(p.guild_name[i])); } else { diff --git a/game/src/desc_client.cpp b/game/src/desc_client.cpp index 3186fd8..d49e2d7 100644 --- a/game/src/desc_client.cpp +++ b/game/src/desc_client.cpp @@ -156,7 +156,7 @@ void CLIENT_DESC::SetPhase(int iPhase) TPacketGDSetup p; memset(&p, 0, sizeof(p)); - strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP)); + strncpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP)); if (!g_bAuthServer) { @@ -192,9 +192,9 @@ void CLIENT_DESC::SetPhase(int iPhase) if (r.id != 0) { pck.dwID = r.id; - strlcpy(pck.szLogin, r.login, sizeof(pck.szLogin)); - strlcpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID)); - strlcpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost)); + strncpy(pck.szLogin, r.login, sizeof(pck.szLogin)); + strncpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID)); + strncpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost)); pck.dwLoginKey = d->GetLoginKey(); #ifndef _IMPROVED_PACKET_ENCRYPTION_ thecore_memcpy(pck.adwClientKey, d->GetDecryptionKey(), 16); diff --git a/game/src/desc_manager.cpp b/game/src/desc_manager.cpp index 1cb1c00..99a6cdf 100644 --- a/game/src/desc_manager.cpp +++ b/game/src/desc_manager.cpp @@ -156,7 +156,7 @@ LPDESC DESC_MANAGER::AcceptDesc(LPFDWATCH fdw, socket_t s) if ((desc = socket_accept(s, &peer)) == -1) return NULL; - strlcpy(host, inet_ntoa(peer.sin_addr), sizeof(host)); + strncpy(host, inet_ntoa(peer.sin_addr), sizeof(host)); if (g_bAuthServer) { @@ -205,7 +205,7 @@ LPDESC DESC_MANAGER::AcceptP2PDesc(LPFDWATCH fdw, socket_t bind_fd) if ((fd = socket_accept(bind_fd, &peer)) == -1) return NULL; - strlcpy(host, inet_ntoa(peer.sin_addr), sizeof(host)); + strncpy(host, inet_ntoa(peer.sin_addr), sizeof(host)); LPDESC_P2P pkDesc = M2_NEW DESC_P2P; diff --git a/game/src/desc_manager.h b/game/src/desc_manager.h index e2dfd7d..6ad0f2c 100644 --- a/game/src/desc_manager.h +++ b/game/src/desc_manager.h @@ -3,8 +3,8 @@ #include -#include "../../common/stl.h" -#include "../../common/length.h" +#include +#include #include "IFileMonitor.h" class CLoginKey; diff --git a/game/src/exchange.cpp b/game/src/exchange.cpp index f6cf5af..7738ea1 100644 --- a/game/src/exchange.cpp +++ b/game/src/exchange.cpp @@ -10,7 +10,7 @@ #include "log.h" #include "db.h" #include "locale_service.h" -#include "../../common/length.h" +#include #include "exchange.h" #include "DragonSoul.h" diff --git a/game/src/fishing.cpp b/game/src/fishing.cpp index b240401..be322fc 100644 --- a/game/src/fishing.cpp +++ b/game/src/fishing.cpp @@ -248,7 +248,7 @@ void Initialize() do { - strlcpy(szCol2, start, MIN(sizeof(szCol2), (tab - start) + 1)); + strncpy(szCol2, start, MIN(sizeof(szCol2), (tab - start) + 1)); szCol2[tab-start] = '\0'; trim_and_lower(szCol2, szCol, sizeof(szCol)); @@ -259,7 +259,7 @@ void Initialize() { switch (iColCount++) { - case 0: strlcpy(fish_info[idx].name, szCol, sizeof(fish_info[idx].name)); break; + case 0: strncpy(fish_info[idx].name, szCol, sizeof(fish_info[idx].name)); break; case 1: str_to_number(fish_info[idx].vnum, szCol); break; case 2: str_to_number(fish_info[idx].dead_vnum, szCol); break; case 3: str_to_number(fish_info[idx].grill_vnum, szCol); break; @@ -660,11 +660,11 @@ void Take(fishing_event_info* info, LPCHARACTER ch) if (info->fish_id == 5) { - strlcpy(p.szBoard, LC_TEXT("³¬½ÃÀ̺¥Æ®¿ùôºØ¾î"), sizeof(p.szBoard)); + strncpy(p.szBoard, LC_TEXT("³¬½ÃÀ̺¥Æ®¿ùôºØ¾î"), sizeof(p.szBoard)); } else if (info->fish_id == 6) { - strlcpy(p.szBoard, LC_TEXT("³¬½ÃÀ̺¥Æ®À×¾î"), sizeof(p.szBoard)); + strncpy(p.szBoard, LC_TEXT("³¬½ÃÀ̺¥Æ®À×¾î"), sizeof(p.szBoard)); } db_clientdesc->DBPacket(HEADER_GD_HIGHSCORE_REGISTER, 0, &p, sizeof(TPacketGDHighscore)); diff --git a/game/src/group_text_parse_tree.cpp b/game/src/group_text_parse_tree.cpp index ff5d227..a1f3f9c 100644 --- a/game/src/group_text_parse_tree.cpp +++ b/game/src/group_text_parse_tree.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/stl.h" +#include #include "group_text_parse_tree.h" CGroupTextParseTreeLoader::CGroupTextParseTreeLoader() diff --git a/game/src/group_text_parse_tree.h b/game/src/group_text_parse_tree.h index fbc8f1f..3bf49c0 100644 --- a/game/src/group_text_parse_tree.h +++ b/game/src/group_text_parse_tree.h @@ -1,8 +1,8 @@ #ifndef __INC_METIN_II_GROUP_TEXT_PARSE_TREE_H__ #define __INC_METIN_II_GROUP_TEXT_PARSE_TREE_H__ -#include "../../common/d3dtype.h" -#include "../../common/pool.h" +#include +#include #include "file_loader.h" #include typedef std::map TTokenVectorMap; diff --git a/game/src/guild.cpp b/game/src/guild.cpp index 3d595c3..34aebc5 100644 --- a/game/src/guild.cpp +++ b/game/src/guild.cpp @@ -61,14 +61,14 @@ CGuild::CGuild(TGuildCreateParameter & cp) m_iMemberCountBonus = 0; - strlcpy(m_data.name, cp.name, sizeof(m_data.name)); + strncpy(m_data.name, cp.name, sizeof(m_data.name)); m_data.master_pid = cp.master->GetPlayerID(); - strlcpy(m_data.grade_array[0].grade_name, LC_TEXT("±æµåÀå"), sizeof(m_data.grade_array[0].grade_name)); + strncpy(m_data.grade_array[0].grade_name, LC_TEXT("±æµåÀå"), sizeof(m_data.grade_array[0].grade_name)); m_data.grade_array[0].auth_flag = GUILD_AUTH_ADD_MEMBER | GUILD_AUTH_REMOVE_MEMBER | GUILD_AUTH_NOTICE | GUILD_AUTH_USE_SKILL; for (int i = 1; i < GUILD_GRADE_COUNT; ++i) { - strlcpy(m_data.grade_array[i].grade_name, LC_TEXT("±æµå¿ø"), sizeof(m_data.grade_array[i].grade_name)); + strncpy(m_data.grade_array[i].grade_name, LC_TEXT("±æµå¿ø"), sizeof(m_data.grade_array[i].grade_name)); m_data.grade_array[i].auth_flag = 0; } @@ -446,7 +446,7 @@ void CGuild::SendListPacket(LPCHARACTER ch) buf.write(&(it->second), sizeof(DWORD)*3+1); - strlcpy(c, it->second.name.c_str(), MIN(sizeof(c), it->second.name.length() + 1)); + strncpy(c, it->second.name.c_str(), MIN(sizeof(c), it->second.name.length() + 1)); buf.write(c, CHARACTER_NAME_MAX_LEN+1 ); @@ -579,7 +579,7 @@ void CGuild::LoadGuildGradeData(SQLMsg* pmsg) if (grade >= 1 && grade <= 15) { //sys_log(0, "GuildGradeLoad %s", name); - strlcpy(m_data.grade_array[grade-1].grade_name, name, sizeof(m_data.grade_array[grade-1].grade_name)); + strncpy(m_data.grade_array[grade-1].grade_name, name, sizeof(m_data.grade_array[grade-1].grade_name)); m_data.grade_array[grade-1].auth_flag = auth; } } @@ -596,7 +596,7 @@ void CGuild::LoadGuildData(SQLMsg* pmsg) m_data.master_pid = strtoul(row[0], (char **)NULL, 10); m_data.level = (BYTE)strtoul(row[1], (char **)NULL, 10); m_data.exp = strtoul(row[2], (char **)NULL, 10); - strlcpy(m_data.name, row[3], sizeof(m_data.name)); + strncpy(m_data.name, row[3], sizeof(m_data.name)); m_data.skill_point = (BYTE) strtoul(row[4], (char **) NULL, 10); if (row[5]) @@ -703,7 +703,7 @@ void CGuild::__P2PUpdateGrade(SQLMsg* pmsg) // µî±Þ ¸íĪÀÌ ÇöÀç¿Í ´Ù¸£´Ù¸é ¾÷µ¥ÀÌÆ® if (0 != strcmp(m_data.grade_array[grade].grade_name, name)) { - strlcpy(m_data.grade_array[grade].grade_name, name, sizeof(m_data.grade_array[grade].grade_name)); + strncpy(m_data.grade_array[grade].grade_name, name, sizeof(m_data.grade_array[grade].grade_name)); TPacketGCGuild pack; @@ -715,7 +715,7 @@ void CGuild::__P2PUpdateGrade(SQLMsg* pmsg) pack.size += sizeof(pack2); pack2.grade = grade + 1; - strlcpy(pack2.grade_name, name, sizeof(pack2.grade_name)); + strncpy(pack2.grade_name, name, sizeof(pack2.grade_name)); TEMP_BUFFER buf; @@ -810,7 +810,7 @@ void CGuild::ChangeGradeName(BYTE grade, const char* grade_name) DBManager::instance().FuncAfterQuery(FSendChangeGrade(GetID(), grade), "UPDATE guild_grade%s SET name = '%s' where guild_id = %u and grade = %d", get_table_postfix(), text, m_data.guild_id, grade); grade--; - strlcpy(m_data.grade_array[grade].grade_name, grade_name, sizeof(m_data.grade_array[grade].grade_name)); + strncpy(m_data.grade_array[grade].grade_name, grade_name, sizeof(m_data.grade_array[grade].grade_name)); TPacketGCGuild pack; pack.header = HEADER_GC_GUILD; @@ -820,7 +820,7 @@ void CGuild::ChangeGradeName(BYTE grade, const char* grade_name) TOneGradeNamePacket pack2; pack.size+=sizeof(pack2); pack2.grade = grade+1; - strlcpy(pack2.grade_name,grade_name, sizeof(pack2.grade_name)); + strncpy(pack2.grade_name,grade_name, sizeof(pack2.grade_name)); TEMP_BUFFER buf; buf.write(&pack,sizeof(pack)); @@ -896,7 +896,7 @@ void CGuild::SendGuildInfoPacket(LPCHARACTER ch) pack_sub.master_pid = m_data.master_pid; pack_sub.exp = m_data.exp; pack_sub.level = m_data.level; - strlcpy(pack_sub.name, m_data.name, sizeof(pack_sub.name)); + strncpy(pack_sub.name, m_data.name, sizeof(pack_sub.name)); pack_sub.gold = m_data.gold; pack_sub.has_land = HasLand(); @@ -1079,8 +1079,8 @@ void CGuild::RefreshCommentForce(DWORD player_id) MYSQL_ROW row = mysql_fetch_row(pmsg->Get()->pSQLResult); DWORD id = strtoul(row[0], NULL, 10); - strlcpy(szName, row[1], sizeof(szName)); - strlcpy(szContent, row[2], sizeof(szContent)); + strncpy(szName, row[1], sizeof(szName)); + strncpy(szContent, row[2], sizeof(szContent)); d->BufferedPacket(&id, sizeof(id)); d->BufferedPacket(szName, sizeof(szName)); @@ -1679,7 +1679,7 @@ void CGuild::Chat(const char* c_pszText) p1.bHeader = HEADER_GG_GUILD; p1.bSubHeader = GUILD_SUBHEADER_GG_CHAT; p1.dwGuild = GetID(); - strlcpy(p2.szText, c_pszText, sizeof(p2.szText)); + strncpy(p2.szText, c_pszText, sizeof(p2.szText)); P2P_MANAGER::instance().Send(&p1, sizeof(TPacketGGGuild)); P2P_MANAGER::instance().Send(&p2, sizeof(TPacketGGGuildChat)); diff --git a/game/src/horsename_manager.cpp b/game/src/horsename_manager.cpp index 63d8a28..6159869 100644 --- a/game/src/horsename_manager.cpp +++ b/game/src/horsename_manager.cpp @@ -50,7 +50,7 @@ void CHorseNameManager::BroadcastHorseName(DWORD dwPlayerID, const char* szHorse { TPacketUpdateHorseName packet; packet.dwPlayerID = dwPlayerID; - strlcpy(packet.szHorseName, szHorseName, sizeof(packet.szHorseName)); + strncpy(packet.szHorseName, szHorseName, sizeof(packet.szHorseName)); db_clientdesc->DBPacket(HEADER_GD_UPDATE_HORSE_NAME, 0, &packet, sizeof(TPacketUpdateHorseName)); } diff --git a/game/src/input.cpp b/game/src/input.cpp index d5e14ee..0274c9a 100644 --- a/game/src/input.cpp +++ b/game/src/input.cpp @@ -241,7 +241,7 @@ void LoginFailure(LPDESC d, const char * c_pszStatus) TPacketGCLoginFailure failurePacket; failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, c_pszStatus, sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, c_pszStatus, sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(failurePacket)); } @@ -395,7 +395,7 @@ int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData) p.dwID = (DWORD)(atoi(msg.c_str())); snprintf(szTmp,sizeof(szTmp),"Sent to DB cache to delete ItemAward, id: %d",p.dwID); //sys_log(0,"%d",p.dwID); - // strlcpy(p.login, msg.c_str(), sizeof(p.login)); + // strncpy(p.login, msg.c_str(), sizeof(p.login)); db_clientdesc->DBPacket(HEADER_GD_DELETE_AWARDID, 0, &p, sizeof(p)); stResult += szTmp; } @@ -446,14 +446,14 @@ dev_log(LOG_DEB0, "DC : '%s'", msg.c_str()); TPacketGGDisconnect pgg; pgg.bHeader = HEADER_GG_DISCONNECT; - strlcpy(pgg.szLogin, msg.c_str(), sizeof(pgg.szLogin)); + strncpy(pgg.szLogin, msg.c_str(), sizeof(pgg.szLogin)); P2P_MANAGER::instance().Send(&pgg, sizeof(TPacketGGDisconnect)); // delete login key { TPacketDC p; - strlcpy(p.login, msg.c_str(), sizeof(p.login)); + strncpy(p.login, msg.c_str(), sizeof(p.login)); db_clientdesc->DBPacket(HEADER_GD_DC, 0, &p, sizeof(p)); } } diff --git a/game/src/input_auth.cpp b/game/src/input_auth.cpp index 34f5ef8..e7687cd 100644 --- a/game/src/input_auth.cpp +++ b/game/src/input_auth.cpp @@ -135,7 +135,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData) trim_and_lower(pinfo->login, login, sizeof(login)); char passwd[PASSWD_MAX_LEN + 1]; - strlcpy(passwd, pinfo->passwd, sizeof(passwd)); + strncpy(passwd, pinfo->passwd, sizeof(passwd)); sys_log(0, "InputAuth::Login : %s(%d) desc %p", login, strlen(login), get_pointer(d)); @@ -154,7 +154,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData) TPacketGCLoginFailure failurePacket; failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(failurePacket)); return; @@ -287,7 +287,7 @@ void CInputAuth::LoginOpenID(LPDESC d, const char * c_pData) trim_and_lower(pinfo->login, login, sizeof(login)); char passwd[PASSWD_MAX_LEN + 1]; - strlcpy(passwd, pinfo->passwd, sizeof(passwd)); + strncpy(passwd, pinfo->passwd, sizeof(passwd)); sys_log(0, "InputAuth::Login : %s(%d) desc %p", login, strlen(login), get_pointer(d)); @@ -306,7 +306,7 @@ void CInputAuth::LoginOpenID(LPDESC d, const char * c_pData) TPacketGCLoginFailure failurePacket; failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(failurePacket)); return; diff --git a/game/src/input_db.cpp b/game/src/input_db.cpp index cc5e595..ab6c130 100644 --- a/game/src/input_db.cpp +++ b/game/src/input_db.cpp @@ -134,7 +134,7 @@ void CInputDB::LoginSuccess(DWORD dwHandle, const char *data) TLogoutPacket pack; - strlcpy(pack.login, pTab->login, sizeof(pack.login)); + strncpy(pack.login, pTab->login, sizeof(pack.login)); db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack)); return; } @@ -145,7 +145,7 @@ void CInputDB::LoginSuccess(DWORD dwHandle, const char *data) TLogoutPacket pack; - strlcpy(pack.login, pTab->login, sizeof(pack.login)); + strncpy(pack.login, pTab->login, sizeof(pack.login)); db_clientdesc->DBPacket(HEADER_GD_LOGOUT, dwHandle, &pack, sizeof(pack)); LoginFailure(d, pTab->status); @@ -323,14 +323,14 @@ void CInputDB::ChangeName(LPDESC d, const char * data) for (size_t i = 0; i < PLAYER_PER_ACCOUNT; ++i) if (r.players[i].dwID == p->pid) { - strlcpy(r.players[i].szName, p->name, sizeof(r.players[i].szName)); + strncpy(r.players[i].szName, p->name, sizeof(r.players[i].szName)); r.players[i].bChangeName = 0; TPacketGCChangeName pgc; pgc.header = HEADER_GC_CHANGE_NAME; pgc.pid = p->pid; - strlcpy(pgc.name, p->name, sizeof(pgc.name)); + strncpy(pgc.name, p->name, sizeof(pgc.name)); d->Packet(&pgc, sizeof(TPacketGCChangeName)); break; @@ -408,7 +408,7 @@ void CInputDB::PlayerLoad(LPDESC d, const char * data) TPacketGGLogin p; p.bHeader = HEADER_GG_LOGIN; - strlcpy(p.szName, ch->GetName(), sizeof(p.szName)); + strncpy(p.szName, ch->GetName(), sizeof(p.szName)); p.dwPID = ch->GetPlayerID(); p.bEmpire = ch->GetEmpire(); p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(ch->GetX(), ch->GetY()); @@ -1282,7 +1282,7 @@ void CInputDB::LoginAlready(LPDESC d, const char * c_pData) TPacketGGDisconnect pgg; pgg.bHeader = HEADER_GG_DISCONNECT; - strlcpy(pgg.szLogin, p->szLogin, sizeof(pgg.szLogin)); + strncpy(pgg.szLogin, p->szLogin, sizeof(pgg.szLogin)); P2P_MANAGER::instance().Send(&pgg, sizeof(TPacketGGDisconnect)); } @@ -1981,7 +1981,7 @@ void CInputDB::Notice(const char * c_pData) extern void SendNotice(const char * c_pszBuf); char szBuf[256+1]; - strlcpy(szBuf, c_pData, sizeof(szBuf)); + strncpy(szBuf, c_pData, sizeof(szBuf)); sys_log(0, "InputDB:: Notice: %s", szBuf); diff --git a/game/src/input_login.cpp b/game/src/input_login.cpp index 674bf77..20d3b60 100644 --- a/game/src/input_login.cpp +++ b/game/src/input_login.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" #include "constants.h" -#include "../../common/teen_packet.h" +#include #include "config.h" #include "utils.h" #include "input.h" @@ -98,7 +98,7 @@ void CInputLogin::Login(LPDESC d, const char * data) if (g_iUseLocale && !test_server) { failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "VERSION", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "VERSION", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure)); return; } @@ -106,7 +106,7 @@ void CInputLogin::Login(LPDESC d, const char * data) if (g_bNoMoreClient) { failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure)); return; } @@ -122,7 +122,7 @@ void CInputLogin::Login(LPDESC d, const char * data) if (g_iUserLimit <= iTotal) { failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure)); return; } @@ -130,8 +130,8 @@ void CInputLogin::Login(LPDESC d, const char * data) TLoginPacket login_packet; - strlcpy(login_packet.login, login, sizeof(login_packet.login)); - strlcpy(login_packet.passwd, pinfo->passwd, sizeof(login_packet.passwd)); + strncpy(login_packet.login, login, sizeof(login_packet.login)); + strncpy(login_packet.passwd, pinfo->passwd, sizeof(login_packet.passwd)); db_clientdesc->DBPacket(HEADER_GD_LOGIN, d->GetHandle(), &login_packet, sizeof(TLoginPacket)); } @@ -162,7 +162,7 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data) TPacketGCLoginFailure failurePacket; failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure)); return; } @@ -180,7 +180,7 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data) TPacketGCLoginFailure failurePacket; failurePacket.header = HEADER_GC_LOGIN_FAILURE; - strlcpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus)); + strncpy(failurePacket.szStatus, "FULL", sizeof(failurePacket.szStatus)); d->Packet(&failurePacket, sizeof(TPacketGCLoginFailure)); return; @@ -196,10 +196,10 @@ void CInputLogin::LoginByKey(LPDESC d, const char * data) TPacketGDLoginByKey ptod; - strlcpy(ptod.szLogin, login, sizeof(ptod.szLogin)); + strncpy(ptod.szLogin, login, sizeof(ptod.szLogin)); ptod.dwLoginKey = pinfo->dwLoginKey; thecore_memcpy(ptod.adwClientKey, pinfo->adwClientKey, sizeof(DWORD) * 4); - strlcpy(ptod.szIP, d->GetHostName(), sizeof(ptod.szIP)); + strncpy(ptod.szIP, d->GetHostName(), sizeof(ptod.szIP)); db_clientdesc->DBPacket(HEADER_GD_LOGIN_BY_KEY, d->GetHandle(), &ptod, sizeof(TPacketGDLoginByKey)); } @@ -230,7 +230,7 @@ void CInputLogin::ChangeName(LPDESC d, const char * data) TPacketGDChangeName pdb; pdb.pid = c_r.players[p->index].dwID; - strlcpy(pdb.name, p->name, sizeof(pdb.name)); + strncpy(pdb.name, p->name, sizeof(pdb.name)); db_clientdesc->DBPacket(HEADER_GD_CHANGE_NAME, d->GetHandle(), &pdb, sizeof(TPacketGDChangeName)); } @@ -284,7 +284,7 @@ bool NewPlayerTable(TPlayerTable * table, memset(table, 0, sizeof(TPlayerTable)); - strlcpy(table->name, name, sizeof(table->name)); + strncpy(table->name, name, sizeof(table->name)); table->level = 1; table->job = job; @@ -400,7 +400,7 @@ bool NewPlayerTable2(TPlayerTable * table, const char * name, BYTE race, BYTE sh memset(table, 0, sizeof(TPlayerTable)); - strlcpy(table->name, name, sizeof(table->name)); + strncpy(table->name, name, sizeof(table->name)); table->level = 1; table->job = race; // Á÷¾÷´ë½Å Á¾Á·À» ³Ö´Â´Ù @@ -493,7 +493,7 @@ void CInputLogin::CharacterCreate(LPDESC d, const char * data) const TAccountTable & c_rAccountTable = d->GetAccountTable(); trim_and_lower(c_rAccountTable.login, player_create_packet.login, sizeof(player_create_packet.login)); - strlcpy(player_create_packet.passwd, c_rAccountTable.passwd, sizeof(player_create_packet.passwd)); + strncpy(player_create_packet.passwd, c_rAccountTable.passwd, sizeof(player_create_packet.passwd)); player_create_packet.account_id = c_rAccountTable.id; player_create_packet.account_index = pinfo->index; @@ -538,7 +538,7 @@ void CInputLogin::CharacterDelete(LPDESC d, const char * data) trim_and_lower(c_rAccountTable.login, player_delete_packet.login, sizeof(player_delete_packet.login)); player_delete_packet.player_id = c_rAccountTable.players[pinfo->index].dwID; player_delete_packet.account_index = pinfo->index; - strlcpy(player_delete_packet.private_code, pinfo->private_code, sizeof(player_delete_packet.private_code)); + strncpy(player_delete_packet.private_code, pinfo->private_code, sizeof(player_delete_packet.private_code)); db_clientdesc->DBPacket(HEADER_GD_PLAYER_DELETE, d->GetHandle(), &player_delete_packet, sizeof(TPlayerDeletePacket)); } diff --git a/game/src/input_main.cpp b/game/src/input_main.cpp index deda546..0ebe0d9 100644 --- a/game/src/input_main.cpp +++ b/game/src/input_main.cpp @@ -148,7 +148,7 @@ bool SpamBlockCheck(LPCHARACTER ch, const char* const buf, const size_t buflen) if (it->second.first >= g_uiSpamBlockScore) { spam_event_info* info = AllocEventInfo(); - strlcpy(info->host, ch->GetDesc()->GetHostName(), sizeof(info->host)); + strncpy(info->host, ch->GetDesc()->GetHostName(), sizeof(info->host)); it->second.second = event_create(block_chat_by_ip_event, info, PASSES_PER_SEC(g_uiSpamBlockDuration)); sys_log(0, "SPAM_IP: %s for %u seconds", info->host, g_uiSpamBlockDuration); @@ -326,7 +326,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.bHeader = HEADER_GC_WHISPER; pack.bType = WHISPER_TYPE_SENDER_BLOCKED; pack.wSize = sizeof(TPacketGCWhisper); - strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); ch->GetDesc()->Packet(&pack, sizeof(pack)); } return iExtraLen; @@ -361,7 +361,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.bHeader = HEADER_GC_WHISPER; pack.bType = WHISPER_TYPE_NOT_EXIST; pack.wSize = sizeof(TPacketGCWhisper); - strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); ch->GetDesc()->Packet(&pack, sizeof(TPacketGCWhisper)); sys_log(0, "WHISPER: no player"); } @@ -376,7 +376,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.bHeader = HEADER_GC_WHISPER; pack.bType = WHISPER_TYPE_SENDER_BLOCKED; pack.wSize = sizeof(TPacketGCWhisper); - strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); ch->GetDesc()->Packet(&pack, sizeof(pack)); } } @@ -388,7 +388,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.bHeader = HEADER_GC_WHISPER; pack.bType = WHISPER_TYPE_TARGET_BLOCKED; pack.wSize = sizeof(TPacketGCWhisper); - strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); ch->GetDesc()->Packet(&pack, sizeof(pack)); } } @@ -397,7 +397,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) BYTE bType = WHISPER_TYPE_NORMAL; char buf[CHAT_MAX_LEN + 1]; - strlcpy(buf, data + sizeof(TPacketCGWhisper), MIN(iExtraLen + 1, sizeof(buf))); + strncpy(buf, data + sizeof(TPacketCGWhisper), MIN(iExtraLen + 1, sizeof(buf))); const size_t buflen = strlen(buf); if (true == SpamBlockCheck(ch, buf, buflen)) @@ -464,7 +464,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.bHeader = HEADER_GC_WHISPER; pack.bType = WHISPER_TYPE_ERROR; pack.wSize = sizeof(TPacketGCWhisper) + len; - strlcpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, pinfo->szNameTo, sizeof(pack.szNameFrom)); ch->GetDesc()->BufferedPacket(&pack, sizeof(pack)); ch->GetDesc()->Packet(buf, len); @@ -488,7 +488,7 @@ int CInputMain::Whisper(LPCHARACTER ch, const char * data, size_t uiBytes) pack.bHeader = HEADER_GC_WHISPER; pack.wSize = sizeof(TPacketGCWhisper) + buflen; pack.bType = bType; - strlcpy(pack.szNameFrom, ch->GetName(), sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, ch->GetName(), sizeof(pack.szNameFrom)); // desc->BufferedPacketÀ» ÇÏÁö ¾Ê°í ¹öÆÛ¿¡ ½á¾ßÇÏ´Â ÀÌÀ¯´Â // P2P relayµÇ¾î ÆÐŶÀÌ Ä¸½¶È­ µÉ ¼ö Àֱ⠶§¹®ÀÌ´Ù. @@ -567,7 +567,7 @@ struct FEmpireChatPacket else { // »ç¶÷¸¶´Ù ½ºÅ³·¹º§ÀÌ ´Ù¸£´Ï ¸Å¹ø ÇؾßÇÕ´Ï´Ù - size_t len = strlcpy(converted_msg, orig_msg, sizeof(converted_msg)); + size_t len = strncpy(converted_msg, orig_msg, sizeof(converted_msg)); if (len >= sizeof(converted_msg)) len = sizeof(converted_msg) - 1; @@ -659,7 +659,7 @@ int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes) } char buf[CHAT_MAX_LEN - (CHARACTER_NAME_MAX_LEN + 3) + 1]; - strlcpy(buf, data + sizeof(TPacketCGChat), MIN(iExtraLen + 1, sizeof(buf))); + strncpy(buf, data + sizeof(TPacketCGChat), MIN(iExtraLen + 1, sizeof(buf))); const size_t buflen = strlen(buf); if (buflen > 1 && *buf == '/') @@ -745,7 +745,7 @@ int CInputMain::Chat(LPCHARACTER ch, const char * data, size_t uiBytes) p.bHeader = HEADER_GG_SHOUT; p.bEmpire = ch->GetEmpire(); - strlcpy(p.szText, chatbuf, sizeof(p.szText)); + strncpy(p.szText, chatbuf, sizeof(p.szText)); P2P_MANAGER::instance().Send(&p, sizeof(TPacketGGShout)); @@ -965,7 +965,7 @@ int CInputMain::Messenger(LPCHARACTER ch, const char* c_pData, size_t uiBytes) return -1; char name[CHARACTER_NAME_MAX_LEN + 1]; - strlcpy(name, c_pData, sizeof(name)); + strncpy(name, c_pData, sizeof(name)); if (ch->GetGMLevel() == GM_PLAYER && gm_get_level(name) != GM_PLAYER) { @@ -1002,7 +1002,7 @@ int CInputMain::Messenger(LPCHARACTER ch, const char* c_pData, size_t uiBytes) return -1; char char_name[CHARACTER_NAME_MAX_LEN + 1]; - strlcpy(char_name, c_pData, sizeof(char_name)); + strncpy(char_name, c_pData, sizeof(char_name)); MessengerManager::instance().RemoveFromList(ch->GetName(), char_name); } return CHARACTER_NAME_MAX_LEN; @@ -2002,7 +2002,7 @@ void CInputMain::QuestInputString(LPCHARACTER ch, const void* c_pData) TPacketCGQuestInputString * p = (TPacketCGQuestInputString*) c_pData; char msg[65]; - strlcpy(msg, p->msg, sizeof(msg)); + strncpy(msg, p->msg, sizeof(msg)); sys_log(0, "QUEST InputString pid %u msg %s", ch->GetPlayerID(), msg); quest::CQuestManager::Instance().Input(ch->GetPlayerID(), msg); @@ -2429,7 +2429,7 @@ void CInputMain::AnswerMakeGuild(LPCHARACTER ch, const char* c_pData) memset(&cp, 0, sizeof(cp)); cp.master = ch; - strlcpy(cp.name, p->guild_name, sizeof(cp.name)); + strncpy(cp.name, p->guild_name, sizeof(cp.name)); if (cp.name[0] == 0 || !check_name(cp.name)) { @@ -2685,7 +2685,7 @@ int CInputMain::Guild(LPCHARACTER ch, const char * data, size_t uiBytes) case GUILD_SUBHEADER_CG_CHANGE_GRADE_NAME: { char gradename[GUILD_GRADE_NAME_MAX_LEN + 1]; - strlcpy(gradename, c_pData + 1, sizeof(gradename)); + strncpy(gradename, c_pData + 1, sizeof(gradename)); const TGuildMember * m = pGuild->GetMember(ch->GetPlayerID()); @@ -2918,7 +2918,7 @@ void CInputMain::Hack(LPCHARACTER ch, const char * c_pData) TPacketCGHack * p = (TPacketCGHack *) c_pData; char buf[sizeof(p->szBuf)]; - strlcpy(buf, p->szBuf, sizeof(buf)); + strncpy(buf, p->szBuf, sizeof(buf)); sys_err("HACK_DETECT: %s %s", ch->GetName(), buf); diff --git a/game/src/input_p2p.cpp b/game/src/input_p2p.cpp index dcb8e4d..43f901d 100644 --- a/game/src/input_p2p.cpp +++ b/game/src/input_p2p.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/billing.h" +#include #include "config.h" #include "desc_client.h" #include "desc_manager.h" @@ -117,7 +117,7 @@ int CInputP2P::Notice(LPDESC d, const char * c_pData, size_t uiBytes) } char szBuf[256+1]; - strlcpy(szBuf, c_pData + sizeof(TPacketGGNotice), MIN(p->lSize + 1, sizeof(szBuf))); + strncpy(szBuf, c_pData + sizeof(TPacketGGNotice), MIN(p->lSize + 1, sizeof(szBuf))); SendNotice(szBuf); return (p->lSize); } @@ -137,7 +137,7 @@ int CInputP2P::MonarchNotice(LPDESC d, const char * c_pData, size_t uiBytes) } char szBuf[256+1]; - strlcpy(szBuf, c_pData + sizeof(TPacketGGMonarchNotice), MIN(p->lSize + 1, sizeof(szBuf))); + strncpy(szBuf, c_pData + sizeof(TPacketGGMonarchNotice), MIN(p->lSize + 1, sizeof(szBuf))); SendMonarchNotice(p->bEmpire, szBuf); return (p->lSize); } diff --git a/game/src/input_teen.cpp b/game/src/input_teen.cpp index cae29aa..1e64ead 100644 --- a/game/src/input_teen.cpp +++ b/game/src/input_teen.cpp @@ -9,7 +9,7 @@ #include "stdafx.h" #include "constants.h" -#include "../../common/teen_packet.h" +#include #include "input.h" #include "desc.h" #include "desc_manager.h" diff --git a/game/src/ip_ban.cpp b/game/src/ip_ban.cpp index 128bfca..1437e94 100644 --- a/game/src/ip_ban.cpp +++ b/game/src/ip_ban.cpp @@ -114,7 +114,7 @@ class IP if (!pDot) break; - strlcpy(szNum, p, sizeof(szNum)); + strncpy(szNum, p, sizeof(szNum)); str_to_number(dest[bClass++], szNum); p = pDot + 1; @@ -157,7 +157,7 @@ bool LoadBanIP(const char * filename) if (!p) { - strlcpy(start, buf, sizeof(start)); + strncpy(start, buf, sizeof(start)); *end = '\0'; } else @@ -167,10 +167,10 @@ bool LoadBanIP(const char * filename) if (p2) *p2 = '\0'; - strlcpy(end, p + 1, sizeof(end)); + strncpy(end, p + 1, sizeof(end)); *p = '\0'; - strlcpy(start, buf, sizeof(start)); + strncpy(start, buf, sizeof(start)); } IP ip(start, end); @@ -340,14 +340,14 @@ int main(int argc, char **argv) if (!p) { - strlcpy(start, buf, sizeof(start)); + strncpy(start, buf, sizeof(start)); *end = '\0'; } else { - strlcpy(end, p + 1, sizeof(end)); + strncpy(end, p + 1, sizeof(end)); *p = '\0'; - strlcpy(start, buf, sizeof(start)); + strncpy(start, buf, sizeof(start)); } v.push_back(IP(start, end)); diff --git a/game/src/item.cpp b/game/src/item.cpp index 3fc1662..67b9e0c 100644 --- a/game/src/item.cpp +++ b/game/src/item.cpp @@ -20,7 +20,7 @@ #include "DragonSoul.h" #include "buff_on_attributes.h" #include "belt_inventory_helper.h" -#include "../../common/VnumHelper.h" +#include CItem::CItem(DWORD dwVnum) : m_dwVnum(dwVnum), m_bWindow(0), m_dwID(0), m_bEquipped(false), m_dwVID(0), m_wCell(0), m_dwCount(0), m_lFlag(0), m_dwLastOwnerPID(0), @@ -151,7 +151,7 @@ void CItem::EncodeInsertPacket(LPENTITY ent) p.bHeader = HEADER_GC_ITEM_OWNERSHIP; p.dwVID = m_dwVID; - strlcpy(p.szName, info->szOwnerName, sizeof(p.szName)); + strncpy(p.szName, info->szOwnerName, sizeof(p.szName)); d->Packet(&p, sizeof(TPacketGCItemOwnership)); } @@ -1095,7 +1095,7 @@ void CItem::SetOwnership(LPCHARACTER ch, int iSec) m_dwOwnershipPID = ch->GetPlayerID(); item_event_info* info = AllocEventInfo(); - strlcpy(info->szOwnerName, ch->GetName(), sizeof(info->szOwnerName)); + strncpy(info->szOwnerName, ch->GetName(), sizeof(info->szOwnerName)); info->item = this; SetOwnershipEvent(event_create(ownership_event, info, PASSES_PER_SEC(iSec))); @@ -1104,7 +1104,7 @@ void CItem::SetOwnership(LPCHARACTER ch, int iSec) p.bHeader = HEADER_GC_ITEM_OWNERSHIP; p.dwVID = m_dwVID; - strlcpy(p.szName, ch->GetName(), sizeof(p.szName)); + strncpy(p.szName, ch->GetName(), sizeof(p.szName)); PacketAround(&p, sizeof(p)); } diff --git a/game/src/item_manager.cpp b/game/src/item_manager.cpp index df8653c..d2ef828 100644 --- a/game/src/item_manager.cpp +++ b/game/src/item_manager.cpp @@ -18,7 +18,7 @@ #include "item.h" #include "item_manager.h" -#include "../../common/VnumHelper.h" +#include #include "DragonSoul.h" #include "cube.h" diff --git a/game/src/item_manager_read_tables.cpp b/game/src/item_manager_read_tables.cpp index 364bc19..eb69275 100644 --- a/game/src/item_manager_read_tables.cpp +++ b/game/src/item_manager_read_tables.cpp @@ -60,7 +60,7 @@ bool ITEM_MANAGER::ReadCommonDropItemFile(const char * c_pszFileName) if (!p2) break; - strlcpy(szTemp, p, MIN(sizeof(szTemp), (p2 - p) + 1)); + strncpy(szTemp, p, MIN(sizeof(szTemp), (p2 - p) + 1)); p = p2 + 1; switch (j) @@ -69,7 +69,7 @@ bool ITEM_MANAGER::ReadCommonDropItemFile(const char * c_pszFileName) case 1: str_to_number(d[i].iLvStart, szTemp); break; case 2: str_to_number(d[i].iLvEnd, szTemp); break; case 3: d[i].fPercent = atof(szTemp); break; - case 4: strlcpy(d[i].szItemName, szTemp, sizeof(d[i].szItemName)); break; + case 4: strncpy(d[i].szItemName, szTemp, sizeof(d[i].szItemName)); break; case 5: str_to_number(d[i].iCount, szTemp); break; } } @@ -451,7 +451,7 @@ bool ITEM_MANAGER::ReadEtcDropItemFile(const char * c_pszFileName) char szItemName[256]; float fProb = 0.0f; - strlcpy(szItemName, buf, sizeof(szItemName)); + strncpy(szItemName, buf, sizeof(szItemName)); char * cpTab = strrchr(szItemName, '\t'); if (!cpTab) diff --git a/game/src/locale.cpp b/game/src/locale.cpp index d46c7e4..e1f32cd 100644 --- a/game/src/locale.cpp +++ b/game/src/locale.cpp @@ -30,7 +30,7 @@ const char * locale_find(const char *string) if( iter == localeString.end() ) { static char s_line[1024] = "@0949"; - strlcpy(s_line + 5, string, sizeof(s_line) - 5); + strncpy(s_line + 5, string, sizeof(s_line) - 5); sys_err("LOCALE_ERROR: \"%s\";", string); return s_line; diff --git a/game/src/log.h b/game/src/log.h index c9c9913..14d9fab 100644 --- a/game/src/log.h +++ b/game/src/log.h @@ -1,7 +1,7 @@ #ifndef __INC_LOG_MANAGER_H__ #define __INC_LOG_MANAGER_H__ -#include "../../libsql/AsyncSQL.h" +#include #include "any_function.h" enum GOLDBAR_HOW diff --git a/game/src/login_data.cpp b/game/src/login_data.cpp index d41ff66..56d4286 100644 --- a/game/src/login_data.cpp +++ b/game/src/login_data.cpp @@ -81,7 +81,7 @@ DWORD CLoginData::GetLogonTime() void CLoginData::SetIP(const char * c_pszIP) { - strlcpy(m_szIP, c_pszIP, sizeof(m_szIP)); + strncpy(m_szIP, c_pszIP, sizeof(m_szIP)); } const char * CLoginData::GetIP() diff --git a/game/src/main.cpp b/game/src/main.cpp index 7229836..8c46d54 100644 --- a/game/src/main.cpp +++ b/game/src/main.cpp @@ -186,11 +186,11 @@ void ShutdownOnFatalError() { char buf[256]; - strlcpy(buf, LC_TEXT("¼­¹ö¿¡ Ä¡¸íÀûÀÎ ¿À·ù°¡ ¹ß»ýÇÏ¿© ÀÚµ¿À¸·Î ÀçºÎÆõ˴ϴÙ."), sizeof(buf)); + strncpy(buf, LC_TEXT("¼­¹ö¿¡ Ä¡¸íÀûÀÎ ¿À·ù°¡ ¹ß»ýÇÏ¿© ÀÚµ¿À¸·Î ÀçºÎÆõ˴ϴÙ."), sizeof(buf)); SendNotice(buf); - strlcpy(buf, LC_TEXT("10ÃÊÈÄ ÀÚµ¿À¸·Î Á¢¼ÓÀÌ Á¾·áµÇ¸ç,"), sizeof(buf)); + strncpy(buf, LC_TEXT("10ÃÊÈÄ ÀÚµ¿À¸·Î Á¢¼ÓÀÌ Á¾·áµÇ¸ç,"), sizeof(buf)); SendNotice(buf); - strlcpy(buf, LC_TEXT("5ºÐ ÈÄ¿¡ Á¤»óÀûÀ¸·Î Á¢¼ÓÇϽǼö ÀÖ½À´Ï´Ù."), sizeof(buf)); + strncpy(buf, LC_TEXT("5ºÐ ÈÄ¿¡ Á¤»óÀûÀ¸·Î Á¢¼ÓÇϽǼö ÀÖ½À´Ï´Ù."), sizeof(buf)); SendNotice(buf); } @@ -722,7 +722,7 @@ int start(int argc, char **argv) switch (ch) { case 'I': // IP - strlcpy(g_szPublicIP, argv[optind], sizeof(g_szPublicIP)); + strncpy(g_szPublicIP, argv[optind], sizeof(g_szPublicIP)); printf("IP %s\n", g_szPublicIP); diff --git a/game/src/map_location.h b/game/src/map_location.h index ecf87a3..f5009cc 100644 --- a/game/src/map_location.h +++ b/game/src/map_location.h @@ -1,5 +1,5 @@ -#include "../../common/stl.h" +#include class CMapLocation : public singleton { diff --git a/game/src/marriage.cpp b/game/src/marriage.cpp index de32fee..9544db9 100644 --- a/game/src/marriage.cpp +++ b/game/src/marriage.cpp @@ -45,7 +45,7 @@ namespace marriage TPacketGCLoverInfo p; p.header = HEADER_GC_LOVER_INFO; - strlcpy(p.name, lover_name.c_str(), sizeof(p.name)); + strncpy(p.name, lover_name.c_str(), sizeof(p.name)); p.love_point = love_point; ch->GetDesc()->Packet(&p, sizeof(p)); } @@ -552,8 +552,8 @@ namespace marriage p.dwPID1 = dwPID1; p.dwPID2 = dwPID2; - strlcpy(p.szName1, szName1, sizeof(p.szName1)); - strlcpy(p.szName2, szName2, sizeof(p.szName2)); + strncpy(p.szName1, szName1, sizeof(p.szName1)); + strncpy(p.szName2, szName2, sizeof(p.szName2)); db_clientdesc->DBPacket(HEADER_GD_MARRIAGE_ADD, 0, &p, sizeof(p)); } diff --git a/game/src/messenger_manager.cpp b/game/src/messenger_manager.cpp index d3949fa..9fc94bf 100644 --- a/game/src/messenger_manager.cpp +++ b/game/src/messenger_manager.cpp @@ -200,8 +200,8 @@ void MessengerManager::AddToList(MessengerManager::keyA account, MessengerManage TPacketGGMessenger p2ppck; p2ppck.bHeader = HEADER_GG_MESSENGER_ADD; - strlcpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount)); - strlcpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion)); + strncpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount)); + strncpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion)); P2P_MANAGER::instance().Send(&p2ppck, sizeof(TPacketGGMessenger)); } @@ -231,8 +231,8 @@ void MessengerManager::RemoveFromList(MessengerManager::keyA account, MessengerM TPacketGGMessenger p2ppck; p2ppck.bHeader = HEADER_GG_MESSENGER_REMOVE; - strlcpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount)); - strlcpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion)); + strncpy(p2ppck.szAccount, account.c_str(), sizeof(p2ppck.szAccount)); + strncpy(p2ppck.szCompanion, companion.c_str(), sizeof(p2ppck.szCompanion)); P2P_MANAGER::instance().Send(&p2ppck, sizeof(TPacketGGMessenger)); } diff --git a/game/src/monarch.h b/game/src/monarch.h index 5954339..411dec9 100644 --- a/game/src/monarch.h +++ b/game/src/monarch.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_MONARCH_H__ #define __INC_METIN_II_MONARCH_H__ -#include "../../common/tables.h" +#include class CMonarch : public singleton { diff --git a/game/src/motion.cpp b/game/src/motion.cpp index 60b3248..9089eaa 100644 --- a/game/src/motion.cpp +++ b/game/src/motion.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/stl.h" +#include #include "constants.h" #include "motion.h" #include "text_file_loader.h" diff --git a/game/src/motion.h b/game/src/motion.h index 79b52c1..e13c3c8 100644 --- a/game/src/motion.h +++ b/game/src/motion.h @@ -1,7 +1,7 @@ #ifndef __INC_GAME_MOTION_H__ #define __INC_GAME_MOTION_H__ -#include "../../common/d3dtype.h" +#include enum EMotionMode { diff --git a/game/src/p2p.cpp b/game/src/p2p.cpp index 8c60963..0990dca 100644 --- a/game/src/p2p.cpp +++ b/game/src/p2p.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/stl.h" +#include #include "constants.h" #include "config.h" @@ -41,7 +41,7 @@ void P2P_MANAGER::Boot(LPDESC d) it++; p.bHeader = HEADER_GG_LOGIN; - strlcpy(p.szName, ch->GetName(), sizeof(p.szName)); + strncpy(p.szName, ch->GetName(), sizeof(p.szName)); p.dwPID = ch->GetPlayerID(); p.bEmpire = ch->GetEmpire(); p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex(ch->GetX(), ch->GetY()); @@ -142,7 +142,7 @@ void P2P_MANAGER::Login(LPDESC d, const TPacketGGLogin * p) pkCCI = M2_NEW CCI; if (false == LC_IsBrazil()) - strlcpy(pkCCI->szName, p->szName, sizeof(pkCCI->szName)); + strncpy(pkCCI->szName, p->szName, sizeof(pkCCI->szName)); else trim_and_lower(p->szName, pkCCI->szName, sizeof(pkCCI->szName)); diff --git a/game/src/p2p.h b/game/src/p2p.h index 8604904..f1f1043 100644 --- a/game/src/p2p.h +++ b/game/src/p2p.h @@ -5,7 +5,7 @@ #include #include "input.h" -#include "../../common/stl.h" +#include typedef struct _CCI { diff --git a/game/src/packet_info.cpp b/game/src/packet_info.cpp index 10c1c62..3af506f 100644 --- a/game/src/packet_info.cpp +++ b/game/src/packet_info.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/stl.h" +#include #include "constants.h" #include "packet_info.h" #include "HackShield_Impl.h" diff --git a/game/src/panama.cpp b/game/src/panama.cpp index ed07ddb..04f76a4 100644 --- a/game/src/panama.cpp +++ b/game/src/panama.cpp @@ -77,7 +77,7 @@ void SendPanamaList(LPDESC d) while (it != s_panamaVector.end()) { - strlcpy(pack.szPackName, it->first.c_str(), sizeof(pack.szPackName)); + strncpy(pack.szPackName, it->first.c_str(), sizeof(pack.szPackName)); memcpy(pack.abIV, it->second, sizeof(pack.abIV)); diff --git a/game/src/party.cpp b/game/src/party.cpp index bfb958b..57ea1fb 100644 --- a/game/src/party.cpp +++ b/game/src/party.cpp @@ -689,7 +689,7 @@ void CParty::SendPartyJoinOneToAll(DWORD pid) p.header = HEADER_GC_PARTY_ADD; p.pid = pid; - strlcpy(p.name, r.strName.c_str(), sizeof(p.name)); + strncpy(p.name, r.strName.c_str(), sizeof(p.name)); for (TMemberMap::iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it) { @@ -711,7 +711,7 @@ void CParty::SendPartyJoinAllToOne(LPCHARACTER ch) for (TMemberMap::iterator it = m_memberMap.begin();it!= m_memberMap.end(); ++it) { p.pid = it->first; - strlcpy(p.name, it->second.strName.c_str(), sizeof(p.name)); + strncpy(p.name, it->second.strName.c_str(), sizeof(p.name)); ch->GetDesc()->Packet(&p, sizeof(p)); } } @@ -1441,7 +1441,7 @@ void CParty::UpdateOnlineState(DWORD dwPID, const char* name) p.header = HEADER_GC_PARTY_ADD; p.pid = dwPID; r.strName = name; - strlcpy(p.name, name, sizeof(p.name)); + strncpy(p.name, name, sizeof(p.name)); for (TMemberMap::iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it) { diff --git a/game/src/pvp.cpp b/game/src/pvp.cpp index cced1d1..0c656f2 100644 --- a/game/src/pvp.cpp +++ b/game/src/pvp.cpp @@ -218,7 +218,7 @@ void CPVPManager::Insert(LPCHARACTER pkChr, LPCHARACTER pkVictim) pack.bHeader = HEADER_GC_WHISPER; pack.wSize = sizeof(TPacketGCWhisper) + len; pack.bType = WHISPER_TYPE_SYSTEM; - strlcpy(pack.szNameFrom, pkChr->GetName(), sizeof(pack.szNameFrom)); + strncpy(pack.szNameFrom, pkChr->GetName(), sizeof(pack.szNameFrom)); TEMP_BUFFER buf; diff --git a/game/src/questevent.cpp b/game/src/questevent.cpp index 898a0b0..5cfc372 100644 --- a/game/src/questevent.cpp +++ b/game/src/questevent.cpp @@ -97,7 +97,7 @@ END_OF_TIMER_EVENT: info->name = M2_NEW char[nameCapacity]; if (info->name) - strlcpy(info->name, name, nameCapacity); + strncpy(info->name, name, nameCapacity); return event_create(quest_server_timer_event, info, ltime_cycle); } @@ -115,7 +115,7 @@ END_OF_TIMER_EVENT: info->name = M2_NEW char[nameCapacity]; if (info->name) - strlcpy(info->name, name, nameCapacity); + strncpy(info->name, name, nameCapacity); sys_log(0, "QUEST timer name %s cycle %d pc %u npc %u loop? %d", name ? name : "", ltime_cycle, player_id, npc_id, loop ? 1 : 0); diff --git a/game/src/questlua.cpp b/game/src/questlua.cpp index def9dcb..7dd20b1 100644 --- a/game/src/questlua.cpp +++ b/game/src/questlua.cpp @@ -226,7 +226,7 @@ namespace quest THighscoreRegisterQueryInfo * qi = M2_NEW THighscoreRegisterQueryInfo; - strlcpy(qi->szBoard, lua_tostring(L, 1), sizeof(qi->szBoard)); + strncpy(qi->szBoard, lua_tostring(L, 1), sizeof(qi->szBoard)); qi->dwPID = q.GetCurrentCharacterPtr()->GetPlayerID(); qi->iValue = (int) lua_tonumber(L, 2); qi->bOrder = (int) lua_tonumber(L, 3); diff --git a/game/src/questlua_forked.cpp b/game/src/questlua_forked.cpp index 53e328b..68e3f7a 100644 --- a/game/src/questlua_forked.cpp +++ b/game/src/questlua_forked.cpp @@ -2,7 +2,7 @@ #include "threeway_war.h" -#include "../../common/stl.h" +#include #include "questlua.h" #include "questmanager.h" diff --git a/game/src/questlua_guild.cpp b/game/src/questlua_guild.cpp index c2c5ed3..fb787a8 100644 --- a/game/src/questlua_guild.cpp +++ b/game/src/questlua_guild.cpp @@ -191,7 +191,7 @@ namespace quest TPacketGDGuildWarBet p; p.dwWarID = (DWORD) lua_tonumber(L, 1); - strlcpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); + strncpy(p.szLogin, ch->GetDesc()->GetAccountTable().login, sizeof(p.szLogin)); p.dwGuild = (DWORD) lua_tonumber(L, 2); p.dwGold = (DWORD) lua_tonumber(L, 3); diff --git a/game/src/questlua_monarch.cpp b/game/src/questlua_monarch.cpp index 3d1374e..ea3e551 100644 --- a/game/src/questlua_monarch.cpp +++ b/game/src/questlua_monarch.cpp @@ -706,7 +706,7 @@ namespace quest TPacketGGTransfer pgg; pgg.bHeader = HEADER_GG_TRANSFER; - strlcpy(pgg.szName, name.c_str(), sizeof(pgg.szName)); + strncpy(pgg.szName, name.c_str(), sizeof(pgg.szName)); pgg.lX = ch->GetX(); pgg.lY = ch->GetY(); @@ -793,7 +793,7 @@ namespace quest return 0; char vnum[256]; - strlcpy(vnum, lua_tostring(L, 1), sizeof(vnum)); + strncpy(vnum, lua_tostring(L, 1), sizeof(vnum)); do_monarch_mob(ch, vnum, 0, 0); return 0; } diff --git a/game/src/questmanager.cpp b/game/src/questmanager.cpp index 367a1ee..61dae50 100644 --- a/game/src/questmanager.cpp +++ b/game/src/questmanager.cpp @@ -1155,7 +1155,7 @@ namespace quest void CQuestManager::RequestSetEventFlag(const string& name, int value) { TPacketSetEventFlag p; - strlcpy(p.szFlagName, name.c_str(), sizeof(p.szFlagName)); + strncpy(p.szFlagName, name.c_str(), sizeof(p.szFlagName)); p.lValue = value; db_clientdesc->DBPacket(HEADER_GD_SET_EVENT_FLAG, 0, &p, sizeof(TPacketSetEventFlag)); } diff --git a/game/src/questnpc.cpp b/game/src/questnpc.cpp index 5f5232f..1cd83bf 100644 --- a/game/src/questnpc.cpp +++ b/game/src/questnpc.cpp @@ -61,7 +61,7 @@ namespace quest continue; sys_log(1, "QUEST reading %s", pde->d_name); - strlcpy(buf + is, pde->d_name, sizeof(buf) - is); + strncpy(buf + is, pde->d_name, sizeof(buf) - is); LoadStateScript(event_index, buf, pde->d_name); } diff --git a/game/src/questpc.cpp b/game/src/questpc.cpp index 7379e9e..0be7d4d 100644 --- a/game/src/questpc.cpp +++ b/game/src/questpc.cpp @@ -571,8 +571,8 @@ namespace quest TQuestTable & r = s_table[i++]; r.dwPID = m_dwID; - strlcpy(r.szName, stName.c_str(), sizeof(r.szName)); - strlcpy(r.szState, stState.c_str(), sizeof(r.szState)); + strncpy(r.szName, stName.c_str(), sizeof(r.szName)); + strncpy(r.szState, stState.c_str(), sizeof(r.szState)); r.lValue = lValue; } diff --git a/game/src/sectree_manager.cpp b/game/src/sectree_manager.cpp index 9b7db76..7ef83ac 100644 --- a/game/src/sectree_manager.cpp +++ b/game/src/sectree_manager.cpp @@ -1149,7 +1149,7 @@ void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch) for (it = m_mapNPCPosition[lMapIndex].begin(); it != m_mapNPCPosition[lMapIndex].end(); ++it) { np.bType = it->bType; - strlcpy(np.name, it->name, sizeof(np.name)); + strncpy(np.name, it->name, sizeof(np.name)); np.x = it->x; np.y = it->y; buf.write(&np, sizeof(np)); diff --git a/game/src/skill.cpp b/game/src/skill.cpp index cd05b5a..d799cc4 100644 --- a/game/src/skill.cpp +++ b/game/src/skill.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/stl.h" +#include #include "constants.h" #include "skill.h" @@ -101,7 +101,7 @@ bool CSkillManager::Initialize(TSkillTable * pTab, int iSize) CSkillProto * pkProto = M2_NEW CSkillProto; pkProto->dwVnum = t->dwVnum; - strlcpy(pkProto->szName, t->szName, sizeof(pkProto->szName)); + strncpy(pkProto->szName, t->szName, sizeof(pkProto->szName)); pkProto->dwType = t->bType; pkProto->bMaxLevel = t->bMaxLevel; pkProto->dwFlag = t->dwFlag; diff --git a/game/src/skill_power.cpp b/game/src/skill_power.cpp index 88629fb..96d45f1 100644 --- a/game/src/skill_power.cpp +++ b/game/src/skill_power.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" -#include "../../common/length.h" +#include #include "skill_power.h" diff --git a/game/src/spam.h b/game/src/spam.h index 492ead3..7fd0e89 100644 --- a/game/src/spam.h +++ b/game/src/spam.h @@ -7,7 +7,7 @@ #include #include -#include "../../common/singleton.h" +#include #include "utils.h" class SpamManager : public singleton diff --git a/game/src/stdafx.h b/game/src/stdafx.h index f4322b0..7bb9696 100644 --- a/game/src/stdafx.h +++ b/game/src/stdafx.h @@ -8,9 +8,9 @@ #include "../../libthecore/include/stdafx.h" -#include "../../common/singleton.h" -#include "../../common/utils.h" -#include "../../common/service.h" +#include +#include +#include #include #include diff --git a/game/src/target.cpp b/game/src/target.cpp index 34d71dd..1062242 100644 --- a/game/src/target.cpp +++ b/game/src/target.cpp @@ -23,7 +23,7 @@ pck.bHeader = HEADER_GC_TARGET_CREATE; pck.lID = info->iID; pck.bType = info->iType; pck.dwVID = info->iArg1; -strlcpy(pck.szName, info->szTargetDesc, sizeof(pck.szName)); +strncpy(pck.szName, info->szTargetDesc, sizeof(pck.szName)); d->Packet(&pck, sizeof(TPacketGCTargetCreate)); } @@ -181,7 +181,7 @@ void CTargetManager::CreateTarget(DWORD dwPID, if (c_pszTargetDesc) { - strlcpy(existInfo->szTargetDesc, c_pszTargetDesc, sizeof(existInfo->szTargetDesc)); + strncpy(existInfo->szTargetDesc, c_pszTargetDesc, sizeof(existInfo->szTargetDesc)); } else { @@ -206,7 +206,7 @@ void CTargetManager::CreateTarget(DWORD dwPID, if (c_pszTargetDesc) { - strlcpy(newInfo->szTargetDesc, c_pszTargetDesc, sizeof(newInfo->szTargetDesc)); + strncpy(newInfo->szTargetDesc, c_pszTargetDesc, sizeof(newInfo->szTargetDesc)); } else { @@ -218,7 +218,7 @@ void CTargetManager::CreateTarget(DWORD dwPID, //newInfo->pkChr = pkChr; newInfo->dwPID = dwPID; newInfo->dwQuestIndex = dwQuestIndex; - strlcpy(newInfo->szTargetName, c_pszTargetName, sizeof(newInfo->szTargetName)); + strncpy(newInfo->szTargetName, c_pszTargetName, sizeof(newInfo->szTargetName)); newInfo->iType = iType; newInfo->iArg1 = iArg1; newInfo->iArg2 = iArg2; diff --git a/game/src/text_file_loader.cpp b/game/src/text_file_loader.cpp index 2b7a38b..594cb65 100644 --- a/game/src/text_file_loader.cpp +++ b/game/src/text_file_loader.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "../../common/stl.h" +#include #include "text_file_loader.h" CDynamicPool CTextFileLoader::ms_groupNodePool; diff --git a/game/src/text_file_loader.h b/game/src/text_file_loader.h index 5315f73..a0534a7 100644 --- a/game/src/text_file_loader.h +++ b/game/src/text_file_loader.h @@ -1,8 +1,8 @@ #ifndef __INC_METIN_II_TEXTFILELOADER_H__ #define __INC_METIN_II_TEXTFILELOADER_H__ -#include "../../common/d3dtype.h" -#include "../../common/pool.h" +#include +#include #include "file_loader.h" typedef std::map TTokenVectorMap; diff --git a/game/src/threeway_war.cpp b/game/src/threeway_war.cpp index c8e6fbf..75170cb 100644 --- a/game/src/threeway_war.cpp +++ b/game/src/threeway_war.cpp @@ -2,8 +2,8 @@ #include "threeway_war.h" -#include "../../common/length.h" -#include "../../common/tables.h" +#include +#include #include "p2p.h" #include "locale_service.h" #include "packet.h" diff --git a/game/src/threeway_war.h b/game/src/threeway_war.h index 30f0ada..5b257f1 100644 --- a/game/src/threeway_war.h +++ b/game/src/threeway_war.h @@ -4,7 +4,7 @@ #include -#include "../../common/stl.h" +#include struct ForkedSungziMapInfo { diff --git a/libgame/src/grid.cc b/libgame/src/grid.cc index 5aa238d..82645ec 100644 --- a/libgame/src/grid.cc +++ b/libgame/src/grid.cc @@ -1,7 +1,7 @@ #include #include #include "../../libthecore/include/memcpy.h" -#include "../../common/stl.h" +#include #include "grid.h" CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h) diff --git a/liblua/src/lstring.h b/liblua/src/lstring.h index be5a1e3..5dfc2dc 100644 --- a/liblua/src/lstring.h +++ b/liblua/src/lstring.h @@ -7,6 +7,7 @@ #ifndef lstring_h #define lstring_h +#include #include "lobject.h" #include "lstate.h" diff --git a/libsql/include/libsql.h b/libsql/include/libsql.h index 97130ca..037a31c 100644 --- a/libsql/include/libsql.h +++ b/libsql/include/libsql.h @@ -1 +1 @@ -#include "AsyncSQL.h" +#include "CAsyncSQL.h" diff --git a/libthecore/CMakeLists.txt b/libthecore/CMakeLists.txt index 02fcc52..4e6d6dc 100644 --- a/libthecore/CMakeLists.txt +++ b/libthecore/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 2.8) -project(libthecore C) +project(libthecore CXX) # Find source files file(GLOB SOURCES - "src/*.c" + "src/*.cpp" "include/*.h" ) diff --git a/libthecore/include/fdwatch.h b/libthecore/include/fdwatch.h index f97e0a2..2c09c3e 100644 --- a/libthecore/include/fdwatch.h +++ b/libthecore/include/fdwatch.h @@ -1,41 +1,7 @@ #ifndef __INC_LIBTHECORE_FDWATCH_H__ #define __INC_LIBTHECORE_FDWATCH_H__ -#ifndef __WIN32__ - - typedef struct fdwatch FDWATCH; - typedef struct fdwatch * LPFDWATCH; - - enum EFdwatch - { - FDW_NONE = 0, - FDW_READ = 1, - FDW_WRITE = 2, - FDW_WRITE_ONESHOT = 4, - FDW_EOF = 8, - }; - - typedef struct kevent KEVENT; - typedef struct kevent * LPKEVENT; - typedef int KQUEUE; - - struct fdwatch - { - KQUEUE kq; - - int nfiles; - - LPKEVENT kqevents; - int nkqevents; - - LPKEVENT kqrevents; - int * fd_event_idx; - - void ** fd_data; - int * fd_rw; - }; - -#else +#if defined(WIN32) || defined(__linux__) typedef struct fdwatch FDWATCH; typedef struct fdwatch * LPFDWATCH; @@ -68,6 +34,40 @@ int* fd_rw; }; +#else + +typedef struct fdwatch FDWATCH; +typedef struct fdwatch* LPFDWATCH; + +enum EFdwatch +{ + FDW_NONE = 0, + FDW_READ = 1, + FDW_WRITE = 2, + FDW_WRITE_ONESHOT = 4, + FDW_EOF = 8, +}; + +typedef struct kevent KEVENT; +typedef struct kevent* LPKEVENT; +typedef int KQUEUE; + +struct fdwatch +{ + KQUEUE kq; + + int nfiles; + + LPKEVENT kqevents; + int nkqevents; + + LPKEVENT kqrevents; + int* fd_event_idx; + + void** fd_data; + int* fd_rw; +}; + #endif // WIN32 #ifdef __cplusplus diff --git a/libthecore/include/stdafx.h b/libthecore/include/stdafx.h index f74b2d1..cfce8bc 100644 --- a/libthecore/include/stdafx.h +++ b/libthecore/include/stdafx.h @@ -47,7 +47,7 @@ struct timespec // C runtime library adjustments #define strlcat(dst, src, size) strcat_s(dst, size, src) -#define strlcpy(dst, src, size) strncpy_s(dst, size, src, _TRUNCATE) +#define strncpy(dst, src, size) strncpy_s(dst, size, src, _TRUNCATE) #define strtoull(str, endptr, base) _strtoui64(str, endptr, base) #define strtof(str, endptr) (float)strtod(str, endptr) #define strcasecmp(s1, s2) stricmp(s1, s2) diff --git a/libthecore/src/buffer.c b/libthecore/src/buffer.cpp similarity index 100% rename from libthecore/src/buffer.c rename to libthecore/src/buffer.cpp diff --git a/libthecore/src/des.c b/libthecore/src/des.cpp similarity index 100% rename from libthecore/src/des.c rename to libthecore/src/des.cpp diff --git a/libthecore/src/fdwatch.c b/libthecore/src/fdwatch.cpp similarity index 100% rename from libthecore/src/fdwatch.c rename to libthecore/src/fdwatch.cpp diff --git a/libthecore/src/gost.c b/libthecore/src/gost.cpp similarity index 100% rename from libthecore/src/gost.c rename to libthecore/src/gost.cpp diff --git a/libthecore/src/gost_old.c b/libthecore/src/gost_old.cpp similarity index 100% rename from libthecore/src/gost_old.c rename to libthecore/src/gost_old.cpp diff --git a/libthecore/src/hangul.c b/libthecore/src/hangul.cpp similarity index 100% rename from libthecore/src/hangul.c rename to libthecore/src/hangul.cpp diff --git a/libthecore/src/heart.c b/libthecore/src/heart.cpp similarity index 100% rename from libthecore/src/heart.c rename to libthecore/src/heart.cpp diff --git a/libthecore/src/kstbl.c b/libthecore/src/kstbl.cpp similarity index 100% rename from libthecore/src/kstbl.c rename to libthecore/src/kstbl.cpp diff --git a/libthecore/src/log.c b/libthecore/src/log.cpp similarity index 96% rename from libthecore/src/log.c rename to libthecore/src/log.cpp index 4696898..51485c5 100644 --- a/libthecore/src/log.c +++ b/libthecore/src/log.cpp @@ -113,6 +113,12 @@ void _sys_err(const char *func, int line, const char *format, ...) time_t ct = time(0); char *time_s = asctime(localtime(&ct)); + struct timeval tv; + int nMiliSec = 0; + gettimeofday(&tv, NULL); + + + char buf[1024 + 2]; // \nÀ» ºÙÀ̱â À§ÇØ.. int len; @@ -120,7 +126,7 @@ void _sys_err(const char *func, int line, const char *format, ...) return; time_s[strlen(time_s) - 1] = '\0'; - len = snprintf(buf, 1024, "SYSERR: %-15.15s :: %s: ", time_s + 4, func); + len = snprintf(buf, 1024, "SYSERR: %-15.15s.%d :: %s: ", time_s + 4, tv.tv_usec, func); buf[1025] = '\0'; if (len < 1024) @@ -190,6 +196,10 @@ void sys_log(unsigned int bit, const char *format, ...) { va_list args; + struct timeval tv; + int nMiliSec = 0; + gettimeofday(&tv, NULL); + if (bit != 0 && !(log_level_bits & bit)) return; @@ -201,7 +211,7 @@ void sys_log(unsigned int bit, const char *format, ...) fprintf(log_file_sys->fp, sys_log_header_string); time_s[strlen(time_s) - 1] = '\0'; - fprintf(log_file_sys->fp, "%-15.15s :: ", time_s + 4); + fprintf(log_file_sys->fp, "%-15.15s.%d :: ", time_s + 4, tv.tv_usec ); va_start(args, format); vfprintf(log_file_sys->fp, format, args); diff --git a/libthecore/src/main.c b/libthecore/src/main.cpp similarity index 97% rename from libthecore/src/main.c rename to libthecore/src/main.cpp index 33a2bc6..d5b8990 100644 --- a/libthecore/src/main.c +++ b/libthecore/src/main.cpp @@ -50,7 +50,7 @@ static void pid_deinit(void) int thecore_init(int fps, HEARTFUNC heartbeat_func) { -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__linux__) srand(time(0)); #else srandom(time(0) + getpid() + getuid()); diff --git a/libthecore/src/memcpy.c b/libthecore/src/memcpy.cpp similarity index 100% rename from libthecore/src/memcpy.c rename to libthecore/src/memcpy.cpp diff --git a/libthecore/src/signal.c b/libthecore/src/signal.cpp similarity index 97% rename from libthecore/src/signal.c rename to libthecore/src/signal.cpp index d78d5e6..8acdcef 100644 --- a/libthecore/src/signal.c +++ b/libthecore/src/signal.cpp @@ -7,7 +7,7 @@ #define __LIBTHECORE__ #include "stdafx.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__linux__) void signal_setup() {} void signal_timer_disable() {} void signal_timer_enable(int timeout_seconds) {} diff --git a/libthecore/src/socket.c b/libthecore/src/socket.cpp similarity index 98% rename from libthecore/src/socket.c rename to libthecore/src/socket.cpp index 10c2e89..3c9afae 100644 --- a/libthecore/src/socket.c +++ b/libthecore/src/socket.cpp @@ -157,14 +157,16 @@ int socket_bind(const char * ip, int port, int protocol) } socket_reuse(s); -#ifndef __WIN32__ - socket_lingeroff(s); -#else +#ifndef __linux__ +#if defined(WIN32) // Winsock2: SO_DONTLINGER, SO_KEEPALIVE, SO_LINGER, and SO_OOBINLINE are // not supported on sockets of type SOCK_DGRAM if (protocol == SOCK_STREAM) { socket_lingeroff(s); } +#else + socket_lingeroff(s); +#endif #endif memset(&sa, 0, sizeof(sa)); @@ -183,8 +185,9 @@ int socket_bind(const char * ip, int port, int protocol) sys_err("bind: %s", strerror(errno)); return -1; } - +#ifndef __linux__ socket_nonblock(s); +#endif if (protocol == SOCK_STREAM) { @@ -235,9 +238,10 @@ socket_t socket_accept(socket_t s, struct sockaddr_in *peer) socket_close(s); return -1; } - +#ifndef __linux__ socket_nonblock(desc); socket_lingeroff(desc); +#endif return (desc); } @@ -386,7 +390,7 @@ void socket_dontroute(socket_t s) void socket_lingeroff(socket_t s) { -#ifdef __WIN32__ +#if defined(__WIN32__) int linger; linger = 0; #else @@ -405,7 +409,7 @@ void socket_lingeroff(socket_t s) void socket_lingeron(socket_t s) { -#ifdef __WIN32__ +#if defined(__WIN32__) int linger; linger = 0; #else @@ -487,6 +491,8 @@ void socket_timeout(socket_t s, long sec, long usec) socklen_t optlen = sizeof(rcvopt); sndopt = rcvopt = (sec * 1000) + (usec / 1000); #endif + +#ifndef __linux__ if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const char*) &rcvopt, optlen) < 0) { sys_err("setsockopt: timeout: %s", strerror(errno)); @@ -500,9 +506,10 @@ void socket_timeout(socket_t s, long sec, long usec) socket_close(s); return; } +#endif optlen = sizeof(sndopt); - +#ifndef __linux__ if (setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (const char*) &sndopt, optlen) < 0) { sys_err("setsockopt: timeout: %s", strerror(errno)); @@ -516,6 +523,7 @@ void socket_timeout(socket_t s, long sec, long usec) socket_close(s); return; } +#endif #ifndef __WIN32__ sys_log(1, "SYSTEM: %d: TIMEOUT RCV: %d.%d, SND: %d.%d", s, rcvopt.tv_sec, rcvopt.tv_usec, sndopt.tv_sec, sndopt.tv_usec); diff --git a/libthecore/src/tea.c b/libthecore/src/tea.cpp similarity index 100% rename from libthecore/src/tea.c rename to libthecore/src/tea.cpp diff --git a/libthecore/src/utils.c b/libthecore/src/utils.cpp similarity index 100% rename from libthecore/src/utils.c rename to libthecore/src/utils.cpp diff --git a/libthecore/src/xdirent.c b/libthecore/src/xdirent.cpp similarity index 100% rename from libthecore/src/xdirent.c rename to libthecore/src/xdirent.cpp diff --git a/libthecore/src/xgetopt.c b/libthecore/src/xgetopt.cpp similarity index 100% rename from libthecore/src/xgetopt.c rename to libthecore/src/xgetopt.cpp diff --git a/libthecore/src/xmd5.c b/libthecore/src/xmd5.cpp similarity index 100% rename from libthecore/src/xmd5.c rename to libthecore/src/xmd5.cpp diff --git a/quest/src/qc.cc b/quest/src/qc.cc index c1103c3..5cff0fa 100644 --- a/quest/src/qc.cc +++ b/quest/src/qc.cc @@ -4,9 +4,9 @@ extern "C" { #include #include #include -#include "../../../liblua/src/lzio.h" -#include "../../../liblua/src/llex.h" -#include "../../../liblua/src/lstring.h" +#include +#include +#include #if !defined(_MSC_VER) && defined(__cplusplus) } #endif