// File: nesro[P]NCursesGomoku/src/game.cpp
// Function: CGame::CGame(int, char**)
CGame::CGame(int argc, char ** argv) {

	this->m_PlayerOnTurn = 0;
	this->m_ServerSocket = 0;
	this->m_ConnectionSocket = 0;

	if (argc > 1) {
		m_Port = atoi(argv[1]);
	} else {
		m_Port = CNetwork::DEFAULT_PORT;
	}

	if (argc > 2) {
		m_Host = argv[2];
	} else {
		m_Host = "localhost";
	}

	m_IsConnectionUp = false;
	m_IsServerUp = false;

	m_Players[0] = NULL;
	m_Players[1] = NULL;

	srand((unsigned) (time(NULL)));

	m_Status = STATUS_MENU;

	initscr();
	raw();
	keypad(stdscr, TRUE);
	noecho();

	/* turn off cursor */
	curs_set(0);

	start_color();
	init_pair(1, COLOR_CYAN, COLOR_BLACK);
	init_pair(6, COLOR_MAGENTA, COLOR_BLACK);

	/* color of old stones*/
	init_pair(2, COLOR_WHITE, COLOR_RED);
	init_pair(3, COLOR_WHITE, COLOR_GREEN);

	/* color of newest stone*/
	init_pair(4, COLOR_BLACK, COLOR_RED);
	init_pair(5, COLOR_BLACK, COLOR_GREEN);

	init_pair(BACKROUND_COLOR_X_PAIR, BACKROUND_COLOR_X, COLOR_BLACK);
	init_pair(BACKROUND_COLOR_O_PAIR, BACKROUND_COLOR_O, COLOR_BLACK);

	m_Board = new CBoard();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x30(%rbp)
addq $0x18, %rdi
movq %rdi, -0x38(%rbp)
callq 0x3380
movq -0x30(%rbp), %rax
movl $0x0, 0x58(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, 0xc(%rax)
cmpl $0x1, -0xc(%rbp)
jle 0x536f
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x33d0
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x38(%rax)
jmp 0x537a
movq -0x30(%rbp), %rax
movl $0x44d, 0x38(%rax)      # imm = 0x44D
cmpl $0x2, -0xc(%rbp)
jle 0x53aa
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
addq $0x18, %rdi
callq 0x3370
jmp 0x5397
jmp 0x53c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x5518
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
leaq 0x3767(%rip), %rsi      # 0x8b20
callq 0x3370
jmp 0x53c0
jmp 0x53c2
movq -0x30(%rbp), %rax
movb $0x0, 0x10(%rax)
movb $0x0, 0x4(%rax)
movq $0x0, 0x40(%rax)
movq $0x0, 0x48(%rax)
xorl %eax, %eax
movl %eax, %edi
callq 0x3240
movl %eax, %edi
callq 0x3260
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
callq 0x33b0
jmp 0x53ff
callq 0x30e0
jmp 0x5406
movq 0x6bbb(%rip), %rax      # 0xbfc8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x3110
jmp 0x541c
callq 0x3310
jmp 0x5423
xorl %edi, %edi
callq 0x31f0
jmp 0x542c
callq 0x3090
jmp 0x5433
movl $0x1, %edi
movl $0x6, %esi
xorl %edx, %edx
callq 0x3060
jmp 0x5446
movl $0x6, %edi
movl $0x5, %esi
xorl %edx, %edx
callq 0x3060
jmp 0x5459
movl $0x2, %edi
movl $0x7, %esi
movl $0x1, %edx
callq 0x3060
jmp 0x546f
movl $0x3, %edi
movl $0x7, %esi
movl $0x2, %edx
callq 0x3060
jmp 0x5485
movl $0x4, %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0x3060
jmp 0x5498
movl $0x5, %edi
xorl %esi, %esi
movl $0x2, %edx
callq 0x3060
jmp 0x54ab
movl $0xc, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x3060
jmp 0x54be
movl $0xd, %edi
movl $0x5, %esi
xorl %edx, %edx
callq 0x3060
jmp 0x54d1
movl $0x11c, %edi            # imm = 0x11C
callq 0x3280
movq %rax, -0x40(%rbp)
jmp 0x54e1
movq -0x40(%rbp), %rdi
callq 0x3f80
jmp 0x54ec
movq -0x30(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x50(%rax)
addq $0x40, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x11c, %esi            # imm = 0x11C
callq 0x3290
movq -0x38(%rbp), %rdi
callq 0x3190
movq -0x20(%rbp), %rdi
callq 0x3410
nopw (%rax,%rax)