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
zonemgr.cpp File Reference
#include "networking/lowlevel/netbuffer.h"
#include "networking/lowlevel/vsnet_debug.h"
#include "universe_generic.h"
#include "universe_util.h"
#include "star_system_generic.h"
#include "cmd/unit_generic.h"
#include "cmd/unit_factory.h"
#include "gfx/cockpit_generic.h"
#include "networking/lowlevel/packet.h"
#include "networking/savenet_util.h"
#include "networking/zonemgr.h"
#include "vs_globals.h"
#include "endianness.h"
#include <assert.h>
#include "networking/netserver.h"
#include "vs_random.h"
#include "lin_time.h"

Go to the source code of this file.

Functions

StarSystemGetLoadedStarSystem (const char *system)
 
void displayUnitInfo (Unit *un, const string callsign, const char *type)
 
bool Nearby (ClientPtr clt, Unit *un)
 

Function Documentation

void displayUnitInfo ( Unit un,
const string  callsign,
const char *  type 
)

Definition at line 46 of file zonemgr.cpp.

References UnitUtil::getFactionName(), Unit::getFgSubnumber(), Unit::getFlightgroup(), Unit::getFullname(), Unit::GetSerial(), Flightgroup::name, and Unit::name.

Referenced by ZoneMgr::addClient(), ZoneInfo::display(), ZoneMgr::displayNPCs(), ZoneMgr::removeClient(), NetServer::sendKill(), and NetServer::sendNewUnitQueue().

47 {
48  cout<<type;
49  if (!un) {
50  cout<<"\'"<<callsign<<"\' (dead)"<<endl;
51  } else {
52  {
53  char tmp[10];
54  sprintf( tmp, "% 5d ", un->GetSerial() );
55  cout<<tmp;
56  }
57  cout<<UnitUtil::getFactionName( un )<<" "<<un->getFullname()<<" ("<<un->name<<")";
58  Flightgroup *fg = un->getFlightgroup();
59  if (fg) cout<<", \'"<<fg->name<<"\' "<<un->getFgSubnumber();
60  if ( !callsign.empty() && (!fg || callsign != fg->name) )
61  cout<<", callsign \'"<<callsign<<"\'";
62  cout<<endl;
63  }
64 }
StarSystem* GetLoadedStarSystem ( const char *  system)

Definition at line 786 of file star_system_generic.cpp.

787 {
788  StarSystem *ss = star_system_table.Get( string( system ) );
789  std::string ssys( string( system )+string( ".system" ) );
790  if (!ss)
791  ss = star_system_table.Get( ssys );
792  return ss;
793 }
bool Nearby ( ClientPtr  clt,
Unit un 
)

Definition at line 619 of file zonemgr.cpp.

References Unit::computer, VegaConfig::getVariable(), Unit::InRange(), Unit::Computer::RADARLIM::maxrange, XMLSupport::parse_float(), Unit::Position(), QVector, Unit::Computer::radar, and vs_config.

Referenced by ZoneMgr::addPosition().

620 {
621  Unit *parent = clt->game_unit.GetUnit();
622  if (parent) {
623  if (un == parent) return true;
624  double mm;
625  if ( !parent->InRange( un, mm, false, false, true ) ) {
626  static double always_send_range =
627  XMLSupport::parse_float( vs_config->getVariable( "server", "visible_send_range", "1000" ) );
628  if (parent->computer.radar.maxrange >= always_send_range)
629  return false;
630  {
631  QVector dist = ( un->Position()-parent->Position() );
632  if (dist.Dot( dist ) >= always_send_range*always_send_range)
633  return false;
634  }
635  }
636  static double maxrange = XMLSupport::parse_float( vs_config->getVariable( "server", "max_send_range", "1e21" ) );
637  if (mm > maxrange)
638  return false;
639  } else {return false; } return true;
640 }