Fix for #bot create when same named PC exists
Hello all. I found that when you create a bot that has the same name as an existing player it bugs both the player and the bot out like crazy. I added a check against the character_ table in the database to make sure a player does not already exist with the target name.
Code:
Index: bot.cpp |
Nice! This really needed to be fixed
|
So I added your fix, but instead of crashing one zone now, it crashes the entire zone.exe, could you explain how this is supposed to be used? It's currently causing more detriment than anything.
Edit: Code below. Code:
bool Bot::IsBotNameAvailable(std::string* errorMessage) { |
Doesn't look like this fix works? It seems to still crash
|
Your check seems to first check the Bot names... if there is no bot name... it sets
Result = True Then it checks players .. if the player DOES exist it doesn't set the result back to false. Code:
bool Bot::IsBotNameAvailable(std::string* errorMessage) { I do not have a bots compile to test this on... but this might be a fix? Not 100% on that one just yet |
there is no reason to use COUNT, or LIKE since there is no wildcard being used, because you're only concerned about a single, exact match. you really don't need to return anything but a 1, since you're not doing anything with the ids. it wouldn't hurt to put LIMIT 1 on the end of the query either.
you can do the whole thing in a single query like so. "SELECT 1 FROM character_ AS c, vwBotCharacterMobs AS b WHERE '%s' IN (c.name, b.name) LIMIT 1;" |
I think there was a slight issue with my diff. There was also a bug related to the return value. I have fixed the code and just posted the entire IsBotNameAvailable function above.
As for why I used LIKE: I was just using the same method used that was already there to check against the vwBotCharacterMobs table. Just trying to keep the code consistant, and it was really easy to just copy and paste what was there. You are quite right c0ncrete what you posted is much cleaner. I will look at cleaning the code up a bit when I get some time. Code:
bool Bot::IsBotNameAvailable(std::string* errorMessage) { |
Is this fix working? Have you tried it on your server/development server?
|
Not yet. I will verify it tomorrow. I have not had a chance yet.
|
All right, the first fix you gave out actually crashed the entire zone.exe rather than fixing anything. D:
|
Thanks zip, shame the other bot servers that already had this fixed never shared how they fixed it. It's been a known issue for some time.
|
This fix works, 100% confirmed, Wolfwalkereci?
|
Zam
I just confirmed it. Replace your existing Bot::IsBotNameAvailable function with this one. Sorry about the issue before. The problem before was a bug in the code and also the diff i posted. I wish I could update the code in the main post but wont let me. Code:
bool Bot::IsBotNameAvailable(std::string* errorMessage) { |
Good, thanks ZippZipp!
|
So it turns out the issue was seeded much deeper than I had realized. While the fixes posted before fixed issues with creating bots with same name, they did not fix the issue of that player with the same name going Linkdead when another user attempted to create a bot with their name.
The problem was rooted in the fact that the function in bot.cpp: Bot::IsBotNameAvailable is a non-static class function and a Bot object was needed in order to check if the name was valid. Creating that Bot object was crashing people with the same name. What I did was make the IsBotNameAvailable a static class function and pass it the name to check. I then call the function before the new Bot object is created. This fixes the problem of crashing and prevents people from making bots with the same name as PCs. Code:
// Bot.h Code:
// Bot.cpp Code:
// bot.cpp Code:
// questmgr.cpp |
All times are GMT -4. The time now is 10:21 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.