MCPcopy Create free account
hub / github.com/ZDoom/gzdoom / P_OpenMapData

Function P_OpenMapData

src/p_openmap.cpp:114–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112//===========================================================================
113
114MapData *P_OpenMapData(const char * mapname, bool justcheck)
115{
116 MapData * map = new MapData;
117 FileReader * wadReader = nullptr;
118 bool externalfile = !strnicmp(mapname, "file:", 5);
119
120 if (externalfile)
121 {
122 mapname += 5;
123 if (!FileExists(mapname))
124 {
125 delete map;
126 return NULL;
127 }
128 map->resource = FResourceFile::OpenResourceFile(mapname);
129 wadReader = map->resource->GetContainerReader();
130 }
131 else
132 {
133 FString fmt;
134 int lump_wad;
135 int lump_map;
136 int lump_name = -1;
137
138 // Check for both *.wad and *.map in order to load Build maps
139 // as well. The higher one will take precedence.
140 // Names with more than 8 characters will only be checked as .wad and .map.
141 if (strlen(mapname) <= 8) lump_name = fileSystem.CheckNumForName(mapname);
142 fmt.Format("maps/%s.wad", mapname);
143 lump_wad = fileSystem.CheckNumForFullName(fmt.GetChars());
144 fmt.Format("maps/%s.map", mapname);
145 lump_map = fileSystem.CheckNumForFullName(fmt.GetChars());
146
147 if (lump_name > lump_wad && lump_name > lump_map && lump_name != -1)
148 {
149 int lumpfile = fileSystem.GetFileContainer(lump_name);
150 int nextfile = fileSystem.GetFileContainer(lump_name+1);
151
152 map->lumpnum = lump_name;
153
154 if (lumpfile != nextfile)
155 {
156 // The following lump is from a different file so whatever this is,
157 // it is not a multi-lump Doom level so let's assume it is a Build map.
158 map->MapLumps[0].Reader = fileSystem.ReopenFileReader(lump_name);
159 if (!P_IsBuildMap(map))
160 {
161 delete map;
162 return NULL;
163 }
164 return map;
165 }
166
167 // This case can only happen if the lump is inside a real WAD file.
168 // As such any special handling for other types of lumps is skipped.
169 map->MapLumps[0].Reader = fileSystem.ReopenFileReader(lump_name);
170 strncpy(map->MapLumps[0].Name, fileSystem.GetFileFullName(lump_name), 8);
171 map->InWad = true;

Callers 5

CCMDFunction · 0.85
P_CheckMapDataFunction · 0.85
P_SetupLevelFunction · 0.85
STAT_ChangeLevelFunction · 0.85
DEFINE_ACTION_FUNCTIONFunction · 0.85

Calls 15

P_IsBuildMapFunction · 0.85
stricmpFunction · 0.85
GetMapIndexFunction · 0.85
I_ErrorFunction · 0.85
uppercopyFunction · 0.85
GetContainerReaderMethod · 0.80
CheckNumForFullNameMethod · 0.80
GetFileContainerMethod · 0.80
GetFileFullNameMethod · 0.80
EntryCountMethod · 0.80
FileExistsFunction · 0.50
CheckNumForNameMethod · 0.45

Tested by

no test coverage detected