本文整理汇总了C++中PlayerObject::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getId方法的具体用法?C++ PlayerObject::getId怎么用?C++ PlayerObject::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//======================================================================================================================
//
// Modifies the Admin List
//
void ObjectController::_handleTransferStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// requirement we have the structure targeted AND give the name of the recipient on the commandline
// OR we have the recipient targeted and stand NEXT to the structure were about to transfer
//do we have a valid donor ?
CreatureObject* creature = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
if(!player)
{
return;
}
// is the player online and near 30m ?
// we get the players id as targetid if yes, otherwise we get the name as string
// however, we do not want players that are not online
//now get the target player
PlayerObject* recipient = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(targetId));
if(!recipient)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "no_transfer_target"), player);
return;
}
//do we have a valid structure ??? check our target first
uint64 id = player->GetCreature()->getTargetId();
Object* object = gWorldManager->getObjectById(id);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
if(!structure)
{
// we need to get the nearest structure that we own
// for now dustoff
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
//is the structure in Range???
float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Transfer_Structure_Distance",(float)8.0);
if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
StructureAsyncCommand command;
command.PlayerId = player->getId();
command.StructureId = structure->getId();
command.RecipientId = recipient->getId();
command.PlayerStr = recipient->GetCreature()->getFirstName();
command.Command = Structure_Command_TransferStructure;
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);
}
示例2: DLOG
//======================================================================================================================
//
// provides the harvester with the current resources
//
void ObjectController::_handleHarvesterGetResourceData(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if(!player)
{
return;
}
//do we have a valid structure ???
uint64 id = targetId;
Object* object = gWorldManager->getObjectById(id);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
if(!structure)
{
//gMessageLib->sendSystemMessage(player,L"","player_structure","command_no_building");
return;
}
//is the structure in Range???
float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
if(glm::distance(player->mPosition, structure->mPosition) > fTransferDistance)
{
DLOG(INFO) << " ObjectController::_handleHarvesterGetResourceData Structure not in Range";
return;
}
HarvesterObject* harvester = dynamic_cast<HarvesterObject*>(structure);
StructureAsyncCommand command;
command.Command = Structure_Command_GetResourceData;
command.PlayerId = player->getId();
command.StructureId = structure->getId();
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->getFirstName().getAnsi(),"ADMIN",command);
return;
gMessageLib->sendHarvesterResourceData(structure,player);
DLOG(INFO) << " ObjectController::_handleHarvesterGetResourceData :: hino 7 baseline";
gMessageLib->sendBaselinesHINO_7(harvester,player);
//add the structure to the timer so the resource amounts are updated while we look at the hopper
//harvester->getTTS()->todo = ttE_UpdateHopper;
//harvester->getTTS()->playerId = player->getId();
//structure->getTTS()->projectedTime = 5000 + Anh_Utils::Clock::getSingleton()->getLocalTime();
//gStructureManager->addStructureforHopperUpdate(harvester->getId());
// this needs to be handled zoneserverside - otherwise the addition of a res will trigger a racecondition
// between the sql write query and the sql read please note that the harvesting itself happens through stored procedures
// and we cant keep the updatecounters synchronized
}
示例3: sscanf
//======================================================================================================================
//
// Modifies the Admin List
//
void ObjectController::_handleNameStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// requirement we have the structure targeted AND give the name of the recipient on the commandline
// OR we have the recipient targeted and stand NEXT to the structure were about to transfer
//do we have a valid donor ?
CreatureObject* creature = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();
if(!player)
{
return;
}
//do we have a valid structure ??? check our target first
uint64 id = player->GetCreature()->getTargetId();
Object* object = gWorldManager->getObjectById(id);
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
if(!structure)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
//is the structure in Range???
float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
return;
}
//find out where our structure is
BString dataStr;
message->getStringUnicode16(dataStr);
BString nameStr;
dataStr.convert(BSTRType_ANSI);
sscanf(dataStr.getAnsi(),"%s",nameStr.getAnsi());
if(nameStr.getLength() > 68)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "not_valid_name"), player);
return;
}
StructureAsyncCommand command;
command.Command = Structure_Command_RenameStructure;
command.PlayerId = player->getId();
command.StructureId = structure->getId();
gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);
}
示例4: savePlayer
void WorldManager::savePlayer(uint32 accId,bool remove, WMLogOut mLogout, CharacterLoadingContainer* clContainer)
{
PlayerObject* playerObject = getPlayerByAccId(accId);
if(!playerObject) {
DLOG(INFO) << "WorldManager::savePlayer could not find player with AccId:" <<accId<<", save aborted.";
return;
}
// WMQuery_SavePlayer_Position is the query handler called by the buffmanager when all the buffcallbacks are finished
// we prepare the asynccontainer here already
WMAsyncContainer* asyncContainer = new(mWM_DB_AsyncPool.ordered_malloc()) WMAsyncContainer(WMQuery_SavePlayer_Position);
if(remove)
{
asyncContainer->mBool = true;
}
//clarify what handler we have to call after saving - if any
asyncContainer->mObject = playerObject;
asyncContainer->mLogout = mLogout;
asyncContainer->clContainer = clContainer;
switch (mLogout)
{
case WMLogOut_LogOut:
case WMLogOut_Char_Load:
mDatabase->executeSqlAsync(this,asyncContainer,"UPDATE characters SET parent_id=%"PRIu64",oX=%f,oY=%f,oZ=%f,oW=%f,x=%f,y=%f,z=%f,planet_id=%u,jedistate=%u WHERE id=%"PRIu64"",playerObject->getParentId()
,playerObject->mDirection.x,playerObject->mDirection.y,playerObject->mDirection.z,playerObject->mDirection.w
,playerObject->mPosition.x,playerObject->mPosition.y,playerObject->mPosition.z
,mZoneId,playerObject->getJediState(),playerObject->getId());
break;
case WMLogOut_No_LogOut:
case WMLogOut_Zone_Transfer:
//start by saving the buffs the buffmanager will deal with the buffspecific db callbacks and start the position safe at their end
//which will return its callback to the worldmanager
//if no buff was there to be saved we will continue directly
if(playerObject && playerObject->isConnected() && !playerObject->isBeingDestroyed())
{
if(!gBuffManager->SaveBuffsAsync(asyncContainer, this, playerObject, GetCurrentGlobalTick()))
{
// position save will be called by the buff callback if there is any buff
mDatabase->executeSqlAsync(this,asyncContainer,"UPDATE characters SET parent_id=%"PRIu64",oX=%f,oY=%f,oZ=%f,oW=%f,x=%f,y=%f,z=%f,planet_id=%u,jedistate=%u WHERE id=%"PRIu64"",playerObject->getParentId()
,playerObject->mDirection.x,playerObject->mDirection.y,playerObject->mDirection.z,playerObject->mDirection.w
,playerObject->mPosition.x,playerObject->mPosition.y,playerObject->mPosition.z
,mZoneId,playerObject->getJediState(),playerObject->getId());
}
}
break;
default:
DLOG(INFO) << "We should never get in here, make sure to call savePlayer with the enum WMLogOut";
}
}
示例5: removePlayerfromAccountMap
void WorldManager::removePlayerfromAccountMap(uint64 playerID)
{
CreatureObject* creature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(playerID));
if(!creature) {
LOG (error) << "WorldManager::removePlayerfromAccountMap : no player";
return;
}
PlayerObject* player = creature->GetGhost();
if(player) {
PlayerAccMap::iterator playerAccIt = mPlayerAccMap.find(player->getAccountId());
if(playerAccIt != mPlayerAccMap.end()) {
LOG(info) << "Player left [" << player->getId() << "] Total players on zone [" << (getPlayerAccMap()->size() -1) << "]";
mPlayerAccMap.erase(playerAccIt);
}
else
{
LOG(error) << "Error removing player from account map [" << player->getAccountId() << "]";
}
}
else
{
LOG(error) << "Error removing player from account map [" << player->getAccountId() << "]";
}
}
示例6: _handleDisconnectUpdate
bool WorldManager::_handleDisconnectUpdate(uint64 callTime,void* ref)
{
PlayerList::iterator it = mPlayersToRemove.begin();
while(it != mPlayersToRemove.end())
{
PlayerObject* playerObject = (*it);
// we timed out, so save + remove it
if(--*(playerObject->getDisconnectTime()) <= 0 && playerObject->isLinkDead())
{
// reset link dead state
playerObject->togglePlayerFlagOff(PlayerFlag_LinkDead);
playerObject->setConnectionState(PlayerConnState_Destroying);
//remove the player out of his group - if any
GroupObject* group = gGroupManager->getGroupObject(playerObject->getGroupId());
if(group)
{
group->removePlayer(playerObject->getId());
}
//asynch save
savePlayer(playerObject->getAccountId(),true,WMLogOut_LogOut);
it = mPlayersToRemove.erase(it);
}
else
++it;
}
return(true);
}
示例7: handleObjectReady
void StructureManager::handleObjectReady(Object* object,DispatchClient* client)
{
PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);
if(!structure)
{
gLogger->logMsg("StructureManager::handleObjectReady: No structure");
}
if(gWorldManager->getWMState() == WMState_Running)
{
// set timer for deletion of building fence
uint32 account = client->getAccountId();
PlayerObject* player = gWorldManager->getPlayerByAccId(account);
PlayerStructure* fence = gNonPersistantObjectFactory->requestBuildingFenceObject(structure->mPosition.x,structure->mPosition.y,structure->mPosition.z, player);
structure->getTTS()->todo = ttE_BuildingFence;
structure->getTTS()->buildingFence = fence->getId();
structure->getTTS()->playerId = player->getId();
structure->getTTS()->projectedTime = mBuildingFenceInterval + Anh_Utils::Clock::getSingleton()->getLocalTime();
gWorldManager->handleObjectReady(structure,player->getClient());
addStructureforConstruction(structure->getId());
}
else
{
gWorldManager->handleObjectReady(structure,NULL);
}
}
示例8: prepareCustomRadialMenu
void MountObject::prepareCustomRadialMenu(CreatureObject* creature, uint8_t item_count) {
PlayerObject* player = creature->GetGhost();// dynamic_cast<PlayerObject*>(creature);
if (!player) {
// Verify the data passed in is what is expected. In debug mode the assert will
// trigger and crash the server.
assert(false && "MountObject::handleObjectMenuSelect - Menu preparation requested for a non-player object.");
return;
}
// Reset the radial menu with a new instance.
mRadialMenu.reset(new RadialMenu());
// Add the radial options for the custom menu.
mRadialMenu->addItem(1, 0, radId_examine, radAction_Default);
// Check to see if the player requesting the menu is the owner of the mount.
if(player->getId() == owner_) {
// Check to see if the player is mounted or not and display the appropriate exit/enter option.
if(player->checkIfMounted()) {
mRadialMenu->addItem(2, 0, radId_serverVehicleExit,radAction_Default, "@pet/pet_menu:menu_enter_exit");
} else {
mRadialMenu->addItem(2, 0, radId_serverVehicleEnter,radAction_Default, "@pet/pet_menu:menu_enter_exit");
}
mRadialMenu->addItem(3, 0, radId_vehicleStore,radAction_ObjCallback, "@pet/pet_menu:menu_store");
// @TODO: Check if near a garage then add repair
}
}
示例9: savePlayerSync
void WorldManager::savePlayerSync(uint32 accId,bool remove)
{
PlayerObject* playerObject = getPlayerByAccId(accId);
Ham* ham = playerObject->getHam();
mDatabase->destroyResult(mDatabase->executeSynchSql("UPDATE characters SET parent_id=%"PRIu64",oX=%f,oY=%f,oZ=%f,oW=%f,x=%f,y=%f,z=%f,planet_id=%u WHERE id=%"PRIu64"",playerObject->getParentId()
,playerObject->mDirection.x,playerObject->mDirection.y,playerObject->mDirection.z,playerObject->mDirection.w
,playerObject->mPosition.x,playerObject->mPosition.y,playerObject->mPosition.z
,mZoneId,playerObject->getId()));
mDatabase->destroyResult(mDatabase->executeSynchSql("UPDATE character_attributes SET health_current=%u,action_current=%u,mind_current=%u"
",health_wounds=%u,strength_wounds=%u,constitution_wounds=%u,action_wounds=%u,quickness_wounds=%u"
",stamina_wounds=%u,mind_wounds=%u,focus_wounds=%u,willpower_wounds=%u,battlefatigue=%u,posture=%u,moodId=%u,title=\'%s\'"
",character_flags=%u,states=%"PRIu64",language=%u, group_id=%"PRIu64" WHERE character_id=%"PRIu64"",
ham->mHealth.getCurrentHitPoints() - ham->mHealth.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM
ham->mAction.getCurrentHitPoints() - ham->mAction.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM
ham->mMind.getCurrentHitPoints() - ham->mMind.getModifier(), //Llloydyboy Added the -Modifier so that when buffs are reinitialised, it doesn't screw up HAM
ham->mHealth.getWounds(),
ham->mStrength.getWounds(),
ham->mConstitution.getWounds(),
ham->mAction.getWounds(),
ham->mQuickness.getWounds(),
ham->mStamina.getWounds(),
ham->mMind.getWounds(),
ham->mFocus.getWounds(),
ham->mWillpower.getWounds(),
ham->getBattleFatigue(),
playerObject->states.getPosture(),
playerObject->getMoodId(),
playerObject->getTitle().getAnsi(),
playerObject->getPlayerFlags(),
playerObject->states.getAction(),
playerObject->getLanguage(),
playerObject->getGroupId(),
playerObject->getId()));
gBuffManager->SaveBuffs(playerObject, GetCurrentGlobalTick());
if(remove)
destroyObject(playerObject);
}
示例10: onObjectEnter
void CampRegion::onObjectEnter(Object* object) {
if (object->getType() != ObjType_Player) {
return;
}
PlayerObject* visitor = dynamic_cast<PlayerObject*>(object);
if (!visitor) {
return;
}
if (!addVisitor(visitor)) {
return;
}
auto it = std::find_if(links.begin(), links.end(), [=] (campLink* link) {
return link->objectID == visitor->getId();
});
if (it != links.end()) {
campLink* temp = new campLink;
temp->objectID = visitor->getId();
temp->lastSeenTime = gWorldManager->GetCurrentGlobalTick();
temp->tickCount = 0;
links.push_back(temp);
}
PlayerObject* owner = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(mOwnerId));
if (owner && (owner->getId() != visitor->getId())) {
std::string text = "You have entered " + this->getCampOwnerName() + "'s camp.";
gMessageLib->SendSystemMessage(std::wstring(text.begin(), text.end()).c_str(), visitor);
} else {
//ensure it's not time to destroy the camp
mAbandoned = false;
}
}
示例11: _processIsmInviteRequest
void GroupManager::_processIsmInviteRequest(Message* message)
{
PlayerObject* sender = gWorldManager->getPlayerByAccId(message->getUint32()); // the player who sent the invite
PlayerObject* target = gWorldManager->getPlayerByAccId(message->getUint32()); // the player who will recieve it
if(sender == NULL || target == NULL)
{
gLogger->logMsg("GroupManager::_processIsmInviteRequest PlayerAccId not found");
return;
}
//target->setGroupId(message->getUint64()); // the group id provided by the chatserver
gMessageLib->sendInviteSenderUpdateDeltasCreo6(sender->getId(),target);
}
示例12: _handleRemoveFriend
void ObjectController::_handleRemoveFriend(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if(player->getContactListUpdatePending())
return;
else
player->setContactListUpdatePending(true);
string friendName;
int8 sql[1024],end[16],*sqlPointer;
message->getStringUnicode16(friendName);
friendName.convert(BSTRType_ANSI);
if(!friendName.getLength())
{
player->setContactListUpdatePending(false);
return;
}
if(player->isConnected())
gMessageLib->sendHeartBeat(player->getClient());
friendName.toLower();
if(!player->checkFriendList(friendName.getCrc()))
{
player->setContactListUpdatePending(false);
return;
}
ObjControllerAsyncContainer* asyncContainer = new(mDBAsyncContainerPool.malloc()) ObjControllerAsyncContainer(OCQuery_RemoveFriend);
asyncContainer->mString = friendName.getAnsi();
sprintf(sql,"SELECT sf_removeFriend(%"PRIu64",'",player->getId());
sprintf(end,"')");
sqlPointer = sql + strlen(sql);
sqlPointer += mDatabase->Escape_String(sqlPointer,friendName.getAnsi(),friendName.getLength());
strcat(sql,end);
mDatabase->ExecuteSqlAsync(this,asyncContainer,sql);
}
示例13: _handleMount
void ObjectController::_handleMount(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// The very idea with using ID's instead of object refs are that you can TEST them without using the object itself.
// And some parameter validation...
if (targetId == 0)
{
DLOG(info) << "ObjectController::_handleMount : Cannot find vehicle ID :(";
return;
}
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (player && player->getMount() && (player->getParentId() == 0))
{
// Do we have a valid target?
if (!player->checkIfMounted())
{
// verify its player's mount
MountObject* pet = dynamic_cast<MountObject*>(gWorldManager->getObjectById(targetId));
if (pet && (pet->owner() == player->getId()))
{
// get the mount Vehicle object by the id (Creature object id - 1 )
if(VehicleController* vehicle = dynamic_cast<VehicleController*>(gWorldManager->getObjectById(pet->controller())))
{
//The /mount command can work up to 32m on live
if(glm::distance(vehicle->body()->mPosition, player->mPosition) <= 32) {
//change locomotion
vehicle->MountPlayer();
} else {
gMessageLib->SendSystemMessage(L"Your target is too far away to mount.", player);
}
}
else
{
DLOG(info) << "ObjectController::_handleMount : Cannot find vehicle";
}
}
} else {
gMessageLib->SendSystemMessage(L"You cannot mount this because you are already mounted.", player);
}
}
}
示例14: _handleSetBiography
void ObjectController::_handleSetBiography(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
BString bio;
int8 sql[5000],end[64],*sqlPointer;
message->getStringUnicode16(bio);
player->setBiography(bio);
bio.convert(BSTRType_ANSI);
sprintf(sql,"UPDATE %s.character_biography SET biography ='",mDatabase->galaxy());
sprintf(end,"' WHERE character_id = %" PRIu64 "",player->getId());
sqlPointer = sql + strlen(sql);
sqlPointer += mDatabase->escapeString(sqlPointer,bio.getAnsi(),bio.getLength());
strcat(sql,end);
mDatabase->executeAsyncSql(sql);
}
示例15: _handleDismount
void ObjectController::_handleDismount(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
// The very idea with using ID's instead of object refs are that you can TEST them without using the object itself.
// And some parameter validation...
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (player && player->getMount() && (player->getParentId() == 0))
{
if (player->checkIfMounted())
{
// verify its player's mount
MountObject* pet = NULL;
if (targetId == 0)
{
// No object targeted, assume the one we are riding. - what else should we dismount ???
pet = player->getMount();
}
else
{
pet = dynamic_cast<MountObject*>(gWorldManager->getObjectById(targetId));
}
if (pet && (pet->owner() == player->getId()))
{
// get the pets controller for a swoop its the vehicle
if(VehicleController* vehicle = dynamic_cast<VehicleController*>(gWorldManager->getObjectById(pet->controller())))
{
vehicle->DismountPlayer();
}
}
}
else
{
gMessageLib->SendSystemMessage(L"You are not mounted to perform this action.", player);
}
}
}