1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-20 04:09:16 +00:00

Avatar Clothing data => plString

This commit is contained in:
2014-01-10 00:01:53 -08:00
parent 71c9771cfb
commit 7de24157a5
12 changed files with 142 additions and 207 deletions

View File

@ -80,9 +80,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetClientComm/plNetClientComm.h"
plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fDescription(nil), fCustomText(nil), fThumbnail(nil),
fAccessory(nil), fAccessoryName(nil)
plClothingItem::plClothingItem() : fGroup(0), fTileset(0), fType(0), fSortOrder(0),
fThumbnail(nil), fAccessory(nil)
{
int i;
fTextures.Reset();
@ -99,16 +98,8 @@ plClothingItem::plClothingItem() : fName(nil), fGroup(0), fTileset(0), fType(0),
plClothingItem::~plClothingItem()
{
while (fElementNames.GetCount() > 0)
delete [] fElementNames.Pop();
while (fTextures.GetCount() > 0)
delete [] fTextures.Pop();
delete [] fName;
delete [] fDescription;
delete [] fCustomText;
delete [] fAccessoryName;
}
bool plClothingItem::CanWearWith(plClothingItem *item)
@ -169,14 +160,14 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
fGroup = s->ReadByte();
fType = s->ReadByte();
fTileset = s->ReadByte();
fSortOrder = s->ReadByte();
fCustomText = s->ReadSafeString();
fDescription = s->ReadSafeString();
fCustomText = s->ReadSafeString_TEMP();
fDescription = s->ReadSafeString_TEMP();
if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef); // thumbnail
@ -184,13 +175,13 @@ void plClothingItem::Read(hsStream *s, hsResMgr *mgr)
int i, j;
for (i = 0; i < tileCount; i++)
{
fElementNames.Append(s->ReadSafeString());
fElementNames.Append(s->ReadSafeString_TEMP());
int layerCount = s->ReadByte();
for (j = 0; j < layerCount; j++)
{
int layer = s->ReadByte();
mgr->ReadKeyNotifyMe(s, new plElementRefMsg(GetKey(), plRefMsg::kOnCreate, i, -1, nil, layer), plRefFlags::kActiveRef); // texture
mgr->ReadKeyNotifyMe(s, new plElementRefMsg(GetKey(), plRefMsg::kOnCreate, i, -1, plString::Null, layer), plRefFlags::kActiveRef); // texture
}
}
@ -274,13 +265,13 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr)
// EXPORT ONLY
plKey accessoryKey = nil;
if (fAccessoryName)
if (!fAccessoryName.IsEmpty())
{
plString strBuf = plString::Format("CItm_%s", fAccessoryName);
plString strBuf = plString::Format("CItm_%s", fAccessoryName.c_str());
accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", "", plClothingItem::Index(), strBuf);
if (accessoryKey == nil)
{
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName);
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName.c_str());
hsMessageBox(strBuf.c_str(), GetKeyName().c_str(), hsMessageBoxNormal);
}
}
@ -306,10 +297,10 @@ bool plClothingItem::MsgReceive(plMessage* msg)
if (fTextures.GetCount() <= eMsg->fWhich)
fTextures.ExpandAndZero(eMsg->fWhich + 1);
if (fElementNames.GetCount() <= eMsg->fWhich)
fElementNames.ExpandAndZero(eMsg->fWhich + 1);
fElementNames.Expand(eMsg->fWhich + 1);
if (fElementNames.Get(eMsg->fWhich) == nil)
fElementNames.Set(eMsg->fWhich, hsStrcpy(eMsg->fElementName));
if (fElementNames.Get(eMsg->fWhich).IsEmpty())
fElementNames.Set(eMsg->fWhich, eMsg->fElementName);
if (fTextures.Get(eMsg->fWhich) == nil)
{
plMipmap **layers = new plMipmap*[plClothingElement::kLayerMax];
@ -378,22 +369,16 @@ bool plClosetItem::IsMatch(plClosetItem *other)
/////////////////////////////////////////////////////////////////////////////
plClothingBase::plClothingBase() : fName(nil), fBaseTexture(nil), fLayoutName(nil) {}
plClothingBase::~plClothingBase()
{
delete [] fName;
delete [] fLayoutName;
}
plClothingBase::plClothingBase() : fBaseTexture(nil) {}
void plClothingBase::Read(hsStream* s, hsResMgr* mgr)
{
hsKeyedObject::Read(s, mgr);
fName = s->ReadSafeString();
fName = s->ReadSafeString_TEMP();
if (s->ReadBool())
mgr->ReadKeyNotifyMe(s, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, -1), plRefFlags::kActiveRef);
fLayoutName = s->ReadSafeString();
fLayoutName = s->ReadSafeString_TEMP();
}
void plClothingBase::Write(hsStream* s, hsResMgr* mgr)
@ -640,7 +625,7 @@ void plClothingOutfit::IAddItem(plClothingItem *item)
if (soundEffect)
{
if (!strcmp(item->fName, "03_MLFoot04_01") || !strcmp(item->fName, "03_FLFoot04_01"))
if (item->fName == "03_MLFoot04_01" || item->fName == "03_FLFoot04_01")
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeBare);
else
soundEffect->SetFootType(plArmatureEffectFootSound::kFootTypeShoe);
@ -1438,9 +1423,8 @@ void plClothingOutfit::IInstanceSharedMeshes(plClothingItem *item)
if (fAvatar)
fAvatar->ValidateMesh();
bool partialSort = item->fCustomText && strstr(item->fCustomText, "NeedsSort");
int i;
for (i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
bool partialSort = (item->fCustomText.Find("NeedsSort") >= 0);
for (int i = 0; i < plClothingItem::kMaxNumLODLevels; i++)
{
const plSceneObject *so = fAvatar->GetClothingSO(i);
if (so != nil && item->fMeshes[i] != nil)
@ -1619,23 +1603,21 @@ plClothingMgr::~plClothingMgr()
delete fItems.Pop();
}
plClothingLayout *plClothingMgr::GetLayout(char *name)
plClothingLayout *plClothingMgr::GetLayout(const plString &name) const
{
int i;
for (i = 0; i < fLayouts.GetCount(); i++)
for (int i = 0; i < fLayouts.GetCount(); i++)
{
if (!strcmp(fLayouts.Get(i)->fName, name))
if (fLayouts.Get(i)->fName == name)
return fLayouts.Get(i);
}
return nil;
}
plClothingElement *plClothingMgr::FindElementByName(const char *name)
plClothingElement *plClothingMgr::FindElementByName(const plString &name) const
{
int i;
for (i = 0; i < fElements.GetCount(); i++)
for (int i = 0; i < fElements.GetCount(); i++)
{
if (!strcmp(fElements.Get(i)->fName, name))
if (fElements.Get(i)->fName == name)
return fElements.Get(i);
}
return nil;
@ -1750,16 +1732,15 @@ void plClothingMgr::FilterUniqueMeshes(hsTArray<plClothingItem*> &items)
}
}
plClothingItem *plClothingMgr::FindItemByName(const char *name)
plClothingItem *plClothingMgr::FindItemByName(const plString &name) const
{
if (!name)
if (name.IsEmpty())
return nil;
int i;
for (i = 0; i < fItems.GetCount(); i++)
for (int i = 0; i < fItems.GetCount(); i++)
{
plClothingItem* item = fItems.Get(i);
if (!strcmp(item->fName, name))
if (item->fName == name)
return item;
}
return nil;
@ -1902,7 +1883,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
{
for (j = 0; j < fElements.GetCount(); j++)
{
if (!strcmp(item->fElementNames.Get(i), fElements.Get(j)->fName))
if (item->fElementNames.Get(i) == fElements.Get(j)->fName)
{
item->fElements.Set(i, fElements.Get(j));
break;
@ -1928,7 +1909,7 @@ void plClothingMgr::IAddItem(plClothingItem *item)
hsAssert(false, "Couldn't match all elements of added clothing item.");
}
void plClothingMgr::ChangeAvatar(const char* name, const plFileName &clothingFile)
void plClothingMgr::ChangeAvatar(const plString& name, const plFileName &clothingFile)
{
plAvatarMgr::GetInstance()->UnLoadLocalPlayer();
plAvatarMgr::GetInstance()->LoadPlayerFromFile(name, "", clothingFile);