Fix crashes on SatCom in Moon missions (#1334)

fix-quicksave-sim-speed-crash
Mateusz Przybył 2020-07-22 00:37:37 +02:00 committed by GitHub
parent 5112bf86df
commit a5c7187017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 18 deletions

View File

@ -430,7 +430,7 @@ float CText::GetStringWidth(const std::string &text,
UTF8Char ch;
int len = StrUtils::Utf8CharSizeAt(text, index);
int len = GetCharSizeAt(font, text, index);
if (len >= 1)
ch.c1 = text[index];
if (len >= 2)
@ -565,7 +565,7 @@ int CText::Justify(const std::string &text, std::vector<FontMetaChar>::iterator
UTF8Char ch;
int len = StrUtils::Utf8CharSizeAt(text, index);
int len = GetCharSizeAt(font, text, index);
if (len >= 1)
ch.c1 = text[index];
if (len >= 2)
@ -606,7 +606,7 @@ int CText::Justify(const std::string &text, FontType font, float size, float wid
{
UTF8Char ch;
int len = StrUtils::Utf8CharSizeAt(text, index);
int len = GetCharSizeAt(font, text, index);
if (len >= 1)
ch.c1 = text[index];
if (len >= 2)
@ -648,12 +648,9 @@ int CText::Detect(const std::string &text, std::vector<FontMetaChar>::iterator f
if (format + fmtIndex != end)
font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);
// TODO: if (font == FONT_BUTTON)
//if (font == FONT_BUTTON) continue;
UTF8Char ch;
int len = StrUtils::Utf8CharSizeAt(text, index);
int len = GetCharSizeAt(font, text, index);
if (len >= 1)
ch.c1 = text[index];
if (len >= 2)
@ -686,7 +683,7 @@ int CText::Detect(const std::string &text, FontType font, float size, float offs
{
UTF8Char ch;
int len = StrUtils::Utf8CharSizeAt(text, index);
int len = GetCharSizeAt(font, text, index);
if (len >= 1)
ch.c1 = text[index];
if (len >= 2)
@ -898,16 +895,7 @@ void CText::StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &
if (format + index != end)
font = static_cast<FontType>(*(format + index) & FONT_MASK_FONT);
int len;
if(font == FONT_BUTTON)
{
len = 1;
}
else
{
len = StrUtils::Utf8CharSizeAt(text, index);
}
int len = GetCharSizeAt(font, text, index);
if (len >= 1)
ch.c1 = text[index];
@ -922,6 +910,20 @@ void CText::StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &
}
}
int CText::GetCharSizeAt(Gfx::FontType font, const std::string& text, unsigned int index) const
{
int len = 0;
if (font == FONT_BUTTON)
{
len = 1;
}
else
{
len = StrUtils::Utf8CharSizeAt(text, index);
}
return len;
}
void CText::DrawString(const std::string &text, FontType font,
float size, Math::IntPoint pos, int width, int eol, Color color)
{

View File

@ -337,6 +337,8 @@ protected:
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars);
void StringToUTFCharList(const std::string &text, std::vector<UTF8Char> &chars, std::vector<FontMetaChar>::iterator format, std::vector<FontMetaChar>::iterator end);
int GetCharSizeAt(Gfx::FontType font, const std::string& text, unsigned int index) const;
protected:
CEngine* m_engine;
CDevice* m_device;