naev 0.12.5
damagetype.c File Reference

Handles damage types. More...

#include "damagetype.h"
#include "array.h"
#include "log.h"
#include "ndata.h"
#include "nxml.h"
#include "shipstats.h"
Include dependency graph for damagetype.c:

Go to the source code of this file.

Data Structures

struct  DTYPE
 A damage type. More...

Macros

#define DTYPE_XML_ID   "dtype"
#define MELEMENT(o, s)

Functions

static int DTYPE_parse (DTYPE *temp, const char *file)
 Parses an XML file containing a DTYPE.
static void DTYPE_free (DTYPE *damtype)
 Frees a DTYPE.
static DTYPEdtype_validType (int type)
 Gets the damage type.
static int dtype_cmp (const void *p1, const void *p2)
 For sorting and bsearching.
int dtype_get (const char *name)
 Gets the id of a dtype based on name.
const char * dtype_damageTypeToStr (int type)
 Gets the human readable string from damage type.
int dtype_load (void)
 Loads the dtype stack.
void dtype_free (void)
 Frees the dtype stack.
int dtype_raw (int type, double *shield, double *armour, double *knockback)
 Gets the raw modulation stats of a damage type.
void dtype_calcDamage (double *dshield, double *darmour, double absorb, double *knockback, const Damage *dmg, const ShipStats *s)
 Gives the real shield damage, armour damage and knockback modifier.

Variables

static DTYPEdtype_types = NULL

Detailed Description

Handles damage types.

Definition in file damagetype.c.

Macro Definition Documentation

◆ DTYPE_XML_ID

#define DTYPE_XML_ID   "dtype"

XML Document tag.

Definition at line 21 of file damagetype.c.

◆ MELEMENT

#define MELEMENT ( o,
s )
Value:
if ( o ) \
WARN( _( "DTYPE '%s' invalid '"s \
"' element" ), \
temp->name )

Function Documentation

◆ dtype_calcDamage()

void dtype_calcDamage ( double * dshield,
double * darmour,
double absorb,
double * knockback,
const Damage * dmg,
const ShipStats * s )

Gives the real shield damage, armour damage and knockback modifier.

Parameters
[out]dshieldReal shield damage.
[out]darmourReal armour damage.
[out]knockbackKnockback modifier.
[in]absorbAbsorption value.
[in]dmgDamage information.
[in]sShip stats to use.

Definition at line 275 of file damagetype.c.

◆ dtype_cmp()

int dtype_cmp ( const void * p1,
const void * p2 )
static

For sorting and bsearching.

Definition at line 51 of file damagetype.c.

◆ dtype_damageTypeToStr()

const char * dtype_damageTypeToStr ( int type)

Gets the human readable string from damage type.

Definition at line 184 of file damagetype.c.

◆ DTYPE_free()

void DTYPE_free ( DTYPE * damtype)
static

Frees a DTYPE.

Parameters
damtypeDTYPE to free.

Definition at line 143 of file damagetype.c.

◆ dtype_free()

void dtype_free ( void )

Frees the dtype stack.

Definition at line 233 of file damagetype.c.

◆ dtype_get()

int dtype_get ( const char * name)

Gets the id of a dtype based on name.

Parameters
nameName to match.
Returns
ID of the damage type or -1 on error.

Definition at line 157 of file damagetype.c.

◆ dtype_load()

int dtype_load ( void )

Loads the dtype stack.

Returns
0 on success.

Definition at line 197 of file damagetype.c.

◆ DTYPE_parse()

int DTYPE_parse ( DTYPE * temp,
const char * file )
static

Parses an XML file containing a DTYPE.

Parameters
tempAddress to load DTYPE into.
fileFile to parse.
Returns
0 on success.

Definition at line 65 of file damagetype.c.

◆ dtype_raw()

int dtype_raw ( int type,
double * shield,
double * armour,
double * knockback )

Gets the raw modulation stats of a damage type.

Parameters
typeType to get stats of.
[out]shieldShield damage modulator.
[out]armourArmour damage modulator.
[out]knockbackKnockback modulator.
Returns
0 on success.

Definition at line 251 of file damagetype.c.

◆ dtype_validType()

DTYPE * dtype_validType ( int type)
static

Gets the damage type.

Definition at line 172 of file damagetype.c.

Variable Documentation

◆ dtype_types

DTYPE* dtype_types = NULL
static

Total damage types.

Definition at line 38 of file damagetype.c.