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