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  const std::string args = event.args;
829  Being *being = nullptr;
830 
831  if (!args.empty() && args[0] == ':')
832  {
833  being = actorManager->findBeing(fromInt(atoi(
834  args.substr(1).c_str()), BeingId));
835  }
836  else
837  {
838  being = findBeing(args, true);
839  }
840 
841  if (being == nullptr)
842  return false;
843 
844  if (being->canTalk())
845  {
846  being->talkTo();
847  }
848  else if (being->getType() == ActorType::Player)
849  {
851  being->getName());
852  }
853  return true;
854 }
855 
857 {
858  if (localPlayer != nullptr)
859  {
860  localPlayer->stopAttack(false);
861  // not consume if target attack key pressed
863  return false;
864  return true;
865  }
866  return false;
867 }
868 
870 {
871  if (localPlayer != nullptr)
872  {
874  return true;
875  }
876  return false;
877 }
878 
880 {
881  if ((localPlayer == nullptr) || (actorManager == nullptr))
882  return false;
883 
884  Being *target = nullptr;
885  std::string args = event.args;
886  if (!args.empty())
887  {
888  if (args[0] != ':')
889  {
890  target = actorManager->findNearestByName(args,
892  }
893  else
894  {
895  target = actorManager->findBeing(fromInt(atoi(
896  args.substr(1).c_str()), BeingId));
897  if (target != nullptr &&
898  target->getType() != ActorType::Monster)
899  {
900  target = nullptr;
901  }
902  }
903  }
904  if (target == nullptr)
905  target = localPlayer->getTarget();
906  else
907  localPlayer->setTarget(target);
908  if (target != nullptr)
909  localPlayer->attack(target, true, false);
910  return true;
911 }
912 
914 {
915  if ((localPlayer != nullptr) && (actorManager != nullptr))
916  {
917  Being *target = nullptr;
918  std::string args = event.args;
919  const bool newTarget = !inputManager.isActionActive(
921 
922  if (!args.empty())
923  {
924  if (args[0] != ':')
925  {
926  target = actorManager->findNearestByName(args,
928  }
929  else
930  {
931  target = actorManager->findBeing(fromInt(atoi(
932  args.substr(1).c_str()), BeingId));
933  if (target != nullptr &&
934  target->getType() != ActorType::Monster)
935  {
936  target = nullptr;
937  }
938  }
939  }
940 
941  if ((target == nullptr) && (settings.targetingType == 0u))
942  target = localPlayer->getTarget();
943 
944  if (target == nullptr)
945  {
948  }
949 
950  localPlayer->attack2(target, newTarget, false);
951  return true;
952  }
953  return false;
954 }
955 
957 {
958  if ((actorManager == nullptr) || (localPlayer == nullptr))
959  return false;
960 
961  Being *const target = actorManager->findNearestPvpPlayer();
962  if (target != nullptr)
963  {
964  localPlayer->setTarget(target);
965  localPlayer->attack2(target, true, false);
966  }
967  return true;
968 }
969 
971 {
973 
974  return true;
975 }
976 
978 {
979  if (localPlayer != nullptr)
980  {
981  localPlayer->stopAttack(false);
982  // not consume if target attack key pressed
984  return false;
985  if (localPlayer->getTarget() == nullptr)
986  {
987  doSit();
988  return true;
989  }
990  return true;
991  }
992  return false;
993 }
994 
996 {
997 #ifdef ANDROID
998 #ifdef USE_SDL2
999  if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE)
1000  SDL_StopTextInput();
1001  else
1002  SDL_StartTextInput();
1003 #else // USE_SDL2
1004 
1005  SDL_ANDROID_ToggleScreenKeyboardTextInput(nullptr);
1006 #endif // USE_SDL2
1007 
1008  return true;
1009 #else // ANDROID
1010 
1011  return false;
1012 #endif // ANDROID
1013 }
1014 
1016 {
1017  if (popupMenu != nullptr)
1018  {
1020  return true;
1021  }
1022  return false;
1023 }
1024 
1026 {
1027  const Being *const being = localPlayer->getTarget();
1028  if ((being != nullptr) && being->getType() == ActorType::Player)
1029  {
1030  if (tradeHandler != nullptr)
1031  tradeHandler->request(being);
1032  tradePartnerName = being->getName();
1033  if (tradeWindow != nullptr)
1034  tradeWindow->clear();
1035  return true;
1036  }
1037  return false;
1038 }
1039 
1041 {
1042  if (ipc != nullptr)
1043  {
1044  IPC::stop();
1045  if (ipc == nullptr)
1046  {
1047  debugChatTab->chatLog("IPC service stopped.",
1051  }
1052  else
1053  {
1054  debugChatTab->chatLog("Unable to stop IPC service.",
1058  }
1059  }
1060  else
1061  {
1062  IPC::start();
1063  if (ipc != nullptr)
1064  {
1066  strprintf("IPC service available on port %d", ipc->getPort()),
1070  }
1071  else
1072  {
1073  debugChatTab->chatLog("Unable to start IPC service",
1077  }
1078  }
1079  return true;
1080 }
1081 
1083 {
1084  ChatTab *const tab = event.tab != nullptr ? event.tab : debugChatTab;
1085  if (tab == nullptr)
1086  return false;
1087  std::ostringstream where;
1088  where << Game::instance()->getCurrentMapName() << ", coordinates: "
1089  << ((localPlayer->getPixelX() - mapTileSize / 2) / mapTileSize)
1090  << ", " << ((localPlayer->getPixelY() - mapTileSize) / mapTileSize);
1091  tab->chatLog(where.str(),
1095  return true;
1096 }
1097 
1099 {
1100  if (chatHandler != nullptr)
1101  chatHandler->who();
1102  return true;
1103 }
1104 
1106 {
1108 
1109  if (debugChatTab != nullptr)
1110  {
1111  // TRANSLATORS: clear graphics command message
1112  debugChatTab->chatLog(_("Cache cleared"),
1116  }
1117  return true;
1118 }
1119 
1121 {
1122  if (gui != nullptr)
1123  gui->clearFonts();
1124  if (debugChatTab != nullptr)
1125  {
1126  // TRANSLATORS: clear fonts cache message
1127  debugChatTab->chatLog(_("Cache cleared"),
1131  }
1132  return true;
1133 }
1134 
1136 {
1137  if (actorManager == nullptr)
1138  return false;
1139 
1140  const Being *being = actorManager->findBeingByName(
1141  event.args, ActorType::Player);
1142  if (being == nullptr)
1143  being = localPlayer->getTarget();
1144  if (being != nullptr)
1145  {
1146  if (tradeHandler != nullptr)
1147  tradeHandler->request(being);
1148  tradePartnerName = being->getName();
1149  if (tradeWindow != nullptr)
1150  tradeWindow->clear();
1151  }
1152  return true;
1153 }
1154 
1156 {
1157  if (shopWindow != nullptr)
1158  {
1159  shopWindow->loadList();
1160  return true;
1161  }
1162  return false;
1163 }
1164 
1166 {
1167  if (shopWindow != nullptr)
1168  {
1169  shopWindow->saveList();
1170  return true;
1171  }
1172  return false;
1173 }
1174 
1176 {
1177  if ((chatWindow == nullptr) || (debugChatTab == nullptr))
1178  return false;
1179 
1180 /*
1181  Font *const font = chatWindow->getFont();
1182  if (!font)
1183  return;
1184 
1185  const TextChunkList *const cache = font->getCache();
1186  if (!cache)
1187  return;
1188 
1189  unsigned int all = 0;
1190  // TRANSLATORS: chat fonts message
1191  debugChatTab->chatLog(_("font cache size"),
1192  ChatMsgType::BY_SERVER,
1193  IgnoreRecord_false,
1194  TryRemoveColors_true);
1195  std::string str;
1196  for (int f = 0; f < 256; f ++)
1197  {
1198  if (!cache[f].size)
1199  {
1200  const unsigned int sz = CAST_S32(cache[f].size);
1201  all += sz;
1202  str.append(strprintf("%d: %u, ", f, sz));
1203  }
1204  }
1205  debugChatTab->chatLog(str,
1206  ChatMsgType::BY_SERVER,
1207  IgnoreRecord_false,
1208  TryRemoveColors_true);
1209  // TRANSLATORS: chat fonts message
1210  debugChatTab->chatLog(strprintf("%s %d", _("Cache size:"), all),
1211  ChatMsgType::BY_SERVER,
1212  IgnoreRecord_false,
1213  TryRemoveColors_true);
1214 #ifdef DEBUG_FONT_COUNTERS
1215  debugChatTab->chatLog("",
1216  ChatMsgType::BY_SERVER,
1217  IgnoreRecord_false,
1218  TryRemoveColors_true);
1219  debugChatTab->chatLog(strprintf("%s %d",
1220  // TRANSLATORS: chat fonts message
1221  _("Created:"), font->getCreateCounter()),
1222  ChatMsgType::BY_SERVER,
1223  IgnoreRecord_false,
1224  TryRemoveColors_true);
1225  debugChatTab->chatLog(strprintf("%s %d",
1226  // TRANSLATORS: chat fonts message
1227  _("Deleted:"), font->getDeleteCounter()),
1228  ChatMsgType::BY_SERVER,
1229  IgnoreRecord_false,
1230  TryRemoveColors_true);
1231 #endif
1232 */
1233  return true;
1234 }
1235 
1237 {
1238  if (gameHandler != nullptr)
1240  return true;
1241 }
1242 
1244 {
1245  if ((actorManager == nullptr) || (localPlayer == nullptr))
1246  return false;
1247 
1248  const std::string args = event.args;
1249  StringVect pars;
1250  if (!splitParameters(pars, args, " ,", '\"'))
1251  return false;
1252  Being *target = nullptr;
1253  const size_t sz = pars.size();
1254  if (sz == 0)
1255  {
1256  target = localPlayer->getTarget();
1257  }
1258  else
1259  {
1260  if (pars[0][0] == ':')
1261  {
1262  target = actorManager->findBeing(fromInt(atoi(
1263  pars[0].substr(1).c_str()), BeingId));
1264  if ((target != nullptr) && target->getType() == ActorType::Monster)
1265  target = nullptr;
1266  }
1267  else
1268  {
1269  target = actorManager->findNearestByName(args,
1271  }
1272  }
1273 
1274  if (sz == 2)
1275  {
1276  const int itemId = atoi(pars[1].c_str());
1277  if (target != nullptr)
1278  target->undressItemById(itemId);
1279  }
1280  else
1281  {
1282  if ((target != nullptr) && (beingHandler != nullptr))
1283  beingHandler->undress(target);
1284  }
1285 
1286  return true;
1287 }
1288 
1290 {
1291  if (debugChatTab == nullptr)
1292  return false;
1293 
1294  debugChatTab->chatLog("config directory: "
1295  + settings.configDir,
1299  debugChatTab->chatLog("logs directory: "
1304  debugChatTab->chatLog("screenshots directory: "
1309  debugChatTab->chatLog("temp directory: "
1310  + settings.tempDir,
1314  return true;
1315 }
1316 
1318 {
1319  if (debugChatTab == nullptr)
1320  return false;
1321 
1322  if (cur_time < start_time)
1323  {
1324  // TRANSLATORS: uptime command
1325  debugChatTab->chatLog(strprintf(_("Client uptime: %s"), "unknown"),
1329  }
1330  else
1331  {
1332  // TRANSLATORS: uptime command
1333  debugChatTab->chatLog(strprintf(_("Client uptime: %s"),
1334  timeDiffToString(CAST_S32(cur_time - start_time)).c_str()),
1338  }
1339  return true;
1340 }
1341 
1342 #ifdef DEBUG_DUMP_LEAKS1
1343 static void showRes(std::string str, ResourceManager::Resources *res)
1344 {
1345  if (!res)
1346  return;
1347 
1348  str.append(toString(res->size()));
1349  if (debugChatTab)
1350  {
1351  debugChatTab->chatLog(str,
1355  }
1356  logger->log(str);
1357  ResourceManager::ResourceIterator iter = res->begin();
1358  const ResourceManager::ResourceIterator iter_end = res->end();
1359  while (iter != iter_end)
1360  {
1361  if (iter->second && iter->second->mRefCount)
1362  {
1363  char type = ' ';
1364  char isNew = 'N';
1365  if (iter->second->getDumped())
1366  isNew = 'O';
1367  else
1368  iter->second->setDumped(true);
1369 
1370  SubImage *const subImage = dynamic_cast<SubImage *>(
1371  iter->second);
1372  Image *const image = dynamic_cast<Image *>(iter->second);
1373  int id = 0;
1374  if (subImage)
1375  type = 'S';
1376  else if (image)
1377  type = 'I';
1378  if (image)
1379  id = image->getGLImage();
1380  logger->log("Resource %c%c: %s (%d) id=%d", type,
1381  isNew, iter->second->getIdPath().c_str(),
1382  iter->second->mRefCount, id);
1383  }
1384  ++ iter;
1385  }
1386 }
1387 
1389 {
1390  if (!debugChatTab)
1391  return false;
1392 
1393  if (!event.args.empty())
1394  {
1395  ResourceManager::Resources *res = ResourceManager::getResources();
1396  // TRANSLATORS: dump command
1397  showRes(_("Resource images:"), res);
1398  res = ResourceManager::getOrphanedResources();
1399  // TRANSLATORS: dump command
1400  showRes(_("Orphaned resource images:"), res);
1401  }
1402  else
1403  {
1404  ResourceManager::Resources *res = ResourceManager::getResources();
1405  // TRANSLATORS: dump command
1406  debugChatTab->chatLog(_("Resource images:") + toString(res->size()),
1410  res = ResourceManager::getOrphanedResources();
1411  // TRANSLATORS: dump command
1412  debugChatTab->chatLog(_("Orphaned resource images:")
1413  + toString(res->size()),
1417  }
1418  return true;
1419 }
1420 
1421 #elif defined ENABLE_MEM_DEBUG
1423 {
1425  return true;
1426 }
1427 #else // DEBUG_DUMP_LEAKS1
1428 
1430 {
1431  return true;
1432 }
1433 #endif // DEBUG_DUMP_LEAKS1
1434 
1436 {
1437  if (chatHandler != nullptr)
1439  return true;
1440 }
1441 
1443 {
1444  if (chatHandler != nullptr)
1446  return true;
1447 }
1448 
1449 PRAGMA6(GCC diagnostic push)
1450 PRAGMA6(GCC diagnostic ignored "-Wnull-dereference")
1452 {
1453  int *const ptr = nullptr;
1454  *(ptr + 1) = 20;
1455 // logger->log("test %d", *ptr);
1456  exit(1);
1457 }
1458 PRAGMA6(GCC diagnostic pop)
1459 
1461 {
1462  std::string str = strprintf("%s,%s,%dX%dX%d,", PACKAGE_OS, SMALL_VERSION,
1464  mainGraphics->getBpp());
1465 
1466  if (mainGraphics->getFullScreen())
1467  str.append("F");
1468  else
1469  str.append("W");
1470  if (mainGraphics->getHWAccel())
1471  str.append("H");
1472  else
1473  str.append("S");
1474 
1476  str.append("D");
1477  else
1478  str.append("_");
1479 
1480 #if defined USE_OPENGL
1481  str.append(strprintf(",%d", mainGraphics->getOpenGL()));
1482 #else // defined USE_OPENGL
1483 
1484  str.append(",0");
1485 #endif // defined USE_OPENGL
1486 
1487  str.append(strprintf(",%f,", static_cast<double>(settings.guiAlpha)))
1488  .append(config.getBoolValue("adjustPerfomance") ? "1" : "0")
1489  .append(config.getBoolValue("alphaCache") ? "1" : "0")
1490  .append(config.getBoolValue("enableMapReduce") ? "1" : "0")
1491  .append(config.getBoolValue("beingopacity") ? "1" : "0")
1492  .append(",")
1493  .append(config.getBoolValue("enableAlphaFix") ? "1" : "0")
1494  .append(config.getBoolValue("disableAdvBeingCaching") ? "1" : "0")
1495  .append(config.getBoolValue("disableBeingCaching") ? "1" : "0")
1496  .append(config.getBoolValue("particleeffects") ? "1" : "0")
1497  .append(strprintf(",%d-%d", fps, config.getIntValue("fpslimit")));
1498  outStringNormal(event.tab, str, str);
1499  return true;
1500 }
1501 
1503 {
1504  logger->log1("Start environment variables");
1505  for (char **env = environ; *env != nullptr; ++ env)
1506  logger->log1(*env);
1507  logger->log1("End environment variables");
1508  if (debugChatTab != nullptr)
1509  {
1510  // TRANSLATORS: dump environment command
1511  debugChatTab->chatLog(_("Environment variables dumped"),
1515  }
1516  return true;
1517 }
1518 
1520 {
1521  const std::string str = config.getStringValue("testInfo");
1522  outStringNormal(event.tab, str, str);
1523  return true;
1524 }
1525 
1527 {
1528 #if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
1530 #endif // defined(USE_OPENGL) && !defined(ANDROID) &&
1531  // !defined(__native_client__)
1532 
1533  return true;
1534 }
1535 
1536 #ifdef USE_OPENGL
1538 {
1539  std::string str = graphicsManager.getGLVersion();
1540  outStringNormal(event.tab, str, str);
1541  return true;
1542 }
1543 #else // USE_OPENGL
1544 
1546 {
1547  return true;
1548 }
1549 #endif // USE_OPENGL
1550 
1552 {
1553  std::string str = "enabled mods: " + serverConfig.getValue("mods", "");
1554  outStringNormal(event.tab, str, str);
1555  return true;
1556 }
1557 
1558 #if defined USE_OPENGL && defined DEBUG_SDLFONT
1559 impHandler0(testSdlFont)
1560 {
1561  Font *font = new Font("fonts/dejavusans.ttf", 18, TTF_STYLE_NORMAL);
1562  timespec time1;
1563  timespec time2;
1564  NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics;
1565  STD_VECTOR<std::string> data;
1566  volatile int width = 0;
1567 
1568  for (int f = 0; f < 300; f ++)
1569  data.push_back("test " + toString(f) + "string");
1570  nullGraphics->beginDraw();
1571 
1572  clock_gettime(CLOCK_MONOTONIC, &time1);
1573  Color color(0, 0, 0, 255);
1574 
1575  for (int f = 0; f < 500; f ++)
1576  {
1577  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
1578  {
1579  width += font->getWidth(*it);
1580  font->drawString(nullGraphics, color, color, *it, 10, 10);
1581  }
1582  FOR_EACH (STD_VECTOR<std::string>::const_iterator, it, data)
1583  font->drawString(nullGraphics, color, color, *it, 10, 10);
1584 
1585  font->doClean();
1586  }
1587 
1588  clock_gettime(CLOCK_MONOTONIC, &time2);
1589 
1590  delete nullGraphics;
1591  delete font;
1592 
1593  int64_t diff = (static_cast<long long int>(
1594  time2.tv_sec) * 1000000000LL + static_cast<long long int>(
1595  time2.tv_nsec)) / 100000 - (static_cast<long long int>(
1596  time1.tv_sec) * 1000000000LL + static_cast<long long int>(
1597  time1.tv_nsec)) / 100000;
1598  if (debugChatTab)
1599  {
1600  debugChatTab->chatLog("sdlfont time: " + toString(diff),
1604  }
1605  return true;
1606 }
1607 #endif // defined USE_OPENGL && defined DEBUG_SDLFONT
1608 
1610 {
1611  BuyDialog *const dialog = CREATEWIDGETR0(BuyDialog);
1612  const ItemDB::ItemInfos &items = ItemDB::getItemInfos();
1613  FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items)
1614  {
1615  const ItemInfo *const info = (*it).second;
1616  if (info == nullptr)
1617  continue;
1618  const int id = info->getId();
1619  if (id <= 500)
1620  continue;
1621 
1622  dialog->addItem(id,
1624  ItemColor_one,
1625  100,
1626  0);
1627  }
1628  dialog->sort();
1629  return true;
1630 }
1631 
1633 {
1634  int id = 0;
1635  int amount = 0;
1636 
1637  if (adminHandler == nullptr)
1638  return false;
1639 
1640  if (parse2Int(event.args, id, amount))
1641  adminHandler->createItems(id, ItemColor_one, amount);
1642  else
1643  adminHandler->createItems(atoi(event.args.c_str()), ItemColor_one, 1);
1644  return true;
1645 }
1646 
1648 {
1649  // TRANSLATORS: upload config chat message
1650  uploadFile(_("Config uploaded to:"),
1651  config.getFileName(),
1652  "?xml",
1653  event.tab);
1654  return true;
1655 }
1656 
1658 {
1659  // TRANSLATORS: upload config chat message
1660  uploadFile(_("Server config Uploaded to:"),
1662  "?xml",
1663  event.tab);
1664  return true;
1665 }
1666 
1668 {
1669  // TRANSLATORS: upload log chat message
1670  uploadFile(_("Log uploaded to:"),
1672  "",
1673  event.tab);
1674  return true;
1675 }
1676 
1678 {
1679  if (mercenaryHandler != nullptr)
1681  return true;
1682 }
1683 
1685 {
1686  if (mercenaryHandler != nullptr)
1688  return true;
1689 }
1690 
1692 {
1693  if (homunculusHandler != nullptr)
1695  return true;
1696 }
1697 
1699 {
1700  if (homunculusHandler != nullptr)
1702  return true;
1703 }
1704 
1706 {
1707  StringVect pars;
1708  if (!splitParameters(pars, event.args, " ,", '\"'))
1709  return false;
1710  const int sz = CAST_S32(pars.size());
1711  if (sz < 1)
1712  return false;
1713 
1714  const int itemId = atoi(pars[0].c_str());
1715 
1716  if (itemId < SPELL_MIN_ID)
1717  {
1718  const Inventory *const inv = PlayerInfo::getInventory();
1719  if (inv != nullptr)
1720  {
1721  ItemColor color = ItemColor_one;
1722  int16_t useType = 0;
1723  StringVect pars2;
1724  if (!splitParameters(pars2, pars[0], " ,", '\"'))
1725  return false;
1726  const int sz2 = CAST_S32(pars2.size());
1727  if (sz2 < 1)
1728  return false;
1729  if (sz2 >= 2)
1730  color = fromInt(atoi(pars2[1].c_str()), ItemColor);
1731  if (sz >= 2)
1732  useType = CAST_S16(atoi(pars[1].c_str()));
1733  const Item *const item = inv->findItem(itemId,
1734  color);
1735  PlayerInfo::useEquipItem(item, useType, Sfx_true);
1736  }
1737  }
1738  else if (itemId < SKILL_MIN_ID && (spellManager != nullptr))
1739  {
1740  spellManager->useItem(itemId);
1741  }
1742  else if (skillDialog != nullptr)
1743  {
1744  // +++ probably need get data parameter from args
1745  skillDialog->useItem(itemId,
1746  fromBool(config.getBoolValue("skillAutotarget"), AutoTarget),
1747  0,
1748  std::string());
1749  }
1750  return true;
1751 }
1752 
1754 {
1755  int param1 = 0;
1756  int param2 = 0;
1757  const std::string args = event.args;
1758  if (parse2Int(args, param1, param2))
1759  {
1760  Item *const item = getItemByInvIndex(param1,
1762  PlayerInfo::useEquipItem(item, CAST_S16(param2), Sfx_true);
1763  }
1764  else
1765  {
1766  Item *const item = getItemByInvIndex(atoi(event.args.c_str()),
1769  }
1770  return true;
1771 }
1772 
1774 {
1775  Item *item = nullptr;
1776  const int amount = getAmountFromEvent(event, item,
1778  if (item == nullptr)
1779  return true;
1780  if (amount != 0)
1781  {
1782  if (inventoryHandler != nullptr)
1783  {
1785  item->getInvIndex(),
1786  amount,
1788  }
1789  }
1790  else
1791  {
1794  item,
1795  0,
1796  0);
1797  }
1798  return true;
1799 }
1800 
1802 {
1803  Item *item = nullptr;
1804  const int amount = getAmountFromEvent(event, item,
1806  if ((item == nullptr) || PlayerInfo::isItemProtected(item->getId()))
1807  return true;
1808 
1809  if (amount != 0)
1810  {
1811  if (tradeWindow != nullptr)
1812  tradeWindow->tradeItem(item, amount, true);
1813  }
1814  else
1815  {
1817  tradeWindow,
1818  item,
1819  0,
1820  0);
1821  }
1822  return true;
1823 }
1824 
1826 {
1827  Item *item = nullptr;
1828  const int amount = getAmountFromEvent(event, item, InventoryType::Storage);
1829  if (amount != 0)
1830  {
1831  if ((inventoryHandler != nullptr) && (item != nullptr))
1832  {
1834  item->getInvIndex(),
1835  amount,
1837  }
1838  }
1839  else
1840  {
1842  storageWindow,
1843  item,
1844  0,
1845  0);
1846  }
1847  return true;
1848 }
1849 
1851 {
1852  const int id = atoi(event.args.c_str());
1853  if (id > 0)
1855  return true;
1856 }
1857 
1859 {
1860  const int id = atoi(event.args.c_str());
1861  if (id > 0)
1863  return true;
1864 }
1865 
1867 {
1868  if ((localPlayer == nullptr) || (actorManager == nullptr))
1869  return false;
1870 
1871  Being *target = nullptr;
1872  std::string args = event.args;
1873  if (!args.empty())
1874  {
1875  if (args[0] != ':')
1876  {
1877  target = actorManager->findNearestByName(args,
1879  }
1880  else
1881  {
1882  target = actorManager->findBeing(fromInt(atoi(
1883  args.substr(1).c_str()), BeingId));
1884  }
1885  }
1886  if (target == nullptr)
1887  target = localPlayer->getTarget();
1888  if ((target != nullptr) && (adminHandler != nullptr))
1889  adminHandler->kick(target->getId());
1890  return true;
1891 }
1892 
1894 {
1895  if (dropShortcut != nullptr)
1896  dropShortcut->clear(true);
1897  return true;
1898 }
1899 
1901 {
1902  if (actorManager != nullptr)
1903  {
1904  logger->log("actors count: %d", CAST_S32(
1905  actorManager->size()));
1906  return true;
1907  }
1908  return false;
1909 }
1910 
1912 {
1913  const int slot = (event.action - InputAction::CRAFT_1);
1914  if (slot >= 0 && slot < 9)
1915  {
1916  if (inventoryWindow != nullptr)
1918  return true;
1919  }
1920  return false;
1921 }
1922 
1924 {
1926  return true;
1927 }
1928 
1930 {
1931  if (chatWindow != nullptr)
1932  {
1933  chatWindow->addInputText(event.args,
1934  true);
1935  return true;
1936  }
1937  return false;
1938 }
1939 
1941 {
1942  if (actorManager == nullptr)
1943  return false;
1944 
1945  ChatTab *tab = event.tab;
1946  if (tab == nullptr)
1947  tab = localChatTab;
1948  if (tab == nullptr)
1949  return false;
1950 
1951  if (config.getBoolValue("enableIdCollecting") == false)
1952  {
1953  // TRANSLATORS: last seen disabled warning
1954  tab->chatLog(_("Last seen disabled. "
1955  "Enable in players / collect players ID and seen log."),
1959  return true;
1960  }
1961 
1962  const std::string name = event.args;
1963  if (name.empty())
1964  return false;
1965 
1966  std::string dir = settings.usersDir;
1967  dir.append(stringToHexPath(name)).append("/seen.txt");
1968  if (Files::existsLocal(dir))
1969  {
1970  StringVect lines;
1971  Files::loadTextFileLocal(dir, lines);
1972  if (lines.size() < 3)
1973  {
1974  // TRANSLATORS: last seen error
1975  tab->chatLog(_("You have never seen this nick."),
1979  return true;
1980  }
1981  const std::string message = strprintf(
1982  // TRANSLATORS: last seen message
1983  _("Last seen for %s: %s"),
1984  name.c_str(),
1985  lines[2].c_str());
1986  tab->chatLog(message,
1990  }
1991  else
1992  {
1993  // TRANSLATORS: last seen error
1994  tab->chatLog(_("You have not seen this nick before."),
1998  }
1999 
2000  return true;
2001 }
2002 
2004 {
2005  if (event.tab != nullptr)
2006  memoryManager.printAllMemory(event.tab);
2007  else
2009  return true;
2010 }
2011 
2013 {
2014  const std::string &args = event.args;
2015  if (args == "player" || args.empty())
2016  {
2018  }
2019  else if (args == "pet")
2020  {
2022  }
2023  else if (args == "homun" || args == "homunculus")
2024  {
2026  }
2027  else if (args == "merc" || args == "mercenary")
2028  {
2030  }
2031  return true;
2032 }
2033 
2034 } // 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:534
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:1272
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:157
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:134
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