diff options
| author | david <[email protected]> | 2026-07-25 05:05:21 -0300 |
|---|---|---|
| committer | david <[email protected]> | 2026-07-25 05:05:21 -0300 |
| commit | 8d63c9dd1c6d1b78caee7aa21670185fe022d0df (patch) | |
| tree | c37120e07efa864d191a9f067ffcc97f5fdb5abd /games | |
| parent | 20da733459123ccb1c83e7a5689b34741711ad5c (diff) | |
| download | petratc-8d63c9dd1c6d1b78caee7aa21670185fe022d0df.tar.gz petratc-8d63c9dd1c6d1b78caee7aa21670185fe022d0df.zip | |
segfault if you go to negative numbers in the maze game...
Diffstat (limited to 'games')
| -rw-r--r-- | games/gamemaze.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/games/gamemaze.c b/games/gamemaze.c index 3ce8737..6e563cf 100644 --- a/games/gamemaze.c +++ b/games/gamemaze.c @@ -276,8 +276,8 @@ void gamemaze(){ case 'q': case 'Q': stop(); break; case 'r': case 'R': properrestart(&curs, &W, &H); break; case 'a': case 'A': case KEY_LEFT: - if(!iswall(curs.posy, curs.posx - 1)){ - curs.posx -= 1; + if(curs.posx > 0 && !iswall(curs.posy, curs.posx - 1)){ + curs.posx -= 1; } break; case 'd': case 'D': case KEY_RIGHT: @@ -286,7 +286,7 @@ void gamemaze(){ } break; case 'w': case 'W': case KEY_UP: - if (!iswall(curs.posy - 1, curs.posx)){ + if (curs.posy > 0 && !iswall(curs.posy - 1, curs.posx)){ curs.posy -= 1; } break; |
