summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2008-05-18 05:08:17 -0700
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:37 +0200
commit2d2faf124767533d1d594b753b129d9bf547b5b7 (patch)
tree587b6a255da58ff4c252cc9d619eb76762222b0a /src
parent5d730a8930d735935082b25288ac4916c0a81289 (diff)
Worked around a crash during level reloads.
Global state in bh_marin.c isn't being deinitialized, and this was causing some code to incorrectly execute during a level restart. Said code has been commented out, as it appears to have been previously disabled. Improved the deinitialization in pheromon.c to make similar crashes more obvious.
Diffstat (limited to 'src')
-rw-r--r--src/avp/bh_marin.c9
-rw-r--r--src/avp/pheromon.c42
2 files changed, 43 insertions, 8 deletions
diff --git a/src/avp/bh_marin.c b/src/avp/bh_marin.c
index 8befd1c..7db60df 100644
--- a/src/avp/bh_marin.c
+++ b/src/avp/bh_marin.c
@@ -13719,6 +13719,12 @@ void GetPointToFaceMarineTowards(STRATEGYBLOCK *sbPtr,VECTORCH *output) {
return;
}
+ // SBF - 20080518 - commented out - this block of code is a NO-OP
+ // due to the aliased targetModule variable. This code might have
+ // been disabled intentionally? In any case, disabling this code
+ // works around a crash in FarNPC_GetTargetAIModuleForMarineRespond
+ // during level reloads.
+#if 0 // SBF - 20080518 - commented out
if (NpcSquad.alertZone) {
/* Might want to face towards trouble. */
if (sbPtr->containingModule->m_aimodule!=NpcSquad.alertZone) {
@@ -13726,7 +13732,7 @@ void GetPointToFaceMarineTowards(STRATEGYBLOCK *sbPtr,VECTORCH *output) {
targetModule = FarNPC_GetTargetAIModuleForMarineRespond(sbPtr);
}
}
-
+
/* Did that work? */
if (targetModule) {
@@ -13745,6 +13751,7 @@ void GetPointToFaceMarineTowards(STRATEGYBLOCK *sbPtr,VECTORCH *output) {
}
}
+#endif // SBF - 20080518 - commented out
AdjModuleRefPtr = sbPtr->containingModule->m_aimodule->m_link_ptrs;
/* check if there is a module adjacency list */
diff --git a/src/avp/pheromon.c b/src/avp/pheromon.c
index 4a04fa8..cb84b84 100644
--- a/src/avp/pheromon.c
+++ b/src/avp/pheromon.c
@@ -182,16 +182,44 @@ End of level clean up for pheromone system
void CleanUpPheromoneSystem(void)
{
#if 1
- if (Pher_Player1) DeallocateMem(Pher_Player1);
- if (Pher_Player2) DeallocateMem(Pher_Player2);
- if (Pher_Ai1) DeallocateMem(Pher_Ai1);
+ if (Pher_Player1 != NULL) {
+ DeallocateMem(Pher_Player1);
+ Pher_Player1 = NULL;
+ }
+ if (Pher_Player2 != NULL) {
+ DeallocateMem(Pher_Player2);
+ Pher_Player2 = NULL;
+ }
+ if (Pher_Ai1 != NULL) {
+ DeallocateMem(Pher_Ai1);
+ Pher_Ai1 = NULL;
+ }
+ PherPl_ReadBuf = NULL;
+ PherPl_WriteBuf = NULL;
+ PherAi_Buf = NULL;
#endif
#if SUPER_PHEROMONE_SYSTEM
- if (Pher_Aliens1) DeallocateMem(Pher_Aliens1);
- if (Pher_Aliens2) DeallocateMem(Pher_Aliens2);
- if (Pher_Marines1) DeallocateMem(Pher_Marines1);
- if (Pher_Marines2) DeallocateMem(Pher_Marines2);
+ if (Pher_Aliens1 != NULL) {
+ DeallocateMem(Pher_Aliens1);
+ Pher_Aliens1 = NULL;
+ }
+ if (Pher_Aliens2 != NULL) {
+ DeallocateMem(Pher_Aliens2);
+ Pher_Aliens2 = NULL;
+ }
+ if (Pher_Marines1 != NULL) {
+ DeallocateMem(Pher_Marines1);
+ Pher_Marines1 = NULL;
+ }
+ if (Pher_Marines2 != NULL) {
+ DeallocateMem(Pher_Marines2);
+ Pher_Marines2 = NULL;
+ }
+ PherAls_ReadBuf = NULL;
+ PherAls_WriteBuf = NULL;
+ PherMars_ReadBuf = NULL;
+ PherMars_WriteBuf = NULL;
#endif
}