Hello,
I have some GUI classes and they generally worked correct until I've started to play with icons.
This code will cause crash
[code=c++]void CIcon:raw(int x, int y)
{
Screen::PrintItem(1, x + m_x, y + m_y, m_size, m_itemId, m_itemCount, false);
Screen::PrintText(1, x + m_x + (m_size / 2), y + m_y + m_size, 2, 255, 127, 1, "Text under icon", 1);
}[/code]
This won't
[code=c++]void CIcon:raw(int x, int y)
{
Screen::PrintItem(1, x + m_x, y + m_y, m_size, m_itemId, m_itemCount, false);
Screen::PrintText(1, 45, 70, 2, 255, 127, 1, "Text under icon", 1);
}[/code]
As you can see this is almost the same code.
Variable values and it's addresses
Code:
x = 0 - adr: 0018EC1C - const adr
m_x = 20 - adr: 02C7A11C
m_size = 50 - adr: 02C7A134
y = 0 - adr: 0018EC20 - const adr
m_y = 20 - adr: 02C7A120
My PrintText procedure
Code:
void PrintText(int nSurface, int nX, int nY, int nFont, int nRed, int nGreen, int nBlue, char* nText, int nAlign)
{
__asm
{
PUSH nAlign
PUSH nBlue
PUSH nGreen
PUSH nRed
PUSH nFont
PUSH nY
PUSH nX
PUSH nSurface
MOV ECX, nText
CALL Addresses::Print::PrintTextFunc
ADD ESP, 32
}
}
It seems to me that doing any operations on variables inside icon's Draw procedure causes crash.
This would also cause crash
[code=c++]int uselessInt = 1;
void CIcon:raw(int x, int y)
{
Screen::PrintItem(1, x + m_x, y + m_y, m_size, m_itemId, m_itemCount, false);
uselessInt += x + m_size;
}[/code]
Few error files from Tibia:
Code:
+---------------------------------------------------------------
Debug Assertion 9.44 NWin32Exception.cpp 55
Mon Feb 06 19:00:09 2012
Graphic Engine: DirectX5 (0)
Operating System: Windows XP Professional in POL
Processor: AMD Phenom II X6 110
Video Card: NVIDIA GeForce GTX 570
Player.cpp 361: exception occurred, reason:
Player.cpp 465: exception occurred, reason:
Control.cpp 1763: exception occurred (MessageType: 0 MaW: 3E51CF0 MoW: 0), reason:
Control.cpp 1758: exception occurred, reason:
Control.cpp 450: exception occurred (Force?1:0 = 0), reason:
NWin32Exception.cpp 55: win32 exception occurred, reason:
access violation (read attempt at 0000000C)
----------------------------------------------------------------
+---------------------------------------------------------------
Debug Assertion 9.44 NWin32Exception.cpp 55
Mon Feb 06 19:03:15 2012
Graphic Engine: DirectX5 (0)
Operating System: Windows XP Professional in POL
Processor: AMD Phenom II X6 110
Video Card: NVIDIA GeForce GTX 570
Player.cpp 361: exception occurred, reason:
Player.cpp 465: exception occurred, reason:
Control.cpp 1763: exception occurred (MessageType: 0 MaW: 3FF3AE0 MoW: 40660B0), reason:
Control.cpp 1758: exception occurred, reason:
Control.cpp 450: exception occurred (Force?1:0 = 0), reason:
NWin32Exception.cpp 55: win32 exception occurred, reason:
access violation (read attempt at 0000000C)
----------------------------------------------------------------
+---------------------------------------------------------------
Debug Assertion 9.44 NWin32Exception.cpp 55
Mon Feb 06 19:33:24 2012
Graphic Engine: DirectX5 (0)
Operating System: Windows XP Professional in POL
Processor: AMD Phenom II X6 110
Video Card: NVIDIA GeForce GTX 570
Player.cpp 361: exception occurred, reason:
Player.cpp 465: exception occurred, reason:
Control.cpp 1763: exception occurred (MessageType: 0 MaW: 3DD4F88 MoW: 3E48358), reason:
Control.cpp 1758: exception occurred, reason:
Control.cpp 450: exception occurred (Force?1:0 = 0), reason:
NWin32Exception.cpp 55: win32 exception occurred, reason:
access violation (read attempt at FFFFFFF9)
----------------------------------------------------------------
Anyone knows what causes this crashes?