mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-07 18:38:26 +00:00
Increase buffer size for player names in !recent menu
This commit is contained in:
parent
c00ab666be
commit
60d9609b7d
@ -1883,12 +1883,8 @@ public void SQL_RR_Callback(Database db, DBResultSet results, const char[] error
|
||||
results.FetchString(1, sMap, sizeof(sMap));
|
||||
|
||||
char sName[MAX_NAME_LENGTH];
|
||||
results.FetchString(2, sName, 10);
|
||||
|
||||
if(strlen(sName) >= 9)
|
||||
{
|
||||
Format(sName, MAX_NAME_LENGTH, "%s...", sName);
|
||||
}
|
||||
results.FetchString(2, sName, sizeof(sName));
|
||||
TrimPlayerName(sName, sName, sizeof(sName), 9);
|
||||
|
||||
char sTime[16];
|
||||
float fTime = results.FetchFloat(3);
|
||||
@ -2650,3 +2646,24 @@ float ExactTimeMaybe(float time, int exact_time)
|
||||
{
|
||||
return (exact_time != 0) ? view_as<float>(exact_time) : time;
|
||||
}
|
||||
|
||||
// https://forums.alliedmods.net/showthread.php?t=216841
|
||||
void TrimPlayerName(const char[] name, char[] outname, int len, int total_allowed_length)
|
||||
{
|
||||
int count, finallen;
|
||||
for(int i = 0; name[i]; i++)
|
||||
{
|
||||
count += ((name[i] & 0xc0) != 0x80) ? 1 : 0;
|
||||
|
||||
if(count <= total_allowed_length)
|
||||
{
|
||||
outname[i] = name[i];
|
||||
finallen = i;
|
||||
}
|
||||
}
|
||||
|
||||
outname[finallen + 1] = '\0';
|
||||
|
||||
if(count > total_allowed_length)
|
||||
Format(outname, len, "%s...", outname);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user