engine: client: refactor variable declarations

This commit is contained in:
Alibek Omarov
2026-05-20 17:26:14 +05:00
committed by a1batross
parent d49178d5b6
commit e8845fc404
52 changed files with 987 additions and 1670 deletions

View File

@@ -88,13 +88,12 @@ Apply gyro movement to view angles
*/
void IN_GyroFinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
{
platform_orientation_t orient;
float orient_scale = 1.0f;
if( !gyro_enable.value || !gyro_available.value )
return;
orient = Platform_GetDisplayOrientation();
platform_orientation_t orient = Platform_GetDisplayOrientation();
if( orient == ORIENTATION_LANDSCAPE_FLIPPED )
orient_scale = -1.0f;

View File

@@ -129,9 +129,8 @@ static void Joy_HatMotionEvent( int value )
{ JOY_HAT_LEFT, K_LEFTARROW },
{ JOY_HAT_RIGHT, K_RIGHTARROW },
};
int i;
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( value & keys[i].mask )
{
@@ -317,9 +316,8 @@ void Joy_FinalizeMove( float *fw, float *side, float *dpitch, float *dyaw )
if( FBitSet( joy_axis_binding.flags, FCVAR_CHANGED ) )
{
const char *bind = joy_axis_binding.string;
size_t i;
for( i = 0; bind[i] && i < MAX_AXES; i++ )
for( size_t i = 0; bind[i] && i < MAX_AXES; i++ )
{
switch( bind[i] )
{
@@ -535,8 +533,6 @@ void Joy_DrawDebug( void )
}
qboolean pressed = Key_IsDown( buttons[i] );
int btn_w = 0;
rgba_t color;
string name;
Q_strncpy( name, Key_KeynumToString( buttons[i] ), sizeof( name ));
@@ -545,8 +541,11 @@ void Joy_DrawDebug( void )
if( p )
*p = 0;
rgba_t color;
MakeRGBA( color, pressed ? 0 : 255, pressed ? 255 : 0, 0, 255 );
CL_DrawString( x, y, name, color, font, 0 );
int btn_w = 0;
CL_DrawStringLen( font, name, &btn_w, NULL, 0 );
x += btn_w + 6;
}

View File

@@ -187,8 +187,6 @@ to be configured even if they don't have defined names.
*/
static int Key_StringToKeynum( const char *str )
{
int i;
if( !str || !str[0] )
return -1;
@@ -207,7 +205,7 @@ static int Key_StringToKeynum( const char *str )
}
// scan for a text match
for( i = 0; i < ARRAYSIZE( keynames ); i++ )
for( int i = 0; i < ARRAYSIZE( keynames ); i++ )
{
if( !Q_stricmp( str, keynames[i].name ))
return keynames[i].keynum;
@@ -293,19 +291,16 @@ Key_GetKey
*/
static int Key_GetKey( const char *pBinding )
{
int i, len;
const char *p;
if( !pBinding ) return -1;
len = Q_strlen( pBinding );
int len = Q_strlen( pBinding );
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( !keys[i].binding )
continue;
p = keys[i].binding;
const char *p = keys[i].binding;
if( *p == '+' )
p++;
@@ -340,15 +335,13 @@ Key_Unbind_f
*/
static void Key_Unbind_f( void )
{
int b;
if( Cmd_Argc() != 2 )
{
Con_Printf( S_USAGE "unbind <key> : remove commands from a key\n" );
return;
}
b = Key_StringToKeynum( Cmd_Argv( 1 ));
int b = Key_StringToKeynum( Cmd_Argv( 1 ));
if( b == -1 )
{
@@ -372,9 +365,7 @@ Key_Unbindall_f
*/
static void Key_Unbindall_f( void )
{
int i;
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( keys[i].binding )
Key_SetBinding( i, "" );
@@ -392,17 +383,15 @@ Key_Reset_f
*/
static void Key_Reset_f( void )
{
int i;
// clear all keys first
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( keys[i].binding )
Key_SetBinding( i, "" );
}
// apply default values
for( i = 0; i < ARRAYSIZE( keynames ); i++ )
for( int i = 0; i < ARRAYSIZE( keynames ); i++ )
Key_SetBinding( keynames[i].keynum, keynames[i].binding );
}
@@ -413,10 +402,7 @@ Key_Bind_f
*/
static void Key_Bind_f( void )
{
char cmd[1024];
int i, c, b;
c = Cmd_Argc();
int c = Cmd_Argc();
if( c < 2 )
{
@@ -424,7 +410,7 @@ static void Key_Bind_f( void )
return;
}
b = Key_StringToKeynum( Cmd_Argv( 1 ));
int b = Key_StringToKeynum( Cmd_Argv( 1 ));
if( b == -1 )
{
@@ -441,9 +427,10 @@ static void Key_Bind_f( void )
}
// copy the rest of the command line
char cmd[1024];
cmd[0] = 0; // start out with a null string
for( i = 2; i < c; i++ )
for( int i = 2; i < c; i++ )
{
Q_strncat( cmd, Cmd_Argv( i ), sizeof( cmd ));
if( i != ( c - 1 )) Q_strncat( cmd, " ", sizeof( cmd ));
@@ -461,18 +448,16 @@ Writes lines containing "bind key value"
*/
void Key_WriteBindings( file_t *f )
{
int i;
string newCommand;
if( !f ) return;
FS_Printf( f, "unbindall\n" );
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( COM_StringEmptyOrNULL( keys[i].binding ))
continue;
string newCommand;
Cmd_Escape( newCommand, keys[i].binding, sizeof( newCommand ));
// NOTE: as TheKingFireS figured out, some particular mods (like CoF) do not
@@ -491,9 +476,7 @@ Key_Bindlist_f
*/
static void Key_Bindlist_f( void )
{
int i;
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( COM_StringEmptyOrNULL( keys[i].binding ))
continue;
@@ -514,10 +497,9 @@ qboolean Cmd_GetKeysList( const char *s, char *completedname, int length, qboole
size_t i, numkeys;
string keys_strings[ARRAYSIZE( keys )];
string matchbuf;
int len;
// compare keys list with current keyword
len = Q_strlen( s );
int len = Q_strlen( s );
for( i = 0, numkeys = 0; i < ARRAYSIZE( keys ); i++ )
{
@@ -569,8 +551,6 @@ Key_Init
*/
void Key_Init( void )
{
int i;
// register our functions
Cmd_AddRestrictedCommand( "bind", Key_Bind_f, "binds a command to the specified key in bindmap" );
Cmd_AddRestrictedCommand( "unbind", Key_Unbind_f, "removes a command on the specified key in bindmap" );
@@ -580,7 +560,7 @@ void Key_Init( void )
Cmd_AddCommand( "makehelp", Key_EnumCmds_f, "write help.txt that contains all console cvars and cmds" );
// setup default binding. "unbindall" from config.cfg will be reset it
for( i = 0; i < ARRAYSIZE( keynames ); i++ )
for( int i = 0; i < ARRAYSIZE( keynames ); i++ )
Key_SetBinding( keynames[i].keynum, keynames[i].binding );
Cvar_RegisterVariable( &key_rotate );
@@ -594,21 +574,20 @@ Key_AddKeyCommands
*/
static void Key_AddKeyCommands( int key, const char *kb, qboolean down )
{
char button[1024];
char *buttonPtr;
char cmd[1024];
int i;
if( !kb ) return;
buttonPtr = button;
for( i = 0; ; i++ )
char button[1024];
char *buttonPtr = button;
for( int i = 0; ; i++ )
{
if( kb[i] == ';' || !kb[i] )
{
*buttonPtr = '\0';
if( button[0] == '+' )
{
char cmd[1024];
// button commands add keynum as a parm
if( down ) Q_snprintf( cmd, sizeof( cmd ), "%s %i\n", button, key );
else Q_snprintf( cmd, sizeof( cmd ), "-%s %i\n", button + 1, key );
@@ -708,8 +687,6 @@ Called by the system for both key up and key down events
*/
void GAME_EXPORT Key_Event( int key, int down )
{
const char *kb;
key = Key_Rotate( key );
if( OSK_KeyEvent( key, down ) )
@@ -719,7 +696,7 @@ void GAME_EXPORT Key_Event( int key, int down )
if( !keys[key].down && !down )
return;
kb = keys[key].binding;
const char *kb = keys[key].binding;
keys[key].down = down ? true : false;
#ifdef HACKS_RELATED_HLMODS
@@ -917,13 +894,11 @@ Key_ClearStates
*/
void GAME_EXPORT Key_ClearStates( void )
{
int i;
// don't clear keys during changelevel
if( cls.changelevel )
return;
for( i = 0; i < ARRAYSIZE( keys ); i++ )
for( int i = 0; i < ARRAYSIZE( keys ); i++ )
{
if( i >= K_MOUSE1 && i <= K_MOUSE5 )
IN_MouseEvent( i - K_MOUSE1, false );

View File

@@ -144,8 +144,6 @@ qboolean OSK_KeyEvent( int key, int down )
break;
default:
{
int ch;
if( !down )
{
if( osk.shift && osk.curlayout & 1 )
@@ -156,7 +154,7 @@ qboolean OSK_KeyEvent( int key, int down )
break;
}
ch = (byte)osk.curbutton.val;
int ch = (byte)osk.curbutton.val;
// do not pass UTF-8 sequence into the engine, convert it here
if( !cls.accept_utf8 )

View File

@@ -249,10 +249,7 @@ Dump config to file
*/
static qboolean Touch_DumpConfig( const char *name, const char *profilename )
{
file_t *f;
const touch_button_t *button;
f = FS_Open( name, "w", true );
file_t *f = FS_Open( name, "w", true );
if( !f )
{
@@ -299,7 +296,7 @@ static qboolean Touch_DumpConfig( const char *name, const char *profilename )
FS_Printf( f, "touch_removeall\n" );
FS_Printf( f, "touch_aspectratio %g\n", Touch_AspectRatio());
for( button = touch.list_user.first; button; button = button->next )
for( const touch_button_t *button = touch.list_user.first; button; button = button->next )
Touch_ExportButtonToConfig( f, button, false );
FS_Close( f );
@@ -347,9 +344,6 @@ export current touch configuration into profile
*/
static void Touch_ExportConfig_f( void )
{
const char *name;
string profilename;
if( Cmd_Argc() != 2 )
{
Con_Printf( S_USAGE "touch_exportconfig <name>\n" );
@@ -362,7 +356,8 @@ static void Touch_ExportConfig_f( void )
return;
}
name = Cmd_Argv( 1 );
const char *name = Cmd_Argv( 1 );
string profilename;
if( Q_strstr( name, "touch_presets/" ))
{
@@ -386,7 +381,6 @@ export current touch configuration into C code
*/
static void Touch_GenerateCode_f( void )
{
const touch_button_t *button;
rgba_t c = { 0 };
if( !touch.list_user.first )
@@ -395,11 +389,9 @@ static void Touch_GenerateCode_f( void )
return;
}
for( button = touch.list_user.first; button; button = button->next )
for( const touch_button_t *button = touch.list_user.first; button; button = button->next )
{
float aspect;
int flags = button->flags;
int round;
if( FBitSet( flags, TOUCH_FL_CLIENT ))
continue; // skip temporary buttons
@@ -410,7 +402,7 @@ static void Touch_GenerateCode_f( void )
if( FBitSet( flags, TOUCH_FL_DEF_HIDE ))
SetBits( flags, TOUCH_FL_HIDE );
aspect = ( button->y2 - button->y1 ) / (( button->x2 - button->x1 ) / Touch_AspectRatio( ));
float aspect = ( button->y2 - button->y1 ) / (( button->x2 - button->x1 ) / Touch_AspectRatio( ));
if( memcmp( c, button->color, sizeof( c )))
{
@@ -419,6 +411,7 @@ static void Touch_GenerateCode_f( void )
memcpy( c, button->color, sizeof( c ));
}
int round;
if( button->type == touch_command )
{
if( fabs( aspect - 1.0f ) < 0.001 )
@@ -438,22 +431,18 @@ static void Touch_GenerateCode_f( void )
static void Touch_RoundAll_f( void )
{
touch_button_t *button;
if( !touch_grid_enable.value )
return;
for( button = touch.list_user.first; button; button = button->next )
for( touch_button_t *button = touch.list_user.first; button; button = button->next )
IN_TouchCheckCoords( &button->x1, &button->y1, &button->x2, &button->y2 );
}
static void Touch_ListButtons_f( void )
{
touch_button_t *button;
Touch_InitConfig();
for( button = touch.list_user.first; button; button = button->next )
for( touch_button_t *button = touch.list_user.first; button; button = button->next )
{
Con_Printf( "%s %s %s %g %g %g %g %d %d %d %d %d\n",
button->name, button->texture, button->command,
@@ -483,9 +472,7 @@ static void Touch_Stroke_f( void )
static touch_button_t *Touch_FindNextNoPattern( touch_button_t *buttons, const char *name, qboolean privileged )
{
touch_button_t *b;
for( b = buttons; b; b = b->next )
for( touch_button_t *b = buttons; b; b = b->next )
{
if( !privileged && !FBitSet( b->flags, TOUCH_FL_UNPRIVILEGED ))
continue;
@@ -504,13 +491,12 @@ static touch_button_t *Touch_FindButtonNoPattern( touchbuttonlist_t *list, const
static touch_button_t *Touch_FindNext( touch_button_t *buttons, const char *name, qboolean privileged )
{
touch_button_t *b;
qboolean has_pattern = Q_strchr( name, '*' ) != NULL;
if( !has_pattern )
return Touch_FindNextNoPattern( buttons, name, privileged );
for( b = buttons; b; b = b->next )
for( touch_button_t *b = buttons; b; b = b->next )
{
if( !privileged && !FBitSet( b->flags, TOUCH_FL_UNPRIVILEGED ))
continue;
@@ -584,10 +570,9 @@ static void Touch_SetClientOnly_f( void )
static void Touch_RemoveButtonFromList( touchbuttonlist_t *list, const char *name, qboolean privileged )
{
touch_button_t *button;
IN_TouchEditClear();
touch_button_t *button;
while(( button = Touch_FindFirst( list, name, privileged )))
{
if( button->prev )
@@ -640,9 +625,7 @@ static void Touch_RemoveAll_f( void )
static void Touch_SetColor( touchbuttonlist_t *list, const char *name, byte *color, qboolean privileged )
{
touch_button_t *b;
for( b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
for( touch_button_t *b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
Vector4Copy( color, b->color );
}
@@ -677,9 +660,7 @@ static void Touch_SetCommand( touch_button_t *button, const char *command )
void Touch_HideButtons( const char *name, byte hide, qboolean privileged )
{
touch_button_t *b;
for( b = Touch_FindFirst( &touch.list_user, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
for( touch_button_t *b = Touch_FindFirst( &touch.list_user, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
{
if( hide )
SetBits( b->flags, TOUCH_FL_HIDE );
@@ -718,9 +699,7 @@ static void Touch_Show_f( void )
static void Touch_FadeButtons( touchbuttonlist_t *list, const char *name, float speed, float end, float start, qboolean privileged )
{
touch_button_t *b;
for( b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
for( touch_button_t *b = Touch_FindFirst( list, name, privileged ); b != NULL; b = Touch_FindNext( b->next, name, privileged ))
{
if( start >= 0 )
b->fade = start;
@@ -855,8 +834,6 @@ static touch_button_t *Touch_AddButton( touchbuttonlist_t *list, const char *nam
void Touch_AddClientButton( const char *name, const char *texture, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags )
{
touch_button_t *button;
if( !touch.initialized )
return;
@@ -865,15 +842,14 @@ void Touch_AddClientButton( const char *name, const char *texture, const char *c
if( round == round_aspect )
y2 = y1 + ( x2 - x1 ) / (Touch_AspectRatio()) * aspect;
button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true );
touch_button_t *button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, true );
SetBits( button->flags, TOUCH_FL_CLIENT | TOUCH_FL_NOEDIT );
button->aspect = aspect;
}
static void Touch_LoadDefaults_f( void )
{
int i;
for( i = 0; i < g_DefaultButtonsLength; i++ )
for( int i = 0; i < g_DefaultButtonsLength; i++ )
{
touch_button_t *button;
float x1 = g_DefaultButtons[i].x1,
@@ -903,11 +879,9 @@ static void Touch_LoadDefaults_f( void )
// Add default button from client
void Touch_AddDefaultButton( const char *name, const char *texture, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags )
{
touchdefaultbutton_t *b;
g_DefaultButtons = Mem_Realloc( touch.mempool, g_DefaultButtons, sizeof( *g_DefaultButtons ) * ( g_DefaultButtonsLength + 1 ));
b = &g_DefaultButtons[g_DefaultButtonsLength];
touchdefaultbutton_t *b = &g_DefaultButtons[g_DefaultButtonsLength];
Q_strncpy( b->name, name, sizeof( b->name ));
Q_strncpy( b->texture, texture, sizeof( b->texture ));
@@ -938,22 +912,18 @@ void Touch_ResetDefaultButtons( void )
static void Touch_AddButton_f( void )
{
rgba_t color = { 255, 255, 255, 255 };
touch_button_t *button = NULL;
const char *name, *command;
float x1 = 0.4f, y1 = 0.4f, x2 = 0.6f, y2 = 0.6f;
qboolean privileged = Cmd_CurrentCommandIsPrivileged();
string texture;
if( Cmd_Argc( ) < 4 )
{
Con_Printf( S_USAGE "touch_addbutton <name> <texture> <command> [<x1> <y1> <x2> <y2> [ r g b a ] ]\n" );
return;
}
name = Cmd_Argv( 1 );
const char *name = Cmd_Argv( 1 );
string texture;
Q_strncpy( texture, Cmd_Argv( 2 ), sizeof( texture ));
command = Cmd_Argv( 3 );
const char *command = Cmd_Argv( 3 );
float x1 = 0.4f, y1 = 0.4f, x2 = 0.6f, y2 = 0.6f;
rgba_t color = { 255, 255, 255, 255 };
// HACKHACK: old engine specifically used .tga for touch buttons
// and because new engine extras.pk3 don't have .tga textures
@@ -980,7 +950,8 @@ static void Touch_AddButton_f( void )
color[3] = Q_atoi( Cmd_Argv( 11 ));
}
button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, privileged );
qboolean privileged = Cmd_CurrentCommandIsPrivileged();
touch_button_t *button = Touch_AddButton( &touch.list_user, name, texture, command, x1, y1, x2, y2, color, privileged );
if( Cmd_Argc( ) >= 13 )
SetBits( button->flags, Q_atoi( Cmd_Argv( 12 )));
@@ -1023,9 +994,7 @@ static void Touch_EnableEdit_f( void )
// convert coordinates to actual aspect ratio after it was updated
if( touch.config_aspect_ratio != touch.actual_aspect_ratio )
{
touch_button_t *button;
for( button = touch.list_user.first; button; button = button->next )
for( touch_button_t *button = touch.list_user.first; button; button = button->next )
{
button->y1 /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
button->y2 /= touch.actual_aspect_ratio / touch.config_aspect_ratio;
@@ -1315,10 +1284,6 @@ static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 )
static float Touch_DrawCharacter( float x, float y, int number, float size )
{
float s1, s2, t1, t2, width, height;
int w, h;
wrect_t *prc;
if( !cls.creditsFont.valid )
return 0;
@@ -1328,16 +1293,17 @@ static float Touch_DrawCharacter( float x, float y, int number, float size )
if( !number )
return 0;
int w, h;
R_GetTextureParms( &w, &h, cls.creditsFont.hFontTexture );
prc = &cls.creditsFont.fontRc[number];
wrect_t *prc = &cls.creditsFont.fontRc[number];
s1 = prc->left / (float)w;
t1 = prc->top / (float)h;
s2 = prc->right / (float)w;
t2 = prc->bottom / (float)h;
float s1 = prc->left / (float)w;
float t1 = prc->top / (float)h;
float s2 = prc->right / (float)w;
float t2 = prc->bottom / (float)h;
width = ( prc->right - prc->left ) / 1024.0f * size;
height = ( prc->bottom - prc->top ) / 1024.0f * size;
float width = ( prc->right - prc->left ) / 1024.0f * size;
float height = ( prc->bottom - prc->top ) / 1024.0f * size;
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( x ), TO_SCRN_Y( y ), TO_SCRN_X( width ), TO_SCRN_X( height ),
s1, t1, s2, t2, cls.creditsFont.hFontTexture );
@@ -1384,9 +1350,7 @@ static float Touch_DrawText( float x1, float y1, float x2, float y2, const char
static void Touch_DrawButtons( touchbuttonlist_t *list )
{
touch_button_t *b;
for( b = list->first; b; b = b->next )
for( touch_button_t *b = list->first; b; b = b->next )
{
if( Touch_IsVisible( b ))
{
@@ -1506,17 +1470,15 @@ void Touch_Draw( void )
if( touch.state >= state_edit && touch_grid_enable.value )
{
float x;
if( touch_in_menu.value )
ref.dllFuncs.FillRGBA( kRenderTransTexture, 0, 0, 1, 1, 32, 32, 32, 255 );
else
ref.dllFuncs.FillRGBA( kRenderTransTexture, 0, 0, 1, 1, 0, 0, 0, 112 );
for( x = 0.0f; x < 1.0f; x += GRID_X )
for( float x = 0.0f; x < 1.0f; x += GRID_X )
ref.dllFuncs.FillRGBA( kRenderTransTexture, TO_SCRN_X( x ), 0, 1, TO_SCRN_Y( 1 ), 0, 224, 224, 112 );
for( x = 0.0f; x < 1.0f; x += GRID_Y )
for( float x = 0.0f; x < 1.0f; x += GRID_Y )
ref.dllFuncs.FillRGBA( kRenderTransTexture, 0, TO_SCRN_Y( x ), TO_SCRN_X( 1 ), 1, 0, 224, 224, 112 );
}
@@ -1738,16 +1700,14 @@ static void Touch_Motion( int fingerID, float x, float y, float dx, float dy )
if( touch_nonlinear_look.value )
{
float dabs, dcos, dsin;
// save angle, modify only velocity
dabs = sqrt( dx * dx + dy * dy );
float dabs = sqrt( dx * dx + dy * dy );
if( dabs < 0.000001f )
return; // no motion, avoid division by zero
dcos = dx / dabs;
dsin = dy / dabs;
float dcos = dx / dabs;
float dsin = dy / dabs;
if( touch_exp_mult.value > 1 )
dabs = ( exp( dabs * touch_exp_mult.value ) - 1 ) / touch_exp_mult.value;
@@ -1771,14 +1731,13 @@ static void Touch_Motion( int fingerID, float x, float y, float dx, float dy )
static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type, int fingerID, float x, float y )
{
touch_button_t *button;
qboolean result = false;
if( type != event_down && type != event_up )
return false;
// run from end(front) to start(back)
for( button = list->last; button; button = button->prev )
for( touch_button_t *button = list->last; button; button = button->prev )
{
// skip invisible buttons
if( !Touch_IsVisible( button ))
@@ -1850,14 +1809,12 @@ static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type,
if( touch.look_finger == fingerID )
{
touch_button_t *newbutton;
// this is an error, try recover
touch.move_finger = touch.look_finger = -1;
// player touched touch_move with enabled look mode
// and same finger id. release all move triggers
for( newbutton = list->first; newbutton; newbutton = newbutton->next )
for( touch_button_t *newbutton = list->first; newbutton; newbutton = newbutton->next )
{
if( newbutton->type == touch_move || newbutton->type == touch_look )
newbutton->finger = -1;
@@ -1910,14 +1867,12 @@ static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type,
if( touch.move_finger == fingerID )
{
touch_button_t *newbutton;
// this is an error, try recover
touch.move_finger = touch.look_finger = -1;
// player touched touch_move with enabled look mode
// and same finger id. release all move triggers
for( newbutton = list->first; newbutton; newbutton = newbutton->next )
for( touch_button_t *newbutton = list->first; newbutton; newbutton = newbutton->next )
{
if( newbutton->type == touch_move || newbutton->type == touch_look )
newbutton->finger = -1;
@@ -1994,8 +1949,6 @@ static qboolean Touch_ButtonPress( touchbuttonlist_t *list, touchEventType type,
static qboolean Touch_ButtonEdit( touchEventType type, int fingerID, float x, float y )
{
touch_button_t *button;
// edit buttons are on y1
if( type == event_down )
{
@@ -2010,7 +1963,7 @@ static qboolean Touch_ButtonEdit( touchEventType type, int fingerID, float x, fl
}
// run from end(front) to start(back)
for( button = touch.list_user.last; button; button = button->prev )
for( touch_button_t *button = touch.list_user.last; button; button = button->prev )
{
if( type == event_down )
{

View File

@@ -337,8 +337,6 @@ IN_MouseMove
*/
static void IN_MouseMove( void )
{
int x, y;
if( !in_mouseinitialized )
return;
@@ -350,6 +348,7 @@ static void IN_MouseMove( void )
}
// find mouse movement
int x, y;
Platform_GetMousePos( &x, &y );
VGui_MouseMove( x, y );
@@ -586,18 +585,15 @@ Called from cl_main.c after generating command in client
*/
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
{
float forward, side, pitch, yaw;
if( clgame.dllFuncs.pfnLookEvent )
return;
if( cls.key_dest != key_game || cl.paused || cl.intermission )
return;
forward = side = pitch = yaw = 0;
if( active )
{
float forward = 0, side = 0, pitch = 0, yaw = 0;
float sensitivity = 1;//( (float)cl.local.scr_fov / (float)90.0f );
IN_CollectInput( &forward, &side, &pitch, &yaw, false );