diff --git a/doomsday/client/include/world/map.h b/doomsday/client/include/world/map.h index bdf74aa3f9..1e4d83c094 100644 --- a/doomsday/client/include/world/map.h +++ b/doomsday/client/include/world/map.h @@ -657,6 +657,11 @@ class Map #endif // __CLIENT__ + /** + * To be called following an engine reset to update the map state. + */ + void update(); + public: /// @todo Make private: /** diff --git a/doomsday/client/src/world/map.cpp b/doomsday/client/src/world/map.cpp index ba006e6228..fa5af1cad9 100644 --- a/doomsday/client/src/world/map.cpp +++ b/doomsday/client/src/world/map.cpp @@ -32,6 +32,7 @@ #include "de_platform.h" #include "de_base.h" #include "de_console.h" // Con_GetInteger +#include "de_defs.h" #include "m_nodepile.h" #include "BspLeaf" @@ -56,6 +57,9 @@ #include "world/world.h" #include "render/r_main.h" // validCount +#ifdef __CLIENT__ +# include "render/sky.h" +#endif #include "world/map.h" @@ -2478,6 +2482,77 @@ void Map::updateMissingMaterialsForLinesOfSector(Sector const &sec) #endif // __CLIENT__ +void Map::update() +{ +#ifdef __CLIENT__ + // Update all surfaces. + foreach(Sector *sector, d->sectors) + foreach(Plane *plane, sector->planes()) + { + plane->surface().markAsNeedingDecorationUpdate(); + } + + foreach(Line *line, d->lines) + for(int i = 0; i < 2; ++i) + { + Line::Side &side = line->side(i); + if(!side.hasSections()) continue; + + side.top().markAsNeedingDecorationUpdate(); + side.middle().markAsNeedingDecorationUpdate(); + side.bottom().markAsNeedingDecorationUpdate(); + } + + /// @todo Is this even necessary? + foreach(Polyobj *polyobj, d->polyobjs) + foreach(Line *line, polyobj->lines()) + { + line->front().middle().markAsNeedingDecorationUpdate(); + } + + // Rebuild the surface lists. + buildSurfaceLists(); + +#endif // __CLIENT__ + + // Reapply values defined in MapInfo (they may have changed). + ded_mapinfo_t *mapInfo = Def_GetMapInfo(reinterpret_cast(&d->uri)); + if(!mapInfo) + { + // Use the default def instead. + Uri defaultDefUri(RC_NULL, "*"); + mapInfo = Def_GetMapInfo(reinterpret_cast(&defaultDefUri)); + } + + if(mapInfo) + { + _globalGravity = mapInfo->gravity; + _ambientLightLevel = mapInfo->ambient * 255; + } + else + { + // No map info found -- apply defaults. + _globalGravity = 1.0f; + _ambientLightLevel = 0; + } + + _effectiveGravity = _globalGravity; + +#ifdef __CLIENT__ + // Reconfigure the sky. + /// @todo Sky needs breaking up into multiple components. There should be + /// a representation on server side and a logical entity which the renderer + /// visualizes. We also need multiple concurrent skies for BOOM support. + ded_sky_t *skyDef = 0; + if(mapInfo) + { + skyDef = Def_GetSky(mapInfo->skyID); + if(!skyDef) skyDef = &mapInfo->sky; + } + Sky_Configure(skyDef); +#endif +} + /// Runtime map editing ----------------------------------------------------- /// Used when sorting vertex line owners. diff --git a/doomsday/client/src/world/world.cpp b/doomsday/client/src/world/world.cpp index c3da4d9ab4..43cd9f603b 100644 --- a/doomsday/client/src/world/world.cpp +++ b/doomsday/client/src/world/world.cpp @@ -351,27 +351,15 @@ DENG2_PIMPL(World) << TABBED("BSP Leafs", map->bspLeafCount()) << TABBED("Segments", map->segmentCount()); - // See what mapinfo says about this map. - Uri mapUri = map->uri(); - ded_mapinfo_t *mapInfo = Def_GetMapInfo(reinterpret_cast(&mapUri)); + // See what MapInfo says about this map. + ded_mapinfo_t *mapInfo = Def_GetMapInfo(reinterpret_cast(&map->uri())); if(!mapInfo) { + // Use the default def instead. Uri defaultMapUri("*", RC_NULL); mapInfo = Def_GetMapInfo(reinterpret_cast(&defaultMapUri)); } -#ifdef __CLIENT__ - ded_sky_t *skyDef = 0; - if(mapInfo) - { - skyDef = Def_GetSky(mapInfo->skyID); - if(!skyDef) - skyDef = &mapInfo->sky; - } - Sky_Configure(skyDef); -#endif - - // Setup accordingly. if(mapInfo) { map->_globalGravity = mapInfo->gravity; @@ -379,13 +367,24 @@ DENG2_PIMPL(World) } else { - // No map info found, so set some basic stuff. + // No map info found -- apply defaults. map->_globalGravity = 1.0f; map->_ambientLightLevel = 0; } map->_effectiveGravity = map->_globalGravity; +#ifdef __CLIENT__ + // Reconfigure the sky. + ded_sky_t *skyDef = 0; + if(mapInfo) + { + skyDef = Def_GetSky(mapInfo->skyID); + if(!skyDef) skyDef = &mapInfo->sky; + } + Sky_Configure(skyDef); +#endif + // Init the thinker lists (public and private). map->thinkers().initLists(0x1 | 0x2); @@ -516,7 +515,7 @@ DENG2_PIMPL(World) // Run the special map setup command, which the user may alias to do // something useful. - String cmd = "init-" + mapUri.resolved(); + String cmd = "init-" + map->uri().resolved(); if(Con_IsValidCommand(cmd.toUtf8().constData())) { Con_Executef(CMDS_SCRIPT, false, "%s", cmd.toUtf8().constData()); @@ -645,73 +644,10 @@ void World::update() ddpl->pSprites[0].statePtr = ddpl->pSprites[1].statePtr = 0; } + // Update the current map too. if(d->map) { -#ifdef __CLIENT__ - - // Update all world surfaces. - foreach(Sector *sector, d->map->sectors()) - foreach(Plane *plane, sector->planes()) - { - plane->surface().markAsNeedingDecorationUpdate(); - } - - foreach(Line *line, d->map->lines()) - for(int i = 0; i < 2; ++i) - { - Line::Side &side = line->side(i); - if(!side.hasSections()) continue; - - side.top().markAsNeedingDecorationUpdate(); - side.middle().markAsNeedingDecorationUpdate(); - side.bottom().markAsNeedingDecorationUpdate(); - } - - /// @todo Is this even necessary? - foreach(Polyobj *polyobj, d->map->polyobjs()) - foreach(Line *line, polyobj->lines()) - { - line->front().middle().markAsNeedingDecorationUpdate(); - } - - d->map->buildSurfaceLists(); - -#endif // __CLIENT__ - - // See what mapinfo says about this map. - Uri mapUri = d->map->uri(); - ded_mapinfo_t *mapInfo = Def_GetMapInfo(reinterpret_cast(&mapUri)); - if(!mapInfo) - { - // Use the default def instead. - Uri defaultDefUri = de::Uri(RC_NULL, "*"); - mapInfo = Def_GetMapInfo(reinterpret_cast(&defaultDefUri)); - } - - // Reconfigure the sky - ded_sky_t *skyDef = 0; - if(mapInfo) - { - skyDef = Def_GetSky(mapInfo->skyID); - if(!skyDef) skyDef = &mapInfo->sky; - } -#ifdef __CLIENT__ - Sky_Configure(skyDef); -#endif - - if(mapInfo) - { - d->map->_globalGravity = mapInfo->gravity; - d->map->_ambientLightLevel = mapInfo->ambient * 255; - } - else - { - // No map info found -- apply defaults. - d->map->_globalGravity = 1.0f; - d->map->_ambientLightLevel = 0; - } - - d->map->_effectiveGravity = d->map->_globalGravity; + d->map->update(); } }