I was messing with the dll (Tibia-Extended-Client-Library), and I found a problem with the mana bar when you hide it (CTRL + N) causing the client to crash. I found the problem in the code and it's in creaturepointer, so when you use it in an if, it causes the client to crash. As I have no experience with memory manipulation and the like, I am trying some difficulties to correct this.
In code the part that causes the problem is this if.
when I remove it, it doesn't crash anymore, but the mana bar is drawn on all creatures and not just the local player.
Anyone who has touched it and has any ideas?
Complete code of mana bar:
Github project link: Tibia Extended Client Library
In code the part that causes the problem is this if.
C++:
DWORD creatureId = [I](DWORD[/I])creaturePointer;
if(creatureId == [I](DWORD[/I])PlayerIDAddr)
when I remove it, it doesn't crash anymore, but the mana bar is drawn on all creatures and not just the local player.
Anyone who has touched it and has any ideas?
Complete code of mana bar:
C++:
void __stdcall MyDrawHPBar(DWORD nSurface, DWORD X, DWORD Y, DWORD W, DWORD creaturePointer/[I]this should be height but we don't need it so we hack our way'[/I]/, DWORD nRed, DWORD nGreen, DWORD nBlue)
{
if(nRed == 0 && nGreen == 0 && nBlue == 0)
return;
DWORD creatureId = [I](DWORD[/I])creaturePointer;
uint32_t engineAddr = GetEngineAddr();
uint32_t drawRectAddr = [I](DWORD[/I])([I](DWORD[/I])(engineAddr)+0x14);
((void (__fastcall *)(DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD))drawRectAddr)(engineAddr, 0, nSurface, X-1, Y-1, 27, 4, 0, 0, 0);
((void (__fastcall *)(DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD))drawRectAddr)(engineAddr, 0, nSurface, X, Y, W, 2, nRed, nGreen, nBlue);
if(creatureId == [I](DWORD[/I])PlayerIDAddr)
{
double tmp_float = 1.f;
if([I](DWORD[/I])PlayerManaMaxAddr != 0)
tmp_float = ((double)([I](DWORD[/I])PlayerManaAddr))/([I](DWORD[/I])PlayerManaMaxAddr);
((void (__fastcall *)(DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD))drawRectAddr)(engineAddr, 0, nSurface, X-1, Y+4, 27, 4, 0, 0, 0);
((void (__fastcall *)(DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD))drawRectAddr)(engineAddr, 0, nSurface, X, Y+5, static_cast<int32_t>(25*tmp_float), 2, 0, 108, 255);
}
}
newRenderer->DrawRectangle = MyDrawHPBar;
HookCall((client_BaseAddr+0xF5675), (DWORD)&HPBarRenderHandle);
HookCall((client_BaseAddr+0xF573E), (DWORD)&HPBarRenderHandle);
HookCall((client_BaseAddr+0xF5875), (DWORD)&HPBarRenderHandle);
HookCall((client_BaseAddr+0xF5922), (DWORD)&HPBarRenderHandle);
OverWriteWord((client_BaseAddr+0xF57D8), 0xFFD0);//hack our way to creaturepointer
OverWriteWord((client_BaseAddr+0xF5912), 0xFFD0);//hack our way to creaturepointer
Github project link: Tibia Extended Client Library