本文整理汇总了C++中DataBinding类的典型用法代码示例。如果您正苦于以下问题:C++ DataBinding类的具体用法?C++ DataBinding怎么用?C++ DataBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: offsetof
void MessageRouter::_loadMessageProcessMap(void)
{
MessageRoute route;
// We need to populate our message map.
// setup our databinding parameters.
DataBinding* binding = mDatabase->createDataBinding(2);
binding->addField(DFT_uint32, offsetof(MessageRoute, mMessageId), 4);
binding->addField(DFT_uint32, offsetof(MessageRoute, mProcessId), 4);
// Execute our statement
DatabaseResult* result = mDatabase->executeSynchSql("SELECT messageId, processId FROM %s.config_message_routes;",mDatabase->galaxy());
uint32 count = static_cast<uint32>(result->getRowCount());
// Retrieve our routes and add them to the map.
for(uint32 i = 0; i < count; i++)
{
result->getNextRow(binding, &route);
mMessageRouteMap.insert(std::make_pair(route.mMessageId, route.mProcessId));
}
// Delete our DB objects.
mDatabase->destroyDataBinding(binding);
mDatabase->destroyResult(result);
}
示例2: BuffAttributeDBItem
void BuffManager::LoadBuffAttributesFromResult(buffAsyncContainer* asyncContainer, DatabaseResult* result)
{
DataBinding* buffBinding = mDatabase->createDataBinding(4);
buffBinding->addField(DFT_uint64,offsetof(BuffAttributeDBItem,mType),8,0);
buffBinding->addField(DFT_int32,offsetof(BuffAttributeDBItem,mInitialValue),4,1);
buffBinding->addField(DFT_int32,offsetof(BuffAttributeDBItem,mTickValue),4,2);
buffBinding->addField(DFT_int32,offsetof(BuffAttributeDBItem,mFinalValue),4,3);
uint64 rowCount = result->getRowCount();
BuffAttributeDBItem* tmp = new BuffAttributeDBItem();
for(uint64 i = 0; i < rowCount; i++)
{
result->getNextRow(buffBinding,tmp);
asyncContainer->buff->AddAttribute(BuffAttribute::FromDB(tmp));
}
asyncContainer->buff->SetInit(true);
SAFE_DELETE(tmp);
mDatabase->destroyDataBinding(buffBinding);
//Start the buff later on - we want to avoid racing conditions with the knownplayer map
//asyncContainer->buff->ReInit();
asyncContainer->player->DecBuffAsyncCount();
asyncContainer->mQueryType=BMQuery_Delete;
int8 sql2[550];
sprintf(sql2, "delete from %s.character_buff_attributes where character_id = %" PRIu64 " and buff_id = %" PRIu64 ";",mDatabase->galaxy(), asyncContainer->player->getId(), asyncContainer->buff->GetDBID());
mDatabase->executeSqlAsync(this,asyncContainer,sql2);
//we use the asyncContainer again the line above
}
示例3: _HandleUpdateAdminPermission
void StructureManager::_HandleUpdateAdminPermission(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result)
{
HouseObject* house = dynamic_cast<HouseObject*>(gWorldManager->getObjectById(asynContainer->mStructureId));
struct adminStruct
{
uint64 playerID;
};
adminStruct adminData;
DataBinding* adminBinding = mDatabase->CreateDataBinding(1);
adminBinding->addField(DFT_uint64,offsetof(adminStruct,playerID),8,0);
uint64 count = result->getRowCount();
house->resetHousingAdminList();
for(uint32 j = 0;j < count;j++)
{
result->GetNextRow(adminBinding,&adminData);
house->addHousingAdminEntry(adminData.playerID);
//now that we added it to the list we need to update the players delta
}
mDatabase->DestroyDataBinding(adminBinding);
}
示例4: switch
//======================================================================================================================
void ClientManager::handleDatabaseJobComplete(void* ref, DatabaseResult* result)
{
// This assumes only authentication calls are async right now. Will change as needed.
ConnectionClient* client = reinterpret_cast<ConnectionClient*>(ref);
switch (client->getState())
{
case CCSTATE_QueryAuth:
{
_handleQueryAuth(client, result);
break;
}
case CCSTATE_AllowedChars:
{
struct charsCurrentAllowed {
uint32 currentChars;
uint32 charsAllowed;
} charsStruct;
DataBinding* binding = mDatabase->createDataBinding(2);
binding->addField(DFT_int32,offsetof(charsCurrentAllowed, currentChars), 4, 0);
binding->addField(DFT_int32,offsetof(charsCurrentAllowed, charsAllowed), 4, 1);
result->getNextRow(binding,&charsStruct);
client->setCharsAllowed(charsStruct.charsAllowed);
client->setCurrentChars(charsStruct.currentChars);
client->setState(CCSTATE_QueryAuth);
mDatabase->destroyDataBinding(binding);
break;
}
default:
break;
}
}
示例5: _HandleUpdateCharacterLots
//==================================================================================================
//
// updates the characters lots
//
void StructureManager::_HandleUpdateCharacterLots(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId));
uint8 lotCount;
DataBinding* binding = mDatabase->CreateDataBinding(1);
binding->addField(DFT_uint8,0,1);
uint64 count;
count = result->getRowCount();
if (!count)
{
gLogger->logMsgLoadFailure("StructureManager::add Permission no return value...",MSG_NORMAL);
return;
}
result->GetNextRow(binding,&lotCount);
if(player)
{
//update the lots
uint8 maxLots = gWorldConfig->getConfiguration("Player_Max_Lots",(uint8)10);
maxLots -= static_cast<uint8>(lotCount);
player->setLots((uint8)maxLots);
//mmmmh a bit of a hack ... maybe it works ?
gMessageLib->sendCharacterSheetResponse(player);
}
mDatabase->DestroyDataBinding(binding);
}
示例6: _HandleQueryEntryPermissionData
//==================================================================================================
// handles the admin permission list
// it will be read in for the list to display when the player displays it to make changes
// please note that the list is purely db based and *not* kept in memory
// it will be cleared once the changes are made
//
void StructureManager::_HandleQueryEntryPermissionData(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result)
{
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(gWorldManager->getObjectById(asynContainer->mStructureId));
string playerName;
DataBinding* binding = mDatabase->CreateDataBinding(1);
binding->addField(DFT_bstring,0,64);
uint64 count;
count = result->getRowCount();
structure->resetStructureEntryList();
for(uint64 i = 0;i < count;i++)
{
result->GetNextRow(binding,&playerName);
structure->addStructureEntryListEntry(playerName);
}
structure->sendStructureEntryList(asynContainer->mPlayerId);
mDatabase->DestroyDataBinding(binding);
}
示例7: VALUES
void StructureManager::_HandleStructureTransferLotsRecipient(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result)
{
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(gWorldManager->getObjectById(asynContainer->mStructureId));
PlayerObject* donor = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mPlayerId));
PlayerObject* recipient = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(asynContainer->mTargetId));
uint8 lots;
DataBinding* binding = mDatabase->CreateDataBinding(1);
binding->addField(DFT_uint8,0,1);
uint64 count;
count = result->getRowCount();
if(!count)
{
gLogger->logMsgF("StructureManager::Transfer Structure Admin List Callback couldnt get recipients lots",MSG_HIGH);
mDatabase->DestroyDataBinding(binding);
return;
}
//thats lots in use
result->GetNextRow(binding,&lots);
uint8 requiredLots = structure->getLotCount();
uint8 freelots = gWorldConfig->getConfiguration("Player_Max_Lots",(uint8)10) - lots;
if(freelots >= requiredLots)
{
//yay we were succesful
structure->setOwner(asynContainer->mTargetId);
mDatabase->ExecuteSqlAsync(0,0,"UPDATE structures SET structures.owner = %I64u WHERE structures.id = %I64u",asynContainer->mTargetId,asynContainer->mStructureId);
mDatabase->ExecuteSqlAsync(0,0,"DELETE FROM structure_admin_data where playerId = %I64u AND StructureID = %I64u",asynContainer->mPlayerId,asynContainer->mStructureId);
mDatabase->ExecuteSqlAsync(0,0,"INSERT INTO structure_admin_data VALUES (NULL,%I64u,%I64u,'ADMIN')",asynContainer->mStructureId, asynContainer->mTargetId);
//update the administration list
if(donor)
{
gMessageLib->sendSystemMessage(donor,L"","player_structure","ownership_transferred_out","",asynContainer->name);
}
if(recipient)
{
gMessageLib->sendSystemMessage(recipient,L"","player_structure","ownership_transferred_in","",donor->getFirstName().getAnsi());
}
}
else
{
//say something
}
mDatabase->DestroyDataBinding(binding);
}
示例8: memset
//======================================================================================================================
void LoginManager::_sendCharacterList(LoginClient* client, DatabaseResult* result)
{
CharacterInfo data;
memset(&data, 0, sizeof(CharacterInfo));
// This DataBinding code I'm not sure where to put atm. I've thought about a base class for any objects that want
// DataBinding, but I don't want to go overboard on abstraction. Any suggestions would be appreciated. :)
DataBinding* binding = mDatabase->createDataBinding(5);
binding->addField(DFT_uint64, offsetof(CharacterInfo, mCharacterId), 8);
binding->addField(DFT_bstring, offsetof(CharacterInfo, mFirstName), 64);
binding->addField(DFT_bstring, offsetof(CharacterInfo, mLastName), 64);
binding->addField(DFT_uint32, offsetof(CharacterInfo, mServerId), 4);
binding->addField(DFT_bstring, offsetof(CharacterInfo, mBaseModel), 64);
uint32 charCount = static_cast<uint32>(result->getRowCount());
// Create our server list message
gMessageFactory->StartMessage(); // Opcode group number
gMessageFactory->addUint32(opEnumerateCharacterId);
gMessageFactory->addUint32(charCount); // Character count
for (uint32 i = 0; i < charCount; i++)
{
result->getNextRow(binding, &data);
// Append first and last names
BString fullName, baseModel;
fullName << data.mFirstName.getAnsi();
if(data.mLastName.getLength())
{
fullName << " ";
// fullName << data.mLastName.getAnsi();
}
fullName.convert(BSTRType_Unicode16);
gMessageFactory->addString(fullName); // Characters full name
baseModel = data.mBaseModel;
gMessageFactory->addUint32(baseModel.getCrc()); // Base model
gMessageFactory->addUint64(data.mCharacterId); // Character Id
gMessageFactory->addUint32(data.mServerId); // Server Id
gMessageFactory->addUint32(1); // Uknown
}
Message* message = gMessageFactory->EndMessage();
client->SendChannelA(message, 2, false);
// Destroy our data binding
mDatabase->destroyDataBinding(binding);
}
示例9: _processSelectCharacter
//======================================================================================================================
void ClientManager::_processSelectCharacter(ConnectionClient* client, Message* message)
{
uint64 characterId = message->getUint64();
DatabaseResult* result = mDatabase->executeSynchSql("SELECT planet_id FROM %s.characters WHERE id=%"PRIu64";",mDatabase->galaxy(), characterId);
uint32 serverId;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_uint32, 0, 4);
result->getNextRow(binding, &serverId);
client->setServerId(serverId + 8); // server ids for zones are planetId + 8;
mDatabase->destroyDataBinding(binding);
mDatabase->destroyResult(result);
// send an opClusterClientConnect message to zone server.
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opClusterClientConnect);
gMessageFactory->addUint64(characterId);
Message* zoneMessage = gMessageFactory->EndMessage();
// This one goes to the ZoneServer the client is currently on.
zoneMessage->setAccountId(client->getAccountId());
zoneMessage->setDestinationId(static_cast<uint8>(serverId + 8));
zoneMessage->setRouted(true);
mMessageRouter->RouteMessage(zoneMessage, client);
// send an opClusterClientConnect message to chat server.
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opClusterClientConnect);
gMessageFactory->addUint64(characterId);
gMessageFactory->addUint32(serverId);
Message* chatMessage = gMessageFactory->EndMessage();
// This one goes to the ChatServer
chatMessage->setAccountId(client->getAccountId());
chatMessage->setDestinationId(CR_Chat);
chatMessage->setRouted(true);
mMessageRouter->RouteMessage(chatMessage, client);
// Now send the SelectCharacter message off to the zone server.
gMessageFactory->StartMessage();
gMessageFactory->addData(message->getData(), message->getSize());
Message* selectMessage = gMessageFactory->EndMessage();
selectMessage->setAccountId(client->getAccountId());
selectMessage->setDestinationId(static_cast<uint8>(serverId + 8));
selectMessage->setRouted(true);
mMessageRouter->RouteMessage(selectMessage, client);
}
示例10: offsetof
//======================================================================================================================
void LoginManager::_getLauncherSessionKey(LoginClient* client, DatabaseResult* result)
{
AccountData data;
DataBinding* binding = mDatabase->createDataBinding(1);
binding->addField(DFT_int64, offsetof(AccountData, mId), 8);
if (result->getRowCount())
{
//we have the account id
result->getNextRow(binding, (void*)&data);
client->setAccountId(data.mId);
//log it
DLOG(info) << "void LoginManager::_sendLauncherSessionKey Login: AccountId: " << data.mId<< " Name: " << client->getUsername().getAnsi();
//get the session_key made and returned
int8 sql[512];
sprintf(sql,"CALL %s.sp_AccountSessionKeyGenerate(%" PRIu64 ");",mDatabase->galaxy(), data.mId);
client->setState(LCSTATE_RetrieveSessionKey);
mDatabase->executeProcedureAsync(this, client, sql);
}
else
{
Message* newMessage;
BString errType, errMsg;
errType = "@cpt_login_fail";
errMsg = "@msg_login_fail";
DLOG(info) << " Login failed for username: " << client->getUsername().getAnsi() <<", password: ********" << client->getPassword().getAnsi();
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opErrorMessage);
gMessageFactory->addString(errType);
gMessageFactory->addString(errMsg);
gMessageFactory->addUint8(0);
newMessage = gMessageFactory->EndMessage();
client->SendChannelA(newMessage, 3,false);
client->Disconnect(6);
}
// Destroy our database object
mDatabase->destroyDataBinding(binding);
}
示例11: switch
void NpcManager::handleDatabaseJobComplete(void* ref, DatabaseResult* result)
{
NpcAsyncContainer* asyncContainer = reinterpret_cast<NpcAsyncContainer*>(ref);
switch(asyncContainer->mQuery)
{
case NpcQuery_Lairs:
{
// warning... this assumes that someone has called the Init()-function before we execute the line below.
// For now, it's done at ZoneServer::Startup().
NonPersistentNpcFactory* nonPersistentNpcFactory = NonPersistentNpcFactory::Instance();
NpcLairEntity lair;
// Here we will get the lair type.
DataBinding* lairSpawnBinding = mDatabase->createDataBinding(3);
lairSpawnBinding->addField(DFT_uint64,offsetof(NpcLairEntity,mLairsId),8,0);
lairSpawnBinding->addField(DFT_uint64,offsetof(NpcLairEntity,mLairTemplateId),8,1);
lairSpawnBinding->addField(DFT_uint32,offsetof(NpcLairEntity,mNumberOfLairs),4,2);
uint64 count = result->getRowCount();
for (uint64 i = 0; i < count; i++)
{
result->getNextRow(lairSpawnBinding,&lair);
for (uint64 lairs = 0; lairs < lair.mNumberOfLairs; lairs++)
{
// We need two id's in sequence, since nps'c have an inventory.
uint64 npcNewId = gWorldManager->getRandomNpNpcIdSequence();
if (npcNewId != 0)
{
nonPersistentNpcFactory->requestLairObject(this, lair.mLairsId, npcNewId);
}
}
}
mDatabase->destroyDataBinding(lairSpawnBinding);
}
break;
default:
{
}
break;
}
}
示例12: sprintf
void StructureManager::_HandleStructureDestruction(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result)
{
struct structData
{
uint64 id;
uint32 condition;
};
structData sd;
DataBinding* binding = mDatabase->CreateDataBinding(2);
binding->addField(DFT_uint64,offsetof(structData,id),8,0);
binding->addField(DFT_uint32,offsetof(structData,condition),4,1);
uint64 count;
count = result->getRowCount();
for(uint64 i = 0;i < count;i++)
{
result->GetNextRow(binding,&sd);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(gWorldManager->getObjectById(sd.id));
if(structure)
{
gLogger->logMsgF("StructureManager::delete structure due to zero condition %I64u",MSG_NORMAL,structure->getId());
//delete the deed in the db
//the parent is the structure and the item family is 15
int8 sql[100];
sprintf(sql,"DELETE FROM items WHERE parent_id = %"PRIu64" AND item_family = 15",structure->getId());
mDatabase->ExecuteSqlAsync(NULL,NULL,sql);
//delete harvester db side with all power and all resources
gObjectFactory->deleteObjectFromDB(structure);
UpdateCharacterLots(structure->getOwner());
//delete it in the world
gMessageLib->sendDestroyObject_InRangeofObject(structure);
gWorldManager->destroyObject(structure);
}
}
mDatabase->DestroyDataBinding(binding);
}
示例13: LoadCurrentGlobalTick
void WorldManager::LoadCurrentGlobalTick()
{
uint64 Tick;
DatabaseResult* temp = mDatabase->executeSynchSql("SELECT Global_Tick_Count FROM %s.galaxy WHERE galaxy_id = '2'",mDatabase->galaxy());
DataBinding* tickbinding = mDatabase->createDataBinding(1);
tickbinding->addField(DFT_uint64,0,8,0);
temp->getNextRow(tickbinding,&Tick);
mDatabase->destroyDataBinding(tickbinding);
mDatabase->destroyResult(temp);
LOG(info) << "Current global tick count [" << Tick << "]";
mTick = Tick;
mSubsystemScheduler->addTask(fastdelegate::MakeDelegate(this,&WorldManager::_handleTick),7,1000,NULL);
}
示例14: _HandleGetInactiveHarvesters
void StructureManager::_HandleGetInactiveHarvesters(StructureManagerAsyncContainer* asynContainer,DatabaseResult* result)
{
struct structData
{
uint64 id;
uint32 condition;
};
structData sd;
DataBinding* binding = mDatabase->CreateDataBinding(2);
binding->addField(DFT_uint64,offsetof(structData,id),8,0);
binding->addField(DFT_uint32,offsetof(structData,condition),4,1);
uint64 count;
count = result->getRowCount();
for(uint64 i = 0;i < count;i++)
{
result->GetNextRow(binding,&sd);
HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(gWorldManager->getObjectById(sd.id));
if(harvester)
{
//if the harvesters status is changed we need to alter it
if(harvester->getActive())
{
harvester->setActive(false);
harvester->setDamage(sd.condition);
gMessageLib->sendHarvesterActive(harvester);
}
//Now update the condition
gMessageLib->sendHarvesterCurrentConditionUpdate(harvester);
}
}
mDatabase->DestroyDataBinding(binding);
}
示例15: memset
void ZoneServer::_connectToConnectionServer(void)
{
ProcessAddress processAddress;
memset(&processAddress, 0, sizeof(ProcessAddress));
// Query the DB to find out who this is.
// setup our databinding parameters.
DataBinding* binding = mDatabase->CreateDataBinding(5);
binding->addField(DFT_uint32, offsetof(ProcessAddress, mType), 4);
binding->addField(DFT_string, offsetof(ProcessAddress, mAddress), 16);
binding->addField(DFT_uint16, offsetof(ProcessAddress, mPort), 2);
binding->addField(DFT_uint32, offsetof(ProcessAddress, mStatus), 4);
binding->addField(DFT_uint32, offsetof(ProcessAddress, mActive), 4);
// Execute our statement
DatabaseResult* result = mDatabase->ExecuteSynchSql("SELECT id, address, port, status, active FROM config_process_list WHERE name='connection';");
uint32 count = static_cast<uint32>(result->getRowCount());
// If we found them
if (count == 1)
{
// Retrieve our routes and add them to the map.
result->GetNextRow(binding, &processAddress);
}
// Delete our DB objects.
mDatabase->DestroyDataBinding(binding);
mDatabase->DestroyResult(result);
// Now connect to the ConnectionServer
DispatchClient* client = new DispatchClient();
mRouterService->Connect(client, processAddress.mAddress, processAddress.mPort);
// Send our registration message
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opClusterRegisterServer);
gMessageFactory->addString(mZoneName);
Message* message = gMessageFactory->EndMessage();
client->SendChannelA(message, 0, CR_Connection, 1);
}