Skip to content

Commit

Permalink
пофикшено изменение денег у НПС после торговле, в случае если у НПС н…
Browse files Browse the repository at this point in the history
…е бесконечное количество денег
  • Loading branch information
kola24511 authored and Drombeys committed Nov 30, 2024
1 parent 82eb879 commit cfd03fa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
17 changes: 17 additions & 0 deletions src/xrGame/inventory_owner_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,28 @@
#include "alife_registry_wrappers.h"
#include "../xrScripts/script_callback_ex.h"
#include "game_object_space.h"
#include "xrServer_Objects_ALife_Monsters.h"

void CInventoryOwner::OnEvent (NET_Packet& P, u16 type)
{
switch (type)
{
case GE_MONEY:
{
u32 amount = P.r_u32();
if (InfinitiveMoney())
m_money = _max(m_money, amount);
else
m_money = amount;
if (OnServer())
{
CSE_Abstract* e_dest = Level().Server->ID_to_entity(this->object_id());
CSE_ALifeTraderAbstract* pTa = smart_cast<CSE_ALifeTraderAbstract*>(e_dest);
if (pTa)
pTa->m_dwMoney = m_money;
}
}
break;
case GE_INFO_TRANSFER:
{
u16 id;
Expand Down
15 changes: 12 additions & 3 deletions src/xrGame/xrServer_process_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,18 @@ void xrServer::Process_event (NET_Packet& P, ClientID sender)
}break;
case GE_MONEY:
{
CSE_Abstract *e_dest = receiver;
CSE_ALifeTraderAbstract* pTa = smart_cast<CSE_ALifeTraderAbstract*>(e_dest);
pTa->m_dwMoney = P.r_u32();
if (game->Type() == eGameIDSingle)
{
CSE_Abstract* e_dest = receiver;
CSE_ALifeTraderAbstract* pTa = smart_cast<CSE_ALifeTraderAbstract*>(e_dest);
if (pTa)
pTa->m_dwMoney = P.r_u32();
}
else
{
// Signal to everyone (including sender)
SendBroadcast(BroadcastCID, P, MODE);
}

}break;
case GE_FREEZE_OBJECT:
Expand Down

0 comments on commit cfd03fa

Please sign in to comment.