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
netserver.cpp File Reference
#include <time.h>
#include <math.h>
#include <unistd.h>
#include "cmd/unit_generic.h"
#include "cmd/unit_util.h"
#include "cmd/weapon_xml.h"
#include "cmd/bolt.h"
#include "gfx/cockpit_generic.h"
#include "universe_util.h"
#include "cmd/unit_factory.h"
#include "load_mission.h"
#include "save_util.h"
#include "networking/client.h"
#include "networking/lowlevel/packet.h"
#include "lin_time.h"
#include "python/init.h"
#include "networking/netserver.h"
#include "networking/zonemgr.h"
#include "networking/lowlevel/vsnet_serversocket.h"
#include "networking/lowlevel/vsnet_sockethttp.h"
#include "networking/lowlevel/vsnet_debug.h"
#include "networking/savenet_util.h"
#include "vsfilesystem.h"
#include "options.h"
#include "networking/lowlevel/netbuffer.h"
#include "networking/lowlevel/vsnet_dloadmgr.h"
#include "cmd/ai/script.h"
#include "cmd/ai/order.h"
#include "cmd/ai/fire.h"
#include "cmd/ai/fireall.h"
#include "cmd/ai/flybywire.h"
#include "cmd/ai/communication.h"
#include "cmd/pilot.h"
#include "cmd/role_bitmask.h"
#include "gfxlib_struct.h"
#include "posh.h"
#include "fileutil.h"
#include "faction_generic.h"
#include "cmd/unit_const_cache.h"
#include <Python.h>
#include "netversion.h"

Go to the source code of this file.

Macros

#define MAXINPUT   1024
 

Functions

const UnitgetUnitFromUpgradeName (const string &upgradeName, int myUnitFaction=0)
 
int GetModeFromName (const char *)
 
bool isWeapon (std::string name)
 
CargoGetMasterPartList (const char *input_buffer)
 
void ExecuteDirector ()
 
void getZoneInfoBuffer (unsigned short zoneid, NetBuffer &netbuf)
 
void InitUnitTables ()
 

Variables

ObjSerial SERVER_NETVERSION = NETWORK_VERSION
 
class vs_options game_options
 
double clienttimeout
 
double logintimeout
 
int acct_con
 
double DAMAGE_ATOM
 
double PLANET_ATOM
 
double SAVE_ATOM
 
static const char *const MISSION_SCRIPTS_LABEL = "mission_scripts"
 
static const char *const MISSION_NAMES_LABEL = "mission_names"
 
static const char *const MISSION_DESC_LABEL = "mission_descriptions"
 
char input_buffer [MAXINPUT]
 
int nbchars
 
string universe_file
 
string universe_path
 
static const string LOAD_FAILED = "LOAD_FAILED"
 

Macro Definition Documentation

#define MAXINPUT   1024

Definition at line 85 of file netserver.cpp.

Referenced by NetServer::start().

Function Documentation

void ExecuteDirector ( )

Definition at line 617 of file star_system_generic.cpp.

References _Universe, Universe::AccessCockpit(), active_missions, Cockpit::activeStarSystem, Universe::CurrentCockpit(), i, mission, Universe::popActiveStarSystem(), processDelayedMissions(), Universe::pushActiveStarSystem(), and Universe::SetActiveCockpit().

618 {
619  unsigned int curcockpit = _Universe->CurrentCockpit();
620  {
621  for (unsigned int i = 0; i < active_missions.size(); ++i)
622  if (active_missions[i]) {
623  _Universe->SetActiveCockpit( active_missions[i]->player_num );
625  if (ss) _Universe->pushActiveStarSystem( ss );
627  active_missions[i]->DirectorLoop();
628  if (ss) _Universe->popActiveStarSystem();
629  }
630  }
631  _Universe->SetActiveCockpit( curcockpit );
634  {
635  for (unsigned int i = 1; i < active_missions.size();) {
636  if (active_missions[i]) {
637  if (active_missions[i]->runtime.pymissions) {
638  ++i;
639  } else {
640  unsigned int w = active_missions.size();
641  active_missions[i]->terminateMission();
642  if ( w == active_missions.size() ) {
643  printf( "MISSION NOT ERASED\n" );
644  break;
645  }
646  }
647  } else {
648  active_missions.Get()->erase( active_missions.Get()->begin()+i );
649  }
650  }
651  }
652 }
Cargo* GetMasterPartList ( const char *  input_buffer)

Definition at line 8519 of file unit_generic.cpp.

References Unit::GetCargo(), and GetUnitMasterPartList().

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 }
const Unit* getUnitFromUpgradeName ( const string &  upgradeName,
int  myUnitFaction = 0 
)

Definition at line 37 of file unit_functions_generic.cpp.

References UnitFactory::createUnit(), ClassCache< Typ, Key >::getCachedConst(), FactionUtil::GetUpgradeFaction(), Unit::name, and ClassCache< Typ, Key >::setCachedConst().

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 }
void getZoneInfoBuffer ( unsigned short  zoneid,
NetBuffer netbuf 
)

Definition at line 103 of file netserver.cpp.

References ZoneMgr::getZoneBuffer(), VSServer, and NetServer::zonemgr.

104 {
105  VSServer->zonemgr->getZoneBuffer( zoneid, netbuf );
106 }
void InitUnitTables ( )

Definition at line 341 of file universe_generic.cpp.

References VSFileSystem::VSFile::Close(), VSFileSystem::VSFile::GetRoot(), VegaConfig::getVariable(), VSFileSystem::Ok, VSFileSystem::VSFile::OpenReadOnly(), VSFileSystem::UnitFile, unitTables, and vs_config.

342 {
343  VSFile allUnits;
344  VSError err;
345  static string unitdata = vs_config->getVariable( "data", "UnitCSV", "modunits.csv" );
346  while (unitdata.length() != 0) {
347  string::size_type where = unitdata.find( " " ), where2 = where;
348  if (where == string::npos)
349  where = unitdata.length();
350  string tmp = unitdata.substr( 0, where );
351  err = allUnits.OpenReadOnly( tmp, UnitFile );
352  if (err <= Ok) {
353  unitTables.push_back( new CSVTable( allUnits, allUnits.GetRoot() ) );
354  allUnits.Close();
355  }
356  if (where2 == string::npos) break;
357  unitdata = unitdata.substr( where+1, unitdata.length() );
358  }
359  //Now include units.csv at the end.
360  err = allUnits.OpenReadOnly( "units.csv", UnitFile );
361  if (err <= Ok) {
362  unitTables.push_back( new CSVTable( allUnits, allUnits.GetRoot() ) );
363  allUnits.Close();
364  }
365 }
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 }

Variable Documentation

int acct_con

Definition at line 76 of file netserver.cpp.

Referenced by NetServer::saveAccount(), and NetServer::start().

double clienttimeout

Definition at line 74 of file netserver.cpp.

Referenced by NetServer::start().

double DAMAGE_ATOM

Definition at line 77 of file netserver.cpp.

Referenced by NetServer::start().

class vs_options game_options

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

Definition at line 83 of file main.cpp.

char input_buffer[MAXINPUT]
const string LOAD_FAILED = "LOAD_FAILED"
static

Definition at line 97 of file netserver.cpp.

double logintimeout

Definition at line 75 of file netserver.cpp.

Referenced by NetServer::start().

const char* const MISSION_DESC_LABEL = "mission_descriptions"
static

Definition at line 83 of file netserver.cpp.

const char* const MISSION_NAMES_LABEL = "mission_names"
static

Definition at line 82 of file netserver.cpp.

const char* const MISSION_SCRIPTS_LABEL = "mission_scripts"
static

Definition at line 81 of file netserver.cpp.

int nbchars

Definition at line 87 of file netserver.cpp.

Referenced by NetServer::start().

double PLANET_ATOM

Definition at line 78 of file netserver.cpp.

Referenced by NetServer::start().

double SAVE_ATOM

Definition at line 79 of file netserver.cpp.

Referenced by NetServer::start().

ObjSerial SERVER_NETVERSION = NETWORK_VERSION

Definition at line 70 of file netserver.cpp.

string universe_file

Definition at line 89 of file netserver.cpp.

Referenced by NetServer::start().

string universe_path

Definition at line 90 of file netserver.cpp.

Referenced by NetServer::start().