Jump to content


Photo

Beregost Crashes Solved!


  • Please log in to reply
48 replies to this topic

#1 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 09 April 2010 - 06:41 AM

After painstaking reversing of the executable, I have solved the problem of random Beregost crashes and corruption of saved games. Funnily enough, the error is actually in the ARE file! (AR3300.ARE for BG1, FW3300.ARE for BG1Tutu, AR6700.ARE for BGT).

In a nutshell, the problem is bad search map coordinates for DOOR3304 impeded points when door is open. The search map is 320 x 320, yet there are points where y > 320. This causes a buffer overflow problem, resulting in heap corruption. The heap corruption causes the symptoms we all see with Beregost crashes.

A fix will be incorporated into a new version of BGT-WeiDU. The coded fix below can be used for BG1 and BG1Tutu, editing the COPY_EXISTING ~filename~ as necessary.

Note that while this should solve the random Beregost crashing, it may not cover all types of Beregost crashes. The most obvious of this case would be mods causing problems with objects/creatures in the area, or mod incompatibility (as we saw with BG2Fixpack: http://www.shsforums...post__p__478775).

Fix will only work on new games or saved games where you have not visited Beregost yet, since the area is saved into the BALDUR.SAV file once you have visited it.

BACKUP ~BeregostFix~

AUTHOR ~Asc64~

BEGIN ~BeregostFix~

//AR3300, FW3300, AR6700 (BG1, BGTutu, BGT)
COPY_EXISTING ~AR6700.ARE~ ~override~
  READ_LONG 0xA4 nDoors
  READ_LONG 0xA8 offDoors
  READ_LONG 0x7C offPoints
  READ_LONG 0x80 nPoints

  SET i = 0

  FOR (i = 0; i < nDoors; i += 1) BEGIN
    READ_ASCII ( %offDoors% + %i% * 0xC8 + 0x20 ) DoorId
    PATCH_IF ( "%DoorId%" STRING_EQUAL "DOOR3304" ) BEGIN
      READ_LONG ( %offDoors% + %i% * 0xC8 + 0x48 ) idxPointsImpededOpen
      READ_SHORT ( %offDoors% + %i% * 0xC8 + 0x4C ) nPointsImpededOpen

      SET j = 0
      FOR (j = %idxPointsImpededOpen%; j < %idxPointsImpededOpen% + %nPointsImpededOpen%; j += 1) BEGIN
        READ_SHORT ( %offPoints% + %j% * 0x4) x
        READ_SHORT ( %offPoints% + %j% * 0x4 + 0x2) y

        PATCH_IF ( x = 243 && y = 326 ) BEGIN
          WRITE_SHORT ( %offPoints% + %j% * 0x4) 233
          WRITE_SHORT ( %offPoints% + %j% * 0x4 + 0x2) 302
        END

        PATCH_IF ( x = 243 && y = 327 ) BEGIN
          WRITE_SHORT ( %offPoints% + %j% * 0x4) 233
          WRITE_SHORT ( %offPoints% + %j% * 0x4 + 0x2) 304
        END

        PATCH_IF ( x = 242 && y = 325 ) BEGIN
          WRITE_SHORT ( %offPoints% + %j% * 0x4) 232
          WRITE_SHORT ( %offPoints% + %j% * 0x4 + 0x2) 304
        END

        PATCH_IF ( x = 233 && y = 303 ) BEGIN
        END

      END
    END
  END

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#2 ScuD

ScuD
  • Member
  • 492 posts

Posted 09 April 2010 - 07:14 AM

I'm in awe... Posted Image

#3 cmorgan

cmorgan
  • Modder
  • 2301 posts

Posted 09 April 2010 - 07:37 AM

This (in my book) is the equivalent of finding Atlantis. Thank you! There is nothing, I repeat NOTHING more frustrating to me than having a white-knuckle moment every time i visit Beregost!

Edited by cmorgan, 09 April 2010 - 07:37 AM.


#4 Daulmakan

Daulmakan

    Comfortably numb

  • Member
  • 1065 posts

Posted 09 April 2010 - 08:26 AM

Posted Image

item_pack.jpg   Drows.jpg

 


#5 Wisp

Wisp
  • Modder
  • 1353 posts

Posted 09 April 2010 - 08:39 AM

Great job!

#6 Hoppy

Hoppy

    Mage Hunter

  • Member
  • 2107 posts

Posted 09 April 2010 - 08:58 AM

Right on!!! :cheers:
?May God defend me from my friends; I can defend myself from my enemies.? - Voltaire

"If you think that a size of the mod indicates an amount of bugs that it introduces and their severity you're totally wrong...
Try not to use next time a load of shitty "super-mega-improving-tweaking-revising" small mods that you have installed and try to meet Wulfgar once again."
- King Diamond


Posted Image The Definitive Guide to Trolls

"Finding food and a place to sleep is your own business. I imagine Paul the Cat should have some fun with you, too" - Potencius in The Darkest Day
"You have been warned, little bastard!" -Khelben to a young <CHARNAME>in Check the Bodies
There are those who will snivel, and offer nothing in return except criticism, meanwhile never lifting a finger to do other than to cut other peoples labor down simply for the fact that they lack the capability to put anything of their own together. -erebusant

#7 KathStoneDog

KathStoneDog
  • Member
  • 4 posts

Posted 09 April 2010 - 11:40 AM

Wow! That is just......... WOW!

Kath Stonedog

#8 Taimon

Taimon
  • Member
  • 387 posts

Posted 09 April 2010 - 11:43 AM

Well done!
I'm glad to see that you haven't given up on the reversing stuff. :)

#9 Fennek

Fennek
  • Member
  • 355 posts

Posted 09 April 2010 - 01:21 PM

You are a true hero. I salute you, Sir Ascension 64! :)

#10 Xicloing

Xicloing
  • Member
  • 76 posts

Posted 09 April 2010 - 03:28 PM

Just Wow. Awesome. :cheers:

#11 Chevalier

Chevalier

    Knight of the Realms

  • Modder
  • 2405 posts

Posted 09 April 2010 - 10:26 PM

:new_thumbs:
:clap:
:cheers:

I Ride for the King!


a.k.a. Chev


#12 Dakk

Dakk
  • Member
  • 398 posts

Posted 10 April 2010 - 12:42 PM

What do you know, the time of wonders is not over :woot:

#13 -Rocko-

-Rocko-
  • Guest

Posted 10 April 2010 - 02:26 PM

If we have a save file where we've already visited Beregost, is there a sure way to avoid this bug?

Thanks!

#14 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 10 April 2010 - 05:08 PM

You can edit Beregost in your BALDUR.SAV file manually with NearInfinity or DLTCEP.
It is probably easier to continue to take precautions around Beregost if you are using a 'vulnerable' saved game, which has been the advice for years.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)


#15 Anomaly

Anomaly
  • Member
  • 562 posts

Posted 13 April 2010 - 01:19 AM

Posted Image
Nothing else to add than praise.
French translator of: BG2 FixPack, BG2 Tweaks, Baldur's Gate Trilogy-WeiDU, BGT-Tweaks and some minor mods.

#16 Lupuss

Lupuss
  • Member
  • 7 posts

Posted 13 April 2010 - 12:16 PM

Hello, I'm curious as to how I should insert the code posted above into the game. Which file(s) should be edited and how?

Thank you for your input.

#17 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 13 April 2010 - 10:21 PM

Hello, I'm curious as to how I should insert the code posted above into the game. Which file(s) should be edited and how?

My advice is that you don't, unless you know what you are doing... but you would do the editing into the Setup-BGT.tp2 file. Or to a complete new setup-*modname*.tp2 and then install it with the setup-*modname*.exe ... just like any other WeiDU.exe mod.

Edited by Jarno Mikkola, 13 April 2010 - 10:24 PM.

Deactivated account. The user today is known as The Imp.


#18 Lupuss

Lupuss
  • Member
  • 7 posts

Posted 14 April 2010 - 12:35 AM

The thing is, I've just installed BG Trilogy along with a bunch of other mods and I'd like to avoid the Beregost bug. I've just started the game so I haven't got to Beregost yet (currently in Friendly Arm's Inn). If there's another way to avoid it I'm all ears (I haven't used DLTCEP in a loooooooooong time, I don't even remember how you edit SAV files with it :/)

#19 Jarno Mikkola

Jarno Mikkola

    The Imp in his pink raincoat.

  • Member
  • 10911 posts

Posted 14 April 2010 - 01:29 AM

If there's another way to avoid it I'm all ears

Them listen, just close the door to the Jovial Juggler when you visit the place, and you can avoid the problem in this version... as he problem only occurs when it's open, and the map is reloaded.

Deactivated account. The user today is known as The Imp.


#20 Ascension64

Ascension64
  • Modder
  • 5983 posts

Posted 14 April 2010 - 01:48 AM

Just to clarify, the crash will still occur regardless of whether you have the door open or closed. The impeded search map coordinate data is loaded regardless...unless you delete the door from the ARE file.

--------------
Retired Modder
Note: I do not respond to profile comments/personal messages in regards to troubleshooting my modifications. Please post on the public forums instead.

Baldur's Gate Trilogy-WeiDU and Mods
Throne of Bhaal Extender (TobEx)

Contributions: (NWN2) A Deathstalker (voice acting) - (IWD2) IWD2 NPC Project (soundset editing) - (Misc) SHS PC Soundsets (voice acting)
Legacy: (BG/Tutu/BGT) Beregost Crash Fixer 1.9 (18 Jul 10) - (BG2) Enable conversations with charmed/dominated creatures (18 Jul 10) - (BG2) Experience Corrections (18 Jul 10) - (Misc) Platform Conversion Utility RC2 (13 Feb 10)