[Change] Split beam/bolt loading logic.
This commit is contained in:
parent
5557963d1f
commit
2e444ff54b
64
src/outfit.c
64
src/outfit.c
@ -28,7 +28,8 @@ static OutfitType outfit_strToOutfitType(char* buf);
|
|||||||
/* Parsing. */
|
/* Parsing. */
|
||||||
static int outfit_parseDamage(DamageType* dtype, double* dmg, xmlNodePtr node);
|
static int outfit_parseDamage(DamageType* dtype, double* dmg, xmlNodePtr node);
|
||||||
static Outfit* outfit_parse(const xmlNodePtr parent);
|
static Outfit* outfit_parse(const xmlNodePtr parent);
|
||||||
static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent);
|
static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent);
|
||||||
|
static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent);
|
||||||
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent);
|
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent);
|
||||||
static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent);
|
static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent);
|
||||||
static void outfit_parseSMod(Outfit* tmp, const xmlNodePtr parent);
|
static void outfit_parseSMod(Outfit* tmp, const xmlNodePtr parent);
|
||||||
@ -436,7 +437,7 @@ static int outfit_parseDamage(DamageType* dtype, double* dmg, xmlNodePtr node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parses the specific area for a weapon and loads it into outfit. */
|
/* Parses the specific area for a weapon and loads it into outfit. */
|
||||||
static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent) {
|
static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) {
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
char str[PATH_MAX] = "\0";
|
char str[PATH_MAX] = "\0";
|
||||||
|
|
||||||
@ -468,7 +469,7 @@ static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
#define MELEMENT(o,s) \
|
#define MELEMENT(o,s) \
|
||||||
if (o) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
if (o) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->u.blt.gfx_space==NULL, "gfx");
|
MELEMENT(tmp->u.blt.gfx_space==NULL, "gfx");
|
||||||
MELEMENT((sound_disabled!=NULL) && (tmp->u.blt.sound==0), "sound");
|
MELEMENT((sound_disabled!=0) && (tmp->u.blt.sound<0), "sound");
|
||||||
MELEMENT(tmp->u.blt.delay==0, "delay");
|
MELEMENT(tmp->u.blt.delay==0, "delay");
|
||||||
MELEMENT(tmp->u.blt.speed==0, "speed");
|
MELEMENT(tmp->u.blt.speed==0, "speed");
|
||||||
MELEMENT(tmp->u.blt.range==0, "range");
|
MELEMENT(tmp->u.blt.range==0, "range");
|
||||||
@ -477,6 +478,37 @@ static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
#undef MELEMENT
|
#undef MELEMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent)
|
||||||
|
*
|
||||||
|
* @brief Parse the beam weapon specifics of an outfit.
|
||||||
|
* @param tmp Outfit to finish loading.
|
||||||
|
* @param parent Outfit's parent node.
|
||||||
|
*/
|
||||||
|
static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
||||||
|
xmlNodePtr node;
|
||||||
|
|
||||||
|
node = parent->xmlChildrenNode;
|
||||||
|
do { /* Load all the data. */
|
||||||
|
xmlr_float(node, "range", tmp->u.bem.range);
|
||||||
|
xmlr_float(node, "turn", tmp->u.bem.turn);
|
||||||
|
xmlr_float(node, "energy", tmp->u.bem.energy);
|
||||||
|
|
||||||
|
if(xml_isNode(node, "damage"))
|
||||||
|
outfit_parseDamage(&tmp->u.bem.dtype, &tmp->u.bem.damage, node);
|
||||||
|
} while(xml_nextNode(node));
|
||||||
|
|
||||||
|
tmp->u.bem.colour = &cWhite; /** @todo Make it loadable. */
|
||||||
|
|
||||||
|
#define MELEMENT(o,s) if(0) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
||||||
|
MELEMENT(tmp->u.bem.range==0, "range");
|
||||||
|
MELEMENT(tmp->u.bem.turn==0, "turn");
|
||||||
|
MELEMENT(tmp->u.bem.energy==0, "energy");
|
||||||
|
MELEMENT(tmp->u.bem.damage==0, "damage");
|
||||||
|
#undef MELEMENT
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Parse the specific area for a launcher and loads it into Outfit. */
|
/* Parse the specific area for a launcher and loads it into Outfit. */
|
||||||
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent) {
|
static void outfit_parseSLauncher(Outfit* tmp, const xmlNodePtr parent) {
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
@ -530,7 +562,7 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
|
|
||||||
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)
|
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->u.amm.gfx_space == NULL, "gfx");
|
MELEMENT(tmp->u.amm.gfx_space == NULL, "gfx");
|
||||||
MELEMENT((sound_disabled != NULL) && (tmp->u.amm.sound == 0), "sound");
|
MELEMENT((sound_disabled != 0) && (tmp->u.amm.sound < 0), "sound");
|
||||||
MELEMENT(tmp->u.amm.thrust==0, "thrust");
|
MELEMENT(tmp->u.amm.thrust==0, "thrust");
|
||||||
/* Dumb missiles don't need everything. */
|
/* Dumb missiles don't need everything. */
|
||||||
if(tmp->type != OUTFIT_TYPE_MISSILE_DUMB_AMMO) {
|
if(tmp->type != OUTFIT_TYPE_MISSILE_DUMB_AMMO) {
|
||||||
@ -673,14 +705,14 @@ static Outfit* outfit_parse(const xmlNodePtr parent) {
|
|||||||
}
|
}
|
||||||
if(tmp->type == OUTFIT_TYPE_NULL)
|
if(tmp->type == OUTFIT_TYPE_NULL)
|
||||||
WARN("Outfit '%s' is of type NONE", tmp->name);
|
WARN("Outfit '%s' is of type NONE", tmp->name);
|
||||||
else if(outfit_isWeapon(tmp))
|
else if(outfit_isBolt(tmp))
|
||||||
outfit_parseSWeapon(tmp, node);
|
outfit_parseSBolt(tmp, node);
|
||||||
|
else if(outfit_isBeam(tmp))
|
||||||
|
outfit_parseSBeam(tmp, node);
|
||||||
else if(outfit_isLauncher(tmp))
|
else if(outfit_isLauncher(tmp))
|
||||||
outfit_parseSLauncher(tmp, node);
|
outfit_parseSLauncher(tmp, node);
|
||||||
else if(outfit_isAmmo(tmp))
|
else if(outfit_isAmmo(tmp))
|
||||||
outfit_parseSAmmo(tmp, node);
|
outfit_parseSAmmo(tmp, node);
|
||||||
else if(outfit_isTurret(tmp))
|
|
||||||
outfit_parseSWeapon(tmp, node);
|
|
||||||
else if(outfit_isMod(tmp))
|
else if(outfit_isMod(tmp))
|
||||||
outfit_parseSMod(tmp, node);
|
outfit_parseSMod(tmp, node);
|
||||||
else if(outfit_isAfterburner(tmp))
|
else if(outfit_isAfterburner(tmp))
|
||||||
@ -690,15 +722,15 @@ static Outfit* outfit_parse(const xmlNodePtr parent) {
|
|||||||
else if(outfit_isJammer(tmp))
|
else if(outfit_isJammer(tmp))
|
||||||
outfit_parseSJammer(tmp, node);
|
outfit_parseSJammer(tmp, node);
|
||||||
}
|
}
|
||||||
} while((node = node->next));
|
} while(xml_nextNode(node));
|
||||||
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)
|
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->name==NULL, "name");
|
MELEMENT(tmp->name==NULL, "name");
|
||||||
MELEMENT(tmp->max==0, "max");
|
MELEMENT(tmp->max==0, "max");
|
||||||
MELEMENT(tmp->tech==0, "tech");
|
MELEMENT(tmp->tech==0, "tech");
|
||||||
MELEMENT(tmp->gfx_store==NULL, "gfx_store");
|
MELEMENT(tmp->gfx_store==NULL, "gfx_store");
|
||||||
/*MELEMENT(tmp->mass==0, "mass"); */
|
/*MELEMENT(tmp->mass==0, "mass"); */
|
||||||
MELEMENT(tmp->type==0, "type");
|
MELEMENT(tmp->type==0, "type");
|
||||||
MELEMENT(tmp->price==0, "price");
|
MELEMENT(tmp->price==0, "price");
|
||||||
MELEMENT(tmp->description==NULL, "description");
|
MELEMENT(tmp->description==NULL, "description");
|
||||||
#undef MELEMENT
|
#undef MELEMENT
|
||||||
|
|
||||||
|
@ -64,10 +64,11 @@ typedef struct OutfitBoltData_ {
|
|||||||
*/
|
*/
|
||||||
typedef struct OutfitBeamData_ {
|
typedef struct OutfitBeamData_ {
|
||||||
double range; /**< How far it goes. */
|
double range; /**< How far it goes. */
|
||||||
glColour colour; /**< Beam colour. */
|
double turn; /**< How fast it can turn. Only for turrets. */
|
||||||
double energy; /**< Energy it drains. */
|
glColour* colour; /**< Beam colour. */
|
||||||
double dtype; /**< Damage type. */
|
double energy; /**< Amount of energy it drains (per second). */
|
||||||
double damage; /**< Damage. */
|
DamageType dtype; /**< Damage type. */
|
||||||
|
double damage; /**< Damage amount. */
|
||||||
} OutfitBeamData;
|
} OutfitBeamData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user