File: Quake3MapFormat.cpp

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (122 lines) | stat: -rw-r--r-- 2,804 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "Quake3MapFormat.h"

#include "parser/DefTokeniser.h"

#include "Quake3MapReader.h"
#include "Quake3MapWriter.h"

#include "Doom3MapFormat.h"

#include "module/StaticModule.h"

namespace map
{

const StringSet& Quake3MapFormatBase::getDependencies() const
{
	static StringSet _dependencies;

	if (_dependencies.empty())
	{
		_dependencies.insert(MODULE_MAPFORMATMANAGER);
	}

	return _dependencies;
}

void Quake3MapFormatBase::initialiseModule(const IApplicationContext& ctx)
{
	// Register ourselves as map format for maps and regions
	GlobalMapFormatManager().registerMapFormat("map", getSharedToThis());
	GlobalMapFormatManager().registerMapFormat("reg", getSharedToThis());
	GlobalMapFormatManager().registerMapFormat("pfb", getSharedToThis());
}

void Quake3MapFormatBase::shutdownModule()
{
	// Unregister now that we're shutting down
	GlobalMapFormatManager().unregisterMapFormat(getSharedToThis());
}

IMapReaderPtr Quake3MapFormatBase::getMapReader(IMapImportFilter& filter) const
{
	return std::make_shared<Quake3MapReader>(filter);
}

bool Quake3MapFormatBase::allowInfoFileCreation() const
{
	// allow .darkradiant files to be saved
	return true;
}

bool Quake3MapFormatBase::canLoad(std::istream& stream) const
{
	// Instantiate a tokeniser to read the first few tokens
	parser::BasicDefTokeniser<std::istream> tok(stream);

	try
	{
		// Require the opening brace of the first entity as first token
		tok.assertNextToken("{");

		// That's it for the moment being
		return true;
	}
	catch (parser::ParseException&)
	{}

	return false;
}

const std::string& Quake3MapFormat::getMapFormatName() const
{
    static std::string _name = "Quake 3";
    return _name;
}

const std::string& Quake3MapFormat::getGameType() const
{
    static std::string _gameType = "quake3";
    return _gameType;
}

const std::string& Quake3MapFormat::getName() const
{
    static std::string _name("Quake3MapLoader");
    return _name;
}

IMapWriterPtr Quake3MapFormat::getMapWriter() const
{
    return std::make_shared<Quake3MapWriter>();
}

// Quake 3 with alternate brush format

const std::string& Quake3AlternateMapFormat::getMapFormatName() const
{
    static std::string _name = "Quake 3 Alternate";
    return _name;
}

const std::string& Quake3AlternateMapFormat::getGameType() const
{
    static std::string _gameType = "quake3alternate";
    return _gameType;
}

const std::string& Quake3AlternateMapFormat::getName() const
{
    static std::string _name("Quake3AlternateMapLoader");
    return _name;
}

IMapWriterPtr Quake3AlternateMapFormat::getMapWriter() const
{
    return std::make_shared<Quake3AlternateMapWriter>();
}

module::StaticModuleRegistration<Quake3MapFormat> q3MapModule;
module::StaticModuleRegistration<Quake3AlternateMapFormat> q3AlternateMapModule;

} // namespace map