Implemented sourceType for SendSetCurrency

Implemented sourceType for the function SendSetCurrency.
This commit is contained in:
EmosewaMC 2021-12-21 23:26:54 -08:00
parent 0531365cb5
commit 23e269940b
10 changed files with 24 additions and 26 deletions

View File

@ -527,7 +527,7 @@ void Character::OnZoneLoad()
*/
if (HasPermission(PermissionMap::Old)) {
if (GetCoins() > 1000000) {
SetCoins(1000000);
SetCoins(1000000, 0);
}
}
@ -567,7 +567,7 @@ const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const
return pair->second;
}
void Character::SetCoins(int64_t newCoins, const bool message) {
void Character::SetCoins(int64_t newCoins, int lootType) {
if (newCoins < 0)
{
newCoins = 0;
@ -575,10 +575,7 @@ void Character::SetCoins(int64_t newCoins, const bool message) {
m_Coins = newCoins;
if (message)
{
GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true);
}
GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootType);
}
bool Character::HasBeenToWorld(LWOMAPID mapID) const

View File

@ -314,7 +314,7 @@ public:
* @param newCoins the amount of coins to update by
* @param message whether to notify the client of the change
*/
void SetCoins(int64_t newCoins, bool message = true);
void SetCoins(int64_t newCoins, int lootType);
/**
* Get the entity this character belongs to

View File

@ -151,8 +151,8 @@ void Trade::Complete()
if (inventoryA == nullptr || inventoryB == nullptr || characterA == nullptr || characterB == nullptr || missionsA == nullptr || missionsB == nullptr) return;
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB);
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA);
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, 6);
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, 6);
for (const auto& tradeItem : m_ItemsA)
{

View File

@ -818,7 +818,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
LootGenerator::Instance().DropLoot(m_Parent, m_Parent, -1, coinsToLoose, coinsToLoose);
}
character->SetCoins(coinsTotal);
character->SetCoins(coinsTotal, 11);
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {

View File

@ -706,7 +706,7 @@ void GameMessages::SendBroadcastTextToChatbox(Entity* entity, const SystemAddres
SEND_PACKET_BROADCAST
}
void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent) {
void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, int sourceType) {
CBITSTREAM
CMSGHEADER
@ -729,7 +729,6 @@ void GameMessages::SendSetCurrency(Entity* entity, int64_t currency, int lootTyp
bitStream.Write(sourceTradeID != LWOOBJID_EMPTY);
if (sourceTradeID != LWOOBJID_EMPTY) bitStream.Write(sourceTradeID);
int sourceType = 0; //For now.
bitStream.Write(sourceType != LOOTTYPE_NONE);
if (sourceType != LOOTTYPE_NONE) bitStream.Write(sourceType);
@ -4685,7 +4684,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
inv->RemoveItem(itemComp.currencyLOT, altCurrencyCost);
}
character->SetCoins(character->GetCoins() - (coinCost));
character->SetCoins(character->GetCoins() - (coinCost), 9);
inv->AddItem(item, count);
}
@ -4734,7 +4733,7 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
//inv->RemoveItem(count, -1, iObjID);
inv->MoveItemToInventory(item, VENDOR_BUYBACK, count, true, false, true);
character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count)));
character->SetCoins(std::floor(character->GetCoins() + ((itemComp.baseValue * sellScalar)*count)), 9);
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
GameMessages::SendVendorTransactionResult(entity, sysAddr);
}
@ -4796,7 +4795,7 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
//inv->RemoveItem(count, -1, iObjID);
inv->MoveItemToInventory(item, Inventory::FindInventoryTypeForLot(item->GetLot()), count, true, false);
character->SetCoins(character->GetCoins() - cost);
character->SetCoins(character->GetCoins() - cost, 9);
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
GameMessages::SendVendorTransactionResult(entity, sysAddr);
}
@ -5240,7 +5239,7 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent
auto* ch = entity->GetCharacter();
if (entity->CanPickupCoins(currency)) {
ch->SetCoins(ch->GetCoins() + currency);
ch->SetCoins(ch->GetCoins() + currency, 11);
}
}

View File

@ -78,7 +78,7 @@ namespace GameMessages {
void SendPlayFXEffect(const LWOOBJID& entity, int32_t effectID, const std::u16string& effectType, const std::string& name, LWOOBJID secondary = LWOOBJID_EMPTY, float priority = 1, float scale = 1, bool serialize = true);
void SendStopFXEffect(Entity* entity, bool killImmediate, std::string name);
void SendBroadcastTextToChatbox(Entity* entity, const SystemAddress& sysAddr, const std::u16string& attrs, const std::u16string& wsText);
void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent);
void SendSetCurrency(Entity* entity, int64_t currency, int lootType, const LWOOBJID& sourceID, const LOT& sourceLOT, int sourceTradeID, bool overrideCurrent, int sourceType);
void SendRebuildNotifyState(Entity* entity, int prevState, int state, const LWOOBJID& playerID);
void SendEnableRebuild(Entity* entity, bool enable, bool fail, bool success, int failReason, float duration, const LWOOBJID& playerID);

View File

@ -444,7 +444,7 @@ void Mission::YieldRewards() {
auto count = pair.second > 0 ? pair.second : 1;
// Sanitfy check, 6 is the max any mission yields
// Sanity check, 6 is the max any mission yields
if (count > 6) {
count = 0;
}
@ -453,7 +453,7 @@ void Mission::YieldRewards() {
}
if (info->reward_currency_repeatable > 0) {
character->SetCoins(character->GetCoins() + info->reward_currency_repeatable);
character->SetCoins(character->GetCoins() + info->reward_currency_repeatable, 2);
}
return;
@ -481,8 +481,10 @@ void Mission::YieldRewards() {
inventoryComponent->AddItem(pair.first, count);
}
if (info->reward_currency > 0) {
character->SetCoins(character->GetCoins() + info->reward_currency, info->isMission);
if (info->reward_currency > 0 && info->isMission) {
character->SetCoins(character->GetCoins() + info->reward_currency, 2);
} else if (info->reward_currency && !info->isMission) {
character->SetCoins(character->GetCoins() + info->reward_currency, 5);
}
if (info->reward_maxinventory > 0) {

View File

@ -316,7 +316,7 @@ void LootGenerator::GiveActivityLoot(Entity* player, Entity* source, uint32_t ac
auto* character = player->GetCharacter();
character->SetCoins(character->GetCoins() + coins);
character->SetCoins(character->GetCoins() + coins, 10);
}
void LootGenerator::DropLoot(Entity* player, Entity* killedObject, uint32_t matrixIndex, uint32_t minCoins, uint32_t maxCoins) {

View File

@ -262,7 +262,7 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
}
Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success);
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost);
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, 3);
Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i\n", itemID, attachmentCount, itemLOT);

View File

@ -1326,7 +1326,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
}
auto* ch = entity->GetCharacter();
ch->SetCoins(ch->GetCoins() + money);
ch->SetCoins(ch->GetCoins() + money, 14);
}
if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
@ -1339,7 +1339,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
}
auto* ch = entity->GetCharacter();
ch->SetCoins(money);
ch->SetCoins(money, 14);
}
// Allow for this on even while not a GM, as it sometimes toggles incorrrectly.