@@ -66,8 +66,8 @@ impl WorldExtension for Dungeon {
6666 let s = if seconds_remaining == 1 { "" } else { "s" } ;
6767 let str = format ! ( "§aStarting in {} second{}." , seconds_remaining, s) ;
6868
69- for player_rc in world . players . iter_mut ( ) {
70- let player = unsafe { & mut * player_rc . get ( ) } ;
69+ // todo: global packet buffer for these global stuff
70+ for player in world . players_mut ( ) {
7171 player. write_packet ( & Chat {
7272 component : ChatComponent :: new ( str. clone ( ) ) ,
7373 chat_type : 0 ,
@@ -127,8 +127,7 @@ impl WorldExtension for Dungeon {
127127 }
128128
129129 if let Some ( packet) = world. extension . map . get_packet ( ) {
130- for player_rc in world. players . iter_mut ( ) {
131- let player = unsafe { & mut * player_rc. get ( ) } ;
130+ for player in world. players_mut ( ) {
132131 player. write_packet ( & packet)
133132 }
134133 }
@@ -195,7 +194,7 @@ impl WorldExtension for Dungeon {
195194 player. flush_packets ( )
196195 }
197196
198- fn on_player_leave ( world : & mut World < Self > , player : & mut Player < Self :: Player > ) {
197+ fn on_player_leave ( _ : & mut World < Self > , player : & mut Player < Self :: Player > ) {
199198 if let Some ( ( room_rc, _) ) = & player. current_room {
200199 let mut room = room_rc. borrow_mut ( ) ;
201200 room. remove_player_ref ( player. client_id )
@@ -210,8 +209,7 @@ impl Dungeon {
210209 }
211210
212211 pub fn start_dungeon ( world : & mut World < Self > ) {
213- for player_rc in world. players . iter_mut ( ) {
214- let player = unsafe { & mut * player_rc. get ( ) } ;
212+ for player in world. players_mut ( ) {
215213 if let OpenContainer :: Menu ( _) = player. get_container ( ) {
216214 player. open_container ( OpenContainer :: None )
217215 }
@@ -243,16 +241,14 @@ impl Dungeon {
243241 chat_type : 0 ,
244242 } ;
245243
246- for player_rc in world. players . iter_mut ( ) {
247- let player = unsafe { & mut * player_rc. get ( ) } ;
244+ for player in world. players_mut ( ) {
248245 player. write_packet ( & packet)
249246 }
250247
251248 if is_ready {
252249 let mut should_start = true ;
253250
254- for player_rc in world. players . iter ( ) {
255- let player = unsafe { & * player_rc. get ( ) } ;
251+ for player in world. players_mut ( ) {
256252 if !player. extension . is_ready {
257253 should_start = false
258254 }
0 commit comments