ZoriaRPG icon

Function Pointer Global Model (Would Be Nice)

ZoriaRPG | PRO | 03/24/19 10:49:33 AM UTC | 0 ⭐ | 688 👁️ | Never ⏰ | []
C++ |

1.09 KB

|

None

|

0 👍

/

0 👎

int initfunctions[2048];
int globalfunctions[2048];
int globalfunctionsPostWaitdraw[2048];
int count[3];
 
global script init
{
    
    void addInitFunction(*f)
    {
        initfunctions[count] = f;
        ++count[0];
    }
    void addFunction(*f)
    {
        globalfunctions[count] = f;
        ++count[1];
    }
    void addLateFunction(*f)
    {
        globalfunctionsPostWaitdraw[count] = f;
        ++count[2];
    }
    initfunctions((*void)StartTangoZH);
    initfunctions((*void)StartGhostZH);
    initfunctions((*void)StartMain);
    globalfunctions((*void)Tango_Update1);
    globalfunctions((*void)Ghost_Update1);
    globalfunctions((*void)Main);
    globalfunctionsPostWaitdraw((*void)Tango_Update2);
    globalfunctionsPostWaitdraw((*void)Ghost_Update2);
    globalfunctionsPostWaitdraw((*void)Cleanup);
}
 
global script active
{
    void run()
    {
        for ( int q = 0; q < count[0]; ++q )
        {
            globalfunctions[q];
        }
        while(1)
        {
            for ( int q = 0; q < count[1]; ++q )
            {
                globalfunctions[q];
            }
            Waitdraw();
            for ( int q = 0; q < count[2]; ++q )
            {
                globalfunctionsPostWaitdraw[q];
            }
            Waitframe();
        }
    }
}

Comments