Trader not buildable after city building trader was taken by opponent
I have a new civilization with two cities. One of them was building a trader (I'm only allowed 1 trader at this point of the game). An opponent AI captured this city. I noticed that I can no longer build traders, even after recapturing this same city. No production queue in my civilization has any Traders in it. PQ still thinks that I am limited. I disabled CQUI and Civ IV lets me build my trader as expected. This appears to be a bug only with PQ (via CQUI). I originally filed this under CQUI https://github.com/Azurency/CQUI_Community-Edition/issues/255
Looks like the same issue would happen if you are training a Spy, just from seeing the same code used with the Spy:
if(spyCap > numberOfSpies) then
for _,city in pairs(prodQueue) do
for _,qi in pairs(city) do
if(qi.entry.Hash == item.Hash) then
numberOfSpies = numberOfSpies + 1;
end
end
end
Thanks for reporting this. When I have a chance I'll look into it.
I was hoping I could help more...but I'm not too familiar with lua, nor workshop code in general. I was thinking maybe there needs to be some sort of sanity-check in prodQueue to make sure only data for user-owned-cities is in there, but I think that isn't what you intended (maybe there are other players' data in there as well?). But maybe instead of sanity-cleaning the prodQueue, the spy/trader code would be something like the ugly broken code below:
if(spyCap > numberOfSpies) then
for _,city in pairs(prodQueue) do
local cityId = GetCityIdFromProdQueueKey(city); ?
if (city:GetOwner() == Game.GetLocalPlayer() then
for _,qi in pairs(city) do
if(qi.entry.Hash == item.Hash) then
numberOfSpies = numberOfSpies + 1;
end
end
end
end