From 659a9a73341ed37793aedfac2cd4ec3dec70a40e Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Wed, 17 Oct 2007 11:53:19 +0000 Subject: [PATCH] * "GetName" should also use the player name cache, done. * removed debug output from "processchatai" script. --- bin/scripts/__core_chatAI.def | 2 -- src/Client/DefScriptInterface.cpp | 11 ++++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/scripts/__core_chatAI.def b/bin/scripts/__core_chatAI.def index 5ac4423..ae4ad9a 100644 --- a/bin/scripts/__core_chatAI.def +++ b/bin/scripts/__core_chatAI.def @@ -125,8 +125,6 @@ loop endif endif endif - - logdebug AI call: ${call} if ${call} // logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched. diff --git a/src/Client/DefScriptInterface.cpp b/src/Client/DefScriptInterface.cpp index 8617517..f446026 100644 --- a/src/Client/DefScriptInterface.cpp +++ b/src/Client/DefScriptInterface.cpp @@ -407,7 +407,8 @@ DefReturnResult DefScriptPackage::SCGetPlayerGuid(CmdSet& Set) DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set) { - if(!(((PseuInstance*)parentMethod)->GetWSession())) + WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); + if(!ws) { logerror("Invalid Script call: SCGetName: WorldSession not valid"); DEF_RETURN_ERROR; @@ -415,7 +416,7 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set) DefReturnResult r; uint64 guid=DefScriptTools::toNumber(Set.defaultarg); r.ret="Unknown Entity"; - Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); + Object *o = ws->objmgr.GetObj(guid); if(o) { if(o->GetTypeId()==TYPEID_ITEM || o->GetTypeId()==TYPEID_CONTAINER) @@ -431,7 +432,11 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set) } else { - logerror("SCGetName: Object "I64FMT" not known",guid); + // if no object with that guid is near, it might exist in the cache, check it and use that if present + if(ws->plrNameCache.IsKnown(guid)) + r.ret = ws->plrNameCache.GetName(guid); + else + logerror("SCGetName: Object "I64FMT" not known",guid); } return r; }