11 using namespace VSFileSystem;
17 for (
unsigned char i = 0;
i <
sizeof (
int)*8;
i++)
27 static vector< vector< char > >allrolepriority =
buildroles();
28 return allrolepriority;
51 static const std::string empty;
53 vsUMap< int, string >::const_iterator
i =
irolemap.find( c );
61 vector< vector< string > >scripts;
68 char *temp = (
char*) malloc( len+1 );
69 memset( temp, 0, len+1 );
73 vector< string >vec =
readCSV( temp );
77 "FATAL error in hash map... column %u in ai/VegaEvents.csv does not line up with that item in ai/VegaPriorities.csv\n",
78 (
unsigned int) vec.size() );
80 if ( vec.size() ) vec.erase( vec.begin() );
81 for (
unsigned int j = 0;
j < vec.size();
j++)
85 "FATAL error in hash map... column %d in ai/VegaEvents.csv does not line up with that item in ai/VegaPriorities.csv\n",
89 for (i = 0; i < siz; i++) {
90 scripts.push_back( vector< string > () );
91 for (
unsigned int j = 0; j < vec.size(); j++)
92 scripts[i].push_back(
"default" );
94 for (i = 0; i < vec.size(); i++) {
96 vector< string >strs =
readCSV( temp );
98 string front = strs.front();
99 unsigned int scriptind =
getRole( front );
100 while (scripts.size() <= scriptind)
101 scripts.push_back( vector< string > () );
102 for (
unsigned int j = 1; j < strs.size() && j <= vec.size(); j++) {
104 while (scripts[scriptind].
size() <= index)
105 scripts[scriptind].push_back(
"default" );
106 scripts[scriptind][
index] = strs[j];
115 const std::string&
getRoleEvents(
unsigned char ourrole,
unsigned char theirs )
117 static vector< vector< string > >script =
buildscripts();
118 const static string def =
"default";
119 if ( ourrole >= script.size() ) {
123 if ( theirs >= script[ourrole].
size() ) {
127 return script[ourrole][theirs];
131 vector< vector< char > >rolePriorities;
136 char *temp = (
char*) malloc( len+1 );
137 memset( temp, 0, len+1 );
139 vector< string >vec =
readCSV( temp );
141 for (i = 1; i < vec.size(); i++) {
145 vector< vector< char > >tmprolepriorities;
146 vector< string >tmpnamelist;
148 vector< string >priority =
readCSV( temp );
149 if (priority.size() > 0) {
150 tmpnamelist.push_back(
strtoupper( priority[0] ) );
151 tmprolepriorities.push_back( vector< char > () );
152 for (
unsigned int j = 1;
j < priority.size();
j++)
154 while ( tmprolepriorities.back().size() < vec.size() )
155 tmprolepriorities.back().push_back( 31 );
158 for (
int k = 0;
k < 2; ++
k)
159 for (i = 0; i < tmpnamelist.size(); ++i) {
160 vsUMap< string, int >::iterator iter =
rolemap.find( tmpnamelist[i] );
166 for (j = 0; j < (
int) rolePriorities.size(); ++j)
167 if (rolePriorities[j].
size() == 0)
173 while (rolePriorities.size() <= (
unsigned int) j)
174 rolePriorities.push_back( vector< char > () );
175 rolePriorities[j].swap( tmprolepriorities[i] );
178 size_t a = rolePriorities.size();
179 if ( rolePriorities.size() ) {
180 size_t b = rolePriorities[0].size();
182 rolePriorities.push_back( rolePriorities[0] );
186 for (
size_t i = 0; i < rolePriorities.size(); ++i)
187 rolePriorities[i].resize( a );
193 rolePriorities.push_back( vector< char > () );
194 rolePriorities[0].push_back( 0 );
196 return rolePriorities;
209 std::string::size_type loc = string::npos;
213 ans |= ( 1<<
getRole( s.substr( 0, loc ) ) );
214 if (loc != string::npos)
215 s = s.substr( loc+1 );
216 }
while (loc != string::npos);
223 "ESCORTCAP CAPITAL CARRIER BASE TROOP" );
224 unsigned int retval = 0;
225 string inp = defaultcapshipvalues;
226 string::size_type where;
227 while ( ( where = inp.find(
" " ) ) != string::npos ) {
228 string tmp = inp.substr( 0, where );
229 unsigned char logrole =
getRole( tmp );
230 if ( tmp ==
getRole( logrole ) )
231 retval |= (1<<logrole);
232 inp = inp.substr( where+1 );
234 if ( inp.length() ) {
235 unsigned char logrole =
getRole( inp );
236 string tmp =
getRole( logrole );
238 retval |= (1<<logrole);