Skip to content

Commit a09aa42

Browse files
authored
Merge pull request #67 from rtw1x1/main
ML: Item / Mob / NPC client sided
2 parents 95b5998 + ce49389 commit a09aa42

7 files changed

Lines changed: 47 additions & 12 deletions

File tree

‎src/game/char.cpp‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,6 +4056,26 @@ void CHARACTER::ChatPacket(BYTE type, const char * format, ...)
40564056
sys_log(0, "SEND_COMMAND %s %s", GetName(), chatbuf);
40574057
}
40584058

4059+
void CHARACTER::ItemGetPacket(DWORD dwItemVnum, BYTE bCount, const char* szName, bool bIsDelivery)
4060+
{
4061+
LPDESC d = GetDesc();
4062+
4063+
if (!d)
4064+
return;
4065+
4066+
TPacketGCItemGet pack;
4067+
pack.header = HEADER_GC_ITEM_GET;
4068+
pack.dwItemVnum = dwItemVnum;
4069+
pack.bCount = bCount;
4070+
// bArg: 0 = normal, 1 = from party member, 2 = delivered to party member
4071+
pack.bArg = szName ? (bIsDelivery ? 2 : 1) : 0;
4072+
memset(pack.szFromName, 0, sizeof(pack.szFromName));
4073+
if (szName)
4074+
strlcpy(pack.szFromName, szName, sizeof(pack.szFromName));
4075+
4076+
d->Packet(&pack, sizeof(pack));
4077+
}
4078+
40594079
// MINING
40604080
void CHARACTER::mining_take()
40614081
{

‎src/game/char.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider
739739
void Motion(BYTE motion, LPCHARACTER victim = NULL);
740740

741741
void ChatPacket(BYTE type, const char *format, ...);
742+
void ItemGetPacket(DWORD dwItemVnum, BYTE bCount, const char* szName = NULL, bool bIsDelivery = false);
742743
void MonsterChat(BYTE bMonsterChatType);
743744
void SendGreetMessage();
744745

‎src/game/char_item.cpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5894,7 +5894,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
58945894

58955895
if (bCount == 0)
58965896
{
5897-
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item2->GetName());
5897+
ItemGetPacket(item2->GetVnum(), item2->GetCount());
58985898
M2_DESTROY_ITEM(item);
58995899
if (item2->GetType() == ITEM_QUEST)
59005900
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
@@ -5936,7 +5936,7 @@ bool CHARACTER::PickupItem(DWORD dwVID)
59365936
char szHint[32+1];
59375937
snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
59385938
LogManager::instance().ItemLog(this, item, "GET", szHint);
5939-
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
5939+
ItemGetPacket(item->GetVnum(), item->GetCount());
59405940

59415941
if (item->GetType() == ITEM_QUEST)
59425942
quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
@@ -5995,11 +5995,11 @@ bool CHARACTER::PickupItem(DWORD dwVID)
59955995
LogManager::instance().ItemLog(owner, item, "GET", szHint);
59965996

59975997
if (owner == this)
5998-
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
5998+
ItemGetPacket(item->GetVnum(), item->GetCount());
59995999
else
60006000
{
6001-
owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s 님으로부터 %s"), GetName(), item->GetName());
6002-
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 전달: %s 님에게 %s"), owner->GetName(), item->GetName());
6001+
owner->ItemGetPacket(item->GetVnum(), item->GetCount(), GetName());
6002+
ItemGetPacket(item->GetVnum(), item->GetCount(), owner->GetName(), true);
60036003
}
60046004

60056005
if (item->GetType() == ITEM_QUEST)
@@ -6621,7 +6621,7 @@ LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, BYTE bCount, int iRarePct, bool
66216621
if (bCount == 0)
66226622
{
66236623
if (bMsg)
6624-
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
6624+
ItemGetPacket(item->GetVnum(), item->GetCount());
66256625

66266626
return item;
66276627
}
@@ -6673,7 +6673,7 @@ LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, BYTE bCount, int iRarePct, bool
66736673
if (iEmptyCell != -1)
66746674
{
66756675
if (bMsg)
6676-
ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템 획득: %s"), item->GetName());
6676+
ItemGetPacket(item->GetVnum(), item->GetCount());
66776677

66786678
if (item->IsDragonSoul())
66796679
item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));

‎src/game/packet.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ enum
279279
HEADER_GC_DRAGON_SOUL_REFINE = 209,
280280
HEADER_GC_RESPOND_CHANNELSTATUS = 210,
281281

282+
HEADER_GC_ITEM_GET = 211,
282283

283284
/////////////////////////////////////////////////////////////////////////////
284285

@@ -1114,6 +1115,15 @@ typedef struct packet_item_set
11141115
TPlayerItemAttribute aAttr[ITEM_ATTRIBUTE_MAX_NUM];
11151116
} TPacketGCItemSet;
11161117

1118+
typedef struct packet_item_get
1119+
{
1120+
uint8_t header;
1121+
uint32_t dwItemVnum;
1122+
uint8_t bCount;
1123+
uint8_t bArg; // 0: normal, 1: from party member (need extra handling)
1124+
char szFromName[CHARACTER_NAME_MAX_LEN + 1]; // party member name when bArg == 1
1125+
} TPacketGCItemGet;
1126+
11171127
struct packet_item_use
11181128
{
11191129
uint8_t header;
@@ -1954,6 +1964,7 @@ typedef struct SPacketGCRefineInformaion
19541964
struct TNPCPosition
19551965
{
19561966
uint8_t bType;
1967+
uint32_t dwVnum;
19571968
char name[CHARACTER_NAME_MAX_LEN+1];
19581969
int32_t x;
19591970
int32_t y;

‎src/game/regen.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ bool regen_load(const char* filename, long lMapIndex, int base_x, int base_y)
676676
{
677677
SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
678678
p->m_table.bType,
679+
p->m_table.dwVnum,
679680
p->m_table.szLocaleName,
680681
(regen->sx+regen->ex) / 2 - base_x,
681682
(regen->sy+regen->ey) / 2 - base_y);

‎src/game/sectree_manager.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,7 @@ void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch)
11451145
for (auto it = m_mapNPCPosition[lMapIndex].begin(); it != m_mapNPCPosition[lMapIndex].end(); ++it)
11461146
{
11471147
np.bType = it->bType;
1148+
np.dwVnum = it->dwVnum;
11481149
strlcpy(np.name, it->name, sizeof(np.name));
11491150
np.x = it->x;
11501151
np.y = it->y;
@@ -1162,9 +1163,9 @@ void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch)
11621163
d->Packet(&p, sizeof(TPacketGCNPCPosition));
11631164
}
11641165

1165-
void SECTREE_MANAGER::InsertNPCPosition(long lMapIndex, BYTE bType, const char* szName, long x, long y)
1166+
void SECTREE_MANAGER::InsertNPCPosition(long lMapIndex, BYTE bType, DWORD dwVnum, const char* szName, long x, long y)
11661167
{
1167-
m_mapNPCPosition[lMapIndex].push_back(npc_info(bType, szName, x, y));
1168+
m_mapNPCPosition[lMapIndex].push_back(npc_info(bType, dwVnum, szName, x, y));
11681169
}
11691170

11701171
BYTE SECTREE_MANAGER::GetEmpireFromMapIndex(long lMapIndex)

‎src/game/sectree_manager.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ struct TAreaInfo
2727
struct npc_info
2828
{
2929
BYTE bType;
30+
DWORD dwVnum;
3031
const char* name;
3132
long x, y;
32-
npc_info(BYTE bType, const char* name, long x, long y)
33-
: bType(bType), name(name), x(x), y(y)
33+
npc_info(BYTE bType, DWORD dwVnum, const char* name, long x, long y)
34+
: bType(bType), dwVnum(dwVnum), name(name), x(x), y(y)
3435
{}
3536
};
3637

@@ -155,7 +156,7 @@ class SECTREE_MANAGER : public singleton<SECTREE_MANAGER>
155156

156157
TAreaMap& GetDungeonArea(long lMapIndex);
157158
void SendNPCPosition(LPCHARACTER ch);
158-
void InsertNPCPosition(long lMapIndex, BYTE bType, const char* szName, long x, long y);
159+
void InsertNPCPosition(long lMapIndex, BYTE bType, DWORD dwVnum, const char* szName, long x, long y);
159160

160161
BYTE GetEmpireFromMapIndex(long lMapIndex);
161162

0 commit comments

Comments
 (0)