Well, I don't exactly know how to go about fixing this. So, here is my bug.
Server checks to see if NPC can transform.
If yes, transform(when required).
When the NPC transforms, it doesn't transform correctly. Here is the issue.
If the first player that was online walks by an NPC that transforms(like rock crabs), then the NPC transforms into NPC 256 no matter what.
If it's the second player that walks by, it transforms into 512, no matter what.
If it's the third player that walks by, it transforms into 768, no matter what .
And so on, so forth with intervals of 256.
Code:
Code:
if(transformNPC(i)) {
if(!npcs[i].transformed) {
requestTransform(i, npcs[i].npcType - 1);
npcs[i].walkingType = 1;
npcs[i].transformed = true;
}
}
Code:
public void requestTransform(int i, int id) {
npcs[i].transformId = id;
npcs[i].transformUpdateRequired = true;
npcs[i].updateRequired = true;
}
Code:
public void appendTransformUpdate(Stream str) {
str.writeWordBigEndianA(transformId);
}
Code:
public void appendNPCUpdateBlock(Stream str) {
if(!updateRequired)
return ;
int updateMask = 0;
if(animUpdateRequired)
updateMask |= 0x10;
if(hitUpdateRequired2)
updateMask |= 8;
if(transformUpdateRequired)
updateMask |= 0x2;
if(mask80update)
updateMask |= 0x80;
if(dirUpdateRequired)
updateMask |= 0x20;
if(forcedChatRequired)
updateMask |= 1;
if(hitUpdateRequired)
updateMask |= 0x40;
if(FocusPointX != -1)
updateMask |= 4;
str.writeByte(updateMask);
if (animUpdateRequired)
appendAnimUpdate(str);
if (hitUpdateRequired2)
appendHitUpdate2(str);
if (transformUpdateRequired)
appendTransformUpdate(str);
if (mask80update)
appendMask80Update(str);
if (dirUpdateRequired)
appendFaceEntity(str);
if(forcedChatRequired) {
str.writeString(forcedText);
}
if (hitUpdateRequired)
appendHitUpdate(str);
if(FocusPointX != -1)
appendSetFocusDestination(str);
}
And yes I am aware the hit masks are mixed up thanks.
Any ideas?
EDIT: It also isn't my client, because I tried it with moparscape 3.2 and it did the same thing(froze the client). My client just doesn't freeze when it errors, so I can see the error itself.