JohnAnthony / Nyancat

Screensaver of the (now passé) "poptart cat" fad, complete with free-as-in-freedom alternative resource set. This is the original C version.
Other
13 stars 1 forks source link

Fix `full` mode #4

Open jsjolen opened 9 months ago

jsjolen commented 9 months ago

Hi,

I fixed the full mode, you forgot to malloc the stretch_cat and had an off-by-one error, so close! I can't be bothered to make a fork and all of that, so here's the patch file. It only works in fullscreen mode so far btw.

diff --git a/nyan.c b/nyan.c
index 9e52439..05a71c5 100644
--- a/nyan.c
+++ b/nyan.c
@@ -448,7 +448,6 @@ load_resource_data(void) {
         errout("Error opening resource data file");

     ANIM_FRAMES_FG = atoi(fgets(buffer, BUF_SZ, f));
-    stretch_cat = malloc(sizeof(SDL_Surface*)*ANIM_FRAMES_FG);
     ANIM_FRAMES_BG = atoi(fgets(buffer, BUF_SZ, f));

     if (!ANIM_FRAMES_FG || !ANIM_FRAMES_BG)
@@ -519,7 +518,7 @@ stretch_images(void) {
     stretchto.h = stretchto.w * cat_img[0]->h / cat_img[0]->w;

     SDL_PixelFormat fmt = *(cat_img[0]->format);
-    for (int i=0; i < ANIM_FRAMES_FG; i++) {
+    for (int i=0; i <= ANIM_FRAMES_FG; i++) {
         stretch_cat[i] = SDL_CreateRGBSurface(SURF_TYPE, stretchto.w,
             stretchto.h,SCREEN_BPP,fmt.Rmask,fmt.Gmask,fmt.Bmask,fmt.Amask);
         SDL_SoftStretch(cat_img[i],NULL,stretch_cat[i],NULL);

Edit: Oops, I generated the diff in reverse, so this is how to remove my fix. Oh well, you'll figure it out.

jsjolen commented 9 months ago

PS, I hope I gave you some nostalgia :-D