MCPcopy Create free account
hub / github.com/bwapi/bwapi / updateData

Method updateData

bwapi/BWAPI/Source/BWAPI/BulletImpl.cpp:52–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 return BroodwarImpl.getBulletFromIndex(index);
51 }
52 void BulletImpl::updateData()
53 {
54 bool _exists = __exists && bwOriginalBullet;
55 if ( _exists )
56 {
57 for(int i = 0; i < 9; ++i)
58 {
59 PlayerImpl* player = static_cast<PlayerImpl*>(Broodwar->getPlayer(i));
60
61 if ( !bwOriginalBullet->sprite || !player )
62 self->isVisible[i] = false;
63 else if ( BWAPI::BroodwarImpl.isFlagEnabled(Flag::CompleteMapInformation) )
64 self->isVisible[i] = true;
65 else
66 self->isVisible[i] = Broodwar->isVisible( TilePosition(bwOriginalBullet->sprite->position) );
67 }
68 }
69 else
70 {
71 MemZero(self->isVisible);
72 }
73
74 if ( _exists &&
75 (BWAPI::BroodwarImpl.isFlagEnabled(Flag::CompleteMapInformation) ||
76 BroodwarImpl.isReplay() ||
77 isVisible()) )
78 {
79 UnitImpl *_getSource = UnitImpl::BWUnitToBWAPIUnit(bwOriginalBullet->sourceUnit);
80 UnitImpl *_getTarget = UnitImpl::BWUnitToBWAPIUnit(bwOriginalBullet->attackTarget.pUnit);
81 Player _getPlayer = _getSource ? _getSource->_getPlayer : nullptr;
82
83 // id, player, type, source
84 self->id = id;
85 self->player = (_getSource && _getSource->isAlive && _getPlayer) ? _getPlayer->getID() : -1;
86 self->type = bwOriginalBullet->type;
87 self->source = (_getSource && _getSource->exists()) ? _getSource->getID() : -1;
88
89 // position
90 self->positionX = bwOriginalBullet->position.x;
91 self->positionY = bwOriginalBullet->position.y;
92
93 // angle, velocity
94 int d = (int)bwOriginalBullet->currentDirection - 64;
95 if ( d < 0 )
96 d += 256;
97 self->angle = (double)d * 3.14159265358979323846 / 128.0;
98 self->velocityX = (double)(bwOriginalBullet->current_speed.x / 256.0);
99 self->velocityY = (double)(bwOriginalBullet->current_speed.y / 256.0);
100
101 // target, targetPosition
102 self->target = (_getTarget && _getTarget->exists()) ? _getTarget->getID() : -1;
103 self->targetPositionX = bwOriginalBullet->targetPosition.x;
104 self->targetPositionY = bwOriginalBullet->targetPosition.y;
105
106 // removeTimer
107 self->removeTimer = bwOriginalBullet->time_remaining;
108
109 // exists

Callers

nothing calls this directly

Calls 7

MemZeroFunction · 0.50
getPlayerMethod · 0.45
isFlagEnabledMethod · 0.45
isVisibleMethod · 0.45
isReplayMethod · 0.45
getIDMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected