[Add] Documented ltime.

This commit is contained in:
Allanis 2014-05-27 19:22:35 +01:00
parent 35f8570f83
commit 4455499beb
2 changed files with 32 additions and 6 deletions

View File

@ -14,7 +14,7 @@ void hook_rmParent(unsigned int parent);
* -- "takeoff" - When taking off.
* -- "jump" - When changing systems.
* -- "time" - When time is increment drastically
* (hyperspace and taking off.
* (hyperspace and taking off).
* ========================================================
*/

View File

@ -1,3 +1,16 @@
/**
* @file ltime.c
*
* @brief Handle the lephisto time.
*
* The basic unit of time is the STU. There are 1000 STU in a MTU. The time
* representation is generally UST which consists of MTU.STU.
*
* Acronyms:
* - MTU : Major Time Unit (1000 STU)
* - STU : Synchronized Time Unit.
* - UST : Universal Synchonized Time.
*/
#include <stdio.h>
#include <string.h>
@ -6,14 +19,21 @@
#include "economy.h"
#include "ltime.h"
static unsigned int lephisto_time = 0;
static unsigned int lephisto_time = 0; /**< Contains the current time in mSTU. */
/* Get the current time. */
/**
* @brief Get the current time.
* @return The current time in mSTU.
*/
unsigned int ltime_get(void) {
return lephisto_time;
}
/* Return the time in pretty text. */
/**
* @brief Get the time in a pretty human readable format.
* @param t Time to print (in STU), if 0 it'll use the current time.
* @return The time in a human readable format (must free).
*/
char* ltime_pretty(unsigned int t) {
unsigned int lt;
int maj, stu;
@ -34,12 +54,18 @@ char* ltime_pretty(unsigned int t) {
return ret;
}
/* Set the time absolutely, does *not* generate an event, used at init. */
/**
* @brief Set the time absolutely, does *not* generate an event, used at init.
* @param t Absolute time to set to in STU.
*/
void ltime_set(unsigned int t) {
lephisto_time = t;
}
/* Set the time relatively. */
/**
* @brief Set the time relatively.
* @param t Time modifier in STU.
*/
void ltime_inc(unsigned int t) {
lephisto_time += t;