* fixed wrong reading of cached item protos

* fixed+cleanup GetName and GetEntry script funcs
This commit is contained in:
false_genesis 2008-02-20 22:48:16 +00:00
parent c6b11a029e
commit 4dce611346
2 changed files with 13 additions and 8 deletions

View File

@ -463,9 +463,15 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set)
if(source.empty() || source == "guid") if(source.empty() || source == "guid")
{ {
Object *o = ws->objmgr.GetObj(id); Object *o = ws->objmgr.GetObj(id);
std::string n;
if(o) if(o)
return o->GetName(); {
else n = o->GetName();
if(!n.empty())
return n;
}
if(!o || n.empty())
{ {
// fallback if that guid is player guid, its maybe stored, so check that // fallback if that guid is player guid, its maybe stored, so check that
if(IS_PLAYER_GUID(id)) if(IS_PLAYER_GUID(id))
@ -506,7 +512,7 @@ DefReturnResult DefScriptPackage::SCGetEntry(CmdSet& Set)
DEF_RETURN_ERROR; DEF_RETURN_ERROR;
} }
DefReturnResult r; DefReturnResult r;
uint64 guid=DefScriptTools::toNumber(Set.defaultarg); uint64 guid=DefScriptTools::toUint64(Set.defaultarg);
r.ret="0"; r.ret="0";
Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid);
if(o) if(o)
@ -528,7 +534,7 @@ DefReturnResult DefScriptPackage::SCGetObjectType(CmdSet& Set)
DEF_RETURN_ERROR; DEF_RETURN_ERROR;
} }
DefReturnResult r; DefReturnResult r;
uint64 guid=DefScriptTools::toNumber(Set.defaultarg); uint64 guid=DefScriptTools::toUint64(Set.defaultarg);
r.ret="0"; r.ret="0";
Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid); Object *o=((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetObj(guid);
if(o) if(o)
@ -842,11 +848,11 @@ DefReturnResult DefScriptPackage::SCGetObjectValue(CmdSet &Set)
DEF_RETURN_ERROR; DEF_RETURN_ERROR;
} }
uint64 guid = DefScriptTools::toNumber(Set.defaultarg); uint64 guid = DefScriptTools::toUint64(Set.defaultarg);
Object *o = ws->objmgr.GetObj(guid); Object *o = ws->objmgr.GetObj(guid);
if(o) if(o)
{ {
uint32 v = (uint32)DefScriptTools::toNumber(Set.arg[0]); uint32 v = (uint32)DefScriptTools::toUint64(Set.arg[0]);
if(v > o->GetValuesCount()) if(v > o->GetValuesCount())
{ {
logerror("SCGetObjectValue ["I64FMTD", type %u]: invalid value index: %u",guid,o->GetTypeId(),v); logerror("SCGetObjectValue ["I64FMTD", type %u]: invalid value index: %u",guid,o->GetTypeId(),v);

View File

@ -179,7 +179,7 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
fh.read((char*)&total,4); fh.read((char*)&total,4);
logdetail("ItemProtoCache: %u item prototypes stored",total); logdetail("ItemProtoCache: %u item prototypes stored",total);
uint32 datasize,unk, counter = 0; uint32 datasize, counter = 0;
ByteBuffer buf; ByteBuffer buf;
for(uint32 i = 0; i < total && !fh.eof(); i++) for(uint32 i = 0; i < total && !fh.eof(); i++)
{ {
@ -192,7 +192,6 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
buf >> proto->Id; buf >> proto->Id;
buf >> proto->Class; buf >> proto->Class;
buf >> proto->SubClass; buf >> proto->SubClass;
buf >> unk;
buf >> proto->Name; buf >> proto->Name;
buf >> proto->DisplayInfoID; buf >> proto->DisplayInfoID;
buf >> proto->Quality; buf >> proto->Quality;