EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Development (https://www.eqemulator.org/forums/forumdisplay.php?f=590)
-   -   Client::OPMemorizeSpell (https://www.eqemulator.org/forums/showthread.php?t=38368)

Bonehard 06-10-2014 01:23 AM

Client::OPMemorizeSpell
 
Hello all,
first i'am not sure where to post this under wich dev section.
So feel free to move to the correct section. :)

I'am working on some code and have find a strange bug and not sure where this comes from.

I have add some code to the Client::OPMemorizeSpell function.
Code:

        // Custom - Used for disabling scribes more than given number
        if (disableScribe)
        {
                // Count scribed spells
                int iScribed = 0;
                for (int i = 0; i < MAX_PP_SPELLBOOK; i++)
                {
                        if (m_pp.spell_book[i] != 0xFFFFFFFF)
                                iScribed++;
                }

                // check if we reached the maximum client can scribe spells
                if (iScribed >= numMaxScribeSpells)
                {
                        Message(13, "Maximum spells scribed. Please unscripe some spells.");
                        return;
                }
        }

The code is very simple it checks just if the user can scribe a spell or max number is reached. For example i disable scribing after 10 spells so that the user will get the message above.

The code works so far when a user tries to scribe a spell and reached the maximum scribe number he gets this message and the spells will not be scribed.

So far so good. :)
But on the client something strange happend.
The user get the info from server spell is not scribed but the gui is not responding anymore.
I can't click on npc's or door's.
Keys also don't work anymore so i cant open any windows like inventory.
I can open dialogs like inventory only over the menu.
Buttons stills works but it seems the gui is not responding anymore to hotkeys.
If i open one of the dialogs like inventory over the menu it shows up but it takes no input from mouse.
This happend to any menu i call over the menu.
I can click into the chat input window and still can type some commands.
So when i use the #zone command to leave the zone the gui seems to work like it should.
It only happend when i try to use the custom code i posted above.

Some more infos:
I compile under windows with visual studion 2013 in X64 mode.

The client iam testing at the moment is underfoot(steam).

Thanks in advance!!!
(Going to work now. Maybe i can respond later from work.)

Zaela_S 06-10-2014 01:56 AM

Total guess, but the client probably assumes scribing will succeed under normal circumstances and gets stuck in scribe-mode waiting for a packet.

I would try:

Code:

UnscribeSpell(memspell->slot, true);
Sends a delete-from-spellbook packet to the client. It may accept that as a failure to scribe.

Alternatively:

Code:

MemorizeSpell(memspell->slot, 0xFFFFFFFF, memSpellScribing);
Sends the success packet the client expects. Not sure if the client would consider 0xFFFFFFFF to be an invalid spellid the way we do, though...

I am moderately confident that the first one might work.

Bonehard 06-10-2014 09:55 AM

Quote:

Originally Posted by Zaela_S (Post 231101)
Total guess, but the client probably assumes scribing will succeed under normal circumstances and gets stuck in scribe-mode waiting for a packet.

I would try:

Code:

UnscribeSpell(memspell->slot, true);
Sends a delete-from-spellbook packet to the client. It may accept that as a failure to scribe.

Alternatively:

Code:

MemorizeSpell(memspell->slot, 0xFFFFFFFF, memSpellScribing);
Sends the success packet the client expects. Not sure if the client would consider 0xFFFFFFFF to be an invalid spellid the way we do, though...

I am moderately confident that the first one might work.

Heya,
i will check this later at home when iam back from work. :)

Bonehard 06-10-2014 01:19 PM

Hello,
it works now.
But you need to answer with the MemorizeSpell(memspell->slot, 0xFFFFFFFF, memSpellScribing).
I think it has to do with the fact that when the client wants to write a valid spell to the spellbook it send the packet for scribing a spell.
So you need to answer with the correct packet i think.

Code:

        // Custom - Used for disabling scribes more than given number
        if (disableScribe)
        {
                // Count scribed spells
                int iScribed = 0;
                for (int i = 0; i < MAX_PP_SPELLBOOK; i++)
                {
                        if (m_pp.spell_book[i] != 0xFFFFFFFF)
                                iScribed++;
                }

                // check if we reached the maximum client can scribe spells
                if (iScribed >= numMaxScribeSpells)
                {
                        MemorizeSpell(memspell->slot, 0xFFFFFFFF, memSpellScribing);
                        Message(13, "Maximum spells scribed. Please unscripe some spells.");
                        return;
                }
        }

This works now like i wanted.
The only side effect is that you see the answer unknown spell written etc...

But thats ok since i can send the information to the client whats the real problem. :)

Thank you very much for the nice hint Zaela_S.


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

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