achievements
authorhgn <hgodden00@gmail.com>
Sat, 27 May 2023 20:11:49 +0000 (21:11 +0100)
committerhgn <hgodden00@gmail.com>
Sat, 27 May 2023 20:11:49 +0000 (21:11 +0100)
14 files changed:
blender_export.py
entity.c
entity.h
highscores.h
maps_src/mp_mtzero/main.mdl
maps_src/mp_spawn/main.mdl
network.h
steam.h
world.h
world_entity.c
world_entity.h
world_gen.c
world_load.c
world_routes.c

index 293b87cd89e81385131e586cd25a939446ff929f..ca29004d8c743edf498af4c6446d0695b080b556 100644 (file)
@@ -35,6 +35,7 @@ sr_entity_list = [
    ('ent_swspreview', 'Workshop Preview', '', 14 ),
    ('ent_menuitem',     'Menu Item',      '', 15 ),
    ('ent_worldinfo',    'World Info',     '', 16 ),
+   ('ent_ccmd',         'CCmd',           '', 17 )
 ]
 
 def get_entity_enum_id( alias ):
@@ -439,6 +440,11 @@ class ent_worldinfo(Structure):
                ("timezone",c_float)]
 #}
 
+class ent_ccmd(Structure):
+#{
+   _fields_ = [("pstr_command",c_uint32)]
+#}
+
 def obj_ent_type( obj ):
 #{
    if obj.type == 'ARMATURE': return 'mdl_armature'
@@ -1727,6 +1733,12 @@ def sr_compile( collection ):
             worldinfo.timezone = obj_data.timezone
             sr_ent_push( worldinfo )
          #}
+         elif ent_type == 'ent_ccmd':#{
+            ccmd = ent_ccmd()
+            obj_data = obj.SR_data.ent_ccmd[0]
+            ccmd.pstr_command = sr_compile_string( obj_data.command )
+            sr_ent_push( ccmd )
+         #}
       #}
    #}
 
@@ -2677,7 +2689,7 @@ class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):
    target: bpy.props.PointerProperty( \
            type=bpy.types.Object, name="Target", \
            poll=lambda self,obj: sr_filter_ent_type(obj,\
-                                    ['ent_audio','ent_skateshop']))
+                                    ['ent_audio','ent_skateshop','ent_ccmd']))
 
    @staticmethod
    def sr_inspector( layout, data ):
@@ -2962,6 +2974,11 @@ class SR_OBJECT_ENT_WORLD_INFO(bpy.types.PropertyGroup):
    timezone: bpy.props.FloatProperty(name="Timezone(hrs) (UTC0 +hrs)")
 #}
 
+class SR_OBJECT_ENT_CCMD(bpy.types.PropertyGroup):
+#{
+   command: bpy.props.StringProperty(name="Command Line")
+#}
+
 class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
 #{
    ent_gate: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_GATE)
@@ -2978,6 +2995,7 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
          bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORKSHOP_PREVIEW)
    ent_menuitem: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MENU_ITEM)
    ent_worldinfo: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORLD_INFO)
+   ent_ccmd: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CCMD)
 
    ent_type: bpy.props.EnumProperty(
       name="Type",
@@ -4097,7 +4115,7 @@ classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\
             SR_UL_FONT_VARIANT_LIST,SR_UL_FONT_GLYPH_LIST,\
             SR_OBJECT_ENT_FONT,SR_OBJECT_ENT_TRAFFIC,SR_OBJECT_ENT_SKATESHOP,\
             SR_OBJECT_ENT_WORKSHOP_PREVIEW,SR_OBJECT_ENT_MENU_ITEM,\
-            SR_OBJECT_ENT_WORLD_INFO,\
+            SR_OBJECT_ENT_WORLD_INFO,SR_OBJECT_ENT_CCMD,\
             \
             SR_OBJECT_PROPERTIES, SR_LIGHT_PROPERTIES, SR_BONE_PROPERTIES, 
             SR_MESH_PROPERTIES, SR_MATERIAL_PROPERTIES \
index 1e85e565ecd89ce8ceafbe0316998e1c7b185e51..f5e8004510d104c3eb9799b572a6e9c168cef7d6 100644 (file)
--- a/entity.c
+++ b/entity.c
@@ -17,6 +17,8 @@ VG_STATIC void entity_call( world_instance *world, ent_call *call )
       ent_audio_call( world, call );
    } else if( type == k_ent_skateshop ){
       ent_skateshop_call( world, call );
+   } else if( type == k_ent_ccmd ){
+      ent_ccmd_call( world, call );
    }
 }
 
index 1de6f7026b62379c7f80092ecc6550849e5723c7..7143a4130aaccadaa905fa55eaceebf664785f6a 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -25,6 +25,7 @@ typedef struct ent_skateshop ent_skateshop;
 typedef struct ent_camera ent_camera;
 typedef struct ent_swspreview ent_swspreview;
 typedef struct ent_worldinfo ent_worldinfo;
+typedef struct ent_ccmd ent_ccmd;
 
 enum entity_alias{
    k_ent_none        = 0,
@@ -43,21 +44,19 @@ enum entity_alias{
    k_ent_camera      = 13,
    k_ent_swspreview  = 14,
    k_ent_menuitem    = 15,
-   k_ent_worldinfo   = 16
+   k_ent_worldinfo   = 16,
+   k_ent_ccmd        = 17
 };
 
-static u32 mdl_entity_id_type( u32 entity_id )
-{
+static u32 mdl_entity_id_type( u32 entity_id ){
    return (entity_id & 0xffff0000) >> 16;
 }
 
-static u32 mdl_entity_id_id( u32 entity_id )
-{
+static u32 mdl_entity_id_id( u32 entity_id ){
    return entity_id & 0x0000ffff;
 }
 
-static u32 mdl_entity_id( u32 type, u32 index )
-{
+static u32 mdl_entity_id( u32 type, u32 index ){
    return (type & 0xfffff)<<16 | (index & 0xfffff);
 }
 
@@ -375,6 +374,9 @@ struct ent_glyph{
        indice_count;
 };
 
+struct ent_ccmd{
+   u32 pstr_command;
+};
 
 typedef struct ent_call ent_call;
 struct ent_call{
index 3a2071758a8c04f76c6ddd8d5a2a1ead67d1c62d..817a503870ef602ed543f81338873e2e5fc6238d 100644 (file)
@@ -310,8 +310,7 @@ VG_STATIC aatree_ptr highscores_push_record( highscore_record *record )
 
    vg_low( "Inserting record into database for track %hu\n",record->trackid );
 
-   if( record->trackid >= vg_list_size(sys->dbheader.tracks) )
-   {
+   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) );
 
@@ -324,8 +323,7 @@ VG_STATIC aatree_ptr highscores_push_record( highscore_record *record )
                                        table->root_playerid,
                                        record );
 
-   if( existing != AATREE_PTR_NIL )
-   {
+   if( existing != AATREE_PTR_NIL ){
       highscore_record *crecord = aatree_get_data( &sys->aainfo_playerid, 
                                                    existing );
 
index ddd7d6df75e5026e8eaf4f999df3841899ba726e..32a44d909de9fc3422ea460af2f52254e65d2c9d 100644 (file)
Binary files a/maps_src/mp_mtzero/main.mdl and b/maps_src/mp_mtzero/main.mdl differ
index 097b6bda60321eb033a91d20440fab16a54dfcf5..56ef1b389b1bc3f1ab05c0fce11c7dd94eaec825 100644 (file)
Binary files a/maps_src/mp_spawn/main.mdl and b/maps_src/mp_spawn/main.mdl differ
index 3d45ab85e6dce64344fa8094ce464fa2fd936f85..3a49d63795473646e9609329cad58e87abdc16eb 100644 (file)
--- a/network.h
+++ b/network.h
@@ -135,15 +135,12 @@ VG_STATIC void send_score_update(void)
    setscore->inetmsg_id = k_inetmsg_set_score;
 
    int count = 0;
-   for( u32 i=0; i<vg_list_size(track_infos); i++ )
-   {
-      if( track_infos[i].push )
-      {
+   for( u32 i=0; i<vg_list_size(track_infos); i++ ){
+      if( track_infos[i].push ){
          track_infos[i].push = 0;
          highscore_record *user_record = highscore_find_user_record( 0, i );
 
-         if( !user_record )
-         {
+         if( !user_record ){
             vg_error( "No score set but tried to upload for track %u\n", i );
             continue;
          }
@@ -157,9 +154,7 @@ VG_STATIC void send_score_update(void)
       }
    }
 
-   if( count == 0 )
-      return;
-
+   if( count == 0 ) return;
    u32 send_size = sizeof(netmsg_set_score) +
                   count*sizeof(struct netmsg_score_record);
    setscore->record_count = count;
diff --git a/steam.h b/steam.h
index 5403c16d6f36f657ee786fd49b11cff597f723f5..09e3935aecff37421f81fd31058136961a3bf3e6 100644 (file)
--- a/steam.h
+++ b/steam.h
@@ -91,8 +91,7 @@ VG_STATIC void steam_clear_achievement( const char *name )
 }
 
 
-VG_STATIC int steam_list_achievements( int argc, char const *argv[] )
-{
+VG_STATIC void steam_print_all_achievements(void){
    vg_info( "Achievements: \n" );
 
    if( steam_ready && steam_stats_ready ){
@@ -113,38 +112,39 @@ VG_STATIC int steam_list_achievements( int argc, char const *argv[] )
    else{
       vg_warn( "  Steam is not initialized, no results\n" );
    }
-
-   return 0;
 }
 
-VG_STATIC int steam_clear_all_achievements( int argc, char const *argv[] )
+VG_STATIC int steam_achievement_ccmd( int argc, char const *argv[] )
 {
-   if( steam_ready && steam_stats_ready ){
-      for( int i=0; i<vg_list_size(steam_achievement_names); i++ ){
-         steam_clear_achievement( steam_achievement_names[i] );
+   if( !(steam_ready && steam_stats_ready) ) return 1;
+
+   if( argc == 1 ){
+      if( !strcmp( argv[0], "list" ) ){
+         steam_print_all_achievements();
+         return 0;
+      }
+      else if( !strcmp( argv[0], "clearall" )){
+         for( int i=0; i<vg_list_size(steam_achievement_names); i++ )
+            steam_clear_achievement( steam_achievement_names[i] );
+         
+         steam_store_achievements();
       }
-      
-      steam_store_achievements();
-   }
-   else{
-      vg_warn( "steam is not initialized, cannot clear\n" );
    }
 
-   return 0;
-}
-
-VG_STATIC int steam_set_achievemnt_test( int argc, char const *argv[] )
-{
-   if( argc < 2 )
-      return 0;
-
-   if( strcmp( argv[0], "monkey_island" ) )
-      return 0;
-
-   steam_set_achievement( argv[1] );
-   steam_store_achievements();
+   if( argc == 2 ){
+      if( !strcmp( argv[0], "set" ) ){
+         steam_set_achievement( argv[1] );
+         steam_store_achievements();
+         return 0;
+      }
+      else if( strcmp( argv[0], "clear" ) ){
+         steam_clear_achievement( argv[1] );
+         steam_store_achievements();
+         return 0;
+      }
+   }
 
-   return 0;
+   return 1;
 }
 
 VG_STATIC void steam_on_recieve_current_stats( CallbackMsg_t *msg )
@@ -255,9 +255,7 @@ VG_STATIC int steam_init(void)
       vg_warn( "No Steam Logon: Cannot request stats\n" );
 
 
-   vg_console_reg_cmd( "ach_list", steam_list_achievements, NULL );
-   vg_console_reg_cmd( "ach_clear_all", steam_clear_all_achievements, NULL );
-   vg_console_reg_cmd( "ach_set", steam_set_achievemnt_test, NULL );
+   vg_console_reg_cmd( "ach", steam_achievement_ccmd, NULL );
 
 #endif
 
diff --git a/world.h b/world.h
index d6f80412bb97f00336614b124198b905d2fcd058..58ff1b6bd4b4fb82a0b1f44f7124a22c390aa89c 100644 (file)
--- a/world.h
+++ b/world.h
@@ -154,7 +154,8 @@ struct world_instance {
                  ent_skateshop,
                  ent_marker,
                  ent_camera,
-                 ent_swspreview;
+                 ent_swspreview,
+                 ent_ccmd;
 
    ent_gate *rendering_gate;
 
index 38bf86f7e650a0f4660f901db07a70fdae00cb33..61d014d6ea38806dcecfef8ab4066ba72aba89cd 100644 (file)
@@ -162,8 +162,7 @@ VG_STATIC void ent_volume_call( world_instance *world, ent_call *call )
    }
 }
 
-VG_STATIC void ent_audio_call( world_instance *world, ent_call *call )
-{
+VG_STATIC void ent_audio_call( world_instance *world, ent_call *call ){
    if( world->status == k_world_status_unloading ){
       vg_warn( "cannot modify audio while unloading world\n" );
       return;
@@ -256,4 +255,13 @@ VG_STATIC void ent_audio_call( world_instance *world, ent_call *call )
    }
 }
 
+
+VG_STATIC void ent_ccmd_call( world_instance *world, ent_call *call ){
+   if( call->function == k_ent_function_trigger ){
+      u32 index = mdl_entity_id_id( call->id );
+      ent_ccmd *ccmd = mdl_arritm( &world->ent_ccmd, index );
+      vg_execute_console_input( mdl_pstr(&world->meta, ccmd->pstr_command) );
+   }
+}
+
 #endif /* WORLD_ENTITY_C */
index 807cd9713743edc255a1516d6f1f240022f650a9..3c6d10de95407f3b1a1ad8df25efc982754d9a1f 100644 (file)
@@ -12,5 +12,6 @@ VG_STATIC ent_spawn *world_find_closest_spawn( world_instance *world,
 
 VG_STATIC void ent_volume_call( world_instance *world, ent_call *call );
 VG_STATIC void ent_audio_call( world_instance *world, ent_call *call );
+VG_STATIC void ent_ccmd_call( world_instance *world, ent_call *call );
 
 #endif /* WORLD_ENTITY_H */
index 799059a5f423626e00dd8a9969f94f3ece09a58e..f7f8eda03658b8638b41888c33507689e65fbfd7 100644 (file)
@@ -227,7 +227,7 @@ VG_STATIC void world_gen_generate_meshes(void)
 
    vg_async_item *call = scene_alloc_async( &world->scene_no_collide,
                                             &world->mesh_no_collide,
-                                            200000, 500000 );
+                                            250000, 500000 );
 
    for( u32 i=0; i<world->surface_count; i++ ){
       struct world_surface *surf = &world->surfaces[ i ];
index 4f5f8f4628fe242a7da595018420f1191690f24d..2eca813ceeda80941dffed10b9f76dcbc5438773 100644 (file)
@@ -58,6 +58,7 @@ VG_STATIC void world_load_mdl( const char *path )
    mdl_load_array( meta, &world->ent_marker,    "ent_marker",     heap );
    mdl_load_array( meta, &world->ent_skateshop, "ent_skateshop",  heap );
    mdl_load_array( meta, &world->ent_swspreview,"ent_swspreview", heap );
+   mdl_load_array( meta, &world->ent_ccmd,      "ent_ccmd",       heap );
 
    mdl_array_ptr infos;
    mdl_load_array( meta, &infos, "ent_worldinfo", vg_mem.scratch );
index 529fdefcccfcf2bfbf416fdb6c94e264b290829a..efde3644dd07d3203988a0d1ddb577ad42d9cafe 100644 (file)
@@ -14,6 +14,7 @@
 #include "font.h"
 #include "pointcloud.h"
 #include "gui.h"
+#include "steam.h"
 
 #include "shaders/scene_route.h"
 #include "shaders/routeui.h"
@@ -45,10 +46,8 @@ void world_routes_local_set_record( world_instance *world, ent_route *route,
       ti->push = 1;
       
       if( ti->achievement_id ){
-#if 0
          steam_set_achievement( ti->achievement_id );
          steam_store_achievements();
-#endif
       }
    }
    else{