diff --git a/common/tables.h b/common/tables.h index 41a912d..5fe2b64 100644 --- a/common/tables.h +++ b/common/tables.h @@ -352,8 +352,8 @@ typedef struct SPacketDGCreateSuccess typedef struct TPlayerItemAttribute { - BYTE bType; - WORD sValue; + uint8_t bType; + int16_t sValue; } TPlayerItemAttribute; typedef struct SPlayerItem diff --git a/db/src/Cache.cpp b/db/src/Cache.cpp index 8b1aa87..5c6cd54 100644 --- a/db/src/Cache.cpp +++ b/db/src/Cache.cpp @@ -138,7 +138,7 @@ void CItemCache::OnFlush() p->aAttr[6].bType, p->aAttr[6].sValue); } - char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN]; + char szItemQuery[QUERY_MAX_LEN + QUERY_MAX_LEN + 100]; snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues); if (g_test_server) diff --git a/db/src/ClientManager.cpp b/db/src/ClientManager.cpp index 1ff6267..95a83a0 100644 --- a/db/src/ClientManager.cpp +++ b/db/src/ClientManager.cpp @@ -558,7 +558,7 @@ void CClientManager::QUERY_QUEST_SAVE(CPeer * pkPeer, TQuestTable * pTable, DWOR else { snprintf(szQuery, sizeof(szQuery), - "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(%d, '%s', '%s', %ld)", + "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(%d, '%s', '%s', %d)", GetTablePostfix(), pTable->dwPID, pTable->szName, pTable->szState, pTable->lValue); } @@ -1402,7 +1402,7 @@ void CClientManager::QUERY_ITEM_SAVE(CPeer * pkPeer, const char * c_pData) "attrtype4, attrvalue4, " "attrtype5, attrvalue5, " "attrtype6, attrvalue6) " - "VALUES(%u, %u, %d, %d, %u, %u, %ld, %ld, %ld, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)", + "VALUES(%u, %u, %d, %d, %u, %u, %d, %d, %d, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd, %hd)", GetTablePostfix(), p->id, p->owner, diff --git a/db/src/ClientManager.h b/db/src/ClientManager.h index 3d38f9f..251cd2a 100644 --- a/db/src/ClientManager.h +++ b/db/src/ClientManager.h @@ -170,7 +170,7 @@ class CClientManager : public singleton void SendNotice(const char * c_pszFormat, ...); - char* GetCommand(char* str); //µ¶Àϼ±¹°±â´É¿¡¼­ ¸í·É¾î ¾ò´Â ÇÔ¼ö + std::string GetCommand(char* str); //µ¶Àϼ±¹°±â´É¿¡¼­ ¸í·É¾î ¾ò´Â ÇÔ¼ö void ItemAward(CPeer * peer, char* login); //µ¶ÀÏ ¼±¹° ±â´É CPeer * AddPeer(bufferevent* bufev, sockaddr* addr); diff --git a/db/src/ClientManagerEventFlag.cpp b/db/src/ClientManagerEventFlag.cpp index 95df025..d27dc16 100644 --- a/db/src/ClientManagerEventFlag.cpp +++ b/db/src/ClientManagerEventFlag.cpp @@ -50,7 +50,7 @@ void CClientManager::SetEventFlag(TPacketSetEventFlag* p) { char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), - "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(0, '%s', '', %ld)", + "REPLACE INTO quest%s (dwPID, szName, szState, lValue) VALUES(0, '%s', '', %d)", GetTablePostfix(), p->szFlagName, p->lValue); szQuery[1023] = '\0'; diff --git a/db/src/ClientManagerPlayer.cpp b/db/src/ClientManagerPlayer.cpp index edc1919..daf9071 100644 --- a/db/src/ClientManagerPlayer.cpp +++ b/db/src/ClientManagerPlayer.cpp @@ -84,9 +84,9 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p "y = %d, " "z = %d, " "map_index = %d, " - "exit_x = %ld, " - "exit_y = %ld, " - "exit_map_index = %ld, " + "exit_x = %d, " + "exit_y = %d, " + "exit_map_index = %d, " "hp = %d, " "mp = %d, " "stamina = %d, " @@ -110,7 +110,7 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p "part_hair = %d, " "last_play = NOW(), " "skill_group = %d, " - "alignment = %ld, " + "alignment = %d, " "horse_level = %d, " "horse_riding = %d, " "horse_hp = %d, " @@ -417,7 +417,7 @@ void CClientManager::ItemAward(CPeer * peer,char* login) char cmdStr[100] = ""; //whyÄÝ·ë¿¡¼­ ÀÐÀº °ªÀ» Àӽà ¹®ÀÚ¿­¿¡ º¹»çÇØµÒ strcpy(cmdStr,whyStr); //¸í·É¾î ¾ò´Â °úÁ¤¿¡¼­ ÅäÅ«¾²¸é ¿øº»µµ ÅäÅ«È­ µÇ±â ¶§¹® char command[20] = ""; - strcpy(command,GetCommand(cmdStr)); // command ¾ò±â + strcpy(command,GetCommand(cmdStr).c_str()); // command ¾ò±â if( !(strcmp(command,"GIFT") )) // command °¡ GIFTÀ̸é { TPacketItemAwardInfromer giftData; @@ -428,7 +428,7 @@ void CClientManager::ItemAward(CPeer * peer,char* login) } } } -char* CClientManager::GetCommand(char* str) +std::string CClientManager::GetCommand(char* str) { char command[20] = ""; char* tok; @@ -1187,7 +1187,7 @@ void CClientManager::QUERY_ADD_AFFECT(CPeer * peer, TPacketGDAddAffect * p) */ snprintf(queryStr, sizeof(queryStr), "REPLACE INTO affect%s (dwPID, bType, bApplyOn, lApplyValue, dwFlag, lDuration, lSPCost) " - "VALUES(%u, %u, %u, %ld, %u, %ld, %ld)", + "VALUES(%u, %u, %u, %d, %u, %d, %d)", GetTablePostfix(), p->dwPID, p->elem.dwType, diff --git a/db/src/ItemAwardManager.cpp b/db/src/ItemAwardManager.cpp index a258b73..ff163c9 100644 --- a/db/src/ItemAwardManager.cpp +++ b/db/src/ItemAwardManager.cpp @@ -59,7 +59,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg) char cmdStr[100] = ""; //whyÄÝ·ë¿¡¼­ ÀÐÀº °ªÀ» Àӽà ¹®ÀÚ¿­¿¡ º¹»çÇØµÒ strcpy(cmdStr,whyStr); //¸í·É¾î ¾ò´Â °úÁ¤¿¡¼­ ÅäÅ«¾²¸é ¿øº»µµ ÅäÅ«È­ µÇ±â ¶§¹® char command[20] = ""; - strcpy(command,CClientManager::instance().GetCommand(cmdStr)); // command ¾ò±â + strcpy(command,CClientManager::instance().GetCommand(cmdStr).c_str()); // command ¾ò±â //sys_err("%d, %s",pItemAward->dwID,command); if( !(strcmp(command,"GIFT") )) // command °¡ GIFTÀ̸é { diff --git a/db/src/Monarch.cpp b/db/src/Monarch.cpp index 984c5aa..e5a9469 100644 --- a/db/src/Monarch.cpp +++ b/db/src/Monarch.cpp @@ -129,7 +129,7 @@ bool CMonarch::AddMoney(int Empire, int64_t Money) int64_t Money64 = m_MonarchInfo.money[Empire]; char szQuery[1024]; - snprintf(szQuery, sizeof(szQuery), "UPDATE monarch set money=%lld where empire=%d", Money64, Empire); + snprintf(szQuery, sizeof(szQuery), "UPDATE monarch set money=%ld where empire=%d", Money64, Empire); CDBManager::instance().AsyncQuery(szQuery); @@ -145,7 +145,7 @@ bool CMonarch::DecMoney(int Empire, int64_t Money) int64_t Money64 = m_MonarchInfo.money[Empire]; char szQuery[1024]; - snprintf(szQuery, sizeof(szQuery), "UPDATE monarch set money=%lld where empire=%d", Money64, Empire); + snprintf(szQuery, sizeof(szQuery), "UPDATE monarch set money=%ld where empire=%d", Money64, Empire); CDBManager::instance().AsyncQuery(szQuery); return true; @@ -163,7 +163,7 @@ bool CMonarch::TakeMoney(int Empire, DWORD pid, int64_t Money) char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), - "UPDATE monarch set money=%lld; where empire=%d", m_MonarchInfo.money[Empire], Empire); + "UPDATE monarch set money=%ld; where empire=%d", m_MonarchInfo.money[Empire], Empire); CDBManager::instance().AsyncQuery(szQuery); @@ -237,7 +237,7 @@ bool CMonarch::SetMonarch(const char * name) //db¿¡ ÀÔ·Â snprintf(szQuery, sizeof(szQuery), - "REPLACE INTO monarch (empire, name, windate, money) VALUES(%d, %d, now(), %lld)", Empire, p->pid[Empire], p->money[Empire]); + "REPLACE INTO monarch (empire, name, windate, money) VALUES(%d, %d, now(), %ld)", Empire, p->pid[Empire], p->money[Empire]); CDBManager::instance().AsyncQuery(szQuery, SQL_PLAYER); return true; diff --git a/libthecore/src/log.cpp b/libthecore/src/log.cpp index fdaa39d..2ecde97 100644 --- a/libthecore/src/log.cpp +++ b/libthecore/src/log.cpp @@ -185,7 +185,7 @@ void _sys_err(const char *func, int line, const char *format, ...) } #endif -static char sys_log_header_string[33] = { 0, }; +static char sys_log_header_string[33] = ""; void sys_log_header(const char *header) { @@ -316,7 +316,7 @@ void log_file_delete_old(const char *filename) struct stat sb; int num1, num2; char buf[32]; - char system_cmd[64]; + char system_cmd[512]; struct tm new_tm; if (stat(filename, &sb) == -1) @@ -361,7 +361,7 @@ void log_file_delete_old(const char *filename) if (num2 <= num1) { - sprintf(system_cmd, "rm -rf %s/%s", filename, name); + snprintf(system_cmd, sizeof(system_cmd), "rm -rf %s/%s", filename, name); system(system_cmd); sys_log(0, "%s: SYSTEM_CMD: %s", __FUNCTION__, system_cmd); @@ -404,7 +404,7 @@ void log_file_rotate(LPLOGFILE logfile) struct tm curr_tm; time_t time_s; char dir[256]; - char system_cmd[256]; + char system_cmd[512]; time_s = time(0); curr_tm = *localtime(&time_s);