From c8fcae3be40a894616c361f146b95323d6c4b7ff Mon Sep 17 00:00:00 2001 From: qbix79 Date: Wed, 13 May 2009 10:40:42 +0000 Subject: [PATCH] Improve saving on 64 bit linux. DukePlus seems to save/load for me now. No changes for HUBmaps though. git-svn-id: https://svn.eduke32.com/eduke32@1378 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/savegame.c | 60 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 0c724bcc2..e82b853d6 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -234,15 +234,15 @@ int32_t G_LoadPlayer(int32_t spot) if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; invalidatetile(TILE_LOADSHOT,0,255); - if (kdfread(&numwalls,2,1,fil) != 1) goto corrupt; + if (kdfread(&numwalls,sizeof(numwalls),1,fil) != 1) goto corrupt; if (kdfread(&wall[0],sizeof(walltype),MAXWALLS,fil) != MAXWALLS) goto corrupt; - if (kdfread(&numsectors,2,1,fil) != 1) goto corrupt; + if (kdfread(&numsectors,sizeof(numsectors),1,fil) != 1) goto corrupt; if (kdfread(§or[0],sizeof(sectortype),MAXSECTORS,fil) != MAXSECTORS) goto corrupt; if (kdfread(&sprite[0],sizeof(spritetype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; if (kdfread(&spriteext[0],sizeof(spriteext_t),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; #ifdef POLYMER - if (kdfread(&staticlightcount,sizeof(int32_t),1,fil) != 1) goto corrupt; + if (kdfread(&staticlightcount,sizeof(staticlightcount),1,fil) != 1) goto corrupt; if (kdfread(&staticlights[0],sizeof(_prlight),staticlightcount,fil) != staticlightcount) goto corrupt; #else if (kdfread(&i,sizeof(int32_t),1,fil) != 1) goto corrupt; @@ -253,14 +253,14 @@ int32_t G_LoadPlayer(int32_t spot) if (spriteext[i].mdanimtims) spriteext[i].mdanimtims+=mdtims; #endif - if (kdfread(&headspritesect[0],2,MAXSECTORS+1,fil) != MAXSECTORS+1) goto corrupt; - if (kdfread(&prevspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&nextspritesect[0],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&headspritestat[STAT_DEFAULT],2,MAXSTATUS+1,fil) != MAXSTATUS+1) goto corrupt; - if (kdfread(&prevspritestat[STAT_DEFAULT],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; - if (kdfread(&nextspritestat[STAT_DEFAULT],2,MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&headspritesect[0],sizeof(headspritesect[0]),MAXSECTORS+1,fil) != MAXSECTORS+1) goto corrupt; + if (kdfread(&prevspritesect[0],sizeof(prevspritesect[0]),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritesect[0],sizeof(nextspritesect[0]),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&headspritestat[STAT_DEFAULT],sizeof(headspritestat[STAT_DEFAULT]),MAXSTATUS+1,fil) != MAXSTATUS+1) goto corrupt; + if (kdfread(&prevspritestat[STAT_DEFAULT],sizeof(prevspritestat[STAT_DEFAULT]),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; + if (kdfread(&nextspritestat[STAT_DEFAULT],sizeof(nextspritestat[STAT_DEFAULT]),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; if (kdfread(&g_numCyclers,sizeof(g_numCyclers),1,fil) != 1) goto corrupt; - if (kdfread(&cyclers[0][0],12,MAXCYCLERS,fil) != MAXCYCLERS) goto corrupt; + if (kdfread(&cyclers[0][0],sizeof(cyclers[0][0])*6,MAXCYCLERS,fil) != MAXCYCLERS) goto corrupt; for (i=0; i=0; i--) animateptr[i] = (int32_t *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); - if (kdfread(&animategoal[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; - if (kdfread(&animatevel[0],4,MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + if (kdfread(&animatesect[0],sizeof(animatesect[0]),MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + if (kdfread(&animateptr[0],sizeof(animateptr[0]),MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + for (i = g_animateCount-1; i>=0; i--) animateptr[i] = (int32_t*)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); + if (kdfread(&animategoal[0],sizeof(animategoal[0]),MAXANIMATES,fil) != MAXANIMATES) goto corrupt; + if (kdfread(&animatevel[0],sizeof(animatevel[0]),MAXANIMATES,fil) != MAXANIMATES) goto corrupt; if (kdfread(&g_earthquakeTime,sizeof(g_earthquakeTime),1,fil) != 1) goto corrupt; if (kdfread(&ud.from_bonus,sizeof(ud.from_bonus),1,fil) != 1) goto corrupt; @@ -671,9 +671,9 @@ int32_t G_SavePlayer(int32_t spot) } dfwrite((char *)waloff[TILE_SAVESHOT],320,200,fil); - dfwrite(&numwalls,2,1,fil); + dfwrite(&numwalls,sizeof(numwalls),1,fil); dfwrite(&wall[0],sizeof(walltype),MAXWALLS,fil); - dfwrite(&numsectors,2,1,fil); + dfwrite(&numsectors,sizeof(numsectors),1,fil); dfwrite(§or[0],sizeof(sectortype),MAXSECTORS,fil); dfwrite(&sprite[0],sizeof(spritetype),MAXSPRITES,fil); #if defined(POLYMOST) && defined(USE_OPENGL) @@ -688,7 +688,7 @@ int32_t G_SavePlayer(int32_t spot) dfwrite(&spriteext[0],sizeof(spriteext_t),MAXSPRITES,fil); #ifdef POLYMER - dfwrite(&staticlightcount,sizeof(int32_t),1,fil); + dfwrite(&staticlightcount,sizeof(staticlightcount),1,fil); dfwrite(&staticlights[0],sizeof(_prlight),staticlightcount,fil); #else i = 0; @@ -698,14 +698,14 @@ int32_t G_SavePlayer(int32_t spot) #if defined(POLYMOST) && defined(USE_OPENGL) for (i=0; i=0; i--) animateptr[i] = (int32_t *)((intptr_t)animateptr[i]-(intptr_t)(§or[0])); - dfwrite(&animateptr[0],4,MAXANIMATES,fil); + dfwrite(&animateptr[0],sizeof(animateptr[0]),MAXANIMATES,fil); for (i = g_animateCount-1; i>=0; i--) animateptr[i] = (int32_t *)((intptr_t)animateptr[i]+(intptr_t)(§or[0])); - dfwrite(&animategoal[0],4,MAXANIMATES,fil); - dfwrite(&animatevel[0],4,MAXANIMATES,fil); + dfwrite(&animategoal[0],sizeof(animategoal[0]),MAXANIMATES,fil); + dfwrite(&animatevel[0],sizeof(animatevel[0]),MAXANIMATES,fil); dfwrite(&g_earthquakeTime,sizeof(g_earthquakeTime),1,fil); dfwrite(&ud.from_bonus,sizeof(ud.from_bonus),1,fil);