Merge pull request #113 from Laupetin/fix/2d-material-text-icons
Fix 2d material text icons
This commit is contained in:
commit
52748b4cbe
@ -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)
|
||||
{
|
||||
Dedicated::SendChat = true;
|
||||
@ -87,6 +110,8 @@ namespace Components
|
||||
++text;
|
||||
}
|
||||
|
||||
StripMaterialTextIcons(text);
|
||||
|
||||
Game::Scr_AddEntity(player);
|
||||
Game::Scr_AddString(text + 1);
|
||||
Game::Scr_NotifyLevel(Game::SL_GetString("say", 0), 2);
|
||||
|
@ -14,6 +14,8 @@ namespace Components
|
||||
|
||||
static void Heartbeat();
|
||||
|
||||
static void StripMaterialTextIcons(char* text);
|
||||
|
||||
private:
|
||||
static bool SendChat;
|
||||
|
||||
|
@ -161,7 +161,12 @@ namespace Components
|
||||
Materials::ImageNameLength = 4 + 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;
|
||||
|
@ -469,6 +469,11 @@ namespace Components
|
||||
server.ping = (Game::Sys_Milliseconds() - i->sendTime);
|
||||
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
|
||||
i = ServerList::RefreshContainer.servers.erase(i);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user