35 #define SWITCH_CONST (0.9)
48 ( (
Cockpit*) userData )->endElement( name );
66 return (most == -1024) ? 1 : most;
80 using namespace VSFileSystem;
87 if (file == NULL || strlen( file ) == 0) {
91 file =
"disabled-cockpit.cpt";
94 if (isDisabled ==
true) {
95 std::string disname = std::string(
"disabled-" )+
file;
96 Init( disname.c_str() );
103 if ( isDisabled ==
false && (
string( file ).find(
"disabled-" ) == string::npos) )
115 Unit *un = parentturret.GetUnit();
117 un = parent.GetUnit();
126 parent.SetUnit( unit );
127 savegame->SetPlayerLocation( pos );
128 if (filename[0] !=
'\0') {
129 this->GetUnitFileName() = std::string( filename );
130 this->unitmodname = std::string( unitmodname );
133 this->unitfaction = unit->
faction;
135 if (StartArmor[0] == 0) StartArmor[0] = 1;
136 if (StartArmor[1] == 0) StartArmor[1] = 1;
137 if (StartArmor[2] == 0) StartArmor[2] = 1;
138 if (StartArmor[3] == 0) StartArmor[3] = 1;
139 if (StartArmor[4] == 0) StartArmor[4] = 1;
140 if (StartArmor[5] == 0) StartArmor[5] = 1;
141 if (StartArmor[6] == 0) StartArmor[6] = 1;
142 if (StartArmor[7] == 0) StartArmor[7] = 1;
150 viewport_offset = cockpit_offset = 0;
155 godliness = maxgodliness;
156 if (godliness > maxgodliness)
157 godliness = maxgodliness;
167 static float autopilot_term_distance =
169 Unit *targ = autopilot_target.GetUnit();
182 , cockpit_offset( 0 )
183 , viewport_offset( 0 )
185 , savegame( new
SaveGame( pilot_name ) )
285 qq = qq+
QVector( .001, .001, .001 );
295 if ( ( retauto = un->
AutoPilotTo( un,
false ) ) ) {
299 static bool face_target_on_auto =
301 if (face_target_on_auto)
304 static double numave = 1.0;
314 static float initialzoom =
330 bool pointingtool =
false;
331 bool pointingtonw =
false;
339 if ( ol && (!pointingtool) ) {
352 static bool FlyStraightInTurret =
354 if (FlyStraightInTurret) {
364 Unit *un = baseTurret;
397 for (; i != end; ++i) {
398 float tmag = (pos.Cast()-(*i).GetPosition()).
Magnitude()-un->
rSize()-(*i).GetRadius();
415 if (max_attackers == 0)
return;
422 bool isDone = attack_iterator.
isDone();
439 if (attack_iterator.
isDone() ==
false && (un = *attack_iterator) != NULL) {
441 float speed = 0, range = 0, mmrange = 0;
442 if (
parent == targ && targ != NULL) {
445 if (dist <= range*2 || dist <= mmrange)
475 if (shield->
shield8.frontlefttop/howmuch > shield->
shield8.frontlefttopmax)
476 shield->
shield8.frontlefttop = shield->
shield8.frontlefttopmax*howmuch;
477 if (shield->
shield8.frontleftbottom/howmuch > shield->
shield8.frontleftbottommax)
478 shield->
shield8.frontleftbottom = shield->
shield8.frontleftbottommax*howmuch;
479 if (shield->
shield8.frontrighttop/howmuch > shield->
shield8.frontrighttopmax)
480 shield->
shield8.frontrighttop = shield->
shield8.frontrighttopmax*howmuch;
481 if (shield->
shield8.frontrightbottom/howmuch > shield->
shield8.frontrightbottommax)
482 shield->
shield8.frontrightbottom = shield->
shield8.frontrightbottommax*howmuch;
483 if (shield->
shield8.backlefttop/howmuch > shield->
shield8.backlefttopmax)
484 shield->
shield8.backlefttop = shield->
shield8.backlefttopmax*howmuch;
485 if (shield->
shield8.backleftbottom/howmuch > shield->
shield8.backleftbottommax)
486 shield->
shield8.backleftbottom = shield->
shield8.backleftbottommax*howmuch;
487 if (shield->
shield8.backrighttop/howmuch > shield->
shield8.backrighttopmax)
488 shield->
shield8.backrighttop = shield->
shield8.backrighttopmax*howmuch;
489 if (shield->
shield8.backrightbottom/howmuch > shield->
shield8.backrightbottommax)
490 shield->
shield8.backrightbottom = shield->
shield8.backrightbottommax*howmuch;
510 static float minEnergyForShieldDownpower =
512 static float minEnergyShieldTime =
514 static float minEnergyShieldPercent =
517 bool toolittleenergy = (par->
EnergyData() <= minEnergyForShieldDownpower);
518 if (toolittleenergy) {
534 if (par->
name ==
"return_to_cockpit") {
546 static int index = 0;
561 if (un->
name.get().find(
"accessory" ) == string::npos) {
575 if (tmpgot) index = 0;
589 if (autoclear && par) {
592 static float autopilot_term_distance =
596 && doubled < autopilot_term_distance)
608 && (doubled >= autopilot_term_distance) ) ) ) {
620 static float initialzoom =
623 static int index = 0;
625 static bool switch_nonowned_units =
634 if (un->faction == this->unitfaction) {
639 if ( ( ( (par != NULL)
642 && ( switch_nonowned_units
650 && un->
owner) ) && (un->name !=
"eject") && (un->name !=
"Pilot")
657 if (k->
name ==
"eject" || k->
name ==
"Pilot" || k->
name ==
"return_to_cockpit")
662 if ( !(k->
name ==
"return_to_cockpit") )
665 if ( !(k->
name ==
"return_to_cockpit") )
668 if ( !(k->
name ==
"return_to_cockpit") )
715 static float initialzoom =
735 unsigned int whichcp = k;
742 vector< string > packedInfo;
752 if (pos.i == FLT_MAX && pos.j == FLT_MAX && pos.k == FLT_MAX)
756 bool actually_have_save =
false;
757 static bool persistent_on_load =
760 actually_have_save =
true;
764 if (newsystem.find(
".system" ) == string::npos)
765 newsystem +=
".system";
768 {NULL, NULL, NULL, NULL, NULL, NULL, NULL}
770 if (persistent_on_load) {
774 savedtextures = tmp->
Cache();
778 if (!persistent_on_load)
783 vector< StarSystem* >saved;
788 if ( !saved.empty() )
790 unsigned int mysize = saved.size();
791 for (
unsigned int i = 0;
i < mysize;
i++) {
821 if (!persistent_on_load)
833 string key(
string(
"visited_" )+systemname );
837 else if ( (*v)[0] != 1.0 && num == 1 )
844 for (
int i = 0;
i < adj; ++
i)
882 vector< string > filenames, systemnames, basenames;
886 filenames.push_back( info[0] );
887 systemnames.push_back(
"" );
888 basenames.push_back(
"" );
892 for (
size_t i=1, n=info.size();
i < n;
i += 2) {
893 filenames.push_back( info[
i] );
895 string location = ((i+1) < n) ? info[i+1] :
"";
896 string::size_type atpos = location.find_first_of(
'@');
898 systemnames.push_back(location.substr(0, atpos));
899 basenames.push_back((atpos != string::npos) ? location.substr(atpos+1) :
"");
902 unitfilename.swap(filenames);
903 unitsystemname.swap(systemnames);
904 unitbasename.swap(basenames);
911 if ( which >= unitfilename.size() )
914 return unitfilename[which];
919 if ( which >= unitsystemname.size() )
922 return unitsystemname[which];
927 if ( which >= unitbasename.size() )
930 return unitbasename[which];
935 if (which < unitfilename.size())
936 unitfilename.erase(unitfilename.begin()+which);
937 if (which < unitsystemname.size())
938 unitsystemname.erase(unitsystemname.begin()+which);
939 if (which < unitbasename.size())
940 unitbasename.erase(unitbasename.begin()+which);
955 std::replace(name.begin(), name.end(),
' ',
'_');