davidlallen Posted February 18, 2016 Share Posted February 18, 2016 (edited) A lot of the uc classes use private variables, and then a class function refers to the variable. It seems that this coding style makes it impossible to replace the function. Is there some other approach we can use? Suppose the original file W.uc is: class W extends X;var private Y;function Z { ... something with Y } This attempted new code fails to compile because a subclass cannot refer to a private variable: class myW extends W;function Z { ... something new with Y } I could try replacing the entire class: class myW extends X;var private Y;function Z { ... something new with Y } This compiles OK. Then I add this line into XcomEngine.ini:+ModClassOverrides=(BaseGameClass="W", ModClass="myW") But, when I run this, myW is ignored, and the original unmodified W is used. I have run around this circle a few times without getting anywhere. Are these functions unmoddable? The details of my actual mod replacement are here: http://forums.nexusmods.com/index.php?/topic/3802360-better-implementation-of-all-armor-options/&do=findComment&comment=34606180 Any help would be greatly appreciated. Edited February 18, 2016 by davidlallen Link to comment Share on other sites More sharing options...
hairlessorphan Posted February 18, 2016 Share Posted February 18, 2016 (edited) If it's private, you'll have to override the class. There are two things to check if the override isn't working. One is any class dependencies need to be declared in your override. So if the original class has a dependson(SomeOtherThing), your override needs to also have a dependson(SomeOtherThing). If it has a config(SomeIni), then yours also needs to have that config(SomeIni). Two is the .ini needs to have a [Engine.Engine] header over it in the XComEngine.ini entry. If you can override it, it's as simple as adding a getter function (or make that variable not private, that will work, too). Scratch that line, it's untrue. Har har, confusing myself. If you can override it, you can re-declare your own private y and use it in your functions. What class are you looking at trying to override? I can try to take a look if these two things still aren't working. Edited February 18, 2016 by hairlessorphan Link to comment Share on other sites More sharing options...
davidlallen Posted February 18, 2016 Author Share Posted February 18, 2016 That may have been it. I didn't think I had to copy the config(SomeIni). Now it is working! Thanks a million. The classes I am trying to override are from the thread I quoted before, basically fixing a bug in the All Armor Options mod. (I am not the author but it's a cool idea.) Link to comment Share on other sites More sharing options...
TeamDragonpunk Posted February 18, 2016 Share Posted February 18, 2016 Wow, this scared me, and I'm glad you resolved it. This is a huge problem in Java and has to be resolved through the constructor and interfaces (in Java). -Dan Link to comment Share on other sites More sharing options...
Recommended Posts