 	id = parseInt(request.params.id, 10)
 	if isNaN(id)
 		throw new Error '404'
-	chars = lib.game.getCharacter.sync null, dbConnection, id
+	chars = lib.game.getCharacter.sync null, request.uonline.db, id
 	if not chars?
 		throw new Error '404'
 	for i of chars

app.post '/action/equip',
	mustBeAuthed,
	(request, response) ->
		dbConnection.query.sync dbConnection,
			'UPDATE items '+
				'SET equipped = true '+
				'WHERE id = $1 AND owner = $2',

app.post '/action/switchCharacter',
	mustBeAuthed,
	(request, response) ->
		lib.character.switchCharacter.sync null, request.uonline.db, request.uonline.user.id, request.body.id
		response.redirect 303, 'back'


app.post '/action/deleteCharacter',
	mustBeAuthed,
	(request, response) ->
		lib.character.deleteCharacter.sync null, request.uonline.db, request.uonline.user.id, request.body.id
		response.redirect 303, '/account/'


app.get '/state/',
	(request, response, next) ->
		players = request.uonline.db.query.sync request.uonline.db,
			"SELECT *, (sess_time > NOW() - $1 * INTERVAL '1 SECOND') AS online FROM uniusers",
			[config.sessionExpireTime]
		request.uonline.userstate = players.rows
