diff --git a/src/Client/DefScript/DynamicEvent.cpp b/src/Client/DefScript/DynamicEvent.cpp index 9017be3..9f91b28 100644 --- a/src/Client/DefScript/DynamicEvent.cpp +++ b/src/Client/DefScript/DynamicEvent.cpp @@ -62,19 +62,26 @@ void DefScript_DynamicEventMgr::Update(void) for(DefDynamicEventList::iterator i = _storage.begin(); i != _storage.end(); i++) { sc = NULL; - (*i)->counter += diff; - if((*i)->counter >= (*i)->interval) - { - (*i)->counter %= (*i)->interval; + try + { + (*i)->counter += diff; + if((*i)->counter >= (*i)->interval) + { + (*i)->counter %= (*i)->interval; - if(!(*i)->parent.empty()) - sc = _pack->GetScript((*i)->parent); + if(!(*i)->parent.empty()) + sc = _pack->GetScript((*i)->parent); - if(sc) - _pack->RunSingleLineFromScript((*i)->cmd,sc); - else - _pack->RunSingleLine((*i)->cmd); - } + if(sc) + _pack->RunSingleLineFromScript((*i)->cmd,sc); + else + _pack->RunSingleLine((*i)->cmd); + } + } + catch (...) + { + printf("Error in DefScript_DynamicEventMgr::Update()\n"); + } } } \ No newline at end of file diff --git a/src/Client/DefScriptInterface.cpp b/src/Client/DefScriptInterface.cpp index c85880c..c7acee3 100644 --- a/src/Client/DefScriptInterface.cpp +++ b/src/Client/DefScriptInterface.cpp @@ -115,9 +115,11 @@ DefReturnResult DefScriptPackage::SCemote(CmdSet& Set){ return true; } + DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set) { DEF_RETURN_ERROR; // prevent execution for now + /* WorldSession *ws=((PseuInstance*)parentMethod)->GetWSession(); if(Set.defaultarg.empty()){ ws->SendChatMessage(CHAT_MSG_SAY,0,"Stopping! (Please give me a Playername to follow!)",""); @@ -131,6 +133,7 @@ DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set) else ss << "Can't follow player '"<SendChatMessage(CHAT_MSG_SAY,0,ss.str(),""); + */ return true; } diff --git a/src/Client/World/CMSGConstructor.cpp b/src/Client/World/CMSGConstructor.cpp index a68c6b3..1c96225 100644 --- a/src/Client/World/CMSGConstructor.cpp +++ b/src/Client/World/CMSGConstructor.cpp @@ -57,7 +57,7 @@ void WorldSession::SendEmote(uint32 id){ if(!_logged) return; WorldPacket packet; - packet << id << id << _targetGUID; // TODO: correct this! + packet << id << id << GetMyChar()->GetTarget(); packet.SetOpcode(CMSG_TEXT_EMOTE); SendWorldPacket(packet); } diff --git a/src/Client/World/CacheHandler.cpp b/src/Client/World/CacheHandler.cpp index f8422c6..89c590f 100644 --- a/src/Client/World/CacheHandler.cpp +++ b/src/Client/World/CacheHandler.cpp @@ -10,6 +10,9 @@ #include "CacheHandler.h" #include "Item.h" +// increase this number whenever you change something that makes old files unusable +uint32 ITEMPROTOTYPES_CACHE_VERSION = 0x00000000; + bool PlayerNameCache::AddInfo(uint64 guid, std::string name){ PlayerNameCacheItem *cacheItem=new PlayerNameCacheItem; cacheItem->_name=name; @@ -127,7 +130,16 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session) return; } - uint32 datasize,counter=0; + uint32 cacheversion; + fh.read((char*)&cacheversion,4); + if(cacheversion != ITEMPROTOTYPES_CACHE_VERSION) + { + logerror("ItemProtoCache is outdated! Creating new cache."); + fh.close(); + return; + } + + uint32 datasize,counter=0,unk; ByteBuffer buf; while(!fh.eof()) { @@ -139,6 +151,7 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session) buf >> proto->Id; buf >> proto->Class; buf >> proto->SubClass; + buf >> unk; for(uint8 i=0;i<4;i++) buf >> proto->Name[i]; buf >> proto->DisplayInfoID; @@ -202,12 +215,23 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session) buf >> proto->Material; buf >> proto->Sheath; buf >> proto->Extra; + buf >> proto->Unk1; // added in 2.0.3 buf >> proto->Block; buf >> proto->ItemSet; buf >> proto->MaxDurability; - buf >> proto->Area; - buf >> proto->Unknown1; - buf >> proto->Unknown2; // Added in 1.12.x client branch + buf >> proto->Area; + buf >> proto->Map; + buf >> proto->BagFamily; + buf >> proto->TotemCategory; // Added in 1.12.x client branch + for(uint32 s = 0; s < 3; s++) + { + buf >> proto->Socket[s].Color; + buf >> proto->Socket[s].Content; + } + buf >> proto->socketBonus; + buf >> proto->GemProperties; + buf >> proto->ExtendedCost; + buf >> proto->RequiredDisenchantSkill; if(proto->Id) { //DEBUG(logdebug("ItemProtoCache: Loaded %u [%s]",proto->Id, proto->Name[0].c_str())); @@ -232,7 +256,7 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session) logerror("ItemProtoCache: Could not write to file '%s'!",fn); return; } - + fh.write((char*)&(uint32)ITEMPROTOTYPES_CACHE_VERSION,4); uint32 counter=0; ByteBuffer buf; for(uint32 i=0;iobjmgr.GetItemProtoCount();i++) @@ -304,13 +328,24 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session) buf << proto->LockID; buf << proto->Material; buf << proto->Sheath; - buf << proto->Extra; - buf << proto->Block; - buf << proto->ItemSet; - buf << proto->MaxDurability; - buf << proto->Area; - buf << proto->Unknown1; - buf << proto->Unknown2; // Added in 1.12.x client branch + buf << proto->Extra; + buf << proto->Unk1; // added in 2.0.3 + buf << proto->Block; + buf << proto->ItemSet; + buf << proto->MaxDurability; + buf << proto->Area; + buf << proto->Map; + buf << proto->BagFamily; + buf << proto->TotemCategory; // Added in 1.12.x client branch + for(uint32 s = 0; s < 3; s++) + { + buf << proto->Socket[s].Color; + buf << proto->Socket[s].Content; + } + buf << proto->socketBonus; + buf << proto->GemProperties; + buf << proto->ExtendedCost; + buf << proto->RequiredDisenchantSkill; //DEBUG(logdebug("ItemProtoCache: Saved %u [%s]",proto->Id, proto->Name[0].c_str())); uint32 size = buf.size(); diff --git a/src/Client/World/Item.cpp b/src/Client/World/Item.cpp index 4e5f12c..1208970 100644 --- a/src/Client/World/Item.cpp +++ b/src/Client/World/Item.cpp @@ -9,11 +9,13 @@ void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket) ItemProto *proto = new ItemProto; recvPacket >> proto->Id; uint8 field[64]; + uint32 unk; memset(field,0,64); if(memcmp(recvPacket.contents()+sizeof(uint32),field,64)) { recvPacket >> proto->Class; recvPacket >> proto->SubClass; + recvPacket >> unk; // dont need that value? for(uint8 i=0;i<4;i++) recvPacket >> proto->Name[i]; recvPacket >> proto->DisplayInfoID; @@ -81,8 +83,18 @@ void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket) recvPacket >> proto->ItemSet; recvPacket >> proto->MaxDurability; recvPacket >> proto->Area; - recvPacket >> proto->Unknown1; - recvPacket >> proto->Unknown2; // Added in 1.12.x client branch + recvPacket >> proto->Map; + recvPacket >> proto->BagFamily; + recvPacket >> proto->TotemCategory; // Added in 1.12.x client branch + for(uint32 s = 0; s < 3; s++) + { + recvPacket >> proto->Socket[s].Color; + recvPacket >> proto->Socket[s].Content; + } + recvPacket >> proto->socketBonus; + recvPacket >> proto->GemProperties; + recvPacket >> proto->ExtendedCost; + recvPacket >> proto->RequiredDisenchantSkill; logdetail("Got Item Info: Id=%u Name='%s' ReqLevel=%u Armor=%u Desc='%s'", proto->Id, proto->Name[0].c_str(), proto->RequiredLevel, proto->Armor, proto->Description.c_str()); diff --git a/src/Client/World/Item.h b/src/Client/World/Item.h index bf5af58..f235749 100644 --- a/src/Client/World/Item.h +++ b/src/Client/World/Item.h @@ -316,13 +316,19 @@ struct _ItemSpell { uint32 SpellId; uint32 SpellTrigger; - uint32 SpellCharges; - uint32 SpellCooldown; + uint32 SpellCharges; + uint32 SpellCooldown; uint32 SpellCategory; - uint32 SpellCategoryCooldown; + uint32 SpellCategoryCooldown; }; +struct _ItemSocket +{ + uint32 Color; + uint32 Content; +}; + struct _ItemDamage { float DamageMin; @@ -381,13 +387,19 @@ struct ItemProto uint32 Material; uint32 Sheath; uint32 Extra; + uint32 Unk1; uint32 Block; uint32 ItemSet; uint32 MaxDurability; - uint32 Area; - uint32 BagFamily; - uint32 Unknown1; - uint32 Unknown2; + uint32 Area; + uint32 Map; + uint32 BagFamily; + uint32 TotemCategory; + _ItemSocket Socket[3]; + uint32 socketBonus; + uint32 GemProperties; + uint32 ExtendedCost; + uint32 RequiredDisenchantSkill; }; class Item : public Object diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index 09f355b..05e075b 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -18,8 +18,6 @@ WorldSession::WorldSession(PseuInstance *in) _instance = in; _valid=_authed=_logged=false; _socket=new WorldSocket(_sh,this); - _targetGUID=0; // no target - _followGUID=0; // dont follow anything _myGUID=0; // i dont have a guid yet plrNameCache.ReadFromFile(); // load names/guids of known players ItemProtoCache_InsertDataToSession(this); @@ -212,12 +210,6 @@ void WorldSession::SetTarget(uint64 guid) SendSetSelection(guid); } -// redundant for now -void WorldSession::SetFollowTarget(uint64 guid) -{ - _followGUID=guid; -} - void WorldSession::_OnEnterWorld(void) { if(!_logged) @@ -414,7 +406,7 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket) uint8 type=0; uint32 lang=0; uint64 target_guid=0; - uint32 msglen=0,unk; + uint32 msglen=0; std::string msg,channel=""; bool isCmd=false; diff --git a/src/Client/World/WorldSession.h b/src/Client/World/WorldSession.h index e911cf3..cc8c8a7 100644 --- a/src/Client/World/WorldSession.h +++ b/src/Client/World/WorldSession.h @@ -46,9 +46,7 @@ public: void SendWorldPacket(WorldPacket&); void SetTarget(uint64 guid); - uint64 GetTarget(void) { return _targetGUID; } - void SetFollowTarget(uint64 guid); - uint64 GetFollowTarget(void) { return _followGUID; } + uint64 GetTarget(void) { return GetMyChar()->GetTarget(); } uint64 GetGuid(void) { return _myGUID; } Channel *GetChannels(void) { return _channels; } MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); } @@ -107,7 +105,7 @@ private: bool _valid,_authed,_logged,_deleteme; // world status SocketHandler _sh; // handles the WorldSocket Channel *_channels; - uint64 _targetGUID,_followGUID,_myGUID; + uint64 _myGUID; }; #endif \ No newline at end of file diff --git a/src/tools/stuffextract/DBCFieldData.h b/src/tools/stuffextract/DBCFieldData.h index e2b4f98..5ae344a 100644 --- a/src/tools/stuffextract/DBCFieldData.h +++ b/src/tools/stuffextract/DBCFieldData.h @@ -191,4 +191,71 @@ static const char *ChrRacesFieldNames[] = "" }; +enum MapEnum +{ + MAP_ID = 0, + MAP_NAME_GENERAL = 1, + MAP_NAME1 = 4, + MAP_NAME2, + MAP_NAME3, + MAP_NAME4, + MAP_NAME5, + MAP_NAME6, + MAP_NAME7, + MAP_NAME8, + MAP_END = 75 +}; + +static const char *MapFieldNames[] = +{ + "","name_general","","","name","name","name","name","name","name", + "name","name","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","","","","","","","", + "","","","", + "" +}; + +static const char *MapFormat = +{ + "isxxssssss" + "ssxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxxxxxxx" + "xxxxx" +}; + +enum AreaTableEnum +{ + AREATABLE_ID = 0, + AREATABLE_NAME1 = 11, + AREATABLE_NAME2, + AREATABLE_NAME3, + AREATABLE_NAME4, + AREATABLE_NAME5, + AREATABLE_NAME6, + AREATABLE_NAME7, + AREATABLE_NAME8, + AREATABLE_END = 27, +}; + +static const char *AreaTableFieldNames[] = { + "","","","","","","","","","", + "name","name","name","name","name","name","name","name","","", + "","","","","","", + "" +}; + +static const char *AreaTableFormat = { + "ixxxxxxxxx" + "xssssssssx" + "xxxxxxx" +}; + #endif diff --git a/src/tools/stuffextract/StuffExtract.cpp b/src/tools/stuffextract/StuffExtract.cpp index 6a8e5f2..07ff11b 100644 --- a/src/tools/stuffextract/StuffExtract.cpp +++ b/src/tools/stuffextract/StuffExtract.cpp @@ -40,7 +40,7 @@ std::string AutoGetDataString(DBCFile::Iterator& it, const char* format, uint32 { if(format[field]=='i' || format[field]=='f') return toString( (*it).getInt(field) ); - if(format[field]=='s') + if(format[field]=='s' && (*it).getUInt(field)) return (*it).getString(field); return ""; } @@ -73,8 +73,8 @@ void OutSCP(char *fn, SCPStorageMap& scp) bool ConvertDBC(void) { std::map racemap; // needed to extract other dbc files correctly - SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage; // will store the converted data from dbc files - DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries; + SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage,MapDataStorage,AreaDataStorage; // will store the converted data from dbc files + DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries,Map,AreaTable; printf("Opening DBC archive...\n"); MPQHelper mpq; if(!mpq.AssignArchive("dbc")) @@ -88,6 +88,8 @@ bool ConvertDBC(void) EmotesTextSound.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextSound.dbc")); ChrRaces.openmem(mpq.ExtractFile("DBFilesClient\\ChrRaces.dbc")); SoundEntries.openmem(mpq.ExtractFile("DBFilesClient\\SoundEntries.dbc")); + Map.openmem(mpq.ExtractFile("DBFilesClient\\Map.dbc")); + AreaTable.openmem(mpq.ExtractFile("DBFilesClient\\AreaTable.dbc")); //... printf("DBC files opened.\n"); //... @@ -167,16 +169,51 @@ bool ConvertDBC(void) } } + printf("map info.."); + for(DBCFile::Iterator it = Map.begin(); it != Map.end(); ++it) + { + uint32 id = it->getUInt(MAP_ID); + for(uint32 field=MAP_ID; field < MAP_END; field++) + { + if(strlen(MapFieldNames[field])) + { + std::string value = AutoGetDataString(it,MapFormat,field); + if(value.size()) // only store if not null + MapDataStorage[id].push_back(std::string(MapFieldNames[field]) + "=" + value); + } + } + } + + printf("area.."); + for(DBCFile::Iterator it = AreaTable.begin(); it != AreaTable.end(); ++it) + { + uint32 id = it->getUInt(MAP_ID); + for(uint32 field=AREATABLE_ID; field < AREATABLE_END; field++) + { + if(strlen(AreaTableFieldNames[field])) + { + std::string value = AutoGetDataString(it,AreaTableFormat,field); + if(value.size()) // only store if not null + AreaDataStorage[id].push_back(std::string(AreaTableFieldNames[field]) + "=" + value); + } + } + } + + + //... printf("DONE!\n"); //... CreateDir("stuffextract"); - CreateDir("stuffextract/scp"); + CreateDir("stuffextract/data"); + CreateDir("stuffextract/data/scp"); printf("Writing SCP files:\n"); printf("emote.."); OutSCP(SCPDIR "/emote.scp",EmoteDataStorage); printf("race.."); OutSCP(SCPDIR "/race.scp",RaceDataStorage); printf("sound.."); OutSCP(SCPDIR "/sound.scp",SoundDataStorage); + printf("map.."); OutSCP(SCPDIR "/map.scp",MapDataStorage); + printf("area.."); OutSCP(SCPDIR "/area.scp",AreaDataStorage); //... printf("DONE!\n"); diff --git a/src/tools/stuffextract/StuffExtract.h b/src/tools/stuffextract/StuffExtract.h index 72af413..dc92952 100644 --- a/src/tools/stuffextract/StuffExtract.h +++ b/src/tools/stuffextract/StuffExtract.h @@ -7,7 +7,7 @@ #define SE_VERSION 1 #define MAPS_VERSION ((uint32)0) #define OUTDIR "stuffextract" -#define SCPDIR OUTDIR "/scp" +#define SCPDIR OUTDIR "/data/scp" typedef std::map< uint32,std::list > SCPStorageMap;