示例#1
0
/*
================
vmMain

This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {

	switch ( command ) {
	case CG_INIT:
		CG_Init( arg0, arg1, arg2 );
		return 0;
	case CG_SHUTDOWN:
		CG_Shutdown();
		return 0;
	case CG_CONSOLE_COMMAND:
		return CG_ConsoleCommand();
	case CG_DRAW_ACTIVE_FRAME:
		CG_DrawActiveFrame( arg0, arg1, arg2 );
		return 0;
	case CG_CROSSHAIR_PLAYER:
		return CG_CrosshairPlayer();
	case CG_LAST_ATTACKER:
		return CG_LastAttacker();
	case CG_KEY_EVENT:
		CG_KeyEvent(arg0, arg1);
		return 0;
	case CG_MOUSE_EVENT:
		CG_MouseEvent(arg0, arg1);
		return 0;
	case CG_EVENT_HANDLING:
		CG_EventHandling(arg0);
		return 0;
	default:
		CG_Error( "vmMain: unknown command %i", command );
		break;
	}
	return -1;
}
示例#2
0
/*
================
vmMain

This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {

	switch ( command ) {
	case CG_INIT:
		CG_Init( arg0, arg1, arg2, arg3 );
		return 0;
	case CG_SHUTDOWN:
		CG_Shutdown();
		return 0;
	case CG_CONSOLE_COMMAND:
		return CG_ConsoleCommand();
	case CG_DRAW_ACTIVE_FRAME:
		CG_DrawActiveFrame( arg0, arg1, arg2 );
		return 0;
	case CG_DRAW_2D:
		CG_Draw2D( arg0, arg1, arg2 );
		return 0;
	case CG_CROSSHAIR_PLAYER:
		return CG_CrosshairPlayer();
	case CG_LAST_ATTACKER:
		return CG_LastAttacker();
	case CG_KEY_EVENT:
		CG_KeyEvent(arg0, arg1);
		return 0;
	case CG_MOUSE_EVENT:
		CG_MouseEvent(arg0, arg1);
		return 0;
	case CG_EVENT_HANDLING:
		CG_EventHandling(arg0);
		return 0;
	case CG_CENTERPRINT:
		CG_CenterPrint( (const char*)arg0, 200, 10 );
		return 0;
	case CG_LOCATIONPRINT:
		CG_LocationPrint( (const char*)arg0, arg1, arg2, 10 );
		return 0;
	case CG_PARSEMSG:
		CG_ParseCGMessage();
		return 0;
	default:
		CG_Error( "vmMain: unknown command %i", command );
		break;
	}
	return -1;
}
示例#3
0
void VM::VMHandleSyscall(uint32_t id, Util::Reader reader) {
    int major = id >> 16;
    int minor = id & 0xffff;
    if (major == VM::QVM) {
        switch (minor) {
            case CG_STATIC_INIT:
                IPC::HandleMsg<CGameStaticInitMsg>(VM::rootChannel, std::move(reader), [] (int milliseconds) {
                    VM::InitializeProxies(milliseconds);
                    FS::Initialize();
                    srand(time(nullptr));
					cmdBuffer.Init();
                });
                break;

            case CG_INIT:
                IPC::HandleMsg<CGameInitMsg>(VM::rootChannel, std::move(reader), [] (int serverMessageNum, int clientNum, glconfig_t gl, GameStateCSs gamestate) {
                    CG_Init(serverMessageNum, clientNum, gl, gamestate);
                    cmdBuffer.TryFlush();
                });
                break;

            case CG_SHUTDOWN:
                IPC::HandleMsg<CGameShutdownMsg>(VM::rootChannel, std::move(reader), [] {
                    CG_Shutdown();
                });
                break;

			case CG_ROCKET_VM_INIT:
				IPC::HandleMsg<CGameRocketInitMsg>(VM::rootChannel, std::move(reader), [] (glconfig_t gl) {
					CG_Rocket_Init(gl);
				});
				break;

			case CG_ROCKET_FRAME:
				IPC::HandleMsg<CGameRocketFrameMsg>(VM::rootChannel, std::move(reader), [] (cgClientState_t cs) {
					CG_Rocket_Frame(cs);
					cmdBuffer.TryFlush();
				});
				break;

            case CG_DRAW_ACTIVE_FRAME:
                IPC::HandleMsg<CGameDrawActiveFrameMsg>(VM::rootChannel, std::move(reader), [] (int serverTime, bool demoPlayback) {
                    CG_DrawActiveFrame(serverTime, demoPlayback);
                    cmdBuffer.TryFlush();
                });
                break;

            case CG_CROSSHAIR_PLAYER:
                IPC::HandleMsg<CGameCrosshairPlayerMsg>(VM::rootChannel, std::move(reader), [] (int& player) {
                    player = CG_CrosshairPlayer();
                });
                break;

            case CG_KEY_EVENT:
                IPC::HandleMsg<CGameKeyEventMsg>(VM::rootChannel, std::move(reader), [] (int key, bool down) {
                    CG_KeyEvent(key, down);
                    cmdBuffer.TryFlush();
                });
                break;

            case CG_MOUSE_EVENT:
                IPC::HandleMsg<CGameMouseEventMsg>(VM::rootChannel, std::move(reader), [] (int dx, int dy) {
                    CG_MouseEvent(dx, dy);
					cmdBuffer.TryFlush();
                });
                break;

			case CG_MOUSE_POS_EVENT:
				IPC::HandleMsg<CGameMousePosEventMsg>(VM::rootChannel, std::move(reader), [] (int x, int y) {
					CG_MousePosEvent(x, y);
					cmdBuffer.TryFlush();
				});
				break;

			case CG_TEXT_INPUT_EVENT:
				IPC::HandleMsg<CGameTextInptEvent>(VM::rootChannel, std::move(reader), [] (int c) {
					Rocket_ProcessTextInput(c);
					cmdBuffer.TryFlush();
				});
				break;

			case CG_CONSOLE_LINE:
				IPC::HandleMsg<CGameConsoleLineMsg>(VM::rootChannel, std::move(reader), [](std::string str) {
					Rocket_AddConsoleText( str );
					cmdBuffer.TryFlush();
				});
				break;

            default:
                CG_Error("VMMain(): unknown cgame command %i", minor);

        }
    } else if (major < VM::LAST_COMMON_SYSCALL) {
        VM::HandleCommonSyscall(major, minor, std::move(reader), VM::rootChannel);
    } else {
        CG_Error("unhandled VM major syscall number %i", major);
    }
}