patched coin exploit

This commit is contained in:
Jett 2021-12-11 13:21:00 +00:00
parent e31dc35733
commit b6453376e4
5 changed files with 45 additions and 1 deletions

View File

@ -1644,6 +1644,24 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
droppedLoot.erase(objectID);
}
bool Entity::PickupCoins(uint64_t count) { // bool because we are returning whether they can pick up the coins
if (!IsPlayer()) return false;
auto droppedcoins = static_cast<Player*>(this)->GetDroppedCoins();
if (count > droppedcoins) {
return false;
} else {
static_cast<Player*>(this)->SetDroppedCoins(droppedcoins - count);
return true;
}
}
void Entity::DropCoins(uint64_t count) {
if (!IsPlayer()) return;
auto droppedcoins = static_cast<Player*>(this)->GetDroppedCoins();
droppedcoins += count;
static_cast<Player*>(this)->SetDroppedCoins(droppedcoins);
}
void Entity::AddChild(Entity* child) {
m_ChildEntities.push_back(child);
}

View File

@ -202,6 +202,9 @@ public:
void AddLootItem(const Loot::Info& info);
void PickupItem(const LWOOBJID& objectID);
bool PickupCoins(uint64_t count);
void DropCoins(uint64_t count);
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
void TriggerEvent(std::string eveneventtID, Entity* optionalTarget = nullptr);
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }

View File

@ -24,6 +24,7 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
m_GMLevel = m_Character->GetGMLevel();
m_SystemAddress = m_ParentUser->GetSystemAddress();
m_DroppedLoot = {};
m_DroppedCoins = 0;
m_GhostReferencePoint = NiPoint3::ZERO;
m_GhostOverridePoint = NiPoint3::ZERO;
@ -290,6 +291,14 @@ const std::vector<Player*>& Player::GetAllPlayers()
return m_Players;
}
uint64_t Player::GetDroppedCoins() {
return m_DroppedCoins;
}
void Player::SetDroppedCoins(uint64_t value) {
m_DroppedCoins = value;
}
Player::~Player()
{
Game::logger->Log("Player", "Deleted player\n");

View File

@ -36,6 +36,8 @@ public:
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
uint64_t GetDroppedCoins();
/**
* Setters
*/
@ -52,6 +54,8 @@ public:
void SetGhostOverride(bool value);
void SetDroppedCoins(uint64_t value);
/**
* Wrapper for sending an in-game mail.
*
@ -126,5 +130,7 @@ private:
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
uint64_t m_DroppedCoins;
static std::vector<Player*> m_Players;
};

View File

@ -1031,6 +1031,10 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
entity->AddLootItem(info);
}
if (item == LOT_NULL && currency != 0) {
entity->DropCoins(currency);
}
if (spawnPos != NiPoint3::ZERO) {
bUsePosition = true;
@ -5232,9 +5236,13 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent
unsigned int currency;
inStream->Read(currency);
if (currency == 0) return;
auto* ch = entity->GetCharacter();
if (entity->PickupCoins(currency)) {
ch->SetCoins(ch->GetCoins() + currency);
}
}
void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) {
LWOOBJID killerID;