BOOL KLootList::IsEmpty() { BOOL bRetCode = FALSE; int nItem = GetSize(); int nMoney = GetMoney(); KG_PROCESS_ERROR(nItem == 0 && nMoney == 0); bRetCode = TRUE; Exit0: return bRetCode; }
bool CPlayer::BuyBackItemFromMultiVendor(uint32 slot) { DEBUG_LOG("WORLD: BuyBackItemFromMultiVendor"); uint32 entry; ObjectGuid vendorGuid; GetMultiVendor(entry, vendorGuid); Creature* pCreature = GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_NONE); if (!pCreature) { DEBUG_LOG("WORLD: BuyBackItemFromMultiVendor - %s not found or you can't interact with him.", vendorGuid.GetString().c_str()); SendSellError(SELL_ERR_CANT_FIND_VENDOR, NULL, ObjectGuid(), 0); return false; } // remove fake death if (hasUnitState(UNIT_STAT_DIED)) RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); Item* pItem = GetItemFromBuyBackSlot(slot); if (pItem) { uint32 price = GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + slot - BUYBACK_SLOT_START); if (GetMoney() < price) { SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, pItem->GetEntry(), 0); return false; } ItemPosCountVec dest; InventoryResult msg = CanStoreItem(NULL_BAG, NULL_SLOT, dest, pItem, false); if (msg == EQUIP_ERR_OK) { ModifyMoney(-(int32)price); RemoveItemFromBuyBackSlot(slot, false); ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount()); StoreItem(dest, pItem, true); } else SendEquipError(msg, pItem, NULL); return true; } else SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, 0, 0); return false; }
void CPlayer::AddReward(std::string name, float amount) { m_Rewards.push_back(name + "|r"); m_PendingReward += amount; if (m_PendingReward >= 1) { uint32 Reward = m_PendingReward * 10000.f; m_PendingReward = 0; SetMoney(GetMoney() + Reward); BoxChat << "You were rewarded with " << GetGoldString(Reward) << " for the kills of " << GetRewardNames(false) << std::endl; m_Rewards.clear(); } }
/** * Sends a mail. * * @param receiver The MailReceiver to which this mail is sent. * @param sender The MailSender from which this mail is originated. * @param checked The mask used to specify the mail. * @param deliver_delay The delay after which the mail is delivered in seconds */ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay) { Player* pReceiver = receiver.GetPlayer(); // can be NULL uint32 pReceiverAccount = 0; if (!pReceiver) pReceiverAccount = sObjectMgr.GetPlayerAccountIdByGUID(receiver.GetPlayerGuid()); if (!pReceiver && !pReceiverAccount) // receiver not exist { deleteIncludedItems(true); return; } bool has_items = !m_items.empty(); // generate mail template items for online player, for offline player items will generated at open if (pReceiver) { if (prepareItems(pReceiver)) has_items = true; } uint32 mailId = sObjectMgr.GenerateMailID(); time_t deliver_time = time(NULL) + deliver_delay; uint32 expire_delay; // auction mail without any items and money (auction sale note) pending 1 hour if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.empty() && !m_money) expire_delay = HOUR; // default case: expire time if COD 3 days, if no COD 30 days else expire_delay = (m_COD > 0) ? 3 * DAY : 30 * DAY; time_t expire_time = deliver_time + expire_delay; // Add to DB std::string safe_subject = GetSubject(); CharacterDatabase.escape_string(safe_subject); std::string safe_body = GetBody(); CharacterDatabase.escape_string(safe_body); CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,body,has_items,expire_time,deliver_time,money,cod,checked) " "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%s', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%u')", mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGuid().GetCounter(), safe_subject.c_str(), safe_body.c_str(), (has_items ? 1 : 0), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked); for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGuid().GetCounter()); } CharacterDatabase.CommitTransaction(); // For online receiver update in game mail status and data if (pReceiver) { pReceiver->AddNewMailDeliverTime(deliver_time); Mail *m = new Mail; m->messageID = mailId; m->mailTemplateId = GetMailTemplateId(); m->subject = GetSubject(); m->body = GetBody(); m->money = GetMoney(); m->COD = GetCOD(); for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; m->AddItem(item->GetGUIDLow(), item->GetEntry()); } m->messageType = sender.GetMailMessageType(); m->stationery = sender.GetStationery(); m->sender = sender.GetSenderId(); m->receiverGuid = receiver.GetPlayerGuid(); m->expire_time = expire_time; m->deliver_time = deliver_time; m->checked = checked; m->state = MAIL_STATE_UNCHANGED; pReceiver->AddMail(m); // to insert new mail to beginning of maillist if (!m_items.empty()) { for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) pReceiver->AddMItem(mailItemIter->second); } } else if (!m_items.empty()) deleteIncludedItems(); }
void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay) { Player* pReceiver = receiver.GetPlayer(); // can be NULL Player* pSender = sObjectMgr->GetPlayerByLowGUID(sender.GetSenderId()); if (pReceiver) prepareItems(pReceiver, trans); // generate mail template items uint32 mailId = sObjectMgr->GenerateMailID(); time_t deliver_time = time(NULL) + deliver_delay; //expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour uint32 expire_delay; // auction mail without any items and money if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.empty() && !m_money) expire_delay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY); // mail from battlemaster (rewardmarks) should last only one day else if (sender.GetMailMessageType() == MAIL_CREATURE && sBattlegroundMgr->GetBattleMasterBG(sender.GetSenderId()) != BATTLEGROUND_TYPE_NONE) expire_delay = DAY; // default case: expire time if COD 3 days, if no COD 30 days (or 90 days if sender is a game master) else { if (m_COD) expire_delay = 3 * DAY; else expire_delay = pSender && pSender->IsGameMaster() ? 90 * DAY : 30 * DAY; } time_t expire_time = deliver_time + expire_delay; // Add to DB uint8 index = 0; PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL); stmt->setUInt32( index, mailId); stmt->setUInt8 (++index, uint8(sender.GetMailMessageType())); stmt->setInt8 (++index, int8(sender.GetStationery())); stmt->setUInt16(++index, GetMailTemplateId()); stmt->setUInt32(++index, sender.GetSenderId()); stmt->setUInt32(++index, receiver.GetPlayerGUIDLow()); stmt->setString(++index, GetSubject()); stmt->setString(++index, GetBody()); stmt->setBool (++index, !m_items.empty()); stmt->setUInt64(++index, uint64(expire_time)); stmt->setUInt64(++index, uint64(deliver_time)); stmt->setUInt32(++index, m_money); stmt->setUInt32(++index, m_COD); stmt->setUInt8 (++index, uint8(checked)); trans->Append(stmt); for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* pItem = mailItemIter->second; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL_ITEM); stmt->setUInt32(0, mailId); stmt->setUInt32(1, pItem->GetGUID().GetCounter()); stmt->setUInt32(2, receiver.GetPlayerGUIDLow()); trans->Append(stmt); } // For online receiver update in game mail status and data if (pReceiver) { pReceiver->AddNewMailDeliverTime(deliver_time); if (pReceiver->IsMailsLoaded()) { Mail* m = new Mail; m->messageID = mailId; m->mailTemplateId = GetMailTemplateId(); m->subject = GetSubject(); m->body = GetBody(); m->money = GetMoney(); m->COD = GetCOD(); for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; m->AddItem(item->GetGUID().GetCounter(), item->GetEntry()); } m->messageType = sender.GetMailMessageType(); m->stationery = sender.GetStationery(); m->sender = sender.GetSenderId(); m->receiver = receiver.GetPlayerGUIDLow(); m->expire_time = expire_time; m->deliver_time = deliver_time; m->checked = checked; m->state = MAIL_STATE_UNCHANGED; pReceiver->AddMail(m); // to insert new mail to beginning of maillist if (!m_items.empty()) { for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) pReceiver->AddMItem(mailItemIter->second); } } else if (!m_items.empty()) { SQLTransaction temp = SQLTransaction(NULL); deleteIncludedItems(temp); } } else if (!m_items.empty()) { SQLTransaction temp = SQLTransaction(NULL); deleteIncludedItems(temp); } }
void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay) { Player* pReceiver = receiver.GetPlayer(); // can be NULL if (pReceiver) prepareItems(pReceiver); // generate mail template items uint32 mailId = objmgr.GenerateMailID(); time_t deliver_time = time(NULL) + deliver_delay; uint32 expire_delay; // auction mail without any items and money (auction sale note) pending 1 hour if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.empty() && !m_money) expire_delay = HOUR; // mail from battlemaster (rewardmarks) should last only one day else if (sender.GetMailMessageType() == MAIL_CREATURE && sBattleGroundMgr.GetBattleMasterBG(sender.GetSenderId()) != BATTLEGROUND_TYPE_NONE) expire_delay = DAY; // default case: expire time if COD 3 days, if no COD 30 days else expire_delay = (m_COD > 0) ? 3 * DAY : 30 * DAY; time_t expire_time = deliver_time + expire_delay; // Add to DB std::string safe_subject = GetSubject(); CharacterDatabase.BeginTransaction(); CharacterDatabase.escape_string(safe_subject); CharacterDatabase.PExecute("INSERT INTO mail (id,messageType,stationery,mailTemplateId,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked) " "VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%s', '%u', '%u', '" UI64FMTD "','" UI64FMTD "', '%u', '%u', '%d')", mailId, sender.GetMailMessageType(), sender.GetStationery(), GetMailTemplateId(), sender.GetSenderId(), receiver.GetPlayerGUIDLow(), safe_subject.c_str(), GetBodyId(), (m_items.empty() ? 0 : 1), (uint64)expire_time, (uint64)deliver_time, m_money, m_COD, checked); for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; CharacterDatabase.PExecute("INSERT INTO mail_items (mail_id,item_guid,item_template,receiver) VALUES ('%u', '%u', '%u','%u')", mailId, item->GetGUIDLow(), item->GetEntry(), receiver.GetPlayerGUIDLow()); } CharacterDatabase.CommitTransaction(); // For online receiver update in game mail status and data if (pReceiver) { pReceiver->AddNewMailDeliverTime(deliver_time); if (pReceiver->IsMailsLoaded()) { Mail *m = new Mail; m->messageID = mailId; m->mailTemplateId = GetMailTemplateId(); m->subject = GetSubject(); m->itemTextId = GetBodyId(); m->money = GetMoney(); m->COD = GetCOD(); for(MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) { Item* item = mailItemIter->second; m->AddItem(item->GetGUIDLow(), item->GetEntry()); } m->messageType = sender.GetMailMessageType(); m->stationery = sender.GetStationery(); m->sender = sender.GetSenderId(); m->receiver = receiver.GetPlayerGUIDLow(); m->expire_time = expire_time; m->deliver_time = deliver_time; m->checked = checked; m->state = MAIL_STATE_UNCHANGED; pReceiver->AddMail(m); // to insert new mail to beginning of maillist if (!m_items.empty()) { for(MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter) pReceiver->AddMItem(mailItemIter->second); } } else if (!m_items.empty()) deleteIncludedItems(); } else if (!m_items.empty()) deleteIncludedItems(); }
void QuizRoom::TakeInput() { system("CLS"); char Answer[50]; std::cout << "You passed my puzzle room pretty easily, but can you stand the heat of my quiz room?\n"; std::cout << "\nThere are 5 questions in total can you muster your brain power to get all 5 right? if so they might be something in it for you\n"; std::cout << "\nRight lets begin, Question 1 What piece in chess has the least value?\n\nBishop\nRook\nPawn\n"; String input1; input1.setString(); if (input1.lowerCase().compare("pawn")) { system("CLS"); Correct++; std::cout << "Correct, Onto the second question!\n"; totalScore++; std::cout << "\n" << totalScore << " / 1\n"; AddMoney(500); std::cout << "$" << GetMoney(); } else { system("CLS"); std::cout << "Nice try, try the next one!\n"; } String input2; std::cout << "\nQuestion 2 What is the name of the main antagonist in the mario franchise?\nKamek\nBowser\nGoomba\n"; input2.setString(); if (input2.lowerCase().compare("bowser")) { system("CLS"); Correct++; std::cout << "Correct, Onto the Third question!\n"; totalScore++; std::cout << "\n" << totalScore << " / 2\n"; AddMoney(500); std::cout << "$" << GetMoney() << "\n"; } else { system("CLS"); std::cout << "\n" << "Nice try, the next one!\n"; } String input3; std::cout << "\nQuestion 3 What is the name of playstations marsupial mascot?\nCrash\nCoco\nSteve\n"; input3.setString(); if (input3.lowerCase().compare("crash")) { system("CLS"); Correct++; std::cout << "\nCorrect, Onto the Fourth question! \n"; totalScore++; std::cout << "\n" << totalScore << " / 3\n"; AddMoney(500); std::cout << "$" << GetMoney() << "\n"; } else { system("CLS"); std::cout << "Nice try, the next one!\n"; } std::cout << "\nQuestion 4, The OUYA isnt a well known console amongst gamers, but who made it?\nAndroid\nApple\nSony\nMicrosoft\n"; String input4; input4.setString(); if (input4.lowerCase().compare("android")) { system("CLS"); Correct++; std::cout << "\nCorrect, Onto the Last question! \n"; totalScore++; std::cout << "\n" << totalScore << " / 4 \n"; AddMoney(500); std::cout << "$" << GetMoney() << "\n"; } else { system("CLS"); std::cout << "Nice attempt, that was a hard question, onto the grand finale\n"; } std::cout << "\nFinal Question!, Which character does this quote originate from, *Show me your moves!*\nBloodFalcon\nCaptainFalcon\nFox\nMario\n"; String input5; input5.setString(); if (input5.lowerCase().compare("captainfalcon")) { system("CLS"); Correct++; std::cout << "\nWell done! you completed the Quiz\n"; totalScore++; AddMoney(500); std::cout << "$" << GetMoney() << "\n"; std::cout << "Your total score was" << totalScore << " / 5"; } else { system("CLS"); std::cout << "\nYour total score was" << totalScore << " / 5"; } if (totalScore == 5) { std::cout << "\nWell done your preformance in the quizzing room has opened up the treasure room for you\nHead to the east\n"; std::cout << "\nyour total money is now $" << GetMoney() << '\n'; } else { std::cout << "\nnice attempt east is the way to go now, but you dont get access to the bonuses in that room\n"; std::cout << "\nyour total money is now $" << GetMoney() << '\n'; } }
// Return true is the bought item has a max count to force refresh of window by caller bool CPlayer::BuyItemFromMultiVendor(uint32 item, uint8 count, uint8 bag, uint8 slot) { DEBUG_LOG("WORLD: BuyItemFromMultiVendor"); // cheating attempt if (count < 1) count = 1; if (!isAlive()) return false; ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); if (!pProto) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, item, 0); return false; } uint32 entry; ObjectGuid guid; GetMultiVendor(entry, guid); CreatureInfo const *cinfo = sObjectMgr.GetCreatureTemplate(entry); if (!cinfo) { BoxChat << MSG_COLOR_WHITE << "This vendor seems to be removed from the database. Please report that creature " << entry << " is missing." << std::endl; return false; } Creature* pCreature = GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!pCreature) { DEBUG_LOG("WORLD: BuyItemFromMultiVendor - %s not found or you can't interact with him.", guid.GetString().c_str()); SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, NULL, item, 0); return false; } VendorItemData const* vItems = sObjectMgr.GetNpcVendorItemList(entry); VendorItemData const* tItems = cinfo->VendorTemplateId ? sObjectMgr.GetNpcVendorTemplateItemList(cinfo->VendorTemplateId) : NULL; if ((!vItems || vItems->Empty()) && (!tItems || tItems->Empty())) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); return false; } uint32 vCount = vItems ? vItems->GetItemCount() : 0; uint32 tCount = tItems ? tItems->GetItemCount() : 0; size_t vendorslot = vItems ? vItems->FindItemSlot(item) : vCount; if (vendorslot >= vCount) vendorslot = vCount + (tItems ? tItems->FindItemSlot(item) : tCount); if (vendorslot >= vCount + tCount) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); return false; } VendorItem const* crItem = vendorslot < vCount ? vItems->GetItem(vendorslot) : tItems->GetItem(vendorslot - vCount); if (!crItem || crItem->item != item) // store diff item (cheating) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); return false; } uint32 totalCount = pProto->BuyCount * count; // check current item amount if it limited if (crItem->maxcount != 0) { if (pCreature->GetVendorItemCurrentCount(crItem) < totalCount) { SendBuyError(BUY_ERR_ITEM_ALREADY_SOLD, pCreature, item, 0); return false; } } if (uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank) { SendBuyError(BUY_ERR_REPUTATION_REQUIRE, pCreature, item, 0); return false; } if (uint32 extendedCostId = crItem->ExtendedCost) { ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId); if (!iece) { sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, extendedCostId); return false; } // honor points price if (GetHonorPoints() < (iece->reqhonorpoints * count)) { SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL); return false; } // arena points price if (GetArenaPoints() < (iece->reqarenapoints * count)) { SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL); return false; } // item base price for (auto i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i) { if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], iece->reqitemcount[i] * count)) { SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); return false; } } // check for personal arena rating requirement if (GetMaxPersonalArenaRatingRequirement() < iece->reqpersonalarenarating) { // probably not the proper equip err SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, NULL, NULL); return false; } } if (crItem->conditionId && !isGameMaster() && !sObjectMgr.IsPlayerMeetToCondition(crItem->conditionId, ToPlayer(), pCreature->GetMap(), pCreature, CONDITION_FROM_VENDOR)) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); return false; } uint32 price = pProto->BuyPrice * count; // reputation discount price = uint32(floor(price * GetReputationPriceDiscount(pCreature))); if (GetMoney() < price) { SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, pCreature, item, 0); return false; } // if (GetAverageItemLevel() < crItem->itemlevel && !isGameMaster()) // { // // probably not the proper equip err // SendEquipError(EQUIP_ERR_CANT_EQUIP_RANK, NULL, NULL); // SendChatMessage("You need at least %u averange itemlevel.", crItem->itemlevel); // SendChatMessage("You currently have a averange itemlevel %u.", uint32(floor(GetAverageItemLevel()))); // return false; // } Item* pItem = NULL; if ((bag == NULL_BAG && slot == NULL_SLOT) || IsInventoryPos(bag, slot)) { ItemPosCountVec dest; InventoryResult msg = CanStoreNewItem(bag, slot, dest, item, totalCount); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, NULL, NULL, item); return false; } ModifyMoney(-int32(price)); if (crItem->ExtendedCost) TakeExtendedCost(crItem->ExtendedCost, count); pItem = StoreNewItem(dest, item, true); } else if (IsEquipmentPos(bag, slot)) { if (totalCount != 1) { SendEquipError(EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL); return false; } uint16 dest; InventoryResult msg = CanEquipNewItem(slot, dest, item, false); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, NULL, NULL, item); return false; } ModifyMoney(-int32(price)); if (crItem->ExtendedCost) TakeExtendedCost(crItem->ExtendedCost, count); pItem = EquipNewItem(dest, item, true); if (pItem) AutoUnequipOffhandIfNeed(); } else { SendEquipError(EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT, NULL, NULL); return false; } if (!pItem) return false; uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem, totalCount); WorldPacket data(SMSG_BUY_ITEM, 8 + 4 + 4 + 4); data << pCreature->GetObjectGuid(); data << uint32(vendorslot + 1); // numbered from 1 at client data << uint32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); data << uint32(count); GetSession()->SendPacket(&data); SendNewItem(pItem, totalCount, true, false, false); return crItem->maxcount != 0; }
void CFSPlayer::SetAutoDonate(CFSPlayer* pplayer, Money amount, bool bSend) { assert (pplayer != this); ShipID sidDonateBy = GetShipID(); ShipID sidDonateTo; IshipIGC* pship; if (pplayer) { pship = pplayer->GetIGCShip()->GetAutoDonate(); if (pship == NULL) pship = pplayer->GetIGCShip(); else { assert (pship->GetAutoDonate() == NULL); CFSPlayer* pplayerNew = ((CFSShip*)(pship->GetPrivateData()))->GetPlayer(); if (pplayerNew == this) { //We are trying to autodonate to someone who is already autodonating to us //Tell them to stop first (but don't send any messages) pplayer->SetAutoDonate(NULL, 0, false); //and then set our autodonate to go to them anyhow pship = pplayer->GetIGCShip(); } else { //The person we would like to donate to was already donating to someone else //donate to who ever they were donating to. pplayer = pplayerNew; } } assert (pship->GetAutoDonate() == NULL); assert (pplayer->GetIGCShip() == pship); sidDonateTo = pship->GetObjectID(); if (amount != 0) { TrapHack(GetMoney() >= amount); pplayer->SetMoney(amount + pplayer->GetMoney()); SetMoney(GetMoney() - amount); } } else { pship = NULL; sidDonateTo = NA; } GetIGCShip()->SetAutoDonate(pship); BEGIN_PFM_CREATE(g.fm, pfmAD, S, AUTODONATE) END_PFM_CREATE pfmAD->sidDonateBy = sidDonateBy; pfmAD->sidDonateTo = sidDonateTo; pfmAD->amount = amount; if (bSend) g.fm.SendMessages(CFSSide::FromIGC(GetSide())->GetGroup(), FM_GUARANTEED, FM_FLUSH); }