Exemple #1
0
void FCEUD_NetworkClose(void) {
	NetStatAdd("*** Connection lost.");
	if (netwin) {
		SetDlgItemText(netwin, 250, "Connect");
		FixCDis(netwin, 1);
	}
	if (Socket != INVALID_SOCKET) {
		closesocket(Socket);
		Socket = INVALID_SOCKET;
	}

	if (wsainit) {
		WSACleanup();
		wsainit = 0;
	}
	/* Make sure blocking is returned to normal once network play is stopped. */
	NoWaiting &= ~2;
	FCEUDnetplay = 0;
	FCEUI_NetplayStop();
}
Exemple #2
0
static BOOL CALLBACK NetCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg)
  {
   case WM_CLOSE:
                        GetSettings(hwndDlg);
                        DestroyWindow(hwndDlg);
                        netwin=0;
                        FCEUD_NetworkClose();
                        break;
   case WM_COMMAND:
                   if(HIWORD(wParam)==BN_CLICKED)
                   {
                    switch(LOWORD(wParam))
                    {
                     case BTN_NETMOO_CONNECT:
                        if(FCEUDnetplay)
                        {
                         FCEUD_NetworkClose();
                         SetDlgItemText(hwndDlg,BTN_NETMOO_CONNECT,"Connect");
                         FixCDis(hwndDlg,1);
                        }
                        else if(GameInfo)
                        {
                         GetSettings(hwndDlg);
                         if(FCEUD_NetworkConnect())
                         {
                          SetDlgItemText(hwndDlg,BTN_NETMOO_CONNECT,"Disconnect");
                          FixCDis(hwndDlg,0);
                         }
                        }
                        break;
                    }
                   }
                   else if(HIWORD(wParam)==EN_CHANGE && Socket!=INVALID_SOCKET)
                   {
                    char buf[1024];
                    int t;


                    t=GetDlgItemText(hwndDlg,IDC_NETMOO_CMD_INPUT,buf,1024);
                    buf[1023]=0;

                    if(strchr(buf,'\r'))
                    {
                     char *src,*dest;

                     src=dest=buf;
                    
                     while(*src)
                     {
                      if(*src != '\n' && *src != '\r')
                      {
                       *dest = *src;
                       dest++;
                      }
                      src++;
                     }
                     *dest = 0;
                     FCEUI_NetplayText((uint8*)buf); //mbg merge 7/17/06 added cast
                     SetDlgItemText(hwndDlg,IDC_NETMOO_CMD_INPUT,"");                    
                    }
                   }
                   break;
   case WM_INITDIALOG:
                   if(netplayhost)
                    SetDlgItemText(hwndDlg,IDC_NETMOO_HOST,netplayhost);
                   SetDlgItemInt(hwndDlg,IDC_NETMOO_PORT,remotetport,0);
                   if(netplaynick)
                    SetDlgItemText(hwndDlg,IDC_NETMOO_NICK,netplaynick);
                   if(netgamekey)
                    SetDlgItemText(hwndDlg,IDC_NETMOO_KEY,netgamekey);
                   if(netpassword)
                    SetDlgItemText(hwndDlg,IDC_NETMOO_PASS,netpassword);

                   {
                    int x;
                    char buf[8];
                    for(x=0;x<4;x++)
                    {
                     sprintf(buf,"%d",x+1);
                     SendDlgItemMessage(hwndDlg,COMBO_NETMOO_LOCAL_PLAYERS,CB_ADDSTRING,0,(LPARAM)(LPSTR)buf);
                    }
                    SendDlgItemMessage(hwndDlg,COMBO_NETMOO_LOCAL_PLAYERS,CB_SETCURSEL,netlocalplayers-1,(LPARAM)(LPSTR)0);
                   }


                   break;
  }

 return 0;
}
Exemple #3
0
static BOOL CALLBACK NetCon(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	switch (uMsg) {
	case WM_CLOSE:
		GetSettings(hwndDlg);
		DestroyWindow(hwndDlg);
		netwin = 0;
		FCEUD_NetworkClose();
		break;
	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			switch (LOWORD(wParam)) {
			case 250:
				if (FCEUDnetplay) {
					FCEUD_NetworkClose();
					SetDlgItemText(hwndDlg, 250, "Connect");
					FixCDis(hwndDlg, 1);
				} else if (GI) {
					GetSettings(hwndDlg);
					if (FCEUD_NetworkConnect()) {
						SetDlgItemText(hwndDlg, 250, "Disconnect");
						FixCDis(hwndDlg, 0);
					}
				}
				break;
			}
		} else if (HIWORD(wParam) == EN_CHANGE && Socket != INVALID_SOCKET) {
			char buf[1024];
			int t;


			t = GetDlgItemText(hwndDlg, 102, buf, 1024);
			buf[1023] = 0;

			if (strchr(buf, '\r')) {
				char *src, *dest;

				src = dest = buf;

				while (*src) {
					if (*src != '\n' && *src != '\r') {
						*dest = *src;
						dest++;
					}
					src++;
				}
				*dest = 0;
				FCEUI_NetplayText(buf);
				SetDlgItemText(hwndDlg, 102, "");
			}
		}
		break;
	case WM_INITDIALOG:
		if (netplayhost)
			SetDlgItemText(hwndDlg, 200, netplayhost);
		SetDlgItemInt(hwndDlg, 201, remotetport, 0);
		if (netplaynick)
			SetDlgItemText(hwndDlg, 203, netplaynick);
		if (netgamekey)
			SetDlgItemText(hwndDlg, 205, netgamekey);
		if (netpassword)
			SetDlgItemText(hwndDlg, 206, netpassword);

		{
			int x;
			char buf[8];
			for (x = 0; x < 4; x++) {
				sprintf(buf, "%d", x + 1);
				SendDlgItemMessage(hwndDlg, 204, CB_ADDSTRING, 0, (LPARAM)(LPSTR)buf);
			}
			SendDlgItemMessage(hwndDlg, 204, CB_SETCURSEL, netlocalplayers - 1, (LPARAM)(LPSTR)0);
		}


		break;
	}

	return 0;
}