Factorio HD Age: Base Game - Military


This mod contains and integrates HD textures for the military entities of the base game.

Tweaks
17 days ago
2.0
12.7K
Combat

b [Fixed] Finaly fixed your with and height calcs.

7 months ago
(updated 7 months ago)

So I finally found out why I was still seeing errors in the log for your width and height calcs. It boils down to pathed_data["line_length"] is sometimes 0 and you don't get a correct width calc and the height created a divide by zero which created an erroneous "true" result in the the if statement creating the log entry. So below is the corrected with and height calcs which account for a line_length of 0. You should replace this code in all of your mods.

I was seeing the errors on the gun-turret and laser-turret graphics files.

edited: to erroneous "true" result. I typed that incorrectly thankfully the code was still correct. :)

    -- find width of animations
    if type(pathed_data["width"]) == "number" and type(pathed_data["line_length"]) == "number" then
        -- If pathed_data["line_length"] is > 0 do the operation normally. If is is zero then multiply pathed_data["frame_count"] and pathed_data["width"] to get correct number for with calc.
        local width = pathed_data["line_length"] > 0 and pathed_data["line_length"] * pathed_data["width"] or pathed_data["frame_count"] * pathed_data["width"]
        -- Separate upscaling calc to make it easier to read above calc. 
        width = math.max(math.floor(width * settings["upscale"]), 1)
        if width > 8192 then
            log("[ERROR]: Image @ " .. new_path .. " is wider than 8192 px (maximum)! It can't be loaded into the game!")
            return
        end
    end
    -- find height of animations
    if type(pathed_data["height"]) == "number" and type(pathed_data["line_length"]) == "number" then
        -- If pathed_data["line_length"] is > 0 do the operation normally. If is is zero then substitute pathed_data["direction_count"] to get correct number for hight calc.
        local height = pathed_data["line_length"] > 0 and math.ceil((pathed_data["frame_count"] or 1) / pathed_data["line_length"]) or pathed_data["direction_count"]
        -- Separate pathed_data["height"] calc and upscaling calc to make it easier to read above calc. 
        height = math.max(math.floor(height * pathed_data["height"] * settings["upscale"]), 1)
        if height > 8192 then
            log("[ERROR]: Image @ " .. new_path .. " is taller than 8192 px (maximum)! It can't be loaded into the game!")
            return
        end
    end
7 months ago

First of all, thank you very much for this bug report and the detailed solution.
I will test it and then implement it in all mods.

7 months ago

Feel free to hit me up if you run into any edge cases or have an issue.

7 months ago

Thanks, everything seems to be working, I'm currently doing a few other bugfixes and improvements. After that I will update all mods.

7 months ago

No problem happy to help, I actually had fun tracking that down!

7 months ago

I almost forgot. For your protection. I freely grant you a permanent non-revocable license to my code modifications above. I would appreciate a mention in the changelog. :)

I try to always do this after watching the minecraft bucket server fiasco that nearly completely killed that project after someone claimed copyright on the code they contributed freely. It is a crappy thing to do to a community.

7 months ago

Thank you for this hint and the permission to use the code. I will gladly mention you in the changelog.

This thread has been locked.