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
netclient.cpp File Reference
#include "config.h"
#include "networking/netclient.h"
#include "networking/lowlevel/netui.h"
#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include "gfx/background.h"
#include "vs_globals.h"
#include "endianness.h"
#include "cmd/unit_generic.h"
#include "cmd/unit_util.h"
#include "cmd/unit_const_cache.h"
#include "configxml.h"
#include "networking/client.h"
#include "networking/const.h"
#include "networking/lowlevel/packet.h"
#include "universe_util.h"
#include "cmd/unit_factory.h"
#include "gfx/matrix.h"
#include "load_mission.h"
#include "lin_time.h"
#include "vsfilesystem.h"
#include "cmd/role_bitmask.h"
#include "cmd/base_util.h"
#include "gfx/cockpit_generic.h"
#include "savenet_util.h"
#include "save_util.h"
#include "cmd/pilot.h"
#include "cmd/ai/communication.h"
#include "cmd/ai/order.h"
#include "networking/lowlevel/vsnet_clientstate.h"
#include "networking/lowlevel/vsnet_debug.h"
#include "networking/lowlevel/vsnet_dloadmgr.h"
#include "networking/lowlevel/vsnet_notify.h"
#include "vegastrike.h"
#include "networking/lowlevel/netbuffer.h"
#include "networking/networkcomm.h"
#include "posh.h"
#include "networking/prediction.h"
#include "fileutil.h"
#include "faction_generic.h"
#include "netversion.h"
#include "lowlevel/vsnet_err.h"

Go to the source code of this file.

Typedefs

typedef vector< Client * >
::iterator 
VC
 
typedef vector< ObjSerial >
::iterator 
ObjI
 

Functions

const UnitgetUnitFromUpgradeName (const string &upgradeName, int myUnitFaction=0)
 
int GetModeFromName (const char *)
 
CargoGetMasterPartList (const char *input_buffer)
 
bool isWeapon (std::string name)
 
bool isLocalSerial (ObjSerial sernum)
 
UnitgetNetworkUnit (ObjSerial cserial)
 
void SwitchUnits2 (Unit *un)
 
bool preEmptiveClientFire (const weapon_info *)
 

Variables

ObjSerial CLIENT_NETVERSION = NETWORK_VERSION
 
double NETWORK_ATOM
 
Hashtable< std::string,
StarSystem, 127 > 
star_system_table
 
static const string LOAD_FAILED = "LOAD_FAILED"
 
vector< ObjSeriallocalSerials
 

Typedef Documentation

typedef vector< ObjSerial >::iterator ObjI

Definition at line 81 of file netclient.cpp.

typedef vector< Client* >::iterator VC

Definition at line 80 of file netclient.cpp.

Function Documentation

Cargo* GetMasterPartList ( const char *  input_buffer)

Definition at line 8519 of file unit_generic.cpp.

8520 {
8521  unsigned int i;
8523 }
int GetModeFromName ( const char *  )

Definition at line 87 of file unit_xml.cpp.

88 {
89  if (strlen( input_buffer ) > 3) {
90  if (input_buffer[0] == 'a'
91  && input_buffer[1] == 'd'
92  && input_buffer[2] == 'd')
93  return 1;
94  if (input_buffer[0] == 'm'
95  && input_buffer[1] == 'u'
96  && input_buffer[2] == 'l')
97  return 2;
98  }
99  return 0;
100 }
Unit* getNetworkUnit ( ObjSerial  cserial)

Definition at line 109 of file netclient.cpp.

References _Universe, Unit::GetSerial(), UniverseUtil::getUnit(), i, Network, and Universe::numPlayers().

Referenced by NetClient::AddClientObject().

110 {
111  for (unsigned int i = 0; i < _Universe->numPlayers(); i++)
112  if (Network[i].getUnit()->GetSerial() == cserial)
113  return Network[i].getUnit();
114  return NULL;
115 }
const Unit* getUnitFromUpgradeName ( const string &  upgradeName,
int  myUnitFaction = 0 
)

Definition at line 37 of file unit_functions_generic.cpp.

38 {
39  const char *name = upgradeName.c_str();
41  if (!partUnit) {
45  }
46  if (partUnit->name == "LOAD_FAILED") {
47  partUnit = UnitConstCache::getCachedConst( StringIntKey( name, myUnitFaction ) );
48  if (!partUnit)
49  partUnit = UnitConstCache::setCachedConst( StringIntKey( name, myUnitFaction ),
50  UnitFactory::createUnit( name, true, myUnitFaction ) );
51  }
52  return partUnit;
53 }
bool isLocalSerial ( ObjSerial  sernum)

Definition at line 96 of file netclient.cpp.

References i, and localSerials.

Referenced by NetClient::AddClientObject().

97 {
98  //COUT<<"Looking for serial : "<<sernum<<" in ";
99  bool ret = false;
100  for (ObjI i = localSerials.begin(); !ret && i != localSerials.end(); i++)
101  //COUT<<(*i)<<", ";
102  if ( sernum == (*i) )
103  ret = true;
104  //COUT<<endl;
105 
106  return ret;
107 }
bool isWeapon ( std::string  name)

Definition at line 8815 of file unit_generic.cpp.

8816 {
8817  if (name.find( "Weapon" ) != std::string::npos)
8818  return true;
8819  if (name.find( "SubUnit" ) != std::string::npos)
8820  return true;
8821  if (name.find( "Ammunition" ) != std::string::npos)
8822  return true;
8823  return false;
8824 }
bool preEmptiveClientFire ( const weapon_info )

Definition at line 1415 of file unit_generic.cpp.

References weapon_info::BEAM, VegaConfig::getVariable(), XMLSupport::parse_bool(), weapon_info::PROJECTILE, weapon_info::type, and vs_config.

Referenced by Unit::Fire().

1416 {
1417  static bool
1418  client_side_fire = XMLSupport::parse_bool( vs_config->getVariable( "network", "client_side_fire", "true" ) );
1419  return client_side_fire && wi->type != weapon_info::BEAM && wi->type != weapon_info::PROJECTILE;
1420 }
void SwitchUnits2 ( Unit un)

Definition at line 2808 of file cockpit.cpp.

References _Universe, Universe::AccessCockpit(), Universe::CurrentCockpit(), Unit::DisableTurretAI(), Unit::EnqueueAI(), Unit::getCockpit(), VegaConfig::getVariable(), Cockpit::Init(), XMLSupport::parse_bool(), Unit::PrimeOrders(), Unit::SetTurretAI(), and vs_config.

Referenced by NetClient::Respawn(), and SwitchUnits().

2809 {
2810  if (nw) {
2811  nw->PrimeOrders();
2812  nw->EnqueueAI( new FireKeyboard( _Universe->CurrentCockpit(), _Universe->CurrentCockpit() ) );
2813  nw->EnqueueAI( new FlyByJoystick( _Universe->CurrentCockpit() ) );
2814 
2815  nw->SetTurretAI();
2816  nw->DisableTurretAI();
2817 
2818  static bool LoadNewCockpit =
2819  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "UnitSwitchCockpitChange", "false" ) );
2820  static bool DisCockpit =
2821  XMLSupport::parse_bool( vs_config->getVariable( "graphics", "SwitchCockpitToDefaultOnUnitSwitch", "false" ) );
2822  if (nw->getCockpit().length() > 0 || DisCockpit)
2823  _Universe->AccessCockpit()->Init( nw->getCockpit().c_str(), LoadNewCockpit == false );
2824  /* Here is the old code:
2825  *
2826  * if (nw->getCockpit().length()>0&&LoadNewCockpit) {
2827  * _Universe->AccessCockpit()->Init (nw->getCockpit().c_str());
2828  * }else {
2829  * if (DisCockpit) {
2830  * _Universe->AccessCockpit()->Init ("disabled-cockpit.cpt");
2831  * }
2832  * }
2833  *
2834  */
2835  }
2836 }

Variable Documentation

ObjSerial CLIENT_NETVERSION = NETWORK_VERSION

Definition at line 71 of file netclient.cpp.

Referenced by NetClient::init().

const string LOAD_FAILED = "LOAD_FAILED"
static

Definition at line 85 of file netclient.cpp.

double NETWORK_ATOM

Definition at line 77 of file netclient.cpp.

Referenced by NetClient::init(), NetClient::isTime(), and NetServer::start().

Hashtable< std::string, StarSystem, 127 > star_system_table

Definition at line 773 of file star_system_generic.cpp.