1. #include "stdafx.h"
  2. #include "constants.h"
  3. #include "config.h"
  4. #include "utils.h"
  5. #include "desc_manager.h"
  6. #include "char.h"
  7. #include "char_manager.h"
  8. #include "item.h"
  9. #include "item_manager.h"
  10. #include "packet.h"
  11. #include "protocol.h"
  12. #include "mob_manager.h"
  13. #include "shop_manager.h"
  14. #include "sectree_manager.h"
  15. #include "skill.h"
  16. #include "questmanager.h"
  17. #include "p2p.h"
  18. #ifdef __ENABLE_NEW_OFFLINESHOP__
  19. #include "new_offlineshop.h"
  20. #include "new_offlineshop_manager.h"
  21. #endif
  22. #include "guild.h"
  23. #include "guild_manager.h"
  24. #include "start_position.h"
  25. #include "party.h"
  26. #include "refine.h"
  27. #include "banword.h"
  28. #include "priv_manager.h"
  29. #include "db.h"
  30. #include "building.h"
  31. #include "login_sim.h"
  32. #include "wedding.h"
  33. #include "login_data.h"
  34. #include "unique_item.h"
  35. #include "affect.h"
  36. #include "motion.h"
  37. #include "log.h"
  38. #include "horsename_manager.h"
  39. #include "gm.h"
  40. #include "panama.h"
  41. #include "map_location.h"
  42. #include "DragonSoul.h"
  43. extern BYTE g_bAuthServer;
  44. extern void gm_insert (const char* name, BYTE level);
  45. extern BYTE gm_get_level (const char* name, const char* host, const char* account);
  46. extern void gm_host_insert (const char* host);
  47. #define MAPNAME_DEFAULT "none"
  48. bool GetServerLocation (TAccountTable& rTab, BYTE bEmpire)
  49. {
  50. bool bFound = false;
  51. for (int i = 0; i < PLAYER_PER_ACCOUNT; ++i)
  52. {
  53. if (0 == rTab.players[i].dwID)
  54. {
  55. continue;
  56. }
  57. bFound = true;
  58. long lIndex = 0;
  59. if (!CMapLocation::instance().Get (rTab.players[i].x,
  60. rTab.players[i].y,
  61. lIndex,
  62. rTab.players[i].lAddr,
  63. rTab.players[i].wPort))
  64. {
  65. sys_err ("location error name %s mapindex %d %d x %d empire %d",
  66. rTab.players[i].szName, lIndex, rTab.players[i].x, rTab.players[i].y, rTab.bEmpire);
  67. rTab.players[i].x = EMPIRE_START_X (rTab.bEmpire);
  68. rTab.players[i].y = EMPIRE_START_Y (rTab.bEmpire);
  69. lIndex = 0;
  70. if (!CMapLocation::instance().Get (rTab.players[i].x, rTab.players[i].y, lIndex, rTab.players[i].lAddr, rTab.players[i].wPort))
  71. {
  72. sys_err ("cannot find server for mapindex %d %d x %d (name %s)",
  73. lIndex,
  74. rTab.players[i].x,
  75. rTab.players[i].y,
  76. rTab.players[i].szName);
  77. if (!g_stProxyIP.empty())
  78. rTab.players[i].lAddr=inet_addr(g_stProxyIP.c_str());
  79. continue;
  80. }
  81. }
  82. if (!g_stProxyIP.empty())
  83. rTab.players[i].lAddr=inet_addr(g_stProxyIP.c_str());
  84. struct in_addr in;
  85. in.s_addr = rTab.players[i].lAddr;
  86. sys_log (0, "success to %s:%d", inet_ntoa (in), rTab.players[i].wPort);
  87. }
  88. return bFound;
  89. }
  90. extern std::map<DWORD, CLoginSim*> g_sim;
  91. extern std::map<DWORD, CLoginSim*> g_simByPID;
  92. void CInputDB::LoginSuccess (DWORD dwHandle, const char* data)
  93. {
  94. sys_log (0, "LoginSuccess");
  95. TAccountTable* pTab = (TAccountTable*) data;
  96. itertype (g_sim) it = g_sim.find (pTab->id);
  97. if (g_sim.end() != it)
  98. {
  99. sys_log (0, "CInputDB::LoginSuccess - already exist sim [%s]", pTab->login);
  100. it->second->SendLoad();
  101. return;
  102. }
  103. LPDESC d = DESC_MANAGER::instance().FindByHandle (dwHandle);
  104. if (!d)
  105. {
  106. sys_log (0, "CInputDB::LoginSuccess - cannot find handle [%s]", pTab->login);
  107. TLogoutPacket pack;
  108. strlcpy (pack.login, pTab->login, sizeof (pack.login));
  109. db_clientdesc->DBPacket (HEADER_GD_LOGOUT, dwHandle, &pack, sizeof (pack));
  110. return;
  111. }
  112. if (strcmp (pTab->status, "OK")) // OK�� �ƴϸ�
  113. {
  114. sys_log (0, "CInputDB::LoginSuccess - status[%s] is not OK [%s]", pTab->status, pTab->login);
  115. TLogoutPacket pack;
  116. strlcpy (pack.login, pTab->login, sizeof (pack.login));
  117. db_clientdesc->DBPacket (HEADER_GD_LOGOUT, dwHandle, &pack, sizeof (pack));
  118. LoginFailure (d, pTab->status);
  119. return;
  120. }
  121. for (int i = 0; i != PLAYER_PER_ACCOUNT; ++i)
  122. {
  123. TSimplePlayer& player = pTab->players[i];
  124. sys_log (0, "\tplayer(%s).job(%d)", player.szName, player.byJob);
  125. }
  126. bool bFound = GetServerLocation (*pTab, pTab->bEmpire);
  127. d->BindAccountTable (pTab);
  128. if (!bFound) // ij���Ͱ� ������ ������ �������� ������.. -_-
  129. {
  130. TPacketGCEmpire pe;
  131. pe.bHeader = HEADER_GC_EMPIRE;
  132. pe.bEmpire = number (1, 3);
  133. d->Packet (&pe, sizeof (pe));
  134. }
  135. else
  136. {
  137. TPacketGCEmpire pe;
  138. pe.bHeader = HEADER_GC_EMPIRE;
  139. pe.bEmpire = d->GetEmpire();
  140. d->Packet (&pe, sizeof (pe));
  141. }
  142. d->SetPhase (PHASE_SELECT);
  143. d->SendLoginSuccessPacket();
  144. sys_log (0, "InputDB::login_success: %s", pTab->login);
  145. }
  146. void CInputDB::PlayerCreateFailure (LPDESC d, BYTE bType)
  147. {
  148. if (!d)
  149. {
  150. return;
  151. }
  152. TPacketGCCreateFailure pack;
  153. pack.header = HEADER_GC_CHARACTER_CREATE_FAILURE;
  154. pack.bType = bType;
  155. d->Packet (&pack, sizeof (pack));
  156. }
  157. void CInputDB::PlayerCreateSuccess (LPDESC d, const char* data)
  158. {
  159. if (!d)
  160. {
  161. return;
  162. }
  163. TPacketDGCreateSuccess* pPacketDB = (TPacketDGCreateSuccess*) data;
  164. if (pPacketDB->bAccountCharacterIndex >= PLAYER_PER_ACCOUNT)
  165. {
  166. d->Packet (encode_byte (HEADER_GC_CHARACTER_CREATE_FAILURE), 1);
  167. return;
  168. }
  169. long lIndex = 0;
  170. if (!CMapLocation::instance().Get (pPacketDB->player.x,
  171. pPacketDB->player.y,
  172. lIndex,
  173. pPacketDB->player.lAddr,
  174. pPacketDB->player.wPort))
  175. {
  176. sys_err ("InputDB::PlayerCreateSuccess: cannot find server for mapindex %d %d x %d (name %s)",
  177. lIndex,
  178. pPacketDB->player.x,
  179. pPacketDB->player.y,
  180. pPacketDB->player.szName);
  181. }
  182. TAccountTable& r_Tab = d->GetAccountTable();
  183. r_Tab.players[pPacketDB->bAccountCharacterIndex] = pPacketDB->player;
  184. TPacketGCPlayerCreateSuccess pack;
  185. pack.header = HEADER_GC_CHARACTER_CREATE_SUCCESS;
  186. pack.bAccountCharacterIndex = pPacketDB->bAccountCharacterIndex;
  187. pack.player = pPacketDB->player;
  188. if (!g_stProxyIP.empty())
  189. pack.player.lAddr=inet_addr(g_stProxyIP.c_str());
  190. d->Packet (&pack, sizeof (TPacketGCPlayerCreateSuccess));
  191. // �⺻ ����� ��ȯ�θ� ����
  192. TPlayerItem t;
  193. memset (&t, 0, sizeof (t));
  194. LogManager::instance().CharLog (pack.player.dwID, 0, 0, 0, "CREATE PLAYER", "", d->GetHostName());
  195. }
  196. void CInputDB::PlayerDeleteSuccess (LPDESC d, const char* data)
  197. {
  198. if (!d)
  199. {
  200. return;
  201. }
  202. BYTE account_index;
  203. account_index = decode_byte (data);
  204. d->BufferedPacket (encode_byte (HEADER_GC_CHARACTER_DELETE_SUCCESS), 1);
  205. d->Packet (encode_byte (account_index), 1);
  206. d->GetAccountTable().players[account_index].dwID = 0;
  207. }
  208. void CInputDB::PlayerDeleteFail (LPDESC d)
  209. {
  210. if (!d)
  211. {
  212. return;
  213. }
  214. d->Packet (encode_byte (HEADER_GC_CHARACTER_DELETE_WRONG_SOCIAL_ID), 1);
  215. //d->Packet(encode_byte(account_index), 1);
  216. //d->GetAccountTable().players[account_index].dwID = 0;
  217. }
  218. void CInputDB::ChangeName (LPDESC d, const char* data)
  219. {
  220. if (!d)
  221. {
  222. return;
  223. }
  224. TPacketDGChangeName* p = (TPacketDGChangeName*) data;
  225. TAccountTable& r = d->GetAccountTable();
  226. if (!r.id)
  227. {
  228. return;
  229. }
  230. for (size_t i = 0; i < PLAYER_PER_ACCOUNT; ++i)
  231. if (r.players[i].dwID == p->pid)
  232. {
  233. strlcpy (r.players[i].szName, p->name, sizeof (r.players[i].szName));
  234. r.players[i].bChangeName = 0;
  235. TPacketGCChangeName pgc;
  236. pgc.header = HEADER_GC_CHANGE_NAME;
  237. pgc.pid = p->pid;
  238. strlcpy (pgc.name, p->name, sizeof (pgc.name));
  239. d->Packet (&pgc, sizeof (TPacketGCChangeName));
  240. break;
  241. }
  242. }
  243. void CInputDB::PlayerLoad (LPDESC d, const char* data)
  244. {
  245. TPlayerTable* pTab = (TPlayerTable*) data;
  246. if (!d)
  247. {
  248. return;
  249. }
  250. long lMapIndex = pTab->lMapIndex;
  251. PIXEL_POSITION pos;
  252. if (lMapIndex == 0)
  253. {
  254. lMapIndex = SECTREE_MANAGER::instance().GetMapIndex (pTab->x, pTab->y);
  255. if (lMapIndex == 0) // ��ǥ�� ã�� �� ����.
  256. {
  257. lMapIndex = EMPIRE_START_MAP (d->GetAccountTable().bEmpire);
  258. pos.x = EMPIRE_START_X (d->GetAccountTable().bEmpire);
  259. pos.y = EMPIRE_START_Y (d->GetAccountTable().bEmpire);
  260. }
  261. else
  262. {
  263. pos.x = pTab->x;
  264. pos.y = pTab->y;
  265. }
  266. }
  267. pTab->lMapIndex = lMapIndex;
  268. // Private �ʿ� �־��µ�, Private ���� ����� ���¶�� �ⱸ�� ���ư��� �Ѵ�.
  269. // ----
  270. // �ٵ� �ⱸ�� ���ư��� �Ѵٸ鼭... �� �ⱸ�� �ƴ϶� private map �� �����Ǵ� pulic map�� ��ġ�� ã�İ�...
  271. // ���縦 �𸣴�... �� �ϵ��ڵ� �Ѵ�.
  272. // �Ʊ͵����̸�, �ⱸ��...
  273. // by rtsummit
  274. if (!SECTREE_MANAGER::instance().GetValidLocation (pTab->lMapIndex, pTab->x, pTab->y, lMapIndex, pos, d->GetEmpire()))
  275. {
  276. sys_err ("InputDB::PlayerLoad : cannot find valid location %d x %d (name: %s)", pTab->x, pTab->y, pTab->name);
  277. d->SetPhase (PHASE_CLOSE);
  278. return;
  279. }
  280. pTab->x = pos.x;
  281. pTab->y = pos.y;
  282. pTab->lMapIndex = lMapIndex;
  283. if (d->GetCharacter() || d->IsPhase (PHASE_GAME))
  284. {
  285. LPCHARACTER p = d->GetCharacter();
  286. sys_err ("login state already has main state (character %s %p)", p->GetName(), get_pointer (p));
  287. return;
  288. }
  289. if (NULL != CHARACTER_MANAGER::Instance().FindPC (pTab->name))
  290. {
  291. sys_err ("InputDB: PlayerLoad : %s already exist in game", pTab->name);
  292. return;
  293. }
  294. LPCHARACTER ch = CHARACTER_MANAGER::instance().CreateCharacter (pTab->name, pTab->id);
  295. ch->BindDesc (d);
  296. ch->SetPlayerProto (pTab);
  297. ch->SetEmpire (d->GetEmpire());
  298. d->BindCharacter (ch);
  299. {
  300. // P2P Login
  301. TPacketGGLogin p;
  302. p.bHeader = HEADER_GG_LOGIN;
  303. strlcpy (p.szName, ch->GetName(), sizeof (p.szName));
  304. p.dwPID = ch->GetPlayerID();
  305. p.bEmpire = ch->GetEmpire();
  306. p.lMapIndex = SECTREE_MANAGER::instance().GetMapIndex (ch->GetX(), ch->GetY());
  307. p.bChannel = g_bChannel;
  308. P2P_MANAGER::instance().Send (&p, sizeof (TPacketGGLogin));
  309. char buf[51];
  310. snprintf (buf, sizeof (buf), "%s %d %d %ld %d",
  311. inet_ntoa (ch->GetDesc()->GetAddr().sin_addr), ch->GetGold(), g_bChannel, ch->GetMapIndex(), ch->GetAlignment());
  312. LogManager::instance().CharLog (ch, 0, "LOGIN", buf);
  313. LogManager::instance().LoginLog (true,
  314. ch->GetDesc()->GetAccountTable().id, ch->GetPlayerID(), ch->GetLevel(), ch->GetJob(), ch->GetRealPoint (POINT_PLAYTIME));
  315. }
  316. d->SetPhase (PHASE_LOADING);
  317. ch->MainCharacterPacket();
  318. long lPublicMapIndex = lMapIndex >= 10000 ? lMapIndex / 10000 : lMapIndex;
  319. //Send Supplementary Data Block if new map requires security packages in loading this map
  320. const TMapRegion* rMapRgn = SECTREE_MANAGER::instance().GetMapRegion (lPublicMapIndex);
  321. if (rMapRgn)
  322. {
  323. DESC_MANAGER::instance().SendClientPackageSDBToLoadMap (d, rMapRgn->strMapName.c_str());
  324. }
  325. //if (!map_allow_find(lMapIndex >= 10000 ? lMapIndex / 10000 : lMapIndex) || !CheckEmpire(ch, lMapIndex))
  326. if (!map_allow_find (lPublicMapIndex))
  327. {
  328. sys_err ("InputDB::PlayerLoad : entering %d map is not allowed here (name: %s, empire %u)",
  329. lMapIndex, pTab->name, d->GetEmpire());
  330. ch->SetWarpLocation (EMPIRE_START_MAP (d->GetEmpire()),
  331. EMPIRE_START_X (d->GetEmpire()) / 100,
  332. EMPIRE_START_Y (d->GetEmpire()) / 100);
  333. d->SetPhase (PHASE_CLOSE);
  334. return;
  335. }
  336. quest::CQuestManager::instance().BroadcastEventFlagOnLogin (ch);
  337. for (int i = 0; i < QUICKSLOT_MAX_NUM; ++i)
  338. {
  339. ch->SetQuickslot (i, pTab->quickslot[i]);
  340. }
  341. ch->PointsPacket();
  342. ch->SkillLevelPacket();
  343. sys_log (0, "InputDB: player_load %s %dx%dx%d LEVEL %d MOV_SPEED %d JOB %d ATG %d DFG %d GMLv %d",
  344. pTab->name,
  345. ch->GetX(), ch->GetY(), ch->GetZ(),
  346. ch->GetLevel(),
  347. ch->GetPoint (POINT_MOV_SPEED),
  348. ch->GetJob(),
  349. ch->GetPoint (POINT_ATT_GRADE),
  350. ch->GetPoint (POINT_DEF_GRADE),
  351. ch->GetGMLevel());
  352. ch->QuerySafeboxSize();
  353. }
  354. void CInputDB::Boot (const char* data)
  355. {
  356. signal_timer_disable();
  357. // ��Ŷ ������ üũ
  358. DWORD dwPacketSize = decode_4bytes (data);
  359. data += 4;
  360. // ��Ŷ ���� üũ
  361. BYTE bVersion = decode_byte (data);
  362. data += 1;
  363. sys_log (0, "BOOT: PACKET: %d", dwPacketSize);
  364. sys_log (0, "BOOT: VERSION: %d", bVersion);
  365. if (bVersion != 6)
  366. {
  367. sys_err ("boot version error");
  368. thecore_shutdown();
  369. }
  370. sys_log (0, "sizeof(TMobTable) = %d", sizeof (TMobTable));
  371. sys_log (0, "sizeof(TItemTable) = %d", sizeof (TItemTable));
  372. sys_log (0, "sizeof(TShopTable) = %d", sizeof (TShopTable));
  373. sys_log (0, "sizeof(TSkillTable) = %d", sizeof (TSkillTable));
  374. sys_log (0, "sizeof(TRefineTable) = %d", sizeof (TRefineTable));
  375. sys_log (0, "sizeof(TItemAttrTable) = %d", sizeof (TItemAttrTable));
  376. sys_log (0, "sizeof(TItemRareTable) = %d", sizeof (TItemAttrTable));
  377. sys_log (0, "sizeof(TBanwordTable) = %d", sizeof (TBanwordTable));
  378. sys_log (0, "sizeof(TLand) = %d", sizeof (building::TLand));
  379. sys_log (0, "sizeof(TObjectProto) = %d", sizeof (building::TObjectProto));
  380. sys_log (0, "sizeof(TObject) = %d", sizeof (building::TObject));
  381. //ADMIN_MANAGER
  382. sys_log (0, "sizeof(TAdminManager) = %d", sizeof (TAdminInfo));
  383. //END_ADMIN_MANAGER
  384. WORD size;
  385. /*
  386. * MOB
  387. */
  388. if (decode_2bytes (data)!=sizeof (TMobTable))
  389. {
  390. sys_err ("mob table size error");
  391. thecore_shutdown();
  392. return;
  393. }
  394. data += 2;
  395. size = decode_2bytes (data);
  396. data += 2;
  397. sys_log (0, "BOOT: MOB: %d", size);
  398. if (size)
  399. {
  400. CMobManager::instance().Initialize ((TMobTable*) data, size);
  401. data += size * sizeof (TMobTable);
  402. }
  403. /*
  404. * ITEM
  405. */
  406. if (decode_2bytes (data) != sizeof (TItemTable))
  407. {
  408. sys_err ("item table size error");
  409. thecore_shutdown();
  410. return;
  411. }
  412. data += 2;
  413. size = decode_2bytes (data);
  414. data += 2;
  415. sys_log (0, "BOOT: ITEM: %d", size);
  416. if (size)
  417. {
  418. ITEM_MANAGER::instance().Initialize ((TItemTable*) data, size);
  419. data += size * sizeof (TItemTable);
  420. }
  421. /*
  422. * SHOP
  423. */
  424. if (decode_2bytes (data) != sizeof (TShopTable))
  425. {
  426. sys_err ("shop table size error");
  427. thecore_shutdown();
  428. return;
  429. }
  430. data += 2;
  431. size = decode_2bytes (data);
  432. data += 2;
  433. sys_log (0, "BOOT: SHOP: %d", size);
  434. if (size)
  435. {
  436. if (!CShopManager::instance().Initialize ((TShopTable*) data, size))
  437. {
  438. sys_err ("shop table Initialize error");
  439. thecore_shutdown();
  440. return;
  441. }
  442. data += size * sizeof (TShopTable);
  443. }
  444. /*
  445. * SKILL
  446. */
  447. if (decode_2bytes (data) != sizeof (TSkillTable))
  448. {
  449. sys_err ("skill table size error");
  450. thecore_shutdown();
  451. return;
  452. }
  453. data += 2;
  454. size = decode_2bytes (data);
  455. data += 2;
  456. sys_log (0, "BOOT: SKILL: %d", size);
  457. if (size)
  458. {
  459. if (!CSkillManager::instance().Initialize ((TSkillTable*) data, size))
  460. {
  461. sys_err ("cannot initialize skill table");
  462. thecore_shutdown();
  463. return;
  464. }
  465. data += size * sizeof (TSkillTable);
  466. }
  467. /*
  468. * REFINE RECIPE
  469. */
  470. if (decode_2bytes (data) != sizeof (TRefineTable))
  471. {
  472. sys_err ("refine table size error");
  473. thecore_shutdown();
  474. return;
  475. }
  476. data += 2;
  477. size = decode_2bytes (data);
  478. data += 2;
  479. sys_log (0, "BOOT: REFINE: %d", size);
  480. if (size)
  481. {
  482. CRefineManager::instance().Initialize ((TRefineTable*) data, size);
  483. data += size * sizeof (TRefineTable);
  484. }
  485. /*
  486. * ITEM ATTR
  487. */
  488. if (decode_2bytes (data) != sizeof (TItemAttrTable))
  489. {
  490. sys_err ("item attr table size error");
  491. thecore_shutdown();
  492. return;
  493. }
  494. data += 2;
  495. size = decode_2bytes (data);
  496. data += 2;
  497. sys_log (0, "BOOT: ITEM_ATTR: %d", size);
  498. if (size)
  499. {
  500. TItemAttrTable* p = (TItemAttrTable*) data;
  501. for (int i = 0; i < size; ++i, ++p)
  502. {
  503. if (p->dwApplyIndex >= MAX_APPLY_NUM)
  504. {
  505. continue;
  506. }
  507. g_map_itemAttr[p->dwApplyIndex] = *p;
  508. sys_log (0, "ITEM_ATTR[%d]: %s %u", p->dwApplyIndex, p->szApply, p->dwProb);
  509. }
  510. }
  511. data += size * sizeof (TItemAttrTable);
  512. /*
  513. * ITEM RARE
  514. */
  515. if (decode_2bytes (data) != sizeof (TItemAttrTable))
  516. {
  517. sys_err ("item rare table size error");
  518. thecore_shutdown();
  519. return;
  520. }
  521. data += 2;
  522. size = decode_2bytes (data);
  523. data += 2;
  524. sys_log (0, "BOOT: ITEM_RARE: %d", size);
  525. if (size)
  526. {
  527. TItemAttrTable* p = (TItemAttrTable*) data;
  528. for (int i = 0; i < size; ++i, ++p)
  529. {
  530. if (p->dwApplyIndex >= MAX_APPLY_NUM)
  531. {
  532. continue;
  533. }
  534. g_map_itemRare[p->dwApplyIndex] = *p;
  535. sys_log (0, "ITEM_RARE[%d]: %s %u", p->dwApplyIndex, p->szApply, p->dwProb);
  536. }
  537. }
  538. data += size * sizeof (TItemAttrTable);
  539. /*
  540. * BANWORDS
  541. */
  542. if (decode_2bytes (data) != sizeof (TBanwordTable))
  543. {
  544. sys_err ("ban word table size error");
  545. thecore_shutdown();
  546. return;
  547. }
  548. data += 2;
  549. size = decode_2bytes (data);
  550. data += 2;
  551. CBanwordManager::instance().Initialize ((TBanwordTable*) data, size);
  552. data += size * sizeof (TBanwordTable);
  553. {
  554. using namespace building;
  555. /*
  556. * LANDS
  557. */
  558. if (decode_2bytes (data) != sizeof (TLand))
  559. {
  560. sys_err ("land table size error");
  561. thecore_shutdown();
  562. return;
  563. }
  564. data += 2;
  565. size = decode_2bytes (data);
  566. data += 2;
  567. TLand* kLand = (TLand*) data;
  568. data += size * sizeof (TLand);
  569. for (WORD i = 0; i < size; ++i, ++kLand)
  570. {
  571. CManager::instance().LoadLand (kLand);
  572. }
  573. /*
  574. * OBJECT PROTO
  575. */
  576. if (decode_2bytes (data) != sizeof (TObjectProto))
  577. {
  578. sys_err ("object proto table size error");
  579. thecore_shutdown();
  580. return;
  581. }
  582. data += 2;
  583. size = decode_2bytes (data);
  584. data += 2;
  585. CManager::instance().LoadObjectProto ((TObjectProto*) data, size);
  586. data += size * sizeof (TObjectProto);
  587. /*
  588. * OBJECT
  589. */
  590. if (decode_2bytes (data) != sizeof (TObject))
  591. {
  592. sys_err ("object table size error");
  593. thecore_shutdown();
  594. return;
  595. }
  596. data += 2;
  597. size = decode_2bytes (data);
  598. data += 2;
  599. TObject* kObj = (TObject*) data;
  600. data += size * sizeof (TObject);
  601. for (WORD i = 0; i < size; ++i, ++kObj)
  602. {
  603. CManager::instance().LoadObject (kObj, true);
  604. }
  605. }
  606. set_global_time (* (time_t*) data);
  607. data += sizeof (time_t);
  608. if (decode_2bytes (data) != sizeof (TItemIDRangeTable))
  609. {
  610. sys_err ("ITEM ID RANGE size error");
  611. thecore_shutdown();
  612. return;
  613. }
  614. data += 2;
  615. size = decode_2bytes (data);
  616. data += 2;
  617. TItemIDRangeTable* range = (TItemIDRangeTable*) data;
  618. data += size * sizeof (TItemIDRangeTable);
  619. TItemIDRangeTable* rangespare = (TItemIDRangeTable*) data;
  620. data += size * sizeof (TItemIDRangeTable);
  621. //ADMIN_MANAGER
  622. //������ ���
  623. int ChunkSize = decode_2bytes (data);
  624. data += 2;
  625. int HostSize = decode_2bytes (data);
  626. data += 2;
  627. sys_log (0, "GM Value Count %d %d", HostSize, ChunkSize);
  628. for (int n = 0; n < HostSize; ++n)
  629. {
  630. gm_new_host_inert (data);
  631. sys_log (0, "GM HOST : IP[%s] ", data);
  632. data += ChunkSize;
  633. }
  634. data += 2;
  635. int adminsize = decode_2bytes (data);
  636. data += 2;
  637. for (int n = 0; n < adminsize; ++n)
  638. {
  639. tAdminInfo& rAdminInfo = * (tAdminInfo*)data;
  640. gm_new_insert (rAdminInfo);
  641. data += sizeof (rAdminInfo);
  642. }
  643. //END_ADMIN_MANAGER
  644. WORD endCheck=decode_2bytes (data);
  645. if (endCheck != 0xffff)
  646. {
  647. sys_err ("boot packet end check error [%x]!=0xffff", endCheck);
  648. thecore_shutdown();
  649. return;
  650. }
  651. else
  652. {
  653. sys_log (0, "boot packet end check ok [%x]==0xffff", endCheck);
  654. }
  655. data +=2;
  656. if (!ITEM_MANAGER::instance().SetMaxItemID (*range))
  657. {
  658. sys_err ("not enough item id contact your administrator!");
  659. thecore_shutdown();
  660. return;
  661. }
  662. if (!ITEM_MANAGER::instance().SetMaxSpareItemID (*rangespare))
  663. {
  664. sys_err ("not enough item id for spare contact your administrator!");
  665. thecore_shutdown();
  666. return;
  667. }
  668. // LOCALE_SERVICE
  669. const int FILE_NAME_LEN = 256;
  670. char szCommonDropItemFileName[FILE_NAME_LEN];
  671. char szETCDropItemFileName[FILE_NAME_LEN];
  672. char szMOBDropItemFileName[FILE_NAME_LEN];
  673. char szDropItemGroupFileName[FILE_NAME_LEN];
  674. char szSpecialItemGroupFileName[FILE_NAME_LEN];
  675. char szMapIndexFileName[FILE_NAME_LEN];
  676. char szItemVnumMaskTableFileName[FILE_NAME_LEN];
  677. char szDragonSoulTableFileName[FILE_NAME_LEN];
  678. snprintf (szCommonDropItemFileName, sizeof (szCommonDropItemFileName),
  679. "%s/common_drop_item.txt", LocaleService_GetBasePath().c_str());
  680. snprintf (szETCDropItemFileName, sizeof (szETCDropItemFileName),
  681. "%s/etc_drop_item.txt", LocaleService_GetBasePath().c_str());
  682. snprintf (szMOBDropItemFileName, sizeof (szMOBDropItemFileName),
  683. "%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());
  684. snprintf (szSpecialItemGroupFileName, sizeof (szSpecialItemGroupFileName),
  685. "%s/special_item_group.txt", LocaleService_GetBasePath().c_str());
  686. snprintf (szDropItemGroupFileName, sizeof (szDropItemGroupFileName),
  687. "%s/drop_item_group.txt", LocaleService_GetBasePath().c_str());
  688. snprintf (szMapIndexFileName, sizeof (szMapIndexFileName),
  689. "%s/index", LocaleService_GetMapPath().c_str());
  690. snprintf (szItemVnumMaskTableFileName, sizeof (szItemVnumMaskTableFileName),
  691. "%s/ori_to_new_table.txt", LocaleService_GetBasePath().c_str());
  692. snprintf (szDragonSoulTableFileName, sizeof (szDragonSoulTableFileName),
  693. "%s/dragon_soul_table.txt", LocaleService_GetBasePath().c_str());
  694. sys_log (0, "Initializing Informations of Cube System");
  695. if (!Cube_InformationInitialize())
  696. {
  697. sys_err ("cannot init cube infomation.");
  698. thecore_shutdown();
  699. return;
  700. }
  701. sys_log (0, "LoadLocaleFile: CommonDropItem: %s", szCommonDropItemFileName);
  702. if (!ITEM_MANAGER::instance().ReadCommonDropItemFile (szCommonDropItemFileName))
  703. {
  704. sys_err ("cannot load CommonDropItem: %s", szCommonDropItemFileName);
  705. thecore_shutdown();
  706. return;
  707. }
  708. sys_log (0, "LoadLocaleFile: ETCDropItem: %s", szETCDropItemFileName);
  709. if (!ITEM_MANAGER::instance().ReadEtcDropItemFile (szETCDropItemFileName))
  710. {
  711. sys_err ("cannot load ETCDropItem: %s", szETCDropItemFileName);
  712. thecore_shutdown();
  713. return;
  714. }
  715. sys_log (0, "LoadLocaleFile: DropItemGroup: %s", szDropItemGroupFileName);
  716. if (!ITEM_MANAGER::instance().ReadDropItemGroup (szDropItemGroupFileName))
  717. {
  718. sys_err ("cannot load DropItemGroup: %s", szDropItemGroupFileName);
  719. thecore_shutdown();
  720. return;
  721. }
  722. sys_log (0, "LoadLocaleFile: SpecialItemGroup: %s", szSpecialItemGroupFileName);
  723. if (!ITEM_MANAGER::instance().ReadSpecialDropItemFile (szSpecialItemGroupFileName))
  724. {
  725. sys_err ("cannot load SpecialItemGroup: %s", szSpecialItemGroupFileName);
  726. thecore_shutdown();
  727. return;
  728. }
  729. sys_log (0, "LoadLocaleFile: ItemVnumMaskTable : %s", szItemVnumMaskTableFileName);
  730. if (!ITEM_MANAGER::instance().ReadItemVnumMaskTable (szItemVnumMaskTableFileName))
  731. {
  732. sys_log (0, "Could not open MaskItemTable");
  733. }
  734. sys_log (0, "LoadLocaleFile: MOBDropItemFile: %s", szMOBDropItemFileName);
  735. if (!ITEM_MANAGER::instance().ReadMonsterDropItemGroup (szMOBDropItemFileName))
  736. {
  737. sys_err ("cannot load MOBDropItemFile: %s", szMOBDropItemFileName);
  738. thecore_shutdown();
  739. return;
  740. }
  741. sys_log (0, "LoadLocaleFile: MapIndex: %s", szMapIndexFileName);
  742. if (!SECTREE_MANAGER::instance().Build (szMapIndexFileName, LocaleService_GetMapPath().c_str()))
  743. {
  744. sys_err ("cannot load MapIndex: %s", szMapIndexFileName);
  745. thecore_shutdown();
  746. return;
  747. }
  748. sys_log (0, "LoadLocaleFile: DragonSoulTable: %s", szDragonSoulTableFileName);
  749. if (!DSManager::instance().ReadDragonSoulTableFile (szDragonSoulTableFileName))
  750. {
  751. sys_err ("cannot load DragonSoulTable: %s", szDragonSoulTableFileName);
  752. //thecore_shutdown();
  753. //return;
  754. }
  755. // END_OF_LOCALE_SERVICE
  756. building::CManager::instance().FinalizeBoot();
  757. CMotionManager::instance().Build();
  758. signal_timer_enable (30);
  759. if (test_server)
  760. {
  761. CMobManager::instance().DumpRegenCount ("mob_count");
  762. }
  763. }
  764. EVENTINFO (quest_login_event_info)
  765. {
  766. DWORD dwPID;
  767. quest_login_event_info()
  768. : dwPID (0)
  769. {
  770. }
  771. };
  772. EVENTFUNC (quest_login_event)
  773. {
  774. quest_login_event_info* info = dynamic_cast<quest_login_event_info*> (event->info);
  775. if (info == NULL)
  776. {
  777. sys_err ("quest_login_event> <Factor> Null pointer");
  778. return 0;
  779. }
  780. DWORD dwPID = info->dwPID;
  781. LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID (dwPID);
  782. if (!ch)
  783. {
  784. return 0;
  785. }
  786. LPDESC d = ch->GetDesc();
  787. if (!d)
  788. {
  789. return 0;
  790. }
  791. if (d->IsPhase (PHASE_HANDSHAKE) ||
  792. d->IsPhase (PHASE_LOGIN) ||
  793. d->IsPhase (PHASE_SELECT) ||
  794. d->IsPhase (PHASE_DEAD) ||
  795. d->IsPhase (PHASE_LOADING))
  796. {
  797. return PASSES_PER_SEC (1);
  798. }
  799. else if (d->IsPhase (PHASE_CLOSE))
  800. {
  801. return 0;
  802. }
  803. else if (d->IsPhase (PHASE_GAME))
  804. {
  805. sys_log (0, "QUEST_LOAD: Login pc %d by event", ch->GetPlayerID());
  806. quest::CQuestManager::instance().Login (ch->GetPlayerID());
  807. return 0;
  808. }
  809. else
  810. {
  811. sys_err (0, "input_db.cpp:quest_login_event INVALID PHASE pid %d", ch->GetPlayerID());
  812. return 0;
  813. }
  814. }
  815. void CInputDB::QuestLoad (LPDESC d, const char* c_pData)
  816. {
  817. if (NULL == d)
  818. {
  819. return;
  820. }
  821. LPCHARACTER ch = d->GetCharacter();
  822. if (NULL == ch)
  823. {
  824. return;
  825. }
  826. const DWORD dwCount = decode_4bytes (c_pData);
  827. const TQuestTable* pQuestTable = reinterpret_cast<const TQuestTable*> (c_pData+4);
  828. if (NULL != pQuestTable)
  829. {
  830. if (dwCount != 0)
  831. {
  832. if (ch->GetPlayerID() != pQuestTable[0].dwPID)
  833. {
  834. sys_err ("PID differs %u %u", ch->GetPlayerID(), pQuestTable[0].dwPID);
  835. return;
  836. }
  837. }
  838. sys_log (0, "QUEST_LOAD: count %d", dwCount);
  839. quest::PC* pkPC = quest::CQuestManager::instance().GetPCForce (ch->GetPlayerID());
  840. if (!pkPC)
  841. {
  842. sys_err ("null quest::PC with id %u", pQuestTable[0].dwPID);
  843. return;
  844. }
  845. if (pkPC->IsLoaded())
  846. {
  847. return;
  848. }
  849. for (unsigned int i = 0; i < dwCount; ++i)
  850. {
  851. std::string st (pQuestTable[i].szName);
  852. st += ".";
  853. st += pQuestTable[i].szState;
  854. sys_log (0, " %s %d", st.c_str(), pQuestTable[i].lValue);
  855. pkPC->SetFlag (st.c_str(), pQuestTable[i].lValue, false);
  856. }
  857. pkPC->SetLoaded();
  858. pkPC->Build();
  859. if (ch->GetDesc()->IsPhase (PHASE_GAME))
  860. {
  861. sys_log (0, "QUEST_LOAD: Login pc %d", pQuestTable[0].dwPID);
  862. quest::CQuestManager::instance().Login (pQuestTable[0].dwPID);
  863. }
  864. else
  865. {
  866. quest_login_event_info* info = AllocEventInfo<quest_login_event_info>();
  867. info->dwPID = ch->GetPlayerID();
  868. event_create (quest_login_event, info, PASSES_PER_SEC (1));
  869. }
  870. }
  871. }
  872. void CInputDB::SafeboxLoad (LPDESC d, const char* c_pData)
  873. {
  874. if (!d)
  875. {
  876. return;
  877. }
  878. TSafeboxTable* p = (TSafeboxTable*) c_pData;
  879. if (d->GetAccountTable().id != p->dwID)
  880. {
  881. sys_err ("SafeboxLoad: safebox has different id %u != %u", d->GetAccountTable().id, p->dwID);
  882. return;
  883. }
  884. if (!d->GetCharacter())
  885. {
  886. return;
  887. }
  888. BYTE bSize = 1;
  889. LPCHARACTER ch = d->GetCharacter();
  890. //PREVENT_TRADE_WINDOW
  891. if (ch->GetShopOwner() || ch->GetExchange() || ch->GetMyShop() || ch->IsCubeOpen())
  892. {
  893. d->GetCharacter()->ChatPacket (CHAT_TYPE_INFO, "[LS;441]");
  894. d->GetCharacter()->CancelSafeboxLoad();
  895. return;
  896. }
  897. //END_PREVENT_TRADE_WINDOW
  898. // ADD_PREMIUM
  899. if (d->GetCharacter()->GetPremiumRemainSeconds (PREMIUM_SAFEBOX) > 0 ||
  900. d->GetCharacter()->IsEquipUniqueGroup (UNIQUE_GROUP_LARGE_SAFEBOX))
  901. {
  902. bSize = 3;
  903. }
  904. // END_OF_ADD_PREMIUM
  905. //if (d->GetCharacter()->IsEquipUniqueItem(UNIQUE_ITEM_SAFEBOX_EXPAND))
  906. //bSize = 3; // â��Ȯ���
  907. //d->GetCharacter()->LoadSafebox(p->bSize * SAFEBOX_PAGE_SIZE, p->dwGold, p->wItemCount, (TPlayerItem *) (c_pData + sizeof(TSafeboxTable)));
  908. d->GetCharacter()->LoadSafebox (bSize * SAFEBOX_PAGE_SIZE, p->dwGold, p->wItemCount, (TPlayerItem*) (c_pData + sizeof (TSafeboxTable)));
  909. }
  910. void CInputDB::SafeboxChangeSize (LPDESC d, const char* c_pData)
  911. {
  912. if (!d)
  913. {
  914. return;
  915. }
  916. BYTE bSize = * (BYTE*) c_pData;
  917. if (!d->GetCharacter())
  918. {
  919. return;
  920. }
  921. d->GetCharacter()->ChangeSafeboxSize (bSize);
  922. }
  923. //
  924. // @version 05/06/20 Bang2ni - ReqSafeboxLoad �� ���
  925. //
  926. void CInputDB::SafeboxWrongPassword (LPDESC d)
  927. {
  928. if (!d)
  929. {
  930. return;
  931. }
  932. if (!d->GetCharacter())
  933. {
  934. return;
  935. }
  936. TPacketCGSafeboxWrongPassword p;
  937. p.bHeader = HEADER_GC_SAFEBOX_WRONG_PASSWORD;
  938. d->Packet (&p, sizeof (p));
  939. d->GetCharacter()->CancelSafeboxLoad();
  940. }
  941. void CInputDB::SafeboxChangePasswordAnswer (LPDESC d, const char* c_pData)
  942. {
  943. if (!d)
  944. {
  945. return;
  946. }
  947. if (!d->GetCharacter())
  948. {
  949. return;
  950. }
  951. TSafeboxChangePasswordPacketAnswer* p = (TSafeboxChangePasswordPacketAnswer*) c_pData;
  952. if (p->flag)
  953. {
  954. d->GetCharacter()->ChatPacket (CHAT_TYPE_INFO, "[LS;774]");
  955. }
  956. else
  957. {
  958. d->GetCharacter()->ChatPacket (CHAT_TYPE_INFO, "[LS;526]");
  959. }
  960. }
  961. void CInputDB::MallLoad (LPDESC d, const char* c_pData)
  962. {
  963. if (!d)
  964. {
  965. return;
  966. }
  967. TSafeboxTable* p = (TSafeboxTable*) c_pData;
  968. if (d->GetAccountTable().id != p->dwID)
  969. {
  970. sys_err ("safebox has different id %u != %u", d->GetAccountTable().id, p->dwID);
  971. return;
  972. }
  973. if (!d->GetCharacter())
  974. {
  975. return;
  976. }
  977. d->GetCharacter()->LoadMall (p->wItemCount, (TPlayerItem*) (c_pData + sizeof (TSafeboxTable)));
  978. }
  979. void CInputDB::LoginAlready (LPDESC d, const char* c_pData)
  980. {
  981. if (!d)
  982. {
  983. return;
  984. }
  985. // INTERNATIONAL_VERSION �̹� �������̸� ���� ����
  986. {
  987. TPacketDGLoginAlready* p = (TPacketDGLoginAlready*) c_pData;
  988. LPDESC d2 = DESC_MANAGER::instance().FindByLoginName (p->szLogin);
  989. if (d2)
  990. {
  991. d2->DisconnectOfSameLogin();
  992. }
  993. else
  994. {
  995. TPacketGGDisconnect pgg;
  996. pgg.bHeader = HEADER_GG_DISCONNECT;
  997. strlcpy (pgg.szLogin, p->szLogin, sizeof (pgg.szLogin));
  998. P2P_MANAGER::instance().Send (&pgg, sizeof (TPacketGGDisconnect));
  999. }
  1000. }
  1001. // END_OF_INTERNATIONAL_VERSION
  1002. LoginFailure (d, "ALREADY");
  1003. }
  1004. void CInputDB::EmpireSelect (LPDESC d, const char* c_pData)
  1005. {
  1006. sys_log (0, "EmpireSelect %p", get_pointer (d));
  1007. if (!d)
  1008. {
  1009. return;
  1010. }
  1011. TAccountTable& rTable = d->GetAccountTable();
  1012. rTable.bEmpire = * (BYTE*) c_pData;
  1013. TPacketGCEmpire pe;
  1014. pe.bHeader = HEADER_GC_EMPIRE;
  1015. pe.bEmpire = rTable.bEmpire;
  1016. d->Packet (&pe, sizeof (pe));
  1017. for (int i = 0; i < PLAYER_PER_ACCOUNT; ++i)
  1018. if (rTable.players[i].dwID)
  1019. {
  1020. rTable.players[i].x = EMPIRE_START_X (rTable.bEmpire);
  1021. rTable.players[i].y = EMPIRE_START_Y (rTable.bEmpire);
  1022. }
  1023. GetServerLocation (d->GetAccountTable(), rTable.bEmpire);
  1024. d->SendLoginSuccessPacket();
  1025. }
  1026. void CInputDB::MapLocations (const char* c_pData)
  1027. {
  1028. BYTE bCount = * (BYTE*) (c_pData++);
  1029. sys_log (0, "InputDB::MapLocations %d", bCount);
  1030. TMapLocation* pLoc = (TMapLocation*) c_pData;
  1031. while (bCount--)
  1032. {
  1033. for (int i = 0; i < 32; ++i)
  1034. {
  1035. if (0 == pLoc->alMaps[i])
  1036. {
  1037. break;
  1038. }
  1039. CMapLocation::instance().Insert (pLoc->alMaps[i], pLoc->szHost, pLoc->wPort);
  1040. }
  1041. pLoc++;
  1042. }
  1043. }
  1044. void CInputDB::P2P (const char* c_pData)
  1045. {
  1046. extern LPFDWATCH main_fdw;
  1047. TPacketDGP2P* p = (TPacketDGP2P*) c_pData;
  1048. P2P_MANAGER& mgr = P2P_MANAGER::instance();
  1049. if (false == DESC_MANAGER::instance().IsP2PDescExist (p->szHost, p->wPort))
  1050. {
  1051. LPCLIENT_DESC pkDesc = NULL;
  1052. sys_log (0, "InputDB:P2P %s:%u", p->szHost, p->wPort);
  1053. pkDesc = DESC_MANAGER::instance().CreateConnectionDesc (main_fdw, p->szHost, p->wPort, PHASE_P2P, false);
  1054. mgr.RegisterConnector (pkDesc);
  1055. pkDesc->SetP2P (p->szHost, p->wPort, p->bChannel);
  1056. }
  1057. }
  1058. void CInputDB::GuildLoad (const char* c_pData)
  1059. {
  1060. CGuildManager::instance().LoadGuild (* (DWORD*) c_pData);
  1061. }
  1062. void CInputDB::GuildSkillUpdate (const char* c_pData)
  1063. {
  1064. TPacketGuildSkillUpdate* p = (TPacketGuildSkillUpdate*) c_pData;
  1065. CGuild* g = CGuildManager::instance().TouchGuild (p->guild_id);
  1066. if (g)
  1067. {
  1068. g->UpdateSkill (p->skill_point, p->skill_levels);
  1069. g->GuildPointChange (POINT_SP, p->amount, p->save?true:false);
  1070. }
  1071. }
  1072. void CInputDB::GuildWar (const char* c_pData)
  1073. {
  1074. TPacketGuildWar* p = (TPacketGuildWar*) c_pData;
  1075. sys_log (0, "InputDB::GuildWar %u %u state %d", p->dwGuildFrom, p->dwGuildTo, p->bWar);
  1076. switch (p->bWar)
  1077. {
  1078. case GUILD_WAR_SEND_DECLARE:
  1079. case GUILD_WAR_RECV_DECLARE:
  1080. CGuildManager::instance().DeclareWar (p->dwGuildFrom, p->dwGuildTo, p->bType);
  1081. break;
  1082. case GUILD_WAR_REFUSE:
  1083. CGuildManager::instance().RefuseWar (p->dwGuildFrom, p->dwGuildTo);
  1084. break;
  1085. case GUILD_WAR_WAIT_START:
  1086. CGuildManager::instance().WaitStartWar (p->dwGuildFrom, p->dwGuildTo);
  1087. break;
  1088. case GUILD_WAR_CANCEL:
  1089. CGuildManager::instance().CancelWar (p->dwGuildFrom, p->dwGuildTo);
  1090. break;
  1091. case GUILD_WAR_ON_WAR:
  1092. CGuildManager::instance().StartWar (p->dwGuildFrom, p->dwGuildTo);
  1093. break;
  1094. case GUILD_WAR_END:
  1095. CGuildManager::instance().EndWar (p->dwGuildFrom, p->dwGuildTo);
  1096. break;
  1097. case GUILD_WAR_OVER:
  1098. CGuildManager::instance().WarOver (p->dwGuildFrom, p->dwGuildTo, p->bType);
  1099. break;
  1100. case GUILD_WAR_RESERVE:
  1101. CGuildManager::instance().ReserveWar (p->dwGuildFrom, p->dwGuildTo, p->bType);
  1102. break;
  1103. default:
  1104. sys_err ("Unknown guild war state");
  1105. break;
  1106. }
  1107. }
  1108. void CInputDB::GuildWarScore (const char* c_pData)
  1109. {
  1110. TPacketGuildWarScore* p = (TPacketGuildWarScore*) c_pData;
  1111. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuildGainPoint);
  1112. g->SetWarScoreAgainstTo (p->dwGuildOpponent, p->lScore);
  1113. }
  1114. void CInputDB::GuildSkillRecharge()
  1115. {
  1116. CGuildManager::instance().SkillRecharge();
  1117. }
  1118. void CInputDB::GuildExpUpdate (const char* c_pData)
  1119. {
  1120. TPacketGuildSkillUpdate* p = (TPacketGuildSkillUpdate*) c_pData;
  1121. sys_log (1, "GuildExpUpdate %d", p->amount);
  1122. CGuild* g = CGuildManager::instance().TouchGuild (p->guild_id);
  1123. if (g)
  1124. {
  1125. g->GuildPointChange (POINT_EXP, p->amount);
  1126. }
  1127. }
  1128. void CInputDB::GuildAddMember (const char* c_pData)
  1129. {
  1130. TPacketDGGuildMember* p = (TPacketDGGuildMember*) c_pData;
  1131. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1132. if (g)
  1133. {
  1134. g->AddMember (p);
  1135. }
  1136. }
  1137. void CInputDB::GuildRemoveMember (const char* c_pData)
  1138. {
  1139. TPacketGuild* p= (TPacketGuild*)c_pData;
  1140. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1141. if (g)
  1142. {
  1143. g->RemoveMember (p->dwInfo);
  1144. }
  1145. }
  1146. void CInputDB::GuildChangeGrade (const char* c_pData)
  1147. {
  1148. TPacketGuild* p= (TPacketGuild*)c_pData;
  1149. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1150. if (g)
  1151. {
  1152. g->P2PChangeGrade ((BYTE)p->dwInfo);
  1153. }
  1154. }
  1155. void CInputDB::GuildChangeMemberData (const char* c_pData)
  1156. {
  1157. sys_log (0, "Recv GuildChangeMemberData");
  1158. TPacketGuildChangeMemberData* p = (TPacketGuildChangeMemberData*) c_pData;
  1159. CGuild* g = CGuildManager::instance().TouchGuild (p->guild_id);
  1160. if (g)
  1161. {
  1162. g->ChangeMemberData (p->pid, p->offer, p->level, p->grade);
  1163. }
  1164. }
  1165. void CInputDB::GuildDisband (const char* c_pData)
  1166. {
  1167. TPacketGuild* p = (TPacketGuild*) c_pData;
  1168. CGuildManager::instance().DisbandGuild (p->dwGuild);
  1169. }
  1170. void CInputDB::GuildLadder (const char* c_pData)
  1171. {
  1172. TPacketGuildLadder* p = (TPacketGuildLadder*) c_pData;
  1173. sys_log (0, "Recv GuildLadder %u %d / w %d d %d l %d", p->dwGuild, p->lLadderPoint, p->lWin, p->lDraw, p->lLoss);
  1174. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1175. g->SetLadderPoint (p->lLadderPoint);
  1176. g->SetWarData (p->lWin, p->lDraw, p->lLoss);
  1177. }
  1178. void CInputDB::ItemLoad (LPDESC d, const char* c_pData)
  1179. {
  1180. LPCHARACTER ch;
  1181. if (!d || ! (ch = d->GetCharacter()))
  1182. {
  1183. return;
  1184. }
  1185. if (ch->IsItemLoaded())
  1186. {
  1187. return;
  1188. }
  1189. DWORD dwCount = decode_4bytes (c_pData);
  1190. c_pData += sizeof (DWORD);
  1191. sys_log (0, "ITEM_LOAD: COUNT %s %u", ch->GetName(), dwCount);
  1192. std::vector<LPITEM> v;
  1193. TPlayerItem* p = (TPlayerItem*) c_pData;
  1194. for (DWORD i = 0; i < dwCount; ++i, ++p)
  1195. {
  1196. LPITEM item = ITEM_MANAGER::instance().CreateItem (p->vnum, p->count, p->id);
  1197. if (!item)
  1198. {
  1199. sys_err ("cannot create item by vnum %u (name %s id %u)", p->vnum, ch->GetName(), p->id);
  1200. continue;
  1201. }
  1202. item->SetSkipSave (true);
  1203. item->SetSockets (p->alSockets);
  1204. item->SetAttributes (p->aAttr);
  1205. if ((p->window == INVENTORY && ch->GetInventoryItem (p->pos)) ||
  1206. (p->window == EQUIPMENT && ch->GetWear (p->pos)))
  1207. {
  1208. sys_log (0, "ITEM_RESTORE: %s %s", ch->GetName(), item->GetName());
  1209. v.push_back (item);
  1210. }
  1211. else
  1212. {
  1213. switch (p->window)
  1214. {
  1215. case INVENTORY:
  1216. case DRAGON_SOUL_INVENTORY:
  1217. item->AddToCharacter (ch, TItemPos (p->window, p->pos));
  1218. break;
  1219. case EQUIPMENT:
  1220. if (item->CheckItemUseLevel (ch->GetLevel()) == true)
  1221. {
  1222. if (item->EquipTo (ch, p->pos) == false)
  1223. {
  1224. v.push_back (item);
  1225. }
  1226. }
  1227. else
  1228. {
  1229. v.push_back (item);
  1230. }
  1231. break;
  1232. }
  1233. }
  1234. if (false == item->OnAfterCreatedItem())
  1235. {
  1236. sys_err ("Failed to call ITEM::OnAfterCreatedItem (vnum: %d, id: %d)", item->GetVnum(), item->GetID());
  1237. }
  1238. item->SetSkipSave (false);
  1239. }
  1240. itertype (v) it = v.begin();
  1241. while (it != v.end())
  1242. {
  1243. LPITEM item = * (it++);
  1244. int pos = ch->GetEmptyInventory (item->GetSize());
  1245. if (pos < 0)
  1246. {
  1247. PIXEL_POSITION coord;
  1248. coord.x = ch->GetX();
  1249. coord.y = ch->GetY();
  1250. item->AddToGround (ch->GetMapIndex(), coord);
  1251. item->SetOwnership (ch, 180);
  1252. item->StartDestroyEvent();
  1253. }
  1254. else
  1255. {
  1256. item->AddToCharacter (ch, TItemPos (INVENTORY, pos));
  1257. }
  1258. }
  1259. ch->CheckMaximumPoints();
  1260. ch->PointsPacket();
  1261. ch->SetItemLoaded();
  1262. }
  1263. void CInputDB::AffectLoad (LPDESC d, const char* c_pData)
  1264. {
  1265. if (!d)
  1266. {
  1267. return;
  1268. }
  1269. if (!d->GetCharacter())
  1270. {
  1271. return;
  1272. }
  1273. LPCHARACTER ch = d->GetCharacter();
  1274. DWORD dwPID = decode_4bytes (c_pData);
  1275. c_pData += sizeof (DWORD);
  1276. DWORD dwCount = decode_4bytes (c_pData);
  1277. c_pData += sizeof (DWORD);
  1278. if (ch->GetPlayerID() != dwPID)
  1279. {
  1280. return;
  1281. }
  1282. ch->LoadAffect (dwCount, (TPacketAffectElement*) c_pData);
  1283. }
  1284. void CInputDB::PartyCreate (const char* c_pData)
  1285. {
  1286. TPacketPartyCreate* p = (TPacketPartyCreate*) c_pData;
  1287. CPartyManager::instance().P2PCreateParty (p->dwLeaderPID);
  1288. }
  1289. void CInputDB::PartyDelete (const char* c_pData)
  1290. {
  1291. TPacketPartyDelete* p = (TPacketPartyDelete*) c_pData;
  1292. CPartyManager::instance().P2PDeleteParty (p->dwLeaderPID);
  1293. }
  1294. void CInputDB::PartyAdd (const char* c_pData)
  1295. {
  1296. TPacketPartyAdd* p = (TPacketPartyAdd*) c_pData;
  1297. CPartyManager::instance().P2PJoinParty (p->dwLeaderPID, p->dwPID, p->bState);
  1298. }
  1299. void CInputDB::PartyRemove (const char* c_pData)
  1300. {
  1301. TPacketPartyRemove* p = (TPacketPartyRemove*) c_pData;
  1302. CPartyManager::instance().P2PQuitParty (p->dwPID);
  1303. }
  1304. void CInputDB::PartyStateChange (const char* c_pData)
  1305. {
  1306. TPacketPartyStateChange* p = (TPacketPartyStateChange*) c_pData;
  1307. LPPARTY pParty = CPartyManager::instance().P2PCreateParty (p->dwLeaderPID);
  1308. if (!pParty)
  1309. {
  1310. return;
  1311. }
  1312. pParty->SetRole (p->dwPID, p->bRole, p->bFlag);
  1313. }
  1314. void CInputDB::PartySetMemberLevel (const char* c_pData)
  1315. {
  1316. TPacketPartySetMemberLevel* p = (TPacketPartySetMemberLevel*) c_pData;
  1317. LPPARTY pParty = CPartyManager::instance().P2PCreateParty (p->dwLeaderPID);
  1318. if (!pParty)
  1319. {
  1320. return;
  1321. }
  1322. pParty->P2PSetMemberLevel (p->dwPID, p->bLevel);
  1323. }
  1324. void CInputDB::Time (const char* c_pData)
  1325. {
  1326. set_global_time (* (time_t*) c_pData);
  1327. }
  1328. void CInputDB::ReloadProto (const char* c_pData)
  1329. {
  1330. WORD wSize;
  1331. /*
  1332. * Skill
  1333. */
  1334. wSize = decode_2bytes (c_pData);
  1335. c_pData += sizeof (WORD);
  1336. if (wSize)
  1337. {
  1338. CSkillManager::instance().Initialize ((TSkillTable*) c_pData, wSize);
  1339. }
  1340. c_pData += sizeof (TSkillTable) * wSize;
  1341. /*
  1342. * Banwords
  1343. */
  1344. wSize = decode_2bytes (c_pData);
  1345. c_pData += sizeof (WORD);
  1346. CBanwordManager::instance().Initialize ((TBanwordTable*) c_pData, wSize);
  1347. c_pData += sizeof (TBanwordTable) * wSize;
  1348. /*
  1349. * ITEM
  1350. */
  1351. wSize = decode_2bytes (c_pData);
  1352. c_pData += 2;
  1353. sys_log (0, "RELOAD: ITEM: %d", wSize);
  1354. if (wSize)
  1355. {
  1356. ITEM_MANAGER::instance().Initialize ((TItemTable*) c_pData, wSize);
  1357. c_pData += wSize * sizeof (TItemTable);
  1358. }
  1359. /*
  1360. * MONSTER
  1361. */
  1362. wSize = decode_2bytes (c_pData);
  1363. c_pData += 2;
  1364. sys_log (0, "RELOAD: MOB: %d", wSize);
  1365. if (wSize)
  1366. {
  1367. CMobManager::instance().Initialize ((TMobTable*) c_pData, wSize);
  1368. c_pData += wSize * sizeof (TMobTable);
  1369. }
  1370. CMotionManager::instance().Build();
  1371. CHARACTER_MANAGER::instance().for_each_pc (std::mem_fn (&CHARACTER::ComputePoints));
  1372. }
  1373. void CInputDB::GuildSkillUsableChange (const char* c_pData)
  1374. {
  1375. TPacketGuildSkillUsableChange* p = (TPacketGuildSkillUsableChange*) c_pData;
  1376. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1377. g->SkillUsableChange (p->dwSkillVnum, p->bUsable?true:false);
  1378. }
  1379. void CInputDB::AuthLogin (LPDESC d, const char* c_pData)
  1380. {
  1381. if (!d)
  1382. {
  1383. return;
  1384. }
  1385. BYTE bResult = * (BYTE*) c_pData;
  1386. TPacketGCAuthSuccess ptoc;
  1387. ptoc.bHeader = HEADER_GC_AUTH_SUCCESS;
  1388. if (bResult)
  1389. {
  1390. // Panama ��ȣȭ �ѿ� �ʿ��� Ű ������
  1391. SendPanamaList (d);
  1392. ptoc.dwLoginKey = d->GetLoginKey();
  1393. //NOTE: AuthSucess���� ���� �������� �ȱ׷��� PHASE Close�� �Ǽ� �������� �ʴ´�.-_-
  1394. //Send Client Package CryptKey
  1395. {
  1396. DESC_MANAGER::instance().SendClientPackageCryptKey (d);
  1397. DESC_MANAGER::instance().SendClientPackageSDBToLoadMap (d, MAPNAME_DEFAULT);
  1398. }
  1399. }
  1400. else
  1401. {
  1402. ptoc.dwLoginKey = 0;
  1403. }
  1404. ptoc.bResult = bResult;
  1405. d->Packet (&ptoc, sizeof (TPacketGCAuthSuccess));
  1406. sys_log (0, "AuthLogin result %u key %u", bResult, d->GetLoginKey());
  1407. }
  1408. void CInputDB::ChangeEmpirePriv (const char* c_pData)
  1409. {
  1410. TPacketDGChangeEmpirePriv* p = (TPacketDGChangeEmpirePriv*) c_pData;
  1411. // ADD_EMPIRE_PRIV_TIME
  1412. CPrivManager::instance().GiveEmpirePriv (p->empire, p->type, p->value, p->bLog, p->end_time_sec);
  1413. // END_OF_ADD_EMPIRE_PRIV_TIME
  1414. }
  1415. /**
  1416. * @version 05/06/08 Bang2ni - ���ӽð� �߰�
  1417. */
  1418. void CInputDB::ChangeGuildPriv (const char* c_pData)
  1419. {
  1420. TPacketDGChangeGuildPriv* p = (TPacketDGChangeGuildPriv*) c_pData;
  1421. // ADD_GUILD_PRIV_TIME
  1422. CPrivManager::instance().GiveGuildPriv (p->guild_id, p->type, p->value, p->bLog, p->end_time_sec);
  1423. // END_OF_ADD_GUILD_PRIV_TIME
  1424. }
  1425. void CInputDB::ChangeCharacterPriv (const char* c_pData)
  1426. {
  1427. TPacketDGChangeCharacterPriv* p = (TPacketDGChangeCharacterPriv*) c_pData;
  1428. CPrivManager::instance().GiveCharacterPriv (p->pid, p->type, p->value, p->bLog);
  1429. }
  1430. void CInputDB::MoneyLog (const char* c_pData)
  1431. {
  1432. TPacketMoneyLog* p = (TPacketMoneyLog*) c_pData;
  1433. if (p->type == 4) // QUEST_MONEY_LOG_SKIP
  1434. {
  1435. return;
  1436. }
  1437. if (g_bAuthServer ==true)
  1438. {
  1439. return;
  1440. }
  1441. LogManager::instance().MoneyLog (p->type, p->vnum, p->gold);
  1442. }
  1443. void CInputDB::GuildMoneyChange (const char* c_pData)
  1444. {
  1445. TPacketDGGuildMoneyChange* p = (TPacketDGGuildMoneyChange*) c_pData;
  1446. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1447. if (g)
  1448. {
  1449. g->RecvMoneyChange (p->iTotalGold);
  1450. }
  1451. }
  1452. void CInputDB::GuildWithdrawMoney (const char* c_pData)
  1453. {
  1454. TPacketDGGuildMoneyWithdraw* p = (TPacketDGGuildMoneyWithdraw*) c_pData;
  1455. CGuild* g = CGuildManager::instance().TouchGuild (p->dwGuild);
  1456. if (g)
  1457. {
  1458. g->RecvWithdrawMoneyGive (p->iChangeGold);
  1459. }
  1460. }
  1461. void CInputDB::SetEventFlag (const char* c_pData)
  1462. {
  1463. TPacketSetEventFlag* p = (TPacketSetEventFlag*) c_pData;
  1464. quest::CQuestManager::instance().SetEventFlag (p->szFlagName, p->lValue);
  1465. }
  1466. void CInputDB::CreateObject (const char* c_pData)
  1467. {
  1468. using namespace building;
  1469. CManager::instance().LoadObject ((TObject*) c_pData);
  1470. }
  1471. void CInputDB::DeleteObject (const char* c_pData)
  1472. {
  1473. using namespace building;
  1474. CManager::instance().DeleteObject (* (DWORD*) c_pData);
  1475. }
  1476. void CInputDB::UpdateLand (const char* c_pData)
  1477. {
  1478. using namespace building;
  1479. CManager::instance().UpdateLand ((TLand*) c_pData);
  1480. }
  1481. ////////////////////////////////////////////////////////////////////
  1482. // Billing
  1483. ////////////////////////////////////////////////////////////////////
  1484. void CInputDB::BillingRepair (const char* c_pData)
  1485. {
  1486. DWORD dwCount = * (DWORD*) c_pData;
  1487. c_pData += sizeof (DWORD);
  1488. TPacketBillingRepair* p = (TPacketBillingRepair*) c_pData;
  1489. for (DWORD i = 0; i < dwCount; ++i, ++p)
  1490. {
  1491. CLoginData* pkLD = M2_NEW CLoginData;
  1492. pkLD->SetKey (p->dwLoginKey);
  1493. pkLD->SetLogin (p->szLogin);
  1494. pkLD->SetIP (p->szHost);
  1495. sys_log (0, "BILLING: REPAIR %s host %s", p->szLogin, p->szHost);
  1496. }
  1497. }
  1498. void CInputDB::BillingExpire (const char* c_pData)
  1499. {
  1500. TPacketBillingExpire* p = (TPacketBillingExpire*) c_pData;
  1501. LPDESC d = DESC_MANAGER::instance().FindByLoginName (p->szLogin);
  1502. if (!d)
  1503. {
  1504. return;
  1505. }
  1506. LPCHARACTER ch = d->GetCharacter();
  1507. if (p->dwRemainSeconds <= 60)
  1508. {
  1509. int i = MAX (5, p->dwRemainSeconds);
  1510. sys_log (0, "BILLING_EXPIRE: %s %u", p->szLogin, p->dwRemainSeconds);
  1511. d->DelayedDisconnect (i);
  1512. }
  1513. else
  1514. {
  1515. if ((p->dwRemainSeconds - d->GetBillingExpireSecond()) > 60)
  1516. {
  1517. d->SetBillingExpireSecond (p->dwRemainSeconds);
  1518. if (ch)
  1519. {
  1520. ch->ChatPacket (CHAT_TYPE_INFO, "[LS;776;%d]", (p->dwRemainSeconds / 60));
  1521. }
  1522. }
  1523. }
  1524. }
  1525. void CInputDB::BillingLogin (const char* c_pData)
  1526. {
  1527. if (NULL == c_pData)
  1528. {
  1529. return;
  1530. }
  1531. TPacketBillingLogin* p;
  1532. DWORD dwCount = * (DWORD*) c_pData;
  1533. c_pData += sizeof (DWORD);
  1534. p = (TPacketBillingLogin*) c_pData;
  1535. for (DWORD i = 0; i < dwCount; ++i, ++p)
  1536. {
  1537. DBManager::instance().SetBilling (p->dwLoginKey, p->bLogin);
  1538. }
  1539. }
  1540. void CInputDB::BillingCheck (const char* c_pData)
  1541. {
  1542. DWORD size = * (DWORD*) c_pData;
  1543. c_pData += sizeof (DWORD);
  1544. for (DWORD i = 0; i < size; ++i)
  1545. {
  1546. DWORD dwKey = * (DWORD*) c_pData;
  1547. c_pData += sizeof (DWORD);
  1548. sys_log (0, "BILLING: NOT_LOGIN %u", dwKey);
  1549. DBManager::instance().SetBilling (dwKey, 0, true);
  1550. }
  1551. }
  1552. void CInputDB::Notice (const char* c_pData)
  1553. {
  1554. extern void SendNotice (const char* c_pszBuf);
  1555. char szBuf[256+1];
  1556. strlcpy (szBuf, c_pData, sizeof (szBuf));
  1557. sys_log (0, "InputDB:: Notice: %s", szBuf);
  1558. //SendNotice(LC_TEXT(szBuf));
  1559. SendNotice (szBuf);
  1560. }
  1561. void CInputDB::GuildWarReserveAdd (TGuildWarReserve* p)
  1562. {
  1563. CGuildManager::instance().ReserveWarAdd (p);
  1564. }
  1565. void CInputDB::GuildWarReserveDelete (DWORD dwID)
  1566. {
  1567. CGuildManager::instance().ReserveWarDelete (dwID);
  1568. }
  1569. void CInputDB::GuildWarBet (TPacketGDGuildWarBet* p)
  1570. {
  1571. CGuildManager::instance().ReserveWarBet (p);
  1572. }
  1573. void CInputDB::MarriageAdd (TPacketMarriageAdd* p)
  1574. {
  1575. sys_log (0, "MarriageAdd %u %u %u %s %s", p->dwPID1, p->dwPID2, (DWORD)p->tMarryTime, p->szName1, p->szName2);
  1576. marriage::CManager::instance().Add (p->dwPID1, p->dwPID2, p->tMarryTime, p->szName1, p->szName2);
  1577. }
  1578. void CInputDB::MarriageUpdate (TPacketMarriageUpdate* p)
  1579. {
  1580. sys_log (0, "MarriageUpdate %u %u %d %d", p->dwPID1, p->dwPID2, p->iLovePoint, p->byMarried);
  1581. marriage::CManager::instance().Update (p->dwPID1, p->dwPID2, p->iLovePoint, p->byMarried);
  1582. }
  1583. void CInputDB::MarriageRemove (TPacketMarriageRemove* p)
  1584. {
  1585. sys_log (0, "MarriageRemove %u %u", p->dwPID1, p->dwPID2);
  1586. marriage::CManager::instance().Remove (p->dwPID1, p->dwPID2);
  1587. }
  1588. void CInputDB::WeddingRequest (TPacketWeddingRequest* p)
  1589. {
  1590. marriage::WeddingManager::instance().Request (p->dwPID1, p->dwPID2);
  1591. }
  1592. void CInputDB::WeddingReady (TPacketWeddingReady* p)
  1593. {
  1594. sys_log (0, "WeddingReady %u %u %u", p->dwPID1, p->dwPID2, p->dwMapIndex);
  1595. marriage::CManager::instance().WeddingReady (p->dwPID1, p->dwPID2, p->dwMapIndex);
  1596. }
  1597. void CInputDB::WeddingStart (TPacketWeddingStart* p)
  1598. {
  1599. sys_log (0, "WeddingStart %u %u", p->dwPID1, p->dwPID2);
  1600. marriage::CManager::instance().WeddingStart (p->dwPID1, p->dwPID2);
  1601. }
  1602. void CInputDB::WeddingEnd (TPacketWeddingEnd* p)
  1603. {
  1604. sys_log (0, "WeddingEnd %u %u", p->dwPID1, p->dwPID2);
  1605. marriage::CManager::instance().WeddingEnd (p->dwPID1, p->dwPID2);
  1606. }
  1607. // MYSHOP_PRICE_LIST
  1608. void CInputDB::MyshopPricelistRes (LPDESC d, const TPacketMyshopPricelistHeader* p)
  1609. {
  1610. LPCHARACTER ch;
  1611. if (!d || ! (ch = d->GetCharacter()))
  1612. {
  1613. return;
  1614. }
  1615. sys_log (0, "RecvMyshopPricelistRes name[%s]", ch->GetName());
  1616. ch->UseSilkBotaryReal (p);
  1617. }
  1618. // END_OF_MYSHOP_PRICE_LIST
  1619. //RELOAD_ADMIN
  1620. void CInputDB::ReloadAdmin (const char* c_pData)
  1621. {
  1622. gm_new_clear();
  1623. int ChunkSize = decode_2bytes (c_pData);
  1624. c_pData += 2;
  1625. int HostSize = decode_2bytes (c_pData);
  1626. c_pData += 2;
  1627. for (int n = 0; n < HostSize; ++n)
  1628. {
  1629. gm_new_host_inert (c_pData);
  1630. c_pData += ChunkSize;
  1631. }
  1632. c_pData += 2;
  1633. int size = decode_2bytes (c_pData);
  1634. c_pData += 2;
  1635. for (int n = 0; n < size; ++n)
  1636. {
  1637. tAdminInfo& rAdminInfo = * (tAdminInfo*)c_pData;
  1638. gm_new_insert (rAdminInfo);
  1639. c_pData += sizeof (tAdminInfo);
  1640. LPCHARACTER pChar = CHARACTER_MANAGER::instance().FindPC (rAdminInfo.m_szName);
  1641. if (pChar)
  1642. {
  1643. pChar->SetGMLevel();
  1644. }
  1645. }
  1646. }
  1647. //END_RELOAD_ADMIN
  1648. ////////////////////////////////////////////////////////////////////
  1649. // Analyze
  1650. // @version 05/06/10 Bang2ni - ������ �������� ����Ʈ ��Ŷ(HEADER_DG_MYSHOP_PRICELIST_RES) ó����ƾ �߰�.
  1651. ////////////////////////////////////////////////////////////////////
  1652. int CInputDB::Analyze (LPDESC d, BYTE bHeader, const char* c_pData)
  1653. {
  1654. switch (bHeader)
  1655. {
  1656. case HEADER_DG_BOOT:
  1657. Boot (c_pData);
  1658. break;
  1659. case HEADER_DG_LOGIN_SUCCESS:
  1660. LoginSuccess (m_dwHandle, c_pData);
  1661. break;
  1662. case HEADER_DG_LOGIN_NOT_EXIST:
  1663. LoginFailure (DESC_MANAGER::instance().FindByHandle (m_dwHandle), "NOID");
  1664. break;
  1665. case HEADER_DG_LOGIN_WRONG_PASSWD:
  1666. LoginFailure (DESC_MANAGER::instance().FindByHandle (m_dwHandle), "WRONGPWD");
  1667. break;
  1668. case HEADER_DG_LOGIN_ALREADY:
  1669. LoginAlready (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1670. break;
  1671. case HEADER_DG_PLAYER_LOAD_SUCCESS:
  1672. PlayerLoad (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1673. break;
  1674. case HEADER_DG_PLAYER_CREATE_SUCCESS:
  1675. PlayerCreateSuccess (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1676. break;
  1677. case HEADER_DG_PLAYER_CREATE_FAILED:
  1678. PlayerCreateFailure (DESC_MANAGER::instance().FindByHandle (m_dwHandle), 0);
  1679. break;
  1680. case HEADER_DG_PLAYER_CREATE_ALREADY:
  1681. PlayerCreateFailure (DESC_MANAGER::instance().FindByHandle (m_dwHandle), 1);
  1682. break;
  1683. case HEADER_DG_PLAYER_DELETE_SUCCESS:
  1684. PlayerDeleteSuccess (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1685. break;
  1686. case HEADER_DG_PLAYER_LOAD_FAILED:
  1687. //sys_log(0, "PLAYER_LOAD_FAILED");
  1688. break;
  1689. case HEADER_DG_PLAYER_DELETE_FAILED:
  1690. //sys_log(0, "PLAYER_DELETE_FAILED");
  1691. PlayerDeleteFail (DESC_MANAGER::instance().FindByHandle (m_dwHandle));
  1692. break;
  1693. case HEADER_DG_ITEM_LOAD:
  1694. ItemLoad (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1695. break;
  1696. case HEADER_DG_QUEST_LOAD:
  1697. QuestLoad (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1698. break;
  1699. case HEADER_DG_AFFECT_LOAD:
  1700. AffectLoad (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1701. break;
  1702. case HEADER_DG_SAFEBOX_LOAD:
  1703. SafeboxLoad (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1704. break;
  1705. case HEADER_DG_SAFEBOX_CHANGE_SIZE:
  1706. SafeboxChangeSize (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1707. break;
  1708. case HEADER_DG_SAFEBOX_WRONG_PASSWORD:
  1709. SafeboxWrongPassword (DESC_MANAGER::instance().FindByHandle (m_dwHandle));
  1710. break;
  1711. case HEADER_DG_SAFEBOX_CHANGE_PASSWORD_ANSWER:
  1712. SafeboxChangePasswordAnswer (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1713. break;
  1714. case HEADER_DG_MALL_LOAD:
  1715. MallLoad (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1716. break;
  1717. case HEADER_DG_EMPIRE_SELECT:
  1718. EmpireSelect (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1719. break;
  1720. case HEADER_DG_MAP_LOCATIONS:
  1721. MapLocations (c_pData);
  1722. break;
  1723. case HEADER_DG_P2P:
  1724. P2P (c_pData);
  1725. break;
  1726. case HEADER_DG_GUILD_SKILL_UPDATE:
  1727. GuildSkillUpdate (c_pData);
  1728. break;
  1729. case HEADER_DG_GUILD_LOAD:
  1730. GuildLoad (c_pData);
  1731. break;
  1732. case HEADER_DG_GUILD_SKILL_RECHARGE:
  1733. GuildSkillRecharge();
  1734. break;
  1735. case HEADER_DG_GUILD_EXP_UPDATE:
  1736. GuildExpUpdate (c_pData);
  1737. break;
  1738. case HEADER_DG_PARTY_CREATE:
  1739. PartyCreate (c_pData);
  1740. break;
  1741. case HEADER_DG_PARTY_DELETE:
  1742. PartyDelete (c_pData);
  1743. break;
  1744. case HEADER_DG_PARTY_ADD:
  1745. PartyAdd (c_pData);
  1746. break;
  1747. case HEADER_DG_PARTY_REMOVE:
  1748. PartyRemove (c_pData);
  1749. break;
  1750. case HEADER_DG_PARTY_STATE_CHANGE:
  1751. PartyStateChange (c_pData);
  1752. break;
  1753. case HEADER_DG_PARTY_SET_MEMBER_LEVEL:
  1754. PartySetMemberLevel (c_pData);
  1755. break;
  1756. case HEADER_DG_TIME:
  1757. Time (c_pData);
  1758. break;
  1759. case HEADER_DG_GUILD_ADD_MEMBER:
  1760. GuildAddMember (c_pData);
  1761. break;
  1762. case HEADER_DG_GUILD_REMOVE_MEMBER:
  1763. GuildRemoveMember (c_pData);
  1764. break;
  1765. case HEADER_DG_GUILD_CHANGE_GRADE:
  1766. GuildChangeGrade (c_pData);
  1767. break;
  1768. case HEADER_DG_GUILD_CHANGE_MEMBER_DATA:
  1769. GuildChangeMemberData (c_pData);
  1770. break;
  1771. case HEADER_DG_GUILD_DISBAND:
  1772. GuildDisband (c_pData);
  1773. break;
  1774. case HEADER_DG_RELOAD_PROTO:
  1775. ReloadProto (c_pData);
  1776. break;
  1777. case HEADER_DG_GUILD_WAR:
  1778. GuildWar (c_pData);
  1779. break;
  1780. case HEADER_DG_GUILD_WAR_SCORE:
  1781. GuildWarScore (c_pData);
  1782. break;
  1783. case HEADER_DG_GUILD_LADDER:
  1784. GuildLadder (c_pData);
  1785. break;
  1786. case HEADER_DG_GUILD_SKILL_USABLE_CHANGE:
  1787. GuildSkillUsableChange (c_pData);
  1788. break;
  1789. case HEADER_DG_CHANGE_NAME:
  1790. ChangeName (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1791. break;
  1792. case HEADER_DG_AUTH_LOGIN:
  1793. AuthLogin (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1794. break;
  1795. case HEADER_DG_CHANGE_EMPIRE_PRIV:
  1796. ChangeEmpirePriv (c_pData);
  1797. break;
  1798. case HEADER_DG_CHANGE_GUILD_PRIV:
  1799. ChangeGuildPriv (c_pData);
  1800. break;
  1801. case HEADER_DG_CHANGE_CHARACTER_PRIV:
  1802. ChangeCharacterPriv (c_pData);
  1803. break;
  1804. case HEADER_DG_MONEY_LOG:
  1805. MoneyLog (c_pData);
  1806. break;
  1807. case HEADER_DG_GUILD_WITHDRAW_MONEY_GIVE:
  1808. GuildWithdrawMoney (c_pData);
  1809. break;
  1810. case HEADER_DG_GUILD_MONEY_CHANGE:
  1811. GuildMoneyChange (c_pData);
  1812. break;
  1813. case HEADER_DG_SET_EVENT_FLAG:
  1814. SetEventFlag (c_pData);
  1815. break;
  1816. case HEADER_DG_BILLING_REPAIR:
  1817. BillingRepair (c_pData);
  1818. break;
  1819. case HEADER_DG_BILLING_EXPIRE:
  1820. BillingExpire (c_pData);
  1821. break;
  1822. case HEADER_DG_BILLING_LOGIN:
  1823. BillingLogin (c_pData);
  1824. break;
  1825. case HEADER_DG_BILLING_CHECK:
  1826. BillingCheck (c_pData);
  1827. break;
  1828. case HEADER_DG_CREATE_OBJECT:
  1829. CreateObject (c_pData);
  1830. break;
  1831. case HEADER_DG_DELETE_OBJECT:
  1832. DeleteObject (c_pData);
  1833. break;
  1834. case HEADER_DG_UPDATE_LAND:
  1835. UpdateLand (c_pData);
  1836. break;
  1837. case HEADER_DG_NOTICE:
  1838. Notice (c_pData);
  1839. break;
  1840. case HEADER_DG_GUILD_WAR_RESERVE_ADD:
  1841. GuildWarReserveAdd ((TGuildWarReserve*) c_pData);
  1842. break;
  1843. case HEADER_DG_GUILD_WAR_RESERVE_DEL:
  1844. GuildWarReserveDelete (* (DWORD*) c_pData);
  1845. break;
  1846. case HEADER_DG_GUILD_WAR_BET:
  1847. GuildWarBet ((TPacketGDGuildWarBet*) c_pData);
  1848. break;
  1849. case HEADER_DG_MARRIAGE_ADD:
  1850. MarriageAdd ((TPacketMarriageAdd*) c_pData);
  1851. break;
  1852. case HEADER_DG_MARRIAGE_UPDATE:
  1853. MarriageUpdate ((TPacketMarriageUpdate*) c_pData);
  1854. break;
  1855. case HEADER_DG_MARRIAGE_REMOVE:
  1856. MarriageRemove ((TPacketMarriageRemove*) c_pData);
  1857. break;
  1858. case HEADER_DG_WEDDING_REQUEST:
  1859. WeddingRequest ((TPacketWeddingRequest*) c_pData);
  1860. break;
  1861. case HEADER_DG_WEDDING_READY:
  1862. WeddingReady ((TPacketWeddingReady*) c_pData);
  1863. break;
  1864. case HEADER_DG_WEDDING_START:
  1865. WeddingStart ((TPacketWeddingStart*) c_pData);
  1866. break;
  1867. case HEADER_DG_WEDDING_END:
  1868. WeddingEnd ((TPacketWeddingEnd*) c_pData);
  1869. break;
  1870. // MYSHOP_PRICE_LIST
  1871. case HEADER_DG_MYSHOP_PRICELIST_RES:
  1872. MyshopPricelistRes (DESC_MANAGER::instance().FindByHandle (m_dwHandle), (TPacketMyshopPricelistHeader*) c_pData);
  1873. break;
  1874. // END_OF_MYSHOP_PRICE_LIST
  1875. //
  1876. // RELOAD_ADMIN
  1877. case HEADER_DG_RELOAD_ADMIN:
  1878. ReloadAdmin (c_pData);
  1879. break;
  1880. //END_RELOAD_ADMIN
  1881. case HEADER_DG_ACK_CHANGE_GUILD_MASTER :
  1882. this->GuildChangeMaster ((TPacketChangeGuildMaster*) c_pData);
  1883. break;
  1884. case HEADER_DG_ACK_SPARE_ITEM_ID_RANGE :
  1885. ITEM_MANAGER::instance().SetMaxSpareItemID (* ((TItemIDRangeTable*)c_pData));
  1886. break;
  1887. case HEADER_DG_UPDATE_HORSE_NAME :
  1888. case HEADER_DG_ACK_HORSE_NAME :
  1889. CHorseNameManager::instance().UpdateHorseName (
  1890. ((TPacketUpdateHorseName*)c_pData)->dwPlayerID,
  1891. ((TPacketUpdateHorseName*)c_pData)->szHorseName);
  1892. break;
  1893. case HEADER_DG_NEED_LOGIN_LOG:
  1894. DetailLog ((TPacketNeedLoginLogInfo*) c_pData);
  1895. break;
  1896. // ���� ���� ��� �׽�Ʈ
  1897. case HEADER_DG_ITEMAWARD_INFORMER:
  1898. ItemAwardInformer ((TPacketItemAwardInfromer*) c_pData);
  1899. break;
  1900. case HEADER_DG_RESPOND_CHANNELSTATUS:
  1901. RespondChannelStatus (DESC_MANAGER::instance().FindByHandle (m_dwHandle), c_pData);
  1902. break;
  1903. #ifdef __ENABLE_NEW_OFFLINESHOP__
  1904. case HEADER_DG_NEW_OFFLINESHOP:
  1905. OfflineshopPacket(c_pData);
  1906. break;
  1907. #endif
  1908. default:
  1909. return (-1);
  1910. }
  1911. return 0;
  1912. }
  1913. #ifdef __ENABLE_NEW_OFFLINESHOP__
  1914. template <class T>
  1915. const char* Decode(T*& pObj, const char* data)
  1916. {
  1917. pObj = (T*) data;
  1918. return data + sizeof(T);
  1919. }
  1920. void OfflineShopLoadTables(const char* data)
  1921. {
  1922. offlineshop::TSubPacketDGLoadTables* pSubPack = nullptr;
  1923. data = Decode(pSubPack, data);
  1924. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  1925. OFFSHOP_DEBUG("shop count %u , offer count %u , auction count %u, auction offers %u ",pSubPack->dwShopCount , pSubPack->dwOfferCount, pSubPack->dwAuctionCount , pSubPack->dwAuctionOfferCount);
  1926. for (DWORD i = 0; i < pSubPack->dwShopCount; i++)
  1927. {
  1928. offlineshop::TShopInfo* pShop = nullptr;
  1929. #ifdef ENABLE_IRA_REWORK
  1930. offlineshop::TShopPosition* pShopPos = nullptr;
  1931. #endif
  1932. offlineshop::TItemInfo* pItem = nullptr;
  1933. DWORD* pdwSoldCount= nullptr;
  1934. data = Decode(pShop, data);
  1935. #ifdef ENABLE_IRA_REWORK
  1936. data = Decode(pShopPos, data);
  1937. #endif
  1938. data = Decode(pdwSoldCount, data);
  1939. OFFSHOP_DEBUG("shop %u %s (solds %u) ",pShop->dwOwnerID , pShop->szName , *pdwSoldCount);
  1940. #ifdef ENABLE_IRA_REWORK
  1941. offlineshop::CShop* pkShop = rManager.PutsNewShop(pShop, pShopPos);
  1942. #else
  1943. offlineshop::CShop* pkShop = rManager.PutsNewShop(pShop);
  1944. #endif
  1945. for (DWORD j = 0; j < pShop->dwCount; j++)
  1946. {
  1947. data = Decode(pItem, data);
  1948. offlineshop::CShopItem kItem(pItem->dwItemID);
  1949. kItem.SetOwnerID(pItem->dwOwnerID);
  1950. kItem.SetInfo(pItem->item);
  1951. kItem.SetPrice(pItem->price);
  1952. kItem.SetWindow(NEW_OFFSHOP);
  1953. OFFSHOP_DEBUG("for sale item %u ",pItem->dwItemID);
  1954. pkShop->AddItem(kItem);
  1955. }
  1956. for (DWORD j = 0; j < *pdwSoldCount; j++)
  1957. {
  1958. data = Decode(pItem, data);
  1959. offlineshop::CShopItem kItem(pItem->dwItemID);
  1960. kItem.SetOwnerID(pItem->dwOwnerID);
  1961. kItem.SetInfo(pItem->item);
  1962. kItem.SetPrice(pItem->price);
  1963. kItem.SetWindow(NEW_OFFSHOP);
  1964. OFFSHOP_DEBUG("sold item %u ",pItem->dwItemID);
  1965. pkShop->AddItemSold(kItem);
  1966. }
  1967. }
  1968. offlineshop::TOfferInfo* pOffer=nullptr;
  1969. for (DWORD i = 0; i < pSubPack->dwOfferCount; i++)
  1970. {
  1971. data = Decode(pOffer, data);
  1972. OFFSHOP_DEBUG("offer shop : id %u , shopid %u, itemid %u, buyer %u ",pOffer->dwOfferID, pOffer->dwOwnerID, pOffer->dwItemID , pOffer->dwOffererID);
  1973. offlineshop::CShop* pkShop = rManager.GetShopByOwnerID(pOffer->dwOwnerID);
  1974. if (!pkShop)
  1975. {
  1976. sys_err("CANNOT FIND SHOP BY OWNERID (TOfferInfo) %d ",pOffer->dwOwnerID);
  1977. continue;
  1978. }
  1979. pkShop->AddOffer(pOffer);
  1980. rManager.PutsNewOffer(pOffer);
  1981. }
  1982. offlineshop::TAuctionInfo* pTempAuction=nullptr;
  1983. offlineshop::TAuctionOfferInfo* pTempAuctionOffer=nullptr;
  1984. for (DWORD i = 0; i < pSubPack->dwAuctionCount; i++)
  1985. {
  1986. data = Decode(pTempAuction, data);
  1987. rManager.PutsAuction(*pTempAuction);
  1988. OFFSHOP_DEBUG("auction %u id , %s name , %u minutes ",pTempAuction->dwOwnerID , pTempAuction->szOwnerName, pTempAuction->dwDuration);
  1989. }
  1990. for (DWORD i = 0; i < pSubPack->dwAuctionOfferCount; i++)
  1991. {
  1992. data = Decode(pTempAuctionOffer, data);
  1993. rManager.PutsAuctionOffer(*pTempAuctionOffer);
  1994. OFFSHOP_DEBUG("offer %u shop , %s buyer ",pTempAuctionOffer->dwOwnerID, pTempAuctionOffer->szBuyerName);
  1995. }
  1996. }
  1997. void OfflineShopBuyItemPacket(const char* data)
  1998. {
  1999. offlineshop::TSubPacketDGBuyItem* subpack;
  2000. data = Decode(subpack, data);
  2001. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2002. rManager.RecvShopBuyDBPacket(subpack->dwBuyerID, subpack->dwOwnerID, subpack->dwItemID);
  2003. }
  2004. void OfflineShopLockedBuyItemPacket(const char* data)
  2005. {
  2006. offlineshop::TSubPacketDGLockedBuyItem* subpack;
  2007. data = Decode(subpack, data);
  2008. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2009. rManager.RecvShopLockedBuyItemDBPacket(subpack->dwBuyerID, subpack->dwOwnerID, subpack->dwItemID);
  2010. }
  2011. void OfflineShopEditItemPacket(const char* data)
  2012. {
  2013. offlineshop::TSubPacketDGEditItem* subpack;
  2014. data = Decode(subpack, data);
  2015. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2016. rManager.RecvShopEditItemDBPacket(subpack->dwOwnerID , subpack->dwItemID, subpack->price);
  2017. }
  2018. void OfflineShopRemoveItemPacket(const char* data)
  2019. {
  2020. offlineshop::TSubPacketDGRemoveItem* subpack;
  2021. data = Decode(subpack, data);
  2022. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2023. rManager.RecvShopRemoveItemDBPacket(subpack->dwOwnerID , subpack->dwItemID);
  2024. }
  2025. void OfflineShopAddItemPacket(const char* data)
  2026. {
  2027. offlineshop::TSubPacketDGAddItem* subpack;
  2028. data = Decode(subpack, data);
  2029. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2030. rManager.RecvShopAddItemDBPacket(subpack->dwOwnerID, subpack->item);
  2031. }
  2032. void OfflineShopForceClosePacket(const char* data)
  2033. {
  2034. offlineshop::TSubPacketDGShopForceClose* subpack;
  2035. data = Decode(subpack, data);
  2036. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2037. rManager.RecvShopForceCloseDBPacket(subpack->dwOwnerID);
  2038. }
  2039. void OfflineShopShopCreateNewPacket(const char* data)
  2040. {
  2041. offlineshop::TSubPacketDGShopCreateNew* subpack;
  2042. data = Decode(subpack, data);
  2043. OFFSHOP_DEBUG("shop %u , dur %u , count %u ",subpack->shop.dwOwnerID , subpack->shop.dwDuration , subpack->shop.dwCount);
  2044. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2045. std::vector<offlineshop::TItemInfo> vec;
  2046. vec.reserve(subpack->shop.dwCount);
  2047. offlineshop::TItemInfo* pItemInfo=nullptr;
  2048. for (DWORD i = 0; i < subpack->shop.dwCount; i++)
  2049. {
  2050. data = Decode(pItemInfo, data);
  2051. vec.push_back(*pItemInfo);
  2052. OFFSHOP_DEBUG("item id %u , item vnum %u , item count %u ",pItemInfo->dwItemID , pItemInfo->item.dwVnum , pItemInfo->item.dwCount);
  2053. }
  2054. #ifdef ENABLE_IRA_REWORK
  2055. rManager.RecvShopCreateNewDBPacket(subpack->shop, subpack->pos, vec);
  2056. #else
  2057. rManager.RecvShopCreateNewDBPacket(subpack->shop, vec);
  2058. #endif
  2059. }
  2060. void OfflineShopShopChangeNamePacket(const char* data)
  2061. {
  2062. offlineshop::TSubPacketDGShopChangeName* subpack;
  2063. data = Decode(subpack, data);
  2064. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2065. rManager.RecvShopChangeNameDBPacket(subpack->dwOwnerID , subpack->szName);
  2066. }
  2067. void OfflineShopOfferCreatePacket(const char* data)
  2068. {
  2069. offlineshop::TSubPacketDGOfferCreate* subpack;
  2070. data = Decode(subpack, data);
  2071. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2072. rManager.RecvShopOfferNewDBPacket(subpack->offer);
  2073. }
  2074. void OfflineShopOfferNotifiedPacket(const char* data)
  2075. {
  2076. offlineshop::TSubPacketDGOfferNotified* subpack;
  2077. data = Decode(subpack, data);
  2078. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2079. rManager.RecvShopOfferNotifiedDBPacket(subpack->dwOfferID , subpack->dwOwnerID);
  2080. }
  2081. void OfflineShopOfferAcceptPacket(const char* data)
  2082. {
  2083. offlineshop::TSubPacketDGOfferAccept* subpack;
  2084. data = Decode(subpack, data);
  2085. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2086. rManager.RecvShopOfferAcceptDBPacket(subpack->dwOfferID , subpack->dwOwnerID);
  2087. }
  2088. void OfflineShopOfferCancelPacket(const char* data)
  2089. {
  2090. offlineshop::TSubPacketDGOfferCancel* subpack;
  2091. data = Decode(subpack, data);
  2092. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2093. rManager.RecvShopOfferCancelDBPacket(subpack->dwOfferID , subpack->dwOwnerID, subpack->IsRemovingItem);
  2094. }
  2095. void OfflineShopSafeboxAddItemPacket(const char* data)
  2096. {
  2097. offlineshop::TSubPacketDGSafeboxAddItem* subpack;
  2098. data = Decode(subpack, data);
  2099. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2100. rManager.RecvShopSafeboxAddItemDBPacket(subpack->dwOwnerID , subpack->dwItemID , subpack->item);
  2101. }
  2102. void OfflineShopSafeboxAddValutesPacket(const char* data)
  2103. {
  2104. offlineshop::TSubPacketDGSafeboxAddValutes* subpack;
  2105. data = Decode(subpack, data);
  2106. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2107. rManager.RecvShopSafeboxAddValutesDBPacket(subpack->dwOwnerID , subpack->valute);
  2108. }
  2109. void OfflineShopSafeboxLoad(const char* data)
  2110. {
  2111. offlineshop::TSubPacketDGSafeboxLoad* subpack;
  2112. data = Decode(subpack, data);
  2113. std::vector<DWORD> ids;
  2114. std::vector<offlineshop::TItemInfoEx> items;
  2115. ids.reserve(subpack->dwItemCount);
  2116. items.reserve(subpack->dwItemCount);
  2117. DWORD* pdwItemID=nullptr;
  2118. offlineshop::TItemInfoEx* temp;
  2119. for (DWORD i = 0; i < subpack->dwItemCount; i++)
  2120. {
  2121. data = Decode(pdwItemID, data);
  2122. data = Decode(temp, data);
  2123. ids.push_back(*pdwItemID);
  2124. items.push_back(*temp);
  2125. }
  2126. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2127. rManager.RecvShopSafeboxLoadDBPacket(subpack->dwOwnerID , subpack->valute , ids, items);
  2128. }
  2129. void OfflineshopSafeboxExpiredItem(const char* data)
  2130. {
  2131. offlineshop::TSubPacketDGSafeboxExpiredItem* subpack;
  2132. data = Decode(subpack, data);
  2133. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2134. rManager.RecvShopSafeboxExpiredItemDBPacket(subpack->dwOwnerID, subpack->dwItemID);
  2135. }
  2136. void OfflineShopAuctionCreate(const char* data)
  2137. {
  2138. offlineshop::TSubPacketDGAuctionCreate* subpack;
  2139. data = Decode(subpack, data);
  2140. offlineshop::GetManager().RecvAuctionCreateDBPacket(subpack->auction);
  2141. }
  2142. void OfflineShopAuctionAddOffer(const char* data)
  2143. {
  2144. offlineshop::TSubPacketDGAuctionAddOffer* subpack;
  2145. data = Decode(subpack, data);
  2146. offlineshop::GetManager().RecvAuctionAddOfferDBPacket(subpack->offer);
  2147. }
  2148. void OfflineShopAuctionExpired(const char* data)
  2149. {
  2150. offlineshop::TSubPacketDGAuctionExpired* subpack;
  2151. data = Decode(subpack, data);
  2152. offlineshop::GetManager().RecvAuctionExpiredDBPacket(subpack->dwOwnerID);
  2153. }
  2154. void OfflineshopShopExpired(const char* data)
  2155. {
  2156. offlineshop::TSubPacketDGShopExpired* subpack;
  2157. data = Decode(subpack, data);
  2158. offlineshop::CShopManager& rManager = offlineshop::GetManager();
  2159. rManager.RecvShopExpiredDBPacket(subpack->dwOwnerID);
  2160. }
  2161. void OfflineshopPacket(const char* data)
  2162. {
  2163. TPacketDGNewOfflineShop* pPack=nullptr;
  2164. data = Decode(pPack, data);
  2165. OFFSHOP_DEBUG("recv subheader %d",pPack->bSubHeader);
  2166. switch (pPack->bSubHeader)
  2167. {
  2168. case offlineshop::SUBHEADER_DG_LOAD_TABLES: OfflineShopLoadTables(data); return;
  2169. case offlineshop::SUBHEADER_DG_BUY_ITEM: OfflineShopBuyItemPacket(data); return;
  2170. case offlineshop::SUBHEADER_DG_LOCKED_BUY_ITEM: OfflineShopLockedBuyItemPacket(data); return;
  2171. case offlineshop::SUBHEADER_DG_EDIT_ITEM: OfflineShopEditItemPacket(data); return;
  2172. case offlineshop::SUBHEADER_DG_REMOVE_ITEM: OfflineShopRemoveItemPacket(data); return;
  2173. case offlineshop::SUBHEADER_DG_ADD_ITEM: OfflineShopAddItemPacket(data); return;
  2174. case offlineshop::SUBHEADER_DG_SHOP_FORCE_CLOSE: OfflineShopForceClosePacket(data); return;
  2175. case offlineshop::SUBHEADER_DG_SHOP_CREATE_NEW: OfflineShopShopCreateNewPacket(data); return;
  2176. case offlineshop::SUBHEADER_DG_SHOP_CHANGE_NAME: OfflineShopShopChangeNamePacket(data); return;
  2177. case offlineshop::SUBHEADER_DG_SHOP_EXPIRED: OfflineshopShopExpired(data); return;
  2178. case offlineshop::SUBHEADER_DG_OFFER_CREATE: OfflineShopOfferCreatePacket(data); return;
  2179. case offlineshop::SUBHEADER_DG_OFFER_NOTIFIED: OfflineShopOfferNotifiedPacket(data); return;
  2180. case offlineshop::SUBHEADER_DG_OFFER_ACCEPT: OfflineShopOfferAcceptPacket(data); return;
  2181. case offlineshop::SUBHEADER_DG_OFFER_CANCEL: OfflineShopOfferCancelPacket(data); return;
  2182. case offlineshop::SUBHEADER_DG_SAFEBOX_ADD_ITEM: OfflineShopSafeboxAddItemPacket(data); return;
  2183. case offlineshop::SUBHEADER_DG_SAFEBOX_ADD_VALUTES: OfflineShopSafeboxAddValutesPacket(data); return;
  2184. case offlineshop::SUBHEADER_DG_SAFEBOX_LOAD: OfflineShopSafeboxLoad(data); return;
  2185. case offlineshop::SUBHEADER_DG_SAFEBOX_EXPIRED_ITEM: OfflineshopSafeboxExpiredItem(data); return;
  2186. case offlineshop::SUBHEADER_DG_AUCTION_CREATE: OfflineShopAuctionCreate(data); return;
  2187. case offlineshop::SUBHEADER_DG_AUCTION_ADD_OFFER: OfflineShopAuctionAddOffer(data); return;
  2188. case offlineshop::SUBHEADER_DG_AUCTION_EXPIRED: OfflineShopAuctionExpired(data); return;
  2189. default:
  2190. sys_err("UKNOWN SUB HEADER %d ", pPack->bSubHeader);
  2191. return;
  2192. }
  2193. }
  2194. #endif
  2195. bool CInputDB::Process (LPDESC d, const void* orig, int bytes, int& r_iBytesProceed)
  2196. {
  2197. const char* c_pData = (const char*) orig;
  2198. BYTE bHeader, bLastHeader = 0;
  2199. int iSize;
  2200. int iLastPacketLen = 0;
  2201. for (m_iBufferLeft = bytes; m_iBufferLeft > 0;)
  2202. {
  2203. if (m_iBufferLeft < 9)
  2204. {
  2205. return true;
  2206. }
  2207. bHeader = * ((BYTE*) (c_pData)); // 1
  2208. m_dwHandle = * ((DWORD*) (c_pData + 1)); // 4
  2209. iSize = * ((DWORD*) (c_pData + 5)); // 4
  2210. sys_log (1, "DBCLIENT: header %d handle %d size %d bytes %d", bHeader, m_dwHandle, iSize, bytes);
  2211. if (m_iBufferLeft - 9 < iSize)
  2212. {
  2213. return true;
  2214. }
  2215. const char* pRealData = (c_pData + 9);
  2216. if (Analyze (d, bHeader, pRealData) < 0)
  2217. {
  2218. sys_err ("in InputDB: UNKNOWN HEADER: %d, LAST HEADER: %d(%d), REMAIN BYTES: %d, DESC: %d",
  2219. bHeader, bLastHeader, iLastPacketLen, m_iBufferLeft, d->GetSocket());
  2220. //printdata((BYTE*) orig, bytes);
  2221. //d->SetPhase(PHASE_CLOSE);
  2222. }
  2223. c_pData += 9 + iSize;
  2224. m_iBufferLeft -= 9 + iSize;
  2225. r_iBytesProceed += 9 + iSize;
  2226. iLastPacketLen = 9 + iSize;
  2227. bLastHeader = bHeader;
  2228. }
  2229. return true;
  2230. }
  2231. void CInputDB::GuildChangeMaster (TPacketChangeGuildMaster* p)
  2232. {
  2233. CGuildManager::instance().ChangeMaster (p->dwGuildID);
  2234. }
  2235. void CInputDB::DetailLog (const TPacketNeedLoginLogInfo* info)
  2236. {
  2237. LPCHARACTER pChar = CHARACTER_MANAGER::instance().FindByPID (info->dwPlayerID);
  2238. if (NULL != pChar)
  2239. {
  2240. LogManager::instance().DetailLoginLog (true, pChar);
  2241. }
  2242. }
  2243. void CInputDB::ItemAwardInformer (TPacketItemAwardInfromer* data)
  2244. {
  2245. LPDESC d = DESC_MANAGER::instance().FindByLoginName (data->login); //login����
  2246. if (d == NULL)
  2247. {
  2248. return;
  2249. }
  2250. else
  2251. {
  2252. if (d->GetCharacter())
  2253. {
  2254. LPCHARACTER ch = d->GetCharacter();
  2255. ch->SetItemAward_vnum (data->vnum); // ch �� �ӽ� �����س��ٰ� QuestLoad �Լ����� ó��
  2256. ch->SetItemAward_cmd (data->command);
  2257. if (d->IsPhase (PHASE_GAME)) //�����������϶�
  2258. {
  2259. quest::CQuestManager::instance().ItemInformer (ch->GetPlayerID(), ch->GetItemAward_vnum()); //questmanager ȣ��
  2260. }
  2261. }
  2262. }
  2263. }
  2264. void CInputDB::RespondChannelStatus (LPDESC desc, const char* pcData)
  2265. {
  2266. if (!desc)
  2267. {
  2268. return;
  2269. }
  2270. const int nSize = decode_4bytes (pcData);
  2271. pcData += sizeof (nSize);
  2272. BYTE bHeader = HEADER_GC_RESPOND_CHANNELSTATUS;
  2273. desc->BufferedPacket (&bHeader, sizeof (BYTE));
  2274. desc->BufferedPacket (&nSize, sizeof (nSize));
  2275. if (0 < nSize)
  2276. {
  2277. desc->BufferedPacket (pcData, sizeof (TChannelStatus)*nSize);
  2278. }
  2279. BYTE bSuccess = 1;
  2280. desc->Packet (&bSuccess, sizeof (bSuccess));
  2281. desc->SetChannelStatusRequested (false);
  2282. }

input_db.cpp