wrap noavatar uids at 10

fix noavatar uid loop
n5 pngcrush
This commit is contained in:
Azareal 2020-11-09 16:28:14 +10:00
parent b8c570c87e
commit 1e3a2f4cd6
4 changed files with 10 additions and 13 deletions

View File

@ -769,18 +769,16 @@ type GuestAvatar struct {
func buildNoavatar(uid, width int) string { func buildNoavatar(uid, width int) string {
if !Config.DisableNoavatarRange { if !Config.DisableNoavatarRange {
// TODO: Find a faster algorithm // TODO: Find a faster algorithm
if uid > 50000 { l := func(max int) {
uid -= 50000 for uid > max {
uid -= max
} }
if uid > 5000 {
uid -= 5000
}
if uid > 500 {
uid -= 500
}
for uid > 50 {
uid -= 50
} }
l(50000)
l(5000)
l(500)
l(50)
l(10)
} }
if !Config.DisableDefaultNoavatar && uid < 11 { if !Config.DisableDefaultNoavatar && uid < 11 {
if width == 200 { if width == 200 {

View File

@ -27,8 +27,7 @@ func main() {
// Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows // Capture panics instead of closing the window at a superhuman speed before the user can read the message on Windows
defer func() { defer func() {
r := recover() if r := recover() r != nil {
if r != nil {
fmt.Println(r) fmt.Println(r)
debug.PrintStack() debug.PrintStack()
pressAnyKey(scanner) pressAnyKey(scanner)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB