From 6b74fec8ed4def2da942b57e6f836af94f369890 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 17 May 2012 17:13:41 +0200 Subject: [PATCH 1/4] don't do a half finished cell change, when trying to switch to an interior cell that does not exist --- apps/openmw/mwworld/scene.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 6f9f3ed3ed..caaef52649 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -251,6 +251,9 @@ namespace MWWorld void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) { std::cout << "Changing to interior\n"; + + Ptr::CellStore *cell = mWorld->getInterior(cellName); + // remove active CellStoreCollection::iterator active = mActiveCells.begin(); @@ -261,11 +264,9 @@ namespace MWWorld // Load cell. std::cout << "cellName:" << cellName << std::endl; - Ptr::CellStore *cell = mWorld->getInterior(cellName); loadCell (cell); - // adjust player mCurrentCell = cell; playerCellChange (cell, position); From ae77e7b0d84a0fa92e9a13f558d6ca0bf901efe0 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 17 May 2012 18:11:34 +0200 Subject: [PATCH 2/4] don't try to retrieve land data from non-predefined cells. --- apps/openmw/mwworld/scene.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index caaef52649..e4236b2f7f 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -82,7 +82,11 @@ namespace MWWorld } if (!((*iter)->cell->data.flags & ESM::Cell::Interior)) - mPhysics->removeHeightField( (*iter)->cell->data.gridX, (*iter)->cell->data.gridY ); + { + ESM::Land* land = mWorld->getStore().lands.search((*iter)->cell->data.gridX,(*iter)->cell->data.gridY); + if (land) + mPhysics->removeHeightField( (*iter)->cell->data.gridX, (*iter)->cell->data.gridY ); + } } mRendering.removeCell(*iter); @@ -118,9 +122,10 @@ namespace MWWorld if (!(cell->cell->data.flags & ESM::Cell::Interior)) { ESM::Land* land = mWorld->getStore().lands.search(cell->cell->data.gridX,cell->cell->data.gridY); - mPhysics->addHeightField (land->landData->heights, - cell->cell->data.gridX, cell->cell->data.gridY, - 0, ( worldsize/(verts-1) ), verts); + if (land) + mPhysics->addHeightField (land->landData->heights, + cell->cell->data.gridX, cell->cell->data.gridY, + 0, ( worldsize/(verts-1) ), verts); } mRendering.configureAmbient(*cell); From 0afda15ce9f0e564abceef4773e724625d80fc40 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 17 May 2012 18:14:33 +0200 Subject: [PATCH 3/4] fix for cells that have no region. --- apps/openmw/mwgui/window_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/window_manager.cpp b/apps/openmw/mwgui/window_manager.cpp index dfac55beb9..610f1b2f25 100644 --- a/apps/openmw/mwgui/window_manager.cpp +++ b/apps/openmw/mwgui/window_manager.cpp @@ -447,7 +447,8 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) else { const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->region); - name = region->name; + if (region) + name = region->name; } map->setCellName( name ); From 375c198ebd9d350dd3d137c3faf8af7382e3e032 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 17 May 2012 18:21:05 +0200 Subject: [PATCH 4/4] WeatherManager: fix for cells that have no region. --- apps/openmw/mwworld/weather.cpp | 73 +++++++++++++++++---------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index bcbb96eecf..316463f539 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -499,51 +499,54 @@ void WeatherManager::update(float duration) mCurrentRegion = regionstr; mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*3600; - std::string weather; + std::string weather = "clear"; if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) weather = mRegionOverrides[regionstr]; else { // get weather probabilities for the current region - const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.find (regionstr); + const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.search (regionstr); - float clear = region->data.clear/255.f; - float cloudy = region->data.cloudy/255.f; - float foggy = region->data.foggy/255.f; - float overcast = region->data.overcast/255.f; - float rain = region->data.rain/255.f; - float thunder = region->data.thunder/255.f; - float ash = region->data.ash/255.f; - float blight = region->data.blight/255.f; - //float snow = region->data.a/255.f; - //float blizzard = region->data.b/255.f; + if (region != 0) + { + float clear = region->data.clear/255.f; + float cloudy = region->data.cloudy/255.f; + float foggy = region->data.foggy/255.f; + float overcast = region->data.overcast/255.f; + float rain = region->data.rain/255.f; + float thunder = region->data.thunder/255.f; + float ash = region->data.ash/255.f; + float blight = region->data.blight/255.f; + //float snow = region->data.a/255.f; + //float blizzard = region->data.b/255.f; - // re-scale to 100 percent - const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; + // re-scale to 100 percent + const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; - float random = ((rand()%100)/100.f) * total; + float random = ((rand()%100)/100.f) * total; - //if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - // weather = "blizzard"; - //else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) - // weather = "snow"; - /*else*/ if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) - weather = "blight"; - else if (random >= thunder+rain+overcast+foggy+cloudy+clear) - weather = "ashstorm"; - else if (random >= rain+overcast+foggy+cloudy+clear) - weather = "thunderstorm"; - else if (random >= overcast+foggy+cloudy+clear) - weather = "rain"; - else if (random >= foggy+cloudy+clear) - weather = "overcast"; - else if (random >= cloudy+clear) - weather = "foggy"; - else if (random >= clear) - weather = "cloudy"; - else - weather = "clear"; + //if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + // weather = "blizzard"; + //else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) + // weather = "snow"; + /*else*/ if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) + weather = "blight"; + else if (random >= thunder+rain+overcast+foggy+cloudy+clear) + weather = "ashstorm"; + else if (random >= rain+overcast+foggy+cloudy+clear) + weather = "thunderstorm"; + else if (random >= overcast+foggy+cloudy+clear) + weather = "rain"; + else if (random >= foggy+cloudy+clear) + weather = "overcast"; + else if (random >= cloudy+clear) + weather = "foggy"; + else if (random >= clear) + weather = "cloudy"; + else + weather = "clear"; + } } setWeather(weather, false);