ProductionQueue icon indicating copy to clipboard operation
ProductionQueue copied to clipboard

Trader not buildable after city building trader was taken by opponent

Open mlsad3 opened this issue 7 years ago • 3 comments

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

mlsad3 avatar Jan 02 '18 04:01 mlsad3

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

mlsad3 avatar Jan 02 '18 17:01 mlsad3

Thanks for reporting this. When I have a chance I'll look into it.

kblease avatar Jan 02 '18 17:01 kblease

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

mlsad3 avatar Jan 02 '18 17:01 mlsad3