Skip to content

Commit

Permalink
Added triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 8, 2003
1 parent 7c5cc3c commit 6a868ef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions doomsday/Include/m_misc.h
Expand Up @@ -27,6 +27,11 @@
#define MAX_READ 8192
#define ISSPACE(c) ((c) == 0 || (c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r')

typedef struct trigger_s {
timespan_t duration;
timespan_t accum;
} trigger_t;

extern int read_count;
extern int rndindex;

Expand Down Expand Up @@ -84,6 +89,9 @@ void M_RotateVector(float vec[3], float degYaw, float degPitch);
void M_ProjectPointOnLinef(fixed_t *point, fixed_t *linepoint, fixed_t *delta, float gap, float *result);
float M_CycleIntoRange(float value, float length);

// Time utilities.
boolean M_CheckTrigger(trigger_t *trigger, timespan_t advanceTime);

// Other utilities.
int M_ScreenShot(char *filename, int bits);

Expand Down
24 changes: 20 additions & 4 deletions doomsday/Src/m_misc.c
Expand Up @@ -922,10 +922,9 @@ void M_ReplaceFileExt(char *path, char *newext)
}
}

//===========================================================================
// M_Pretty
// Return a prettier copy of the original path.
//===========================================================================
/*
* Return a prettier copy of the original path.
*/
const char *M_Pretty(const char *path)
{
#define MAX_BUFS 8
Expand All @@ -943,3 +942,20 @@ const char *M_Pretty(const char *path)
// We don't know how to make this prettier.
return path;
}

/*
* Advances time and return true if the trigger is triggered.
*/
boolean M_CheckTrigger(trigger_t *trigger, timespan_t advanceTime)
{
trigger->accum += advanceTime;

if(trigger->accum >= trigger->duration)
{
trigger->accum -= trigger->duration;
return true;
}

// It wasn't triggered.
return false;
}

0 comments on commit 6a868ef

Please sign in to comment.