예제 #1
0
/*
=================
GetGameAPI

Returns a pointer to the structure with all entry points and global variables
=================
*/
game_export_t *GetGameAPI (game_import_t *import)
{
	gi = *import;

	globals.apiversion = GAME_API_VERSION;
	globals.Init = InitGame;
	globals.Shutdown = ShutdownGame;
	globals.SpawnEntities = SpawnEntities;

	globals.WriteGame = WriteGame;
	globals.ReadGame = ReadGame;
	globals.WriteLevel = WriteLevel;
	globals.ReadLevel = ReadLevel;

	globals.ClientThink = ClientThink;
	globals.ClientConnect = ClientConnect;
	globals.ClientUserinfoChanged = ClientUserinfoChanged;
	globals.ClientDisconnect = ClientDisconnect;
	globals.ClientBegin = ClientBegin;
	globals.ClientCommand = ClientCommand;

	globals.RunFrame = G_RunFrame;

	globals.ServerCommand = ServerCommand;

	globals.edict_size = sizeof(edict_t);

	gl_driver = gi.cvar("gl_driver", "", 0);
	vid_ref = gi.cvar("vid_ref", "", 0);
	gl_driver_fog = gi.cvar("gl_driver_fog", "opengl32", CVAR_NOSET | CVAR_ARCHIVE);

	Fog_Init();

	developer = gi.cvar("developer", "0", CVAR_SERVERINFO);
	readout = gi.cvar("readout", "0", CVAR_SERVERINFO);

	if (readout->value)
	{
		max_modelindex = 0;
		max_soundindex = 0;
		RealFunc.modelindex = gi.modelindex;
		gi.modelindex = Debug_Modelindex;
		RealFunc.soundindex = gi.soundindex;
		gi.soundindex = Debug_Soundindex;
	}

	return &globals;
}
예제 #2
0
EXPORT game_export_t *GetGameAPI (game_import_t *import)
{
	gi = *import;
    
#ifdef Q2VR_ENGINE_MOD
	globals.apiversion = GAME_API_VERSION;
#else
    globals.apiversion = LEGACY_API_VERSION;
#endif
    
	globals.Init = InitGame;
	globals.Shutdown = ShutdownGame;
	globals.SpawnEntities = SpawnEntities;

	globals.WriteGame = WriteGame;
	globals.ReadGame = ReadGame;
	globals.WriteLevel = WriteLevel;
	globals.ReadLevel = ReadLevel;

	globals.ClientThink = ClientThink;
	globals.ClientConnect = ClientConnect;
	globals.ClientUserinfoChanged = ClientUserinfoChanged;
	globals.ClientDisconnect = ClientDisconnect;
	globals.ClientBegin = ClientBegin;
	globals.ClientCommand = ClientCommand;

	globals.RunFrame = G_RunFrame;

	globals.ServerCommand = ServerCommand;

	globals.edict_size = sizeof(edict_t);

    // initialize these so ShutdownGame doesn't crash
    dedicated = gi.cvar ("dedicated", "0", CVAR_NOSET);
    deathmatch = gi.cvar ("deathmatch", "0", CVAR_LATCH);
    coop = gi.cvar ("coop", "0", CVAR_LATCH);
    lazarus_pitch = gi.cvar("lazarus_pitch",   "0", 0);
    
	gl_driver = gi.cvar ("gl_driver", "", 0);
	vid_ref = gi.cvar ("vid_ref", "", 0);

	Fog_Init();

	developer = gi.cvar("developer", "0", CVAR_SERVERINFO);
	readout   = gi.cvar("readout", "0", CVAR_SERVERINFO);
	if(readout->value)
	{
		max_modelindex = 0;
		max_soundindex = 0;
		RealFunc.modelindex = gi.modelindex;
		gi.modelindex       = Debug_Modelindex;
		RealFunc.soundindex = gi.soundindex;
		gi.soundindex       = Debug_Soundindex;
	}

	return &globals;
}
예제 #3
0
/*
=================
GetGameAPI
 
Returns a pointer to the structure with all entry points
and global variables
=================
*/
game_export_t *GetGameAPI(game_import_t *import)
{
	char dllname[256];
	cvar_t *game;
	GAMEAPI *getapi;
	game_import_t g_import;

	gi = *import;

	game = gi.cvar ("game", "baseq2", 0);
	q2a_strcpy(moddir, game->string);
	
	if(moddir[0] == 0)
		q2a_strcpy(moddir, "baseq2");

	gi.dprintf ("Q2Admin %s running %s\n", Q2A_VERSION, moddir);
	gi.cvar ("*Q2Admin", Q2A_VERSION, CVAR_SERVERINFO|CVAR_NOSET);

	q2a_lua_init();

	sprintf(dllname, "%s/%s", moddir, DLLNAME);
#ifdef _WIN32
	hdll = LoadLibrary(dllname);
#else
	hdll = dlopen(dllname, RTLD_NOW);
#endif
	
	if(hdll == NULL)
	{
		gi.dprintf ("Q2A: Unable to load DLL %s.\n", dllname);
		return &globals;
	}

	gi.dprintf("Q2A: Loaded game DLL: %s.\n", dllname);
		
#ifdef _WIN32
	getapi = (GAMEAPI *)GetProcAddress (hdll, "GetGameAPI");
#else
	getapi = (GAMEAPI *)dlsym(hdll, "GetGameAPI");
#endif
	
	if(getapi == NULL)
	{
#ifdef _WIN32
		FreeLibrary(hdll);
#else
		dlclose(hdll);
#endif
		hdll = NULL;

		gi.dprintf ("Q2A: No \"GetGameApi\" entry in DLL %s.\n", dllname);
		return &globals;
	}

	/* proxy a few imports so we can capture the data */
	memcpy(&g_import, import, sizeof(game_import_t));
	g_import.bprintf = game_bprintf;
	g_import.dprintf = game_dprintf;
	g_import.cprintf = game_cprintf;

	dllglobals = (*getapi)(&g_import);

	globals.apiversion = dllglobals->apiversion;

	globals.Init = Init;
	globals.Shutdown = Shutdown;
	globals.SpawnEntities = SpawnEntities;

	globals.WriteGame = dllglobals->WriteGame;
	globals.ReadGame = dllglobals->ReadGame;

	globals.WriteLevel = dllglobals->WriteLevel;
	globals.ReadLevel = dllglobals->ReadLevel;
	
	globals.ClientConnect = ClientConnect;
	globals.ClientBegin = ClientBegin;
	globals.ClientUserinfoChanged = ClientUserinfoChanged;
	globals.ClientDisconnect = ClientDisconnect;
	globals.ClientCommand = ClientCommand;
	globals.ClientThink = ClientThink;
	
	globals.RunFrame = RunFrame;
	
	globals.ServerCommand = ServerCommand;

	copyDllInfo();

	return &globals;
}
예제 #4
0
static void G_Cvar_Create( const char *var_name, const char *var_value, int flags ) {
	gi.cvar( var_name, var_value, flags );
}
예제 #5
0
/*
============
G_InitCvars

============
*/
void G_InitCvars( void ) {
	// don't override the cheat state set by the system
	g_cheats = gi.cvar ("helpUsObi", "", 0);
	g_developer = gi.cvar ("developer", "", 0);

	// noset vars
	gi.cvar( "gamename", GAMEVERSION , CVAR_SERVERINFO | CVAR_ROM );
	gi.cvar( "gamedate", __DATE__ , CVAR_ROM );
	g_skippingcin = gi.cvar ("skippingCinematic", "0", CVAR_ROM);

	// latched vars

	// change anytime vars
	g_speed = gi.cvar( "g_speed", "250", CVAR_CHEAT );
	g_gravity = gi.cvar( "g_gravity", "800", CVAR_USERINFO|CVAR_ROM );	//using userinfo as savegame flag
	g_sex = gi.cvar ("sex", "male", CVAR_USERINFO | CVAR_ARCHIVE );
	g_spskill = gi.cvar ("g_spskill", "0", CVAR_ARCHIVE | CVAR_USERINFO);	//using userinfo as savegame flag
	g_knockback = gi.cvar( "g_knockback", "1000", CVAR_CHEAT );
	g_dismemberment = gi.cvar ( "g_dismemberment", "3", CVAR_ARCHIVE );//0 = none, 1 = arms and hands, 2 = legs, 3 = waist and head, 4 = mega dismemberment
	g_dismemberProbabilities = gi.cvar ( "g_dismemberProbabilities", "1", CVAR_ARCHIVE );//0 = ignore probabilities, 1 = use probabilities
	g_synchSplitAnims = gi.cvar ( "g_synchSplitAnims", "1", 0 );

	g_inactivity = gi.cvar ("g_inactivity", "0", 0);
	g_debugMove = gi.cvar ("g_debugMove", "0", CVAR_CHEAT );
	g_debugDamage = gi.cvar ("g_debugDamage", "0", CVAR_CHEAT );
	g_ICARUSDebug = gi.cvar( "g_ICARUSDebug", "0", CVAR_CHEAT );
	g_timescale = gi.cvar( "timescale", "1", 0 );

	g_subtitles = gi.cvar( "g_subtitles", "2", CVAR_ARCHIVE );
	com_buildScript = gi.cvar ("com_buildscript", "0", 0);

	g_saberAutoBlocking = gi.cvar( "g_saberAutoBlocking", "1", CVAR_ARCHIVE|CVAR_CHEAT );//must press +block button to do any blocking
	g_saberRealisticCombat = gi.cvar( "g_saberRealisticCombat", "0", CVAR_ARCHIVE|CVAR_CHEAT );//makes collision more precise, increases damage
	g_saberMoveSpeed = gi.cvar( "g_saberMoveSpeed", "1", CVAR_ARCHIVE|CVAR_CHEAT );//how fast you run while attacking with a saber
	g_saberAnimSpeed = gi.cvar( "g_saberAnimSpeed", "1", CVAR_ARCHIVE|CVAR_CHEAT );//how fast saber animations run
	g_saberAutoAim = gi.cvar( "g_saberAutoAim", "1", CVAR_ARCHIVE|CVAR_CHEAT );//auto-aims at enemies when not moving or when just running forward

	g_AIsurrender = gi.cvar( "g_AIsurrender", "0", CVAR_CHEAT );
	g_numEntities = gi.cvar( "g_numEntities", "0", CVAR_CHEAT );
	
	gi.cvar( "newTotalSecrets", "0", CVAR_ROM );
	gi.cvar_set("newTotalSecrets", "0");//used to carry over the count from SP_target_secret to ClientBegin
	g_iscensored = gi.cvar( "ui_iscensored", "0", CVAR_ARCHIVE|CVAR_ROM|CVAR_INIT|CVAR_CHEAT|CVAR_NORESTART );
}
예제 #6
0
파일: g_main.c 프로젝트: lambda/wxQuake2
void CheckPlayerLookTargets (void)
{
    cvar_t *show_look;
    int i;
	edict_t	*ent;
    player_state_t *ps;
	vec3_t view_origin, forward, right, distance, view_target;
	trace_t trace;

    // Set this console variable to display information about what the
    // player is looking at.  For debugging purposes.
    show_look = gi.cvar("show_look", "0", CVAR_SERVERINFO);

    // Iterate over all the active players.
    for (i=0 ; i<maxclients->value ; i++)
    {
		ent = g_edicts + 1 + i;
		if (!ent->inuse)
			continue;
        
        // Calculate the player's line of sight, beginning at view_origin
        // and extending to view_target a fair distance away.
        ps = &ent->client->ps;
        VectorAdd(ent->s.origin, ps->viewoffset, view_origin);
        AngleVectors(ps->viewangles, forward, right, NULL);
        VectorSet(distance, LOOK_DISTANCE, 0, 0);
        G_ProjectSource(view_origin, distance, forward, right, view_target);

        // Trace the player's line of sight and see what we hit.  We begin
        // the trace at view_origin, use a size zero bounding box (NULL,
        // NULL), end the trace at view_target, ignore the player 'ent', and
        // stop when we hit any of the specified object types.
        trace = gi.trace(view_origin, NULL, NULL, view_target, ent,
                         MASK_OPAQUE|CONTENTS_WINDOW|CONTENTS_MONSTER|
                         CONTENTS_DEADMONSTER);

        // If show_look is true, report what the player is currently
        // looking at for debugging purposes
        if (show_look->value && trace.ent && trace.ent->classname)
            gi.cprintf(ent, PRINT_HIGH, "Looking at: %s %x\n",
                       trace.ent->classname, trace.ent);

		// If we're looking at something new, remember it and run any
		// associated look_target.
		if (trace.ent != ent->client->looking_at)
		{
			ent->client->looking_at = trace.ent;
			if (trace.ent && trace.ent->look_target)
				G_UseTargetsByName(trace.ent, trace.ent->look_target, ent);
		}

		// Objects don't get reticles if they're too far away.
		if (trace.fraction > (1.0 * RETICLE_DISTANCE) / LOOK_DISTANCE)
			trace.ent = NULL;

		// We need to resend the reticle every frame, in case the entity
		// is moving relative to the world.
		SendReticle(trace.ent, ent);

		// If the reticle is on something new, remember it and run any
		// associated r_look_target (sound familiar?).
		if (trace.ent != ent->client->reticle_on)
		{
			ent->client->reticle_on = trace.ent;
			if (trace.ent && trace.ent->r_look_target)
				G_UseTargetsByName(trace.ent, trace.ent->r_look_target, ent);
		}
    }
}