本文整理汇总了C++中PlayerObject::getEquipManager方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::getEquipManager方法的具体用法?C++ PlayerObject::getEquipManager怎么用?C++ PlayerObject::getEquipManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::getEquipManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handleFindFriendDBReply
void ObjectController::_handleFindFriendDBReply(uint64 retCode,string friendName)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
friendName.convert(BSTRType_Unicode16);
if(retCode == 0)
{
gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed_noname","","",L"",0,"","",friendName.getUnicode16());
return;
}
PlayerObject* searchObject = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(retCode));
if(!searchObject)
{
gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
return;
}
//are we on our targets friendlist???
if(!searchObject->checkFriendList(player->getFirstName().getCrc()))
{
gMessageLib->sendSystemMessage(player,L"","cmnty","friend_location_failed","","",L"",0,"","",friendName.getUnicode16());
return;
}
Datapad* thePad = dynamic_cast<Datapad*>(searchObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
if(thePad && thePad->getCapacity())
{
//the datapad automatically checks for waypoint caspacity and gives the relevant error messages
thePad->requestNewWaypoint(searchObject->getFirstName().getAnsi(),searchObject->mPosition,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
}
}
示例2: handleObjectReady
void VehicleFactory::handleObjectReady(Object* object,DispatchClient* client)
{
if(Vehicle* vehicle = dynamic_cast<Vehicle*>(object))
{
PlayerObject* player = gWorldManager->getPlayerByAccId(client->getAccountId());
if(player)
{
vehicle->setOwner(player);
if(Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad)))
{
datapad->addData(vehicle);
gWorldManager->addObject(vehicle,true);
//spawn it in the player's datapad
gMessageLib->sendCreateInTangible(vehicle, datapad->getId(), player);
//now spawn it in the world
vehicle->call();
}
}
}
}
示例3: createInWorld
void SpatialIndexManager::createInWorld(Object* object)
{
uint32 baseCell = 0xffffffff;
//get parent object determine who to send creates for
if(object->getParentId() == 0) {
//just create in the SI - it will keep track of nearby players
this->_AddObject(object);
return;
}
Object* parent = gWorldManager->getObjectById(object->getParentId());
//start with equipped items
if(parent->getType() == ObjType_Player) {
PlayerObject* player = static_cast<PlayerObject*>(parent);
//add to equiplist manually yet we dont use the objectcontainer for equipped items yet
player->getEquipManager()->addEquippedObject(object);
gContainerManager->createObjectToRegisteredPlayers(parent, object);
//sendCreateObject(object,player,false);
gContainerManager->updateEquipListToRegisteredPlayers(player);
return;
}
if(parent) {
//items in containers
gContainerManager->createObjectToRegisteredPlayers(parent, object);
return;
}
assert(false && "No valid parent");
}
示例4: _processPlayerMoneyRequest
void CharSheetManager::_processPlayerMoneyRequest(Message* message,DispatchClient* client)
{
PlayerObject* player = gWorldManager->getPlayerByAccId(client->getAccountId());
if(player == NULL)
{
DLOG(info) << "CharSheetManager::_processPlayerMoneyRequest: could not find player " << client->getAccountId();
return;
}
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opPlayerMoneyResponse);
gMessageFactory->addUint32(dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank))->credits());
gMessageFactory->addUint32(dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits());
Message* newMessage = gMessageFactory->EndMessage();
client->SendChannelA(newMessage,client->getAccountId(),CR_Client,3);
}
示例5: _handleDestroyInstrument
void ObjectController::_handleDestroyInstrument(Item* item)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Item* tempInstrument = NULL;
Item* permanentInstrument = NULL;
// first, stop playing, if its currently in use
if(playerObject->getPerformingState() == PlayerPerformance_Music)
{
// equipped instrument
if(item == dynamic_cast<Item*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Instrument))
|| playerObject->getPlacedInstrumentId())
{
gEntertainerManager->stopEntertaining(playerObject);
}
}
// handle destruction of instanced instruments, placed in world
if(playerObject->getPlacedInstrumentId())
{
// get the instruments
tempInstrument = dynamic_cast<Item*>(gWorldManager->getObjectById(playerObject->getPlacedInstrumentId()));
if(!tempInstrument)
{
gLogger->logMsg("ObjectController::handleDestroyInstrument : no temporary Instrument\n");
return;
}
permanentInstrument = dynamic_cast<Item*>(gWorldManager->getObjectById(tempInstrument->getPersistantCopy()));
if(!permanentInstrument)
{
gLogger->logMsg("ObjectController::handleDestroyInstrument : no parent Instrument\n");
return;
}
// the temporary gets ALWAYS deleted
// update the attributes of the permanent Instrument
if(tempInstrument == item)
{
permanentInstrument->setPlaced(false);
permanentInstrument->setNonPersistantCopy(0);
playerObject->setPlacedInstrumentId(0);
}
// it is the permanent Instrument delete the temporary copy too
else if(permanentInstrument == item)
{
destroyObject(tempInstrument->getId());
}
}
}
示例6: itemExist
//=============================================================================
bool Inventory::itemExist(uint32 familyId, uint32 typeId)
{
bool found = false;
ObjectIDList::iterator invObjectIt = getObjects()->begin();
// Items inside inventory and child objects.
while (invObjectIt != getObjects()->end())
{
Object* object = getObjectById(*invObjectIt);
Item* item = dynamic_cast<Item*>(object);
if (item)
{
if ((item->getItemFamily() == familyId) && (item->getItemType() == typeId))
{
found = true;
break;
}
}
invObjectIt++;
}
if (!found)
{
// Items equipped by the player.
PlayerObject* player = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(this->getParentId()));
if(!player)
return found;
ObjectList* objList = player->getEquipManager()->getEquippedObjects();
ObjectList::iterator equippedObjectIt = objList->begin();
while (equippedObjectIt != objList->end())
{
Object* object = (*equippedObjectIt);
Item* item = dynamic_cast<Item*>(object);
if (item)
{
if ((item->getItemFamily() == familyId) && (item->getItemType() == typeId))
{
found = true;
break;
}
}
equippedObjectIt++;
}
delete objList;
}
return found;
}
示例7: sendGroupMissionUpdate
void GroupManager::sendGroupMissionUpdate(GroupObject* group)
{
// this procedure ensures, that in case of a change in the mission pool of the group
// all players get updated Mission waypoints
// it concerns all players of the group on the zone, but not on other zones
//get us the mission nearest to the most players on the Zone
MissionObject* mission = getZoneGroupMission(group->getPlayerList());
if(!mission)
return;
//now set the GroupWaypoint for all onZone groupmembers
Uint64List::iterator playerListIt = group->getPlayerList()->begin();
while(playerListIt != group->getPlayerList()->end())
{
PlayerObject* player = dynamic_cast<PlayerObject*> (gWorldManager->getObjectById((*playerListIt)));
Datapad* datapad = dynamic_cast<Datapad*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Datapad));
WaypointObject* waypoint = datapad->getWaypointByName("@group:groupwaypoint");
// remove the old one
if(waypoint)
{
gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateAdd,player);
datapad->removeWaypoint(waypoint);
gObjectFactory->deleteObjectFromDB(waypoint);
}
else
// create a new one
if(datapad->getCapacity())
{
datapad->requestNewWaypoint("@group:groupwaypoint",mission->getDestination().Coordinates,static_cast<uint16>(gWorldManager->getZoneId()),Waypoint_blue);
gMessageLib->sendSystemMessage(player,L"","group","groupwaypoint");
}
playerListIt++;
}
}
示例8: handleUIEvent
void BankTerminal::handleUIEvent(BString strInventoryCash, BString strBankCash, UIWindow* window)
{
if(window == NULL)
{
return;
}
PlayerObject* playerObject = window->getOwner(); // window owner
if(playerObject == NULL || !playerObject->isConnected() || playerObject->getSamplingState() || playerObject->isIncapacitated() || playerObject->isDead() || playerObject->checkState(CreatureState_Combat))
{
return;
}
// two money movement deltas stands for credits
// variations into bank & inventory.
// casting as signed cause one will be negative.
// when inventoryDelta + bankDelta is not equal to zero,
// that means player treasury has changed since
// the transfer window opened.
// we get the money deltas by parsing the string returned
// by the SUI window
strInventoryCash.convert(BSTRType_ANSI);
strBankCash.convert(BSTRType_ANSI);
int32 inventoryMoneyDelta = atoi(strInventoryCash.getAnsi()) - dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits();
int32 bankMoneyDelta = atoi(strBankCash.getAnsi()) - dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank))->getCredits();
// the amount transfered must be greater than zero
if(bankMoneyDelta == 0 || inventoryMoneyDelta == 0)
{
return;
}
gTreasuryManager->bankTransfer(inventoryMoneyDelta, bankMoneyDelta, playerObject);
}
示例9: _handlePurchaseTicket
void ObjectController::_handlePurchaseTicket(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
BString dataStr;
BStringVector dataElements;
uint16 elements;
float purchaseRange = gWorldConfig->getConfiguration<float>("Player_TicketTerminalAccess_Distance",(float)10.0);
if(playerObject->states.getPosture() == CreaturePosture_SkillAnimating)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return;
}
//however we are able to use the purchaseticket command in starports
//without having to use a ticketvendor by just giving commandline parameters
//when we are *near* a ticket vendor
TravelTerminal* terminal = dynamic_cast<TravelTerminal*> (gWorldManager->getNearestTerminal(playerObject,TanType_TravelTerminal));
// iterate through the results
if((!terminal)|| (glm::distance(terminal->mPosition, playerObject->mPosition) > purchaseRange))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "too_far"), playerObject);
return;
}
playerObject->setTravelPoint(terminal);
message->getStringUnicode16(dataStr);
// Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
// Either do the conversion HERE, or better fix the split so it handles unicoe also.
dataStr.convert(BSTRType_ANSI);
elements = dataStr.split(dataElements,' ');
if(elements < 4)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "route_not_available"), playerObject);
return;
}
// get price and planet ids
TicketProperties ticketProperties;
gTravelMapHandler->getTicketInformation(dataElements,&ticketProperties);
if(!ticketProperties.dstPoint)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "route_not_available"), playerObject);
return;
}
uint8 roundTrip = 0;
if(elements > 4)
roundTrip = atoi(dataElements[4].getAnsi());
if(dataElements[4].getCrc() == BString("single").getCrc())
roundTrip = 0;
//how many tickets will it be?
uint32 amount = 1;
if(roundTrip)
amount = 2;
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Bank* bank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
if(!inventory->checkSlots(static_cast<uint8>(amount)))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "inv_full"), playerObject);
return;
}
if(roundTrip == 1)
{
ticketProperties.price *= 2;
}
// update bank or inventory credits
if(!(inventory->updateCredits(-ticketProperties.price)))
{
if(!(bank->updateCredits(-ticketProperties.price)))
{
//gMessageLib->sendSystemMessage(entertainer,L"","travel","route_not_available");
gUIManager->createNewMessageBox(NULL,"ticketPurchaseFailed","The Galactic Travel Commission","You do not have enough money to complete the ticket purchase.",playerObject);
return;
}
}
if(playerObject->isConnected())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_pay_acct_success", "", "", "", "", "money/acct_n", "travelsystem", ticketProperties.price), playerObject);
gObjectFactory->requestNewTravelTicket(inventory,ticketProperties,inventory->getId(),99);
//.........这里部分代码省略.........
示例10: _handleTransferItemMisc
void ObjectController::_handleTransferItemMisc(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
//we need to make sure that ONLY equipped items are contained by the player
//all other items are contained by the inventory!!!!!!!!
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Object* itemObject = gWorldManager->getObjectById(targetId);
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
BString dataStr;
uint64 targetContainerId;
uint32 linkType;
float x,y,z;
CellObject* cell;
message->getStringUnicode16(dataStr);
if(swscanf(dataStr.getUnicode16(),L"%" WidePRIu64 L" %u %f %f %f",&targetContainerId,&linkType,&x,&y,&z) != 5)
{
DLOG(info) << "ObjController::_handleTransferItemMisc: Error in parameters";
return;
}
if (!itemObject)
{
DLOG(warning) << "ObjController::_handleTransferItemMisc: No Object to transfer :(";
return;
}
TangibleObject* tangible = dynamic_cast<TangibleObject*>(itemObject);
if(!tangible)
{
//no tagible - get out of here
DLOG(warning) << "ObjController::_handleTransferItemMisc: No tangible to transfer :(";
return;
}
//get our containers
Object* newContainer = gWorldManager->getObjectById(targetContainerId);
Object* oldContainer = gWorldManager->getObjectById(tangible->getParentId());
DLOG(info) << "ObjController::_handleTransferItemMisc: parameters";
DLOG(info) << "ObjController::_handleTransferItemMisc: newcontainer : " << targetContainerId;
DLOG(info) << "ObjController::_handleTransferItemMisc: oldcontainer : " << tangible->getParentId();
DLOG(info) << "ObjController::_handleTransferItemMisc: linktype : " << linkType;
// We may want to transfer other things than items...basically tangibleObjects!
// resourcecontainers / factory crates
// first check whether its an instrument with persistant copy - thats a special case!
Item* item = dynamic_cast<Item*>(itemObject);
if (item)
{
//check if its only temporarily placed
if(item->getItemFamily() == ItemFamily_Instrument)
{
if(item->getPersistantCopy())
{
// gMessageLib->sendSystemMessage(playerObject,L"you cannot pick this up");
// You bet, I can! Remove the temp instrument from the world.
// Do I have access to this instrument?
if (item->getOwner() == playerObject->getId())
{
playerObject->getController()->destroyObject(targetId);
}
return;
}
}
}
// A FYI: When we drop items, we use player pos.
itemObject->mPosition = glm::vec3(x,y,z);
if (!targetContainerId)
{
DLOG(info) << "ObjController::_handleTransferItemMisc:TargetContainer is 0 :(";
//return;
}
//ok how to tackle this ... :
//basically I want to use ObjectContainer as standard access point for item handling!
//so far we have different accesses for Objects on the player and for the inventory and for ContainerObjects and for cells ...
//lets begin by getting the target Object
if(!checkTargetContainer(targetContainerId,itemObject))
{
DLOG(info) << "ObjController::_handleTransferItemMisc:TargetContainer is not valid :(";
return;
}
if(!checkContainingContainer(tangible->getParentId(), playerObject->getId()))
{
DLOG(info) << "ObjController::_handleTransferItemMisc:ContainingContainer is not allowing the transfer :(";
//.........这里部分代码省略.........
示例11: removeFromContainer
bool ObjectController::removeFromContainer(uint64 targetContainerId, uint64 targetId)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Object* itemObject = gWorldManager->getObjectById(targetId);
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
TangibleObject* targetContainer = dynamic_cast<TangibleObject*>(gWorldManager->getObjectById(targetContainerId));
TangibleObject* tangible = dynamic_cast<TangibleObject*>(itemObject);
Item* item = dynamic_cast<Item*>(itemObject);
// its us
if (tangible->getParentId() == playerObject->getId())
{
// unequip it
return playerObject->getEquipManager()->unEquipItem(itemObject);
}
//the containerObject is the container used in the tutorial or some random dungeon container
Container* container = dynamic_cast<Container*>(gWorldManager->getObjectById(tangible->getParentId()));
if (container)
{
container->removeObject(itemObject);
//gContainerManager->destroyObjectToRegisteredPlayers(container, tangible->getId());
if (gWorldConfig->isTutorial())
{
playerObject->getTutorial()->transferedItemFromContainer(targetId, tangible->getParentId());
// If object is owned by player (private owned for instancing), we remove the owner from the object.
// what is this used for ???
if (itemObject->getPrivateOwner() == playerObject->getId())
{
itemObject->setPrivateOwner(0);
}
}
return true;
}
//creature inventories are a special case - their items are temporary!!! we cannot loot them directly
CreatureObject* unknownCreature;
Inventory* creatureInventory;
if (itemObject->getParentId() &&
(unknownCreature = dynamic_cast<CreatureObject*>(gWorldManager->getObjectById(itemObject->getParentId() - INVENTORY_OFFSET))) &&
(creatureInventory = dynamic_cast<Inventory*>(unknownCreature->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))) &&
(creatureInventory->getId() == itemObject->getParentId()) && (creatureInventory->getId() != inventory->getId()))
{
if(!creatureInventory->removeObject(itemObject))
{
LOG(warning) << "ObjectController::removeFromContainer: Internal Error could not remove " << itemObject->getId() << " from creature inventory " << creatureInventory->getId();
return false;
}
// we destroy the item in this case as its a temporary!!
// we do not want to clog the db with unlooted items
gContainerManager->destroyObjectToRegisteredPlayers(creatureInventory, tangible->getId());
ObjectIDList* invObjList = creatureInventory->getObjects();
if (invObjList->size() == 0)
{
// Put this creature in the pool of delayed destruction and remove the corpse from scene.
gWorldManager->addCreatureObjectForTimedDeletion(creatureInventory->getParentId(), LootedCorpseTimeout);
}
if (gWorldConfig->isTutorial())
{
// TODO: Update tutorial about the loot.
playerObject->getTutorial()->transferedItemFromContainer(targetId, creatureInventory->getId());
}
//bail out here and request the item over the db - as the item in the NPC has a temporary id and we dont want that in the db
// This ensure that we do not use/store any of the temp id's in the database.
gObjectFactory->requestNewDefaultItem(inventory, item->getItemFamily(), item->getItemType(), inventory->getId(), 99, glm::vec3(), "");
return false;
}
//cells are NOT tangibles - thei are static Objects
CellObject* cell;
if(cell = dynamic_cast<CellObject*>(gWorldManager->getObjectById(itemObject->getParentId())))
{
// Stop playing if we pick up the (permanently placed) instrument we are playing
if (item && (item->getItemFamily() == ItemFamily_Instrument))
{
uint32 instrumentType = item->getItemType();
if ((instrumentType == ItemType_Nalargon) || (instrumentType == ItemType_omni_box) || (instrumentType == ItemType_nalargon_max_reebo))
{
// It's a placeable original instrument.
// Are we targeting the instrument we actually play on?
if (playerObject->getActiveInstrumentId() == item->getId())
{
gEntertainerManager->stopEntertaining(playerObject);
}
}
}
//.........这里部分代码省略.........
示例12: checkTargetContainer
bool ObjectController::checkTargetContainer(uint64 targetContainerId, Object* object)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
TangibleObject* tangibleItem = dynamic_cast<TangibleObject*>(object);
//if its a backpack etc we want to know how many items are in it!
uint32 objectSize = tangibleItem->getHeadCount();
//********************
//this is a special case as we are equipping the item
//so handle it separately
if(playerObject->getId() == targetContainerId)
{
//check for equip restrictions!!!!
//we cant drop that check - further down we assume that the transfer is accepted
// a failing equip will just loose us our item in the receiving container and crash the server in the end
return playerObject->getEquipManager()->CheckEquipable(object);
}
//*****************************
//ok everything else is a tangible Object
Object* targetContainer = gWorldManager->getObjectById(targetContainerId);
//sanity check -
if(!targetContainer)
{
//inventory is NOT part of the main ObjectMap - everything else should be in there
if(inventory && (inventory->getId() != targetContainerId))
{
return false;
}
if(inventory)
targetContainer = dynamic_cast<TangibleObject*>(inventory);
else
{
DLOG(info) << "ObjController::_handleTransferItemMisc: TargetContainer is NULL and not an inventory :(";
return false;
}
}
//====================================================================00
//check access permissions first
bool access = false;
bool fit = false;
//********************
//The tutorial Container is a special case
//so handle it separately
Container* container = dynamic_cast<Container*>(targetContainer );
if (container)
{
if (gWorldConfig->isTutorial())
{
// We don't allow users to place item in the container.
// gMessageLib->sendSystemMessage(playerObject,L"","event_perk","chest_can_not_add");
gMessageLib->SendSystemMessage(L"",playerObject,"error_message","remove_only");
return false;
}
}
//********************
//Factory Outputhopper is retrieve only
//access has been granted through the UI already
TangibleObject* tangibleContainer = dynamic_cast<TangibleObject*>(targetContainer);
if((tangibleContainer)&&(strcmp(tangibleContainer->getName().getAnsi(),"ingredient_hopper")==0))
{
//do we have access rights to the factories hopper?? this would have to be checked asynchronously
//for now we can only access the hoppers UI through the client and checking our permission so its proven already
//a hacker might in theory exploit this, though factories items should only be in memory when someone accesses the hopper
access = true;
}
//====================================================================================
//get the mainOwner of the container - thats a building or a player or an inventory
//
uint64 ownerId = gSpatialIndexManager->getObjectMainParent(targetContainer);
Object* objectOwner = dynamic_cast<Object*>(gWorldManager->getObjectById(ownerId));
if(BuildingObject* building = dynamic_cast<BuildingObject*>(objectOwner))
{
if(building->hasAdminRights(playerObject->getId()))
{
access = true;
//do we have enough room ?
if(building->checkCapacity(objectSize))
{
//*****************************
//if it is the House wé dont need to check a containers capacity further down
if(!tangibleContainer) //mainly as the container might not exist if its placed in the house directly
return true;
if(tangibleContainer->checkCapacity(objectSize,playerObject))
return true;
//.........这里部分代码省略.........
示例13: handleUIEvent
void InsuranceTerminal::handleUIEvent(uint32 action,int32 element,string inputStr,UIWindow* window)
{
// gLogger->logMsgF("InsuranceTerminal::handleUIEvent You are here!",MSG_NORMAL);
if(window == NULL)
{
return;
}
PlayerObject* playerObject = window->getOwner(); // window owner
if(playerObject == NULL || !playerObject->isConnected() || playerObject->getSamplingState() || playerObject->isIncapacitated() || playerObject->isDead()|| playerObject->checkState(CreatureState_Combat))
{
return;
}
switch(window->getWindowType())
{
case SUI_Window_Insurance_Newbie_MessageBox: // Tried to insure item when still having free rounds left.
{
switch(action)
{
case 0: // Yes
{
// Player selected to continue with insurance of item even if no need for.
// gLogger->logMsgF("SUI_Window_Insurance_Newbie_MessageBox Yes",MSG_NORMAL);
// Build the items list and optional use error-messages if needed.
BStringVector insuranceList;
this->getUninsuredItems(playerObject, &insuranceList);
// We should display all uninsured items that can be insured, and that are wearing or carrying in our inventory.
// Items in backpackage or in other containers within our inventory shall also be handled.
gUIManager->createNewListBox(this,"insure","@sui:mnu_insure","Select an item to insure.",insuranceList,playerObject,SUI_Window_Insurance_ListBox, SUI_MB_OKCANCEL);
}
break;
case 1: // No
{
// Player selected to abort, since all items are still treated as insured.
// gLogger->logMsgF("SUI_Window_Insurance_Newbie_MessageBox No",MSG_NORMAL);
}
break;
default:
{
gLogger->logMsgF("SUI_Window_Insurance_Newbie_MessageBox Invalid selection!",MSG_NORMAL);
}
break;
}
}
break;
case SUI_Window_Insurance_ListBox:
{
switch (action)
{
case 0: // OK
{
// Insure one item.
// gLogger->logMsgF("SUI_Window_Insurance_ListBox OK",MSG_NORMAL);
Inventory* inventoryObject = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Bank* bankObject = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
if(!inventoryObject || !bankObject)
return;
int32 creditsInInventory = inventoryObject->getCredits();
int32 creditsAtBank = bankObject->getCredits();
if (mSortedInsuranceList.size() == 0)
{
// You have no insurable items.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "no_insurables");
}
else if (element > (int32)mSortedInsuranceList.size() - 1 || element < 0)
{
// Unable to process insure item request.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "bad_insure_request");
}
else
{
string selectedItemm((mSortedInsuranceList.at(element).first).getAnsi());
selectedItemm.convert(BSTRType_Unicode16);
Object* object = gWorldManager->getObjectById(mSortedInsuranceList.at(element).second);
if (!object)
{
// Invalid object.
// Insure attempt failed.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "insure_fail");
break;
}
TangibleObject* tangibleObject = dynamic_cast<TangibleObject*>(object);
if (!tangibleObject)
{
// Not a tangible object.
// Insure attempt failed.
gMessageLib->sendSystemMessage(playerObject, L"", "error_message", "insure_fail");
//.........这里部分代码省略.........
示例14: handleUIEvent
void PlayerStructure::handleUIEvent(BString strCharacterCash, BString strHarvesterCash, UIWindow* window)
{
PlayerObject* player = window->getOwner();
if(!player)
{
return;
}
switch(window->getWindowType())
{
case SUI_Window_Deposit_Power:
{
strCharacterCash.convert(BSTRType_ANSI);
BString characterPower = strCharacterCash;
strHarvesterCash.convert(BSTRType_ANSI);
BString harvesterPower = strHarvesterCash;
int32 harvesterPowerDelta = atoi(harvesterPower.getAnsi());
gStructureManager->deductPower(player,harvesterPowerDelta);
this->setCurrentPower(getCurrentPower()+harvesterPowerDelta);
gWorldManager->getDatabase()->executeSqlAsync(0,0,"UPDATE %s.structure_attributes SET value='%u' WHERE structure_id=%" PRIu64 " AND attribute_id=384",gWorldManager->getDatabase()->galaxy(),getCurrentPower(),this->getId());
}
break;
case SUI_Window_Pay_Maintenance:
{
strCharacterCash.convert(BSTRType_ANSI);
strHarvesterCash.convert(BSTRType_ANSI);
Bank* bank = dynamic_cast<Bank*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
Inventory* inventory = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
int32 bankFunds = bank->credits();
int32 inventoryFunds = inventory->getCredits();
int32 funds = inventoryFunds + bankFunds;
int32 characterMoneyDelta = atoi(strCharacterCash.getAnsi()) - funds;
int32 harvesterMoneyDelta = atoi(strHarvesterCash.getAnsi()) - this->getCurrentMaintenance();
// the amount transfered must be greater than zero
if(harvesterMoneyDelta == 0 || characterMoneyDelta == 0)
{
return;
}
//lets get the money from the bank first
if((bankFunds +characterMoneyDelta)< 0)
{
characterMoneyDelta += bankFunds;
bankFunds = 0;
inventoryFunds += characterMoneyDelta;
}
else
{
bankFunds += characterMoneyDelta;
}
if(inventoryFunds < 0)
{
return;
}
int32 maintenance = this->getCurrentMaintenance() + harvesterMoneyDelta;
if(maintenance < 0)
{
return;
}
bank->credits(bankFunds);
inventory->setCredits(inventoryFunds);
gWorldManager->getDatabase()->destroyResult(gWorldManager->getDatabase()->executeSynchSql("UPDATE %s.banks SET credits=%u WHERE id=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),bank->credits(),bank->getId()));
gWorldManager->getDatabase()->destroyResult(gWorldManager->getDatabase()->executeSynchSql("UPDATE %s.inventories SET credits=%u WHERE id=%" PRIu64 "",gWorldManager->getDatabase()->galaxy(),inventory->getCredits(),inventory->getId()));
//send the appropriate deltas.
gMessageLib->sendInventoryCreditsUpdate(player);
gMessageLib->sendBankCreditsUpdate(player);
//get the structures conditiondamage and see whether it needs repair
uint32 damage = this->getDamage();
if(damage)
{
uint32 cost = this->getRepairCost();
uint32 all = cost*damage;
if(maintenance <= (int32)all)
{
all -= (uint32)maintenance;
damage = (uint32)(all/cost);
maintenance = 0;
}
//.........这里部分代码省略.........
示例15: _handleResourceContainerSplit
void ObjectController::_handleResourceContainerSplit(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
ResourceContainer* selectedContainer = dynamic_cast<ResourceContainer*>(gWorldManager->getObjectById(targetId));
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
gLogger->logMsgF("ObjectController::_handleResourceContainerSplit: Container : %I64u",MSG_NORMAL,targetId);
if(!selectedContainer)
{
gLogger->logMsg("ObjectController::_handleResourceContainerSplit: Container does not exist!");
return;
}
string dataStr;
message->getStringUnicode16(dataStr);
dataStr.convert(BSTRType_ANSI);
BStringVector dataElements;
uint16 elementCount = dataStr.split(dataElements,' ');
if(!elementCount)
{
gLogger->logMsg("ObjectController::_handleResourceContainerSplit: Error in requestStr");
return;
}
uint32 splitOffAmount = boost::lexical_cast<uint32>(dataElements[0].getAnsi());
uint64 parentId = boost::lexical_cast<uint64>(dataElements[1].getAnsi());
if(selectedContainer->getParentId() == inventory->getId())
{
//check if we can fit an additional resource container in our inventory
if(!inventory->checkSlots(1))
{
gMessageLib->sendSystemMessage(playerObject,L"","error_message","inv_full");
return;
}
mDatabase->ExecuteSqlAsync(NULL,NULL,"UPDATE resource_containers SET amount=%u WHERE id=%"PRIu64"",selectedContainer->getAmount(),selectedContainer->getId());
// create a new one
// update selected container contents
selectedContainer->setAmount(selectedContainer->getAmount() - splitOffAmount);
gMessageLib->sendResourceContainerUpdateAmount(selectedContainer,playerObject);
gObjectFactory->requestNewResourceContainer(inventory,(selectedContainer->getResource())->getId(),parentId,99,splitOffAmount);
return;
}
Item* item = dynamic_cast<Item*>(gWorldManager->getObjectById(parentId));
if(!item)
{
gLogger->logMsg("ObjectController::_ExtractObject: resourcecontainers parent does not exist!");
assert(false && "ObjectController::_ExtractObject resourcecontainers parent does not exist");
return;
}
if(!item->checkCapacity())
{
//check if we can fit an additional item in our inventory
gMessageLib->sendSystemMessage(playerObject,L"","container_error_message","container3");
return;
}
// update selected container contents
selectedContainer->setAmount(selectedContainer->getAmount() - splitOffAmount);
gMessageLib->sendResourceContainerUpdateAmount(selectedContainer,playerObject);
gObjectFactory->requestNewResourceContainer(item,(selectedContainer->getResource())->getId(),parentId,99,splitOffAmount);
}