// Tile initialization
// row[ cx ] .. etc
+ struct cell *cell = &row[ cx ];
if( *c == '+' || *c == '-' )
{
struct cell_terminal term = { .id = cx + world.h*world.w };
arrpush( world.io, term );
- row[ cx ++ ].state = *c == '+'? FLAG_INPUT: FLAG_OUTPUT;
+ cell->state = *c == '+'? FLAG_INPUT: FLAG_OUTPUT;
reg_end ++;
}
- else if( *c == '#' )
- {
- row[ cx ++ ].state = FLAG_WALL;
- }
- else
- {
- row[ cx ++ ].state = 0x00;
- }
+ else if( *c == '#' ) cell->state = FLAG_WALL;
+ else if( *c == '*' ) cell->state = FLAG_CANAL;
+ else cell->state = 0x00;
+
+ cx ++;
}
c ++;
{
if( argc >= 1 )
{
- FILE *test_writer = fopen( argv[0], "w" );
+ FILE *test_writer = fopen( argv[0], "wb" );
if( test_writer )
{
map_serialize( test_writer );
}
}
+static void console_load_map( int argc, char *argv[] )
+{
+ if( argc >= 1 )
+ {
+ char *text_source = vg_textasset_read( argv[0] );
+
+ if( text_source )
+ map_load( text_source );
+
+ free( text_source );
+ }
+}
+
void vg_start(void)
{
vg_function_push( (struct vg_cmd){
- .name = "save_map",
+ .name = "map_write",
.function = console_save_map
});
+
+ vg_function_push( (struct vg_cmd){
+ .name = "map_load",
+ .function = console_load_map
+ });
// Quad mesh
{