mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
Simplify error logging
This commit is contained in:
+45
-36
@@ -42,7 +42,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
|
||||
{
|
||||
if (!user || !in_augment)
|
||||
{
|
||||
Log(Logs::General, Logs::Error, "Client or AugmentItem_Struct not set in Object::HandleAugmentation");
|
||||
LogError("Client or AugmentItem_Struct not set in Object::HandleAugmentation");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
|
||||
|
||||
if(!container)
|
||||
{
|
||||
Log(Logs::General, Logs::Error, "Player tried to augment an item without a container set.");
|
||||
LogError("Player tried to augment an item without a container set");
|
||||
user->Message(Chat::Red, "Error: This item is not a container!");
|
||||
return;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
|
||||
bool isSolvent = auged_with->GetItem()->ItemType == EQEmu::item::ItemTypeAugmentationSolvent;
|
||||
if (!isSolvent && auged_with->GetItem()->ItemType != EQEmu::item::ItemTypeAugmentationDistiller)
|
||||
{
|
||||
Log(Logs::General, Logs::Error, "Player tried to remove an augment without a solvent or distiller.");
|
||||
LogError("Player tried to remove an augment without a solvent or distiller");
|
||||
user->Message(Chat::Red, "Error: Missing an augmentation solvent or distiller for removing this augment.");
|
||||
|
||||
return;
|
||||
@@ -179,7 +179,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
|
||||
if (aug) {
|
||||
if (!isSolvent && auged_with->GetItem()->ID != aug->GetItem()->AugDistiller)
|
||||
{
|
||||
Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", auged_with->GetItem()->ID, aug->GetItem()->AugDistiller);
|
||||
LogError("Player tried to safely remove an augment with the wrong distiller (item [{}] vs expected [{}])", auged_with->GetItem()->ID, aug->GetItem()->AugDistiller);
|
||||
user->Message(Chat::Red, "Error: Wrong augmentation distiller for safely removing this augment.");
|
||||
return;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
|
||||
void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Object *worldo)
|
||||
{
|
||||
if (!user || !in_combine) {
|
||||
Log(Logs::General, Logs::Error, "Client or NewCombine_Struct not set in Object::HandleCombine");
|
||||
LogError("Client or NewCombine_Struct not set in Object::HandleCombine");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
|
||||
if(success && spec.replace_container) {
|
||||
if(worldcontainer){
|
||||
//should report this error, but we dont have the recipe ID, so its not very useful
|
||||
Log(Logs::General, Logs::Error, "Replace container combine executed in a world container.");
|
||||
LogError("Replace container combine executed in a world container");
|
||||
}
|
||||
else
|
||||
user->DeleteItemInInventory(in_combine->container_slot, 0, true);
|
||||
@@ -459,7 +459,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
|
||||
//ask the database for the recipe to make sure it exists...
|
||||
DBTradeskillRecipe_Struct spec;
|
||||
if (!database.GetTradeRecipe(rac->recipe_id, rac->object_type, rac->some_id, user->CharacterID(), &spec)) {
|
||||
Log(Logs::General, Logs::Error, "Unknown recipe for HandleAutoCombine: %u\n", rac->recipe_id);
|
||||
LogError("Unknown recipe for HandleAutoCombine: [{}]\n", rac->recipe_id);
|
||||
user->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
@@ -488,14 +488,14 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac
|
||||
}
|
||||
|
||||
if(results.RowCount() < 1) {
|
||||
Log(Logs::General, Logs::Error, "Error in HandleAutoCombine: no components returned");
|
||||
LogError("Error in HandleAutoCombine: no components returned");
|
||||
user->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(results.RowCount() > 10) {
|
||||
Log(Logs::General, Logs::Error, "Error in HandleAutoCombine: too many components returned (%u)", results.RowCount());
|
||||
LogError("Error in HandleAutoCombine: too many components returned ([{}])", results.RowCount());
|
||||
user->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
@@ -706,7 +706,7 @@ void Client::TradeskillSearchResults(const std::string &query, unsigned long obj
|
||||
return; //search gave no results... not an error
|
||||
|
||||
if(results.ColumnCount() != 6) {
|
||||
Log(Logs::General, Logs::Error, "Error in TradeskillSearchResults query '%s': Invalid column count in result", query.c_str());
|
||||
LogError("Error in TradeskillSearchResults query [{}]: Invalid column count in result", query.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -756,12 +756,12 @@ void Client::SendTradeskillDetails(uint32 recipe_id) {
|
||||
}
|
||||
|
||||
if(results.RowCount() < 1) {
|
||||
Log(Logs::General, Logs::Error, "Error in SendTradeskillDetails: no components returned");
|
||||
LogError("Error in SendTradeskillDetails: no components returned");
|
||||
return;
|
||||
}
|
||||
|
||||
if(results.RowCount() > 10) {
|
||||
Log(Logs::General, Logs::Error, "Error in SendTradeskillDetails: too many components returned (%u)", results.RowCount());
|
||||
LogError("Error in SendTradeskillDetails: too many components returned ([{}])", results.RowCount());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1146,8 +1146,8 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_
|
||||
buf2.c_str(), containers.c_str(), count, sum);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe search, query: %s", query.c_str());
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe search, error: %s", results.ErrorMessage().c_str());
|
||||
LogError("Error in GetTradeRecipe search, query: [{}]", query.c_str());
|
||||
LogError("Error in GetTradeRecipe search, error: [{}]", results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1168,7 +1168,7 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_
|
||||
|
||||
//length limit on buf2
|
||||
if(index == 214) { //Maximum number of recipe matches (19 * 215 = 4096)
|
||||
Log(Logs::General, Logs::Error, "GetTradeRecipe warning: Too many matches. Unable to search all recipe entries. Searched %u of %u possible entries.", index + 1, results.RowCount());
|
||||
LogError("GetTradeRecipe warning: Too many matches. Unable to search all recipe entries. Searched [{}] of [{}] possible entries", index + 1, results.RowCount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1180,8 +1180,8 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_
|
||||
"AND sum(tre.item_id * tre.componentcount) = %u", buf2.c_str(), count, sum);
|
||||
results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str());
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str());
|
||||
LogError("Error in GetTradeRecipe, re-query: [{}]", query.c_str());
|
||||
LogError("Error in GetTradeRecipe, error: [{}]", results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1189,36 +1189,45 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_
|
||||
if (results.RowCount() < 1)
|
||||
return false;
|
||||
|
||||
if(results.RowCount() > 1) {
|
||||
if (results.RowCount() > 1) {
|
||||
//The recipe is not unique, so we need to compare the container were using.
|
||||
uint32 containerId = 0;
|
||||
|
||||
if(some_id) //Standard container
|
||||
if (some_id) { //Standard container
|
||||
containerId = some_id;
|
||||
else if(c_type)//World container
|
||||
}
|
||||
else if (c_type) {//World container
|
||||
containerId = c_type;
|
||||
else //Invalid container
|
||||
}
|
||||
else { //Invalid container
|
||||
return false;
|
||||
}
|
||||
|
||||
query = StringFormat("SELECT tre.recipe_id "
|
||||
"FROM tradeskill_recipe_entries AS tre "
|
||||
"WHERE tre.recipe_id IN (%s) "
|
||||
"AND tre.item_id = %u;", buf2.c_str(), containerId);
|
||||
results = QueryDatabase(query);
|
||||
query = StringFormat(
|
||||
"SELECT tre.recipe_id "
|
||||
"FROM tradeskill_recipe_entries AS tre "
|
||||
"WHERE tre.recipe_id IN (%s) "
|
||||
"AND tre.item_id = %u;", buf2.c_str(), containerId
|
||||
);
|
||||
results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str());
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str());
|
||||
LogError("Error in GetTradeRecipe, re-query: [{}]", query.c_str());
|
||||
LogError("Error in GetTradeRecipe, error: [{}]", results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(results.RowCount() == 0) { //Recipe contents matched more than 1 recipe, but not in this container
|
||||
Log(Logs::General, Logs::Error, "Combine error: Incorrect container is being used!");
|
||||
if (results.RowCount() == 0) { //Recipe contents matched more than 1 recipe, but not in this container
|
||||
LogError("Combine error: Incorrect container is being used!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() > 1) //Recipe contents matched more than 1 recipe in this container
|
||||
Log(Logs::General, Logs::Error, "Combine error: Recipe is not unique! %u matches found for container %u. Continuing with first recipe match.", results.RowCount(), containerId);
|
||||
|
||||
if (results.RowCount() > 1) { //Recipe contents matched more than 1 recipe in this container
|
||||
LogError(
|
||||
"Combine error: Recipe is not unique! [{}] matches found for container [{}]. Continuing with first recipe match",
|
||||
results.RowCount(),
|
||||
containerId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
@@ -1288,8 +1297,8 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
|
||||
char_id, (unsigned long)recipe_id, containers.c_str());
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, query: %s", query.c_str());
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str());
|
||||
LogError("Error in GetTradeRecipe, query: [{}]", query.c_str());
|
||||
LogError("Error in GetTradeRecipe, error: [{}]", results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1324,7 +1333,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
|
||||
}
|
||||
|
||||
if(results.RowCount() < 1 && !spec->quest) {
|
||||
Log(Logs::General, Logs::Error, "Error in GetTradeRecept success: no success items returned");
|
||||
LogError("Error in GetTradeRecept success: no success items returned");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user