trickerer / Trinity-Bots

NPCBots for TrinityCore and AzerothCore 3.3.5
https://github.com/trickerer/TrinityCore-3.3.5-with-NPCBots/
472 stars 156 forks source link

Transmogrification compatibility: worldserver.exe crash while loading bot data entries #101

Closed x92mko closed 3 years ago

x92mko commented 3 years ago

Dear all,

I've had a very stable server on version a534d17e2624+ 2021-05-24 with latest version of bots (and transmog vendor) running. Everything went smoothly and I've set 167 bots into the world.

When I was playing the last days everything worked but then suddenly since yesterday evening I can no longer load the worldserver. It crashs while loading:

Starting NpcBot system...

Bot appearance data loaded Bot race data loaded Loaded 167 bot data entries

...and then the worldsever is closed.

Could you please have a look into the files? Please let me know if you need more files or any more details.

All the best, love your amazing work

Marco

Server.log DBErrors.log a534d17e2624+worldserver.exe[28-5_20-41-40].txt

trickerer commented 3 years ago

Can't confirm using https://github.com/trickerer/TrinityCore-3.3.5-with-NPCBots/commit/293c0130c5f53e2b4af04050e6033bc4fb2dd603 (https://github.com/TrinityCore/TrinityCore/commit/3f36dc734364d7ef182b1f6bef64798b3c1235a1)

a534d17e2624 is not a TrinityCore revision

The only way to find a source of that crash is to produce a debug crash log.

qyh214 commented 3 years ago

you should use debug with crash log. seems you add transmog patch? you must fix item conflict with transmog.patch

x92mko commented 3 years ago

Hi all, thanks for your fast replys. I will start to investigate via debugger, which I didn't do before this way. Afterwards I will let you know. Thanks!

@qyh214 I already applied the transmog.patch with success. Of course I had a merge conflict but I solved it. Just the hint: the server worked the last days. I was able to play with bots and transmog too. I already started the sever like 20 times. But now suddenly without a config change the bots crashes on that exact point. As I said, I will skill myself in debug and will let you know afterwards. :-)

x92mko commented 3 years ago

Hi all,

I started the worldserver.exe in Visual Studio debug mode. Could you please let me know if this is enough what I got?

Exception thrown at 0x00007FF7A5ED24D4 in worldserver.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

'worldserver.exe' (Win32): Loaded 'D:_SERVER\Trinity Core Server\worldserver.exe'. Module was built without symbols. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. 'worldserver.exe' (Win32): Loaded 'D:_SERVER\Trinity Core Server\libmysql.dll'. 'worldserver.exe' (Win32): Loaded 'D:_SERVER\Trinity Core Server\libcrypto-1_1-x64.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\dbghelp.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1.dll'. 'worldserver.exe' (Win32): Loaded 'D:_SERVER\Trinity Core Server\libssl-1_1-x64.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\dnsapi.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\secur32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\dbgcore.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\sspicli.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\IPHLPAPI.DLL'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'. The thread 0x4480 has exited with code 0 (0x0). 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\NapiNSP.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\pnrpnsp.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\wshbth.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\nlaapi.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\winrnr.dll'. 'worldserver.exe' (Win32): Loaded 'C:\Windows\System32\rasadhlp.dll'. Exception thrown at 0x00007FFCA8814B89 in worldserver.exe: Microsoft C++ exception: boost::wrapexcept at memory location 0x000000BBF6EF4A20. Exception thrown at 0x00007FF7A5ED24D4 in worldserver.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

The thread 0x2a90 has exited with code -1073741510 (0xc000013a). The thread 0x3c58 has exited with code -1073741510 (0xc000013a). The thread 0x269c has exited with code -1073741510 (0xc000013a). The thread 0x125c has exited with code -1073741510 (0xc000013a). The thread 0x4928 has exited with code -1073741510 (0xc000013a). The thread 0x3d70 has exited with code -1073741510 (0xc000013a). The thread 0x1174 has exited with code -1073741510 (0xc000013a). The thread 0x482c has exited with code -1073741510 (0xc000013a). The thread 0x3480 has exited with code -1073741510 (0xc000013a). The thread 0xb1c has exited with code -1073741510 (0xc000013a). The thread 0x55e0 has exited with code -1073741510 (0xc000013a). The program '[18980] worldserver.exe' has exited with code -1073741510 (0xc000013a).

Viewing options: (If this is also necessary to know...) 00007FF7A5ED24D4 mov eax,dword ptr [rcx]
00007FF7A5ED24D6 ret
00007FF7A5ED24D7 xor edx,edx
00007FF7A5ED24D9 lea r8d,[rdx+0Ah]
00007FF7A5ED24DD jmp qword ptr [7FF7A611FC18h]
00007FF7A5ED24E4 int 3
00007FF7A5ED24E5 int 3
00007FF7A5ED24E6 int 3
00007FF7A5ED24E7 int 3
00007FF7A5ED24E8 int 3
00007FF7A5ED24E9 int 3
00007FF7A5ED24EA int 3
00007FF7A5ED24EB int 3
00007FF7A5ED24EC int 3
00007FF7A5ED24ED int 3
00007FF7A5ED24EE int 3
00007FF7A5ED24EF int 3
00007FF7A5ED24F0 mov rax,rcx
00007FF7A5ED24F3 mov rcx,qword ptr [rcx]
00007FF7A5ED24F6 test rcx,rcx
00007FF7A5ED24F9 jne 00007FF7A5ED24FE
00007FF7A5ED24FB xor eax,eax
00007FF7A5ED24FD ret
00007FF7A5ED24FE cmp byte ptr [rax+0Ch],0
00007FF7A5ED2502 je 00007FF7A5ED2508
00007FF7A5ED2504 mov rax,qword ptr [rcx]
00007FF7A5ED2507 ret
00007FF7A5ED2508 xor edx,edx
00007FF7A5ED250A lea r8d,[rdx+0Ah]
00007FF7A5ED250E jmp qword ptr [7FF7A611FC28h]

qyh214 commented 3 years ago

If you use transmog patch and I remember correctly, it will crash after starting the server for the second time. because system read npcbot equip then crash.

Please focus on : npcbot equip with char.item_instance ,with transmog patch in item_instance add new column you should fix this conflict.

src/server/database/Database/Implementation/CharacterDatabase.cpp

CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE

trickerer commented 3 years ago

I started the worldserver.exe in Visual Studio debug mode. Could you please let me know if this is enough what I got?

No. You need to build server in Debug mode (instead of Release) and then it will produce useful crash log.

x92mko commented 3 years ago

Hi all, thanks again for your massive support. I very appreciate it.

@qyh214 I've investigated the src/server/database/Database/Implementation/CharacterDatabase.cpp and CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE:

PrepareStatement(CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, guid, itemEntry, owner_guid " "FROM item_instance WHERE guid IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_SYNCH);

May I ask you what you think I should add into here?

@trickerer I've run cmake again and build the server in debug mode, afterwards I've put the worldserver and worldserver.pdb into my server folder and run worldserver.exe. The logs are attached.

bf831f686994worldserver.exe[30-5_21-32-0].txt

trickerer commented 3 years ago

Here is where this issue was discussed last time (just in case).

Try changing

PrepareStatement(CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, guid, itemEntry, owner_guid " "FROM item_instance WHERE guid IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_SYNCH); to PrepareStatement(CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, guid, itemEntry, owner_guid, transmog " "FROM item_instance WHERE guid IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_SYNCH);

x92mko commented 3 years ago

The good thing: Thanks to your hint @trickerer I was able to start my server again. I just cleared SQL characters > item_instance and afterwards I was able to start my worldserver. Now I know exactly what causes the error. As soon as I give any kind of item to my npcbot, this will work in game but as soon as I restart the server the crash happens again. It only works when I clear the relevant data in SQL.

The bad thing: I tried to add "transmog" in the database line CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, but this did not help.

For your information: When I was building my server (TrinityCore, then applied Bots Patch, afterwards transmogvendor) as explained I had a merge conflict. This conflict was related to DBCStructure.h, which was easy to solve, and the other one to DBCfmt.h which I would like to explain a bit more.

This was exactly what I got: <<<<<<< HEAD char constexpr ItemDisplayTemplateEntryfmt[] = "nxxxxsxxxxxxxxxxxxxxxxxxx";

char constexpr ItemDisplayTemplateEntryfmt[] = "nssssssiiiiiiiissssssssii";
>>>>>>> a2f1af703d25abaa4d7fa36872b3cca8dc567bf3

I decided to use the bots ItemDisplay instead of transmogvendor. Could this maybe also be related? I build the server with "nxxxxsxxxxxxxxxxxxxxxxxxx".

One more thing: I now tried to build the server with "nssssssiiiiiiiissssssssii" but this causes an error when starting the worldserver and then closes: Initialize data stores... Size of 'ItemDisplayInfo.dbc' set by format string (156) not equal size of C++ structure (12).

trickerer commented 3 years ago

Oops, you actually need to add a zero into a query to match data length with CHAR_SEL_CHARACTER_INVENTORY query result:

PrepareStatement(CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, "SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, guid, itemEntry, owner_guid, 0, transmog " "FROM item_instance WHERE guid IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_SYNCH);

x92mko commented 3 years ago

Dear @trickerer , you're really amazing! The worldserver runs now great with bots and transmog! The zero solved the issue "... 0, transmog "

One more question: The npcbot equipment doesn't get saved. That means everytime I start the worldserver again the equipment is gone and I have to dress them again. In case this is the only solution to play with bots and transmog, then it is ok, but is there a smarter way to get it running?

trickerer commented 3 years ago

You should scan your DBErrors.log and Server.log for sql errors or anything item related to see what is wrong. It is possible that items are saved, but not loaded, cluttering your item_instance with useless entries.

x92mko commented 3 years ago

DBErrors.log: "Script '0' is referenced by the database, but does not exist in the core!" Server log looks pretty well and I don't have any crashes to report.

For a new test I've deleted all entrees in item_instance, and

Do you have any further proposals? Is it possible to write the bot transmog in a different table then the rochet transmog or vice versa that they doesn't get mixed up (if this makes sense)?

Example

Server.log DBErrors.log

trickerer commented 3 years ago

I'll guess all the other items in the table are worn by your character.

Something sets item guid to 0, which could be related for item deletion.

Before messing with code try snapshotting your item_template after you create an item, after you give it to bot, and after you restart the server (which is already done on the picture).

Could you provide a link to a transmog patch you're using? Also I'd like to know what modification adds these additional links to bot whisper output.

qyh214 commented 3 years ago

@trickerer maybe he used https://github.com/Rochet2/TrinityCore/tree/transmog_3.3.5 or https://github.com/Rochet2/TrinityCore/tree/transmogvendor_3.3.5 or both. this is my fix:

PrepareStatement(CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, "
SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, guid, itemEntry, owner_guid, 0, transmog "
"FROM item_instance WHERE guid IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_SYNCH);

and this is not only work,I also fix : src/server/game/AI/NpcBots/botdatamgr.cpp

void BotDataMgr::UpdateNpcBotData()
…………
stmt->setUInt32(++index, botitem->GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
stmt->setString(++index, botitem->GetText());
//after this line add
stmt->setUInt32(++index, 0); // this for transmog

and this will give a bug!

If you transmog this item then give bot,then refund to yourself.transmog will missing.because I don't know how to fix this problem, how to get transmog data so I set 0.

trickerer commented 3 years ago

void BotDataMgr::UpdateNpcBotData() ………… stmt->setUInt32(++index, botitem->GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME)); stmt->setString(++index, botitem->GetText()); //after this line add stmt->setUInt32(++index, 0); // this for transmog

Change last line to stmt->setUInt32(++index, botitem->transmog); // this for transmog

x92mko commented 3 years ago

Yeah it works now! You guys are outstanding. Big THANK YOU for this amazing support.

To summarize and to help other people which are having NPCBots by trickerer + rochet's transmog 3.3.5 (Blizzlike) installed:

1. src/server/database/Database/Implementation/CharacterDatabase.cpp --> CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE must be changed to:

PrepareStatement(CHAR_SEL_NPCBOT_EQUIP_BY_ITEM_INSTANCE, "
SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, guid, itemEntry, owner_guid, 0, transmog "
"FROM item_instance WHERE guid IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_SYNCH);

2. src/server/game/AI/NpcBots/botdatamgr.cpp --> find "stmt->setString(++index, botitem->GetText());" and add a new line below, add there "stmt->setUInt32(++index, botitem->transmog); // this for transmog"

This will ensure that the bots equipment gets correctly saved into SQL characters "item_instance"

I will do more tests in the next days. When I don't get any more errors/problems, then I will close this issue.

x92mko commented 3 years ago

Works great, thank you. Issue can be closed, solved!

trickerer commented 1 year ago

303