Skip to content

Commit

Permalink
Очередной костыль от наобновления погоды
Browse files Browse the repository at this point in the history
  • Loading branch information
xrSimpodin committed Nov 9, 2018
1 parent bc52abc commit 7411c8c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Game/Resources_SoC_1.0006/gamedata/config/external.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ wpn_bobbing = false
; и статиков condition_progess_bar и cell_item_text.
show_inv_item_condition = false

; Включить фикс восстанавливающий солнце.
; Как побочный эффект при включении - может возникать необновление погоды, чтобы его избежать нужно устанавливать погоду не ранее чем на первом апдейте актора, примерно так:
; level.add_call(
; function() return true end,
; function() level.set_weather(что-то там) end
; )
; Либо, что ещё лучше, использовать скриптовый погодный менеджер из ОГСЕ.
restore_sun_fix = true

; Вычисление и использование правильного положения солнца, вместо позиции из погодных конфигов.
; !Эту опцию желательно использовать в ОГСЕ и прочих модах с полностью скриптовым менеджером погоды!
; При использовании со стандартным погодным менеджером может получиться эффект "вечной ночи"
Expand Down
68 changes: 68 additions & 0 deletions Game/Resources_SoC_1.0006/gamedata/scripts/level_weathers.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
class "WeatherManager"
function WeatherManager:__init()
--printf ("WeatherManager:WeatherManager()")
self.weather_change_day = 0
self.update_time = 0
self.update_level = ""
end

function WeatherManager:reset()
--printf ("WeatherManager:WeatherManager():Reset()")
-- Загрузить кондлист с погодой.
local ini = game_ini() --KRodin: так быстрее же, чем через ini_file().
local weather = utils.cfg_get_string(ini, level.name(), "weathers", db.actor, false, "", "default")
local postprocess = utils.cfg_get_string(ini, level.name(), "postprocess", db.actor, false, "")
if postprocess ~= nil then
printf("LEVEL POSTPROCESS: level: [%s], postprocess: [%s]", level.name(), postprocess)
level.add_pp_effector(postprocess, 999, true)
else
printf("LEVEL POSTPROCESS: level: [%s], postprocess: [none]", level.name())
level.remove_pp_effector(999)
end

if weather == "default" then
-- сетим дефолтовую погоду
self.weather_list = xr_logic.parse_condlist(db.actor, level.name(), "weather", "default")
else
self.weather_list = xr_logic.parse_condlist(db.actor, level.name(), "weather", weather)
end
self:select_weather(true)
end

function WeatherManager:select_weather(now)
self.weather_change_day = level.get_time_days()
self.update_level = level.name()
local weather = xr_logic.pick_section_from_condlist(db.actor, db.actor, self.weather_list)
--printf("WEATHER: '%s' now '%s'", weather, tostring(now))

--KRodin: из-за фикса солнца в движке, погоду нужно устанавливать не ранее, чем на первом апдейте!
level.add_call(
function() return true end,
function() level.set_weather(weather, now) end
)
end

function WeatherManager:load(F)
self.update_level = F:r_stringZ();
self.update_time = F:r_u32();
end

function WeatherManager:save(F)
F:w_stringZ (self.update_level);
F:w_u32 (self.update_time);
end

function WeatherManager:update()
if self.update_time <= time_global() then
printf("weather_update day [%s]", level.get_time_days())

if self.update_level ~= level.name() then
self:select_weather(true)
end

if self.weather_change_day ~= level.get_time_days() then
self:select_weather(false)
end
self.update_time = self.update_time + 10000
end
end
3 changes: 2 additions & 1 deletion ogsr_engine/xrCore/xrCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ class XRCORE_API xrCore
colorize_untradable = 1ull << 33,
select_mode_1342 = 1ull << 34,
old_outfit_slot_style = 1ull << 35,
npc_simplified_shooting = 1ull << 36;
npc_simplified_shooting = 1ull << 36,
restore_sun_fix = 1ull << 37;
};

void _initialize (LPCSTR ApplicationName, LogCallback cb=0, BOOL init_fs=TRUE, LPCSTR fs_fname=0);
Expand Down
9 changes: 5 additions & 4 deletions ogsr_engine/xrGame/game_cl_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ void game_cl_GameState::net_import_GameTime (NET_Packet& P)
float EnvironmentTimeFactor;
P.r_float (EnvironmentTimeFactor);

//u64 OldTime = Level().GetEnvironmentGameTime();
u64 OldTime = Level().GetEnvironmentGameTime();
Level().SetEnvironmentGameTimeFactor (GameEnvironmentTime,EnvironmentTimeFactor);
//KRodin: закомментировал для восттановления солнца. Внимание! Установку погоды теперь нужно делать не ранее, чем на первом апдейте. В ОГСЕ проблем быть не должно, там погодный менеджер всё контроллирует.
//if (OldTime > GameEnvironmentTime)
// GamePersistent().Environment().Invalidate();

if (!Core.Features.test(xrCore::Feature::restore_sun_fix))
if (OldTime > GameEnvironmentTime)
GamePersistent().Environment().Invalidate();
}

void game_cl_GameState::net_import_state (NET_Packet& P)
Expand Down
1 change: 1 addition & 0 deletions ogsr_engine/xr_3da/x_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void InitConsole ()
CORE_FEATURE_SET( ruck_flag_preferred, "features" );
CORE_FEATURE_SET( old_outfit_slot_style, "features" );
CORE_FEATURE_SET( npc_simplified_shooting, "features" );
CORE_FEATURE_SET( restore_sun_fix, "features" );
}

void InitInput ()
Expand Down

0 comments on commit 7411c8c

Please sign in to comment.