Files
wowdecomp/Engine/Source/ComSat/ComSatRunningAverageCalculator.cpp
SatyandClaude Opus 5.5 82879a879d Port the last non-anti-cheat functions: ServerLink, PetAction, emitter params
- Grunt::ServerLink: all CMD_GRUNT_* handlers, send helpers, features/strings, command table 0xB24D70,
  s_localeIds 0xAD3004, Pending::Remove (dead server-side link, docs/0x008CE200.md); ServerLink.h stub removed
- PetAction type for CGPetInfo::m_actions / pet spell actions / cursor pet action, SetAutocast 0x5D32F0
- CParticleEmitter2 fields 0x98-0x11F moved into CParticleEmitter2::Params (ctor 0x979250)
- fixed16(float), C3Vector::FlushDenormals, CGxuLightQueue + static 0xC7C074, CAaSphere(), CMapLowDetail(),
  C2Vector()/C4Plane() out of line, SpellHistory dtor, CGDynamicObject_C GetScale/GetRawFacing
- DB record operator= (PetNameCache, CGPetition, DanceCache): fixes the shallow-copy double free in AddItem
- ClientSetTimer(delay, handler, param) with its five callers, IOMd5Unit::Create without container,
  CDataStore::GetByte / Get(int32_t&), WDataStore::GetHeaderSpace, TSHashTable::Head, TSList::IsEmpty
- CameraTurnPlayer calls CVehicleCamera_C::IsTransitioningFacing 0x5FAA10 (was IsHierarchyChasingFacing)
- OFFSET additions: TSHashTable::Unlink, TInstanceId dtor, DBCACHEHASH dtor (+ ItemNameCache_C dtor),
  CDataStoreCache ctor, BitUnpacker/RunningAverageCalculator deleting dtors, CGTooltip::GetObjectType

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-04 08:10:06 +02:00

58 lines
1.6 KiB
C++

#include "Engine/Source/ComSat/ComSatRunningAverageCalculator.h"
// VERIFY: 08159cc8 auto
// OFFSET: 0x00886600
ComSat::RunningAverageCalculator::RunningAverageCalculator(ComSat::Allocator& allocator) {
this->m_sum = 0.0;
this->m_allocator = &allocator;
this->m_values = nullptr;
this->m_count = 0;
this->m_index = 0;
}
// VERIFY: 94225611 auto
// OFFSET: [0x00886750, 0x00886790]
ComSat::RunningAverageCalculator::~RunningAverageCalculator() {
if (this->m_values) {
this->m_allocator->Free(this->m_values);
this->m_values = nullptr;
}
this->m_count = 0;
this->m_sum = 0.0;
this->m_index = 0;
}
// VERIFY: fac249da manual
// OFFSET: 0x00886630
void ComSat::RunningAverageCalculator::Init(double value, uint32_t count) {
if (this->m_values) {
this->m_allocator->Free(this->m_values);
this->m_values = nullptr;
}
this->m_sum = 0.0;
this->m_count = 0;
this->m_index = 0;
this->m_values = static_cast<double*>(this->m_allocator->Alloc(sizeof(double) * count));
this->m_count = count;
for (uint32_t i = 0; i < count; i++) {
this->m_values[i] = value;
this->m_sum += value;
}
}
// VERIFY: daa1cb75 auto
// OFFSET: 0x008866F0
void ComSat::RunningAverageCalculator::SubmitData(double value) {
if (this->m_values) {
this->m_sum = this->m_sum - this->m_values[this->m_index] + value;
this->m_values[this->m_index] = value;
this->m_index = (this->m_index + 1) % this->m_count;
}
}
// VERIFY: e888bf5d auto
// OFFSET: 0x00886730
double ComSat::RunningAverageCalculator::GetCurrentAverage() {
return this->m_sum / this->m_count;
}