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

Script action IncrementGlobalOnce() compiles incorrectly on PST:EE #110

Closed Argent77 closed 6 years ago

Argent77 commented 6 years ago

The first action of the following script

IF
  True()
THEN
  RESPONSE #100
    IncrementGlobalOnce("MyVar1","GLOBAL","MyVar2","GLOBAL",1)
    IncrementGlobalOnceEx("GLOBALMyVar1","GLOBALMyVar2",1)
END

isn't encoded correctly. The second set of variable scope and name appears to be discarded by the compiler.

The resulting script source after a compile/decompile operation:

IF
  True()
THEN
  RESPONSE #100
    IncrementGlobalOnceEx("MyVar1","GLOBAL",1)
    IncrementGlobalOnceEx("GLOBALMyVar1","GLOBALMyVar2",1)
END

Both actions IncrementGlobalOnce and IncrementGlobalOnceEx should be encoded into identical byte code:

AC
446OB
0 0 0 0 0 0 0 0 0 0 0 0 ""OB
OB
0 0 0 0 0 0 0 0 0 0 0 0 ""OB
OB
0 0 0 0 0 0 0 0 0 0 0 0 ""OB
1 0 0 0 0"GLOBALMyVar1" "GLOBALMyVar2" AC

From PST:EE ACTION.IDS:

446 IncrementGlobalOnce(S:Name1*,S:Area1*,S:Name2*,S:Area2*,I:Val*)
446 IncrementGlobalOnceEx(S:Var1*,S:Var2*,I:Val*)
FredrikLindgren commented 6 years ago

Can you diff PSTEE's IDS file with old PST's one (or post the former)? At least part of the problem is that IncrementGlobalOnce() is no longer action 202. I'm going to have to create a new scripting style for PSTEE, and if I'm doing that, I also want whatever else they've changed.

Argent77 commented 6 years ago

PST:EE uses a bunch of new actions to imitate original PST behavior or handle PSTEE-specific stuff. I have attached the PST:EE action.ids.

Actions 391-393, 395-405, 407 as well as 413 and everything above are currently PST:EE specific.

action.ids.zip

Edit: There are several pending feature requests for porting selected PSTEE script actions and triggers to the other EE games. It would probably make more sense to incorporate the new actions into the EE-specific branch of the compiler.

FredrikLindgren commented 6 years ago

This will be too big for me to have anything ready for 243. Will PST scripts generally even compile on PSTEE? There seems to be a lot of actions that have been outright removed.

Argent77 commented 6 years ago

What else are you planning to fix? Every other script command (action or trigger) seems to work fine already with current WeiDU (242). It's only the script action 446 variant mentioned above that needs fixing atm.

The PSTEE engine is basically an extension of the EE engine. I think it is safe to assume that features added to PSTEE will not interfere with nor override features from the other EE games. PST is not directly compatible with PSTEE. However, each PST-specific trait can be reproduced with the available set of PSTEE features.

FredrikLindgren commented 6 years ago

The PSTEE engine is basically an extension of the EE engine. I think it is safe to assume that features added to PSTEE will not interfere with nor override features from the other EE games.

Okay, so that's how it is. This should be easy in that case. I just need to add opcode 446 to the list opcodes that should have string operands (de-)concatenated for the BG2 scripting style. Sorry for the confusion.

Edit: actually, no, this will not be easy after all. IncrementGlobalOnce() and IncrementGlobalOnceEx() share an opcode, but one should be concatenated and the other should not be. Back to potentially not having something for this in time for 243.

FredrikLindgren commented 6 years ago

Fixed.