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
|
typedef struct TPlayerItemAttribute
|
||||||
{
|
{
|
||||||
BYTE bType;
|
uint8_t bType;
|
||||||
WORD sValue;
|
int16_t sValue;
|
||||||
} TPlayerItemAttribute;
|
} TPlayerItemAttribute;
|
||||||
|
|
||||||
typedef struct SPlayerItem
|
typedef struct SPlayerItem
|
||||||
|
|
|
@ -138,7 +138,7 @@ void CItemCache::OnFlush()
|
||||||
p->aAttr[6].bType, p->aAttr[6].sValue);
|
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);
|
snprintf(szItemQuery, sizeof(szItemQuery), "REPLACE INTO item%s (%s) VALUES(%s)", GetTablePostfix(), szColumns, szValues);
|
||||||
|
|
||||||
if (g_test_server)
|
if (g_test_server)
|
||||||
|
|
|
@ -558,7 +558,7 @@ void CClientManager::QUERY_QUEST_SAVE(CPeer * pkPeer, TQuestTable * pTable, DWOR
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
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);
|
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, "
|
"attrtype4, attrvalue4, "
|
||||||
"attrtype5, attrvalue5, "
|
"attrtype5, attrvalue5, "
|
||||||
"attrtype6, attrvalue6) "
|
"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(),
|
GetTablePostfix(),
|
||||||
p->id,
|
p->id,
|
||||||
p->owner,
|
p->owner,
|
||||||
|
|
|
@ -170,7 +170,7 @@ class CClientManager : public singleton<CClientManager>
|
||||||
|
|
||||||
void SendNotice(const char * c_pszFormat, ...);
|
void SendNotice(const char * c_pszFormat, ...);
|
||||||
|
|
||||||
char* GetCommand(char* str); //독일선물기능에서 명령어 얻는 함수
|
std::string GetCommand(char* str); //독일선물기능에서 명령어 얻는 함수
|
||||||
void ItemAward(CPeer * peer, char* login); //독일 선물 기능
|
void ItemAward(CPeer * peer, char* login); //독일 선물 기능
|
||||||
|
|
||||||
CPeer * AddPeer(bufferevent* bufev, sockaddr* addr);
|
CPeer * AddPeer(bufferevent* bufev, sockaddr* addr);
|
||||||
|
|
|
@ -50,7 +50,7 @@ void CClientManager::SetEventFlag(TPacketSetEventFlag* p)
|
||||||
{
|
{
|
||||||
char szQuery[1024];
|
char szQuery[1024];
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
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);
|
GetTablePostfix(), p->szFlagName, p->lValue);
|
||||||
szQuery[1023] = '\0';
|
szQuery[1023] = '\0';
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||||
"y = %d, "
|
"y = %d, "
|
||||||
"z = %d, "
|
"z = %d, "
|
||||||
"map_index = %d, "
|
"map_index = %d, "
|
||||||
"exit_x = %ld, "
|
"exit_x = %d, "
|
||||||
"exit_y = %ld, "
|
"exit_y = %d, "
|
||||||
"exit_map_index = %ld, "
|
"exit_map_index = %d, "
|
||||||
"hp = %d, "
|
"hp = %d, "
|
||||||
"mp = %d, "
|
"mp = %d, "
|
||||||
"stamina = %d, "
|
"stamina = %d, "
|
||||||
|
@ -110,7 +110,7 @@ size_t CreatePlayerSaveQuery(char * pszQuery, size_t querySize, TPlayerTable * p
|
||||||
"part_hair = %d, "
|
"part_hair = %d, "
|
||||||
"last_play = NOW(), "
|
"last_play = NOW(), "
|
||||||
"skill_group = %d, "
|
"skill_group = %d, "
|
||||||
"alignment = %ld, "
|
"alignment = %d, "
|
||||||
"horse_level = %d, "
|
"horse_level = %d, "
|
||||||
"horse_riding = %d, "
|
"horse_riding = %d, "
|
||||||
"horse_hp = %d, "
|
"horse_hp = %d, "
|
||||||
|
@ -417,7 +417,7 @@ void CClientManager::ItemAward(CPeer * peer,char* login)
|
||||||
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
|
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
|
||||||
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
|
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
|
||||||
char command[20] = "";
|
char command[20] = "";
|
||||||
strcpy(command,GetCommand(cmdStr)); // command ¾ò±â
|
strcpy(command,GetCommand(cmdStr).c_str()); // command ¾ò±â
|
||||||
if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면
|
if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면
|
||||||
{
|
{
|
||||||
TPacketItemAwardInfromer giftData;
|
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 command[20] = "";
|
||||||
char* tok;
|
char* tok;
|
||||||
|
@ -1187,7 +1187,7 @@ void CClientManager::QUERY_ADD_AFFECT(CPeer * peer, TPacketGDAddAffect * p)
|
||||||
*/
|
*/
|
||||||
snprintf(queryStr, sizeof(queryStr),
|
snprintf(queryStr, sizeof(queryStr),
|
||||||
"REPLACE INTO affect%s (dwPID, bType, bApplyOn, lApplyValue, dwFlag, lDuration, lSPCost) "
|
"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(),
|
GetTablePostfix(),
|
||||||
p->dwPID,
|
p->dwPID,
|
||||||
p->elem.dwType,
|
p->elem.dwType,
|
||||||
|
|
|
@ -59,7 +59,7 @@ void ItemAwardManager::Load(SQLMsg * pMsg)
|
||||||
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
|
char cmdStr[100] = ""; //why콜룸에서 읽은 값을 임시 문자열에 복사해둠
|
||||||
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
|
strcpy(cmdStr,whyStr); //명령어 얻는 과정에서 토큰쓰면 원본도 토큰화 되기 때문
|
||||||
char command[20] = "";
|
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);
|
//sys_err("%d, %s",pItemAward->dwID,command);
|
||||||
if( !(strcmp(command,"GIFT") )) // command 가 GIFT이면
|
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];
|
int64_t Money64 = m_MonarchInfo.money[Empire];
|
||||||
|
|
||||||
char szQuery[1024];
|
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);
|
CDBManager::instance().AsyncQuery(szQuery);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ bool CMonarch::DecMoney(int Empire, int64_t Money)
|
||||||
int64_t Money64 = m_MonarchInfo.money[Empire];
|
int64_t Money64 = m_MonarchInfo.money[Empire];
|
||||||
|
|
||||||
char szQuery[1024];
|
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);
|
CDBManager::instance().AsyncQuery(szQuery);
|
||||||
return true;
|
return true;
|
||||||
|
@ -163,7 +163,7 @@ bool CMonarch::TakeMoney(int Empire, DWORD pid, int64_t Money)
|
||||||
|
|
||||||
char szQuery[1024];
|
char szQuery[1024];
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
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);
|
CDBManager::instance().AsyncQuery(szQuery);
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ bool CMonarch::SetMonarch(const char * name)
|
||||||
|
|
||||||
//db¿¡ ÀÔ·Â
|
//db¿¡ ÀÔ·Â
|
||||||
snprintf(szQuery, sizeof(szQuery),
|
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);
|
CDBManager::instance().AsyncQuery(szQuery, SQL_PLAYER);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -185,7 +185,7 @@ void _sys_err(const char *func, int line, const char *format, ...)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static char sys_log_header_string[33] = { 0, };
|
static char sys_log_header_string[33] = "";
|
||||||
|
|
||||||
void sys_log_header(const char *header)
|
void sys_log_header(const char *header)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +316,7 @@ void log_file_delete_old(const char *filename)
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int num1, num2;
|
int num1, num2;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
char system_cmd[64];
|
char system_cmd[512];
|
||||||
struct tm new_tm;
|
struct tm new_tm;
|
||||||
|
|
||||||
if (stat(filename, &sb) == -1)
|
if (stat(filename, &sb) == -1)
|
||||||
|
@ -361,7 +361,7 @@ void log_file_delete_old(const char *filename)
|
||||||
|
|
||||||
if (num2 <= num1)
|
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);
|
system(system_cmd);
|
||||||
|
|
||||||
sys_log(0, "%s: SYSTEM_CMD: %s", __FUNCTION__, 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;
|
struct tm curr_tm;
|
||||||
time_t time_s;
|
time_t time_s;
|
||||||
char dir[256];
|
char dir[256];
|
||||||
char system_cmd[256];
|
char system_cmd[512];
|
||||||
|
|
||||||
time_s = time(0);
|
time_s = time(0);
|
||||||
curr_tm = *localtime(&time_s);
|
curr_tm = *localtime(&time_s);
|
||||||
|
|
Loading…
Reference in New Issue