projects
/
fishladder.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b99d010
)
refactor cell references to use pcell
author
hgn
<hgodden00@gmail.com>
Sun, 26 Sep 2021 00:28:35 +0000
(
01:28
+0100)
committer
hgn
<hgodden00@gmail.com>
Sun, 26 Sep 2021 00:28:35 +0000
(
01:28
+0100)
fishladder.c
patch
|
blob
|
history
diff --git
a/fishladder.c
b/fishladder.c
index 8d1443b93cbc00af95013aa1e3e54482d70fb280..dc875272cd304b624f2df4227c785c7a0ff9149c 100644
(file)
--- a/
fishladder.c
+++ b/
fishladder.c
@@
-424,7
+424,7
@@
static int cell_interactive( v2i co )
for( int y = co[1]-2; y < co[1]+3; y ++ )
for( int x = co[0]-2; x < co[0]+3; x ++ )
{
for( int y = co[1]-2; y < co[1]+3; y ++ )
for( int x = co[0]-2; x < co[0]+3; x ++ )
{
- struct cell *cell =
&world.data[ world.w*y + x ]
;
+ struct cell *cell =
pcell((v2i){x,y})
;
if( cell && (cell->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT)) )
blob |= 0x1 << ((y-(co[1]-2))*5 + x-(co[0]-2));
if( cell && (cell->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT)) )
blob |= 0x1 << ((y-(co[1]-2))*5 + x-(co[0]-2));
@@
-532,18
+532,18
@@
void vg_update(void)
u8 config = 0x00;
u8 config = 0x00;
- if(
world.data[y*world.w+x].
state & FLAG_CANAL )
+ if(
pcell((v2i){x,y})->
state & FLAG_CANAL )
{
for( int i = 0; i < vg_list_size( dirs ); i ++ )
{
{
for( int i = 0; i < vg_list_size( dirs ); i ++ )
{
- struct cell *neighbour =
&world.data[(y+dirs[i][1])*world.w+x+dirs[i][0]]
;
+ struct cell *neighbour =
pcell((v2i){x+dirs[i][0], y+dirs[i][1]})
;
if( neighbour->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT) )
config |= 0x1 << i;
}
} else config = 0xF;
if( neighbour->state & (FLAG_CANAL|FLAG_INPUT|FLAG_OUTPUT) )
config |= 0x1 << i;
}
} else config = 0xF;
-
world.data[ y*world.w+x ].
config = config;
-
world.data[ y*world.w+x ].
state &= ~(FLAG_DROP_L|FLAG_DROP_R|FLAG_SPLIT|FLAG_MERGER);
+
pcell((v2i){x,y})->
config = config;
+
pcell((v2i){x,y})->
state &= ~(FLAG_DROP_L|FLAG_DROP_R|FLAG_SPLIT|FLAG_MERGER);
}
}
}
}
@@
-554,7
+554,7
@@
void vg_update(void)
// R,-,L,U - 1011 (merger, 2 drop created)
// R,-,L,U - 1011 (merger, 2 drop created)
- u8 config =
world.data[y*world.w+x].
config;
+ u8 config =
pcell((v2i){x,y})->
config;
if( config == 0x7 ) // splitter
{
if( config == 0x7 ) // splitter
{
@@
-583,7
+583,7
@@
void vg_update(void)
{
for( int x = 1; x < world.w-1; x ++ )
{
{
for( int x = 1; x < world.w-1; x ++ )
{
- struct cell *cell =
&world.data[y*world.w+x]
;
+ struct cell *cell =
pcell((v2i){x,y})
;
if( cell->state & FLAG_OUTPUT )
cell->water[ buffer_next ] = 16;
if( cell->state & FLAG_OUTPUT )
cell->water[ buffer_next ] = 16;
@@
-780,7
+780,7
@@
void vg_render(void)
v4f colour;
v4f colour;
- struct cell *cell =
&world.data[y*world.w+x]
;
+ struct cell *cell =
pcell((v2i){x,y})
;
if( cell->state & FLAG_WALL ) { v4_copy( (v4f){ 0.2f, 0.2f, 0.2f, 1.0f }, colour ); }
else if( cell->state & FLAG_CANAL ) { v4_copy( (v4f){ 0.6f, 0.6f, 0.6f, 1.0f }, colour ); }
if( cell->state & FLAG_WALL ) { v4_copy( (v4f){ 0.2f, 0.2f, 0.2f, 1.0f }, colour ); }
else if( cell->state & FLAG_CANAL ) { v4_copy( (v4f){ 0.6f, 0.6f, 0.6f, 1.0f }, colour ); }