Browse Source

Toss lots of custom CString code

We already have a C standard library, so let's not reimplement it.
Adam Johnson 13 years ago
parent
commit
f0af98b0a7
  1. 4
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 11
      Sources/Plasma/Apps/plFileEncrypt/main.cpp
  3. 6
      Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp
  4. 128
      Sources/Plasma/CoreLib/HeadSpin.cpp
  5. 14
      Sources/Plasma/CoreLib/HeadSpin.h
  6. 12
      Sources/Plasma/CoreLib/hsStream.cpp
  7. 24
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp
  8. 4
      Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGameGUIMgr.cpp
  9. 2
      Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp
  10. 4
      Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp
  11. 7
      Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp
  12. 6
      Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.cpp
  13. 10
      Sources/Plasma/PubUtilLib/plFile/hsFiles.cpp
  14. 3
      Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp
  15. 4
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  16. 2
      Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp
  17. 8
      Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp
  18. 8
      Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp
  19. 4
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp
  20. 4
      Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp
  21. 2
      Sources/Tools/MaxComponent/plAnimCompProc.cpp
  22. 4
      Sources/Tools/MaxComponent/plAnimComponent.cpp
  23. 45
      Sources/Tools/MaxComponent/plMultistageStage.cpp
  24. 4
      Sources/Tools/MaxComponent/plResponderLink.cpp
  25. 4
      Sources/Tools/MaxComponent/plResponderMtl.cpp
  26. 4
      Sources/Tools/MaxConvert/hsMaterialConverter.cpp
  27. 2
      Sources/Tools/MaxMain/plMaxNode.cpp
  28. 8
      Sources/Tools/MaxMain/plPluginResManager.cpp
  29. 4
      Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.cpp

4
Sources/Plasma/Apps/plClient/plClient.cpp

@ -1015,7 +1015,7 @@ void plClient::IQueueRoomLoad(const std::vector<plLocation>& locs, bool hold)
fLoadRooms.push_back(new LoadRequest(loc, hold)); fLoadRooms.push_back(new LoadRequest(loc, hold));
if (!lastAgeName || hsStrEQ(info->GetAge(), lastAgeName)) if (!lastAgeName || strcmp(info->GetAge(), lastAgeName) == 0)
lastAgeName = info->GetAge(); lastAgeName = info->GetAge();
else else
allSameAge = false; allSameAge = false;
@ -1208,7 +1208,7 @@ void plClient::IRoomLoaded(plSceneNode* node, bool hold)
int numMsgs = 0; int numMsgs = 0;
for (int i = 0; i < sizeof(ageMsgCount)/sizeof(AgeMsgCount); i++) for (int i = 0; i < sizeof(ageMsgCount)/sizeof(AgeMsgCount); i++)
{ {
if (hsStrEQ(ageMsgCount[i].AgeName, name)) if (strcmp(ageMsgCount[i].AgeName, name) == 0)
{ {
numMsgs = ageMsgCount[i].NumMsgs; numMsgs = ageMsgCount[i].NumMsgs;
break; break;

11
Sources/Plasma/Apps/plFileEncrypt/main.cpp

@ -62,37 +62,38 @@ void print_help() {
printf("\t-v|--version\t - Prints build version information\n"); printf("\t-v|--version\t - Prints build version information\n");
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool encrypt = true; bool encrypt = true;
const char* dir = "."; const char* dir = ".";
#define ARGCMP(y) (strcmp(argv[1], y) == 0)
if (argc > 1) if (argc > 1)
{ {
if (hsStrEQ(argv[1], "encrypt") || hsStrEQ(argv[1], "-e") ) if (ARGCMP("encrypt") || ARGCMP("-e") )
{ {
if (argc > 2) if (argc > 2)
dir = argv[2]; dir = argv[2];
encrypt = true; encrypt = true;
} }
else if (hsStrEQ(argv[1], "decrypt") || hsStrEQ(argv[1], "-d")) else if (ARGCMP("decrypt") || ARGCMP("-d"))
{ {
if (argc > 2) if (argc > 2)
dir = argv[2]; dir = argv[2];
encrypt = false; encrypt = false;
} }
else if(hsStrEQ(argv[1], "--help") || hsStrEQ(argv[1], "-h") || hsStrEQ(argv[1], "-?") || hsStrEQ(argv[1], "/?")) else if(ARGCMP("--help") || ARGCMP("-h") || ARGCMP("-?") || ARGCMP("/?"))
{ {
print_help(); print_help();
return 0; return 0;
} }
else if (hsStrEQ(argv[1], "-v") || hsStrEQ(argv[1], "--version")) else if (ARGCMP("-v") || ARGCMP("--version"))
{ {
print_version(); print_version();
return 0; return 0;
} }
} }
#undef ARGCMP
EncryptFiles(dir, ".age", encrypt); EncryptFiles(dir, ".age", encrypt);
EncryptFiles(dir, ".fni", encrypt); EncryptFiles(dir, ".fni", encrypt);

6
Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp

@ -95,7 +95,7 @@ int PrintHelp( void )
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (argc >= 1 && hsStrEQ(argv[1], "-v")) if (argc >= 1 && strcmp(argv[1], "-v") == 0)
{ {
PrintVersion(); PrintVersion();
return 0; return 0;
@ -110,9 +110,9 @@ int main(int argc, char* argv[])
int arg = 1; int arg = 1;
for (arg = 1; arg < argc; arg++) for (arg = 1; arg < argc; arg++)
{ {
if (hsStrEQ(argv[arg], "-s")) if (strcmp(argv[arg], "-s") == 0)
sounds = true; sounds = true;
else if (hsStrEQ(argv[arg], "-i")) else if (strcmp(argv[arg], "-i") == 0)
stats = true; stats = true;
else else
break; break;

128
Sources/Plasma/CoreLib/HeadSpin.cpp

@ -377,12 +377,6 @@ int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int
return hsMessageBoxWithOwner((hsWindowHndl)nil,message,caption,kind,icon); return hsMessageBoxWithOwner((hsWindowHndl)nil,message,caption,kind,icon);
} }
inline hsBool hsCompare(float a, float b, float delta)
{
return (fabs(a - b) < delta);
}
/* Generic psuedo RNG used in ANSI C. */ /* Generic psuedo RNG used in ANSI C. */
static unsigned long SEED = 1; static unsigned long SEED = 1;
int hsRand() int hsRand()
@ -398,24 +392,13 @@ void hsRandSeed(int seed)
SEED = seed; SEED = seed;
} }
/**************************************/ /**************************************/
int hsStrlen(const char src[])
{
if (src==nil)
return 0;
int i = 0;
while (src[i])
i++;
return i;
}
char* hsStrcpy(char dst[], const char src[]) char* hsStrcpy(char dst[], const char src[])
{ {
if (src) if (src)
{ {
if (dst == nil) if (dst == nil)
{ {
int count = hsStrlen(src); int count = strlen(src);
dst = (char *)malloc(count + 1); dst = (char *)malloc(count + 1);
memcpy(dst, src, count); memcpy(dst, src, count);
dst[count] = 0; dst[count] = 0;
@ -431,75 +414,16 @@ char* hsStrcpy(char dst[], const char src[])
return dst; return dst;
} }
bool hsStrEQ(const char s1[], const char s2[])
{
if (s1 && s2)
{
while (*s1)
if(*s1++ != *s2++)
return false;
return *s2 == 0;
}
return (!s1 && !s2);
}
bool hsStrCaseEQ(const char* s1, const char* s2)
{
if (s1 && s2)
{
while (*s1)
if(tolower(*s1++) != tolower(*s2++))
return false;
return *s2 == 0;
}
return (!s1 && !s2);
}
void hsStrcat(char dst[], const char src[])
{
if (src && dst)
{
dst += hsStrlen(dst);
while(*src)
*dst++ = *src++;
*dst = 0;
}
}
void hsStrLower(char *s) void hsStrLower(char *s)
{ {
if (s) if (s)
{ {
int i; int i;
for (i = 0; i < hsStrlen(s); i++) for (i = 0; i < strlen(s); i++)
s[i] = tolower(s[i]); s[i] = tolower(s[i]);
} }
} }
char* hsP2CString(const uint8_t pstring[], char cstring[])
{
char* cstr = cstring;
const uint8_t* stop = &pstring[1] + pstring[0];
pstring += 1; // skip length byte
while (pstring < stop)
*cstr++ = *pstring++;
*cstr = 0;
return cstring;
}
uint8_t* hsC2PString(const char cstring[], uint8_t pstring[])
{
int i;
for (i = 1; *cstring; i++)
pstring[i] = *cstring++;
pstring[0] = i - 1;
return pstring;
}
//// IStringToWString ///////////////////////////////////////////////////////// //// IStringToWString /////////////////////////////////////////////////////////
// Converts a char * string to a wchar_t * string // Converts a char * string to a wchar_t * string
@ -540,54 +464,6 @@ char *hsWStringToString( const wchar_t *str )
return sStr; return sStr;
} }
void hsCPathToMacPath(char* dst, char* fname)
{
int i;
int offset = 0;
hsBool prefix = 1; // Assume it's a relative path.
// KLUDGE: this determines whether a PC path is
// relative or absolute. True if relative, therefore
// we prefix the pathname with a colon.
hsStrcpy(dst, "");
if(strstr(fname, ":"))
{
prefix = 0;
}
else if(strstr(fname, "\\\\"))
{
prefix = 0;
offset = 2; // copy fname from 2-Bytes in. This removes
// the first two chars...
}
if(prefix)
{
hsStrcpy(dst, ":");
}
hsStrcat(dst, &fname[offset]);
// No more slashes? We're done. (Optimization? Not really I guess.)
if(!strstr(dst, "\\") && !strstr(dst, "/")) return;
for(i =0; i < hsStrlen(dst); i++)
{
if(dst[i] == '\\' || dst[i] == '/')
{
dst[i] = ':';
}
}
}
int hsRemove(const char * fname)
{
return remove(fname);
}
// //
// Microsoft SAMPLE CODE // Microsoft SAMPLE CODE
// returns array of allocated version info strings or nil // returns array of allocated version info strings or nil

14
Sources/Plasma/CoreLib/HeadSpin.h

@ -401,14 +401,7 @@ void SWAP (T & a, T & b) {
void hsStatusMessageF(const char * fmt, ...); void hsStatusMessageF(const char * fmt, ...);
#endif // PLASMA_EXTERNAL_RELEASE #endif // PLASMA_EXTERNAL_RELEASE
int hsStrlen(const char src[]);
char* hsStrcpy(char dstOrNil[], const char src[]); char* hsStrcpy(char dstOrNil[], const char src[]);
void hsStrcat(char dst[], const char src[]);
bool hsStrEQ(const char s1[], const char s2[]);
bool hsStrCaseEQ(const char* s1, const char* s2);
char* hsScalarToStr(float);
int hsRemove(const char* filename);
void hsCPathToMacPath(char* dst, char* fname);
void hsStrLower(char *s); void hsStrLower(char *s);
char * hsFormatStr(const char * fmt, ...); // You are responsible for returned memory. char * hsFormatStr(const char * fmt, ...); // You are responsible for returned memory.
char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory. char * hsFormatStrV(const char * fmt, va_list args); // You are responsible for returned memory.
@ -428,11 +421,6 @@ char * hsFormatStrV(const char * fmt, va_list args); // You are responsible f
# define strlwr hsStrLower # define strlwr hsStrLower
#endif #endif
// A pstring has a length uint8_t at the beginning, and no trailing 0
char* hsP2CString(const uint8_t pstring[], char cstring[]);
uint8_t* hsC2PString(const char cstring[], uint8_t pstring[]);
inline char* hsStrcpy(const char src[]) inline char* hsStrcpy(const char src[])
{ {
return hsStrcpy(nil, src); return hsStrcpy(nil, src);
@ -480,8 +468,6 @@ int hsMessageBox(const wchar_t message[], const wchar_t caption[], int kind, int
int hsMessageBoxWithOwner(hsWindowHndl owner, const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk); int hsMessageBoxWithOwner(hsWindowHndl owner, const char message[], const char caption[], int kind, int icon=hsMessageBoxIconAsterisk);
int hsMessageBoxWithOwner(hsWindowHndl owner, const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk); int hsMessageBoxWithOwner(hsWindowHndl owner, const wchar_t message[], const wchar_t caption[], int kind, int icon=hsMessageBoxIconAsterisk);
inline hsBool hsCompare(float a, float b, float delta=0.0001);
// flag testing / clearing // flag testing / clearing
#define hsCheckBits(f,c) ((f & c)==c) #define hsCheckBits(f,c) ((f & c)==c)
#define hsTestBits(f,b) ( (f) & (b) ) #define hsTestBits(f,b) ( (f) & (b) )

12
Sources/Plasma/CoreLib/hsStream.cpp

@ -118,7 +118,9 @@ hsStream::~hsStream()
uint32_t hsStream::WriteString(const char cstring[]) uint32_t hsStream::WriteString(const char cstring[])
{ {
return Write(hsStrlen(cstring), cstring); if (cstring)
return Write(strlen(cstring), cstring);
return 0;
} }
uint32_t hsStream::WriteFmt(const char * fmt, ...) uint32_t hsStream::WriteFmt(const char * fmt, ...)
@ -139,7 +141,9 @@ uint32_t hsStream::WriteFmtV(const char * fmt, va_list av)
uint32_t hsStream::WriteSafeStringLong(const char *string) uint32_t hsStream::WriteSafeStringLong(const char *string)
{ {
uint32_t len = hsStrlen(string); uint32_t len = 0;
if (string)
len = strlen(string);
WriteLE32(len); WriteLE32(len);
if (len > 0) if (len > 0)
{ {
@ -222,7 +226,9 @@ wchar_t *hsStream::ReadSafeWStringLong()
uint32_t hsStream::WriteSafeString(const char *string) uint32_t hsStream::WriteSafeString(const char *string)
{ {
int len = hsStrlen(string); int len = 0;
if (string)
len = strlen(string);
hsAssert(len<0xf000, xtl::format("string len of %d is too long for WriteSafeString %s, use WriteSafeStringLong", hsAssert(len<0xf000, xtl::format("string len of %d is too long for WriteSafeString %s, use WriteSafeStringLong",
string, len).c_str() ); string, len).c_str() );

24
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp

@ -149,14 +149,14 @@ PF_CONSOLE_CMD(
"string base64Key", "string base64Key",
"Set the Auth Server N key" "Set the Auth Server N key"
) { ) {
int baseLength = hsStrlen((const char *)params[0]); int baseLength = strlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8); kNetDiffieHellmanKeyBits / 8);
return; return;
} }
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(strlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kAuthDhNData); kNetDiffieHellmanKeyBits / 8, kAuthDhNData);
} }
@ -167,14 +167,14 @@ PF_CONSOLE_CMD(
"string base64Key", "string base64Key",
"Set the Auth Server X key" "Set the Auth Server X key"
) { ) {
int baseLength = hsStrlen((const char *)params[0]); int baseLength = strlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8); kNetDiffieHellmanKeyBits / 8);
return; return;
} }
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(strlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kAuthDhXData); kNetDiffieHellmanKeyBits / 8, kAuthDhXData);
} }
@ -190,14 +190,14 @@ PF_CONSOLE_CMD(
"string base64Key", "string base64Key",
"Set the Game Server N key" "Set the Game Server N key"
) { ) {
int baseLength = hsStrlen((const char *)params[0]); int baseLength = strlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8); kNetDiffieHellmanKeyBits / 8);
return; return;
} }
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(strlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGameDhNData); kNetDiffieHellmanKeyBits / 8, kGameDhNData);
} }
@ -208,14 +208,14 @@ PF_CONSOLE_CMD(
"string base64Key", "string base64Key",
"Set the Game Server X key" "Set the Game Server X key"
) { ) {
int baseLength = hsStrlen((const char *)params[0]); int baseLength = strlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8); kNetDiffieHellmanKeyBits / 8);
return; return;
} }
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(strlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGameDhXData); kNetDiffieHellmanKeyBits / 8, kGameDhXData);
} }
@ -241,14 +241,14 @@ PF_CONSOLE_CMD(
"string base64Key", "string base64Key",
"Set the GateKeeper Server N key" "Set the GateKeeper Server N key"
) { ) {
int baseLength = hsStrlen((const char *)params[0]); int baseLength = strlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8); kNetDiffieHellmanKeyBits / 8);
return; return;
} }
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(strlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGateKeeperDhNData); kNetDiffieHellmanKeyBits / 8, kGateKeeperDhNData);
} }
@ -259,13 +259,13 @@ PF_CONSOLE_CMD(
"string base64Key", "string base64Key",
"Set the GateKeeper Server X key" "Set the GateKeeper Server X key"
) { ) {
int baseLength = hsStrlen((const char *)params[0]); int baseLength = strlen((const char *)params[0]);
if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) { if ((kNetDiffieHellmanKeyBits / 8) != Base64DecodeSize(baseLength, (const char *)params[0])) {
PrintStringF(PrintString, "Invalid key: should be exactly %u bytes", PrintStringF(PrintString, "Invalid key: should be exactly %u bytes",
kNetDiffieHellmanKeyBits / 8); kNetDiffieHellmanKeyBits / 8);
return; return;
} }
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(strlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGateKeeperDhXData); kNetDiffieHellmanKeyBits / 8, kGateKeeperDhXData);
} }

4
Sources/Plasma/FeatureLib/pfGameGUIMgr/pfGameGUIMgr.cpp

@ -235,7 +235,7 @@ void pfGameGUIMgr::IAddDlgToList( hsKeyedObject *obj )
// check to see if it is the dialog we are waiting for to be loaded // check to see if it is the dialog we are waiting for to be loaded
for ( i=0 ; i<fDialogToSetKeyOf.Count() ; i++ ) for ( i=0 ; i<fDialogToSetKeyOf.Count() ; i++ )
{ {
if ( hsStrEQ(fDialogToSetKeyOf[i]->GetName(), mod->GetName()) ) if ( strcmp(fDialogToSetKeyOf[i]->GetName(), mod->GetName()) == 0 )
{ {
SetDialogToNotify(mod,fDialogToSetKeyOf[i]->GetKey()); SetDialogToNotify(mod,fDialogToSetKeyOf[i]->GetKey());
// now remove this entry... we did it // now remove this entry... we did it
@ -316,7 +316,7 @@ void pfGameGUIMgr::LoadDialog( const char *name, plKey recvrKey, const char *
int i; int i;
for ( i=0 ; i<fDialogToSetKeyOf.Count() ; i++ ) for ( i=0 ; i<fDialogToSetKeyOf.Count() ; i++ )
{ {
if ( hsStrEQ(fDialogToSetKeyOf[i]->GetName(), name) ) if ( strcmp(fDialogToSetKeyOf[i]->GetName(), name) == 0 )
{ {
alreadyLoaded = true; alreadyLoaded = true;
break; break;

2
Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp

@ -202,7 +202,7 @@ void plLayerMovie::Write(hsStream* s, hsResMgr* mgr)
{ {
plLayerAnimation::Write(s, mgr); plLayerAnimation::Write(s, mgr);
int len = hsStrlen(fMovieName); int len = (fMovieName) ? strlen(fMovieName) : 0;
s->WriteLE32(len); s->WriteLE32(len);
if( len ) if( len )
s->Write(len, fMovieName); s->Write(len, fMovieName);

4
Sources/Plasma/NucleusLib/pnKeyedObject/plKeyImp.cpp

@ -68,7 +68,9 @@ static uint16_t kClassType = CLASS_INDEX_SCOPED(plSceneNode);
static uint32_t kCloneID = 0; static uint32_t kCloneID = 0;
hsBool IsTrackedKey(const plKeyImp* key) hsBool IsTrackedKey(const plKeyImp* key)
{ {
return hsStrEQ(key->GetName(), kObjName) && key->GetUoid().GetClassType() == kClassType && key->GetUoid().GetCloneID() == kCloneID; return (strcmp(key->GetName(), kObjName) == 0) &&
key->GetUoid().GetClassType() == kClassType &&
key->GetUoid().GetCloneID() == kCloneID;
} }
#endif #endif

7
Sources/Plasma/NucleusLib/pnMessage/plMessage.cpp

@ -367,11 +367,10 @@ int plMsgXtlStringHelper::Peek(xtl::istring & stringref, hsStream* stream, const
// STATIC // STATIC
int plMsgCStringHelper::Poke(const char * str, hsStream* stream, const uint32_t peekOptions) int plMsgCStringHelper::Poke(const char * str, hsStream* stream, const uint32_t peekOptions)
{ {
plMessage::plStrLen strlen; plMessage::plStrLen len = (str) ? strlen(str) : 0;
strlen = (str)?hsStrlen(str):0; stream->WriteLE(len);
stream->WriteLE(strlen);
if (strlen) if (strlen)
stream->Write(strlen,str); stream->Write(len,str);
return stream->GetPosition(); return stream->GetPosition();
} }

6
Sources/Plasma/NucleusLib/pnNetCommon/plSynchedValue.cpp

@ -100,9 +100,9 @@ const plKey plSynchedValueBase::ISaveOrLoad(const plKey key, hsBool32 save, hsSt
stream->WriteByte(1); stream->WriteByte(1);
// I need to write a key to MY stream... // I need to write a key to MY stream...
#if 0 // DEBUG #if 0 // DEBUG
int32_t len = hsStrlen(key->GetName()); plStringBuffer<char> buf = key->GetName()->ToIso8859_1();
stream->WriteLE32(len); stream->WriteLE32(buf.GetSize());
stream->Write(len, key->GetName()); stream->Write(buf.GetSize(), buf.GetData());
#endif #endif
key->GetUoid().Write(stream); key->GetUoid().Write(stream);
} }

10
Sources/Plasma/PubUtilLib/plFile/hsFiles.cpp

@ -153,18 +153,20 @@ hsBool hsFolderIterator::NextFileSuffix(const char suffix[])
int hsFolderIterator::GetPathAndName(char pathandname[]) int hsFolderIterator::GetPathAndName(char pathandname[])
{ {
hsAssert(pathandname, "NULL path string");
const char* name = this->GetFileName(); const char* name = this->GetFileName();
int pathLen = hsStrlen(fPath); int pathLen = strlen(fPath);
// add 1 for null terminator // add 1 for null terminator
int totalLen = pathLen + sizeof(kDirChar) + hsStrlen(name) + 1; int totalLen = pathLen + sizeof(kDirChar) + strlen(name) + 1;
hsAssert(totalLen <= kFolderIterator_MaxPath, "Overrun kFolderIterator_MaxPath"); hsAssert(totalLen <= kFolderIterator_MaxPath, "Overrun kFolderIterator_MaxPath");
if (pathandname) if (pathandname)
{ hsStrcpy(pathandname, fPath); {
strcpy(pathandname, fPath);
if (pathLen > 0 && pathandname[pathLen - 1] != kDirChar) if (pathLen > 0 && pathandname[pathLen - 1] != kDirChar)
pathandname[pathLen++] = kDirChar; pathandname[pathLen++] = kDirChar;
hsStrcpy(pathandname + pathLen, name); strcpy(pathandname + pathLen, name);
} }
return totalLen; return totalLen;
} }

3
Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp

@ -518,7 +518,8 @@ bool plEncryptedStream::ICheckMagicString(FILE* fp)
char magicString[kMagicStringLen+1]; char magicString[kMagicStringLen+1];
fread(&magicString, kMagicStringLen, 1, fp); fread(&magicString, kMagicStringLen, 1, fp);
magicString[kMagicStringLen] = '\0'; magicString[kMagicStringLen] = '\0';
return (hsStrEQ(magicString, kMagicString) || hsStrEQ(magicString, kOldMagicString)); return strcmp(magicString, kMagicString) == 0 ||
strcmp(magicString, kOldMagicString) == 0;
} }
bool plEncryptedStream::IsEncryptedFile(const char* fileName) bool plEncryptedStream::IsEncryptedFile(const char* fileName)

4
Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp

@ -652,7 +652,7 @@ bool plSecureStream::ICheckMagicString(hsStream* s)
char magicString[kMagicStringLen+1]; char magicString[kMagicStringLen+1];
s->Read(kMagicStringLen, &magicString); s->Read(kMagicStringLen, &magicString);
magicString[kMagicStringLen] = '\0'; magicString[kMagicStringLen] = '\0';
return (hsStrEQ(magicString, kMagicString) != 0); return (strcmp(magicString, kMagicString) == 0);
} }
bool plSecureStream::ICheckMagicString(hsFD fp) bool plSecureStream::ICheckMagicString(hsFD fp)
@ -665,7 +665,7 @@ bool plSecureStream::ICheckMagicString(hsFD fp)
fread(&magicString, kMagicStringLen, 1, fp); fread(&magicString, kMagicStringLen, 1, fp);
#endif #endif
magicString[kMagicStringLen] = '\0'; magicString[kMagicStringLen] = '\0';
return (hsStrEQ(magicString, kMagicString) != 0); return (strcmp(magicString, kMagicString) == 0);
} }
bool plSecureStream::IsSecureFile(const char* fileName) bool plSecureStream::IsSecureFile(const char* fileName)

2
Sources/Plasma/PubUtilLib/plMessage/plLoadAgeMsg.cpp

@ -70,7 +70,7 @@ void plLoadAgeMsg::Write(hsStream* stream, hsResMgr* mgr)
plMessage::IMsgWrite(stream, mgr); plMessage::IMsgWrite(stream, mgr);
// write agename // write agename
uint8_t len=fAgeFilename?hsStrlen(fAgeFilename):0; uint8_t len = fAgeFilename ? strlen(fAgeFilename) : 0;
stream->WriteLE(len); stream->WriteLE(len);
if (len) if (len)
{ {

8
Sources/Plasma/PubUtilLib/plPipeline/hsG3DDeviceSelector.cpp

@ -415,19 +415,19 @@ void hsG3DDeviceRecord::Write(hsStream* s) const
int len; int len;
len = hsStrlen(fG3DDriverDesc); len = strlen(fG3DDriverDesc);
s->WriteLE32(len); s->WriteLE32(len);
s->Write(len, fG3DDriverDesc); s->Write(len, fG3DDriverDesc);
len = hsStrlen(fG3DDriverName); len = strlen(fG3DDriverName);
s->WriteLE32(len); s->WriteLE32(len);
s->Write(len, fG3DDriverName); s->Write(len, fG3DDriverName);
len = hsStrlen(fG3DDriverVersion); len = strlen(fG3DDriverVersion);
s->WriteLE32(len); s->WriteLE32(len);
s->Write(len, fG3DDriverVersion); s->Write(len, fG3DDriverVersion);
len = hsStrlen(fG3DDeviceDesc); len = strlen(fG3DDeviceDesc);
s->WriteLE32(len); s->WriteLE32(len);
s->Write(len, fG3DDeviceDesc); s->Write(len, fG3DDeviceDesc);

8
Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp

@ -244,7 +244,7 @@ plRegistryPageNode* plResManager::FindSinglePage(const char* path) const
PageMap::const_iterator it; PageMap::const_iterator it;
for (it = fAllPages.begin(); it != fAllPages.end(); it++) for (it = fAllPages.begin(); it != fAllPages.end(); it++)
{ {
if (hsStrCaseEQ((it->second)->GetPagePath(), path)) if (strcmpi((it->second)->GetPagePath(), path) == 0)
return it->second; return it->second;
} }
@ -1651,8 +1651,8 @@ plRegistryPageNode* plResManager::FindPage(const char* age, const char* page) co
for (it = fAllPages.begin(); it != fAllPages.end(); ++it) for (it = fAllPages.begin(); it != fAllPages.end(); ++it)
{ {
const plPageInfo& info = (it->second)->GetPageInfo(); const plPageInfo& info = (it->second)->GetPageInfo();
if (hsStrCaseEQ(info.GetAge(), age) && if (strcmpi(info.GetAge(), age) == 0 &&
hsStrCaseEQ(info.GetPage(), page)) strcmpi(info.GetPage(), page) == 0)
return it->second; return it->second;
} }
@ -1766,7 +1766,7 @@ hsBool plResManager::IteratePages(plRegistryPageIterator* iterator, const char*
if (page->GetPageInfo().GetLocation() == plLocation::kGlobalFixedLoc) if (page->GetPageInfo().GetLocation() == plLocation::kGlobalFixedLoc)
continue; continue;
if (!ageToRestrictTo || hsStrCaseEQ(page->GetPageInfo().GetAge(), ageToRestrictTo)) if (!ageToRestrictTo || strcmpi(page->GetPageInfo().GetAge(), ageToRestrictTo) == 0)
{ {
if (!iterator->EatPage(page)) if (!iterator->EatPage(page))
{ {

4
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -1468,8 +1468,8 @@ bool plSimpleStateVariable::Set(const char* v, int idx)
if (v && fVar.GetType()==plVarDescriptor::kString32) if (v && fVar.GetType()==plVarDescriptor::kString32)
{ {
hsAssert(hsStrlen(v)<32, "string length overflow"); hsAssert(strlen(v)<32, "string length overflow");
hsStrncpy(fS32[idx], v, 32); strncpy(fS32[idx], v, 32);
IVarSet(); IVarSet();
return true; return true;
} }

4
Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp

@ -310,7 +310,7 @@ void plProfileManagerFull::Update()
std::vector<plProfileBase*> group; std::vector<plProfileBase*> group;
for (int i = 0; i < fVars.size(); i++) for (int i = 0; i < fVars.size(); i++)
if (hsStrEQ(fVars[i]->GetGroup(), groupName)) if (strcmp(fVars[i]->GetGroup(), groupName) == 0)
group.push_back(fVars[i]); group.push_back(fVars[i]);
int x = 10; int x = 10;
@ -405,7 +405,7 @@ void plProfileManagerFull::IPrintGroup(hsStream* s, const char* groupName, bool
for (int i = 0; i < fVars.size(); i++) for (int i = 0; i < fVars.size(); i++)
{ {
plProfileVar* var = fVars[i]; plProfileVar* var = fVars[i];
if (hsStrEQ(var->GetGroup(), groupName)) if (strcmp(var->GetGroup(), groupName) == 0)
{ {
if (printTitle) if (printTitle)
sprintf(buf, "%s:%s", var->GetGroup(), var->GetName()); sprintf(buf, "%s:%s", var->GetGroup(), var->GetName());

2
Sources/Tools/MaxComponent/plAnimCompProc.cpp

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

4
Sources/Tools/MaxComponent/plAnimComponent.cpp

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

45
Sources/Tools/MaxComponent/plMultistageStage.cpp

@ -48,39 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvatar/plAnimStage.h" #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() plBaseStage::plBaseStage()
{ {
fName = nil; fName = nil;
@ -139,15 +106,15 @@ void plBaseStage::SetName(const char* name)
void plBaseStage::Read(hsStream *stream) void plBaseStage::Read(hsStream *stream)
{ {
int version = stream->ReadLE16(); stream->ReadLE16();
delete [] fName; delete [] fName;
fName = MyReadSafeString(stream); fName = stream->ReadSafeString();
} }
void plBaseStage::Write(hsStream *stream) void plBaseStage::Write(hsStream *stream)
{ {
stream->WriteLE16(1); stream->WriteLE16(1);
MyWriteSafeString(stream, fName); stream->WriteSafeString(fName);
} }
void plBaseStage::IBaseClone(plBaseStage* clone) void plBaseStage::IBaseClone(plBaseStage* clone)
@ -189,7 +156,7 @@ void plStandardStage::Read(hsStream *stream)
uint16_t version = stream->ReadLE16(); uint16_t version = stream->ReadLE16();
delete [] fAnimName; delete [] fAnimName;
fAnimName = MyReadSafeString(stream); fAnimName = stream->ReadSafeString();
fNumLoops = stream->ReadLE32(); fNumLoops = stream->ReadLE32();
fLoopForever = stream->Readbool(); fLoopForever = stream->Readbool();
fForward = stream->ReadByte(); fForward = stream->ReadByte();
@ -214,7 +181,7 @@ void plStandardStage::Write(hsStream *stream)
stream->WriteLE16(2); stream->WriteLE16(2);
MyWriteSafeString(stream, fAnimName); stream->WriteSafeString(fAnimName);
stream->WriteLE32(fNumLoops); stream->WriteLE32(fNumLoops);
stream->Writebool(fLoopForever); stream->Writebool(fLoopForever);
stream->WriteByte(fForward); stream->WriteByte(fForward);
@ -357,7 +324,7 @@ void plStandardStage::IGetAnimName()
char buf[256]; char buf[256];
edit->GetText(buf, sizeof(buf)); edit->GetText(buf, sizeof(buf));
if (!hsStrEQ(buf, fAnimName)) if (strcmp(buf, fAnimName) != 0)
{ {
delete [] fAnimName; delete [] fAnimName;
fAnimName = hsStrcpy(buf); fAnimName = hsStrcpy(buf);

4
Sources/Tools/MaxComponent/plResponderLink.cpp

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

4
Sources/Tools/MaxComponent/plResponderMtl.cpp

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

4
Sources/Tools/MaxConvert/hsMaterialConverter.cpp

@ -5020,7 +5020,7 @@ void hsMaterialConverter::IPrintDoneMaterials(const char* path, hsTArray<DoneMat
*dot = 0; *dot = 0;
char fileName[512]; char fileName[512];
if( path[hsStrlen(path)-1] == '\\' ) if( path[strlen(path)-1] == '\\' )
{ {
sprintf(fileName, "%slog\\mat_%s.log", path, maxFile); sprintf(fileName, "%slog\\mat_%s.log", path, maxFile);
} }
@ -5035,7 +5035,7 @@ void hsMaterialConverter::IPrintDoneMaterials(const char* path, hsTArray<DoneMat
// We may not have a \log folder. If that failed, try // We may not have a \log folder. If that failed, try
// putting it in the \dat folder. If that doesn't work, // putting it in the \dat folder. If that doesn't work,
// just quietly give up. // just quietly give up.
if( path[hsStrlen(path)-1] == '\\' ) if( path[strlen(path)-1] == '\\' )
{ {
sprintf(fileName, "%sdat\\mat_%s.log", path, maxFile); sprintf(fileName, "%sdat\\mat_%s.log", path, maxFile);
} }

2
Sources/Tools/MaxMain/plMaxNode.cpp

@ -3658,7 +3658,7 @@ void plMaxNode::SetupBonesAliasesRecur(const char *rootName)
char* start=strstr(propsBuf, "BoneName="); char* start=strstr(propsBuf, "BoneName=");
if (!start) if (!start)
start=strstr(propsBuf, "bonename="); start=strstr(propsBuf, "bonename=");
const int len = hsStrlen("BoneName="); const int len = strlen("BoneName=");
if(start && UserPropExists("BoneName")) if(start && UserPropExists("BoneName"))
{ {
start+=len; start+=len;

8
Sources/Tools/MaxMain/plPluginResManager.cpp

@ -195,7 +195,7 @@ void plPluginResManager::IPreLoadTextures(plRegistryPageNode* pageNode, int32_t
bool common = false; bool common = false;
for (int i = 0; i < plAgeDescription::kNumCommonPages; i++) for (int i = 0; i < plAgeDescription::kNumCommonPages; i++)
{ {
if (hsStrCaseEQ(plAgeDescription::GetCommonPage(i), pageNode->GetPageInfo().GetPage())) if (strcmpi(plAgeDescription::GetCommonPage(i), pageNode->GetPageInfo().GetPage()) == 0)
{ {
common = true; common = true;
break; break;
@ -327,7 +327,7 @@ plLocation plPluginResManager::ICreateLocation(const char* age, const char* page
plLocation plPluginResManager::ICreateLocation(const char* age, const char* page, int32_t seqNum, hsBool itinerant) plLocation plPluginResManager::ICreateLocation(const char* age, const char* page, int32_t seqNum, hsBool itinerant)
{ {
hsBool willBeReserved = hsStrCaseEQ(age, "global"); bool willBeReserved = strcmpi(age, "global") == 0;
int32_t oldNum = seqNum; int32_t oldNum = seqNum;
seqNum = VerifySeqNumber(seqNum, age, page); seqNum = VerifySeqNumber(seqNum, age, page);
@ -351,7 +351,7 @@ plLocation plPluginResManager::ICreateLocation(const char* age, const char* page
// Flag common pages // Flag common pages
for (int i = 0; i < plAgeDescription::kNumCommonPages; i++) for (int i = 0; i < plAgeDescription::kNumCommonPages; i++)
{ {
if (hsStrEQ(plAgeDescription::GetCommonPage(i), page)) if (strcmp(plAgeDescription::GetCommonPage(i), page) == 0)
{ {
newLoc.SetFlags(plLocation::kBuiltIn); newLoc.SetFlags(plLocation::kBuiltIn);
break; break;
@ -428,7 +428,7 @@ void plPluginResManager::AddLooseEnd(plKey key)
// Verifies that the given sequence number belongs to the given string combo and ONLY that combo. Returns a new, unique sequenceNumber if not // Verifies that the given sequence number belongs to the given string combo and ONLY that combo. Returns a new, unique sequenceNumber if not
int32_t plPluginResManager::VerifySeqNumber(int32_t sequenceNumber, const char* age, const char* page) int32_t plPluginResManager::VerifySeqNumber(int32_t sequenceNumber, const char* age, const char* page)
{ {
hsBool negated = false, willBeReserved = hsStrCaseEQ(age, "global"); bool negated = false, willBeReserved = strcmpi(age, "global") == 0;
if (sequenceNumber < 0) if (sequenceNumber < 0)
{ {
sequenceNumber = -sequenceNumber; sequenceNumber = -sequenceNumber;

4
Sources/Tools/MaxPlasmaMtls/Materials/plAnimStealthNode.cpp

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

Loading…
Cancel
Save