Implement DefaultGuild rule

This commit is contained in:
Paul Coene 2020-02-03 12:54:26 -05:00 committed by GitHub
parent 424b669cbb
commit f9b3b7aecf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -338,6 +338,27 @@ bool Database::ReserveName(uint32 account_id, char* name) {
query = StringFormat("INSERT INTO `character_data` SET `account_id` = %i, `name` = '%s'", account_id, name);
results = QueryDatabase(query);
if (!results.Success() || results.ErrorMessage() != ""){ return false; }
// Put character into the default guild if rule is being used.
int guild_id = RuleI(Character, DefaultGuild);
if (guild_id != 0) {
int char_id=-1;
query = StringFormat("select `id` FROM `character_data` WHERE `name` = '%s'", name);
results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
char_id = atoi(row[0]);
}
if (char_id > -1) {
query = StringFormat("INSERT INTO `guild_members` SET `char_id` = %i, `guild_id` = '%i'", char_id, guild_id);
results = QueryDatabase(query);
if (!results.Success() || results.ErrorMessage() != ""){
LogInfo("Could not put character [{}] into default Guild", name);
}
}
}
return true;
}