Crossfire Server, Trunk  R20513
CREMapInformationManager.cpp
Go to the documentation of this file.
2 #include "CRESettings.h"
3 #include "CREArchetypePanel.h"
4 #include "MessageManager.h"
5 #include "MessageFile.h"
6 #include "QuestManager.h"
7 #include "Quest.h"
8 #include "ScriptFileManager.h"
9 #include "ScriptFile.h"
10 #include "CRERandomMap.h"
11 
12 extern "C" {
13 #include "global.h"
14 }
15 
16 const char* eventNames[NR_EVENTS] = {
17  "EVENT_NONE",
18  "EVENT_APPLY",
19  "EVENT_ATTACKED",
20  "EVENT_DEATH",
21  "EVENT_DROP",
22  "EVENT_PICKUP",
23  "EVENT_SAY",
24  "EVENT_STOP",
25  "EVENT_TIME",
26  "EVENT_THROW",
27  "EVENT_TRIGGER",
28  "EVENT_CLOSE",
29  "EVENT_TIMER",
30  "EVENT_DESTROY",
31  "EVENT_BORN",
32  "EVENT_CLOCK",
33  "EVENT_CRASH",
34  "EVENT_PLAYER_DEATH",
35  "EVENT_GKILL",
36  "EVENT_LOGIN",
37  "EVENT_LOGOUT",
38  "EVENT_MAPENTER",
39  "EVENT_MAPLEAVE",
40  "EVENT_MAPRESET",
41  "EVENT_REMOVE",
42  "EVENT_SHOUT",
43  "EVENT_TELL",
44  "EVENT_MUZZLE",
45  "EVENT_KICK",
46  "EVENT_MAPUNLOAD",
47  "EVENT_MAPLOAD",
48  "EVENT_USER",
49  "EVENT_SELLING",
50  "EVENT_ATTACKS",
51 };
52 
53 CREMapInformationManager::CREMapInformationManager(QObject* parent, MessageManager* messageManager, QuestManager* questManager, ScriptFileManager* scriptManager) : QObject(parent)
54 {
55  Q_ASSERT(messageManager != NULL);
56  Q_ASSERT(questManager != NULL);
57  Q_ASSERT(scriptManager != NULL);
58  myMessageManager = messageManager;
59  myQuestManager = questManager;
60  myScriptManager = scriptManager;
61 }
62 
64 {
65  qDeleteAll(myInformation.values());
66 }
67 
69 {
70  return myWorker.isFinished();
71 }
72 
74 {
75  if (myWorker.isRunning())
76  return;
77 
78  myWorker = QtConcurrent::run(this, &CREMapInformationManager::browseMaps);
79 }
80 
81 void CREMapInformationManager::checkInventory(const object* item, CREMapInformation* information, const object* env)
82 {
83  FOR_INV_PREPARE(item, inv)
84  {
85  archetype *arch = find_archetype(inv->arch->name);
86  addArchetypeUse(arch->name, information);
87  information->addArchetype(arch->name);
88  checkEvent(inv, information, env);
89  checkInventory(inv, information, env);
90  } FOR_INV_FINISH();
91 }
92 
93 void CREMapInformationManager::process(const QString& path2)
94 {
95  /*
96  don't ask why, but the variable gets apparently destroyed on the myToProcess.append() when it reallocated values...
97  so keep a copy to avoid messes
98  */
99  QString path(path2);
100 
101  if (myCancelled)
102  return;
103 
104  emit browsingMap(path);
105 // qDebug() << "processing" << path;
106  CREMapInformation* information = getOrCreateMapInformation(path);
107 
108  char tmppath[MAX_BUF];
109  create_pathname(path.toAscii(), tmppath, MAX_BUF);
110  QFileInfo info(tmppath);
111 
112  if (!info.exists())
113  {
114 // qDebug() << "non existant map" << tmppath;
115  return;
116  }
117 
118  if (!information->mapTime().isNull() && information->mapTime() >= info.lastModified())
119  {
120  foreach(QString exit, information->exitsTo())
121  {
122  if (!myToProcess.contains(exit))
123  myToProcess.append(exit);
124  }
125 // qDebug() << "skipping " << tmppath;
126  return;
127  }
128 
129  /* remove scripts to avoid duplications */
130  myScriptManager->removeMap(information);
131 
132  mapstruct *m = ready_map_name(path.toAscii(), 0);
133 // qDebug() << "processing" << path << information->mapTime() << info.lastModified();
134  information->setName(m->name);
135  information->setMapTime(info.lastModified());
136  if (m->region != NULL)
137  information->setRegion(m->region->name);
138  else
139  information->setRegion("wilderness");
140  information->setLevel(m->difficulty);
141 
142  information->setShopGreed(m->shopgreed);
143  if (m->shopitems != NULL)
144  {
145  for (int i = 0; i < m->shopitems[0].index; i++)
146  {
147  information->shopItems().insert(QString(m->shopitems[i].name == NULL ? "*" : m->shopitems[i].name), m->shopitems[i].strength);
148  }
149  }
150  if (m->shoprace != NULL)
151  information->setShopRace(m->shoprace);
152  information->setShopMin(m->shopmin);
153  information->setShopMax(m->shopmax);
154 
155  char exit_path[500];
156  quint64 exp = 0;
157 
158  for (int x = 0; x < 4; x++)
159  if (m->tile_path[x] != NULL) {
160  path_combine_and_normalize(m->path, m->tile_path[x], exit_path, sizeof(exit_path));
161  create_pathname(exit_path, tmppath, MAX_BUF);
162  if (!QFileInfo(tmppath).exists()) {
163  printf(" map %s doesn't exist in map %s, for tile %d.\n", exit_path, m->path, x);
164  }
165 
166  QString exit = exit_path;
167  if (!myToProcess.contains(exit))
168  myToProcess.append(exit);
169 
171  Q_ASSERT(other);
172  other->addAccessedFrom(path);
173  information->addExitTo(exit_path);
174  }
175 
176  for (int x = MAP_WIDTH(m)-1; x >= 0; x--)
177  {
178  for (int y = MAP_HEIGHT(m)-1; y >= 0; y--)
179  {
180  FOR_MAP_PREPARE(m, x, y, item)
181  {
182  {
183  archetype *arch = find_archetype(item->arch->name);
184  addArchetypeUse(arch->name, information);
185  information->addArchetype(arch->name);
186  }
187 
188  checkInventory(item, information, item);
189 
190  if (item->type == EXIT || item->type == TELEPORTER || item->type == PLAYER_CHANGER) {
191  char ep[500];
192  const char *start;
193 
194  if (!item->slaying) {
195  ep[0] = '\0';
196  /*if (warn_no_path)
197  printf(" exit without any path at %d, %d on %s\n", item->x, item->y, info->path);*/
198  } else {
199  memset(ep, 0, 500);
200  if (strcmp(item->slaying, "/!"))
201  strcpy(ep, EXIT_PATH(item));
202  else {
203  if (!item->msg) {
204  //printf(" random map without message in %s at %d, %d\n", info->path, item->x, item->y);
205  } else {
206  /* Some maps have a 'exit_on_final_map' flag, ignore it. */
207  start = strstr(item->msg, "\nfinal_map ");
208  if (!start && strncmp(item->msg, "final_map", strlen("final_map")) == 0)
209  /* Message start is final_map, nice */
210  start = item->msg;
211  if (start) {
212  const char *end = strchr(start+1, '\n');
213 
214  start += strlen("final_map")+2;
215  strncpy(ep, start, end-start);
216  }
217 
218  information->addRandomMap(new CRERandomMap(information, x, y, item->msg));
219  }
220  }
221 
222  if (strlen(ep)) {
223  path_combine_and_normalize(m->path, ep, exit_path, 500);
224  create_pathname(exit_path, tmppath, MAX_BUF);
225  if (!QFileInfo(tmppath).exists()) {
226  printf(" map %s doesn't exist in map %s, at %d, %d.\n", ep, m->path, item->x, item->y);
227  } else {
228  QString exit = exit_path;
229  if (!myToProcess.contains(exit))
230  myToProcess.append(exit);
231 
233  Q_ASSERT(other);
234  other->addAccessedFrom(path);
235  information->addExitTo(exit_path);
236 
237 #if 0
238  link = get_map_info(exit_path);
239  add_map(link, &info->exits_from);
240  add_map(info, &link->exits_to);
241 
242  if (do_regions_link) {
243  mapstruct *link = ready_map_name(exit_path, 0);
244 
245  if (link && link != m) {
246  /* no need to link a map with itself. Also, if the exit points to the same map, we don't
247  * want to reset it. */
248  add_region_link(m, link, item->arch->clone.name);
249  link->reset_time = 1;
250  link->in_memory = MAP_IN_MEMORY;
251  delete_map(link);
252  }
253  }
254 #endif
255  }
256  }
257  }
258  }
259  else if (item->type == EVENT_CONNECTOR && item->subtype > 0 && item->subtype < NR_EVENTS)
260  {
261  ScriptFile* script = myScriptManager->getFile(item->slaying);
262  script->addHook(new HookInformation(information, x, y, item->name, item->title, eventNames[item->subtype]));
263  }
264 
265  if (QUERY_FLAG(item, FLAG_MONSTER))
266  exp += item->stats.exp;
267  } FOR_MAP_FINISH();
268  }
269  }
270 
271  information->setExperience(exp);
272 
273  QMutexLocker lock(&myLock);
274  if (m->region == NULL)
275  qDebug() << "map without region" << m->name << m->path;
276  myExperience[m->region ? m->region->name : "(undefined)"] += exp;
277 
278  m->reset_time = 1;
280  delete_map(m);
281 }
282 
284 {
286  myInformation.clear();
287  myArchetypeUse.clear();
288 
289  loadCache();
290 
291  myCancelled = false;
292  myCurrentMap = 0;
293  myToProcess.clear();
294  myToProcess.append(QString(first_map_path));
295 
296  /* try to find race-specific start maps */
297  if (first_map_ext_path[0] != 0)
298  {
299  char path[MAX_BUF], name[MAX_BUF];
300  const archetype* arch = first_archetype;
301  while (arch)
302  {
303  if (arch->clone.type == PLAYER)
304  {
305  snprintf(name, sizeof(name), "%s/%s", first_map_ext_path, arch->name);
306  create_pathname(name, path, sizeof(path));
307  if (QFileInfo(path).exists()) {
308  myToProcess.append(name);
309  }
310  }
311  arch = arch->next;
312  }
313  }
314 
315  while (myCurrentMap < myToProcess.size())
316  {
318  myCurrentMap++;
319  if (myCancelled)
320  break;
321  }
322 
323  storeCache();
324 
325  emit finished();
326 
328  qDebug() << "experience repartition:";
329  foreach(QString region, myExperience.keys())
330  {
331  qDebug() << region << myExperience[region];
332  }
333 
334  qDebug() << myToProcess.size() << "maps processed";
335 }
336 
338 {
339  myCancelled = true;
340  myWorker.waitForFinished();
341 }
342 
343 QList<CREMapInformation*> CREMapInformationManager::allMaps()
344 {
345  QMutexLocker lock(&myLock);
346  return myInformation.values();
347 }
348 
349 QList<CREMapInformation*> CREMapInformationManager::getArchetypeUse(const archetype* arch)
350 {
351  QMutexLocker lock(&myLock);
352  return myArchetypeUse.values(arch->name);
353 }
354 
356 {
357  Q_ASSERT(myInformation.isEmpty());
358 
360  QFile file(settings.mapCacheDirectory() + QDir::separator() + "maps_cache.xml");
361  file.open(QFile::ReadOnly);
362 
363  QXmlStreamReader reader(&file);
364  bool hasMaps = false;
365  CREMapInformation* map = NULL;
366 
367  while (!reader.atEnd())
368  {
369  reader.readNext();
370 
371  if (reader.isStartElement() && reader.name() == "maps")
372  {
373  int version = reader.attributes().value("version").toString().toInt();
374  if (version < 1)
375  return;
376  hasMaps = true;
377  continue;
378  }
379 
380  if (!hasMaps)
381  continue;
382 
383  if (reader.isStartElement() && reader.name() == "map")
384  {
385  map = new CREMapInformation();
386  continue;
387  }
388  if (reader.isStartElement() && reader.name() == "path")
389  {
390  QString path = reader.readElementText();
391  map->setPath(path);
392  Q_ASSERT(!myInformation.contains(path));
393  myInformation[path] = map;
394  continue;
395  }
396  if (reader.isStartElement() && reader.name() == "name")
397  {
398  map->setName(reader.readElementText());
399  continue;
400  }
401  if (reader.isStartElement() && reader.name() == "lastModified")
402  {
403  QString date = reader.readElementText();
404  map->setMapTime(QDateTime::fromString(date, Qt::ISODate));
405  continue;
406  }
407  if (reader.isStartElement() && reader.name() == "level")
408  {
409  map->setLevel(reader.readElementText().toInt());
410  }
411  if (reader.isStartElement() && reader.name() == "experience")
412  {
413  map->setExperience(reader.readElementText().toLongLong());
414  }
415  if (reader.isStartElement() && reader.name() == "region")
416  {
417  map->setRegion(reader.readElementText());
418  }
419  if (reader.isStartElement() && reader.name() == "arch")
420  {
421  QString arch = reader.readElementText();
422  map->addArchetype(arch);
423  addArchetypeUse(arch, map);
424  continue;
425  }
426  if (reader.isStartElement() && reader.name() == "exitTo")
427  {
428  QString path = reader.readElementText();
429  map->addExitTo(path);
430  continue;
431  }
432  if (reader.isStartElement() && reader.name() == "accessedFrom")
433  {
434  QString path = reader.readElementText();
435  map->addAccessedFrom(path);
436  continue;
437  }
438  if (reader.isStartElement() && reader.name() == "messageFile")
439  {
440  QString file = reader.readElementText();
441  map->addMessage(file);
442  MessageFile* message = myMessageManager->findMessage(file);
443  if (message != NULL)
444  message->maps().append(map);
445  continue;
446  }
447  if (reader.isStartElement() && reader.name() == "quest")
448  {
449  QString code = reader.readElementText();
450  map->addQuest(code);
451  Quest* quest = myQuestManager->findByCode(code);
452  if (quest != NULL)
453  quest->maps().append(map);
454  continue;
455  }
456  if (reader.isStartElement() && reader.name() == "shopItem")
457  {
458  QString item = reader.attributes().value("name").toString();
459  int strength = reader.readElementText().toInt();
460  map->shopItems()[item] = strength;
461  }
462  if (reader.isStartElement() && reader.name() == "shopGreed")
463  {
464  double greed = reader.readElementText().toDouble();
465  map->setShopGreed(greed);
466  }
467  if (reader.isStartElement() && reader.name() == "shopRace")
468  {
469  map->setShopRace(reader.readElementText());
470  }
471  if (reader.isStartElement() && reader.name() == "shopMin")
472  {
473  quint64 min = reader.readElementText().toULongLong();
474  map->setShopMin(min);
475  }
476  if (reader.isStartElement() && reader.name() == "shopMax")
477  {
478  quint64 max = reader.readElementText().toULongLong();
479  map->setShopMax(max);
480  }
481  if (reader.isStartElement() && reader.name() == "script")
482  {
483  int x = reader.attributes().value("x").toString().toInt();
484  int y = reader.attributes().value("x").toString().toInt();
485  QString item = reader.attributes().value("itemName").toString();
486  QString plugin = reader.attributes().value("pluginName").toString();
487  QString event = reader.attributes().value("eventName").toString();
488  QString script = reader.readElementText();
489  myScriptManager->getFile(script)->addHook(new HookInformation(map, x, y, item, plugin, event));
490  }
491  if (reader.isStartElement() && reader.name() == "random_map")
492  {
493  int x = reader.attributes().value("x").toString().toInt();
494  int y = reader.attributes().value("y").toString().toInt();
495  QString params = reader.attributes().value("params").toString();
496  map->addRandomMap(new CRERandomMap(map, x, y, params.toLatin1().constData()));
497  }
498 
499  if (reader.isEndElement() && reader.name() == "map")
500  {
501  map = NULL;
502  continue;
503  }
504  }
505 
506 // qDebug() << "loaded maps from cache:" << myInformation.size();
507 }
508 
510 {
512  QFile file(settings.mapCacheDirectory() + QDir::separator() + "maps_cache.xml");
513  file.open(QFile::WriteOnly | QFile::Truncate);
514 
515  QXmlStreamWriter writer(&file);
516 
517  writer.setAutoFormatting(true);
518  writer.writeStartDocument();
519 
520  writer.writeStartElement("maps");
521  writer.writeAttribute("version", "1");
522 
523  QList<CREMapInformation*> maps = myInformation.values();
524  foreach(CREMapInformation* map, maps)
525  {
526  writer.writeStartElement("map");
527  writer.writeTextElement("path", map->path());
528  writer.writeTextElement("name", map->name());
529  writer.writeTextElement("lastModified", map->mapTime().toString(Qt::ISODate));
530  writer.writeTextElement("level", QString::number(map->level()));
531  writer.writeTextElement("experience", QString::number(map->experience()));
532  writer.writeTextElement("region", map->region());
533  foreach(QString arch, map->archetypes())
534  {
535  writer.writeTextElement("arch", arch);
536  }
537  foreach(QString path, map->exitsTo())
538  {
539  writer.writeTextElement("exitTo", path);
540  }
541  foreach(QString path, map->accessedFrom())
542  {
543  writer.writeTextElement("accessedFrom", path);
544  }
545  foreach(QString file, map->messages())
546  {
547  writer.writeTextElement("messageFile", file);
548  }
549  foreach(QString code, map->quests())
550  {
551  writer.writeTextElement("quest", code);
552  }
553  foreach(QString item, map->shopItems().keys())
554  {
555  writer.writeStartElement("shopItem");
556  writer.writeAttribute("name", item);
557  writer.writeCharacters(QString::number(map->shopItems()[item]));
558  writer.writeEndElement();
559  }
560  if (map->shopGreed() != 0)
561  {
562  writer.writeTextElement("shopGreed", QString::number(map->shopGreed()));
563  }
564  if (!map->shopRace().isEmpty())
565  {
566  writer.writeTextElement("shopRace", map->shopRace());
567  }
568  if (map->shopMin() != 0)
569  {
570  writer.writeTextElement("shopMin", QString::number(map->shopMin()));
571  }
572  if (map->shopMax() != 0)
573  {
574  writer.writeTextElement("shopMax", QString::number(map->shopMax()));
575  }
576 
577  QList<ScriptFile*> scripts = myScriptManager->scriptsForMap(map);
578  foreach(ScriptFile* script, scripts)
579  {
580  foreach(const HookInformation* hook, script->hooks())
581  {
582  if (hook->map() == map)
583  {
584  writer.writeStartElement("script");
585  writer.writeAttribute("x", QString::number(hook->x()));
586  writer.writeAttribute("y", QString::number(hook->y()));
587  writer.writeAttribute("itemName", hook->itemName());
588  writer.writeAttribute("pluginName", hook->pluginName());
589  writer.writeAttribute("eventName", hook->eventName());
590  writer.writeCharacters(script->path());
591  writer.writeEndElement();
592  }
593  }
594  }
595 
596  foreach(CRERandomMap* random, map->randomMaps())
597  {
598  writer.writeStartElement("random_map");
599  writer.writeAttribute("x", QString::number(random->x()));
600  writer.writeAttribute("y", QString::number(random->y()));
602  char* params = stringbuffer_finish(sb);
603  writer.writeAttribute("params", params);
604  free(params);
605  }
606 
607  writer.writeEndElement();
608  }
609 
610  writer.writeEndElement();
611 
612  writer.writeEndDocument();
613 }
614 
616 {
617  if (!myInformation.contains(path))
618  {
619  CREMapInformation* information = new CREMapInformation(path);
620  myInformation[path] = information;
621  }
622  return myInformation[path];
623 }
624 
626 {
627  QMutexLocker lock(&myLock);
628  if (!myArchetypeUse.values(name).contains(map))
629  myArchetypeUse.insert(name, map);
630 }
631 
632 void CREMapInformationManager::checkEvent(const object* item, CREMapInformation* map, const object* env)
633 {
634  const QString slaying = "/python/dialog/npc_dialog.py";
635  const QString python = "Python";
636 
637  if (item->type != EVENT_CONNECTOR)
638  return;
639 
640  if (item->subtype > 0 && item->subtype < NR_EVENTS)
641  {
642  ScriptFile* script = myScriptManager->getFile(item->slaying);
643  script->addHook(new HookInformation(map, env->x, env->y, env->name, item->title, eventNames[item->subtype]));
644  }
645 
646  if (python != item->title)
647  return;
648 
649  if (item->subtype == EVENT_SAY && slaying == item->slaying)
650  {
651  //qDebug() << "message event in" << map->path() << item->name;
652  QString path = item->name;
653  if (!path.startsWith('/'))
654  path = '/' + path;
655 
656  MessageFile* message = myMessageManager->findMessage(path);
657  if (message != NULL)
658  {
659  if (!message->maps().contains(map))
660  message->maps().append(map);
661  map->addMessage(path);
662  } else
663  qDebug() << "missing message file" << path << "in" << map->path();
664  }
665 
666  if (QString(item->slaying).startsWith("/python/quests/"))
667  {
668  //qDebug() << "quest-related Python stuff";
669  QStringList split = QString(item->name).split(' ', QString::SkipEmptyParts);
670  if (split.length() > 1)
671  {
672  Quest* quest = myQuestManager->findByCode(split[0]);
673  if (quest != NULL)
674  {
675  //qDebug() << "definitely quest" << split[0];
676  map->addQuest(split[0]);
677  if (!quest->maps().contains(map))
678  quest->maps().append(map);
679  } else
680  qDebug() << "missing quest" << split[0] << "in" << map->path();
681  }
682  }
683 }
684 
685 QList<CREMapInformation*> CREMapInformationManager::getMapsForRegion(const QString& region)
686 {
687  QList<CREMapInformation*> list;
688 
689  foreach(CREMapInformation* map, myInformation.values())
690  {
691  if (map->region() == region)
692  list.append(map);
693  }
694 
695  return list;
696 }
697 
699 {
701  Q_ASSERT(myWorker.isFinished());
702  QFile::remove(settings.mapCacheDirectory() + QDir::separator() + "maps_cache.xml");
703 }
704 
706 {
707  QList<CRERandomMap*> maps;
708  foreach(CREMapInformation* map, myInformation.values())
709  {
710  maps.append(map->randomMaps());
711  }
712  return maps;
713 }
QStringList exitsTo() const
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
double shopgreed
How much our shopkeeper overcharges.
Definition: map.h:358
archetype * find_archetype(const char *name)
Finds, using the hashtable, which archetype matches the given name.
Definition: arch.c:695
void process(const QString &path)
int x() const
QList< CREMapInformation * > allMaps()
int x() const
Definition: ScriptFile.cpp:75
Definition: Quest.h:32
ScriptFileManager * myScriptManager
char * create_pathname(const char *name, char *buf, size_t size)
Get the full path to a map file.
Definition: map.c:104
Manage scripts for items.
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
Definition: map.h:345
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
Definition: map.c:1803
QList< CREMapInformation * > getMapsForRegion(const QString &region)
#define NR_EVENTS
Definition: plugin.h:100
#define MAP_HEIGHT(m)
Map height.
Definition: map.h:80
object clone
An object from which to do object_copy()
Definition: object.h:470
uint32_t reset_time
When this map should reset.
Definition: map.h:332
const char * slaying
Which race to do double damage to.
Definition: object.h:319
Information about a script file.
Definition: ScriptFile.h:31
uint8_t subtype
Subtype of object.
Definition: object.h:339
const char * name
Name of the item in question, null if it is the default item.
Definition: map.h:306
EXTERN char first_map_ext_path[MAX_BUF]
Path used for per-race start maps.
Definition: global.h:154
Global type definitions and header inclusions.
void setPath(const QString &path)
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
MessageFile * findMessage(const QString &path)
QString itemName() const
Definition: ScriptFile.cpp:85
void addMessage(const QString &message)
char * name
Name of map as given by its creator.
Definition: map.h:328
QList< CRERandomMap * > randomMaps() const
#define MAP_IN_MEMORY
Map is fully loaded.
Definition: map.h:130
const char * title
Of foo, etc.
Definition: object.h:317
QMultiHash< QString, CREMapInformation * > myArchetypeUse
int16_t y
Position in the map for this object.
Definition: object.h:326
void setShopRace(const QString &race)
char * name
Shortend name of the region as maps refer to it.
Definition: map.h:278
void addQuest(const QString &quest)
void addHook(HookInformation *hook)
Definition: ScriptFile.cpp:14
Quest * findByCode(const QString &code)
QStringList messages() const
QList< CREMapInformation * > getArchetypeUse(const archetype *arch)
QHash< QString, CREMapInformation * > myInformation
See Exit.
Definition: object.h:181
int index
Being the size of the shopitems array.
Definition: map.h:311
void setShopMin(quint64 min)
QStringList archetypes() const
double shopGreed() const
int8_t strength
The degree of specialisation the shop has in this item, as a percentage from -100 to 100...
Definition: map.h:309
void checkInventory(const object *item, CREMapInformation *information, const object *env)
const char * eventNames[NR_EVENTS]
This is a game region.
Definition: map.h:276
#define snprintf
Definition: win32.h:46
uint64_t shopmin
Minimum price a shop will trade for.
Definition: map.h:359
QString mapCacheDirectory() const
Definition: CRESettings.cpp:43
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Combines the 2 paths.
Definition: path.c:172
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
Definition: define.h:712
void browsingMap(const QString &path)
void setRegion(const QString &region)
const char * name
The name of the object, obviously...
Definition: object.h:311
void addRandomMap(CRERandomMap *map)
const QString & shopRace() const
#define EXIT_PATH(xyz)
Definition: define.h:455
const RMParms * parameters() const
char * tile_path[4]
Path to adjoining maps.
Definition: map.h:363
const QString & path() const
Definition: ScriptFile.cpp:36
void checkEvent(const object *item, CREMapInformation *map, const object *env)
int y() const
Definition: ScriptFile.cpp:80
#define EVENT_SAY
Someone speaks.
Definition: plugin.h:70
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
StringBuffer * write_map_parameters_to_string(const RMParms *RP)
Creates a suitable message for exit from RP.
Definition: random_map.c:735
void setName(const QString &name)
static void add_region_link(mapstruct *source, mapstruct *dest, const char *linkname)
Creates a link between two maps if they are on different regions.
Definition: mapper.c:1726
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
int16_t x
Definition: object.h:326
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
QStringList accessedFrom() const
void removeMap(CREMapInformation *map)
Remove scripts linked to a map.
void setShopMax(quint64 max)
uint16_t difficulty
What level the player should be to play here.
Definition: map.h:343
QString eventName() const
Definition: ScriptFile.cpp:95
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
Definition: define.h:765
See Player.
Definition: object.h:107
void addAccessedFrom(const QString &path)
QHash< QString, qint64 > myExperience
void setMapTime(const QDateTime &date)
QList< CRERandomMap * > randomMaps()
int y() const
static int do_regions_link
Definition: mapper.c:481
#define MAP_WIDTH(m)
Map width.
Definition: map.h:78
uint64_t shopmax
MMaximum price a shop will offer.
Definition: map.h:360
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
struct Settings settings
Server settings.
Definition: init.c:40
void addArchetypeUse(const QString &name, CREMapInformation *map)
QString pluginName() const
Definition: ScriptFile.cpp:90
struct archt * next
Next archetype in a linked list.
Definition: object.h:467
void addExitTo(const QString &path)
void delete_map(mapstruct *m)
Frees the map, including the mapstruct.
Definition: map.c:1741
EXTERN char first_map_path[MAX_BUF]
The start-level.
Definition: global.h:153
ScriptFile * getFile(const QString &path)
Get information about a script path.
const QString & region() const
Lauwenmark: an invisible object holding a plugin event hook.
Definition: object.h:227
quint64 shopMin() const
const CREMapInformation * map() const
Definition: ScriptFile.cpp:70
void setExperience(qint64 experience)
#define FLAG_MONSTER
Will attack players.
Definition: define.h:245
quint64 shopMax() const
Information about an event hook, linked to a script file.
Definition: ScriptFile.h:9
void addArchetype(const QString &archetype)
QList< CREMapInformation * > & maps()
CREMapInformation * getOrCreateMapInformation(const QString &path)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
Definition: define.h:758
struct shopitem * shopitems
List of item-types the map&#39;s shop will trade in.
Definition: map.h:356
QList< HookInformation * > hooks() const
Definition: ScriptFile.cpp:31
void setLevel(int level)
A buffer that will be expanded as content is added to it.
Definition: stringbuffer.c:25
char * shoprace
The preffered race of the local shopkeeper.
Definition: map.h:357
This is a game-map.
Definition: map.h:325
const QDateTime & mapTime() const
static struct_map_info * get_map_info(const char *path)
Gets or creates if required the info structure for a map.
Definition: mapper.c:1625
struct regiondef * region
What jurisdiction in the game world this map is ruled by points to the struct containing all the prop...
Definition: map.h:329
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
CREMapInformationManager(QObject *parent, MessageManager *messageManager, QuestManager *questManager, ScriptFileManager *scriptManager)
See Teleporter.
Definition: object.h:141
static void add_map(struct_map_info *info, struct_map_list *list)
Adds a map to specified array, if it isn&#39;t already.
Definition: mapper.c:1530
const char * name
More definite name, like "generate_kobold".
Definition: object.h:466
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
Definition: stringbuffer.c:76
void setShopGreed(double greed)
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
Definition: define.h:705
QStringList quests() const
QHash< QString, int > & shopItems()
struct regiondef region
This is a game region.
QList< CREMapInformation * > & maps()
Definition: Quest.cpp:180