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