non-meaningful cleanup
authorhgn <hgodden00@gmail.com>
Sat, 13 Jan 2024 13:42:59 +0000 (13:42 +0000)
committerhgn <hgodden00@gmail.com>
Sat, 13 Jan 2024 13:42:59 +0000 (13:42 +0000)
13 files changed:
ent_skateshop.c
highscores.c [deleted file]
highscores.h [deleted file]
network.h
player.c
skaterift.c
workshop.c
world_entity.c
world_entity.h
world_info.h
world_load.c
world_render.c
world_routes.c

index 8aa5fbc46c397cb910a01c5ff0dedcb6006eab4d..85a0fa48b5fda101d32380f03790b9ca3c3532df 100644 (file)
@@ -10,7 +10,6 @@
 #include "player.h"
 #include "gui.h"
 #include "menu.h"
-#include "highscores.h"
 #include "steam.h"
 #include "addon.h"
 #include "save.h"
diff --git a/highscores.c b/highscores.c
deleted file mode 100644 (file)
index c72b987..0000000
+++ /dev/null
@@ -1,547 +0,0 @@
-#ifndef HIGHSCORES_C
-#define HIGHSCORES_C
-
-#include "highscores.h"
-
-static int highscore_cmp_points( void *a, void *b )
-{
-   highscore_record *pa = a, *pb = b;
-   return (int)pa->points - (int)pb->points;
-}
-
-static int highscore_cmp_datetime( void *a, void *b )
-{
-   highscore_record *pa = a, *pb = b;
-   
-   if( pa->datetime == pb->datetime ) return 0;
-   return pa->datetime < pb->datetime? 1: -1;
-}
-
-static int highscore_cmp_time( void *a, void *b )
-{
-   highscore_record *pa = a, *pb = b;
-   return (int)pb->time - (int)pa->time;
-}
-
-static int highscore_cmp_playerid( void *a, void *b )
-{
-   highscore_record *pa = a, *pb = b;
-   if( pa->playerid == pb->playerid ) return 0;
-   return pa->playerid < pb->playerid? -1: 1;
-}
-
-static int highscore_cmp_playerinfo_playerid( void *a, void *b )
-{
-   highscore_playerinfo *pa = a, *pb = b;
-   if( pa->playerid == pb->playerid ) return 0;
-   return pa->playerid < pb->playerid? -1: 1;
-}
-
-static void highscores_create_db(void)
-{
-   struct highscore_system *sys = &highscore_system;
-
-   vg_info( "Initializing database nodes\n" );
-   memset( &sys->dbheader, 0, sizeof(highscore_database) );
-
-   sys->dbheader.pool_head = aatree_init_pool( &sys->aainfo, sys->pool_size );
-   sys->dbheader.entry_capacity = sys->pool_size;
-
-   for( int i=0; i<vg_list_size(sys->dbheader.tracks); i++ )
-   {
-      highscore_track_table *table = &sys->dbheader.tracks[i];
-      table->root_points = AATREE_PTR_NIL;
-      table->root_playerid = AATREE_PTR_NIL;
-      table->root_time = AATREE_PTR_NIL;
-      table->root_datetime = AATREE_PTR_NIL;
-   }
-
-   /* Initialize secondary db */
-   sys->dbheader.playerinfo_head = aatree_init_pool( 
-         &sys->aainfo_playerinfo,
-         sys->playerinfo_pool_size );
-   sys->dbheader.playerinfo_capacity = sys->playerinfo_pool_size;
-   sys->dbheader.playerinfo_root = AATREE_PTR_NIL;
-}
-
-static int highscores_read( const char *path ){
-   struct highscore_system *sys = &highscore_system;
-
-   if( path == NULL )
-      path = ".aadb";
-
-   FILE *fp = fopen( path, "rb" );
-   if( fp ){
-      vg_info( "Loading existing database\n" );
-      
-      u64 count = fread( &sys->dbheader, sizeof(highscore_database), 1, fp );
-
-      if( count != 1 )
-      {
-         vg_error( "Unexpected EOF reading database header\n" );
-         return 0;
-      }
-
-      count = fread( sys->data, sizeof(highscore_record), 
-                     sys->pool_size, fp );
-
-      if( count != sys->pool_size )
-      {
-         vg_error( "Unexpected EOF reading database contents;"
-                   " %lu records of %u were read\n", count, sys->pool_size );
-         return 0;
-      }
-
-      count = fread( sys->playerinfo_data, sizeof(highscore_playerinfo),
-                     sys->playerinfo_pool_size, fp );
-
-      if( count != sys->playerinfo_pool_size )
-      {
-         vg_error( "Unexpected EOF reading playerinfo contents;"
-                   " %lu records of %u were read\n", count, 
-                   sys->playerinfo_pool_size );
-         return 0;
-      }
-
-      fclose( fp );
-      return 1;
-   }
-   else
-   {
-      vg_low( "No existing database found (%s)\n", path );
-      return 0;
-   }
-}
-
-static void highscores_init( u32 pool_size, u32 playerinfo_pool_size )
-{
-   struct highscore_system *sys = &highscore_system;
-
-   sys->data = vg_linear_alloc( vg_mem.rtmemory, 
-                                pool_size*sizeof(highscore_record) );
-
-   sys->playerinfo_data = 
-      vg_linear_alloc( vg_mem.rtmemory,
-                       playerinfo_pool_size * sizeof(highscore_playerinfo) );
-
-   memset( sys->data, 0, pool_size*sizeof(highscore_record) );
-   memset( sys->playerinfo_data, 0, 
-         playerinfo_pool_size*sizeof(highscore_playerinfo) );
-
-
-   /* This is ugly.. too bad! */
-   sys->aainfo.base = highscore_system.data;
-   sys->aainfo.stride = sizeof(highscore_record);
-   sys->aainfo.offset = offsetof(highscore_record,pool);
-   sys->aainfo.p_cmp = NULL;
-
-   sys->aainfo_datetime.base = highscore_system.data;
-   sys->aainfo_datetime.stride = sizeof(highscore_record);
-   sys->aainfo_datetime.offset = offsetof(highscore_record,aa.datetime);
-   sys->aainfo_datetime.p_cmp = highscore_cmp_datetime;
-
-   sys->aainfo_points.base = highscore_system.data;
-   sys->aainfo_points.stride = sizeof(highscore_record);
-   sys->aainfo_points.offset = offsetof(highscore_record,aa.points);
-   sys->aainfo_points.p_cmp = highscore_cmp_points;
-
-   sys->aainfo_time.base = highscore_system.data;
-   sys->aainfo_time.stride = sizeof(highscore_record);
-   sys->aainfo_time.offset = offsetof(highscore_record,aa.time);
-   sys->aainfo_time.p_cmp = highscore_cmp_time;
-
-   sys->aainfo_playerid.base = highscore_system.data;
-   sys->aainfo_playerid.stride = sizeof(highscore_record);
-   sys->aainfo_playerid.offset = offsetof(highscore_record,aa.playerid);
-   sys->aainfo_playerid.p_cmp = highscore_cmp_playerid;
-
-   sys->aainfo_playerinfo_playerid.base = highscore_system.playerinfo_data;
-   sys->aainfo_playerinfo_playerid.stride = sizeof(highscore_playerinfo);
-   sys->aainfo_playerinfo_playerid.offset = 
-      offsetof(highscore_playerinfo,aa_playerid);
-   sys->aainfo_playerinfo_playerid.p_cmp = highscore_cmp_playerinfo_playerid;
-
-   /* TODO: Is this even useable? */
-   sys->aainfo_playerinfo.base = highscore_system.playerinfo_data;
-   sys->aainfo_playerinfo.stride = sizeof(highscore_playerinfo);
-   sys->aainfo_playerinfo.offset = offsetof(highscore_playerinfo,aapn);
-   sys->aainfo_playerinfo.p_cmp = NULL;
-
-   sys->playerinfo_pool_size = playerinfo_pool_size;
-   sys->pool_size = pool_size;
-}
-
-static int highscores_serialize_all(void)
-{
-   struct highscore_system *sys = &highscore_system;
-   vg_info( "Serializing database\n" );
-
-   FILE *fp = fopen( ".aadb", "wb" );
-
-   if( !fp )
-   {
-      vg_error( "Could not open .aadb\n" );
-      return 0;
-   }
-
-   fwrite( &sys->dbheader, sizeof(highscore_database), 1, fp );
-   fwrite( sys->data, sizeof(highscore_record), 
-           sys->dbheader.entry_capacity, fp );
-   fwrite( sys->playerinfo_data, sizeof(highscore_playerinfo),
-            sys->dbheader.playerinfo_capacity, fp );
-
-   fclose( fp );
-   return 1;
-}
-
-static highscore_record *highscore_find_user_record( u64 playerid, 
-                                                        u32 trackid )
-{
-   struct highscore_system *sys = &highscore_system;
-
-   highscore_track_table *table = &sys->dbheader.tracks[trackid];
-   highscore_record temp;
-   temp.playerid = playerid;
-
-   aatree_ptr find = 
-      aatree_find( &sys->aainfo_playerid, table->root_playerid, &temp );
-
-   if( find == AATREE_PTR_NIL )
-      return NULL;
-
-   return aatree_get_data( &sys->aainfo_playerid, find );
-}
-
-static aatree_ptr highscores_push_record( highscore_record *record )
-{
-   struct highscore_system *sys = &highscore_system;
-
-   vg_low( "Inserting record into database for track %hu\n",record->trackid );
-
-   if( record->trackid >= vg_list_size(sys->dbheader.tracks) ){
-      vg_error( "TrackID out of range (%hu>=%d)\n", record->trackid,
-                  vg_list_size(sys->dbheader.tracks) );
-
-      return AATREE_PTR_NIL;
-   }
-
-   /* Search for existing record on this track */
-   highscore_track_table *table = &sys->dbheader.tracks[record->trackid];
-   aatree_ptr existing = aatree_find( &sys->aainfo_playerid, 
-                                       table->root_playerid,
-                                       record );
-
-   if( existing != AATREE_PTR_NIL ){
-      highscore_record *crecord = aatree_get_data( &sys->aainfo_playerid, 
-                                                   existing );
-
-      if( crecord->time < record->time || 
-            (crecord->time == record->time && crecord->points > record->points))
-      {
-         vg_low( "Not overwriting better score\n" );
-         return existing;
-      }
-
-      vg_low( "Freeing existing record for player %lu\n", record->playerid );
-      table->root_playerid = aatree_del( &sys->aainfo_playerid, existing );
-      table->root_datetime = aatree_del( &sys->aainfo_datetime, existing );
-      table->root_points = aatree_del( &sys->aainfo_points, existing );
-      table->root_time = aatree_del( &sys->aainfo_time, existing );
-
-      aatree_pool_free( &sys->aainfo, existing, &sys->dbheader.pool_head );
-   }
-
-   aatree_ptr index = 
-      aatree_pool_alloc( &sys->aainfo, &sys->dbheader.pool_head );
-
-   if( index == AATREE_PTR_NIL )
-   {
-      vg_error( "Database records are over capacity!\n" );
-      return index;
-   }
-
-   highscore_record *dst = aatree_get_data( &sys->aainfo, index );
-   memset( dst, 0, sizeof(highscore_record) );
-
-   dst->trackid = record->trackid;
-   dst->datetime = record->datetime;
-   dst->playerid = record->playerid;
-   dst->points = record->points;
-   dst->time = record->time;
-
-   table->root_time = 
-      aatree_insert( &sys->aainfo_time, table->root_time, index );
-   table->root_datetime =
-      aatree_insert( &sys->aainfo_datetime, table->root_datetime, index );
-   table->root_playerid = 
-      aatree_insert( &sys->aainfo_playerid, table->root_playerid, index );
-   table->root_points =
-      aatree_insert( &sys->aainfo_points, table->root_points, index );
-
-   return index;
-}
-
-static aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] )
-{
-   char name[17];
-   for( int i=0; i<16; i++ )
-      name[i] = nick[i];
-   name[16] = '\0';
-
-   vg_low( "Updating %lu's nickname -> %s\n", steamid, name );
-
-   struct highscore_system *sys = &highscore_system;
-   
-   highscore_playerinfo temp;
-   temp.playerid = steamid;
-
-   aatree_ptr record = aatree_find( &sys->aainfo_playerinfo_playerid, 
-                                     sys->dbheader.playerinfo_root,
-                                     &temp );
-   highscore_playerinfo *info;
-
-   if( record != AATREE_PTR_NIL )
-   {
-      info = aatree_get_data( &sys->aainfo_playerinfo, record );
-   }
-   else
-   {
-      record = aatree_pool_alloc( &sys->aainfo_playerinfo, 
-                                  &sys->dbheader.playerinfo_head );
-
-      if( record == AATREE_PTR_NIL )
-      {
-         vg_error( "Player info database is over capacity!\n" );
-         return AATREE_PTR_NIL;
-      }
-
-      info = aatree_get_data( &sys->aainfo_playerinfo, record );
-      memset( info, 0, sizeof(highscore_playerinfo) );
-
-      info->playerid = steamid;
-      sys->dbheader.playerinfo_root = aatree_insert( 
-            &sys->aainfo_playerinfo_playerid,
-            sys->dbheader.playerinfo_root, record );
-   }
-
-   for( int i=0; i<16; i++ )
-      info->nickname[i] = nick[i];
-
-   return AATREE_PTR_NIL;
-}
-
-/* Get the length of a string, bounded by '\0' or len, whichever is first */
-static int highscore_strlen( const char *str, int len )
-{
-   int str_length;
-   for( str_length=0; str_length<len; str_length++ )
-      if( !str[str_length] )
-         return str_length;
-
-   return str_length;
-}
-
-/* Print the string(max length:len) centered into buf (has width:width) */
-static void highscore_strc( char *buf, const char *str, int len, int width )
-{
-   int str_length = highscore_strlen( str, len ),
-       offs = (width-str_length)/2;
-
-   for( int i=0; i<str_length; i++ )
-   {
-      int j=i+offs;
-
-      if( j >= width )
-         return;
-
-      buf[j] = str[i];
-   }
-}
-
-/* Print the string(max length:len) left aligned into buf */
-static void highscore_strl( char *buf, const char *str, int len )
-{
-   for( int i=0; i<len; i++ )
-   {
-      if( !str[i] )
-         return;
-
-      buf[i] = str[i];
-   }
-}
-
-/* Print the string (max length:len) right aligned into buf (has width:width) */
-static void highscore_strr( char *buf, const char *str, int len, int width )
-{
-   int str_length = highscore_strlen( str, len );
-   
-   for( int i=0; i<len; i++ )
-   {
-      if( !str[i] )
-         return;
-
-      buf[width-str_length+i] = str[i];
-   }
-}
-
-/* Print integer (padded with: alt), right aligned into buf(width: len)
- * returns number of digits (not including alt), that were written to buf */
-static int highscore_intr( char *buf, int value, int len, char alt )
-{
-   int i=0;
-   while(value){
-      if( i>=len ) 
-         return i;
-
-      buf[ len-1 - (i ++) ] = '0' + (value % 10);
-      value /= 10;
-   }
-
-   for( ;i<len; i ++ )
-      buf[ len-1 - i ] = alt;
-
-   return i;
-}
-
-/* Print integer into buffer with max length len 
- * retuns the number of digits written to buf */
-static int highscore_intl( char *buf, int value, int len ){
-   if( value ){
-      char temp[32];
-      int i=0;
-      while(value){
-         if( i>=len ) 
-            break;
-
-         temp[ i ++ ] = '0' + (value % 10);
-         value /= 10;
-      }
-
-      if( i>len )
-         i = len;
-
-      for( int j=0; j<i; j ++ )
-         buf[j] = temp[ i-1-j ];
-
-      return i;
-   }
-   else{
-      buf[ 0 ] = '0';
-      return 1;
-   }
-}
-
-/* Clear buffer with length using clr character */
-static void highscore_clear( char *buf, char clr, int length )
-{
-   for( int i=0; i<length; i++ )
-      buf[i] = clr;
-}
-
-/*
-       Megapark Green      
---------------------------
- #|   Player |  Time | Pts 
- 1|aaaabbbbcc 5:23.32 30000
- 2|       jef 0:20.34 10000
- 3|aaabbbcccl 2:30.45 20000
- 4|
- 5|
- 6|
- 7|
- 8|
- 9|
-10|
-*/
-
-/* Generate a highscores board in text form, the width is always 27. Buffer 
- * must be (count+3)*27 in size. */
-static void highscores_board_generate( char *buf, u32 id, u32 count )
-{
-   int w=27;
-   highscore_clear( buf, ' ', (count+3)*w );
-
-   struct track_info *inf = &track_infos[id];
-   struct highscore_system *sys = &highscore_system;
-
-   highscore_track_table *table = &sys->dbheader.tracks[ id ];
-   aatree_ptr it = aatree_kth( &sys->aainfo_time, table->root_time, 0 );
-
-   highscore_strc ( buf+w*0, inf->name, w,w );
-   highscore_clear( buf+w*1, '-', w );
-   highscore_strl ( buf+w*2, " #|     Player     | Time  ", 27 );
-
-   for( int i=0; i<count; i++ )
-   {
-      char *line = buf+w*(3+i);
-      highscore_intr( line, i+1, 2, ' ' );
-      line[2] = '|';
-
-      if( it == AATREE_PTR_NIL )
-         continue;
-
-      highscore_record *record = aatree_get_data( &sys->aainfo_time, it );
-      highscore_playerinfo temp;
-      temp.playerid = record->playerid;
-
-      aatree_ptr info_ptr = aatree_find( &sys->aainfo_playerinfo_playerid,
-                                          sys->dbheader.playerinfo_root,
-                                          &temp );
-      
-      /* Player name */
-      if( info_ptr == AATREE_PTR_NIL )
-         highscore_strl( line+3, "unknown", 16 );
-      else
-      {
-         highscore_playerinfo *inf = aatree_get_data( 
-               &sys->aainfo_playerinfo_playerid, info_ptr );
-
-         highscore_strl( line+3, inf->nickname, 16 );
-
-         /* yep, this is fucking awesome! */
-         if( inf->playerid == 0x8297744501001001 ||
-             inf->playerid == 0x1ec4620101001001 ||
-             inf->playerid == 0x0110000145749782 ||
-             inf->playerid == 0x011000010162c41e )
-         {
-            i --;
-            /* FIXME: Clear line, or yknow, do it properly */
-         }
-      }
-
-      u16 centiseconds = record->time,
-          seconds      = centiseconds / 100,
-          minutes      = seconds / 60;
-
-      centiseconds %= 100;
-      seconds     %= 60;
-      minutes     %= 60;
-
-      if( minutes > 9 ) minutes = 9;
-      
-      /* Timer */
-      highscore_intr( line+20, minutes, 1, '0' );
-      line[21] = ':';
-      highscore_intr( line+22, seconds, 2, '0' );
-      line[24] = '.';
-      highscore_intr( line+25, centiseconds, 2, '0' );
-
-#if 0
-      /* Score */
-      highscore_intl( line+22, record->points, 5 );
-#endif
-      it = aatree_next( &sys->aainfo_time, it );
-   }
-}
-
-/* Print string out to file using newlines. Count is number of records 
- * ( this requires a buffer of (count+3)*27 size */
-static void highscores_board_printf( FILE *fp, const char *buf, u32 count )
-{
-   int w=27;
-
-   for( int i=0; i<count+3; i++ )
-      fprintf( fp, "%.27s\n", &buf[i*w] );
-}
-
-#endif /* HIGHSCORES_C */
diff --git a/highscores.h b/highscores.h
deleted file mode 100644 (file)
index 0c4ae54..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
- */
-
-#ifndef HIGHSCORES_H
-#define HIGHSCORES_H
-
-#include "vg/vg_store.h"
-#include "vg/vg_stdint.h"
-#include "world_info.h"
-
-/* 
- * Designed to be used across client and server,
- * for the client its only storing the local users records, for server its 
- * storing many.
- */
-
-typedef struct highscore highscore;
-typedef struct highscore_record highscore_record;
-typedef struct highscore_track_table highscore_track_table;
-typedef struct highscore_database highscore_database;
-typedef struct highscore_playerinfo highscore_playerinfo;
-
-#pragma pack(push,1)
-
-struct highscore_playerinfo
-{
-   char nickname[16];
-   u64 playerid;
-
-   union
-   {
-      aatree_pool_node aapn;
-      aatree_node aa_playerid;
-   };
-};
-
-struct highscore_record
-{
-   u16 trackid, points, time, reserved0;
-   u64 playerid;
-   u32 datetime;
-   u32 reserved1;
-   
-   union
-   {
-      struct
-      {
-         aatree_node points,
-                     time,
-                     playerid,
-                     datetime;
-      }
-      aa;
-
-      aatree_pool_node pool;
-   };
-};
-
-struct highscore_track_table
-{
-   aatree_ptr root_points,
-              root_time,
-              root_playerid,
-              root_datetime;
-
-   u32 reserved[12];
-};
-
-struct highscore_database
-{
-   highscore_track_table tracks[ 128 ];
-
-   aatree_ptr pool_head, playerinfo_head;
-   u32 entry_capacity, 
-       playerinfo_capacity, playerinfo_root;
-
-   u32 reserved[59];
-};
-
-#pragma pack(pop)
-
-static struct highscore_system
-{
-   highscore_database dbheader;
-   aatree aainfo,
-          aainfo_points,
-          aainfo_time,
-          aainfo_playerid,
-          aainfo_datetime,
-          aainfo_playerinfo_playerid,
-          aainfo_playerinfo;
-
-   void *data, 
-        *playerinfo_data;
-
-   u32 pool_size, playerinfo_pool_size;
-}
-highscore_system;
-
-static int highscore_intr( char *buf, int value, int len, char alt );
-static int highscore_intl( char *buf, int value, int len );
-static void highscores_board_printf( FILE *fp, const char *buf, u32 count );
-static aatree_ptr highscore_set_user_nickname( u64 steamid, char nick[16] );
-static aatree_ptr highscores_push_record( highscore_record *record );
-static void highscores_board_generate( char *buf, u32 id, u32 count );
-static void highscores_init( u32 pool_size, u32 playerinfo_pool_size );
-static int highscores_read( const char *path );
-static void highscores_create_db(void);
-static int highscores_serialize_all(void);
-
-#endif /* HIGHSCORES_H */
index dd6adc0c25f0faab87237f5415b9a230bf370934..6770d323a0e0b7fd7b788172eac54b86a1bd3d20 100644 (file)
--- a/network.h
+++ b/network.h
@@ -10,7 +10,6 @@
 #include "steam.h"
 #include "network_common.h"
 #include "network_msg.h"
-#include "highscores.h"
 #include "addon_types.h"
 
 #define NETWORK_MAX_REQUESTS 8
index c115162099fb6d4b075ebcccb8f420b90eda5632..7a099f0fc16847c58d5862f22d0a97f0b5d2880f 100644 (file)
--- a/player.c
+++ b/player.c
@@ -114,7 +114,8 @@ static void player__update(void){
       player_subsystems[ localplayer.subsystem ]->update();
 }
 
-static void player__post_update(void){
+static void player__post_update(void)
+{
    struct player_subsystem_interface *sys = 
       player_subsystems[ localplayer.subsystem ];
 
@@ -128,7 +129,8 @@ static void player__post_update(void){
 /*
  * Applies gate transport to a player_interface
  */
-static void player__pass_gate( u32 id ){
+static void player__pass_gate( u32 id )
+{
    world_instance *world = world_current_instance();
    skaterift_record_frame( &skaterift.replay, 1 );
 
@@ -151,20 +153,16 @@ static void player__pass_gate( u32 id ){
 
    m4x3_mulv( gate->transport, localplayer.cam.pos, localplayer.cam.pos );
 
-   if( gate->flags & k_ent_gate_nonlocal ){
-      /* FIXME: Code dupe with world_load.c */
-      ent_spawn *rp = world_find_spawn_by_name( world, "start" );
-      if( !rp ) rp = world_find_closest_spawn( world, (v3f){0.0f,0.0f,0.0f} );
-      /* TODO: fallback to searching for a safe location using raycasts */
-      assert(rp);
-      v3_copy( rp->transform.co, world->player_co );
-
+   if( gate->flags & k_ent_gate_nonlocal )
+   {
+      world_default_spawn_pos( world, world->player_co );
       world_static.active_instance = gate->target;
       player__clean_refs();
 
       replay_clear( &skaterift.replay );
    }
-   else {
+   else 
+   {
       world_routes_activate_entry_gate( world, gate );
    }
    
@@ -178,7 +176,8 @@ static void player__pass_gate( u32 id ){
    audio_unlock();
 }
 
-static void player_apply_transport_to_cam( m4x3f transport ){
+static void player_apply_transport_to_cam( m4x3f transport )
+{
    /* Pre-emptively edit the camera matrices so that the motion vectors 
     * are correct */
    m4x3f transport_i;
@@ -194,7 +193,8 @@ static void player_apply_transport_to_cam( m4x3f transport ){
    m4x4_mul( world_gates.cam.mtx.v,  transport_4, world_gates.cam.mtx.v );
 }
 
-static void player__im_gui(void){
+static void player__im_gui(void)
+{
    if( !k_player_debug_info ) return;
 
    ui_rect box = {
index cdef5a41c4f5b9ba236981ecca7036b313fc7a08..aa0bc8de2e50889a2ba52e8b65ada5ac0a82055a 100644 (file)
@@ -48,7 +48,6 @@
 #include "entity.c"
 #include "workshop.c"
 #include "addon.c"
-#include "highscores.c"
 #include "save.c"
 #include "world_map.c"
 #include "network.c"
index c074e156f3e090fee656d7b9d5774a01565d0ad7..1b3015f58648c821781d0d4f98e3c8b97bdda801 100644 (file)
@@ -14,7 +14,6 @@
 #include "vg/vg_steam_ugc.h"
 #include "vg/vg_steam_friends.h"
 #include "steam.h"
-#include "highscores.h"
 
 static struct ui_enum_opt workshop_form_visibility_opts[] = {
  { k_ERemoteStoragePublishedFileVisibilityPublic,       "Public"       },
@@ -1327,12 +1326,12 @@ static void workshop_form_gui_sidebar( ui_rect sidebar )
    ui_fill( controls, ui_colour( k_ui_bg+1 ) );
 
    char buf[32];
-   strcpy( buf, "page " );
-   int i  = 5;
-       i += highscore_intl( buf+i, workshop_form.view_published_page_id+1, 4 );
-            buf[ i ++ ] = '/';
-       i += highscore_intl( buf+i, workshop_form.view_published_page_count, 4 );
-            buf[ i ++ ] = '\0';
+   vg_str str;
+   vg_strnull( &str, buf, sizeof(buf) );
+   vg_strcat( &str, "page " );
+   vg_strcati32( &str,  workshop_form.view_published_page_id+1 );
+   vg_strcatch( &str, '/' );
+   vg_strcati32( &str, workshop_form.view_published_page_count );
 
    ui_rect_pad( controls, (ui_px[2]){0,4} );
    ui_rect info;
index d8f4259dacd67179503656e569c6d415d68a1edb..440229102ecc8d548635c70dc1d100b5af76b186 100644 (file)
@@ -277,6 +277,19 @@ ent_spawn *world_find_spawn_by_name( world_instance *world, const char *name )
    return rp;
 }
 
+static void world_default_spawn_pos( world_instance *world, v3f pos )
+{
+   ent_spawn *rp = world_find_spawn_by_name( world, "start" );
+   if( !rp ) rp = world_find_closest_spawn( world, (v3f){0,0,0} );
+   if( rp )
+      v3_copy( rp->transform.co, pos );
+   else
+   {
+      vg_error( "There are no valid spawns in the world\n" );
+      v3_zero( pos );
+   }
+}
+
 static void ent_volume_call( world_instance *world, ent_call *call ){
    u32 index = mdl_entity_id_id( call->id );
    ent_volume *volume = mdl_arritm( &world->ent_volume, index );
index 1e5e70c684d55e4ace42df0749ce31d008a602fb..a3c5f331c5e97c8cea455ca908418c1930eb6f07 100644 (file)
@@ -12,6 +12,7 @@ static ent_spawn *world_find_spawn_by_name( world_instance *world,
                                                const char *name );
 static ent_spawn *world_find_closest_spawn( world_instance *world, 
                                                v3f position );
+static void world_default_spawn_pos( world_instance *world, v3f pos );
 static void world_entity_start( world_instance *world, vg_msg *sav );
 static void world_entity_serialize( world_instance *world, vg_msg *sav );
 
index 772d9e1b71c6379f9bc20dc78f22516e0f71839d..3b29b1fedf60a82c7d215059158c57c6daf0060a 100644 (file)
@@ -8,8 +8,6 @@
 /* Purely an information header, shares common strings across client and 
  * server programs. */
 
-#include "highscores.h"
-
 struct track_info
 {
    const char *name, 
index b1363b7a9a056c9d55a29685e80bfb4b0c024350..6055d887acbe96ed7b7a5d68b53a2fc52765a2b3 100644 (file)
@@ -74,16 +74,20 @@ static void world_instance_load_mdl( u32 instance_id, const char *path ){
    MDL_LOAD_ARRAY( meta, &infos, ent_worldinfo, vg_mem.scratch );
 
    world->skybox = k_skybox_default;
-   if( mdl_arrcount(&infos) ){
+   if( mdl_arrcount(&infos) )
+   {
       world->info = *((ent_worldinfo *)mdl_arritm(&infos,0));
 
-      if( world->meta.info.version >= 104 ){
-         if( MDL_CONST_PSTREQ( &world->meta, world->info.pstr_skybox,"space")){
+      if( world->meta.info.version >= 104 )
+      {
+         if( MDL_CONST_PSTREQ( &world->meta, world->info.pstr_skybox,"space"))
+         {
             world->skybox = k_skybox_space;
          }
       }
    }
-   else{
+   else
+   {
       world->info.pstr_author = 0;
       world->info.pstr_desc = 0;
       world->info.pstr_name = 0;
@@ -131,21 +135,14 @@ static void world_instance_load_mdl( u32 instance_id, const char *path ){
 
    /* init player position.
     *   - this is overriden by the save state when(if) it loads */
-   ent_spawn *rp = world_find_spawn_by_name( world, "start" );
-   if( !rp ) rp = world_find_closest_spawn( world, (v3f){0.0f,0.0f,0.0f} );
-   if( rp )
-      v3_copy( rp->transform.co, world->player_co );
-   else{
-      /* FIXME: we need to find a safe place to put the player_co using
-       * raycasts. */
-      v3_zero( world->player_co );
-   }
+   world_default_spawn_pos( world, world->player_co );
 
    /* allocate leaderboard buffers */
    u32 bs = mdl_arrcount(&world->ent_route)*sizeof(struct leaderboard_cache);
    world->leaderboard_cache = vg_linear_alloc( heap, bs );
 
-   for( u32 i=0; i<mdl_arrcount( &world->ent_route ); i ++ ){
+   for( u32 i=0; i<mdl_arrcount( &world->ent_route ); i ++ )
+   {
       struct leaderboard_cache *board = &world->leaderboard_cache[i];
       board->data = vg_linear_alloc( heap, NETWORK_REQUEST_MAX );
       board->status = k_request_status_client_error;
@@ -347,8 +344,13 @@ static void skaterift_change_world_start( addon_reg *reg ){
 }
 
 /* console command for the above function */
-static int skaterift_load_world_command( int argc, const char *argv[] ){
-   if( !vg_loader_availible() ) return 0; /* FIXME */
+static int skaterift_load_world_command( int argc, const char *argv[] )
+{
+   if( !vg_loader_availible() ) 
+   {
+      vg_error( "Loading thread is currently unavailible\n" );
+      return 0;
+   }
 
    if( argc == 1 ){
       addon_alias q;
index 613d3bffa6af21c473ff170938391b7357971624..9eac40e3eda13e2c8bcc3acb94f48cb007aa8039 100644 (file)
@@ -565,19 +565,20 @@ static void world_render_challenges( world_instance *world,
    /* render texts */
    font3d_bind( &gui.font, k_font_shader_world, 0, world, &skaterift.cam );
 
-   char buf[32];
    u32 count = 0;
 
-   for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ ){
+   for( u32 i=0; i<mdl_arrcount(&world->ent_challenge); i++ )
+   {
       ent_challenge *challenge = mdl_arritm( &world->ent_challenge, i );
       if( challenge->status ) count ++;
    }
 
-   int c=0;
-   c+=highscore_intl( buf+c, count, 3 );
-   buf[c++] = '/';
-   c+=highscore_intl( buf+c, mdl_arrcount(&world->ent_challenge), 3 );
-   buf[c++] = '\0';
+   char buf[32];
+   vg_str str;
+   vg_strnull( &str, buf, sizeof(buf) );
+   vg_strcati32( &str, count );
+   vg_strcatch( &str, '/' );
+   vg_strcati32( &str, mdl_arrcount(&world->ent_challenge) );
 
    f32 w = font3d_string_width( 1, buf );
    m4x3f mlocal;
@@ -586,7 +587,8 @@ static void world_render_challenges( world_instance *world,
    mlocal[3][1] = 0.0f;
    mlocal[3][2] = 0.0f;
 
-   for( u32 i=0; i<challenge_count; i++ ){
+   for( u32 i=0; i<challenge_count; i++ )
+   {
       u32 index = challenge_list[ i ];
       ent_challenge *challenge = mdl_arritm( &world->ent_challenge, index );
       m4x3f mmdl;
index ca072e62985290569c6a7d780e2ed0b588efea99..b80e68e2777209a849d8039cbef257005df08d00 100644 (file)
@@ -10,7 +10,6 @@
 #include "world_routes.h"
 #include "world_gate.h"
 #include "world_load.h"
-#include "highscores.h"
 #include "network.h"
 
 #include "font.h"
@@ -756,7 +755,11 @@ static void world_routes_update_timer_texts( world_instance *world ){
          text->gate = gate;
          text->route = route;
 
-         if( route->valid_checkpoints >= route->checkpoints_count ){
+         vg_str str;
+         vg_strnull( &str, text->text, sizeof(text->text) );
+
+         if( route->valid_checkpoints >= route->checkpoints_count )
+         {
             double lap_time = world_static.time - route->timing_base,
                    time_centiseconds = lap_time * 100.0;
 
@@ -770,30 +773,32 @@ static void world_routes_update_timer_texts( world_instance *world ){
             seconds     %= 60;
             minutes     %= 60;
 
-            if( minutes > 9 ) minutes = 9;
+            if( minutes > 9 ) 
+               minutes = 9;
             
-            int j=0;
-            if( minutes ){
-               highscore_intr( text->text, minutes, 1, ' ' ); j++;
-               text->text[j++] = ':';
+            if( minutes )
+            {
+               vg_strcati32r( &str, minutes, 1, ' ' );
+               vg_strcatch( &str, ':' );
             }
             
-            if( seconds >= 10 || minutes ){
-               highscore_intr( text->text+j, seconds, 2, '0' ); j+=2;
+            if( seconds >= 10 || minutes )
+            {
+               vg_strcati32r( &str, seconds, 2, '0' );
             }
-            else{
-               highscore_intr( text->text+j, seconds, 1, '0' ); j++;
+            else
+            {
+               vg_strcati32r( &str, seconds, 1, '0' );
             }
 
-            text->text[j++] = '.';
-            highscore_intr( text->text+j, centiseconds, 1, '0' ); j++;
-            text->text[j] = '\0';
+            vg_strcatch( &str, '.' );
+            vg_strcati32r( &str, centiseconds, 1, '0' );
          }
-         else{
-            highscore_intr( text->text, route->valid_checkpoints, 1, ' ' );
-            text->text[1] = '/';
-            highscore_intr( text->text+2, route->checkpoints_count+1, 1, ' ' );
-            text->text[3] = '\0';
+         else
+         {
+            vg_strcati32r( &str, route->valid_checkpoints, 1, ' ' );
+            vg_strcatch( &str, '/' );
+            vg_strcati32r( &str, route->checkpoints_count + 1, 1, ' ' );
          }
    
          gui_font3d.font = &gui.font;