Merge pull request #113 from Laupetin/fix/2d-material-text-icons

Fix 2d material text icons
This commit is contained in:
Dss0 2021-08-21 13:22:18 +02:00 committed by GitHub
commit 52748b4cbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 1 deletions

View File

@ -76,6 +76,29 @@ namespace Components
} }
} }
void Dedicated::StripMaterialTextIcons(char* text)
{
char* currentChar = text;
bool isEscaped = false;
while (*currentChar)
{
if (*currentChar == '^')
{
isEscaped = true;
}
else if(isEscaped == true && (*currentChar == '\x01' || *currentChar == '\x02'))
{
*currentChar = ' ';
}
else
{
isEscaped = false;
}
currentChar++;
}
}
const char* Dedicated::EvaluateSay(char* text, Game::gentity_t* player) const char* Dedicated::EvaluateSay(char* text, Game::gentity_t* player)
{ {
Dedicated::SendChat = true; Dedicated::SendChat = true;
@ -87,6 +110,8 @@ namespace Components
++text; ++text;
} }
StripMaterialTextIcons(text);
Game::Scr_AddEntity(player); Game::Scr_AddEntity(player);
Game::Scr_AddString(text + 1); Game::Scr_AddString(text + 1);
Game::Scr_NotifyLevel(Game::SL_GetString("say", 0), 2); Game::Scr_NotifyLevel(Game::SL_GetString("say", 0), 2);

View File

@ -14,6 +14,8 @@ namespace Components
static void Heartbeat(); static void Heartbeat();
static void StripMaterialTextIcons(char* text);
private: private:
static bool SendChat; static bool SendChat;

View File

@ -161,7 +161,12 @@ namespace Components
Materials::ImageNameLength = 4 + length; Materials::ImageNameLength = 4 + length;
std::string image(imagePtr, length); std::string image(imagePtr, length);
return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material; auto* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material;
if(material == nullptr || material->techniqueSet == nullptr || material->techniqueSet->name == nullptr || strcmp(material->techniqueSet->name, "2d") != 0)
return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "default").material;
return material;
} }
Materials::ImageNameLength = 4; Materials::ImageNameLength = 4;

View File

@ -469,6 +469,11 @@ namespace Components
server.ping = (Game::Sys_Milliseconds() - i->sendTime); server.ping = (Game::Sys_Milliseconds() - i->sendTime);
server.addr = address; server.addr = address;
Dedicated::StripMaterialTextIcons(server.hostname.data());
Dedicated::StripMaterialTextIcons(server.mapname.data());
Dedicated::StripMaterialTextIcons(server.gametype.data());
Dedicated::StripMaterialTextIcons(server.mod.data());
// Remove server from queue // Remove server from queue
i = ServerList::RefreshContainer.servers.erase(i); i = ServerList::RefreshContainer.servers.erase(i);