Fixed issue where hitdata read wrong memory.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-08-04 12:22:05 +02:00
parent 08ef84f6d6
commit f38161f573
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 2 additions and 2 deletions

View File

@ -24,7 +24,7 @@ namespace CreatureLib::Battling {
public: public:
EventHook() : _offset(0), _capacity(defaultSize) { EventHook() : _offset(0), _capacity(defaultSize) {
auto ptr = calloc(defaultSize, 1); auto ptr = malloc(_capacity);
if (ptr == nullptr) { if (ptr == nullptr) {
THROW_CREATURE("Out of memory."); THROW_CREATURE("Out of memory.");
} }

View File

@ -63,7 +63,7 @@ namespace CreatureLib::Battling {
HitData& GetHitData(Creature* creature, uint8_t hit) { HitData& GetHitData(Creature* creature, uint8_t hit) {
for (uint8_t i = 0; i < _targetCount; i++) { for (uint8_t i = 0; i < _targetCount; i++) {
if (_targets[i] == creature) { if (_targets[i] == creature) {
return _hits[i * _numberHits + hit]; return _hits[(i * _numberHits + hit) * sizeof(HitData)];
} }
} }
THROW_CREATURE("Invalid target requested."); THROW_CREATURE("Invalid target requested.");