[Scummvm-cvs-logs] CVS: scummvm/dc Makefile,1.2,1.3 vmsave.cpp,1.1,1.2

Marcus Comstedt marcus_c at users.sourceforge.net
Tue Feb 26 17:03:08 CET 2002


Update of /cvsroot/scummvm/scummvm/dc
In directory usw-pr-cvs1:/tmp/cvs-serv16134

Modified Files:
	Makefile vmsave.cpp 
Log Message:
Compressed savegames.

Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Makefile	2 Feb 2002 23:36:35 -0000	1.2
--- Makefile	27 Feb 2002 01:02:16 -0000	1.3
***************
*** 11,15 ****
  INCLUDES:= -I./ -I../ -I../sound
  CPPFLAGS= $(DEFINES) $(INCLUDES)
! LIBS	= ronin/libronin.a -lm
  
  INCS	= scumm.h scummsys.h stdafx.h portdefs.h dc.h
--- 11,15 ----
  INCLUDES:= -I./ -I../ -I../sound
  CPPFLAGS= $(DEFINES) $(INCLUDES)
! LIBS	= ronin/libronin.a ronin/libz.a -lm
  
  INCS	= scumm.h scummsys.h stdafx.h portdefs.h dc.h
***************
*** 19,24 ****
  	sys.o verbs.o script_v1.o script_v2.o debug.o gui.o \
  	sound/imuse.o sound/fmopl.o sound/adlib.o sound/gmidi.o debugrl.o \
! 	akos.o dcmain.o display.o audio.o input.o selector.o icon.o label.o \
! 	vmsave.o
  
  .cpp.o:
--- 19,24 ----
  	sys.o verbs.o script_v1.o script_v2.o debug.o gui.o \
  	sound/imuse.o sound/fmopl.o sound/adlib.o sound/gmidi.o debugrl.o \
! 	akos.o vars.o dcmain.o display.o audio.o input.o selector.o icon.o \
! 	label.o vmsave.o
  
  .cpp.o:

Index: vmsave.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/dc/vmsave.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** vmsave.cpp	2 Feb 2002 23:36:35 -0000	1.1
--- vmsave.cpp	27 Feb 2002 01:02:16 -0000	1.2
***************
*** 26,29 ****
--- 26,35 ----
  #include "icon.h"
  
+ #include <ronin/zlib.h>
+ 
+ 
+ // Savegame can not be bigger than this, even before compression
+ #define MAX_SAVE_SIZE (128*1024)
+ 
  
  enum vmsaveResult {
***************
*** 170,176 ****
      strncpy(c->filename, filename, 16);
      c->pos = 0;
!     c->buffer = new char[c->size = 128*1024];
      return true;
    } else if(readSaveGame(c->buffer, c->size, filename)) {
      c->issave = false;
      c->pos = 0;
--- 176,192 ----
      strncpy(c->filename, filename, 16);
      c->pos = 0;
!     c->buffer = new char[c->size = MAX_SAVE_SIZE];
      return true;
    } else if(readSaveGame(c->buffer, c->size, filename)) {
+     if(c->size > 0 && c->buffer[0] != 'S') {
+       // Data does not start with "SCVM".  Maybe compressed?
+       char *expbuf = new char[MAX_SAVE_SIZE];
+       unsigned long destlen = MAX_SAVE_SIZE;
+       if(!uncompress((Bytef*)expbuf, &destlen, (Bytef*)c->buffer, c->size)) {
+ 	delete(c->buffer);
+ 	c->buffer = expbuf;
+ 	c->size = destlen;
+       } else delete expbuf;
+     }
      c->issave = false;
      c->pos = 0;
***************
*** 190,196 ****
    if(context) {
      vmStreamContext *c = (vmStreamContext *)context;
!     if(c->issave)
        writeSaveGame(&scumm, c->buffer, c->pos,
  		    c->filename, icon);
      delete c->buffer;
      delete c;
--- 206,223 ----
    if(context) {
      vmStreamContext *c = (vmStreamContext *)context;
!     if(c->issave) {
!       if(c->pos) {
! 	// Try compression
! 	char *compbuf = new char[c->pos];
! 	unsigned long destlen = c->pos;
! 	if(!compress((Bytef*)compbuf, &destlen, (Bytef*)c->buffer, c->pos)) {
! 	  delete c->buffer;
! 	  c->buffer = compbuf;
! 	  c->pos = destlen;
! 	} else delete compbuf;
!       }
        writeSaveGame(&scumm, c->buffer, c->pos,
  		    c->filename, icon);
+     }
      delete c->buffer;
      delete c;





More information about the Scummvm-git-logs mailing list