13 using namespace XMLSupport;
95 using namespace FactionXML;
98 AttributeList::const_iterator iter;
100 std::string secString;
101 std::string secStringAlph;
114 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
119 factions.back()->explosion_name.push_back( (*iter).value );
130 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
134 name = (*iter).value;
141 if ( rel != 0 && name.length() )
142 factions.back()->ship_relation_modifier[name] = rel;
149 factions.back()->comm_face_sex.push_back( 0 );
150 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
157 factions.back()->comm_faces.back().dockable =
158 parse_bool( (*iter).value ) ? comm_face_t::CYES : comm_face_t::CNO;
162 factions.back()->comm_faces.back().base =
parse_bool( (*iter).value ) ? comm_face_t::CYES : comm_face_t::CNO;
170 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
186 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
202 factions[
factions.size()-1]->factionname =
new char[strlen( (*iter).value.c_str() )+1];
240 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
247 new char[strlen( (*iter).value.c_str() )+1];
250 (*iter).value.c_str() );
259 -1]->faction[
factions[
factions.size()-1]->faction.size()-1].conversation.reset(
new FSM( (*iter).value ));
271 using namespace FactionXML;
286 using namespace FactionXML;
287 using namespace VSFileSystem;
294 if (buflength == 0 || xmlbuffer == NULL) {
295 cout<<
"FactionXML:LoadXML "<<filename<<endl;
298 cout<<
"Failed to open '"<<filename<<
"' this probably means it can't find the data directory"<<endl;
302 XML_Parser parser = XML_ParserCreate( NULL );
303 XML_SetUserData( parser, NULL );
305 if (buflength != 0 && xmlbuffer != NULL)
306 XML_Parse( parser, xmlbuffer, buflength, 1 );
308 XML_Parse( parser, (
f.ReadFull() ).c_str(),
f.Size(), 1 );
309 XML_ParserFree( parser );
313 typedef vsUMap< string, boost::shared_ptr<FSM> > Cache;
316 std::string fileSuffix(
".xml");
317 std::string neutralName(
"neutral");
318 boost::shared_ptr<FSM> neutralComm;
319 neutralComm.reset(
new FSM(neutralName + fileSuffix));
320 cache.insert(Cache::value_type(neutralName, neutralComm));
324 boost::shared_ptr<Faction> fact =
factions[
i];
325 std::string myCommFile = fact->factionname + fileSuffix;
326 boost::shared_ptr<FSM> myComm;
327 Cache::iterator it = cache.find(myCommFile);
328 if ( it != cache.end() )
336 myComm.reset(
new FSM(myCommFile));
342 cache.insert(Cache::value_type(myCommFile, myComm));
345 for (
unsigned int j = 0;
j <
factions[
i]->faction.size();
j++)
347 std::string jointCommFile = fact->factionname
351 boost::shared_ptr<FSM> jointComm;
352 if (!fact->faction[
j].conversation)
354 it = cache.find(jointCommFile);
355 if ( it != cache.end() )
357 jointComm = it->second;
363 jointComm.reset(
new FSM(jointCommFile));
369 cache.insert(Cache::value_type(jointCommFile, jointComm));
371 factions[
i]->faction[
j].conversation = jointComm
373 : (myComm ? myComm : neutralComm);