diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 18a9d68c09..531ab42629 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,9 @@ March 22, 2008 (Changes by Graf Zahl) +- Added more options to Light_ForceLightning: Setting the first arg to 0 + will behave as before, setting it to 1 will create exactly one lighting + and setting it to 2 will terminate lightning for the current level + completely. And it will also work on maps that don't have lightning set + in MAPINFO now. - Added: Sector movement that causes deep water to change its height now will trigger associated sector actions and adjust the actor's water level. - Fixed: The serializer for side_t::part never read the texture information diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index 501429e81d..7bf5ad842d 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -14,6 +14,7 @@ IMPLEMENT_CLASS (DLightningThinker) DLightningThinker::DLightningThinker () : DThinker (STAT_LIGHTNING) { + Stopped = false; LightningLightLevels = NULL; LightningFlashCount = 0; NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start @@ -37,7 +38,7 @@ void DLightningThinker::Serialize (FArchive &arc) Super::Serialize (arc); - arc << NextLightningFlash << LightningFlashCount; + arc << Stopped << NextLightningFlash << LightningFlashCount; if (arc.IsLoading ()) { @@ -63,6 +64,7 @@ void DLightningThinker::Tick () else { --NextLightningFlash; + if (Stopped) Destroy(); } } @@ -166,9 +168,21 @@ void DLightningThinker::LightningFlash () } } -void DLightningThinker::ForceLightning () +void DLightningThinker::ForceLightning (int mode) { - NextLightningFlash = 0; + switch (mode) + { + default: + NextLightningFlash = 0; + break; + + case 1: + NextLightningFlash = 0; + // Fall through + case 2: + Stopped = true; + break; + } } static DLightningThinker *LocateLightning () @@ -186,20 +200,15 @@ void P_StartLightning () } } -void P_StopLightning () +void P_ForceLightning (int mode) { DLightningThinker *lightning = LocateLightning (); + if (lightning == NULL) + { + lightning = new DLightningThinker (); + } if (lightning != NULL) { - lightning->Destroy (); - } -} - -void P_ForceLightning () -{ - DLightningThinker *lightning = LocateLightning (); - if (lightning != NULL) - { - lightning->ForceLightning (); + lightning->ForceLightning (mode); } } diff --git a/src/g_shared/a_lightning.h b/src/g_shared/a_lightning.h index ff72df5534..4e3a08ebeb 100644 --- a/src/g_shared/a_lightning.h +++ b/src/g_shared/a_lightning.h @@ -15,18 +15,19 @@ public: ~DLightningThinker (); void Serialize (FArchive &arc); void Tick (); - void ForceLightning (); + void ForceLightning (int mode); + void TerminateLightning(); protected: void LightningFlash (); int NextLightningFlash; int LightningFlashCount; + bool Stopped; BYTE *LightningLightLevels; }; void P_StartLightning (); -void P_StopLightning (); -void P_ForceLightning (); +void P_ForceLightning (int mode); #endif //__A_LIGHTNING_H__ diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 2be3039335..9ebf4c332c 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1666,9 +1666,9 @@ FUNC(LS_Elevator_LowerToNearest) } FUNC(LS_Light_ForceLightning) -// Light_ForceLightning (tag) +// Light_ForceLightning (mode) { - P_ForceLightning (); + P_ForceLightning (arg0); return true; } diff --git a/src/version.h b/src/version.h index 6dd8175cea..77eb4b184c 100644 --- a/src/version.h +++ b/src/version.h @@ -75,7 +75,7 @@ // SAVESIG should match SAVEVER. // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 836 +#define MINSAVEVER 837 #if SVN_REVISION_NUMBER < MINSAVEVER // Never write a savegame with a version lower than what we need