• 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] YSI Daily Tips
#37
2021-05-19: Initialisation Order



I?m somewhat loathe to document this, as I know someone will abuse it, but this is the complete order of initialisation callbacks in YSI.? Unfortunately, over the years this has got slowly more complicated with more and more dependencies and restrictions.



Originally it was just either OnGameModeInit or OnFilterScriptInit, but no-one uses the FILTERSCRIPT macro correctly, so OnScriptInit was added, which can detect if the script is a GM or FS; and is called before either of their callbacks.



Then JIT support was added to the code, which requires generating assembly from OnJITInit, but that won?t be called if they aren?t using the JIT plugin.? Thus OnCodeInit was added, which is called from either OnJITInit, OnFilterScriptInit, or OnGameModeInit; whichever comes first. OnCodeInit is harder to use than any other callback because it actually generates the code used by y_hooks and other libraries, thus no advanced YSI features like hook or inline can be used within it.



Then I added caching.? This saves a copy of the mode after all OnCodeInit generation has run, and is called when the mode is loaded from cache, rather than loaded initially.? However, this entire feature was a dead-end and recently removed, thus this callback was also removed.? I don?t normally like removing features as it breaks backwards-compatibility, but this was an exception - it was an awful feature you should avoid.



In addition, there are the lightweight initialisation functions, which can be used in place of OnScriptInit.? PRE_INIT__ and POST_INIT__.? Instead of using hook with a normal init name, these have unique names with a custom declaration (meaning you can make initialisation hooks without needing to include y_hooks):



Quote:

POST_INIT__ CreateGroups()

{

____// Code goes here.

}




The most common example of POST_INIT__ is final*:



Quote:

final Group:gAdmin = Group_Create("Admin 1");




So the full intialisation order is:


  • OnCodeInit - no (very few) YSI features can be used.

  • OnJITInit - with JIT plugin.

  • PRE_INIT__ functions - old final location.

  • OnScriptInit - all scripts.

  • POST_INIT__ functions - new final location.

  • OnFilterScriptInit - filterscripts only.

  • OnGameModeInit - all scripts, no others are called in filterscripts.




* Its actually currently PRE_INIT__, but I?m changing that due to some conflicts, and it making the initialisation actually even more complicated than is listed here.


Messages In This Thread
YSI Daily Tips - by Y_Less - 2021-05-01, 05:25 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 05:40 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 06:59 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 06:59 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 06:59 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:06 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:06 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:06 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:07 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:07 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:08 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:08 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:08 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:09 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:09 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:09 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:09 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:10 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-01, 07:11 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-02, 07:44 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-03, 01:17 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-04, 08:08 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-05, 09:44 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-06, 02:46 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-07, 05:13 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-08, 08:08 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-09, 10:58 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-11, 08:55 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-11, 08:56 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-12, 09:41 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-13, 01:20 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-14, 08:20 PM
RE: YSI Daily Tips - by Y_Less - 2021-05-16, 07:41 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-16, 07:49 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-19, 11:25 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-19, 11:26 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-19, 11:27 AM
RE: YSI Daily Tips - by Y_Less - 2021-05-20, 10:05 AM
RE: YSI Daily Tips - by Y_Less - 2021-06-01, 09:26 AM
RE: YSI Daily Tips - by Y_Less - 2021-06-25, 08:06 PM
RE: YSI Daily Tips - by Y_Less - 2021-11-17, 09:12 PM
RE: YSI Daily Tips - by Y_Less - 2021-11-19, 12:21 AM
RE: YSI Daily Tips - by Y_Less - 2022-12-30, 09:56 PM
RE: YSI Daily Tips - by Y_Less - 2023-01-02, 01:25 AM
RE: YSI Daily Tips - by Y_Less - 2023-01-03, 12:17 AM

Forum Jump: