project-navigation
Personal tools

Author Topic: possible annoyance: no lower time limit on alien missions  (Read 3579 times)

thebohemian

  • Guest
possible annoyance: no lower time limit on alien missions
« on: April 05, 2008, 03:43:25 pm »
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:
Code: [Select]
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:
Code: [Select]
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]

Offline kracken

  • Squad Leader
  • ****
  • Posts: 159
    • View Profile
Re: possible annoyance: no lower time limit on alien missions
« Reply #1 on: April 05, 2008, 05:12:05 pm »
Thank you, this was on my todo list, but I didn't had time to do it :)

Your patch is committed in trunk, 16157