28 float timeuntilinterrupts,
30 const std::string &aiscript )
44 for (
int i = 0;
i < 10; ++
i) {
45 printf(
"SERIOUS WARNING %s\n", this->
script.c_str() );
46 fprintf( stderr,
"SERIOUS WARNING: %s\n", this->
script.c_str() );
50 "SERIOUS WARNING in AI script: no fast method to perform %s when type %d is at least %f and at most %f with priority %f for %f time\n",
85 string aiscriptname(
"" );
89 float timetofinish = eam->
maxtime;
90 float timetointerrupt = 0;
92 AttributeList::const_iterator iter;
96 eam->
result.push_back( std::list< AIEvresult > () );
97 eam->
result.push_back( std::list< AIEvresult > () );
98 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
109 assert( eam->
level != 1 && eam->
result.size() >= 2 );
112 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
125 aiscriptname = (*iter).value;
140 AIEvresult newelem( elem, min, max, timetofinish, timetointerrupt, priority, aiscriptname );
141 eam->
result.back().push_back( newelem );
150 if (eam->
result.back().size() == 0) {
152 assert( eam->
level == 0 );
154 eam->
result.back().pop_back();
161 using namespace VSFileSystem;
170 err =
f.OpenReadOnly( filename,
AiFile );
172 printf(
"ai file %s not found\n", filename );
173 string full_filename = filename;
174 full_filename = full_filename.substr( 0, strlen( filename )-4 );
175 string::size_type where = full_filename.find_last_of(
"." );
176 string type =
".agg.xml";
177 if (where != string::npos) {
178 type = full_filename.substr( where );
179 full_filename = full_filename.substr( 0, where )+
".agg.xml";
180 err =
f.OpenReadOnly( full_filename,
AiFile );
183 printf(
"ai file %s again not found\n", full_filename.c_str() );
184 full_filename =
"default";
185 full_filename += type;
186 err =
f.OpenReadOnly( full_filename,
AiFile );
189 printf(
"ai file again %s again not found\n", full_filename.c_str() );
190 err =
f.OpenReadOnly(
"default.agg.xml",
AiFile );
192 fprintf( stderr,
"ai file again default.agg.xml again not found\n" );
197 XML_Parser parser = XML_ParserCreate( NULL );
198 XML_SetUserData( parser, &result );
200 XML_Parse( parser, (
f.ReadFull() ).c_str(),
f.Size(), 1 );
202 XML_ParserFree( parser );
203 if (result.
level != 0)
204 fprintf( stderr,
"Error loading AI script %s for faction %s. Final count not zero.\n", filename, faction.c_str() );