Otclient 1.0  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 
26 #include "effect.h"
27 #include "game.h"
28 #include "item.h"
29 #include "localplayer.h"
30 #include "luavaluecasts.h"
31 #include "map.h"
32 #include "missile.h"
33 #include "thingtypemanager.h"
34 #include "tile.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  const int readPos = msg->getReadPos();
55  if(callLuaField<bool>("onOpcode", opcode, msg))
56  continue;
57  msg->setReadPos(readPos);
58  // 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", static_cast<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  const uint playerId = msg->getU32();
413  const int serverBeat = msg->getU16();
414 
416  Creature::speedA = msg->getDouble();
417  Creature::speedB = msg->getDouble();
418  Creature::speedC = msg->getDouble();
419  }
420 
421  const 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  const 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  const 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  const 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  const 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  const 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  msg->getU8(); // == 1; // isUpdating
538 }
539 
540 void ProtocolGame::parseCompleteStorePurchase(const InputMessagePtr& msg)
541 {
542  // not used
543  msg->getU8();
544 
545  const std::string message = msg->getString();
546  const int coins = msg->getU32();
547  const 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  const 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  const 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  const 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  const 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  const 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  const int subOffers = msg->getU16();
603  for(int j = 0; j < subOffers; ++j) {
604  msg->getString(); // name
605  msg->getString(); // description
606 
607  const 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  const int errorType = msg->getU8();
619  const 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  const uint8 openPvpSituations = msg->getU8();
640 
641  g_game.setOpenPvpSituations(openPvpSituations);
642 }
643 
644 void ProtocolGame::parsePlayerHelpers(const InputMessagePtr& msg)
645 {
646  const uint id = msg->getU32();
647  const int helpers = msg->getU16();
648 
649  const 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  const std::string signature = msg->getString();
677  g_game.processUpdateNeeded(signature);
678 }
679 
680 void ProtocolGame::parseLoginError(const InputMessagePtr& msg)
681 {
682  const std::string error = msg->getString();
683 
684  g_game.processLoginError(error);
685 }
686 
687 void ProtocolGame::parseLoginAdvice(const InputMessagePtr& msg)
688 {
689  const std::string message = msg->getString();
690 
691  g_game.processLoginAdvice(message);
692 }
693 
694 void ProtocolGame::parseLoginWait(const InputMessagePtr& msg)
695 {
696  const std::string message = msg->getString();
697  const int time = msg->getU8();
698 
699  g_game.processLoginWait(message, time);
700 }
701 
702 void ProtocolGame::parseLoginToken(const InputMessagePtr& msg)
703 {
704  const bool unknown = msg->getU8() == 0;
705  g_game.processLoginToken(unknown);
706 }
707 
708 void ProtocolGame::parsePing(const InputMessagePtr&)
709 {
711 }
712 
713 void ProtocolGame::parsePingBack(const InputMessagePtr&)
714 {
716 }
717 
718 void ProtocolGame::parseChallenge(const InputMessagePtr& msg)
719 {
720  const uint timestamp = msg->getU32();
721  const 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  const 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 
796  ++pos.y;
797 
798  AwareRange range = g_map.getAwareRange();
799  setMapDescription(msg, pos.x - range.left, pos.y + range.bottom, pos.z, range.horizontal(), 1);
801 }
802 
803 void ProtocolGame::parseMapMoveWest(const InputMessagePtr& msg)
804 {
805  Position pos;
807  pos = getPosition(msg);
808  else
809  pos = g_map.getCentralPosition();
810  --pos.x;
811 
812  AwareRange range = g_map.getAwareRange();
813  setMapDescription(msg, pos.x - range.left, pos.y - range.top, pos.z, 1, range.vertical());
815 }
816 
817 void ProtocolGame::parseUpdateTile(const InputMessagePtr& msg)
818 {
819  const Position tilePos = getPosition(msg);
820  setTileDescription(msg, tilePos);
821 }
822 
823 void ProtocolGame::parseTileAddThing(const InputMessagePtr& msg)
824 {
825  const Position pos = getPosition(msg);
826  int stackPos = -1;
827 
828  if(g_game.getClientVersion() >= 841)
829  stackPos = msg->getU8();
830 
831  const ThingPtr thing = getThing(msg);
832  g_map.addThing(thing, pos, stackPos);
833 }
834 
835 void ProtocolGame::parseTileTransformThing(const InputMessagePtr& msg)
836 {
837  ThingPtr thing = getMappedThing(msg);
838  const ThingPtr newThing = getThing(msg);
839 
840  if(!thing) {
841  g_logger.traceError("no thing");
842  return;
843  }
844 
845  const Position pos = thing->getPosition();
846  const int stackpos = thing->getStackPos();
847 
848  if(!g_map.removeThing(thing)) {
849  g_logger.traceError("unable to remove thing");
850  return;
851  }
852 
853  g_map.addThing(newThing, pos, stackpos);
854 }
855 
856 void ProtocolGame::parseTileRemoveThing(const InputMessagePtr& msg)
857 {
858  const ThingPtr thing = getMappedThing(msg);
859  if(!thing) {
860  g_logger.traceError("no thing");
861  return;
862  }
863 
864  if(!g_map.removeThing(thing))
865  g_logger.traceError("unable to remove thing");
866 }
867 
868 void ProtocolGame::parseCreatureMove(const InputMessagePtr& msg)
869 {
870  ThingPtr thing = getMappedThing(msg);
871  const Position newPos = getPosition(msg);
872 
873  if(!thing || !thing->isCreature()) {
874  g_logger.traceError("no creature found to move");
875  return;
876  }
877 
878  if(!g_map.removeThing(thing)) {
879  g_logger.traceError("unable to remove creature");
880  return;
881  }
882 
883  CreaturePtr creature = thing->static_self_cast<Creature>();
884  creature->allowAppearWalk();
885 
886  g_map.addThing(thing, newPos, -1);
887 }
888 
889 void ProtocolGame::parseOpenContainer(const InputMessagePtr& msg)
890 {
891  const int containerId = msg->getU8();
892  const ItemPtr containerItem = getItem(msg);
893  const std::string name = msg->getString();
894  const int capacity = msg->getU8();
895  const bool hasParent = msg->getU8() != 0;
896 
897  bool isUnlocked = true;
898  bool hasPages = false;
899  int containerSize = 0;
900  int firstIndex = 0;
901 
903  isUnlocked = msg->getU8() != 0; // drag and drop
904  hasPages = msg->getU8() != 0; // pagination
905  containerSize = msg->getU16(); // container size
906  firstIndex = msg->getU16(); // first index
907  }
908 
909  const int itemCount = msg->getU8();
910 
911  std::vector<ItemPtr> items(itemCount);
912  for(int i = 0; i < itemCount; ++i)
913  items[i] = getItem(msg);
914 
915  g_game.processOpenContainer(containerId, containerItem, name, capacity, hasParent, items, isUnlocked, hasPages, containerSize, firstIndex);
916 }
917 
918 void ProtocolGame::parseCloseContainer(const InputMessagePtr& msg)
919 {
920  const int containerId = msg->getU8();
921  g_game.processCloseContainer(containerId);
922 }
923 
924 void ProtocolGame::parseContainerAddItem(const InputMessagePtr& msg)
925 {
926  const int containerId = msg->getU8();
927  int slot = 0;
929  slot = msg->getU16(); // slot
930  }
931  const ItemPtr item = getItem(msg);
932  g_game.processContainerAddItem(containerId, item, slot);
933 }
934 
935 void ProtocolGame::parseContainerUpdateItem(const InputMessagePtr& msg)
936 {
937  const int containerId = msg->getU8();
938  int slot;
940  slot = msg->getU16();
941  } else {
942  slot = msg->getU8();
943  }
944  const ItemPtr item = getItem(msg);
945  g_game.processContainerUpdateItem(containerId, slot, item);
946 }
947 
948 void ProtocolGame::parseContainerRemoveItem(const InputMessagePtr& msg)
949 {
950  const int containerId = msg->getU8();
951  int slot;
952  ItemPtr lastItem;
954  slot = msg->getU16();
955 
956  const int itemId = msg->getU16();
957  if(itemId != 0)
958  lastItem = getItem(msg, itemId);
959  } else {
960  slot = msg->getU8();
961  }
962  g_game.processContainerRemoveItem(containerId, slot, lastItem);
963 }
964 
965 void ProtocolGame::parseAddInventoryItem(const InputMessagePtr& msg)
966 {
967  const int slot = msg->getU8();
968  const ItemPtr item = getItem(msg);
969  g_game.processInventoryChange(slot, item);
970 }
971 
972 void ProtocolGame::parseRemoveInventoryItem(const InputMessagePtr& msg)
973 {
974  const int slot = msg->getU8();
976 }
977 
978 void ProtocolGame::parseOpenNpcTrade(const InputMessagePtr& msg)
979 {
980  std::vector<std::tuple<ItemPtr, std::string, int, int, int>> items;
981 
983  std::string 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  const uint16 itemId = msg->getU16();
994  const 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  const int size = msg->getU8();
1020  for(int i = 0; i < size; ++i) {
1021  const 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  const std::string name = g_game.formatCreatureName(msg->getString());
1043  const 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  const std::string name = g_game.formatCreatureName(msg->getString());
1055  const 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  const 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  const Position position = getPosition(msg);
1100  const int color = msg->getU8();
1101  const 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  const Position fromPos = getPosition(msg);
1112  const Position toPos = getPosition(msg);
1113  const 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  const uint id = msg->getU32();
1129  const 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  const 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  const 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  const uint id = msg->getU32();
1158  const int healthPercent = msg->getU8();
1159 
1160  CreaturePtr creature = g_map.getCreatureById(id);
1161  if(creature) creature->setHealthPercent(healthPercent);
1162 }
1163 
1164 void ProtocolGame::parseCreatureLight(const InputMessagePtr& msg)
1165 {
1166  const uint id = msg->getU32();
1167 
1168  Light light;
1169  light.intensity = msg->getU8();
1170  light.color = msg->getU8();
1171 
1172  CreaturePtr creature = g_map.getCreatureById(id);
1173  if(!creature) {
1174  g_logger.traceError("could not get creature");
1175  return;
1176  }
1177 
1178  creature->setLight(light);
1180 }
1181 
1182 void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
1183 {
1184  const uint id = msg->getU32();
1185  const Outfit outfit = getOutfit(msg);
1186 
1187  CreaturePtr creature = g_map.getCreatureById(id);
1188  if(!creature) {
1189  g_logger.traceError("could not get creature");
1190  return;
1191  }
1192 
1193  creature->setOutfit(outfit);
1194 }
1195 
1196 void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
1197 {
1198  const uint id = msg->getU32();
1199 
1200  int baseSpeed = -1;
1201  if(g_game.getClientVersion() >= 1059)
1202  baseSpeed = msg->getU16();
1203 
1204  const int speed = msg->getU16();
1205 
1206  CreaturePtr creature = g_map.getCreatureById(id);
1207  if(!creature) return;
1208 
1209  creature->setSpeed(speed);
1210  if(baseSpeed != -1)
1211  creature->setBaseSpeed(baseSpeed);
1212 }
1213 
1214 void ProtocolGame::parseCreatureSkulls(const InputMessagePtr& msg)
1215 {
1216  const uint id = msg->getU32();
1217  const int skull = msg->getU8();
1218 
1219  CreaturePtr creature = g_map.getCreatureById(id);
1220  if(!creature) {
1221  g_logger.traceError("could not get creature");
1222  return;
1223  }
1224 
1225  creature->setSkull(skull);
1226 }
1227 
1228 void ProtocolGame::parseCreatureShields(const InputMessagePtr& msg)
1229 {
1230  const uint id = msg->getU32();
1231  const int shield = msg->getU8();
1232 
1233  CreaturePtr creature = g_map.getCreatureById(id);
1234  if(!creature) {
1235  g_logger.traceError("could not get creature");
1236  return;
1237  }
1238 
1239  creature->setShield(shield);
1240 }
1241 
1242 void ProtocolGame::parseCreatureUnpass(const InputMessagePtr& msg)
1243 {
1244  const uint id = msg->getU32();
1245  const bool unpass = msg->getU8();
1246 
1247  CreaturePtr creature = g_map.getCreatureById(id);
1248  if(!creature) {
1249  g_logger.traceError("could not get creature");
1250  return;
1251  }
1252 
1253  creature->setPassable(!unpass);
1254 }
1255 
1256 void ProtocolGame::parseEditText(const InputMessagePtr& msg)
1257 {
1258  const uint id = msg->getU32();
1259 
1260  int itemId;
1261  if(g_game.getClientVersion() >= 1010) {
1262  // TODO: processEditText with ItemPtr as parameter
1263  ItemPtr item = getItem(msg);
1264  itemId = item->getId();
1265  } else
1266  itemId = msg->getU16();
1267 
1268  const int maxLength = msg->getU16();
1269  const std::string text = msg->getString();
1270 
1271  const std::string writer = msg->getString();
1272  std::string date = "";
1274  date = msg->getString();
1275 
1276  g_game.processEditText(id, itemId, maxLength, text, writer, date);
1277 }
1278 
1279 void ProtocolGame::parseEditList(const InputMessagePtr& msg)
1280 {
1281  const int doorId = msg->getU8();
1282  const uint id = msg->getU32();
1283  const std::string& text = msg->getString();
1284 
1285  g_game.processEditList(id, doorId, text);
1286 }
1287 
1288 void ProtocolGame::parsePremiumTrigger(const InputMessagePtr& msg)
1289 {
1290  const int triggerCount = msg->getU8();
1291  std::vector<int> triggers;
1292 
1293  for(int i = 0; i < triggerCount; ++i) {
1294  triggers.push_back(msg->getU8());
1295  }
1296 
1297  if(g_game.getClientVersion() <= 1096) {
1298  msg->getU8(); // == 1; // something
1299  }
1300 }
1301 
1302 void ProtocolGame::parsePlayerInfo(const InputMessagePtr& msg)
1303 {
1304  const bool premium = msg->getU8(); // premium
1306  msg->getU32(); // premium expiration used for premium advertisement
1307  const int vocation = msg->getU8(); // vocation
1308 
1309  const int spellCount = msg->getU16();
1310  std::vector<int> spells;
1311  for(int i = 0; i < spellCount; ++i)
1312  spells.push_back(msg->getU8()); // spell id
1313 
1314  m_localPlayer->setPremium(premium);
1315  m_localPlayer->setVocation(vocation);
1316  m_localPlayer->setSpells(spells);
1317 }
1318 
1319 void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg)
1320 {
1321  double health;
1322  double maxHealth;
1323 
1325  health = msg->getU32();
1326  maxHealth = msg->getU32();
1327  } else {
1328  health = msg->getU16();
1329  maxHealth = msg->getU16();
1330  }
1331 
1332  double freeCapacity;
1334  freeCapacity = msg->getU32() / 100.0;
1335  else
1336  freeCapacity = msg->getU16() / 100.0;
1337 
1338  double totalCapacity = 0;
1340  totalCapacity = msg->getU32() / 100.0;
1341 
1342  double experience;
1344  experience = msg->getU64();
1345  else
1346  experience = msg->getU32();
1347 
1348  const double level = msg->getU16();
1349  const double levelPercent = msg->getU8();
1350 
1352  if(g_game.getClientVersion() <= 1096) {
1353  msg->getDouble(); // experienceBonus
1354  } else {
1355  msg->getU16(); // baseXpGain
1356  msg->getU16(); // voucherAddend
1357  msg->getU16(); // grindingAddend
1358  msg->getU16(); // storeBoostAddend
1359  msg->getU16(); // huntingBoostFactor
1360  }
1361  }
1362 
1363  double mana;
1364  double maxMana;
1365 
1367  mana = msg->getU32();
1368  maxMana = msg->getU32();
1369  } else {
1370  mana = msg->getU16();
1371  maxMana = msg->getU16();
1372  }
1373 
1374  const double magicLevel = msg->getU8();
1375 
1376  double baseMagicLevel;
1378  baseMagicLevel = msg->getU8();
1379  else
1380  baseMagicLevel = magicLevel;
1381 
1382  const double magicLevelPercent = msg->getU8();
1383  const double soul = msg->getU8();
1384  double stamina = 0;
1386  stamina = msg->getU16();
1387 
1388  double baseSpeed = 0;
1390  baseSpeed = msg->getU16();
1391 
1392  double regeneration = 0;
1394  regeneration = msg->getU16();
1395 
1396  double training = 0;
1398  training = msg->getU16();
1399  if(g_game.getClientVersion() >= 1097) {
1400  msg->getU16(); // remainingStoreXpBoostSeconds
1401  msg->getU8(); // canBuyMoreStoreXpBoosts
1402  }
1403  }
1404 
1405  m_localPlayer->setHealth(health, maxHealth);
1406  m_localPlayer->setFreeCapacity(freeCapacity);
1407  m_localPlayer->setTotalCapacity(totalCapacity);
1408  m_localPlayer->setExperience(experience);
1409  m_localPlayer->setLevel(level, levelPercent);
1410  m_localPlayer->setMana(mana, maxMana);
1411  m_localPlayer->setMagicLevel(magicLevel, magicLevelPercent);
1412  m_localPlayer->setBaseMagicLevel(baseMagicLevel);
1413  m_localPlayer->setStamina(stamina);
1414  m_localPlayer->setSoul(soul);
1415  m_localPlayer->setBaseSpeed(baseSpeed);
1416  m_localPlayer->setRegenerationTime(regeneration);
1417  m_localPlayer->setOfflineTrainingTime(training);
1418 }
1419 
1420 void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
1421 {
1422  int lastSkill = Otc::Fishing + 1;
1424  lastSkill = Otc::LastSkill;
1425 
1426  for(int skill = 0; skill < lastSkill; ++skill) {
1427  int level;
1428 
1430  level = msg->getU16();
1431  else
1432  level = msg->getU8();
1433 
1434  int baseLevel;
1437  baseLevel = msg->getU16();
1438  else
1439  baseLevel = msg->getU8();
1440  else
1441  baseLevel = level;
1442 
1443  int levelPercent = 0;
1444  // Critical, Life Leech and Mana Leech have no level percent
1445  if(skill <= Otc::Fishing)
1446  levelPercent = msg->getU8();
1447 
1448  m_localPlayer->setSkill(static_cast<Otc::Skill>(skill), level, levelPercent);
1449  m_localPlayer->setBaseSkill(static_cast<Otc::Skill>(skill), baseLevel);
1450  }
1451 }
1452 
1453 void ProtocolGame::parsePlayerState(const InputMessagePtr& msg)
1454 {
1455  int states;
1457  states = msg->getU16();
1458  else
1459  states = msg->getU8();
1460 
1461  m_localPlayer->setStates(states);
1462 }
1463 
1464 void ProtocolGame::parsePlayerCancelAttack(const InputMessagePtr& msg)
1465 {
1466  uint seq = 0;
1468  seq = msg->getU32();
1469 
1471 }
1472 
1473 
1474 void ProtocolGame::parsePlayerModes(const InputMessagePtr& msg)
1475 {
1476  int fightMode = msg->getU8();
1477  int chaseMode = msg->getU8();
1478  const bool safeMode = msg->getU8();
1479 
1480  int pvpMode = 0;
1482  pvpMode = msg->getU8();
1483 
1484  g_game.processPlayerModes(static_cast<Otc::FightModes>(fightMode), static_cast<Otc::ChaseModes>(chaseMode), safeMode, static_cast<Otc::PVPModes>(pvpMode));
1485 }
1486 
1487 void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
1488 {
1489  const int spellId = msg->getU8();
1490  const int delay = msg->getU32();
1491 
1492  g_lua.callGlobalField("g_game", "onSpellCooldown", spellId, delay);
1493 }
1494 
1495 void ProtocolGame::parseSpellGroupCooldown(const InputMessagePtr& msg)
1496 {
1497  const int groupId = msg->getU8();
1498  const int delay = msg->getU32();
1499 
1500  g_lua.callGlobalField("g_game", "onSpellGroupCooldown", groupId, delay);
1501 }
1502 
1503 void ProtocolGame::parseMultiUseCooldown(const InputMessagePtr& msg)
1504 {
1505  const int delay = msg->getU32();
1506 
1507  g_lua.callGlobalField("g_game", "onMultiUseCooldown", delay);
1508 }
1509 
1510 void ProtocolGame::parseTalk(const InputMessagePtr& msg)
1511 {
1513  msg->getU32(); // channel statement guid
1514 
1515  const std::string name = g_game.formatCreatureName(msg->getString());
1516 
1517  int level = 0;
1519  level = msg->getU16();
1520 
1522  int channelId = 0;
1523  Position pos;
1524 
1525  switch(mode) {
1526  case Otc::MessageSay:
1527  case Otc::MessageWhisper:
1528  case Otc::MessageYell:
1531  case Otc::MessageNpcTo:
1532  case Otc::MessageBarkLow:
1533  case Otc::MessageBarkLoud:
1534  case Otc::MessageSpell:
1536  pos = getPosition(msg);
1537  break;
1538  case Otc::MessageChannel:
1542  channelId = msg->getU16();
1543  break;
1544  case Otc::MessageNpcFrom:
1548  case Otc::MessageRVRAnswer:
1550  break;
1552  msg->getU32();
1553  break;
1554  default:
1555  stdext::throw_exception(stdext::format("unknown message mode %d", mode));
1556  break;
1557  }
1558 
1559  const std::string text = msg->getString();
1560 
1561  g_game.processTalk(name, level, mode, text, channelId, pos);
1562 }
1563 
1564 void ProtocolGame::parseChannelList(const InputMessagePtr& msg)
1565 {
1566  const int count = msg->getU8();
1567  std::vector<std::tuple<int, std::string> > channelList;
1568  for(int i = 0; i < count; ++i) {
1569  int id = msg->getU16();
1570  std::string name = msg->getString();
1571  channelList.emplace_back(id, name);
1572  }
1573 
1574  g_game.processChannelList(channelList);
1575 }
1576 
1577 void ProtocolGame::parseOpenChannel(const InputMessagePtr& msg)
1578 {
1579  const int channelId = msg->getU16();
1580  const std::string name = msg->getString();
1581 
1583  const int joinedPlayers = msg->getU16();
1584  for(int i = 0; i < joinedPlayers; ++i)
1585  g_game.formatCreatureName(msg->getString()); // player name
1586  const int invitedPlayers = msg->getU16();
1587  for(int i = 0; i < invitedPlayers; ++i)
1588  g_game.formatCreatureName(msg->getString()); // player name
1589  }
1590 
1591  g_game.processOpenChannel(channelId, name);
1592 }
1593 
1594 void ProtocolGame::parseOpenPrivateChannel(const InputMessagePtr& msg)
1595 {
1596  const std::string name = g_game.formatCreatureName(msg->getString());
1597 
1599 }
1600 
1601 void ProtocolGame::parseOpenOwnPrivateChannel(const InputMessagePtr& msg)
1602 {
1603  const int channelId = msg->getU16();
1604  const std::string name = msg->getString();
1605 
1606  g_game.processOpenOwnPrivateChannel(channelId, name);
1607 }
1608 
1609 void ProtocolGame::parseCloseChannel(const InputMessagePtr& msg)
1610 {
1611  const int channelId = msg->getU16();
1612 
1613  g_game.processCloseChannel(channelId);
1614 }
1615 
1616 void ProtocolGame::parseRuleViolationChannel(const InputMessagePtr& msg)
1617 {
1618  const int channelId = msg->getU16();
1619 
1621 }
1622 
1623 void ProtocolGame::parseRuleViolationRemove(const InputMessagePtr& msg)
1624 {
1625  const std::string name = msg->getString();
1626 
1628 }
1629 
1630 void ProtocolGame::parseRuleViolationCancel(const InputMessagePtr& msg)
1631 {
1632  const std::string name = msg->getString();
1634 }
1635 
1636 void ProtocolGame::parseRuleViolationLock(const InputMessagePtr&)
1637 {
1639 }
1640 
1641 void ProtocolGame::parseTextMessage(const InputMessagePtr& msg)
1642 {
1643  const int code = msg->getU8();
1645  std::string text;
1646 
1647  switch(mode) {
1649  {
1650  msg->getU16(); // channelId
1651  text = msg->getString();
1652  break;
1653  }
1654  case Otc::MessageGuild:
1656  case Otc::MessageParty:
1657  {
1658  msg->getU16(); // channelId
1659  text = msg->getString();
1660  break;
1661  }
1665  {
1666  const Position pos = getPosition(msg);
1667  uint value[2];
1668  int color[2];
1669 
1670  // physical damage
1671  value[0] = msg->getU32();
1672  color[0] = msg->getU8();
1673 
1674  // magic damage
1675  value[1] = msg->getU32();
1676  color[1] = msg->getU8();
1677  text = msg->getString();
1678 
1679  for(int i = 0; i < 2; ++i) {
1680  if(value[i] == 0)
1681  continue;
1682  AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
1683  animatedText->setColor(color[i]);
1684  animatedText->setText(stdext::to_string(value[i]));
1685  g_map.addThing(animatedText, pos);
1686  }
1687  break;
1688  }
1689  case Otc::MessageHeal:
1690  case Otc::MessageMana:
1691  case Otc::MessageExp:
1693  case Otc::MessageExpOthers:
1694  {
1695  const Position pos = getPosition(msg);
1696  const uint value = msg->getU32();
1697  const 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  const Otc::Direction direction = static_cast<Otc::Direction>(msg->getU8());
1720 
1721  g_game.processWalkCancel(direction);
1722 }
1723 
1724 void ProtocolGame::parseWalkWait(const InputMessagePtr& msg)
1725 {
1726  const 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  } else if(pos.z > Otc::UNDERGROUND_FLOOR && pos.z < Otc::MAX_Z - 1)
1768  skip = setFloorDescription(msg, pos.x - range.left, pos.y - range.top, pos.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, range.horizontal(), range.vertical(), -3, skip);
1769 
1770  --pos.x;
1771  --pos.y;
1773 }
1774 
1775 void ProtocolGame::parseOpenOutfitWindow(const InputMessagePtr& msg)
1776 {
1777  const Outfit currentOutfit = getOutfit(msg);
1778  std::vector<std::tuple<int, std::string, int> > outfitList;
1779 
1781  const int outfitCount = msg->getU8();
1782  for(int i = 0; i < outfitCount; ++i) {
1783  int outfitId = msg->getU16();
1784  std::string outfitName = msg->getString();
1785  int outfitAddons = msg->getU8();
1786 
1787  outfitList.emplace_back(outfitId, outfitName, outfitAddons);
1788  }
1789  } else {
1790  int outfitStart, outfitEnd;
1792  outfitStart = msg->getU16();
1793  outfitEnd = msg->getU16();
1794  } else {
1795  outfitStart = msg->getU8();
1796  outfitEnd = msg->getU8();
1797  }
1798 
1799  for(int i = outfitStart; i <= outfitEnd; ++i)
1800  outfitList.emplace_back(i, "", 0);
1801  }
1802 
1803  std::vector<std::tuple<int, std::string> > mountList;
1805  const int mountCount = msg->getU8();
1806  for(int i = 0; i < mountCount; ++i) {
1807  int mountId = msg->getU16(); // mount type
1808  std::string mountName = msg->getString(); // mount name
1809 
1810  mountList.emplace_back(mountId, mountName);
1811  }
1812  }
1813 
1814  g_game.processOpenOutfitWindow(currentOutfit, outfitList, mountList);
1815 }
1816 
1817 void ProtocolGame::parseVipAdd(const InputMessagePtr& msg)
1818 {
1819  uint iconId = 0;
1820  std::string desc = "";
1821  bool notifyLogin = false;
1822 
1823  const uint id = msg->getU32();
1824  const std::string name = g_game.formatCreatureName(msg->getString());
1826  desc = msg->getString();
1827  iconId = msg->getU32();
1828  notifyLogin = msg->getU8();
1829  }
1830  const uint status = msg->getU8();
1831 
1832  g_game.processVipAdd(id, name, status, desc, iconId, notifyLogin);
1833 }
1834 
1835 void ProtocolGame::parseVipState(const InputMessagePtr& msg)
1836 {
1837  const uint id = msg->getU32();
1839  const uint status = msg->getU8();
1840  g_game.processVipStateChange(id, status);
1841  } else {
1843  }
1844 }
1845 
1846 void ProtocolGame::parseVipLogout(const InputMessagePtr& msg)
1847 {
1848  const uint id = msg->getU32();
1850 }
1851 
1852 void ProtocolGame::parseTutorialHint(const InputMessagePtr& msg)
1853 {
1854  const int id = msg->getU8();
1856 }
1857 
1858 void ProtocolGame::parseAutomapFlag(const InputMessagePtr& msg)
1859 {
1860  const Position pos = getPosition(msg);
1861  const int icon = msg->getU8();
1862  const std::string description = msg->getString();
1863 
1864  bool remove = false;
1866  remove = msg->getU8() != 0;
1867 
1868  if(!remove)
1869  g_game.processAddAutomapFlag(pos, icon, description);
1870  else
1871  g_game.processRemoveAutomapFlag(pos, icon, description);
1872 }
1873 
1874 void ProtocolGame::parseQuestLog(const InputMessagePtr& msg)
1875 {
1876  std::vector<std::tuple<int, std::string, bool> > questList;
1877  const int questsCount = msg->getU16();
1878  for(int i = 0; i < questsCount; ++i) {
1879  int id = msg->getU16();
1880  std::string name = msg->getString();
1881  bool completed = msg->getU8();
1882  questList.emplace_back(id, name, completed);
1883  }
1884 
1885  g_game.processQuestLog(questList);
1886 }
1887 
1888 void ProtocolGame::parseQuestLine(const InputMessagePtr& msg)
1889 {
1890  std::vector<std::tuple<std::string, std::string>> questMissions;
1891  const int questId = msg->getU16();
1892  const int missionCount = msg->getU8();
1893  for(int i = 0; i < missionCount; ++i) {
1894  std::string missionName = msg->getString();
1895  std::string missionDescrition = msg->getString();
1896  questMissions.emplace_back(missionName, missionDescrition);
1897  }
1898 
1899  g_game.processQuestLine(questId, questMissions);
1900 }
1901 
1902 void ProtocolGame::parseChannelEvent(const InputMessagePtr& msg)
1903 {
1904  const uint16 channelId = msg->getU16();
1905  const std::string name = g_game.formatCreatureName(msg->getString());
1906  const uint8 type = msg->getU8();
1907 
1908  g_lua.callGlobalField("g_game", "onChannelEvent", channelId, name, type);
1909 }
1910 
1911 void ProtocolGame::parseItemInfo(const InputMessagePtr& msg)
1912 {
1913  std::vector<std::tuple<ItemPtr, std::string>> list;
1914  const int size = msg->getU8();
1915  for(int i = 0; i < size; ++i) {
1916  ItemPtr item(new Item);
1917  item->setId(msg->getU16());
1918  item->setCountOrSubType(msg->getU8());
1919 
1920  std::string desc = msg->getString();
1921  list.emplace_back(item, desc);
1922  }
1923 
1924  g_lua.callGlobalField("g_game", "onItemInfo", list);
1925 }
1926 
1927 void ProtocolGame::parsePlayerInventory(const InputMessagePtr& msg)
1928 {
1929  const int size = msg->getU16();
1930  for(int i = 0; i < size; ++i) {
1931  msg->getU16(); // id
1932  msg->getU8(); // subtype
1933  msg->getU16(); // count
1934  }
1935 }
1936 
1937 void ProtocolGame::parseModalDialog(const InputMessagePtr& msg)
1938 {
1939  const uint32 windowId = msg->getU32();
1940  const std::string title = msg->getString();
1941  const std::string message = msg->getString();
1942 
1943  const int sizeButtons = msg->getU8();
1944  std::vector<std::tuple<int, std::string> > buttonList;
1945  for(int i = 0; i < sizeButtons; ++i) {
1946  std::string value = msg->getString();
1947  int buttonId = msg->getU8();
1948  buttonList.push_back(std::make_tuple(buttonId, value));
1949  }
1950 
1951  const int sizeChoices = msg->getU8();
1952  std::vector<std::tuple<int, std::string> > choiceList;
1953  for(int i = 0; i < sizeChoices; ++i) {
1954  std::string value = msg->getString();
1955  int choideId = msg->getU8();
1956  choiceList.push_back(std::make_tuple(choideId, value));
1957  }
1958 
1959  int enterButton, escapeButton;
1960  if(g_game.getClientVersion() > 970) {
1961  escapeButton = msg->getU8();
1962  enterButton = msg->getU8();
1963  } else {
1964  enterButton = msg->getU8();
1965  escapeButton = msg->getU8();
1966  }
1967 
1968  const bool priority = msg->getU8() == 0x01;
1969 
1970  g_game.processModalDialog(windowId, title, message, buttonList, enterButton, escapeButton, choiceList, priority);
1971 }
1972 
1973 void ProtocolGame::parseExtendedOpcode(const InputMessagePtr& msg)
1974 {
1975  const int opcode = msg->getU8();
1976  const std::string buffer = msg->getString();
1977 
1978  if(opcode == 0)
1979  m_enableSendExtendedOpcode = true;
1980  else if(opcode == 2)
1981  parsePingBack(msg);
1982  else
1983  callLuaField("onExtendedOpcode", opcode, buffer);
1984 }
1985 
1986 void ProtocolGame::parseChangeMapAwareRange(const InputMessagePtr& msg)
1987 {
1988  const int xrange = msg->getU8();
1989  const int yrange = msg->getU8();
1990 
1991  AwareRange range;
1992  range.left = xrange / 2 - (xrange + 1) % 2;
1993  range.right = xrange / 2;
1994  range.top = yrange / 2 - (yrange + 1) % 2;
1995  range.bottom = yrange / 2;
1996 
1997  g_map.setAwareRange(range);
1998  g_lua.callGlobalField("g_game", "onMapChangeAwareRange", xrange, yrange);
1999 }
2000 
2001 void ProtocolGame::parseCreaturesMark(const InputMessagePtr& msg)
2002 {
2003  int len;
2004  if(g_game.getClientVersion() >= 1035) {
2005  len = 1;
2006  } else {
2007  len = msg->getU8();
2008  }
2009 
2010  for(int i = 0; i < len; ++i) {
2011  const uint32 id = msg->getU32();
2012  const bool isPermanent = msg->getU8() != 1;
2013  const uint8 markType = msg->getU8();
2014 
2015  CreaturePtr creature = g_map.getCreatureById(id);
2016  if(creature) {
2017  if(isPermanent) {
2018  if(markType == 0xff)
2019  creature->hideStaticSquare();
2020  else
2021  creature->showStaticSquare(Color::from8bit(markType));
2022  } else
2023  creature->addTimedSquare(markType);
2024  } else
2025  g_logger.traceError("could not get creature");
2026  }
2027 }
2028 
2029 void ProtocolGame::parseCreatureType(const InputMessagePtr& msg)
2030 {
2031  const uint32 id = msg->getU32();
2032  const uint8 type = msg->getU8();
2033 
2034  CreaturePtr creature = g_map.getCreatureById(id);
2035  if(creature)
2036  creature->setType(type);
2037  else
2038  g_logger.traceError("could not get creature");
2039 }
2040 
2041 void ProtocolGame::setMapDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height)
2042 {
2043  int startz, endz, zstep;
2044 
2045  if(z > Otc::SEA_FLOOR) {
2047  endz = std::min<int>(z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE, static_cast<int>(Otc::MAX_Z));
2048  zstep = 1;
2049  } else {
2050  startz = Otc::SEA_FLOOR;
2051  endz = 0;
2052  zstep = -1;
2053  }
2054 
2055  int skip = 0;
2056  for(int nz = startz; nz != endz + zstep; nz += zstep)
2057  skip = setFloorDescription(msg, x, y, nz, width, height, z - nz, skip);
2058 }
2059 
2060 int ProtocolGame::setFloorDescription(const InputMessagePtr& msg, int x, int y, int z, int width, int height, int offset, int skip)
2061 {
2062  for(int nx = 0; nx < width; ++nx) {
2063  for(int ny = 0; ny < height; ++ny) {
2064  Position tilePos(x + nx + offset, y + ny + offset, z);
2065  if(skip == 0)
2066  skip = setTileDescription(msg, tilePos);
2067  else {
2068  g_map.cleanTile(tilePos);
2069  --skip;
2070  }
2071  }
2072  }
2073  return skip;
2074 }
2075 
2077 {
2078  g_map.cleanTile(position);
2079 
2080  bool gotEffect = false;
2081  for(int stackPos = 0; stackPos < 256; ++stackPos) {
2082  if(msg->peekU16() >= 0xff00)
2083  return msg->getU16() & 0xff;
2084 
2085  if(g_game.getFeature(Otc::GameEnvironmentEffect) && !gotEffect) {
2086  msg->getU16(); // environment effect
2087  gotEffect = true;
2088  continue;
2089  }
2090 
2091  if(stackPos > 10)
2092  g_logger.traceError(stdext::format("too many things, pos=%s, stackpos=%d", stdext::to_string(position), stackPos));
2093 
2094  ThingPtr thing = getThing(msg);
2095  g_map.addThing(thing, position, stackPos);
2096  }
2097 
2098  return 0;
2099 }
2101 {
2102  Outfit outfit;
2103 
2104  int lookType;
2106  lookType = msg->getU16();
2107  else
2108  lookType = msg->getU8();
2109 
2110  if(lookType != 0) {
2112  const int head = msg->getU8();
2113  const int body = msg->getU8();
2114  const int legs = msg->getU8();
2115  const int feet = msg->getU8();
2116  int addons = 0;
2118  addons = msg->getU8();
2119 
2120  if(!g_things.isValidDatId(lookType, ThingCategoryCreature)) {
2121  g_logger.traceError(stdext::format("invalid outfit looktype %d", lookType));
2122  lookType = 0;
2123  }
2124 
2125  outfit.setId(lookType);
2126  outfit.setHead(head);
2127  outfit.setBody(body);
2128  outfit.setLegs(legs);
2129  outfit.setFeet(feet);
2130  outfit.setAddons(addons);
2131  } else {
2132  int lookTypeEx = msg->getU16();
2133  if(lookTypeEx == 0) {
2135  outfit.setAuxId(13); // invisible effect id
2136  } else {
2137  if(!g_things.isValidDatId(lookTypeEx, ThingCategoryItem)) {
2138  g_logger.traceError(stdext::format("invalid outfit looktypeex %d", lookTypeEx));
2139  lookTypeEx = 0;
2140  }
2142  outfit.setAuxId(lookTypeEx);
2143  }
2144  }
2145 
2147  const int mount = msg->getU16();
2148  outfit.setMount(mount);
2149  }
2150 
2151  return outfit;
2152 }
2153 
2155 {
2156  ThingPtr thing;
2157 
2158  const int id = msg->getU16();
2159 
2160  if(id == 0)
2161  stdext::throw_exception("invalid thing id");
2162  else if(id == Proto::UnknownCreature || id == Proto::OutdatedCreature || id == Proto::Creature)
2163  thing = getCreature(msg, id);
2164  else if(id == Proto::StaticText) // otclient only
2165  thing = getStaticText(msg, id);
2166  else // item
2167  thing = getItem(msg, id);
2168 
2169  return thing;
2170 }
2171 
2173 {
2174  ThingPtr thing;
2175  const uint16 x = msg->getU16();
2176 
2177  if(x != 0xffff) {
2178  Position pos;
2179  pos.x = x;
2180  pos.y = msg->getU16();
2181  pos.z = msg->getU8();
2182  const uint8 stackpos = msg->getU8();
2183  assert(stackpos != 255);
2184  thing = g_map.getThing(pos, stackpos);
2185  if(!thing)
2186  g_logger.traceError(stdext::format("no thing at pos:%s, stackpos:%d", stdext::to_string(pos), stackpos));
2187  } else {
2188  const uint32 id = msg->getU32();
2189  thing = g_map.getCreatureById(id);
2190  if(!thing)
2191  g_logger.traceError(stdext::format("no creature with id %u", id));
2192  }
2193 
2194  return thing;
2195 }
2196 
2198 {
2199  if(type == 0)
2200  type = msg->getU16();
2201 
2202  CreaturePtr creature;
2203  const bool known = type != Proto::UnknownCreature;
2204  if(type == Proto::OutdatedCreature || type == Proto::UnknownCreature) {
2205  if(known) {
2206  const uint id = msg->getU32();
2207  creature = g_map.getCreatureById(id);
2208  if(!creature)
2209  g_logger.traceError("server said that a creature is known, but it's not");
2210 
2211  if(creature->isLocalPlayer()) g_map.resetLastCamera();
2212  } else {
2213  const uint removeId = msg->getU32();
2214  g_map.removeCreatureById(removeId);
2215 
2216  const uint id = msg->getU32();
2217 
2218  int creatureType;
2219  if(g_game.getClientVersion() >= 910)
2220  creatureType = msg->getU8();
2221  else {
2222  if(id >= Proto::PlayerStartId && id < Proto::PlayerEndId)
2223  creatureType = Proto::CreatureTypePlayer;
2224  else creatureType = Proto::CreatureTypeNpc;
2225  }
2226 
2227  const std::string name = g_game.formatCreatureName(msg->getString());
2228 
2229  if(id == m_localPlayer->getId())
2230  creature = m_localPlayer;
2231  else if(creatureType == Proto::CreatureTypePlayer) {
2232  // fixes a bug server side bug where GameInit is not sent and local player id is unknown
2233  if(m_localPlayer->getId() == 0 && name == m_localPlayer->getName())
2234  creature = m_localPlayer;
2235  else
2236  creature = PlayerPtr(new Player);
2237  } else if(creatureType == Proto::CreatureTypeMonster)
2238  creature = MonsterPtr(new Monster);
2239  else if(creatureType == Proto::CreatureTypeNpc)
2240  creature = NpcPtr(new Npc);
2241  else
2242  g_logger.traceError("creature type is invalid");
2243 
2244  if(creature) {
2245  creature->setId(id);
2246  creature->setName(name);
2247 
2248  g_map.addCreature(creature);
2249  }
2250  }
2251 
2252  const int healthPercent = msg->getU8();
2253  const Otc::Direction direction = static_cast<Otc::Direction>(msg->getU8());
2254  const Outfit outfit = getOutfit(msg);
2255 
2256  Light light;
2257  light.intensity = msg->getU8();
2258  light.color = msg->getU8();
2259 
2260  const int speed = msg->getU16();
2261  const int skull = msg->getU8();
2262  const int shield = msg->getU8();
2263 
2264  // emblem is sent only when the creature is not known
2265  int8 emblem = -1;
2266  int8 creatureType = -1;
2267  int8 icon = -1;
2268  bool unpass = true;
2269 
2271  emblem = msg->getU8();
2272 
2274  creatureType = msg->getU8();
2275  }
2276 
2278  icon = msg->getU8();
2279  }
2280 
2282  const uint8 mark = msg->getU8(); // mark
2283  msg->getU16(); // helpers
2284 
2285  if(creature) {
2286  if(mark == 0xff)
2287  creature->hideStaticSquare();
2288  else
2289  creature->showStaticSquare(Color::from8bit(mark));
2290  }
2291  }
2292 
2293  if(g_game.getClientVersion() >= 854)
2294  unpass = msg->getU8();
2295 
2296  if(creature) {
2297  creature->setHealthPercent(healthPercent);
2298  creature->setDirection(direction);
2299  creature->setOutfit(outfit);
2300  creature->setSpeed(speed);
2301  creature->setSkull(skull);
2302  creature->setShield(shield);
2303  creature->setPassable(!unpass);
2304  creature->setLight(light);
2305 
2306  if(emblem != -1)
2307  creature->setEmblem(emblem);
2308 
2309  if(creatureType != -1)
2310  creature->setType(creatureType);
2311 
2312  if(icon != -1)
2313  creature->setIcon(icon);
2314 
2315  if(creature == m_localPlayer && !m_localPlayer->isKnown())
2316  m_localPlayer->setKnown(true);
2317  }
2318  } else if(type == Proto::Creature) {
2319  const uint id = msg->getU32();
2320  creature = g_map.getCreatureById(id);
2321 
2322  if(!creature)
2323  g_logger.traceError("invalid creature");
2324 
2325  const Otc::Direction direction = static_cast<Otc::Direction>(msg->getU8());
2326  if(creature)
2327  creature->turn(direction);
2328 
2329  if(g_game.getClientVersion() >= 953) {
2330  const bool unpass = msg->getU8();
2331 
2332  if(creature)
2333  creature->setPassable(!unpass);
2334  }
2335 
2336  } else {
2337  stdext::throw_exception("invalid creature opcode");
2338  }
2339 
2340  return creature;
2341 }
2342 
2344 {
2345  if(id == 0)
2346  id = msg->getU16();
2347 
2348  ItemPtr item = Item::create(id);
2349  if(item->getId() == 0)
2350  stdext::throw_exception(stdext::format("unable to create item with invalid id %d", id));
2351 
2353  msg->getU8(); // mark
2354  }
2355 
2356  if(item->isStackable() || item->isFluidContainer() || item->isSplash() || item->isChargeable())
2357  item->setCountOrSubType(msg->getU8());
2358 
2360  if(item->getAnimationPhases() > 1) {
2361  // 0x00 => automatic phase
2362  // 0xFE => random phase
2363  // 0xFF => async phase
2364  msg->getU8();
2365  //item->setPhase(msg->getU8());
2366  }
2367  }
2368 
2369  return item;
2370 }
2371 
2373 {
2374  const int colorByte = msg->getU8();
2375  const Color color = Color::from8bit(colorByte);
2376  const std::string fontName = msg->getString();
2377  const std::string text = msg->getString();
2378  StaticTextPtr staticText = StaticTextPtr(new StaticText);
2379  staticText->setText(text);
2380  staticText->setFont(fontName);
2381  staticText->setColor(color);
2382  return staticText;
2383 }
2384 
2386 {
2387  const uint16 x = msg->getU16();
2388  const uint16 y = msg->getU16();
2389  const uint8 z = msg->getU8();
2390 
2391  return Position(x, y, z);
2392 }
Otc::GameThingMarks
@ GameThingMarks
Definition: const.h:406
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:336
Otc::GamePVPMode
@ GamePVPMode
Definition: const.h:415
Creature::getId
uint32 getId() override
Definition: creature.h:82
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:341
Creature::turn
void turn(Otc::Direction direction)
Definition: creature.cpp:323
Map::setAwareRange
void setAwareRange(const AwareRange &range)
Definition: map.cpp:744
Otc::GameAttackSeq
@ GameAttackSeq
Definition: const.h:397
LocalPlayer::setRegenerationTime
void setRegenerationTime(double regenerationTime)
Definition: localplayer.cpp:488
Map::requestDrawing
void requestDrawing(const Position &pos, const Otc::RequestDrawFlags reDrawFlags, const bool force=false, const bool isLocalPlayer=false)
Definition: map.cpp:84
Creature::setShield
void setShield(uint8 shield)
Definition: creature.cpp:773
Proto::GameServerTextEffect
@ GameServerTextEffect
Definition: protocolcodes.h:96
Game::processQuestLine
static void processQuestLine(int questId, const std::vector< std::tuple< std::string, std::string > > &questMissions)
Definition: game.cpp:510
eventdispatcher.h
Game::processWalkCancel
void processWalkCancel(Otc::Direction direction)
Definition: game.cpp:528
Proto::GameServerCreatureParty
@ GameServerCreatureParty
Definition: protocolcodes.h:105
g_map
Map g_map
Definition: map.cpp:36
Game::processOpenChannel
static void processOpenChannel(int channelId, const std::string &name)
Definition: game.cpp:367
Proto::GameServerUnjustifiedStats
@ GameServerUnjustifiedStats
Definition: protocolcodes.h:138
Otc::MessageBarkLow
@ MessageBarkLow
Definition: const.h:343
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:1357
Proto::OutdatedCreature
@ OutdatedCreature
Definition: protocolcodes.h:39
Proto::GameServerGMActions
@ GameServerGMActions
Definition: protocolcodes.h:46
Color
Definition: color.h:32
Game::processTextMessage
static 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
Creature::speedB
static double speedB
Definition: creature.h:45
Otc::GameNewSpeedLaw
@ GameNewSpeedLaw
Definition: const.h:401
ThingCategoryMissile
@ ThingCategoryMissile
Definition: thingtype.h:49
InputMessage::getDouble
double getDouble()
Definition: inputmessage.cpp:89
LocalPlayer::setMana
void setMana(double mana, double maxMana)
Definition: localplayer.cpp:397
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:358
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
Thing::isChargeable
bool isChargeable()
Definition: thing.h:99
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
static void processLogin()
Definition: game.cpp:164
Otc::MessageParty
@ MessageParty
Definition: const.h:342
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
static void processEditList(uint id, int doorId, const std::string &text)
Definition: game.cpp:500
Otc::ChaseModes
ChaseModes
Definition: const.h:233
UnjustifiedPoints::killsDayRemaining
uint8 killsDayRemaining
Definition: game.h:51
Item::setCountOrSubType
void setCountOrSubType(int value)
Definition: item.h:89
Proto::GameServerPremiumTrigger
@ GameServerPremiumTrigger
Definition: protocolcodes.h:114
Game::processQuestLog
static void processQuestLog(const std::vector< std::tuple< int, std::string, bool > > &questList)
Definition: game.cpp:505
Otc::Fishing
@ Fishing
Definition: const.h:173
Proto::CreatureTypePlayer
@ CreatureTypePlayer
Definition: protocolcodes.h:277
UnjustifiedPoints::killsDay
uint8 killsDay
Definition: game.h:50
Proto::GameServerOpenPrivateChannel
@ GameServerOpenPrivateChannel
Definition: protocolcodes.h:128
Otc::MessagePrivateFrom
@ MessagePrivateFrom
Definition: const.h:313
Position::x
int x
Definition: position.h:265
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
static 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:360
Otc::GamePlayerAddons
@ GamePlayerAddons
Definition: const.h:409
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:2041
Item::getId
uint32 getId() override
Definition: item.h:97
g_dispatcher
EventDispatcher g_dispatcher
Definition: eventdispatcher.cpp:28
Proto::GameServerOpenChannel
@ GameServerOpenChannel
Definition: protocolcodes.h:127
Otc::GameChannelPlayerList
@ GameChannelPlayerList
Definition: const.h:378
Proto::GameServerFirstGameOpcode
@ GameServerFirstGameOpcode
Definition: protocolcodes.h:61
PlayerPtr
stdext::shared_object_ptr< Player > PlayerPtr
Definition: declarations.h:66
Otc::MessageChannel
@ MessageChannel
Definition: const.h:316
Creature::speedC
static double speedC
Definition: creature.h:45
uint32
uint32_t uint32
Definition: types.h:35
Creature::setDirection
void setDirection(Otc::Direction direction)
Definition: creature.cpp:672
luavaluecasts.h
Creature
Definition: creature.h:37
LocalPlayer::setLevel
void setLevel(double level, double levelPercent)
Definition: localplayer.cpp:385
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:400
Game::processTutorialHint
static 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:2100
Proto::GameServerCloseContainer
@ GameServerCloseContainer
Definition: protocolcodes.h:82
Otc::GameAdditionalVipInfo
@ GameAdditionalVipInfo
Definition: const.h:417
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:52
Game::processPlayerGoods
static void processPlayerGoods(int money, const std::vector< std::tuple< ItemPtr, int > > &goods)
Definition: game.cpp:470
InputMessage::getReadPos
int getReadPos()
Definition: inputmessage.h:60
Map::resetLastCamera
void resetLastCamera()
Definition: map.cpp:938
Game::processEditText
static 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:133
Game::processGMActions
void processGMActions(const std::vector< uint8 > &actions)
Definition: game.cpp:239
ProtocolGame::getThing
ThingPtr getThing(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2154
Map::getThing
ThingPtr getThing(const Position &pos, int stackPos)
Definition: map.cpp:190
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
static 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:391
Thing::getAnimationPhases
int getAnimationPhases()
Definition: thing.h:78
Map::cleanTile
void cleanTile(const Position &pos)
Definition: map.cpp:399
Game::getClientVersion
int getClientVersion()
Definition: game.h:318
Game::processAddAutomapFlag
static 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:310
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
static void processCloseTrade()
Definition: game.cpp:490
Game::processLoginAdvice
static void processLoginAdvice(const std::string &message)
Definition: game.cpp:149
Creature::setLight
void setLight(const Light &light)
Definition: creature.h:62
Proto::CreatureTypeNpc
@ CreatureTypeNpc
Definition: protocolcodes.h:279
Otc::MessageNpcFrom
@ MessageNpcFrom
Definition: const.h:319
Game::processOpenOwnPrivateChannel
static void processOpenOwnPrivateChannel(int channelId, const std::string &name)
Definition: game.cpp:377
Otc::MessageMana
@ MessageMana
Definition: const.h:350
Proto::GameServerAmbient
@ GameServerAmbient
Definition: protocolcodes.h:94
Otc::MessageGamemasterChannel
@ MessageGamemasterChannel
Definition: const.h:322
Otc::SEA_FLOOR
@ SEA_FLOOR
Definition: const.h:36
Game::processLoginError
static 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:332
Proto::GameServerUpdateNeeded
@ GameServerUpdateNeeded
Definition: protocolcodes.h:48
Position::y
int y
Definition: position.h:266
Otc::GamePlayerMounts
@ GamePlayerMounts
Definition: const.h:379
Otc::ReDrawLight
@ ReDrawLight
Definition: const.h:57
Proto::GameServerDeleteOnMap
@ GameServerDeleteOnMap
Definition: protocolcodes.h:79
Map::addCreature
void addCreature(const CreaturePtr &creature)
Definition: map.cpp:520
Map::setLight
void setLight(const Light &light)
Definition: map.h:227
Proto::GameServerEditList
@ GameServerEditList
Definition: protocolcodes.h:111
Proto::PlayerEndId
@ PlayerEndId
Definition: protocolcodes.h:287
Otc::GameBaseSkillU16
@ GameBaseSkillU16
Definition: const.h:418
ThingCategoryEffect
@ ThingCategoryEffect
Definition: thingtype.h:48
InputMessage::eof
bool eof()
Definition: inputmessage.h:64
Game::processCloseNpcTrade
static void processCloseNpcTrade()
Definition: game.cpp:475
stdext::format
std::string format()
Definition: format.h:84
stdext::time
ticks_t time()
Definition: time.cpp:33
Proto::GameServerVipLogout
@ GameServerVipLogout
Definition: protocolcodes.h:145
Otc::MessageNpcTo
@ MessageNpcTo
Definition: const.h:320
Game::processPendingGame
void processPendingGame()
Definition: game.cpp:169
InputMessage::getUnreadSize
int getUnreadSize()
Definition: inputmessage.h:61
Thing::isFluidContainer
bool isFluidContainer()
Definition: thing.h:101
Proto::GameServerFullMap
@ GameServerFullMap
Definition: protocolcodes.h:71
Creature::setType
void setType(uint8 type)
Definition: creature.cpp:787
Otc::GameDoubleSkills
@ GameDoubleSkills
Definition: const.h:394
Proto::GameServerSetStoreDeepLink
@ GameServerSetStoreDeepLink
Definition: protocolcodes.h:124
Game::processRemoveAutomapFlag
static void processRemoveAutomapFlag(const Position &pos, int icon, const std::string &message)
Definition: game.cpp:429
Otc::GameMessageStatements
@ GameMessageStatements
Definition: const.h:410
Otc::LastSkill
@ LastSkill
Definition: const.h:180
Proto::GameServerPing
@ GameServerPing
Definition: protocolcodes.h:56
Proto::GameServerStoreOffers
@ GameServerStoreOffers
Definition: protocolcodes.h:163
Otc::Skill
Skill
Definition: const.h:166
Outfit::setAuxId
void setAuxId(int id)
Definition: outfit.h:42
Creature::setSkull
void setSkull(uint8 skull)
Definition: creature.cpp:765
LocalPlayer::setBaseMagicLevel
void setBaseMagicLevel(double baseMagicLevel)
Definition: localplayer.cpp:424
Proto::GameServerQuestLine
@ GameServerQuestLine
Definition: protocolcodes.h:152
int8
int8_t int8
Definition: types.h:41
Otc::GameLooktypeU16
@ GameLooktypeU16
Definition: const.h:407
Otc::MessageGamemasterPrivateFrom
@ MessageGamemasterPrivateFrom
Definition: const.h:323
Position::z
short z
Definition: position.h:267
Proto::GameServerChangeOnMap
@ GameServerChangeOnMap
Definition: protocolcodes.h:78
Game::setServerBeat
void setServerBeat(int beat)
Definition: game.h:339
uint16
uint16_t uint16
Definition: types.h:36
Otc::MessageYell
@ MessageYell
Definition: const.h:312
UnjustifiedPoints::skullTime
uint8 skullTime
Definition: game.h:56
ProtocolGame::getItem
ItemPtr getItem(const InputMessagePtr &msg, int id=0)
Definition: protocolgameparse.cpp:2343
Proto::GameServerLoginOrPendingState
@ GameServerLoginOrPendingState
Definition: protocolcodes.h:45
Otc::GameNameOnNpcTrade
@ GameNameOnNpcTrade
Definition: const.h:372
Proto::GameServerOpenNpcTrade
@ GameServerOpenNpcTrade
Definition: protocolcodes.h:88
Otc::GameExperienceBonus
@ GameExperienceBonus
Definition: const.h:431
Game::processContainerRemoveItem
void processContainerRemoveItem(int containerId, int slot, const ItemPtr &lastItem)
Definition: game.cpp:344
Light::intensity
uint8 intensity
Definition: thingtype.h:122
Creature::speedA
static double speedA
Definition: creature.h:45
Proto::GameServerRuleViolationLock
@ GameServerRuleViolationLock
Definition: protocolcodes.h:132
Otc::Direction
Direction
Definition: const.h:183
Otc::UNDERGROUND_FLOOR
@ UNDERGROUND_FLOOR
Definition: const.h:38
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:102
Proto::GameServerTrappers
@ GameServerTrappers
Definition: protocolcodes.h:99
LocalPlayer::setMagicLevel
void setMagicLevel(double magicLevel, double magicLevelPercent)
Definition: localplayer.cpp:412
Proto::GameServerChooseOutfit
@ GameServerChooseOutfit
Definition: protocolcodes.h:142
Proto::GameServerSetInventory
@ GameServerSetInventory
Definition: protocolcodes.h:86
Monster
Definition: creature.h:240
Proto::GameServerChallenge
@ GameServerChallenge
Definition: protocolcodes.h:57
Otc::MessageInvalid
@ MessageInvalid
Definition: const.h:364
LocalPlayer::setStates
void setStates(int states)
Definition: localplayer.cpp:293
Otc::MessageExp
@ MessageExp
Definition: const.h:333
Proto::translateMessageModeFromServer
Otc::MessageMode translateMessageModeFromServer(uint8 mode)
Definition: protocolcodes.cpp:177
Proto::GameServerCreatureSpeed
@ GameServerCreatureSpeed
Definition: protocolcodes.h:103
uint
unsigned int uint
Definition: types.h:31
Otc::MessageMode
MessageMode
Definition: const.h:308
LuaObject::callLuaField
R callLuaField(const std::string &field, const T &... args)
Definition: luaobject.h:172
Creature::getName
std::string getName()
Definition: creature.h:83
Otc::GameTotalCapacity
@ GameTotalCapacity
Definition: const.h:375
Otc::GameNewOutfitProtocol
@ GameNewOutfitProtocol
Definition: const.h:414
Proto::PlayerStartId
@ PlayerStartId
Definition: protocolcodes.h:286
ThingCategoryCreature
@ ThingCategoryCreature
Definition: thingtype.h:47
Proto::GameServerCloseTrade
@ GameServerCloseTrade
Definition: protocolcodes.h:93
LocalPlayer::setPremium
void setPremium(bool premium)
Definition: localplayer.cpp:479
g_logger
Logger g_logger
Definition: logger.cpp:35
Npc
Definition: creature.h:233
Otc::MessageBarkLoud
@ MessageBarkLoud
Definition: const.h:344
LocalPlayer::setExperience
void setExperience(double experience)
Definition: localplayer.cpp:375
g_lua
LuaInterface g_lua
Definition: luainterface.cpp:31
Game::setUnjustifiedPoints
void setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints)
Definition: game.cpp:1201
Game::canReportBugs
bool canReportBugs()
Definition: game.h:342
Creature::setIcon
void setIcon(uint8 icon)
Definition: creature.cpp:793
Proto::GameServerChangeMapAwareRange
@ GameServerChangeMapAwareRange
Definition: protocolcodes.h:68
LocalPlayer::setSoul
void setSoul(double soul)
Definition: localplayer.cpp:434
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:377
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:125
Otc::GameContainerPagination
@ GameContainerPagination
Definition: const.h:405
Position
Definition: position.h:33
Creature::setName
void setName(const std::string &name)
Definition: creature.cpp:640
Thing::isLocalPlayer
virtual bool isLocalPlayer()
Definition: thing.h:59
Otc::GameAdditionalSkills
@ GameAdditionalSkills
Definition: const.h:441
Outfit::setHead
void setHead(int head)
Definition: outfit.h:43
UnjustifiedPoints::killsMonthRemaining
uint8 killsMonthRemaining
Definition: game.h:55
Otc::GameDoubleHealth
@ GameDoubleHealth
Definition: const.h:393
Creature::setSpeed
void setSpeed(uint16 speed)
Definition: creature.cpp:733
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:321
missile.h
Proto::GameServerDeleteInContainer
@ GameServerDeleteInContainer
Definition: protocolcodes.h:85
ProtocolGame::getCreature
CreaturePtr getCreature(const InputMessagePtr &msg, int type=0)
Definition: protocolgameparse.cpp:2197
Otc::MessageRVRAnswer
@ MessageRVRAnswer
Definition: const.h:359
LocalPlayer::setVocation
void setVocation(int vocation)
Definition: localplayer.cpp:469
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:46
Proto::GameServerOwnTrade
@ GameServerOwnTrade
Definition: protocolcodes.h:91
UnjustifiedPoints::killsWeekRemaining
uint8 killsWeekRemaining
Definition: game.h:53
Otc::MessageExpOthers
@ MessageExpOthers
Definition: const.h:336
Proto::GameServerEnterGame
@ GameServerEnterGame
Definition: protocolcodes.h:47
Game::processCloseContainer
void processCloseContainer(int containerId)
Definition: game.cpp:313
map.h
Game::processModalDialog
static void processModalDialog(uint32 id, const std::string &title, const std::string &message, const std::vector< std::tuple< int, std::string > > &buttonList, int enterButton, int escapeButton, const std::vector< std::tuple< int, std::string > > &choiceList, bool priority)
Definition: game.cpp:515
Otc::GamePlayerStamina
@ GamePlayerStamina
Definition: const.h:408
Otc::MessageGuild
@ MessageGuild
Definition: const.h:340
InputMessage::getU64
uint64 getU64()
Definition: inputmessage.cpp:72
Game::getFeature
bool getFeature(Otc::GameFeature feature)
Definition: game.h:312
Otc::GameDoubleShopSellAmount
@ GameDoubleShopSellAmount
Definition: const.h:404
InputMessage::getU32
uint32 getU32()
Definition: inputmessage.cpp:64
Otc::MessageDamageOthers
@ MessageDamageOthers
Definition: const.h:334
Creature::setPassable
void setPassable(bool passable)
Definition: creature.h:75
Map::removeCreatureById
void removeCreatureById(uint32 id)
Definition: map.cpp:533
AwareRange::vertical
int vertical()
Definition: map.h:137
ProtocolGame::setTileDescription
int setTileDescription(const InputMessagePtr &msg, Position position)
Definition: protocolgameparse.cpp:2076
Creature::setId
void setId(uint32 id) override
Definition: creature.h:56
Proto::GameServerStoreCompletePurchase
@ GameServerStoreCompletePurchase
Definition: protocolcodes.h:165
Otc::PVPModes
PVPModes
Definition: const.h:238
AwareRange::horizontal
int horizontal()
Definition: map.h:136
Proto::GameServerDeleteInventory
@ GameServerDeleteInventory
Definition: protocolcodes.h:87
Otc::GameWritableDate
@ GameWritableDate
Definition: const.h:416
Proto::GameServerCreateOnMap
@ GameServerCreateOnMap
Definition: protocolcodes.h:77
Otc::MAX_Z
@ MAX_Z
Definition: const.h:37
ProtocolGame::getPosition
Position getPosition(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2385
Otc::MessageChannelHighlight
@ MessageChannelHighlight
Definition: const.h:317
Proto::GameServerVipState
@ GameServerVipState
Definition: protocolcodes.h:144
Otc::MessageDamageDealed
@ MessageDamageDealed
Definition: const.h:330
Proto::GameServerPreset
@ GameServerPreset
Definition: protocolcodes.h:113
Otc::GameCreatureIcons
@ GameCreatureIcons
Definition: const.h:419
Otc::GameItemAnimationPhase
@ GameItemAnimationPhase
Definition: const.h:382
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
static void processRuleViolationLock()
Definition: game.cpp:402
LocalPlayer::setOfflineTrainingTime
void setOfflineTrainingTime(double offlineTrainingTime)
Definition: localplayer.cpp:498
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:52
Creature::showStaticSquare
void showStaticSquare(const Color &color)
Definition: creature.h:79
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:376
AwareRange
Definition: map.h:129
Otc::GameOfflineTrainingTime
@ GameOfflineTrainingTime
Definition: const.h:387
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
Proto::GameServerEditText
@ GameServerEditText
Definition: protocolcodes.h:110
Proto::GameServerRuleViolationCancel
@ GameServerRuleViolationCancel
Definition: protocolcodes.h:131
LocalPlayer::setTotalCapacity
void setTotalCapacity(double totalCapacity)
Definition: localplayer.cpp:365
Otc::GameMinimapRemove
@ GameMinimapRemove
Definition: const.h:403
MonsterPtr
stdext::shared_object_ptr< Monster > MonsterPtr
Definition: declarations.h:64
Otc::GameMagicEffectU16
@ GameMagicEffectU16
Definition: const.h:383
Game::processOpenPrivateChannel
static void processOpenPrivateChannel(const std::string &name)
Definition: game.cpp:372
Proto::GameServerChangeInContainer
@ GameServerChangeInContainer
Definition: protocolcodes.h:84
AwareRange::left
int left
Definition: map.h:134
Game::processChannelList
static void processChannelList(const std::vector< std::tuple< int, std::string > > &channelList)
Definition: game.cpp:362
Otc::GameMapMovePosition
@ GameMapMovePosition
Definition: const.h:396
Game::setOpenPvpSituations
void setOpenPvpSituations(int openPvpSituations)
Definition: game.cpp:1214
Proto::GameServerOpenContainer
@ GameServerOpenContainer
Definition: protocolcodes.h:81
LocalPlayer::setBaseSkill
void setBaseSkill(Otc::Skill skill, int baseLevel)
Definition: localplayer.cpp:321
Game::processRuleViolationRemove
static void processRuleViolationRemove(const std::string &name)
Definition: game.cpp:392
effect.h
Otc::GameIngameStoreHighlights
@ GameIngameStoreHighlights
Definition: const.h:439
Game::formatCreatureName
std::string formatCreatureName(const std::string &name)
Definition: game.cpp:1699
Missile
Definition: missile.h:31
Otc::MessageMonsterSay
@ MessageMonsterSay
Definition: const.h:355
Otc::GameDoubleExperience
@ GameDoubleExperience
Definition: const.h:374
stdext::shared_object_ptr< InputMessage >
Otc::MessagePartyManagement
@ MessagePartyManagement
Definition: const.h:341
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:444
Proto::GameServerStore
@ GameServerStore
Definition: protocolcodes.h:162
Otc::MessageDamageReceived
@ MessageDamageReceived
Definition: const.h:331
Item::setId
void setId(uint32 id) override
Definition: item.cpp:96
LocalPlayer::setSpells
void setSpells(const std::vector< int > &spells)
Definition: localplayer.cpp:508
Proto::GameServerUpdateTile
@ GameServerUpdateTile
Definition: protocolcodes.h:76
Otc::GamePenalityOnDeath
@ GamePenalityOnDeath
Definition: const.h:371
Proto::GameServerPlayerGoods
@ GameServerPlayerGoods
Definition: protocolcodes.h:89
Proto::GameServerFloorChangeDown
@ GameServerFloorChangeDown
Definition: protocolcodes.h:141
Otc::MessageWhisper
@ MessageWhisper
Definition: const.h:311
Otc::GamePlayerStateU16
@ GamePlayerStateU16
Definition: const.h:413
Light::color
uint8 color
Definition: thingtype.h:123
Game::processCounterTrade
static void processCounterTrade(const std::string &name, const std::vector< ItemPtr > &items)
Definition: game.cpp:485
Otc::GameDoubleFreeCapacity
@ GameDoubleFreeCapacity
Definition: const.h:373
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:120
Game::processVipStateChange
void processVipStateChange(uint id, uint status)
Definition: game.cpp:413
UnjustifiedPoints::killsMonth
uint8 killsMonth
Definition: game.h:54
game.h
Otc::GameCreatureEmblems
@ GameCreatureEmblems
Definition: const.h:381
Game::processRuleViolationCancel
static void processRuleViolationCancel(const std::string &name)
Definition: game.cpp:397
Proto::GameServerCounterTrade
@ GameServerCounterTrade
Definition: protocolcodes.h:92
Otc::GameMessageLevel
@ GameMessageLevel
Definition: const.h:411
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:53
Proto::GameServerItemInfo
@ GameServerItemInfo
Definition: protocolcodes.h:155
LocalPlayer::setBlessings
void setBlessings(int blessings)
Definition: localplayer.cpp:518
Proto::GameServerMoveCreature
@ GameServerMoveCreature
Definition: protocolcodes.h:80
Proto::GameServerChannels
@ GameServerChannels
Definition: protocolcodes.h:126
Creature::hideStaticSquare
void hideStaticSquare()
Definition: creature.h:80
Otc::GameDeathType
@ GameDeathType
Definition: const.h:435
Proto::GameServerCreatureSkull
@ GameServerCreatureSkull
Definition: protocolcodes.h:104
protocolgame.h
Game::processTalk
static 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:595
Proto::GameServerPlayerInventory
@ GameServerPlayerInventory
Definition: protocolcodes.h:156
Otc::GameIngameStore
@ GameIngameStore
Definition: const.h:438
Game::processUpdateNeeded
static 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:646
Otc::AWARE_UNDEGROUND_FLOOR_RANGE
@ AWARE_UNDEGROUND_FLOOR_RANGE
Definition: const.h:39
Color::from8bit
static Color from8bit(int color)
Definition: color.h:90
Otc::FightModes
FightModes
Definition: const.h:227
ProtocolGame::getMappedThing
ThingPtr getMappedThing(const InputMessagePtr &msg)
Definition: protocolgameparse.cpp:2172
Map::getCreatureById
CreaturePtr getCreatureById(uint32 id)
Definition: map.cpp:525
Proto::GameServerRequestPurchaseData
@ GameServerRequestPurchaseData
Definition: protocolcodes.h:150
Proto::GameServerMultiUseDelay
@ GameServerMultiUseDelay
Definition: protocolcodes.h:123
Game::processAttackCancel
void processAttackCancel(uint seq)
Definition: game.cpp:522
Otc::MessageChannelManagement
@ MessageChannelManagement
Definition: const.h:315
Otc::MessageNpcFromStartBlock
@ MessageNpcFromStartBlock
Definition: const.h:362
Otc::MessageMonsterYell
@ MessageMonsterYell
Definition: const.h:354
tile.h
Map::getCentralPosition
Position getCentralPosition()
Definition: map.h:242
Creature::setBaseSpeed
void setBaseSpeed(double baseSpeed)
Definition: creature.cpp:755
LocalPlayer::setFreeCapacity
void setFreeCapacity(double freeCapacity)
Definition: localplayer.cpp:355
ProtocolGame::getStaticText
StaticTextPtr getStaticText(const InputMessagePtr &msg, int type=0)
Definition: protocolgameparse.cpp:2372
Creature::setOutfit
void setOutfit(const Outfit &outfit)
Definition: creature.cpp:678
Otc::GamePremiumExpiration
@ GamePremiumExpiration
Definition: const.h:422
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:343
Proto::StaticText
@ StaticText
Definition: protocolcodes.h:37
AwareRange::top
int top
Definition: map.h:131
Game::processLoginWait
static 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:198
Game::processPlayerHelpers
static void processPlayerHelpers(int helpers)
Definition: game.cpp:245
Creature::setEmblem
void setEmblem(uint8 emblem)
Definition: creature.cpp:781
AwareRange::right
int right
Definition: map.h:132
Thing::isStackable
bool isStackable()
Definition: thing.h:95
Otc::DeathRegular
@ DeathRegular
Definition: const.h:508
Game::processOwnTrade
static 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
static 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:380
Proto::GameServerPlayerData
@ GameServerPlayerData
Definition: protocolcodes.h:116
Game::processCloseChannel
static 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:239
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:2060
Otc::MessageHealOthers
@ MessageHealOthers
Definition: const.h:335
LocalPlayer::setSkill
void setSkill(Otc::Skill skill, int level, int levelPercent)
Definition: localplayer.cpp:303
Proto::GameServerOpenOwnChannel
@ GameServerOpenOwnChannel
Definition: protocolcodes.h:133
Otc::MessageSpell
@ MessageSpell
Definition: const.h:318
item.h
Proto::GameServerPlayerHelpers
@ GameServerPlayerHelpers
Definition: protocolcodes.h:108