34 xmlTextWriterPtr writer;
35 char *file, *cleanName;
40 writer = xmlNewTextWriterDoc(&doc, 0);
42 WARN(_(
"testXmlwriterDoc: Error creating the xml writer"));
51 xmlw_startElem( writer,
"spob" );
54 xmlw_attr( writer,
"name",
"%s", p->name );
58 xmlw_elem( writer,
"display",
"%s", p->display );
60 xmlw_elem( writer,
"feature",
"%s", p->feature );
61 if ((p->lua_file!=NULL) && ((lua_default==NULL) || strcmp(lua_default,p->lua_file)!=0))
62 xmlw_elem( writer,
"lua",
"%s", p->lua_file );
63 if (spob_isFlag(p,SPOB_RADIUS))
64 xmlw_elem( writer,
"radius",
"%f", p->radius );
65 if (p->marker != NULL)
66 xmlw_elem( writer,
"marker",
"%s", p->marker->name );
69 xmlw_startElem( writer,
"pos" );
70 xmlw_attr( writer,
"x",
"%f", p->pos.x );
71 xmlw_attr( writer,
"y",
"%f", p->pos.y );
72 xmlw_endElem( writer );
75 xmlw_startElem( writer,
"GFX" );
76 if (p->gfx_spacePath != NULL)
77 xmlw_elem( writer,
"space",
"%s", p->gfx_spacePath );
78 if (p->gfx_exteriorPath != NULL)
79 xmlw_elem( writer,
"exterior",
"%s", p->gfx_exteriorPath );
80 if (p->gfx_commPath != NULL)
81 xmlw_elem( writer,
"comm",
"%s", p->gfx_commPath );
82 xmlw_endElem( writer );
85 if (p->presence.faction >= 0) {
86 xmlw_startElem( writer,
"presence" );
87 xmlw_elem( writer,
"faction",
"%s",
faction_name( p->presence.faction ) );
88 xmlw_elem( writer,
"base",
"%f", p->presence.base );
89 xmlw_elem( writer,
"bonus",
"%f", p->presence.bonus );
90 xmlw_elem( writer,
"range",
"%d", p->presence.range );
91 xmlw_endElem( writer );
95 xmlw_startElem( writer,
"general" );
96 xmlw_elem( writer,
"class",
"%s", p->class );
97 xmlw_elem( writer,
"population",
"%g", (
double)p->population );
98 xmlw_elem( writer,
"hide",
"%f", p->hide );
99 xmlw_startElem( writer,
"services" );
100 if (spob_hasService( p, SPOB_SERVICE_LAND ))
101 xmlw_elemEmpty( writer,
"land" );
102 if (spob_hasService( p, SPOB_SERVICE_REFUEL ))
103 xmlw_elemEmpty( writer,
"refuel" );
104 if (spob_hasService( p, SPOB_SERVICE_BAR ))
105 xmlw_elemEmpty( writer,
"bar" );
106 if (spob_hasService( p, SPOB_SERVICE_MISSIONS ))
107 xmlw_elemEmpty( writer,
"missions" );
108 if (spob_hasService( p, SPOB_SERVICE_COMMODITY ))
109 xmlw_elemEmpty( writer,
"commodity" );
110 if (spob_hasService( p, SPOB_SERVICE_OUTFITS ))
111 xmlw_elemEmpty( writer,
"outfits" );
112 if (spob_hasService( p, SPOB_SERVICE_SHIPYARD ))
113 xmlw_elemEmpty( writer,
"shipyard" );
114 if (spob_hasService( p, SPOB_SERVICE_BLACKMARKET ))
115 xmlw_elemEmpty( writer,
"blackmarket" );
116 if (spob_isFlag( p, SPOB_NOMISNSPAWN ))
117 xmlw_elemEmpty( writer,
"nomissionspawn" );
118 if (spob_isFlag( p, SPOB_UNINHABITED ))
119 xmlw_elemEmpty( writer,
"uninhabited" );
120 if (spob_isFlag( p, SPOB_NOLANES ))
121 xmlw_elemEmpty( writer,
"nolanes" );
122 xmlw_endElem( writer );
123 if (spob_hasService( p, SPOB_SERVICE_LAND )) {
124 if (p->presence.faction >= 0) {
125 xmlw_startElem( writer,
"commodities" );
126 for (
int i=0; i<
array_size(p->commodities); i++) {
128 if (!commodity_isFlag(
c,COMMODITY_FLAG_STANDARD))
129 xmlw_elem( writer,
"commodity",
"%s",
c->name );
131 xmlw_endElem( writer );
134 xmlw_elem( writer,
"description",
"%s", p->description );
135 if (spob_hasService( p, SPOB_SERVICE_BAR ))
136 xmlw_elem( writer,
"bar",
"%s", p->bar_description );
138 xmlw_endElem( writer );
141 if (spob_hasService( p, SPOB_SERVICE_LAND ))
145 xmlw_startElem( writer,
"tags" );
147 xmlw_elem( writer,
"tag",
"%s", p->tags[i] );
148 xmlw_endElem( writer );
151 xmlw_endElem( writer );
155 xmlFreeTextWriter( writer );
158 cleanName = uniedit_nameFilter( p->name );
159 SDL_asprintf( &file,
"%s/%s.xml", conf.
dev_save_spob, cleanName );
160 if (xmlSaveFileEnc( file, doc,
"UTF-8" ) < 0) {
161 WARN(
"Failed to write '%s'!", file);
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...