ref: d053170646190f31263ae1ed75ad8cbf95409e91
parent: 88dd6235bcf78c545796795ac6a1f0732e4fab9e
author: Simon Howard <[email protected]>
date: Thu Oct 9 15:40:04 EDT 2008
Fix crashes when loading the same level twice. Subversion-branch: /branches/raven-branch Subversion-revision: 1348
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -342,11 +342,13 @@
}
}
ACStringCount = *buffer++;
- ACStrings = (char **) buffer;
- for (i = 0; i < ACStringCount; i++)
+ ACStrings = Z_Malloc(ACStringCount * sizeof(char *), PU_LEVEL, NULL);
+
+ for (i=0; i<ACStringCount; ++i)
{
- ACStrings[i] += (int) ActionCodeBase;
+ ACStrings[i] = (char *) ActionCodeBase + buffer[i];
}
+
memset(MapVars, 0, sizeof(MapVars));
}
--- a/src/hexen/p_mobj.c
+++ b/src/hexen/p_mobj.c
@@ -1446,11 +1446,18 @@
// Check for player starts 5 to 8
if (mthing->type >= 9100 && mthing->type <= 9103)
{
- mthing->type = 5 + mthing->type - 9100; // Translate to 5 - 8
- playerstarts[mthing->arg1][mthing->type - 1] = *mthing;
- if (!deathmatch && !mthing->arg1)
+ mapthing_t *player_start;
+ int player;
+
+ player = 4 + mthing->type - 9100;
+
+ player_start = &playerstarts[mthing->arg1][player];
+ memcpy(player_start, mthing, sizeof(mapthing_t));
+ player_start->type = player + 1;
+
+ if (!deathmatch && !player_start->arg1)
{
- P_SpawnPlayer(mthing);
+ P_SpawnPlayer(player_start);
}
return;
}