* "GetName" should also use the player name cache, done.

* removed debug output from "processchatai" script.
This commit is contained in:
False.Genesis 2007-10-17 11:53:19 +00:00
parent f0b340ef3d
commit 659a9a7334
2 changed files with 8 additions and 5 deletions

View File

@ -126,8 +126,6 @@ loop
endif endif
endif endif
logdebug AI call: ${call}
if ${call} if ${call}
// logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched. // logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched.
${script},{${@0}},{${@1}},{${@2}},{${@3}},{${langname}} ${@def} ${script},{${@0}},{${@1}},{${@2}},{${@3}},{${langname}} ${@def}

View File

@ -407,7 +407,8 @@ DefReturnResult DefScriptPackage::SCGetPlayerGuid(CmdSet& Set)
DefReturnResult DefScriptPackage::SCGetName(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"); logerror("Invalid Script call: SCGetName: WorldSession not valid");
DEF_RETURN_ERROR; DEF_RETURN_ERROR;
@ -415,7 +416,7 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set)
DefReturnResult r; DefReturnResult r;
uint64 guid=DefScriptTools::toNumber(Set.defaultarg); uint64 guid=DefScriptTools::toNumber(Set.defaultarg);
r.ret="Unknown Entity"; r.ret="Unknown Entity";
Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); Object *o = ws->objmgr.GetObj(guid);
if(o) if(o)
{ {
if(o->GetTypeId()==TYPEID_ITEM || o->GetTypeId()==TYPEID_CONTAINER) if(o->GetTypeId()==TYPEID_ITEM || o->GetTypeId()==TYPEID_CONTAINER)
@ -431,6 +432,10 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set)
} }
else else
{ {
// 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); logerror("SCGetName: Object "I64FMT" not known",guid);
} }
return r; return r;