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