From 37cacd27b12a815c210f04e23499a26b93aa4406 Mon Sep 17 00:00:00 2001 From: JJ Date: Sat, 14 Dec 2013 09:55:46 -0500 Subject: [PATCH] Changed enable/disable recipe to confirm change made. --- changelog.txt | 3 +++ zone/command.cpp | 20 ++++++++++++++++---- zone/embparser_api.cpp | 16 ++++++++++++---- zone/lua_general.cpp | 8 ++++---- zone/questmgr.cpp | 12 ++++++++---- zone/questmgr.h | 4 ++-- zone/tradeskills.cpp | 13 +++++++++---- zone/zonedb.h | 4 ++-- 8 files changed, 56 insertions(+), 24 deletions(-) diff --git a/changelog.txt b/changelog.txt index c697e1347..6a905b761 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 12/14/2013 == +JJ: Changed enable/disable recipe to confirm change made. + == 12/13/2013 == Kayen: Implemented additional functionality for SE_CurrentHP utilizing base2 values. (ie limit to body type) Kayen: Implemented SE_MitigateMeleeDamageSP (Partial Melee Rune that only is lowered if melee hits are over X amount of damage) diff --git a/zone/command.cpp b/zone/command.cpp index c149768b6..d37e1a31d 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -11462,6 +11462,7 @@ void command_questerrors(Client *c, const Seperator *sep) void command_enablerecipe(Client *c, const Seperator *sep) { uint32 recipe_id = 0; + bool success = false; if (c) { if (sep->argnum == 1) { recipe_id = atoi(sep->arg[1]); @@ -11471,8 +11472,13 @@ void command_enablerecipe(Client *c, const Seperator *sep) return; } if (recipe_id > 0) { - database.EnableRecipe(recipe_id); - c->Message(0, "Recipe enabled."); + success = database.EnableRecipe(recipe_id); + if (success) { + c->Message(0, "Recipe enabled."); + } + else { + c->Message(0, "Recipe not enabled."); + } } else { c->Message(0, "Invalid recipe id.\nUsage: #enablerecipe recipe_id"); @@ -11483,6 +11489,7 @@ void command_enablerecipe(Client *c, const Seperator *sep) void command_disablerecipe(Client *c, const Seperator *sep) { uint32 recipe_id = 0; + bool success = false; if (c) { if (sep->argnum == 1) { recipe_id = atoi(sep->arg[1]); @@ -11492,8 +11499,13 @@ void command_disablerecipe(Client *c, const Seperator *sep) return; } if (recipe_id > 0) { - database.DisableRecipe(recipe_id); - c->Message(0, "Recipe disabled."); + success = database.DisableRecipe(recipe_id); + if (success) { + c->Message(0, "Recipe disabled."); + } + else { + c->Message(0, "Recipe not disabled."); + } } else { c->Message(0, "Invalid recipe id.\nUsage: #disablerecipe recipe_id"); diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 5e79b52b8..54f9bd73e 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -3317,32 +3317,40 @@ XS(XS__enablerecipe); XS(XS__enablerecipe) { dXSARGS; + bool success = false; if (items != 1) { Perl_croak(aTHX_ "Usage: enablerecipe(recipe_id)"); } else { uint32 recipe_id = (uint32)SvIV(ST(0)); - quest_manager.EnableRecipe(recipe_id); + success = quest_manager.EnableRecipe(recipe_id); + } + if (!success) { + XSRETURN_NO; } - XSRETURN_EMPTY; + XSRETURN_YES; } XS(XS__disablerecipe); XS(XS__disablerecipe) { dXSARGS; + bool success = false; if (items != 1) { Perl_croak(aTHX_ "Usage: disablerecipe(recipe_id)"); } else { uint32 recipe_id = (uint32)SvIV(ST(0)); - quest_manager.DisableRecipe(recipe_id); + success = quest_manager.DisableRecipe(recipe_id); + } + if (!success) { + XSRETURN_NO; } - XSRETURN_EMPTY; + XSRETURN_YES; } /* diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 28f8df634..a3f8b4236 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1021,12 +1021,12 @@ void lua_clear_opcode(int op) { ClearMappedOpcode(static_cast(op)); } -void lua_enable_recipe(uint32 recipe_id) { - quest_manager.EnableRecipe(recipe_id); +bool lua_enable_recipe(uint32 recipe_id) { + return quest_manager.EnableRecipe(recipe_id); } -void lua_disable_recipe(uint32 recipe_id) { - quest_manager.DisableRecipe(recipe_id); +bool lua_disable_recipe(uint32 recipe_id) { + return quest_manager.DisableRecipe(recipe_id); } luabind::scope lua_register_general() { diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 75763a7a6..9942b1f9f 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2901,16 +2901,20 @@ void QuestManager::CrossZoneMessagePlayerByName(uint32 Type, const char *CharNam safe_delete(pack); } -void QuestManager::EnableRecipe(uint32 recipe_id) +bool QuestManager::EnableRecipe(uint32 recipe_id) { + bool success = false; if (recipe_id > 0) - database.EnableRecipe(recipe_id); + success = database.EnableRecipe(recipe_id); + return (success); } -void QuestManager::DisableRecipe(uint32 recipe_id) +bool QuestManager::DisableRecipe(uint32 recipe_id) { + bool success = false; if (recipe_id > 0) - database.DisableRecipe(recipe_id); + success = database.DisableRecipe(recipe_id); + return (success); } Client *QuestManager::GetInitiator() const { diff --git a/zone/questmgr.h b/zone/questmgr.h index 9873dc441..1ea026357 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -231,8 +231,8 @@ public: void CrossZoneSignalPlayerByCharID(int charid, uint32 data); void CrossZoneSignalPlayerByName(const char *CharName, uint32 data); void CrossZoneMessagePlayerByName(uint32 Type, const char *CharName, const char *Message); - void EnableRecipe(uint32 recipe_id); - void DisableRecipe(uint32 recipe_id); + bool EnableRecipe(uint32 recipe_id); + bool DisableRecipe(uint32 recipe_id); Client *GetInitiator() const; NPC *GetNPC() const; diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index fa1e32b7c..e308335cb 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -1600,30 +1600,35 @@ bool Client::CanIncreaseTradeskill(SkillUseTypes tradeskill) { return true; } -void ZoneDatabase::EnableRecipe(uint32 recipe_id) +bool ZoneDatabase::EnableRecipe(uint32 recipe_id) { char *query = 0; uint32 qlen; char errbuf[MYSQL_ERRMSG_SIZE]; + uint32 affected_rows = 0; qlen = MakeAnyLenString(&query, "UPDATE tradeskill_recipe SET enabled = 1 WHERE id = %u;", recipe_id); - if (!RunQuery(query, qlen, errbuf)) { + if (!RunQuery(query, qlen, errbuf, 0, &affected_rows)) { LogFile->write(EQEMuLog::Error, "Error in EnableRecipe query '%s': %s", query, errbuf); } safe_delete_array(query); + + return (affected_rows > 0); } -void ZoneDatabase::DisableRecipe(uint32 recipe_id) +bool ZoneDatabase::DisableRecipe(uint32 recipe_id) { char *query = 0; uint32 qlen; char errbuf[MYSQL_ERRMSG_SIZE]; + uint32 affected_rows = 0; qlen = MakeAnyLenString(&query, "UPDATE tradeskill_recipe SET enabled = 0 WHERE id = %u;", recipe_id); - if (!RunQuery(query, qlen, errbuf)) { + if (!RunQuery(query, qlen, errbuf, 0, &affected_rows)) { LogFile->write(EQEMuLog::Error, "Error in DisableRecipe query '%s': %s", query, errbuf); } safe_delete_array(query); + return (affected_rows > 0); } diff --git a/zone/zonedb.h b/zone/zonedb.h index 39941e307..78ef3c831 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -385,8 +385,8 @@ public: uint32 GetZoneForage(uint32 ZoneID, uint8 skill); /* for foraging */ uint32 GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, uint8 &npc_chance); void UpdateRecipeMadecount(uint32 recipe_id, uint32 char_id, uint32 madecount); - void EnableRecipe(uint32 recipe_id); - void DisableRecipe(uint32 recipe_id); + bool EnableRecipe(uint32 recipe_id); + bool DisableRecipe(uint32 recipe_id); /* * Tribute