📄 mysql.cpp
字号:
char tempid[ 20+1];
strcpy( tempid, id );
EatRearWhiteChar( tempid); CharUpper( tempid);
if( strcmp( tempid, realid ) ) // Character狼 家蜡拌沥捞 酒聪促..
{
RecvHackingUser( realid, name[i], 20009, " ", "Not His Char" );
tp->name[i][0] = 0;
SQLFreeStmt(hStmt, SQL_DROP);
sprintf(szQuerry, "UPDATE chr_log_info SET name%d = NULL WHERE login_id = '%s' ", i+1, realid ); // 鞍篮 捞抚捞 乐阑 版快 瘤款促.
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
SQLFreeStmt(hStmt, SQL_DROP);
continue;
}
retCode = SQLGetData(hStmt, 2, SQL_C_ULONG, &Level, 0, &cbValue);
retCode = SQLGetData(hStmt, 3, SQL_C_ULONG, &Job, 0, &cbValue);
retCode = SQLGetData(hStmt, 4, SQL_C_ULONG, &Class, 0, &cbValue);
retCode = SQLGetData(hStmt, 5, SQL_C_ULONG, &Gender, 0, &cbValue);
retCode = SQLGetData(hStmt, 6, SQL_C_ULONG, &bodyr, 0, &cbValue);
retCode = SQLGetData(hStmt, 7, SQL_C_ULONG, &bodyg, 0, &cbValue);
retCode = SQLGetData(hStmt, 8, SQL_C_ULONG, &bodyb, 0, &cbValue);
//"clothr,clothg, clothb, money, age, "
retCode = SQLGetData(hStmt, 9, SQL_C_ULONG, &clothr, 0, &cbValue);
retCode = SQLGetData(hStmt,10, SQL_C_ULONG, &clothg, 0, &cbValue);
retCode = SQLGetData(hStmt,11, SQL_C_ULONG, &clothb, 0, &cbValue);
retCode = SQLGetData(hStmt,12, SQL_C_ULONG, &money, 0, &cbValue);
retCode = SQLGetData(hStmt,13, SQL_C_ULONG, &age, 0, &cbValue);
//"acc_equip1, acc_equip2, acc_equip3, acc_equip4 "
retCode = SQLGetData(hStmt,14, SQL_C_ULONG, &acc_equip1, 0, &cbValue );
retCode = SQLGetData(hStmt,15, SQL_C_ULONG, &acc_equip2, 0, &cbValue );
retCode = SQLGetData(hStmt,16, SQL_C_ULONG, &acc_equip3, 0, &cbValue );
retCode = SQLGetData(hStmt,17, SQL_C_ULONG, &acc_equip4, 0, &cbValue );
retCode = SQLGetData(hStmt,18, SQL_C_ULONG, &nation[i], 0, &cbValue );
memcpy(tp->name[i], name[i], NM_LENGTH);
tp->level[i] = Level;
tp->job[i] = Job;
tp->cla[i] = Class;
tp->gender[i] = Gender;
tp->bodyr[i] = bodyr;
tp->bodyg[i] = bodyg;
tp->bodyb[i] = bodyb;
tp->clothr[i] = clothr;
tp->clothg[i] = clothg;
tp->clothb[i] = clothb;
tp->money[i] = money;
tp->age[i] = age;
tp->acc_equip1[i] = acc_equip1;
tp->acc_equip2[i] = acc_equip2;
tp->acc_equip3[i] = acc_equip3;
tp->acc_equip4[i] = acc_equip4;
}
}
else
{
tp->name[i][0] = 0;
}
SQLFreeStmt(hStmt, SQL_DROP);
}
// 啊瘤绊 乐绰 某腐磐狼 沥焊甫 厚背秦辑
// 捞惑茄 版快唱 扁鸥 版快甫 贸府茄促.
tp->nation = 0; // 1027 YGI
for( int j=0; j<4; j++ )
{
if( tp->name[j][0] ) // 捞抚阑 啊瘤绊 乐绰 某腐磐啊
{
CCharRank temp_status;
memcpy( &temp_status, &nation[j], sizeof( DWORD ) );
if( temp_status.nation == 0 ) // 某腐磐吝 茄疙捞扼档 惫啊 0阑 啊瘤绊 乐栏搁 唱扼 急琶 促矫
{
tp->nation = 0;
break;
}
if( tp->nation && ( tp->nation != temp_status.nation ) ) // 某腐磐吝 辑肺 促弗 唱扼甫 啊瘤绊 乐促搁 // 1028 YGI
{
tp->nation = 0;
break;
}
tp->nation = temp_status.nation;
}
}
return 1;
};
int GetCharactersBasicInfoInID_SQL( LPSTR id, t_packet *packet )
{
char name[ 4][ NM_LENGTH]={{0,},};
if( GetCharacterNameInID( id, name ) == 1 )
{
GetCharInfo_SQL2( id, name, packet);
}
return 1;
}
int GetCharInfo_SQL(LPSTR szUID, t_packet *packet)
{
HSTMT hStmt = NULL;
RETCODE retCode;
SDWORD cbValue;
char szQuerry[255];
int Num;
char Name[ID_LENGTH];
int Level, Job, Class, Gender;
int bodyr, bodyg, bodyb, clothr, clothg, clothb;
DWORD money;
int age;
int acc_equip1, acc_equip2, acc_equip3, acc_equip4;
t_server_accept_login *tp;
tp = &packet->u.server_accept_login;
Num = 0;
//sprintf(szQuerry, "select name, lev, job, class, gender, bodyr, bodyg, bodyb, "
// "clothr,clothg, clothb, money, age, "
// "acc_equip1, acc_equip2, acc_equip3, acc_equip4 "
// " from chr_info where login_id='%s'", szUID);
/////////////////////////////////////////////////////////////////////////////
sprintf(szQuerry, "EXEC up_get_char_info '%s'", szUID);
/////////////////////////////////////////////////////////////////////////////
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
retCode = SQLFetch(hStmt);
while(retCode == SQL_SUCCESS)
{
//"select name, lev, job, class, gender, bodyr, bodyg, bodyb, "
retCode = SQLGetData(hStmt, 1, SQL_C_CHAR, Name, ID_LENGTH, &cbValue);
retCode = SQLGetData(hStmt, 2, SQL_C_ULONG, &Level, 0, &cbValue);
retCode = SQLGetData(hStmt, 3, SQL_C_ULONG, &Job, 0, &cbValue);
retCode = SQLGetData(hStmt, 4, SQL_C_ULONG, &Class, 0, &cbValue);
retCode = SQLGetData(hStmt, 5, SQL_C_ULONG, &Gender, 0, &cbValue);
retCode = SQLGetData(hStmt, 6, SQL_C_ULONG, &bodyr, 0, &cbValue);
retCode = SQLGetData(hStmt, 7, SQL_C_ULONG, &bodyg, 0, &cbValue);
retCode = SQLGetData(hStmt, 8, SQL_C_ULONG, &bodyb, 0, &cbValue);
//"clothr,clothg, clothb, money, age, "
retCode = SQLGetData(hStmt, 9, SQL_C_ULONG, &clothr, 0, &cbValue);
retCode = SQLGetData(hStmt,10, SQL_C_ULONG, &clothg, 0, &cbValue);
retCode = SQLGetData(hStmt,11, SQL_C_ULONG, &clothb, 0, &cbValue);
retCode = SQLGetData(hStmt,12, SQL_C_ULONG, &money, 0, &cbValue);
retCode = SQLGetData(hStmt,13, SQL_C_ULONG, &age, 0, &cbValue);
//"acc_equip1, acc_equip2, acc_equip3, acc_equip4 "
retCode = SQLGetData(hStmt,14, SQL_C_ULONG, &acc_equip1, 0, &cbValue );
retCode = SQLGetData(hStmt,15, SQL_C_ULONG, &acc_equip2, 0, &cbValue );
retCode = SQLGetData(hStmt,16, SQL_C_ULONG, &acc_equip3, 0, &cbValue );
retCode = SQLGetData(hStmt,17, SQL_C_ULONG, &acc_equip4, 0, &cbValue );
//name, lev, job, class, gender, bodyr, bodyg, bodyb, clothr, clothg, clothb, money, age
memcpy( &tp->name[Num][0], Name, ID_LENGTH);
tp->level[Num] = Level;
tp->job[Num] = Job;
tp->cla[Num] = Class;
tp->gender[Num] = Gender;
tp->bodyr[Num] = bodyr;
tp->bodyg[Num] = bodyg;
tp->bodyb[Num] = bodyb;
tp->clothr[Num] = clothr;
tp->clothg[Num] = clothg;
tp->clothb[Num] = clothb;
tp->money[Num] = money;
tp->age[Num] = age;
tp->acc_equip1[Num] = acc_equip1;
tp->acc_equip2[Num] = acc_equip2;
tp->acc_equip3[Num] = acc_equip3;
tp->acc_equip4[Num] = acc_equip4;
Num ++;
if(Num >= MAX_CHARACTEROFID )
break;
retCode = SQLFetch(hStmt);
}
SQLFreeStmt(hStmt, SQL_DROP);
return(1);
}
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return(-1);
};
#define READSQL( a, b, c ) retCode = SQLGetData(hStmt, a, b, &c, 0, &cbValue);
#define SET_LIMIT( a, b, c ) { if( (a) > (c) ) (a) = (c); if( (a) < (b) ) (a) = (b); }
int GetCharDB_SQL(t_connection c[], int cn)
{
HSTMT hStmt = NULL;
RETCODE retCode;
SDWORD cbValue;
char szQuerry[2048];
int t;
char exp[ 12], money[12];
CHARLIST *ch = &c[cn].chrlst;
sprintf(szQuerry,
"Select lev, exp, "
"gender, face, spritvalue, class, spell, "
"str, con, dex, wis, int, movep, char, endu, moral, "
"money, hp, hpmax, mana, manamax, hungry, hungrymax, condition, "
"sprno, x, y, mapname, sight, "
"bodyr, bodyg, bodyb, clothr, clothg, clothb, "
"Age, luck, wsps, nation, "
"acc_equip1, acc_equip2, acc_equip3, acc_equip4, bAlive, "
"openhouse, disease1, disease2, disease3, disease4, disease5, disease6, total_id, "
"resist_poison, resist_stone, resist_magic, resist_fire, resist_ice, resist_elect, viewtype, job, "
"social_status, fame, fame_pk, guildname "
"From chr_info Where name='%s'", c[cn].name );
//sprintf(szQuerry, "EXEC up_get_char_db '%s'", c[cn].name);
strcpy( ch->Name, c[cn].name );
EatRearWhiteChar( ch->Name );
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)
{
// "Select lev, exp "
retCode = SQLGetData(hStmt, 1, SQL_C_ULONG, &t, 0, &cbValue); ch->Level = (short )t;
retCode = SQLGetData(hStmt, 2, SQL_C_CHAR, exp, 11, &cbValue); ch->Exp = (DWORD ) atof( exp );
// "gender, face, spritvalue, class, spell, "
retCode = SQLGetData(hStmt, 3, SQL_C_ULONG, &t, 0, &cbValue); ch->Gender = (short )t;
retCode = SQLGetData(hStmt, 4, SQL_C_ULONG, &t, 0, &cbValue); ch->Face = (short )t;
retCode = SQLGetData(hStmt, 5, SQL_C_ULONG, &t, 0, &cbValue); ch->nGuildCode = (short )t; // CSD-030324
retCode = SQLGetData(hStmt, 6, SQL_C_ULONG, &t, 0, &cbValue); ch->Class = (short )t;
retCode = SQLGetData(hStmt, 7, SQL_C_ULONG, &t, 0, &cbValue); ch->Spell = (short )t;
// "str, con, dex, wis, int, movep, char, endu, moral, "
retCode = SQLGetData(hStmt, 8, SQL_C_ULONG, &t, 0, &cbValue); ch->Str = (short )t; //SET_LIMIT( ch->Str, 0, 100 );
retCode = SQLGetData(hStmt, 9, SQL_C_ULONG, &t, 0, &cbValue); ch->Con = (short )t; //SET_LIMIT( ch->Con, 0, 100 );
retCode = SQLGetData(hStmt, 10, SQL_C_ULONG, &t, 0, &cbValue); ch->Dex = (short )t; //SET_LIMIT( ch->Dex, 0, 100 );
retCode = SQLGetData(hStmt, 11, SQL_C_ULONG, &t, 0, &cbValue); ch->Wis = (short )t; //SET_LIMIT( ch->Wis, 0, 100 );
retCode = SQLGetData(hStmt, 12, SQL_C_ULONG, &t, 0, &cbValue); ch->Int = (short )t; //SET_LIMIT( ch->Int, 0, 100 );
retCode = SQLGetData(hStmt, 13, SQL_C_ULONG, &t, 0, &cbValue); ch->MoveP = (short )t; //SET_LIMIT( ch->MoveP, 0, 100 );
retCode = SQLGetData(hStmt, 14, SQL_C_ULONG, &t, 0, &cbValue); ch->Char = (short )t; //SET_LIMIT( ch->Char, 0, 100 );
retCode = SQLGetData(hStmt, 15, SQL_C_ULONG, &t, 0, &cbValue); ch->Endu = (short )t; //SET_LIMIT( ch->Endu, 0, 100 );
retCode = SQLGetData(hStmt, 16, SQL_C_ULONG, &t, 0, &cbValue); ch->Moral = (short )t; //SET_LIMIT( ch->Moral, 0, 100 );
// "money, hp, hpmax, mana, manamax, hungry, hungrymax, condition, "
//< CSD-011012
retCode = SQLGetData(hStmt, 17, SQL_C_CHAR, money, 11, &cbValue); ch->Money = (DWORD ) atof( money );
retCode = SQLGetData(hStmt, 18, SQL_C_LONG, &t, 0, &cbValue); ch->Hp = t;
retCode = SQLGetData(hStmt, 19, SQL_C_ULONG, &t, 0, &cbValue); ch->HpMax = t; SET_LIMIT(ch->Hp, 0, ch->HpMax);
retCode = SQLGetData(hStmt, 20, SQL_C_ULONG, &t, 0, &cbValue); ch->Mana = t;
retCode = SQLGetData(hStmt, 21, SQL_C_ULONG, &t, 0, &cbValue); ch->ManaMax = t; SET_LIMIT(ch->Mana, 0, ch->ManaMax);
retCode = SQLGetData(hStmt, 22, SQL_C_ULONG, &t, 0, &cbValue); ch->Hungry = t;
retCode = SQLGetData(hStmt, 23, SQL_C_ULONG, &t, 0, &cbValue); ch->HungryMax = t; SET_LIMIT(ch->Hungry, 0, ch->HungryMax);
//> CSD-011012
retCode = SQLGetData(hStmt, 24, SQL_C_ULONG, &t, 0, &cbValue); ch->Condition = (BYTE )t;
if( ch->Condition == CON_DEATH ) //0206 YGI
{
}
else ch->Condition = CON_NORMAL; // 磷篮惑怕啊 酒聪扼搁 扁夯利栏肺 '芭固临'鞍篮 惑怕绰 绝矩促...
// "sprno, x, y, mapname, peacests, sight, "
retCode = SQLGetData(hStmt, 25, SQL_C_ULONG, &t , 0, &cbValue); ch->SprNo = (short )t;
retCode = SQLGetData(hStmt, 26, SQL_C_ULONG, &t , 0, &cbValue); ch->X = (short )t;
retCode = SQLGetData(hStmt, 27, SQL_C_ULONG, &t , 0, &cbValue); ch->Y = (short )t;
retCode = SQLGetData(hStmt, 28, SQL_C_CHAR, ch->MapName , 20, &cbValue);
retCode = SQLGetData(hStmt, 29, SQL_C_ULONG, &t, 0, &cbValue); ch->Sight = t;
// "bodyr, bodyg, bodyb, clothr, clothg, clothb, "
retCode = SQLGetData(hStmt, 30, SQL_C_ULONG, &t, 0, &cbValue); ch->BodyR = (short )t;
retCode = SQLGetData(hStmt, 31, SQL_C_ULONG, &t, 0, &cbValue); ch->BodyG = (short )t;
retCode = SQLGetData(hStmt, 32, SQL_C_ULONG, &t, 0, &cbValue); ch->BodyB = (short )t;
retCode = SQLGetData(hStmt, 33, SQL_C_ULONG, &t, 0, &cbValue); ch->ClothR = (short )t;
retCode = SQLGetData(hStmt, 34, SQL_C_ULONG, &t, 0, &cbValue); ch->ClothG = (short )t;
retCode = SQLGetData(hStmt, 35, SQL_C_ULONG, &t, 0, &cbValue); ch->ClothB = (short )t;
// "Age, luck, wsps, nation, "
retCode = SQLGetData(hStmt, 36, SQL_C_ULONG, &t, 0, &cbValue); ch->Age = (short )t;
retCode = SQLGetData(hStmt, 37, SQL_C_ULONG, &t, 0, &cbValue); ch->Luck = (short )t; //SET_LIMIT( ch->Luck, 0, 100 );
retCode = SQLGetData(hStmt, 38, SQL_C_ULONG, &t, 0, &cbValue); ch->wsps = (short )t; //SET_LIMIT( ch->wsps, 0, 100 );
retCode = SQLGetData(hStmt, 39, SQL_C_ULONG, &t, 0, &cbValue); memcpy( &ch->name_status, &t, sizeof( DWORD ) ); // 1004 YGI
// "acc_equip1, acc_equip2, acc_equip3, acc_equip4, bAlive "
retCode = SQLGetData(hStmt, 40, SQL_C_ULONG, &t, 0, &cbValue); ch->accessory[0] = (unsigned char )t;
retCode = SQLGetData(hStmt, 41, SQL_C_ULONG, &t, 0, &cbValue); ch->accessory[1] = (unsigned char )t;
retCode = SQLGetData(hStmt, 42, SQL_C_ULONG, &t, 0, &cbValue); ch->accessory[2] = (unsigned char )t;
retCode = SQLGetData(hStmt, 43, SQL_C_ULONG, &t, 0, &cbValue); ch->accessory[3] = (unsigned char )t;
retCode = SQLGetData(hStmt, 44, SQL_C_ULONG, &t, 0, &cbValue); ch->bAlive = (unsigned char )t;
//"openhouse, disease1, disease2, disease3, di5ease4, disease5, disease6 ",
retCode = SQLGetData(hStmt, 45, SQL_C_ULONG, &t, 0, &cbValue); ch->openhouse = (short )t;
retCode = SQLGetData(hStmt, 46, SQL_C_ULONG, &t, 0, &cbValue); ch->disease[0] = (char )t;
retCode = SQLGetData(hStmt, 47, SQL_C_ULONG, &t, 0, &cbValue); ch->disease[1] = (char )t;
retCode = SQLGetData(hStmt, 48, SQL_C_ULONG, &t, 0, &cbValue); ch->disease[2] = (char )t;
retCode = SQLGetData(hStmt, 49, SQL_C_ULONG, &t, 0, &cbValue); ch->disease[3] = (char )t;
retCode = SQLGetData(hStmt, 50, SQL_C_ULONG, &t, 0, &cbValue); ch->disease[4] = (char )t;
retCode = SQLGetData(hStmt, 51, SQL_C_ULONG, &t, 0, &cbValue); ch->disease[5] = (char )t;
retCode = SQLGetData(hStmt, 52, SQL_C_ULONG, &t, 0, &cbValue); ch->total_id = t;
// "resis_poison, resis_stone, resis_magic, resis_fire, resis_ice, resis_elect "
retCode = SQLGetData(hStmt, 53, SQL_C_ULONG, &t, 0, &cbValue); ch->nPoison = t;
retCode = SQLGetData(hStmt, 54, SQL_C_ULONG, &t, 0, &cbValue); ch->nCurse = t;
retCode = SQLGetData(hStmt, 55, SQL_C_ULONG, &t, 0, &cbValue); ch->nHoly = t;
retCode = SQLGetData(hStmt, 56, SQL_C_ULONG, &t, 0, &cbValue); ch->nFire = t;
retCode = SQLGetData(hStmt, 57, SQL_C_ULONG, &t, 0, &cbValue); ch->nIce = t;
retCode = SQLGetData(hStmt, 58, SQL_C_ULONG, &t, 0, &cbValue); ch->nElect = t;
retCode = SQLGetData(hStmt, 59, SQL_C_ULONG, &t, 0, &cbValue); ch->viewtype = (char )t;
retCode = SQLGetData(hStmt, 60, SQL_C_ULONG, &t, 0, &cbValue); ch->Job = (short int )t; // 0212 YGI
// "social_status, fame, fame_pk"
retCode = SQLGetData(hStmt, 61, SQL_C_ULONG, &t, 0, &cbValue); ch->social_status = (short )t; //
retCode = SQLGetData(hStmt, 62, SQL_C_ULONG, &t, 0, &cbValue); ch->fame = (short )t;
retCode = SQLGetData(hStmt, 63, SQL_C_LONG, &t, 0, &cbValue); memcpy(&ch->NWCharacter,&t,sizeof(DWORD)); // 010915 LTS
//< CSD-010927
retCode = SQLGetData(hStmt, 64, SQL_C_CHAR, ch->aStepInfo , 20, &cbValue);
ConvertLoad(ch->aStepInfo);
//> CSD-010927
SQLFreeStmt(hStmt, SQL_DROP);
return(1);
}
else
{
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return(-2);
}
}
else
{
SQLFreeStmt(hStmt, SQL_DROP); // 0308 YGI
return(-1);
}
};
// 困狼 GetCharDB_SQL()绰 Login Server俊辑档 荤侩登绰 窃荐肺 Client肺 扁夯沥焊甫 焊郴绰 格利阑 林肺 窍绊
// 捞锅 GetCharGameDB_SQL()绰 霸烙 Server俊辑父 荤侩登绰 函荐甫 佬扁困茄巴捞促.
// GameServer俊辑父 捞窃荐甫 荤侩茄促.
int GetCharGameDB_SQL(t_connection c[], int cn)
{
HSTMT hStmt = NULL;
RETCODE retCode;
SDWORD cbValue;
char szQuerry[2048];
DWORD t;
char money[12];
CHARLIST *ch = &c[cn].chrlst;
// 010406 YGI
//sprintf(szQuerry, "Select bankmoney, LastLoan, "
// "nut1, nut2, nut3, killmon, killanimal, killpc, "
// "reserved_point, "
// "tactics, "
// "win_defeat, LadderScore "
// "From chr_info Where name='%s'", c[cn].name );
/////////////////////////////////////////////////////////////////////////////
sprintf(szQuerry, "EXEC up_get_char_game_db '%s'", c[cn].name);
/////////////////////////////////////////////////////////////////////////////
SQLAllocStmt(hDBC, &hStmt);
retCode = SQLExecDirect(hStmt, (UCHAR *)szQuerry, SQL_NTS);
if(retCode == SQL_SUCCESS || retCode == SQL_SUCCESS_WITH_INFO)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -