Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
main_loop.cpp File Reference
#include <stdlib.h>
#include <fenv.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "lin_time.h"
#include "cmd/unit.h"
#include "cmd/unit_factory.h"
#include "vegastrike.h"
#include "vs_globals.h"
#include "in.h"
#include "gfx/mesh.h"
#include "gfx/sprite.h"
#include "physics.h"
#include "gfxlib.h"
#include "cmd/bolt.h"
#include "gfx/loc_select.h"
#include <string>
#include "cmd/collection.h"
#include "star_system.h"
#include "cmd/planet.h"
#include "gfx/sphere.h"
#include "gfx/coord_select.h"
#include "cmd/building.h"
#include "cmd/ai/fire.h"
#include "cmd/ai/aggressive.h"
#include "cmd/ai/navigation.h"
#include "cmd/beam.h"
#include "gfx/halo.h"
#include "gfx/matrix.h"
#include "cmd/ai/flyjoystick.h"
#include "cmd/ai/firekeyboard.h"
#include "cmd/ai/script.h"
#include "gfx/cockpit.h"
#include "gfx/aux_texture.h"
#include "gfx/background.h"
#include "cmd/music.h"
#include "main_loop.h"
#include "audiolib.h"
#include "cmd/nebula.h"
#include "vsfilesystem.h"
#include "cmd/script/mission.h"
#include "xml_support.h"
#include "config_xml.h"
#include "cmd/ai/missionscript.h"
#include "cmd/enhancement.h"
#include "cmd/cont_terrain.h"
#include "cmd/script/flightgroup.h"
#include "force_feedback.h"
#include "universe_util.h"
#include "networking/netclient.h"
#include "save_util.h"
#include "in_kb_data.h"
#include "vs_random.h"
#include "options.h"
#include "audio/SceneManager.h"
#include "gldrv/gl_globals.h"

Go to the source code of this file.

Namespaces

 CockpitKeys
 

Constant Groups

 CockpitKeys
 

Macros

#define KEYDOWN(name, key)   (name[key]&0x80)
 

Functions

int shiftup (int)
 
string getUnitNameAndFgNoBase (Unit *target)
 
void VolUp (const KBData &, KBSTATE newState)
 
void VolDown (const KBData &, KBSTATE newState)
 
static void SwitchVDUTo (VDU::VDU_MODE v)
 
void ExamineWhenTargetKey ()
 
void CockpitKeys::TextMessageCallback (unsigned int ch, unsigned int mod, bool release, int x, int y)
 
void CockpitKeys::TextMessageKey (const KBData &, KBSTATE newState)
 
void CockpitKeys::QuitNow ()
 
void CockpitKeys::SkipMusicTrack (const KBData &, KBSTATE newState)
 
static void CockpitKeys::_PitchDown (KBSTATE newState, int fromCam=0, int toCam=NUM_CAM-1)
 
static void CockpitKeys::_PitchUp (KBSTATE newState, int fromCam=0, int toCam=NUM_CAM-1)
 
static void CockpitKeys::_YawLeft (KBSTATE newState, int fromCam=0, int toCam=NUM_CAM-1)
 
static void CockpitKeys::_YawRight (KBSTATE newState, int fromCam=0, int toCam=NUM_CAM-1)
 
void CockpitKeys::PitchDown (const KBData &, KBSTATE newState)
 
void CockpitKeys::PitchUp (const KBData &, KBSTATE newState)
 
void CockpitKeys::YawLeft (const KBData &, KBSTATE newState)
 
void CockpitKeys::YawRight (const KBData &, KBSTATE newState)
 
static void CockpitKeys::InitPanInside ()
 
void CockpitKeys::LookDown (const KBData &kbdata, KBSTATE newState)
 
void CockpitKeys::LookUp (const KBData &kbdata, KBSTATE newState)
 
void CockpitKeys::LookLeft (const KBData &kbdata, KBSTATE newState)
 
void CockpitKeys::LookRight (const KBData &kbdata, KBSTATE newState)
 
void CockpitKeys::Quit (const KBData &, KBSTATE newState)
 
void CockpitKeys::Inside (const KBData &, KBSTATE newState)
 
void CockpitKeys::ZoomOut (const KBData &, KBSTATE newState)
 
void CockpitKeys::ScrollUp (const KBData &, KBSTATE newState)
 
void CockpitKeys::ScrollDown (const KBData &, KBSTATE newState)
 
void CockpitKeys::ZoomIn (const KBData &, KBSTATE newState)
 
void CockpitKeys::ZoomReset (const KBData &, KBSTATE newState)
 
void CockpitKeys::InsideLeft (const KBData &, KBSTATE newState)
 
void CockpitKeys::InsideRight (const KBData &, KBSTATE newState)
 
void CockpitKeys::PanTarget (const KBData &, KBSTATE newState)
 
void CockpitKeys::ViewTarget (const KBData &, KBSTATE newState)
 
void CockpitKeys::OutsideTarget (const KBData &, KBSTATE newState)
 
void CockpitKeys::InsideBack (const KBData &, KBSTATE newState)
 
void CockpitKeys::CommModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::ScanningModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::ObjectiveModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::TargetModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::ViewModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::DamageModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::ManifestModeVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::GunModeVDU (const KBData &s, KBSTATE newState)
 
void CockpitKeys::ReverseGunModeVDU (const KBData &s, KBSTATE newState)
 
void CockpitKeys::MissileModeVDU (const KBData &s, KBSTATE newState)
 
void CockpitKeys::ReverseMissileModeVDU (const KBData &s, KBSTATE newState)
 
void CockpitKeys::SwitchLVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::SwitchRVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::SwitchMVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::SwitchULVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::SwitchURVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::SwitchUMVDU (const KBData &, KBSTATE newState)
 
void CockpitKeys::Behind (const KBData &, KBSTATE newState)
 
void CockpitKeys::Pan (const KBData &, KBSTATE newState)
 
void InitializeInput ()
 
void IncrementStartupVariable ()
 
void createObjects (std::vector< std::string > &fighter0name, std::vector< StarSystem * > &ssys, std::vector< QVector > &savedloc, vector< vector< std::string > > &savefiles)
 
void AddUnitToSystem (const SavedUnits *su)
 
void destroyObjects ()
 
int getmicrosleep ()
 
void restore_main_loop ()
 
void main_loop ()
 

Variables

vs_options game_options
 
std::string global_username
 
static Texturetmpcockpittexture
 
Unit ** fighters
 
Unitcarrier = NULL
 
Unitfighter = NULL
 
Unitfighter2 = NULL
 
Unitmidway = NULL
 
GFXBOOL capture
 
GFXBOOL quit = GFXFALSE
 
bool _Slew = true
 
bool QuitAllow = false
 
bool cleanexit
 
int allexcept = FE_DIVBYZERO
 
ContinuousTerrainmyterrain
 
int numf = 0
 
CoordinateSelectlocSel = NULL
 
SphereMeshbg2 = NULL
 
ClickListshipList = NULL
 
unsigned int CockpitKeys::textmessager = 0
 
static bool CockpitKeys::waszero = false
 
static float CockpitKeys::scrolltime = 0
 

Macro Definition Documentation

#define KEYDOWN (   name,
  key 
)    (name[key]&0x80)

Definition at line 71 of file main_loop.cpp.

Function Documentation

void AddUnitToSystem ( const SavedUnits su)

Definition at line 954 of file main_loop.cpp.

References _Universe, Universe::AccessCockpit(), Universe::activeStarSystem(), StarSystem::AddUnit(), UnitFactory::createEnhancement(), UnitFactory::createUnit(), ENHANCEMENTPTR, Unit::EnqueueAI(), SavedUnits::faction, SavedUnits::filename, FactionUtil::GetFactionIndex(), Cockpit::GetParent(), Unit::Position(), QVector, Unit::SetPosition(), Unit::SetTurretAI(), SavedUnits::type, and UNITPTR.

Referenced by bootstrap_main_loop().

955 {
956  Unit *un = NULL;
957  switch (su->type)
958  {
959  case ENHANCEMENTPTR:
960  un =
961  UnitFactory::createEnhancement( su->filename.get().c_str(), FactionUtil::GetFactionIndex( su->faction ), string( "" ) );
962  un->SetPosition( QVector( 0, 0, 0 ) );
963  break;
964  case UNITPTR:
965  default:
966  un = UnitFactory::createUnit( su->filename.get().c_str(), false, FactionUtil::GetFactionIndex( su->faction ) );
967  un->EnqueueAI( new Orders::AggressiveAI( "default.agg.xml" ) );
968  un->SetTurretAI();
969  if ( _Universe->AccessCockpit()->GetParent() )
971  +QVector( rand()*10000./RAND_MAX-5000, rand()*10000./RAND_MAX-5000, rand()*10000./RAND_MAX-5000 ) );
972  break;
973  }
975 }
void createObjects ( std::vector< std::string > &  fighter0name,
std::vector< StarSystem * > &  ssys,
std::vector< QVector > &  savedloc,
vector< vector< std::string > > &  savefiles 
)

Definition at line 737 of file main_loop.cpp.

References _Universe, a, Universe::AccessCockpit(), Cockpit::activeStarSystem, Universe::activeStarSystem(), StarSystem::AddUnit(), Flightgroup::ainame, AUDListenerSize(), benchmark, BindKey(), UnitFactory::createBuilding(), UnitCollection::createIterator(), UnitFactory::createUnit(), Mission::DirectorInitgame(), Unit::DisableTurretAI(), Unit::EnqueueAI(), Flightgroup::faction, Unit::faction, Mission::flightgroups, fprintf, vs_options::getCallsign(), NetClient::getCallsign(), StarSystem::getClickList(), StarSystem::getContTerrain(), Unit::GetDestinations(), FactionUtil::GetFactionIndex(), SaveGame::getMissionStringData(), Mission::GetOrigin(), SaveGame::GetPlayerFaction(), StarSystem::getTerrain(), Mission::getVariable(), GFXEnable(), global_username, StarSystem::gravitationalUnits(), i, Identity(), IncrementStartupVariable(), Cockpit::Init(), Unit::isUnit(), Unit::LoadAIScript(), FactionUtil::LoadFactionPlaylists(), Unit::LocalPosition(), vs_options::mass, mission, CoordinateSelect::MouseMoveHandle(), muzak, muzak_count, Flightgroup::name, Network, Flightgroup::nr_ships, Mission::number_of_ships, StarSystem::numContTerrain(), numf, StarSystem::numTerrain(), PLANETPTR, Universe::popActiveStarSystem(), Flightgroup::pos, Universe::pushActiveStarSystem(), QVector, vs_options::radius, Unit::rSize(), UniverseUtil::SafeEntrancePoint(), Cockpit::savegame, ScaleMatrix(), Universe::SetActiveCockpit(), Unit::SetNetworkMode(), Cockpit::SetParent(), SaveGame::SetPlayerLocation(), Unit::SetPosAndCumPos(), Unit::SetSerial(), ContinuousTerrain::SetTransformation(), Terrain::SetTransformation(), Unit::SetTurretAI(), NetClient::setUnit(), TEXTURE0, TEXTURE1, Flightgroup::type, VSRandom::uniformExc(), UpdateTime(), Vector, vsrandom, vs_options::xscale, vs_options::yscale, and vs_options::zscale.

741 {
742  vector< std::string >fighter0mods;
743  vector< int > fighter0indices;
744 
746 
747  myterrain = NULL;
748  std::string stdstr = mission->getVariable( "terrain", "" );
749  if (stdstr.length() > 0) {
750  Terrain *terr = new Terrain( stdstr.c_str(), TerrainScale, game_options.mass, game_options.radius );
751  Matrix tmp;
752  ScaleMatrix( tmp, TerrainScale );
753  QVector pos;
754  mission->GetOrigin( pos, stdstr );
755  tmp.p = -pos;
756  terr->SetTransformation( tmp );
757  }
758  stdstr = mission->getVariable( "continuousterrain", "" );
759  if (stdstr.length() > 0) {
760  myterrain = new ContinuousTerrain( stdstr.c_str(), TerrainScale, game_options.mass );
761  Matrix tmp;
762  Identity( tmp );
763  QVector pos;
764  mission->GetOrigin( pos, stdstr );
765  tmp.p = -pos;
767  }
769 
771 
772  fighters = new Unit*[numf];
773  int *tmptarget = new int[numf];
774 
775  GFXEnable( TEXTURE0 );
776  GFXEnable( TEXTURE1 );
777 
778  vsUMap< string, int >targetmap;
779 
780  char fightername[1024] = "hornet.xunit";
781  int a = 0;
782 
783  vector< Flightgroup* >::const_iterator siter;
784  vector< Flightgroup* >fg = mission->flightgroups;
785  int squadnum = 0;
786  for (siter = fg.begin(); siter != fg.end(); siter++) {
787  Flightgroup *fg = *siter;
788  string fg_name = fg->name;
789  string fullname = fg->type; //+ ".xunit";
790  strcpy( fightername, fullname.c_str() );
791  string ainame = fg->ainame;
792  float fg_radius = 0.0;
793  Cockpit *cp = NULL;
794  for (int s = 0; s < fg->nr_ships; s++) {
795  if (a >= mission->number_of_ships) {
796  a -= 22;
797  printf( "Error: in createObjects: more ships in flightgroups than in total for mission!\n"
798  "Variables a=%d, fg-number-of-ships=%d, total nr=%d, fact=%s, fgname=%s\n",
799  a, fg->nr_ships, mission->number_of_ships, fg->faction.c_str(), fg->name.c_str() );
800  break;
801  }
802  numf++;
803  QVector pox( 1000+150*a, 100*a, 100 );
804 
805  pox.i = fg->pos.i+s*fg_radius*3;
806  pox.j = fg->pos.j+s*fg_radius*3;
807  pox.k = fg->pos.k+s*fg_radius*3;
808  if (pox.i == pox.j && pox.j == pox.k && pox.k == 0) {
809  pox.i = rand()*10000./RAND_MAX-5000;
810  pox.j = rand()*10000./RAND_MAX-5000;
811  pox.k = rand()*10000./RAND_MAX-5000;
812  }
813  tmptarget[a] = FactionUtil::GetFactionIndex( fg->faction ); //that should not be in xml?
814  int fg_terrain = -1;
815  if ( fg_terrain == -1 || (fg_terrain == -2 && myterrain == NULL) ) {
816  string modifications( "" );
817  if ( s == 0 && squadnum < (int) fighter0name.size() ) {
818  cp = _Universe->AccessCockpit( squadnum );
819  cp->activeStarSystem = ssys[squadnum];
820  fighter0indices.push_back( a );
821  if (fighter0name[squadnum].length() == 0)
822  fighter0name[squadnum] = string( fightername );
823  else
824  strcpy( fightername, fighter0name[squadnum].c_str() );
825  if (mission->getVariable( "savegame", "" ).length() > 0) {
826  if (savedloc[squadnum].i != FLT_MAX)
827  pox = UniverseUtil::SafeEntrancePoint( savedloc[squadnum] );
828  vector< std::string > *dat = &cp->savegame->getMissionStringData( "jump_from" );
829  if ( dat->size() ) {
830  std::string srcsys = (*dat)[0];
831  Unit *grav;
833  (grav = *ui) != NULL;
834  ++ui) {
835  size_t siz = grav->GetDestinations().size();
836  for (unsigned int i = 0; i < siz; ++i)
837  if (srcsys == grav->GetDestinations()[i]) {
838  QVector newpos = grav->LocalPosition()
839  +QVector( vsrandom.uniformExc( -grav->rSize()/4, grav->rSize()/4 ),
840  vsrandom.uniformExc( -grav->rSize()/4,
841  grav->rSize()/4 ),
842  vsrandom.uniformExc( -grav->rSize()/4,
843  grav->rSize()/4 ) );
844  if (grav->isUnit() != PLANETPTR)
845  newpos = UniverseUtil::SafeEntrancePoint( newpos );
846  cp->savegame->SetPlayerLocation( newpos );
847  pox = newpos;
848  }
849  }
850  dat->clear();
851  }
852  fighter0mods.push_back( modifications = game_options.getCallsign( squadnum ) );
853  if ( squadnum == 0 && global_username.length() ) {
854  fighter0mods.back() = global_username;
855  modifications = global_username;
856  }
857  fprintf( stderr, "FOUND MODIFICATION = %s FOR PLAYER #%d\n", modifications.c_str(), squadnum );
858  } else {
859  fighter0mods.push_back( "" );
860  }
861  }
862  Cockpit *backupcp = _Universe->AccessCockpit();
863  if ( squadnum < (int) fighter0name.size() ) {
866  }
867  //In networking mode we name the ship save with .xml as they are xml files
868  if ( Network != NULL && squadnum < (int) fighter0name.size() ) {
869  if (Network[squadnum].getCallsign() != modifications) {
870  cout<<"Not CREATING A NETWORK PLAYER "<<fightername<<" FOR "<<modifications<<endl;
871  break;
872  }
873  cout<<"CREATING A NETWORK PLAYER : "<<fightername<<endl;
874  fighters[a] = UnitFactory::createUnit( fightername, false, tmptarget[a], "", fg, s, &savefiles[squadnum][1] );
875  //Set the faction we have in the save file instead of the mission file (that is to be ignored in networking mode)
878  fighters[a]->SetSerial( Network[squadnum].serial );
879  Network[squadnum].setUnit( fighters[a] );
880  cout<<"Creating fighter["<<squadnum<<"] from "<<modifications<<" on Network["<<squadnum<<"] named "
881  <<Network[squadnum].getCallsign()<<endl;
882  } else if (Network != NULL) {
883  cout<<"Not CREATING A LOCAL SHIP : "<<fightername<<endl;
884  break;
885  } else {
886  cout<<"CREATING A LOCAL SHIP : "<<fightername<<endl;
887  fighters[a] = UnitFactory::createUnit( fightername, false, tmptarget[a], modifications, fg, s );
888  }
890  if ( s == 0 && squadnum < (int) fighter0name.size() ) {
891  _Universe->AccessCockpit( squadnum )->Init( fighters[a]->getCockpit().c_str() );
892  _Universe->AccessCockpit( squadnum )->SetParent( fighters[a], fighter0name[squadnum].c_str(),
893  fighter0mods[squadnum].c_str(), pox );
894  }
895  if ( squadnum < (int) fighter0name.size() ) {
897  _Universe->SetActiveCockpit( backupcp );
898  }
899  } else {
900  bool isvehicle = false;
901  if (fg_terrain == -2) {
902  fighters[a] =
903  UnitFactory::createBuilding( myterrain, isvehicle, fightername, false, tmptarget[a], string( "" ), fg );
904  } else {
905  if ( fg_terrain >= (int) _Universe->activeStarSystem()->numTerrain() ) {
907  assert(
908  fg_terrain-_Universe->activeStarSystem()->numTerrain()
911  fighters[a] = UnitFactory::createBuilding( t, isvehicle, fightername, false, tmptarget[a], string(
912  "" ), fg );
913  } else {
914  Terrain *t = _Universe->activeStarSystem()->getTerrain( fg_terrain );
915  fighters[a] = UnitFactory::createBuilding( t, isvehicle, fightername, false, tmptarget[a], string(
916  "" ), fg );
917  }
918  }
920  }
921  printf( "pox %lf %lf %lf\n", pox.i, pox.j, pox.k );
922  fighters[a]->SetPosAndCumPos( pox );
923  fg_radius = fighters[a]->rSize();
924  if ( benchmark > 0.0 || ( s != 0 || squadnum >= (int) fighter0name.size() ) ) {
925  fighters[a]->LoadAIScript( ainame );
926  fighters[a]->SetTurretAI();
927  }
928  a++;
929  } //for nr_ships
930  squadnum++;
931  } //end of for flightgroups
932 
933  delete[] tmptarget;
934  for (int m_i = 0; m_i < muzak_count; m_i++)
935  muzak[m_i].SetParent( fighters[0] );
937  AUDListenerSize( fighters[0]->rSize()*4 );
938  for (unsigned int cnum = 0; cnum < fighter0indices.size(); cnum++) {
939  if (benchmark == -1) {
940  fighters[fighter0indices[cnum]]->EnqueueAI( new FlyByJoystick( cnum ) );
941  fighters[fighter0indices[cnum]]->EnqueueAI( new FireKeyboard( cnum, cnum ) );
942  }
943  fighters[fighter0indices[cnum]]->SetTurretAI();
944  fighters[fighter0indices[cnum]]->DisableTurretAI();
945  }
947  locSel = new CoordinateSelect( QVector( 0, 0, 5 ) );
948  UpdateTime();
949 
952 }
void destroyObjects ( )

Definition at line 977 of file main_loop.cpp.

References Terrain::DeleteAll(), fighters, locSel, myterrain, and tmpcockpittexture.

978 {
979  if (myterrain)
980  delete myterrain;
982  delete tmpcockpittexture;
983  delete[] fighters;
984  delete locSel;
985 }
void ExamineWhenTargetKey ( )

Definition at line 152 of file main_loop.cpp.

References _Universe, Universe::AccessCockpit(), Cockpit::getVDUMode(), vs_options::switchToTargetModeOnKey, SwitchVDUTo(), VDU::TARGET, GFXMatrices::view, and VDU::VIEW.

Referenced by FireKeyboard::IncomingMissileTargetKey(), FireKeyboard::MissileTargetKey(), FireKeyboard::NearestBaseKey(), FireKeyboard::NearestDangerousHostileKey(), FireKeyboard::NearestFriendlyKey(), FireKeyboard::NearestHostileTargetKey(), FireKeyboard::NearestJumpKey(), FireKeyboard::NearestPlanetKey(), FireKeyboard::NearestTargetKey(), FireKeyboard::NearestTargetTurretKey(), FireKeyboard::PickTargetKey(), FireKeyboard::PickTargetTurretKey(), FireKeyboard::ReverseIncomingMissileTargetKey(), FireKeyboard::ReverseMissileTargetKey(), FireKeyboard::ReverseNearestTargetKey(), FireKeyboard::ReversePickTargetKey(), FireKeyboard::ReverseSigTargetKey(), FireKeyboard::ReverseTargetKey(), FireKeyboard::ReverseThreatTargetKey(), FireKeyboard::ReverseUnitTargetKey(), FireKeyboard::SigTargetKey(), FireKeyboard::SubUnitTargetKey(), FireKeyboard::TargetKey(), FireKeyboard::TargetTurretKey(), FireKeyboard::ThreatTargetKey(), FireKeyboard::ThreatTargetTurretKey(), and FireKeyboard::UnitTargetKey().

153 {
155  int view = 0;
156  int examine = 0;
157  for (; view < 2; ++view)
158  if (_Universe->AccessCockpit()->getVDUMode( view ) == VDU::VIEW)
159  break;
160  for (; examine < 2; ++examine)
161  if (_Universe->AccessCockpit()->getVDUMode( examine ) == VDU::TARGET)
162  break;
163  if ( (examine == 2) && (view == 2) )
165  }
166 }
int getmicrosleep ( )

Definition at line 987 of file main_loop.cpp.

References vs_options::threadtime.

Referenced by GameUniverse::StartDraw().

988 {
989  return game_options.threadtime;
990 }
string getUnitNameAndFgNoBase ( Unit target)

Definition at line 60 of file vdu.cpp.

References Unit::getFgSubnumber(), Unit::getFlightgroup(), Unit::getFullname(), VegaConfig::getVariable(), Unit::isUnit(), Flightgroup::name, Unit::name, Network, XMLSupport::parse_bool(), PLANETPTR, reformatName(), XMLSupport::tostring(), UNITPTR, and vs_config.

61 {
62  Flightgroup *fg = target->getFlightgroup();
63  if (target->isUnit() == PLANETPTR) {
64  string hr = ( (Planet*) target )->getHumanReadablePlanetType();
65  if ( !hr.empty() )
66  return hr+string( ":" )+reformatName( target->name );
67  } else if (target->isUnit() == UNITPTR) {
68  if (fg) {
69  int fgsnumber = target->getFgSubnumber();
70  string fgnstring = XMLSupport::tostring( fgsnumber );
71  static bool confignums =
72  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "print_fg_sub_id", "false" ) );
73  string fgname;
74  if (fg->name != "Base" && fg->name != "Asteroid" && fg->name != "Nebula") {
75  static bool printfgname =
76  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "print_fg_name", "true" ) );
77  static bool printshiptype =
78  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "print_ship_type", "true" ) );
79  if (printfgname)
80  fgname += fg->name
81  +(printshiptype ? ( ( confignums && ("" != fgnstring) ) ? " =" : " : " ) : "");
82  if ( confignums && ("" != fgnstring) )
83  fgname += fgnstring+"= ";
84  if (printshiptype)
85  return fgname+reformatName( target->getFullname() );
86  return fgname;
87  } else if (fg->name == "Base") {
88  static bool namecolonname =
89  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "hud", "basename:basename", "true" ) );
90  if ( namecolonname == false || reformatName( target->name ) == ( reformatName( target->getFullname() ) ) ) {
91  std::string retval( reformatName( target->getFullname() ) );
92  if ( confignums && ("" != fgnstring) ) retval += " : "+fgnstring;
93  return retval;
94  } else {
95  if ( reformatName( target->name ) == ( reformatName( target->getFullname() ) ) ) {
96  std::string retval( reformatName(
97  target->name )+" "
98  +( ( confignums && ("" != fgnstring) ) ? (": "+fgnstring) : "" ) );
99  return retval;
100  } else {
101  std::string retval( reformatName( target->name )+" : "+target->getFullname() );
102  return retval;
103  }
104  }
105  }
106  } else if (Network != NULL) {
107  std::string retval( reformatName( target->name )+":"+target->getFullname() );
108  return retval;
109  }
110  }
111  return reformatName( target->name );
112 }
void IncrementStartupVariable ( )

Definition at line 720 of file main_loop.cpp.

References getSaveData(), getSaveDataLength(), Mission::getVariable(), mission, GameCockpit::NavScreen(), PRESS, pushSaveData(), putSaveData(), and vs_options::times_to_show_help_screen.

Referenced by createObjects().

721 {
722  if (mission->getVariable( "savegame", "" ).length() == 0)
723  return;
724  int len = getSaveDataLength( 0, "436457r1K3574r7uP71m35" );
725  float var = FLT_MAX;
726  if (len <= 0) {
727  pushSaveData( 0, "436457r1K3574r7uP71m35", 1 );
728  var = 1;
729  } else {
730  var = getSaveData( 0, "436457r1K3574r7uP71m35", 0 );
731  putSaveData( 0, "436457r1K3574r7uP71m35", 0, var+1 );
732  }
734  GameCockpit::NavScreen( KBData(), PRESS ); //HELP FIXME
735 }
void InitializeInput ( )

Definition at line 715 of file main_loop.cpp.

References BindKey(), and CockpitKeys::Quit().

Referenced by bootstrap_main_loop().

716 {
717  BindKey( 27, 0, 0, Quit, KBData() ); //always have quit on esc
718 }
void main_loop ( )

Definition at line 999 of file main_loop.cpp.

References _Universe, Universe::activeStarSystem(), ContinuousTerrain::AdjustTerrain(), avg_loop, cur_check, g_game, getNewTime(), Singleton< SceneManager >::getSingleton(), gl_batches_this_frame, gl_vertices_this_frame, last_check, loop_count, Music::MuzakCycle(), nb_checks, Network, Universe::numPlayers(), game_data_t::sound_enabled, Universe::StartDraw(), and VSFileSystem::vs_dprintf().

Referenced by bootstrap_main_loop(), GFXLoop(), GameUniverse::Loop(), restore_main_loop(), and NavComputer::toggleVisibility().

1000 {
1001  //Evaluate number of loops per second each XX loops
1002  if (loop_count == 500) {
1004  cur_check = getNewTime();
1005  if (last_check != 1) {
1006  //Time to update test
1008  nb_checks = nb_checks+1;
1009  }
1010  loop_count = -1;
1011  }
1012  loop_count++;
1013 
1014  //Execute DJ script
1016 
1017  _Universe->StartDraw();
1018  if (myterrain)
1020  if (Network != NULL)
1021  for (size_t jj = 0; jj < _Universe->numPlayers(); jj++)
1022  Network[jj].checkMsg( NULL );
1023 
1024 #ifndef NO_GFX
1025  VSFileSystem::vs_dprintf(3, "Drawn %d vertices in %d batches\n",
1030 #endif
1031 
1032  //Commit audio scene status to renderer
1033  if (g_game.sound_enabled)
1035 }
int shiftup ( int  )

Definition at line 72 of file in_kb.cpp.

References _himap, _lomap, and c.

73 {
74  if ( ch == (ch&0xFF) ) {
75  const char *c = strchr( _lomap, ch );
76  if (c)
77  return _himap[c-_lomap];
78 
79  else
80  return toupper( ch );
81  } else {return ch; }}
static void SwitchVDUTo ( VDU::VDU_MODE  v)
static

Definition at line 124 of file main_loop.cpp.

References _Universe, Universe::AccessCockpit(), Cockpit::getVDUMode(), i, j, Cockpit::VDUSwitch(), VDU::VIEW, and VDU::WEAPON.

Referenced by CockpitKeys::CommModeVDU(), CockpitKeys::DamageModeVDU(), ExamineWhenTargetKey(), CockpitKeys::GunModeVDU(), CockpitKeys::ManifestModeVDU(), CockpitKeys::MissileModeVDU(), CockpitKeys::ObjectiveModeVDU(), CockpitKeys::ReverseGunModeVDU(), CockpitKeys::ReverseMissileModeVDU(), CockpitKeys::ScanningModeVDU(), CockpitKeys::TargetModeVDU(), and CockpitKeys::ViewModeVDU().

125 {
126  int i;
127  static int whichvdu = 1;
128  for (int j = 0; j < 3; ++j) {
129  if ( v != _Universe->AccessCockpit()->getVDUMode( whichvdu ) || (v != VDU::VIEW && v != VDU::WEAPON) ) {
130  whichvdu += 1;
131  whichvdu %= 2;
132  }
133  int curmode = _Universe->AccessCockpit()->getVDUMode( whichvdu );
134  if ( v == _Universe->AccessCockpit()->getVDUMode( whichvdu ) ) {
135  if (v == VDU::VIEW)
136  _Universe->AccessCockpit()->VDUSwitch( whichvdu ); //get different view mode
137  return;
138  }
139  for (i = 0; i < 32; ++i) {
140  _Universe->AccessCockpit()->VDUSwitch( whichvdu );
141  if ( v == _Universe->AccessCockpit()->getVDUMode( whichvdu ) )
142  return;
143  }
144  for (i = 0; i < 32; ++i) {
145  _Universe->AccessCockpit()->VDUSwitch( whichvdu );
146  if ( curmode == _Universe->AccessCockpit()->getVDUMode( whichvdu ) )
147  break;
148  }
149  }
150 }
void VolDown ( const KBData ,
KBSTATE  newState 
)

Definition at line 111 of file main_loop.cpp.

References AUDGetListenerGain(), AUDListenerGain(), Music::ChangeVolume(), and PRESS.

Referenced by initGlobalCommandMap().

112 {
113  if (newState == PRESS) {
114  float gain = AUDGetListenerGain();
115  if (gain > 0) {
116  gain -= .03125;
117  if (gain < 0) gain = 0;
118  AUDListenerGain( gain );
119  Music::ChangeVolume( 0 );
120  }
121  }
122 }
void VolUp ( const KBData ,
KBSTATE  newState 
)

Definition at line 97 of file main_loop.cpp.

References AUDGetListenerGain(), AUDListenerGain(), Music::ChangeVolume(), and PRESS.

Referenced by initGlobalCommandMap().

98 {
99  if (newState == PRESS) {
100  float gain = AUDGetListenerGain();
101  if (gain < 1) {
102  gain += .0625;
103  if (gain > 1) gain = 1;
104  AUDListenerGain( gain );
105  Music::ChangeVolume( 0 );
106  }
107  }
108 }

Variable Documentation

int allexcept = FE_DIVBYZERO

Definition at line 85 of file main_loop.cpp.

Referenced by CockpitKeys::ScrollUp().

SphereMesh* bg2 = NULL

Definition at line 94 of file main_loop.cpp.

GFXBOOL capture

Definition at line 79 of file main_loop.cpp.

Unit* carrier = NULL

Definition at line 75 of file main_loop.cpp.

bool cleanexit

Definition at line 9 of file vs_globals.cpp.

Referenced by bootstrap_main_loop(), cleanup(), and CockpitKeys::QuitNow().

Unit* fighter = NULL

Definition at line 76 of file main_loop.cpp.

Referenced by LoadMission().

Unit* fighter2 = NULL

Definition at line 77 of file main_loop.cpp.

Unit** fighters

Definition at line 74 of file main_loop.cpp.

Referenced by destroyObjects().

vs_options game_options

Draws cockpit parts Draws gauges, info strings, radar, ...

Definition at line 83 of file main.cpp.

std::string global_username

Definition at line 18 of file netclient_login.cpp.

CoordinateSelect* locSel = NULL

Definition at line 93 of file main_loop.cpp.

Referenced by destroyObjects().

Unit* midway = NULL

Definition at line 78 of file main_loop.cpp.

ContinuousTerrain* myterrain

Definition at line 91 of file main_loop.cpp.

Referenced by destroyObjects().

int numf = 0

Definition at line 92 of file main_loop.cpp.

Referenced by createObjects().

GFXBOOL quit = GFXFALSE

Definition at line 80 of file main_loop.cpp.

Referenced by BaseComputer::constructControls(), main(), and ScanOptions().

bool QuitAllow = false

Definition at line 82 of file main_loop.cpp.

Referenced by CockpitKeys::_PitchDown(), CockpitKeys::LookDown(), and CockpitKeys::Quit().

ClickList* shipList = NULL

Definition at line 95 of file main_loop.cpp.

Referenced by NetActionConfirm::confirmedJoinGame().

Texture* tmpcockpittexture
static

Definition at line 73 of file main_loop.cpp.

Referenced by destroyObjects().