sammilucia / cyberpunk-ultra-plus

Cyberpunk Ultra Plus
MIT License
20 stars 6 forks source link

Rain Detect Bug? #18

Open semool opened 6 months ago

semool commented 6 months ago

https://github.com/sammilucia/cyberpunk-ultra-plus/blob/af07cd80d02ae19deb6713c8a8e260beaea83179/UltraPlus/init.lua#L357C9-L359C43

var.settings.rain and var.settings.indoors are referenced in the DoRainFix() Function. So they must be set before run the DoRainFix() Function:

var.settings.rain = testRain var.settings.indoors = testIndoors DoRainFix()

sammilucia commented 6 months ago

it shouldn't matter, because the first time it runs it will sort itself out... that's how it's designed (unless I haven't thought it through properly?)

semool commented 6 months ago
local function DoRainFix()
    -- enable particle PT integration unless player is outdoors AND it's raining
    if var.settings.indoors or not var.settings.rain then
        logger.info("It's not raining... Enabling separate particle colour")
        SetOption("Rendering", "DLSSDSeparateParticleColor", true)
        return
    end

    logger.info("It's raining... Disabling separate particle colour")
    SetOption("Rendering", "DLSSDSeparateParticleColor", false)
end

local function DoFastUpdate()

    local testRain = Game.GetWeatherSystem():GetRainIntensity() > 0 and true or false
    local testIndoors = IsEntityInInteriorArea(GetPlayer())
    local testNrd = GetOption("RayTracing", "EnableNRD")

    if testRain ~= var.settings.rain or testIndoors ~= var.settings.indoors then
        DoRainFix()
        var.settings.rain = testRain
        var.settings.indoors = testIndoors
    end

You are outside and it begins to rain. The function DoFastUpdate() detect this with local testRain. var.settings.rain is currently set to "0", its not raining. Now the function DoRainFix() is triggered. the first line in the function checks var.settings.rain which is still set to "0". The Log says its not raining. Then the vars will be set. Now testRain = var.settings.rain and dorainfix will not triggered again :)

In DoFastUpdate you must set the vars first, then trigger DoRainFix() and all is working in the first run.