2 // ===========================================================================================================
4 vg_tex2d tex_tile_data
= { .path
= "textures/tileset.qoi" };
5 vg_tex2d tex_tile_detail
= { .path
= "textures/tile_overlays.qoi" };
6 vg_tex2d tex_wood
= { .path
= "textures/wood.qoi" };
7 vg_tex2d tex_background
= { .path
= "textures/background.qoi" };
8 vg_tex2d tex_ball_noise
= { .path
= "textures/bnoise.qoi" };
9 vg_tex2d tex_monofur
= { .path
= "textures/ascii.qoi", .flags
= VG_TEXTURE_NO_MIP
};
10 vg_tex2d tex_unkown
= { .path
= "textures/unkown.qoi" };
11 vg_tex2d tex_buttons
= { .path
= "textures/buttons.qoi" };
13 vg_tex2d
*texture_list
[] = { &tex_tile_detail
, &tex_tile_data
, &tex_wood
, &tex_background
, &tex_ball_noise
, &tex_monofur
, &tex_unkown
, &tex_buttons
};
16 // ===========================================================================================================
18 sfx_vol_control audio_volume_sfx
= { .val
= 1.0f
, .name
= "Sound effects" };
19 sfx_vol_control audio_volume_music
= { .val
= 1.0f
, .name
= "Music" };
21 sfx_system audio_system_sfx
=
25 .vol_src
= &audio_volume_sfx
,
29 sfx_set audio_tile_mod
=
41 sfx_set audio_splitter
=
44 sound/splitter_01.ogg\0"
50 sound/rolling_01.ogg\0\
51 sound/rolling_02.ogg\0"
54 sfx_set audio_random
=
57 sound/random_01.ogg\0\
58 sound/random_02.ogg\0\
59 sound/random_03.ogg\0\
60 sound/random_04.ogg\0\
61 sound/random_05.ogg\0\
62 sound/random_06.ogg\0\
63 sound/random_07.ogg\0\
64 sound/random_08.ogg\0"
67 sfx_set audio_clicks
=
75 // One two or three layers of rolling noise
76 sfx_system audio_system_balls_rolling
=
78 .vol
= 1.f
, .ch
= 1, .vol_src
= &audio_volume_sfx
,
79 .name
= "Balls Rolling", .flags
= SFX_FLAG_REPEAT
83 sfx_system audio_system_balls_switching
=
85 .vol
= 1.f
, .ch
= 1, .vol_src
= &audio_volume_sfx
,
86 .name
= "Balls Switching"
89 // Gameplay critical sounds eg. splitter sound rocking
90 sfx_system audio_system_balls_important
=
92 .vol
= 1.f
, .ch
= 1, .vol_src
= &audio_volume_sfx
,
93 .name
= "Balls Gameplay"
97 sfx_system audio_system_balls_extra
=
99 .vol
= 1.f
, .ch
= 1, .vol_src
= &audio_volume_sfx
,
100 .name
= "Balls Extra"
103 sfx_system audio_system_ui
=
105 .vol
= 1.f
, .ch
= 1, .vol_src
= &audio_volume_sfx
,
109 ui_colourset ui_fl_colours
= {
115 ui_colourset ui_fl_colours_inactive
= {
121 static void resource_load_main(void)
124 vg_tex2d_init( texture_list
, vg_list_size( texture_list
) );
126 ui_override_font( tex_monofur
.name
, 7 );
128 ui_global_ctx
.colours_main
= &ui_fl_colours
;
132 sfx_set_init( &audio_tile_mod
, NULL
);
133 sfx_set_init( &audio_splitter
, NULL
);
134 sfx_set_init( &audio_rolls
, NULL
);
135 sfx_set_init( &audio_random
, NULL
);
136 sfx_set_init( &audio_clicks
, NULL
);
139 static void resource_free_main(void)
141 vg_tex2d_free( texture_list
, vg_list_size( texture_list
) );
143 sfx_set_free( &audio_tile_mod
);
144 sfx_set_free( &audio_splitter
);
145 sfx_set_free( &audio_rolls
);
146 sfx_set_free( &audio_random
);
147 sfx_set_free( &audio_clicks
);
151 // ===========================================================================================================
153 SHADER_DEFINE( shader_tile_colour
,
156 "layout (location=0) in vec2 a_co;"
158 "uniform vec3 uOffset;"
162 "gl_Position = vec4( uPv * vec3( a_co * uOffset.z + uOffset.xy, 1.0 ), 1.0 );"
166 "out vec4 FragColor;"
167 "uniform vec4 uColour;"
171 "FragColor = uColour;"
174 UNIFORMS({ "uPv", "uOffset", "uColour" })
177 SHADER_DEFINE( shader_ball
,
179 "layout (location=0) in vec2 a_co;"
180 "uniform vec3 uOffset;"
183 "out vec4 aTexCoords;"
188 "vec3 worldpos = vec3( (a_co * 0.5 - 0.25) * uOffset.z + uOffset.xy, 1.0 );"
189 "gl_Position = vec4( uPv * worldpos, 1.0 );"
191 // Create texture coords
192 "aTexCoords = vec4( a_co, worldpos.xy );"
196 "out vec4 FragColor;"
198 "uniform sampler2D uTexMain;"
199 "uniform vec3 uColour;"
200 "uniform vec2 uTexOffset;"
202 "in vec4 aTexCoords;"
206 "vec2 center_coords = aTexCoords.xy - 0.5;"
207 "vec2 center_coords_sqr = center_coords*center_coords;"
208 "float circle_factor = smoothstep( 0.07, 0.0625, center_coords_sqr.x+center_coords_sqr.y );"
210 "float bulge_amt = center_coords_sqr.x+center_coords_sqr.y;"
211 "vec2 warped_coords = aTexCoords.zw+uTexOffset - center_coords;"
212 "vec4 noise_sample = texture( uTexMain, warped_coords );"
214 "float rim_light = (center_coords_sqr.x+center_coords_sqr.y)*15.0;"
216 "vec2 shadow_coords = center_coords + vec2(0.02,0.07);"
217 "vec2 shadow_coords_sqr = shadow_coords*shadow_coords;"
218 "float shadow = exp(-((shadow_coords_sqr.x+shadow_coords_sqr.y)-0.0125)*15.0);"
220 "vec3 marble_comp = uColour*0.9 + (noise_sample.x*0.7+pow(rim_light,3.0)*2.0) * 0.1;"
221 "vec4 colour_comp = mix( vec4(0.74,0.53,0.34,shadow), vec4(marble_comp,1.0), circle_factor );"
223 "FragColor = colour_comp;"
226 UNIFORMS({ "uTexMain", "uColour", "uOffset", "uPv", "uTexOffset" })
229 SHADER_DEFINE( shader_tile_main
,
231 "layout (location=0) in vec2 a_co;"
232 "uniform vec4 uOffset;" // Tile x/y, uv x/y
234 "uniform mat2 uSubTransform;"
236 "out vec4 aTexCoords;"
237 "out vec2 aWorldCoords;"
239 "vec2 hash22(vec2 p)"
241 "vec3 p3 = fract(vec3(p.xyx) * vec3(.1031, .1030, .0973));"
242 "p3 += dot(p3, p3.yzx+33.33);"
243 "return fract((p3.xx+p3.yz)*p3.zy);"
249 "vec2 subtransform = uSubTransform * (a_co-0.5) + 0.5;"
250 "vec3 worldpos = vec3( subtransform + uOffset.xy, 1.0 );"
251 "gl_Position = vec4( uPv * worldpos, 1.0 );"
253 // Create texture coords
254 "vec2 random_offset = floor(hash22(uOffset.xy) * 4.0) * 0.25;"
255 "vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
256 "aTexCoords = vec4((edge_safe_coords + uOffset.zw) * 0.25, edge_safe_coords * 0.25 + random_offset );"
257 "aWorldCoords = worldpos.xy;"
261 "out vec4 FragColor;"
263 "uniform sampler2D uTexGlyphs;"
264 "uniform sampler2D uTexWood;"
265 "uniform float uGhost;"
266 "uniform float uForeground;"
267 "uniform vec2 uMousePos;"
268 "uniform vec4 uColour;"
270 "in vec4 aTexCoords;"
271 "in vec2 aWorldCoords;"
275 "vec3 shadowing_colour = vec3( 0.93, 0.88536, 0.8184 ) * 0.97;"
276 "vec4 glyph = texture( uTexGlyphs, aTexCoords.xy );"
277 "vec4 wood = texture( uTexWood, aTexCoords.zw );"
278 "vec4 wood_secondary = texture( uTexWood, aTexCoords.zw + 0.25 );"
279 "vec3 wood_comp = mix( wood_secondary.rgb * shadowing_colour, wood.rgb, clamp( glyph.b * 2.0 - 1.0, 0.0, 1.0 ) );"
281 "vec3 shadows = mix( vec3( 0.85, 0.7344, 0.561 ), vec3(1.0,1.0,1.0), glyph.r );"
283 "vec4 output_regular = vec4( wood_comp * shadows, mix( glyph.a, glyph.b, uForeground ) );"
285 "float ghost_dist = clamp( 1.5 - distance(uMousePos, aWorldCoords), 0.0, 1.0 );"
286 "vec4 output_ghost = vec4( 1.0, 1.0, 1.0, glyph.g * ghost_dist );"
288 "FragColor = mix( output_regular, output_ghost, uGhost ) * uColour;"
291 UNIFORMS({ "uPv", "uOffset", "uTexGlyphs", "uTexWood", "uSubTransform", "uGhost", "uMousePos", "uColour", "uForeground" })
294 SHADER_DEFINE( shader_background
,
296 "layout (location=0) in vec2 a_co;"
298 "uniform vec3 uOffset;"
300 "out vec2 aTexCoords;"
304 "vec2 world_pos = a_co * uOffset.z + uOffset.xy;"
305 "gl_Position = vec4( uPv * vec3( world_pos, 1.0 ), 1.0 );"
310 "out vec4 FragColor;"
312 "uniform sampler2D uTexMain;"
313 "uniform sampler2D uSamplerNoise;"
314 "uniform float uVariance;"
316 "in vec2 aTexCoords;"
320 "float ao_accum = 0.0;"
321 "for( int i=0; i<10; ++i )"
323 "vec2 random_noise = (texture( uSamplerNoise, aTexCoords * 20.0 + float(i) * 0.2 ).xy - vec2( 0.5, 0.5 )) * uVariance;"
324 "vec4 background = texture( uTexMain, aTexCoords + random_noise );"
325 "ao_accum += background.r * clamp((1.0 - length( random_noise )), 0.0, 1.0);"
329 "vec4 data_this_tile = texture( uTexMain, aTexCoords );"
331 "ao_accum -= data_this_tile.r;"
333 "vec3 colour_main = mix( vec3( 0.369768, 0.3654, 0.42 ),vec3( 0.275, 0.388, 0.553 ), data_this_tile.g );"
335 "vec2 square_coords = fract( aTexCoords * 64.0 );"
336 "vec2 grid_coords = abs( square_coords - 0.5 );"
337 "float edge_contrast = (1.0-ao_accum*0.2);"
339 "float gridline = step( 0.49, max(grid_coords.x,grid_coords.y) );"
340 "float gridline_fadeout = min(max(edge_contrast-1.0, 0.0)*40.0 + data_this_tile.g,10.0);"
342 "FragColor = vec4( colour_main * edge_contrast + gridline * 0.02 * gridline_fadeout, 1.0 );"
345 UNIFORMS({ "uPv", "uOffset", "uTexMain", "uVariance", "uSamplerNoise" })
348 SHADER_DEFINE( shader_wire
,
350 "layout (location=0) in vec2 a_co;"
351 "uniform vec3 uStart;"
354 "uniform float uCurve;"
356 "out vec2 aTexCoords;"
358 "vec3 sample_curve_time( float t )"
360 "vec3 line_coord = mix( uStart, uEnd, t );"
362 "float curve_amt = 1.0-(pow((t*2.0-1.0),2.0));"
363 "return vec3( line_coord.x, line_coord.y - curve_amt*uCurve, line_coord.z );"
369 "vec3 p0 = sample_curve_time( a_co.x );"
370 "vec3 p1 = sample_curve_time( a_co.x + 0.025 );"
372 "vec2 line_tangent = normalize(p1.xy-p0.xy);"
373 "vec2 line_normal = vec2( -line_tangent.y, line_tangent.x );"
375 "vec2 worldfinal = p0.xy + line_normal*a_co.y*p0.z;"
377 "gl_Position = vec4( uPv * vec3(worldfinal, 1.0), 1.0 );"
379 // Create texture coords (todo: include stretch adjusted coords?)
380 "aTexCoords = vec2( a_co.x, a_co.y + 0.5 );"
384 "out vec4 FragColor;"
386 "uniform sampler2D uTexMain;"
387 "uniform vec4 uColour;"
388 "uniform float uTime;"
389 "uniform float uGlow;"
391 "in vec2 aTexCoords;"
396 "float shadow = 1.0 - abs(aTexCoords.y - 0.5) * 2.0;"
397 "float masking = smoothstep( 0.5, 0.8, shadow );"
399 "vec3 colour_comp = mix( vec3(0.0,0.0,0.0), uColour.rgb, masking );"
401 "float flow_thing = fract( aTexCoords.x + uTime );"
402 "vec3 final_comp = colour_comp + flow_thing * uGlow;"
404 "FragColor = vec4( final_comp, max( shadow* 0.2, masking ) * uColour.a );"
407 UNIFORMS({ "uPv", "uColour", "uTexMain", "uStart", "uEnd", "uCurve", "uTime", "uGlow" })
410 SHADER_DEFINE( shader_buttons
,
412 "layout (location=0) in vec2 a_co;"
413 "uniform vec4 uOffset;" // Tile x/y, uv x/y
416 "out vec2 aTexCoords;"
421 "vec3 worldpos = vec3( a_co + uOffset.xy, 1.0 );"
422 "gl_Position = vec4( uPv * worldpos, 1.0 );"
424 // Create texture coords
425 "vec2 edge_safe_coords = a_co * 0.98 + 0.01;"
426 "aTexCoords = (edge_safe_coords + uOffset.zw) * 0.25;"
430 "out vec4 FragColor;"
432 "uniform sampler2D uTexMain;"
433 "uniform vec4 uColour;" // rgb, light amount
435 "in vec2 aTexCoords;"
439 "vec4 glyph = texture( uTexMain, aTexCoords.xy );"
441 "FragColor = vec4( uColour.rgb * (mix(glyph.r, glyph.g, uColour.a)+0.02)*2.6 + glyph.b * 0.4, glyph.a );"
444 UNIFORMS({ "uPv", "uOffset", "uTexMain", "uColour" })
448 void vg_register(void)
450 SHADER_INIT( shader_tile_colour
);
451 SHADER_INIT( shader_tile_main
);
452 SHADER_INIT( shader_ball
);
453 SHADER_INIT( shader_background
);
454 SHADER_INIT( shader_wire
);
455 SHADER_INIT( shader_buttons
);
459 0000 0 | 0001 1 | 0010 2 | 0011 3
463 0100 4 | 0101 5 | 0110 6 | 0111 7
467 1000 8 | 1001 9 | 1010 10 | 1011 11
471 1100 12 | 1101 13 | 1110 14 | 1111 15
477 float const MESH_NUMBER_0
[] = {
478 #include "fonts/numbers/n0.h"
481 float const MESH_NUMBER_1
[] = {
482 #include "fonts/numbers/n1.h"
485 float const MESH_NUMBER_2
[] = {
486 #include "fonts/numbers/n2.h"
489 float const MESH_NUMBER_3
[] = {
490 #include "fonts/numbers/n3.h"
493 float const MESH_NUMBER_4
[] = {
494 #include "fonts/numbers/n4.h"
497 float const MESH_NUMBER_5
[] = {
498 #include "fonts/numbers/n5.h"
501 float const MESH_NUMBER_6
[] = {
502 #include "fonts/numbers/n6.h"
505 float const MESH_NUMBER_7
[] = {
506 #include "fonts/numbers/n7.h"
509 float const MESH_NUMBER_8
[] = {
510 #include "fonts/numbers/n8.h"
513 float const MESH_NUMBER_9
[] = {
514 #include "fonts/numbers/n9.h"
517 float const MESH_NUMBERS_BUFFER
[] =
519 #include "fonts/numbers/n0.h"
520 #include "fonts/numbers/n1.h"
521 #include "fonts/numbers/n2.h"
522 #include "fonts/numbers/n3.h"
523 #include "fonts/numbers/n4.h"
524 #include "fonts/numbers/n5.h"
525 #include "fonts/numbers/n6.h"
526 #include "fonts/numbers/n7.h"
527 #include "fonts/numbers/n8.h"
528 #include "fonts/numbers/n9.h"
531 #define MESH_NUMBER_DIVISOR 6
533 u32
const MESH_NUMBERS_OFFSETS
[][2] =
537 vg_list_size( MESH_NUMBER_0
) / MESH_NUMBER_DIVISOR
540 vg_list_size( MESH_NUMBER_0
) / MESH_NUMBER_DIVISOR
,
541 vg_list_size( MESH_NUMBER_1
) / MESH_NUMBER_DIVISOR
545 vg_list_size( MESH_NUMBER_0
) +
546 vg_list_size( MESH_NUMBER_1
)
547 ) / MESH_NUMBER_DIVISOR
,
548 vg_list_size( MESH_NUMBER_2
) / MESH_NUMBER_DIVISOR
552 vg_list_size( MESH_NUMBER_0
) +
553 vg_list_size( MESH_NUMBER_1
) +
554 vg_list_size( MESH_NUMBER_2
)
555 ) / MESH_NUMBER_DIVISOR
,
556 vg_list_size( MESH_NUMBER_3
) / MESH_NUMBER_DIVISOR
560 vg_list_size( MESH_NUMBER_0
) +
561 vg_list_size( MESH_NUMBER_1
) +
562 vg_list_size( MESH_NUMBER_2
) +
563 vg_list_size( MESH_NUMBER_3
)
564 ) / MESH_NUMBER_DIVISOR
,
565 vg_list_size( MESH_NUMBER_4
) / MESH_NUMBER_DIVISOR
569 vg_list_size( MESH_NUMBER_0
) +
570 vg_list_size( MESH_NUMBER_1
) +
571 vg_list_size( MESH_NUMBER_2
) +
572 vg_list_size( MESH_NUMBER_3
) +
573 vg_list_size( MESH_NUMBER_4
)
574 ) / MESH_NUMBER_DIVISOR
,
575 vg_list_size( MESH_NUMBER_5
) / MESH_NUMBER_DIVISOR
579 vg_list_size( MESH_NUMBER_0
) +
580 vg_list_size( MESH_NUMBER_1
) +
581 vg_list_size( MESH_NUMBER_2
) +
582 vg_list_size( MESH_NUMBER_3
) +
583 vg_list_size( MESH_NUMBER_4
) +
584 vg_list_size( MESH_NUMBER_5
)
585 ) / MESH_NUMBER_DIVISOR
,
586 vg_list_size( MESH_NUMBER_6
) / MESH_NUMBER_DIVISOR
590 vg_list_size( MESH_NUMBER_0
) +
591 vg_list_size( MESH_NUMBER_1
) +
592 vg_list_size( MESH_NUMBER_2
) +
593 vg_list_size( MESH_NUMBER_3
) +
594 vg_list_size( MESH_NUMBER_4
) +
595 vg_list_size( MESH_NUMBER_5
) +
596 vg_list_size( MESH_NUMBER_6
)
597 ) / MESH_NUMBER_DIVISOR
,
598 vg_list_size( MESH_NUMBER_7
) / MESH_NUMBER_DIVISOR
602 vg_list_size( MESH_NUMBER_0
) +
603 vg_list_size( MESH_NUMBER_1
) +
604 vg_list_size( MESH_NUMBER_2
) +
605 vg_list_size( MESH_NUMBER_3
) +
606 vg_list_size( MESH_NUMBER_4
) +
607 vg_list_size( MESH_NUMBER_5
) +
608 vg_list_size( MESH_NUMBER_6
) +
609 vg_list_size( MESH_NUMBER_7
)
610 ) / MESH_NUMBER_DIVISOR
,
611 vg_list_size( MESH_NUMBER_8
) / MESH_NUMBER_DIVISOR
615 vg_list_size( MESH_NUMBER_0
) +
616 vg_list_size( MESH_NUMBER_1
) +
617 vg_list_size( MESH_NUMBER_2
) +
618 vg_list_size( MESH_NUMBER_3
) +
619 vg_list_size( MESH_NUMBER_4
) +
620 vg_list_size( MESH_NUMBER_5
) +
621 vg_list_size( MESH_NUMBER_6
) +
622 vg_list_size( MESH_NUMBER_7
) +
623 vg_list_size( MESH_NUMBER_8
)
624 ) / MESH_NUMBER_DIVISOR
,
625 vg_list_size( MESH_NUMBER_9
) / MESH_NUMBER_DIVISOR
631 const char *map_name
;
633 const char *description
;
638 int _unlock
, _linked
; // When completed, unlock this level
639 struct cmp_level
*unlock
, *linked
;
644 SteamLeaderboard_t steam_leaderboard
;
647 static struct cmp_level cmp_levels_tutorials
[] =
652 .title
= "PRINCIPLE 1",
653 .map_name
= "cmp_t01",
655 "Utilize basic transport methods",
663 .title
= "PRINCIPLE 2",
664 .map_name
= "cmp_t02",
666 "Utilize the twisty turny(TM) piece to split the marble\n"
675 .title
= "PRINCIPLE 3",
676 .map_name
= "cmp_t03",
678 "Merge transport into one path",
686 .title
= "PRINCIPLE 4",
687 .map_name
= "cmp_t04",
689 "Some stages require multiple runs to succeed in order to\n"
697 static struct cmp_level cmp_levels_basic
[] =
703 .map_name
= "cmp_b04",
705 "For some reason, the division module our intern built\n"
706 "for us is sending twice as many yellows as needed. Send\n"
707 "the excess to be recycled!",
715 .title
= "SUBDIVISION 1",
716 .map_name
= "cmp_b01",
718 "Sometimes getting the desired amount takes dividing up\n"
719 "the input and recombining it.",
727 .title
= "SUBDIVISION 2",
728 .map_name
= "cmp_b02",
737 .title
= "RESTRUCTURE",
738 .map_name
= "cmp_b03",
740 "It is possible to swap these values using simple\n"
741 "division and addition.",
748 .title
= "PATTERNS 1",
749 .map_name
= "cmp_b05",
751 "Replicate the pattern",
758 .title
= "PATTERNS 2",
759 .map_name
= "cmp_b06",
768 .title
= "PRINCIPLE 5",
769 .map_name
= "cmp_b10",
771 "The sharp engineers among you may have already spotted\n"
772 "and utilized this part of the system\n"
774 "We forgot to include the relevant principle tasks as\n"
775 "of your training package, you will now be tasked to\n"
784 .title
= "ROUTING PROBLEM",
785 .map_name
= "cmp_routing",
787 "Things can get a little chaotic on tight boards, do your\n"
788 "best to utilize principle 5 to get the job done\n",
795 .title
= "MIGHTY CONSUMER",
796 .map_name
= "cmp_b07",
798 "Build a greedy system",
806 .map_name
= "cmp_b08",
816 .map_name
= "cmp_b09",
818 "Reverse the incoming order. Always length 4",
825 .title
= "PRINCIPLE 6",
826 .map_name
= "cmp_b11",
828 "Usually the splitter piece will flip flop between left\n"
829 "and right, however it can be forced to only rotate in\n"
830 "one direction if trigger wires are attached.\n"
832 "Right click and drag from a regular block, and attach it\n"
833 "to a splitter. This creates a trigger.\n"
834 "The default state is left, and once a marble hits the\n"
835 "trigger it will switch to rotating that direction.",
844 .map_name
= "cmp_not",
846 "Test your knowledge of triggers, build an 'NOT GATE'\n"
847 "emulated by marble logic.",
856 .map_name
= "cmp_and",
858 "A slightly more complicated gate, but shouldn't be\n"
859 "too difficult for your skillset.",
866 .title
= "QUALIFICATION PROJECT",
867 .map_name
= "cmp_xor",
869 "Significantly more complicated than an AND or NOT gate,\n"
876 static struct cmp_level cmp_levels_grad
[] =
882 .map_name
= "cmp_i01",
884 "Devise a scheme to filter and sort the inputs. If you\n"
885 "believe you lack the tools required to solve this one,\n"
886 "take a harder look at the inputs.",
894 .map_name
= "cmp_i02",
896 "Split the inputs up into a third of their values\n"
898 "Is this possible? -HG",
905 .title
= "SIMPLE ADDITION",
906 .map_name
= "cmp_grad",
908 "Take the amount of yellows coming in, and add them\n"
909 "together. Send your result using the stream of blues.",
916 .title
= "SECRET CODE",
917 .map_name
= "cmp_secret",
923 #define NUM_CAMPAIGN_LEVELS (vg_list_size( cmp_levels_tutorials ) + vg_list_size( cmp_levels_basic ) + vg_list_size( cmp_levels_grad ))
925 static struct serializable_set
927 struct cmp_level
*pack
;
930 career_serializable
[] =
933 .pack
= cmp_levels_tutorials
,
934 .count
= vg_list_size( cmp_levels_tutorials
)
937 .pack
= cmp_levels_basic
,
938 .count
= vg_list_size( cmp_levels_basic
)
941 .pack
= cmp_levels_grad
,
942 .count
= vg_list_size( cmp_levels_grad
)
946 // Setup pointers and that
947 static void career_local_data_init(void)
949 struct cmp_level
*level_ptrs
[ NUM_CAMPAIGN_LEVELS
];
952 for( int i
= 0; i
< vg_list_size( career_serializable
); i
++ )
954 struct serializable_set
*set
= &career_serializable
[i
];
956 for( int j
= 0; j
< set
->count
; j
++ )
957 level_ptrs
[ set
->pack
[j
].serial_id
] = &set
->pack
[j
];
961 for( int i
= 0; i
< vg_list_size( career_serializable
); i
++ )
963 struct serializable_set
*set
= &career_serializable
[i
];
965 for( int j
= 0; j
< set
->count
; j
++ )
967 struct cmp_level
*lvl
= &set
->pack
[j
];
968 lvl
->unlock
= lvl
->_unlock
? level_ptrs
[ lvl
->_unlock
]: NULL
;
969 lvl
->linked
= lvl
->_linked
? level_ptrs
[ lvl
->_linked
]: NULL
;