Skip to content

Commit cc156a6

Browse files
committed
2.3: Add safeguard against savegame corruption when saving script data. This closes ticket:2625.
1 parent ebfc46b commit cc156a6

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
2011-04-xx: Version 2.3.8
22
* General:
3-
* New: Two new 2 player maps - Vision and Roughness (697afb16d5244f9715952f8762b1011c6d75101e)
3+
* New: Two new 2 player maps - Vision and Roughness (commit:697afb16d5244f9715952f8762b1011c6d75101e)
44
* Change: Increase recycled experience storage in memory (commit:703665b4b7df1282eee29a7064961bc66152a847)
55
* Change: Set a window icon (ticket:2465, commit:ac792c67d4bb66618ae7ff712844c4eebb70a496)
66
* Fix: Prevent savegame corruption (ticket:2100, commit:a974722e397b7072fb59d0114e2a4ef9f8d509d8)

src/scriptobj.c

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -562,31 +562,6 @@ BOOL scrGroupObjGet(UDWORD index)
562562
return false;
563563
}
564564

565-
//fix: turn off caching, since it can screw up everything if returns outdated values
566-
// recalculate the values if necessary
567-
/*
568-
if (lgGameTime != gameTime || psScrLastGroup != psGroup)
569-
{
570-
lgGameTime = gameTime;
571-
psScrLastGroup = psGroup;
572-
lgMembers = 0;
573-
lgHealth = 0;
574-
lgX = lgY = 0;
575-
for(psCurr = psGroup->psList; psCurr; psCurr = psCurr->psGrpNext)
576-
{
577-
lgMembers += 1;
578-
lgX += (SDWORD)psCurr->pos.x;
579-
lgY += (SDWORD)psCurr->pos.y;
580-
lgHealth += (SDWORD)((100 * psCurr->body)/psCurr->originalBody);
581-
}
582-
if (lgMembers > 0)
583-
{
584-
lgX = lgX / lgMembers;
585-
lgY = lgY / lgMembers;
586-
lgHealth = lgHealth / lgMembers;
587-
}
588-
}
589-
*/
590565
switch (index)
591566
{
592567
case GROUPID_POSX:
@@ -798,7 +773,7 @@ BOOL scrValDefSave(INTERP_VAL *psVal, char *pBuffer, UDWORD *pSize)
798773
// just save the id
799774
if (pBuffer)
800775
{
801-
if (psVal->v.oval == NULL)
776+
if (psVal->v.oval == NULL || ((BASE_OBJECT *)psVal->v.oval)->died > 1 || !getBaseObjFromId(((BASE_OBJECT *)psVal->v.oval)->id))
802777
{
803778
*((UDWORD*)pBuffer) = UDWORD_MAX;
804779
}
@@ -1197,26 +1172,8 @@ BOOL scrValDefLoad(SDWORD version, INTERP_VAL *psVal, char *pBuffer, UDWORD size
11971172
*
11981173
* Thus loading of these strings is practically impossible.
11991174
*/
1200-
#if 0
1201-
const char * const str = strresGetString(psStringRes, id);
1202-
if (!str)
1203-
{
1204-
debug(LOG_FATAL, "Couldn't find string with id %u", id);
1205-
abort();
1206-
return false;
1207-
}
1208-
1209-
psVal->v.sval = strdup(str);
1210-
if (!psVal->v.sval)
1211-
{
1212-
debug(LOG_FATAL, "Out of memory");
1213-
abort();
1214-
return false;
1215-
}
1216-
#else
12171175
debug(LOG_ERROR, "Incompatible savegame format version %u, should be at least version 4", (unsigned int)version);
12181176
return false;
1219-
#endif
12201177
}
12211178
}
12221179
else

0 commit comments

Comments
 (0)