Merge pull request #5 from mq1n/main
fix build issues on FreeBSD and Github actions workflow
This commit is contained in:
35
.github/workflows/main.yml
vendored
Normal file
35
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
bsd:
|
||||
runs-on: ubuntu-latest
|
||||
name: Main build job
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: FreeBSD job
|
||||
id: test
|
||||
uses: vmactions/freebsd-vm@v1
|
||||
with:
|
||||
usesh: true
|
||||
sync: sshfs
|
||||
prepare: |
|
||||
pkg install -y git cmake gmake
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
gmake all -j6
|
||||
- name: Collect outputs
|
||||
run: |
|
||||
mkdir _output
|
||||
cp build/bin/* _output
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: output_bsd
|
||||
path: _output
|
||||
@@ -36,6 +36,34 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
# Derive a version string from git for the db target
|
||||
find_package(Git QUIET)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_SOURCE_DIR} describe --always --dirty --tags
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT GIT_DESCRIBE_VERSION)
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_SOURCE_DIR} rev-parse --short HEAD
|
||||
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
else()
|
||||
set(GIT_DESCRIBE_VERSION "unknown")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT GIT_DESCRIBE_VERSION)
|
||||
set(GIT_DESCRIBE_VERSION "unknown")
|
||||
endif()
|
||||
|
||||
add_definitions(-DNOMINMAX)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
add_executable(db ${DB_SOURCES})
|
||||
|
||||
target_compile_definitions(db PRIVATE GIT_DESCRIBE="${GIT_DESCRIBE_VERSION}")
|
||||
|
||||
target_link_libraries(db
|
||||
common
|
||||
libgame
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef GIT_DESCRIBE
|
||||
#define GIT_DESCRIBE "unknown"
|
||||
#endif
|
||||
|
||||
void WriteVersion()
|
||||
{
|
||||
#ifndef OS_WINDOWS
|
||||
@@ -8,7 +12,7 @@ void WriteVersion()
|
||||
|
||||
if (NULL != fp)
|
||||
{
|
||||
fprintf(fp, "db revision: %s\n", __P4_VERSION__);
|
||||
fprintf(fp, "db revision: %s\n", GIT_DESCRIBE);
|
||||
//fprintf(fp, "%s@%s:%s\n", __USER__, __HOSTNAME__, __PWD__);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
add_executable(game ${GAME_SOURCES})
|
||||
|
||||
target_compile_definitions(game PRIVATE GIT_DESCRIBE="${GIT_DESCRIBE_VERSION}")
|
||||
|
||||
target_link_libraries(game
|
||||
common
|
||||
libgame
|
||||
|
||||
@@ -76,11 +76,9 @@ bool CArenaManager::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD st
|
||||
|
||||
bool CArenaMap::AddArena(DWORD mapIdx, WORD startA_X, WORD startA_Y, WORD startB_X, WORD startB_Y)
|
||||
{
|
||||
itertype(m_listArena) iter = m_listArena.begin();
|
||||
|
||||
for (; iter != m_listArena.end(); iter++)
|
||||
for (const auto& arena : m_listArena)
|
||||
{
|
||||
if ((CArena*)(*iter)->CheckArea(startA_X, startA_Y, startB_X, startB_Y) == false)
|
||||
if (arena->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;
|
||||
|
||||
@@ -13,11 +13,7 @@
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef OS_FREEBSD
|
||||
#include <md5.h>
|
||||
#else
|
||||
#include "libthecore/xmd5.h"
|
||||
#endif
|
||||
|
||||
#include "auth_brazil.h"
|
||||
|
||||
|
||||
@@ -6010,13 +6010,13 @@ void CHARACTER::EffectPacket(int enumEffectType)
|
||||
PacketAround(&p, sizeof(TPacketGCSpecialEffect));
|
||||
}
|
||||
|
||||
void CHARACTER::SpecificEffectPacket(const char filename[MAX_EFFECT_FILE_NAME])
|
||||
void CHARACTER::SpecificEffectPacket(const std::string& stEffectName)
|
||||
{
|
||||
TPacketGCSpecificEffect p;
|
||||
|
||||
p.header = HEADER_GC_SPECIFIC_EFFECT;
|
||||
p.vid = GetVID();
|
||||
memcpy (p.effect_file, filename, MAX_EFFECT_FILE_NAME);
|
||||
strlcpy(p.effect_file, stEffectName.c_str(), sizeof(p.effect_file));
|
||||
|
||||
PacketAround(&p, sizeof(TPacketGCSpecificEffect));
|
||||
}
|
||||
|
||||
@@ -1091,7 +1091,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
|
||||
|
||||
// void PotionPacket(int iPotionType);
|
||||
void EffectPacket(int enumEffectType);
|
||||
void SpecificEffectPacket(const char filename[128]);
|
||||
void SpecificEffectPacket(const std::string& stEffectName);
|
||||
|
||||
// ADD_MONSTER_REFINE
|
||||
bool DoRefine(LPITEM item, bool bMoneyOnly = false);
|
||||
|
||||
@@ -3195,7 +3195,7 @@ LPCHARACTER CHARACTER::GetNearestVictim(LPCHARACTER pkChr)
|
||||
|
||||
LPCHARACTER pAttacker = CHARACTER_MANAGER::instance().Find(c_VID);
|
||||
|
||||
if (!pAttacker)
|
||||
if (!pAttacker || pAttacker->IsDead())
|
||||
continue;
|
||||
|
||||
if (pAttacker->IsAffectFlag(AFF_EUNHYUNG) ||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#ifdef OS_FREEBSD
|
||||
#include <md5.h>
|
||||
#else
|
||||
#include "libthecore/xmd5.h"
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
|
||||
@@ -4082,28 +4082,28 @@ ACMD (do_item_full_set)
|
||||
{
|
||||
|
||||
item = ITEM_MANAGER::instance().CreateItem(11699);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(13049);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(15189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(12529 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(14109 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(17209 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(16209 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
}
|
||||
break;
|
||||
@@ -4111,28 +4111,28 @@ ACMD (do_item_full_set)
|
||||
{
|
||||
|
||||
item = ITEM_MANAGER::instance().CreateItem(11299);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(13049);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(15189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(3159 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(12249 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(14109 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(17109 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(16109 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
}
|
||||
break;
|
||||
@@ -4140,28 +4140,28 @@ ACMD (do_item_full_set)
|
||||
{
|
||||
|
||||
item = ITEM_MANAGER::instance().CreateItem(11899);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(13049);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(15189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(7159 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(12669 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(14109 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(17209 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(16209 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
}
|
||||
break;
|
||||
@@ -4169,31 +4169,35 @@ ACMD (do_item_full_set)
|
||||
{
|
||||
|
||||
item = ITEM_MANAGER::instance().CreateItem(11499);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(13049);
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(15189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(1139 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(12389 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(14109 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(17189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
item = ITEM_MANAGER::instance().CreateItem(16189 );
|
||||
if (!item || !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
if (item && !item->EquipTo(ch, item->FindEquipCell(ch)))
|
||||
M2_DESTROY_ITEM(item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ch->ChatPacket(CHAT_TYPE_INFO, "Full set is not available for your job");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ bool DESC::Setup(LPFDWATCH _fdw, socket_t _fd, const struct sockaddr_in & c_rSoc
|
||||
// m_lpOutputBuffer = buffer_new(DEFAULT_PACKET_BUFFER_SIZE * 2);
|
||||
//else
|
||||
//NOTE: 이걸 나라별로 다르게 잡아야할 이유가 있나?
|
||||
m_lpOutputBuffer = buffer_new(DEFAULT_PACKET_BUFFER_SIZE * 2);
|
||||
m_lpOutputBuffer = buffer_new(DEFAULT_PACKET_BUFFER_SIZE * 3); // Default: 2
|
||||
|
||||
m_iMinInputBufferLen = MAX_INPUT_LEN >> 1;
|
||||
m_lpInputBuffer = buffer_new(MAX_INPUT_LEN);
|
||||
@@ -418,6 +418,12 @@ void DESC::BufferedPacket(const void * c_pvData, int iSize)
|
||||
if (!m_lpBufferedOutputBuffer)
|
||||
m_lpBufferedOutputBuffer = buffer_new(MAX(1024, iSize));
|
||||
|
||||
#ifdef _DEBUG
|
||||
const std::string stName = GetCharacter() ? GetCharacter()->GetName() : GetHostName();
|
||||
const auto kHeader = *(static_cast<const uint8_t*>(c_pvData));
|
||||
sys_log(0, "[B] SENT HEADER : %u(0x%X) to %s (size %d) ", kHeader, kHeader, stName.c_str(), iSize);
|
||||
#endif
|
||||
|
||||
buffer_write(m_lpBufferedOutputBuffer, c_pvData, iSize);
|
||||
}
|
||||
|
||||
@@ -428,6 +434,19 @@ void DESC::Packet(const void * c_pvData, int iSize)
|
||||
if (m_iPhase == PHASE_CLOSE) // 끊는 상태면 보내지 않는다.
|
||||
return;
|
||||
|
||||
if (!m_lpOutputBuffer)
|
||||
{
|
||||
sys_err("DESC::Packet: Trying to send packet but output buffer is NULL! (DESC: %p)", this);
|
||||
SetPhase(PHASE_CLOSE);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
const std::string stName = GetCharacter() ? GetCharacter()->GetName() : GetHostName();
|
||||
const auto kHeader = *(static_cast<const uint8_t*>(c_pvData));
|
||||
sys_log(0, "[N] SENT HEADER : %u(0x%X) to %s (size %d) ", kHeader, kHeader, stName.c_str(), iSize);
|
||||
#endif
|
||||
|
||||
if (m_stRelayName.length() != 0)
|
||||
{
|
||||
// Relay 패킷은 암호화하지 않는다.
|
||||
|
||||
@@ -111,6 +111,7 @@ class DESC
|
||||
LPCHARACTER GetCharacter() { return m_lpCharacter; }
|
||||
|
||||
bool IsPhase(int phase) const { return m_iPhase == phase ? true : false; }
|
||||
int32_t GetPhase() const { return m_iPhase; }
|
||||
|
||||
const struct sockaddr_in & GetAddr() { return m_SockAddr; }
|
||||
|
||||
|
||||
@@ -2013,13 +2013,13 @@ void CGuild::Invite( LPCHARACTER pchInviter, LPCHARACTER pchInvitee )
|
||||
|
||||
TPacketGCGuild p;
|
||||
p.header = HEADER_GC_GUILD;
|
||||
p.size = sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN + 1;
|
||||
p.size = sizeof(p) + sizeof(DWORD) + GUILD_NAME_MAX_LEN;
|
||||
p.subheader = GUILD_SUBHEADER_GC_GUILD_INVITE;
|
||||
|
||||
TEMP_BUFFER buf;
|
||||
buf.write( &p, sizeof(p) );
|
||||
buf.write( &gid, sizeof(DWORD) );
|
||||
buf.write( GetName(), GUILD_NAME_MAX_LEN + 1 );
|
||||
buf.write( GetName(), GUILD_NAME_MAX_LEN );
|
||||
|
||||
pchInvitee->GetDesc()->Packet( buf.read_peek(), buf.size() );
|
||||
}
|
||||
|
||||
@@ -81,14 +81,33 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes,
|
||||
iPacketLen = 1;
|
||||
else if (!m_pPacketInfo->Get(bHeader, &iPacketLen, &c_pszName))
|
||||
{
|
||||
sys_err("UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, fd: %d",
|
||||
bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, lpDesc->GetSocket());
|
||||
//printdata((BYTE *) c_pvOrig, m_iBufferLeft);
|
||||
LPCHARACTER ch = lpDesc->GetCharacter();
|
||||
|
||||
char szLogBuffer[1024];
|
||||
snprintf(szLogBuffer, sizeof(szLogBuffer),
|
||||
"UNKNOWN HEADER: %u(0x%X) LAST HEADER: %u(0x%X)[%u], REMAIN BYTES: %d, CHAR: %s, PHASE: %d, fd: %d host: %s",
|
||||
bHeader, bHeader, bLastHeader, bLastHeader, iLastPacketLen, m_iBufferLeft,
|
||||
ch ? ch->GetName() : "<none>",
|
||||
lpDesc->GetPhase(), lpDesc->GetSocket(), lpDesc->GetHostName()
|
||||
);
|
||||
|
||||
if (lpDesc->GetPhase() < PHASE_SELECT) // early phase
|
||||
sys_log(0, szLogBuffer);
|
||||
else
|
||||
sys_err(szLogBuffer);
|
||||
|
||||
#if defined(_DEBUG) && defined(_WIN32)
|
||||
printdata((uint8_t*)c_pvOrig, m_iBufferLeft);
|
||||
#endif
|
||||
lpDesc->SetPhase(PHASE_CLOSE);
|
||||
return true;
|
||||
}
|
||||
|
||||
sys_log(0, "PACKET %d (%s)", bHeader, c_pszName);
|
||||
#ifdef _DEBUG
|
||||
const auto ch = lpDesc->GetCharacter();
|
||||
const std::string stName = ch ? ch->GetName() : lpDesc->GetHostName();
|
||||
sys_log(0, "RECEIVED HEADER : %u(0x%X) to %s (size %d) ", bHeader, bHeader, stName.c_str(), iBytes);
|
||||
#endif
|
||||
|
||||
if (m_iBufferLeft < iPacketLen)
|
||||
return true;
|
||||
@@ -103,7 +122,14 @@ bool CInputProcessor::Process(LPDESC lpDesc, const void * c_pvOrig, int iBytes,
|
||||
int iExtraPacketSize = Analyze(lpDesc, bHeader, c_pData);
|
||||
|
||||
if (iExtraPacketSize < 0)
|
||||
{
|
||||
LPCHARACTER ch = lpDesc->GetCharacter();
|
||||
sys_err("Failed to analyze header(%u) size: %d phase: %d host %s from %s (%u) in: %u",
|
||||
bHeader, iPacketLen, lpDesc->GetPhase(), lpDesc->GetHostName(),
|
||||
ch ? ch->GetName() : "NO_CHAR", ch ? ch->GetPlayerID() : 0, ch ? ch->GetMapIndex() : 0
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
iPacketLen += iExtraPacketSize;
|
||||
lpDesc->Log("%s %d", c_pszName, iPacketLen);
|
||||
|
||||
@@ -469,21 +469,31 @@ void ITEM_MANAGER::SaveSingleItem(LPITEM item)
|
||||
|
||||
void ITEM_MANAGER::Update()
|
||||
{
|
||||
std::unordered_set<LPITEM>::iterator it = m_set_pkItemForDelayedSave.begin();
|
||||
std::unordered_set<LPITEM>::iterator this_it;
|
||||
|
||||
while (it != m_set_pkItemForDelayedSave.end())
|
||||
for (auto it = m_set_pkItemForDelayedSave.begin(); it != m_set_pkItemForDelayedSave.end();)
|
||||
{
|
||||
this_it = it++;
|
||||
LPITEM item = *this_it;
|
||||
|
||||
// SLOW_QUERY 플래그가 있는 것은 종료시에만 저장한다.
|
||||
if (item->GetOwner() && IS_SET(item->GetFlag(), ITEM_FLAG_SLOW_QUERY))
|
||||
LPITEM item = *it;
|
||||
if (!item)
|
||||
{
|
||||
sys_err("nullptr item, erasing from delayed save.");
|
||||
it = m_set_pkItemForDelayedSave.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!FindByVID(item->GetVID()))
|
||||
{
|
||||
sys_err("Invalid item(%u), erasing from delayed save.", item->GetVID());
|
||||
it = m_set_pkItemForDelayedSave.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item->GetOwner() && IS_SET(item->GetFlag(), ITEM_FLAG_SLOW_QUERY))
|
||||
{
|
||||
++it; // just skip don't erase
|
||||
continue;
|
||||
}
|
||||
|
||||
SaveSingleItem(item);
|
||||
|
||||
m_set_pkItemForDelayedSave.erase(this_it);
|
||||
it = m_set_pkItemForDelayedSave.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,28 +629,29 @@ TItemTable * ITEM_MANAGER::GetTable(DWORD vnum)
|
||||
|
||||
int ITEM_MANAGER::RealNumber(DWORD vnum)
|
||||
{
|
||||
int bot, top, mid;
|
||||
if (m_vec_prototype.empty())
|
||||
return -1;
|
||||
|
||||
bot = 0;
|
||||
top = m_vec_prototype.size();
|
||||
int left = 0;
|
||||
int right = m_vec_prototype.size() - 1;
|
||||
|
||||
TItemTable * pTable = &m_vec_prototype[0];
|
||||
|
||||
while (1)
|
||||
while (left <= right)
|
||||
{
|
||||
mid = (bot + top) >> 1;
|
||||
int mid = (left + right) / 2;
|
||||
|
||||
if ((pTable + mid)->dwVnum == vnum)
|
||||
return (mid);
|
||||
if (mid < 0 || mid >= static_cast<int>(m_vec_prototype.size()))
|
||||
return -1;
|
||||
|
||||
if (bot >= top)
|
||||
return (-1);
|
||||
if (m_vec_prototype[mid].dwVnum == vnum)
|
||||
return mid;
|
||||
|
||||
if ((pTable + mid)->dwVnum > vnum)
|
||||
top = mid - 1;
|
||||
else
|
||||
bot = mid + 1;
|
||||
if (m_vec_prototype[mid].dwVnum > vnum)
|
||||
right = mid - 1;
|
||||
else
|
||||
left = mid + 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool ITEM_MANAGER::GetVnum(const char * c_pszName, DWORD & r_dwVnum)
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef GIT_DESCRIBE_VERSION
|
||||
#define GIT_DESCRIBE_VERSION "unknown"
|
||||
#endif
|
||||
|
||||
void WriteVersion()
|
||||
{
|
||||
#ifndef OS_WINDOWS
|
||||
@@ -7,7 +11,7 @@ void WriteVersion()
|
||||
|
||||
if (fp)
|
||||
{
|
||||
fprintf(fp, "game revision: 40250");
|
||||
fprintf(fp, "game revision: %s\n", GIT_DESCRIBE_VERSION);
|
||||
//fprintf(fp, "game revision: %s\n", __SVN_VERSION__);
|
||||
//fprintf(fp, "%s@%s:%s\n", __USER__, __HOSTNAME__, __PWD__);
|
||||
fclose(fp);
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// #define LIBPOLY_STANDALONE
|
||||
#ifdef LIBPOLY_STANDALONE
|
||||
|
||||
#include "Poly.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -45,3 +49,4 @@ int main(int argc, char ** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef OS_FREEBSD
|
||||
|
||||
/*
|
||||
* luau (Lib Update/Auto-Update): Simple Update Library
|
||||
* Copyright (C) 2003 David Eklund
|
||||
@@ -341,5 +339,3 @@ void MD5Transform(uint32_t buf[4], uint32_t const in[16])
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#endif // #ifndef OS_FREEBSD
|
||||
@@ -1,5 +1,4 @@
|
||||
#ifndef OS_FREEBSD
|
||||
|
||||
#pragma once
|
||||
/*
|
||||
* luau (Lib Update/Auto-Update): Simple Update Library
|
||||
* Copyright (C) 2003 David Eklund
|
||||
@@ -65,5 +64,3 @@ char* MD5End(MD5_CTX *, char *);
|
||||
|
||||
char* lutil_md5_file(const char *filename, char *buf);
|
||||
char* lutil_md5_data(const unsigned char *data, unsigned int len, char *buf);
|
||||
|
||||
#endif // #ifndef OS_FREEBSD
|
||||
|
||||
Reference in New Issue
Block a user