mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 21:47:24 +00:00
patched coin exploit
This commit is contained in:
parent
e31dc35733
commit
b6453376e4
@ -1644,6 +1644,24 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
|||||||
droppedLoot.erase(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) {
|
void Entity::AddChild(Entity* child) {
|
||||||
m_ChildEntities.push_back(child);
|
m_ChildEntities.push_back(child);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,9 @@ public:
|
|||||||
void AddLootItem(const Loot::Info& info);
|
void AddLootItem(const Loot::Info& info);
|
||||||
void PickupItem(const LWOOBJID& objectID);
|
void PickupItem(const LWOOBJID& objectID);
|
||||||
|
|
||||||
|
bool PickupCoins(uint64_t count);
|
||||||
|
void DropCoins(uint64_t count);
|
||||||
|
|
||||||
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
|
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
|
||||||
void TriggerEvent(std::string eveneventtID, Entity* optionalTarget = nullptr);
|
void TriggerEvent(std::string eveneventtID, Entity* optionalTarget = nullptr);
|
||||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||||
|
@ -24,6 +24,7 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
|
|||||||
m_GMLevel = m_Character->GetGMLevel();
|
m_GMLevel = m_Character->GetGMLevel();
|
||||||
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
m_SystemAddress = m_ParentUser->GetSystemAddress();
|
||||||
m_DroppedLoot = {};
|
m_DroppedLoot = {};
|
||||||
|
m_DroppedCoins = 0;
|
||||||
|
|
||||||
m_GhostReferencePoint = NiPoint3::ZERO;
|
m_GhostReferencePoint = NiPoint3::ZERO;
|
||||||
m_GhostOverridePoint = NiPoint3::ZERO;
|
m_GhostOverridePoint = NiPoint3::ZERO;
|
||||||
@ -290,6 +291,14 @@ const std::vector<Player*>& Player::GetAllPlayers()
|
|||||||
return m_Players;
|
return m_Players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Player::GetDroppedCoins() {
|
||||||
|
return m_DroppedCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::SetDroppedCoins(uint64_t value) {
|
||||||
|
m_DroppedCoins = value;
|
||||||
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player()
|
||||||
{
|
{
|
||||||
Game::logger->Log("Player", "Deleted player\n");
|
Game::logger->Log("Player", "Deleted player\n");
|
||||||
|
@ -36,6 +36,8 @@ public:
|
|||||||
|
|
||||||
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
|
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
|
||||||
|
|
||||||
|
uint64_t GetDroppedCoins();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setters
|
* Setters
|
||||||
*/
|
*/
|
||||||
@ -52,6 +54,8 @@ public:
|
|||||||
|
|
||||||
void SetGhostOverride(bool value);
|
void SetGhostOverride(bool value);
|
||||||
|
|
||||||
|
void SetDroppedCoins(uint64_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for sending an in-game mail.
|
* Wrapper for sending an in-game mail.
|
||||||
*
|
*
|
||||||
@ -126,5 +130,7 @@ private:
|
|||||||
|
|
||||||
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
|
||||||
|
|
||||||
|
uint64_t m_DroppedCoins;
|
||||||
|
|
||||||
static std::vector<Player*> m_Players;
|
static std::vector<Player*> m_Players;
|
||||||
};
|
};
|
||||||
|
@ -1031,6 +1031,10 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
|
|||||||
entity->AddLootItem(info);
|
entity->AddLootItem(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item == LOT_NULL && currency != 0) {
|
||||||
|
entity->DropCoins(currency);
|
||||||
|
}
|
||||||
|
|
||||||
if (spawnPos != NiPoint3::ZERO) {
|
if (spawnPos != NiPoint3::ZERO) {
|
||||||
bUsePosition = true;
|
bUsePosition = true;
|
||||||
|
|
||||||
@ -5232,8 +5236,12 @@ void GameMessages::HandlePickupCurrency(RakNet::BitStream* inStream, Entity* ent
|
|||||||
unsigned int currency;
|
unsigned int currency;
|
||||||
inStream->Read(currency);
|
inStream->Read(currency);
|
||||||
|
|
||||||
|
if (currency == 0) return;
|
||||||
|
|
||||||
auto* ch = entity->GetCharacter();
|
auto* ch = entity->GetCharacter();
|
||||||
ch->SetCoins(ch->GetCoins() + currency);
|
if (entity->PickupCoins(currency)) {
|
||||||
|
ch->SetCoins(ch->GetCoins() + currency);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) {
|
void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) {
|
||||||
|
Loading…
Reference in New Issue
Block a user