Jump to content

fumarolelocaltemperature returns an invalid temperature value when not cached


hoxi
  • Fixed

Not that big of a deal I don't think, but I thought I'd point it out:

function self:GetTemperatureAtXZ(x, z)
    local tx, ty = _map:GetTileCoordsAtPoint(x, 0, z)
    local index = _cachetemperature:GetIndex(tx, ty)
    local _cachedtemp = _cachetemperature:GetDataAtIndex(index)
    if _cachedtemp then
        return _cachedtemp ~= 0 and Lerp(_state.temperature, _currenttemperature, _cachedtemp)
    end

    local num_fumarole = 0
    local tile_area = 0
    for off_tx = -TILE_SEARCH_RADIUS, TILE_SEARCH_RADIUS do
        for off_ty = -TILE_SEARCH_RADIUS, TILE_SEARCH_RADIUS do
            local ptx, pty = tx + off_tx, ty + off_ty
            if not TileGroupManager:IsImpassableTile(_map:GetTile(ptx, pty)) then
                tile_area = tile_area + 1
                if _map:NodeAtTileHasTag(ptx, pty, "fumarolearea") then
                    num_fumarole = num_fumarole + 1
                end
            end
        end
    end

    local perc_fumarole = num_fumarole / tile_area

    _cachetemperature:SetDataAtIndex(index, perc_fumarole)
    return _currenttemperature * perc_fumarole -- HERE, shouldn't return anything when temp perc_fumarole is 0
end

Also this is uh, not safeguarded against setting a NaN value, so it should probably account for that too and ensure the cached value is 0, even if it really shouldn't normally happen. You could also cache false instead of 0 and check for it instead of ~= 0, so that 0 is a potential valid value.

 

Also I'd figure this is intended, but temperature modifiers aren't set for the component:

local function custom_postinit(inst)
    inst:AddComponent("caveweather")
    inst:AddComponent("quaker")
    inst:AddComponent("nightmareclock")
    inst:AddComponent("vault_floor_helper")
    inst:AddComponent("fumarolelocaltemperature")

    inst.components.worldtemperature:SetTemperatureMod(TUNING.CAVES_TEMP_MULT, TUNING.CAVES_TEMP_LOCUS)
end

Just also pointing it out just in case.


Steps to Reproduce

See above.




User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.

Oops, yeah! I reported this and then checked general and saw the new hotfix, then checked the code and noticed it was addressed, cool!

  • Like 1
  • Thanks 1

Share this comment


Link to comment
Share on other sites

37 minutes ago, hoxi said:

Oops, yeah! I reported this and then checked general and saw the new hotfix, then checked the code and noticed it was addressed, cool!

We do appreciate it when things are investigated into, thank you.

  • Like 1

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...