Author Topic: how to fix the most common crash  (Read 2261 times)

0 Members and 1 Guest are viewing this topic.

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
how to fix the most common crash
« on: September 15, 2021, 03:17:06 AM »
I'm one of these mavericks who doesn't play the game with any binary patches.  I use my own .txt mod and that's it.  I have found the GOG stock binary to be pretty stable, to the point that I haven't felt the need for any patches.

That said, I have one recurring crash in the past 2 years, on Windows 10.  It is so predictable, that any time I have a crash, I automatically go looking for it now.  It is the "AI has wrong faction units in some city, then attacks that city" bug.  It generally happens in AI vs. AI play.  You'll be watching the AIs do their moves between your turns, when BOOM! game gone.

It's not that frequent a problem.  I go through many games without any issue.  But the likelihood of this problem occurring, does go up the longer a game goes on.  I was doing a particularly long After Action Report when this bug hit me again.  Of course, I want to finish my AAR, so I had to apply my workaround.  I made a cookbook for it, in the middle of my AAR, which I will repeat here.

Scient's patch doesn't fix this problem.  If it did, I would finally be converted to using it, as it's the only bug I can absolutely count on to occur "sometime".

When I say "the most common crash", I should note in fairness that I never play multiplayer.  Multiplayer might make all kinds of demands on the binary and need all kinds of patches and fixing, for all I know.  I'm just a single player punter.  The game is far too long for me to usually consider playing it with others.  And the few times I have considered, it quickly got lost in the shuffle of my real life pressures.

The GOG binary is pretty darned solid IMO, but this is the crash on Windows 10.  Look for this 1st before considering any other reason.

Earlier versions of Windows 10 had more dodginess IMO.  I think things got a lot more stable in the 19xx era.

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: how to fix the most common crash
« Reply #1 on: September 15, 2021, 03:19:18 AM »
Uh oh, I'm being affected by the infamous "enemy faction in someone's city" bug, I think.  At least, that's the only thing that consistently crashes my games in recent years.  It happens just after the Cult takes over Xi Ellipse from the Cyborgs.  I will have to investigate the turn order and see if I can find the city that's causing it.  I don't think using the Scenario Editor is a big sin at this point, as there's not really any secret information to be had at this point.

Ok, but before I even do that, does my installation of "SMACX AI Growth mod with Scient's Patch" solve the problem?  I just updated it with my latest greatest .txt files.  I've copied the .sav.  Firing it up.  ...Nope, Scient's Patch goes down like a ton 'o' bricks as well.  I'll have to find the guilty city.

the official turn order
the official turn order

Step 1 of fixing this kind of problem is to determine the official turn order.  Since it happens after the Cult takes a base, it's probably either the Cult or the Morganites that have the problem.  If we want to get really extreme about narrowing it down, we can use the Scenario Editor to completely eliminate factions, thereby narrowing the possibilities.  But as I've been down this road many times, I think simple manual searching will probably suffice.  Famous last words.

unfriendly
unfriendly

Cha Dawn is at war with everyone.  So anyone in his bases other than his own troops, is a bug.  It might be helpful to know if alliances changed from last year, but in his case I doubt it.  These relocation bugs can be sleepers for some time before an actual combat event triggers the crash.

varied
varied

Morgan has alliances, treaties, and wars.  I'm not sure that narrows anything down by itself.  It's just information to know, when I'm looking around.

here it is, surely
here it is, surely

That badly wounded Cult mindworm shouldn't be inside Alpha Prime!  Gotta go eat dinner.  Later I'll figure out a way to get rid of it.

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: how to fix the most common crash
« Reply #2 on: September 15, 2021, 03:21:51 AM »
wrong faction unit crashes AI
wrong faction unit crashes AI

This is the source of at least 1 problem.  It's possible to have more than one problem, but this will surely cause a crash.  So, that Cult mindworm has to either be deleted, or changed to a Cyborg mindworm.  Unfortunately my experience with the Scenario Editor is that deleting units inside a city is rather clumsy and coarse.  All units get deleted if you go that route.  So, the less invasive procedure, is to change the ownership of the unit.

Using the Scenario Editor is going to mark my score as "Cheated!"  That's not true, it's the game's damn bug and not my fault, but the anti-cheat mechanism is too stupid to know that.  If I was very determined to protect my score, I'd have to find a way to solve the problem in the game, before it manifests in a crash.  For instance in this particular game, I think one of my allies is at war with the Cyborgs.  In principle I could declare war without harming my Reputation, then take over the base.  In practice, I don't have any units that can reach the base.  Also, having Lal flippantly declare war like that, is rather out of character for the "arch peacemaker" way I'm playing him.  Anyways the point is moot for this game, it doesn't matter.  I'm not playing this game for a score, I'm playing it to demo this version of my mod.

Activate Scenario Editor
Activate Scenario Editor

The 1st step is starting from a saved game before the crash happens, activate the scenario editor.

accept the cheating
accept the cheating

There's nothing you can do about being branded a cheater.  You just have to live with it.  If I knew a way to unflag this in the game's .sav file, I would.  But I don't.

right click on offending unit
right click on offending unit

Right click on the unit that doesn't belong in the base and is causing the crash.  This will bring up a menu.  You know you're in the scenario editor because you've got an option you otherwise wouldn't, called "Edit Unit".

select Edit Unit
select Edit Unit

Select "Edit Unit". 

select PLAYER
select PLAYER

Select PLAYER.  This brings up a menu that shows who owns the unit.  You can use this menu to change the unit's owner.

change it to the base's owner
change it to the base's owner

Change the unit so that it's just another part of the base owner's army.  You might not want to use this technique if the unit is very advanced or very powerful, because it would give an advantage.  However in this case the Cyborgs already know how to make mindworms so it doesn't matter.  Even if it did matter, sometimes you just gotta do what you hafta do.  Wiping out a base full of units just to solve this problem gives someone else an advantage, so this could be the least invasive technique.

the result
the result

Look Ma, no more suspiciously weird inhabitant of the base!  This is probably going to solve the crash, but strictly speaking, we don't yet know if this the only problem.  We do want to save our work for this part of the problem, in case we have more to do.

toggle Activate Scenario Editor
toggle Activate Scenario Editor

You deactivate the Scenario Editor by choosing its menu option again, or using the shortcut key.  You know you're out of the Scenario Editor when the center part of the panel looks normal again, with no terrain editing stuff.  It'll also briefly flash a small message saying you deactivated it.

save game with a different name
save game with a different name

When you save your game, don't just overwrite your old one.  You might want that original problem game for a bug report, or to try to solve the problem without using the editor, or who knows.  I mean, the sky might fall.  I'm optimistically calling this the "fixed" version.  If it isn't, well there's gonna be a lot of name clowning.

Yes, it worked!  I was able to continue my After Action Report.

Offline BFG

Re: how to fix the most common crash
« Reply #3 on: November 09, 2021, 06:36:31 AM »
Hmm...

This is pure speculation - and may reflect my not fully understanding the circumstances since I haven't fired up your savegame yet - but I wonder if the actual crash might be caused by the unit attacking the cell it is already in.  I cannot think of any legitimate game scenario (excepting Missiles, and whether that qualifies as "combat" in the game code is arguable) where a unit can initiate combat against its own cell.  That could cause some sort of an error wherein the game (1) tries to make the unit target itself, (2) is unable to find a valid target, or (3) any number of other weird circumstances depending on how the routine is written.  Again, just speculation.

Of course, the underlying question is - how to prevent it?  I suppose one approach would be to add an instruction to the binary such that, any time a city changes ownership, all units in the city either must belong to the new owner or Pact partners, and all others are either destroyed or change ownership to the conqueror.  I think the binary is supposed to do this, but not sure it always does, particularly in "I will gift you a city if you stop attacking me" and similar such oddball situations.  Another approach, if I'm right in the above speculation, would be to edit the combat initiation code to immediately exit combat (or not allow it to initiate to start with) if a valid target is not found, or if the target is in the same cell as the source.  There probably are simpler options too.

Again, just speculation.  For what it's worth, if I get a break from work and grad school I'll take a look at the savegame.  I don't know squat about editing the SMAC/X binaries but am at least a semi-competent tester. :)
« Last Edit: November 09, 2021, 06:51:38 AM by BFG »

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: how to fix the most common crash
« Reply #4 on: November 10, 2021, 09:13:19 AM »
Attacking one's own square, I suppose it could explain the behavior!

My own operative theory / assumption, is that the presence of an inappropriately allied / treatied unit in a square, somehow crashes the game when someone else makes an attack on it.  I haven't really drilled down to whether the inappropriate unit is the attacker, the defender, or a defending victim of collateral damage.  And it could very well just be something that's messing up a list of units in the city, at the data representation level.

I haven't looked at whether it's about attacking one's own units, either directly or indirectly.

I don't do binary modding, personally.  It's not for lack of skills in principle to do so.  My background was writing OpenGL device drivers for DEC Alpha workstations in assembly code, back in the day.  Having spent a fair amount of time doing ASM for money, I know what development suicide looks like!  I've worked on my mod for 14 full time person months, spread out over 3.5 years.  That was all just taking the low hanging fruit of shuffling things around in alphax.txt and the faction.txt files.  There's that much complexity and scope to a game of this size.

Bug killing, that's Scient's specialty.  There are a few other binary modders, but I think their interest in weapons grade bug killing is incidental.

Offline BFG

Re: how to fix the most common crash
« Reply #5 on: November 13, 2021, 11:48:28 PM »
Still haven't had a chance to fire up your savegame - I'm in the midst of grad school midterms ATM  :-\.  However, do you happen to have a savegame from the turn before the errant Mindworm entered that base (or alternatively, was reassigned to Cult, which seems unlikely outside of a bug)?  Figuring this one out will require not just determining what causes the crash, but also how to prevent it - and knowing how the Mindworm unit ended up there in the first place would help.


The first, most logical circumstance I can think of is that Cult broke a Brotherhood Pact with Cyborgs recently.  That could cause a circumstance where Cha Dawn's units were inside Cyborg bases and didn't get expunged when the Pact was broken.  If that's the case, it's probably a code oversight or error; perhaps the code doesn't (correctly) check the bases of former Pact allies for units that need to be returned or destroyed when a Pact is broken.  If so, I can think of 4 solutions:
(1) Run the same unit check routine that is run when a base changes hands in the Diplomacy window.  That check automatically reassigns ownership of stranded units to the base owner.  The check would need run on every base of both factions.
(2) Remove all stranded units from the game.  Less ideal but may be simpler code-wise.
(3) Return all stranded units to nearest base - similar to the routine that's done when you get the "friendly you're violating my territory" warning in Diplomacy.
(4) Move all units out-of-base.  But there are three problems with this: first, I can't think of anywhere else this is done.  Second, there may not always be valid squares available (land units on a base occupying a single-land-square island, for example.)  Third, they're sitting ducks.


If the above guess is right, this could probably be tested using Scenario Editor and checking the results - i.e. if units are correctly moved/removed upon breaking a Pact.


Come to think of it, I think I've had this exact thing happen to me - I played a game recently where Miriam and I (Zak) were Pact Brothers (yes, really - weird game) and, when she turned on me, her units remained in my bases.  I had no way to attack them except moving my units outside of the base and then firing at the base.  Strangely enough, I waited 20+ turns to do so and never had a crash - the units in question were outclassed by 20:1 or better odds so not surprising she never used them.

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: how to fix the most common crash
« Reply #6 on: November 14, 2021, 09:15:43 AM »
I won't have any more saves for this particular game than I already recorded.  I could try to provide more saves in a future game when I notice the bug again.  I do play with a specially cooked binary from Scient, that autosaves every turn of the game.  However I have to know in advance that I need to dig through them, as they get overwritten from game to game.

Offline BFG

Re: how to fix the most common crash
« Reply #7 on: November 14, 2021, 07:03:54 PM »
That makes sense; I typically only save every 5 turns or so and like you said, unless you know ahead of time it will happen you can’t know to save it. And who knows, that particular unit could have been there 10+ turns before it did anything to cause a crash.

I’ll keep an eye out for the same circumstances, or see if I can force them in Scenario.

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

That sunny dome! Those caves of ice! And all who heard should see them there, And all should cry, Beware! Beware! His flashing eyes, his floating hair! Weave a circle round him thrice, And close your eyes with holy dread, For he on honey-dew hath fed, And drunk the milk of Paradise.
~Samuel Taylor Coleridge, Datalinks

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 5: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default), Aeva.english (default).
Style sheets: 0: .
Files included: 50 - 1568KB. (show)
Queries used: 38.

[Show Queries]