feat: complete Stage 6 item shop, durable point queue, Gaya market, and alchemy parity
- Implement durable point drop intent journal on disk with fsync before network send - Fix DB point settlement day by fixing CURDATE() on initial account row lock within transaction - Implement Gaya market subsystem (port_gaya.cpp/h, 27 slots, 55 items, filesystem persistence, /gem command) - Add POINT_GEM (248) to CHARACTER and support 39063 / 39064 right-click usage - Fix treasure key (77921~77923) and box (77918~77920) stack decrement in char_item.cpp - Verify Dragon Soul recharge items 100001 / 100002 and holly bean 100500 DoRefineStrength - Add 8 verified products (144, 145, 149, 233, 234, 240, 241, 242) to verified-products.json (count: 57) - Add comprehensive test suites for durable queue, Gaya market, key stacks, and dragon soul alchemy
This commit is contained in:
@@ -82,7 +82,9 @@ void CClientManager::Ava2ItemShop(CPeer* peer,DWORD handle,const char* data,DWOR
|
||||
if(tx.active) {
|
||||
auto owner=query("SELECT account_id FROM player WHERE id="+decimal(r.player));
|
||||
auto wallet=query("SELECT coins FROM "+adb+".account WHERE id="+aid+" FOR UPDATE");
|
||||
if(ok(owner) && owner->Get()->uiNumRows==1 && strtoul(mysql_fetch_row(owner->Get()->pSQLResult)[0],0,10)==r.account && ok(wallet) && wallet->Get()->uiNumRows==1) {
|
||||
auto dateQ=query("SELECT CURDATE()");
|
||||
if(ok(owner) && owner->Get()->uiNumRows==1 && strtoul(mysql_fetch_row(owner->Get()->pSQLResult)[0],0,10)==r.account && ok(wallet) && wallet->Get()->uiNumRows==1 && ok(dateQ) && dateQ->Get()->uiNumRows==1) {
|
||||
const std::string rewardDay = mysql_fetch_row(dateQ->Get()->pSQLResult)[0];
|
||||
balance=strtoll(mysql_fetch_row(wallet->Get()->pSQLResult)[0],0,10);
|
||||
auto previous=query("SELECT account_id,vnum,requested,amount FROM port_point_rewards WHERE token='"+std::string(r.token)+"'");
|
||||
if(ok(previous) && previous->Get()->uiNumRows==1) {
|
||||
@@ -91,13 +93,13 @@ void CClientManager::Ava2ItemShop(CPeer* peer,DWORD handle,const char* data,DWOR
|
||||
} else if(ok(previous)) {
|
||||
if(!rule.eligible(mob->bLevel,r.expectedVnum) || r.count<uint32_t(rule.minimum) || r.count>uint32_t(rule.maximum))status=1;
|
||||
else {
|
||||
auto earned=query("SELECT COALESCE(SUM(amount),0) FROM port_point_rewards WHERE account_id="+aid+" AND reward_day=CURDATE()");
|
||||
auto earned=query("SELECT COALESCE(SUM(amount),0) FROM port_point_rewards WHERE account_id="+aid+" AND reward_day='"+rewardDay+"'");
|
||||
if(ok(earned) && earned->Get()->uiNumRows==1) {
|
||||
granted=PortPointDropAmount(r.count,strtoull(mysql_fetch_row(earned->Get()->pSQLResult)[0],0,10),rule.dailyCap);
|
||||
if(balance<0 || uint64_t(balance)>uint64_t(INT64_MAX)-granted){status=1;granted=0;}
|
||||
else {
|
||||
bool success=run("UPDATE "+adb+".account SET coins=coins+"+decimal(granted)+" WHERE id="+aid);
|
||||
success=success && run("INSERT INTO port_point_rewards(token,account_id,player_id,vnum,requested,amount,reward_day) VALUES('"+std::string(r.token)+"',"+aid+","+decimal(r.player)+","+decimal(r.product)+","+decimal(r.count)+","+decimal(granted)+",CURDATE())");
|
||||
success=success && run("INSERT INTO port_point_rewards(token,account_id,player_id,vnum,requested,amount,reward_day) VALUES('"+std::string(r.token)+"',"+aid+","+decimal(r.player)+","+decimal(r.product)+","+decimal(r.count)+","+decimal(granted)+",'"+rewardDay+"')");
|
||||
if(success){if(tx.commit()){balance+=granted;status=0;}else status=8;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ CPPFILE = BattleArena.cpp FSM.cpp MarkConvert.cpp MarkImage.cpp MarkManager.cpp
|
||||
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 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 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\
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <cctype>
|
||||
#include <map>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include "char_manager.h"
|
||||
#include "questmanager.h"
|
||||
@@ -22,16 +23,90 @@ namespace {
|
||||
struct PendingPoints { Ava2ShopRequest request; unsigned handle; int attempts; time_t next; };
|
||||
std::map<std::string, PendingPoints> pendingPoints;
|
||||
LPEVENT pointRetryEvent = NULL;
|
||||
std::string s_pointLogPath = "log/point_rewards_pending.log";
|
||||
|
||||
bool AppendDurableIntent(const Ava2ShopRequest& r) {
|
||||
if (s_pointLogPath.empty()) return false;
|
||||
size_t slash = s_pointLogPath.rfind('/');
|
||||
if (slash != std::string::npos) {
|
||||
std::string dir = s_pointLogPath.substr(0, slash);
|
||||
mkdir(dir.c_str(), 0755);
|
||||
}
|
||||
FILE* fp = fopen(s_pointLogPath.c_str(), "a");
|
||||
if (!fp) return false;
|
||||
int res = fprintf(fp, "INTENT v1 %s %u %u %u %u %u %lld\n",
|
||||
r.token, r.account, r.player, r.product, r.count, r.expectedVnum, (long long)time(0));
|
||||
if (res < 0) { fclose(fp); return false; }
|
||||
if (fflush(fp) != 0) { fclose(fp); return false; }
|
||||
if (fsync(fileno(fp)) != 0) { fclose(fp); return false; }
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppendDurableDone(const char* token, uint8_t status, uint32_t granted, int64_t balance) {
|
||||
if (s_pointLogPath.empty()) return false;
|
||||
FILE* fp = fopen(s_pointLogPath.c_str(), "a");
|
||||
if (!fp) return false;
|
||||
int res = fprintf(fp, "DONE v1 %s %u %u %lld %lld\n",
|
||||
token, (unsigned)status, (unsigned)granted, (long long)balance, (long long)time(0));
|
||||
if (res < 0) { fclose(fp); return false; }
|
||||
if (fflush(fp) != 0) { fclose(fp); return false; }
|
||||
if (fsync(fileno(fp)) != 0) { fclose(fp); return false; }
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CompactDurableLog() {
|
||||
if (s_pointLogPath.empty()) return;
|
||||
FILE* fp = fopen(s_pointLogPath.c_str(), "r");
|
||||
if (!fp) return;
|
||||
std::map<std::string, Ava2ShopRequest> uncompleted;
|
||||
char line[256];
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
char op[16] = {}, ver[16] = {}, token[64] = {};
|
||||
if (sscanf(line, "%15s %15s %63s", op, ver, token) >= 3) {
|
||||
if (strcmp(op, "INTENT") == 0) {
|
||||
Ava2ShopRequest r = {};
|
||||
r.operation = 3;
|
||||
unsigned long long t = 0;
|
||||
if (sscanf(line, "%*s %*s %32s %u %u %u %u %u %llu",
|
||||
r.token, &r.account, &r.player, &r.product, &r.count, &r.expectedVnum, &t) >= 6) {
|
||||
uncompleted[token] = r;
|
||||
}
|
||||
} else if (strcmp(op, "DONE") == 0) {
|
||||
uncompleted.erase(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
std::string tmpPath = s_pointLogPath + ".tmp";
|
||||
FILE* out = fopen(tmpPath.c_str(), "w");
|
||||
if (!out) return;
|
||||
for (const auto& kv : uncompleted) {
|
||||
const auto& r = kv.second;
|
||||
fprintf(out, "INTENT v1 %s %u %u %u %u %u 0\n",
|
||||
r.token, r.account, r.player, r.product, r.count, r.expectedVnum);
|
||||
}
|
||||
fflush(out);
|
||||
fsync(fileno(out));
|
||||
fclose(out);
|
||||
rename(tmpPath.c_str(), s_pointLogPath.c_str());
|
||||
}
|
||||
|
||||
EVENTINFO(PointRetryInfo) {};
|
||||
EVENTFUNC(RetryPoints) {
|
||||
for(auto it=pendingPoints.begin();it!=pendingPoints.end();) {
|
||||
auto& p=it->second;
|
||||
if(get_global_time()<p.next){++it;continue;}
|
||||
if(p.attempts>=12) {
|
||||
sys_err("POINT_DROP: retry exhausted account=%u token=%s",p.request.account,p.request.token);
|
||||
it=pendingPoints.erase(it);continue;
|
||||
sys_err("POINT_DROP: retry throttled account=%u token=%s attempts=%d",p.request.account,p.request.token,p.attempts);
|
||||
p.next=get_global_time()+60; // Throttled retry: resend every 60s, never silently drop!
|
||||
if(db_clientdesc) db_clientdesc->DBPacket(76,p.handle,&p.request,sizeof(p.request));
|
||||
++p.attempts;++it;
|
||||
continue;
|
||||
}
|
||||
db_clientdesc->DBPacket(76,p.handle,&p.request,sizeof(p.request));
|
||||
if(db_clientdesc) db_clientdesc->DBPacket(76,p.handle,&p.request,sizeof(p.request));
|
||||
++p.attempts;p.next=get_global_time()+10;++it;
|
||||
}
|
||||
if(pendingPoints.empty()){pointRetryEvent=NULL;return 0;}
|
||||
@@ -44,8 +119,9 @@ bool PointReply(const Ava2ShopReply& reply,const char* data) {
|
||||
if(found==pendingPoints.end() || found->second.request.account!=reply.account || found->second.request.player!=reply.player)return true;
|
||||
const uint8_t status=uint8_t(data[1]);
|
||||
if(status==6 || status==8)return true; // Same durable token retries transaction/commit uncertainty.
|
||||
pendingPoints.erase(found);
|
||||
uint32_t amount=0;int64_t balance=0;memcpy(&amount,data+34,4);memcpy(&balance,data+38,8);
|
||||
AppendDurableDone(token, status, amount, balance);
|
||||
pendingPoints.erase(found);
|
||||
auto ch=CHARACTER_MANAGER::instance().FindByPID(reply.player);
|
||||
if(status || !amount || balance<0 || !ch || !ch->GetDesc() || ch->GetDesc()->GetAccountTable().id!=reply.account)return true;
|
||||
const char* version=strstr(ch->GetDesc()->GetClientVersion(),"mt");
|
||||
@@ -55,20 +131,79 @@ bool PointReply(const Ava2ShopReply& reply,const char* data) {
|
||||
}
|
||||
}
|
||||
|
||||
void Ava2PointDropSetLogPath(const std::string& path) {
|
||||
s_pointLogPath = path;
|
||||
}
|
||||
|
||||
const std::string& Ava2PointDropGetLogPath() {
|
||||
return s_pointLogPath;
|
||||
}
|
||||
|
||||
size_t Ava2PointPendingCount() {
|
||||
return pendingPoints.size();
|
||||
}
|
||||
|
||||
void Ava2PointDropInit() {
|
||||
if (s_pointLogPath.empty()) return;
|
||||
FILE* fp = fopen(s_pointLogPath.c_str(), "r");
|
||||
if (!fp) return;
|
||||
std::map<std::string, Ava2ShopRequest> uncompleted;
|
||||
char line[256];
|
||||
int doneCount = 0;
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
char op[16] = {}, ver[16] = {}, token[64] = {};
|
||||
if (sscanf(line, "%15s %15s %63s", op, ver, token) >= 3) {
|
||||
if (strcmp(op, "INTENT") == 0) {
|
||||
Ava2ShopRequest r = {};
|
||||
r.operation = 3;
|
||||
unsigned long long t = 0;
|
||||
if (sscanf(line, "%*s %*s %32s %u %u %u %u %u %llu",
|
||||
r.token, &r.account, &r.player, &r.product, &r.count, &r.expectedVnum, &t) >= 6) {
|
||||
uncompleted[token] = r;
|
||||
}
|
||||
} else if (strcmp(op, "DONE") == 0) {
|
||||
uncompleted.erase(token);
|
||||
++doneCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
for (const auto& kv : uncompleted) {
|
||||
const auto& r = kv.second;
|
||||
if (pendingPoints.find(r.token) == pendingPoints.end()) {
|
||||
PendingPoints pending = {r, 0, 1, get_global_time() + 2};
|
||||
pendingPoints.emplace(r.token, pending);
|
||||
}
|
||||
}
|
||||
|
||||
if (doneCount > 500) {
|
||||
CompactDurableLog();
|
||||
}
|
||||
|
||||
if (!pendingPoints.empty() && !pointRetryEvent) {
|
||||
pointRetryEvent = event_create(RetryPoints, AllocEventInfo<PointRetryInfo>(), PASSES_PER_SEC(1));
|
||||
}
|
||||
}
|
||||
|
||||
void Ava2PointDrop(CHARACTER* ch,CHARACTER* victim) {
|
||||
if(!ch || !victim || !ch->IsPC() || !ch->GetDesc() || victim->IsPC() || victim->IsPet() ||
|
||||
(!victim->IsMonster() && !victim->IsStone()))return;
|
||||
const auto rule=PortPointRule([](const std::string& key){return quest::CQuestManager::instance().GetEventFlag(key);},victim->IsStone());
|
||||
if(!rule.eligible(victim->GetLevel(),ch->GetLevel()) || number(1,10000)>rule.chance)return;
|
||||
if(pendingPoints.size()>=4096){sys_err("POINT_DROP: pending queue full");return;}
|
||||
if(pendingPoints.size()>=4096){sys_err("POINT_DROP: pending queue full, drop suppressed");return;}
|
||||
Ava2ShopRequest p={};p.operation=3;p.account=ch->GetDesc()->GetAccountTable().id;p.player=ch->GetPlayerID();
|
||||
p.product=victim->GetRaceNum();p.count=number(rule.minimum,rule.maximum);p.expectedVnum=ch->GetLevel();
|
||||
static const uint64_t boot=[](){timeval t;gettimeofday(&t,NULL);return (uint64_t(t.tv_sec)*1000000+t.tv_usec) ^ (uint64_t(getpid())<<32);}();
|
||||
static uint64_t serial=0;
|
||||
snprintf(p.token,sizeof(p.token),"%016llx%016llx",static_cast<unsigned long long>(boot),static_cast<unsigned long long>(++serial));
|
||||
strlcpy(p.name,ch->GetName(),sizeof(p.name));
|
||||
if (!AppendDurableIntent(p)) {
|
||||
sys_err("POINT_DROP: failed to write durable log, drop aborted for account=%u token=%s", p.account, p.token);
|
||||
return;
|
||||
}
|
||||
PendingPoints pending={p,ch->GetDesc()->GetHandle(),1,get_global_time()+10};pendingPoints.emplace(p.token,pending);
|
||||
db_clientdesc->DBPacket(76,pending.handle,&p,sizeof(p));
|
||||
if(db_clientdesc) db_clientdesc->DBPacket(76,pending.handle,&p,sizeof(p));
|
||||
if(!pointRetryEvent)pointRetryEvent=event_create(RetryPoints,AllocEventInfo<PointRetryInfo>(),PASSES_PER_SEC(1));
|
||||
}
|
||||
ACMD(do_ishop) {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
class CHARACTER;
|
||||
void Ava2ItemShopReply(unsigned long handle,const char* data);
|
||||
void Ava2PointDrop(CHARACTER* player, CHARACTER* victim);
|
||||
void Ava2PointDropInit();
|
||||
void Ava2PointDropSetLogPath(const std::string& path);
|
||||
const std::string& Ava2PointDropGetLogPath();
|
||||
size_t Ava2PointPendingCount();
|
||||
|
||||
@@ -290,6 +290,7 @@ enum EPointTypes
|
||||
POINT_ENCHANT_WIND = 245,
|
||||
POINT_ENCHANT_EARTH = 246,
|
||||
POINT_ENCHANT_DARK = 247,
|
||||
POINT_GEM = 248,
|
||||
POINT_RESIST_HUMAN = 220,
|
||||
|
||||
// 추가 속성 저항
|
||||
@@ -1193,6 +1194,12 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
void OpenChest(LPITEM item, WORD count);
|
||||
bool AutoGiveItemChest(LPITEM item, DWORD& count, std::map<LPITEM, WORD>& updates);
|
||||
bool GiveItemFromSpecialItemGroupNew(DWORD group, WORD& count);
|
||||
int GetGem() const;
|
||||
void ChangeGem(int amount);
|
||||
bool OpenGemSlot();
|
||||
void RefreshGemALL(bool withRealTime = false);
|
||||
void RefreshGemPlayer();
|
||||
void BuyGemItem(BYTE slotIndex);
|
||||
bool PickupItem(DWORD vid);
|
||||
bool EquipItem(LPITEM item, int iCandidateCell = -1);
|
||||
bool UnequipItem(LPITEM item);
|
||||
|
||||
@@ -2741,8 +2741,8 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
|
||||
if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
|
||||
{
|
||||
ITEM_MANAGER::instance().RemoveItem(item);
|
||||
ITEM_MANAGER::instance().RemoveItem(item2);
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
item2->SetCount(item2->GetCount() - 1);
|
||||
|
||||
for (int i = 0; i < count; i++){
|
||||
switch (dwVnums[i])
|
||||
@@ -3232,6 +3232,19 @@ bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
|
||||
item->SetCount(item->GetCount()-1);
|
||||
return true;
|
||||
}
|
||||
if(item->GetVnum()==39063) {
|
||||
RefreshGemALL();
|
||||
item->SetCount(item->GetCount()-1);
|
||||
return true;
|
||||
}
|
||||
if(item->GetVnum()==39064) {
|
||||
if(OpenGemSlot()) {
|
||||
item->SetCount(item->GetCount()-1);
|
||||
return true;
|
||||
}
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("더 이상 슬롯을 확장할 수 없습니다."));
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (item->GetVnum())
|
||||
{
|
||||
|
||||
+32
-30
@@ -197,7 +197,7 @@ ACMD(do_add_socket);
|
||||
|
||||
ACMD(do_inputall)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("명령어를 모두 입력하세요."));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("명령어를 모두 입력하세요."));
|
||||
}
|
||||
|
||||
ACMD(do_show_arena_list);
|
||||
@@ -217,7 +217,7 @@ ACMD(do_effect);
|
||||
ACMD(do_threeway_war_info );
|
||||
ACMD(do_threeway_war_myinfo );
|
||||
//
|
||||
//군주 전용기능
|
||||
//군주 전용기능
|
||||
ACMD(do_monarch_warpto);
|
||||
ACMD(do_monarch_transfer);
|
||||
ACMD(do_monarch_info);
|
||||
@@ -226,7 +226,7 @@ ACMD(do_monarch_tax);
|
||||
ACMD(do_monarch_mob);
|
||||
ACMD(do_monarch_notice);
|
||||
|
||||
//군주 관리 기능
|
||||
//군주 관리 기능
|
||||
ACMD(do_rmcandidacy);
|
||||
ACMD(do_setmonarch);
|
||||
ACMD(do_rmmonarch);
|
||||
@@ -234,10 +234,10 @@ ACMD(do_rmmonarch);
|
||||
ACMD(do_hair);
|
||||
//gift notify quest command
|
||||
ACMD(do_gift);
|
||||
// 큐브관련
|
||||
// 큐브관련
|
||||
ACMD(do_inventory);
|
||||
ACMD(do_cube);
|
||||
// 공성전
|
||||
// 공성전
|
||||
ACMD(do_siege);
|
||||
ACMD(do_temp);
|
||||
ACMD(do_frog);
|
||||
@@ -265,7 +265,7 @@ ACMD(do_ride);
|
||||
ACMD(do_get_item_id_list);
|
||||
ACMD(do_set_socket);
|
||||
#ifdef __AUCTION__
|
||||
// temp_auction 임시
|
||||
// temp_auction 임시
|
||||
ACMD(do_get_auction_list);
|
||||
ACMD (do_get_my_auction_list);
|
||||
ACMD (do_get_my_purchase_list);
|
||||
@@ -285,30 +285,31 @@ ACMD (do_cancel_sale);
|
||||
ACMD (do_rebid);
|
||||
ACMD (do_bid_cancel);
|
||||
#endif
|
||||
// 코스츔 상태보기 및 벗기
|
||||
// 코스츔 상태보기 및 벗기
|
||||
ACMD(do_costume);
|
||||
ACMD(do_set_stat);
|
||||
|
||||
// 무적
|
||||
// 무적
|
||||
ACMD (do_can_dead);
|
||||
|
||||
ACMD (do_full_set);
|
||||
// 직군과 레벨에 따른 최고 아이템
|
||||
// 직군과 레벨에 따른 최고 아이템
|
||||
ACMD (do_item_full_set);
|
||||
// 직군에 따른 최고 옵션의 속성 셋팅
|
||||
// 직군에 따른 최고 옵션의 속성 셋팅
|
||||
ACMD (do_attr_full_set);
|
||||
// 모든 스킬 마스터
|
||||
// 모든 스킬 마스터
|
||||
ACMD (do_all_skill_master);
|
||||
// 아이템 착용. icon이 없어 클라에서 확인 할 수 없는 아이템 착용을 위해 만듦.
|
||||
// 아이템 착용. icon이 없어 클라에서 확인 할 수 없는 아이템 착용을 위해 만듦.
|
||||
ACMD (do_use_item);
|
||||
ACMD (do_dragon_soul);
|
||||
ACMD (do_ds_list);
|
||||
ACMD (do_clear_affect);
|
||||
ACMD(do_gem);
|
||||
|
||||
ACMD(do_ishop);
|
||||
struct command_info cmd_info[] =
|
||||
{
|
||||
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
||||
{ "!RESERVED!", NULL, 0, POS_DEAD, GM_IMPLEMENTOR }, /* 반드시 이 것이 처음이어야 한다. */
|
||||
{ "ishop", do_ishop, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "autohunt_pull", do_autohunt_pull, 0, POS_FIGHTING, GM_PLAYER },
|
||||
{ "bio", do_port_biolog, 0, POS_DEAD, GM_PLAYER },
|
||||
@@ -334,7 +335,7 @@ struct command_info cmd_info[] =
|
||||
{ "item", do_item, 0, POS_DEAD, GM_GOD },
|
||||
|
||||
{ "mob", do_mob, 0, POS_DEAD, GM_HIGH_WIZARD },
|
||||
{ "mob_ld", do_mob_ld, 0, POS_DEAD, GM_HIGH_WIZARD }, /* 몹의 위치와 방향을 설정해 소환 /mob_ld vnum x y dir */
|
||||
{ "mob_ld", do_mob_ld, 0, POS_DEAD, GM_HIGH_WIZARD }, /* 몹의 위치와 방향을 설정해 소환 /mob_ld vnum x y dir */
|
||||
{ "ma", do_mob_aggresive, 0, POS_DEAD, GM_HIGH_WIZARD },
|
||||
{ "mc", do_mob_coward, 0, POS_DEAD, GM_HIGH_WIZARD },
|
||||
{ "mm", do_mob_map, 0, POS_DEAD, GM_HIGH_WIZARD },
|
||||
@@ -432,8 +433,8 @@ struct command_info cmd_info[] =
|
||||
{ "delqf", do_delqf, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
{ "set_state", do_set_state, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
|
||||
{ "로그를보여줘", do_detaillog, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
{ "몬스터보여줘", do_monsterlog, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
{ "로그를보여줘", do_detaillog, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
{ "몬스터보여줘", do_monsterlog, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
|
||||
{ "detaillog", do_detaillog, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
{ "monsterlog", do_monsterlog, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
@@ -577,7 +578,7 @@ struct command_info cmd_info[] =
|
||||
{ "get_mob_count", do_get_mob_count, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
|
||||
{ "dice", do_dice, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "주사위", do_dice, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "주사위", do_dice, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "special_item", do_special_item, 0, POS_DEAD, GM_IMPLEMENTOR },
|
||||
|
||||
{ "click_mall", do_click_mall, 0, POS_DEAD, GM_PLAYER },
|
||||
@@ -587,7 +588,7 @@ struct command_info cmd_info[] =
|
||||
{ "item_id_list", do_get_item_id_list, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
{ "set_socket", do_set_socket, 0, POS_DEAD, GM_LOW_WIZARD },
|
||||
#ifdef __AUCTION__
|
||||
// auction 임시
|
||||
// auction 임시
|
||||
{ "auction_list", do_get_auction_list, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "my_auction_list", do_get_my_auction_list, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "my_purchase_list", do_get_my_purchase_list, 0, POS_DEAD, GM_PLAYER },
|
||||
@@ -651,7 +652,8 @@ struct command_info cmd_info[] =
|
||||
{ "pet_add_slot", do_pet_add_slot, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "change_name", do_change_name, 0, POS_DEAD, GM_PLAYER },
|
||||
#endif
|
||||
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
||||
{ "gem", do_gem, 0, POS_DEAD, GM_PLAYER },
|
||||
{ "\n", NULL, 0, POS_DEAD, GM_IMPLEMENTOR } /* 반드시 이 것이 마지막이어야 한다. */
|
||||
};
|
||||
|
||||
void interpreter_set_privilege(const char *cmd, int lvl)
|
||||
@@ -674,7 +676,7 @@ void double_dollar(const char *src, size_t src_len, char *dest, size_t dest_len)
|
||||
const char * tmp = src;
|
||||
size_t cur_len = 0;
|
||||
|
||||
// \0 넣을 자리 확보
|
||||
// \0 넣을 자리 확보
|
||||
dest_len -= 1;
|
||||
|
||||
while (src_len-- && *tmp)
|
||||
@@ -709,7 +711,7 @@ void interpret_command(LPCHARACTER ch, const char * argument, size_t len)
|
||||
return ;
|
||||
}
|
||||
|
||||
char cmd[128 + 1]; // buffer overflow 문제가 생기지 않도록 일부러 길이를 짧게 잡음
|
||||
char cmd[128 + 1]; // buffer overflow 문제가 생기지 않도록 일부러 길이를 짧게 잡음
|
||||
char new_line[256 + 1];
|
||||
const char * line;
|
||||
int icmd;
|
||||
@@ -726,7 +728,7 @@ void interpret_command(LPCHARACTER ch, const char * argument, size_t len)
|
||||
{
|
||||
if (cmd_info[icmd].command_pointer == do_cmd)
|
||||
{
|
||||
if (!strcmp(cmd_info[icmd].command, cmd)) // do_cmd는 모든 명령어를 쳐야 할 수 있다.
|
||||
if (!strcmp(cmd_info[icmd].command, cmd)) // do_cmd는 모든 명령어를 쳐야 할 수 있다.
|
||||
break;
|
||||
}
|
||||
else if (!strncmp(cmd_info[icmd].command, cmd, cmdlen))
|
||||
@@ -738,24 +740,24 @@ void interpret_command(LPCHARACTER ch, const char * argument, size_t len)
|
||||
switch (ch->GetPosition())
|
||||
{
|
||||
case POS_MOUNTING:
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("탄 상태에서는 할 수 없습니다."));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("탄 상태에서는 할 수 없습니다."));
|
||||
break;
|
||||
|
||||
case POS_DEAD:
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("쓰러진 상태에서는 할 수 없습니다."));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("쓰러진 상태에서는 할 수 없습니다."));
|
||||
break;
|
||||
|
||||
case POS_SLEEPING:
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("꿈속에서 어떻게요?"));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("꿈속에서 어떻게요?"));
|
||||
break;
|
||||
|
||||
case POS_RESTING:
|
||||
case POS_SITTING:
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("먼저 일어 나세요."));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("먼저 일어 나세요."));
|
||||
break;
|
||||
/*
|
||||
case POS_FIGHTING:
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("목숨을 걸고 전투 중 입니다. 집중 하세요."));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("목숨을 걸고 전투 중 입니다. 집중 하세요."));
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
@@ -768,17 +770,17 @@ void interpret_command(LPCHARACTER ch, const char * argument, size_t len)
|
||||
|
||||
if (*cmd_info[icmd].command == '\n')
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("그런 명령어는 없습니다"));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("그런 명령어는 없습니다"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd_info[icmd].gm_level && cmd_info[icmd].gm_level > ch->GetGMLevel())
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("그런 명령어는 없습니다"));
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("그런 명령어는 없습니다"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp("phase", cmd_info[icmd].command, 5) != 0) // 히든 명령어 처리
|
||||
if (strncmp("phase", cmd_info[icmd].command, 5) != 0) // 히든 명령어 처리
|
||||
sys_log(0, "COMMAND: %s: %s", ch->GetName(), cmd_info[icmd].command);
|
||||
|
||||
((*cmd_info[icmd].command_pointer) (ch, line, icmd, cmd_info[icmd].subcmd));
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
// #include "XTrapManager.h"
|
||||
#include "DragonSoul.h"
|
||||
#include "port_switchbot.h"
|
||||
#include "ava2_itemshop.h"
|
||||
#include <boost/bind.hpp>
|
||||
#ifndef __WIN32__
|
||||
#include "limit_time.h"
|
||||
@@ -558,6 +559,7 @@ int main(int argc, char **argv)
|
||||
Blend_Item_init();
|
||||
ani_init();
|
||||
PanamaLoad();
|
||||
Ava2PointDropInit();
|
||||
|
||||
Metin2Server_Check();
|
||||
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_gaya.h"
|
||||
#include "char.h"
|
||||
#include "utils.h"
|
||||
#include "cmd.h"
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
namespace {
|
||||
std::string s_gayaDir = "locale/germany/gem";
|
||||
std::map<uint32_t, std::map<uint8_t, TGemItem>> s_playerGayaItems;
|
||||
|
||||
struct GemCatalogEntry {
|
||||
uint32_t vnum;
|
||||
uint32_t count;
|
||||
int price;
|
||||
int lucky;
|
||||
};
|
||||
|
||||
static const GemCatalogEntry s_gemCatalog[] = {
|
||||
{71136, 1, 100, 100},
|
||||
{76012, 5, 1, 100},
|
||||
{76012, 20, 5, 100},
|
||||
{25162, 1, 2, 100},
|
||||
{39032, 1, 1, 100},
|
||||
{6884, 1, 250, 100},
|
||||
{72320, 1, 10, 100},
|
||||
{72320, 2, 20, 100},
|
||||
{72319, 1, 20, 100},
|
||||
{72319, 2, 40, 100},
|
||||
{71153, 1, 100, 100},
|
||||
{55035, 1, 5, 100},
|
||||
{30250, 1, 25, 100},
|
||||
{71035, 1, 25, 100},
|
||||
{55001, 1, 150, 100},
|
||||
{55009, 1, 55, 100},
|
||||
{85009, 1, 250, 100},
|
||||
{25163, 1, 3, 100},
|
||||
{25164, 1, 5, 100},
|
||||
{25165, 1, 7, 100},
|
||||
{25166, 1, 10, 100},
|
||||
{25167, 1, 12, 100},
|
||||
{25168, 1, 12, 100},
|
||||
{25169, 1, 15, 100},
|
||||
{71097, 1, 50, 100},
|
||||
{71097, 2, 100, 100},
|
||||
{100001, 1, 5, 100},
|
||||
{100002, 1, 10, 100},
|
||||
{71509, 1, 150, 100},
|
||||
{71506, 1, 150, 100},
|
||||
{71503, 1, 150, 100},
|
||||
{71500, 1, 150, 100},
|
||||
{53002, 1, 150, 100},
|
||||
{53005, 1, 150, 100},
|
||||
{53008, 1, 150, 100},
|
||||
{53011, 1, 150, 100},
|
||||
{77910, 1, 10, 100},
|
||||
{77911, 1, 35, 100},
|
||||
{77912, 1, 70, 100},
|
||||
{70043, 1, 20, 100},
|
||||
{70005, 1, 20, 100},
|
||||
{80025, 1, 10, 100},
|
||||
{25100, 1, 1, 100},
|
||||
{71084, 500, 10, 100},
|
||||
{71084, 1000, 20, 100},
|
||||
{71084, 2000, 40, 100},
|
||||
{71151, 1000, 5, 100},
|
||||
{71151, 2000, 10, 100},
|
||||
{72346, 1, 55, 100},
|
||||
{72346, 2, 110, 100},
|
||||
{53996, 20, 25, 100},
|
||||
{55036, 1, 300, 100},
|
||||
{30402, 1, 2, 100},
|
||||
{30403, 1, 7, 100},
|
||||
{30404, 1, 13, 100},
|
||||
{30405, 1, 17, 100},
|
||||
{30406, 1, 27, 100},
|
||||
{30407, 1, 53, 100},
|
||||
{30408, 1, 105, 100},
|
||||
{55401, 1, 20, 100},
|
||||
{77927, 1, 150, 100},
|
||||
{50348, 1, 250, 100},
|
||||
{50349, 1, 50, 100},
|
||||
};
|
||||
}
|
||||
|
||||
void PortGayaSetDirectory(const std::string& dir) {
|
||||
s_gayaDir = dir;
|
||||
}
|
||||
|
||||
const std::string& PortGayaGetDirectory() {
|
||||
return s_gayaDir;
|
||||
}
|
||||
|
||||
int PortGayaGet(const CHARACTER* ch) {
|
||||
if (!ch) return 0;
|
||||
return const_cast<CHARACTER*>(ch)->GetQuestFlag("gem.points");
|
||||
}
|
||||
|
||||
void PortGayaChange(CHARACTER* ch, int amount) {
|
||||
if (!ch) return;
|
||||
int current = PortGayaGet(ch);
|
||||
int updated = std::max(0, std::min(GEM_MAX, current + amount));
|
||||
ch->SetQuestFlag("gem.points", updated);
|
||||
ch->SetPoint(POINT_GEM, updated);
|
||||
ch->PointChange(POINT_GEM, 0);
|
||||
}
|
||||
|
||||
bool PortGayaOpenSlot(CHARACTER* ch) {
|
||||
if (!ch) return false;
|
||||
const int openSlotFlag = ch->GetQuestFlag("gem.open_slot");
|
||||
if (openSlotFlag < 18) {
|
||||
ch->SetQuestFlag("gem.open_slot", openSlotFlag + 1);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemUpdateSlotCount %d", openSlotFlag + 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PortGayaLoadItems(CHARACTER* ch) {
|
||||
if (!ch) return;
|
||||
uint32_t pid = ch->GetPlayerID();
|
||||
auto& items = s_playerGayaItems[pid];
|
||||
items.clear();
|
||||
|
||||
char filename[256];
|
||||
snprintf(filename, sizeof(filename), "%s/%u", s_gayaDir.c_str(), pid);
|
||||
FILE* fp = fopen(filename, "r");
|
||||
if (fp) {
|
||||
char line[256];
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
unsigned slot = 0, vnum = 0, count = 0, buyed = 0;
|
||||
int price = 0;
|
||||
if (sscanf(line, "%u %u %u %d %u", &slot, &vnum, &count, &price, &buyed) == 5) {
|
||||
TGemItem item;
|
||||
item.itemVnum = vnum;
|
||||
item.itemCount = count;
|
||||
item.itemPrice = price;
|
||||
item.itemBuyed = (buyed != 0);
|
||||
items[(uint8_t)slot] = item;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
void PortGayaSaveItems(CHARACTER* ch) {
|
||||
if (!ch) return;
|
||||
uint32_t pid = ch->GetPlayerID();
|
||||
const auto& items = s_playerGayaItems[pid];
|
||||
|
||||
// Ensure directory exists
|
||||
size_t slash = s_gayaDir.rfind('/');
|
||||
if (slash != std::string::npos) {
|
||||
std::string parent = s_gayaDir.substr(0, slash);
|
||||
mkdir(parent.c_str(), 0755);
|
||||
}
|
||||
mkdir(s_gayaDir.c_str(), 0755);
|
||||
|
||||
char filename[256];
|
||||
snprintf(filename, sizeof(filename), "%s/%u", s_gayaDir.c_str(), pid);
|
||||
FILE* fp = fopen(filename, "w+");
|
||||
if (fp) {
|
||||
fprintf(fp, "index-vnum-count-price-buyed\n");
|
||||
for (const auto& kv : items) {
|
||||
fprintf(fp, "%u %u %u %d %u\n", kv.first, kv.second.itemVnum, kv.second.itemCount, kv.second.itemPrice, kv.second.itemBuyed ? 1 : 0);
|
||||
}
|
||||
fflush(fp);
|
||||
fsync(fileno(fp));
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void PortGayaGenerateItems(CHARACTER* ch) {
|
||||
if (!ch) return;
|
||||
uint32_t pid = ch->GetPlayerID();
|
||||
auto& items = s_playerGayaItems[pid];
|
||||
items.clear();
|
||||
|
||||
const size_t catalogSize = sizeof(s_gemCatalog) / sizeof(s_gemCatalog[0]);
|
||||
std::vector<uint8_t> chosenIndices;
|
||||
while (chosenIndices.size() < 27 && chosenIndices.size() < catalogSize) {
|
||||
for (size_t i = 0; i < catalogSize; ++i) {
|
||||
if (number(1, 100) > s_gemCatalog[i].lucky) continue;
|
||||
if (std::find(chosenIndices.begin(), chosenIndices.end(), (uint8_t)i) != chosenIndices.end()) continue;
|
||||
chosenIndices.push_back((uint8_t)i);
|
||||
if (chosenIndices.size() >= 27) break;
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < chosenIndices.size(); ++i) {
|
||||
const auto& entry = s_gemCatalog[chosenIndices[i]];
|
||||
TGemItem it;
|
||||
it.itemBuyed = false;
|
||||
it.itemVnum = entry.vnum;
|
||||
it.itemCount = entry.count;
|
||||
it.itemPrice = entry.price;
|
||||
items[(uint8_t)i] = it;
|
||||
}
|
||||
PortGayaSaveItems(ch);
|
||||
}
|
||||
|
||||
void PortGayaRefreshPlayer(CHARACTER* ch) {
|
||||
if (!ch) return;
|
||||
uint32_t pid = ch->GetPlayerID();
|
||||
auto it = s_playerGayaItems.find(pid);
|
||||
if (it == s_playerGayaItems.end() || it->second.empty()) {
|
||||
PortGayaLoadItems(ch);
|
||||
if (s_playerGayaItems[pid].empty())
|
||||
PortGayaGenerateItems(ch);
|
||||
}
|
||||
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemClear");
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemUpdateSlotCount %d", ch->GetQuestFlag("gem.open_slot"));
|
||||
int left = ch->GetQuestFlag("gem.left_time") - time(0);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemSetRefreshLeftTime %d", left > 0 ? left : 0);
|
||||
|
||||
const auto& items = s_playerGayaItems[pid];
|
||||
std::string cmdString = "";
|
||||
for (const auto& kv : items) {
|
||||
const uint8_t slotPos = kv.first;
|
||||
const auto& itemData = kv.second;
|
||||
cmdString += std::to_string(slotPos);
|
||||
cmdString += "#";
|
||||
cmdString += std::to_string(itemData.itemVnum);
|
||||
cmdString += "#";
|
||||
cmdString += std::to_string(itemData.itemCount);
|
||||
cmdString += "#";
|
||||
cmdString += std::to_string(itemData.itemPrice);
|
||||
cmdString += "#";
|
||||
cmdString += std::to_string(itemData.itemBuyed ? 1 : 0);
|
||||
cmdString += "|";
|
||||
if (cmdString.size() + 50 > 450) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemSetItemsWithString %s", cmdString.c_str());
|
||||
cmdString.clear();
|
||||
}
|
||||
}
|
||||
if (!cmdString.empty()) {
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemSetItemsWithString %s", cmdString.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void PortGayaRefreshAll(CHARACTER* ch, bool withRealTime) {
|
||||
if (!ch) return;
|
||||
int leftTime = 0;
|
||||
if (withRealTime && ch->GetQuestFlag("gem.left_time") != 0) {
|
||||
leftTime = time(0) - ch->GetQuestFlag("gem.left_time");
|
||||
if (leftTime < 1) leftTime = 0;
|
||||
}
|
||||
ch->SetQuestFlag("gem.left_time", (time(0) + REFRESH_TIME) - leftTime);
|
||||
PortGayaGenerateItems(ch);
|
||||
PortGayaRefreshPlayer(ch);
|
||||
}
|
||||
|
||||
void PortGayaBuyItem(CHARACTER* ch, uint8_t slotIndex) {
|
||||
if (!ch) return;
|
||||
uint32_t pid = ch->GetPlayerID();
|
||||
auto& items = s_playerGayaItems[pid];
|
||||
if (items.empty()) {
|
||||
PortGayaLoadItems(ch);
|
||||
}
|
||||
auto it = items.find(slotIndex);
|
||||
if (it != items.end()) {
|
||||
if (slotIndex >= 9) {
|
||||
if (ch->GetQuestFlag("gem.open_slot") < (slotIndex - 9) + 1)
|
||||
return;
|
||||
}
|
||||
if (it->second.itemBuyed)
|
||||
return;
|
||||
int price = it->second.itemPrice;
|
||||
if (price > PortGayaGet(ch)) {
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, "Not enough Gaya.");
|
||||
return;
|
||||
}
|
||||
it->second.itemBuyed = true;
|
||||
PortGayaChange(ch, -price);
|
||||
ch->AutoGiveItem(it->second.itemVnum, it->second.itemCount);
|
||||
ch->ChatPacket(CHAT_TYPE_COMMAND, "GemSetBuyedSlot %d 1", slotIndex);
|
||||
PortGayaSaveItems(ch);
|
||||
}
|
||||
}
|
||||
|
||||
// CHARACTER member method forwarders
|
||||
int CHARACTER::GetGem() const {
|
||||
return PortGayaGet(this);
|
||||
}
|
||||
|
||||
void CHARACTER::ChangeGem(int amount) {
|
||||
PortGayaChange(this, amount);
|
||||
}
|
||||
|
||||
bool CHARACTER::OpenGemSlot() {
|
||||
return PortGayaOpenSlot(this);
|
||||
}
|
||||
|
||||
void CHARACTER::RefreshGemALL(bool withRealTime) {
|
||||
PortGayaRefreshAll(this, withRealTime);
|
||||
}
|
||||
|
||||
void CHARACTER::RefreshGemPlayer() {
|
||||
PortGayaRefreshPlayer(this);
|
||||
}
|
||||
|
||||
void CHARACTER::BuyGemItem(BYTE slotIndex) {
|
||||
PortGayaBuyItem(this, slotIndex);
|
||||
}
|
||||
|
||||
ACMD(do_gem) {
|
||||
if (!ch || !ch->IsPC() || !ch->GetDesc() || ch->IsWarping() || ch->IsDead()) return;
|
||||
std::vector<std::string> vecArgs;
|
||||
split_argument(argument, vecArgs);
|
||||
if (vecArgs.size() < 2) return;
|
||||
if (vecArgs[1] == "load") {
|
||||
if (time(0) >= ch->GetQuestFlag("gem.left_time")) {
|
||||
ch->RefreshGemALL(true);
|
||||
} else {
|
||||
ch->RefreshGemPlayer();
|
||||
}
|
||||
} else if (vecArgs[1] == "time") {
|
||||
if (time(0) >= ch->GetQuestFlag("gem.left_time")) {
|
||||
ch->RefreshGemALL(true);
|
||||
}
|
||||
} else if (vecArgs[1] == "slot") {
|
||||
if (ch->CountSpecifyItem(OPEN_GEM_SLOT_ITEM) < 1) {
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, "You don't have enough Gaya slot expansion items.");
|
||||
return;
|
||||
}
|
||||
if (ch->OpenGemSlot()) {
|
||||
ch->RemoveSpecifyItem(OPEN_GEM_SLOT_ITEM, 1);
|
||||
}
|
||||
} else if (vecArgs[1] == "refresh") {
|
||||
if (ch->CountSpecifyItem(OPEN_GEM_REFRESH_ITEM) < 1) {
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, "You don't have enough refresh Gaya market items.");
|
||||
return;
|
||||
}
|
||||
ch->RemoveSpecifyItem(OPEN_GEM_REFRESH_ITEM, 1);
|
||||
ch->RefreshGemALL();
|
||||
} else if (vecArgs[1] == "buy") {
|
||||
if (vecArgs.size() < 3) return;
|
||||
BYTE slotIndex = 0;
|
||||
if (!str_to_number(slotIndex, vecArgs[2].c_str())) return;
|
||||
ch->BuyGemItem(slotIndex);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
enum EGemConstants
|
||||
{
|
||||
REFRESH_TIME = 60 * 60 * 5,
|
||||
OPEN_GEM_SLOT_ITEM = 39064,
|
||||
OPEN_GEM_REFRESH_ITEM = 39063,
|
||||
GEM_MAX = 1000000,
|
||||
};
|
||||
|
||||
struct TGemItem
|
||||
{
|
||||
uint32_t itemVnum;
|
||||
uint32_t itemCount;
|
||||
int itemPrice;
|
||||
bool itemBuyed;
|
||||
};
|
||||
|
||||
class CHARACTER;
|
||||
|
||||
int PortGayaGet(const CHARACTER* ch);
|
||||
void PortGayaChange(CHARACTER* ch, int amount);
|
||||
bool PortGayaOpenSlot(CHARACTER* ch);
|
||||
void PortGayaRefreshAll(CHARACTER* ch, bool withRealTime = false);
|
||||
void PortGayaRefreshPlayer(CHARACTER* ch);
|
||||
void PortGayaBuyItem(CHARACTER* ch, uint8_t slotIndex);
|
||||
void PortGayaSaveItems(CHARACTER* ch);
|
||||
void PortGayaLoadItems(CHARACTER* ch);
|
||||
void PortGayaSetDirectory(const std::string& dir);
|
||||
const std::string& PortGayaGetDirectory();
|
||||
Reference in New Issue
Block a user