* updated items & items cache to 2.0.12

* added extracting of map & area names to stuffextract
* code cleanups
This commit is contained in:
False.Genesis 2007-05-06 00:34:30 +00:00
parent f7f9d8b6b4
commit 54a37a3ff9
11 changed files with 214 additions and 51 deletions

View File

@ -62,19 +62,26 @@ void DefScript_DynamicEventMgr::Update(void)
for(DefDynamicEventList::iterator i = _storage.begin(); i != _storage.end(); i++) for(DefDynamicEventList::iterator i = _storage.begin(); i != _storage.end(); i++)
{ {
sc = NULL; sc = NULL;
(*i)->counter += diff; try
if((*i)->counter >= (*i)->interval) {
{ (*i)->counter += diff;
(*i)->counter %= (*i)->interval; if((*i)->counter >= (*i)->interval)
{
(*i)->counter %= (*i)->interval;
if(!(*i)->parent.empty()) if(!(*i)->parent.empty())
sc = _pack->GetScript((*i)->parent); sc = _pack->GetScript((*i)->parent);
if(sc) if(sc)
_pack->RunSingleLineFromScript((*i)->cmd,sc); _pack->RunSingleLineFromScript((*i)->cmd,sc);
else else
_pack->RunSingleLine((*i)->cmd); _pack->RunSingleLine((*i)->cmd);
} }
}
catch (...)
{
printf("Error in DefScript_DynamicEventMgr::Update()\n");
}
} }
} }

View File

@ -115,9 +115,11 @@ DefReturnResult DefScriptPackage::SCemote(CmdSet& Set){
return true; return true;
} }
DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set) DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set)
{ {
DEF_RETURN_ERROR; // prevent execution for now DEF_RETURN_ERROR; // prevent execution for now
/*
WorldSession *ws=((PseuInstance*)parentMethod)->GetWSession(); WorldSession *ws=((PseuInstance*)parentMethod)->GetWSession();
if(Set.defaultarg.empty()){ if(Set.defaultarg.empty()){
ws->SendChatMessage(CHAT_MSG_SAY,0,"Stopping! (Please give me a Playername to follow!)",""); ws->SendChatMessage(CHAT_MSG_SAY,0,"Stopping! (Please give me a Playername to follow!)","");
@ -131,6 +133,7 @@ DefReturnResult DefScriptPackage::SCfollow(CmdSet& Set)
else else
ss << "Can't follow player '"<<Set.defaultarg<<"' (not known)"; ss << "Can't follow player '"<<Set.defaultarg<<"' (not known)";
ws->SendChatMessage(CHAT_MSG_SAY,0,ss.str(),""); ws->SendChatMessage(CHAT_MSG_SAY,0,ss.str(),"");
*/
return true; return true;
} }

View File

@ -57,7 +57,7 @@ void WorldSession::SendEmote(uint32 id){
if(!_logged) if(!_logged)
return; return;
WorldPacket packet; WorldPacket packet;
packet << id << id << _targetGUID; // TODO: correct this! packet << id << id << GetMyChar()->GetTarget();
packet.SetOpcode(CMSG_TEXT_EMOTE); packet.SetOpcode(CMSG_TEXT_EMOTE);
SendWorldPacket(packet); SendWorldPacket(packet);
} }

View File

@ -10,6 +10,9 @@
#include "CacheHandler.h" #include "CacheHandler.h"
#include "Item.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){ bool PlayerNameCache::AddInfo(uint64 guid, std::string name){
PlayerNameCacheItem *cacheItem=new PlayerNameCacheItem; PlayerNameCacheItem *cacheItem=new PlayerNameCacheItem;
cacheItem->_name=name; cacheItem->_name=name;
@ -127,7 +130,16 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
return; 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; ByteBuffer buf;
while(!fh.eof()) while(!fh.eof())
{ {
@ -139,6 +151,7 @@ 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;
for(uint8 i=0;i<4;i++) for(uint8 i=0;i<4;i++)
buf >> proto->Name[i]; buf >> proto->Name[i];
buf >> proto->DisplayInfoID; buf >> proto->DisplayInfoID;
@ -202,12 +215,23 @@ void ItemProtoCache_InsertDataToSession(WorldSession *session)
buf >> proto->Material; buf >> proto->Material;
buf >> proto->Sheath; buf >> proto->Sheath;
buf >> proto->Extra; buf >> proto->Extra;
buf >> proto->Unk1; // added in 2.0.3
buf >> proto->Block; buf >> proto->Block;
buf >> proto->ItemSet; buf >> proto->ItemSet;
buf >> proto->MaxDurability; buf >> proto->MaxDurability;
buf >> proto->Area; buf >> proto->Area;
buf >> proto->Unknown1; buf >> proto->Map;
buf >> proto->Unknown2; // Added in 1.12.x client branch 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) if(proto->Id)
{ {
//DEBUG(logdebug("ItemProtoCache: Loaded %u [%s]",proto->Id, proto->Name[0].c_str())); //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); logerror("ItemProtoCache: Could not write to file '%s'!",fn);
return; return;
} }
fh.write((char*)&(uint32)ITEMPROTOTYPES_CACHE_VERSION,4);
uint32 counter=0; uint32 counter=0;
ByteBuffer buf; ByteBuffer buf;
for(uint32 i=0;i<session->objmgr.GetItemProtoCount();i++) for(uint32 i=0;i<session->objmgr.GetItemProtoCount();i++)
@ -304,13 +328,24 @@ void ItemProtoCache_WriteDataToCache(WorldSession *session)
buf << proto->LockID; buf << proto->LockID;
buf << proto->Material; buf << proto->Material;
buf << proto->Sheath; buf << proto->Sheath;
buf << proto->Extra; buf << proto->Extra;
buf << proto->Block; buf << proto->Unk1; // added in 2.0.3
buf << proto->ItemSet; buf << proto->Block;
buf << proto->MaxDurability; buf << proto->ItemSet;
buf << proto->Area; buf << proto->MaxDurability;
buf << proto->Unknown1; buf << proto->Area;
buf << proto->Unknown2; // Added in 1.12.x client branch 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())); //DEBUG(logdebug("ItemProtoCache: Saved %u [%s]",proto->Id, proto->Name[0].c_str()));
uint32 size = buf.size(); uint32 size = buf.size();

View File

@ -9,11 +9,13 @@ void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket)
ItemProto *proto = new ItemProto; ItemProto *proto = new ItemProto;
recvPacket >> proto->Id; recvPacket >> proto->Id;
uint8 field[64]; uint8 field[64];
uint32 unk;
memset(field,0,64); memset(field,0,64);
if(memcmp(recvPacket.contents()+sizeof(uint32),field,64)) if(memcmp(recvPacket.contents()+sizeof(uint32),field,64))
{ {
recvPacket >> proto->Class; recvPacket >> proto->Class;
recvPacket >> proto->SubClass; recvPacket >> proto->SubClass;
recvPacket >> unk; // dont need that value?
for(uint8 i=0;i<4;i++) for(uint8 i=0;i<4;i++)
recvPacket >> proto->Name[i]; recvPacket >> proto->Name[i];
recvPacket >> proto->DisplayInfoID; recvPacket >> proto->DisplayInfoID;
@ -81,8 +83,18 @@ void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket)
recvPacket >> proto->ItemSet; recvPacket >> proto->ItemSet;
recvPacket >> proto->MaxDurability; recvPacket >> proto->MaxDurability;
recvPacket >> proto->Area; recvPacket >> proto->Area;
recvPacket >> proto->Unknown1; recvPacket >> proto->Map;
recvPacket >> proto->Unknown2; // Added in 1.12.x client branch 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'", 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()); proto->Id, proto->Name[0].c_str(), proto->RequiredLevel, proto->Armor, proto->Description.c_str());

View File

@ -316,13 +316,19 @@ struct _ItemSpell
{ {
uint32 SpellId; uint32 SpellId;
uint32 SpellTrigger; uint32 SpellTrigger;
uint32 SpellCharges; uint32 SpellCharges;
uint32 SpellCooldown; uint32 SpellCooldown;
uint32 SpellCategory; uint32 SpellCategory;
uint32 SpellCategoryCooldown; uint32 SpellCategoryCooldown;
}; };
struct _ItemSocket
{
uint32 Color;
uint32 Content;
};
struct _ItemDamage struct _ItemDamage
{ {
float DamageMin; float DamageMin;
@ -381,13 +387,19 @@ struct ItemProto
uint32 Material; uint32 Material;
uint32 Sheath; uint32 Sheath;
uint32 Extra; uint32 Extra;
uint32 Unk1;
uint32 Block; uint32 Block;
uint32 ItemSet; uint32 ItemSet;
uint32 MaxDurability; uint32 MaxDurability;
uint32 Area; uint32 Area;
uint32 BagFamily; uint32 Map;
uint32 Unknown1; uint32 BagFamily;
uint32 Unknown2; uint32 TotemCategory;
_ItemSocket Socket[3];
uint32 socketBonus;
uint32 GemProperties;
uint32 ExtendedCost;
uint32 RequiredDisenchantSkill;
}; };
class Item : public Object class Item : public Object

View File

@ -18,8 +18,6 @@ WorldSession::WorldSession(PseuInstance *in)
_instance = in; _instance = in;
_valid=_authed=_logged=false; _valid=_authed=_logged=false;
_socket=new WorldSocket(_sh,this); _socket=new WorldSocket(_sh,this);
_targetGUID=0; // no target
_followGUID=0; // dont follow anything
_myGUID=0; // i dont have a guid yet _myGUID=0; // i dont have a guid yet
plrNameCache.ReadFromFile(); // load names/guids of known players plrNameCache.ReadFromFile(); // load names/guids of known players
ItemProtoCache_InsertDataToSession(this); ItemProtoCache_InsertDataToSession(this);
@ -212,12 +210,6 @@ void WorldSession::SetTarget(uint64 guid)
SendSetSelection(guid); SendSetSelection(guid);
} }
// redundant for now
void WorldSession::SetFollowTarget(uint64 guid)
{
_followGUID=guid;
}
void WorldSession::_OnEnterWorld(void) void WorldSession::_OnEnterWorld(void)
{ {
if(!_logged) if(!_logged)
@ -414,7 +406,7 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
uint8 type=0; uint8 type=0;
uint32 lang=0; uint32 lang=0;
uint64 target_guid=0; uint64 target_guid=0;
uint32 msglen=0,unk; uint32 msglen=0;
std::string msg,channel=""; std::string msg,channel="";
bool isCmd=false; bool isCmd=false;

View File

@ -46,9 +46,7 @@ public:
void SendWorldPacket(WorldPacket&); void SendWorldPacket(WorldPacket&);
void SetTarget(uint64 guid); void SetTarget(uint64 guid);
uint64 GetTarget(void) { return _targetGUID; } uint64 GetTarget(void) { return GetMyChar()->GetTarget(); }
void SetFollowTarget(uint64 guid);
uint64 GetFollowTarget(void) { return _followGUID; }
uint64 GetGuid(void) { return _myGUID; } uint64 GetGuid(void) { return _myGUID; }
Channel *GetChannels(void) { return _channels; } Channel *GetChannels(void) { return _channels; }
MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); } MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); }
@ -107,7 +105,7 @@ private:
bool _valid,_authed,_logged,_deleteme; // world status bool _valid,_authed,_logged,_deleteme; // world status
SocketHandler _sh; // handles the WorldSocket SocketHandler _sh; // handles the WorldSocket
Channel *_channels; Channel *_channels;
uint64 _targetGUID,_followGUID,_myGUID; uint64 _myGUID;
}; };
#endif #endif

View File

@ -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 #endif

View File

@ -40,7 +40,7 @@ std::string AutoGetDataString(DBCFile::Iterator& it, const char* format, uint32
{ {
if(format[field]=='i' || format[field]=='f') if(format[field]=='i' || format[field]=='f')
return toString( (*it).getInt(field) ); return toString( (*it).getInt(field) );
if(format[field]=='s') if(format[field]=='s' && (*it).getUInt(field))
return (*it).getString(field); return (*it).getString(field);
return ""; return "";
} }
@ -73,8 +73,8 @@ void OutSCP(char *fn, SCPStorageMap& scp)
bool ConvertDBC(void) bool ConvertDBC(void)
{ {
std::map<uint8,std::string> racemap; // needed to extract other dbc files correctly std::map<uint8,std::string> racemap; // needed to extract other dbc files correctly
SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage; // will store the converted data from dbc files SCPStorageMap EmoteDataStorage,RaceDataStorage,SoundDataStorage,MapDataStorage,AreaDataStorage; // will store the converted data from dbc files
DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries; DBCFile EmotesText,EmotesTextData,EmotesTextSound,ChrRaces,SoundEntries,Map,AreaTable;
printf("Opening DBC archive...\n"); printf("Opening DBC archive...\n");
MPQHelper mpq; MPQHelper mpq;
if(!mpq.AssignArchive("dbc")) if(!mpq.AssignArchive("dbc"))
@ -88,6 +88,8 @@ bool ConvertDBC(void)
EmotesTextSound.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextSound.dbc")); EmotesTextSound.openmem(mpq.ExtractFile("DBFilesClient\\EmotesTextSound.dbc"));
ChrRaces.openmem(mpq.ExtractFile("DBFilesClient\\ChrRaces.dbc")); ChrRaces.openmem(mpq.ExtractFile("DBFilesClient\\ChrRaces.dbc"));
SoundEntries.openmem(mpq.ExtractFile("DBFilesClient\\SoundEntries.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"); 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"); printf("DONE!\n");
//... //...
CreateDir("stuffextract"); CreateDir("stuffextract");
CreateDir("stuffextract/scp"); CreateDir("stuffextract/data");
CreateDir("stuffextract/data/scp");
printf("Writing SCP files:\n"); printf("Writing SCP files:\n");
printf("emote.."); OutSCP(SCPDIR "/emote.scp",EmoteDataStorage); printf("emote.."); OutSCP(SCPDIR "/emote.scp",EmoteDataStorage);
printf("race.."); OutSCP(SCPDIR "/race.scp",RaceDataStorage); printf("race.."); OutSCP(SCPDIR "/race.scp",RaceDataStorage);
printf("sound.."); OutSCP(SCPDIR "/sound.scp",SoundDataStorage); printf("sound.."); OutSCP(SCPDIR "/sound.scp",SoundDataStorage);
printf("map.."); OutSCP(SCPDIR "/map.scp",MapDataStorage);
printf("area.."); OutSCP(SCPDIR "/area.scp",AreaDataStorage);
//... //...
printf("DONE!\n"); printf("DONE!\n");

View File

@ -7,7 +7,7 @@
#define SE_VERSION 1 #define SE_VERSION 1
#define MAPS_VERSION ((uint32)0) #define MAPS_VERSION ((uint32)0)
#define OUTDIR "stuffextract" #define OUTDIR "stuffextract"
#define SCPDIR OUTDIR "/scp" #define SCPDIR OUTDIR "/data/scp"
typedef std::map< uint32,std::list<std::string> > SCPStorageMap; typedef std::map< uint32,std::list<std::string> > SCPStorageMap;