- fixed some places where FStrings were incorrectly used.

- replace all implicit conversions from FString to const char * in the header files (so that it can be test compiled with the implicit type conversion turned off without throwing thousands of identical errors.)
This commit is contained in:
Christoph Oelckers 2016-02-05 10:40:45 +01:00
parent c8d25378d5
commit 8da6483223
10 changed files with 19 additions and 19 deletions

View file

@ -69,7 +69,7 @@ public:
const char *GetBind(unsigned int index) const
{
if (index < NUM_KEYS) return Binds[index];
if (index < NUM_KEYS) return Binds[index].GetChars();
else return NULL;
}

View file

@ -1203,11 +1203,11 @@ static int DumpHash (FConsoleCommand **table, bool aliases, const char *pattern=
void FConsoleAlias::PrintAlias ()
{
if (m_Command[0])
if (m_Command[0].IsNotEmpty())
{
Printf (TEXTCOLOR_YELLOW "%s : %s\n", m_Name, m_Command[0].GetChars());
}
if (m_Command[1])
if (m_Command[1].IsNotEmpty())
{
Printf (TEXTCOLOR_ORANGE "%s : %s\n", m_Name, m_Command[1].GetChars());
}

View file

@ -925,7 +925,7 @@ void WriteUserInfo(FArchive &arc, userinfo_t &info)
case NAME_PlayerClass:
i = info.GetPlayerClassNum();
arc.WriteString(i == -1 ? "Random" : PlayerClasses[i].Type->DisplayName);
arc.WriteString(i == -1 ? "Random" : PlayerClasses[i].Type->DisplayName.GetChars());
break;
default:

View file

@ -1411,7 +1411,7 @@ void DBaseStatusBar::DrawLog ()
{
int hudwidth, hudheight;
if (CPlayer->LogText && *CPlayer->LogText)
if (CPlayer->LogText.IsNotEmpty())
{
// This uses the same scaling as regular HUD messages
switch (con_scaletext)

View file

@ -504,7 +504,7 @@ public:
int Draw(FOptionMenuDescriptor *desc, int y, int indent, bool selected)
{
const char *txt = mCurrent? (const char*)mAltText : mLabel;
const char *txt = mCurrent? mAltText.GetChars() : mLabel;
if (*txt == '$') txt = GStrings(txt + 1);
int w = SmallFont->StringWidth(txt) * CleanXfac_1;
int x = (screen->GetWidth() - w) / 2;

View file

@ -1189,7 +1189,7 @@ const char *APlayerPawn::GetSoundClass() const
// [GRB]
PClassPlayerPawn *pclass = GetClass();
return pclass->SoundClass.IsNotEmpty() ? pclass->SoundClass : "player";
return pclass->SoundClass.IsNotEmpty() ? pclass->SoundClass.GetChars() : "player";
}
//===========================================================================

View file

@ -151,8 +151,8 @@ struct FUDMFKey
FUDMFKey& operator =(const FString &val)
{
Type = UDMF_String;
IntVal = strtol(val, NULL, 0);
FloatVal = strtod(val, NULL);
IntVal = strtol(val.GetChars(), NULL, 0);
FloatVal = strtod(val.GetChars(), NULL);
StringVal = val;
return *this;
}

View file

@ -415,7 +415,7 @@ void S_Start ()
// Parse the global SNDINFO
S_ParseSndInfo(true);
if (*LocalSndInfo)
if (LocalSndInfo.IsNotEmpty())
{
// Now parse the local SNDINFO
int j = Wads.CheckNumForFullName(LocalSndInfo, true);
@ -432,7 +432,7 @@ void S_Start ()
if (parse_ss)
{
S_ParseSndSeq(*LocalSndSeq? Wads.CheckNumForFullName(LocalSndSeq, true) : -1);
S_ParseSndSeq(LocalSndSeq.IsNotEmpty()? Wads.CheckNumForFullName(LocalSndSeq, true) : -1);
}
LastLocalSndInfo = LocalSndInfo;
@ -2553,7 +2553,7 @@ int S_GetMusic (char **name)
{
int order;
if (mus_playing.name)
if (mus_playing.name.IsNotEmpty())
{
*name = copystring (mus_playing.name);
order = mus_playing.baseorder;

View file

@ -102,7 +102,7 @@ public:
}
FSoundID(const FString &name)
{
ID = S_FindSound(name);
ID = S_FindSound(name.GetChars());
}
FSoundID(const FSoundID &other)
{
@ -120,7 +120,7 @@ public:
}
FSoundID &operator=(const FString &name)
{
ID = S_FindSound(name);
ID = S_FindSound(name.GetChars());
return *this;
}
operator int() const

View file

@ -343,16 +343,16 @@ namespace StringFormat
// FName inline implementations that take FString parameters
inline FName::FName(const FString &text) { Index = NameData.FindName (text, text.Len(), false); }
inline FName::FName(const FString &text, bool noCreate) { Index = NameData.FindName (text, text.Len(), noCreate); }
inline FName &FName::operator = (const FString &text) { Index = NameData.FindName (text, text.Len(), false); return *this; }
inline FName &FNameNoInit::operator = (const FString &text) { Index = NameData.FindName (text, text.Len(), false); return *this; }
inline FName::FName(const FString &text) { Index = NameData.FindName (text.GetChars(), text.Len(), false); }
inline FName::FName(const FString &text, bool noCreate) { Index = NameData.FindName (text.GetChars(), text.Len(), noCreate); }
inline FName &FName::operator = (const FString &text) { Index = NameData.FindName (text.GetChars(), text.Len(), false); return *this; }
inline FName &FNameNoInit::operator = (const FString &text) { Index = NameData.FindName (text.GetChars(), text.Len(), false); return *this; }
// Hash FStrings on their contents. (used by TMap)
extern unsigned int SuperFastHash (const char *data, size_t len);
template<> struct THashTraits<FString>
{
hash_t Hash(const FString &key) { return (hash_t)SuperFastHash(key, key.Len()); }
hash_t Hash(const FString &key) { return (hash_t)SuperFastHash(key.GetChars(), key.Len()); }
// Compares two keys, returning zero if they are the same.
int Compare(const FString &left, const FString &right) { return left.Compare(right); }
};