aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavid <[email protected]>2026-07-25 05:05:21 -0300
committerdavid <[email protected]>2026-07-25 05:05:21 -0300
commit8d63c9dd1c6d1b78caee7aa21670185fe022d0df (patch)
treec37120e07efa864d191a9f067ffcc97f5fdb5abd
parent20da733459123ccb1c83e7a5689b34741711ad5c (diff)
downloadpetratc-8d63c9dd1c6d1b78caee7aa21670185fe022d0df.tar.gz
petratc-8d63c9dd1c6d1b78caee7aa21670185fe022d0df.zip
segfault if you go to negative numbers in the maze game...
-rw-r--r--games/gamemaze.c6
-rw-r--r--petratc.c10
-rw-r--r--rat.c10
3 files changed, 13 insertions, 13 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;
diff --git a/petratc.c b/petratc.c
index d3171cd..2cb60fb 100644
--- a/petratc.c
+++ b/petratc.c
@@ -33,9 +33,9 @@ char *funfact[] = {
Rat rat;
-//i was cleaning the code up a bit and what the fuck is this
+/*i was cleaning the code up a bit and what the fuck is this
//it's so funny Rat rat
-
+*/
void printrat(WINDOW *win){
werase(win);
@@ -101,13 +101,13 @@ int truing = 1;
case '2':
endwin();
gamemaze();
- //printf("the maze is really dark squeak...\n\n");
+ /*printf("the maze is really dark squeak...\n\n");*/
refresh();
break;
case '4':
endwin();
gamecatch();
- //printf("your rat feels cleaner!\n\n");
+ /*printf("your rat feels cleaner!\n\n");*/
refresh();
break;
case '5':
@@ -118,7 +118,7 @@ int truing = 1;
case '9': break;
case '0': truing = 0; break;
}
-// i will put those printfs where the squeaks go but i have no clue how to do that today
+/* i will put those printfs where the squeaks go but i have no clue how to do that today */
if(truing) printrat(win);
}
diff --git a/rat.c b/rat.c
index e713cc4..136659f 100644
--- a/rat.c
+++ b/rat.c
@@ -47,7 +47,7 @@ void load(void) {
&rat.hunger, &rat.love, &rat.fun, &rat.clean, &rat.health, &rat.age) != 6){
fprintf(stderr, "error: failed to initialize save data.\n");
}
- //this should shut the compiler up
+ /*this should shut the compiler up*/
fclose(f);
}
@@ -67,12 +67,12 @@ float decay(float current, float dayspassed, float rate) {
void setstat(){
int timenow = time(NULL);
int newage = timenow - rat.age;
- float days = newage / 86400.0f; //one day
+ float days = newage / 86400.0f; /*one day*/
- rat.hunger = decay(rat.hunger, days, 50.0f); //hungry beast
- rat.love = decay(rat.love, days, 1.1f); //rats love you they won't hate you easly
+ rat.hunger = decay(rat.hunger, days, 50.0f); /*hungry beast*/
+ rat.love = decay(rat.love, days, 1.1f); /*rats love you they won't hate you easly*/
rat.fun = decay(rat.fun, days, 25.0f);
- rat.clean = decay(rat.clean, days, 5.0f);//rats are surprisingly clean they clean themselves so slow
+ rat.clean = decay(rat.clean, days, 5.0f);/*rats are surprisingly clean they clean themselves so slow*/
rat.health = decay(rat.health, days, 0.6f);
rat.age = timenow;