Side note -- I would define a constant that represents "never expires". Something like:
class DisasterHelper
{
public:
static const int NEVER_EXPIRES = 0;
public:
DisasterHelper();
/* etc. */
};
That way it could be called with something like:
DisasterHelper d;
d.setTimer(DisasterHelper::NEVER_EXPIRES);
Haven't thoroughly looked over the disaster helper code so hopefully my explanation is clear.
A constant is a good idea. Very nice syntax leeor_net.
Might I suggest using MAX_INT instead of 0? Then everything would work out without special checks.
if (intVar > MAX_INT) {
// never true
}
You can find MAX_INT in a standard header. I believe <climits> is where you should look, unless you have a really old compiler in which case it might be <limits.h>.
I'd be tempted to use unsigned integers for time counters, since negative values don't make sense, in which case MAX_UINT would be more appropriate. I don't recommend that here though, since the game just declares most stuff as int. Better to stick with the datatype that is actually being used.
Leeor & Hooman,
I'm adding the Timer as indicated in the following code. I'm setting it to expire by default at 250 marks. This is a bit of a shot in the dark. If anyone has a better default time for when to drop the SafeZones, please suggest it. Perhaps I'll find some time to test a couple of Last One Standing rounds to see from experience what the number should be when the player is pretty established. The people I usually play with are not big on LoS though. Thanks for the ideas!
Side question, is it a good practice to use this->someClassProperty = someClassProperty? This way if I make the variable from the function setting the class property the same name as the class property, there is no confusion. I do this all the time in C# using this.someClassProperty = someClassProperty and I think they are kind of equivalent.
public:
// Sets a timer value in marks where base safeZones expire, allowing more dangerous disasters to hit bases.
// To make SafeZones never expire, set timeInMarks to the const TimerNeverExpires.
// To disable SafeZones without clearing them from DisasterHelper, set timeInMarks <= 0
void SetSafeZoneExpirationTimer(int timeInMarks)
{
this->safeZoneTimer = timeInMarks;
}
static const int TimerNeverExpires = INT_MAX;
private:
int safeZoneTimer = 250;