projectmercy Posted June 21, 2014 Share Posted June 21, 2014 (edited) What is the intention on switch statements in the psuedo code calls? If the labels are a one-to-one offset relationship, how would I use @labels for case offsets? Edit: I flipped through the code and didn't see anything that looked like it'd handle the switch offsets. (as an aside, is there a makefile or project/solution for UPKUtils? Are you just manually compiling and linking it?) I guess my next question is, how do you update virtual size after you're done if you chose AUTO on the object scope to move the function, and went with [REPLACEMENT_CODE] for pure hex? I'm still not exactly sure how to compute virtual size before the function gets parsed correctly in UE Explorerer. If it's parsing it fully, then opening it up and hitting disassembly tokens makes it easy, but it seems like you have to have it working before that works. It's chicken and egg. Putting in 0x00 00 for jump placeholders also seems to throw UE E off. Edited June 21, 2014 by projectmercy Link to comment Share on other sites More sharing options...
wghost81 Posted June 21, 2014 Author Share Posted June 21, 2014 One important thing to remember: pseudo code or not - it is still hex editing. Patcher commands just do some work for you, like automatic offsets calculation, but in the end they produce pure hex code. To fully understand XCOM bytecode, you have to understand upk file format. Pdf document with upk format description can be found at UPKUtils downloads page. Labels are not in the one-to-one relationship. It's like labels and goto statements in C and other programming languages: define one label, then reference it as many times, as you need. Switch example: //switch(iCountry) 05 <.iCountry> 00 00 <.iCountry> //case 1: 0A [@label1] 26 //break 06 [@EndSwitch] //case 24: [#label1] 0A [@label2] 2C 18 //break 06 [@EndSwitch] // default: [#label2] 0A FF FF //break 06 [@EndSwitch] [#EndSwitch] REPLACEMENT_CODE calculates file and memory offsets automatically. To manually change those values, you have to change two integers, located at 0x28 offset relative to function offset. First one is a file size and second is a memory size. UE Explorer tokens view shows file/memory offsets for code lines as (file_offset/memory_offset). Navigate to last statement, which is EOS (53), add 1 to both file and memory offset and you will get file and memory size of a whole script. You can use UE Explorer tokens view to calculate memory offsets for jump values. You can also use online tool for memory offsets recalculations (use forum search to find the appropriate topic) or UPK Modder by Amineri. But, IMO, using REPLACEMENT_CODE with pseudo code and labels is way better than recalculating offsets manually. :wink: Link to comment Share on other sites More sharing options...
Amineri Posted June 21, 2014 Share Posted June 21, 2014 I have to say that I'm quite tempted to implement in UPKmodder something similar to your label construction to make generation of offset simpler. I'd always intended to port in a version of Bertilsson's automatic jump calculator (which calculates what offsets it can and then prompts for the rest), but I pretty much got sidetracked modding and haven't really been doing much UPKmodder updating. Link to comment Share on other sites More sharing options...
Starman001 Posted June 21, 2014 Share Posted June 21, 2014 (edited) Hi all, I'm now quite frustrated, I cannot express how much I hate these 2k people for their still active anti-modding fight. Such a great game with huge potential... Since they already rabatting it out for 10 bucks, active mod support could even get them some more sold copies... :sad: The march-update destroyed my mod (like for most people), even while having it not on update and home phoning, but it was pointed out that some updates still make it through...Since Toolbook is now dead, I don't manage to get my mod together... So I really hope to get some help here. Most of the stuff I'm modding is in the ini-files.... So first I use this : http://wiki.tesnexus.com/index.php/How_to_DIY_common_mod_solutions_-_XCOM:EU_2012#How_to_enable_direct_INI_editingto make the exe reading the ini-files again... Then I'm trying to install the old mods using this new tool here (since it says it reads the same mod files)... However, as soon as I make the first change to an upk-file, the game is broken... Even more funny, I cannot even start it again when restoring the original files I had made a backup... Wtf is going on, why is it not even working again with the original files ? Is there another new protection of some sort ? What I want is are the following features, and I hope you give me a hand : 1) I want the death-ani delay removed (used attached toolbook file) 2) I want more squads... 6 at start, upgradable to 8... For that, I install the older mod that also fixes mission start spawn positions. (used the attached toolbook file) 3) I want larger alien pod sizes, but modified with the "tweak" (I made them a bit smaller than the default mod) I copied the upk-files delivered in the mod, then applied tweak from attachment... It's the mod created from the author of this gui patcher... My used version of this mod is the 1.0EWp1 4) I just want to make that one simple hex change, that allows the item production times from the ini to work againhttp://forums.nexusmods.com/index.php?/topic/1274456-can-someone-pls-give-a-hand-in-adding-timed-production/ Everything else I made in the ini's..... Are there any changes with the last update, or should my files still work...Appearantly the game get's broken with issue 2 or 3... Best outcome is being 1 second in the game main menu, before it crashes back to desktop... Also my old modded backup upk-files aren't working. Game crashes. I don't mind if I have to do the ini-changes again, but I need help creating working upk / exe files... Any help would be appreciated... Edited June 21, 2014 by Starman001 Link to comment Share on other sites More sharing options...
projectmercy Posted June 21, 2014 Share Posted June 21, 2014 I have to say that I'm quite tempted to implement in UPKmodder something similar to your label construction to make generation of offset simpler. I'd always intended to port in a version of Bertilsson's automatic jump calculator (which calculates what offsets it can and then prompts for the rest), but I pretty much got sidetracked modding and haven't really been doing much UPKmodder updating. So far I'm finding UPKUtils to be really handy. It isn't so much that it's not doable the manually computing everything, it's just so much easier with the tool making the two passes over the code, and not having to worry about function memory size is another huge boon. It's definitely made entry into XCOM modding a lot less painful than it otherwise should be. Thank you wghost81 for your effort. I'll check out that PDF. Link to comment Share on other sites More sharing options...
wghost81 Posted June 21, 2014 Author Share Posted June 21, 2014 (edited) Starman001, see http://www.nexusmods.com/xcom/mods/474 and http://www.nexusmods.com/xcom/mods/404 They work for both EU and EW, newest versions. 2 and 4 are implemented in LW, you can ask LW authors if they can help you with that. projectmercy, thanks. Edited June 21, 2014 by wghost81 Link to comment Share on other sites More sharing options...
Starman001 Posted June 21, 2014 Share Posted June 21, 2014 Thank you, these mods look interesting, i give them a try... No help needed for issue 4, it's easy... Just 2 is the problem.... In the beginning it was enough doing it in the ini file, but not anymore... And thank you for your work, contribution and your help. Really appreaciated :) Link to comment Share on other sites More sharing options...
projectmercy Posted June 22, 2014 Share Posted June 22, 2014 I apologize, but I haven't been able to get FIND_CODE to work for me. Here's an example. The change hard-codes the movement on the DLC Characters to 12. UPK_FILE=XComStrategyGame.upkOBJECT=XGFundingCouncil.GiveCustomSoldier:AUTO[FIND_CODE]// Soldier.m_kChar.aStats[1] = CustomSoldier.Aim;0F 1A 26 35 <XComGame.XGTacticalGameCoreNativeBase.TCharacter.aStats> <XComGame.XGTacticalGameCoreNativeBase.TCharacter> 00 01 19 00 <XGFundingCouncil.GiveCustomSoldier.Soldier> 09 00 <XGStrategySoldier.m_kChar> 00 01 <XGStrategySoldier.m_kChar> 35 <XGFundingCouncil.TFundingCouncilRewardSoldier.Aim> <XGFundingCouncil.TFundingCouncilRewardSoldier> 00 00 48 <XGFundingCouncil.GiveCustomSoldier.CustomSoldier> [MODDED_CODE ]// Soldier.m_kChar.aStats[1] = CustomSoldier.Aim;0F 1A 2C 01 35 <XComGame.XGTacticalGameCoreNativeBase.TCharacter.aStats> <XComGame.XGTacticalGameCoreNativeBase.TCharacter> 00 01 19 00 <XGFundingCouncil.GiveCustomSoldier.Soldier> 09 00 <XGStrategySoldier.m_kChar> 00 01 <XGStrategySoldier.m_kChar> 35 <XGFundingCouncil.TFundingCouncilRewardSoldier.Aim> <XGFundingCouncil.TFundingCouncilRewardSoldier> 00 00 48 <XGFundingCouncil.GiveCustomSoldier.CustomSoldier>// Soldier.m_kChar.aStats[3] = 12;0F 1A 2C 03 35 <XComGame.XGTacticalGameCoreNativeBase.TCharacter.aStats> <XComGame.XGTacticalGameCoreNativeBase.TCharacter> 00 01 19 00 <XGFundingCouncil.GiveCustomSoldier.Soldier> 09 00 <XGStrategySoldier.m_kChar> 00 01 <XGStrategySoldier.m_kChar> 2C 0C PatcherGUI logs out: Searching for object named XGFundingCouncil.GiveCustomSoldier ...Object found!Searching for specified data chunk ...Uninstall script saved to D:\mods\XCOM\SoldierBootcamp\mod_test2.txt.uninstall3.txtCan't find specified data!Execution stopped at #5 command named [FIND_CODE].Restoring from backup in D:\mods\XCOM\Tools\PatcherGUI\Backup\1403463647XComStrategyGame.upk restored from backup dirXComStrategyGame.upk.uncompressed_size restored from backup dirRestoring from backup completed successfully As near as I can tell, the FIND_CODE section is a duplicate of what's in the file, just comparing the binary dump from UE Explorer; but it doesn't seem to find it. Note, in this example I manually scoped every variable instead of using the @ or . shortcuts. It didn't help any. Link to comment Share on other sites More sharing options...
wghost81 Posted June 23, 2014 Author Share Posted June 23, 2014 [MODDED_CODE ] Remove space in [MODDED_CODE ]: [MODDED_CODE] Section and key names are case and whitespace sensitive. Patcher actually looks for [MODDED_CODE] as a whole. So no spaces are allowed there. Link to comment Share on other sites More sharing options...
eu3fan Posted June 24, 2014 Share Posted June 24, 2014 By the way, is UKP Patcher now broken? I've had trouble getting it to XSHAPE. See this post. Link to comment Share on other sites More sharing options...
Recommended Posts