MCPcopy Create free account
hub / github.com/TurningWheel/Barony / setSpriteAttributes

Function setSpriteAttributes

src/entity_shared.cpp:2469–3190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2467}
2468
2469void setSpriteAttributes(Entity* entityNew, Entity* entityToCopy, Entity* entityStatToCopy)
2470{
2471 Stat* tmpStats = nullptr;
2472 if ( !entityNew )
2473 {
2474 return;
2475 }
2476
2477 if ( entityStatToCopy != nullptr )
2478 {
2479 tmpStats = entityStatToCopy->getStats();
2480 }
2481
2482 int spriteType = checkSpriteType(entityNew->sprite);
2483 // monsters.
2484 if ( spriteType == 1 )
2485 {
2486 //STAT ASSIGNMENT
2487 Stat* myStats = nullptr;
2488 if ( multiplayer != CLIENT )
2489 {
2490 // need to give the entity its list stuff.
2491 // create an empty first node for traversal purposes
2492 node_t* node2 = list_AddNodeFirst(&entityNew->children);
2493 node2->element = nullptr;
2494 node2->deconstructor = &emptyDeconstructor;
2495
2496 node2 = list_AddNodeLast(&entityNew->children);
2497 if ( tmpStats != nullptr )
2498 {
2499 node2->element = tmpStats->copyStats();
2500 node2->size = sizeof(tmpStats);
2501 }
2502 else
2503 {
2504 // if the previous sprite did not have stats initialised, or creating a new entity.
2505 myStats = new Stat(entityNew->sprite);
2506 node2->element = myStats;
2507 node2->size = sizeof(myStats);
2508 }
2509 node2->deconstructor = &statDeconstructor;
2510 }
2511 }
2512 // chests.
2513 else if ( spriteType == 2 )
2514 {
2515 if ( entityToCopy != nullptr )
2516 {
2517 // copy old entity attributes to newly created.
2518 entityNew->yaw = entityToCopy->yaw;
2519 entityNew->skill[9] = entityToCopy->skill[9];
2520 entityNew->chestLocked = entityToCopy->chestLocked;
2521 entityNew->chestMimicChance = entityToCopy->chestMimicChance;
2522 }
2523 else
2524 {
2525 // set default new entity attributes.
2526 entityNew->yaw = 1;

Callers 11

makeUndoFunction · 0.85
undoFunction · 0.85
redoFunction · 0.85
mainFunction · 0.85
loadMapFunction · 0.85
doNewGameFunction · 0.85
buttonCycleSpritesFunction · 0.85
summonChestFunction · 0.85
generateDungeonFunction · 0.85
assignActionsFunction · 0.85

Calls 5

checkSpriteTypeFunction · 0.85
list_AddNodeFirstFunction · 0.85
list_AddNodeLastFunction · 0.85
getStatsMethod · 0.45
copyStatsMethod · 0.45

Tested by

no test coverage detected