refactor
authorhgn <hgodden00@gmail.com>
Tue, 15 Nov 2022 21:05:11 +0000 (21:05 +0000)
committerhgn <hgodden00@gmail.com>
Tue, 15 Nov 2022 21:05:11 +0000 (21:05 +0000)
12 files changed:
.gitignore
build.c
build.sh
common.h
menu.h
play.sh [deleted file]
player.h
player_physics.h
server.c
skaterift.c
steam.h
world_routes.h

index a9534e41b75c95001f44f2c769bd2b6bd85865f0..510138c2a2960889413c10c2b36c624fae4b63fc 100755 (executable)
@@ -1,55 +1,13 @@
-# Gitignore for MMV project.
-#  Whitelist mode
+*.o
+*.so
+*.dll
+*.log
 
-# Ignore all but directories
-*
-!*/
+# soft links
+steamworks_sdk
+vg
 
 bin/
-restricted/
 dist/
 
-# ALLOW ============================
-!.gitattributes
-!.gitignore
-!.gitmodules
-
-# Code sources _____________________
-# C source files
-!*.c
-!*.h
-
-# Blender projects
-!*.blend
-
-# GLSL shader source files
-!*.fs
-!*.vs
-!*.gls
-!*.glsl
-
-# Python source files
-!*.py
-
-# Build scripts
-!*.sh
-!*.bat
-!*.conf
-
-# Compiled resources _______________
-# MMV proprietary files
-!*.vmd
-!*.vma
-!*.cfg
-!*.vmv
-!*.map
-!*.mdl
-
-# Other game assets (3rd party)
-!*.bdf
-!*.png
-!*.ogg
-!*.txt
-!*.tga
-!*.vdf
-!*.qoi
+compile_commands.json
diff --git a/build.c b/build.c
index bc6e81a89d6cc8e7ce9a1bfcf0cbfa62971044d5..96a8930cfaa8ddb90238c3e821e9d4691d190161 100644 (file)
--- a/build.c
+++ b/build.c
@@ -1,3 +1,4 @@
+#include <time.h>
 #include "vg/vg_platform.h"
 #include "vg/vg_log.h"
 #include "vg/vg_opt.h"
@@ -15,7 +16,7 @@ void build_server( enum compiler compiler )
 {
    vg_build_start( "skaterift_server", compiler );
    vg_build_object( "server.c " );
-   vg_build_link( "-pthread -lm -lsdkencryptedappticket -lsteam_api " );
+   vg_build_link( "-lm -lsdkencryptedappticket -lsteam_api " );
    vg_build_library_dir( "-L./vg/dep/steam " );
 
    vg_build_bin_dependency_file( "vg/dep/steam/steamclient.so" );
@@ -42,7 +43,6 @@ void build_game( enum compiler compiler )
    vg_build_symbolic_link( "sound_src", "sound" );
    vg_build_syscall( "mkdir -p %s/cfg", vg_compiler.build_dir );
 
-   vg_build_miniaudio();
    vg_build();
    compiled_something = 1;
 }
@@ -72,6 +72,16 @@ int main( int argc, char *argv[] )
       if( vg_long_opt( "mingw" ) )
          build_game( k_compiler_mingw );
 
+      if( vg_opt('p') || vg_long_opt("run") )
+      {
+         chdir( vg_compiler.build_dir );
+         if( vg_compiler.compiler == k_compiler_mingw )
+            vg_build_syscall( "wine %s.exe", vg_compiler.name );
+         else
+            vg_build_syscall( "./%s", vg_compiler.name );
+         chdir( "../../" );
+      }
+
       if( vg_long_opt( "tar" ) || vg_opt( 't' ) )
       {
          vg_build_syscall( "mkdir -p dist" );
@@ -80,13 +90,6 @@ int main( int argc, char *argv[] )
                               vg_compiler.name, uid, vg_compiler.build_dir );
       }
 
-      if( vg_opt('p') || vg_long_opt("run") )
-      {
-         chdir( vg_compiler.build_dir );
-         vg_build_syscall( "./%s", vg_compiler.name );
-         chdir( "../../" );
-      }
-
       if( vg_long_opt( "zip" ) || vg_opt( 'z' ) )
       {
          vg_build_syscall( "mkdir -p dist" );
index f6ac6295341206ca69d3a04bc492e8400bf66dd2..d807648f5c4c0b8567c1d98974b8037da16bbe8d 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -1 +1 @@
-clang -fsanitize=address -O0 -Ivg/src build.c -o /tmp/tmpsr && /tmp/tmpsr $@
+clang -fsanitize=address -O0 -I./vg build.c -o /tmp/tmpsr && /tmp/tmpsr $@
index e9df311a030462474d0c27d2d09bc9c967b9bedc..c3f3e69d6fff15c262feeeaa6de270c1e30f3b97 100644 (file)
--- a/common.h
+++ b/common.h
@@ -9,7 +9,7 @@
 #define VG_3D
 #define VG_FRAMEBUFFER_RESIZE 1
 #include "vg/vg.h"
-#include "anyascii/anyascii.h"
+#include "submodules/anyascii/impl/c/anyascii.c"
 
 #define RESET_MAX_TIME 45.0
 
diff --git a/menu.h b/menu.h
index 2945449fff77fdadad516a5d5281009dee813354..e52f3d7faa8265a34d37aea146ee7a55ea0085ca 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -7,10 +7,8 @@
 #include "player.h"
 
 #include "shaders/menu.h"
-#include "vg/vg_steam_friends.h"
-
-#define CUTE_FILES_IMPLEMENTATION
-#include "vg/dep/randygaul/cute_files.h"
+#include "vg_steam_friends.h"
+#include "submodules/tinydir/tinydir.h"
 
 VG_STATIC mdl_context menu_model;
 VG_STATIC glmesh      menu_glmesh;
@@ -194,7 +192,7 @@ VG_STATIC void menu_btn_reset( int event )
 
 VG_STATIC void menu_btn_fuckoff( int event )
 {
-   glfwSetWindowShouldClose( vg.window, 1 );
+   vg.window_should_close = 1;
 }
 
 VG_STATIC void menu_btn_quit( int event )
@@ -220,13 +218,13 @@ VG_STATIC void menu_btn_map( int event )
    game_menu.map_count = 0;
    game_menu.selected_map = 0;
 
-   cf_dir_t dir;
-   cf_dir_open( &dir, "maps" );
+   tinydir_dir dir;
+   tinydir_open( &dir, "maps" );
 
    while( dir.has_next )
    {
-      cf_file_t file;
-      cf_read_file( &dir, &file );
+      tinydir_file file;
+      tinydir_readfile( &dir, &file );
       
       if( file.is_reg )
       {
@@ -240,10 +238,10 @@ VG_STATIC void menu_btn_map( int event )
             break;
       }
 
-      cf_dir_next( &dir );
+      tinydir_next( &dir );
    }
 
-   cf_dir_close(&dir);
+   tinydir_close(&dir);
 }
 
 VG_STATIC void menu_crap_ui(void)
diff --git a/play.sh b/play.sh
deleted file mode 100755 (executable)
index b2c57c9..0000000
--- a/play.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-cd bin/skaterift-clang/
-./skaterift $@
-cd ../../
index d3038915c0b09b6393c66c0f0dbcdf39bc18f2de..d0ce43137cb08cda399fb80cc64db3b2f58a78c6 100644 (file)
--- a/player.h
+++ b/player.h
@@ -395,7 +395,7 @@ VG_STATIC void player_mouseview(void)
 
    v2_muladds( player.angles, vg.mouse_delta, 0.0025f, player.angles );
 
-   if( vg.gamepad_use_trackpad_look )
+   if( vg_input.controller_should_use_trackpad_look )
    {
       static v2f last_input;
       static v2f vel;
index 9d58e17dfa7196147b7ead3cc944a677c4dfbe09..e396e0031d3771cb937a5955b73c5f13bbed2de3 100644 (file)
@@ -456,6 +456,12 @@ VG_STATIC void player_walk_physics(void)
       }
       v3_add( dt, phys->rb.co, phys->rb.co );
 
+      if( len )
+      {
+         struct world_material *surface_mat = world_contact_material(manifold);
+         player.surface_prop = surface_mat->info.surface_prop;
+      }
+
       /* jump */
       if( player.input_jump->button.value )
       {
index 4b088c17f404b6a5da2025b09720f8e72083a2bd..e3149c9caa371513ea1a64e95a39389cb1c7a8dd 100644 (file)
--- a/server.c
+++ b/server.c
@@ -11,6 +11,7 @@
 #define _DEFAULT_SOURCE
 #include <unistd.h>
 #include <signal.h>
+#include <time.h>
 
 volatile sig_atomic_t sig_stop;
 
index 97f6553d7cb438a20d6a8680eb8f1033f63840a1..d4bf10ca42d014aec0c14148abf60750ec634e3f 100644 (file)
@@ -9,22 +9,10 @@
  *            '        ' '--' [] '----- '----- '     ' '---'  SOFTWARE
  *
  * =============================================================================
- *
- * register: shader register & init scheduling
- * init:     initialization
- * update:   logic
- * render:   graphics
- * free:     resource free
- * 
  */
 
-#define VG_3D
 #define VG_STATIC static
-//#define VG_STATIC 
-
-//#define VG_MINIMAL_TEST
-#ifndef VG_MINIMAL_TEST
-
+#define VG_GAME
 #define SR_NETWORKED
 
 #include "common.h"
@@ -43,6 +31,8 @@ int main( int argc, char *argv[] )
    vg_mem.use_libc_malloc = 0;
    vg_set_mem_quota( 128*1024*1024 );
    vg_enter( argc, argv, "Voyager Game Engine" ); 
+
+   return 0;
 }
 
 VG_STATIC void highscores_save_at_exit(void*_)
@@ -50,9 +40,13 @@ VG_STATIC void highscores_save_at_exit(void*_)
    highscores_serialize_all();
 }
 
-VG_STATIC void vg_preload(void)
+VG_STATIC void vg_launch_opt(void)
 {
 
+}
+
+VG_STATIC void vg_preload(void)
+{
    vg_convar_push( (struct vg_convar){
       .name = "cl_ui",
       .data = &cl_ui,
@@ -352,11 +346,11 @@ VG_STATIC void run_debug_info(void)
          player.phys.rb.co[0], player.phys.rb.co[1], player.phys.rb.co[2] );
    ui_text( (ui_px [2]){ 0, 40 }, buf, 1, k_text_align_left );
 
-   if( vg.gamepad_ready )
+   if( vg_input.controller_handle )
    {
-      for( int i=0; i<6; i++ )
+      for( int i=0; i<vg_list_size(vg_input.controller_axises); i++ )
       {
-         snprintf( buf, 40, "%.2f", vg.gamepad.axes[i] );
+         snprintf( buf, 40, "%.2f", vg_input.controller_axises[i] );
          ui_text( (ui_px [2]){ 0, (i+3)*20 }, buf, 1, k_text_align_left );
       }
    }
@@ -366,75 +360,3 @@ VG_STATIC void run_debug_info(void)
             "Gamepad not ready", 1, k_text_align_left );
    }
 }
-
-#else
-
-#define VG_TIMESTEP_FIXED (1.0/60.0)
-#define VG_3D
-#define VG_FRAMEBUFFER_RESIZE 1
-#include "vg/vg.h"
-
-int main( int argc, char *argv[] )
-{
-   vg_prealloc_quota( 512*1024*1024 );
-   vg_enter( argc, argv, "Voyager Game Engine" ); 
-}
-
-VG_STATIC void vg_preload(void)
-{
-vg_info(" Copyright  .        . .       -----, ,----- ,---.   .---.  \n" );
-vg_info(" 2021-2022  |\\      /| |           /  |      |    | |    /| \n" );
-vg_info("            | \\    / | +--        /   +----- +---'  |   / | \n" );
-vg_info("            |  \\  /  | |         /    |      |   \\  |  /  | \n" );
-vg_info("            |   \\/   | |        /     |      |    \\ | /   | \n" );
-vg_info("            '        ' '--' [] '----- '----- '     ' '---'  " 
-        "SOFTWARE\n" );
-}
-
-VG_STATIC void vg_load(void)
-{
-   vg_bake_shaders();
-   vg_console_load_autos();
-}
-
-VG_STATIC void vg_start(void)
-{
-}
-
-VG_STATIC void vg_update( int loaded )
-{
-}
-
-VG_STATIC void vg_update_fixed( int loaded )
-{
-}
-
-VG_STATIC void vg_update_post( int loaded )
-{
-}
-
-VG_STATIC void vg_framebuffer_resize( int w, int h )
-{
-}
-
-VG_STATIC void vg_render(void)
-{
-   glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-   glViewport( 0,0, vg.window_x, vg.window_y );
-   glDisable( GL_DEPTH_TEST );
-
-   glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
-   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
-   
-   /* Other shite */
-   glDisable(GL_BLEND);
-   glDisable( GL_DEPTH_TEST );
-   vg_lines_drawall( (float *)vg.pv );
-   glViewport( 0,0, vg.window_x, vg.window_y );
-}
-
-VG_STATIC void vg_ui(void)
-{
-}
-
-#endif
diff --git a/steam.h b/steam.h
index 47de1089a42aad244497970394fe9be1c7a3478f..360a45fd7bda6d6a070ae508faec44c22b1334b8 100644 (file)
--- a/steam.h
+++ b/steam.h
@@ -261,6 +261,9 @@ VG_STATIC void steam_update(void)
    {
       steamworks_event_loop( hSteamClientPipe );
 
+      /* TODO
+       * We can probably request this from SDL too
+       */
       if( steam_hInput )
       {
          SteamAPI_ISteamInput_RunFrame( steam_hInput, 0 );
@@ -268,7 +271,7 @@ VG_STATIC void steam_update(void)
          InputHandle_t joy0 = SteamAPI_ISteamInput_GetControllerForGamepadIndex( 
                                  steam_hInput, 0 );
 
-         vg.gamepad_use_trackpad_look = 0;
+         vg_input.controller_should_use_trackpad_look = 0;
          if( joy0 != 0 )
          {
             ESteamInputType type = SteamAPI_ISteamInput_GetInputTypeForHandle(
@@ -276,7 +279,7 @@ VG_STATIC void steam_update(void)
 
             if( type == k_ESteamInputType_SteamController )
             {
-               vg.gamepad_use_trackpad_look = 1;
+               vg_input.controller_should_use_trackpad_look = 1;
                menu_display_controller = k_menu_controller_type_steam;
             }
             else if( type == k_ESteamInputType_SteamDeckController )
index 6f34c8c56de1a1e00f1316364ff871feeec4df02..795f57b9f3eae6143abb3eb520c589b1c05943e8 100644 (file)
@@ -5,6 +5,7 @@
 #ifndef ROUTES_H
 #define ROUTES_H
 
+#include <time.h>
 #include "world.h"
 #include "world_gate.h"