Loads in the map and all submodels.
(String name, boolean clientload, int[] checksum)
| 185 | * Loads in the map and all submodels. |
| 186 | */ |
| 187 | public cmodel_t CM_LoadMap(String name, boolean clientload, int[] checksum) { |
| 188 | Com.DPrintf("CM_LoadMap(" + name + ")...\n"); |
| 189 | byte buf[]; |
| 190 | qfiles.dheader_t header; |
| 191 | int length; |
| 192 | |
| 193 | map_noareas = Cvar.getInstance().Get("map_noareas", "0", 0); |
| 194 | |
| 195 | if (map_name.equals(name) |
| 196 | && (clientload || 0 == Cvar.getInstance().VariableValue("flushmap"))) { |
| 197 | |
| 198 | checksum[0] = last_checksum; |
| 199 | |
| 200 | if (!clientload) { |
| 201 | Arrays.fill(portalopen, false); |
| 202 | FloodAreaConnections(); |
| 203 | } |
| 204 | return map_cmodels[0]; // still have the right version |
| 205 | } |
| 206 | |
| 207 | // free old stuff |
| 208 | numnodes = 0; |
| 209 | numleafs = 0; |
| 210 | numcmodels = 0; |
| 211 | numvisibility = 0; |
| 212 | numentitychars = 0; |
| 213 | map_entitystring = ""; |
| 214 | map_name = ""; |
| 215 | |
| 216 | if (name == null || name.length() == 0) { |
| 217 | numleafs = 1; |
| 218 | numclusters = 1; |
| 219 | numareas = 1; |
| 220 | checksum[0] = 0; |
| 221 | return map_cmodels[0]; |
| 222 | // cinematic servers won't have anything at all |
| 223 | } |
| 224 | |
| 225 | // |
| 226 | // load the file |
| 227 | // |
| 228 | buf = FS.LoadFile(name); |
| 229 | |
| 230 | if (buf == null) |
| 231 | Com.Error(Defines.ERR_DROP, "Couldn't load " + name); |
| 232 | |
| 233 | length = buf.length; |
| 234 | |
| 235 | ByteBuffer bbuf = ByteBuffer.wrap(buf); |
| 236 | |
| 237 | last_checksum = MD4.Com_BlockChecksum(buf, length); |
| 238 | checksum[0] = last_checksum; |
| 239 | |
| 240 | header = new qfiles.dheader_t(bbuf.slice()); |
| 241 | |
| 242 | if (header.version != Defines.BSPVERSION) |
| 243 | Com.Error(Defines.ERR_DROP, "CMod_LoadBrushModel: " + name |
| 244 | + " has wrong version number (" + header.version |