added content lock for demo version
authorhgn <hgodden00@gmail.com>
Mon, 4 Dec 2023 09:39:25 +0000 (09:39 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 4 Dec 2023 09:39:25 +0000 (09:39 +0000)
addon.c
addon.h
ent_miniworld.c
skaterift.c
skaterift.h
world.c
world_gate.c

diff --git a/addon.c b/addon.c
index 7ebd165756645a7979a06efdbb3377006143570f..91cb35050491654f72308a205f75ad39c76ac782 100644 (file)
--- 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 59645daed4ef8ec603daf1e7c5654cbafaf3d2cd..bb96f2e5023777cb8a21642745a05891ce427138 100644 (file)
--- 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{
index 024fa6c0bc9153ad76d2075d7453efea57d74cd9..afd7b484c920fd6eec132aa611c84e9dbfc9132c 100644 (file)
@@ -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;
index 714ed11cbdd44f05a73585a2e998aa8a0a406c40..c7e2d42f0e57e0632e03f023e55b58f27087959a 100644 (file)
@@ -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 */
index 09adb5d2a6c3c6a3dcbbcd085ef3cd27238fd09a..fdb055486aa6f0a2c902b0eb4221aabac03b79ef 100644 (file)
@@ -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 550ac508f0c894a64412a73923fe92cc3289068b..f8d7168a1ca781a99c60fe1a733d2394035bedff 100644 (file)
--- 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();
 }
 
index 259260c0f006a3110409ec27d0fd7b5fc7c5e5ea..1631e05dc535b65ea19b925e65962e03271c7743 100644 (file)
@@ -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;