| 2870 | } |
| 2871 | |
| 2872 | void CEntitySystem::LoadInternalState(IDataReadStream& reader) |
| 2873 | { |
| 2874 | // get layers in the level |
| 2875 | std::vector<CEntityLayer*> allLayers; |
| 2876 | for (TLayers::iterator it = m_layers.begin(); |
| 2877 | it != m_layers.end(); ++it) |
| 2878 | { |
| 2879 | CEntityLayer* pLayer = it->second; |
| 2880 | allLayers.push_back(pLayer); |
| 2881 | } |
| 2882 | |
| 2883 | // enable layers that are explicitly listed |
| 2884 | const uint32 numLayers = reader.ReadUint32(); |
| 2885 | for (uint32 i = 0; i < numLayers; ++i) |
| 2886 | { |
| 2887 | const string layerName = reader.ReadString(); |
| 2888 | |
| 2889 | // find local layer |
| 2890 | CEntityLayer* pLayer = NULL; |
| 2891 | for (TLayers::iterator it = m_layers.begin(); |
| 2892 | it != m_layers.end(); ++it) |
| 2893 | { |
| 2894 | if (it->second->GetName() == layerName) |
| 2895 | { |
| 2896 | pLayer = it->second; |
| 2897 | break; |
| 2898 | } |
| 2899 | } |
| 2900 | |
| 2901 | // No layer found |
| 2902 | if (NULL == pLayer) |
| 2903 | { |
| 2904 | gEnv->pLog->LogAlways("Layer with name '%s' not found in local data", |
| 2905 | layerName.c_str()); |
| 2906 | continue; |
| 2907 | } |
| 2908 | |
| 2909 | // remove from the "all layers" list - what's left will be hidden |
| 2910 | std::vector<CEntityLayer*>::iterator it = std::find(allLayers.begin(), allLayers.end(), pLayer); |
| 2911 | if (it != allLayers.end()) |
| 2912 | { |
| 2913 | allLayers.erase(it); |
| 2914 | } |
| 2915 | |
| 2916 | pLayer->Enable(true, false, false); // NON RECURSIVE |
| 2917 | |
| 2918 | // show/hide the objects also |
| 2919 | if (pLayer->GetId() != 0) |
| 2920 | { |
| 2921 | gEnv->p3DEngine->ActivateObjectsLayer(pLayer->GetId(), true, true, true, true, pLayer->GetName(), NULL, false); |
| 2922 | } |
| 2923 | } |
| 2924 | |
| 2925 | // Hide rest of the layers |
| 2926 | for (std::vector<CEntityLayer*>::const_iterator it = allLayers.begin(); |
| 2927 | it != allLayers.end(); ++it) |
| 2928 | { |
| 2929 | CEntityLayer* pLayer = *it; |
nothing calls this directly
no test coverage detected