Crossfire Server, Trunk
CREMainWindow.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include <Qt>
14 #include <QtWidgets>
15 #include <memory>
16 
17 #include <CREMainWindow.h>
18 #include <CREResourcesWindow.h>
20 #include "CREExperienceWindow.h"
21 #include "MessageManager.h"
22 #include "CREReportDisplay.h"
23 #include "CREPixmap.h"
24 #include "CRESmoothFaceMaker.h"
25 #include "CREHPBarMaker.h"
26 #include "ResourcesManager.h"
27 #include "CRECombatSimulator.h"
28 #include "CREHPBarMaker.h"
30 #include "FaceMakerDialog.h"
31 #include "EditMonstersDialog.h"
32 #include "random_maps/RandomMap.h"
33 
34 #include "global.h"
35 #include "sproto.h"
36 #include "image.h"
37 #include "assets.h"
38 #include "AssetsManager.h"
39 #include "CRESettings.h"
40 #include "LicenseManager.h"
41 #include "AllAssets.h"
42 #include "assets/AssetModel.h"
43 #include "ChangesDock.h"
44 #include "HelpManager.h"
45 #include "MonsterResistances.h"
46 #include "sounds/SoundsDialog.h"
47 
48 const char *AssetWrapper::tipProperty = "_cre_internal";
49 
50 CREMainWindow::CREMainWindow(const QString &helpRoot)
51 {
52  myArea = new QMdiArea();
53  setCentralWidget(myArea);
54  myArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
55  myArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
56 
59 
60  myMessageManager = new MessageManager(nullptr);
62  myScriptManager = new ScriptFileManager(nullptr);
63 
65  connect(myMapManager, SIGNAL(browsingMap(const QString&)), this, SLOT(browsingMap(const QString&)));
66  connect(myMapManager, SIGNAL(finished()), this, SLOT(browsingFinished()));
69 
71 
73  myModel = new AssetModel(myAssets, this);
76 
77  myHelpManager = new HelpManager(helpRoot);
78 
79  createActions();
80  createMenus();
81 
82  statusBar()->showMessage(tr("Ready"));
83  myMapBrowseStatus = new QLabel(tr("Browsing maps..."));
84  statusBar()->addPermanentWidget(myMapBrowseStatus);
85 
86  setWindowTitle(tr("Crossfire Resource Editor"));
87 
88  fillFacesets();
89 
90  myChanges = new ChangesDock(myHelpManager, this);
91  addDockWidget(Qt::RightDockWidgetArea, myChanges);
92 
94  myHelpManager->setupData();
95 
97  if (settings.storeWindowsState()) {
98  restoreGeometry(settings.mainWindowGeometry());
99 
100  int count = settings.subWindowCount();
101  for (int idx = 0; idx < count; idx++) {
102  int type = settings.subWindowType(idx);
103  if (type == -2) {
104  onOpenExperience(settings.subWindowPosition(idx));
105  } else {
106  doResourceWindow(type, settings.subWindowPosition(idx));
107  }
108  }
109  }
110 }
111 
113 {
115  if (QMessageBox::question(this, "Discard changes?", "You have unsaved changes, really discard them?") != QMessageBox::Yes) {
116  event->ignore();
117  return;
118  }
119  }
120 
122  if (settings.storeWindowsState()) {
123  auto windows = myArea->subWindowList();
124  settings.setSubWindowCount(windows.size());
125  for (int idx = 0; idx < windows.size(); idx++) {
126  settings.setSubWindowPosition(idx, windows[idx]->saveGeometry());
127  auto widget = windows[idx]->widget();
128  auto crew = dynamic_cast<CREResourcesWindow *>(widget);
129  if (crew != nullptr) {
130  settings.setSubWindowType(idx, crew->rootIndex());
131  }
132  auto ew = dynamic_cast<CREExperienceWindow *>(widget);
133  if (ew) {
134  settings.setSubWindowType(idx, -2);
135  }
136  }
137  settings.setMainWindowGeometry(saveGeometry());
138  }
139 
140  myArea->closeAllSubWindows();
141  delete myArea;
142  QMainWindow::closeEvent(event);
143 
144  myMapManager->cancel();
145  delete myMapManager;
146  delete myMessageManager;
147  delete myResourcesManager;
148  cleanup();
149 }
150 
151 template <typename F>
152 QAction *CREMainWindow::createAction(const QString &title, const QString &statusTip, F functor, bool waitMaps) {
153  auto action = createAction(title, statusTip);
154  if (waitMaps) {
155  connect(action, &QAction::triggered, [this, functor] {
156  if (!myMapManager->browseFinished()) {
157  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
158  QProgressDialog prog(this);
159  prog.setLabelText(tr("Waiting for maps browing to finish..."));
160  prog.setWindowModality(Qt::ApplicationModal);
161  prog.setRange(0, 0);
162  prog.setVisible(true);
163  prog.setValue(0);
164  while (!myMapManager->browseFinished())
165  {
166  if (prog.wasCanceled()) {
167  QApplication::restoreOverrideCursor();
168  return;
169  }
170  QApplication::processEvents();
171  QThread::msleep(1);
172  }
173  QApplication::restoreOverrideCursor();
174  }
175  functor();
176  });
177  } else {
178  connect(action, &QAction::triggered, functor);
179  }
180  return action;
181 }
182 
183 QAction *CREMainWindow::createAction(const QString &title, const QString &statusTip) {
184  auto action = new QAction(title, this);
185  action->setStatusTip(statusTip);
186  return action;
187 }
188 
190 {
191  mySaveFormulae = new QAction(tr("Formulae"), this);
192  mySaveFormulae->setEnabled(false);
193  connect(mySaveFormulae, SIGNAL(triggered()), this, SLOT(onSaveFormulae()));
194 
195  myClearMapCache = new QAction(tr("Clear map cache"), this);
196  myClearMapCache->setStatusTip(tr("Force a refresh of all map information at next start."));
197  connect(myClearMapCache, SIGNAL(triggered()), this, SLOT(onClearCache()));
198  /* can't clear map cache while collecting information */
199  myClearMapCache->setEnabled(false);
200 
201  myToolFacesetUseFallback = new QAction(tr("Use set fallback for missing faces"), this);
202  connect(myToolFacesetUseFallback, SIGNAL(triggered()), this, SLOT(onToolFacesetUseFallback()));
203  myToolFacesetUseFallback->setCheckable(true);
204  myToolFacesetUseFallback->setChecked(true);
205 }
206 
208 {
209  myOpenMenu = menuBar()->addMenu(tr("&Open"));
210 
211  auto add = [this] (int index, const QString &name, const QString &tip) {
212  QAction* action = new QAction(name, this);
213  action->setStatusTip(tip);
214  action->setData(static_cast<int>(index));
215  connect(action, &QAction::triggered, [this, index] () { doResourceWindow(index); });
216  myOpenMenu->addAction(action);
217  };
218  add(-1, tr("Assets"), tr("Display all defined assets, except the experience table."));
219  for (int asset = 0; asset < myAssets->childrenCount(); asset++) {
220  add(asset, myAssets->child(asset)->displayName(), myAssets->child(asset)->property(AssetWrapper::tipProperty).toString());
221  }
222 
223  myOpenMenu->addAction(createAction(tr("Experience"), tr("Display the experience table."), [this] { onOpenExperience(); }));
224 
225  myOpenMenu->addSeparator();
226  QAction* exit = myOpenMenu->addAction(tr("&Exit"));
227  exit->setStatusTip(tr("Close the application."));
228  connect(exit, SIGNAL(triggered()), this, SLOT(close()));
229 
230  mySaveMenu = menuBar()->addMenu(tr("&Save"));
231  mySaveMenu->addAction(mySaveFormulae);
232  mySaveMenu->addAction(createAction(tr("Quests"), tr("Save all modified quests to disk."), [this] { onSaveQuests(); }));
233  mySaveMenu->addAction(createAction(tr("Dialogs"), tr("Save all modified NPC dialogs."), [this] { onSaveMessages(); }));
234  mySaveMenu->addAction(createAction(tr("Archetypes"), tr("Save all modified archetypes."), [this] { myResourcesManager->saveArchetypes(); }));
235  mySaveMenu->addAction(createAction(tr("Treasures"), tr("Save all modified treasures."), [this] { myResourcesManager->saveTreasures(); }));
236  mySaveMenu->addAction(createAction(tr("General messages"), tr("Save all modified general messages."), [this] { myResourcesManager->saveGeneralMessages(); }));
237  mySaveMenu->addAction(createAction(tr("Artifacts"), tr("Save all modified artifacts."), [this] { myResourcesManager->saveArtifacts(); }));
238 
239  QMenu* reportMenu = menuBar()->addMenu(tr("&Reports"));
240  reportMenu->addAction(createAction(tr("Faces and animations report"), tr("Show faces and animations which are used by multiple archetypes, or not used."), [this] { onReportDuplicate(); }));
241  reportMenu->addAction(createAction(tr("Spell damage"), tr("Display damage by level for some spells."), [this] () { onReportSpellDamage(); }, true));
242  reportMenu->addAction(createAction(tr("Alchemy"), tr("Display alchemy formulae, in a table."), [this] { onReportAlchemy(); }));
243  reportMenu->addAction(createAction(tr("Alchemy graph"), tr("Export alchemy relationship as a DOT file."), [this] { onReportAlchemyGraph(); }));
244  reportMenu->addAction(createAction(tr("Spells"), tr("Display all spells, in a table."), [this] { onReportSpells(); }));
245  reportMenu->addAction(createAction(tr("Player vs monsters"), tr("Compute statistics related to player vs monster combat."), [=] { onReportPlayer(); }, true));
246  reportMenu->addAction(createAction(tr("Summoned pets statistics"), tr("Display wc, hp, speed and other statistics for summoned pets."), [=] { onReportSummon(); }));
247  reportMenu->addAction(createAction(tr("Shop specialization"), tr("Display the list of shops and their specialization for items."), [=] { onReportShops(); }, true));
248  reportMenu->addAction(createAction(tr("Quest solved by players"), tr("Display quests the players have solved."), [=] { onReportQuests(); }, true));
249  reportMenu->addAction(createAction(tr("Materials"), tr("Display all materials with their properties."), [this] { onReportMaterials(); }));
250  reportMenu->addAction(createAction(tr("Unused archetypes"), tr("Display all archetypes which seem unused."), [=] { onReportArchetypes(); }, true));
251  reportMenu->addAction(createAction(tr("Licenses checks"), tr("Check for licenses inconsistencies."), [this] { onReportLicenses(); }));
252  reportMenu->addAction(createAction(tr("Map reset groups"), tr("List map reset groups."), [this] { onReportResetGroups(); }, true));
253 
254  myToolsMenu = menuBar()->addMenu(tr("&Tools"));
255  myToolsMenu->addAction(createAction(tr("Edit monsters"), tr("Edit monsters in a table."), [this] { onToolEditMonsters(); }));
256  auto resist = createAction(tr("Monster resistances overview"), tr("Display an overview of resistances of monsters"));
257  connect(resist, &QAction::triggered, [&] {
258  MonsterResistances dlg(this);
259  dlg.exec();
260  });
261  myToolsMenu->addAction(resist);
262  myToolsMenu->addAction(createAction(tr("Generate smooth face base"), tr("Generate the basic smoothed picture for a face."), [this] { onToolSmooth(); }));
263  myToolsMenu->addAction(createAction(tr("Generate HP bar"), tr("Generate faces for a HP bar."), [this] { onToolBarMaker(); }));
264  myToolsMenu->addAction(createAction(tr("Combat simulator"), tr("Simulate fighting between two objects."), [this] { onToolCombatSimulator(); }));
265  myToolsMenu->addAction(createAction(tr("Generate face variants"), tr("Generate faces by changing colors of existing faces."), [this] { onToolFaceMaker(); }));
266  myToolsMenu->addAction(myClearMapCache);
267  myToolsMenu->addAction(createAction(tr("Reload assets"), tr("Reload all assets from the data directory."), [this] { onToolReloadAssets(); }));
268  myToolsMenu->addAction(createAction(tr("Sounds"), tr("Display defined sounds and associated files."), [this] { onToolSounds(); }));
269 
270  CRESettings set;
271 
272  myWindows = menuBar()->addMenu(tr("&Windows"));
273  connect(myWindows, SIGNAL(aboutToShow()), this, SLOT(onWindowsShowing()));
274  auto store = createAction(tr("Restore windows positions at launch"), tr("If enabled then opened windows are automatically opened again when the application starts"));
275  store->setCheckable(true);
276  store->setChecked(set.storeWindowsState());
277  myWindows->addAction(store);
278  connect(store, &QAction::triggered, [store] {
279  CRESettings set;
280  set.setStoreWindowState(store->isChecked());
281  } );
282 
283  myWindows->addAction(createAction(tr("Close current window"), tr("Close the currently focused window"), [this] { myArea->closeActiveSubWindow(); }));
284  myWindows->addAction(createAction(tr("Close all windows"), tr("Close all opened windows"), [=] { myArea->closeAllSubWindows(); }));
285  myWindows->addAction(createAction(tr("Tile windows"), tr("Tile all windows"), [=] { myArea->tileSubWindows(); }));
286  myWindows->addAction(createAction(tr("Cascade windows"), tr("Cascade all windows"), [=] { myArea->cascadeSubWindows(); }));
287 
288  auto sep = new QAction(this);
289  sep->setSeparator(true);
290  myWindows->addAction(sep);
291 
292  auto helpMenu = menuBar()->addMenu(tr("&Help"));
293  auto help = createAction(tr("Help"), tr("CRE Help"), [=] { myHelpManager->displayHelp(); });
294  help->setShortcut(Qt::Key_F1);
295  helpMenu->addAction(help);
296 
297  helpMenu->addAction(createAction(tr("About"), tr("About CRE"), [=] () { QMessageBox::about(this, tr("About CRE"), tr("Crossfire Resource Editor")); }));
298 
300  auto show = createAction(tr("Show changes after updating"), tr("If checked, then show latest changes at first startup after an update"));
301  show->setCheckable(true);
302  show->setChecked(settings.showChanges());
303  helpMenu->addAction(show);
304  connect(show, &QAction::triggered, [&] (bool checked) {
306  settings.setShowChanges(checked);
307  });
308 
309  helpMenu->addAction(createAction(tr("Changes"), tr("Display CRE changes"), [=] () { myChanges->setVisible(true); }));
310 }
311 
312 void CREMainWindow::doResourceWindow(int assets, const QByteArray& position)
313 {
314  QModelIndex root;
315  if (assets != -1) {
316  root = myModel->index(assets, 0, QModelIndex());
317  }
318 
320  resources->setAttribute(Qt::WA_DeleteOnClose);
321  connect(this, SIGNAL(updateFilters()), resources, SLOT(updateFilters()));
322  connect(resources, SIGNAL(filtersModified()), this, SLOT(onFiltersModified()));
323  connect(this, SIGNAL(updateReports()), resources, SLOT(updateReports()));
324  connect(resources, SIGNAL(reportsModified()), this, SLOT(onReportsModified()));
325  auto widget = myArea->addSubWindow(resources);
326  widget->setAttribute(Qt::WA_DeleteOnClose);
327  if (position.isEmpty()) {
328  if (myArea->subWindowList().size() == 1) {
329  widget->setWindowState(Qt::WindowMaximized);
330  }
331  } else {
332  widget->restoreGeometry(position);
333  }
334  resources->show();
335 }
336 
337 void CREMainWindow::onOpenExperience(const QByteArray& position)
338 {
339  QWidget* experience = new CREExperienceWindow();
340  auto widget = myArea->addSubWindow(experience);
341  if (!position.isEmpty()) {
342  widget->restoreGeometry(position);
343  }
344  experience->show();
345 }
346 
348 {
350  const QString select = settings.facesetToDisplay();
351  const bool use = settings.facesetUseFallback();
352 
353  QMenu *fs = myToolsMenu->addMenu(tr("Facesets"));
354  myFacesetsGroup = new QActionGroup(this);
355  connect(myFacesetsGroup, SIGNAL(triggered(QAction*)), this, SLOT(onToolFaceset(QAction*)));
356  getManager()->facesets()->each([&fs, &select, this] (face_sets *f)
357  {
358  QAction *a = new QAction(f->fullname, fs);
359  a->setCheckable(true);
360  a->setData(f->prefix);
361  fs->addAction(a);
362  myFacesetsGroup->addAction(a);
363  if (select == f->prefix)
364  a->setChecked(true);
365  });
366  fs->addSeparator();
367  fs->addAction(myToolFacesetUseFallback);
368  myToolFacesetUseFallback->setChecked(use);
369 }
370 
372 {
373 }
374 
376 {
378 }
379 
381 {
383 }
384 
385 void CREMainWindow::browsingMap(const QString& path)
386 {
387  myMapBrowseStatus->setText(tr("Browsing map %1").arg(path));
388 }
389 
391 {
392  statusBar()->showMessage(tr("Finished browsing maps."), 5000);
393  myMapBrowseStatus->setVisible(false);
394  myClearMapCache->setEnabled(true);
395 }
396 
398 {
399  emit updateFilters();
400 }
401 
403 {
404  emit updateReports();
405 }
406 
414 {
415  QHash<QString, QStringList> faces, anims;
416 
417  // browse all archetypes
418  getManager()->archetypes()->each([&faces, &anims] (const auto arch)
419  {
420  if (arch->head)
421  {
422  return;
423  }
424  // if there is an animation, don't consider the face, since it's part of the animation anyway (hopefully, see lower for report on that)
425  if (arch->clone.animation == NULL)
426  {
427  if (arch->clone.face) {
428  faces[QString::fromLatin1(arch->clone.face->name)].append(QString(arch->name) + " (arch)");
429  sstring key = object_get_value(&arch->clone, "identified_face");
430  if (key)
431  {
432  faces[QString(key)].append(QString(arch->name) + " (arch)");
433  }
434  }
435  }
436  else
437  {
438  anims[arch->clone.animation->name].append(QString(arch->name) + " (arch)");
439  sstring key = object_get_value(&arch->clone, "identified_animation");
440  if (key)
441  {
442  anims[QString(key)].append(QString(arch->name) + " (arch)");
443  }
444  }
445  });
446 
447  // list faces in animations
448  getManager()->animations()->each([&faces] (const auto anim)
449  {
450  QStringList done;
451  for (int i = 0; i < anim->num_animations; i++)
452  {
453  // don't list animation twice if they use the same face
454  if (!done.contains(QString::fromLatin1(anim->faces[i]->name)))
455  {
456  faces[QString::fromLatin1(anim->faces[i]->name)].append(QString(anim->name) + " (animation)");
457  done.append(QString::fromLatin1(anim->faces[i]->name));
458  }
459  }
460  });
461 
462  // list faces and animations for artifacts
464  for (list = first_artifactlist; list != NULL; list = list->next)
465  {
466  for (auto art : list->items)
467  {
468  if (art->item->animation == 0)
469  {
470  if (art->item->face) {
471  faces[QString::fromLatin1(art->item->face->name)].append(QString(art->item->name) + " (art)");
472  sstring key = object_get_value(art->item, "identified_face");
473  if (key)
474  {
475  faces[QString(key)].append(QString(art->item->name) + " (art)");
476  }
477  }
478  }
479  else
480  {
481  anims[art->item->animation->name].append(QString(art->item->name) + " (art)");
482  sstring key = object_get_value(art->item, "identified_animation");
483  if (key)
484  {
485  anims[QString(key)].append(QString(art->item->name) + " (arch)");
486  }
487  }
488  }
489  }
490 
491  getManager()->quests()->each([&] (auto quest) {
492  if (quest->face != nullptr)
493  {
494  faces[quest->face->name].append(QString(quest->quest_code) + " (quest)");
495  }
496  });
497 
499  {
500  if (message->face != nullptr)
501  {
502  faces[message->face->name].append(QString(message->identifier) + " (message)");
503  }
504  });
505 
506  for (const auto map : myMapManager->allMaps())
507  {
508  for (const auto face : map->faces())
509  {
510  faces[face].append(QString(map->path()) + " (map)");
511  }
512  for (const auto animation : map->animations())
513  {
514  anims[animation].append(map->path() + " (map)");
515  }
516  }
517 
518  QString report("<p><strong>Warning:</strong> this list doesn't take into account faces for all artifacts, especially the 'animation_suffix' ones.</p><h1>Faces used multiple times:</h1><ul>");
519 
520  QStringList keys = faces.keys();
521  keys.sort();
522  foreach(QString name, keys)
523  {
524  if (faces[name].size() <= 1 || name.compare("blank.111") == 0)
525  continue;
526 
527  faces[name].sort();
528  report += "<li>" + name + ": ";
529  report += faces[name].join(", ");
530  report += "</li>";
531  }
532 
533  report += "</ul>";
534 
535  report += "<h1>Unused faces:</h1><ul>";
536  getManager()->faces()->each([&faces, &report] (const auto face)
537  {
538  if (faces[face->name].size() > 0)
539  return;
540  report += QString("<li>") + face->name + "</li>";
541  });
542  report += "</ul>";
543 
544  report += "<h1>Animations used multiple times:</h1><ul>";
545  keys = anims.keys();
546  keys.sort();
547  foreach(QString name, keys)
548  {
549  if (anims[name].size() <= 1)
550  continue;
551 
552  anims[name].sort();
553  report += "<li>" + name + ": ";
554  report += anims[name].join(", ");
555  report += "</li>";
556  }
557  report += "</ul>";
558 
559  report += "<h1>Unused animations:</h1><ul>";
560  getManager()->animations()->each([&anims, &report] (const auto anim)
561  {
562  if (anims[anim->name].size() > 0 || !strcmp(anim->name, "###none"))
563  return;
564  report += QString("<li>") + anim->name + "</li>";
565  });
566  report += "</ul>";
567 
568  // Find faces used for an object having an animation not including this face
569  report += "<h1>Objects having a face not part of their animation:</h1><ul>";
570 
572  // if there is an animation, don't consider the face, since it's part of the animation anyway (hopefully)
573  if (arch->clone.animation == NULL || arch->clone.face == NULL) {
574  return;
575  }
576  bool included = false;
577  for (int f = 0; f < arch->clone.animation->num_animations && !included; f++) {
578  if (arch->clone.animation->faces[f] == arch->clone.face) {
579  included = true;
580  }
581  }
582  if (!included) {
583  report += QString("<li>%1 (%2) has face %3 not in animation %4</li>\n").arg(arch->name, arch->clone.name, arch->clone.face->name, arch->clone.animation->name);
584  }
585  });
586 
587  CREReportDisplay show(report, "Faces and animations report");
588  show.exec();
589 }
590 
592 {
593  QStringList spell;
594  QList<QStringList> damage;
595 
596  object* caster = create_archetype("orc");
597 
598  getManager()->archetypes()->each([&caster, &spell, &damage] (archetype *arch)
599  {
600  if (arch->clone.type == SPELL && arch->clone.subtype == SP_BULLET && arch->clone.skill && strcmp(arch->clone.skill, "praying") == 0)
601  {
602  spell.append(arch->clone.name);
603  QStringList dam;
604  for (int l = 0; l < settings.max_level; l++)
605  {
606  caster->level = l;
607  int dm = arch->clone.stats.dam + SP_level_dam_adjust(caster, &arch->clone);
608  int cost = SP_level_spellpoint_cost(caster, &arch->clone, SPELL_GRACE);
609  dam.append(tr("%1 [%2]").arg(dm).arg(cost));
610  }
611  damage.append(dam);
612  }
613  });
614 
616 
617  QString report("<table><thead><tr><th>level</th>");
618 
619  for (int i = 0; i < spell.size(); i++)
620  {
621  report += "<th>" + spell[i] + "</th>";
622  }
623 
624  report += "</tr></thead><tbody>";
625 
626  for (int l = 0; l < settings.max_level; l++)
627  {
628  report += "<tr><td>" + QString::number(l) + "</td>";
629  for (int s = 0; s < spell.size(); s++)
630  report += "<td>" + damage[s][l] + "</td>";
631  report += "</tr>";
632  }
633 
634  report += "</tbody></table>";
635 
636  CREReportDisplay show(report, "Spell damage");
637  show.exec();
638 }
639 
640 static QString alchemyTable(const QString& skill, QStringList& noChance, std::vector<std::pair<QString, int>> &allIngredients)
641 {
642  int count = 0;
643 
644  QHash<int, QStringList> recipes;
645 
646  const recipelist* list;
647  const recipe* recipe;
648 
649  for (int ing = 1; ; ing++)
650  {
651  list = get_formulalist(ing);
652  if (!list)
653  break;
654 
655  for (recipe = list->items; recipe; recipe = recipe->next)
656  {
657  if (skill == recipe->skill)
658  {
659  if (recipe->arch_names == 0)
660  // hu?
661  continue;
662 
664  if (arch == NULL) {
665  continue;
666  }
667 
668  QString name;
669  if (strcmp(recipe->title, "NONE") == 0)
670  {
671  if (arch->clone.title == NULL)
672  name = arch->clone.name;
673  else
674  name = QString("%1 %2").arg(arch->clone.name, arch->clone.title);
675  }
676  else
677  {
678  name = QString("%1 of %2").arg(arch->clone.name, recipe->title);
679  }
680 
681  QStringList ingredients;
682  for (const linked_char* ingred = recipe->ingred; ingred != NULL; ingred = ingred->next)
683  {
684  ingredients.append(ingred->name);
685  const char* name = ingred->name;
686  if (isdigit(ingred->name[0])) {
687  name = strchr(ingred->name, ' ') + 1;
688  }
689  auto ing = std::find_if(allIngredients.begin(), allIngredients.end(), [&] (auto i) { return i.first == name; } );
690  if (ing != allIngredients.end()) {
691  (*ing).second++;
692  } else {
693  allIngredients.push_back(std::make_pair(name, 1));;
694  }
695  }
696 
697  recipes[recipe->diff].append(QString("<tr><td>%1</td><td>%2</td><td>%3</td><td>%4</td><td>%5</td></tr>").arg(name).arg(recipe->diff).arg(recipe->ingred_count).arg(recipe->exp).arg(ingredients.join(", ")));
698  count++;
699 
700  if (recipe->chance == 0) {
701  noChance.append(name);
702  }
703  }
704  }
705  }
706 
707  if (count == 0)
708  return QString();
709 
710  QString report = QString("<h2>%1 (%2 recipes)</h2><table><thead><tr><th>product</th><th>difficulty</th><th>ingredients count</th><th>experience</th><th>Ingredients</th>").arg(skill).arg(count);
711  report += "</tr></thead><tbody>";
712 
713  QList<int> difficulties = recipes.keys();
714  qSort(difficulties);
715  foreach(int difficulty, difficulties)
716  {
717  QStringList line = recipes[difficulty];
718  qSort(line);
719  report += line.join("\n");
720  }
721 
722  report += "</tbody></table>";
723 
724  return report;
725 }
726 
727 static void doIngredients(const std::vector<std::pair<QString, int>> &allIngredients, const QString &criteria, QString &report) {
728  report += QString("<h1>All items used as ingredients (%1)</h1>").arg(criteria);
729  report += "<ul>";
730  for (auto ing : allIngredients) {
731  report += QString("<li>%1 (%2 recipes)</li>").arg(ing.first).arg(ing.second);
732  }
733  report += "</ul>";
734 }
735 
737 {
738  QStringList skills;
739 
740  getManager()->archetypes()->each([&skills] (const auto arch)
741  {
742  if (arch->clone.type == SKILL)
743  skills.append(arch->clone.name);
744  });
745  skills.sort();
746 
747  QString report("<h1>Alchemy formulae</h1>");
748  QStringList noChance;
749  std::vector<std::pair<QString, int>> allIngredients;
750 
751  foreach(const QString skill, skills)
752  {
753  report += alchemyTable(skill, noChance, allIngredients);
754  }
755 
756  qSort(noChance);
757  report += tr("<h1>Formulae with chance of 0</h1>");
758  report += "<table><th>";
759  foreach(const QString& name, noChance) {
760  report += "<tr><td>" + name + "</td></tr>";
761  }
762  report += "</th></table>";
763 
764  std::sort(allIngredients.begin(), allIngredients.end(), [] (auto i1, auto i2) {
765  return i1.first.toLower() < i2.first.toLower();
766  });
767  doIngredients(allIngredients, "alphabetical order", report);
768 
769  std::sort(allIngredients.begin(), allIngredients.end(), [] (auto i1, auto i2) {
770  if (i1.second == i2.second) {
771  return i1.first.toLower() < i2.first.toLower();
772  }
773  return i1.second > i2.second;
774  });
775  doIngredients(allIngredients, "count of uses", report);
776 
777  CREReportDisplay show(report, "Alchemy formulae");
778  show.exec();
779 }
780 
782 {
783  QString output = QFileDialog::getSaveFileName(this, tr("Destination file"), "", tr("Dot files (*.dot);;All files (*.*)"));
784  if (output.isEmpty()) {
785  return;
786  }
787 
788  QFile file(output);
789  if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
790  QMessageBox::critical(this, "Write error", tr("Unable to write to %1").arg(output));
791  return;
792  }
793  QTextStream out(&file);
794 
795  out << "digraph alchemy {\n";
796 
797  QVector<const recipe*> recipes;
798  QHash<const recipe*, QString> names;
799  QHash<QString, QVector<const recipe*> > products;
800 
801  for (int ing = 1; ; ing++)
802  {
803  const recipelist* list = get_formulalist(ing);
804  if (!list)
805  break;
806 
807  for (const recipe* recipe = list->items; recipe; recipe = recipe->next)
808  {
809  QString product("???");
810  for (size_t idx = 0; idx < recipe->arch_names; idx++) {
811  auto arch = getManager()->archetypes()->find(recipe->arch_name[idx]);
812  if (!arch) {
813  continue;
814  }
815  if (recipe->title && strcmp(recipe->title, "NONE")) {
816  product = tr("%1 of %2").arg(arch->clone.name, recipe->title);
817  } else {
818  product = arch->clone.name;
819  }
820  products[product].append(recipe);
821  }
822  names[recipe] = product;
823  recipes.append(recipe);
824  }
825  }
826 
827  QHash<const recipe*, bool> added;
828 
829  foreach (const recipe* rec, recipes) {
830  for (linked_char* ing = rec->ingred; ing; ing = ing->next) {
831  const char* name = ing->name;
832  if (isdigit(name[0]) && strchr(name, ' ')) {
833  name = strchr(name, ' ') + 1;
834  }
835  QHash<QString, QVector<const recipe*> >::iterator item = products.find(name);
836  if (item != products.end()) {
837  if (!added[rec]) {
838  out << tr("alchemy_%1 [label=\"%2\"]\n").arg(recipes.indexOf(rec)).arg(names[rec]);
839  added[rec] = true;
840  }
841  for (auto r = item->begin(); r != item->end(); r++) {
842  if (!added[*r]) {
843  out << tr("alchemy_%1 [label=\"%2\"]\n").arg(recipes.indexOf(*r)).arg(names[*r]);
844  added[*r] = true;
845  }
846  out << tr("alchemy_%1 -> alchemy_%2\n").arg(recipes.indexOf(*r)).arg(recipes.indexOf(rec));
847  }
848  }
849  }
850  }
851 
852  int ignored = 0;
853  foreach (const recipe* rec, recipes) {
854  if (!added[rec]) {
855  ignored++;
856  }
857  }
858  out << "graph [labelloc=\"b\" labeljust=\"c\" label=\"Alchemy graph, formulae producing ingredients of other formulae";
859  if (ignored) {
860  out << tr(" (%1 formulae not displayed)").arg(ignored);
861  }
862  out << "\"]\n";
863 
864  out << "}\n";
865 }
866 
867 static QString spellsTable(const QString& skill)
868 {
869  bool one = false;
870 
871  QString report = QString("<h2>%1</h2><table><thead><tr><th>Spell</th><th>Level</th><th>Path</th>").arg(skill);
872  report += "</tr></thead><tbody>";
873 
874  QHash<int, QStringList> spells;
875 
876  getManager()->archetypes()->each([&skill, &spells, &one] (const archetype *spell) {
877  if (spell->clone.type == SPELL && spell->clone.skill == skill)
878  {
879  auto buf = stringbuffer_finish(describe_spellpath_attenuation(nullptr, spell->clone.path_attuned, nullptr));
880  spells[spell->clone.level].append(QString("<tr><td>%1</td><td>%2</td><td>%3</td></tr>").arg(spell->clone.name).arg(spell->clone.level).arg(buf));
881  free(buf);
882  one = true;
883  }
884  });
885 
886  if (!one)
887  return QString();
888 
889  QList<int> levels = spells.keys();
890  qSort(levels);
891  foreach(int level, levels)
892  {
893  spells[level].sort();
894  report += spells[level].join("\n");
895  }
896 
897  report += "</tbody></table>";
898 
899  return report;
900 }
901 
903 {
904  QStringList skills;
905 
906  getManager()->archetypes()->each([&skills] (const archetype *arch)
907  {
908  if (arch->clone.type == SKILL)
909  skills.append(arch->clone.name);
910  });
911 
912  skills.sort();
913 
914  QString report("<h1>Spell list</h1>");
915 
916  foreach(const QString skill, skills)
917  {
918  report += spellsTable(skill);
919  }
920 
921  CREReportDisplay show(report, "Spell list");
922  show.exec();
923 }
924 
934 static int monsterFight(archetype* monster, archetype* skill, int level)
935 {
936  int limit = 50, result = 1;
937  player pl;
938  socket_struct sock;
939  memset(&pl, 0, sizeof(player));
940  memset(&sock, 0, sizeof(sock));
941  strncpy(pl.savebed_map, "/HallOfSelection", MAX_BUF);
942  pl.bed_x = 5;
943  pl.bed_y = 5;
944  pl.socket = &sock;
945  std::unique_ptr<uint8_t[]> faces(new uint8_t[get_faces_count()]);
946  sock.faces_sent = faces.get();
947 
948  archetype *dwarf_player_arch = find_archetype("dwarf_player");
949  if (dwarf_player_arch == NULL) {
950  return 0;
951  }
952  object* obfirst = object_create_arch(dwarf_player_arch);
953  obfirst->level = level;
954  obfirst->contr = &pl;
955  pl.ob = obfirst;
956  object* obskill = object_create_arch(skill);
957  obskill->level = level;
958  SET_FLAG(obskill, FLAG_APPLIED);
959  object_insert_in_ob(obskill, obfirst);
960  archetype *skill_arch = find_archetype((skill->clone.subtype == SK_TWO_HANDED_WEAPON) ? "sword_3" : "sword");
961  if (skill_arch == NULL) {
962  return 0;
963  }
964  object* sword = object_create_arch(skill_arch);
965  SET_FLAG(sword, FLAG_APPLIED);
966  object_insert_in_ob(sword, obfirst);
967  fix_object(obfirst);
968  obfirst->stats.hp = obfirst->stats.maxhp;
969 
970  object* obsecond = object_create_arch(monster);
971  tag_t tagfirst = obfirst->count;
972  tag_t tagsecond = obsecond->count;
973 
974  // make a big map so large monsters are ok in map
975  mapstruct* test_map = get_empty_map(50, 50);
976 
977  obfirst = object_insert_in_map_at(obfirst, test_map, NULL, 0, 0, 0);
978  obsecond = object_insert_in_map_at(obsecond, test_map, NULL, 0, 1 + monster->tail_x, monster->tail_y);
979 
980  if (!obsecond || object_was_destroyed(obsecond, tagsecond))
981  {
982  qDebug() << "second removed??";
983  }
984 
985  while (limit-- > 0 && obfirst->stats.hp >= 0 && obsecond->stats.hp >= 0)
986  {
987  if (obfirst->weapon_speed_left > 0) {
988  --obfirst->weapon_speed_left;
989  do_some_living(obfirst);
990 
991  move_player(obfirst, 3);
992  if (object_was_destroyed(obsecond, tagsecond))
993  break;
994 
995  /* the player may have been killed (acid for instance), so check here */
996  if (object_was_destroyed(obfirst, tagfirst) || (obfirst->map != test_map))
997  {
998  result = 0;
999  break;
1000  }
1001  }
1002 
1003  if (obsecond->speed_left > 0) {
1004  --obsecond->speed_left;
1005  monster_do_living(obsecond);
1006 
1007  attack_ob(obfirst, obsecond);
1008  /* when player is killed, she is teleported to bed of reality -> check map */
1009  if (object_was_destroyed(obfirst, tagfirst) || (obfirst->map != test_map))
1010  {
1011  result = 0;
1012  break;
1013  }
1014  }
1015 
1016  obfirst->weapon_speed_left += obfirst->weapon_speed;
1017  if (obfirst->weapon_speed_left > 1.0)
1018  obfirst->weapon_speed_left = 1.0;
1019  if (obsecond->speed_left <= 0)
1020  obsecond->speed_left += FABS(obsecond->speed);
1021  }
1022 
1023  if (!object_was_destroyed(obfirst, tagfirst))
1024  {
1025  object_remove(obfirst);
1027  }
1028  if (!object_was_destroyed(obsecond, tagsecond))
1029  {
1030  object_remove(obsecond);
1032  }
1034 
1035  return result;
1036 }
1037 
1048 static int monsterFight(archetype* monster, archetype* skill, int level, int count)
1049 {
1050  int victory = 0;
1051  while (count-- > 0)
1052  victory += monsterFight(monster, skill, level);
1053 
1054  return victory;
1055 }
1056 
1066 static QString monsterFight(archetype* monster, archetype* skill)
1067 {
1068  qDebug() << "monsterFight:" << monster->clone.name << skill->clone.name;
1069  int ret, min = settings.max_level + 1, half = settings.max_level + 1, count = 5, level;
1070  int first = 1, max = settings.max_level;
1071 
1072  while (first != max)
1073  {
1074  level = (max + first) / 2;
1075  if (level < first)
1076  level = first;
1077  if (first > max)
1078  first = max;
1079 
1080  ret = monsterFight(monster, skill, level, count);
1081  if (ret > 0)
1082  {
1083  if (level < min)
1084  min = level;
1085  if (ret > (count / 2) && (level < half))
1086  half = level;
1087 
1088  max = level;
1089  }
1090  else
1091  {
1092  if (first == level)
1093  break;
1094  first = level;
1095  }
1096  }
1097 
1098  //qDebug() << " result:" << min << half;
1099 
1100  // if player was killed, then HallOfSelection was loaded, so clean it now.
1101  // This speeds up various checks, like in free_all_objects().
1102  mapstruct* hos = has_been_loaded("/HallOfSelection");
1103  if (hos)
1104  {
1105  hos->reset_time = 1;
1106  hos->in_memory = MAP_IN_MEMORY;
1107  delete_map(hos);
1108  }
1109  /*
1110  extern int nroffreeobjects;
1111  extern int nrofallocobjects;
1112  qDebug() << "free: " << nroffreeobjects << ", all: " << nrofallocobjects;
1113  */
1114 
1115  if (min == settings.max_level + 1)
1116  return "<td colspan=\"2\">-</td>";
1117  return "<td>" + QString::number(min) + "</td><td>" + ((half != 0) ? QString::number(half) : "") + "</td>";
1118 }
1119 
1126 static QString monsterTable(archetype* monster, QList<archetype*> skills)
1127 {
1128  QString line = "<tr>";
1129 
1130  line += "<td>" + QString(monster->clone.name) + "</td>";
1131  line += "<td>" + QString::number(monster->clone.level) + "</td>";
1132  line += "<td>" + QString::number(monster->clone.speed) + "</td>";
1133  line += "<td>" + QString::number(monster->clone.stats.wc) + "</td>";
1134  line += "<td>" + QString::number(monster->clone.stats.dam) + "</td>";
1135  line += "<td>" + QString::number(monster->clone.stats.ac) + "</td>";
1136  line += "<td>" + QString::number(monster->clone.stats.hp) + "</td>";
1137  line += "<td>" + QString::number(monster->clone.stats.Con) + "</td>";
1138 
1139  foreach(archetype* skill, skills)
1140  {
1141  line += monsterFight(monster, skill);
1142  }
1143  line += "</tr>\n";
1144 
1145  return line;
1146 }
1147 
1153 {
1154  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1155 
1156  QStringList names;
1157  QMap<QString, archetype*> monsters;
1158  QList<archetype*> skills;
1159 
1160  getManager()->archetypes()->each([&names, &monsters, &skills] (archetype *arch)
1161  {
1162  if (QUERY_FLAG(&arch->clone, FLAG_MONSTER) && arch->clone.stats.hp > 0 && arch->head == NULL)
1163  {
1164  QString name(QString(arch->clone.name).toLower());
1165  if (monsters.contains(name))
1166  {
1167  int suffix = 1;
1168  do
1169  {
1170  name = QString(arch->clone.name).toLower() + "_" + QString::number(suffix);
1171  suffix++;
1172  } while (monsters.contains(name));
1173  }
1174 
1175  monsters[name] = arch;
1176  }
1177  if (arch->clone.type == SKILL && IS_COMBAT_SKILL(arch->clone.subtype))
1178  {
1179  if (strcmp(arch->name, "skill_missile_weapon") == 0 || strcmp(arch->name, "skill_throwing") == 0)
1180  return;
1181  skills.append(arch);
1182  }
1183  });
1184 
1185  names = monsters.keys();
1186  names.sort();
1187 
1188  QString report(tr("<h1>Player vs monsters</h1><p><strong>fv</strong> is the level at which the first victory happened, <strong>hv</strong> is the level at which at least 50% of fights were victorious.</p>\n")), line;
1189  report += "<table border=\"1\"><tbody>\n";
1190  report += "<tr>";
1191  report += "<th rowspan=\"2\">Monster</th>";
1192  report += "<th rowspan=\"2\">level</th>";
1193  report += "<th rowspan=\"2\">speed</th>";
1194  report += "<th rowspan=\"2\">wc</th>";
1195  report += "<th rowspan=\"2\">dam</th>";
1196  report += "<th rowspan=\"2\">ac</th>";
1197  report += "<th rowspan=\"2\">hp</th>";
1198  report += "<th rowspan=\"2\">regen</th>";
1199 
1200  line = "<tr>";
1201  foreach(archetype* skill, skills)
1202  {
1203  report += "<th colspan=\"2\">" + QString(skill->clone.name) + "</th>";
1204  line += "<th>fv</th><th>hv</th>";
1205  }
1206  report += "</tr>\n" + line + "</tr>\n";
1207 
1208  int limit = 500;
1209  foreach(const QString name, names)
1210  {
1211  report += monsterTable(monsters[name], skills);
1212  if (limit-- <= 0)
1213  break;
1214  }
1215 
1216  report += "</tbody></table>\n";
1217 
1218  CREReportDisplay show(report, "Player vs monsters (hand to hand)");
1219  QApplication::restoreOverrideCursor();
1220  show.exec();
1221 }
1222 
1223 static QString reportSummon(const archetype* summon, const object* other, QString name)
1224 {
1225  QString report;
1226  int level, wc_adj = 0;
1227 
1228  const object* spell = &summon->clone;
1229  sstring rate = object_get_value(spell, "wc_increase_rate");
1230  if (rate != NULL) {
1231  wc_adj = atoi(rate);
1232  }
1233 
1234  // hp, dam, speed, wc
1235 
1236  QString ac("<tr><td>ac</td>");
1237  QString hp("<tr><td>hp</td>");
1238  QString dam("<tr><td>dam</td>");
1239  QString speed("<tr><td>speed</td>");
1240  QString wc("<tr><td>wc</td>");
1241  int ihp, idam, iwc, diff;
1242  float fspeed;
1243 
1244  for (level = 1; level < 120; level += 10)
1245  {
1246  if (level < spell->level)
1247  {
1248  ac += "<td></td>";
1249  hp += "<td></td>";
1250  dam += "<td></td>";
1251  speed += "<td></td>";
1252  wc += "<td></td>";
1253  continue;
1254  }
1255 
1256  diff = level - spell->level;
1257 
1258  ihp = other->stats.hp + spell->duration + (spell->duration_modifier != 0 ? (diff / spell->duration_modifier) : 0);
1259  idam = (spell->stats.dam ? spell->stats.dam : other->stats.dam) + (spell->dam_modifier != 0 ? (diff / spell->dam_modifier) : 0);
1260  fspeed = MIN(1.0, FABS(other->speed) + .02 * (spell->range_modifier != 0 ? (diff / spell->range_modifier) : 0));
1261  iwc = other->stats.wc;
1262  if (wc_adj > 0)
1263  iwc -= (diff / wc_adj);
1264 
1265  ac += "<td>" + QString::number(other->stats.ac) + "</td>";
1266  hp += "<td>" + QString::number(ihp) + "</td>";
1267  dam += "<td>" + QString::number(idam) + "</td>";
1268  speed += "<td>" + QString::number(fspeed) + "</td>";
1269  wc += "<td>" + QString::number(iwc) + "</td>";
1270  }
1271 
1272  report += "<tr><td colspan=\"13\"><strong>" + name + "</strong></td></tr>\n";
1273 
1274  report += ac + "</tr>\n" + hp + "</tr>\n" + dam + "</tr>\n" + speed + "</tr>\n" + wc + "</tr>\n\n";
1275 
1276  return report;
1277 }
1278 
1280 {
1281  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1282 
1283  int level;
1284 
1285  QString report(tr("<h1>Summoned pet statistics</h1>\n")), line;
1286  report += "<table border=\"1\">\n<thead>\n";
1287  report += "<tr>";
1288  report += "<th rowspan=\"2\">Spell</th>";
1289  report += "<th colspan=\"12\">Level</th>";
1290  report += "</tr>\n";
1291  report += "<tr>";
1292 
1293  for (level = 1; level < 120; level += 10)
1294  {
1295  report += "<th>" + QString::number(level) + "</th>";
1296  }
1297  report += "</tr>\n</thead>\n<tbody>\n";
1298 
1299  QMap<QString, QString> spells;
1300 
1301  getManager()->archetypes()->each([&spells] (archetype *summon)
1302  {
1303  if (summon->clone.type != SPELL || summon->clone.subtype != SP_SUMMON_GOLEM)
1304  return;
1305  if (summon->clone.other_arch != NULL)
1306  {
1307  spells[summon->clone.name] = reportSummon(summon, &summon->clone.other_arch->clone, QString(summon->clone.name));
1308  return;
1309  }
1310 
1311  // god-based summoning
1312  getManager()->archetypes()->each([&summon, &spells] (archetype *god)
1313  {
1314  if (god->clone.type != GOD)
1315  return;
1316 
1317  QString name(QString(summon->clone.name) + " (" + QString(god->name) + ")");
1318  archetype* holy = determine_holy_arch(&god->clone, summon->clone.race);
1319  if (holy == NULL)
1320  return;
1321 
1322  spells[name] = reportSummon(summon, &holy->clone, name);
1323  });
1324  });
1325 
1326  QStringList keys = spells.keys();
1327  keys.sort();
1328  foreach(QString key, keys)
1329  {
1330  report += spells[key];
1331  }
1332 
1333  report += "</tbody>\n</table>\n";
1334 
1335  CREReportDisplay show(report, "Summoned pet statistics");
1336  QApplication::restoreOverrideCursor();
1337  show.exec();
1338 }
1339 
1340 static QString buildShopReport(const QString& title, const QStringList& types, const QList<CREMapInformation*>& maps, QStringList& items)
1341 {
1342  QString report("<h2>" + title + "</h2>");
1343  report += "<table border=\"1\">\n<thead>\n";
1344  report += "<tr>";
1345  report += "<th>Shop</th>";
1346  report += "<th>Greed</th>";
1347  report += "<th>Race</th>";
1348  report += "<th>Min</th>";
1349  report += "<th>Max</th>";
1350  foreach (QString item, types)
1351  {
1352  report += "<th>" + item + "</th>";
1353  items.removeAll(item);
1354  }
1355  report += "</tr>\n</thead><tbody>";
1356 
1357  foreach(const CREMapInformation* map, maps)
1358  {
1359  QString line;
1360  bool keep = false;
1361 
1362  if (map->shopItems().size() == 0)
1363  continue;
1364 
1365  line += "<tr>";
1366 
1367  line += "<td>" + map->name() + " " + map->path() + "</td>";
1368  line += "<td>" + QString::number(map->shopGreed()) + "</td>";
1369  line += "<td>" + map->shopRace() + "</td>";
1370  line += "<td>" + (map->shopMin() != 0 ? QString::number(map->shopMin()) : "") + "</td>";
1371  line += "<td>" + (map->shopMax() != 0 ? QString::number(map->shopMax()) : "") + "</td>";
1372 
1373  foreach(const QString item, types)
1374  {
1375  if (map->shopItems()[item] == 0)
1376  {
1377  if (map->shopItems()["*"] == 0)
1378  line += "<td></td>";
1379  else
1380  line += "<td>" + QString::number(map->shopItems()["*"]) + "</td>";
1381  continue;
1382  }
1383  keep = true;
1384  line += "<td>" + QString::number(map->shopItems()[item]) + "</td>";
1385  }
1386 
1387  line += "</tr>";
1388  if (keep)
1389  report += line;
1390  }
1391 
1392  report += "</tbody></table>";
1393  return report;
1394 }
1395 
1397 {
1398  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1399 
1400  QString report(tr("<h1>Shop information</h1>\n"));
1401 
1402  QList<CREMapInformation*> maps = myMapManager->allMaps();
1403  QStringList items;
1404  foreach(const CREMapInformation* map, maps)
1405  {
1406  QStringList add = map->shopItems().keys();
1407  foreach(const QString item, add)
1408  {
1409  if (!items.contains(item))
1410  items.append(item);
1411  }
1412  }
1413  qSort(items);
1414 
1415  QStringList part;
1416 
1417  part << "weapon" << "weapon improver" << "bow" << "arrow";
1418  report += buildShopReport("Weapons", part, maps, items);
1419 
1420  part.clear();
1421  part << "armour" << "armour improver" << "boots" << "bracers" << "cloak" << "girdle" << "gloves" << "helmet" << "shield";
1422  report += buildShopReport("Armour", part, maps, items);
1423 
1424  part.clear();
1425  part << "amulet" << "potion" << "power_crystal" << "ring" << "rod" << "scroll" << "skillscroll" << "spellbook" << "wand";
1426  report += buildShopReport("Magical", part, maps, items);
1427 
1428  part.clear();
1429  part << "container" << "food" << "key" << "lamp" << "skill tool" << "special key";
1430  report += buildShopReport("Equipment", part, maps, items);
1431 
1432  if (!items.isEmpty())
1433  {
1434 
1435  part = items;
1436  report += buildShopReport("Others", part, maps, items);
1437  }
1438 
1439  CREReportDisplay show(report, "Shop information");
1440  QApplication::restoreOverrideCursor();
1441  show.exec();
1442 }
1443 
1444 void readDirectory(const QString& path, QHash<QString, QHash<QString, bool> >& states)
1445 {
1446  QDir dir(path);
1447  QStringList subdirs = dir.entryList(QStringList("*"), QDir::Dirs | QDir::NoDotAndDotDot);
1448  foreach(QString subdir, subdirs)
1449  {
1450  readDirectory(path + QDir::separator() + subdir, states);
1451  }
1452 
1453  QStringList quests = dir.entryList(QStringList("*.quest"), QDir::Files);
1454  foreach(QString file, quests)
1455  {
1456  qDebug() << "read quest:" << path << file;
1457  QString name = file.left(file.length() - 6);
1458  QFile read(path + QDir::separator() + file);
1459  read.open(QFile::ReadOnly);
1460  QTextStream stream(&read);
1461  QString line, code;
1462  bool completed;
1463  while (!(line = stream.readLine(0)).isNull())
1464  {
1465  if (line.startsWith("quest "))
1466  {
1467  code = line.mid(6);
1468  completed = false;
1469  continue;
1470  }
1471  if (code.isEmpty())
1472  continue;
1473  if (line == "end_quest")
1474  {
1475  states[code][name] = completed;
1476  code.clear();
1477  continue;
1478  }
1479  if (line.startsWith("state "))
1480  continue;
1481  if (line == "completed 1")
1482  completed = true;
1483  }
1484  }
1485 }
1486 
1488 {
1489  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1490 
1491  QHash<QString, QHash<QString, bool> > states;
1492  QString directory(settings.localdir);
1493  directory += QDir::separator();
1494  directory += settings.playerdir;
1495  readDirectory(directory, states);
1496 
1497  QStringList codes;
1498  getManager()->quests()->each([&] (const auto quest) {
1499  codes.append(quest->quest_code);
1500  });
1501 
1502  QString report("<html><body>\n<h1>Quests</h1>\n");
1503 
1504  QStringList keys = states.keys();
1505  keys.sort();
1506 
1507  foreach(QString key, keys)
1508  {
1509  codes.removeAll(key);
1510  const auto quest = getManager()->quests()->get(key.toStdString());
1511  report += "<h2>Quest: " + (quest != NULL ? quest->quest_title : (key + " ???")) + "</h2>\n";
1512  report += "<p>";
1513  QHash<QString, bool> done = states[key];
1514  QStringList players = done.keys();
1515  players.sort();
1516  int completed = 0;
1517  QString sep;
1518  foreach(QString player, players)
1519  {
1520  report += sep;
1521  sep = ", ";
1522  if (done[player])
1523  {
1524  completed++;
1525  report += "<strong>" + player + "</strong>";
1526  }
1527  else
1528  {
1529  report += player;
1530  }
1531  }
1532  report += "</p>\n";
1533  report += "<p>" + tr("%1 completed out of %2 (%3%)").arg(completed).arg(players.size()).arg(completed * 100 / players.size()) + "</p>\n";
1534  }
1535 
1536  if (codes.length() > 0)
1537  {
1538  codes.sort();
1539  QString sep;
1540  report += "<h2>Quests never done</h2>\n<p>\n";
1541  foreach(QString code, codes)
1542  {
1543  report += sep;
1544  sep = ", ";
1545  const auto quest = getManager()->quests()->find(code.toStdString());
1546  report += (quest != NULL ? quest->quest_title : (code + " ???"));
1547  }
1548  report += "</p>\n";
1549  }
1550 
1551  report += "</body>\n</html>\n";
1552 
1553  CREReportDisplay show(report, "Quests report");
1554  QApplication::restoreOverrideCursor();
1555  show.exec();
1556 }
1557 
1559 {
1560  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1561 
1562  QString report;
1563  report += "<html>";
1564 
1565  report += "<h1>Materials</h1>";
1566  report += "<table><tr><th>Name</th><th>Description</th></tr>";
1567  for (const auto &mat : materials) {
1568  report += tr("<tr><td>%1</td><td>%2</td></tr>").arg(mat->name, mat->description);
1569  }
1570  report += "</table>";
1571 
1572  for (int s = 0; s < 2; s++) {
1573  QString name(s == 0 ? "Saves" : "Resistances");
1574  report += tr("<h1>%1</h1>").arg(name);
1575  report += tr("<tr><th rowspan='2'>Name</th><th colspan='%1'>%2</th></tr>").arg(NROFATTACKS).arg(name);
1576  report += "<tr>";
1577  for (int r = 0; r < NROFATTACKS; r++) {
1578  report += "<th>" + QString(attacktype_desc[r]) + "</th>";
1579  }
1580  report += "</tr>";
1581 
1582  for (auto const &mat : materials) {
1583  report += tr("<tr><td>%1</td>").arg(mat->name);
1584  for (int r = 0; r < NROFATTACKS; r++) {
1585  int8_t val = (s == 0 ? mat->save[r] : mat->mod[r]);
1586  report += tr("<td>%1</td>").arg(val == 0 ? QString() : QString::number(val));
1587  }
1588  report += "</tr>";
1589  }
1590  report += "</table>";
1591  }
1592 
1593  report += "</html>";
1594 
1595  CREReportDisplay show(report, "Materials report");
1596  QApplication::restoreOverrideCursor();
1597  show.exec();
1598 }
1599 
1601 {
1602  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1603 
1604  QString report;
1605  report += "<html>";
1606 
1607  report += "<h1>Apparently unused archetypes</h1>";
1608  report += "<h3>Warning: this list contains skills, items on style maps, and other things which are actually used.</h3>";
1609  report += "<table>";
1610  report += "<tr><th>Image</th><th>Archetype name</th><th>Item name</th><th>Type</th></tr>";
1611 
1612  getManager()->archetypes()->each([this, &report] (const archetype* arch)
1613  {
1614  if (arch->head || arch->clone.type == PLAYER || arch->clone.type == MAP || arch->clone.type == EVENT_CONNECTOR)
1615  return;
1616  if (strstr(arch->name, "hpbar") != nullptr)
1617  return;
1618 
1619  bool used = false;
1621  (ArchetypeUse, const archetype*, const treasurelist*, const CREMapInformation*, const recipe*) -> bool
1622  {
1623  used = true;
1624  return false;
1625  });
1626 
1627  if (!used)
1628  {
1629  QImage image(CREPixmap::getIcon(arch->clone.face->number).pixmap(32,32).toImage());
1630  QByteArray byteArray;
1631  QBuffer buffer(&byteArray);
1632  image.save(&buffer, "PNG");
1633  QString iconBase64 = QString::fromLatin1(byteArray.toBase64().data());
1634  auto td = get_typedata(arch->clone.type);
1635  report += tr("<tr><td><img src='data:image/png;base64,%1'></td><td>%2</td><td>%3</td><td>%4</td></tr>")
1636  .arg(iconBase64, arch->name, arch->clone.name, td ? td->name : tr("unknown: %1").arg(arch->clone.type));
1637  }
1638  });
1639 
1640  report += "</table>";
1641  report += "</html>";
1642 
1643  CREReportDisplay show(report, "Unused archetypes report");
1644  QApplication::restoreOverrideCursor();
1645  show.exec();
1646 }
1647 
1649 {
1650  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1651 
1652  QString report;
1653  report += "<html>";
1654 
1655  auto all = myResourcesManager->licenseManager()->getAll();
1656  std::set<std::string> faces, facesets, fields;
1657 
1658  for (auto item : all)
1659  {
1660  faces.insert(item.first);
1661  for (auto fs : item.second)
1662  {
1663  facesets.insert(fs.first);
1664  for (auto items : fs.second)
1665  {
1666  fields.insert(items.first);
1667  }
1668  }
1669  }
1670 
1671  getManager()->facesets()->each([&facesets] (const face_sets *fs)
1672  {
1673  facesets.erase(fs->prefix);
1674  });
1675  getManager()->faces()->each([&faces] (const Face *face)
1676  {
1678  });
1679 
1680  if (facesets.empty())
1681  {
1682  report += "<h1>No invalid faceset</h1>\n";
1683  }
1684  else
1685  {
1686  report += "<h1>Invalid faceset found</h1>\n";
1687  report += "<p>The faceset of the license file doesn't match any defined facesets.</p>";
1688  report += "<ul>\n";
1689  for (auto fs : facesets)
1690  {
1691  report += "<li>" + QString(fs.c_str()) + "</li>\n";
1692  }
1693  report += "</ul>\n";
1694  }
1695 
1696  if (faces.empty())
1697  {
1698  report += "<h1>No invalid face name</h1>\n";
1699  }
1700  else
1701  {
1702  report += "<h1>Invalid face names found</h1>\n";
1703  report += "<p>The face name from the license file doesn't match any defined face.</p>";
1704  report += "<ul>\n";
1705  for (auto f : faces)
1706  {
1707  report += "<li>" + QString(f.c_str()) + "</li>\n";
1708  }
1709  report += "</ul>\n";
1710  }
1711 
1712  report += "<h1>All fields used in license descriptions</h1>\n";
1713  report += "<ul>\n";
1714  for (auto f : fields)
1715  {
1716  report += "<li>" + QString(f.c_str()) + "</li>\n";
1717  }
1718  report += "</ul>\n";
1719 
1720  report += "</html>";
1721  CREReportDisplay show(report, "Licenses checks");
1722  QApplication::restoreOverrideCursor();
1723  show.exec();
1724 }
1725 
1727 {
1728  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1729 
1730  QString report;
1731  report += "<html>";
1732 
1734  auto groupCmp = [] (const std::string &left, const std::string &right) { return left < right; };
1735  auto mapCmp = [] (const CREMapInformation *left, const CREMapInformation *right)
1736  {
1737  int name = left->name().compare(right->name());
1738  if (name != 0)
1739  {
1740  return name < 0;
1741  }
1742  return left->path().compare(right->path()) < 0;
1743  };
1744  std::map<std::string, std::vector<CREMapInformation *>, decltype(groupCmp)> groups(groupCmp);
1745 
1746  for (auto map : maps)
1747  {
1748  if (!map->resetGroup().isEmpty())
1749  {
1750  groups[map->resetGroup().toStdString()].push_back(map);
1751  }
1752  }
1753 
1754  if (groups.empty())
1755  {
1756  report += "<h1>No reset group defined</h1>\n";
1757  }
1758  else
1759  {
1760  for (auto group : groups)
1761  {
1762  report += "<h1>" + QString(group.first.c_str()) + " (" + QString::number(group.second.size()) + " maps)</h1>\n";
1763  report += "<ul>\n";
1764  std::sort(group.second.begin(), group.second.end(), mapCmp);
1765  for (auto map : group.second)
1766  {
1767  report += tr("<li>%1 (%2)</li>").arg(map->name(), map->path());
1768  }
1769  report += "</ul>\n";
1770  }
1771  }
1772 
1773  report += "</html>";
1774  CREReportDisplay show(report, "Map reset groups");
1775  QApplication::restoreOverrideCursor();
1776  show.exec();
1777 }
1778 
1780 {
1782  edit.exec();
1783 }
1784 
1786 {
1787  CRESmoothFaceMaker smooth;
1788  smooth.exec();
1789 }
1790 
1792 {
1793  CRECombatSimulator simulator;
1794  simulator.exec();
1795 }
1796 
1798 {
1799  CREHPBarMaker maker;
1800  maker.exec();
1801 }
1802 
1804 {
1805  FaceMakerDialog maker(this, myResourcesManager);
1806  maker.exec();
1807 }
1808 
1810 {
1811  QMessageBox confirm;
1812  confirm.setWindowTitle(tr("Crossfire Resource Editor"));
1813  confirm.setText(tr("Really clear map cache?"));
1814  confirm.setInformativeText(tr("This will force cache rebuild at next application start."));
1815  confirm.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
1816  confirm.setDefaultButton(QMessageBox::No);
1817  confirm.setIcon(QMessageBox::Question);
1818  if (confirm.exec() == QMessageBox::Yes)
1819  {
1821  }
1822 }
1823 
1825 {
1826  CREPixmap::setFaceset(action->data().toString());
1827 }
1828 
1830 {
1832 }
1833 
1835 {
1836  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
1840  QApplication::restoreOverrideCursor();
1841  QMessageBox::information(this, "Reload complete", "Assets reload complete, you may need to change the selected item to see updated versions.");
1842 }
1843 
1845 {
1847  QString dir = QFileDialog::getExistingDirectory(this, tr("Please select the 'sounds' directory"), settings.soundsDirectory());
1848  if (dir.isEmpty())
1849  return;
1850  settings.setSoundsDirectory(dir);
1851  SoundsDialog dlg(dir, this);
1852  dlg.exec();
1853 }
1854 
1856  auto windows = myArea->subWindowList();
1857  bool hasWindows = !windows.empty();
1858 
1859  while (myWindows->actions().size() > 6) {
1860  myWindows->removeAction(myWindows->actions()[6]);
1861  }
1862  for (auto a : myWindows->actions()) {
1863  if (a->isSeparator()) {
1864  a->setVisible(hasWindows);
1865  } else if (a != myWindows->actions()[0]) {
1866  a->setEnabled(hasWindows);
1867  }
1868  }
1869 
1870  for (int i = 0; i < windows.size(); ++i) {
1871  QMdiSubWindow *mdiSubWindow = windows.at(i);
1872 
1873  QString title(mdiSubWindow->widget()->windowTitle());
1874  if (i < 9) {
1875  title = tr("&%1 %2").arg(i + 1).arg(title);
1876  } else {
1877  title = tr("%1 %2").arg(i + 1).arg(title);
1878  }
1879  QAction *action = myWindows->addAction(title, mdiSubWindow, [this, mdiSubWindow] () {
1880  myArea->setActiveSubWindow(mdiSubWindow);
1881  });
1882  action->setCheckable(true);
1883  action ->setChecked(mdiSubWindow == myArea->activeSubWindow());
1884  }
1885 }
1886 
1888  auto reg = get_region_by_name(map->region().toLocal8Bit().data());
1889  map->setDisplayParent(myResourcesManager->wrap(reg, myAssets->regions()));
1890  for (auto rm : map->randomMaps()) {
1891  rm->setDisplayParent(myAssets->randomMaps());
1892  }
1893 }
object_was_destroyed
#define object_was_destroyed(op, old_tag)
Definition: object.h:70
Face::name
sstring name
Definition: face.h:19
ScriptFileManager
Definition: ScriptFileManager.h:26
CREPixmap::setFaceset
static void setFaceset(const QString &prefix)
Definition: CREPixmap.cpp:44
Face
Definition: face.h:14
MonsterResistances
Definition: MonsterResistances.h:24
object::weapon_speed_left
float weapon_speed_left
Definition: object.h:340
PLAYER
@ PLAYER
Definition: object.h:112
CREMainWindow::onSaveFormulae
void onSaveFormulae()
Definition: CREMainWindow.cpp:371
global.h
make_face_from_files.anims
list anims
Definition: make_face_from_files.py:59
AllAssets::randomMaps
AssetWrapper * randomMaps()
Definition: AllAssets.h:35
CREMainWindow::browsingMap
void browsingMap(const QString &path)
Definition: CREMainWindow.cpp:385
settings
struct Settings settings
Definition: init.cpp:139
object::range_modifier
uint8_t range_modifier
Definition: object.h:418
banquet.l
l
Definition: banquet.py:164
GeneralMessage
Definition: book.h:44
MAP
@ MAP
Definition: object.h:130
get_formulalist
recipelist * get_formulalist(int i)
Definition: recipe.cpp:98
CREMainWindow::closeEvent
void closeEvent(QCloseEvent *event)
Definition: CREMainWindow.cpp:112
ResourcesManager::licenseManager
LicenseManager * licenseManager()
Definition: ResourcesManager.h:153
living::maxhp
int16_t maxhp
Definition: living.h:41
CREMainWindow::onReportAlchemyGraph
void onReportAlchemyGraph()
Definition: CREMainWindow.cpp:781
Settings::max_level
int16_t max_level
Definition: global.h:302
CREMainWindow::myClearMapCache
QAction * myClearMapCache
Definition: CREMainWindow.h:66
ChangesDock.h
FABS
#define FABS(x)
Definition: define.h:22
CREMainWindow::onFiltersModified
void onFiltersModified()
Definition: CREMainWindow.cpp:397
maps
static std::unordered_map< std::string, mapzone * > maps
Definition: citylife.cpp:92
EVENT_CONNECTOR
@ EVENT_CONNECTOR
Definition: object.h:232
monsterFight
static int monsterFight(archetype *monster, archetype *skill, int level)
Definition: CREMainWindow.cpp:934
get_empty_map
mapstruct * get_empty_map(int sizex, int sizey)
Definition: map.cpp:842
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
test_map
mapstruct * test_map
Definition: comet_perf.cpp:74
AssetsManager::messages
Messages * messages()
Definition: AssetsManager.h:59
get_region_by_name
region * get_region_by_name(const char *region_name)
Definition: region.cpp:46
monsters
static std::vector< object * > monsters
Definition: readable.cpp:142
player
Definition: player.h:105
CREResourcesWindow
Definition: CREResourcesWindow.h:31
spellsTable
static QString spellsTable(const QString &skill)
Definition: CREMainWindow.cpp:867
ScriptFileManager.h
CREPixmap::setUseFacesetFallback
static void setUseFacesetFallback(bool use)
Definition: CREPixmap.cpp:52
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
MessageManager.h
recipe::arch_names
size_t arch_names
Definition: recipe.h:12
ResourcesManager
Definition: ResourcesManager.h:80
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
ResourcesManager::saveArchetypes
void saveArchetypes()
Definition: ResourcesManager.cpp:218
AssetsManager.h
has_been_loaded
mapstruct * has_been_loaded(const char *name)
Definition: map.cpp:79
socket_struct
Definition: newserver.h:89
CREMapInformationManager::start
void start()
Definition: CREMapInformationManager.cpp:86
types
type_definition ** types
Definition: gridarta-types-convert.cpp:56
Settings::datadir
const char * datadir
Definition: global.h:248
MessageManager::loadMessages
void loadMessages()
Definition: MessageManager.cpp:34
disinfect.a
a
Definition: disinfect.py:13
FaceMakerDialog.h
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:132
object::speed
float speed
Definition: object.h:337
if
if(!(yy_init))
Definition: loader.cpp:36428
cleanup
void cleanup(void)
Definition: server.cpp:1252
CREMapInformationManager::clearCache
void clearCache()
Definition: CREMapInformationManager.cpp:806
guildoracle.list
list
Definition: guildoracle.py:87
object::speed_left
float speed_left
Definition: object.h:338
report.report
def report(pl)
Definition: report.py:6
AssetsManager::animations
AllAnimations * animations()
Definition: AssetsManager.h:49
object::map
struct mapstruct * map
Definition: object.h:305
AssetWrapper::setDisplayParent
void setDisplayParent(AssetWrapper *parent)
Definition: AssetWrapper.h:47
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:65
CRESettings::storeWindowsState
bool storeWindowsState() const
Definition: CRESettings.cpp:120
CREMainWindow::createMenus
void createMenus()
Definition: CREMainWindow.cpp:207
ArchetypeUse
ArchetypeUse
Definition: ResourcesManager.h:66
root
static char root[500]
Definition: mapper.cpp:304
AllAssets.h
npc_dialog.player
player
Definition: npc_dialog.py:97
mad_mage_user.file
file
Definition: mad_mage_user.py:15
MIN
#define MIN(x, y)
Definition: compat.h:21
move_player
int move_player(object *op, int dir)
Definition: player.cpp:2948
hall_of_fame.keys
keys
Definition: hall_of_fame.py:43
SKILL
@ SKILL
Definition: object.h:148
object::count
tag_t count
Definition: object.h:307
monster_do_living
void monster_do_living(object *op)
Definition: monster.cpp:719
ResourcesManager::archetypeUse
static void archetypeUse(const archetype *item, CREMapInformationManager *store, AssetUseCallback callback)
Definition: ResourcesManager.cpp:138
fix_object
void fix_object(object *op)
Definition: living.cpp:1132
CREMapInformationManager::allMaps
QList< CREMapInformation * > allMaps()
Definition: CREMapInformationManager.cpp:374
AssetWrapper::displayName
QString displayName
Definition: AssetWrapper.h:29
recipe::arch_name
char ** arch_name
Definition: recipe.h:13
LicenseManager::reset
void reset()
Definition: LicenseManager.h:52
CREMainWindow::onSaveQuests
void onSaveQuests()
Definition: CREMainWindow.cpp:375
RandomMap.h
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
curse_on_apply.ac
ac
Definition: curse_on_apply.py:4
ResourcesManager::saveQuests
void saveQuests()
Definition: ResourcesManager.cpp:226
CREMainWindow::onReportMaterials
void onReportMaterials()
Definition: CREMainWindow.cpp:1558
materials
std::vector< materialtype_t * > materials
Definition: init.cpp:128
object_get_value
const char * object_get_value(const object *op, const char *const key)
Definition: object.cpp:4346
recipe::exp
int exp
Definition: recipe.h:17
FLAG_APPLIED
#define FLAG_APPLIED
Definition: define.h:235
object::level
int16_t level
Definition: object.h:361
AssetWrapper::tipProperty
static const char * tipProperty
Definition: AssetWrapper.h:34
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.cpp:2857
face_sets::prefix
char * prefix
Definition: image.h:19
AssetsCollection::find
T * find(const Key &name)
Definition: AssetsCollection.h:108
CREMainWindow::myMapBrowseStatus
QLabel * myMapBrowseStatus
Definition: CREMainWindow.h:68
CREMainWindow::onReportLicenses
void onReportLicenses()
Definition: CREMainWindow.cpp:1648
CREMapInformation::name
QString name
Definition: CREMapInformation.h:32
LicenseManager.h
CREMainWindow::onReportSpellDamage
void onReportSpellDamage()
Definition: CREMainWindow.cpp:591
linked_char
Definition: global.h:96
CREMainWindow::myResourcesManager
ResourcesManager * myResourcesManager
Definition: CREMainWindow.h:71
ResourcesManager::getMapInformationManager
CREMapInformationManager * getMapInformationManager()
Definition: ResourcesManager.h:91
ResourcesManager::saveArtifacts
void saveArtifacts()
Definition: ResourcesManager.cpp:265
quest
Definition: quest.py:1
CREMapInformation
Definition: CREMapInformation.h:27
CREMainWindow::onSaveMessages
void onSaveMessages()
Definition: CREMainWindow.cpp:380
MAP_IN_MEMORY
#define MAP_IN_MEMORY
Definition: map.h:126
CREMainWindow::onToolCombatSimulator
void onToolCombatSimulator()
Definition: CREMainWindow.cpp:1791
CREHPBarMaker
Definition: CREHPBarMaker.h:22
CREMainWindow::myModel
AssetModel * myModel
Definition: CREMainWindow.h:53
object_free_drop_inventory
void object_free_drop_inventory(object *ob)
Definition: object.cpp:1560
object::contr
struct player * contr
Definition: object.h:284
CREMainWindow::updateReports
void updateReports()
CREMainWindow::onReportResetGroups
void onReportResetGroups()
Definition: CREMainWindow.cpp:1726
is_valid_types_gen.line
line
Definition: is_valid_types_gen.py:34
SP_BULLET
#define SP_BULLET
Definition: spells.h:79
disinfect.map
map
Definition: disinfect.py:4
object::subtype
uint8_t subtype
Definition: object.h:349
EditMonstersDialog.h
SK_TWO_HANDED_WEAPON
@ SK_TWO_HANDED_WEAPON
Definition: skills.h:56
recipelist
Definition: recipe.h:37
CREExperienceWindow.h
CREMainWindow::onToolSounds
void onToolSounds()
Definition: CREMainWindow.cpp:1844
rotate-tower.result
bool result
Definition: rotate-tower.py:13
get_typedata
const typedata * get_typedata(int itemtype)
Definition: item.cpp:323
buildShopReport
static QString buildShopReport(const QString &title, const QStringList &types, const QList< CREMapInformation * > &maps, QStringList &items)
Definition: CREMainWindow.cpp:1340
alchemyTable
static QString alchemyTable(const QString &skill, QStringList &noChance, std::vector< std::pair< QString, int >> &allIngredients)
Definition: CREMainWindow.cpp:640
ResourcesManager::saveGeneralMessages
void saveGeneralMessages()
Definition: ResourcesManager.cpp:261
object::weapon_speed
float weapon_speed
Definition: object.h:339
CREMainWindow::doResourceWindow
void doResourceWindow(int assets, const QByteArray &position=QByteArray())
Definition: CREMainWindow.cpp:312
CREMainWindow::onToolFaceset
void onToolFaceset(QAction *action)
Definition: CREMainWindow.cpp:1824
ResourcesManager::load
void load()
Definition: ResourcesManager.cpp:57
levels
int64_t * levels
Definition: exp.cpp:26
treasurelist
Definition: treasure.h:85
ResourcesManager::setMapInformationManager
void setMapInformationManager(CREMapInformationManager *mapInformationManager)
Definition: ResourcesManager.h:88
CREMainWindow::CREMainWindow
CREMainWindow(const QString &helpRoot)
Definition: CREMainWindow.cpp:50
archetype::clone
object clone
Definition: object.h:487
HelpManager.h
CRECombatSimulator.h
CREMainWindow::onWindowsShowing
void onWindowsShowing()
Definition: CREMainWindow.cpp:1855
CREMainWindow::createAction
QAction * createAction(const QString &title, const QString &statusTip, F functor, bool waitMaps=false)
Definition: CREMainWindow.cpp:152
CRESettings.h
python_init.path
path
Definition: python_init.py:8
done
int done
Definition: readable.cpp:1566
CREMainWindow::onToolFacesetUseFallback
void onToolFacesetUseFallback()
Definition: CREMainWindow.cpp:1829
convert.action
action
Definition: convert.py:25
doIngredients
static void doIngredients(const std::vector< std::pair< QString, int >> &allIngredients, const QString &criteria, QString &report)
Definition: CREMainWindow.cpp:727
AssetsManager::quests
Quests * quests()
Definition: AssetsManager.h:71
AssetsManager::faces
Faces * faces()
Definition: AssetsManager.h:39
CREMainWindow::browsingFinished
void browsingFinished()
Definition: CREMainWindow.cpp:390
object::type
uint8_t type
Definition: object.h:348
CREMainWindow::fillFacesets
void fillFacesets()
Definition: CREMainWindow.cpp:347
living::dam
int16_t dam
Definition: living.h:46
LicenseManager::licenseNameFromFaceName
static std::string licenseNameFromFaceName(const std::string &face)
Definition: LicenseManager.cpp:83
SoundsDialog.h
AssetModel
Definition: AssetModel.h:29
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:298
CREReportDisplay.h
linked_char::next
struct linked_char * next
Definition: global.h:98
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1592
title
Definition: readable.cpp:108
artifactlist
Definition: artifact.h:24
CREMainWindow::onToolReloadAssets
void onToolReloadAssets()
Definition: CREMainWindow.cpp:1834
CREMainWindow::createActions
void createActions()
Definition: CREMainWindow.cpp:189
AssetModel.h
disinfect.count
int count
Definition: disinfect.py:7
say.max
dictionary max
Definition: say.py:148
MessageManager
Definition: MessageManager.h:25
tag_t
uint32_t tag_t
Definition: object.h:14
CREMapInformation::path
QString path
Definition: CREMapInformation.h:31
archetype
Definition: object.h:483
CREMainWindow::myScriptManager
ScriptFileManager * myScriptManager
Definition: CREMainWindow.h:72
AssetsCollection::get
T * get(const Key &name)
Definition: AssetsCollection.h:89
sproto.h
AssetsCollection::each
void each(std::function< void(T *)> op)
Definition: AssetsCollection.h:158
animate.anim
string anim
Definition: animate.py:20
IS_COMBAT_SKILL
#define IS_COMBAT_SKILL(num)
Definition: skills.h:91
CREMainWindow::myAssets
AllAssets * myAssets
Definition: CREMainWindow.h:54
delete_map
void delete_map(mapstruct *m)
Definition: map.cpp:1696
AssetsManager::facesets
Facesets * facesets()
Definition: AssetsManager.h:65
CREMainWindow::mySaveMenu
QMenu * mySaveMenu
Definition: CREMainWindow.h:60
object::race
sstring race
Definition: object.h:326
CREMainWindow::myMapManager
CREMapInformationManager * myMapManager
Definition: CREMainWindow.h:69
ChangesDock
Definition: ChangesDock.h:24
CREMainWindow::myChanges
ChangesDock * myChanges
Definition: CREMainWindow.h:73
CREMainWindow::onToolEditMonsters
void onToolEditMonsters()
Definition: CREMainWindow.cpp:1779
image.h
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.cpp:2100
object::other_arch
struct archetype * other_arch
Definition: object.h:425
ASSETS_ALL
#define ASSETS_ALL
Definition: assets.h:32
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
recipe::ingred_count
int ingred_count
Definition: recipe.h:23
CREMapInformationManager::browseFinished
bool browseFinished() const
Definition: CREMapInformationManager.cpp:81
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
MAX_BUF
#define MAX_BUF
Definition: define.h:35
CREMapInformationManager.h
CREMainWindow::onReportSpells
void onReportSpells()
Definition: CREMainWindow.cpp:902
CREMainWindow::onReportAlchemy
void onReportAlchemy()
Definition: CREMainWindow.cpp:736
ResourcesManager.h
CREMainWindow::myArea
QMdiArea * myArea
Definition: CREMainWindow.h:52
CREMainWindow::onReportDuplicate
void onReportDuplicate()
Definition: CREMainWindow.cpp:413
create_archetype
object * create_archetype(const char *name)
Definition: arch.cpp:278
CREMainWindow::myFacesetsGroup
QActionGroup * myFacesetsGroup
Definition: CREMainWindow.h:64
CREMainWindow::mySaveFormulae
QAction * mySaveFormulae
Definition: CREMainWindow.h:62
living::wc
int8_t wc
Definition: living.h:37
Settings::playerdir
const char * playerdir
Definition: global.h:250
CREMainWindow::onReportsModified
void onReportsModified()
Definition: CREMainWindow.cpp:402
CREMainWindow::myToolsMenu
QMenu * myToolsMenu
Definition: CREMainWindow.h:63
MonsterResistances.h
recipe
Definition: recipe.h:10
diamondslots.message
string message
Definition: diamondslots.py:57
CRESmoothFaceMaker
Definition: CRESmoothFaceMaker.h:23
make_face_from_files.out
out
Definition: make_face_from_files.py:81
object::dam_modifier
uint8_t dam_modifier
Definition: object.h:419
HelpManager
Definition: HelpManager.h:23
archetype::tail_x
int8_t tail_x
Definition: object.h:488
object::duration_modifier
uint8_t duration_modifier
Definition: object.h:416
object::name
sstring name
Definition: object.h:319
attacktype_desc
const char *const attacktype_desc[NROFATTACKS]
Definition: init.cpp:40
report
Definition: report.py:1
players
std::vector< archetype * > players
Definition: player.cpp:493
powerbroker.confirm
def confirm(text, action)
Definition: powerbroker.py:97
recipe::chance
int chance
Definition: recipe.h:14
item
Definition: item.py:1
mapstruct
Definition: map.h:313
AllAssets
Definition: AllAssets.h:23
readDirectory
void readDirectory(const QString &path, QHash< QString, QHash< QString, bool > > &states)
Definition: CREMainWindow.cpp:1444
CREMainWindow::onReportSummon
void onReportSummon()
Definition: CREMainWindow.cpp:1279
sstring
const typedef char * sstring
Definition: sstring.h:2
CRESettings
Definition: CRESettings.h:21
CREExperienceWindow
Definition: CREExperienceWindow.h:18
object::skill
sstring skill
Definition: object.h:329
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:266
mapstruct::in_memory
uint32_t in_memory
Definition: map.h:333
help
static void help(void)
Definition: init.cpp:1138
recipe::diff
int diff
Definition: recipe.h:16
CREMainWindow::onReportShops
void onReportShops()
Definition: CREMainWindow.cpp:1396
EditMonstersDialog
Definition: EditMonstersDialog.h:24
HelpManager::displayHelp
void displayHelp()
Definition: HelpManager.cpp:50
CREMainWindow::myHelpManager
HelpManager * myHelpManager
Definition: CREMainWindow.h:74
CREMainWindow::myMessageManager
MessageManager * myMessageManager
Definition: CREMainWindow.h:70
assets.h
npc_dialog.index
int index
Definition: npc_dialog.py:102
CREMapInformationManager::cancel
void cancel()
Definition: CREMapInformationManager.cpp:368
living::ac
int8_t ac
Definition: living.h:38
dragon_attune.faces
dictionary faces
Definition: dragon_attune.py:31
object::duration
int16_t duration
Definition: object.h:415
CREMainWindow::updateFilters
void updateFilters()
socket_struct::faces_sent
uint8_t * faces_sent
Definition: newserver.h:96
CREHPBarMaker.h
AllAssets::childrenCount
virtual int childrenCount() const
Definition: AllAssets.h:30
level
int level
Definition: readable.cpp:1563
first_artifactlist
artifactlist * first_artifactlist
Definition: init.cpp:109
AllAssets::regions
AssetWrapper * regions()
Definition: AllAssets.h:34
castle_read.key
key
Definition: castle_read.py:64
CREPixmap::init
static void init()
Definition: CREPixmap.cpp:32
object_remove
void object_remove(object *op)
Definition: object.cpp:1833
animate.event
event
DIALOGCHECK MINARGS 1 MAXARGS 2
Definition: animate.py:17
CREMainWindow::myOpenMenu
QMenu * myOpenMenu
Definition: CREMainWindow.h:59
monsterTable
static QString monsterTable(archetype *monster, QList< archetype * > skills)
Definition: CREMainWindow.cpp:1126
recipe::ingred
linked_char * ingred
Definition: recipe.h:22
CREMainWindow::myToolFacesetUseFallback
QAction * myToolFacesetUseFallback
Definition: CREMainWindow.h:65
CREMainWindow::onReportArchetypes
void onReportArchetypes()
Definition: CREMainWindow.cpp:1600
face_sets::fullname
char * fullname
Definition: image.h:20
do_some_living
void do_some_living(object *op)
Definition: player.cpp:3276
SP_SUMMON_GOLEM
#define SP_SUMMON_GOLEM
Definition: spells.h:86
ResourcesManager::saveTreasures
void saveTreasures()
Definition: ResourcesManager.cpp:234
archetype::tail_y
int8_t tail_y
Definition: object.h:488
CREMainWindow::onReportPlayer
void onReportPlayer()
Definition: CREMainWindow.cpp:1152
FREE_OBJ_FREE_INVENTORY
#define FREE_OBJ_FREE_INVENTORY
Definition: object.h:544
CREMainWindow.h
archetype::name
sstring name
Definition: object.h:484
recipe::next
recipe * next
Definition: recipe.h:24
assets_collect
void assets_collect(const char *datadir, int what)
Definition: assets.cpp:113
mapstruct::reset_time
uint32_t reset_time
Definition: map.h:320
names
const char *const names[]
Definition: AssetOriginAndCreationDialog.cpp:26
recipe::skill
sstring skill
Definition: recipe.h:26
say.item
dictionary item
Definition: say.py:149
object::stats
living stats
Definition: object.h:378
reportSummon
static QString reportSummon(const archetype *summon, const object *other, QString name)
Definition: CREMainWindow.cpp:1223
attack_ob
int attack_ob(object *op, object *hitter)
Definition: attack.cpp:937
connect
Definition: connect.py:1
CREPixmap::clearFaceCache
static void clearFaceCache()
Definition: CREPixmap.cpp:60
CRESettings::setStoreWindowState
void setStoreWindowState(bool store)
Definition: CRESettings.cpp:124
get_faces_count
size_t get_faces_count()
Definition: assets.cpp:293
CREMainWindow::mapAdded
void mapAdded(CREMapInformation *map)
Definition: CREMainWindow.cpp:1887
CRESmoothFaceMaker.h
CREMainWindow::onToolBarMaker
void onToolBarMaker()
Definition: CREMainWindow.cpp:1797
AssetModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const override
Definition: AssetModel.cpp:30
CREMapInformationManager
Definition: CREMapInformationManager.h:27
face_sets
Definition: image.h:17
FaceMakerDialog
Definition: FaceMakerDialog.h:26
CREResourcesWindow.h
SPELL
@ SPELL
Definition: object.h:219
quests
static struct_quest ** quests
Definition: mapper.cpp:892
CREMainWindow::onOpenExperience
void onOpenExperience(const QByteArray &position=QByteArray())
Definition: CREMainWindow.cpp:337
ResourcesManager::hasPendingChanges
bool hasPendingChanges() const
Definition: ResourcesManager.h:122
CREPixmap.h
altar_valkyrie.pl
pl
Definition: altar_valkyrie.py:28
CREReportDisplay
Definition: CREReportDisplay.h:19
CREMainWindow::myWindows
QMenu * myWindows
Definition: CREMainWindow.h:67
LicenseManager::getAll
std::map< std::string, LicenseItems > getAll() const
Definition: LicenseManager.h:47
living::hp
int16_t hp
Definition: living.h:40
SoundsDialog
Definition: SoundsDialog.h:18
CREMainWindow::onReportQuests
void onReportQuests()
Definition: CREMainWindow.cpp:1487
AllAssets::child
virtual AssetWrapper * child(int index)
Definition: AllAssets.h:31
CRECombatSimulator
Definition: CRECombatSimulator.h:27
ring_occidental_mages.r
r
Definition: ring_occidental_mages.py:6
CREMainWindow::onClearCache
void onClearCache()
Definition: CREMainWindow.cpp:1809
MessageManager::saveMessages
void saveMessages()
Definition: MessageManager.cpp:43
GOD
@ GOD
Definition: object.h:153
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
spell_arrow.spells
spells
Definition: spell_arrow.py:6
determine_holy_arch
archetype * determine_holy_arch(const object *god, const char *type)
Definition: gods.cpp:675
living::Con
int8_t Con
Definition: living.h:36
give.name
name
Definition: give.py:27
CREMainWindow::onToolSmooth
void onToolSmooth()
Definition: CREMainWindow.cpp:1785
CREMainWindow::onToolFaceMaker
void onToolFaceMaker()
Definition: CREMainWindow.cpp:1803
recipe::title
sstring title
Definition: recipe.h:11
level
Definition: level.py:1
Settings::localdir
const char * localdir
Definition: global.h:249