/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ int CL_UISystemCalls( int *args ) { switch( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( VMA(1), VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( VMA(1), VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] ); case UI_FS_SEEK: return FS_Seek( args[1], args[2], args[3] ); case UI_R_REGISTERMODEL: return re.RegisterModel( VMA(1) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( VMA(1) ); case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( VMA(1) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); return 0; case UI_R_ADDLIGHTTOSCENE: re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case UI_R_RENDERSCENE: re.RenderScene( VMA(1) ); return 0; case UI_R_SETCOLOR: re.SetColor( VMA(1) ); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case UI_R_MODELBOUNDS: re.ModelBounds( args[1], VMA(2), VMA(3) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: re.LerpTag( VMA(1), args[2], args[3], args[4], VMF(5), VMA(6) ); return 0; case UI_S_REGISTERSOUND: return S_RegisterSound( VMA(1), args[2] ); case UI_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], VMA(2), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], VMA(2), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], VMA(2) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData( VMA(1), args[2] ); return 0; case UI_GETCLIENTSTATE: GetClientState( VMA(1) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( VMA(1) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], VMA(2), args[3] ); case UI_LAN_LOADCACHEDSERVERS: LAN_LoadCachedServers(); return 0; case UI_LAN_SAVECACHEDSERVERS: LAN_SaveServersToCache(); return 0; case UI_LAN_ADDSERVER: return LAN_AddServer(args[1], VMA(2), VMA(3)); case UI_LAN_REMOVESERVER: LAN_RemoveServer(args[1], VMA(2)); return 0; case UI_LAN_GETPINGQUEUECOUNT: return LAN_GetPingQueueCount(); case UI_LAN_CLEARPING: LAN_ClearPing( args[1] ); return 0; case UI_LAN_GETPING: LAN_GetPing( args[1], VMA(2), args[3], VMA(4) ); return 0; case UI_LAN_GETPINGINFO: LAN_GetPingInfo( args[1], VMA(2), args[3] ); return 0; case UI_LAN_GETSERVERCOUNT: return LAN_GetServerCount(args[1]); case UI_LAN_GETSERVERADDRESSSTRING: LAN_GetServerAddressString( args[1], args[2], VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERINFO: LAN_GetServerInfo( args[1], args[2], VMA(3), args[4] ); return 0; case UI_LAN_GETSERVERPING: return LAN_GetServerPing( args[1], args[2] ); case UI_LAN_MARKSERVERVISIBLE: LAN_MarkServerVisible( args[1], args[2], args[3] ); return 0; case UI_LAN_SERVERISVISIBLE: return LAN_ServerIsVisible( args[1], args[2] ); case UI_LAN_UPDATEVISIBLEPINGS: return LAN_UpdateVisiblePings( args[1] ); case UI_LAN_RESETPINGS: LAN_ResetPings( args[1] ); return 0; case UI_LAN_SERVERSTATUS: return LAN_GetServerStatus( VMA(1), VMA(2), args[3] ); case UI_LAN_COMPARESERVERS: return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); case UI_GET_CDKEY: CLUI_GetCDKey( VMA(1), args[2] ); return 0; case UI_SET_CDKEY: CLUI_SetCDKey( VMA(1) ); return 0; case UI_SET_PBCLSTATUS: return 0; case UI_R_REGISTERFONT: re.RegisterFont( VMA(1), args[2], VMA(3)); return 0; case UI_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case UI_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case UI_STRNCPY: return (int)strncpy( VMA(1), VMA(2), args[3] ); case UI_SIN: return FloatAsInt( sin( VMF(1) ) ); case UI_COS: return FloatAsInt( cos( VMF(1) ) ); case UI_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case UI_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case UI_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case UI_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( VMA(1) ); case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( VMA(1) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( VMA(1), VMA(2)); return 0; case UI_REAL_TIME: return Com_RealTime( VMA(1) ); case UI_CIN_PLAYCINEMATIC: Com_DPrintf("UI_CIN_PlayCinematic\n"); return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); case UI_CIN_STOPCINEMATIC: return CIN_StopCinematic(args[1]); case UI_CIN_RUNCINEMATIC: return CIN_RunCinematic(args[1]); case UI_CIN_DRAWCINEMATIC: CIN_DrawCinematic(args[1]); return 0; case UI_CIN_SETEXTENTS: CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); return 0; case UI_R_REMAP_SHADER: re.RemapShader( VMA(1), VMA(2), VMA(3) ); return 0; case UI_VERIFY_CDKEY: return CL_CDKeyValidate(VMA(1), VMA(2)); default: Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); } return 0; }
/* ==================== MainWndProc main window procedure ==================== */ LONG WINAPI MainWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LONG lRet = 0; if ( uMsg == MSH_MOUSEWHEEL ) { if ( ( ( int ) wParam ) > 0 ) { Key_Event( K_MWHEELUP, true, sys_msg_time ); Key_Event( K_MWHEELUP, false, sys_msg_time ); } else { Key_Event( K_MWHEELDOWN, true, sys_msg_time ); Key_Event( K_MWHEELDOWN, false, sys_msg_time ); } return DefWindowProc (hWnd, uMsg, wParam, lParam); } switch (uMsg) { case WM_MOUSEWHEEL: /* ** this chunk of code theoretically only works under NT4 and Win98 ** since this message doesn't exist under Win95 */ if ( ( short ) HIWORD( wParam ) > 0 ) { Key_Event( K_MWHEELUP, true, sys_msg_time ); Key_Event( K_MWHEELUP, false, sys_msg_time ); } else { Key_Event( K_MWHEELDOWN, true, sys_msg_time ); Key_Event( K_MWHEELDOWN, false, sys_msg_time ); } break; case WM_HOTKEY: return 0; case WM_CREATE: cl_hwnd = hWnd; MSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG"); return DefWindowProc (hWnd, uMsg, wParam, lParam); case WM_PAINT: SCR_DirtyScreen (); // force entire screen to update next frame return DefWindowProc (hWnd, uMsg, wParam, lParam); case WM_DESTROY: // let sound and input know about this? cl_hwnd = NULL; return DefWindowProc (hWnd, uMsg, wParam, lParam); case WM_ACTIVATE: { int fActive, fMinimized; // KJB: Watch this for problems in fullscreen modes with Alt-tabbing. fActive = LOWORD(wParam); fMinimized = (BOOL) HIWORD(wParam); AppActivate( fActive != WA_INACTIVE, fMinimized); if ( reflib_active ) re.AppActivate( !( fActive == WA_INACTIVE ) ); } return DefWindowProc (hWnd, uMsg, wParam, lParam); case WM_MOVE: { int xPos, yPos; RECT r; int style; if (!vid_fullscreen->value) { xPos = (short) LOWORD(lParam); // horizontal position yPos = (short) HIWORD(lParam); // vertical position r.left = 0; r.top = 0; r.right = 1; r.bottom = 1; style = GetWindowLong( hWnd, GWL_STYLE ); AdjustWindowRect( &r, style, FALSE ); Cvar_SetValue( "vid_xpos", xPos + r.left); Cvar_SetValue( "vid_ypos", yPos + r.top); vid_xpos->modified = false; vid_ypos->modified = false; if (ActiveApp) IN_Activate (true); } } return DefWindowProc (hWnd, uMsg, wParam, lParam); // this is complicated because Win32 seems to pack multiple mouse events into // one update sometimes, so we always check all states and look for events case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MOUSEMOVE: { int temp; temp = 0; if (wParam & MK_LBUTTON) temp |= 1; if (wParam & MK_RBUTTON) temp |= 2; if (wParam & MK_MBUTTON) temp |= 4; IN_MouseEvent (temp); } break; case WM_SYSCOMMAND: if ( wParam == SC_SCREENSAVE ) return 0; return DefWindowProc (hWnd, uMsg, wParam, lParam); case WM_SYSKEYDOWN: if ( wParam == 13 ) { if ( vid_fullscreen ) { Cvar_SetValue( "vid_fullscreen", !vid_fullscreen->value ); } return 0; } // fall through case WM_KEYDOWN: Key_Event( MapKey( lParam ), true, sys_msg_time); break; case WM_SYSKEYUP: case WM_KEYUP: Key_Event( MapKey( lParam ), false, sys_msg_time); break; case MM_MCINOTIFY: { LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam); } break; default: // pass all unhandled messages to DefWindowProc return DefWindowProc (hWnd, uMsg, wParam, lParam); } /* return 0 if handled message, 1 if not */ return DefWindowProc( hWnd, uMsg, wParam, lParam ); }
/* * Keybinding command */ void SCR_SizeUp_f(void) { Cvar_SetValue("viewsize", (float)scr_viewsize->value + 10); }
/** * @brief Updates the alienscont menu. */ static void AC_UpdateMenu (const base_t *base) { Cvar_Set("mn_al_alientype", ""); Cvar_Set("mn_al_alienimage", ""); Cvar_SetValue("mn_al_dead", 0); Cvar_SetValue("mn_al_alive", 0); Cvar_SetValue("mn_al_capacity", CAP_GetCurrent(base, CAP_ALIENS)); Cvar_SetValue("mn_al_capacity_max", CAP_GetMax(base, CAP_ALIENS)); /* Reset list. */ cgi->UI_ExecuteConfunc("aliencont_clear"); if (B_GetBuildingStatus(base, B_ALIEN_CONTAINMENT)) { const aliensCont_t *containment = base->alienscont; int i, j; for (i = 0, j = 0; i < ccs.numAliensTD; i++) { if (j < MAX_AC_MENU_ENTRIES) { if (containment[i].teamDef) { const technology_t *tech = containment[i].tech; if (!tech) { Com_Printf("AC_UpdateMenu: Tech entry for containment %i not set!\n", i); /* to let the click function still work */ continue; } if (!aliencontCurrent) { aliencontCurrent = &containment[i]; } if (containment[i].amountAlive > 0 || containment[i].amountDead > 0) { /* Generate a list entry. */ if (RS_IsResearched_ptr(tech)) { Cvar_Set(va("mn_ac_statusstr%i", j), _("Researched")); } else { Cvar_Set(va("mn_ac_statusstr%i", j), _("Awaiting autopsy")); if (!containment[i].amountDead) { cgi->UI_ExecuteConfunc("aliencontkill %i", j); } else { cgi->UI_ExecuteConfunc("aliencontneedautopsy %i", j); } } Cvar_SetValue(va("mn_ac_progress%i", j), (1 - tech->time / tech->overallTime) * 100); /* Display name in the correct list-entry. */ Cvar_Set(va("mn_ac_name%i", j), _(containment[i].teamDef->name)); /* Display amount of dead aliens in the correct list-entry. */ Cvar_SetValue(va("mn_ac_dead%i", j), containment[i].amountDead); /* Display number of live aliens in the correct list-entry. */ Cvar_SetValue(va("mn_ac_alive%i", j), containment[i].amountAlive); j++; } } } } numAliensOnList = j; for (; j < MAX_AC_MENU_ENTRIES; j++) { Cvar_Set(va("mn_ac_statusstr%i", j), _("Free slot")); Cvar_Set(va("mn_ac_name%i", j), _("None")); Cvar_Set(va("mn_ac_dead%i", j), ""); Cvar_Set(va("mn_ac_alive%i", j), ""); Cvar_SetValue(va("mn_ac_progress%i", j), 0); } } /** @todo Select the containment we (maybe) just clicked again */ AC_AlienClick(base, 0); }
/* ================= SCR_SizeDown_f Keybinding command ================= */ void SCR_SizeDown_f(void) { Cvar_SetValue("viewsize", scr_viewsize.value - 10); vid.recalc_refdef = 1; }
/* =================== Key_Event Called by the system between frames for both key up and key down events Should NOT be called during an interrupt! =================== */ void Key_Event (int key, qboolean down, uint32 time) { char *kb; char cmd[1024]; // hack for modal presses /*if (key_waiting == -1) { if (down) key_waiting = key; return; }*/ //Com_Printf ("%d is %d for %u\n", LOG_GENERAL, key, down, time); // update auto-repeat status if (down) { key_repeats[key]++; if (cls.key_dest != key_console && key != K_BACKSPACE && key != K_DEL && key != K_LEFTARROW && key != K_RIGHTARROW && key != K_PAUSE && key != K_PGUP && key != K_KP_PGUP && key != K_PGDN && key != K_KP_PGDN && key_repeats[key] > 1) return; // ignore most autorepeats if (key >= 200 && !keybindings[key]) Com_Printf ("%s is unbound, hit F4 to set.\n", LOG_CLIENT, Key_KeynumToString (key) ); } else { key_repeats[key] = 0; } //for dinput if (down && keydown[K_ALT]) { if (key == K_ENTER) { Com_Printf ("ALT+Enter, setting fullscreen %d.\n", LOG_CLIENT, !vid_fullscreen->intvalue); Cvar_SetValue( "vid_fullscreen", (float)!vid_fullscreen->intvalue ); return; } else if (key == K_TAB) { //prevent executing action on alt+tab return; } } if (key == K_SHIFT) shift_down = down; // console key is hardcoded, so the user can never unbind it if ((key == '`' || key == '~') && !shift_down) { if (!down) return; Con_ToggleConsole_f (); return; } // any key during the attract mode will bring up the menu /*if (cl.attractloop && cls.key_dest != key_menu && !(key >= K_F1 && key <= K_F12)) key = K_ESCAPE;*/ // menu key is hardcoded, so the user can never unbind it if (key == K_ESCAPE) { if (!down) return; if (cl.frame.playerstate.stats[STAT_LAYOUTS] && cls.key_dest == key_game) { // put away help computer / inventory Cbuf_AddText ("cmd putaway\n"); return; } switch (cls.key_dest) { case key_message: Key_Message (key); break; case key_menu: M_Keydown (key); break; case key_game: case key_console: M_Menu_Main_f (); break; default: Com_Error (ERR_FATAL, "Bad cls.key_dest"); } return; } if (!keydown[key]) key_lastrepeat[key] = curtime + key_repeatdelay; // track if any key is down for BUTTON_ANY keydown[key] = down; if (down) { if (key_repeats[key] == 1) anykeydown++; } else { key_lastrepeat[key] = 0; anykeydown--; if (anykeydown < 0) anykeydown = 0; } // // key up events only generate commands if the game key binding is // a button command (leading + sign). These will occur even in console mode, // to keep the character from continuing an action started before a console // switch. Button commands include the kenum as a parameter, so multiple // downs can be matched with ups // if (!down) { //r1ch: only generate -events if key was down (prevents -binds in menu / messagemode) if (buttondown[key]) { kb = keybindings[key]; if (kb && kb[0] == '+') { Com_sprintf (cmd, sizeof(cmd), "-%s %i %u\n", kb+1, key, time); Cbuf_AddText (cmd); } if (keyshift[key] != key) { kb = keybindings[keyshift[key]]; if (kb && kb[0] == '+') { Com_sprintf (cmd, sizeof(cmd), "-%s %i %u\n", kb+1, key, time); Cbuf_AddText (cmd); } } buttondown[key] = false; } return; } // // if not a consolekey, send to the interpreter no matter what mode is // if ( (cls.key_dest == key_menu && menubound[key]) || (cls.key_dest == key_console && !consolekeys[key]) || (cls.key_dest == key_game && ( cls.state == ca_active || !consolekeys[key] ) ) ) { kb = keybindings[key]; if (kb && kb[0]) { if (kb[0] == '+') { // button commands add keynum and time as a parm if (cls.key_dest != key_game) //r1: don't run buttons in console return; Com_sprintf (cmd, sizeof(cmd), "%s %i %u\n", kb, key, time); Cbuf_AddText (cmd); buttondown[key] = true; } else { Cbuf_AddText (kb); Cbuf_AddText ("\n"); } } return; } //if (!down) // return; // other systems only care about key down events if (shift_down) key = keyshift[key]; switch (cls.key_dest) { case key_message: Key_Message (key); break; case key_menu: M_Keydown (key); break; case key_game: case key_console: Key_Console (key); break; default: Com_Error (ERR_FATAL, "Bad cls.key_dest"); } }
static void IN_ProcessEvents( void ) { SDL_Event e; const char *character = NULL; keyNum_t key = 0; if( !SDL_WasInit( SDL_INIT_VIDEO ) ) return; if( Key_GetCatcher( ) == 0 && keyRepeatEnabled ) { SDL_EnableKeyRepeat( 0, 0 ); keyRepeatEnabled = qfalse; } else if( !keyRepeatEnabled ) { SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); keyRepeatEnabled = qtrue; } while( SDL_PollEvent( &e ) ) { switch( e.type ) { case SDL_KEYDOWN: character = IN_TranslateSDLToQ3Key( &e.key.keysym, &key, qtrue ); if( key ) Com_QueueEvent( 0, SE_KEY, key, qtrue, 0, NULL ); if( character ) Com_QueueEvent( 0, SE_CHAR, *character, 0, 0, NULL ); break; case SDL_KEYUP: IN_TranslateSDLToQ3Key( &e.key.keysym, &key, qfalse ); if( key ) Com_QueueEvent( 0, SE_KEY, key, qfalse, 0, NULL ); break; case SDL_MOUSEMOTION: if( mouseActive ) Com_QueueEvent( 0, SE_MOUSE, e.motion.x, e.motion.y, 0, NULL ); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { unsigned char b; switch( e.button.button ) { case 1: b = K_MOUSE1; break; case 2: b = K_MOUSE3; break; case 3: b = K_MOUSE2; break; case 4: b = K_MWHEELUP; break; case 5: b = K_MWHEELDOWN; break; case 6: b = K_MOUSE4; break; case 7: b = K_MOUSE5; break; default: b = K_AUX1 + ( e.button.button - 8 ) % 16; break; } Com_QueueEvent( 0, SE_KEY, b, ( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL ); } break; case SDL_JOYAXISMOTION: // Android accelerometer and on-screen joystick { if( e.jaxis.which == JOY_SDL_TOUCHSCREEN && e.jaxis.axis < 2 ) // joy 0 axes 0-1 = screen joystick Com_QueueEvent( 0, SE_JOYSTICK_AXIS, e.jaxis.axis + JOY_AXIS_SCREENJOY_X, e.jaxis.value, 0, NULL ); if( e.jaxis.which == JOY_SDL_GYROSCOPE && e.jaxis.axis >= 2 && e.jaxis.axis <= 4 ) // joy 1 axes 2-4 = gyroscope Com_QueueEvent( 0, SE_GYROSCOPE, e.jaxis.axis - 2, e.jaxis.value, 0, NULL ); if( e.jaxis.which == JOY_SDL_GYROSCOPE && e.jaxis.axis >= 5 && e.jaxis.axis <= 7 ) // joy 1 axes 5-7 = accelerometer Com_QueueEvent( 0, SE_ACCELEROMETER, e.jaxis.axis - 5, e.jaxis.value, 0, NULL ); if( e.jaxis.which == JOY_SDL_GAMEPAD && e.jaxis.axis < 6 ) // joy 2-5 = gamepad { Com_QueueEvent( 0, SE_JOYSTICK_AXIS, e.jaxis.axis + JOY_AXIS_GAMEPADLEFT_X, e.jaxis.value, 0, NULL ); if ( !hideScreenKeys && e.jaxis.axis == JOY_AXIS_GAMEPADRIGHT_X - JOY_AXIS_GAMEPADLEFT_X && abs(e.jaxis.value) > 20000 ) { hideScreenKeys = qtrue; #ifdef __ANDROID__ SDL_Rect rect; rect.x = rect.y = rect.w = rect.h = 0; SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_4, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_5, &rect); // Do not hide text input, we don't have gamepad key to invoke it rect.w = rect.h = cls.glconfig.vidHeight / 10; rect.x = rect.y = 0; SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, &rect); #endif } } } break; case SDL_JOYBUTTONDOWN: // Android multitouch case SDL_JOYBUTTONUP: { if( e.jbutton.which == JOY_SDL_TOUCHSCREEN && e.jbutton.button < MAX_POINTERS ) { touchPointers[e.jbutton.button].pressed = (e.jbutton.state == SDL_PRESSED); IN_ProcessTouchPoints(); } } break; case SDL_JOYBALLMOTION: // Android multitouch { if( e.jaxis.which == JOY_SDL_TOUCHSCREEN && e.jball.ball < MAX_POINTERS ) { int i; touchPointers[e.jball.ball].x = e.jball.xrel; touchPointers[e.jball.ball].y = e.jball.yrel; if (cl_runningOnOuya->integer) { touchPointers[e.jball.ball].x = touchPointers[e.jball.ball].x * cls.glconfig.vidWidth / (cls.glconfig.vidWidth - cls.glconfig.vidWidth * OUYA_BORDER / 100 * 3 / 2) - cls.glconfig.vidWidth * OUYA_BORDER / 100; touchPointers[e.jball.ball].y = touchPointers[e.jball.ball].y * cls.glconfig.vidHeight / (cls.glconfig.vidHeight - cls.glconfig.vidHeight * OUYA_BORDER / 100 * 3 / 2) - cls.glconfig.vidHeight * OUYA_BORDER / 100; } if( e.jball.ball == filteredTouch[0].idx ) Com_QueueEvent( 0, SE_MOUSE, touchPointers[e.jball.ball].x, touchPointers[e.jball.ball].y, 0, NULL ); if( e.jball.ball == filteredTouch[1].idx ) Com_QueueEvent( 0, SE_MOUSE2, touchPointers[e.jball.ball].x, touchPointers[e.jball.ball].y, 0, NULL ); } } break; case SDL_QUIT: Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n"); break; case SDL_VIDEORESIZE: { char width[32], height[32]; Com_sprintf( width, sizeof(width), "%d", e.resize.w ); Com_sprintf( height, sizeof(height), "%d", e.resize.h ); Cvar_Set( "r_customwidth", width ); Cvar_Set( "r_customheight", height ); Cvar_Set( "r_mode", "-1" ); /* wait until user stops dragging for 1 second, so we aren't constantly recreating the GL context while he tries to drag...*/ vidRestartTime = Sys_Milliseconds() + 1000; #ifdef __ANDROID__ vidRestartTime = Sys_Milliseconds(); #endif } break; case SDL_ACTIVEEVENT: if (e.active.state & SDL_APPINPUTFOCUS) { Cvar_SetValue( "com_unfocused", !e.active.gain); } if (e.active.state & SDL_APPACTIVE) { Cvar_SetValue( "com_minimized", !e.active.gain); } break; default: break; } } if( deferredTouch > 0 ) { deferredTouch --; if( !deferredTouch ) Com_QueueEvent( 0, SE_KEY, K_MOUSE1, qtrue, 0, NULL ); } }
static void IN_HandleEvents( void ) { Uint16 *wtext = NULL; SDL_PumpEvents(); SDL_Event event; while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_KEYDOWN: key_event( &event.key, true ); // Emulate copy/paste #if defined( __APPLE__ ) #define KEYBOARD_COPY_PASTE_MODIFIER KMOD_GUI #else #define KEYBOARD_COPY_PASTE_MODIFIER KMOD_CTRL #endif if( event.key.keysym.sym == SDLK_c ) { if( event.key.keysym.mod & KEYBOARD_COPY_PASTE_MODIFIER ) { Key_CharEvent( KC_CTRLC, KC_CTRLC ); } } else if( event.key.keysym.sym == SDLK_v ) { if( event.key.keysym.mod & KEYBOARD_COPY_PASTE_MODIFIER ) { Key_CharEvent( KC_CTRLV, KC_CTRLV ); } } break; case SDL_KEYUP: key_event( &event.key, false ); break; case SDL_TEXTINPUT: // SDL_iconv_utf8_ucs2 uses "UCS-2-INTERNAL" as tocode and fails to convert text on Linux // where SDL_iconv uses system iconv. So we force needed encoding directly #if SDL_BYTEORDER == SDL_LIL_ENDIAN #define UCS_2_INTERNAL "UCS-2LE" #else #define UCS_2_INTERNAL "UCS-2BE" #endif wtext = (Uint16 *)SDL_iconv_string( UCS_2_INTERNAL, "UTF-8", event.text.text, SDL_strlen( event.text.text ) + 1 ); if( wtext ) { wchar_t charkey = wtext[0]; int key = ( charkey <= 255 ) ? charkey : 0; Key_CharEvent( key, charkey ); SDL_free( wtext ); } break; case SDL_MOUSEMOTION: mouse_motion_event( &event.motion ); break; case SDL_MOUSEBUTTONDOWN: mouse_button_event( &event.button, true ); break; case SDL_MOUSEBUTTONUP: mouse_button_event( &event.button, false ); break; case SDL_MOUSEWHEEL: mouse_wheel_event( &event.wheel ); break; case SDL_QUIT: Cbuf_ExecuteText( EXEC_NOW, "quit" ); break; case SDL_WINDOWEVENT: switch( event.window.event ) { case SDL_WINDOWEVENT_SHOWN: AppActivate( true ); break; case SDL_WINDOWEVENT_HIDDEN: AppActivate( false ); break; case SDL_WINDOWEVENT_CLOSE: break; case SDL_WINDOWEVENT_FOCUS_GAINED: input_focus = true; break; case SDL_WINDOWEVENT_FOCUS_LOST: input_focus = false; break; case SDL_WINDOWEVENT_MOVED: // FIXME: move this somewhere else Cvar_SetValue( "vid_xpos", event.window.data1 ); Cvar_SetValue( "vid_ypos", event.window.data2 ); vid_xpos->modified = false; vid_ypos->modified = false; break; } break; } } }
static void ApplyChanges(void *unused) { qboolean restart = false; /* custom mode */ if (s_mode_list.curvalue != CUSTOM_MODE) { /* Restarts automatically */ Cvar_SetValue("gl_mode", s_mode_list.curvalue); } else { /* Restarts automatically */ Cvar_SetValue("gl_mode", -1); } /* horplus */ if (s_aspect_list.curvalue == 0) { if (horplus->value != 1) { Cvar_SetValue("horplus", 1); } } else { if (horplus->value != 0) { Cvar_SetValue("horplus", 0); } } /* fov */ if (s_aspect_list.curvalue == 0 || s_aspect_list.curvalue == 1) { if (fov->value != 90) { /* Restarts automatically */ Cvar_SetValue("fov", 90); } } else if (s_aspect_list.curvalue == 2) { if (fov->value != 86) { /* Restarts automatically */ Cvar_SetValue("fov", 86); } } else if (s_aspect_list.curvalue == 3) { if (fov->value != 100) { /* Restarts automatically */ Cvar_SetValue("fov", 100); } } else if (s_aspect_list.curvalue == 4) { if (fov->value != 106) { /* Restarts automatically */ Cvar_SetValue("fov", 106); } } /* Restarts automatically */ Cvar_SetValue("vid_fullscreen", s_fs_box.curvalue); /* vertical sync */ if (gl_swapinterval->value != s_vsync_list.curvalue) { Cvar_SetValue("gl_swapinterval", s_vsync_list.curvalue); restart = true; } /* multisample anti-aliasing */ if (s_msaa_list.curvalue == 0) { if (gl_msaa_samples->value != 0) { Cvar_SetValue("gl_msaa_samples", 0); restart = true; } } else { if (gl_msaa_samples->value != pow(2, s_msaa_list.curvalue)) { Cvar_SetValue("gl_msaa_samples", pow(2, s_msaa_list.curvalue)); restart = true; } } if (restart) { Cbuf_AddText("vid_restart\n"); } M_ForceMenuOff(); }
/* SCR_CalcRefdef Must be called whenever vid changes Internal use only */ static void SCR_CalcRefdef (void) { vrect_t vrect; float size; int h; qboolean full = false; scr_fullupdate = 0; // force a background redraw vid.recalc_refdef = 0; // force the status bar to redraw Sbar_Changed (); //======================================== // bound viewsize Cvar_SetValue (scr_viewsize, bound (30, scr_viewsize->int_val, 120)); // bound field of view Cvar_SetValue (scr_fov, bound (10, scr_fov->value, 170)); if (scr_viewsize->int_val >= 120) sb_lines = 0; // no status bar at all else if (scr_viewsize->int_val >= 110) sb_lines = 24; // no inventory else sb_lines = 24 + 16 + 8; if (scr_viewsize->int_val >= 100) { full = true; size = 100.0; } else { size = scr_viewsize->int_val; } // intermission is always full screen if (cl.intermission) { full = true; size = 100.0; sb_lines = 0; } size /= 100.0; if (!cl_sbar->int_val && full) h = vid.height; else h = vid.height - sb_lines; r_refdef.vrect.width = vid.width * size + 0.5; if (r_refdef.vrect.width < 96) { size = 96.0 / r_refdef.vrect.width; r_refdef.vrect.width = 96; // min for icons } r_refdef.vrect.height = vid.height * size + 0.5; if (cl_sbar->int_val || !full) { if (r_refdef.vrect.height > vid.height - sb_lines) r_refdef.vrect.height = vid.height - sb_lines; } else if (r_refdef.vrect.height > vid.height) r_refdef.vrect.height = vid.height; r_refdef.vrect.x = (vid.width - r_refdef.vrect.width) / 2; if (full) r_refdef.vrect.y = 0; else r_refdef.vrect.y = (h - r_refdef.vrect.height) / 2; r_refdef.fov_x = scr_fov->int_val; r_refdef.fov_y = CalcFov (r_refdef.fov_x, r_refdef.vrect.width, r_refdef.vrect.height); scr_vrect = r_refdef.vrect; // these calculations mirror those in R_Init() for r_refdef, but take no // account of water warping vrect.x = 0; vrect.y = 0; vrect.width = vid.width; vrect.height = vid.height; R_SetVrect (&vrect, &scr_vrect, sb_lines); // guard against going from one mode to another that's less than half the // vertical resolution if (scr_con_current > vid.height) scr_con_current = vid.height; // notify the refresh of the change R_ViewChanged (&vrect, sb_lines, vid.aspect); }
/* SCR_SizeDown_f Keybinding command */ void SCR_SizeDown_f (void) { Cvar_SetValue (scr_viewsize, scr_viewsize->int_val - 10); vid.recalc_refdef = 1; }
void CL_Frame ( int msec,float fractionMsec ) { if ( !com_cl_running->integer ) { return; } // load the ref / cgame if needed CL_StartHunkUsers(); if ( cls.state == CA_DISCONNECTED && !( Key_GetCatcher( ) & KEYCATCH_UI ) && !com_sv_running->integer ) { // if disconnected, bring up the menu if (!CL_CheckPendingCinematic()) // this avoid having the menu flash for one frame before pending cinematics { UI_SetActiveMenu( "mainMenu",NULL ); } } // if recording an avi, lock to a fixed fps if ( cl_avidemo->integer ) { // save the current screen if ( cls.state == CA_ACTIVE ) { if (cl_avidemo->integer > 0) { Cbuf_ExecuteText( EXEC_NOW, "screenshot silent\n" ); } else { Cbuf_ExecuteText( EXEC_NOW, "screenshot_tga silent\n" ); } } // fixed time for next frame if (cl_avidemo->integer > 0) { msec = 1000 / cl_avidemo->integer; } else { msec = 1000 / -cl_avidemo->integer; } } // save the msec before checking pause cls.realFrametime = msec; // decide the simulation time cls.frametime = msec; if(cl_framerate->integer) { avgFrametime+=msec; char mess[256]; if(!(frameCount&0x1f)) { sprintf(mess,"Frame rate=%f\n\n",1000.0f*(1.0/(avgFrametime/32.0f))); // OutputDebugString(mess); Com_Printf(mess); avgFrametime=0.0f; } frameCount++; } cls.frametimeFraction=fractionMsec; cls.realtime += msec; cls.realtimeFraction+=fractionMsec; if (cls.realtimeFraction>=1.0f) { if (cl_newClock&&cl_newClock->integer) { cls.realtime++; } cls.realtimeFraction-=1.0f; } if ( cl_timegraph->integer ) { SCR_DebugGraph ( cls.realFrametime * 0.25, 0 ); } // see if we need to update any userinfo CL_CheckUserinfo(); // if we haven't gotten a packet in a long time, // drop the connection CL_CheckTimeout(); // send intentions now CL_SendCmd(); // resend a connection request if necessary CL_CheckForResend(); // decide on the serverTime to render CL_SetCGameTime(); if (cl_pano->integer && cls.state == CA_ACTIVE) { //grab some panoramic shots int i = 1; int pref = cl_pano->integer; int oldnoprint = cl_noprint->integer; Con_Close(); cl_noprint->integer = 1; //hide the screen shot msgs for (; i <= cl_panoNumShots->integer; i++) { Cvar_SetValue( "pano", i ); SCR_UpdateScreen();// update the screen Cbuf_ExecuteText( EXEC_NOW, va("screenshot %dpano%02d\n", pref, i) ); //grab this screen } Cvar_SetValue( "pano", 0 ); //done cl_noprint->integer = oldnoprint; } if (cl_skippingcin->integer && !cl_endcredits->integer && !com_developer->integer ) { if (cl_skippingcin->modified){ S_StopSounds(); //kill em all but music cl_skippingcin->modified=qfalse; Com_Printf (S_COLOR_YELLOW "%s", SE_GetString("CON_TEXT_SKIPPING")); SCR_UpdateScreen(); } } else { // update the screen SCR_UpdateScreen(); } // update audio S_Update(); // advance local effects for next frame SCR_RunCinematic(); Con_RunConsole(); cls.framecount++; }
/* =============== IN_ProcessEvents =============== */ static void IN_ProcessEvents( void ) { SDL_Event e; keyNum_t key = 0; static keyNum_t lastKeyDown = 0; if( !SDL_WasInit( SDL_INIT_VIDEO ) ) return; while( SDL_PollEvent( &e ) ) { switch( e.type ) { case SDL_KEYDOWN: if ( e.key.repeat && Key_GetCatcher( ) == 0 ) break; if( ( key = IN_TranslateSDLToQ3Key( &e.key.keysym, qtrue ) ) ) Com_QueueEvent( 0, SE_KEY, key, qtrue, 0, NULL ); if( key == K_BACKSPACE ) Com_QueueEvent( 0, SE_CHAR, CTRL('h'), 0, 0, NULL ); else if( keys[K_CTRL].down && key >= 'a' && key <= 'z' ) Com_QueueEvent( 0, SE_CHAR, CTRL(key), 0, 0, NULL ); lastKeyDown = key; break; case SDL_KEYUP: if( ( key = IN_TranslateSDLToQ3Key( &e.key.keysym, qfalse ) ) ) Com_QueueEvent( 0, SE_KEY, key, qfalse, 0, NULL ); lastKeyDown = 0; break; case SDL_TEXTINPUT: if( lastKeyDown != K_CONSOLE ) { char *c = e.text.text; // Quick and dirty UTF-8 to UTF-32 conversion while( *c ) { int utf32 = 0; if( ( *c & 0x80 ) == 0 ) utf32 = *c++; else if( ( *c & 0xE0 ) == 0xC0 ) // 110x xxxx { utf32 |= ( *c++ & 0x1F ) << 6; utf32 |= ( *c++ & 0x3F ); } else if( ( *c & 0xF0 ) == 0xE0 ) // 1110 xxxx { utf32 |= ( *c++ & 0x0F ) << 12; utf32 |= ( *c++ & 0x3F ) << 6; utf32 |= ( *c++ & 0x3F ); } else if( ( *c & 0xF8 ) == 0xF0 ) // 1111 0xxx { utf32 |= ( *c++ & 0x07 ) << 18; utf32 |= ( *c++ & 0x3F ) << 12; utf32 |= ( *c++ & 0x3F ) << 6; utf32 |= ( *c++ & 0x3F ); } else { Com_DPrintf( "Unrecognised UTF-8 lead byte: 0x%x\n", (unsigned int)*c ); c++; } if( utf32 != 0 ) { if( IN_IsConsoleKey( 0, utf32 ) ) { Com_QueueEvent( 0, SE_KEY, K_CONSOLE, qtrue, 0, NULL ); Com_QueueEvent( 0, SE_KEY, K_CONSOLE, qfalse, 0, NULL ); } else Com_QueueEvent( 0, SE_CHAR, utf32, 0, 0, NULL ); } } } break; case SDL_MOUSEMOTION: if( mouseActive ) { if( !e.motion.xrel && !e.motion.yrel ) break; Com_QueueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL ); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { int b; switch( e.button.button ) { case SDL_BUTTON_LEFT: b = K_MOUSE1; break; case SDL_BUTTON_MIDDLE: b = K_MOUSE3; break; case SDL_BUTTON_RIGHT: b = K_MOUSE2; break; case SDL_BUTTON_X1: b = K_MOUSE4; break; case SDL_BUTTON_X2: b = K_MOUSE5; break; default: b = K_AUX1 + ( e.button.button - SDL_BUTTON_X2 + 1 ) % 16; break; } Com_QueueEvent( 0, SE_KEY, b, ( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL ); } break; case SDL_MOUSEWHEEL: if( e.wheel.y > 0 ) { Com_QueueEvent( 0, SE_KEY, K_MWHEELUP, qtrue, 0, NULL ); Com_QueueEvent( 0, SE_KEY, K_MWHEELUP, qfalse, 0, NULL ); } else if( e.wheel.y < 0 ) { Com_QueueEvent( 0, SE_KEY, K_MWHEELDOWN, qtrue, 0, NULL ); Com_QueueEvent( 0, SE_KEY, K_MWHEELDOWN, qfalse, 0, NULL ); } break; case SDL_QUIT: Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n"); break; case SDL_WINDOWEVENT: switch( e.window.event ) { case SDL_WINDOWEVENT_RESIZED: { int width, height; width = e.window.data1; height = e.window.data2; // check if size actually changed if( cls.glconfig.vidWidth == width && cls.glconfig.vidHeight == height ) { break; } Cvar_SetValue( "r_customwidth", width ); Cvar_SetValue( "r_customheight", height ); Cvar_Set( "r_mode", "-1" ); // Wait until user stops dragging for 1 second, so // we aren't constantly recreating the GL context while // he tries to drag... vidRestartTime = Sys_Milliseconds( ) + 1000; } break; case SDL_WINDOWEVENT_MINIMIZED: Cvar_SetValue( "com_minimized", 1 ); break; case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_MAXIMIZED: Cvar_SetValue( "com_minimized", 0 ); break; case SDL_WINDOWEVENT_FOCUS_LOST: Cvar_SetValue( "com_unfocused", 1 ); break; case SDL_WINDOWEVENT_FOCUS_GAINED: Cvar_SetValue( "com_unfocused", 0 ); break; } break; default: break; } } }
//----------------------------------------------------------------------------- // Name: CommunicatorStatusUpdate // Desc: XHV Callback - called when the engine detects that the status of a // communicator has changed. May not be called if a communicator // is quickly removed and re-inserted, but in that case there is // nothing the game has to do. //----------------------------------------------------------------------------- HRESULT CVoiceManager::CommunicatorStatusUpdate( DWORD dwPort, XHV_VOICE_COMMUNICATOR_STATUS status ) { // If we're not initialized, then do nothing if( !m_bInitialized ) return S_OK; if( status == XHV_VOICE_COMMUNICATOR_STATUS_INSERTED ) { // Got a new headset: // Let the UI know that we have a headset, so it can enable things! Cvar_SetValue( "ui_headset", 1 ); // Awful UI hack. If we're on the online options screen, move off any item // that just became disabled. menuDef_t *menu = Menu_GetFocused(); if( menu && !Q_stricmp(menu->window.name, "xbl_onlineoptions") ) { VM_Call( uivm, UI_KEY_EVENT, A_CURSOR_DOWN, qtrue ); // Send a "move the cursor down" // Also, if we had "Speakers" selected, switch it to "Enabled" if( Cvar_VariableIntegerValue( "ui_voiceMode" ) == 1 ) Cvar_SetValue( "ui_voiceMode", 2 ); } // Always re-route voice to headset m_XHVVoiceManager.SetVoiceThroughSpeakers( FALSE ); // Don't do anything else if banned, or voice is disabled: if( m_bVoiceDisabled || (logged_on && !XOnlineIsUserVoiceAllowed( XBLLoggedOnUsers[ IN_GetMainController() ].xuid.dwUserFlags ) ) ) return S_OK; // If we're logged onto live, update our voice flag if( logged_on ) XBL_F_SetState( XONLINE_FRIENDSTATE_FLAG_VOICE, true ); // Finally, if we're in a session, update our status and tell everyone: if( m_bRunning ) { xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags |= VOICE_CAN_RECV; xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags |= VOICE_CAN_SEND; SendVoiceInfo( VOICEINFO_HAVEVOICE, NULL ); } } else if( status == XHV_VOICE_COMMUNICATOR_STATUS_REMOVED ) { // Lost a headset: // Let the UI know that we don't have a headset, so it can disable things! Cvar_SetValue( "ui_headset", 0 ); // Awful UI hack. If we're on the online options screen, move off any item // that just became disabled. menuDef_t *menu = Menu_GetFocused(); if( menu && !Q_stricmp(menu->window.name, "xbl_onlineoptions") ) { VM_Call( uivm, UI_KEY_EVENT, A_CURSOR_UP, qtrue ); // Send a "move the cursor up" // Also, if we had "Enabled" selected, that's no longer valid. Change ui_voiceMode: if( Cvar_VariableIntegerValue( "ui_voiceMode" ) == 2 ) Cvar_SetValue( "ui_voiceMode", 1 ); } // If the user pulls the headset and it was set to "speakers" or "enabled", // then change to "speakers" m_XHVVoiceManager.SetVoiceThroughSpeakers( !m_bVoiceDisabled ); // Don't do anything else if banned, or voice is disabled: if( m_bVoiceDisabled || (logged_on && !XOnlineIsUserVoiceAllowed( XBLLoggedOnUsers[ IN_GetMainController() ].xuid.dwUserFlags ) ) ) return S_OK; // If we're logged onto live, update our voice flag if( logged_on ) XBL_F_SetState( XONLINE_FRIENDSTATE_FLAG_VOICE, false ); // Finally, if we're in a session, update our status and tell everyone: if( m_bRunning ) { xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags |= VOICE_CAN_RECV; xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags &= ~VOICE_CAN_SEND; SendVoiceInfo( VOICEINFO_SPEAKERS, NULL ); } } return S_OK; }
static void WalkFunc (void *unused ) { float temp = s_options_vr_walkspeed_slider.curvalue / 10.0; temp += 0.5; Cvar_SetValue("vr_walkspeed",temp); }
void SV_LoadGame_f (void) { extern cvar_t sv_progtype; char name[MAX_OSPATH], mapname[MAX_QPATH], str[32 * 1024], *start; FILE *f; float time, tfloat, spawn_parms[NUM_SPAWN_PARMS]; edict_t *ent; int entnum, version, r; unsigned int i; if (Cmd_Argc() != 2) { Com_Printf ("Usage: %s <savename> : load a game\n", Cmd_Argv(0)); return; } snprintf (name, sizeof (name), "%s/save/%s", com_gamedir, Cmd_Argv(1)); COM_DefaultExtension (name, ".sav"); Com_Printf ("Loading game from %s...\n", name); if (!(f = fopen (name, "rb"))) { Com_Printf ("ERROR: couldn't open.\n"); return; } if (fscanf (f, "%i\n", &version) != 1) { fclose (f); Com_Printf ("Error reading savegame data\n"); return; } if (version != SAVEGAME_VERSION) { fclose (f); Com_Printf ("Savegame is version %i, not %i\n", version, SAVEGAME_VERSION); return; } if (fscanf (f, "%s\n", str) != 1) { fclose (f); Com_Printf ("Error reading savegame data\n"); return; } for (i = 0; i < NUM_SPAWN_PARMS; i++) { if (fscanf (f, "%f\n", &spawn_parms[i]) != 1) { fclose (f); Com_Printf ("Error reading savegame data\n"); return; } } // this silliness is so we can load 1.06 save files, which have float skill values if (fscanf (f, "%f\n", &tfloat) != 1) { fclose (f); Com_Printf ("Error reading savegame data\n"); return; } current_skill = (int)(tfloat + 0.1); Cvar_Set (&skill, va("%i", current_skill)); Cvar_SetValue (&deathmatch, 0); Cvar_SetValue (&coop, 0); Cvar_SetValue (&teamplay, 0); Cvar_SetValue (&maxclients, 1); Cvar_Set (&sv_progsname, "spprogs"); // force progsname #ifdef USE_PR2 Cvar_Set (&sv_progtype, "0"); // force .dat #endif if (fscanf (f, "%s\n", mapname) != 1) { fclose (f); Com_Printf ("Error reading savegame data\n"); return; } if (fscanf (f, "%f\n", &time) != 1) { fclose (f); Com_Printf ("Error reading savegame data\n"); return; } Host_EndGame(); CL_BeginLocalConnection (); SV_SpawnServer (mapname, false); if (sv.state != ss_active) { Com_Printf ("Couldn't load map\n"); fclose (f); return; } // load the light styles for (i = 0; i < MAX_LIGHTSTYLES; i++) { if (fscanf (f, "%s\n", str) != 1) { Com_Printf("Couldn't read lightstyles\n"); fclose (f); return; } sv.lightstyles[i] = (char *) Hunk_Alloc (strlen(str) + 1); strlcpy (sv.lightstyles[i], str, strlen(str) + 1); } // pause until all clients connect if (!(sv.paused & 1)) SV_TogglePause (NULL, 1); sv.loadgame = true; // load the edicts out of the savegame file entnum = -1; // -1 is the globals while (!feof(f)) { for (i = 0; i < sizeof(str) - 1; i++) { r = fgetc (f); if (r == EOF || !r) break; str[i] = r; if (r == '}') { i++; break; } } if (i == sizeof(str)-1) Host_Error ("Loadgame buffer overflow"); str[i] = 0; start = str; start = COM_Parse(str); if (!com_token[0]) break; // end of file if (strcmp(com_token,"{")) Host_Error ("First token isn't a brace"); if (entnum == -1) { // parse the global vars ED_ParseGlobals (start); } else { // parse an edict ent = EDICT_NUM(entnum); memset (&ent->v, 0, progs->entityfields * 4); ent->e->free = false; ED_ParseEdict (start, ent); // link it into the bsp tree if (!ent->e->free) SV_LinkEdict (ent, false); } entnum++; } sv.num_edicts = entnum; sv.time = time; fclose (f); for (i = 0; i < NUM_SPAWN_PARMS; i++) svs.clients->spawn_parms[i] = spawn_parms[i]; }
/* * Input event processing */ void IN_GetEvent(SDL_Event *event) { unsigned int key; switch (event->type) { /* The mouse wheel */ case SDL_MOUSEBUTTONDOWN: if (event->button.button == 4) { keyq[keyq_head].key = K_MWHEELUP; keyq[keyq_head].down = true; keyq_head = (keyq_head + 1) & 127; keyq[keyq_head].key = K_MWHEELUP; keyq[keyq_head].down = false; keyq_head = (keyq_head + 1) & 127; } else if (event->button.button == 5) { keyq[keyq_head].key = K_MWHEELDOWN; keyq[keyq_head].down = true; keyq_head = (keyq_head + 1) & 127; keyq[keyq_head].key = K_MWHEELDOWN; keyq[keyq_head].down = false; keyq_head = (keyq_head + 1) & 127; } break; case SDL_MOUSEBUTTONUP: break; /* The user pressed a button */ case SDL_KEYDOWN: /* Fullscreen switch via Alt-Return */ if ((KeyStates[SDLK_LALT] || KeyStates[SDLK_RALT]) && (event->key.keysym.sym == SDLK_RETURN)) { SDL_WM_ToggleFullScreen(surface); if (surface->flags & SDL_FULLSCREEN) { Cvar_SetValue("vid_fullscreen", 1); } else { Cvar_SetValue("vid_fullscreen", 0); } vid_fullscreen->modified = false; break; } /* Make Shift+Escape toggle the console. This really belongs in Key_Event(), but since Key_ClearStates() can mess up the internal K_SHIFT state let's do it here instead. */ if ((KeyStates[SDLK_LSHIFT] || KeyStates[SDLK_RSHIFT]) && (event->key.keysym.sym == SDLK_ESCAPE)) { Cbuf_ExecuteText(EXEC_NOW, "toggleconsole"); break; } KeyStates[event->key.keysym.sym] = 1; /* Get the pressed key and add it to the key list */ key = IN_TranslateSDLtoQ2Key(event->key.keysym.sym); if (key) { keyq[keyq_head].key = key; keyq[keyq_head].down = true; keyq_head = (keyq_head + 1) & 127; } break; /* The user released a key */ case SDL_KEYUP: if (KeyStates[event->key.keysym.sym]) { KeyStates[event->key.keysym.sym] = 0; /* Get the pressed key and remove it from the key list */ key = IN_TranslateSDLtoQ2Key(event->key.keysym.sym); if (key) { keyq[keyq_head].key = key; keyq[keyq_head].down = false; keyq_head = (keyq_head + 1) & 127; } } break; } }
qboolean SNDDMA_Init(void) { ALconfig ac = NULL; ALpv pvbuf[2]; s_loadas8bit = Cvar_Get("s_loadas8bit", "16", CVAR_ARCHIVE); if ((int)s_loadas8bit->value) dma.samplebits = 8; else dma.samplebits = 16; if (dma.samplebits != 16) { Com_Printf("Don't currently support %i-bit data. Forcing 16-bit.\n", dma.samplebits); dma.samplebits = 16; Cvar_SetValue( "s_loadas8bit", false ); } s_khz = Cvar_Get("s_khz", "0", CVAR_ARCHIVE); switch ((int)s_khz->value) { case 48: dma.speed = AL_RATE_48000; break; case 44: dma.speed = AL_RATE_44100; break; case 32: dma.speed = AL_RATE_32000; break; case 22: dma.speed = AL_RATE_22050; break; case 16: dma.speed = AL_RATE_16000; break; case 11: dma.speed = AL_RATE_11025; break; case 8: dma.speed = AL_RATE_8000; break; default: dma.speed = AL_RATE_22050; Com_Printf("Don't currently support %i kHz sample rate. Using %i.\n", (int)s_khz->value, (int)(dma.speed/1000)); } sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE); dma.channels = (int)sndchannels->value; if (dma.channels != 2) Com_Printf("Don't currently support %i sound channels. Try 2.\n", sndchannels); /***********************/ ac = alNewConfig(); alSetChannels( ac, AL_STEREO ); alSetSampFmt( ac, AL_SAMPFMT_TWOSCOMP ); alSetQueueSize( ac, QSND_BUFFER_FRAMES ); if (dma.samplebits == 8) alSetWidth( ac, AL_SAMPLE_8 ); else alSetWidth( ac, AL_SAMPLE_16 ); sgisnd_aport = alOpenPort( "Quake", "w", ac ); if (!sgisnd_aport) { printf( "failed to open audio port!\n" ); } // set desired sample rate pvbuf[0].param = AL_MASTER_CLOCK; pvbuf[0].value.i = AL_CRYSTAL_MCLK_TYPE; pvbuf[1].param = AL_RATE; pvbuf[1].value.ll = alIntToFixed( dma.speed ); alSetParams( alGetResource( sgisnd_aport ), pvbuf, 2 ); if (pvbuf[1].sizeOut < 0) printf( "illegal sample rate %d\n", dma.speed ); sgisnd_frames_per_ns = dma.speed * 1.0e-9; dma.samples = sizeof(dma_buffer)/(dma.samplebits/8); dma.submission_chunk = 1; dma.buffer = (unsigned char *)dma_buffer; dma.samplepos = 0; alFreeConfig( ac ); return true; }
/* =============== IN_Init =============== */ void IN_Init( void ) { int appState; if( !SDL_WasInit( SDL_INIT_VIDEO ) ) { Com_Error( ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )" ); return; } Com_DPrintf( "\n------- Input Initialization -------\n" ); in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_ARCHIVE ); // mouse variables in_mouse = Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE ); in_nograb = Cvar_Get( "in_nograb", "0", CVAR_ARCHIVE ); in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH ); in_joystickDebug = Cvar_Get( "in_joystickDebug", "0", CVAR_TEMP ); in_joystickThreshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE ); cg_touchscreenControls = Cvar_Get ("cg_touchscreenControls", "0", CVAR_ARCHIVE); in_gyroscope = Cvar_Get ("in_gyroscope", "1", CVAR_ARCHIVE); #ifdef MACOS_X_ACCELERATION_HACK in_disablemacosxmouseaccel = Cvar_Get( "in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE ); #endif SDL_EnableUNICODE( 1 ); SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); keyRepeatEnabled = qtrue; mouseAvailable = ( in_mouse->value != 0 ); IN_DeactivateMouse( ); appState = SDL_GetAppState( ); Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); IN_InitKeyLockStates( ); IN_InitJoystick( ); #ifdef __ANDROID__ hideScreenKeys = cl_runningOnOuya->integer; if (hideScreenKeys) { // Hide everything SDL_Rect rect; rect.x = rect.y = rect.w = rect.h = 0; SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_4, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_5, &rect); SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_TEXT, &rect); } #endif Com_DPrintf( "------------------------------------\n" ); }
/* =============== IN_ProcessEvents =============== */ static void IN_ProcessEvents( void ) { SDL_Event e; const char *character = NULL; keyNum_t key = 0; if ( !SDL_WasInit( SDL_INIT_VIDEO ) ) { return; } if ( cls.keyCatchers == 0 && keyRepeatEnabled ) { SDL_EnableKeyRepeat( 0, 0 ); keyRepeatEnabled = qfalse; } else if ( !keyRepeatEnabled ) { SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); keyRepeatEnabled = qtrue; } while ( SDL_PollEvent( &e ) ) { switch ( e.type ) { case SDL_KEYDOWN: character = IN_TranslateSDLToQ3Key( &e.key.keysym, &key, qtrue ); if ( key ) { Com_QueueEvent( 0, SE_KEY, key, qtrue, 0, NULL ); } if ( character ) { Com_QueueEvent( 0, SE_CHAR, *character, 0, 0, NULL ); } break; case SDL_KEYUP: IN_TranslateSDLToQ3Key( &e.key.keysym, &key, qfalse ); if ( key ) { Com_QueueEvent( 0, SE_KEY, key, qfalse, 0, NULL ); } break; case SDL_MOUSEMOTION: if ( mouseActive ) { Com_QueueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL ); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { unsigned char b; switch ( e.button.button ) { case 1: b = K_MOUSE1; break; case 2: b = K_MOUSE3; break; case 3: b = K_MOUSE2; break; case 4: b = K_MWHEELUP; break; case 5: b = K_MWHEELDOWN; break; case 6: b = K_MOUSE4; break; case 7: b = K_MOUSE5; break; default: b = K_AUX1 + ( e.button.button - 8 ) % 16; break; } Com_QueueEvent( 0, SE_KEY, b, ( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL ); } break; case SDL_QUIT: Cbuf_ExecuteText( EXEC_NOW, "quit Closed window\n" ); break; case SDL_VIDEORESIZE: { char width[ 32 ], height[ 32 ]; Com_sprintf( width, sizeof( width ), "%d", e.resize.w ); Com_sprintf( height, sizeof( height ), "%d", e.resize.h ); Cvar_Set( "r_customwidth", width ); Cvar_Set( "r_customheight", height ); Cvar_Set( "r_mode", "-1" ); /* wait until user stops dragging for 1 second, so we aren't constantly recreating the GL context while he tries to drag...*/ vidRestartTime = Sys_Milliseconds() + 1000; } break; case SDL_ACTIVEEVENT: if ( e.active.state & SDL_APPINPUTFOCUS ) { Cvar_SetValue( "com_unfocused", !e.active.gain ); } if ( e.active.state & SDL_APPACTIVE ) { Cvar_SetValue( "com_minimized", !e.active.gain ); } break; default: break; } } }
qboolean GLimp_InitGL (void) { PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd 1, // version number PFD_DRAW_TO_WINDOW | // support window PFD_SUPPORT_OPENGL | // support OpenGL PFD_DOUBLEBUFFER, // double buffered PFD_TYPE_RGBA, // RGBA type 32, // 32-bit color depth // was 24 0, 0, 0, 0, 0, 0, // color bits ignored 0, // no alpha buffer 0, // shift bit ignored 0, // no accumulation buffer 0, 0, 0, 0, // accum bits ignored //Knightmare 12/24/2001- stencil buffer 24, // 24-bit z-buffer, was 32 8, // 8-bit stencil buffer //end Knightmare 0, // no auxiliary buffer PFD_MAIN_PLANE, // main layer 0, // reserved 0, 0, 0 // layer masks ignored }; int pixelformat; cvar_t *stereo; stereo = Cvar_Get( "cl_stereo", "0", 0 ); /* ** set PFD_STEREO if necessary */ if ( stereo->value != 0 ) { VID_Printf( PRINT_ALL, "...attempting to use stereo\n" ); pfd.dwFlags |= PFD_STEREO; gl_state.stereo_enabled = true; } else { gl_state.stereo_enabled = false; } /* ** figure out if we're running on a minidriver or not */ if ( strstr( gl_driver->string, "opengl32" ) != 0 ) glw_state.minidriver = false; else glw_state.minidriver = true; /* ** Get a DC for the specified window */ if ( glw_state.hDC != NULL ) VID_Printf( PRINT_ALL, "GLimp_Init() - non-NULL DC exists\n" ); if ( ( glw_state.hDC = GetDC( glw_state.hWnd ) ) == NULL ) { VID_Printf( PRINT_ALL, "GLimp_Init() - GetDC failed\n" ); return false; } if ( glw_state.minidriver ) { if ( (pixelformat = qwglChoosePixelFormat( glw_state.hDC, &pfd)) == 0 ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglChoosePixelFormat failed\n"); return false; } if ( qwglSetPixelFormat( glw_state.hDC, pixelformat, &pfd) == FALSE ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglSetPixelFormat failed\n"); return false; } qwglDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); } else { if ( ( pixelformat = ChoosePixelFormat( glw_state.hDC, &pfd)) == 0 ) { VID_Printf (PRINT_ALL, "GLimp_Init() - ChoosePixelFormat failed\n"); return false; } if ( SetPixelFormat( glw_state.hDC, pixelformat, &pfd) == FALSE ) { VID_Printf (PRINT_ALL, "GLimp_Init() - SetPixelFormat failed\n"); return false; } DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd ); if ( !( pfd.dwFlags & PFD_GENERIC_ACCELERATED ) ) { extern cvar_t *gl_allow_software; if ( gl_allow_software->value ) glw_state.mcd_accelerated = true; else glw_state.mcd_accelerated = false; } else { glw_state.mcd_accelerated = true; } } /* ** report if stereo is desired but unavailable */ if ( !( pfd.dwFlags & PFD_STEREO ) && ( stereo->value != 0 ) ) { VID_Printf( PRINT_ALL, "...failed to select stereo pixel format\n" ); Cvar_SetValue( "cl_stereo", 0 ); gl_state.stereo_enabled = false; } /* ** startup the OpenGL subsystem by creating a context and making ** it current */ if ( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglCreateContext failed\n"); goto fail; } if ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) { VID_Printf (PRINT_ALL, "GLimp_Init() - qwglMakeCurrent failed\n"); goto fail; } if ( !VerifyDriver() ) { VID_Printf( PRINT_ALL, "GLimp_Init() - no hardware acceleration detected.\nPlease install drivers provided by your video card/GPU vendor.\n" ); goto fail; } /* ** print out PFD specifics */ VID_Printf( PRINT_ALL, "PIXELFORMAT: color(%d-bits) Z(%d-bit)\n", ( int ) pfd.cColorBits, ( int ) pfd.cDepthBits ); //Knightmare- Vic's hardware gamma stuff if ( !r_ignorehwgamma->value ) { if( qwglGetDeviceGammaRamp3DFX ) { WORD newramp[3*256]; int j; gl_state.gammaRamp = qwglGetDeviceGammaRamp3DFX ( glw_state.hDC, newramp ); for( j = 0; j < 256; j++ ) { original_ramp[0][j] = newramp[j+0]; original_ramp[1][j] = newramp[j+256]; original_ramp[2][j] = newramp[j+512]; } } else { gl_state.gammaRamp = GetDeviceGammaRamp ( glw_state.hDC, original_ramp ); } } else { gl_state.gammaRamp = false; } if (gl_state.gammaRamp) vid_gamma->modified = true; // moved these to GL_SetDefaultState //gl_state.blend = false; //gl_state.alphaTest = false; //end Knightmare //Knightmare- 12/24/2001- stecil buffer { char buffer[1024]; strcpy( buffer, qglGetString( GL_RENDERER ) ); strlwr( buffer ); if (strstr(buffer, "Voodoo3")) { VID_Printf( PRINT_ALL, "... Voodoo3 has no stencil buffer\n" ); gl_config.have_stencil = false; } else { if (pfd.cStencilBits) { VID_Printf( PRINT_ALL, "... Using stencil buffer\n" ); gl_config.have_stencil = true; // Stencil shadows - MrG } } } //if (pfd.cStencilBits) // gl_config.have_stencil = true; //end Knightmare /* Moved to GL_SetDefaultState in r_glstate.c // Vertex arrays qglEnableClientState (GL_TEXTURE_COORD_ARRAY); qglEnableClientState (GL_VERTEX_ARRAY); qglEnableClientState (GL_COLOR_ARRAY); qglTexCoordPointer (2, GL_FLOAT, sizeof(texCoordArray[0][0]), texCoordArray[0][0]); qglVertexPointer (3, GL_FLOAT, sizeof(vertexArray[0]), vertexArray[0]); qglColorPointer (4, GL_FLOAT, sizeof(colorArray[0]), colorArray[0]); //gl_state.activetmu[0] = true; // end vertex arrays */ return true; fail: if ( glw_state.hGLRC ) { qwglDeleteContext( glw_state.hGLRC ); glw_state.hGLRC = NULL; } if ( glw_state.hDC ) { ReleaseDC( glw_state.hWnd, glw_state.hDC ); glw_state.hDC = NULL; } return false; }
/** * @brief Set node property */ bool UI_NodeSetProperty (uiNode_t* node, const value_t* property, const char* value) { const int specialType = property->type & V_UI_MASK; int result; size_t bytes; switch (specialType) { case V_NOT_UI: /* common type */ result = Com_ParseValue(node, value, property->type, property->ofs, property->size, &bytes); if (result != RESULT_OK) { Com_Printf("UI_NodeSetProperty: Invalid value for property '%s': %s\n", property->string, Com_GetLastParseError()); return false; } UI_Node_PropertyChanged(node, property); return true; case V_UI_CVAR: /* cvar */ switch ((int)property->type) { case V_UI_CVAR: if (Q_strstart(value, "*cvar:")) { char*& b = Com_GetValue<char*>(node, property); UI_FreeStringProperty(b); b = Mem_PoolStrDup(value, ui_dynStringPool, 0); UI_Node_PropertyChanged(node, property); return true; } break; case V_CVAR_OR_FLOAT: { float f; if (Q_strstart(value, "*cvar:")) { char*& b = Com_GetValue<char*>(node, property); UI_FreeStringProperty(b); b = Mem_PoolStrDup(value, ui_dynStringPool, 0); UI_Node_PropertyChanged(node, property); return true; } result = Com_ParseValue(&f, value, V_FLOAT, 0, sizeof(f), &bytes); if (result != RESULT_OK) { Com_Printf("UI_NodeSetProperty: Invalid value for property '%s': %s\n", property->string, Com_GetLastParseError()); return false; } void* const b = Com_GetValue<void*>(node, property); if (char const* const cvar = Q_strstart((char const*)b, "*cvar:")) Cvar_SetValue(cvar, f); else *(float*) b = f; UI_Node_PropertyChanged(node, property); return true; } case V_CVAR_OR_LONGSTRING: case V_CVAR_OR_STRING: { char*& b = Com_GetValue<char*>(node, property); UI_FreeStringProperty(b); b = Mem_PoolStrDup(value, ui_dynStringPool, 0); UI_Node_PropertyChanged(node, property); return true; } } break; case V_UI: switch ((int)property->type) { case V_UI_SPRITEREF: { uiSprite_t* sprite = UI_GetSpriteByName(value); Com_GetValue<uiSprite_t const*>(node, property) = sprite; UI_Node_PropertyChanged(node, property); return true; } } break; } Com_Printf("UI_NodeSetProperty: Unimplemented type for property '%s@%s'\n", UI_GetPath(node), property->string); return false; }
/* ================== SCR_PlayCinematic ================== */ void SCR_PlayCinematic (char *arg) { int width, height; byte *palette; char name[MAX_OSPATH], *dot; int old_khz; // make sure CD isn't playing music CDAudio_Stop(); cl.cinematicframe = 0; dot = strstr (arg, "."); if (dot && !strcmp (dot, ".pcx")) { // static pcx image Com_sprintf (name, sizeof(name), "pics/%s", arg); SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height); cl.cinematicframe = -1; cl.cinematictime = 1; SCR_EndLoadingPlaque (); cls.state = ca_active; if (!cin.pic) { Com_Printf ("%s not found.\n", name); cl.cinematictime = 0; } else { memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette)); Z_Free (palette); } return; } Com_sprintf (name, sizeof(name), "video/%s", arg); FS_FOpenFile (name, &cl.cinematic_file); if (!cl.cinematic_file) { // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name); SCR_FinishCinematic (); cl.cinematictime = 0; // done return; } SCR_EndLoadingPlaque (); cls.state = ca_active; FS_Read (&width, 4, cl.cinematic_file); FS_Read (&height, 4, cl.cinematic_file); cin.width = LittleLong(width); cin.height = LittleLong(height); FS_Read (&cin.s_rate, 4, cl.cinematic_file); cin.s_rate = LittleLong(cin.s_rate); FS_Read (&cin.s_width, 4, cl.cinematic_file); cin.s_width = LittleLong(cin.s_width); FS_Read (&cin.s_channels, 4, cl.cinematic_file); cin.s_channels = LittleLong(cin.s_channels); Huff1TableInit (); // switch up to 22 khz sound if necessary old_khz = Cvar_VariableValue ("s_khz"); if (old_khz != cin.s_rate/1000) { cin.restart_sound = true; Cvar_SetValue ("s_khz", cin.s_rate/1000); CL_Snd_Restart_f (); Cvar_SetValue ("s_khz", old_khz); } cl.cinematicframe = 0; cin.pic = SCR_ReadNextFrame (); cl.cinematictime = Sys_Milliseconds (); }
/* ===================== CL_ParseDownload A download message has been received from the server ===================== */ void CL_ParseDownload(msg_t *msg) { int size; unsigned char data[MAX_MSGLEN]; int block; if (!*cls.downloadTempName) { Com_Printf("Server sending download, but no download was requested\n"); CL_AddReliableCommand("stopdl"); return; } // read the data block = MSG_ReadShort(msg); // www dl // if we haven't acked the download redirect yet if (block == -1) { if (!clc.bWWWDl) { // server is sending us a www download Q_strncpyz(cls.originalDownloadName, cls.downloadName, sizeof(cls.originalDownloadName)); Q_strncpyz(cls.downloadName, MSG_ReadString(msg), sizeof(cls.downloadName)); clc.downloadSize = MSG_ReadLong(msg); clc.downloadFlags = MSG_ReadLong(msg); if (clc.downloadFlags & (1 << DL_FLAG_URL)) { Sys_OpenURL(cls.downloadName, qtrue); Cbuf_ExecuteText(EXEC_APPEND, "quit\n"); CL_AddReliableCommand("wwwdl bbl8r"); // not sure if that's the right msg clc.bWWWDlAborting = qtrue; return; } Cvar_SetValue("cl_downloadSize", clc.downloadSize); Com_DPrintf("Server redirected download: %s\n", cls.downloadName); clc.bWWWDl = qtrue; // activate wwwdl client loop CL_AddReliableCommand("wwwdl ack"); // make sure the server is not trying to redirect us again on a bad checksum if (strstr(clc.badChecksumList, va("@%s", cls.originalDownloadName))) { Com_Printf("refusing redirect to %s by server (bad checksum)\n", cls.downloadName); CL_AddReliableCommand("wwwdl fail"); clc.bWWWDlAborting = qtrue; return; } // make downloadTempName an OS path Q_strncpyz(cls.downloadTempName, FS_BuildOSPath(Cvar_VariableString("fs_homepath"), cls.downloadTempName, ""), sizeof(cls.downloadTempName)); cls.downloadTempName[strlen(cls.downloadTempName) - 1] = '\0'; if (!DL_BeginDownload(cls.downloadTempName, cls.downloadName)) { // setting bWWWDl to false after sending the wwwdl fail doesn't work // not sure why, but I suspect we have to eat all remaining block -1 that the server has sent us // still leave a flag so that CL_WWWDownload is inactive // we count on server sending us a gamestate to start up clean again CL_AddReliableCommand("wwwdl fail"); clc.bWWWDlAborting = qtrue; Com_Printf("Failed to initialize download for '%s'\n", cls.downloadName); } // Check for a disconnected download // we'll let the server disconnect us when it gets the bbl8r message if (clc.downloadFlags & (1 << DL_FLAG_DISCON)) { CL_AddReliableCommand("wwwdl bbl8r"); cls.bWWWDlDisconnected = qtrue; } return; } else { // server keeps sending that message till we ack it, eat and ignore //MSG_ReadLong( msg ); MSG_ReadString(msg); MSG_ReadLong(msg); MSG_ReadLong(msg); return; } } if (!block) { // block zero is special, contains file size clc.downloadSize = MSG_ReadLong(msg); Cvar_SetValue("cl_downloadSize", clc.downloadSize); if (clc.downloadSize < 0) { Com_Error(ERR_DROP, "%s", MSG_ReadString(msg)); return; } } size = MSG_ReadShort(msg); if (size < 0 || size > sizeof(data)) { Com_Error(ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk.", size); return; } MSG_ReadData(msg, data, size); if (clc.downloadBlock != block) { Com_DPrintf("CL_ParseDownload: Expected block %d, got %d\n", clc.downloadBlock, block); return; } // open the file if not opened yet if (!clc.download) { clc.download = FS_SV_FOpenFileWrite(cls.downloadTempName); if (!clc.download) { Com_Printf("Could not create %s\n", cls.downloadTempName); CL_AddReliableCommand("stopdl"); CL_NextDownload(); return; } } if (size) { FS_Write(data, size, clc.download); } CL_AddReliableCommand(va("nextdl %d", clc.downloadBlock)); clc.downloadBlock++; clc.downloadCount += size; // So UI gets access to it Cvar_SetValue("cl_downloadCount", clc.downloadCount); if (!size) // A zero length block means EOF { if (clc.download) { FS_FCloseFile(clc.download); clc.download = 0; // rename the file FS_SV_Rename(cls.downloadTempName, cls.downloadName); } *cls.downloadTempName = *cls.downloadName = 0; Cvar_Set("cl_downloadName", ""); // send intentions now // We need this because without it, we would hold the last nextdl and then start // loading right away. If we take a while to load, the server is happily trying // to send us that last block over and over. // Write it twice to help make sure we acknowledge the download CL_WritePacket(); CL_WritePacket(); // get another file if needed CL_NextDownload(); } }
static void ApplyChanges(void *unused) { qboolean restart = false; if (gl_picmip->value != (3 - s_tq_slider.curvalue)) { Cvar_SetValue("gl_picmip", 3 - s_tq_slider.curvalue); restart = true; } if (gl_ext_palettedtexture->value != s_paletted_texture_box.curvalue) { Cvar_SetValue("gl_ext_palettedtexture", s_paletted_texture_box.curvalue); restart = true; } /* Restarts automatically */ Cvar_SetValue("vid_fullscreen", s_fs_box.curvalue); /* custom mode */ if (s_mode_list.curvalue != CUSTOM_MODE) { /* Restarts automatically */ Cvar_SetValue("gl_mode", s_mode_list.curvalue); } else { /* Restarts automatically */ Cvar_SetValue("gl_mode", -1); } /* horplus */ if (s_aspect_list.curvalue == 0) { if (horplus->value != 1) { Cvar_SetValue("horplus", 1); } } else { if (horplus->value != 0) { Cvar_SetValue("horplus", 0); } } /* fov */ if (s_aspect_list.curvalue == 0 || s_aspect_list.curvalue == 1) { if (fov->value != 90) { /* Restarts automatically */ Cvar_SetValue("fov", 90); } } else if (s_aspect_list.curvalue == 2) { if (fov->value != 86) { /* Restarts automatically */ Cvar_SetValue("fov", 86); } } else if (s_aspect_list.curvalue == 3) { if (fov->value != 100) { /* Restarts automatically */ Cvar_SetValue("fov", 100); } } else if (s_aspect_list.curvalue == 4) { if (fov->value != 106) { /* Restarts automatically */ Cvar_SetValue("fov", 106); } } if (restart) { Cbuf_AddText("vid_restart\n"); } M_ForceMenuOff(); }
/* ===================== CL_ParseDownload A download message has been received from the server ===================== */ void CL_ParseDownload ( msg_t *msg ) { int size; unsigned char data[MAX_MSGLEN]; uint16_t block; if (!*clc.downloadTempName) { Com_Printf("Server sending download, but no download was requested\n"); CL_AddReliableCommand("stopdl", qfalse); return; } // read the data block = MSG_ReadShort ( msg ); if(!block && !clc.downloadBlock) { // block zero is special, contains file size clc.downloadSize = MSG_ReadLong ( msg ); Cvar_SetValue( "cl_downloadSize", clc.downloadSize ); if (clc.downloadSize < 0) { Com_Error( ERR_DROP, "%s", MSG_ReadString( msg ) ); return; } } size = MSG_ReadShort ( msg ); if (size < 0 || size > sizeof(data)) { Com_Error(ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk", size); return; } MSG_ReadData(msg, data, size); if((clc.downloadBlock & 0xFFFF) != block) { Com_DPrintf( "CL_ParseDownload: Expected block %d, got %d\n", (clc.downloadBlock & 0xFFFF), block); return; } // open the file if not opened yet if (!clc.download) { clc.download = FS_SV_FOpenFileWrite( clc.downloadTempName ); if (!clc.download) { Com_Printf( "Could not create %s\n", clc.downloadTempName ); CL_AddReliableCommand("stopdl", qfalse); CL_NextDownload(); return; } } if (size) FS_Write( data, size, clc.download ); CL_AddReliableCommand(va("nextdl %d", clc.downloadBlock), qfalse); clc.downloadBlock++; clc.downloadCount += size; // So UI gets access to it Cvar_SetValue( "cl_downloadCount", clc.downloadCount ); if (!size) { // A zero length block means EOF if (clc.download) { FS_FCloseFile( clc.download ); clc.download = 0; // rename the file FS_SV_Rename ( clc.downloadTempName, clc.downloadName, qfalse ); } // send intentions now // We need this because without it, we would hold the last nextdl and then start // loading right away. If we take a while to load, the server is happily trying // to send us that last block over and over. // Write it twice to help make sure we acknowledge the download CL_WritePacket(); CL_WritePacket(); // get another file if needed CL_NextDownload (); } }
static void IN_ProcessEvents( void ) { SDL_Event e; fakeAscii_t key = A_NULL; static fakeAscii_t lastKeyDown = A_NULL; if( !SDL_WasInit( SDL_INIT_VIDEO ) ) return; while( SDL_PollEvent( &e ) ) { switch( e.type ) { case SDL_KEYDOWN: key = IN_TranslateSDLToJKKey( &e.key.keysym, qtrue ); if ( key != A_NULL ) Sys_QueEvent( 0, SE_KEY, key, qtrue, 0, NULL ); if ( key == A_BACKSPACE ) Sys_QueEvent( 0, SE_CHAR, CTRL('h'), qfalse, 0, NULL); else if ( kg.keys[A_CTRL].down && key >= A_CAP_A && key <= A_CAP_Z ) Sys_QueEvent( 0, SE_CHAR, CTRL(tolower(key)), qfalse, 0, NULL ); lastKeyDown = key; break; case SDL_KEYUP: key = IN_TranslateSDLToJKKey( &e.key.keysym, qfalse ); if( key != A_NULL ) Sys_QueEvent( 0, SE_KEY, key, qfalse, 0, NULL ); lastKeyDown = A_NULL; break; case SDL_TEXTINPUT: if( lastKeyDown != A_CONSOLE ) { char *c = e.text.text; // Quick and dirty UTF-8 to UTF-32 conversion while( *c ) { uint32_t utf32 = ConvertUTF8ToUTF32( c, &c ); if( utf32 != 0 ) { if( IN_IsConsoleKey( A_NULL, utf32 ) ) { Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qtrue, 0, NULL ); Sys_QueEvent( 0, SE_KEY, A_CONSOLE, qfalse, 0, NULL ); } else { uint8_t encoded = ConvertUTF32ToExpectedCharset( utf32 ); Sys_QueEvent( 0, SE_CHAR, encoded, 0, 0, NULL ); } } } } break; case SDL_MOUSEMOTION: if ( mouseActive ) { if ( !e.motion.xrel && !e.motion.yrel ) break; Sys_QueEvent( 0, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL ); } break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: { unsigned short b; switch( e.button.button ) { case SDL_BUTTON_LEFT: b = A_MOUSE1; break; case SDL_BUTTON_MIDDLE: b = A_MOUSE3; break; case SDL_BUTTON_RIGHT: b = A_MOUSE2; break; case SDL_BUTTON_X1: b = A_MOUSE4; break; case SDL_BUTTON_X2: b = A_MOUSE5; break; default: b = A_AUX0 + ( e.button.button - 6 ) % 32; break; } Sys_QueEvent( 0, SE_KEY, b, ( e.type == SDL_MOUSEBUTTONDOWN ? qtrue : qfalse ), 0, NULL ); } break; case SDL_MOUSEWHEEL: if( e.wheel.y > 0 ) { Sys_QueEvent( 0, SE_KEY, A_MWHEELUP, qtrue, 0, NULL ); Sys_QueEvent( 0, SE_KEY, A_MWHEELUP, qfalse, 0, NULL ); } else if( e.wheel.y < 0 ) { Sys_QueEvent( 0, SE_KEY, A_MWHEELDOWN, qtrue, 0, NULL ); Sys_QueEvent( 0, SE_KEY, A_MWHEELDOWN, qfalse, 0, NULL ); } break; case SDL_QUIT: Cbuf_ExecuteText(EXEC_NOW, "quit Closed window\n"); break; case SDL_WINDOWEVENT: switch( e.window.event ) { case SDL_WINDOWEVENT_MINIMIZED: Cvar_SetValue( "com_minimized", 1 ); break; case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_MAXIMIZED: Cvar_SetValue( "com_minimized", 0 ); break; case SDL_WINDOWEVENT_FOCUS_LOST: { Cvar_SetValue( "com_unfocused", 1 ); SNDDMA_Activate( qfalse ); break; } case SDL_WINDOWEVENT_FOCUS_GAINED: { Cvar_SetValue( "com_unfocused", 0 ); SNDDMA_Activate( qtrue ); break; } } break; default: break; } } }
/* ==================== CL_UISystemCalls The ui module is making a system call ==================== */ int CL_UISystemCalls( int *args ) { switch( args[0] ) { //rww - alright, DO NOT EVER add a GAME/CGAME/UI generic call without adding a trap to match, and //all of these traps must be shared and have cases in sv_game, cl_cgame, and cl_ui. They must also //all be in the same order, and start at 100. case TRAP_MEMSET: Com_Memset( VMA(1), args[2], args[3] ); return 0; case TRAP_MEMCPY: Com_Memcpy( VMA(1), VMA(2), args[3] ); return 0; case TRAP_STRNCPY: return (int)strncpy( (char *)VMA(1), (const char *)VMA(2), args[3] ); case TRAP_SIN: return FloatAsInt( sin( VMF(1) ) ); case TRAP_COS: return FloatAsInt( cos( VMF(1) ) ); case TRAP_ATAN2: return FloatAsInt( atan2( VMF(1), VMF(2) ) ); case TRAP_SQRT: return FloatAsInt( sqrt( VMF(1) ) ); case TRAP_MATRIXMULTIPLY: MatrixMultiply( (vec3_t *)VMA(1), (vec3_t *)VMA(2), (vec3_t *)VMA(3) ); return 0; case TRAP_ANGLEVECTORS: AngleVectors( (const float *)VMA(1), (float *)VMA(2), (float *)VMA(3), (float *)VMA(4) ); return 0; case TRAP_PERPENDICULARVECTOR: PerpendicularVector( (float *)VMA(1), (const float *)VMA(2) ); return 0; case TRAP_FLOOR: return FloatAsInt( floor( VMF(1) ) ); case TRAP_CEIL: return FloatAsInt( ceil( VMF(1) ) ); case TRAP_TESTPRINTINT: return 0; case TRAP_TESTPRINTFLOAT: return 0; case TRAP_ACOS: return FloatAsInt( Q_acos( VMF(1) ) ); case TRAP_ASIN: return FloatAsInt( Q_asin( VMF(1) ) ); case UI_ERROR: Com_Error( ERR_DROP, "%s", VMA(1) ); return 0; case UI_PRINT: Com_Printf( "%s", VMA(1) ); return 0; case UI_MILLISECONDS: return Sys_Milliseconds(); case UI_CVAR_REGISTER: Cvar_Register( (vmCvar_t *)VMA(1), (const char *)VMA(2), (const char *)VMA(3), args[4] ); return 0; case UI_CVAR_UPDATE: Cvar_Update( (vmCvar_t *)VMA(1) ); return 0; case UI_CVAR_SET: Cvar_Set( (const char *)VMA(1), (const char *)VMA(2) ); return 0; case UI_CVAR_VARIABLEVALUE: return FloatAsInt( Cvar_VariableValue( (const char *)VMA(1) ) ); case UI_CVAR_VARIABLESTRINGBUFFER: Cvar_VariableStringBuffer( (const char *)VMA(1), (char *)VMA(2), args[3] ); return 0; case UI_CVAR_SETVALUE: Cvar_SetValue( (const char *)VMA(1), VMF(2) ); return 0; case UI_CVAR_RESET: Cvar_Reset( (const char *)VMA(1) ); return 0; case UI_CVAR_CREATE: Cvar_Get( (const char *)VMA(1), (const char *)VMA(2), args[3] ); return 0; case UI_CVAR_INFOSTRINGBUFFER: Cvar_InfoStringBuffer( args[1], (char *)VMA(2), args[3] ); return 0; case UI_ARGC: return Cmd_Argc(); case UI_ARGV: Cmd_ArgvBuffer( args[1], (char *)VMA(2), args[3] ); return 0; case UI_CMD_EXECUTETEXT: Cbuf_ExecuteText( args[1], (const char *)VMA(2) ); return 0; case UI_FS_FOPENFILE: return FS_FOpenFileByMode( (const char *)VMA(1), (int *)VMA(2), (fsMode_t)args[3] ); case UI_FS_READ: FS_Read2( VMA(1), args[2], args[3] ); return 0; case UI_FS_WRITE: FS_Write( VMA(1), args[2], args[3] ); return 0; case UI_FS_FCLOSEFILE: FS_FCloseFile( args[1] ); return 0; case UI_FS_GETFILELIST: return FS_GetFileList( (const char *)VMA(1), (const char *)VMA(2), (char *)VMA(3), args[4] ); case UI_R_REGISTERMODEL: return re.RegisterModel( (const char *)VMA(1) ); case UI_R_REGISTERSKIN: return re.RegisterSkin( (const char *)VMA(1) ); case UI_R_REGISTERSHADERNOMIP: return re.RegisterShaderNoMip( (const char *)VMA(1) ); case UI_R_SHADERNAMEFROMINDEX: { char *gameMem = (char *)VMA(1); const char *retMem = re.ShaderNameFromIndex(args[2]); if (retMem) { strcpy(gameMem, retMem); } else { gameMem[0] = 0; } } return 0; case UI_R_CLEARSCENE: re.ClearScene(); return 0; case UI_R_ADDREFENTITYTOSCENE: re.AddRefEntityToScene( (const refEntity_t *)VMA(1) ); return 0; case UI_R_ADDPOLYTOSCENE: re.AddPolyToScene( args[1], args[2], (const polyVert_t *)VMA(3), 1 ); return 0; case UI_R_ADDLIGHTTOSCENE: re.AddLightToScene( (const float *)VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); return 0; case UI_R_RENDERSCENE: re.RenderScene( (const refdef_t *)VMA(1) ); return 0; case UI_R_SETCOLOR: re.SetColor( (const float *)VMA(1) ); return 0; case UI_R_DRAWSTRETCHPIC: re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); return 0; case UI_R_MODELBOUNDS: re.ModelBounds( args[1], (float *)VMA(2), (float *)VMA(3) ); return 0; case UI_UPDATESCREEN: SCR_UpdateScreen(); return 0; case UI_CM_LERPTAG: re.LerpTag( (orientation_t *)VMA(1), args[2], args[3], args[4], VMF(5), (const char *)VMA(6) ); return 0; case UI_S_REGISTERSOUND: return S_RegisterSound( (const char *)VMA(1) ); case UI_S_STARTLOCALSOUND: S_StartLocalSound( args[1], args[2] ); return 0; case UI_KEY_KEYNUMTOSTRINGBUF: Key_KeynumToStringBuf( args[1], (char *)VMA(2), args[3] ); return 0; case UI_KEY_GETBINDINGBUF: Key_GetBindingBuf( args[1], (char *)VMA(2), args[3] ); return 0; case UI_KEY_SETBINDING: Key_SetBinding( args[1], (const char *)VMA(2) ); return 0; case UI_KEY_ISDOWN: return Key_IsDown( args[1] ); case UI_KEY_GETOVERSTRIKEMODE: return Key_GetOverstrikeMode(); case UI_KEY_SETOVERSTRIKEMODE: Key_SetOverstrikeMode( (qboolean)args[1] ); return 0; case UI_KEY_CLEARSTATES: Key_ClearStates(); return 0; case UI_KEY_GETCATCHER: return Key_GetCatcher(); case UI_KEY_SETCATCHER: Key_SetCatcher( args[1] ); return 0; case UI_GETCLIPBOARDDATA: GetClipboardData( (char *)VMA(1), args[2] ); return 0; case UI_GETCLIENTSTATE: GetClientState( (uiClientState_t *)VMA(1) ); return 0; case UI_GETGLCONFIG: CL_GetGlconfig( (glconfig_t *)VMA(1) ); return 0; case UI_GETCONFIGSTRING: return GetConfigString( args[1], (char *)VMA(2), args[3] ); case UI_MEMORY_REMAINING: return Hunk_MemoryRemaining(); #ifdef USE_CD_KEY case UI_GET_CDKEY: CLUI_GetCDKey( (char *)VMA(1), args[2] ); return 0; case UI_SET_CDKEY: CLUI_SetCDKey( (char *)VMA(1) ); return 0; #endif // USE_CD_KEY case UI_R_REGISTERFONT: return re.RegisterFont( (const char *)VMA(1) ); case UI_R_FONT_STRLENPIXELS: return re.Font_StrLenPixels( (const char *)VMA(1), args[2], VMF(3) ); case UI_R_FONT_STRLENCHARS: return re.Font_StrLenChars( (const char *)VMA(1) ); case UI_R_FONT_STRHEIGHTPIXELS: return re.Font_HeightPixels( args[1], VMF(2) ); case UI_R_FONT_DRAWSTRING: re.Font_DrawString( args[1], args[2], (const char *)VMA(3), (const float *) VMA(4), args[5], args[6], VMF(7) ); return 0; case UI_LANGUAGE_ISASIAN: return re.Language_IsAsian(); case UI_LANGUAGE_USESSPACES: return re.Language_UsesSpaces(); case UI_ANYLANGUAGE_READCHARFROMSTRING: return re.AnyLanguage_ReadCharFromString( (const char *)VMA(1), (int *) VMA(2), (qboolean *) VMA(3) ); case UI_PC_ADD_GLOBAL_DEFINE: return botlib_export->PC_AddGlobalDefine( (char *)VMA(1) ); case UI_PC_LOAD_SOURCE: return botlib_export->PC_LoadSourceHandle( (const char *)VMA(1) ); case UI_PC_FREE_SOURCE: return botlib_export->PC_FreeSourceHandle( args[1] ); case UI_PC_READ_TOKEN: return botlib_export->PC_ReadTokenHandle( args[1], (struct pc_token_s *)VMA(2) ); case UI_PC_SOURCE_FILE_AND_LINE: return botlib_export->PC_SourceFileAndLine( args[1], (char *)VMA(2), (int *)VMA(3) ); case UI_PC_LOAD_GLOBAL_DEFINES: return botlib_export->PC_LoadGlobalDefines ( (char *)VMA(1) ); case UI_PC_REMOVE_ALL_GLOBAL_DEFINES: botlib_export->PC_RemoveAllGlobalDefines ( ); return 0; case UI_S_STOPBACKGROUNDTRACK: S_StopBackgroundTrack(); return 0; case UI_S_STARTBACKGROUNDTRACK: S_StartBackgroundTrack( (const char *)VMA(1), (const char *)VMA(2), qfalse); return 0; case UI_REAL_TIME: return Com_RealTime( (struct qtime_s *)VMA(1) ); case UI_R_REMAP_SHADER: re.RemapShader( (const char *)VMA(1), (const char *)VMA(2), (const char *)VMA(3) ); return 0; #ifdef USE_CD_KEY case UI_VERIFY_CDKEY: return CL_CDKeyValidate((const char *)VMA(1), (const char *)VMA(2)); #endif // USE_CD_KEY case UI_SP_GETNUMLANGUAGES: assert( 0 ); return 0; // return SE_GetNumLanguages(); case UI_SP_GETLANGUAGENAME: assert( 0 ); return 0; case UI_SP_GETSTRINGTEXTSTRING: const char* text; assert(VMA(1)); assert(VMA(2)); text = SE_GetString((const char *) VMA(1)); Q_strncpyz( (char *) VMA(2), text, args[3] ); return qtrue; /* Ghoul2 Insert Start */ /* Ghoul2 Insert Start */ case UI_G2_LISTSURFACES: G2API_ListSurfaces( (CGhoul2Info *) args[1] ); return 0; case UI_G2_LISTBONES: G2API_ListBones( (CGhoul2Info *) args[1], args[2]); return 0; case UI_G2_HAVEWEGHOULMODELS: return G2API_HaveWeGhoul2Models( *((CGhoul2Info_v *)args[1]) ); case UI_G2_SETMODELS: G2API_SetGhoul2ModelIndexes( *((CGhoul2Info_v *)args[1]),(qhandle_t *)VMA(2),(qhandle_t *)VMA(3)); return 0; case UI_G2_GETBOLT: return G2API_GetBoltMatrix(*((CGhoul2Info_v *)args[1]), args[2], args[3], (mdxaBone_t *)VMA(4), (const float *)VMA(5),(const float *)VMA(6), args[7], (qhandle_t *)VMA(8), (float *)VMA(9)); case UI_G2_GETBOLT_NOREC: gG2_GBMNoReconstruct = qtrue; return G2API_GetBoltMatrix(*((CGhoul2Info_v *)args[1]), args[2], args[3], (mdxaBone_t *)VMA(4), (const float *)VMA(5),(const float *)VMA(6), args[7], (qhandle_t *)VMA(8), (float *)VMA(9)); case UI_G2_GETBOLT_NOREC_NOROT: gG2_GBMNoReconstruct = qtrue; gG2_GBMUseSPMethod = qtrue; return G2API_GetBoltMatrix(*((CGhoul2Info_v *)args[1]), args[2], args[3], (mdxaBone_t *)VMA(4), (const float *)VMA(5),(const float *)VMA(6), args[7], (qhandle_t *)VMA(8), (float *)VMA(9)); case UI_G2_INITGHOUL2MODEL: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif return G2API_InitGhoul2Model((CGhoul2Info_v **)VMA(1), (const char *)VMA(2), args[3], (qhandle_t) args[4], (qhandle_t) args[5], args[6], args[7]); case UI_G2_COLLISIONDETECT: return 0; //not supported for ui case UI_G2_ANGLEOVERRIDE: return G2API_SetBoneAngles(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3), (float *)VMA(4), args[5], (const Eorientations) args[6], (const Eorientations) args[7], (const Eorientations) args[8], (qhandle_t *)VMA(9), args[10], args[11] ); case UI_G2_CLEANMODELS: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif G2API_CleanGhoul2Models((CGhoul2Info_v **)VMA(1)); // G2API_CleanGhoul2Models((CGhoul2Info_v **)args[1]); return 0; case UI_G2_PLAYANIM: return G2API_SetBoneAnim(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3), args[4], args[5], args[6], VMF(7), args[8], VMF(9), args[10]); case UI_G2_GETBONEANIM: { CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); int modelIndex = args[10]; return G2API_GetBoneAnim(&g2[modelIndex], (const char*)VMA(2), args[3], (float *)VMA(4), (int *)VMA(5), (int *)VMA(6), (int *)VMA(7), (float *)VMA(8), (int *)VMA(9)); } case UI_G2_GETBONEFRAME: { //rwwFIXMEFIXME: Just make a G2API_GetBoneFrame func too. This is dirty. CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); int modelIndex = args[6]; int iDontCare1 = 0, iDontCare2 = 0, iDontCare3 = 0; float fDontCare1 = 0; return G2API_GetBoneAnim(&g2[modelIndex], (const char*)VMA(2), args[3], (float *)VMA(4), &iDontCare1, &iDontCare2, &iDontCare3, &fDontCare1, (int *)VMA(5)); } case UI_G2_GETGLANAME: // return (int)G2API_GetGLAName(*((CGhoul2Info_v *)VMA(1)), args[2]); { char *point = ((char *)VMA(3)); char *local; local = G2API_GetGLAName(*((CGhoul2Info_v *)args[1]), args[2]); if (local) { strcpy(point, local); } } return 0; case UI_G2_COPYGHOUL2INSTANCE: return (int)G2API_CopyGhoul2Instance(*((CGhoul2Info_v *)args[1]), *((CGhoul2Info_v *)args[2]), args[3]); case UI_G2_COPYSPECIFICGHOUL2MODEL: G2API_CopySpecificG2Model(*((CGhoul2Info_v *)args[1]), args[2], *((CGhoul2Info_v *)args[3]), args[4]); return 0; case UI_G2_DUPLICATEGHOUL2INSTANCE: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif G2API_DuplicateGhoul2Instance(*((CGhoul2Info_v *)args[1]), (CGhoul2Info_v **)VMA(2)); return 0; case UI_G2_HASGHOUL2MODELONINDEX: return (int)G2API_HasGhoul2ModelOnIndex((CGhoul2Info_v **)VMA(1), args[2]); //return (int)G2API_HasGhoul2ModelOnIndex((CGhoul2Info_v **)args[1], args[2]); case UI_G2_REMOVEGHOUL2MODEL: #ifdef _FULL_G2_LEAK_CHECKING g_G2AllocServer = 0; #endif return (int)G2API_RemoveGhoul2Model((CGhoul2Info_v **)VMA(1), args[2]); //return (int)G2API_RemoveGhoul2Model((CGhoul2Info_v **)args[1], args[2]); case UI_G2_ADDBOLT: return G2API_AddBolt(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3)); // case UI_G2_REMOVEBOLT: // return G2API_RemoveBolt(*((CGhoul2Info_v *)VMA(1)), args[2]); case UI_G2_SETBOLTON: G2API_SetBoltInfo(*((CGhoul2Info_v *)args[1]), args[2], args[3]); return 0; #ifdef _SOF2 case UI_G2_ADDSKINGORE: G2API_AddSkinGore(*((CGhoul2Info_v *)args[1]),*(SSkinGoreData *)VMA(2)); return 0; #endif // _SOF2 /* Ghoul2 Insert End */ case UI_G2_SETROOTSURFACE: return G2API_SetRootSurface(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3)); case UI_G2_SETSURFACEONOFF: return G2API_SetSurfaceOnOff(*((CGhoul2Info_v *)args[1]), (const char *)VMA(2), /*(const int)VMA(3)*/args[3]); case UI_G2_SETNEWORIGIN: return G2API_SetNewOrigin(*((CGhoul2Info_v *)args[1]), /*(const int)VMA(2)*/args[2]); case UI_G2_GETTIME: return G2API_GetTime(0); case UI_G2_SETTIME: G2API_SetTime(args[1], args[2]); return 0; case UI_G2_SETRAGDOLL: return 0; //not supported for ui break; case UI_G2_ANIMATEG2MODELS: return 0; //not supported for ui break; case UI_G2_SETBONEIKSTATE: return G2API_SetBoneIKState(*((CGhoul2Info_v *)args[1]), args[2], (const char *)VMA(3), args[4], (sharedSetBoneIKStateParams_t *)VMA(5)); case UI_G2_IKMOVE: return G2API_IKMove(*((CGhoul2Info_v *)args[1]), args[2], (sharedIKMoveParams_t *)VMA(3)); case UI_G2_GETSURFACENAME: { //Since returning a pointer in such a way to a VM seems to cause MASSIVE FAILURE<tm>, we will shove data into the pointer the vm passes instead char *point = ((char *)VMA(4)); char *local; int modelindex = args[3]; CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); local = G2API_GetSurfaceName(&g2[modelindex], args[2]); if (local) { strcpy(point, local); } } return 0; case UI_G2_SETSKIN: { CGhoul2Info_v &g2 = *((CGhoul2Info_v *)args[1]); int modelIndex = args[2]; return G2API_SetSkin(&g2[modelIndex], args[3], args[4]); } case UI_G2_ATTACHG2MODEL: { CGhoul2Info_v *g2From = ((CGhoul2Info_v *)args[1]); CGhoul2Info_v *g2To = ((CGhoul2Info_v *)args[3]); return G2API_AttachG2Model(g2From[0], args[2], g2To[0], args[4], args[5]); } /* Ghoul2 Insert End */ default: Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); } return 0; }
/* *Keybinding command */ void SCR_SizeDown_f(void) { Cvar_SetValue("viewsize", (float)scr_viewsize->value - 10); }
/* * Change the server to a new map, taking all connected * clients along with it. */ void SV_SpawnServer ( char *server, char *spawnpoint, server_state_t serverstate, qboolean attractloop, qboolean loadgame ) { int i; unsigned checksum; if ( attractloop ) { Cvar_Set( "paused", "0" ); } Com_Printf( "------- server initialization ------\n" ); Com_DPrintf( "SpawnServer: %s\n", server ); if ( sv.demofile ) { FS_FCloseFile( (size_t) sv.demofile ); } svs.spawncount++; /* any partially connected client will be restarted */ sv.state = ss_dead; Com_SetServerState( sv.state ); /* wipe the entire per-level structure */ memset( &sv, 0, sizeof ( sv ) ); svs.realtime = 0; sv.loadgame = loadgame; sv.attractloop = attractloop; /* save name for levels that don't set message */ strcpy( sv.configstrings [ CS_NAME ], server ); if ( Cvar_VariableValue( "deathmatch" ) ) { sprintf( sv.configstrings [ CS_AIRACCEL ], "%g", sv_airaccelerate->value ); pm_airaccelerate = sv_airaccelerate->value; } else { strcpy( sv.configstrings [ CS_AIRACCEL ], "0" ); pm_airaccelerate = 0; } SZ_Init( &sv.multicast, sv.multicast_buf, sizeof ( sv.multicast_buf ) ); strcpy( sv.name, server ); /* leave slots at start for clients only */ for ( i = 0; i < maxclients->value; i++ ) { /* needs to reconnect */ if ( svs.clients [ i ].state > cs_connected ) { svs.clients [ i ].state = cs_connected; } svs.clients [ i ].lastframe = -1; } sv.time = 1000; strcpy( sv.name, server ); strcpy( sv.configstrings [ CS_NAME ], server ); if ( serverstate != ss_game ) { sv.models [ 1 ] = CM_LoadMap( "", false, &checksum ); /* no real map */ } else { Com_sprintf( sv.configstrings [ CS_MODELS + 1 ], sizeof ( sv.configstrings [ CS_MODELS + 1 ] ), "maps/%s.bsp", server ); sv.models [ 1 ] = CM_LoadMap( sv.configstrings [ CS_MODELS + 1 ], false, &checksum ); } Com_sprintf( sv.configstrings [ CS_MAPCHECKSUM ], sizeof ( sv.configstrings [ CS_MAPCHECKSUM ] ), "%i", checksum ); /* clear physics interaction links */ SV_ClearWorld(); for ( i = 1; i < CM_NumInlineModels(); i++ ) { Com_sprintf( sv.configstrings [ CS_MODELS + 1 + i ], sizeof ( sv.configstrings [ CS_MODELS + 1 + i ] ), "*%i", i ); sv.models [ i + 1 ] = CM_InlineModel( sv.configstrings [ CS_MODELS + 1 + i ] ); } /* spawn the rest of the entities on the map */ sv.state = ss_loading; Com_SetServerState( sv.state ); /* load and spawn all other entities */ ge->SpawnEntities( sv.name, CM_EntityString(), spawnpoint ); /* run two frames to allow everything to settle */ ge->RunFrame(); ge->RunFrame(); /* verify game didn't clobber important stuff */ if ( (int) checksum != (int)strtol( sv.configstrings [ CS_MAPCHECKSUM ], (char **)NULL, 10 ) ) { Com_Error( ERR_DROP, "Game DLL corrupted server configstrings" ); } /* all precaches are complete */ sv.state = serverstate; Com_SetServerState( sv.state ); /* create a baseline for more efficient communications */ SV_CreateBaseline(); /* check for a savegame */ SV_CheckForSavegame(); /* set serverinfo variable */ Cvar_FullSet( "mapname", sv.name, CVAR_SERVERINFO | CVAR_NOSET ); Cvar_SetValue( "windowed_mouse", 1 ); Com_Printf( "------------------------------------\n\n" ); }