// File: /workspace/github_cpp_makefile_star2_O3/lotuskip[P]yuxtapa/server/game.cpp
// Function: Game::remove_player(std::_List_iterator<Player>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
list<Player>::iterator Game::remove_player(list<Player>::iterator pit,
	const string &reason)
{
	// last_seen was updated when the player connected (and
	// adjusted after each intermission):
	if(intermission)
		pit->stats_i->last_seen += time(NULL) - pit->last_switched_cl;
	else
	{
		del_owneds(pit);
		// Remove any poisoning caused by this player!
		for(list<Player>::iterator it = cur_players.begin();
			it != cur_players.end(); ++it)
		{
			if(it->poisoner == pit)
				it->poisoner = cur_players.end();
		}
	}
	pit->stats_i->total_time += time(NULL) - pit->stats_i->last_seen;
	time(&(pit->stats_i->last_seen));

	if(pit->team != T_SPEC)
	{
		pit->own_vp->move_watchers();
		--num_players[pit->team - T_GREEN];
		send_team_upds(cur_players.end());
	}

	if(pit->is_alive())
		kill_player(pit); // this records time spent as a class
	else
	{
		pit->viewn_vp->drop_watcher(pit->stats_i->ID);
		// if is spec, record time spent as spec:
		if(pit->team == T_SPEC && !intermission)
			pit->stats_i->time_specced += time(NULL) - pit->last_switched_cl;
	}
	
	// If it is a bot, kill the process and ditch stats:
	if(pit->botpid != -1)
	{
		known_players.erase(pit->stats_i);
		Network::send_buffer.clear();
		Network::send_buffer.add((unsigned char)MID_QUIT);
		Network::send_to_player(*pit);
		int cet;
		waitpid(pit->botpid, &cet, 0);
	}
	
	string msg = pit->nick + reason;
	list<Player>::iterator retval = cur_players.erase(pit);
	Network::to_chat(msg);

	// minplayers != 0 implies (by checks in settings.cpp) that bots are around
	if(cur_players.size() < int_settings[IS_MINPLAYERS])
	{
		/* if ALL remaining players are now bots, drop them all */
		if((unsigned int)num_bots() == cur_players.size())
		{
			while(drop_a_bot()); // not fast, but simple
		}
		else // otherwise fill up with a bot
			spawn_bot();
	}

	if(cur_players.empty())
		timed_log("no more players, awaiting connections.");
	else
		active_teambal_check();

	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x2454a(%rip), %r12     # 0x40408
cmpb $0x1, (%r12)
jne 0x1bf59
xorl %edi, %edi
callq 0x43b0
subq 0xc8(%rbx), %rax
movq 0x90(%rbx), %rcx
addq %rax, 0x138(%rcx)
xorl %edi, %edi
callq 0x43b0
leaq 0x10(%rbx), %r15
movq 0x90(%rbx), %rcx
subq 0x138(%rcx), %rax
leaq 0x138(%rcx), %rdi
addq %rax, 0xb0(%rcx)
callq 0x43b0
cmpl $0x2, 0xbc(%rbx)
je 0x1bf43
movq 0xd0(%rbx), %rdi
callq 0x1ec86
movslq 0xbc(%rbx), %rax
leaq 0x282ed(%rip), %rcx     # 0x44221
decb (%rax,%rcx)
leaq 0x27182(%rip), %rdi     # 0x430c0
callq 0x19e31
movq %r15, %rdi
callq 0x12496
testb %al, %al
je 0x1bf89
movq %rbx, %rdi
callq 0x25636
jmp 0x1bfcc
movq %rbx, %rdi
callq 0x1d23a
leaq 0x27158(%rip), %rax     # 0x430c0
movq (%rax), %rcx
cmpq %rax, %rcx
je 0x1bee5
cmpq %rbx, 0x160(%rcx)
jne 0x1bf84
movq %rax, 0x160(%rcx)
movq (%rcx), %rcx
jmp 0x1bf6b
movq 0x90(%rbx), %rax
movq 0xd8(%rbx), %rdi
movzwl 0x10(%rax), %esi
callq 0x1ec26
cmpl $0x2, 0xbc(%rbx)
jne 0x1bfcc
cmpb $0x0, (%r12)
jne 0x1bfcc
xorl %edi, %edi
callq 0x43b0
subq 0xc8(%rbx), %rax
movq 0x90(%rbx), %rcx
addq %rax, 0xb8(%rcx)
cmpl $-0x1, 0x174(%rbx)
je 0x1c020
movq 0x90(%rbx), %rsi
leaq 0x270c5(%rip), %rdi     # 0x430a8
callq 0x14da4
leaq 0x25139(%rip), %r12     # 0x41128
movq %r12, %rdi
callq 0x2af20
movq %r12, %rdi
movl $0x2, %esi
callq 0x2af34
movq %r15, %rdi
movq %r12, %rsi
callq 0xf719
movl 0x174(%rbx), %edi
leaq -0x60(%rbp), %rsi
xorl %edx, %edx
callq 0x42f0
leaq 0x98(%rbx), %rsi
leaq -0x60(%rbp), %r12
movq %r12, %rdi
movq %r14, %rdx
callq 0x146ff
movq (%rbx), %r14
leaq 0x27080(%rip), %r15     # 0x430c0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1dc8c
movq %r12, %rdi
callq 0xf579
leaq 0x26846(%rip), %rax     # 0x428a0
movl 0x2c(%rax), %eax
cmpq %rax, 0x10(%r15)
jae 0x1c084
callq 0x13d91
movswq %ax, %rax
movl %eax, %eax
cmpq 0x10(%r15), %rax
jne 0x1c07f
callq 0x2a7f1
testb %al, %al
jne 0x1c074
jmp 0x1c084
callq 0x2a6b4
cmpq %r15, (%r15)
je 0x1c090
callq 0x1d3fb
jmp 0x1c0cd
leaq -0x30(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x12fff(%rip), %rsi     # 0x2f09e
leaq 0x1301e(%rip), %rdx     # 0x2f0c4
leaq -0x40(%rbp), %rdi
callq 0xe01c
leaq -0x40(%rbp), %rdi
callq 0x15128
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x1c0cd
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43f0
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1c0e6
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43f0
movq %r14, %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x40(%rbp), %rdi
cmpq %r15, %rdi
je 0x1c117
movq -0x30(%rbp), %rsi
incq %rsi
callq 0x43f0
jmp 0x1c117
jmp 0x1c114
jmp 0x1c114
movq %rax, %rbx
leaq -0x50(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x1c130
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x43f0
movq %rbx, %rdi
callq 0x4740