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

Toss lots of custom CString code

We already have a C standard library, so let's not reimplement it.
This commit is contained in:
2012-06-17 20:15:04 -04:00
parent 1556d147d9
commit f0af98b0a7
29 changed files with 91 additions and 251 deletions

View File

@ -412,7 +412,7 @@ protected:
void ISetUserType(plMaxNode* node, const char* userType)
{
if (hsStrEQ(userType, kUserTypeAll))
if (strcmp(userType, kUserTypeAll) == 0)
ISetNodeValue(nil);
}

View File

@ -963,12 +963,12 @@ protected:
void ISetUserType(plMaxNode* node, const char* userType)
{
if (hsStrEQ(userType, kUseParamBlockNodeString))
if (strcmp(userType, kUseParamBlockNodeString) == 0)
{
ISetNodeValue(nil);
fPB->SetValue(fTypeID, 0, plAnimObjInterface::kUseParamBlockNode);
}
else if (hsStrEQ(userType, kUseOwnerNodeString))
else if (strcmp(userType, kUseOwnerNodeString) == 0)
{
ISetNodeValue(nil);
fPB->SetValue(fTypeID, 0, plAnimObjInterface::kUseOwnerNode);

View File

@ -48,39 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvatar/plAnimStage.h"
// We don't want to be subject to any changes to ReadSafeString, so we just keep
// our own version now. Unfortunately, some files were saved with a modified
// version of it, so we need to keep all the backwards compatability BS
char* MyReadSafeString(hsStream* s)
{
char *name = nil;
uint16_t numChars = s->ReadLE16();
bool oldFormat = !(numChars & 0xf000);
if (oldFormat)
s->ReadLE16();
numChars &= ~0xf000;
hsAssert(numChars <= s->GetSizeLeft(), "Bad string");
if (numChars > 0)
{
name = new char[numChars+1];
s->Read(numChars, name);
name[numChars] = '\0';
}
return name;
}
void MyWriteSafeString(hsStream* s, const char* str)
{
int len = hsStrlen(str);
hsAssert(len<0xf000, "String too long");
s->WriteLE16(len | 0xf000);
if (len > 0)
s->Write(len, str);
}
plBaseStage::plBaseStage()
{
fName = nil;
@ -139,15 +106,15 @@ void plBaseStage::SetName(const char* name)
void plBaseStage::Read(hsStream *stream)
{
int version = stream->ReadLE16();
stream->ReadLE16();
delete [] fName;
fName = MyReadSafeString(stream);
fName = stream->ReadSafeString();
}
void plBaseStage::Write(hsStream *stream)
{
stream->WriteLE16(1);
MyWriteSafeString(stream, fName);
stream->WriteSafeString(fName);
}
void plBaseStage::IBaseClone(plBaseStage* clone)
@ -189,7 +156,7 @@ void plStandardStage::Read(hsStream *stream)
uint16_t version = stream->ReadLE16();
delete [] fAnimName;
fAnimName = MyReadSafeString(stream);
fAnimName = stream->ReadSafeString();
fNumLoops = stream->ReadLE32();
fLoopForever = stream->Readbool();
fForward = stream->ReadByte();
@ -214,7 +181,7 @@ void plStandardStage::Write(hsStream *stream)
stream->WriteLE16(2);
MyWriteSafeString(stream, fAnimName);
stream->WriteSafeString(fAnimName);
stream->WriteLE32(fNumLoops);
stream->Writebool(fLoopForever);
stream->WriteByte(fForward);
@ -357,7 +324,7 @@ void plStandardStage::IGetAnimName()
char buf[256];
edit->GetText(buf, sizeof(buf));
if (!hsStrEQ(buf, fAnimName))
if (strcmp(buf, fAnimName) != 0)
{
delete [] fAnimName;
fAnimName = hsStrcpy(buf);

View File

@ -332,7 +332,7 @@ void plResponderLinkProc::ILoadAgeFilenamesCombo(HWND hWnd, IParamBlock2 *pb)
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)name);
if (hsStrEQ(name, savedName))
if (strcmp(name, savedName) == 0)
SendMessage(hAge, CB_SETCURSEL, idx, 0);
}
}
@ -369,7 +369,7 @@ void plResponderLinkProc::ILoadParentAgeFilenamesCombo(HWND hWnd, IParamBlock2 *
int idx = SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)name);
if (hsStrEQ(name, savedName))
if (strcmp(name, savedName) == 0)
SendMessage(hAge, CB_SETCURSEL, idx, 0);
}
}

View File

@ -607,12 +607,12 @@ protected:
void ISetUserType(plMaxNode* node, const char* userType)
{
if (hsStrEQ(userType, kUserTypeAll))
if (strcmp(userType, kUserTypeAll) == 0)
{
ISetNodeValue(nil);
fPB->SetValue(fTypeID, 0, kNodePB);
}
else if (hsStrEQ(userType, kResponderNodeName))
else if (strcmp(userType, kResponderNodeName) == 0)
{
ISetNodeValue(nil);
fPB->SetValue(fTypeID, 0, kNodeResponder);