* "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

@ -125,8 +125,6 @@ loop
endif
endif
endif
logdebug AI call: ${call}
if ${call}
// logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched.

View File

@ -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;
}