ManaPlus
actions.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2017 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/delete2.h"
106 #include "utils/foreach.h"
107 #include "utils/gettext.h"
108 #include "utils/parameters.h"
109 #include "utils/timer.h"
110 
111 #ifdef TMWA_SUPPORT
112 #include "net/playerhandler.h"
113 
114 #include "utils/mathutils.h"
115 #endif // TMWA_SUPPORT
116 
117 PRAGMA48(GCC diagnostic push)
118 PRAGMA48(GCC diagnostic ignored "-Wshadow")
119 #ifdef ANDROID
120 #ifndef USE_SDL2
121 #include <SDL_screenkeyboard.h>
122 #endif // USE_OPENGL
123 #endif // ANDROID
124 PRAGMA48(GCC diagnostic pop)
125 
126 #include <sstream>
127 
128 #include "debug.h"
129 
130 extern std::string tradePartnerName;
131 extern QuitDialog *quitDialog;
132 extern time_t start_time;
133 extern char **environ;
134 
135 namespace Actions
136 {
137 
138 static int uploadUpdate(void *ptr,
139  const DownloadStatusT status,
140  size_t total A_UNUSED,
141  const size_t remaining A_UNUSED) A_NONNULL(1);
142 
143 static int uploadUpdate(void *ptr,
144  const DownloadStatusT status,
145  size_t total A_UNUSED,
146  const size_t remaining A_UNUSED)
147 {
148  if (status == DownloadStatus::Idle || status == DownloadStatus::Starting)
149  return 0;
150 
151  UploadChatInfo *const info = reinterpret_cast<UploadChatInfo*>(ptr);
152  if (info == nullptr)
153  return 0;
154 
155  if (status == DownloadStatus::Complete)
156  {
157  std::string str = Net::Download::getUploadResponse();
158  const size_t sz = str.size();
159  if (sz > 0)
160  {
161  if (str[sz - 1] == '\n')
162  str = str.substr(0, sz - 1);
163  str.append(info->addStr);
164  ChatTab *const tab = info->tab;
165  if (chatWindow != nullptr &&
166  (tab == nullptr || chatWindow->isTabPresent(tab)))
167  {
168  str = strprintf("%s [@@%s |%[email protected]@]",
169  info->text.c_str(), str.c_str(), str.c_str());
170  outStringNormal(tab, str, str);
171  }
172  else
173  {
175  // TRANSLATORS: file uploaded message
176  _("File uploaded"),
177  str,
178  // TRANSLATORS: ok dialog button
179  _("OK"),
181  Modal_true,
183  nullptr,
184  260);
185  }
186  }
187  }
188  delete2(info->upload);
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://sprunge.us",
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);
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  {
348  outfitWindow->wearOutfit(num);
349  if (Game::instance() != nullptr)
351  return true;
352  }
353  }
355  {
356  const int num = event.action - InputAction::OUTFIT_1;
357  if ((outfitWindow != nullptr) && num >= 0)
358  {
359  outfitWindow->copyOutfit(num);
360  if (Game::instance() != nullptr)
362  return true;
363  }
364  }
365 
366  return false;
367 }
368 
370 {
371  if ((guiInput == nullptr) || (gui == nullptr))
372  return false;
373 
374  int mouseX, mouseY;
375  Gui::getMouseState(mouseX, mouseY);
377  return true;
378 }
379 
381 {
382  // Close the Browser if opened
383  if ((helpWindow != nullptr) && helpWindow->isWindowVisible())
384  {
386  return true;
387  }
388  // Close the config window, cancelling changes if opened
389  else if ((setupWindow != nullptr) && setupWindow->isWindowVisible())
390  {
391  setupWindow->action(ActionEvent(nullptr, "cancel"));
392  return true;
393  }
394  else if (NpcDialog *const dialog = NpcDialog::getActive())
395  {
396  dialog->action(ActionEvent(nullptr, "ok"));
397  return true;
398  }
399  else if (popupMenu->isPopupVisible())
400  {
401  popupMenu->select();
402  }
403  return false;
404 }
405 
407 {
408  if (itemShortcutWindow != nullptr)
409  {
410  const int num = itemShortcutWindow->getTabIndex();
411  if (num >= 0 && num < CAST_S32(SHORTCUT_TABS))
412  {
413  if (itemShortcut[num] != nullptr)
414  {
415  itemShortcut[num]->useItem(event.action
417  }
418  }
419  return true;
420  }
421  return false;
422 }
423 
425 {
426  if (Game::instance() == nullptr)
427  return false;
429  {
431  return true;
432  }
433  else if (quitDialog == nullptr)
434  {
435  CREATEWIDGETV(quitDialog, QuitDialog,
436  &quitDialog);
437  quitDialog->requestMoveToTop();
438  return true;
439  }
440  return false;
441 }
442 
444 {
445  if (dropShortcut != nullptr)
446  {
448  return true;
449  }
450  return false;
451 }
452 
454 {
455  if (dropShortcut != nullptr)
456  {
458  return true;
459  }
460  return false;
461 }
462 
464 {
465  const Inventory *const inv = PlayerInfo::getInventory();
466  if (inv == nullptr)
467  return false;
468 
469  // +++ ignoring item color for now
470  Item *const item = inv->findItem(atoi(event.args.c_str()),
471  ItemColor_one);
472 
473  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
474  {
476  inventoryWindow, item);
477  }
478  return true;
479 }
480 
482 {
483  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
485  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
486  {
488  inventoryWindow, item);
489  }
490  return true;
491 }
492 
494 {
495  const Inventory *const inv = PlayerInfo::getInventory();
496  if (inv == nullptr)
497  return false;
498 
499  // +++ ignoring item color for now
500  Item *const item = inv->findItem(atoi(event.args.c_str()),
501  ItemColor_one);
502 
503  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
504  PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
505  return true;
506 }
507 
509 {
510  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
512  if ((item != nullptr) && !PlayerInfo::isItemProtected(item->getId()))
513  PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
514  return true;
515 }
516 
517 #ifdef TMWA_SUPPORT
519 {
521  return false;
522  if (actorManager != nullptr &&
523  localPlayer != nullptr)
524  {
525  std::string args = event.args;
526 
527  if (!args.empty())
528  {
529  const Being *being = nullptr;
530  if (args[0] == ':')
531  {
532  being = actorManager->findBeing(fromInt(atoi(
533  args.substr(1).c_str()), BeingId));
534  if (being != nullptr && being->getType() == ActorType::Monster)
535  being = nullptr;
536  }
537  else
538  {
540  }
541  if (being != nullptr)
542  actorManager->heal(being);
543  }
544  else
545  {
546  Being *target = localPlayer->getTarget();
548  {
549  if (target == nullptr ||
550  target->getType() != ActorType::Player)
551  {
554  }
555  }
556  else
557  {
558  if (target == nullptr)
559  target = localPlayer;
560  }
561  actorManager->heal(target);
562  }
563 
564  if (Game::instance() != nullptr)
566  return true;
567  }
568  return false;
569 }
570 #else // TMWA_SUPPORT
571 
573 {
574  return false;
575 }
576 #endif // TMWA_SUPPORT
577 
579 {
580 #ifdef TMWA_SUPPORT
582  return false;
583  if (actorManager != nullptr)
584  {
586  int maxHealingRadius;
587 
588  // magic levels < 2
589  if (PlayerInfo::getSkillLevel(340) < 2
590  || PlayerInfo::getSkillLevel(341) < 2)
591  {
592  maxHealingRadius = matk / 100 + 1;
593  }
594  else
595  {
596  maxHealingRadius = (12 * fastSqrtInt(matk) + matk) / 100 + 1;
597  }
598 
599  Being *target = actorManager->findMostDamagedPlayer(maxHealingRadius);
600  if (target != nullptr)
601  actorManager->heal(target);
602 
603  if (Game::instance() != nullptr)
605  return true;
606  }
607 #endif // TMWA_SUPPORT
608 
609  return false;
610 }
611 
613 {
614 #ifdef TMWA_SUPPORT
616  return false;
617  if (actorManager != nullptr)
618  {
619  if (playerHandler != nullptr &&
622  {
624  }
625  return true;
626  }
627 #endif // TMWA_SUPPORT
628 
629  return false;
630 }
631 
633 {
634  if (localPlayer != nullptr)
635  {
636  localPlayer->setHome();
637  return true;
638  }
639  return false;
640 }
641 
643 {
644 #ifdef TMWA_SUPPORT
646  return false;
647  if (localPlayer != nullptr)
648  {
650  return true;
651  }
652 #endif // TMWA_SUPPORT
653 
654  return false;
655 }
656 
658 {
659  if (outfitWindow != nullptr)
660  {
662  return true;
663  }
664  return false;
665 }
666 
668 {
669  if (localPlayer == nullptr)
670  return false;
671 
672  const std::string args = event.args;
673  if (args.empty())
674  {
676  }
677  else
678  {
680  atoi(args.c_str()), BeingId));
681  if (item != nullptr)
682  localPlayer->pickUp(item);
683  }
684  return true;
685 }
686 
687 static void doSit()
688 {
691  else
693 }
694 
696 {
697  if (localPlayer != nullptr)
698  {
699  doSit();
700  return true;
701  }
702  return false;
703 }
704 
706 {
707  Game::createScreenshot(event.args);
708  return true;
709 }
710 
712 {
713  return true;
714 }
715 
717 {
718  if (serverFeatures == nullptr)
719  return false;
720  const std::string args = event.args;
721  Being *being = findBeing(args, false);
722  if ((being == nullptr) && Net::getNetworkType() == ServerType::TMWATHENA)
723  {
724  if (whoIsOnline != nullptr)
725  {
726  const std::set<std::string> &players =
728  if (players.find(args) != players.end())
729  {
730  if (buySellHandler != nullptr)
732  return true;
733  }
734  }
735  return false;
736  }
737 
738  if (being == nullptr)
739  being = findBeing(args, true);
740 
741  if (being == nullptr)
742  return false;
743 
744  if (being->getType() == ActorType::Npc)
745  {
746  if (npcHandler != nullptr)
747  npcHandler->buy(being);
748  return true;
749  }
750  else if (being->getType() == ActorType::Player)
751  {
752  if (vendingHandler != nullptr &&
754  {
755  vendingHandler->open(being);
756  }
757  else if (buySellHandler != nullptr)
758  {
760  }
761  return true;
762  }
763  return false;
764 }
765 
767 {
768  if (serverFeatures == nullptr)
769  return false;
770 
771  const std::string args = event.args;
772  Being *being = findBeing(args, false);
773  if (being == nullptr &&
775  {
776  if (whoIsOnline != nullptr)
777  {
778  const std::set<std::string> &players =
780  if (players.find(args) != players.end())
781  {
782  if (buySellHandler != nullptr)
784  return true;
785  }
786  }
787  return false;
788  }
789 
790  if (being == nullptr)
791  being = findBeing(args, true);
792 
793  if (being == nullptr)
794  return false;
795 
796  if (being->getType() == ActorType::Npc)
797  {
798  if (npcHandler != nullptr)
799  npcHandler->sell(being->getId());
800  return true;
801  }
802  else if (being->getType() == ActorType::Player)
803  {
804  if ((buyingStoreHandler != nullptr) &&
806  {
807  buyingStoreHandler->open(being);
808  }
809  else if (buySellHandler != nullptr)
810  {
812  }
813  return true;
814  }
815  return false;
816 }
817 
819 {
820  Being *being = findBeing(event.args, true);
821  if (being == nullptr)
822  return false;
823 
824  if (being->canTalk())
825  {
826  being->talkTo();
827  }
828  else if (being->getType() == ActorType::Player)
829  {
831  being->getName());
832  }
833  return true;
834 }
835 
837 {
838  if (localPlayer != nullptr)
839  {
841  // not consume if target attack key pressed
843  return false;
844  return true;
845  }
846  return false;
847 }
848 
850 {
851  if (localPlayer != nullptr)
852  {
854  return true;
855  }
856  return false;
857 }
858 
860 {
861  if ((localPlayer == nullptr) || (actorManager == nullptr))
862  return false;
863 
864  Being *target = nullptr;
865  std::string args = event.args;
866  if (!args.empty())
867  {
868  if (args[0] != ':')
869  {
870  target = actorManager->findNearestByName(args);
871  }
872  else
873  {
874  target = actorManager->findBeing(fromInt(atoi(
875  args.substr(1).c_str()), BeingId));
876  if (target != nullptr &&
877  target->getType() != ActorType::Monster)
878  {
879  target = nullptr;
880  }
881  }
882  }
883  if (target == nullptr)
884  target = localPlayer->getTarget();
885  else
886  localPlayer->setTarget(target);
887  if (target != nullptr)
888  localPlayer->attack(target, true);
889  return true;
890 }
891 
893 {
894  if ((localPlayer != nullptr) && (actorManager != nullptr))
895  {
896  Being *target = nullptr;
897  std::string args = event.args;
898  const bool newTarget = !inputManager.isActionActive(
900 
901  if (!args.empty())
902  {
903  if (args[0] != ':')
904  {
905  target = actorManager->findNearestByName(args);
906  }
907  else
908  {
909  target = actorManager->findBeing(fromInt(atoi(
910  args.substr(1).c_str()), BeingId));
911  if (target != nullptr &&
912  target->getType() != ActorType::Monster)
913  {
914  target = nullptr;
915  }
916  }
917  }
918 
919  if ((target == nullptr) && (settings.targetingType == 0u))
920  target = localPlayer->getTarget();
921 
922  if (target == nullptr)
923  {
926  }
927 
928  localPlayer->attack2(target, newTarget);
929  return true;
930  }
931  return false;
932 }
933 
935 {
936  if ((actorManager == nullptr) || (localPlayer == nullptr))
937  return false;
938 
939  Being *const target = actorManager->findNearestPvpPlayer();
940  if (target != nullptr)
941  {
942  localPlayer->setTarget(target);
943  localPlayer->attack2(target, true);
944  }
945  return true;
946 }
947 
949 {
951 
952  return true;
953 }
954 
956 {
957  if (localPlayer != nullptr)
958  {
960  // not consume if target attack key pressed
962  return false;
963  if (localPlayer->getTarget() == nullptr)
964  {
965  doSit();
966  return true;
967  }
968  return true;
969  }
970  return false;
971 }
972 
974 {
975 #ifdef ANDROID
976 #ifdef USE_SDL2
977  if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE)
978  SDL_StopTextInput();
979  else
980  SDL_StartTextInput();
981 #else // USE_SDL2
982 
983  SDL_ANDROID_ToggleScreenKeyboardTextInput(nullptr);
984 #endif // USE_SDL2
985 
986  return true;
987 #else // ANDROID
988 
989  return false;
990 #endif // ANDROID
991 }
992 
994 {
995  if (popupMenu != nullptr)
996  {
998  return true;
999  }
1000  return false;
1001 }
1002 
1004 {
1005  const Being *const being = localPlayer->getTarget();
1006  if ((being != nullptr) && being->getType() == ActorType::Player)
1007  {
1008  if (tradeHandler != nullptr)
1009  tradeHandler->request(being);
1010  tradePartnerName = being->getName();
1011  if (tradeWindow != nullptr)
1012  tradeWindow->clear();
1013  return true;
1014  }
1015  return false;
1016 }
1017 
1019 {
1020  if (ipc != nullptr)
1021  {
1022  IPC::stop();
1023  if (ipc == nullptr)
1024  {
1025  debugChatTab->chatLog("IPC service stopped.",
1027  }
1028  else
1029  {
1030  debugChatTab->chatLog("Unable to stop IPC service.",
1032  }
1033  }
1034  else
1035  {
1036  IPC::start();
1037  if (ipc != nullptr)
1038  {
1040  strprintf("IPC service available on port %d", ipc->getPort()),
1042  }
1043  else
1044  {
1045  debugChatTab->chatLog("Unable to start IPC service",
1047  }
1048  }
1049  return true;
1050 }
1051 
1053 {
1054  ChatTab *const tab = event.tab != nullptr ? event.tab : debugChatTab;
1055  if (tab == nullptr)
1056  return false;
1057  std::ostringstream where;
1058  where << Game::instance()->getCurrentMapName() << ", coordinates: "
1059  << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize)
1060  << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize);
1061  tab->chatLog(where.str(), ChatMsgType::BY_SERVER);
1062  return true;
1063 }
1064 
1066 {
1067  if (chatHandler != nullptr)
1068  chatHandler->who();
1069  return true;
1070 }
1071 
1073 {
1075 
1076  if (debugChatTab != nullptr)
1077  {
1078  // TRANSLATORS: clear graphics command message
1079  debugChatTab->chatLog(_("Cache cleared"),
1081  }
1082  return true;
1083 }
1084 
1086 {
1087  if (gui != nullptr)
1088  gui->clearFonts();
1089  if (debugChatTab != nullptr)
1090  {
1091  // TRANSLATORS: clear fonts cache message
1092  debugChatTab->chatLog(_("Cache cleared"),
1094  }
1095  return true;
1096 }
1097 
1099 {
1100  if (actorManager == nullptr)
1101  return false;
1102 
1103  const Being *being = actorManager->findBeingByName(
1104  event.args, ActorType::Player);
1105  if (being == nullptr)
1106  being = localPlayer->getTarget();
1107  if (being != nullptr)
1108  {
1109  if (tradeHandler != nullptr)
1110  tradeHandler->request(being);
1111  tradePartnerName = being->getName();
1112  if (tradeWindow != nullptr)
1113  tradeWindow->clear();
1114  }
1115  return true;
1116 }
1117 
1119 {
1120  if (shopWindow != nullptr)
1121  {
1122  shopWindow->loadList();
1123  return true;
1124  }
1125  return false;
1126 }
1127 
1129 {
1130  if (shopWindow != nullptr)
1131  {
1132  shopWindow->saveList();
1133  return true;
1134  }
1135  return false;
1136 }
1137 
1139 {
1140  if ((chatWindow == nullptr) || (debugChatTab == nullptr))
1141  return false;
1142 
1143 /*
1144  Font *const font = chatWindow->getFont();
1145  if (!font)
1146  return;
1147 
1148  const TextChunkList *const cache = font->getCache();
1149  if (!cache)
1150  return;
1151 
1152  unsigned int all = 0;
1153  // TRANSLATORS: chat fonts message
1154  debugChatTab->chatLog(_("font cache size"), ChatMsgType::BY_SERVER);
1155  std::string str;
1156  for (int f = 0; f < 256; f ++)
1157  {
1158  if (!cache[f].size)
1159  {
1160  const unsigned int sz = CAST_S32(cache[f].size);
1161  all += sz;
1162  str.append(strprintf("%d: %u, ", f, sz));
1163  }
1164  }
1165  debugChatTab->chatLog(str, ChatMsgType::BY_SERVER);
1166  // TRANSLATORS: chat fonts message
1167  debugChatTab->chatLog(strprintf("%s %d", _("Cache size:"), all),
1168  ChatMsgType::BY_SERVER);
1169 #ifdef DEBUG_FONT_COUNTERS
1170  debugChatTab->chatLog("", ChatMsgType::BY_SERVER);
1171  debugChatTab->chatLog(strprintf("%s %d",
1172  // TRANSLATORS: chat fonts message
1173  _("Created:"), font->getCreateCounter()),
1174  ChatMsgType::BY_SERVER);
1175  debugChatTab->chatLog(strprintf("%s %d",
1176  // TRANSLATORS: chat fonts message
1177  _("Deleted:"), font->getDeleteCounter()),
1178  ChatMsgType::BY_SERVER);
1179 #endif
1180 */
1181  return true;
1182 }
1183 
1185 {
1186  if (gameHandler != nullptr)
1188  return true;
1189 }
1190 
1192 {
1193  if ((actorManager == nullptr) || (localPlayer == nullptr))
1194  return false;
1195 
1196  const std::string args = event.args;
1197  StringVect pars;
1198  if (!splitParameters(pars, args, " ,", '\"'))
1199  return false;
1200  Being *target = nullptr;
1201  const size_t sz = pars.size();
1202  if (sz == 0)
1203  {
1204  target = localPlayer->getTarget();
1205  }
1206  else
1207  {
1208  if (pars[0][0] == ':')
1209  {
1210  target = actorManager->findBeing(fromInt(atoi(
1211  pars[0].substr(1).c_str()), BeingId));
1212  if ((target != nullptr) && target->getType() == ActorType::Monster)
1213  target = nullptr;
1214  }
1215  else
1216  {
1217  target = actorManager->findNearestByName(args);
1218  }
1219  }
1220 
1221  if (sz == 2)
1222  {
1223  const int itemId = atoi(pars[1].c_str());
1224  if (target != nullptr)
1225  target->undressItemById(itemId);
1226  }
1227  else
1228  {
1229  if ((target != nullptr) && (beingHandler != nullptr))
1230  beingHandler->undress(target);
1231  }
1232 
1233  return true;
1234 }
1235 
1237 {
1238  if (debugChatTab == nullptr)
1239  return false;
1240 
1241  debugChatTab->chatLog("config directory: "
1242  + settings.configDir,
1244  debugChatTab->chatLog("logs directory: "
1247  debugChatTab->chatLog("screenshots directory: "
1250  debugChatTab->chatLog("temp directory: "
1251  + settings.tempDir,
1253  return true;
1254 }
1255 
1257 {
1258  if (debugChatTab == nullptr)
1259  return false;
1260 
1261  if (cur_time < start_time)
1262  {
1263  // TRANSLATORS: uptime command
1264  debugChatTab->chatLog(strprintf(_("Client uptime: %s"), "unknown"),
1266  }
1267  else
1268  {
1269  // TRANSLATORS: uptime command
1270  debugChatTab->chatLog(strprintf(_("Client uptime: %s"),
1271  timeDiffToString(CAST_S32(cur_time - start_time)).c_str()),
1273  }
1274  return true;
1275 }
1276 
1277 #ifdef DEBUG_DUMP_LEAKS1
1278 static void showRes(std::string str, ResourceManager::Resources *res)
1279 {
1280  if (!res)
1281  return;
1282 
1283  str.append(toString(res->size()));
1284  if (debugChatTab)
1286  logger->log(str);
1287  ResourceManager::ResourceIterator iter = res->begin();
1288  const ResourceManager::ResourceIterator iter_end = res->end();
1289  while (iter != iter_end)
1290  {
1291  if (iter->second && iter->second->mRefCount)
1292  {
1293  char type = ' ';
1294  char isNew = 'N';
1295  if (iter->second->getDumped())
1296  isNew = 'O';
1297  else
1298  iter->second->setDumped(true);
1299 
1300  SubImage *const subImage = dynamic_cast<SubImage *>(
1301  iter->second);
1302  Image *const image = dynamic_cast<Image *>(iter->second);
1303  int id = 0;
1304  if (subImage)
1305  type = 'S';
1306  else if (image)
1307  type = 'I';
1308  if (image)
1309  id = image->getGLImage();
1310  logger->log("Resource %c%c: %s (%d) id=%d", type,
1311  isNew, iter->second->getIdPath().c_str(),
1312  iter->second->mRefCount, id);
1313  }
1314  ++ iter;
1315  }
1316 }
1317 
1319 {
1320  if (!debugChatTab)
1321  return false;
1322 
1323  if (!event.args.empty())
1324  {
1325  ResourceManager::Resources *res = ResourceManager::getResources();
1326  // TRANSLATORS: dump command
1327  showRes(_("Resource images:"), res);
1328  res = ResourceManager::getOrphanedResources();
1329  // TRANSLATORS: dump command
1330  showRes(_("Orphaned resource images:"), res);
1331  }
1332  else
1333  {
1334  ResourceManager::Resources *res = ResourceManager::getResources();
1335  // TRANSLATORS: dump command
1336  debugChatTab->chatLog(_("Resource images:") + toString(res->size()),
1338  res = ResourceManager::getOrphanedResources();
1339  // TRANSLATORS: dump command
1340  debugChatTab->chatLog(_("Orphaned resource images:")
1341  + toString(res->size()),
1343  }
1344  return true;
1345 }
1346 
1347 #elif defined ENABLE_MEM_DEBUG
1349 {
1351  return true;
1352 }
1353 #else // DEBUG_DUMP_LEAKS1
1354 
1356 {
1357  return true;
1358 }
1359 #endif // DEBUG_DUMP_LEAKS1
1360 
1362 {
1363  if (chatHandler != nullptr)
1365  return true;
1366 }
1367 
1369 {
1370  if (chatHandler != nullptr)
1372  return true;
1373 }
1374 
1375 PRAGMA6(GCC diagnostic push)
1376 PRAGMA6(GCC diagnostic ignored "-Wnull-dereference")
1378 {
1379  int *const ptr = nullptr;
1380  *(ptr + 1) = 20;
1381 // logger->log("test %d", *ptr);
1382  exit(1);
1383 }
1384 PRAGMA6(GCC diagnostic pop)
1385 
1387 {
1388  std::string str = strprintf("%s,%s,%dX%dX%d,", PACKAGE_OS, SMALL_VERSION,
1390  mainGraphics->getBpp());
1391 
1392  if (mainGraphics->getFullScreen())
1393  str.append("F");
1394  else
1395  str.append("W");
1396  if (mainGraphics->getHWAccel())
1397  str.append("H");
1398  else
1399  str.append("S");
1400 
1402  str.append("D");
1403  else
1404  str.append("_");
1405 
1406 #if defined USE_OPENGL
1407  str.append(strprintf(",%d", mainGraphics->getOpenGL()));
1408 #else // defined USE_OPENGL
1409 
1410  str.append(",0");
1411 #endif // defined USE_OPENGL
1412 
1413  str.append(strprintf(",%f,", static_cast<double>(settings.guiAlpha)))
1414  .append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
1415  .append(config.getBoolValue("alphaCache") ? "1" : "0")
1416  .append(config.getBoolValue("enableMapReduce") ? "1" : "0")
1417  .append(config.getBoolValue("beingopacity") ? "1" : "0")
1418  .append(",")
1419  .append(config.getBoolValue("enableAlphaFix") ? "1" : "0")
1420  .append(config.getBoolValue("disableAdvBeingCaching") ? "1" : "0")
1421  .append(config.getBoolValue("disableBeingCaching") ? "1" : "0")
1422  .append(config.getBoolValue("particleeffects") ? "1" : "0")
1423  .append(strprintf(",%d-%d", fps, config.getIntValue("fpslimit")));
1424  outStringNormal(event.tab, str, str);
1425  return true;
1426 }
1427 
1429 {
1430  logger->log1("Start environment variables");
1431  for (char **env = environ; *env != nullptr; ++ env)
1432  logger->log1(*env);
1433  logger->log1("End environment variables");
1434  if (debugChatTab != nullptr)
1435  {
1436  // TRANSLATORS: dump environment command
1437  debugChatTab->chatLog(_("Environment variables dumped"),
1439  }
1440  return true;
1441 }
1442 
1444 {
1445  const std::string str = config.getStringValue("testInfo");
1446  outStringNormal(event.tab, str, str);
1447  return true;
1448 }
1449 
1451 {
1452 #if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
1454 #endif // defined(USE_OPENGL) && !defined(ANDROID) &&
1455  // !defined(__native_client__)
1456 
1457  return true;
1458 }
1459 
1460 #ifdef USE_OPENGL
1462 {
1463  std::string str = graphicsManager.getGLVersion();
1464  outStringNormal(event.tab, str, str);
1465  return true;
1466 }
1467 #else // USE_OPENGL
1468 
1470 {
1471  return true;
1472 }
1473 #endif // USE_OPENGL
1474 
1476 {
1477  std::string str = "enabled mods: " + serverConfig.getValue("mods", "");
1478  outStringNormal(event.tab, str, str);
1479  return true;
1480 }
1481 
1482 #if defined USE_OPENGL && defined DEBUG_SDLFONT
1483 impHandler0(testSdlFont)
1484 {
1485  Font *font = new Font("fonts/dejavusans.ttf", 18, TTF_STYLE_NORMAL);
1486  timespec time1;
1487  timespec time2;
1488  NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
1489  STD_VECTOR<std::string> data;
1490  volatile int width = 0;
1491 
1492  for (int f = 0; f < 300; f ++)
1493  data.push_back("test " + toString(f) + "string");
1494  nullGraphics->beginDraw();
1495 
1496  clock_gettime(CLOCK_MONOTONIC, &time1);
1497  Color color(0, 0, 0, 255);
1498 
1499  for (int f = 0; f < 500; f ++)
1500  {
1501  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
1502  {
1503  width += font->getWidth(*it);
1504  font->drawString(nullGraphics, color, color, *it, 10, 10);
1505  }
1506  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
1507  font->drawString(nullGraphics, color, color, *it, 10, 10);
1508 
1509  font->doClean();
1510  }
1511 
1512  clock_gettime(CLOCK_MONOTONIC, &time2);
1513 
1514  delete nullGraphics;
1515  delete font;
1516 
1517  int64_t diff = (static_cast<long long int>(
1518  time2.tv_sec) * 1000000000LL + static_cast<long long int>(
1519  time2.tv_nsec)) / 100000 - (static_cast<long long int>(
1520  time1.tv_sec) * 1000000000LL + static_cast<long long int>(
1521  time1.tv_nsec)) / 100000;
1522  if (debugChatTab)
1523  {
1524  debugChatTab->chatLog("sdlfont time: " + toString(diff),
1526  }
1527  return true;
1528 }
1529 #endif // defined USE_OPENGL && defined DEBUG_SDLFONT
1530 
1532 {
1533  BuyDialog *const dialog = CREATEWIDGETR0(BuyDialog);
1534  const ItemDB::ItemInfos &items = ItemDB::getItemInfos();
1535  FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items)
1536  {
1537  const ItemInfo *const info = (*it).second;
1538  if (info == nullptr)
1539  continue;
1540  const int id = info->getId();
1541  if (id <= 500)
1542  continue;
1543 
1544  dialog->addItem(id,
1546  ItemColor_one,
1547  100,
1548  0);
1549  }
1550  dialog->sort();
1551  return true;
1552 }
1553 
1555 {
1556  int id = 0;
1557  int amount = 0;
1558 
1559  if (adminHandler == nullptr)
1560  return false;
1561 
1562  if (parse2Int(event.args, id, amount))
1563  adminHandler->createItems(id, ItemColor_one, amount);
1564  else
1565  adminHandler->createItems(atoi(event.args.c_str()), ItemColor_one, 1);
1566  return true;
1567 }
1568 
1570 {
1571  // TRANSLATORS: upload config chat message
1572  uploadFile(_("Config uploaded to:"),
1573  config.getFileName(),
1574  "?xml",
1575  event.tab);
1576  return true;
1577 }
1578 
1580 {
1581  // TRANSLATORS: upload config chat message
1582  uploadFile(_("Server config Uploaded to:"),
1584  "?xml",
1585  event.tab);
1586  return true;
1587 }
1588 
1590 {
1591  // TRANSLATORS: upload log chat message
1592  uploadFile(_("Log uploaded to:"),
1594  "?txt",
1595  event.tab);
1596  return true;
1597 }
1598 
1600 {
1601  if (mercenaryHandler != nullptr)
1603  return true;
1604 }
1605 
1607 {
1608  if (mercenaryHandler != nullptr)
1610  return true;
1611 }
1612 
1614 {
1615  if (homunculusHandler != nullptr)
1617  return true;
1618 }
1619 
1621 {
1622  if (homunculusHandler != nullptr)
1624  return true;
1625 }
1626 
1628 {
1629  const int itemId = atoi(event.args.c_str());
1630 
1631  if (itemId < SPELL_MIN_ID)
1632  {
1633  const Inventory *const inv = PlayerInfo::getInventory();
1634  if (inv != nullptr)
1635  {
1636  // +++ ignoring item color for now
1637  const Item *const item = inv->findItem(itemId,
1638  ItemColor_one);
1640  }
1641  }
1642  else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
1643  {
1644  spellManager->useItem(itemId);
1645  }
1646  else if (skillDialog != nullptr)
1647  {
1648  // +++ probably need get data parameter from args
1649  skillDialog->useItem(itemId,
1650  fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
1651  0,
1652  std::string());
1653  }
1654  return true;
1655 }
1656 
1658 {
1659  int param1 = 0;
1660  int param2 = 0;
1661  const std::string args = event.args;
1662  if (parse2Int(args, param1, param2))
1663  {
1664  Item *const item = getItemByInvIndex(param1,
1666  PlayerInfo::useEquipItem(item, CAST_S16(param2), Sfx_true);
1667  }
1668  else
1669  {
1670  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
1673  }
1674  return true;
1675 }
1676 
1678 {
1679  Item *item = nullptr;
1680  const int amount = getAmountFromEvent(event, item,
1682  if (item == nullptr)
1683  return true;
1684  if (amount != 0)
1685  {
1686  if (inventoryHandler != nullptr)
1687  {
1689  item->getInvIndex(),
1690  amount,
1692  }
1693  }
1694  else
1695  {
1697  inventoryWindow, item);
1698  }
1699  return true;
1700 }
1701 
1703 {
1704  Item *item = nullptr;
1705  const int amount = getAmountFromEvent(event, item,
1707  if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
1708  return true;
1709 
1710  if (amount != 0)
1711  {
1712  if (tradeWindow != nullptr)
1713  tradeWindow->tradeItem(item, amount, true);
1714  }
1715  else
1716  {
1718  tradeWindow, item);
1719  }
1720  return true;
1721 }
1722 
1724 {
1725  Item *item = nullptr;
1726  const int amount = getAmountFromEvent(event, item, InventoryType::Storage);
1727  if (amount != 0)
1728  {
1729  if ((inventoryHandler != nullptr) && (item != nullptr))
1730  {
1732  item->getInvIndex(),
1733  amount,
1735  }
1736  }
1737  else
1738  {
1740  storageWindow, item);
1741  }
1742  return true;
1743 }
1744 
1746 {
1747  const int id = atoi(event.args.c_str());
1748  if (id > 0)
1750  return true;
1751 }
1752 
1754 {
1755  const int id = atoi(event.args.c_str());
1756  if (id > 0)
1758  return true;
1759 }
1760 
1762 {
1763  if ((localPlayer == nullptr) || (actorManager == nullptr))
1764  return false;
1765 
1766  Being *target = nullptr;
1767  std::string args = event.args;
1768  if (!args.empty())
1769  {
1770  if (args[0] != ':')
1771  {
1772  target = actorManager->findNearestByName(args);
1773  }
1774  else
1775  {
1776  target = actorManager->findBeing(fromInt(atoi(
1777  args.substr(1).c_str()), BeingId));
1778  }
1779  }
1780  if (target == nullptr)
1781  target = localPlayer->getTarget();
1782  if ((target != nullptr) && (adminHandler != nullptr))
1783  adminHandler->kick(target->getId());
1784  return true;
1785 }
1786 
1788 {
1789  if (dropShortcut != nullptr)
1790  dropShortcut->clear();
1791  return true;
1792 }
1793 
1795 {
1796  if (actorManager != nullptr)
1797  {
1798  logger->log("actors count: %d", CAST_S32(
1799  actorManager->size()));
1800  return true;
1801  }
1802  return false;
1803 }
1804 
1806 {
1807  const int slot = (event.action - InputAction::CRAFT_1);
1808  if (slot >= 0 && slot < 9)
1809  {
1810  if (inventoryWindow != nullptr)
1812  return true;
1813  }
1814  return false;
1815 }
1816 
1818 {
1820  return true;
1821 }
1822 
1824 {
1825  if (chatWindow != nullptr)
1826  {
1827  chatWindow->addInputText(event.args);
1828  return true;
1829  }
1830  return false;
1831 }
1832 
1834 {
1835  if (actorManager == nullptr)
1836  return false;
1837 
1838  ChatTab *tab = event.tab;
1839  if (tab == nullptr)
1840  tab = localChatTab;
1841  if (tab == nullptr)
1842  return false;
1843 
1844  if (config.getBoolValue("enableIdCollecting") == false)
1845  {
1846  // TRANSLATORS: last seen disabled warning
1847  tab->chatLog(_("Last seen disabled. "
1848  "Enable in players / collect players ID and seen log."),
1850  return true;
1851  }
1852 
1853  const std::string name = event.args;
1854  if (name.empty())
1855  return false;
1856 
1857  std::string dir = settings.usersDir;
1858  dir.append(stringToHexPath(name)).append("/seen.txt");
1859  if (Files::existsLocal(dir))
1860  {
1861  StringVect lines;
1862  Files::loadTextFileLocal(dir, lines);
1863  if (lines.size() < 3)
1864  {
1865  // TRANSLATORS: last seen error
1866  tab->chatLog(_("You have never seen this nick."),
1868  return true;
1869  }
1870  const std::string message = strprintf(
1871  // TRANSLATORS: last seen message
1872  _("Last seen for %s: %s"),
1873  name.c_str(),
1874  lines[2].c_str());
1875  tab->chatLog(message, ChatMsgType::BY_SERVER);
1876  }
1877  else
1878  {
1879  // TRANSLATORS: last seen error
1880  tab->chatLog(_("You have not seen this nick before."),
1882  }
1883 
1884  return true;
1885 }
1886 
1888 {
1889  if (event.tab != nullptr)
1890  memoryManager.printAllMemory(event.tab);
1891  else
1893  return true;
1894 }
1895 
1897 {
1898  const std::string &args = event.args;
1899  if (args == "player" || args.empty())
1900  {
1902  }
1903  else if (args == "pet")
1904  {
1906  }
1907  else if (args == "homun" || args == "homunculus")
1908  {
1910  }
1911  else if (args == "merc" || args == "mercenary")
1912  {
1914  }
1915  return true;
1916 }
1917 
1918 } // namespace Actions
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
int getInvIndex() const
Definition: item.h:164
ChatWindow * chatWindow
Definition: chatwindow.cpp:88
#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
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
void clear(const bool isSave=true)
virtual void feed() const =0
static int uploadUpdate(void *ptr, const DownloadStatusT status, size_t total, const size_t remaining)
Definition: actions.cpp:143
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:525
void log1(const char *const log_text)
Definition: logger.cpp:222
bool testInfo(InputEvent &event)
Definition: actions.cpp:112
static void doSit()
Definition: actions.cpp:687
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:519
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
Being * findBeingByName(const std::string &name, const ActorTypeT type=ActorType::Unknown) const
Gui * gui
Definition: gui.cpp:110
void stopAttack(const bool keepAttack=false)
Definition: font.h:88
std::string removeToken(std::string &str, const std::string &token)
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:1238
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:47
bool stopSit(InputEvent &event)
Definition: actions.cpp:61
OutfitWindow * outfitWindow
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord=IgnoreRecord_false, const TryRemoveColors tryRemoveColors=TryRemoveColors_true)
Definition: chattab.cpp:109
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:36
void clearFonts()
Definition: gui.cpp:371
InventoryType ::T InventoryTypeT
Definition: inventorytype.h:41
static std::string getUploadResponse()
Definition: download.h:110
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:227
static NpcDialog * getActive()
Definition: npcdialog.cpp:848
virtual void requestMoveToTop()
Definition: widget.cpp:212
void doClean()
Definition: font.cpp:365
virtual bool canUseMagic() const =0
Inventory * getInventory()
Definition: playerinfo.cpp:207
std::string usersDir
Definition: settings.h:116
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
MemoryManager memoryManager
void showWindowsPopup()
Definition: popupmenu.cpp:2199
bool copyEquippedToOutfit(InputEvent &event)
Definition: actions.cpp:47
void saveList() const
Definition: shopwindow.cpp:588
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
#define impHandler0(name)
Definition: actiondef.h:33
IPC * ipc
Definition: ipc.cpp:36
bool trade(InputEvent &event)
Definition: actions.cpp:70
int getIntValue(const std::string &key) const
bool pickUpItems(int pickUpType=0)
QuitDialog * quitDialog
Definition: game.cpp:153
bool dirs(InputEvent &event)
Definition: actions.cpp:76
void attack2(Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
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
#define delete2(var)
Definition: delete2.h:24
bool targetAttack(InputEvent &event)
Definition: actions.cpp:58
Configuration serverConfig
bool sit(InputEvent &event)
Definition: actions.cpp:49
#define A_NONNULL(...)
Definition: localconsts.h:179
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
void attack(Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
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:122
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:448
bool homunculusToMaster(InputEvent &event)
Definition: actions.cpp:101
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:95
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
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:94
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:274
virtual void requestSellList(const std::string &nick) const =0
bool useItem(InputEvent &event)
Definition: actions.cpp:103
std::string logFileName
Definition: settings.h:120
void addInputText(const std::string &text, const bool space=true)
void printAllMemory(ChatTab *const tab)
InventoryWindow * storageWindow
virtual int getPixelY() const
Definition: actor.h:92
#define CAST_S32
Definition: cast.h:29
void wearOutfit(const int outfit, const bool unwearEmpty=true, const bool select=false)
bool AutoTarget
Definition: autotarget.h:29
void setFile(const std::string &filename, const int64_t adler32=-1)
Definition: download.cpp:164
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:463
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:514
bool useItemInv(InputEvent &event)
Definition: actions.cpp:104
bool resetGameModifiers(InputEvent &event)
Definition: actions.cpp:114
size_t size() const
Definition: actormanager.h:381
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:212
Net::BeingHandler * beingHandler
Definition: net.cpp:92
bool dumpMods(InputEvent &event)
Definition: actions.cpp:90
bool buy(InputEvent &event)
Definition: actions.cpp:52
Net::MercenaryHandler * mercenaryHandler
Definition: net.cpp:108
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
bool isWindowVisible() const
Definition: window.h:476
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:214
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:1153
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:233
bool start()
Definition: download.cpp:186
bool mouseClick(InputEvent &event)
Definition: actions.cpp:32
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:82
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:78
std::string tempDir
Definition: settings.h:111
bool outfit(InputEvent &event)
Definition: actions.cpp:31
bool getDoubleBuffer() const
Definition: graphics.h:304
virtual void requestBuyList(const std::string &nick) const =0
Net::BuyingStoreHandler * buyingStoreHandler
Definition: net.cpp:98
bool showKeyboard(InputEvent &event)
Definition: actions.cpp:62
static void showWindow(const ItemAmountWindowUsageT usage, Window *const parent, Item *const item, int maxRange=0, const int tag=0)
ShopWindow * shopWindow
Definition: shopwindow.cpp:97
ServerTypeT getNetworkType()
Definition: net.cpp:178
bool canTalk() const
Definition: being.h:662
EmoteShortcut * emoteShortcut
Being * findNearestByName(const std::string &name, const ActorTypeT &type=ActorType::Unknown) const
bool isItemProtected(const int id)
Definition: playerinfo.cpp:526
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:171
virtual void setVisible(Visible visible)
Definition: window.cpp:766
bool setFullScreen(const bool fs)
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:80
std::map< int, ItemInfo * > ItemInfos
Definition: itemdb.h:62
Net::HomunculusHandler * homunculusHandler
Definition: net.cpp:103
Net::TradeHandler * tradeHandler
Definition: net.cpp:91
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:93
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()
void tradeItem(const Item *const item, const int quantity, const bool check=false) const
bool existsLocal(const std::string &path)
Definition: files.cpp:207
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
Net::VendingHandler * vendingHandler
Definition: net.cpp:111
int getTileX() const
Definition: being.h:167
bool dumpOGL(InputEvent &event)
Definition: actions.cpp:88
Net::NpcHandler * npcHandler
Definition: net.cpp:86
#define CAST_S16
Definition: cast.h:27
SetupWindow * setupWindow
Definition: setupwindow.cpp:63
InputManager inputManager
void select()
Definition: popupmenu.cpp:3610
void undressItemById(const int id)
Definition: being.cpp:4632
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:243
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:207
float guiAlpha
Definition: settings.h:129
Net::GameHandler * gameHandler
Definition: net.cpp:84
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:520
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:3608
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
const ItemDB::ItemInfos & getItemInfos()
Definition: itemdb.cpp:851
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:366
std::string timeDiffToString(int timeDiff)
Being * getTarget() const
void dropItems(const int cnt=1)
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