Пример #1
0
/*
====================
CL_InitUI
====================
*/
void CL_InitUI(void) {
	int v;
	vmInterpret_t interpret;
	// load the dll or bytecode
	if ( cl_connectedToPureServer != 0 ) {
#if 0
		// if sv_pure is set we only allow qvms to be loaded
		interpret = VMI_COMPILED;
#else //load the module type based on what the server is doing -rww
		interpret = (vmInterpret_t)cl_connectedUI;
#endif
	} else {
		interpret = (vmInterpret_t)(int)Cvar_VariableValue("vm_ui");
	}
	//ent, from q3mme: CaNaBiS, force a native binary first
	interpret = VMI_NATIVE;
//	uivm = VM_Create("ui", CL_UISystemCalls, interpret);
	uivm = VM_CreateLegacy(VM_UI, CL_UISystemCalls);
	if (!uivm) {
		Com_Error(ERR_FATAL, "VM_Create on UI failed");
	}
	// sanity check
	v = VM_Call(uivm, UI_GETAPIVERSION);
	if (v != UI_API_VERSION) {
		Com_Error(ERR_DROP, "User Interface is version %d, expected %d", v, UI_API_VERSION);
		cls.uiStarted = qfalse;
	} else {
		// init for this gamestate
		//rww - changed to <= CA_ACTIVE, because that is the state when we did a vid_restart
		//ingame (was just < CA_ACTIVE before, resulting in ingame menus getting wiped and
		//not reloaded on vid restart from ingame menu)
		VM_Call(uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state <= CA_ACTIVE));
	}
}
Пример #2
0
// Reload the data, but leave everything else in place
// This allows a server to do a map_restart without changing memory allocation
vm_t *VM_Restart( vm_t *vm ) {
	const vm_t saved = *vm;

	VM_Free( vm );

	if ( saved.isLegacy )
		return VM_CreateLegacy( saved.slot, saved.legacy.syscall );
	else
		return VM_Create( saved.slot );
}
Пример #3
0
/*
=================
VM_Restart

Reload the data, but leave everything else in place
This allows a server to do a map_restart without changing memory allocation
=================
*/
vm_t *VM_Restart( vm_t *vm ) {
	vm_t saved;

	memcpy( &saved, vm, sizeof( saved ) );

	VM_Free( vm );

	if ( saved.isLegacy )
		return VM_CreateLegacy( saved.slot, saved.legacy.syscall );
	else
		return VM_Create( saved.slot );
}
Пример #4
0
void CL_BindUI( void ) {
	static uiImport_t uii;
	uiExport_t		*ret;
	GetUIAPI_t		GetUIAPI;
	char			dllName[MAX_OSPATH] = "ui"ARCH_STRING DLL_EXT;

	memset( &uii, 0, sizeof( uii ) );

	uivm = VM_Create( VM_UI );
	if ( uivm ) {
		uii.Print								= Com_Printf;
		uii.Error								= Com_Error;
		uii.Milliseconds						= CL_Milliseconds;
		uii.RealTime							= Com_RealTime;
		uii.MemoryRemaining						= Hunk_MemoryRemaining;

		uii.Cvar_Create							= CL_Cvar_Get;
		uii.Cvar_InfoStringBuffer				= Cvar_InfoStringBuffer;
		uii.Cvar_Register						= Cvar_Register;
		uii.Cvar_Reset							= Cvar_Reset;
		uii.Cvar_Set							= Cvar_Set;
		uii.Cvar_SetValue						= Cvar_SetValue;
		uii.Cvar_Update							= Cvar_Update;
		uii.Cvar_VariableStringBuffer			= Cvar_VariableStringBuffer;
		uii.Cvar_VariableValue					= Cvar_VariableValue;

		uii.Cmd_Argc							= Cmd_Argc;
		uii.Cmd_Argv							= Cmd_ArgvBuffer;
		uii.Cmd_ExecuteText						= Cbuf_ExecuteText;

		uii.FS_Close							= FS_FCloseFile;
		uii.FS_GetFileList						= FS_GetFileList;
		uii.FS_Open								= FS_FOpenFileByMode;
		uii.FS_Read								= FS_Read2;
		uii.FS_Write							= FS_Write;

		uii.GetClientState						= CL_GetClientState;
		uii.GetClipboardData					= GetClipboardData;
		uii.GetConfigString						= GetConfigString;
		uii.GetGlconfig							= CL_GetGlconfig;
		uii.UpdateScreen						= SCR_UpdateScreen;

		uii.Key_ClearStates						= Key_ClearStates;
		uii.Key_GetBindingBuf					= Key_GetBindingBuf;
		uii.Key_IsDown							= Key_IsDown;
		uii.Key_KeynumToStringBuf				= Key_KeynumToStringBuf;
		uii.Key_SetBinding						= Key_SetBinding;
		uii.Key_GetCatcher						= Key_GetCatcher;
		uii.Key_GetOverstrikeMode				= Key_GetOverstrikeMode;
		uii.Key_SetCatcher						= Key_SetCatcher;
		uii.Key_SetOverstrikeMode				= Key_SetOverstrikeMode;

		uii.PC_AddGlobalDefine					= botlib_export->PC_AddGlobalDefine;
		uii.PC_FreeSource						= botlib_export->PC_FreeSourceHandle;
		uii.PC_LoadGlobalDefines				= botlib_export->PC_LoadGlobalDefines;
		uii.PC_LoadSource						= botlib_export->PC_LoadSourceHandle;
		uii.PC_ReadToken						= botlib_export->PC_ReadTokenHandle;
		uii.PC_RemoveAllGlobalDefines			= botlib_export->PC_RemoveAllGlobalDefines;
		uii.PC_SourceFileAndLine				= botlib_export->PC_SourceFileAndLine;

		uii.CIN_DrawCinematic					= CIN_DrawCinematic;
		uii.CIN_PlayCinematic					= CIN_PlayCinematic;
		uii.CIN_RunCinematic					= CIN_RunCinematic;
		uii.CIN_SetExtents						= CIN_SetExtents;
		uii.CIN_StopCinematic					= CIN_StopCinematic;

		uii.LAN_AddServer						= LAN_AddServer;
		uii.LAN_ClearPing						= LAN_ClearPing;
		uii.LAN_CompareServers					= LAN_CompareServers;
		uii.LAN_GetPing							= LAN_GetPing;
		uii.LAN_GetPingInfo						= LAN_GetPingInfo;
		uii.LAN_GetPingQueueCount				= LAN_GetPingQueueCount;
		uii.LAN_GetServerAddressString			= LAN_GetServerAddressString;
		uii.LAN_GetServerCount					= LAN_GetServerCount;
		uii.LAN_GetServerInfo					= LAN_GetServerInfo;
		uii.LAN_GetServerPing					= LAN_GetServerPing;
		uii.LAN_LoadCachedServers				= LAN_LoadCachedServers;
		uii.LAN_MarkServerVisible				= LAN_MarkServerVisible;
		uii.LAN_RemoveServer					= LAN_RemoveServer;
		uii.LAN_ResetPings						= LAN_ResetPings;
		uii.LAN_SaveCachedServers				= LAN_SaveServersToCache;
		uii.LAN_ServerIsVisible					= LAN_ServerIsVisible;
		uii.LAN_ServerStatus					= LAN_GetServerStatus;
		uii.LAN_UpdateVisiblePings				= LAN_UpdateVisiblePings;

		uii.S_StartBackgroundTrack				= S_StartBackgroundTrack;
		uii.S_StartLocalSound					= S_StartLocalSound;
		uii.S_StopBackgroundTrack				= S_StopBackgroundTrack;
		uii.S_RegisterSound						= S_RegisterSound;

		uii.SE_GetLanguageName					= CL_SE_GetLanguageName;
		uii.SE_GetNumLanguages					= SE_GetNumLanguages;
		uii.SE_GetStringTextString				= CL_SE_GetStringTextString;

		uii.R_Language_IsAsian					= re->Language_IsAsian;
		uii.R_Language_UsesSpaces				= re->Language_UsesSpaces;
		uii.R_AnyLanguage_ReadCharFromString	= re->AnyLanguage_ReadCharFromString;

		uii.R_AddLightToScene					= re->AddLightToScene;
		uii.R_AddPolysToScene					= re->AddPolyToScene;
		uii.R_AddRefEntityToScene				= re->AddRefEntityToScene;
		uii.R_ClearScene						= re->ClearScene;
		uii.R_DrawStretchPic					= re->DrawStretchPic;
		uii.R_Font_DrawString					= re->Font_DrawString;
		uii.R_Font_HeightPixels					= re->Font_HeightPixels;
		uii.R_Font_StrLenChars					= re->Font_StrLenChars;
		uii.R_Font_StrLenPixels					= re->Font_StrLenPixels;
		uii.R_LerpTag							= re->LerpTag;
		uii.R_ModelBounds						= re->ModelBounds;
		uii.R_RegisterFont						= re->RegisterFont;
		uii.R_RegisterModel						= re->RegisterModel;
		uii.R_RegisterShaderNoMip				= re->RegisterShaderNoMip;
		uii.R_RegisterSkin						= re->RegisterSkin;
		uii.R_RemapShader						= re->RemapShader;
		uii.R_RenderScene						= re->RenderScene;
		uii.R_SetColor							= re->SetColor;
		uii.R_ShaderNameFromIndex				= CL_R_ShaderNameFromIndex;

		uii.G2_ListModelSurfaces				= CL_G2API_ListModelSurfaces;
		uii.G2_ListModelBones					= CL_G2API_ListModelBones;
		uii.G2_SetGhoul2ModelIndexes			= CL_G2API_SetGhoul2ModelIndexes;
		uii.G2_HaveWeGhoul2Models				= CL_G2API_HaveWeGhoul2Models;
		uii.G2API_GetBoltMatrix					= CL_G2API_GetBoltMatrix;
		uii.G2API_GetBoltMatrix_NoReconstruct	= CL_G2API_GetBoltMatrix_NoReconstruct;
		uii.G2API_GetBoltMatrix_NoRecNoRot		= CL_G2API_GetBoltMatrix_NoRecNoRot;
		uii.G2API_InitGhoul2Model				= CL_G2API_InitGhoul2Model;
		uii.G2API_SetSkin						= CL_G2API_SetSkin;
		uii.G2API_CollisionDetect				= CL_G2API_CollisionDetect;
		uii.G2API_CollisionDetectCache			= CL_G2API_CollisionDetectCache;
		uii.G2API_CleanGhoul2Models				= CL_G2API_CleanGhoul2Models;
		uii.G2API_SetBoneAngles					= CL_G2API_SetBoneAngles;
		uii.G2API_SetBoneAnim					= CL_G2API_SetBoneAnim;
		uii.G2API_GetBoneAnim					= CL_G2API_GetBoneAnim;
		uii.G2API_GetBoneFrame					= CL_G2API_GetBoneFrame;
		uii.G2API_GetGLAName					= CL_G2API_GetGLAName;
		uii.G2API_CopyGhoul2Instance			= CL_G2API_CopyGhoul2Instance;
		uii.G2API_CopySpecificGhoul2Model		= CL_G2API_CopySpecificGhoul2Model;
		uii.G2API_DuplicateGhoul2Instance		= CL_G2API_DuplicateGhoul2Instance;
		uii.G2API_HasGhoul2ModelOnIndex			= CL_G2API_HasGhoul2ModelOnIndex;
		uii.G2API_RemoveGhoul2Model				= CL_G2API_RemoveGhoul2Model;
		uii.G2API_AddBolt						= CL_G2API_AddBolt;
		uii.G2API_SetBoltInfo					= CL_G2API_SetBoltInfo;
		uii.G2API_SetRootSurface				= CL_G2API_SetRootSurface;
		uii.G2API_SetSurfaceOnOff				= CL_G2API_SetSurfaceOnOff;
		uii.G2API_SetNewOrigin					= CL_G2API_SetNewOrigin;
		uii.G2API_GetTime						= CL_G2API_GetTime;
		uii.G2API_SetTime						= CL_G2API_SetTime;
		uii.G2API_SetRagDoll					= CL_G2API_SetRagDoll;
		uii.G2API_AnimateG2Models				= CL_G2API_AnimateG2Models;
		uii.G2API_SetBoneIKState				= CL_G2API_SetBoneIKState;
		uii.G2API_IKMove						= CL_G2API_IKMove;
		uii.G2API_GetSurfaceName				= CL_G2API_GetSurfaceName;
		uii.G2API_AttachG2Model					= CL_G2API_AttachG2Model;

		GetUIAPI = (GetUIAPI_t)uivm->GetModuleAPI;
		ret = GetUIAPI( UI_API_VERSION, &uii );
		if ( !ret ) {
			//free VM?
			cls.uiStarted = qfalse;
			Com_Error( ERR_FATAL, "GetGameAPI failed on %s", dllName );
		}
		uie = ret;
	}

	// fall back to legacy syscall/vm_call api
	uivm = VM_CreateLegacy( VM_UI, CL_UISystemCalls );
	if ( !uivm ) {
		cls.uiStarted = qfalse;
		Com_Error( ERR_DROP, "VM_CreateLegacy on ui failed" );
	}
}