MCPcopy Create free account
hub / github.com/chrxh/alien / getNewCreatureId

Function getNewCreatureId

source/EngineInterface/DescriptionEditService.cpp:563–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561namespace
562{
563 int getNewCreatureId(int origCreatureId, std::unordered_map<int, int>& origToNewCreatureIdMap)
564 {
565 auto findResult = origToNewCreatureIdMap.find(origCreatureId);
566 if (findResult != origToNewCreatureIdMap.end()) {
567 return findResult->second;
568 } else {
569 int newCreatureId = 0;
570 while (newCreatureId == 0) {
571 newCreatureId = NumberGenerator::get().getRandomInt();
572 }
573 origToNewCreatureIdMap.emplace(origCreatureId, newCreatureId);
574 return newCreatureId;
575 }
576 };
577
578}
579

Callers 1

Calls 3

findMethod · 0.80
endMethod · 0.80
getRandomIntMethod · 0.80

Tested by

no test coverage detected