Log in

View Full Version : Sometime in last month my extensions stopped processing OOB_MSGTYPE_ENDTURN



SilentRuin
September 26th, 2023, 17:22
For years I've had overrrides for end turn in more than one of my 5E extensions where in the OnInit of the extension I have



OOBManager.registerOOBMsgHandler(OOB_MSGTYPE_ENDTU RN, handleEndTurn);


pointing to my own version of handleEndTurn.

Sometime in the last month they all stopped overriding that message which is located in CORERPG/scripts/manager_combat.lua

Now when I set a debug print in my handleEndTurn it no longer functions.

Before I go to extreme lengths to get my functionality back, I'm wondering what has changed and what I'm not understanding here as this used to work (not sure on month - just since I last played and did not notice it failing to process).

SilentRuin
September 26th, 2023, 17:48
Solved it myself. Evidently the underlying lua magic of when an address is defined (used to be extensions onInit were always last) no longer applies.

Making sure this override occurs after all onInits are done (by using onDesktop) is the only way to override this message reliably now. This probably the only message I've had to override because it had no underlying way to replace the code it was executing which is against my "don't step on others toes" rules - but no way around it in this case. Usually functions like this have way to override the actual function doing the work - but not here. Jumps right into doing stuff I can't have it limited to.




function onDesktopInit()
-- In order to support player controlled NPC end turn we have to override this function for use with new DB NCPowner entry
OOBManager.registerOOBMsgHandler(CombatManager.OOB _MSGTYPE_ENDTURN, handleEndTurn);
end

Moon Wizard
September 26th, 2023, 19:48
Actually, all you need to do is replace CombatManager.handleEndTurn in your onInit.



function onInit()
CombatManager.handleEndTurn = handleEndTurn;
end


The CombatManager already registers the call in the onTabletopInit (which, by the way, should be used instead of defining Interface.onDesktopInit = onDesktopInit; since it doesn't need the extra registration).

Regards,
JPG

SilentRuin
September 26th, 2023, 20:31
Actually, all you need to do is replace CombatManager.handleEndTurn in your onInit.



function onInit()
CombatManager.handleEndTurn = handleEndTurn;
end


The CombatManager already registers the call in the onTabletopInit (which, by the way, should be used instead of defining Interface.onDesktopInit = onDesktopInit; since it doesn't need the extra registration).

Regards,
JPG

Yeah when I first wrote this the handleEndTurn override did not trigger at all and I had to use the message registration as the registration had already occurred (address was not the same?) and for whatever reason it was not picking it up. Now that the registration is happening after my onInit, I realize overriding the function directly would probably work as you say, where it did not way back when. I forgot about the new onTabletopInit, but for now as I've just redelivered and its working I'm going to leave it. Maybe I'll do what I normally do an override the function next time I'm in those extensions.