Otclient  14/8/2020
protocolgameparse.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #include "protocolgame.h"
24 
25 #include "localplayer.h"
26 #include "thingtypemanager.h"
27 #include "game.h"
28 #include "map.h"
29 #include "item.h"
30 #include "effect.h"
31 #include "missile.h"
32 #include "tile.h"
33 #include "luavaluecasts.h"
35 
36 void ProtocolGame::parseMessage(const InputMessagePtr& msg)
37 {
38  int opcode = -1;
39  int prevOpcode = -1;
40 
41  try {
42  while(!msg->eof()) {
43  opcode = msg->getU8();
44 
45  // must be > so extended will be enabled before GameStart.
47  if(!m_gameInitialized && opcode > Proto::GameServerFirstGameOpcode) {
49  m_gameInitialized = true;
50  }
51  }
52 
53  // try to parse in lua first
54  int readPos = msg->getReadPos();
55  if(callLuaField<bool>("onOpcode", opcode, msg))
56  continue;
57  else
58  msg->setReadPos(readPos); // restore read pos
59 
60  switch(opcode) {
63  parsePendingGame(msg);
64  else
65  parseLogin(msg);
66  break;
68  parseGMActions(msg);
69  break;
71  parseUpdateNeeded(msg);
72  break;
74  parseLoginError(msg);
75  break;
77  parseLoginAdvice(msg);
78  break;
80  parseLoginWait(msg);
81  break;
83  parseLoginToken(msg);
84  break;
89  parsePingBack(msg);
90  else
91  parsePing(msg);
92  break;
94  parseChallenge(msg);
95  break;
97  parseDeath(msg);
98  break;
100  parseMapDescription(msg);
101  break;
103  parseMapMoveNorth(msg);
104  break;
106  parseMapMoveEast(msg);
107  break;
109  parseMapMoveSouth(msg);
110  break;
112  parseMapMoveWest(msg);
113  break;
115  parseUpdateTile(msg);
116  break;
118  parseTileAddThing(msg);
119  break;
121  parseTileTransformThing(msg);
122  break;
124  parseTileRemoveThing(msg);
125  break;
127  parseCreatureMove(msg);
128  break;
130  parseOpenContainer(msg);
131  break;
133  parseCloseContainer(msg);
134  break;
136  parseContainerAddItem(msg);
137  break;
139  parseContainerUpdateItem(msg);
140  break;
142  parseContainerRemoveItem(msg);
143  break;
145  parseAddInventoryItem(msg);
146  break;
148  parseRemoveInventoryItem(msg);
149  break;
151  parseOpenNpcTrade(msg);
152  break;
154  parsePlayerGoods(msg);
155  break;
157  parseCloseNpcTrade(msg);
158  break;
160  parseOwnTrade(msg);
161  break;
163  parseCounterTrade(msg);
164  break;
166  parseCloseTrade(msg);
167  break;
169  parseWorldLight(msg);
170  break;
172  parseMagicEffect(msg);
173  break;
175  parseAnimatedText(msg);
176  break;
178  parseDistanceMissile(msg);
179  break;
181  parseCreatureMark(msg);
182  break;
184  parseTrappers(msg);
185  break;
187  parseCreatureHealth(msg);
188  break;
190  parseCreatureLight(msg);
191  break;
193  parseCreatureOutfit(msg);
194  break;
196  parseCreatureSpeed(msg);
197  break;
199  parseCreatureSkulls(msg);
200  break;
202  parseCreatureShields(msg);
203  break;
205  parseCreatureUnpass(msg);
206  break;
208  parseEditText(msg);
209  break;
211  parseEditList(msg);
212  break;
213  // PROTOCOL>=1038
215  parsePremiumTrigger(msg);
216  break;
218  parsePlayerStats(msg);
219  break;
221  parsePlayerSkills(msg);
222  break;
224  parsePlayerState(msg);
225  break;
227  parsePlayerCancelAttack(msg);
228  break;
230  parsePlayerModes(msg);
231  break;
233  parseTalk(msg);
234  break;
236  parseChannelList(msg);
237  break;
239  parseOpenChannel(msg);
240  break;
242  parseOpenPrivateChannel(msg);
243  break;
245  parseRuleViolationChannel(msg);
246  break;
248  parseRuleViolationRemove(msg);
249  break;
251  parseRuleViolationCancel(msg);
252  break;
254  parseRuleViolationLock(msg);
255  break;
257  parseOpenOwnPrivateChannel(msg);
258  break;
260  parseCloseChannel(msg);
261  break;
263  parseTextMessage(msg);
264  break;
266  parseCancelWalk(msg);
267  break;
269  parseWalkWait(msg);
270  break;
272  parseFloorChangeUp(msg);
273  break;
275  parseFloorChangeDown(msg);
276  break;
278  parseOpenOutfitWindow(msg);
279  break;
281  parseVipAdd(msg);
282  break;
284  parseVipState(msg);
285  break;
287  parseVipLogout(msg);
288  break;
290  parseTutorialHint(msg);
291  break;
293  parseAutomapFlag(msg);
294  break;
296  parseQuestLog(msg);
297  break;
299  parseQuestLine(msg);
300  break;
301  // PROTOCOL>=870
303  parseSpellCooldown(msg);
304  break;
306  parseSpellGroupCooldown(msg);
307  break;
309  parseMultiUseCooldown(msg);
310  break;
311  // PROTOCOL>=910
313  parseChannelEvent(msg);
314  break;
316  parseItemInfo(msg);
317  break;
319  parsePlayerInventory(msg);
320  break;
321  // PROTOCOL>=950
323  parsePlayerInfo(msg);
324  break;
325  // PROTOCOL>=970
327  parseModalDialog(msg);
328  break;
329  // PROTOCOL>=980
331  parseLogin(msg);
332  break;
334  parseEnterGame(msg);
335  break;
337  parsePlayerHelpers(msg);
338  break;
339  // PROTOCOL>=1000
341  parseCreaturesMark(msg);
342  break;
344  parseCreatureType(msg);
345  break;
346  // PROTOCOL>=1055
348  parseBlessings(msg);
349  break;
351  parseUnjustifiedStats(msg);
352  break;
354  parsePvpSituations(msg);
355  break;
357  parsePreset(msg);
358  break;
359  // PROTOCOL>=1080
361  parseCoinBalanceUpdating(msg);
362  break;
364  parseCoinBalance(msg);
365  break;
367  parseRequestPurchaseData(msg);
368  break;
370  parseCompleteStorePurchase(msg);
371  break;
373  parseStoreOffers(msg);
374  break;
376  parseStoreTransactionHistory(msg);
377  break;
379  parseStoreError(msg);
380  break;
382  parseStore(msg);
383  break;
384  // PROTOCOL>=1097
386  parseStoreButtonIndicators(msg);
387  break;
389  parseSetStoreDeepLink(msg);
390  break;
391  // otclient ONLY
393  parseExtendedOpcode(msg);
394  break;
396  parseChangeMapAwareRange(msg);
397  break;
398  default:
399  stdext::throw_exception(stdext::format("unhandled opcode %d", (int)opcode));
400  break;
401  }
402  prevOpcode = opcode;
403  }
404  } catch(stdext::exception& e) {
405  g_logger.error(stdext::format("ProtocolGame parse message exception (%d bytes unread, last opcode is %d, prev opcode is %d): %s",
406  msg->getUnreadSize(), opcode, prevOpcode, e.what()));
407  }
408 }
409 
410 void ProtocolGame::parseLogin(const InputMessagePtr& msg)
411 {
412  uint playerId = msg->getU32();
413  int serverBeat = msg->getU16();
414 
416  double speedA = msg->getDouble();
417  double speedB = msg->getDouble();
418  double speedC = msg->getDouble();
419  m_localPlayer->setSpeedFormula(speedA, speedB, speedC);
420  }
421  bool canReportBugs = msg->getU8();
422 
423  if(g_game.getClientVersion() >= 1054)
424  msg->getU8(); // can change pvp frame option
425 
426  if(g_game.getClientVersion() >= 1058) {
427  int expertModeEnabled = msg->getU8();
428  g_game.setExpertPvpMode(expertModeEnabled);
429  }
430 
432  // URL to ingame store images
433  msg->getString();
434 
435  // premium coin package size
436  // e.g you can only buy packs of 25, 50, 75, .. coins in the market
437  msg->getU16();
438  }
439 
440  m_localPlayer->setId(playerId);
441  g_game.setServerBeat(serverBeat);
443 
445 }
446 
447 void ProtocolGame::parsePendingGame(const InputMessagePtr&)
448 {
449  //set player to pending game state
451 }
452 
453 void ProtocolGame::parseEnterGame(const InputMessagePtr&)
454 {
455  //set player to entered game state
457 
458  if(!m_gameInitialized) {
460  m_gameInitialized = true;
461  }
462 }
463 
464 void ProtocolGame::parseStoreButtonIndicators(const InputMessagePtr& msg)
465 {
466  msg->getU8(); // unknown
467  msg->getU8(); // unknown
468 }
469 
470 void ProtocolGame::parseSetStoreDeepLink(const InputMessagePtr& msg)
471 {
472  msg->getU8(); // currentlyFeaturedServiceType
473 }
474 
475 void ProtocolGame::parseBlessings(const InputMessagePtr& msg)
476 {
477  uint16 blessings = msg->getU16();
478  m_localPlayer->setBlessings(blessings);
479 }
480 
481 void ProtocolGame::parsePreset(const InputMessagePtr& msg)
482 {
483  msg->getU32(); // preset
484 }
485 
486 void ProtocolGame::parseRequestPurchaseData(const InputMessagePtr& msg)
487 {
488  msg->getU32(); // transactionId
489  msg->getU8(); // productType
490 }
491 
492 void ProtocolGame::parseStore(const InputMessagePtr& msg)
493 {
494  parseCoinBalance(msg);
495 
496  int categories = msg->getU16();
497  for(int i = 0; i < categories; i++) {
498  std::string category = msg->getString();
499  std::string description = msg->getString();
500 
501  int highlightState = 0;
503  highlightState = msg->getU8();
504 
505  std::vector<std::string> icons;
506  int iconCount = msg->getU8();
507  for(int j = 0; j < iconCount; j++) {
508  std::string icon = msg->getString();
509  icons.push_back(icon);
510  }
511 
512  // If this is a valid category name then
513  // the category we just parsed is a child of that
514  msg->getString();
515  }
516 }
517 
518 void ProtocolGame::parseCoinBalance(const InputMessagePtr& msg)
519 {
520  bool update = msg->getU8() == 1;
521  int coins = -1;
522  int transferableCoins = -1;
523  if(update) {
524  // amount of coins that can be used to buy prodcuts
525  // in the ingame store
526  coins = msg->getU32();
527 
528  // amount of coins that can be sold in market
529  // or be transfered to another player
530  transferableCoins = msg->getU32();
531  }
532 }
533 
534 void ProtocolGame::parseCoinBalanceUpdating(const InputMessagePtr& msg)
535 {
536  // coin balance can be updating and might not be accurate
537  bool isUpdating = msg->getU8() == 1;
538 }
539 
540 void ProtocolGame::parseCompleteStorePurchase(const InputMessagePtr& msg)
541 {
542  // not used
543  msg->getU8();
544 
545  std::string message = msg->getString();
546  int coins = msg->getU32();
547  int transferableCoins = msg->getU32();
548 
549  g_logger.info(stdext::format("Purchase Complete: %s\nAvailable coins: %d (transferable: %d)", message, coins, transferableCoins));
550 }
551 
552 void ProtocolGame::parseStoreTransactionHistory(const InputMessagePtr &msg)
553 {
554  int currentPage;
555  if(g_game.getClientVersion() <= 1096) {
556  currentPage = msg->getU16();
557  msg->getU8(); // hasNextPage (bool)
558  } else {
559  currentPage = msg->getU32();
560  msg->getU32(); // pageCount
561  }
562 
563  int entries = msg->getU8();
564  for(int i = 0; i < entries; i++) {
565  int time = msg->getU16();
566  int productType = msg->getU8();
567  int coinChange = msg->getU32();
568  std::string productName = msg->getString();
569  g_logger.error(stdext::format("Time %i, type %i, change %i, product name %s", time, productType, coinChange, productName));
570  }
571 }
572 
573 void ProtocolGame::parseStoreOffers(const InputMessagePtr& msg)
574 {
575  msg->getString(); // categoryName
576 
577  int offers = msg->getU16();
578  for(int i = 0; i < offers; i++) {
579  msg->getU32(); // offerId
580  msg->getString(); // offerName
581  msg->getString(); // offerDescription
582 
583  msg->getU32(); // price
584  int highlightState = msg->getU8();
585  if(highlightState == 2 && g_game.getFeature(Otc::GameIngameStoreHighlights) && g_game.getClientVersion() >= 1097) {
586  msg->getU32(); // saleValidUntilTimestamp
587  msg->getU32(); // basePrice
588  }
589 
590  int disabledState = msg->getU8();
591  if(g_game.getFeature(Otc::GameIngameStoreHighlights) && disabledState == 1) {
592  msg->getString(); // disabledReason
593  }
594 
595  std::vector<std::string> icons;
596  int iconCount = msg->getU8();
597  for(int j = 0; j < iconCount; j++) {
598  std::string icon = msg->getString();
599  icons.push_back(icon);
600  }
601 
602  int subOffers = msg->getU16();
603  for(int j = 0; j < subOffers; j++) {
604  msg->getString(); // name
605  msg->getString(); // description
606 
607  int subIcons = msg->getU8();
608  for(int k = 0; k < subIcons; k++) {
609  msg->getString(); // icon
610  }
611  msg->getString(); // serviceType
612  }
613  }
614 }
615 
616 void ProtocolGame::parseStoreError(const InputMessagePtr& msg)
617 {
618  int errorType = msg->getU8();
619  std::string message = msg->getString();
620  g_logger.error(stdext::format("Store Error: %s [%i]", message, errorType));
621 }
622 
623 void ProtocolGame::parseUnjustifiedStats(const InputMessagePtr& msg)
624 {
625  UnjustifiedPoints unjustifiedPoints;
626  unjustifiedPoints.killsDay = msg->getU8();
627  unjustifiedPoints.killsDayRemaining = msg->getU8();
628  unjustifiedPoints.killsWeek = msg->getU8();
629  unjustifiedPoints.killsWeekRemaining = msg->getU8();
630  unjustifiedPoints.killsMonth = msg->getU8();
631  unjustifiedPoints.killsMonthRemaining = msg->getU8();
632  unjustifiedPoints.skullTime = msg->getU8();
633 
634  g_game.setUnjustifiedPoints(unjustifiedPoints);
635 }
636 
637 void ProtocolGame::parsePvpSituations(const InputMessagePtr& msg)
638 {
639  uint8 openPvpSituations = msg->getU8();
640 
641  g_game.setOpenPvpSituations(openPvpSituations);
642 }
643 
644 void ProtocolGame::parsePlayerHelpers(const InputMessagePtr& msg)
645 {
646  uint id = msg->getU32();
647  int helpers = msg->getU16();
648 
649  CreaturePtr creature = g_map.getCreatureById(id);
650  if(creature)
651  g_game.processPlayerHelpers(helpers);
652  else
653  g_logger.traceError(stdext::format("could not get creature with id %d", id));
654 }
655 
656 void ProtocolGame::parseGMActions(const InputMessagePtr& msg)
657 {
658  std::vector<uint8> actions;
659 
660  int numViolationReasons;
661 
662  if(g_game.getClientVersion() >= 850)
663  numViolationReasons = 20;
664  else if(g_game.getClientVersion() >= 840)
665  numViolationReasons = 23;
666  else
667  numViolationReasons = 32;
668 
669  for(int i = 0; i < numViolationReasons; ++i)
670  actions.push_back(msg->getU8());
671  g_game.processGMActions(actions);
672 }
673 
674 void ProtocolGame::parseUpdateNeeded(const InputMessagePtr& msg)
675 {
676  std::string signature = msg->getString();
677  g_game.processUpdateNeeded(signature);
678 }
679 
680 void ProtocolGame::parseLoginError(const InputMessagePtr& msg)
681 {
682  std::string error = msg->getString();
683 
684  g_game.processLoginError(error);
685 }
686 
687 void ProtocolGame::parseLoginAdvice(const InputMessagePtr& msg)
688 {
689  std::string message = msg->getString();
690 
691  g_game.processLoginAdvice(message);
692 }
693 
694 void ProtocolGame::parseLoginWait(const InputMessagePtr& msg)
695 {
696  std::string message = msg->getString();
697  int time = msg->getU8();
698 
699  g_game.processLoginWait(message, time);
700 }
701 
702 void ProtocolGame::parseLoginToken(const InputMessagePtr& msg)
703 {
704  bool unknown = (msg->getU8() == 0);
705  g_game.processLoginToken(unknown);
706 }
707 
708 void ProtocolGame::parsePing(const InputMessagePtr& msg)
709 {
711 }
712 
713 void ProtocolGame::parsePingBack(const InputMessagePtr& msg)
714 {
716 }
717 
718 void ProtocolGame::parseChallenge(const InputMessagePtr& msg)
719 {
720  uint timestamp = msg->getU32();
721  uint8 random = msg->getU8();
722 
723  sendLoginPacket(timestamp, random);
724 }
725 
726 void ProtocolGame::parseDeath(const InputMessagePtr& msg)
727 {
728  int penality = 100;
729  int deathType = Otc::DeathRegular;
730 
732  deathType = msg->getU8();
733 
735  penality = msg->getU8();
736 
737  g_game.processDeath(deathType, penality);
738 }
739 
740 void ProtocolGame::parseMapDescription(const InputMessagePtr& msg)
741 {
742  Position pos = getPosition(msg);
743 
744  if(!m_mapKnown)
745  m_localPlayer->setPosition(pos);
746 
748 
749  AwareRange range = g_map.getAwareRange();
750  setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, range.horizontal(), range.vertical());
751 
752  if(!m_mapKnown) {
753  g_dispatcher.addEvent([] { g_lua.callGlobalField("g_game", "onMapKnown"); });
754  m_mapKnown = true;
755  }
756 
757  g_dispatcher.addEvent([] { g_lua.callGlobalField("g_game", "onMapDescription"); });
758 }
759 
760 void ProtocolGame::parseMapMoveNorth(const InputMessagePtr& msg)
761 {
762  Position pos;
764  pos = getPosition(msg);
765  else
766  pos = g_map.getCentralPosition();
767  pos.y--;
768 
769  AwareRange range = g_map.getAwareRange();
770  setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, range.horizontal(), 1);
772 }
773 
774 void ProtocolGame::parseMapMoveEast(const InputMessagePtr& msg)
775 {
776  Position pos;
778  pos = getPosition(msg);
779  else
780  pos = g_map.getCentralPosition();
781  pos.x++;
782 
783  AwareRange range = g_map.getAwareRange();
784  setMapDescription(msg, pos.x + range.right, pos.y - range.top, pos.z, 1, range.vertical());
786 }
787 
788 void ProtocolGame::parseMapMoveSouth(const InputMessagePtr& msg)
789 {
790  Position pos;
792  pos = getPosition(msg);
793  else
794  pos = g_map.getCentralPosition();
795  pos.y++;
796 
797  AwareRange range = g_map.getAwareRange();
798  setMapDescription(msg, pos.x - range.left, pos.y + range.bottom, pos.z, range.horizontal(), 1);
800 }
801 
802 void ProtocolGame::parseMapMoveWest(const InputMessagePtr& msg)
803 {
804  Position pos;
806  pos = getPosition(msg);
807  else
808  pos = g_map.getCentralPosition();
809  pos.x--;
810 
811  AwareRange range = g_map.getAwareRange();
812  setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, 1, range.vertical());
814 }
815 
816 void ProtocolGame::parseUpdateTile(const InputMessagePtr& msg)
817 {
818  Position tilePos = getPosition(msg);
819  setTileDescription(msg, tilePos);
820 }
821 
822 void ProtocolGame::parseTileAddThing(const InputMessagePtr& msg)
823 {
824  Position pos = getPosition(msg);
825  int stackPos = -1;
826 
827  if(g_game.getClientVersion() >= 841)
828  stackPos = msg->getU8();
829 
830  ThingPtr thing = getThing(msg);
831  g_map.addThing(thing, pos, stackPos);
832 }
833 
834 void ProtocolGame::parseTileTransformThing(const InputMessagePtr& msg)
835 {
836  ThingPtr thing = getMappedThing(msg);
837  ThingPtr newThing = getThing(msg);
838 
839  if(!thing) {
840  g_logger.traceError("no thing");
841  return;
842  }
843 
844  Position pos = thing->getPosition();
845  int stackpos = thing->getStackPos();
846 
847  if(!g_map.removeThing(thing)) {
848  g_logger.traceError("unable to remove thing");
849  return;
850  }
851 
852  g_map.addThing(newThing, pos, stackpos);
853 }
854 
855 void ProtocolGame::parseTileRemoveThing(const InputMessagePtr& msg)
856 {
857  ThingPtr thing = getMappedThing(msg);
858  if(!thing) {
859  g_logger.traceError("no thing");
860  return;
861  }
862 
863  if(!g_map.removeThing(thing))
864  g_logger.traceError("unable to remove thing");
865 }
866 
867 void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
868 {
869  ThingPtr thing = getMappedThing(msg);
870  Position newPos = getPosition(msg);
871 
872  if(!thing || !thing->isCreature()) {
873  g_logger.traceError("no creature found to move");
874  return;
875  }
876 
877  if(!g_map.removeThing(thing)) {
878  g_logger.traceError("unable to remove creature");
879  return;
880  }
881 
882  CreaturePtr creature = thing->static_self_cast<Creature>();
883  creature->allowAppearWalk();
884 
885  g_map.addThing(thing, newPos, -1);
886 }
887 
888 void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
889 {
890  int containerId = msg->getU8();
891  ItemPtr containerItem = getItem(msg);
892  std::string name = msg->getString();
893  int capacity = msg->getU8();
894  bool hasParent = (msg->getU8() != 0);
895 
896  bool isUnlocked = true;
897  bool hasPages = false;
898  int containerSize = 0;
899  int firstIndex = 0;
900 
902  isUnlocked = (msg->getU8() != 0); // drag and drop
903  hasPages = (msg->getU8() != 0); // pagination
904  containerSize = msg->getU16(); // container size
905  firstIndex = msg->getU16(); // first index
906  }
907 
908  int itemCount = msg->getU8();
909 
910  std::vector<ItemPtr> items(itemCount);
911  for(int i = 0; i < itemCount; i++)
912  items[i] = getItem(msg);
913 
914  g_game.processOpenContainer(containerId, containerItem, name, capacity, hasParent, items, isUnlocked, hasPages, containerSize, firstIndex);
915 }
916 
917 void ProtocolGame::parseCloseContainer(const InputMessagePtr& msg)
918 {
919  int containerId = msg->getU8();
920  g_game.processCloseContainer(containerId);
921 }
922 
923 void ProtocolGame::parseContainerAddItem(const InputMessagePtr& msg)
924 {
925  int containerId = msg->getU8();
926  int slot = 0;
928  slot = msg->getU16(); // slot
929  }
930  ItemPtr item = getItem(msg);
931  g_game.processContainerAddItem(containerId, item, slot);
932 }
933 
934 void ProtocolGame::parseContainerUpdateItem(const InputMessagePtr& msg)
935 {
936  int containerId = msg->getU8();
937  int slot;
939  slot = msg->getU16();
940  } else {
941  slot = msg->getU8();
942  }
943  ItemPtr item = getItem(msg);
944  g_game.processContainerUpdateItem(containerId, slot, item);
945 }
946 
947 void ProtocolGame::parseContainerRemoveItem(const InputMessagePtr& msg)
948 {
949  int containerId = msg->getU8();
950  int slot;
951  ItemPtr lastItem;
953  slot = msg->getU16();
954 
955  int itemId = msg->getU16();
956  if(itemId != 0)
957  lastItem = getItem(msg, itemId);
958  } else {
959  slot = msg->getU8();
960  }
961  g_game.processContainerRemoveItem(containerId, slot, lastItem);
962 }
963 
964 void ProtocolGame::parseAddInventoryItem(const InputMessagePtr& msg)
965 {
966  int slot = msg->getU8();
967  ItemPtr item = getItem(msg);
968  g_game.processInventoryChange(slot, item);
969 }
970 
971 void ProtocolGame::parseRemoveInventoryItem(const InputMessagePtr& msg)
972 {
973  int slot = msg->getU8();
975 }
976 
977 void ProtocolGame::parseOpenNpcTrade(const InputMessagePtr& msg)
978 {
979  std::vector<std::tuple<ItemPtr, std::string, int, int, int>> items;
980  std::string npcName;
981 
983  npcName = msg->getString();
984 
985  int listCount;
986 
987  if(g_game.getClientVersion() >= 900)
988  listCount = msg->getU16();
989  else
990  listCount = msg->getU8();
991 
992  for(int i = 0; i < listCount; ++i) {
993  uint16 itemId = msg->getU16();
994  uint8 count = msg->getU8();
995 
996  ItemPtr item = Item::create(itemId);
997  item->setCountOrSubType(count);
998 
999  std::string name = msg->getString();
1000  int weight = msg->getU32();
1001  int buyPrice = msg->getU32();
1002  int sellPrice = msg->getU32();
1003  items.emplace_back(item, name, weight, buyPrice, sellPrice);
1004  }
1005 
1006  g_game.processOpenNpcTrade(items);
1007 }
1008 
1009 void ProtocolGame::parsePlayerGoods(const InputMessagePtr& msg)
1010 {
1011  std::vector<std::tuple<ItemPtr, int>> goods;
1012 
1013  int money;
1014  if(g_game.getClientVersion() >= 973)
1015  money = msg->getU64();
1016  else
1017  money = msg->getU32();
1018 
1019  int size = msg->getU8();
1020  for(int i = 0; i < size; i++) {
1021  int itemId = msg->getU16();
1022  int amount;
1023 
1025  amount = msg->getU16();
1026  else
1027  amount = msg->getU8();
1028 
1029  goods.emplace_back(Item::create(itemId), amount);
1030  }
1031 
1032  g_game.processPlayerGoods(money, goods);
1033 }
1034 
1035 void ProtocolGame::parseCloseNpcTrade(const InputMessagePtr&)
1036 {
1038 }
1039 
1040 void ProtocolGame::parseOwnTrade(const InputMessagePtr& msg)
1041 {
1042  std::string name = g_game.formatCreatureName(msg->getString());
1043  int count = msg->getU8();
1044 
1045  std::vector<ItemPtr> items(count);
1046  for(int i = 0; i < count; i++)
1047  items[i] = getItem(msg);
1048 
1049  g_game.processOwnTrade(name, items);
1050 }
1051 
1052 void ProtocolGame::parseCounterTrade(const InputMessagePtr& msg)
1053 {
1054  std::string name = g_game.formatCreatureName(msg->getString());
1055  int count = msg->getU8();
1056 
1057  std::vector<ItemPtr> items(count);
1058  for(int i = 0; i < count; i++)
1059  items[i] = getItem(msg);
1060 
1061  g_game.processCounterTrade(name, items);
1062 }
1063 
1064 void ProtocolGame::parseCloseTrade(const InputMessagePtr&)
1065 {
1067 }
1068 
1069 void ProtocolGame::parseWorldLight(const InputMessagePtr& msg)
1070 {
1071  Light light;
1072  light.intensity = msg->getU8();
1073  light.color = msg->getU8();
1074 
1075  g_map.setLight(light);
1076 }
1077 
1078 void ProtocolGame::parseMagicEffect(const InputMessagePtr& msg)
1079 {
1080  Position pos = getPosition(msg);
1081  int effectId;
1083  effectId = msg->getU16();
1084  else
1085  effectId = msg->getU8();
1086 
1087  if(!g_things.isValidDatId(effectId, ThingCategoryEffect)) {
1088  g_logger.traceError(stdext::format("invalid effect id %d", effectId));
1089  return;
1090  }
1091 
1092  EffectPtr effect = EffectPtr(new Effect());
1093  effect->setId(effectId);
1094  g_map.addThing(effect, pos);
1095 }
1096 
1097 void ProtocolGame::parseAnimatedText(const InputMessagePtr& msg)
1098 {
1099  Position position = getPosition(msg);
1100  int color = msg->getU8();
1101  std::string text = msg->getString();
1102 
1103  AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
1104  animatedText->setColor(color);
1105  animatedText->setText(text);
1106  g_map.addThing(animatedText, position);
1107 }
1108 
1109 void ProtocolGame::parseDistanceMissile(const InputMessagePtr& msg)
1110 {
1111  Position fromPos = getPosition(msg);
1112  Position toPos = getPosition(msg);
1113  int shotId = msg->getU8();
1114 
1116  g_logger.traceError(stdext::format("invalid missile id %d", shotId));
1117  return;
1118  }
1119 
1120  MissilePtr missile = MissilePtr(new Missile());
1121  missile->setId(shotId);
1122  missile->setPath(fromPos, toPos);
1123  g_map.addThing(missile, fromPos);
1124 }
1125 
1126 void ProtocolGame::parseCreatureMark(const InputMessagePtr& msg)
1127 {
1128  uint id = msg->getU32();
1129  int color = msg->getU8();
1130 
1131  CreaturePtr creature = g_map.getCreatureById(id);
1132  if(creature)
1133  creature->addTimedSquare(color);
1134  else
1135  g_logger.traceError("could not get creature");
1136 }
1137 
1138 void ProtocolGame::parseTrappers(const InputMessagePtr& msg)
1139 {
1140  int numTrappers = msg->getU8();
1141 
1142  if(numTrappers > 8)
1143  g_logger.traceError("too many trappers");
1144 
1145  for(int i=0;i<numTrappers;++i) {
1146  uint id = msg->getU32();
1147  CreaturePtr creature = g_map.getCreatureById(id);
1148  if(creature) {
1149  //TODO: set creature as trapper
1150  } else
1151  g_logger.traceError("could not get creature");
1152  }
1153 }
1154 
1155 void ProtocolGame::parseCreatureHealth(const InputMessagePtr& msg)
1156 {
1157  uint id = msg->getU32();
1158  int healthPercent = msg->getU8();
1159 
1160  CreaturePtr creature = g_map.getCreatureById(id);
1161  if(creature)
1162  creature->setHealthPercent(healthPercent);
1163 
1164  // some servers has a bug in get spectators and sends unknown creatures updates
1165  // so this code is disabled
1166  /*
1167  else
1168  g_logger.traceError("could not get creature");
1169  */
1170 }
1171 
1172 void ProtocolGame::parseCreatureLight(const InputMessagePtr& msg)
1173 {
1174  uint id = msg->getU32();
1175 
1176  Light light;
1177  light.intensity = msg->getU8();
1178  light.color = msg->getU8();
1179 
1180  CreaturePtr creature = g_map.getCreatureById(id);
1181  if(creature)
1182  creature->setLight(light);
1183  else
1184  g_logger.traceError("could not get creature");
1185 }
1186 
1187 void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
1188 {
1189  uint id = msg->getU32();
1190  Outfit outfit = getOutfit(msg);
1191 
1192  CreaturePtr creature = g_map.getCreatureById(id);
1193  if(creature)
1194  creature->setOutfit(outfit);
1195  else
1196  g_logger.traceError("could not get creature");
1197 }
1198 
1199 void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
1200 {
1201  uint id = msg->getU32();
1202 
1203  int baseSpeed = -1;
1204  if(g_game.getClientVersion() >= 1059)
1205  baseSpeed = msg->getU16();
1206 
1207  int speed = msg->getU16();
1208 
1209  CreaturePtr creature = g_map.getCreatureById(id);
1210  if(creature) {
1211  creature->setSpeed(speed);
1212  if(baseSpeed != -1)
1213  creature->setBaseSpeed(baseSpeed);
1214  }
1215 
1216  // some servers has a bug in get spectators and sends unknown creatures updates
1217  // so this code is disabled
1218  /*
1219  else
1220  g_logger.traceError("could not get creature");
1221  */
1222 }
1223 
1224 void ProtocolGame::parseCreatureSkulls(const InputMessagePtr& msg)
1225 {
1226  uint id = msg->getU32();
1227  int skull = msg->getU8();
1228 
1229  CreaturePtr creature = g_map.getCreatureById(id);
1230  if(creature)
1231  creature->setSkull(skull);
1232  else
1233  g_logger.traceError("could not get creature");
1234 }
1235 
1236 void ProtocolGame::parseCreatureShields(const InputMessagePtr& msg)
1237 {
1238  uint id = msg->getU32();
1239  int shield = msg->getU8();
1240 
1241  CreaturePtr creature = g_map.getCreatureById(id);
1242  if(creature)
1243  creature->setShield(shield);
1244  else
1245  g_logger.traceError("could not get creature");
1246 }
1247 
1248 void ProtocolGame::parseCreatureUnpass(const InputMessagePtr& msg)
1249 {
1250  uint id = msg->getU32();
1251  bool unpass = msg->getU8();
1252 
1253  CreaturePtr creature = g_map.getCreatureById(id);
1254  if(creature)
1255  creature->setPassable(!unpass);
1256  else
1257  g_logger.traceError("could not get creature");
1258 }
1259 
1260 void ProtocolGame::parseEditText(const InputMessagePtr& msg)
1261 {
1262  uint id = msg->getU32();
1263 
1264  int itemId;
1265  if(g_game.getClientVersion() >= 1010) {
1266  // TODO: processEditText with ItemPtr as parameter
1267  ItemPtr item = getItem(msg);
1268  itemId = item->getId();
1269  } else
1270  itemId = msg->getU16();
1271 
1272  int maxLength = msg->getU16();
1273  std::string text = msg->getString();
1274 
1275  std::string writer = msg->getString();
1276  std::string date = "";
1278  date = msg->getString();
1279 
1280  g_game.processEditText(id, itemId, maxLength, text, writer, date);
1281 }
1282 
1283 void ProtocolGame::parseEditList(const InputMessagePtr& msg)
1284 {
1285  int doorId = msg->getU8();
1286  uint id = msg->getU32();
1287  const std::string& text = msg->getString();
1288 
1289  g_game.processEditList(id, doorId, text);
1290 }
1291 
1292 void ProtocolGame::parsePremiumTrigger(const InputMessagePtr& msg)
1293 {
1294  int triggerCount = msg->getU8();
1295  std::vector<int> triggers;
1296  for(int i=0;i<triggerCount;++i) {
1297  triggers.push_back(msg->getU8());
1298  }
1299 
1300  if(g_game.getClientVersion() <= 1096) {
1301  bool something = msg->getU8() == 1;
1302  }
1303 }
1304 
1305 void ProtocolGame::parsePlayerInfo(const InputMessagePtr& msg)
1306 {
1307  bool premium = msg->getU8(); // premium
1309  msg->getU32(); // premium expiration used for premium advertisement
1310  int vocation = msg->getU8(); // vocation
1311 
1312  int spellCount = msg->getU16();
1313  std::vector<int> spells;
1314  for(int i=0;i<spellCount;++i)
1315  spells.push_back(msg->getU8()); // spell id
1316 
1317  m_localPlayer->setPremium(premium);
1318  m_localPlayer->setVocation(vocation);
1319  m_localPlayer->setSpells(spells);
1320 }
1321 
1322 void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg)
1323 {
1324  double health;
1325  double maxHealth;
1326 
1328  health = msg->getU32();
1329  maxHealth = msg->getU32();
1330  } else {
1331  health = msg->getU16();
1332  maxHealth = msg->getU16();
1333  }
1334 
1335  double freeCapacity;
1337  freeCapacity = msg->getU32() / 100.0;
1338  else
1339  freeCapacity = msg->getU16() / 100.0;
1340 
1341  double totalCapacity = 0;
1343  totalCapacity = msg->getU32() / 100.0;
1344 
1345  double experience;
1347  experience = msg->getU64();
1348  else
1349  experience = msg->getU32();
1350 
1351  double level = msg->getU16();
1352  double levelPercent = msg->getU8();
1353 
1355  if(g_game.getClientVersion() <= 1096) {
1356  msg->getDouble(); // experienceBonus
1357  } else {
1358  msg->getU16(); // baseXpGain
1359  msg->getU16(); // voucherAddend
1360  msg->getU16(); // grindingAddend
1361  msg->getU16(); // storeBoostAddend
1362  msg->getU16(); // huntingBoostFactor
1363  }
1364  }
1365 
1366  double mana;
1367  double maxMana;
1368 
1370  mana = msg->getU32();
1371  maxMana = msg->getU32();
1372  } else {
1373  mana = msg->getU16();
1374  maxMana = msg->getU16();
1375  }
1376 
1377  double magicLevel = msg->getU8();
1378 
1379  double baseMagicLevel;
1381  baseMagicLevel = msg->getU8();
1382  else
1383  baseMagicLevel = magicLevel;
1384 
1385  double magicLevelPercent = msg->getU8();
1386  double soul = msg->getU8();
1387  double stamina = 0;
1389  stamina = msg->getU16();
1390 
1391  double baseSpeed = 0;
1393  baseSpeed = msg->getU16();
1394 
1395  double regeneration = 0;
1397  regeneration = msg->getU16();
1398 
1399  double training = 0;
1401  training = msg->getU16();
1402  if(g_game.getClientVersion() >= 1097) {
1403  int remainingStoreXpBoostSeconds = msg->getU16();
1404  bool canBuyMoreStoreXpBoosts = msg->getU8();
1405  }
1406  }
1407 
1408  m_localPlayer->setHealth(health, maxHealth);
1409  m_localPlayer->setFreeCapacity(freeCapacity);
1410  m_localPlayer->setTotalCapacity(totalCapacity);
1411  m_localPlayer->setExperience(experience);
1412  m_localPlayer->setLevel(level, levelPercent);
1413  m_localPlayer->setMana(mana, maxMana);
1414  m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
1415  m_localPlayer->setBaseMagicLevel(baseMagicLevel);
1416  m_localPlayer->setStamina(stamina);
1417  m_localPlayer->setSoul(soul);
1418  m_localPlayer->setBaseSpeed(baseSpeed);
1419  m_localPlayer->setRegenerationTime(regeneration);
1420  m_localPlayer->setOfflineTrainingTime(training);
1421 }
1422 
1423 void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
1424 {
1425  int lastSkill = Otc::Fishing + 1;
1427  lastSkill = Otc::LastSkill;
1428 
1429  for(int skill = 0; skill < lastSkill; skill++) {
1430  int level;
1431 
1433  level = msg->getU16();
1434  else
1435  level = msg->getU8();
1436 
1437  int baseLevel;
1440  baseLevel = msg->getU16();
1441  else
1442  baseLevel = msg->getU8();
1443  else
1444  baseLevel = level;
1445 
1446  int levelPercent = 0;
1447  // Critical, Life Leech and Mana Leech have no level percent
1448  if(skill <= Otc::Fishing)
1449  levelPercent = msg->getU8();
1450 
1451  m_localPlayer->setSkill((Otc::Skill)skill, level, levelPercent);
1452  m_localPlayer->setBaseSkill((Otc::Skill)skill, baseLevel);
1453  }
1454 }
1455 
1456 void ProtocolGame::parsePlayerState(const InputMessagePtr& msg)
1457 {
1458  int states;
1460  states = msg->getU16();
1461  else
1462  states = msg->getU8();
1463 
1464  m_localPlayer->setStates(states);
1465 }
1466 
1467 void ProtocolGame::parsePlayerCancelAttack(const InputMessagePtr& msg)
1468 {
1469  uint seq = 0;
1471  seq = msg->getU32();
1472 
1474 }
1475 
1476 
1477 void ProtocolGame::parsePlayerModes(const InputMessagePtr& msg)
1478 {
1479  int fightMode = msg->getU8();
1480  int chaseMode = msg->getU8();
1481  bool safeMode = msg->getU8();
1482 
1483  int pvpMode = 0;
1485  pvpMode = msg->getU8();
1486 
1487  g_game.processPlayerModes((Otc::FightModes)fightMode, (Otc::ChaseModes)chaseMode, safeMode, (Otc::PVPModes)pvpMode);
1488 }
1489 
1490 void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
1491 {
1492  int spellId = msg->getU8();
1493  int delay = msg->getU32();
1494 
1495  g_lua.callGlobalField("g_game", "onSpellCooldown", spellId, delay);
1496 }
1497 
1498 void ProtocolGame::parseSpellGroupCooldown(const InputMessagePtr& msg)
1499 {
1500  int groupId = msg->getU8();
1501  int delay = msg->getU32();
1502 
1503  g_lua.callGlobalField("g_game", "onSpellGroupCooldown", groupId, delay);
1504 }
1505 
1506 void ProtocolGame::parseMultiUseCooldown(const InputMessagePtr& msg)
1507 {
1508  int delay = msg->getU32();
1509 
1510  g_lua.callGlobalField("g_game", "onMultiUseCooldown", delay);
1511 }
1512 
1513 void ProtocolGame::parseTalk(const InputMessagePtr& msg)
1514 {
1516  msg->getU32(); // channel statement guid
1517 
1518  std::string name = g_game.formatCreatureName(msg->getString());
1519 
1520  int level = 0;
1522  level = msg->getU16();
1523 
1525  int channelId = 0;
1526  Position pos;
1527 
1528  switch(mode) {
1529  case Otc::MessageSay:
1530  case Otc::MessageWhisper:
1531  case Otc::MessageYell:
1534  case Otc::MessageNpcTo:
1535  case Otc::MessageBarkLow:
1536  case Otc::MessageBarkLoud:
1537  case Otc::MessageSpell:
1539  pos = getPosition(msg);
1540  break;
1541  case Otc::MessageChannel:
1545  channelId = msg->getU16();
1546  break;
1547  case Otc::MessageNpcFrom:
1551  case Otc::MessageRVRAnswer:
1553  break;
1555  msg->getU32();
1556  break;
1557  default:
1558  stdext::throw_exception(stdext::format("unknown message mode %d", mode));
1559  break;
1560  }
1561 
1562  std::string text = msg->getString();
1563 
1564  g_game.processTalk(name, level, mode, text, channelId, pos);
1565 }
1566 
1567 void ProtocolGame::parseChannelList(const InputMessagePtr& msg)
1568 {
1569  int count = msg->getU8();
1570  std::vector<std::tuple<int, std::string> > channelList;
1571  for(int i = 0; i < count; i++) {
1572  int id = msg->getU16();
1573  std::string name = msg->getString();
1574  channelList.emplace_back(id, name);
1575  }
1576 
1577  g_game.processChannelList(channelList);
1578 }
1579 
1580 void ProtocolGame::parseOpenChannel(const InputMessagePtr& msg)
1581 {
1582  int channelId = msg->getU16();
1583  std::string name = msg->getString();
1584 
1586  int joinedPlayers = msg->getU16();
1587  for(int i=0;i<joinedPlayers;++i)
1588  g_game.formatCreatureName(msg->getString()); // player name
1589  int invitedPlayers = msg->getU16();
1590  for(int i=0;i<invitedPlayers;++i)
1591  g_game.formatCreatureName(msg->getString()); // player name
1592  }
1593 
1594  g_game.processOpenChannel(channelId, name);
1595 }
1596 
1597 void ProtocolGame::parseOpenPrivateChannel(const InputMessagePtr& msg)
1598 {
1599  std::string name = g_game.formatCreatureName(msg->getString());
1600 
1602 }
1603 
1604 void ProtocolGame::parseOpenOwnPrivateChannel(const InputMessagePtr& msg)
1605 {
1606  int channelId = msg->getU16();
1607  std::string name = msg->getString();
1608 
1609  g_game.processOpenOwnPrivateChannel(channelId, name);
1610 }
1611 
1612 void ProtocolGame::parseCloseChannel(const InputMessagePtr& msg)
1613 {
1614  int channelId = msg->getU16();
1615 
1616  g_game.processCloseChannel(channelId);
1617 }
1618 
1619 void ProtocolGame::parseRuleViolationChannel(const InputMessagePtr& msg)
1620 {
1621  int channelId = msg->getU16();
1622 
1624 }
1625 
1626 void ProtocolGame::parseRuleViolationRemove(const InputMessagePtr& msg)
1627 {
1628  std::string name = msg->getString();
1629 
1631 }
1632 
1633 void ProtocolGame::parseRuleViolationCancel(const InputMessagePtr& msg)
1634 {
1635  std::string name = msg->getString();
1636 
1638 }
1639 
1640 void ProtocolGame::parseRuleViolationLock(const InputMessagePtr& msg)
1641 {
1643 }
1644 
1645 void ProtocolGame::parseTextMessage(const InputMessagePtr& msg)
1646 {
1647  int code = msg->getU8();
1649  std::string text;
1650 
1651  switch(mode) {
1653  msg->getU16(); // channelId
1654  text = msg->getString();
1655  break;
1656  }
1657  case Otc::MessageGuild:
1659  case Otc::MessageParty: {
1660  msg->getU16(); // channelId
1661  text = msg->getString();
1662  break;
1663  }
1666  case Otc::MessageDamageOthers: {
1667  Position pos = getPosition(msg);
1668  uint value[2];
1669  int color[2];
1670 
1671  // physical damage
1672  value[0] = msg->getU32();
1673  color[0] = msg->getU8();
1674 
1675  // magic damage
1676  value[1] = msg->getU32();
1677  color[1] = msg->getU8();
1678  text = msg->getString();
1679 
1680  for(int i=0;i<2;++i) {
1681  if(value[i] == 0)
1682  continue;
1683  AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
1684  animatedText->setColor(color[i]);
1685  animatedText->setText(stdext::to_string(value[i]));
1686  g_map.addThing(animatedText, pos);
1687  }
1688  break;
1689  }
1690  case Otc::MessageHeal:
1691  case Otc::MessageMana:
1692  case Otc::MessageExp:
1694  case Otc::MessageExpOthers: {
1695  Position pos = getPosition(msg);
1696  uint value = msg->getU32();
1697  int color = msg->getU8();
1698  text = msg->getString();
1699 
1700  AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
1701  animatedText->setColor(color);
1702  animatedText->setText(stdext::to_string(value));
1703  g_map.addThing(animatedText, pos);
1704  break;
1705  }
1706  case Otc::MessageInvalid:
1707  stdext::throw_exception(stdext::format("unknown message mode %d", mode));
1708  break;
1709  default:
1710  text = msg->getString();
1711  break;
1712  }
1713 
1714  g_game.processTextMessage(mode, text);
1715 }
1716 
1717 void ProtocolGame::parseCancelWalk(const InputMessagePtr& msg)
1718 {
1719  Otc::Direction direction = (Otc::Direction)msg->getU8();
1720 
1721  g_game.processWalkCancel(direction);
1722 }
1723 
1724 void ProtocolGame::parseWalkWait(const InputMessagePtr& msg)
1725 {
1726  int millis = msg->getU16();
1727  m_localPlayer->lockWalk(millis);
1728 }
1729 
1730 void ProtocolGame::parseFloorChangeUp(const InputMessagePtr& msg)
1731 {
1732  Position pos;
1734  pos = getPosition(msg);
1735  else
1736  pos = g_map.getCentralPosition();
1737  AwareRange range = g_map.getAwareRange();
1738  pos.z--;
1739 
1740  int skip = 0;
1741  if(pos.z == Otc::SEA_FLOOR)
1742  for(int i = Otc::SEA_FLOOR - Otc::AWARE_UNDEGROUND_FLOOR_RANGE; i >= 0; i--)
1743  skip = setFloorDescription(msg, pos.x - range.left, pos.y - range.top, i, range.horizontal(), range.vertical(), 8 - i, skip);
1744  else if(pos.z > Otc::SEA_FLOOR)
1745  skip = setFloorDescription(msg, pos.x - range.left, pos.y - range.top, pos.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, range.horizontal(), range.vertical(), 3, skip);
1746 
1747  pos.x++;
1748  pos.y++;
1750 }
1751 
1752 void ProtocolGame::parseFloorChangeDown(const InputMessagePtr& msg)
1753 {
1754  Position pos;
1756  pos = getPosition(msg);
1757  else
1758  pos = g_map.getCentralPosition();
1759  AwareRange range = g_map.getAwareRange();
1760  pos.z++;
1761 
1762  int skip = 0;
1763  if(pos.z == Otc::UNDERGROUND_FLOOR) {
1764  int j, i;
1765  for(i = pos.z, j = -1; i <= pos.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE; ++i, --j)
1766  skip = setFloorDescription(msg, pos.x - range.left, pos.y - range.top, i, range.horizontal(), range.vertical(), j, skip);
1767  }
1768  else if(pos.z > Otc::UNDERGROUND_FLOOR && pos.z < Otc::MAX_Z-1)
1769  skip = setFloorDescription(msg, pos.x - range.left, pos.y - range.top, pos.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, range.horizontal(), range.vertical(), -3, skip);
1770 
1771  pos.x--;
1772  pos.y--;
1774 }
1775 
1776 void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
1777 {
1778  Outfit currentOutfit = getOutfit(msg);
1779  std::vector<std::tuple<int, std::string, int> > outfitList;
1780 
1782  int outfitCount = msg->getU8();
1783  for(int i = 0; i < outfitCount; i++) {
1784  int outfitId = msg->getU16();
1785  std::string outfitName = msg->getString();
1786  int outfitAddons = msg->getU8();
1787 
1788  outfitList.emplace_back(outfitId, outfitName, outfitAddons);
1789  }
1790  } else {
1791  int outfitStart, outfitEnd;
1793  outfitStart = msg->getU16();
1794  outfitEnd = msg->getU16();
1795  } else {
1796  outfitStart = msg->getU8();
1797  outfitEnd = msg->getU8();
1798  }
1799 
1800  for(int i = outfitStart; i <= outfitEnd; i++)
1801  outfitList.emplace_back(i, "", 0);
1802  }
1803 
1804  std::vector<std::tuple<int, std::string> > mountList;
1806  int mountCount = msg->getU8();
1807  for(int i = 0; i < mountCount; ++i) {
1808  int mountId = msg->getU16(); // mount type
1809  std::string mountName = msg->getString(); // mount name
1810 
1811  mountList.emplace_back(mountId, mountName);
1812  }
1813  }
1814 
1815  g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList);
1816 }
1817 
1818 void ProtocolGame::parseVipAdd(const InputMessagePtr& msg)
1819 {
1820  uint id, iconId = 0, status;
1821  std::string name, desc = "";
1822  bool notifyLogin = false;
1823 
1824  id = msg->getU32();
1825  name = g_game.formatCreatureName(msg->getString());
1827  desc = msg->getString();
1828  iconId = msg->getU32();
1829  notifyLogin = msg->getU8();
1830  }
1831  status = msg->getU8();
1832 
1833  g_game.processVipAdd(id, name, status, desc, iconId, notifyLogin);
1834 }
1835 
1836 void ProtocolGame::parseVipState(const InputMessagePtr& msg)
1837 {
1838  uint id = msg->getU32();
1840  uint status = msg->getU8();
1841  g_game.processVipStateChange(id, status);
1842  }
1843  else {
1845  }
1846 }
1847 
1848 void ProtocolGame::parseVipLogout(const InputMessagePtr& msg)
1849 {
1850  uint id = msg->getU32();
1852 }
1853 
1854 void ProtocolGame::parseTutorialHint(const InputMessagePtr& msg)
1855 {
1856  int id = msg->getU8();
1858 }
1859 
1860 void ProtocolGame::parseAutomapFlag(const InputMessagePtr& msg)
1861 {
1862  Position pos = getPosition(msg);
1863  int icon = msg->getU8();
1864  std::string description = msg->getString();
1865 
1866  bool remove = false;
1868  remove = msg->getU8() != 0;
1869 
1870  if(!remove)
1871  g_game.processAddAutomapFlag(pos, icon, description);
1872  else
1873  g_game.processRemoveAutomapFlag(pos, icon, description);
1874 }
1875 
1876 void ProtocolGame::parseQuestLog(const InputMessagePtr& msg)
1877 {
1878  std::vector<std::tuple<int, std::string, bool> > questList;
1879  int questsCount = msg->getU16();
1880  for(int i = 0; i < questsCount; i++) {
1881  int id = msg->getU16();
1882  std::string name = msg->getString();
1883  bool completed = msg->getU8();
1884  questList.emplace_back(id, name, completed);
1885  }
1886 
1887  g_game.processQuestLog(questList);
1888 }
1889 
1890 void ProtocolGame::parseQuestLine(const InputMessagePtr& msg)
1891 {
1892  std::vector<std::tuple<std::string, std::string>> questMissions;
1893  int questId = msg->getU16();
1894  int missionCount = msg->getU8();
1895  for(int i = 0; i < missionCount; i++) {
1896  std::string missionName = msg->getString();
1897  std::string missionDescrition = msg->getString();
1898  questMissions.emplace_back(missionName, missionDescrition);
1899  }
1900 
1901  g_game.processQuestLine(questId, questMissions);
1902 }
1903 
1904 void ProtocolGame::parseChannelEvent(const InputMessagePtr& msg)
1905 {
1906  uint16 channelId = msg->getU16();
1907  std::string name = g_game.formatCreatureName(msg->getString());
1908  uint8 type = msg->getU8();
1909 
1910  g_lua.callGlobalField("g_game", "onChannelEvent", channelId, name, type);
1911 }
1912 
1913 void ProtocolGame::parseItemInfo(const InputMessagePtr& msg)
1914 {
1915  std::vector<std::tuple<ItemPtr, std::string>> list;
1916  int size = msg->getU8();
1917  for(int i=0;i<size;++i) {
1918  ItemPtr item(new Item);
1919  item->setId(msg->getU16());
1920  item->setCountOrSubType(msg->getU8());
1921 
1922  std::string desc = msg->getString();
1923  list.emplace_back(item, desc);
1924  }
1925 
1926  g_lua.callGlobalField("g_game", "onItemInfo", list);
1927 }
1928 
1929 void ProtocolGame::parsePlayerInventory(const InputMessagePtr& msg)
1930 {
1931  int size = msg->getU16();
1932  for(int i=0;i<size;++i) {
1933  msg->getU16(); // id
1934  msg->getU8(); // subtype
1935  msg->getU16(); // count
1936  }
1937 }
1938 
1939 void ProtocolGame::parseModalDialog(const InputMessagePtr& msg)
1940 {
1941  uint32 windowId = msg->getU32();
1942  std::string title = msg->getString();
1943  std::string message = msg->getString();
1944 
1945  int sizeButtons = msg->getU8();
1946  std::vector<std::tuple<int, std::string> > buttonList;
1947  for(int i = 0; i < sizeButtons; ++i) {
1948  std::string value = msg->getString();
1949  int buttonId = msg->getU8();
1950  buttonList.push_back(std::make_tuple(buttonId, value));
1951  }
1952 
1953  int sizeChoices = msg->getU8();
1954  std::vector<std::tuple<int, std::string> > choiceList;
1955  for(int i = 0; i < sizeChoices; ++i) {
1956  std::string value = msg->getString();
1957  int choideId = msg->getU8();
1958  choiceList.push_back(std::make_tuple(choideId, value));
1959  }
1960 
1961  int enterButton, escapeButton;
1962  if(g_game.getClientVersion() > 970) {
1963  escapeButton = msg->getU8();
1964  enterButton = msg->getU8();
1965  }
1966  else {
1967  enterButton = msg->getU8();
1968  escapeButton = msg->getU8();
1969  }
1970 
1971  bool priority = msg->getU8() == 0x01;
1972 
1973  g_game.processModalDialog(windowId, title, message, buttonList, enterButton, escapeButton, choiceList, priority);
1974 }
1975 
1976 void ProtocolGame::parseExtendedOpcode(const InputMessagePtr& msg)
1977 {
1978  int opcode = msg->getU8();
1979  std::string buffer = msg->getString();
1980 
1981  if(opcode == 0)
1982  m_enableSendExtendedOpcode = true;
1983  else if(opcode == 2)
1984  parsePingBack(msg);
1985  else
1986  callLuaField("onExtendedOpcode", opcode, buffer);
1987 }
1988 
1989 void ProtocolGame::parseChangeMapAwareRange(const InputMessagePtr& msg)
1990 {
1991  int xrange = msg->getU8();
1992  int yrange = msg->getU8();
1993 
1994  AwareRange range;
1995  range.left = xrange/2 - ((xrange+1) % 2);
1996  range.right = xrange/2;
1997  range.top = yrange/2 - ((yrange+1) % 2);
1998  range.bottom = yrange/2;
1999 
2000  g_map.setAwareRange(range);
2001  g_lua.callGlobalField("g_game", "onMapChangeAwareRange", xrange, yrange);
2002 }
2003 
2004 void ProtocolGame::parseCreaturesMark(const InputMessagePtr& msg)
2005 {
2006  int len;
2007  if(g_game.getClientVersion() >= 1035) {
2008  len = 1;
2009  } else {
2010  len = msg->getU8();
2011  }
2012 
2013  for(int i=0; i<len; ++i) {
2014  uint32 id = msg->getU32();
2015  bool isPermanent = msg->getU8() != 1;
2016  uint8 markType = msg->getU8();
2017 
2018  CreaturePtr creature = g_map.getCreatureById(id);
2019  if(creature) {
2020  if(isPermanent) {
2021  if(markType == 0xff)
2022  creature->hideStaticSquare();
2023  else
2024  creature->showStaticSquare(Color::from8bit(markType));
2025  } else
2026  creature->addTimedSquare(markType);
2027  } else
2028  g_logger.traceError("could not get creature");
2029  }
2030 }
2031 
2032 void ProtocolGame::parseCreatureType(const InputMessagePtr& msg)
2033 {
2034  uint32 id = msg->getU32();
2035  uint8 type = msg->getU8();
2036 
2037  CreaturePtr creature = g_map.getCreatureById(id);
2038  if(creature)
2039  creature->setType(type);
2040  else
2041  g_logger.traceError("could not get creature");
2042 }
2043 
2044 void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height)
2045 {
2046  int startz, endz, zstep;
2047 
2048  if(z > Otc::SEA_FLOOR) {
2050  endz = std::min<int>(z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::MAX_Z);
2051  zstep = 1;
2052  }
2053  else {
2054  startz = Otc::SEA_FLOOR;
2055  endz = 0;
2056  zstep = -1;
2057  }
2058 
2059  int skip = 0;
2060  for(int nz = startz; nz != endz + zstep; nz += zstep)
2061  skip = setFloorDescription(msg, x, y, nz, width, height, z - nz, skip);
2062 }
2063 
2064 int ProtocolGame::setFloorDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height, int offset, int skip)
2065 {
2066  for(int nx = 0; nx < width; nx++) {
2067  for(int ny = 0; ny < height; ny++) {
2068  Position tilePos(x + nx + offset, y + ny + offset, z);
2069  if(skip == 0)
2070  skip = setTileDescription(msg, tilePos);
2071  else {
2072  g_map.cleanTile(tilePos);
2073  skip--;
2074  }
2075  }
2076  }
2077  return skip;
2078 }
2079 
2081 {
2082  g_map.cleanTile(position);
2083 
2084  bool gotEffect = false;
2085  for(int stackPos=0;stackPos<256;stackPos++) {
2086  if(msg->peekU16() >= 0xff00)
2087  return msg->getU16() & 0xff;
2088 
2089  if(g_game.getFeature(Otc::GameEnvironmentEffect) && !gotEffect) {
2090  msg->getU16(); // environment effect
2091  gotEffect = true;
2092  continue;
2093  }
2094 
2095  if(stackPos > 10)
2096  g_logger.traceError(stdext::format("too many things, pos=%s, stackpos=%d", stdext::to_string(position), stackPos));
2097 
2098  ThingPtr thing = getThing(msg);
2099  g_map.addThing(thing, position, stackPos);
2100  }
2101 
2102  return 0;
2103 }
2105 {
2106  Outfit outfit;
2107 
2108  int lookType;
2110  lookType = msg->getU16();
2111  else
2112  lookType = msg->getU8();
2113 
2114  if(lookType != 0) {
2116  int head = msg->getU8();
2117  int body = msg->getU8();
2118  int legs = msg->getU8();
2119  int feet = msg->getU8();
2120  int addons = 0;
2122  addons = msg->getU8();
2123 
2124  if(!g_things.isValidDatId(lookType, ThingCategoryCreature)) {
2125  g_logger.traceError(stdext::format("invalid outfit looktype %d", lookType));
2126  lookType = 0;
2127  }
2128 
2129  outfit.setId(lookType);
2130  outfit.setHead(head);
2131  outfit.setBody(body);
2132  outfit.setLegs(legs);
2133  outfit.setFeet(feet);
2134  outfit.setAddons(addons);
2135  }
2136  else {
2137  int lookTypeEx = msg->getU16();
2138  if(lookTypeEx == 0) {
2140  outfit.setAuxId(13); // invisible effect id
2141  }
2142  else {
2143  if(!g_things.isValidDatId(lookTypeEx, ThingCategoryItem)) {
2144  g_logger.traceError(stdext::format("invalid outfit looktypeex %d", lookTypeEx));
2145  lookTypeEx = 0;
2146  }
2148  outfit.setAuxId(lookTypeEx);
2149  }
2150  }
2151 
2153  int mount = msg->getU16();
2154  outfit.setMount(mount);
2155  }
2156 
2157  return outfit;
2158 }
2159 
2161 {
2162  ThingPtr thing;
2163 
2164  int id = msg->getU16();
2165 
2166  if(id == 0)
2167  stdext::throw_exception("invalid thing id");
2168  else if(id == Proto::UnknownCreature || id == Proto::OutdatedCreature || id == Proto::Creature)
2169  thing = getCreature(msg, id);
2170  else if(id == Proto::StaticText) // otclient only
2171  thing = getStaticText(msg, id);
2172  else // item
2173  thing = getItem(msg, id);
2174 
2175  return thing;
2176 }
2177 
2179 {
2180  ThingPtr thing;
2181  uint16 x = msg->getU16();
2182 
2183  if(x != 0xffff) {
2184  Position pos;
2185  pos.x = x;
2186  pos.y = msg->getU16();
2187  pos.z = msg->getU8();
2188  uint8 stackpos = msg->getU8();
2189  assert(stackpos != 255);
2190  thing = g_map.getThing(pos, stackpos);
2191  if(!thing)
2192  g_logger.traceError(stdext::format("no thing at pos:%s, stackpos:%d", stdext::to_string(pos), stackpos));
2193  } else {
2194  uint32 id = msg->getU32();
2195  thing = g_map.getCreatureById(id);
2196  if(!thing)
2197  g_logger.traceError(stdext::format("no creature with id %u", id));
2198  }
2199 
2200  return thing;
2201 }
2202 
2204 {
2205  if(type == 0)
2206  type = msg->getU16();
2207 
2208  CreaturePtr creature;
2209  bool known = (type != Proto::UnknownCreature);
2210  if(type == Proto::OutdatedCreature || type == Proto::UnknownCreature) {
2211  if(known) {
2212  uint id = msg->getU32();
2213  creature = g_map.getCreatureById(id);
2214  if(!creature)
2215  g_logger.traceError("server said that a creature is known, but it's not");
2216  } else {
2217  uint removeId = msg->getU32();
2218  g_map.removeCreatureById(removeId);
2219 
2220  uint id = msg->getU32();
2221 
2222  int creatureType;
2223  if(g_game.getClientVersion() >= 910)
2224  creatureType = msg->getU8();
2225  else {
2226  if(id >= Proto::PlayerStartId && id < Proto::PlayerEndId)
2227  creatureType = Proto::CreatureTypePlayer;
2228  else if(id >= Proto::MonsterStartId && id < Proto::MonsterEndId)
2229  creatureType = Proto::CreatureTypeMonster;
2230  else
2231  creatureType = Proto::CreatureTypeNpc;
2232  }
2233 
2234  std::string name = g_game.formatCreatureName(msg->getString());
2235 
2236  if(id == m_localPlayer->getId())
2237  creature = m_localPlayer;
2238  else if(creatureType == Proto::CreatureTypePlayer) {
2239  // fixes a bug server side bug where GameInit is not sent and local player id is unknown
2240  if(m_localPlayer->getId() == 0 && name == m_localPlayer->getName())
2241  creature = m_localPlayer;
2242  else
2243  creature = PlayerPtr(new Player);
2244  }
2245  else if(creatureType == Proto::CreatureTypeMonster)
2246  creature = MonsterPtr(new Monster);
2247  else if(creatureType == Proto::CreatureTypeNpc)
2248  creature = NpcPtr(new Npc);
2249  else
2250  g_logger.traceError("creature type is invalid");
2251 
2252  if(creature) {
2253  creature->setId(id);
2254  creature->setName(name);
2255 
2256  g_map.addCreature(creature);
2257  }
2258  }
2259 
2260  int healthPercent = msg->getU8();
2261  Otc::Direction direction = (Otc::Direction)msg->getU8();
2262  Outfit outfit = getOutfit(msg);
2263 
2264  Light light;
2265  light.intensity = msg->getU8();
2266  light.color = msg->getU8();
2267 
2268  int speed = msg->getU16();
2269  int skull = msg->getU8();
2270  int shield = msg->getU8();
2271 
2272  // emblem is sent only when the creature is not known
2273  int8 emblem = -1;
2274  int8 creatureType = -1;
2275  int8 icon = -1;
2276  bool unpass = true;
2277  uint8 mark;
2278 
2280  emblem = msg->getU8();
2281 
2283  creatureType = msg->getU8();
2284  }
2285 
2287  icon = msg->getU8();
2288  }
2289 
2291  mark = msg->getU8(); // mark
2292  msg->getU16(); // helpers
2293 
2294  if(creature) {
2295  if(mark == 0xff)
2296  creature->hideStaticSquare();
2297  else
2298  creature->showStaticSquare(Color::from8bit(mark));
2299  }
2300  }
2301 
2302  if(g_game.getClientVersion() >= 854)
2303  unpass = msg->getU8();
2304 
2305  if(creature) {
2306  creature->setHealthPercent(healthPercent);
2307  creature->setDirection(direction);
2308  creature->setOutfit(outfit);
2309  creature->setSpeed(speed);
2310  creature->setSkull(skull);
2311  creature->setShield(shield);
2312  creature->setPassable(!unpass);
2313  creature->setLight(light);
2314 
2315  if(emblem != -1)
2316  creature->setEmblem(emblem);
2317 
2318  if(creatureType != -1)
2319  creature->setType(creatureType);
2320 
2321  if(icon != -1)
2322  creature->setIcon(icon);
2323 
2324  if(creature == m_localPlayer && !m_localPlayer->isKnown())
2325  m_localPlayer->setKnown(true);
2326  }
2327  } else if(type == Proto::Creature) {
2328  uint id = msg->getU32();
2329  creature = g_map.getCreatureById(id);
2330 
2331  if(!creature)
2332  g_logger.traceError("invalid creature");
2333 
2334  Otc::Direction direction = (Otc::Direction)msg->getU8();
2335  if(creature)
2336  creature->turn(direction);
2337 
2338  if(g_game.getClientVersion() >= 953) {
2339  bool unpass = msg->getU8();
2340 
2341  if(creature)
2342  creature->setPassable(!unpass);
2343  }
2344 
2345  } else {
2346  stdext::throw_exception("invalid creature opcode");
2347  }
2348 
2349  return creature;
2350 }
2351 
2353 {
2354  if(id == 0)
2355  id = msg->getU16();
2356 
2357  ItemPtr item = Item::create(id);
2358  if(item->getId() == 0)
2359  stdext::throw_exception(stdext::format("unable to create item with invalid id %d", id));
2360 
2362  msg->getU8(); // mark
2363  }
2364 
2365  if(item->isStackable() || item->isFluidContainer() || item->isSplash() || item->isChargeable())
2366  item->setCountOrSubType(msg->getU8());
2367 
2369  if(item->getAnimationPhases() > 1) {
2370  // 0x00 => automatic phase
2371  // 0xFE => random phase
2372  // 0xFF => async phase
2373  msg->getU8();
2374  //item->setPhase(msg->getU8());
2375  }
2376  }
2377 
2378  return item;
2379 }
2380 
2382 {
2383  int colorByte = msg->getU8();
2384  Color color = Color::from8bit(colorByte);
2385  std::string fontName = msg->getString();
2386  std::string text = msg->getString();
2387  StaticTextPtr staticText = StaticTextPtr(new StaticText);
2388  staticText->setText(text);
2389  staticText->setFont(fontName);
2390  staticText->setColor(color);
2391  return staticText;
2392 }
2393 
2395 {
2396  uint16 x = msg->getU16();
2397  uint16 y = msg->getU16();
2398  uint8 z = msg->getU8();
2399 
2400  return Position(x, y, z);
2401 }
Otc::GameThingMarks
@ GameThingMarks
Definition: const.h:384
stdext::millis
ticks_t millis()
Definition: time.cpp:37
Proto::GameServerModalDialog
@ GameServerModalDialog
Definition: protocolcodes.h:161
Proto::CreatureTypeMonster
@ CreatureTypeMonster
Definition: protocolcodes.h:278
LocalPlayer::setHealth
void setHealth(double health, double maxHealth)
Definition: localplayer.cpp:364
Otc::GamePVPMode
@ GamePVPMode
Definition: const.h:393
Proto::GameServerCreatureUnpass
@ GameServerCreatureUnpass
Definition: protocolcodes.h:106
thingtypemanager.h
Proto::GameServerLoginWait
@ GameServerLoginWait
Definition: protocolcodes.h:51
Game::setCanReportBugs
void setCanReportBugs(bool enable)
Definition: game.h:339
Creature::turn
void turn(Otc::Direction direction)
Definition: creature.cpp:325
Map::setAwareRange
void setAwareRange(const AwareRange &range)
Definition: map.cpp:683
Otc::GameAttackSeq
@ GameAttackSeq
Definition: const.h:375
LocalPlayer::setRegenerationTime
void setRegenerationTime(double regenerationTime)
Definition: localplayer.cpp:513
Creature::setShield
void setShield(uint8 shield)
Definition: creature.cpp:742
Proto::GameServerTextEffect
@ GameServerTextEffect
Definition: protocolcodes.h:96
Game::processQuestLine
void processQuestLine(int questId, const std::vector< std::tuple< std::string, std::string > > &questMissions)
Definition: game.cpp:510
Game::processModalDialog
void processModalDialog(uint32 id, std::string title, std::string message, std::vector< std::tuple< int, std::string > > buttonList, int enterButton, int escapeButton, std::vector< std::tuple< int, std::string > > choiceList, bool priority)
Definition: game.cpp:515
eventdispatcher.h
Game::processWalkCancel
void processWalkCancel(Otc::Direction direction)
Definition: game.cpp:526
Proto::GameServerCreatureParty
@ GameServerCreatureParty
Definition: protocolcodes.h:105
g_map
Map g_map
Definition: map.cpp:36
Game::processOpenChannel
void processOpenChannel(int channelId, const std::string &name)
Definition: game.cpp:367
Creature::getId
uint32 getId()
Definition: creature.h:81
Proto::GameServerUnjustifiedStats
@ GameServerUnjustifiedStats
Definition: protocolcodes.h:138
Otc::MessageBarkLow
@ MessageBarkLow
Definition: const.h:321
Proto::GameServerCoinBalance
@ GameServerCoinBalance
Definition: protocolcodes.h:148
Proto::GameServerClearTarget
@ GameServerClearTarget
Definition: protocolcodes.h:119
Outfit::setBody
void setBody(int body)
Definition: outfit.h:44
Game::mount
void mount(bool mount)
Definition: game.cpp:1372
Proto::OutdatedCreature
@ OutdatedCreature
Definition: protocolcodes.h:39
Proto::GameServerGMActions
@ GameServerGMActions
Definition: protocolcodes.h:46
Color
Definition: color.h:32
Game::processTextMessage
void processTextMessage(Otc::MessageMode mode, const std::string &text)
Definition: game.cpp:287
Proto::GameServerCancelWalk
@ GameServerCancelWalk
Definition: protocolcodes.h:136
AnimatedTextPtr
stdext::shared_object_ptr< AnimatedText > AnimatedTextPtr
Definition: declarations.h:70
Otc::GameNewSpeedLaw
@ GameNewSpeedLaw
Definition: const.h:379
ThingCategoryMissile
@ ThingCategoryMissile
Definition: thingtype.h:46
Item::getId
uint32 getId()
Definition: item.h:97
InputMessage::getDouble
double getDouble()
Definition: inputmessage.cpp:89
LocalPlayer::setMana
void setMana(double mana, double maxMana)
Definition: localplayer.cpp:425
Proto::GameServerCreatureLight
@ GameServerCreatureLight
Definition: protocolcodes.h:101
Game::processOpenOutfitWindow
void processOpenOutfitWindow(const Outfit &currentOutfit, const std::vector< std::tuple< int, std::string, int > > &outfitList, const std::vector< std::tuple< int, std::string > > &mountList)
Definition: game.cpp:434
Otc::MessageRVRChannel
@ MessageRVRChannel
Definition: const.h:336
Proto::GameServerPingBack
@ GameServerPingBack
Definition: protocolcodes.h:55
Proto::GameServerPlayerState
@ GameServerPlayerState
Definition: protocolcodes.h:118
Proto::GameServerLoginSuccess
@ GameServerLoginSuccess
Definition: protocolcodes.h:52
Game::processPing
void processPing()
Definition: game.cpp:263
Creature::setId
void setId(uint32 id)
Definition: creature.h:53
Thing::isChargeable
bool isChargeable()
Definition: thing.h:94
Outfit::setFeet
void setFeet(int feet)
Definition: outfit.h:46
Proto::GameServerExtendedOpcode
@ GameServerExtendedOpcode
Definition: protocolcodes.h:64
LocalPlayer::isKnown
bool isKnown()
Definition: localplayer.h:93
Game::processLogin
void processLogin()
Definition: game.cpp:164
Otc::MessageParty
@ MessageParty
Definition: const.h:320
Proto::GameServerRuleViolationRemove
@ GameServerRuleViolationRemove
Definition: protocolcodes.h:130
Game::processDeath
void processDeath(int deathType, int penality)
Definition: game.cpp:231
Outfit::setAddons
void setAddons(int addons)
Definition: outfit.h:47
z
gc sort z
Definition: CMakeLists.txt:176
Game::processEditList
void processEditList(uint id, int doorId, const std::string &text)
Definition: game.cpp:500
Otc::ChaseModes
ChaseModes
Definition: const.h:211
UnjustifiedPoints::killsDayRemaining
uint8 killsDayRemaining
Definition: game.h:50
Item::setCountOrSubType
void setCountOrSubType(int value)
Definition: item.h:89
Proto::GameServerPremiumTrigger
@ GameServerPremiumTrigger
Definition: protocolcodes.h:114
Game::processQuestLog
void processQuestLog(const std::vector< std::tuple< int, std::string, bool > > &questList)
Definition: game.cpp:505
Otc::Fishing
@ Fishing
Definition: const.h:151
Proto::CreatureTypePlayer
@ CreatureTypePlayer
Definition: protocolcodes.h:277
UnjustifiedPoints::killsDay
uint8 killsDay
Definition: game.h:49
Proto::GameServerOpenPrivateChannel
@ GameServerOpenPrivateChannel
Definition: protocolcodes.h:128
Otc::MessagePrivateFrom
@ MessagePrivateFrom
Definition: const.h:291
Position::x
int x
Definition: position.h:243
InputMessage::getU16
uint16 getU16()
Definition: inputmessage.cpp:56
EffectPtr
stdext::shared_object_ptr< Effect > EffectPtr
Definition: declarations.h:68
Effect
Definition: effect.h:31
Proto::GameServerMissleEffect
@ GameServerMissleEffect
Definition: protocolcodes.h:97
LocalPlayer::lockWalk
void lockWalk(int millis=250)
Definition: localplayer.cpp:60
Game::processRuleViolationChannel
void processRuleViolationChannel(int channelId)
Definition: game.cpp:387
Proto::GameServerBlessings
@ GameServerBlessings
Definition: protocolcodes.h:112
Proto::GameServerQuestLog
@ GameServerQuestLog
Definition: protocolcodes.h:151
Otc::MessageRVRContinue
@ MessageRVRContinue
Definition: const.h:338
Otc::GamePlayerAddons
@ GamePlayerAddons
Definition: const.h:387
Proto::GameServerPlayerSkills
@ GameServerPlayerSkills
Definition: protocolcodes.h:117
Proto::GameServerMapBottomRow
@ GameServerMapBottomRow
Definition: protocolcodes.h:74
ProtocolGame::setMapDescription
void setMapDescription(const InputMessagePtr &msg, int x, int y, int z, int width, int height)
Definition: protocolgameparse.cpp:2044
g_dispatcher
EventDispatcher g_dispatcher
Definition: eventdispatcher.cpp:28
Proto::GameServerOpenChannel
@ GameServerOpenChannel
Definition: protocolcodes.h:127
Otc::GameChannelPlayerList
@ GameChannelPlayerList
Definition: const.h:356
Proto::GameServerFirstGameOpcode
@ GameServerFirstGameOpcode
Definition: protocolcodes.h:61
PlayerPtr
stdext::shared_object_ptr< Player > PlayerPtr
Definition: declarations.h:66
Otc::MessageChannel
@ MessageChannel
Definition: const.h:294
uint32
uint32_t uint32
Definition: types.h:35
Creature::setDirection
void setDirection(Otc::Direction direction)
Definition: creature.cpp:659
luavaluecasts.h
Creature
Definition: creature.h:37
LocalPlayer::setLevel
void setLevel(double level, double levelPercent)
Definition: localplayer.cpp:413
Proto::GameServerStoreButtonIndicators
@ GameServerStoreButtonIndicators
Definition: protocolcodes.h:54
Game::processInventoryChange
void processInventoryChange(int slot, const ItemPtr &item)
Definition: game.cpp:354
Proto::GameServerMapTopRow
@ GameServerMapTopRow
Definition: protocolcodes.h:72
Otc::GameLoginPending
@ GameLoginPending
Definition: const.h:378
Game::processTutorialHint
void processTutorialHint(int id)
Definition: game.cpp:419
Proto::GameServerDeath
@ GameServerDeath
Definition: protocolcodes.h:58
ProtocolGame::getOutfit
Outfit getOutfit(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2104
Proto::GameServerCloseContainer
@ GameServerCloseContainer
Definition: protocolcodes.h:82
Otc::GameAdditionalVipInfo
@ GameAdditionalVipInfo
Definition: const.h:395
LuaInterface::callGlobalField
void callGlobalField(const std::string &global, const std::string &field, const T &... args)
Definition: luainterface.h:445
UnjustifiedPoints::killsWeek
uint8 killsWeek
Definition: game.h:51
Game::processPlayerGoods
void processPlayerGoods(int money, const std::vector< std::tuple< ItemPtr, int > > &goods)
Definition: game.cpp:470
InputMessage::getReadPos
int getReadPos()
Definition: inputmessage.h:60
Game::processEditText
void processEditText(uint id, int itemId, int maxLength, const std::string &text, const std::string &writer, const std::string &date)
Definition: game.cpp:495
MissilePtr
stdext::shared_object_ptr< Missile > MissilePtr
Definition: declarations.h:69
Proto::GameServerCreatureMarks
@ GameServerCreatureMarks
Definition: protocolcodes.h:107
AwareRange::bottom
int bottom
Definition: map.h:131
Game::processGMActions
void processGMActions(const std::vector< uint8 > &actions)
Definition: game.cpp:239
ProtocolGame::getThing
ThingPtr getThing(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2160
Map::getThing
ThingPtr getThing(const Position &pos, int stackPos)
Definition: map.cpp:170
Proto::GameServerCreatureOutfit
@ GameServerCreatureOutfit
Definition: protocolcodes.h:102
Proto::GameServerTalk
@ GameServerTalk
Definition: protocolcodes.h:125
LocalPlayer::setKnown
void setKnown(bool known)
Definition: localplayer.h:57
StaticText
Definition: statictext.h:31
Game::processLoginToken
void processLoginToken(bool unknown)
Definition: game.cpp:159
InputMessage::getU8
uint8 getU8()
Definition: inputmessage.cpp:48
Logger::error
void error(const std::string &what)
Definition: logger.h:54
Otc::GameClientPing
@ GameClientPing
Definition: const.h:369
Thing::getAnimationPhases
int getAnimationPhases()
Definition: thing.h:76
Map::cleanTile
void cleanTile(const Position &pos)
Definition: map.cpp:350
Game::getClientVersion
int getClientVersion()
Definition: game.h:316
Game::processAddAutomapFlag
void processAddAutomapFlag(const Position &pos, int icon, const std::string &message)
Definition: game.cpp:424
ProtocolGame::sendLoginPacket
void sendLoginPacket(uint challengeTimestamp, uint8 challengeRandom)
Definition: protocolgamesend.cpp:51
Otc::MessageSay
@ MessageSay
Definition: const.h:288
Proto::GameServerPlayerDataBasic
@ GameServerPlayerDataBasic
Definition: protocolcodes.h:115
Proto::GameServerCreatureType
@ GameServerCreatureType
Definition: protocolcodes.h:109
Outfit::setCategory
void setCategory(ThingCategory category)
Definition: outfit.h:49
Proto::GameServerCoinBalanceUpdating
@ GameServerCoinBalanceUpdating
Definition: protocolcodes.h:153
Proto::Creature
@ Creature
Definition: protocolcodes.h:40
Game::processCloseTrade
void processCloseTrade()
Definition: game.cpp:490
Game::processLoginAdvice
void processLoginAdvice(const std::string &message)
Definition: game.cpp:149
Creature::setLight
void setLight(const Light &light)
Definition: creature.h:59
Proto::CreatureTypeNpc
@ CreatureTypeNpc
Definition: protocolcodes.h:279
Otc::MessageNpcFrom
@ MessageNpcFrom
Definition: const.h:297
Game::processOpenOwnPrivateChannel
void processOpenOwnPrivateChannel(int channelId, const std::string &name)
Definition: game.cpp:377
Otc::MessageMana
@ MessageMana
Definition: const.h:328
Proto::GameServerAmbient
@ GameServerAmbient
Definition: protocolcodes.h:94
Otc::MessageGamemasterChannel
@ MessageGamemasterChannel
Definition: const.h:300
Item::setId
void setId(uint32 id)
Definition: item.cpp:93
Otc::SEA_FLOOR
@ SEA_FLOOR
Definition: const.h:32
Game::processLoginError
void processLoginError(const std::string &error)
Definition: game.cpp:144
g_game
Game g_game
Definition: game.cpp:37
Otc::MessageHeal
@ MessageHeal
Definition: const.h:310
Proto::GameServerUpdateNeeded
@ GameServerUpdateNeeded
Definition: protocolcodes.h:48
Position::y
int y
Definition: position.h:244
Otc::GamePlayerMounts
@ GamePlayerMounts
Definition: const.h:357
Proto::MonsterStartId
@ MonsterStartId
Definition: protocolcodes.h:288
Proto::GameServerDeleteOnMap
@ GameServerDeleteOnMap
Definition: protocolcodes.h:79
Map::addCreature
void addCreature(const CreaturePtr &creature)
Definition: map.cpp:466
Map::setLight
void setLight(const Light &light)
Definition: map.h:223
Proto::GameServerEditList
@ GameServerEditList
Definition: protocolcodes.h:111
Proto::PlayerEndId
@ PlayerEndId
Definition: protocolcodes.h:287
Otc::GameBaseSkillU16
@ GameBaseSkillU16
Definition: const.h:396
ThingCategoryEffect
@ ThingCategoryEffect
Definition: thingtype.h:45
InputMessage::eof
bool eof()
Definition: inputmessage.h:64
Game::processCloseNpcTrade
void processCloseNpcTrade()
Definition: game.cpp:475
stdext::format
std::string format()
Definition: format.h:82
stdext::time
ticks_t time()
Definition: time.cpp:33
Proto::GameServerVipLogout
@ GameServerVipLogout
Definition: protocolcodes.h:145
Otc::MessageNpcTo
@ MessageNpcTo
Definition: const.h:298
Game::processPendingGame
void processPendingGame()
Definition: game.cpp:169
InputMessage::getUnreadSize
int getUnreadSize()
Definition: inputmessage.h:61
Thing::isFluidContainer
bool isFluidContainer()
Definition: thing.h:96
Proto::GameServerFullMap
@ GameServerFullMap
Definition: protocolcodes.h:71
Creature::setType
void setType(uint8 type)
Definition: creature.cpp:754
Otc::GameDoubleSkills
@ GameDoubleSkills
Definition: const.h:372
Proto::GameServerSetStoreDeepLink
@ GameServerSetStoreDeepLink
Definition: protocolcodes.h:124
Game::processRemoveAutomapFlag
void processRemoveAutomapFlag(const Position &pos, int icon, const std::string &message)
Definition: game.cpp:429
Otc::GameMessageStatements
@ GameMessageStatements
Definition: const.h:388
Otc::LastSkill
@ LastSkill
Definition: const.h:158
Proto::GameServerPing
@ GameServerPing
Definition: protocolcodes.h:56
Proto::GameServerStoreOffers
@ GameServerStoreOffers
Definition: protocolcodes.h:163
Otc::Skill
Skill
Definition: const.h:144
Outfit::setAuxId
void setAuxId(int id)
Definition: outfit.h:42
Creature::setSkull
void setSkull(uint8 skull)
Definition: creature.cpp:736
LocalPlayer::setBaseMagicLevel
void setBaseMagicLevel(double baseMagicLevel)
Definition: localplayer.cpp:449
Proto::GameServerQuestLine
@ GameServerQuestLine
Definition: protocolcodes.h:152
int8
int8_t int8
Definition: types.h:41
Otc::GameLooktypeU16
@ GameLooktypeU16
Definition: const.h:385
Otc::MessageGamemasterPrivateFrom
@ MessageGamemasterPrivateFrom
Definition: const.h:301
Position::z
short z
Definition: position.h:245
Proto::GameServerChangeOnMap
@ GameServerChangeOnMap
Definition: protocolcodes.h:78
Game::setServerBeat
void setServerBeat(int beat)
Definition: game.h:337
uint16
uint16_t uint16
Definition: types.h:36
Otc::MessageYell
@ MessageYell
Definition: const.h:290
UnjustifiedPoints::skullTime
uint8 skullTime
Definition: game.h:55
ProtocolGame::getItem
ItemPtr getItem(const InputMessagePtr &msg, int id=0)
Definition: protocolgameparse.cpp:2352
Proto::GameServerLoginOrPendingState
@ GameServerLoginOrPendingState
Definition: protocolcodes.h:45
Otc::GameNameOnNpcTrade
@ GameNameOnNpcTrade
Definition: const.h:350
Proto::GameServerOpenNpcTrade
@ GameServerOpenNpcTrade
Definition: protocolcodes.h:88
Otc::GameExperienceBonus
@ GameExperienceBonus
Definition: const.h:409
Game::processContainerRemoveItem
void processContainerRemoveItem(int containerId, int slot, const ItemPtr &lastItem)
Definition: game.cpp:344
Light::intensity
uint8 intensity
Definition: thingtype.h:119
Proto::GameServerRuleViolationLock
@ GameServerRuleViolationLock
Definition: protocolcodes.h:132
Otc::Direction
Direction
Definition: const.h:161
Otc::UNDERGROUND_FLOOR
@ UNDERGROUND_FLOOR
Definition: const.h:34
Game::processEnterGame
void processEnterGame()
Definition: game.cpp:176
Proto::GameServerLoginError
@ GameServerLoginError
Definition: protocolcodes.h:49
localplayer.h
Proto::GameServerVipAdd
@ GameServerVipAdd
Definition: protocolcodes.h:143
Outfit
Definition: outfit.h:29
Proto::GameServerMapLeftRow
@ GameServerMapLeftRow
Definition: protocolcodes.h:75
Thing::isSplash
bool isSplash()
Definition: thing.h:97
Proto::GameServerTrappers
@ GameServerTrappers
Definition: protocolcodes.h:99
LocalPlayer::setMagicLevel
void setMagicLevel(double magicLevel, double magicLevelPercent)
Definition: localplayer.cpp:437
Proto::GameServerChooseOutfit
@ GameServerChooseOutfit
Definition: protocolcodes.h:142
Proto::GameServerSetInventory
@ GameServerSetInventory
Definition: protocolcodes.h:86
Monster
Definition: creature.h:217
Proto::GameServerChallenge
@ GameServerChallenge
Definition: protocolcodes.h:57
Otc::MessageInvalid
@ MessageInvalid
Definition: const.h:342
LocalPlayer::setStates
void setStates(int states)
Definition: localplayer.cpp:321
Otc::MessageExp
@ MessageExp
Definition: const.h:311
Proto::translateMessageModeFromServer
Otc::MessageMode translateMessageModeFromServer(uint8 mode)
Definition: protocolcodes.cpp:176
Proto::GameServerCreatureSpeed
@ GameServerCreatureSpeed
Definition: protocolcodes.h:103
uint
unsigned int uint
Definition: types.h:31
Otc::MessageMode
MessageMode
Definition: const.h:286
LuaObject::callLuaField
R callLuaField(const std::string &field, const T &... args)
Definition: luaobject.h:172
Creature::getName
std::string getName()
Definition: creature.h:82
Otc::GameTotalCapacity
@ GameTotalCapacity
Definition: const.h:353
Otc::GameNewOutfitProtocol
@ GameNewOutfitProtocol
Definition: const.h:392
Proto::PlayerStartId
@ PlayerStartId
Definition: protocolcodes.h:286
ThingCategoryCreature
@ ThingCategoryCreature
Definition: thingtype.h:44
Proto::GameServerCloseTrade
@ GameServerCloseTrade
Definition: protocolcodes.h:93
Proto::MonsterEndId
@ MonsterEndId
Definition: protocolcodes.h:289
LocalPlayer::setPremium
void setPremium(bool premium)
Definition: localplayer.cpp:504
g_logger
Logger g_logger
Definition: logger.cpp:35
Npc
Definition: creature.h:210
Otc::MessageBarkLoud
@ MessageBarkLoud
Definition: const.h:322
LocalPlayer::setExperience
void setExperience(double experience)
Definition: localplayer.cpp:403
g_lua
LuaInterface g_lua
Definition: luainterface.cpp:31
Game::setUnjustifiedPoints
void setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints)
Definition: game.cpp:1216
Game::canReportBugs
bool canReportBugs()
Definition: game.h:340
Creature::setIcon
void setIcon(uint8 icon)
Definition: creature.cpp:760
Proto::GameServerChangeMapAwareRange
@ GameServerChangeMapAwareRange
Definition: protocolcodes.h:68
LocalPlayer::setSoul
void setSoul(double soul)
Definition: localplayer.cpp:459
Game::processOpenContainer
void processOpenContainer(int containerId, const ItemPtr &containerItem, const std::string &name, int capacity, bool hasParent, const std::vector< ItemPtr > &items, bool isUnlocked, bool hasPages, int containerSize, int firstIndex)
Definition: game.cpp:297
Proto::GameServerFloorChangeUp
@ GameServerFloorChangeUp
Definition: protocolcodes.h:140
Otc::GamePlayerRegenerationTime
@ GamePlayerRegenerationTime
Definition: const.h:355
Proto::GameServerMarkCreature
@ GameServerMarkCreature
Definition: protocolcodes.h:98
Proto::GameServerAutomapFlag
@ GameServerAutomapFlag
Definition: protocolcodes.h:147
Outfit::setId
void setId(int id)
Definition: outfit.h:41
Map::addThing
void addThing(const ThingPtr &thing, const Position &pos, int stackPos=-1)
Definition: map.cpp:107
Otc::GameContainerPagination
@ GameContainerPagination
Definition: const.h:383
Position
Definition: position.h:33
Creature::setName
void setName(const std::string &name)
Definition: creature.cpp:631
Otc::GameAdditionalSkills
@ GameAdditionalSkills
Definition: const.h:419
Outfit::setHead
void setHead(int head)
Definition: outfit.h:43
UnjustifiedPoints::killsMonthRemaining
uint8 killsMonthRemaining
Definition: game.h:54
Otc::GameDoubleHealth
@ GameDoubleHealth
Definition: const.h:371
Creature::setSpeed
void setSpeed(uint16 speed)
Definition: creature.cpp:714
InputMessage::getString
std::string getString()
Definition: inputmessage.cpp:80
EventDispatcher::addEvent
EventPtr addEvent(const std::function< void()> &callback, bool pushFront=false)
Definition: eventdispatcher.cpp:104
Otc::MessageGamemasterBroadcast
@ MessageGamemasterBroadcast
Definition: const.h:299
missile.h
Proto::GameServerDeleteInContainer
@ GameServerDeleteInContainer
Definition: protocolcodes.h:85
ProtocolGame::getCreature
CreaturePtr getCreature(const InputMessagePtr &msg, int type=0)
Definition: protocolgameparse.cpp:2203
Otc::MessageRVRAnswer
@ MessageRVRAnswer
Definition: const.h:337
LocalPlayer::setVocation
void setVocation(int vocation)
Definition: localplayer.cpp:494
Proto::GameServerCloseNpcTrade
@ GameServerCloseNpcTrade
Definition: protocolcodes.h:90
Proto::GameServerMapRightRow
@ GameServerMapRightRow
Definition: protocolcodes.h:73
Outfit::setMount
void setMount(int mount)
Definition: outfit.h:48
ThingCategoryItem
@ ThingCategoryItem
Definition: thingtype.h:43
Proto::GameServerOwnTrade
@ GameServerOwnTrade
Definition: protocolcodes.h:91
UnjustifiedPoints::killsWeekRemaining
uint8 killsWeekRemaining
Definition: game.h:52
Otc::MessageExpOthers
@ MessageExpOthers
Definition: const.h:314
Proto::GameServerEnterGame
@ GameServerEnterGame
Definition: protocolcodes.h:47
Game::processCloseContainer
void processCloseContainer(int containerId)
Definition: game.cpp:313
map.h
Otc::GamePlayerStamina
@ GamePlayerStamina
Definition: const.h:386
Otc::MessageGuild
@ MessageGuild
Definition: const.h:318
InputMessage::getU64
uint64 getU64()
Definition: inputmessage.cpp:72
Game::getFeature
bool getFeature(Otc::GameFeature feature)
Definition: game.h:310
Otc::GameDoubleShopSellAmount
@ GameDoubleShopSellAmount
Definition: const.h:382
InputMessage::getU32
uint32 getU32()
Definition: inputmessage.cpp:64
Otc::MessageDamageOthers
@ MessageDamageOthers
Definition: const.h:312
Creature::setPassable
void setPassable(bool passable)
Definition: creature.h:72
Map::removeCreatureById
void removeCreatureById(uint32 id)
Definition: map.cpp:479
AwareRange::vertical
int vertical()
Definition: map.h:135
ProtocolGame::setTileDescription
int setTileDescription(const InputMessagePtr &msg, Position position)
Definition: protocolgameparse.cpp:2080
Proto::GameServerStoreCompletePurchase
@ GameServerStoreCompletePurchase
Definition: protocolcodes.h:165
Otc::PVPModes
PVPModes
Definition: const.h:216
AwareRange::horizontal
int horizontal()
Definition: map.h:134
Proto::GameServerDeleteInventory
@ GameServerDeleteInventory
Definition: protocolcodes.h:87
Otc::GameWritableDate
@ GameWritableDate
Definition: const.h:394
Proto::GameServerCreateOnMap
@ GameServerCreateOnMap
Definition: protocolcodes.h:77
Otc::MAX_Z
@ MAX_Z
Definition: const.h:33
ProtocolGame::getPosition
Position getPosition(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2394
Otc::MessageChannelHighlight
@ MessageChannelHighlight
Definition: const.h:295
Proto::GameServerVipState
@ GameServerVipState
Definition: protocolcodes.h:144
Otc::MessageDamageDealed
@ MessageDamageDealed
Definition: const.h:308
Proto::GameServerPreset
@ GameServerPreset
Definition: protocolcodes.h:113
Otc::GameCreatureIcons
@ GameCreatureIcons
Definition: const.h:397
Otc::GameItemAnimationPhase
@ GameItemAnimationPhase
Definition: const.h:360
InputMessage::setReadPos
void setReadPos(uint16 readPos)
Definition: inputmessage.h:44
stdext::throw_exception
void throw_exception(const std::string &what)
Throws a generic exception.
Definition: exception.h:43
Game::processRuleViolationLock
void processRuleViolationLock()
Definition: game.cpp:402
LocalPlayer::setOfflineTrainingTime
void setOfflineTrainingTime(double offlineTrainingTime)
Definition: localplayer.cpp:523
Game::processContainerAddItem
void processContainerAddItem(int containerId, const ItemPtr &item, int slot)
Definition: game.cpp:324
Proto::GameServerRuleViolationChannel
@ GameServerRuleViolationChannel
Definition: protocolcodes.h:129
Item::create
static ItemPtr create(int id)
Definition: item.cpp:51
Creature::showStaticSquare
void showStaticSquare(const Color &color)
Definition: creature.h:78
Proto::GameServerWalkWait
@ GameServerWalkWait
Definition: protocolcodes.h:137
stdext::to_string
std::string to_string(const T &t)
Definition: string.h:35
InputMessage::peekU16
uint16 peekU16()
Definition: inputmessage.h:53
Otc::GameSkillsBase
@ GameSkillsBase
Definition: const.h:354
AwareRange
Definition: map.h:127
Otc::GameOfflineTrainingTime
@ GameOfflineTrainingTime
Definition: const.h:365
Game::processVipAdd
void processVipAdd(uint id, const std::string &name, uint status, const std::string &description, int iconId, bool notifyLogin)
Definition: game.cpp:407
Item
Definition: item.h:76
Proto::GameServerCloseChannel
@ GameServerCloseChannel
Definition: protocolcodes.h:134
Proto::GameServerTutorialHint
@ GameServerTutorialHint
Definition: protocolcodes.h:146
Proto::GameServerSpellDelay
@ GameServerSpellDelay
Definition: protocolcodes.h:121
stdext::exception::what
virtual const char * what() const
Definition: exception.h:37
Game::processPingBack
void processPingBack()
Definition: game.cpp:271
Creature::setSpeedFormula
void setSpeedFormula(double speedA, double speedB, double speedC)
Definition: creature.cpp:801
Proto::GameServerEditText
@ GameServerEditText
Definition: protocolcodes.h:110
Proto::GameServerRuleViolationCancel
@ GameServerRuleViolationCancel
Definition: protocolcodes.h:131
LocalPlayer::setTotalCapacity
void setTotalCapacity(double totalCapacity)
Definition: localplayer.cpp:393
Otc::GameMinimapRemove
@ GameMinimapRemove
Definition: const.h:381
MonsterPtr
stdext::shared_object_ptr< Monster > MonsterPtr
Definition: declarations.h:64
Otc::GameMagicEffectU16
@ GameMagicEffectU16
Definition: const.h:361
Game::processOpenPrivateChannel
void processOpenPrivateChannel(const std::string &name)
Definition: game.cpp:372
Proto::GameServerChangeInContainer
@ GameServerChangeInContainer
Definition: protocolcodes.h:84
AwareRange::left
int left
Definition: map.h:132
Game::processChannelList
void processChannelList(const std::vector< std::tuple< int, std::string > > &channelList)
Definition: game.cpp:362
Otc::GameMapMovePosition
@ GameMapMovePosition
Definition: const.h:374
Game::setOpenPvpSituations
void setOpenPvpSituations(int openPvpSituations)
Definition: game.cpp:1229
Proto::GameServerOpenContainer
@ GameServerOpenContainer
Definition: protocolcodes.h:81
LocalPlayer::setBaseSkill
void setBaseSkill(Otc::Skill skill, int baseLevel)
Definition: localplayer.cpp:349
Game::processRuleViolationRemove
void processRuleViolationRemove(const std::string &name)
Definition: game.cpp:392
effect.h
Otc::GameIngameStoreHighlights
@ GameIngameStoreHighlights
Definition: const.h:417
Game::formatCreatureName
std::string formatCreatureName(const std::string &name)
Definition: game.cpp:1713
Missile
Definition: missile.h:31
Otc::MessageMonsterSay
@ MessageMonsterSay
Definition: const.h:333
Otc::GameDoubleExperience
@ GameDoubleExperience
Definition: const.h:352
stdext::shared_object_ptr< InputMessage >
Otc::MessagePartyManagement
@ MessagePartyManagement
Definition: const.h:319
Proto::GameServerCreatureHealth
@ GameServerCreatureHealth
Definition: protocolcodes.h:100
Proto::GameServerStoreError
@ GameServerStoreError
Definition: protocolcodes.h:149
Game::processContainerUpdateItem
void processContainerUpdateItem(int containerId, int slot, const ItemPtr &item)
Definition: game.cpp:334
LocalPlayer::setStamina
void setStamina(double stamina)
Definition: localplayer.cpp:469
Proto::GameServerStore
@ GameServerStore
Definition: protocolcodes.h:162
Otc::MessageDamageReceived
@ MessageDamageReceived
Definition: const.h:309
LocalPlayer::setSpells
void setSpells(const std::vector< int > &spells)
Definition: localplayer.cpp:533
Proto::GameServerUpdateTile
@ GameServerUpdateTile
Definition: protocolcodes.h:76
Otc::GamePenalityOnDeath
@ GamePenalityOnDeath
Definition: const.h:349
Proto::GameServerPlayerGoods
@ GameServerPlayerGoods
Definition: protocolcodes.h:89
Proto::GameServerFloorChangeDown
@ GameServerFloorChangeDown
Definition: protocolcodes.h:141
Otc::MessageWhisper
@ MessageWhisper
Definition: const.h:289
Otc::GamePlayerStateU16
@ GamePlayerStateU16
Definition: const.h:391
Light::color
uint8 color
Definition: thingtype.h:120
Game::processCounterTrade
void processCounterTrade(const std::string &name, const std::vector< ItemPtr > &items)
Definition: game.cpp:485
Otc::GameDoubleFreeCapacity
@ GameDoubleFreeCapacity
Definition: const.h:351
NpcPtr
stdext::shared_object_ptr< Npc > NpcPtr
Definition: declarations.h:65
AnimatedText
Definition: animatedtext.h:32
StaticTextPtr
stdext::shared_object_ptr< StaticText > StaticTextPtr
Definition: declarations.h:71
Proto::GameServerGraphicalEffect
@ GameServerGraphicalEffect
Definition: protocolcodes.h:95
Light
Definition: thingtype.h:117
Game::processVipStateChange
void processVipStateChange(uint id, uint status)
Definition: game.cpp:413
UnjustifiedPoints::killsMonth
uint8 killsMonth
Definition: game.h:53
game.h
Otc::GameCreatureEmblems
@ GameCreatureEmblems
Definition: const.h:359
Game::processRuleViolationCancel
void processRuleViolationCancel(const std::string &name)
Definition: game.cpp:397
Proto::GameServerCounterTrade
@ GameServerCounterTrade
Definition: protocolcodes.h:92
Otc::GameMessageLevel
@ GameMessageLevel
Definition: const.h:389
Proto::GameServerPlayerModes
@ GameServerPlayerModes
Definition: protocolcodes.h:120
Game::processGameStart
void processGameStart()
Definition: game.cpp:182
Thing::setPosition
void setPosition(const Position &position)
Definition: thing.cpp:36
Proto::GameServerItemInfo
@ GameServerItemInfo
Definition: protocolcodes.h:155
LocalPlayer::setBlessings
void setBlessings(int blessings)
Definition: localplayer.cpp:543
Proto::GameServerMoveCreature
@ GameServerMoveCreature
Definition: protocolcodes.h:80
Proto::GameServerChannels
@ GameServerChannels
Definition: protocolcodes.h:126
Creature::hideStaticSquare
void hideStaticSquare()
Definition: creature.h:79
Otc::GameDeathType
@ GameDeathType
Definition: const.h:413
Proto::GameServerCreatureSkull
@ GameServerCreatureSkull
Definition: protocolcodes.h:104
protocolgame.h
Game::processTalk
void processTalk(const std::string &name, int level, Otc::MessageMode mode, const std::string &text, int channelId, const Position &pos)
Definition: game.cpp:292
Proto::GameServerCreateContainer
@ GameServerCreateContainer
Definition: protocolcodes.h:83
Map::setCentralPosition
void setCentralPosition(const Position &centralPosition)
Definition: map.cpp:534
Proto::GameServerPlayerInventory
@ GameServerPlayerInventory
Definition: protocolcodes.h:156
Otc::GameIngameStore
@ GameIngameStore
Definition: const.h:416
Game::processUpdateNeeded
void processUpdateNeeded(const std::string &signature)
Definition: game.cpp:139
Proto::GameServerStoreTransactionHistory
@ GameServerStoreTransactionHistory
Definition: protocolcodes.h:164
Creature::setHealthPercent
void setHealthPercent(uint8 healthPercent)
Definition: creature.cpp:637
Otc::AWARE_UNDEGROUND_FLOOR_RANGE
@ AWARE_UNDEGROUND_FLOOR_RANGE
Definition: const.h:35
Color::from8bit
static Color from8bit(int color)
Definition: color.h:90
Otc::FightModes
FightModes
Definition: const.h:205
ProtocolGame::getMappedThing
ThingPtr getMappedThing(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2178
Map::getCreatureById
CreaturePtr getCreatureById(uint32 id)
Definition: map.cpp:471
Proto::GameServerRequestPurchaseData
@ GameServerRequestPurchaseData
Definition: protocolcodes.h:150
Proto::GameServerMultiUseDelay
@ GameServerMultiUseDelay
Definition: protocolcodes.h:123
Game::processAttackCancel
void processAttackCancel(uint seq)
Definition: game.cpp:520
Otc::MessageChannelManagement
@ MessageChannelManagement
Definition: const.h:293
Otc::MessageNpcFromStartBlock
@ MessageNpcFromStartBlock
Definition: const.h:340
Otc::MessageMonsterYell
@ MessageMonsterYell
Definition: const.h:332
tile.h
Map::getCentralPosition
Position getCentralPosition()
Definition: map.h:236
Creature::setBaseSpeed
void setBaseSpeed(double baseSpeed)
Definition: creature.cpp:726
LocalPlayer::setFreeCapacity
void setFreeCapacity(double freeCapacity)
Definition: localplayer.cpp:383
ProtocolGame::getStaticText
StaticTextPtr getStaticText(const InputMessagePtr &msg, int type=0)
Definition: protocolgameparse.cpp:2381
Creature::setOutfit
void setOutfit(const Outfit &outfit)
Definition: creature.cpp:665
Otc::GamePremiumExpiration
@ GamePremiumExpiration
Definition: const.h:400
Proto::UnknownCreature
@ UnknownCreature
Definition: protocolcodes.h:38
UnjustifiedPoints
Definition: game.h:39
Proto::GameServerSpellGroupDelay
@ GameServerSpellGroupDelay
Definition: protocolcodes.h:122
ItemPtr
stdext::shared_object_ptr< Item > ItemPtr
Definition: declarations.h:61
Proto::GameServerLoginToken
@ GameServerLoginToken
Definition: protocolcodes.h:53
Game::setExpertPvpMode
void setExpertPvpMode(bool enable)
Definition: game.h:341
Proto::StaticText
@ StaticText
Definition: protocolcodes.h:37
AwareRange::top
int top
Definition: map.h:129
Game::processLoginWait
void processLoginWait(const std::string &message, int time)
Definition: game.cpp:154
g_things
ThingTypeManager g_things
Definition: thingtypemanager.cpp:38
Map::removeThing
bool removeThing(const ThingPtr &thing)
Definition: map.cpp:177
Game::processPlayerHelpers
void processPlayerHelpers(int helpers)
Definition: game.cpp:245
Creature::setEmblem
void setEmblem(uint8 emblem)
Definition: creature.cpp:748
AwareRange::right
int right
Definition: map.h:130
Thing::isStackable
bool isStackable()
Definition: thing.h:90
Otc::DeathRegular
@ DeathRegular
Definition: const.h:486
Game::processOwnTrade
void processOwnTrade(const std::string &name, const std::vector< ItemPtr > &items)
Definition: game.cpp:480
Outfit::setLegs
void setLegs(int legs)
Definition: outfit.h:45
Proto::GameServerPvpSituations
@ GameServerPvpSituations
Definition: protocolcodes.h:139
Proto::GameServerChannelEvent
@ GameServerChannelEvent
Definition: protocolcodes.h:154
Proto::GameServerLoginAdvice
@ GameServerLoginAdvice
Definition: protocolcodes.h:50
Game::processOpenNpcTrade
void processOpenNpcTrade(const std::vector< std::tuple< ItemPtr, std::string, int, int, int > > &items)
Definition: game.cpp:465
Player
Definition: player.h:29
Proto::GameServerTextMessage
@ GameServerTextMessage
Definition: protocolcodes.h:135
uint8
uint8_t uint8
Definition: types.h:37
Otc::GameEnvironmentEffect
@ GameEnvironmentEffect
Definition: const.h:358
Proto::GameServerPlayerData
@ GameServerPlayerData
Definition: protocolcodes.h:116
Game::processCloseChannel
void processCloseChannel(int channelId)
Definition: game.cpp:382
Logger::info
void info(const std::string &what)
Definition: logger.h:52
Game::processPlayerModes
void processPlayerModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeMode, Otc::PVPModes pvpMode)
Definition: game.cpp:250
ThingTypeManager::isValidDatId
bool isValidDatId(uint16 id, ThingCategory category)
Definition: thingtypemanager.h:75
Map::getAwareRange
AwareRange getAwareRange()
Definition: map.h:233
stdext::exception
Definition: exception.h:31
ProtocolGame::setFloorDescription
int setFloorDescription(const InputMessagePtr &msg, int x, int y, int z, int width, int height, int offset, int skip)
Definition: protocolgameparse.cpp:2064
Otc::MessageHealOthers
@ MessageHealOthers
Definition: const.h:313
LocalPlayer::setSkill
void setSkill(Otc::Skill skill, int level, int levelPercent)
Definition: localplayer.cpp:331
Proto::GameServerOpenOwnChannel
@ GameServerOpenOwnChannel
Definition: protocolcodes.h:133
Otc::MessageSpell
@ MessageSpell
Definition: const.h:296
item.h
Proto::GameServerPlayerHelpers
@ GameServerPlayerHelpers
Definition: protocolcodes.h:108