31 xmlTextWriterPtr writer;
36 if ( conf.dev_data_dir == NULL ) {
37 WARN( _(
"%s is not set!" ),
"conf.dev_data_dir" );
42 writer = xmlNewTextWriterDoc( &doc, 0 );
43 if ( writer == NULL ) {
44 WARN( _(
"testXmlwriterDoc: Error creating the xml writer" ) );
53 xmlw_startElem( writer,
"spob" );
56 xmlw_attr( writer,
"name",
"%s", p->name );
59 if ( p->display != NULL )
60 xmlw_elem( writer,
"display",
"%s", p->display );
61 if ( p->feature != NULL )
62 xmlw_elem( writer,
"feature",
"%s", p->feature );
63 if ( ( p->lua_file != NULL ) &&
64 ( ( lua_default == NULL ) || strcmp( lua_default, p->lua_file ) != 0 ) )
65 xmlw_elem( writer,
"lua",
"%s", p->lua_file_raw );
66 if ( spob_isFlag( p, SPOB_RADIUS ) )
67 xmlw_elem( writer,
"radius",
"%f", p->radius );
68 if ( p->marker != NULL )
69 xmlw_elem( writer,
"marker",
"%s", p->marker->name );
72 xmlw_startElem( writer,
"pos" );
73 xmlw_attr( writer,
"x",
"%f", p->pos.x );
74 xmlw_attr( writer,
"y",
"%f", p->pos.y );
75 xmlw_endElem( writer );
78 xmlw_startElem( writer,
"GFX" );
79 if ( p->gfx_space3dPath != NULL ) {
80 xmlw_startElem( writer,
"space3d" );
81 xmlw_attr( writer,
"size",
"%f", p->gfx_space3d_size );
82 xmlw_str( writer,
"%s", p->gfx_space3dPath );
83 xmlw_endElem( writer );
85 if ( p->gfx_spacePath != NULL )
86 xmlw_elem( writer,
"space",
"%s", p->gfx_spacePath );
87 if ( p->gfx_exteriorPath != NULL )
88 xmlw_elem( writer,
"exterior",
"%s", p->gfx_exteriorPath );
89 if ( p->gfx_commPath != NULL )
90 xmlw_elem( writer,
"comm",
"%s", p->gfx_commPath );
91 xmlw_endElem( writer );
94 if ( p->presence.faction >= 0 ) {
95 xmlw_startElem( writer,
"presence" );
96 xmlw_elem( writer,
"faction",
"%s",
faction_name( p->presence.faction ) );
97 xmlw_elem( writer,
"base",
"%f", p->presence.base );
98 xmlw_elem( writer,
"bonus",
"%f", p->presence.bonus );
99 xmlw_elem( writer,
"range",
"%d", p->presence.range );
100 xmlw_endElem( writer );
104 xmlw_startElem( writer,
"general" );
105 xmlw_elem( writer,
"class",
"%s", p->class );
106 xmlw_elem( writer,
"population",
"%g", (
double)p->population );
107 xmlw_elem( writer,
"hide",
"%f", p->hide );
108 xmlw_startElem( writer,
"services" );
109 if ( spob_hasService( p, SPOB_SERVICE_LAND ) )
110 xmlw_elemEmpty( writer,
"land" );
111 if ( spob_hasService( p, SPOB_SERVICE_REFUEL ) )
112 xmlw_elemEmpty( writer,
"refuel" );
113 if ( spob_hasService( p, SPOB_SERVICE_BAR ) )
114 xmlw_elemEmpty( writer,
"bar" );
115 if ( spob_hasService( p, SPOB_SERVICE_MISSIONS ) )
116 xmlw_elemEmpty( writer,
"missions" );
117 if ( spob_hasService( p, SPOB_SERVICE_COMMODITY ) )
118 xmlw_elemEmpty( writer,
"commodity" );
119 if ( spob_hasService( p, SPOB_SERVICE_OUTFITS ) )
120 xmlw_elemEmpty( writer,
"outfits" );
121 if ( spob_hasService( p, SPOB_SERVICE_SHIPYARD ) )
122 xmlw_elemEmpty( writer,
"shipyard" );
123 if ( spob_hasService( p, SPOB_SERVICE_BLACKMARKET ) )
124 xmlw_elemEmpty( writer,
"blackmarket" );
125 if ( spob_isFlag( p, SPOB_NOMISNSPAWN ) )
126 xmlw_elemEmpty( writer,
"nomissionspawn" );
127 if ( spob_isFlag( p, SPOB_UNINHABITED ) )
128 xmlw_elemEmpty( writer,
"uninhabited" );
129 if ( spob_isFlag( p, SPOB_NOLANES ) )
130 xmlw_elemEmpty( writer,
"nolanes" );
131 xmlw_endElem( writer );
132 if ( spob_hasService( p, SPOB_SERVICE_LAND ) ) {
133 if ( p->presence.faction >= 0 ) {
134 xmlw_startElem( writer,
"commodities" );
135 for (
int i = 0; i <
array_size( p->commodities ); i++ ) {
137 if ( !commodity_isFlag(
c, COMMODITY_FLAG_STANDARD ) )
138 xmlw_elem( writer,
"commodity",
"%s",
c->name );
140 xmlw_endElem( writer );
143 xmlw_elem( writer,
"description",
"%s", p->description );
144 if ( spob_hasService( p, SPOB_SERVICE_BAR ) )
145 xmlw_elem( writer,
"bar",
"%s", p->bar_description );
147 xmlw_endElem( writer );
150 if ( spob_hasService( p, SPOB_SERVICE_LAND ) )
154 xmlw_startElem( writer,
"tags" );
155 for (
int i = 0; i <
array_size( p->tags ); i++ )
156 xmlw_elem( writer,
"tag",
"%s", p->tags[i] );
157 xmlw_endElem( writer );
160 xmlw_endElem( writer );
164 xmlFreeTextWriter( writer );
168 snprintf( path,
sizeof( path ),
"%s", p->filename );
169 const char *filename = basename( path );
170 SDL_asprintf( &file,
"%s/spob/%s", conf.dev_data_dir, filename );
171 if ( xmlSaveFileEnc( file, doc,
"UTF-8" ) < 0 ) {
172 WARN(
"Failed to write '%s'!", file );