|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Development::Bots Forum for bots. |
02-22-2013, 09:46 PM
|
|
Developer
|
|
Join Date: Dec 2012
Posts: 515
|
|
Tested and I can confirm this issue is fixed with those changes! Thanks ZippZipp
|
02-22-2013, 09:47 PM
|
Discordant
|
|
Join Date: Jan 2013
Posts: 284
|
|
Thanks ZippZipp! Works 100%!
|
02-24-2013, 04:46 AM
|
|
Developer
|
|
Join Date: Dec 2012
Posts: 515
|
|
Can anyone put this fix into the newest revision?
|
02-24-2013, 05:52 AM
|
Demi-God
|
|
Join Date: Aug 2010
Posts: 1,742
|
|
It'd be easier to do so if an actual diff was posted.
|
|
|
|
07-10-2013, 04:03 AM
|
|
Developer
|
|
Join Date: Dec 2012
Posts: 515
|
|
Bot.cpp
Code:
old new
... ... @@ -2347,16 +2347,17 @@ bool Bot::IsValidName() {
2347 2347 return Result;
2348 2348 }
2349 2349
2350 -bool Bot::IsBotNameAvailable(std::string* errorMessage) {
2351 - bool Result = false;
2350 +bool Bot::IsBotNameAvailable(char *botName, std::string* errorMessage) {
2351 + bool Result1 = false;
2352 + bool Result2 = false;
2352 2353
2353 - if(this->GetCleanName()) {
2354 + if(botName !="") {
2354 2355 char* Query = 0;
2355 2356 char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
2356 2357 MYSQL_RES* DatasetResult;
2357 2358 MYSQL_ROW DataRow;
2358 2359
2359 - if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT COUNT(id) FROM vwBotCharacterMobs WHERE name LIKE '%s'", this->GetCleanName()), TempErrorMessageBuffer, &DatasetResult)) {
2360 + if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT COUNT(id) FROM vwBotCharacterMobs WHERE name LIKE '%s'", botName), TempErrorMessageBuffer, &DatasetResult)) {
2360 2361 *errorMessage = std::string(TempErrorMessageBuffer);
2361 2362 }
2362 2363 else {
... ... @@ -2368,15 +2369,34 @@ bool Bot::IsBotNameAvailable(std::string* errorMessage) {
2368 2369 }
2369 2370
2370 2371 if(ExistingNameCount == 0)
2371 - Result = true;
2372 + Result1 = true;
2372 2373
2373 2374 mysql_free_result(DatasetResult);
2374 - }
2375 2375
2376 + if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT COUNT(id) FROM character_ WHERE name LIKE '%s'", botName), TempErrorMessageBuffer, &DatasetResult)) {
2377 + *errorMessage = std::string(TempErrorMessageBuffer);
2378 + } else {
2379 + uint32 ExistingNameCount = 0;
2380 +
2381 + while(DataRow = mysql_fetch_row(DatasetResult)) {
2382 + ExistingNameCount = atoi(DataRow[0]);
2383 + break;
2384 + }
2385 +
2386 + if(ExistingNameCount == 0)
2387 + Result2 = true;
2388 +
2389 + mysql_free_result(DatasetResult);
2390 +
2391 + }
2392 + }
2376 2393 safe_delete(Query);
2377 2394 }
2378 2395
2379 - return Result;
2396 + if(Result1 && Result2)
2397 + return true;
2398 + else
2399 + return false;
2380 2400 }
2381 2401
2382 2402 bool Bot::Save() {
... ... @@ -12182,6 +12202,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
12182 12202 if(!strcasecmp(sep->arg[5], "female"))
12183 12203 gender = 1;
12184 12204
12205 + if(!IsBotNameAvailable(sep->arg[2],&TempErrorMessage)) {
12206 + c->Message(0, "The name %s is already being used. Please choose a different name.", sep->arg[2]);
12207 + return;
12208 + }
12209 +
12185 12210 NPCType DefaultNPCTypeStruct = CreateDefaultNPCTypeStructForBot(std::string(sep->arg[2]), std::string(), c->GetLevel(), atoi(sep->arg[4]), atoi(sep->arg[3]), gender);
12186 12211 Bot* NewBot = new Bot(DefaultNPCTypeStruct, c);
12187 12212
... ... @@ -12196,11 +12221,6 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
12196 12221 return;
12197 12222 }
12198 12223
12199 - if(!NewBot->IsBotNameAvailable(&TempErrorMessage)) {
12200 - c->Message(0, "The name %s is already being used. Please choose a different name.", NewBot->GetCleanName());
12201 - return;
12202 - }
12203 -
12204 12224 if(!TempErrorMessage.empty()) {
12205 12225 c->Message(13, "Database Error: %s", TempErrorMessage.c_str());
12206 12226 return;
Bot.h
Code:
old new
... ... @@ -152,7 +152,7 @@ public:
152 152 // Class Methods
153 153 bool IsValidRaceClassCombo();
154 154 bool IsValidName();
155 - bool IsBotNameAvailable(std::string* errorMessage);
155 + static bool IsBotNameAvailable(char *botName, std::string* errorMessage);
156 156 bool DeleteBot(std::string* errorMessage);
157 157 void Spawn(Client* botCharacterOwner, std::string* errorMessage);
158 158 virtual void SetLevel(uint8 in_level, bool command = false);
questmgr.cpp
Code:
old new
... ... @@ -2011,6 +2011,11 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level
2011 2011 return false;
2012 2012 }
2013 2013
2014 + if(Bot::IsBotNameAvailable((char*)name,&TempErrorMessage)) {
2015 + initiator->Message(0, "The name %s is already being used. Please choose a different name.", (char*)name);
2016 + return false;
2017 + }
2018 +
2014 2019 NPCType DefaultNPCTypeStruct = Bot::CreateDefaultNPCTypeStructForBot(name, lastname, level, race, botclass, gender);
2015 2020 Bot* NewBot = new Bot(DefaultNPCTypeStruct, initiator);
2016 2021
... ... @@ -2026,11 +2031,6 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level
2026 2031 return false;
2027 2032 }
2028 2033
2029 - if(!NewBot->IsBotNameAvailable(&TempErrorMessage)) {
2030 - initiator->Message(0, "The name %s is already being used. Please choose a different name.", NewBot->GetCleanName());
2031 - return false;
2032 - }
2033 -
2034 2034 if(!TempErrorMessage.empty()) {
2035 2035 initiator->Message(13, "Database Error: %s", TempErrorMessage.c_str());
2036 2036 return false;
If that is the correct format...
|
|
|
|
01-08-2014, 02:43 PM
|
Administrator
|
|
Join Date: May 2013
Location: United States
Posts: 1,594
|
|
Can we get this committed? I haven't seen anything in the changelog about committing it, or was it a silent commit?
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 03:23 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|