18#include "dev_uniedit.h"
34 xmlTextWriterPtr writer;
35 char *file, *cleanName;
39 writer = xmlNewTextWriterDoc(&doc, 0);
41 WARN(_(
"testXmlwriterDoc: Error creating the xml writer"));
50 xmlw_startElem( writer,
"spob" );
53 xmlw_attr( writer,
"name",
"%s", p->name );
57 xmlw_elem( writer,
"display",
"%s", p->display );
59 xmlw_elem( writer,
"feature",
"%s", p->feature );
60 if ((p->lua_file!=NULL) && ((lua_default==NULL) || strcmp(lua_default,p->lua_file)!=0))
61 xmlw_elem( writer,
"lua",
"%s", p->lua_file );
62 if (spob_isFlag(p,SPOB_RADIUS))
63 xmlw_elem( writer,
"radius",
"%f", p->radius );
64 if (p->marker != NULL)
65 xmlw_elem( writer,
"marker",
"%s", p->marker->name );
68 xmlw_startElem( writer,
"pos" );
69 xmlw_attr( writer,
"x",
"%f", p->pos.x );
70 xmlw_attr( writer,
"y",
"%f", p->pos.y );
71 xmlw_endElem( writer );
74 xmlw_startElem( writer,
"GFX" );
75 if (p->gfx_spacePath != NULL)
76 xmlw_elem( writer,
"space",
"%s", p->gfx_spacePath );
77 if (p->gfx_exteriorPath != NULL)
78 xmlw_elem( writer,
"exterior",
"%s", p->gfx_exteriorPath );
79 xmlw_endElem( writer );
82 if (p->presence.faction >= 0) {
83 xmlw_startElem( writer,
"presence" );
84 xmlw_elem( writer,
"faction",
"%s",
faction_name( p->presence.faction ) );
85 xmlw_elem( writer,
"base",
"%f", p->presence.base );
86 xmlw_elem( writer,
"bonus",
"%f", p->presence.bonus );
87 xmlw_elem( writer,
"range",
"%d", p->presence.range );
88 xmlw_endElem( writer );
92 xmlw_startElem( writer,
"general" );
93 xmlw_elem( writer,
"class",
"%s", p->class );
94 xmlw_elem( writer,
"population",
"%g", (
double)p->population );
95 xmlw_elem( writer,
"hide",
"%f", p->hide );
96 xmlw_startElem( writer,
"services" );
97 if (spob_hasService( p, SPOB_SERVICE_LAND ))
98 xmlw_elemEmpty( writer,
"land" );
99 if (spob_hasService( p, SPOB_SERVICE_REFUEL ))
100 xmlw_elemEmpty( writer,
"refuel" );
101 if (spob_hasService( p, SPOB_SERVICE_BAR ))
102 xmlw_elemEmpty( writer,
"bar" );
103 if (spob_hasService( p, SPOB_SERVICE_MISSIONS ))
104 xmlw_elemEmpty( writer,
"missions" );
105 if (spob_hasService( p, SPOB_SERVICE_COMMODITY ))
106 xmlw_elemEmpty( writer,
"commodity" );
107 if (spob_hasService( p, SPOB_SERVICE_OUTFITS ))
108 xmlw_elemEmpty( writer,
"outfits" );
109 if (spob_hasService( p, SPOB_SERVICE_SHIPYARD ))
110 xmlw_elemEmpty( writer,
"shipyard" );
111 if (spob_hasService( p, SPOB_SERVICE_BLACKMARKET ))
112 xmlw_elemEmpty( writer,
"blackmarket" );
113 if (spob_isFlag( p, SPOB_NOMISNSPAWN ))
114 xmlw_elemEmpty( writer,
"nomissionspawn" );
115 if (spob_isFlag( p, SPOB_UNINHABITED ))
116 xmlw_elemEmpty( writer,
"uninhabited" );
117 xmlw_endElem( writer );
118 if (spob_hasService( p, SPOB_SERVICE_LAND )) {
119 if (p->presence.faction >= 0) {
120 xmlw_startElem( writer,
"commodities" );
121 for (
int i=0; i<
array_size(p->commodities); i++) {
123 if (!commodity_isFlag(
c,COMMODITY_FLAG_STANDARD))
124 xmlw_elem( writer,
"commodity",
"%s",
c->name );
126 xmlw_endElem( writer );
129 xmlw_elem( writer,
"description",
"%s", p->description );
130 if (spob_hasService( p, SPOB_SERVICE_BAR ))
131 xmlw_elem( writer,
"bar",
"%s", p->bar_description );
133 xmlw_endElem( writer );
136 if (spob_hasService( p, SPOB_SERVICE_LAND ))
140 xmlw_startElem( writer,
"tags" );
142 xmlw_elem( writer,
"tag",
"%s", p->tags[i] );
143 xmlw_endElem( writer );
146 xmlw_endElem( writer );
150 xmlFreeTextWriter( writer );
153 cleanName = uniedit_nameFilter( p->name );
155 if (xmlSaveFileEnc( file, doc,
"UTF-8" ) < 0)
156 WARN(
"Failed writing '%s'!", file);
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
int dpl_saveAll(void)
Saves all the star spobs.
int dpl_saveSpob(const Spob *p)
Saves a spob.
const char * faction_name(int f)
Gets a factions "real" (internal) name.
Header file with generic functions and naev-specifics.
int asprintf(char **strp, const char *fmt,...)
Like sprintf(), but it allocates a large-enough string and returns the pointer in the first argument....
void xmlw_setParams(xmlTextWriterPtr writer)
Sets up the standard xml write parameters.
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
const char * start_spob_lua_default(void)
Gets the default spob Lua file.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
int tech_groupWrite(xmlTextWriterPtr writer, tech_group_t *grp)
Writes a group in an xml node.