Advertisement
Guest User

Untitled

a guest
Sep 29th, 2018
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 494.06 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include "protocol.h"
  3. #include "IllusionTemple.h"
  4. #include "ChatProtocol.h"
  5. #include "BuffManager.h"
  6. #include "MSSQL.h"
  7. #include "OffTrade.h"
  8. #include "OffAttack.h"
  9. #include "ScorpAttack.h"
  10. #include "GambleSystem.h"
  11. #include "IpAuthorization.h"
  12. #include "PropensitySystem.h"
  13. #include "GameMain.h"
  14. #include "Reconnect.h"
  15. #include "News.h"
  16. //#include "PackSystem.h"
  17. #include "Logger.h"
  18. #include "Configs.h"
  19. #include "PartyHelper.h"
  20. #include "PickUpSystem.h"
  21. #include "Antihack.h"
  22. #include "MiscCustom.h"
  23. #include "MatchEvent.h"
  24. #include "GuessEvent.h"
  25. #include "VipSystem.h"
  26. #include "Reaches.h"
  27. int ltesttime;
  28. int logincounttest;
  29.  
  30. int tempindex;
  31. int iCount;
  32.  
  33.  
  34. BOOL PacketCheckTime(LPOBJ lpObj)
  35. {
  36. if ((GetTickCount() - lpObj->m_PacketCheckTime ) < 300)
  37. {
  38. return FALSE;
  39. }
  40.  
  41. lpObj->m_PacketCheckTime = GetTickCount();
  42. return TRUE;
  43. }
  44.  
  45. BOOL DataEncryptCheck(int aIndex, BYTE protoNum, BOOL Encrypt)
  46. {
  47. if (Encrypt == FALSE)
  48. {
  49. LogAdd("Error-L1 : Not Encrypt %s %d", gObj[aIndex].AccountID, protoNum);
  50. CloseClient(aIndex);
  51. return FALSE;
  52. }
  53. return TRUE;
  54. }
  55.  
  56. void ProtocolCore(BYTE protoNum, unsigned char *aRecv, int aLen, int aIndex, BOOL Encrypt, int serial)
  57. {
  58. #if (TEST_SERVER == 1)
  59. LogAddHeadHex(gObj[aIndex].AccountID, (char*)aRecv, aLen+2);
  60. #endif
  61.  
  62. if (gStalkProtocol)
  63. {
  64. if (gStalkProtocolId[0] == gObj[aIndex].AccountID[0])
  65. {
  66. if (gStalkProtocolId[1] == gObj[aIndex].AccountID[1])
  67. {
  68. if (!strcmp(gStalkProtocolId, gObj[aIndex].AccountID))
  69. {
  70. //??
  71. //LogAddHeadHex(gObj[aIndex].AccountID, (char*)aRecv, aLen);
  72. }
  73. }
  74. }
  75. }
  76.  
  77. // Check Socket Serial
  78. if (serial >= 0)
  79. {
  80. if (gObj[aIndex].Type == OBJ_USER)
  81. {
  82. if (gNSerialCheck[aIndex].InCheck(serial) == FALSE)
  83. {
  84. LogAdd("Error-L1 : Socket Serial %s %d o_serial:%d serial:%d ", gObj[aIndex].AccountID, protoNum, gNSerialCheck[aIndex].GetSerial(), serial);
  85. CloseClient(aIndex);
  86. }
  87. }
  88. }
  89.  
  90. if (protoNum == 0xF1 || protoNum == 0xF3)
  91. {
  92. switch (protoNum)
  93. {
  94. case LIVE_CLIENT: //0x0E:
  95. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  96. {
  97. CGLiveClient((PMSG_CLIENTTIME *)aRecv, aIndex);
  98. tempindex = aIndex;
  99. }
  100. break;
  101.  
  102. case SELECT_SERVER: //0xF1:
  103. {
  104. PMSG_DEFAULT2 *lpMsg2 = (PMSG_DEFAULT2 *)aRecv;
  105.  
  106. switch (lpMsg2->subcode)
  107. {
  108. case JOIN_ID_PASS_REQ: //0x01:
  109. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  110. {
  111. CSPJoinIdPassRequest((PMSG_IDPASS *)aRecv, aIndex);
  112. }
  113. break;
  114.  
  115. case CLIENT_CLOSE_MSG: //0x02:
  116. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  117. {
  118. CGClientCloseMsg((PMSG_CLIENTCLOSE *)aRecv, aIndex);
  119. }
  120. break;
  121.  
  122. case CLIENT_MSG: //0x03:
  123. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  124. {
  125. CGClientMsg((PMSG_CLIENTMSG *)aRecv, aIndex);
  126. }
  127. break;
  128. }
  129. }
  130. break;
  131.  
  132. case SELECT_CHARACTER: //0xF3:
  133. {
  134. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2 *)aRecv;
  135.  
  136. switch (lpDef->subcode)
  137. {
  138. case GET_CHAR_LIST_REQ: //0x00:
  139. DataServerGetCharListRequest(aIndex);
  140. break;
  141. case CHARACTER_CREATE: //0x01:
  142. CGPCharacterCreate((PMSG_CHARCREATE *)aRecv, aIndex);
  143. break;
  144. case CHARACTER_DELETE: //0x02:
  145. CGPCharDel((PMSG_CHARDELETE *)aRecv, aIndex);
  146. break;
  147. case CHAR_MAP_JOIN_REQ: //0x03:
  148. CGPCharacterMapJoinRequest((PMSG_CHARMAPJOIN *)aRecv, aIndex);
  149.  
  150. break;
  151. case LEVEL_UP_POINT_ADD: //0x06:
  152. CGLevelUpPointAdd((PMSG_LVPOINTADD *)aRecv, aIndex);
  153. break;
  154. case MOVE_DATA_LOADING: //0x12:
  155. gObjMoveDataLoadingOK(aIndex);
  156. break;
  157. case SKILL_KEY: //0x30:
  158. GCSkillKeyRecv((PMSG_SKILLKEY *)aRecv, aIndex);
  159. break;
  160. }
  161. }
  162. break;
  163. }
  164. }
  165. else
  166. {
  167. LPOBJ lpObj = &gObj[aIndex];
  168.  
  169. switch (protoNum)
  170. {
  171. case 0x00: //0x00:
  172.  
  173.  
  174.  
  175.  
  176. tempindex = aIndex;
  177. PChatProc((PMSG_CHATDATA *)aRecv, aIndex);
  178. //CheckCommands(lpObj, (PMSG_CHATDATA *)aRecv);
  179. break;
  180. case CHAT_RECV: //0x01:
  181. CGChatRecv((PMSG_CHATDATA_NUMBER *)aRecv, aIndex);
  182. break;
  183. case CHAT_WHISPER_RECV: //0x02:
  184. CGChatWhisperRecv((PMSG_CHATDATA_WHISPER *)aRecv, aIndex);
  185. break;
  186. case CHECK_MAIN_RECV: //0x03:
  187. CGCheckMainRecv((PMSG_CHECK_MAINEXE_RESULT *)aRecv, aIndex);
  188. break;
  189. case LIVE_CLIENT: //0x0E:
  190. CGLiveClient((PMSG_CLIENTTIME *)aRecv, aIndex);
  191. break;
  192. // --------------------------------------------------
  193. case MOVE_PROTOCOL:
  194. PMoveProc((PMSG_MOVE *)aRecv, aIndex); // Move
  195. break;
  196. case SETPOS_PROTOCOL:
  197. RecvPositionSetProc((PMSG_POSISTION_SET*)aRecv, aIndex); //Skill
  198. break;
  199. case ATTACK_PROTOCOL:
  200. CGAttack((PMSG_ATTACK *)aRecv, aIndex); // Attack
  201. break;
  202. // --------------------------------------------------
  203. case ACTION_RECV: //0x18:
  204. CGActionRecv((PMSG_ACTION *)aRecv, aIndex);
  205. break;
  206. case MAGIC_ATTACK: //0x19:
  207. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  208. {
  209. CGMagicAttack((PMSG_MAGICATTACK *)aRecv, aIndex);
  210. }
  211. break;
  212. case MAGIC_CANCEL: //0x1B:
  213. CGMagicCancel((PMSG_MAGICCANCEL *)aRecv, aIndex);
  214. break;
  215. case TELEPORT_RECV: //0x1C:
  216. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  217. {
  218. CGTeleportRecv((PMSG_TELEPORT *)aRecv, aIndex);
  219. }
  220. break;
  221. case TARGET_TELEPORT_RECV: //0xB0:
  222. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  223. {
  224. CGTargetTeleportRecv((PMSG_TARGET_TELEPORT *)aRecv, aIndex);
  225. }
  226. break;
  227. case BEATTACK_PROTOCOL:
  228. CGBeattackRecv(aRecv, aIndex, FALSE);
  229. break;
  230. case DURATION_MAGIC_RECV: //0x1E:
  231. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  232. {
  233. CGDurationMagicRecv((PMSG_DURATION_MAGIC_RECV *)aRecv, aIndex);
  234. }
  235. break;
  236. case ITEM_GET_REQUEST: //0x22:
  237. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  238. {
  239. CGItemGetRequest((PMSG_ITEMGETREQUEST *)aRecv, aIndex);
  240. }
  241. break;
  242. case ITEM_DROP_REQUEST: //0x23:
  243. CGItemDropRequest((PMSG_ITEMTHROW *)aRecv, aIndex, 0);
  244. break;
  245. case INVENTORY_ITEM_MOVE: //0x24:
  246. CGInventoryItemMove((PMSG_INVENTORYITEMMOVE *)aRecv, aIndex);
  247. break;
  248. case USE_ITEM_RECV: //0x26:
  249. CGUseItemRecv((PMSG_USEITEM *)aRecv, aIndex);
  250. break;
  251. case TALK_REQ_RECV: //0x30:
  252. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  253. {
  254. CGTalkRequestRecv((PMSG_TALKREQUEST *)aRecv, aIndex);
  255. }
  256. break;
  257. case CLOSE_WINDOW: //0x31:
  258. CGCloseWindow(aIndex);
  259. break;
  260. case BUY_REQ_RECV: //0x32:
  261. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  262. {
  263. CGBuyRequestRecv((PMSG_BUYREQUEST *)aRecv, aIndex);
  264. }
  265. break;
  266. case SELL_REQ_RECV: //0x33:
  267. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  268. {
  269. CGSellRequestRecv((PMSG_SELLREQUEST *)aRecv, aIndex);
  270. }
  271. break;
  272. case MODIFY_REQ_ITEM: //0x34:
  273. CGModifyRequestItem((PMSG_ITEMDURREPAIR *)aRecv, aIndex);
  274. break;
  275. case TRADE_REQ_SEND: //0x36:
  276. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  277. {
  278. CGTradeRequestSend((PMSG_TRADE_REQUEST *)aRecv, aIndex);
  279. }
  280. break;
  281. case TRADE_RESPONSE_RECV: //0x37:
  282. CGTradeResponseRecv((PMSG_TRADE_RESPONSE *)aRecv, aIndex);
  283. break;
  284. case TRADE_MONEY_RECV: //0x3A:
  285. CGTradeMoneyRecv((PMSG_TRADE_GOLD *)aRecv, aIndex);
  286. break;
  287. case TRADE_OK_BUTTON_RECV: //0x3C:
  288. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  289. {
  290. CGTradeOkButtonRecv((PMSG_TRADE_OKBUTTON *)aRecv, aIndex);
  291. }
  292. break;
  293. case TRADE_CANCEL_BUTTON_RECV: //0x3D:
  294. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  295. {
  296. CGTradeCancelButtonRecv(aIndex);
  297. }
  298. break;
  299. case SHOP_PROTOCOL_ID: //0x3F:
  300. {
  301. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  302.  
  303. switch (lpDef->subcode)
  304. {
  305. case SHOP_REQ_SET_ITEM_PRICE: //0x01:
  306. CGPShopReqSetItemPrice((PMSG_REQ_PSHOP_SETITEMPRICE *)aRecv, aIndex);
  307. break;
  308. case SHOP_REQ_OPEN: //0x02:
  309. CGPShopReqOpen((PMSG_REQ_PSHOP_OPEN *)aRecv, aIndex);
  310. break;
  311. case SHOP_REQ_CLOSE: //0x03:
  312. CGPShopReqClose(aIndex);
  313. break;
  314. case SHOP_REQ_BUY_LIST: //0x05:
  315. CGPShopReqBuyList((PMSG_REQ_BUYLIST_FROM_PSHOP *)aRecv, aIndex);
  316. break;
  317. case SHOP_REQ_BUY_ITEM: //0x06:
  318. CGPShopReqBuyItem((PMSG_REQ_BUYITEM_FROM_PSHOP *)aRecv, aIndex);
  319. break;
  320. }
  321. }
  322. break;
  323. case PARTY_REQ_RECV: //0x40:
  324. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  325. {
  326. CGPartyRequestRecv((PMSG_PARTYREQUEST *)aRecv, aIndex);
  327. }
  328. break;
  329. case PARTY_REQ_RESULT_RECV: //0x41:
  330. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  331. {
  332. CGPartyRequestResultRecv((PMSG_PARTYREQUESTRESULT *)aRecv, aIndex);
  333. }
  334. break;
  335. case PARTY_LIST: //0x42:
  336. CGPartyList(aIndex);
  337. break;
  338. case PARTY_DELETE_USER: //0x43:
  339. if (PacketCheckTime(&gObj[aIndex]) == TRUE)
  340. {
  341. CGPartyDelUser((PMSG_PARTYDELUSER *)aRecv, aIndex);
  342. }
  343. break;
  344. case GUILD_REQ_RECV: //0x50:
  345. CGGuildRequestRecv((PMSG_GUILDJOINQ *)aRecv, aIndex);
  346. break;
  347. case GUILD_REQ_RESULT_RECV: //0x51:
  348. CGGuildRequestResultRecv((PMSG_GUILDQRESULT *)aRecv, aIndex);
  349. break;
  350. case GUILD_LIST_ALL: //0x52:
  351. CGGuildListAll(aIndex);
  352. break;
  353. case GUILD_DELETE_USER: //0x53:
  354. CGGuildDelUser((PMSG_GUILDDELUSER *)aRecv, aIndex);
  355. break;
  356. case GUILD_MASTER_ANSWER_RECV: //0x54:
  357. CGGuildMasterAnswerRecv((PMSG_GUILDMASTERANSWER *)aRecv, aIndex);
  358. break;
  359. case GUILD_MASTER_INFO_SAFE: //0x55:
  360. CGGuildMasterInfoSave(aIndex, (PMSG_GUILDINFOSAVE *)aRecv);
  361. break;
  362. case GUILD_MASTER_CREATE_CANCEL: //0x57:
  363. CGGuildMasterCreateCancel(aIndex);
  364. break;
  365. case GUILD_WAR_REQ_SEND_RECV: //0x61:
  366. GCGuildWarRequestSendRecv((PMSG_GUILDWARSEND_RESULT *)aRecv, aIndex);
  367. break;
  368. case GUILD_VIEWPORT_INFO: //0x66:
  369. GCGuildViewportInfo((PMSG_REQ_GUILDVIEWPORT *)aRecv, aIndex);
  370. break;
  371. case MAP_SRV_AUTH_PROTOCOL_ID: //0xB1:
  372. {
  373. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  374.  
  375. switch (lpDef->subcode)
  376. {
  377. case REQ_MAP_SRV_AUTH: //0x01:
  378. if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  379. {
  380. CGReqMapSvrAuth((PMSG_REQ_MAPSERVERAUTH*)aRecv, aIndex);
  381. }
  382. break;
  383. }
  384. }
  385. break;
  386. case CASTLE_SIEGE_PROTOCOL_ID: //0xB2:
  387. {
  388. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  389.  
  390. switch ( lpDef->subcode )
  391. {
  392. case REQ_CASTLE_SIEGE_STATE: //0x00:
  393. CGReqCastleSiegeState((PMSG_REQ_CASTLESIEGESTATE *)aRecv, aIndex);
  394. break;
  395. case REQ_REG_CASTLE_SIEGE: //0x01:
  396. CGReqRegCastleSiege((PMSG_REQ_REGCASTLESIEGE *)aRecv, aIndex);
  397. break;
  398. case REQ_GIVE_UP_CASTLE_SIEGE: //0x02:
  399. CGReqGiveUpCastleSiege((PMSG_REQ_GIVEUPCASTLESIEGE *)aRecv, aIndex);
  400. break;
  401. case REQ_GUILD_REG_INFO: //0x03:
  402. CGReqGuildRegInfo((PMSG_REQ_GUILDREGINFO *)aRecv, aIndex);
  403. break;
  404. case REQ_REG_GUILD_MARK: //0x04:
  405. CGReqRegGuildMark((PMSG_REQ_REGGUILDMARK *)aRecv, aIndex);
  406. break;
  407. case REQ_NPC_BUY: //0x05:
  408. CGReqNpcBuy((PMSG_REQ_NPCBUY *)aRecv, aIndex);
  409. break;
  410. case REQ_NPC_REPAIR: //0x06:
  411. CGReqNpcRepair((PMSG_REQ_NPCREPAIR *)aRecv, aIndex);
  412. break;
  413. case REQ_NPC_UPGRADE: //0x07:
  414. CGReqNpcUpgrade((PMSG_REQ_NPCUPGRADE *)aRecv, aIndex);
  415. break;
  416. case REQ_TAX_MONEY_INFO: //0x08:
  417. CGReqTaxMoneyInfo((PMSG_REQ_TAXMONEYINFO *)aRecv, aIndex);
  418. break;
  419. case REQ_TAX_RATE_CHANGE: //0x09:
  420. CGReqTaxRateChange((PMSG_REQ_TAXRATECHANGE *)aRecv, aIndex);
  421. break;
  422. case REQ_MONEY_DRAW_OUT: //0x10:
  423. CGReqMoneyDrawOut((PMSG_REQ_MONEYDRAWOUT *)aRecv, aIndex);
  424. break;
  425. case REQ_CS_GATE_OPERATE: //0x12:
  426. CGReqCsGateOperate((PMSG_REQ_CSGATEOPERATE *)aRecv, aIndex);
  427. break;
  428. case REQ_CS_MINIMAP_DATA: //0x1B:
  429. CGReqCsMiniMapData((PMSG_REQ_MINIMAPDATA *)aRecv, aIndex);
  430. break;
  431. case REQ_CS_STOP_MINIMAP_DATA: //0x1C:
  432. CGReqStopCsMiniMapData((PMSG_REQ_STOPMINIMAPDATA *)aRecv, aIndex);
  433. break;
  434. case REQ_CS_SEND_COMMAND: //0x1D:
  435. CGReqCsSendCommand((PMSG_REQ_CSCOMMAND *)aRecv, aIndex);
  436. break;
  437. case REQ_CS_SET_ENTER_HUNTZONE: //0x1F:
  438. CGReqCsSetEnterHuntZone((PMSG_REQ_CSHUNTZONEENTER *)aRecv, aIndex);
  439. break;
  440. }
  441. }
  442. break;
  443. case REQ_NPC_DB_LIST: //0xB3:
  444. CGReqNpcDbList((PMSG_REQ_NPCDBLIST *)aRecv, aIndex);
  445. break;
  446. case REQ_CS_REG_GUILD_LIST: //0xB4:
  447. CGReqCsRegGuildList((PMSG_REQ_CSREGGUILDLIST *)aRecv, aIndex);
  448. break;
  449. case REQ_CS_ATTACK_GUILD_LIST: //0xB5:
  450. CGReqCsAttkGuildList((PMSG_REQ_CSATTKGUILDLIST *)aRecv, aIndex);
  451. break;
  452. case WEAPON_PROTOCOL_ID: //0xB7:
  453. {
  454. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  455.  
  456. switch ( lpDef->subcode )
  457. {
  458. case REQ_WEAPON_USE: //0x01:
  459. CGReqWeaponUse((PMSG_REQ_USEWEAPON *)aRecv, aIndex);
  460. break;
  461. case REQ_WEAPON_DAMAGE_VALUE: //0x04:
  462. CGReqWeaponDamageValue((PMSG_REQ_WEAPON_DAMAGE_VALUE *)aRecv, aIndex);
  463. break;
  464. }
  465. }
  466. break;
  467. case CASTLESIEGE_PROTOCOL_ID: //0xB9:
  468. {
  469. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  470.  
  471. switch (lpDef->subcode)
  472. {
  473. case REQ_GUILD_MARK_OF_CS_OWNER: //0x02:
  474. CGReqGuildMarkOfCastleOwner((PMSG_REQ_GUILDMARK_OF_CASTLEOWNER *)aRecv, aIndex);
  475. break;
  476. case REQ_CS_HUNTZONE_ENTRANCE: //0x05:
  477. CGReqCastleHuntZoneEntrance((PMSG_REQ_MOVE_TO_CASTLE_HUNTZONE*) aRecv, aIndex);
  478. break;
  479. }
  480. }
  481. break;
  482. case JEWEL_PROTOCOL_ID: //0xBC:
  483. {
  484. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  485.  
  486. switch (lpDef->subcode)
  487. {
  488. case REQ_JEWEL_MIX: //0x00:
  489. CGReqJewelMix((PMSG_REQ_JEWEL_MIX *)aRecv, aIndex);
  490. break;
  491. case REQ_JEWEL_UNMIX: //0x01:
  492. CGReqJewelUnMix((PMSG_REQ_JEWEL_UNMIX *)aRecv, aIndex);
  493. break;
  494. }
  495. }
  496. break;
  497. case CRYWOLF_PROTOCOL_ID: //0xBD:
  498. {
  499. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  500.  
  501. switch (lpDef->subcode)
  502. {
  503. case REQ_CRYWOLF_INFO: //0x00:
  504. CGReqCrywolfInfo((PMSG_REQ_CRYWOLF_INFO *)aRecv, aIndex);
  505. break;
  506. case REQ_ALTAR_CONTRACT: //0x03:
  507. CGReqAlatrContract((PMSG_REQ_CRYWOLF_ALTAR_CONTRACT *)aRecv, aIndex);
  508. break;
  509. case REQ_PLUS_CHAOS_RATE: //0x09:
  510. CGReqPlusChaosRate((PMSG_REQ_CRYWOLF_BENEFIT_PLUS_CHAOSRATE *)aRecv, aIndex);
  511. break;
  512. }
  513. }
  514. break;
  515. case 0xE1:
  516. CGGuildAssignStatus((PMSG_GUILD_ASSIGN_STATUS_REQ *)aRecv, aIndex);
  517. break;
  518. case 0xE2:
  519. CGGuildAssignType((PMSG_GUILD_ASSIGN_TYPE_REQ *)aRecv, aIndex);
  520. break;
  521. case 0xE5:
  522. CGRelationShipReqJoinBreakOff((PMSG_RELATIONSHIP_JOIN_BREAKOFF_REQ *)aRecv, aIndex);
  523. break;
  524. case 0xE6:
  525. CGRelationShipAnsJoinBreakOff((PMSG_RELATIONSHIP_JOIN_BREAKOFF_ANS *)aRecv, aIndex);
  526. break;
  527. case 0xE9:
  528. CGUnionList((PMSG_UNIONLIST_REQ *)aRecv, aIndex);
  529. break;
  530. case 0xEB:
  531. {
  532. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  533.  
  534. switch ( lpDef->subcode )
  535. {
  536. case 0x01:
  537. CGRelationShipReqKickOutUnionMember((PMSG_KICKOUT_UNIONMEMBER_REQ *)aRecv, aIndex);
  538. break;
  539. }
  540. }
  541. break;
  542. case 0xBF:
  543. {
  544. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  545.  
  546. switch ( lpDef->subcode )
  547. {
  548. case 0x00:
  549. CGReqEnterIllusionTemple((PMSG_ANS_ILLUSIONTEMPLE_ENTER *)aRecv, aIndex);
  550. break;
  551. case 0x02:
  552. // CGReqUseIllusionTempleKillCntSkill((PMSG_USE_ILLUSIONTEMPLE_KILLCOUNT_SKILL *)aRecv, aIndex);
  553. CGReqUseIllusionTempleKillCntSkill((aRecv[5] * 256) + aRecv[6], aRecv[4], aIndex);
  554. break;
  555. case 0x05:
  556. CGReqIllusionTempleDropReward((PMSG_ILLUSIONTEMPLE_DROP_REWARD *)aRecv, aIndex);
  557. break;
  558. }
  559. }
  560. break;
  561.  
  562.  
  563. case PING_SEND_RECV: //0x71:
  564. GCPingSendRecv((PMSG_PING_RESULT *)aRecv, aIndex);
  565. break;
  566. //case PACKET_CHECKSUM_RECV: //0x72:
  567. // if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  568. // {
  569. // GCPacketCheckSumRecv((PMSG_PACKETCHECKSUM*)aRecv, aIndex);
  570. // }
  571. // break;
  572. //case GAMEGUARD_CHECKSUM_RECV: //0x73:
  573. // if (DataEncryptCheck(aIndex, protoNum, Encrypt) != FALSE)
  574. // {
  575. // //GCNPggCheckSumRecv((PMSG_NPROTECTGGCHECKSUM *)aRecv, aIndex);
  576. // }
  577. // break;
  578. case WAREHOUSE_MONEY_IN_OUT: //0x81:
  579. CGWarehouseMoneyInOut(aIndex, (PMSG_WAREHOUSEMONEYINOUT *)aRecv);
  580. break;
  581. case WAREHOUSE_USE_END: //0x82:
  582. CGWarehouseUseEnd(aIndex);
  583. break;
  584. case WAREHOUSE_RECIVE_PASSWORD: //0x83:
  585. GCWarehouseRecivePassword(aIndex, (PMSG_WAREHOUSEPASSSEND *)aRecv);
  586. break;
  587. case CHAOSBOX_ITEM_MIX_BTN_CLICK: //0x86:
  588. CGChaosBoxItemMixButtonClick((PMSG_CHAOSMIX *)aRecv, aIndex);
  589. break;
  590. case CHAOSBOX_USE_END: //0x87:
  591. CGChaosBoxUseEnd(aIndex);
  592. break;
  593. case REQ_MOVE_DEVILSQUARE: //0x90:
  594. GCReqmoveDevilSquare((PMSG_REQ_MOVEDEVILSQUARE *)aRecv, aIndex);
  595. break;
  596. case REQ_DEVIL_SQUARE_REMAIN_TIME: //0x91:
  597. GCReqDevilSquareRemainTime((PMSG_REQ_DEVILSQUARE_REMAINTIME *)aRecv, aIndex);
  598. break;
  599. case REQ_EVENT_CHIP_RECV: //0x95:
  600. GCRegEventChipRecv((PMSG_REGEVENTCHIP *)aRecv, aIndex);
  601. break;
  602. case GET_MUTO_NUM_RECV: //0x96:
  603. GCGetMutoNumRecv((PMSG_GETMUTONUMBER *)aRecv, aIndex);
  604. break;
  605. case USE_END_EVENT_CHIP_RECV: //0x97:
  606. GCUseEndEventChipRescv(aIndex);
  607. break;
  608. case USE_RENA_CHANGE_ZEN_RECV: //0x98:
  609. GCUseRenaChangeZenRecv((PMSG_EXCHANGE_EVENTCHIP *)aRecv, aIndex);
  610. break;
  611. case REQ_MOVE_OTHER_SERVER: //0x99:
  612. CGReqMoveOtherServer((PMSG_REQ_MOVE_OTHERSERVER *)aRecv, aIndex);
  613. break;
  614. case REQ_QUEST_INFO: //0xA0:
  615. CGRequestQuestInfo(aIndex);
  616. break;
  617. case SET_QUEST_STATE: //0xA2:
  618. CGSetQuestState((PMSG_SETQUEST *)aRecv, aIndex);
  619. break;
  620.  
  621.  
  622. case REQ_PET_ITEM_COMMAND: //0xA7:
  623. CGRequestPetItemCommand((PMSG_REQUEST_PET_ITEM_COMMAND *)aRecv, aIndex);
  624. break;
  625. case 0xA9:
  626. CGRequestPetItemInfo((PMSG_REQUEST_PET_ITEMINFO *)aRecv, aIndex);
  627. break;
  628.  
  629. case DUEL_START_REQ_RECV: //0xAA:
  630. CGDuelStartRequestRecv((PMSG_REQ_START_DUEL *)aRecv, aIndex);
  631. break;
  632. case DUEL_END_REQ_RECV: //0xAB:
  633. CGDuelEndRequestRecv((PMSG_REQ_END_DUEL *)aRecv, aIndex);
  634. break;
  635. case DUEL_OK_REQ_RECV: //0xAC:
  636. CGDuelOkRequestRecv((PMSG_ANS_DUEL_OK *)aRecv, aIndex);
  637. break;
  638. case REQ_ENTER_BLOODCASTLE: //0x9A:
  639. CGRequestEnterBloodCastle((PMSG_REQ_MOVEBLOODCASTLE*)aRecv, aIndex);
  640. break;
  641. case LACKING_PACKET_PROTOCOL_ID: //0x9B:
  642. //#error LAcking PACKET HERE
  643. break;
  644. case REQ_EVENT_ENTER_COUNT: //0x9F:
  645. CGRequestEventEnterCount((PMSG_REQ_CL_ENTERCOUNT *)aRecv, aIndex);
  646. break;
  647. case REQ_LOTTO_REGISTER: //0x9D:
  648. CGRequestLottoRegister((PMSG_REQ_2ANV_LOTTO_EVENT *)aRecv, aIndex);
  649. break;
  650. case CHAOSCASTLE_PROTOCOL_ID: //0xAF:
  651. {
  652. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  653.  
  654. switch (lpDef->subcode)
  655. {
  656. case REQ_ENTER_CHAOSCASTLE: //0x01:
  657. CGRequestEnterChaosCastle((PMSG_REQ_MOVECHAOSCASTLE *)aRecv, aIndex);
  658. break;
  659. case REQ_REPOSITION_USER_IN_CHAOSCASTLE: //0x02:
  660. CGRequestRepositionUserInChaosCastle((PMSG_REQ_REPOSUSER_IN_CC *)aRecv, aIndex);
  661. break;
  662. }
  663. }
  664. break;
  665. case FRIEND_LIST_REQ: //0xC0:
  666. FriendListRequest(aIndex);
  667. break;
  668. case FRIEND_ADD_REQ: //0xC1:
  669. FriendAddRequest((PMSG_FRIEND_ADD_REQ *)aRecv, aIndex);
  670. break;
  671. case WAIT_FRIEND_ADD_REQ: //0xC2:
  672. WaitFriendAddRequest((PMSG_FRIEND_ADD_SIN_RESULT *)aRecv, aIndex);
  673. break;
  674. case FRIEND_DELETE_REQ: //0xC3:
  675. FriendDelRequest((PMSG_FRIEND_DEL_REQ *)aRecv, aIndex);
  676. break;
  677. case FRIEND_STATE_CLIENT_RECV: //0xC4:
  678. FriendStateClientRecv((PMSG_FRIEND_STATE_C *)aRecv, aIndex);
  679. break;
  680. case FRIEND_MEMO_SEND: //0xC5:
  681. FriendMemoSend((PMSG_FRIEND_MEMO *)aRecv, aIndex);
  682. break;
  683. case FRIEND_MEMO_READ_REQ: //0xC7:
  684. FriendMemoReadReq((PMSG_FRIEND_READ_MEMO_REQ *)aRecv, aIndex);
  685. break;
  686. case FRIEND_MEMO_DELETE_REQ: //0xC8:
  687. FriendMemoDelReq((PMSG_FRIEND_MEMO_DEL_REQ *)aRecv, aIndex);
  688. break;
  689. case FRIEND_MEMO_LIST_REQ: //0xC9:
  690. FriendMemoListReq(aIndex);
  691. break;
  692. case FRIEND_CHAT_ROOM_CREATE_REQ: //0xCA:
  693. FriendChatRoomCreateReq((PMSG_FRIEND_ROOMCREATE_REQ *)aRecv, aIndex);
  694. break;
  695. case FRIEND_ROOM_INVITATION_REQ: //0xCB:
  696. FriendRoomInvitationReq((PMSG_ROOM_INVITATION *)aRecv, aIndex);
  697. break;
  698.  
  699. case 0xD0:
  700. {
  701. PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
  702.  
  703. //LogAddC(2, "HEAD: %x, SUB: %x",protoNum, lpDef->subcode);
  704.  
  705. switch ( lpDef->subcode )
  706. {
  707. case 0x07:
  708. CGReqWerewolfMove((PMSG_REQ_WEREWOLF_MOVE *)aRecv, aIndex);
  709. break;
  710. case 0x08:
  711. CGReqGatekeeperMove((PMSG_REQ_GATEKEEPER_MOVE *)aRecv, aIndex);
  712. break;
  713.  
  714.  
  715.  
  716.  
  717. case 0x10:
  718. // CGReqXMasSetPayItem((PMSG_REQ_XMAS_PAYITEM *)aRecv, aIndex);
  719. break;
  720. case 0x0A:
  721. // CGReqXMasToDeviasMapMove((PMSG_REQ_XMASNPCMAP_MOVE *)aRecv, aIndex);
  722. break;
  723. }
  724. }
  725. break;
  726. case KANTURU_PROTOCOL_ID: //0xD1:
  727. {
  728. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  729.  
  730. switch (lpDef->subcode)
  731. {
  732. case REQ_KANTURU_STATE_INFO: //0x00:
  733. CGReqKanturuStateInfo((PMSG_REQ_KANTURU_STATE_INFO *)aRecv, aIndex);
  734. break;
  735. case REQ_KANTURU_ENTER_BOSS_MAP: //0x01:
  736. GCReqEnterKanturuBossMap((PMSG_REQ_ENTER_KANTURU_BOSS_MAP *)aRecv, aIndex);
  737. break;
  738. }
  739. }
  740. break;
  741. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  742. /////////////////////////////CashShopProtocol Edit////////////////////////////////////////////////////////
  743. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  744. case 0xF5: //0xF5:
  745. {
  746. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  747.  
  748. switch (lpDef->subcode)
  749. {
  750. case 0x01: //0x01:
  751. g_CashShop.CGCashShopOpen(lpObj, (PMSG_REQ_CASHSHOPOPEN *)aRecv);
  752. break;
  753. case 0x03: //0x03:
  754. g_CashShop.CGCashPoint(lpObj);
  755. break;
  756. case 0x05: //0x05:
  757. g_CashShop.GCCashItemListSend(&gObj[aIndex], (PMSG_REQ_CASHITEMLIST *)aRecv);
  758. break;
  759. case CASH_ITEM_BUY: //0x07:
  760. g_CashShop.CGCashItemBuy(&gObj[aIndex], (PMSG_REQ_CASHITEM_BUY *)aRecv);
  761. break;
  762. }
  763. }
  764. break;
  765. #ifdef MULTI_CHARACTERS
  766. case 0xFA:
  767. {
  768. DataServerGetCharListRequestMultiChar(aIndex, (SDHP_GETNUMPAGE_MULTICHAR*)aRecv);
  769. }
  770. break;
  771. #endif
  772. case 0xFB:
  773. {
  774. g_ConnectEx.SendLogin(aIndex, (CONNECTEX_LOGIN*)aRecv);
  775. }
  776. break;
  777. case 0xFC:
  778. {
  779. DisconnectEx((DISCONNECTEX*)aRecv);
  780. }
  781. break;
  782. case 0xFD:
  783. {
  784. ClientAccept(aIndex, (PMSG_CLIENT_ACCEPT*)aRecv);
  785.  
  786. }
  787. break;
  788. #ifdef MULTI_WAREHOUSE
  789. case 0xFE:
  790. {
  791. PMSG_DEFAULT2 *lpDef = (PMSG_DEFAULT2*)aRecv;
  792.  
  793. switch (lpDef->subcode)
  794. {
  795. case 0x01: //0x01:
  796. BankNumberOpen(aIndex, (BANK_OPEN_NUM *)aRecv);
  797. break;
  798. case 0x02: //0x01:
  799. BankNumberCreate(aIndex, (CREATE_BANK *)aRecv);
  800. break;
  801. }
  802. }
  803. break;
  804. #endif
  805. //case 0xFD:
  806. // {
  807. // g_NewsBoard.OpenMain(&gObj[aIndex]);
  808. // }
  809. // break;
  810. // // --
  811. //case 0xFE:
  812. // {
  813. // g_NewsBoard.OpenItem(&gObj[aIndex], (NEWS_REQ_NEWS*)aRecv);
  814. // }
  815. // break;
  816.  
  817. //////////////////////////////////////////////////////////////////////////////////////////////////////////
  818. default:
  819. LogAddC(2, "error-L2 : account:%s name:%s HEAD:%x (%s,%d) State:%d",
  820. gObj[aIndex].AccountID, gObj[aIndex].Name, protoNum, __FILE__, __LINE__, gObj[aIndex].Connected);
  821. CloseClient(aIndex);
  822. }
  823. #ifdef DEBUG_SYSTEM_PROTOCOL
  824. LogAddC(2, "%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", aRecv[0], aRecv[1], aRecv[2], aRecv[3], aRecv[4], aRecv[5], aRecv[6], aRecv[7], aRecv[8], aRecv[9], aRecv[10], aRecv[11], aRecv[12], aRecv[13], aRecv[14], aRecv[15], aRecv[16], aRecv[17], aRecv[18], aRecv[19], aRecv[20], aRecv[21], aRecv[22], aRecv[23], aRecv[24], aRecv[25], aRecv[26], aRecv[27], aRecv[28], aRecv[29], aRecv[30]);
  825. #endif
  826. }
  827.  
  828. }
  829. #ifdef MULTI_WAREHOUSE
  830.  
  831. void BankNumberOpen(int aIndex, BANK_OPEN_NUM * lpData)
  832. {
  833. gObj[aIndex].WarehouseNum = lpData->BankNum;
  834. gObj[aIndex].WarehouseCount = 0;
  835. gObj[aIndex].m_ReqWarehouseOpen = true;
  836. gObj[aIndex].m_IfState.type = 6;
  837. gObj[aIndex].m_IfState.state = 0;
  838. GDGetWarehouseList(aIndex, gObj[aIndex].AccountID);
  839. }
  840.  
  841. struct PMSG_WAREHOUSE_PRICE
  842. {
  843. PBMSG_HEAD h; // C1:
  844. DWORD PRICE; // 4
  845. };
  846.  
  847. void BankNumberCreate(int aIndex, CREATE_BANK * lpData)
  848. {
  849. if (gObj[aIndex].TotalWarehouseHave >= 12)
  850. {
  851. LogAddC(3, "[MULTI WAREHOUSE][%s][%s]Maximum warehouse have ", gObj[aIndex].AccountID, gObj[aIndex].Name);
  852. return;
  853. }
  854. CreateEmptyWarehouse(aIndex, gObj[aIndex].TotalWarehouseHave + 1);
  855. OpenMultiWarehouse(aIndex);
  856. }
  857. #endif
  858. void ClientAccept(int aIndex,PMSG_CLIENT_ACCEPT * lpData)
  859. {
  860. if (lpData->Accept != 0)
  861. {
  862.  
  863. LogAddC(3, "The player has confirmed the original client [aIndex: %d]",aIndex-1);
  864. gObj[aIndex].ClientAccept = 1;
  865. }
  866.  
  867. }
  868. void DisconnectEx(DISCONNECTEX * lpData)
  869. {
  870. int UserIndex = gObjGetIndexByAccount(lpData->AccountID);
  871. // ----
  872. if( UserIndex == -1 )
  873. {
  874. return;
  875. }
  876. // ----
  877. LPOBJ lpUser = &gObj[UserIndex];
  878. // ----
  879. //if( strcmp(lpUser->m_Password, lpData->Password) )
  880. //{
  881. // return;
  882. //}
  883. // ----
  884. //g_ConnectEx.SendClose(UserIndex);
  885. CloseClient(UserIndex);
  886. }
  887. void TestSend()
  888. {
  889. PMSG_TEST pMsg;
  890. int size = sizeof(pMsg);
  891. pMsg.h.c = 0xC2;
  892. pMsg.h.headcode = 0xFF; // Test Packet
  893. pMsg.h.sizeH = SET_NUMBERH(size);
  894. pMsg.h.sizeL = SET_NUMBERL(size);
  895. DataSend( tempindex, (LPBYTE)&pMsg, size);
  896. DataSend( tempindex, (LPBYTE)&pMsg, size);
  897. LogAdd("TEST Data Send");
  898. }
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907. void MsgSendV2(LPOBJ lpObj, unsigned char* Msg, int size)
  908. {
  909. for ( int n=0;n<MAX_VIEWPORT;n++)
  910. {
  911. if ( lpObj->VpPlayer2[n].type == OBJ_USER )
  912. {
  913. if ( lpObj->VpPlayer2[n].state != 0 )
  914. {
  915. DataSend(lpObj->VpPlayer2[n].number, Msg, size);
  916. }
  917. }
  918. }
  919. }
  920.  
  921. void CGLiveClient(PMSG_CLIENTTIME * lpClientTime, short aIndex)
  922. {
  923. if (gObj[aIndex].Connected > PLAYER_CONNECTED)
  924. {
  925. gObj[aIndex].ConnectCheckTime = GetTickCount();
  926. }
  927.  
  928. //if (gObj[aIndex].CheckSpeedHack != false)
  929. //{
  930. // int systemtick = GetTickCount() - gObj[aIndex].CheckTick2;
  931. // int usertick = lpClientTime->Time - gObj[aIndex].CheckTick;
  932. // int checktime = systemtick - usertick;
  933. //
  934. // if (checktime < -7000)
  935. // {
  936. // LogAddTD(lMsg.Get(MSGGET(1, 214)), gObj[aIndex].AccountID, gObj[aIndex].Name, checktime);
  937. // CloseClient(aIndex);
  938. // }
  939. //
  940. // gObj[aIndex].CheckTickCount++;
  941. //
  942. // if (gObj[aIndex].CheckTickCount > 45)
  943. // {
  944. // gObj[aIndex].CheckTick = lpClientTime->Time;
  945. // gObj[aIndex].CheckTickCount = 0;
  946. // }
  947. //}
  948.  
  949. if (gObj[aIndex].Connected == PLAYER_PLAYING)
  950. {
  951. //int SpeedCheck = gObj[aIndex].m_AttackSpeed + 30;
  952. //int MagicSpeedCheck = gObj[aIndex].m_MagicSpeed + 30;
  953. //if ( SpeedCheck < lpClientTime->AttackSpeed || MagicSpeedCheck < lpClientTime->MagicSpeed )
  954. //{
  955. // LogAddC(2, "[%s][%s][%s] ClientHack Detected : Editing AttackSpeed [%d][%d] [%d][%d]",
  956. // gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].Ip_addr,
  957. // gObj[aIndex].m_AttackSpeed, lpClientTime->AttackSpeed, gObj[aIndex].m_MagicSpeed,
  958. // lpClientTime->MagicSpeed);
  959. // gObj[aIndex].m_AttackSpeedHackDetectedCount++;
  960. //
  961. // if (gObj[aIndex].m_AttackSpeedHackDetectedCount > 3)
  962. // {
  963. // CloseClient(aIndex);
  964. // }
  965. //}
  966. //else
  967. //{
  968. // gObj[aIndex].m_AttackSpeedHackDetectedCount = 0;
  969. //}
  970. gObj[aIndex].m_AttackSpeedHackDetectedCount = 0;
  971. #if (FOREIGN_GAMESERVER == 1)
  972. if (szAuthKey[10] != AUTHKEY10)
  973. DestroyGIocp();
  974.  
  975. if (szAuthKey[11] != AUTHKEY11)
  976. DestroyGIocp();
  977. #endif
  978.  
  979.  
  980. }
  981. }
  982.  
  983.  
  984.  
  985. struct PMSG_CHECK_MAINEXE
  986. {
  987. PBMSG_HEAD h; // C1:03
  988. WORD m_wKey; // 4
  989. };
  990.  
  991. void GCCheckMainExeKeySend(int aIndex)
  992. {
  993. PMSG_CHECK_MAINEXE pMsg;
  994.  
  995. gObj[aIndex].CheckSumTableNum = rand() % MAX_CHECKSUM_KEY;
  996. gObj[aIndex].CheckSumTime = GetTickCount();
  997. PHeadSetB((LPBYTE)&pMsg, 0x03, sizeof(pMsg));
  998. pMsg.m_wKey = EncryptCheckSumKey(gObj[aIndex].CheckSumTableNum);
  999.  
  1000. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  1001. }
  1002.  
  1003. WORD EncryptCheckSumKey(WORD wSource)
  1004. {
  1005. WORD wRandom = rand() % 64;
  1006. WORD wAcc = ((wSource & 0x3F0) * 64) | (wRandom * 16) | (wSource & 0x0F);
  1007. return wAcc ^ 0xB479;
  1008. }
  1009.  
  1010. void CGCheckMainRecv(PMSG_CHECK_MAINEXE_RESULT *lpMsg, int aIndex)
  1011. {
  1012.  
  1013. #ifdef ENABLE_CHECKSUM
  1014.  
  1015.  
  1016. /* if (strcmp(gObj[aIndex].Ip_addr, "218.234.76.254") == 0) // #warning To Prevent HAckrs
  1017. {
  1018. gObj[aIndex].CheckSumTime = 0;
  1019. gObj[aIndex].m_InWebzen = true;
  1020. return;
  1021. } */
  1022.  
  1023. if (gObj[aIndex].CheckSumTableNum < 0 || gObj[aIndex].CheckSumTableNum > MAX_CHECKSUM_KEY - 1)
  1024. {
  1025. LogAdd("error-L1 : [%s][%s] CheckSum-Exe error ", gObj[aIndex].AccountID, gObj[aIndex].Name);
  1026. CloseClient(aIndex);
  1027. return;
  1028. }
  1029.  
  1030. if (dwgCheckSum[gObj[aIndex].CheckSumTableNum] != lpMsg->m_dwKey)
  1031. {
  1032. LogAddTD("error-L1 : CheckSum-Exe error %d %d %d [%s]", dwgCheckSum[gObj[aIndex].CheckSumTableNum],
  1033. lpMsg->m_dwKey, gObj[aIndex].CheckSumTableNum, gObj[aIndex].AccountID);
  1034. CloseClient(aIndex);
  1035. return;
  1036. }
  1037.  
  1038. gObj[aIndex].CheckSumTime = 0;
  1039.  
  1040. #else
  1041. gObj[aIndex].CheckSumTime = 0;
  1042. gObj[aIndex].m_InWebzen = true;
  1043. return;
  1044.  
  1045. #endif
  1046. }
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054. void PEchoProc(unsigned char * aMsg, int aLen, short aIndex)
  1055. {
  1056. for ( int n = 0 ; n< OBJMAX ; n++)
  1057. {
  1058. if ( gObj[n].Connected >= PLAYER_CONNECTED )
  1059. {
  1060. DataSend(n, aMsg, aLen);
  1061. }
  1062. }
  1063. }
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074. void GCResultSend(int aIndex, BYTE headcode, BYTE result)
  1075. {
  1076. PMSG_DEFRESULT pResult;
  1077.  
  1078. PHeadSetB((LPBYTE)&pResult, headcode, sizeof(pResult));
  1079. pResult.result = result;
  1080.  
  1081. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  1082. }
  1083.  
  1084.  
  1085.  
  1086.  
  1087. void ChatSend(LPOBJ lpObj, char* szChat)
  1088. {
  1089. int len = strlen(szChat);
  1090.  
  1091. if ( len < 1 )
  1092. return;
  1093.  
  1094. if ( len > MAX_CHAT_LEN-1 )
  1095. return;
  1096.  
  1097. /* char szTempMsg[4096] = {0};
  1098. MultiByteToWideChar(1258, 0, szChat, len, (unsigned short *)szTempMsg, sizeof(szTempMsg));
  1099. memcpy(&pMsg.szChatMsg, szTempMsg, sizeof(pMsg.szChatMsg));
  1100. pMsg.szChatMsg[MAX_CHAT_LEN-2]=0;
  1101. pMsg.szChatMsg[MAX_CHAT_LEN-1]=0;
  1102. PHeadSetB((LPBYTE)&pMsg, 0x01, wcslen((unsigned short*)pMsg.szChatMsg)*2 + (sizeof(GC_CHATSEND)-sizeof(pMsg.szChatMsg)));
  1103. pMsg.sIndex[0] = lpObj->m_Index >> 8;
  1104. pMsg.sIndex[1] = lpObj->m_Index & 0xFF;*/
  1105.  
  1106. PMSG_CHATDATA_NUMBER pMsg;
  1107.  
  1108. PHeadSetB((LPBYTE)&pMsg, 0x01, len+6);
  1109. strcpy(pMsg.chatmsg, szChat);
  1110. pMsg.NumberH = SET_NUMBERH(lpObj->m_Index);
  1111. pMsg.NumberL = SET_NUMBERL(lpObj->m_Index);
  1112.  
  1113. MsgSendV2(lpObj, (UCHAR*)&pMsg, pMsg.h.size);
  1114. }
  1115.  
  1116.  
  1117.  
  1118. /*
  1119.  
  1120. void vChatSend(LPOBJ lpObj, char* szChat, ...)
  1121. {
  1122. char szBuffer[256] = "";
  1123. va_list pArguments;
  1124.  
  1125. va_start(pArguments, szChat);
  1126. vsprintf(szBuffer, szChat, pArguments);
  1127. va_end(pArguments);
  1128.  
  1129. int len = strlen(szBuffer);
  1130.  
  1131. if ( len < 1 )
  1132. return;
  1133.  
  1134. if ( len > MAX_CHAT_LEN-1 )
  1135. return;
  1136.  
  1137. // char szTempMsg[4096] = {0};
  1138. // MultiByteToWideChar(1258, 0, szChat, len, (unsigned short*)szTempMsg, sizeof(szTempMsg));
  1139. // memcpy(&pMsg.szChatMsg, szTempMsg, sizeof(pMsg.szChatMsg));
  1140. // pMsg.szChatMsg[MAX_CHAT_LEN-2]=0;
  1141. // pMsg.szChatMsg[MAX_CHAT_LEN-1]=0;
  1142. // PHeadSetB((LPBYTE)&pMsg, 0x01, wcslen((unsigned short*)pMsg.szChatMsg)*2 + (sizeof(GC_CHATSEND)-sizeof(pMsg.szChatMsg)));
  1143. // pMsg.sIndex[0] = lpObj->m_Index >> 8;
  1144. // pMsg.sIndex[1] = lpObj->m_Index & 0xFF;
  1145.  
  1146. PMSG_CHATDATA_NUMBER pMsg;
  1147.  
  1148. PHeadSetB((LPBYTE)&pMsg, 0x01, len+6);
  1149. strcpy(pMsg.chatmsg, szBuffer);
  1150. pMsg.NumberH = SET_NUMBERH(lpObj->m_Index);
  1151. pMsg.NumberL = SET_NUMBERL(lpObj->m_Index);
  1152.  
  1153. MsgSendV2(lpObj, (UCHAR*)&pMsg, pMsg.h.size);
  1154. }
  1155. */
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164. void AllSendServerMsg( char* chatmsg)
  1165. {
  1166. PMSG_NOTICE pNotice;
  1167.  
  1168. TNotice::MakeNoticeMsg((TNotice*)&pNotice, 0x00, chatmsg);
  1169.  
  1170. for ( int n = OBJ_STARTUSERINDEX ; n < OBJMAX ; n++)
  1171. {
  1172. if ( gObj[n].Connected == PLAYER_PLAYING )
  1173. {
  1174. if ( gObj[n].Type == OBJ_USER )
  1175. {
  1176. DataSend(n, (unsigned char*)&pNotice , pNotice.h.size );
  1177. }
  1178. }
  1179. }
  1180. }
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186. void DataSendAll(unsigned char* lpMsg, int iMsgSize)
  1187. {
  1188. for ( int n = OBJ_STARTUSERINDEX ; n < OBJMAX ; n++)
  1189. {
  1190. if ( gObj[n].Connected == PLAYER_PLAYING )
  1191. {
  1192. if ( gObj[n].Type == OBJ_USER )
  1193. {
  1194. DataSend(n, (unsigned char*)lpMsg , iMsgSize );
  1195. }
  1196. }
  1197. }
  1198. }
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205. void ChatTargetSend(LPOBJ lpObj, char * szChat, int senduser)
  1206. {
  1207. int len = strlen(szChat);
  1208.  
  1209. if ( len < 1 || len > MAX_CHAT_LEN-1)
  1210. return;
  1211.  
  1212. PMSG_CHATDATA_NUMBER pMsg;
  1213.  
  1214. PHeadSetB((LPBYTE)&pMsg, 0x01, len+6);
  1215. strcpy(pMsg.chatmsg, szChat);
  1216. pMsg.NumberH = SET_NUMBERH(lpObj->m_Index);
  1217. pMsg.NumberL = SET_NUMBERL(lpObj->m_Index);
  1218. pMsg.chatmsg[len+1] = 0;
  1219.  
  1220. DataSend(senduser, (UCHAR*)&pMsg, pMsg.h.size);
  1221. }
  1222.  
  1223.  
  1224.  
  1225.  
  1226. struct CHAT_LOG_DATA
  1227. {
  1228. PBMSG_HEAD h; // C1:02
  1229. WORD wServer; // 4
  1230. char AccountID[11]; // 6
  1231. char Name[11]; // 11
  1232. BYTE btType; // 1C
  1233. char szChatMsg[61]; // 1D
  1234. char szTargetName[5][11]; // 5A
  1235. };
  1236. bool CheckAuthorityCondition(int AuthorityCode, LPOBJ lpObj)
  1237. {
  1238. return ((lpObj->Authority & AuthorityCode) == lpObj->Authority) ? true : false;
  1239. }
  1240.  
  1241.  
  1242.  
  1243. void PChatProc(PMSG_CHATDATA * lpChat, short aIndex)
  1244. {
  1245.  
  1246. int n;
  1247. LPOBJ lpObj = &gObj[aIndex];
  1248. int number;
  1249.  
  1250. BOOL ChatChecked;
  1251.  
  1252. //CheckCommands(lpObj, lpChat);
  1253.  
  1254. //int CheckOk = 1;
  1255. //for (int i = 0; i < 60; i++)
  1256. //{
  1257. // if (lpChat->chatmsg[i] == '%')
  1258. // {
  1259. // if ((lpChat->chatmsg[i + 1] == 'd') || (lpChat->chatmsg[i + 1] == 's') || (lpChat->chatmsg[i + 1] == 'D') || (lpChat->chatmsg[i + 1] == 'S'))
  1260. // {
  1261. // //CheckOk = 0;
  1262. // LogAddC(5, "[AntiHack][%s][%s]Attept to Crush Server [%s]", lpObj->AccountID, lpObj->Name, lpChat->chatmsg);
  1263. // //lpChat->chatmsg[60] = "Hello";
  1264. // //lpChat->chatmsg[60] = 0;
  1265. // memcpy(lpChat->chatmsg, "hello", sizeof("hello"));
  1266. // }
  1267. // }
  1268. //
  1269. //}
  1270. int slen = strlen(lpChat->chatmsg);
  1271.  
  1272.  
  1273. if ( slen < 1 )
  1274. return;
  1275.  
  1276. if ( slen > MAX_CHAT_LEN-1 )
  1277. {
  1278. LogAddTD("[Anti-HACK][PChatProc][%s][%s] Chat Message Len : %d", lpObj->AccountID, lpObj->Name, slen);
  1279. return;
  1280. }
  1281.  
  1282. char szId[MAX_ACCOUNT_LEN+1];
  1283. szId[MAX_ACCOUNT_LEN] = 0;
  1284. CHAT_LOG_DATA pChatMsg;
  1285.  
  1286. memcpy(szId, gObj[aIndex].Name, MAX_ACCOUNT_LEN);
  1287. memcpy(lpChat->chatid, szId, MAX_ACCOUNT_LEN);
  1288. int szTargetNameCount = 0;
  1289.  
  1290.  
  1291.  
  1292. if ( gWriteChatLog )
  1293. {
  1294. pChatMsg.h.c = 0xC1;
  1295. pChatMsg.h.headcode = 0x02;
  1296. memcpy(pChatMsg.AccountID, gObj[aIndex].AccountID, MAX_ACCOUNT_LEN);
  1297. memcpy(pChatMsg.Name, gObj[aIndex].Name, MAX_ACCOUNT_LEN);
  1298. pChatMsg.AccountID[MAX_ACCOUNT_LEN] = 0;
  1299. pChatMsg.Name[MAX_ACCOUNT_LEN] = 0;
  1300. pChatMsg.wServer = gGameServerCode;
  1301. pChatMsg.btType = 0xFF;
  1302. }
  1303.  
  1304. //if (CheckCommands(lpObj, lpChat))
  1305. //{
  1306. //ChatChecked = false;
  1307.  
  1308. //return;
  1309. //}
  1310. //else
  1311. //{
  1312. // ChatChecked = true;
  1313. //}
  1314. //for (int i = 0; i < 60; i++)
  1315. //{
  1316. // if (lpChat->chatmsg[i] == '%')
  1317. // {
  1318. // if ((lpChat->chatmsg[i + 1] == 'd') || (lpChat->chatmsg[i + 1] == 's') || (lpChat->chatmsg[i + 1] == 'D') || (lpChat->chatmsg[i + 1] == 'S'))
  1319. // {
  1320. // // CheckOk = 0;
  1321. // LogAddC(5, "[AntiHack][%s][%s]Attept to Crush Server [%s]", lpObj->AccountID, lpObj->Name, lpChat->chatmsg);
  1322. // lpChat->chatmsg = 0;
  1323. // }
  1324. // }
  1325. //
  1326. //}
  1327.  
  1328. if (s_Match.CheckIsMatchActive())
  1329. {
  1330. s_Match.CheckCurAnswer(lpObj->m_Index, atoi(lpChat->chatmsg));
  1331. }
  1332. if (s_Guess.CheckIsGuessActive())
  1333. {
  1334. s_Guess.CheckCurAnswer(lpObj->m_Index, atoi(lpChat->chatmsg));
  1335. }
  1336. #ifdef CUSTOM_PROPENSITY_SYSTEM
  1337. if(gObj[aIndex].GuildNumber >= 0)
  1338. {
  1339.  
  1340. if(gObj[aIndex].GuildStatus == GUILD_MASTER)
  1341. {
  1342.  
  1343. if(gObj[aIndex].GuildPropersity < 1)
  1344. {
  1345. if ((!memcmp(lpChat->chatmsg, "light", strlen("light")))
  1346. ||(!memcmp(lpChat->chatmsg, "/light", strlen("/light")))
  1347. ||(!memcmp(lpChat->chatmsg, "Light", strlen("Light")))
  1348. ||(!memcmp(lpChat->chatmsg, "/Light", strlen("/Light"))))
  1349. CPropensity::SetLightGuild(lpObj, lpChat);
  1350.  
  1351. if ((!memcmp(lpChat->chatmsg, "chaos", strlen("chaos")))
  1352. ||(!memcmp(lpChat->chatmsg, "/chaos", strlen("/chaos")))
  1353. ||(!memcmp(lpChat->chatmsg, "Chaos", strlen("Chaos")))
  1354. ||(!memcmp(lpChat->chatmsg, "/Chaos", strlen("/Chaos"))) )
  1355. CPropensity::SetChaosGuild(lpObj, lpChat);
  1356.  
  1357.  
  1358. if ((!memcmp(lpChat->chatmsg, "darkness", strlen("darkness")))
  1359. ||(!memcmp(lpChat->chatmsg, "/darkness", strlen("/darkness")))
  1360. ||(!memcmp(lpChat->chatmsg, "Darkness", strlen("Darkness")))
  1361. ||(!memcmp(lpChat->chatmsg, "/Darkness", strlen("/Darkness"))) )
  1362. CPropensity::SetDarknessGuild(lpObj, lpChat);
  1363.  
  1364. if ((!memcmp(lpChat->chatmsg, "harmony", strlen("harmony")))
  1365. ||(!memcmp(lpChat->chatmsg, "/harmony", strlen("/harmony")))
  1366. ||(!memcmp(lpChat->chatmsg, "Harmony", strlen("Harmony")))
  1367. ||(!memcmp(lpChat->chatmsg, "/Harmony", strlen("/Harmony"))) )
  1368. CPropensity::SetHarmonyGuild(lpObj, lpChat);
  1369.  
  1370. }
  1371. }
  1372. }
  1373.  
  1374. #endif
  1375.  
  1376. switch ( lpChat->chatmsg[0] )
  1377. {
  1378. case '!': // Global Announcement
  1379. if ( slen > 2 )
  1380. {
  1381. //NEED ADD GM SYSTEM
  1382. if ( CheckAuthorityCondition(98, lpObj) == true) //season4 changed
  1383. {
  1384. DataSend(aIndex, (LPBYTE)lpChat, lpChat->h.size);
  1385. AllSendServerMsg(&lpChat->chatmsg[1]);
  1386.  
  1387. LogAddTD(lMsg.Get(MSGGET(1, 215)), gObj[aIndex].AccountID, gObj[aIndex].Name, &lpChat->chatmsg[1]);
  1388.  
  1389. if ( gWriteChatLog )
  1390. {
  1391. memcpy(pChatMsg.szChatMsg, &lpChat->chatmsg[1], MAX_CHAT_LEN-1);
  1392. pChatMsg.szChatMsg[MAX_CHAT_LEN] = 0;
  1393. pChatMsg.btType = 0x03;
  1394. }
  1395.  
  1396. char pBufferLog[90];
  1397. sprintf(pBufferLog, "[%s][%s] %s",lpObj->AccountID,lpObj->Name, &lpChat->chatmsg[1]);
  1398. Log.SaveLogInFile(Log.t_GM_GLOBAL,pBufferLog);
  1399.  
  1400. return;
  1401. }
  1402. }
  1403. break;
  1404. case '#': // Command
  1405. if ( slen > 2 )
  1406. {
  1407. if (!g_Configs.Commands.IsPost)
  1408. {
  1409. GCServerMsgStringSend("The command '#' is not available", lpObj->m_Index, 1);
  1410. return;
  1411. }
  1412. //----
  1413. //if (!CCommandSystem::ValidateSyntax(lpObj, lpChat->chatmsg, "/post"))
  1414. // return;
  1415. //----
  1416. if (lpObj->Level < g_Configs.Commands.PostLevelReq)
  1417. {
  1418. char pMsg[MAX_CHAT_LEN];
  1419. sprintf(pMsg, "You don\'t have enough level [%d] to use '#' command", g_Configs.Commands.PostLevelReq);
  1420. GCServerMsgStringSend(pMsg, lpObj->m_Index, 1); return;
  1421. }
  1422. //----
  1423. if (lpObj->Money < g_Configs.Commands.PostZenReq)
  1424. {
  1425. char pMsg[MAX_CHAT_LEN];
  1426. sprintf(pMsg, "You don\'t have enough money [%d] to use '#' command", lpObj->Money);
  1427. GCServerMsgStringSend(pMsg, lpObj->m_Index, 1); return;
  1428. }
  1429. //----
  1430. lpObj->Money -= g_Configs.Commands.PostZenReq;
  1431. GCMoneySend(lpObj->m_Index, lpObj->Money);
  1432. //----
  1433.  
  1434. if (lpObj->BanPost == 1)
  1435. {
  1436. char pMsg[MAX_CHAT_LEN];
  1437. sprintf(pMsg, "You is banned in post", lpObj->Money);
  1438. GCServerMsgStringSend(pMsg, lpObj->m_Index, 1); return;
  1439. }
  1440. #ifdef VIP_SYSTEM
  1441. if (lpObj->TimeLeftTick > 0)
  1442. {
  1443. g_Configs.Commands.PostColor = s_Vip.GetPostColorChange(lpObj->VipGroup);
  1444.  
  1445. }
  1446. #endif
  1447.  
  1448.  
  1449.  
  1450. switch (g_Configs.Commands.PostColor)
  1451. {
  1452. case E_POST::C_YELLOW:
  1453. {
  1454. strcpy(lpChat->chatid, lpObj->Name);
  1455. char pBuffer[MAX_CHAT_LEN];
  1456. sprintf(pBuffer, "[POST] %s", &lpChat->chatmsg[strlen("#")]);
  1457. memcpy(&lpChat->chatmsg, &pBuffer, strlen(pBuffer) + 1);
  1458. PHeadSetB((LPBYTE)lpChat, 0x02, sizeof(pBuffer) + 13);
  1459.  
  1460. for (int i = OBJ_STARTUSERINDEX; i < OBJMAX; i++)
  1461. {
  1462. if (gObj[i].Connected >= 3)
  1463. {
  1464. DataSend(i, (LPBYTE)lpChat, lpChat->h.size);
  1465. }
  1466. }
  1467. char pBufferLog[90];
  1468. sprintf(pBufferLog, "[%s][%s]Use Post [Text]: %s",lpObj->AccountID,lpObj->Name, &lpChat->chatmsg[strlen("#")]);
  1469. Log.SaveLogInFile(Log.t_CHAT_POST,pBufferLog);
  1470. return;
  1471. }
  1472. break;
  1473.  
  1474. case E_POST::C_BLUE:
  1475. {
  1476. strcpy(lpChat->chatid, lpObj->Name);
  1477. char pBuffer[MAX_CHAT_LEN];
  1478. sprintf(pBuffer, "~[POST] %s", &lpChat->chatmsg[strlen("#")]);
  1479. memcpy(&lpChat->chatmsg, &pBuffer, strlen(pBuffer) + 1);
  1480. PHeadSetB((LPBYTE)lpChat, 0x00, sizeof(pBuffer) + 13);
  1481.  
  1482. for (int i = OBJ_STARTUSERINDEX; i < OBJMAX; i++)
  1483. {
  1484. if (gObj[i].Connected >= 3)
  1485. {
  1486. DataSend(i, (LPBYTE)lpChat, lpChat->h.size);
  1487. }
  1488. }
  1489. char pBufferLog[90];
  1490. sprintf(pBufferLog, "[%s][%s]Use Post [Text]: %s",lpObj->AccountID,lpObj->Name, &lpChat->chatmsg[strlen("#")]);
  1491. Log.SaveLogInFile(Log.t_CHAT_POST,pBufferLog);
  1492. return;
  1493. }
  1494. break;
  1495.  
  1496. case E_POST::C_GREEN:
  1497. {
  1498. strcpy(lpChat->chatid, lpObj->Name);
  1499. char pBuffer[MAX_CHAT_LEN];
  1500. sprintf(pBuffer, "@[POST] %s", &lpChat->chatmsg[strlen("#")]);
  1501. memcpy(&lpChat->chatmsg, &pBuffer, strlen(pBuffer) + 1);
  1502. PHeadSetB((LPBYTE)lpChat, 0x00, sizeof(pBuffer) + 13);
  1503.  
  1504. for (int i = OBJ_STARTUSERINDEX; i < OBJMAX; i++)
  1505. {
  1506. if (gObj[i].Connected >= 3)
  1507. {
  1508. DataSend(i, (LPBYTE)lpChat, lpChat->h.size);
  1509. }
  1510. }
  1511. char pBufferLog[90];
  1512. sprintf(pBufferLog, "[%s][%s]Use Post [Text]: %s",lpObj->AccountID,lpObj->Name, &lpChat->chatmsg[strlen("#")]);
  1513. Log.SaveLogInFile(Log.t_CHAT_POST,pBufferLog);
  1514. return;
  1515. }
  1516. break;
  1517. }
  1518.  
  1519.  
  1520.  
  1521. }
  1522. break;
  1523.  
  1524. case '/': // Command
  1525. if (slen > 2)
  1526. {
  1527. for (int i = 5; i < slen; i++)
  1528. {
  1529. if ((lpChat->chatmsg[i] == '%') && (lpChat->chatmsg[i + 2] == '%') && (lpChat->chatmsg[i + 4] == '%') && (lpChat->chatmsg[i + 6] == '%'))
  1530. {
  1531. LogAddC(5, "[AntiHack][%s][%s]Attept to Crush Server[%s]", lpObj->AccountID, lpObj->Name, lpChat->chatmsg);
  1532. return;
  1533. }
  1534. }
  1535.  
  1536. ////////////////////////////////////////////////////////////////////////////////////////////////
  1537. ////////////////////////////////////////////////////////////////////////////////////////////////
  1538. ////////////////////////////////////////////////////////////////////////////////////////////////
  1539.  
  1540.  
  1541. ////////////////////////////////////////////////////////////////////////////////////////////////
  1542. ////////////////////////////////////////////////////////////////////////////////////////////////
  1543. ////////////////////////////////////////////////////////////////////////////////////////////////
  1544. if (!memcmp(lpChat->chatmsg, "/post", strlen("/post"))) //Work
  1545. CCommandSystem::IsPost(lpObj, lpChat);
  1546.  
  1547. ////////////////////////////////////////////////////////////////////////////////////////////////
  1548. if (!memcmp(lpChat->chatmsg, "/addstr", strlen("/addstr"))) // Work
  1549. CCommandSystem::IsAdd(lpObj, lpChat, "/addstr", E_STAT::STRENGHT);
  1550. ////////////////////////////////////////////////////////////////////////////////////////////////
  1551. if (!memcmp(lpChat->chatmsg, "/addagi", strlen("/addagi"))) // Work
  1552. CCommandSystem::IsAdd(lpObj, lpChat, "/addagi", E_STAT::AGILITY);
  1553. ////////////////////////////////////////////////////////////////////////////////////////////////
  1554. if (!memcmp(lpChat->chatmsg, "/addvit", strlen("/addvit"))) // Work
  1555. CCommandSystem::IsAdd(lpObj, lpChat, "/addvit", E_STAT::VITALITY);
  1556. ////////////////////////////////////////////////////////////////////////////////////////////////
  1557. if (!memcmp(lpChat->chatmsg, "/addene", strlen("/addene"))) // Work
  1558. CCommandSystem::IsAdd(lpObj, lpChat, "/addene", E_STAT::ENERGY);
  1559. ////////////////////////////////////////////////////////////////////////////////////////////////
  1560. if (!memcmp(lpChat->chatmsg, "/addcmd", strlen("/addcmd")))
  1561. CCommandSystem::IsAdd(lpObj, lpChat, "/addcmd", E_STAT::DLCOMMAND);
  1562. //////////////////////////////////////////////////////////////////////////////////////////////// -- Work
  1563.  
  1564. if (!memcmp(lpChat->chatmsg, "/fireworks", strlen("/fireworks"))) // Work
  1565. CCommandSystem::IsFireworksCommand(lpObj, lpChat);
  1566. ////////////////////////////////////////////////////////////////////////////////////////////////
  1567. if (!memcmp(lpChat->chatmsg, "/setzen", strlen("/setzen"))) // Work
  1568. CCommandSystem::IsSetZen(lpObj, lpChat);
  1569. ////////////////////////////////////////////////////////////////////////////////////////////////
  1570. if (!memcmp(lpChat->chatmsg, "/zen", strlen("/zen"))) // Work
  1571. CCommandSystem::IsZenCommand(lpObj);
  1572. ////////////////////////////////////////////////////////////////////////////////////////////////
  1573. if (!memcmp(lpChat->chatmsg, "/clear", strlen("/clear"))) // Work
  1574. CCommandSystem::IsClearCommand(lpObj);
  1575. ////////////////////////////////////////////////////////////////////////////////////////////////
  1576. if (!memcmp(lpChat->chatmsg, "/disconnect", strlen("/disconnect")))
  1577. CCommandSystem::IsDisconnectCommand(lpObj, lpChat);
  1578. ////////////////////////////////////////////////////////////////////////////////////////////////
  1579. if (!memcmp(lpChat->chatmsg, "/disconnectguild", strlen("/disconnectguild")))
  1580. CCommandSystem::IsGuildDisconnectCommand(lpObj, lpChat);
  1581. ////////////////////////////////////////////////////////////////////////////////////////////////
  1582. #ifdef MOR
  1583. if (!memcmp(lpChat->chatmsg, "/trace", strlen("/trace"))) // Work
  1584. CCommandSystem::IsTraceCommand(lpObj, lpChat);
  1585. ////////////////////////////////////////////////////////////////////////////////////////////////
  1586. if (!memcmp(lpChat->chatmsg, "/track", strlen("/track"))) // Work
  1587. CCommandSystem::IsTransCommand(lpObj, lpChat);
  1588. #else
  1589.  
  1590. if (!memcmp(lpChat->chatmsg, "/trace", strlen("/trace"))) // Work
  1591. CCommandSystem::IsTraceCommand(lpObj, lpChat);
  1592. ////////////////////////////////////////////////////////////////////////////////////////////////
  1593. if (!memcmp(lpChat->chatmsg, "/track", strlen("/track"))) // Work
  1594. CCommandSystem::IsTransCommand(lpObj, lpChat);
  1595. #endif
  1596.  
  1597. if (!memcmp(lpChat->chatmsg, "/tmarry", strlen("/tmarry"))) // Work
  1598. CCommandSystem::IsTMarry(lpObj);
  1599. ////////////////////////////////////////////////////////////////////////////////////////////////
  1600. if (!memcmp(lpChat->chatmsg, "/drop", strlen("/drop"))) // Work
  1601. CCommandSystem::IsDropCommand(lpObj, lpChat);
  1602. ////////////////////////////////////////////////////////////////////////////////////////////////
  1603. #ifdef PICKUP_SYSTEM
  1604. if (!memcmp(lpChat->chatmsg, "/pickup", strlen("/pickup")))
  1605. s_PickUp.IsPickAddCommand(lpObj, lpChat);
  1606.  
  1607. if (!memcmp(lpChat->chatmsg, "/pickoff", strlen("/pickoff")))
  1608. s_PickUp.IsPickOffCommand(lpObj);
  1609.  
  1610. if (!memcmp(lpChat->chatmsg, "/picklist", strlen("/picklist")))
  1611. s_PickUp.IsPickList(lpObj);
  1612. #endif
  1613. #ifdef VIP_SYSTEM
  1614. if (!memcmp(lpChat->chatmsg, "/setvip", strlen("/setvip"))) // Work
  1615. s_Vip.IsAddVipCommand(lpObj, lpChat);
  1616.  
  1617. if (!memcmp(lpChat->chatmsg, "/deletevip", strlen("/deletevip"))) // Work
  1618. s_Vip.IsDeleteVipCommand(lpObj, lpChat);
  1619.  
  1620. if (!memcmp(lpChat->chatmsg, "/vip", strlen("/vip"))) // Work
  1621. s_Vip.IsShowVipCommand(lpObj, lpChat);
  1622. #endif
  1623. if (!memcmp(lpChat->chatmsg, "/sendresets", strlen("/sendresets"))) //
  1624. CCommandSystem::IsSendResets(lpObj, lpChat);
  1625. if (!memcmp(lpChat->chatmsg, "/setcredits", strlen("/setcredits"))) //
  1626. CCommandSystem::IsSetCredits(lpObj, lpChat);
  1627. // if (!memcmp(lpChat->chatmsg, "/sendcredits", strlen("/sendcredits"))) //
  1628. // CCommandSystem::IsSendCredits(lpObj, lpChat);
  1629. ////////////////////////////////////////////////////////////////////////////////////////////////
  1630. if (!memcmp(lpChat->chatmsg, "/skin", strlen("/skin")))
  1631. CCommandSystem::IsSkin(lpObj, lpChat);
  1632.  
  1633. /* if (!memcmp(lpChat->chatmsg, "/kick", strlen("/kick")))
  1634. CCommandSystem::IsCrash(lpObj, lpChat);
  1635.  
  1636. if (!memcmp(lpChat->chatmsg, "/close", strlen("/close")))
  1637. CCommandSystem::IsCrash(lpObj, lpChat);
  1638.  
  1639. if (!memcmp(lpChat->chatmsg, "/crush", strlen("/crush")))
  1640. CCommandSystem::IsCrash(lpObj, lpChat); */
  1641. ////////////////////////////////////////////////////////////////////////////////////////////////
  1642. if (!memcmp(lpChat->chatmsg, "/math", strlen("/math")))
  1643. CCommandSystem::IsStartMatch(lpObj);
  1644. ////////////////////////////////////////////////////////////////////////////////////////////////
  1645. if (!memcmp(lpChat->chatmsg, "/guess", strlen("/guess")))
  1646. CCommandSystem::IsStartGuess(lpObj);
  1647.  
  1648. if (!memcmp(lpChat->chatmsg, "/run", strlen("/run")))
  1649. CCommandSystem::IsStartReaches(lpObj);
  1650.  
  1651. ////////////////////////////////////////////////////////////////////////////////////////////////
  1652. if (!memcmp(lpChat->chatmsg, "/fake", strlen("/fake")))
  1653. CCommandSystem::IsFakeOnline(lpObj, lpChat);
  1654. ////////////////////////////////////////////////////////////////////////////////////////////////
  1655. if (!memcmp(lpChat->chatmsg, "/gg", strlen("/gg")))
  1656. CCommandSystem::IsGg(lpObj, lpChat);
  1657. if (!memcmp(lpChat->chatmsg, "/msg", strlen("/msg")))
  1658. CCommandSystem::IsMSG(lpObj, lpChat);
  1659. ////////////////////////////////////////////////////////////////////////////////////////////////
  1660. if (!memcmp(lpChat->chatmsg, "/info", strlen("/info")))
  1661. CCommandSystem::IsInfo(lpObj, lpChat);
  1662. ////////////////////////////////////////////////////////////////////////////////////////////////
  1663. if (!memcmp(lpChat->chatmsg, "/banpost", strlen("/banpost")))
  1664. CCommandSystem::IsBanPost(lpObj, lpChat);
  1665.  
  1666. ////////////////////////////////////////////////////////////////////////////////////////////////
  1667. if (!memcmp(lpChat->chatmsg, "/marry", strlen("/marry")))
  1668. CCommandSystem::IsMarryChar(lpObj, lpChat);
  1669. if (!memcmp(lpChat->chatmsg, "/yes", strlen("/yes")))
  1670. CCommandSystem::IsYesCommand(lpObj);
  1671. if (!memcmp(lpChat->chatmsg, "/no", strlen("/no")))
  1672. CCommandSystem::IsNoCommand(lpObj);
  1673. if (!memcmp(lpChat->chatmsg, "/divorce", strlen("/divorce")))
  1674. CCommandSystem::IsDivorceCommand(lpObj);
  1675. ////////////////////////////////////////////////////////////////////////////////////////////////
  1676. if (!memcmp(lpChat->chatmsg, "/unbanpost", strlen("/unbanpost")))
  1677. CCommandSystem::IsUnBanPost(lpObj, lpChat);
  1678.  
  1679. ////////////////////////////////////////////////////////////////////////////////////////////////
  1680. if (!memcmp(lpChat->chatmsg, "/ban", strlen("/ban")))
  1681. CCommandSystem::IsBanPlayer(lpObj, lpChat);
  1682.  
  1683. ////////////////////////////////////////////////////////////////////////////////////////////////
  1684. if (!memcmp(lpChat->chatmsg, "/unban", strlen("/unban")))
  1685. CCommandSystem::IsUnBanPlayer(lpObj, lpChat);
  1686.  
  1687.  
  1688. ////////////////////////////////////////////////////////////////////////////////////////////////
  1689. if (!memcmp(lpChat->chatmsg, "/online", strlen("/online")))
  1690. CCommandSystem::IsOnline(lpObj);
  1691.  
  1692. ////////////////////////////////////////////////////////////////////////////////////////////////
  1693. if (!memcmp(lpChat->chatmsg, "/crew", strlen("/crew")))
  1694. CCommandSystem::IsCrew(lpObj);
  1695.  
  1696. ////////////////////////////////////////////////////////////////////////////////////////////////
  1697. if (!memcmp(lpChat->chatmsg, "/setfull", strlen("/setfull")))
  1698. CCommandSystem::IsSetFull(lpObj ,lpChat);
  1699. ////////////////////////////////////////////////////////////////////////////////////////////////
  1700. if (!memcmp(lpChat->chatmsg, "/evo", strlen("/evo")))
  1701. CCommandSystem::IsEvo(lpObj);
  1702. ////////////////////////////////////////////////////////////////////////////////////////////////
  1703. //#ifdef MuContinent
  1704. if (!memcmp(lpChat->chatmsg, "/pkclear", strlen("/pkclear"))) //PKClear handly
  1705. CCommandSystem::IsPkClearAny(lpObj);
  1706. //#endif
  1707. ////////////////////////////////////////////////////////////////////////////////////////////////
  1708. if (!memcmp(lpChat->chatmsg, "/pkset", strlen("/pkset")))
  1709. CCommandSystem::IsPkSet(lpObj, lpChat);
  1710. ////////////////////////////////////////////////////////////////////////////////////////////////
  1711. if (!memcmp(lpChat->chatmsg, "/call", strlen("/call")))
  1712. CCommandSystem::IsCallPet(lpObj, lpChat);
  1713. ////////////////////////////////////////////////////////////////////////////////////////////////
  1714. #ifdef OFFLINE_ATTACK
  1715. if (!memcmp(lpChat->chatmsg, "/afk", strlen("/afk")))
  1716. OfflineAttackSystem.OffExpStart(aIndex);
  1717. #endif
  1718.  
  1719. #ifdef CUSTOM_OFFTRADEJEWEL
  1720. ////////////////////////////////////////////////////////////////////////////////////////////////
  1721. if (!memcmp(lpChat->chatmsg, "/soul", strlen("/soul")))
  1722. CCommandSystem::IsSoul(lpObj, lpChat);
  1723. ////////////////////////////////////////////////////////////////////////////////////////////////
  1724. if (!memcmp(lpChat->chatmsg, "/getsoul", strlen("/getsoul")))
  1725. CCommandSystem::IsSoulGet(lpObj, lpChat);
  1726. ////////////////////////////////////////////////////////////////////////////////////////////////
  1727. if (!memcmp(lpChat->chatmsg, "/bless", strlen("/bless")))
  1728. CCommandSystem::IsBless(lpObj, lpChat);
  1729. ////////////////////////////////////////////////////////////////////////////////////////////////
  1730. if (!memcmp(lpChat->chatmsg, "/getbless", strlen("/getbless")))
  1731. CCommandSystem::IsBlessGet(lpObj, lpChat);
  1732. #endif
  1733. #ifdef OFFLINE_TRADE
  1734. ////////////////////////////////////////////////////////////////////////////////////////////////
  1735. if (!memcmp(lpChat->chatmsg, "/offsoul", strlen("/offsoul")))
  1736. CCommandSystem::IsOffTradeSoul(lpObj, lpChat);
  1737. ////////////////////////////////////////////////////////////////////////////////////////////////
  1738. if (!memcmp(lpChat->chatmsg, "/offbless", strlen("/offbless")))
  1739. CCommandSystem::IsOffTradeBless(lpObj, lpChat);
  1740.  
  1741. ////////////////////////////////////////////////////////////////////////////////////////////////
  1742. if (!memcmp(lpChat->chatmsg, CommandOffTrZen, strlen(CommandOffTrZen)))
  1743. CCommandSystem::IsOffTradeZen(lpObj, lpChat);
  1744. ////////////////////////////////////////////////////////////////////////////////////////////////
  1745. if (!memcmp(lpChat->chatmsg, CommandOffTrCoins, strlen(CommandOffTrCoins)))
  1746. CCommandSystem::IsOffTradeCoin(lpObj, lpChat);
  1747. ////////////////////////////////////////////////////////////////////////////////////////////////
  1748. if (!memcmp(lpChat->chatmsg, CommandOffTrCredits, strlen(CommandOffTrCredits)))
  1749. CCommandSystem::IsOffTradeCredits(lpObj, lpChat);
  1750. #endif
  1751. ////////////////////////////////////////////////////////////////////////////////////////////////
  1752. /* if (!memcmp(lpChat->chatmsg, "/packlife", strlen("/packlife")))
  1753. PackLife(aIndex);
  1754. ////////////////////////////////////////////////////////////////////////////////////////////////
  1755. if (!memcmp(lpChat->chatmsg, "/unpacklife", strlen("/unpacklife")))
  1756. UnPackLife(aIndex);
  1757. ////////////////////////////////////////////////////////////////////////////////////////////////
  1758. if (!memcmp(lpChat->chatmsg, "/packchaos", strlen("/packchaos")))
  1759. PackChaos(aIndex);
  1760. ////////////////////////////////////////////////////////////////////////////////////////////////
  1761. if (!memcmp(lpChat->chatmsg, "/unpackchaos", strlen("/unpackchaos")))
  1762. UnPackChaos(aIndex);
  1763. ////////////////////////////////////////////////////////////////////////////////////////////////
  1764. if (!memcmp(lpChat->chatmsg, "/packcreation", strlen("/packcreation")))
  1765. PackCreation(aIndex);
  1766. ////////////////////////////////////////////////////////////////////////////////////////////////
  1767. if (!memcmp(lpChat->chatmsg, "/unpackcreation", strlen("/unpackcreation")))
  1768. UnPackCreation(aIndex);/
  1769. ////////////////////////////////////////////////////////////////////////////////////////////////
  1770. if (!memcmp(lpChat->chatmsg, "/packharmony", strlen("/packharmony")))
  1771. PackHarmony(aIndex);
  1772. ////////////////////////////////////////////////////////////////////////////////////////////////
  1773. if (!memcmp(lpChat->chatmsg, "/unpackharmony", strlen("/unpackharmony")))
  1774. UnPackHarmony(aIndex);
  1775. ////////////////////////////////////////////////////////////////////////////////////////////////
  1776. if (!memcmp(lpChat->chatmsg, "/packguardian", strlen("/packguardian")))
  1777. PackGuardian(aIndex);
  1778. ////////////////////////////////////////////////////////////////////////////////////////////////
  1779. if (!memcmp(lpChat->chatmsg, "/unpackguardian", strlen("/unpackguardian")))
  1780. UnPackGuardian(aIndex); */
  1781. ////////////////////////////////////////////////////////////////////////////////////////////////
  1782. if (!memcmp(lpChat->chatmsg, "/test", strlen("/test")))
  1783. CCommandSystem::IsTestCommand(lpObj, lpChat);
  1784. #ifdef QUEST_SYSTEM
  1785. if (!memcmp(lpChat->chatmsg, "/kill", strlen("/kill")))
  1786. CCommandSystem::IsQuesKillInfo(lpObj, lpChat);
  1787. #endif
  1788. ////////////////////////////////////////////////////////////////////////////////////////////////
  1789. if (!memcmp(lpChat->chatmsg, "/reset", strlen("/reset")))
  1790. CCommandSystem::IsResetCommand(lpObj, lpChat);
  1791. ////////////////////////////////////////////////////////////////////////////////////////////////
  1792. #ifdef CUSTOM_PROPENSITY_SYSTEM
  1793. if (!memcmp(lpChat->chatmsg, "/go", strlen("/go")))
  1794. CPropensity::PropensityLightSkill(lpObj, lpChat);
  1795.  
  1796. if (!memcmp(lpChat->chatmsg, "/get", strlen("/get")))
  1797. CPropensity::PropensityLightHarmony(lpObj, lpChat);
  1798. #endif
  1799.  
  1800. ////////////////////////////////////////////////////////////////////////////////////////////////
  1801. if ((GetTickCount() - lpObj->MySelfDefenseTime) < 60000)
  1802. {
  1803. GCServerMsgStringSend(lMsg.Get(1133),lpObj->m_Index,1);
  1804. return;
  1805. }
  1806.  
  1807. cManager.ManagementProc(lpObj, lpChat->chatmsg, aIndex);
  1808. LogAddTD("[%s][%s] Use Text - %s ", lpObj->AccountID, lpObj->Name,lpChat->chatmsg);
  1809. return;
  1810. }
  1811. break;
  1812. }
  1813.  
  1814. // Other Commands
  1815. if ( lpObj->ChatLimitTime > 0 )
  1816. {
  1817. MsgOutput(lpObj->m_Index, lMsg.Get(MSGGET(4, 223)), lpObj->ChatLimitTime);
  1818. return;
  1819. }
  1820.  
  1821. if ( (lpObj->Penalty&2)==2)
  1822. return;
  1823.  
  1824. // Party Message
  1825. if ( lpChat->chatmsg[0] == '~' || lpChat->chatmsg[0] == ']' )
  1826. {
  1827. for (int i = 5; i < slen; i++)
  1828. {
  1829. if ((lpChat->chatmsg[i] == '%') && (lpChat->chatmsg[i + 2] == '%') && (lpChat->chatmsg[i + 4] == '%') && (lpChat->chatmsg[i + 6] == '%'))
  1830. {
  1831. LogAddC(5, "[AntiHack][%s][%s]Attept to Crush Server[%s]", lpObj->AccountID, lpObj->Name, lpChat->chatmsg);
  1832. return;
  1833. }
  1834. }
  1835.  
  1836. if ( lpObj->PartyNumber >= 0 )
  1837. {
  1838. int partycount = gParty.GetPartyCount(lpObj->PartyNumber);
  1839.  
  1840. if ( partycount >= 0 )
  1841. {
  1842. if ( gWriteChatLog )
  1843. {
  1844. memcpy(pChatMsg.szChatMsg, &lpChat->chatmsg[1], MAX_CHAT_LEN-1);
  1845. pChatMsg.szChatMsg[MAX_CHAT_LEN] = 0;
  1846. pChatMsg.btType = 0x01;
  1847. }
  1848. char pBufferLog[90];
  1849. sprintf(pBufferLog, "[%s][%s] %s",lpObj->AccountID,lpObj->Name, &lpChat->chatmsg[1]);
  1850. Log.SaveLogInFile(Log.t_CHAT_PARTY,pBufferLog);
  1851.  
  1852. for (n=0;n<MAX_USER_IN_PARTY;n++ )
  1853. {
  1854. number = gParty.m_PartyS[lpObj->PartyNumber].Number[n];
  1855.  
  1856. if ( number >= 0 )
  1857. {
  1858. DataSend(number, (LPBYTE)lpChat, lpChat->h.size);
  1859.  
  1860. if ( gWriteChatLog )
  1861. {
  1862. strcpy(pChatMsg.szTargetName[szTargetNameCount], gObj[number].Name);
  1863. szTargetNameCount++;
  1864. }
  1865. }
  1866. }
  1867. }
  1868. }
  1869. }
  1870. // Guild
  1871. else if ( lpChat->chatmsg[0] == '@' )
  1872. {
  1873. for (int i = 5; i < slen; i++)
  1874. {
  1875. if ((lpChat->chatmsg[i] == '%') && (lpChat->chatmsg[i + 2] == '%') && (lpChat->chatmsg[i + 4] == '%') && (lpChat->chatmsg[i + 6] == '%'))
  1876. {
  1877. LogAddC(5, "[AntiHack][%s][%s]Attept to Crush Server[%s]", lpObj->AccountID, lpObj->Name, lpChat->chatmsg);
  1878. return;
  1879. }
  1880. }
  1881.  
  1882. if ( lpObj->GuildNumber > 0 )
  1883. {
  1884. // Notice
  1885. if ( lpChat->chatmsg[1] == '>' )
  1886. {
  1887.  
  1888. CheckProcent(lpChat->chatmsg);
  1889. /*
  1890. if (lpChat->chatmsg[3] == '%')
  1891. {
  1892. if (lpChat->chatmsg[4] == 'd')
  1893. {
  1894. LogAddC(5,"[AntiHack][%s][%s]Attept to Crush Server ", lpObj->AccountID, lpObj->Name);
  1895. return;
  1896.  
  1897. }
  1898. if (lpChat->chatmsg[4] == 's')
  1899. {
  1900. LogAddC(5,"[AntiHack][%s][%s]Attept to Crush Server ", lpObj->AccountID, lpObj->Name);
  1901. return;
  1902.  
  1903. }
  1904. }
  1905. */
  1906. if ( lpObj->Name[0] == lpObj->lpGuild->Names[0][0] )
  1907. {
  1908. if ( !strcmp(lpObj->Name, lpObj->lpGuild->Names[0] ) )
  1909. {
  1910. GDGuildNoticeSave(lpObj->lpGuild->Name, &lpChat->chatmsg[2]);
  1911. LogAdd(lMsg.Get(MSGGET(1, 216)), lpObj->lpGuild->Name, lpChat->chatmsg);
  1912.  
  1913. if ( gWriteChatLog )
  1914. {
  1915. memcpy(pChatMsg.szChatMsg, &lpChat->chatmsg[2], MAX_CHAT_LEN-2);
  1916. pChatMsg.szChatMsg[MAX_CHAT_LEN] = 0;
  1917. pChatMsg.btType = 0x04;
  1918. }
  1919. }
  1920. }
  1921. }
  1922. // Aliances
  1923. else if ( lpChat->chatmsg[1] == '@' && lpObj->lpGuild->iGuildUnion )
  1924. {
  1925.  
  1926. //strcpy(lpChat->chatid, lpObj->Name);
  1927. //char pBuffer[MAX_CHAT_LEN];
  1928. //sprintf(pBuffer, "[POST] %s", &lpChat->chatmsg[strlen("/post")]);
  1929.  
  1930.  
  1931.  
  1932.  
  1933. int iGuildCount = 0;
  1934. int iGuildList[MAX_UNION_GUILD] ={0};
  1935.  
  1936. if ( UnionManager.GetGuildUnionMemberList(lpObj->lpGuild->iGuildUnion, iGuildCount, iGuildList) == TRUE )
  1937. {
  1938.  
  1939. char pBufferLog[90];
  1940. sprintf(pBufferLog, "[%s][%s][%s] %s",lpObj->AccountID,lpObj->Name,lpObj->GuildName, &lpChat->chatmsg[1]);
  1941. Log.SaveLogInFile(Log.t_CHAT_GUILD,pBufferLog);
  1942.  
  1943. for ( int i=0;i<iGuildCount;i++)
  1944. {
  1945. _GUILD_INFO_STRUCT *lpGuildInfo = Guild.SearchGuild_Number(iGuildList[i]);
  1946.  
  1947. if ( !lpGuildInfo )
  1948. continue;
  1949.  
  1950. for (n=0;n<MAX_USER_GUILD;n++)
  1951. {
  1952. if ( lpGuildInfo->Use[n] )
  1953. {
  1954. number = lpGuildInfo->Index[n];
  1955.  
  1956. if ( number >= 0 )
  1957. {
  1958. if ( lpGuildInfo->Names[n][0] == gObj[number].Name[0] )
  1959. {
  1960. if ( !strcmp(lpGuildInfo->Names[n], gObj[number].Name ))
  1961. {
  1962. DataSend(number, (LPBYTE)lpChat, lpChat->h.size);
  1963. }
  1964. }
  1965. }
  1966. }
  1967. }
  1968. }
  1969. }
  1970.  
  1971.  
  1972. if ( g_iServerGroupUnionChatting == TRUE )
  1973. GDUnionServerGroupChattingSend(lpObj->lpGuild->iGuildUnion, lpChat);
  1974. }
  1975. // Just Guild
  1976. else
  1977. {
  1978. int count = lpObj->lpGuild->Count;
  1979.  
  1980. if ( count >= 0 )
  1981. {
  1982. for ( int n=0;n<MAX_USER_GUILD;n++)
  1983. {
  1984. if ( lpObj->lpGuild->Use[n] )
  1985. {
  1986. number = lpObj->lpGuild->Index[n];
  1987.  
  1988. if ( number >= 0 )
  1989. {
  1990. if ( lpObj->lpGuild->Names[n][0] == gObj[number].Name[0] )
  1991. {
  1992. if ( !strcmp(lpObj->lpGuild->Names[n], gObj[number].Name ) )
  1993. {
  1994. DataSend(number, (LPBYTE)lpChat, lpChat->h.size);
  1995. }
  1996. }
  1997. }
  1998. }
  1999. }
  2000. }
  2001.  
  2002. if ( g_iServerGroupGuildChatting == TRUE )
  2003. {
  2004. if ( lpObj->lpGuild->Count > 1 )
  2005. {
  2006. GDGuildServerGroupChattingSend(lpObj->lpGuild->Number, lpChat);
  2007. }
  2008. }
  2009.  
  2010. if ( gWriteChatLog )
  2011. {
  2012. memcpy(pChatMsg.szChatMsg, &lpChat->chatmsg[1], MAX_CHAT_LEN-1);
  2013. pChatMsg.szChatMsg[MAX_CHAT_LEN] = 0;
  2014. pChatMsg.btType = 0x02;
  2015. }
  2016. char pBufferLog[90];
  2017. sprintf(pBufferLog, "[%s][%s][%s] %s",lpObj->AccountID,lpObj->Name,lpObj->GuildName, &lpChat->chatmsg[1]);
  2018. Log.SaveLogInFile(Log.t_CHAT_GUILD,pBufferLog);
  2019. }
  2020.  
  2021. if ( gWriteChatLog )
  2022. {
  2023. strcpy(pChatMsg.szTargetName[szTargetNameCount], lpObj->GuildName);
  2024. szTargetNameCount++;
  2025. }
  2026. }
  2027. }
  2028. else
  2029. {
  2030. if(((lpObj->Authority&32)==32) && gObjSearchActiveEffect(lpObj, AT_INVISIBILITY) != FALSE) //season 2.5 add-on
  2031. {
  2032. return;
  2033. }
  2034.  
  2035. DataSend(aIndex, (LPBYTE)lpChat, lpChat->h.size);
  2036. MsgSendV2(lpObj, (LPBYTE)lpChat, lpChat->h.size);
  2037.  
  2038. if ( gWriteChatLog )
  2039. {
  2040. memcpy(pChatMsg.szChatMsg, lpChat->chatmsg, MAX_CHAT_LEN);
  2041. pChatMsg.szChatMsg[MAX_CHAT_LEN] = 0;
  2042. pChatMsg.btType = 0x00;
  2043.  
  2044. }
  2045. }
  2046.  
  2047. if ( gWriteChatLog )
  2048. {
  2049. if ( pChatMsg.btType != 0xFF )
  2050. {
  2051. pChatMsg.btType |= szTargetNameCount<<4;
  2052. pChatMsg.h.size = sizeof(pChatMsg) - (5 - szTargetNameCount) - 1;
  2053.  
  2054. if ( gWriteChatLog )
  2055. {
  2056. gSendHackLog.SendData((LPBYTE)&pChatMsg, pChatMsg.h.size);
  2057. }
  2058. }
  2059. }
  2060. //}
  2061.  
  2062. }
  2063. void CGChatRecv(PMSG_CHATDATA_NUMBER * lpMsg, int aIndex)
  2064. {
  2065. LPOBJ lpObj = &gObj[aIndex];
  2066.  
  2067. if ( PacketCheckTime(lpObj) == FALSE )
  2068. {
  2069. return;
  2070. }
  2071.  
  2072. DataSend(aIndex, (LPBYTE)lpMsg, lpMsg->h.size);
  2073. MsgSendV2(lpObj, (LPBYTE)lpMsg, lpMsg->h.size);
  2074. }
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080. struct PMSG_SERVERMSG
  2081. {
  2082. PBMSG_HEAD h; // C1:0C
  2083. BYTE MsgNumber; // 3
  2084. };
  2085.  
  2086.  
  2087. void GCServerMsgSend(BYTE msg, int aIndex)
  2088. {
  2089. PMSG_SERVERMSG pMsg;
  2090.  
  2091. PHeadSetB((LPBYTE)&pMsg, 0x0C, sizeof(pMsg));
  2092. pMsg.MsgNumber = msg;
  2093. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  2094. }
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101. void GCServerMsgStringSend(LPSTR szMsg, int aIndex, BYTE type)
  2102. {
  2103. PMSG_NOTICE pNotice;
  2104.  
  2105. TNotice::MakeNoticeMsg((TNotice*)&pNotice, type, szMsg);
  2106. DataSend(aIndex, (UCHAR*)&pNotice, pNotice.h.size);
  2107. }
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113. void GCServerMsgStringSendGuild(_GUILD_INFO_STRUCT* lpNode, LPSTR szMsg, BYTE type)
  2114. {
  2115. if ( lpNode == NULL )
  2116. {
  2117. return;
  2118. }
  2119.  
  2120. for ( int n = 0; n<MAX_USER_GUILD ; n++)
  2121. {
  2122. if (lpNode->Use[n] > 0 && lpNode->Index[n] >= 0 )
  2123. {
  2124. GCServerMsgStringSend((char*)szMsg, lpNode->Index[n], type);
  2125. }
  2126. }
  2127. }
  2128.  
  2129. struct PMSG_EVENT
  2130. {
  2131. PBMSG_HEAD h; // C1:0B
  2132. BYTE State; // 3
  2133. BYTE Event; // 4
  2134. };
  2135.  
  2136. void GCEventStateSend(int aIndex, BYTE state, BYTE event)
  2137. {
  2138. PMSG_EVENT pMsg;
  2139.  
  2140. PHeadSetB((LPBYTE)&pMsg, 0x0B, sizeof(pMsg));
  2141. pMsg.Event = event;
  2142. pMsg.State = state;
  2143.  
  2144. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  2145. }
  2146.  
  2147. void GCMapEventStateSend(int map, BYTE state, BYTE event)
  2148. {
  2149. PMSG_EVENT pMsg;
  2150.  
  2151. PHeadSetB((LPBYTE)&pMsg, 0x0B, sizeof(pMsg));
  2152. pMsg.Event = event;
  2153. pMsg.State = state;
  2154.  
  2155. for ( int n=0; n<OBJMAX ; n++ )
  2156. {
  2157. if ( gObj[n].Connected == PLAYER_PLAYING && gObj[n].Type == OBJ_USER && map == gObj[n].MapNumber )
  2158. {
  2159. DataSend(n, (UCHAR*)&pMsg, pMsg.h.size);
  2160. }
  2161. }
  2162. }
  2163. void CGReqWerewolfMove(PMSG_REQ_WEREWOLF_MOVE* lpMsg, int iIndex)
  2164. {
  2165. if(lpMsg == NULL)
  2166. {
  2167. return;
  2168. }
  2169.  
  2170. if ( OBJMAX_RANGE(iIndex) == FALSE )
  2171. {
  2172. return;
  2173. }
  2174.  
  2175. //g_QuestInfo.GCReqWerewolfMove(iIndex);
  2176. g_QuestInfo.NotifyResultEnterBarracks(iIndex);
  2177. }
  2178.  
  2179. void CGReqGatekeeperMove(PMSG_REQ_GATEKEEPER_MOVE* lpMsg, int iIndex)
  2180. {
  2181. if(lpMsg == NULL)
  2182. {
  2183. return;
  2184. }
  2185.  
  2186. if ( OBJMAX_RANGE(iIndex) == FALSE )
  2187. {
  2188. return;
  2189. }
  2190.  
  2191. //g_QuestInfo.GCReqGateKeeperMove(iIndex);
  2192. g_QuestInfo.NotifyResultEnterRefuge(iIndex);
  2193.  
  2194. }
  2195. void CGChatWhisperRecv(PMSG_CHATDATA_WHISPER* lpMsg, int aIndex)
  2196. {
  2197. char tid[11];
  2198. PMSG_CHATDATA_WHISPER pWhisper;
  2199. int len;
  2200. LPOBJ lpObj = &gObj[aIndex];
  2201. int index;
  2202.  
  2203. if ( PacketCheckTime(lpObj) == FALSE )
  2204. {
  2205. return;
  2206. }
  2207.  
  2208. if ( lpObj->ChatLimitTime > 0 )
  2209. {
  2210. MsgOutput(lpObj->m_Index, lMsg.Get(MSGGET(4, 223)), lpObj->ChatLimitTime);
  2211. return;
  2212. }
  2213.  
  2214. if ( (lpObj->Penalty & 2) == 2 )
  2215. {
  2216. return;
  2217. }
  2218.  
  2219. tid[10]=0;
  2220. memcpy(tid, lpMsg->id, sizeof(lpMsg->id));
  2221. index = WhisperCash.AddCash(tid);
  2222.  
  2223. if ( index < 0 )
  2224. {
  2225. GCServerMsgSend(0, aIndex);
  2226. return;
  2227. }
  2228.  
  2229. PHeadSetB((LPBYTE)&pWhisper, 0x02, sizeof(pWhisper));
  2230. strcpy(pWhisper.id, gObj[aIndex].Name);
  2231. memcpy(pWhisper.chatmsg, lpMsg->chatmsg, sizeof(lpMsg->chatmsg));
  2232.  
  2233. len = strlen(pWhisper.chatmsg);
  2234.  
  2235. if ( len > 0 )
  2236. {
  2237. pWhisper.h.size -= sizeof(pWhisper.chatmsg);
  2238. pWhisper.h.size += len + 1;
  2239.  
  2240. DataSend(index, (UCHAR*)&pWhisper, pWhisper.h.size);
  2241.  
  2242. CHAT_LOG_DATA pChatMsg;
  2243. int szTargetNameCount = 0;
  2244.  
  2245. if ( gWriteChatLog != FALSE )
  2246. {
  2247.  
  2248.  
  2249. pChatMsg.h.c = 0xC1;
  2250. pChatMsg.h.headcode = 0x02;
  2251. memcpy(pChatMsg.AccountID, gObj[aIndex].AccountID, MAX_ACCOUNT_LEN);
  2252. memcpy(pChatMsg.Name, gObj[aIndex].Name, MAX_ACCOUNT_LEN);
  2253. pChatMsg.AccountID[MAX_ACCOUNT_LEN] = 0;
  2254. pChatMsg.Name[MAX_ACCOUNT_LEN] = 0;
  2255. pChatMsg.wServer = gGameServerCode;
  2256. memcpy(pChatMsg.szChatMsg, lpMsg->chatmsg, MAX_CHAT_LEN);
  2257. pChatMsg.szChatMsg[MAX_CHAT_LEN] = 0;
  2258. pChatMsg.btType = 5;
  2259. strcpy(pChatMsg.szTargetName[szTargetNameCount], gObj[index].Name);
  2260. szTargetNameCount++;
  2261.  
  2262. if ( szTargetNameCount != 0 )
  2263. {
  2264. pChatMsg.btType |= szTargetNameCount << 4;
  2265. }
  2266.  
  2267. pChatMsg.h.size = sizeof(pChatMsg);
  2268.  
  2269. gSendHackLog.SendData((LPBYTE)&pChatMsg, pChatMsg.h.size);
  2270. }
  2271.  
  2272. char pBufferLog[90];
  2273. sprintf(pBufferLog, "[%s] [%s] -> [%s] [%s]: %s",lpObj->AccountID,lpObj->Name,gObj[index].AccountID, gObj[index].Name, lpMsg->chatmsg);
  2274. Log.SaveLogInFile(Log.t_CHAT_PRIVATE,pBufferLog);
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280. }
  2281. }
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287. struct PMSG_JOINRESULT
  2288. {
  2289. PBMSG_HEAD h; // C1:F1
  2290. BYTE scode; // 3
  2291. BYTE result; // 4
  2292. BYTE NumberH; // 5
  2293. BYTE NumberL; // 6
  2294. BYTE CliVersion[5]; // 7
  2295. };
  2296.  
  2297.  
  2298.  
  2299. void SCPJoinResultSend(int aIndex, BYTE result)
  2300. {
  2301. PMSG_JOINRESULT pResult;
  2302.  
  2303. memset(&pResult, 0, sizeof(pResult));
  2304.  
  2305. pResult.h.size = sizeof(pResult);
  2306. pResult.h.c = 0xC1;
  2307. pResult.h.headcode = 0xF1;
  2308. pResult.scode = 0x00;
  2309. pResult.result = result;
  2310. pResult.NumberH = SET_NUMBERH(aIndex);
  2311. pResult.NumberL = SET_NUMBERL(aIndex);
  2312. pResult.CliVersion[0] = szClientVersion[0];
  2313. pResult.CliVersion[1] = szClientVersion[1];
  2314. pResult.CliVersion[2] = szClientVersion[2];
  2315. pResult.CliVersion[3] = szClientVersion[3];
  2316. pResult.CliVersion[4] = szClientVersion[4];
  2317.  
  2318. //DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
  2319. //טחלוםום
  2320. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  2321. gObj[aIndex].ConnectCheckTime = GetTickCount();
  2322. }
  2323.  
  2324.  
  2325.  
  2326.  
  2327. void CSPJoinIdPassRequest(PMSG_IDPASS* lpMsg, int aIndex)
  2328. {
  2329. char serial[17];
  2330. char id[11];
  2331. char pass[11];
  2332.  
  2333. int isOff = 0;
  2334.  
  2335. if ( lpMsg->CliVersion[0] != szClientVersion[0] ||
  2336. lpMsg->CliVersion[1] != szClientVersion[1] ||
  2337. lpMsg->CliVersion[2] != szClientVersion[2] ||
  2338. lpMsg->CliVersion[3] != szClientVersion[3] ||
  2339. lpMsg->CliVersion[4] != szClientVersion[4] )
  2340. {
  2341. GCJoinResult(JS_BAD_CLIENT_VERSION, aIndex);
  2342. CloseClient(aIndex);
  2343. return;
  2344. }
  2345.  
  2346. serial[16] = 0;
  2347. memcpy(serial, lpMsg->CliSerial, sizeof(lpMsg->CliSerial));
  2348. id[10]=0;
  2349. pass[10] = 0;
  2350.  
  2351. memcpy(id, lpMsg->Id, sizeof(lpMsg->Id));
  2352. memcpy(pass, lpMsg->Pass, sizeof(lpMsg->Pass));
  2353.  
  2354. BuxConvert(id, MAX_ACCOUNT_LEN);
  2355. BuxConvert(pass, MAX_ACCOUNT_LEN);
  2356. if ( strcmp(serial, szGameServerExeSerial) != 0 )
  2357. {
  2358. LogAddC(2, "error-L1: Serial error [%s] [%s]", id, serial);
  2359. GCJoinResult(JS_BAD_CLIENT_VERSION, aIndex);
  2360. CloseClient(aIndex);
  2361. return;
  2362. }
  2363.  
  2364. if ( bCanConnectMember == TRUE )
  2365. {
  2366. if ( ConMember.IsMember(id) == FALSE )
  2367. {
  2368. GCJoinResult(JS_ONLY_VIP_MEMBERS, aIndex);
  2369. return;
  2370. }
  2371. }
  2372.  
  2373. LPOBJ lpObj = &gObj[aIndex];
  2374.  
  2375. if (PacketCheckTime(lpObj) == FALSE )
  2376. {
  2377. LogAdd(lMsg.Get(MSGGET(1, 217)), aIndex, id);
  2378. CloseClient(aIndex);
  2379. return;
  2380. }
  2381. #ifdef OFFLINE_ATTACK
  2382. OfflineAttackSystem.Close(id);
  2383. #endif
  2384. //========================================================================================================================
  2385. #ifdef IP_AUTHORIZATION
  2386. for(int i=0;i<g_IPAUTConfig.iCount;i++)
  2387. {
  2388. if(!strcmp(id,g_IPAUTConfig.m_Data[i].szName))
  2389. {
  2390. if(!g_IPAUTConfig.CheckIsIP(id,gObj[aIndex].Ip_addr))
  2391. {
  2392. LogAddC(2, "Wrong Ip Adress [%s] [%s]/[%s] " ,id,g_IPAUTConfig.m_Data[i].szIp,gObj[aIndex].Ip_addr );
  2393. GCJoinResult(JS_ONLY_VIP_MEMBERS, aIndex);
  2394. return;
  2395. }
  2396. }
  2397. }
  2398. #endif
  2399. //========================================================================================================================
  2400. for(int i=OBJ_STARTUSERINDEX;i<OBJMAX;i++)
  2401. {
  2402. if(gObj[i].Connected == 3)
  2403. {
  2404. if(!strcmp(id,gObj[i].AccountID))
  2405. {
  2406.  
  2407. //pass
  2408. //if(g_OfflineState[i].IsOffState != 0)
  2409. if ((gObj[i].OffAttack != 0 ) && ( gObj[i].OffTrade != 0))
  2410. {
  2411. gObj[i].OffAttack = 0;
  2412. gObj[i].OffTrade = 0;
  2413. //g_OfflineState[i].IsOffState = 0;
  2414. GJPUserClose(gObj[i].AccountID);
  2415. gObjDel(i);
  2416. CloseClient(i);
  2417. }
  2418.  
  2419. }
  2420. }
  2421. }
  2422. if ( gObj[aIndex].Connected != PLAYER_CONNECTED )
  2423. {
  2424. LogAdd(lMsg.Get(MSGGET(1, 218)), aIndex, id);
  2425. CloseClient(aIndex);
  2426. return;
  2427. }
  2428.  
  2429. if ( gObj[aIndex].LoginMsgSnd != FALSE )
  2430. {
  2431. if ( gObj[aIndex].LoginMsgSnd == TRUE )
  2432. {
  2433. LogAdd(lMsg.Get(MSGGET(1, 219)), aIndex, id, gObj[aIndex].Ip_addr );
  2434. }
  2435. else
  2436. {
  2437. LogAdd("error : %d %s %d", gObj[aIndex].LoginMsgSnd, __FILE__, __LINE__);
  2438. }
  2439.  
  2440. return;
  2441. }
  2442.  
  2443.  
  2444. SDHP_IDPASS spMsg;
  2445.  
  2446. PHeadSetB((LPBYTE)&spMsg, 0x01, sizeof(spMsg));
  2447. spMsg.Number = aIndex;
  2448. memcpy(spMsg.Id, lpMsg->Id, sizeof(spMsg.Id));
  2449. memcpy(spMsg.Pass, lpMsg->Pass, sizeof(spMsg.Pass));
  2450. strcpy(spMsg.IpAddress, gObj[aIndex].Ip_addr);
  2451. gObj[aIndex].CheckTick = lpMsg->TickCount;
  2452. gObj[aIndex].CheckTick2 = GetTickCount();
  2453. gObj[aIndex].ConnectCheckTime = GetTickCount();
  2454. gObj[aIndex].CheckSpeedHack = true;
  2455. gObj[aIndex].ConnectCheckTime = GetTickCount();
  2456. gObj[aIndex].LoginMsgSnd = 1;
  2457. gObj[aIndex].LoginMsgCount++;
  2458. gObj[aIndex].AccountID[MAX_ACCOUNT_LEN] = 0;
  2459. memcpy(gObj[aIndex].AccountID, id, MAX_ACCOUNT_LEN);
  2460. //LogAddC(2, "PASSWORD %s", pass);
  2461. memcpy(gObj[aIndex].Password, pass, MAX_ACCOUNT_LEN);
  2462. //LogAddC(2, "PASSWORD %s", gObj[aIndex].Password);
  2463. gObj[aIndex].m_cAccountItemBlock = 0;
  2464.  
  2465. wsJServerCli.DataSend((char*)&spMsg, spMsg.h.size);
  2466. LogAddTD("join send : (%d)%s", aIndex, gObj[aIndex].AccountID);
  2467. lpObj->m_bMapSvrMoveReq = false;
  2468. lpObj->m_sPrevMapSvrCode = -1;
  2469. lpObj->m_sDestMapNumber = -1;
  2470. lpObj->m_btDestX = 0;
  2471. lpObj->m_btDestY = 0;
  2472. #ifdef MAXIMUM_IP_CONNECTIONS
  2473. if (!Check2IP_AccountEnter(aIndex))
  2474. {
  2475. LogAddC(2, "[CONNECT CHECK][%s](%s)Attept to connect with 1 ip - Refuse", lpObj->AccountID, lpObj->Ip_addr);
  2476. CloseClient(aIndex);
  2477. }
  2478. #endif
  2479.  
  2480. }
  2481. void CSPJoinIdPassRequestTEST(int aIndex)
  2482. {
  2483. char szId[11];
  2484. char szPass[MAX_PASS_LEN+1];
  2485. LPOBJ lpObj = &gObj[aIndex];
  2486. SDHP_IDPASS spMsg;
  2487.  
  2488. PHeadSetB((LPBYTE)&spMsg, 0x11, sizeof(spMsg));
  2489. spMsg.Number = aIndex;
  2490. wsprintf(szId, "admin", logincounttest);
  2491. wsprintf(szPass, "admin", rand()%9);
  2492. LogAdd("test login send : %s %s", szId, szPass);
  2493.  
  2494. BuxConvert(szId, MAX_ACCOUNT_LEN);
  2495. BuxConvert(szPass, MAX_ACCOUNT_LEN);
  2496. memcpy(spMsg.Id, szId, MAX_ACCOUNT_LEN);
  2497. memcpy(spMsg.Pass, szPass, MAX_PASS_LEN);
  2498. logincounttest++;
  2499.  
  2500. if ( (GetTickCount()-ltesttime) > 1000 )
  2501. {
  2502. ltesttime = GetTickCount();
  2503. logincounttest=0;
  2504. }
  2505.  
  2506. wsJServerCli.DataSend((char*)&spMsg, spMsg.h.size);
  2507. spMsg.h.headcode = 0x01;
  2508. wsJServerCli.DataSend((char*)&spMsg, spMsg.h.size);
  2509. }
  2510.  
  2511. void GCJoinResult(BYTE result, int aIndex)
  2512. {
  2513. PMSG_RESULT pResult;
  2514.  
  2515. PHeadSubSetB((LPBYTE)&pResult, 0xF1, 0x01, sizeof(pResult));
  2516. pResult.result = result;
  2517. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  2518. }
  2519.  
  2520. void GCJoinSocketResult(BYTE result, SOCKET Socket)
  2521. {
  2522. PMSG_RESULT pResult;
  2523.  
  2524. PHeadSubSetB((LPBYTE)&pResult , 0xF1, 0x01, sizeof(pResult) );
  2525. pResult.result= result;
  2526.  
  2527. wsGServer.DataSocketSend(Socket, (char*)&pResult, pResult.h.size);
  2528. }
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535. void CGClientCloseMsg(PMSG_CLIENTCLOSE * lpMsg, int aIndex)
  2536. {
  2537. switch ( lpMsg->Flag )
  2538. {
  2539. case 0: // Close Game
  2540. gObjCloseSet(aIndex, 0);
  2541.  
  2542. if ( aIndex < 0 || aIndex > OBJMAX-1)
  2543. {
  2544. return;
  2545. }
  2546.  
  2547. LogAddTD("[UserSelClose] Go Exit [%s][%s] Map:[%d][%d/%d]",
  2548. gObj[aIndex].AccountID, gObj[aIndex].Name,
  2549. gObj[aIndex].MapNumber, gObj[aIndex].X, gObj[aIndex].Y);
  2550. break;
  2551.  
  2552. case 2: // ServerList
  2553. gObjCloseSet(aIndex, 2);
  2554.  
  2555. if ( aIndex < 0 || aIndex > OBJMAX-1)
  2556. {
  2557. return;
  2558. }
  2559.  
  2560. LogAddTD("[UserSelClose] Go ServerList [%s][%s] Map:[%d][%d/%d]",
  2561. gObj[aIndex].AccountID, gObj[aIndex].Name,
  2562. gObj[aIndex].MapNumber, gObj[aIndex].X, gObj[aIndex].Y);
  2563. break;
  2564.  
  2565. case 1: // Select Character
  2566. gObjCloseSet(aIndex, 1);
  2567.  
  2568. if ( aIndex < 0 || aIndex > OBJMAX-1)
  2569. {
  2570. return;
  2571. }
  2572.  
  2573. LogAddTD("[UserSelClose] Go CharSelect [%s][%s] Map:[%d][%d/%d]",
  2574. gObj[aIndex].AccountID, gObj[aIndex].Name,
  2575. gObj[aIndex].MapNumber, gObj[aIndex].X, gObj[aIndex].Y);
  2576. break;
  2577. }
  2578. }
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585. void GCCloseMsgSend(int aIndex, BYTE result)
  2586. {
  2587. PMSG_RESULT pMsg;
  2588.  
  2589. PHeadSubSetBE((LPBYTE)&pMsg, 0xF1, 0x02, sizeof(pMsg));
  2590. pMsg.result = result;
  2591.  
  2592. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  2593. }
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599. void CGClientMsg(PMSG_CLIENTMSG* lpMsg, int aIndex)
  2600. {
  2601. if ( lpMsg->Flag )
  2602. {
  2603. LogAddC(2,"error-L1 : HackCheck [%s][%s] 0x%x 0x%x",
  2604. gObj[aIndex].AccountID, gObj[aIndex].Name,
  2605. lpMsg->Flag, lpMsg->subFlag);
  2606. }
  2607. else
  2608. {
  2609. if ( gObj[aIndex].m_ClientHackLogCount < 100 )
  2610. {
  2611. LogAddC(2, "error-L1 : HackCheck [%s][%s] 0x%x 0x%x",
  2612. gObj[aIndex].AccountID, gObj[aIndex].Name,
  2613. lpMsg->Flag, lpMsg->subFlag);
  2614. }
  2615.  
  2616. gObj[aIndex].m_ClientHackLogCount++;
  2617.  
  2618. if ( gObj[aIndex].m_ClientHackLogCount >= 100 )
  2619. gObj[aIndex].m_ClientHackLogCount = 100;
  2620. }
  2621.  
  2622. char msg[255];
  2623.  
  2624. wsprintf(msg, "Client HackCheck %d", lpMsg->Flag);
  2625. gSendHackLog.Send(aIndex, 0, msg);
  2626. }
  2627.  
  2628.  
  2629.  
  2630.  
  2631. struct SDHP_CREATECHAR
  2632. {
  2633. PBMSG_HEAD h; // C1:04
  2634. int UserNumber; // 4
  2635. int DBNumber; // 8
  2636. short Number; // C
  2637. char AccountId[10]; // E
  2638. char Name[10]; // 18
  2639. BYTE ClassSkin; // 22
  2640. };
  2641.  
  2642.  
  2643.  
  2644. void CGPCharacterCreate( PMSG_CHARCREATE * lpMsg, int aIndex)
  2645. {
  2646. if ( !PacketCheckTime(&gObj[aIndex]))
  2647. {
  2648. JGCharacterCreateFailSend(aIndex, lpMsg->Name);
  2649. return;
  2650. }
  2651.  
  2652. if ( gObj[aIndex].Connected < PLAYER_LOGGED )
  2653. {
  2654. LogAdd(lMsg.Get(MSGGET(1, 220)), aIndex, gObj[aIndex].Ip_addr);
  2655. CloseClient(aIndex);
  2656.  
  2657. return;
  2658. }
  2659.  
  2660. if ( gObj[aIndex].Connected == PLAYER_PLAYING )
  2661. {
  2662. LogAddTD("[Anti-HACK][CGPCharacterCreate] Attempted Character Create during GamePlay. [%s][%s]",
  2663. gObj[aIndex].AccountID, gObj[aIndex].Name);
  2664. CloseClient(aIndex);
  2665.  
  2666. return;
  2667. }
  2668.  
  2669.  
  2670. if ( !gCreateCharacter )
  2671. {
  2672. GCServerMsgStringSend("¼­¹צ÷׀ַׂ ±ג°£¿¡´ֲ ִ³¸¯ֵֽ¸¦ »‎¼÷ַׂ¼צ ¾ר½ְ´ֿ´", aIndex, 1);
  2673. JGCharacterCreateFailSend(aIndex, lpMsg->Name);
  2674.  
  2675. return;
  2676. }
  2677.  
  2678.  
  2679. if ( lpMsg->ClassSkin == 0x00 || lpMsg->ClassSkin == 0x10 || lpMsg->ClassSkin == 0x20 || lpMsg->ClassSkin == 0x30 || lpMsg->ClassSkin == 0x40 )
  2680. {
  2681.  
  2682. }
  2683. else
  2684. {
  2685. JGCharacterCreateFailSend(aIndex, lpMsg->Name);
  2686. return;
  2687. }
  2688.  
  2689. if ( lpMsg->ClassSkin == 0x30 ) // MG
  2690. {
  2691. if ( gObj[aIndex].Magumsa == 0 )
  2692. {
  2693. LogAddC(2, "error-L1: Magumsa Character create error [%s]", gObj[aIndex].AccountID);
  2694. JGCharacterCreateFailSend(aIndex, lpMsg->Name);
  2695. return;
  2696. }
  2697. }
  2698.  
  2699. if ( lpMsg->ClassSkin == 0x40 ) // DL
  2700. {
  2701. if ( gObj[aIndex].Magumsa != 2 )
  2702. {
  2703. LogAddC(2, "error-L1: Darklord Character create error [%s]", gObj[aIndex].AccountID);
  2704. JGCharacterCreateFailSend(aIndex, lpMsg->Name);
  2705. return;
  2706. }
  2707. }
  2708.  
  2709. SDHP_CREATECHAR sCreate;
  2710.  
  2711. memset(&sCreate, 0, sizeof(sCreate));
  2712. PHeadSetB((LPBYTE)&sCreate, 0x04, sizeof(sCreate));
  2713. sCreate.ClassSkin = lpMsg->ClassSkin;
  2714. sCreate.Number = aIndex;
  2715. memcpy(sCreate.AccountId, gObj[aIndex].AccountID, MAX_ACCOUNT_LEN);
  2716. memcpy(sCreate.Name, lpMsg->Name, MAX_ACCOUNT_LEN);
  2717. char szTemp[20];
  2718. char szTemp2[20];
  2719. szTemp[10]=0;
  2720. szTemp2[10]=0;
  2721. memcpy(szTemp, sCreate.Name, MAX_ACCOUNT_LEN);
  2722. memcpy(szTemp2, sCreate.AccountId, MAX_ACCOUNT_LEN);
  2723.  
  2724. LogAddTD("Character create : %s,%s", szTemp2, szTemp);
  2725.  
  2726. cDBSMng.Send((char*)&sCreate, sCreate.h.size);
  2727. }
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734. struct SDHP_CHARDELETE
  2735. {
  2736. PBMSG_HEAD h; // C1:05
  2737. short Number; // 4
  2738. char AccountID[10]; // 6
  2739. char Name[10]; // 10
  2740. BYTE Guild; // [0:NoGuild] [1:Master] [2:Member] 1A
  2741. char GuildName[8]; // 1B
  2742. };
  2743.  
  2744.  
  2745.  
  2746.  
  2747. void CGPCharDel(PMSG_CHARDELETE * lpMsg,int aIndex)
  2748. {
  2749. if ( !PacketCheckTime(&gObj[aIndex]))
  2750. return;
  2751.  
  2752. if ( gObj[aIndex].Connected < PLAYER_LOGGED )
  2753. {
  2754. CloseClient(aIndex);
  2755. return;
  2756. }
  2757.  
  2758. if ( gObj[aIndex].Connected == PLAYER_PLAYING )
  2759. {
  2760. LogAddTD("[Anti-HACK][CGPCharDel] Attempted Character Delete during GamePlay. [%s][%s]",
  2761. gObj[aIndex].AccountID, gObj[aIndex].Name);
  2762. CloseClient(aIndex);
  2763. return;
  2764. }
  2765.  
  2766. if ( gObj[aIndex].bEnableDelCharacter == FALSE )
  2767. {
  2768. LogAddTD("[Anti-HACK][CGPCharDel] Attempted Character Delete during Prevented Time. [%s][%s]",
  2769. gObj[aIndex].AccountID, gObj[aIndex].Name);
  2770. CloseClient(aIndex);
  2771. return;
  2772. }
  2773.  
  2774. SDHP_CHARDELETE pCDel;
  2775. PMSG_RESULT pResult;
  2776.  
  2777. PHeadSubSetB((LPBYTE)&pResult, 0xF3, 0x02, sizeof(pResult));
  2778. pResult.result = 0;
  2779.  
  2780. if ( gObj[aIndex].m_cAccountItemBlock )
  2781. {
  2782. pResult.result = 3;
  2783. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  2784.  
  2785. return;
  2786. }
  2787.  
  2788. if ( !gGuildDestroy )
  2789. {
  2790. pResult.result = 0;
  2791. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  2792.  
  2793. return;
  2794. }
  2795. /*if ((gCharacterDeleteMaxLevel < gObj[aIndex].Level)||(gCharacterDeleteMinLevel > gObj[aIndex].Level))
  2796. {
  2797. pResult.result = 0;
  2798. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  2799. return;
  2800.  
  2801. }*/
  2802. char szJoomin[11];
  2803. char szTemp[20];
  2804. char szTemp2[20];
  2805.  
  2806. memset(szJoomin, 0, sizeof(szJoomin));
  2807. memcpy(szJoomin, lpMsg->LastJoominNumber, 10);
  2808.  
  2809. if (NeedIdCharacter != 1)
  2810. {
  2811.  
  2812. }
  2813. else
  2814. {
  2815. if ( gObjJoominCheck(aIndex, szJoomin) == FALSE )
  2816. {
  2817. pResult.result = 2;
  2818. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  2819.  
  2820. return;
  2821. }
  2822. }
  2823. PHeadSetB((LPBYTE)&pCDel, 0x05, sizeof(pCDel));
  2824. pCDel.Number = aIndex;
  2825. memcpy(pCDel.AccountID, gObj[aIndex].AccountID, sizeof(pCDel.AccountID));
  2826. memcpy(pCDel.Name, lpMsg->Name, sizeof(pCDel.Name));
  2827. pCDel.Guild = 0;
  2828.  
  2829. if ( gObj[aIndex].GuildNumber > 0 && gObj[aIndex].lpGuild != NULL)
  2830. {
  2831. if ( !strcmp(gObj[aIndex].Name, gObj[aIndex].lpGuild->Names[0] ))
  2832. {
  2833. pCDel.Guild = 1; // Master
  2834. }
  2835. else
  2836. {
  2837. pCDel.Guild = 2; // Member
  2838. }
  2839.  
  2840. memcpy(pCDel.GuildName, gObj[aIndex].lpGuild->Name, MAX_GUILD_LEN);
  2841. }
  2842.  
  2843. g_CashItemPeriodSystem.GDReqPeriodItemDelete(&gObj[aIndex], lpMsg->Name);
  2844. szTemp[10]=0;
  2845. szTemp2[10]=0;
  2846. memcpy(szTemp, pCDel.Name, MAX_ACCOUNT_LEN);
  2847. memcpy(szTemp2, pCDel.AccountID, MAX_ACCOUNT_LEN);
  2848.  
  2849. LogAddTD("Character delete : %s,%s", szTemp2, szTemp);
  2850.  
  2851. cDBSMng.Send((PCHAR)&pCDel, pCDel.h.size);
  2852. gObj[aIndex].Level = 0;
  2853. }
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859. void CGPCharacterMapJoinRequest( PMSG_CHARMAPJOIN * lpMsg, int aIndex)
  2860. {
  2861. if ( !PacketCheckTime(&gObj[aIndex]))
  2862. {
  2863. //JGCharacterCreateFailSend(aIndex, lpMsg->Name);
  2864. return;
  2865. }
  2866.  
  2867. if (gObj[aIndex].ClientAccept != 1)
  2868. {
  2869.  
  2870. LogAddC(2, "The player has not confirmed the original client [aIndex: %d]%d", aIndex, gObj[aIndex].ClientAccept);
  2871. CloseClient(aIndex);
  2872. return;
  2873. }
  2874. if ( !gObjIsAccontConnect(aIndex, gObj[aIndex].AccountID))
  2875. return;
  2876.  
  2877. if ( gObj[aIndex].Connected == PLAYER_PLAYING )
  2878. return;
  2879.  
  2880. gObj[aIndex].bEnableDelCharacter = FALSE;
  2881. char _name[MAX_ACCOUNT_LEN+1];
  2882. SDHP_DBCHARINFOREQUEST pCRequest;
  2883.  
  2884. PHeadSetB((LPBYTE)&pCRequest, 0x06, sizeof(pCRequest));
  2885. memset(_name, 0, MAX_ACCOUNT_LEN);
  2886. memcpy(_name, lpMsg->Name, MAX_ACCOUNT_LEN);
  2887. BuxConvert(_name, MAX_ACCOUNT_LEN);
  2888. memcpy(pCRequest.Name, _name, MAX_ACCOUNT_LEN);
  2889. strcpy(pCRequest.AccountID, gObj[aIndex].AccountID);
  2890. pCRequest.Number = aIndex;
  2891.  
  2892. cDBSMng.Send((char*)&pCRequest, pCRequest.h.size);
  2893.  
  2894.  
  2895.  
  2896. }
  2897.  
  2898.  
  2899.  
  2900. struct PMSG_LEVELUP
  2901. {
  2902. PBMSG_HEAD h; // C1:F3:05
  2903. BYTE subcode; // 3
  2904. WORD Level; // 4
  2905. WORD LevelUpPoint; // 6
  2906. WORD MaxLife; // 8
  2907. WORD MaxMana; // A
  2908. WORD wMaxShield; // C
  2909. WORD MaxBP; // E
  2910. short AddPoint; // 10
  2911. short MaxAddPoint; // 12
  2912. short MinusPoint; // 14
  2913. short MaxMinusPoint; // 16
  2914. };
  2915.  
  2916.  
  2917.  
  2918. void GCLevelUpMsgSend(int aIndex, int iSendEffect)
  2919. {
  2920. if ( !OBJMAX_RANGE(aIndex))
  2921. return;
  2922.  
  2923. short AddPoint=0;
  2924. short MaxAddPoint=0;
  2925. short MinusPoint=0;
  2926. short MaxMinusPoint=0;
  2927.  
  2928. gObjGetStatPointState(gObj[aIndex].m_Index, AddPoint, MaxAddPoint, MinusPoint, MaxMinusPoint);
  2929.  
  2930. PMSG_LEVELUP pMsg;
  2931.  
  2932. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x05, sizeof(pMsg));
  2933. pMsg.Level = gObj[aIndex].Level;
  2934. pMsg.LevelUpPoint = gObj[aIndex].LevelUpPoint;
  2935. pMsg.MaxLife = ((float)gObj[aIndex].MaxLife+(float)gObj[aIndex].AddLife);
  2936. pMsg.MaxMana = ( (float)gObj[aIndex].MaxMana+(float)gObj[aIndex].AddMana);
  2937. pMsg.MaxBP = gObj[aIndex].MaxBP + gObj[aIndex].AddBP;
  2938. pMsg.wMaxShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  2939. pMsg.AddPoint = AddPoint;
  2940. pMsg.MaxAddPoint = MaxAddPoint;
  2941. pMsg.MinusPoint = MinusPoint;
  2942. pMsg.MaxMinusPoint = MaxMinusPoint;
  2943.  
  2944. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  2945.  
  2946. if ( iSendEffect == 1 )
  2947. GCSendEffectInfo(aIndex, 0x10);
  2948. }
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954. void CGLevelUpPointAdd(PMSG_LVPOINTADD * lpMsg, int aIndex)
  2955. {
  2956. if ( !gObjIsConnected(aIndex))
  2957. {
  2958. CloseClient(aIndex);
  2959. return;
  2960. }
  2961.  
  2962. PMSG_LVPOINTADDRESULT pMsg;
  2963.  
  2964. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x06, sizeof(pMsg));
  2965. pMsg.ResultType = 0;
  2966.  
  2967. if (::gObjLevelUpPointAdd(lpMsg->Type, &gObj[aIndex]) == TRUE )
  2968. {
  2969. pMsg.ResultType = 0x10;
  2970. pMsg.ResultType += lpMsg->Type;
  2971.  
  2972. switch ( lpMsg->Type )
  2973. {
  2974. case 2: // Vit
  2975. pMsg.MaxLifeAndMana = gObj[aIndex].MaxLife + gObj[aIndex].AddLife;
  2976. break;
  2977.  
  2978. case 3: // Energy
  2979. pMsg.MaxLifeAndMana = gObj[aIndex].MaxMana + gObj[aIndex].AddMana;
  2980. break;
  2981. }
  2982.  
  2983. #if (FOREIGN_GAMESERVER==1)
  2984. if ( szAuthKey[9] != AUTHKEY9 )
  2985. DestroyGIocp();
  2986. #endif
  2987. pMsg.wMaxShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  2988. gObjSetBP(aIndex);
  2989. pMsg.MaxBP = gObj[aIndex].MaxBP + gObj[aIndex].AddBP;
  2990. }
  2991.  
  2992. DataSend(aIndex, (UCHAR *)&pMsg, pMsg.h.size);
  2993.  
  2994. }
  2995.  
  2996.  
  2997.  
  2998. struct PMSG_INVENTORYITEMMODIFY
  2999. {
  3000. PBMSG_HEAD h; // C1:F3:14
  3001. BYTE subcode; // 3
  3002. BYTE Pos; // 4
  3003. BYTE ItemInfo[MAX_ITEM_INFO]; // 5
  3004.  
  3005. };
  3006.  
  3007.  
  3008. void GCInventoryItemOneSend(int aIndex, int pos)
  3009. {
  3010. if ( !gObj[aIndex].pInventory[pos].IsItem())
  3011. return;
  3012.  
  3013. PMSG_INVENTORYITEMMODIFY pMsg;
  3014.  
  3015. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x14, sizeof(pMsg));
  3016. pMsg.Pos = pos;
  3017. ItemByteConvert(pMsg.ItemInfo, gObj[aIndex].pInventory[pos]);
  3018.  
  3019. DataSend(aIndex, (UCHAR *)&pMsg, pMsg.h.size);
  3020. }
  3021.  
  3022.  
  3023.  
  3024. struct PMSG_PKLEVEL
  3025. {
  3026. PBMSG_HEAD h; // C1:F3:08
  3027. BYTE subcode; // 3
  3028. BYTE NumberH; // 4
  3029. BYTE NumberL; // 5
  3030. BYTE PkLevel; // 6
  3031. };
  3032.  
  3033.  
  3034. void GCPkLevelSend(int aIndex, BYTE pklevel)
  3035. {
  3036. PMSG_PKLEVEL pMsg;
  3037.  
  3038. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x08, sizeof(pMsg));
  3039. pMsg.NumberH = SET_NUMBERH(aIndex);
  3040. pMsg.NumberL = SET_NUMBERL(aIndex);
  3041. pMsg.PkLevel = pklevel;
  3042.  
  3043. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  3044. MsgSendV2(&gObj[aIndex], (UCHAR*)&pMsg, pMsg.h.size);
  3045. }
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051. struct PMSG_MAGICLIST
  3052. {
  3053. char Pos; // 0
  3054. BYTE MagicInfo[MAX_MAGIC_INFO]; // 1
  3055. };
  3056.  
  3057.  
  3058. struct PMSG_MAGICLISTCOUNT
  3059. {
  3060. PBMSG_HEAD h; // C1:F3:11
  3061. BYTE subcode; // 3
  3062. BYTE Count; // [0xFE:AddOne] [0xFF:DelOne] 4
  3063. BYTE btListType; // 5
  3064. };
  3065.  
  3066.  
  3067.  
  3068. void GCMagicListOneSend(int aIndex, char Pos, BYTE type, BYTE level, BYTE skill, BYTE btListType)
  3069. {
  3070. PMSG_MAGICLISTCOUNT pCount;
  3071. PMSG_MAGICLIST pList;
  3072. BYTE sendbuf[1000];
  3073. int lOfs = sizeof(pCount);
  3074.  
  3075. PHeadSubSetB((LPBYTE)&pCount, 0xF3, 0x11, 0);
  3076. pCount.Count = 0xFE;
  3077. pCount.btListType = btListType;
  3078. pList.Pos = Pos;
  3079. pList.MagicInfo[DBM_TYPE] = type;
  3080. pList.MagicInfo[DBM_LEVEL] = level<<3;
  3081. pList.MagicInfo[DBM_LEVEL] |= skill & 0x07;
  3082. memcpy(&sendbuf[lOfs], &pList, sizeof(pList));
  3083. lOfs+= sizeof(pList);
  3084. pCount.h.size = lOfs;
  3085. memcpy(sendbuf, &pCount, sizeof(pCount));
  3086.  
  3087. DataSend(aIndex, sendbuf, lOfs);
  3088. }
  3089.  
  3090.  
  3091.  
  3092. void GCMagicListOneDelSend(int aIndex, char Pos, BYTE type, BYTE level, BYTE skill, BYTE btListType)
  3093. {
  3094. PMSG_MAGICLISTCOUNT pCount;
  3095. PMSG_MAGICLIST pList;
  3096. BYTE sendbuf[1000];
  3097. int lOfs = sizeof(pCount);
  3098.  
  3099. PHeadSubSetB((LPBYTE)&pCount, 0xF3, 0x11, 0);
  3100. pCount.h.size = 0;
  3101. pCount.Count = 0xFF;
  3102. pCount.btListType = btListType;
  3103. pList.Pos = Pos;
  3104. pList.MagicInfo[DBM_TYPE] = type;
  3105. pList.MagicInfo[DBM_LEVEL] = level<<3;
  3106. pList.MagicInfo[DBM_LEVEL] |= skill & 0x07;
  3107. memcpy(&sendbuf[lOfs], &pList, sizeof(pList));
  3108. lOfs+= sizeof(pList);
  3109. pCount.h.size = lOfs;
  3110. memcpy(sendbuf, &pCount, sizeof(pCount));
  3111.  
  3112. DataSend(aIndex, sendbuf, lOfs);
  3113. }
  3114.  
  3115.  
  3116.  
  3117. void GCMagicListMultiSend(LPOBJ lpObj, BYTE btListType)
  3118. {
  3119. PMSG_MAGICLISTCOUNT pCount;
  3120. PMSG_MAGICLIST pList;
  3121. BYTE sendbuf[1000];
  3122. int lOfs = sizeof(pCount);
  3123. int Count = 0;
  3124. pCount.btListType = btListType;
  3125.  
  3126. PHeadSubSetB((LPBYTE)&pCount, 0xF3, 0x11, 0);
  3127.  
  3128. for ( int n=0;n<MAX_MAGIC;n++)
  3129. {
  3130. if ( lpObj->Magic[n].IsMagic() == TRUE )
  3131. {
  3132. pList.Pos = n;
  3133. pList.MagicInfo[DBM_TYPE] = lpObj->Magic[n].m_Skill;
  3134. pList.MagicInfo[DBM_LEVEL] = lpObj->Magic[n].m_Level<<3;
  3135. pList.MagicInfo[DBM_LEVEL] |= lpObj->Magic[n].m_Skill & 0x07;
  3136. memcpy(&sendbuf[lOfs], &pList, sizeof(pList));
  3137. lOfs+= sizeof(pList);
  3138. Count++;
  3139. }
  3140. }
  3141.  
  3142. pCount.Count = Count;
  3143. pCount.h.size = lOfs;
  3144. memcpy(sendbuf, &pCount, sizeof(pCount));
  3145.  
  3146. DataSend(lpObj->m_Index, sendbuf, lOfs);
  3147. }
  3148.  
  3149.  
  3150.  
  3151.  
  3152. struct PMSG_EQUIPMENTLIST
  3153. {
  3154. PBMSG_HEAD h; // C1:F3:13
  3155. BYTE subcode; // 3
  3156. BYTE NumberH; // 4
  3157. BYTE NumberL; // 5
  3158. BYTE Equipment[CHAR_SET_SIZE]; // 6
  3159. };
  3160.  
  3161.  
  3162. void GCEquipmentSend(int aIndex)
  3163. {
  3164. PMSG_EQUIPMENTLIST pMsg;
  3165.  
  3166. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x13, sizeof(pMsg));
  3167. pMsg.NumberH = SET_NUMBERH(aIndex);
  3168. pMsg.NumberL = SET_NUMBERL(aIndex);
  3169. gObjMakePreviewCharSet(aIndex);
  3170. LPOBJ lpObj = &gObj[aIndex];
  3171. memcpy(pMsg.Equipment, lpObj->CharSet, sizeof(lpObj->CharSet));
  3172.  
  3173. MsgSendV2(lpObj, (LPBYTE)&pMsg, pMsg.h.size);
  3174. }
  3175.  
  3176.  
  3177.  
  3178. struct PMSG_RECALLMONLIFE
  3179. {
  3180. PBMSG_HEAD h; // C1:F3:20
  3181. BYTE subcode; // 3
  3182. BYTE Life; // 4
  3183. };
  3184.  
  3185.  
  3186. void GCRecallMonLife(int aIndex, int maxlife, int life)
  3187. {
  3188. if ( maxlife <= 0 )
  3189. return;
  3190.  
  3191. PMSG_RECALLMONLIFE pMsg;
  3192. BYTE per = life * 100 / maxlife;
  3193. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x20, sizeof(pMsg));
  3194. pMsg.Life = per;
  3195.  
  3196. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  3197. }
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203. struct PMSG_TIMEVIEW
  3204. {
  3205. PBMSG_HEAD h; // C1:F3:22
  3206. BYTE subcode; // 3
  3207. WORD Second; // 4
  3208. };
  3209.  
  3210.  
  3211. void GCTimeViewSend(int aIndex, int second)
  3212. {
  3213. PMSG_TIMEVIEW pMsg;
  3214.  
  3215. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x22, sizeof(pMsg));
  3216. pMsg.Second = second;
  3217.  
  3218. DataSend(aIndex, (UCHAR *)&pMsg, pMsg.h.size);
  3219. }
  3220.  
  3221.  
  3222.  
  3223.  
  3224. struct PMSG_GOALSEND
  3225. {
  3226. PBMSG_HEAD h; // C1:F3:23
  3227. BYTE subcode; // 3
  3228. char RedTeamName[8]; // 4
  3229. BYTE RedTeamScore; // C
  3230. char BlueTeamName[8]; // D
  3231. BYTE BlueTeamScore; // 15
  3232. };
  3233.  
  3234.  
  3235. void GCGoalSend(int aIndex, char* Name1, BYTE score1, char* Name2, BYTE score2)
  3236. {
  3237. PMSG_GOALSEND pMsg;
  3238.  
  3239. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x23, sizeof(pMsg));
  3240. memcpy(pMsg.RedTeamName, Name1, sizeof(pMsg.RedTeamName));
  3241. pMsg.RedTeamScore = score1;
  3242. memcpy(pMsg.BlueTeamName, Name2, sizeof(pMsg.BlueTeamName));
  3243. pMsg.BlueTeamScore = score2;
  3244.  
  3245. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  3246. }
  3247.  
  3248.  
  3249.  
  3250.  
  3251. void GCSkillKeyRecv(PMSG_SKILLKEY * lpMsg, int aIndex)
  3252. {
  3253. if ( !gObjIsGamePlaing(&gObj[aIndex]))
  3254. return;
  3255.  
  3256. DGOptionDataSend(aIndex, gObj[aIndex].Name,
  3257. lpMsg->SKillKey, lpMsg->GameOption,
  3258. lpMsg->QkeyDefine, lpMsg->WkeyDefine, lpMsg->EkeyDefine, lpMsg->ChatWindow);
  3259.  
  3260. LogAddL("Option Recv %d %d %d %d", lpMsg->GameOption,
  3261. lpMsg->QkeyDefine, lpMsg->WkeyDefine, lpMsg->EkeyDefine);
  3262. }
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271. void GCSkillKeySend(int aIndex, LPBYTE keybuffer, BYTE GO, BYTE Qk, BYTE Wk, BYTE Ek, BYTE ChatWnd)
  3272. {
  3273. PMSG_SKILLKEY pMsg;
  3274.  
  3275. PHeadSubSetB((LPBYTE)&pMsg, 0xF3, 0x30, sizeof(pMsg));
  3276. memcpy(pMsg.SKillKey, keybuffer, sizeof(pMsg.SKillKey));
  3277. pMsg.GameOption = GO;
  3278. pMsg.QkeyDefine = Qk;
  3279. pMsg.WkeyDefine = Wk;
  3280. pMsg.EkeyDefine = Ek;
  3281. pMsg.ChatWindow = ChatWnd;
  3282.  
  3283. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  3284. LogAddL("Option Send %d %d %d %d", GO, Qk, Wk, Ek);
  3285. }
  3286.  
  3287.  
  3288.  
  3289. struct PMSG_ITEMGETRESULT
  3290. {
  3291. PBMSG_HEAD h; // C1:22
  3292. BYTE result; // [0xFE:Money] 3
  3293. BYTE Data[MAX_ITEM_INFO]; // 4
  3294. };
  3295.  
  3296.  
  3297. void GCMoneySend(int aIndex, DWORD money)
  3298. {
  3299. PMSG_ITEMGETRESULT pMsg;
  3300.  
  3301. pMsg.h.c = 0xC3;
  3302. pMsg.h.headcode = 0x22;
  3303. pMsg.h.size = sizeof(pMsg);
  3304. pMsg.result = 0xFE;
  3305.  
  3306. WORD hiWord = SET_NUMBERHW(money);
  3307. WORD loWord = SET_NUMBERLW(money);
  3308. pMsg.Data[0] = SET_NUMBERH(hiWord);
  3309. pMsg.Data[1] = SET_NUMBERL(hiWord);
  3310. pMsg.Data[2] = SET_NUMBERH(loWord);
  3311. pMsg.Data[3] = SET_NUMBERL(loWord);
  3312.  
  3313. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  3314. }
  3315.  
  3316.  
  3317.  
  3318. void GCItemInventoryPutSend(int aIndex,BYTE result, BYTE iteminfo1, BYTE iteminfo2)
  3319. {
  3320. PMSG_ITEMGETRESULT pResult;
  3321.  
  3322. pResult.h.c = 0xC3;
  3323. pResult.h.headcode = 0x22;
  3324. pResult.h.size = sizeof(pResult);
  3325. pResult.result = result;
  3326. pResult.Data[0] = iteminfo1;
  3327. pResult.Data[1] = iteminfo2;
  3328. pResult.h.size -= 2;
  3329.  
  3330. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  3331. }
  3332.  
  3333.  
  3334.  
  3335.  
  3336.  
  3337. void CGItemGetRequest(PMSG_ITEMGETREQUEST * lpMsg, int aIndex)
  3338. {
  3339. int item_num, map_num;
  3340. PMSG_ITEMGETRESULT pResult;
  3341. int type;
  3342. int level;
  3343. int special;
  3344. int NOption;
  3345. char szItemName[50];
  3346.  
  3347. CMapItem * lpItem;
  3348.  
  3349. pResult.h.c = 0xC3;
  3350. pResult.h.headcode = 0x22;
  3351. pResult.h.size = sizeof(pResult);
  3352. pResult.result = -1;
  3353.  
  3354. if ( !gObjIsConnected(aIndex))
  3355. {
  3356. CloseClient(aIndex);
  3357. return;
  3358. }
  3359.  
  3360. if ( gObj[aIndex].CloseType != -1 )
  3361. return;
  3362.  
  3363. if ( gObj[aIndex].DieRegen != 0 )
  3364. {
  3365. pResult.result = -1;
  3366. pResult.h.size -= sizeof(pResult.Data);
  3367. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  3368.  
  3369. return;
  3370. }
  3371.  
  3372. if ( gObj[aIndex].m_IfState.use != 0 )
  3373. {
  3374. if ( gObj[aIndex].m_IfState.type != 3 )
  3375. {
  3376. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 94)), aIndex, 1);
  3377. pResult.result = -1;
  3378. pResult.h.size -= sizeof(pResult.Data);
  3379. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  3380.  
  3381. return;
  3382. }
  3383. }
  3384.  
  3385.  
  3386. if ( !::gObjFixInventoryPointer(aIndex))
  3387. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  3388.  
  3389. if ( gObj[aIndex].pTransaction == TRUE )
  3390. {
  3391. LogAddTD("[%s][%s] CGItemGetRequest() Failed : Transaction == 1, IF_TYPE : %d",
  3392. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  3393.  
  3394. return;
  3395.  
  3396. }
  3397.  
  3398.  
  3399. // Get RealNumber
  3400. item_num = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  3401.  
  3402. // Check In Range
  3403. // if not spit
  3404. if ( MAX_ITEM_TYPE_RANGE(item_num) == FALSE )
  3405. {
  3406.  
  3407. LogAdd("error-L3 : %s %d", __FILE__, __LINE__);
  3408. pResult.result = -1;
  3409. pResult.h.size -= sizeof(pResult.Data);
  3410. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  3411. return;
  3412. }
  3413.  
  3414. map_num = gObj[aIndex].MapNumber;
  3415. if ( MAX_MAP_RANGE(map_num) == FALSE )
  3416. {
  3417. LogAdd("error-L3 : %s %d", __FILE__, __LINE__);
  3418. pResult.result = -1;
  3419. pResult.h.size -= sizeof(pResult.Data);
  3420. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  3421.  
  3422. return;
  3423. }
  3424.  
  3425. lpItem = &MapC[map_num].m_cItem[item_num];
  3426.  
  3427. if ( lpItem->IsItem() == TRUE && lpItem->Give == false && lpItem->live == true)
  3428. {
  3429. /*
  3430. if ( lpItem->m_QuestItem != false ) // ALLOW PICK
  3431. {
  3432. //BOOL bNotFoundQuestItem = g_QuestInfo.CountQuestItemInInventory(aIndex, lpItem->m_Type, lpItem->m_Level); //season 2.5 add-on
  3433. int bResult = g_QuestInfo.CheckItemCount(aIndex, lpItem->m_Type, lpItem->m_Level);
  3434.  
  3435. if(bResult == FALSE)
  3436. {
  3437. pResult.result = -1;
  3438. pResult.h.size -= sizeof(pResult.Data);
  3439. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3440. return;
  3441. }
  3442. }
  3443. */
  3444.  
  3445. if ( lpItem->m_Type == ITEMGET(13,20) ) // Wizard Ring
  3446. {
  3447. switch ( lpItem->m_Level )
  3448. {
  3449. case 0:
  3450. {
  3451. int iWRCount = gObjGetItemCountInIventory(aIndex, lpItem->m_Type/MAX_SUBTYPE_ITEMS, lpItem->m_Type%MAX_SUBTYPE_ITEMS, lpItem->m_Level);
  3452.  
  3453. if ( iWRCount > 0 )
  3454. {
  3455. LogAdd("[Ring Event] Too many have Magician's Ring [%s][%s] (Name:%s, Count:%d)",
  3456. gObj[aIndex].AccountID, gObj[aIndex].Name, lpItem->GetName(), iWRCount);
  3457.  
  3458. pResult.result = -1;
  3459. pResult.h.size -= sizeof(pResult.Data);
  3460.  
  3461. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3462. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 186)), aIndex, 1);
  3463.  
  3464. return;
  3465. }
  3466. break;
  3467. }
  3468. case 1:
  3469.  
  3470. pResult.result = -1;
  3471. pResult.h.size -= sizeof(pResult.Data);
  3472.  
  3473. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3474. return;
  3475. break;
  3476.  
  3477. }
  3478. }
  3479.  
  3480. if ( lpItem->m_Type == ITEMGET(13,20) && lpItem->m_Level == 2 ) // Wizard Ring
  3481. {
  3482. pResult.result = -1;
  3483. pResult.h.size -= sizeof(pResult.Data);
  3484.  
  3485. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3486.  
  3487. return;
  3488. }
  3489.  
  3490. if ( lpItem->m_Type == ITEMGET(13,38) ) // MoonStonePendant
  3491. {
  3492. int count = gObjGetItemCountInIventory(aIndex, lpItem->m_Type/MAX_SUBTYPE_ITEMS,
  3493. lpItem->m_Type % MAX_SUBTYPE_ITEMS, lpItem->m_Level);
  3494.  
  3495. if ( count > 0 )
  3496. {
  3497. LogAdd("[ MoonStonePendant ] Too many have MoonStonePendant [%s][%s] ( Name:%s, Count:%d )",
  3498. gObj[aIndex].AccountID, gObj[aIndex].Name, lpItem->GetName(), count);
  3499.  
  3500. pResult.result = -1;
  3501. pResult.h.size -= sizeof(pResult.Data);
  3502.  
  3503. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3504. GCServerMsgStringSend(lMsg.Get(MSGGET(13, 56)), aIndex, 1);
  3505.  
  3506. return;
  3507. }
  3508. }
  3509.  
  3510. if ( lpItem->m_Type == ITEMGET(13,39) ) // ChangeRing
  3511. {
  3512. int count = gObjGetItemCountInIventory(aIndex, lpItem->m_Type/MAX_SUBTYPE_ITEMS,
  3513. lpItem->m_Type % MAX_SUBTYPE_ITEMS, lpItem->m_Level);
  3514.  
  3515. if ( count > 0 )
  3516. {
  3517. LogAdd("[ ChangeRing ] Too many have ChangeRing [%s][%s] ( Name:%s, Count:%d )",
  3518. gObj[aIndex].AccountID, gObj[aIndex].Name, lpItem->GetName(), count);
  3519.  
  3520. pResult.result = -1;
  3521. pResult.h.size -= sizeof(pResult.Data);
  3522.  
  3523. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3524. GCServerMsgStringSend(lMsg.Get(MSGGET(13, 63)), aIndex, 1);
  3525.  
  3526. return;
  3527. }
  3528. }
  3529.  
  3530. type = lpItem->m_Type;
  3531. level = lpItem->m_Level;
  3532. special = lpItem->m_Special[0];
  3533. NOption = lpItem->m_NewOption;
  3534. strcpy(szItemName, lpItem->GetName());
  3535.  
  3536. if ( lpItem->m_Type == ITEMGET(14,15) ) // Zen
  3537. {
  3538. if ( MapC[map_num].ItemGive(aIndex, item_num, false) == TRUE )
  3539. {
  3540. if ( !gObjCheckMaxZen(aIndex, lpItem->m_BuyMoney))
  3541. {
  3542. if ( gObj[aIndex].Money < MAX_ZEN )
  3543. {
  3544. gObj[aIndex].Money = MAX_ZEN;
  3545. pResult.result = -2;
  3546. WORD hiWord = SET_NUMBERHW(gObj[aIndex].Money);
  3547. WORD loWord = SET_NUMBERLW(gObj[aIndex].Money);
  3548. pResult.Data[0] = SET_NUMBERH(hiWord);
  3549. pResult.Data[1] = SET_NUMBERL(hiWord);
  3550. pResult.Data[2] = SET_NUMBERH(loWord);
  3551. pResult.Data[3] = SET_NUMBERL(loWord);
  3552.  
  3553. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3554.  
  3555. return;
  3556. }
  3557.  
  3558. pResult.result = -1;
  3559. pResult.h.size -= sizeof(pResult.Data);
  3560.  
  3561. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3562.  
  3563. return;
  3564. }
  3565.  
  3566. gObj[aIndex].Money += lpItem->m_BuyMoney;
  3567. pResult.result = -2;
  3568.  
  3569. WORD hiWord = SET_NUMBERHW(gObj[aIndex].Money);
  3570. WORD loWord = SET_NUMBERLW(gObj[aIndex].Money);
  3571. pResult.Data[0] = SET_NUMBERH(hiWord);
  3572. pResult.Data[1] = SET_NUMBERL(hiWord);
  3573. pResult.Data[2] = SET_NUMBERH(loWord);
  3574. pResult.Data[3] = SET_NUMBERL(loWord);
  3575. pResult.h.size -= 3;
  3576. }
  3577.  
  3578. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3579.  
  3580. }
  3581. else
  3582. {
  3583. if ( lpItem->m_Type == ITEMGET(13,32) )
  3584. {
  3585.  
  3586. int pos = gObjOverlapItemUsingDur((lpItem)?((CItem *)&lpItem->m_Number):NULL, map_num, item_num, aIndex, 20, ITEMGET(13,32), 0);
  3587.  
  3588. if ( MAIN_INVENTORY_RANGE(pos) != FALSE )
  3589. {
  3590. pResult.result = -3;
  3591. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3592. gObj[aIndex].pInventory[pos].m_Durability += lpItem->m_Durability;
  3593. GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
  3594.  
  3595. return;
  3596. }
  3597. }
  3598.  
  3599. if ( lpItem->m_Type == ITEMGET(13,33) )
  3600. {
  3601. int pos = gObjOverlapItemUsingDur((lpItem)?((CItem *)&lpItem->m_Number):NULL, map_num, item_num, aIndex, 20, ITEMGET(13,33), 0);
  3602.  
  3603. if ( MAIN_INVENTORY_RANGE(pos) != FALSE )
  3604. {
  3605. pResult.result = -3;
  3606. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3607. gObj[aIndex].pInventory[pos].m_Durability += lpItem->m_Durability;
  3608. GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
  3609.  
  3610. return;
  3611. }
  3612. }
  3613.  
  3614. if ( lpItem->m_Type == ITEMGET(13,34) )
  3615. {
  3616. int pos = gObjOverlapItemUsingDur((lpItem)?((CItem *)&lpItem->m_Number):NULL, map_num, item_num, aIndex, 10, ITEMGET(13,34), 0);
  3617.  
  3618. if ( MAIN_INVENTORY_RANGE(pos) != FALSE )
  3619. {
  3620. pResult.result = -3;
  3621. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3622. gObj[aIndex].pInventory[pos].m_Durability += lpItem->m_Durability;
  3623. GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
  3624.  
  3625. return;
  3626. }
  3627. }
  3628. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3629. ///////////////////////////////////////Elite Potion/////////////////////////////////////////////////////////////////////
  3630. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3631. if (lpItem->m_Type == ITEMGET(14,70) || lpItem->m_Type == ITEMGET(14,71) || lpItem->m_Type == ITEMGET(14,94))
  3632. {
  3633. int pos = gObjOverlapItemUsingDur((lpItem)?((CItem *)&lpItem->m_Number):NULL, map_num, item_num, aIndex, 50, lpItem->m_Type, 0);
  3634.  
  3635. if (MAIN_INVENTORY_RANGE(pos) != FALSE )
  3636. {
  3637. pResult.result = -3;
  3638. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3639. gObj[aIndex].pInventory[pos].m_Durability += lpItem->m_Durability;
  3640. GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
  3641. return;
  3642. }
  3643. }
  3644. if ( lpItem->m_Type == ITEMGET(14,29) ) // Symbol of Kundun
  3645. {
  3646. for ( int n=0;n<MAIN_INVENTORY_SIZE;n++)
  3647. {
  3648. int pos = ::g_KalimaGate.CheckOverlapKundunMark(aIndex, lpItem->m_Level);
  3649.  
  3650. if ( MAIN_INVENTORY_RANGE(pos) )
  3651. {
  3652. if ( MapC[map_num].ItemGive(aIndex, item_num, true) == TRUE )
  3653. {
  3654. BYTE NewOption[MAX_EXOPTION_SIZE];
  3655.  
  3656. ::ItemIsBufExOption(NewOption, (lpItem != NULL)?(CItem*)&lpItem->m_Number:NULL);
  3657.  
  3658. LogAddTD(lMsg.Get(MSGGET(1, 221)), gObj[aIndex].AccountID, gObj[aIndex].Name, map_num,
  3659. gObj[aIndex].X, gObj[aIndex].Y, lpItem->m_Number, szItemName, type,
  3660. level, lpItem->m_Option1, lpItem->m_Option2, lpItem->m_Option3, (int)lpItem->m_Durability,
  3661. NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4], NewOption[5],
  3662. NewOption[6], lpItem->m_SetOption, lpItem->m_ItemOptionEx>>7,
  3663. g_kJewelOfHarmonySystem.GetItemStrengthenOption((lpItem)?((CItem *)&lpItem->m_Number):NULL), g_kJewelOfHarmonySystem.GetItemOptionLevel((lpItem)?((CItem *)&lpItem->m_Number):NULL));
  3664.  
  3665. pResult.result = -3;
  3666.  
  3667. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3668.  
  3669. gObj[aIndex].pInventory[pos].m_Durability += lpItem->m_Durability;
  3670.  
  3671. if ( gObj[aIndex].pInventory[pos].m_Durability >= 5.0f )
  3672. {
  3673. int NewDur = gObj[aIndex].pInventory[pos].m_Durability - 5.0f;
  3674. ::gObjInventoryItemSet(aIndex, pos, -1);
  3675. gObj[aIndex].pInventory[pos].Clear();
  3676. ::GCInventoryItemDeleteSend(aIndex, pos, 1);
  3677. ::ItemSerialCreateSend(aIndex, 235, gObj[aIndex].X, gObj[aIndex].Y, ItemGetNumberMake(14, 28),
  3678. lpItem->m_Level, 0, 0, 0, 0, aIndex, 0, 0);
  3679.  
  3680. LogAddTD("[Kalima] [%s][%s] Make Lost Kalima Map (Left Kundun Mark:%d)",
  3681. gObj[aIndex].AccountID, gObj[aIndex].Name, NewDur);
  3682.  
  3683. if ( NewDur > 0 )
  3684. {
  3685. lpItem->m_State = 2;
  3686. lpItem->Give = false;
  3687. lpItem->live = true;
  3688. lpItem->m_Durability = NewDur;
  3689.  
  3690. continue;
  3691.  
  3692. }
  3693. }
  3694. else
  3695. {
  3696. GCItemDurSend(aIndex,pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
  3697.  
  3698. }
  3699. return;
  3700. }
  3701. }
  3702. else
  3703. {
  3704. break;
  3705. }
  3706. }
  3707. }
  3708.  
  3709. if ( lpItem->m_Type == ITEMGET(14,21) && lpItem->m_Level == 3) // Sign of Lord
  3710. {
  3711. for ( int n=0;n<MAIN_INVENTORY_SIZE;n++)
  3712. {
  3713. int pos = ::g_CastleSiegeSync.CheckOverlapCsMarks(aIndex);
  3714.  
  3715. if ( MAIN_INVENTORY_RANGE(pos) )
  3716. {
  3717. int Dur = gObj[aIndex].pInventory[pos].m_Durability + lpItem->m_Durability;
  3718.  
  3719. if ( Dur <= 255 )
  3720. {
  3721. if ( MapC[map_num].ItemGive(aIndex, item_num, true) == TRUE )
  3722. {
  3723. pResult.result = -3;
  3724. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3725. gObj[aIndex].pInventory[pos].m_Durability += lpItem->m_Durability;
  3726. GCItemDurSend( aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability,0);
  3727. return;
  3728. }
  3729. }
  3730. else
  3731. {
  3732. lpItem->m_Durability = Dur - 255;
  3733. gObj[aIndex].pInventory[pos].m_Durability = 255.0f;
  3734. GCItemDurSend(aIndex, pos, gObj[aIndex].pInventory[pos].m_Durability, 0);
  3735. }
  3736.  
  3737. }
  3738. else
  3739. {
  3740. break;
  3741. }
  3742. }
  3743. }
  3744.  
  3745. pResult.result = ::gObjInventoryInsertItemTemp(&gObj[aIndex], lpItem);
  3746.  
  3747. if ( pResult.result != 0xFF )
  3748. {
  3749. ItemByteConvert((LPBYTE)&pResult.Data[0], lpItem->m_Type, lpItem->m_Option1, lpItem->m_Option2,
  3750. lpItem->m_Option3, lpItem->m_Level, lpItem->m_Durability, lpItem->m_NewOption,
  3751. lpItem->m_SetOption, lpItem->m_JewelOfHarmonyOption, lpItem->m_ItemOptionEx);
  3752.  
  3753. if ( MapC[map_num].ItemGive(aIndex, item_num, false) == TRUE )
  3754. {
  3755. BYTE pos = ::gObjInventoryInsertItem(aIndex, lpItem);
  3756.  
  3757. if ( pos == 0xFF )
  3758. pResult.result = -1;
  3759.  
  3760. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3761.  
  3762. if ( pos == 0xFF )
  3763. {
  3764. ::GCItemListSend(aIndex);
  3765. }
  3766. else
  3767. {
  3768. BYTE NewOption[MAX_EXOPTION_SIZE];
  3769.  
  3770. ::ItemIsBufExOption(NewOption, (lpItem != NULL)?(CItem*)&lpItem->m_Number:NULL);
  3771.  
  3772. LogAddTD(lMsg.Get(MSGGET(1, 221)), gObj[aIndex].AccountID, gObj[aIndex].Name, map_num,
  3773. gObj[aIndex].X, gObj[aIndex].Y, lpItem->m_Number, szItemName, type,
  3774. level, lpItem->m_Option1, lpItem->m_Option2, lpItem->m_Option3, (INT)lpItem->m_Durability,
  3775. NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4], NewOption[5],
  3776. NewOption[6], lpItem->m_SetOption, lpItem->m_ItemOptionEx>>7,
  3777. g_kJewelOfHarmonySystem.GetItemStrengthenOption((lpItem)?((CItem *)&lpItem->m_Number):NULL), g_kJewelOfHarmonySystem.GetItemOptionLevel((lpItem)?((CItem *)&lpItem->m_Number):NULL));
  3778. ::GCSendGetItemInfoForParty(aIndex, lpItem);
  3779.  
  3780. if ( BC_MAP_RANGE(map_num) )
  3781. {
  3782. if ( g_BloodCastle.CheckQuestItemSerial(map_num-MAP_INDEX_BLOODCASTLE1, lpItem) )
  3783. {
  3784. g_BloodCastle.m_BridgeData[map_num-MAP_INDEX_BLOODCASTLE1].m_iBC_QUEST_ITEM_USER_INDEX = gObj[aIndex].m_Index;
  3785. char szTempMsg[128];
  3786.  
  3787. switch ( lpItem->m_Level )
  3788. {
  3789. case 0: // Staff of Archangel
  3790. wsprintf(szTempMsg, lMsg.Get(MSGGET(4, 150)), gObj[aIndex].Name);
  3791. g_BloodCastle.SendNoticeMessage(gObj[aIndex].MapNumber-MAP_INDEX_BLOODCASTLE1, szTempMsg);
  3792. break;
  3793.  
  3794. case 1: // Sword of Archangel
  3795. wsprintf(szTempMsg, lMsg.Get(MSGGET(4, 151)), gObj[aIndex].Name);
  3796. g_BloodCastle.SendNoticeMessage(gObj[aIndex].MapNumber-MAP_INDEX_BLOODCASTLE1, szTempMsg);
  3797. break;
  3798.  
  3799. case 2: // Crossbow of Archangel
  3800. wsprintf(szTempMsg, lMsg.Get(MSGGET(4, 152)), gObj[aIndex].Name);
  3801. g_BloodCastle.SendNoticeMessage(gObj[aIndex].MapNumber-MAP_INDEX_BLOODCASTLE1, szTempMsg);
  3802. break;
  3803.  
  3804. default:
  3805. szTempMsg[0] = 0;
  3806. }
  3807.  
  3808. LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) picked up Angel King's Weapon (%d)",
  3809. map_num-MAP_INDEX_BLOODCASTLE1+1, gObj[aIndex].AccountID, gObj[aIndex].Name, lpItem->m_Level);
  3810. }
  3811. }
  3812. if (IT_MAP_RANGE(map_num) ) //Season 2.5 add-on
  3813. {
  3814. if (lpItem->m_Type == ITEMGET(14,64))
  3815. {
  3816. BYTE pos = ::gObjInventoryInsertItem(aIndex, lpItem);
  3817. if ( pos == 0xFF )
  3818. {
  3819. pResult.result = -1;
  3820. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3821. return;
  3822. }
  3823. g_IllusionTempleEvent.SetRegPedestal(gObj[aIndex].MapNumber,aIndex,pos); //check
  3824. g_IllusionTempleEvent.SetRelicsCarrierViewState(&gObj[aIndex]);
  3825. LogAddTD("[Illusion Temple] (%d) (Account:%s, Name:%s) picked up Relics Item(serial:%d)", map_num-(MAP_INDEX_ILLUSIONTEMPLE_MIN-1), gObj[aIndex].AccountID, gObj[aIndex].Name, lpItem->m_Number);
  3826. }
  3827. }
  3828.  
  3829. }
  3830. }
  3831. else
  3832. {
  3833. pResult.result = -1;
  3834. pResult.h.size -= sizeof(pResult.Data);
  3835.  
  3836. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3837. }
  3838. }
  3839. else
  3840. {
  3841. pResult.result = -1;
  3842. pResult.h.size -= sizeof(pResult.Data);
  3843.  
  3844. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  3845. }
  3846. }
  3847. }
  3848. else
  3849. {
  3850. pResult.h.size -= sizeof(pResult.Data);
  3851. DataSend(aIndex, (UCHAR*)&pResult, pResult.h.size);
  3852. }
  3853. }
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862. BOOL CGItemDropRequest(PMSG_ITEMTHROW * lpMsg, int aIndex, BOOL drop_type)
  3863. {
  3864. BOOL CopyItem = FALSE;
  3865. BYTE NewOption[MAX_EXOPTION_SIZE];
  3866.  
  3867. if ( !PacketCheckTime(&gObj[aIndex]))
  3868. return FALSE;
  3869.  
  3870. PMSG_ITEMTHROW_RESULT pResult;
  3871.  
  3872. PHeadSetB((LPBYTE)&pResult, 0x23, sizeof(pResult));
  3873. pResult.Result = true;
  3874. pResult.Ipos = lpMsg->Ipos;
  3875.  
  3876. if ( gObj[aIndex].m_IfState.use != 0 )
  3877. {
  3878. if ( gObj[aIndex].m_IfState.type != 3 )
  3879. {
  3880. pResult.Result = false;
  3881. return FALSE;
  3882. }
  3883. }
  3884.  
  3885. if ( gObj[aIndex].CloseType != -1 )
  3886. pResult.Result = false;
  3887.  
  3888. if ( gObj[aIndex].m_bMapSvrMoveQuit == true )
  3889. {
  3890. LogAddTD("[ANTI-HACK][Item Duplication] - Item Drop during MapServer Move [%s][%s]",
  3891. gObj[aIndex].AccountID, gObj[aIndex].Name);
  3892. pResult.Result = false;
  3893. }
  3894.  
  3895.  
  3896. if ( !::gObjFixInventoryPointer(aIndex))
  3897. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  3898.  
  3899. if ( gObj[aIndex].pTransaction == 1 )
  3900. {
  3901. LogAddTD("[%s][%s] CGItemDropRequest() Failed : Transaction == 1, IF_TYPE : %d",
  3902. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  3903. pResult.Result = false;
  3904.  
  3905. return false;
  3906. }
  3907.  
  3908. LPOBJ lpObj = &gObj[aIndex];
  3909.  
  3910. if ( lpMsg->Ipos == 0xFF ) // Null Position
  3911. {
  3912. LogAdd("error:%s %d", __FILE__, __LINE__);
  3913. pResult.Result = false;
  3914. }
  3915.  
  3916. if ( lpMsg->Ipos < 0 || lpMsg->Ipos > MAIN_INVENTORY_SIZE-1) // Out of Bounds
  3917. pResult.Result = false;
  3918.  
  3919. if (!::gObjCanItemTouch(lpObj, 0))
  3920. pResult.Result = false;
  3921.  
  3922. // Icarus Preventions about Dinorant
  3923. if ( gObj[aIndex].MapNumber == MAP_INDEX_ICARUS)
  3924. {
  3925. if ( lpMsg->Ipos == 8 )
  3926. {
  3927. if ( lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(13,3) ) // Dinorant
  3928. {
  3929. if( lpObj->pInventory[7].IsItem() == FALSE )
  3930. {
  3931. pResult.Result = false;
  3932. }
  3933. }
  3934. }
  3935. else if ( lpMsg->Ipos == 7 )
  3936. {
  3937. if ( lpObj->pInventory[8].m_Type != ITEMGET(13,3) ) // Dinorant
  3938. {
  3939. pResult.Result = false;
  3940. }
  3941. }
  3942. }
  3943.  
  3944. if ( lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(12,30) ||
  3945. lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(12,31) ||
  3946. lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(13,36) ||
  3947. lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(13,37) )
  3948. {
  3949. pResult.Result = false;
  3950. }
  3951. if (IT_MAP_RANGE(lpObj->MapNumber) != FALSE) //Season 2.5 add-on
  3952. {
  3953. if ( lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(13,51) )
  3954. {
  3955. pResult.Result = false;
  3956. }
  3957. }
  3958. if (lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(14,64) )
  3959. {
  3960. pResult.Result = false;
  3961. }
  3962.  
  3963. if ( (lpObj->pInventory[lpMsg->Ipos].m_Type >= ITEMGET(13,0) && lpObj->pInventory[lpMsg->Ipos].m_Type <= ITEMGET(13,3))
  3964. || lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(14,13) ||
  3965. lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(14,14) ||
  3966. lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(14,16) ||
  3967. (lpObj->pInventory[lpMsg->Ipos].m_Type >= ITEMGET(12,0)
  3968. && lpObj->pInventory[lpMsg->Ipos].m_Type <= ITEMGET(12,6))
  3969. || lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(12,15)
  3970. || (lpObj->pInventory[lpMsg->Ipos].m_Level > 4
  3971. && lpObj->pInventory[lpMsg->Ipos].m_Type < ITEMGET(12,0))
  3972. || lpObj->pInventory[lpMsg->Ipos].IsSetItem() != FALSE
  3973. || lpObj->pInventory[lpMsg->Ipos].IsExtItem() != FALSE )
  3974. {
  3975. if ( gPkLimitFree == FALSE )
  3976. {
  3977. pResult.Result = false;
  3978. }
  3979. }
  3980.  
  3981. if ( g_kJewelOfHarmonySystem.IsStrengthenByJewelOfHarmony(&lpObj->pInventory[lpMsg->Ipos]) == TRUE )
  3982. {
  3983. pResult.Result = false;
  3984. GCServerMsgStringSend(lMsg.Get(MSGGET(13, 43)), lpObj->m_Index, 1);
  3985. }
  3986.  
  3987. if ( g_kJewelOfHarmonySystem.IsJewelOfHarmonyOriginal(lpObj->pInventory[lpMsg->Ipos].m_Type) ||
  3988. g_kJewelOfHarmonySystem.IsJewelOfHarmonyPurity(lpObj->pInventory[lpMsg->Ipos].m_Type) ||
  3989. g_kJewelOfHarmonySystem.IsJewelOfHarmonySmeltingItems(lpObj->pInventory[lpMsg->Ipos].m_Type) )
  3990. {
  3991. pResult.Result = false;
  3992. }
  3993.  
  3994. if ( lpObj->pInventory[lpMsg->Ipos].m_Type == ITEMGET(13,39) )
  3995. {
  3996. pResult.Result = false;
  3997. }
  3998.  
  3999. if ( IsCashItem(lpObj->pInventory[lpMsg->Ipos].m_Type) == TRUE )
  4000. {
  4001. pResult.Result = false;
  4002. }
  4003. /*
  4004. if( lpObj->pInventory[lpMsg->Ipos].m_QuestItem) //season 2.5 add-on // ALLOW DORP
  4005. {
  4006. return 0xFF;
  4007. }
  4008. */
  4009. if ( pResult.Result == 1 )
  4010. {
  4011. ::ItemIsBufExOption(NewOption, &lpObj->pInventory[lpMsg->Ipos]);
  4012.  
  4013. int map = lpObj->MapNumber;
  4014. int type = lpObj->pInventory[lpMsg->Ipos].m_Type;
  4015. int level = lpObj->pInventory[lpMsg->Ipos].m_Level;
  4016. float dur = lpObj->pInventory[lpMsg->Ipos].m_Durability;
  4017. BOOL bIsItem = lpObj->pInventory[lpMsg->Ipos].IsItem();
  4018. BYTE Option1 = lpObj->pInventory[lpMsg->Ipos].m_Option1;
  4019. BYTE Option2 = lpObj->pInventory[lpMsg->Ipos].m_Option2;
  4020. BYTE Option3 = lpObj->pInventory[lpMsg->Ipos].m_Option3;
  4021. BYTE NOption = lpObj->pInventory[lpMsg->Ipos].m_NewOption;
  4022. DWORD serial = lpObj->pInventory[lpMsg->Ipos].m_Number;
  4023. int PetLevel = lpObj->pInventory[lpMsg->Ipos].m_PetItem_Level;
  4024. int PetExp = lpObj->pInventory[lpMsg->Ipos].m_PetItem_Exp;
  4025. BYTE SOption = lpObj->pInventory[lpMsg->Ipos].m_SetOption;
  4026. BYTE btItemEffectEx = lpObj->pInventory[lpMsg->Ipos].m_ItemOptionEx;
  4027. int serial2 = lpObj->pInventory[lpMsg->Ipos].m_Number;
  4028. char szItemName[50] = "Item";
  4029. BYTE JOHOption = g_kJewelOfHarmonySystem.GetItemStrengthenOption(&lpObj->pInventory[lpMsg->Ipos]);
  4030. BYTE JOHOptionLevel = g_kJewelOfHarmonySystem.GetItemOptionLevel(&lpObj->pInventory[lpMsg->Ipos]);
  4031.  
  4032. if ( gObjCheckSerial0ItemList(&lpObj->pInventory[lpMsg->Ipos]) != FALSE )
  4033. {
  4034. MsgOutput(lpObj->m_Index, lMsg.Get(MSGGET(13, 26)));
  4035. LogAddTD("[ANTI-HACK][Serial 0 Item] [ItemDrop] (%s)(%s) Item(%s) Pos(%d)",
  4036. lpObj->AccountID, lpObj->Name, lpObj->pInventory[lpMsg->Ipos].GetName(),
  4037. lpMsg->Ipos);
  4038.  
  4039. CopyItem = TRUE;
  4040. pResult.Result = false;
  4041. bIsItem = FALSE;
  4042. }
  4043.  
  4044.  
  4045. if ( !::gObjInventorySearchSerialNumber(lpObj, serial2)) // ANTI DUPE SYSTEM
  4046. {
  4047. CopyItem = TRUE;
  4048. pResult.Result = false;
  4049. bIsItem = FALSE;
  4050. }
  4051.  
  4052. if ( bIsItem == TRUE )
  4053. {
  4054. strcpy(szItemName, lpObj->pInventory[lpMsg->Ipos].GetName());
  4055.  
  4056. if ( type == ITEMGET(14,11)) // Box of Luck until Kunduns
  4057. {
  4058. ::gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4059. pResult.Result = true;
  4060.  
  4061. if ( level == 1 )
  4062. {
  4063. ::StarOfXMasOpenEven(&gObj[aIndex]);
  4064. LogAddTD("[%s][%s][%d]%d/%d Used box of StarOfXMas Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4065. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4066. serial, szItemName, type, level, Option1, Option2, Option3);
  4067. }
  4068. else if ( level == 2 )
  4069. {
  4070. ::FireCrackerOpenEven(&gObj[aIndex]);
  4071. LogAddTD("[%s][%s][%d]%d/%d Used box of FireCracker Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4072. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4073. serial, szItemName, type, level, Option1, Option2, Option3);
  4074. }
  4075. else if ( level == 3 )
  4076. {
  4077. ::HeartOfLoveOpenEven(&gObj[aIndex]);
  4078. LogAddTD("[%s][%s][%d]%d/%d Used box of HeartOfLove Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4079. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4080. serial, szItemName, type, level, Option1, Option2, Option3);
  4081. }
  4082. else if ( level == 6 )
  4083. {
  4084. ::GoldMedalOpenEven(&gObj[aIndex]);
  4085. LogAddTD("[%s][%s][%d]%d/%d Used box of GoldMedal Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4086. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4087. serial, szItemName, type, level, Option1, Option2, Option3);
  4088. }
  4089. else if ( level == 5 )
  4090. {
  4091. ::SilverMedalOpenEven(&gObj[aIndex]);
  4092. LogAddTD("[%s][%s][%d]%d/%d Used box of SilverMedal Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4093. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4094. serial, szItemName, type, level, Option1, Option2, Option3);
  4095. }
  4096. else if ( level == 7 )
  4097. {
  4098. ::EventChipOpenEven(&gObj[aIndex]);
  4099. LogAddTD("[%s][%s][%d]%d/%d Used box of EventChip Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4100. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4101. serial, szItemName, type, level, Option1, Option2, Option3);
  4102. }
  4103. else if ( level == 8 )
  4104. {
  4105. ::EledoradoBoxOpenEven(&gObj[aIndex], level, 2, 50000);
  4106. LogAddTD("[%s][%s][%d]%d/%d Used box of ElradoraBox-8 Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4107. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4108. serial, szItemName, type, level, Option1, Option2, Option3);
  4109. }
  4110. else if ( level == 9 )
  4111. {
  4112. ::EledoradoBoxOpenEven(&gObj[aIndex], level, 2, 100000);
  4113. LogAddTD("[%s][%s][%d]%d/%d Used box of ElradoraBox-9 Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4114. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4115. serial, szItemName, type, level, Option1, Option2, Option3);
  4116. }
  4117. else if ( level == 10 )
  4118. {
  4119. ::EledoradoBoxOpenEven(&gObj[aIndex], level, 2, 150000);
  4120. LogAddTD("[%s][%s][%d]%d/%d Used box of ElradoraBox-10 Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4121. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4122. serial, szItemName, type, level, Option1, Option2, Option3);
  4123. }
  4124. else if ( level == 11 )
  4125. {
  4126. ::EledoradoBoxOpenEven(&gObj[aIndex], level, 1, 200000);
  4127. LogAddTD("[%s][%s][%d]%d/%d Used box of ElradoraBox1-11 Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4128. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4129. serial, szItemName, type, level, Option1, Option2, Option3);
  4130. }
  4131. else if ( level == 12 )
  4132. {
  4133. ::EledoradoBoxOpenEven(&gObj[aIndex], level, 0, 250000);
  4134. LogAddTD("[%s][%s][%d]%d/%d Used box of ElradoraBox1-12 Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4135. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4136. serial, szItemName, type, level, Option1, Option2, Option3);
  4137. }
  4138. else if ( level == 13 )
  4139. {
  4140. ::DarkLordHeartItemBoxOpen(&gObj[aIndex]);
  4141. LogAddTD("[%s][%s][%d]%d/%d Used box of DarkLordHeart Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4142. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4143. serial, szItemName, type, level, Option1, Option2, Option3);
  4144. }
  4145. else if ( level == 0 )
  4146. {
  4147. ::LuckyBoxOpenEven(&gObj[aIndex]);
  4148. LogAddTD(lMsg.Get(MSGGET(1, 222)), // [%s][%s][%d]%d/%d Used Box of Luck Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)
  4149. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4150. serial, szItemName, type, level, Option1, Option2, Option3);
  4151. }
  4152. else
  4153. {
  4154. pResult.Result = false;
  4155. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4156.  
  4157. return FALSE;
  4158. }
  4159.  
  4160. LogAddTD("[%s][%s] Used box of luck (level:%d)",
  4161. lpObj->AccountID, lpObj->Name, level);
  4162. }
  4163. else if ( type == ITEMGET(12,32) )
  4164. {
  4165. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4166. RedRibbonBoxOpen(&gObj[aIndex]);
  4167. LogAddTD("[%s][%s][%d]%d/%d Used Christmas RibbonBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4168. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4169. serial, szItemName, type, level, Option1, Option2, Option3);
  4170. }
  4171. else if ( type == ITEMGET(12,33) )
  4172. {
  4173. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4174. GreenRibbonBoxOpen(&gObj[aIndex]);
  4175. LogAddTD("[%s][%s][%d]%d/%d Used Christmas RibbonBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4176. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4177. serial, szItemName, type, level, Option1, Option2, Option3);
  4178. }
  4179. else if ( type == ITEMGET(12,34) )
  4180. {
  4181. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4182. BlueRibbonBoxOpen(&gObj[aIndex]);
  4183. LogAddTD("[%s][%s][%d]%d/%d Used Christmas RibbonBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4184. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4185. serial, szItemName, type, level, Option1, Option2, Option3);
  4186. }
  4187. else if ( type == ITEMGET(14,32) && level == 0 )
  4188. {
  4189. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4190. PinkChocolateBoxOpen(&gObj[aIndex]);
  4191. LogAddTD("[%s][%s][%d]%d/%d Used Valentine's Day ChocolateBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4192. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4193. serial, szItemName, type, level, Option1, Option2, Option3);
  4194.  
  4195. }
  4196. else if ( type == ITEMGET(14,33) && level == 0 )
  4197. {
  4198. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4199. RedChocolateBoxOpen(&gObj[aIndex]);
  4200. LogAddTD("[%s][%s][%d]%d/%d Used Valentine's Day ChocolateBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4201. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4202. serial, szItemName, type, level, Option1, Option2, Option3);
  4203.  
  4204. }
  4205. else if ( type == ITEMGET(14,34) && level == 0 )
  4206. {
  4207. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4208. BlueChocolateBoxOpen(&gObj[aIndex]);
  4209. LogAddTD("[%s][%s][%d]%d/%d Used Valentine's Day ChocolateBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4210. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4211. serial, szItemName, type, level, Option1, Option2, Option3);
  4212. }
  4213. else if ( type == ITEMGET(14,32) && level == 1 )
  4214. {
  4215. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4216. LightPurpleCandyBoxOpen(&gObj[aIndex]);
  4217. LogAddTD("[%s][%s][%d]%d/%d Used WhiteDay CandyBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4218. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4219. serial, szItemName, type, level, Option1, Option2, Option3);
  4220. }
  4221. else if ( type == ITEMGET(14,33) && level == 1 )
  4222. {
  4223. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4224. VermilionCandyBoxOpen(&gObj[aIndex]);
  4225. LogAddTD("[%s][%s][%d]%d/%d Used WhiteDay CandyBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4226. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4227. serial, szItemName, type, level, Option1, Option2, Option3);
  4228.  
  4229. }
  4230. else if ( type == ITEMGET(14,34) && level == 1 )
  4231. {
  4232. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4233. DeepBlueCandyBoxOpen(&gObj[aIndex]);
  4234. LogAddTD("[%s][%s][%d]%d/%d Used WhiteDay CandyBox Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4235. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4236. serial, szItemName, type, level, Option1, Option2, Option3);
  4237.  
  4238. }
  4239. else if ( type == ITEMGET(14,45) )
  4240. {
  4241. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4242. HallowinDayEventItemBoxOpen(lpObj);
  4243. LogAddTD("[%s][%s][%d]%d/%d Used Pumpkin of Luck Serial:%d (%s:%d/level:%d/skill:%d/op2:%d/op3:%d)",
  4244. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4245. serial, szItemName, type, level, Option1, Option2, Option3);
  4246. }
  4247. else if ( type == ITEMGET(14,63) )
  4248. {
  4249. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4250. FireworksOpenEven(&gObj[aIndex]);
  4251.  
  4252. LogAddTD("[%s][%s][Used Pounch Fireworks Effect] : (%d)(X:%d/Y:%d)",
  4253. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y);
  4254. }
  4255. else if (type == ITEMGET(14, 52)) //GM BOX
  4256. {
  4257. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4258. GMItemBoxOpen(lpObj);
  4259.  
  4260. LogAddTD("[%s][%s][Used GM Box] : (%d)(X:%d/Y:%d)",
  4261. lpObj->AccountID, lpObj->Name, lpObj->MapNumber, lpObj->X, lpObj->Y);
  4262. }
  4263.  
  4264.  
  4265. else if ( type == ITEMGET(12,26) )
  4266. {
  4267. switch ( level )
  4268. {
  4269. case 0:
  4270. {
  4271. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4272. pResult.Result = true;
  4273. int ltype = ITEMGET(12,26);
  4274. int randor = rand()%100;
  4275. int Level;
  4276.  
  4277. if ( randor < 10 )
  4278. {
  4279. Level = 3;
  4280. }
  4281. else if ( randor < 45 )
  4282. {
  4283. Level = 1;
  4284. }
  4285. else
  4286. {
  4287. Level = 2;
  4288. }
  4289.  
  4290. ItemSerialCreateSend(aIndex, lpObj->MapNumber, lpObj->X, lpObj->Y,
  4291. ltype, Level, 1, 0, 0, 0, lpObj->m_Index, 0, 0);
  4292.  
  4293. LogAddTD("[Hidden TreasureBox Event] [%s][%s] Throw Mysterious Bead : Drop (%d) - serial:%d",
  4294. lpObj->AccountID, lpObj->Name, Level, serial);
  4295. }
  4296. break;
  4297. case 1: case 2: case 3:
  4298. {
  4299. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4300. pResult.Result = true;
  4301.  
  4302. PMSG_SERVERCMD ServerCmd;
  4303.  
  4304. PHeadSubSetB((LPBYTE)&ServerCmd, 0xF3, 0x40, sizeof(ServerCmd));
  4305. ServerCmd.CmdType = 0;
  4306. ServerCmd.X = lpObj->X;
  4307. ServerCmd.Y = lpObj->Y;
  4308.  
  4309. MsgSendV2(lpObj, (LPBYTE)&ServerCmd, sizeof(ServerCmd));
  4310. DataSend(lpObj->m_Index, (LPBYTE)&ServerCmd, sizeof(ServerCmd));
  4311.  
  4312. LogAddTD("[Hidden TreasureBox Event] [%s][%s] Throw Crystal (%d) - serial:%d",
  4313. lpObj->AccountID, lpObj->Name, level, serial);
  4314. }
  4315. break;
  4316. case 4:
  4317. LogAddTD("[Hidden TreasureBox Event] [%s][%s] Throw Hidden Treasure Box - serial:%d",
  4318. lpObj->AccountID, lpObj->Name, serial);
  4319.  
  4320. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4321. pResult.Result = true;
  4322. HiddenTreasureBoxItemBoxOpen(&gObj[aIndex]);
  4323.  
  4324. break;
  4325. case 5:
  4326. LogAddTD("[Hidden TreasureBox Event] [%s][%s] Throw Surprise Treasure Box - serial:%d",
  4327. lpObj->AccountID, lpObj->Name, serial);
  4328. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4329. pResult.Result = true;
  4330.  
  4331. if ( (rand()%10000) < g_iHiddenTreasureBoxOfflineRate )
  4332. {
  4333. EGReqRegHTOfflineGift(lpObj->m_Index);
  4334. }
  4335. else
  4336. {
  4337. int money = 1000000;
  4338. MapC[lpObj->MapNumber].MoneyItemDrop(money, lpObj->X, lpObj->Y);
  4339.  
  4340. LogAddTD("[Hidden TreasureBox Event] [%s][%s] Event ZenDrop : %d : (%d)(%d/%d)",
  4341. lpObj->AccountID, lpObj->Name, money, lpObj->MapNumber, lpObj->X, lpObj->Y);
  4342. }
  4343. break;
  4344. }
  4345. }
  4346. else if ( type == ITEMGET(13,20) && level == 1 ) // Wizard Ring A
  4347. {
  4348. if ( gObj[aIndex].Level >= 40 )
  4349. {
  4350. ::gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4351. ::RingEventItemBoxOpen(&gObj[aIndex]);
  4352. }
  4353. else
  4354. {
  4355. PMSG_NOTICE pNotice;
  4356.  
  4357. TNotice::MakeNoticeMsg((TNotice *)&pNotice, 10, lMsg.Get(MSGGET(4, 187)));
  4358. TNotice::SetNoticeProperty((TNotice *)&pNotice, 10, _ARGB(255, 128, 149, 196), 1, 0, 20);
  4359. TNotice::SendNoticeToUser(aIndex, (TNotice *)&pNotice);
  4360. pResult.Result = false;
  4361. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4362.  
  4363. return FALSE;
  4364. }
  4365. }
  4366. else if ( type == ITEMGET(13,20) && level == 2 ) // Wizard Ring B
  4367. {
  4368. if ( gObj[aIndex].Level >= 80 )
  4369. {
  4370. ::gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4371. ::FriendShipItemBoxOpen(&gObj[aIndex]);
  4372. }
  4373. else
  4374. {
  4375. PMSG_NOTICE pNotice;
  4376.  
  4377. TNotice::MakeNoticeMsg((TNotice *)&pNotice, 10, lMsg.Get(MSGGET(4, 191)));
  4378. TNotice::SetNoticeProperty((TNotice *)&pNotice, 10, _ARGB(255, 128, 149, 196), 1, 0, 20);
  4379. TNotice::SendNoticeToUser(aIndex, (TNotice *)&pNotice);
  4380. pResult.Result = false;
  4381. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4382.  
  4383. return FALSE;
  4384. }
  4385. }
  4386. else if ( type == ITEMGET(14,28) ) // Lost Map
  4387. {
  4388. if ( g_KalimaGate.CreateKalimaGate(aIndex, level, lpMsg->px, lpMsg->py))
  4389. {
  4390. LogAddTD("[Kalima] [%s][%s] Success to Make Kalima Gate (Lost Kalima Map Serial:%d)",
  4391. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].pInventory[lpMsg->Ipos].m_Number);
  4392.  
  4393. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4394. }
  4395. else
  4396. {
  4397. pResult.Result = false;
  4398. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4399.  
  4400. return FALSE;
  4401. }
  4402. }
  4403. //Scorpion Event
  4404. #ifdef MONSTER_SCORPION_ATTACK
  4405. else if ( type == ITEMGET(14,89) ) ///Scorpion Mobility
  4406. {
  4407.  
  4408. if(g_ScorpAttack.ScorpionCreate == 1)
  4409. {
  4410. gObjTeleport(lpObj->m_Index, gObj[g_ScorpAttack.ScorpionCreateIndex].MapNumber, gObj[g_ScorpAttack.ScorpionCreateIndex].X, gObj[g_ScorpAttack.ScorpionCreateIndex].Y);
  4411. LogAddTD("[Scorpion] [%s][%s] Success to Move to Scorpion (Scorpion Mobility Serial:%d)",
  4412. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].pInventory[lpMsg->Ipos].m_Number);
  4413. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4414. }
  4415. else
  4416. {
  4417. pResult.Result = false;
  4418. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4419.  
  4420. return FALSE;
  4421. }
  4422. }
  4423. #endif
  4424. else if ( type == ITEMGET(14,20) && ( ((level-1<0)?FALSE:(level-1>4)?FALSE:TRUE) != FALSE ) ) // Remedy Of Love
  4425. {
  4426. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4427. Japan1StAnivBoxOpen(&gObj[aIndex], level);
  4428. }
  4429. else if ( type == ITEMGET(13,7) ) // Contract (Summon)
  4430. {
  4431. int iMonsterID = 0;
  4432.  
  4433. if ( level == 0 )
  4434. iMonsterID = 286;
  4435. else if ( level == 1 )
  4436. iMonsterID = 287;
  4437.  
  4438.  
  4439. if ( g_CsNPC_Mercenary.CreateMercenary(aIndex, iMonsterID, lpMsg->px, lpMsg->py) )
  4440. {
  4441. ::gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4442. }
  4443. else
  4444. {
  4445. pResult.Result = false;
  4446. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4447.  
  4448. return FALSE;
  4449. }
  4450. }
  4451. else if ( type == ITEMGET(13,11) ) // Guardian / LifeStone
  4452. {
  4453. BOOL bResult = FALSE;
  4454.  
  4455. if ( level == 0 )
  4456. bResult = g_CsNPC_Guardian.CreateGuardian(aIndex);
  4457. else if ( level == 1 )
  4458. bResult = g_CsNPC_LifeStone.CreateLifeStone(aIndex);
  4459. if ( bResult == TRUE )
  4460. ::gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4461. else
  4462. {
  4463. pResult.Result = false;
  4464. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4465.  
  4466. return FALSE;
  4467. }
  4468. }
  4469. else
  4470. {
  4471. int OwnerIndex = aIndex;
  4472.  
  4473. if ( (type >= ITEMGET(14,0) && type <= ITEMGET(14,10)) || (type == ITEMGET(4,7) ) || type ==ITEMGET(4,15) )
  4474. OwnerIndex = -1;
  4475.  
  4476. if ( MapC[map].ItemDrop( type, level, dur, lpMsg->px, lpMsg->py, Option1, Option2, Option3,
  4477. NOption, SOption, serial2, OwnerIndex, PetLevel, PetExp, btItemEffectEx) == TRUE )
  4478. {
  4479. gObjInventoryDeleteItem(aIndex, lpMsg->Ipos);
  4480. pResult.Result = true;
  4481.  
  4482. if ( drop_type == FALSE )
  4483. {
  4484. LogAddTD(lMsg.Get(MSGGET(1, 223)), lpObj->AccountID, lpObj->Name, lpObj->MapNumber,
  4485. lpObj->X, lpObj->Y, serial, szItemName, type, level, Option1, Option2,
  4486. Option3, (int)dur, NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4],
  4487. NewOption[5], NewOption[6], SOption, btItemEffectEx>>7, JOHOption, JOHOptionLevel);
  4488. }
  4489. else
  4490. {
  4491. LogAddTD(lMsg.Get(MSGGET(1, 224)), lpObj->AccountID, lpObj->Name, lpObj->MapNumber,
  4492. lpObj->X, lpObj->Y, serial, szItemName, type, level, Option1, Option2,
  4493. Option3, (int)dur, NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4],
  4494. NewOption[5], NewOption[6], SOption, btItemEffectEx, JOHOption, JOHOptionLevel );
  4495. }
  4496. }
  4497. else
  4498. {
  4499. pResult.Result = false;
  4500. }
  4501. }
  4502. }
  4503. else // bIsItem
  4504. {
  4505. LogAdd(lMsg.Get(MSGGET(1, 225)));
  4506. pResult.Result = false;
  4507. }
  4508. }
  4509.  
  4510. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  4511.  
  4512. if ( CopyItem != FALSE )
  4513. ::GCItemListSend(aIndex);
  4514.  
  4515. if ( pResult.Result == 1 )
  4516. {
  4517. if ( lpMsg->Ipos < 12 )
  4518. {
  4519. if ( lpMsg->Ipos == 10 || lpMsg->Ipos == 11 )
  4520. {
  4521. gObjUseSkill.SkillChangeUse(aIndex);
  4522. }
  4523.  
  4524.  
  4525. ::gObjMakePreviewCharSet(aIndex);
  4526.  
  4527. PMSG_USEREQUIPMENTCHANGED pChange;
  4528.  
  4529. PHeadSetB((LPBYTE)&pChange, 0x25, sizeof(pChange));
  4530. pChange.NumberH = SET_NUMBERH(aIndex);
  4531. pChange.NumberL = SET_NUMBERL(aIndex);
  4532. ItemByteConvert(pChange.ItemInfo, lpObj->pInventory[lpMsg->Ipos]);
  4533. pChange.ItemInfo[I_OPTION] = lpMsg->Ipos << 4;
  4534. pChange.ItemInfo[I_OPTION] |= LevelSmallConvert(aIndex, lpMsg->Ipos) & 0x0F;
  4535.  
  4536. DataSend(aIndex, (LPBYTE)&pChange, pChange.h.size);
  4537. MsgSendV2(lpObj, (LPBYTE)&pChange, pChange.h.size);
  4538. }
  4539. }
  4540.  
  4541. return pResult.Result;
  4542. }
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552. struct PMSG_INVENTORYITEMMOVE_RESULT
  4553. {
  4554. PBMSG_HEAD h; // C3:24
  4555. BYTE result; // 3
  4556. BYTE Pos; // 4
  4557. BYTE ItemInfo[MAX_ITEM_INFO]; // 5
  4558. };
  4559.  
  4560.  
  4561.  
  4562. void GCItemMoveResultSend(int aIndex, BYTE result, BYTE pos, LPBYTE const ItemInfo)
  4563. {
  4564. PMSG_INVENTORYITEMMOVE_RESULT pMsg;
  4565.  
  4566. pMsg.h.c = 0xC3;
  4567. pMsg.h.headcode = 0x24;
  4568. pMsg.h.size = sizeof(pMsg);
  4569. pMsg.result = result;
  4570. pMsg.Pos = pos;
  4571. pMsg.ItemInfo[I_TYPE] = ItemInfo[I_TYPE];
  4572. pMsg.ItemInfo[I_OPTION] = ItemInfo[I_OPTION];
  4573. pMsg.ItemInfo[I_DUR] = ItemInfo[I_DUR];
  4574. pMsg.ItemInfo[I_NOPTION] = ItemInfo[I_NOPTION];
  4575. pMsg.ItemInfo[I_SOPTION] = ItemInfo[I_SOPTION];
  4576. pMsg.ItemInfo[I_380OPTION] = ItemInfo[I_380OPTION];
  4577. pMsg.ItemInfo[I_JOHOPTION] = ItemInfo[I_JOHOPTION];
  4578.  
  4579. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  4580. }
  4581.  
  4582.  
  4583.  
  4584.  
  4585.  
  4586.  
  4587. void CGInventoryItemMove(PMSG_INVENTORYITEMMOVE * lpMsg, int aIndex) //00446250
  4588. {
  4589. BYTE result;
  4590. BYTE ItemInfo[MAX_ITEM_INFO];
  4591. if ( !PacketCheckTime(&gObj[aIndex]))
  4592. {
  4593. ::GCItemMoveResultSend(aIndex, -1, 0, ItemInfo);
  4594. return;
  4595. }
  4596.  
  4597. if ( !::gObjIsConnectedGP(aIndex))
  4598. {
  4599. LogAddC(2,"[%s][%d] error-L3", __FILE__, __LINE__);
  4600. ::GCItemMoveResultSend(aIndex, -1, 0, ItemInfo);
  4601. return;
  4602. }
  4603.  
  4604. LPOBJ lpObj = &gObj[aIndex];
  4605. int it_type = 0;
  4606.  
  4607. if ( lpObj->m_ReqWarehouseOpen != false )
  4608. {
  4609. LogAddC(2,"[%s][%d] error-L3", __FILE__, __LINE__);
  4610. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4611. return;
  4612. }
  4613.  
  4614. int source = lpMsg->source_item_num;
  4615. int target = lpMsg->target_item_num;
  4616.  
  4617. if ( lpMsg->tFlag == 2 || lpMsg->sFlag == 2 )
  4618. {
  4619. it_type = 6;
  4620. }
  4621.  
  4622. if ( lpMsg->tFlag == 0 && lpMsg->sFlag == 0 )
  4623. {
  4624. it_type = 8;
  4625. }
  4626.  
  4627. if ( (lpMsg->tFlag == 0 && lpMsg->sFlag == 4) || (lpMsg->tFlag == 4 && lpMsg->sFlag == 0) || (lpMsg->tFlag == 4 && lpMsg->sFlag == 4) )
  4628. {
  4629. it_type = 8;
  4630. }
  4631.  
  4632. if( (lpMsg->tFlag == lpMsg->sFlag) && (source == target)) //season 3.0 add-on (New-Antihack)
  4633. {
  4634. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4635. return;
  4636. }
  4637.  
  4638. if (::gObjCanItemTouch(lpObj, it_type) == FALSE)
  4639. {
  4640. if ( lpMsg->sItemInfo[0] == ITEMGET(4,7) || lpMsg->sItemInfo[0] == ITEMGET(4,15) )
  4641. {
  4642. if ( target >= 12 || source < 12 )
  4643. {
  4644. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4645. return;
  4646. }
  4647. }
  4648. else
  4649. {
  4650. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4651. return;
  4652. }
  4653. }
  4654.  
  4655. if ( lpObj->DieRegen != FALSE )
  4656. {
  4657. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4658. return;
  4659. }
  4660.  
  4661. ItemInfo[I_TYPE] = lpMsg->sItemInfo[I_TYPE];
  4662. ItemInfo[I_OPTION] = lpMsg->sItemInfo[I_OPTION];
  4663. ItemInfo[I_DUR] = lpMsg->sItemInfo[I_DUR];
  4664. ItemInfo[I_NOPTION] = lpMsg->sItemInfo[I_NOPTION];
  4665. ItemInfo[I_SOPTION] = lpMsg->sItemInfo[I_SOPTION];
  4666. ItemInfo[I_380OPTION] = lpMsg->sItemInfo[I_380OPTION];
  4667. ItemInfo[I_JOHOPTION] = lpMsg->sItemInfo[I_JOHOPTION];
  4668.  
  4669. //ItemInfo[7] = lpMsg->sItemInfo[7];
  4670. //ItemInfo[8] = lpMsg->sItemInfo[8];
  4671. //ItemInfo[9] = lpMsg->sItemInfo[9];
  4672. //ItemInfo[10] = lpMsg->sItemInfo[10];
  4673. //ItemInfo[11] = lpMsg->sItemInfo[11];
  4674.  
  4675.  
  4676. //ItemInfo[0] = lpMsg->sItemInfo[0];
  4677. //ItemInfo[1] = lpMsg->sItemInfo[1];
  4678. //ItemInfo[2] = lpMsg->sItemInfo[2];
  4679. //ItemInfo[3] = lpMsg->sItemInfo[3];
  4680. //ItemInfo[4] = lpMsg->sItemInfo[4];
  4681. //ItemInfo[5] = lpMsg->sItemInfo[5];
  4682. //ItemInfo[6] = lpMsg->sItemInfo[6];
  4683.  
  4684.  
  4685. if ( lpMsg->sFlag == 3 || lpMsg->tFlag == 3 )
  4686. {
  4687. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 7 )
  4688. {
  4689. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4690. LogAdd("[%s][%s] error-L1 : used not Chaosbox", gObj[aIndex].AccountID, gObj[aIndex].Name);
  4691.  
  4692. return;
  4693. }
  4694.  
  4695. if ( lpObj->ChaosLock == TRUE )
  4696. {
  4697. LogAddTD("[%s][%s] error-L3 : CBMixing", gObj[aIndex].AccountID, gObj[aIndex].Name);
  4698. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4699.  
  4700. return;
  4701. }
  4702. }
  4703.  
  4704. if ( lpMsg->sFlag == 5 || lpMsg->tFlag == 5 )
  4705. {
  4706. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 13 )
  4707. {
  4708. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4709. LogAdd("[%s][%s] error-L1 : used not DarkTrainerBox", gObj[aIndex].AccountID, gObj[aIndex].Name);
  4710.  
  4711. return;
  4712. }
  4713.  
  4714. if ( lpObj->ChaosLock == TRUE )
  4715. {
  4716. LogAddTD("[%s][%s] error-L3 : DarkTrainerBoxMixing", gObj[aIndex].AccountID, gObj[aIndex].Name);
  4717. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4718.  
  4719. return;
  4720. }
  4721. }
  4722.  
  4723. if ( lpMsg->sFlag == 6 || lpMsg->sFlag == 7 || lpMsg->sFlag == 8 ||
  4724. lpMsg->tFlag == 6 || lpMsg->tFlag == 7 || lpMsg->tFlag == 8 )
  4725. {
  4726. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type !=7 )
  4727. {
  4728. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4729. LogAdd("[%s][%s] error-L1 : used not ChaosBox",
  4730. gObj[aIndex].AccountID, gObj[aIndex].Name);
  4731.  
  4732. return;
  4733. }
  4734.  
  4735. if ( lpObj->ChaosLock == TRUE )
  4736. {
  4737. LogAddTD("[%s][%s] error-L3 : JewelOfHarmony Mixing",
  4738. gObj[aIndex].AccountID, gObj[aIndex].Name);
  4739. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4740.  
  4741. return;
  4742. }
  4743. }
  4744.  
  4745. if ( lpMsg->sFlag == 9 || lpMsg->tFlag == 9 )
  4746. {
  4747. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type !=7 )
  4748. {
  4749. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4750. LogAdd("[%s][%s] error-L1 : used not ChaosBox",
  4751. gObj[aIndex].AccountID, gObj[aIndex].Name);
  4752.  
  4753. return;
  4754. }
  4755.  
  4756. if ( lpObj->ChaosLock == TRUE )
  4757. {
  4758. LogAddTD("[%s][%s] error-L3 : JewelOfHarmony Mixing",
  4759. gObj[aIndex].AccountID, gObj[aIndex].Name);
  4760. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4761.  
  4762. return;
  4763. }
  4764. }
  4765.  
  4766.  
  4767. if ( lpMsg->sFlag == 2 || lpMsg->tFlag == 2 )
  4768. {
  4769. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 6 )
  4770. {
  4771. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4772. LogAdd("[%s][%s] error-L1 : used not Warehouse", gObj[aIndex].AccountID, gObj[aIndex].Name);
  4773.  
  4774. return;
  4775. }
  4776. }
  4777.  
  4778. if ( lpMsg->sFlag == 1 && lpMsg->tFlag == 0 )
  4779. {
  4780. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 1 )
  4781. {
  4782. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4783. LogAdd("[%s][%s] error-L1 : used not Trade", gObj[aIndex].AccountID, gObj[aIndex].Name);
  4784.  
  4785. return;
  4786. }
  4787. }
  4788.  
  4789. if ( lpMsg->sFlag == 2 && lpMsg->tFlag == 0 )
  4790. {
  4791. int money = ::GetWarehouseUsedHowMuch(lpObj->Level, lpObj->WarehousePW);
  4792.  
  4793. if ( (lpObj->Money - money ) < 1 && (lpObj->WarehouseMoney - money) < 1)
  4794. {
  4795. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4796. char szTemp[256];
  4797. wsprintf(szTemp, lMsg.Get(MSGGET(6, 69)), money);
  4798. ::GCServerMsgStringSend(szTemp, lpObj->m_Index, 1);
  4799.  
  4800. return;
  4801. }
  4802.  
  4803. if ( ::bCanWarehouseLock == TRUE )
  4804. {
  4805. if ( gObj[aIndex].WarehouseLock == 1 )
  4806. {
  4807. ::GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4808. ::GCServerMsgStringSend(lMsg.Get(MSGGET(6, 70)), lpObj->m_Index, 1);
  4809.  
  4810. return;
  4811. }
  4812. }
  4813. }
  4814.  
  4815. if( it_type != 8 )
  4816. {
  4817. //int type = (ItemInfo[0] + ((ItemInfo[3] & 0x80 )*2)) + ((ItemInfo[5] & 0xF0)<<5);
  4818. int type = (ItemInfo[I_TYPE] + ((ItemInfo[I_NOPTION] & 0x80) * 2)) + ((ItemInfo[I_380OPTION] & 0xF0) << 5);
  4819. LPITEM_ATTRIBUTE lpItemAttr = GetItemAttr(type);
  4820.  
  4821. if ( lpItemAttr == NULL )
  4822. {
  4823. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4824. return;
  4825. }
  4826.  
  4827. if ( lpItemAttr->QuestItem != false )
  4828. {
  4829. GCItemMoveResultSend(aIndex, -1, 0, (LPBYTE)&ItemInfo);
  4830. return;
  4831. }
  4832. }
  4833.  
  4834. if ( (lpMsg->sFlag == 0 && lpMsg->tFlag == 0) ||
  4835. (lpMsg->sFlag == 2 && lpMsg->tFlag == 0) ||
  4836. (lpMsg->sFlag == 0 && lpMsg->tFlag == 2) ||
  4837. (lpMsg->sFlag == 2 && lpMsg->tFlag == 2) ||
  4838. (lpMsg->sFlag == 0 && lpMsg->tFlag == 3) ||
  4839. (lpMsg->sFlag == 0 && lpMsg->tFlag == 5) ||
  4840. (lpMsg->sFlag == 0 && lpMsg->tFlag == 6) ||
  4841. (lpMsg->sFlag == 0 && lpMsg->tFlag == 7) ||
  4842. (lpMsg->sFlag == 0 && lpMsg->tFlag == 8) ||
  4843. (lpMsg->sFlag == 0 && lpMsg->tFlag == 9) ||
  4844. (lpMsg->sFlag == 9 && lpMsg->tFlag == 9) ||
  4845. (lpMsg->sFlag == 9 && lpMsg->tFlag == 0) ||
  4846. (lpMsg->sFlag == 0 && lpMsg->tFlag == 10) ||
  4847. (lpMsg->sFlag == 10 && lpMsg->tFlag == 10) ||
  4848. (lpMsg->sFlag == 10 && lpMsg->tFlag == 0) ||
  4849. (lpMsg->sFlag == 0 && lpMsg->tFlag == 4) ||
  4850. (lpMsg->sFlag == 4 && lpMsg->tFlag == 0) ||
  4851. (lpMsg->sFlag == 4 && lpMsg->tFlag == 4) ||
  4852. (lpMsg->sFlag == 5 && lpMsg->tFlag == 0) ||
  4853. (lpMsg->sFlag == 5 && lpMsg->tFlag == 5) ||
  4854. (lpMsg->sFlag == 6 && lpMsg->tFlag == 0) ||
  4855. (lpMsg->sFlag == 6 && lpMsg->tFlag == 6) ||
  4856. (lpMsg->sFlag == 7 && lpMsg->tFlag == 0) ||
  4857. (lpMsg->sFlag == 7 && lpMsg->tFlag == 7) ||
  4858. (lpMsg->sFlag == 8 && lpMsg->tFlag == 0) ||
  4859. (lpMsg->sFlag == 8 && lpMsg->tFlag == 8) ||
  4860. (lpMsg->sFlag == 3 && lpMsg->tFlag == 0) ||
  4861. (lpMsg->sFlag == 3 && lpMsg->tFlag == 3) )
  4862. {
  4863. BOOL DurSSend;
  4864. BOOL DurTSend;
  4865.  
  4866. result = gObjInventoryMoveItem(aIndex, source, target, DurSSend, DurTSend, lpMsg->sFlag, lpMsg->tFlag, (LPBYTE)&ItemInfo);
  4867. ::GCItemMoveResultSend(aIndex, result, target, (LPBYTE)&ItemInfo);
  4868.  
  4869. if ( DurSSend != FALSE )
  4870. ::GCItemDurSend(aIndex, source, lpObj->pInventory[source].m_Durability, FALSE);
  4871.  
  4872. if ( DurTSend != FALSE )
  4873. ::GCItemDurSend(aIndex, target, lpObj->pInventory[target].m_Durability, FALSE);
  4874.  
  4875. int loc77 = (lpMsg->sItemInfo[0] + ((lpMsg->sItemInfo[3] & 0x80 )*2)) + ((lpMsg->sItemInfo[5] & 0xF0)<<5);
  4876.  
  4877. if( loc77 == ITEMGET(14,29)) //season 2.5 add-on
  4878. {
  4879. if( lpObj->pInventory[target].m_Durability == 0.0f && (lpMsg->sFlag == FALSE) && (lpMsg->tFlag == FALSE))
  4880. {
  4881. GCInventoryItemDeleteSend(aIndex,target,0);
  4882. }
  4883. }
  4884.  
  4885. if ( result != 0xFF && lpMsg->sFlag == 2 && lpMsg->tFlag == 0)
  4886. {
  4887. int money = ::GetWarehouseUsedHowMuch(lpObj->Level, lpObj->WarehousePW);
  4888.  
  4889. if ( (lpObj->Money - money) > 0 )
  4890. {
  4891. int iZen = lpObj->Money;
  4892. lpObj->Money -= money;
  4893. GCMoneySend(lpObj->m_Index, lpObj->Money);
  4894.  
  4895. LogAdd("Pay WareHouse Money(In Inventory) : %d - %d = %d", iZen, money, lpObj->Money);
  4896. }
  4897. else if ( (lpObj->WarehouseMoney - money) > 0 )
  4898. {
  4899. int iZen = lpObj->WarehouseMoney;
  4900. lpObj->WarehouseMoney -= money;
  4901.  
  4902. LogAdd("Pay WareHouse Money(In WareHouse) : %d - %d = %d", iZen, money, lpObj->WarehouseMoney);
  4903.  
  4904. GCWarehouseInventoryMoneySend(aIndex, 1, lpObj->Money, lpObj->WarehouseMoney);
  4905. }
  4906. }
  4907. return;
  4908. }
  4909.  
  4910. if ( lpMsg->sFlag == 1 && lpMsg->tFlag == 1 )
  4911. {
  4912. result = gObjTradeTradeMove(lpObj, source, target);
  4913. GCItemMoveResultSend(aIndex, result, target, (LPBYTE)&ItemInfo);
  4914. return;
  4915. }
  4916.  
  4917. if ( lpMsg->sFlag == 1 && lpMsg->tFlag == 0 )
  4918. {
  4919. result = gObjTradeInventoryMove(lpObj, source, target);
  4920.  
  4921. if ( result == 0xFF )
  4922. {
  4923. GCItemMoveResultSend(aIndex, 0xFF, target, (LPBYTE)&ItemInfo);
  4924. CGTradeCancelButtonRecv(aIndex);
  4925. }
  4926. else
  4927. {
  4928. GCItemMoveResultSend(aIndex, result, target, (LPBYTE)&ItemInfo);
  4929. }
  4930.  
  4931. if ( result == 0xFF )
  4932. {
  4933. lpObj->m_IfState.state = 0;
  4934. GCItemListSend(aIndex);
  4935. }
  4936.  
  4937. if ( lpObj->TargetNumber >= 0 )
  4938. {
  4939. lpObj->TradeOk = false;
  4940. gObj[gObj[aIndex].TargetNumber].TradeOk = false;
  4941. GCTradeOkButtonSend(lpObj->TargetNumber, 2);
  4942. GCTradeOkButtonSend(aIndex, 0);
  4943. }
  4944. return;
  4945. }
  4946.  
  4947. if ( lpMsg->sFlag == 0 && lpMsg->tFlag == 1 )
  4948. {
  4949. result = gObjInventoryTradeMove(lpObj, source, target);
  4950. GCItemMoveResultSend(aIndex, result, target, (LPBYTE)&ItemInfo);
  4951. }
  4952. }
  4953.  
  4954.  
  4955.  
  4956.  
  4957. void GCEquipmentChange(int aIndex, int pos)
  4958. {
  4959. PMSG_USEREQUIPMENTCHANGED pChange;
  4960. LPOBJ lpObj = &gObj[aIndex];
  4961.  
  4962. PHeadSetB((LPBYTE)&pChange, 0x25, sizeof(PMSG_USEREQUIPMENTCHANGED));
  4963. pChange.NumberH = SET_NUMBERH(aIndex);
  4964. pChange.NumberL = SET_NUMBERL(aIndex);
  4965. ItemByteConvert(pChange.ItemInfo, lpObj->pInventory[pos]);
  4966. pChange.ItemInfo[I_OPTION] = pos << 4;
  4967. pChange.ItemInfo[I_OPTION] |= LevelSmallConvert(aIndex, pos) & MAX_ITEM_LEVEL;
  4968.  
  4969. MsgSendV2(lpObj, (LPBYTE)&pChange, pChange.h.size);
  4970. }
  4971.  
  4972.  
  4973.  
  4974.  
  4975. struct PMSG_SHOPITEMCOUNT
  4976. {
  4977. PWMSG_HEAD h; // C2:31
  4978. BYTE Type; // 4
  4979. BYTE count; // 5
  4980. };
  4981.  
  4982.  
  4983. void CGTalkRequestRecv(PMSG_TALKREQUEST * lpMsg, int aIndex)
  4984. {
  4985. LPOBJ lpObj = &gObj[aIndex];
  4986. int DealerNumber ;
  4987. PMSG_TALKRESULT pResult;
  4988. PMSG_SHOPITEMCOUNT pShopItemCount;
  4989.  
  4990. if ( !PacketCheckTime(lpObj))
  4991. {
  4992. return;
  4993. }
  4994.  
  4995. if ( gObj[aIndex].CloseType != -1 )
  4996. {
  4997. return;
  4998. }
  4999.  
  5000. if ( !gObjIsConnectedGP(aIndex) )
  5001. {
  5002. LogAddTD("[ANTI-HACK][NPC Talk] Couldn't talk.. (%s)(%s)", gObj[aIndex].AccountID, gObj[aIndex].Name);
  5003. return;
  5004. }
  5005.  
  5006. BYTE SendByte[1024];
  5007. int lOfs = 0;
  5008.  
  5009. if ( lpObj->m_IfState.use > 0 )
  5010. {
  5011. return;
  5012. }
  5013.  
  5014. DealerNumber = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  5015.  
  5016. if ( DealerNumber < 0 || DealerNumber > OBJMAX-1)
  5017. {
  5018. return;
  5019. }
  5020.  
  5021. if ( lpObj->MapNumber != gObj[DealerNumber].MapNumber )
  5022. {
  5023. return;
  5024. }
  5025.  
  5026. //#TODO ןנמגונטע ףסכמגטו
  5027. if ( gObj[DealerNumber].Class == 367 )
  5028. {
  5029. if ( (lpObj->X < (gObj[DealerNumber].X-5) )|| (lpObj->X> (gObj[DealerNumber].X+5) )||(lpObj->Y < (gObj[DealerNumber].Y-10)) ||(lpObj->Y > (gObj[DealerNumber].Y+5)))
  5030. {
  5031. return;
  5032. }
  5033. }
  5034. //
  5035. else if ( (lpObj->X < (gObj[DealerNumber].X-5) )|| (lpObj->X> (gObj[DealerNumber].X+5) )||(lpObj->Y < (gObj[DealerNumber].Y-5)) ||(lpObj->Y > (gObj[DealerNumber].Y+5)))
  5036. {
  5037. return;
  5038. }
  5039. if ( (lpObj->X < (gObj[DealerNumber].X-5) )|| (lpObj->X> (gObj[DealerNumber].X+5) )||(lpObj->Y < (gObj[DealerNumber].Y-5)) ||(lpObj->Y > (gObj[DealerNumber].Y+5)))
  5040. {
  5041. return;
  5042. }
  5043. //
  5044. int ShopNum = gObj[DealerNumber].ShopNumber;
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050. if ( gObj[DealerNumber].Type == OBJ_NPC )
  5051. {
  5052. if ( NpcTalk(&gObj[DealerNumber], lpObj) == TRUE )
  5053. {
  5054. return;
  5055. }
  5056. }
  5057.  
  5058. if ( ::gObjFixInventoryPointer(aIndex) == false )
  5059. {
  5060. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  5061. }
  5062.  
  5063. if ( gObj[DealerNumber].Class == 234 )
  5064. {
  5065. pResult.h.c = 0xC3;
  5066. pResult.h.headcode = 0x30;
  5067. pResult.h.size = sizeof(pResult);
  5068. pResult.result = 0;
  5069. pResult.result = 5;
  5070.  
  5071. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5072. return;
  5073. }
  5074.  
  5075. if ( gObj[DealerNumber].Type == OBJ_NPC && ShopNum < 0)
  5076. {
  5077. return;
  5078. }
  5079.  
  5080. if ( ShopNum < MAX_SHOP )
  5081. {
  5082. if ( ShopC[ShopNum].ItemCount < TRUE )
  5083. {
  5084. if ( (rand()%2) != 0 )
  5085. ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 119)), aIndex);
  5086. else
  5087. ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 120)), aIndex);
  5088.  
  5089. return;
  5090. }
  5091.  
  5092. if ( gPkLimitFree == FALSE )
  5093. {
  5094. if ( lpObj->m_PK_Level > 4 )
  5095. {
  5096. if ( (rand()%2) != 0 )
  5097. ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 121)), aIndex);
  5098. else
  5099. ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 122)), aIndex);
  5100.  
  5101. return;
  5102. }
  5103. }
  5104. }
  5105. if ( gMerryXMasNpcEvent == TRUE )
  5106. {
  5107. if ( (rand()%6) == 0 )
  5108. {
  5109. ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 123)), aIndex);
  5110. }
  5111. }
  5112.  
  5113. if ( ::gHappyNewYearNpcEvent == TRUE )
  5114. {
  5115. if ( (rand()%6) == 0 )
  5116. {
  5117. ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 124)), aIndex);
  5118. }
  5119. }
  5120.  
  5121. lpObj->TargetShopNumber = ShopNum;
  5122. lpObj->m_IfState.use = 1;
  5123. lpObj->m_IfState.type = 3;
  5124. lpObj->m_ShopTime = 0;
  5125. pResult.h.c = 0xC3;
  5126. pResult.h.headcode = 0x30;
  5127. pResult.h.size = sizeof(pResult);
  5128. pResult.result = 0;
  5129. /////////////Archer
  5130. if (ShopNum == 14)
  5131. {
  5132.  
  5133.  
  5134. if(lpObj->EventChipCount >= GoldenArcherRn)
  5135. {
  5136.  
  5137.  
  5138. }
  5139. else
  5140. {
  5141. PMSG_ARCHER_INFO_STAT_RENAS pMsg;
  5142. PHeadSubSetB((LPBYTE)&pMsg, 0xF9, 0x02, sizeof(PMSG_ARCHER_INFO_STAT_RENAS));
  5143. pMsg.Result = 1;
  5144. DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
  5145. LogAddTD("[GoldenArcher] EventChipCount [%d]", lpObj->EventChipCount);
  5146. return;
  5147.  
  5148.  
  5149. }
  5150.  
  5151. }
  5152. //////////
  5153. if ( ShopNum == 100 )
  5154. {
  5155. #ifdef MULTI_WAREHOUSE
  5156.  
  5157. #else
  5158. if ( gObj[aIndex].m_ReqWarehouseOpen != false )
  5159. return;
  5160.  
  5161. gObj[aIndex].m_ReqWarehouseOpen = true;
  5162. lpObj->m_IfState.type = 6;
  5163. lpObj->m_IfState.state = 0;
  5164. #endif
  5165.  
  5166. }
  5167.  
  5168. else if ( ShopNum == 101 )
  5169. {
  5170. if ( bCanChaosBox == TRUE )
  5171. {
  5172. if ( lpObj->m_bPShopOpen == true )
  5173. {
  5174. LogAdd("[%s][%s] is Already Opening PShop, ChaosBox Failed", lpObj->AccountID, lpObj->Name);
  5175. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 194)), lpObj->m_Index, 1);
  5176. return;
  5177. }
  5178.  
  5179. lpObj->m_IfState.type = 7;
  5180. lpObj->m_IfState.state = 0;
  5181. pResult.result = 3;
  5182.  
  5183.  
  5184.  
  5185. lpObj->bIsChaosMixCompleted = false;
  5186.  
  5187. pResult.level1 = gDQChaosSuccessRateLevel1;
  5188. pResult.level2 = gDQChaosSuccessRateLevel2;
  5189. pResult.level3 = gDQChaosSuccessRateLevel3;
  5190. pResult.level4 = gDQChaosSuccessRateLevel4;
  5191. pResult.level5 = gDQChaosSuccessRateLevel5;
  5192. pResult.level6 = gDQChaosSuccessRateLevel6;
  5193.  
  5194.  
  5195. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5196. gObjInventoryTrans(lpObj->m_Index);
  5197.  
  5198. LogAddTD("[%s][%s] Open Chaos Box", lpObj->AccountID, lpObj->Name);
  5199. gObjItemTextSave(lpObj);
  5200. gObjWarehouseTextSave(lpObj);
  5201. GCAnsCsMapSvrTaxInfo( lpObj->m_Index, 1, ::g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index));
  5202. }
  5203. }
  5204. else
  5205. {
  5206.  
  5207.  
  5208. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5209. }
  5210.  
  5211. if ( ShopNum == 100 )
  5212. {
  5213. #ifdef MULTI_WAREHOUSE
  5214. LogAddTD("[%s][%s] Open Chaos Boxaaa", lpObj->AccountID, lpObj->Name);
  5215. OpenMultiWarehouse(aIndex);
  5216. #else
  5217. gObj[aIndex].WarehouseCount = 0;
  5218. GDGetWarehouseList(aIndex, gObj[aIndex].AccountID);
  5219. #endif
  5220. //ADDHERE
  5221. return;
  5222. }
  5223.  
  5224. if ( ShopNum == 101 )
  5225. {
  5226. return;
  5227. }
  5228. else
  5229. {
  5230. lOfs = 0;
  5231.  
  5232. lOfs += sizeof(pShopItemCount );
  5233.  
  5234. int size = lOfs + ShopC[ShopNum].SendItemDataLen;
  5235. PHeadSetW((LPBYTE)&pShopItemCount, 0x31, size);
  5236. pShopItemCount.Type = 0;
  5237. pShopItemCount.count = ShopC[ShopNum].ItemCount;
  5238. memcpy(SendByte, &pShopItemCount, sizeof(pShopItemCount));
  5239. memcpy(&SendByte[lOfs], ShopC[ShopNum].SendItemData, ShopC[ShopNum].SendItemDataLen);
  5240.  
  5241. DataSend(aIndex, SendByte, size);
  5242. GCAnsCsMapSvrTaxInfo(lpObj->m_Index,2, ::g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index));
  5243. }
  5244. ///////////////////Archer/////////////////////
  5245. if (ShopNum == 14)
  5246. {
  5247. PMSG_ARCHER_INFO_STAT_RENAS pMsg;
  5248. PHeadSubSetB((LPBYTE)&pMsg, 0xF9,0x02, sizeof(PMSG_ARCHER_INFO_STAT_RENAS));
  5249. pMsg.Result = 2;
  5250. pMsg.NeedRenas = GoldenArcherRn;
  5251. DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
  5252. }
  5253. ////////////////////////////////////////////////
  5254. }
  5255.  
  5256. void GCUserWarehouseSend(LPOBJ lpObj)
  5257. {
  5258. if ( lpObj->m_IfState.type != 6 )
  5259. return;
  5260.  
  5261. if ( lpObj->m_IfState.type == 6 && lpObj->m_IfState.state == 1 )
  5262. return;
  5263.  
  5264. PMSG_SHOPITEMCOUNT pMsg;
  5265. BYTE SendByte[2048];
  5266. int lOfs = sizeof(pMsg);
  5267.  
  5268. PHeadSetW((LPBYTE)&pMsg, 0x31, 0);
  5269. pMsg.count = 0;
  5270. pMsg.Type = 0;
  5271.  
  5272. for ( int n=0;n<WAREHOUSE_SIZE;n++)
  5273. {
  5274. if ( lpObj->pWarehouse[n].IsItem() == TRUE )
  5275. {
  5276. SendByte[lOfs] = n;
  5277. lOfs++;
  5278. ItemByteConvert(&SendByte[lOfs], lpObj->pWarehouse[n] );
  5279. lOfs += MAX_ITEM_INFO;
  5280. pMsg.count ++;
  5281. }
  5282. }
  5283.  
  5284. pMsg.h.sizeH = SET_NUMBERH(lOfs);
  5285. pMsg.h.sizeL = SET_NUMBERL(lOfs);
  5286. memcpy(SendByte, &pMsg, sizeof(pMsg));
  5287.  
  5288. DataSend(lpObj->m_Index, SendByte, lOfs);
  5289. GCWarehouseInventoryMoneySend(lpObj->m_Index, 1, lpObj->Money, lpObj->WarehouseMoney);
  5290.  
  5291. if ( lpObj->m_IfState.type == 6 )
  5292. {
  5293. lpObj->m_IfState.state = 1;
  5294. lpObj->WarehouseSave = TRUE;
  5295. }
  5296. }
  5297.  
  5298.  
  5299.  
  5300.  
  5301. struct PMSG_BUYRESULT
  5302. {
  5303. PBMSG_HEAD h; // C1:32
  5304. BYTE Result; // 3
  5305. BYTE ItemInfo[MAX_ITEM_INFO]; // 4
  5306. };
  5307.  
  5308.  
  5309.  
  5310. void CGBuyRequestRecv(PMSG_BUYREQUEST * lpMsg, int aIndex)
  5311. {
  5312. LPOBJ lpObj = &gObj[aIndex];
  5313. PMSG_BUYRESULT pResult;
  5314.  
  5315. PHeadSetB((LPBYTE)&pResult, 0x32, sizeof(pResult));
  5316. pResult.Result = -1;
  5317.  
  5318.  
  5319. if ( !PacketCheckTime(lpObj))
  5320. {
  5321. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5322. return;
  5323. }
  5324.  
  5325. if ( gObj[aIndex].CloseType != -1 )
  5326. {
  5327. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5328. return;
  5329. }
  5330.  
  5331. if ( !::gObjFixInventoryPointer(aIndex))
  5332. {
  5333. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  5334. }
  5335.  
  5336. if ( gObj[aIndex].m_ShopTime == 0 )
  5337. gObj[aIndex].m_ShopTime = 1;
  5338.  
  5339. if ( gObj[aIndex].m_ShopTime > 60 )
  5340. {
  5341. if ( lpObj->m_IfState.use != 0 && lpObj->m_IfState.type == 3 )
  5342. {
  5343. lpObj->TargetShopNumber = -1;
  5344. lpObj->m_IfState.use = 0;
  5345. lpObj->m_IfState.type = 0;
  5346. }
  5347.  
  5348. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5349. return;
  5350. }
  5351.  
  5352. if ( lpObj->m_IfState.use > 0 )
  5353. {
  5354. if ( lpObj->m_IfState.type != 3 )
  5355. {
  5356. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5357. return;
  5358. }
  5359. }
  5360.  
  5361. int tShop = lpObj->TargetShopNumber;
  5362.  
  5363. if ( tShop < 0 || tShop > MAX_SHOP-1 )
  5364. {
  5365. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5366. return;
  5367. }
  5368.  
  5369. if ( lpMsg->Pos > MAX_ITEM_IN_SHOP-1 )
  5370. {
  5371. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5372. return;
  5373. }
  5374.  
  5375.  
  5376.  
  5377. ///////////////////////////////////////////////////////////////////
  5378. /////////////////////////////Archer////////////////////////////////
  5379. ///////////////////////////////////////////////////////////////////
  5380. if (tShop == 14)
  5381. {
  5382.  
  5383. LogAddTD("[GoldenArcher] EventChipCount [%d]",lpObj->EventChipCount);
  5384. int iStoreTaxRenas = GoldenArcherRn;
  5385. if ( iStoreTaxRenas < 1 )
  5386. iStoreTaxRenas = 1;
  5387.  
  5388. if (lpObj->EventChipCount >= iStoreTaxRenas)
  5389. {
  5390.  
  5391. BOOL bNoItem = TRUE;
  5392.  
  5393. if ((ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14, 0) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14, 8)) ||
  5394. (ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14, 35) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14, 40)))
  5395. {
  5396. int dur = ShopC[tShop].m_item[lpMsg->Pos].m_Durability;
  5397.  
  5398. if (dur == 0)
  5399. dur = 1;
  5400.  
  5401. if (::gObjSearchItem(&gObj[aIndex], ShopC[tShop].m_item[lpMsg->Pos].m_Type, dur, ShopC[tShop].m_item[lpMsg->Pos].m_Level) == TRUE)
  5402. {
  5403. bNoItem = FALSE;
  5404.  
  5405. if (lpObj->Money < 0)
  5406. lpObj->Money = 0;
  5407.  
  5408.  
  5409. ::GCMoneySend(aIndex, lpObj->Money);
  5410. }
  5411. }
  5412.  
  5413. if (bNoItem != FALSE)
  5414. {
  5415. pResult.Result = gObjShopBuyInventoryInsertItem(aIndex, ShopC[tShop].m_item[lpMsg->Pos]);
  5416.  
  5417. if (pResult.Result != 0xFF)
  5418. {
  5419. ItemByteConvert((LPBYTE)&pResult.ItemInfo, ShopC[tShop].m_item[lpMsg->Pos]);
  5420.  
  5421.  
  5422. if (lpObj->Money < 0)
  5423. lpObj->Money = 0;
  5424.  
  5425. lpObj->EventChipCount -= GoldenArcherRn;
  5426. GCMoneySend(aIndex, lpObj->Money);
  5427. GDSetRena(lpObj->m_Index);
  5428. //SQL.UpdateRenasPlayer(lpObj->AccountID, lpObj->EventChipCount);
  5429. LogAddTD("[GoldenArcher] [%s][%s] (%d) Shop buy [%s] LEV:%d, DUR:%d, OP:[%d][%d][%d]",
  5430. lpObj->AccountID, lpObj->Name, tShop, ShopC[tShop].m_item[lpMsg->Pos].GetName(),
  5431. ShopC[tShop].m_item[lpMsg->Pos].m_Level, ShopC[tShop].m_item[lpMsg->Pos].m_Durability,
  5432. ShopC[tShop].m_item[lpMsg->Pos].m_Option1, ShopC[tShop].m_item[lpMsg->Pos].m_Option2,
  5433. ShopC[tShop].m_item[lpMsg->Pos].m_Option3);
  5434.  
  5435.  
  5436. PMSG_ARCHER_INFO_LEFT_RENAS pMsg;
  5437. PHeadSubSetB((LPBYTE)&pMsg, 0xF9, 0x01, sizeof(PMSG_ARCHER_INFO_LEFT_RENAS));
  5438. pMsg.LeftRenas = lpObj->EventChipCount;
  5439. DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size);
  5440.  
  5441. int x = lpObj->X;
  5442. int y = lpObj->Y;
  5443. PMSG_SERVERCMD pMsgs;
  5444. PHeadSubSetB((LPBYTE)&pMsgs, 0xF3, 0x40, sizeof(pMsgs));
  5445. pMsgs.CmdType = 0;
  5446. pMsgs.X = x - 1;
  5447. pMsgs.Y = y - 1;
  5448. MsgSendV2(lpObj, (UCHAR*)&pMsgs, sizeof(pMsgs));
  5449. DataSend(lpObj->m_Index, (UCHAR*)&pMsgs, sizeof(pMsgs));
  5450. }
  5451. }
  5452.  
  5453.  
  5454. }
  5455. else
  5456. {
  5457. pResult.Result = -1;
  5458. }
  5459.  
  5460.  
  5461. }
  5462.  
  5463. else if(tShop == 15)
  5464. {
  5465. //if(ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14,84) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14,88))
  5466. //{
  5467. #ifdef MOSS_THE_MERCHANT
  5468. Moss.SellItem(aIndex,lpMsg);
  5469. #endif
  5470. //}
  5471. }
  5472.  
  5473.  
  5474.  
  5475. ////////////////////////
  5476. else
  5477. {
  5478. if( ShopC[tShop].m_item[lpMsg->Pos].m_Type == ITEMGET(13, 4) || ShopC[tShop].m_item[lpMsg->Pos].m_Type == ITEMGET(13, 5) )
  5479. {
  5480. PetItemSerialCreateSend(aIndex, 236, 0, 0, ShopC[tShop].m_item[lpMsg->Pos].m_Type,
  5481. ShopC[tShop].m_item[lpMsg->Pos].m_Level, ShopC[tShop].m_item[lpMsg->Pos].m_Durability,
  5482. ShopC[tShop].m_item[lpMsg->Pos].m_Option1, ShopC[tShop].m_item[lpMsg->Pos].m_Option2,
  5483. ShopC[tShop].m_item[lpMsg->Pos].m_Option3, -1, ShopC[tShop].m_item[lpMsg->Pos].m_NewOption,
  5484. ShopC[tShop].m_item[lpMsg->Pos].m_SetOption);
  5485. int lc64 = ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney;
  5486. lpObj->Money -= 500; //FIX
  5487. ::g_CastleSiegeSync.AddTributeMoney(600); // FIX
  5488. if( lpObj->Money < 0 )
  5489. {
  5490. lpObj->Money = 0;
  5491. }
  5492. GCMoneySend(aIndex, lpObj->Money);
  5493. int iTaxRate = g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index);
  5494. LogAddTD("[%s][%s] (%d) Shop buy [%d][%d][%d][%s] LEV:%d, DUR:%d, OP:[%d][%d][%d]", lpObj->AccountID, lpObj->Name, tShop, lc64, iTaxRate, lc64+600, ShopC[tShop].m_item[lpMsg->Pos].GetName(), ShopC[tShop].m_item[lpMsg->Pos].m_Level, ShopC[tShop].m_item[lpMsg->Pos].m_Durability, ShopC[tShop].m_item[lpMsg->Pos].m_Option1, ShopC[tShop].m_item[lpMsg->Pos].m_Option2, ShopC[tShop].m_item[lpMsg->Pos].m_Option3);
  5495. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5496. return;
  5497. }
  5498. if ( ShopC[tShop].m_item[lpMsg->Pos].IsItem() == TRUE )
  5499. {
  5500. int iStoreTaxMoney;
  5501. int iStoreTaxMoney2;
  5502. #ifdef CUSTOM_COINZEN
  5503. if (ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14,102) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14,104))
  5504. {
  5505. iStoreTaxMoney = ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney;
  5506. iStoreTaxMoney2 = ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney;
  5507. }
  5508. else
  5509. {
  5510. iStoreTaxMoney = ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney + (int)((__int64)ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);
  5511. iStoreTaxMoney2 = (int)((__int64)ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);
  5512. }
  5513. #else
  5514. iStoreTaxMoney = ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney + (int)((__int64)ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);
  5515. iStoreTaxMoney2 = (int)((__int64)ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);
  5516. #endif
  5517. if ( iStoreTaxMoney < 0 )
  5518. iStoreTaxMoney = 0;
  5519.  
  5520. #ifdef CUSTOM_COINZEN
  5521. // if (ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14,102) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14,104))
  5522. // {
  5523. // //iStoreTaxMoney = 0;
  5524. // iStoreTaxMoney2 = 0;
  5525. // }
  5526. #endif
  5527. if ( iStoreTaxMoney2 < 0 )
  5528. iStoreTaxMoney2 = 0;
  5529.  
  5530. if ( lpObj->Money < iStoreTaxMoney )
  5531. pResult.Result = -1;
  5532. else
  5533. {
  5534. BOOL bNoItem = TRUE;
  5535.  
  5536. if ( (ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14,0) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14,8)) ||
  5537. (ShopC[tShop].m_item[lpMsg->Pos].m_Type >= ITEMGET(14,35) && ShopC[tShop].m_item[lpMsg->Pos].m_Type <= ITEMGET(14,40)))
  5538. {
  5539. int dur = ShopC[tShop].m_item[lpMsg->Pos].m_Durability;
  5540.  
  5541. if ( dur == 0 )
  5542. dur = 1;
  5543.  
  5544. if ( ::gObjSearchItem(&gObj[aIndex], ShopC[tShop].m_item[lpMsg->Pos].m_Type,dur, ShopC[tShop].m_item[lpMsg->Pos].m_Level) == TRUE )
  5545. {
  5546. bNoItem = FALSE;
  5547.  
  5548.  
  5549. lpObj->Money -= iStoreTaxMoney;
  5550.  
  5551. ::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);
  5552.  
  5553. if ( lpObj->Money < 0 )
  5554. lpObj->Money = 0;
  5555.  
  5556.  
  5557. ::GCMoneySend(aIndex, lpObj->Money);
  5558. }
  5559. }
  5560.  
  5561. if ( bNoItem != FALSE )
  5562. {
  5563. pResult.Result = gObjShopBuyInventoryInsertItem(aIndex, ShopC[tShop].m_item[lpMsg->Pos]);
  5564.  
  5565. if ( pResult.Result != 0xFF )
  5566. {
  5567. ItemByteConvert((LPBYTE)&pResult.ItemInfo, ShopC[tShop].m_item[lpMsg->Pos]);
  5568. int lc64 = ShopC[tShop].m_item[lpMsg->Pos].m_BuyMoney;
  5569.  
  5570. lpObj->Money -= iStoreTaxMoney;
  5571.  
  5572. ::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);
  5573.  
  5574. if ( lpObj->Money < 0 )
  5575. lpObj->Money = 0;
  5576.  
  5577. GCMoneySend(aIndex, lpObj->Money);
  5578. int iTaxRate = g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index);
  5579.  
  5580. LogAddTD("[%s][%s] (%d) Shop buy [%d][%d][%d][%s] LEV:%d, DUR:%d, OP:[%d][%d][%d]",
  5581. lpObj->AccountID, lpObj->Name, tShop, lc64, iTaxRate, lc64+iStoreTaxMoney2, ShopC[tShop].m_item[lpMsg->Pos].GetName(),
  5582. ShopC[tShop].m_item[lpMsg->Pos].m_Level, ShopC[tShop].m_item[lpMsg->Pos].m_Durability,
  5583. ShopC[tShop].m_item[lpMsg->Pos].m_Option1, ShopC[tShop].m_item[lpMsg->Pos].m_Option2,
  5584. ShopC[tShop].m_item[lpMsg->Pos].m_Option3);
  5585.  
  5586.  
  5587. }
  5588. }
  5589. }
  5590. }
  5591. }
  5592. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5593. }
  5594.  
  5595.  
  5596.  
  5597.  
  5598. struct PMSG_SELLRESULT
  5599. {
  5600. PBMSG_HEAD h; // C1:33
  5601. BYTE Result; // 3
  5602. DWORD Money; // 4
  5603. };
  5604.  
  5605.  
  5606.  
  5607.  
  5608. void CGSellRequestRecv(PMSG_SELLREQUEST * lpMsg, int aIndex)
  5609. {
  5610. PMSG_SELLRESULT pResult;
  5611. LPOBJ lpObj = &gObj[aIndex];
  5612.  
  5613. PHeadSetB((LPBYTE)&pResult, 0x33, sizeof(pResult));
  5614. pResult.Result = false;
  5615. pResult.Money = 0;
  5616.  
  5617. if ( gObj[aIndex].CloseType != -1 )
  5618. {
  5619. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5620. return;
  5621. }
  5622.  
  5623. if ( lpObj->m_IfState.use > 0 && lpObj->m_IfState.type != 3 )
  5624. {
  5625. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5626. return;
  5627. }
  5628.  
  5629. if ( !PacketCheckTime(lpObj))
  5630. {
  5631. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5632. return;
  5633. }
  5634.  
  5635. if ( !::gObjFixInventoryPointer(aIndex))
  5636. {
  5637. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  5638. }
  5639.  
  5640. if ( gObj[aIndex].pTransaction == 1 )
  5641. {
  5642. LogAddTD("[%s][%s] CGSellRequestRecv() Failed : Transaction == 1, IF_TYPE : %d",
  5643. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  5644.  
  5645. return;
  5646. }
  5647.  
  5648. int tShop = lpObj->TargetShopNumber;
  5649.  
  5650. if ( tShop < 0 || tShop > MAX_SHOP-1 )
  5651. {
  5652. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5653. return;
  5654. }
  5655. if( tShop == 15 )
  5656. {
  5657. return;
  5658. }
  5659.  
  5660. if ( !gObjCanItemTouch(lpObj, 3))
  5661. {
  5662. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5663. return;
  5664. }
  5665.  
  5666. if ( lpMsg->Pos > MAIN_INVENTORY_SIZE-1 )
  5667. {
  5668. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5669. LogAdd(lMsg.Get(MSGGET(1, 227)), lpMsg->Pos);
  5670. return;
  5671. }
  5672.  
  5673. if ( gObjCheckSerial0ItemList(&lpObj->pInventory[lpMsg->Pos]) != FALSE )
  5674. {
  5675. MsgOutput(aIndex, lMsg.Get(MSGGET(13, 26)));
  5676. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5677.  
  5678. LogAddTD("[ANTI-HACK][Serial 0 Item] [Sell Item] (%s)(%s) Item(%s) Pos(%d)",
  5679. lpObj->AccountID, lpObj->Name, lpObj->pInventory[lpMsg->Pos].GetName(), lpMsg->Pos);
  5680.  
  5681. return;
  5682. }
  5683.  
  5684. if ( lpObj->pInventory[lpMsg->Pos].m_Type == ITEMGET(14,11) ) // Box of Luck
  5685. {
  5686. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5687. return;
  5688. }
  5689.  
  5690. /* if ( lpObj->pInventory[lpMsg->Pos].m_QuestItem != false) // SELL QUEST ITEMS
  5691. {
  5692. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5693. return;
  5694. }
  5695. */
  5696. if ( lpObj->pInventory[lpMsg->Pos].m_Type == ITEMGET(13,20) && lpObj->pInventory[lpMsg->Pos].m_Level == 1) // Wizards Ring +1
  5697. {
  5698. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5699. return;
  5700. }
  5701.  
  5702. if ( lpObj->pInventory[lpMsg->Pos].m_Type == ITEMGET(13,20) && lpObj->pInventory[lpMsg->Pos].m_Level == 2) // Wizards Ring +2
  5703. {
  5704. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5705. return;
  5706. }
  5707.  
  5708. if ( lpObj->pInventory[lpMsg->Pos].m_Type == ITEMGET(12,26) &&
  5709. (lpObj->pInventory[lpMsg->Pos].m_Level == 1 ||
  5710. lpObj->pInventory[lpMsg->Pos].m_Level == 2 ||
  5711. lpObj->pInventory[lpMsg->Pos].m_Level == 3 ||
  5712. lpObj->pInventory[lpMsg->Pos].m_Level == 4 ||
  5713. lpObj->pInventory[lpMsg->Pos].m_Level == 5 ))
  5714. {
  5715. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5716. return;
  5717. }
  5718.  
  5719. if ( g_kJewelOfHarmonySystem.IsStrengthenByJewelOfHarmony(&lpObj->pInventory[lpMsg->Pos]) == TRUE )
  5720. {
  5721. GCServerMsgStringSend(lMsg.Get(MSGGET(13, 37)), lpObj->m_Index, 1);
  5722. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5723. return;
  5724. }
  5725.  
  5726. if ( IsCashItem(lpObj->pInventory[lpMsg->Pos].m_Type) == TRUE )
  5727. {
  5728. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5729. return;
  5730. }
  5731.  
  5732. if ( lpObj->pInventory[lpMsg->Pos].m_Type == ITEMGET(14,12) && lpObj->pInventory[lpMsg->Pos].m_Level == 1) // Heart+1
  5733. {
  5734. pResult.Result = true;
  5735. pResult.Money = lpObj->Money;
  5736. gObjInventoryItemSet(aIndex, lpMsg->Pos, -1);
  5737. lpObj->pInventory[lpMsg->Pos].Clear();
  5738. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5739.  
  5740. return;
  5741. }
  5742.  
  5743. if ( lpObj->pInventory[lpMsg->Pos].IsItem() == FALSE )
  5744. {
  5745. pResult.Result = false;
  5746. pResult.Money = lpObj->Money;
  5747. LogAdd(lMsg.Get(MSGGET(1, 228)), __FILE__, __LINE__, lpObj->Name, lpMsg->Pos);
  5748. LogAdd("ID:%s CharID:%s ", lpObj->AccountID, lpObj->Name);
  5749. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5750.  
  5751. }
  5752. else
  5753. {
  5754. BYTE NewOption[MAX_EXOPTION_SIZE];
  5755. int iAddZen = 0;
  5756. int type = lpObj->pInventory[lpMsg->Pos].m_Type;
  5757.  
  5758. if ( type == ITEMGET(13,4) || type == ITEMGET(13,5)) // Pets
  5759. lpObj->pInventory[lpMsg->Pos].PetValue();
  5760. else
  5761. lpObj->pInventory[lpMsg->Pos].Value();
  5762.  
  5763. //if( type == ITEMGET(12,30))
  5764. //{
  5765. //lpObj->pInventory[lpMsg->Pos].m_SellMoney = 5000;
  5766. //}
  5767. iAddZen = lpObj->pInventory[lpMsg->Pos].m_SellMoney;
  5768. if ( iAddZen < 0 )
  5769. {
  5770. LogAdd("Error cost for item Account:[%s]Character:[%s]Item:[%s]Cost:[%d] ",lpObj->AccountID, lpObj->Name,lpObj->pInventory[lpMsg->Pos].GetName(),iAddZen);
  5771. return;
  5772. }
  5773. if ( gObjCheckMaxZen(aIndex, iAddZen) == FALSE )
  5774. {
  5775. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5776. return;
  5777. }
  5778.  
  5779. lpObj->Money += iAddZen;
  5780. pResult.Result =true;
  5781. pResult.Money = lpObj->Money;
  5782.  
  5783.  
  5784.  
  5785. ItemIsBufExOption(NewOption, &lpObj->pInventory[lpMsg->Pos]);
  5786.  
  5787. LogAddTD(lMsg.Get(MSGGET(1, 229)), lpObj->AccountID, lpObj->Name, tShop,
  5788. iAddZen, lpObj->pInventory[lpMsg->Pos].GetName(),
  5789. lpObj->pInventory[lpMsg->Pos].m_Level, lpObj->pInventory[lpMsg->Pos].m_Option1,
  5790. lpObj->pInventory[lpMsg->Pos].m_Option2, lpObj->pInventory[lpMsg->Pos].m_Option3,
  5791. lpObj->pInventory[lpMsg->Pos].m_Number, (int)lpObj->pInventory[lpMsg->Pos].m_Durability,
  5792. NewOption[0], NewOption[1], NewOption[2], NewOption[3], NewOption[4], NewOption[5], NewOption[6],
  5793. lpObj->pInventory[lpMsg->Pos].m_SetOption);
  5794.  
  5795. ::gObjInventoryDeleteItem(aIndex, lpMsg->Pos);
  5796.  
  5797. if ( lpMsg->Pos == 10 || lpMsg->Pos == 11 )
  5798. {
  5799. ::gObjUseSkill.SkillChangeUse(aIndex);
  5800. }
  5801.  
  5802. ::gObjMakePreviewCharSet(aIndex);
  5803. }
  5804.  
  5805. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  5806. }
  5807.  
  5808.  
  5809.  
  5810. int GetNeedMoneyItemDurRepaire(CItem * DurItem, BOOL RequestPos)
  5811. {
  5812. int iMoney = 0;
  5813. int type = DurItem->m_Type;
  5814. float ItemDurability = DurItem->m_Durability;
  5815.  
  5816. if ( type == ITEMGET(13,10) ) // Transformation Ring
  5817. return 0;
  5818.  
  5819. if ( ::HasItemDurability(type ) != FALSE )
  5820. {
  5821. float lc4;
  5822. float lc5 = 0;
  5823. lc4 = DurItem->m_BaseDurability;
  5824.  
  5825. if ( ItemDurability == lc4 )
  5826. return 0;
  5827.  
  5828. float lc6 = 1.0f - ItemDurability / lc4;
  5829. int lc7;
  5830.  
  5831. if ( type == ITEMGET(13,4)|| type ==ITEMGET(13,5) ) // Pets
  5832. lc7 = DurItem->m_BuyMoney;
  5833. else
  5834. lc7 = DurItem->m_BuyMoney/3;
  5835.  
  5836. if ( lc7 > 400000000 ) lc7 = 400000000;
  5837.  
  5838. if ( lc7 >= 1000 )
  5839. lc7 = lc7/100*100;
  5840. else if ( lc7 >= 100 )
  5841. lc7 = lc7/10*10;
  5842.  
  5843. float lc8 = sqrt((double)lc7);
  5844. float lc9 = sqrt(sqrt((double)lc7));
  5845. lc5 = 3.0f * lc8 * lc9;
  5846. lc5 *= lc6;
  5847. lc5 += 1.0f;
  5848.  
  5849. if ( ItemDurability <= 0.0f )
  5850. {
  5851. if ( type == ITEMGET(13,4)|| type ==ITEMGET(13,5) ) // Pets
  5852. lc5 *= 2;
  5853. else
  5854. lc5 *= ::GetAllRepairItemRate(type);
  5855.  
  5856. }
  5857.  
  5858. if ( RequestPos == TRUE )
  5859. {
  5860. lc5 += lc5 * 0.05f;
  5861. }
  5862. iMoney = lc5;
  5863.  
  5864. if ( iMoney >= 1000 )
  5865. iMoney = iMoney/100*100;
  5866. else if ( iMoney > 10 ) // Deathway fix Here -> Must be 100 and >=
  5867. iMoney = iMoney/10*10;
  5868.  
  5869. }
  5870. else
  5871. {
  5872. iMoney = -1;
  5873. }
  5874.  
  5875. return iMoney;
  5876. }
  5877.  
  5878.  
  5879.  
  5880.  
  5881. struct PMSG_ITEMDURREPAIR_RESULT
  5882. {
  5883. PBMSG_HEAD h; // C1:34
  5884. int Money; // 4
  5885. };
  5886.  
  5887.  
  5888.  
  5889.  
  5890. //void ItemDurRepaire(LPOBJ lpObj, CItem * DurItem, int pos, int RequestPos)
  5891. //{
  5892. // PMSG_ITEMDURREPAIR_RESULT pResult;
  5893. // int result = TRUE;
  5894. //
  5895. // PHeadSetB((LPBYTE)&pResult, 0x34, sizeof(pResult));
  5896. // int itemtype = DurItem->m_Type;
  5897. //
  5898. // if ( lpObj->m_IfState.type != 13 )
  5899. // {
  5900. // if ( itemtype ==ITEMGET(13,4) || itemtype == ITEMGET(13,5))
  5901. // {
  5902. // pResult.Money = 0;
  5903. // DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5904. //
  5905. // return;
  5906. // }
  5907. // }
  5908. //
  5909. // if ( itemtype >= ITEMGET(14,0) || ( itemtype >= ITEMGET(13,0) &&itemtype < ITEMGET(13,4) ) ||itemtype == ITEMGET(13,10) || (itemtype >= ITEMGET(12,7) &&itemtype <ITEMGET(12,36) ) ||itemtype ==ITEMGET(4,7) ||itemtype ==ITEMGET(4,15) )
  5910. // {
  5911. // pResult.Money = 0;
  5912. // DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5913. //
  5914. // return;
  5915. // }
  5916. //
  5917. // if ( itemtype == ITEMGET(13,38) )
  5918. // {
  5919. // pResult.Money = 0;
  5920. // DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5921. //
  5922. // return;
  5923. // }
  5924. //
  5925. // if ( itemtype == ITEMGET(13,39) )
  5926. // {
  5927. // pResult.Money = 0;
  5928. // DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5929. //
  5930. // return;
  5931. // }
  5932. //
  5933. // pResult.Money = GetNeedMoneyItemDurRepaire(DurItem, RequestPos);
  5934. //
  5935. // if ( pResult.Money <= 0 )
  5936. // {
  5937. // pResult.Money = 0;
  5938. // DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5939. //
  5940. // return;
  5941. // }
  5942. //
  5943. // if ( (lpObj->Money - pResult.Money) < 1 )
  5944. // pResult.Money = 0;
  5945. // else
  5946. // {
  5947. // lpObj->Money -= pResult.Money;
  5948. // pResult.Money = lpObj->Money;
  5949. // DurItem->m_Durability = (float)((int)DurItem->m_BaseDurability);
  5950. // DurItem->Convert(DurItem->m_Type, DurItem->m_Option1, DurItem->m_Option2, DurItem->m_Option3,
  5951. // DurItem->m_NewOption, DurItem->m_SetOption,DurItem->m_ItemOptionEx, CURRENT_DB_VERSION);
  5952. // GCItemDurSend(lpObj->m_Index, pos, DurItem->m_Durability, FALSE);
  5953. // }
  5954. //
  5955. // DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5956. //}
  5957. //
  5958.  
  5959.  
  5960. void ItemDurRepaire(LPOBJ lpObj, CItem * DurItem, int pos, int RequestPos)
  5961. {
  5962. PMSG_ITEMDURREPAIR_RESULT pResult;
  5963. int result = TRUE;
  5964.  
  5965. PHeadSetB((LPBYTE)&pResult, 0x34, sizeof(pResult));
  5966. int itemtype = DurItem->m_Type;
  5967.  
  5968. //season4 removed
  5969. /*if ( lpObj->m_IfState.type != 13 )
  5970. {
  5971. if ( itemtype ==ITEMGET(13,4) || itemtype == ITEMGET(13,5))
  5972. {
  5973. pResult.Money = 0;
  5974. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5975. return;
  5976. }
  5977. }*/
  5978.  
  5979. if ( itemtype >= ITEMGET(14,0) || ( itemtype >= ITEMGET(13,0) &&itemtype < ITEMGET(13,4) ) ||
  5980. itemtype == ITEMGET(13,10) || (itemtype >= ITEMGET(12,7) && itemtype < ITEMGET(12,36)) ||
  5981. (itemtype >= ITEMGET(12,240) && itemtype < ITEMGET(12,245)) ||
  5982. (itemtype > ITEMGET(12,43) && itemtype <ITEMGET(13,0) ) ||
  5983. itemtype ==ITEMGET(4,7) ||itemtype ==ITEMGET(4,15) )
  5984. {
  5985. pResult.Money = 0;
  5986. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5987. return;
  5988. }
  5989.  
  5990. if ( itemtype == ITEMGET(13,38) )
  5991. {
  5992. pResult.Money = 0;
  5993. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  5994. return;
  5995. }
  5996.  
  5997. if ( itemtype == ITEMGET(13,39) )
  5998. {
  5999. pResult.Money = 0;
  6000. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  6001. return;
  6002. }
  6003.  
  6004. if ( itemtype == ITEMGET(13,40) ) //Second Edition
  6005. {
  6006. pResult.Money = 0;
  6007. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  6008. return;
  6009. }
  6010.  
  6011. if ( itemtype == ITEMGET(13,41) ) //season 2.5 add-on
  6012. {
  6013. pResult.Money = 0;
  6014. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  6015. //return;
  6016. }
  6017.  
  6018. if ( itemtype == ITEMGET(13,42) ) //season 2.5 add-on
  6019. {
  6020. pResult.Money = 0;
  6021. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  6022. //return;
  6023. }
  6024.  
  6025. pResult.Money = GetNeedMoneyItemDurRepaire(DurItem, RequestPos);
  6026.  
  6027. if ( pResult.Money <= 0 )
  6028. {
  6029. pResult.Money = 0;
  6030. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  6031. return;
  6032. }
  6033.  
  6034. if ( (lpObj->Money - pResult.Money) < 1 )
  6035. {
  6036. pResult.Money = 0;
  6037. }
  6038. else
  6039. {
  6040. lpObj->Money -= pResult.Money;
  6041. pResult.Money = lpObj->Money;
  6042. DurItem->m_Durability = (float)((int)DurItem->m_BaseDurability);
  6043. DurItem->Convert(DurItem->m_Type, DurItem->m_Option1, DurItem->m_Option2, DurItem->m_Option3,
  6044. DurItem->m_NewOption, DurItem->m_SetOption,DurItem->m_ItemOptionEx, CURRENT_DB_VERSION);
  6045. if ( DurItem->m_Type == ITEMGET(13,4) || DurItem->m_Type == ITEMGET(13,5)) //season4.5 add-on
  6046. {
  6047. DurItem->PetValue();
  6048. }
  6049.  
  6050. GCItemDurSend(lpObj->m_Index, pos, DurItem->m_Durability, FALSE);
  6051. }
  6052.  
  6053. DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
  6054. }
  6055.  
  6056.  
  6057.  
  6058. void CGModifyRequestItem(PMSG_ITEMDURREPAIR * lpMsg, int aIndex)
  6059. {
  6060. LPOBJ lpObj = &gObj[aIndex];
  6061. PMSG_ITEMDURREPAIR_RESULT pResult;
  6062.  
  6063. PHeadSetB((LPBYTE)&pResult, 0x34, sizeof(pResult));
  6064. pResult.Money = 0;
  6065.  
  6066.  
  6067. if ( gObj[aIndex].CloseType != -1 )
  6068. {
  6069. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  6070. return;
  6071. }
  6072.  
  6073. if ( !PacketCheckTime(lpObj))
  6074. {
  6075. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  6076. return;
  6077. }
  6078.  
  6079. if (lpMsg->Requestpos == 1 && gObj[aIndex].Level < 50 )
  6080. {
  6081. pResult.Money = 0;
  6082. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  6083. return;
  6084. }
  6085.  
  6086. if ( lpMsg->Position == 0xFF )
  6087. {
  6088. for ( int n=0;n<MAIN_INVENTORY_SIZE;n++)
  6089. {
  6090. if ( lpObj->pInventory[n].IsItem())
  6091. {
  6092. if ( IsCashItem(lpObj->pInventory[n].m_Type ) == TRUE )
  6093. continue;
  6094.  
  6095. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,20) && (lpObj->pInventory[n].m_Level == 0 ||lpObj->pInventory[n].m_Level == 1 ))
  6096. continue;
  6097.  
  6098. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,20) && lpObj->pInventory[n].m_Level == 2 )
  6099. continue;
  6100.  
  6101. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,4) || lpObj->pInventory[n].m_Type == ITEMGET(13,5) )
  6102. continue;
  6103.  
  6104. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,37) )
  6105. continue;
  6106.  
  6107. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,38) )
  6108. continue;
  6109.  
  6110. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,39) )
  6111. continue;
  6112.  
  6113. if ( lpObj->pInventory[n].m_Type == ITEMGET(12,26) &&
  6114. (lpObj->pInventory[n].m_Level == 1 ||
  6115. lpObj->pInventory[n].m_Level == 2 ||
  6116. lpObj->pInventory[n].m_Level == 3 ||
  6117. lpObj->pInventory[n].m_Level == 4 ||
  6118. lpObj->pInventory[n].m_Level == 5 ))
  6119. continue;
  6120.  
  6121.  
  6122. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,40) ) //Second Edition
  6123. continue;
  6124.  
  6125. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,41) ) //season 2.5 add-on
  6126. continue;
  6127.  
  6128. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,42) ) //season 2.5 add-on
  6129. continue;
  6130.  
  6131. if ( lpObj->pInventory[n].m_Type == ITEMGET(13,51) ) //season 2.5 add-on
  6132. continue;
  6133.  
  6134. ItemDurRepaire(lpObj,&lpObj->pInventory[n] , n, lpMsg->Requestpos);
  6135. }
  6136. }
  6137.  
  6138. gObjCalCharacter(lpObj->m_Index);
  6139. return;
  6140. }
  6141.  
  6142. if ( lpMsg->Position > MAIN_INVENTORY_SIZE-1)
  6143. {
  6144. pResult.Money = 0;
  6145. return;
  6146. }
  6147.  
  6148. if ( IsCashItem(lpObj->pInventory[lpMsg->Position].m_Type ) == TRUE )
  6149. return;
  6150.  
  6151.  
  6152. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,20) && (lpObj->pInventory[lpMsg->Position].m_Level == 0 ||lpObj->pInventory[lpMsg->Position].m_Level == 1 ))
  6153. return;
  6154.  
  6155. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,20) && lpObj->pInventory[lpMsg->Position].m_Level == 2 )
  6156. return;
  6157.  
  6158. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,37) )
  6159. return;
  6160.  
  6161. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,38) )
  6162. return;
  6163.  
  6164. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,40) ) //Second Edition
  6165. return;
  6166.  
  6167. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,41) ) //season 2.5 add-on
  6168. return;
  6169.  
  6170. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,42) ) //season 2.5 add-on
  6171. return;
  6172.  
  6173. if ( lpObj->pInventory[lpMsg->Position].m_Type == ITEMGET(13,51) ) //season 2.5 add-on
  6174. return;
  6175.  
  6176.  
  6177.  
  6178. ItemDurRepaire(lpObj, &lpObj->pInventory[lpMsg->Position], lpMsg->Position, lpMsg->Requestpos);
  6179. gObjCalCharacter(lpObj->m_Index);
  6180. }
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186. struct PMSG_TRADE_REQUESTSEND
  6187. {
  6188. PBMSG_HEAD h; // C3:36
  6189. char szId[10]; // 3
  6190. };
  6191.  
  6192.  
  6193.  
  6194. void CGTradeRequestSend(PMSG_TRADE_REQUEST * lpMsg, int aIndex)
  6195. {
  6196. int number;
  6197. LPOBJ lpObj = &gObj[aIndex];
  6198. if (bCanTrade == FALSE )
  6199. {
  6200. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 125)), aIndex, 1);
  6201. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 126)), aIndex, 1);
  6202. return;
  6203. }
  6204.  
  6205. if(lpObj->Level < bNeedLevelTrade)
  6206. {
  6207. char pMsg[MAX_CHAT_LEN];
  6208. sprintf(pMsg, "You don\'t have enough level [%d] to use Trade ", bNeedLevelTrade);
  6209. GCServerMsgStringSend(pMsg, lpObj->m_Index, 1);
  6210. return;
  6211. }
  6212.  
  6213. if ( gObj[aIndex].CloseType != -1 )
  6214. return;
  6215.  
  6216.  
  6217.  
  6218. if ( !PacketCheckTime(lpObj))
  6219. return;
  6220.  
  6221. number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  6222.  
  6223. if ( OBJMAX_RANGE(number) == FALSE )
  6224. {
  6225. LogAdd("error : %s %d (%d)", __FILE__, __LINE__, number);
  6226. return;
  6227. }
  6228.  
  6229. if ( number == aIndex )
  6230. return;
  6231.  
  6232. if ( !gObjIsConnected(number))
  6233. return;
  6234.  
  6235. if ( gObj[number].Type == OBJ_MONSTER )
  6236. return;
  6237.  
  6238. if ( gObj[number].CloseCount >= 0 )
  6239. return;
  6240.  
  6241. if ( DS_MAP_RANGE(gObj[number].MapNumber) != FALSE )
  6242. {
  6243. ::GCServerMsgStringSend(lMsg.Get(MSGGET(2, 199)), aIndex, 1);
  6244. return;
  6245. }
  6246.  
  6247. if ( gObj[aIndex].m_bPShopOpen == true )
  6248. return;
  6249.  
  6250. if ( gObj[number].m_bPShopOpen == true )
  6251. return;
  6252.  
  6253. if ( CC_MAP_RANGE(gObj[number].MapNumber) != FALSE )
  6254. {
  6255. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 196)), aIndex, 1);
  6256. return;
  6257. }
  6258.  
  6259. if ( BC_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE )
  6260. {
  6261. if ( g_BloodCastle.GetCurrentState(gObj[aIndex].MapNumber-MAP_INDEX_BLOODCASTLE1) != 1 || g_BloodCastle.CheckCanEnter(gObj[aIndex].MapNumber-MAP_INDEX_BLOODCASTLE1) == false )
  6262. {
  6263. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 188)), aIndex, 1);
  6264. return;
  6265. }
  6266. }
  6267. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE )
  6268. {
  6269.  
  6270. ::GCServerMsgStringSend(lMsg.Get(3396), aIndex, 1);
  6271. return;
  6272. }
  6273. if ( (gObj[number].m_Option &1) != 1 )
  6274. {
  6275. ::GCTradeResponseSend(0, aIndex, gObj[number].Name, 0, 0);
  6276. return;
  6277. }
  6278.  
  6279. if ( lpObj->m_IfState.use > 0 )
  6280. {
  6281. ::GCTradeResponseSend(3, aIndex, gObj[number].Name, 0, 0);
  6282. return;
  6283. }
  6284.  
  6285. if (gObj[number].m_IfState.use > 0 )
  6286. {
  6287. ::GCTradeResponseSend(2, aIndex, gObj[number].Name, 0, 0);
  6288. return;
  6289. }
  6290.  
  6291. if ( ::gObjFixInventoryPointer(aIndex) == false )
  6292. {
  6293. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  6294. }
  6295.  
  6296. if ( gObj[aIndex].pTransaction == 1 )
  6297. {
  6298. LogAddTD("[%s][%s] CGTradeRequestSend() Failed : Transaction == 1, IF_TYPE : %d",
  6299. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  6300.  
  6301. return;
  6302. }
  6303.  
  6304. lpObj->m_IfState.use = 1;
  6305. lpObj->m_IfState.state = 0;
  6306. lpObj->m_IfState.type = 1;
  6307. lpObj->TargetNumber = number;
  6308. gObj[number].m_IfState.use = 1;
  6309. gObj[number].m_IfState.state = 0;
  6310. gObj[number].m_IfState.type = 1;
  6311. gObj[number].TargetNumber = aIndex;
  6312. lpObj->m_InterfaceTime = GetTickCount();
  6313. gObj[number].m_InterfaceTime = GetTickCount();
  6314.  
  6315. PMSG_TRADE_REQUESTSEND pMsg;
  6316.  
  6317. pMsg.h.c = 0xC3;
  6318. pMsg.h.headcode = 0x36;
  6319. pMsg.h.size = sizeof(pMsg);
  6320. memcpy(pMsg.szId, gObj[aIndex].Name, sizeof(pMsg.szId));
  6321.  
  6322. DataSend(number, (LPBYTE)&pMsg, pMsg.h.size);
  6323.  
  6324. LogAddTD(lMsg.Get(MSGGET(1, 230)), gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].Ip_addr,
  6325. gObj[number].AccountID, gObj[number].Name, gObj[number].Ip_addr);
  6326. }
  6327.  
  6328.  
  6329.  
  6330.  
  6331. void CGTradeResponseRecv(PMSG_TRADE_RESPONSE * lpMsg, int aIndex)
  6332. {
  6333. BOOL Result = TRUE;
  6334. int number = gObj[aIndex].TargetNumber;
  6335.  
  6336. if ( OBJMAX_RANGE(aIndex) == FALSE )
  6337. {
  6338. LogAdd("error-L1 : %d (A_ID:%s) %s %d", number, gObj[aIndex].AccountID, __FILE__, __LINE__);
  6339. Result = FALSE;
  6340. lpMsg->Response = false;
  6341. }
  6342.  
  6343. if ( OBJMAX_RANGE(number) == FALSE )
  6344. {
  6345. if ( gObj[aIndex].m_IfState.use != FALSE )
  6346. {
  6347. if ( gObj[aIndex].m_IfState.type == 1 )
  6348. {
  6349. gObj[aIndex].m_IfState.use = FALSE;
  6350. gObj[aIndex].TargetNumber = -1;
  6351. }
  6352. }
  6353.  
  6354. LogAdd("error-L1 : target:%d (A_ID:%s) %s %d", number, gObj[aIndex].AccountID, __FILE__, __LINE__);
  6355. Result = FALSE;
  6356. lpMsg->Response = false;
  6357. }
  6358.  
  6359. if ( gObjIsConnected(number) == FALSE )
  6360. {
  6361. Result = FALSE;
  6362. lpMsg->Response = false;
  6363. }
  6364.  
  6365. if ( gObj[aIndex].CloseType != -1 )
  6366. {
  6367. Result = FALSE;
  6368. lpMsg->Response = false;
  6369. }
  6370.  
  6371. if ( gObj[aIndex].m_bPShopOpen == true )
  6372. {
  6373. Result = FALSE;
  6374. lpMsg->Response = false;
  6375. }
  6376.  
  6377. if ( gObj[number].m_bPShopOpen == true )
  6378. {
  6379. Result = FALSE;
  6380. lpMsg->Response = false;
  6381. }
  6382.  
  6383. //if ( gObj[aIndex].X < (gObj[number].X -2 ) || gObj[aIndex].X > (gObj[number].X +2 ) || gObj[aIndex].Y < (gObj[number].Y -2 ) || gObj[aIndex].Y > (gObj[number].Y +2 ) )
  6384. //{
  6385. // Result = FALSE;
  6386. // lpMsg->Response = false;
  6387. //}
  6388.  
  6389. if ( gObj[aIndex].m_IfState.use == FALSE || gObj[aIndex].m_IfState.type != 1 || gObj[aIndex].m_IfState.state != 0 )
  6390. {
  6391. LogAddTD("(%s)(%s) Trade Interface State Error : use:%d type:%d", gObj[aIndex].AccountID, gObj[aIndex].Name,
  6392. gObj[aIndex].m_IfState.use, gObj[aIndex].m_IfState.type);
  6393.  
  6394. return;
  6395. }
  6396.  
  6397. if ( gObj[number].m_IfState.use == FALSE || gObj[number].m_IfState.type != 1 || gObj[number].m_IfState.state != 0 )
  6398. {
  6399. LogAddTD("(%s)(%s) Trade Interface State Error : use:%d type:%d", gObj[number].AccountID, gObj[number].Name,
  6400. gObj[number].m_IfState.use, gObj[number].m_IfState.type);
  6401.  
  6402. return;
  6403. }
  6404.  
  6405. if ( gObjFixInventoryPointer(aIndex) == false )
  6406. {
  6407. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  6408. }
  6409.  
  6410. if ( gObj[aIndex].pTransaction == 1 )
  6411. {
  6412. LogAddTD("[%s][%s] CGTradeResponseRecv() Failed : Transaction == 1, IF_TYPE : %d",
  6413. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  6414.  
  6415. return;
  6416. }
  6417.  
  6418. if ( lpMsg->Response == false )
  6419. {
  6420. GCTradeResponseSend(lpMsg->Response, number, gObj[aIndex].Name, 0, 0);
  6421. Result = FALSE;
  6422. LogAdd("[TEST] False Location - %s, %d", __FILE__, __LINE__);
  6423.  
  6424. }
  6425. else
  6426. {
  6427. Result = TRUE;
  6428.  
  6429. for ( int i=0;i<TRADE_BOX_SIZE;i++)
  6430. {
  6431. gObj[aIndex].Trade[i].Clear();
  6432. gObj[number].Trade[i].Clear();
  6433. }
  6434.  
  6435. memset(gObj[aIndex].TradeMap, (BYTE)-1, TRADE_BOX_MAP_SIZE );
  6436. memset(gObj[number].TradeMap, (BYTE)-1, TRADE_BOX_MAP_SIZE );
  6437. gObj[aIndex].m_IfState.state = 1;
  6438. gObj[number].m_IfState.state = 1;
  6439. gObj[aIndex].TradeMoney = 0;
  6440. gObj[number].TradeMoney = 0;
  6441.  
  6442. if (::gObjInventoryTrans(aIndex) == FALSE )
  6443. Result = 2;
  6444.  
  6445. if (::gObjInventoryTrans(number) == FALSE )
  6446. Result = 3;
  6447.  
  6448. if ( Result != TRUE )
  6449. {
  6450. lpMsg->Response = false;
  6451. GCTradeResponseSend(lpMsg->Response, number, gObj[aIndex].Name, 0, 0);
  6452. GCTradeResponseSend(lpMsg->Response, aIndex, gObj[number].Name, 0, 0);
  6453.  
  6454. if ( Result == 2 )
  6455. {
  6456. LogAddTD("[%s][%s] Made Trade Error (in Transaction) [%s][%s]",
  6457. gObj[aIndex].AccountID, gObj[aIndex].Name,
  6458. gObj[number].AccountID, gObj[number].Name);
  6459. }
  6460. else if ( Result == 3 )
  6461. {
  6462. LogAddTD("[%s][%s] Made Trade Error (in Transaction) [%s][%s]",
  6463. gObj[number].AccountID, gObj[number].Name,
  6464. gObj[aIndex].AccountID, gObj[aIndex].Name);
  6465. }
  6466.  
  6467. Result = FALSE;
  6468. }
  6469. else
  6470. {
  6471. lpMsg->Response = true;
  6472. GCTradeResponseSend(lpMsg->Response, number, gObj[aIndex].Name, gObj[aIndex].Level, gObj[aIndex].GuildNumber);
  6473. GCTradeResponseSend(lpMsg->Response, aIndex, gObj[number].Name, gObj[number].Level, gObj[number].GuildNumber);
  6474.  
  6475. LogAddTD("[%s][%s] Trade Ready [%s][%s]",
  6476. gObj[number].AccountID, gObj[number].Name,
  6477. gObj[aIndex].AccountID, gObj[aIndex].Name);
  6478. }
  6479. }
  6480.  
  6481. if ( Result == FALSE )
  6482. {
  6483. if ( gObj[aIndex].m_IfState.use != FALSE && gObj[aIndex].m_IfState.type == 1 )
  6484. {
  6485. gObj[aIndex].m_IfState.use = FALSE;
  6486. gObj[aIndex].TargetNumber = -1;
  6487. LogAddTD("Interface State : %d", gObj[aIndex].m_IfState.use);
  6488. }
  6489.  
  6490. if ( gObj[number].TargetNumber == aIndex )
  6491. {
  6492. if ( gObj[number].m_IfState.use != FALSE && gObj[number].m_IfState.type == 1 )
  6493. {
  6494. gObj[number].m_IfState.use = FALSE;
  6495. gObj[number].TargetNumber = -1;
  6496. LogAddTD("Interface State : %d", gObj[number].m_IfState.use);
  6497. }
  6498. }
  6499. }
  6500. }
  6501.  
  6502.  
  6503.  
  6504.  
  6505.  
  6506.  
  6507. BOOL GCTradeResponseSend(BYTE response, int aIndex, LPSTR id, WORD level, int GuildNumber)
  6508. {
  6509. PMSG_TRADE_RESPONSE pMsg;
  6510.  
  6511. PHeadSetB((LPBYTE)&pMsg, 0x37, sizeof(pMsg));
  6512. pMsg.Response = response;
  6513. pMsg.Level = level;
  6514. pMsg.GuildNumber = GuildNumber;
  6515. memcpy(pMsg.Id, id, sizeof(pMsg.Id));
  6516.  
  6517. return DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6518. }
  6519.  
  6520.  
  6521. struct PMSG_TRADE_OTHER_DEL
  6522. {
  6523. PBMSG_HEAD h; // C1:38
  6524. BYTE TradeItemIndex; // 3
  6525. };
  6526.  
  6527.  
  6528. int GCTradeOtherDel(int aIndex, BYTE tradeindex)
  6529. {
  6530. PMSG_TRADE_OTHER_DEL pMsg;
  6531.  
  6532. PHeadSetB((LPBYTE)&pMsg, 0x38, sizeof(pMsg ));
  6533. pMsg.TradeItemIndex = tradeindex;
  6534.  
  6535. return DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6536. }
  6537.  
  6538.  
  6539. struct PMSG_TRADE_OTHER_MOVE
  6540. {
  6541. PBMSG_HEAD h; // C1:39
  6542. BYTE TradeItemIndex; // 3
  6543. BYTE ItemInfo[MAX_ITEM_INFO]; // 4
  6544. };
  6545.  
  6546.  
  6547.  
  6548. int GCTradeOtherAdd(int aIndex, BYTE tradeindex, LPBYTE iteminfo)
  6549. {
  6550. PMSG_TRADE_OTHER_MOVE pMsg;
  6551.  
  6552. PHeadSetB((LPBYTE)&pMsg, 0x39, sizeof(pMsg));
  6553. pMsg.TradeItemIndex = tradeindex;
  6554. pMsg.ItemInfo[I_TYPE] = iteminfo[I_TYPE];
  6555. pMsg.ItemInfo[I_OPTION] = iteminfo[I_OPTION];
  6556. pMsg.ItemInfo[I_DUR] = iteminfo[I_DUR];
  6557. pMsg.ItemInfo[I_NOPTION] = iteminfo[I_NOPTION];
  6558. pMsg.ItemInfo[I_SOPTION] = iteminfo[I_SOPTION];
  6559. pMsg.ItemInfo[5] = iteminfo[5];
  6560. pMsg.ItemInfo[6] = iteminfo[6];
  6561.  
  6562. return DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6563. }
  6564.  
  6565.  
  6566.  
  6567.  
  6568.  
  6569. void CGTradeMoneyRecv(PMSG_TRADE_GOLD * lpMsg, int aIndex)
  6570. {
  6571. PMSG_DEFRESULT pMsg;
  6572. int money = 0;
  6573. int number;
  6574.  
  6575. if ( !PacketCheckTime(&gObj[aIndex]))
  6576. return;
  6577.  
  6578. if ( !OBJMAX_RANGE(aIndex) )
  6579. {
  6580. LogAdd("error : %s %d (%d)", __FILE__, __LINE__, aIndex);
  6581. return;
  6582. }
  6583.  
  6584. if ( gObj[aIndex].CloseType != -1 )
  6585. {
  6586. LogAdd(lMsg.Get(MSGGET(1, 231)), gObj[aIndex].AccountID, gObj[aIndex].Name);
  6587. return;
  6588. }
  6589.  
  6590. number = gObj[aIndex].TargetNumber;
  6591.  
  6592. if ( !OBJMAX_RANGE(number) )
  6593. {
  6594. LogAdd(lMsg.Get(MSGGET(1, 232)), gObj[aIndex].AccountID, gObj[aIndex].Name, number);
  6595. return;
  6596. }
  6597.  
  6598. if ( gObj[number].CloseType != -1 )
  6599. {
  6600. LogAdd(lMsg.Get(MSGGET(1, 233)), gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[number].AccountID, gObj[number].Name);
  6601. return;
  6602. }
  6603.  
  6604. if ( gObj[aIndex].m_IfState.use == FALSE && gObj[aIndex].m_IfState.type != 1 )
  6605. return;
  6606.  
  6607. if ( ::gObjCanItemTouch(&gObj[aIndex], 1) == FALSE )
  6608. return;
  6609.  
  6610. if ( lpMsg->Money > 100000000 )
  6611. return;
  6612.  
  6613. money = lpMsg->Money;
  6614.  
  6615. if ( (gObj[aIndex].Money - money) < 0 )
  6616. return;
  6617.  
  6618. GCMoneySend(aIndex, gObj[aIndex].Money - money);
  6619.  
  6620. PHeadSetB((LPBYTE)&pMsg, 0x3A, sizeof(pMsg));
  6621. pMsg.result = 1;
  6622.  
  6623. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6624.  
  6625. if ( number >= 0)
  6626. {
  6627. gObj[aIndex].TradeMoney = money;
  6628. gObj[aIndex].TradeOk = false;
  6629. gObj[number].TradeOk = false;
  6630.  
  6631. GCTradeOkButtonSend(number, 2);
  6632. GCTradeOkButtonSend(aIndex, 0);
  6633. GCTradeMoneyOther(number, gObj[aIndex].TradeMoney);
  6634. }
  6635. }
  6636.  
  6637.  
  6638.  
  6639. struct PMSG_TRADE_OTHER_GOLD
  6640. {
  6641. PBMSG_HEAD h; // C1:3B
  6642. DWORD Money; // 4
  6643. };
  6644.  
  6645.  
  6646.  
  6647. BOOL GCTradeMoneyOther(int aIndex, DWORD money)
  6648. {
  6649. PMSG_TRADE_OTHER_GOLD pMsg;
  6650.  
  6651. PHeadSetB((LPBYTE)&pMsg, 0x3B, sizeof(pMsg));
  6652. pMsg.Money = money;
  6653.  
  6654. return DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6655. }
  6656.  
  6657.  
  6658.  
  6659.  
  6660. BOOL GCTradeOkButtonSend(int aIndex, BYTE flag)
  6661. {
  6662. PMSG_TRADE_OKBUTTON pMsg;
  6663.  
  6664. PHeadSetB((LPBYTE)&pMsg, 0x3C, sizeof(pMsg));
  6665. pMsg.Flag = flag;
  6666.  
  6667. return DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6668. }
  6669.  
  6670.  
  6671.  
  6672. void CGTradeOkButtonRecv(PMSG_TRADE_OKBUTTON * lpMsg, int aIndex)
  6673. {
  6674. int number = gObj[aIndex].TargetNumber;
  6675.  
  6676. if ( number < 0 || number > OBJMAX-1 )
  6677. return;
  6678.  
  6679. if ( !gObjIsConnected(&gObj[number]))
  6680. return;
  6681.  
  6682. if ( gObj[aIndex].m_IfState.use < 1 || gObj[aIndex].m_IfState.state != 1 )
  6683. return;
  6684.  
  6685. if ( gObj[number].m_IfState.use < 1 || gObj[number].m_IfState.state != 1 )
  6686. return;
  6687.  
  6688. if ( gObj[aIndex].CloseType != -1 )
  6689. return;
  6690.  
  6691. if ( gObj[number].CloseType != -1 )
  6692. return;
  6693.  
  6694. if ( lpMsg->Flag == 1 )
  6695. {
  6696. if ( gObj[aIndex].TradeOk == false )
  6697. {
  6698. gObj[aIndex].TradeOk = true;
  6699. LogAddTD("[%s][%s] Trade Accept", gObj[aIndex].AccountID, gObj[aIndex].Name);
  6700. GCTradeOkButtonSend(number, 1);
  6701. }
  6702. }
  6703. else if ( lpMsg->Flag == 0 )
  6704. {
  6705. if ( gObj[aIndex].TradeOk == true )
  6706. {
  6707. GCTradeOkButtonSend(number, 0);
  6708. gObj[aIndex].TradeOk = false;
  6709. }
  6710. }
  6711.  
  6712. gObjTradeOkButton(aIndex);
  6713. }
  6714.  
  6715.  
  6716.  
  6717. void CGTradeCancelButtonRecv(int aIndex)
  6718. {
  6719. int number = gObj[aIndex].TargetNumber;
  6720. gObjTradeCancel(aIndex);
  6721. CGTradeResult(aIndex, 0);
  6722.  
  6723. if ( number >= 0 )
  6724. {
  6725. gObjTradeCancel(number);
  6726. CGTradeResult(number, 0);
  6727. }
  6728. }
  6729.  
  6730.  
  6731.  
  6732. struct PMSG_TRADE_RESULT
  6733. {
  6734. PBMSG_HEAD h; // C1:3D
  6735. BYTE Result; // 3
  6736. };
  6737.  
  6738.  
  6739.  
  6740. void CGTradeResult(int aIndex , BYTE result )
  6741. {
  6742. PMSG_TRADE_RESULT pMsg;
  6743.  
  6744. PHeadSetB((LPBYTE)&pMsg, 0x3D, sizeof(pMsg));
  6745. pMsg.Result = result;
  6746.  
  6747. DataSend(aIndex, (unsigned char*)&pMsg, pMsg.h.size);
  6748. }
  6749.  
  6750.  
  6751.  
  6752.  
  6753.  
  6754.  
  6755. struct CG_REQ_PSHOP_SET_ITEM_PRICE
  6756. {
  6757. PHEADSUBB PHeader;
  6758. BYTE btSourcePos;
  6759. BYTE dwItemPrice[4];
  6760. };
  6761.  
  6762.  
  6763.  
  6764. void CGPShopReqSetItemPrice(PMSG_REQ_PSHOP_SETITEMPRICE * lpMsg, int aIndex)
  6765. {
  6766. if ( gDoPShopOpen == FALSE )
  6767. {
  6768. CGPShopAnsSetItemPrice(aIndex, 0, lpMsg->btItemPos);
  6769. return;
  6770. }
  6771.  
  6772. if ( !gObjIsConnected(aIndex))
  6773. {
  6774. LogAddTD("[PShop] ERROR : Index is not CONNECTED : %d", aIndex);
  6775. return;
  6776. }
  6777.  
  6778. if ( gObj[aIndex].Type != OBJ_USER )
  6779. {
  6780. LogAddTD("[PShop] ERROR : Index is not CHARACTER : %d", aIndex);
  6781. return;
  6782. }
  6783.  
  6784. if ( gObj[aIndex].Level <= 5 )
  6785. {
  6786. LogAddTD("[PShop] [%s][%s] ERROR : Level is Under 6 : %d",
  6787. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].Level);
  6788. CGPShopAnsSetItemPrice(aIndex, 5, lpMsg->btItemPos);
  6789.  
  6790. return;
  6791. }
  6792.  
  6793. if ( INVENTORY_RANGE(lpMsg->btItemPos) == FALSE )
  6794. {
  6795. LogAddTD("[PShop] [%s][%s] ERROR : Item Position Out of Bound : %d",
  6796. gObj[aIndex].AccountID, gObj[aIndex].Name, lpMsg->btItemPos);
  6797. CGPShopAnsSetItemPrice(aIndex, 2, lpMsg->btItemPos);
  6798.  
  6799. return;
  6800. }
  6801.  
  6802. if ( gObj[aIndex].Inventory1[lpMsg->btItemPos].IsItem() == FALSE )
  6803. {
  6804. LogAddTD("[PShop] [%s][%s] ERROR : Item Does Not Exist : %d",
  6805. gObj[aIndex].AccountID, gObj[aIndex].Name, lpMsg->btItemPos);
  6806. CGPShopAnsSetItemPrice(aIndex, 3, lpMsg->btItemPos);
  6807.  
  6808. return;
  6809. }
  6810.  
  6811. CItem * sitem = &gObj[aIndex].Inventory1[lpMsg->btItemPos];
  6812. int iItemPrice = MAKE_NUMBERDW(MAKE_NUMBERW(lpMsg->sItemPrice4, lpMsg->sItemPrice3), MAKE_NUMBERW(lpMsg->sItemPrice2, lpMsg->sItemPrice1));
  6813.  
  6814. if ( gObjCheckSerial0ItemList(sitem) != FALSE )
  6815. {
  6816. MsgOutput(aIndex, lMsg.Get(MSGGET(13, 26)));
  6817. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  6818.  
  6819. LogAddTD("[ANTI-HACK][Serial 0 Item] [PShop] (%s)(%s) Item(%s) Pos(%d)",
  6820. gObj[aIndex].AccountID, gObj[aIndex].Name, sitem->GetName(), lpMsg->btItemPos);
  6821.  
  6822. return;
  6823. }
  6824.  
  6825.  
  6826. if ( gObjInventorySearchSerialNumber(&gObj[aIndex], sitem->GetNumber()) == FALSE )
  6827. {
  6828. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, TRUE, gObj[aIndex].iShield);
  6829. LogAdd("error-L2 : CopyItem [%s][%s] return %s %d", gObj[aIndex].AccountID, gObj[aIndex].Name, __FILE__, __LINE__);
  6830.  
  6831. return;
  6832. }
  6833.  
  6834. if ( iItemPrice <= 0 )
  6835. {
  6836. LogAddTD("[PShop] [%s][%s] ERROR : Personal Shop Item Price <= 0 : %d",
  6837. gObj[aIndex].AccountID, gObj[aIndex].Name, sitem->m_iPShopValue);
  6838. CGPShopAnsSetItemPrice(aIndex, 4, lpMsg->btItemPos);
  6839.  
  6840. return;
  6841. }
  6842.  
  6843. if ( (gObj[aIndex].Penalty&4) == 4 || (gObj[aIndex].Penalty&8) == 8 )
  6844. {
  6845. LogAddTD("[PShop] [%s][%s] ERROR : Item Price Change - Item Block",gObj[aIndex].AccountID, gObj[aIndex].Name,sitem->m_iPShopValue); // Deathway fix Here - Last parameter can cause crash
  6846. CGPShopAnsSetItemPrice(aIndex, 6 , lpMsg->btItemPos);
  6847.  
  6848. return;
  6849. }
  6850.  
  6851. sitem->m_iPShopValue = iItemPrice;
  6852. ItemAttribute[sitem->m_Type].Name[31] = 0; // Zero String Terminated
  6853.  
  6854. LogAddTD("[PShop] [%s][%s] Changing Item Price : %d (Type:%d (%s), Lev:%d, Serial:%d, Dur:%d",
  6855. gObj[aIndex].AccountID, gObj[aIndex].Name, sitem->m_iPShopValue, sitem->m_Type,
  6856. ItemAttribute[sitem->m_Type].Name, sitem->m_Level, sitem->m_Number,
  6857. sitem->m_Durability);
  6858.  
  6859. CGPShopAnsSetItemPrice(aIndex, 1 , lpMsg->btItemPos);
  6860. }
  6861.  
  6862.  
  6863.  
  6864.  
  6865. struct PMSG_ANS_PSHOP_SETITEMPRICE
  6866. {
  6867. PBMSG_HEAD2 h; // C1:3F:01
  6868. BYTE btResult; // 4
  6869. BYTE btItemPos; // 5
  6870. };
  6871.  
  6872.  
  6873. void CGPShopAnsSetItemPrice(int aIndex, BYTE btResult, BYTE btItemPos)
  6874. {
  6875. PMSG_ANS_PSHOP_SETITEMPRICE pMsg;
  6876.  
  6877. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x01, sizeof(pMsg));
  6878. pMsg.btResult = btResult;
  6879. pMsg.btItemPos = btItemPos;
  6880.  
  6881. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  6882. }
  6883.  
  6884.  
  6885.  
  6886.  
  6887.  
  6888.  
  6889. void CGPShopReqOpen(PMSG_REQ_PSHOP_OPEN * lpMsg, int aIndex)
  6890. {
  6891. if ( ::gDoPShopOpen == FALSE )
  6892. return;
  6893. if ( !gObjIsConnected(aIndex))
  6894. {
  6895. LogAddTD("[PShop] ERROR : Index is not CONNECTED : %d",aIndex);
  6896. return;
  6897. }
  6898.  
  6899. if ( gObj[aIndex].Type != OBJ_USER )
  6900. {
  6901. LogAddTD("[PShop] ERROR : Index is not CHARACTER : %d", aIndex);
  6902. return;
  6903. }
  6904.  
  6905. if ( gObj[aIndex].Level <= PShopNeedLevelCreate )
  6906. {
  6907. LogAddTD("[PShop] [%s][%s] ERROR : Level is Under %d : %d",
  6908. gObj[aIndex].AccountID, gObj[aIndex].Name,PShopNeedLevelCreate, gObj[aIndex].Level);
  6909. ::CGPShopAnsOpen( aIndex, 2);
  6910.  
  6911. return;
  6912. }
  6913.  
  6914. if ( (gObj[aIndex].Penalty&4) == 4 || (gObj[aIndex].Penalty&8) == 8 )
  6915. {
  6916. LogAddTD("[PShop] [%s][%s] ERROR : Cant't Open Shop - Item Block" ,gObj[aIndex].AccountID, gObj[aIndex].Name);
  6917. ::CGPShopAnsOpen( aIndex, 3);
  6918.  
  6919. return;
  6920. }
  6921.  
  6922. if ( CC_MAP_RANGE(gObj[aIndex].MapNumber) )
  6923. {
  6924. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 197)), aIndex, 1);
  6925. ::CGPShopAnsOpen( aIndex, 0);
  6926.  
  6927. return;
  6928. }
  6929.  
  6930. bool bEnablePShopOpen = false;
  6931.  
  6932. if ( gObj[aIndex].m_IfState.use == FALSE )
  6933. bEnablePShopOpen = true;
  6934. else
  6935. {
  6936. if ( gObj[aIndex].m_IfState.use == TRUE )
  6937. {
  6938. switch ( gObj[aIndex].m_IfState.type )
  6939. {
  6940. case 8:
  6941. bEnablePShopOpen = true; break;
  6942. }
  6943.  
  6944. if ( !bEnablePShopOpen )
  6945. {
  6946. LogAddTD("[PShop] [%s][%s] ERROR : m_IfState.type is Using : %d", gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  6947. }
  6948. }
  6949. else
  6950. {
  6951. LogAddTD("[PShop] [%s][%s] ERROR : Unknown m_IfState.type : %d", gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  6952. return;
  6953. }
  6954. }
  6955.  
  6956. if ( !::gObjFixInventoryPointer(aIndex))
  6957. {
  6958. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__ ,__LINE__);
  6959. }
  6960.  
  6961. if ( gObj[aIndex].pTransaction == 1 )
  6962. {
  6963. LogAddTD("[PShop] [%s][%s] ERROR : Transaction == 1, IF_TYPE : %d", gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_IfState.type);
  6964. bEnablePShopOpen = false;
  6965. }
  6966.  
  6967. if ( bEnablePShopOpen )
  6968. {
  6969. if ( gObj[aIndex].m_bPShopOpen == false )
  6970. {
  6971. gObj[aIndex].m_bPShopOpen = true;
  6972. memcpy(gObj[aIndex].m_szPShopText, lpMsg->szPShopText, sizeof(lpMsg->szPShopText));
  6973. LogAddTD("[PShop] [%s][%s] Personal Shop Opened", gObj[aIndex].AccountID, gObj[aIndex].Name);
  6974. }
  6975. else
  6976. {
  6977. memcpy(gObj[aIndex].m_szPShopText, lpMsg->szPShopText, sizeof(lpMsg->szPShopText));
  6978.  
  6979. PMSG_ANS_PSHOP_TEXT_CHANGED pMsg;
  6980.  
  6981. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x10, sizeof(pMsg));
  6982. pMsg.NumberH = SET_NUMBERH(aIndex);
  6983. pMsg.NumberL = SET_NUMBERL(aIndex);
  6984. memcpy(pMsg.btPShopText, lpMsg->szPShopText, sizeof(pMsg.btPShopText));
  6985. memcpy(pMsg.btName, gObj[aIndex].Name, sizeof(pMsg.btName));
  6986.  
  6987. MsgSendV2(&gObj[aIndex], (LPBYTE)&pMsg, pMsg.h.size);
  6988.  
  6989. LogAddTD("[PShop] [%s][%s] Personal Shop Already Opened - Changing PShop Name",
  6990. gObj[aIndex].AccountID, gObj[aIndex].Name);
  6991. }
  6992. }
  6993. else
  6994. {
  6995. CGPShopAnsOpen(aIndex, 0);
  6996. return;
  6997. }
  6998.  
  6999. CGPShopAnsOpen(aIndex, 1);
  7000. }
  7001.  
  7002.  
  7003.  
  7004.  
  7005. struct PMSG_ANS_PSHOP_OPEN
  7006. {
  7007. PBMSG_HEAD2 h; // C1:3F:02
  7008. BYTE btResult; // 4
  7009. };
  7010.  
  7011.  
  7012. void CGPShopAnsOpen(int aIndex, BYTE btResult)
  7013. {
  7014. PMSG_ANS_PSHOP_OPEN pMsg;
  7015.  
  7016. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x02, sizeof(pMsg));
  7017. pMsg.btResult = btResult;
  7018.  
  7019. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  7020. }
  7021.  
  7022.  
  7023.  
  7024.  
  7025. void CGPShopReqClose(int aIndex)
  7026. {
  7027. if ( !gObjIsConnected(aIndex))
  7028. {
  7029. LogAddTD("[PShop] ERROR : Index is not CONNECTED : %d", aIndex);
  7030. return;
  7031. }
  7032.  
  7033. if ( gObj[aIndex].Type != OBJ_USER )
  7034. {
  7035. LogAddTD("[PShop] ERROR : Index is not CHARACTER : %d", aIndex);
  7036. return;
  7037. }
  7038.  
  7039. LogAddTD("[PShop] [%s][%s] Requested to Close PShop", gObj[aIndex].AccountID, gObj[aIndex].Name);
  7040. gObj[aIndex].m_bPShopOpen = false;
  7041. memset(gObj[aIndex].m_szPShopText, 0, sizeof(gObj[aIndex].m_szPShopText));
  7042. CGPShopAnsClose(aIndex, 1);
  7043. }
  7044.  
  7045.  
  7046.  
  7047.  
  7048. struct PMSG_ANS_PSHOP_CLOSE
  7049. {
  7050. PBMSG_HEAD2 h; // C1:3F:03
  7051. BYTE btResult; // 4
  7052. BYTE NumberH; // 5
  7053. BYTE NumberL; // 6
  7054. };
  7055.  
  7056.  
  7057. void CGPShopAnsClose(int aIndex, BYTE btResult)
  7058. {
  7059. LogAddTD("[PShop] [%s][%s] Close PShop", gObj[aIndex].AccountID, gObj[aIndex].Name);
  7060.  
  7061.  
  7062. if( gObj[aIndex].OffTrade )
  7063. {
  7064. gObjDel(aIndex);
  7065. }
  7066. // ----
  7067. gObj[aIndex].OffTrade = 0;
  7068.  
  7069. PMSG_ANS_PSHOP_CLOSE pMsg;
  7070. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x03, sizeof(pMsg));
  7071. pMsg.btResult = btResult;
  7072. pMsg.NumberH = SET_NUMBERH(aIndex);
  7073. pMsg.NumberL = SET_NUMBERL(aIndex);
  7074.  
  7075. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  7076.  
  7077. if ( btResult == 1 )
  7078. MsgSendV2(&gObj[aIndex], (LPBYTE)&pMsg, pMsg.h.size);
  7079. }
  7080.  
  7081.  
  7082.  
  7083.  
  7084.  
  7085. void CGPShopReqBuyList(PMSG_REQ_BUYLIST_FROM_PSHOP * lpMsg, int aSourceIndex)
  7086. {
  7087. if ( ::gDoPShopOpen == FALSE )
  7088. return;
  7089.  
  7090. if ( gObjIsConnected(MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)) == FALSE)
  7091. {
  7092. LogAddTD("[PShop] [%s][%s] PShop List Request Failed : Seller did Not CONNECTED (%d)",
  7093. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
  7094. ::CGPShopAnsBuyList(aSourceIndex, -1, 2, 0);
  7095. return;
  7096. }
  7097.  
  7098. LPOBJ lpObj = &gObj[MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)];
  7099. if(lpObj->FakeState == true)
  7100. return;
  7101. if ( lpObj->Type != OBJ_USER )
  7102. {
  7103. LogAddTD("[PShop] [%s][%s] PShop List Request Failed : Seller is Not CHARACTER (%d)"
  7104. ,gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
  7105. ::CGPShopAnsBuyList(aSourceIndex, -1, 2, 0);
  7106. return;
  7107. }
  7108.  
  7109. if ( lpObj->CloseCount >= 0 )
  7110. {
  7111. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Seller is Closing (%d)"
  7112. ,gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL) );
  7113. CGPShopAnsBuyItem(aSourceIndex, -1, 0,2);
  7114. return;
  7115. }
  7116.  
  7117. if ( gObj[aSourceIndex].CloseCount >= 0 )
  7118. {
  7119. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Buyer is Closing (%d)",
  7120. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
  7121. CGPShopAnsBuyItem(aSourceIndex, -1, 0, 2);
  7122. return;
  7123. }
  7124.  
  7125. if ( lpObj->m_Index == aSourceIndex )
  7126. {
  7127. LogAddTD("[PShop] [%s][%s] PShop List Requested to Him(/Her)Self",
  7128. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name);
  7129. ::CGPShopAnsBuyList(aSourceIndex, -1, 2, 0);
  7130. return;
  7131. }
  7132.  
  7133. if ( lpObj->m_bPShopOpen == false )
  7134. {
  7135. LogAddTD("[PShop] [%s][%s] PShop List Request Failed : [%s][%s] Did not Open PShop",
  7136. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7137. lpObj->AccountID, lpObj->Name);
  7138. ::CGPShopAnsBuyList(aSourceIndex, -1, 3, 0);
  7139. return;
  7140. }
  7141.  
  7142. if ( (lpObj->Penalty &4) == 4 || (lpObj->Penalty&8) == 8 )
  7143. {
  7144. LogAddTD("[PShop] [%s][%s] PShop List Request Failed : [%s][%s] is in Item Block",
  7145. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7146. lpObj->AccountID, lpObj->Name);
  7147. ::CGPShopAnsBuyList(aSourceIndex, -1, 4, 0);
  7148. return;
  7149. }
  7150.  
  7151. if ( !::gObjFixInventoryPointer(aSourceIndex))
  7152. {
  7153. LogAdd("[Fix Inv.Ptr] False Location - %s, %d", __FILE__, __LINE__);
  7154. }
  7155.  
  7156. if ( gObj[aSourceIndex].pTransaction == 1 )
  7157. {
  7158. LogAddTD("[PShop] [%s][%s] PShop List Request Failed : Requester Transaction == 1, IF_TYPE : %d",
  7159. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].m_IfState.type);
  7160. return;
  7161. }
  7162.  
  7163. LogAddTD("[PShop] [%s][%s] is Receiving PShop List From [%s][%s]",
  7164. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7165. lpObj->AccountID, lpObj->Name);
  7166.  
  7167. gObj[aSourceIndex].m_bPShopWantDeal = true;
  7168. gObj[aSourceIndex].m_iPShopDealerIndex = lpObj->m_Index;
  7169. memcpy(gObj[aSourceIndex].m_szPShopDealerName, lpObj->Name, MAX_ACCOUNT_LEN);
  7170. ::CGPShopAnsBuyList(aSourceIndex, lpObj->m_Index, 1, false);
  7171. }
  7172.  
  7173.  
  7174.  
  7175.  
  7176. struct PMSG_BUYLIST_FROM_PSHOP
  7177. {
  7178. BYTE Pos; // 0
  7179. BYTE ItemInfo[MAX_ITEM_INFO]; // 1
  7180. int PShopItemValue; // 8
  7181. };
  7182.  
  7183.  
  7184.  
  7185.  
  7186. struct PMSG_ANS_BUYLIST_FROM_PSHOP
  7187. {
  7188. PWMSG_HEAD2 h; // C2:3F:[05:13]
  7189. BYTE Result; // 5
  7190. BYTE NumberH; // 6
  7191. BYTE NumberL; // 7
  7192. BYTE btName[10]; // 8
  7193. char szPShopText[36]; // 12
  7194. BYTE btCount; // 36
  7195. };
  7196.  
  7197.  
  7198. void CGPShopAnsBuyList(int aSourceIndex, int aTargetIndex, BYTE btResult, bool bResend)
  7199. {
  7200. if ( gDoPShopOpen == FALSE )
  7201. return;
  7202.  
  7203.  
  7204. PMSG_ANS_BUYLIST_FROM_PSHOP pMsgILC; // Packet Message Item List Count
  7205. PMSG_BUYLIST_FROM_PSHOP pMsgIL;
  7206. BYTE sendBuf[1024];
  7207. int sOfs = sizeof(pMsgILC);
  7208. int pMsgILSize = sizeof(pMsgIL);
  7209.  
  7210. if ( btResult != 1 )
  7211. {
  7212. LPOBJ lpObj = &gObj[aSourceIndex];
  7213.  
  7214. pMsgILC.h.c = 0xC2;
  7215. pMsgILC.h.headcode = 0x3F;
  7216.  
  7217. if ( bResend == false )
  7218. pMsgILC.h.subcode = 0x05;
  7219. else
  7220. pMsgILC.h.subcode = 0x13;
  7221.  
  7222. pMsgILC.h.sizeH = SET_NUMBERH(sOfs);
  7223. pMsgILC.h.sizeL = SET_NUMBERL(sOfs);
  7224. pMsgILC.btCount = 0;
  7225. pMsgILC.Result = btResult;
  7226. pMsgILC.NumberH = SET_NUMBERH(aTargetIndex);
  7227. pMsgILC.NumberL = SET_NUMBERL(aTargetIndex);
  7228. memset(pMsgILC.btName, 0, sizeof(pMsgILC.btName));
  7229. memset(pMsgILC.szPShopText, 0, sizeof(pMsgILC.szPShopText));
  7230. memcpy(sendBuf, &pMsgILC, sizeof(pMsgILC));
  7231.  
  7232. DataSend(aSourceIndex, sendBuf, sOfs);
  7233. }
  7234. else
  7235. {
  7236. LPOBJ lpObjSource = &gObj[aSourceIndex];
  7237. LPOBJ lpObjTarget = &gObj[aTargetIndex];
  7238. int iCount = 0;
  7239.  
  7240. for ( int n=MAIN_INVENTORY_SIZE;n<INVENTORY_SIZE;n++)
  7241. {
  7242. if ( lpObjTarget->Inventory1[n].IsItem() == TRUE )
  7243. {
  7244. pMsgIL.Pos = n;
  7245. ItemByteConvert(pMsgIL.ItemInfo, lpObjTarget->Inventory1[n]);
  7246. pMsgIL.PShopItemValue = lpObjTarget->Inventory1[n].m_iPShopValue;
  7247. memcpy(&sendBuf[sOfs], &pMsgIL, pMsgILSize);
  7248. iCount++;
  7249. sOfs += pMsgILSize;
  7250.  
  7251. LogAddTD("ITEM TYPE:%d", lpObjTarget->Inventory1[n].m_Type);
  7252. }
  7253. }
  7254.  
  7255. pMsgILC.h.c = 0xC2;
  7256. pMsgILC.h.headcode = 0x3F;
  7257.  
  7258. if ( bResend == false )
  7259. pMsgILC.h.subcode = 0x05;
  7260. else
  7261. pMsgILC.h.subcode = 0x13;
  7262.  
  7263. pMsgILC.h.sizeH = SET_NUMBERH(sOfs);
  7264. pMsgILC.h.sizeL = SET_NUMBERL(sOfs);
  7265. pMsgILC.btCount = iCount;
  7266. pMsgILC.Result = btResult;
  7267. pMsgILC.NumberH = SET_NUMBERH(aTargetIndex);
  7268. pMsgILC.NumberL = SET_NUMBERL(aTargetIndex);
  7269. memcpy(pMsgILC.btName, lpObjTarget->Name, sizeof(pMsgILC.btName));
  7270. memcpy(pMsgILC.szPShopText, lpObjTarget->m_szPShopText, sizeof(pMsgILC.szPShopText));
  7271. memcpy(sendBuf, &pMsgILC, sizeof(pMsgILC));
  7272.  
  7273. DataSend(aSourceIndex, sendBuf, sOfs);
  7274.  
  7275. }
  7276. }
  7277.  
  7278.  
  7279.  
  7280.  
  7281.  
  7282. void CGPShopReqBuyItem(PMSG_REQ_BUYITEM_FROM_PSHOP * lpMsg, int aSourceIndex)
  7283. {
  7284. if ( gDoPShopOpen == FALSE )
  7285. return;
  7286.  
  7287. if ( gObjIsConnected( MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)) == FALSE )
  7288. {
  7289. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Seller did Not CONNECTED (%d)",
  7290. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
  7291. ::CGPShopAnsBuyItem(aSourceIndex, -1, 0, 2);
  7292. return;
  7293. }
  7294.  
  7295. LPOBJ lpObj = &gObj[MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)];
  7296.  
  7297. if ( lpObj->Type != OBJ_USER )
  7298. {
  7299. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Seller is Not CHARACTER (%d)",
  7300. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
  7301. ::CGPShopAnsBuyItem(aSourceIndex, -1, 0, 2);
  7302. return;
  7303. }
  7304.  
  7305. if ( lpObj->CloseCount >= 0 )
  7306. {
  7307. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Seller is Closing (%d)"
  7308. ,gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL) );
  7309. ::CGPShopAnsBuyItem(aSourceIndex, -1, 0,2);
  7310. return;
  7311. }
  7312.  
  7313.  
  7314. if ( gObj[aSourceIndex].CloseCount >= 0 )
  7315. {
  7316. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Buyer is Closing (%d)",
  7317. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL));
  7318. ::CGPShopAnsBuyItem(aSourceIndex, -1, 0, 2);
  7319. return;
  7320. }
  7321.  
  7322. if ( lpObj->m_bPShopOpen == false )
  7323. {
  7324. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Did not Open PShop",
  7325. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7326. lpObj->AccountID, lpObj->Name);
  7327. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 3);
  7328. return;
  7329. }
  7330.  
  7331. char szName[MAX_ACCOUNT_LEN+1] = {0};
  7332. memcpy(szName, lpMsg->btName, sizeof(lpMsg->btName));
  7333. szName[MAX_ACCOUNT_LEN] = 0;
  7334. int iITEM_LOG_TYPE;
  7335. int iITEM_LOG_LEVEL;
  7336. int iITEM_LOG_DUR;
  7337. int iITEM_LOG_SERIAL;
  7338.  
  7339. if ( strcmp(szName, lpObj->Name) )
  7340. {
  7341. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Name Mismatch [%s] - [%s]",
  7342. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7343. szName, lpObj->Name);
  7344. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 6);
  7345.  
  7346. return;
  7347. }
  7348.  
  7349. if ( lpObj->CloseType != -1 )
  7350. {
  7351. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] is Closing Connection",
  7352. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7353. lpObj->AccountID, lpObj->Name);
  7354. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0,2);
  7355.  
  7356. return;
  7357. }
  7358.  
  7359. if ( (lpObj->Penalty &4) == 4 || (lpObj->Penalty &8) == 8 )
  7360. {
  7361. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] is in Item Block",
  7362. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7363. lpObj->AccountID, lpObj->Name);
  7364. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0,9);
  7365.  
  7366. return;
  7367. }
  7368.  
  7369. if ( (gObj[aSourceIndex].Penalty &4) == 4 || (gObj[aSourceIndex].Penalty &8) == 8 )
  7370. {
  7371. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] is in Item Block",
  7372. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7373. lpObj->AccountID, lpObj->Name);
  7374. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0,9);
  7375.  
  7376. return;
  7377. }
  7378.  
  7379. EnterCriticalSection(&lpObj->m_critPShopTrade);
  7380.  
  7381. if ( lpObj->m_bPShopTransaction == true )
  7382. {
  7383. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Already Trade With Other",
  7384. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7385. lpObj->AccountID, lpObj->Name);
  7386. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0,4);
  7387. LeaveCriticalSection(&lpObj->m_critPShopTrade);
  7388.  
  7389. }
  7390. else
  7391. {
  7392. lpObj->m_bPShopTransaction = true;
  7393. LeaveCriticalSection(&lpObj->m_critPShopTrade);
  7394.  
  7395. if ( gObjCheckSerial0ItemList(&lpObj->Inventory1[lpMsg->btItemPos]) != FALSE )
  7396. {
  7397. MsgOutput(lpObj->m_Index, lMsg.Get(MSGGET(13, 26)));
  7398. GCReFillSend(aSourceIndex, gObj[aSourceIndex].Life, 0xFD, 1, gObj[aSourceIndex].iShield);
  7399.  
  7400. LogAddTD("[ANTI-HACK][Serial 0 Item] [PShop Buy] (%s)(%s) Item(%s) Pos(%d)",
  7401. lpObj->AccountID, lpObj->Name, lpObj->Inventory1[lpMsg->btItemPos].GetName(), lpMsg->btItemPos);
  7402.  
  7403. return;
  7404. }
  7405.  
  7406.  
  7407.  
  7408. // New for Check Item Serials
  7409. if ( ::gObjInventorySearchSerialNumber(&gObj[aSourceIndex], lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE )
  7410. {
  7411. ::GCReFillSend(aSourceIndex, gObj[aSourceIndex].Life, -3, 1, gObj[aSourceIndex].iShield);
  7412. LogAdd("error-L2 : CopyItem [%s][%s] return %s %d", gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7413. __FILE__, __LINE__);
  7414.  
  7415. return;
  7416. }
  7417.  
  7418. if ( ::gObjInventorySearchSerialNumber(lpObj, lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE )
  7419. {
  7420. GCReFillSend(lpObj->m_Index, lpObj->Life, -3, 1, lpObj->iShield);
  7421. LogAdd("error-L2 : CopyItem [%s][%s] return %s %d",
  7422. lpObj->AccountID, lpObj->Name,
  7423. __FILE__, __LINE__);
  7424.  
  7425. return;
  7426. }
  7427.  
  7428. if (gObjFixInventoryPointer(aSourceIndex) == false )
  7429. {
  7430. LogAdd( "[Fix Inv.Ptr] False Location - %s, %d",
  7431. __FILE__, __LINE__);
  7432. }
  7433.  
  7434. if ( gObj[aSourceIndex].pTransaction == 1 )
  7435. {
  7436. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : Requester Transaction == 1, IF_TYPE : %d",
  7437. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].m_IfState.type);
  7438. return;
  7439. }
  7440.  
  7441. iITEM_LOG_TYPE=0;
  7442. iITEM_LOG_LEVEL=0;
  7443. iITEM_LOG_DUR=0;
  7444. iITEM_LOG_SERIAL = 0;
  7445.  
  7446. __try
  7447. {
  7448. if ( PSHOP_RANGE(lpMsg->btItemPos) == FALSE )
  7449. {
  7450. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 5);
  7451. return;
  7452. }
  7453.  
  7454. if ( lpObj->m_bMapSvrMoveQuit == true )
  7455. {
  7456. CGPShopAnsBuyItem(aSourceIndex, -1, 0, 2);
  7457. return;
  7458. }
  7459.  
  7460. if ( lpObj->Inventory1[lpMsg->btItemPos].IsItem() == TRUE )
  7461. {
  7462. if ( lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue <= 0 )
  7463. {
  7464. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Did Not Choose Item Price",
  7465. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7466. lpObj->AccountID, lpObj->Name);
  7467. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 6);
  7468.  
  7469. return;
  7470. }
  7471.  
  7472.  
  7473.  
  7474. if(lpObj->OffTradeZen == 1)
  7475. {
  7476. if ( gObj[aSourceIndex].Money < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
  7477. {
  7478. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Zen",
  7479. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7480. lpObj->AccountID, lpObj->Name);
  7481. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 7);
  7482.  
  7483. return;
  7484. }
  7485.  
  7486. DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7487.  
  7488. if ( gObjCheckMaxZen(lpObj->m_Index, dwCost) == FALSE )
  7489. {
  7490. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Exceeding Zen of the Host",
  7491. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7492. lpObj->AccountID, lpObj->Name);
  7493. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7494.  
  7495. return;
  7496. }
  7497.  
  7498. BYTE btNewItemPos = 0;
  7499. btNewItemPos = ::gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
  7500.  
  7501. iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type;
  7502. iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level;
  7503. iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
  7504. iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number;
  7505. ::gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
  7506. lpObj->Inventory1[lpMsg->btItemPos].Clear();
  7507. ::GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
  7508. gObj[aSourceIndex].Money -= dwCost;
  7509. lpObj->Money += dwCost;
  7510. ::GCMoneySend(aSourceIndex, gObj[aSourceIndex].Money);
  7511. ::GCMoneySend(lpObj->m_Index, lpObj->Money);
  7512. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
  7513. ::CGPShopAnsSoldItem(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
  7514.  
  7515. if ( btNewItemPos == 0xFF )
  7516. {
  7517. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] No Room to Buy Item",
  7518. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7519. lpObj->AccountID, lpObj->Name);
  7520. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7521.  
  7522. return;
  7523. }
  7524. LogAddTD("[OffTrade][PShop] [%s][%s][%s] PShop Item Buy Request Succeed : [%s][%s][%s] (Price=%d ZEN, ItemType:%d (%s), ItemLevel:%d, ItemDur:%d, Serial:%d",
  7525. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].Ip_addr,
  7526. lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE,
  7527. ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
  7528. }
  7529. else if (lpObj->OffTradeCoin == 1)
  7530. {
  7531. //int PlayerCoinsCount = gObj[aSourceIndex].m_wCashPoint;
  7532. //int SellerCoinsCount = lpObj->m_wCashPoint;
  7533. if (gObj[aSourceIndex].m_wCashPoint < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
  7534. {
  7535. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Coins",
  7536. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7537. lpObj->AccountID, lpObj->Name);
  7538. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 7);
  7539.  
  7540. return;
  7541. }
  7542. // DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7543.  
  7544.  
  7545. BYTE btNewItemPos = 0;
  7546. btNewItemPos = ::gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
  7547.  
  7548. iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type;
  7549. iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level;
  7550. iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
  7551. iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number;
  7552. ::gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
  7553. lpObj->Inventory1[lpMsg->btItemPos].Clear();
  7554. ::GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
  7555.  
  7556.  
  7557. //SQL.UpdateCoinsPlayer(gObj[aSourceIndex].AccountID,PlayerCoinsCount-dwCost);
  7558. //SQL.UpdateCoinsPlayer(lpObj->AccountID,SellerCoinsCount+dwCost);
  7559. gObj[aSourceIndex].m_wCashPoint -= lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7560. lpObj->m_wCashPoint += lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7561.  
  7562. if (lpObj->m_wCashPoint > 65535)
  7563. {
  7564. lpObj->m_wCashPoint = 65535;
  7565. }
  7566. GDSetValutList(aSourceIndex);
  7567. GDSetValutList(lpObj->m_Index);
  7568. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
  7569. ::CGPShopAnsSoldItem(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
  7570. if ( btNewItemPos == 0xFF )
  7571. {
  7572. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] No Room to Buy Item",
  7573. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7574. lpObj->AccountID, lpObj->Name);
  7575. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7576.  
  7577. return;
  7578. }
  7579. LogAddTD("[OffTrade][PShop] [%s][%s][%s] PShop Item Buy Request Succeed : [%s][%s][%s] (Price=%d Coin, ItemType:%d (%s), ItemLevel:%d, ItemDur:%d, Serial:%d",
  7580. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].Ip_addr,
  7581. lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue, iITEM_LOG_TYPE,
  7582. ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
  7583. }
  7584. else if (lpObj->OffTradeSoul == 1)
  7585. {
  7586. int PlayerSoulCount = GetCountSoulCharacter(gObj[aSourceIndex].m_Index,0);
  7587. int PlayerBaseSoulCount = SQL.GetSoulPlayer(lpObj->Name);
  7588. if ( PlayerSoulCount < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
  7589. {
  7590. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Souls",
  7591. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7592. lpObj->AccountID, lpObj->Name);
  7593. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 7);
  7594.  
  7595. return;
  7596. }
  7597. DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7598.  
  7599.  
  7600. BYTE btNewItemPos = 0;
  7601. btNewItemPos = ::gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
  7602.  
  7603. iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type;
  7604. iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level;
  7605. iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
  7606. iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number;
  7607. ::gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
  7608. lpObj->Inventory1[lpMsg->btItemPos].Clear();
  7609. ::GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
  7610.  
  7611.  
  7612.  
  7613. DeleteCountSoulCharacter(aSourceIndex);
  7614. int CountJewel = PlayerSoulCount - dwCost;
  7615. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
  7616. ::CGPShopAnsSoldItem(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
  7617. if(SetCountSoulInventory(aSourceIndex,CountJewel) == false)
  7618. {
  7619.  
  7620. }
  7621. SQL.UpdateSoulPlayer(lpObj->Name,PlayerBaseSoulCount+dwCost);
  7622.  
  7623. if ( btNewItemPos == 0xFF )
  7624. {
  7625. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] No Room to Buy Item",
  7626. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7627. lpObj->AccountID, lpObj->Name);
  7628. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7629.  
  7630. return;
  7631. }
  7632. LogAddTD("[OffTrade][PShop] [%s][%s][%s] PShop Item Buy Request Succeed : [%s][%s][%s] (Price=%d Soul, ItemType:%d (%s), ItemLevel:%d, ItemDur:%d, Serial:%d",
  7633. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].Ip_addr,
  7634. lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE,
  7635. ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
  7636. }
  7637. else if (lpObj->OffTradeBless == 1)
  7638. {
  7639.  
  7640. int PlayerBlessCount = GetCountBlessCharacter(gObj[aSourceIndex].m_Index,0);
  7641. int PlayerBaseBlessCount = SQL.GetBlessPlayer(lpObj->Name);
  7642. if ( PlayerBlessCount < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
  7643. {
  7644. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Bless",
  7645. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7646. lpObj->AccountID, lpObj->Name);
  7647. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 7);
  7648.  
  7649. return;
  7650. }
  7651. DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7652.  
  7653.  
  7654. BYTE btNewItemPos = 0;
  7655. btNewItemPos = ::gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
  7656.  
  7657. iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type;
  7658. iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level;
  7659. iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
  7660. iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number;
  7661. ::gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
  7662. lpObj->Inventory1[lpMsg->btItemPos].Clear();
  7663. ::GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
  7664.  
  7665. DeleteCountBlessCharacter(aSourceIndex);
  7666. int CountJewel = PlayerBlessCount - dwCost;
  7667.  
  7668. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
  7669. ::CGPShopAnsSoldItem(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
  7670. if(SetCountBlessInventory(aSourceIndex,CountJewel) == false)
  7671. {
  7672.  
  7673. }
  7674. SQL.UpdateBlessPlayer(lpObj->Name,PlayerBaseBlessCount+dwCost);
  7675.  
  7676.  
  7677. if ( btNewItemPos == 0xFF )
  7678. {
  7679. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] No Room to Buy Item",
  7680. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7681. lpObj->AccountID, lpObj->Name);
  7682. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7683.  
  7684. return;
  7685. }
  7686. LogAddTD("[OffTrade][PShop] [%s][%s][%s] PShop Item Buy Request Succeed : [%s][%s][%s] (Price=%d Bless, ItemType:%d (%s), ItemLevel:%d, ItemDur:%d, Serial:%d",
  7687. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].Ip_addr,
  7688. lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE,
  7689. ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
  7690. }
  7691. else if (lpObj->OffTradeCredits == 1)
  7692. {
  7693. int CreditsCount = SQL.GetPlayerCredits(gObj[aSourceIndex].AccountID);
  7694. if (CreditsCount < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
  7695. {
  7696. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Credits",
  7697. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7698. lpObj->AccountID, lpObj->Name);
  7699. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 7);
  7700.  
  7701. return;
  7702. }
  7703.  
  7704.  
  7705.  
  7706. BYTE btNewItemPos = 0;
  7707. btNewItemPos = ::gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
  7708.  
  7709. iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type;
  7710. iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level;
  7711. iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
  7712. iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number;
  7713. ::gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
  7714. lpObj->Inventory1[lpMsg->btItemPos].Clear();
  7715. ::GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
  7716.  
  7717. /*
  7718. gObj[aSourceIndex].Credits -= lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7719. lpObj->Credits += lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7720. */
  7721. int Value = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7722. SQL.UpdateMinusCreditsPlayer(gObj[aSourceIndex].AccountID,Value);
  7723. SQL.UpdateCreditsPlayer(lpObj->AccountID,Value);
  7724. GDSetValutList(aSourceIndex);
  7725. GDSetValutList(lpObj->m_Index);
  7726. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
  7727. ::CGPShopAnsSoldItem(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
  7728.  
  7729. if ( btNewItemPos == 0xFF )
  7730. {
  7731. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] No Room to Buy Item",
  7732. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7733. lpObj->AccountID, lpObj->Name);
  7734. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7735.  
  7736. return;
  7737. }
  7738. LogAddTD("[OffTrade][PShop] [%s][%s][%s] PShop Item Buy Request Succeed : [%s][%s][%s] (Price=%d Credits, ItemType:%d (%s), ItemLevel:%d, ItemDur:%d, Serial:%d",
  7739. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].Ip_addr,
  7740. lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue, iITEM_LOG_TYPE,
  7741. ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
  7742. }
  7743. else
  7744. {
  7745. if ( gObj[aSourceIndex].Money < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue )
  7746. {
  7747. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Zen",
  7748. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7749. lpObj->AccountID, lpObj->Name);
  7750. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 7);
  7751.  
  7752. return;
  7753. }
  7754.  
  7755. DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue;
  7756.  
  7757. if ( gObjCheckMaxZen(lpObj->m_Index, dwCost) == FALSE )
  7758. {
  7759. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Exceeding Zen of the Host",
  7760. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7761. lpObj->AccountID, lpObj->Name);
  7762. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7763.  
  7764. return;
  7765. }
  7766.  
  7767. BYTE btNewItemPos = 0;
  7768. btNewItemPos = ::gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]);
  7769.  
  7770. iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type;
  7771. iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level;
  7772. iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability;
  7773. iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number;
  7774. ::gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1);
  7775. lpObj->Inventory1[lpMsg->btItemPos].Clear();
  7776. ::GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE);
  7777. gObj[aSourceIndex].Money -= dwCost;
  7778. lpObj->Money += dwCost;
  7779. ::GCMoneySend(aSourceIndex, gObj[aSourceIndex].Money);
  7780. ::GCMoneySend(lpObj->m_Index, lpObj->Money);
  7781. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, btNewItemPos, 1);
  7782. ::CGPShopAnsSoldItem(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos);
  7783.  
  7784. if ( btNewItemPos == 0xFF )
  7785. {
  7786. LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] No Room to Buy Item",
  7787. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name,
  7788. lpObj->AccountID, lpObj->Name);
  7789. ::CGPShopAnsBuyItem(aSourceIndex, lpObj->m_Index, 0, 8);
  7790.  
  7791. return;
  7792. }
  7793. LogAddTD("[OffTrade][PShop] [%s][%s][%s] PShop Item Buy Request Succeed : [%s][%s][%s] (Price=%d , ItemType:%d (%s), ItemLevel:%d, ItemDur:%d, Serial:%d",
  7794. gObj[aSourceIndex].AccountID, gObj[aSourceIndex].Name, gObj[aSourceIndex].Ip_addr,
  7795. lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE,
  7796. ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL);
  7797.  
  7798.  
  7799.  
  7800.  
  7801. }
  7802. if (PShop_CheckInventoryEmpty(lpObj->m_Index) == true )
  7803. {
  7804. LogAddTD("[PShop] [%s][%s] Sold All Items - Auto Closing PShop",
  7805. lpObj->AccountID, lpObj->Name);::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 195)), lpObj->m_Index, 1);
  7806. lpObj->m_bPShopOpen = false;
  7807. memset(lpObj->m_szPShopText, 0, sizeof(lpObj->m_szPShopText));
  7808. ::CGPShopAnsClose(lpObj->m_Index, 1);
  7809. }
  7810. else
  7811. {
  7812. lpObj->m_bPShopItemChange = true;
  7813. }
  7814.  
  7815. }
  7816. }
  7817. __finally
  7818. {
  7819. lpObj->m_bPShopTransaction = false;
  7820. }
  7821. }
  7822. }
  7823.  
  7824.  
  7825.  
  7826.  
  7827.  
  7828. struct PMSG_ANS_BUYITEM_FROM_PSHOP
  7829. {
  7830. PBMSG_HEAD2 h; // C1:3F:06
  7831. BYTE Result; // 3
  7832. BYTE NumberH; // 5
  7833. BYTE NumberL; // 6
  7834. BYTE cItemInfo[7]; // 7
  7835. BYTE btItemPos; // E
  7836. };
  7837.  
  7838.  
  7839. void CGPShopAnsBuyItem(int aSourceIndex, int aTargetIndex, int iItemPos, BYTE btResult)
  7840. {
  7841. PMSG_ANS_BUYITEM_FROM_PSHOP pMsg;
  7842.  
  7843. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x06, sizeof(pMsg));
  7844. pMsg.NumberH = SET_NUMBERH(aTargetIndex);
  7845. pMsg.NumberL = SET_NUMBERL(aTargetIndex);
  7846. pMsg.btItemPos = iItemPos;
  7847. pMsg.Result = btResult;
  7848. ItemByteConvert(pMsg.cItemInfo, gObj[aSourceIndex].Inventory1[iItemPos]);
  7849.  
  7850. DataSend(aSourceIndex, (LPBYTE)&pMsg, pMsg.h.size);
  7851. }
  7852.  
  7853.  
  7854.  
  7855.  
  7856. struct PMSG_ANS_SOLDITEM_FROM_PSHOP
  7857. {
  7858. PBMSG_HEAD2 h; // C1:3F:08
  7859. BYTE btItemPos; // 4
  7860. BYTE btName[10]; // 5
  7861. };
  7862.  
  7863.  
  7864. void CGPShopReqCloseDeal(PMSG_REQ_PSHOPDEAL_CLOSE * lpMsg, int aIndex)
  7865. {
  7866. if ( !gObjIsConnected(aIndex))
  7867. return;
  7868.  
  7869. gObj[aIndex].m_bPShopWantDeal = false;
  7870. gObj[aIndex].m_iPShopDealerIndex =-1;
  7871. memset(gObj[aIndex].m_szPShopDealerName , 0, MAX_ACCOUNT_LEN);
  7872. }
  7873.  
  7874.  
  7875.  
  7876.  
  7877. void CGPShopAnsSoldItem(int aSourceIndex, int aTargetIndex, int iItemPos)
  7878. {
  7879. PMSG_ANS_SOLDITEM_FROM_PSHOP pMsg;
  7880.  
  7881. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x08, sizeof(pMsg));
  7882. pMsg.btItemPos = iItemPos;
  7883. memcpy(pMsg.btName, gObj[aTargetIndex].Name, MAX_ACCOUNT_LEN);
  7884.  
  7885. DataSend(aSourceIndex, (LPBYTE)&pMsg, pMsg.h.size);
  7886. }
  7887.  
  7888.  
  7889.  
  7890.  
  7891. struct PMSG_REQ_DEALER_CLOSED_SHOP
  7892. {
  7893. PBMSG_HEAD2 h; // C1:3F:12
  7894. BYTE NumberH; // 4
  7895. BYTE NumberL; // 5
  7896. };
  7897.  
  7898.  
  7899. void CGPShopAnsDealerClosedShop(int aSourceIndex, int aTargetIndex)
  7900. {
  7901. PMSG_REQ_DEALER_CLOSED_SHOP pMsg;
  7902.  
  7903. PHeadSubSetB((LPBYTE)&pMsg, 0x3F, 0x12, sizeof(pMsg));
  7904. pMsg.NumberH = SET_NUMBERH(aTargetIndex);
  7905. pMsg.NumberL = SET_NUMBERL(aTargetIndex);
  7906.  
  7907. DataSend(aSourceIndex, (LPBYTE)&pMsg, pMsg.h.size);
  7908. }
  7909.  
  7910.  
  7911.  
  7912.  
  7913. struct PMSG_PARTYREQUESTSEND
  7914. {
  7915. PBMSG_HEAD h; // C1:40
  7916. BYTE NumberH; // 3
  7917. BYTE NumberL; // 4
  7918. };
  7919.  
  7920.  
  7921. void CGPartyRequestRecv(PMSG_PARTYREQUEST * lpMsg, int aIndex)
  7922. {
  7923. int number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  7924. PMSG_PARTYREQUESTSEND pMsg;
  7925.  
  7926. if ( number < 0 || number > OBJMAX-1)
  7927. return;
  7928.  
  7929. #ifdef PARTY_HELPER
  7930. if (gObj[number].PartyHelper == true)
  7931. {
  7932. LogAdd("[DEBUG][PartyHelper]Give Party , aIndex : %d , PartyHelper : %d", aIndex, number);
  7933. m_PartyHelper.AddParty(aIndex, number, 1);
  7934. return;
  7935. }
  7936. #endif
  7937. if (!PacketCheckTime(&gObj[aIndex]))
  7938. return;
  7939.  
  7940. if ( !gObjIsConnected(&gObj[number]))
  7941. {
  7942. ::GCResultSend(aIndex, 0x41, 0x03);
  7943. return;
  7944. }
  7945.  
  7946. if ( gObj[aIndex].CloseCount >= 0 || gObj[number].CloseCount >= 0 )
  7947. {
  7948. ::GCResultSend(aIndex, 0x41, 0x00);
  7949. return;
  7950. }
  7951.  
  7952. if ( CC_MAP_RANGE(gObj[aIndex].MapNumber) )
  7953. {
  7954. ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 198)), aIndex, 1);
  7955. return;
  7956. }
  7957. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) ) //season 2.5 add-on
  7958. {
  7959. ::GCServerMsgStringSend(lMsg.Get(3397), aIndex, 1);
  7960. return;
  7961. }
  7962. #if (FOREIGN_GAMESERVER==1)
  7963. if ( szAuthKey[4] != AUTHKEY4 )
  7964. DestroyGIocp();
  7965. #endif
  7966.  
  7967. LogAddL("Party result : %d %d %d %d", gObj[aIndex].CloseCount, gObj[number].CloseCount, gObj[aIndex].Connected, gObj[number].Connected);
  7968. LogAddL("%s %s", gObj[aIndex].Name, gObj[number].Name);
  7969.  
  7970. if ( gObj[aIndex].m_IfState.use > 0 )
  7971. {
  7972. ::GCResultSend(aIndex, 0x41, 0x00);
  7973. return;
  7974. }
  7975.  
  7976. if ( gObj[number].m_IfState.use > 0 )
  7977. {
  7978. ::GCResultSend(aIndex, 0x41, 0x00);
  7979. return;
  7980. }
  7981.  
  7982. if ( (gObj[number].m_Option &1) != TRUE )
  7983. {
  7984. ::GCResultSend(aIndex, 0x41, 0x01);
  7985. return;
  7986. }
  7987.  
  7988. if ( gObj[aIndex].PartyNumber >= 0 )
  7989. {
  7990. int iUserIndex;
  7991. int iDbNumber;
  7992. gParty.GetIndexUser(gObj[aIndex].PartyNumber, 0, iUserIndex, iDbNumber);
  7993.  
  7994. if ( iUserIndex < 0 || ( iUserIndex != aIndex && gObj[aIndex].DBNumber != iDbNumber ) )
  7995. {
  7996. ::GCResultSend(aIndex, 0x41, 0x00);
  7997. return;
  7998.  
  7999. }
  8000. }
  8001.  
  8002. if ( gObj[aIndex].PartyTargetUser >= 0 )
  8003. return;
  8004.  
  8005. if ( gObj[number].PartyNumber >= 0 )
  8006. {
  8007. ::GCResultSend(aIndex, 0x41, 0x04);
  8008. return;
  8009. }
  8010.  
  8011. if ( gObj[number].PartyTargetUser >= 0 )
  8012. {
  8013. ::GCResultSend(aIndex, 0x41, 0x00);
  8014. return;
  8015. }
  8016.  
  8017. int maxlevel = 0;
  8018. int minlevel = 0;
  8019. if (PartyDeference_Active == 1)
  8020. {
  8021. if (gObj[number].PartyNumber >= 0)
  8022. {
  8023. if (gParty.GetLevel(gObj[number].PartyNumber, maxlevel, minlevel) == TRUE)
  8024. {
  8025. int limmaxlevel;
  8026. int limmaxlevel2;
  8027.  
  8028. if (maxlevel > gObj[number].Level)
  8029. limmaxlevel = maxlevel;
  8030. else
  8031. limmaxlevel = gObj[number].Level;
  8032.  
  8033. if (maxlevel < gObj[number].Level)
  8034. limmaxlevel2 = maxlevel;
  8035. else
  8036. limmaxlevel2 = gObj[number].Level;
  8037.  
  8038. if ((limmaxlevel - limmaxlevel2) > PartyDeference_Level)
  8039. {
  8040. ::GCResultSend(aIndex, 0x41, 0x05);
  8041. LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level);
  8042. return;
  8043. }
  8044.  
  8045. int limminlevel;
  8046. int limminlevel2;
  8047.  
  8048. if (maxlevel > gObj[number].Level)
  8049. limminlevel = minlevel;
  8050. else
  8051. limminlevel = gObj[number].Level;
  8052.  
  8053. if (maxlevel < gObj[number].Level)
  8054. limminlevel2 = minlevel;
  8055. else
  8056. limminlevel2 = gObj[number].Level;
  8057.  
  8058. if ((limminlevel - limminlevel2) > PartyDeference_Level)
  8059. {
  8060. ::GCResultSend(aIndex, 0x41, 0x05);
  8061. // Restricted level for the party is %d
  8062. // DEATHWAY FIX HERE
  8063. LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level);
  8064. return;
  8065. }
  8066. }
  8067. }
  8068. else
  8069. {
  8070. short sMaxMinLevel[2];
  8071.  
  8072. if (gObj[aIndex].Level > gObj[number].Level)
  8073. sMaxMinLevel[1] = gObj[aIndex].Level;
  8074. else
  8075. sMaxMinLevel[1] = gObj[number].Level;
  8076.  
  8077. if (gObj[aIndex].Level < gObj[number].Level)
  8078. sMaxMinLevel[0] = gObj[aIndex].Level;
  8079. else
  8080. sMaxMinLevel[0] = gObj[number].Level;
  8081.  
  8082. if ((sMaxMinLevel[1] - sMaxMinLevel[0]) >PartyDeference_Level)
  8083. {
  8084. ::GCResultSend(aIndex, 0x41, 0x05);
  8085. // Restricted level for the party is %d
  8086. // DEATHWAY FIX HERE
  8087. LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level);
  8088. return;
  8089. }
  8090. }
  8091. }
  8092. gObj[aIndex].m_IfState.use = TRUE;
  8093. gObj[aIndex].m_IfState.type = 2;
  8094. gObj[aIndex].m_IfState.state = 0;
  8095. gObj[number].m_IfState.use = TRUE;
  8096. gObj[number].m_IfState.type = 2;
  8097. gObj[number].m_IfState.state = 0;
  8098. gObj[aIndex].TargetNumber = number;
  8099. gObj[number].TargetNumber = aIndex;
  8100. gObj[aIndex].m_InterfaceTime = GetTickCount();
  8101. gObj[number].m_InterfaceTime = GetTickCount();
  8102. gObj[aIndex].PartyTargetUser = number;
  8103.  
  8104. PHeadSetB((LPBYTE)&pMsg, 0x40, sizeof(pMsg));
  8105. pMsg.NumberH = SET_NUMBERH(aIndex);
  8106. pMsg.NumberL = SET_NUMBERL(aIndex);
  8107.  
  8108. DataSend(number, (LPBYTE)&pMsg, pMsg.h.size);
  8109. }
  8110.  
  8111.  
  8112.  
  8113.  
  8114.  
  8115. void CGPartyRequestResultRecv(PMSG_PARTYREQUESTRESULT * lpMsg, int aIndex)
  8116. {
  8117. int number;
  8118. BYTE result = false;
  8119. char szTemp[256];
  8120. int pnumber = -1;
  8121.  
  8122. if ( !PacketCheckTime(&gObj[aIndex]))
  8123. return;
  8124.  
  8125. number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  8126.  
  8127. if ( number < 0 || number > OBJMAX-1)
  8128. return;
  8129.  
  8130. if ( !gObjIsConnected(&gObj[aIndex]))
  8131. return;
  8132.  
  8133. if ( !gObjIsConnected(&gObj[number]))
  8134. {
  8135. GCResultSend(aIndex, 0x41, 0x04);
  8136. }
  8137. else
  8138. {
  8139. result = true;
  8140. }
  8141.  
  8142. if ( gObj[number].MapNumber != gObj[aIndex].MapNumber )
  8143. {
  8144. result = false;
  8145. GCResultSend(number, 0x41, 0x00);
  8146. }
  8147.  
  8148. if ( CC_MAP_RANGE(gObj[aIndex].MapNumber) )
  8149. {
  8150. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 198)), aIndex, 1);
  8151. result = false;
  8152. ::GCResultSend(number, 0x41, 0x00);
  8153. }
  8154.  
  8155. if ( lpMsg->Result == 0 )
  8156. {
  8157. result = false;
  8158. ::GCResultSend(number, 0x41, 0x01);
  8159. }
  8160. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) ) //season 2.5 add-on
  8161. {
  8162. result = false;
  8163. ::GCResultSend(number, 0x41, 0x00);
  8164. }
  8165. if ( gObj[number].m_IfState.use == 0 || gObj[number].m_IfState.type != 2)
  8166. {
  8167. result = false;
  8168. ::GCResultSend(number, 0x41, 0x00);
  8169. }
  8170.  
  8171. if ( gObj[aIndex].m_IfState.use == 0 || gObj[aIndex].m_IfState.type != 2)
  8172. {
  8173. result = false;
  8174. ::GCResultSend(number, 0x41, 0x00);
  8175. }
  8176.  
  8177. if ( result == 1 )
  8178. {
  8179. if ( gObj[number].PartyNumber < 0 )
  8180. {
  8181. gObj[number].PartyNumber = gParty.Create(number, gObj[number].DBNumber, gObj[number].Level);
  8182. }
  8183.  
  8184. if ( gObj[number].PartyNumber >= 0 )
  8185. {
  8186. pnumber = gObj[number].PartyNumber;
  8187. int iPartyPos = gParty.Add(gObj[number].PartyNumber, aIndex, gObj[aIndex].DBNumber, gObj[aIndex].Level);
  8188.  
  8189. if ( iPartyPos >= 0 )
  8190. {
  8191. gObj[aIndex].PartyNumber = gObj[number].PartyNumber;
  8192. result = true;
  8193. wsprintf(szTemp, lMsg.Get(MSGGET(4, 83)), gObj[aIndex].Name);
  8194. ::GCServerMsgStringSend(szTemp, number, 1);
  8195. wsprintf(szTemp, lMsg.Get(MSGGET(4, 83)), gObj[number].Name);
  8196. ::GCServerMsgStringSend(szTemp, aIndex, 1);
  8197.  
  8198. gParty.Paint(pnumber);
  8199. }
  8200. else if ( iPartyPos == -1 )
  8201. {
  8202. GCResultSend(number, 0x41, 2);
  8203. GCResultSend(aIndex, 0x41, 2);
  8204. }
  8205. else if ( iPartyPos == -2 )
  8206. {
  8207. result = 2;
  8208. wsprintf(szTemp, lMsg.Get(MSGGET(4, 84)), gObj[aIndex].Name);
  8209. GCServerMsgStringSend(szTemp, aIndex, 1);
  8210. }
  8211. }
  8212. }
  8213.  
  8214. if ( gObj[aIndex].m_IfState.use != 0 && gObj[aIndex].m_IfState.type == 2)
  8215. {
  8216. gObj[aIndex].m_IfState.use = 0;
  8217. gObj[aIndex].PartyTargetUser = -1;
  8218. }
  8219.  
  8220. if ( gObj[number].m_IfState.use != 0 && gObj[number].m_IfState.type == 2)
  8221. {
  8222. gObj[number].m_IfState.use = 0;
  8223. gObj[number].PartyTargetUser = -1;
  8224. }
  8225.  
  8226. if ( pnumber >= 0 )
  8227. {
  8228. CGPartyListAll(pnumber);
  8229. }
  8230. }
  8231.  
  8232.  
  8233.  
  8234. struct PMSG_PARTYLIST
  8235. {
  8236. char szId[10]; // 0
  8237. BYTE Number; // A
  8238. BYTE MapNumber; // B
  8239. BYTE X; // C
  8240. BYTE Y; // D
  8241. int Life; // 10
  8242. int MaxLife; // 14
  8243. };
  8244.  
  8245.  
  8246. struct PMSG_PARTYLISTCOUNT
  8247. {
  8248. PBMSG_HEAD h; // C1:42
  8249. BYTE Result; // 3
  8250. BYTE Count; // 4
  8251. };
  8252.  
  8253.  
  8254.  
  8255. void CGPartyList(int aIndex)
  8256. {
  8257. PMSG_PARTYLISTCOUNT pCount;
  8258. PMSG_PARTYLIST pList;
  8259. BYTE sendbuf[512];
  8260. int lOfs = 0;
  8261.  
  8262. if ( !PacketCheckTime(&gObj[aIndex]))
  8263. return;
  8264.  
  8265. PHeadSetB((LPBYTE)&pCount, 0x42, sizeof(pCount));
  8266. pCount.Count = 0;
  8267. pCount.Result = false;
  8268.  
  8269. int number;
  8270. int pnumber = gObj[aIndex].PartyNumber ;
  8271.  
  8272. if ( pnumber >= 0 )
  8273. pCount.Count = gParty.GetCount(pnumber);
  8274.  
  8275. lOfs += sizeof(pCount);
  8276.  
  8277. if ( pCount.Count != 0 )
  8278. {
  8279. for ( int n=0;n<MAX_USER_IN_PARTY;n++)
  8280. {
  8281. number = gParty.m_PartyS[pnumber].Number[n];
  8282.  
  8283. if ( number >= 0 )
  8284. {
  8285. if ( gObjIsConnected(&gObj[number], gParty.m_PartyS[pnumber].DbNumber[n]) == TRUE )
  8286. {
  8287. memset(&pList, 0, sizeof(pList));
  8288. memcpy(pList.szId, gObj[number].Name, MAX_ACCOUNT_LEN);
  8289. pList.Number = n;
  8290. pList.MapNumber = gObj[number].MapNumber;
  8291. pList.X = gObj[number].X;
  8292. pList.Y = gObj[number].Y;
  8293. pList.Life = gObj[number].Life;
  8294. pList.MaxLife = gObj[number].MaxLife + gObj[number].AddLife;
  8295.  
  8296. memcpy(&sendbuf[lOfs], &pList, sizeof(pList));
  8297. lOfs += sizeof(pList);
  8298. }
  8299. }
  8300. }
  8301.  
  8302. pCount.Result = true;
  8303. }
  8304.  
  8305. pCount.h.size = lOfs;
  8306. memcpy(sendbuf, &pCount, sizeof(pCount));
  8307.  
  8308. DataSend(aIndex, (LPBYTE)&sendbuf, lOfs);
  8309. }
  8310.  
  8311.  
  8312.  
  8313.  
  8314. void CGPartyListAll(int pnumber)
  8315. {
  8316. PMSG_PARTYLISTCOUNT pCount;
  8317. PMSG_PARTYLIST pList;
  8318. BYTE sendbuf[512];
  8319. int lOfs = 0;
  8320. int number;
  8321.  
  8322. if ( pnumber < 0 )
  8323. return;
  8324.  
  8325. if ( gParty.IsParty(pnumber) == FALSE )
  8326. return;
  8327.  
  8328. PHeadSetB((LPBYTE)&pCount, 0x42, sizeof(pCount));
  8329. pCount.Result = false;
  8330. pCount.Count = gParty.GetCount(pnumber);
  8331.  
  8332. if ( pCount.Count == 0 )
  8333. return;
  8334.  
  8335. pCount.Result = true;
  8336. lOfs += sizeof(pCount);
  8337.  
  8338. for ( int n=0;n<MAX_USER_IN_PARTY;n++)
  8339. {
  8340. number = gParty.m_PartyS[pnumber].Number[n];
  8341.  
  8342. if ( number >= 0 )
  8343. {
  8344. if ( gObjIsConnected(&gObj[number], gParty.m_PartyS[pnumber].DbNumber[n]) == TRUE )
  8345. {
  8346. memset(&pList, 0, sizeof(pList));
  8347. memcpy(pList.szId, gObj[number].Name, MAX_ACCOUNT_LEN);
  8348. pList.Number = n;
  8349. pList.MapNumber = gObj[number].MapNumber;
  8350. pList.X = gObj[number].X;
  8351. pList.Y = gObj[number].Y;
  8352. pList.Life = gObj[number].Life;
  8353. pList.MaxLife = gObj[number].MaxLife;
  8354.  
  8355. memcpy(&sendbuf[lOfs], &pList, sizeof(pList));
  8356. lOfs += sizeof(pList);
  8357. }
  8358. }
  8359. }
  8360.  
  8361. pCount.h.size = lOfs;
  8362. memcpy(sendbuf, &pCount, sizeof(pCount));
  8363.  
  8364. for (int n = 0; n < MAX_USER_IN_PARTY; n++)
  8365. {
  8366. number = gParty.m_PartyS[pnumber].Number[n];
  8367.  
  8368. if ( number >= 0 )
  8369. {
  8370. DataSend(number, sendbuf, lOfs);
  8371. }
  8372. }
  8373. }
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379. void CGPartyDelUser(PMSG_PARTYDELUSER * lpMsg, int aIndex)
  8380. {
  8381. int usernumber = -1;
  8382. int dbnumber = -1;
  8383.  
  8384. if ( gObj[aIndex].PartyNumber < 0 )
  8385. {
  8386. LogAdd("No Party %s %s", gObj[aIndex].AccountID, gObj[aIndex].Name);
  8387. return;
  8388. }
  8389.  
  8390. if ( !gParty.GetIndexUser(gObj[aIndex].PartyNumber, lpMsg->Number, usernumber, dbnumber))
  8391. {
  8392. LogAdd("User Not found");
  8393. return;
  8394. }
  8395.  
  8396. if ( usernumber < 0 )
  8397. {
  8398. LogAdd("User Not found");
  8399. return;
  8400. }
  8401.  
  8402. int count;
  8403. int number;
  8404. int pnumber = gObj[aIndex].PartyNumber;
  8405.  
  8406. if ( pnumber < 0 )
  8407. {
  8408. LogAdd("%s %d", __FILE__, __LINE__);
  8409. return;
  8410. }
  8411.  
  8412. count = gParty.GetCount(pnumber);
  8413.  
  8414. if ( count < 1 )
  8415. {
  8416. LogAdd("%s %d", __FILE__, __LINE__);
  8417. return;
  8418. }
  8419.  
  8420.  
  8421.  
  8422. if ( lpMsg->Number == 0 )
  8423. {
  8424. if ( count >= 2 )
  8425. {
  8426. gParty.Delete(pnumber, lpMsg->Number);
  8427. count = gParty.GetCount(gObj[aIndex].PartyNumber);
  8428. gObj[usernumber].PartyNumber = -1;
  8429. gObj[usernumber].PartyTargetUser = -1;
  8430. //gParty.UpdatePKPartyPanalty(pnumber);
  8431. //if(gChangeLeader == 1)
  8432. //{
  8433. // gParty.ChangeLeader(pnumber);
  8434. //}
  8435. GCPartyDelUserSend(usernumber);
  8436. CGPartyListAll(pnumber);
  8437. return;
  8438. }
  8439. }
  8440.  
  8441.  
  8442.  
  8443. if ( lpMsg->Number == 0 || count <= 2 )
  8444. {
  8445. if (IT_MAP_RANGE(gObj[usernumber].MapNumber) != FALSE ) //season 2.5 add-on
  8446. {
  8447. if (lpMsg->Number == 0 && count > 2 )
  8448. {
  8449. gParty.Delete(pnumber, lpMsg->Number);
  8450. count = gParty.GetCount(gObj[aIndex].PartyNumber);
  8451.  
  8452. gObj[usernumber].PartyNumber = -1;
  8453. gObj[usernumber].PartyTargetUser = -1;
  8454.  
  8455. gParty.SetPkCount(pnumber);
  8456. gParty.ResetPkLevel(pnumber);
  8457. GCPartyDelUserSend(usernumber);
  8458.  
  8459. CGPartyListAll(pnumber);
  8460.  
  8461. if (count == 0)
  8462. {
  8463. gParty.Destroy(pnumber);
  8464. }
  8465. return;
  8466. }
  8467. }
  8468. if (IT_MAP_RANGE(gObj[usernumber].MapNumber) != FALSE ) //season 2.5 add-on
  8469. {
  8470. if (count <= 2 )
  8471. {
  8472. gParty.Delete(pnumber, lpMsg->Number);
  8473. count = gParty.GetCount(gObj[aIndex].PartyNumber);
  8474.  
  8475. gObj[usernumber].PartyNumber = -1;
  8476. gObj[usernumber].PartyTargetUser = -1;
  8477.  
  8478. gParty.SetPkCount(pnumber);
  8479.  
  8480. if (lpMsg == NULL)
  8481. {
  8482. gParty.ResetPkLevel(pnumber);
  8483. }
  8484.  
  8485. GCPartyDelUserSend(usernumber);
  8486. CGPartyListAll(pnumber);
  8487. return;
  8488. }
  8489. }
  8490. if (lpMsg->Number == 0 || count <= 2)
  8491. {
  8492. for (int n = 0; n < MAX_USER_IN_PARTY; n++)
  8493. {
  8494. number = gParty.m_PartyS[pnumber].Number[n];
  8495.  
  8496. if (number >= 0)
  8497. {
  8498. gParty.Delete(pnumber, n);
  8499. gObj[number].PartyNumber = -1;
  8500. gObj[number].PartyTargetUser = -1;
  8501. GCPartyDelUserSend(number);
  8502. }
  8503. }
  8504.  
  8505. gParty.Destroy(pnumber);
  8506. }
  8507. }
  8508. else
  8509. {
  8510. gParty.Delete(pnumber, lpMsg->Number);
  8511. count = gParty.GetCount(gObj[aIndex].PartyNumber);
  8512. gObj[usernumber].PartyNumber = -1;
  8513. gObj[usernumber].PartyTargetUser = -1;
  8514. GCPartyDelUserSend(usernumber);
  8515. CGPartyListAll(pnumber);
  8516. }
  8517. }
  8518.  
  8519. struct PMSG_PARTYDELUSERSEND
  8520. {
  8521. PBMSG_HEAD h; // C1:43
  8522. };
  8523.  
  8524.  
  8525.  
  8526. void GCPartyDelUserSend(int aIndex)
  8527. {
  8528. PMSG_PARTYDELUSERSEND pMsg;
  8529.  
  8530. PHeadSetB((LPBYTE)&pMsg, 0x43, sizeof(pMsg));
  8531.  
  8532. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  8533. }
  8534.  
  8535.  
  8536. struct PMSG_GUILDQUESTSEND
  8537. {
  8538. PBMSG_HEAD h; // C1:50
  8539. BYTE NumberH; // 3
  8540. BYTE NumberL; // 4
  8541. };
  8542.  
  8543.  
  8544. void CGGuildRequestRecv(PMSG_GUILDJOINQ * lpMsg, int aIndex)
  8545. {
  8546. PMSG_GUILDQUESTSEND pMsg;
  8547. int number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  8548.  
  8549. if ( number < 0 || number > OBJMAX-1 )
  8550. return;
  8551.  
  8552. if ( !PacketCheckTime(&gObj[aIndex]))
  8553. return;
  8554.  
  8555. if ( g_CastleSiegeSync.GetCastleState() == CASTLESIEGE_STATE_STARTSIEGE )
  8556. {
  8557. MsgOutput(aIndex, lMsg.Get(MSGGET(6,194)));
  8558. return;
  8559. }
  8560. if ( IT_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE ) //season 2.5 add-on
  8561. {
  8562. MsgOutput(aIndex,(lMsg.Get(3398)));
  8563. return;
  8564. }
  8565.  
  8566. if ( !gObjIsConnected(&gObj[number]))
  8567. {
  8568. GCResultSend(aIndex, 0x51, 0x03);
  8569. return;
  8570. }
  8571.  
  8572. if ( gObj[aIndex].m_IfState.use > 0 )
  8573. {
  8574. GCResultSend(aIndex, 0x51, 0x06);
  8575. return;
  8576. }
  8577.  
  8578. if ( gObj[number].m_IfState.use > 0 )
  8579. {
  8580. GCResultSend(aIndex, 0x51, 0x06);
  8581. return;
  8582. }
  8583.  
  8584. if ( gObj[aIndex].Level < 6 )
  8585. {
  8586. GCResultSend(aIndex, 0x51, 0x07);
  8587. return;
  8588. }
  8589.  
  8590. if ( gObj[aIndex].GuildNumber > 0 )
  8591. {
  8592. GCResultSend(aIndex, 0x51, 0x05);
  8593. return;
  8594. }
  8595.  
  8596. if ( (gObj[number].m_Option&1 ) != 1 )
  8597. {
  8598. GCResultSend(aIndex, 0x51, 0x00);
  8599. return;
  8600. }
  8601.  
  8602. if ( gObj[number].GuildNumber > 0 )
  8603. {
  8604. if ( strcmp(gObj[number].lpGuild->Names[0], gObj[number].Name))
  8605. {
  8606. GCResultSend(aIndex, 0x51, 0x04);
  8607. return;
  8608. }
  8609.  
  8610. if ( gObj[number].lpGuild->WarState )
  8611. {
  8612. GCResultSend(aIndex, 0x51, 0x06);
  8613. return;
  8614. }
  8615.  
  8616. int MaxGuildMember;
  8617.  
  8618. if ( gObj[number].Class == CLASS_DARKLORD )
  8619. MaxGuildMember = gObj[number].Level / 10 + gObj[number].Leadership / 10;
  8620. else
  8621. MaxGuildMember = gObj[number].Level / 10;
  8622.  
  8623. if ( MaxGuildMember > MAX_USER_GUILD )
  8624. MaxGuildMember = MAX_USER_GUILD;
  8625.  
  8626. if ( gObj[number].lpGuild->TotalCount >= MaxGuildMember )
  8627. {
  8628. GCResultSend(aIndex, 0x51, 0x02);
  8629. return;
  8630. }
  8631. }
  8632. else
  8633. {
  8634. GCResultSend(aIndex, 0x51, 0x04);
  8635. return;
  8636. }
  8637.  
  8638. gObj[aIndex].m_IfState.use = 1;
  8639. gObj[aIndex].m_IfState.type = 4;
  8640. gObj[aIndex].m_IfState.state = 0;
  8641.  
  8642. gObj[number].m_IfState.use = 1;
  8643. gObj[number].m_IfState.type = 4;
  8644. gObj[number].m_IfState.state = 0;
  8645.  
  8646. gObj[aIndex].TargetNumber = number;
  8647. gObj[number].TargetNumber = aIndex;
  8648. gObj[aIndex].m_InterfaceTime = GetTickCount();
  8649. gObj[number].m_InterfaceTime = GetTickCount();
  8650.  
  8651. PHeadSetB((LPBYTE)&pMsg, 0x50, sizeof(pMsg));
  8652. pMsg.NumberH = SET_NUMBERH(aIndex);
  8653. pMsg.NumberL = SET_NUMBERL(aIndex);
  8654.  
  8655. DataSend(number, (LPBYTE)&pMsg, pMsg.h.size);
  8656.  
  8657. LogAddTD("[%s][%s] Guild Request - Join : %s",
  8658. gObj[aIndex].AccountID, gObj[aIndex].Name,
  8659. gObj[number].lpGuild->Name);
  8660. }
  8661.  
  8662.  
  8663.  
  8664.  
  8665. void CGGuildRequestResultRecv(PMSG_GUILDQRESULT * lpMsg, int aIndex)
  8666. {
  8667. int number;
  8668. BYTE result=0;
  8669. int pnumber=-1;
  8670.  
  8671. if ( !PacketCheckTime(&gObj[aIndex]))
  8672. return;
  8673.  
  8674. number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  8675.  
  8676. if ( number < 0 || number > OBJMAX-1)
  8677. return;
  8678.  
  8679. if ( !gObjIsConnected(&gObj[number]))
  8680. {
  8681. GCResultSend(aIndex, 0x51, 0x02);
  8682. }
  8683. else
  8684. {
  8685. result = 1;
  8686. }
  8687.  
  8688. if ( lpMsg->Result == 0 )
  8689. {
  8690. result = 0;
  8691. GCResultSend(number, 0x51, 0x00);
  8692. }
  8693.  
  8694. if ( result == 1 )
  8695. {
  8696. if ( gObj[aIndex].GuildNumber > 0 )
  8697. {
  8698. GDGuildMemberAdd(number, gObj[aIndex].lpGuild->Name, gObj[number].Name);
  8699. }
  8700. }
  8701.  
  8702. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 4)
  8703. gObj[aIndex].m_IfState.use = 0;
  8704.  
  8705. if ( gObj[number].m_IfState.use && gObj[number].m_IfState.type == 4)
  8706. gObj[number].m_IfState.use = 0;
  8707. }
  8708.  
  8709.  
  8710.  
  8711.  
  8712.  
  8713.  
  8714.  
  8715. struct PMSG_GUILDLIST
  8716. {
  8717. char Name[10]; // 0
  8718. BYTE Number; // A
  8719. BYTE ConnectAServer; // B
  8720. BYTE btGuildStatus; // C
  8721. };
  8722.  
  8723.  
  8724. struct PMSG_GUILDLISTCOUNT
  8725. {
  8726. PWMSG_HEAD h; // C2:52
  8727. BYTE Result; // 4
  8728. BYTE Count; // 5
  8729. int TotalScore; // 8
  8730. BYTE Score; // C
  8731. char szRivalGuild[9]; // D
  8732. };
  8733.  
  8734.  
  8735.  
  8736. void CGGuildListAll(int pnumber)
  8737. {
  8738. if ( gObj[pnumber].lpGuild == NULL )
  8739. return;
  8740.  
  8741. PMSG_GUILDLISTCOUNT pCount;
  8742. PMSG_GUILDLIST pList;
  8743. char sendbuf[1500];
  8744. int lOfs = 0;
  8745. int number;
  8746. int n;
  8747. int guildmaster = 0;
  8748.  
  8749. PHeadSetW((LPBYTE)&pCount, 0x52, 0);
  8750. pCount.Result = 0;
  8751. pCount.Count = 0;
  8752. lOfs += sizeof(pCount);
  8753. pCount.h.sizeH = SET_NUMBERH(lOfs);
  8754. pCount.h.sizeL = SET_NUMBERL(lOfs);
  8755.  
  8756. if ( gObj[pnumber].GuildNumber < 1 )
  8757. {
  8758. DataSend(pnumber, (LPBYTE)&pCount, lOfs);
  8759. return;
  8760. }
  8761.  
  8762. pCount.Count = gObj[pnumber].lpGuild->Count;
  8763. pCount.TotalScore = gObj[pnumber].lpGuild->TotalScore;
  8764. pCount.Score = gObj[pnumber].lpGuild->PlayScore;
  8765. memset(pCount.szRivalGuild, 0, sizeof(pCount.szRivalGuild));
  8766.  
  8767. if ( gObj[pnumber].lpGuild->iGuildRival )
  8768. memcpy(pCount.szRivalGuild, gObj[pnumber].lpGuild->szGuildRivalName, MAX_GUILD_LEN);
  8769.  
  8770. pCount.Result = 1;
  8771. guildmaster = 1;
  8772.  
  8773. if ( pCount.Count == 0 )
  8774. return;
  8775.  
  8776. pCount.Count = 0;
  8777.  
  8778. for ( n=0;n<MAX_USER_GUILD;n++)
  8779. {
  8780. number = gObj[pnumber].lpGuild->Use[n];
  8781.  
  8782. if ( number > 0 )
  8783. {
  8784. memset(&pList, 0, sizeof(pList));
  8785. memcpy(pList.Name, gObj[pnumber].lpGuild->Names[n], sizeof(pList.Name));
  8786. pList.Number = gObj[pnumber].lpGuild->pServer[n];
  8787. pList.ConnectAServer = (short)gObj[pnumber].lpGuild->pServer[n] & 0x7F;
  8788.  
  8789. if ( gObj[pnumber].lpGuild->pServer[n] >= 0 )
  8790. pList.ConnectAServer |= 0x80;
  8791.  
  8792. pList.btGuildStatus = gObj[pnumber].lpGuild->GuildStatus[n];
  8793. memcpy(&sendbuf[lOfs], &pList, sizeof(pList));
  8794. lOfs+= sizeof(pList);
  8795. pCount.Count++;
  8796. }
  8797. }
  8798.  
  8799. pCount.h.sizeH = SET_NUMBERH(lOfs);
  8800. pCount.h.sizeL = SET_NUMBERL(lOfs);
  8801. memcpy(sendbuf, (LPBYTE)&pCount, sizeof(pCount));
  8802.  
  8803. DataSend(pnumber, (LPBYTE)sendbuf, lOfs);
  8804. }
  8805.  
  8806.  
  8807. struct PMSG_GUILDDELUSER_RESULT
  8808. {
  8809. PBMSG_HEAD h; // C1:53
  8810. BYTE Result; // 3
  8811. };
  8812.  
  8813.  
  8814. void CGGuildDelUser(PMSG_GUILDDELUSER * lpMsg, int aIndex)
  8815. {
  8816.  
  8817. if ( !PacketCheckTime(&gObj[aIndex]))
  8818. return;
  8819.  
  8820. if ( g_CastleSiegeSync.GetCastleState() == CASTLESIEGE_STATE_STARTSIEGE )
  8821. {
  8822. MsgOutput(aIndex, lMsg.Get(MSGGET(6,195)));
  8823. return;
  8824. }
  8825.  
  8826. if ( gObj[aIndex].GuildNumber < 1 )
  8827. return;
  8828.  
  8829. char joomin[14];
  8830. char memberid[11];
  8831. char guildname[11];
  8832. PMSG_GUILDDELUSER_RESULT pMsg;
  8833.  
  8834. PHeadSetB((LPBYTE)&pMsg, 0x53, sizeof(pMsg));
  8835. pMsg.Result = 3;
  8836.  
  8837. if ( !gGuildDestroy )
  8838. {
  8839. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  8840. return;
  8841. }
  8842.  
  8843. memset(memberid, 0, sizeof(memberid));
  8844. memset(guildname, 0, sizeof(guildname));
  8845. memcpy(memberid, lpMsg->Name, MAX_ACCOUNT_LEN);
  8846. strcpy(guildname, gObj[aIndex].lpGuild->Name);
  8847.  
  8848. if ( !strcmp(gObj[aIndex].lpGuild->Names[0], gObj[aIndex].Name ))
  8849. {
  8850. memset(joomin, 0, sizeof(joomin));
  8851. memcpy(joomin, lpMsg->JoominNumber, 10);
  8852. if ( gGuildDelPersID == TRUE)
  8853. {
  8854. if ( gObjJoominCheck(aIndex, joomin) != TRUE )
  8855. {
  8856. pMsg.Result = 0;
  8857. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  8858. return;
  8859. }
  8860. }
  8861. if ( !strcmp(memberid, gObj[aIndex].Name ))
  8862. {
  8863. if ( g_bCastleGuildDestoyLimit )
  8864. {
  8865. if ( strcmp(gObj[aIndex].lpGuild->Name, g_CastleSiege.GetCastleOwnerGuild()) == 0 )
  8866. {
  8867. MsgOutput(aIndex, lMsg.Get(MSGGET(6,189)));
  8868. return;
  8869. }
  8870. }
  8871. if(gObj[aIndex].lpGuild->WarState > 0)
  8872. {
  8873. gObjGuildWarMasterClose(&gObj[aIndex]);
  8874. }
  8875. GDGuildDestroySend(aIndex, gObj[aIndex].lpGuild->Name, gObj[aIndex].Name);
  8876. }
  8877. else
  8878. {
  8879. GDGuildMemberDel(aIndex, guildname, memberid);
  8880. }
  8881.  
  8882. LogAddTD("[%s][%s] Guild Request - Dismiss All : %s",
  8883. gObj[aIndex].AccountID,gObj[aIndex].Name, guildname);
  8884. #ifdef CUSTOM_PROPENSITY_SYSTEM
  8885. gObj[aIndex].GuildPropersity = 0;
  8886. #endif
  8887. }
  8888. else
  8889. {
  8890. if ( strcmp(memberid, gObj[aIndex].Name) )
  8891. {
  8892. pMsg.Result = 0;
  8893. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  8894. return;
  8895. }
  8896.  
  8897. memset(joomin, 0, sizeof(joomin));
  8898. memcpy(joomin, lpMsg->JoominNumber, 10);
  8899. if ( gGuildDelPersID == TRUE)
  8900. {
  8901. if ( gObjJoominCheck(aIndex, joomin) != TRUE )
  8902. {
  8903. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 108)), aIndex, 1);
  8904. return;
  8905. }
  8906. }
  8907. GDGuildMemberDel(aIndex, guildname, memberid);
  8908.  
  8909.  
  8910. LogAddTD("[%s][%s] Guild Request - Leave : %s",
  8911. gObj[aIndex].AccountID, gObj[aIndex].Name, guildname);
  8912. }
  8913. }
  8914.  
  8915.  
  8916.  
  8917.  
  8918. void GCGuildDelUserResult(int aIndex, BYTE Result)
  8919. {
  8920. PMSG_GUILDDELUSER_RESULT pMsg;
  8921.  
  8922. PHeadSetB((LPBYTE)&pMsg, 0x53, sizeof(pMsg));
  8923. pMsg.Result = Result;
  8924.  
  8925. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  8926. }
  8927.  
  8928.  
  8929.  
  8930.  
  8931. struct PMSG_GUILDMASTERQUESTION
  8932. {
  8933. PBMSG_HEAD h; // C1:54
  8934. };
  8935.  
  8936.  
  8937. void GCGuildMasterQuestionSend(int aIndex)
  8938. {
  8939. if ( gObj[aIndex].m_IfState.use > 0 )
  8940. {
  8941. return;
  8942. }
  8943.  
  8944. PMSG_GUILDMASTERQUESTION pMsg;
  8945.  
  8946. PHeadSetB((LPBYTE)&pMsg, 0x54, sizeof(pMsg));
  8947. gObj[aIndex].m_IfState.use = 1;
  8948. gObj[aIndex].m_IfState.type = 5;
  8949. gObj[aIndex].m_IfState.state = 0;
  8950.  
  8951. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  8952. }
  8953.  
  8954.  
  8955.  
  8956.  
  8957. void CGGuildMasterAnswerRecv(PMSG_GUILDMASTERANSWER * lpMsg, int aIndex)
  8958. {
  8959. if ( lpMsg->Result == 1 )
  8960. {
  8961. if ( !gObjGuildMasterCapacityTest(&gObj[aIndex]))
  8962. {
  8963. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 5 )
  8964. {
  8965. gObj[aIndex].m_IfState.use = 0;
  8966. }
  8967.  
  8968. return;
  8969. }
  8970.  
  8971. GCGuildMasterManagerRun(aIndex);
  8972. return;
  8973. }
  8974.  
  8975. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 5 )
  8976. {
  8977. gObj[aIndex].m_IfState.use = 0;
  8978. }
  8979. }
  8980.  
  8981.  
  8982.  
  8983. struct PMSG_GUILDMASTERMANAGER_RUN
  8984. {
  8985. PBMSG_HEAD h; // C1:55
  8986. };
  8987.  
  8988.  
  8989. void GCGuildMasterManagerRun(int aIndex)
  8990. {
  8991. PMSG_GUILDMASTERMANAGER_RUN pMsg;
  8992.  
  8993. PHeadSetB((LPBYTE)&pMsg, 0x55, sizeof(pMsg));
  8994.  
  8995. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  8996. }
  8997.  
  8998.  
  8999.  
  9000.  
  9001. void CGGuildMasterInfoSave(int aIndex, PMSG_GUILDINFOSAVE * lpMsg)
  9002. {
  9003. char GuildName[MAX_GUILD_LEN+1];
  9004. GuildName[MAX_GUILD_LEN] ='\0';
  9005. memcpy(GuildName, lpMsg->GuildName, MAX_GUILD_LEN);
  9006. int len = strlen(GuildName);
  9007.  
  9008. if ( len <= 2 || len > MAX_GUILD_LEN)
  9009. {
  9010. PMSG_GUILDCREATED_RESULT pMsg;
  9011.  
  9012. PHeadSetB((LPBYTE)&pMsg, 0x56, sizeof(pMsg));
  9013. pMsg.Result = 2;
  9014.  
  9015. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9016.  
  9017. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 5 )
  9018. {
  9019. gObj[aIndex].m_IfState.use = 0;
  9020. }
  9021.  
  9022. return;
  9023. }
  9024.  
  9025. GDGuildCreateSend(aIndex, GuildName, gObj[aIndex].Name, lpMsg->Mark, lpMsg->btGuildType);
  9026.  
  9027. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 5 )
  9028. {
  9029. gObj[aIndex].m_IfState.use = 0;
  9030. }
  9031. }
  9032.  
  9033.  
  9034.  
  9035.  
  9036. void CGGuildMasterCreateCancel(int aIndex)
  9037. {
  9038. if ( gObj[aIndex].GuildNumber > 0 )
  9039. return;
  9040.  
  9041. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 5 )
  9042. {
  9043. gObj[aIndex].m_IfState.use = 0;
  9044. }
  9045. }
  9046.  
  9047.  
  9048.  
  9049. void GCGuildViewportNowPaint(int aIndex, char* guildname, BYTE* mark, BOOL isGuildMaster)
  9050. {
  9051. _GUILD_INFO_STRUCT * lpGuild = Guild.SearchGuild(guildname);
  9052.  
  9053. if ( lpGuild == NULL )
  9054. return;
  9055.  
  9056. LPOBJ lpObj = &gObj[aIndex];
  9057. BYTE _GuildInfoBuf[256] = {0};
  9058. int _GuildInfoOfs = 5;
  9059.  
  9060. if ( lpObj->lpGuild == NULL )
  9061. return;
  9062.  
  9063.  
  9064. PMSG_SIMPLE_GUILDVIEWPORT pMsg;
  9065. pMsg.GuildNumber = lpObj->lpGuild->Number;
  9066. pMsg.NumberH = SET_NUMBERH(aIndex)&0x7F;
  9067. pMsg.NumberL = SET_NUMBERL(aIndex);
  9068.  
  9069. if ( isGuildMaster != FALSE )
  9070. pMsg.NumberH |= 0x80;
  9071.  
  9072.  
  9073. if ( isGuildMaster != FALSE )
  9074. pMsg.btGuildStatus = 0x80;
  9075. else
  9076. pMsg.btGuildStatus = lpObj->GuildStatus;
  9077.  
  9078. pMsg.btGuildType = lpObj->lpGuild->btGuildType;
  9079. pMsg.btGuildRelationShip = 0;
  9080. lpObj->iGuildUnionTimeStamp = 0;
  9081. memcpy(&_GuildInfoBuf[_GuildInfoOfs], &pMsg, sizeof(pMsg));
  9082. _GuildInfoOfs += sizeof(pMsg);
  9083.  
  9084. PMSG_SIMPLE_GUILDVIEWPORT_COUNT pGVCount;
  9085.  
  9086. pGVCount.h.c = 0xC2;
  9087. pGVCount.h.headcode = 0x65;
  9088. pGVCount.h.sizeH = SET_NUMBERH(_GuildInfoOfs);
  9089. pGVCount.h.sizeL = SET_NUMBERL(_GuildInfoOfs);
  9090. pGVCount.Count = 1;
  9091. memcpy(_GuildInfoBuf, &pGVCount, sizeof(pGVCount));
  9092.  
  9093. if ( !CC_MAP_RANGE(gObj[aIndex].MapNumber) )
  9094. DataSend(aIndex, _GuildInfoBuf, _GuildInfoOfs);
  9095.  
  9096. MsgSendV2(lpObj, _GuildInfoBuf, _GuildInfoOfs);
  9097. }
  9098.  
  9099.  
  9100.  
  9101.  
  9102. struct PMSG_GUILDDEL_VIEWPORT_NOW
  9103. {
  9104. PBMSG_HEAD h; // C1:5D
  9105. BYTE NumberH; // 3
  9106. BYTE NumberL; // 4
  9107. };
  9108.  
  9109.  
  9110.  
  9111.  
  9112. void GCGuildViewportDelNow(int aIndex, BOOL isGuildMaster)
  9113. {
  9114. PMSG_GUILDDEL_VIEWPORT_NOW pMsg;
  9115.  
  9116. LPOBJ lpObj = &gObj[aIndex];
  9117.  
  9118. PHeadSetB((LPBYTE)&pMsg, 0x5D, sizeof(pMsg));
  9119. pMsg.NumberH = SET_NUMBERH(aIndex) & 0x7F;
  9120. pMsg.NumberL = SET_NUMBERL(aIndex);
  9121.  
  9122. if ( isGuildMaster != FALSE )
  9123. {
  9124. pMsg.NumberH |= 0x80;
  9125. }
  9126.  
  9127. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9128. MsgSendV2(lpObj, (LPBYTE)&pMsg, pMsg.h.size);
  9129. }
  9130.  
  9131.  
  9132.  
  9133.  
  9134. void GCManagerGuildWarEnd(char * GuildName)
  9135. {
  9136. _GUILD_INFO_STRUCT * lpNode = Guild.SearchGuild(GuildName);
  9137.  
  9138. if ( lpNode == NULL )
  9139. {
  9140. return;
  9141. }
  9142.  
  9143. int n=0;
  9144. int warmaster = -1;
  9145.  
  9146. while ( true )
  9147. {
  9148. if ( gObj[n].Type == OBJ_USER )
  9149. {
  9150. if ( gObj[n].Connected > PLAYER_LOGGED )
  9151. {
  9152. if ( gObj[n].Name[0] == lpNode->Names[0][0] )
  9153. {
  9154. if ( strcmp(gObj[n].Name, lpNode->Names[0]) == 0 )
  9155. {
  9156. warmaster = n;
  9157. break;
  9158. }
  9159. }
  9160. }
  9161. }
  9162.  
  9163. if ( n < OBJMAX-1 )
  9164. {
  9165. n++;
  9166. }
  9167. else
  9168. {
  9169. break;
  9170. }
  9171. }
  9172.  
  9173. if ( warmaster >= 1 )
  9174. {
  9175. BYTE Result1 = 0;
  9176. BYTE Result2 = 0;
  9177.  
  9178. if ( lpNode != NULL )
  9179. {
  9180. if ( lpNode->lpTargetGuildNode != NULL )
  9181. {
  9182. if ( lpNode->PlayScore == 0 && lpNode->lpTargetGuildNode->PlayScore == 0 )
  9183. {
  9184. Result1 = 6;
  9185. Result2 = 6;
  9186. }
  9187. else
  9188. {
  9189. Result1 = 0;
  9190. Result2 = 1;
  9191. }
  9192. }
  9193. }
  9194.  
  9195. if ( lpNode->WarType == 1 )
  9196. {
  9197. gBattleGroundEnable(lpNode->BattleGroundIndex, FALSE );
  9198. gObjGuildWarEndSend(lpNode, lpNode->lpTargetGuildNode, Result1, Result2);
  9199. gObjGuildWarEnd(lpNode, lpNode->lpTargetGuildNode);
  9200.  
  9201. cManager.BattleInfoSend(::GetBattleTeamName(0, 0), -1, ::GetBattleTeamName(0, 1), -1);
  9202. }
  9203. else
  9204. {
  9205. gObjGuildWarEndSend(lpNode, lpNode->lpTargetGuildNode, Result1, Result2);
  9206. gObjGuildWarEnd(lpNode, lpNode->lpTargetGuildNode);
  9207. }
  9208. }
  9209. }
  9210.  
  9211.  
  9212.  
  9213.  
  9214. void GCManagerGuildWarSet(LPSTR GuildName1, LPSTR GuildName2, int type)
  9215. {
  9216. _GUILD_INFO_STRUCT * lpNode = Guild.SearchGuild(GuildName1);
  9217.  
  9218. if ( lpNode == NULL )
  9219. {
  9220. return;
  9221. }
  9222.  
  9223. int n=0;
  9224. int warmaster = -1;
  9225.  
  9226. while ( true )
  9227. {
  9228. if ( gObj[n].Type == OBJ_USER )
  9229. {
  9230. if ( gObj[n].Connected > PLAYER_LOGGED )
  9231. {
  9232. if ( gObj[n].Name[0] == lpNode->Names[0][0] )
  9233. {
  9234. if ( strcmp(gObj[n].Name, lpNode->Names[0]) == 0 )
  9235. {
  9236. warmaster = n;
  9237. break;
  9238. }
  9239. }
  9240. }
  9241. }
  9242.  
  9243. if ( n < OBJMAX-1 )
  9244. {
  9245. n++;
  9246. }
  9247. else
  9248. {
  9249. break;
  9250. }
  9251. }
  9252.  
  9253. if ( warmaster >= 1 )
  9254. {
  9255. ::GCGuildWarRequestResult(GuildName2, warmaster, type);
  9256. }
  9257. }
  9258.  
  9259.  
  9260.  
  9261. struct PMSG_GUILDWARREQUEST_RESULT
  9262. {
  9263. PBMSG_HEAD h; // C1:60
  9264. BYTE Result; // 3
  9265. };
  9266.  
  9267.  
  9268. void GCGuildWarRequestResult(LPSTR GuildName, int aIndex, int type)
  9269. {
  9270. PMSG_GUILDWARREQUEST_RESULT pMsg;
  9271.  
  9272. PHeadSetB((LPBYTE)&pMsg, 0x60, sizeof(pMsg));
  9273. pMsg.Result = 3;
  9274.  
  9275. if ( gObj[aIndex].GuildNumber < 1)
  9276. {
  9277. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9278. return;
  9279. }
  9280.  
  9281. _GUILD_INFO_STRUCT * lpMyGuild = gObj[aIndex].lpGuild;
  9282.  
  9283. if ( !lpMyGuild )
  9284. {
  9285. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9286. return;
  9287. }
  9288.  
  9289. if ( lpMyGuild->WarState == 1 || lpMyGuild->WarDeclareState == 1 )
  9290. {
  9291. pMsg.Result = 4;
  9292.  
  9293. //Error on declaring war : %d %d %s
  9294. LogAdd(lMsg.Get(MSGGET(1, 234)), lpMyGuild->WarState,
  9295. lpMyGuild->WarDeclareState, lpMyGuild->Name);
  9296. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9297.  
  9298. return;
  9299. }
  9300.  
  9301. if ( gPkLimitFree == FALSE && gObj[aIndex].m_PK_Level >= 6)
  9302. {
  9303. pMsg.Result = 4;
  9304.  
  9305. LogAdd("Error on declaring war : GuildMaster Is Murderer 0x04 %s %s",
  9306. lpMyGuild->Names[0], gObj[aIndex].Name);
  9307.  
  9308. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9309.  
  9310. return;
  9311. }
  9312.  
  9313. if ( strcmp(lpMyGuild->Names[0], gObj[aIndex].Name ) )
  9314. {
  9315. pMsg.Result = 5;
  9316.  
  9317. // Error on declaring war : 0x05 %s %s
  9318. LogAdd(lMsg.Get(MSGGET(1, 235)),
  9319. lpMyGuild->Names[0], gObj[aIndex].Name);
  9320. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9321.  
  9322. return;
  9323. }
  9324.  
  9325. char _guildname[MAX_GUILD_LEN+1];
  9326. memset(_guildname, 0, sizeof(_guildname));
  9327. memcpy(_guildname, GuildName, MAX_GUILD_LEN);
  9328.  
  9329. if ( !strncmp(lpMyGuild->Name, GuildName, MAX_GUILD_LEN))
  9330. return;
  9331.  
  9332. _GUILD_INFO_STRUCT * lpNode = Guild.SearchGuild(_guildname);
  9333.  
  9334. if ( lpNode )
  9335. {
  9336. if ( lpNode->WarState == 1 || lpNode->WarDeclareState == 1 )
  9337. {
  9338. pMsg.Result = 4;
  9339.  
  9340. //Error on declaring war : %d %d %s
  9341. LogAdd(lMsg.Get(MSGGET(1, 234)), lpNode->WarState,
  9342. lpNode->WarDeclareState, lpNode->Name);
  9343. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9344.  
  9345. return;
  9346. }
  9347.  
  9348. if ( lpMyGuild->iGuildUnion != 0 && lpMyGuild->iGuildUnion == lpNode->iGuildUnion )
  9349. {
  9350. LogAddTD("[U.System][Guildwar] Can't declare guildwar between Same Union (%s / %d) <-> (%s / %d)",
  9351. lpMyGuild->Name, lpMyGuild->iGuildUnion, lpNode->Name, lpMyGuild->iGuildUnion);
  9352.  
  9353. return;
  9354. }
  9355.  
  9356. int n=0; // #warning Change this 0 to OBJ_STARTUSERINDEX
  9357. int warmaster=-1;
  9358.  
  9359. while ( true )
  9360. {
  9361. if ( gObj[n].Type == OBJ_USER )
  9362. {
  9363. if ( gObj[n].Connected > PLAYER_LOGGED )
  9364. {
  9365. if ( gObj[n].Name[0] == lpNode->Names[0][0] )
  9366. {
  9367. if ( !strcmp(gObj[n].Name, lpNode->Names[0]))
  9368. {
  9369. if ( gPkLimitFree == FALSE && gObj[n].m_PK_Level >= 6)
  9370. {
  9371. pMsg.Result = 4;
  9372.  
  9373. LogAdd("Error on declaring war : Target GuildMaster Is Murderer 0x04 %s %s",
  9374. lpMyGuild->Names[0], gObj[aIndex].Name);
  9375.  
  9376. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9377.  
  9378. return;
  9379. }
  9380.  
  9381. warmaster = n;
  9382. break;
  9383. }
  9384. }
  9385. }
  9386. }
  9387.  
  9388. if ( n < OBJMAX-1 )
  9389. n++;
  9390. else
  9391. break;
  9392. }
  9393.  
  9394. if ( warmaster >= 1 )
  9395. {
  9396. if ( CC_MAP_RANGE(gObj[aIndex].MapNumber) || CC_MAP_RANGE(gObj[warmaster].MapNumber) )
  9397. {
  9398. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 199)), aIndex, 1);
  9399. return;
  9400. }
  9401.  
  9402. if ( (gObj[warmaster].m_Option&1) != 1 )
  9403. {
  9404. pMsg.Result = 4;
  9405. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9406.  
  9407. return;
  9408. }
  9409.  
  9410. pMsg.Result = 1;
  9411. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9412. GCGuildWarRequestSend(lpMyGuild->Name, warmaster, type);
  9413. lpMyGuild->WarDeclareState = 1;
  9414. lpNode->WarDeclareState = 1;
  9415. lpMyGuild->WarType = type;
  9416. lpNode->WarType = type;
  9417.  
  9418. // Declared guild war [%s][%s] sGuild:(%s) TargetGuild:(%s)
  9419. LogAddTD(lMsg.Get(MSGGET(1, 236)), gObj[aIndex].AccountID, gObj[aIndex].Name,
  9420. lpMyGuild->Name, lpNode->Name);
  9421.  
  9422. strcpy(lpMyGuild->TargetGuildName, lpNode->Name);
  9423. strcpy(lpNode->TargetGuildName, lpMyGuild->Name);
  9424. lpMyGuild->lpTargetGuildNode = lpNode;
  9425. lpNode->lpTargetGuildNode = lpMyGuild;
  9426. }
  9427. else
  9428. {
  9429. pMsg.Result = 2;
  9430. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9431.  
  9432. //return;
  9433. }
  9434. }
  9435. else
  9436. {
  9437. pMsg.Result = 0;
  9438. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9439.  
  9440. return;
  9441. }
  9442. }
  9443.  
  9444.  
  9445.  
  9446. struct PMSG_GUILDWARSEND
  9447. {
  9448. PBMSG_HEAD h; // C1:61
  9449. char GuildName[8]; // 3
  9450. BYTE Type; // B
  9451. };
  9452.  
  9453. #pragma warning ( disable : 4101 )
  9454.  
  9455. void GCGuildWarRequestSend(LPSTR GuildName, int aIndex, int type)
  9456. {
  9457. PMSG_GUILDWARSEND pMsg;
  9458. PHeadSetB((LPBYTE)&pMsg, 0x61, sizeof(pMsg));
  9459. pMsg.Type = type;
  9460. memcpy(pMsg.GuildName, GuildName, MAX_GUILD_LEN);
  9461.  
  9462. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9463.  
  9464. // (%s) guild declared guild war
  9465. LogAddTD(lMsg.Get(MSGGET(1, 237)), GuildName);
  9466. }
  9467. #pragma warning ( default : 4101 )
  9468. struct PMSG_GUILDWAR_DECLARE
  9469. {
  9470. PBMSG_HEAD h; // C1:62
  9471. char GuildName[8]; // 3
  9472. BYTE Type; // B
  9473. BYTE TeamCode; // C
  9474. };
  9475.  
  9476.  
  9477.  
  9478. void GCGuildWarRequestSendRecv(PMSG_GUILDWARSEND_RESULT * lpMsg, int aIndex)
  9479. {
  9480.  
  9481. PMSG_GUILDWAR_DECLARE pMsg;
  9482. int count=0;
  9483. int g_call=0;
  9484.  
  9485. PHeadSetB((LPBYTE)&pMsg, 0x62, sizeof(pMsg));
  9486. pMsg.Type = 0;
  9487.  
  9488. _GUILD_INFO_STRUCT * lpMyNode = gObj[aIndex].lpGuild;
  9489.  
  9490. if ( !lpMyNode )
  9491. {
  9492. PMSG_GUILDWARREQUEST_RESULT pResult;
  9493.  
  9494. pResult.h.c = 0xC1;
  9495. pResult.h.headcode = 0x60;
  9496. pResult.h.size = sizeof(pMsg); // #error Change fro pResult
  9497. pResult.Result = 0;
  9498.  
  9499. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  9500. return;
  9501. }
  9502.  
  9503. if ( lpMyNode->lpTargetGuildNode && lpMsg->Result )
  9504. {
  9505. int iTarGetIndex = lpMyNode->lpTargetGuildNode->Index[0];
  9506.  
  9507. if ( BC_MAP_RANGE(gObj[iTarGetIndex].MapNumber) ||
  9508. CC_MAP_RANGE(gObj[iTarGetIndex].MapNumber) ||
  9509. DS_MAP_RANGE(gObj[iTarGetIndex].MapNumber) )
  9510. {
  9511. PMSG_NOTICE pNotice;
  9512.  
  9513. TNotice::MakeNoticeMsgEx(&pNotice, 1, lMsg.Get(MSGGET(4, 199)));
  9514.  
  9515. DataSend(aIndex, (LPBYTE)&pNotice, pNotice.h.size);
  9516.  
  9517. lpMsg->Result = 0;
  9518. }
  9519. }
  9520.  
  9521. pMsg.Type = lpMyNode->WarType;
  9522.  
  9523. if ( lpMsg->Result == 0 )
  9524. {
  9525. if ( lpMyNode->lpTargetGuildNode )
  9526. {
  9527. if ( lpMyNode->lpTargetGuildNode->WarDeclareState == 1 )
  9528. {
  9529. lpMyNode->lpTargetGuildNode->WarDeclareState = 0;
  9530. lpMyNode->WarDeclareState = 0;
  9531.  
  9532. PMSG_GUILDWARREQUEST_RESULT pResult;
  9533.  
  9534. PHeadSetB((LPBYTE)&pResult, 0x60, sizeof(pResult));
  9535. pResult.Result = 6;
  9536.  
  9537. if ( lpMyNode->lpTargetGuildNode->Index[0] >= 0 )
  9538. {
  9539. DataSend(lpMyNode->lpTargetGuildNode->Index[0], (LPBYTE)&pResult, pResult.h.size);
  9540. }
  9541. }
  9542. }
  9543. }
  9544. else //if ( lpMsg->Result == 1 )
  9545. {
  9546. if ( lpMyNode->WarDeclareState == 1 )
  9547. {
  9548. if ( lpMyNode->lpTargetGuildNode )
  9549. {
  9550. if (lpMyNode->lpTargetGuildNode->WarDeclareState == 1 )
  9551. {
  9552. PMSG_TELEPORT pTeleportMsg;
  9553.  
  9554. if ( lpMyNode->WarType == 1 )
  9555. {
  9556. lpMyNode->BattleGroundIndex = gCheckBlankBattleGround();
  9557.  
  9558. switch ( lpMyNode->BattleGroundIndex )
  9559. {
  9560. case 0xFF:
  9561. lpMyNode->WarDeclareState = 0;
  9562. lpMyNode->WarState = 0;
  9563. lpMyNode->lpTargetGuildNode->WarDeclareState = 0;
  9564. lpMyNode->lpTargetGuildNode->WarState = 0;
  9565.  
  9566. PMSG_GUILDWARREQUEST_RESULT pResult;
  9567.  
  9568. PHeadSetB((LPBYTE)&pResult, 0x60, sizeof(pResult));
  9569. pResult.Result = 4;
  9570.  
  9571. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  9572. return;
  9573. }
  9574.  
  9575. pTeleportMsg.MoveNumber = 51;
  9576. lpMyNode->lpTargetGuildNode->BattleGroundIndex = lpMyNode->BattleGroundIndex;
  9577.  
  9578. if ( gBSGround[0]->m_BallIndex >= 0 )
  9579. gObjMonsterRegen(&gObj[gBSGround[0]->m_BallIndex]);
  9580.  
  9581. BattleSoccerGoalEnd(0);
  9582. lpMyNode->PlayScore = 0;
  9583. lpMyNode->lpTargetGuildNode->PlayScore = 0;
  9584. gBattleGroundEnable(lpMyNode->BattleGroundIndex, TRUE);
  9585. gSetBattleTeamMaster(lpMyNode->BattleGroundIndex, 0, lpMyNode->Name, lpMyNode);
  9586. gSetBattleTeamMaster(lpMyNode->BattleGroundIndex, 1, lpMyNode->lpTargetGuildNode->Name, lpMyNode->lpTargetGuildNode);
  9587. }
  9588.  
  9589. lpMyNode->WarDeclareState = 2;
  9590. lpMyNode->WarState = 1;
  9591. lpMyNode->lpTargetGuildNode->WarDeclareState = 2;
  9592. lpMyNode->lpTargetGuildNode->WarState = 1;
  9593. lpMyNode->PlayScore = 0;
  9594. lpMyNode->lpTargetGuildNode->PlayScore = 0;
  9595. lpMyNode->BattleTeamCode = 0;
  9596. lpMyNode->lpTargetGuildNode->BattleTeamCode = 1;
  9597. memset(pMsg.GuildName, 0, sizeof(pMsg.GuildName));
  9598. memcpy(pMsg.GuildName, lpMyNode->lpTargetGuildNode->Name, sizeof(pMsg.GuildName));
  9599. pMsg.TeamCode = lpMyNode->BattleTeamCode;
  9600. count = 0;
  9601.  
  9602. for ( int n=0;n<MAX_USER_GUILD;n++)
  9603. {
  9604. if ( lpMyNode->Use[n] )
  9605. {
  9606. if ( lpMyNode->Index[n] >= 0 )
  9607. {
  9608. g_call = 0;
  9609.  
  9610. if ( n > 0 )
  9611. {
  9612. if ( lpMyNode->WarType == 1 )
  9613. {
  9614. if ( gObj[lpMyNode->Index[0]].PartyNumber >= 0 )
  9615. {
  9616. if ( gObj[lpMyNode->Index[0]].PartyNumber == gObj[lpMyNode->Index[n]].PartyNumber )
  9617. {
  9618. g_call = 1;
  9619. }
  9620. }
  9621. }
  9622. else
  9623. {
  9624. g_call = 1;
  9625. }
  9626. }
  9627. else if ( n== 0 )
  9628. {
  9629. g_call = 1;
  9630. }
  9631.  
  9632. if ( g_call )
  9633. {
  9634. DataSend(lpMyNode->Index[n], (LPBYTE)&pMsg, pMsg.h.size);
  9635.  
  9636. // Declared guild war against (%s)
  9637. LogAddTD(lMsg.Get(MSGGET(1, 238)), lpMyNode->Name);
  9638. GCGuildWarScore(lpMyNode->Index[n]);
  9639. int x = 60;
  9640.  
  9641. if ( lpMyNode->WarType == 1 )
  9642. {
  9643. gObj[lpMyNode->Index[n]].IsInBattleGround = true;
  9644. pTeleportMsg.MoveNumber = 51;
  9645.  
  9646. if ( gPkLimitFree || gObj[lpMyNode->Index[n]].m_PK_Level < 6 )
  9647. {
  9648. gObjTeleport(lpMyNode->Index[n], 6, x++, 153);
  9649. count++;
  9650. }
  9651. }
  9652. }
  9653. }
  9654. }
  9655. }
  9656.  
  9657. memset(pMsg.GuildName, 0, sizeof(pMsg.GuildName));
  9658. memcpy(pMsg.GuildName, lpMyNode->Name, sizeof(pMsg.GuildName));
  9659.  
  9660. pMsg.TeamCode = lpMyNode->lpTargetGuildNode->BattleTeamCode;
  9661. count = 0;
  9662.  
  9663. for (int n = 0; n < MAX_USER_GUILD; n++)
  9664. {
  9665. if ( lpMyNode->lpTargetGuildNode->Use[n] )
  9666. {
  9667. if ( lpMyNode->lpTargetGuildNode->Index[n] >= 0 )
  9668. {
  9669. g_call = 0;
  9670.  
  9671. if ( n > 0 )
  9672. {
  9673. if ( lpMyNode->WarType == 1 )
  9674. {
  9675. if ( gObj[lpMyNode->lpTargetGuildNode->Index[0]].PartyNumber >= 0 )
  9676. {
  9677. if ( gObj[lpMyNode->lpTargetGuildNode->Index[0]].PartyNumber == gObj[lpMyNode->lpTargetGuildNode->Index[n]].PartyNumber )
  9678. {
  9679. g_call = 1;
  9680. }
  9681. }
  9682. }
  9683. else
  9684. {
  9685. g_call = 1;
  9686. }
  9687. }
  9688. else if ( n== 0 )
  9689. {
  9690. g_call = 1;
  9691. }
  9692.  
  9693. if ( g_call )
  9694. {
  9695. DataSend(lpMyNode->lpTargetGuildNode->Index[n], (LPBYTE)&pMsg, pMsg.h.size);
  9696.  
  9697. // Declared guild war against (%s)
  9698. LogAddTD(lMsg.Get(MSGGET(1, 238)), lpMyNode->lpTargetGuildNode->Name);
  9699. GCGuildWarScore(lpMyNode->lpTargetGuildNode->Index[n]);
  9700. int x = 59;
  9701.  
  9702. if ( lpMyNode->lpTargetGuildNode->WarType == 1 )
  9703. {
  9704.  
  9705. if ( gPkLimitFree != 0 || gObj[lpMyNode->lpTargetGuildNode->Index[n]].m_PK_Level < 6 )
  9706. {
  9707. gObj[lpMyNode->lpTargetGuildNode->Index[n]].IsInBattleGround = true;
  9708. gObjTeleport(lpMyNode->lpTargetGuildNode->Index[n], 6, x++, 164);
  9709. count++;
  9710. }
  9711. }
  9712. }
  9713. }
  9714. }
  9715. }
  9716.  
  9717. cManager.BattleInfoSend(GetBattleTeamName(0,0),
  9718. GetBattleTeamScore(0,0),
  9719. GetBattleTeamName(0, 1),
  9720. GetBattleTeamScore(0,1));
  9721.  
  9722. if ( lpMyNode->WarType == 1 )
  9723. {
  9724. gObjAddMsgSendDelay(&gObj[aIndex], 5, aIndex, 10000, 0);
  9725. GCServerMsgStringSendGuild(lpMyNode->lpTargetGuildNode,lMsg.Get(MSGGET(4, 130)), 1);
  9726. GCServerMsgStringSendGuild(lpMyNode,lMsg.Get(MSGGET(4, 130)), 1);
  9727. }
  9728. }
  9729. }
  9730. }
  9731. }
  9732. }
  9733.  
  9734.  
  9735.  
  9736. #pragma warning ( disable : 4101 )
  9737.  
  9738. void GCGuildWarDeclare(int aIndex, LPSTR _guildname)
  9739. {
  9740. PMSG_GUILDWAR_DECLARE pMsg;
  9741. PHeadSetB((LPBYTE)&pMsg, 0x62, sizeof(pMsg));
  9742. memcpy(pMsg.GuildName, _guildname, sizeof(pMsg.GuildName));
  9743.  
  9744. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9745. }
  9746.  
  9747.  
  9748.  
  9749. struct PMSG_GUILDWAR_END
  9750. {
  9751. PBMSG_HEAD h; // C1:63
  9752. BYTE Result; // 3
  9753. char GuildName[8]; // 4
  9754. };
  9755.  
  9756.  
  9757.  
  9758. void GCGuildWarEnd(int aIndex, BYTE result, char* _guildname)
  9759. {
  9760. PMSG_GUILDWAR_END pMsg;
  9761. PHeadSetB((LPBYTE)&pMsg, 0x63, sizeof(pMsg));
  9762. pMsg.Result = result;
  9763. memcpy(pMsg.GuildName, _guildname, sizeof(pMsg.GuildName));
  9764.  
  9765. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9766. }
  9767.  
  9768.  
  9769.  
  9770. struct PMSG_GUILDSCORE
  9771. {
  9772. PBMSG_HEAD h; // C1:64
  9773. BYTE Score1; // 3
  9774. BYTE Score2; // 4
  9775. BYTE Type; // 5
  9776. };
  9777.  
  9778.  
  9779.  
  9780. void GCGuildWarScore(int aIndex)
  9781. {
  9782. PMSG_GUILDSCORE pMsg;
  9783. if ( gObj[aIndex].GuildNumber < 1 )
  9784. return;
  9785.  
  9786. PHeadSetB((LPBYTE)&pMsg, 0x64, sizeof(pMsg));
  9787. pMsg.Score1 = 0;
  9788. pMsg.Score2 = 0;
  9789. pMsg.Type = 0;
  9790.  
  9791. if ( gObj[aIndex].lpGuild != NULL )
  9792. {
  9793. pMsg.Score1 = gObj[aIndex].lpGuild->PlayScore;
  9794. LogAdd("Score %s %d", gObj[aIndex].Name, gObj[aIndex].lpGuild->PlayScore);
  9795. }
  9796.  
  9797. if ( gObj[aIndex].lpGuild->lpTargetGuildNode != NULL )
  9798. {
  9799. pMsg.Score2 = gObj[aIndex].lpGuild->lpTargetGuildNode->PlayScore;
  9800. LogAdd("Target Score %s %d", gObj[aIndex].Name, gObj[aIndex].lpGuild->lpTargetGuildNode->PlayScore);
  9801. }
  9802.  
  9803. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9804. }
  9805.  
  9806.  
  9807. #pragma warning ( default : 4101 )
  9808.  
  9809. void CGWarehouseMoneyInOut(int aIndex, PMSG_WAREHOUSEMONEYINOUT* lpMsg)
  9810. {
  9811. int money = 0;
  9812. if ( !gObjIsConnected(aIndex))
  9813. {
  9814. LogAddC(2, "error-L3 [%s][%d]", __FILE__, __LINE__);
  9815. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9816. return;
  9817. }
  9818.  
  9819. LPOBJ lpObj = &gObj[aIndex];
  9820. money = lpMsg->Money;
  9821.  
  9822. if ( lpObj->m_IfState.state == 0 )
  9823. {
  9824. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9825. return;
  9826. }
  9827.  
  9828. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 6 )
  9829. {
  9830. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9831. LogAdd("[%s][%s] error-L1 : used not Warehouse[2]",
  9832. gObj[aIndex].AccountID, gObj[aIndex].Name);
  9833.  
  9834. return;
  9835. }
  9836.  
  9837. switch ( lpMsg->Type )
  9838. {
  9839. case 0x00:
  9840. if ( money <= 0 || money > MAX_WAREHOUSE_ZEN )
  9841. {
  9842. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9843. return;
  9844. }
  9845.  
  9846. if ( (lpObj->WarehouseMoney+money) > MAX_WAREHOUSE_ZEN )
  9847. {
  9848. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9849. return;
  9850. }
  9851.  
  9852. if ( money > lpObj->Money )
  9853. {
  9854. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9855. return;
  9856. }
  9857.  
  9858. lpObj->Money-=money;
  9859. lpObj->WarehouseMoney+=money;
  9860. break;
  9861. case 0x01:
  9862. {
  9863. if ( bCanWarehouseLock == TRUE)
  9864. {
  9865. if ( lpObj->WarehouseLock == 1)
  9866. {
  9867. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9868. GCServerMsgStringSend(lMsg.Get(MSGGET(6, 70)), lpObj->m_Index,1);
  9869. return;
  9870. }
  9871. }
  9872.  
  9873. if ( money <= 0 || money > MAX_WAREHOUSE_ZEN )
  9874. {
  9875. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9876. return;
  9877. }
  9878.  
  9879. if ( money > lpObj->WarehouseMoney )
  9880. {
  9881. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9882. return;
  9883. }
  9884.  
  9885. lpObj->WarehouseMoney -= money;
  9886. lpObj->Money += money;
  9887. int rZen = GetWarehouseUsedHowMuch(lpObj->Level, lpObj->WarehousePW);
  9888.  
  9889. if ( (lpObj->Money-rZen) > 0 )
  9890. {
  9891. int oldmoney = lpObj->Money;
  9892. lpObj->Money -= rZen;
  9893. GCMoneySend(lpObj->m_Index, lpObj->Money);
  9894.  
  9895. LogAdd("Get WareHouse Money(In Inventory) : %d - %d = %d",
  9896. oldmoney, rZen, lpObj->Money);
  9897. }
  9898. else if ( (lpObj->WarehouseMoney-rZen) > 0 )
  9899. {
  9900. int oldmoney = lpObj->WarehouseMoney;
  9901. lpObj->WarehouseMoney -= rZen;
  9902.  
  9903. LogAdd("Get WareHouse Money(In WareHouse) : %d - %d = %d",
  9904. oldmoney, rZen, lpObj->WarehouseMoney);
  9905.  
  9906. GCWarehouseInventoryMoneySend(aIndex, 1, lpObj->Money, lpObj->WarehouseMoney);
  9907. }
  9908. else
  9909. {
  9910. lpObj->WarehouseMoney +=money;
  9911. lpObj->Money -= money;
  9912. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9913. char msg[255];
  9914.  
  9915. wsprintf(msg, lMsg.Get(MSGGET(6, 69)), rZen);
  9916. GCServerMsgStringSend(msg, lpObj->m_Index, 1);
  9917. return;
  9918. }
  9919. }
  9920. break;
  9921.  
  9922. default:
  9923. GCWarehouseInventoryMoneySend(aIndex, 0, 0, 0);
  9924. return;
  9925. }
  9926.  
  9927. lpObj->WarehouseCount++;
  9928. GCWarehouseInventoryMoneySend(aIndex, 1, lpObj->Money, lpObj->WarehouseMoney);
  9929. }
  9930.  
  9931.  
  9932.  
  9933. struct PMSG_MONEY
  9934. {
  9935. PBMSG_HEAD h; // C1:81
  9936. BYTE Result; // 3
  9937. int wMoney; // 4
  9938. int iMoney; // 8
  9939. };
  9940.  
  9941.  
  9942. void GCWarehouseInventoryMoneySend(int aIndex, BYTE result, int money, int wmoney)
  9943. {
  9944. PMSG_MONEY pMsg;
  9945.  
  9946. PHeadSetB((LPBYTE)&pMsg, 0x81, sizeof(pMsg));
  9947. pMsg.Result = result;
  9948. pMsg.iMoney = money;
  9949. pMsg.wMoney = wmoney;
  9950.  
  9951. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9952. }
  9953.  
  9954.  
  9955.  
  9956.  
  9957. void CGWarehouseUseEnd(int aIndex)
  9958. {
  9959. if ( !gObjIsConnectedGP(aIndex))
  9960. {
  9961. LogAddC(2, "error-L3 [%s][%d]", __FILE__, __LINE__);
  9962. return;
  9963. }
  9964.  
  9965. LPOBJ lpObj = &gObj[aIndex];
  9966. // LogAddC(2, "end");
  9967. PMSG_DEFAULT pMsg;
  9968. PHeadSetB((LPBYTE)&pMsg, 0x82, sizeof(pMsg));
  9969. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  9970.  
  9971. gObjItemTextSave(lpObj);
  9972. GDSetWarehouseList(aIndex);
  9973. GDUserItemSave(lpObj);
  9974.  
  9975. if ( lpObj->m_IfState.use && lpObj->m_IfState.type == 6 )
  9976. {
  9977. lpObj->m_IfState.use = 0;
  9978. lpObj->m_IfState.state = 0;
  9979. lpObj->WarehouseSave = FALSE;
  9980. }
  9981. }
  9982.  
  9983.  
  9984.  
  9985.  
  9986. struct PMSG_WAREHOUSESTATE
  9987. {
  9988. PBMSG_HEAD h; // C1:83
  9989. BYTE State; // 3
  9990. };
  9991.  
  9992.  
  9993.  
  9994. void GCWarehouseStateSend(int aIndex, BYTE state)
  9995. {
  9996. PMSG_WAREHOUSESTATE pMsg;
  9997.  
  9998. PHeadSetB((LPBYTE)&pMsg, 0x83, sizeof(pMsg));
  9999. pMsg.State = state;
  10000.  
  10001. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  10002. }
  10003.  
  10004.  
  10005.  
  10006.  
  10007. void GCWarehouseRecivePassword(int aIndex, PMSG_WAREHOUSEPASSSEND* lpMsg)
  10008. {
  10009. if ( bCanWarehouseLock == FALSE )
  10010. return;
  10011.  
  10012. int pw = lpMsg->Pass;
  10013.  
  10014. switch ( lpMsg->Type )
  10015. {
  10016. case 0x00:
  10017. if ( gObj[aIndex].WarehouseLock )
  10018. {
  10019. if ( gObj[aIndex].WarehousePW == pw )
  10020. {
  10021. gObj[aIndex].WarehouseLock = FALSE;
  10022. GCWarehouseStateSend(aIndex, 0x0C);
  10023. }
  10024. else
  10025. {
  10026. GCWarehouseStateSend(aIndex, 0x0A);
  10027. }
  10028. }
  10029. break;
  10030. case 0x01:
  10031. if ( !gObj[aIndex].WarehouseLock || gObj[aIndex].WarehouseLock == 0xFF )
  10032. {
  10033. char szJoomin[11];
  10034.  
  10035. memset(szJoomin, 0, sizeof(szJoomin));
  10036. memcpy(szJoomin, lpMsg->LastJoominNumber, 10);
  10037.  
  10038. if ( gObjJoominCheck(aIndex, szJoomin) == FALSE )
  10039. {
  10040. GCWarehouseStateSend(aIndex, 0x0D);
  10041. return;
  10042. }
  10043.  
  10044. gObj[aIndex].WarehousePW = pw;
  10045. gObj[aIndex].WarehouseLock = FALSE;
  10046. GCWarehouseStateSend(aIndex, 0x0C);
  10047. }
  10048. else
  10049. {
  10050. GCWarehouseStateSend(aIndex, 0x0B);
  10051. }
  10052. break;
  10053. case 0x02:
  10054. {
  10055. char szJoomin[11];
  10056.  
  10057. memset(szJoomin, 0, sizeof(szJoomin));
  10058. memcpy(szJoomin, lpMsg->LastJoominNumber, 10);
  10059.  
  10060. if ( gObjJoominCheck(aIndex, szJoomin) == FALSE )
  10061. {
  10062. GCWarehouseStateSend(aIndex, 0x0D);
  10063. return;
  10064. }
  10065.  
  10066. gObj[aIndex].WarehouseLock = FALSE;
  10067. gObj[aIndex].WarehousePW = 0;
  10068. GCWarehouseStateSend(aIndex, gObj[aIndex].WarehouseLock);
  10069. }
  10070. break;
  10071. }
  10072. }
  10073.  
  10074.  
  10075.  
  10076.  
  10077. void GCUserChaosBoxSend(LPOBJ lpObj, int iChaosBoxType)
  10078. {
  10079. if ( iChaosBoxType == 1 )
  10080. {
  10081. if ( lpObj->m_IfState.type != 13 )
  10082. {
  10083. return;
  10084. }
  10085.  
  10086. if ( lpObj->m_IfState.type == 13 && lpObj->m_IfState.state == 1 )
  10087. {
  10088. return;
  10089. }
  10090. }
  10091. else
  10092. {
  10093. if ( lpObj->m_IfState.type != 7 )
  10094. {
  10095. return;
  10096. }
  10097.  
  10098. if ( lpObj->m_IfState.type == 7 && lpObj->m_IfState.state == 1 )
  10099. {
  10100. return;
  10101. }
  10102. }
  10103.  
  10104. PMSG_SHOPITEMCOUNT pMsg;
  10105. BYTE SendByte[2048];
  10106. int lOfs = sizeof(pMsg);
  10107. PHeadSetW((LPBYTE)&pMsg, 0x31, 0);
  10108. pMsg.count = 0;
  10109.  
  10110. if ( iChaosBoxType == 1 )
  10111. {
  10112. pMsg.Type = 5;
  10113. }
  10114. else
  10115. {
  10116. pMsg.Type = 3;
  10117. }
  10118.  
  10119. for ( int n=0;n<CHAOS_BOX_SIZE;n++)
  10120. {
  10121. if ( lpObj->pChaosBox[n].IsItem() == TRUE )
  10122. {
  10123. SendByte[lOfs] = n;
  10124. lOfs++;
  10125. ItemByteConvert(&SendByte[lOfs], lpObj->pChaosBox[n] );
  10126. lOfs += MAX_ITEM_INFO;
  10127. pMsg.count ++;
  10128. }
  10129. }
  10130.  
  10131. pMsg.h.sizeH = SET_NUMBERH(lOfs);
  10132. pMsg.h.sizeL = SET_NUMBERL(lOfs);
  10133. memcpy(SendByte, &pMsg, sizeof(pMsg));
  10134.  
  10135. DataSend(lpObj->m_Index, SendByte, lOfs);
  10136. }
  10137.  
  10138.  
  10139.  
  10140.  
  10141. void CGChaosBoxItemMixButtonClick(PMSG_CHAOSMIX* aRecv, int aIndex)
  10142. {
  10143. if ( !gObjIsConnectedGP(aIndex))
  10144. {
  10145. LogAddC(2, "error-L3 [%s][%d]", __FILE__, __LINE__);
  10146. return;
  10147. }
  10148.  
  10149. LPOBJ lpObj = &gObj[aIndex];
  10150.  
  10151. if ( lpObj->ChaosLock == TRUE )
  10152. {
  10153. LogAdd("[%s][%s] Already Used Chaos", lpObj->AccountID, lpObj->Name);
  10154. GCServerMsgStringSend(lMsg.Get(MSGGET(2, 198)), lpObj->m_Index, 1);
  10155. return;
  10156. }
  10157.  
  10158. if ( lpObj->m_bPShopOpen == true )
  10159. {
  10160. LogAdd("[%s][%s] is Already Opening PShop, ChaosBox Failed", lpObj->AccountID, lpObj->Name);
  10161. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 194)), lpObj->m_Index, 1);
  10162. return;
  10163. }
  10164.  
  10165. lpObj->bIsChaosMixCompleted = true;
  10166. int iMixType = aRecv->Type;
  10167.  
  10168. switch ( iMixType )
  10169. {
  10170. case CHAOS_TYPE_DEVILSQUARE:
  10171. g_MixSystem.DevilSquareItemChaosMix(lpObj);
  10172. break;
  10173. case CHAOS_TYPE_UPGRADE_10:
  10174. g_MixSystem.PlusItemLevelChaosMix(lpObj, CHAOS_TYPE_UPGRADE_10);
  10175. break;
  10176. case CHAOS_TYPE_UPGRADE_11:
  10177. g_MixSystem.PlusItemLevelChaosMix(lpObj, CHAOS_TYPE_UPGRADE_11);
  10178. break;
  10179. case CHAOS_TYPE_UPGRADE_12:
  10180. g_MixSystem.PlusItemLevelChaosMix(lpObj, CHAOS_TYPE_UPGRADE_12);
  10181. break;
  10182. case CHAOS_TYPE_UPGRADE_13:
  10183. g_MixSystem.PlusItemLevelChaosMix(lpObj, CHAOS_TYPE_UPGRADE_13);
  10184. break;
  10185. case CHAOS_TYPE_DINORANT:
  10186. g_MixSystem.PegasiaChaosMix(lpObj);
  10187. break;
  10188. case CHAOS_TYPE_FRUIT:
  10189. g_MixSystem.CircleChaosMix(lpObj);
  10190. break;
  10191. case CHAOS_TYPE_SECOND_WING:
  10192. case CHAOS_TYPE_CLOAK:
  10193. g_MixSystem.WingChaosMix(lpObj);
  10194. break;
  10195. case CHAOS_TYPE_BLOODCATLE:
  10196. g_MixSystem.BloodCastleItemChaosMix(lpObj);
  10197. break;
  10198. case CHAOS_TYPE_DEFAULT:
  10199. case CHAOS_TYPE_FIRST_WING:
  10200. g_MixSystem.DefaultChaosMix(lpObj);
  10201. break;
  10202. //case CHAOS_TYPE_SETITEM:
  10203. // g_MixSystem.SetItemChaosMix(lpObj);
  10204. // break;
  10205. case CHAOS_TYPE_DARKHORSE:
  10206. g_MixSystem.DarkHorseChaosMix(lpObj);
  10207. break;
  10208. case CHAOS_TYPE_DARKSPIRIT:
  10209. g_MixSystem.DarkSpiritChaosMix(lpObj);
  10210. break;
  10211. case CHAOS_TYPE_BLESS_POTION:
  10212. g_MixSystem.BlessPotionChaosMix(lpObj);
  10213. break;
  10214. case CHAOS_TYPE_SOUL_POTION:
  10215. g_MixSystem.SoulPotionChaosMix(lpObj);
  10216. break;
  10217. case CHAOS_TYPE_LIFE_STONE:
  10218. g_MixSystem.LifeStoneChaosMix(lpObj);
  10219. break;
  10220. case CHAOS_TYPE_CASTLE_ITEM:
  10221. g_MixSystem.CastleSpecialItemMix(lpObj);
  10222. break;
  10223. case CHAOS_TYPE_HT_BOX:
  10224. g_MixSystem.HiddenTreasureBoxItemMix(lpObj);
  10225. break;
  10226. case CHAOS_TYPE_FENRIR_01:
  10227. g_MixSystem.Fenrir_01Level_Mix(lpObj);
  10228. break;
  10229. case CHAOS_TYPE_FENRIR_02:
  10230. g_MixSystem.Fenrir_02Level_Mix(lpObj);
  10231. break;
  10232. case CHAOS_TYPE_FENRIR_03:
  10233. g_MixSystem.Fenrir_03Level_Mix(lpObj);
  10234. break;
  10235. case CHAOS_TYPE_FENRIR_04:
  10236. g_MixSystem.Fenrir_04Upgrade_Mix(lpObj);
  10237. break;
  10238. case CHAOS_TYPE_COMPOUNDPOTION_LV1:
  10239. g_MixSystem.ShieldPotionLv1_Mix(lpObj);
  10240. break;
  10241. case CHAOS_TYPE_COMPOUNTPOTION_LV2:
  10242. g_MixSystem.ShieldPotionLv2_Mix(lpObj);
  10243. break;
  10244. case CHAOS_TYPE_COMPOUNTPOTION_LV3:
  10245. g_MixSystem.ShieldPotionLv3_Mix(lpObj);
  10246. break;
  10247. case CHAOS_TYPE_JEWELOFHARMONY_PURITY:
  10248. g_kJewelOfHarmonySystem.PurityJewelOfHarmony(lpObj);
  10249. break;
  10250. case CHAOS_TYPE_JEWELOFHARMONY_MIX_SMELTINGITEM:
  10251. g_kJewelOfHarmonySystem.MakeSmeltingStoneItem(lpObj);
  10252. break;
  10253. case CHAOS_TYPE_JEWELOFHARMONY_RESTORE_ITEM:
  10254. g_kJewelOfHarmonySystem.RestoreStrengthenItem(lpObj);
  10255. break;
  10256. case CHAOS_TYPE_380_OPTIONITEM:
  10257. g_kItemSystemFor380.ChaosMix380ItemOption(lpObj);
  10258. LogAddTD("[%s][%s] Denected %d", lpObj->AccountID, lpObj->Name, iMixType);
  10259. break;
  10260. case CHAOS_TYPE_LOTTERY_MIX:
  10261. g_MixSystem.LotteryItemMix(lpObj);
  10262. break;
  10263. case CHAOS_TYPE_BLOOD_SCROLL_MIX:
  10264. g_IllusionTempleEvent.TicketChaosMix(lpObj);
  10265. break;
  10266. case CHAOS_TYPE_CONDOR_FEATHER_MIX:
  10267. g_MixSystem.ThirdWingMix1(lpObj);
  10268. break;
  10269. case CHAOS_TYPE_THIRD_WING_MIX:
  10270. g_MixSystem.ThirdWingMix2(lpObj);
  10271. break;
  10272. default:
  10273. LogAddTD("[%s][%s] Undefine chaosmix type detect %d", lpObj->AccountID, lpObj->Name, iMixType);
  10274. break;
  10275. }
  10276. }
  10277.  
  10278.  
  10279.  
  10280. void CGChaosBoxUseEnd(int aIndex)
  10281. {
  10282. if ( !gObjIsConnectedGP(aIndex))
  10283. {
  10284. LogAddC(2, "error-L3 [%s][%d]", __FILE__, __LINE__);
  10285. return;
  10286. }
  10287.  
  10288. LPOBJ lpObj = &gObj[aIndex];
  10289.  
  10290. PMSG_DEFAULT pMsg;
  10291. PHeadSetB((LPBYTE)&pMsg, 0x87, sizeof(pMsg));
  10292. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  10293.  
  10294. if ( lpObj->m_IfState.use && lpObj->m_IfState.type == 7 )
  10295. {
  10296. lpObj->m_IfState.use = 0;
  10297. lpObj->m_IfState.state = 0;
  10298. }
  10299.  
  10300. g_MixSystem.ChaosBoxInit(lpObj);
  10301. gObjInventoryCommit(lpObj->m_Index);
  10302. lpObj->m_bIsCastleNPCUpgradeCompleted = false;
  10303. }
  10304.  
  10305.  
  10306.  
  10307.  
  10308. struct PMSG_ACTIONRESULT
  10309. {
  10310. PBMSG_HEAD h;
  10311. BYTE NumberH; // 3
  10312. BYTE NumberL; // 4
  10313. BYTE Dir; // 5
  10314. BYTE ActionNumber; // 6
  10315. BYTE TargetNumberH; // 7
  10316. BYTE TargetNumberL; // 8
  10317. };
  10318.  
  10319.  
  10320. void PMoveProc(PMSG_MOVE* lpMove, int aIndex)
  10321. {
  10322. if ( !OBJMAX_RANGE(aIndex))
  10323. {
  10324. LogAdd("error-L3 : move protocol index error %s %d", __FILE__, __LINE__);
  10325. return;
  10326. }
  10327.  
  10328. PMSG_RECVMOVE pMove;
  10329. short n;
  10330. short pathtable;
  10331. short ax;
  10332. short ay;
  10333. int sx;
  10334. int sy;
  10335. LPOBJ lpObj = &gObj[aIndex];
  10336.  
  10337.  
  10338. if ( lpObj->RegenOk > 0 )
  10339. {
  10340. return;
  10341. }
  10342.  
  10343. if ( lpObj->SkillRecallParty_Time )
  10344. {
  10345. lpObj->SkillRecallParty_Time = 0;
  10346. char msg[255];
  10347. wsprintf(msg, lMsg.Get(MSGGET(4, 230)));
  10348. GCServerMsgStringSend(msg, lpObj->m_Index, 1);
  10349. }
  10350.  
  10351. if ( (GetTickCount()-lpObj->m_LastMoveTime) < 100 )
  10352. {
  10353. return;
  10354. }
  10355.  
  10356. if ( lpObj->Teleport )
  10357. {
  10358. return;
  10359. }
  10360.  
  10361. if ( lpObj->m_SkillHarden )
  10362. {
  10363. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10364. return;
  10365. }
  10366.  
  10367. if ( lpObj->m_iSkillStunTime > 0 )
  10368. {
  10369. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10370. return;
  10371. }
  10372.  
  10373. lpObj->m_LastMoveTime = GetTickCount();
  10374. lpObj->m_Rest = 0;
  10375. lpObj->PathCur = 0;
  10376. lpObj->Dir = lpMove->Path[0] >> 4;
  10377. lpObj->PathCount = lpMove->Path[0] & 0x0F;
  10378.  
  10379. if ( lpObj->PathCount > 15 )
  10380. {
  10381. LogAdd("error-L3 : Path Count error %d id:%s %s %d",
  10382. lpObj->PathCount, lpObj->AccountID, __FILE__, __LINE__);
  10383. return;
  10384. }
  10385.  
  10386. for ( n=0;n<15;n++)
  10387. {
  10388. lpObj->PathX[n]=0;
  10389. lpObj->PathY[n]=0;
  10390. lpObj->PathOri[n]=0;
  10391. }
  10392.  
  10393. sx = lpMove->X;
  10394. sy = lpMove->Y;
  10395.  
  10396. if ( gObjCheckXYMapTile(lpObj, 1) == TRUE )
  10397. {
  10398. lpObj->PathCount = 0;
  10399. lpObj->PathCur = 0;
  10400. lpObj->PathStartEnd = 0;
  10401. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10402. return;
  10403. }
  10404. /*
  10405. lpObj->PathX[0] = lpMove->X;
  10406. ax = lpObj->PathX[0];
  10407. lpObj->PathY[0] = lpMove->Y;
  10408. ay = lpObj->PathY[0];
  10409. lpObj->PathDir[0] = lpObj->Dir;
  10410. lpObj->PathStartEnd = 1;
  10411. */
  10412. ax = lpObj->PathX[0] = lpMove->X;
  10413. ay = lpObj->PathY[0] = lpMove->Y;
  10414.  
  10415. lpObj->PathDir[0] = lpObj->Dir;
  10416.  
  10417. lpObj->PathStartEnd = 1;
  10418.  
  10419. if ( lpObj->PathCount > 0 )
  10420. {
  10421. lpObj->PathCur = 1;
  10422. lpObj->PathCount += 1;
  10423. }
  10424.  
  10425. for (n=1;n<lpObj->PathCount;n++)
  10426. {
  10427. if ( (n%2) == 1 )
  10428. {
  10429. pathtable = lpMove->Path[(n+1) / 2] >> 4;
  10430. }
  10431. else
  10432. {
  10433. pathtable = lpMove->Path[(n+1) / 2] & 0x0F;
  10434. }
  10435.  
  10436. ax += RoadPathTable[pathtable*2];
  10437. ay += RoadPathTable[pathtable*2+1];
  10438.  
  10439. lpObj->PathOri[n-1] = pathtable;
  10440. lpObj->PathDir[n]= pathtable;
  10441. lpObj->PathX[n] = ax;
  10442. lpObj->PathY[n] = ay;
  10443. }
  10444.  
  10445. if ( lpObj->PathCount > 0 )
  10446. {
  10447. int nextX;
  10448. int nextY;
  10449. BYTE mapnumber;
  10450. BYTE attr;
  10451. nextX = lpObj->PathX[1];
  10452. nextY = lpObj->PathY[1];
  10453. mapnumber = lpObj->MapNumber;
  10454.  
  10455. if ( lpObj->PathCount > 0 ) //HermeX Add-on for fixing registers
  10456. {
  10457. //logadd
  10458. }
  10459.  
  10460. attr = MapC[mapnumber].GetAttr(nextX, nextY);
  10461.  
  10462. if ( ((attr & (BYTE)4) == (BYTE)4) || ((attr & (BYTE)8) == (BYTE)8) )
  10463. {
  10464. for ( n=0 ; n<15 ; n++)
  10465. {
  10466. lpObj->PathX[n] = 0;
  10467. lpObj->PathY[n] = 0;
  10468. lpObj->PathOri[n] = 0;
  10469. }
  10470.  
  10471. lpObj->PathCount = 0;
  10472. lpObj->PathCur = 0;
  10473. lpObj->PathStartEnd = 0;
  10474. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10475. return;
  10476. }
  10477. }
  10478. lpObj->TX = (BYTE)ax;
  10479. lpObj->TY = (BYTE)ay;
  10480.  
  10481. if ( lpObj->Type == OBJ_USER )
  10482. {
  10483. int nextX = lpObj->X;
  10484. int nextY = lpObj->Y;
  10485.  
  10486. // This is used
  10487. /* To Prevent any shit
  10488. like bypass the doors
  10489. or other things
  10490. */
  10491.  
  10492. BOOL bFound = FALSE;
  10493. WORD wMapAttr = 0;
  10494. for (int n=0;n<256;n++)
  10495. {
  10496. if(nextX > lpObj->TX)
  10497. {
  10498. nextX -= 1;
  10499. }
  10500.  
  10501. if(nextX < lpObj->TX)
  10502. {
  10503. nextX += 1;
  10504. }
  10505.  
  10506. if(nextY > lpObj->TY)
  10507. {
  10508. nextY -= 1;
  10509. }
  10510.  
  10511. if(nextY < lpObj->TY)
  10512. {
  10513. nextY += 1;
  10514. }
  10515.  
  10516. wMapAttr = (BYTE)MapC[lpObj->MapNumber].GetAttr(nextX, nextY);
  10517. if ((wMapAttr&16) == 16 )
  10518. {
  10519. bFound = TRUE;
  10520. break;
  10521. }
  10522.  
  10523. if( nextX == lpObj->TX)
  10524. {
  10525. if(nextY == lpObj->TY)
  10526. {
  10527. break;
  10528. }
  10529. }
  10530. }
  10531.  
  10532. if ( bFound == TRUE )
  10533. {
  10534. lpObj->m_Rest = 1;
  10535. lpObj->PathCur = 0;
  10536. lpObj->PathCount = 0;
  10537. lpObj->PathStartEnd = 0;
  10538.  
  10539. gObjSetPosition(lpObj->m_Index,lpObj->X,lpObj->Y);
  10540.  
  10541. PMSG_ACTIONRESULT pActionResult;
  10542.  
  10543. PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10544. pActionResult.NumberH = SET_NUMBERH(aIndex);
  10545. pActionResult.NumberL = SET_NUMBERL(aIndex);
  10546. pActionResult.ActionNumber = 0x7A;
  10547. pActionResult.Dir = lpObj->Dir;
  10548. pActionResult.TargetNumberH = 0;
  10549. pActionResult.TargetNumberL = 0;
  10550.  
  10551. DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10552. return;
  10553. }
  10554. }
  10555.  
  10556. //if ( BC_MAP_RANGE(lpObj->MapNumber) && lpObj->Type == OBJ_USER )
  10557. //{
  10558. // switch ( g_BloodCastle.GetCurrentState(lpObj->MapNumber-11) )
  10559. // {
  10560. // case 0x01:
  10561. // if ( lpObj->TY > 15 )
  10562. // {
  10563. // lpObj->m_Rest = 1;
  10564. // lpObj->PathCur = 0;
  10565. // lpObj->PathCount = 0;
  10566. // lpObj->PathStartEnd = 0;
  10567. // gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10568. //
  10569. // PMSG_ACTIONRESULT pActionResult;
  10570. //
  10571. // PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10572. // pActionResult.NumberH = SET_NUMBERH(aIndex);
  10573. // pActionResult.NumberL = SET_NUMBERL(aIndex);
  10574. // pActionResult.ActionNumber = 0x7A;
  10575. // pActionResult.Dir = lpObj->Dir;
  10576. // pActionResult.TargetNumberH = 0;
  10577. // pActionResult.TargetNumberL = 0;
  10578. //
  10579. // DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10580. // return;
  10581. // }
  10582. // break;
  10583. // case 0x02:
  10584. // if ( lpObj->Y > 17 && g_BloodCastle.CheckPlayStart(lpObj->MapNumber-MAP_INDEX_BLOODCASTLE1) == false)
  10585. // {
  10586. // gObjMoveGate(lpObj->m_Index, lpObj->MapNumber+0x37);
  10587. // return;
  10588. // }
  10589. //
  10590. // if ( lpObj->TY > 15 && g_BloodCastle.CheckPlayStart(lpObj->MapNumber- MAP_INDEX_BLOODCASTLE1) == false )
  10591. // {
  10592. // lpObj->m_Rest = 1;
  10593. // lpObj->PathCur = 0;
  10594. // lpObj->PathCount = 0;
  10595. // lpObj->PathStartEnd = 0;
  10596. // gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10597. //
  10598. // PMSG_ACTIONRESULT pActionResult;
  10599. //
  10600. // PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10601. // pActionResult.NumberH = SET_NUMBERH(aIndex);
  10602. // pActionResult.NumberL = SET_NUMBERL(aIndex);
  10603. // pActionResult.ActionNumber = 0x7A;
  10604. // pActionResult.Dir = lpObj->Dir;
  10605. // pActionResult.TargetNumberH = 0;
  10606. // pActionResult.TargetNumberL = 0;
  10607. //
  10608. // DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10609. // return;
  10610. // }
  10611. //
  10612. // if ( lpObj->TY > 76 && g_BloodCastle.m_BridgeData[(lpObj->MapNumber-9)].m_bCASTLE_DOOR_LIVE )
  10613. // {
  10614. // lpObj->m_Rest = 1;
  10615. // lpObj->PathCur = 0;
  10616. // lpObj->PathCount = 0;
  10617. // lpObj->PathStartEnd = 0;
  10618. // gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10619. //
  10620. // PMSG_ACTIONRESULT pActionResult;
  10621. //
  10622. // PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10623. // pActionResult.NumberH = SET_NUMBERH(aIndex);
  10624. // pActionResult.NumberL = SET_NUMBERL(aIndex);
  10625. // pActionResult.ActionNumber = 0x7A;
  10626. // pActionResult.Dir = lpObj->Dir;
  10627. // pActionResult.TargetNumberH = 0;
  10628. // pActionResult.TargetNumberL = 0;
  10629. //
  10630. // DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10631. // return;
  10632. // }
  10633. // break;
  10634. // }
  10635. //}
  10636. if (BC_MAP_RANGE(lpObj->MapNumber) && lpObj->Type == OBJ_USER)
  10637. {
  10638. int iBridgeIndex = gObj[aIndex].MapNumber - MAP_INDEX_BLOODCASTLE1;
  10639.  
  10640. LogAdd("WORK MOVE PROC %d", g_BloodCastle.GetCurrentState(iBridgeIndex));
  10641.  
  10642. switch (g_BloodCastle.GetCurrentState(iBridgeIndex))
  10643. {
  10644. case 0x01:
  10645. if (lpObj->TY > 15)
  10646. {
  10647. lpObj->m_Rest = 1;
  10648. lpObj->PathCur = 0;
  10649. lpObj->PathCount = 0;
  10650. lpObj->PathStartEnd = 0;
  10651. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10652.  
  10653. PMSG_ACTIONRESULT pActionResult;
  10654.  
  10655. PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10656. pActionResult.NumberH = SET_NUMBERH(aIndex);
  10657. pActionResult.NumberL = SET_NUMBERL(aIndex);
  10658. pActionResult.ActionNumber = 0x7A;
  10659. pActionResult.Dir = lpObj->Dir;
  10660. pActionResult.TargetNumberH = 0;
  10661. pActionResult.TargetNumberL = 0;
  10662.  
  10663. DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10664. return;
  10665. }
  10666. break;
  10667. case 0x02:
  10668. if (lpObj->Y > 17 && g_BloodCastle.CheckPlayStart(iBridgeIndex) == false)
  10669. {
  10670. gObjMoveGate(lpObj->m_Index, iBridgeIndex + 66);
  10671. return;
  10672. }
  10673.  
  10674. if (lpObj->TY > 15 && g_BloodCastle.CheckPlayStart(iBridgeIndex) == false)
  10675. {
  10676. lpObj->m_Rest = 1;
  10677. lpObj->PathCur = 0;
  10678. lpObj->PathCount = 0;
  10679. lpObj->PathStartEnd = 0;
  10680. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10681.  
  10682. PMSG_ACTIONRESULT pActionResult;
  10683.  
  10684. PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10685. pActionResult.NumberH = SET_NUMBERH(aIndex);
  10686. pActionResult.NumberL = SET_NUMBERL(aIndex);
  10687. pActionResult.ActionNumber = 0x7A;
  10688. pActionResult.Dir = lpObj->Dir;
  10689. pActionResult.TargetNumberH = 0;
  10690. pActionResult.TargetNumberL = 0;
  10691.  
  10692. DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10693. return;
  10694. }
  10695.  
  10696. if (lpObj->TY > 76 && g_BloodCastle.m_BridgeData[iBridgeIndex].m_bCASTLE_DOOR_LIVE)
  10697. {
  10698. lpObj->m_Rest = 1;
  10699. lpObj->PathCur = 0;
  10700. lpObj->PathCount = 0;
  10701. lpObj->PathStartEnd = 0;
  10702. gObjSetPosition(lpObj->m_Index, lpObj->X, lpObj->Y);
  10703.  
  10704. PMSG_ACTIONRESULT pActionResult;
  10705.  
  10706. PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  10707. pActionResult.NumberH = SET_NUMBERH(aIndex);
  10708. pActionResult.NumberL = SET_NUMBERL(aIndex);
  10709. pActionResult.ActionNumber = 0x7A;
  10710. pActionResult.Dir = lpObj->Dir;
  10711. pActionResult.TargetNumberH = 0;
  10712. pActionResult.TargetNumberL = 0;
  10713.  
  10714. DataSend(lpObj->m_Index, (LPBYTE)&pActionResult, sizeof(pActionResult));
  10715. return;
  10716. }
  10717. break;
  10718. }
  10719. }
  10720.  
  10721. PHeadSetB((LPBYTE)&pMove, MOVE_PROTOCOL, sizeof(pMove));
  10722. pMove.NumberH = SET_NUMBERH(aIndex);
  10723. pMove.NumberL = SET_NUMBERL(aIndex);
  10724. pMove.X = (BYTE)ax;
  10725. pMove.Y = (BYTE)ay;
  10726.  
  10727. pMove.Path = lpObj->Dir << 4;
  10728.  
  10729. if ( lpObj->Type == OBJ_USER )
  10730. {
  10731. if ( lpObj->m_IfState.use )
  10732. {
  10733. if ( lpObj->m_IfState.type == 3 )
  10734. {
  10735. lpObj->TargetShopNumber = -1;
  10736. lpObj->m_IfState.type = 0;
  10737. lpObj->m_IfState.use = 0;
  10738. }
  10739. }
  10740.  
  10741. if ( !gObjPositionCheck(lpObj))
  10742. {
  10743. lpObj->PathCur = 0;
  10744. lpObj->PathCount = 0;
  10745. ax = lpObj->X;
  10746. ay = lpObj->Y;
  10747. lpObj->TX = (BYTE)ax;
  10748. lpObj->TY = (BYTE)ay;
  10749. pMove.X = ax;
  10750. pMove.Y = ay;
  10751. }
  10752.  
  10753. DataSend(aIndex, (LPBYTE)&pMove, pMove.h.size);
  10754. }
  10755.  
  10756. int MVL = MAX_VIEWPORT;
  10757.  
  10758. if ( lpObj->Type == OBJ_MONSTER )
  10759. MVL = MAX_VIEWPORT_MONSTER;
  10760.  
  10761. for (n=0;n<MVL;n++)
  10762. {
  10763. if ( lpObj->VpPlayer2[n].state == TRUE )
  10764. {
  10765. int number = lpObj->VpPlayer2[n].number;
  10766.  
  10767. if ( number >= 0 )
  10768. {
  10769. if ( gObj[number].Connected > PLAYER_CONNECTED )
  10770. {
  10771. if ( gObj[number].Live )
  10772. {
  10773. if ( gObj[number].Type == OBJ_USER )
  10774. {
  10775. DataSend(lpObj->VpPlayer2[n].number, (LPBYTE)&pMove, pMove.h.size);
  10776. }
  10777. }
  10778. }
  10779. else
  10780. {
  10781. lpObj->VpPlayer2[n].number= -1;
  10782. lpObj->VpPlayer2[n].state = 0;
  10783. lpObj->VPCount2--;
  10784. }
  10785. }
  10786. }
  10787. }
  10788.  
  10789. MapC[lpObj->MapNumber].ClearStandAttr(lpObj->m_OldX, lpObj->m_OldY);
  10790. MapC[lpObj->MapNumber].SetStandAttr(lpObj->TX, lpObj->TY);
  10791. lpObj->m_OldX = lpObj->TX;
  10792. lpObj->m_OldY = lpObj->TY;
  10793. lpObj->X = sx;
  10794. lpObj->Y = sy;
  10795. lpObj->m_ViewState = 0;
  10796.  
  10797.  
  10798. }
  10799.  
  10800.  
  10801.  
  10802.  
  10803. void RecvPositionSetProc(PMSG_POSISTION_SET * lpMove, int aIndex)
  10804. {
  10805. short n;
  10806.  
  10807. // Check of aIndex is in range
  10808. if ( OBJMAX_RANGE(aIndex) == FALSE)
  10809. {
  10810. LogAdd("error : move protocol index error %s %d", __FILE__, __LINE__);
  10811. return;
  10812. }
  10813.  
  10814. LPOBJ lpObj = &gObj[aIndex];
  10815.  
  10816. if ( ::PacketCheckTime(lpObj) == FALSE )
  10817. {
  10818. return;
  10819. }
  10820.  
  10821. if ( lpObj->Teleport != 0 )
  10822. {
  10823. return;
  10824. }
  10825.  
  10826. lpObj->X = lpMove->X;
  10827. lpObj->Y = lpMove->Y;
  10828.  
  10829. if ( CC_MAP_RANGE(lpObj->MapNumber) != FALSE )
  10830. {
  10831. if ( (GetTickCount() - lpObj->m_iChaosCastleBlowTime ) < 1000 )
  10832. {
  10833. return;
  10834. }
  10835. }
  10836.  
  10837. if ( gObjCheckXYMapTile(lpObj, 2) == TRUE)
  10838. {
  10839. return;
  10840. }
  10841.  
  10842. PMSG_RECV_POSISTION_SET pMove;
  10843.  
  10844. PHeadSetB((LPBYTE)&pMove, SETPOS_PROTOCOL, sizeof(pMove));
  10845. pMove.NumberH = SET_NUMBERH(aIndex);
  10846. pMove.NumberL = SET_NUMBERL(aIndex);
  10847. pMove.X = lpMove->X;
  10848. pMove.Y = lpMove->Y;
  10849. lpObj->TX = lpMove->X;
  10850. lpObj->TY = lpMove->Y;
  10851.  
  10852. if ( ::gObjPositionCheck(lpObj) == FALSE )
  10853. {
  10854. return;
  10855. }
  10856.  
  10857. CreateFrustrum(lpObj->X, lpObj->Y, aIndex);
  10858.  
  10859. if ( lpObj->Type == OBJ_USER )
  10860. {
  10861. DataSend(aIndex, (UCHAR *)&pMove, pMove.h.size);
  10862. }
  10863.  
  10864. int MVL = MAX_VIEWPORT;
  10865.  
  10866. if ( lpObj->Type == OBJ_MONSTER )
  10867. {
  10868. MVL = MAX_VIEWPORT_MONSTER;
  10869. }
  10870.  
  10871. for ( n=0;n<MVL;n++)
  10872. {
  10873. if ( lpObj->VpPlayer2[n].type == OBJ_USER )
  10874. {
  10875. if ( lpObj->VpPlayer2[n].state == 1 )
  10876. {
  10877. int Index = lpObj->VpPlayer2[n].number;
  10878.  
  10879. if ( gObj[Index].Connected > PLAYER_CONNECTED && gObj[Index].Live != FALSE)
  10880. {
  10881. DataSend(lpObj->VpPlayer2[n].number, (UCHAR *)&pMove, pMove.h.size);
  10882. }
  10883. else
  10884. {
  10885. lpObj->VpPlayer2[n].number = -1;
  10886. lpObj->VpPlayer2[n].state = FALSE;
  10887. lpObj->VPCount2--;
  10888. }
  10889. }
  10890. }
  10891. }
  10892.  
  10893. MapC[lpObj->MapNumber].ClearStandAttr(lpObj->m_OldX, lpObj->m_OldY);
  10894. MapC[lpObj->MapNumber].SetStandAttr(lpObj->TX, lpObj->TY);
  10895.  
  10896. lpObj->m_OldX = lpObj->TX;
  10897. lpObj->m_OldY = lpObj->TY;
  10898.  
  10899. }
  10900.  
  10901.  
  10902.  
  10903.  
  10904. void CGAttack(PMSG_ATTACK* lpMsg, int aIndex)
  10905. {
  10906. LPOBJ lpObj;
  10907. LPOBJ lpTargetObj;
  10908. int usernumber = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  10909.  
  10910. if ( usernumber < 0 || usernumber > OBJMAX-1)
  10911. {
  10912. LogAdd("[CGAttack] [UserIndex Error] :%s %d %d", __FILE__, __LINE__, usernumber);
  10913. return;
  10914. }
  10915.  
  10916. if ( !gObj[usernumber].Live )
  10917. return;
  10918.  
  10919. lpObj = &gObj[aIndex];
  10920.  
  10921. int iTimeCalc = GetTickCount() - lpObj->m_LastAttackTime;
  10922.  
  10923. if ( iTimeCalc < lpObj->m_DetectSpeedHackTime) //season4 changed (fix)
  10924. {
  10925. lpObj->m_DetectCount++;
  10926. lpObj->m_SumLastAttackTime += iTimeCalc;
  10927.  
  10928. if ( lpObj->m_DetectCount > gHackCheckCount )
  10929. {
  10930. lpObj->m_DetectedHackKickCount++;
  10931. lpObj->m_SpeedHackPenalty = gSpeedHackPenalty;
  10932.  
  10933. if ( gIsKickDetecHackCountLimit )
  10934. {
  10935. if ( lpObj->m_DetectedHackKickCount > gDetectedHackKickCount )
  10936. {
  10937. LogAddTD("[%s][%s] %s Kick DetecHackCountLimit Over User (%d)", lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 108)+lpObj->Class), lpObj->m_DetectedHackKickCount);
  10938. CloseClient(aIndex);
  10939. return;
  10940. }
  10941. }
  10942.  
  10943. LogAddTD("[%s][%s] %s Attack Speed Is Wrong Normal (%d)(%d) Penalty %d", lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 108)+lpObj->Class), lpObj->m_DetectSpeedHackTime, lpObj->m_SumLastAttackTime/lpObj->m_DetectCount, lpObj->m_SpeedHackPenalty);
  10944. }
  10945.  
  10946. lpObj->m_LastAttackTime = GetTickCount();
  10947. }
  10948. else
  10949. {
  10950. lpObj->m_SumLastAttackTime = 0;
  10951. lpObj->m_DetectCount = 0;
  10952. }
  10953.  
  10954. lpObj->m_LastAttackTime = GetTickCount();
  10955.  
  10956. if ( bIsIgnorePacketSpeedHackDetect )
  10957. {
  10958. if ( lpObj->m_SpeedHackPenalty > 0 )
  10959. {
  10960. lpObj->m_SpeedHackPenalty--;
  10961.  
  10962. LogAddTD("[%s][%s] %s Apply Attack Speed Penalty (%d left)",
  10963. lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 108)+lpObj->Class),
  10964. lpObj->m_SpeedHackPenalty);
  10965.  
  10966. return;
  10967. }
  10968. }
  10969.  
  10970. lpTargetObj = &gObj[usernumber];
  10971. lpObj->Dir = lpMsg->DirDis;
  10972. GCActionSend(lpObj, lpMsg->AttackAction, aIndex, usernumber);
  10973. gComboAttack.CheckCombo(aIndex, 0);
  10974. gObjAttack(lpObj, lpTargetObj, NULL, FALSE, FALSE, 0, FALSE);
  10975. lpObj->UseMagicNumber = 0;
  10976. }
  10977.  
  10978.  
  10979.  
  10980. void GCDamageSend(int aIndex, int TargetIndex, int AttackDamage, int MSBFlag, int MSBDamage, int iShieldDamage)
  10981. {
  10982. PMSG_ATTACKRESULT pResult;
  10983.  
  10984. PHeadSetB((LPBYTE)&pResult, ATTACK_PROTOCOL, sizeof(pResult));
  10985. pResult.NumberH = SET_NUMBERH(TargetIndex);
  10986. pResult.NumberL = SET_NUMBERL(TargetIndex);
  10987. pResult.DamageH = SET_NUMBERH(AttackDamage);
  10988. pResult.DamageL = SET_NUMBERL(AttackDamage);
  10989. pResult.btShieldDamageH = SET_NUMBERH(iShieldDamage);
  10990. pResult.btShieldDamageL = SET_NUMBERL(iShieldDamage);
  10991. if((gObj[aIndex].Type == OBJ_USER)&&(gObj[TargetIndex].Type != OBJ_USER))
  10992. {
  10993. pResult.Life = gObj[TargetIndex].Life;
  10994. pResult.MaxLife = gObj[TargetIndex].MaxLife+gObj[TargetIndex].AddLife;
  10995. }
  10996. else
  10997. {
  10998. pResult.Life = 0;
  10999. pResult.MaxLife = 0;
  11000. }
  11001. if ( MSBFlag != FALSE )
  11002. {
  11003. pResult.NumberH &= 0x7F;
  11004. pResult.NumberH |= 0x80;
  11005. }
  11006.  
  11007. pResult.DamageType = MSBDamage;
  11008.  
  11009. if ( gObj[TargetIndex].Type == OBJ_USER )
  11010. {
  11011. DataSend(TargetIndex, (LPBYTE)&pResult, pResult.h.size);
  11012. }
  11013.  
  11014. if ( cManager.WatchTargetIndex == TargetIndex || cManager.WatchTargetIndex == aIndex )
  11015. {
  11016. cManager.DataSend((LPBYTE)&pResult, pResult.h.size);
  11017. }
  11018.  
  11019. if ( gObj[aIndex].Type == OBJ_USER )
  11020. {
  11021. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  11022. }
  11023.  
  11024. }
  11025.  
  11026.  
  11027.  
  11028. struct PMSG_DAMAGE
  11029. {
  11030. PBMSG_HEAD h; // C1:F3:07
  11031. BYTE subcode; // 3
  11032. BYTE DamageH; // 4
  11033. BYTE DamageL; // 5
  11034. BYTE btShieldDamageH; // 6
  11035. BYTE btShieldDamageL; // 7
  11036. };
  11037.  
  11038.  
  11039. void GCDamageSend(int aIndex, int damage, int iShieldDamage)
  11040. {
  11041. if ( gObj[aIndex].Type != OBJ_USER )
  11042. {
  11043. return;
  11044. }
  11045.  
  11046.  
  11047. PMSG_DAMAGE pDamage;
  11048.  
  11049. PHeadSubSetB((LPBYTE)&pDamage, 0xF3, 0x07, sizeof(pDamage));
  11050. pDamage.DamageH = SET_NUMBERH(damage);
  11051. pDamage.DamageL = SET_NUMBERL(damage);
  11052. pDamage.btShieldDamageH = SET_NUMBERH(iShieldDamage);
  11053. pDamage.btShieldDamageL = SET_NUMBERL(iShieldDamage);
  11054.  
  11055. DataSend(aIndex, (LPBYTE)&pDamage, pDamage.h.size);
  11056. }
  11057.  
  11058.  
  11059.  
  11060. struct PMSG_KILLPLAYER
  11061. {
  11062. PBMSG_HEAD h; // C1:16
  11063. BYTE NumberH; // 3
  11064. BYTE NumberL; // 4
  11065. BYTE ExpH; // 5
  11066. BYTE ExpL; // 6
  11067. BYTE DamageH; // 7
  11068. BYTE DamageL; // 8
  11069. };
  11070.  
  11071.  
  11072.  
  11073. void GCKillPlayerExpSend(int aIndex, int TargetIndex, int exp, int AttackDamage, BOOL MSBFlag)
  11074. {
  11075. PMSG_KILLPLAYER pkillMsg;
  11076.  
  11077. PHeadSetBE((LPBYTE)&pkillMsg, 0x16, sizeof(pkillMsg));
  11078. pkillMsg.NumberH = SET_NUMBERH(TargetIndex);
  11079. pkillMsg.NumberL = SET_NUMBERL(TargetIndex);
  11080. pkillMsg.ExpH = SET_NUMBERH(exp);
  11081. pkillMsg.ExpL = SET_NUMBERL(exp);
  11082. pkillMsg.DamageH = SET_NUMBERH(AttackDamage);
  11083. pkillMsg.DamageL = SET_NUMBERL(AttackDamage);
  11084.  
  11085. if ( MSBFlag != FALSE )
  11086. {
  11087. pkillMsg.NumberH &= 0x7F;
  11088. pkillMsg.NumberH |= 0x80;
  11089. }
  11090.  
  11091. if ( BC_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE )
  11092. {
  11093. g_BloodCastle.AddExperience(aIndex, exp);
  11094. }
  11095.  
  11096. DataSend(aIndex, (UCHAR*)&pkillMsg, pkillMsg.h.size);
  11097. }
  11098.  
  11099.  
  11100.  
  11101.  
  11102. struct PMSG_DIEPLAYER
  11103. {
  11104. PBMSG_HEAD h; // C1:17
  11105. BYTE NumberH; // 3
  11106. BYTE NumberL; // 4
  11107. BYTE Skill; // 5
  11108. BYTE KillerNumberH; // 6
  11109. BYTE KillerNumberL; // 7
  11110. };
  11111.  
  11112.  
  11113.  
  11114. void GCDiePlayerSend(LPOBJ lpObj, int TargetIndex, BYTE skill, int KillerIndex)
  11115. {
  11116. PMSG_DIEPLAYER pDieMsg;
  11117.  
  11118. PHeadSetB((LPBYTE)&pDieMsg, 0x17, sizeof(pDieMsg));
  11119. pDieMsg.NumberH = SET_NUMBERH(TargetIndex);
  11120. pDieMsg.NumberL = SET_NUMBERL(TargetIndex);
  11121. pDieMsg.Skill = skill;
  11122. pDieMsg.KillerNumberH = SET_NUMBERH(KillerIndex);
  11123. pDieMsg.KillerNumberL = SET_NUMBERL(KillerIndex);
  11124. int iSize = pDieMsg.h.size;
  11125.  
  11126. MsgSendV2(lpObj, (LPBYTE)&pDieMsg, iSize);
  11127.  
  11128. if ( lpObj->Type == OBJ_USER )
  11129. {
  11130. DataSend(lpObj->m_Index, (LPBYTE)&pDieMsg, iSize);
  11131. }
  11132. }
  11133.  
  11134.  
  11135.  
  11136.  
  11137. void GCActionSend(LPOBJ lpObj, BYTE ActionNumber, int aIndex, int aTargetIndex)
  11138. {
  11139. PMSG_ACTIONRESULT pActionResult;
  11140.  
  11141. PHeadSetB((LPBYTE)&pActionResult, 0x18, sizeof(pActionResult));
  11142. pActionResult.NumberH = SET_NUMBERH(aIndex);
  11143. pActionResult.NumberL = SET_NUMBERL(aIndex);
  11144. pActionResult.ActionNumber = ActionNumber;
  11145. pActionResult.Dir = lpObj->Dir;
  11146. pActionResult.TargetNumberH = SET_NUMBERH(aTargetIndex);
  11147. pActionResult.TargetNumberL = SET_NUMBERL(aTargetIndex);
  11148.  
  11149. MsgSendV2(lpObj, (LPBYTE)&pActionResult, pActionResult.h.size);
  11150. }
  11151.  
  11152.  
  11153.  
  11154.  
  11155. void CGActionRecv(PMSG_ACTION * lpMsg, int aIndex)
  11156. {
  11157. if ( !OBJMAX_RANGE(aIndex))
  11158. {
  11159. LogAdd("error : move protocol index error %s %d", __FILE__, __LINE__);
  11160. return;
  11161. }
  11162.  
  11163. PMSG_ACTIONRESULT pResult;
  11164. LPOBJ lpObj = &gObj[aIndex];
  11165.  
  11166. PHeadSetB((LPBYTE)&pResult, 0x18, sizeof(pResult));
  11167. pResult.ActionNumber = lpMsg->ActionNumber;
  11168. pResult.NumberH = SET_NUMBERH(aIndex);
  11169. pResult.NumberL = SET_NUMBERL(aIndex);
  11170. lpObj->m_ActionNumber = lpMsg->ActionNumber;
  11171. lpObj->Dir = lpMsg->Dir;
  11172. pResult.Dir = lpObj->Dir;
  11173. pResult.TargetNumberH = lpMsg->iTargetIndexH;
  11174. pResult.TargetNumberL = lpMsg->iTargetIndexL;
  11175.  
  11176. if ( lpObj->m_ActionNumber == 0x80)
  11177. {
  11178. lpObj->m_ViewState = 2;
  11179. lpObj->m_Rest = lpObj->m_ActionNumber;
  11180. }
  11181. else if ( lpObj->m_ActionNumber == 0x81 )
  11182. {
  11183. lpObj->m_ViewState = 3;
  11184. lpObj->m_Rest = lpObj->m_ActionNumber;
  11185. }
  11186. else if ( lpObj->m_ActionNumber == 0x82 )
  11187. {
  11188. lpObj->m_ViewState = 4;
  11189. lpObj->m_Rest = lpObj->m_ActionNumber;
  11190. }
  11191.  
  11192. int MVL = MAX_VIEWPORT;
  11193.  
  11194. if ( lpObj->Type == OBJ_MONSTER )
  11195. MVL = MAX_VIEWPORT_MONSTER;
  11196.  
  11197. for (int n=0;n<MVL;n++)
  11198. {
  11199. if ( lpObj->VpPlayer2[n].type == OBJ_USER )
  11200. {
  11201. if ( lpObj->VpPlayer2[n].state != 0 && lpObj->VpPlayer2[n].state != 0x10 && lpObj->VpPlayer2[n].state != 0x08)
  11202. {
  11203. DataSend(lpObj->VpPlayer2[n].number, (LPBYTE)&pResult, pResult.h.size);
  11204.  
  11205. }
  11206. }
  11207. }
  11208. }
  11209.  
  11210.  
  11211.  
  11212.  
  11213. void CGMagicAttack(PMSG_MAGICATTACK* lpMsg, int aIndex)
  11214. {
  11215. LPOBJ lpObj;
  11216. LPOBJ lpTargetObj;
  11217. int usernumber = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  11218.  
  11219. if ( usernumber < 0 || usernumber > OBJMAX-1 )
  11220. {
  11221. LogAdd("error :%s %d %d", __FILE__, __LINE__, usernumber);
  11222. return;
  11223. }
  11224.  
  11225. if ( gObj[usernumber].Live == 0 || gObj[usernumber].Connected < PLAYER_LOGGED )
  11226. return;
  11227.  
  11228. if ( gObj[aIndex].CloseCount >= 0 )
  11229. return;
  11230.  
  11231. lpObj = &gObj[aIndex];
  11232. lpTargetObj = &gObj[usernumber];
  11233.  
  11234. CMagicInf * lpMagic;
  11235. int attackret = gObjCheckAttackArea(aIndex, usernumber);
  11236.  
  11237. if ( attackret )
  11238. {
  11239. LogAddTD("[%s][%s] Try Attack In Not Attack Area [Protocol] (%s:%d,%d) errortype = %d",
  11240. lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 208)+lpObj->MapNumber), lpObj->X, lpObj->Y,
  11241. attackret);
  11242.  
  11243. if ( lpObj->Class == 275 ) // Kundun
  11244. lpObj->TargetNumber = -1;
  11245.  
  11246. if ( bIsIgnorePacketSpeedHackDetect )
  11247. return;
  11248. }
  11249.  
  11250. if ( lpObj->Type == OBJ_USER )
  11251. {
  11252. if ( lpMsg->MagicNumber == 58 )
  11253. usernumber = 58; // #error BIG ERROR - Deathway
  11254.  
  11255. lpMagic = gObjGetMagicSearch(lpObj, lpMsg->MagicNumber);
  11256.  
  11257. if ( !lpMagic )
  11258. return;
  11259.  
  11260. if ( MagicDamageC.SkillGetRequireClass(lpObj->Class, lpObj->ChangeUP, lpMagic->m_Skill) < 1 )
  11261. return;
  11262.  
  11263. if ( MagicDamageC.CheckStatus(lpMagic->m_Skill, lpObj->GuildStatus) == 0 )
  11264. {
  11265. LogAddC(2, "[0x19] CGMagicAttack() - Invalid Status");
  11266. return;
  11267. }
  11268.  
  11269. if ( MagicDamageC.CheckKillCount(lpMagic->m_Skill, lpObj->m_btKillCount) < 0 )
  11270. {
  11271. LogAddC(2, "[0x19] CGMagicAttack() - Invalid KillCount");
  11272. return;
  11273. }
  11274. }
  11275. else
  11276. {
  11277. lpMagic = gObjGetMagic(lpObj, lpMsg->MagicNumber);
  11278.  
  11279. if ( !lpMagic )
  11280. return;
  11281. }
  11282.  
  11283. if ( lpMagic->m_Skill != 24 && gObjUseSkill.SpeedHackCheck(aIndex) == FALSE )
  11284. return;
  11285.  
  11286. if ( !gCheckSkillDistance(aIndex, usernumber, lpMagic->m_Skill))
  11287. {
  11288. DWORD dwTick = GetTickCount() - lpObj->m_dwSkillDistanceErrorTick;
  11289.  
  11290. if ( dwTick > (g_iSkillDiatanceKickCheckTime*1000) )
  11291. {
  11292. lpObj->m_iSkillDistanceErrorCount = 0;
  11293. lpObj->m_dwSkillDistanceErrorTick = GetTickCount();
  11294. }
  11295.  
  11296. lpObj->m_iSkillDistanceErrorCount++;
  11297.  
  11298. if ( lpObj->m_iSkillDistanceErrorCount > g_iSkillDistanceKickCount )
  11299. {
  11300. if ( g_iSkillDistanceKick )
  11301. {
  11302. LogAddTD("[SKILL DISTANCE CHECK] [%s][%s] Kick Invalid Skill Area User. count(%d)",
  11303. lpObj->AccountID, lpObj->Name, lpObj->m_iSkillDistanceErrorCount);
  11304.  
  11305. CloseClient(lpObj->m_Index);
  11306. return;
  11307. }
  11308.  
  11309. lpObj->m_iSkillDistanceErrorCount=0;
  11310. }
  11311.  
  11312. return;
  11313. }
  11314.  
  11315. gObjUseSkill.UseSkill(aIndex, usernumber, lpMagic);
  11316. }
  11317.  
  11318.  
  11319.  
  11320.  
  11321. void GCMagicAttackNumberSend(LPOBJ lpObj, BYTE MagicNumber, int usernumber, unsigned char skillsuccess)
  11322. {
  11323. PMSG_MAGICATTACK_RESULT pAttack;
  11324.  
  11325. PHeadSetBE((LPBYTE)&pAttack, 0x19, sizeof(pAttack));
  11326. pAttack.MagicNumber = MagicNumber;
  11327. pAttack.SourceNumberH = SET_NUMBERH(lpObj->m_Index);
  11328. pAttack.SourceNumberL = SET_NUMBERL(lpObj->m_Index);
  11329. pAttack.TargetNumberH = SET_NUMBERH(usernumber);
  11330. pAttack.TargetNumberL = SET_NUMBERL(usernumber);
  11331. pAttack.TargetNumberH &= 0x7F;
  11332.  
  11333. if ( skillsuccess )
  11334. pAttack.TargetNumberH |= 0x80;
  11335.  
  11336. if ( lpObj->Type == OBJ_USER )
  11337. DataSend(lpObj->m_Index, (LPBYTE)&pAttack, pAttack.h.size);
  11338.  
  11339. if ( CC_MAP_RANGE(lpObj->MapNumber) )
  11340. {
  11341. switch ( MagicNumber )
  11342. {
  11343. case 16:
  11344. case 26:
  11345. case 27:
  11346. case 28:
  11347. case 48:
  11348. return;
  11349. }
  11350. }
  11351.  
  11352. MsgSendV2(lpObj, (LPBYTE)&pAttack, pAttack.h.size);
  11353. }
  11354.  
  11355.  
  11356.  
  11357.  
  11358.  
  11359. void GCMagicCancelSend(LPOBJ lpObj, BYTE MagicNumber)
  11360. {
  11361. PMSG_MAGICCANCEL pMsg;
  11362.  
  11363. PHeadSetB((LPBYTE)&pMsg, 0x1B, sizeof(pMsg));
  11364. pMsg.MagicNumber = MagicNumber;
  11365. pMsg.NumberH = SET_NUMBERH(lpObj->m_Index);
  11366. pMsg.NumberL = SET_NUMBERL(lpObj->m_Index);
  11367.  
  11368. if ( lpObj->Type == OBJ_USER )
  11369. DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size);
  11370.  
  11371. MsgSendV2(lpObj, (UCHAR*)&pMsg, pMsg.h.size);
  11372. }
  11373.  
  11374.  
  11375.  
  11376. struct PMSG_USEEFFECTITEM
  11377. {
  11378. PBMSG_HEAD h; // C1:2D
  11379. WORD wOptionType; // 4
  11380. WORD wEffectType; // 6
  11381. BYTE byEffectOption; // 8
  11382. int iLeftTime; // C
  11383. };
  11384.  
  11385.  
  11386.  
  11387. void GCUseEffectItem(LPOBJ lpObj, int iEffectUseOption, int iOptionType, int iEffectType, int iLeftTime)
  11388. {
  11389. PMSG_USEEFFECTITEM pMsg;
  11390.  
  11391. PHeadSetB((LPBYTE)&pMsg, 0x2D, sizeof(pMsg));
  11392. pMsg.byEffectOption = iEffectUseOption;
  11393. pMsg.wOptionType = iOptionType;
  11394. pMsg.wEffectType = iEffectType;
  11395. pMsg.iLeftTime = iLeftTime;
  11396.  
  11397. if ( lpObj->Type == OBJ_USER )
  11398. DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size);
  11399. }
  11400. struct PMSG_VIEWSKILLSTATE
  11401. {
  11402. PBMSG_HEAD h; // C1:07
  11403. BYTE State; // 3
  11404. int ViewSkillState; // 4
  11405. BYTE NumberH; // 8
  11406. BYTE NumberL; // 9
  11407. };
  11408.  
  11409.  
  11410. void GCStateInfoSend(LPOBJ lpObj, BYTE state, int ViewSkillState)
  11411. {
  11412. PMSG_VIEWSKILLSTATE pMsg;
  11413.  
  11414. PHeadSetB((LPBYTE)&pMsg, 0x07, sizeof(pMsg));
  11415. pMsg.State = state;
  11416. pMsg.ViewSkillState = ViewSkillState;
  11417. pMsg.NumberH = SET_NUMBERH(lpObj->m_Index);
  11418. pMsg.NumberL = SET_NUMBERL(lpObj->m_Index);
  11419.  
  11420. if ( lpObj->Type == OBJ_USER )
  11421. DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size);
  11422.  
  11423. if ( CC_MAP_RANGE(lpObj->MapNumber) != FALSE )
  11424. pMsg.ViewSkillState = 0;
  11425.  
  11426. MsgSendV2(lpObj, (UCHAR*)&pMsg, pMsg.h.size);
  11427. }
  11428.  
  11429. void CGMagicCancel(PMSG_MAGICCANCEL * lpMsg, int aIndex)
  11430. {
  11431. if ( !OBJMAX_RANGE(aIndex))
  11432. return;
  11433.  
  11434. LPOBJ lpObj = &gObj[aIndex];
  11435.  
  11436.  
  11437. if ( lpMsg->MagicNumber == 77 )
  11438. {
  11439. if ( lpObj->m_iMuseElfInfinityArrowSkillTime > 0 )
  11440. {
  11441. lpObj->m_iMuseElfInfinityArrowSkillTime = 0;
  11442. lpObj->m_ViewSkillState &= 0xFBFFFFFF;
  11443. GCStateInfoSend(lpObj, 0, 0x04000000);
  11444. }
  11445. }
  11446. }
  11447.  
  11448.  
  11449. struct PMSG_USE_MONSTERSKILL
  11450. {
  11451. PBMSG_HEAD h; // C1:69
  11452. BYTE btMonsterSkillNumber; // 3
  11453. WORD wObjIndex; // 4
  11454. WORD wTargetObjIndex; // 6
  11455. };
  11456.  
  11457.  
  11458. void GCUseMonsterSkillSend(LPOBJ lpObj, LPOBJ lpTargetObj, int iSkillNumber)
  11459. {
  11460. PMSG_USE_MONSTERSKILL pMsg;
  11461.  
  11462. PHeadSetB((LPBYTE)&pMsg, 0x69, sizeof(pMsg));
  11463. pMsg.btMonsterSkillNumber = iSkillNumber;
  11464. pMsg.wObjIndex = lpObj->m_Index;
  11465. pMsg.wTargetObjIndex = lpTargetObj->m_Index;
  11466.  
  11467. if ( lpObj->Type == OBJ_USER )
  11468. DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size);
  11469.  
  11470. MsgSendV2(lpObj, (UCHAR*)&pMsg, pMsg.h.size);
  11471. }
  11472.  
  11473.  
  11474.  
  11475.  
  11476.  
  11477. struct PMSG_TELEPORT_RESULT
  11478. {
  11479. PBMSG_HEAD h; // C3:1C
  11480. BYTE MoveNumber; // 3
  11481. BYTE MapNumber; // 4
  11482. BYTE MapX; // 5
  11483. BYTE MapY; // 6
  11484. BYTE Dir; // 7
  11485. };
  11486.  
  11487.  
  11488.  
  11489. void CGTeleportRecv(PMSG_TELEPORT* lpMsg, int aIndex)
  11490. {
  11491. if ( !OBJMAX_RANGE(aIndex))
  11492. return;
  11493.  
  11494. if ( gObj[aIndex].m_iSkillStunTime > 0 )
  11495. return;
  11496.  
  11497. CMagicInf * lpMagic;
  11498. BYTE x;
  11499. BYTE y;
  11500. PMSG_MAGICATTACK_RESULT pAttack;
  11501.  
  11502. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE) //season 2.5 add-on
  11503. {
  11504. if (g_IllusionTempleEvent.GetState(gObj[aIndex].MapNumber) == 2)
  11505. {
  11506. if (g_IllusionTempleEvent.CheckTeleport(aIndex) != FALSE)
  11507. {
  11508. PMSG_TELEPORT_RESULT pTeleportResult;
  11509.  
  11510. pTeleportResult.h.c = 0xC3;
  11511. pTeleportResult.h.size = sizeof(pTeleportResult);
  11512. pTeleportResult.h.headcode = 0x1C;
  11513. pTeleportResult.MoveNumber = 0;
  11514. pTeleportResult.MapNumber = gObj[aIndex].MapNumber;
  11515. pTeleportResult.MapX = gObj[aIndex].X;
  11516. pTeleportResult.MapY = gObj[aIndex].Y;
  11517. pTeleportResult.Dir = gObj[aIndex].Dir;
  11518. DataSend(aIndex, (LPBYTE)&pTeleportResult, pTeleportResult.h.size);
  11519. return;
  11520. }
  11521. if (g_IllusionTempleEvent.GetRestrictionSpellStatus(gObj[aIndex].m_iIllusionTempleIndex,gObj[aIndex].MapNumber) != FALSE)
  11522. {
  11523. PMSG_TELEPORT_RESULT pTeleportResult;
  11524.  
  11525. pTeleportResult.h.c = 0xC3;
  11526. pTeleportResult.h.size = sizeof(pTeleportResult);
  11527. pTeleportResult.h.headcode = 0x1C;
  11528. pTeleportResult.MoveNumber = 0;
  11529. pTeleportResult.MapNumber = gObj[aIndex].MapNumber;
  11530. pTeleportResult.MapX = gObj[aIndex].X;
  11531. pTeleportResult.MapY = gObj[aIndex].Y;
  11532. pTeleportResult.Dir = gObj[aIndex].Dir;
  11533. DataSend(aIndex, (LPBYTE)&pTeleportResult, pTeleportResult.h.size);
  11534. return;
  11535. }
  11536. }
  11537. }
  11538.  
  11539. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE) //season 2.5 add-on
  11540. {
  11541. if (g_IllusionTempleEvent.GetState(gObj[aIndex].MapNumber) == 1)
  11542. {
  11543. PMSG_TELEPORT_RESULT pTeleportResult;
  11544.  
  11545. pTeleportResult.h.c = 0xC3;
  11546. pTeleportResult.h.size = sizeof(pTeleportResult);
  11547. pTeleportResult.h.headcode = 0x1C;
  11548. pTeleportResult.MoveNumber = 0;
  11549. pTeleportResult.MapNumber = gObj[aIndex].MapNumber;
  11550. pTeleportResult.MapX = gObj[aIndex].X;
  11551. pTeleportResult.MapY = gObj[aIndex].Y;
  11552. pTeleportResult.Dir = gObj[aIndex].Dir;
  11553. DataSend(aIndex, (LPBYTE)&pTeleportResult, pTeleportResult.h.size);
  11554. return;
  11555. }
  11556. }
  11557.  
  11558.  
  11559. if ( lpMsg->MoveNumber == 0 )
  11560. {
  11561.  
  11562. PHeadSetBE((LPBYTE)&pAttack, 0x19, sizeof(pAttack));
  11563. pAttack.MagicNumber = 6;
  11564. pAttack.SourceNumberH = SET_NUMBERH(aIndex);
  11565. pAttack.SourceNumberL = SET_NUMBERL(aIndex);
  11566. pAttack.TargetNumberH = SET_NUMBERH(aIndex);
  11567. pAttack.TargetNumberL = SET_NUMBERL(aIndex);
  11568.  
  11569. lpMagic = gObjGetMagicSearch(&gObj[aIndex], 6);
  11570. x = lpMsg->MapX;
  11571. y = lpMsg->MapY;
  11572.  
  11573. if ( gObjCheckTeleportArea(aIndex, x, y) == FALSE )
  11574. {
  11575. LogAddC(2, "[%s][%s] Try Teleport Not Move Area [%d,%d]",
  11576. gObj[aIndex].AccountID, gObj[aIndex].Name,
  11577. x, y);
  11578.  
  11579. if ( szAuthKey[5] != AUTHKEY5 )
  11580. DestroyGIocp();
  11581.  
  11582. PMSG_TELEPORT_RESULT pTeleportResult;
  11583.  
  11584. pTeleportResult.h.c = 0xC3;
  11585. pTeleportResult.h.size = sizeof(pTeleportResult);
  11586. pTeleportResult.h.headcode = 0x1C;
  11587. pTeleportResult.MoveNumber = 0;
  11588. pTeleportResult.MapNumber = gObj[aIndex].MapNumber;
  11589. pTeleportResult.MapX = gObj[aIndex].X;
  11590. pTeleportResult.MapY = gObj[aIndex].Y;
  11591. pTeleportResult.Dir = gObj[aIndex].Dir;
  11592.  
  11593. DataSend(aIndex, (LPBYTE)&pTeleportResult, pTeleportResult.h.size);
  11594. return;
  11595. }
  11596. if ( gObj[aIndex].MapNumber == MAP_INDEX_CASTLESIEGE )
  11597. {
  11598. if ( g_CastleSiege.CheckTeleportMagicAxisY(gObj[aIndex].Y, x, y) == FALSE )
  11599. {
  11600. y = gObj[aIndex].Y;
  11601. }
  11602. }
  11603.  
  11604. if ( lpMagic )
  11605. {
  11606. int usemana = gObjMagicManaUse(&gObj[aIndex], lpMagic);
  11607.  
  11608. if ( usemana >= 0 )
  11609. {
  11610. int usebp = gObjMagicBPUse(&gObj[aIndex], lpMagic);
  11611.  
  11612. if ( usebp >= 0 )
  11613. {
  11614. if ( gObj[aIndex].Type == OBJ_USER )
  11615. DataSend(aIndex, (LPBYTE)&pAttack, pAttack.h.size);
  11616.  
  11617. MsgSendV2(&gObj[aIndex], (LPBYTE)&pAttack, pAttack.h.size);
  11618. gObjTeleportMagicUse(aIndex, x, y);
  11619. gObj[aIndex].Mana = usemana;
  11620. gObj[aIndex].BP = usebp;
  11621. GCManaSend(gObj[aIndex].m_Index, gObj[aIndex].Mana, -1, 0, gObj[aIndex].BP);
  11622. }
  11623. }
  11624. }
  11625. return;
  11626. }
  11627.  
  11628. if ( gGateC.IsInGate(aIndex, lpMsg->MoveNumber) )
  11629. {
  11630. gObjMoveGate(aIndex, lpMsg->MoveNumber);
  11631. return;
  11632. }
  11633. gObjClearViewport(&gObj[aIndex]);
  11634. GCTeleportSend(&gObj[aIndex], lpMsg->MoveNumber,
  11635. gObj[aIndex].MapNumber, gObj[aIndex].X, gObj[aIndex].Y, gObj[aIndex].Dir);
  11636.  
  11637. if ( gObj[aIndex].MapNumber == MAP_INDEX_CASTLESIEGE )
  11638. {
  11639. if ( g_CastleSiege.GetCastleState() == CASTLESIEGE_STATE_STARTSIEGE )
  11640. {
  11641. g_CastleSiege.NotifySelfCsJoinSide(aIndex);
  11642. g_CastleSiege.NotifyCsSelfLeftTime(aIndex);
  11643. }
  11644. }
  11645. }
  11646.  
  11647.  
  11648.  
  11649.  
  11650. void CGTargetTeleportRecv(PMSG_TARGET_TELEPORT * lpMsg, int aIndex)
  11651. {
  11652. if ( !OBJMAX_RANGE(aIndex))
  11653. return;
  11654.  
  11655. if ( gObj[aIndex].m_iSkillStunTime > 0 )
  11656. return;
  11657.  
  11658. CMagicInf * lpMagic;
  11659. BYTE x;
  11660. BYTE y;
  11661. PMSG_MAGICATTACK_RESULT pAttack;
  11662.  
  11663. PHeadSetBE((LPBYTE)&pAttack, 0x19, sizeof(pAttack));
  11664. pAttack.MagicNumber = AT_SKILL_TARGET_TELEPORT;
  11665. pAttack.SourceNumberH = SET_NUMBERH(aIndex);
  11666. pAttack.SourceNumberL = SET_NUMBERL(aIndex);
  11667. int iTargetIndex = MAKE_NUMBERW(lpMsg->NumberL, lpMsg->NumberH); // #error? parameters inverse?
  11668. pAttack.TargetNumberH = SET_NUMBERH(iTargetIndex); // #error? parameters inverse?
  11669. pAttack.TargetNumberL = SET_NUMBERL(iTargetIndex); // #error? parameters inverse?
  11670. lpMagic = gObjGetMagicSearch(&gObj[aIndex], AT_SKILL_TARGET_TELEPORT);
  11671. x = lpMsg->MapX;
  11672. y = lpMsg->MapY;
  11673.  
  11674. if ( !gObjIsConnectedGP(iTargetIndex) )
  11675. {
  11676. LogAddC(2, "[%s][%s] Try Target Teleport Not Move Area [%d,%d]",
  11677. gObj[aIndex].AccountID, gObj[aIndex].Name, x, y);
  11678.  
  11679. return;
  11680. }
  11681.  
  11682.  
  11683.  
  11684. if ( gObj[aIndex].PartyNumber != gObj[iTargetIndex].PartyNumber ||
  11685. gObj[aIndex].PartyNumber == -1 ||
  11686. gObj[iTargetIndex].PartyNumber == -1)
  11687. {
  11688. return;
  11689. }
  11690.  
  11691. if ( !gObjCheckTeleportArea(iTargetIndex, x, y))
  11692. {
  11693. LogAddC(2, "[%s][%s] Try Target Teleport Not Move Area [%d,%d]",
  11694. gObj[aIndex].AccountID, gObj[aIndex].Name, x, y);
  11695.  
  11696. return;
  11697. }
  11698. if (IT_MAP_RANGE(gObj[iTargetIndex].MapNumber) != FALSE) //season 2.5 add-on
  11699. {
  11700. if (g_IllusionTempleEvent.CheckTeleport(gObj[iTargetIndex].m_Index) != FALSE)
  11701. {
  11702. return;
  11703. }
  11704. }
  11705. if ( lpMagic )
  11706. {
  11707. int usemana = gObjMagicManaUse(&gObj[aIndex], lpMagic);
  11708.  
  11709. if ( usemana >= 0 )
  11710. {
  11711. int usebp = gObjMagicBPUse(&gObj[aIndex], lpMagic);
  11712.  
  11713. if ( usebp >= 0 )
  11714. {
  11715. if ( gObj[aIndex].Type == OBJ_USER )
  11716. DataSend(aIndex, (LPBYTE)&pAttack, pAttack.h.size);
  11717.  
  11718. MsgSendV2(&gObj[aIndex], (LPBYTE)&pAttack, pAttack.h.size);
  11719. gObjTeleportMagicUse(iTargetIndex, x, y);
  11720. gObj[aIndex].Mana = usemana;
  11721. gObj[aIndex].BP = usebp;
  11722. GCManaSend(gObj[aIndex].m_Index, gObj[aIndex].Mana, -1, 0, gObj[aIndex].BP);
  11723.  
  11724. return;
  11725. }
  11726. }
  11727. }
  11728. }
  11729.  
  11730.  
  11731.  
  11732.  
  11733.  
  11734.  
  11735. void GCTeleportSend(LPOBJ lpObj, BYTE MoveNumber, BYTE MapNumber, BYTE MapX, BYTE MapY, BYTE Dir)
  11736. {
  11737. PMSG_TELEPORT_RESULT pMsg;
  11738.  
  11739. if ( lpObj->Type != OBJ_USER )
  11740. return;
  11741.  
  11742. pMsg.h.c = 0xC3;
  11743. pMsg.h.size = sizeof(pMsg);
  11744. pMsg.h.headcode = 0x1C;
  11745. pMsg.MoveNumber = MoveNumber;
  11746. pMsg.MapNumber = MapNumber;
  11747. pMsg.MapX = MapX;
  11748. pMsg.MapY = MapY;
  11749. pMsg.Dir = Dir;
  11750.  
  11751. if ( MoveNumber == 0 )
  11752. DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size);
  11753. else
  11754. DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size);
  11755. }
  11756.  
  11757.  
  11758.  
  11759.  
  11760.  
  11761. void CGBeattackRecv(unsigned char* lpRecv, int aIndex, int magic_send)
  11762. {
  11763. // Set the lpRecv to a Predeterminated Packet
  11764. PMSG_BEATTACK_COUNT * lpCount = (PMSG_BEATTACK_COUNT *)lpRecv;
  11765.  
  11766. // Check the Protocol
  11767. if ( lpCount->h.headcode != BEATTACK_PROTOCOL )
  11768. {
  11769. LogAdd("error-L3 %s %d", __FILE__, __LINE__);
  11770. return;
  11771. }
  11772.  
  11773. // Check if the count is leess than 1
  11774. if ( lpCount->Count < 1 )
  11775. {
  11776. LogAdd("error-L3 %s %d", __FILE__, __LINE__);
  11777. return;
  11778. }
  11779.  
  11780. // Set the Max limitation to 5
  11781. if ( lpCount->Count > 5 )
  11782. {
  11783. lpCount->Count = 5;
  11784. }
  11785.  
  11786. // Set the Start of the Offset
  11787. int lOfs = sizeof(PMSG_BEATTACK_COUNT);
  11788. CMagicInf * lpMagic;
  11789. int tNumber;
  11790. PMSG_BEATTACK * lpMsg;
  11791.  
  11792. // Set lpMagic according
  11793. // if aIndex is OBJ_USER
  11794. // or if it is OBJ_MONSTER
  11795. if ( gObj[aIndex].Type == OBJ_USER )
  11796. {
  11797. lpMagic = gObjGetMagicSearch(&gObj[aIndex], lpCount->MagicNumber);
  11798. }
  11799. else
  11800. {
  11801. lpMagic = gObjGetMagic(&gObj[aIndex], lpCount->MagicNumber);
  11802. }
  11803.  
  11804. // Check if there is Magic
  11805. if ( lpMagic == NULL )
  11806. {
  11807. LogAdd("error-L3 %s %d", __FILE__, __LINE__);
  11808. return;
  11809. }
  11810.  
  11811. // Avoid use Skill of the following types
  11812. if ( lpMagic->m_Skill == 42 ||
  11813. lpMagic->m_Skill == 43 ||
  11814. lpMagic->m_Skill == 41 )
  11815. {
  11816. return;
  11817. }
  11818.  
  11819. if ( gObj[aIndex].Type == OBJ_USER )
  11820. {
  11821. // Check if Player can use Magic
  11822. // Acording to its Class
  11823. if ( MagicDamageC.SkillGetRequireClass(gObj[aIndex].Class,
  11824. gObj[aIndex].ChangeUP,
  11825. lpMagic->m_Skill) < 1 )
  11826. {
  11827. // It's not his magic [%s][%s] .
  11828. LogAddC(2, lMsg.Get(MSGGET(1, 239)),
  11829. gObj[aIndex].AccountID,
  11830. gObj[aIndex].Name,
  11831. lpMagic->m_Skill); // #error Deathway change on WTFFile
  11832.  
  11833. gObjUserKill(aIndex);
  11834. return;
  11835. }
  11836.  
  11837. // Check the time cast Spell
  11838. // No longer that 8 seconds
  11839. if ( (GetTickCount()- gObj[aIndex].UseMagicTime) > 8000 )
  11840. {
  11841. LogAddC(2, "Too long time passed after casting magic. [%s][%s] (%d)(%d)",
  11842. gObj[aIndex].AccountID,
  11843. gObj[aIndex].Name,
  11844. lpMagic->m_Skill,
  11845. GetTickCount() - gObj[aIndex].UseMagicTime);
  11846.  
  11847. return;
  11848. }
  11849.  
  11850. // Check if user cast to much Spells
  11851. // Npo longer thant 4
  11852. if ( gObj[aIndex].UseMagicCount > 4 )
  11853. {
  11854. return;
  11855. }
  11856.  
  11857. gObj[aIndex].UseMagicCount++;
  11858. }
  11859.  
  11860.  
  11861. // Avoid Attack out of the predeterminated
  11862. // Magic need to be one of the following
  11863. //
  11864. // 8 "Twister"
  11865. // 9 "Evil Spirit"
  11866. // 10 "Hellfire"
  11867. // 13 "Blast"
  11868. // 14 "Inferno"
  11869. // 5 "Flame"
  11870. // 24 "Triple Shot"
  11871. // 50 "Flame of Evil(Monster)"
  11872. // 12 "Aquaflash"
  11873. // 41 "Twisting Slash"
  11874. // 47 "Impale"
  11875. // 43 "Death Stab"
  11876. // 42 "Rageful Blow"
  11877. // 52 "Penetration"
  11878. // 55 "Fire Slash"
  11879. // 78 "#Unknown"
  11880.  
  11881. if ( lpMagic->m_Skill != 8
  11882. && lpMagic->m_Skill != 9
  11883. && lpMagic->m_Skill != 10
  11884. && lpMagic->m_Skill != 13
  11885. && lpMagic->m_Skill != 14
  11886. && lpMagic->m_Skill != 5
  11887. && lpMagic->m_Skill != 24
  11888. && lpMagic->m_Skill != 50
  11889. && lpMagic->m_Skill != 12
  11890. && lpMagic->m_Skill != 41
  11891. && lpMagic->m_Skill != 47
  11892. && lpMagic->m_Skill != 43
  11893. && lpMagic->m_Skill != 42
  11894. && lpMagic->m_Skill != 52
  11895. && lpMagic->m_Skill != 55
  11896. && lpMagic->m_Skill != 61
  11897. && lpMagic->m_Skill != 62
  11898. && lpMagic->m_Skill != 78
  11899. && lpMagic->m_Skill != 80 )
  11900. {
  11901. LogAdd("error-L3 [Skill is %d] %s %d", lpMagic->m_Skill ,__FILE__, __LINE__);
  11902. return;
  11903. }
  11904.  
  11905. if ( lpMagic->m_Skill == 24 || lpMagic->m_Skill == 78 )
  11906. {
  11907. int NSAttackSerial = lpCount->Serial;
  11908.  
  11909. if ( gObj[aIndex].OSAttackSerial >= 255 && (gObj[aIndex].OSAttackSerial - lpCount->Serial) > 50 )
  11910. {
  11911. gObj[aIndex].OSAttackSerial = -1;
  11912. }
  11913.  
  11914. if ( NSAttackSerial > gObj[aIndex].OSAttackSerial )
  11915. {
  11916. gObj[aIndex].OSAttackSerial = NSAttackSerial;
  11917. LPOBJ lpObj = &gObj[aIndex];
  11918. int iTimeCalc = GetTickCount() - lpObj->m_LastAttackTime;
  11919.  
  11920. if ( iTimeCalc < lpObj->m_DetectSpeedHackTime && iTimeCalc )
  11921. {
  11922. lpObj->m_DetectCount++;
  11923. lpObj->m_SumLastAttackTime += iTimeCalc;
  11924.  
  11925. if ( lpObj->m_DetectCount > gHackCheckCount )
  11926. {
  11927. lpObj->m_DetectedHackKickCount++;
  11928.  
  11929. if ( gIsKickDetecHackCountLimit )
  11930. {
  11931. if ( lpObj->m_DetectedHackKickCount > gDetectedHackKickCount )
  11932. {
  11933. LogAddTD("[%s][%s] %s Kick DetecHackCountLimit Over User (%d)",
  11934. lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 108)+lpObj->Class),
  11935. lpObj->m_DetectedHackKickCount);
  11936.  
  11937. CloseClient(aIndex);
  11938. return;
  11939. }
  11940. }
  11941.  
  11942. LogAddTD("[%s][%s] %s Attack Speed Is Wrong Magic3 (%d)(%d) Penalty %d",
  11943. lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 108)+lpObj->Class),
  11944. lpObj->m_DetectSpeedHackTime,lpObj->m_SumLastAttackTime/lpObj->m_DetectCount,
  11945. lpObj->m_SpeedHackPenalty);
  11946. }
  11947.  
  11948. lpObj->m_LastAttackTime = GetTickCount();
  11949. }
  11950. else
  11951. {
  11952. lpObj->m_SumLastAttackTime = 0;
  11953. lpObj->m_DetectCount = 0;
  11954. }
  11955.  
  11956. lpObj->m_LastAttackTime = GetTickCount();
  11957. }
  11958. }
  11959.  
  11960. if ( bIsIgnorePacketSpeedHackDetect )
  11961. {
  11962. LPOBJ lpObj = &gObj[aIndex];
  11963.  
  11964. if ( lpObj->m_SpeedHackPenalty > 0 )
  11965. {
  11966. lpObj->m_SpeedHackPenalty--;
  11967.  
  11968. LogAddTD("[%s][%s] %s Apply Attack Speed Penalty (%d left)",
  11969. lpObj->AccountID, lpObj->Name, lMsg.Get(MSGGET(7, 108)+lpObj->Class),
  11970. lpObj->m_SpeedHackPenalty);
  11971.  
  11972. return;
  11973. }
  11974. }
  11975.  
  11976. int lOfs2 = lOfs;
  11977. int pTargetNumber[128];
  11978.  
  11979. for (int i=0;i<lpCount->Count;i++)
  11980. {
  11981. lpMsg = (PMSG_BEATTACK *)&lpRecv[lOfs2];
  11982. pTargetNumber[i] = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  11983. lOfs2 += sizeof(PMSG_BEATTACK);
  11984. }
  11985.  
  11986. for (int n=0;n<lpCount->Count;n++)
  11987. {
  11988. lpMsg = (PMSG_BEATTACK *)&lpRecv[lOfs];
  11989. tNumber = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  11990. LPOBJ lpObj = &gObj[aIndex];
  11991.  
  11992. if ( lpMsg->MagicKey && lpMagic->m_Skill == 9 ) // "Evil Spirit"
  11993. {
  11994. if ( lpObj->DurMagicKeyChecker.IsValidDurationTime(lpMsg->MagicKey) == FALSE )
  11995. {
  11996. LogAddC(0, "InValid DurationTime Key = %d ( Time : %d) [%d][%d]", // #error BIG_ERROR Deathway Change tp %s %s
  11997. lpMsg->MagicKey, lpObj->DurMagicKeyChecker.GetValidDurationTime(lpMsg->MagicKey),
  11998. lpObj->AccountID, lpObj->Name);
  11999. lOfs += sizeof(PMSG_BEATTACK);
  12000.  
  12001. continue;
  12002. }
  12003.  
  12004. if ( lpObj->DurMagicKeyChecker.IsValidCount(lpMsg->MagicKey) == FALSE )
  12005. {
  12006. LogAddC(0, " InValid VailidCount = %d ( Count : %d) [%d][%d]", // #error BIG_ERROR Deathway Change tp %s %s
  12007. lpMsg->MagicKey, lpObj->DurMagicKeyChecker.GetValidCount(lpMsg->MagicKey),
  12008. lpObj->AccountID, lpObj->Name);
  12009. lOfs += sizeof(PMSG_BEATTACK);
  12010.  
  12011. continue;
  12012. }
  12013. }
  12014.  
  12015. if ( gWriteSkillLog )
  12016. {
  12017. LogAddTD("Magic Attack3 : %d, serial = %d, Tgt = %d, cnt = %d",
  12018. lpMagic->m_Skill, lpCount->Serial, tNumber, lpCount->Count);
  12019. }
  12020.  
  12021. if ( gEnableCheckPenetrationSkill )
  12022. {
  12023. if ( lpMagic->m_Skill == 78 ) // #error Also Put the Check for FireScream
  12024. {
  12025. if ( gMultiAttackHackCheck[gObj[aIndex].m_Index].CheckFireScreamSkill(tNumber, lpMagic->m_Skill, lpCount->Serial) == FALSE )
  12026. {
  12027. return;
  12028. }
  12029. }
  12030. else if ( gMultiAttackHackCheck[gObj[aIndex].m_Index].CheckPenetrationSkill(tNumber, lpMagic->m_Skill, lpCount->Serial)== FALSE )
  12031. {
  12032. return;
  12033. }
  12034. }
  12035.  
  12036. for (int i = 0; i < lpCount->Count; i++)
  12037. {
  12038. if ( n != i)
  12039. {
  12040. if ( pTargetNumber[i] == tNumber )
  12041. {
  12042. LogAddTD("[%s][%s] %s Detect Hack : Multi Attack",
  12043. gObj[aIndex].AccountID, gObj[aIndex].Name,
  12044. lMsg.Get(MSGGET(7, 108)+gObj[aIndex].Class));
  12045.  
  12046. CloseClient(gObj[aIndex].m_Index);
  12047. return;
  12048. }
  12049. }
  12050. }
  12051.  
  12052. if ( tNumber >= 0 && tNumber < OBJMAX-1 )
  12053. {
  12054. if ( lpMagic->m_Skill == 55 )
  12055. {
  12056. gObjUseSkill.MaGumSkillDefenseDown(aIndex, tNumber, lpMagic->m_Level);
  12057. gObjAttack(&gObj[aIndex], &gObj[tNumber], lpMagic, TRUE, 1, 0, FALSE);
  12058. }
  12059. else if ( lpMagic->m_Skill == 78 )
  12060. {
  12061. gObjUseSkill.SkillFireScream(aIndex, tNumber, lpMagic);
  12062. }
  12063. else if ( magic_send )
  12064. {
  12065. gObjAttack(&gObj[aIndex], &gObj[tNumber], lpMagic, TRUE, 1, 0, FALSE);
  12066. }
  12067. else
  12068. {
  12069. gObjAttack(&gObj[aIndex], &gObj[tNumber], lpMagic, FALSE, 1, 0, FALSE);
  12070. }
  12071. }
  12072.  
  12073. lOfs += sizeof(PMSG_BEATTACK);
  12074. }
  12075. }
  12076.  
  12077.  
  12078.  
  12079.  
  12080.  
  12081.  
  12082. void CGDurationMagicRecv(PMSG_DURATION_MAGIC_RECV* lpMsg, int aIndex)
  12083. {
  12084. CMagicInf * lpMagic;
  12085. LPOBJ lpObj = &gObj[aIndex];
  12086.  
  12087. if ( lpObj->Teleport )
  12088. {
  12089. return;
  12090. }
  12091.  
  12092. if ( gObj[aIndex].Type == OBJ_USER )
  12093. {
  12094. lpMagic = gObjGetMagicSearch(lpObj, lpMsg->MagicNumber);
  12095. }
  12096. else
  12097. {
  12098. lpMagic = gObjGetMagic( lpObj, lpMsg->MagicNumber);
  12099. }
  12100.  
  12101. if ( lpMagic == NULL )
  12102. {
  12103. return;
  12104. }
  12105.  
  12106. if ( lpObj->Type == OBJ_USER )
  12107. {
  12108. if ( MagicDamageC.CheckStatus(lpMagic->m_Skill, lpObj->GuildStatus) == FALSE )
  12109. {
  12110. LogAddC(2, "[0x1E] CGDurationMagicRecv() - Invalid Status"); // #warning maybe protocol here change
  12111. return;
  12112. }
  12113.  
  12114. if ( MagicDamageC.CheckKillCount(lpMagic->m_Skill, lpObj->m_btKillCount) < 0 )
  12115. {
  12116. LogAddC(2, "[0x1E] CGDurationMagicRecv() - Invalid KillCount");
  12117. return;
  12118. }
  12119. }
  12120.  
  12121. lpObj->UseMagicNumber = 0;
  12122.  
  12123. if ( lpMagic->m_Skill != 24 )
  12124. {
  12125. if ( !gObjUseSkill.SpeedHackCheck(aIndex))
  12126. {
  12127. return;
  12128. }
  12129. }
  12130.  
  12131. if ( !gObjUseSkill.EnableSkill(lpMagic->m_Skill) )
  12132. {
  12133. return;
  12134. }
  12135. if (gObj[aIndex].pInventory[0].m_Type == -1 && gObj[aIndex].pInventory[1].m_Type == -1 && lpMagic->m_Skill == 41) //Fix slash without weapon
  12136. {
  12137. MsgOutput(aIndex,"Please put weapon on you to use this skill!");
  12138. return;
  12139. }
  12140. int aTargetIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  12141.  
  12142. gObjUseSkill.UseSkill(aIndex, lpMagic,lpMsg->X, lpMsg->Y, lpMsg->Dir, lpMsg->TargetPos, aTargetIndex);
  12143.  
  12144. if ( lpMsg->MagicKey )
  12145. lpObj->DurMagicKeyChecker.SetDurationTime(lpMsg->MagicKey, GetTickCount());
  12146. }
  12147.  
  12148.  
  12149. struct PMSG_USERMAPJOIN
  12150. {
  12151. PBMSG_HEAD h; // C1:F3:03
  12152. BYTE subcode; // 3
  12153. BYTE NumberH; // 4
  12154. BYTE NumberL; // 5
  12155. BYTE X; // 6
  12156. BYTE Y; // 7
  12157. BYTE MapNumber; // 8
  12158. BYTE Dir; // 9
  12159. };
  12160.  
  12161.  
  12162.  
  12163. void ObjectMapJoinPositionSend(short aIndex) // Not Used
  12164. {
  12165. PMSG_USERMAPJOIN pObject;
  12166.  
  12167. PHeadSubSetB((LPBYTE)&pObject, 0xF3, 0x03, sizeof(pObject));
  12168. pObject.NumberH = SET_NUMBERH(aIndex);
  12169. pObject.NumberL = SET_NUMBERL(aIndex);
  12170. pObject.X = gObj[aIndex].X;
  12171. pObject.Y = gObj[aIndex].Y;
  12172. pObject.MapNumber = gObj[aIndex].MapNumber;
  12173. pObject.Dir = gObj[aIndex].Dir;
  12174.  
  12175. DataSend(aIndex, (LPBYTE)&pObject, pObject.h.size);
  12176. }
  12177.  
  12178.  
  12179.  
  12180.  
  12181. void CGUseItemRecv(PMSG_USEITEM* lpMsg, int aIndex)
  12182. {
  12183. int pos;
  12184. CItem * citem;
  12185. int iItemUseType = lpMsg->btItemUseType;
  12186.  
  12187. //LogAddTD("111");
  12188. // Check User States
  12189. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type != 3 )
  12190. {
  12191. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, TRUE, gObj[aIndex].iShield);
  12192.  
  12193. LogAdd("[%s][%s] CGUseItemRecv()_If return %s %d",
  12194. gObj[aIndex].AccountID,
  12195. gObj[aIndex].Name,
  12196. __FILE__, __LINE__);
  12197.  
  12198. return;
  12199. }
  12200.  
  12201. // Check if User is exiting
  12202. if ( gObj[aIndex].CloseType != -1 )
  12203. {
  12204. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, TRUE, gObj[aIndex].iShield);
  12205.  
  12206. LogAdd("[%s][%s] CGUseItemRecv()_CloseType return %s %d",
  12207. gObj[aIndex].AccountID,
  12208. gObj[aIndex].Name,
  12209. __FILE__, __LINE__);
  12210.  
  12211. return;
  12212. }
  12213.  
  12214. // Fix Inventory Pointer
  12215. if ( gObjFixInventoryPointer(aIndex) == false )
  12216. {
  12217. LogAdd("[Fix Inv.Ptr] False Location - %s, %d",
  12218. __FILE__, __LINE__);
  12219. //return;
  12220. }
  12221.  
  12222. // Check if there is a Transaction
  12223. // Dupe
  12224. if ( gObj[aIndex].pTransaction == 1 )
  12225. {
  12226. LogAddTD("[%s][%s] CGUseItemRecv() Failed : Transaction == 1, IF_TYPE : %d",
  12227. gObj[aIndex].AccountID,
  12228. gObj[aIndex].Name,
  12229. gObj[aIndex].m_IfState.type);
  12230.  
  12231. return;
  12232. }
  12233.  
  12234. // Set Var Pos
  12235. pos = lpMsg->inventoryPos;
  12236.  
  12237. // Check if the pos is in bounds
  12238. if ( pos > MAIN_INVENTORY_SIZE-1 )
  12239. {
  12240. // error : Location is over the range. %s/%d
  12241. LogAdd(lMsg.Get(MSGGET(1, 241)), __FILE__, __LINE__);
  12242.  
  12243. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12244.  
  12245. LogAdd("[%s][%s] CGUseItemRecv()_Inventory return %s %d",
  12246. gObj[aIndex].AccountID,
  12247. gObj[aIndex].Name,
  12248. __FILE__, __LINE__);
  12249.  
  12250. return;
  12251. }
  12252.  
  12253.  
  12254. // check if the item
  12255. // have the same position
  12256. // as the new position
  12257. if ( lpMsg->inventoryPos == lpMsg->invenrotyTarget )
  12258. {
  12259. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12260.  
  12261. LogAdd("error-L1 : [%s][%s] CGUseItemRecv()_Pos return %s %d",
  12262. gObj[aIndex].AccountID,
  12263. gObj[aIndex].Name,
  12264. __FILE__, __LINE__);
  12265.  
  12266. return;
  12267. }
  12268.  
  12269. // Set Pointer
  12270. citem = &gObj[aIndex].pInventory[pos];
  12271.  
  12272.  
  12273. // The item is ITEM
  12274. if ( citem->IsItem() )
  12275. {
  12276.  
  12277. // Check if item have 0 as Serial
  12278. if ( gObjCheckSerial0ItemList(citem) )
  12279. {
  12280. MsgOutput(aIndex, lMsg.Get(MSGGET(13, 26)));
  12281.  
  12282. GCReFillSend(aIndex,
  12283. gObj[aIndex].Life,
  12284. 0xFD,
  12285. 1,
  12286. gObj[aIndex].iShield);
  12287.  
  12288.  
  12289. LogAddTD("[ANTI-HACK][Serial 0 Item] [UseItem] (%s)(%s) Item(%s) Pos(%d)",
  12290. gObj[aIndex].AccountID,
  12291. gObj[aIndex].Name,
  12292. citem->GetName(),
  12293. pos);
  12294.  
  12295. return;
  12296. }
  12297.  
  12298. // Check the item Serial
  12299. if ( gObjInventorySearchSerialNumber(&gObj[aIndex],
  12300. citem->GetNumber()) == FALSE )
  12301. {
  12302. GCReFillSend(aIndex,
  12303. gObj[aIndex].Life,
  12304. 0xFD,
  12305. 1,
  12306. gObj[aIndex].iShield);
  12307.  
  12308.  
  12309. LogAdd("error-L2 : CopyItem [%s][%s] return %s %d",
  12310. gObj[aIndex].AccountID,
  12311. gObj[aIndex].Name,
  12312. __FILE__, __LINE__);
  12313.  
  12314. return;
  12315. }
  12316.  
  12317. if ( citem->m_serial && !gObjCanItemTouch(&gObj[aIndex], 1) )
  12318. {
  12319. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12320. return;
  12321. }
  12322.  
  12323. if ( citem->m_Type == ITEMGET(14,0) || // Apple
  12324. citem->m_Type == ITEMGET(14,1) ||
  12325. citem->m_Type == ITEMGET(14,2) ||
  12326. citem->m_Type == ITEMGET(14,3) )
  12327. {
  12328. #ifdef POTION_DELAY
  12329. if (gObj[aIndex].PotionDelay >= 0)
  12330. {
  12331.  
  12332. gObj[aIndex].PotionDelay = PotionDelay;
  12333. #endif
  12334. int tLife = (citem->m_Value * 10) - (gObj[aIndex].Level * 2); // #formula
  12335.  
  12336. if (tLife < 0)
  12337. {
  12338. tLife = 0;
  12339. }
  12340.  
  12341. int nAddRate = 0;
  12342.  
  12343. switch (citem->m_Type)
  12344. {
  12345. case ITEMGET(14, 0): // Apple
  12346. nAddRate = 10;
  12347. break;
  12348. case ITEMGET(14, 1): //
  12349. nAddRate = 20;
  12350. break;
  12351. case ITEMGET(14, 2): //
  12352. nAddRate = 30;
  12353. break;
  12354. case ITEMGET(14, 3): //
  12355. nAddRate = 40;
  12356. break;
  12357. }
  12358.  
  12359. if (citem->m_Level == 1) // #formula
  12360. {
  12361. nAddRate += 5;
  12362. }
  12363.  
  12364. tLife += ((int)gObj[aIndex].MaxLife * nAddRate) / 100; // #formula
  12365.  
  12366. if (citem->m_Type == ITEMGET(14, 0))
  12367. {
  12368. if (citem->m_Level < 2)
  12369. {
  12370. gObj[aIndex].FillLife += tLife;
  12371. tLife = 0;
  12372. }
  12373. }
  12374.  
  12375. if (gObj[aIndex].FillLife > 0.0f)
  12376. {
  12377. gObj[aIndex].Life += gObj[aIndex].FillLife;
  12378.  
  12379. if (gObj[aIndex].Life > (gObj[aIndex].MaxLife + gObj[aIndex].AddLife))
  12380. {
  12381. gObj[aIndex].Life = gObj[aIndex].MaxLife + gObj[aIndex].AddLife;
  12382. gObj[aIndex].FillLife = 0;
  12383. }
  12384.  
  12385. GCReFillSend(gObj[aIndex].m_Index, gObj[aIndex].Life, 0xFF, FALSE, gObj[aIndex].iShield);
  12386. }
  12387.  
  12388. gObj[aIndex].FillLifeMax = tLife;
  12389. gObj[aIndex].FillLife = tLife;
  12390.  
  12391. if (citem->m_Type == ITEMGET(14, 0) && citem->m_Level < 2)
  12392. {
  12393. gObj[aIndex].FillLifeCount = 0;
  12394. }
  12395. else if (citem->m_Level == 1)
  12396. {
  12397. gObj[aIndex].FillLifeCount = 2;
  12398. }
  12399. else
  12400. {
  12401. gObj[aIndex].FillLifeCount = 3;
  12402. }
  12403.  
  12404. if (!gObjSearchItemMinus(&gObj[aIndex], pos, 1))
  12405. {
  12406. gObjInventoryItemSet(aIndex, pos, -1);
  12407. gObj[aIndex].pInventory[pos].Clear();
  12408. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12409. }
  12410. #ifdef POTION_DELAY
  12411. }
  12412. #endif
  12413. }
  12414. else if (citem->m_Type == ITEMGET(14,4) || // Small Mana Potion
  12415. citem->m_Type == ITEMGET(14,5) ||
  12416. citem->m_Type == ITEMGET(14,6) )
  12417. {
  12418. int tMana = (citem->m_Value*10) - (gObj[aIndex].Level); // #formula
  12419.  
  12420. if ( tMana < 0 )
  12421. {
  12422. tMana=0;
  12423. }
  12424.  
  12425. switch ( citem->m_Type )
  12426. {
  12427. case ITEMGET(14,4): // Small Mana Potion
  12428. tMana += ((int)(gObj[aIndex].MaxMana + gObj[aIndex].AddMana))*20/100;
  12429. break;
  12430. case ITEMGET(14,5): // Mana Potion
  12431. tMana += ((int)(gObj[aIndex].MaxMana + gObj[aIndex].AddMana))*30/100;
  12432. break;
  12433. case ITEMGET(14,6): // Large Mana Potion
  12434. tMana += ((int)(gObj[aIndex].MaxMana + gObj[aIndex].AddMana))*40/100;
  12435. break;
  12436. }
  12437.  
  12438. gObj[aIndex].Mana += tMana;
  12439.  
  12440. if ( gObj[aIndex].Mana > (gObj[aIndex].MaxMana+gObj[aIndex].AddMana-1.0f) )
  12441. gObj[aIndex].Mana = gObj[aIndex].MaxMana+gObj[aIndex].AddMana;
  12442.  
  12443. GCManaSend(aIndex, gObj[aIndex].Mana, 0xFF, 0, gObj[aIndex].BP);
  12444.  
  12445. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12446. {
  12447. gObjInventoryItemSet(aIndex, pos, -1);
  12448. gObj[aIndex].pInventory[pos].Clear();
  12449. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12450. }
  12451. }
  12452. else if ( citem->m_Type == ITEMGET(14,38) ) // Small Compound Potion
  12453. {
  12454. int iShieldGage = (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield) * 5/100; // #formula
  12455. int iHPGage = (int)((gObj[aIndex].MaxLife + gObj[aIndex].AddLife) * 10.0f / 100.0f ); // #formula
  12456.  
  12457. if ( gObj[aIndex].iShield < 0 )
  12458. gObj[aIndex].iShield = 0;
  12459.  
  12460. if ( gObj[aIndex].FillLife > 0.0f )
  12461. {
  12462. gObj[aIndex].Life += gObj[aIndex].FillLife;
  12463.  
  12464. if ( gObj[aIndex].Life > (gObj[aIndex].MaxLife + gObj[aIndex].AddLife ) )
  12465. gObj[aIndex].Life = gObj[aIndex].MaxLife + gObj[aIndex].AddLife;
  12466. }
  12467.  
  12468. if ( gObj[aIndex].iFillShield > 0 )
  12469. {
  12470. gObj[aIndex].iShield += gObj[aIndex].iFillShield;
  12471.  
  12472. if ( gObj[aIndex].iShield > (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield ) )
  12473. gObj[aIndex].iShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  12474. }
  12475.  
  12476. gObj[aIndex].FillLife = iHPGage;
  12477. gObj[aIndex].FillLifeMax = iHPGage;
  12478. gObj[aIndex].FillLifeCount = 4;
  12479. gObj[aIndex].iFillShield = iShieldGage;
  12480. gObj[aIndex].iFillShieldMax = iShieldGage;
  12481. gObj[aIndex].iFillShieldCount = 4;
  12482.  
  12483. GCSendEffectInfo(aIndex, 3);
  12484.  
  12485. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12486. {
  12487. gObjInventoryItemSet(aIndex, pos, -1);
  12488. gObj[aIndex].pInventory[pos].Clear();
  12489. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12490. }
  12491.  
  12492. LogAddTD("[%s][%s]Use Compound Potion Lv1 - SD[%d] HP[%f] -> SD[%d] HP[%f]",
  12493. gObj[aIndex].AccountID, gObj[aIndex].Name,
  12494. gObj[aIndex].iShield, gObj[aIndex].Life,
  12495. gObj[aIndex].iShield+iShieldGage, (double)(gObj[aIndex].Life+(float)iHPGage));
  12496. }
  12497. else if ( citem->m_Type == ITEMGET(14,39) ) // Compound Potion
  12498. {
  12499. int iShieldGage = (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield) * 10/100; // #formula
  12500. int iHPGage = (int)((gObj[aIndex].MaxLife + gObj[aIndex].AddLife) * 25.0f / 100.0f ); // #formula
  12501.  
  12502. if ( gObj[aIndex].iShield < 0 )
  12503. gObj[aIndex].iShield = 0;
  12504.  
  12505. if ( gObj[aIndex].FillLife > 0.0f )
  12506. {
  12507. gObj[aIndex].Life += gObj[aIndex].FillLife;
  12508.  
  12509. if ( gObj[aIndex].Life > (gObj[aIndex].MaxLife + gObj[aIndex].AddLife ) )
  12510. gObj[aIndex].Life = gObj[aIndex].MaxLife + gObj[aIndex].AddLife;
  12511. }
  12512.  
  12513. if ( gObj[aIndex].iFillShield > 0 )
  12514. {
  12515. gObj[aIndex].iShield += gObj[aIndex].iFillShield;
  12516.  
  12517. if ( gObj[aIndex].iShield > (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield ) )
  12518. gObj[aIndex].iShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  12519. }
  12520.  
  12521. gObj[aIndex].FillLife = iHPGage;
  12522. gObj[aIndex].FillLifeMax = iHPGage;
  12523. gObj[aIndex].FillLifeCount = 4;
  12524. gObj[aIndex].iFillShield = iShieldGage;
  12525. gObj[aIndex].iFillShieldMax = iShieldGage;
  12526. gObj[aIndex].iFillShieldCount = 4;
  12527.  
  12528. GCSendEffectInfo(aIndex, 3);
  12529.  
  12530. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12531. {
  12532. gObjInventoryItemSet(aIndex, pos, -1);
  12533. gObj[aIndex].pInventory[pos].Clear();
  12534. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12535. }
  12536.  
  12537. LogAddTD("[%s][%s]Use Compound Potion Lv2 - SD[%d] HP[%f] -> SD[%d] HP[%f]",
  12538. gObj[aIndex].AccountID, gObj[aIndex].Name,
  12539. gObj[aIndex].iShield, gObj[aIndex].Life,
  12540. gObj[aIndex].iShield+iShieldGage, (double)(gObj[aIndex].Life+(float)iHPGage));
  12541. }
  12542. else if ( citem->m_Type == ITEMGET(14,40) ) // Large Compound Potion
  12543. {
  12544. int iShieldGage = (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield) * 20/100; // #formula
  12545. int iHPGage = (int)((gObj[aIndex].MaxLife + gObj[aIndex].AddLife) * 45.0f / 100.0f ); // #formula
  12546.  
  12547. if ( gObj[aIndex].iShield < 0 )
  12548. gObj[aIndex].iShield = 0;
  12549.  
  12550. if ( gObj[aIndex].FillLife > 0.0f )
  12551. {
  12552. gObj[aIndex].Life += gObj[aIndex].FillLife;
  12553.  
  12554. if ( gObj[aIndex].Life > (gObj[aIndex].MaxLife + gObj[aIndex].AddLife ) )
  12555. gObj[aIndex].Life = gObj[aIndex].MaxLife + gObj[aIndex].AddLife;
  12556. }
  12557.  
  12558. if ( gObj[aIndex].iFillShield > 0 )
  12559. {
  12560. gObj[aIndex].iShield += gObj[aIndex].iFillShield;
  12561.  
  12562. if ( gObj[aIndex].iShield > (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield ) )
  12563. gObj[aIndex].iShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  12564. }
  12565.  
  12566. gObj[aIndex].FillLife = iHPGage;
  12567. gObj[aIndex].FillLifeMax = iHPGage;
  12568. gObj[aIndex].FillLifeCount = 4;
  12569. gObj[aIndex].iFillShield = iShieldGage;
  12570. gObj[aIndex].iFillShieldMax = iShieldGage;
  12571. gObj[aIndex].iFillShieldCount = 4;
  12572.  
  12573. GCSendEffectInfo(aIndex, 3);
  12574.  
  12575. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12576. {
  12577. gObjInventoryItemSet(aIndex, pos, -1);
  12578. gObj[aIndex].pInventory[pos].Clear();
  12579. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12580. }
  12581.  
  12582. LogAddTD("[%s][%s]Use Compound Potion Lv3 - SD[%d] HP[%f] -> SD[%d] HP[%f]",
  12583. gObj[aIndex].AccountID, gObj[aIndex].Name,
  12584. gObj[aIndex].iShield, gObj[aIndex].Life,
  12585. gObj[aIndex].iShield+iShieldGage, (double)(gObj[aIndex].Life+(float)iHPGage));
  12586. }
  12587. else if ( citem->m_Type == ITEMGET(14,35) )
  12588. {
  12589. int iShieldGage = (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield) * 25 / 100; // #formula
  12590.  
  12591. if ( gObj[aIndex].iShield < 0 )
  12592. gObj[aIndex].iShield = 0;
  12593.  
  12594. if ( gObj[aIndex].iFillShield > 0 )
  12595. {
  12596. gObj[aIndex].iShield += gObj[aIndex].iFillShield;
  12597.  
  12598. if ( gObj[aIndex].iShield > (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield ) )
  12599. gObj[aIndex].iShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  12600. }
  12601.  
  12602. gObj[aIndex].iFillShieldCount = 2;
  12603. gObj[aIndex].iFillShield = iShieldGage;
  12604. gObj[aIndex].iFillShieldMax = iShieldGage;
  12605.  
  12606. GCSendEffectInfo(aIndex, 3);
  12607.  
  12608. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12609. {
  12610. gObjInventoryItemSet(aIndex, pos, -1);
  12611. gObj[aIndex].pInventory[pos].Clear();
  12612. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12613. }
  12614. }
  12615. else if ( citem->m_Type == ITEMGET(14,36) )
  12616. {
  12617. int iShieldGage = (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield) * 35 / 100; // #formula
  12618.  
  12619. if ( gObj[aIndex].iShield < 0 )
  12620. gObj[aIndex].iShield = 0;
  12621.  
  12622. if ( gObj[aIndex].iFillShield > 0 )
  12623. {
  12624. gObj[aIndex].iShield += gObj[aIndex].iFillShield;
  12625.  
  12626. if ( gObj[aIndex].iShield > (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield ) )
  12627. gObj[aIndex].iShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  12628. }
  12629.  
  12630. gObj[aIndex].iFillShieldCount = 2;
  12631. gObj[aIndex].iFillShield = iShieldGage;
  12632. gObj[aIndex].iFillShieldMax = iShieldGage;
  12633.  
  12634. GCSendEffectInfo(aIndex, 3);
  12635.  
  12636. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12637. {
  12638. gObjInventoryItemSet(aIndex, pos, -1);
  12639. gObj[aIndex].pInventory[pos].Clear();
  12640. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12641. }
  12642. }
  12643. else if ( citem->m_Type == ITEMGET(14,37) )
  12644. {
  12645. int iShieldGage = (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield) * 45 / 100; // #formula
  12646.  
  12647. if ( gObj[aIndex].iShield < 0 )
  12648. gObj[aIndex].iShield = 0;
  12649.  
  12650. if ( gObj[aIndex].iFillShield > 0 )
  12651. {
  12652. gObj[aIndex].iShield += gObj[aIndex].iFillShield;
  12653.  
  12654. if ( gObj[aIndex].iShield > (gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield ) )
  12655. gObj[aIndex].iShield = gObj[aIndex].iMaxShield + gObj[aIndex].iAddShield;
  12656. }
  12657.  
  12658. gObj[aIndex].iFillShieldCount = 2;
  12659. gObj[aIndex].iFillShield = iShieldGage;
  12660. gObj[aIndex].iFillShieldMax = iShieldGage;
  12661.  
  12662. GCSendEffectInfo(aIndex, 3);
  12663.  
  12664. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12665. {
  12666. gObjInventoryItemSet(aIndex, pos, -1);
  12667. gObj[aIndex].pInventory[pos].Clear();
  12668. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12669. }
  12670. }
  12671. else if ( citem->m_Type == ITEMGET(14,8) ) // Antidote
  12672. {
  12673. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12674. {
  12675. gObjInventoryItemSet(aIndex, pos, -1);
  12676. gObj[aIndex].pInventory[pos].Clear();
  12677. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12678. }
  12679.  
  12680. if ( gObj[aIndex].m_PoisonBeattackCount )
  12681. {
  12682. gObj[aIndex].m_PoisonType = 0;
  12683. gObj[aIndex].m_PoisonBeattackCount = 0;
  12684. gObj[aIndex].lpAttackObj = NULL;
  12685. GCMagicCancelSend(&gObj[aIndex], 1);
  12686. }
  12687.  
  12688. if ( gObj[aIndex].m_ColdBeattackCount != 0 )
  12689. {
  12690. gObj[aIndex].m_ColdBeattackCount = 0;
  12691. gObj[aIndex].DelayActionTime = 0;
  12692. gObj[aIndex].DelayLevel = 0;
  12693. gObj[aIndex].lpAttackObj = NULL;
  12694. GCMagicCancelSend(&gObj[aIndex], 7);
  12695. }
  12696. }
  12697. else if ( citem->m_Type == ITEMGET(14,46) )
  12698. {
  12699. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12700. {
  12701. gObjInventoryItemSet(aIndex, pos, -1);
  12702. gObj[aIndex].pInventory[pos].Clear();
  12703. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12704. }
  12705.  
  12706. g_ItemAddOption.SetItemEffect(&gObj[aIndex], ITEMGET(14,46), 0);
  12707. }
  12708. else if ( citem->m_Type == ITEMGET(14,47) )
  12709. {
  12710. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12711. {
  12712. gObjInventoryItemSet(aIndex, pos, -1);
  12713. gObj[aIndex].pInventory[pos].Clear();
  12714. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12715. }
  12716.  
  12717. g_ItemAddOption.SetItemEffect(&gObj[aIndex], ITEMGET(14,47), 0);
  12718. }
  12719. else if ( citem->m_Type == ITEMGET(14,48) )
  12720. {
  12721. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12722. {
  12723. gObjInventoryItemSet(aIndex, pos, -1);
  12724. gObj[aIndex].pInventory[pos].Clear();
  12725. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12726. }
  12727.  
  12728. g_ItemAddOption.SetItemEffect(&gObj[aIndex], ITEMGET(14,48), 0);
  12729. }
  12730. else if ( citem->m_Type == ITEMGET(14,49) )
  12731. {
  12732. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12733. {
  12734. gObjInventoryItemSet(aIndex, pos, -1);
  12735. gObj[aIndex].pInventory[pos].Clear();
  12736. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12737. }
  12738.  
  12739. g_ItemAddOption.SetItemEffect(&gObj[aIndex], ITEMGET(14,49), 0);
  12740. }
  12741. else if ( citem->m_Type == ITEMGET(14,50) )
  12742. {
  12743. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  12744. {
  12745. gObjInventoryItemSet(aIndex, pos, -1);
  12746. gObj[aIndex].pInventory[pos].Clear();
  12747. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12748. }
  12749.  
  12750. g_ItemAddOption.SetItemEffect(&gObj[aIndex], ITEMGET(14,50), 0);
  12751. }
  12752. else if ( g_kJewelOfHarmonySystem.IsJewelOfHarmonyPurity(citem->m_Type) == TRUE )
  12753. {
  12754. if ( g_kJewelOfHarmonySystem.StrengthenItemByJewelOfHarmony(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12755. {
  12756. gObjInventoryItemSet(aIndex, pos, -1);
  12757. gObj[aIndex].pInventory[pos].Clear();
  12758. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12759. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12760. }
  12761. else
  12762. {
  12763. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12764. }
  12765. }
  12766. else if ( g_kJewelOfHarmonySystem.IsJewelOfHarmonySmeltingItems(citem->m_Type) == TRUE )
  12767. {
  12768. if ( g_kJewelOfHarmonySystem.SmeltItemBySmeltingStone(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12769. {
  12770. gObjInventoryItemSet(aIndex, pos, -1);
  12771. gObj[aIndex].pInventory[pos].Clear();
  12772. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12773. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12774. }
  12775. else
  12776. {
  12777. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12778. }
  12779. }
  12780. else if ( citem->m_Type == ITEMGET(14,13) ) // Jewel Of Bless
  12781. {
  12782. if ( gObjItemLevelUp(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12783. {
  12784. gObjInventoryItemSet(aIndex, pos, -1);
  12785. gObj[aIndex].pInventory[pos].Clear();
  12786. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12787. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12788. }
  12789. }
  12790. else if ( citem->m_Type == ITEMGET(14,14) ) // Jewel Of Soul
  12791. {
  12792. if ( gObjItemRandomLevelUp(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12793. {
  12794. gObjInventoryItemSet(aIndex, pos, -1);
  12795. gObj[aIndex].pInventory[pos].Clear();
  12796. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12797. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12798. }
  12799. }
  12800. else if ( citem->m_Type == ITEMGET(14,16) ) // Jewel Of Life
  12801. {
  12802. if ( gObjItemRandomOption3Up(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12803. {
  12804. gObjInventoryItemSet(aIndex, pos, -1);
  12805. gObj[aIndex].pInventory[pos].Clear();
  12806. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12807. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12808. }
  12809. else
  12810. {
  12811. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12812. }
  12813. }
  12814. #ifdef ANTI_ANCIENT_JEWEL
  12815. else if (citem->m_Type == ITEMGET(14, 102)) // AntiAncient Statue
  12816. {
  12817. if (gObjItemAntiAncientJewel(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE)
  12818. {
  12819. gObjInventoryItemSet(aIndex, pos, -1);
  12820. gObj[aIndex].pInventory[pos].Clear();
  12821. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12822. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12823. }
  12824. else
  12825. {
  12826. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12827. }
  12828.  
  12829. }
  12830. else if (citem->m_Type == ITEMGET(14, 103)) // Make Ancient Item
  12831. {
  12832. if (gObjItemAncientJewel(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE)
  12833. {
  12834. gObjInventoryItemSet(aIndex, pos, -1);
  12835. gObj[aIndex].pInventory[pos].Clear();
  12836. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12837. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12838. }
  12839. else
  12840. {
  12841. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12842. }
  12843.  
  12844. }
  12845. #endif
  12846. #ifdef NEW_JEWELS
  12847.  
  12848. else if ( citem->m_Type == ITEMGET(14,99) ) // Jewel Of Skill
  12849. {
  12850. if ( gObjItemRandomSetSkill(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12851. {
  12852. gObjInventoryItemSet(aIndex, pos, -1);
  12853. gObj[aIndex].pInventory[pos].Clear();
  12854. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12855. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12856. }
  12857. else
  12858. {
  12859. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12860. }
  12861.  
  12862. }
  12863. else if ( citem->m_Type == ITEMGET(14,100) ) // Jewel of Exeotion
  12864. {
  12865. if ( gObjItemRandomSetExellentOption(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12866. {
  12867.  
  12868. gObjInventoryItemSet(aIndex, pos, -1);
  12869. gObj[aIndex].pInventory[pos].Clear();
  12870. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12871. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12872. }
  12873. else
  12874. {
  12875. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12876. }
  12877.  
  12878. }
  12879. else if ( citem->m_Type == ITEMGET(14,101) ) // Jewel Of Luck
  12880. {
  12881. if ( gObjItemRandomSetLuck(&gObj[aIndex], lpMsg->inventoryPos, lpMsg->invenrotyTarget) == TRUE )
  12882. {
  12883. gObjInventoryItemSet(aIndex, pos, -1);
  12884. gObj[aIndex].pInventory[pos].Clear();
  12885. GCInventoryItemOneSend(aIndex, lpMsg->invenrotyTarget);
  12886. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12887. }
  12888. else
  12889. {
  12890. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12891. }
  12892. }
  12893. #endif
  12894.  
  12895. else if ( citem->m_Type >= ITEMGET(15,0) || // Group 15 - Scrolls
  12896. citem->m_Type == ITEMGET(12,7) || // Orb of Twisting Slash
  12897. (citem->m_Type >= ITEMGET(12,8) && citem->m_Type <= ITEMGET(12,24) ) || // Orbs
  12898. citem->m_Type == ITEMGET(12,35) ) // Scroll of Fire Scream
  12899. {
  12900.  
  12901. if ( (gObj[aIndex].Strength + gObj[aIndex].AddStrength) < citem->m_RequireStrength )
  12902. {
  12903. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12904. return;
  12905. }
  12906.  
  12907. if ( (gObj[aIndex].Dexterity + gObj[aIndex].AddDexterity) < citem->m_RequireDexterity )
  12908. {
  12909. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12910. return;
  12911. }
  12912.  
  12913. //if ( citem->m_Type == ITEMGET(15,18) ) // Scroll of HellBurst
  12914. //{
  12915. // //if ( g_QuestInfo.GetQuestState(&gObj[aIndex], 2) != 2 )
  12916. // //{
  12917. // // GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12918. // // return;
  12919. // //}
  12920. //
  12921. //
  12922. //}
  12923.  
  12924. if (citem->m_Type >= ITEMGET(12,8) && citem->m_Type <= ITEMGET(12,24) )
  12925. {
  12926. if ( gObj[aIndex].Level < citem->m_RequireLevel ) // Orbs
  12927. {
  12928. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  12929. return;
  12930. }
  12931. }
  12932.  
  12933. unsigned char skillnumber;
  12934.  
  12935. if ( citem->IsClass(gObj[aIndex].Class, gObj[aIndex].ChangeUP, gObj[aIndex].ChangeUP3rd) == FALSE )
  12936. {
  12937. GCInventoryItemDeleteSend(aIndex, -1, 1);
  12938. }
  12939. else
  12940. {
  12941.  
  12942. int addskill = gObjMagicAdd(&gObj[aIndex], citem->m_Type>>(9), citem->m_Type % MAX_SUBTYPE_ITEMS, citem->m_Level, skillnumber);
  12943.  
  12944. if ( addskill >= 0 )
  12945. {
  12946.  
  12947. gObjInventoryItemSet(aIndex, pos, -1);
  12948. GCMagicListOneSend(aIndex, addskill, skillnumber, citem->m_Level, 0, 0);
  12949. gObj[aIndex].pInventory[pos].Clear();
  12950. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12951. }
  12952. else
  12953. {
  12954.  
  12955. GCInventoryItemDeleteSend(aIndex, -1, 1);
  12956. }
  12957. }
  12958. }
  12959. else if ( citem->m_Type == ITEMGET(14,10) ) // Town Portal Scroll
  12960. {
  12961.  
  12962.  
  12963.  
  12964. LogAddTD("[Using Item] [Return Scroll] [%s][%s] - Current Map:[%d]",
  12965. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].MapNumber);
  12966.  
  12967. if (BC_MAP_RANGE(gObj[aIndex].MapNumber))
  12968. {
  12969. int iBridgeIndex = gObj[aIndex].MapNumber - MAP_INDEX_BLOODCASTLE1;
  12970.  
  12971. if (g_BloodCastle.GetCurrentState(iBridgeIndex) == 2)
  12972. {
  12973. g_BloodCastle.SearchUserDropQuestItem(aIndex);
  12974. }
  12975. else
  12976. {
  12977. g_BloodCastle.SearchUserDeleteQuestItem(aIndex);
  12978. }
  12979. }
  12980.  
  12981. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) ) //Season2.5 add-on
  12982. {
  12983. g_IllusionTempleEvent.SearchUserDropQuestItem(gObj[aIndex].MapNumber, aIndex);
  12984. }
  12985.  
  12986.  
  12987. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 3 )
  12988. {
  12989. gObj[aIndex].TargetShopNumber = -1;
  12990. gObj[aIndex].m_IfState.type = 0;
  12991. gObj[aIndex].m_IfState.use = 0;
  12992. }
  12993.  
  12994. gObjInventoryItemSet(aIndex, pos, -1);
  12995. gObj[aIndex].pInventory[pos].Clear();
  12996. GCInventoryItemDeleteSend(aIndex, pos, 1);
  12997.  
  12998. if ( gObj[aIndex].MapNumber == MAP_INDEX_DEVIAS )
  12999. {
  13000. gObjMoveGate(aIndex, 22);
  13001. }
  13002. else if ( gObj[aIndex].MapNumber == MAP_INDEX_NORIA )
  13003. {
  13004. gObjMoveGate(aIndex, 27);
  13005. }
  13006. else if ( gObj[aIndex].MapNumber == MAP_INDEX_LOSTTOWER )
  13007. {
  13008. gObjMoveGate(aIndex, 42);
  13009. }
  13010. else if ( gObj[aIndex].MapNumber == MAP_INDEX_ATHLANSE )
  13011. {
  13012. gObjMoveGate(aIndex, 49);
  13013. }
  13014. else if ( gObj[aIndex].MapNumber == MAP_INDEX_TARKAN )
  13015. {
  13016. gObjMoveGate(aIndex, 57);
  13017. }
  13018. else if ( BC_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE )
  13019. {
  13020. gObjMoveGate(aIndex, 22);
  13021. }
  13022. else if ( CC_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE )
  13023. {
  13024. gObjMoveGate(aIndex, 22);
  13025. }
  13026. else if ( KALIMA_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE )
  13027. {
  13028. gObjMoveGate(aIndex, 22);
  13029. }
  13030. else if ( gObj[aIndex].MapNumber == MAP_INDEX_AIDA )
  13031. {
  13032. //gObjMoveGate(aIndex, 27);
  13033. gObjMoveGate(aIndex, 119);
  13034.  
  13035. }
  13036. else if ( gObj[aIndex].MapNumber == MAP_INDEX_CRYWOLF_FIRSTZONE )
  13037. {
  13038. //gObjMoveGate(aIndex, 27);
  13039. gObjMoveGate(aIndex, 118);
  13040.  
  13041. }
  13042. else if ( gObj[aIndex].MapNumber == MAP_INDEX_CASTLESIEGE )
  13043. {
  13044. if ( g_CastleSiege.GetCastleState() == CASTLESIEGE_STATE_STARTSIEGE )
  13045. {
  13046. if ( gObj[aIndex].m_btCsJoinSide == 1 )
  13047. {
  13048. gObjMoveGate(aIndex, 101);
  13049. }
  13050. else
  13051. {
  13052. gObjMoveGate(aIndex, 100);
  13053. }
  13054. }
  13055. else if ( g_CastleSiege.CheckCastleOwnerMember(aIndex) == TRUE || g_CastleSiege.CheckCastleOwnerUnionMember(aIndex) == TRUE)
  13056. {
  13057. gObjMoveGate(aIndex, 101);
  13058. }
  13059. else
  13060. {
  13061. gObjMoveGate(aIndex, 100);
  13062. }
  13063. }
  13064. else
  13065. {
  13066. gObjMoveGate(aIndex, 17);
  13067. }
  13068. }
  13069. else if (citem->m_Type == ITEMGET(14,63) || citem->m_Type == ITEMGET(14,64) )
  13070. {
  13071. switch(citem->m_Type)
  13072. {
  13073. case ITEMGET(14,63):
  13074. {
  13075. gObj[aIndex].Life = gObj[aIndex].MaxLife + gObj[aIndex].AddLife;
  13076. GCReFillSend(aIndex,gObj[aIndex].Life, -1, 0,gObj[aIndex].iShield);
  13077. }
  13078. break;
  13079. case ITEMGET(14,64):
  13080. {
  13081. gObj[aIndex].Mana = gObj[aIndex].MaxMana + gObj[aIndex].AddMana;
  13082. GCManaSend(aIndex,gObj[aIndex].Mana, -1, 0, gObj[aIndex].BP);
  13083. }
  13084. break;
  13085. }
  13086.  
  13087. if (!gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  13088. {
  13089. gObjInventoryItemSet(aIndex, pos, -1);
  13090. gObj[aIndex].pInventory[pos].Clear();
  13091. GCInventoryItemDeleteSend(aIndex, pos, 1);
  13092. }
  13093. }
  13094. else if ( citem->m_Type == ITEMGET(14,9) ) // Ale
  13095. {
  13096. int level = citem->m_Level;
  13097.  
  13098. gObjInventoryItemSet(aIndex, pos, -1);
  13099. gObj[aIndex].pInventory[pos].Clear();
  13100. GCInventoryItemDeleteSend(aIndex, pos, 1);
  13101. gObjUseDrink(&gObj[aIndex], level);
  13102. }
  13103. else if ( citem->m_Type == ITEMGET(14,20) ) // Remedy of Love
  13104. {
  13105. if ( citem->m_Level == 0 )
  13106. {
  13107. gObjInventoryItemSet(aIndex, pos, -1);
  13108. gObj[aIndex].pInventory[pos].Clear();
  13109. GCInventoryItemDeleteSend(aIndex, pos, 1);
  13110. gObjUseDrink(&gObj[aIndex], 2);
  13111. }
  13112. }
  13113. else if ( citem->m_Type == ITEMGET(13,15) ) // Fruits
  13114. {
  13115. if ( iItemUseType == 0 )
  13116. {
  13117. gObjUsePlusStatFruit(aIndex, pos);
  13118. }
  13119. else if ( iItemUseType == 1 )
  13120. {
  13121. gObjUseMinusStatFruit(aIndex, pos);
  13122. }
  13123. }
  13124. else if (citem->m_Type == ITEMGET(13,54) ||
  13125. citem->m_Type == ITEMGET(13,55) ||
  13126. citem->m_Type == ITEMGET(13,56) ||
  13127. citem->m_Type == ITEMGET(13,57) ||
  13128. citem->m_Type == ITEMGET(13,58) )
  13129. {
  13130. gObjUseCashShopStatFruit(&gObj[aIndex], pos);
  13131. }
  13132.  
  13133. else if (citem->m_Type == ITEMGET(14,78) ||
  13134. citem->m_Type == ITEMGET(14,79) ||
  13135. citem->m_Type == ITEMGET(14,80) ||
  13136. citem->m_Type == ITEMGET(14,81) ||
  13137. citem->m_Type == ITEMGET(14,82) )
  13138. {
  13139. gObjUseCashShopStatPotion(&gObj[aIndex], pos);
  13140. }
  13141. ///Scroll's from cash shop
  13142. else if (citem->m_Type == ITEMGET(14,72) ||
  13143. citem->m_Type == ITEMGET(14,73) ||
  13144. citem->m_Type == ITEMGET(14,74) ||
  13145. citem->m_Type == ITEMGET(14,75) ||
  13146. citem->m_Type == ITEMGET(14,76) ||
  13147. citem->m_Type == ITEMGET(14,77) )
  13148. {
  13149. gObjUseCashShopScrollItem(&gObj[aIndex], pos);
  13150. }
  13151. else if (citem->m_Type == ITEMGET(14,70) ||
  13152. citem->m_Type == ITEMGET(14,71) )
  13153. {
  13154. gObjUseFullRecoveryPotion(&gObj[aIndex], pos);//ElitePotion
  13155. }
  13156. else if ( citem->m_Type == ITEMGET(14,7) ) // Siege Potion
  13157. {
  13158. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  13159. {
  13160. gObjInventoryItemSet(aIndex, pos, -1);
  13161. gObj[aIndex].pInventory[pos].Clear();
  13162. GCInventoryItemDeleteSend(aIndex, pos, 1);
  13163. }
  13164.  
  13165. int iLevel = citem->m_Level;
  13166. int iSerial = citem->GetNumber();
  13167. int iDur = citem->m_Durability;
  13168.  
  13169. if ( gObj[aIndex].lpGuild )
  13170. {
  13171. LogAddTD("[CastleSiege] Using CastleSiege Potion Lv[%d]/Si[%d]/Dur[%d] - [%s][%s] - (Guild : %s)",
  13172. iLevel, iSerial, iDur, gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].lpGuild->Name);
  13173. }
  13174. else
  13175. {
  13176. LogAddTD("[CastleSiege] Using CastleSiege Potion Lv[%d]/Si[%d]/Dur[%d] - [%s][%s]",
  13177. iLevel, iSerial, iDur, gObj[aIndex].AccountID, gObj[aIndex].Name);
  13178. }
  13179.  
  13180. if ( iLevel == 0 )
  13181. {
  13182. gObjUseBlessAndSoulPotion(aIndex, iLevel);
  13183. }
  13184. else if ( iLevel == 1 )
  13185. {
  13186. gObjUseBlessAndSoulPotion(aIndex, iLevel);
  13187. }
  13188. }
  13189. else if ( citem->m_Type == ITEMGET(13,48) )
  13190. {
  13191. if ( (gObj[aIndex].MapNumber < MAP_INDEX_KALIMA1 || gObj[aIndex].MapNumber > MAP_INDEX_KALIMA6 ) && gObj[aIndex].MapNumber != MAP_INDEX_KALIMA7 )
  13192. {
  13193. int iLevel = g_KalimaGate.GetKalimaGateLevel2(aIndex);
  13194. int iSerial = citem->GetNumber();
  13195. int iDuration = citem->m_Durability;
  13196. BOOL bKalimaGateCreateResult = FALSE;
  13197. int iKalimaGateX = 0;
  13198. int iKalimaGateY = 0;
  13199.  
  13200. iLevel++;
  13201. iKalimaGateX = gObj[aIndex].X + rand()%6 - 2;
  13202. iKalimaGateY = gObj[aIndex].Y + rand()%6 - 2;
  13203.  
  13204. bKalimaGateCreateResult = g_KalimaGate.CreateKalimaGate(aIndex, iLevel, iKalimaGateX, iKalimaGateY);
  13205.  
  13206. if ( bKalimaGateCreateResult == TRUE )
  13207. {
  13208. if ( !gObjSearchItemMinus(&gObj[aIndex], pos, 1) )
  13209. {
  13210. gObjInventoryItemSet(aIndex, pos, -1);
  13211. gObj[aIndex].pInventory[pos].Clear();
  13212. GCInventoryItemDeleteSend(aIndex, pos, 1);
  13213. }
  13214.  
  13215. LogAddTD("[PCS] Use Free Kalima Ticket Success");
  13216. }
  13217. else
  13218. {
  13219. LogAddTD("[PCS] Use Free Kalima Ticket Failed");
  13220. }
  13221. }
  13222. }
  13223. else
  13224. {
  13225. //LogAdd("error-L3 : %s return %s %d %d %s",
  13226. //gObj[aIndex].Name, __FILE__,__LINE__, pos, CItem::GetName); // #error Convert to other Name
  13227.  
  13228. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  13229. }
  13230. }
  13231. else
  13232. {
  13233. GCReFillSend(aIndex, gObj[aIndex].Life, 0xFD, 1, gObj[aIndex].iShield);
  13234. LogAdd("error-L3 : %s return %s %d %d",
  13235. gObj[aIndex].Name, __FILE__,__LINE__, pos);
  13236. }
  13237. }
  13238.  
  13239.  
  13240.  
  13241. struct PMSG_REFILL
  13242. {
  13243. PBMSG_HEAD h; // C1:26
  13244. BYTE IPos; // 3
  13245. BYTE LifeH; // 4
  13246. BYTE LifeL; // 5
  13247. BYTE Flag; // 6
  13248. BYTE btShieldH; // 7
  13249. BYTE btShieldL; // 8
  13250. };
  13251.  
  13252.  
  13253.  
  13254.  
  13255. void GCReFillSend(int aIndex, DWORD Life, BYTE Ipos, unsigned char flag, WORD wShield)
  13256. {
  13257. PMSG_REFILL pMsg;
  13258.  
  13259. PHeadSetB((LPBYTE)&pMsg, 0x26, sizeof(pMsg));
  13260. pMsg.IPos = Ipos;
  13261. pMsg.LifeH = SET_NUMBERH(Life);
  13262. pMsg.LifeL = SET_NUMBERL(Life);
  13263. pMsg.btShieldH = SET_NUMBERH(wShield);
  13264. pMsg.btShieldL = SET_NUMBERL(wShield);
  13265. pMsg.Flag = 0; // #error Flag is Disabled
  13266.  
  13267. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13268.  
  13269. }
  13270.  
  13271.  
  13272.  
  13273. struct PMSG_MANASEND
  13274. {
  13275. PBMSG_HEAD h; // C1:27
  13276. BYTE IPos; // 3
  13277. BYTE ManaH; // 4
  13278. BYTE ManaL; // 5
  13279. BYTE BPH; // 6
  13280. BYTE BPL; // 7
  13281. };
  13282.  
  13283.  
  13284. void GCManaSend(int aIndex, short Mana, BYTE Ipos, unsigned char flag, WORD BP)
  13285. {
  13286. if ( aIndex < 0 || aIndex > OBJMAX-1)
  13287. {
  13288. LogAdd("GCManaSend() return %s %d", __FILE__, __LINE__);
  13289. return;
  13290. }
  13291.  
  13292. if ( gObj[aIndex].Type != OBJ_USER )
  13293. {
  13294. return;
  13295. }
  13296.  
  13297. PMSG_MANASEND pMsg;
  13298.  
  13299. PHeadSetB((LPBYTE)&pMsg, 0x27, sizeof(pMsg));
  13300. pMsg.IPos = Ipos;
  13301. pMsg.ManaH = SET_NUMBERH(Mana);
  13302. pMsg.ManaL = SET_NUMBERL(Mana);
  13303. pMsg.BPH = SET_NUMBERH(BP);
  13304. pMsg.BPL = SET_NUMBERL(BP);
  13305.  
  13306. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13307. }
  13308.  
  13309.  
  13310.  
  13311. struct PMSG_INVENTORYDELETE
  13312. {
  13313. PBMSG_HEAD h; // C1:28
  13314. BYTE IPos; // 3
  13315. BYTE Flag; // 4
  13316. };
  13317.  
  13318.  
  13319. void GCInventoryItemDeleteSend(int aIndex, BYTE pos, unsigned char flag)
  13320. {
  13321. PMSG_INVENTORYDELETE pMsg;
  13322.  
  13323. PHeadSetB((LPBYTE)&pMsg, 0x28, sizeof(pMsg));
  13324. pMsg.IPos = pos;
  13325. pMsg.Flag = flag;
  13326.  
  13327. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13328. }
  13329.  
  13330.  
  13331.  
  13332. struct PMSG_ITEMUSESPECIALTIME
  13333. {
  13334. PBMSG_HEAD h; // C1:29
  13335. BYTE Number; // 3
  13336. WORD Time; // 4
  13337. };
  13338.  
  13339. void GCItemUseSpecialTimeSend(int aIndex, unsigned char number, int time)
  13340. {
  13341. if ( time > 65535 )
  13342. {
  13343. time = 65535;
  13344. }
  13345.  
  13346. PMSG_ITEMUSESPECIALTIME pMsg;
  13347.  
  13348. PHeadSetBE((LPBYTE)&pMsg, 0x29, sizeof(pMsg));
  13349. pMsg.Number = number;
  13350. pMsg.Time = time;
  13351.  
  13352. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13353. }
  13354.  
  13355.  
  13356. struct PMSG_ITEMDUR
  13357. {
  13358. PBMSG_HEAD h; // C1:2A
  13359. BYTE IPos; // 3
  13360. BYTE Dur; // 4
  13361. BYTE Flag; // 5
  13362. };
  13363.  
  13364.  
  13365.  
  13366. void GCItemDurSend(int aIndex, BYTE pos, BYTE dur, unsigned char flag)
  13367. {
  13368. PMSG_ITEMDUR pMsg;
  13369.  
  13370. PHeadSetB((LPBYTE)&pMsg, 0x2A, sizeof(pMsg));
  13371. pMsg.IPos = pos;
  13372. pMsg.Dur = dur;
  13373. pMsg.Flag = flag;
  13374.  
  13375. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13376. }
  13377.  
  13378.  
  13379.  
  13380.  
  13381. void GCItemDurSend2(int aIndex, unsigned char pos, unsigned char dur, unsigned char flag)
  13382. {
  13383. PMSG_ITEMDUR pMsg;
  13384.  
  13385. PHeadSetB((LPBYTE)&pMsg, 0x2A, sizeof(pMsg));
  13386. pMsg.IPos = pos;
  13387. pMsg.Dur = dur;
  13388. pMsg.Flag = flag;
  13389.  
  13390. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13391. }
  13392.  
  13393.  
  13394.  
  13395. struct PMSG_WEATHER
  13396. {
  13397. PBMSG_HEAD h; // C1:0F
  13398. BYTE Weather; // 3
  13399. };
  13400.  
  13401.  
  13402. void CGWeatherSend(int aIndex, BYTE weather)
  13403. {
  13404. PMSG_WEATHER pMsg;
  13405.  
  13406. PHeadSetB((LPBYTE)&pMsg, 0x0F, sizeof(pMsg));
  13407. pMsg.Weather = weather;
  13408.  
  13409. DataSend(aIndex, (UCHAR*)&pMsg, pMsg.h.size);
  13410. }
  13411.  
  13412.  
  13413.  
  13414.  
  13415.  
  13416. void GCServerCmd(int aIndex, BYTE type, BYTE Cmd1, BYTE Cmd2)
  13417. {
  13418. PMSG_SERVERCMD ServerCmd;
  13419.  
  13420. PHeadSubSetB((LPBYTE)&ServerCmd, 0xF3, 0x40, sizeof(ServerCmd));
  13421. ServerCmd.CmdType = type;
  13422. ServerCmd.X = Cmd1;
  13423. ServerCmd.Y = Cmd2;
  13424.  
  13425. DataSend(aIndex, (UCHAR*)&ServerCmd, ServerCmd.h.size);
  13426. }
  13427.  
  13428.  
  13429.  
  13430. struct PMSG_RESULT_MOVEDEVILSQUARE
  13431. {
  13432. PBMSG_HEAD h; // C1:90
  13433. BYTE Result; // 3
  13434. };
  13435.  
  13436.  
  13437. void GCReqmoveDevilSquare(PMSG_REQ_MOVEDEVILSQUARE* lpMsg, int aIndex)
  13438. {
  13439. if ( aIndex < 0 || aIndex > OBJMAX-1 )
  13440. {
  13441. LogAdd("return %s %d", __FILE__, __LINE__);
  13442. return;
  13443. }
  13444.  
  13445. BYTE cSquareNumber = lpMsg->SquareNumber;
  13446. BYTE cInvitationItemPos = lpMsg->InvitationItemPos - INVENTORY_BAG_START;
  13447.  
  13448. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type != 12 )
  13449. return;
  13450.  
  13451. PMSG_RESULT_MOVEDEVILSQUARE pResult;
  13452.  
  13453. PHeadSetB((LPBYTE)&pResult, 0x90, sizeof(pResult));
  13454. pResult.Result = 0;
  13455.  
  13456. LPOBJ lpObj = &gObj[aIndex];
  13457.  
  13458. LogAddTD("[DevilSquare] [%s][%s] Request Move DevilSquare [%d][%d][%d]",
  13459. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1);
  13460.  
  13461. if ( gObj[aIndex].m_PK_Level >= 4 )
  13462. {
  13463. pResult.Result = 6;
  13464. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13465. return;
  13466. }
  13467.  
  13468. if ( MAIN_INVENTORY_RANGE(cInvitationItemPos) == FALSE )
  13469. {
  13470. pResult.Result = 1;
  13471. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13472.  
  13473. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d]",
  13474. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1);
  13475.  
  13476. return;
  13477. }
  13478.  
  13479. if ( DS_LEVEL_RANGE(cSquareNumber) == FALSE )
  13480. {
  13481. pResult.Result = 1;
  13482. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13483.  
  13484. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d]",
  13485. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1);
  13486.  
  13487. return;
  13488. }
  13489.  
  13490. if ( g_DevilSquare.GetState() != DevilSquare_OPEN )
  13491. {
  13492. pResult.Result = 2;
  13493. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13494.  
  13495. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d]",
  13496. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1);
  13497.  
  13498. return;
  13499. }
  13500.  
  13501. if ( g_DevilSquare.m_DevilSquareGround[cSquareNumber].GetObjCount() >= MAX_DEVILSQUARE_USER )
  13502. {
  13503. pResult.Result = 5;
  13504. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13505.  
  13506. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d]",
  13507. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1);
  13508.  
  13509. return;
  13510. }
  13511.  
  13512. CItem * sitem = &lpObj->pInventory[cInvitationItemPos];
  13513.  
  13514. if ( sitem->m_Type != ITEMGET(14,19) && ( sitem->m_Type != ITEMGET(13,46) || sitem->m_Durability <= 0.0f ) ) // Devil's Invitation
  13515. {
  13516. pResult.Result = 1;
  13517. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13518.  
  13519. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d]",
  13520. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1);
  13521.  
  13522. return;
  13523. }
  13524.  
  13525. int ItemLevel = sitem->m_Level;
  13526.  
  13527. if ( sitem->m_Type == ITEMGET(13,46) )
  13528. ItemLevel = 10;
  13529.  
  13530. int level = lpObj->Level;
  13531.  
  13532. if ( lpObj->Class == CLASS_DARKLORD || lpObj->Class == CLASS_MAGUMSA )
  13533. {
  13534. level = (level+1)/2*3;
  13535. }
  13536.  
  13537. if ( ItemLevel != 0 )
  13538. {
  13539. if ( ItemLevel != 10 )
  13540. {
  13541. if ( ItemLevel != (cSquareNumber+1) )
  13542. {
  13543. pResult.Result = 1;
  13544. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13545.  
  13546. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Invitation LevelError [%d][%d][%d][%d]",
  13547. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber+1, ItemLevel);
  13548.  
  13549. return;
  13550. }
  13551. }
  13552. }
  13553.  
  13554. BOOL bEnterCheck = FALSE;
  13555. BYTE movegateindex = 61; // #gate
  13556. int iENTER_LEVEL = g_DevilSquare.GetUserLevelToEnter(aIndex, movegateindex);
  13557.  
  13558. if ( DS_LEVEL_RANGE(iENTER_LEVEL) == FALSE )
  13559. {
  13560. LogAddTD("[DevilSquare] [%s][%s] GetUserLevelToEnter() failed",
  13561. lpObj->AccountID, lpObj->Name);
  13562.  
  13563. return;
  13564. }
  13565.  
  13566. if ( ItemLevel == 10 )
  13567. cSquareNumber = iENTER_LEVEL;
  13568.  
  13569. if ( cSquareNumber != iENTER_LEVEL )
  13570. {
  13571. if ( cSquareNumber > iENTER_LEVEL )
  13572. {
  13573. bEnterCheck = 2;
  13574. }
  13575. else
  13576. {
  13577. bEnterCheck = 1;
  13578. }
  13579. }
  13580.  
  13581. if ( bEnterCheck == 1 )
  13582. {
  13583. pResult.Result = 3;
  13584. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13585.  
  13586. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d][%d]",
  13587. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber, ItemLevel);
  13588.  
  13589. return;
  13590. }
  13591.  
  13592. if ( bEnterCheck == 2 )
  13593. {
  13594. pResult.Result = 4;
  13595. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13596.  
  13597. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare Fail [%d][%d][%d][%d]",
  13598. lpObj->AccountID, lpObj->Name, lpObj->Class, lpObj->Level, cSquareNumber, ItemLevel);
  13599.  
  13600. return;
  13601. }
  13602.  
  13603. #if (FOREIGN_GAMESERVER==1)
  13604. if ( szAuthKey[6] != AUTHKEY6 )
  13605. DestroyGIocp();
  13606. #endif
  13607.  
  13608. LogAddTD("[DevilSquare] [%s][%s] Move DevilSquare success [%d][%d] RemoveItem[%s][%d][%d][%d]",
  13609. lpObj->AccountID, lpObj->Name, lpObj->Level, cSquareNumber, lpObj->pInventory[cInvitationItemPos].GetName(),
  13610. cInvitationItemPos, ItemLevel, lpObj->pInventory[cInvitationItemPos].m_Number);
  13611.  
  13612. if ( sitem->m_Type == ITEMGET(14,19) || (sitem->m_Type == ITEMGET(13,46) && sitem->m_Durability == 1.0f) )
  13613. {
  13614. gObjInventoryDeleteItem(aIndex, cInvitationItemPos);
  13615. GCInventoryItemDeleteSend(aIndex, cInvitationItemPos, 1);
  13616. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13617. }
  13618. else if ( sitem->m_Type == ITEMGET(13,46) && sitem->m_Durability > 1.0f )
  13619. {
  13620. sitem->m_Durability -= 1.0f;
  13621. GCItemDurSend2(lpObj->m_Index, cInvitationItemPos, sitem->m_Durability, 0);
  13622. }
  13623.  
  13624. lpObj->m_nEventExp = 0;
  13625. lpObj->m_nEventScore = 0;
  13626. lpObj->m_nEventMoney = 0;
  13627. lpObj->m_bDevilSquareIndex = g_DevilSquare.GetDevilSquareIndex(movegateindex);
  13628. lpObj->m_bDevilSquareAuth = true;
  13629. lpObj->m_IfState.state = 0;
  13630. lpObj->m_IfState.type = 0;
  13631. lpObj->m_IfState.use = 0;
  13632.  
  13633. gObjMoveGate(lpObj->m_Index, movegateindex);
  13634. g_DevilSquare.m_DevilSquareGround[cSquareNumber].IncObjCount();
  13635. }
  13636.  
  13637.  
  13638.  
  13639.  
  13640.  
  13641. void GCReqDevilSquareRemainTime(PMSG_REQ_DEVILSQUARE_REMAINTIME* lpMsg, int aIndex)
  13642. {
  13643. PMSG_RESULT_DEVILSQUARE_REMAINTIME pResult;
  13644.  
  13645. PHeadSetB((LPBYTE)&pResult, 0x91, sizeof(pResult));
  13646. pResult.RemainTime = 0;
  13647.  
  13648. switch ( lpMsg->hEventType )
  13649. {
  13650. case 1:
  13651. if ( gObj[aIndex].m_PK_Level >= 4 )
  13652. {
  13653. GCServerCmd(aIndex, 0x37, 0, 0);
  13654.  
  13655. LogAddTD("[PK User][DevilSquare] [%s][%s] Move Fail [PK Level:%d]",
  13656. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_PK_Level);
  13657.  
  13658. return;
  13659. }
  13660.  
  13661. pResult.hEventType = 1;
  13662.  
  13663. if ( g_DevilSquare.GetState() == DevilSquare_CLOSE )
  13664. {
  13665. pResult.RemainTime = g_DevilSquare.GetRemainTime();
  13666. }
  13667. else if ( g_DevilSquare.GetState() == DevilSquare_OPEN )
  13668. {
  13669. pResult.RemainTime = 0;
  13670. }
  13671. else
  13672. {
  13673. pResult.RemainTime = g_DevilSquare.GetRemainTime() + g_DevilSquare.m_iCloseTime;
  13674. }
  13675. break;
  13676.  
  13677. case 2:
  13678. if ( gObj[aIndex].m_PK_Level >= 4 )
  13679. {
  13680. GCServerCmd(aIndex, 0x38, 0, 0);
  13681.  
  13682. LogAddTD("[PK User][BloodCastle] [%s][%s] Move Fail [PK Level:%d]",
  13683. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_PK_Level);
  13684.  
  13685. return;
  13686. }
  13687.  
  13688. pResult.hEventType = 2;
  13689.  
  13690. // if ( g_BloodCastle.GetCurrentState(lpMsg->btItemLevel-1) == 1 )
  13691. // {
  13692. // if ( g_BloodCastle.CheckCanEnter(lpMsg->btItemLevel-1) != false )
  13693. // {
  13694. // pResult.RemainTime = 0;
  13695. // }
  13696. // else
  13697. // {
  13698. // pResult.RemainTime = g_BloodCastle.GetRemainTime(lpMsg->btItemLevel-1);
  13699. // }
  13700. // }
  13701. // else
  13702. // {
  13703. // pResult.RemainTime = g_BloodCastle.GetRemainTime(lpMsg->btItemLevel-1);
  13704. // }
  13705. // break;
  13706.  
  13707. //if (gBloodCastleAllowingPlayers == FALSE)
  13708. //{
  13709. // if (gObj[aIndex].m_PK_Level >= 4)
  13710. // {
  13711. // GCServerCmd(aIndex, 0x38, 0, 0);
  13712. //
  13713. // LogAddTD("[PK User][BloodCastle] [%s][%s] Move Fail [PK Level:%d]", gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_PK_Level);
  13714. //
  13715. // return;
  13716. // }
  13717. //}
  13718.  
  13719. pResult.hEventType = 2;
  13720.  
  13721. if (g_BloodCastle.GetCurrentState(lpMsg->btItemLevel) == 1)
  13722. {
  13723. if (g_BloodCastle.CheckCanEnter(lpMsg->btItemLevel) != false)
  13724. {
  13725. pResult.RemainTime = 0;
  13726. }
  13727. else
  13728. {
  13729. pResult.RemainTime = g_BloodCastle.GetRemainTime(lpMsg->btItemLevel);
  13730. }
  13731. }
  13732. else
  13733. {
  13734. pResult.RemainTime = g_BloodCastle.GetRemainTime(lpMsg->btItemLevel);
  13735. }
  13736. break;
  13737. case 4:
  13738. {
  13739. if ( gObj[aIndex].m_PK_Level >= 4 )
  13740. {
  13741. GCServerCmd(aIndex, 0x39, 0, 0);
  13742.  
  13743. LogAddTD("[PK User][ChaosCastle] [%s][%s] Move Fail [PK Level:%d]",
  13744. gObj[aIndex].AccountID, gObj[aIndex].Name, gObj[aIndex].m_PK_Level);
  13745.  
  13746. return;
  13747. }
  13748.  
  13749. int iENTER_LEVEL = g_ChaosCastle.GetUserLevelToEnter(aIndex);
  13750.  
  13751. if ( iENTER_LEVEL == -1 )
  13752. return;
  13753.  
  13754. pResult.hEventType = 4;
  13755.  
  13756. if ( g_ChaosCastle.GetCurrentState(iENTER_LEVEL) == 1 )
  13757. {
  13758. if ( g_ChaosCastle.CheckCanEnter(iENTER_LEVEL) != false )
  13759. {
  13760. pResult.RemainTime = 0;
  13761. pResult.RemainTime_LOW = 0;
  13762. pResult.EnteredUser = g_ChaosCastle.GetCurEnteredUser(iENTER_LEVEL);
  13763. }
  13764. else
  13765. {
  13766. WORD wREMAIN_TIME = g_ChaosCastle.GetRemainTime(iENTER_LEVEL);
  13767. pResult.RemainTime = SET_NUMBERH(wREMAIN_TIME);
  13768. pResult.RemainTime_LOW = SET_NUMBERL(wREMAIN_TIME);
  13769. pResult.EnteredUser = g_ChaosCastle.GetCurEnteredUser(iENTER_LEVEL);
  13770. }
  13771. }
  13772. else
  13773. {
  13774. WORD wREMAIN_TIME = g_ChaosCastle.GetRemainTime(iENTER_LEVEL);
  13775. pResult.RemainTime = SET_NUMBERH(wREMAIN_TIME);
  13776. pResult.RemainTime_LOW = SET_NUMBERL(wREMAIN_TIME);
  13777. pResult.EnteredUser = g_ChaosCastle.GetCurEnteredUser(iENTER_LEVEL);
  13778. }
  13779. }
  13780. break;
  13781. case 5:
  13782. pResult.hEventType = 5;
  13783. pResult.RemainTime = g_IllusionTempleEvent.GetRemainTime();
  13784. pResult.EnteredUser = 0;
  13785. pResult.RemainTime_LOW = 0;
  13786. break;
  13787. }
  13788.  
  13789. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  13790. }
  13791.  
  13792.  
  13793.  
  13794.  
  13795. void AllSendMsg(LPBYTE Msg, int size)
  13796. {
  13797. for ( int n=OBJ_STARTUSERINDEX;n<OBJMAX;n++)
  13798. {
  13799. if ( gObj[n].Connected == PLAYER_PLAYING )
  13800. {
  13801. if ( gObj[n].Type == OBJ_USER )
  13802. {
  13803. DataSend(n, Msg, size);
  13804. }
  13805. }
  13806. }
  13807. }
  13808.  
  13809.  
  13810.  
  13811.  
  13812. void AllSendSameMapMsg(UCHAR * Msg, int size, BYTE mapnumber)
  13813. {
  13814. for ( int n=0;n<OBJMAX;n++)
  13815. {
  13816. if ( gObj[n].Connected == PLAYER_PLAYING )
  13817. {
  13818. if ( gObj[n].Type == OBJ_USER )
  13819. {
  13820. if ( gObj[n].MapNumber == mapnumber )
  13821. {
  13822. DataSend(n, Msg, size);
  13823. }
  13824. }
  13825. }
  13826. }
  13827. }
  13828.  
  13829.  
  13830.  
  13831. struct PMSG_PING
  13832. {
  13833. PBMSG_HEAD h; // C1:71
  13834. };
  13835.  
  13836.  
  13837.  
  13838. //#unused
  13839. void GCSendPing(int aIndex)
  13840. {
  13841. PMSG_PING pMsgPing;
  13842.  
  13843. PHeadSetB((LPBYTE)&pMsgPing, 0x71, sizeof(pMsgPing));
  13844. gObj[aIndex].iPingTime = GetTickCount();
  13845.  
  13846. DataSend(aIndex, (LPBYTE)&pMsgPing, pMsgPing.h.size);
  13847. }
  13848.  
  13849.  
  13850.  
  13851. //#unused
  13852. void GCPingSendRecv(PMSG_PING_RESULT* aRecv, int aIndex)
  13853. {
  13854. int PingTime = GetTickCount() - gObj[aIndex].iPingTime;
  13855.  
  13856. LogAdd("[%s][%s] Ping = %d ms",
  13857. gObj[aIndex].AccountID, gObj[aIndex].Name, PingTime);
  13858. }
  13859.  
  13860.  
  13861.  
  13862.  
  13863. struct PMSG_REQ_REGISTER_EVENTCHIP
  13864. {
  13865. PBMSG_HEAD h; // C1:02
  13866. int iINDEX; // 4
  13867. BYTE Pos; // 8
  13868. char szUID[11]; // 9
  13869. };
  13870.  
  13871.  
  13872. struct PMSG_REQ_REGISTER_STONES
  13873. {
  13874. PBMSG_HEAD h; // C1:06
  13875. int iINDEX; // 4
  13876. BYTE iPosition; // 8
  13877. char szUID[11]; // 9
  13878. };
  13879.  
  13880.  
  13881.  
  13882. void GCRegEventChipRecv(PMSG_REGEVENTCHIP* lpMsg, int aIndex)
  13883. {
  13884. if ( !EVENCHIP_TYPE_RANGE(lpMsg->Type) )
  13885. return;
  13886.  
  13887. LPOBJ lpObj = &gObj[aIndex];
  13888.  
  13889. if ( lpObj->m_IfState.type == 1 )
  13890. {
  13891. LogAddTD("[EventChip] [%s][%s] Attempted ItemCopy using Trade Window",
  13892. lpObj->AccountID, lpObj->Name);
  13893.  
  13894. return;
  13895. }
  13896.  
  13897. if ( lpObj->m_IfState.type == 7 )
  13898. {
  13899. LogAddTD("[EventChip] [%s][%s] Attempted ItemCopy using ChaosBox Window",
  13900. lpObj->AccountID, lpObj->Name);
  13901.  
  13902. return;
  13903. }
  13904.  
  13905. if ( lpObj->UseEventServer != FALSE )
  13906. {
  13907. PMSG_REGEVENTCHIP_RESULT Result;
  13908.  
  13909. PHeadSetB((LPBYTE)&Result, 0x95, sizeof(Result));
  13910. Result.ChipCount = -1;
  13911. Result.Type = lpMsg->Type;
  13912.  
  13913. LogAddTD("[EventChip] [%s][%s] Not Found EventChip (RegEventchip) #1 %d",
  13914. lpObj->AccountID, lpObj->Name, lpMsg->ChipPos);
  13915.  
  13916. DataSend(aIndex, (LPBYTE)&Result, Result.h.size);
  13917.  
  13918. return;
  13919. }
  13920.  
  13921. int Pos = lpMsg->ChipPos + INVENTORY_BAG_START;
  13922. CItem * sitem = &lpObj->pInventory[Pos];
  13923.  
  13924. if ( !sitem->IsItem() )
  13925. {
  13926. PMSG_REGEVENTCHIP_RESULT Result;
  13927.  
  13928. PHeadSetB((LPBYTE)&Result, 0x95, sizeof(Result));
  13929. Result.ChipCount = -1;
  13930. Result.Type = lpMsg->Type;
  13931.  
  13932. LogAddTD("[EventChip] [%s][%s] Not Found EventChip (RegEventchip) #2 %d",
  13933. lpObj->AccountID, lpObj->Name, lpMsg->ChipPos);
  13934.  
  13935. DataSend(aIndex, (LPBYTE)&Result, Result.h.size);
  13936.  
  13937. return;
  13938. }
  13939.  
  13940. lpObj->UseEventServer = TRUE;
  13941.  
  13942. switch ( lpMsg->Type )
  13943. {
  13944. case 0x00:
  13945. if ( sitem->m_Type == ITEMGET(14,21) && sitem->m_Level == 0 ) // Rena
  13946. {
  13947. PMSG_REQ_REGISTER_EVENTCHIP pMsg;
  13948.  
  13949. PHeadSetB((LPBYTE)&pMsg, 0x02, sizeof(pMsg));
  13950. pMsg.iINDEX = aIndex;
  13951. pMsg.Pos = Pos;
  13952. strcpy(pMsg.szUID, lpObj->AccountID);
  13953. DataSendEventChip((PCHAR)&pMsg, sizeof(pMsg));
  13954. }
  13955. else
  13956. {
  13957. PMSG_REGEVENTCHIP_RESULT Result;
  13958.  
  13959. PHeadSetB((LPBYTE)&Result, 0x95, sizeof(Result));
  13960. Result.ChipCount = -1;
  13961. Result.Type = 0x00;
  13962.  
  13963. LogAddTD("[EventChip] [%s][%s] Not Found EventChip (RegEventchip) #3 %d",
  13964. lpObj->AccountID, lpObj->Name, lpMsg->ChipPos);
  13965.  
  13966. DataSend(aIndex, (LPBYTE)&Result, Result.h.size);
  13967. lpObj->UseEventServer = FALSE;
  13968. }
  13969. break;
  13970. case 0x01:
  13971. if ( sitem->m_Type == ITEMGET(14,21) && sitem->m_Level == 1 ) // Stone
  13972. {
  13973. PMSG_REQ_REGISTER_STONES pMsg;
  13974.  
  13975. PHeadSetB((LPBYTE)&pMsg, 0x06, sizeof(pMsg));
  13976. pMsg.iINDEX = aIndex;
  13977. pMsg.iPosition = Pos;
  13978. strcpy(pMsg.szUID, lpObj->AccountID);
  13979.  
  13980. DataSendEventChip((PCHAR)&pMsg, sizeof(pMsg));
  13981.  
  13982. LogAddTD("[Stone] [%s][%s] Register Stone (Stone Pos:%d, Serial:%d)",
  13983. lpObj->AccountID, lpObj->Name, lpMsg->ChipPos, sitem->m_Number);
  13984. }
  13985. else
  13986. {
  13987. PMSG_REGEVENTCHIP_RESULT Result;
  13988.  
  13989. PHeadSetB((LPBYTE)&Result, 0x95, sizeof(Result));
  13990. Result.ChipCount = -1;
  13991. Result.Type = 0x01;
  13992.  
  13993. LogAddTD("[Stone] [%s][%s] Not Found EventChip (Stone Pos: %d)",
  13994. lpObj->AccountID, lpObj->Name, lpMsg->ChipPos);
  13995.  
  13996. DataSend(aIndex, (LPBYTE)&Result, Result.h.size);
  13997. lpObj->UseEventServer = FALSE;
  13998. }
  13999. break;
  14000. default:
  14001. lpObj->UseEventServer = FALSE;
  14002. break;
  14003. }
  14004. }
  14005.  
  14006.  
  14007. struct PMSG_REQ_REGISTER_MUTONUM
  14008. {
  14009. PBMSG_HEAD h; // C1:03
  14010. int iINDEX; // 4
  14011. char szUID[11]; // 8
  14012. };
  14013.  
  14014.  
  14015. void GCGetMutoNumRecv(PMSG_GETMUTONUMBER* lpMsg, int aIndex)
  14016. {
  14017. if ( gObj[aIndex].MutoNumber != 0 )
  14018. {
  14019. char msg[255];
  14020. wsprintf(msg, "ְּ¹ּ ·ח°¡µוְַ ¼‎ְ°¡ ְײ½ְ´ֿ´");
  14021. GCServerMsgStringSend(msg, aIndex, 1);
  14022. return;
  14023. }
  14024.  
  14025. if ( gObj[aIndex].UseEventServer != FALSE )
  14026. return;
  14027.  
  14028. gObj[aIndex].UseEventServer = TRUE;
  14029.  
  14030. if ( !gObjFind10EventChip(aIndex) )
  14031. {
  14032. PMSG_GETMUTONUMBER_RESULT Result;
  14033.  
  14034. PHeadSetB((LPBYTE)&Result, 0x96, sizeof(Result));
  14035. Result.MutoNum[0] = -1;
  14036. Result.MutoNum[1] = 0;
  14037. Result.MutoNum[2] = 0;
  14038.  
  14039. DataSend(aIndex, (LPBYTE)&Result, Result.h.size);
  14040. gObj[aIndex].UseEventServer = FALSE;
  14041.  
  14042. return;
  14043. }
  14044.  
  14045. PMSG_REQ_REGISTER_MUTONUM pMsg;
  14046.  
  14047. PHeadSetB((LPBYTE)&pMsg, 0x03, sizeof(pMsg));
  14048. pMsg.iINDEX = aIndex;
  14049. strcpy(pMsg.szUID, gObj[aIndex].AccountID);
  14050.  
  14051. DataSendEventChip((PCHAR)&pMsg, sizeof(pMsg));
  14052.  
  14053. LogAddTD("[EventChip] [%s][%s] Request MutoNumber",
  14054. gObj[aIndex].AccountID, gObj[aIndex].Name);
  14055. }
  14056.  
  14057.  
  14058.  
  14059.  
  14060. void GCUseEndEventChipRescv(int aIndex)
  14061. {
  14062. if ( !gObjIsConnectedGP(aIndex))
  14063. {
  14064. LogAddC(2, "error-L3 [%s][%d]", __FILE__, __LINE__);
  14065. return;
  14066. }
  14067.  
  14068. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type == 9 )
  14069. {
  14070. gObj[aIndex].m_IfState.state = 0;
  14071. gObj[aIndex].m_IfState.type = 0;
  14072. gObj[aIndex].m_IfState.use = 0;
  14073. }
  14074. }
  14075.  
  14076.  
  14077. struct PMSG_REQ_RESET_EVENTCHIP
  14078. {
  14079. PBMSG_HEAD h; // C1:[04:Rena] [09:Stone]
  14080. int iINDEX; // 4
  14081. char szUID[11]; // 8
  14082. };
  14083.  
  14084.  
  14085. void GCUseRenaChangeZenRecv(PMSG_EXCHANGE_EVENTCHIP* lpMsg, int aIndex)
  14086. {
  14087. if ( gObj[aIndex].UseEventServer )
  14088. return;
  14089.  
  14090. gObj[aIndex].UseEventServer = TRUE;
  14091.  
  14092. PMSG_REQ_RESET_EVENTCHIP pMsg;
  14093.  
  14094. if ( lpMsg->btType == 1 ) // Stone?
  14095. PHeadSetB((LPBYTE)&pMsg, 0x09, sizeof(pMsg));
  14096. else
  14097. PHeadSetB((LPBYTE)&pMsg, 0x04, sizeof(pMsg));
  14098.  
  14099. pMsg.iINDEX = aIndex;
  14100. strcpy(pMsg.szUID, gObj[aIndex].AccountID);
  14101.  
  14102. DataSendEventChip((PCHAR)&pMsg, sizeof(pMsg));
  14103.  
  14104. if ( lpMsg->btType == 0x01 )
  14105. LogAddTD("[EventChip] [%s][%s] Request Change Stones", gObj[aIndex].AccountID, gObj[aIndex].Name);
  14106. else
  14107. LogAddTD("[EventChip] [%s][%s] Request Change Rena", gObj[aIndex].AccountID, gObj[aIndex].Name);
  14108. }
  14109.  
  14110.  
  14111. void CGRequestQuestInfo(int aIndex)
  14112. {
  14113. LPOBJ lpObj = &gObj[aIndex];
  14114.  
  14115. if (lpObj->m_SendQuestInfo != 0 )
  14116. {
  14117. return;
  14118. }
  14119.  
  14120. int questcount = g_QuestInfo.GetQeustCount();
  14121. int foundquest = 0;
  14122.  
  14123. PMSG_SEND_QEUSTINFO pMsg;
  14124. LPQUEST_INFO lpQuestInfo;
  14125.  
  14126. memcpy(pMsg.State, lpObj->m_Quest, sizeof(pMsg.State));
  14127.  
  14128. int i = 0;
  14129.  
  14130. for (i = 0; i < MAX_QUEST_INFO; i++)
  14131. {
  14132. lpQuestInfo = g_QuestInfo.GetQuestInfo(i);
  14133.  
  14134. if (lpQuestInfo)
  14135. {
  14136. foundquest++;
  14137.  
  14138. if (foundquest == questcount)
  14139. {
  14140. break;
  14141. }
  14142. }
  14143. }
  14144.  
  14145. int iSize = i / 4 + 5;
  14146.  
  14147. PHeadSetB((LPBYTE)&pMsg, 0xA0, iSize);
  14148. pMsg.Count = i;
  14149. DataSend(aIndex, (LPBYTE)&pMsg, iSize);
  14150. lpObj->m_SendQuestInfo = true;
  14151.  
  14152. if (szAuthKey[8] != AUTHKEY8 )
  14153. {
  14154. DestroyGIocp();
  14155. }
  14156. }
  14157.  
  14158. void GCSendQuestInfo(int aIndex, int QuestIndex)
  14159. {
  14160. CGRequestQuestInfo(aIndex);
  14161. LPOBJ lpObj = &gObj[aIndex];
  14162. PMSG_SETQUEST pMsg;
  14163.  
  14164. PHeadSetB((LPBYTE)&pMsg, 0xA1, sizeof(pMsg));
  14165. pMsg.QuestIndex = QuestIndex;
  14166. pMsg.State = g_QuestInfo.GetQuestStateBYTE(lpObj, QuestIndex);
  14167.  
  14168. if ( pMsg.State != 0 )
  14169. {
  14170. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  14171. }
  14172. }
  14173.  
  14174. void CGSetQuestState(PMSG_SETQUEST* lpMsg, int aIndex)
  14175. {
  14176. LPOBJ lpObj = &gObj[aIndex];
  14177. PMSG_SETQUEST_RESULT pMsg;
  14178.  
  14179. PHeadSetB((LPBYTE)&pMsg, 0xA2, sizeof(pMsg));
  14180. pMsg.QuestIndex = lpMsg->QuestIndex;
  14181. pMsg.Result = g_QuestInfo.SetQuestState(lpObj, lpMsg->QuestIndex, lpMsg->State);
  14182. pMsg.State = g_QuestInfo.GetQuestStateBYTE(lpObj, lpMsg->QuestIndex);
  14183.  
  14184. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  14185. }
  14186.  
  14187. void GCSendQuestPrize(int aIndex, BYTE Type, BYTE Count)
  14188. {
  14189. CGRequestQuestInfo(aIndex);
  14190. LPOBJ lpObj = &gObj[aIndex];
  14191.  
  14192. PMSG_SETQUEST_PRIZE pMsg;
  14193.  
  14194. PHeadSetB((LPBYTE)&pMsg, 0xA3, sizeof(pMsg));
  14195. pMsg.NumberH = SET_NUMBERH(lpObj->m_Index);
  14196. pMsg.NumberL = SET_NUMBERL(lpObj->m_Index);
  14197. pMsg.Type = Type;
  14198. pMsg.Count = Count;
  14199.  
  14200. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  14201. MsgSendV2(lpObj, (LPBYTE)&pMsg, sizeof(pMsg));
  14202. }
  14203.  
  14204. void CGCloseWindow(int aIndex)
  14205. {
  14206. if ( gObj[aIndex].m_IfState.use && gObj[aIndex].m_IfState.type )
  14207. {
  14208. if ( gObj[aIndex].m_IfState.type == 7 )
  14209. return;
  14210.  
  14211. if ( gObj[aIndex].m_IfState.type == 10 && gObj[aIndex].TargetShopNumber == 229 ) // Marlon
  14212. {
  14213. gQeustNpcTeleport.TalkRefDel();
  14214. gObj[aIndex].TargetShopNumber = -1;
  14215. }
  14216.  
  14217. if ( gObj[aIndex].m_IfState.type == 3 )
  14218. {
  14219. gObj[aIndex].TargetShopNumber = -1;
  14220. }
  14221.  
  14222. if ( gObj[aIndex].m_IfState.type == 1 )
  14223. {
  14224. CGTradeCancelButtonRecv(aIndex);
  14225. }
  14226.  
  14227. if ( gObj[aIndex].m_IfState.type == 6 )
  14228. {
  14229. CGWarehouseUseEnd(aIndex);
  14230. }
  14231.  
  14232. if ( gObj[aIndex].m_IfState.type == 13 )
  14233. {
  14234. g_MixSystem.ChaosBoxInit(&gObj[aIndex]);
  14235. gObjInventoryCommit(aIndex);
  14236. }
  14237.  
  14238. gObj[aIndex].m_IfState.state = 0;
  14239. gObj[aIndex].m_IfState.type = 0;
  14240. gObj[aIndex].m_IfState.use = 0;
  14241.  
  14242. #if (FOREIGN_GAMESERVER==1)
  14243. if ( szAuthKey[7] != AUTHKEY7)
  14244. DestroyGIocp();
  14245. #endif
  14246. }
  14247. }
  14248.  
  14249.  
  14250. struct PMSG_RESULT_MOVEBLOODCASTLE
  14251. {
  14252. PBMSG_HEAD h; // C1:9A
  14253. BYTE Result; // 3
  14254. };
  14255.  
  14256. void CGRequestEnterBloodCastle(PMSG_REQ_MOVEBLOODCASTLE* lpMsg, int iIndex)
  14257. {
  14258. if (!OBJMAX_RANGE(iIndex))
  14259. {
  14260. LogAdd("return %s %d", __FILE__, __LINE__);
  14261. return;
  14262. }
  14263.  
  14264. BYTE btBridgeNumber = lpMsg->iBridgeNumber - 1;
  14265. BYTE btInvisibleCourtItemPos = lpMsg->iItemPos;
  14266.  
  14267. int iITEM_LEVEL = 0;
  14268. DWORD dwITEM_SERIAL = 0;
  14269.  
  14270. PMSG_RESULT_MOVEBLOODCASTLE pResult;
  14271.  
  14272. PHeadSetB((LPBYTE)&pResult, 0x9A, sizeof(pResult));
  14273. pResult.Result = 0;
  14274.  
  14275. if (gObj[iIndex].Type != OBJ_USER || gObj[iIndex].Connected <= PLAYER_LOGGED)
  14276. {
  14277. return;
  14278. }
  14279.  
  14280. if (gObj[iIndex].m_IfState.use && gObj[iIndex].m_IfState.type != 12)
  14281. {
  14282. return;
  14283. }
  14284.  
  14285. BOOL bPlayerKiller = FALSE; //Season 2.5 add-on
  14286.  
  14287. //if (gBloodCastleAllowingPlayers == FALSE)
  14288. //{
  14289. // if (gObj[iIndex].PartyNumber >= 0) //Season 2.5 add-on
  14290. // {
  14291. // if (gParty.GetPKPartyPenalty(gObj[iIndex].PartyNumber) >= 5)
  14292. // {
  14293. // bPlayerKiller = TRUE;
  14294. // }
  14295. // }
  14296. // else if (gObj[iIndex].m_PK_Level >= 4)
  14297. // {
  14298. // bPlayerKiller = TRUE;
  14299. // }
  14300. //}
  14301. //
  14302. //if (bPlayerKiller == TRUE)
  14303. //{
  14304. // pResult.Result = 7;
  14305. // DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14306. // return;
  14307. //}
  14308.  
  14309. if (g_BloodCastle.CheckCanEnter(btBridgeNumber) == false)
  14310. {
  14311. pResult.Result = 2;
  14312. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14313. return;
  14314. }
  14315.  
  14316. if (gObj[iIndex].pInventory[btInvisibleCourtItemPos].IsItem() == TRUE)
  14317. {
  14318. if (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13, 18))
  14319. {
  14320. iITEM_LEVEL = gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Level;
  14321. dwITEM_SERIAL = gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Number;
  14322.  
  14323. if (BC_CLOACK_LEVEL_RANGE(iITEM_LEVEL) == FALSE)
  14324. {
  14325. pResult.Result = 1;
  14326. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14327. return;
  14328. }
  14329. }
  14330. else if (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13, 47) && gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability > 0.0f)
  14331. {
  14332. // Original, with master level from 400
  14333. //if(g_MasterLevelSystem.IsMasterLevelUser(&gObj[iIndex]) != FALSE)
  14334. //{
  14335. // iITEM_LEVEL = 8;
  14336. //}
  14337. //if (gObj[iIndex].ThirdChangeUp == 1)
  14338. //{
  14339. // iITEM_LEVEL = 8;
  14340. //}
  14341. //else
  14342. //{
  14343. for (int i = 0; i<MAX_CLOACK_LEVEL; i++)
  14344. {
  14345. if (g_BloodCastle.CheckEnterLevel(iIndex, i + 1) == 0)
  14346. {
  14347. iITEM_LEVEL = i + 1;
  14348. break;
  14349. }
  14350. }
  14351. //}
  14352.  
  14353. dwITEM_SERIAL = gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Number;
  14354.  
  14355. if (BC_CLOACK_LEVEL_RANGE(iITEM_LEVEL) == FALSE)
  14356. {
  14357. pResult.Result = 1;
  14358. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14359. return;
  14360. }
  14361. }
  14362. else
  14363. {
  14364. pResult.Result = 1;
  14365. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14366. return;
  14367. }
  14368. }
  14369. else
  14370. {
  14371. pResult.Result = 1;
  14372. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14373. return;
  14374. }
  14375.  
  14376. int iRESULT = g_BloodCastle.CheckEnterLevel(iIndex, iITEM_LEVEL);
  14377.  
  14378. if (iRESULT == 0)
  14379. {
  14380. pResult.Result = 0;
  14381. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14382. }
  14383. else
  14384. {
  14385. if (iRESULT == -1)
  14386. {
  14387. pResult.Result = 4;
  14388. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14389. return;
  14390. }
  14391.  
  14392. if (iRESULT == 1)
  14393. {
  14394. pResult.Result = 3;
  14395. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14396. return;
  14397. }
  14398.  
  14399. return;
  14400. }
  14401.  
  14402. int iBC_INDEX = g_BloodCastle.EnterUserBridge(iITEM_LEVEL - 1, iIndex);
  14403.  
  14404. if (iBC_INDEX == -1)
  14405. {
  14406. pResult.Result = 5;
  14407. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14408. return;
  14409. }
  14410.  
  14411. if ((gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13, 18) || (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13, 47)) && gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability == 1.0f))
  14412. {
  14413. gObjInventoryDeleteItem(iIndex, btInvisibleCourtItemPos);
  14414. GCInventoryItemDeleteSend(iIndex, btInvisibleCourtItemPos, 1);
  14415. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14416. }
  14417. else if (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13, 47) && gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability > 1.0f)
  14418. {
  14419. gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability -= 1.0f;
  14420. GCItemDurSend2(iIndex, btInvisibleCourtItemPos, gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability, 0);
  14421. }
  14422.  
  14423. gObj[iIndex].m_cBloodCastleIndex = iITEM_LEVEL - 1;
  14424. gObj[iIndex].m_cBloodCastleSubIndex = iBC_INDEX;
  14425. gObj[iIndex].m_iBloodCastleEXP = 0;
  14426. gObj[iIndex].m_IfState.state = 0;
  14427. gObj[iIndex].m_IfState.type = 0;
  14428. gObj[iIndex].m_IfState.use = 0;
  14429.  
  14430. g_BloodCastle.SearchUserDeleteQuestItem(iIndex);
  14431.  
  14432. char szTemp[256];
  14433. wsprintf(szTemp, lMsg.Get(MSGGET(4, 147)), iITEM_LEVEL);
  14434.  
  14435. GCServerMsgStringSend(szTemp, iIndex, 1);
  14436.  
  14437. switch (iITEM_LEVEL)
  14438. {
  14439. case 1:
  14440. gObjMoveGate(iIndex, 66);
  14441. break;
  14442. case 2:
  14443. gObjMoveGate(iIndex, 67);
  14444. break;
  14445. case 3:
  14446. gObjMoveGate(iIndex, 68);
  14447. break;
  14448. case 4:
  14449. gObjMoveGate(iIndex, 69);
  14450. break;
  14451. case 5:
  14452. gObjMoveGate(iIndex, 70);
  14453. break;
  14454. case 6:
  14455. gObjMoveGate(iIndex, 71);
  14456. break;
  14457. case 7:
  14458. gObjMoveGate(iIndex, 80);
  14459. break;
  14460. case 8:
  14461. gObjMoveGate(iIndex, 271);
  14462. break;
  14463. }
  14464.  
  14465. LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Entered Blood Castle (Invisible Cloak Serial:%u)", iITEM_LEVEL, gObj[iIndex].AccountID, gObj[iIndex].Name, dwITEM_SERIAL);
  14466. }
  14467.  
  14468. /*void CGRequestEnterBloodCastle(PMSG_REQ_MOVEBLOODCASTLE* lpMsg, int iIndex)
  14469. {
  14470. if ( !OBJMAX_RANGE(iIndex))
  14471. {
  14472. LogAdd("return %s %d", __FILE__, __LINE__);
  14473. return;
  14474. }
  14475.  
  14476. BYTE btBridgeNumber = lpMsg->iBridgeNumber - 1;
  14477. BYTE btInvisibleCourtItemPos = lpMsg->iItemPos;
  14478. int iITEM_LEVEL = 0;
  14479. DWORD dwITEM_SERIAL = 0;
  14480. PMSG_RESULT_MOVEBLOODCASTLE pResult;
  14481.  
  14482. PHeadSetB((LPBYTE)&pResult, 0x9A, sizeof(pResult));
  14483. pResult.Result = 0;
  14484.  
  14485. if ( gObj[iIndex].Type != OBJ_USER || gObj[iIndex].Connected <= PLAYER_LOGGED )
  14486. return;
  14487.  
  14488. if ( gObj[iIndex].m_IfState.use && gObj[iIndex].m_IfState.type != 12 )
  14489. return;
  14490. /////BLOOD CASTLE FIX!!!!!
  14491. if ( g_BloodCastleEnterPK != 1)
  14492. {
  14493. if ( gObj[iIndex].m_PK_Level >= 4 )
  14494. {
  14495. pResult.Result = 7;
  14496. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14497. return;
  14498. }
  14499. }
  14500. if ( g_BloodCastle.CheckCanEnter(btBridgeNumber) == false )
  14501. {
  14502. pResult.Result = 2;
  14503. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14504. return;
  14505. }
  14506.  
  14507. if ( gObj[iIndex].pInventory[btInvisibleCourtItemPos].IsItem() == TRUE )
  14508. {
  14509. if ( gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13,18) )
  14510. {
  14511. iITEM_LEVEL = gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Level;
  14512. dwITEM_SERIAL = gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Number;
  14513.  
  14514. if ( BC_CLOACK_LEVEL_RANGE(iITEM_LEVEL)==FALSE) // #error
  14515. {
  14516. pResult.Result = 1;
  14517. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14518. return;
  14519. }
  14520. }
  14521. else if (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13,47) && gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability > 0.0f )
  14522. {
  14523.  
  14524. for ( int i=0;i<MAX_CLOACK_LEVEL;i++)
  14525. {
  14526. if (g_BloodCastle.CheckEnterLevel(iIndex, i+1) == 0 )
  14527. {
  14528. iITEM_LEVEL = i+1;
  14529. break;
  14530. }
  14531. }
  14532.  
  14533. dwITEM_SERIAL = gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Number;
  14534.  
  14535. if (BC_CLOACK_LEVEL_RANGE(iITEM_LEVEL) == FALSE )
  14536. {
  14537. pResult.Result = 1;
  14538. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14539. return;
  14540. }
  14541. }
  14542. else
  14543. {
  14544. pResult.Result = 1;
  14545. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14546. return;
  14547. }
  14548. }
  14549. else
  14550. {
  14551. pResult.Result = 1;
  14552. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14553. return;
  14554. }
  14555.  
  14556. int iRESULT = g_BloodCastle.CheckEnterLevel(iIndex, iITEM_LEVEL);
  14557.  
  14558. if ( iRESULT== 0 )
  14559. {
  14560. pResult.Result = 0;
  14561. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14562. }
  14563. else
  14564. {
  14565. if ( iRESULT == -1 )
  14566. {
  14567. pResult.Result = 4;
  14568. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14569. return;
  14570. }
  14571.  
  14572. if ( iRESULT == 1 )
  14573. {
  14574. pResult.Result = 3;
  14575. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14576. return;
  14577. }
  14578.  
  14579. return;
  14580. }
  14581.  
  14582. int iBC_INDEX = g_BloodCastle.EnterUserBridge(iITEM_LEVEL-1, iIndex);
  14583.  
  14584. if ( iBC_INDEX == -1 )
  14585. {
  14586. pResult.Result = 5;
  14587. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14588. return;
  14589. }
  14590.  
  14591.  
  14592. if ((gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13,18) || (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13,47)) && gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability == 1.0f ))
  14593. {
  14594. gObjInventoryDeleteItem(iIndex, btInvisibleCourtItemPos);
  14595. GCInventoryItemDeleteSend(iIndex, btInvisibleCourtItemPos, 1);
  14596. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14597. }
  14598. else if (gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Type == ITEMGET(13,47) && gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability > 1.0f )
  14599. {
  14600. gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability -= 1.0f;
  14601. GCItemDurSend2(iIndex, btInvisibleCourtItemPos, gObj[iIndex].pInventory[btInvisibleCourtItemPos].m_Durability, 0);
  14602. }
  14603.  
  14604. gObj[iIndex].m_cBloodCastleIndex = iITEM_LEVEL-1;
  14605. gObj[iIndex].m_cBloodCastleSubIndex = iBC_INDEX;
  14606. gObj[iIndex].m_iBloodCastleEXP = 0;
  14607. gObj[iIndex].m_IfState.state = 0;
  14608. gObj[iIndex].m_IfState.type = 0;
  14609. gObj[iIndex].m_IfState.use = 0;
  14610.  
  14611. g_BloodCastle.SearchUserDeleteQuestItem(iIndex);
  14612. char szTemp[256];
  14613. wsprintf(szTemp, lMsg.Get(MSGGET(4, 147)), iITEM_LEVEL);
  14614. GCServerMsgStringSend(szTemp, iIndex, 1);
  14615.  
  14616. switch ( iITEM_LEVEL )
  14617. {
  14618. case 1:
  14619. gObjMoveGate(iIndex, 66);
  14620. break;
  14621. case 2:
  14622. gObjMoveGate(iIndex, 67);
  14623. break;
  14624. case 3:
  14625. gObjMoveGate(iIndex, 68);
  14626. break;
  14627. case 4:
  14628. gObjMoveGate(iIndex, 69);
  14629. break;
  14630. case 5:
  14631. gObjMoveGate(iIndex, 70);
  14632. break;
  14633. case 6:
  14634. gObjMoveGate(iIndex, 71);
  14635. break;
  14636. case 7:
  14637. gObjMoveGate(iIndex, 80);
  14638. break;
  14639. }
  14640.  
  14641. LogAddTD("[Blood Castle] (%d) (Account:%s, Name:%s) Entered Blood Castle (Invisible Cloak Serial:%d)",
  14642. iITEM_LEVEL, gObj[iIndex].AccountID, gObj[iIndex].Name, dwITEM_SERIAL);
  14643. }
  14644.  
  14645. */
  14646.  
  14647. struct PMSG_RESULT_MOVECHAOSCASTLE
  14648. {
  14649. PBMSG_HEAD2 h; // C1:AF:01
  14650. BYTE Result; // 4
  14651. };
  14652.  
  14653.  
  14654.  
  14655. void CGRequestEnterChaosCastle(PMSG_REQ_MOVECHAOSCASTLE* lpMsg, int iIndex)
  14656. {
  14657. if ( !OBJMAX_RANGE(iIndex))
  14658. {
  14659. LogAdd("return %s %d", __FILE__, __LINE__);
  14660. return;
  14661. }
  14662.  
  14663. BYTE btChaosCastleNumber = lpMsg->iChaosCastleNumber-1;
  14664. BYTE btGuardMailSetItemPos = lpMsg->iItemPos;
  14665. int iITEM_LEVEL=0;
  14666. DWORD dwITEM_SERIAL=0;
  14667. PMSG_RESULT_MOVECHAOSCASTLE pResult;
  14668.  
  14669. PHeadSubSetB((LPBYTE)&pResult, 0xAF, 0x01, sizeof(pResult));
  14670. pResult.Result = 0;
  14671.  
  14672. if ( gObj[iIndex].Type != OBJ_USER || gObj[iIndex].Connected <= PLAYER_LOGGED )
  14673. return;
  14674.  
  14675. if ( BC_MAP_RANGE(gObj[iIndex].MapNumber) ||
  14676. CC_MAP_RANGE(gObj[iIndex].MapNumber) ||
  14677. DS_MAP_RANGE(gObj[iIndex].MapNumber) )
  14678. {
  14679. PMSG_NOTICE pNotice;
  14680. TNotice::MakeNoticeMsgEx(&pNotice, 1, lMsg.Get(MSGGET(4, 200)));
  14681. DataSend(iIndex, (LPBYTE)&pNotice, pNotice.h.size);
  14682. return;
  14683. }
  14684.  
  14685. if ( gObj[iIndex].m_IfState.use && gObj[iIndex].m_IfState.type != 12 )
  14686. return;
  14687.  
  14688. if ( gPkLimitFree == FALSE )
  14689. {
  14690. if ( gObj[iIndex].m_PK_Level >= 6 )
  14691. {
  14692. PMSG_NOTICE pNotice;
  14693. TNotice::MakeNoticeMsgEx(&pNotice, 1, lMsg.Get(MSGGET(4, 201)));
  14694. DataSend(iIndex, (LPBYTE)&pNotice, pNotice.h.size);
  14695. return;
  14696. }
  14697. }
  14698.  
  14699. if ( gObjDuelCheck(&gObj[iIndex]) == TRUE )
  14700. {
  14701. PMSG_NOTICE pNotice;
  14702. TNotice::MakeNoticeMsgEx(&pNotice, 1, lMsg.Get(MSGGET(4, 202)));
  14703. DataSend(iIndex, (LPBYTE)&pNotice, pNotice.h.size);
  14704. return;
  14705. }
  14706.  
  14707. if ( gObj[iIndex].lpGuild )
  14708. {
  14709. if ( gObj[iIndex].lpGuild->WarState == 1 )
  14710. {
  14711. PMSG_NOTICE pNotice;
  14712. TNotice::MakeNoticeMsgEx(&pNotice, 1, lMsg.Get(MSGGET(4, 203)));
  14713. DataSend(iIndex, (LPBYTE)&pNotice, pNotice.h.size);
  14714. return;
  14715. }
  14716. }
  14717.  
  14718. if ( gObj[iIndex].pInventory[8].m_Type == ITEMGET(13,3) || // Dino
  14719. gObj[iIndex].pInventory[8].m_Type == ITEMGET(13,2) || // Uniria
  14720. gObj[iIndex].pInventory[8].m_Type == ITEMGET(13,37) ) // Fenrir
  14721. {
  14722. PMSG_NOTICE pNotice;
  14723. TNotice::MakeNoticeMsgEx(&pNotice, 1, lMsg.Get(MSGGET(4, 204)));
  14724. DataSend(iIndex, (LPBYTE)&pNotice, pNotice.h.size);
  14725. return;
  14726. }
  14727.  
  14728. if ( gObj[iIndex].m_PK_Level >= 4 )
  14729. {
  14730. pResult.Result = 8;
  14731. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14732. return;
  14733. }
  14734.  
  14735. int iENTER_LEVEL = g_ChaosCastle.GetUserLevelToEnter(iIndex);
  14736.  
  14737. if ( iENTER_LEVEL == -1 )
  14738. {
  14739. pResult.Result = 1;
  14740. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14741. return;
  14742. }
  14743.  
  14744. if ( g_ChaosCastle.CheckCanEnter(iENTER_LEVEL) == false )
  14745. {
  14746. pResult.Result = 2;
  14747. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14748. return;
  14749. }
  14750.  
  14751. if ( gObj[iIndex].pInventory[btGuardMailSetItemPos].IsItem() == TRUE )
  14752. {
  14753. if ( gObj[iIndex].pInventory[btGuardMailSetItemPos].m_Type == ITEMGET(13,29) ) // Armor of Guardman
  14754. {
  14755. iITEM_LEVEL = gObj[iIndex].pInventory[btGuardMailSetItemPos].m_Level;
  14756. dwITEM_SERIAL = gObj[iIndex].pInventory[btGuardMailSetItemPos].m_Number;
  14757. }
  14758. else
  14759. {
  14760. pResult.Result = 1;
  14761. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14762. return;
  14763. }
  14764. }
  14765. else
  14766. {
  14767. pResult.Result = 1;
  14768. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14769. return;
  14770. }
  14771.  
  14772. if ( g_ChaosCastle.CheckWearingMOPH(iIndex) == TRUE )
  14773. {
  14774. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 205)), iIndex, 1);
  14775. return;
  14776. }
  14777.  
  14778. int iBC_INDEX = -1;
  14779.  
  14780. if ( g_ChaosCastle.CheckUserEnterMoney(iIndex, iENTER_LEVEL) )
  14781. {
  14782. iBC_INDEX = g_ChaosCastle.EnterUserChaosCastle(iENTER_LEVEL, iIndex);
  14783.  
  14784. if ( iBC_INDEX == -1 )
  14785. {
  14786. pResult.Result = 5;
  14787. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14788. return;
  14789. }
  14790. }
  14791. else
  14792. {
  14793. pResult.Result = 7;
  14794. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14795. return;
  14796. }
  14797.  
  14798. BOOL bRES = g_ChaosCastle.PayUserEnterMoney(iIndex, iENTER_LEVEL);
  14799.  
  14800. if ( bRES == FALSE )
  14801. {
  14802. g_ChaosCastle.LeaveUserChaosCastle(iENTER_LEVEL, iIndex);
  14803. pResult.Result = 5;
  14804. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14805. return;
  14806. }
  14807.  
  14808. gObjInventoryDeleteItem(iIndex, btGuardMailSetItemPos);
  14809. GCInventoryItemDeleteSend(iIndex, btGuardMailSetItemPos, 1);
  14810.  
  14811. DataSend(iIndex, (LPBYTE)&pResult, pResult.h.size);
  14812.  
  14813. gObj[iIndex].m_cChaosCastleIndex = iENTER_LEVEL;
  14814. gObj[iIndex].m_cChaosCastleSubIndex = iBC_INDEX;
  14815. gObj[iIndex].m_IfState.state = 0;
  14816. gObj[iIndex].m_IfState.type = 0;
  14817. gObj[iIndex].m_IfState.use = 0;
  14818.  
  14819. if ( gObj[iIndex].m_bPShopOpen == true )
  14820. CGPShopReqClose(iIndex);
  14821.  
  14822. if ( gObj[iIndex].PartyNumber >= 0 )
  14823. {
  14824. PMSG_PARTYDELUSER pMsg;
  14825. int pindex = gParty.GetIndex(gObj[iIndex].PartyNumber, iIndex, gObj[iIndex].DBNumber);
  14826.  
  14827. if ( pindex >= 0 )
  14828. {
  14829. pMsg.Number = pindex;
  14830. CGPartyDelUser(&pMsg, iIndex);
  14831. }
  14832. }
  14833.  
  14834. if ( gObj[iIndex].Class == CLASS_ELF && gObj[iIndex].m_RecallMon >= 0)
  14835. {
  14836. GCRecallMonLife(iIndex, 60, 0);
  14837. gObjMonsterCallKill(iIndex);
  14838. }
  14839.  
  14840. char szTemp[256];
  14841. wsprintf(szTemp, lMsg.Get(MSGGET(4, 206)), iENTER_LEVEL+1);
  14842. GCServerMsgStringSend(szTemp, iIndex, 1);
  14843.  
  14844. switch ( iENTER_LEVEL+1 )
  14845. {
  14846. case 1:
  14847. gObjMoveGate(iIndex, 82);
  14848. break;
  14849. case 2:
  14850. gObjMoveGate(iIndex, 83);
  14851. break;
  14852. case 3:
  14853. gObjMoveGate(iIndex, 84);
  14854. break;
  14855. case 4:
  14856. gObjMoveGate(iIndex, 85);
  14857. break;
  14858. case 5:
  14859. gObjMoveGate(iIndex, 86);
  14860. break;
  14861. case 6:
  14862. gObjMoveGate(iIndex, 87);
  14863. break;
  14864. }
  14865.  
  14866. LogAddTD("[Chaos Castle] (%d) (Account:%s, Name:%s) Entered Chaos Castle (Guard Mail Set Serial:%d)",
  14867. iENTER_LEVEL+1, gObj[iIndex].AccountID, gObj[iIndex].Name, dwITEM_SERIAL);
  14868. }
  14869.  
  14870.  
  14871.  
  14872.  
  14873. void CGRequestRepositionUserInChaosCastle(PMSG_REQ_REPOSUSER_IN_CC * lpMsg, int aIndex)
  14874. {
  14875. if ( !gObjIsConnected(aIndex) )
  14876. return;
  14877.  
  14878. if ( !CC_MAP_RANGE(gObj[aIndex].MapNumber) )
  14879. return;
  14880.  
  14881. if ( g_ChaosCastle.ObjSetPosition(aIndex, gObj[aIndex].X, gObj[aIndex].Y) == TRUE )
  14882. gObj[aIndex].m_iChaosCastleBlowTime = GetTickCount();
  14883. }
  14884.  
  14885.  
  14886.  
  14887.  
  14888.  
  14889. void CGRequestEventEnterCount(PMSG_REQ_CL_ENTERCOUNT* lpMsg, int aIndex)
  14890. {
  14891. if ( !lpMsg )
  14892. return;
  14893.  
  14894. switch ( lpMsg->btEventType )
  14895. {
  14896. case 0x02:
  14897. EGReqBloodCastleEnterCount(aIndex);
  14898. break;
  14899. case 0x03: //Illusion Temple
  14900. g_IllusionTempleEvent.EGReqIllusionTempleEnterCount(aIndex);
  14901. break;
  14902.  
  14903. }
  14904. }
  14905.  
  14906. struct PMSG_REQ_2ANIV_SERIAL
  14907. {
  14908. PBMSG_HEAD h; // C1:08
  14909. int iINDEX; // 8
  14910. char szUID[MAX_ACCOUNT_LEN+1]; // 8
  14911. char SERIAL1[5]; // 13
  14912. char SERIAL2[5]; // 18
  14913. char SERIAL3[5]; // 1D
  14914. int iMEMB_GUID; // 24
  14915. };
  14916.  
  14917.  
  14918. void CGRequestLottoRegister(PMSG_REQ_2ANV_LOTTO_EVENT* lpMsg, int aIndex)
  14919. {
  14920. PMSG_REQ_2ANIV_SERIAL pMsg;
  14921.  
  14922. PHeadSetB((LPBYTE)&pMsg, 0x08, sizeof(pMsg));
  14923.  
  14924. if ( gObj[aIndex].UseEventServer )
  14925. return;
  14926.  
  14927. gObj[aIndex].UseEventServer = TRUE;
  14928. pMsg.iINDEX = aIndex;
  14929. pMsg.iMEMB_GUID = gObj[aIndex].DBNumber;
  14930. memcpy(pMsg.szUID, gObj[aIndex].AccountID, MAX_ACCOUNT_LEN);
  14931. pMsg.szUID[MAX_ACCOUNT_LEN] = 0;
  14932. memcpy(pMsg.SERIAL1, lpMsg->SERIAL1, 4);
  14933. pMsg.SERIAL1[4] = 0;
  14934. memcpy(pMsg.SERIAL2, lpMsg->SERIAL2, 4);
  14935. pMsg.SERIAL2[4] = 0;
  14936. memcpy(pMsg.SERIAL3, lpMsg->SERIAL3, 4);
  14937. pMsg.SERIAL3[4] = 0;
  14938.  
  14939. DataSendEventChip((PCHAR)&pMsg, sizeof(pMsg));
  14940.  
  14941. LogAddTD("[Mu_2Anv_Event] [%s][%s] Register Lotto Number (Serial: %s-%s-%s)",
  14942. gObj[aIndex].AccountID, gObj[aIndex].Name, pMsg.SERIAL1, pMsg.SERIAL2, pMsg.SERIAL3);
  14943. }
  14944.  
  14945.  
  14946. struct SDHP_CHARACTER_TRANSFER
  14947. {
  14948. PBMSG_HEAD h; // C1:CF
  14949. char Account[10]; // 3
  14950. short Number; // E
  14951. };
  14952.  
  14953.  
  14954.  
  14955. void CGReqMoveOtherServer(PMSG_REQ_MOVE_OTHERSERVER * lpMsg, int aIndex)
  14956. {
  14957. if ( !gEnableServerDivision)
  14958. return;
  14959.  
  14960. if ( !gObjIsConnectedGP(aIndex))
  14961. {
  14962. LogAddC(2, "error-L3 [%s][%d]", __FILE__, __LINE__);
  14963. return;
  14964. }
  14965.  
  14966. LPOBJ lpObj = &gObj[aIndex];
  14967.  
  14968. if ( lpObj->m_MoveOtherServer )
  14969. return;
  14970.  
  14971. lpObj->m_MoveOtherServer = true;
  14972.  
  14973. PMSG_DEFRESULT pResult;
  14974. PHeadSetB((LPBYTE)&pResult, 0x99, sizeof(pResult));
  14975.  
  14976. if ( !gObjJoominCheck(aIndex, lpMsg->LastJoominNumber))
  14977. {
  14978. pResult.result = 0;
  14979.  
  14980. DataSend(aIndex, (LPBYTE)&pResult, pResult.h.size);
  14981. lpObj->m_MoveOtherServer = false;
  14982.  
  14983. LogAddTD("[CharTrasfer] Fail (JoominNumber) [%s][%s]",
  14984. lpObj->AccountID, lpObj->Name);
  14985.  
  14986. GCServerMsgStringSend("¹®ֱ¦ ¹»‎½ֳ change@webzen.co.kr·־ ¹®ְַַ״ ֱײ½ֳ±ג¹¶ר´ֿ´", lpObj->m_Index, 1);
  14987.  
  14988. return;
  14989. }
  14990.  
  14991. SDHP_CHARACTER_TRANSFER pCharTransfer;
  14992.  
  14993. GJSetCharacterInfo(lpObj, lpObj->m_Index, FALSE);
  14994. PHeadSetB((LPBYTE)&pCharTransfer, 0xCF, sizeof(pCharTransfer));
  14995. pCharTransfer.Number = aIndex;
  14996. memcpy(pCharTransfer.Account, lpObj->AccountID, sizeof(pCharTransfer.Account));
  14997.  
  14998. cDBSMng.Send((PCHAR)&pCharTransfer, sizeof(pCharTransfer));
  14999.  
  15000. LogAddTD("[CharTrasfer] Request Character Trasfer [%s][%s]",
  15001. lpObj->AccountID, lpObj->Name);
  15002. }
  15003.  
  15004.  
  15005.  
  15006.  
  15007. void GCPacketCheckSumRecv(PMSG_PACKETCHECKSUM * aRecv, int aIndex)
  15008. {
  15009. gPacketCheckSum.AddCheckSum(aIndex, aRecv->funcindex, aRecv->CheckSum);
  15010. }
  15011.  
  15012.  
  15013.  
  15014.  
  15015. /*void GCNPggSendCheckSum(int aIndex, _GG_AUTH_DATA * pggAuthData)
  15016. {
  15017. PMSG_NPROTECTGGCHECKSUM pMsg;
  15018.  
  15019. PHeadSetBE((LPBYTE)&pMsg, 0x73, sizeof(pMsg));
  15020. memcpy(&pMsg.m_ggadCheckSum, pggAuthData, sizeof(pMsg.m_ggadCheckSum));
  15021.  
  15022. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15023. } */
  15024.  
  15025.  
  15026.  
  15027.  
  15028. /* void GCNPggCheckSumRecv(PMSG_NPROTECTGGCHECKSUM * lpMsg, int aIndex)
  15029. {
  15030. LPOBJ lpObj = &gObj[aIndex];
  15031.  
  15032. if ( !gObjIsConnected(aIndex))
  15033. return;
  15034.  
  15035. LogAddTD("[NPgg] Recv Checksum = %x,AuthValue = %x [%s][%s]",
  15036. lpMsg->m_ggadCheckSum.dwIndex, lpObj->NPggCSAuth.m_AuthAnswer.dwIndex,
  15037. lpObj->AccountID, lpObj->Name);
  15038.  
  15039. memcpy(&gObj[aIndex].NPggCSAuth.m_AuthAnswer, &lpMsg->m_ggadCheckSum, sizeof(lpObj->NPggCSAuth.m_AuthAnswer));
  15040.  
  15041. DWORD dwGGErrCode = gObj[aIndex].NPggCSAuth.CheckAuthAnswer();
  15042.  
  15043. if ( dwGGErrCode )
  15044. {
  15045. LogAddTD("[NPgg] Invalid Checksum Detect Checksum = %x,AuthValue = %x [%s][%s]",
  15046. lpMsg->m_ggadCheckSum.dwIndex, lpObj->NPggCSAuth.m_AuthAnswer.dwIndex,
  15047. lpObj->AccountID, lpObj->Name);
  15048.  
  15049. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 177)), aIndex, 0);
  15050. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 178)), aIndex, 0);
  15051. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 179)), aIndex, 0);
  15052.  
  15053. CloseClient(aIndex);
  15054.  
  15055. return;
  15056. }
  15057.  
  15058. lpObj->m_NPggCheckSumSendTime = GetTickCount();
  15059. lpObj->m_bSentGGAuth = false;
  15060.  
  15061. LogAddTD("[NPgg] Checksum Clear %x [%s][%s]",
  15062. lpMsg->m_ggadCheckSum.dwIndex, lpObj->AccountID, lpObj->Name);
  15063. } */
  15064.  
  15065. struct PMSG_REQ_DUEL_OK
  15066. {
  15067. PBMSG_HEAD h; // C1:AC
  15068. BYTE NumberH; // 3
  15069. BYTE NumberL; // 4
  15070. char szName[10]; // 5
  15071. };
  15072.  
  15073.  
  15074. void CGDuelStartRequestRecv(PMSG_REQ_START_DUEL * lpMsg, int aIndex)
  15075. {
  15076. int iDuelIndex = -1;
  15077. char szTempText[256];
  15078.  
  15079. if ( gObj[aIndex].CloseType != -1 )
  15080. return;
  15081.  
  15082. if ( gNonPK )
  15083. {
  15084. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 174)), aIndex, 1);
  15085. return;
  15086. }
  15087.  
  15088. if ( !gPkLimitFree )
  15089. {
  15090. if ( gObj[aIndex].m_PK_Level >= 6 )
  15091. {
  15092. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 175)), aIndex, 1);
  15093. return;
  15094. }
  15095. }
  15096.  
  15097. if ( OBJMAX_RANGE(gObj[aIndex].m_iDuelUserReserved) )
  15098. {
  15099. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 159)), aIndex, 1);
  15100. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 161)), aIndex, 1);
  15101. return;
  15102. }
  15103.  
  15104. if ( OBJMAX_RANGE(gObj[aIndex].m_iDuelUser ) )
  15105. {
  15106. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 160)), aIndex, 1);
  15107. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 161)), aIndex, 1);
  15108. return;
  15109. }
  15110.  
  15111. if ( CC_MAP_RANGE(gObj[aIndex].MapNumber) )
  15112. {
  15113. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 207)), aIndex, 1);
  15114. return;
  15115. }
  15116.  
  15117. LPOBJ lpObj = &gObj[aIndex];
  15118.  
  15119. if ( !PacketCheckTime(lpObj ) )
  15120. return;
  15121.  
  15122. iDuelIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  15123.  
  15124. if ( !OBJMAX_RANGE(iDuelIndex) )
  15125. {
  15126. LogAdd("error : %s %d (%d)", __FILE__, __LINE__, iDuelIndex);
  15127. return;
  15128. }
  15129.  
  15130. if ( iDuelIndex == aIndex )
  15131. return;
  15132.  
  15133. if ( !gPkLimitFree )
  15134. {
  15135. if ( gObj[iDuelIndex].m_PK_Level >= 6 )
  15136. {
  15137. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 176)), aIndex, 1);
  15138. return;
  15139. }
  15140. }
  15141.  
  15142. char szDuelName[MAX_ACCOUNT_LEN+1]={0};
  15143. char szDuelName2[MAX_ACCOUNT_LEN+1]={0};
  15144. memcpy(szDuelName, gObj[iDuelIndex].Name, MAX_ACCOUNT_LEN);
  15145. szDuelName[MAX_ACCOUNT_LEN] = 0;
  15146. memcpy(szDuelName2, lpMsg->szName, MAX_ACCOUNT_LEN);
  15147. szDuelName2[MAX_ACCOUNT_LEN] = 0;
  15148.  
  15149. if ( strcmp(szDuelName, szDuelName2) )
  15150. {
  15151. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 162)), aIndex, 1);
  15152. return;
  15153. }
  15154.  
  15155. if ( IsDuelEnable(iDuelIndex) == FALSE )
  15156. {
  15157. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 163)), aIndex, 1);
  15158. return;
  15159. }
  15160.  
  15161. if ( lpObj->lpGuild && lpObj->lpGuild->WarState == 1 )
  15162. {
  15163. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 164)), aIndex, 1);
  15164. return;
  15165. }
  15166.  
  15167. if ( gObj[iDuelIndex].lpGuild && gObj[iDuelIndex].lpGuild->WarState == 1 )
  15168. {
  15169. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 165)), aIndex, 1);
  15170. return;
  15171. }
  15172.  
  15173. if ( gObjIsConnected(iDuelIndex) == FALSE )
  15174. return;
  15175.  
  15176. if ( gObj[iDuelIndex].Type == OBJ_MONSTER )
  15177. return;
  15178.  
  15179. if ( gObj[iDuelIndex].CloseCount >= 0 )
  15180. return;
  15181.  
  15182. BOOL bRetVal = FALSE;
  15183.  
  15184. for (int n=0;n<MAX_SELF_DEFENSE;n++)
  15185. {
  15186. if ( lpObj->SelfDefense[n] >= 0 )
  15187. {
  15188. bRetVal = TRUE;
  15189. break;
  15190. }
  15191. }
  15192.  
  15193. if ( bRetVal )
  15194. {
  15195. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 189)), aIndex, 1);
  15196. return;
  15197. }
  15198.  
  15199. for (int n = 0; n < MAX_SELF_DEFENSE; n++)
  15200. {
  15201. if ( gObj[iDuelIndex].SelfDefense[n] >= 0 )
  15202. {
  15203. bRetVal = TRUE;
  15204. break;
  15205. }
  15206. }
  15207.  
  15208. if ( bRetVal )
  15209. {
  15210. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 189)), aIndex, 1);
  15211. return;
  15212. }
  15213.  
  15214. if ( DS_MAP_RANGE(gObj[iDuelIndex].MapNumber ) )
  15215. {
  15216. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 180)), aIndex, 1);
  15217. return;
  15218. }
  15219.  
  15220. if ( BC_MAP_RANGE(gObj[aIndex].MapNumber) )
  15221. {
  15222. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 166)), aIndex, 1);
  15223. return;
  15224. }
  15225.  
  15226. if ( lpObj->m_IfState.use > 0 )
  15227. {
  15228. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 167)), aIndex, 1);
  15229. return;
  15230. }
  15231.  
  15232. if ( gObj[iDuelIndex].m_IfState.use > 0 )
  15233. {
  15234. wsprintf(szTempText, lMsg.Get(MSGGET(4, 168)), gObj[iDuelIndex].Name);
  15235. GCServerMsgStringSend(szTempText, aIndex, 1);
  15236. return;
  15237. }
  15238.  
  15239. if ( OBJMAX_RANGE(gObj[iDuelIndex].m_iDuelUserRequested) )
  15240. {
  15241. wsprintf(szTempText, lMsg.Get(MSGGET(4, 169)), gObj[iDuelIndex].Name);
  15242. GCServerMsgStringSend(szTempText, aIndex, 1);
  15243. return;
  15244. }
  15245.  
  15246. if ( OBJMAX_RANGE(gObj[iDuelIndex].m_iDuelUserReserved) )
  15247. {
  15248. wsprintf(szTempText, lMsg.Get(MSGGET(4, 170)), gObj[iDuelIndex].Name);
  15249. GCServerMsgStringSend(szTempText, aIndex, 1);
  15250. return;
  15251. }
  15252.  
  15253. if ( OBJMAX_RANGE(gObj[iDuelIndex].m_iDuelUser) )
  15254. {
  15255. wsprintf(szTempText, lMsg.Get(MSGGET(4, 171)), gObj[iDuelIndex].Name);
  15256. GCServerMsgStringSend(szTempText, aIndex, 1);
  15257. return;
  15258. }
  15259.  
  15260. lpObj->m_iDuelUserReserved = iDuelIndex;
  15261. lpObj->m_iDuelUser = -1;
  15262. gObj[iDuelIndex].m_iDuelUserRequested = aIndex;
  15263.  
  15264. PMSG_REQ_DUEL_OK pMsg;
  15265.  
  15266. pMsg.h.c = 0xC1;
  15267. pMsg.h.headcode = 0xAC;
  15268. pMsg.h.size = sizeof(pMsg);
  15269. pMsg.NumberH = SET_NUMBERH(aIndex);
  15270. pMsg.NumberL = SET_NUMBERL(aIndex);
  15271. memcpy(pMsg.szName, gObj[aIndex].Name, sizeof(pMsg.szName));
  15272.  
  15273. DataSend(iDuelIndex, (LPBYTE)&pMsg, pMsg.h.size);
  15274.  
  15275. wsprintf(szTempText, lMsg.Get(MSGGET(4, 172)), gObj[iDuelIndex].Name);
  15276. GCServerMsgStringSend(szTempText, aIndex, 1);
  15277.  
  15278. LogAddTD("[Duel] [%s][%s] Requested to Start Duel to [%s][%s]",
  15279. lpObj->AccountID, lpObj->Name, gObj[iDuelIndex].AccountID, gObj[iDuelIndex].Name);
  15280. }
  15281.  
  15282. void CGDuelEndRequestRecv(PMSG_REQ_END_DUEL * lpMsg, int aIndex)
  15283. {
  15284. int iDuelIndex = -1;
  15285.  
  15286. if ( gObj[aIndex].CloseType != -1 )
  15287. return;
  15288.  
  15289. if ( OBJMAX_RANGE(gObj[aIndex].m_iDuelUserReserved) )
  15290. {
  15291. gObj[aIndex].m_iDuelUserReserved = -1;
  15292. }
  15293.  
  15294. if ( OBJMAX_RANGE(gObj[aIndex].m_iDuelUser) )
  15295. {
  15296. iDuelIndex = gObj[aIndex].m_iDuelUser;
  15297. gObj[aIndex].m_iDuelUser = -1;
  15298.  
  15299. PMSG_ANS_END_DUEL pMsg;
  15300.  
  15301. pMsg.h.c = 0xC1;
  15302. pMsg.h.headcode = 0xAB;
  15303. pMsg.h.size = sizeof(pMsg);
  15304. pMsg.NumberH = SET_NUMBERH(iDuelIndex);
  15305. pMsg.NumberL = SET_NUMBERL(iDuelIndex);
  15306. memcpy(pMsg.szName, gObj[iDuelIndex].Name, sizeof(pMsg.szName));
  15307.  
  15308. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  15309.  
  15310. if ( iDuelIndex == aIndex )
  15311. {
  15312. return;
  15313. }
  15314. }
  15315. else
  15316. {
  15317. LogAdd("error : %s %d (%d)", __FILE__, __LINE__, iDuelIndex);
  15318. return;
  15319. }
  15320.  
  15321. if ( OBJMAX_RANGE(gObj[iDuelIndex].m_iDuelUser) )
  15322. {
  15323. if ( gObj[iDuelIndex].m_iDuelUser == aIndex )
  15324. {
  15325. gObj[iDuelIndex].m_iDuelUser = -1;
  15326.  
  15327. PMSG_ANS_END_DUEL pMsg;
  15328.  
  15329. pMsg.h.c = 0xC1;
  15330. pMsg.h.headcode = 0xAB;
  15331. pMsg.h.size = sizeof(pMsg);
  15332. pMsg.NumberH = SET_NUMBERH(aIndex);
  15333. pMsg.NumberL = SET_NUMBERL(aIndex);
  15334. memcpy(pMsg.szName, gObj[aIndex].Name, sizeof(pMsg.szName));
  15335.  
  15336. DataSend(iDuelIndex, (LPBYTE)&pMsg, pMsg.h.size);
  15337.  
  15338. LogAddTD("[Duel] [%s][%s] Duel Ended [%s][%s]",
  15339. gObj[aIndex].AccountID, gObj[aIndex].Name,
  15340. gObj[iDuelIndex].AccountID, gObj[iDuelIndex].Name);
  15341. }
  15342. }
  15343. }
  15344.  
  15345.  
  15346. struct PMSG_ANS_START_DUEL
  15347. {
  15348. PBMSG_HEAD h; // C1:AA
  15349. bool bDuelStart; // 3
  15350. BYTE NumberH; // 4
  15351. BYTE NumberL; // 5
  15352. char szName[10]; // 6
  15353. };
  15354.  
  15355.  
  15356.  
  15357. void CGDuelOkRequestRecv(PMSG_ANS_DUEL_OK * lpMsg, int aIndex)
  15358. {
  15359. int iDuelIndex = -1;
  15360.  
  15361. PMSG_ANS_START_DUEL pMsgSend;
  15362.  
  15363. pMsgSend.h.c = 0xC1;
  15364. pMsgSend.h.headcode = 0xAA;
  15365. pMsgSend.h.size = sizeof(pMsgSend);
  15366.  
  15367. if ( gObj[aIndex].CloseType != -1 )
  15368. return;
  15369.  
  15370. iDuelIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  15371.  
  15372. if ( OBJMAX_RANGE(iDuelIndex) )
  15373. {
  15374. if ( !gObjIsConnected(iDuelIndex) )
  15375. return;
  15376.  
  15377. if ( gObj[iDuelIndex].Type == OBJ_MONSTER )
  15378. return;
  15379.  
  15380. if ( gObj[iDuelIndex].CloseCount >= 0 )
  15381. return;
  15382.  
  15383. if ( lpMsg->bDuelOK )
  15384. {
  15385. if ( BC_MAP_RANGE(gObj[iDuelIndex].MapNumber) ||
  15386. CC_MAP_RANGE(gObj[iDuelIndex].MapNumber) ||
  15387. DS_MAP_RANGE(gObj[iDuelIndex].MapNumber) )
  15388. {
  15389. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 207)), aIndex, 1);
  15390. gObj[aIndex].m_iDuelUserRequested = -1;
  15391. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15392. memcpy(pMsgSend.szName, gObj[aIndex].Name, sizeof(pMsgSend.szName));
  15393. pMsgSend.bDuelStart = false;
  15394.  
  15395. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15396. return;
  15397. }
  15398. }
  15399.  
  15400. if ( OBJMAX_RANGE(gObj[aIndex].m_iDuelUser ) )
  15401. {
  15402. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 160)), aIndex, 1);
  15403. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 161)), aIndex, 1);
  15404. gObj[aIndex].m_iDuelUserRequested = -1;
  15405. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15406. memcpy(pMsgSend.szName, gObj[aIndex].Name, sizeof(pMsgSend.szName));
  15407. pMsgSend.bDuelStart = false;
  15408.  
  15409. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15410. return;
  15411. }
  15412.  
  15413. if ( OBJMAX_RANGE(gObj[aIndex].m_iDuelUserReserved) )
  15414. {
  15415. GCServerMsgStringSend(lMsg.Get(MSGGET(4, 173)), aIndex, 1);
  15416. gObj[aIndex].m_iDuelUserRequested = -1;
  15417. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15418. memcpy(pMsgSend.szName, gObj[aIndex].Name, sizeof(pMsgSend.szName));
  15419. pMsgSend.bDuelStart = false;
  15420.  
  15421. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15422. return;
  15423. }
  15424.  
  15425. if ( gObj[iDuelIndex].m_iDuelUserReserved == aIndex )
  15426. {
  15427. char szDuelName[MAX_ACCOUNT_LEN+1]={0};
  15428. char szDuelName2[MAX_ACCOUNT_LEN+1]={0};
  15429. memcpy(szDuelName, gObj[iDuelIndex].Name, MAX_ACCOUNT_LEN);
  15430. szDuelName[MAX_ACCOUNT_LEN] = 0;
  15431. memcpy(szDuelName2, lpMsg->szName, MAX_ACCOUNT_LEN);
  15432. szDuelName2[MAX_ACCOUNT_LEN] = 0;
  15433.  
  15434. if ( !strcmp(szDuelName, szDuelName2))
  15435. {
  15436. if ( lpMsg->bDuelOK == false)
  15437. {
  15438. gObj[aIndex].m_iDuelUserRequested = -1;
  15439. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15440. memcpy(pMsgSend.szName, gObj[aIndex].Name, sizeof(pMsgSend.szName));
  15441. pMsgSend.bDuelStart = false;
  15442.  
  15443. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15444. }
  15445. else if ( lpMsg->bDuelOK == true )
  15446. {
  15447. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15448. gObj[iDuelIndex].m_btDuelScore = 0;
  15449. gObj[iDuelIndex].m_iDuelUser = aIndex;
  15450. gObj[iDuelIndex].m_iDuelTickCount = GetTickCount();
  15451. gObj[aIndex].m_iDuelUserRequested = -1;
  15452. gObj[aIndex].m_iDuelUserReserved = -1;
  15453. gObj[aIndex].m_btDuelScore = 0;
  15454. gObj[aIndex].m_iDuelUser = iDuelIndex;
  15455. gObj[aIndex].m_iDuelTickCount = GetTickCount();
  15456.  
  15457. pMsgSend.bDuelStart = true;
  15458. pMsgSend.NumberH = SET_NUMBERH(iDuelIndex);
  15459. pMsgSend.NumberL = SET_NUMBERL(iDuelIndex);
  15460. memcpy(pMsgSend.szName, szDuelName, sizeof(pMsgSend.szName));
  15461.  
  15462. DataSend(aIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15463.  
  15464. pMsgSend.NumberH = SET_NUMBERH(aIndex);
  15465. pMsgSend.NumberL = SET_NUMBERL(aIndex);
  15466. memcpy(pMsgSend.szName, gObj[aIndex].Name, sizeof(pMsgSend.szName));
  15467.  
  15468. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15469.  
  15470. GCSendDuelScore(gObj[aIndex].m_Index, gObj[iDuelIndex].m_Index);
  15471.  
  15472. LogAddTD("[Duel] [%s][%s] Duel Started [%s][%s]",
  15473. gObj[aIndex].AccountID, gObj[aIndex].Name,
  15474. gObj[iDuelIndex].AccountID, gObj[iDuelIndex].Name);
  15475. }
  15476. }
  15477. else
  15478. {
  15479. gObj[aIndex].m_iDuelUserRequested = -1;
  15480. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15481. pMsgSend.bDuelStart = false;
  15482.  
  15483. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15484. return;
  15485. }
  15486. }
  15487. else
  15488. {
  15489. gObj[aIndex].m_iDuelUserRequested = -1;
  15490. gObj[iDuelIndex].m_iDuelUserReserved = -1;
  15491. pMsgSend.bDuelStart = false;
  15492.  
  15493. DataSend(iDuelIndex, (LPBYTE)&pMsgSend, pMsgSend.h.size);
  15494. return;
  15495. }
  15496. }
  15497. }
  15498.  
  15499.  
  15500. struct PMSG_ANS_DUEL_SCORE
  15501. {
  15502. PBMSG_HEAD h; // C1:AD
  15503. BYTE NumberH1; // 3
  15504. BYTE NumberL1; // 4
  15505. BYTE NumberH2; // 5
  15506. BYTE NumberL2; // 6
  15507. BYTE btDuelScore1; // 7
  15508. BYTE btDuelScore2; // 8
  15509. };
  15510.  
  15511.  
  15512.  
  15513. void GCSendDuelScore(int aIndex1, int aIndex2)
  15514. {
  15515. if ( !OBJMAX_RANGE(aIndex1) || !OBJMAX_RANGE(aIndex2))
  15516. return;
  15517.  
  15518. if ( !gObjIsConnected(aIndex1) || !gObjIsConnected(aIndex2) )
  15519. return;
  15520.  
  15521. if ( gObj[aIndex1].Type == OBJ_MONSTER || gObj[aIndex2].Type == OBJ_MONSTER )
  15522. return;
  15523.  
  15524. if ( gObj[aIndex1].CloseCount >= 0 || gObj[aIndex2].CloseCount >= 0 )
  15525. return;
  15526.  
  15527. PMSG_ANS_DUEL_SCORE pMsg;
  15528.  
  15529. pMsg.h.c = 0xC1;
  15530. pMsg.h.headcode = 0xAD;
  15531. pMsg.h.size = sizeof(pMsg);
  15532. pMsg.NumberH1 = SET_NUMBERH(aIndex1);
  15533. pMsg.NumberL1 = SET_NUMBERL(aIndex1);
  15534. pMsg.NumberH2 = SET_NUMBERH(aIndex2);
  15535. pMsg.NumberL2 = SET_NUMBERL(aIndex2);
  15536. pMsg.btDuelScore1 = gObj[aIndex1].m_btDuelScore;
  15537. pMsg.btDuelScore2 = gObj[aIndex2].m_btDuelScore;
  15538.  
  15539. DataSend(aIndex1, (LPBYTE)&pMsg, pMsg.h.size);
  15540. DataSend(aIndex2, (LPBYTE)&pMsg, pMsg.h.size);
  15541. }
  15542.  
  15543.  
  15544. struct PMSG_GETITEMINFO_FOR_PARTY
  15545. {
  15546. PBMSG_HEAD h; // C1:47
  15547. BYTE NumberH; // 3
  15548. BYTE NumberL; // 4
  15549. UINT ItemInfo; // 8
  15550. BYTE Level; // C
  15551. };
  15552.  
  15553.  
  15554. void GCSendGetItemInfoForParty(int aIndex, CMapItem * lpItem)
  15555. {
  15556. LPOBJ lpObj = &gObj[aIndex];
  15557.  
  15558. if ( lpObj->PartyNumber >= 0)
  15559. {
  15560. PMSG_GETITEMINFO_FOR_PARTY pMsg;
  15561.  
  15562. pMsg.h.c = 0xC1;
  15563. pMsg.h.headcode = 0x47;
  15564. pMsg.h.size = sizeof(pMsg);
  15565. pMsg.NumberH = SET_NUMBERH(aIndex);
  15566. pMsg.NumberL = SET_NUMBERL(aIndex);
  15567. pMsg.ItemInfo = lpItem->m_Type & (ITEMGET(MAX_TYPE_ITEMS-1, MAX_SUBTYPE_ITEMS-1));
  15568.  
  15569. if ( lpItem->m_Option1 )
  15570. pMsg.ItemInfo |= 0x2000;
  15571.  
  15572. if ( lpItem->m_Option2 )
  15573. pMsg.ItemInfo |= 0x4000;
  15574.  
  15575. if ( lpItem->m_Option3 )
  15576. pMsg.ItemInfo |= 0x8000;
  15577.  
  15578. if ( lpItem->m_NewOption )
  15579. pMsg.ItemInfo |= 0x10000;
  15580.  
  15581. if ( lpItem->m_SetOption )
  15582. pMsg.ItemInfo |= 0x20000;
  15583.  
  15584. if ( g_kItemSystemFor380.Is380OptionItem( (lpItem != NULL)?((CItem *)&lpItem->m_Number):NULL) == TRUE )
  15585. pMsg.ItemInfo |= 0x40000;
  15586.  
  15587. pMsg.Level = lpItem->m_Level;
  15588.  
  15589. int partycount = gParty.GetPartyCount(lpObj->PartyNumber);
  15590.  
  15591. if ( partycount >= 0 )
  15592. {
  15593. for ( int n=0;n<MAX_USER_IN_PARTY;n++)
  15594. {
  15595. int number = gParty.m_PartyS[lpObj->PartyNumber].Number[n];
  15596.  
  15597. if ( number >= 0 )
  15598. {
  15599. DataSend(number, (LPBYTE)&pMsg, pMsg.h.size);
  15600. }
  15601. }
  15602. }
  15603. }
  15604. }
  15605.  
  15606.  
  15607.  
  15608. struct PMSG_EFFECTINFO
  15609. {
  15610. PBMSG_HEAD h; // C1:48
  15611. BYTE NumberH; // 3
  15612. BYTE NumberL; // 4
  15613. BYTE btType; // 5
  15614. };
  15615.  
  15616.  
  15617. void GCSendEffectInfo(int aIndex, BYTE btType)
  15618. {
  15619. if ( OBJMAX_RANGE(aIndex) == FALSE )
  15620. {
  15621. return;
  15622. }
  15623.  
  15624. LPOBJ lpObj = &gObj[aIndex];
  15625. PMSG_EFFECTINFO pMsg;
  15626.  
  15627. pMsg.h.c = 0xC1;
  15628. pMsg.h.headcode = 0x48;
  15629. pMsg.h.size = sizeof(pMsg);
  15630. pMsg.NumberH = SET_NUMBERH(aIndex);
  15631. pMsg.NumberL = SET_NUMBERL(aIndex);
  15632. pMsg.btType = btType;
  15633.  
  15634. if ( btType == 17 )
  15635. {
  15636. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  15637. }
  15638.  
  15639. MsgSendV2(lpObj, (LPBYTE)&pMsg, pMsg.h.size);
  15640. }
  15641.  
  15642.  
  15643.  
  15644.  
  15645. void CGRequestPetItemCommand(PMSG_REQUEST_PET_ITEM_COMMAND * lpMsg, int aIndex)
  15646. {
  15647. if ( !gObjIsConnectedGP(aIndex))
  15648. {
  15649. LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
  15650. return;
  15651. }
  15652.  
  15653. if ( !OBJMAX_RANGE(aIndex))
  15654. return;
  15655.  
  15656. LPOBJ lpObj = &gObj[aIndex];
  15657.  
  15658. if ( lpMsg->PetType )
  15659. return;
  15660.  
  15661. int iTargetIndex = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL);
  15662. gDarkSpirit[aIndex].ChangeCommand(lpMsg->Command, iTargetIndex);
  15663. }
  15664.  
  15665.  
  15666.  
  15667.  
  15668. void CGRequestPetItemInfo(PMSG_REQUEST_PET_ITEMINFO * lpMsg, int aIndex)
  15669. {
  15670. if ( !gObjIsConnectedLG(aIndex))
  15671. {
  15672. LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
  15673. return;
  15674. }
  15675.  
  15676. if ( !OBJMAX_RANGE(aIndex))
  15677. {
  15678. return;
  15679. }
  15680.  
  15681. LPOBJ lpObj = &gObj[aIndex];
  15682.  
  15683. if ( lpMsg->PetType != 0 && lpMsg->PetType != 1 )
  15684. {
  15685. return;
  15686. }
  15687.  
  15688. PMSG_SEND_PET_ITEMINFO pMsg;
  15689.  
  15690. pMsg.h.set((LPBYTE)&pMsg, 0xA9, sizeof(pMsg));
  15691. pMsg.PetType = lpMsg->PetType;
  15692. pMsg.InvenType = lpMsg->InvenType;
  15693. pMsg.nPos = lpMsg->nPos;
  15694.  
  15695. if ( lpMsg->InvenType == 0 ) // Inventory
  15696. {
  15697. if ( !INVENTORY_RANGE(lpMsg->nPos))
  15698. {
  15699. LogAddTD("[PetItem] [%s][%s] RequestPetItem Invalid Iventory nPos %d", lpObj->AccountID, lpObj->Name, lpMsg->nPos);
  15700. return;
  15701. }
  15702.  
  15703. if ( lpObj->pInventory[lpMsg->nPos].IsItem() )
  15704. {
  15705. pMsg.Exp = lpObj->pInventory[lpMsg->nPos].m_PetItem_Exp;
  15706. pMsg.Level = lpObj->pInventory[lpMsg->nPos].m_PetItem_Level;
  15707. pMsg.Life = lpObj->pInventory[lpMsg->nPos].m_Durability;
  15708. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15709. }
  15710. }
  15711. else if ( lpMsg->InvenType == 1 ) // Warehouse
  15712. {
  15713. if ( lpObj->LoadWareHouseInfo != false )
  15714. {
  15715. if ( !WAREHOUSE_RANGE(lpMsg->nPos))
  15716. {
  15717. LogAddTD("[PetItem] [%s][%s] RequestPetItem Invalid WareHouse nPos %d", lpObj->AccountID, lpObj->Name, lpMsg->nPos);
  15718. return;
  15719. }
  15720.  
  15721. if ( lpObj->pWarehouse[lpMsg->nPos].IsItem() )
  15722. {
  15723. pMsg.Exp = lpObj->pWarehouse[lpMsg->nPos].m_PetItem_Exp;
  15724. pMsg.Level = lpObj->pWarehouse[lpMsg->nPos].m_PetItem_Level;
  15725. pMsg.Life = lpObj->pWarehouse[lpMsg->nPos].m_Durability;
  15726. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15727. }
  15728. }
  15729. }
  15730. else if ( lpMsg->InvenType == 2 ) // Trade
  15731. {
  15732. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 1 )
  15733. {
  15734. return;
  15735. }
  15736.  
  15737. if ( !TRADE_BOX_RANGE(lpMsg->nPos))
  15738. {
  15739. LogAddTD("[PetItem] [%s][%s] RequestPetItem Invalid Trade nPos %d", lpObj->AccountID, lpObj->Name, lpMsg->nPos);
  15740. return;
  15741. }
  15742.  
  15743. if ( lpObj->Trade[lpMsg->nPos].IsItem() )
  15744. {
  15745. pMsg.Exp = lpObj->Trade[lpMsg->nPos].m_PetItem_Exp;
  15746. pMsg.Level = lpObj->Trade[lpMsg->nPos].m_PetItem_Level;
  15747. pMsg.Life = lpObj->Trade[lpMsg->nPos].m_Durability;
  15748. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15749. }
  15750. }
  15751. else if ( lpMsg->InvenType == 3 ) // Target Trade
  15752. {
  15753. if ( lpObj->m_IfState.use < 1 || lpObj->m_IfState.type != 1 )
  15754. {
  15755. return;
  15756. }
  15757.  
  15758. int iTargetIndex = gObj[aIndex].TargetNumber;
  15759.  
  15760. if ( iTargetIndex < 0 )
  15761. {
  15762. return;
  15763. }
  15764.  
  15765. if ( !OBJMAX_RANGE(iTargetIndex) )
  15766. {
  15767. return;
  15768. }
  15769.  
  15770. if ( gObj[iTargetIndex].m_IfState.use < 1 || gObj[iTargetIndex].m_IfState.type != 1 )
  15771. {
  15772. return;
  15773. }
  15774.  
  15775. if ( !TRADE_BOX_RANGE(lpMsg->nPos))
  15776. {
  15777. LogAddTD("[PetItem] [%s][%s] RequestPetItem Invalid TargetTrade nPos %d", lpObj->AccountID, lpObj->Name, lpMsg->nPos);
  15778. return;
  15779. }
  15780.  
  15781. if ( gObj[iTargetIndex].Trade[lpMsg->nPos].IsItem() )
  15782. {
  15783. pMsg.Exp = gObj[iTargetIndex].Trade[lpMsg->nPos].m_PetItem_Exp;
  15784. pMsg.Level = gObj[iTargetIndex].Trade[lpMsg->nPos].m_PetItem_Level;
  15785. pMsg.Life = gObj[iTargetIndex].Trade[lpMsg->nPos].m_Durability;
  15786. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15787. }
  15788. }
  15789. else if ( lpMsg->InvenType == 4 ) // Chaos
  15790. {
  15791. if ( !CHAOS_BOX_RANGE(lpMsg->nPos) )
  15792. {
  15793. LogAddTD("[PetItem] [%s][%s] RequestPetItem Invalid Chaos nPos %d", lpObj->AccountID, lpObj->Name, lpMsg->nPos);
  15794. return;
  15795. }
  15796.  
  15797. if ( lpObj->pChaosBox[lpMsg->nPos].IsItem() )
  15798. {
  15799. pMsg.Exp = lpObj->pChaosBox[lpMsg->nPos].m_PetItem_Exp;
  15800. pMsg.Level = lpObj->pChaosBox[lpMsg->nPos].m_PetItem_Level;
  15801. pMsg.Life = lpObj->pChaosBox[lpMsg->nPos].m_Durability;
  15802. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15803. }
  15804. }
  15805. else if ( lpMsg->InvenType == 5 ) // Personal Shop
  15806. {
  15807. if ( !INVENTORY_RANGE(lpMsg->nPos) )
  15808. {
  15809. LogAddTD("[PetItem] [%s][%s] RequestPetItem Invalid Iventory nPos %d", lpObj->AccountID, lpObj->Name, lpMsg->nPos);
  15810. return;
  15811. }
  15812.  
  15813. if ( lpObj->m_iPShopDealerIndex != -1 )
  15814. {
  15815. if ( OBJMAX_RANGE(lpObj->m_iPShopDealerIndex))
  15816. {
  15817. if ( gObj[lpObj->m_iPShopDealerIndex].pInventory[lpMsg->nPos].IsItem() )
  15818. {
  15819. pMsg.Exp = gObj[lpObj->m_iPShopDealerIndex].pInventory[lpMsg->nPos].m_PetItem_Exp;
  15820. pMsg.Level = gObj[lpObj->m_iPShopDealerIndex].pInventory[lpMsg->nPos].m_PetItem_Level;
  15821. pMsg.Life = gObj[lpObj->m_iPShopDealerIndex].pInventory[lpMsg->nPos].m_Durability;
  15822. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15823. }
  15824. }
  15825. }
  15826. }
  15827. }
  15828.  
  15829.  
  15830.  
  15831.  
  15832.  
  15833.  
  15834. struct PMSG_ANS_GUILDVIEWPORT
  15835. {
  15836. PBMSG_HEAD h; // C1:66
  15837. int GuildNumber; // 4
  15838. BYTE btGuildType; // 8
  15839. BYTE UnionName[8]; // 9
  15840. char GuildName[8]; // 11
  15841. BYTE Mark[32]; // 19
  15842.  
  15843. };
  15844.  
  15845.  
  15846. void GCGuildViewportInfo(PMSG_REQ_GUILDVIEWPORT * aRecv, int aIndex)
  15847. {
  15848. if ( !gObjIsConnectedGP(aIndex))
  15849. {
  15850. LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
  15851. return;
  15852. }
  15853.  
  15854. if ( !OBJMAX_RANGE(aIndex))
  15855. return;
  15856.  
  15857. LPOBJ lpObj = &gObj[aIndex];
  15858. DWORD dwGuildNumber = aRecv->GuildNumber;
  15859. _GUILD_INFO_STRUCT * lpGuildInfo = Guild.SearchGuild_Number(dwGuildNumber);
  15860.  
  15861. if ( lpGuildInfo )
  15862. {
  15863. PMSG_ANS_GUILDVIEWPORT pMsg;
  15864.  
  15865. pMsg.h.c = 0xC1;
  15866. pMsg.h.headcode = 0x66;
  15867. pMsg.h.size = sizeof(pMsg);
  15868. pMsg.GuildNumber = lpGuildInfo->Number;
  15869. pMsg.btGuildType = lpGuildInfo->btGuildType;
  15870.  
  15871. TUnionInfo * pUnionInfo = UnionManager.SearchUnion(lpGuildInfo->iGuildUnion);
  15872.  
  15873. if ( pUnionInfo )
  15874. memcpy(pMsg.UnionName, pUnionInfo->m_szMasterGuild, MAX_GUILD_LEN);
  15875. else
  15876. pMsg.UnionName[0] = '\0';
  15877.  
  15878.  
  15879.  
  15880.  
  15881.  
  15882.  
  15883. strcpy(pMsg.GuildName, lpGuildInfo->Name);
  15884. memcpy(pMsg.Mark, lpGuildInfo->Mark, sizeof(pMsg.Mark));
  15885.  
  15886. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15887. }
  15888. else
  15889. {
  15890. LogAddTD("¡¡¡ ±זµו ֱ₪÷¸ ֳ£ְ»¼צ ¾רְ½. ְּ¸§ : [%s] ¹רָ£ : %d",
  15891. lpObj->Name, dwGuildNumber);
  15892. }
  15893. }
  15894.  
  15895.  
  15896.  
  15897.  
  15898.  
  15899.  
  15900.  
  15901. void CGGuildAssignStatus(PMSG_GUILD_ASSIGN_STATUS_REQ * aRecv, int aIndex)
  15902. {
  15903. if ( !gObjIsConnectedGP(aIndex))
  15904. {
  15905. LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
  15906. return;
  15907. }
  15908.  
  15909. if ( !OBJMAX_RANGE(aIndex))
  15910. return;
  15911.  
  15912. LPOBJ lpObj = &gObj[aIndex];
  15913. PMSG_GUILD_ASSIGN_STATUS_RESULT pMsg={0};
  15914.  
  15915. pMsg.h.set((LPBYTE)&pMsg, 0xE1, sizeof(pMsg));
  15916. pMsg.btType = aRecv->btType;
  15917. memcpy(pMsg.szTagetName, aRecv->szTagetName, sizeof(pMsg.szTagetName));
  15918.  
  15919. if ( lpObj->GuildNumber <= 0 || lpObj->lpGuild == NULL )
  15920. {
  15921. pMsg.btResult = GUILD_ANS_NOTEXIST_GUILD;
  15922. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15923. return;
  15924. }
  15925.  
  15926. if ( gObj[aIndex].GuildStatus != G_MASTER )
  15927. {
  15928. pMsg.btResult = GUILD_ANS_NOTEXIST_PERMISSION;
  15929. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15930. return;
  15931. }
  15932.  
  15933. char szTargetName[MAX_ACCOUNT_LEN+1]={0};
  15934. memcpy(szTargetName, aRecv->szTagetName, MAX_ACCOUNT_LEN);
  15935.  
  15936. if ( !strcmp(gObj[aIndex].Name, szTargetName))
  15937. {
  15938. pMsg.btResult = GUILD_ANS_NOTEXIST_PERMISSION;
  15939. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15940. return;
  15941. }
  15942.  
  15943. if ( lpObj->lpGuild == NULL )
  15944. return;
  15945.  
  15946. if ( aRecv->btType == 1 || aRecv->btType == 2 )
  15947. {
  15948. int iSubMasterCount = 0;
  15949. int iBattleMasterCount = 0;
  15950.  
  15951. for ( int n=0;n<MAX_USER_GUILD;n++)
  15952. {
  15953. if ( lpObj->lpGuild->Use[n] > 0 )
  15954. {
  15955. if ( lpObj->lpGuild->GuildStatus[n] == G_SUB_MASTER )
  15956. {
  15957. iSubMasterCount++;
  15958. }
  15959. else if ( lpObj->lpGuild->GuildStatus[n] == G_BATTLE_MASTER )
  15960. {
  15961. iBattleMasterCount++;
  15962. }
  15963. }
  15964. }
  15965.  
  15966. if ( aRecv->btGuildStatus == G_SUB_MASTER )
  15967. {
  15968. if ( iSubMasterCount == 0 )
  15969. {
  15970. GDGuildReqAssignStatus(aIndex, aRecv->btType, aRecv->szTagetName, aRecv->btGuildStatus);
  15971. return;
  15972. }
  15973.  
  15974. pMsg.btResult = GUILD_ANS_NOTEXIST_EXTRA_STATUS;
  15975. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15976. return;
  15977. }
  15978. else if ( aRecv->btGuildStatus == G_BATTLE_MASTER )
  15979. {
  15980. if ( iBattleMasterCount < ((lpObj->Level / 200 ) +1) )
  15981. {
  15982. GDGuildReqAssignStatus(aIndex, aRecv->btType, aRecv->szTagetName, aRecv->btGuildStatus);
  15983. return;
  15984. }
  15985.  
  15986. pMsg.btResult = GUILD_ANS_NOTEXIST_EXTRA_STATUS;
  15987. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  15988. return;
  15989. }
  15990. else if ( aRecv->btGuildStatus == G_PERSON )
  15991. {
  15992. GDGuildReqAssignStatus(aIndex, aRecv->btType, aRecv->szTagetName, aRecv->btGuildStatus);
  15993. return;
  15994. }
  15995. else
  15996. {
  15997. return;
  15998. }
  15999. }
  16000.  
  16001. if ( aRecv->btType == 3 )
  16002. {
  16003. GDGuildReqAssignStatus(aIndex, aRecv->btType, aRecv->szTagetName, aRecv->btGuildStatus);
  16004. }
  16005. }
  16006.  
  16007.  
  16008.  
  16009.  
  16010. void CGGuildAssignType(PMSG_GUILD_ASSIGN_TYPE_REQ * aRecv, int aIndex)
  16011. {
  16012. if ( !gObjIsConnectedGP(aIndex))
  16013. {
  16014. LogAddTD("error-L2 : Index %s %d", __FILE__, __LINE__);
  16015. return;
  16016. }
  16017.  
  16018. if ( !OBJMAX_RANGE(aIndex))
  16019. return;
  16020.  
  16021. LPOBJ lpObj = &gObj[aIndex];
  16022. PMSG_GUILD_ASSIGN_TYPE_RESULT pMsg={0};
  16023.  
  16024. pMsg.h.set((LPBYTE)&pMsg, 0xE2, sizeof(pMsg));
  16025. pMsg.btGuildType = aRecv->btGuildType;
  16026.  
  16027. if ( lpObj->GuildNumber <= 0 || lpObj->lpGuild == NULL )
  16028. {
  16029. pMsg.btResult = GUILD_ANS_NOTEXIST_GUILD;
  16030. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  16031. return;
  16032. }
  16033.  
  16034. if ( gObj[aIndex].GuildStatus != G_MASTER )
  16035. {
  16036. pMsg.btResult = GUILD_ANS_NOTEXIST_PERMISSION;
  16037. DataSend(aIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  16038. return;
  16039. }
  16040.  
  16041. GDGuildReqAssignType(aIndex, aRecv->btGuildType);
  16042. }
  16043.  
  16044.  
  16045.  
  16046.  
  16047. void CGRelationShipReqJoinBreakOff(PMSG_RELATIONSHIP_JOIN_BREAKOFF_REQ * aRecv, int aIndex)
  16048. {
  16049. if ( g_CastleSiegeSync.GetCastleState() >= 5 && g_CastleSiegeSync.GetCastleState() <= 7 )
  16050. {
  16051. MsgOutput(aIndex, lMsg.Get(MSGGET(6, 196)));
  16052. return;
  16053. }
  16054. if (IT_MAP_RANGE(gObj[aIndex].MapNumber) != FALSE ) //season 2.5 add-on
  16055. {
  16056. MsgOutput(aIndex, lMsg.Get(3399));
  16057. return;
  16058. }
  16059. int iTargetUserIndex = MAKE_NUMBERW(aRecv->btTargetUserIndexH, aRecv->btTargetUserIndexL);
  16060.  
  16061. if ( !OBJMAX_RANGE(aIndex) || !OBJMAX_RANGE(iTargetUserIndex))
  16062. return;
  16063.  
  16064. if ( !PacketCheckTime(&gObj[aIndex]))
  16065. return;
  16066.  
  16067. if ( gObjIsConnected(&gObj[iTargetUserIndex]) == FALSE )
  16068. {
  16069. GCResultSend(aIndex, 0x51, 3);
  16070. return;
  16071. }
  16072.  
  16073. if ( !gObj[aIndex].lpGuild || !gObj[iTargetUserIndex].lpGuild )
  16074. {
  16075. GCResultSend(aIndex, 0x51, 5);
  16076. return;
  16077. }
  16078.  
  16079. if ( gObj[aIndex].GuildStatus != G_MASTER && gObj[iTargetUserIndex].GuildStatus != G_MASTER)
  16080. {
  16081. GCResultSend(aIndex, 0x51, 4);
  16082. return;
  16083. }
  16084.  
  16085. if ( gObj[aIndex].m_IfState.use > 0 )
  16086. {
  16087. GCResultSend(aIndex, 0x51, 6);
  16088. return;
  16089. }
  16090.  
  16091. if ( gObj[iTargetUserIndex].m_IfState.use > 0 )
  16092. {
  16093. GCResultSend(aIndex, 0x51, 6);
  16094. return;
  16095. }
  16096.  
  16097. PMSG_RELATIONSHIP_JOIN_BREAKOFF_ANS ErrMsg={0};
  16098.  
  16099. PHeadSetB((LPBYTE)&ErrMsg, 0xE6, sizeof(ErrMsg));
  16100. ErrMsg.btResult = 0;
  16101. ErrMsg.btRequestType = aRecv->btRequestType;
  16102. ErrMsg.btRelationShipType = aRecv->btRelationShipType;
  16103. ErrMsg.btTargetUserIndexH = aRecv->btTargetUserIndexH;
  16104. ErrMsg.btTargetUserIndexL = aRecv->btTargetUserIndexL;
  16105.  
  16106. LPOBJ lpObj = &gObj[aIndex];
  16107. LPOBJ lpTargetObj = &gObj[iTargetUserIndex];
  16108.  
  16109. if ( lpObj->GuildStatus != G_MASTER || lpTargetObj->GuildStatus != G_MASTER)
  16110. {
  16111. ErrMsg.btResult = GUILD_ANS_NOTEXIST_PERMISSION;
  16112. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16113. return;
  16114. }
  16115.  
  16116. _GUILD_INFO_STRUCT * lpGuildInfo = gObj[aIndex].lpGuild;
  16117. _GUILD_INFO_STRUCT * lpTargetGuildInfo = gObj[iTargetUserIndex].lpGuild;
  16118. BYTE btRelationShip = gObjGetRelationShip(lpObj, lpTargetObj);
  16119.  
  16120. if ( aRecv->btRequestType == 1 )
  16121. {
  16122. if ( aRecv->btRelationShipType == 1 )
  16123. {
  16124. if ( lpTargetGuildInfo->Count < MIN_GUILD_COUNT_FOR_CS )
  16125. {
  16126. ErrMsg.btResult = GUILD_ANS_CANNOT_BE_UNION_MASTER;
  16127. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16128. return;
  16129. }
  16130.  
  16131. if ( lpTargetGuildInfo->iGuildUnion != 0 && lpTargetGuildInfo->iGuildUnion == lpTargetGuildInfo->Number ) // #error
  16132. {
  16133. if ( UnionManager.GetGuildRelationShipCount(lpTargetGuildInfo->iGuildUnion, 1) >= MAX_UNION_MEMBER )
  16134. {
  16135. ErrMsg.btResult = GUILD_ANS_EXCEED_MAX_UNION_MEMBER;
  16136. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16137. return;
  16138. }
  16139. }
  16140.  
  16141. char szCastleOwnerGuildName[MAX_GUILD_LEN+1]={0};
  16142. memcpy(szCastleOwnerGuildName, g_CastleSiegeSync.GetCastleOwnerGuild(), MAX_GUILD_LEN);
  16143.  
  16144. if ( !strcmp(lpGuildInfo->Name, szCastleOwnerGuildName))
  16145. {
  16146. ErrMsg.btResult = GUILD_ANS_EXIST_UNION;
  16147. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16148. return;
  16149. }
  16150.  
  16151. if ( lpGuildInfo->iGuildUnion )
  16152. {
  16153. ErrMsg.btResult = GUILD_ANS_EXIST_UNION;
  16154. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16155. return;
  16156. }
  16157.  
  16158. if ( btRelationShip == 2 )
  16159. {
  16160. ErrMsg.btResult = GUILD_ANS_EXIST_RELATIONSHIP_RIVAL;
  16161. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16162. return;
  16163. }
  16164.  
  16165. if ( lpTargetGuildInfo->iGuildUnion && lpTargetGuildInfo->Number != lpTargetGuildInfo->iGuildUnion ) // #error???
  16166. {
  16167. ErrMsg.btResult = GUIDL_ANS_NOT_UNION_MASTER;
  16168. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16169. return;
  16170. }
  16171. }
  16172. else if ( aRecv->btRelationShipType == 2 )
  16173. {
  16174. if ( lpGuildInfo->iGuildRival || lpTargetGuildInfo->iGuildRival )
  16175. {
  16176. ErrMsg.btResult = GUILD_ANS_EXIST_RIVAL;
  16177. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16178. return;
  16179. }
  16180.  
  16181. if ( btRelationShip == 1 )
  16182. {
  16183. ErrMsg.btResult = GUILD_ANS_EXIST_RELATIONSHIP_UNION;
  16184. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16185. return;
  16186. }
  16187. }
  16188. }
  16189. else if ( aRecv->btRequestType == 2 )
  16190. {
  16191. if ( aRecv->btRelationShipType == 1 )
  16192. {
  16193. if ( lpGuildInfo->iGuildUnion == 0 )
  16194. {
  16195. ErrMsg.btResult = GUILD_ANS_NOTEXIST_UNION;
  16196. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16197. return;
  16198. }
  16199. }
  16200. else if ( aRecv->btRelationShipType == 2 )
  16201. {
  16202. if ( !lpGuildInfo->iGuildRival || !lpTargetGuildInfo->iGuildRival )
  16203. {
  16204. ErrMsg.btResult = GUILD_ANS_NOTEXIST_UNION;
  16205. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16206. return;
  16207. }
  16208.  
  16209. if ( lpGuildInfo->iGuildRival != lpTargetGuildInfo->Number || lpGuildInfo->Number != lpTargetGuildInfo->iGuildRival )
  16210. {
  16211. ErrMsg.btResult = GUILD_ANS_NOT_GUILD_RIVAL;
  16212. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16213. return;
  16214. }
  16215. }
  16216. }
  16217.  
  16218. if ( aRecv->btRequestType == 2 )
  16219. {
  16220. if ( aRecv->btRelationShipType == 1 )
  16221. {
  16222. GDUnionBreakOff(aIndex, lpGuildInfo->iGuildUnion);
  16223. return;
  16224. }
  16225. }
  16226.  
  16227. lpObj->m_IfState.use = 1;
  16228. lpObj->m_IfState.type = 14;
  16229. lpObj->m_IfState.state = 0;
  16230. lpObj->m_InterfaceTime = GetTickCount();
  16231.  
  16232. lpTargetObj->m_IfState.use = 1;
  16233. lpTargetObj->m_IfState.type = 14;
  16234. lpTargetObj->m_IfState.state = 0;
  16235. lpTargetObj->m_InterfaceTime = GetTickCount();
  16236.  
  16237. PMSG_RELATIONSHIP_JOIN_BREAKOFF_REQ pMsg={0};
  16238.  
  16239. PHeadSetB((LPBYTE)&pMsg, 0xE5, sizeof(pMsg));
  16240. pMsg.btTargetUserIndexL = SET_NUMBERL(aIndex);
  16241. pMsg.btTargetUserIndexH = SET_NUMBERH(aIndex);
  16242. pMsg.btRequestType = aRecv->btRequestType;
  16243. pMsg.btRelationShipType = aRecv->btRelationShipType;
  16244.  
  16245. DataSend(iTargetUserIndex, (LPBYTE)&pMsg, pMsg.h.size);
  16246. }
  16247.  
  16248.  
  16249.  
  16250.  
  16251. void CGRelationShipAnsJoinBreakOff(PMSG_RELATIONSHIP_JOIN_BREAKOFF_ANS * aRecv, int aIndex)
  16252. {
  16253. int iTargetUserIndex = MAKE_NUMBERW(aRecv->btTargetUserIndexH, aRecv->btTargetUserIndexL);
  16254.  
  16255. if ( !OBJMAX_RANGE(aIndex) || !OBJMAX_RANGE(iTargetUserIndex))
  16256. return;
  16257.  
  16258. if ( !PacketCheckTime(&gObj[aIndex]))
  16259. return;
  16260.  
  16261. if ( gObjIsConnected(&gObj[iTargetUserIndex]) == FALSE )
  16262. {
  16263. GCResultSend(aIndex, 0x51, 3);
  16264. return;
  16265. }
  16266.  
  16267. if ( aRecv->btResult == 1 )
  16268. {
  16269. if ( aRecv->btRequestType == 1 )
  16270. {
  16271. GDRelationShipReqJoin(iTargetUserIndex, aIndex, aRecv->btRelationShipType);
  16272. }
  16273. else if ( aRecv->btRequestType == 2 )
  16274. {
  16275. GDRelationShipReqBreakOff(aIndex, iTargetUserIndex, aRecv->btRelationShipType);
  16276. }
  16277. }
  16278. else
  16279. {
  16280. PMSG_RELATIONSHIP_JOIN_BREAKOFF_ANS ErrMsg ={0};
  16281.  
  16282. PHeadSetB((LPBYTE)&ErrMsg, 0xE6, sizeof(ErrMsg));
  16283. ErrMsg.btResult = 0;
  16284. ErrMsg.btRequestType = aRecv->btRequestType;
  16285. ErrMsg.btRelationShipType = aRecv->btRelationShipType;
  16286. ErrMsg.btTargetUserIndexH = aRecv->btTargetUserIndexH;
  16287. ErrMsg.btTargetUserIndexL = aRecv->btTargetUserIndexL;
  16288. ErrMsg.btResult = GUILD_ANS_CANCLE_REQUEST;
  16289.  
  16290. DataSend(iTargetUserIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16291. }
  16292.  
  16293. if ( gObj[aIndex].m_IfState.use )
  16294. {
  16295. if ( gObj[aIndex].m_IfState.type == 14 )
  16296. {
  16297. gObj[aIndex].m_IfState.use = 0;
  16298. }
  16299. }
  16300.  
  16301. if ( gObj[iTargetUserIndex].m_IfState.use )
  16302. {
  16303. if ( gObj[iTargetUserIndex].m_IfState.type == 14 )
  16304. {
  16305. gObj[iTargetUserIndex].m_IfState.use = 0;
  16306. }
  16307. }
  16308. }
  16309.  
  16310.  
  16311.  
  16312.  
  16313. void CGUnionList(PMSG_UNIONLIST_REQ * aRecv, int aIndex)
  16314. {
  16315. if ( !OBJMAX_RANGE(aIndex))
  16316. return;
  16317.  
  16318. if ( !PacketCheckTime(&gObj[aIndex]))
  16319. return;
  16320.  
  16321. LPOBJ lpObj = &gObj[aIndex];
  16322.  
  16323. if ( lpObj == NULL )
  16324. {
  16325. return;
  16326. }
  16327.  
  16328. if ( gObjIsConnected(&gObj[aIndex]) == FALSE )
  16329. {
  16330. GCResultSend(aIndex, 0x51, 3);
  16331. return;
  16332. }
  16333.  
  16334. if ( lpObj->lpGuild == NULL )
  16335. {
  16336. GCResultSend(aIndex, 0x51, 3);
  16337. return;
  16338. }
  16339.  
  16340. if ( lpObj->lpGuild->iGuildUnion == 0 )
  16341. {
  16342. GCResultSend(aIndex, 0x51, 3);
  16343. return;
  16344. }
  16345.  
  16346. GDUnionListSend(aIndex, lpObj->lpGuild->iGuildUnion);
  16347.  
  16348. }
  16349.  
  16350.  
  16351.  
  16352. void CGRelationShipReqKickOutUnionMember(PMSG_KICKOUT_UNIONMEMBER_REQ* aRecv, int aIndex)
  16353. {
  16354. if ( !OBJMAX_RANGE(aIndex))
  16355. return;
  16356.  
  16357. if ( ::PacketCheckTime(&gObj[aIndex]) == FALSE )
  16358. return;
  16359.  
  16360. LPOBJ lpObj = &gObj[aIndex];
  16361.  
  16362. if ( lpObj == NULL )
  16363. return;
  16364.  
  16365. if ( gObjIsConnected(&gObj[aIndex]) == FALSE )
  16366. {
  16367. GCResultSend(aIndex, 0x51, 3);
  16368. MsgOutput(aIndex, "¡ Terminated User.");
  16369. return;
  16370. }
  16371.  
  16372. if ( lpObj->lpGuild == NULL )
  16373. {
  16374. GCResultSend(aIndex, 0x51, 3);
  16375. MsgOutput(aIndex, "¡ Terminated Guild.");
  16376. return;
  16377. }
  16378.  
  16379. PMSG_RELATIONSHIP_JOIN_BREAKOFF_ANS ErrMsg = {0};
  16380.  
  16381. PHeadSetB((LPBYTE)&ErrMsg, 0xE6, sizeof(ErrMsg));
  16382. ErrMsg.btResult = 0;
  16383. ErrMsg.btRequestType = 2;
  16384. ErrMsg.btRelationShipType = 1;
  16385. ErrMsg.btTargetUserIndexH = 0;
  16386. ErrMsg.btTargetUserIndexL = 0;
  16387.  
  16388.  
  16389. if ( lpObj->lpGuild->iGuildUnion == 0 )
  16390. {
  16391. ErrMsg.btResult = GUILD_ANS_NOTEXIST_UNION;
  16392. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16393.  
  16394. return;
  16395. }
  16396.  
  16397. if ( lpObj->GuildStatus != GUILD_MASTER || lpObj->lpGuild->Number != lpObj->lpGuild->iGuildUnion)
  16398. {
  16399. ErrMsg.btResult = GUILD_ANS_NOTEXIST_PERMISSION;
  16400. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16401.  
  16402. return;
  16403. }
  16404.  
  16405. char szUnionMemberGuildName[MAX_GUILD_LEN+1] = {0};
  16406. memcpy(szUnionMemberGuildName, aRecv->szTargetGuildName, MAX_GUILD_LEN);
  16407.  
  16408. if ( !strcmp(lpObj->lpGuild->Name, szUnionMemberGuildName))
  16409. {
  16410. ErrMsg.btResult = GUILD_ANS_NOTEXIST_PERMISSION;
  16411. DataSend(aIndex, (LPBYTE)&ErrMsg, ErrMsg.h.size);
  16412.  
  16413. return;
  16414. }
  16415.  
  16416. GDRelationShipReqKickOutUnionMember(aIndex, szUnionMemberGuildName);
  16417. }
  16418.  
  16419.  
  16420.  
  16421.  
  16422. void CGReqMapSvrAuth(PMSG_REQ_MAPSERVERAUTH * lpMsg, int iIndex)
  16423. {
  16424. if ( lpMsg->btCliVersion[0] != szClientVersion[0] ||
  16425. lpMsg->btCliVersion[1] != szClientVersion[1] ||
  16426. lpMsg->btCliVersion[2] != szClientVersion[2] ||
  16427. lpMsg->btCliVersion[3] != szClientVersion[3] ||
  16428. lpMsg->btCliVersion[4] != szClientVersion[4] )
  16429. {
  16430. GCAnsMapSvrAuth(iIndex, 6);
  16431. CloseClient(iIndex);
  16432.  
  16433. return;
  16434. }
  16435.  
  16436. BYTE btSerial[17];
  16437.  
  16438. btSerial[16]=0;
  16439. memcpy(btSerial, lpMsg->btCliSerial, sizeof(lpMsg->btCliSerial));
  16440. char id[MAX_ACCOUNT_LEN+1];
  16441. id[MAX_ACCOUNT_LEN] = 0;
  16442. memcpy(id, lpMsg->szAccountID, MAX_ACCOUNT_LEN);
  16443. BuxConvert(id, MAX_ACCOUNT_LEN);
  16444.  
  16445. if ( strcmp((char*)btSerial, szGameServerExeSerial) )
  16446. {
  16447. LogAddC(2, "error-L1: Serial error [%s] [%s]", id, btSerial);
  16448. GCAnsMapSvrAuth(iIndex, 6);
  16449. CloseClient(iIndex);
  16450.  
  16451. return;
  16452. }
  16453.  
  16454. if ( bCanConnectMember == TRUE )
  16455. {
  16456. if ( ConMember.IsMember(id) == FALSE )
  16457. {
  16458. GCAnsMapSvrAuth(iIndex, 2);
  16459.  
  16460. return;
  16461. }
  16462. }
  16463.  
  16464. LPOBJ lpObj = &gObj[iIndex];
  16465.  
  16466. if ( PacketCheckTime(lpObj) == FALSE )
  16467. {
  16468. LogAdd(lMsg.Get(MSGGET(1, 217)), iIndex, id);
  16469. CloseClient(iIndex);
  16470.  
  16471. return;
  16472. }
  16473.  
  16474. if ( gObj[iIndex].Connected != PLAYER_CONNECTED )
  16475. {
  16476. LogAdd(lMsg.Get(MSGGET(1, 218)), iIndex, id);
  16477. CloseClient(iIndex);
  16478.  
  16479. return;
  16480. }
  16481.  
  16482. if ( gObj[iIndex].LoginMsgSnd != 0 )
  16483. {
  16484. if ( gObj[iIndex].LoginMsgSnd == 1 )
  16485. {
  16486. LogAdd(lMsg.Get(MSGGET(1, 219)), iIndex, id, gObj[iIndex].Ip_addr);
  16487. }
  16488. else
  16489. {
  16490. LogAdd("error : %d %s %d", gObj[iIndex].LoginMsgSnd, __FILE__, __LINE__);
  16491. }
  16492.  
  16493. return;
  16494. }
  16495.  
  16496. gObj[iIndex].CheckTick = lpMsg->iTickCount;
  16497. gObj[iIndex].CheckTick2 = GetTickCount();
  16498. gObj[iIndex].ConnectCheckTime = GetTickCount();
  16499. gObj[iIndex].CheckSpeedHack = true;
  16500. gObj[iIndex].ConnectCheckTime = GetTickCount();
  16501. gObj[iIndex].LoginMsgSnd = 1;
  16502. gObj[iIndex].LoginMsgCount++;
  16503. gObj[iIndex].AccountID[MAX_ACCOUNT_LEN] = 0;
  16504. memcpy(gObj[iIndex].AccountID, id, MAX_ACCOUNT_LEN);
  16505. memset(gObj[iIndex].Name, 0, MAX_ACCOUNT_LEN);
  16506. gObj[iIndex].m_cAccountItemBlock = 0;
  16507. GJReqMapSvrAuth(iIndex, gObj[iIndex].AccountID, lpMsg->szCharName,
  16508. lpMsg->iJoinAuthCode1, lpMsg->iJoinAuthCode2,
  16509. lpMsg->iJoinAuthCode3, lpMsg->iJoinAuthCode4);
  16510.  
  16511. LogAddTD("[MapServerMng] Map Server Join Send : [%s][%s](%d)",
  16512. gObj[iIndex].AccountID, gObj[iIndex].Name, iIndex);
  16513.  
  16514.  
  16515. }
  16516.  
  16517.  
  16518. struct PMSG_ANS_MAPSERVERAUTH
  16519. {
  16520. PBMSG_HEAD2 h; // C1:B1:01
  16521. BYTE iResult; // 4
  16522. };
  16523.  
  16524.  
  16525. void GCAnsMapSvrAuth(int iIndex, int iResult)
  16526. {
  16527. if ( !OBJMAX_RANGE(iIndex) )
  16528. {
  16529. LogAddC(2,"[MapServerMng] Packet Error JG [0x7B] - Index out of bound : %d",iIndex);
  16530. return;
  16531. }
  16532.  
  16533. PMSG_ANS_MAPSERVERAUTH pMsgResult;
  16534.  
  16535. PHeadSubSetB((LPBYTE)&pMsgResult, 0xB1, 0x01, sizeof(pMsgResult));
  16536. pMsgResult.iResult = iResult;
  16537.  
  16538. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16539. }
  16540.  
  16541.  
  16542.  
  16543. void CGReqCastleSiegeState(PMSG_REQ_CASTLESIEGESTATE * lpMsg, int iIndex)
  16544. {
  16545. GS_GDReqOwnerGuildMaster(g_MapServerManager.GetMapSvrGroup(), iIndex);
  16546. }
  16547.  
  16548.  
  16549.  
  16550. struct PMSG_ANS_CASTLESIEGESTATE
  16551. {
  16552. /*<thisrel this+0x0>*/ /*|0x4|*/ PBMSG_HEAD2 h;
  16553. /*<thisrel this+0x4>*/ /*|0x1|*/ BYTE btResult;
  16554. /*<thisrel this+0x5>*/ /*|0x1|*/ char cCastleSiegeState;
  16555. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btStartYearH;
  16556. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btStartYearL;
  16557. /*<thisrel this+0x8>*/ /*|0x1|*/ unsigned char btStartMonth;
  16558. /*<thisrel this+0x9>*/ /*|0x1|*/ unsigned char btStartDay;
  16559. /*<thisrel this+0xa>*/ /*|0x1|*/ unsigned char btStartHour;
  16560. /*<thisrel this+0xb>*/ /*|0x1|*/ unsigned char btStartMinute;
  16561. /*<thisrel this+0xc>*/ /*|0x1|*/ unsigned char btEndYearH;
  16562. /*<thisrel this+0xd>*/ /*|0x1|*/ unsigned char btEndYearL;
  16563. /*<thisrel this+0xe>*/ /*|0x1|*/ unsigned char btEndMonth;
  16564. /*<thisrel this+0xf>*/ /*|0x1|*/ unsigned char btEndDay;
  16565. /*<thisrel this+0x10>*/ /*|0x1|*/ unsigned char btEndHour;
  16566. /*<thisrel this+0x11>*/ /*|0x1|*/ unsigned char btEndMinute;
  16567. /*<thisrel this+0x12>*/ /*|0x1|*/ unsigned char btSiegeStartYearH;
  16568. /*<thisrel this+0x13>*/ /*|0x1|*/ unsigned char btSiegeStartYearL;
  16569. /*<thisrel this+0x14>*/ /*|0x1|*/ unsigned char btSiegeStartMonth;
  16570. /*<thisrel this+0x15>*/ /*|0x1|*/ unsigned char btSiegeStartDay;
  16571. /*<thisrel this+0x16>*/ /*|0x1|*/ unsigned char btSiegeStartHour;
  16572. /*<thisrel this+0x17>*/ /*|0x1|*/ unsigned char btSiegeStartMinute;
  16573. /*<thisrel this+0x18>*/ /*|0x8|*/ char cOwnerGuild[8];
  16574. /*<thisrel this+0x20>*/ /*|0xa|*/ char cOwnerGuildMaster[10];
  16575. /*<thisrel this+0x2a>*/ /*|0x1|*/ char btStateLeftSec1;
  16576. /*<thisrel this+0x2b>*/ /*|0x1|*/ char btStateLeftSec2;
  16577. /*<thisrel this+0x2c>*/ /*|0x1|*/ char btStateLeftSec3;
  16578. /*<thisrel this+0x2d>*/ /*|0x1|*/ char btStateLeftSec4;
  16579. };
  16580. void GCAnsCastleSiegeState(int iIndex, int iResult, LPSTR lpszGuildName, LPSTR lpszGuildMaster)
  16581. {
  16582. if ( lpszGuildName == NULL || lpszGuildMaster == NULL )
  16583. return;
  16584.  
  16585. PMSG_ANS_CASTLESIEGESTATE pMsgResult;
  16586.  
  16587. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x00, sizeof(pMsgResult));
  16588. pMsgResult.btResult = iResult;
  16589. memcpy(pMsgResult.cOwnerGuild, lpszGuildName, sizeof(pMsgResult.cOwnerGuild));
  16590. memcpy(pMsgResult.cOwnerGuildMaster, lpszGuildMaster, sizeof(pMsgResult.cOwnerGuildMaster));
  16591. SYSTEMTIME tmStateStartDate={0};
  16592. SYSTEMTIME tmStateEndDate={0};
  16593. SYSTEMTIME tmSiegeStartDate={0};
  16594. int iCastleState = g_CastleSiege.GetCastleState();;
  16595. //BOOL bRETVAL = g_CastleSiege.GetCastleStateTerm(tmStateStartDate, tmStateEndDate);
  16596. int bRETVAL = g_CastleSiege.GetCastleStateTerm(&tmStateStartDate, &tmStateEndDate);
  16597. tmSiegeStartDate = g_CastleSiege.GetCastleLeftSiegeDate();
  16598.  
  16599. if ( bRETVAL == FALSE ) iCastleState = CASTLESIEGE_STATE_NONE;
  16600.  
  16601. int iStateLeftSec = g_CastleSiege.GetCurRemainSec();
  16602.  
  16603. pMsgResult.cCastleSiegeState = iCastleState;
  16604. pMsgResult.btStartYearH = SET_NUMBERH(tmStateStartDate.wYear);
  16605. pMsgResult.btStartYearL = SET_NUMBERL(tmStateStartDate.wYear);
  16606. pMsgResult.btStartMonth = tmStateStartDate.wMonth;
  16607. pMsgResult.btStartDay = tmStateStartDate.wDay;
  16608. pMsgResult.btStartHour = tmStateStartDate.wHour;
  16609. pMsgResult.btStartMinute = tmStateStartDate.wMinute;
  16610.  
  16611. pMsgResult.btEndYearH = SET_NUMBERH(tmStateEndDate.wYear);
  16612. pMsgResult.btEndYearL = SET_NUMBERL(tmStateEndDate.wYear);
  16613. pMsgResult.btEndMonth = tmStateEndDate.wMonth;
  16614. pMsgResult.btEndDay = tmStateEndDate.wDay;
  16615. pMsgResult.btEndHour = tmStateEndDate.wHour;
  16616. pMsgResult.btEndMinute = tmStateEndDate.wMinute;
  16617.  
  16618. pMsgResult.btSiegeStartYearH = SET_NUMBERH(tmSiegeStartDate.wYear);
  16619. pMsgResult.btSiegeStartYearL = SET_NUMBERL(tmSiegeStartDate.wYear);
  16620. pMsgResult.btSiegeStartMonth = tmSiegeStartDate.wMonth;
  16621. pMsgResult.btSiegeStartDay = tmSiegeStartDate.wDay;
  16622. pMsgResult.btSiegeStartHour = tmSiegeStartDate.wHour;
  16623. pMsgResult.btSiegeStartMinute = tmSiegeStartDate.wMinute;
  16624.  
  16625. pMsgResult.btStateLeftSec1 = SET_NUMBERH(SET_NUMBERHW(iStateLeftSec));
  16626. pMsgResult.btStateLeftSec2 = SET_NUMBERL(SET_NUMBERHW(iStateLeftSec));
  16627. pMsgResult.btStateLeftSec3 = SET_NUMBERH(SET_NUMBERLW(iStateLeftSec));
  16628. pMsgResult.btStateLeftSec4 = SET_NUMBERL(SET_NUMBERLW(iStateLeftSec));
  16629.  
  16630. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16631. }
  16632.  
  16633.  
  16634.  
  16635.  
  16636. void CGReqRegCastleSiege(PMSG_REQ_REGCASTLESIEGE * lpMsg, int iIndex)
  16637. {
  16638. if ( g_CastleSiege.GetCastleState() != CASTLESIEGE_STATE_REGSIEGE )
  16639. {
  16640. GCAnsRegCastleSiege(iIndex, 0x07, "");
  16641. return;
  16642. }
  16643.  
  16644. if ( strcmp(gObj[iIndex].GuildName, "") == 0 )
  16645. {
  16646. GCAnsRegCastleSiege(iIndex, 0x06, "");
  16647. return;
  16648. }
  16649.  
  16650. if ( g_CastleSiege.CheckUnionGuildMaster(iIndex) == FALSE )
  16651. {
  16652. GCAnsRegCastleSiege(iIndex, 0x00, "");
  16653. return;
  16654. }
  16655.  
  16656. if ( g_CastleSiege.CheckCastleOwnerMember(iIndex) || g_CastleSiege.CheckCastleOwnerUnionMember(iIndex))
  16657. {
  16658. GCAnsRegCastleSiege(iIndex, 0x03, "");
  16659. return;
  16660. }
  16661.  
  16662. GS_GDReqRegAttackGuild(g_MapServerManager.GetMapSvrGroup(), iIndex);
  16663.  
  16664.  
  16665.  
  16666. }
  16667.  
  16668.  
  16669.  
  16670.  
  16671. struct PMSG_ANS_REGCASTLESIEGE
  16672. {
  16673. PBMSG_HEAD2 h;
  16674. BYTE btResult;
  16675. char szGuildName[8];
  16676. };
  16677. void GCAnsRegCastleSiege(int iIndex, int iResult, LPSTR lpszGuildName)
  16678. {
  16679. if ( lpszGuildName == NULL ) return;
  16680. if ( !CHECK_LIMIT(iIndex, OBJMAX) ) return;
  16681.  
  16682. PMSG_ANS_REGCASTLESIEGE pMsgResult;
  16683.  
  16684. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x01, sizeof(pMsgResult));
  16685. pMsgResult.btResult = iResult;
  16686. memcpy(pMsgResult.szGuildName, lpszGuildName, sizeof(pMsgResult.szGuildName));
  16687.  
  16688. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16689.  
  16690. if ( gObjIsConnected(iIndex) )
  16691. {
  16692. LogAddTD("[CastleSiege] [%s][%s] Registered Castle Siege (GUILD:%s) - Result:%d",
  16693. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName, iResult);
  16694. }
  16695. }
  16696.  
  16697.  
  16698.  
  16699.  
  16700. void CGReqGiveUpCastleSiege(PMSG_REQ_GIVEUPCASTLESIEGE * lpMsg, int iIndex)
  16701. {
  16702. if ( g_CastleSiege.GetCastleState() < CASTLESIEGE_STATE_REGSIEGE ||
  16703. g_CastleSiege.GetCastleState() > CASTLESIEGE_STATE_REGMARK )
  16704. {
  16705. GCAnsGiveUpCastleSiege(iIndex, 0x03, false, 0, "");
  16706. return;
  16707. }
  16708.  
  16709. if ( strcmp(gObj[iIndex].GuildName, "") == 0 ) return;
  16710. if ( g_CastleSiege.CheckUnionGuildMaster(iIndex) == FALSE) return;
  16711.  
  16712. GS_GDReqGuildSetGiveUp(g_MapServerManager.GetMapSvrGroup(), iIndex, lpMsg->btGiveUp);
  16713. }
  16714.  
  16715.  
  16716. struct PMSG_ANS_GIVEUPCASTLESIEGE
  16717. {
  16718. /*<thisrel this+0x0>*/ /*|0x4|*/ PBMSG_HEAD2 h;
  16719. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  16720. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btIsGiveUp;
  16721. /*<thisrel this+0x6>*/ /*|0x8|*/ char szGuildName[8];
  16722. };
  16723.  
  16724. void GCAnsGiveUpCastleSiege(int iIndex, int iResult, BOOL bGiveUp, int iMarkCount, LPSTR lpszGuildName)
  16725. {
  16726. if ( lpszGuildName == NULL ) return;
  16727. if ( !CHECK_LIMIT(iIndex, OBJMAX) ) return;
  16728.  
  16729. PMSG_ANS_GIVEUPCASTLESIEGE pMsgResult;
  16730.  
  16731. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x02, sizeof(pMsgResult));
  16732. pMsgResult.btResult = iResult;
  16733. pMsgResult.btIsGiveUp = bGiveUp;
  16734. memcpy(pMsgResult.szGuildName, lpszGuildName, sizeof(pMsgResult.szGuildName));
  16735.  
  16736. if ( pMsgResult.btResult == 1 )
  16737. {
  16738. if ( iMarkCount > 0 )
  16739. {
  16740. gObj[iIndex].Money += iMarkCount*3000;
  16741. if ( gObj[iIndex].Money > MAX_ZEN ) gObj[iIndex].Money = MAX_ZEN;
  16742.  
  16743. GCMoneySend(iIndex, gObj[iIndex].Money);
  16744. }
  16745. }
  16746.  
  16747. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16748.  
  16749. if ( gObjIsConnected(iIndex) )
  16750. {
  16751. LogAddTD("[CastleSiege] [%s][%s] GiveUp Castle Siege (GUILD:%s) - Result:%d",
  16752. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName, iResult);
  16753. }
  16754. }
  16755.  
  16756.  
  16757.  
  16758.  
  16759. void CGReqGuildRegInfo(PMSG_REQ_GUILDREGINFO * lpMsg, int iIndex)
  16760. {
  16761. if ( lpMsg == NULL ) return;
  16762. if ( strcmp(gObj[iIndex].GuildName, "") == 0 ) return;
  16763.  
  16764. GS_GDReqGuildMarkRegInfo(g_MapServerManager.GetMapSvrGroup(), iIndex);
  16765. }
  16766.  
  16767.  
  16768.  
  16769. struct PMSG_ANS_GUILDREGINFO
  16770. {
  16771. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  16772. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  16773. /*<thisrel this+0x5>*/ /*|0x8|*/ char szGuildName[8];
  16774. /*<thisrel this+0xd>*/ /*|0x1|*/ unsigned char btGuildMark1;
  16775. /*<thisrel this+0xe>*/ /*|0x1|*/ unsigned char btGuildMark2;
  16776. /*<thisrel this+0xf>*/ /*|0x1|*/ unsigned char btGuildMark3;
  16777. /*<thisrel this+0x10>*/ /*|0x1|*/ unsigned char btGuildMark4;
  16778. /*<thisrel this+0x11>*/ /*|0x1|*/ unsigned char btIsGiveUp;
  16779. /*<thisrel this+0x12>*/ /*|0x1|*/ unsigned char btRegRank;
  16780. };
  16781.  
  16782. void GCAnsGuildRegInfo(int iIndex, int iResult, CSP_ANS_GUILDREGINFO * lpMsgResult)
  16783. {
  16784. if ( lpMsgResult == NULL ) return;
  16785. if ( !CHECK_LIMIT(iIndex, OBJMAX) ) return;
  16786.  
  16787. PMSG_ANS_GUILDREGINFO pMsgResult;
  16788.  
  16789. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x03, sizeof(pMsgResult));
  16790. pMsgResult.btResult = iResult;
  16791. pMsgResult.btGuildMark1 = SET_NUMBERH(SET_NUMBERHW(lpMsgResult->iRegMarkCount));
  16792. pMsgResult.btGuildMark2 = SET_NUMBERL(SET_NUMBERHW(lpMsgResult->iRegMarkCount));
  16793. pMsgResult.btGuildMark3 = SET_NUMBERH(SET_NUMBERLW(lpMsgResult->iRegMarkCount));
  16794. pMsgResult.btGuildMark4 = SET_NUMBERL(SET_NUMBERLW(lpMsgResult->iRegMarkCount));
  16795. pMsgResult.btRegRank = lpMsgResult->btRegRank;
  16796. pMsgResult.btIsGiveUp = lpMsgResult->bIsGiveUp;
  16797. memcpy(pMsgResult.szGuildName, lpMsgResult->szGuildName, sizeof(pMsgResult.szGuildName));
  16798.  
  16799. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16800. }
  16801.  
  16802.  
  16803. struct PMSG_ANS_REGGUILDMARK
  16804. {
  16805. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  16806. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  16807. /*<thisrel this+0x5>*/ /*|0x8|*/ char szGuildName[8];
  16808. /*<thisrel this+0xd>*/ /*|0x1|*/ unsigned char btGuildMark1;
  16809. /*<thisrel this+0xe>*/ /*|0x1|*/ unsigned char btGuildMark2;
  16810. /*<thisrel this+0xf>*/ /*|0x1|*/ unsigned char btGuildMark3;
  16811. /*<thisrel this+0x10>*/ /*|0x1|*/ unsigned char btGuildMark4;
  16812. };
  16813.  
  16814. void CGReqRegGuildMark(PMSG_REQ_REGGUILDMARK * lpMsg, int iIndex)
  16815. {
  16816. if ( lpMsg == NULL ) return;
  16817. if ( !CHECK_LIMIT(iIndex, OBJMAX) ) return;
  16818. if ( gObj[iIndex].UseEventServer == TRUE ) return;
  16819.  
  16820. gObj[iIndex].UseEventServer = TRUE;
  16821. if ( g_CastleSiege.GetCastleState() != CASTLESIEGE_STATE_REGMARK )
  16822. {
  16823. gObj[iIndex].UseEventServer = FALSE;
  16824. return;
  16825. }
  16826. if ( strcmp(gObj[iIndex].GuildName, "") == 0 )
  16827. {
  16828. gObj[iIndex].UseEventServer = FALSE;
  16829. return;
  16830. }
  16831.  
  16832. if ( CHECK_LIMIT(lpMsg->btItemPos, (MAIN_INVENTORY_SIZE - INVETORY_WEAR_SIZE)) == 0 )
  16833. {
  16834. PMSG_ANS_REGGUILDMARK pMsgResult={0};
  16835.  
  16836. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x04, sizeof(pMsgResult));
  16837. pMsgResult.btResult = 0x03;
  16838.  
  16839. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16840. gObj[iIndex].UseEventServer = FALSE;
  16841. return;
  16842. }
  16843.  
  16844. int iItemPos = lpMsg->btItemPos + INVETORY_WEAR_SIZE;
  16845. if ( gObj[iIndex].pInventory[iItemPos].IsItem() == FALSE )
  16846. {
  16847. PMSG_ANS_REGGUILDMARK pMsgResult={0};
  16848.  
  16849. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x04, sizeof(pMsgResult));
  16850. pMsgResult.btResult = 0x03;
  16851.  
  16852. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16853. gObj[iIndex].UseEventServer = FALSE;
  16854. return;
  16855. }
  16856.  
  16857. if ( gObj[iIndex].pInventory[iItemPos].m_Type != ITEMGET(14,21) ||
  16858. gObj[iIndex].pInventory[iItemPos].m_Level != 3 ||
  16859. gObj[iIndex].pInventory[iItemPos].m_Durability <= 0.0f )
  16860. {
  16861. PMSG_ANS_REGGUILDMARK pMsgResult={0};
  16862.  
  16863. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x04, sizeof(pMsgResult));
  16864. pMsgResult.btResult = 0x03;
  16865.  
  16866. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16867. gObj[iIndex].UseEventServer = FALSE;
  16868. return;
  16869. }
  16870.  
  16871. GS_GDReqRegGuildMark(g_MapServerManager.GetMapSvrGroup(), iIndex, iItemPos);
  16872. }
  16873.  
  16874.  
  16875.  
  16876.  
  16877. void GCAnsRegGuildMark(int iIndex, int iResult, CSP_ANS_GUILDREGMARK * lpMsgResult)
  16878. {
  16879. if ( lpMsgResult == NULL ) return;
  16880. if ( !CHECK_LIMIT(iIndex, OBJMAX) ) return;
  16881.  
  16882. if ( gObj[iIndex].pInventory[lpMsgResult->iItemPos].IsItem() == FALSE )
  16883. {
  16884. PMSG_ANS_REGGUILDMARK pMsgResult={0};
  16885.  
  16886. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x04, sizeof(pMsgResult));
  16887. pMsgResult.btResult = 0x03;
  16888.  
  16889. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16890. gObj[iIndex].UseEventServer = FALSE;
  16891. return;
  16892. }
  16893.  
  16894. if ( (gObj[iIndex].pInventory[lpMsgResult->iItemPos].m_Type != ITEMGET(14,21) && // #error???
  16895. gObj[iIndex].pInventory[lpMsgResult->iItemPos].m_Level == 3) ||
  16896. gObj[iIndex].pInventory[lpMsgResult->iItemPos].m_Durability <= 0.0f )
  16897. {
  16898. PMSG_ANS_REGGUILDMARK pMsgResult={0};
  16899.  
  16900. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x04, sizeof(pMsgResult));
  16901. pMsgResult.btResult = 0x03;
  16902.  
  16903. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16904. gObj[iIndex].UseEventServer = FALSE;
  16905. return;
  16906. }
  16907.  
  16908. gObj[iIndex].pInventory[lpMsgResult->iItemPos].m_Durability -= 1.0f;
  16909.  
  16910. if ( gObj[iIndex].pInventory[lpMsgResult->iItemPos].m_Durability > 0.0f )
  16911. GCItemDurSend(iIndex, lpMsgResult->iItemPos, gObj[iIndex].pInventory[lpMsgResult->iItemPos].m_Durability, 0);
  16912. else
  16913. {
  16914. gObjInventoryDeleteItem(iIndex, lpMsgResult->iItemPos);
  16915. GCInventoryItemDeleteSend(iIndex, lpMsgResult->iItemPos, 1);
  16916. }
  16917.  
  16918. PMSG_ANS_REGGUILDMARK pMsgResult;
  16919.  
  16920. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x04, sizeof(pMsgResult));
  16921. pMsgResult.btResult = iResult;
  16922. pMsgResult.btGuildMark1 = SET_NUMBERH(SET_NUMBERHW(lpMsgResult->iRegMarkCount));
  16923. pMsgResult.btGuildMark2 = SET_NUMBERL(SET_NUMBERHW(lpMsgResult->iRegMarkCount));
  16924. pMsgResult.btGuildMark3 = SET_NUMBERH(SET_NUMBERLW(lpMsgResult->iRegMarkCount));
  16925. pMsgResult.btGuildMark4 = SET_NUMBERL(SET_NUMBERLW(lpMsgResult->iRegMarkCount));
  16926. memcpy(pMsgResult.szGuildName, lpMsgResult->szGuildName, sizeof(pMsgResult.szGuildName));
  16927.  
  16928. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16929. gObj[iIndex].UseEventServer = FALSE;
  16930. }
  16931.  
  16932.  
  16933.  
  16934.  
  16935. void CGReqNpcBuy(PMSG_REQ_NPCBUY * lpMsg, int iIndex)
  16936. {
  16937. if ( lpMsg == NULL ) return;
  16938. if ( !gObjIsConnected(iIndex) ) return;
  16939. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  16940.  
  16941. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  16942. (gObj[iIndex].GuildStatus != 0x80 && gObj[iIndex].GuildStatus != 0x40 ) )
  16943. {
  16944. LogAddC(2, "[CastleSiege] CGReqNpcBuy() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  16945. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  16946. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex);
  16947. return;
  16948. }
  16949.  
  16950. BYTE bRESULT = FALSE;
  16951. BOOL bRET_VAL = g_CastleSiege.CheckAddDbNPC(iIndex, lpMsg->iNpcNumber, lpMsg->iNpcIndex, bRESULT);
  16952.  
  16953. if ( !bRET_VAL )
  16954. {
  16955. GCAnsNpcBuy(iIndex, bRESULT , lpMsg->iNpcNumber, lpMsg->iNpcIndex);
  16956. LogAddC(2, "[CastleSiege] CGReqNpcBuy() ERROR - CCastleSiege::CheckAddDbNPC() [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  16957. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  16958. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex);
  16959. return;
  16960. }
  16961.  
  16962. LogAddC(2, "[CastleSiege] CGReqNpcBuy() OK - [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  16963. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  16964. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex);
  16965. }
  16966.  
  16967.  
  16968.  
  16969. struct PMSG_ANS_NPCBUY
  16970. {
  16971. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  16972. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  16973. /*<thisrel this+0x8>*/ /*|0x4|*/ int iNpcNumber;
  16974. /*<thisrel this+0xc>*/ /*|0x4|*/ int iNpcIndex;
  16975. };
  16976. void GCAnsNpcBuy(int iIndex, int iResult, int iNpcNumber, int iNpcIndex)
  16977. {
  16978. PMSG_ANS_NPCBUY pMsgResult;
  16979.  
  16980. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x05, sizeof(pMsgResult));
  16981. pMsgResult.btResult = iResult;
  16982. pMsgResult.iNpcNumber = iNpcNumber;
  16983. pMsgResult.iNpcIndex = iNpcIndex;
  16984.  
  16985. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  16986. }
  16987.  
  16988.  
  16989.  
  16990. void CGReqNpcRepair(PMSG_REQ_NPCREPAIR * lpMsg, int iIndex)
  16991. {
  16992. if ( lpMsg == NULL ) return;
  16993. if ( !gObjIsConnected(iIndex)) return;
  16994. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  16995.  
  16996. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  16997. (gObj[iIndex].GuildStatus != 0x80 && gObj[iIndex].GuildStatus != 0x40 ) )
  16998. {
  16999. LogAddC(2, "[CastleSiege] CGReqNpcRepair() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17000. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17001. gObj[iIndex].GuildStatus);
  17002. return;
  17003. }
  17004.  
  17005. _CS_NPC_DATA pNpcData;
  17006. BOOL bRETVAL = g_CastleSiege.GetNpcData(lpMsg->iNpcNumber, lpMsg->iNpcIndex, pNpcData);
  17007. if ( !bRETVAL )
  17008. {
  17009. GCAnsNpcRepair(iIndex, 0, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17010.  
  17011. LogAddC(2, "[CastleSiege] CGReqNpcRepair() ERROR - CL Request Fail [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  17012. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17013. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex);
  17014.  
  17015. return;
  17016. }
  17017.  
  17018. int iNpcIndex = pNpcData.m_iNPC_OBJINDEX;
  17019. if ( !gObjIsConnected(iNpcIndex) )
  17020. {
  17021. GCAnsNpcRepair(iIndex, 0, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17022.  
  17023. LogAddC(2, "[CastleSiege] CGReqNpcRepair() ERROR - Npc Alive Data Mismatch [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  17024. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17025. gObj[iIndex].GuildStatus, pNpcData.m_iNPC_NUM, pNpcData.m_iNPC_INDEX);
  17026.  
  17027. return;
  17028. }
  17029.  
  17030. if ( gObj[iNpcIndex].Live == 0 )
  17031. {
  17032. GCAnsNpcRepair(iIndex, 0, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17033.  
  17034. LogAddC(2, "[CastleSiege] CGReqNpcRepair() ERROR - Npc Alive Data Mismatch [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  17035. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17036. gObj[iIndex].GuildStatus, pNpcData.m_iNPC_NUM, pNpcData.m_iNPC_INDEX);
  17037.  
  17038. return;
  17039. }
  17040.  
  17041. if ( gObj[iNpcIndex].MaxLife == gObj[iNpcIndex].Life ||
  17042. gObj[iNpcIndex].MaxLife < gObj[iNpcIndex].Life )
  17043. {
  17044. gObj[iNpcIndex].Life = gObj[iNpcIndex].MaxLife;
  17045. GCAnsNpcRepair(iIndex, 0, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17046. return;
  17047. }
  17048.  
  17049. int iRepairCost = 0;
  17050.  
  17051. switch ( lpMsg->iNpcNumber )
  17052. {
  17053. case 277: iRepairCost = (gObj[iNpcIndex].MaxLife - gObj[iNpcIndex].Life) * 5.0f + (gObj[iNpcIndex].m_btCsNpcDfLevel * 1000000); break;
  17054. case 283: iRepairCost = (gObj[iNpcIndex].MaxLife - gObj[iNpcIndex].Life) * 3.0f + ((gObj[iNpcIndex].m_btCsNpcDfLevel + gObj[iNpcIndex].m_btCsNpcRgLevel) * 1000000); break;
  17055. default:
  17056. GCAnsNpcRepair(iIndex, 0, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17057. return;
  17058. }
  17059.  
  17060. if ( gObj[iIndex].Money < iRepairCost )
  17061. {
  17062. GCAnsNpcRepair(iIndex, 3, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17063.  
  17064. LogAddC(2, "[CastleSiege] CGReqNpcRepair() ERROR - Money isn't enough [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  17065. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17066. gObj[iIndex].GuildStatus, pNpcData.m_iNPC_NUM, pNpcData.m_iNPC_INDEX);
  17067.  
  17068. return;
  17069. }
  17070.  
  17071. LogAddC(2, "[CastleSiege] CGReqNpcRepair() OK - [%s][%s], Guild:(%s)(%d), Npc:(CLS:%d, IDX:%d)",
  17072. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17073. gObj[iIndex].GuildStatus, pNpcData.m_iNPC_NUM, pNpcData.m_iNPC_INDEX);
  17074.  
  17075. GS_GDReqCastleNpcRepair(g_MapServerManager.GetMapSvrGroup(), iIndex, lpMsg->iNpcNumber, lpMsg->iNpcIndex, iRepairCost);
  17076. }
  17077.  
  17078.  
  17079. struct PMSG_ANS_NPCREPAIR
  17080. {
  17081. struct PBMSG_HEAD2 h;
  17082. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17083. /*<thisrel this+0x8>*/ /*|0x4|*/ int iNpcNumber;
  17084. /*<thisrel this+0xc>*/ /*|0x4|*/ int iNpcIndex;
  17085. /*<thisrel this+0x10>*/ /*|0x4|*/ int iNpcHP;
  17086. /*<thisrel this+0x14>*/ /*|0x4|*/ int iNpcMaxHP;
  17087. };
  17088.  
  17089. void GCAnsNpcRepair(int iIndex, int iResult, int iNpcNumber, int iNpcIndex, int iNpcHP, int iNpcMaxHP)
  17090. {
  17091. PMSG_ANS_NPCREPAIR pMsgResult;
  17092.  
  17093. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x06, sizeof(pMsgResult));
  17094. pMsgResult.btResult = iResult;
  17095. pMsgResult.iNpcNumber = iNpcNumber;
  17096. pMsgResult.iNpcIndex = iNpcIndex;
  17097. pMsgResult.iNpcHP = iNpcHP;
  17098. pMsgResult.iNpcMaxHP = iNpcMaxHP;
  17099.  
  17100. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17101. }
  17102.  
  17103.  
  17104.  
  17105.  
  17106. void CGReqNpcUpgrade(PMSG_REQ_NPCUPGRADE * lpMsg, int iIndex)
  17107. {
  17108. if ( lpMsg == NULL ) return;
  17109. if ( !gObjIsConnected(iIndex)) return;
  17110.  
  17111. int iNEED_GEMOFDEFEND=0;
  17112. int iNEED_MONEY=0;
  17113. int iCUR_UPLVL=0;
  17114. int iNXT_UPLVL=0;
  17115. int iNXT_UPVALUE=0;
  17116. int bENABLE_UPGRADE=0;
  17117.  
  17118. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  17119.  
  17120.  
  17121.  
  17122. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  17123. (gObj[iIndex].GuildStatus != 0x80 ) )
  17124. {
  17125. LogAddTD("[CastleSiege] CGReqNpcUpgrade() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17126. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17127. gObj[iIndex].GuildStatus);
  17128. return;
  17129. }
  17130.  
  17131. switch ( lpMsg->iNpcNumber )
  17132. {
  17133. case 277:
  17134. {
  17135. _CS_NPC_DATA pNpcData;
  17136. BOOL bRETVAL = g_CastleSiege.GetNpcData(lpMsg->iNpcNumber, lpMsg->iNpcIndex, pNpcData);
  17137. if ( bRETVAL )
  17138. {
  17139. switch ( lpMsg->iNpcUpType )
  17140. {
  17141. case 1:
  17142. iCUR_UPLVL = pNpcData.m_iNPC_DF_LEVEL;
  17143. iNXT_UPLVL = lpMsg->iNpcUpValue;
  17144.  
  17145. if ( iNXT_UPLVL >= 1 && iNXT_UPLVL <= 3 && iNXT_UPLVL == (iCUR_UPLVL+1) )
  17146. {
  17147. bENABLE_UPGRADE = TRUE;
  17148. iNXT_UPVALUE = iNXT_UPLVL;
  17149. iNEED_GEMOFDEFEND = g_iNpcUpDfLevel_CGATE[iNXT_UPLVL-1][1];
  17150. iNEED_MONEY = g_iNpcUpDfLevel_CGATE[iNXT_UPLVL-1][2];
  17151. }
  17152. break;
  17153. case 3:
  17154. {
  17155. iCUR_UPLVL = 0;
  17156. for ( int i=0; i<3;i++ )
  17157. {
  17158. if ( pNpcData.m_iNPC_MAXHP >= g_iNpcUpMaxHP_CGATE[i][0] )
  17159. {
  17160. iCUR_UPLVL = i+1;
  17161. }
  17162. }
  17163. iNXT_UPLVL = 0;
  17164. for (int i = 0; i < 3; i++)
  17165. {
  17166. if ( lpMsg->iNpcUpValue >= g_iNpcUpMaxHP_CGATE[i][0] )
  17167. {
  17168. iNXT_UPLVL = i+1;
  17169. }
  17170. }
  17171.  
  17172. if ( iNXT_UPLVL >= 1 && iNXT_UPLVL <= 3 && iNXT_UPLVL == (iCUR_UPLVL+1) )
  17173. {
  17174. bENABLE_UPGRADE = TRUE;
  17175. iNXT_UPVALUE = g_iNpcUpDfLevel_CGATE[iNXT_UPLVL-1][0];
  17176. iNEED_GEMOFDEFEND = g_iNpcUpDfLevel_CGATE[iNXT_UPLVL-1][1];
  17177. iNEED_MONEY = g_iNpcUpDfLevel_CGATE[iNXT_UPLVL-1][2];
  17178. }
  17179. }
  17180. break;
  17181. default:
  17182. GCAnsNpcUpgrade(iIndex, 0x05, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17183. return;
  17184. }
  17185. }
  17186. else
  17187. {
  17188. GCAnsNpcUpgrade(iIndex, 0x07, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17189. return;
  17190. }
  17191. break;
  17192. }
  17193. case 283:
  17194. {
  17195. _CS_NPC_DATA pNpcData;
  17196. BOOL bRETVAL = g_CastleSiege.GetNpcData(lpMsg->iNpcNumber, lpMsg->iNpcIndex, pNpcData);
  17197. if ( bRETVAL )
  17198. {
  17199. switch ( lpMsg->iNpcUpType )
  17200. {
  17201. case 1:
  17202. iCUR_UPLVL = pNpcData.m_iNPC_DF_LEVEL;
  17203. iNXT_UPLVL = lpMsg->iNpcUpValue;
  17204.  
  17205. if ( iNXT_UPLVL >= 1 && iNXT_UPLVL <= 3 && iNXT_UPLVL == (iCUR_UPLVL+1) )
  17206. {
  17207. bENABLE_UPGRADE = TRUE;
  17208. iNXT_UPVALUE = iNXT_UPLVL;
  17209. iNEED_GEMOFDEFEND = g_iNpcUpDfLevel_CSTATUE[iNXT_UPLVL-1][1];
  17210. iNEED_MONEY = g_iNpcUpDfLevel_CSTATUE[iNXT_UPLVL-1][2];
  17211. }
  17212. break;
  17213. case 2:
  17214. iCUR_UPLVL = pNpcData.m_iNPC_RG_LEVEL;
  17215. iNXT_UPLVL = lpMsg->iNpcUpValue;
  17216.  
  17217. if ( iNXT_UPLVL >= 1 && iNXT_UPLVL <= 3 && iNXT_UPLVL == (iCUR_UPLVL+1) )
  17218. {
  17219. bENABLE_UPGRADE = TRUE;
  17220. iNXT_UPVALUE = iNXT_UPLVL;
  17221. iNEED_GEMOFDEFEND = g_iNpcUpRgLevel_CSTATUE[iNXT_UPLVL-1][1];
  17222. iNEED_MONEY = g_iNpcUpRgLevel_CSTATUE[iNXT_UPLVL-1][2];
  17223. }
  17224. break;
  17225. case 3:
  17226. {
  17227. iCUR_UPLVL = 0;
  17228. for ( int i=0; i<3;i++ )
  17229. {
  17230. if ( pNpcData.m_iNPC_MAXHP >= g_iNpcUpMaxHP_CSTATUE[i][0] )
  17231. {
  17232. iCUR_UPLVL = i+1;
  17233. }
  17234. }
  17235. iNXT_UPLVL = 0;
  17236. for ( int i=0; i<3;i++ )
  17237. {
  17238. if ( lpMsg->iNpcUpValue >= g_iNpcUpMaxHP_CSTATUE[i][0] )
  17239. {
  17240. iNXT_UPLVL = i+1;
  17241. }
  17242. }
  17243.  
  17244. if ( iNXT_UPLVL >= 1 && iNXT_UPLVL <= 3 && iNXT_UPLVL == (iCUR_UPLVL+1) )
  17245. {
  17246. bENABLE_UPGRADE = TRUE;
  17247. iNXT_UPVALUE = g_iNpcUpDfLevel_CSTATUE[iNXT_UPLVL-1][0];
  17248. iNEED_GEMOFDEFEND = g_iNpcUpDfLevel_CSTATUE[iNXT_UPLVL-1][1];
  17249. iNEED_MONEY = g_iNpcUpDfLevel_CSTATUE[iNXT_UPLVL-1][2];
  17250. }
  17251. }
  17252. break;
  17253. default:
  17254. GCAnsNpcUpgrade(iIndex, 0x05, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17255. LogAddTD("[CastleSiege] CGReqNpcUpgrade() ERROR - UpType doesn't Exist [%s][%s], Guild:(%s)(%d), NPC CLS:%d, IDX:%d, UPTYPE:%d, UPVAL:%d",
  17256. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17257. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex,
  17258. lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17259. return;
  17260. }
  17261. }
  17262. else
  17263. {
  17264. GCAnsNpcUpgrade(iIndex, 0x07, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17265. return;
  17266. }
  17267. }
  17268. break;
  17269. default:
  17270. GCAnsNpcRepair(iIndex, 0, lpMsg->iNpcNumber, lpMsg->iNpcIndex, 0, 0);
  17271. return;
  17272. }
  17273.  
  17274. if ( !bENABLE_UPGRADE)
  17275. {
  17276. GCAnsNpcUpgrade(iIndex, 0x06, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17277. return;
  17278. }
  17279.  
  17280. if ( gObj[iIndex].Money < iNEED_MONEY )
  17281. {
  17282. GCAnsNpcUpgrade(iIndex, 0x03, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17283.  
  17284. LogAddTD("[CastleSiege] CGReqNpcUpgrade() ERROR - Money is Low [%s][%s], Guild:(%s)(%d), NPC CLS:%d, IDX:%d, UPTYPE:%d, UPVAL:%d, NXTLV:%d, Money:%d, Need Money:%d",
  17285. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17286. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue, iNXT_UPLVL, gObj[iIndex].Money, iNEED_MONEY);
  17287.  
  17288. return;
  17289. }
  17290.  
  17291. int iGEMOFDEFEND_COUNT = 0;
  17292. for ( int x=0; x<INVENTORY_SIZE;x++)
  17293. {
  17294. if ( gObj[iIndex].pInventory[x].IsItem() ==TRUE )
  17295. {
  17296. if ( gObj[iIndex].pInventory[x].m_Type == ITEMGET(14,31) )
  17297. {
  17298. iGEMOFDEFEND_COUNT++;
  17299. }
  17300. }
  17301. }
  17302.  
  17303. if ( iGEMOFDEFEND_COUNT < iNEED_GEMOFDEFEND )
  17304. {
  17305. GCAnsNpcUpgrade(iIndex, 0x04, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue);
  17306.  
  17307. LogAddTD("[CastleSiege] CGReqNpcUpgrade() ERROR - Gem is Low [%s][%s], Guild:(%s)(%d), NPC CLS:%d, IDX:%d, UPTYPE:%d, UPVAL:%d, NXTLV:%d, Gem:%d, Need Gem:%d",
  17308. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17309. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue, iNXT_UPLVL, iGEMOFDEFEND_COUNT, iNEED_GEMOFDEFEND);
  17310.  
  17311. return;
  17312. }
  17313. BOOL bRETVAL = g_CastleSiege.PayForUpgradeDbNpc(iIndex, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue, iNXT_UPLVL-1);
  17314. if ( !bRETVAL ) return;
  17315.  
  17316. gObj[iIndex].m_bIsCastleNPCUpgradeCompleted = true;
  17317.  
  17318. LogAddTD("[CastleSiege] [0xB2][0x07] CGReqNpcUpgrade() - Pay For Npc Upgrade (CLS:%d, IDX:%d, UPTYPE:%d, UPVAL:%d)",
  17319. lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, iNXT_UPVALUE);
  17320.  
  17321. GS_GDReqCastleNpcUpgrade(g_MapServerManager.GetMapSvrGroup(), iIndex, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, iNXT_UPVALUE , iNXT_UPLVL-1);
  17322.  
  17323. LogAddTD("[CastleSiege] CGReqNpcUpgrade() REQ OK - [%s][%s], Guild:(%s)(%d), NPC CLS:%d, IDX:%d, UPTYPE:%d, UPVAL:%d, NXTLV:%d",
  17324. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17325. gObj[iIndex].GuildStatus, lpMsg->iNpcNumber, lpMsg->iNpcIndex, lpMsg->iNpcUpType, lpMsg->iNpcUpValue, iNXT_UPLVL);
  17326. }
  17327.  
  17328.  
  17329.  
  17330. struct PMSG_ANS_NPCUPGRADE
  17331. {
  17332. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17333. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17334. /*<thisrel this+0x8>*/ /*|0x4|*/ int iNpcNumber;
  17335. /*<thisrel this+0xc>*/ /*|0x4|*/ int iNpcIndex;
  17336. /*<thisrel this+0x10>*/ /*|0x4|*/ int iNpcUpType;
  17337. /*<thisrel this+0x14>*/ /*|0x4|*/ int iNpcUpValue;
  17338. };
  17339. void GCAnsNpcUpgrade(int iIndex, int iResult, int iNpcNumber, int iNpcIndex, int iNpcUpType, int iNpcUpValue)
  17340. {
  17341. PMSG_ANS_NPCUPGRADE pMsgResult;
  17342.  
  17343. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x07, sizeof(pMsgResult));
  17344. pMsgResult.btResult = iResult;
  17345. pMsgResult.iNpcNumber = iNpcNumber;
  17346. pMsgResult.iNpcIndex = iNpcIndex;
  17347. pMsgResult.iNpcUpType = iNpcUpType;
  17348. pMsgResult.iNpcUpValue = iNpcUpValue;
  17349.  
  17350. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17351. }
  17352.  
  17353.  
  17354.  
  17355.  
  17356. void CGReqTaxMoneyInfo(PMSG_REQ_TAXMONEYINFO * lpMsg, int iIndex)
  17357. {
  17358. if ( lpMsg == NULL ) return;
  17359. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  17360.  
  17361. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  17362. (gObj[iIndex].GuildStatus != 0x80 ) )
  17363. {
  17364. LogAddC(2, "[CastleSiege] CGReqTaxMoneyInfo() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17365. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17366. gObj[iIndex].GuildStatus);
  17367. return;
  17368. }
  17369.  
  17370. GS_GDReqTaxInfo(g_MapServerManager.GetMapSvrGroup(), iIndex);
  17371.  
  17372. LogAddTD("[CastleSiege] CGReqTaxMoneyInfo() REQ OK - [%s][%s], Guild:(%s)(%d)",
  17373. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17374. gObj[iIndex].GuildStatus);
  17375. }
  17376.  
  17377.  
  17378. struct PMSG_ANS_TAXMONEYINFO
  17379. {
  17380. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17381. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17382. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btTaxRateChaos;
  17383. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btTaxRateStore;
  17384. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btMoney1;
  17385. /*<thisrel this+0x8>*/ /*|0x1|*/ unsigned char btMoney2;
  17386. /*<thisrel this+0x9>*/ /*|0x1|*/ unsigned char btMoney3;
  17387. /*<thisrel this+0xa>*/ /*|0x1|*/ unsigned char btMoney4;
  17388. /*<thisrel this+0xb>*/ /*|0x1|*/ unsigned char btMoney5;
  17389. /*<thisrel this+0xc>*/ /*|0x1|*/ unsigned char btMoney6;
  17390. /*<thisrel this+0xd>*/ /*|0x1|*/ unsigned char btMoney7;
  17391. /*<thisrel this+0xe>*/ /*|0x1|*/ unsigned char btMoney8;
  17392. };
  17393.  
  17394. void GCAnsTaxMoneyInfo(int iIndex, int iResult, BYTE btTaxRateChaos, BYTE btTaxRateStore, __int64 i64Money)
  17395. {
  17396. PMSG_ANS_TAXMONEYINFO pMsgResult;
  17397.  
  17398. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x08, sizeof(pMsgResult));
  17399. pMsgResult.btResult = iResult;
  17400. pMsgResult.btTaxRateChaos = btTaxRateChaos;
  17401. pMsgResult.btTaxRateStore = btTaxRateStore;
  17402. pMsgResult.btMoney1 = SET_NUMBERH(SET_NUMBERHW(SET_NUMBERHDW(i64Money)));
  17403. pMsgResult.btMoney2 = SET_NUMBERL(SET_NUMBERHW(SET_NUMBERHDW(i64Money)));
  17404. pMsgResult.btMoney3 = SET_NUMBERH(SET_NUMBERLW(SET_NUMBERHDW(i64Money)));
  17405. pMsgResult.btMoney4 = SET_NUMBERL(SET_NUMBERLW(SET_NUMBERHDW(i64Money)));
  17406. pMsgResult.btMoney5 = SET_NUMBERH(SET_NUMBERHW(SET_NUMBERLDW(i64Money)));
  17407. pMsgResult.btMoney6 = SET_NUMBERL(SET_NUMBERHW(SET_NUMBERLDW(i64Money)));
  17408. pMsgResult.btMoney7 = SET_NUMBERH(SET_NUMBERLW(SET_NUMBERLDW(i64Money)));
  17409. pMsgResult.btMoney8 = SET_NUMBERL(SET_NUMBERLW(SET_NUMBERLDW(i64Money)));
  17410.  
  17411. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17412. }
  17413.  
  17414.  
  17415.  
  17416.  
  17417. void CGReqTaxRateChange(PMSG_REQ_TAXRATECHANGE * lpMsg, int iIndex)
  17418. {
  17419. if ( lpMsg == NULL ) return;
  17420. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  17421.  
  17422. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  17423. (gObj[iIndex].GuildStatus != 0x80 ) )
  17424. {
  17425. LogAddC(2, "[CastleSiege] CGReqTaxRateChange() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17426. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17427. gObj[iIndex].GuildStatus);
  17428. return;
  17429. }
  17430. int iMaxTaxRate = 0;
  17431.  
  17432. switch ( lpMsg->btTaxType )
  17433. {
  17434. case 1: iMaxTaxRate = 3; break;
  17435. case 2: iMaxTaxRate = 3; break;
  17436. case 3: iMaxTaxRate = 300000; break;
  17437. }
  17438.  
  17439. int iTaxRate = MAKE_NUMBERDW(MAKE_NUMBERW(lpMsg->btTaxRate1, lpMsg->btTaxRate2), MAKE_NUMBERW(lpMsg->btTaxRate3, lpMsg->btTaxRate4));
  17440. if ( iTaxRate < 0 || iTaxRate > iMaxTaxRate )
  17441. {
  17442. GCAnsTaxRateChange(iIndex, 0, 0, 0);
  17443.  
  17444. LogAddTD("[CastleSiege] CGReqTaxRateChange() ERROR - Tax Rate Out of Range [%s][%s], Guild:(%s)(%d), TaxType:%d, TaxRate:%d",
  17445. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17446. gObj[iIndex].GuildStatus, lpMsg->btTaxType, iTaxRate);
  17447.  
  17448. return;
  17449. }
  17450.  
  17451. GS_GDReqTaxRateChange(g_MapServerManager.GetMapSvrGroup(), iIndex, lpMsg->btTaxType, iTaxRate);
  17452.  
  17453. LogAddTD("[CastleSiege] CGReqTaxRateChange() REQ OK - [%s][%s], Guild:(%s)(%d), TaxType:%d, TaxRate:%d",
  17454. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17455. gObj[iIndex].GuildStatus, lpMsg->btTaxType, iTaxRate);
  17456. }
  17457.  
  17458.  
  17459. struct PMSG_ANS_TAXRATECHANGE
  17460. {
  17461. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17462. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17463. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btTaxType;
  17464. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btTaxRate1;
  17465. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btTaxRate2;
  17466. /*<thisrel this+0x8>*/ /*|0x1|*/ unsigned char btTaxRate3;
  17467. /*<thisrel this+0x9>*/ /*|0x1|*/ unsigned char btTaxRate4;
  17468. };
  17469.  
  17470. void GCAnsTaxRateChange(int iIndex, int iResult, BYTE btTaxType, int iTaxRate)
  17471. {
  17472. PMSG_ANS_TAXRATECHANGE pMsgResult;
  17473.  
  17474. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x09, sizeof(pMsgResult));
  17475. pMsgResult.btResult = iResult;
  17476. pMsgResult.btTaxType = btTaxType;
  17477. pMsgResult.btTaxRate1 = SET_NUMBERH(SET_NUMBERHW(iTaxRate));
  17478. pMsgResult.btTaxRate2 = SET_NUMBERL(SET_NUMBERHW(iTaxRate));
  17479. pMsgResult.btTaxRate3 = SET_NUMBERH(SET_NUMBERLW(iTaxRate));
  17480. pMsgResult.btTaxRate4 = SET_NUMBERL(SET_NUMBERLW(iTaxRate));
  17481.  
  17482. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17483. }
  17484.  
  17485.  
  17486.  
  17487.  
  17488. void CGReqMoneyDrawOut(PMSG_REQ_MONEYDRAWOUT * lpMsg, int iIndex)
  17489. {
  17490. if ( lpMsg == NULL ) return;
  17491. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  17492.  
  17493. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  17494. (gObj[iIndex].GuildStatus != 0x80 ) )
  17495. {
  17496. LogAddC(2, "[CastleSiege] CGReqMoneyDrawOut() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17497. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17498. gObj[iIndex].GuildStatus);
  17499. return;
  17500. }
  17501.  
  17502. int iMoneyChange = MAKE_NUMBERDW(MAKE_NUMBERW(lpMsg->btMoney4, lpMsg->btMoney3), MAKE_NUMBERW(lpMsg->btMoney2, lpMsg->btMoney1));
  17503. if ( iMoneyChange <= 0 )
  17504. {
  17505. GCAnsMoneyDrawOut(iIndex, 0, 0);
  17506.  
  17507. LogAddTD("[CastleSiege] CGReqMoneyDrawOut() ERROR - Req Money < 0 [%s][%s], Guild:(%s)(%d), Money:%d, TotMoney:%d",
  17508. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17509. gObj[iIndex].GuildStatus, iMoneyChange, gObj[iIndex].Money);
  17510.  
  17511. return;
  17512. }
  17513.  
  17514. BOOL bRETVAL = g_CastleSiege.CheckCastleHasMoney(iMoneyChange);
  17515. if ( bRETVAL == FALSE )
  17516. {
  17517. GCAnsMoneyDrawOut(iIndex, 0, 0);
  17518.  
  17519. LogAddTD("[CastleSiege] CGReqMoneyDrawOut() ERROR - Castle Money is Low [%s][%s], Guild:(%s)(%d), Money:%d, TotMoney:%d",
  17520. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17521. gObj[iIndex].GuildStatus, iMoneyChange, gObj[iIndex].Money);
  17522.  
  17523. return;
  17524. }
  17525.  
  17526. if ( (gObj[iIndex].Money + iMoneyChange) > MAX_ZEN )
  17527. {
  17528. GCAnsMoneyDrawOut(iIndex, 0, 0);
  17529. return;
  17530. }
  17531.  
  17532. GS_GDReqCastleMoneyChange(g_MapServerManager.GetMapSvrGroup(), iIndex, -iMoneyChange);
  17533.  
  17534. LogAddTD("[CastleSiege] CGReqMoneyDrawOut() REQ OK - [%s][%s], Guild:(%s)(%d), Money:%d, TotMoney:%d",
  17535. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17536. gObj[iIndex].GuildStatus, iMoneyChange, gObj[iIndex].Money);
  17537. }
  17538.  
  17539.  
  17540.  
  17541. struct PMSG_ANS_MONEYDRAWOUT
  17542. {
  17543. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17544. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17545. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btMoney1;
  17546. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btMoney2;
  17547. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btMoney3;
  17548. /*<thisrel this+0x8>*/ /*|0x1|*/ unsigned char btMoney4;
  17549. /*<thisrel this+0x9>*/ /*|0x1|*/ unsigned char btMoney5;
  17550. /*<thisrel this+0xa>*/ /*|0x1|*/ unsigned char btMoney6;
  17551. /*<thisrel this+0xb>*/ /*|0x1|*/ unsigned char btMoney7;
  17552. /*<thisrel this+0xc>*/ /*|0x1|*/ unsigned char btMoney8;
  17553. };
  17554.  
  17555. void GCAnsMoneyDrawOut(int iIndex, int iResult, __int64 i64Money)
  17556. {
  17557. PMSG_ANS_MONEYDRAWOUT pMsgResult;
  17558.  
  17559. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x10, sizeof(pMsgResult));
  17560. pMsgResult.btResult = iResult;
  17561. pMsgResult.btMoney1 = SET_NUMBERH(SET_NUMBERHW(SET_NUMBERHDW(i64Money)));
  17562. pMsgResult.btMoney2 = SET_NUMBERL(SET_NUMBERHW(SET_NUMBERHDW(i64Money)));
  17563. pMsgResult.btMoney3 = SET_NUMBERH(SET_NUMBERLW(SET_NUMBERHDW(i64Money)));
  17564. pMsgResult.btMoney4 = SET_NUMBERL(SET_NUMBERLW(SET_NUMBERHDW(i64Money)));
  17565. pMsgResult.btMoney5 = SET_NUMBERH(SET_NUMBERHW(SET_NUMBERLDW(i64Money)));
  17566. pMsgResult.btMoney6 = SET_NUMBERL(SET_NUMBERHW(SET_NUMBERLDW(i64Money)));
  17567. pMsgResult.btMoney7 = SET_NUMBERH(SET_NUMBERLW(SET_NUMBERLDW(i64Money)));
  17568. pMsgResult.btMoney8 = SET_NUMBERL(SET_NUMBERLW(SET_NUMBERLDW(i64Money)));
  17569.  
  17570. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17571. }
  17572.  
  17573.  
  17574. struct PMSG_ANS_CSGATESTATE
  17575. {
  17576. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17577. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17578. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btIndex1;
  17579. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btIndex2;
  17580. };
  17581.  
  17582. void GCAnsCsGateState(int iIndex, int iResult, int iGateIndex)
  17583. {
  17584. PMSG_ANS_CSGATESTATE pMsgResult;
  17585.  
  17586. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x11, sizeof(pMsgResult));
  17587. pMsgResult.btResult = iResult;
  17588. pMsgResult.btIndex1 = (DWORD(iGateIndex & 0xFFFF) >> 8);
  17589. pMsgResult.btIndex2 = ((iGateIndex & 0xFFFF) & 0xFF);
  17590.  
  17591. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17592. }
  17593.  
  17594.  
  17595.  
  17596.  
  17597.  
  17598. void CGReqCsGateOperate(PMSG_REQ_CSGATEOPERATE * lpMsg, int iIndex)
  17599. {
  17600. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  17601. if ( g_CastleSiege.GetCastleState() == CASTLESIEGE_STATE_STARTSIEGE )
  17602. {
  17603. if ( gObj[iIndex].m_btCsJoinSide != TRUE )
  17604. {
  17605. LogAddTD("[CastleSiege] CGReqCsGateOperate() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17606. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17607. gObj[iIndex].GuildStatus);
  17608. return;
  17609. }
  17610. }
  17611. else if ( g_CastleSiege.CheckCastleOwnerMember(iIndex) == FALSE &&
  17612. g_CastleSiege.CheckCastleOwnerUnionMember(iIndex) == FALSE )
  17613. {
  17614. LogAddTD("[CastleSiege] CGReqCsGateOperate() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  17615. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17616. gObj[iIndex].GuildStatus);
  17617. return;
  17618. }
  17619.  
  17620. int iGateIndex = MAKE_NUMBERW(lpMsg->btIndex1, lpMsg->btIndex2);
  17621. if ( g_CastleSiege.CheckCsGateAlive(iGateIndex) == TRUE )
  17622. {
  17623. BOOL bRETVAL = g_CastleSiege.OperateGate(iGateIndex, gObj[iGateIndex].m_iCsNpcExistVal, lpMsg->btOperate);
  17624. if ( !bRETVAL )
  17625. {
  17626. GCAnsCsGateOperate(iIndex, 0, -1, 0);
  17627. LogAddTD("[CastleSiege] CGReqCsGateOperate() ERROR - Operate Gate Failed [%s][%s], Guild:(%s)(%d)",
  17628. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17629. gObj[iIndex].GuildStatus);
  17630.  
  17631.  
  17632. }
  17633. else
  17634. {
  17635. GCAnsCsGateOperate(iIndex, 1, iGateIndex, lpMsg->btOperate);
  17636. g_CastleSiege.SendCsGateStateViewPort(iGateIndex, lpMsg->btOperate);
  17637.  
  17638. LogAddTD("[CastleSiege] CGReqCsGateOperate() OK - [%s][%s], Guild:(%s)(%d), DOOR:(%d)(X:%d,Y:%d)(STATUE:%d)",
  17639. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17640. gObj[iIndex].GuildStatus, iGateIndex, gObj[iGateIndex].X, gObj[iGateIndex].Y, gObj[iGateIndex].m_btCsGateOpen);
  17641. }
  17642. }
  17643. else
  17644. {
  17645. GCAnsCsGateOperate(iIndex, 2, -1, 0);
  17646.  
  17647. LogAddTD("[CastleSiege] CGReqCsGateOperate() ERROR - Gate Doesn't Exist [%s][%s], Guild:(%s)(%d)",
  17648. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  17649. gObj[iIndex].GuildStatus);
  17650. }
  17651. }
  17652.  
  17653.  
  17654.  
  17655. struct PMSG_ANS_CSGATEOPERATE
  17656. {
  17657. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17658. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  17659. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btOperate;
  17660. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btIndex1;
  17661. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btIndex2;
  17662. };
  17663.  
  17664. void GCAnsCsGateOperate(int iIndex, int iResult, int iGateIndex, int iGateOperate)
  17665. {
  17666. PMSG_ANS_CSGATEOPERATE pMsgResult;
  17667.  
  17668. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x12, sizeof(pMsgResult));
  17669. pMsgResult.btResult = iResult;
  17670. pMsgResult.btOperate = iGateOperate;
  17671. pMsgResult.btIndex1 = (DWORD(iGateIndex & 0xFFFF) >> 8);
  17672. pMsgResult.btIndex2 = ((iGateIndex & 0xFFFF) & 0xFF);
  17673.  
  17674. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17675. }
  17676.  
  17677.  
  17678. struct PMSG_ANS_CSGATECURSTATE {
  17679.  
  17680. // static data ------------------------------------
  17681.  
  17682. // non-static data --------------------------------
  17683. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17684. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btOperate;
  17685. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btIndex1;
  17686. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btIndex2;
  17687. };
  17688.  
  17689. void GCAnsCsGateCurState(int iIndex, int iGateIndex, int iGateOperate)
  17690. {
  17691. PMSG_ANS_CSGATECURSTATE pMsgResult;
  17692.  
  17693. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x13, sizeof(pMsgResult));
  17694. pMsgResult.btOperate = iGateOperate;
  17695. pMsgResult.btIndex1 = (DWORD(iGateIndex & 0xFFFF) >> 8);
  17696. pMsgResult.btIndex2 = ((iGateIndex & 0xFFFF) & 0xFF);
  17697.  
  17698. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17699. }
  17700.  
  17701.  
  17702. struct PMSG_ANS_NOTIFYSWITCHPROC
  17703. {
  17704. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17705. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btIndex1;
  17706. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btIndex2;
  17707. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btUserIndex1;
  17708. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btUserIndex2;
  17709. /*<thisrel this+0x8>*/ /*|0x1|*/ unsigned char btSwitchState;
  17710. };
  17711.  
  17712. void GCAnsCsAccessSwitchState(int iIndex, int iSwitchIndex, int iSwitchUserIndex, BYTE btSwitchState)
  17713. {
  17714. PMSG_ANS_NOTIFYSWITCHPROC pMsgResult;
  17715.  
  17716. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x14, sizeof(pMsgResult));
  17717. pMsgResult.btIndex1 = (DWORD(iSwitchIndex & 0xFFFF) >> 8);
  17718. pMsgResult.btIndex2 = ((iSwitchIndex & 0xFFFF) & 0xFF);
  17719. pMsgResult.btUserIndex1 = (DWORD(iSwitchUserIndex & 0xFFFF) >> 8);
  17720. pMsgResult.btUserIndex2 = ((iSwitchUserIndex & 0xFFFF) & 0xFF);
  17721. pMsgResult.btSwitchState = btSwitchState;
  17722.  
  17723. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17724. }
  17725.  
  17726.  
  17727. struct PMSG_ANS_NOTIFYCROWNPROC
  17728. {
  17729. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17730. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btCrownState;
  17731. /*<thisrel this+0x8>*/ /*|0x4|*/ unsigned long dwAccumulatedCrownAccessTime;
  17732. };
  17733.  
  17734. void GCAnsCsAccessCrownState(int iIndex, BYTE btCrownState)
  17735. {
  17736. PMSG_ANS_NOTIFYCROWNPROC pMsgResult;
  17737.  
  17738. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x15, sizeof(pMsgResult));
  17739. pMsgResult.btCrownState = btCrownState;
  17740.  
  17741. if ( btCrownState == 0 )
  17742. {
  17743. if ( gObj[iIndex].m_iAccumulatedCrownAccessTime < 0 || gObj[iIndex].m_iAccumulatedCrownAccessTime > 30000 )
  17744. {
  17745. gObj[iIndex].m_iAccumulatedCrownAccessTime = 0;
  17746. }
  17747. LogAddTD("[CastleSiege] [Reg. Attempt] Accumulated Crown AccessTime : %d [%s](%s)(%s)",
  17748. gObj[iIndex].m_iAccumulatedCrownAccessTime, gObj[iIndex].GuildName, gObj[iIndex].AccountID,
  17749. gObj[iIndex].Name);
  17750. }
  17751.  
  17752. if ( btCrownState == 1 )
  17753. {
  17754. LogAddTD("[CastleSiege] [Reg. Success] Accumulated Crown AccessTime : %d [%s](%s)(%s)",
  17755. gObj[iIndex].m_iAccumulatedCrownAccessTime, gObj[iIndex].GuildName, gObj[iIndex].AccountID,
  17756. gObj[iIndex].Name);
  17757. gObj[iIndex].m_iAccumulatedCrownAccessTime = 0;
  17758. }
  17759.  
  17760. if ( btCrownState == 2 )
  17761. {
  17762. gObj[iIndex].m_iAccumulatedCrownAccessTime += GetTickCount() - g_CastleSiege.GetCrownAccessTickCount();
  17763. DWORD dwTickCount = 5000;
  17764. gObj[iIndex].m_iAccumulatedCrownAccessTime -= dwTickCount;
  17765.  
  17766. if ( gObj[iIndex].m_iAccumulatedCrownAccessTime < 0 || gObj[iIndex].m_iAccumulatedCrownAccessTime > 30000 )
  17767. {
  17768. gObj[iIndex].m_iAccumulatedCrownAccessTime = 0;
  17769. }
  17770. LogAddTD("[CastleSiege] [Reg. Fail] Accumulated Crown AccessTime : %d [%s](%s)(%s)",
  17771. gObj[iIndex].m_iAccumulatedCrownAccessTime, gObj[iIndex].GuildName, gObj[iIndex].AccountID,
  17772. gObj[iIndex].Name);
  17773. }
  17774.  
  17775. pMsgResult.dwAccumulatedCrownAccessTime = gObj[iIndex].m_iAccumulatedCrownAccessTime;
  17776. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17777. }
  17778.  
  17779.  
  17780.  
  17781. void GCAnsCsNotifyStart(int iIndex, BYTE btStartState)
  17782. {
  17783. PMSG_ANS_NOTIFYCSSTART pMsgResult;
  17784.  
  17785. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x17, sizeof(pMsgResult));
  17786. pMsgResult.btStartState = btStartState;
  17787.  
  17788. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17789. }
  17790.  
  17791.  
  17792.  
  17793.  
  17794.  
  17795. void GCAnsCsNotifyProgress(int iIndex, BYTE btCastleSiegeState, LPSTR lpszGuildName)
  17796. {
  17797. if ( lpszGuildName == NULL )
  17798. return;
  17799.  
  17800. PMSG_ANS_NOTIFYCSPROGRESS pMsgResult;
  17801.  
  17802. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x18, sizeof(pMsgResult));
  17803. pMsgResult.btCastleSiegeState = btCastleSiegeState;
  17804. memset(pMsgResult.szGuildName, 0, sizeof(pMsgResult.szGuildName));
  17805. memcpy(pMsgResult.szGuildName, lpszGuildName, sizeof(pMsgResult.szGuildName));
  17806.  
  17807. DataSend(iIndex, (UCHAR*)&pMsgResult, pMsgResult.h.size);
  17808. }
  17809.  
  17810.  
  17811. struct PMSG_ANS_MAPSVRTAXINFO
  17812. {
  17813. PBMSG_HEAD2 h; // C1:B2:1A
  17814. BYTE btTaxType; // 4
  17815. BYTE btTaxRate; // 5
  17816. };
  17817.  
  17818.  
  17819. void GCAnsCsMapSvrTaxInfo(int iIndex, BYTE btTaxType, BYTE btTaxRate)
  17820. {
  17821. PMSG_ANS_MAPSVRTAXINFO pMsgResult;
  17822.  
  17823. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x1A, sizeof(pMsgResult));
  17824. pMsgResult.btTaxType = btTaxType;
  17825. pMsgResult.btTaxRate = btTaxRate;
  17826.  
  17827. DataSend(iIndex, (UCHAR*)&pMsgResult, pMsgResult.h.size);
  17828.  
  17829. }
  17830.  
  17831.  
  17832.  
  17833.  
  17834. void CGReqCsMiniMapData(PMSG_REQ_MINIMAPDATA * lpMsg, int iIndex)
  17835. {
  17836. if ( !gObjIsConnected(iIndex) ) return;
  17837. if ( gObj[iIndex].m_btCsJoinSide <= 0 || g_CastleSiege.CheckUnionGuildMaster(iIndex) == FALSE )
  17838. {
  17839. GCAnsCsMiniMapData(iIndex, 3);
  17840. return;
  17841. }
  17842.  
  17843. if ( g_CastleSiege.GetCastleState() != CASTLESIEGE_STATE_STARTSIEGE )
  17844. {
  17845. GCAnsCsMiniMapData(iIndex, 2);
  17846. return;
  17847. }
  17848.  
  17849. g_CastleSiege.AddMiniMapDataReqUser(iIndex);
  17850. GCAnsCsMiniMapData(iIndex, 1);
  17851. }
  17852.  
  17853.  
  17854.  
  17855. struct PMSG_ANS_MINIMAPDATA
  17856. {
  17857. PBMSG_HEAD2 h;
  17858. BYTE btResult; // 4
  17859. };
  17860.  
  17861.  
  17862. void GCAnsCsMiniMapData(int iIndex, BYTE btResult)
  17863. {
  17864. PMSG_ANS_MINIMAPDATA pMsgResult;
  17865.  
  17866. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x1B, sizeof(pMsgResult));
  17867. pMsgResult.btResult = btResult;
  17868.  
  17869. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17870. }
  17871.  
  17872.  
  17873.  
  17874. void CGReqStopCsMiniMapData(PMSG_REQ_STOPMINIMAPDATA * lpMsg, int iIndex)
  17875. {
  17876. if ( !gObjIsConnected(iIndex) ) return;
  17877. g_CastleSiege.DelMiniMapDataReqUser(iIndex);
  17878. }
  17879.  
  17880.  
  17881.  
  17882. void CGReqCsSendCommand(PMSG_REQ_CSCOMMAND * lpMsg, int iIndex)
  17883. {
  17884. if ( !gObjIsConnected(iIndex) ) return;
  17885. if ( gObj[iIndex].m_btCsJoinSide <= 0 || g_CastleSiege.CheckUnionGuildMaster(iIndex) == FALSE )
  17886. return;
  17887.  
  17888. if ( g_CastleSiege.GetCastleState() != CASTLESIEGE_STATE_STARTSIEGE )
  17889. return;
  17890.  
  17891. GCAnsCsSendCommand(gObj[iIndex].m_btCsJoinSide,
  17892. lpMsg->btTeam, lpMsg->btX, lpMsg->btY, lpMsg->btCommand);
  17893. }
  17894.  
  17895.  
  17896. struct PMSG_ANS_CSCOMMAND
  17897. {
  17898. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  17899. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btTeam;
  17900. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btX;
  17901. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btY;
  17902. /*<thisrel this+0x7>*/ /*|0x1|*/ unsigned char btCommand;
  17903. };
  17904.  
  17905. void GCAnsCsSendCommand(int iCsJoinSize, BYTE btTeam, BYTE btX, BYTE btY, BYTE btCommand)
  17906. {
  17907. PMSG_ANS_CSCOMMAND pMsgResult;
  17908.  
  17909. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, MOVE_PROTOCOL, sizeof(pMsgResult));
  17910. pMsgResult.btTeam = btTeam;
  17911. pMsgResult.btX = btX;
  17912. pMsgResult.btY = btY;
  17913. pMsgResult.btCommand = btCommand;
  17914.  
  17915. for(int iIndex=OBJ_STARTUSERINDEX ; iIndex < OBJMAX ; iIndex++)
  17916. {
  17917. if ( !gObjIsConnected(iIndex))
  17918. continue;
  17919.  
  17920. if ( gObj[iIndex].m_btCsJoinSide == iCsJoinSize )
  17921. {
  17922. if ( gObj[iIndex].MapNumber == MAP_INDEX_CASTLESIEGE )
  17923. {
  17924. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17925. }
  17926. }
  17927. }
  17928. }
  17929.  
  17930.  
  17931.  
  17932. struct PMSG_ANS_CSLEFTTIMEALARM
  17933. {
  17934. PBMSG_HEAD2 h; // C1:B2:1E
  17935. BYTE btHour; // 4
  17936. BYTE btMinute; // 5
  17937. };
  17938.  
  17939.  
  17940. void GCAnsCsLeftTimeAlarm(BYTE btHour, BYTE btMinute)
  17941. {
  17942. PMSG_ANS_CSLEFTTIMEALARM pMsgResult;
  17943.  
  17944. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x1E, sizeof(pMsgResult));
  17945. pMsgResult.btHour = btHour;
  17946. pMsgResult.btMinute = btMinute;
  17947.  
  17948. for (int iIndex = OBJ_STARTUSERINDEX;iIndex < OBJMAX;iIndex++)
  17949. {
  17950. if ( !gObjIsConnected(iIndex) )
  17951. {
  17952. continue;
  17953. }
  17954.  
  17955. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17956. }
  17957.  
  17958. }
  17959.  
  17960.  
  17961.  
  17962.  
  17963.  
  17964.  
  17965. void GCAnsSelfCsLeftTimeAlarm(int iIndex, BYTE btHour, BYTE btMinute)
  17966. {
  17967. PMSG_ANS_CSLEFTTIMEALARM pMsgResult;
  17968.  
  17969. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x1E, sizeof(pMsgResult));
  17970. pMsgResult.btHour = btHour;
  17971. pMsgResult.btMinute = btMinute;
  17972.  
  17973. if ( !gObjIsConnected(iIndex))
  17974. {
  17975. return;
  17976. }
  17977.  
  17978. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  17979. }
  17980.  
  17981.  
  17982.  
  17983.  
  17984.  
  17985.  
  17986. void CGReqCsSetEnterHuntZone(PMSG_REQ_CSHUNTZONEENTER * lpMsg, int iIndex)
  17987. {
  17988. if ( !gObjIsConnected(iIndex)) return;
  17989.  
  17990. if ( g_CastleSiege.CheckCastleOwnerMember(iIndex) == FALSE ) // #error Add Union also for
  17991. {
  17992. GCAnsCsSetEnterHuntZone(iIndex, 2, lpMsg->btHuntZoneEnter);
  17993. return;
  17994. }
  17995.  
  17996. if ( g_CastleSiege.GetCastleState() == CASTLESIEGE_STATE_STARTSIEGE )
  17997. {
  17998. GCAnsCsSetEnterHuntZone(iIndex, 0, lpMsg->btHuntZoneEnter);
  17999. return;
  18000. }
  18001.  
  18002. g_CastleSiege.SetHuntZoneEnter(lpMsg->btHuntZoneEnter);
  18003. GCAnsCsSetEnterHuntZone(iIndex, 1, lpMsg->btHuntZoneEnter);
  18004. }
  18005.  
  18006.  
  18007.  
  18008. struct PMSG_ANS_CSHUNTZONEENTER
  18009. {
  18010. PBMSG_HEAD2 h; // C1:B2:1F
  18011. BYTE btResult; // 4
  18012. BYTE btHuntZoneEnter; // 5
  18013. };
  18014.  
  18015.  
  18016. void GCAnsCsSetEnterHuntZone(int iIndex, BYTE btResult, BYTE btEnterHuntZone)
  18017. {
  18018. PMSG_ANS_CSHUNTZONEENTER pMsgResult;
  18019.  
  18020. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB2, 0x1F, sizeof(pMsgResult));
  18021. pMsgResult.btResult = btResult;
  18022. pMsgResult.btHuntZoneEnter = btEnterHuntZone;
  18023.  
  18024. DataSend(iIndex, (LPBYTE)&pMsgResult, pMsgResult.h.size);
  18025. }
  18026.  
  18027.  
  18028.  
  18029.  
  18030. void CGReqNpcDbList(PMSG_REQ_NPCDBLIST * lpMsg, int iIndex)
  18031. {
  18032. if ( lpMsg == NULL ) return;
  18033. if ( !strcmp(gObj[iIndex].GuildName, "")) return;
  18034.  
  18035. if ( g_CastleSiege.CheckGuildOwnCastle(gObj[iIndex].GuildName) == FALSE ||
  18036. ( gObj[iIndex].GuildStatus != 0x80 && gObj[iIndex].GuildStatus != 0x40 ) )
  18037. {
  18038. LogAddC(2, "[CastleSiege] CGReqNpcDbList() ERROR - Authority Fail [%s][%s], Guild:(%s)(%d)",
  18039. gObj[iIndex].AccountID, gObj[iIndex].Name, gObj[iIndex].GuildName,
  18040. gObj[iIndex].GuildStatus);
  18041.  
  18042. PMSG_ANS_NPCDBLIST pMsgResult;
  18043.  
  18044. pMsgResult.h.set((LPBYTE)&pMsgResult, 0xB3, sizeof(pMsgResult));
  18045. pMsgResult.iCount = 0;
  18046. pMsgResult.btResult = 2;
  18047.  
  18048. DataSend(iIndex, (LPBYTE)&pMsgResult, sizeof(pMsgResult));
  18049. return;
  18050. }
  18051.  
  18052. switch ( lpMsg->btMonsterCode )
  18053. {
  18054. case 1: g_CastleSiege.SendNpcStateList(iIndex, 277); break;
  18055. case 2: g_CastleSiege.SendNpcStateList(iIndex, 283); break;
  18056. }
  18057. }
  18058.  
  18059.  
  18060.  
  18061. void CGReqCsRegGuildList(PMSG_REQ_CSREGGUILDLIST * lpMsg, int iIndex)
  18062. {
  18063. if ( lpMsg == NULL ) return;
  18064.  
  18065. GS_GDReqAllGuildMarkRegInfo(g_MapServerManager.GetMapSvrGroup(), iIndex);
  18066. }
  18067.  
  18068.  
  18069. struct PMSG_ANS_CSATTKGUILDLIST
  18070. {
  18071. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PWMSG_HEAD h;
  18072. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  18073. /*<thisrel this+0x8>*/ /*|0x4|*/ int iCount;
  18074. };
  18075.  
  18076. void CGReqCsAttkGuildList(PMSG_REQ_CSATTKGUILDLIST * lpMsg, int iIndex)
  18077. {
  18078. if ( lpMsg == NULL) return;
  18079. char cBUFFER[1022];
  18080. PMSG_ANS_CSATTKGUILDLIST * lpMsgSend = (PMSG_ANS_CSATTKGUILDLIST *)cBUFFER;
  18081. PMSG_CSATTKGUILDLIST * lpMsgSendBody = (PMSG_CSATTKGUILDLIST *)(cBUFFER + sizeof(PMSG_ANS_CSATTKGUILDLIST));
  18082. int iCount = 0;
  18083.  
  18084. lpMsgSend->btResult = g_CastleSiege.GetCsAttkGuildList(lpMsgSendBody, iCount);
  18085. lpMsgSend->iCount = iCount;
  18086.  
  18087. if ( lpMsgSend->iCount < 0 )
  18088. lpMsgSend->iCount = 0;
  18089.  
  18090. if ( lpMsgSend->iCount > 100 )
  18091. lpMsgSend->iCount = 100;
  18092.  
  18093. lpMsgSend->h.set((LPBYTE)lpMsgSend, 0xB5, lpMsgSend->iCount * sizeof(PMSG_CSATTKGUILDLIST) + sizeof(PMSG_ANS_CSATTKGUILDLIST));
  18094. DataSend(iIndex, (LPBYTE)lpMsgSend, lpMsgSend->iCount * sizeof(PMSG_CSATTKGUILDLIST) + sizeof(PMSG_ANS_CSATTKGUILDLIST));
  18095. }
  18096.  
  18097.  
  18098.  
  18099.  
  18100. struct PMSG_ANS_USEWEAPON
  18101. {
  18102. PBMSG_HEAD2 h; // C1:B7:01
  18103. BYTE btResult; // [1:Attacker] [2:Targets] 4
  18104. BYTE btObjIndexH; // 5
  18105. BYTE btObjIndexL; // 6
  18106. BYTE btWeaponType; // [1:Slingshot attack] [2:Slingshot defense] 7
  18107. BYTE btPointX; // 8
  18108. BYTE btPointY; // 9
  18109. };
  18110.  
  18111.  
  18112.  
  18113. void CGReqWeaponUse(PMSG_REQ_USEWEAPON * aRecv, int iIndex)
  18114. {
  18115. WORD wObjIndex = MAKE_NUMBERW(aRecv->btObjIndexH, aRecv->btObjIndexL);
  18116.  
  18117. if ( !OBJMAX_RANGE(wObjIndex))
  18118. return;
  18119.  
  18120. if ( !OBJMAX_RANGE(iIndex))
  18121. return;
  18122.  
  18123. LPOBJ lpOwnerObj = &gObj[iIndex];
  18124. LPOBJ lpWeaponObj = &gObj[wObjIndex];
  18125.  
  18126. if ( lpOwnerObj->Type != OBJ_USER )
  18127. return;
  18128.  
  18129. if ( lpWeaponObj->Type != OBJ_NPC )
  18130. return;
  18131.  
  18132. PMSG_ANS_USEWEAPON pMsg = {0};
  18133.  
  18134. PHeadSubSetB((LPBYTE)&pMsg, 0xB7, 0x01, sizeof(pMsg));
  18135. pMsg.btResult = 1;
  18136.  
  18137. if ( lpWeaponObj->Class == 221 ) // Slingshot attack
  18138. {
  18139. pMsg.btWeaponType = 1;
  18140. pMsg.btObjIndexH = SET_NUMBERH(wObjIndex);
  18141. pMsg.btObjIndexL = SET_NUMBERL(wObjIndex);
  18142. g_CsNPC_Weapon.GetTargetPointXY(lpWeaponObj->Class, aRecv->btTargetIndex-1, pMsg.btPointX, pMsg.btPointY, TRUE);
  18143. }
  18144. else if( lpWeaponObj->Class == 222 ) // Slingshot defense
  18145. {
  18146. pMsg.btWeaponType = 2;
  18147. pMsg.btObjIndexH = SET_NUMBERH(wObjIndex);
  18148. pMsg.btObjIndexL = SET_NUMBERL(wObjIndex);
  18149. g_CsNPC_Weapon.GetTargetPointXY(lpWeaponObj->Class, aRecv->btTargetIndex-1, pMsg.btPointX, pMsg.btPointY, TRUE);
  18150. }
  18151.  
  18152. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18153.  
  18154. pMsg.btResult = 2;
  18155.  
  18156. for ( int n=0;n<MAX_VIEWPORT;n++)
  18157. {
  18158. if ( lpWeaponObj->VpPlayer2[n].type == OBJ_USER )
  18159. {
  18160. if ( lpWeaponObj->VpPlayer2[n].state )
  18161. {
  18162. if ( iIndex != lpWeaponObj->VpPlayer2[n].number )
  18163. {
  18164. DataSend(lpWeaponObj->VpPlayer2[n].number, (LPBYTE)&pMsg, sizeof(pMsg));
  18165. }
  18166. }
  18167. }
  18168. }
  18169. gObjNotifyUseWeaponV1(lpOwnerObj, lpWeaponObj, pMsg.btPointX, pMsg.btPointY);
  18170. g_CsNPC_Weapon.SetWeaponCalDamageInfo(wObjIndex, pMsg.btPointX, pMsg.btPointY, 10000);
  18171. }
  18172.  
  18173. void CGReqWeaponDamageValue(PMSG_REQ_WEAPON_DAMAGE_VALUE * aRecv, int iIndex)
  18174. {
  18175. if ( !OBJMAX_RANGE(iIndex) )
  18176. return;
  18177.  
  18178. BYTE btTargetX = 0;
  18179. BYTE btTargetY = 0;
  18180. WORD wObjIndex = MAKE_NUMBERW(aRecv->btObjIndexH, aRecv->btObjIndexL);
  18181.  
  18182. if ( g_CsNPC_Weapon.GetWeaponCalDamageInfo(wObjIndex, btTargetX, btTargetY) == TRUE )
  18183. {
  18184. gObjNotifyUseWeaponDamage(&gObj[wObjIndex], btTargetX, btTargetY);
  18185. }
  18186. else
  18187. {
  18188. MsgOutput(iIndex, lMsg.Get(MSGGET(6, 112)));
  18189. }
  18190. }
  18191.  
  18192.  
  18193. struct PMSG_NOTIFY_OBJECT_CREATION_STATE
  18194. {
  18195. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  18196. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btObjIndexH;
  18197. /*<thisrel this+0x5>*/ /*|0x1|*/ unsigned char btObjIndexL;
  18198. /*<thisrel this+0x6>*/ /*|0x1|*/ unsigned char btCreationState;
  18199. };
  18200.  
  18201. void GCSendObjectCreationState(int iObjectIndex)
  18202. {
  18203. if ( CHECK_LIMIT(iObjectIndex, OBJMAX) == FALSE ) return;
  18204.  
  18205. LPOBJ lpObj = &gObj[iObjectIndex];
  18206. PMSG_NOTIFY_OBJECT_CREATION_STATE pMsg={0};
  18207.  
  18208. if ( lpObj->Class == 278 )
  18209. {
  18210. PHeadSubSetB((LPBYTE)&pMsg, 0xB9, 0x01, sizeof(pMsg));
  18211. pMsg.btObjIndexH = SET_NUMBERH(iObjectIndex);
  18212. pMsg.btObjIndexL = SET_NUMBERL(iObjectIndex);
  18213. pMsg.btCreationState = lpObj->m_btCreationState;
  18214.  
  18215. MsgSendV2(lpObj, (LPBYTE)&pMsg, sizeof(pMsg));
  18216. }
  18217. }
  18218.  
  18219. struct PMSG_ANS_GUILDMARK_OF_CASTLEOWNER
  18220. {
  18221. PBMSG_HEAD2 h; // C1:B9:02
  18222. BYTE GuildMarkOfCastleOwner[32]; // 4
  18223. };
  18224.  
  18225. void CGReqGuildMarkOfCastleOwner(PMSG_REQ_GUILDMARK_OF_CASTLEOWNER * aRecv, int iIndex)
  18226. {
  18227. if ( !OBJMAX_RANGE(iIndex) )
  18228. return;
  18229.  
  18230. LPOBJ lpObj = &gObj[iIndex];
  18231. char szGuildName[MAX_GUILD_LEN+1] = {0};
  18232.  
  18233. memcpy(szGuildName, g_CastleSiegeSync.GetCastleOwnerGuild(), MAX_GUILD_LEN);
  18234.  
  18235. if ( szGuildName )
  18236. {
  18237. _GUILD_INFO_STRUCT * lpGuild = Guild.SearchGuild(szGuildName);
  18238.  
  18239. if ( lpGuild != NULL )
  18240. {
  18241. PMSG_ANS_GUILDMARK_OF_CASTLEOWNER pMsg = {0};
  18242.  
  18243. PHeadSubSetB((LPBYTE)&pMsg, 0xB9, 0x02, sizeof(pMsg));
  18244. memcpy(pMsg.GuildMarkOfCastleOwner, lpGuild->Mark, sizeof(pMsg.GuildMarkOfCastleOwner));
  18245.  
  18246. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18247. }
  18248. }
  18249. }
  18250.  
  18251. struct PMSG_ANS_MOVE_TO_CASTLE_HUNTZONE
  18252. {
  18253. /*<thisrel this+0x0>*/ /*|0x4|*/ struct PBMSG_HEAD2 h;
  18254. /*<thisrel this+0x4>*/ /*|0x1|*/ unsigned char btResult;
  18255. };
  18256.  
  18257. void CGReqCastleHuntZoneEntrance(PMSG_REQ_MOVE_TO_CASTLE_HUNTZONE* aRecv, int iIndex)
  18258. {
  18259. if ( CHECK_LIMIT(iIndex, OBJMAX) == FALSE ) return;
  18260. LPOBJ lpObj = &gObj[iIndex];
  18261. PMSG_ANS_MOVE_TO_CASTLE_HUNTZONE pMsg={0};
  18262.  
  18263. PHeadSubSetB((LPBYTE)&pMsg, 0xB9, 0x05, sizeof(pMsg));
  18264. pMsg.btResult = 0;
  18265. int iEnterTaxMoney = 0;
  18266.  
  18267. iEnterTaxMoney = g_CastleSiegeSync.GetTaxHuntZone(lpObj->m_Index, TRUE);
  18268. if ( iEnterTaxMoney < 0 )
  18269. iEnterTaxMoney = 0;
  18270.  
  18271. BOOL bPermission = FALSE;
  18272. if ( g_CastleSiege.GetHuntZoneEnter() )
  18273. bPermission = TRUE;
  18274.  
  18275. if ( lpObj->lpGuild )
  18276. {
  18277. if ( g_CastleSiege.CheckCastleOwnerUnionMember(lpObj->m_Index) )
  18278. bPermission = TRUE;
  18279.  
  18280. if ( g_CastleSiege.CheckCastleOwnerMember(lpObj->m_Index) )
  18281. bPermission = TRUE;
  18282. }
  18283. else if ( g_CastleSiege.GetHuntZoneEnter() )
  18284. bPermission = TRUE;
  18285.  
  18286. if ( bPermission == TRUE )
  18287. {
  18288. if ( lpObj->Money > iEnterTaxMoney )
  18289. {
  18290. if ( lpObj->MapNumber == MAP_INDEX_CASTLESIEGE )
  18291. {
  18292. if ( gObjMoveGate(lpObj->m_Index, 95) == TRUE )
  18293. {
  18294. pMsg.btResult = 1;
  18295. int iMoney = lpObj->Money;
  18296. lpObj->Money -= iEnterTaxMoney;
  18297.  
  18298. g_CastleSiegeSync.AddTributeMoney(iEnterTaxMoney);
  18299.  
  18300. if ( lpObj->Money < 0 )
  18301. lpObj->Money = 0;
  18302.  
  18303. GCMoneySend(lpObj->m_Index, lpObj->Money);
  18304.  
  18305. LogAddTD("[Castle HuntZone] [%s][%s] - Entrance TAX : %d - %d = %d",
  18306. lpObj->AccountID, lpObj->Name, iMoney, iEnterTaxMoney, lpObj->Money);
  18307. }
  18308. }
  18309. }
  18310. }
  18311. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18312. }
  18313.  
  18314. void CGReqJewelMix(PMSG_REQ_JEWEL_MIX * lpMsg, int iIndex)
  18315. {
  18316. if ( lpMsg == NULL )
  18317. return;
  18318.  
  18319. CJewelMixSystem::MixJewel(iIndex, lpMsg->btJewelType, lpMsg->btJewelMix);
  18320. }
  18321.  
  18322. struct PMSG_ANS_JEWEL_UNMIX
  18323. {
  18324. PBMSG_HEAD2 h; // C1:BC:[00:01]
  18325. BYTE btResult; // 4
  18326. };
  18327.  
  18328. void GCAnsJewelMix(int iIndex, int iResult)
  18329. {
  18330. PMSG_ANS_JEWEL_UNMIX pMsg;
  18331.  
  18332. PHeadSubSetB((LPBYTE)&pMsg, 0xBC, 0x00, sizeof(pMsg));
  18333. pMsg.btResult = iResult;
  18334.  
  18335. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18336. }
  18337.  
  18338. void CGReqJewelUnMix(PMSG_REQ_JEWEL_UNMIX * lpMsg, int iIndex)
  18339. {
  18340. if ( lpMsg == NULL )
  18341. return;
  18342.  
  18343. CJewelMixSystem::UnMixJewel(iIndex, lpMsg->btJewelType, lpMsg->btJewelLevel, lpMsg->btJewelPos);
  18344. }
  18345.  
  18346. void GCAnsJewelUnMix(int iIndex, int iResult)
  18347. {
  18348. PMSG_ANS_JEWEL_UNMIX pMsg;
  18349.  
  18350. PHeadSubSetB((LPBYTE)&pMsg, 0xBC, 0x01, sizeof(pMsg));
  18351. pMsg.btResult = iResult;
  18352.  
  18353. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18354. }
  18355.  
  18356. void CGReqCrywolfInfo(PMSG_REQ_CRYWOLF_INFO* lpMsg, int iIndex)
  18357. {
  18358. if ( !OBJMAX_RANGE(iIndex))
  18359. return;
  18360.  
  18361. LPOBJ lpObj = &gObj[iIndex];
  18362.  
  18363. GCAnsCrywolfInfo(iIndex, g_Crywolf.GetOccupationState(), g_Crywolf.GetCrywolfState());
  18364. }
  18365.  
  18366. void GCAnsCrywolfInfo(int iIndex, BYTE btOccupationState, BYTE btCrywolfState)
  18367. {
  18368. PMSG_ANS_CRYWOLF_INFO pMsg={0};
  18369.  
  18370. PHeadSubSetB((LPBYTE)&pMsg, 0xBD, 0x00, sizeof(pMsg));
  18371. pMsg.btOccupationState = btOccupationState;
  18372. pMsg.btCrywolfState = btCrywolfState;
  18373.  
  18374. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18375. }
  18376.  
  18377. struct PMSG_ANS_CRYWOLF_ALTAR_CONTRACT
  18378. {
  18379. PBMSG_HEAD2 h; // C1:BD:03
  18380. BYTE btResult; // 4
  18381. BYTE btAltarState; // 5
  18382. BYTE btObjIndexH; // 6
  18383. BYTE btObjIndexL; // 7
  18384. };
  18385.  
  18386. void CGReqAlatrContract(PMSG_REQ_CRYWOLF_ALTAR_CONTRACT* lpMsg, int iIndex)
  18387. {
  18388. int iAltarIndex = MAKE_NUMBERW(lpMsg->btObjIndexH, lpMsg->btObjIndexL);
  18389.  
  18390. if ( !OBJMAX_RANGE(iIndex))
  18391. return;
  18392.  
  18393. if ( !OBJMAX_RANGE(iAltarIndex))
  18394. return;
  18395.  
  18396. LPOBJ lpObj = &gObj[iIndex];
  18397. LPOBJ lpAltarObj = &gObj[iAltarIndex];
  18398.  
  18399. if ( !CRYWOLF_ALTAR_CLASS_RANGE(lpAltarObj->Class))
  18400. return;
  18401.  
  18402. if ( !gObjIsConnected(lpObj))
  18403. return;
  18404.  
  18405. PMSG_ANS_CRYWOLF_ALTAR_CONTRACT pMsg={0};
  18406.  
  18407. PHeadSubSetB((LPBYTE)&pMsg, 0xBD, 0x03, sizeof(pMsg));
  18408. pMsg.btResult = 0;
  18409. pMsg.btAltarState = g_CrywolfNPC_Altar.GetAltarState(lpAltarObj->Class);
  18410. pMsg.btObjIndexH = lpMsg->btObjIndexH;
  18411. pMsg.btObjIndexL = lpMsg->btObjIndexL;
  18412.  
  18413. if ( pMsg.btAltarState == 0 &&
  18414. lpObj->Type == OBJ_USER &&
  18415. lpObj->Class == CLASS_ELF &&
  18416. lpObj->Level >= MIN_ELF_LEVEL_ALTAR )
  18417. {
  18418. if ( g_CrywolfNPC_Altar.SetAltarUserIndex(iAltarIndex, lpAltarObj->Class, iIndex) != FALSE )
  18419. {
  18420. pMsg.btResult = 1;
  18421. }
  18422. }
  18423. else
  18424. {
  18425. MsgOutput(iIndex, lMsg.Get(MSGGET(13, 9))); // #error It says 360 when real is 260
  18426. }
  18427. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18428. }
  18429.  
  18430. struct PMSG_ANS_CRYWOLF_BENEFIT_PLUS_CHAOSRATE
  18431. {
  18432. PBMSG_HEAD2 h; // C1:BD:09
  18433. BYTE btPlusChaosRate; // 4
  18434. };
  18435.  
  18436. void CGReqPlusChaosRate(PMSG_REQ_CRYWOLF_BENEFIT_PLUS_CHAOSRATE* lpMsg, int iIndex)
  18437. {
  18438. if ( OBJMAX_RANGE(iIndex) == FALSE )
  18439. return;
  18440.  
  18441. PMSG_ANS_CRYWOLF_BENEFIT_PLUS_CHAOSRATE pMsg={0};
  18442.  
  18443. PHeadSubSetB((LPBYTE)&pMsg, 0xBD, 0x09, sizeof(pMsg));
  18444. pMsg.btPlusChaosRate = g_CrywolfSync.GetPlusChaosRate();
  18445.  
  18446. DataSend(iIndex, (LPBYTE)&pMsg, sizeof(pMsg));
  18447. }
  18448.  
  18449. void CGReqKanturuStateInfo(PMSG_REQ_KANTURU_STATE_INFO* lpMsg, int iIndex)
  18450. {
  18451. if ( OBJMAX_RANGE(iIndex) == FALSE )
  18452. return;
  18453. g_KanturuEntranceNPC.NotifyEntranceInfo(iIndex);
  18454. }
  18455.  
  18456. void GCReqEnterKanturuBossMap(PMSG_REQ_ENTER_KANTURU_BOSS_MAP* lpMsg, int iIndex)
  18457. {
  18458. if (OBJMAX_RANGE(iIndex) == FALSE)
  18459. return;
  18460. g_KanturuEntranceNPC.NotifyResultEnterKanturuBossMap(iIndex);
  18461. }
  18462.  
  18463.  
  18464. void CGReqEnterIllusionTemple(PMSG_ANS_ILLUSIONTEMPLE_ENTER* lpMsg, int iIndex) //case 0
  18465. {
  18466. if (OBJMAX_RANGE(iIndex) == FALSE )
  18467. {
  18468. LogAdd("return %s %d", __FILE__, __LINE__);
  18469. return;
  18470. }
  18471.  
  18472. g_IllusionTempleEvent.IllusionTempleAddUser(iIndex,lpMsg->btFloorIndex-1, lpMsg->TicketPos);
  18473. }
  18474.  
  18475. //void CGReqUseIllusionTempleKillCntSkill(PMSG_USE_ILLUSIONTEMPLE_KILLCOUNT_SKILL* lpMsg, int iIndex) //case 2
  18476. void CGReqUseIllusionTempleKillCntSkill(int aTargetIndex, unsigned char SkillId,int iIndex)
  18477. {
  18478. if ( OBJMAX_RANGE(iIndex) == FALSE )
  18479. {
  18480. LogAdd("return %s %d", __FILE__, __LINE__);
  18481. return;
  18482. }
  18483.  
  18484. //WORD TargetIndex = MAKE_NUMBERW( lpMsg->btTargetH, lpMsg->btTargetL );
  18485.  
  18486. g_IllusionTempleEvent.RunningSkill(iIndex, SkillId, aTargetIndex, 1);
  18487. }
  18488.  
  18489. void CGReqIllusionTempleDropReward(PMSG_ILLUSIONTEMPLE_DROP_REWARD* lpMsg, int iIndex) //case 5
  18490. {
  18491. if (OBJMAX_RANGE(iIndex) == FALSE )
  18492. {
  18493. LogAdd("return %s %d", __FILE__, __LINE__);
  18494. return;
  18495. }
  18496.  
  18497. g_IllusionTempleEvent.GiveItemReward(iIndex);
  18498. }
  18499.  
  18500. void GCSendIllusionTempleKillCount(int aIndex, BYTE KillCount)
  18501. {
  18502. PMSG_SEND_ILLUSIONTEMPLE_KILLCOUNT pMsg;
  18503.  
  18504. PHeadSubSetB((LPBYTE)&pMsg, 0xBF, 0x06, sizeof(pMsg));
  18505. pMsg.btKillCount = KillCount;
  18506. DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
  18507. }
  18508. #ifdef FIX_HP_MP
  18509. void GCSendRecupationInfo(int aIndex)
  18510. {
  18511. PMSG_SEND_RECUPATION_INFO pMsg;
  18512. LPOBJ lpObj = &gObj[aIndex];
  18513. PHeadSubSetB((LPBYTE)&pMsg, 0xF9, 0x04, sizeof(pMsg));
  18514. pMsg.MaxLife = lpObj->MaxLife+lpObj->AddLife;
  18515. pMsg.life = lpObj->Life;
  18516. pMsg.MaxMana = lpObj->MaxMana+lpObj->AddMana;
  18517. pMsg.Mana = lpObj->Mana;
  18518. pMsg.MaxSD = lpObj->iMaxShield+lpObj->iAddShield;
  18519. pMsg.SD = lpObj->iShield;
  18520. pMsg.MaxStamina = lpObj->MaxBP+lpObj->AddBP;
  18521. pMsg.Stanina = lpObj->BP;
  18522. DataSend(aIndex,(LPBYTE)&pMsg,pMsg.h.size);
  18523. }
  18524.  
  18525.  
  18526. #endif
  18527. #ifdef MULTI_WAREHOUSE
  18528.  
  18529. DWORD ReturnMoneyForCreateWarehouse(int aIndex)
  18530. {
  18531. LPOBJ lpObj = &gObj[aIndex];
  18532. DWORD PriceOpen = 60000 * (lpObj->TotalWarehouseHave);
  18533.  
  18534. return PriceOpen;
  18535. }
  18536. void OpenMultiWarehouse(int aIndex)
  18537. {
  18538.  
  18539. LPOBJ lpObj = &gObj[aIndex];
  18540. DWORD PriceOpen = ReturnMoneyForCreateWarehouse(aIndex);
  18541. //WORD loWord = SET_NUMBERLW(money);
  18542. PMSG_OPEN_MULTI_WAREHOUSE pMsg;
  18543.  
  18544. PHeadSetB((LPBYTE)&pMsg, 0xFE, sizeof(pMsg));
  18545. pMsg.TotalZen = PriceOpen;
  18546. pMsg.TotalWarehouseHave = lpObj->TotalWarehouseHave;
  18547. //pMsg.TotalZen2 = SET_NUMBERLW(money);
  18548. DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size);
  18549.  
  18550. }
  18551. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement