Unit Icons (for new formation class) missing after update

TC_

Chieftain
Joined
Jul 8, 2017
Messages
77
Hey guys,

First unexpected issue I am having with the latest update is missing icons for certain units.

I am running a modified version of an old Gedemon mod which changes the formation class of ranged units so that they can be stacked with other unit types.
Code:
/* Create new formation classes */
INSERT INTO Types (Type, Kind) VALUES ('FORMATION_CLASS_LAND_ATTACK_SUPPORT', 'KIND_FORMATION_CLASS');
INSERT INTO UnitFormationClasses (FormationClassType, Name) VALUES ('FORMATION_CLASS_LAND_ATTACK_SUPPORT', 'Attack Support');
/* Apply the new class */
UPDATE Units SET FormationClass = 'FORMATION_CLASS_LAND_ATTACK_SUPPORT' WHERE (RangedCombat > 0 OR Bombard > 0) AND (FormationClass = 'FORMATION_CLASS_LAND_COMBAT');

For some reason after the update, this code is causing the icon above all ranged units to be missing. I can see the unit art in game, but the icon above their head (unit flag?) simply isn't there. Their icons do not seem to be missing anywhere else, such as the production panel.

I have disabled all other mods and simplified this mod to the above code, and the issue persists. Can't find anything that sticks out in the logs.

Does anyone have an idea on why this could be happening?

Thanks in advance
 
I'm curious now, I mean, how did they manage to break that?

You may want to have a look at the diff for the unit flag manager file between the September patch and the last patch.
 
@Gedemon good point, I think is a change in CreateUnitFlag.

Previous Version
Code:
(...)
    if pUnit ~= nil and pUnit:GetUnitType() ~= -1 then
        if (pUnit:GetCombat() ~= 0 or pUnit:GetRangedCombat() ~= 0) then        -- Need a simpler what to test if the unit is a combat unit or not.
            if "DOMAIN_SEA" == GameInfo.Units[pUnit:GetUnitType()].Domain then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_NAVAL );
            else
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_MILITARY );
            end
        else
            if GameInfo.Units[pUnit:GetUnitType()].MakeTradeRoute then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_TRADE );
            elseif "FORMATION_CLASS_SUPPORT" == GameInfo.Units[pUnit:GetUnitType()].FormationClass then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_SUPPORT );
            else
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_CIVILIAN );
            end
        end
    end
(...)


Last Update
Code:
(..) if pUnit ~= nil and pUnit:GetUnitType() ~= -1 then
        local formationClassType = GameInfo.Units[pUnit:GetUnitType()].FormationClass;
        if        (formationClassType == "FORMATION_CLASS_LAND_COMBAT" or formationClassType == "FORMATION_CLASS_AIR") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_MILITARY );
        elseif    (formationClassType == "FORMATION_CLASS_NAVAL") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_NAVAL );
        elseif    (formationClassType == "FORMATION_CLASS_SUPPORT") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_SUPPORT );
        elseif    (formationClassType == "FORMATION_CLASS_CIVILIAN") then
            if    (GameInfo.Units[pUnit:GetUnitType()].MakeTradeRoute) then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_TRADE );
            elseif (pUnit:GetReligiousStrength() > 0) then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_RELIGION );
            else
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_CIVILIAN );
            end
        end
    end (...)
 
Yep, no place for mods in their change, I suppose using the military style for all other case should do, you'll have to replace UnitFlagManager.lua or add an override to CreateUnitFlag using ReplaceUIScript in that context, changing the code above to what's below

@TC_ @Rajendran_P

Code:
    if pUnit ~= nil and pUnit:GetUnitType() ~= -1 then
        local formationClassType = GameInfo.Units[pUnit:GetUnitType()].FormationClass;
        if        (formationClassType == "FORMATION_CLASS_LAND_COMBAT" or formationClassType == "FORMATION_CLASS_AIR") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_MILITARY );
        elseif    (formationClassType == "FORMATION_CLASS_NAVAL") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_NAVAL );
        elseif    (formationClassType == "FORMATION_CLASS_SUPPORT") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_SUPPORT );
        elseif    (formationClassType == "FORMATION_CLASS_CIVILIAN") then
            if    (GameInfo.Units[pUnit:GetUnitType()].MakeTradeRoute) then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_TRADE );
            elseif (pUnit:GetReligiousStrength() > 0) then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_RELIGION );
            else
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_CIVILIAN );
            end
        else
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_MILITARY );
        end
    end
 
Yep, no place for mods in their change, I suppose using the military style for all other case should do, you'll have to replace UnitFlagManager.lua or add an override to CreateUnitFlag using ReplaceUIScript in that context, changing the code above to what's below

@TC_ @Rajendran_P

Code:
    if pUnit ~= nil and pUnit:GetUnitType() ~= -1 then
        local formationClassType = GameInfo.Units[pUnit:GetUnitType()].FormationClass;
        if        (formationClassType == "FORMATION_CLASS_LAND_COMBAT" or formationClassType == "FORMATION_CLASS_AIR") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_MILITARY );
        elseif    (formationClassType == "FORMATION_CLASS_NAVAL") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_NAVAL );
        elseif    (formationClassType == "FORMATION_CLASS_SUPPORT") then
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_SUPPORT );
        elseif    (formationClassType == "FORMATION_CLASS_CIVILIAN") then
            if    (GameInfo.Units[pUnit:GetUnitType()].MakeTradeRoute) then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_TRADE );
            elseif (pUnit:GetReligiousStrength() > 0) then
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_RELIGION );
            else
                UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_CIVILIAN );
            end
        else
            UnitFlag:new( playerID, unitID, FLAGTYPE_UNIT, FLAGSTYLE_MILITARY );
        end
    end
Gedemon and Raen, thank you very much. Appreciate your support.
 
Last edited:
Back
Top Bottom