📄 mysql.cpp
字号:
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
// SQLTransact(SQL_NULL_HENV, hDBC, SQL_COMMIT);
SQLFreeStmt(hStmt, SQL_DROP);
// return(1); // succeed 饶 窍唱歹~ 0303 KHS
// login_id甫 捞侩窍咯 4疙狼 捞抚阑 佬绢 柯促.
//sprintf(szQuerry, "select name1, name2, name3, name4 from chr_log_info where login_id='%s'", c[cn].id);
/////////////////////////////////////////////////////////////////////////////
sprintf(szQuerry, "EXEC up_get_char_all_name '%s'", c[cn].id);
/////////////////////////////////////////////////////////////////////////////
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
{
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
if( retCode == SQL_NO_DATA ) // 010301 KHS
{
return -30; // ther is NOT id..
}
if(retCode == SQL_SUCCESS )
{
for( int i=0; i<4; i++ )
{
*select_name = 0;
retCode= SQLGetData(hStmt, i+1, SQL_C_CHAR, select_name, sizeof(char[20]), &cbValue) ;
if( retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO )
{
if( !*select_name )
{
SQLFreeStmt(hStmt, SQL_DROP);
sprintf(szQuerry, "UPDATE chr_log_info SET name%d = '%s' WHERE login_id = '%s'" , i+1, ch->Name,c[cn].id );
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
SQLFreeStmt(hStmt, SQL_DROP);
return 1;
}
else return -10;
}
}
else
{
sprintf(szQuerry, "UPDATE chr_log_info SET name%d = '%s' WHERE login_id = '%s'" , i+1, ch->Name,c[cn].id );
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
SQLFreeStmt(hStmt, SQL_DROP);
return 1;
}
else return -10;
}
}
}
}
}
}
// SQLTransact(SQL_NULL_HENV, hDBC, SQL_ROLLBACK);
SQLFreeStmt(hStmt, SQL_DROP);
FILE *fp;
fp = fopen( "QuerryError2.txt","at+" );
if( fp )
{
fprintf( fp, szQuerry );
fclose(fp);
}
// 010301 KHS
// delete_char_create_fail( c, cn );
return -20;
};
// sprintf(szQuerry, "select name from chr_info where login_id='%s'", szUID);
int DeleteChar_SQL2( const char *szID, const char *szName, const char* szSecretKeyCode) // 0302 YGI//020725 lsw
{
HSTMT hStmt = NULL;
RETCODE retCode;
SDWORD cbValue ;
char szQuerry[255];
char log_id[20] = {0, };
char ori_log_id[20];
char select_name[20];
const int len = strlen( szName );
if( len > 20 )
{
MyLog( LOG_NORMAL, "Error!! : Failed Character Deleted Name is Very Long ==> '%s'", szName);
return 0;
}
// login_id甫 茫绊
//sprintf(szQuerry, "select login_id from chr_info where name='%s'", szName);
/////////////////////////////////////////////////////////////////////////////
sprintf(szQuerry, "EXEC up_get_login_id '%s'", szName);
/////////////////////////////////////////////////////////////////////////////
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
if(retCode == SQL_SUCCESS)
{
retCode= SQLGetData(hStmt, 1, SQL_C_CHAR, log_id, 20, &cbValue) ;
}
}
SQLFreeStmt(hStmt, SQL_DROP);
// 010414 KHS
if( !*log_id ) return 0;
strcpy( ori_log_id, szID );
EatRearWhiteChar(ori_log_id); CharUpper( ori_log_id );
EatRearWhiteChar( log_id); CharUpper( log_id );
if( strcmp( log_id, ori_log_id ) )
{
RecvHackingUser( log_id, szName, 20009, " ","Not his Char(Delete)" );
return 0;
}
// login_id甫 捞侩窍咯 4疙狼 捞抚阑 佬绢 柯促.
//sprintf(szQuerry, "select name1, name2, name3, name4 from chr_log_info where login_id='%s'", log_id);
/////////////////////////////////////////////////////////////////////////////
sprintf(szQuerry, "EXEC up_get_char_all_name '%s'", log_id);
/////////////////////////////////////////////////////////////////////////////
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
if(retCode == SQL_SUCCESS)
{
for( int i=0; i<4; i++ )
{
retCode= SQLGetData(hStmt, i+1, SQL_C_CHAR, select_name, sizeof(char[20]), &cbValue) ;
if( retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO )
{
// 010414 KHS
EatRearWhiteChar( select_name );
if( !strcmp( select_name, szName ) ) //捞抚捞 鞍栏骨肺
{
SQLFreeStmt(hStmt, SQL_DROP);//瘤况具 且 仇捞促
if( IsSecretKeyCodeOk(log_id,szSecretKeyCode))
{
sprintf(szQuerry, "UPDATE chr_log_info SET name%d = NULL WHERE login_id = '%s' ", i+1, log_id ); // 鞍篮 捞抚捞 乐阑 版快 瘤款促.
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
//retCode = SQLFetch(hStmt);
SQLFreeStmt(hStmt, SQL_DROP);
return 1;
}
else
{
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return 0;
}
}
else
{//虐内靛啊 撇啡扁 锭巩捞促 虐内靛 眉农 且锭 SQL篮 葛滴 Free沁栏聪 瘤陛 橇府 窍瘤 臼绊 府畔 茄促
return 0;
}
}
}
}
}
}
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return 0;
}
// 瘤快妨绊 窍绰 Character Data逢 颗变促.
int MoveDeleteChar_SQL( const char *szName)//020725 lsw
{
HSTMT hStmt = NULL;
RETCODE retCode;
char szQuerry[255];
DeleteBoxByDeleteCharacter( szName ); // 0817 YGI // 啊瘤绊 乐绰 冠胶甫 瘤款促.
sprintf(szQuerry, "INSERT INTO Deleted_Chr_Info SELECT * FROM chr_info WHERE name='%s'", szName );
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
SQLFreeStmt(hStmt, SQL_DROP);
}
else
{
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return -1;
}
sprintf(szQuerry, "INSERT INTO Deleted_Chr_Info2 SELECT * FROM chr_info2 WHERE name='%s'", szName );
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
SQLFreeStmt(hStmt, SQL_DROP);
return TRUE;
}
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return -1;
}
int DeleteChar_SQL( const char *szID, const char *szName ,const char *szSecretKeyCode)//020725 lsw
{
HSTMT hStmt = NULL;
RETCODE retCode;
char szQuerry[255];
if( !DeleteChar_SQL2( szID, szName, szSecretKeyCode) ) return 0; // 0302 YGI
MoveDeleteChar_SQL( szName );
SubtractFaith( szName ); // 瘤快扁 傈俊 磊扁甫 傈档茄 荤恩狼 脚居缴阑 憋绰促. // YGI 0405
DeleteBoxByDeleteCharacter( szName ); // 0817 YGI // 啊瘤绊 乐绰 冠胶甫 瘤款促.
// 021008 YGI // 辨靛 府胶飘俊 乐绰 某腐磐甫 瘤款促.
ChangeGuildMemberList( (char *)szName, 0, 0 );
// 011214 YGI
sprintf(szQuerry, "DELETE FROM friend_list WHERE name='%s'", szName );
Querry_SQL( szQuerry );
sprintf(szQuerry, "DELETE FROM chr_info WHERE name='%s'", szName );
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
SQLFreeStmt(hStmt, SQL_DROP);
}
else
{
SQLFreeStmt(hStmt, SQL_DROP);
}
sprintf(szQuerry, "DELETE FROM chr_info2 WHERE name='%s'", szName );
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
SQLFreeStmt(hStmt, SQL_DROP);
return TRUE;
}
SQLFreeStmt(hStmt, SQL_DROP);
return -1;
}
/////////////////////////////////////////////////////////////////////////////
//
// 窃荐汲疙: 某腐磐狼 binary(农扁啊 奴硅凯甸篮 binary肺 历厘窍绊 binary肺
// 佬绢柯促)甫 佬绢坷绰 窃荐.
//
// 颇扼固磐: ws; 某腐磐 沥焊吝 WS[200]硅凯狼 **, ps; PS[200]硅凯狼 **
// inv; inv[3][3][8]硅凯狼 **
// equip, quick; 秦寸 硅凯狼 **
// (曼绊: inv, equip, quick篮 ItemAttr Structure狼 硅凯捞促)
//
// 府畔蔼: update狼 己傍 咯何; 己傍(1), 角菩(ret < 0)
//
/////////////////////////////////////////////////////////////////////////////
int get_BinaryData_from_Chr_Info(UCHAR *ws, UCHAR *ps, UCHAR *skill, UCHAR *skill_exp, UCHAR *tac_skillEXP, UCHAR *script_var, UCHAR *inv, UCHAR *equip, UCHAR *quick,
UCHAR *party,
UCHAR *relation,
UCHAR *employment,
UCHAR *itemindex,
char *login_id, char *name)
{
SQLINTEGER cbvalue = SQL_C_BINARY ;
//BYTE tt[ 1152];
SQLRETURN retcode;
SQLHSTMT hstmt;
/* Prepare the SQL statement with parameter markers. */
char query[256]= {0, } ;
//sprintf(query, "SELECT ws, ps, inventory, FROM chr_info where login_id='%s' and name='%s' ",
sprintf(query, "SELECT ws, ps, skill, skill_exp, tac_skillEXP, script_var, inventory, equip, quick, party, relation, employment, itemindex FROM chr_info where name='%s' ", name) ;
//printf("\nSQL: %s", query) ;
SQLAllocStmt(hDBC, &hstmt);
retcode = SQLExecDirect(hstmt, (UCHAR *)query, SQL_NTS);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
retcode = SQLFetch(hstmt);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
retcode= SQLGetData(hstmt, 1, SQL_C_BINARY, ws, SIZE_OF_WS, &cbvalue);
retcode= SQLGetData(hstmt, 2, SQL_C_BINARY, ps, SIZE_OF_PS, &cbvalue);
retcode= SQLGetData(hstmt, 3, SQL_C_BINARY, skill, SIZE_OF_SKILL, &cbvalue);
retcode= SQLGetData(hstmt, 4, SQL_C_BINARY, skill_exp, SIZE_OF_SKILL_EXP, &cbvalue);
retcode= SQLGetData(hstmt, 5, SQL_C_BINARY, tac_skillEXP, SIZE_OF_TAC_SKILL_EXP, &cbvalue);
retcode= SQLGetData(hstmt, 6, SQL_C_BINARY, script_var, SIZE_OF_SCRIPT_VAR, &cbvalue);
retcode= SQLGetData(hstmt, 7, SQL_C_BINARY, inv, SIZE_OF_INV, &cbvalue);
retcode= SQLGetData(hstmt, 8, SQL_C_BINARY, equip, SIZE_OF_EQUIP, &cbvalue);
retcode= SQLGetData(hstmt, 9, SQL_C_BINARY, quick, SIZE_OF_QUICK, &cbvalue);
retcode= SQLGetData(hstmt,10, SQL_C_BINARY, party, SIZE_OF_PARTY, &cbvalue);
retcode= SQLGetData(hstmt,11, SQL_C_BINARY, relation, SIZE_OF_RELATION, &cbvalue);
retcode= SQLGetData(hstmt,12, SQL_C_BINARY, employment, SIZE_OF_EMPLOYMENT, &cbvalue);
retcode= SQLGetData(hstmt,13, SQL_C_BINARY, itemindex, SIZE_OF_ITEMINDEX, &cbvalue);
//<soto-030428
ItemAttr* Quick = (ItemAttr*)quick;
if( Quick[5].item_no > 23 || Quick[5].item_no < 1 || Quick[5].attr[0] > 5 || Quick[5].attr[0] < 1)
{
memset( &(Quick[5]),0,sizeof(ItemAttr));
}
//>soto-030428
}
else
{
//printf("\n Fetch Error") ;
SQLFreeStmt(hstmt, SQL_DROP);
return -1 ;
}
}
else {
//printf("\n ExecDirect Error") ;
SQLFreeStmt(hstmt, SQL_DROP);
return -2 ;
}
if(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
{
// SQLTransact(SQL_NULL_HENV, hDBC, SQL_COMMIT);
SQLFreeStmt(hstmt, SQL_DROP);
return(1); // succeed
}
else
{
displaySQLError(hstmt) ;
// SQLTransact(SQL_NULL_HENV, hDBC, SQL_ROLLBACK);
SQLFreeStmt(hstmt, SQL_DROP);
return(-3); // unknown error
}
}
/////////////////////////////////////////////////////////////////////////////
//
// 窃荐汲疙: 某腐磐狼 binary(农扁啊 奴硅凯甸篮 binary肺 历厘窍绊 binary肺佬绢柯促)甫 佬绢坷绰 窃荐.
//
// ---Bank俊 历厘茄 Item格废阑 啊廉柯促. ---
// 父距 LogIn Server俊辑 Client俊霸 傈价且 鞘夸绝绰 Data扼搁 LogIn Server俊辑绰 龋免且鞘夸 绝促.
//
// 颇扼固磐: ItemAttr bankiem[5][3][6]
// (曼绊: ItemAttr Structure狼 硅凯捞促)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -