Although weather sync was added by Koncord to the rewrite in fd721143e2 in a way that used surprisingly few lines of code, it relied on the server requesting weather states every second from authority players and sending them to non-authority players, while also allowing only very sudden weather transitions across regions, i.e. if there was one player in the Ascadian Isles who had stormy weather, and another player with clear weather in the Bitter Coast Region walked across to the Ascadian Isles, that player was instantly made to have stormy weather with no kind of transition at all.
My approach solves both of those problems. It solves the packet spam by only sending weather updates to the server when weather changes happen or when there are new arrivals to a weather authority's region, and it allows for both sudden weather transitions when players teleport to a region and for soft, gradual transitions when players walk across to a region. It is inspired by my previous actor sync, and uses a WorldRegionAuthority packet to set players as region authorities in a similar way to how ActorAuthority sets players as cell AI authorities. Weather changes are created only by the region authority for a given region, and weather packets are also only sent by that authority.
However, it should be noted that gradual weather transitions are used by default in this implementation. To use sudden weather transitions, the serverside Lua scripts need to forward WorldWeather packets with the forceWeather boolean set to true. That is, however, already handled by our default Lua scripts in situations where it makes sense.
This allows the distant land to actually be seen when the user enables it. The
values used are replicated from MGE XE's default settings and should probably
be exposed somewhere.
Fixed several issues:
* Waiting/jail time/training all now properly skip remaining transitions
* ChangeWeather no longer permanently sets the region's weather
* ChangeWeather being called during a transition now correctly queues up
another transition
* Corrected transition delta and factor calculations
* ModRegion settings are now saved
Reversed some formulas for Transition Delta and Clouds Maximum Percent
and implemented them. Refactored Weather some to encapsulate those
formulas (to more closely match MoonModel). Did some small cleanup of
WeatherManager.
Added code to hide the moons, sun, and stars for certain weather
effects. Lightly refactored CelestialBody and derived classes. Fixed
moons switching phase at 24:00.
The progress is not particularly accurate. It simply uses the current / total number of records written/read as indication. Cell records are currently the largest by far, but there is a good chance that could be optimized using a change tracking system.
- Fix indentation
- Consider any kind of light, not just torch_infinite_time
- Hostile NPCs should also wear lights, if they have nothing else that could use the slot (or a twohanded weapon)
- Remove redundant code and don't add additional lights to the inventory
- World::isDark returns false for interiors which are unaffected by weather
Removed changing speed of weather transition introduced in previous
commit. Instead try to detect player "teleporting" (ie. coc),
and then switch instantly to the next weather type.
Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
Added method in WeatherManger and World which returns true if it is night.
This method is used later in character controller to show torches
(or other sources of light) at night and hide them at day.
Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>