ManaPlus
actions.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2018 The ManaPlus Developers
4  *
5  * This file is part of The ManaPlus Client.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "actions/actions.h"
22 
23 #include "actormanager.h"
24 #include "configuration.h"
25 #include "game.h"
26 #ifdef USE_OPENGL
27 #include "graphicsmanager.h"
28 #endif // USE_OPENGL
29 #include "main.h"
30 #include "spellmanager.h"
31 
32 #include "actions/actiondef.h"
33 
34 #include "being/localplayer.h"
35 #include "being/playerinfo.h"
36 
37 #include "const/spells.h"
38 
39 #include "const/resources/skill.h"
40 
41 #include "fs/files.h"
42 
43 #include "gui/gui.h"
44 #include "gui/popupmanager.h"
45 #include "gui/sdlinput.h"
46 #include "gui/windowmanager.h"
47 
51 
52 #include "gui/popups/popupmenu.h"
53 
54 #include "gui/windows/buydialog.h"
55 #include "gui/windows/okdialog.h"
57 #include "gui/windows/quitdialog.h"
59 #include "gui/windows/chatwindow.h"
60 #include "gui/windows/helpwindow.h"
63 #include "gui/windows/npcdialog.h"
66 #include "gui/windows/shopwindow.h"
70 
72 
74 
76 
77 #if defined USE_OPENGL
79 #endif // USE_OPENGL
80 
81 #include "net/adminhandler.h"
82 #include "net/beinghandler.h"
83 #include "net/buyingstorehandler.h"
84 #include "net/buysellhandler.h"
85 #include "net/chathandler.h"
86 #include "net/download.h"
87 #include "net/homunculushandler.h"
88 #include "net/gamehandler.h"
89 #include "net/inventoryhandler.h"
90 #include "net/ipc.h"
91 #include "net/mercenaryhandler.h"
92 #include "net/net.h"
93 #include "net/npchandler.h"
94 #include "net/serverfeatures.h"
95 #include "net/uploadcharinfo.h"
96 #include "net/tradehandler.h"
97 #include "net/vendinghandler.h"
98 
99 #include "resources/iteminfo.h"
100 #include "resources/memorymanager.h"
101 
103 
104 #include "utils/chatutils.h"
105 #include "utils/foreach.h"
106 #include "utils/gettext.h"
107 #include "utils/parameters.h"
108 #include "utils/timer.h"
109 
110 #ifdef TMWA_SUPPORT
111 #include "net/playerhandler.h"
112 
113 #include "utils/mathutils.h"
114 #endif // TMWA_SUPPORT
115 
116 PRAGMA48(GCC diagnostic push)
117 PRAGMA48(GCC diagnostic ignored "-Wshadow")
118 #ifdef ANDROID
119 #ifndef USE_SDL2
120 #include <SDL_screenkeyboard.h>
121 #endif // USE_OPENGL
122 #endif // ANDROID
123 PRAGMA48(GCC diagnostic pop)
124 
125 #include <sstream>
126 
127 #include "debug.h"
128 
129 extern std::string tradePartnerName;
130 extern QuitDialog *quitDialog;
131 extern time_t start_time;
132 extern char **environ;
133 
134 namespace Actions
135 {
136 
137 static int uploadUpdate(void *ptr,
138  const DownloadStatusT status,
139  size_t total A_UNUSED,
140  const size_t remaining A_UNUSED) A_NONNULL(1);
141 
142 static int uploadUpdate(void *ptr,
143  const DownloadStatusT status,
144  size_t total A_UNUSED,
145  const size_t remaining A_UNUSED)
146 {
147  if (status == DownloadStatus::Idle || status == DownloadStatus::Starting)
148  return 0;
149 
150  UploadChatInfo *const info = reinterpret_cast<UploadChatInfo*>(ptr);
151  if (info == nullptr)
152  return 0;
153 
154  if (status == DownloadStatus::Complete)
155  {
156  std::string str = Net::Download::getUploadResponse();
157  const size_t sz = str.size();
158  if (sz > 0)
159  {
160  if (str[sz - 1] == '\n')
161  str = str.substr(0, sz - 1);
162  str.append(info->addStr);
163  ChatTab *const tab = info->tab;
164  if (chatWindow != nullptr &&
165  (tab == nullptr || chatWindow->isTabPresent(tab)))
166  {
167  str = strprintf("%s [@@%s |%[email protected]@]",
168  info->text.c_str(), str.c_str(), str.c_str());
169  outStringNormal(tab, str, str);
170  }
171  else
172  {
174  // TRANSLATORS: file uploaded message
175  _("File uploaded"),
176  str,
177  // TRANSLATORS: ok dialog button
178  _("OK"),
180  Modal_true,
182  nullptr,
183  260);
184  }
185  }
186  }
187 // delete2(info->upload);
188  info->upload = nullptr;
189  delete info;
190  return 0;
191 }
192 
193 static void uploadFile(const std::string &str,
194  const std::string &fileName,
195  const std::string &addStr,
196  ChatTab *const tab)
197 {
198  UploadChatInfo *const info = new UploadChatInfo;
199  Net::Download *const upload = new Net::Download(info,
200  "http://ix.io",
201  &uploadUpdate,
202  false, true, false);
203  info->upload = upload;
204  info->text = str;
205  info->addStr = addStr;
206  info->tab = tab;
207  upload->setFile(fileName, -1);
208  upload->start();
209 }
210 
211 static Being *findBeing(const std::string &name, const bool npc)
212 {
213  if ((localPlayer == nullptr) || (actorManager == nullptr))
214  return nullptr;
215 
216  Being *being = nullptr;
217 
218  if (name.empty())
219  {
220  being = localPlayer->getTarget();
221  }
222  else
223  {
224  being = actorManager->findBeingByName(
225  name, ActorType::Unknown);
226  }
227  if ((being == nullptr) && npc)
228  {
231  if (being != nullptr)
232  {
233  if (abs(being->getTileX() - localPlayer->getTileX()) > 1
234  || abs(being->getTileY() - localPlayer->getTileY()) > 1)
235  {
236  being = nullptr;
237  }
238  }
239  }
240  if ((being == nullptr) && npc)
241  {
244  if (being != nullptr)
245  {
246  if (abs(being->getTileX() - localPlayer->getTileX()) > 1
247  || abs(being->getTileY() - localPlayer->getTileY()) > 1)
248  {
249  being = nullptr;
250  }
251  }
252  }
253  return being;
254 }
255 
256 static Item *getItemByInvIndex(const int index,
257  const InventoryTypeT invType)
258 {
259  const Inventory *inv = nullptr;
260  switch (invType)
261  {
264  break;
265 
267  inv = PlayerInfo::getInventory();
268  break;
270  case InventoryType::Npc:
271  case InventoryType::Cart:
277  default:
278  break;
279  }
280  if (inv != nullptr)
281  return inv->getItem(index);
282  return nullptr;
283 }
284 
285 static int getAmountFromEvent(const InputEvent &event,
286  Item *&item0,
287  const InventoryTypeT invType)
288 {
289  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
290  invType);
291  item0 = item;
292  if (item == nullptr)
293  return 0;
294 
295  std::string str = event.args;
296  removeToken(str, " ");
297 
298  if (str.empty())
299  return 0;
300 
301  int amount = 0;
302  if (str[0] == '-')
303  {
304  if (str.size() > 1)
305  {
306  amount = item->getQuantity() - atoi(str.substr(1).c_str());
307  if (amount <= 0 || amount > item->getQuantity())
308  amount = item->getQuantity();
309  }
310  }
311  else if (str == "/")
312  {
313  amount = item->getQuantity() / 2;
314  }
315  else if (str == "all")
316  {
317  amount = item->getQuantity();
318  }
319  else
320  {
321  amount = atoi(str.c_str());
322  }
323  return amount;
324 }
325 
327 {
328  const int emotion = 1 + (event.action - InputAction::EMOTE_1);
329  if (emotion > 0)
330  {
331  if (emoteShortcut != nullptr)
332  emoteShortcut->useEmotePlayer(emotion);
333  if (Game::instance() != nullptr)
335  return true;
336  }
337 
338  return false;
339 }
340 
342 {
344  {
345  const int num = event.action - InputAction::OUTFIT_1;
346  if ((outfitWindow != nullptr) && num >= 0)
347  {
349  true,
350  false);
351  if (Game::instance() != nullptr)
353  return true;
354  }
355  }
357  {
358  const int num = event.action - InputAction::OUTFIT_1;
359  if ((outfitWindow != nullptr) && num >= 0)
360  {
361  outfitWindow->copyOutfit(num);
362  if (Game::instance() != nullptr)
364  return true;
365  }
366  }
367 
368  return false;
369 }
370 
372 {
373  if ((guiInput == nullptr) || (gui == nullptr))
374  return false;
375 
376  int mouseX, mouseY;
377  Gui::getMouseState(mouseX, mouseY);
379  return true;
380 }
381 
383 {
384  // Close the Browser if opened
385  if ((helpWindow != nullptr) && helpWindow->isWindowVisible())
386  {
388  return true;
389  }
390  // Close the config window, cancelling changes if opened
391  else if ((setupWindow != nullptr) && setupWindow->isWindowVisible())
392  {
393  setupWindow->action(ActionEvent(nullptr, "cancel"));
394  return true;
395  }
396  else if (NpcDialog *const dialog = NpcDialog::getActive())
397  {
398  dialog->action(ActionEvent(nullptr, "ok"));
399  return true;
400  }
401  else if (popupMenu->isPopupVisible())
402  {
403  popupMenu->select();
404  }
405  return false;
406 }
407 
409 {
410  if (itemShortcutWindow != nullptr)
411  {
412  const int num = itemShortcutWindow->getTabIndex();
413  if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
414  {
415  if (itemShortcut[num] != nullptr)
416  {
417  itemShortcut[num]->useItem(event.action
419  }
420  }
421  return true;
422  }
423  return false;
424 }
425 
427 {
428  if (Game::instance() == nullptr)
429  return false;
431  {
433  return true;
434  }
435  else if (quitDialog == nullptr)
436  {
437  CREATEWIDGETV(quitDialog, QuitDialog,
438  &quitDialog);
439  quitDialog->requestMoveToTop();
440  return true;
441  }
442  return false;
443 }
444 
446 {
447  if (dropShortcut != nullptr)
448  {
450  return true;
451  }
452  return false;
453 }
454 
456 {
457  if (dropShortcut != nullptr)
458  {
460  return true;
461  }
462  return false;
463 }
464 
466 {
467  const Inventory *const inv = PlayerInfo::getInventory();
468  if (inv == nullptr)
469  return false;
470 
471  // +++ ignoring item color for now
472  Item *const item = inv->findItem(atoi(event.args.c_str()),
473  ItemColor_one);
474 
475  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
476  {
479  item,
480  0,
481  0);
482  }
483  return true;
484 }
485 
487 {
488  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
490  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
491  {
494  item,
495  0,
496  0);
497  }
498  return true;
499 }
500 
502 {
503  const Inventory *const inv = PlayerInfo::getInventory();
504  if (inv == nullptr)
505  return false;
506 
507  // +++ ignoring item color for now
508  Item *const item = inv->findItem(atoi(event.args.c_str()),
509  ItemColor_one);
510 
511  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
512  PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
513  return true;
514 }
515 
517 {
518  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
520  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
521  PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
522  return true;
523 }
524 
525 #ifdef TMWA_SUPPORT
527 {
529  return false;
530  if (actorManager != nullptr &&
531  localPlayer != nullptr)
532  {
533  std::string args = event.args;
534 
535  if (!args.empty())
536  {
537  const Being *being = nullptr;
538  if (args[0] == ':')
539  {
540  being = actorManager->findBeing(fromInt(atoi(
541  args.substr(1).c_str()), BeingId));
542  if (being != nullptr && being->getType() == ActorType::Monster)
543  being = nullptr;
544  }
545  else
546  {
548  }
549  if (being != nullptr)
550  actorManager->heal(being);
551  }
552  else
553  {
554  Being *target = localPlayer->getTarget();
556  {
557  if (target == nullptr ||
558  target->getType() != ActorType::Player)
559  {
562  }
563  }
564  else
565  {
566  if (target == nullptr)
567  target = localPlayer;
568  }
569  actorManager->heal(target);
570  }
571 
572  if (Game::instance() != nullptr)
574  return true;
575  }
576  return false;
577 }
578 #else // TMWA_SUPPORT
579 
581 {
582  return false;
583 }
584 #endif // TMWA_SUPPORT
585 
587 {
588 #ifdef TMWA_SUPPORT
590  return false;
591  if (actorManager != nullptr)
592  {
594  int maxHealingRadius;
595 
596  // magic levels < 2
597  if (PlayerInfo::getSkillLevel(340) < 2
598  || PlayerInfo::getSkillLevel(341) < 2)
599  {
600  maxHealingRadius = matk / 100 + 1;
601  }
602  else
603  {
604  maxHealingRadius = (12 * fastSqrtInt(matk) + matk) / 100 + 1;
605  }
606 
607  Being *target = actorManager->findMostDamagedPlayer(maxHealingRadius);
608  if (target != nullptr)
609  actorManager->heal(target);
610 
611  if (Game::instance() != nullptr)
613  return true;
614  }
615 #endif // TMWA_SUPPORT
616 
617  return false;
618 }
619 
621 {
622 #ifdef TMWA_SUPPORT
624  return false;
625  if (actorManager != nullptr)
626  {
627  if (playerHandler != nullptr &&
630  {
632  }
633  return true;
634  }
635 #endif // TMWA_SUPPORT
636 
637  return false;
638 }
639 
641 {
642  if (localPlayer != nullptr)
643  {
644  localPlayer->setHome();
645  return true;
646  }
647  return false;
648 }
649 
651 {
652 #ifdef TMWA_SUPPORT
654  return false;
655  if (localPlayer != nullptr)
656  {
658  return true;
659  }
660 #endif // TMWA_SUPPORT
661 
662  return false;
663 }
664 
666 {
667  if (outfitWindow != nullptr)
668  {
670  return true;
671  }
672  return false;
673 }
674 
676 {
677  if (localPlayer == nullptr)
678  return false;
679 
680  const std::string args = event.args;
681  if (args.empty())
682  {
684  }
685  else
686  {
688  atoi(args.c_str()), BeingId));
689  if (item != nullptr)
690  localPlayer->pickUp(item);
691  }
692  return true;
693 }
694 
695 static void doSit()
696 {
699  else
701 }
702 
704 {
705  if (localPlayer != nullptr)
706  {
707  doSit();
708  return true;
709  }
710  return false;
711 }
712 
714 {
715  Game::createScreenshot(event.args);
716  return true;
717 }
718 
720 {
721  return true;
722 }
723 
725 {
726  if (serverFeatures == nullptr)
727  return false;
728  const std::string args = event.args;
729  Being *being = findBeing(args, false);
730  if ((being == nullptr) && Net::getNetworkType() == ServerType::TMWATHENA)
731  {
732  if (whoIsOnline != nullptr)
733  {
734  const std::set<std::string> &players =
736  if (players.find(args) != players.end())
737  {
738  if (buySellHandler != nullptr)
740  return true;
741  }
742  }
743  return false;
744  }
745 
746  if (being == nullptr)
747  being = findBeing(args, true);
748 
749  if (being == nullptr)
750  return false;
751 
752  if (being->getType() == ActorType::Npc)
753  {
754  if (npcHandler != nullptr)
755  npcHandler->buy(being);
756  return true;
757  }
758  else if (being->getType() == ActorType::Player)
759  {
760  if (vendingHandler != nullptr &&
762  {
763  vendingHandler->open(being);
764  }
765  else if (buySellHandler != nullptr)
766  {
768  }
769  return true;
770  }
771  return false;
772 }
773 
775 {
776  if (serverFeatures == nullptr)
777  return false;
778 
779  const std::string args = event.args;
780  Being *being = findBeing(args, false);
781  if (being == nullptr &&
783  {
784  if (whoIsOnline != nullptr)
785  {
786  const std::set<std::string> &players =
788  if (players.find(args) != players.end())
789  {
790  if (buySellHandler != nullptr)
792  return true;
793  }
794  }
795  return false;
796  }
797 
798  if (being == nullptr)
799  being = findBeing(args, true);
800 
801  if (being == nullptr)
802  return false;
803 
804  if (being->getType() == ActorType::Npc)
805  {
806  if (npcHandler != nullptr)
807  npcHandler->sell(being->getId());
808  return true;
809  }
810  else if (being->getType() == ActorType::Player)
811  {
812  if ((buyingStoreHandler != nullptr) &&
814  {
815  buyingStoreHandler->open(being);
816  }
817  else if (buySellHandler != nullptr)
818  {
820  }
821  return true;
822  }
823  return false;
824 }
825 
827 {
828  Being *being = findBeing(event.args, true);
829  if (being == nullptr)
830  return false;
831 
832  if (being->canTalk())
833  {
834  being->talkTo();
835  }
836  else if (being->getType() == ActorType::Player)
837  {
839  being->getName());
840  }
841  return true;
842 }
843 
845 {
846  if (localPlayer != nullptr)
847  {
848  localPlayer->stopAttack(false);
849  // not consume if target attack key pressed
851  return false;
852  return true;
853  }
854  return false;
855 }
856 
858 {
859  if (localPlayer != nullptr)
860  {
862  return true;
863  }
864  return false;
865 }
866 
868 {
869  if ((localPlayer == nullptr) || (actorManager == nullptr))
870  return false;
871 
872  Being *target = nullptr;
873  std::string args = event.args;
874  if (!args.empty())
875  {
876  if (args[0] != ':')
877  {
878  target = actorManager->findNearestByName(args,
880  }
881  else
882  {
883  target = actorManager->findBeing(fromInt(atoi(
884  args.substr(1).c_str()), BeingId));
885  if (target != nullptr &&
886  target->getType() != ActorType::Monster)
887  {
888  target = nullptr;
889  }
890  }
891  }
892  if (target == nullptr)
893  target = localPlayer->getTarget();
894  else
895  localPlayer->setTarget(target);
896  if (target != nullptr)
897  localPlayer->attack(target, true, false);
898  return true;
899 }
900 
902 {
903  if ((localPlayer != nullptr) && (actorManager != nullptr))
904  {
905  Being *target = nullptr;
906  std::string args = event.args;
907  const bool newTarget = !inputManager.isActionActive(
909 
910  if (!args.empty())
911  {
912  if (args[0] != ':')
913  {
914  target = actorManager->findNearestByName(args,
916  }
917  else
918  {
919  target = actorManager->findBeing(fromInt(atoi(
920  args.substr(1).c_str()), BeingId));
921  if (target != nullptr &&
922  target->getType() != ActorType::Monster)
923  {
924  target = nullptr;
925  }
926  }
927  }
928 
929  if ((target == nullptr) && (settings.targetingType == 0u))
930  target = localPlayer->getTarget();
931 
932  if (target == nullptr)
933  {
936  }
937 
938  localPlayer->attack2(target, newTarget, false);
939  return true;
940  }
941  return false;
942 }
943 
945 {
946  if ((actorManager == nullptr) || (localPlayer == nullptr))
947  return false;
948 
949  Being *const target = actorManager->findNearestPvpPlayer();
950  if (target != nullptr)
951  {
952  localPlayer->setTarget(target);
953  localPlayer->attack2(target, true, false);
954  }
955  return true;
956 }
957 
959 {
961 
962  return true;
963 }
964 
966 {
967  if (localPlayer != nullptr)
968  {
969  localPlayer->stopAttack(false);
970  // not consume if target attack key pressed
972  return false;
973  if (localPlayer->getTarget() == nullptr)
974  {
975  doSit();
976  return true;
977  }
978  return true;
979  }
980  return false;
981 }
982 
984 {
985 #ifdef ANDROID
986 #ifdef USE_SDL2
987  if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE)
988  SDL_StopTextInput();
989  else
990  SDL_StartTextInput();
991 #else // USE_SDL2
992 
993  SDL_ANDROID_ToggleScreenKeyboardTextInput(nullptr);
994 #endif // USE_SDL2
995 
996  return true;
997 #else // ANDROID
998 
999  return false;
1000 #endif // ANDROID
1001 }
1002 
1004 {
1005  if (popupMenu != nullptr)
1006  {
1008  return true;
1009  }
1010  return false;
1011 }
1012 
1014 {
1015  const Being *const being = localPlayer->getTarget();
1016  if ((being != nullptr) && being->getType() == ActorType::Player)
1017  {
1018  if (tradeHandler != nullptr)
1019  tradeHandler->request(being);
1020  tradePartnerName = being->getName();
1021  if (tradeWindow != nullptr)
1022  tradeWindow->clear();
1023  return true;
1024  }
1025  return false;
1026 }
1027 
1029 {
1030  if (ipc != nullptr)
1031  {
1032  IPC::stop();
1033  if (ipc == nullptr)
1034  {
1035  debugChatTab->chatLog("IPC service stopped.",
1039  }
1040  else
1041  {
1042  debugChatTab->chatLog("Unable to stop IPC service.",
1046  }
1047  }
1048  else
1049  {
1050  IPC::start();
1051  if (ipc != nullptr)
1052  {
1054  strprintf("IPC service available on port %d", ipc->getPort()),
1058  }
1059  else
1060  {
1061  debugChatTab->chatLog("Unable to start IPC service",
1065  }
1066  }
1067  return true;
1068 }
1069 
1071 {
1072  ChatTab *const tab = event.tab != nullptr ? event.tab : debugChatTab;
1073  if (tab == nullptr)
1074  return false;
1075  std::ostringstream where;
1076  where << Game::instance()->getCurrentMapName() << ", coordinates: "
1077  << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize)
1078  << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize);
1079  tab->chatLog(where.str(),
1083  return true;
1084 }
1085 
1087 {
1088  if (chatHandler != nullptr)
1089  chatHandler->who();
1090  return true;
1091 }
1092 
1094 {
1096 
1097  if (debugChatTab != nullptr)
1098  {
1099  // TRANSLATORS: clear graphics command message
1100  debugChatTab->chatLog(_("Cache cleared"),
1104  }
1105  return true;
1106 }
1107 
1109 {
1110  if (gui != nullptr)
1111  gui->clearFonts();
1112  if (debugChatTab != nullptr)
1113  {
1114  // TRANSLATORS: clear fonts cache message
1115  debugChatTab->chatLog(_("Cache cleared"),
1119  }
1120  return true;
1121 }
1122 
1124 {
1125  if (actorManager == nullptr)
1126  return false;
1127 
1128  const Being *being = actorManager->findBeingByName(
1129  event.args, ActorType::Player);
1130  if (being == nullptr)
1131  being = localPlayer->getTarget();
1132  if (being != nullptr)
1133  {
1134  if (tradeHandler != nullptr)
1135  tradeHandler->request(being);
1136  tradePartnerName = being->getName();
1137  if (tradeWindow != nullptr)
1138  tradeWindow->clear();
1139  }
1140  return true;
1141 }
1142 
1144 {
1145  if (shopWindow != nullptr)
1146  {
1147  shopWindow->loadList();
1148  return true;
1149  }
1150  return false;
1151 }
1152 
1154 {
1155  if (shopWindow != nullptr)
1156  {
1157  shopWindow->saveList();
1158  return true;
1159  }
1160  return false;
1161 }
1162 
1164 {
1165  if ((chatWindow == nullptr) || (debugChatTab == nullptr))
1166  return false;
1167 
1168 /*
1169  Font *const font = chatWindow->getFont();
1170  if (!font)
1171  return;
1172 
1173  const TextChunkList *const cache = font->getCache();
1174  if (!cache)
1175  return;
1176 
1177  unsigned int all = 0;
1178  // TRANSLATORS: chat fonts message
1179  debugChatTab->chatLog(_("font cache size"),
1180  ChatMsgType::BY_SERVER,
1181  IgnoreRecord_false,
1182  TryRemoveColors_true);
1183  std::string str;
1184  for (int f = 0; f < 256; f ++)
1185  {
1186  if (!cache[f].size)
1187  {
1188  const unsigned int sz = CAST_S32(cache[f].size);
1189  all += sz;
1190  str.append(strprintf("%d: %u, ", f, sz));
1191  }
1192  }
1193  debugChatTab->chatLog(str,
1194  ChatMsgType::BY_SERVER,
1195  IgnoreRecord_false,
1196  TryRemoveColors_true);
1197  // TRANSLATORS: chat fonts message
1198  debugChatTab->chatLog(strprintf("%s %d", _("Cache size:"), all),
1199  ChatMsgType::BY_SERVER,
1200  IgnoreRecord_false,
1201  TryRemoveColors_true);
1202 #ifdef DEBUG_FONT_COUNTERS
1203  debugChatTab->chatLog("",
1204  ChatMsgType::BY_SERVER,
1205  IgnoreRecord_false,
1206  TryRemoveColors_true);
1207  debugChatTab->chatLog(strprintf("%s %d",
1208  // TRANSLATORS: chat fonts message
1209  _("Created:"), font->getCreateCounter()),
1210  ChatMsgType::BY_SERVER,
1211  IgnoreRecord_false,
1212  TryRemoveColors_true);
1213  debugChatTab->chatLog(strprintf("%s %d",
1214  // TRANSLATORS: chat fonts message
1215  _("Deleted:"), font->getDeleteCounter()),
1216  ChatMsgType::BY_SERVER,
1217  IgnoreRecord_false,
1218  TryRemoveColors_true);
1219 #endif
1220 */
1221  return true;
1222 }
1223 
1225 {
1226  if (gameHandler != nullptr)
1228  return true;
1229 }
1230 
1232 {
1233  if ((actorManager == nullptr) || (localPlayer == nullptr))
1234  return false;
1235 
1236  const std::string args = event.args;
1237  StringVect pars;
1238  if (!splitParameters(pars, args, " ,", '\"'))
1239  return false;
1240  Being *target = nullptr;
1241  const size_t sz = pars.size();
1242  if (sz == 0)
1243  {
1244  target = localPlayer->getTarget();
1245  }
1246  else
1247  {
1248  if (pars[0][0] == ':')
1249  {
1250  target = actorManager->findBeing(fromInt(atoi(
1251  pars[0].substr(1).c_str()), BeingId));
1252  if ((target != nullptr) && target->getType() == ActorType::Monster)
1253  target = nullptr;
1254  }
1255  else
1256  {
1257  target = actorManager->findNearestByName(args,
1259  }
1260  }
1261 
1262  if (sz == 2)
1263  {
1264  const int itemId = atoi(pars[1].c_str());
1265  if (target != nullptr)
1266  target->undressItemById(itemId);
1267  }
1268  else
1269  {
1270  if ((target != nullptr) && (beingHandler != nullptr))
1271  beingHandler->undress(target);
1272  }
1273 
1274  return true;
1275 }
1276 
1278 {
1279  if (debugChatTab == nullptr)
1280  return false;
1281 
1282  debugChatTab->chatLog("config directory: "
1283  + settings.configDir,
1287  debugChatTab->chatLog("logs directory: "
1292  debugChatTab->chatLog("screenshots directory: "
1297  debugChatTab->chatLog("temp directory: "
1298  + settings.tempDir,
1302  return true;
1303 }
1304 
1306 {
1307  if (debugChatTab == nullptr)
1308  return false;
1309 
1310  if (cur_time < start_time)
1311  {
1312  // TRANSLATORS: uptime command
1313  debugChatTab->chatLog(strprintf(_("Client uptime: %s"), "unknown"),
1317  }
1318  else
1319  {
1320  // TRANSLATORS: uptime command
1321  debugChatTab->chatLog(strprintf(_("Client uptime: %s"),
1322  timeDiffToString(CAST_S32(cur_time - start_time)).c_str()),
1326  }
1327  return true;
1328 }
1329 
1330 #ifdef DEBUG_DUMP_LEAKS1
1331 static void showRes(std::string str, ResourceManager::Resources *res)
1332 {
1333  if (!res)
1334  return;
1335 
1336  str.append(toString(res->size()));
1337  if (debugChatTab)
1338  {
1339  debugChatTab->chatLog(str,
1343  }
1344  logger->log(str);
1345  ResourceManager::ResourceIterator iter = res->begin();
1346  const ResourceManager::ResourceIterator iter_end = res->end();
1347  while (iter != iter_end)
1348  {
1349  if (iter->second && iter->second->mRefCount)
1350  {
1351  char type = ' ';
1352  char isNew = 'N';
1353  if (iter->second->getDumped())
1354  isNew = 'O';
1355  else
1356  iter->second->setDumped(true);
1357 
1358  SubImage *const subImage = dynamic_cast<SubImage *>(
1359  iter->second);
1360  Image *const image = dynamic_cast<Image *>(iter->second);
1361  int id = 0;
1362  if (subImage)
1363  type = 'S';
1364  else if (image)
1365  type = 'I';
1366  if (image)
1367  id = image->getGLImage();
1368  logger->log("Resource %c%c: %s (%d) id=%d", type,
1369  isNew, iter->second->getIdPath().c_str(),
1370  iter->second->mRefCount, id);
1371  }
1372  ++ iter;
1373  }
1374 }
1375 
1377 {
1378  if (!debugChatTab)
1379  return false;
1380 
1381  if (!event.args.empty())
1382  {
1383  ResourceManager::Resources *res = ResourceManager::getResources();
1384  // TRANSLATORS: dump command
1385  showRes(_("Resource images:"), res);
1386  res = ResourceManager::getOrphanedResources();
1387  // TRANSLATORS: dump command
1388  showRes(_("Orphaned resource images:"), res);
1389  }
1390  else
1391  {
1392  ResourceManager::Resources *res = ResourceManager::getResources();
1393  // TRANSLATORS: dump command
1394  debugChatTab->chatLog(_("Resource images:") + toString(res->size()),
1398  res = ResourceManager::getOrphanedResources();
1399  // TRANSLATORS: dump command
1400  debugChatTab->chatLog(_("Orphaned resource images:")
1401  + toString(res->size()),
1405  }
1406  return true;
1407 }
1408 
1409 #elif defined ENABLE_MEM_DEBUG
1411 {
1413  return true;
1414 }
1415 #else // DEBUG_DUMP_LEAKS1
1416 
1418 {
1419  return true;
1420 }
1421 #endif // DEBUG_DUMP_LEAKS1
1422 
1424 {
1425  if (chatHandler != nullptr)
1427  return true;
1428 }
1429 
1431 {
1432  if (chatHandler != nullptr)
1434  return true;
1435 }
1436 
1437 PRAGMA6(GCC diagnostic push)
1438 PRAGMA6(GCC diagnostic ignored "-Wnull-dereference")
1440 {
1441  int *const ptr = nullptr;
1442  *(ptr + 1) = 20;
1443 // logger->log("test %d", *ptr);
1444  exit(1);
1445 }
1446 PRAGMA6(GCC diagnostic pop)
1447 
1449 {
1450  std::string str = strprintf("%s,%s,%dX%dX%d,", PACKAGE_OS, SMALL_VERSION,
1452  mainGraphics->getBpp());
1453 
1454  if (mainGraphics->getFullScreen())
1455  str.append("F");
1456  else
1457  str.append("W");
1458  if (mainGraphics->getHWAccel())
1459  str.append("H");
1460  else
1461  str.append("S");
1462 
1464  str.append("D");
1465  else
1466  str.append("_");
1467 
1468 #if defined USE_OPENGL
1469  str.append(strprintf(",%d", mainGraphics->getOpenGL()));
1470 #else // defined USE_OPENGL
1471 
1472  str.append(",0");
1473 #endif // defined USE_OPENGL
1474 
1475  str.append(strprintf(",%f,", static_cast<double>(settings.guiAlpha)))
1476  .append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
1477  .append(config.getBoolValue("alphaCache") ? "1" : "0")
1478  .append(config.getBoolValue("enableMapReduce") ? "1" : "0")
1479  .append(config.getBoolValue("beingopacity") ? "1" : "0")
1480  .append(",")
1481  .append(config.getBoolValue("enableAlphaFix") ? "1" : "0")
1482  .append(config.getBoolValue("disableAdvBeingCaching") ? "1" : "0")
1483  .append(config.getBoolValue("disableBeingCaching") ? "1" : "0")
1484  .append(config.getBoolValue("particleeffects") ? "1" : "0")
1485  .append(strprintf(",%d-%d", fps, config.getIntValue("fpslimit")));
1486  outStringNormal(event.tab, str, str);
1487  return true;
1488 }
1489 
1491 {
1492  logger->log1("Start environment variables");
1493  for (char **env = environ; *env != nullptr; ++ env)
1494  logger->log1(*env);
1495  logger->log1("End environment variables");
1496  if (debugChatTab != nullptr)
1497  {
1498  // TRANSLATORS: dump environment command
1499  debugChatTab->chatLog(_("Environment variables dumped"),
1503  }
1504  return true;
1505 }
1506 
1508 {
1509  const std::string str = config.getStringValue("testInfo");
1510  outStringNormal(event.tab, str, str);
1511  return true;
1512 }
1513 
1515 {
1516 #if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
1518 #endif // defined(USE_OPENGL) && !defined(ANDROID) &&
1519  // !defined(__native_client__)
1520 
1521  return true;
1522 }
1523 
1524 #ifdef USE_OPENGL
1526 {
1527  std::string str = graphicsManager.getGLVersion();
1528  outStringNormal(event.tab, str, str);
1529  return true;
1530 }
1531 #else // USE_OPENGL
1532 
1534 {
1535  return true;
1536 }
1537 #endif // USE_OPENGL
1538 
1540 {
1541  std::string str = "enabled mods: " + serverConfig.getValue("mods", "");
1542  outStringNormal(event.tab, str, str);
1543  return true;
1544 }
1545 
1546 #if defined USE_OPENGL && defined DEBUG_SDLFONT
1547 impHandler0(testSdlFont)
1548 {
1549  Font *font = new Font("fonts/dejavusans.ttf", 18, TTF_STYLE_NORMAL);
1550  timespec time1;
1551  timespec time2;
1552  NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
1553  STD_VECTOR<std::string> data;
1554  volatile int width = 0;
1555 
1556  for (int f = 0; f < 300; f ++)
1557  data.push_back("test " + toString(f) + "string");
1558  nullGraphics->beginDraw();
1559 
1560  clock_gettime(CLOCK_MONOTONIC, &time1);
1561  Color color(0, 0, 0, 255);
1562 
1563  for (int f = 0; f < 500; f ++)
1564  {
1565  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
1566  {
1567  width += font->getWidth(*it);
1568  font->drawString(nullGraphics, color, color, *it, 10, 10);
1569  }
1570  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
1571  font->drawString(nullGraphics, color, color, *it, 10, 10);
1572 
1573  font->doClean();
1574  }
1575 
1576  clock_gettime(CLOCK_MONOTONIC, &time2);
1577 
1578  delete nullGraphics;
1579  delete font;
1580 
1581  int64_t diff = (static_cast<long long int>(
1582  time2.tv_sec) * 1000000000LL + static_cast<long long int>(
1583  time2.tv_nsec)) / 100000 - (static_cast<long long int>(
1584  time1.tv_sec) * 1000000000LL + static_cast<long long int>(
1585  time1.tv_nsec)) / 100000;
1586  if (debugChatTab)
1587  {
1588  debugChatTab->chatLog("sdlfont time: " + toString(diff),
1592  }
1593  return true;
1594 }
1595 #endif // defined USE_OPENGL && defined DEBUG_SDLFONT
1596 
1598 {
1599  BuyDialog *const dialog = CREATEWIDGETR0(BuyDialog);
1600  const ItemDB::ItemInfos &items = ItemDB::getItemInfos();
1601  FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items)
1602  {
1603  const ItemInfo *const info = (*it).second;
1604  if (info == nullptr)
1605  continue;
1606  const int id = info->getId();
1607  if (id <= 500)
1608  continue;
1609 
1610  dialog->addItem(id,
1612  ItemColor_one,
1613  100,
1614  0);
1615  }
1616  dialog->sort();
1617  return true;
1618 }
1619 
1621 {
1622  int id = 0;
1623  int amount = 0;
1624 
1625  if (adminHandler == nullptr)
1626  return false;
1627 
1628  if (parse2Int(event.args, id, amount))
1629  adminHandler->createItems(id, ItemColor_one, amount);
1630  else
1631  adminHandler->createItems(atoi(event.args.c_str()), ItemColor_one, 1);
1632  return true;
1633 }
1634 
1636 {
1637  // TRANSLATORS: upload config chat message
1638  uploadFile(_("Config uploaded to:"),
1639  config.getFileName(),
1640  "?xml",
1641  event.tab);
1642  return true;
1643 }
1644 
1646 {
1647  // TRANSLATORS: upload config chat message
1648  uploadFile(_("Server config Uploaded to:"),
1650  "?xml",
1651  event.tab);
1652  return true;
1653 }
1654 
1656 {
1657  // TRANSLATORS: upload log chat message
1658  uploadFile(_("Log uploaded to:"),
1660  "",
1661  event.tab);
1662  return true;
1663 }
1664 
1666 {
1667  if (mercenaryHandler != nullptr)
1669  return true;
1670 }
1671 
1673 {
1674  if (mercenaryHandler != nullptr)
1676  return true;
1677 }
1678 
1680 {
1681  if (homunculusHandler != nullptr)
1683  return true;
1684 }
1685 
1687 {
1688  if (homunculusHandler != nullptr)
1690  return true;
1691 }
1692 
1694 {
1695  StringVect pars;
1696  if (!splitParameters(pars, event.args, " ,", '\"'))
1697  return false;
1698  const int sz = CAST_S32(pars.size());
1699  if (sz < 1)
1700  return false;
1701 
1702  const int itemId = atoi(pars[0].c_str());
1703 
1704  if (itemId < SPELL_MIN_ID)
1705  {
1706  const Inventory *const inv = PlayerInfo::getInventory();
1707  if (inv != nullptr)
1708  {
1709  ItemColor color = ItemColor_one;
1710  int16_t useType = 0;
1711  StringVect pars2;
1712  if (!splitParameters(pars2, pars[0], " ,", '\"'))
1713  return false;
1714  const int sz2 = CAST_S32(pars2.size());
1715  if (sz2 < 1)
1716  return false;
1717  if (sz2 >= 2)
1718  color = fromInt(atoi(pars2[1].c_str()), ItemColor);
1719  if (sz >= 2)
1720  useType = CAST_S16(atoi(pars[1].c_str()));
1721  const Item *const item = inv->findItem(itemId,
1722  color);
1723  PlayerInfo::useEquipItem(item, useType, Sfx_true);
1724  }
1725  }
1726  else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
1727  {
1728  spellManager->useItem(itemId);
1729  }
1730  else if (skillDialog != nullptr)
1731  {
1732  // +++ probably need get data parameter from args
1733  skillDialog->useItem(itemId,
1734  fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
1735  0,
1736  std::string());
1737  }
1738  return true;
1739 }
1740 
1742 {
1743  int param1 = 0;
1744  int param2 = 0;
1745  const std::string args = event.args;
1746  if (parse2Int(args, param1, param2))
1747  {
1748  Item *const item = getItemByInvIndex(param1,
1750  PlayerInfo::useEquipItem(item, CAST_S16(param2), Sfx_true);
1751  }
1752  else
1753  {
1754  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
1757  }
1758  return true;
1759 }
1760 
1762 {
1763  Item *item = nullptr;
1764  const int amount = getAmountFromEvent(event, item,
1766  if (item == nullptr)
1767  return true;
1768  if (amount != 0)
1769  {
1770  if (inventoryHandler != nullptr)
1771  {
1773  item->getInvIndex(),
1774  amount,
1776  }
1777  }
1778  else
1779  {
1782  item,
1783  0,
1784  0);
1785  }
1786  return true;
1787 }
1788 
1790 {
1791  Item *item = nullptr;
1792  const int amount = getAmountFromEvent(event, item,
1794  if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
1795  return true;
1796 
1797  if (amount != 0)
1798  {
1799  if (tradeWindow != nullptr)
1800  tradeWindow->tradeItem(item, amount, true);
1801  }
1802  else
1803  {
1805  tradeWindow,
1806  item,
1807  0,
1808  0);
1809  }
1810  return true;
1811 }
1812 
1814 {
1815  Item *item = nullptr;
1816  const int amount = getAmountFromEvent(event, item, InventoryType::Storage);
1817  if (amount != 0)
1818  {
1819  if ((inventoryHandler != nullptr) && (item != nullptr))
1820  {
1822  item->getInvIndex(),
1823  amount,
1825  }
1826  }
1827  else
1828  {
1830  storageWindow,
1831  item,
1832  0,
1833  0);
1834  }
1835  return true;
1836 }
1837 
1839 {
1840  const int id = atoi(event.args.c_str());
1841  if (id > 0)
1843  return true;
1844 }
1845 
1847 {
1848  const int id = atoi(event.args.c_str());
1849  if (id > 0)
1851  return true;
1852 }
1853 
1855 {
1856  if ((localPlayer == nullptr) || (actorManager == nullptr))
1857  return false;
1858 
1859  Being *target = nullptr;
1860  std::string args = event.args;
1861  if (!args.empty())
1862  {
1863  if (args[0] != ':')
1864  {
1865  target = actorManager->findNearestByName(args,
1867  }
1868  else
1869  {
1870  target = actorManager->findBeing(fromInt(atoi(
1871  args.substr(1).c_str()), BeingId));
1872  }
1873  }
1874  if (target == nullptr)
1875  target = localPlayer->getTarget();
1876  if ((target != nullptr) && (adminHandler != nullptr))
1877  adminHandler->kick(target->getId());
1878  return true;
1879 }
1880 
1882 {
1883  if (dropShortcut != nullptr)
1884  dropShortcut->clear(true);
1885  return true;
1886 }
1887 
1889 {
1890  if (actorManager != nullptr)
1891  {
1892  logger->log("actors count: %d", CAST_S32(
1893  actorManager->size()));
1894  return true;
1895  }
1896  return false;
1897 }
1898 
1900 {
1901  const int slot = (event.action - InputAction::CRAFT_1);
1902  if (slot >= 0 && slot < 9)
1903  {
1904  if (inventoryWindow != nullptr)
1906  return true;
1907  }
1908  return false;
1909 }
1910 
1912 {
1914  return true;
1915 }
1916 
1918 {
1919  if (chatWindow != nullptr)
1920  {
1921  chatWindow->addInputText(event.args,
1922  true);
1923  return true;
1924  }
1925  return false;
1926 }
1927 
1929 {
1930  if (actorManager == nullptr)
1931  return false;
1932 
1933  ChatTab *tab = event.tab;
1934  if (tab == nullptr)
1935  tab = localChatTab;
1936  if (tab == nullptr)
1937  return false;
1938 
1939  if (config.getBoolValue("enableIdCollecting") == false)
1940  {
1941  // TRANSLATORS: last seen disabled warning
1942  tab->chatLog(_("Last seen disabled. "
1943  "Enable in players / collect players ID and seen log."),
1947  return true;
1948  }
1949 
1950  const std::string name = event.args;
1951  if (name.empty())
1952  return false;
1953 
1954  std::string dir = settings.usersDir;
1955  dir.append(stringToHexPath(name)).append("/seen.txt");
1956  if (Files::existsLocal(dir))
1957  {
1958  StringVect lines;
1959  Files::loadTextFileLocal(dir, lines);
1960  if (lines.size() < 3)
1961  {
1962  // TRANSLATORS: last seen error
1963  tab->chatLog(_("You have never seen this nick."),
1967  return true;
1968  }
1969  const std::string message = strprintf(
1970  // TRANSLATORS: last seen message
1971  _("Last seen for %s: %s"),
1972  name.c_str(),
1973  lines[2].c_str());
1974  tab->chatLog(message,
1978  }
1979  else
1980  {
1981  // TRANSLATORS: last seen error
1982  tab->chatLog(_("You have not seen this nick before."),
1986  }
1987 
1988  return true;
1989 }
1990 
1992 {
1993  if (event.tab != nullptr)
1994  memoryManager.printAllMemory(event.tab);
1995  else
1997  return true;
1998 }
1999 
2001 {
2002  const std::string &args = event.args;
2003  if (args == "player" || args.empty())
2004  {
2006  }
2007  else if (args == "pet")
2008  {
2010  }
2011  else if (args == "homun" || args == "homunculus")
2012  {
2014  }
2015  else if (args == "merc" || args == "mercenary")
2016  {
2018  }
2019  return true;
2020 }
2021 
2022 } // namespace Actions
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
int getInvIndex() const
Definition: item.h:164
ChatWindow * chatWindow
Definition: chatwindow.cpp:89
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void useItem(const size_t index) const
bool openTrade(InputEvent &event)
Definition: actions.cpp:64
Being * findNearestPvpPlayer() const
void clear(const bool isSave)
std::string getStringValue(const std::string &key) const
#define _(s)
Definition: gettext.h:34
virtual void moveItem2(const InventoryTypeT source, const int slot, const int amount, const InventoryTypeT destination) const =0
DropShortcut * dropShortcut
virtual void feed() const =0
static int uploadUpdate(void *ptr, const DownloadStatusT status, size_t total, const size_t remaining)
Definition: actions.cpp:142
int fastSqrtInt(const unsigned int n)
Definition: mathutils.h:244
bool setHome(InputEvent &event)
Definition: actions.cpp:45
bool invToStorage(InputEvent &event)
Definition: actions.cpp:105
void loadList()
Definition: shopwindow.cpp:545
void log1(const char *const log_text)
Definition: logger.cpp:233
bool testInfo(InputEvent &event)
Definition: actions.cpp:112
static void doSit()
Definition: actions.cpp:695
bool quit(InputEvent &event)
Definition: actions.cpp:35
int getTileY() const
Definition: being.h:173
static bool createScreenshot(const std::string &prefix)
Definition: game.cpp:533
void useItem(const int itemId, const AutoTarget autoTarget, const int level, const std::string &data) const
bool ignoreInput(InputEvent &event)
Definition: actions.cpp:51
bool dropItemIdAll(InputEvent &event)
Definition: actions.cpp:40
bool cleanGraphics(InputEvent &event)
Definition: actions.cpp:68
TradeWindow * tradeWindow
Definition: tradewindow.cpp:64
bool priceLoad(InputEvent &event)
Definition: actions.cpp:71
ChatTab * localChatTab
Definition: chattab.cpp:61
FloorItem * findItem(const BeingId id) const
Gui * gui
Definition: gui.cpp:110
Definition: font.h:88
std::string removeToken(std::string &str, const std::string &token)
void attack(Being *const target, const bool keep, const bool dontChangeEquipment)
void copyOutfit(const int outfit)
bool healmd(InputEvent &event)
Definition: actions.cpp:43
bool showWindows(InputEvent &event)
Definition: actions.cpp:63
void setValidSpeed()
Definition: game.cpp:1269
static void stop()
Definition: ipc.cpp:153
virtual void buy(const Being *const being) const =0
void outStringNormal(ChatTab *const tab, const std::string &str, const std::string &def)
Definition: chatutils.cpp:46
bool stopSit(InputEvent &event)
Definition: actions.cpp:61
OutfitWindow * outfitWindow
virtual void unIgnoreAll() const =0
virtual void undress(Being *const being) const =0
#define fromInt(val, name)
Definition: intdefines.h:45
std::string fileName
Definition: testmain.cpp:38
void clearFonts()
Definition: gui.cpp:371
InventoryType ::T InventoryTypeT
Definition: inventorytype.h:41
static std::string getUploadResponse()
Definition: download.h:113
SpellManager * spellManager
int getId() const
Definition: iteminfo.h:67
const std::string & getCurrentMapName() const
Definition: game.h:109
Item * findItem(const int itemId, const ItemColor color) const
Definition: inventory.cpp:93
BeingId getId() const
Definition: actorsprite.h:63
bool isTabPresent(const ChatTab *const tab) const
std::string stringToHexPath(const std::string &str)
virtual void kick(const BeingId playerId) const =0
std::string getFileName() const
bool loadTextFileLocal(const std::string &fileName, StringVect &lines)
Definition: files.cpp:228
static NpcDialog * getActive()
Definition: npcdialog.cpp:851
virtual void requestMoveToTop()
Definition: widget.cpp:212
void doClean()
Definition: font.cpp:365
virtual bool canUseMagic() const =0
Inventory * getInventory()
Definition: playerinfo.cpp:192
std::string usersDir
Definition: settings.h:116
Being * findNearestByName(const std::string &name, const ActorTypeT &type) const
Configuration config
static int getAmountFromEvent(const InputEvent &event, Item *&item0, const InventoryTypeT invType)
Definition: actions.cpp:285
const bool Sfx_true
Definition: sfx.h:29
int BeingId
Definition: beingid.h:29
bool pickup(InputEvent &event)
Definition: actions.cpp:48
static void showWindow(const ItemAmountWindowUsageT usage, Window *const parent, Item *const item, int maxRange, const int tag)
MemoryManager memoryManager
void showWindowsPopup()
Definition: popupmenu.cpp:2217
bool copyEquippedToOutfit(InputEvent &event)
Definition: actions.cpp:47
void saveList() const
Definition: shopwindow.cpp:608
bool dropItemInv(InputEvent &event)
Definition: actions.cpp:39
bool screenshot(InputEvent &event)
Definition: actions.cpp:50
WhoIsOnline * whoIsOnline
Definition: whoisonline.cpp:78
bool serverIgnoreAll(InputEvent &event)
Definition: actions.cpp:79
Being * findMostDamagedPlayer(const int maxTileDist) const
const bool TryRemoveColors_true
#define impHandler0(name)
Definition: actiondef.h:33
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:110
IPC * ipc
Definition: ipc.cpp:36
bool trade(InputEvent &event)
Definition: actions.cpp:70
uint16_t ItemColor
Definition: itemcolor.h:29
int getIntValue(const std::string &key) const
QuitDialog * quitDialog
Definition: game.cpp:156
bool dirs(InputEvent &event)
Definition: actions.cpp:76
bool isPopupVisible() const
Definition: popup.h:173
const ItemColor ItemColor_one
Definition: itemcolor.h:29
void dropFirst() const
const bool AllowSort_true
Definition: allowsort.h:29
std::vector< std::string > StringVect
Definition: stringvector.h:28
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:24
char ** environ
volatile int fps
Definition: timer.cpp:53
bool targetAttack(InputEvent &event)
Definition: actions.cpp:58
Configuration serverConfig
bool sit(InputEvent &event)
Definition: actions.cpp:49
#define A_NONNULL(...)
Definition: localconsts.h:159
void simulateMouseClick(const int x, const int y, const MouseButtonT button)
Definition: sdlinput.cpp:341
const int SKILL_MIN_ID
Definition: skill.h:24
InventoryWindow * inventoryWindow
bool mercenaryToMaster(InputEvent &event)
Definition: actions.cpp:100
int getStatEffective(const AttributesT id)
Definition: playerinfo.cpp:165
int getWidth() const
Definition: graphics.cpp:642
bool dropItemId(InputEvent &event)
Definition: actions.cpp:38
static void resetModifiers()
bool isActionActive(const InputActionT index) const
time_t start_time
Definition: client.cpp:133
bool uptime(InputEvent &event)
Definition: actions.cpp:77
ShopItem * addItem(const int id, const ItemTypeT type, const ItemColor color, const int amount, const int price)
Definition: buydialog.cpp:456
bool homunculusToMaster(InputEvent &event)
Definition: actions.cpp:101
bool pickUpItems(int pickUpType)
bool dump(InputEvent &event)
Definition: actions.cpp:78
std::map< std::string, Resource * > Resources
Definition: resourcetypes.h:35
bool createItems(InputEvent &event)
Definition: actions.cpp:94
Logger * logger
Definition: logger.cpp:88
bool uploadLog(InputEvent &event)
Definition: actions.cpp:98
std::string localDataDir
Definition: settings.h:110
bool dumpMemoryUsage(InputEvent &event)
Definition: actions.cpp:117
bool ok(InputEvent &event)
Definition: actions.cpp:33
void setFile(const std::string &filename, const int64_t adler32)
Definition: download.cpp:165
virtual void moveToMaster() const =0
virtual void moveToMaster() const =0
Settings settings
Definition: settings.cpp:31
const int SPELL_MIN_ID
Definition: spells.h:27
Net::ServerFeatures * serverFeatures
Definition: net.cpp:97
std::string screenshotDir
Definition: settings.h:113
bool getBoolValue(const std::string &key) const
void useEquipItem(const Item *const item, const int16_t useType, const Sfx sfx)
Definition: playerinfo.cpp:259
virtual void requestSellList(const std::string &nick) const =0
void attack2(Being *const target, const bool keep, const bool dontChangeEquipment)
bool useItem(InputEvent &event)
Definition: actions.cpp:103
std::string logFileName
Definition: settings.h:120
void printAllMemory(ChatTab *const tab)
InventoryWindow * storageWindow
virtual int getPixelY() const
Definition: actor.h:92
#define CAST_S32
Definition: cast.h:29
bool AutoTarget
Definition: autotarget.h:29
bool mercenaryFire(InputEvent &event)
Definition: actions.cpp:99
bool uploadConfig(InputEvent &event)
Definition: actions.cpp:96
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
bool parse2Int(const std::string &args, int &x, int &y)
int getTabIndex() const
void sort()
Definition: buydialog.cpp:471
bool tradeAdd(InputEvent &event)
Definition: actions.cpp:106
virtual void open(const Being *const being) const =0
bool uploadServerConfig(InputEvent &event)
Definition: actions.cpp:97
bool unprotectItem(InputEvent &event)
Definition: actions.cpp:109
const bool Visible_false
Definition: visible.h:29
bool priceSave(InputEvent &event)
Definition: actions.cpp:72
int getQuantity() const
Definition: item.h:104
#define fromBool(val, name)
Definition: booldefines.h:48
bool info(InputEvent &event)
Definition: commands.cpp:56
bool safeVideoMode(InputEvent &event)
Definition: actions.cpp:60
bool disconnect(InputEvent &event)
Definition: actions.cpp:74
#define SMALL_VERSION
Definition: main.h:43
bool dumpTests(InputEvent &event)
Definition: actions.cpp:87
bool untarget(InputEvent &event)
Definition: actions.cpp:56
uint32_t data
LocalPlayer * localPlayer
PopupMenu * popupMenu
Definition: popupmenu.cpp:102
bool stopAttack(InputEvent &event)
Definition: actions.cpp:55
int getHeight() const
Definition: graphics.cpp:647
bool emote(InputEvent &event)
Definition: actions.cpp:30
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
void protectItem(const int id)
Definition: playerinfo.cpp:499
bool useItemInv(InputEvent &event)
Definition: actions.cpp:104
bool resetGameModifiers(InputEvent &event)
Definition: actions.cpp:114
const bool IgnoreRecord_false
Definition: ignorerecord.h:29
size_t size() const
Definition: actormanager.h:380
RenderType getOpenGL() const
Definition: graphics.h:307
Being * findBeing(const BeingId id) const
bool seen(InputEvent &event)
Definition: actions.cpp:116
Resources::iterator ResourceIterator
Definition: resourcetypes.h:36
Definition: item.h:48
Inventory * getStorageInventory()
Definition: playerinfo.cpp:197
Net::BeingHandler * beingHandler
Definition: net.cpp:95
bool dumpMods(InputEvent &event)
Definition: actions.cpp:90
void stopAttack(const bool keepAttack)
bool buy(InputEvent &event)
Definition: actions.cpp:52
Net::MercenaryHandler * mercenaryHandler
Definition: net.cpp:112
static Being * findBeing(const std::string &name, const bool npc)
Definition: actions.cpp:211
Graphics * mainGraphics
Definition: graphics.cpp:108
static void uploadFile(const std::string &str, const std::string &fileName, const std::string &addStr, ChatTab *const tab)
Definition: actions.cpp:193
const std::set< std::string > & getOnlineNicks() const
Definition: whoisonline.h:85
void dropItems(const int cnt)
bool isWindowVisible() const
Definition: window.h:483
static Item * getItemByInvIndex(const int index, const InventoryTypeT invType)
Definition: actions.cpp:256
ActorTypeT getType() const
Definition: being.h:115
unsigned short getPort() const
Definition: ipc.h:52
void magicAttack() const
ShortcutWindow * itemShortcutWindow
const unsigned int SHORTCUT_TABS
Definition: itemshortcut.h:27
bool cleanFonts(InputEvent &event)
Definition: actions.cpp:69
static void closePopupMenu()
bool dropItemInvAll(InputEvent &event)
Definition: actions.cpp:41
bool shortcut(InputEvent &event)
Definition: actions.cpp:34
void moveItemToCraft(const int craftSlot)
const bool ShowCenter_false
Definition: showcenter.h:29
bool cacheInfo(InputEvent &event)
Definition: actions.cpp:73
DownloadStatus ::T DownloadStatusT
bool sell(InputEvent &event)
Definition: actions.cpp:53
#define PRAGMA48(str)
Definition: localconsts.h:190
bool attackHuman(InputEvent &event)
Definition: actions.cpp:59
volatile time_t cur_time
Definition: timer.cpp:57
void untarget()
static uint8_t getMouseState(int &x, int &y)
Definition: gui.cpp:1169
virtual void createItems(const int id, const ItemColor color, const int amount) const =0
int getPixelX() const
Definition: actor.h:86
ItemShortcut * itemShortcut[SHORTCUT_TABS]
bool splitParameters(StringVect &tokens, std::string text, const std::string &separator, const char quote)
Definition: parameters.cpp:102
const std::string & getName() const
Definition: being.h:231
bool start()
Definition: download.cpp:187
bool mouseClick(InputEvent &event)
Definition: actions.cpp:32
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:85
bool dumpEnvironment(InputEvent &event)
Definition: actions.cpp:86
bool protectItem(InputEvent &event)
Definition: actions.cpp:108
bool createItem(InputEvent &event)
Definition: actions.cpp:95
bool updateSit() const
Net::AdminHandler * adminHandler
Definition: net.cpp:80
std::string tempDir
Definition: settings.h:111
bool outfit(InputEvent &event)
Definition: actions.cpp:31
bool getDoubleBuffer() const
Definition: graphics.h:304
void tradeItem(const Item *const item, const int quantity, const bool check) const
virtual void requestBuyList(const std::string &nick) const =0
Net::BuyingStoreHandler * buyingStoreHandler
Definition: net.cpp:102
bool showKeyboard(InputEvent &event)
Definition: actions.cpp:62
ShopWindow * shopWindow
Definition: shopwindow.cpp:100
ServerTypeT getNetworkType()
Definition: net.cpp:182
bool canTalk() const
Definition: being.h:666
EmoteShortcut * emoteShortcut
bool isItemProtected(const int id)
Definition: playerinfo.cpp:511
ChatTab * debugChatTab
Definition: chattab.cpp:62
SkillDialog * skillDialog
Definition: skilldialog.cpp:65
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string getValue(const std::string &key, const std::string &deflt) const
bool dropItem0(InputEvent &event)
Definition: actions.cpp:36
int getId() const
Definition: item.h:80
#define A_UNUSED
Definition: localconsts.h:151
virtual void setVisible(Visible visible)
Definition: window.cpp:773
bool setFullScreen(const bool fs)
void wearOutfit(const int outfit, const bool unwearEmpty, const bool select)
bool craftKey(InputEvent &event)
Definition: actions.cpp:113
#define PACKAGE_OS
Definition: main.h:129
#define CREATEWIDGET(type,...)
Definition: createwidget.h:28
bool heal(InputEvent &event)
Definition: actions.cpp:42
Net::ChatHandler * chatHandler
Definition: net.cpp:82
std::map< int, ItemInfo * > ItemInfos
Definition: itemdb.h:62
Net::HomunculusHandler * homunculusHandler
Definition: net.cpp:107
Net::TradeHandler * tradeHandler
Definition: net.cpp:94
GLuint getGLImage() const
Definition: image.h:177
bool magicAttack(InputEvent &event)
Definition: actions.cpp:46
int getSkillLevel(const int id)
Definition: playerinfo.cpp:118
bool storageToInv(InputEvent &event)
Definition: actions.cpp:107
int getWidth(const std::string &text) const
Definition: font.cpp:333
Net::BuySellHandler * buySellHandler
Definition: net.cpp:96
static void start()
Definition: ipc.cpp:162
void itenplz() const
int check_leaks()
Definition: debug_new.cpp:769
bool attack(InputEvent &event)
Definition: actions.cpp:57
bool kick(InputEvent &event)
Definition: actions.cpp:110
void setTarget(Being *const target)
std::string tradePartnerName
Definition: popupmenu.cpp:100
EmoteTypeT emoteType
Definition: settings.h:149
static bool isPopupMenuVisible()
bool who(InputEvent &event)
Definition: actions.cpp:67
void useItem(const int itemId) const
Definition: image.h:61
bool dumpGL(InputEvent &event)
Definition: actions.cpp:89
bool itenplz(InputEvent &event)
Definition: actions.cpp:44
bool dropItem(InputEvent &event)
Definition: actions.cpp:37
void copyFromEquiped()
bool existsLocal(const std::string &path)
Definition: files.cpp:208
static const int mapTileSize
Definition: map.h:26
bool error(InputEvent &event) __attribute__((noreturn))
Definition: actions.cpp:81
static Game * instance()
Definition: game.h:81
Definition: color.h:74
std::string getGLVersion() const
std::string addStr
bool toggleSit() const
bool talk(InputEvent &event)
Definition: actions.cpp:54
std::string configDir
Definition: settings.h:109
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
Net::VendingHandler * vendingHandler
Definition: net.cpp:115
int getTileX() const
Definition: being.h:167
bool dumpOGL(InputEvent &event)
Definition: actions.cpp:88
Net::NpcHandler * npcHandler
Definition: net.cpp:89
#define CAST_S16
Definition: cast.h:27
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
InputManager inputManager
void select()
Definition: popupmenu.cpp:3630
void undressItemById(const int id)
Definition: being.cpp:4705
virtual void request(const Being *const being) const
Definition: tradehandler.h:45
void useEmotePlayer(const size_t index) const
bool serverUnIgnoreAll(InputEvent &event)
Definition: actions.cpp:80
void log(const char *const log_text,...)
Definition: logger.cpp:264
void action(const ActionEvent &event)
Net::Download * upload
HelpWindow * helpWindow
Definition: helpwindow.cpp:53
Item * getItem(const int index) const
Definition: inventory.cpp:82
bool homunculusFeed(InputEvent &event)
Definition: actions.cpp:102
void heal(const Being *const target) const
#define PRAGMA6(str)
Definition: localconsts.h:183
float guiAlpha
Definition: settings.h:129
Net::GameHandler * gameHandler
Definition: net.cpp:87
std::string text
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100
Being * findNearestLivingBeing(const int x, const int y, int maxTileDist, const ActorTypeT type, const Being *const excluded) const
void unprotectItem(const int id)
Definition: playerinfo.cpp:505
bool clearDrop(InputEvent &event)
Definition: actions.cpp:111
Definition: being.h:93
bool getHWAccel() const
Definition: graphics.h:301
bool dumpGraphics(InputEvent &event)
Definition: actions.cpp:85
SDLInput * guiInput
Definition: sdlinput.cpp:96
virtual void sell(const BeingId beingId) const =0
GraphicsManager graphicsManager
int getBpp() const
Definition: graphics.h:295
virtual void ignoreAll() const =0
bool barToChat(InputEvent &event)
Definition: actions.cpp:115
bool undress(InputEvent &event)
Definition: actions.cpp:75
bool getFullScreen() const
Definition: graphics.h:298
void talkTo() const
Definition: being.cpp:3675
bool setEmoteType(InputEvent &event)
Definition: actions.cpp:118
const std::string args
Definition: inputevent.h:69
virtual void open(const Being *const being) const =0
virtual void disconnect2() const =0
#define impHandler(name)
Definition: actiondef.h:32
void addInputText(const std::string &text, const bool space)
const ItemDB::ItemInfos & getItemInfos()
Definition: itemdb.cpp:829
unsigned int targetingType
Definition: settings.h:144
virtual void who() const =0
ActorManager * actorManager
void dropItem(const Item *const item, const int amount, const Sfx sfx)
Definition: playerinfo.cpp:351
std::string timeDiffToString(int timeDiff)
Being * getTarget() const
bool ipcToggle(InputEvent &event)
Definition: actions.cpp:65
bool where(InputEvent &event)
Definition: actions.cpp:66
bool pickUp(FloorItem *const item)
virtual void fire() const =0
#define CREATEWIDGETR0(type)
Definition: createwidget.h:38