]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/mapq3/plugin.cpp
allow different file type selections for open/import/save
[xonotic/netradiant.git] / plugins / mapq3 / plugin.cpp
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 #include "plugin.h"
23
24 #include "iscriplib.h"
25 #include "ibrush.h"
26 #include "ipatch.h"
27 #include "ifiletypes.h"
28 #include "ieclass.h"
29 #include "qerplugin.h"
30
31 #include "scenelib.h"
32 #include "string/string.h"
33 #include "stringio.h"
34 #include "generic/constant.h"
35
36 #include "modulesystem/singletonmodule.h"
37
38 #include "parse.h"
39 #include "write.h"
40
41
42 class MapDoom3Dependencies :
43   public GlobalRadiantModuleRef,
44   public GlobalFiletypesModuleRef,
45   public GlobalScripLibModuleRef,
46   public GlobalEntityClassManagerModuleRef,
47   public GlobalSceneGraphModuleRef,
48   public GlobalBrushModuleRef
49 {
50   PatchModuleRef m_patchDef2Doom3Module;
51   PatchModuleRef m_patchDoom3Module;
52 public:
53   MapDoom3Dependencies() :
54     GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass")),
55     GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
56     m_patchDef2Doom3Module("def2doom3"),
57     m_patchDoom3Module("doom3")
58   {
59   }
60   BrushCreator& getBrushDoom3()
61   {
62     return GlobalBrushModule::getTable();
63   }
64   PatchCreator& getPatchDoom3()
65   {
66     return *m_patchDoom3Module.getTable();
67   }
68   PatchCreator& getPatchDef2Doom3()
69   {
70     return *m_patchDef2Doom3Module.getTable();
71   }
72 };
73
74 class MapDoom3API : public TypeSystemRef, public MapFormat, public PrimitiveParser
75 {
76   MapDoom3Dependencies& m_dependencies;
77 public:
78   typedef MapFormat Type;
79   STRING_CONSTANT(Name, "mapdoom3");
80   INTEGER_CONSTANT(MapVersion, 2);
81
82   MapDoom3API(MapDoom3Dependencies& dependencies) : m_dependencies(dependencies)
83   {
84     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("doom3 maps", "*.map"));
85     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("doom3 region", "*.reg"));
86   }
87   MapFormat* getTable()
88   {
89     return this;
90   }
91
92   scene::Node& parsePrimitive(Tokeniser& tokeniser) const
93   {
94     const char* primitive = tokeniser.getToken();
95     if(primitive != 0)
96     {
97       if(string_equal(primitive, "patchDef3"))
98       {
99         return m_dependencies.getPatchDoom3().createPatch();
100       }
101       else if(string_equal(primitive, "patchDef2"))
102       {
103         return m_dependencies.getPatchDef2Doom3().createPatch();
104       }
105       else if(string_equal(primitive, "brushDef3"))
106       {
107         return m_dependencies.getBrushDoom3().createBrush();
108       }
109     }
110
111     Tokeniser_unexpectedError(tokeniser, primitive, "#doom3-primitive");
112     return g_nullNode;
113   }
114   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
115   {
116     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
117     tokeniser.nextLine();
118     if(!Tokeniser_parseToken(tokeniser, "Version"))
119     {
120       return;
121     }
122     std::size_t version;
123     if(!Tokeniser_getSize(tokeniser, version))
124     {
125       return;
126     }
127     if(version != MapVersion())
128     {
129       globalErrorStream() << "Doom 3 map version " << MapVersion() << " supported, version is " << Unsigned(version) << "\n";
130       return;
131     }
132     tokeniser.nextLine();
133     Map_Read(root, tokeniser, entityTable, *this);
134     tokeniser.release();
135   }
136   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
137   {
138     TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
139     writer.writeToken("Version");
140     writer.writeInteger(MapVersion());
141     writer.nextLine();
142     Map_Write(root, traverse, writer, false);
143     writer.release();
144   }
145 };
146
147 typedef SingletonModule<
148   MapDoom3API,
149   MapDoom3Dependencies,
150   DependenciesAPIConstructor<MapDoom3API, MapDoom3Dependencies>
151 >
152 MapDoom3Module;
153
154 MapDoom3Module g_MapDoom3Module;
155
156
157 class MapQuake4API : public TypeSystemRef, public MapFormat, public PrimitiveParser
158 {
159   MapDoom3Dependencies& m_dependencies;
160 public:
161   typedef MapFormat Type;
162   STRING_CONSTANT(Name, "mapquake4");
163   INTEGER_CONSTANT(MapVersion, 3);
164
165   MapQuake4API(MapDoom3Dependencies& dependencies) : m_dependencies(dependencies)
166   {
167     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake4 maps", "*.map"));
168     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake4 region", "*.reg"));
169   }
170   MapFormat* getTable()
171   {
172     return this;
173   }
174
175   scene::Node& parsePrimitive(Tokeniser& tokeniser) const
176   {
177     const char* primitive = tokeniser.getToken();
178     if(primitive != 0)
179     {
180       if(string_equal(primitive, "patchDef3"))
181       {
182         return m_dependencies.getPatchDoom3().createPatch();
183       }
184       else if(string_equal(primitive, "patchDef2"))
185       {
186         return m_dependencies.getPatchDef2Doom3().createPatch();
187       }
188       else if(string_equal(primitive, "brushDef3"))
189       {
190         return m_dependencies.getBrushDoom3().createBrush();
191       }
192     }
193
194     Tokeniser_unexpectedError(tokeniser, primitive, "#quake4-primitive");
195     return g_nullNode;
196   }
197   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
198   {
199     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
200     tokeniser.nextLine();
201     if(!Tokeniser_parseToken(tokeniser, "Version"))
202     {
203       return;
204     }
205     std::size_t version;
206     if(!Tokeniser_getSize(tokeniser, version))
207     {
208       return;
209     }
210     if(version != MapVersion())
211     {
212       globalErrorStream() << "Quake 4 map version " << MapVersion() << " supported, version is " << Unsigned(version) << "\n";
213       return;
214     }
215     tokeniser.nextLine();
216     Map_Read(root, tokeniser, entityTable, *this);
217     tokeniser.release();
218   }
219   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
220   {
221     TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
222     writer.writeToken("Version");
223     writer.writeInteger(MapVersion());
224     writer.nextLine();
225     Map_Write(root, traverse, writer, false);
226     writer.release();
227   }
228 };
229
230 typedef SingletonModule<
231   MapQuake4API,
232   MapDoom3Dependencies,
233   DependenciesAPIConstructor<MapQuake4API, MapDoom3Dependencies>
234 >
235 MapQuake4Module;
236
237 MapQuake4Module g_MapQuake4Module;
238
239
240 class MapDependencies : 
241   public GlobalRadiantModuleRef,
242   public GlobalBrushModuleRef,
243   public GlobalPatchModuleRef,
244   public GlobalFiletypesModuleRef,
245   public GlobalScripLibModuleRef,
246   public GlobalEntityClassManagerModuleRef,
247   public GlobalSceneGraphModuleRef
248 {
249 public:
250   MapDependencies() :
251     GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
252     GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes")),
253     GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass"))
254   {
255   }
256 };
257
258 class MapQ3API : public TypeSystemRef, public MapFormat, public PrimitiveParser
259 {
260   mutable bool detectedFormat;
261 public:
262   typedef MapFormat Type;
263   STRING_CONSTANT(Name, "mapq3");
264
265   MapQ3API()
266   {
267     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake3 maps", "*.map"));
268     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake3 region", "*.reg"));
269   }
270   MapFormat* getTable()
271   {
272     return this;
273   }
274
275   scene::Node& parsePrimitive(Tokeniser& tokeniser) const
276   {
277     const char* primitive = tokeniser.getToken();
278     if(primitive != 0)
279     {
280       if(string_equal(primitive, "patchDef2"))
281       {
282         return GlobalPatchModule::getTable().createPatch();
283       }
284       if(GlobalBrushModule::getTable().useAlternativeTextureProjection())
285       {
286         if(string_equal(primitive, "brushDef"))
287         {
288           detectedFormat = true;
289           return GlobalBrushModule::getTable().createBrush();
290         }
291         else if(!detectedFormat && string_equal(primitive, "("))
292         {
293           detectedFormat = true;
294           wrongFormat = true;
295           Tokeniser_unexpectedError(tokeniser, primitive, "#quake3-switch-to-texdef");
296           return g_nullNode;
297         }
298       }
299       else
300       {
301         if(string_equal(primitive, "("))
302         {
303           detectedFormat = true;
304           tokeniser.ungetToken(); // (
305           return GlobalBrushModule::getTable().createBrush();
306         }
307         else if(!detectedFormat && string_equal(primitive, "("))
308         {
309           detectedFormat = true;
310           wrongFormat = true;
311           Tokeniser_unexpectedError(tokeniser, primitive, "#quake3-switch-to-brush-primitives");
312           return g_nullNode;
313         }
314       }
315     }
316
317     Tokeniser_unexpectedError(tokeniser, primitive, "#quake3-primitive");
318     return g_nullNode;
319   }
320
321   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
322   {
323     detectedFormat = false;
324     wrongFormat = false;
325     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
326     Map_Read(root, tokeniser, entityTable, *this);
327     tokeniser.release();
328   }
329   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
330   {
331     TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
332     Map_Write(root, traverse, writer, false);
333     writer.release();
334   }
335 };
336
337 typedef SingletonModule<MapQ3API, MapDependencies> MapQ3Module;
338
339 MapQ3Module g_MapQ3Module;
340
341
342 class MapQ1API : public TypeSystemRef, public MapFormat, public PrimitiveParser
343 {
344 public:
345   typedef MapFormat Type;
346   STRING_CONSTANT(Name, "mapq1");
347
348   MapQ1API()
349   {
350     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake maps", "*.map"));
351     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake region", "*.reg"));
352   }
353   MapFormat* getTable()
354   {
355     return this;
356   }
357
358   scene::Node& parsePrimitive(Tokeniser& tokeniser) const
359   {
360     const char* primitive = tokeniser.getToken();
361     if(primitive != 0)
362     {
363       if(string_equal(primitive, "("))
364       {
365         tokeniser.ungetToken(); // (
366         return GlobalBrushModule::getTable().createBrush();
367       }
368     }
369
370     Tokeniser_unexpectedError(tokeniser, primitive, "#quake-primitive");
371     return g_nullNode;
372   }
373   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
374   {
375     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
376     Map_Read(root, tokeniser, entityTable, *this);
377     tokeniser.release();
378   }
379   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
380   {
381     TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
382     Map_Write(root, traverse, writer, true);
383     writer.release();
384   }
385 };
386
387 typedef SingletonModule<MapQ1API, MapDependencies> MapQ1Module;
388
389 MapQ1Module g_MapQ1Module;
390
391
392 class MapHalfLifeAPI : public TypeSystemRef, public MapFormat, public PrimitiveParser
393 {
394 public:
395   typedef MapFormat Type;
396   STRING_CONSTANT(Name, "maphl");
397
398   MapHalfLifeAPI()
399   {
400     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("half-life maps", "*.map"));
401     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("half-life region", "*.reg"));
402   }
403   MapFormat* getTable()
404   {
405     return this;
406   }
407
408   scene::Node& parsePrimitive(Tokeniser& tokeniser) const
409   {
410     const char* primitive = tokeniser.getToken();
411     if(primitive != 0)
412     {
413       if(string_equal(primitive, "("))
414       {
415         tokeniser.ungetToken(); // (
416         return GlobalBrushModule::getTable().createBrush();
417       }
418     }
419
420     Tokeniser_unexpectedError(tokeniser, primitive, "#halflife-primitive");
421     return g_nullNode;
422   }
423   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
424   {
425     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
426     Map_Read(root, tokeniser, entityTable, *this);
427     tokeniser.release();
428   }
429   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
430   {
431     TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
432     Map_Write(root, traverse, writer, true);
433     writer.release();
434   }
435 };
436
437 typedef SingletonModule<MapHalfLifeAPI, MapDependencies> MapHalfLifeModule;
438
439 MapHalfLifeModule g_MapHalfLifeModule;
440
441
442 class MapQ2API : public TypeSystemRef, public MapFormat, public PrimitiveParser
443 {
444 public:
445   typedef MapFormat Type;
446   STRING_CONSTANT(Name, "mapq2");
447
448   MapQ2API()
449   {
450     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake2 maps", "*.map"));
451     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("quake2 region", "*.reg"));
452   }
453   MapFormat* getTable()
454   {
455     return this;
456   }
457   scene::Node& parsePrimitive(Tokeniser& tokeniser) const
458   {
459     const char* primitive = tokeniser.getToken();
460     if(primitive != 0)
461     {
462       if(string_equal(primitive, "("))
463       {
464         tokeniser.ungetToken(); // (
465         return GlobalBrushModule::getTable().createBrush();
466       }
467     }
468
469     Tokeniser_unexpectedError(tokeniser, primitive, "#quake2-primitive");
470     return g_nullNode;
471   }
472   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
473   {
474     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
475     Map_Read(root, tokeniser, entityTable, *this);
476     tokeniser.release();
477   }
478   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
479   {
480     TokenWriter& writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
481     Map_Write(root, traverse, writer, true);
482     writer.release();
483   }
484 };
485
486 typedef SingletonModule<MapQ2API, MapDependencies> MapQ2Module;
487
488 MapQ2Module g_MapQ2Module;
489
490
491
492 #define PARSE_ERROR "error parsing VMF"
493
494 inline void parseToken(Tokeniser& tokeniser, const char* token)
495 {
496   ASSERT_MESSAGE(Tokeniser_parseToken(tokeniser, token), "error parsing vmf: token not found: " << makeQuoted(token));
497 }
498
499 #include "generic/arrayrange.h"
500
501 class VMFBlock;
502 typedef ArrayConstRange<VMFBlock> VMFBlockArrayRange;
503
504
505 class VMFBlock
506 {
507 public:
508   const char* m_name;
509   VMFBlockArrayRange m_children;
510   typedef const VMFBlock Value;
511
512   VMFBlock(const char* name, VMFBlockArrayRange children = VMFBlockArrayRange(0, 0)) : m_name(name), m_children(children)
513   {
514   }
515   const char* name() const
516   {
517     return m_name;
518   }
519   typedef Value* const_iterator;
520   const_iterator begin() const
521   {
522     return m_children.first;
523   }
524   const_iterator end() const
525   {
526     return m_children.last;
527   }
528 };
529
530 const VMFBlock c_vmfNormals("normals");
531 const VMFBlock c_vmfDistances("distances");
532 const VMFBlock c_vmfOffsets("offsets");
533 const VMFBlock c_vmfOffsetNormals("offset_normals");
534 const VMFBlock c_vmfAlphas("alphas");
535 const VMFBlock c_vmfTriangleTags("triangle_tags");
536 const VMFBlock c_vmfAllowedVerts("allowed_verts");
537 const VMFBlock c_vmfDispInfoChildren[] = { c_vmfNormals, c_vmfDistances, c_vmfOffsets, c_vmfOffsetNormals, c_vmfAlphas, c_vmfTriangleTags, c_vmfAllowedVerts };
538 const VMFBlock c_vmfDispInfo("dispinfo", ARRAY_RANGE(c_vmfDispInfoChildren));
539 const VMFBlock c_vmfSideChildren[] = { c_vmfDispInfo };
540 const VMFBlock c_vmfSide("side", ARRAY_RANGE(c_vmfSideChildren));
541 const VMFBlock c_vmfEditor("editor");
542 const VMFBlock c_vmfVersionInfo("versioninfo");
543 const VMFBlock c_vmfViewSettings("viewsettings");
544 const VMFBlock c_vmfCordon("cordon");
545 const VMFBlock c_vmfGroupChildren[] = { c_vmfEditor };
546 const VMFBlock c_vmfGroup("group", ARRAY_RANGE(c_vmfGroupChildren));
547 const VMFBlock c_vmfCamera("camera");
548 const VMFBlock c_vmfCamerasChildren[] = { c_vmfCamera };
549 const VMFBlock c_vmfCameras("cameras", ARRAY_RANGE(c_vmfCamerasChildren));
550 VMFBlock c_vmfVisGroup("visgroup");
551 VMFBlock c_vmfVisGroups("visgroups", VMFBlockArrayRange(&c_vmfVisGroup, &c_vmfVisGroup+1));
552 const VMFBlock c_vmfSolidChildren[] = { c_vmfSide, c_vmfEditor };
553 const VMFBlock c_vmfSolid("solid", ARRAY_RANGE(c_vmfSolidChildren));
554 const VMFBlock c_vmfConnections("connections");
555 const VMFBlock c_vmfEntityChildren[] = { c_vmfEditor, c_vmfSolid, c_vmfGroup, c_vmfConnections };
556 const VMFBlock c_vmfEntity("entity", ARRAY_RANGE(c_vmfEntityChildren));
557 const VMFBlock c_vmfWorldChildren[] = { c_vmfEditor, c_vmfSolid, c_vmfGroup };
558 const VMFBlock c_vmfWorld("world", ARRAY_RANGE(c_vmfWorldChildren));
559 const VMFBlock c_vmfRootChildren[] = { c_vmfVersionInfo, c_vmfViewSettings, c_vmfVisGroups, c_vmfWorld, c_vmfEntity, c_vmfCameras, c_vmfCordon };
560 const VMFBlock c_vmfRoot("", ARRAY_RANGE(c_vmfRootChildren));
561
562 class VMFInit
563 {
564 public:
565   VMFInit()
566   {
567     c_vmfVisGroup.m_children = VMFBlockArrayRange(&c_vmfVisGroup, &c_vmfVisGroup+1);
568   }
569 };
570
571 VMFInit g_VMFInit;
572
573 int g_vmf_entities;
574 int g_vmf_brushes;
575
576 inline VMFBlock::const_iterator VMFBlock_find(const VMFBlock& block, const char* name)
577 {
578   for(VMFBlock::const_iterator i = block.begin(); i != block.end(); ++i)
579   {
580     if(string_equal(name, (*i).name()))
581     {
582       return i;
583     }
584   }
585   return block.end();
586 }
587
588 void VMF_parseBlock(Tokeniser& tokeniser, const VMFBlock& block)
589 {
590   for(;;)
591   {
592     const char* key = tokeniser.getToken();
593     if(key == 0 || string_equal(key, "}"))
594     {
595       tokeniser.ungetToken();
596       break;
597     }
598     CopiedString tmp(key);
599     tokeniser.nextLine();
600     const char* value = tokeniser.getToken();
601     tokeniser.nextLine();
602     if(string_equal(value, "{"))
603     {
604       VMFBlock::const_iterator i = VMFBlock_find(block, tmp.c_str());
605       ASSERT_MESSAGE(i != block.end(), "error parsing vmf block " << makeQuoted(block.name()) << ": unknown block: " << makeQuoted(tmp.c_str()));
606       if(string_equal(tmp.c_str(), "solid"))
607       {
608         ++g_vmf_brushes;
609       }
610       else if(string_equal(tmp.c_str(), "entity") || string_equal(tmp.c_str(), "world"))
611       {
612         ++g_vmf_entities;
613       }
614       VMF_parseBlock(tokeniser, *i);
615       parseToken(tokeniser, "}");
616       tokeniser.nextLine();
617     }
618     else
619     {
620       // was a pair
621     }
622   }
623 }
624
625 void VMF_Read(scene::Node& root, Tokeniser& tokeniser, EntityCreator& entityTable)
626 {
627   g_vmf_entities = g_vmf_brushes = 0;
628   VMF_parseBlock(tokeniser, c_vmfRoot);
629   globalOutputStream() << g_vmf_entities << " entities\n";
630   globalOutputStream() << g_vmf_brushes << " brushes\n";
631 }
632
633 class MapVMFAPI : public TypeSystemRef, public MapFormat
634 {
635 public:
636   typedef MapFormat Type;
637   STRING_CONSTANT(Name, "mapvmf");
638
639   MapVMFAPI()
640   {
641     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("vmf maps", "*.vmf"));
642     GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("vmf region", "*.reg"));
643   }
644   MapFormat* getTable()
645   {
646     return this;
647   }
648
649   void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
650   {
651     Tokeniser& tokeniser = GlobalScripLibModule::getTable().m_pfnNewSimpleTokeniser(inputStream);
652     VMF_Read(root, tokeniser, entityTable);
653     tokeniser.release();
654   }
655   void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
656   {
657   }
658 };
659
660 typedef SingletonModule<MapVMFAPI, MapDependencies> MapVMFModule;
661
662 MapVMFModule g_MapVMFModule;
663
664
665
666 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
667 {
668   initialiseModule(server);
669
670   g_MapDoom3Module.selfRegister();
671   g_MapQuake4Module.selfRegister();
672   g_MapQ3Module.selfRegister();
673   g_MapQ1Module.selfRegister();
674   g_MapQ2Module.selfRegister();
675   g_MapHalfLifeModule.selfRegister();
676   g_MapVMFModule.selfRegister();
677 }