Think I've cracked it.
Seems like I had miscalculated loading quest flags.
I'm not using a memory dump like the normal version. I pulled all the quest data into discrete structures for saving and loading since it's easier to debug that way.
Had it all set up nicely to mirror the structures in the client with a nice union to make it easier to delete groups of quest flags as done in QUESTREWD(016)
in case you don't have that coded (most people probably don't) here is the code that I use now since figuring it out from the client code.
- //Group Flag Clear
- QUESTREWD(016)
- {
- //word nGroupSN
- GETREWDDATA(016);
- //there are 16 groups of 32 flag bits
- UINT Startpos = data->nGroupSN * 32;
- UINT EndPos = Startpos + 32;
- for(UINT i = Startpos; i < EndPos; i++)
- {
- client->quest.Qflags[i] = 0;
- }
- return QUEST_SUCCESS;
- }
It was previously set up to delete a group in one go due to this code in datatypes.h where the flag structures is set up
- union
- {
- byte Qflags [QUEST_SWITCH_CNT / 8 ]; //64
- DWORD dwFlags [QUEST_SWITCH_CNT / 32]; //16
- };
QUEST_SWITCH_CNT is defined as 512 which is the maximum number of switch-bits used for the flags.
And that was my problems. BITS not bytes
The above code gives me an array of 64 Qflag bytes each of which would have to contain 8 bits.
The actual values coming in from the QSD are in BITs so it might tell me to set FLAG BIT number 498..... but I only have 64 bytes in my array so...... MASSIVE memory overwrites going on
I have now changed the entire structure to remove dwFlags completely and set byte Qflags [QUEST_SWITCH_CNT] so it's now a 512 array, hence the loop in the quest reward instead of simply setting the dwFlags entry to 0.
The character that was causing all my troubles now logs in fine.
This also explains why I've been getting logging issues seemingly randomly for some while now. Hopefully this will be the end of it so that I can actually move on with fixing up the stuff that will make the game more fun to play
ABE
Actually i suppose this would have worked just as well. Meh.. Whatever
- union
- {
- byte Qflags [QUEST_SWITCH_CNT]; //512
- DWORD dwFlags [QUEST_SWITCH_CNT / 32]; //16
- };