feat: support Linux/ARM cross-platform build and AVA2 feature updates
- Port server core and libraries to Linux and 32-bit ARM (armhf): * Replace FreeBSD kqueue with Linux epoll in libthecore fdwatch * Fix unaligned float and 64-bit int memory stores in utils.h str_to_number to avoid ARM VFP alignment fault (SIGBUS) * Fix getopt loop variable type in main.cpp (char -> int) to eliminate infinite loop caused by default unsigned char on ARM * Add -fsigned-char and multi-architecture flags to Makefiles (x86_64 -m32, i386, and ARM armhf) * Update libsql for modern MariaDB client library (removed reconnect field) and C++20 concept/syntax compatibility * Replace Win32 xdirent with standard POSIX dirent on Unix/Linux * Include xmd5 in libthecore on non-FreeBSD platforms - AVA2 unlock features and tools: * Material stacking up to 2000 count, refine material resolution and test suites * AVA2 ticket shop and point drop configuration updates
This commit is contained in:
+4
-12
@@ -1,5 +1,5 @@
|
||||
CC=clang-devel
|
||||
CXX=clang++-devel
|
||||
CC ?= clang-devel
|
||||
CXX ?= clang++-devel
|
||||
|
||||
PLATFORM = $(shell file /bin/ls | cut -d' ' -f3 | cut -d'-' -f1)
|
||||
BSD_VERSION = $(shell uname -v 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)
|
||||
@@ -11,19 +11,16 @@ default: libthecore libpoly libgame liblua libsql libserverkey game db
|
||||
|
||||
libthecore: .
|
||||
@touch $@/src/Depend
|
||||
$(MAKE) -C $@/src dep
|
||||
$(MAKE) -C $@/src clean
|
||||
$(MAKE) -C $@/src
|
||||
|
||||
libpoly: .
|
||||
@touch $@/Depend
|
||||
$(MAKE) -C $@ dep
|
||||
$(MAKE) -C $@ clean
|
||||
$(MAKE) -C $@
|
||||
|
||||
libgame: .
|
||||
@touch $@/src/Depend
|
||||
$(MAKE) -C $@/src dep
|
||||
$(MAKE) -C $@/src clean
|
||||
$(MAKE) -C $@/src
|
||||
|
||||
@@ -33,28 +30,23 @@ liblua: .
|
||||
|
||||
libsql: .
|
||||
@touch $@/Depend
|
||||
$(MAKE) -C $@ dep
|
||||
$(MAKE) -C $@ clean
|
||||
$(MAKE) -C $@
|
||||
|
||||
libserverkey: .
|
||||
@touch $@/Depend
|
||||
$(MAKE) -C $@ dep
|
||||
$(MAKE) -C $@ clean
|
||||
$(MAKE) -C $@
|
||||
|
||||
game: .
|
||||
@touch $@/src/Depend
|
||||
$(MAKE) -C $@/src dep
|
||||
$(MAKE) -C $@/src clean
|
||||
# $(MAKE) -C $@/src limit_time
|
||||
# $(MAKE) -C $@/src
|
||||
$(MAKE) -C $@/src
|
||||
|
||||
db: .
|
||||
@touch $@/src/Depend
|
||||
$(MAKE) -C $@/src dep
|
||||
$(MAKE) -C $@/src clean
|
||||
# $(MAKE) -C $@/src
|
||||
$(MAKE) -C $@/src
|
||||
|
||||
all:
|
||||
@echo "--------------------------------------"
|
||||
|
||||
@@ -9,7 +9,7 @@ enum EItemMisc
|
||||
ITEM_LIMIT_MAX_NUM = 2,
|
||||
ITEM_APPLY_MAX_NUM = 3,
|
||||
ITEM_SOCKET_MAX_NUM = 3,
|
||||
ITEM_MAX_COUNT = 200,
|
||||
ITEM_MAX_COUNT = 2000,
|
||||
ITEM_ATTRIBUTE_MAX_NUM = 7,
|
||||
ITEM_ATTRIBUTE_MAX_LEVEL = 5,
|
||||
ITEM_AWARD_WHY_MAX_LEN = 50,
|
||||
|
||||
@@ -632,20 +632,20 @@ typedef struct SSkillTable
|
||||
typedef struct SShopItemTable
|
||||
{
|
||||
DWORD vnum;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
|
||||
TItemPos pos; // PC 상점에만 이용
|
||||
int64_t price; // PC, shop_table_ex.txt 상점에만 이용
|
||||
BYTE display_pos; // PC, shop_table_ex.txt 상점에만 이용, 보일 위치.
|
||||
} TShopItemTable;
|
||||
static_assert(sizeof(TShopItemTable)==17,"gold64 private shop wire size");
|
||||
static_assert(sizeof(TShopItemTable)==18,"gold64 private shop wire size");
|
||||
|
||||
typedef struct SShopTable
|
||||
{
|
||||
DWORD dwVnum;
|
||||
DWORD dwNPCVnum;
|
||||
|
||||
BYTE byItemCount;
|
||||
WORD byItemCount;
|
||||
TShopItemTable items[SHOP_HOST_ITEM_MAX_NUM];
|
||||
} TShopTable;
|
||||
|
||||
|
||||
@@ -78,21 +78,30 @@ inline bool str_to_number (long long& out, const char *in)
|
||||
if(!in || !*in)return false;
|
||||
errno=0;char* end=NULL;const long long value=strtoll(in,&end,10);
|
||||
if(errno==ERANGE || end==in || *end)return false;
|
||||
out=value;return true;
|
||||
char* dst = reinterpret_cast<char*>(&out);
|
||||
const char* src = reinterpret_cast<const char*>(&value);
|
||||
for (size_t i = 0; i < sizeof(long long); ++i) dst[i] = src[i];
|
||||
return true;
|
||||
}
|
||||
inline bool str_to_number (unsigned long long& out, const char *in)
|
||||
{
|
||||
if(!in || !*in || ((*in<'0'||*in>'9')&&*in!='+'))return false;
|
||||
errno=0;char* end=NULL;const unsigned long long value=strtoull(in,&end,10);
|
||||
if(errno==ERANGE || end==in || *end)return false;
|
||||
out=value;return true;
|
||||
char* dst = reinterpret_cast<char*>(&out);
|
||||
const char* src = reinterpret_cast<const char*>(&value);
|
||||
for (size_t i = 0; i < sizeof(unsigned long long); ++i) dst[i] = src[i];
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool str_to_number (float& out, const char *in)
|
||||
{
|
||||
if (0==in || 0==in[0]) return false;
|
||||
|
||||
out = (float) strtof(in, NULL);
|
||||
float val = (float) strtof(in, NULL);
|
||||
char* dst = reinterpret_cast<char*>(&out);
|
||||
const char* src = reinterpret_cast<const char*>(&val);
|
||||
for (size_t i = 0; i < sizeof(float); ++i) dst[i] = src[i];
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,7 +109,10 @@ inline bool str_to_number (double& out, const char *in)
|
||||
{
|
||||
if (0==in || 0==in[0]) return false;
|
||||
|
||||
out = (double) strtod(in, NULL);
|
||||
double val = (double) strtod(in, NULL);
|
||||
char* dst = reinterpret_cast<char*>(&out);
|
||||
const char* src = reinterpret_cast<const char*>(&val);
|
||||
for (size_t i = 0; i < sizeof(double); ++i) dst[i] = src[i];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -1,28 +1,29 @@
|
||||
MAKE = gmake
|
||||
CC = clang++-devel
|
||||
MAKE = make
|
||||
CC ?= clang++-devel
|
||||
|
||||
INCDIR =
|
||||
LIBDIR =
|
||||
BINDIR = ..
|
||||
OBJDIR = .obj
|
||||
DBDIR = /usr/metin2/server/share/bin
|
||||
DBDIR ?= ../../share/bin
|
||||
|
||||
GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
|
||||
BSD_VERSION = $(shell uname -v 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)
|
||||
UNAME_S := $(shell uname -s)
|
||||
SVN_VERSION = 40142
|
||||
$(shell if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi)
|
||||
|
||||
# TARGET = $(BINDIR)/db_r$(SVN_VERSION)
|
||||
TARGET = $(BINDIR)/db
|
||||
|
||||
CFLAGS = -g -Wall -w -O2 -pipe -fno-rtti -std=c++2b -fno-exceptions -pthread -D_THREAD_SAFE
|
||||
CFLAGS += -mtune=i686
|
||||
|
||||
ifeq ($(UNAME_S), Linux)
|
||||
CFLAGS ?= -g -Wall -w -O2 -pipe -fno-rtti -std=c++2b -fno-exceptions -pthread -D_THREAD_SAFE
|
||||
LIBS += -lmariadb -lz -lssl -lcrypto -ldl
|
||||
INCDIR += -I/usr/include/mariadb -I/usr/include/mysql
|
||||
else
|
||||
CFLAGS ?= -g -Wall -w -O2 -pipe -fno-rtti -std=c++2b -fno-exceptions -pthread -D_THREAD_SAFE -mtune=i686
|
||||
# MySQL
|
||||
LIBS += /usr/local/lib/mysql/libmysqlclient.a /usr/lib/libz.a
|
||||
|
||||
# OpenSSL
|
||||
LIBS += /usr/lib/libssl.a /usr/lib/libcrypto.a
|
||||
endif
|
||||
|
||||
# Miscellaneous external libraries
|
||||
INCDIR += -I../../../extern/include
|
||||
@@ -47,11 +48,10 @@ default: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
@echo linking $(TARGET)....
|
||||
@$(CC) $(CFLAGS) $(LIBDIR) $(OBJS) $(LIBS) -o $(TARGET)
|
||||
$(CC) $(CFLAGS) $(LIBDIR) $(OBJS) $(LIBS) -o $(TARGET)
|
||||
@touch version.cpp
|
||||
@echo "Moving $(TARGET) to $(DBDIR)"
|
||||
@mv $(TARGET) $(DBDIR)
|
||||
@echo "All done! Your db file moved to your server directory."
|
||||
@if [ -d "$(DBDIR)" ]; then cp $(TARGET) $(DBDIR)/; echo "Copied $(TARGET) to $(DBDIR)"; fi
|
||||
@echo "All done!"
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
@echo compile $<
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define __INC_METiN_II_DBSERV_STDAFX_H__
|
||||
|
||||
#include "../../libthecore/include/stdafx.h"
|
||||
#include <memory>
|
||||
|
||||
#ifndef __WIN32__
|
||||
#include <semaphore.h>
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
#include "ClientPackageCryptInfo.h"
|
||||
#include "../../common/stl.h"
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
#if defined(_WIN32)
|
||||
#include "../../libthecore/include/xdirent.h"
|
||||
#else
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
CClientPackageCryptInfo::CClientPackageCryptInfo() : m_pSerializedCryptKeyStream(NULL), m_nCryptKeyPackageCnt(0)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#define INVALID_KERNEL_EVENT -1
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
|
||||
FileMonitorFreeBSD::FileMonitorFreeBSD()
|
||||
{
|
||||
m_KernelEventQueue = INVALID_KERNEL_EVENT;
|
||||
@@ -133,4 +135,12 @@ void FileMonitorFreeBSD::AddWatch(const std::string& strFileName, PFN_FileChange
|
||||
|
||||
m_TriggeredEventLists.push_back( kTriggerEvent );
|
||||
m_MonitoredEventLists.push_back( kMonitorEvent );
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
FileMonitorFreeBSD::FileMonitorFreeBSD() : m_KernelEventQueue(-1) {}
|
||||
FileMonitorFreeBSD::~FileMonitorFreeBSD() {}
|
||||
void FileMonitorFreeBSD::AddWatch(const std::string&, PFN_FileChangeListener) {}
|
||||
void FileMonitorFreeBSD::Update(DWORD) {}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
|
||||
#include "IFileMonitor.h"
|
||||
#include <unistd.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/event.h>
|
||||
#else
|
||||
struct kevent { int dummy; };
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
PLATFORM = $(shell file /bin/ls | cut -d' ' -f3 | cut -d'-' -f1)
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_M := $(shell uname -m)
|
||||
|
||||
GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
|
||||
BSD_VERSION = $(shell uname -v 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)
|
||||
SVN_VERSION = 40250
|
||||
|
||||
CC = clang++-devel
|
||||
CC ?= clang++-devel
|
||||
|
||||
INCDIR =
|
||||
LIBDIR =
|
||||
BINDIR = ..
|
||||
OBJDIR = OBJDIR
|
||||
GAMEDIR = /usr/metin2/server/share/bin
|
||||
GAMEDIR ?= ../../share/bin
|
||||
SVN_VERSION = 40250
|
||||
$(shell if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi)
|
||||
|
||||
# Standard Setting
|
||||
LIBS = -pthread -lm -lmd
|
||||
# Removed -fno-rtti
|
||||
CFLAGS = -g -Wall -w -O2 -m32 -pipe -std=c++2b -fexceptions -D_THREAD_SAFE -DNDEBUG # -D_USE_SERVER_KEY_
|
||||
CFLAGS += -mtune=i686 -fstack-protector-all
|
||||
|
||||
# CryptoPP
|
||||
LIBS += ../../../extern/lib/libcryptopp.a
|
||||
|
||||
# DevIL
|
||||
LIBS += ../../../extern/lib/libIL.a
|
||||
|
||||
# MySQL
|
||||
LIBS += /usr/local/lib/mysql/libmysqlclient.a /usr/lib/libz.a
|
||||
|
||||
# OpenSSL
|
||||
LIBS += /usr/lib/libssl.a /usr/lib/libcrypto.a
|
||||
ifeq ($(UNAME_S), Linux)
|
||||
ifeq ($(UNAME_M), x86_64)
|
||||
ARCH_FLAGS = -m32 -mtune=i686
|
||||
else ifeq ($(UNAME_M), i386)
|
||||
ARCH_FLAGS = -mtune=i686
|
||||
else
|
||||
ARCH_FLAGS =
|
||||
endif
|
||||
CFLAGS ?= -g -Wall -w -O2 $(ARCH_FLAGS) -pipe -std=c++2b -fexceptions -D_THREAD_SAFE -DNDEBUG -fstack-protector-all -fsigned-char
|
||||
INCDIR += -I/usr/include/mariadb -I/usr/include/mysql
|
||||
LIBS = -pthread -lm -lcryptopp -lIL -lILU -lmariadb -lz -lssl -lcrypto -ldl
|
||||
else
|
||||
CFLAGS ?= -g -Wall -w -O2 -m32 -pipe -std=c++2b -fexceptions -D_THREAD_SAFE -DNDEBUG -mtune=i686 -fstack-protector-all
|
||||
LIBS = -pthread -lm -lmd
|
||||
LIBS += ../../../extern/lib/libcryptopp.a
|
||||
LIBS += ../../../extern/lib/libIL.a
|
||||
LIBS += /usr/local/lib/mysql/libmysqlclient.a /usr/lib/libz.a
|
||||
LIBS += /usr/lib/libssl.a /usr/lib/libcrypto.a
|
||||
endif
|
||||
|
||||
# Miscellaneous external libraries
|
||||
INCDIR += -I../../../extern/include
|
||||
@@ -108,10 +108,9 @@ limit_time:
|
||||
|
||||
$(TARGET): $(CPPOBJS) $(COBJS) $(MAINOBJ)
|
||||
@echo linking $(TARGET)....
|
||||
@$(CC) $(CFLAGS) $(LIBDIR) $(COBJS) $(CPPOBJS) $(MAINOBJ) $(LIBS) -o $(TARGET)
|
||||
@echo "Moving $(TARGET) to $(GAMEDIR)"
|
||||
@mv $(TARGET) $(GAMEDIR)
|
||||
@echo "All done! Your game file moved to your server directory."
|
||||
$(CC) $(CFLAGS) $(LIBDIR) $(COBJS) $(CPPOBJS) $(MAINOBJ) $(LIBS) -o $(TARGET)
|
||||
@if [ -d "$(GAMEDIR)" ]; then cp $(TARGET) $(GAMEDIR)/; echo "Copied $(TARGET) to $(GAMEDIR)"; fi
|
||||
@echo "All done!"
|
||||
|
||||
clean:
|
||||
@rm -f $(COBJS) $(CPPOBJS) $(MAINOBJ)
|
||||
|
||||
@@ -424,7 +424,7 @@ bool COXEventManager::LogWinner()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COXEventManager::GiveItemToAttender(DWORD dwItemVnum, BYTE count)
|
||||
bool COXEventManager::GiveItemToAttender(DWORD dwItemVnum, DWORD count)
|
||||
{
|
||||
itertype(m_map_attender) iter = m_map_attender.begin();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class COXEventManager : public singleton<COXEventManager>
|
||||
bool ShowQuizList(LPCHARACTER pChar);
|
||||
|
||||
bool Quiz(unsigned char level, int timelimit);
|
||||
bool GiveItemToAttender(DWORD dwItemVnum, BYTE count);
|
||||
bool GiveItemToAttender(DWORD dwItemVnum, DWORD count);
|
||||
|
||||
bool CheckAnswer(bool answer);
|
||||
void WarpToAudience();
|
||||
|
||||
@@ -80,7 +80,7 @@ bool CArenaMap::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD startB
|
||||
|
||||
for (; iter != m_listArena.end(); iter++)
|
||||
{
|
||||
if ((CArena*)(*iter)->CheckArea(startA_X, startA_Y, startB_X, startB_Y) == false)
|
||||
if ((*iter)->CheckArea(startA_X, startA_Y, startB_X, startB_Y) == false)
|
||||
{
|
||||
sys_log(0, "CArenaMap::AddArena - Same Start Position set. stA(%d, %d) stB(%d, %d)", startA_X, startA_Y, startB_X, startB_Y);
|
||||
return false;
|
||||
@@ -237,17 +237,17 @@ EVENTFUNC(ready_to_start_event)
|
||||
|
||||
if (chA != NULL)
|
||||
{
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
sys_log(0, "ARENA: Oppernent is disappered. MyPID(%d) OppPID(%d)", pArena->GetPlayerAPID(), pArena->GetPlayerBPID());
|
||||
}
|
||||
|
||||
if (chB != NULL)
|
||||
{
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
sys_log(0, "ARENA: Oppernent is disappered. MyPID(%d) OppPID(%d)", pArena->GetPlayerBPID(), pArena->GetPlayerAPID());
|
||||
}
|
||||
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
|
||||
pArena->EndDuel();
|
||||
return 0;
|
||||
@@ -264,20 +264,20 @@ EVENTFUNC(ready_to_start_event)
|
||||
|
||||
if (count > 10000)
|
||||
{
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제한이 없습니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제한이 없습니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제한이 없습니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약 제한이 없습니다."));
|
||||
}
|
||||
else
|
||||
{
|
||||
chA->SetPotionLimit(count);
|
||||
chB->SetPotionLimit(count);
|
||||
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약을 %d 개 까지 사용 가능합니다."), chA->GetPotionLimit());
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약을 %d 개 까지 사용 가능합니다."), chB->GetPotionLimit());
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약을 %d 개 까지 사용 가능합니다."), chA->GetPotionLimit());
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("물약을 %d 개 까지 사용 가능합니다."), chB->GetPotionLimit());
|
||||
}
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 대련이 시작됩니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 대련이 시작됩니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("10초뒤 대련이 시작됩니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 대련이 시작됩니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 대련이 시작됩니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("10초뒤 대련이 시작됩니다."));
|
||||
|
||||
info->state++;
|
||||
return PASSES_PER_SEC(10);
|
||||
@@ -286,15 +286,15 @@ EVENTFUNC(ready_to_start_event)
|
||||
|
||||
case 1:
|
||||
{
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
|
||||
TPacketGCDuelStart duelStart;
|
||||
duelStart.header = HEADER_GC_DUEL_START;
|
||||
duelStart.wSize = sizeof(TPacketGCDuelStart) + 4;
|
||||
|
||||
DWORD dwOppList[8]; // 최대 파티원 8명 이므로..
|
||||
DWORD dwOppList[8]; // 최대 파티원 8명 이므로..
|
||||
|
||||
dwOppList[0] = (DWORD)chB->GetVID();
|
||||
TEMP_BUFFER buf;
|
||||
@@ -343,7 +343,7 @@ EVENTFUNC(ready_to_start_event)
|
||||
|
||||
TEMP_BUFFER buf;
|
||||
TEMP_BUFFER buf2;
|
||||
DWORD dwOppList[8]; // 최대 파티원 8명 이므로..
|
||||
DWORD dwOppList[8]; // 최대 파티원 8명 이므로..
|
||||
TPacketGCDuelStart duelStart;
|
||||
duelStart.header = HEADER_GC_DUEL_START;
|
||||
duelStart.wSize = sizeof(TPacketGCDuelStart) + 4;
|
||||
@@ -358,9 +358,9 @@ EVENTFUNC(ready_to_start_event)
|
||||
buf2.write(&dwOppList[0], 4);
|
||||
chB->GetDesc()->Packet(buf2.read_peek(), buf2.size());
|
||||
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련이 시작되었습니다."));
|
||||
|
||||
pArena->ClearEvent();
|
||||
|
||||
@@ -370,9 +370,9 @@ EVENTFUNC(ready_to_start_event)
|
||||
|
||||
default:
|
||||
{
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장 문제로 인하여 대련을 종료합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장 문제로 인하여 대련을 종료합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련장 문제로 인하여 대련을 종료합니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장 문제로 인하여 대련을 종료합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장 문제로 인하여 대련을 종료합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련장 문제로 인하여 대련을 종료합니다."));
|
||||
|
||||
sys_log(0, "ARENA: Something wrong in event func. info->state(%d)", info->state);
|
||||
|
||||
@@ -411,17 +411,17 @@ EVENTFUNC(duel_time_out)
|
||||
{
|
||||
if (chA != NULL)
|
||||
{
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
sys_log(0, "ARENA: Oppernent is disappered. MyPID(%d) OppPID(%d)", pArena->GetPlayerAPID(), pArena->GetPlayerBPID());
|
||||
}
|
||||
|
||||
if (chB != NULL)
|
||||
{
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
sys_log(0, "ARENA: Oppernent is disappered. MyPID(%d) OppPID(%d)", pArena->GetPlayerBPID(), pArena->GetPlayerAPID());
|
||||
}
|
||||
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("대련 상대가 사라져 대련을 종료합니다."));
|
||||
|
||||
pArena->EndDuel();
|
||||
return 0;
|
||||
@@ -431,14 +431,14 @@ EVENTFUNC(duel_time_out)
|
||||
switch (info->state)
|
||||
{
|
||||
case 0:
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련 시간 초과로 대련을 중단합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("10초뒤 마을로 이동합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련 시간 초과로 대련을 중단합니다."));
|
||||
pArena->SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("10초뒤 마을로 이동합니다."));
|
||||
|
||||
chA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("대련 시간 초과로 대련을 중단합니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("10초뒤 마을로 이동합니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("대련 시간 초과로 대련을 중단합니다."));
|
||||
chA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("10초뒤 마을로 이동합니다."));
|
||||
|
||||
chB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("대련 시간 초과로 대련을 중단합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("10초뒤 마을로 이동합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("대련 시간 초과로 대련을 중단합니다."));
|
||||
chB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("10초뒤 마을로 이동합니다."));
|
||||
|
||||
TPacketGCDuelStart duelStart;
|
||||
duelStart.header = HEADER_GC_DUEL_START;
|
||||
@@ -682,7 +682,7 @@ bool CArenaMap::CanAttack(LPCHARACTER pCharAttacker, LPCHARACTER pCharVictim)
|
||||
|
||||
bool CArena::CanAttack(DWORD dwPIDA, DWORD dwPIDB)
|
||||
{
|
||||
// 1:1 전용 다대다 할 경우 수정 필요
|
||||
// 1:1 전용 다대다 할 경우 수정 필요
|
||||
if (m_dwPIDA == dwPIDA && m_dwPIDB == dwPIDB) return true;
|
||||
if (m_dwPIDA == dwPIDB && m_dwPIDB == dwPIDA) return true;
|
||||
|
||||
@@ -732,20 +732,20 @@ bool CArena::OnDead(DWORD dwPIDA, DWORD dwPIDB)
|
||||
|
||||
if (pCharA == NULL && pCharB == NULL)
|
||||
{
|
||||
// 둘다 접속이 끊어졌다 ?!
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련자 문제로 인하여 대련을 중단합니다."));
|
||||
// 둘다 접속이 끊어졌다 ?!
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련자 문제로 인하여 대련을 중단합니다."));
|
||||
restart = false;
|
||||
}
|
||||
else if (pCharA == NULL && pCharB != NULL)
|
||||
{
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("상대방 캐릭터의 문제로 인하여 대련을 종료합니다."));
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련자 문제로 인하여 대련을 종료합니다."));
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("상대방 캐릭터의 문제로 인하여 대련을 종료합니다."));
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련자 문제로 인하여 대련을 종료합니다."));
|
||||
restart = false;
|
||||
}
|
||||
else if (pCharA != NULL && pCharB == NULL)
|
||||
{
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("상대방 캐릭터의 문제로 인하여 대련을 종료합니다."));
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련자 문제로 인하여 대련을 종료합니다."));
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("상대방 캐릭터의 문제로 인하여 대련을 종료합니다."));
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("대련자 문제로 인하여 대련을 종료합니다."));
|
||||
restart = false;
|
||||
}
|
||||
else if (pCharA != NULL && pCharB != NULL)
|
||||
@@ -756,9 +756,9 @@ bool CArena::OnDead(DWORD dwPIDA, DWORD dwPIDB)
|
||||
|
||||
if (m_dwSetPointOfA >= m_dwSetCount)
|
||||
{
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharA->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharA->GetName());
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharA->GetName());
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharA->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharA->GetName());
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharA->GetName());
|
||||
|
||||
sys_log(0, "ARENA: Duel is end. Winner %s(%d) Loser %s(%d)",
|
||||
pCharA->GetName(), GetPlayerAPID(), pCharB->GetName(), GetPlayerBPID());
|
||||
@@ -766,10 +766,10 @@ bool CArena::OnDead(DWORD dwPIDA, DWORD dwPIDB)
|
||||
else
|
||||
{
|
||||
restart = true;
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharA->GetName());
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharA->GetName());
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, "%s %d : %d %s", pCharA->GetName(), m_dwSetPointOfA, m_dwSetPointOfB, pCharB->GetName());
|
||||
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharA->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharA->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, "%s %d : %d %s", pCharA->GetName(), m_dwSetPointOfA, m_dwSetPointOfB, pCharB->GetName());
|
||||
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, "%s %d : %d %s", pCharA->GetName(), m_dwSetPointOfA, m_dwSetPointOfB, pCharB->GetName());
|
||||
@@ -783,19 +783,19 @@ bool CArena::OnDead(DWORD dwPIDA, DWORD dwPIDB)
|
||||
m_dwSetPointOfB++;
|
||||
if (m_dwSetPointOfB >= m_dwSetCount)
|
||||
{
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharB->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharB->GetName());
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharB->GetName());
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharB->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharB->GetName());
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, LC_TEXT("%s 님이 대련에서 승리하였습니다."), pCharB->GetName());
|
||||
|
||||
sys_log(0, "ARENA: Duel is end. Winner(%d) Loser(%d)", GetPlayerBPID(), GetPlayerAPID());
|
||||
}
|
||||
else
|
||||
{
|
||||
restart = true;
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharB->GetName());
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharB->GetName());
|
||||
pCharA->ChatPacket(CHAT_TYPE_NOTICE, "%s %d : %d %s", pCharA->GetName(), m_dwSetPointOfA, m_dwSetPointOfB, pCharB->GetName());
|
||||
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharB->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님이 승리하였습니다."), pCharB->GetName());
|
||||
pCharB->ChatPacket(CHAT_TYPE_NOTICE, "%s %d : %d %s", pCharA->GetName(), m_dwSetPointOfA, m_dwSetPointOfB, pCharB->GetName());
|
||||
|
||||
SendChatPacketToObserver(CHAT_TYPE_NOTICE, "%s %d : %d %s", pCharA->GetName(), m_dwSetPointOfA, m_dwSetPointOfB, pCharB->GetName());
|
||||
@@ -815,18 +815,18 @@ bool CArena::OnDead(DWORD dwPIDA, DWORD dwPIDB)
|
||||
}
|
||||
else
|
||||
{
|
||||
// 오면 안된다 ?!
|
||||
// 오면 안된다 ?!
|
||||
}
|
||||
|
||||
if (restart == false)
|
||||
{
|
||||
if (pCharA != NULL)
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 마을로 되돌아갑니다."));
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 마을로 되돌아갑니다."));
|
||||
|
||||
if ( pCharB != NULL)
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 마을로 되돌아갑니다."));
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 마을로 되돌아갑니다."));
|
||||
|
||||
SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("10초뒤 마을로 되돌아갑니다."));
|
||||
SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("10초뒤 마을로 되돌아갑니다."));
|
||||
|
||||
if (m_pEvent != NULL) {
|
||||
event_cancel(&m_pEvent);
|
||||
@@ -842,12 +842,12 @@ bool CArena::OnDead(DWORD dwPIDA, DWORD dwPIDB)
|
||||
else
|
||||
{
|
||||
if (pCharA != NULL)
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 다음 판을 시작합니다."));
|
||||
pCharA->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 다음 판을 시작합니다."));
|
||||
|
||||
if (pCharB != NULL)
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 다음 판을 시작합니다."));
|
||||
pCharB->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("10초뒤 다음 판을 시작합니다."));
|
||||
|
||||
SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("10초뒤 다음 판을 시작합니다."));
|
||||
SendChatPacketToObserver(CHAT_TYPE_INFO, LC_TEXT("10초뒤 다음 판을 시작합니다."));
|
||||
|
||||
if (m_pEvent != NULL) {
|
||||
event_cancel(&m_pEvent);
|
||||
@@ -953,7 +953,7 @@ void CArena::OnDisconnect(DWORD pid)
|
||||
if (m_dwPIDA == pid)
|
||||
{
|
||||
if (GetPlayerB() != NULL)
|
||||
GetPlayerB()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방 캐릭터가 접속을 종료하여 대련을 중지합니다."));
|
||||
GetPlayerB()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방 캐릭터가 접속을 종료하여 대련을 중지합니다."));
|
||||
|
||||
sys_log(0, "ARENA : Duel is end because of Opp(%d) is disconnect. MyPID(%d)", GetPlayerAPID(), GetPlayerBPID());
|
||||
EndDuel();
|
||||
@@ -961,7 +961,7 @@ void CArena::OnDisconnect(DWORD pid)
|
||||
else if (m_dwPIDB == pid)
|
||||
{
|
||||
if (GetPlayerA() != NULL)
|
||||
GetPlayerA()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방 캐릭터가 접속을 종료하여 대련을 중지합니다."));
|
||||
GetPlayerA()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방 캐릭터가 접속을 종료하여 대련을 중지합니다."));
|
||||
|
||||
sys_log(0, "ARENA : Duel is end because of Opp(%d) is disconnect. MyPID(%d)", GetPlayerBPID(), GetPlayerAPID());
|
||||
EndDuel();
|
||||
|
||||
@@ -52,14 +52,14 @@ bool CHARACTER::AutoGiveItemChest(LPITEM item, DWORD& itemCount, std::map<LPITEM
|
||||
for (auto it = vecUpdateItems.begin(); it != vecUpdateItems.end(); ++it)
|
||||
{
|
||||
LPITEM item2 = it->first;
|
||||
if (itemVnum == item2->GetVnum())
|
||||
if (item2->CanStackWith(item))
|
||||
{
|
||||
bool same=true;
|
||||
for(int j=0;j<ITEM_SOCKET_MAX_NUM;++j)
|
||||
if(item2->GetSocket(j)!=item->GetSocket(j)) same=false;
|
||||
if(!same) continue;
|
||||
const DWORD item2Count = item2->GetCount();
|
||||
const WORD bCount2 = MIN(ITEM_MAX_COUNT - item2Count, wCount);
|
||||
const WORD bCount2 = MIN(item2->GetStackRoom(), wCount);
|
||||
if (bCount2 > 0)
|
||||
{
|
||||
wCount -= bCount2;
|
||||
@@ -78,7 +78,7 @@ bool CHARACTER::AutoGiveItemChest(LPITEM item, DWORD& itemCount, std::map<LPITEM
|
||||
LPITEM item2 = GetInventoryItem(i);
|
||||
if (!item2)
|
||||
continue;
|
||||
if (item2->GetVnum() == itemVnum)
|
||||
if (item2->CanStackWith(item))
|
||||
{
|
||||
BYTE j;
|
||||
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
|
||||
@@ -87,7 +87,7 @@ bool CHARACTER::AutoGiveItemChest(LPITEM item, DWORD& itemCount, std::map<LPITEM
|
||||
if (j != ITEM_SOCKET_MAX_NUM)
|
||||
continue;
|
||||
const DWORD item2Count = item2->GetCount();
|
||||
const WORD bCount2 = MIN(ITEM_MAX_COUNT - item2Count, wCount);
|
||||
const WORD bCount2 = MIN(item2->GetStackRoom(), wCount);
|
||||
if (bCount2 > 0)
|
||||
{
|
||||
const auto itItem = vecUpdateItems.find(item2);
|
||||
@@ -229,11 +229,15 @@ bool CHARACTER::GiveItemFromSpecialItemGroupNew(DWORD dwGroupNum, WORD& loopCoun
|
||||
break;
|
||||
default:
|
||||
{
|
||||
// The selected base has 200-count stacks and byte item-count packets.
|
||||
// AVA2 rewards larger than a stack must be split, never silently clamped by CreateItem.
|
||||
const auto* proto = ITEM_MANAGER::Instance().GetTable(dwVnum);
|
||||
if (!proto) { --returnCount; break; }
|
||||
unsigned limit = PortMaterialStackPolicy::GrantLimit(proto->bType,
|
||||
(proto->dwFlags & ITEM_FLAG_STACKABLE) != 0,
|
||||
(proto->dwAntiFlags & ITEM_ANTIFLAG_STACK) != 0, dwVnum);
|
||||
if ((PortMaterialStackPolicy::LegacyGrowthMode() || quest::CQuestManager::instance().GetEventFlag("material_stack_legacy_mode"))) limit=std::min(limit,200u);
|
||||
DWORD remaining=dwEarnCount;
|
||||
while(remaining) {
|
||||
LPITEM item=ITEM_MANAGER::Instance().CreateItem(dwVnum,MIN(remaining,ITEM_MAX_COUNT));
|
||||
LPITEM item=ITEM_MANAGER::Instance().CreateItem(dwVnum,MIN(remaining,limit));
|
||||
if(!item) { --returnCount; break; }
|
||||
const DWORD created=item->GetCount();
|
||||
DWORD count=created;
|
||||
|
||||
@@ -20,7 +20,7 @@ static const Ava2TicketOffer kAva2Tickets[]={
|
||||
struct Ava2ShopPrice { DWORD vnum,count; };
|
||||
struct Ava2ShopStart { TPacketGCShopStart shop; Ava2ShopPrice prices[SHOP_HOST_ITEM_MAX_NUM]; };
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(Ava2ShopStart)==2204,"native currency shop payload");
|
||||
static_assert(sizeof(Ava2ShopStart)==2244,"native currency shop payload");
|
||||
static_assert(sizeof(Ava2ShopPrice)==8,"AVA2 item price layout");
|
||||
class CAva2TicketShop : public CShop {
|
||||
public:
|
||||
|
||||
@@ -1226,7 +1226,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
// END_OF_ADD_REFINE_BUILDING
|
||||
|
||||
bool RefineItem(LPITEM pkItem, LPITEM pkTarget);
|
||||
bool DropItem(TItemPos Cell, BYTE bCount=0);
|
||||
bool DropItem(TItemPos Cell, DWORD bCount=0);
|
||||
bool GiveRecallItem(LPITEM item);
|
||||
void ProcessRecallItem(LPITEM item);
|
||||
|
||||
@@ -1250,7 +1250,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
bool GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector <DWORD> &dwItemVnums,
|
||||
std::vector <DWORD> &dwItemCounts, std::vector <LPITEM> &item_gets, int &count);
|
||||
|
||||
bool MoveItem(TItemPos pos, TItemPos change_pos, BYTE num);
|
||||
bool MoveItem(TItemPos pos, TItemPos change_pos, DWORD num);
|
||||
DWORD GetPickUPMode() { return DWORD(GetQuestFlag("ava2_pickup.mode")); }
|
||||
DWORD GetPickUPRarityMode() { return DWORD(GetQuestFlag("ava2_pickup.rarity")); }
|
||||
void ChangePickUPMode(DWORD mode,DWORD rarity);
|
||||
@@ -1275,8 +1275,8 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
bool CanUnequipNow(const LPITEM item, const TItemPos& srcCell = NPOS, const TItemPos& destCell = NPOS);
|
||||
|
||||
bool SwapItem(WORD bCell, WORD bDestCell);
|
||||
LPITEM AutoGiveItem(DWORD dwItemVnum, BYTE bCount=1, int iRarePct = -1, bool bMsg = true);
|
||||
void AutoGiveItem(LPITEM item, bool longOwnerShip = false);
|
||||
LPITEM AutoGiveItem(DWORD dwItemVnum, DWORD bCount=1, int iRarePct = -1, bool bMsg = true);
|
||||
LPITEM AutoGiveItem(LPITEM item, bool longOwnerShip = false);
|
||||
|
||||
int GetEmptyInventory(BYTE size) const;
|
||||
int GetEmptyDragonSoulInventory(LPITEM pItem) const;
|
||||
|
||||
+121
-205
@@ -1,7 +1,10 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_material_stack_policy.h"
|
||||
#include "port_cube_actor.h"
|
||||
#include "../../common/gold_bounds.h"
|
||||
|
||||
// Pickup locale keys must stay CP949, matching locale_string.txt on the server.
|
||||
// UTF-8 source literals miss the dictionary and emit a corrupt @0949 fallback.
|
||||
#include <stack>
|
||||
|
||||
#include "utils.h"
|
||||
@@ -57,6 +60,7 @@
|
||||
#include "port_premium.h"
|
||||
#include "port_battlepass_hooks.h"
|
||||
#include "PetSystem.h"
|
||||
#include "port_refine_materials.h"
|
||||
const int ITEM_BROKEN_METIN_VNUM = 28960;
|
||||
|
||||
// CHANGE_ITEM_ATTRIBUTES
|
||||
@@ -1298,23 +1302,10 @@ bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bMoneyOnly && !RefineChance)
|
||||
if (!bMoneyOnly && !RefineChance && !PortRefineTakeMaterials(this,prt))
|
||||
{
|
||||
for (int i = 0; i < prt->material_count; ++i)
|
||||
{
|
||||
if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
|
||||
{
|
||||
if (test_server)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
|
||||
}
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개량을 하기 위한 재료가 부족합니다."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < prt->material_count; ++i)
|
||||
RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
|
||||
return false;
|
||||
}
|
||||
|
||||
int prob = number(1, 100);
|
||||
@@ -1503,22 +1494,12 @@ bool CHARACTER::DoRefineWithScroll(LPITEM item)
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < prt->material_count; ++i)
|
||||
if (!PortRefineTakeMaterials(this,prt))
|
||||
{
|
||||
if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
|
||||
{
|
||||
if (test_server)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
|
||||
}
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("개량을 하기 위한 재료가 부족합니다."));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < prt->material_count; ++i)
|
||||
RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
|
||||
|
||||
int prob = number(1, 100);
|
||||
int success_prob = prt->prob;
|
||||
bool bDestroyWhenFail = false;
|
||||
@@ -6293,9 +6274,9 @@ bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
|
||||
return UseItemEx(item, DestCell);
|
||||
}
|
||||
|
||||
bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
|
||||
bool CHARACTER::DropItem(TItemPos Cell, DWORD bCount)
|
||||
{
|
||||
LPITEM item = NULL;
|
||||
LPITEM item = NULL;
|
||||
|
||||
if (!CanHandleItem())
|
||||
{
|
||||
@@ -6328,8 +6309,23 @@ bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bCount == 0 || bCount > item->GetCount())
|
||||
bCount = item->GetCount();
|
||||
if (bCount > item->GetCount()) return false;
|
||||
if (bCount == 0) bCount = item->GetCount();
|
||||
|
||||
// Clear the variable, it looks the player does not dropped any item in the past second.
|
||||
if (thecore_pulse() > LastDropTime + 25)
|
||||
CountDrops = 0;
|
||||
|
||||
// It looks the player dropped min. 4 items in the past 1 second
|
||||
if (thecore_pulse() < LastDropTime + 25 && CountDrops >= 4)
|
||||
{
|
||||
// Set it to 0
|
||||
CountDrops = 0;
|
||||
sys_err("%s[%d] has been disconnected because of drophack using", GetName(), GetPlayerID());
|
||||
// Disconnect the player
|
||||
GetDesc()->SetPhase(PHASE_CLOSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255); // Quickslot 에서 지움
|
||||
|
||||
@@ -6348,19 +6344,17 @@ bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
|
||||
sys_log(0, "[DROP_ITEM] drop item count == 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// check non-split items for china
|
||||
//if (LC_IsNewCIBN())
|
||||
// if (item->GetVnum() == 71095 || item->GetVnum() == 71050 || item->GetVnum() == 70038)
|
||||
// return false;
|
||||
|
||||
item->SetCount(item->GetCount() - bCount);
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(item);
|
||||
|
||||
pkItemToDrop = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), bCount);
|
||||
|
||||
// copy item socket -- by mhh
|
||||
FN_copy_item_socket(pkItemToDrop, item);
|
||||
pkItemToDrop = ITEM_MANAGER::instance().CreateItem(item->GetOriginalVnum(), bCount);
|
||||
if (!pkItemToDrop) return false;
|
||||
if (!item->CopyStackStateTo(pkItemToDrop)) { M2_DESTROY_ITEM(pkItemToDrop); return false; }
|
||||
if (!item->SetCount(item->GetCount() - bCount)) { M2_DESTROY_ITEM(pkItemToDrop); return false; }
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(item);
|
||||
|
||||
char szBuf[51 + 1];
|
||||
snprintf(szBuf, sizeof(szBuf), "%u %u", pkItemToDrop->GetID(), pkItemToDrop->GetCount());
|
||||
@@ -6368,21 +6362,7 @@ bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
|
||||
}
|
||||
|
||||
PIXEL_POSITION pxPos = GetXYZ();
|
||||
|
||||
// Clear the variable, it looks the player does not dropped any item in the past second.
|
||||
if (thecore_pulse() > LastDropTime + 25)
|
||||
CountDrops = 0;
|
||||
|
||||
// It looks the player dropped min. 4 items in the past 1 second
|
||||
if (thecore_pulse() < LastDropTime + 25 && CountDrops >= 4)
|
||||
{
|
||||
// Set it to 0
|
||||
CountDrops = 0;
|
||||
sys_err("%s[%d] has been disconnected because of drophack using", GetName(), GetPlayerID());
|
||||
// Disconnect the player
|
||||
GetDesc()->SetPhase(PHASE_CLOSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (pkItemToDrop->AddToGround(GetMapIndex(), pxPos))
|
||||
{
|
||||
@@ -6395,17 +6375,26 @@ bool CHARACTER::DropItem(TItemPos Cell, BYTE bCount)
|
||||
pkItemToDrop->StartDestroyEvent();
|
||||
|
||||
ITEM_MANAGER::instance().FlushDelayedSave(pkItemToDrop);
|
||||
|
||||
|
||||
char szHint[32 + 1];
|
||||
snprintf(szHint, sizeof(szHint), "%s %u %u", pkItemToDrop->GetName(), pkItemToDrop->GetCount(), pkItemToDrop->GetOriginalVnum());
|
||||
LogManager::instance().ItemLog(this, pkItemToDrop, "DROP", szHint);
|
||||
|
||||
|
||||
LastDropTime = thecore_pulse();
|
||||
CountDrops++;
|
||||
|
||||
|
||||
//Motion(MOTION_PICKUP);
|
||||
}
|
||||
|
||||
else {
|
||||
if (pkItemToDrop == item) item->AddToCharacter(this, Cell);
|
||||
else {
|
||||
item->SetCount(item->GetCount() + pkItemToDrop->GetCount());
|
||||
M2_DESTROY_ITEM(pkItemToDrop);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6474,7 +6463,7 @@ bool CHARACTER::DropGold(int64_t gold)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||
bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, DWORD count)
|
||||
{
|
||||
if (Cell.IsSamePosition(DestCell)) // ItemMove dupe exploit fix
|
||||
return false;
|
||||
@@ -6623,7 +6612,7 @@ bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||
|
||||
if ((item2 = GetItem(DestCell)) && item != item2 && item2->IsStackable() &&
|
||||
!IS_SET(item2->GetAntiFlag(), ITEM_ANTIFLAG_STACK) &&
|
||||
item2->GetVnum() == item->GetVnum()) // 합칠 수 있는 아이템의 경우
|
||||
item2->CanStackWith(item)) // 합칠 수 있는 아이템의 경우
|
||||
{
|
||||
for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
|
||||
if (item2->GetSocket(i) != item->GetSocket(i))
|
||||
@@ -6635,7 +6624,8 @@ bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||
sys_log(0, "%s: ITEM_STACK %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
|
||||
DestCell.window_type, DestCell.cell, count);
|
||||
|
||||
count = MIN(200 - item2->GetCount(), count);
|
||||
count = MIN(item2->GetStackRoom(), count);
|
||||
if (!count) return false;
|
||||
|
||||
item->SetCount(item->GetCount() - count);
|
||||
item2->SetCount(item2->GetCount() + count);
|
||||
@@ -6670,11 +6660,10 @@ bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, BYTE count)
|
||||
sys_log(0, "%s: ITEM_SPLIT %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
|
||||
DestCell.window_type, DestCell.cell, count);
|
||||
|
||||
item->SetCount(item->GetCount() - count);
|
||||
LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), count);
|
||||
|
||||
// copy socket -- by mhh
|
||||
FN_copy_item_socket(item2, item);
|
||||
LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetOriginalVnum(), count);
|
||||
if (!item2) return false;
|
||||
if (!item->CopyStackStateTo(item2)) { M2_DESTROY_ITEM(item2); return false; }
|
||||
if (!item->SetCount(item->GetCount() - count)) { M2_DESTROY_ITEM(item2); return false; }
|
||||
|
||||
item2->AddToCharacter(this, DestCell);
|
||||
|
||||
@@ -6856,7 +6845,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
{
|
||||
if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
|
||||
{
|
||||
BYTE bCount = item->GetCount();
|
||||
DWORD bCount = item->GetCount();
|
||||
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
BYTE specialWin = 0;
|
||||
@@ -6873,7 +6862,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
LPITEM item2 = GetItem(TItemPos(specialWin, i));
|
||||
if (!item2)
|
||||
continue;
|
||||
if (item2->GetVnum() == item->GetVnum())
|
||||
if (item2->CanStackWith(item))
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
|
||||
@@ -6882,12 +6871,12 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
if (j != ITEM_SOCKET_MAX_NUM)
|
||||
continue;
|
||||
|
||||
BYTE bCount2 = MIN(200 - item2->GetCount(), bCount);
|
||||
DWORD bCount2 = MIN(item2->GetStackRoom(), bCount);
|
||||
bCount -= bCount2;
|
||||
item2->SetCount(item2->GetCount() + bCount2);
|
||||
if (bCount == 0)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item2->GetName());
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("\xbe\xc6\xc0\xcc\xc5\xdb \xc8\xb9\xb5\xe6: %s"), item2->GetName());
|
||||
M2_DESTROY_ITEM(item);
|
||||
if (item2->GetType() == ITEM_QUEST)
|
||||
quest::CQuestManager::instance().PickupItem(GetPlayerID(), item2);
|
||||
@@ -6906,7 +6895,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
if (!item2)
|
||||
continue;
|
||||
|
||||
if (item2->GetVnum() == item->GetVnum())
|
||||
if (item2->CanStackWith(item))
|
||||
{
|
||||
int j;
|
||||
|
||||
@@ -6917,14 +6906,14 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
if (j != ITEM_SOCKET_MAX_NUM)
|
||||
continue;
|
||||
|
||||
BYTE bCount2 = MIN(200 - item2->GetCount(), bCount);
|
||||
DWORD bCount2 = MIN(item2->GetStackRoom(), bCount);
|
||||
bCount -= bCount2;
|
||||
|
||||
item2->SetCount(item2->GetCount() + bCount2);
|
||||
|
||||
if (bCount == 0)
|
||||
{
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item2->GetName());
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("\xbe\xc6\xc0\xcc\xc5\xdb \xc8\xb9\xb5\xe6: %s"), item2->GetName());
|
||||
M2_DESTROY_ITEM(item);
|
||||
if (item2->GetType() == ITEM_QUEST)
|
||||
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
|
||||
@@ -7013,7 +7002,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
char szHint[32+1];
|
||||
snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
|
||||
LogManager::instance().ItemLog(this, item, "GET", szHint);
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("\xbe\xc6\xc0\xcc\xc5\xdb \xc8\xb9\xb5\xe6: %s"), item->GetName());
|
||||
|
||||
if (item->GetType() == ITEM_QUEST)
|
||||
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
|
||||
@@ -7072,11 +7061,11 @@ bool CHARACTER::PickupItem(DWORD dwVID)
|
||||
LogManager::instance().ItemLog(owner, item, "GET", szHint);
|
||||
|
||||
if (owner == this)
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("\xbe\xc6\xc0\xcc\xc5\xdb \xc8\xb9\xb5\xe6: %s"), item->GetName());
|
||||
else
|
||||
{
|
||||
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s 님으로부터 %s"), GetName(), item->GetName());
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 전달: %s 님에게 %s"), owner->GetName(), item->GetName());
|
||||
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("\xbe\xc6\xc0\xcc\xc5\xdb \xc8\xb9\xb5\xe6: %s \xb4\xd4\xc0\xb8\xb7\xce\xba\xce\xc5\xcd %s"), GetName(), item->GetName());
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("\xbe\xc6\xc0\xcc\xc5\xdb \xc0\xfc\xb4\xde: %s \xb4\xd4\xbf\xa1\xb0\xd4 %s"), owner->GetName(), item->GetName());
|
||||
}
|
||||
|
||||
if (item->GetType() == ITEM_QUEST)
|
||||
@@ -7651,19 +7640,34 @@ void CHARACTER::RemoveSpecifyTypeItem(BYTE type, DWORD count)
|
||||
}
|
||||
}
|
||||
|
||||
void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
|
||||
LPITEM CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
|
||||
{
|
||||
if (NULL == item)
|
||||
{
|
||||
sys_err ("NULL point.");
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
if (item->GetOwner())
|
||||
{
|
||||
sys_err ("item %d 's owner exists!",item->GetID());
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (item->IsStackable())
|
||||
{
|
||||
DWORD remaining = item->GetCount();
|
||||
for (int cell = 0; cell < INVENTORY_MAX_NUM; ++cell)
|
||||
{
|
||||
LPITEM target = GetInventoryItem(cell);
|
||||
if (!target || !target->CanStackWith(item)) continue;
|
||||
const DWORD moved = std::min(remaining, target->GetStackRoom());
|
||||
if (!moved) continue;
|
||||
target->SetCount(target->GetCount() + moved);
|
||||
remaining -= moved;
|
||||
if (!remaining) { M2_DESTROY_ITEM(item); return target; }
|
||||
}
|
||||
item->SetCount(remaining);
|
||||
}
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
if (item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
|
||||
{
|
||||
@@ -7682,7 +7686,7 @@ void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
|
||||
LPITEM item2 = GetItem(TItemPos(specialWin, i));
|
||||
if (!item2)
|
||||
continue;
|
||||
if (item2->GetVnum() == item->GetVnum())
|
||||
if (item2->CanStackWith(item))
|
||||
{
|
||||
bool socketMatch = true;
|
||||
for (int s = 0; s < ITEM_SOCKET_MAX_NUM; ++s)
|
||||
@@ -7696,7 +7700,7 @@ void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
|
||||
if (!socketMatch)
|
||||
continue;
|
||||
|
||||
DWORD bCount2 = MIN(200 - item2->GetCount(), bCount);
|
||||
DWORD bCount2 = MIN(item2->GetStackRoom(), bCount);
|
||||
bCount -= bCount2;
|
||||
item2->SetCount(item2->GetCount() + bCount2);
|
||||
if (bCount == 0)
|
||||
@@ -7704,7 +7708,7 @@ void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
|
||||
if (item2->GetType() == ITEM_QUEST || item2->GetType() == ITEM_MATERIAL)
|
||||
quest::CQuestManager::instance().PickupItem(GetPlayerID(), item2);
|
||||
M2_DESTROY_ITEM(item);
|
||||
return;
|
||||
return item2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7783,132 +7787,44 @@ void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
|
||||
item->SetOwnership (this, 60);
|
||||
LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, BYTE bCount, int iRarePct, bool bMsg)
|
||||
LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, DWORD bCount, int iRarePct, bool bMsg)
|
||||
{
|
||||
TItemTable * p = ITEM_MANAGER::instance().GetTable(dwItemVnum);
|
||||
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
DBManager::instance().SendMoneyLog(MONEY_LOG_DROP, dwItemVnum, bCount);
|
||||
|
||||
if (p->dwFlags & ITEM_FLAG_STACKABLE && p->bType != ITEM_BLEND)
|
||||
{
|
||||
for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
|
||||
{
|
||||
LPITEM item = GetInventoryItem(i);
|
||||
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
|
||||
{
|
||||
if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
|
||||
{
|
||||
if (bCount < p->alValues[1])
|
||||
bCount = p->alValues[1];
|
||||
}
|
||||
|
||||
BYTE bCount2 = MIN(200 - item->GetCount(), bCount);
|
||||
bCount -= bCount2;
|
||||
|
||||
item->SetCount(item->GetCount() + bCount2);
|
||||
|
||||
if (bCount == 0)
|
||||
{
|
||||
if (bMsg)
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LPITEM item = ITEM_MANAGER::instance().CreateItem(dwItemVnum, bCount, 0, true);
|
||||
|
||||
if (!item)
|
||||
{
|
||||
sys_err("cannot create item by vnum %u (name: %s)", dwItemVnum, GetName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (item->GetType() == ITEM_BLEND)
|
||||
{
|
||||
for (int i=0; i < INVENTORY_MAX_NUM; i++)
|
||||
{
|
||||
LPITEM inv_item = GetInventoryItem(i);
|
||||
|
||||
if (inv_item == NULL) continue;
|
||||
|
||||
if (inv_item->GetType() == ITEM_BLEND)
|
||||
{
|
||||
if (inv_item->GetVnum() == item->GetVnum())
|
||||
{
|
||||
if (inv_item->GetSocket(0) == item->GetSocket(0) &&
|
||||
inv_item->GetSocket(1) == item->GetSocket(1) &&
|
||||
inv_item->GetSocket(2) == item->GetSocket(2) &&
|
||||
inv_item->GetCount() < ITEM_MAX_COUNT)
|
||||
{
|
||||
inv_item->SetCount(inv_item->GetCount() + item->GetCount());
|
||||
return inv_item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int iEmptyCell;
|
||||
if (item->IsDragonSoul())
|
||||
{
|
||||
iEmptyCell = GetEmptyDragonSoulInventory(item);
|
||||
}
|
||||
else
|
||||
iEmptyCell = GetEmptyInventory(item->GetSize());
|
||||
|
||||
if (iEmptyCell != -1)
|
||||
{
|
||||
if (bMsg)
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
|
||||
|
||||
if (item->IsDragonSoul())
|
||||
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
|
||||
else
|
||||
item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
|
||||
LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
|
||||
|
||||
if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
|
||||
{
|
||||
TQuickslot * pSlot;
|
||||
|
||||
if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
|
||||
{
|
||||
TQuickslot slot;
|
||||
slot.type = QUICKSLOT_TYPE_ITEM;
|
||||
slot.pos = iEmptyCell;
|
||||
SetQuickslot(0, slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item->AddToGround(GetMapIndex(), GetXYZ());
|
||||
item->StartDestroyEvent();
|
||||
// 안티 드랍 flag가 걸려있는 아이템의 경우,
|
||||
// 인벤에 빈 공간이 없어서 어쩔 수 없이 떨어트리게 되면,
|
||||
// ownership을 아이템이 사라질 때까지(300초) 유지한다.
|
||||
if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP))
|
||||
item->SetOwnership(this, 300);
|
||||
else
|
||||
item->SetOwnership(this, 60);
|
||||
LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
|
||||
}
|
||||
|
||||
sys_log(0,
|
||||
"7: %d %d", dwItemVnum, bCount);
|
||||
return item;
|
||||
const TItemTable* proto = ITEM_MANAGER::instance().GetTable(dwItemVnum);
|
||||
if (!proto || !bCount) return NULL;
|
||||
unsigned limit = PortMaterialStackPolicy::GrantLimit(proto->bType,
|
||||
(proto->dwFlags & ITEM_FLAG_STACKABLE) != 0,
|
||||
(proto->dwAntiFlags & ITEM_ANTIFLAG_STACK) != 0, dwItemVnum);
|
||||
if ((PortMaterialStackPolicy::LegacyGrowthMode() || quest::CQuestManager::instance().GetEventFlag("material_stack_legacy_mode")))
|
||||
limit = std::min(limit, 200u);
|
||||
if ((proto->dwFlags & ITEM_FLAG_MAKECOUNT) && proto->alValues[1] > 0)
|
||||
bCount = std::max(bCount, DWORD(proto->alValues[1]));
|
||||
LPITEM result = NULL;
|
||||
while (bCount)
|
||||
{
|
||||
const DWORD chunk = std::min(bCount, limit);
|
||||
LPITEM item = ITEM_MANAGER::instance().CreateItem(dwItemVnum, chunk, 0, true, iRarePct);
|
||||
if (!item) { sys_err("AutoGiveItem failed: vnum %u remaining %u", dwItemVnum, bCount); return result; }
|
||||
if (item->GetCount() != chunk && !item->SetCount(chunk)) { M2_DESTROY_ITEM(item); return result; }
|
||||
result = AutoGiveItem(item);
|
||||
if (!result) { M2_DESTROY_ITEM(item); return NULL; }
|
||||
DBManager::instance().SendMoneyLog(MONEY_LOG_DROP, dwItemVnum, chunk);
|
||||
bCount -= chunk;
|
||||
}
|
||||
if (result && bMsg)
|
||||
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), result->GetName());
|
||||
if (result && result->GetWindow() == INVENTORY && result->GetType() == ITEM_USE && result->GetSubType() == USE_POTION)
|
||||
{
|
||||
TQuickslot* slot;
|
||||
if (GetQuickslot(0, &slot) && slot->type == QUICKSLOT_TYPE_NONE)
|
||||
{
|
||||
TQuickslot newSlot; newSlot.type = QUICKSLOT_TYPE_ITEM; newSlot.pos = result->GetCell();
|
||||
SetQuickslot(0, newSlot);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CHARACTER::GiveItem(LPCHARACTER victim, TItemPos Cell)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define _cube_cpp_
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "port_material_stack_policy.h"
|
||||
#include "port_cube_actor.h"
|
||||
#include "constants.h"
|
||||
#include "utils.h"
|
||||
@@ -369,6 +370,7 @@ void Cube_init()
|
||||
}
|
||||
|
||||
s_cube_proto.clear();
|
||||
PortMaterialStackPolicy::CubeIngredients().clear();
|
||||
|
||||
if (false == Cube_load(file_name))
|
||||
sys_err("Cube_Init failed");
|
||||
@@ -461,6 +463,8 @@ bool Cube_load (const char *file)
|
||||
continue;
|
||||
}
|
||||
s_cube_proto.push_back(cube_data);
|
||||
for (const auto& material : cube_data->item)
|
||||
PortMaterialStackPolicy::CubeIngredients().insert(material.vnum);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_material_stack_policy.h"
|
||||
#include "port_cheque.h"
|
||||
#include "constants.h"
|
||||
#include "../../common/teen_packet.h"
|
||||
@@ -97,10 +98,19 @@ static bool FN_is_battle_zone(LPCHARACTER ch)
|
||||
|
||||
void CInputLogin::Login(LPDESC d, const char * data)
|
||||
{
|
||||
const char* stackRevision = strstr(d->GetClientVersion(), "mt");
|
||||
if (!stackRevision || atoi(stackRevision + 2) < 20261030) {
|
||||
LoginFailure(d, "VERSION"); d->DelayedDisconnect(1); return;
|
||||
}
|
||||
|
||||
TPacketCGLogin * pinfo = (TPacketCGLogin *) data;
|
||||
|
||||
char login[LOGIN_MAX_LEN + 1];
|
||||
trim_and_lower(pinfo->login, login, sizeof(login));
|
||||
if (!PortMaterialStackPolicy::QAAllowed(login)) {
|
||||
LoginFailure(d, "SHUTDOWN"); d->DelayedDisconnect(1); return;
|
||||
}
|
||||
|
||||
|
||||
sys_log(0, "InputLogin::Login : %s", login);
|
||||
|
||||
@@ -149,10 +159,19 @@ void CInputLogin::Login(LPDESC d, const char * data)
|
||||
|
||||
void CInputLogin::LoginByKey(LPDESC d, const char * data)
|
||||
{
|
||||
const char* stackRevision = strstr(d->GetClientVersion(), "mt");
|
||||
if (!stackRevision || atoi(stackRevision + 2) < 20261030) {
|
||||
LoginFailure(d, "VERSION"); d->DelayedDisconnect(1); return;
|
||||
}
|
||||
|
||||
TPacketCGLogin2 * pinfo = (TPacketCGLogin2 *) data;
|
||||
|
||||
char login[LOGIN_MAX_LEN + 1];
|
||||
trim_and_lower(pinfo->login, login, sizeof(login));
|
||||
if (!PortMaterialStackPolicy::QAAllowed(login)) {
|
||||
LoginFailure(d, "SHUTDOWN"); d->DelayedDisconnect(1); return;
|
||||
}
|
||||
|
||||
|
||||
// is blocked ip?
|
||||
{
|
||||
@@ -247,6 +266,13 @@ void CInputLogin::ChangeName(LPDESC d, const char * data)
|
||||
|
||||
void CInputLogin::CharacterSelect(LPDESC d, const char * data)
|
||||
{
|
||||
const char* revision = strstr(d->GetClientVersion(), "mt");
|
||||
if (!revision || atoi(revision + 2) < 20261030) {
|
||||
LoginFailure(d, "VERSION");
|
||||
d->DelayedDisconnect(1);
|
||||
return;
|
||||
}
|
||||
|
||||
struct command_player_select * pinfo = (struct command_player_select *) data;
|
||||
const TAccountTable & c_r = d->GetAccountTable();
|
||||
|
||||
@@ -573,7 +599,7 @@ void CInputLogin::Entergame(LPDESC d, const char * data)
|
||||
{
|
||||
// PORT: wear40 moves dragon-soul/belt cells; mt20261029 adds the conqueror fields and five slots; older clients must not enter this world.
|
||||
const char* revision=strstr(d->GetClientVersion(),"mt");
|
||||
if(!revision || atoi(revision+2)<20261029)
|
||||
if(!revision || atoi(revision+2)<20261030)
|
||||
{
|
||||
if(d->GetCharacter())d->GetCharacter()->ChatPacket(CHAT_TYPE_INFO,"Please update the client before entering the game.");
|
||||
d->DelayedDisconnect(1);return;
|
||||
@@ -1148,11 +1174,23 @@ int CInputLogin::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
|
||||
break;
|
||||
|
||||
case HEADER_CG_CLIENT_VERSION:
|
||||
Version(d->GetCharacter(), c_pData);
|
||||
{
|
||||
// Version is now sent before character selection; no actor exists yet.
|
||||
const auto* packet = reinterpret_cast<const TPacketCGClientVersion*>(c_pData);
|
||||
char timestamp[sizeof(packet->timestamp) + 1] = {};
|
||||
memcpy(timestamp, packet->timestamp, sizeof(packet->timestamp));
|
||||
d->SetClientVersion(timestamp);
|
||||
}
|
||||
break;
|
||||
|
||||
case HEADER_CG_CLIENT_VERSION2:
|
||||
Version(d->GetCharacter(), c_pData);
|
||||
{
|
||||
// Version is now sent before character selection; no actor exists yet.
|
||||
const auto* packet = reinterpret_cast<const TPacketCGClientVersion*>(c_pData);
|
||||
char timestamp[sizeof(packet->timestamp) + 1] = {};
|
||||
memcpy(timestamp, packet->timestamp, sizeof(packet->timestamp));
|
||||
d->SetClientVersion(timestamp);
|
||||
}
|
||||
break;
|
||||
|
||||
// case HEADER_CG_HS_ACK:
|
||||
|
||||
@@ -1076,15 +1076,16 @@ int CInputMain::Shop(LPCHARACTER ch, const char * data, size_t uiBytes)
|
||||
|
||||
case SHOP_SUBHEADER_CG_SELL2:
|
||||
{
|
||||
if (uiBytes < sizeof(BYTE) + sizeof(BYTE))
|
||||
if (uiBytes < sizeof(BYTE) + sizeof(WORD))
|
||||
return -1;
|
||||
|
||||
BYTE pos = *(c_pData++);
|
||||
BYTE count = *(c_pData);
|
||||
WORD count = 0;
|
||||
memcpy(&count, c_pData, sizeof(count));
|
||||
|
||||
sys_log(0, "INPUT: %s SHOP: SELL2", ch->GetName());
|
||||
CShopManager::instance().Sell(ch, pos, count);
|
||||
return sizeof(BYTE) + sizeof(BYTE);
|
||||
return sizeof(BYTE) + sizeof(WORD);
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "port_material_stack_policy.h"
|
||||
#include "questmanager.h"
|
||||
#include "port_cube_actor.h"
|
||||
#include "../../common/cube_mutation.h"
|
||||
#include "../../common/economy.h"
|
||||
@@ -227,6 +229,19 @@ void CItem::UpdatePacket()
|
||||
if (m_bWindow == SWITCHBOT)
|
||||
return;
|
||||
|
||||
if (m_bWindow == SAFEBOX || m_bWindow == MALL)
|
||||
{
|
||||
TPacketGCItemSet packet = {};
|
||||
packet.header = m_bWindow == SAFEBOX ? HEADER_GC_SAFEBOX_SET : HEADER_GC_MALL_SET;
|
||||
packet.Cell = TItemPos(m_bWindow, m_wCell);
|
||||
packet.vnum = GetVnum(); packet.count = GetCount();
|
||||
packet.flags = GetFlag(); packet.anti_flags = GetAntiFlag();
|
||||
memcpy(packet.alSockets, m_alSockets, sizeof(packet.alSockets));
|
||||
memcpy(packet.aAttr, m_aAttr, sizeof(packet.aAttr));
|
||||
m_pOwner->GetDesc()->Packet(&packet, sizeof(packet));
|
||||
SendPortExtra();
|
||||
return;
|
||||
}
|
||||
TPacketGCItemUpdate pack;
|
||||
|
||||
pack.header = HEADER_GC_ITEM_UPDATE;
|
||||
@@ -244,13 +259,62 @@ void CItem::UpdatePacket()
|
||||
SendPortExtra();
|
||||
}
|
||||
|
||||
unsigned CItem::GetStackLimit() const
|
||||
{
|
||||
return m_pProto ? PortMaterialStackPolicy::Limit(m_pProto->bType,
|
||||
(m_lFlag & ITEM_FLAG_STACKABLE) != 0,
|
||||
(m_pProto->dwAntiFlags & ITEM_ANTIFLAG_STACK) != 0, m_pProto->dwVnum) : 1;
|
||||
}
|
||||
|
||||
unsigned CItem::GetStackRoom()
|
||||
{
|
||||
// Rollback disables growth while retaining wide-count reads and deductions.
|
||||
unsigned limit = GetStackLimit();
|
||||
if ((PortMaterialStackPolicy::LegacyGrowthMode() || quest::CQuestManager::instance().GetEventFlag("material_stack_legacy_mode")))
|
||||
limit = std::min(limit, 200u);
|
||||
return GetCount() < limit ? limit - GetCount() : 0;
|
||||
}
|
||||
|
||||
bool CItem::CanStackWith(const CItem* other) const
|
||||
{
|
||||
if (!other || !m_pProto || !other->m_pProto ||
|
||||
m_dwVnum != other->m_dwVnum || m_dwMaskVnum != other->m_dwMaskVnum ||
|
||||
m_dwSIGVnum != other->m_dwSIGVnum || m_lFlag != other->m_lFlag ||
|
||||
!(m_lFlag & ITEM_FLAG_STACKABLE) || !(other->m_lFlag & ITEM_FLAG_STACKABLE) ||
|
||||
((m_pProto->dwAntiFlags | other->m_pProto->dwAntiFlags) & ITEM_ANTIFLAG_STACK) ||
|
||||
m_bExchanging || other->m_bExchanging || m_isLocked || other->m_isLocked)
|
||||
return false;
|
||||
CItem* self = const_cast<CItem*>(this);
|
||||
CItem* source = const_cast<CItem*>(other);
|
||||
const unsigned mask = PortAttrLockGet(self);
|
||||
const unsigned otherMask = PortAttrLockGet(source);
|
||||
if (!self->m_portAttrLockLoaded || !source->m_portAttrLockLoaded) return false;
|
||||
return !memcmp(m_alSockets, other->m_alSockets, sizeof(m_alSockets)) &&
|
||||
!memcmp(m_aAttr, other->m_aAttr, sizeof(m_aAttr)) &&
|
||||
!memcmp(&m_portExtra, &other->m_portExtra, sizeof(m_portExtra)) &&
|
||||
mask == otherMask;
|
||||
}
|
||||
|
||||
bool CItem::CopyStackStateTo(CItem* target)
|
||||
{
|
||||
if (!target || target->GetOriginalVnum() != GetOriginalVnum()) return false;
|
||||
const unsigned mask = PortAttrLockGet(this);
|
||||
if (!m_portAttrLockLoaded) return false;
|
||||
target->SetSockets(GetSockets());
|
||||
CopyAttributeTo(target);
|
||||
target->SetPortExtra(GetPortExtra());
|
||||
target->m_lFlag = m_lFlag;
|
||||
target->m_dwMaskVnum = m_dwMaskVnum;
|
||||
target->m_dwSIGVnum = m_dwSIGVnum;
|
||||
if (mask && !PortAttrLockSet(NULL, target, mask)) return false;
|
||||
target->m_portAttrLockLoaded = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD CItem::GetCount()
|
||||
{
|
||||
if (GetType() == ITEM_ELK) return MIN(m_dwCount, INT_MAX);
|
||||
else
|
||||
{
|
||||
return MIN(m_dwCount, 200);
|
||||
}
|
||||
// Never truncate saved counts while loading, transferring, or rolling back.
|
||||
return m_dwCount;
|
||||
}
|
||||
|
||||
bool CItem::SetCount(DWORD count)
|
||||
@@ -261,7 +325,8 @@ bool CItem::SetCount(DWORD count)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dwCount = MIN(count, ITEM_MAX_COUNT);
|
||||
if (count > GetStackLimit()) return false;
|
||||
m_dwCount = count;
|
||||
}
|
||||
|
||||
if (count == 0 && m_pOwner)
|
||||
@@ -449,7 +514,7 @@ void CItem::PortCubeInitNewAttach()
|
||||
bool CItem::PortCubeRestoreMetadata(const PortEconomy::Reward& r)
|
||||
{
|
||||
if(!m_portCubeTemplate||m_pOwner||GetSectree()||r.id!=GetID()||r.vnum!=GetOriginalVnum()||
|
||||
!r.count||r.count>ITEM_MAX_COUNT||(!IsStackable()&&r.count!=1))return false;
|
||||
!r.count||r.count>GetStackLimit()||(!IsStackable()&&r.count!=1))return false;
|
||||
m_dwCount=r.count;
|
||||
for(unsigned i=0;i<3;++i)m_alSockets[i]=r.sockets[i];
|
||||
for(unsigned i=0;i<7;++i){m_aAttr[i].bType=r.types[i];m_aAttr[i].sValue=r.values[i];}
|
||||
|
||||
@@ -23,6 +23,11 @@ class CItem : public CEntity
|
||||
|
||||
long FindApplyValue(BYTE bApplyType);
|
||||
|
||||
unsigned GetStackLimit() const;
|
||||
unsigned GetStackRoom();
|
||||
bool CanStackWith(const CItem* other) const;
|
||||
bool CopyStackStateTo(CItem* target);
|
||||
|
||||
bool IsStackable() { return (GetFlag() & ITEM_FLAG_STACKABLE)?true:false; }
|
||||
|
||||
void Initialize();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "item.h"
|
||||
#include "item_manager.h"
|
||||
#include "port_cube_factory.h"
|
||||
#include "port_material_stack_policy.h"
|
||||
#include "mob_manager.h"
|
||||
#include "port_calendar_runtime.h"
|
||||
|
||||
@@ -190,6 +191,12 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
|
||||
|
||||
if (NULL == table)
|
||||
return NULL;
|
||||
const unsigned stackLimit = PortMaterialStackPolicy::Limit(table->bType,
|
||||
(table->dwFlags & ITEM_FLAG_STACKABLE) != 0,
|
||||
(table->dwAntiFlags & ITEM_ANTIFLAG_STACK) != 0, table->dwVnum);
|
||||
if (table->bType != ITEM_ELK && (table->dwFlags & ITEM_FLAG_STACKABLE) && (!count || count > stackLimit)) return NULL;
|
||||
if (!id && table->bType != ITEM_ELK && count > 200 &&
|
||||
(PortMaterialStackPolicy::LegacyGrowthMode() || quest::CQuestManager::instance().GetEventFlag("material_stack_legacy_mode"))) return NULL;
|
||||
|
||||
LPITEM item = NULL;
|
||||
|
||||
@@ -274,7 +281,7 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
|
||||
;
|
||||
else if (item->IsStackable()) // 합칠 수 있는 아이템의 경우
|
||||
{
|
||||
count = MINMAX(1, count, ITEM_MAX_COUNT);
|
||||
|
||||
|
||||
if (bTryMagic && count <= 1 && IS_SET(item->GetFlag(), ITEM_FLAG_MAKECOUNT))
|
||||
count = item->GetValue(1);
|
||||
@@ -282,6 +289,9 @@ LPITEM ITEM_MANAGER::CreateItem(DWORD vnum, DWORD count, DWORD id, bool bTryMagi
|
||||
else
|
||||
count = 1;
|
||||
|
||||
if (table->bType != ITEM_ELK && (!count || count > stackLimit)) {
|
||||
M2_DESTROY_ITEM(item); return NULL;
|
||||
}
|
||||
if(!cubeSlot)item->SetVID(++m_dwVIDCount);
|
||||
|
||||
if (bSkipSave == false)
|
||||
@@ -623,7 +633,7 @@ TItemTable * ITEM_MANAGER::GetTable(DWORD vnum)
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1007,7 +1017,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BuyerTheitGloves Item Group
|
||||
{
|
||||
if (pkKiller->GetPremiumRemainSeconds(PREMIUM_ITEM) > 0 ||
|
||||
@@ -1034,7 +1044,7 @@ bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 잡템
|
||||
if (pkChr->GetMobDropItemVnum())
|
||||
{
|
||||
@@ -1615,7 +1625,7 @@ void ITEM_MANAGER::CreateQuestDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller,
|
||||
if ( (item=CreateItem(halloween_item, 1, 0, true)) )
|
||||
vec_item.push_back(item);
|
||||
}
|
||||
|
||||
|
||||
if ( GetDropPerKillPct(100, g_iUseLocale ? 2000 : 800, iDeltaPercent, "ramadan_drop") >= number(1, iRandRange) )
|
||||
{
|
||||
const static DWORD ramadan_item = 30315;
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
#include "cmd.h"
|
||||
#include "refine.h"
|
||||
#include "banword.h"
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
static int optreset;
|
||||
#endif
|
||||
#include "priv_manager.h"
|
||||
#include "war_map.h"
|
||||
#include "building.h"
|
||||
@@ -725,7 +729,7 @@ int start(int argc, char **argv)
|
||||
std::string st_localeServiceName;
|
||||
|
||||
bool bVerbose = false;
|
||||
char ch;
|
||||
int ch;
|
||||
|
||||
//_malloc_options = "A";
|
||||
#if defined(__FreeBSD__) && defined(DEBUG_ALLOC)
|
||||
|
||||
@@ -748,7 +748,7 @@ typedef struct command_item_drop2
|
||||
BYTE header;
|
||||
TItemPos Cell;
|
||||
DWORD gold;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
} TPacketCGItemDrop2;
|
||||
|
||||
typedef struct command_item_move
|
||||
@@ -756,7 +756,7 @@ typedef struct command_item_move
|
||||
BYTE header;
|
||||
TItemPos Cell;
|
||||
TItemPos CellTo;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
} TPacketCGItemMove;
|
||||
|
||||
typedef struct command_item_pickup
|
||||
@@ -816,7 +816,7 @@ typedef struct command_shop_buy
|
||||
typedef struct command_shop_sell
|
||||
{
|
||||
BYTE pos;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
} TPacketCGShopSell;
|
||||
|
||||
typedef struct command_shop
|
||||
@@ -1204,7 +1204,7 @@ struct TPacketGCItemDelDeprecated
|
||||
BYTE header;
|
||||
TItemPos Cell;
|
||||
DWORD vnum;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
};
|
||||
@@ -1214,7 +1214,7 @@ typedef struct packet_item_set
|
||||
BYTE header;
|
||||
TItemPos Cell;
|
||||
DWORD vnum;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
DWORD flags;
|
||||
DWORD anti_flags;
|
||||
bool highlight;
|
||||
@@ -1327,7 +1327,7 @@ typedef struct packet_item_update
|
||||
{
|
||||
BYTE header;
|
||||
TItemPos Cell;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
} TPacketGCItemUpdate;
|
||||
@@ -1414,12 +1414,12 @@ struct packet_shop_item
|
||||
{
|
||||
DWORD vnum;
|
||||
int64_t price;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
BYTE display_pos;
|
||||
int32_t alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
};
|
||||
static_assert(sizeof(packet_shop_item)==47,"gold64 shop item wire size");
|
||||
static_assert(sizeof(packet_shop_item)==48,"gold64 shop item wire size");
|
||||
|
||||
typedef struct packet_shop_start
|
||||
{
|
||||
@@ -2066,7 +2066,7 @@ typedef struct command_give_item
|
||||
BYTE byHeader;
|
||||
DWORD dwTargetVID;
|
||||
TItemPos ItemPos;
|
||||
BYTE byItemCount;
|
||||
WORD byItemCount;
|
||||
} TPacketCGGiveItem;
|
||||
|
||||
typedef struct SPacketCGHack
|
||||
@@ -2318,7 +2318,7 @@ typedef struct pakcet_view_equip
|
||||
DWORD vid;
|
||||
struct {
|
||||
DWORD vnum;
|
||||
BYTE count;
|
||||
WORD count;
|
||||
long alSockets[ITEM_SOCKET_MAX_NUM];
|
||||
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
|
||||
} equips[WEAR_MAX_NUM];
|
||||
@@ -2754,3 +2754,10 @@ static_assert(sizeof(TPacketGCCubeRenewalReceive)==167,"AVA2 GC221 size");
|
||||
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
// PORT mt20261030: actual item quantities are uint16 on the client wire.
|
||||
static_assert(sizeof(TPacketCGItemMove) == 9, "wide item move");
|
||||
static_assert(sizeof(TPacketCGItemDrop2) == 10, "wide item drop");
|
||||
static_assert(sizeof(TPacketCGGiveItem) == 10, "wide give item");
|
||||
static_assert(sizeof(TPacketGCItemSet) == 52, "wide item set");
|
||||
static_assert(sizeof(TPacketGCItemUpdate) == 39, "wide item update");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// PORT: battle pass, game side (port_battlepass.h has the config and state). Protocol: docs/FEATURE-BATTLEPASS.md.
|
||||
// Included once, by cmd_general.cpp; the hooks in other files go through port_battlepass_hooks.h.
|
||||
#include <map>
|
||||
#include "port_material_stack_policy.h"
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -215,7 +216,7 @@ inline const char* PortBpStacks(const std::vector<PortBpReward>& rewards,std::ve
|
||||
if(!table || table->bType==ITEM_DS || !table->bSize || table->bSize>3)return "config";
|
||||
const bool stackable=IS_SET(table->dwFlags,ITEM_FLAG_STACKABLE) && !IS_SET(table->dwAntiFlags,ITEM_ANTIFLAG_STACK);
|
||||
for(unsigned left=r.count;left;) {
|
||||
const unsigned count=stackable?std::min<unsigned>(left,ITEM_MAX_COUNT):1;
|
||||
const unsigned count=stackable?std::min<unsigned>(left,PortMaterialStackPolicy::Limit(table->bType,true,false,r.vnum)):1;
|
||||
stacks.push_back(PortBpStack{r.vnum,count,table->bSize});left-=count;
|
||||
if(stacks.size()>kPortBpMaxStacks)return "config";
|
||||
}
|
||||
|
||||
@@ -179,9 +179,12 @@ void CubeRenewal_Make(LPCHARACTER ch, DWORD index, DWORD count)
|
||||
const CUBE_VALUE& reward = data.reward[0];
|
||||
const bool stackable = FN_cube_renewal_stackable(reward.vnum);
|
||||
|
||||
// One item stack per make: stackable rewards up to ITEM_MAX_COUNT, others one at a time.
|
||||
const auto* rewardProto = ITEM_MANAGER::instance().GetTable(reward.vnum);
|
||||
const unsigned rewardLimit = rewardProto ? PortMaterialStackPolicy::GrantLimit(rewardProto->bType,
|
||||
stackable, false, reward.vnum) : 0;
|
||||
// One item stack per make, using the reward's actual item-level limit.
|
||||
if (count < 1 || reward.count < 1 || (!stackable && count != 1) ||
|
||||
static_cast<int64_t>(reward.count) * count > ITEM_MAX_COUNT)
|
||||
static_cast<int64_t>(reward.count) * count > rewardLimit)
|
||||
{
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't create that many at once."));
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
|
||||
// Revision mt20261030: item-level stack limits.
|
||||
// Include the server fixed-width typedefs before this header.
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include "../../common/length.h"
|
||||
#include "../../common/item_length.h"
|
||||
|
||||
namespace PortMaterialStackPolicy
|
||||
{
|
||||
constexpr unsigned kLegacyLimit = 200;
|
||||
constexpr unsigned kMaterialLimit = 2000;
|
||||
|
||||
inline bool IsMaterialOrConsumable(unsigned type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ITEM_USE: // Includes 71084 / 71085 attribute scrolls.
|
||||
case ITEM_AUTOUSE:
|
||||
case ITEM_MATERIAL:
|
||||
case ITEM_METIN: // Socket stones when marked stackable.
|
||||
case ITEM_RESOURCE:
|
||||
case ITEM_BLEND:
|
||||
case ITEM_EXTRACT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::set<unsigned>& RefineIngredients() { static std::set<unsigned> values; return values; }
|
||||
inline std::set<unsigned>& CubeIngredients() { static std::set<unsigned> values; return values; }
|
||||
|
||||
inline bool QAAllowed(const char* login)
|
||||
{
|
||||
const char* setting = std::getenv("PORT_MATERIAL_STACK_QA_LOGIN");
|
||||
if (!setting || !*setting) return true;
|
||||
const std::string list(setting);
|
||||
for (size_t begin = 0; begin <= list.size();) {
|
||||
const size_t end = list.find(',', begin);
|
||||
if (list.substr(begin, end == std::string::npos ? end : end - begin) == login) return true;
|
||||
if (end == std::string::npos) break;
|
||||
begin = end + 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool LegacyGrowthMode()
|
||||
{
|
||||
const char* setting = std::getenv("PORT_MATERIAL_STACK_LEGACY_MODE");
|
||||
return setting && !std::strcmp(setting, "1");
|
||||
}
|
||||
|
||||
inline unsigned Limit(unsigned type, bool stackable, bool antiStack, unsigned vnum = 0)
|
||||
{
|
||||
// Preserve the historical storage limit even for non-mergeable legacy rows.
|
||||
// Actual creation/merging still enforces the proto's stack flags.
|
||||
if (!stackable || antiStack)
|
||||
return kLegacyLimit;
|
||||
return IsMaterialOrConsumable(type) || RefineIngredients().count(vnum) || CubeIngredients().count(vnum)
|
||||
? kMaterialLimit : kLegacyLimit;
|
||||
}
|
||||
inline unsigned GrantLimit(unsigned type, bool stackable, bool antiStack, unsigned vnum = 0)
|
||||
{
|
||||
return stackable && !antiStack ? Limit(type, true, false, vnum) : 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
// Included after character/item/shop declarations. Both NPC and scroll refinement
|
||||
// consume from the same usable inventory windows as material rewards.
|
||||
inline bool PortRefineTakeMaterials(LPCHARACTER ch, const TRefineTable* recipe)
|
||||
{
|
||||
if (!ch || !recipe) return false;
|
||||
std::map<DWORD, uint64_t> required;
|
||||
for (unsigned i=0; i<recipe->material_count; ++i) {
|
||||
const auto& material=recipe->materials[i];
|
||||
if (!material.vnum || !material.count) return false;
|
||||
required[material.vnum] += uint64_t(material.count);
|
||||
}
|
||||
std::vector<std::pair<LPITEM,DWORD>> deductions;
|
||||
for (const auto& need:required) {
|
||||
uint64_t remaining=need.second;
|
||||
const BYTE windows[]={INVENTORY,
|
||||
#ifdef ENABLE_SPECIAL_STORAGE
|
||||
UPGRADE_INVENTORY,BOOK_INVENTORY,STONE_INVENTORY,CHANGE_INVENTORY,COSTUME_INVENTORY,
|
||||
#endif
|
||||
};
|
||||
for (BYTE window:windows) {
|
||||
const unsigned size=window==INVENTORY?INVENTORY_MAX_NUM:SPECIAL_INVENTORY_MAX_NUM;
|
||||
for (unsigned cell=0; cell<size && remaining; ++cell) {
|
||||
LPITEM item=ch->GetItem(TItemPos(window,cell));
|
||||
if (!item || item->GetCell()!=cell || item->GetVnum()!=need.first ||
|
||||
item->GetOwner()!=ch || item->IsEquipped() || item->IsExchanging() ||
|
||||
item->isLocked() || item->GetSkipSave() ||
|
||||
(ch->GetMyShop() && ch->GetMyShop()->IsSellingItem(item->GetID()))) continue;
|
||||
const DWORD used=static_cast<DWORD>(std::min<uint64_t>(remaining,item->GetCount()));
|
||||
if (used) deductions.emplace_back(item,used);
|
||||
remaining-=used;
|
||||
}
|
||||
}
|
||||
if (remaining) return false; // Nothing has been deducted yet.
|
||||
}
|
||||
for (const auto& debit:deductions)
|
||||
debit.first->SetCount(debit.first->GetCount()-debit.second);
|
||||
return true;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "refine.h"
|
||||
#include "port_material_stack_policy.h"
|
||||
|
||||
CRefineManager::CRefineManager()
|
||||
{
|
||||
@@ -11,10 +12,13 @@ CRefineManager::~CRefineManager()
|
||||
|
||||
bool CRefineManager::Initialize(TRefineTable * table, int size)
|
||||
{
|
||||
PortMaterialStackPolicy::RefineIngredients().clear();
|
||||
for (int i = 0; i < size; ++i, ++table)
|
||||
{
|
||||
sys_log(0, "REFINE %d prob %d cost %d", table->id, table->prob, table->cost);
|
||||
m_map_RefineRecipe.insert(std::make_pair(table->id, *table));
|
||||
for (unsigned j = 0; j < table->material_count; ++j)
|
||||
PortMaterialStackPolicy::RefineIngredients().insert(table->materials[j].vnum);
|
||||
}
|
||||
|
||||
sys_log(0, "REFINE: COUNT %d", m_map_RefineRecipe.size());
|
||||
|
||||
@@ -68,7 +68,7 @@ bool CSafebox::Add(DWORD dwPos, LPITEM pkItem)
|
||||
m_pkGrid->Put(dwPos, 1, pkItem->GetSize());
|
||||
m_pkItems[dwPos] = pkItem;
|
||||
|
||||
TPacketGCItemSet pack;
|
||||
TPacketGCItemSet pack = {};
|
||||
|
||||
pack.header = m_bWindowMode == SAFEBOX ? HEADER_GC_SAFEBOX_SET : HEADER_GC_MALL_SET;
|
||||
pack.Cell = TItemPos(m_bWindowMode, dwPos);
|
||||
@@ -167,7 +167,7 @@ LPITEM CSafebox::GetItem(BYTE bCell)
|
||||
return m_pkItems[bCell];
|
||||
}
|
||||
|
||||
bool CSafebox::MoveItem(BYTE bCell, BYTE bDestCell, BYTE count)
|
||||
bool CSafebox::MoveItem(BYTE bCell, BYTE bDestCell, DWORD count)
|
||||
{
|
||||
LPITEM item;
|
||||
|
||||
@@ -190,7 +190,7 @@ bool CSafebox::MoveItem(BYTE bCell, BYTE bDestCell, BYTE count)
|
||||
|
||||
if ((item2 = GetItem(bDestCell)) && item != item2 && item2->IsStackable() &&
|
||||
!IS_SET(item2->GetAntiFlag(), ITEM_ANTIFLAG_STACK) &&
|
||||
item2->GetVnum() == item->GetVnum()) // 합칠 수 있는 아이템의 경우
|
||||
item2->CanStackWith(item)) // 합칠 수 있는 아이템의 경우
|
||||
{
|
||||
for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
|
||||
if (item2->GetSocket(i) != item->GetSocket(i))
|
||||
@@ -199,9 +199,10 @@ bool CSafebox::MoveItem(BYTE bCell, BYTE bDestCell, BYTE count)
|
||||
if (count == 0)
|
||||
count = item->GetCount();
|
||||
|
||||
count = MIN(200 - item2->GetCount(), count);
|
||||
count = MIN(item2->GetStackRoom(), count);
|
||||
|
||||
if (item->GetCount() >= count)
|
||||
if (count == 0) return false;
|
||||
if (item->GetCount() == count)
|
||||
Remove(bCell);
|
||||
|
||||
item->SetCount(item->GetCount() - count);
|
||||
@@ -213,6 +214,16 @@ bool CSafebox::MoveItem(BYTE bCell, BYTE bDestCell, BYTE count)
|
||||
|
||||
if (!IsEmpty(bDestCell, item->GetSize()))
|
||||
return false;
|
||||
if (count && count < item->GetCount() && item->IsStackable() &&
|
||||
!(item->GetAntiFlag() & ITEM_ANTIFLAG_STACK))
|
||||
{
|
||||
LPITEM split = ITEM_MANAGER::instance().CreateItem(item->GetOriginalVnum(), count);
|
||||
if (!split) return false;
|
||||
if (!item->CopyStackStateTo(split)) { M2_DESTROY_ITEM(split); return false; }
|
||||
if (!Add(bDestCell, split)) { M2_DESTROY_ITEM(split); return false; }
|
||||
item->SetCount(item->GetCount() - count);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pkGrid->Get(bCell, 1, item->GetSize());
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class CSafebox
|
||||
LPITEM Remove(DWORD dwPos);
|
||||
void ChangeSize(int iSize);
|
||||
|
||||
bool MoveItem(BYTE bCell, BYTE bDestCell, BYTE count);
|
||||
bool MoveItem(BYTE bCell, BYTE bDestCell, DWORD count);
|
||||
LPITEM GetItem(BYTE bCell);
|
||||
|
||||
int64_t GetGold() const { return m_lGold; }
|
||||
|
||||
@@ -16,7 +16,7 @@ class CShop
|
||||
{
|
||||
DWORD vnum; // 아이템 번호
|
||||
int64_t price; // 가격
|
||||
BYTE count; // 아이템 개수
|
||||
DWORD count; // 아이템 개수
|
||||
|
||||
LPITEM pkItem;
|
||||
int cheque; // PORT: Won price (PC shops only)
|
||||
|
||||
@@ -260,7 +260,7 @@ void CShopManager::Buy(LPCHARACTER ch, BYTE pos)
|
||||
}
|
||||
}
|
||||
|
||||
void CShopManager::Sell(LPCHARACTER ch, BYTE bCell, BYTE bCount)
|
||||
void CShopManager::Sell(LPCHARACTER ch, BYTE bCell, DWORD bCount)
|
||||
{
|
||||
if (Ava2IsTicketShop(ch->GetShop())) return;
|
||||
if (!ch->GetShop())
|
||||
@@ -302,8 +302,8 @@ void CShopManager::Sell(LPCHARACTER ch, BYTE bCell, BYTE bCount)
|
||||
|
||||
int64_t dwPrice;
|
||||
|
||||
if (bCount == 0 || bCount > item->GetCount())
|
||||
bCount = item->GetCount();
|
||||
if (bCount > item->GetCount()) return;
|
||||
if (bCount == 0) bCount = item->GetCount();
|
||||
|
||||
dwPrice = item->GetShopBuyPrice();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
void StopShopping(LPCHARACTER ch);
|
||||
|
||||
void Buy(LPCHARACTER ch, BYTE pos);
|
||||
void Sell(LPCHARACTER ch, BYTE bCell, BYTE bCount=0);
|
||||
void Sell(LPCHARACTER ch, BYTE bCell, DWORD bCount=0);
|
||||
|
||||
LPSHOP CreatePCShop(LPCHARACTER ch, TShopItemTable * pTable, BYTE bItemCount, const int32_t * pCheque = NULL);
|
||||
LPSHOP FindPCShop(DWORD dwVID);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "../../common/service.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <math.h>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CXX = clang++-devel
|
||||
CXX ?= clang++-devel
|
||||
BIN_DIR = ../lib
|
||||
BIN = $(BIN_DIR)/libgame.a
|
||||
|
||||
CFLAGS = -Wall -O2 -pipe -mtune=i686 -fno-exceptions -I../include
|
||||
CFLAGS ?= -Wall -O2 -pipe -fno-exceptions -I../include
|
||||
|
||||
LIBS =
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
CXX = clang++-devel
|
||||
CXX ?= clang++-devel
|
||||
BIN = ./libpoly.a
|
||||
|
||||
GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
|
||||
|
||||
CFLAGS = -Wall -O2 -pipe -mtune=i686 -D_GLIBCXX_USE_CXX11_ABI=1 -fno-exceptions -fno-rtti
|
||||
CFLAGS ?= -Wall -O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=1 -fno-exceptions -fno-rtti
|
||||
|
||||
LIBS =
|
||||
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
#CXX = distcc i386-obrien-freebsd5-g++
|
||||
CXX = clang++-devel
|
||||
|
||||
PLATFORM = $(shell file /bin/ls | cut -d' ' -f3 | cut -d'-' -f1)
|
||||
|
||||
GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
|
||||
BSD_VERSION = $(shell uname -v 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)
|
||||
SVN_VERSION = $(shell svnversion -n -c . | cut -d':' -f2)
|
||||
CXX ?= clang++-devel
|
||||
|
||||
BIN = ./libserverkey.a
|
||||
|
||||
# ifeq ($(GCC_VERSION), 4)
|
||||
IFLAGS =
|
||||
CFLAGS = $(IFLAGS) -Wall -O2 -pipe -m32 -std=c++2b -D_THREAD_SAFE -fno-exceptions
|
||||
# else
|
||||
# IFLAGS =
|
||||
# CFLAGS = $(IFLAGS) -Wall -O2 -pipe -mcpu=i686 -D_THREAD_SAFE -fno-exceptions
|
||||
# endif
|
||||
CFLAGS ?= $(IFLAGS) -Wall -O2 -pipe -std=c++2b -D_THREAD_SAFE -fno-exceptions
|
||||
|
||||
LIBS =
|
||||
|
||||
@@ -37,7 +25,7 @@ dep:
|
||||
touch Depend
|
||||
$(CXX) $(CFLAGS) -MM *.cpp > Depend
|
||||
|
||||
$(OBJFILES):
|
||||
$(CXX) $(CFLAGS) -c $<
|
||||
%.o: %.cpp
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
sinclude Depend
|
||||
|
||||
@@ -143,12 +143,12 @@ bool CAsyncSQL::Connect()
|
||||
if (0 != mysql_options(&m_hDB, MYSQL_OPT_RECONNECT, &reconnect))
|
||||
fprintf(stderr, "mysql_option: %s\n", mysql_error(&m_hDB));
|
||||
|
||||
fprintf(stdout, "AsyncSQL: connected to %s (reconnect %d)\n", m_stHost.c_str(), m_hDB.reconnect);
|
||||
fprintf(stdout, "AsyncSQL: connected to %s (reconnect %d)\n", m_stHost.c_str(), (int) reconnect);
|
||||
|
||||
// db cache는 common db의 LOCALE 테이블에서 locale을 알아오고, 이후 character set을 수정한다.
|
||||
// 따라서 최초 Connection을 맺을 때에는 locale을 모르기 때문에 character set을 정할 수가 없음에도 불구하고,
|
||||
// 강제로 character set을 euckr로 정하도록 되어있어 이 부분을 주석처리 하였다.
|
||||
// (아래 주석을 풀면 mysql에 euckr이 안 깔려있는 디비에 접근할 수가 없다.)
|
||||
// db cache는 common db의 LOCALE 테이블에서 locale을 알아오고, 이후 character set을 수정한다.
|
||||
// 따라서 최초 Connection을 맺을 때에는 locale을 모르기 때문에 character set을 정할 수가 없음에도 불구하고,
|
||||
// 강제로 character set을 euckr로 정하도록 되어있어 이 부분을 주석처리 하였다.
|
||||
// (아래 주석을 풀면 mysql에 euckr이 안 깔려있는 디비에 접근할 수가 없다.)
|
||||
//while (!QueryLocaleSet());
|
||||
m_ulThreadID = mysql_thread_id(&m_hDB);
|
||||
|
||||
@@ -236,7 +236,7 @@ void CAsyncSQL::Quit()
|
||||
if (m_hThread)
|
||||
{
|
||||
pthread_join(m_hThread, NULL);
|
||||
m_hThread = NULL;
|
||||
m_hThread = 0;
|
||||
}
|
||||
#else
|
||||
if (m_hThread != INVALID_HANDLE_VALUE) {
|
||||
@@ -530,7 +530,7 @@ class cProfiler
|
||||
|
||||
void CAsyncSQL::ChildLoop()
|
||||
{
|
||||
cProfiler profiler(500000); // 0.5초
|
||||
cProfiler profiler(500000); // 0.5초
|
||||
|
||||
while (!m_bEnd)
|
||||
{
|
||||
@@ -547,7 +547,7 @@ void CAsyncSQL::ChildLoop()
|
||||
|
||||
while (count--)
|
||||
{
|
||||
//시간 체크 시작
|
||||
//시간 체크 시작
|
||||
profiler.Start();
|
||||
|
||||
if (!PeekQueryFromCopyQueue(&p))
|
||||
@@ -593,7 +593,7 @@ void CAsyncSQL::ChildLoop()
|
||||
|
||||
profiler.Stop();
|
||||
|
||||
// 0.5초 이상 걸렸으면 로그에 남기기
|
||||
// 0.5초 이상 걸렸으면 로그에 남기기
|
||||
if (!profiler.IsOk())
|
||||
sys_log(0, "[QUERY : LONG INTERVAL(OverSec %ld.%ld)] : %s",
|
||||
profiler.GetResultSec(), profiler.GetResultUSec(), p->stQuery.c_str());
|
||||
@@ -696,9 +696,9 @@ size_t CAsyncSQL::EscapeString(char* dst, size_t dstSize, const char *src, size_
|
||||
|
||||
if (dstSize < srcSize * 2 + 1)
|
||||
{
|
||||
// \0이 안붙어있을 때를 대비해서 256 바이트만 복사해서 로그로 출력
|
||||
// \0이 안붙어있을 때를 대비해서 256 바이트만 복사해서 로그로 출력
|
||||
char tmp[256];
|
||||
size_t tmpLen = sizeof(tmp) > srcSize ? srcSize : sizeof(tmp); // 둘 중에 작은 크기
|
||||
size_t tmpLen = sizeof(tmp) > srcSize ? srcSize : sizeof(tmp); // 둘 중에 작은 크기
|
||||
strlcpy(tmp, src, tmpLen);
|
||||
|
||||
sys_err("FATAL ERROR!! not enough buffer size (dstSize %u srcSize %u src%s: %s)",
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
#CXX = distcc i386-obrien-freebsd5-g++
|
||||
CXX = clang++-devel
|
||||
|
||||
PLATFORM = $(shell file /bin/ls | cut -d' ' -f3 | cut -d'-' -f1)
|
||||
|
||||
GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
|
||||
BSD_VERSION = $(shell uname -v 2>&1 | cut -d' ' -f2 | cut -d'.' -f1)
|
||||
SVN_VERSION = $(shell svnversion -n -c . | cut -d':' -f2)
|
||||
CXX ?= clang++-devel
|
||||
|
||||
BIN = ./libsql.a
|
||||
|
||||
IFLAGS = -I/usr/local/include
|
||||
CFLAGS = $(IFLAGS) -Wall -O2 -pipe -mtune=i686 -D_GLIBCXX_USE_CXX11_ABI=1 -D_THREAD_SAFE -fno-exceptions
|
||||
IFLAGS = -I/usr/local/include -I/usr/include/mariadb -I/usr/include/mysql
|
||||
CFLAGS ?= $(IFLAGS) -Wall -O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=1 -D_THREAD_SAFE -fno-exceptions
|
||||
|
||||
LIBS =
|
||||
|
||||
@@ -32,7 +25,7 @@ dep:
|
||||
touch Depend
|
||||
$(CXX) $(CFLAGS) -MM *.cpp > Depend
|
||||
|
||||
$(OBJFILES):
|
||||
$(CXX) $(CFLAGS) -c $<
|
||||
%.o: %.cpp
|
||||
$(CXX) $(CFLAGS) -c $< -o $@
|
||||
|
||||
sinclude Depend
|
||||
|
||||
@@ -1,7 +1,33 @@
|
||||
#ifndef __INC_LIBTHECORE_FDWATCH_H__
|
||||
#define __INC_LIBTHECORE_FDWATCH_H__
|
||||
|
||||
#ifndef __WIN32__
|
||||
#if defined(__linux__)
|
||||
|
||||
#include <sys/epoll.h>
|
||||
|
||||
typedef struct fdwatch FDWATCH;
|
||||
typedef struct fdwatch * LPFDWATCH;
|
||||
|
||||
enum EFdwatch
|
||||
{
|
||||
FDW_NONE = 0,
|
||||
FDW_READ = 1,
|
||||
FDW_WRITE = 2,
|
||||
FDW_WRITE_ONESHOT = 4,
|
||||
FDW_EOF = 8,
|
||||
};
|
||||
|
||||
struct fdwatch
|
||||
{
|
||||
int epfd;
|
||||
int nfiles;
|
||||
struct epoll_event * events;
|
||||
int nevents;
|
||||
void ** fd_data;
|
||||
int * fd_rw;
|
||||
};
|
||||
|
||||
#elif !defined(__WIN32__)
|
||||
|
||||
typedef struct fdwatch FDWATCH;
|
||||
typedef struct fdwatch * LPFDWATCH;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef __INC_LIBTHECORE_SIGNAL_H__
|
||||
#define __INC_LIBTHECORE_SIGNAL_H__
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#include_next <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ inline double rint(double x)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
#if !defined(__FreeBSD__) && !defined(__linux__)
|
||||
#define __USE_SELECT__
|
||||
#ifdef __CYGWIN__
|
||||
#define _POSIX_SOURCE 1
|
||||
@@ -106,6 +106,7 @@ inline double rint(double x)
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
@@ -114,14 +115,18 @@ inline double rint(double x)
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/event.h>
|
||||
#elif defined(__linux__)
|
||||
#include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#define true (!false)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE false
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
CC = clang++-devel
|
||||
CC ?= clang++-devel
|
||||
BIN_DIR = ../lib
|
||||
BIN = $(BIN_DIR)/libthecore.a
|
||||
INCLUDE = ../include
|
||||
|
||||
GCC_VERSION = $(shell $(CC) --version 2>&1 | grep "(GCC)" | cut -d' ' -f3 | cut -d'.' -f1)
|
||||
|
||||
ifeq ($(GCC_VERSION), 4)
|
||||
CFLAGS = -Wall -O2 -pipe -mtune=i686 -g -I$(INCLUDE)
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(UNAME_M), x86_64)
|
||||
ARCH_FLAGS = -m32 -mtune=i686
|
||||
else ifeq ($(UNAME_M), i386)
|
||||
ARCH_FLAGS = -mtune=i686
|
||||
else ifeq ($(UNAME_M), i686)
|
||||
ARCH_FLAGS = -mtune=i686
|
||||
else
|
||||
CFLAGS = -Wall -O2 -pipe -mtune=i686 -g -I$(INCLUDE)
|
||||
ARCH_FLAGS =
|
||||
endif
|
||||
|
||||
CFLAGS ?= -Wall -O2 -pipe $(ARCH_FLAGS) -g -I$(INCLUDE) -Wno-deprecated-declarations -Wno-format-security
|
||||
|
||||
LIBS =
|
||||
|
||||
OBJFILES = socket.o fdwatch.o buffer.o signal.o log.o utils.o \
|
||||
kstbl.o hangul.o heart.o main.o tea.o des.o gost.o memcpy.o
|
||||
kstbl.o hangul.o heart.o main.o tea.o des.o gost.o memcpy.o xmd5.o
|
||||
|
||||
default:
|
||||
$(MAKE) $(BIN)
|
||||
|
||||
@@ -1,7 +1,182 @@
|
||||
#define __LIBTHECORE__
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef __USE_SELECT__
|
||||
#if defined(__linux__)
|
||||
|
||||
LPFDWATCH fdwatch_new(int nfiles)
|
||||
{
|
||||
LPFDWATCH fdw;
|
||||
int epfd = epoll_create1(EPOLL_CLOEXEC);
|
||||
if (epfd == -1)
|
||||
{
|
||||
sys_err("epoll_create1 failed: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CREATE(fdw, FDWATCH, 1);
|
||||
fdw->epfd = epfd;
|
||||
fdw->nfiles = nfiles;
|
||||
fdw->nevents = 0;
|
||||
CREATE(fdw->events, struct epoll_event, nfiles * 2);
|
||||
CREATE(fdw->fd_rw, int, nfiles);
|
||||
CREATE(fdw->fd_data, void*, nfiles);
|
||||
return fdw;
|
||||
}
|
||||
|
||||
void fdwatch_delete(LPFDWATCH fdw)
|
||||
{
|
||||
if (!fdw) return;
|
||||
if (fdw->epfd >= 0) close(fdw->epfd);
|
||||
if (fdw->events) free(fdw->events);
|
||||
if (fdw->fd_rw) free(fdw->fd_rw);
|
||||
if (fdw->fd_data) free(fdw->fd_data);
|
||||
free(fdw);
|
||||
}
|
||||
|
||||
void fdwatch_clear_fd(LPFDWATCH fdw, socket_t fd)
|
||||
{
|
||||
if (fd >= 0 && fd < fdw->nfiles)
|
||||
{
|
||||
fdw->fd_data[fd] = NULL;
|
||||
fdw->fd_rw[fd] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void fdwatch_add_fd(LPFDWATCH fdw, socket_t fd, void * client_data, int rw, int oneshot)
|
||||
{
|
||||
if (fd < 0 || fd >= fdw->nfiles)
|
||||
{
|
||||
sys_err("fd overflow %d (max %d)", fd, fdw->nfiles);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fdw->fd_rw[fd] & rw)
|
||||
return;
|
||||
|
||||
int old_rw = fdw->fd_rw[fd];
|
||||
fdw->fd_rw[fd] |= rw;
|
||||
if (oneshot)
|
||||
fdw->fd_rw[fd] |= FDW_WRITE_ONESHOT;
|
||||
|
||||
fdw->fd_data[fd] = client_data;
|
||||
|
||||
struct epoll_event ev;
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.data.fd = fd;
|
||||
|
||||
if (fdw->fd_rw[fd] & FDW_READ)
|
||||
ev.events |= EPOLLIN;
|
||||
if (fdw->fd_rw[fd] & FDW_WRITE)
|
||||
ev.events |= EPOLLOUT;
|
||||
|
||||
int op = (old_rw == 0) ? EPOLL_CTL_ADD : EPOLL_CTL_MOD;
|
||||
if (epoll_ctl(fdw->epfd, op, fd, &ev) < 0)
|
||||
{
|
||||
if (op == EPOLL_CTL_ADD && errno == EEXIST)
|
||||
epoll_ctl(fdw->epfd, EPOLL_CTL_MOD, fd, &ev);
|
||||
else if (op == EPOLL_CTL_MOD && errno == ENOENT)
|
||||
epoll_ctl(fdw->epfd, EPOLL_CTL_ADD, fd, &ev);
|
||||
else
|
||||
sys_err("epoll_ctl failed for fd %d: %s", fd, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
void fdwatch_del_fd(LPFDWATCH fdw, socket_t fd)
|
||||
{
|
||||
if (fd >= 0 && fd < fdw->nfiles)
|
||||
{
|
||||
epoll_ctl(fdw->epfd, EPOLL_CTL_DEL, fd, NULL);
|
||||
fdwatch_clear_fd(fdw, fd);
|
||||
}
|
||||
}
|
||||
|
||||
int fdwatch(LPFDWATCH fdw, struct timeval *timeout)
|
||||
{
|
||||
int to_ms = -1;
|
||||
if (timeout)
|
||||
to_ms = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
|
||||
|
||||
int r = epoll_wait(fdw->epfd, fdw->events, fdw->nfiles * 2, to_ms);
|
||||
if (r < 0)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fdw->nevents = r;
|
||||
return r;
|
||||
}
|
||||
|
||||
void * fdwatch_get_client_data(LPFDWATCH fdw, unsigned int event_idx)
|
||||
{
|
||||
if ((int)event_idx >= fdw->nevents)
|
||||
return NULL;
|
||||
int fd = fdw->events[event_idx].data.fd;
|
||||
if (fd < 0 || fd >= fdw->nfiles)
|
||||
return NULL;
|
||||
return fdw->fd_data[fd];
|
||||
}
|
||||
|
||||
int fdwatch_get_ident(LPFDWATCH fdw, unsigned int event_idx)
|
||||
{
|
||||
if ((int)event_idx >= fdw->nevents)
|
||||
return -1;
|
||||
return fdw->events[event_idx].data.fd;
|
||||
}
|
||||
|
||||
void fdwatch_clear_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx)
|
||||
{
|
||||
if ((int)event_idx >= fdw->nevents)
|
||||
return;
|
||||
if (fdw->events[event_idx].data.fd == fd)
|
||||
{
|
||||
fdw->events[event_idx].data.fd = -1;
|
||||
fdw->events[event_idx].events = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int fdwatch_check_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx)
|
||||
{
|
||||
if ((int)event_idx >= fdw->nevents)
|
||||
return 0;
|
||||
if (fdw->events[event_idx].data.fd != fd)
|
||||
return 0;
|
||||
|
||||
uint32_t ev = fdw->events[event_idx].events;
|
||||
if (ev & (EPOLLERR | EPOLLHUP | EPOLLRDHUP))
|
||||
return FDW_EOF;
|
||||
|
||||
if ((ev & EPOLLIN) && (fdw->fd_rw[fd] & FDW_READ))
|
||||
return FDW_READ;
|
||||
|
||||
if ((ev & EPOLLOUT) && (fdw->fd_rw[fd] & FDW_WRITE))
|
||||
{
|
||||
if (fdw->fd_rw[fd] & FDW_WRITE_ONESHOT)
|
||||
{
|
||||
fdw->fd_rw[fd] &= ~FDW_WRITE;
|
||||
struct epoll_event mod_ev;
|
||||
memset(&mod_ev, 0, sizeof(mod_ev));
|
||||
mod_ev.data.fd = fd;
|
||||
if (fdw->fd_rw[fd] & FDW_READ)
|
||||
mod_ev.events |= EPOLLIN;
|
||||
if (fdw->fd_rw[fd] == 0)
|
||||
epoll_ctl(fdw->epfd, EPOLL_CTL_DEL, fd, NULL);
|
||||
else
|
||||
epoll_ctl(fdw->epfd, EPOLL_CTL_MOD, fd, &mod_ev);
|
||||
}
|
||||
return FDW_WRITE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fdwatch_get_buffer_size(LPFDWATCH fdw, socket_t fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif !defined(__USE_SELECT__)
|
||||
|
||||
LPFDWATCH fdwatch_new(int nfiles)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Filename: main.c
|
||||
* Description: 라이브러리 초기화/삭제 등
|
||||
* Description: 라이브러리 초기화/삭제 등
|
||||
*
|
||||
* Author: 비엽 aka. Cronan
|
||||
* Author: 비엽 aka. Cronan
|
||||
*/
|
||||
#define __LIBTHECORE__
|
||||
#include "stdafx.h"
|
||||
@@ -54,7 +54,9 @@ int thecore_init(int fps, HEARTFUNC heartbeat_func)
|
||||
srand(time(0));
|
||||
#else
|
||||
srandom(time(0) + getpid() + getuid());
|
||||
#ifdef __FreeBSD__
|
||||
srandomdev();
|
||||
#endif
|
||||
#endif
|
||||
signal_setup();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
void signal_setup() {}
|
||||
void signal_timer_disable() {}
|
||||
void signal_timer_enable(int timeout_seconds) {}
|
||||
#elif __FreeBSD__
|
||||
#elif defined(__FreeBSD__) || defined(__linux__)
|
||||
#define RETSIGTYPE void
|
||||
|
||||
RETSIGTYPE reap(int sig)
|
||||
|
||||
Reference in New Issue
Block a user