WeiDUorg / weidu

WeiDU is a program used to develop, distribute and install modifications for games based on the Infinity Engine.
http://www.weidu.org
GNU General Public License v2.0
90 stars 20 forks source link

Mod-breaking regression in commit 18c84e5 #120

Closed Argent77 closed 6 years ago

Argent77 commented 6 years ago

The commit https://github.com/WeiDUorg/weidu/commit/18c84e502f35c235fbff9af574a34e0ac459de0e by @CamDawg seems to prevent EET from installing successfully. It triggers numerous warnings and a fatal error (see logs below).

Warnings:

Copied [EET/temp/patch/cre/BDBEARCA.CRE] to [override/BDBEARCA.CRE]
[EET/temp/patch/cre/BDBEETBH.CRE] loaded, 2944 bytes

CLONE_EFFECT: match_parameter1 = 54318; parameter1 = 14073

WARNING: no effects added to BDBEETBH.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 17399

WARNING: no effects added to BDBEETBH.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 1474

WARNING: no effects added to BDBEETBH.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 14071

WARNING: no effects added to BDBEETBH.CRE
Copied [EET/temp/patch/cre/BDBEETBH.CRE] to [override/BDBEETBH.CRE]
[EET/temp/patch/cre/BDBEETBM.CRE] loaded, 2980 bytes

CLONE_EFFECT: match_parameter1 = 54318; parameter1 = 14073

WARNING: no effects added to BDBEETBM.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 17399

WARNING: no effects added to BDBEETBM.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 1474

WARNING: no effects added to BDBEETBM.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 14071

WARNING: no effects added to BDBEETBM.CRE
Copied [EET/temp/patch/cre/BDBEETBM.CRE] to [override/BDBEETBM.CRE]
[EET/temp/patch/cre/BDBEETBR.CRE] loaded, 2944 bytes

CLONE_EFFECT: match_parameter1 = 54318; parameter1 = 14073

WARNING: no effects added to BDBEETBR.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 17399

WARNING: no effects added to BDBEETBR.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 1474

WARNING: no effects added to BDBEETBR.CRE

CLONE_EFFECT: match_parameter1 = 14674; parameter1 = 14071

WARNING: no effects added to BDBEETBR.CRE

Error:

Copied [EET/temp/patch/cre/BDHYRETH.CRE] to [override/BDHYRETH.CRE]
[EET/temp/patch/cre/BDIDYLET.CRE] loaded, 12120 bytes

DELETE_EFFECT: strref = 14665; headerType = global; del_cnt = 1
ERROR: illegal 2-byte read from offset 3354682 of 12120-byte file EET/temp/patch/cre/BDIDYLET.CRE
ERROR: [EET/temp/patch/cre/BDIDYLET.CRE] -> [override/BDIDYLET.CRE] Patching Failed (COPY) (Failure("EET/temp/patch/cre/BDIDYLET.CRE: read out of bounds"))
Copying 1 file ...
[EET/base/cre/K#FAMKIL.CRE] loaded, 1908 bytes
Copied [EET/base/cre/K#FAMKIL.CRE] to [override/K#FAMKIL.CRE]
[EET/base/cre/K#FAMREM.CRE] loaded, 1908 bytes
Copied [EET/base/cre/K#FAMREM.CRE] to [override/K#FAMREM.CRE]
[EET/base/cre/K#FAMSUM.CRE] loaded, 1908 bytes
Copied [EET/base/cre/K#FAMSUM.CRE] to [override/K#FAMSUM.CRE]
[EET/base/cre/K#TELBGT.CRE] loaded, 1928 bytes
Copied [EET/base/cre/K#TELBGT.CRE] to [override/K#TELBGT.CRE]
Copying and patching 18 files ...
[./override/addy.cre] loaded, 1076 bytes
[./override/andout.cre] loaded, 1076 bytes
Copied [andout.cre] to [override/andout.cre]

ERROR locating resource for 'COPY'
Resource [binkos.cre] not found in KEY file:
    [./chitin.key]
Stopping installation because of error.
Stopping installation because of error.

ERROR Installing [EET core - resource importation], rolling back to previous state
CamDawg commented 6 years ago

Could you send me some of the files it's choking on? The rewrite of the function was supposed to make it universal across the IE file formats by polling the file's version field to determine read/write offsets.

Argent77 commented 6 years ago

The files are apparently the original files from BGEE, copied over to BG2EE and patched internally by the mod. The function calls are only found in macros.tph (CLONE_EFFECT starting at line 891 and DELETE_EFFECT starting at line 862 ). I can't say if the mod applied additional patches internally. The rollback operation prevented me from backing up the files in question.

I've tested EET with both games (BGEE+SoD and BG2EE) at patch level 2.3.67.3 (clean state).

This is the complete EET log with many more warnings (all related to CLONE_EFFECT): SETUP-EET.DEBUG.zip

Argent77 commented 6 years ago

Some of the offsets are incorrectly defined in DELETE_EFFECT and CLONE_EFFECT. CRE V1.0 effects offset is 0x2c4 and count is 0x2c8. Offsets in some of the other CRE blocks don't look right either.

After fixing the CRE V1.0 offsets locally in both functions and making another EET test installation, it finished successfully. No warnings or errors.

FredrikLindgren commented 6 years ago

Unless I missed something, this should be fixed in 906bc52859f0d50b290ef685010b67be37fcbf57.

Argent77 commented 6 years ago

Looks like there is more that needs fixing. EET installs successfully, but a number of patched resources are unreadable because of invalid item and item slot offset values. I have attached the resources in question from EET installations made with WeiDU 244 and latest WeiDU devel version.

Download: eet_diff_resources.zip

Edit: Only DELETE_EFFECT seems to have issues. You can reproduce with this test script:

// For reference
COPY_EXISTING ~abazigal.cre~ ~override~

// Working
PRINT ~Applying CLONE_EFFECT to ABAZIGAL.CRE => ABAZ_CE.CRE~
COPY_EXISTING ~abazigal.cre~ ~override/ABAZ_CE.CRE~
  LPF CLONE_EFFECT
  INT_VAR
    check_globals     = 1
    verbose           = 1
    match_opcode      = 233 // Modify proficiencies
    match_parameter2  = 93  // match PROFICIENCYTWOHANDEDSWORD
    parameter2        = 98  // add new effect with PROFICIENCYSPEAR
  END
BUT_ONLY

// Not working!
PRINT ~Applying DELETE_EFFECT to ABAZIGAL.CRE => ABAZ_DE.CRE~
COPY_EXISTING ~abazigal.cre~ ~override/ABAZ_DE.CRE~
  LPF DELETE_EFFECT
  INT_VAR
    check_globals     = 1
    verbose           = 1
    match_opcode      = 233 // Modify proficiencies
    match_parameter2  = 93  // match PROFICIENCYTWOHANDEDSWORD
  END
BUT_ONLY
FredrikLindgren commented 6 years ago

Thanks for the test case. Fixed in 1423892de3913ec374ef3e4468b752c878f4be12.

Argent77 commented 6 years ago

Thanks. New version produced identical results in EET as with WeiDU 244.