Skip to content

Commit

Permalink
Several fixes around auto-colonization and loading a save
Browse files Browse the repository at this point in the history
- The game should no longer crash if a target planet "disappeared" when
targeted by colonization.
- The colonizers should no longer move choppily towards a colonization
target.
- The game should properly reload each player's known visible/name
planet set.

Fixes #1073
  • Loading branch information
akarnokd committed Feb 1, 2023
1 parent 09045a6 commit b15d13f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 31 deletions.
Binary file added install/open-ig-0.95.235.jar
Binary file not shown.
26 changes: 13 additions & 13 deletions open-ig-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<comment>Open Imperium Galactica Configuration</comment>
<entry key="fileName">open-ig-config.xml</entry>
<entry key="tileCacheBuildingLimit">10</entry>
<entry key="researchMoneyPercent">1000</entry>
<entry key="researchMoneyPercent">2000</entry>
<entry key="language">en</entry>
<entry key="videoVolume">100</entry>
<entry key="videoVolume">80</entry>
<entry key="showBuildingName">true</entry>
<entry key="continuousMoney">false</entry>
<entry key="tileCacheBaseLimit">-10</entry>
Expand All @@ -16,28 +16,28 @@
<entry key="height">822</entry>
<entry key="muteMusic">true</entry>
<entry key="reequipTanks">true</entry>
<entry key="timestep">10</entry>
<entry key="scaleAllScreens">false</entry>
<entry key="timestep">20</entry>
<entry key="scaleAllScreens">true</entry>
<entry key="aiGroundAttackMixed">true</entry>
<entry key="showStarmapScroll">true</entry>
<entry key="maximized">false</entry>
<entry key="classicControls">false</entry>
<entry key="allowWeather">false</entry>
<entry key="classicControls">true</entry>
<entry key="allowWeather">true</entry>
<entry key="fullScreen">false</entry>
<entry key="uiScale">100</entry>
<entry key="hostUPnP">false</entry>
<entry key="useStandardFonts">false</entry>
<entry key="spacewarDiminishingAttach">true</entry>
<entry key="left">585</entry>
<entry key="left">390</entry>
<entry key="aiAllowBuildingUpgrades">false</entry>
<entry key="tileCacheSize">0</entry>
<entry key="autoBuildLimit">20000</entry>
<entry key="autoBuildLimit">0</entry>
<entry key="movieScale">true</entry>
<entry key="currentProfile">default</entry>
<entry key="joinPort">13951</entry>
<entry key="autoRepair">true</entry>
<entry key="musicVolume">100</entry>
<entry key="satelliteDeploy">false</entry>
<entry key="musicVolume">85</entry>
<entry key="satelliteDeploy">true</entry>
<entry key="animateInventory">true</entry>
<entry key="showStarmapMinimap">true</entry>
<entry key="buttonSounds">true</entry>
Expand All @@ -49,14 +49,14 @@
<entry key="joinPorts-count">0</entry>
<entry key="slowOnEnemyAttack">true</entry>
<entry key="showStarmapInfo">true</entry>
<entry key="top">48</entry>
<entry key="top">87</entry>
<entry key="showStarmapLists">true</entry>
<entry key="radarUnion">true</entry>
<entry key="aiGroundAttackEverything">true</entry>
<entry key="targetSpecificRockets">false</entry>
<entry key="hostPort">13951</entry>
<entry key="subtitles">true</entry>
<entry key="effectVolume">100</entry>
<entry key="effectVolume">70</entry>
<entry key="reequipBombs">true</entry>
<entry key="autoBuildEconomyFirst">true</entry>
<entry key="quickRNP">true</entry>
Expand All @@ -68,7 +68,7 @@
<entry key="movieClickSkip">true</entry>
<entry key="joinAddresses-count">0</entry>
<entry key="dayNightCycle">true</entry>
<entry key="aiAutoBuildProduction">true</entry>
<entry key="aiAutoBuildProduction">false</entry>
<entry key="computerVoiceNotify">true</entry>
<entry key="aiGroundAttackGetCloser">true</entry>
<entry key="swapMouseButtons">false</entry>
Expand Down
28 changes: 23 additions & 5 deletions src/hu/openig/mechanics/ColonizationPlanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ void colonizeWithExistingFleets() {
List<String> cts = new ArrayList<>(world.colonizationTargets);
List<String> remaining = new ArrayList<>();
for (final String p : cts) {
if (world.planetMap.get(p).owner == null) {
AIPlanet aip = world.planetMap.get(p);
if (aip != null && aip.owner == null) {
boolean targeted = false;
for (AIFleet f : fleets) {
if (f.targetPlanet != null && f.targetPlanet.id.equals(p) && f.task == FleetTask.COLONIZE) {
Expand All @@ -140,6 +141,7 @@ void colonizeWithExistingFleets() {
add(new Action0() {
@Override
public void invoke() {
log("ColonizationPlanner, Lost sight of planet " + p);
ColonizationPlanner.this.p.colonizationTargets.remove(p);
}
});
Expand Down Expand Up @@ -184,7 +186,7 @@ void planExplicitConquest() {
for (String ct : world.colonizationTargets) {
AIPlanet p = world.planetMap.get(ct);
// check if not owned or lost track
if (p.owner != null || p.knowledge.compareTo(PlanetKnowledge.OWNER) < 0) {
if (p == null || p.owner != null || p.knowledge.compareTo(PlanetKnowledge.OWNER) < 0) {
continue;
}
// check if not target of one of our fleets
Expand Down Expand Up @@ -286,14 +288,30 @@ void cancelColonizersIfNecessary() {
for (final AIFleet fleet : colonizers) {
if (fleet.targetPlanet != null) {
AIPlanet pl = world.planetMap.get(fleet.targetPlanet);
if (pl == null || pl.owner != null || pl.knowledge.compareTo(PlanetKnowledge.OWNER) < 0
|| (explicitMode && !world.colonizationTargets.contains(pl.planet.id))) {
boolean cancel = false;
String reasonStr = "";
if (pl == null) {
cancel = true;
reasonStr = "Planet not found";
} else if (pl.owner != null) {
cancel = true;
reasonStr = "Planet already colonized by " + pl.owner.name;
} else if (!explicitMode && pl.knowledge.compareTo(PlanetKnowledge.OWNER) < 0) {
cancel = true;
reasonStr = "Lost sight of owner (implicit mode)";
} else if (explicitMode && !world.colonizationTargets.contains(pl.planet.id)) {
cancel = true;
reasonStr = "Player cancelled";
}
if (cancel) {
final String fReasonStr = reasonStr;
// stop the fleet
add(new Action0() {
@Override
public void invoke() {
String targetPlanet = fleet.fleet.targetPlanet() != null ? fleet.fleet.targetPlanet().name() : "?";
log("CancelColonization, Fleet = %s (%d), Planet = %s", fleet.fleet.name(), fleet.fleet.id, targetPlanet);
log("CancelColonization, Fleet = %s (%d), Planet = %s, Reason = %s",
fleet.fleet.name(), fleet.fleet.id, targetPlanet, fReasonStr);
fleet.fleet.stop();
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/hu/openig/model/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class Configuration {
/** The version string. */
public static final String VERSION = "0.95.234";
public static final String VERSION = "0.95.235";
/** Annotation for indicating load/save a field. */
@Retention(RetentionPolicy.RUNTIME)
@interface LoadSave { }
Expand Down
21 changes: 11 additions & 10 deletions src/hu/openig/model/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,16 @@ public void loadState(XElement xworld) {

}

Set<String> allPlanets = new HashSet<>(planets.keySet());
for (String rest : allPlanets) {
Planet p = planets.get(rest);
Player lo = p.owner;
p.die();
if (lo != null) {
lo.planets.remove(p);
}
}

for (XElement xplayer : xworld.childrenWithName("player")) {
Player p = players.get(xplayer.get("id"));
// clear player variables
Expand Down Expand Up @@ -1774,19 +1784,14 @@ public void loadState(XElement xworld) {
}
}
}
Set<String> allPlanets = new HashSet<>(planets.keySet());

for (XElement xplanet : xworld.childrenWithName("planet")) {
String pid = xplanet.get("id");
Planet p = planets.get(pid);
if (p == null) {
System.out.println("Unknown planet: " + pid);
continue;
}
Player lo = p.owner;
p.die();
if (lo != null) {
lo.planets.remove(p);
}

if (xplanet.has("x") && xplanet.has("y") && xplanet.has("size")) {
p.x = xplanet.getInt("x");
Expand Down Expand Up @@ -1884,10 +1889,6 @@ public void loadState(XElement xworld) {

allPlanets.remove(p.id);
}
for (String rest : allPlanets) {
Planet p = planets.get(rest);
p.die();
}
for (Map.Entry<Player, XElement[]> e : deferredMessages.entrySet()) {
if (e.getValue()[0] != null) {
e.getKey().messageQueue.clear();
Expand Down
9 changes: 7 additions & 2 deletions update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<desc lang='en'>The launcher&#39;s main file</desc>
</file>
</module>
<module id='Game' version='0.95.234'>
<module id='Game' version='0.95.235'>
<general url='https://github.com/akarnokd/open-ig'>
<desc lang='hu'>
Az Open Imperium Galactica játék.
Expand All @@ -42,6 +42,11 @@
<desc lang='es'>Bugfixes</desc>
</notes>
<release-details>
<entry version='0.95.235' date='2023-02-01'>
<item category='Stability' issues='1073'>The game should no longer crash if a target planet "disappeared" when targeted by colonization.</item>
<item category='Game Logic' issues='1073'>The colonizers should no longer move choppily towards a colonization target.</item>
<item category='Saves' issues='1073'>The game should now properly reload each player's known visible/named planet set.</item>
</entry>
<entry version='0.95.234' date='2023-02-01'>
<item category='Groundwar,Grapics' issues='1070'>Vehicles no longer appear as if they are behind/obscured by a surface feature that was paved over.</item>
</entry>
Expand Down Expand Up @@ -227,7 +232,7 @@
<item category='AI'>Fixed AI unable to build a power plant if the missing energy was above the capacity of available power plant types.</item>
</entry>
</release-details>
<file url='https://github.com/akarnokd/open-ig/raw/master/install/open-ig-0.95.234.jar' sha1='17BEC7E879B649D70E3F73ADAFD6CB55C9AA55FF'/>
<file url='https://github.com/akarnokd/open-ig/raw/master/install/open-ig-0.95.235.jar' sha1='A8C4E0860A884D473CD39B9B0D9519C9616850B2'/>
<file url='https://github.com/akarnokd/open-ig/raw/master/install/open-ig-upgrade-20220207a2.zip' sha1='A4C922A3FC997D1EA7A5FE3FCD4660EE671A3E25'/>
<file url='https://github.com/akarnokd/open-ig/raw/master/install/open-ig-images-20220130a.zip' sha1='321893422AA0E9D00B745A6D9814C1391D2FFAC9'/>
<file url='https://github.com/akarnokd/open-ig/raw/master/open-ig-splash.png' sha1='52b83dbe118575c7dd3dd6c8c41d0446c32dee45'/>
Expand Down

0 comments on commit b15d13f

Please sign in to comment.