Jump to content

I finally got my Gender/Race aware name list mod working :)


SpazmoJones

Recommended Posts

It's available here:

http://www.nexusmods.com/xcom/mods/531

 

Thanks to wghost81 for all your help. Your replies helped steer me in the right direction.

 

I found that whenever I used a conditional command anywhere ( x > y ? : a : b ) it would crash XCom on startup. I wanted to use these as they'd let me avoid if jumps which are rather painful. Anyhow, I got rid of them all and after a lot of trial and error, making lots of very small incremental changes I eventually got the mod working like I intended.

 

To sort out the memory size issues I ended up just using the EXPAND_FUNCTION command in the patcher. I have a fairly good understanding of how the hex code works now but I have a lot to learn still.

 

Cheers

 

Link to comment
Share on other sites

Ternary condition has two skip tokens inside you have to set up correctly to get it to work. Syntax:

45 <Expr(Cond)> <MemSize> <Expr(IfTrue)> <MemSize> <Expr(IfFalse)>
Each MemSize is 2 bytes short integer and is equal to memory size of the following expression. Specifying the wrong value here will cause the game to crash, but if memory serves it usually happens on execution, not on startup. Edited by wghost81
Link to comment
Share on other sites

Ternary condition has two skip tokens inside you have to set up correctly to get it to work. Syntax:

45 <Expr(Cond)> <MemSize> <Expr(IfTrue)> <MemSize> <Expr(IfFalse)>
Each MemSize is 2 bytes short integer and is equal to memory size of the following expression. Specifying the wrong value here will cause the game to crash, but if memory serves it usually happens on execution, not on startup.

 

 

Yep johnnylump helped me with the memsize pointers. The weird thing is my code looked perfect when viewed with UE Explorer but XCom wouldn't start up at all. I presume the IfTrue and IfFalse expressions can be any data type? Are there different versions of hex tokens used to describe variables and functions depending on how they are used?

 

Here's an example that would crash on startup without fail:

 

(This was to be part of the CreateTSoldier function)

 

// kSoldier.strLastName = (iCountry > 0 ? Mid( kSoldier.strLastName, 1 ) : kSoldier.strLastName);


0F // Let
35 96 0F 00 00 99 0F 00 00 00 01 00 E7 B9 00 00  // kSoldier.strLastName

45 // Conditional token "?"
97 // ">"
00 EB B9 00 00 // iCountry
2C 00 // byte 0
16 // end parameters

14 00 // size of true result

7F // Mid function
35 96 0F 00 00 99 0F 00 00 00 01 00 E7 B9 00 00  // kSoldier.strLastName
2C 01 // byte 1

16 // end parameters

// size of false result
10 00 
35 96 0F 00 00 99 0F 00 00 00 01 00 E7 B9 00 00  // kSoldier.strLastName

What's wrong this that?

Edited by SpazmoJones
Link to comment
Share on other sites

Yes, tokens for different data types comparison are different.

Here is the document I created while I was working on hex-to-pseudo-code decompiler for use with patcher. It may seem messy as I made it for myself, but you can find some useful information on tokens there, including data types for different operations.

 

UEE ignores memory sizes, so the code might look well in there but still CTD in game.

 

The problem with this particular code is that skip sizes should be in memory bytes, not serial bytes. Since both expressions contain three object references, their memory size has 3*4=12 more bytes. BTW, null references can be particularly painful here as they are hard to spot (all zeroes), but still have 4 additional bytes of memory size.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...