void ChatMessageLib::sendChatOnUnBanAvatarFromRoom(DispatchClient* client, BString galaxy, BString sender, BString target, Channel* channel, uint32 requestId) const { ChatAvatarIdList::iterator iter = channel->getUserList()->begin(); #ifdef DISP_REAL_FIRST_NAME #else sender.toLower(); target.toLower(); #endif while (iter != channel->getUserList()->end()) { gMessageFactory->StartMessage(); gMessageFactory->addUint32(opChatOnUnbanAvatarFromRoom); gMessageFactory->addString(channel->getFullPath()); gMessageFactory->addString(SWG); gMessageFactory->addString(galaxy); gMessageFactory->addString(sender); gMessageFactory->addString(SWG); gMessageFactory->addString(channel->getGalaxy()); gMessageFactory->addString(target); gMessageFactory->addUint32(0); gMessageFactory->addUint32(((*iter)->getPlayer()->getClient() == client) ? requestId : 0); Message* message = gMessageFactory->EndMessage(); (*iter)->getPlayer()->getClient()->SendChannelA(message, (*iter)->getPlayer()->getClient()->getAccountId(), CR_Client, 6); ++iter; } }
void ChatMessageLib::sendChatFailedToBan(DispatchClient* client, BString galaxy, BString sender, BString target, Channel* channel, uint32 errorcode, uint32 requestId) const { gMessageFactory->StartMessage(); gMessageFactory->addUint32(opChatOnBanAvatarFromRoom); gMessageFactory->addString(channel->getFullPath()); gMessageFactory->addString(SWG); gMessageFactory->addString(galaxy); #ifdef DISP_REAL_FIRST_NAME #else sender.toLower(); #endif gMessageFactory->addString(sender); gMessageFactory->addString(SWG); gMessageFactory->addString(channel->getGalaxy()); #ifdef DISP_REAL_FIRST_NAME #else target.toLower(); #endif gMessageFactory->addString(target); gMessageFactory->addUint32(errorcode); gMessageFactory->addUint32(requestId); Message* message = gMessageFactory->EndMessage(); client->SendChannelA(message, client->getAccountId(), CR_Client, 6); }
void ChatMessageLib::sendChatRoomMessage(Channel* channel, BString galaxy, BString sender, BString message) const { ChatAvatarIdList::iterator iter = channel->getUserList()->begin(); #ifdef DISP_REAL_FIRST_NAME #else sender.toLower(); #endif // Check ignore list. BString loweredName = sender; loweredName.toLower(); uint32 loweredNameCrc = loweredName.getCrc(); while (iter != channel->getUserList()->end()) { // If sender present at recievers ignore list, don't send. if ((*iter)->getPlayer()->checkIgnore(loweredNameCrc)) { // Ignore player } else { DispatchClient* client = (*iter)->getPlayer()->getClient(); if (client == NULL) { LOG(warning) << "sendChatRoomMessage: Client not found for channel " << channel->getId(); } else { gMessageFactory->StartMessage(); gMessageFactory->addUint32(opChatRoomMessage); gMessageFactory->addString(SWG); gMessageFactory->addString(galaxy); gMessageFactory->addString(sender); gMessageFactory->addUint32(channel->getId()); gMessageFactory->addString(message); gMessageFactory->addUint32(0); Message* response = gMessageFactory->EndMessage(); client->SendChannelA(response, client->getAccountId(), CR_Client, 5); } } ++iter; } }
void ObjectController::_handleBoardTransport(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject); ObjectSet inRangeObjects; float boardingRange = 25.0; if(playerObject->states.getPosture() == CreaturePosture_SkillAnimating) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject); return; } BString str; message->getStringUnicode16(str); str.convert(BSTRType_ANSI); str.toLower(); if((str.getCrc() != BString("transport").getCrc())) { gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_what_shuttle"), playerObject); return; } gSpatialIndexManager->getObjectsInRange(playerObject,&inRangeObjects,ObjType_Creature | ObjType_NPC, boardingRange, true); // iterate through the results ObjectSet::iterator it = inRangeObjects.begin(); while(it != inRangeObjects.end()) { if(Shuttle* shuttle = dynamic_cast<Shuttle*>(*it)) { // in range check if(playerObject->getParentId() != shuttle->getParentId()) { gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_too_far"), playerObject); return; } if (!shuttle->availableInPort()) { gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "shuttle_not_available"), playerObject); return; } shuttle->useShuttle(playerObject); return; } ++it; } gMessageLib->SendSystemMessage(::common::OutOfBand("structure/structure_messages", "boarding_what_shuttle"), playerObject); }
int32 WorldManager::getPlanetIdByName(BString name) { uint8 id = 0; name.toLower(); BStringVector::iterator it = mvPlanetNames.begin(); while(it != mvPlanetNames.end()) { if(strcmp((*it).getAnsi(),name.getAnsi()) == 0) return(id); ++it; id++; } return(-1); }
int32 WorldManager::getPlanetIdByNameLike(BString name) { uint8 id = 0; name.toLower(); BStringVector::iterator it = mvPlanetNames.begin(); while(it != mvPlanetNames.end()) { // gLogger->log(LogManager::DEBUG,"Comparing: %s", name.getAnsi()); // gLogger->log(LogManager::DEBUG,"with : %s", (*it).getAnsi()); if(Anh_Utils::cmpnistr((*it).getAnsi(),name.getAnsi(), 3) == 0) { // gLogger->log(LogManager::DEBUG,"Matched with planet id = %d", id); return (id); } ++it; id++; } return(-1); }
void GroupManager::_processIsmInviteInRangeResponse(Message* message, DispatchClient* client) { Player* player = gChatManager->getPlayerByAccId(message->getUint32()); Player* targetPlayer = gChatManager->getPlayerByAccId(message->getUint32()); uint8 inRange = message->getUint8(); if(targetPlayer == NULL || player == NULL) { gLogger->log(LogManager::DEBUG,"GroupManager::_processIsmInviteInRangeResponse player not found"); return; } // If we are not in range, inform the player and return. if(!inRange) { gChatMessageLib->sendSystemMessage(player, L"@error_message:error_invite_ran"); return; } // I must be the group leader and group not full before we bother checking target... GroupObject* group = NULL; uint64 groupId = player->getGroupId(); if (groupId != 0) { group = getGroupById(player->getGroupId()); if (group == NULL) { return; } // Sender in group. // if sender is not leader if(group->getLeader() != player) { gChatMessageLib->sendSystemMessage(player,L"@group:must_be_leader"); return; } // is it full? if(group->getMemberCount() >= 20) { gChatMessageLib->sendSystemMessage(group->getLeader(),L"@group:full"); return; } } // If target have me ignored, auto decline my invitation. BString ignoreName = player->getName(); ignoreName.toLower(); // check our ignorelist if (targetPlayer->checkIgnore(ignoreName.getCrc())) { gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("decline_leader"), player, NULL); return; } // if target is member of a group already if(targetPlayer->getGroupId() != 0 && targetPlayer->getGroupMemberIndex() != 0xFFFF) { if(targetPlayer->getGroupId() == groupId) { gChatMessageLib->sendSystemMessage(player,L"This player is already in your group."); } else { gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("already_grouped"), player, NULL); } return; } // if target in group and is considering to join a group if ((targetPlayer->getGroupMemberIndex() == 0xFFFF) && (targetPlayer->getGroupId() != 0)) { // considering to join your group if(targetPlayer->getGroupId() == player->getGroupId()) { gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("considering_your_group"), player, NULL); } // considering to join another group else { gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("considering_other_group"), player, NULL); } return; } // the sender is not in a group, lets create a new one // and insert it in the group map if (groupId == 0) { groupId = this->getNextGroupId(); group = new GroupObject(player, groupId); mGroups.insert(std::make_pair(groupId, group)); } // add the target player as temp member group->addTempMember(targetPlayer); gChatMessageLib->sendGroupSystemMessage(targetPlayer->getName(), BString("invite_leader"), player, NULL); // tell the zone to display the invite box gChatMessageLib->sendIsmInviteRequest(player, targetPlayer); }
void ObjectController::handleSecureTradeInvitation(uint64 targetId,Message* message) { //targetId is the Id of the one who IS INVITING //receiverId is the Id of the one who GETS INVITED uint32 unknown,error; uint64 receiverId,unknown64; message->getUint32(unknown); message->getUint32(error); message->getUint64(unknown64);//sender (target) id message->getUint64(receiverId); PlayerObject* invitingPlayer = dynamic_cast<PlayerObject*>(mObject); //PlayerObject* invitingPlayer = PlayerObject* invitedPlayer = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(receiverId)); switch(error) { case 2: { // snd invitation returns error as 2 and the id of the invited as 0 :( invitedPlayer = dynamic_cast<PlayerObject*>(invitingPlayer->GetCreature()->getTarget()); error = 0; } break; case 0: { //first invitation set the setInvite to the Inviter //invitedPlayer = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(receiverId)); } break; default: { // Always use a default if message damaged.... DLOG(info) << "ObjController:: Error in trade invitation"; // Since receiver is default NULL, we can use the error message below // return; } } if(!invitedPlayer) { gMessageLib->SendSystemMessage(::common::OutOfBand("ui_trade", "start_fail_target_not_player"), invitingPlayer); return; } if(invitedPlayer->GetCreature()->states.checkStatesEither(CreatureState_Combat | CreatureState_Tumbling | CreatureState_Swimming)) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), invitingPlayer); return; } // Can NOT use bitwise operation on non bitwise constants. CreaturePostures are used exclusive. // if(invitedPlayer->states.checkPosturesEither(CreaturePosture_Dead | CreaturePosture_Incapacitated)) if (invitedPlayer->GetCreature()->states.checkPosture(CreaturePosture_Dead) || invitedPlayer->GetCreature()->states.checkPosture(CreaturePosture_Incapacitated)) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), invitingPlayer); return; } // Can NOT use bitwise operation on non bitwise constants. // if(invitingPlayer->states.checkPosturesEither(CreaturePosture_Dead | CreaturePosture_Incapacitated)) if (invitingPlayer->GetCreature()->states.checkPosture(CreaturePosture_Dead) || invitingPlayer->GetCreature()->states.checkPosture(CreaturePosture_Incapacitated)) { gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), invitingPlayer); return; } if (error == 0) { if (invitedPlayer->getTradeStatus() == false ) { // If sender is invited by receiver already, then accept even if receiver have sender in the Ignore-list. if (!invitingPlayer->getTrade()->verifyInvitation(invitedPlayer)) { // We are not invited, check Ignore. // If receiver have sender ignored, auto decline trade request. BString ignoreName = invitingPlayer->GetCreature()->getFirstName().c_str(); ignoreName.toLower(); // check receivers ignorelist if (invitedPlayer->checkIgnoreList(ignoreName.getCrc())) { gMessageLib->SendSystemMessage(::common::OutOfBand("ui_trade", "request_player_denied_prose", invitedPlayer->getId(), 0, 0), invitingPlayer); return; } } gTradeManager->addTradeInvitation(invitedPlayer,invitingPlayer); } else { gMessageLib->SendSystemMessage(::common::OutOfBand("ui_trade", "request_player_busy_prose", invitedPlayer->getId(), 0, 0), invitingPlayer); } } }
void ObjectController::_handleTip(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties) { // Message can appear as follows: // // (uint32)playerID bank <- banktip in case the client knows the target // (uint32)playerID <- inventory tip in case the client knows the target // (string)playerName bank <- banktip in case the client doesn't know the target // // can't inventory-tip someone out of range so we can assume // the client will send the ID rather than the name in case // of an inventory tip. BString attribute, str; message->getStringUnicode16(str); attribute = str; attribute.convert(BSTRType_ANSI); PlayerObject* player = dynamic_cast<PlayerObject*>(mObject); PlayerObject* target = dynamic_cast<PlayerObject*>(gWorldManager->getObjectById(targetId)); BString targetName; BString dataStr; //int32 amount = 0; //uint64 transferType = 0; BStringVector dataElements; BString bank; attribute.getRawData()[attribute.getLength()] = 0; uint32 elementCount = attribute.split(dataElements,' '); //do we have the right number of attributes? if((elementCount <1) || (elementCount >3)) { gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_invalid_param", L"", L"", str.getUnicode16()), player); return; } BString lower = dataElements[elementCount-1]; // Have to convert BEFORE using toLower, since the conversion done there is removed It will assert(). // Either do the conversion HERE, or better fix the toLower so it handles unicode also. dataStr.convert(BSTRType_ANSI); lower.toLower(); //check for banktip if((lower.getCrc() == BString("bank").getCrc())&&(elementCount > 1)) { uint32 amount = atoi(dataElements[elementCount-2].getAnsi()); bool havetarget = false; BString name; if(target && (target != player)) { havetarget = true; name = target->GetCreature()->getFirstName().c_str(); } if(elementCount == 3) { havetarget = true; name = dataElements[0]; } if((amount >0)&& (amount < 999999999)&&(havetarget)) { //now call the treasury, find that offline bloke and get going gTreasuryManager->bankTipOffline(amount,player,name); return; } if(targetId && (!havetarget)) { //please note that this is rather complex as we have a targetid even if we explicitly names a target gMessageLib->SendSystemMessage(L"You may only /tip or /tip bank to other players.", player); return; } } if(target == player) { gMessageLib->SendSystemMessage(L"You may only /tip or /tip bank to other players.", player); return; } if((elementCount == 1)&&(target)) { uint32 amount = atoi(dataElements[0].getAnsi()); if(amount>0 && (amount < 1000001)) { gTreasuryManager->inventoryTipOnline(amount,player,target); return; } } if(targetId && (!target)) { //please note that this is rather complex as we have a targetid even if we explicitely name a target gMessageLib->SendSystemMessage(L"You may only /tip or /tip bank to other players.", player); return; } gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_invalid_param", L"", L"", str.getUnicode16()), player); return; }