📄 chrlog.cpp
字号:
// SQLTransact(SQL_NULL_HENV, hDBC_ChrLogDB, SQL_ROLLBACK);
SQLFreeStmt(hstmt, SQL_DROP);
return(-3);
}
}
else
{
SQLFreeStmt(hstmt, SQL_DROP);
}
return 1;
}
int PushCharData2ChrLogDB( t_chr_log *t )
{
int ret;
ret = PushCharData2ChrLogDB_Basic( t );
//if( ret ) ret = PushCharData2ChrLogDB_Binary( t );
return ret;
}
// ret : Write at ChrLogDB : 1
// Just Buffering : 0
int Recv_ChrLogDB( t_packet *p, int cn )
{
t_chr_log *t;
t_server_chr_log_basic_data *tp;
t_server_chr_log_binary_data0 *tp0;
t_server_chr_log_binary_data1 *tp1;
t_server_chr_log_binary_data2 *tp2;
t_server_chr_log_binary_data3 *tp3;
switch( p->h.header.type )
{
case CMD_CHR_LOG_CHAR_DB : t = new t_chr_log; tp = &p->u.server_chr_log_basic_data; break;
case CMD_CHR_LOG_BINARY_DATA0 : tp0 = &p->u.server_chr_log_binary_data0; t = Find_Chr_Log( tp0->name ); break;
case CMD_CHR_LOG_BINARY_DATA1 : tp1 = &p->u.server_chr_log_binary_data1; t = Find_Chr_Log( tp1->name ); break;
case CMD_CHR_LOG_BINARY_DATA2 : tp2 = &p->u.server_chr_log_binary_data2; t = Find_Chr_Log( tp2->name ); break;
case CMD_CHR_LOG_BINARY_DATA3 : tp3 = &p->u.server_chr_log_binary_data3; t = Find_Chr_Log( tp3->name ); break;
}
if( t == NULL ) return 0;
switch( p->h.header.type )
{
case CMD_CHR_LOG_CHAR_DB :
{
strcpy( t->name, tp->name );
strcpy( t->id, tp->id );
t->state = tp->state;
t->Level = tp->btLevel; // CSD-030806
t->fame_pk = tp->fame_pk; // 010915 LTS //Fame_PK -> NWCharacter肺 背眉 DB俊绰 角力肺 NWCharacter狼 蔼捞 甸绢癌聪促.
t->NWCharacter = t->NWCharacter; // 010915 LTS
t->Str = tp->Str;
t->Con = tp->Con;
t->Dex = tp->Dex;
t->Wis = tp->Wis;
t->Int = tp->Int;
t->MoveP = tp->MoveP;
t->Char = tp->Char;
t->Endu = tp->Endu;
t->Moral = tp->Moral;
t->Luck = tp->Luck;
t->wsps = tp->wsps;
t->Tactics = tp->Tactics;
t->nation = tp->nation;
t->Money = tp->Money;
t->HpMax = tp->HpMax ;
t->ManaMax = tp->ManaMax;
strcpy( t->MapName, tp->MapName );
t->HungryMax = tp->HungryMax;
t->Resis_Poison = tp->Resis_Poison;
t->Resis_Stone = tp->Resis_Stone ;
t->Resis_Magic = tp->Resis_Magic ;
t->Resis_Fire = tp->Resis_Fire ;
t->Resis_Ice = tp->Resis_Ice ;
t->Resis_Elect = tp->Resis_Elect ;
t->X = tp->X;
t->Y = tp->Y;
t->reserved_point = tp->reserved_point;
t->BankMoney = tp->BankMoney;
t->Exp = tp->Exp;
Push_Chr_Log( t );
}
break;
case CMD_CHR_LOG_BINARY_DATA0 :
{
memcpy( t->Skill, tp0->Skill, SIZE_OF_SKILL );
memcpy( t->skillexp,tp0->skillexp, SIZE_OF_SKILL_EXP);
memcpy( t->tac_skillEXP,tp0->tac_skillEXP, SIZE_OF_TAC_SKILL_EXP);
}
break;
case CMD_CHR_LOG_BINARY_DATA1 :
{
memcpy( t->equip, tp1->equip, SIZE_OF_EQUIP);
memcpy( t->quick, tp1->quick, SIZE_OF_QUICK);
}
break;
case CMD_CHR_LOG_BINARY_DATA2 :
{
memcpy( t->inv, tp2->inv, SIZE_OF_INV );
}
break;
case CMD_CHR_LOG_BINARY_DATA3 :
{
memcpy( t->bankitem, tp3->bankitem, SIZE_OF_BANKITEM );
if( PushCharData2ChrLogDB( t ) )
{
MyLog( LOG_NORMAL, "SUCCESS : '%s' Character Logged ( %d )", t->name, t->state );
}
else
{
MyLog( LOG_NORMAL, "'%s' Character Logged ****** FAIL !!! ( %d )", t->name, t->state );
}
Delete_Chr_Log( t );
}
break;
}
return 1;
}
bool IsDefTable(HDBC hDBC, char* pTblName)
{
HSTMT hStmt = NULL;
SQLAllocStmt(hDBC, &hStmt);
// 抛捞喉狼 沥焊 啊廉坷扁
RETCODE retCode = SQLTables(hStmt, NULL, SQL_NTS, NULL, SQL_NTS,
(SQLCHAR*)(pTblName), SQL_NTS, (SQLCHAR*)("'TABLE'"), SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
char szBuffer[256];
SDWORD cbValue;
// 技锅掳 凯狼 蔼牢 抛捞喉疙 磊廉坷扁
SQLBindCol(hStmt, 3, SQL_C_CHAR, szBuffer, sizeof(szBuffer), &cbValue);
if (SQLFetch(hStmt) == SQL_SUCCESS)
{
SQLFreeStmt(hStmt, SQL_DROP);
return true;
}
}
SQLFreeStmt(hStmt, SQL_DROP);
return false;
}
//010822 lsw 辑滚悸 持澜
void InitHackingLog( void )
{
HSTMT hStmt = NULL;
RETCODE retCode;
SQLAllocStmt(hDBC_ChrLogDB, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)
"CREATE TABLE DoubtUser ( \
[id] [char] (20) NULL , \
[name] [char] (20) NULL , \
[server_no] [int] NULL , \
[date] [datetime] NOT NULL , \
[type] [int] NULL , \
[ip] [varchar] (50) NULL , \
[cause] [varchar] (50) NULL \
) ON [PRIMARY]", SQL_NTS);
SQLFreeStmt(hStmt, SQL_DROP);
if(retCode != SQL_SUCCESS && retCode != SQL_SUCCESS_WITH_INFO) goto SUCCESS_;
SQLAllocStmt(hDBC_ChrLogDB, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)
"ALTER TABLE DoubtUser WITH NOCHECK ADD \
CONSTRAINT [DF_DoubtUser_date] DEFAULT (getdate()) FOR [date], \
CONSTRAINT [PK_DoubtUser] PRIMARY KEY NONCLUSTERED \
( \
[date] \
) ON [PRIMARY]", SQL_NTS);
SQLFreeStmt(hStmt, SQL_DROP);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
MyLog( LOG_NORMAL, " 'DoubtUser' Table successfully Created !" );
}
else
{
MyLog( LOG_NORMAL, " 'DoubtUser' Table Checking : *** Error !!" );
return;
}
SUCCESS_:
MyLog( LOG_NORMAL, " 'DoubtUser' Table Checking...OK !" );
}
//020330 lsw
void InitRareItemMakeResultLog( void )
{
HSTMT hStmt = NULL;
RETCODE retCode;
SQLAllocStmt(hDBC_ChrLogDB, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)
"CREATE TABLE ItemLog ( \
[date] [datetime] NOT NULL,\
[ServerSetNo] [int] ,\
[map] [int] ,\
[maker] [char](20) ,\
[itemno] [int] ,\
[today_count] [int] ,\
[grade] [int] ,\
[mutanttype1] [int] ,\
[mutanttype2] [int] ,\
[mutanttype3] [int] ,\
[addeditem1] [int] ,\
[addeditem1limit] [int] ,\
[addeditem2] [int] ,\
[addeditem2limit] [int] ,\
[resultlimit] [int] ,\
[resultnowdur] [int] ,\
[resultmaxdur] [int] ,\
[why] [int] ,\
[why2] [int] ,\
[resource1limit] [int] ,\
[resource2limit] [int] ,\
[resource3limit] [int] ,\
[resource4limit] [int] ,\
[resource5limit] [int] ,\
[resource6limit] [int] \
) ON [PRIMARY]", SQL_NTS);
SQLFreeStmt(hStmt, SQL_DROP);
if(retCode != SQL_SUCCESS && retCode != SQL_SUCCESS_WITH_INFO) goto SUCCESS_;
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
MyLog( LOG_NORMAL, " 'ItemLog' Table successfully Created !" );
}
else
{
MyLog( LOG_NORMAL, " 'ItemLog' Table Checking : *** Error !!" );
return;
}
SUCCESS_:
MyLog( LOG_NORMAL, " 'RareLog' Table Checking...OK !" );
}
//010822 lsw
bool RecvHackingUser( const char *id, const char *name, const int type, const char *ip, const char *cause )
{
HSTMT hStmt = NULL;
RETCODE retCode;
char szQuerry[256];
int len;
int server_no = g_pServerTable->GetServerSetNum();
if( id == NULL ) goto FAIL_;
if( ip == NULL ) goto FAIL_;
if( cause == NULL ) goto FAIL_;
if( strlen(id) <= 0 ) goto FAIL_;
if( strlen(ip) <= 0 ) goto FAIL_;
len = strlen(cause);
if( len <= 0 || len >= 50 ) goto FAIL_;
sprintf(szQuerry,"DELETE DoubtUser where date < ( getdate()-%d )",LocalMgr.GetDoubtUserTableLimitDay());//030102 lsw
Querry_SQL(szQuerry , hDBC_ChrLogDB ); // 021128 YGI
sprintf( szQuerry, "INSERT INTO DoubtUser (id, name, server_no ,type, ip, cause )"
" VALUES ('%s', '%s', '%d','%d', '%s', '%s' )",id, name, server_no,type, ip, cause );
SQLAllocStmt(hDBC_ChrLogDB, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
SQLFreeStmt(hStmt, SQL_DROP);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO) return true;
MyLog( LOG_NORMAL, " *** Error : 'DoubtUser' Insert FAIL !!\n( Name: %s, Type: %d, Server_no: %d, ip: %s, cause: %s )", id, type, server_no , ip, cause );
FAIL_:
return false;
}
//011030 lsw >
bool RecvRareItemMakeLog( t_rare_item_make_log *tp )
{
HSTMT hStmt = NULL;
RETCODE retCode;
char szQuerry[2048];
const int server_no = g_pServerTable->GetServerSetNum();
if( tp->maker == NULL )
{
MyLog( LOG_NORMAL, "Warning!! *** Error:'ItemLog' Charcter Data NULL!!!!! *** " );
goto FAIL_;
}
sprintf( szQuerry, "INSERT INTO ItemLog \
( \
date,ServerSetNo,map,maker,itemno,today_count,grade,mutanttype1,mutanttype2,mutanttype3,\
addeditem1,addeditem1limit,addeditem2,addeditem2limit,resultlimit, \
resultnowdur,resultmaxdur,why,why2,resource1limit,resource2limit, \
resource3limit,resource4limit,resource5limit,resource6limit \
) \
VALUES \
( \
getdate(), '%d', '%d','%s', \
'%d', '%d', '%d', '%d','%d', '%d', \
'%d', '%d', '%d', '%d','%d', \
'%d', '%d', '%d', '%d','%d', \
'%d', '%d', '%d', '%d','%d' \
)"
,
server_no,
tp->map,
tp->maker,
tp->itemno,
tp->today_count,
tp->grade,
tp->mutanttype1,
tp->mutanttype2,
tp->mutanttype3,
tp->addeditem1,
tp->addeditem1limit,
tp->addeditem2,
tp->addeditem2limit,
tp->resultlimit,
tp->resultnowdur,
tp->resultmaxdur,
tp->why,
tp->why2,
tp->resource1limit,
tp->resource2limit,
tp->resource3limit,
tp->resource4limit,
tp->resource5limit,
tp->resource6limit
);
SQLAllocStmt(hDBC_ChrLogDB, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
SQLFreeStmt(hStmt, SQL_DROP);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO) return true;
MyLog( LOG_NORMAL, "Warning!! *** Error:'ItemLog' Data Insert Failed *** " );
FAIL_:
return false;
}
//011030 lsw <
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -