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

Method Setup

trinity/Eve/SpaceObjectFactory/EveSOFDNA.cpp:216–332  ·  view source on GitHub ↗

-------------------------------------------------------------------------------- Description: Set a complete dna string to this dna --------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

214// Set a complete dna string to this dna
215// --------------------------------------------------------------------------------
216void EveSOFDNA::Setup( const char* dnaString, EveSOFDataMgrPtr dataMgr )
217{
218 CCP_STATS_ZONE( __FUNCTION__ );
219
220 std::vector<std::string> commandArgs;
221
222 // rember dna string
223 m_dna = dnaString;
224
225 // remember the pointer to the BIG lib as long as this DNA object lives
226 m_dataMgr = dataMgr;
227
228 // split up dna string in all subparts
229 std::vector<std::string> dnaParts;
230 StringSplit( dnaParts, dnaString, s_dnaSeperatorCmd );
231
232 // need three at least
233 if( dnaParts.size() < 3 )
234 {
235 CCP_LOGERR( "Invalid SOF DNA, not enough subparts: %s", dnaString );
236 return;
237 }
238
239 // additional dna subparts
240 for( size_t dnaSubpart = 3; dnaSubpart < dnaParts.size(); ++dnaSubpart )
241 {
242 // split into command and args
243 StringSplit( commandArgs, dnaParts[dnaSubpart].c_str(), s_dnaSeperatorArg );
244 if( commandArgs.size() != 2 )
245 {
246 CCP_LOGERR( "Invalid SOF DNA, incorrect command and args: %s", dnaString );
247 return;
248 }
249
250 // get commands
251 std::vector<std::string> commandList;
252 StringSplit( commandList, commandArgs[1].c_str(), s_dnaSeperatorList );
253
254 // put into map, warning: this might overwrite a similar command!
255 m_commands[commandArgs[0]] = commandList;
256 commandArgs.clear();
257 }
258
259 // the main dna hull can be a list (multi-hulls)
260 StringSplit( m_hullNames, dnaParts[0].c_str(), s_dnaSeperatorList );
261 if( m_hullNames.empty() )
262 {
263 CCP_LOGERR( "Couldn't find at least one hull name: %s", dnaString );
264 return;
265 }
266
267 // part 2 and 3 is faction and race
268 m_factionName = dnaParts[1];
269 m_raceName = dnaParts[2];
270
271 // make sure we find this hull(s)
272 m_hullDatas.clear();
273 for( auto it = m_hullNames.begin(); it != m_hullNames.end(); ++it )

Callers 11

CreateDnaMethod · 0.45
ValidateDNAMethod · 0.45
SetupSpriteLineSetsMethod · 0.45
SetupHazeSetsMethod · 0.45
SetupEffectChildrenMethod · 0.45
SetupInstancedMeshesMethod · 0.45
SetupCustomMaskMethod · 0.45
SetupImpactEffectsMethod · 0.45

Calls 14

StringSplitFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.80
GetHullDataMethod · 0.80
GetFactionDataMethod · 0.80
GetRaceDataMethod · 0.80
GetPatternDataMethod · 0.80
GetGenericDataMethod · 0.80
GetDnaCommandArgsMethod · 0.80
HasDnaCommandMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected