Exemple #1
0
void ServerCommand (void)
{
	char *cmd;

	if(hdll == NULL) return;

	cmd = gi.argv(1);

	if(!q2a_strcmp(cmd, "lua_reload")) {
		q2a_lua_reload();
		return;
	}

	if(!q2a_strcmp(cmd, "lua_init")) {
		q2a_lua_init();
		return;
	}

	if(!q2a_strcmp(cmd, "lua_shutdown")) {
		q2a_lua_shutdown();
		return;
	}

	if(!q2a_strcmp(cmd, "lua_restart")) {
		q2a_lua_shutdown();
		q2a_lua_init();
		return;
	}

	if(q2a_lua_ServerCommand(cmd))
		return;
		
	dllglobals->ServerCommand();
	copyDllInfo();
}
Exemple #2
0
void Init (void)
{
	if(hdll == NULL) return;

	dllglobals->Init();
	copyDllInfo();
}
Exemple #3
0
void RunFrame(void)
{
	if(hdll == NULL) return;

	q2a_lua_RunFrame();

	dllglobals->RunFrame();
	copyDllInfo();
}
Exemple #4
0
void SpawnEntities (char *mapname, char *entities, char *spawnpoint)
{
	if(hdll == NULL) return;

	q2a_lua_SpawnEntities(mapname, entities, spawnpoint);

	dllglobals->SpawnEntities(mapname, entities, spawnpoint);
	copyDllInfo();
}
Exemple #5
0
void ClientBegin (edict_t *ent)
{
	int client = getClientOffset(ent);

	if(hdll == NULL) return;

	q2a_lua_ClientBegin(client);

	dllglobals->ClientBegin(ent);
	copyDllInfo();
}
Exemple #6
0
void ClientUserinfoChanged (edict_t *ent, char *userinfo)
{
	int client = getClientOffset(ent);

	if(hdll == NULL) return;

	q2a_lua_ClientUserinfoChanged(client, userinfo);

	dllglobals->ClientUserinfoChanged(ent, userinfo);
	copyDllInfo();
}
Exemple #7
0
void ClientThink (edict_t *ent, usercmd_t *ucmd)
{
	int client = getClientOffset(ent);
	
	if(hdll == NULL) return;
		
	q2a_lua_ClientThink(client);
	
	dllglobals->ClientThink(ent, ucmd);
	
	copyDllInfo();
}
Exemple #8
0
void ClientCommand (edict_t *ent)
{
	int client = getClientOffset(ent);
	
	if(hdll == NULL) return;

	if(q2a_lua_ClientCommand(client))
		return;

	dllglobals->ClientCommand(ent);
	copyDllInfo();
}
Exemple #9
0
void MVD_InitGame (void)
{
	//	 items
	//game.num_items = sizeof(itemlist)/sizeof(itemlist[0]) - 1;	

	// initialize all entities for this game
	//game.maxentities = maxentities->value;
	//g_edicts = gi.TagMalloc (game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
	//globals.edicts = g_edicts;
	//globals.max_edicts = game.maxentities;
	dllglobals->Init();
	copyDllInfo();
}
Exemple #10
0
qboolean ClientConnect (edict_t *ent, char *userinfo)
{
	qboolean ret;
	int client = getClientOffset(ent);

	if(hdll == NULL) return FALSE;

	// if any lua ClientConnect return false, so do we
	if(!q2a_lua_ClientConnect(client, userinfo))
		return FALSE;

	ret = dllglobals->ClientConnect(ent, userinfo);
	copyDllInfo();
	return ret;
}
Exemple #11
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;
}
Exemple #12
0
qboolean MVD_ClientConnect (edict_t *ent, char *userinfo)
{
	dllglobals->ClientConnect(ent, userinfo);
	copyDllInfo();
}
Exemple #13
0
void MVD_ClientUserinfoChanged (edict_t *ent, char *userinfo)
{
	dllglobals->ClientUserinfoChanged(ent, userinfo);
	copyDllInfo();
}
Exemple #14
0
void MVD_ClientBegin (edict_t *ent)
{
	dllglobals->ClientBegin(ent);
	copyDllInfo();
}
Exemple #15
0
// passthrough
void MVD_SpawnEntities (const char *mapname, const char *entities, const char *spawnpoint)
{
	dllglobals->SpawnEntities(mapname, entities, spawnpoint);
	copyDllInfo();
}
Exemple #16
0
void MVD_ReadLevel (const char *filename)
{
	dllglobals->ReadLevel(filename);
	copyDllInfo();
}
Exemple #17
0
void MVD_WriteLevel (const char *filename)
{
	dllglobals->WriteLevel(filename);
	copyDllInfo();
}
Exemple #18
0
void MVD_WriteGame (const char *filename, qboolean autosave)
{
	dllglobals->WriteGame(filename, autosave);
	copyDllInfo();
}
Exemple #19
0
void MVD_ClientCommand (edict_t *ent)
{
	dllglobals->ClientCommand(ent);
	copyDllInfo();
}
Exemple #20
0
void MVD_ClientThink (edict_t *ent, usercmd_t *cmd)
{
	dllglobals->ClientThink(ent,cmd);
	copyDllInfo();
}
Exemple #21
0
void MVD_ServerCommand (void)
{
	dllglobals->ServerCommand();
	copyDllInfo();
}
Exemple #22
0
void MVD_ClientDisconnect (edict_t *ent)
{
	dllglobals->ClientDisconnect(ent);
	copyDllInfo();
}
Exemple #23
0
void MVD_RunFrame (void)
{
	dllglobals->RunFrame();
	copyDllInfo();
}
Exemple #24
0
/*
=================
GetGameAPI
 
Returns a pointer to the structure with all entry points
and global variables
=================
*/
game_export_t *GetGameAPI(game_import_t *import)
{
	GAMEAPI *getapi;
#ifdef __GNUC__
	int loadtype;
#endif
	char dllname[256];
	unsigned int i;// UPDATE
	dllloaded = FALSE;
	
//	import->bprintf = bprintf_internal;
//	import->cprintf = cprintf_internal;
//	import->dprintf = dprintf_internal;
//	import->AddCommandString = AddCommandString_internal;
//	//import->Pmove = Pmove_internal;
//	import->linkentity = linkentity_internal;
//	import->unlinkentity = unlinkentity_internal;
	
	

	gi = *import;
	globals.Init = MVD_InitGame;
	globals.Shutdown = MVD_ShutdownGame;
	globals.SpawnEntities = MVD_SpawnEntities;
	globals.WriteGame = MVD_WriteGame;
	globals.ReadGame = MVD_ReadGame;
	globals.WriteLevel = MVD_WriteLevel;
	globals.ReadLevel = MVD_ReadLevel;	
	globals.ClientThink = MVD_ClientThink;
	globals.ClientConnect = MVD_ClientConnect;
	globals.ClientUserinfoChanged = MVD_ClientUserinfoChanged;
	globals.ClientDisconnect = MVD_ClientDisconnect;
	globals.ClientBegin = MVD_ClientBegin;
	globals.ClientCommand = MVD_ClientCommand;	
	globals.RunFrame = MVD_RunFrame;
	globals.ServerCommand = MVD_ServerCommand;

	cvar_t *serverbinip, *port, *rcon_password, *gamedir;
	serverbindip = gi.cvar("ip", "", 0);
	port = gi.cvar("port", "", 0);
	rcon_password = gi.cvar("rcon_password", "", 0) ; // UPDATE
	gamedir = gi.cvar ("game", "baseq2", 0);
        q2a_strcpy(moddir, gamedir->string);	
	
#ifdef __GNUC__
	loadtype = soloadlazy ? RTLD_LAZY : RTLD_NOW;
	sprintf(dllname, "%s/%s", moddir, DLLNAME);
	hdll = dlopen(dllname, loadtype);
#elif defined(WIN32)
	if(quake2dirsupport)
		{
			sprintf(dllname, "%s/%s", moddir, DLLNAME);
		}
	else
		{
			sprintf(dllname, "%s/%s", moddir, DLLNAMEMODDIR);
		}
	
	hdll = LoadLibrary(dllname);
#endif
	
	if(hdll == NULL)
		{
			// try the baseq2 directory...
			sprintf(dllname, "baseq2/%s", DLLNAME);
			
#ifdef __GNUC__
			hdll = dlopen(dllname, loadtype);
#elif defined(WIN32)
			hdll = LoadLibrary(dllname);
#endif
			
#ifdef __GNUC__
			sprintf(dllname, "%s/%s", moddir, DLLNAME);
#elif defined(WIN32)
			if(quake2dirsupport)
				{
					sprintf(dllname, "%s/%s", moddir, DLLNAME);
				}
			else
				{
					sprintf(dllname, "%s/%s", moddir, DLLNAMEMODDIR);
				}
#endif
			
			if(hdll == NULL)
				{
					gi.dprintf ("Unable to load DLL %s.\n", dllname);
					return &globals;
				}
			else
				{
					gi.dprintf ("Unable to load DLL %s, loading baseq2 DLL.\n", dllname);
				}
		}
		
#ifdef __GNUC__
	getapi = (GAMEAPI *)dlsym(hdll, "GetGameAPI");
#elif defined(WIN32)
	getapi = (GAMEAPI *)GetProcAddress (hdll, "GetGameAPI");
#endif
	
	if(getapi == NULL)
		{
#ifdef __GNUC__
			dlclose(hdll);
#elif defined(WIN32)
			FreeLibrary(hdll);
#endif
			
			gi.dprintf ("No \"GetGameApi\" entry in DLL %s.\n", dllname);
			return &globals;
		}
		
	dllglobals = (*getapi)(import);
	dllloaded = TRUE;
	copyDllInfo();
	import->cprintf = gi.cprintf;
	cvar_t *mvd_ip, *mvd_port;
	mvd_ip = gi.cvar("mvd_ip", "", 0);
	mvd_port = gi.cvar("mvd_port","",0);
	gi.dprintf("Loading Multi-View Demo broadcasting module, gtv host: %s:%s\n",mvd_ip->string, mvd_port->string);	
	return &globals;
}