void MapInstanced::CreateInstance(uint32 InstanceId, Map* &map) { if (!IsValidInstance(InstanceId)) { // instance is invalid, need to verify map presence if (map) { // map for the instance is present, but the instance itself is no more valid, destroy map Guard guard(*this); map->Reset(); m_InstancedMaps.erase(InstanceId); delete map; map = NULL; } } // verify, if we have the map created, and create it if needed if (!map) { // map does not exist, create it Guard guard(*this); map = new Map(GetId(), GetGridExpiry(), InstanceId); m_InstancedMaps[InstanceId] = map; } }
Instance *Instance::LoadInstance(wxFileName rootDir) { if (IsValidInstance(rootDir)) return new Instance(rootDir); else return NULL; }
Instance *Instance::LoadInstance(wxString rootDir) { if (IsValidInstance(wxFileName::DirName(rootDir))) { wxFileConfig fcfg(wxEmptyString, wxEmptyString, Path::Combine(rootDir, "instance.cfg"), wxEmptyString, wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_RELATIVE_PATH); int type = 0; if (!fcfg.Read("type", &type)) { type = INST_TYPE_STANDARD; } switch (type) { case INST_TYPE_STANDARD: default: return new StdInstance(rootDir); break; } } else return NULL; }