projects
/
fishladder.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a6d22d2
)
save/load
author
hgn
<hgodden00@gmail.com>
Thu, 11 Nov 2021 23:24:09 +0000
(23:24 +0000)
committer
hgn
<hgodden00@gmail.com>
Thu, 11 Nov 2021 23:24:09 +0000
(23:24 +0000)
fishladder.c
patch
|
blob
|
history
diff --git
a/fishladder.c
b/fishladder.c
index 4817bdf9a2a20004f7795879f8f96c918fe4b910..09bcf43e605f77f8ec421d7087c300aaaec073ee 100644
(file)
--- a/
fishladder.c
+++ b/
fishladder.c
@@
-336,22
+336,20
@@
static int map_load( const char *str )
// Tile initialization
// row[ cx ] .. etc
// 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 );
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 ++;
}
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 ++;
}
c ++;
@@
-432,7
+430,7
@@
static void console_save_map( int argc, char *argv[] )
{
if( argc >= 1 )
{
{
if( argc >= 1 )
{
- FILE *test_writer = fopen( argv[0], "w" );
+ FILE *test_writer = fopen( argv[0], "w
b
" );
if( test_writer )
{
map_serialize( test_writer );
if( test_writer )
{
map_serialize( test_writer );
@@
-442,12
+440,30
@@
static void console_save_map( int argc, char *argv[] )
}
}
}
}
+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){
void vg_start(void)
{
vg_function_push( (struct vg_cmd){
- .name = "
save_map
",
+ .name = "
map_write
",
.function = console_save_map
});
.function = console_save_map
});
+
+ vg_function_push( (struct vg_cmd){
+ .name = "map_load",
+ .function = console_load_map
+ });
// Quad mesh
{
// Quad mesh
{