UI - Filters in Trade Route Overview

I think I found a bug with this mod: TRs that have just finished and can be sent again are still marked with the exclamation mark (!) and therefore will be filtered out if the appropriate option (VP Blocked) is checked.

Expected behavior is that only active TRs are marked as blocked, since only they are really blocked in VP and it often makes sense to send the TR to the same target again anyway; it also kinda breaks the filtering for blocked TRs.
Spoiler screenshot :
 
I think I found a bug with this mod: TRs that have just finished and can be sent again are still marked with the exclamation mark (!) and therefore will be filtered out if the appropriate option (VP Blocked) is checked.

Expected behavior is that only active TRs are marked as blocked, since only they are really blocked in VP and it often makes sense to send the TR to the same target again anyway; it also kinda breaks the filtering for blocked TRs.
Spoiler screenshot :
Can confirm. That has been happening for a long time, but I was just too lazy to report.
 
Since Infixo is not currently working on Civ 5, I've obtained permission to update this mod for him; here's what I've changed:
  • fixed the aforementioned bug (posts above this one)
  • updated to latest VP
  • made the mod fully compatible with localization
  • added German and Russian translations
  • rearranged the filter checkboxes to fit with all compatible languages (EN, DE, RU)
  • did some cleanup in the UI
  • made the red exclamation mark appear in front of the target city name
  • added a 6th Checkbox (selected Unit) and the appropriate functionality, which is as follows:
The mod will now check what kind of unit you have selected when opening the window and, if it is a valid Trade Unit, will allow you to interact with it through this mod!
Let me show you:
Spoiler Example 1 :

FTRO1.jpg


As you can see, the little Trade Unit icons on the left of that window are now usable for sending commands to the currently selected Trade Unit (in this case a Cargo Ship, as you can see in the bottom left corner of the image). If you click that icon while having an eligible Trade Unit selected and the icon belongs to a row with a viable Trade Route (TR), the Trade Unit (TU) will automatically commence trading, so you don't need the other menu anymore! Conveniently, the 6th checkbox ("Only for selected Unit") will be automatically activated and cannot be activated without having a valid TU selected. You can uncheck the box, however, and see all available TRs anyway, if you wish; that way you can use this window to rebase your TUs by clicking on the same left side icon in a row that has a different origin city than the city in which the TU is currently located, which will then display a tool tip stating exactly that. This should also help with performance in late game, as often times you know that you don't want to change cities anyway, so it is better to just look at the TRs for that particular TU in the current city, which loads a lot faster than all possible TRs.

Here is another screenshot:
Spoiler Example 2 :
FTRO2.jpg


Here you can see two more features I added: this mod is now aware of TR quests by City States, which will be shown with that TR icon as you can see in Example 2 where the tool tip is (the tool tip will also reflect that, as you can see) and the mod is now aware of Corporations, which, however, means that it now requires full VP to run. If your origin city has a corporate office and the TR type is international to a City State or other Civilization, there will be an "Invest"-icon shown, as you can see to the left of the origin city name "Venice" in the screenshots. If this is the case, the target city name can change its color in the list: if a Franchise of your Corporation has been established there, it will be displayed in golden color (like Sydney or Sidon in Example 2); if a Franchise is available but not yet established, it will be shown in the normal color; if a Franchise can't be established it will be displayed in a light gray color and the tool tips will always reflect that, of course. Additionally, the previous TR of the selected TU will now be indicated with a light blue "(P)" in front of the target city name, so that the only info you don't get here that you do get in the "main TR window" is the path of the TR and some supplementary info for rebasing, which isn't that important. I've tested this thoroughly for VP 10/23 but the November updates don't seem to have changed any of the relevant files so it should work well with the newest version, too.

Enjoy.
 

Attachments

As you can see, the little Trade Unit icons on the left of that window are now usable for sending commands to the currently selected Trade Unit (in this case a Cargo Ship, as you can see in the bottom left corner of the image). If you click that icon while having an eligible Trade Unit selected and the icon belongs to a row with a viable Trade Route (TR), the Trade Unit (TU) will automatically commence trading, so you don't need the other menu anymore! Conveniently, the 6th checkbox ("Only for selected Unit") will be automatically activated and cannot be activated without having a valid TU selected. You can uncheck the box, however, and see all available TRs anyway, if you wish; that way you can use this window to rebase your TUs by clicking on the same left side icon in a row that has a different origin city than the city in which the TU is currently located, which will then display a tool tip stating exactly that. This should also help with performance in late game, as often times you know that you don't want to change cities anyway, so it is better to just look at the TRs for that particular TU in the current city, which loads a lot faster than all possible TRs.

Enjoy.
Is this functionality compatible with Visible Trade Units mod? I use it so as to ensure that my units trading are always showing on the map and never go missing in the fog of war. I feel that it should be in the base mod at some point.
https://forums.civfanatics.com/threads/trade-route-mods.510823/
 
Thanks, @civplayer33 , I've been enjoying your fix for a while now! This is such an essential QOL mod, IMO.

One issue, though: sorting by religious pressure doesn't work properly. I've attached a screenshot with 'sorted' pressures. I'm using the Historical Religions Edit mod that adds more religions to choose from to the game, so perhaps that's creating issues?
 

Attachments

  • 20191217163915_1.jpg
    20191217163915_1.jpg
    419.1 KB · Views: 333
One issue, though: sorting by religious pressure doesn't work properly.
I think I know why...if in vanilla the religious icon is also shown in those columns then this is actually a vanilla bug...the icon can't be converted to a number and isn't "excised" in the sort function so that's why it fails to sort. This made me think about sorting for the other columns, which may not work optimally as well due to different factors (among other things, some of my own changes, like putting the exclamation mark for Blocked routes in front of the city name and adding colors and the "(P)" mark and the TR quest icon)...I may look at it in the next few weeks and whip up a fix if I have time.
 
  • Like
Reactions: 4CV
Is this functionality compatible with Visible Trade Units mod?
Btw.: As part of the UI cleanup I did it should now be more obvious how to select the individual TUs that are active; all you have to do is switch to the "Your Trade Routes" portion of the Trade Screen and click on the little TU icon or on the "turns left" number of the TR that this TU is currently engaged in; there is a tool tip telling you that it will select that TU if you click on it. Maybe this is sufficient so you don't even need that mod? For some reason I never seem to have trouble being aware of my TU, even without that mod, though I do have TR visibility activated always.
 
Btw.: As part of the UI cleanup I did it should now be more obvious how to select the individual TUs that are active; all you have to do is switch to the "Your Trade Routes" portion of the Trade Screen and click on the little TU icon or on the "turns left" number of the TR that this TU is currently engaged in; there is a tool tip telling you that it will select that TU if you click on it. Maybe this is sufficient so you don't even need that mod? For some reason I never seem to have trouble being aware of my TU, even without that mod, though I do have TR visibility activated always.
The visibility LUA is below. Could it be merged? Is it even necessary for true "visibility"?
Spoiler Visibility :
Code:
print("This is the 'Units - Visible Trade Units' mod script.")

local gTradeUnits = {}

function ShowTradeUnits()
  local iTeam = Game.GetActiveTeam()
  local iPlayer = Game.GetActivePlayer()
  local pPlayer = Players[iPlayer]

  if (gTradeUnits[iPlayer] == nil) then
    local units = {}
    gTradeUnits[iPlayer] = units

    for pUnit in pPlayer:Units() do
      if pUnit:IsTrade() then
        local unit = {id=pUnit:GetID()}
        table.insert(units, unit)

        local pPlot = pUnit:GetPlot()
        unit.plotX = pPlot:GetX()
        unit.plotY = pPlot:GetY()

        pPlot:ChangeVisibilityCount(iTeam, 1)
        pPlot:UpdateVisibility()
        pPlot:UpdateFog()
        Events.UnitStateChangeDetected(iPlayer, pUnit:GetID(), 2) -- see WhiteFog in UnitFlagManager.lua
      end
    end
  end
end

function HideTradeUnits()
  local iTeam = Game.GetActiveTeam()
  local iPlayer = Game.GetActivePlayer()
  local units = gTradeUnits[iPlayer]

  if (units) then
    for _,unit in pairs(units) do
      local pPlot = Map.GetPlot(unit.plotX, unit.plotY)

      if (pPlot) then
        pPlot:ChangeVisibilityCount(iTeam, -1)
        pPlot:UpdateVisibility()
        pPlot:UpdateFog()
        if (not pPlot:IsVisible(iTeam)) then
          Events.UnitStateChangeDetected(iPlayer, unit.id, 1) -- see GreyFog in UnitFlagManager.lua
        end
      end
    end

    gTradeUnits[iPlayer] = nil
  end
end

Events.ActivePlayerTurnEnd.Add(HideTradeUnits)
Events.ActivePlayerTurnStart.Add(ShowTradeUnits)

ShowTradeUnits()
 
Alright I figured out why the sorting doesn't work for the religion columns...I was wrong in my preliminary assessment; the funny thing is it does actually work, but it sorts by Religion, not by Religious Pressure, thus making it fairly useless, at least for outgoing Pressure (since your own empire will usually have the same Majority Religion in every City); for the received Pressure, however, it can theoretically be interesting to sort by which Religion is going to put Pressure on one's own Cities, so it might make sense to implement a secondary sorting algorithm that is able to sort by Religion and by Pressure at the same time, but honestly it would be hard to do this well from a UI standpoint and require substantial amounts of new code while also degrading performance a bit, so I don't think it's worth it, especially since this is a rather extreme edge case (the only case where you would significantly benefit from it, as far as I can see, would be in late game when there are a huge number of potential TRs and you're trying to make one of your own Cities flip to some foreign Religion for some reason and don't have religious units available for that so you need to use TRs only...but even then the current functionality, which now allows you to sort by overall Religious Pressure, will help you with that...just not as optimally as an implemented secondary sort).

Anyway, below you'll find the updated version where the sorting for Religious Pressure now sorts for the actual Pressure value rather than ordering by Religion. The other potential sorting issues have turned out not to be a problem because of the way the sorting works.
 

Attachments

I don't think so, but I'll keep an eye on it in my current game, maybe I just didn't notice TUs disappearing until now.
I only noticed it when I saw that there was no update to tiles in foreign cities. So fog of war was not being exposed by my trade units until I enabled with the mod. So, they could be killed afar without my knowledge.
 
I only noticed it when I saw that there was no update to tiles in foreign cities. So fog of war was not being exposed by my trade units until I enabled with the mod. So, they could be killed afar without my knowledge.
By "fog of war" you mean tiles that are revealed but not currently visible, right? Or do you mean tiles that haven't been revealed yet?
 
By "fog of war" you mean tiles that are revealed but not currently visible, right? Or do you mean tiles that haven't been revealed yet?
I meant tiles revealed but not currently visible. It seems that the visibility "mod" is actually just fixing a vanilla bug left behind. There isn't a good reason to lose focus of any unit.
 
I meant tiles revealed but not currently visible. It seems that the visibility "mod" is actually just fixing a vanilla bug left behind. There isn't a good reason to lose focus of any unit.
Well I've been observing it in my current game and the TUs are definitely always visible, even when they enter FoW (they will make the tiles they pass over visible, such that there will always be a "trail" of visible tiles in the FoW when I check on them, as they move at the beginning of my turn).

I'll keep checking on it, but it may be caused by something else.
 
pPlot:ChangeVisibilityCount(iTeam, 1) pPlot:UpdateVisibility() pPlot:UpdateFog() Events.UnitStateChangeDetected(iPlayer, pUnit:GetID(), 2) -- see WhiteFog in UnitFlagManager.lua
Code:
local BlackFog = 0; -- invisible
local GreyFog  = 1; -- once seen
local WhiteFog = 2; -- eyes on
https://github.com/LoneGazebo/Commu...mmunity Balance Patch/LUA/UnitFlagManager.lua
This was last seen in version 6-2 but has been taken out of UnitFlagManager.lua since so possibly bug is no longer present.
 
I’m sure This is a stupid question, but what are the values for route.domain? I am on mobile and can’t check it myself.

is route.domain == 0 mean it’s a land TR, and route.domain==1 mean sea?
 
Back
Top Bottom