naev 0.12.6
shiplog.c File Reference

Handles a log/journal of the player's playthrough. More...

#include "shiplog.h"
#include <inttypes.h>
Include dependency graph for shiplog.c:

Go to the source code of this file.

Data Structures

struct  ShipLogEntry
struct  ShipLog

Functions

static ShipLogEntryshiplog_removeEntry (ShipLogEntry *e)
 removes an entry from the log
int shiplog_create (const char *idstr, const char *logname, const char *type, int overwrite, int maxLen)
 Creates a new log with given title of given type.
int shiplog_append (const char *idstr, const char *msg)
 Appends to the log file.
int shiplog_appendByID (int logid, const char *msg)
 Adds to the log file.
void shiplog_delete (int logid)
 Deletes a log (e.g. a cancelled mission may wish to do this, or the user might).
void shiplog_setRemove (int logid, ntime_t when)
 Sets the remove flag for a log - it will be removed once time increases, eg after a player takes off.
void shiplog_deleteType (const char *type)
 Deletes all logs of given type.
void shiplog_clear (void)
 Clear the shiplog.
void shiplog_new (void)
 Set up the shiplog.
int shiplog_save (xmlTextWriterPtr writer)
int shiplog_load (xmlNodePtr parent)
 Loads the logfiile.
void shiplog_listTypes (int *ntypes, char ***logTypes, int includeAll)
void shiplog_listLogsOfType (const char *type, int *nlogs, char ***logsOut, int **logIDs, int includeAll)
 Lists matching logs (which haven't expired via "removeAfter") into the provided arrays.
int shiplog_getIdOfLogOfType (const char *type, int selectedLog)
void shiplog_listLog (int logid, const char *type, int *nentries, char ***logentries, int incempty)
 Get all log entries matching logid, or if logid==LOG_ID_ALL, matching type, or if type==NULL, all.
int shiplog_getID (const char *idstr)
 Checks to see if the log family exists.

Variables

static ShipLog shipLog

Detailed Description

Handles a log/journal of the player's playthrough.

Definition in file shiplog.c.

Function Documentation

◆ shiplog_append()

int shiplog_append ( const char * idstr,
const char * msg )

Appends to the log file.

Parameters
idstrof the log to add to
msgMessage to be added.
Returns
0 on success, -1 on failure.

Definition at line 183 of file shiplog.c.

◆ shiplog_appendByID()

int shiplog_appendByID ( int logid,
const char * msg )

Adds to the log file.

Parameters
logidof the log to add to.
msgMessage to be added.
Returns
0 on success, -1 on failure.

Definition at line 211 of file shiplog.c.

◆ shiplog_clear()

void shiplog_clear ( void )

Clear the shiplog.

Definition at line 367 of file shiplog.c.

◆ shiplog_create()

int shiplog_create ( const char * idstr,
const char * logname,
const char * type,
int overwrite,
int maxLen )

Creates a new log with given title of given type.

Parameters
idstrID string for this logset, or NULL if an ID string not required.
lognameName of the log (title)
typeType of the log, e.g. travel, shipping, etc
overwriteWhether to overwrite an existing log of this type and logname (if 1), or all logs of this type (if 2).
maxLenMaximum number of entries for this log (longer ones will be purged).
Returns
log ID.

Definition at line 56 of file shiplog.c.

◆ shiplog_delete()

void shiplog_delete ( int logid)

Deletes a log (e.g. a cancelled mission may wish to do this, or the user might).

Parameters
logidof the log to remove, or LOG_ID_ALL

Definition at line 277 of file shiplog.c.

◆ shiplog_deleteType()

void shiplog_deleteType ( const char * type)

Deletes all logs of given type.

Parameters
typeof the log to remove

Definition at line 351 of file shiplog.c.

◆ shiplog_getID()

int shiplog_getID ( const char * idstr)

Checks to see if the log family exists.

Parameters
idstrID string for the log family

Definition at line 696 of file shiplog.c.

◆ shiplog_getIdOfLogOfType()

int shiplog_getIdOfLogOfType ( const char * type,
int selectedLog )

Definition at line 584 of file shiplog.c.

◆ shiplog_listLog()

void shiplog_listLog ( int logid,
const char * type,
int * nentries,
char *** logentries,
int incempty )

Get all log entries matching logid, or if logid==LOG_ID_ALL, matching type, or if type==NULL, all.

Definition at line 635 of file shiplog.c.

◆ shiplog_listLogsOfType()

void shiplog_listLogsOfType ( const char * type,
int * nlogs,
char *** logsOut,
int ** logIDs,
int includeAll )

Lists matching logs (which haven't expired via "removeAfter") into the provided arrays.

Parameters
typeThe log-type to match (or NULL to match any type).
[out]nlogsNumber of logs emitted.
[out]logsOutMatching log-names. Will be reallocated as needed. Emitted strings must be freed.
[out]logIDsMatching log ID lists. Will be reallocated as needed. Emitted lists are owned by the shipLog.
includeAllWhether to include the special "All" log.

Definition at line 547 of file shiplog.c.

◆ shiplog_listTypes()

void shiplog_listTypes ( int * ntypes,
char *** logTypes,
int includeAll )

Definition at line 502 of file shiplog.c.

◆ shiplog_load()

int shiplog_load ( xmlNodePtr parent)

Loads the logfiile.

Parameters
parentParent node for economy.
Returns
0 on success.

Definition at line 434 of file shiplog.c.

◆ shiplog_new()

void shiplog_new ( void )

Set up the shiplog.

Definition at line 382 of file shiplog.c.

◆ shiplog_removeEntry()

ShipLogEntry * shiplog_removeEntry ( ShipLogEntry * e)
static

removes an entry from the log

Parameters
ethe entry to remove
Returns
the next entry.

Definition at line 612 of file shiplog.c.

◆ shiplog_save()

int shiplog_save ( xmlTextWriterPtr writer)

Definition at line 390 of file shiplog.c.

◆ shiplog_setRemove()

void shiplog_setRemove ( int logid,
ntime_t when )

Sets the remove flag for a log - it will be removed once time increases, eg after a player takes off.

Parameters
logidthe ID of the log
whenthe time at which to remove. If 0, uses current time, if <0, adds abs to current time, if >0, uses as the time to remove. Rationale: Allows a player to review the log while still landed, and then clears it up once takes off.

Definition at line 330 of file shiplog.c.

Variable Documentation

◆ shipLog

ShipLog shipLog
static

The player's ship log.

Definition at line 36 of file shiplog.c.