game: port AVA2 Won (cheque) currency
Won point (quest flag cheque.points, max 999), /won_exchange sell|buy N at 100,000,000 Yang per Won, Won in trades and private shop prices (int32 cheque[] after the CG_MYSHOP items for clients >= mt20261027). The Won point is sent again at Entergame because the quest-load update arrives before PHASE_GAME. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f5b8424266
commit
103805998c
@@ -61,7 +61,7 @@ CPPFILE = port_cube_actor.cpp port_cube_recovery.cpp port_cube_factory.cpp port_
|
||||
desc_client.cpp desc_manager.cpp desc_p2p.cpp dev_log.cpp dungeon.cpp empire_text_convert.cpp entity.cpp\
|
||||
entity_view.cpp event.cpp event_queue.cpp exchange.cpp file_loader.cpp fishing.cpp gm.cpp guild.cpp\
|
||||
guild_manager.cpp guild_war.cpp horse_rider.cpp horsename_manager.cpp input.cpp input_auth.cpp input_db.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp ava2_channel.cpp new_mob_timer.cpp ava2_track.cpp ava2_ticket_shop.cpp ava2_itemshop.cpp port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.cpp port_switchbot.cpp port_special_storage.cpp offline_shop.cpp offlineshop_manager.cpp offlineshop_search_manager.cpp port_offlineshop.cpp port_ava2_dungeon.cpp port_gaya.cpp port_economy.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
input_login.cpp input_main.cpp input_p2p.cpp port_boss_track.cpp ava2_channel.cpp new_mob_timer.cpp ava2_track.cpp ava2_ticket_shop.cpp ava2_itemshop.cpp port_attr_lock.cpp port_sash.cpp port_mount.cpp port_costume_attr.cpp port_pendant.cpp port_rings.cpp port_switchbot.cpp port_special_storage.cpp offline_shop.cpp offlineshop_manager.cpp offlineshop_search_manager.cpp port_offlineshop.cpp port_ava2_dungeon.cpp port_gaya.cpp port_cheque.cpp port_economy.cpp input_teen.cpp input_udp.cpp ip_ban.cpp\
|
||||
item.cpp item_addon.cpp item_attribute.cpp item_manager.cpp item_manager_idrange.cpp locale.cpp\
|
||||
locale_service.cpp log.cpp login_data.cpp lzo_manager.cpp marriage.cpp matrix_card.cpp\
|
||||
messenger_manager.cpp mining.cpp mob_manager.cpp monarch.cpp motion.cpp over9refine.cpp p2p.cpp packet_info.cpp\
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#include "item.h"
|
||||
#include "port_quiver.h"
|
||||
#include "port_quiver_sync.inc"
|
||||
#include "port_cheque.h"
|
||||
|
||||
extern const BYTE g_aBuffOnAttrPoints;
|
||||
extern bool RaceToJob(unsigned race, unsigned *ret_job);
|
||||
@@ -614,7 +615,7 @@ const char * CHARACTER::GetName() const
|
||||
return m_stName.empty() ? (m_pkMobData ? m_pkMobData->m_table.szLocaleName : "") : m_stName.c_str();
|
||||
}
|
||||
|
||||
void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount)
|
||||
void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount, const int32_t * pCheque)
|
||||
{
|
||||
if (GetPart(PART_MAIN) > 2)
|
||||
{
|
||||
@@ -643,7 +644,9 @@ void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE
|
||||
for (int n = 0; n < bItemCount; ++n)
|
||||
{
|
||||
const int64_t price = pTable[n].price;
|
||||
if (price <= 0 || !PortGoldCanChange(nTotalMoney, price, GOLD_MAX_64))
|
||||
const int32_t cheque = pCheque ? pCheque[n] : 0; // PORT: Won price, may stand alone
|
||||
if (price < 0 || cheque < 0 || cheque > CHEQUE_MAX || (price == 0 && cheque == 0) ||
|
||||
!PortGoldCanChange(nTotalMoney, price, GOLD_MAX_64))
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, "Invalid shop price or gold limit exceeded.");
|
||||
return;
|
||||
@@ -779,7 +782,7 @@ void CHARACTER::OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE
|
||||
|
||||
PacketAround(&p, sizeof(TPacketGCShopSign));
|
||||
|
||||
m_pkMyShop = CShopManager::instance().CreatePCShop(this, pTable, bItemCount);
|
||||
m_pkMyShop = CShopManager::instance().CreatePCShop(this, pTable, bItemCount, pCheque);
|
||||
|
||||
if (IsPolymorphed() == true)
|
||||
{
|
||||
@@ -2331,6 +2334,7 @@ void CHARACTER::ComputePoints()
|
||||
{
|
||||
long lStat = GetPoint(POINT_STAT);
|
||||
const int lGem=GetPoint(POINT_GEM);
|
||||
const int lCheque=GetPoint(POINT_CHEQUE);
|
||||
long lStatResetCount = GetPoint(POINT_STAT_RESET_COUNT);
|
||||
long lSkillActive = GetPoint(POINT_SKILL);
|
||||
long lSkillSub = GetPoint(POINT_SUB_SKILL);
|
||||
@@ -2353,6 +2357,7 @@ void CHARACTER::ComputePoints()
|
||||
|
||||
SetPoint(POINT_STAT, lStat);
|
||||
SetPoint(POINT_GEM,lGem);
|
||||
SetPoint(POINT_CHEQUE,lCheque);
|
||||
SetPoint(POINT_SKILL, lSkillActive);
|
||||
SetPoint(POINT_SUB_SKILL, lSkillSub);
|
||||
SetPoint(POINT_HORSE_SKILL, lSkillHorse);
|
||||
@@ -3461,6 +3466,11 @@ void CHARACTER::PointChange(BYTE type, int64_t amount, bool bAmount, bool bBroad
|
||||
val=GetPoint(type);
|
||||
break;
|
||||
|
||||
case POINT_CHEQUE: // display only: PortChequeChange owns the balance
|
||||
if(amount)return;
|
||||
val=GetPoint(type);
|
||||
break;
|
||||
|
||||
case POINT_GOLD:
|
||||
{
|
||||
if (!PortGoldCanChange(GetGold(),amount,GOLD_MAX_64)) {
|
||||
|
||||
@@ -293,6 +293,7 @@ enum EPointTypes
|
||||
POINT_ENCHANT_EARTH = 246,
|
||||
POINT_ENCHANT_DARK = 247,
|
||||
POINT_GEM = 248,
|
||||
POINT_CHEQUE = 249, // PORT: Won, mirrored from quest flag cheque.points
|
||||
POINT_RESIST_HUMAN = 220,
|
||||
POINT_RESIST_MAGIC_REDUCTION = 144, // AVA2 attacker's magic resistance reduction.
|
||||
|
||||
@@ -1289,7 +1290,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
void SetShopOwner(LPCHARACTER ch) { m_pkChrShopOwner = ch; }
|
||||
LPCHARACTER GetShopOwner() const { return m_pkChrShopOwner;}
|
||||
|
||||
void OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount);
|
||||
void OpenMyShop(const char * c_pszSign, TShopItemTable * pTable, BYTE bItemCount, const int32_t * pCheque = NULL);
|
||||
LPSHOP GetMyShop() const { return m_pkMyShop; }
|
||||
void CloseMyShop();
|
||||
|
||||
|
||||
@@ -305,6 +305,7 @@ ACMD (do_dragon_soul);
|
||||
ACMD (do_ds_list);
|
||||
ACMD (do_clear_affect);
|
||||
ACMD(do_gem);
|
||||
ACMD(do_won_exchange);
|
||||
ACMD(do_mt_economy);
|
||||
|
||||
ACMD(do_ishop);
|
||||
@@ -655,6 +656,7 @@ struct command_info cmd_info[] =
|
||||
#endif
|
||||
{ "mt_economy", do_mt_economy, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "gem", do_gem, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "won_exchange", do_won_exchange, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "../../common/length.h"
|
||||
#include "exchange.h"
|
||||
#include "DragonSoul.h"
|
||||
#include "port_cheque.h"
|
||||
|
||||
void exchange_packet(LPCHARACTER ch, BYTE sub_header, bool is_me, int64_t arg1, TItemPos arg2, DWORD arg3, void * pvData = NULL);
|
||||
|
||||
@@ -124,6 +125,7 @@ CExchange::CExchange(LPCHARACTER pOwner)
|
||||
}
|
||||
|
||||
m_lGold = 0;
|
||||
m_lCheque = 0;
|
||||
|
||||
m_pOwner = pOwner;
|
||||
pOwner->SetExchange(this);
|
||||
@@ -275,6 +277,35 @@ bool CExchange::AddGold(int64_t gold)
|
||||
return true;
|
||||
}
|
||||
|
||||
// PORT: Won offer; both sides need a Won-aware client (an old one would never see it).
|
||||
bool CExchange::AddCheque(int64_t cheque)
|
||||
{
|
||||
LPCHARACTER victim = GetCompany()->GetOwner();
|
||||
if (cheque <= 0 || cheque > CHEQUE_MAX || !PortChequeClientSupported(GetOwner()) || !PortChequeClientSupported(victim))
|
||||
return false;
|
||||
|
||||
if (PortChequeGet(GetOwner()) < cheque)
|
||||
{
|
||||
exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_LESS_CHEQUE, 0, 0, NPOS, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PortChequeCanChange(victim, cheque))
|
||||
{
|
||||
GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The other player can't carry more Won."));
|
||||
return false;
|
||||
}
|
||||
|
||||
Accept(false);
|
||||
GetCompany()->Accept(false);
|
||||
|
||||
m_lCheque = cheque;
|
||||
|
||||
exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_CHEQUE_ADD, true, m_lCheque, NPOS, 0);
|
||||
exchange_packet(victim, EXCHANGE_SUBHEADER_GC_CHEQUE_ADD, false, m_lCheque, NPOS, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 돈이 충분히 있는지, 교환하려는 아이템이 실제로 있는지 확인 한다.
|
||||
bool CExchange::Check(int * piItemCount)
|
||||
{
|
||||
@@ -285,6 +316,11 @@ bool CExchange::Check(int * piItemCount)
|
||||
if (m_lGold > 0 && victim->GetGold() > GOLD_MAX_64 - m_lGold)
|
||||
return false;
|
||||
|
||||
// Won settles as one net transfer in Accept, so bound the victim's final balance.
|
||||
if (m_lCheque > 0 && (PortChequeGet(GetOwner()) < m_lCheque ||
|
||||
!PortChequeCanChange(victim, m_lCheque - GetCompany()->m_lCheque)))
|
||||
return false;
|
||||
|
||||
int item_count = 0;
|
||||
|
||||
for (int i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
|
||||
@@ -616,12 +652,21 @@ bool CExchange::Accept(bool bAccept)
|
||||
|
||||
if (Done())
|
||||
{
|
||||
if (m_lGold) // 돈이 있을 떄만 저장
|
||||
const int64_t netCheque = m_lCheque - GetCompany()->m_lCheque;
|
||||
if (netCheque)
|
||||
{
|
||||
PortChequeChange(GetOwner(), -netCheque);
|
||||
PortChequeChange(victim, netCheque);
|
||||
LogManager::instance().CharLog(victim, netCheque, "EXCHANGE_CHEQUE_TAKE", GetOwner()->GetName());
|
||||
LogManager::instance().CharLog(GetOwner(), -netCheque, "EXCHANGE_CHEQUE_GIVE", victim->GetName());
|
||||
}
|
||||
|
||||
if (m_lGold || netCheque) // 돈이 있을 떄만 저장
|
||||
GetOwner()->Save();
|
||||
|
||||
if (GetCompany()->Done())
|
||||
{
|
||||
if (GetCompany()->m_lGold) // 돈이 있을 때만 저장
|
||||
if (GetCompany()->m_lGold || netCheque) // 돈이 있을 때만 저장
|
||||
victim->Save();
|
||||
|
||||
// INTERNATIONAL_VERSION
|
||||
|
||||
@@ -19,6 +19,7 @@ class CExchange
|
||||
void Cancel();
|
||||
|
||||
bool AddGold(int64_t lGold);
|
||||
bool AddCheque(int64_t lCheque);
|
||||
bool AddItem(TItemPos item_pos, BYTE display_pos);
|
||||
bool RemoveItem(BYTE pos);
|
||||
|
||||
@@ -54,6 +55,7 @@ class CExchange
|
||||
|
||||
bool m_bAccept;
|
||||
int64_t m_lGold;
|
||||
int64_t m_lCheque;
|
||||
|
||||
CGrid * m_pGrid;
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
|
||||
#include "DragonSoul.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "port_cheque.h"
|
||||
|
||||
#ifdef __AUCTION__
|
||||
#include "auction_manager.h"
|
||||
@@ -1213,6 +1214,7 @@ void CInputDB::QuestLoad(LPDESC d, const char * c_pData)
|
||||
pkPC->Build();
|
||||
ch->SetPoint(POINT_GEM, ch->GetQuestFlag("gem.points"));
|
||||
ch->PointChange(POINT_GEM, 0);
|
||||
PortChequeLoad(ch);
|
||||
|
||||
if (ch->GetDesc()->IsPhase(PHASE_GAME))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_cheque.h"
|
||||
#include "constants.h"
|
||||
#include "../../common/teen_packet.h"
|
||||
#include "config.h"
|
||||
@@ -665,6 +666,7 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
||||
PortVipRefresh(ch, false);
|
||||
CSwitchbotManager::Instance().EnterGame(ch); // PORT: AVA2 switchbot (port_switchbot.cpp)
|
||||
Ava2ChannelList(ch); // Authoritative channel after every login/warp, including same-map transfers.
|
||||
PortChequeLoad(ch); // PORT: a Won point sent at quest load (before PHASE_GAME) never reaches the client
|
||||
|
||||
if (LC_IsEurope())
|
||||
{
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "port_switchbot.h"
|
||||
#include "ava2_native_packets.h"
|
||||
#include "cube.h"
|
||||
#include "port_cheque.h"
|
||||
|
||||
extern void SendShout(const char * szText, BYTE bEmpire);
|
||||
extern int g_nPortalLimitTime;
|
||||
@@ -1244,6 +1245,11 @@ void CInputMain::Exchange(LPCHARACTER ch, const char * data)
|
||||
}
|
||||
break;
|
||||
|
||||
case EXCHANGE_SUBHEADER_CG_CHEQUE_ADD: // arg1 == amount of won (PORT)
|
||||
if (ch->GetExchange() && ch->GetExchange()->GetCompany()->GetAcceptStatus() != true)
|
||||
ch->GetExchange()->AddCheque(pinfo->arg1);
|
||||
break;
|
||||
|
||||
case EXCHANGE_SUBHEADER_CG_ACCEPT: // arg1 == not used
|
||||
if (ch->GetExchange())
|
||||
{
|
||||
@@ -2956,7 +2962,9 @@ void CInputMain::Hack(LPCHARACTER ch, const char * c_pData)
|
||||
int CInputMain::MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes)
|
||||
{
|
||||
TPacketCGMyShop * p = (TPacketCGMyShop *) c_pData;
|
||||
int iExtraLen = p->bCount * sizeof(TShopItemTable);
|
||||
// PORT: Won-aware clients append int32 cheque[bCount] after the items.
|
||||
const bool withCheque = PortChequeClientSupported(ch);
|
||||
int iExtraLen = p->bCount * (sizeof(TShopItemTable) + (withCheque ? sizeof(int32_t) : 0));
|
||||
|
||||
if (uiBytes < sizeof(TPacketCGMyShop) + iExtraLen)
|
||||
return -1;
|
||||
@@ -2978,7 +2986,8 @@ int CInputMain::MyShop(LPCHARACTER ch, const char * c_pData, size_t uiBytes)
|
||||
}
|
||||
|
||||
sys_log(0, "MyShop count %d", p->bCount);
|
||||
ch->OpenMyShop(p->szSign, (TShopItemTable *) (c_pData + sizeof(TPacketCGMyShop)), p->bCount);
|
||||
const int32_t * pCheque = withCheque ? (const int32_t *) (c_pData + sizeof(TPacketCGMyShop) + p->bCount * sizeof(TShopItemTable)) : NULL;
|
||||
ch->OpenMyShop(p->szSign, (TShopItemTable *) (c_pData + sizeof(TPacketCGMyShop)), p->bCount, pCheque);
|
||||
return (iExtraLen);
|
||||
}
|
||||
|
||||
|
||||
@@ -841,6 +841,7 @@ enum
|
||||
EXCHANGE_SUBHEADER_CG_ELK_ADD, /* arg1 == amount of gold */
|
||||
EXCHANGE_SUBHEADER_CG_ACCEPT, /* arg1 == not used */
|
||||
EXCHANGE_SUBHEADER_CG_CANCEL, /* arg1 == not used */
|
||||
EXCHANGE_SUBHEADER_CG_CHEQUE_ADD, /* arg1 == amount of won (PORT) */
|
||||
};
|
||||
|
||||
typedef struct command_exchange
|
||||
@@ -1395,6 +1396,9 @@ enum EPacketShopSubHeaders
|
||||
SHOP_SUBHEADER_GC_REFRESH_COUNT,
|
||||
SHOP_SUBHEADER_GC_CHANGE_TITLE,
|
||||
#endif
|
||||
// PORT: Won prices for mt>=20261027 clients; START_CHEQUE = START + int32 cheque[SHOP_HOST_ITEM_MAX_NUM].
|
||||
SHOP_SUBHEADER_GC_START_CHEQUE = 40,
|
||||
SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE = 41,
|
||||
};
|
||||
|
||||
struct packet_shop_item
|
||||
@@ -1467,6 +1471,8 @@ enum EPacketTradeSubHeaders
|
||||
EXCHANGE_SUBHEADER_GC_END, /* arg1 == not used */
|
||||
EXCHANGE_SUBHEADER_GC_ALREADY, /* arg1 == not used */
|
||||
EXCHANGE_SUBHEADER_GC_LESS_GOLD, /* arg1 == not used */
|
||||
EXCHANGE_SUBHEADER_GC_CHEQUE_ADD, /* arg1 == won (PORT) */
|
||||
EXCHANGE_SUBHEADER_GC_LESS_CHEQUE, /* arg1 == not used */
|
||||
};
|
||||
|
||||
struct packet_position
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_cheque.h"
|
||||
#include "char.h"
|
||||
#include "desc.h"
|
||||
#include "questmanager.h"
|
||||
#include "questpc.h"
|
||||
#include "log.h"
|
||||
#include "cmd.h"
|
||||
#include "../../common/gold_bounds.h"
|
||||
#include <sstream>
|
||||
|
||||
bool PortClientAtLeast(const CHARACTER* ch, int minDate)
|
||||
{
|
||||
const char* version = ch && ch->GetDesc() ? strstr(ch->GetDesc()->GetClientVersion(), "mt") : NULL;
|
||||
return version && atoi(version + 2) >= minDate;
|
||||
}
|
||||
|
||||
bool PortChequeClientSupported(const CHARACTER* ch)
|
||||
{
|
||||
return PortClientAtLeast(ch, CHEQUE_MIN_CLIENT);
|
||||
}
|
||||
|
||||
static quest::PC* FN_cheque_pc(const CHARACTER* ch)
|
||||
{
|
||||
if (!ch || !ch->IsPC())
|
||||
return NULL;
|
||||
quest::PC* pc = quest::CQuestManager::instance().GetPCForce(ch->GetPlayerID());
|
||||
return pc && pc->IsLoaded() ? pc : NULL;
|
||||
}
|
||||
|
||||
int PortChequeGet(const CHARACTER* ch)
|
||||
{
|
||||
quest::PC* pc = FN_cheque_pc(ch);
|
||||
if (!pc)
|
||||
return 0;
|
||||
const int value = pc->GetFlag("cheque.points");
|
||||
return value < 0 ? 0 : (value > CHEQUE_MAX ? CHEQUE_MAX : value);
|
||||
}
|
||||
|
||||
bool PortChequeCanChange(const CHARACTER* ch, int64_t delta)
|
||||
{
|
||||
return FN_cheque_pc(ch) && PortGoldCanChange(PortChequeGet(ch), delta, CHEQUE_MAX);
|
||||
}
|
||||
|
||||
bool PortChequeChange(CHARACTER* ch, int64_t delta)
|
||||
{
|
||||
if (!PortChequeCanChange(ch, delta))
|
||||
return false;
|
||||
const int updated = static_cast<int>(PortChequeGet(ch) + delta);
|
||||
FN_cheque_pc(ch)->SetFlag("cheque.points", updated);
|
||||
ch->SetPoint(POINT_CHEQUE, updated);
|
||||
ch->PointChange(POINT_CHEQUE, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PortChequeLoad(CHARACTER* ch)
|
||||
{
|
||||
if (!FN_cheque_pc(ch))
|
||||
return;
|
||||
ch->SetPoint(POINT_CHEQUE, PortChequeGet(ch));
|
||||
ch->PointChange(POINT_CHEQUE, 0);
|
||||
}
|
||||
|
||||
// "/won_exchange sell N" turns N Won into N*100M yang, "buy N" the reverse (uiwonexchange.py).
|
||||
ACMD(do_won_exchange)
|
||||
{
|
||||
if (!ch || !ch->IsPC() || !ch->GetDesc() || ch->IsWarping() || ch->IsDead())
|
||||
return;
|
||||
if (ch->GetExchange() || ch->GetMyShop() || ch->GetShopOwner() || ch->IsOpenSafebox() || ch->IsCubeOpen())
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Close the other windows first."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::istringstream input(argument);
|
||||
std::string mode;
|
||||
long long amount = 0;
|
||||
if (!(input >> mode >> amount) || amount < 1 || amount > CHEQUE_MAX || (mode != "sell" && mode != "buy"))
|
||||
return;
|
||||
|
||||
const int64_t yang = amount * WON_EXCHANGE_YANG;
|
||||
const int64_t won = mode == "sell" ? -amount : amount;
|
||||
const int64_t gold = mode == "sell" ? yang : -yang;
|
||||
|
||||
if (!PortChequeCanChange(ch, won))
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT(won < 0 ? "You don't have enough Won." : "You can't carry more Won."));
|
||||
return;
|
||||
}
|
||||
if (!PortGoldCanChange(ch->GetGold(), gold, GOLD_MAX_64))
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT(gold < 0 ? "You don't have enough Yang." : "You can't carry more Yang."));
|
||||
return;
|
||||
}
|
||||
|
||||
PortChequeChange(ch, won);
|
||||
ch->PointChange(POINT_GOLD, gold, true);
|
||||
ch->Save();
|
||||
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%s %lld won %lld yang", mode.c_str(), amount, (long long)gold);
|
||||
LogManager::instance().CharLog(ch, amount, "WON_EXCHANGE", buf);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
// PORT: Won (cheque) currency. The balance lives in quest flag "cheque.points" (saved with the
|
||||
// quest PC, like gem.points) and is mirrored into POINT_CHEQUE for the client.
|
||||
enum EChequeConstants
|
||||
{
|
||||
CHEQUE_MAX = 999,
|
||||
CHEQUE_MIN_CLIENT = 20261027,
|
||||
};
|
||||
|
||||
static const int64_t WON_EXCHANGE_YANG = 100000000LL;
|
||||
|
||||
class CHARACTER;
|
||||
|
||||
// True when the client sends "mt<date>" with date >= minDate.
|
||||
bool PortClientAtLeast(const CHARACTER* ch, int minDate);
|
||||
bool PortChequeClientSupported(const CHARACTER* ch);
|
||||
|
||||
int PortChequeGet(const CHARACTER* ch);
|
||||
bool PortChequeCanChange(const CHARACTER* ch, int64_t delta);
|
||||
bool PortChequeChange(CHARACTER* ch, int64_t delta);
|
||||
void PortChequeLoad(CHARACTER* ch);
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "locale_service.h"
|
||||
#include "unique_item.h"
|
||||
#include "port_battlepass_hooks.h"
|
||||
#include "port_cheque.h"
|
||||
|
||||
// MT: the sockets ITEM_MANAGER::CreateItem gives a new item of this vnum (its remaining time), sent
|
||||
// with an NPC shop's items so the client tooltip shows how long a bought one lasts instead of 0.
|
||||
@@ -129,7 +130,7 @@ bool CShop::Create(DWORD dwVnum, DWORD dwNPCVnum, TShopItemTable * pTable)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount)
|
||||
void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount, const int32_t * pCheque)
|
||||
{
|
||||
if (bItemCount > SHOP_HOST_ITEM_MAX_NUM)
|
||||
return;
|
||||
@@ -141,6 +142,7 @@ void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount)
|
||||
|
||||
for (int i = 0; i < bItemCount; ++i, ++pTable)
|
||||
{
|
||||
const int32_t cheque = pCheque ? pCheque[i] : 0;
|
||||
LPITEM pkItem = NULL;
|
||||
const TItemTable * item_table;
|
||||
|
||||
@@ -212,6 +214,7 @@ void CShop::SetShopItems(TShopItemTable * pTable, BYTE bItemCount)
|
||||
item.count = pkItem->GetCount(); // PC 샵의 경우 아이템 개수는 진짜 아이템의 개수여야 한다.
|
||||
item.price = pTable->price; // 가격도 사용자가 정한대로..
|
||||
item.itemid = pkItem->GetID();
|
||||
item.cheque = cheque;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -293,6 +296,17 @@ int CShop::Buy(LPCHARACTER ch, BYTE pos)
|
||||
return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
|
||||
}
|
||||
|
||||
const int cheque = m_pkPC ? r_item.cheque : 0;
|
||||
if (cheque < 0 || cheque > CHEQUE_MAX || (cheque > 0 && (!PortChequeClientSupported(ch) || m_pkPC == ch)))
|
||||
return SHOP_SUBHEADER_GC_INVALID_POS;
|
||||
if (cheque > 0 && PortChequeGet(ch) < cheque)
|
||||
return SHOP_SUBHEADER_GC_NOT_ENOUGH_CHEQUE;
|
||||
if (cheque > 0 && !PortChequeCanChange(m_pkPC, cheque))
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The seller can't hold more Won."));
|
||||
return SHOP_SUBHEADER_GC_INVALID_POS;
|
||||
}
|
||||
|
||||
LPITEM item;
|
||||
|
||||
if (m_pkPC) // 피씨가 운영하는 샵은 피씨가 실제 아이템을 가지고있어야 한다.
|
||||
@@ -407,6 +421,15 @@ int CShop::Buy(LPCHARACTER ch, BYTE pos)
|
||||
|
||||
m_pkPC->PointChange(POINT_GOLD, dwPrice, false);
|
||||
|
||||
if (cheque > 0)
|
||||
{
|
||||
PortChequeChange(ch, -cheque);
|
||||
PortChequeChange(m_pkPC, cheque);
|
||||
LogManager::instance().CharLog(ch, -cheque, "SHOP_BUY_CHEQUE", m_pkPC->GetName());
|
||||
LogManager::instance().CharLog(m_pkPC, cheque, "SHOP_SELL_CHEQUE", ch->GetName());
|
||||
m_pkPC->Save();
|
||||
}
|
||||
|
||||
if (iVal > 0)
|
||||
m_pkPC->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("판매금액의 %d %% 가 세금으로 나가게됩니다"), iVal);
|
||||
|
||||
@@ -468,12 +491,17 @@ bool CShop::AddGuest(LPCHARACTER ch, DWORD owner_vid, bool bOtherEmpire)
|
||||
|
||||
TPacketGCShop pack;
|
||||
|
||||
// PORT: PC shops tell Won-aware clients each item's Won price; older clients never see Won items.
|
||||
const bool sendCheque = m_pkPC && PortChequeClientSupported(ch);
|
||||
|
||||
pack.header = HEADER_GC_SHOP;
|
||||
pack.subheader = SHOP_SUBHEADER_GC_START;
|
||||
pack.subheader = sendCheque ? SHOP_SUBHEADER_GC_START_CHEQUE : SHOP_SUBHEADER_GC_START;
|
||||
|
||||
TPacketGCShopStart pack2;
|
||||
int32_t cheques[SHOP_HOST_ITEM_MAX_NUM];
|
||||
|
||||
memset(&pack2, 0, sizeof(pack2));
|
||||
memset(cheques, 0, sizeof(cheques));
|
||||
pack2.owner_vid = owner_vid;
|
||||
|
||||
for (DWORD i = 0; i < m_itemVector.size() && i < SHOP_HOST_ITEM_MAX_NUM; ++i)
|
||||
@@ -493,11 +521,16 @@ bool CShop::AddGuest(LPCHARACTER ch, DWORD owner_vid, bool bOtherEmpire)
|
||||
if (m_pkPC && !item.pkItem)
|
||||
continue;
|
||||
|
||||
if (m_pkPC && item.cheque > 0 && !sendCheque)
|
||||
continue;
|
||||
|
||||
cheques[i] = m_pkPC ? item.cheque : 0;
|
||||
pack2.items[i].vnum = item.vnum;
|
||||
|
||||
if (!PortShopQuote(item.price, !IsPCShop() && bOtherEmpire, GOLD_MAX_64, pack2.items[i].price))
|
||||
{
|
||||
memset(&pack2.items[i], 0, sizeof(pack2.items[i]));
|
||||
cheques[i] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -512,10 +545,16 @@ bool CShop::AddGuest(LPCHARACTER ch, DWORD owner_vid, bool bOtherEmpire)
|
||||
MT_GetNewItemSockets(item.vnum, pack2.items[i].alSockets);
|
||||
}
|
||||
|
||||
pack.size = sizeof(pack) + sizeof(pack2);
|
||||
pack.size = sizeof(pack) + sizeof(pack2) + (sendCheque ? sizeof(cheques) : 0);
|
||||
|
||||
ch->GetDesc()->BufferedPacket(&pack, sizeof(TPacketGCShop));
|
||||
ch->GetDesc()->Packet(&pack2, sizeof(TPacketGCShopStart));
|
||||
if (sendCheque)
|
||||
{
|
||||
ch->GetDesc()->BufferedPacket(&pack2, sizeof(TPacketGCShopStart));
|
||||
ch->GetDesc()->Packet(cheques, sizeof(cheques));
|
||||
}
|
||||
else
|
||||
ch->GetDesc()->Packet(&pack2, sizeof(TPacketGCShopStart));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class CShop
|
||||
BYTE count; // 아이템 개수
|
||||
|
||||
LPITEM pkItem;
|
||||
int cheque; // PORT: Won price (PC shops only)
|
||||
int itemid; // 아이템 고유아이디
|
||||
|
||||
shop_item()
|
||||
@@ -27,6 +28,7 @@ class CShop
|
||||
price = 0;
|
||||
count = 0;
|
||||
itemid = 0;
|
||||
cheque = 0;
|
||||
pkItem = NULL;
|
||||
}
|
||||
} SHOP_ITEM;
|
||||
@@ -35,7 +37,7 @@ class CShop
|
||||
~CShop();
|
||||
|
||||
bool Create(DWORD dwVnum, DWORD dwNPCVnum, TShopItemTable * pItemTable);
|
||||
void SetShopItems(TShopItemTable * pItemTable, BYTE bItemCount);
|
||||
void SetShopItems(TShopItemTable * pItemTable, BYTE bItemCount, const int32_t * pCheque = NULL);
|
||||
|
||||
virtual void SetPCShop(LPCHARACTER ch);
|
||||
virtual bool IsPCShop() { return m_pkPC ? true : false; }
|
||||
|
||||
@@ -164,14 +164,14 @@ LPSHOP CShopManager::FindPCShop(DWORD dwVID)
|
||||
return it->second;
|
||||
}
|
||||
|
||||
LPSHOP CShopManager::CreatePCShop(LPCHARACTER ch, TShopItemTable * pTable, BYTE bItemCount)
|
||||
LPSHOP CShopManager::CreatePCShop(LPCHARACTER ch, TShopItemTable * pTable, BYTE bItemCount, const int32_t * pCheque)
|
||||
{
|
||||
if (FindPCShop(ch->GetVID()))
|
||||
return NULL;
|
||||
|
||||
LPSHOP pkShop = M2_NEW CShop;
|
||||
pkShop->SetPCShop(ch);
|
||||
pkShop->SetShopItems(pTable, bItemCount);
|
||||
pkShop->SetShopItems(pTable, bItemCount, pCheque);
|
||||
|
||||
m_map_pkShopByPC.insert(TShopMap::value_type(ch->GetVID(), pkShop));
|
||||
return pkShop;
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
void Buy(LPCHARACTER ch, BYTE pos);
|
||||
void Sell(LPCHARACTER ch, BYTE bCell, BYTE bCount=0);
|
||||
|
||||
LPSHOP CreatePCShop(LPCHARACTER ch, TShopItemTable * pTable, BYTE bItemCount);
|
||||
LPSHOP CreatePCShop(LPCHARACTER ch, TShopItemTable * pTable, BYTE bItemCount, const int32_t * pCheque = NULL);
|
||||
LPSHOP FindPCShop(DWORD dwVID);
|
||||
void DestroyPCShop(LPCHARACTER ch);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user