<?php declare(strict_types=1);

$session = Smr\Session::getInstance();
$var = $session->getCurrentVar();
$account = $session->getAccount();

// register game_id
$session->updateGame($var['game_id']);

$player = SmrPlayer::getPlayer($account->getAccountID(), $var['game_id']);
$player->updateLastCPLAction();

// Check to see if newbie status has changed
$player->updateNewbieStatus();

// get rid of old plotted course
$player->deletePlottedCourse();
$player->update();

// log
$player->log(LOG_TYPE_GAME_ENTERING, 'Player entered game ' . $player->getGameID());

$container = Page::create('skeleton.php', 'current_sector.php');
$container->go();

<?php declare(strict_types=1);

$session = Smr\Session::getInstance();
$var = $session->getCurrentVar();
$account = $session->getAccount();

// register game_id
$session->updateGame($var['game_id']);

$player = SmrPlayer::getPlayer($account->getAccountID(), $var['game_id']);
acquire_lock($player->getSectorID()); // skip var update in do_voodoo

$player->updateLastCPLAction();

// Check to see if newbie status has changed
$player->updateNewbieStatus();

// get rid of old plotted course
$player->deletePlottedCourse();
$player->update();

// log
$player->log(LOG_TYPE_GAME_ENTERING, 'Player entered game ' . $player->getGameID());

$container = Page::create('skeleton.php', 'current_sector.php');
$container->go();

Fix reloading the wrong session $var
Fix reloading the wrong session $var

In `do_voodoo`, we reload the session var from the database whenever
we're in a game, but don't have a sector lock yet.

When we're joining or entering a game, we're in the unique situation
where we load the original session var outside of a game (so no sector
lock is acquired), but then we forward to a page that is inside a game,
where we reload the session from the database.

The problem is that we have already modified the session var, so the
one in the database is outdated. Loading the outdated session can
cause arbitrary bugs.

In the past, this issue was handled by *always* updating the session
var in the database any time we forwarded to a new page without a
sector lock. This was an overly aggressive strategy, because in most
cases we don't need to update the database session var if we don't
have a sector lock (i.e. anything we do outside of a game). This was
(incorrectly) removed in 13cd14751.

To fix this bug, we do not re-implement the old, generic behavior.
Instead, we simply put a sector lock in game_play_processing.php, as
it is the only place where we transition from not in a game. (This
also fixes the more critical problem with game_join_processing.php.)
