コード例 #1
0
ファイル: g_main.c プロジェクト: angeld29/TF2003-qvm
int 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 )
{
    ClearGlobals();
    switch ( command )
    {
    case GAME_INIT:
        api_ver = trap_GetApiVersion();
        if ( api_ver < MIN_API_VERSION )
        {
            G_conprintf("Mod requried API_VERSION %d or higher, server have %d\n", MIN_API_VERSION, api_ver);
            return 0;
        }
        if( api_ver >= MIN_API_VERSION && api_ver <= GAME_API_VERSION )
        {
            gamedata.APIversion = api_ver;
        }
        G_InitGame( arg0, arg1 );
        return ( int ) ( &gamedata );

    case GAME_LOADENTS:
        G_SpawnEntitiesFromString();
        return 1;

    case GAME_START_FRAME:
        StartFrame( arg0 );
        return 1;

    case GAME_CLIENT_CONNECT:
        self = PROG_TO_EDICT( g_globalvars.self );
        self->auth_time = g_globalvars.time + 10.0;
        self->isSpectator = arg0?1:0;
        if ( arg0 )
            SpectatorConnect();
        else
            ClientConnect();
        return 1;

    case GAME_PUT_CLIENT_IN_SERVER:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( !arg0 )
            PutClientInServer();
        return 1;

    case GAME_CLIENT_DISCONNECT:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( arg0 )
            SpectatorDisconnect();
        else
            ClientDisconnect();
        return 1;

    case GAME_SETNEWPARMS:
        SetNewParms();
        return 1;

    case GAME_CLIENT_PRETHINK:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( !arg0 )
            PlayerPreThink();
        return 1;

    case GAME_CLIENT_POSTTHINK:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( !arg0 )
            PlayerPostThink();
        else
            SpectatorThink();
        return 1;

    case GAME_EDICT_TOUCH:
        G_EdictTouch();
        return 1;

    case GAME_EDICT_THINK:
        G_EdictThink();
        return 1;

    case GAME_EDICT_BLOCKED:
        G_EdictBlocked();
        return 1;

    case GAME_SETCHANGEPARMS: //called before spawn new server for save client params
        self = PROG_TO_EDICT( g_globalvars.self );
        SetChangeParms();
        return 1;

    case GAME_CLIENT_COMMAND:
        self = PROG_TO_EDICT( g_globalvars.self );
        return ClientCommand();

    case GAME_CLIENT_USERINFO_CHANGED:
        // called on user /cmd setinfo	if value changed
        // return not zero dont allow change
        // params like GAME_CLIENT_COMMAND, but argv(0) always "setinfo" and argc always 3

        self = PROG_TO_EDICT( g_globalvars.self );
        return ClientUserInfoChanged();

    case GAME_SHUTDOWN:
        return 0;

    case GAME_CONSOLE_COMMAND:

        // called on server console command "mod"
        // params like GAME_CLIENT_COMMAND, but argv(0) always "mod"
        // self - rconner if can detect else world
        // other
        //SV_CMD_CONSOLE		0
        //SV_CMD_RCON			1
        //SV_CMD_MASTER		2
        //SV_CMD_BOT			3
        self = PROG_TO_EDICT( g_globalvars.self );
        ModCommand();
        return 0;
    }

    return 0;
}
コード例 #2
0
ファイル: g_main.c プロジェクト: stayoutEE/qwprogs-qvm
/*
================
vmMain

This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
int 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 )
{
	ClearGlobals();
	switch ( command )
	{
	case GAME_INIT:
		if ( trap_GetApiVersion() < GAME_API_VERSION )
			return 0;

		G_InitGame( arg0, arg1 );
		return ( int ) ( &gamedata );

	case GAME_LOADENTS:
		G_SpawnEntitiesFromString();
		return 1;

	case GAME_START_FRAME:
		StartFrame( arg0 );
		return 1;

	case GAME_CLIENT_CONNECT:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( arg0 )
			SpectatorConnect();
		else
			ClientConnect();
		return 1;

	case GAME_PUT_CLIENT_IN_SERVER:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( !arg0 )
			PutClientInServer();
		return 1;

	case GAME_CLIENT_DISCONNECT:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( arg0 )
			SpectatorDisconnect();
		else
			ClientDisconnect();
		return 1;

	case GAME_SETNEWPARMS:
		SetNewParms();
		return 1;

	case GAME_CLIENT_PRETHINK:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( !arg0 )
			PlayerPreThink();
		return 1;

	case GAME_CLIENT_POSTTHINK:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( !arg0 )
			PlayerPostThink();
		else
			SpectatorThink();
		return 1;

	case GAME_EDICT_TOUCH:
		G_EdictTouch();
		return 1;

	case GAME_EDICT_THINK:
		G_EdictThink();
		return 1;

	case GAME_EDICT_BLOCKED:
		G_EdictBlocked();
		return 1;

	case GAME_SETCHANGEPARMS:
		self = PROG_TO_EDICT( g_globalvars.self );
		SetChangeParms();
		return 1;

	case GAME_CLIENT_COMMAND:

		return ClientCommand();

/*	case GAME_SHUTDOWN:
		G_ShutdownGame( arg0 );
		return 0;
	case GAME_CLIENT_USERINFO_CHANGED:
		ClientUserinfoChanged( arg0 );
		return 0;
	case GAME_CONSOLE_COMMAND:
		return ConsoleCommand();*/
	}

	return 0;
}