From 9a751c9645f63a4e324ef2ea486efb7b669fddc5 Mon Sep 17 00:00:00 2001 From: hgn Date: Thu, 23 Feb 2023 03:05:57 +0000 Subject: [PATCH] small clean --- common.h | 88 ++++++-------------------------------------------- network.h | 2 ++ player.h | 63 ------------------------------------ player_skate.c | 2 +- rigidbody.h | 2 -- steam.h | 59 +++++++++++++++++++++++++++++++++ 6 files changed, 71 insertions(+), 145 deletions(-) diff --git a/common.h b/common.h index 3d60978..0621e7c 100644 --- a/common.h +++ b/common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved */ #ifndef COMMON_H @@ -36,89 +36,23 @@ struct ray_hit v3f pos, normal; }; -VG_STATIC int network_scores_updated = 0; - -VG_STATIC u32 utf8_byte0_byte_count( u8 char0 ) -{ - for( u32 k=2; k<4; k++ ) - { - if( !(char0 & (0x80 >> k)) ) - return k; - } - - return 0; -} - -VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length ) -{ - u8 *ustr = (u8 *)str; - u32 utf32_code = 0x00000000; - u32 i=0, j=0, utf32_byte_ct=0; - - for(;i < length-1;) - { - if( ustr[i] == 0x00 ) - break; - - if( ustr[i] & 0x80 ) - { - if( utf32_byte_ct ) - { - utf32_byte_ct --; - utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6); - - if( !utf32_byte_ct ) - { - const char *match; - size_t chars = anyascii( utf32_code, &match ); - - for( u32 k=0; k> utf32_byte_ct); - utf32_code <<= utf32_byte_ct*6; - } - } - else - { - utf32_byte_ct = 0x00; - buf[j ++] = str[i]; - } - - i++; - } - - buf[j] = 0x00; -} - VG_STATIC float - k_runspeed = 20.0f, /* depr */ - k_board_allowance = 0.04f, k_friction_lat = 12.0f, k_friction_resistance = 0.01f, + k_max_push_speed = 16.0f, k_push_accel = 10.0f, k_push_cycle_rate = 8.0f, + k_steer_ground = 2.5f, k_steer_air = 3.6f, - k_steer_air_lerp = 0.3f, - k_pump_force = 0.0f, - k_downforce = 0.0f, - k_escape_velocity = 1.0f, - k_walk_downforce = 8.0f, + k_jump_charge_speed = (1.0f/1.0f), k_jump_force = 5.0f, + k_pitch_limit = 1.5f, k_look_speed = 2.0f, - k_spin_boost = 4.20f, - k_cog_spring = 0.2f, k_cog_damp = 0.02f, k_cog_mass_ratio = 0.9f, @@ -136,8 +70,8 @@ VG_STATIC float k_grind_aligment = 10.0f, k_grind_dampener = 5.0f, - k_board_spring = 100.0f, - k_board_dampener = 40.0f, + k_surface_spring = 100.0f, + k_surface_dampener = 40.0f, k_manul_spring = 200.0f, k_manul_dampener = 30.0f, k_board_interia = 8.0f, @@ -192,8 +126,8 @@ VG_STATIC void common_var_temp(void) VG_VAR_F32( k_grind_dampener ); VG_VAR_F32( k_grind_spring ); VG_VAR_F32( k_grind_aligment ); - VG_VAR_F32( k_board_spring ); - VG_VAR_F32( k_board_dampener ); + VG_VAR_F32( k_surface_spring ); + VG_VAR_F32( k_surface_dampener ); VG_VAR_F32( k_board_interia ); VG_VAR_F32( k_grind_decayxy ); VG_VAR_F32( k_grind_axel_min_vel ); @@ -205,7 +139,6 @@ VG_STATIC void common_var_temp(void) VG_VAR_F32( k_airspeed ); VG_VAR_F32( k_walk_friction ); VG_VAR_F32( k_walk_air_accel ); - VG_VAR_F32( k_runspeed ); VG_VAR_F32( k_walk_accel ); VG_VAR_I32( freecam ); @@ -222,10 +155,7 @@ VG_STATIC void common_var_temp(void) VG_VAR_F32( k_cog_spring ); VG_VAR_F32( k_cog_damp ); - VG_VAR_F32( k_cog_mass_ratio ); - VG_VAR_F32( k_escape_velocity ); - VG_VAR_F32( k_downforce ); VG_VAR_F32( k_spring_force ); VG_VAR_F32( k_spring_dampener ); diff --git a/network.h b/network.h index 4d34e82..fc454c7 100644 --- a/network.h +++ b/network.h @@ -11,6 +11,8 @@ #include "network_msg.h" #include "highscores.h" +VG_STATIC int network_scores_updated = 0; + /* * Interface */ diff --git a/player.h b/player.h index 3dce2f0..8ecce40 100644 --- a/player.h +++ b/player.h @@ -400,68 +400,6 @@ VG_STATIC void reset_player_poll( int argc, char const *argv[] ); VG_STATIC void player_init(void) /* 1 */ { -#if 0 - player.input_js1h = vg_create_named_input( "steer-h", k_input_type_axis ); - player.input_js1v = vg_create_named_input( "steer-v", k_input_type_axis ); - player.input_grab = vg_create_named_input( "grab", k_input_type_axis_norm ); - player.input_js2h = vg_create_named_input( "grab-h", k_input_type_axis ); - player.input_js2v = vg_create_named_input( "grab-v", k_input_type_axis ); - player.input_jump = vg_create_named_input( "jump", k_input_type_button ); - player.input_push = vg_create_named_input( "push", k_input_type_button ); - player.input_walk = vg_create_named_input( "walk", k_input_type_button ); - - player.input_walkh = vg_create_named_input( "walk-h", - k_input_type_axis ); - player.input_walkv = vg_create_named_input( "walk-v", - k_input_type_axis ); - - - player.input_switch_mode = vg_create_named_input( "switch-mode", - k_input_type_button ); - player.input_reset = vg_create_named_input( "reset", k_input_type_button ); - - const char *default_cfg[] = - { - "bind steer-h gp-ls-h", - "bind -steer-h a", - "bind +steer-h d", - - "bind steer-v gp-ls-v", - "bind -steer-v w", - "bind +steer-v s", - - "bind grab gp-rt", - "bind +grab shift", - "bind grab-h gp-rs-h", - "bind grab-v gp-rs-v", - - "bind jump space", - "bind jump gp-a", - - "bind push gp-b", - "bind push w", - - "bind walk shift", - "bind walk gp-ls", - - "bind walk-h gp-ls-h", - "bind walk-v -gp-ls-v", - "bind +walk-h d", - "bind -walk-h a", - "bind +walk-v w", - "bind -walk-v s", - - "bind reset gp-lb", - "bind reset r", - - "bind switch-mode gp-y", - "bind switch-mode e", - }; - - for( int i=0; irb, player->rb.to_world[0], axel, - k_board_spring, k_board_dampener, + k_surface_spring, k_surface_dampener, s->substep_delta ); v3_add( normal, s->surface_picture, s->surface_picture ); diff --git a/rigidbody.h b/rigidbody.h index 746c684..0bba8f1 100644 --- a/rigidbody.h +++ b/rigidbody.h @@ -16,8 +16,6 @@ VG_STATIC void rb_tangent_basis( v3f n, v3f tx, v3f ty ); VG_STATIC bh_system bh_system_rigidbodies; - - #ifndef RIGIDBODY_H #define RIGIDBODY_H diff --git a/steam.h b/steam.h index 5d768b8..4f98dd9 100644 --- a/steam.h +++ b/steam.h @@ -180,6 +180,65 @@ VG_STATIC void steam_on_recieve_current_stats( CallbackMsg_t *msg ) VG_STATIC ISteamInput *steam_hInput; +VG_STATIC u32 utf8_byte0_byte_count( u8 char0 ) +{ + for( u32 k=2; k<4; k++ ) + { + if( !(char0 & (0x80 >> k)) ) + return k; + } + + return 0; +} + +VG_STATIC void str_utf8_collapse( const char *str, char *buf, u32 length ) +{ + u8 *ustr = (u8 *)str; + u32 utf32_code = 0x00000000; + u32 i=0, j=0, utf32_byte_ct=0; + + for(;i < length-1;) + { + if( ustr[i] == 0x00 ) + break; + + if( ustr[i] & 0x80 ) + { + if( utf32_byte_ct ) + { + utf32_byte_ct --; + utf32_code |= (ustr[i] & 0x3F) << (utf32_byte_ct*6); + + if( !utf32_byte_ct ) + { + const char *match; + size_t chars = anyascii( utf32_code, &match ); + + for( u32 k=0; k> utf32_byte_ct); + utf32_code <<= utf32_byte_ct*6; + } + } + else + { + utf32_byte_ct = 0x00; + buf[j ++] = str[i]; + } + + i++; + } + + buf[j] = 0x00; +} + VG_STATIC int steam_init(void) { const char *username = NULL; -- 2.25.1