From: hgn Date: Mon, 4 Dec 2023 09:39:25 +0000 (+0000) Subject: added content lock for demo version X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=47bdc07d1a3e268f7926b5849ea751b0ef63289b;hp=aae2ef3e087d980130ea12cb90df15bb3d85ec65;p=carveJwlIkooP6JGAAIwe30JlM.git added content lock for demo version --- diff --git a/addon.c b/addon.c index 7ebd165..91cb350 100644 --- a/addon.c +++ b/addon.c @@ -429,7 +429,12 @@ static addon_reg *addon_mount_local_addon( const char *folder, * Check all subscribed items */ static void addon_mount_workshop_items(void){ + if( skaterift.demo_mode ){ + vg_info( "Won't load workshop items in demo mode\n" ); + return; + } if( !steam_ready ) return; + /* * Steam workshop scan */ diff --git a/addon.h b/addon.h index 59645da..bb96f2e 100644 --- a/addon.h +++ b/addon.h @@ -19,9 +19,10 @@ struct addon_alias { char foldername[ ADDON_FOLDERNAME_MAX ]; }; -#define ADDON_REG_HIDDEN 0x1 -#define ADDON_REG_MTZERO 0x2 -#define ADDON_REG_CITY 0x4 +#define ADDON_REG_HIDDEN 0x1 +#define ADDON_REG_MTZERO 0x2 +#define ADDON_REG_CITY 0x4 +#define ADDON_REG_PREMIUM 0x8 struct { struct addon_reg{ diff --git a/ent_miniworld.c b/ent_miniworld.c index 024fa6c..afd7b48 100644 --- a/ent_miniworld.c +++ b/ent_miniworld.c @@ -153,6 +153,13 @@ static void ent_miniworld_preupdate(void){ } if( button_down( k_srbind_miniworld_resume ) ){ + if( skaterift.demo_mode ){ + if( world_static.instance_addons[1]->flags & ADDON_REG_PREMIUM ){ + /* TODO: open menu page with link to buy */ + return; + } + } + global_miniworld.transition = 1; global_miniworld.t = 0.0f; global_miniworld.cam = skaterift.cam; diff --git a/skaterift.c b/skaterift.c index 714ed11..c7e2d42 100644 --- a/skaterift.c +++ b/skaterift.c @@ -82,6 +82,10 @@ static void vg_launch_opt(void){ if( vg_long_opt( "tools" ) ){ k_tools_mode = 1; } + + if( vg_long_opt( "demo" ) ){ + skaterift.demo_mode = 1; + } } static void vg_preload(void){ @@ -217,8 +221,10 @@ static void vg_load(void){ /* hub world */ addon_reg *hub = skaterift_mount_world_unloadable( "maps/dev_hub", 0 ); - skaterift_mount_world_unloadable( "maps/mp_spawn", ADDON_REG_CITY ); - skaterift_mount_world_unloadable( "maps/mp_mtzero", ADDON_REG_MTZERO ); + skaterift_mount_world_unloadable( "maps/mp_spawn", + ADDON_REG_CITY|ADDON_REG_PREMIUM ); + skaterift_mount_world_unloadable( "maps/mp_mtzero", + ADDON_REG_MTZERO|ADDON_REG_PREMIUM ); skaterift_mount_world_unloadable( "maps/dev_tutorial", 0 ); /* load home/permanent world manually */ diff --git a/skaterift.h b/skaterift.h index 09adb5d..fdb0554 100644 --- a/skaterift.h +++ b/skaterift.h @@ -65,6 +65,7 @@ struct{ GLuint rt_textures[k_skaterift_rt_max]; u32 achievements; + int demo_mode; } static skaterift = { .op = k_async_op_clientloading, .time_rate = 1.0f }; diff --git a/world.c b/world.c index 550ac50..f8d7168 100644 --- a/world.c +++ b/world.c @@ -41,6 +41,13 @@ static void world_switch_instance( u32 index ){ return; } + if( skaterift.demo_mode ){ + if( world_static.instance_addons[index]->flags & ADDON_REG_PREMIUM ){ + vg_error( "Can't switch to a premium world in the demo version\n" ); + return; + } + } + world_instance *current = &world_static.instances[ world_static.active_instance ]; @@ -52,7 +59,6 @@ static void world_switch_instance( u32 index ){ v3_copy( new->player_co, localplayer.rb.co ); world_static.active_instance = index; - player__reset(); } diff --git a/world_gate.c b/world_gate.c index 259260c..1631e05 100644 --- a/world_gate.c +++ b/world_gate.c @@ -326,6 +326,10 @@ static void world_link_nonlocal_async( void *payload, u32 size ){ ent_gate *gate = mdl_arritm( &world->ent_gate, j ); gate_transform_update( gate ); + if( skaterift.demo_mode ) + if( world_static.instance_addons[world_id]->flags & ADDON_REG_PREMIUM ) + continue; + if( !(gate->flags & k_ent_gate_nonlocal) ) continue; if( gate->flags & k_ent_gate_linked ) continue;