Not logged inOpenClonk Forum
Up Topic Fixing and improving the power system

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Sven2
Since hostility changes don't happen that often, you can change the engine and add the callback to all objects I guess, then schedule a network update for the next frame if it wasn't scheduled yet (to avoid updating the network n times).

If engine changes are not an option, you can always do a runtime hook:

if (!hostility_change_hooked)
{
  this.Scenario_OnHostilityChanged = Scenario.OnHostilityChanged;
  Scenario.OnHostilityChanged = this.OnHostilityChanged;
  hostility_change_hooked = true;
}

func OnHostilityChanged(...)
{
// your code
// ...
// inherited
  if (this.Scenario_OnHostilityChanged) return Scenario->Call(this.Scenario_OnHostilityChanged, ...);
  return true;
}


Although I'm not really a fan of this. The engine change would probably be easier to understand and maintain.

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill