Subversion Repositories tpanel

Rev

Rev 446 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 446 Rev 462
Line 41... Line 41...
41
 
41
 
42
using std::string;
42
using std::string;
43
using std::vector;
43
using std::vector;
44
using namespace Expat;
44
using namespace Expat;
45
 
45
 
46
TMap::TMap(const std::string& file)
46
TMap::TMap(const std::string& file, bool tp)
47
    : mFile(file)
47
    : mFile(file),
-
 
48
      mIsTP5(tp)
48
{
49
{
49
    DECL_TRACER("TMap::TMap(std::string& file)");
50
    DECL_TRACER("TMap::TMap(std::string& file, bool tp)");
50
 
51
 
51
    if (!fs::exists(file))
52
    if (!fs::exists(file))
52
    {
53
    {
53
        MSG_ERROR("File " << file << " does not exist!");
54
        MSG_ERROR("File " << file << " does not exist!");
54
        mError = true;
55
        mError = true;
Line 62... Line 63...
62
bool TMap::readMap()
63
bool TMap::readMap()
63
{
64
{
64
    DECL_TRACER("TMap::readMap()");
65
    DECL_TRACER("TMap::readMap()");
65
 
66
 
66
    string path = makeFileName(mFile, "map.xma");
67
    string path = makeFileName(mFile, "map.xma");
67
    vector<string> elements = { "cm", "am", "lm", "bm", "sm", "strm", "pm" };
68
    vector<string> elements = { "cm", "am", "lm", "bm" };
-
 
69
 
-
 
70
    if (mIsTP5)
-
 
71
        elements.push_back("evpf");
-
 
72
    else
-
 
73
    {
-
 
74
        elements.push_back("sm");
-
 
75
        elements.push_back("strm");
-
 
76
        elements.push_back("pm");
-
 
77
    }
68
 
78
 
69
    if (!isValidFile())
79
    if (!isValidFile())
70
    {
80
    {
71
        MSG_ERROR("File \"" << path << "\" is not a regular readable file!");
81
        MSG_ERROR("File \"" << path << "\" is not a regular readable file!");
72
        return false;
82
        return false;
Line 95... Line 105...
95
        }
105
        }
96
 
106
 
97
        MAP_T map;
107
        MAP_T map;
98
        MAP_BM_T mapBm;
108
        MAP_BM_T mapBm;
99
        MAP_PM_T mapPm;
109
        MAP_PM_T mapPm;
-
 
110
        MAP_EVPF_T mapEvpf;
100
        string name, content;
111
        string name, content;
101
 
112
 
102
        while ((index = xml.getNextElementFromIndex(index, &name, nullptr, nullptr)) != TExpat::npos)
113
        while ((index = xml.getNextElementFromIndex(index, &name, nullptr, nullptr)) != TExpat::npos)
103
        {
114
        {
104
            string el = name;
115
            string el = name;
Line 149... Line 160...
149
                                mapBm.sl = xml.convertElementToInt(content);
160
                                mapBm.sl = xml.convertElementToInt(content);
150
                            else if (im.compare("pn") == 0)
161
                            else if (im.compare("pn") == 0)
151
                                mapBm.pn = content;
162
                                mapBm.pn = content;
152
                            else if (im.compare("bn") == 0)
163
                            else if (im.compare("bn") == 0)
153
                                mapBm.bn = content;
164
                                mapBm.bn = content;
-
 
165
                            else if (im.compare("rc") == 0)
-
 
166
                                mapBm.rc = xml.convertElementToInt(content);
154
 
167
 
155
                            oldIndex = index;
168
                            oldIndex = index;
156
                        }
169
                        }
157
 
170
 
158
                        mMap.map_bm.push_back(mapBm);
171
                        mMap.map_bm.push_back(mapBm);
Line 178... Line 191...
178
                        else if (e.compare("pn") == 0)
191
                        else if (e.compare("pn") == 0)
179
                            mapPm.pn = content;
192
                            mapPm.pn = content;
180
                        else if (e.compare("bn") == 0)
193
                        else if (e.compare("bn") == 0)
181
                            mapPm.bn = content;
194
                            mapPm.bn = content;
182
                    }
195
                    }
-
 
196
                    else if (mapIter->compare("evpf") == 0)
-
 
197
                    {
-
 
198
                        if (e.compare("a") == 0)
-
 
199
                            mapEvpf.a = xml.convertElementToInt(content);
-
 
200
                        else if (e.compare("t") == 0)
-
 
201
                            mapEvpf.t = content;
-
 
202
                        else if (e.compare("pg") == 0)
-
 
203
                            mapEvpf.pg = xml.convertElementToInt(content);
-
 
204
                        else if (e.compare("bt") == 0)
-
 
205
                            mapEvpf.bt = xml.convertElementToInt(content);
-
 
206
                        else if (e.compare("ev") == 0)
-
 
207
                            mapEvpf.ev = content;
-
 
208
                        else if (e.compare("ai") == 0)
-
 
209
                            mapEvpf.ai = xml.convertElementToInt(content);
-
 
210
                    }
183
 
211
 
184
                    oldIndex = index;
212
                    oldIndex = index;
185
                }
213
                }
186
 
214
 
187
                if (mapIter->compare("cm") == 0)
215
                if (mapIter->compare("cm") == 0)
Line 192... Line 220...
192
                    mMap.map_lm.push_back(map);
220
                    mMap.map_lm.push_back(map);
193
                else if (mapIter->compare("strm") == 0)
221
                else if (mapIter->compare("strm") == 0)
194
                    mMap.map_strm.push_back(map);
222
                    mMap.map_strm.push_back(map);
195
                else if (mapIter->compare("pm") == 0)
223
                else if (mapIter->compare("pm") == 0)
196
                    mMap.map_pm.push_back(mapPm);
224
                    mMap.map_pm.push_back(mapPm);
-
 
225
                else if (mapIter->compare("evpf") == 0)
-
 
226
                    mMap.map_evpf.push_back(mapEvpf);
197
 
227
 
198
                if (index == TExpat::npos)
228
                if (index == TExpat::npos)
199
                    index = oldIndex + 1;
229
                    index = oldIndex + 1;
200
            }
230
            }
201
 
231
 
Line 370... Line 400...
370
 
400
 
371
bool TMap::soundExist(const string& sname)
401
bool TMap::soundExist(const string& sname)
372
{
402
{
373
    DECL_TRACER("TAmxCommands::soundExist(const string sname)");
403
    DECL_TRACER("TAmxCommands::soundExist(const string sname)");
374
 
404
 
-
 
405
    if (mIsTP5)
-
 
406
        return false;
-
 
407
 
375
    if (mMap.map_sm.size() == 0)
408
    if (mMap.map_sm.size() == 0)
376
        return false;
409
        return false;
377
 
410
 
378
    vector<string>::iterator iter;
411
    vector<string>::iterator iter;
379
 
412