Advertisement
ZoriaRPG

Function Pointer Global Model (Would Be Nice)

Mar 24th, 2019
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. int initfunctions[2048];
  2. int globalfunctions[2048];
  3. int globalfunctionsPostWaitdraw[2048];
  4. int count[3];
  5.  
  6. global script init
  7. {
  8.    
  9.     void addInitFunction(*f)
  10.     {
  11.         initfunctions[count] = f;
  12.         ++count[0];
  13.     }
  14.     void addFunction(*f)
  15.     {
  16.         globalfunctions[count] = f;
  17.         ++count[1];
  18.     }
  19.     void addLateFunction(*f)
  20.     {
  21.         globalfunctionsPostWaitdraw[count] = f;
  22.         ++count[2];
  23.     }
  24.     initfunctions((*void)StartTangoZH);
  25.     initfunctions((*void)StartGhostZH);
  26.     initfunctions((*void)StartMain);
  27.     globalfunctions((*void)Tango_Update1);
  28.     globalfunctions((*void)Ghost_Update1);
  29.     globalfunctions((*void)Main);
  30.     globalfunctionsPostWaitdraw((*void)Tango_Update2);
  31.     globalfunctionsPostWaitdraw((*void)Ghost_Update2);
  32.     globalfunctionsPostWaitdraw((*void)Cleanup);
  33. }
  34.  
  35. global script active
  36. {
  37.     void run()
  38.     {
  39.         for ( int q = 0; q < count[0]; ++q )
  40.         {
  41.             globalfunctions[q];
  42.         }
  43.         while(1)
  44.         {
  45.             for ( int q = 0; q < count[1]; ++q )
  46.             {
  47.                 globalfunctions[q];
  48.             }
  49.             Waitdraw();
  50.             for ( int q = 0; q < count[2]; ++q )
  51.             {
  52.                 globalfunctionsPostWaitdraw[q];
  53.             }
  54.             Waitframe();
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement