forked from metin2/server
Fixed various datatype and buffer issues
This commit is contained in:
parent
71189e7c08
commit
7c821325c7
|
@ -352,8 +352,8 @@ typedef struct SPacketDGCreateSuccess
|
|||
|
||||
typedef struct TPlayerItemAttribute
|
||||
{
|
||||
BYTE bType;
|
||||
WORD sValue;
|
||||
uint8_t bType;
|
||||
int16_t sValue;
|
||||
} TPlayerItemAttribute;
|
||||
|
||||
typedef struct SPlayerItem
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -170,7 +170,7 @@ class CClientManager : public singleton<CClientManager>
|
|||
|
||||
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);
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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이면
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue