Guest User

exchange.cpp

a guest
Aug 30th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.39 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "../../libgame/include/grid.h"
  3. #include "utils.h"
  4. #include "desc.h"
  5. #include "desc_client.h"
  6. #include "char.h"
  7. #include "item.h"
  8. #include "item_manager.h"
  9. #include "packet.h"
  10. #include "log.h"
  11. #include "db.h"
  12. #include "locale_service.h"
  13. #include "../../common/length.h"
  14. #include "exchange.h"
  15. #include "DragonSoul.h"
  16.  
  17. void exchange_packet(LPCHARACTER ch, BYTE sub_header, bool is_me, DWORD arg1, TItemPos arg2, DWORD arg3, void * pvData = NULL);
  18.  
  19. // 교환 패킷
  20. void exchange_packet(LPCHARACTER ch, BYTE sub_header, bool is_me, DWORD arg1, TItemPos arg2, DWORD arg3, void * pvData)
  21. {
  22. if (!ch->GetDesc())
  23. return;
  24.  
  25. struct packet_exchange pack_exchg;
  26.  
  27. pack_exchg.header = HEADER_GC_EXCHANGE;
  28. pack_exchg.sub_header = sub_header;
  29. pack_exchg.is_me = is_me;
  30. pack_exchg.arg1 = arg1;
  31. pack_exchg.arg2 = arg2;
  32. pack_exchg.arg3 = arg3;
  33.  
  34. if (sub_header == EXCHANGE_SUBHEADER_GC_ITEM_ADD && pvData)
  35. {
  36. thecore_memcpy(&pack_exchg.alSockets, ((LPITEM) pvData)->GetSockets(), sizeof(pack_exchg.alSockets));
  37. thecore_memcpy(&pack_exchg.aAttr, ((LPITEM) pvData)->GetAttributes(), sizeof(pack_exchg.aAttr));
  38. }
  39. else
  40. {
  41. memset(&pack_exchg.alSockets, 0, sizeof(pack_exchg.alSockets));
  42. memset(&pack_exchg.aAttr, 0, sizeof(pack_exchg.aAttr));
  43. }
  44.  
  45. ch->GetDesc()->Packet(&pack_exchg, sizeof(pack_exchg));
  46. }
  47.  
  48. // 교환을 시작
  49. bool CHARACTER::ExchangeStart(LPCHARACTER victim)
  50. {
  51. if (this == victim) // 자기 자신과는 교환을 못한다.
  52. return false;
  53.  
  54. if (IsObserverMode())
  55. {
  56. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("관전 상태에서는 교환을 할 수 없습니다."));
  57. return false;
  58. }
  59.  
  60. if (victim->IsNPC())
  61. return false;
  62.  
  63. //PREVENT_TRADE_WINDOW
  64. if ( IsOpenSafebox() || GetShopOwner() || GetMyShop() || IsCubeOpen())
  65. {
  66. ChatPacket( CHAT_TYPE_INFO, LC_TEXT("다른 거래창이 열려있을경우 거래를 할수 없습니다." ) );
  67. return false;
  68. }
  69.  
  70. if ( victim->IsOpenSafebox() || victim->GetShopOwner() || victim->GetMyShop() || victim->IsCubeOpen() )
  71. {
  72. ChatPacket( CHAT_TYPE_INFO, LC_TEXT("상대방이 다른 거래중이라 거래를 할수 없습니다." ) );
  73. return false;
  74. }
  75. //END_PREVENT_TRADE_WINDOW
  76. int iDist = DISTANCE_APPROX(GetX() - victim->GetX(), GetY() - victim->GetY());
  77.  
  78. // 거리 체크
  79. if (iDist >= EXCHANGE_MAX_DISTANCE)
  80. return false;
  81.  
  82. if (GetExchange())
  83. return false;
  84.  
  85. if (victim->GetExchange())
  86. {
  87. exchange_packet(this, EXCHANGE_SUBHEADER_GC_ALREADY, 0, 0, NPOS, 0);
  88. return false;
  89. }
  90.  
  91. if (victim->IsBlockMode(BLOCK_EXCHANGE))
  92. {
  93. ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방이 교환 거부 상태입니다."));
  94. return false;
  95. }
  96.  
  97. SetExchange(M2_NEW CExchange(this));
  98. victim->SetExchange(M2_NEW CExchange(victim));
  99.  
  100. victim->GetExchange()->SetCompany(GetExchange());
  101. GetExchange()->SetCompany(victim->GetExchange());
  102.  
  103. //
  104. SetExchangeTime();
  105. victim->SetExchangeTime();
  106.  
  107. exchange_packet(victim, EXCHANGE_SUBHEADER_GC_START, 0, GetVID(), NPOS, 0);
  108. exchange_packet(this, EXCHANGE_SUBHEADER_GC_START, 0, victim->GetVID(), NPOS, 0);
  109.  
  110. return true;
  111. }
  112.  
  113. CExchange::CExchange(LPCHARACTER pOwner)
  114. {
  115. m_pCompany = NULL;
  116.  
  117. m_bAccept = false;
  118.  
  119. for (int i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
  120. {
  121. m_apItems[i] = NULL;
  122. m_aItemPos[i] = NPOS;
  123. m_abItemDisplayPos[i] = 0;
  124. }
  125.  
  126. m_lGold = 0;
  127.  
  128. m_pOwner = pOwner;
  129. pOwner->SetExchange(this);
  130.  
  131. m_pGrid = M2_NEW CGrid(4,3);
  132. }
  133.  
  134. CExchange::~CExchange()
  135. {
  136. M2_DELETE(m_pGrid);
  137. }
  138.  
  139. bool CExchange::AddItem(TItemPos item_pos, BYTE display_pos)
  140. {
  141. assert(m_pOwner != NULL && GetCompany());
  142.  
  143. if (!item_pos.IsValidItemPosition())
  144. return false;
  145.  
  146. // 장비는 교환할 수 없음
  147. if (item_pos.IsEquipPosition())
  148. return false;
  149.  
  150. LPITEM item;
  151.  
  152. if (!(item = m_pOwner->GetItem(item_pos)))
  153. return false;
  154.  
  155. if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_GIVE))
  156. {
  157. m_pOwner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("아이템을 건네줄 수 없습니다."));
  158. return false;
  159. }
  160.  
  161. if (true == item->isLocked())
  162. {
  163. return false;
  164. }
  165.  
  166. // 이미 교환창에 추가된 아이템인가?
  167. if (item->IsExchanging())
  168. {
  169. sys_log(0, "EXCHANGE under exchanging");
  170. return false;
  171. }
  172.  
  173. if (!m_pGrid->IsEmpty(display_pos, 1, item->GetSize()))
  174. {
  175. sys_log(0, "EXCHANGE not empty item_pos %d %d %d", display_pos, 1, item->GetSize());
  176. return false;
  177. }
  178.  
  179. Accept(false);
  180. GetCompany()->Accept(false);
  181.  
  182. for (int i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
  183. {
  184. if (m_apItems[i])
  185. continue;
  186.  
  187. m_apItems[i] = item;
  188. m_aItemPos[i] = item_pos;
  189. m_abItemDisplayPos[i] = display_pos;
  190. m_pGrid->Put(display_pos, 1, item->GetSize());
  191.  
  192. item->SetExchanging(true);
  193.  
  194. exchange_packet(m_pOwner,
  195. EXCHANGE_SUBHEADER_GC_ITEM_ADD,
  196. true,
  197. item->GetVnum(),
  198. TItemPos(RESERVED_WINDOW, display_pos),
  199. item->GetCount(),
  200. item);
  201.  
  202. exchange_packet(GetCompany()->GetOwner(),
  203. EXCHANGE_SUBHEADER_GC_ITEM_ADD,
  204. false,
  205. item->GetVnum(),
  206. TItemPos(RESERVED_WINDOW, display_pos),
  207. item->GetCount(),
  208. item);
  209.  
  210. sys_log(0, "EXCHANGE AddItem success %s pos(%d, %d) %d", item->GetName(), item_pos.window_type, item_pos.cell, display_pos);
  211.  
  212. return true;
  213. }
  214.  
  215. // 추가할 공간이 없음
  216. return false;
  217. }
  218.  
  219. bool CExchange::RemoveItem(BYTE pos)
  220. {
  221. if (pos >= EXCHANGE_ITEM_MAX_NUM)
  222. return false;
  223.  
  224. if (!m_apItems[pos])
  225. return false;
  226.  
  227. TItemPos PosOfInventory = m_aItemPos[pos];
  228. m_apItems[pos]->SetExchanging(false);
  229.  
  230. m_pGrid->Get(m_abItemDisplayPos[pos], 1, m_apItems[pos]->GetSize());
  231.  
  232. exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_ITEM_DEL, true, pos, NPOS, 0);
  233. exchange_packet(GetCompany()->GetOwner(), EXCHANGE_SUBHEADER_GC_ITEM_DEL, false, pos, PosOfInventory, 0);
  234.  
  235. Accept(false);
  236. GetCompany()->Accept(false);
  237.  
  238. m_apItems[pos] = NULL;
  239. m_aItemPos[pos] = NPOS;
  240. m_abItemDisplayPos[pos] = 0;
  241. return true;
  242. }
  243.  
  244. bool CExchange::AddGold(long gold)
  245. {
  246. if (gold <= 0)
  247. return false;
  248.  
  249. if (GetOwner()->GetGold() < gold)
  250. {
  251. // 가지고 있는 돈이 부족.
  252. exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_LESS_GOLD, 0, 0, NPOS, 0);
  253. return false;
  254. }
  255.  
  256. if ( LC_IsCanada() == true || LC_IsEurope() == true )
  257. {
  258. if ( m_lGold > 0 )
  259. {
  260. return false;
  261. }
  262. }
  263.  
  264. Accept(false);
  265. GetCompany()->Accept(false);
  266.  
  267. m_lGold = gold;
  268.  
  269. exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_GOLD_ADD, true, m_lGold, NPOS, 0);
  270. exchange_packet(GetCompany()->GetOwner(), EXCHANGE_SUBHEADER_GC_GOLD_ADD, false, m_lGold, NPOS, 0);
  271. return true;
  272. }
  273.  
  274. // 돈이 충분히 있는지, 교환하려는 아이템이 실제로 있는지 확인 한다.
  275. bool CExchange::Check(int * piItemCount)
  276. {
  277. if (GetOwner()->GetGold() < m_lGold)
  278. return false;
  279.  
  280. int item_count = 0;
  281.  
  282. for (int i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
  283. {
  284. if (!m_apItems[i])
  285. continue;
  286.  
  287. if (!m_aItemPos[i].IsValidItemPosition())
  288. return false;
  289.  
  290. if (m_apItems[i] != GetOwner()->GetItem(m_aItemPos[i]))
  291. return false;
  292.  
  293. ++item_count;
  294. }
  295.  
  296. *piItemCount = item_count;
  297. return true;
  298. }
  299.  
  300. bool CExchange::CheckSpace()
  301. {
  302. static CGrid s_grid1(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 1 9 Rows a 5 Columns
  303. static CGrid s_grid2(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 2 9 Rows a 5 Columns
  304. static CGrid s_grid3(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 3 9 Rows a 5 Columns
  305. static CGrid s_grid4(5, INVENTORY_MAX_NUM / 5 / 4); // inven page 4 9 Rows a 5 Columns
  306.  
  307. s_grid1.Clear();
  308. s_grid2.Clear();
  309. s_grid3.Clear();
  310. s_grid4.Clear();
  311.  
  312. LPCHARACTER victim = GetCompany()->GetOwner();
  313. LPITEM item;
  314.  
  315. int i;
  316.  
  317. const int perPageSlotCount = INVENTORY_MAX_NUM / 4;
  318.  
  319. for (i = 0; i < INVENTORY_MAX_NUM; ++i) {
  320. if (!(item = victim->GetInventoryItem(i)))
  321. continue;
  322.  
  323. BYTE itemSize = item->GetSize();
  324.  
  325. if (i < perPageSlotCount) //
  326. s_grid1.Put(i, 1, itemSize);
  327. else if (i < perPageSlotCount * 2)
  328. s_grid2.Put(i - perPageSlotCount, 1, itemSize);
  329. else if (i < perPageSlotCount * 3)
  330. s_grid3.Put(i - perPageSlotCount * 2, 1, itemSize);
  331. else
  332. s_grid4.Put(i - perPageSlotCount * 3, 1, itemSize);
  333. }
  334.  
  335. // 아... 뭔가 개병신 같지만... 용혼석 인벤을 노멀 인벤 보고 따라 만든 내 잘못이다 ㅠㅠ
  336. static std::vector <WORD> s_vDSGrid(DRAGON_SOUL_INVENTORY_MAX_NUM);
  337.  
  338. // 일단 용혼석을 교환하지 않을 가능성이 크므로, 용혼석 인벤 복사는 용혼석이 있을 때 하도록 한다.
  339. bool bDSInitialized = false;
  340.  
  341. for (i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
  342. {
  343. if (!(item = m_apItems[i]))
  344. continue;
  345.  
  346. if (item->IsDragonSoul())
  347. {
  348. if (!victim->DragonSoul_IsQualified())
  349. {
  350. return false;
  351. }
  352.  
  353. if (!bDSInitialized)
  354. {
  355. bDSInitialized = true;
  356. victim->CopyDragonSoulItemGrid(s_vDSGrid);
  357. }
  358.  
  359. bool bExistEmptySpace = false;
  360. WORD wBasePos = DSManager::instance().GetBasePosition(item);
  361. if (wBasePos >= DRAGON_SOUL_INVENTORY_MAX_NUM)
  362. return false;
  363.  
  364. for (int i = 0; i < DRAGON_SOUL_BOX_SIZE; i++)
  365. {
  366. WORD wPos = wBasePos + i;
  367. if (0 == s_vDSGrid[wBasePos])
  368. {
  369. bool bEmpty = true;
  370. for (int j = 1; j < item->GetSize(); j++)
  371. {
  372. if (s_vDSGrid[wPos + j * DRAGON_SOUL_BOX_COLUMN_NUM])
  373. {
  374. bEmpty = false;
  375. break;
  376. }
  377. }
  378. if (bEmpty)
  379. {
  380. for (int j = 0; j < item->GetSize(); j++)
  381. {
  382. s_vDSGrid[wPos + j * DRAGON_SOUL_BOX_COLUMN_NUM] = wPos + 1;
  383. }
  384. bExistEmptySpace = true;
  385. break;
  386. }
  387. }
  388. if (bExistEmptySpace)
  389. break;
  390. }
  391. if (!bExistEmptySpace)
  392. return false;
  393. }
  394. else
  395. {
  396. int iPos = s_grid1.FindBlank(1, item->GetSize());
  397.  
  398. if (iPos >= 0)
  399. {
  400. s_grid1.Put(iPos, 1, item->GetSize());
  401. }
  402. else
  403. {
  404. iPos = s_grid2.FindBlank(1, item->GetSize());
  405.  
  406. if (iPos >= 0)
  407. {
  408. s_grid2.Put(iPos, 1, item->GetSize());
  409. }
  410. else
  411. {
  412. iPos = s_grid3.FindBlank(1, item->GetSize());
  413.  
  414. if (iPos >= 0)
  415. {
  416. s_grid3.Put(iPos, 1, item->GetSize());
  417. }
  418. else
  419. {
  420. iPos = s_grid4.FindBlank(1, item->GetSize());
  421.  
  422. if (iPos >= 0)
  423. {
  424. s_grid4.Put(iPos, 1, item->GetSize());
  425. }
  426. else
  427. {
  428. return false;
  429. }
  430. }
  431. }
  432. }
  433. }
  434. }
  435. return true;
  436. }
  437.  
  438. // 교환 끝 (아이템과 돈 등을 실제로 옮긴다)
  439. bool CExchange::Done()
  440. {
  441. int empty_pos, i;
  442. LPITEM item;
  443.  
  444. LPCHARACTER victim = GetCompany()->GetOwner();
  445. GetOwner()->CreateFly(6,victim);
  446.  
  447. for (i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
  448. {
  449. if (!(item = m_apItems[i]))
  450. continue;
  451.  
  452. if (item->IsDragonSoul())
  453. empty_pos = victim->GetEmptyDragonSoulInventory(item);
  454. else
  455. empty_pos = victim->GetEmptyInventory(item->GetSize());
  456.  
  457. if (empty_pos < 0)
  458. {
  459. sys_err("Exchange::Done : Cannot find blank position in inventory %s <-> %s item %s",
  460. m_pOwner->GetName(), victim->GetName(), item->GetName());
  461. continue;
  462. }
  463.  
  464. assert(empty_pos >= 0);
  465.  
  466. if (item->GetVnum() == 90008 || item->GetVnum() == 90009) // VCARD
  467. {
  468. VCardUse(m_pOwner, victim, item);
  469. continue;
  470. }
  471.  
  472. m_pOwner->SyncQuickslot(QUICKSLOT_TYPE_ITEM, item->GetCell(), 255);
  473.  
  474. item->RemoveFromCharacter();
  475. if (item->IsDragonSoul())
  476. item->AddToCharacter(victim, TItemPos(DRAGON_SOUL_INVENTORY, empty_pos));
  477. else
  478. item->AddToCharacter(victim, TItemPos(INVENTORY, empty_pos));
  479. ITEM_MANAGER::instance().FlushDelayedSave(item);
  480.  
  481. GetOwner()->CreateFly(5,victim);
  482. item->SetExchanging(false);
  483. {
  484. char exchange_buf[51];
  485.  
  486. snprintf(exchange_buf, sizeof(exchange_buf), "%s %u %u", item->GetName(), GetOwner()->GetPlayerID(), item->GetCount());
  487. LogManager::instance().ItemLog(victim, item, "EXCHANGE_TAKE", exchange_buf);
  488.  
  489. snprintf(exchange_buf, sizeof(exchange_buf), "%s %u %u", item->GetName(), victim->GetPlayerID(), item->GetCount());
  490. LogManager::instance().ItemLog(GetOwner(), item, "EXCHANGE_GIVE", exchange_buf);
  491.  
  492. if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
  493. {
  494. LogManager::instance().GoldBarLog(victim->GetPlayerID(), item->GetID(), EXCHANGE_TAKE, "");
  495. LogManager::instance().GoldBarLog(GetOwner()->GetPlayerID(), item->GetID(), EXCHANGE_GIVE, "");
  496. }
  497. }
  498.  
  499. m_apItems[i] = NULL;
  500. }
  501.  
  502. if (m_lGold)
  503. {
  504. for (int i = 1; i < m_lGold+1; i=i+500000)
  505. GetOwner()->CreateFly(4,victim); // 1 Fly pro 500k . dh max 20 auf einmal (TradeLimit: 10kkk
  506. GetOwner()->PointChange(POINT_GOLD, -m_lGold, true);
  507. victim->PointChange(POINT_GOLD, m_lGold, true);
  508.  
  509. if (m_lGold > 1000)
  510. {
  511. char exchange_buf[51];
  512. snprintf(exchange_buf, sizeof(exchange_buf), "%u %s", GetOwner()->GetPlayerID(), GetOwner()->GetName());
  513. LogManager::instance().CharLog(victim, m_lGold, "EXCHANGE_GOLD_TAKE", exchange_buf);
  514.  
  515. snprintf(exchange_buf, sizeof(exchange_buf), "%u %s", victim->GetPlayerID(), victim->GetName());
  516. LogManager::instance().CharLog(GetOwner(), m_lGold, "EXCHANGE_GOLD_GIVE", exchange_buf);
  517. }
  518. }
  519.  
  520. m_pGrid->Clear();
  521. return true;
  522. }
  523.  
  524. // 교환을 동의
  525. bool CExchange::Accept(bool bAccept)
  526. {
  527. if (m_bAccept == bAccept)
  528. return true;
  529.  
  530. m_bAccept = bAccept;
  531.  
  532. // 둘 다 동의 했으므로 교환 성립
  533. if (m_bAccept && GetCompany()->m_bAccept)
  534. {
  535. int iItemCount;
  536.  
  537. LPCHARACTER victim = GetCompany()->GetOwner();
  538.  
  539. //PREVENT_PORTAL_AFTER_EXCHANGE
  540. GetOwner()->SetExchangeTime();
  541. victim->SetExchangeTime();
  542. //END_PREVENT_PORTAL_AFTER_EXCHANGE
  543.  
  544. // exchange_check 에서는 교환할 아이템들이 제자리에 있나 확인하고,
  545. // 엘크도 충분히 있나 확인한다, 두번째 인자로 교환할 아이템 개수
  546. // 를 리턴한다.
  547. if (!Check(&iItemCount))
  548. {
  549. GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈이 부족하거나 아이템이 제자리에 없습니다."));
  550. victim->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방의 돈이 부족하거나 아이템이 제자리에 없습니다."));
  551. goto EXCHANGE_END;
  552. }
  553.  
  554. // 리턴 받은 아이템 개수로 상대방의 소지품에 남은 자리가 있나 확인한다.
  555. if (!CheckSpace())
  556. {
  557. GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방의 소지품에 빈 공간이 없습니다."));
  558. victim->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지품에 빈 공간이 없습니다."));
  559. goto EXCHANGE_END;
  560. }
  561.  
  562. // 상대방도 마찬가지로..
  563. if (!GetCompany()->Check(&iItemCount))
  564. {
  565. victim->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("돈이 부족하거나 아이템이 제자리에 없습니다."));
  566. GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방의 돈이 부족하거나 아이템이 제자리에 없습니다."));
  567. goto EXCHANGE_END;
  568. }
  569.  
  570. if (!GetCompany()->CheckSpace())
  571. {
  572. victim->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("상대방의 소지품에 빈 공간이 없습니다."));
  573. GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지품에 빈 공간이 없습니다."));
  574. goto EXCHANGE_END;
  575. }
  576.  
  577. if (db_clientdesc->GetSocket() == INVALID_SOCKET)
  578. {
  579. sys_err("Cannot use exchange feature while DB cache connection is dead.");
  580. victim->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
  581. GetOwner()->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
  582. goto EXCHANGE_END;
  583. }
  584.  
  585. if (Done())
  586. {
  587. if (m_lGold) // 돈이 있을 ‹š만 저장
  588. GetOwner()->Save();
  589.  
  590. if (GetCompany()->Done())
  591. {
  592. if (GetCompany()->m_lGold) // 돈이 있을 때만 저장
  593. victim->Save();
  594.  
  595. // INTERNATIONAL_VERSION
  596. GetOwner()->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님과의 교환이 성사 되었습니다."), victim->GetName());
  597. victim->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s 님과의 교환이 성사 되었습니다."), GetOwner()->GetName());
  598. // END_OF_INTERNATIONAL_VERSION
  599. }
  600. }
  601.  
  602. EXCHANGE_END:
  603. Cancel();
  604. return false;
  605. }
  606. else
  607. {
  608. // 아니면 accept에 대한 패킷을 보내자.
  609. exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_ACCEPT, true, m_bAccept, NPOS, 0);
  610. exchange_packet(GetCompany()->GetOwner(), EXCHANGE_SUBHEADER_GC_ACCEPT, false, m_bAccept, NPOS, 0);
  611. return true;
  612. }
  613. }
  614.  
  615. // 교환 취소
  616. void CExchange::Cancel()
  617. {
  618. exchange_packet(GetOwner(), EXCHANGE_SUBHEADER_GC_END, 0, 0, NPOS, 0);
  619. GetOwner()->SetExchange(NULL);
  620.  
  621. for (int i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
  622. {
  623. if (m_apItems[i])
  624. m_apItems[i]->SetExchanging(false);
  625. }
  626.  
  627. if (GetCompany())
  628. {
  629. GetCompany()->SetCompany(NULL);
  630. GetCompany()->Cancel();
  631. }
  632.  
  633. M2_DELETE(this);
  634. }
Advertisement
Add Comment
Please, Sign In to add comment