Crossfire Server, Trunk  R20513
ScriptFileManager.cpp
Go to the documentation of this file.
1 #include "ScriptFileManager.h"
2 #include "ScriptFile.h"
3 
5 {
6 }
7 
9 {
10  qDeleteAll(myScripts.values());
11 }
12 
14 {
15  QList<ScriptFile*> list;
16  foreach(ScriptFile* script, myScripts.values())
17  {
18  if (script->forMap(map))
19  {
20  list.append(script);
21  }
22  }
23  return list;
24 }
25 
27 {
28  if (!myScripts.contains(path))
29  {
30  myScripts.insert(path, new ScriptFile(path));
31  }
32  return myScripts[path];
33 }
34 
36 {
37  QHash<QString, ScriptFile*>::iterator script = myScripts.begin();
38  while (script != myScripts.end())
39  {
40  if ((*script)->removeMap(map))
41  {
42  ScriptFile* s = *script;
43  script = myScripts.erase(script);
44  delete s;
45  }
46  else
47  {
48  script++;
49  }
50  }
51 }
52 
53 QList<ScriptFile*> ScriptFileManager::scripts() const
54 {
55  return myScripts.values();
56 }
Information about a script file.
Definition: ScriptFile.h:31
virtual ~ScriptFileManager()
QHash< QString, ScriptFile * > myScripts
QList< ScriptFile * > scripts() const
QList< ScriptFile * > scriptsForMap(CREMapInformation *map)
void removeMap(CREMapInformation *map)
Remove scripts linked to a map.
ScriptFile * getFile(const QString &path)
Get information about a script path.
bool forMap(CREMapInformation *map) const
Definition: ScriptFile.cpp:19