File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -249,10 +249,13 @@ export default class Game {
249
249
// check if its possible to spawn tank here
250
250
if ( this . world . isIntersecting ( tank , Collision . BLOCK_MOVE ) . length === 0 ) {
251
251
const client = this . clients [ tank . id ] ;
252
- tank . location = this . spawnPoints [ client . spawnId ] ;
253
- this . tanks [ tank . id ] = tank ;
254
- this . world . registerObject ( tank , Collision . BLOCK_ALL ) ;
255
- this . io . emit ( NetworkPacket . BOARD_STATE_TANKS , Object . values ( this . tanks ) ) ;
252
+ // abort respawning if client quit
253
+ if ( typeof client === 'object' ) {
254
+ tank . location = this . spawnPoints [ client . spawnId ] ;
255
+ this . tanks [ tank . id ] = tank ;
256
+ this . world . registerObject ( tank , Collision . BLOCK_ALL ) ;
257
+ this . io . emit ( NetworkPacket . BOARD_STATE_TANKS , Object . values ( this . tanks ) ) ;
258
+ }
256
259
} else {
257
260
// defer spawning
258
261
setTimeout ( ( ) => this . spawnTank ( tank ) , 1000 ) ;
You can’t perform that action at this time.
0 commit comments