[DiscordArchive] should be only value?
[DiscordArchive] should be only value?
Archived author: CyberMist2 • Posted: 2023-01-25T18:57:00.222000+00:00
Original source
or is the code from above correct at least?
Archived author: jackpoz • Posted: 2023-01-25T18:57:02.300000+00:00
Original source
the last code you wrote is an improvement, but you are focusing too much on health fields
Archived author: jackpoz • Posted: 2023-01-25T18:57:17.272000+00:00
Original source
if (index == UNIT_FIELD_HEALTH || index == UNIT_FIELD_MAXHEALTH)
...
fieldBuffer << value;
Archived author: jackpoz • Posted: 2023-01-25T18:57:47.500000+00:00
Original source
what happens if index is not any health field ? well, your code never calls fieldBuffer << m_uint32Values[index] or fieldBuffer << value in that case
Archived author: CyberMist2 • Posted: 2023-01-25T18:58:06.123000+00:00
Original source
let me redo
Archived author: jackpoz • Posted: 2023-01-25T18:58:17.525000+00:00
Original source
other than that it's probably the most correct code you wrote
Archived author: CyberMist2 • Posted: 2023-01-25T18:58:28.732000+00:00
Original source
```c++
for (uint16 index = 0; index < m_valuesCount; ++index)
{
if (_fieldNotifyFlags & flags[index] ||
((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)))
{
updateMask.SetBit(index);
if (isType(TYPEMASK_UNIT))
{
if (index == UNIT_FIELD_HEALTH || index == UNIT_FIELD_MAXHEALTH)
{
uint32 value = m_uint32Values[index];
switch (index)
{
case UNIT_FIELD_HEALTH: value = uint32(ceil((100.0 * value) / m_uint32Values[UNIT_FIELD_MAXHEALTH])); break;
case UNIT_FIELD_MAXHEALTH: value = 100; break;
}
fieldBuffer << value;
}
fieldBuffer << m_uint32Values[index];
}
else
fieldBuffer << m_uint32Values[index];
}
}
```
Archived author: jackpoz • Posted: 2023-01-25T18:58:39.166000+00:00
Original source
also, really important, when writing code assume that the code is always wrong
Archived author: jackpoz • Posted: 2023-01-25T18:59:06.494000+00:00
Original source
you need to debug it, setting breakpoints, use "step into" and "step over" and "step out" in your debugging IDE (VS is just the best)
Archived author: CyberMist2 • Posted: 2023-01-25T18:59:13.983000+00:00
Original source
hmm