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
UnitFactory Class Reference

#include <unit_factory.h>

Static Public Member Functions

static UnitgetMasterPartList ()
 
static UnitcreateUnit ()
 
static UnitcreateUnit (const char *filename, bool SubUnit, int faction, std::string customizedUnit=string(""), Flightgroup *flightgroup=NULL, int fg_subnumber=0, string *netxml=NULL, ObjSerial netcreate=0)
 
static UnitcreateServerSideUnit (const char *filename, bool SubUnit, int faction, std::string customizedUnit=string(""), Flightgroup *flightgroup=NULL, int fg_subnumber=0)
 
static UnitcreateUnit (std::vector< Mesh * > &meshes, bool Subunit, int faction)
 
static NebulacreateNebula (const char *unitfile, bool SubU, int faction, Flightgroup *fg=NULL, int fg_snumber=0, ObjSerial netcreate=0)
 
static MissilecreateMissile (const char *filename, int faction, const string &modifications, const float damage, float phasedamage, float time, float radialeffect, float radmult, float detonation_radius, ObjSerial netcreate=0)
 
static PlanetcreatePlanet ()
 
static PlanetcreatePlanet (QVector x, QVector y, float vely, const Vector &rotvel, float pos, float gravity, float radius, const std::string &filename, const std::string &technique, const std::string &unitname, BLENDFUNC blendsrc, BLENDFUNC blenddst, const vector< string > &dest, const QVector &orbitcent, Unit *parent, const GFXMaterial &ourmat, const std::vector< GFXLightLocal > &ligh, int faction, string fullname, bool inside_out=false, ObjSerial netcreate=0)
 
static EnhancementcreateEnhancement (const char *filename, int faction, const string &modifications, Flightgroup *flightgrp=NULL, int fg_subnumber=0)
 
static BuildingcreateBuilding (ContinuousTerrain *parent, bool vehicle, const char *filename, bool SubUnit, int faction, const std::string &unitModifications=std::string(""), Flightgroup *fg=NULL)
 
static BuildingcreateBuilding (Terrain *parent, bool vehicle, const char *filename, bool SubUnit, int faction, const std::string &unitModifications=std::string(""), Flightgroup *fg=NULL)
 
static AsteroidcreateAsteroid (const char *filename, int faction, Flightgroup *fg=NULL, int fg_snumber=0, float difficulty=.01, ObjSerial netcreate=0)
 
static TerraincreateTerrain (const char *file, Vector scale, float position, float radius, Matrix &t)
 
static ContinuousTerraincreateContinuousTerrain (const char *file, Vector scale, float position, Matrix &t)
 
static void addUnitBuffer (NetBuffer &netbuf, const string &filename, const string &name, const string &fullname, bool SubUnit, int faction, std::string customizedUnit, const ClientState &curr_state, Flightgroup *flightgroup, int fg_subnumber, string *netxml, ObjSerial netcreate)
 
static void addUnitBuffer (NetBuffer &netbuf, const Unit *un, string *netxml=NULL)
 
static UnitparseUnitBuffer (NetBuffer &netbuf)
 
static void addPlanetBuffer (NetBuffer &netbuf, QVector x, QVector y, float vely, const Vector &rotvel, float pos, float gravity, float radius, const char *filename, BLENDFUNC sr, BLENDFUNC ds, const vector< string > &dest, const QVector &orbitcent, Unit *parent, const GFXMaterial &ourmat, const std::vector< GFXLightLocal > &ligh, int faction, string fullname, bool inside_out, ObjSerial netcreate)
 
static PlanetparsePlanetBuffer (NetBuffer &netbuf)
 
static void addNebulaBuffer (NetBuffer &netbuf, const char *unitfile, bool SubU, int faction, Flightgroup *fg, int fg_snumber, ObjSerial netcreate)
 
static void addNebulaBuffer (NetBuffer &netbuf, const Nebula *neb)
 
static NebulaparseNebulaBuffer (NetBuffer &netbuf)
 
static void addMissileBuffer (NetBuffer &netbuf, const string &filename, const string &name, const string &fullname, int faction, const string &modifications, const ClientState &curr_state, const float damage, float phasedamage, float time, float radialeffect, float radmult, float detonation_radius, ObjSerial netcreate)
 
static void addMissileBuffer (NetBuffer &netbuf, const Missile *mis)
 
static MissileparseMissileBuffer (NetBuffer &netbuf)
 
static void addAsteroidBuffer (NetBuffer &netbuf, const char *filename, int faction, Flightgroup *fg, int fg_snumber, float difficulty, ObjSerial netcreate)
 
static void addAsteroidBuffer (NetBuffer &netbuf, const Asteroid *ast)
 
static AsteroidparseAsteroidBuffer (NetBuffer &netbuf)
 
static void addBuffer (NetBuffer &netbuf, const Unit *un, bool allowSystemTypes, string *netxml=NULL)
 
static void endBuffer (NetBuffer &netbuf)
 
static void broadcastUnit (Unit *un, unsigned short zone)
 

Static Protected Attributes

static Unit_masterPartList = NULL
 

Detailed Description

Definition at line 40 of file unit_factory.h.

Member Function Documentation

void UnitFactory::addAsteroidBuffer ( NetBuffer netbuf,
const char *  filename,
int  faction,
Flightgroup fg,
int  fg_snumber,
float  difficulty,
ObjSerial  netcreate 
)
static

Definition at line 323 of file unit_factory_generic.cpp.

References ZoneMgr::AddAsteroid, NetBuffer::addChar(), NetBuffer::addFloat(), NetBuffer::addInt32(), NetBuffer::addSerial(), NetBuffer::addString(), and Flightgroup::name.

Referenced by addAsteroidBuffer(), and addBuffer().

330 {
331  netbuf.addChar( ZoneMgr::AddAsteroid );
332  netbuf.addSerial( netcreate );
333  netbuf.addString( string( filename ) );
334  netbuf.addInt32( faction );
335  netbuf.addString( fg->name );
336  netbuf.addInt32( fg_snumber );
337  netbuf.addFloat( difficulty );
338 }
void UnitFactory::addAsteroidBuffer ( NetBuffer netbuf,
const Asteroid ast 
)
static

Definition at line 340 of file unit_factory_generic.cpp.

References addAsteroidBuffer(), Unit::faction, Unit::getFgSubnumber(), Unit::getFilename(), Unit::getFlightgroup(), and Unit::GetSerial().

341 {
342  addAsteroidBuffer( netbuf, aster->getFilename().c_str(), aster->faction, aster->getFlightgroup(), aster->getFgSubnumber(),
343  0 /*difficulty--only determines angular velocity*/, aster->GetSerial() );
344 }
void UnitFactory::addBuffer ( NetBuffer netbuf,
const Unit un,
bool  allowSystemTypes,
string *  netxml = NULL 
)
static

Definition at line 368 of file unit_factory_generic.cpp.

References addAsteroidBuffer(), addMissileBuffer(), addNebulaBuffer(), addUnitBuffer(), ASTEROIDPTR, Unit::isUnit(), MISSILEPTR, NEBULAPTR, and UNITPTR.

Referenced by ZoneMgr::getZoneBuffer(), and NetServer::sendNewUnitQueue().

369 {
370  switch ( un->isUnit() )
371  {
372  case UNITPTR:
373  addUnitBuffer( netbuf, un, netxml );
374  break;
375  case MISSILEPTR:
376  addMissileBuffer( netbuf, static_cast< const Missile* > (un) );
377  break;
378  case NEBULAPTR:
379  if (allowSystemTypes)
380  addNebulaBuffer( netbuf, static_cast< const Nebula* > (un) );
381  break;
382  case ASTEROIDPTR:
383  if (allowSystemTypes)
384  addAsteroidBuffer( netbuf, static_cast< const Asteroid* > (un) );
385  break;
386  default:
387  break;
388  }
389 }
void UnitFactory::addMissileBuffer ( NetBuffer netbuf,
const string &  filename,
const string &  name,
const string &  fullname,
int  faction,
const string &  modifications,
const ClientState curr_state,
const float  damage,
float  phasedamage,
float  time,
float  radialeffect,
float  radmult,
float  detonation_radius,
ObjSerial  netcreate 
)
static

Definition at line 245 of file unit_factory_generic.cpp.

References NetBuffer::addChar(), NetBuffer::addClientState(), NetBuffer::addFloat(), NetBuffer::addInt32(), ZoneMgr::AddMissile, NetBuffer::addSerial(), NetBuffer::addString(), NetBuffer::addTransformation(), ClientState::getTransformation(), and NetBuffer::version().

Referenced by addBuffer(), and addMissileBuffer().

259 {
260  netbuf.addChar( ZoneMgr::AddMissile );
261  netbuf.addSerial( netcreate );
262  netbuf.addString( filename );
263  netbuf.addString( name );
264  netbuf.addString( fullname );
265 
266  netbuf.addInt32( faction );
267  netbuf.addString( modifications );
268  netbuf.addFloat( damage );
269  netbuf.addFloat( phasedamage );
270  netbuf.addFloat( time );
271  netbuf.addFloat( radialeffect );
272  netbuf.addFloat( radmult );
273  netbuf.addFloat( detonation_radius );
274  if (netbuf.version() <= 4951)
275  netbuf.addTransformation( curr_state.getTransformation() );
276  else
277  netbuf.addClientState( curr_state );
278 }
void UnitFactory::addMissileBuffer ( NetBuffer netbuf,
const Missile mis 
)
static

Definition at line 280 of file unit_factory_generic.cpp.

References addMissileBuffer(), Missile::damage, Missile::detonation_radius, Unit::faction, Unit::getFilename(), Unit::getFullname(), Unit::GetSerial(), Unit::name, Missile::phasedamage, Missile::radial_effect, Missile::radial_multiplier, and Missile::time.

281 {
282  addMissileBuffer( netbuf, mis->getFilename().c_str(), mis->name, mis->getFullname(), mis->faction,
283  "" /* modifications */, ClientState(
284  static_cast< const Unit* > (mis) ), mis->damage, mis->phasedamage, mis->time,
285  mis->radial_effect, mis->radial_multiplier, mis->detonation_radius, mis->GetSerial() );
286 }
void UnitFactory::addNebulaBuffer ( NetBuffer netbuf,
const char *  unitfile,
bool  SubU,
int  faction,
Flightgroup fg,
int  fg_snumber,
ObjSerial  netcreate 
)
static

Definition at line 201 of file unit_factory_generic.cpp.

References NetBuffer::addChar(), NetBuffer::addInt32(), ZoneMgr::AddNebula, NetBuffer::addSerial(), NetBuffer::addString(), and Flightgroup::name.

Referenced by addBuffer(), and addNebulaBuffer().

208 {
209  netbuf.addChar( ZoneMgr::AddNebula );
210  netbuf.addSerial( netcreate );
211  netbuf.addString( string( unitfile ) );
212  netbuf.addChar( SubU );
213  netbuf.addInt32( faction );
214  netbuf.addString( fg->name );
215  netbuf.addInt32( fg_snumber );
216 }
void UnitFactory::addNebulaBuffer ( NetBuffer netbuf,
const Nebula neb 
)
static

Definition at line 218 of file unit_factory_generic.cpp.

References addNebulaBuffer(), Unit::faction, Unit::getFgSubnumber(), Unit::getFilename(), Unit::getFlightgroup(), Unit::GetSerial(), and Unit::isSubUnit().

219 {
220  addNebulaBuffer( netbuf, neb->getFilename().c_str(), neb->isSubUnit(), neb->faction,
221  neb->getFlightgroup(), neb->getFgSubnumber(), neb->GetSerial() );
222 }
void UnitFactory::addPlanetBuffer ( NetBuffer netbuf,
QVector  x,
QVector  y,
float  vely,
const Vector rotvel,
float  pos,
float  gravity,
float  radius,
const char *  filename,
BLENDFUNC  sr,
BLENDFUNC  ds,
const vector< string > &  dest,
const QVector orbitcent,
Unit parent,
const GFXMaterial ourmat,
const std::vector< GFXLightLocal > &  ligh,
int  faction,
string  fullname,
bool  inside_out,
ObjSerial  netcreate 
)
static

Definition at line 100 of file unit_factory_generic.cpp.

References NetBuffer::addChar(), NetBuffer::addFloat(), NetBuffer::addGFXLightLocal(), NetBuffer::addGFXMaterial(), NetBuffer::addInt32(), ZoneMgr::AddPlanet, NetBuffer::addQVector(), NetBuffer::addSerial(), NetBuffer::addShort(), NetBuffer::addString(), NetBuffer::addVector(), Unit::GetSerial(), i, j, QVector, and Vector.

120 {
121  netbuf.addChar( ZoneMgr::AddPlanet );
122  netbuf.addSerial( netcreate );
123  netbuf.addQVector( x );
124  netbuf.addQVector( y );
125  netbuf.addFloat( vely );
126  netbuf.addVector( Vector( rotvel ) );
127  netbuf.addFloat( pos );
128  netbuf.addFloat( gravity );
129  netbuf.addFloat( radius );
130 
131  netbuf.addString( string( filename ) );
132  netbuf.addChar( sr );
133  netbuf.addChar( ds );
134 
135  netbuf.addShort( dest.size() );
136  for (unsigned int i = 0; i < dest.size(); i++)
137  netbuf.addString( dest[i] );
138  netbuf.addQVector( QVector( orbitcent ) );
139  netbuf.addSerial( parent->GetSerial() );
140  netbuf.addGFXMaterial( ourmat );
141  netbuf.addShort( ligh.size() );
142  for (unsigned int j = 0; j < ligh.size(); j++)
143  netbuf.addGFXLightLocal( ligh[j] );
144  netbuf.addInt32( faction );
145  netbuf.addString( fullname );
146  netbuf.addChar( inside_out );
147 }
void UnitFactory::addUnitBuffer ( NetBuffer netbuf,
const string &  filename,
const string &  name,
const string &  fullname,
bool  SubUnit,
int  faction,
std::string  customizedUnit,
const ClientState curr_state,
Flightgroup flightgroup,
int  fg_subnumber,
string *  netxml,
ObjSerial  netcreate 
)
static

Definition at line 25 of file unit_factory_generic.cpp.

References NetBuffer::addChar(), NetBuffer::addClientState(), NetBuffer::addInt32(), NetBuffer::addSerial(), NetBuffer::addString(), NetBuffer::addTransformation(), ZoneMgr::AddUnit, ClientState::getTransformation(), Flightgroup::name, and NetBuffer::version().

Referenced by addBuffer(), and addUnitBuffer().

37 {
38  netbuf.addChar( ZoneMgr::AddUnit );
39  assert( netcreate != 0 ); //crash if we are doing something stupid :)
40  netbuf.addSerial( netcreate );
41  netbuf.addString( filename );
42  netbuf.addString( name );
43  netbuf.addString( fullname );
44  netbuf.addChar( SubUnit );
45  netbuf.addInt32( faction );
46  netbuf.addString( flightgroup != NULL ? flightgroup->name : std::string( "Object" ) );
47  netbuf.addString( customizedUnit );
48  netbuf.addInt32( fg_subnumber );
49  if (netbuf.version() <= 4951)
50  netbuf.addTransformation( curr_state.getTransformation() );
51  else
52  netbuf.addClientState( curr_state );
53 }
void UnitFactory::addUnitBuffer ( NetBuffer netbuf,
const Unit un,
string *  netxml = NULL 
)
static

Definition at line 55 of file unit_factory_generic.cpp.

References addUnitBuffer(), Unit::faction, Unit::fullname, Unit::getFgSubnumber(), Unit::getFilename(), Unit::getFlightgroup(), Unit::GetSerial(), Unit::isSubUnit(), and Unit::name.

56 {
57  addUnitBuffer( netbuf, un->getFilename(), un->name.get(), un->fullname, un->isSubUnit(), un->faction,
58  "" /* Not sure... maybe netxml will take care of this? */, ClientState( un ),
59  un->getFlightgroup(),
60  un->getFgSubnumber(), netxml /*For ENTERCLIENT, will generate a saved game netxml*/, un->GetSerial() );
61 }
void UnitFactory::broadcastUnit ( Unit un,
unsigned short  zone 
)
static

Definition at line 252 of file unit_factory.cpp.

Referenced by StarSystem::AddUnit().

252 {}
Asteroid * UnitFactory::createAsteroid ( const char *  filename,
int  faction,
Flightgroup fg = NULL,
int  fg_snumber = 0,
float  difficulty = .01,
ObjSerial  netcreate = 0 
)
static

Definition at line 233 of file unit_factory.cpp.

References KillDuplicateUnits(), and Unit::SetSerial().

Referenced by Mission::call_unit_launch(), and parseAsteroidBuffer().

239 {
240  Asteroid *ast = new GameAsteroid( filename,
241  faction,
242  fg,
243  fg_snumber,
244  difficulty );
245  if (netcreate) {
246  KillDuplicateUnits( netcreate );
247  ast->SetSerial( netcreate );
248  }
249  return ast;
250 }
Building * UnitFactory::createBuilding ( ContinuousTerrain parent,
bool  vehicle,
const char *  filename,
bool  SubUnit,
int  faction,
const std::string &  unitModifications = std::string( "" ),
Flightgroup fg = NULL 
)
static

Definition at line 199 of file unit_factory.cpp.

Referenced by createObjects().

206 {
207  return new GameBuilding( parent,
208  vehicle,
209  filename,
210  SubUnit,
211  faction,
212  unitModifications,
213  fg );
214 }
Building * UnitFactory::createBuilding ( Terrain parent,
bool  vehicle,
const char *  filename,
bool  SubUnit,
int  faction,
const std::string &  unitModifications = std::string( "" ),
Flightgroup fg = NULL 
)
static

Definition at line 216 of file unit_factory.cpp.

223 {
224  return new GameBuilding( parent,
225  vehicle,
226  filename,
227  SubUnit,
228  faction,
229  unitModifications,
230  fg );
231 }
ContinuousTerrain * UnitFactory::createContinuousTerrain ( const char *  file,
Vector  scale,
float  position,
Matrix t 
)
static

Definition at line 262 of file unit_factory.cpp.

References ContinuousTerrain::SetTransformation().

263 {
264  ContinuousTerrain *ct;
265  ct = new ContinuousTerrain( file, scale, position );
266  ct->SetTransformation( t );
267  return ct;
268 }
Enhancement * UnitFactory::createEnhancement ( const char *  filename,
int  faction,
const string &  modifications,
Flightgroup flightgrp = NULL,
int  fg_subnumber = 0 
)
static

Definition at line 186 of file unit_factory.cpp.

Referenced by AddUnitToSystem().

191 {
192  return new GameEnhancement( filename,
193  faction,
194  modifications,
195  flightgrp,
196  fg_subnumber );
197 }
Missile * UnitFactory::createMissile ( const char *  filename,
int  faction,
const string &  modifications,
const float  damage,
float  phasedamage,
float  time,
float  radialeffect,
float  radmult,
float  detonation_radius,
ObjSerial  netcreate = 0 
)
static

Definition at line 116 of file unit_factory.cpp.

References KillDuplicateUnits(), and Unit::SetSerial().

Referenced by Unit::EjectCargo(), parseMissileBuffer(), and Mount::PhysicsAlignedFire().

126 {
127  Missile *un = new GameMissile( filename,
128  faction,
129  modifications,
130  damage,
131  phasedamage,
132  time,
133  radialeffect,
134  radmult,
135  detonation_radius );
136  if (netcreate) {
137  KillDuplicateUnits( netcreate );
138  un->SetSerial( netcreate );
139  }
140  return un;
141 }
Nebula * UnitFactory::createNebula ( const char *  unitfile,
bool  SubU,
int  faction,
Flightgroup fg = NULL,
int  fg_snumber = 0,
ObjSerial  netcreate = 0 
)
static

Definition at line 97 of file unit_factory.cpp.

References KillDuplicateUnits(), and Unit::SetSerial().

Referenced by Mission::call_unit_launch(), and parseNebulaBuffer().

103 {
104  Nebula *neb = new GameNebula( unitfile,
105  SubU,
106  faction,
107  fg,
108  fg_snumber );
109  if (netcreate) {
110  KillDuplicateUnits( netcreate );
111  neb->SetSerial( netcreate );
112  }
113  return neb;
114 }
Planet * UnitFactory::createPlanet ( )
static

Definition at line 143 of file unit_factory.cpp.

Referenced by Planet::beginElement(), Mission::call_unit_launch(), and parsePlanetBuffer().

144 {
145  return new GamePlanet;
146 }
Planet * UnitFactory::createPlanet ( QVector  x,
QVector  y,
float  vely,
const Vector rotvel,
float  pos,
float  gravity,
float  radius,
const std::string &  filename,
const std::string &  technique,
const std::string &  unitname,
BLENDFUNC  blendsrc,
BLENDFUNC  blenddst,
const vector< string > &  dest,
const QVector orbitcent,
Unit parent,
const GFXMaterial ourmat,
const std::vector< GFXLightLocal > &  ligh,
int  faction,
string  fullname,
bool  inside_out = false,
ObjSerial  netcreate = 0 
)
static

Definition at line 150 of file unit_factory_server.cpp.

References _Universe, Universe::netLock(), and Unit::SetSerial().

171 {
172  _Universe->netLock( true );
173  Planet *p = new Planet( x, y, vely, rotvel, pos, gravity, radius,
174  filename, technique, unitname, dest, orbitcent, parent, faction,
175  fullname, inside_out, ligh.size() );
176  _Universe->netLock( false );
177  if (netcreate)
178  p->SetSerial( netcreate );
179 /*
180  * // False: Only allow creation through system files? Doesn't make sense to be able to dynamically generate these.
181  * // Could cause inconsistencies with new clients that just read system files.
182  * if ( false && !_Universe->netLocked()) {
183  * NetBuffer netbuf;
184  * // Send a packet to clients in order to make them create this unit
185  *
186  * addPlanetBuffer( netbuf, x, y, vely, rotvel, pos, gravity, radius, filename, sr, ds, dest, orbitcent, parent, ourmat, ligh, faction, fullname, inside_out, netcreate);
187  * endBuffer( netbuf );
188  * VSServer->broadcast( netbuf, 0, _Universe->activeStarSystem()->GetZone(), CMD_ENTERCLIENT, true);
189  * }
190  * VSServer->invalidateSnapshot();
191  */
192  return p;
193 }
Unit * UnitFactory::createServerSideUnit ( const char *  filename,
bool  SubUnit,
int  faction,
std::string  customizedUnit = string(                                            "" ),
Flightgroup flightgroup = NULL,
int  fg_subnumber = 0 
)
static

Definition at line 75 of file unit_factory.cpp.

Referenced by makeBlankUpgrade(), and Unit::UpAndDownGrade().

81 {
82  return new Unit( filename,
83  SubUnit,
84  faction,
85  customizedUnit,
86  flightgroup,
87  fg_subnumber );
88 }
Terrain * UnitFactory::createTerrain ( const char *  file,
Vector  scale,
float  position,
float  radius,
Matrix t 
)
static

Definition at line 254 of file unit_factory.cpp.

References Terrain::SetTransformation().

255 {
256  Terrain *tt;
257  tt = new Terrain( file, scale, position, radius );
258  tt->SetTransformation( t );
259  return tt;
260 }
Unit * UnitFactory::createUnit ( const char *  filename,
bool  SubUnit,
int  faction,
std::string  customizedUnit = string(                                  "" ),
Flightgroup flightgroup = NULL,
int  fg_subnumber = 0,
string *  netxml = NULL,
ObjSerial  netcreate = 0 
)
static

Definition at line 54 of file unit_factory.cpp.

References StarSystemGent::faction, KillDuplicateUnits(), and Unit::SetSerial().

62 {
63  Unit *un = new GameUnit< Unit > ( filename,
64  SubUnit,
65  faction,
66  customizedUnit,
67  flightgroup,
68  fg_subnumber, netxml );
69  if (netcreate) {
70  KillDuplicateUnits( netcreate );
71  un->SetSerial( netcreate );
72  }
73  return un;
74 }
static Unit* UnitFactory::createUnit ( std::vector< Mesh * > &  meshes,
bool  Subunit,
int  faction 
)
static
void UnitFactory::endBuffer ( NetBuffer netbuf)
static

Definition at line 391 of file unit_factory_generic.cpp.

References NetBuffer::addChar(), and ZoneMgr::End.

Referenced by NetServer::sendNewUnitQueue().

392 {
393  netbuf.addChar( ZoneMgr::End );
394 }
Unit * UnitFactory::getMasterPartList ( )
static

Definition at line 12 of file unit_factory_generic.cpp.

References _masterPartList, and Unit::makeMasterPartList().

Referenced by Unit::GetCargo(), UniverseUtil::GetMasterPartList(), GetUnitMasterPartList(), Unit::PriceCargo(), and Unit::RepairUpgrade().

13 {
14  if (_masterPartList == NULL) {
15  static bool making = true;
16  if (making) {
17  making = false;
19  making = true;
20  }
21  }
22  return _masterPartList;
23 }
Asteroid * UnitFactory::parseAsteroidBuffer ( NetBuffer netbuf)
static

Definition at line 346 of file unit_factory_generic.cpp.

References createAsteroid(), StarSystemGent::faction, accountXML::file, Mission::findFlightgroup(), FactionUtil::GetFactionName(), NetBuffer::getFloat(), NetBuffer::getInt32(), NetBuffer::getSerial(), NetBuffer::getString(), and mission.

Referenced by NetClient::AddObjects().

347 {
348  ObjSerial serial = netbuf.getSerial();
349  string file( netbuf.getString() );
350  int faction = netbuf.getInt32();
351  string fname( netbuf.getString() );
352  int fg_snumber = netbuf.getInt32();
353  float diff = netbuf.getFloat();
354 
355  cerr<<"NETCREATE ASTEROID : "<<file<<endl;
356 
357  string facname = FactionUtil::GetFactionName( faction );
358  if ( facname.empty() ) {
359  //Got an invalid faction number...
360  cerr<<" Asteroid has an invalid faction "<<faction<<endl;
361  faction = 0;
362  }
363  Flightgroup *fg = mission[0].findFlightgroup( fname, facname );
364 
365  return UnitFactory::createAsteroid( file.c_str(), faction, fg, fg_snumber, diff, serial );
366 }
Missile * UnitFactory::parseMissileBuffer ( NetBuffer netbuf)
static

Definition at line 288 of file unit_factory_generic.cpp.

References createMissile(), Unit::curr_physical_state, StarSystemGent::faction, accountXML::file, Unit::fullname, NetBuffer::getClientState(), FactionUtil::GetFactionName(), NetBuffer::getFloat(), NetBuffer::getInt32(), NetBuffer::getSerial(), NetBuffer::getString(), NetBuffer::getTransformation(), Unit::name, ClientState::setUnitState(), and NetBuffer::version().

Referenced by NetClient::AddObjects().

289 {
290  ObjSerial serial = netbuf.getSerial();
291  string file( netbuf.getString() );
292  string name( netbuf.getString() );
293  string fullname( netbuf.getString() );
294  int faction = netbuf.getInt32();
295  string mods( netbuf.getString() );
296  const float damage( netbuf.getFloat() );
297  float phasedamage = netbuf.getFloat();
298  float time = netbuf.getFloat();
299  float radialeffect = netbuf.getFloat();
300  float radmult = netbuf.getFloat();
301  float detonation_radius = netbuf.getFloat();
302  const string modifs( mods );
303 
304  cerr<<"NETCREATE MISSILE : "<<file<<" ("<<serial<<")"<<endl;
305 
306  string facname = FactionUtil::GetFactionName( faction );
307  if ( facname.empty() ) {
308  //Got an invalid faction number...
309  cerr<<" Missile has an invalid faction "<<faction<<endl;
310  faction = 0;
311  }
312  Missile *mis = createMissile(
313  file.c_str(), faction, modifs, damage, phasedamage, time, radialeffect, radmult, detonation_radius, serial );
314  if (netbuf.version() <= 4951)
315  mis->curr_physical_state = netbuf.getTransformation();
316  else
317  netbuf.getClientState().setUnitState( mis );
318  mis->name = name;
319  mis->fullname = fullname;
320  return mis;
321 }
Nebula * UnitFactory::parseNebulaBuffer ( NetBuffer netbuf)
static

Definition at line 224 of file unit_factory_generic.cpp.

References createNebula(), StarSystemGent::faction, accountXML::file, Mission::findFlightgroup(), NetBuffer::getChar(), FactionUtil::GetFactionName(), NetBuffer::getInt32(), NetBuffer::getSerial(), NetBuffer::getString(), and mission.

Referenced by NetClient::AddObjects().

225 {
226  ObjSerial serial = netbuf.getSerial();
227  string file( netbuf.getString() );
228  bool sub = netbuf.getChar();
229  int faction = netbuf.getInt32();
230  string fname( netbuf.getString() );
231  int fg_num = netbuf.getInt32();
232 
233  cerr<<"NETCREATE NEBULA : "<<file<<endl;
234 
235  string facname = FactionUtil::GetFactionName( faction );
236  if ( facname.empty() ) {
237  //Got an invalid faction number...
238  cerr<<" Nebula has an invalid faction "<<faction<<endl;
239  faction = 0;
240  }
241  Flightgroup *fg = mission[0].findFlightgroup( fname, facname );
242  return UnitFactory::createNebula( file.c_str(), sub, faction, fg, fg_num, serial );
243 }
Planet * UnitFactory::parsePlanetBuffer ( NetBuffer netbuf)
static

Definition at line 149 of file unit_factory_generic.cpp.

References createPlanet(), StarSystemGent::faction, accountXML::file, NetBuffer::getChar(), FactionUtil::GetFactionName(), NetBuffer::getFloat(), NetBuffer::getGFXLightLocal(), NetBuffer::getGFXMaterial(), NetBuffer::getInt32(), NetBuffer::getQVector(), NetBuffer::getSerial(), NetBuffer::getShort(), NetBuffer::getString(), UniverseUtil::GetUnitFromSerial(), NetBuffer::getVector(), i, StarSystemGent::lights, VsnetOSS::memcpy(), QVector, Vector, x, and y.

Referenced by NetClient::AddObjects().

150 {
151  ObjSerial serial = netbuf.getSerial();
152  QVector x = netbuf.getQVector();
153  QVector y = netbuf.getQVector();
154  float vely = netbuf.getFloat();
155  const Vector rotvel( netbuf.getVector() );
156  float pos = netbuf.getFloat();
157  float gravity = netbuf.getFloat();
158  float radius = netbuf.getFloat();
159 
160  string file( netbuf.getString() );
161  char sr = netbuf.getChar();
162  char ds = netbuf.getChar();
163 
164  vector< string >dest;
165  unsigned short nbdest = netbuf.getShort();
166  int i = 0;
167  for (i = 0; i < nbdest; i++) {
168  string tmp( netbuf.getString() );
169  char *ctmp = new char[tmp.length()+1];
170  ctmp[tmp.length()] = 0;
171  memcpy( ctmp, tmp.c_str(), tmp.length() );
172  dest.push_back( ctmp );
173  }
174  const QVector orbitcent( netbuf.getQVector() );
176  GFXMaterial mat = netbuf.getGFXMaterial();
177 
178  vector< GFXLightLocal >lights;
179  unsigned short nblight = netbuf.getShort();
180  for (i = 0; i < nblight; i++)
181  lights.push_back( netbuf.getGFXLightLocal() );
182  int faction = netbuf.getInt32();
183 
184  string facname = FactionUtil::GetFactionName( faction );
185  if ( facname.empty() ) {
186  //Got an invalid faction number...
187  cerr<<" Planet "<<file<<" has an invalid faction "<<faction<<endl;
188  faction = 0;
189  }
190  string fullname( netbuf.getString() );
191  char insideout = netbuf.getChar();
192 
193  cerr<<"NETCREATE PLANET : "<<file<<endl;
194 
195  return UnitFactory::createPlanet( x, y, vely, rotvel, pos, gravity, radius,
196  file, string(), string(),
197  (BLENDFUNC) sr, (BLENDFUNC) ds, dest, orbitcent, un, mat, lights, faction, fullname,
198  insideout, serial );
199 }
Unit * UnitFactory::parseUnitBuffer ( NetBuffer netbuf)
static

Definition at line 63 of file unit_factory_generic.cpp.

References createUnit(), Unit::curr_physical_state, StarSystemGent::faction, accountXML::file, Mission::findFlightgroup(), Unit::fullname, NetBuffer::getChar(), NetBuffer::getClientState(), FactionUtil::GetFactionName(), NetBuffer::getInt32(), NetBuffer::getSerial(), NetBuffer::getString(), NetBuffer::getTransformation(), mission, Unit::name, Flightgroup::newFlightgroup(), ClientState::setUnitState(), and NetBuffer::version().

Referenced by NetClient::AddObjects().

64 {
65  ObjSerial serial = netbuf.getSerial();
66  string file( netbuf.getString() );
67  string name( netbuf.getString() );
68  string fullname( netbuf.getString() );
69  bool sub = netbuf.getChar();
70  int faction = netbuf.getInt32();
71  string fname( netbuf.getString() );
72  string custom( netbuf.getString() );
73  int fg_num = netbuf.getInt32();
74 
75  cerr<<"NETCREATE UNIT : "<<file<<" ("<<serial<<")"<<endl;
76 
77  string facname = FactionUtil::GetFactionName( faction );
78  if ( facname.empty() ) {
79  //Got an invalid faction number...
80  cerr<<" Unit has an invalid faction "<<faction<<endl;
81  faction = 0;
82  }
83  Flightgroup *fg = NULL;
84  if ( !fname.empty() ) {
85  fg = mission[0].findFlightgroup( fname, facname );
86  if (!fg)
87  fg = Flightgroup::newFlightgroup( fname, file, facname,
88  "default", 1, 1, "", "", mission );
89  }
90  Unit *un = createUnit( file.c_str(), sub, faction, custom, fg, fg_num, NULL, serial );
91  if (netbuf.version() <= 4951)
93  else
94  netbuf.getClientState().setUnitState( un );
95  un->name = name;
96  un->fullname = fullname;
97  return un;
98 }

Member Data Documentation

Unit * UnitFactory::_masterPartList = NULL
staticprotected

Definition at line 43 of file unit_factory.h.

Referenced by getMasterPartList().


The documentation for this class was generated from the following files: