Hi,
I just started looking over UFOAI's source code to learn how some things are implemented and found something that may lead to an annoying effect: Namely the time an alien mission lasts has no lower bound.
Some affected code from client/cl_campaign.c:
static void CP_TerrorMissionStart (mission_t *mission)
{
const date_t missionDelay = {3, 0};
assert(mission->ufo);
mission->finalDate = Date_Add(ccs.date, Date_Random(missionDelay));
...
(Other mission types may use similar code.)
Date_Random() is implemented as:
static date_t Date_Random (date_t frame)
{
frame.sec = (frame.day * 3600 * 24 + frame.sec) * frand();
frame.day = frame.sec / (3600 * 24);
frame.sec = frame.sec % (3600 * 24);
return frame;
}
In case frand() returns a very small value it is possible that a terror mission may last only a few hours, minutes or even seconds which is to quick for the player to react. I propose that a lower bound should be added .
The attached patch does just that. One may argue about the minimum values I chose but this can be tweaked easily by others.
[attachment deleted by admin]