[Chat]: Skip over '/' (#989)
This commit is contained in:
parent
c1809dbf7d
commit
ad59acc457
@ -51,6 +51,7 @@ namespace Components
|
||||
if (text[msgIndex] == '/')
|
||||
{
|
||||
SendChat = false;
|
||||
++msgIndex;
|
||||
}
|
||||
|
||||
if (IsMuted(player))
|
||||
@ -65,13 +66,14 @@ namespace Components
|
||||
Game::SV_GameSendServerCommand(player - Game::g_entities, Game::SV_CMD_CAN_IGNORE, Utils::String::VA("%c \"Chat is disabled\"", 0x65));
|
||||
}
|
||||
|
||||
// Message might be empty after the special characters
|
||||
// Message might be empty after the special characters or '/'
|
||||
if (text[msgIndex] == '\0')
|
||||
{
|
||||
SendChat = false;
|
||||
return text;
|
||||
}
|
||||
|
||||
TextRenderer::StripMaterialTextIcons(text, text, std::strlen(text) + 1);
|
||||
Logger::Print("{}: {}\n", Game::svs_clients[player - Game::g_entities].name, (text + msgIndex));
|
||||
|
||||
for (const auto& callback : SayCallbacks)
|
||||
@ -82,8 +84,6 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
TextRenderer::StripMaterialTextIcons(text, text, std::strlen(text) + 1);
|
||||
|
||||
Game::Scr_AddEntity(player);
|
||||
Game::Scr_AddString(text + msgIndex);
|
||||
Game::Scr_NotifyLevel(static_cast<std::uint16_t>(Game::SL_GetString("say", 0)), 2);
|
||||
|
@ -940,7 +940,7 @@ namespace Components
|
||||
}
|
||||
|
||||
const auto materialNameLen = static_cast<uint8_t>(*text);
|
||||
text++;
|
||||
++text;
|
||||
|
||||
for (auto i = 0u; i < materialNameLen; i++)
|
||||
{
|
||||
@ -954,8 +954,10 @@ namespace Components
|
||||
text += materialNameLen;
|
||||
|
||||
auto* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, materialName.data()).material;
|
||||
if (material == nullptr || material->techniqueSet == nullptr || material->techniqueSet->name == nullptr || strcmp(material->techniqueSet->name, "2d") != 0)
|
||||
if (material == nullptr || material->techniqueSet == nullptr || material->techniqueSet->name == nullptr || std::strcmp(material->techniqueSet->name, "2d") != 0)
|
||||
{
|
||||
material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "default").material;
|
||||
}
|
||||
|
||||
const auto yy = y - (h + yScale * static_cast<float>(font->pixelHeight)) * 0.5f;
|
||||
|
||||
@ -1091,7 +1093,7 @@ namespace Components
|
||||
if (renderFlags & Game::TEXT_RENDERFLAG_PADDING)
|
||||
xa += xScale * padding;
|
||||
++count;
|
||||
maxLengthRemaining--;
|
||||
--maxLengthRemaining;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1111,7 +1113,7 @@ namespace Components
|
||||
if (renderFlags & Game::TEXT_RENDERFLAG_PADDING)
|
||||
xa += xScale * padding;
|
||||
count += (fontIconEnd - curText) + 1;
|
||||
maxLengthRemaining--;
|
||||
--maxLengthRemaining;
|
||||
curText = fontIconEnd;
|
||||
continue;
|
||||
}
|
||||
@ -1222,8 +1224,8 @@ namespace Components
|
||||
if (renderFlags & Game::TEXT_RENDERFLAG_PADDING)
|
||||
xa += xScale * padding;
|
||||
|
||||
count++;
|
||||
maxLengthRemaining--;
|
||||
++count;
|
||||
--maxLengthRemaining;
|
||||
}
|
||||
|
||||
if (renderFlags & Game::TEXT_RENDERFLAG_CURSOR && count == cursorPos)
|
||||
@ -1240,10 +1242,14 @@ namespace Components
|
||||
auto maxWidth = 0;
|
||||
|
||||
if (maxChars <= 0)
|
||||
{
|
||||
maxChars = std::numeric_limits<int>::max();
|
||||
}
|
||||
|
||||
if (text == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto count = 0;
|
||||
while (text && *text && count < maxChars)
|
||||
@ -1259,7 +1265,7 @@ namespace Components
|
||||
{
|
||||
if (*text >= COLOR_FIRST_CHAR && *text <= COLOR_LAST_CHAR)
|
||||
{
|
||||
text++;
|
||||
++text;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1309,7 +1315,8 @@ namespace Components
|
||||
{
|
||||
maxWidth = lineWidth;
|
||||
}
|
||||
count++;
|
||||
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1328,7 +1335,7 @@ namespace Components
|
||||
if (!in || !out) return;
|
||||
|
||||
max--;
|
||||
size_t current = 0;
|
||||
std::size_t current = 0;
|
||||
while (*in != 0 && current < max)
|
||||
{
|
||||
const char index = *(in + 1);
|
||||
@ -1345,6 +1352,7 @@ namespace Components
|
||||
|
||||
++in;
|
||||
}
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
@ -1352,7 +1360,7 @@ namespace Components
|
||||
{
|
||||
char buffer[1024]{}; // 1024 is a lucky number in the engine
|
||||
StripColors(in.data(), buffer, sizeof(buffer));
|
||||
return {buffer};
|
||||
return std::string{ buffer };
|
||||
}
|
||||
|
||||
void TextRenderer::StripMaterialTextIcons(const char* in, char* out, std::size_t max)
|
||||
@ -1399,6 +1407,7 @@ namespace Components
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
@ -1406,7 +1415,7 @@ namespace Components
|
||||
{
|
||||
char buffer[1000]{}; // Should be more than enough
|
||||
StripAllTextIcons(in.data(), buffer, sizeof(buffer));
|
||||
return {buffer};
|
||||
return std::string{ buffer };
|
||||
}
|
||||
|
||||
void TextRenderer::StripAllTextIcons(const char* in, char* out, std::size_t max)
|
||||
@ -1414,7 +1423,7 @@ namespace Components
|
||||
if (!in || !out) return;
|
||||
|
||||
--max;
|
||||
size_t current = 0;
|
||||
std::size_t current = 0;
|
||||
while (*in != 0 && current < max)
|
||||
{
|
||||
if (*in == '^' && (in[1] == '\x01' || in[1] == '\x02'))
|
||||
@ -1422,18 +1431,25 @@ namespace Components
|
||||
in += 2;
|
||||
|
||||
if (*in) // width
|
||||
in++;
|
||||
{
|
||||
++in;
|
||||
}
|
||||
|
||||
if (*in) // height
|
||||
in++;
|
||||
{
|
||||
++in;
|
||||
}
|
||||
|
||||
if (*in) // material name length + material name characters
|
||||
{
|
||||
const auto materialNameLength = *in;
|
||||
in++;
|
||||
++in;
|
||||
for (auto i = 0; i < materialNameLength; i++)
|
||||
{
|
||||
if (*in)
|
||||
in++;
|
||||
{
|
||||
++in;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1486,16 +1502,16 @@ namespace Components
|
||||
|
||||
if (c == '^' && *curText >= COLOR_FIRST_CHAR && *curText <= COLOR_LAST_CHAR && !(cursorPos > count && cursorPos < count + 2))
|
||||
{
|
||||
curText++;
|
||||
count++;
|
||||
++curText;
|
||||
++count;
|
||||
}
|
||||
else if(c != '\r' && c != '\n')
|
||||
{
|
||||
len++;
|
||||
++len;
|
||||
}
|
||||
|
||||
count++;
|
||||
lenWithInvisibleTail++;
|
||||
++count;
|
||||
++lenWithInvisibleTail;
|
||||
}
|
||||
|
||||
return lenWithInvisibleTail;
|
||||
@ -1524,17 +1540,17 @@ namespace Components
|
||||
{
|
||||
Utils::Hook::Set<char>(0x535629, limit); // DrawText2d
|
||||
Utils::Hook::Set<char>(0x4C1BE4, limit); // SEH_PrintStrlen
|
||||
Utils::Hook::Set<char>(0x4863DD, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x486429, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x49A5A8, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x4863DD, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x486429, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x49A5A8, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x505721, limit); // R_TextWidth
|
||||
Utils::Hook::Set<char>(0x505801, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x50597F, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x5815DB, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x592ED0, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x5A2E2E, limit); // No idea :P
|
||||
Utils::Hook::Set<char>(0x505801, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x50597F, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x5815DB, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x592ED0, limit); // No idea
|
||||
Utils::Hook::Set<char>(0x5A2E2E, limit); // No idea
|
||||
|
||||
Utils::Hook::Set<char>(0x5A2733, static_cast<char>(ColorIndexForChar(limit))); // No idea :P
|
||||
Utils::Hook::Set<char>(0x5A2733, static_cast<char>(ColorIndexForChar(limit))); // No idea
|
||||
}
|
||||
|
||||
// Patches team overhead normally
|
||||
@ -1654,7 +1670,7 @@ namespace Components
|
||||
fontIconLookup.emplace(std::make_pair(entry.iconName, entry));
|
||||
}
|
||||
|
||||
std::sort(fontIconList.begin(), fontIconList.end(), [](const FontIconTableEntry& a, const FontIconTableEntry& b)
|
||||
std::ranges::sort(fontIconList, [](const FontIconTableEntry& a, const FontIconTableEntry& b) -> bool
|
||||
{
|
||||
return a.iconName < b.iconName;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user