本文整理汇总了C++中Connection::GetHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ Connection::GetHandle方法的具体用法?C++ Connection::GetHandle怎么用?C++ Connection::GetHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::GetHandle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DropGift
int ShopSvc::DropGift(UInt32 roleID,UInt32 num)
{
char szSql[1024];
Connection con;
DBOperate dbo;
Int16 iRet = 0;
UInt32 Gift=0;
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
sprintf(szSql, "select Gift from RoleMoney where RoleID=%d",roleID);
iRet=dbo.QuerySQL(szSql);
if(iRet==0)
{
while(dbo.HasRowData())
{
Gift=dbo.GetIntField(0);
dbo.NextRow();
}
}
else
{
//ch
LOG(LOG_ERROR,__FILE__,__LINE__,"szSql[%s] ", mysql_error(con.GetHandle()), szSql);
return -1;
}
if(Gift>num)
{
sprintf(szSql, "Update RoleMoney set Gift=Gift-%d where RoleID=%d",num,roleID);
iRet=dbo.ExceSQL(szSql);
if(iRet!=0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"szSql[%s] ", mysql_error(con.GetHandle()), szSql);
return -1;
}
}
else
{
//没有足够多的礼券
LOG(LOG_ERROR,__FILE__,__LINE__," Not so many Gift");
return 1;
}
if(Gift>num)
{
Gift=Gift-num;
NotifyGift(roleID,Gift);
//S-C礼券
}
return 0;
}
示例2: UpdateDBspecialItem
int ShopSvc::UpdateDBspecialItem(UInt32 ItemID,UInt32 num)
{
UInt32 RetCode = 0;
char szSql[1024];
Connection con;
DBOperate dbo;
Int16 iRet = 0;
UInt32 LeftNum=0;
List<ItemList> lis;
ItemList item;
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
sprintf(szSql, "Update specialItem set leftNum=leftNum-%d where ItemID=%d and leftNum>%d;",num,ItemID,num);
iRet=dbo.ExceSQL(szSql);
if(iRet!=0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"szSql[%s] ", mysql_error(con.GetHandle()), szSql);
return -1;
}
sprintf(szSql, "select leftNum from specialItem where ItemID=%d",ItemID);
iRet=dbo.QuerySQL(szSql);
if(iRet==0)
{
while(dbo.HasRowData())
{
LeftNum=dbo.GetIntField(0);
dbo.NextRow();
}
}
else
{
//ch
LOG(LOG_ERROR,__FILE__,__LINE__,"szSql[%s] ", mysql_error(con.GetHandle()), szSql);
return -1;
}
item.ItemID=ItemID;
item.num=LeftNum;
lis.push_back(item);
NotifyspecialItemNum(lis);
return 0;
}
示例3: IfHasSoMoney
//角色是否有这么多金钱, 1 绑定银,2 金币。
//返回 0成功,-1 失败 ,1 没有
int OffLineUpdateSvc::IfHasSoMoney(UInt32 roleID, UInt32 money,Byte moneyType)
{
char szSql[1024];
char szSql1[1024];
char szTemp[50];
char szMoney[50];
int iRet;
UInt32 roleMoney;
Connection con;
DBOperate dbo;
//获取DB连接
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
if(1== moneyType) //银币
{
sprintf(szSql,"select %s from RoleMoney where RoleID = %d;","Money",roleID);
sprintf(szSql1,"select %s from RoleMoney where RoleID = %d;","BindMoney",roleID);
iRet = dbo.QuerySQL(szSql);
if(iRet < 0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"DB operate failed !");
return -1;
}
roleMoney = dbo.GetIntField(0);
iRet = dbo.QuerySQL(szSql1);
if(iRet < 0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"DB operate failed !");
return -1;
}
roleMoney += dbo.GetIntField(0);
}
if(2 == moneyType) //金币
{
sprintf(szSql,"select %s from RoleMoney where RoleID = %d;","Gold",roleID);
iRet = dbo.QuerySQL(szSql);
if(iRet < 0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"DB operate failed !");
return -1;
}
roleMoney = dbo.GetIntField(0);
}
if (iRet == 0) {
if (roleMoney < money) {
return -1;
}
}
return 0;
}
示例4: UpdateDBItemSellCount
//更新商城中出售的物品的总数
int ShopSvc::UpdateDBItemSellCount(UInt32 ItemID,Byte type,UInt32 num)
{
char szSql[1024];
Connection con;
DBOperate dbo;
Int16 iRet = 0;
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
sprintf(szSql, "update ShopItem set ItemSellTolalNum=ItemSellTolalNum+%d where ItemID =%d and Category=%d;",num,ItemID,type);
iRet=dbo.ExceSQL(szSql);
if(iRet!=0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"szSql[%s] ", mysql_error(con.GetHandle()), szSql);
}
return 0;
}
示例5: TakeoffAndLockMoney
//扣除并锁定金钱
//返回值 0 成功,1 失败
int OffLineUpdateSvc::TakeoffAndLockMoney(UInt32 roleID, UInt32 money,Byte moneyType,const OffLineUpdateItem& offHang)
{
char szSql[1024];
UInt32 RetCode = 0;
int iRet;
char szTemp[100];
Connection con;
DBOperate dbo;
//获取DB连接
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
LOG(LOG_ERROR,__FILE__,__LINE__,"money[%d]",money);
if(1 == moneyType)
{
sprintf(szSql,"select %s from RoleMoney where RoleID = %d;","BindMoney",roleID);
iRet = dbo.QuerySQL(szSql);
if(iRet < 0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"DB operate failed !");
return -1;
}
int bindMoney = dbo.GetIntField(0);
int decreaseMoney = bindMoney - money;
if(bindMoney >= money){
sprintf(szSql,"update RoleMoney set \
BindMoney = %d where RoleID = %d;",decreaseMoney,roleID);
iRet = dbo.ExceSQL(szSql);
if(0 != iRet)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"DB operate failed !");
return 1;
}
}else{
示例6: ProcessBuyItem
void ShopSvc::ProcessBuyItem(Session& session,Packet& packet)
{
UInt32 RetCode = 0;
DataBuffer serbuffer(1024);
char szSql[1024];
Connection con;
DBOperate dbo;
Int16 iRet = 0;
UInt16 num=0;
UInt16 cellType=0;
UInt16 itemType=0;
UInt16 IsStack=0;
UInt16 Bind=0;
UInt32 Dur=0;
UInt32 price=0;
UInt32 EntityID=0;
UInt32 CellIndex=0;
UInt32 leftnum=0;
List<UInt16> cell;
List<ItemCell> lic;
ItemCell lic1;
List<UInt16>::iterator itor;
UInt32 roleID = packet.RoleID;
UInt32 itemID=0;
UInt16 count=0;
UInt32 numcell=1;
UInt16 Rarity=0;
UInt32 BuyType=0;
Byte type=0;
Byte flag=0;
//序列化类
Serializer s(packet.GetBuffer());
s>>type>>itemID>>num;
LOG(LOG_ERROR,__FILE__,__LINE__,"type[%d]--itemid[%d]--num[%d]",type,itemID,num);
//得到物品ID和数量
if( s.GetErrorCode()!= 0 )
{
RetCode = ERR_SYSTEM_SERERROR;
LOG(LOG_ERROR,__FILE__,__LINE__,"serial error" );
goto EndOf_Process;
}
//获取DB连接
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
//验证价格
sprintf( szSql, "select NowPrice from ShopItem where ItemID=%d and Category=%d;",itemID,type );
iRet = dbo.QuerySQL(szSql);
if(iRet==0)
{
price=dbo.GetIntField(0);
}
else
{
RetCode = ERR_SYSTEM_DBNORECORD;
LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL data not found or erro,szSql[%s] " , szSql);
goto EndOf_Process;
}
if(type==6)
{
//表示礼券购买
iRet=DropGift(roleID,price*num);
if(iRet==1)
{
//没有这么多数量的礼券
RetCode = NO_MUCH_GIFT;
LOG(LOG_ERROR,__FILE__,__LINE__,"Not so many Gift!! ");
goto EndOf_Process;
}
else if(iRet==-1)
{
//错误
RetCode = ERR_APP_DATA;
LOG(LOG_ERROR,__FILE__,__LINE__,"there are some erro!! ");
goto EndOf_Process;
}
}
else if(type==7)
{
//表示限量抢购
sprintf( szSql, "select ItemID,leftNum from specialItem where ItemID=%d;",itemID);
iRet = dbo.QuerySQL(szSql);
if(iRet!=0)
{
RetCode = ERR_SYSTEM_DBNORECORD;
LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL data not found ,szSql[%s] " , szSql);
goto EndOf_Process;
}
else
{
leftnum=dbo.GetIntField(1);
//.........这里部分代码省略.........
示例7: MakeSSPkgForPet
int PKSvc::MakeSSPkgForPet(const ArchvPosition &posPKOrigin, UInt32 roleID, List<ArchvRolePKInfo> &lrpki,Byte type,Byte dirte)
{
char szSql[1024];
Connection con;
DBOperate dbo;
int iRet = 0;
UInt32 PetID=0;
ArchvRolePKInfo petpkInfo;
//获取DB连接
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
sprintf( szSql, "select PetID , PetType,PetKind ,PetName ,Level ,Exp ,MaxExp, \
AddPoint ,Strength \
,Intelligence ,Agility ,MoveSpeed ,HP ,MP \
,MaxHP ,MaxMP ,HPRegen ,MPRegen ,AttackPowerHigh \
,AttackPowerLow ,AttackScope ,AttackSpeed ,BulletSpeed ,Defence \
,MDefence ,CritRate ,HitRate ,DodgeRate \
from Pet \
where RoleID=%d and IsUse=1;", roleID );
iRet = dbo.QuerySQL(szSql);
if( 1 == iRet )
{
// LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL data not found ,szSql[%s] " , szSql);
return -1;
}
if( iRet < 0 )
{
LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL error[%s],szSql[%s] ", mysql_error(con.GetHandle()), szSql);
return -1;
}
petpkInfo.controlID=roleID;
petpkInfo.creatureFlag=4;
petpkInfo.opposition=type;
if(posPKOrigin.X-PKSCREEN_XLENGTH/2>0)
{
petpkInfo.currPosX=posPKOrigin.X+2;
}
else
{
petpkInfo.currPosX=posPKOrigin.X-2;
}
petpkInfo.currPosY=posPKOrigin.Y;
while(dbo.HasRowData())
{
PetID = dbo.GetIntField(0);
petpkInfo.roleID=PetID;
petpkInfo.creatureType=dbo.GetIntField(1);
//_petkind=dbo.GetIntField(2) ;力量型什么的
// Name( dbo.GetStringField(3) );
petpkInfo.level=dbo.GetIntField(4);
//Exp( dbo.GetIntField(5) );
//MaxExp(dbo.GetIntField(6));
//AddPoint( dbo.GetIntField(7) );
petpkInfo.Strength=dbo.GetIntField(8);
petpkInfo.Wisdom=dbo.GetIntField(9);
petpkInfo.Agile=dbo.GetIntField(10);
petpkInfo.moveSpeed=dbo.GetIntField(11);
petpkInfo.hp=dbo.GetIntField(12);
petpkInfo.mp=dbo.GetIntField(13);
petpkInfo.maxHP=dbo.GetIntField(14);
petpkInfo.maxMP=dbo.GetIntField(15);
// HpRegen( dbo.GetIntField(16) );
//MpRegen( dbo.GetIntField(17) );
petpkInfo.attackPowerHigh=dbo.GetIntField(19);
petpkInfo.attackPowerLow=dbo.GetIntField(20);
petpkInfo.attackArea=dbo.GetIntField(21);
petpkInfo.attackBulletSpeed=dbo.GetIntField(22);
petpkInfo.attackSpeed=dbo.GetIntField(23);
petpkInfo.defense=dbo.GetIntField(24);
petpkInfo.mDefense=dbo.GetIntField(25);
petpkInfo.CritRate=dbo.GetIntField(26);
petpkInfo.hitRate=dbo.GetIntField(27);
petpkInfo.dodgeRate=dbo.GetIntField(28);
dbo.NextRow();
}
sprintf( szSql, "select PetID ,Strength ,Intelligence ,Agility ,MovSpeed ,MaxHP,MaxMP \
,HPRegen ,MPRegen ,AttackPowerHigh ,AttackPowerLow ,AttackSpeed \
,Defence ,MDefence ,CritRate ,HitRate ,DodgeRae \
from PetBonus \
where PetID = %d ", PetID );
iRet=dbo.QuerySQL(szSql);
if( 1 == iRet )
{
LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL data not found ,szSql[%s] " , szSql);
return -1;
}
if( iRet < 0 )
{
LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL error[%s],szSql[%s] ", mysql_error(con.GetHandle()), szSql);
return -1;
}
while(dbo.HasRowData())
{
petpkInfo.Strength =petpkInfo.Strength+dbo.GetIntField(1);
petpkInfo.Wisdom=petpkInfo.Wisdom+dbo.GetIntField(2);
petpkInfo.Agile=petpkInfo.Agile+dbo.GetIntField(3);
petpkInfo.moveSpeed=petpkInfo.moveSpeed+dbo.GetIntField(4);
petpkInfo.maxHP=petpkInfo.maxHP+dbo.GetIntField(5);
//.........这里部分代码省略.........
示例8: MakeSSPkgForRole
//@brief 组建 S_S pk请求包: for 角色
//@lrpki 返回的组建结果
//@return 0 成功 非0 失败,type为1表示攻击者,为2表示被攻击者,区分阵营
int PKSvc::MakeSSPkgForRole( const ArchvPosition &posPKOrigin, RolePtr &role, List<ArchvRolePKInfo> &lrpki,Byte type)
{
ArchvRolePKInfo pkInfo;
ArchvAvatarDescBrief adb;
List<ArchvAvatarDescBrief> ladb;
ArchvPosition rolePosition;
List<UInt32> lrid;
ArchvSkill skill;
char szSql[1024];
Connection con;
DBOperate dbo;
int iRet = 0;
//获取DB连接
con = _cp->GetConnection();
dbo.SetHandle(con.GetHandle());
//赋值
pkInfo.controlID = role->ID();
pkInfo.roleID = role->ID();
pkInfo.level = role->Level();
if(type==1)
{
pkInfo.opposition = 1;
}
else
{
pkInfo.opposition = 2;
}
pkInfo.creatureFlag = 1;
pkInfo.creatureType = role->ProID();
// pkInfo.origin = 1;
//pkInfo.live = 1;
pkInfo.maxHP = role->MaxHp()+role->MaxHpBonus();
pkInfo.maxMP =role->MaxMp()+role->MaxMpBonus();
pkInfo.hp = role->Hp();
//+(time(NULL)-role->LastHpMpTime)*(role->HpRegen());
pkInfo.mp = role->Mp();
//+(time(NULL)-role->LastHpMpTime)*(role->MpRegen());
pkInfo.moveSpeed = role->MoveSpeed()+role->MovSpeedBonus();
//pk坐标处理
// 对超出pk地图范围的坐标进行调整
pkInfo.currPosX = posPKOrigin.X;
pkInfo.currPosY = posPKOrigin.Y;
LOG(LOG_DEBUG,__FILE__,__LINE__,"----------->>>>roleID [%d], currPosX x[%d],y[%d] ",
role->ID(), pkInfo.currPosX, pkInfo.currPosY );
pkInfo.direct = role->Direct();
pkInfo.attackPowerHigh = role->AttackPowerHigh()+role->AttackPowerHighBonus();
pkInfo.attackPowerLow = role->AttackPowerLow()+role->AttackPowerLowBonus();
pkInfo.attackArea = role->AttackScope();
pkInfo.attackSpeed = role->AttackSpeed()+role->AttackSpeedBonus();
pkInfo.attackDisplayTime = 2;
pkInfo.attackBulletSpeed = role->BulletSpeed();
pkInfo.hitRate = role->HitRate()+role->HitRateBonus();
pkInfo.dodgeRate = role->DodgeRate()+role->DodgeRateBonus();
pkInfo.defense = role->Defence()+role->DefenceBonus();
pkInfo.mDefense = role->MDefence()+role->MDefenceBonus();
pkInfo.CritRate=role->CritRate()+role->CritRateBonus();
pkInfo.Agile=role->Agility()+role->AgilityBonus();
pkInfo.Strength=role->Strength()+role->StrengthBonus();
pkInfo.Wisdom=role->Intelligence()+role->IntelligenceBonus();
// LOG(LOG_ERROR,__FILE__,__LINE__,"PKRoleID:::: %d contronID :::%d ---------" , pkInfo.roleID,pkInfo.controlID);
//pkInfo.
/* lrid.push_back( pkInfo.roleID );
iRet = _mainSvc->GetAvatarSvc()->GetEquipBrief( lrid, ladb);
if(iRet)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"GetEquipBrief error" );
return -1;
}
*/
// pkInfo.wpnItemID = ladb.front().wpnItemID;
// pkInfo.flag = ladb.front().coatID;
//技能
pkInfo.las.clear();
sprintf(szSql,"select SkillID,SkillLev from RoleSkill where RoleID=%d and SkillID<300 and SkillLev>0",role->ID());
iRet=dbo.QuerySQL(szSql);
if(iRet!=0)
{
LOG(LOG_ERROR,__FILE__,__LINE__,"QuerySQL role not have skill[%s],szSql[%s] ", mysql_error(con.GetHandle()), szSql);
}
while(dbo.HasRowData())
{
skill.skillID=dbo.GetIntField(0);
skill.skillLevel=dbo.GetIntField(1);
pkInfo.las.push_back(skill);
dbo.NextRow();
//.........这里部分代码省略.........