Guest User

CityProcess.java (Java RE-port of Civ 1 for DOS)

a guest
Oct 14th, 2014
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 83.88 KB | None | 0 0
  1. /*
  2.  * This is a development version of a JCivED source file, reverse-engineered and
  3.  * back-ported from CIV.EXE assembly to Java (from Sid Meier's Civilization for MS-DOS)
  4.  * It rougly covers 70% of the "city screen" routine which processes city resource
  5.  * production, renders the city screen, and manages city screen interaction (not
  6.  * ported, i.e. the 30% remaining)
  7.  * darkpandaman @ gmail.com - 14/10/2014
  8.  */
  9.  
  10. package dd.civ.logic.port;
  11.  
  12. import java.awt.Graphics2D;
  13. import java.awt.image.BufferedImage;
  14. import java.util.Arrays;
  15. import java.util.Iterator;
  16.  
  17. import dd.civ.data.font.FontUtils;
  18. import dd.civ.data.game.model.generic.AbstractGameState;
  19. import dd.civ.data.game.model.generic.City;
  20. import dd.civ.data.game.model.generic.Civ;
  21. import dd.civ.data.game.model.generic.Entity;
  22. import dd.civ.data.game.model.generic.MapLocation;
  23. import dd.civ.data.game.model.generic.Unit;
  24. import dd.civ.data.game.model.generic.UnitType;
  25. import dd.civ.data.game.model.generic.impl.AbstractCiv;
  26. import dd.civ.data.game.model.sve.SVECity;
  27. import dd.civ.data.game.model.sve.SVECiv;
  28. import dd.civ.data.game.model.sve.SVEMapEntity;
  29. import dd.civ.data.game.model.sve.SVEUnit;
  30. import dd.civ.data.game.model.sve.impl.AbstractSVEUnit;
  31. import dd.civ.data.game.types.Advance;
  32. import dd.civ.data.game.types.CityImprovement;
  33. import dd.civ.data.game.types.CitySpecialistType;
  34. import dd.civ.data.game.types.CityStatus;
  35. import dd.civ.data.game.types.DifficultyLevel;
  36. import dd.civ.data.game.types.GovernmentType;
  37. import dd.civ.data.game.types.UnitCategory;
  38. import dd.civ.data.game.types.UnitTypeCode;
  39. import dd.civ.data.game.types.VisibilityType;
  40. import dd.civ.data.game.types.WonderType;
  41. import dd.civ.graphics.CivDosRenderer;
  42. import dd.civ.logic.CivUtils;
  43. import dd.jcived.util.ImageUtils;
  44. import dd.jcived.util.Palette;
  45. import dd.jcived.util.ResourceManager;
  46.  
  47. public class CityProcess {
  48.  
  49.     //seg007_0043:
  50.     public static void cityProcess(AbstractGameState gs, int arg_cityID, int arg_processMode) {
  51.         int var_B6;
  52.         int var_D8;
  53.         int var_FA;
  54.         int var_C8;
  55.         int var_EA;
  56.         int var_E8;
  57.         int var_X;
  58.         int var_Y;
  59.         int var_neighbourX;
  60.         int var_neighbourY;
  61.         int varOtherDist;
  62.         int varDist;
  63.         int var_cityLoop;
  64.         int var_loopCounter;
  65.         int var_settlerFoodCost;
  66.         int var_16_min_2xDifficulty;
  67.    
  68.         int var_multi1;
  69.    
  70.         // HELPER
  71.         SVECity city = (SVECity) gs.city(arg_cityID);
  72.    
  73.         System.out.println("City ["+arg_cityID+"] exists ? "+city.exists());
  74.         if(!city.exists()) {
  75.             //seg007_5E:
  76.             //seg007_675B:
  77.             return;
  78.         }
  79.    
  80.         //seg007_61:
  81.         int[] var_5x5_cityAreaArray = new int[5*5];
  82.         //CivLogic.dseg_2496_cityViewActiveTab = 0;
  83.         CivLogic.dseg_2496_cityViewActiveTab++;
  84.         CivLogic.dseg_2496_cityViewActiveTab%=3;
  85.         var_B6 = 0;
  86.         var_D8 = 0;
  87.         var_FA = 0;
  88.         var_C8 = 0;
  89.    
  90.         //          var_X = 0;
  91.         //          while(var_X<5) {
  92.         //              var_Y = 0;
  93.         //              while(var_Y<5) {
  94.         //                  var_5x5_cityAreaArray[5*var_X+var_Y] = 0;
  95.         //                  var_Y++;
  96.         //              }
  97.         //              var_X++;
  98.         //          }
  99.         Arrays.fill(var_5x5_cityAreaArray, 0);
  100.    
  101.         //seg007_CC:
  102.         var_X = city.getLocation().x();
  103.         var_Y = city.getLocation().y();
  104.         CivLogic.currentProcessingCity_dseg_64C2 = arg_cityID;
  105.         varOtherDist = 7;
  106.    
  107.         if(city.has(CityImprovement.PALACE)) {
  108.             //seg007_10E:
  109.             CivLogic.dseg_6AB0_distanceToCapital = 0;
  110.         } else {
  111.             //seg007_114:
  112.             CivLogic.dseg_6AB0_distanceToCapital = 32;
  113.         }
  114.    
  115.         //seg007_117:
  116.         if(city.getShieldStock()>999 ||
  117.                 //seg007_12D:
  118.                 city.getShieldStock()<0) {
  119.             //seg007_13F:
  120.             city.setShieldStock(0);
  121.         }
  122.    
  123.         // Looping on all cities to detect neighbour squares already used
  124.         // up by another city
  125.         //seg007_14D:
  126.         var_cityLoop = 0;
  127.         while(var_cityLoop<128) {
  128.             if(((SVEMapEntity) gs.city(var_cityLoop)).exists()) {
  129.                 City someCity = gs.city(var_cityLoop);
  130.                 if(var_cityLoop!=arg_cityID) {
  131.                     varDist = CivLogic.distance(var_X,someCity.getLocation().x(),var_Y,someCity.getLocation().y());
  132.                     if(varDist<varOtherDist && varDist!=0) {
  133.                         varOtherDist = varDist;
  134.                     }
  135.                     if(city.owner().equals(someCity.owner())) {
  136.                         if(someCity.has(CityImprovement.PALACE)) {
  137.                             if(varDist<CivLogic.dseg_6AB0_distanceToCapital) {
  138.                                 CivLogic.dseg_6AB0_distanceToCapital = varDist;
  139.                             }
  140.                         }
  141.                     }
  142.                     if(varDist<=5) {
  143.                         var_loopCounter = 0;
  144.                         while(var_loopCounter<=20) {
  145.                             //int w0 = (Byte)someCity.getValue("workers_flag0");
  146.                             //int w1 = (Byte)someCity.getValue("workers_flag1");
  147.                             //int w2 = (Byte)someCity.getValue("workers_flag2");
  148.                             //int workers = (w0&0xFF)|((w1&0xFF)<<8)|((w2&0xFF)<<16);
  149.                             //int workerComp = (0x1<<var_loopCounter);
  150.                             if(someCity.hasWorkerAt(var_loopCounter) || var_loopCounter==20) {
  151.                                 var_neighbourX = someCity.getLocation().x() + CivUtils.relCityX[var_loopCounter];
  152.                                 var_neighbourY = someCity.getLocation().y() + CivUtils.relCityY[var_loopCounter];
  153.                                 if(Math.abs(var_neighbourX-var_X)<=2 && Math.abs(var_neighbourY-var_Y)<=2) {
  154.                                     int i = 5*(var_neighbourX-var_X) + var_neighbourY-var_Y;
  155.                                     var_5x5_cityAreaArray[12+i] = 1;
  156.                                 }
  157.                             }
  158.                             var_loopCounter++;
  159.                         }
  160.                     }
  161.                 }
  162.             }
  163.             var_cityLoop++;
  164.         }
  165.    
  166.         //seg007_2F5:
  167.         var_5x5_cityAreaArray[12] = 0;
  168.         CivLogic.cityOwner_dseg_64CA = ((SVECiv)city.owner()).getID();
  169.         Civ cityOwner = gs.civ(CivLogic.cityOwner_dseg_64CA);
  170.         CivLogic.neighbourSquareCount_dseg_64C4 = 21;
  171.         // TODO: Skipping viewport alignment at seg007:0x311
  172.    
  173.    
  174.         if(cityOwner.government().equals(GovernmentType.ANARCHY)
  175.                 || cityOwner.government().equals(GovernmentType.DESPOTISM)) {
  176.             var_settlerFoodCost = 1;
  177.         } else {
  178.             var_settlerFoodCost = 2;
  179.         }
  180.    
  181.         //seg007_338:
  182.         CivLogic.pollutionFactor_dseg_C7A2 = 0;
  183.         if(!city.has(CityImprovement.MASS_TRANSIT)) {
  184.             if(cityOwner.knows(Advance.INDUSTRIALIZATION)) CivLogic.pollutionFactor_dseg_C7A2++;
  185.             if(cityOwner.knows(Advance.AUTOMOBILE)) CivLogic.pollutionFactor_dseg_C7A2++;
  186.             if(cityOwner.knows(Advance.MASS_PRODUCTION)) CivLogic.pollutionFactor_dseg_C7A2++;
  187.             if(cityOwner.knows(Advance.PLASTICS)) CivLogic.pollutionFactor_dseg_C7A2++;
  188.         }
  189.    
  190.         //seg007_3C4:
  191.         var_16_min_2xDifficulty = 10;
  192.         CivLogic.citySpecialistCount_dseg_F7D8 = city.getCitySpecialistCount();
  193.         if(!cityOwner.equals(gs.player())) {
  194.             var_16_min_2xDifficulty = 16 - 2*(Integer)gs.getValue("difficulty");
  195.             if((Short)gs.getValue("year")>=0) {
  196.                 if((Short)((Entity) gs.player()).getValue("ranking")==7 // Your ranking impacts the game!
  197.                         && (Integer)gs.getValue("difficulty")>1) {
  198.                     var_16_min_2xDifficulty -= 2;
  199.                 }
  200.             }
  201.             if(arg_processMode==0) {
  202.                 if(!city.has(CityStatus.RIOT)) { // Check if City is in riot
  203.                     CivLogic.citySpecialistCount_dseg_F7D8 = 0;
  204.                 } else {
  205.                     ((Entity) city).setPropertyValue("workers_flag0", (byte)0);
  206.                     ((Entity) city).setPropertyValue("workers_flag1", (byte)0);
  207.                     ((Entity) city).setPropertyValue("workers_flag2", (byte)0);
  208.                     ((Entity) city).setPropertyValue("workers_flag3", (byte)0);
  209.                 }
  210.             }
  211.         }
  212.    
  213.         //seg007_45D:
  214.    
  215.         // Start drawing the city screen...
  216.         BufferedImage bi = new BufferedImage(320,200,BufferedImage.TYPE_INT_ARGB);
  217.         if(arg_processMode == 1) ImageUtils.animate(bi, city.getName().toUpperCase(), 200);
  218.  
  219.         //ImageUtils.animate(bi, "DEBUG", 200);
  220.         Graphics2D gfx = bi.createGraphics();
  221.         var_X = city.getLocation().x();
  222.         var_Y = city.getLocation().y();
  223.         if(arg_processMode==1) { // means ax = 1 and dx = 0;
  224.    
  225.             // TODO: deal with call to unkCity_27_28_createFortifiedUnit:
  226.             // it extracts "integrated units" as "real units" for further processing
  227.             // such as displaying them on screen and counting them in unit-related
  228.             // formulas
  229.    
  230.             gfx.setColor(Palette.defaultColors.get(0));
  231.             gfx.fillRect(0, 0, 320, 200);
  232.    
  233.             // city box 1: population
  234.             CivDosRenderer.drawBlueDialogBackground(2, 1, 208, 21, gfx, false);
  235.    
  236.             var_multi1 = 0;
  237.             var_loopCounter = 1;
  238.    
  239.             while(var_loopCounter<=city.actualSize()) {
  240.                 var_multi1 += var_loopCounter;
  241.                 var_loopCounter++;
  242.             }
  243.    
  244.             String s = city.getName().toUpperCase() + " (Pop:";
  245.             s += CivLogic.populationString(var_multi1);
  246.             s += ")";
  247.    
  248.             CivDosRenderer.drawString(s, gfx, 1, Palette.defaultColors.get(15), 104, 2+FontUtils.getFontHeight(1), 100, 1);
  249.    
  250.    
  251.             // city box 2: city squares
  252.             CivDosRenderer.drawBlueDialogBackground(127, 23, 208, 104, gfx, false);
  253.    
  254.             // Good to know, map viewport gets aligned on (City_X - 5, City_Y - 3)
  255.             ImageUtils.drawMapTerrainSquare(gs, city.getLocation().x(), city.getLocation().y(), bi, 80+5*16,8+3*16, gs.getRandomSeed(), 1, true,true,true,true,true,true,true,true);
  256.    
  257.             var_loopCounter = 0;
  258.             while(var_loopCounter < CivLogic.neighbourSquareCount_dseg_64C4) {
  259.                 var_neighbourX = city.getLocation().x() + CivUtils.relCityX[var_loopCounter];
  260.                 var_neighbourY = city.getLocation().y() + CivUtils.relCityY[var_loopCounter];
  261.                 if(!city.owner().equals(gs.player()) // Spy or Debug mode: can see all enemy city squares
  262.                         || gs.player().canSee(city.getLocation().neighbour(var_loopCounter, 0))) {
  263.                     var_multi1 = CivLogic.getLandOccupation(gs, var_neighbourX, var_neighbourY);
  264.                     if(var_multi1==-1
  265.                             ||var_multi1== ((SVECiv) city.owner()).getID()) {
  266.                         ImageUtils.drawMapTerrainSquare(gs, var_neighbourX, var_neighbourY, bi, 80+(5+CivUtils.relCityX[var_loopCounter])*16,8+(3+CivUtils.relCityY[var_loopCounter])*16, gs.getRandomSeed(), 1, true,true,true,true,true,true,true,true);
  267.                         int i = 12 + 5*(CivUtils.relCityX[var_loopCounter]) + CivUtils.relCityY[var_loopCounter];
  268.                         if(var_5x5_cityAreaArray[i]!=0) {
  269.                             gfx.setColor(Palette.defaultColors.get(12));
  270.                             gfx.drawRect(80+(5+CivUtils.relCityX[var_loopCounter])*16,8+(3+CivUtils.relCityY[var_loopCounter])*16, 15, 15);
  271.                         }
  272.                     } else {
  273.                         ImageUtils.drawMapTerrainSquare(gs, var_neighbourX, var_neighbourY, bi, 80+(5+CivUtils.relCityX[var_loopCounter])*16,8+(3+CivUtils.relCityY[var_loopCounter])*16, gs.getRandomSeed(), 1, true,true,true,true,true,true,true,true);
  274.                         //ImageUtils.drawMapSquareItems(gs, cityOwner, var_neighbourX, var_neighbourY, bi, 80+(5+CivUtils.relCityX[var_loopCounter])*16,8+(3+CivUtils.relCityY[var_loopCounter])*16,false, 1);
  275.                     }
  276.                 }
  277.                 var_loopCounter++;
  278.             }
  279.         }
  280.    
  281.         //seg007_6FA:
  282.         if(arg_processMode==0) {
  283.             city.set(CityStatus.IMPROVEMENT_SOLD,false);
  284.             if((Short)((Entity) city).getValue("food_count")<0) {
  285.                 var_multi1 = -1;
  286.                 var_loopCounter = 0;
  287.                 Iterator<SVEUnit> it = ((SVECiv) cityOwner).getUnits(false).iterator();
  288.                 //seg007_737:
  289.                 while(var_loopCounter<128) {
  290.                     SVEUnit unit = it.next();
  291.                     if(unit.typeID()==0 && (Short)((Entity) unit).getValue("home_city_id")==arg_cityID) {
  292.                         var_multi1 = var_loopCounter;
  293.                         break;
  294.                     }
  295.                     var_loopCounter++;
  296.                 }
  297.                 //seg007_78B:
  298.                 if(cityOwner.equals(gs.player())) {
  299.                     // TODO: pop-up message:
  300.                     // String s = "Food storage exhausted\nin "+city.getName();
  301.                     // if(var_multiusage_bulbs_pop_==-1) {
  302.                     //   s+= "!\nFamine feared.\n"
  303.                     // } else {
  304.                     //   s+= "!\nSettlers lost.\n"
  305.                     // }
  306.                     // Show newspaper headlines with s, play music, etc.
  307.                 }
  308.                 //seg007_7F5:
  309.                 if(var_multi1==-1) {
  310.                     ((Entity) city).setPropertyValue("actual_size",(byte)(city.actualSize()-1));
  311.                     if(city.actualSize()==0) {
  312.                         // TODO
  313.                         //seg007_823:
  314.                         // Deal with city destroyed, and possibly Civ destroyed...
  315.                     }
  316.                 } else {
  317.                     //seg007_7FF:
  318.                     // TODO: remove lost settlers
  319.                 }
  320.    
  321.                 //seg007_85C:
  322.                 // TODO: refresh map square
  323.                 ImageUtils.drawMapTerrainSquare(gs, var_X, var_Y, bi, 80+(5+0)*16,8+(3+0)*16, gs.getRandomSeed(), 1, true,true,true,true,true,true,true,true);
  324.                 ImageUtils.drawMapSquareItems(gs, (AbstractCiv) cityOwner, var_X, var_Y, bi,bi,bi, 80+(5+0)*16,8+(3+0)*16,false, 1);
  325.    
  326.                 ((Entity) city).setPropertyValue("food_count",(short)0);
  327.             }
  328.             //seg007_87A:
  329.             if((city.actualSize()+1)*var_16_min_2xDifficulty<=(Short)((Entity) city).getValue("food_count")) {
  330.                 ((Entity) city).setPropertyValue("actual_size",(byte)(city.actualSize()+1));
  331.                 if(city.has(CityImprovement.GRANARY)) {
  332.                     ((Entity) city).setPropertyValue("food_count", (short)(5*city.actualSize()+5));
  333.                 } else {
  334.                     ((Entity) city).setPropertyValue("food_count", (short)0);
  335.                 }
  336.                 if(city.actualSize()>10 && !city.has(CityImprovement.AQUEDUCT)
  337.                         /* && DebugSwitch 0x100 is set to 1 */) {
  338.                     ((Entity) city).setPropertyValue("actual_size",(byte)(city.actualSize()-1));
  339.                     if(cityOwner.equals((gs.player()))) {
  340.                         // TODO: String popup:
  341.                         // citName + " requires an AQUEDUCT\nfor further growth."
  342.                     }
  343.                 }
  344.                 ImageUtils.drawMapTerrainSquare(gs, var_X, var_Y, bi, 80+(5+0)*16,8+(3+0)*16, gs.getRandomSeed(), 1, true,true,true,true,true,true,true,true);
  345.                 ImageUtils.drawMapSquareItems(gs, cityOwner, var_X, var_Y, bi, bi, bi, 80+(5+0)*16,8+(3+0)*16,false, 1);
  346.             }
  347.         }
  348.    
  349.         //seg007_95E:
  350.         int var_citySize_plus_1 = city.actualSize() + 1;
  351.         CivLogic.dseg_64C8_away_unit_counter = 0;
  352.         CivLogic.dseg_EDD8_unk27_28_counter = 0;
  353.         CivLogic.dseg_E216_unitShieldMaintenanceCost = 0;
  354.         CivLogic.dseg_F2E6_settler_counter = 0;
  355.    
  356.         var_loopCounter = 0;
  357.         //seg007_98B:
  358.         while(var_loopCounter<2) {
  359.             if(((Short)((Entity) city).getValue("unknown_cb2"+(7+var_loopCounter))&0xFF)!=0xFF) {
  360.                 CivLogic.dseg_EDD8_unk27_28_counter++;
  361.             }
  362.             var_loopCounter++;
  363.         }
  364.         //seg007_9B2:
  365.         if(city.actualSize()<CivLogic.dseg_EDD8_unk27_28_counter) {
  366.             CivLogic.dseg_E216_unitShieldMaintenanceCost = CivLogic.dseg_EDD8_unk27_28_counter - city.actualSize();
  367.         }
  368.    
  369.         //seg007_9DF:
  370.         var_loopCounter = 0;
  371.         Iterator<SVEUnit> it = ((SVECiv) cityOwner).getUnits(false).iterator();
  372.         while(var_loopCounter<128) {
  373.             SVEUnit _SVEUnit = it.next();
  374.             if((_SVEUnit.typeID()&0xFF)!=0xFF && (Short)((Entity) _SVEUnit).getValue("home_city_id")==arg_cityID) {
  375.                 if(_SVEUnit.typeID()<26) {
  376.                     if(city.actualSize()<CivLogic.dseg_EDD8_unk27_28_counter
  377.                             || !(cityOwner.government().equals(GovernmentType.ANARCHY)||cityOwner.government().equals(GovernmentType.DESPOTISM))) {
  378.                         /*if DebugSwitches 0x10 is set to 1 */
  379.                         CivLogic.dseg_E216_unitShieldMaintenanceCost++;
  380.                     }
  381.                     if(_SVEUnit.typeID()!=0) {
  382.                         if((Short)((Entity) _SVEUnit.getType()).getValue("terrain_cat")==1
  383.                                 || _SVEUnit.getLocation().x()!=city.getLocation().x()
  384.                                 || _SVEUnit.getLocation().y()!=city.getLocation().y()) {
  385.                             CivLogic.dseg_64C8_away_unit_counter++;
  386.                         }
  387.                     }
  388.    
  389.                 }
  390.                 if(_SVEUnit.typeID()==0) {
  391.                     //seg007_B38:
  392.                     CivLogic.dseg_F2E6_settler_counter++;
  393.                 }
  394.             }
  395.             //seg007_9E8:
  396.             var_loopCounter++;
  397.         }
  398.    
  399.         //seg007_B3F:
  400.         int[] var_occupiedSquares = new int[CivLogic.neighbourSquareCount_dseg_64C4];
  401.         CivLogic.dseg_7068_playerTrespassingAIcityFlag = 0;
  402.         var_loopCounter = 0;
  403.         while(var_loopCounter<CivLogic.neighbourSquareCount_dseg_64C4) {
  404.             var_occupiedSquares[var_loopCounter] = 0;
  405.    
  406.             var_neighbourX = city.getLocation().x() + CivUtils.relCityX[var_loopCounter];
  407.             var_neighbourY = city.getLocation().y() + CivUtils.relCityY[var_loopCounter];
  408.    
  409.             if(((SVECiv) cityOwner).getID()!=0) {
  410.                 if(!cityOwner.canSee(city.getLocation().neighbour(var_loopCounter, 0))) {
  411.                     var_occupiedSquares[var_loopCounter] = 1;
  412.                 }
  413.             }
  414.    
  415.             int i = CivUtils.relCityX[var_loopCounter]*5 + CivUtils.relCityY[var_loopCounter];
  416.    
  417.             Civ occup = CivLogic.whatCivOccupies(gs, var_neighbourX, var_neighbourY);
  418.             //int var_multiusage_bulbs_pop_ = gs.getMap().getRawLayerValue(8, var_neighbourX, var_neighbourY);
  419.    
  420.             //var_multiusage_bulbs_pop_ &= 0xFF;
  421.             if(occup!=null) {
  422.                 if(!cityOwner.equals(occup)) {
  423.                     //seg007_c02
  424.                     var_occupiedSquares[var_loopCounter] = 1;
  425.                     var_5x5_cityAreaArray[i+12] = 1;
  426.                     if(occup.equals(((SVECiv) gs.player()).getID())) {
  427.                         CivLogic.dseg_7068_playerTrespassingAIcityFlag = 1;
  428.                     }
  429.                 }
  430.             }
  431.    
  432.             if(var_5x5_cityAreaArray[i+12]!=0) {
  433.                 var_occupiedSquares[var_loopCounter] = 1;
  434.             }
  435.    
  436.             if(var_occupiedSquares[var_loopCounter]!=0) {
  437.                 //                      // remove worker, if any
  438.                 //                      int w0 = (Byte)city.getValue("workers_flag0");
  439.                 //                      int w1 = (Byte)city.getValue("workers_flag1");
  440.                 //                      int w2 = (Byte)city.getValue("workers_flag2");
  441.                 //                      //int w3 = (Byte)city.getValue("workers_flag3");
  442.                 //                      int workers = (w0&0xFF)|((w1&0xFF)<<8)|((w2&0xFF)<<16)/*|((w3&0xFF)<<24)*/;
  443.                 //                      int workerComp = ~(0x1<<var_loopCounter);
  444.                 //                      workers &= workerComp;
  445.                 //                      w0 = workers&0xFF;
  446.                 //                      w1 = (workers>>8)&0xFF;
  447.                 //                      w2 = (workers>>16)&0xFF;
  448.                 //                      //w3 = (workers>>24)&0xFF;
  449.                 //                      city.setValue("workers_flag0", (byte)w0);
  450.                 //                      city.setValue("workers_flag1", (byte)w1);
  451.                 //                      city.setValue("workers_flag2", (byte)w2);
  452.                 //                      //city.setValue("workers_flag3", (byte)w3);
  453.                 city.setWorkerAt(var_loopCounter, false);
  454.             }
  455.             var_loopCounter++;
  456.         }
  457.    
  458.         //seg007_C9A:
  459.         var_loopCounter = 0;
  460.         CivLogic.cityFoodProd_dseg_705A = 0;
  461.         CivLogic.cityShieldProd_dseg_705C = 0;
  462.         CivLogic.cityTradeProd_dseg_705E = 0;
  463.         CivLogic.cityLuxuryProd_dseg_7060 = 0;
  464.         //          while(var_loopCounter<4) {
  465.         //              dseg_705A_resourceCounters[var_loopCounter] = 0;
  466.         //              var_loopCounter++;
  467.         //          }
  468.    
  469.         //seg007_CC0:
  470.         var_E8 = 0;
  471.         var_EA = 0;
  472.    
  473.         boolean _skip0 = false;
  474.         if(cityOwner.equals(gs.player())
  475.                 || ((arg_cityID + (Integer)gs.getValue("game_turn")) & 0b11) != 0 // definitely some kind of randomization
  476.                 || (city.has(CityStatus.RIOT))  // city is rioting
  477.                 || (CivLogic.dseg_7068_playerTrespassingAIcityFlag!=0)) {
  478.             //seg007_D07:
  479.             var_loopCounter = 0;
  480.             while(var_loopCounter<CivLogic.neighbourSquareCount_dseg_64C4) {
  481.                 if(city.hasWorkerAt(var_loopCounter)) {
  482.                     var_citySize_plus_1--;
  483.                 }
  484.                 var_loopCounter++;
  485.             }
  486.    
  487.             if(var_citySize_plus_1>=0) {
  488.                 var_citySize_plus_1 = city.actualSize() + 1;
  489.                 var_loopCounter = 0;
  490.                 while(var_loopCounter<CivLogic.neighbourSquareCount_dseg_64C4) {
  491.                     if(var_citySize_plus_1 != 0) {
  492.                         //System.out.println(" city has worker at id="+var_loopCounter+" : "+city.hasWorkerAt(var_loopCounter));
  493.                         if(city.hasWorkerAt(var_loopCounter)) {
  494.                             var_occupiedSquares[var_loopCounter] = 1;
  495.    
  496.                             CivLogic.drawResourcesOnCityMapSquare(gs, bi, arg_cityID, var_loopCounter, arg_processMode);
  497.    
  498.                             var_citySize_plus_1 --;
  499.    
  500.                             var_EA |= (1<<var_loopCounter)&0x0000FFFF;
  501.                             var_E8 |= ((1<<var_loopCounter)&0xFFFF0000)>>16;
  502.                         }
  503.                     }
  504.                     var_loopCounter++;
  505.                 }
  506.    
  507.             } else {
  508.                 if(arg_processMode==0) {
  509.                     if(cityOwner.equals(gs.player())) {
  510.                         //TODO: popup message:
  511.                         // "Population decrease\nin "
  512.                         // city name
  513.                         // ".\n"
  514.                         CivLogic.dseg_2F4E = 4;
  515.                         CivLogic.dseg_C108_openCityScreenFlag = 1;
  516.                     }
  517.                 }
  518.                 var_citySize_plus_1 = city.actualSize() + 1;
  519.             }
  520.    
  521.             if(CivLogic.citySpecialistCount_dseg_F7D8 == var_citySize_plus_1
  522.                     || var_citySize_plus_1==0) {
  523.                 _skip0 = true;
  524.             }
  525.         }
  526.    
  527.         int var_bestNeighbourSquareID = 0; // ? no initialization...
  528.         int var_foodProd;
  529.         if(!_skip0) {
  530.             //seg007_E7D:
  531.             if(var_citySize_plus_1>0) {
  532.                 if(var_occupiedSquares[20] == 0) {
  533.                     var_occupiedSquares[20] = 1;
  534.                     CivLogic.drawResourcesOnCityMapSquare(gs, bi, arg_cityID, 20, arg_processMode);
  535.                     var_EA |= 0;
  536.                     var_E8 |= 0x10;
  537.                     var_citySize_plus_1--;
  538.                 }
  539.             }
  540.             //int AX = var_citySize_plus_1 + (var_citySize_plus_1<0?1:0);
  541.             //AX/=2;
  542.             //AX+=dseg_705A[0];
  543.             //int CX = dseg_705A[0]+var_citySize_plus_1 + (var_citySize_plus_1<0?1:0)/2;
  544.             //int AX = city.getActualSize()*2;
  545.             //int DX = city.getActualSize()*2;
  546.             //int AX = var_govtBonus_1_or_2;
  547.             //int BX = city.getActualSize()*2+dseg_F2E6_settler_counter*var_govtBonus_1_or_2;
  548.             //AX *= dseg_F2E6_settler_counter;
  549.             //BX += dseg_F2E6_settler_counter*var_govtBonus_1_or_2;
  550.    
  551.             int var_bestSquareFitness; // ? no initialization...
  552.             int var_bestFoodProd; // ? no initialization...
  553.             int var_squareFitness;
  554.             // Seems to be "worker auto-assign" loop
  555.             //seg007_EB5:
  556.             while( (
  557.                     (city.actualSize()*2+CivLogic.dseg_F2E6_settler_counter*var_settlerFoodCost) // Food consumption
  558.                     >
  559.                     (CivLogic.cityFoodProd_dseg_705A+(var_citySize_plus_1 + (var_citySize_plus_1<0?1:0))/2) // Food production ?
  560.                     || city.actualSize()<3
  561.                     )
  562.                     &&
  563.                     (var_citySize_plus_1>CivLogic.citySpecialistCount_dseg_F7D8)
  564.                     &&
  565.                     (var_bestNeighbourSquareID!=-1)) {
  566.    
  567.                 var_bestNeighbourSquareID = -1;
  568.                 var_bestSquareFitness = 0;
  569.                 var_bestFoodProd = 0;
  570.                 var_loopCounter = 0;
  571.    
  572.                 // Find next best, available city square
  573.                 while(var_loopCounter<CivLogic.neighbourSquareCount_dseg_64C4) {
  574.                     if(var_occupiedSquares[var_loopCounter] == 0) { // not occupied
  575.    
  576.                         var_neighbourX = city.getLocation().x() + CivUtils.relCityX[var_loopCounter];
  577.                         var_neighbourY = city.getLocation().y() + CivUtils.relCityY[var_loopCounter];
  578.                         var_foodProd = CivLogic.computeMapSquareResources(gs, var_neighbourX, var_neighbourY, 0);
  579.                         var_squareFitness = CivLogic.computeMapSquareResources(gs, var_neighbourX, var_neighbourY, 1);
  580.                         if(var_citySize_plus_1 != 1
  581.                                 || CivLogic.cityShieldProd_dseg_705C != 0 // shields
  582.                                 || var_squareFitness != 0) {
  583.                             var_squareFitness += CivLogic.computeMapSquareResources(gs, var_neighbourX, var_neighbourY, 2);
  584.    
  585.                             if(var_foodProd>var_bestFoodProd
  586.                                     || (var_foodProd==var_bestFoodProd && var_squareFitness>var_bestSquareFitness)) {
  587.                                 var_bestFoodProd = var_foodProd;
  588.                                 var_bestSquareFitness = var_squareFitness;
  589.                                 var_bestNeighbourSquareID = var_loopCounter;
  590.                             }
  591.                         }
  592.                     }
  593.                     var_loopCounter++;
  594.                 }
  595.    
  596.                 if(var_bestNeighbourSquareID!=-1) {
  597.                     var_occupiedSquares[var_bestNeighbourSquareID] = 1; // occupy square w/ specialist
  598.                     CivLogic.drawResourcesOnCityMapSquare(gs, bi, arg_cityID, var_bestNeighbourSquareID, arg_processMode);
  599.                     var_EA |= (1<<var_bestNeighbourSquareID)&0x0000FFFF;
  600.                     var_E8 |= ((1<<var_bestNeighbourSquareID)&0xFFFF0000)>>16;
  601.                     //city.setWorkerAt(var_bestNeighbourSquareID, true);
  602.                     var_citySize_plus_1--;
  603.                 }
  604.             }
  605.    
  606.             //seg007_1074:
  607.             if(!cityOwner.equals(gs.player())) {
  608.                 if(city.has(CityStatus.RIOT)) { // city is rioting?
  609.                     //seg007_1092
  610.                     CivLogic.citySpecialistCount_dseg_F7D8++;
  611.                 }
  612.             }
  613.    
  614.             //seg007_1096:
  615.             while(var_citySize_plus_1>CivLogic.citySpecialistCount_dseg_F7D8) {
  616.                 var_bestFoodProd = 0;
  617.                 var_bestSquareFitness = 0;
  618.                 var_bestNeighbourSquareID = -1;
  619.                 int var_E0 = 0;
  620.                 var_loopCounter = 0;
  621.                 while(var_loopCounter<CivLogic.neighbourSquareCount_dseg_64C4) {
  622.                     if(var_occupiedSquares[var_loopCounter]==0) {
  623.                         //seg007_10DE
  624.                         var_neighbourX = city.getLocation().x() + CivUtils.relCityX[var_loopCounter];
  625.                         var_neighbourY = city.getLocation().y() + CivUtils.relCityY[var_loopCounter];
  626.    
  627.                         int foodProduction = CivLogic.cityFoodProd_dseg_705A;
  628.                         int foodConsumption = city.actualSize()*2 + var_settlerFoodCost * CivLogic.dseg_F2E6_settler_counter;
  629.                         int foodSurplus = CivLogic.rangeBound(foodProduction - foodConsumption,1,99);
  630.    
  631.                         //int SI = 16/foodSurplus;
  632.    
  633.                         int var_foodProd_2 = CivLogic.computeMapSquareResources(gs, var_neighbourX,var_neighbourY,0);
  634.                         var_squareFitness = (16/foodSurplus) * var_foodProd_2;
  635.    
  636.                         int var_shieldProd_2 = CivLogic.computeMapSquareResources(gs, var_neighbourX,var_neighbourY,1);
  637.    
  638.                         int shieldProduction = CivLogic.cityShieldProd_dseg_705C;
  639.                         int shieldConsumption = CivLogic.dseg_E216_unitShieldMaintenanceCost;
  640.                         int shieldSurplus = CivLogic.rangeBound(shieldProduction - shieldConsumption,1,99);
  641.    
  642.                         //int CX = rangeBound(dseg_705A_resourceCounters[1]-dseg_E216_unitShieldMaintenanceCost,1,99);
  643.                         //int AX = (city.getActualSize()*3/shieldSurplus)*var_shieldProd_2;
  644.                         var_squareFitness += (city.actualSize()*3/shieldSurplus)*var_shieldProd_2;
  645.    
  646.                         int var_tradeProd = CivLogic.computeMapSquareResources(gs, var_neighbourX,var_neighbourY,2);
  647.    
  648.                         int AX = CivLogic.rangeBound(CivLogic.cityTradeProd_dseg_705E,1,99);
  649.                         var_squareFitness += (city.actualSize()*2/AX)*var_tradeProd;
  650.    
  651.                         if(var_squareFitness>var_bestSquareFitness) {
  652.                             var_bestSquareFitness = var_squareFitness;
  653.                             var_bestNeighbourSquareID = var_loopCounter;
  654.                             var_E0 = 2*(var_foodProd_2+var_shieldProd_2)+var_tradeProd;
  655.                         }
  656.                     }
  657.                     var_loopCounter++;
  658.                 }
  659.                 if(var_bestNeighbourSquareID!=-1) {
  660.                     var_occupiedSquares[var_bestNeighbourSquareID] = 1; // occupy square w/ worker
  661.                     CivLogic.drawResourcesOnCityMapSquare(gs, bi, arg_cityID, var_bestNeighbourSquareID, arg_processMode);
  662.                     var_EA |= (1<<var_bestNeighbourSquareID)&0x0000FFFF;
  663.                     var_E8 |= ((1<<var_bestNeighbourSquareID)&0xFFFF0000)>>16;
  664.                     var_citySize_plus_1--;
  665.                 } else {
  666.                     break;
  667.                 }
  668.             }
  669.    
  670.         }
  671.         //seg007_127E:
  672.         var_E8 |= ((var_citySize_plus_1<<10)&0b1111110000000000);
  673.         ((Entity) city).setPropertyValue("workers_flag0", (byte)(var_EA&0xFF));
  674.         ((Entity) city).setPropertyValue("workers_flag1", (byte)((var_EA>>8)&0xFF));
  675.         ((Entity) city).setPropertyValue("workers_flag2", (byte)(var_E8&0xFF));
  676.         ((Entity) city).setPropertyValue("workers_flag3", (byte)((var_E8>>8)&0xFF));
  677.    
  678.    
  679.         // =====================================
  680.         // Major loop start - seg007_12AE
  681.         // =====================================
  682.         //seg007_12AE:
  683.         var_X = city.getLocation().x();
  684.         var_Y = city.getLocation().y();
  685.         int var_specialistCount = var_citySize_plus_1;
  686.         var_loopCounter = 0;
  687.    
  688.         //seg007_12AE:
  689.         while(var_loopCounter<var_specialistCount) {
  690.             if(city.getCitySpecialistType(var_loopCounter).equals(CitySpecialistType.NONE)) {
  691.                 city.setCitySpecialistType(var_loopCounter, CitySpecialistType.ENTERTAINER);
  692.             }
  693.             var_loopCounter++;
  694.         }
  695.         var_loopCounter = var_specialistCount;
  696.         //seg007_1326:
  697.         while(var_loopCounter<8) {
  698.             city.setCitySpecialistType(var_loopCounter, CitySpecialistType.NONE);
  699.             var_loopCounter++;
  700.         }
  701.    
  702.         //seg007_1343:
  703.         int var_prodMultiplier2 = 0;
  704.         int var_prodMultiplier1 = 0;
  705.         CivLogic.dseg_6C18_cityPowerType = 1;
  706.         if(city.has(CityImprovement.FACTORY)) { var_prodMultiplier1 = 2; }
  707.         if(city.has(CityImprovement.MFG_PLANT)) { var_prodMultiplier1 = 4; }
  708.         if(city.has(CityImprovement.POWER_PLANT)) { var_prodMultiplier2 = 2; }
  709.         if(city.has(CityImprovement.HYDRO_PLANT)) { CivLogic.dseg_6C18_cityPowerType = 2; var_prodMultiplier2 = 2; }
  710.         if(city.has(CityImprovement.NUCLEAR_PLANT)) { CivLogic.dseg_6C18_cityPowerType = 2; var_prodMultiplier2 = 2; }
  711.         if(CivLogic.isWonderApplicable(cityOwner,WonderType.HOOVER_DAM)) {
  712.             int hx = gs.wonder(WonderType.HOOVER_DAM.getId()-1).getHostCity().getLocation().x();
  713.             int hy = gs.wonder(WonderType.HOOVER_DAM.getId()-1).getHostCity().getLocation().y();
  714.             int hcid = gs.landMassID(new MapLocation(hx,hy));
  715.             int cx = city.getLocation().x();
  716.             int cy = city.getLocation().y();
  717.             int ccid = gs.landMassID(new MapLocation(cx,cy));
  718.             if(hcid==ccid) {
  719.                 CivLogic.dseg_6C18_cityPowerType = 2; var_prodMultiplier2 = 2;
  720.             }
  721.         }
  722.         if(city.has(CityImprovement.RECYCLING_CENTER)) { CivLogic.dseg_6C18_cityPowerType = 3; }
  723.    
  724.         //seg007_1464:
  725.         var_prodMultiplier2 = CivLogic.rangeBound(var_prodMultiplier2, 0, var_prodMultiplier1);
  726.         int var_cityShieldProd = CivLogic.cityShieldProd_dseg_705C;
  727.         int var_cityTradeProd = CivLogic.cityTradeProd_dseg_705E;
  728.         CivLogic.cityShieldProd_dseg_705C += (var_prodMultiplier1*CivLogic.cityShieldProd_dseg_705C)/4 + (var_prodMultiplier2*CivLogic.cityShieldProd_dseg_705C)/4;
  729.         if(arg_processMode==0) {
  730.             //seg007_14CA:
  731.             int food = city.getFoodStock()+CivLogic.cityFoodProd_dseg_705A-var_settlerFoodCost*CivLogic.dseg_F2E6_settler_counter - city.actualSize()*2;
  732.             city.setFoodStock(food);
  733.             var_multi1 = CivLogic.cityShieldProd_dseg_705C - CivLogic.dseg_E216_unitShieldMaintenanceCost;
  734.             if(city.has(CityStatus.RIOT)) {
  735.                 //seg007_150E:
  736.                 var_multi1 = 0;
  737.             }
  738.             //seg007_1514:
  739.             city.setShieldStock(city.getShieldStock()+var_multi1);
  740.             boolean goto_seg007_22D9 = false; // strange control impossible to port otherwise; maybe a goto in original code
  741.             if(city.getCurrentProductionID()>=0) {
  742.                 //seg007_1536:
  743.                 int cost = gs.unitType(city.getCurrentProductionID()).cost()*var_16_min_2xDifficulty;
  744.                 if(cost<=city.getShieldStock() &&
  745.                         //seg007_1556:
  746.                         ( city.getCurrentProductionID() != 0
  747.                         ||
  748.                         //seg007_1568:
  749.                         city.actualSize() != 1
  750.                         ||
  751.                         //seg007_157A:
  752.                         gs.getDifficultyLevel() != DifficultyLevel.CHIEFTAIN)) {
  753.                     //seg007_1587:
  754.                     Unit newUnit = null;
  755.                     city.setShieldStock(city.getShieldStock()-cost);
  756.                     if(cityOwner.equals(gs.player())
  757.                             //seg007_15B4:
  758.                             || city.getCurrentProductionID() != 26) {
  759.                         //seg007_15C6:
  760.                         newUnit = CivLogic.createUnit(cityOwner,gs.unitType(city.getCurrentProductionID()),city.getLocation().x(),city.getLocation().y());
  761.                     }
  762.                     //seg007_15F2:
  763.                     if(gs.unitFirstTimeBuilt((UnitType) city.getCurrentProduction())) {
  764.                         //seg007_1612:
  765.                         //Skipped: write Replay Entry for unit first time built
  766.                         // with arguments: 6, 2 cityOwner, city.currentProdID
  767.                         gs.setUnitFirstTimeBuilt((UnitType) city.getCurrentProduction(), true);
  768.                     }
  769.                     //seg007_1650:
  770.                     if(city.has(CityImprovement.BARRACKS)
  771.                             &&
  772.                             //seg007_1662:
  773.                             newUnit != null) {
  774.                         //seg007_166C:
  775.                         newUnit.setVeteran(true);
  776.                     }
  777.                     //seg007_1683:
  778.                     if(newUnit != null) {
  779.                         //seg007_168D:
  780.                         if(city.getCurrentProductionID() == 0) {
  781.                             //seg007_169F:
  782.                             if(city.actualSize() > 1
  783.                                     ||
  784.                                     //seg007_16B1:
  785.                                     cityOwner.cities().size() > 1) {
  786.                                 //seg007_16C1:
  787.                                 city.actualSize(city.actualSize() - 1);
  788.                                 if(city.actualSize() == 0) {
  789.                                     //seg007_16D2:
  790.                                     //TODO destroy city, and check whether Civ is destroyed too...
  791.                                 }
  792.                             }
  793.                         }
  794.                     }
  795.                     //seg007_1737:
  796.                     if(!cityOwner.equals(gs.player())) {
  797.                         //seg007_1743:
  798.                         if(city.getCurrentProductionID() == 27) { // AI just produced a Caravan
  799.                             //seg007_1755:
  800.                             var_bestNeighbourSquareID = -1;
  801.                             int var_C6 = -1;
  802.                             var_cityLoop = 0;
  803.                             //seg007_176B:
  804.                             while(var_cityLoop < 0x80) {
  805.                                 //TODO: lookup the other, non-player City that has the best BaseTrade score
  806.                                 var_cityLoop++;
  807.                             }
  808.                             //seg007_17E4:
  809.                             // TODO ...and establish a trade route with them
  810.    
  811.                         }
  812.                         //seg007_17F8:
  813.                         if(city.getCurrentProductionID() == 26) { // AI just produced a Diplomat
  814.                             //TODO:
  815.                             // find a player city, that didn't have tech stolen this turn,
  816.                             // and which has a city or unit on the same continent (diplomat not on ocean, of course)
  817.    
  818.                             //seg007_1991:
  819.                             //if city is more than 3 squares away, or player at peace with AI civ: reimburse the diplomat (cheating AI!)
  820.                             //otherwise, create a Diplomat on the position of nearest city/unit and assign its GoTo to player city
  821.                         }
  822.                         //seg007_1A59:
  823.                         if(city.getCurrentProductionID() == 25) { // AI just produced a Nuclear
  824.                             //TODO:
  825.                             //if the AI civ has totally 1 Active Nuclear (just created),
  826.                             // then prepare to meet the Player (nextContact set to -1)
  827.                         }
  828.    
  829.                         //seg007_1A8A:
  830.                         //call: selectCityProduction(city)
  831.    
  832.                     } else {
  833.                         //seg007_1A98:
  834.                         city.setShieldStock(0);
  835.                         if(newUnit != null) {
  836.                             //seg007_1AB0:
  837.                             if(city.getCurrentProductionID() == 0
  838.                                     ||
  839.                                     //seg007_1AC2:
  840.                                     city.getCurrentProductionID() >= 26) {
  841.                                 //TODO: popup a dialog to tell the player a Settler, Diplomat or Caravan was just built
  842.                                 CivLogic.dseg_C108_openCityScreenFlag = 1;
  843.                             }
  844.    
  845.                         }
  846.                     }
  847.                     //seg007_1B42:
  848.                 } else {
  849.                     goto_seg007_22D9 = true;
  850.                 }
  851.             } else { //prod ID < 0, i.e. a building or wonder was just built
  852.                 //seg007_1B45:
  853.                 if(city.getCurrentProduction().getCostBase()*var_16_min_2xDifficulty <= city.getShieldStock()) {
  854.                     var_multi1 = -city.getCurrentProductionID();
  855.                     if(var_multi1 > 24) { // just built a wonder
  856.                         //seg007_1B88:
  857.                         if(gs.wonder(var_multi1 - 24).getHostCity() == null) {
  858.                             //seg007_1B98:
  859.                             //gs.wonder(var_multi1 - 24).setHostCity(city);
  860.                             //write replay entry for wonder built
  861.                         } else {
  862.                             var_multi1 = -1;
  863.                         }
  864.                     } else {
  865.                         //seg007_1BCD:
  866.                         if(city.has((CityImprovement)city.getCurrentProduction())) {
  867.                             var_multi1 = -1;
  868.                         }
  869.                     }
  870.                     //seg007_1BFF:
  871.                     if(var_multi1 != -1) {
  872.                         if(var_multi1 == 41) { // Project Manhattan
  873.                             //seg007_1C13:
  874.                             //Newspaper headlines: "Sensors report a NUCLEAR WEAPONS test near"...
  875.                         }
  876.                         //seg007_1C62:
  877.                         if(var_multi1 < 22) {
  878.                             //seg007_1C6C:
  879.                             city.add((CityImprovement)city.getCurrentProduction());
  880.                         }
  881.                         //seg007_1C91:
  882.                         city.setShieldStock(city.getShieldStock() - var_16_min_2xDifficulty*city.getCurrentProduction().getCostBase());
  883.                         if(!cityOwner.equals(gs.player())
  884.                                 //seg007_1CC4:
  885.                                 || var_multi1>24) {
  886.                             //seg007_1CCE:
  887.                             if(cityOwner.equals(gs.player())) {
  888.                                 //seg007_1CE0;
  889.                                 CivLogic.dseg_C108_openCityScreenFlag = 1; // open screen after building built
  890.                             } else {
  891.                                 //seg007_1CE9:
  892.                                 for(int i=0;i<8;i++) {
  893.                                     gs.setVisibility(gs.civ(0), city.getLocation().x(), city.getLocation().y(), 1, 1, VisibilityType.VISIBLE);
  894.                                 }
  895.                             }
  896.                             //seg007_1D04:
  897.                             //Skipped: prepare newspaperheadlines to inform player of construction
  898.                             if(gs.player().equals(cityOwner)) {
  899.                                 //seg007_1D57:
  900.                                 if(((Short)gs.getValue("game_settings") & 0x8) != 0) {
  901.                                     //seg07_1D61:
  902.                                 }
  903.                             }
  904.                             //seg007_1DBB:
  905.                         }
  906.                         //seg007_1DD7:
  907.                     }
  908.                 }
  909.             }
  910.             if(!goto_seg007_22D9) {
  911.                 //seg007_21E1:
  912.                 if(cityOwner.equals(gs.player())) {
  913.                     //seg007_21ED:
  914.                     if(city.has(CityStatus.AUTO_BUILD)) {
  915.                         //seg007_21FF:
  916.                         if(city.getShieldStock() == 0
  917.                                 ||
  918.                                 //seg007_2211:
  919.                                 (city.getCurrentProductionID()<0
  920.                                         //seg007_2223:
  921.                                         && var_multi1 == -1)) {
  922.                             //seg007_222D:
  923.    
  924.                             //TODO: auto-select city production for player
  925.                             //store auto-prod result in var_multi1
  926.                             //if auto-production could not find a suitable prod, result is 99
  927.                             if(var_multi1 != 99) {
  928.                                 //seg007_2253:
  929.                                 CivLogic.dseg_C108_openCityScreenFlag = 0;
  930.                                 if(city.getCurrentProductionID() >= 0) {
  931.                                     //seg007_226B:
  932.                                     //decrease PerCivUnitsInProduction...
  933.                                 }
  934.                                 //seg007_2289:
  935.                                 city.setCurrentProductionID(var_multi1);
  936.                                 if(city.getCurrentProductionID() >= 0) {
  937.                                     //seg007_22AB:
  938.                                     //increase PerCivUnitsInProduction...
  939.                                 }
  940.                                 //seg007_22C9:
  941.                             } else {
  942.                                 //seg007_22CC:
  943.                                 city.set(CityStatus.AUTO_BUILD,  false);
  944.                             }
  945.                         }
  946.                     }
  947.                 }
  948.             }
  949.    
  950.             //seg007_22D9:
  951.             if(!city.owner().equals(gs.player())) {
  952.                 //seg007_22EB:
  953.                 if(city.has(CityStatus.AUTO_BUILD)) {
  954.                     //seg007_22FD:
  955.                     //TODO!! select city production
  956.                 }
  957.                 //seg007_2308:
  958.                 var_foodProd = 0;
  959.                 int var_policy = (short)(Short)gs.getValue("civ"+cityOwner.getID()+".geostrategy"+gs.landMassID(var_X, var_Y)+".policy");
  960.                 if(var_policy == 1
  961.                         ||
  962.                         //seg007_233C:
  963.                         var_policy == 2
  964.                         ||
  965.                         //seg007_2346:
  966.                         var_policy == 5
  967.                         ) {
  968.                     //seg007_2350:
  969.                     if(var_multi1 == 0) {
  970.                         //seg007_235A:
  971.                         if(city.getCurrentProductionID() >= 0) {
  972.                             //seg007_236C:
  973.                             if(gs.unitType(city.getCurrentProductionID()).role().id() == var_policy) {
  974.                                 //seg007_2389:
  975.                                 var_foodProd = cityOwner.gold()>>6;
  976.                             }
  977.                         }
  978.                     }
  979.                 }
  980.                 //seg007_23A5:
  981.                 if(gs.player().hasLaunchedSpaceShip()) {
  982.                     //seg007)23BA:
  983.                     if(city.getCurrentProductionID()>=22) {
  984.                         //seg007)23D1:
  985.                         if(city.getCurrentProductionID()<=24) {
  986.                             //seg007_23E8:
  987.                             var_foodProd = cityOwner.gold()>>7;
  988.                         }
  989.                     }
  990.                 }
  991.                 //seg007_2404:
  992.                 if(city.has(CityStatus.RIOT)) {
  993.                     //seg007_2416:
  994.                     if(city.getCurrentProductionID() < 0) {
  995.                         //seg007_2428:
  996.                         if(city.getShieldStock() != 0) {
  997.                             //seg007_243A:
  998.                             var_foodProd = CivLogic.rangeBound(city.getCurrentProduction().getCostBase()*var_16_min_2xDifficulty - city.getShieldStock(), 0, cityOwner.gold()>>3);
  999.                         }
  1000.                     }
  1001.                 }
  1002.                 //seg007_2485:
  1003.                 if(CivLogic.whatCivOccupies(gs, var_X, var_Y).getID() == 0
  1004.                         ||
  1005.                         //seg007_249B:
  1006.                         city.has(CityStatus.AUTO_BUILD)) {
  1007.                     //seg007_24AD:
  1008.                     if(city.getCurrentProductionID() >= 0) {
  1009.                         //seg007_24BF:
  1010.                         if(city.getShieldStock() != 0) {
  1011.                             //seg007_24D1:
  1012.                             var_foodProd = CivLogic.rangeBound(city.getCurrentProduction().getCostBase()*var_16_min_2xDifficulty - city.getShieldStock(), 0, cityOwner.gold() / 3);
  1013.                         }
  1014.                     }
  1015.                 }
  1016.                 //seg007_250E:
  1017.                 if(city.getCurrentProduction() == null) {
  1018.                     //seg007_2520:
  1019.                     if(city.getShieldStock()!=0) {
  1020.                         //seg007_2532:
  1021.                         var_foodProd = CivLogic.rangeBound(city.getCurrentProduction().getCostBase()*var_16_min_2xDifficulty - city.getShieldStock(), 0, cityOwner.gold() / 3);
  1022.                     }
  1023.                 }
  1024.                 //seg007_256F:
  1025.                 if(city.has(CityStatus.RIOT) // cmp CityData.Status[bx], 19h
  1026.                         && !city.has(CityStatus.COASTAL)
  1027.                         && !city.has(CityStatus.RAPTURE_1)
  1028.                         &&  city.has(CityStatus.HYDRO_AVAILABLE)
  1029.                         &&  city.has(CityStatus.AUTO_BUILD)
  1030.                         && !city.has(CityStatus.TECH_STOLEN)
  1031.                         && !city.has(CityStatus.RAPTURE_2)
  1032.                         && !city.has(CityStatus.IMPROVEMENT_SOLD)
  1033.                         ) {
  1034.                     //seg007_2581:
  1035.                     //if(cityOwner has no nukes) {
  1036.                     //seg007_2594:
  1037.                     if(city.getShieldStock() != 0) {
  1038.                         //seg007_25A6:
  1039.                         var_foodProd = CivLogic.rangeBound(city.getCurrentProduction().getCostBase()*var_16_min_2xDifficulty - city.getShieldStock(), 0, cityOwner.gold() >> 2);
  1040.                     }
  1041.                     //}
  1042.                 }
  1043.    
  1044.                 //seg007_25EB:
  1045.                 if(cityOwner.gold() > 2000) {
  1046.                     //seg007_25FC:
  1047.                     var_foodProd += (cityOwner.gold() >> 9);
  1048.                 }
  1049.                 //seg007_2618:
  1050.                 city.setShieldStock(city.getShieldStock() + var_foodProd);
  1051.                 cityOwner.setGold(cityOwner.gold() - 2*var_foodProd);
  1052.                 city.set(CityStatus.AUTO_BUILD, false);
  1053.             }
  1054.         }
  1055.        
  1056.         //seg007_2645:
  1057.         if(arg_processMode == 1) {
  1058.             //seg007_2651:
  1059.              
  1060.             //city box 3: resources?
  1061.             CivDosRenderer.drawBlueDialogBackground(2, 67, 124, 104, gfx, false);
  1062.    
  1063.             //city box 4: happiness+map+?
  1064.             CivDosRenderer.drawBlueDialogBackground(95, 106, 227, 197, gfx, false);
  1065.    
  1066.             //tab INFO
  1067.             CivDosRenderer.drawPushButton(95, 106, 128, 114, bi, "INFO", Palette.defaultColors.get(9));
  1068.             //tab HAPPY
  1069.             CivDosRenderer.drawPushButton(129, 106, 160, 114, bi, "HAPPY", Palette.defaultColors.get(9));
  1070.             //tab MAP
  1071.             CivDosRenderer.drawPushButton(161, 106, 193, 114, bi, "MAP", Palette.defaultColors.get(9));
  1072.             //tab VIEW
  1073.             CivDosRenderer.drawPushButton(194, 106, 226, 114, bi, "VIEW", Palette.defaultColors.get(9));
  1074.            
  1075.             //CivLogic.dseg_2496_cityViewActiveTab = 1;
  1076.             CivDosRenderer.replaceColor(bi, 96+33*CivLogic.dseg_2496_cityViewActiveTab, 107, 32, 7, 9, 15);
  1077.            
  1078.             if(CivLogic.dseg_2496_cityViewActiveTab == 2) {
  1079.                 CivDosRenderer.drawCityMiniMap(bi, gs);
  1080.             }
  1081.         }
  1082.        
  1083.         //seg007_2750:
  1084.         var_X = city.getLocation().x();
  1085.         var_Y = city.getLocation().y();
  1086.        
  1087.         CivLogic.dseg_E200_corruption = 0;
  1088.         if(cityOwner.government().equals(GovernmentType.COMMUNISM)) {
  1089.             //seg007_278A:
  1090.             CivLogic.dseg_6AB0_distanceToCapital = 10;
  1091.         }
  1092.        
  1093.         //seg007_2790:
  1094.         CivLogic.dseg_E200_corruption = (CivLogic.cityTradeProd_dseg_705E * CivLogic.dseg_6AB0_distanceToCapital * 3) / (20 * ((SVECiv)cityOwner).governmentID() + 80);
  1095.    
  1096.         if(city.has(CityImprovement.COURTHOUSE)
  1097.                 ||
  1098.                 //seg007_27C6:
  1099.                 city.has(CityImprovement.PALACE)) {
  1100.             //seg007_27D8:
  1101.             CivLogic.dseg_E200_corruption = CivLogic.dseg_E200_corruption / 2;
  1102.         }
  1103.    
  1104.         //seg007_27E4:
  1105.         if(cityOwner.government().equals(GovernmentType.DEMOCRACY)) {
  1106.             //seg007_27F4:
  1107.             CivLogic.dseg_E200_corruption = 0;
  1108.         }
  1109.    
  1110.         //seg007_27FA:
  1111.         city.setBaseTrade(CivLogic.cityTradeProd_dseg_705E - CivLogic.dseg_E200_corruption);
  1112.    
  1113.         //seg007_281A:
  1114.         for(City tradeCity : city.getTradeCities()) {
  1115.             //seg007_2824:
  1116.             SVECity sveCity = (SVECity)tradeCity;
  1117.             if(sveCity != null && sveCity.exists()) {
  1118.                 //seg007_2843:
  1119.                 int cx = 3;
  1120.                 if(sveCity.owner().equals(cityOwner)) {
  1121.                     //seg007_2882:
  1122.                     cx = 4;
  1123.                 } else {
  1124.                     //seg007_2859:
  1125.                 }
  1126.                 CivLogic.cityTradeProd_dseg_705E += (sveCity.getBaseTrade() + CivLogic.cityTradeProd_dseg_705E + 4) >> cx;
  1127.             }
  1128.         }
  1129.         //seg007_28AB:
  1130.        
  1131. //      int ax = 20*cityOwner.government().getID();
  1132. //      int cx = ax;
  1133. //      cx = cx+80;
  1134. //      int bx = 3;
  1135. //      ax = CivLogic.cityTradeProd_dseg_705E;
  1136. //      ax = ax*CivLogic.dseg_6AB0_distanceToCapital;
  1137. //      ax = ax*bx;
  1138. //      ax = ax/cx;
  1139. //      CivLogic.dseg_E200_corruption = ax;
  1140.  
  1141.         CivLogic.dseg_E200_corruption = CivLogic.cityTradeProd_dseg_705E*CivLogic.dseg_6AB0_distanceToCapital*3/(20*cityOwner.government().getID()+80);
  1142.  
  1143.         if(cityOwner.government().equals(GovernmentType.DEMOCRACY)) {
  1144.             //seg007_28DF:
  1145.             CivLogic.dseg_E200_corruption = 0;
  1146.         }
  1147.  
  1148.         //seg007_28E5:
  1149.         if(city.has(CityImprovement.COURTHOUSE)) {
  1150.             //seg007_28F7:
  1151.             CivLogic.dseg_E200_corruption = CivLogic.dseg_E200_corruption/2;
  1152.         }
  1153.        
  1154.         //seg007_2903:
  1155.        
  1156. //      int cx = CivLogic.cityTradeProd_dseg_705E;
  1157. //      cx = cx-CivLogic.dseg_E200_corruption;
  1158. //      int ax = cityOwner.scienceRate();
  1159. //      ax = ax+cityOwner.taxRate();
  1160. //      ax = ax-10;
  1161. //      ax = -ax;
  1162. //      ax = ax*cx;
  1163. //      ax = ax+5;
  1164. //      cx = 10;
  1165. //      ax = ax/cx;
  1166. //      ax = CivLogic.rangeBound(ax, 0, CivLogic.cityTradeProd_dseg_705E);
  1167. //      CivLogic.cityLuxuryProd_dseg_7060 = ax;
  1168.        
  1169.         CivLogic.cityLuxuryProd_dseg_7060 = CivLogic.rangeBound((cityOwner.luxuryRate()*(CivLogic.cityTradeProd_dseg_705E-CivLogic.dseg_E200_corruption)+5)/10, 0, CivLogic.cityTradeProd_dseg_705E);
  1170.  
  1171.         //seg007_293D: non listed
  1172.         CivLogic.countCityTaxCollected_dseg_F09A = CivLogic.rangeBound((cityOwner.taxRate()*(CivLogic.cityTradeProd_dseg_705E-CivLogic.dseg_E200_corruption)+5)/10, 0, CivLogic.cityTradeProd_dseg_705E-CivLogic.cityLuxuryProd_dseg_7060-CivLogic.dseg_E200_corruption);                      
  1173.        
  1174.         //seg007_2976: non listed
  1175.         CivLogic.countCityResearchBulbs_dseg_7066 = CivLogic.cityTradeProd_dseg_705E-CivLogic.cityLuxuryProd_dseg_7060-CivLogic.countCityTaxCollected_dseg_F09A-CivLogic.dseg_E200_corruption;
  1176.        
  1177.         //seg007:2988
  1178.         CivLogic.countCityTaxCollected_dseg_F09A += 2*city.getCitySpecialistCount(CitySpecialistType.TAXMAN);
  1179.        
  1180.         //seg007:299A
  1181.         CivLogic.countCityResearchBulbs_dseg_7066 += 2*city.getCitySpecialistCount(CitySpecialistType.SCIENTIST);
  1182.        
  1183.         //seg007:29AC
  1184.         CivLogic.cityLuxuryProd_dseg_7060 += 2*city.getCitySpecialistCount(CitySpecialistType.ENTERTAINER);
  1185.        
  1186.         if(city.has(CityImprovement.MARKETPLACE)) {
  1187.             //seg007_29D0:
  1188.             CivLogic.cityLuxuryProd_dseg_7060 += CivLogic.cityLuxuryProd_dseg_7060/2;
  1189.             CivLogic.countCityTaxCollected_dseg_F09A += CivLogic.countCityTaxCollected_dseg_F09A/2;
  1190.         }
  1191.         //seg007_29E8:
  1192.         if(city.has(CityImprovement.BANK)) {
  1193.             //seg007_2FB8:
  1194.             CivLogic.cityLuxuryProd_dseg_7060 += CivLogic.cityLuxuryProd_dseg_7060/2;
  1195.             CivLogic.countCityTaxCollected_dseg_F09A += CivLogic.countCityTaxCollected_dseg_F09A/2;
  1196.         }
  1197.         //seg007_2A13:
  1198.         var_multi1 = CivLogic.countCityResearchBulbs_dseg_7066;
  1199.         if(city.has(CityImprovement.LIBRARY)) {
  1200.             //seg007_2A2C:
  1201.             var_multi1 += CivLogic.countCityResearchBulbs_dseg_7066/2;
  1202.             if(CivLogic.isWonderApplicable(cityOwner, WonderType.NEWTON_COLLEGE)) {
  1203.                 //seg007_2A50:
  1204.                 var_multi1 += CivLogic.countCityResearchBulbs_dseg_7066/3;
  1205.             }
  1206.         }
  1207.  
  1208.         //seg007_2A5D:
  1209.         if(city.has(CityImprovement.UNIVERSITY)) {
  1210.             //seg007_2A70:
  1211.             var_multi1 += CivLogic.countCityResearchBulbs_dseg_7066/2;
  1212.             if(CivLogic.isWonderApplicable(cityOwner, WonderType.NEWTON_COLLEGE)) {
  1213.                 //seg007_2A94:
  1214.                 var_multi1 += CivLogic.countCityResearchBulbs_dseg_7066/3;
  1215.             }
  1216.         }
  1217.        
  1218.         //seg007_2AA1:
  1219.         if(city.has(WonderType.COPERNICUS_OBSERVATORY)) {
  1220.             //seg007_2AB5:
  1221.             var_multi1 += var_multi1;
  1222.         }
  1223.        
  1224.         //seg007_2ABD:
  1225.         CivLogic.countCityResearchBulbs_dseg_7066 = var_multi1;
  1226.  
  1227.         CivLogic.city_happyCitizenCount_dseg_7062 = 0;
  1228.         if(cityOwner.equals(gs.player())) {
  1229.             //seg007_2AD6:
  1230.             CivLogic.city_unhappyCitizenCount_dseg_7064 = city.actualSize() + gs.getDifficultyLevel().getID() - 6;
  1231.            
  1232.         } else {
  1233.             //seg007_2AF4:
  1234.             CivLogic.city_unhappyCitizenCount_dseg_7064 = city.actualSize() - 3;
  1235.         }
  1236.         int var_unhappyCitizenCount = CivLogic.city_unhappyCitizenCount_dseg_7064;
  1237.        
  1238.         //seg007_2B0B:
  1239.         int var_40 = 116;
  1240.         CivLogic.adjustCitizenHappiness(city, var_specialistCount);
  1241.         if(arg_processMode == 1) {
  1242.             //seg007_2B2D:
  1243.             if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1244.                 //seg007_2B37:
  1245.                 var_40 = 116;
  1246.                 CivDosRenderer.drawCitizensInCityScreen(bi, city, 100, var_40, var_specialistCount, 92);
  1247.                 var_40 += 16;
  1248.                 gfx.setColor(Palette.defaultColors.get(1));
  1249.                 gfx.drawLine(100, var_40-2, 222, var_40-2);
  1250.             }
  1251.         }
  1252.        
  1253.         //seg007_2B75:
  1254.         CivLogic.city_happyCitizenCount_dseg_7062 = CivLogic.cityLuxuryProd_dseg_7060 / 2;
  1255.         CivLogic.adjustCitizenHappiness(city, var_specialistCount);
  1256.         if(arg_processMode == 1) {
  1257.             //seg007_2BA2:
  1258.             if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1259.                 //seg007_2BAC:
  1260.                 if(CivLogic.city_happyCitizenCount_dseg_7062 != 0) {
  1261.                     //seg007_2BB6:
  1262.                     CivDosRenderer.drawCitizensInCityScreen(bi, city, 100, var_40, var_specialistCount, 92);
  1263.                     BufferedImage luxuryIcon = ResourceManager.getSprite("city.resource.luxury.");
  1264.                     gfx.drawImage(luxuryIcon, 208, 4+var_40, null);
  1265.                     var_40 += 16;
  1266.                     gfx.setColor(Palette.defaultColors.get(1));
  1267.                     gfx.drawLine(100, var_40-2, 222, var_40-2);
  1268.                 }
  1269.             }
  1270.         }
  1271.        
  1272.         //seg007_2C06:
  1273.         int var_4 = 208;
  1274.         if(city.has(CityImprovement.COLOSSEUM)) {
  1275.             //seg007_2C1E:
  1276.             CivLogic.city_unhappyCitizenCount_dseg_7064 -= 3;
  1277.             if(arg_processMode == 1) {
  1278.                 //seg007_2C37:
  1279.                 if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1280.                     //seg007_2C41:
  1281.                     BufferedImage icon = ResourceManager.getSprite("city.improvement.icon.colosseum.");
  1282.                     gfx.drawImage(icon, var_4, var_40, null);
  1283.                     var_4 -= 16;
  1284.                 }
  1285.             }
  1286.         }
  1287.         //seg007_2C57:
  1288.         if(cityOwner.knows(Advance.RELIGION)) {
  1289.             //seg007_2C6F
  1290.             int ax = 0;
  1291.             if(city.has(CityImprovement.CATHEDRAL)) {
  1292.                 //seg007_2C82:
  1293.                 if(CivLogic.isWonderApplicable(cityOwner, WonderType.MICHELANGELO_CHAPEL)) {
  1294.                     //seg007_2C9A:
  1295.                     ax = 6;
  1296.                 } else {
  1297.                     ax = 4;
  1298.                 }
  1299.             }
  1300.             //seg007_2CA9:
  1301.             CivLogic.city_unhappyCitizenCount_dseg_7064 -= ax;
  1302.             if(arg_processMode == 1) {
  1303.                 //seg007_2CC1:
  1304.                 if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1305.                     //seg007_2CCB:
  1306.                     if(city.has(CityImprovement.CATHEDRAL)) {
  1307.                         //seg007_2CDE:
  1308.                         BufferedImage icon = ResourceManager.getSprite("city.improvement.icon.cathedral.");
  1309.                         gfx.drawImage(icon, var_4, var_40, null);
  1310.                         var_4 -= 16;
  1311.                     }
  1312.                 }
  1313.             }
  1314.         }
  1315.         //seg007_2CF4:
  1316.         if(city.has(CityImprovement.TEMPLE)) {
  1317.             //seg007_2D06:
  1318.             if(cityOwner.knows(Advance.MYSTICISM)) {
  1319.                 //seg007_2D1E:
  1320.                 CivLogic.city_unhappyCitizenCount_dseg_7064 -= 2;
  1321.             } else {
  1322.                 //seg007_2D26:
  1323.                 if(cityOwner.knows(Advance.CEREMONIAL_BURIAL)) {
  1324.                     //seg007_2D3E:
  1325.                     CivLogic.city_unhappyCitizenCount_dseg_7064 --;
  1326.                 }
  1327.             }
  1328.             //seg007_2D42:
  1329.             if(CivLogic.isWonderApplicable(cityOwner, WonderType.ORACLE)) {
  1330.                 //seg007_2D5A:
  1331.                 int ax = 1;
  1332.                 if(cityOwner.knows(Advance.MYSTICISM)) {
  1333.                     //seg007_2D72:
  1334.                     ax = 2;
  1335.                 }
  1336.                 //seg007_2D7B:
  1337.                 CivLogic.city_unhappyCitizenCount_dseg_7064 -= ax;
  1338.             }
  1339.             //seg007_2D7F:
  1340.             if(arg_processMode == 1) {
  1341.                 //seg007_2D93:
  1342.                 if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1343.                     //seg007_2D9D:
  1344.                     BufferedImage icon = ResourceManager.getSprite("city.improvement.icon.temple.");
  1345.                     gfx.drawImage(icon, var_4, var_40, null);
  1346.                     var_4 -= 16;
  1347.                 }
  1348.             }
  1349.         }
  1350.         //seg007_2DB3:
  1351.         CivLogic.adjustCitizenHappiness(city, var_specialistCount);
  1352.         if(arg_processMode == 1) {
  1353.             //seg007_2DD5:
  1354.             if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1355.                 //seg007_2DDF:
  1356.                 if(city.has(CityImprovement.TEMPLE)
  1357.                         || city.has(CityImprovement.COLOSSEUM)
  1358.                         || city.has(CityImprovement.CATHEDRAL)) {
  1359.                     //seg007_2DDF:
  1360.                     CivDosRenderer.drawCitizensInCityScreen(bi, city, 100, var_40, var_specialistCount, 92);
  1361.                     var_40 += 16;
  1362.                     gfx.setColor(Palette.defaultColors.get(1));
  1363.                     gfx.drawLine(100, var_40-2, 222, var_40-2);
  1364.                 }
  1365.             }
  1366.         }
  1367.        
  1368.         //seg007_2E2B:
  1369.         var_4 = 208;
  1370.         if(!cityOwner.government().equals(GovernmentType.DEMOCRACY)
  1371.                 && !cityOwner.government().equals(GovernmentType.REPUBLIC)) {
  1372.             //seg007_2E40:
  1373.             //int var_newUnitID = 0;
  1374.             //while(var_newUnitID<2) {
  1375.                 //seg007_2E57:
  1376.                 if(CivLogic.city_unhappyCitizenCount_dseg_7064 != 0) {
  1377.                     //seg007_2E61:
  1378.                     if(gs.unitType(city.getUnknown_citybyte27()&0x3F)!=null
  1379.                             && gs.unitType(city.getUnknown_citybyte27()&0x3F).attack()>0) {
  1380.                         //seg007_2E77:
  1381.                         CivLogic.city_unhappyCitizenCount_dseg_7064--;
  1382.                     }
  1383.                 }
  1384.                 //2nd loop iteration
  1385.                 //seg007_2E57:
  1386.                 if(CivLogic.city_unhappyCitizenCount_dseg_7064 != 0) {
  1387.                     //seg007_2E61:
  1388.                     if(gs.unitType(city.getUnknown_citybyte28()&0x3F)!=null
  1389.                             && gs.unitType(city.getUnknown_citybyte28()&0x3F).attack()>0) {
  1390.                         //seg007_2E77:
  1391.                         CivLogic.city_unhappyCitizenCount_dseg_7064--;
  1392.                     }
  1393.                 }
  1394.             //}
  1395.             //seg007_2EA3:
  1396.             Unit unit = CivLogic.getUnitAt(gs, var_X,  var_Y);
  1397.             Unit var_multi1_unit = unit;
  1398.             Unit var_newUnitId = unit;
  1399.             //seg007_2EBB:
  1400.             while(var_newUnitId != null) {
  1401.                 //seg007_2EC5:
  1402.                 if(var_newUnitId.getType().attack()>0) {
  1403.                     //seg007_2EE9:
  1404.                     if(CivLogic.city_unhappyCitizenCount_dseg_7064>0) {
  1405.                         //seg007_2EF3:
  1406.                         CivLogic.city_unhappyCitizenCount_dseg_7064--;
  1407.                     }
  1408.                     //seg007_2EF7:
  1409.                     if(arg_processMode == 1) {
  1410.                         //seg007_2F0B:
  1411.                         if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1412.                             //seg007_2F15:
  1413.                             BufferedImage unitimg = ImageUtils.getCivUnitIcon((SVEUnit) var_newUnitId);
  1414.                             gfx.drawImage(unitimg, var_4, var_40-1, null);
  1415.                             var_4 -= 2;
  1416.                         }
  1417.                     }
  1418.                 }
  1419.                 //seg007_2F4E:
  1420.                 var_newUnitId = ((SVEUnit)var_newUnitId).nextInStack();
  1421.                 if(var_newUnitId!=null && var_newUnitId.equals(var_multi1_unit)) {
  1422.                     //seg007_2F76:
  1423.                     var_newUnitId = null;
  1424.                 }
  1425.             }
  1426.             //seg007_2F7F: -> 3020
  1427.         } else {
  1428.             //seg007_2F82:
  1429.             int var_multi1_sadPerUnit = CivLogic.isWonderApplicable(cityOwner, WonderType.WOMEN_SUFFRAGE)?0:1;
  1430.             if(cityOwner.government().equals(GovernmentType.DEMOCRACY)) {
  1431.                 //seg007_2FAD:
  1432.                 var_multi1_sadPerUnit++;
  1433.             }
  1434.             //seg007_2FB1:
  1435.             if(var_multi1_sadPerUnit != 0) {
  1436.                 //seg007_2FBB:
  1437.                 CivLogic.city_unhappyCitizenCount_dseg_7064 += CivLogic.dseg_64C8_away_unit_counter * var_multi1_sadPerUnit;
  1438.                 if(arg_processMode == 1) {
  1439.                     //seg007_2FDB:
  1440.                     if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1441.                         //seg007_2FE5:
  1442.                         BufferedImage sadIcon = ResourceManager.getSprite("city.resource.unhappiness.");
  1443.                         for(int i=0;i<CivLogic.dseg_64C8_away_unit_counter * var_multi1_sadPerUnit;i++) {
  1444.                             //seg007_3003:
  1445.                             gfx.drawImage(sadIcon, var_4, 4+var_40, null);
  1446.                             var_4 -= 2;
  1447.                         }
  1448.                     }
  1449.                 }
  1450.             }
  1451.         }
  1452.         //seg007_3020:
  1453.         CivLogic.adjustCitizenHappiness(city, var_specialistCount);
  1454.         if(arg_processMode == 1) {
  1455.             //seg007_3042:
  1456.             if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1457.                 //seg007_304C:
  1458.                 CivDosRenderer.drawCitizensInCityScreen(bi, city, 100, var_40, var_specialistCount, 92);
  1459.                 var_40 += 16;
  1460.                 gfx.setColor(Palette.defaultColors.get(1));
  1461.                 gfx.drawLine(100, var_40-2, 222, var_40-2);
  1462.             }
  1463.         }
  1464.         //seg007_3085:
  1465.         int var_multi1_content = CivLogic.city_happyCitizenCount_dseg_7062 - CivLogic.city_unhappyCitizenCount_dseg_7064;
  1466.         if(CivLogic.isWonderApplicable(cityOwner, WonderType.HANGING_GARDENS)) {
  1467.             //seg007_30A8:
  1468.             CivLogic.city_happyCitizenCount_dseg_7062++;
  1469.         }
  1470.         //seg007_30AC:
  1471.         if(CivLogic.isWonderApplicable(cityOwner, WonderType.CURE_FOR_CANCER)) {
  1472.             //seg007_30C4:
  1473.             CivLogic.city_happyCitizenCount_dseg_7062++;
  1474.         }
  1475.         //seg007_30C8:
  1476.         if(city.has(WonderType.SHAKESPEARE_THEATRE)) {
  1477.             //seg007_30DC:
  1478.             CivLogic.city_unhappyCitizenCount_dseg_7064 = 0;
  1479.         }
  1480.         //seg007_30E2:
  1481.         if(CivLogic.isWonderApplicable(cityOwner, WonderType.JSBACH_CATHEDRAL)) {
  1482.             //seg007_30FA:
  1483.             assert gs.wonder(WonderType.JSBACH_CATHEDRAL.getId()) != null;
  1484.             assert gs.wonder(WonderType.JSBACH_CATHEDRAL.getId()).getHostCity() != null;
  1485.             if(gs.landMassID(gs.wonder(WonderType.JSBACH_CATHEDRAL.getId()).getHostCity().getLocation())
  1486.                     == gs.landMassID(city.getLocation())){
  1487.                 //seg007_3132:
  1488.                 CivLogic.city_unhappyCitizenCount_dseg_7064 -= 2;
  1489.             }
  1490.         }
  1491.         //seg007_3137:
  1492.         CivLogic.adjustCitizenHappiness(city, var_specialistCount);
  1493.         if(arg_processMode == 1) {
  1494.             //seg007_3042:
  1495.             if(CivLogic.dseg_2496_cityViewActiveTab == 1) {
  1496.                 if(var_multi1_content != CivLogic.city_happyCitizenCount_dseg_7062 - CivLogic.city_unhappyCitizenCount_dseg_7064){
  1497.                     //seg007_3173:
  1498.                     CivDosRenderer.drawCitizensInCityScreen(bi, city, 100, var_40, var_specialistCount, 92);
  1499. //                  seg007:318C 10C                 mov     ax, 15
  1500. //                  seg007:318F 10C                 push    ax
  1501.                    
  1502. //                  seg007:3190 10E                 mov     ax, [bp+var_40]
  1503. //                  seg007:3193 10E                 add     ax, 5           ; Add
  1504. //                  seg007:3196 10E                 push    ax
  1505.                    
  1506. //                  seg007:3197 110                 mov     ax, 190
  1507. //                  seg007:319A 110                 push    ax
  1508.                    
  1509. //                  seg007:319B 112                 mov     ax, offset aWonders ; "WONDERS"
  1510. //                  seg007:319E 112                 push    ax
  1511.                    
  1512. //                  seg007:319F 114                 call    drawStringFlat_str_x_y_color ; Call Procedure
  1513. //                  seg007:319F
  1514. //                  seg007:31A4 114                 add
  1515.                     CivDosRenderer.drawString("WONDERS", gfx, 1, Palette.defaultColors.get(15), 190, var_40+5);
  1516.                     var_40 += 16;
  1517.                     gfx.setColor(Palette.defaultColors.get(1));
  1518.                     gfx.drawLine(100, var_40-2, 222, var_40-2);
  1519.                 }
  1520.             }
  1521.         }
  1522.        
  1523.         //seg007_31C7:
  1524.         //if debug switches 2 is disabled, set happy and unhappy citizens to 0
  1525.        
  1526.         //seg007_31DA:
  1527.         int var_4C = 0;
  1528.         CivLogic.dseg_EDD8_unk27_28_counter = 0;
  1529.         CivLogic.dseg_EDD6 = 0;
  1530.         CivLogic.dseg_E216_unitShieldMaintenanceCost = 0;
  1531.         var_loopCounter = 0;
  1532.         {
  1533.             //seg007_31F6:
  1534.             while(var_loopCounter < 2) {
  1535.                 //seg007_3200:
  1536.                 if( ( (var_loopCounter==0?city.getUnknown_citybyte27():city.getUnknown_citybyte28())&0xFF) != 0xFF) {
  1537.                     //seg007_3216:
  1538.                     CivLogic.dseg_EDD8_unk27_28_counter++;
  1539.                 }
  1540.                 var_loopCounter++;
  1541.             }
  1542.             //seg007_321D:
  1543.             if(city.actualSize() < CivLogic.dseg_EDD8_unk27_28_counter) {
  1544.                 //seg007_3233:
  1545.                 CivLogic.dseg_E216_unitShieldMaintenanceCost = CivLogic.dseg_EDD8_unk27_28_counter - city.actualSize();
  1546.             }
  1547.             //seg007_324A:
  1548.             int var_stockAreaWidth = 8;
  1549.             int var_stockAreaHeight = 69;
  1550.             int var_F6 = 100;
  1551.             int var_FC = 116;
  1552.             var_loopCounter = 0;
  1553.            
  1554.             //seg007_326F:
  1555.             while(var_loopCounter < 128) {
  1556.                 //seg007_327A:
  1557.                 SVEUnit unit = (SVEUnit) cityOwner.unit(var_loopCounter);
  1558.                 if(unit!=null && unit.exists()) {
  1559.                     //seg007_3296:
  1560.                     if(unit.getHome().equals(city)) {
  1561.                         //seg007_32B5:
  1562.                         if(!unit.getType().getUnitTypeCode().equals(UnitTypeCode.DIPLOMAT)
  1563.                                 && !unit.getType().getUnitTypeCode().equals(UnitTypeCode.CARAVAN)) {
  1564.                             //seg007_32D1:
  1565.                             CivLogic.dseg_EDD8_unk27_28_counter++;
  1566.                             if(city.actualSize()<CivLogic.dseg_EDD8_unk27_28_counter
  1567.                                 ||
  1568.                                 //seg007_32EB:
  1569.                                 (!cityOwner.government().equals(GovernmentType.ANARCHY)
  1570.                                         &&!cityOwner.government().equals(GovernmentType.DESPOTISM)
  1571.                                         //&& debugSwitches 2 is set...
  1572.                                         )
  1573.                                 ) {
  1574.                                 //seg007_3305:
  1575.                                 CivLogic.dseg_E216_unitShieldMaintenanceCost++;
  1576.                             }
  1577.                         }
  1578.                         //seg007_3309:
  1579.                         if(arg_processMode == 0) {
  1580.                             //seg007_3314:
  1581.                             if(CivLogic.cityShieldProd_dseg_705C < CivLogic.dseg_E216_unitShieldMaintenanceCost
  1582.                                     ||
  1583.                                     (
  1584.                                             //seg007_3320:
  1585.                                             city.has(CityStatus.RIOT)
  1586.                                             &&
  1587.                                             //seg007_3332:
  1588.                                             ((gs.turn()+var_loopCounter)%8==0)
  1589.                                             &&
  1590.                                             //seg007_3341:
  1591.                                             !cityOwner.equals(gs.player())
  1592.                                             &&
  1593.                                             //seg007_334D:
  1594.                                             (cityOwner.government().equals(GovernmentType.REPUBLIC)
  1595.                                                     ||cityOwner.government().equals(GovernmentType.DEMOCRACY))
  1596.                                     )
  1597.                                 ) {
  1598.                                 //seg007_335D:
  1599.                                 var_bestNeighbourSquareID = -1;
  1600.                                 int var_bestCityBaseTrade = -1;
  1601.                                 int var_spyCityCount = 0;
  1602.                                
  1603.                                 //seg007_3375:
  1604.                                 while(var_spyCityCount < 0x80) {
  1605.                                     //seg00_3380:
  1606.                                     SVEUnit unit2 = (SVEUnit) cityOwner.unit(var_loopCounter);
  1607.                                     if(unit2!=null && unit2.exists()) {
  1608.                                         //seg007_339C:
  1609.                                         if(unit2.getHome().equals(city)) {
  1610.                                             //seg007_33BB:
  1611.                                             if(!unit2.getType().getUnitTypeCode().equals(UnitTypeCode.DIPLOMAT)
  1612.                                                     && !unit2.getType().getUnitTypeCode().equals(UnitTypeCode.CARAVAN)) {
  1613.                                                 //seg007_33D7:
  1614.                                                 varOtherDist = CivLogic.distance(city.getLocation().x(), unit2.getLocation().x(), city.getLocation().y(), unit2.getLocation().y());
  1615.                                                 if(varOtherDist > var_bestCityBaseTrade) {
  1616.                                                     //seg007_3426:
  1617.                                                     var_bestCityBaseTrade = varOtherDist;
  1618.                                                     var_bestNeighbourSquareID = var_spyCityCount;
  1619.                                                 }
  1620.                                             }
  1621.                                         }
  1622.                                     }
  1623.                                    
  1624.                                    
  1625.                                     //seg007_3371:
  1626.                                     var_spyCityCount++;
  1627.                                 }
  1628.                                 //seg007_3439:
  1629.                                 if(CivLogic.cityShieldProd_dseg_705C >= CivLogic.dseg_E216_unitShieldMaintenanceCost) {
  1630.                                     //seg007_3445:
  1631.                                     if(CivLogic.dseg_8F98 != 0
  1632.                                         &&
  1633.                                         //seg007_344F:
  1634.                                         cityOwner.techCount() < gs.player().techCount()
  1635.                                             ) {
  1636.                                         //  //seg007_3468:
  1637.                                         CivLogic.dseg_EA62 = -999;
  1638.                                     } else {
  1639.                                         //seg007_3471:
  1640.                                         if(var_bestCityBaseTrade > 0) {
  1641.                                             //seg007_347B:
  1642.                                             if(cityOwner.unit(var_bestNeighbourSquareID).getType().category().equals(UnitCategory.LAND)) {
  1643.                                                 //seg007_349F:
  1644.                                                 if(!cityOwner.unit(var_bestNeighbourSquareID).getType().getUnitTypeCode().equals(UnitTypeCode.SETTLER)) {
  1645.                                                     //seg007_34BB:
  1646.                                                     cityOwner.unit(var_bestNeighbourSquareID).delete();
  1647.                                                     city.set(CityStatus.RIOT, false);
  1648.                                                 }
  1649.                                             }
  1650.                                         }
  1651.                                     }
  1652.                                 } else {
  1653.                                     //seg007_34DB:
  1654.                                     if(gs.player().equals(cityOwner)) {
  1655.                                         //seg007_34E7:
  1656.                                         //TODO DISBANDING UNSUPPORTED UNIT DIALOG
  1657.                                     }
  1658.                                     //seg007_3559
  1659.                                     //DELETE UNIT AND
  1660.                                     cityOwner.unit(var_bestNeighbourSquareID).delete();
  1661.                                     //LOOP BACK TO TOP LOOP seg007_31DA
  1662.                                     continue;
  1663.                                 }
  1664.                             }
  1665.                         }
  1666.                         //seg007_356C:
  1667.                         if(arg_processMode == 1) {
  1668.                             //seg007_3580:
  1669.                             if(!unit.getType().getUnitTypeCode().equals(UnitTypeCode.DIPLOMAT)
  1670.                                     && !unit.getType().getUnitTypeCode().equals(UnitTypeCode.CARAVAN)) {
  1671.                                 //seg007_359C:
  1672.                                 if(CivLogic.dseg_E216_unitShieldMaintenanceCost != 0) {
  1673.                                     //seg007_35A6:
  1674.                                     BufferedImage shieldicon = ResourceManager.getSprite("city.resource.shield.");
  1675.                                     gfx.drawImage(shieldicon, 8+var_stockAreaWidth,  12+var_stockAreaHeight, null);
  1676.                                 }
  1677.                                 //seg007_35C2:
  1678.                                 if(unit.getType().getUnitTypeCode().equals(UnitTypeCode.SETTLER)) {
  1679.                                     //seg007_35DE:
  1680.                                     BufferedImage foodicon = ResourceManager.getSprite("city.resource.food.");
  1681.                                     gfx.drawImage(foodicon, var_stockAreaWidth,  12+var_stockAreaHeight, null);
  1682.                                     if(cityOwner.government().ordinal()>=2) {
  1683.                                         //seg007_3606:
  1684.                                         gfx.drawImage(foodicon, var_stockAreaWidth+2,  12+var_stockAreaHeight, null);
  1685.                                     }
  1686.                                 } else {
  1687.                                     //seg007_3624:
  1688.                                     if(CivLogic.isWonderApplicable(cityOwner, WonderType.WOMEN_SUFFRAGE)) {
  1689.                                         //seg007_364F:
  1690.                                         var_multi1++;
  1691.                                     }
  1692.                                     //seg007_3653:
  1693.                                     if(cityOwner.government().ordinal()>=4) {
  1694.                                         //seg007_3663:
  1695.                                         if(var_multi1 != 0) {
  1696.                                             //seg007_366D:
  1697.                                             if(unit.getType().category().equals(UnitCategory.AIR)
  1698.                                                     ||
  1699.                                                     //seg007_3691:
  1700.                                                     unit.getLocation().x() != city.getLocation().x()
  1701.                                                     ||
  1702.                                                     //seg007_36BA:
  1703.                                                     unit.getLocation().y() != city.getLocation().y()
  1704.                                                     ) {
  1705.                                                 //seg007_36E3:
  1706.                                                 BufferedImage sadicon = ResourceManager.getSprite("city.resource.unhappiness.");
  1707.                                                 gfx.drawImage(sadicon, var_stockAreaWidth,  12+var_stockAreaHeight, null);
  1708.                                                 if(var_multi1>1) {
  1709.                                                     //seg007_3705:
  1710.                                                     gfx.drawImage(sadicon, 2+var_stockAreaWidth,  12+var_stockAreaHeight, null);
  1711.                                                 }
  1712.                                             }
  1713.                                         }
  1714.                                     }
  1715.                                 }
  1716.                             }
  1717.                             //seg007_3720:
  1718.                             BufferedImage uniticon = ImageUtils.getCivUnitIcon(cityOwner.getID(), unit.getType().getID());
  1719.                             gfx.drawImage(uniticon, var_stockAreaWidth, var_stockAreaHeight, null);
  1720.                             CivDosRenderer.drawPointInCityMap(bi, gs, unit.getLocation().x(), unit.getLocation().y(), 7);
  1721.                             var_stockAreaWidth += 0x10;
  1722.                             if(var_stockAreaWidth >= 0x70) {
  1723.                                 //seg007_3790:
  1724.                                 var_stockAreaWidth = 8;
  1725.                                 var_stockAreaHeight += 0x10;
  1726.                                 if(var_stockAreaHeight > 0x55) {
  1727.                                     //seg007_37A5:
  1728.                                     var_stockAreaHeight -= 0x18;
  1729.                                 }
  1730.                             }
  1731.                         }
  1732.                     }
  1733.                 }
  1734.                 int[] var_72 = new int[0x12];
  1735.                 //seg007_37AA:
  1736.                 if(var_4C < 0x12) {
  1737.                     //seg007_37B3:
  1738.                     if(CivLogic.dseg_2496_cityViewActiveTab == 0) {
  1739.                         //seg007_37BD:
  1740.                         if(unit!=null && unit.exists()) {
  1741.                             //seg007_37D9:
  1742.                             if(arg_processMode == 1) {
  1743.                                 //seg007_37ED:
  1744.                                 if(unit.getLocation().equals(city.getLocation())) {
  1745.                                     //seg007_382F:
  1746.                                    
  1747.                                     //gfx.drawImage(ImageUtils.getCivUnitIcon(unit),var_F6, var_FC, null);
  1748.                                     ImageUtils.drawUnit((AbstractSVEUnit) unit, gfx, var_F6, var_FC);
  1749.                                    
  1750.                                     String cityCode = unit.getHome().getName().substring(0, 3)+".";
  1751.                                     CivDosRenderer.drawString(cityCode, gfx, 1, Palette.defaultColors.get(0), var_F6, var_FC+0xF +6);
  1752.                                     var_72[var_4C++] = var_loopCounter;
  1753.                                     var_F6 += 0x12;
  1754.                                     if(var_4C%6 == 0) {
  1755.                                         var_F6 = 0x64;
  1756.                                         var_FC += 0x10;
  1757.                                     }
  1758.                                 }
  1759.                             }
  1760.                         }
  1761.                     }
  1762.                 }
  1763.                 //seg007_38C2:
  1764.                 var_loopCounter++;
  1765.             }
  1766.             //seg007_38C5:
  1767.             if(arg_processMode == 0) {
  1768.                 //seg007_38D0:
  1769.                 if(CivLogic.cityShieldProd_dseg_705C<CivLogic.dseg_EDD8_unk27_28_counter) {
  1770.                     //seg007_38DC:
  1771.                     CivLogic.dseg_F2E2 += (CivLogic.dseg_EDD8_unk27_28_counter - CivLogic.cityShieldProd_dseg_705C) * 5;
  1772.                 }
  1773.                 //seg007_38EC:
  1774.                 CivLogic.dseg_F2E2 += CivLogic.rangeBound(CivLogic.dseg_EDD8_unk27_28_counter, 0, city.actualSize());
  1775.                 int ax;
  1776.                 if(city.has(CityImprovement.MARKETPLACE)) {
  1777.                     //seg007_3920:
  1778.                     ax = 5;
  1779.                 } else {
  1780.                     //seg007_3926:
  1781.                     ax = 7;
  1782.                 }
  1783.                 CivLogic.dseg_EA62 -= CivLogic.dseg_64C8_away_unit_counter * (ax - cityOwner.militaryAttitude().value());
  1784.             }
  1785.             //seg007_3948:
  1786.             if(arg_processMode == 1) { // heavy duty rendering! strap your seat belts...
  1787.                 //seg007_395C:
  1788.                 CivDosRenderer.drawBlueDialogBackground(211, 1, 317, 97, gfx, false);
  1789.                 int var_spyCityCount = 2;
  1790.                 var_Y = 2;
  1791.                 int var_3E = 0;
  1792.                 int var_B2 = 0;
  1793.                 if(var_D8 == 0) {
  1794.                     //seg007_399C:
  1795.                     int var_improvementTypeID = 0;
  1796.                     while(var_improvementTypeID < 21) {
  1797.                         //seg007_39B3:
  1798.                         if(city.equals(gs.wonder(var_improvementTypeID).getHostCity())) {
  1799.                             //seg007_39C5:
  1800.                             CivDosRenderer.drawString(FontUtils.truncateStringToPixelLength(gs.wonder(var_improvementTypeID).getName().toUpperCase(), 1, 63), gfx, 1, Palette.defaultColors.get(15), 253, var_Y+2+6);
  1801.                            
  1802.                             //seg007_3A38:
  1803.                             BufferedImage wicon = ResourceManager.getSprite("wonder.icon."+gs.wonder(var_improvementTypeID).getType().getCode()+".");
  1804.                             gfx.drawImage(wicon, var_spyCityCount%2==0?233:213, var_Y-2, null);
  1805.                            
  1806.                             var_Y += 6;
  1807.                             var_spyCityCount++;
  1808.                             var_3E++;
  1809.                         }
  1810.                         //seg007_39A5:
  1811.                         var_improvementTypeID++;
  1812.                     }
  1813.                 }
  1814.                 //seg007_3A56:
  1815.                 var_FA = 0;
  1816.                 int var_improvementTypeID = var_D8;
  1817.                 while(var_improvementTypeID < 24) {
  1818.                     //seg007_3A75:
  1819.                     if(city.has(CityImprovement.getById(var_improvementTypeID))) {
  1820.                         //seg007_3A9F:
  1821.                         if(var_spyCityCount >= 16) {
  1822.                             //seg007_3AA9:
  1823.                             var_C8 |= 2;
  1824.                             var_C8 &= 0xFFFE;
  1825.                             var_FA = var_improvementTypeID;
  1826.                             break;
  1827.                         } else {
  1828.                             //seg007_3ABF:
  1829.                             BufferedImage sicon = ResourceManager.getSprite("city.resource.tax.");
  1830.                             gfx.drawImage(sicon, 309,  var_Y+1, null);
  1831.                            
  1832.                             CivDosRenderer.drawString(FontUtils.truncateStringToPixelLength(CityImprovement.getById(var_improvementTypeID).getLocalizedName(gs.getVersion().language()).toUpperCase(), 1, 56), gfx, 1, Palette.defaultColors.get(15), 253, var_Y+2+6);
  1833.                            
  1834.                             BufferedImage bicon = ResourceManager.getSprite("city.improvement.icon."+CityImprovement.getById(var_improvementTypeID).getCode()+".");
  1835.                             gfx.drawImage(bicon, var_spyCityCount%2==0?233:213, var_Y-2, null);
  1836.  
  1837.                             //seg007_3B3E:
  1838.                             var_Y += 6;
  1839.                             var_spyCityCount++;
  1840.                         }
  1841.                     }
  1842.                     var_improvementTypeID++;
  1843.                 }
  1844.                 //seg007_3B59:
  1845.                 gfx.setColor(Palette.defaultColors.get(0));
  1846.                 gfx.drawLine(231, 0, 250, 0);
  1847.                 gfx.setColor(Palette.defaultColors.get(1));
  1848.                 gfx.drawLine(231, 1, 250, 1);
  1849.  
  1850.                 if((var_C8 & 2) != 0) {
  1851.                     //seg007_3B9B:
  1852.                     CivDosRenderer.drawPushButton(287, 88, 315, 96, bi, "MORE", Palette.defaultColors.get(9));
  1853.                 }
  1854.                 //seg007_3BBB:
  1855.                 CivDosRenderer.replaceColor(bi, 309, 2, 8, 96, 14, 12);
  1856.                
  1857.                 //seg007_3BF1:
  1858.                 //seg007_3C0C:
  1859.                 int var_costBase = city.getCurrentProduction().getCostBase();
  1860.                
  1861.                 //seg007_3C2A:
  1862.                 int max = 99;
  1863.                 int min = (city.getShieldStock()-1)/100+1;
  1864.                 int val = (var_costBase-1)/10+1;
  1865.                 int var_columns = CivLogic.rangeBound(val, min, max);
  1866.                
  1867.                 var_multi1 = 80 / var_16_min_2xDifficulty;
  1868.                
  1869. //              seg007:3C6A 10C                 mov     ax, [bp+var_16_min_2xDifficulty]
  1870.                 //int ax = var_16_min_2xDifficulty;
  1871. //                      seg007:3C6D 10C                 imul    [bp+var_multi1] ; Signed Multiply
  1872.                 //ax *= var_multi1;
  1873. //                      seg007:3C71 10C                 mov     cx, ax
  1874.                 //int cx = ax;
  1875. //                      seg007:3C73 10C                 mov     ax, [bp+var_42]
  1876.                 //ax = var_42;
  1877. //                      seg007:3C76 10C                 mov     dx, cx
  1878.                 //int dx = cx;
  1879. //                      seg007:3C78 10C                 mov     cl, 3
  1880.                 //cx = 3;
  1881. //                      seg007:3C7A 10C                 shl     ax, cl          ; Shift Logical Left
  1882.                 //ax <<= cx; // *8
  1883. //                      seg007:3C7C 10C                 sub     ax, 8           ; Integer Subtraction
  1884.                 //ax -= 8;
  1885. //                      seg007:3C7F 10C                 mov     cx, dx
  1886.                 //cx = dx;
  1887. //                      seg007:3C81 10C                 cwd                     ; AX -> DX:AX (with sign)
  1888. //                      seg007:3C82 10C                 mov     bx, [bp+var_42]
  1889. //                      seg007:3C85 10C                 idiv    bx              ; Signed Divide
  1890.                 //ax /= var_42;
  1891. //                      seg007:3C87 10C                 add     ax, cx          ; Add
  1892.                 //ax += cx;
  1893. //                      seg007:3C89 10C              
  1894.                 //var_F2 = ax;
  1895.                
  1896.                 var_stockAreaWidth = ((var_columns*8)-8)/var_columns + var_16_min_2xDifficulty*var_multi1;
  1897.  
  1898.                 var_stockAreaHeight = (((var_costBase-1)/var_columns)*8)+8;
  1899.  
  1900.                 gfx.setColor(Palette.defaultColors.get(1));
  1901.                 gfx.fillRect(230, 99, var_stockAreaWidth+3, var_stockAreaHeight+19);
  1902.                
  1903.                 if(cityOwner.equals(gs.player())) {
  1904.                     //seg007_3CD7:
  1905.                     CivDosRenderer.drawPushButton(231, 106, 263, 114, bi, city.has(CityStatus.AUTO_BUILD)?"AUTO.":"CHANGE", Palette.defaultColors.get(9));
  1906.                     CivDosRenderer.drawPushButton(294, 106, 311, 114, bi, "BUY", Palette.defaultColors.get(9));
  1907.                 }
  1908.  
  1909.                 //seg007_3D2F:
  1910.                 if(city.getCurrentProductionID()<28) {
  1911.                     //seg007_3D41:
  1912.                     gfx.drawImage(ImageUtils.getCivUnitIcon(cityOwner.getID(), city.getCurrentProductionID(), false), 264, 100, null);
  1913.                 } else {
  1914.                     //seg007_3D6F:
  1915.                     CivDosRenderer.drawString(FontUtils.truncateStringToPixelLength(city.getCurrentProduction().getListDescription(), 1,  86), gfx, 1, Palette.defaultColors.get(15), 274, 100+6, 100, 1);
  1916.                 }
  1917.                 //seg007_3DBB:
  1918.                 CivDosRenderer.fillRectWithCityPanelBackground(231, 116, var_stockAreaWidth+1, var_stockAreaHeight+1, gfx, 0);
  1919.                
  1920.                 for(var_loopCounter = 0; var_loopCounter<city.getShieldStock() ; var_loopCounter++) {
  1921.                     //seg007_3DF9:
  1922.                     gfx.drawImage(ResourceManager.getSprite("city.resource.shield."),
  1923.                             232+((var_loopCounter%(var_columns*var_16_min_2xDifficulty))*var_multi1)/var_columns,
  1924.                             117+((var_loopCounter/(var_columns*var_16_min_2xDifficulty))<<3),
  1925.                             null);
  1926.                 }
  1927.                 //seg007_3E36:
  1928.                 max = 8;
  1929.                 min = 1;
  1930.                 val = 80 / city.actualSize();
  1931.                 var_multi1 = CivLogic.rangeBound(val, min, max); // food area width in columns
  1932.  
  1933.                 var_stockAreaHeight = 80 / var_16_min_2xDifficulty;
  1934.                 gfx.setColor(Palette.defaultColors.get(1));
  1935.                 gfx.fillRect(2, 106, 91, 12+var_stockAreaHeight*var_16_min_2xDifficulty);
  1936.                
  1937.                 CivDosRenderer.drawString("Food Storage", gfx, 1, Palette.defaultColors.get(15), 8, 6+108);
  1938.                
  1939.                 CivDosRenderer.fillRectWithCityPanelBackground(3, 0x73, 9+var_multi1*city.actualSize(), 2+var_stockAreaHeight*var_16_min_2xDifficulty, gfx, 0);
  1940.                
  1941.                 if(city.has(CityImprovement.GRANARY)) {
  1942.                     //seg007_3EEC:
  1943.                     gfx.setColor(Palette.defaultColors.get(1));
  1944.                     gfx.drawLine(5, 155, 9+var_multi1*city.actualSize(), 155);
  1945.                 }
  1946.                
  1947.                 //seg007_3F19:
  1948.                 for(var_loopCounter = 0;
  1949.                         /*seg007_3F26:*/ var_loopCounter < CivLogic.rangeBound(city.getFoodStock(),0,(city.actualSize()+1)*var_16_min_2xDifficulty);
  1950.                         var_loopCounter++) {
  1951.                     //seg007_3F51:
  1952.                     gfx.drawImage(ResourceManager.getSprite("city.resource.food."),
  1953.                             4+var_multi1*(var_loopCounter%(city.actualSize()+1)),
  1954.                             0x74+var_stockAreaHeight*(var_loopCounter/(city.actualSize()+1)),
  1955.                             null);
  1956.                 }
  1957.                 //seg007_3F90:
  1958.                 CivDosRenderer.drawBlueDialogBackground(2, 23, 124, 65, gfx, false);
  1959.                
  1960.                 var_stockAreaHeight = 25;
  1961.                 gfx.setColor(Palette.defaultColors.get(1));
  1962.                 gfx.fillRect(2,  23,  122,  9);
  1963.                 CivDosRenderer.drawString("City Resources", gfx, 1, Palette.defaultColors.get(15), 8, 6+var_stockAreaHeight);
  1964.                 var_stockAreaHeight += 8;
  1965.                 for(var_improvementTypeID = 0;
  1966.                         //seg007_3FF8:
  1967.                         var_improvementTypeID < 3;
  1968.                         //seg007_3FF4:
  1969.                         var_improvementTypeID ++) {
  1970.                     //seg007_4002:
  1971.                     var_X = 4;
  1972.                     if(var_improvementTypeID == 0) {
  1973.                         //seg007_4012:
  1974. //                      seg007_4012:
  1975. //                          10C mov     ax, 8
  1976.                         int ax = 8;
  1977. //                          10C push    ax              ; C
  1978.                         int arg0 = ax;
  1979. //                          10E mov     ax, 1
  1980.                         ax = 1;
  1981. //                          10E push    ax
  1982.                         int arg1 = ax;
  1983. //                          110 mov     ax, 999
  1984.                         ax = 999;
  1985. //                          110 push    ax              ; C
  1986.                         int arg2 = ax;
  1987. //                          112 mov     ax, 1Ch
  1988. //                          112 imul    [bp+arg_cityID] ; Signed Multiply
  1989. //                          112 mov     bx, ax
  1990. //                          112 mov     al, CityData.ActualSize[bx]
  1991. //                          112 cbw                     ; AL -> AX (with sign)
  1992.                         ax = city.actualSize();
  1993. //                          112 shl     ax, 1           ; Shift Logical Left
  1994.                         ax <<= 1;
  1995. //                          112 mov     cx, ax
  1996.                         int cx = ax;
  1997. //                          112 mov     ax, [bp+var_settlerFoodCost]
  1998.                         ax = var_settlerFoodCost;
  1999. //                          112 imul    dseg_F2E6_settler_counter ; Signed Multiply
  2000.                         ax *= CivLogic.dseg_F2E6_settler_counter;
  2001. //                          112 add     cx, ax          ; Add
  2002.                         cx += ax;
  2003. //                          112 push    cx
  2004.                         int arg3 = cx;
  2005. //                          114 mov     bx, [bp+var_ImprovementTypeID]
  2006. //                          114 shl     bx, 1           ; Shift Logical Left
  2007. //                          114 push    cityFoodProd_dseg_705A[bx] ; __int16
  2008.                         int arg4 = CivLogic.cityFoodProd_dseg_705A;
  2009. //                          116 call    Math_rangeBound_val__min_max ; Call Procedure
  2010.                         ax = CivLogic.rangeBound(arg4, arg3, arg2);
  2011. //                          116 add     sp, 6           ; Add
  2012. //                          110 mov     cx, ax
  2013.                         cx = ax;
  2014. //                          110 inc     cx              ; Increment by 1
  2015.                         cx++;
  2016. //                          110 mov     ax, 74h ; 't'
  2017.                         ax = 0x74;
  2018. //                          110 mov     dx, 0
  2019. //                          110 idiv    cx              ; Signed Divide
  2020.                         ax /= cx;
  2021. //                          110 push    ax              ; __int16
  2022.                         int arg5 = ax;
  2023. //                          112 call    Math_rangeBound_val__min_max ; Call Procedure
  2024.                         ax = CivLogic.rangeBound(arg5, arg1, arg0);
  2025. //                          112 add     sp, 6           ; Add
  2026. //                          10C mov     [bp+var_multi1], ax
  2027.                         var_multi1 = ax;
  2028. //                          10C jmp     seg007_408E     ; Jump                 
  2029.                     } else {
  2030.                         //seg007_4066:
  2031. //                      seg007_4066:
  2032. //                          10C mov     ax, 8
  2033. //                          10C push    ax              ; C
  2034. //                          10E mov     ax, 1
  2035. //                          10E push    ax
  2036. //                          110 mov     ax, 116
  2037. //                          110 mov     dx, 0
  2038. //                          110 mov     bx, [bp+var_ImprovementTypeID]
  2039. //                          110 shl     bx, 1           ; Shift Logical Left
  2040. //                          110 mov     cx, cityFoodProd_dseg_705A[bx]
  2041. //                          110 inc     cx              ; Increment by 1
  2042. //                          110 idiv    cx              ; Signed Divide
  2043. //                          110 push    ax              ; __int16
  2044. //                          112 call    Math_rangeBound_val__min_max ; Call Procedure
  2045. //                          112 add     sp, 6           ; Add
  2046. //                          10C mov     [bp+var_multi1], ax
  2047.                         int resProd = 0;
  2048.                         switch(var_improvementTypeID) {
  2049.                         case 1:
  2050.                             resProd = CivLogic.cityShieldProd_dseg_705C;
  2051.                             break;
  2052.                         case 2:
  2053.                             resProd = CivLogic.cityTradeProd_dseg_705E;
  2054.                             break;
  2055.                         default:
  2056.                             break;
  2057.                         }
  2058.                         var_multi1 = CivLogic.rangeBound(116/(resProd+1), 1, 8);
  2059.                     }
  2060.                     //seg007_408E:
  2061.                     for(var_loopCounter = 0;
  2062.                             //seg007_409B:
  2063.                             var_loopCounter < (var_improvementTypeID == 0?CivLogic.cityFoodProd_dseg_705A:
  2064.                                 var_improvementTypeID == 1?CivLogic.cityShieldProd_dseg_705C:
  2065.                                     CivLogic.cityTradeProd_dseg_705E);
  2066.                             //seg007_4097:
  2067.                             var_loopCounter++) {
  2068.                         //seg007_40AE:
  2069.                         String restr = null;
  2070.                         if(var_improvementTypeID == 0) {
  2071.                             restr = "food";
  2072.                             //seg007_40B8:
  2073.                             if(var_loopCounter == city.actualSize()*2 + var_settlerFoodCost*CivLogic.dseg_F2E6_settler_counter) {
  2074.                                 //seg007_40DB:
  2075.                                 var_X += 4;
  2076.                             }
  2077.                         }
  2078.                         //seg007_40E0:
  2079.                         if(var_improvementTypeID == 1) {
  2080.                             restr = "shield";
  2081.                             //seg007_40EA:
  2082.                             if(CivLogic.dseg_E216_unitShieldMaintenanceCost != 0) {
  2083.                                 //seg007_40F4:
  2084.                                 if(CivLogic.dseg_E216_unitShieldMaintenanceCost == var_loopCounter) {
  2085.                                     //seg007_4100:
  2086.                                     var_X += 4;
  2087.                                 }
  2088.                             }
  2089.                         }
  2090.                         //seg007_4105:
  2091.                         if(var_improvementTypeID == 2) {
  2092.                             restr = "trade";
  2093.                             //seg007_410F:
  2094.                             if(CivLogic.cityTradeProd_dseg_705E - CivLogic.dseg_E200_corruption == var_loopCounter) {
  2095.                                 //seg007_411F:
  2096.                                 var_X += 2;
  2097.                             }
  2098.                         }
  2099.                         //seg007_4124:
  2100.                         BufferedImage resicon = ResourceManager.getSprite("city.resource."+restr+".");
  2101.                         gfx.drawImage(resicon, var_X, var_improvementTypeID*8+var_stockAreaHeight, null);
  2102.                         var_X += var_multi1;
  2103.                     }
  2104.                     //seg007_4150:
  2105.                 }
  2106.                 //seg007_4153:
  2107.                 var_X = 8;
  2108.                 var_multi1 = CivLogic.rangeBound(224 / (CivLogic.cityLuxuryProd_dseg_7060+CivLogic.countCityResearchBulbs_dseg_7066+CivLogic.countCityTaxCollected_dseg_F09A+CivLogic.dseg_E200_corruption+1+1), 1, 16);
  2109.                 var_loopCounter = 0;
  2110.                 //seg007_4195:
  2111.                 while(var_loopCounter<CivLogic.cityLuxuryProd_dseg_7060) {
  2112.                     //seg007_41A1:
  2113.                     gfx.drawImage(ResourceManager.getSprite("city.resource.luxury."), var_X/2, var_stockAreaHeight+0x18, null);
  2114.                     var_X += var_multi1;
  2115.                     //seg007_4191:
  2116.                     var_loopCounter++;
  2117.                 }
  2118.                 //seg007_41CA:
  2119.                 if(CivLogic.cityLuxuryProd_dseg_7060 != 0) {
  2120.                     //seg007_41D4:
  2121.                     var_X += 8;
  2122.                 }
  2123.  
  2124.                 //seg007_41D9:
  2125.                 var_stockAreaWidth = var_X;
  2126.                 var_loopCounter = 0;
  2127.                 //seg007_41EE:
  2128.                 while(var_loopCounter < CivLogic.countCityTaxCollected_dseg_F09A) {
  2129.                     //seg007_41FA:
  2130.                     gfx.drawImage(ResourceManager.getSprite("city.resource.tax."), var_X/2, var_stockAreaHeight+0x18, null);
  2131.                     var_X += var_multi1;
  2132.                     //seg007_41EA:
  2133.                     var_loopCounter++;
  2134.                 }
  2135.                 //seg007_4223:
  2136.                 if(CivLogic.countCityTaxCollected_dseg_F09A != 0) {
  2137.                     //seg007_422D:
  2138.                     var_X += 8;
  2139.                 }
  2140.  
  2141.                 //seg007_4232:
  2142.                 var_loopCounter = 0;
  2143.                 //seg007_423F:
  2144.                 while(var_loopCounter < CivLogic.countCityResearchBulbs_dseg_7066) {
  2145.                     //seg007_424B:
  2146.                     gfx.drawImage(ResourceManager.getSprite("city.resource.science."), var_X/2, var_stockAreaHeight+0x18, null);
  2147.                     var_X += var_multi1;
  2148.                     //seg007_423B:
  2149.                     var_loopCounter++;
  2150.                 }
  2151.                 //seg007_4274:
  2152.                 if(CivLogic.cityFoodProd_dseg_705A < city.actualSize()*2 + var_settlerFoodCost*CivLogic.dseg_F2E6_settler_counter) {
  2153.                     //seg007_4296:
  2154.                     val = 116 / (city.actualSize()*2 + var_settlerFoodCost*CivLogic.dseg_F2E6_settler_counter + 1);
  2155.                     var_multi1 = CivLogic.rangeBound(val, 1, 8);
  2156.                     var_loopCounter = CivLogic.cityFoodProd_dseg_705A;
  2157.                     //seg007_42DD:
  2158.                     while(var_loopCounter < city.actualSize()*2 + var_settlerFoodCost*CivLogic.dseg_F2E6_settler_counter) {
  2159.                         //seg007_4300:
  2160.                         gfx.drawImage(ResourceManager.getSprite("city.resource.food."), 8+var_multi1*var_loopCounter, var_stockAreaHeight, null);
  2161.                         //seg007_42D9:
  2162.                         var_loopCounter++;
  2163.                     }
  2164.                     //seg007_431F:
  2165.                     CivDosRenderer.replaceColor(bi, 8+var_multi1*CivLogic.cityFoodProd_dseg_705A, var_stockAreaHeight, 4+var_multi1*(city.actualSize()*2+CivLogic.dseg_F2E6_settler_counter*var_settlerFoodCost - CivLogic.cityFoodProd_dseg_705A), 8, 15, 0);
  2166.                 }
  2167.                 //seg007_436D:
  2168.                 if(CivLogic.cityShieldProd_dseg_705C < CivLogic.dseg_E216_unitShieldMaintenanceCost) {
  2169.                     //seg007_4379:
  2170.                     var_multi1 = CivLogic.rangeBound(116 / (CivLogic.cityShieldProd_dseg_705C+1), 1, 8);
  2171.                     var_loopCounter = CivLogic.cityShieldProd_dseg_705C;
  2172.                     //seg007_43A9:
  2173.                     while(var_loopCounter < CivLogic.dseg_E216_unitShieldMaintenanceCost) {
  2174.                         //seg007_43B5:
  2175.                         gfx.drawImage(ResourceManager.getSprite("city.resource.shield."), 8+var_multi1*var_loopCounter, var_stockAreaHeight+8, null);
  2176.                         //seg007_43A5:
  2177.                         var_loopCounter++;
  2178.                     }
  2179.                     //seg007_43D8:
  2180.                     CivDosRenderer.replaceColor(bi, 8+var_multi1*CivLogic.cityShieldProd_dseg_705C, 8+var_stockAreaHeight, var_multi1*(CivLogic.dseg_E216_unitShieldMaintenanceCost - CivLogic.cityShieldProd_dseg_705C), 8, 15, 0);
  2181.                 }
  2182.                 //seg007_4410:
  2183.                 if(CivLogic.dseg_E200_corruption != 0) {
  2184.                     //seg007_441A:
  2185.                     var_multi1 = CivLogic.rangeBound(116 / (CivLogic.cityTradeProd_dseg_705E+1), 1, 8);
  2186.                     CivDosRenderer.replaceColor(bi, 6+var_multi1*(CivLogic.cityTradeProd_dseg_705E - CivLogic.dseg_E200_corruption), var_stockAreaHeight + 16, var_multi1 * (CivLogic.dseg_E200_corruption+2), 8, 15, 0);
  2187.                 }
  2188.                 //seg007_4476:
  2189.                 CivDosRenderer.fillRectWithCityPanelBackground(8, 8, 200, 13, gfx, 0);
  2190.                 int var_F0 = CivDosRenderer.drawCitizensInCityScreen(bi, city, 8, 8, var_specialistCount, 192);
  2191.                 var_multi1 = CivLogic.rangeBound(0x18+city.actualSize()*8, 0, 0x80);
  2192.                 var_improvementTypeID = 0;
  2193.                
  2194.                 //seg007_44E2:
  2195.                 while(var_improvementTypeID < 3) {
  2196.                     //seg007_44EC:
  2197.                     SVECity tradeCity = null;
  2198.                     switch(var_improvementTypeID) {
  2199.                     case 0:
  2200.                         tradeCity = city.getTradeCity1();
  2201.                         break;
  2202.                     case 1:
  2203.                         tradeCity = city.getTradeCity2();
  2204.                         break;
  2205.                     case 2:
  2206.                         tradeCity = city.getTradeCity3();
  2207.                         break;
  2208.                     default:
  2209.                         break;
  2210.                     }
  2211.                     if(tradeCity != null && ((SVECity) tradeCity).exists()) {
  2212.                         String str = tradeCity.getName()+":+";
  2213.                         if(cityOwner.equals(tradeCity.owner())) {
  2214.                             //seg007_4591:
  2215.                             str += (city.getBaseTrade() + tradeCity.getBaseTrade() + 4)/16;
  2216.                         } else {
  2217.                             //seg007_4541:
  2218.                             str += (city.getBaseTrade() + tradeCity.getBaseTrade() + 4)/8;
  2219.                         }
  2220.                         //seg007_45DE:
  2221.                         str+= "} ";
  2222.                         if(CivLogic.dseg_2496_cityViewActiveTab == 2) {
  2223.                             //seg007_45F8:
  2224.                             CivDosRenderer.drawPointInCityMap(bi, gs, tradeCity.getLocation().x(), tradeCity.getLocation().y(), 10);
  2225.                         }
  2226.                         //seg007_461A:
  2227.                         if(CivLogic.dseg_2496_cityViewActiveTab == 0) {
  2228.                             //seg007_4624:
  2229.                             CivDosRenderer.drawString(str, gfx, 1, Palette.defaultColors.get(10), 98, 6+ 179+6*var_improvementTypeID);
  2230.                         }
  2231.                     }
  2232.                     //seg007_44DE:
  2233.                     var_improvementTypeID++;
  2234.                 }
  2235.                 //seg007_4646:
  2236.                 if(CivLogic.dseg_2496_cityViewActiveTab == 2) {
  2237.                     //seg007_4650:
  2238.                     CivDosRenderer.drawPointInCityMap(bi, gs, city.getLocation().x(), city.getLocation().y(), 15);
  2239.                 }
  2240.                 //seg007_4673:
  2241.                 if(CivLogic.dseg_2496_cityViewActiveTab == 0) {
  2242.                     //seg007_467D:
  2243.                     int var_pollutionProd = -20 + CivLogic.cityShieldProd_dseg_705C/CivLogic.dseg_6C18_cityPowerType;
  2244.                     var_pollutionProd += (city.actualSize()*CivLogic.pollutionFactor_dseg_C7A2)/4;
  2245.                    
  2246.                     var_stockAreaHeight =
  2247.                             CivLogic.rangeBound(
  2248.                                     100/CivLogic.rangeBound(var_pollutionProd,
  2249.                                             1, 99),
  2250.                                     1, 8);
  2251.                    
  2252.                     var_loopCounter = 0;
  2253.                     //seg007_46F1:
  2254.                     while(var_loopCounter < var_pollutionProd) {
  2255.                         //seg007_46FE:
  2256.                         gfx.drawImage(ResourceManager.getSprite("city.resource.pollution."), 98+var_loopCounter*var_stockAreaHeight, (var_loopCounter&1)+161, null);
  2257.                         //seg007_46ED:
  2258.                         var_loopCounter++;
  2259.                     }
  2260.                 }
  2261.                 //seg007_4728:
  2262.                 if(cityOwner.equals(gs.player()) /*  || Cheat Enabled */ ) {
  2263.                     //seg007_473E:
  2264.                     CivDosRenderer.drawPushButton(284, 190, 316, 198, bi, "EXIT", Palette.defaultColors.get(12));
  2265.                     int var_flag = 0;
  2266.                     if(city.getCurrentProductionID()>27) {
  2267.                         //seg007_4776:
  2268.                         if(city.getCurrentProductionID()>=235) {
  2269.                             //seg007_4788:
  2270.                             if(city.has((CityImprovement) city.getCurrentProduction())) {
  2271.                                 //seg007_47B5:
  2272.                                 var_flag = 1;
  2273.                             }
  2274.                         }
  2275.                     }
  2276.                     //seg007_47BB:
  2277.                     if(city.getCurrentProductionID()<235 && city.getCurrentProductionID()>27) {
  2278.                         //seg007_47CD:
  2279.                         //weird, skipped: cmp     word ptr CityData.Buildings2[bx], -1
  2280.                         //                jge     short seg007_47DF
  2281.                         //                seg007_47DF:            ; Jump if Less or Equal (ZF=1 | SF!=OF)
  2282.                         //                jle     short seg007_47E4
  2283.                         //seg007_47E4:
  2284.                         if(city.getCurrentProductionID()>=232) {
  2285.                             //seg007_47EE:
  2286.                             if(cityOwner.hasLaunchedSpaceShip()) {
  2287.                                 //seg007_4800:
  2288.                                 var_flag = 1;
  2289.                             }
  2290.                         }
  2291.                     }
  2292.                     //seg007_4806:
  2293.                     if((city.getCurrentProductionID()<232 && city.getCurrentProductionID()>27) || city.getCurrentProductionID()<-24) { // Wonders
  2294.                         //seg007_4818:
  2295.                         if(gs.wonder((WonderType) city.getCurrentProduction()).getHostCity()!=null) {
  2296.                             //seg007_4835:
  2297.                             var_flag = 1;
  2298.                         }
  2299.                     }
  2300.                     //seg007_483B:
  2301.                     if((city.getCurrentProductionID()>=0 && city.getCurrentProductionID()<28)) { // Units
  2302.                         //seg007_484D:
  2303.                         if(cityOwner.units().size()>=127) {
  2304.                             //seg007_485D:
  2305.                             var_flag = 1;
  2306.                         }
  2307.                     }
  2308.                     //seg007_4863:
  2309.                     //HERE STARTS THE INTERACTIVE MANAGEMENT OF CITY SCREEN
  2310.                 }
  2311.                 //seg007_5AF1:
  2312.             }
  2313.             //seg007_5B04:
  2314.            
  2315.         }
  2316.  
  2317.        
  2318.         System.out.println("DEBUG: "+city.getName()+" ["+city.getID()+"] has:\r\n"
  2319.                 +"\t"+CivLogic.dseg_F2E6_settler_counter+" settlers\r\n"
  2320.                 +"\t"+CivLogic.cityFoodProd_dseg_705A+" food prod\r\n"
  2321.                 +"\t"+CivLogic.cityShieldProd_dseg_705C+" shield prod\r\n"
  2322.                 +"\t"+CivLogic.cityTradeProd_dseg_705E+" trade prod\r\n"
  2323.                 +"\t"+CivLogic.cityLuxuryProd_dseg_7060+" luxury prod\r\n"
  2324.                 +"\t"+CivLogic.countCityResearchBulbs_dseg_7066+" bulbs\r\n"
  2325.                 +"\t"+CivLogic.countCityTaxCollected_dseg_F09A+" tax\r\n"
  2326.                 +"\t"+CivLogic.dseg_E200_corruption+" corruption\r\n"
  2327.                 );
  2328.         //ImageUtils.animate(bi, city.getName().toUpperCase(), 200);
  2329.         // TODO: end
  2330.     }
  2331.  
  2332.  
  2333. }
Advertisement
Add Comment
Please, Sign In to add comment