MCPcopy Create free account
hub / github.com/carbonengine/trinity / RebuildTurretPositions

Method RebuildTurretPositions

trinity/Eve/SpaceObject/EveMobile.cpp:480–597  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: Checks all attached turret sets for the number of single turrets this set has, then tries to find this locator and it's type: granny bone or jessica locator. Finally we tell the turret about its position and store some of this data in a vector for future use. Special case locators are fitted sequencially

Source from the content-addressed store, hash-verified

478// EveTurretSet, EveLocatorType, GetTurretCount, GetLocatorTransform
479// --------------------------------------------------------------------------------
480void EveMobile::RebuildTurretPositions()
481{
482 // all new
483 m_turretSetsLocatorInfo.clear();
484 ResetTurretLocatorCounter( false );
485
486 for( auto it = m_turretSets.begin(); it != m_turretSets.end(); ++it )
487 {
488 // turret knows unique name
489 std::string name = ( *it )->GetLocatorName();
490
491 // prepare a new locatorInfo entry
492 TurretSetLocatorInfo locatorInfo;
493
494 bool turretInName = false;
495
496 unsigned int locatorNumber = 0;
497
498 // Check whether this is a standard turret locator or a special case
499 size_t found = name.find( "_turret_" );
500 if( found != std::string::npos )
501 {
502 turretInName = true;
503 }
504
505 if( !turretInName )
506 {
507 unsigned int totalNumber = 0;
508 // Check whether we have a locator with the name
509 if( !GetTurretLocatorCountingInfo( name.c_str(), locatorNumber, totalNumber ) )
510 {
511 // Replace the locatorName with "locator_turret_" as a fallback
512 name = "locator_turret_";
513 // Try again
514 if( !GetTurretLocatorCountingInfo( name.c_str(), locatorNumber, totalNumber ) )
515 {
516 CCP_LOGWARN( "Unable to get valid locator count for '%s'", name.c_str() );
517 continue;
518 }
519 turretInName = true;
520 }
521 // Check whether we have an empty slot
522 if( locatorNumber > totalNumber )
523 {
524 if( !turretInName )
525 {
526 // Replace the locatorName with "locator_turret_" as a fallback
527 name = "locator_turret_";
528 // Try again
529 if( !GetTurretLocatorCountingInfo( name.c_str(), locatorNumber, totalNumber ) )
530 {
531 CCP_LOGWARN( "Unable to get valid locator count for '%s'", name.c_str() );
532 continue;
533 }
534 }
535 else
536 {
537 CCP_LOGWARN( "Unable to get valid locator count for '%s'. Too many turrets used even with fallback", name.c_str() );

Callers

nothing calls this directly

Calls 6

GetLocatorNameMethod · 0.80
GetSlotNumberMethod · 0.80
SetLocalTransformMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
SetShaderOptionMethod · 0.45

Tested by

no test coverage detected