]> git.cworth.org Git - empires-server/commit
game: Index players directly by session ID
authorCarl Worth <cworth@cworth.org>
Fri, 5 Jun 2020 13:57:04 +0000 (06:57 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 5 Jun 2020 14:46:37 +0000 (07:46 -0700)
commitb5a5c28f09756d7a7e65dd2bc75de130bc71e0dd
tree72a385ae3480eef9b990a1053e9e1b770cbb4961
parent16564f558ee42c3fbc0ca5ee56c91407253747b5
game: Index players directly by session ID

Previously we were just storing the players in an unordered array, and
doing an O(n) walk through the array to find a player with a session
ID that matched the ID of interest.

Instead, we now index directly with the session ID which is already
guaranteed yo be unique and is convenient in JavaScript where we can
use the session ID as a property name, and even use a convenient
subscript syntax for that.

With this change we don't even need to store the session_id property
on the player since it is now not used at all.
game.js