Skip to content

Commit 952b0e3

Browse files
committed
serialize only when the info is updated
1 parent 8dab473 commit 952b0e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

server/src/network/status.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ pub struct Status {
1515
players: u32,
1616
max_players: u32,
1717

18-
info: ChatComponent,
18+
serialized_info: String,
1919
icon: &'static str,
2020

2121
cached: Option<StatusBytes>,
2222
}
2323

2424
impl Status {
2525
pub fn new(players: u32, max_players: u32, info: ChatComponent, icon: &'static str) -> Self {
26-
Self { players, max_players, info, icon, cached: None, }
26+
Self { players, max_players, serialized_info: info.serialize(), icon, cached: None, }
2727
}
2828

2929
pub fn set(&mut self, update: StatusUpdate) {
3030
match update {
3131
StatusUpdate::Players(count) => self.players = count,
3232
StatusUpdate::MaxPlayers(count) => self.max_players = count,
33-
StatusUpdate::Info(component) => self.info = component,
33+
StatusUpdate::Info(component) => self.serialized_info = component.serialize(),
3434
StatusUpdate::Icon(icon_data) => self.icon = icon_data,
3535
}
3636
self.cached = None;
@@ -49,7 +49,7 @@ impl Status {
4949
}},
5050
"description": {},
5151
"favicon": "data:image/png;base64,{}"
52-
}}"#, self.max_players, self.players, self.info.serialize(), self.icon)))
52+
}}"#, self.max_players, self.players, self.serialized_info, self.icon)))
5353
}).clone()
5454
}
5555
}

0 commit comments

Comments
 (0)