From 7489c70b3d4c1f7c09c6719332bea03fa70ba696 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 26 May 2008 00:58:26 +0000 Subject: [PATCH] there was a very old bug in the emulator which didnt matter due to luck but which caused unexciting mappers not to store their (empty) state correctly in the savestate. WriteStateChunk() returned 0 when there was an error in SubWrite(), even though it shouldve written a 5 to account for the overhead --- src/state.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/state.cpp b/src/state.cpp index cd19b3a3..364b952f 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -143,7 +143,7 @@ static int WriteStateChunk(FILE *st, int type, SFORMAT *sf) if(!SubWrite(st,sf)) { - return(0); + return 5; } return (bsize+5); } @@ -358,7 +358,7 @@ bool FCEUSS_SaveFP(FILE *st) //compress it uint8* cbuf = new uint8[len*2]; //worst case compression, lets say twice the input buffer size - uLongf comprlen; + uLongf comprlen = len*2; int error = compress2(cbuf,&comprlen,&buf[0],len,Z_BEST_COMPRESSION); //dump the header