[saco] Implement/match GetColorFromEmbedCode(...)

This commit is contained in:
RD42 2024-07-22 18:37:27 +08:00
parent ed1646d102
commit 1f42d8cc6e
2 changed files with 40 additions and 0 deletions

View File

@ -1859,6 +1859,44 @@ BOOL IsHexChar(wchar_t c)
return c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f';
}
DWORD GetColorFromEmbedCode(char *szString)
{
if(szString[0] && szString[0] == '{'
&& szString[1] && IsHexChar(szString[1])
&& szString[2] && IsHexChar(szString[2])
&& szString[3] && IsHexChar(szString[3])
&& szString[4] && IsHexChar(szString[4])
&& szString[5] && IsHexChar(szString[5])
&& szString[6] && IsHexChar(szString[6])
&& szString[7] && szString[7] == '}')
{
char szBuffer[17];
memset(szBuffer,0,sizeof(szBuffer));
strncpy(szBuffer,szString+1,6);
return strtoul(szBuffer,NULL,16);
}
return 0xFFFFFFFF;
}
DWORD GetColorFromEmbedCode(wchar_t *szString)
{
if(szString[0] && szString[0] == '{'
&& szString[1] && IsHexChar(szString[1])
&& szString[2] && IsHexChar(szString[2])
&& szString[3] && IsHexChar(szString[3])
&& szString[4] && IsHexChar(szString[4])
&& szString[5] && IsHexChar(szString[5])
&& szString[6] && IsHexChar(szString[6])
&& szString[7] && szString[7] == '}')
{
wchar_t szBuffer[17];
memset(szBuffer,0,sizeof(szBuffer));
wcsncpy(szBuffer,szString+1,6);
return wcstoul(szBuffer,NULL,16);
}
return 0xFFFFFFFF;
}
DWORD unnamed_100B6100(char *szString, int nMaxLen)
{
char tmp_buf[2049];

View File

@ -67,3 +67,5 @@ BOOL __stdcall IsATrainPart(ENTITY_TYPE *pEntity);
BOOL IsHexChar(char c);
BOOL IsHexChar(wchar_t c);
DWORD GetColorFromEmbedCode(char *szString);
DWORD GetColorFromEmbedCode(wchar_t *szString);