projectmercy Posted April 6, 2015 Share Posted April 6, 2015 Nice tip. Added to "Hex editing UPK files" article. -Dubious- Yeah, I second that. I hadn't thought about it. Clearly I'm too far away from my GOTO days. Thanks for the tip. Link to comment Share on other sites More sharing options...
SpazmoJones Posted April 15, 2015 Share Posted April 15, 2015 Hey I think I've just found a bug. I'm using PatcherGUI 7.1 It looks like putting a "//" inside a %t text literal causes strange things to happen. e.g.: 1f <%t "<img src='img://LongWar.ClassIcons.sniper' height='16' width='16'>: "> This code: 0f 35 <UISoldierListBase.UISoldierOption.strName> <@UISoldierOption> 00 00 10 2c 00 01 <@m_arrUIOptions> //m_arrUIOptions[0].strName = 70 70 // concat 35 <UISoldierListBase.UISoldierOption.strName> <@UISoldierOption> 00 00 10 2c 00 01 <@m_arrUIOptions> 70 // concat 1f <%t " <font color='#ffd800' size='14'>"> // sniper color 70 1f <%t "<img src='img://LongWar.ClassIcons.sniper' height='16' width='16'>: "> /* 70 1A 24 <%b 11> 12 20 <Class.XGLocalizedData> [@] <XGLocalizedData.SoldierClassNames> 00 ( 02 <XGLocalizedData.SoldierClassNames> ) 1f <%t ": "> 16 */ 38 53 00 <.numAvailableSoldiers> // string(numAvailableSoldiers) 16 16 16 1f <%t "</font>"> 16 After patching, UE Explorer decodes as follows, which is a bit of a mess: m_arrUIOptions[0].strName = (m_arrUIOptions[0].strName $ (" <font color='#ffd800' size='14'>" $ ("<img src='img:\\n\\t\\t \\n\\n\\t\\t 38 53 00 <.numAvailableSoldiers> \\n\\t\\t16\\n\\t16\\n16\\n1f <%t \\"</font>" $ )))) $ numAvailableSoldiers = numAvailableSoldiers + ((m_arrUIOptions[I].iClass == 21) ? 1 : 0); I'm working around this for now by using hex bytes for the img:// bit Link to comment Share on other sites More sharing options...
wghost81 Posted April 16, 2015 Author Share Posted April 16, 2015 Yes, // is most probably treated as a comment, so the end of the line is removed and all the code up to the next text token ends up treated as a text. I tried to do without escape characters, but it's getting increasingly hard as mods are getting increasingly complex. :) I'll think of something, so stay tuned. ;) Link to comment Share on other sites More sharing options...
SpazmoJones Posted April 16, 2015 Share Posted April 16, 2015 Yes, // is most probably treated as a comment, so the end of the line is removed and all the code up to the next text token ends up treated as a text. I tried to do without escape characters, but it's getting increasingly hard as mods are getting increasingly complex. :smile: I'll think of something, so stay tuned. :wink: Hey I'm sure you'll figure it out. Anyway, thanks for making such an awesome tool. The HexToPseudoCode utility and the support for labels so that jump offsets are calculated automatically is just fantastic. I had a lot of trouble handling jumps with the first few mods I did and it's soooo much easier and quicker to develop complex mods now. Link to comment Share on other sites More sharing options...
wghost81 Posted April 17, 2015 Author Share Posted April 17, 2015 (edited) Well, it looks like it was figured out long before me. :smile: I was thinking and I can't think of anything better than good old escape characters to guard special symbols. It'll make some of the older mods incompatible, but it should eliminate all the problems. I believe guarding inner " characters with backslash symbol will be enough. And of course, the backslash itself should also be guarded: "\"" and "\\". Edited April 17, 2015 by wghost81 Link to comment Share on other sites More sharing options...
tracktwo Posted May 24, 2015 Share Posted May 24, 2015 @WGhost81: Quick bug report with upkutils73-1.7. It fails to patch a program containing the replacement pseudocode <%t "//">. It works fine if I replace it with the hex string 2F 2F 00. The error context is: Bad token: <%t " [#label_0x07B8] A3 00 <.I> 16 06 [@label_0x06A9] [#label_0x07C6] 1B <AS_UpdateBlips> 00 <.Data> 16 04 0B 53 Link to comment Share on other sites More sharing options...
dip0 Posted May 24, 2015 Share Posted May 24, 2015 So as someone who has never used this before and has limited HEX editing experience, how exactly do I use UPKUtils? I want to find and change the time it takes to do genetic modifications and build interceptors (not firestorm, thats in default core) but reading the readme and the wiki entries just left me really confused... Ideally I want to create a text file like other mods do and then apply it using patchgui Link to comment Share on other sites More sharing options...
tracktwo Posted May 25, 2015 Share Posted May 25, 2015 UPKUtils is a collection of utilities for modifying .upk files, and are what PatcherGUI uses under the covers to actually apply the changes in the modfile to your .upk file. Creating the text file is the tricky bit. :) The approach I usually take is to poke around in UE Explorer searching for likely strings in XComGame.upk or XComStrategyGame.upk (depending on whether it's a tactical or strategic layer thing I want to change) to try to find the function(s) that do the thing I want to change. One I find the function of interest I need to figure out if I can modify it to do what I want - can I picture writing the code to actually make the changes I need. Then, use HexToPseudoCode (one of the UPKutils utilities) to dump a template patch file for that function. You give it the function you want to modify and the .upk file it lives in and it dumps out a modfile that would replace that function with an exact copy of itself. It's great as a starting point. Then, make changes to that modfile by writing in the new hex by hand. This requires a pretty detailed knowledge of the unrealscript bytecode format, which you can get from the wiki articles. Apply the modfile and test it out in game. Then go back and scratch your head when (not if) it doesn't work and try figure out what you did wrong. Repeat until it works or you give up :) That probably sounds awfully scary, but some mods are much simpler than others. E.g. just changing some values like timing constants should be *much* simpler than trying to write all new logic into a function. The process is the same: find the function that does it, dump out the template, then find the appropriate constant in the resulting modfile and change it to the value you want. Then apply with patcherGUI and see if it worked. Good luck! Link to comment Share on other sites More sharing options...
wghost81 Posted May 25, 2015 Author Share Posted May 25, 2015 tracktwo, thanks. I still haven't got around to implement escape characters for strings, that's why this one isn't working. Text after // is considered a comment and the rest of the line gets ignored. Strings in patcher are very simple entities, so while I'm working on a new version with escape characters using hex equivalent is a best solution for this type of bugs. Link to comment Share on other sites More sharing options...
tracktwo Posted May 25, 2015 Share Posted May 25, 2015 (edited) wghost81, ah makes sense. I didn't even notice that was the same as a start of a comment. I'm used to languages where string literals are resolved before comments, so it wouldn't be considered a comment in that context (e.g. like in c/c++). It only came up because it exists in the .upk and HexToPseudoCode created the string literal that patchupk can't read. Took me a little while to figure out what was going on. :smile: Edited May 25, 2015 by tracktwo Link to comment Share on other sites More sharing options...
Recommended Posts