MCHPR / MCHPRS

A multithreaded Minecraft server built for redstone.
MIT License
1.62k stars 72 forks source link

Running current commit failed when having 2 players in a world #58

Closed hube12 closed 2 years ago

hube12 commented 2 years ago

022-01-18 23:43:23][mchprs::server][ERROR] plot panicked at 'index out of bounds: the len is 1 but the index is 1', src/plot/mod.rs:999:28

EwanFox commented 2 years ago

I think I see the issue, will go try to reproduce

StackDoubleFlow commented 2 years ago

There should be another error which causes the Drop implementation of Plot to run while there are still players in it just prior to this one. Would you be able to provide a more complete log?

hube12 commented 2 years ago

@StackDoubleFlow This was the only and sole error before the panic, nothing happened before. We only moved our player in and out of a plot albeit a bit fast but still. I did not have the backtrace full on tho.

hube12 commented 2 years ago

@BananaSquares Maybe use a if let guard with if let Some(player)= self.players.get(index)

Anyway player should be behind an Arc lock or a mutex. also index-1 would yield -1 for index=0 so probs not the fix.

StackDoubleFlow commented 2 years ago

Nah that's not going to actually fix that. That needs to be something like while !self.players.is_empty() instead of a for loop there.

EwanFox commented 2 years ago

59 should fix it