diff --git a/bin/scripts/database_loader.def b/bin/scripts/database_loader.def index f4cd546..cb120ce 100644 --- a/bin/scripts/database_loader.def +++ b/bin/scripts/database_loader.def @@ -1,14 +1,14 @@ #script=register_db_loader if ?{not ?{IsHooked _startup}} - HookStart _startup - HookAdd db_loader_load_all - HookEnd - - // set up paths; ./data/scp and ./cache are set in the core already - // the SCP files placed in this directory are used to override some values - // in already present SCP files or to add custom fields or content - // note: it DOES matter in which order paths are added!! - AddDBPath ./data/scp-patches + HookStart _startup + HookAdd db_loader_load_all + HookEnd + + // set up paths; ./data/scp and ./cache are set in the core already + // the SCP files placed in this directory are used to override some values + // in already present SCP files or to add custom fields or content + // note: it DOES matter in which order paths are added!! + AddDBPath ./data/scp-patches endif //--------------------------------------------------------- @@ -26,6 +26,7 @@ LoadDB map LoadDB zone LoadDB creaturedisplayinfo LoadDB creaturemodeldata +LoadDB gameobjectdisplayinfo // LoadDB itemdisplayinfo // not yet used // LoadDB charsections // not yet used // LoadDB sound // not yet used diff --git a/bin/stuffextract_svn.exe b/bin/stuffextract_svn.exe index dd0ab63..36e28b1 100644 Binary files a/bin/stuffextract_svn.exe and b/bin/stuffextract_svn.exe differ diff --git a/src/Client/DefScriptInterface.cpp b/src/Client/DefScriptInterface.cpp index 92a8cf0..8df2751 100644 --- a/src/Client/DefScriptInterface.cpp +++ b/src/Client/DefScriptInterface.cpp @@ -113,7 +113,9 @@ DefReturnResult DefScriptPackage::SCsavecache(CmdSet& Set){ str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetItemProtoCount(); str << " Item Prototypes, "; str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetCreatureTemplateCount(); - str << " Creature Templates"; + str << " Creature Templates, "; + str << ((PseuInstance*)parentMethod)->GetWSession()->objmgr.GetGOTemplateCount(); + str << " GameObject Tempates"; str << " ]"; ((PseuInstance*)parentMethod)->GetWSession()->SendChatMessage(CHAT_MSG_SAY,0,str.str(),""); @@ -490,6 +492,11 @@ DefReturnResult DefScriptPackage::SCGetName(CmdSet& Set) CreatureTemplate *ct = ws->objmgr.GetCreatureTemplate((uint32)id); return ct ? ct->name : ""; } + else if(source == "gameobject") + { + GameobjectTemplate *gt = ws->objmgr.GetGOTemplate((uint32)id); + return gt ? gt->name : ""; + } // TODO: add gameobject, dynamicobject return ""; diff --git a/src/Client/GUI/DrawObject.cpp b/src/Client/GUI/DrawObject.cpp index 974851b..6d0feff 100644 --- a/src/Client/GUI/DrawObject.cpp +++ b/src/Client/GUI/DrawObject.cpp @@ -4,6 +4,8 @@ #include "PseuWoW.h" #include "Object.h" #include "Player.h" +#include "GameObject.h" +#include "WorldSession.h" using namespace irr; @@ -46,12 +48,44 @@ void DrawObject::_Init(void) if(!cube && _obj->IsWorldObject()) // only world objects have coords and can be drawn { - uint32 displayid = _obj->IsUnit() ? _obj->GetUInt32Value(UNIT_FIELD_DISPLAYID) : 0; // TODO: in case its GO get it from proto data - SCPDatabase *cdi = _instance->dbmgr.GetDB("creaturedisplayinfo"); - SCPDatabase *cmd = _instance->dbmgr.GetDB("creaturemodeldata"); - uint32 modelid = cdi && displayid ? cdi->GetUint32(displayid,"model") : 0; - std::string modelfile = std::string("data/model/") + cmd->GetString(modelid,"file"); - uint32 opacity = cdi && displayid ? cdi->GetUint32(displayid,"opacity") : 255; + std::string modelfile; + uint32 opacity = 255; + if (_obj->IsUnit()) + { + uint32 displayid = _obj->GetUInt32Value(UNIT_FIELD_DISPLAYID); + SCPDatabase *cdi = _instance->dbmgr.GetDB("creaturedisplayinfo"); + SCPDatabase *cmd = _instance->dbmgr.GetDB("creaturemodeldata"); + uint32 modelid = cdi && displayid ? cdi->GetUint32(displayid,"model") : 0; + modelfile = std::string("data/model/") + cmd->GetString(modelid,"file"); + opacity = cdi && displayid ? cdi->GetUint32(displayid,"opacity") : 255; + } + else if (_obj->IsGameObject()) + { + GameobjectTemplate* gotempl = _instance->GetWSession()->objmgr.GetGOTemplate(_obj->GetEntry()); + while (!gotempl) + { + ZThread::Thread::sleep(10); + gotempl = _instance->GetWSession()->objmgr.GetGOTemplate(_obj->GetEntry()); + } + if (gotempl) + { + // GAMEOBJECT_TYPE_TRAP + if (gotempl->type == 6) // damage source on fires, skip for now + { + _initialized = true; + return; + } + + uint32 displayid = gotempl->displayId; + SCPDatabase *gdi = _instance->dbmgr.GetDB("gameobjectdisplayinfo"); + if (gdi && displayid) + modelfile = std::string("data/model/") + gdi->GetString(displayid,"model"); + std::string test = gdi->GetString(displayid,"model"); + DEBUG(logdebug("GAMEOBJECT: %u - %u - %s", _obj->GetEntry(), displayid, test.c_str())); + } else { + DEBUG(logdebug("GAMEOBJECT UNKNOWN: %u", _obj->GetEntry())); + } + } scene::IAnimatedMesh *mesh = _smgr->getMesh(modelfile.c_str()); if(mesh) { @@ -61,7 +95,7 @@ void DrawObject::_Init(void) } else { - cube = _smgr->addCubeSceneNode(2); + cube = _smgr->addCubeSceneNode(1); } //cube->getMaterial(0).DiffuseColor.setAlpha(opacity); cube->setName("OBJECT"); diff --git a/src/Client/PseuWoW.cpp b/src/Client/PseuWoW.cpp index f43032c..9be86e4 100644 --- a/src/Client/PseuWoW.cpp +++ b/src/Client/PseuWoW.cpp @@ -392,6 +392,7 @@ void PseuInstance::SaveAllCache(void) GetWSession()->plrNameCache.SaveToFile(); ItemProtoCache_WriteDataToCache(GetWSession()); CreatureTemplateCache_WriteDataToCache(GetWSession()); + GOTemplateCache_WriteDataToCache(GetWSession()); //... } } diff --git a/src/Client/World/CacheHandler.cpp b/src/Client/World/CacheHandler.cpp index 3f85da0..4c520a8 100644 --- a/src/Client/World/CacheHandler.cpp +++ b/src/Client/World/CacheHandler.cpp @@ -617,7 +617,7 @@ void GOTemplateCache_WriteDataToCache(WorldSession *session) for(GOTemplateMap::iterator it = session->objmgr.GetGOTemplateStorage()->begin(); it != session->objmgr.GetGOTemplateStorage()->end(); it++) { buf.clear(); - GameobjectTemplate *go = new GameobjectTemplate(); + GameobjectTemplate *go = it->second; buf << go->entry; buf << go->type; buf << go->displayId; diff --git a/src/Client/World/Object.h b/src/Client/World/Object.h index 63d7b91..e4a9ed4 100644 --- a/src/Client/World/Object.h +++ b/src/Client/World/Object.h @@ -55,6 +55,7 @@ public: inline bool IsContainer(void) { return _typeid == TYPEID_CONTAINER; } // specific inline bool IsCorpse(void) { return _typeid == TYPEID_CORPSE; } // specific inline bool IsDynObject(void) { return _typeid == TYPEID_DYNAMICOBJECT; } // specific + inline bool IsGameObject(void) { return _typeid == TYPEID_GAMEOBJECT; } // specific inline bool IsWorldObject(void) { return _type & (TYPE_PLAYER | TYPE_UNIT | TYPE_CORPSE | TYPE_DYNAMICOBJECT | TYPE_GAMEOBJECT); } inline const uint32 GetUInt32Value( uint16 index ) const { diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index 4b9afca..dc8d947 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -109,6 +109,7 @@ void WorldSession::_LoadCache(void) plrNameCache.ReadFromFile(); // load names/guids of known players ItemProtoCache_InsertDataToSession(this); CreatureTemplateCache_InsertDataToSession(this); + GOTemplateCache_InsertDataToSession(this); //... } @@ -624,7 +625,7 @@ void WorldSession::_HandleCharEnumOpcode(WorldPacket& recvPacket) } if(!char_found) { - logerror("Character \"%s\" was not found on char list!", plr[charId]._name.c_str()); + logerror("Character \"%s\" was not found on char list!", GetInstance()->GetConf()->charname.c_str()); GetInstance()->SetError(); return; } diff --git a/src/tools/stuffextract/DBCFieldData.h b/src/tools/stuffextract/DBCFieldData.h index d970564..3af64af 100644 --- a/src/tools/stuffextract/DBCFieldData.h +++ b/src/tools/stuffextract/DBCFieldData.h @@ -407,6 +407,25 @@ static const char *CharSectionsFormat = { }; +// GameObjectDisplayInfo + +enum GameObjectDisplayInfoEnum +{ + GAMEOBJECTDISPLAYINFO_ID = 0, // <<-- this is the so-called DisplayID!! + GAMEOBJECTDISPLAYINFO_MODEL = 1, + GAMEOBJECTDISPLAYINFO_END = 18 +}; + +static const char *GameObjectDisplayInfoFieldNames[] = { + "","model","","","","","","","","", // 0-9 + "","","","","","","","" // 10-17 +}; + +static const char *GameObjectDisplayInfoFormat = { + "isxxxxxxxx" // 0-9 + "xxxxxxxx" // 10-17 +}; + diff --git a/src/tools/stuffextract/StuffExtract.cpp b/src/tools/stuffextract/StuffExtract.cpp index 1726500..5d82d26 100644 --- a/src/tools/stuffextract/StuffExtract.cpp +++ b/src/tools/stuffextract/StuffExtract.cpp @@ -255,9 +255,9 @@ bool ConvertDBC(void) { std::map racemap; // needed to extract other dbc files correctly SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage,MapDataStorage,ZoneDataStorage,ItemDisplayInfoStorage, - CreatureModelStorage,CreatureDisplayInfoStorage,NPCSoundStorage,CharSectionStorage; // will store the converted data from dbc files + CreatureModelStorage,CreatureDisplayInfoStorage,NPCSoundStorage,CharSectionStorage, GameObjectDisplayInfoStorage; // will store the converted data from dbc files DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries,Map,AreaTable,ItemDisplayInfo, - CreatureModelData,CreatureDisplayInfo,NPCSounds,CharSections; + CreatureModelData,CreatureDisplayInfo,NPCSounds,CharSections,GameObjectDisplayInfo; printf("Opening DBC archive...\n"); MPQHelper mpq("dbc"); @@ -272,6 +272,7 @@ bool ConvertDBC(void) ItemDisplayInfo.openmem(mpq.ExtractFile("DBFilesClient\\ItemDisplayInfo.dbc")); CreatureModelData.openmem(mpq.ExtractFile("DBFilesClient\\CreatureModelData.dbc")); CreatureDisplayInfo.openmem(mpq.ExtractFile("DBFilesClient\\CreatureDisplayInfo.dbc")); + GameObjectDisplayInfo.openmem(mpq.ExtractFile("DBFilesClient\\GameObjectDisplayInfo.dbc")); NPCSounds.openmem(mpq.ExtractFile("DBFilesClient\\NPCSounds.dbc")); CharSections.openmem(mpq.ExtractFile("DBFilesClient\\CharSections.dbc")); //... @@ -479,6 +480,30 @@ bool ConvertDBC(void) } } + printf("gameobjectdisplayinfo.."); + for(DBCFile::Iterator it = GameObjectDisplayInfo.begin(); it != GameObjectDisplayInfo.end(); ++it) + { + uint32 id = it->getUInt(GAMEOBJECTDISPLAYINFO_ID); + + for(uint32 field=GAMEOBJECTDISPLAYINFO_ID; field < GAMEOBJECTDISPLAYINFO_END; field++) + { + if(strlen(GameObjectDisplayInfoFieldNames[field])) + { + std::string value = AutoGetDataString(it,GameObjectDisplayInfoFormat,field); + if(value.size()) // only store if not null + { + // TODO: add check for wmo model files ? + if(doModels) + modelNames.insert(NameAndAlt(value)); // we need to extract model later, store it + std::string fn = _PathToFileName(value); + if(stricmp(fn.c_str()+fn.length()-4, "mdx")) + fn = fn.substr(0,fn.length()-3) + "m2"; + GameObjectDisplayInfoStorage[id].push_back(std::string(GameObjectDisplayInfoFieldNames[field]) + "=" + fn); + } + } + } + } + printf("npcsounds.."); for(DBCFile::Iterator it = NPCSounds.begin(); it != NPCSounds.end(); ++it) { @@ -544,6 +569,7 @@ bool ConvertDBC(void) printf("itemdisplayinfo.."); OutSCP(SCPDIR "/itemdisplayinfo.scp",ItemDisplayInfoStorage, "itemdisplayinfo"); printf("creaturemodeldata.."); OutSCP(SCPDIR "/creaturemodeldata.scp",CreatureModelStorage,"creaturemodeldata"); printf("creaturedisplayinfo.."); OutSCP(SCPDIR "/creaturedisplayinfo.scp",CreatureDisplayInfoStorage,"creaturedisplayinfo"); + printf("gameobjectdisplayinfo.."); OutSCP(SCPDIR "/gameobjectdisplayinfo.scp",GameObjectDisplayInfoStorage,"gameobjectdisplayinfo"); printf("npcsound.."); OutSCP(SCPDIR "/npcsound.scp",NPCSoundStorage,"npcsound"); printf("charsections.."); OutSCP(SCPDIR "/charsections.scp",CharSectionStorage,"charsections"); //... @@ -912,10 +938,13 @@ void FetchTexturesFromModel(ByteBuffer& bb) { bb.rpos(0); irr::scene::ModelHeader header; + if (bb.size() < sizeof(header)) + return; + bb.read((uint8*)&header, sizeof(header)); - if (header.version[0] != 4 && header.version[1] != 1 && header.version[2] != 0 && header.version[3] != 0) { - printf("Not model file!"); + if (header.version[0] != 4 || header.version[1] != 1 || header.version[2] != 0 || header.version[3] != 0) { + //printf("Not M2 model file!"); return; }