From b7b22a6b33b7a7e6166b3de1fcabf71eb2aed287 Mon Sep 17 00:00:00 2001 From: hgn Date: Mon, 27 Nov 2023 15:15:51 +0000 Subject: [PATCH] extremely hacky achievement models lol --- blender_export.py | 11 ++++++++--- entity.h | 2 +- save.c | 1 + skaterift.c | 4 +++- skaterift.h | 2 ++ steam.h | 31 +++++++++++++++++++++++++++++-- world_entity.c | 25 ++++++++++++++++++++++++- 7 files changed, 68 insertions(+), 8 deletions(-) diff --git a/blender_export.py b/blender_export.py index 30b1fe9..cc0eb21 100644 --- a/blender_export.py +++ b/blender_export.py @@ -563,7 +563,8 @@ class ent_prop(Structure):#{ _fields_ = [("transform",mdl_transform), ("submesh_start",c_uint32), ("submesh_count",c_uint32), - ("flags",c_uint32)] + ("flags",c_uint32), + ("pstr_alias",c_uint32)] #} def obj_ent_type( obj ): @@ -1717,7 +1718,7 @@ def sr_compile( collection ): #} #-------------------------- - print( F'[SR] {i: 3}/{mesh_count} {obj.name:<40}', end='\r' ) + print( F'[SR] {i: 3}/{mesh_count} {obj.name:<40}' ) sr_compile_mesh( obj ) #} #} @@ -2034,10 +2035,12 @@ def sr_compile( collection ): #} elif ent_type == 'ent_prop':#{ prop = ent_prop() + obj_data = obj.SR_data.ent_prop[0] compile_obj_transform( obj, prop.transform ) prop.submesh_start, prop.submesh_count, _ = \ sr_compile_mesh_internal( obj ) - prop.flags = 0 + prop.flags = obj_data.flags + prop.pstr_alias = sr_compile_string( obj_data.alias ) sr_ent_push( prop ) #} #} @@ -3215,6 +3218,7 @@ class SR_OBJECT_ENT_AUDIO(bpy.types.PropertyGroup): class SR_OBJECT_ENT_MARKER(bpy.types.PropertyGroup): #{ alias: bpy.props.StringProperty() + flags: bpy.props.IntProperty() #} class SR_OBJECT_ENT_GLYPH(bpy.types.PropertyGroup): @@ -3558,6 +3562,7 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup): ent_volume: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_VOLUME) ent_audio: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_AUDIO) ent_marker: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MARKER) + ent_prop: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MARKER) ent_glyph: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_GLYPH) ent_font: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_FONT) ent_traffic: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_TRAFFIC) diff --git a/entity.h b/entity.h index ce14816..1c11f38 100644 --- a/entity.h +++ b/entity.h @@ -543,7 +543,7 @@ struct ent_miniworld { struct ent_prop { mdl_transform transform; - u32 submesh_start, submesh_count, flags; + u32 submesh_start, submesh_count, flags, pstr_alias; }; struct ent_region { diff --git a/save.c b/save.c index 472305d..88dfada 100644 --- a/save.c +++ b/save.c @@ -112,6 +112,7 @@ static void skaterift_populate_main_savedata( savedata_file *file ){ vg_msg sav; vg_msg_init( &sav, file->buf, sizeof(file->buf) ); + vg_msg_wkvu32( &sav, "ach", skaterift.achievements ); vg_msg_frame( &sav, "player" ); { diff --git a/skaterift.c b/skaterift.c index 2152fb1..7756377 100644 --- a/skaterift.c +++ b/skaterift.c @@ -125,12 +125,12 @@ static void skaterift_restore_state(void){ vg_msg kvsav; vg_msg_init( &kvsav, sav.buf, sizeof(sav.buf) ); + skaterift.achievements |= vg_msg_getkvu32( &kvsav, "ach", 0 ); u32 board_reg_id = 0, player_reg_id = 0; vg_msg_cursor orig = kvsav.cur; - if( vg_msg_seekframe( &kvsav, "player" ) ){ addon_alias q; @@ -245,6 +245,8 @@ static void vg_load(void){ /* and now */ skaterift_restore_state(); + update_ach_models(); + vg_loader_step( NULL, skaterift_autosave_synchronous ); //board_processview_thread(NULL); diff --git a/skaterift.h b/skaterift.h index 21814df..09adb5d 100644 --- a/skaterift.h +++ b/skaterift.h @@ -63,6 +63,8 @@ struct{ f64 last_autosave; GLuint rt_textures[k_skaterift_rt_max]; + + u32 achievements; } static skaterift = { .op = k_async_op_clientloading, .time_rate = 1.0f }; diff --git a/steam.h b/steam.h index cbe88ee..dcfc1c8 100644 --- a/steam.h +++ b/steam.h @@ -60,11 +60,19 @@ static void steam_store_achievements(void) } } -static void steam_set_achievement( const char *name ) -{ +static void update_ach_models(void); +static void steam_set_achievement( const char *name ){ + /* hack lol */ + if( !strcmp(name,"MARC") ) skaterift.achievements |= 0x1; + if( !strcmp(name,"ALBERT") ) skaterift.achievements |= 0x2; + if( !strcmp(name,"JANET") ) skaterift.achievements |= 0x4; + if( !strcmp(name,"BERNADETTA") ) skaterift.achievements |= 0x8; + update_ach_models(); + if( steam_ready && steam_stats_ready ){ if( SteamAPI_ISteamUserStats_SetAchievement( hSteamUserStats, name ) ){ vg_success( "Achievement set! '%s'\n", name ); + } else{ vg_warn( "Failed to set achievement: %s\n", name ); @@ -155,6 +163,25 @@ static void steam_on_recieve_current_stats( CallbackMsg_t *msg ) vg_info( "Recieved stats for: %lu (user: %lu)\n", rec->m_nGameID, rec->m_steamIDUser ); steam_stats_ready = 1; + + steamapi_bool set = 0; + if( SteamAPI_ISteamUserStats_GetAchievement( + hSteamUserStats, "MARC", &set ) ){ + if( set ) skaterift.achievements |= 0x1; + } + if( SteamAPI_ISteamUserStats_GetAchievement( + hSteamUserStats, "ALBERT", &set ) ){ + if( set ) skaterift.achievements |= 0x2; + } + if( SteamAPI_ISteamUserStats_GetAchievement( + hSteamUserStats, "JANET", &set ) ){ + if( set ) skaterift.achievements |= 0x4; + } + if( SteamAPI_ISteamUserStats_GetAchievement( + hSteamUserStats, "BERNADETTA", &set ) ){ + if( set ) skaterift.achievements |= 0x8; + } + update_ach_models(); } else{ vg_error( "Error recieveing stats for user (%u)\n", rec->m_eResult ); diff --git a/world_entity.c b/world_entity.c index 947a3bd..02bbeb2 100644 --- a/world_entity.c +++ b/world_entity.c @@ -560,6 +560,29 @@ static void entity_bh_debug( void *user, u32 item_index ){ } } +static void update_ach_models(void){ + world_instance *hub = &world_static.instances[k_world_purpose_hub]; + if( hub->status != k_world_status_loaded ) return; + + for( u32 i=0; ient_prop ); i ++ ){ + ent_prop *prop = mdl_arritm( &hub->ent_prop, i ); + if( prop->flags & 0x2 ){ + if( MDL_CONST_PSTREQ( &hub->meta, prop->pstr_alias, "MARC" ) ) + if( skaterift.achievements & 0x1 ) + prop->flags &= ~0x1; + if( MDL_CONST_PSTREQ( &hub->meta, prop->pstr_alias, "ALBERT" ) ) + if( skaterift.achievements & 0x2 ) + prop->flags &= ~0x1; + if( MDL_CONST_PSTREQ( &hub->meta, prop->pstr_alias, "JANET" ) ) + if( skaterift.achievements & 0x4 ) + prop->flags &= ~0x1; + if( MDL_CONST_PSTREQ( &hub->meta, prop->pstr_alias, "BERNADETTA" ) ) + if( skaterift.achievements & 0x8 ) + prop->flags &= ~0x1; + } + } +} + static void entity_bh_closest( void *user, u32 item_index, v3f point, v3f closest ){ world_instance *world = user; @@ -652,7 +675,7 @@ static void world_entity_start( world_instance *world, vg_msg *sav ){ } /* LEGACY: check if steam achievements can give us a medal */ - if( steam_ready && steam_stats_ready ){ + if( steam_ready && steam_stats_ready ){ for( u32 j=0; jname, -- 2.25.1