EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   base_data, Shared memory, t_start_server_with_login_server.bat, 2x enemy dmg hp (https://www.eqemulator.org/forums/showthread.php?t=43671)

Ryuichi 07-11-2022 03:49 PM

HP lost is 2x Dmg Taken
 
When in combat, the combat log will show, "x hits for 4 damage". However, when looking at my hitpoints in my inventory window, and at the hitpoint % on my health bar, I'm seeing 2x enemy damage reflected. I.e., I see HP: 92/100 (-8 hp), and 92%, respectively. Has anyone else experienced this, or have any immediate thoughts, before I put myself through the displeasure of suffering through the hot mess that is the server code?


Also, should the files in .\eqemu\shared\ folder rebuild with each server launch? Mine do not, unless I manually delete them first. Is this the intended behavior?

Ryuichi 07-11-2022 04:04 PM

Revised my original post, so this response is no longer relevant.

Ryuichi 07-12-2022 05:43 PM

I believe this to be a bug in the below code, and will post in the Bug section accordingly. For the sake of others, I'll include my findings here as well.

In mob.cpp, in the Mob::SendHPUpdate function, the cur_hp and max_hp values set in the packet are reduced by any HP gained from items. This is resulting in the client showing 2x the damage taken, both in the inventory window and on the health bar.

Code:

void Mob::SendHPUpdate(bool force_update_all)
{

        // If our HP is different from last HP update call - let's update selves
        if (IsClient()) {
                if (current_hp != last_hp || force_update_all) {

                        LogHPUpdate(
                                "[SendHPUpdate] Update HP of self [{}] current_hp [{}] max_hp [{}] last_hp [{}]",
                                GetCleanName(), current_hp, max_hp, last_hp
                        );

                        auto client_packet    = new EQApplicationPacket(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct));
                        auto *hp_packet_client = (SpawnHPUpdate_Struct *) client_packet->pBuffer;

                        hp_packet_client->cur_hp = static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
                        hp_packet_client->spawn_id = GetID();
                        hp_packet_client->max_hp = CastToClient()->GetMaxHP() - itembonuses.HP;

                        CastToClient()->QueuePacket(client_packet);

                        safe_delete(client_packet);

                        ResetHPUpdateTimer();

                        // Used to check if HP has changed to update self next round
                        last_hp = current_hp;
                }
        }
        ...

By making the following change, to remove the reduction of HP granted by items, the client is now showing values consistent with what the server is reporting.
Code:

hp_packet_client->cur_hp = CastToClient()->GetHP(); // static_cast<uint32>(CastToClient()->GetHP() - itembonuses.HP);
hp_packet_client->spawn_id = GetID();
hp_packet_client->max_hp = CastToClient()->GetMaxHP(); // CastToClient()->GetMaxHP() - itembonuses.HP;



All times are GMT -4. The time now is 11:07 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.