25 #define VS_PI (3.1415926536)
33 std::string::size_type text = 0;
34 while ( ( text = inp.find(
".000000", text ) ) != string::npos )
35 inp = inp.substr( 0, text )+inp.substr( text+7 );
43 writestr +=
"Name: "+un->
name;
50 static std::set< string >lookfor;
51 if ( lookfor.empty() ) {
52 lookfor.insert(
"Shie" );
53 lookfor.insert(
"Armo" );
55 lookfor.insert(
"Reac" );
56 lookfor.insert(
"Moun" );
57 lookfor.insert(
"Comp" );
59 lookfor.insert(
"Engi" );
60 lookfor.insert(
"Mane" );
61 lookfor.insert(
"Jump" );
63 lookfor.insert(
"Stat" );
64 lookfor.insert(
"Engi" );
66 lookfor.insert(
"Rada" );
68 std::string::size_type foundpos;
69 while ( ( foundpos = str.find(
"<" ) ) != string::npos ) {
70 if (str.size() <= foundpos+1)
72 str = str.substr( foundpos+1 );
74 char mycomp[5] = {str[0], str[1], str[2], str[3], 0};
75 if ( lookfor.find( mycomp ) != lookfor.end() ) {
76 int newline = str.find(
">" );
78 if (str[newline-1] ==
'/')
89 if (strlen( input_buffer ) > 3) {
90 if (input_buffer[0] ==
'a'
91 && input_buffer[1] ==
'd'
92 && input_buffer[2] ==
'd')
94 if (input_buffer[0] ==
'm'
95 && input_buffer[1] ==
'u'
96 && input_buffer[2] ==
'l')
111 ( (
Unit*) userData )->endElement( name );
438 unsigned char uc = (*input.
w.
uc)/jumpdelaymult;
445 std::vector< Mesh* >
MakeMesh(
unsigned int mysize )
447 std::vector< Mesh* >temp;
448 for (
unsigned int i = 0;
i < mysize;
i++)
449 temp.push_back( NULL );
470 float &randomstartframe,
471 float &randomstartseconds,
472 const char *filename,
477 double texturestarttime )
480 for (
unsigned int i = 0;
i < m.size(); ++
i) {
481 meshes.push_back( m[
i] );
482 if (startframe >= 0) {
483 meshes.back()->setCurrentFrame( startframe );
484 }
else if (startframe == -2) {
485 float r = ( (
float) rand() )/RAND_MAX;
486 meshes.back()->setCurrentFrame( r*meshes.back()->getFramesPerSecond() );
487 }
else if (startframe == -1) {
488 if (randomstartseconds == 0)
489 randomstartseconds = randomstartframe*meshes.back()->getNumLOD()/meshes.back()->getFramesPerSecond();
490 meshes.back()->setCurrentFrame( randomstartseconds*meshes.back()->getFramesPerSecond() );
492 if (texturestarttime > 0) {
493 meshes.back()->setTextureCumulativeTime( texturestarttime );
495 float fps = meshes.back()->getTextureFramesPerSecond();
496 int frames = meshes.back()->getNumTextureFrames();
497 double ran = randomstartframe;
498 if (fps > 0 && frames > 1) {
503 meshes.back()->setTextureCumulativeTime( ran );
510 return new Mount( name.c_str(), ammo,
volume, xyscale, zscale, 1, 1, banked );
523 return (
unsigned int) ( ( (
x) > 4294967295.0 ) ? (
unsigned int) 4294967295U : ( (x) < 0 ? 0 : (
x) ) );
526 #define ADDTAGNAME( a ) do {pImage->unitwriter->AddTag( a );} \
528 #define ADDTAG do {pImage->unitwriter->AddTag( name );} \
530 #define ADDELEMNAME( a, b, c ) do {pImage->unitwriter->AddElement( a, b, c );} \
532 #define ADDELEM( b, c ) do {pImage->unitwriter->AddElement( (*iter).name, b, c );} \
534 #define ADDDEFAULT do {pImage->unitwriter->AddElement( (*iter).name, stringHandler, XMLType( (*iter).value ) );} \
536 #define ADDELEMI( b ) do {ADDELEM( intStarHandler, XMLType( &b ) );} \
538 #define ADDELEMF( b ) do {ADDELEM( floatStarHandler, XMLType( &b ) );} \
543 using namespace UnitXML;
558 unsigned int dirfrac = 0;
559 float fbrltb[6] = {-1};
560 AttributeList::const_iterator iter;
572 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
590 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
609 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
626 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
630 carg.quantity =
parse_int( (*iter).value );
649 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
663 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
667 carg.quantity =
parse_int( (*iter).value );
685 carg.description = strdup( (*iter).value.c_str() );
694 std::string
file =
"box.bfxm";
696 double texturestarttime = 0;
700 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
705 file = (*iter).value;
710 else if (
strtoupper( (*iter).value ) ==
"ASYNC")
717 texturestarttime = -1;
741 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
769 Q =
QVector( FLT_MAX, FLT_MAX, FLT_MAX );
770 R =
QVector( FLT_MAX, FLT_MAX, FLT_MAX );
771 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
821 if (Q.i == FLT_MAX || Q.j == FLT_MAX || Q.k == FLT_MAX ||
R.i == FLT_MAX ||
R.j == FLT_MAX ||
R.k == FLT_MAX) {
838 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
843 light_type = (*iter).value;
891 halocolor[3] ), light_type, act_speed );
902 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
954 if ( fabs( Q.i ) == fabs(
R.i ) && fabs( Q.j ) == fabs(
R.j ) && fabs( Q.k ) == fabs(
R.k ) ) {
960 CrossProduct( Q,
R, P );
961 CrossProduct(
R, P, Q );
967 xml->
mountz[indx]->SetMountPosition( pos.Cast() );
982 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1032 if (
xml->
units.back()->name ==
"LOAD_FAILED") {
1034 xml->
units.back()->limits.pitch = 0;
1035 xml->
units.back()->limits.roll = 0;
1037 xml->
units.back()->limits.afterburn = 0.0;
1039 xml->
units.back()->SetRecursiveOwner(
this );
1040 xml->
units[indx]->SetOrientation( Q,
R );
1042 xml->
units[indx]->prev_physical_state =
xml->
units[indx]->curr_physical_state;
1043 xml->
units[indx]->SetPosition( pos );
1044 xml->
units[indx]->limits.structurelimits =
R.Cast();
1045 xml->
units[indx]->limits.limitmin = fbrltb[0];
1047 if (
xml->
units[indx]->pImage->unitwriter != NULL)
1053 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1064 float minfreq = 0, maxfreq = 0;
1065 bool video =
false, secured =
false;
1069 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1085 method = (*iter).value;
1093 static float insys_jump_cost =
1095 bool foundinsysenergy =
false;
1100 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1111 if (!foundinsysenergy)
1117 foundinsysenergy =
true;
1128 static int jumpdelaymult =
1151 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1245 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1279 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1350 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1422 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1442 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1462 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1480 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1513 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1560 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1592 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1612 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1632 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1649 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1678 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1695 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1713 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1738 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1742 if ( (*iter).value.length() ) {
1748 if ( (*iter).value.length() ) {
1775 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
1794 for (iter = attributes.begin(); iter != attributes.end(); iter++)
1811 using namespace UnitXML;
1825 using namespace VSFileSystem;
1854 for (i = 0; i <= (UnitImages< void >::NUMGAUGES+
MAXVDUS); i++) {
1955 XML_Parser parser = XML_ParserCreate( NULL );
1956 XML_SetUserData( parser,
this );
1958 if (xmlbuffer != NULL)
1959 XML_Parse( parser, xmlbuffer->c_str(), xmlbuffer->length(), 1 );
1961 XML_Parse( parser, ( f.
ReadFull() ).c_str(), f.
Size(), 1 );
1962 XML_ParserFree( parser );
1974 for (a = 0; a <
xml->
mountz.size(); a++)
1977 unsigned char parity = 0;
1978 for (a = 0; a <
xml->
mountz.size(); a++) {
1980 if (a%2 == parity) {
1993 for (a = 0; a <
xml->
units.size(); a++)
1998 vector< mesh_polygon >polies;
2007 meshdata.back()->GetPolys( polies );
2014 static std::string shieldtex =
vs_config->
getVariable(
"graphics",
"shield_texture",
"shield.bmp" );
2015 static std::string shieldtechnique =
vs_config->
getVariable(
"graphics",
"shield_technique",
"" );
2019 meshdata.back()->EnableSpecialFX();
2035 unsigned int which = 1<<i;
2047 vector< mesh_polygon >polies;
2053 if (scale.i != 1 || scale.j != 1 || scale.k != 1) {
2054 for (vector< mesh_polygon >::iterator i = polies.begin(); i != polies.end(); ++i)
2055 for (
unsigned int j = 0;
j < i->v.size(); ++
j) {
2056 i->v[
j].i *= scale.i;
2057 i->v[
j].j *= scale.j;
2058 i->v[
j].k *= scale.k;