예제 #1
0
파일: winctrl6.cpp 프로젝트: Rupan/winscp
int CIPAddressCtrl::GetAddress(BYTE& nField0, BYTE& nField1, BYTE& nField2, BYTE& nField3)
{
	ASSERT(::IsWindow(m_hWnd));
	DWORD dwAddress;
	LRESULT nRetVal = ::SendMessage(m_hWnd, IPM_GETADDRESS, 0, (LPARAM) &dwAddress);

	nField0 = (BYTE) FIRST_IPADDRESS(dwAddress);
	nField1 = (BYTE) SECOND_IPADDRESS(dwAddress);
	nField2 = (BYTE) THIRD_IPADDRESS(dwAddress);
	nField3 = (BYTE) FOURTH_IPADDRESS(dwAddress);

	return nRetVal;
}
예제 #2
0
INT_PTR
CALLBACK
LANStatusUiAdvancedDlg(
    HWND hwndDlg,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam)
{
    WCHAR szBuffer[100] = {0};
    PROPSHEETPAGE *page;
    LANSTATUSUI_CONTEXT * pContext;
    DWORD dwIpAddr;


    switch (uMsg)
    {
        case WM_INITDIALOG:
            page = (PROPSHEETPAGE*)lParam;
            pContext = (LANSTATUSUI_CONTEXT*)page->lParam;
            SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pContext);
            if (pContext->DHCPEnabled)
                LoadStringW(netshell_hInstance, IDS_ASSIGNED_DHCP, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));
            else
                LoadStringW(netshell_hInstance, IDS_ASSIGNED_MANUAL, szBuffer, sizeof(szBuffer)/sizeof(WCHAR));

            szBuffer[(sizeof(szBuffer)/sizeof(WCHAR))-1] = L'\0';
            SendDlgItemMessageW(hwndDlg, IDC_DETAILSTYPE, WM_SETTEXT, 0, (LPARAM)szBuffer);


            dwIpAddr = ntohl(pContext->IpAddress);
            swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
                     THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
            SendDlgItemMessageW(hwndDlg, IDC_DETAILSIP, WM_SETTEXT, 0, (LPARAM)szBuffer);

            dwIpAddr = ntohl(pContext->SubnetMask);
            swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
                     THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
            SendDlgItemMessageW(hwndDlg, IDC_DETAILSSUBNET, WM_SETTEXT, 0, (LPARAM)szBuffer);

            dwIpAddr = ntohl(pContext->Gateway);
            if (dwIpAddr)
            {
                swprintf(szBuffer, L"%u.%u.%u.%u", FIRST_IPADDRESS(dwIpAddr), SECOND_IPADDRESS(dwIpAddr),
                         THIRD_IPADDRESS(dwIpAddr), FOURTH_IPADDRESS(dwIpAddr));
                SendDlgItemMessageW(hwndDlg, IDC_DETAILSGATEWAY, WM_SETTEXT, 0, (LPARAM)szBuffer);
            }
            return TRUE;
        case WM_COMMAND:
            if (LOWORD(wParam) == IDC_DETAILS)
            {
                pContext = (LANSTATUSUI_CONTEXT*)GetWindowLongPtr(hwndDlg, DWLP_USER);
                if (pContext)
                {
                    DialogBoxParamW(netshell_hInstance, MAKEINTRESOURCEW(IDD_LAN_NETSTATUSDETAILS), GetParent(hwndDlg),
                                    LANStatusUiDetailsDlg, (LPARAM)pContext);
                }
            }
            break;
        default:
            break;
    }
    return FALSE;
}
예제 #3
0
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
   { 
   switch (message) 
      { 
      case WM_INITDIALOG:
         {
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER1), TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(4, 10));
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER2), TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(1, 2));
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER3), TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER4), TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER5), TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER6), TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(1, 6));

         int nValue;

         nValue = GetPrivateProfileInt("MoonbaseConsole", "SizeValue", 4, szMoonbaseIniFileG);
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER1), TBM_SETPOS, TRUE, nValue);  
         nValue = GetPrivateProfileInt("MoonbaseConsole", "SizeRandom", FALSE, szMoonbaseIniFileG);
         CheckDlgButton(hwndDlg, IDC_CHECK1, nValue);
         
         nValue = GetPrivateProfileInt("MoonbaseConsole", "GeneratorValue", 1, szMoonbaseIniFileG);
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER2), TBM_SETPOS, TRUE, nValue);  
         nValue = GetPrivateProfileInt("MoonbaseConsole", "GeneratorRandom", TRUE, szMoonbaseIniFileG);
         CheckDlgButton(hwndDlg, IDC_CHECK2, nValue);

         nValue = GetPrivateProfileInt("MoonbaseConsole", "EnergyValue", 3, szMoonbaseIniFileG);
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER3), TBM_SETPOS, TRUE, nValue);  
         nValue = GetPrivateProfileInt("MoonbaseConsole", "EnergyRandom", TRUE, szMoonbaseIniFileG);
         CheckDlgButton(hwndDlg, IDC_CHECK3, nValue);

         nValue = GetPrivateProfileInt("MoonbaseConsole", "TerrainValue", 3, szMoonbaseIniFileG);
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER4), TBM_SETPOS, TRUE, nValue);  
         nValue = GetPrivateProfileInt("MoonbaseConsole", "TerrainRandom", TRUE, szMoonbaseIniFileG);
         CheckDlgButton(hwndDlg, IDC_CHECK4, nValue);

         nValue = GetPrivateProfileInt("MoonbaseConsole", "WaterValue", 3, szMoonbaseIniFileG);
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER5), TBM_SETPOS, TRUE, nValue);  
         nValue = GetPrivateProfileInt("MoonbaseConsole", "WaterRandom", TRUE, szMoonbaseIniFileG);
         CheckDlgButton(hwndDlg, IDC_CHECK5, nValue);

         nValue = GetPrivateProfileInt("MoonbaseConsole", "TilesetValue", 5, szMoonbaseIniFileG);
         SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER6), TBM_SETPOS, TRUE, nValue);  
         nValue = GetPrivateProfileInt("MoonbaseConsole", "TilesetRandom", TRUE, szMoonbaseIniFileG);
         CheckDlgButton(hwndDlg, IDC_CHECK6, nValue);

         SendMessage(hwndDlg, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIconG);

         EnableDialog(hwndDlg, true);

         return TRUE; 
         }

      case WM_VSCROLL:
         {
         if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER1))
            CheckDlgButton(hwndDlg, IDC_CHECK1, BST_UNCHECKED);
         else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER2))
            CheckDlgButton(hwndDlg, IDC_CHECK2, BST_UNCHECKED);
         else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER3))
            CheckDlgButton(hwndDlg, IDC_CHECK3, BST_UNCHECKED);
         else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER4))
            CheckDlgButton(hwndDlg, IDC_CHECK4, BST_UNCHECKED);
         else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER5))
            CheckDlgButton(hwndDlg, IDC_CHECK5, BST_UNCHECKED);
         else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER6))
            CheckDlgButton(hwndDlg, IDC_CHECK6, BST_UNCHECKED);
         return TRUE;
         }

      case WM_COMMAND: 
         switch (LOWORD(wParam)) 
            {
            case IDC_BUTTON1: // Help
               {
               HRSRC hrsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_TXT1), "TXT");
               HGLOBAL hgbl = LoadResource(NULL, hrsrc);
               BYTE *pReadme = (BYTE *)LockResource(hgbl);

               char sz[MAX_PATH];
               strcpy(sz, szMoonbasePathG);
               strcat(sz, "\\MC_README.TXT");
               FILE *pf;
               pf = fopen(sz, "wb");
               fwrite(pReadme, 1, SizeofResource(NULL, hrsrc), pf);
               fclose(pf);

               ShellExecute(hwndDlg, "open", "MC_README.TXT", NULL, szMoonbasePathG, SW_SHOWNORMAL);

               return TRUE;
               }

            case IDC_BUTTON3: // Credits
               MessageBox(hwndDlg, "A lot of people helped in one way or the other. Here are the main contributors (in alphabetical order).\n"
                                   "\n"
                                   "Katton designed and coded the Katton map generation algorithm. He decoded a lot of the tiles and published what he learned. He also coded the algorithm that puts the \"craters\" on the map and wrote the code that generates the map preview showing the options.\n"
                                   "\n"
                                   "MYCROFT wrote the tools to rip apart the MAP files so they could be deciphered, decoded the rest of the tiles, defined the format that allows the generators to describe the map without caring about tiles, wrote the code to translate the generator output to a useable map, and did the Windows coding.\n"
                                   "\n"
                                   "SpacemanSpiff designed and coded the Spiff map generation algorithm. He also contributed to deciphering the map file format.\n"
                                   "\n"
                                   "Special thanks to Bwappo for his contest-winning thumbnail image.\n"
                                   "\n"
                                   "A number of other people on the Moonbase Commander forums also contributed to map decoding or beta testing including Bwappo, Covak, florent28, Kamolas, llangford, and YorkdinK.\n",
                                   "Moonbase Console Credits",
                                   MB_OK);
               return TRUE;
            
            case IDC_BTN_HOST_GAME:
               if (!DialogBoxParam(hInstanceG, MAKEINTRESOURCE(IDD_DIALOG3), hwndDlg, HostDlgProc, 0))
                  return TRUE; // bail if they cancel
               // fall through

            case IDC_SINGLE_GENERATE:
               {
               CGameInfo gi;

               gi.nVersion = GAMENUM_VERSION;

               if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK1))
                  gi.nMapSize = ((rand() % 5) + 4) * 8; // Don't randomly pick nonstandard map sizes.
               else
                  gi.nMapSize = SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER1), TBM_GETPOS, 0, 0) * 8;

               if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK2))
                  gi.nGenerator = (rand() % 2) + 1;
               else
                  gi.nGenerator = SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER2), TBM_GETPOS, 0, 0);

               if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK6))
                  gi.nTileset = (rand() % 6) + 1;
               else
                  gi.nTileset = 7 - SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER6), TBM_GETPOS, 0, 0);;

               gi.nIP1 = (unsigned char) FIRST_IPADDRESS(dwIPAddressG);
               gi.nIP2 = (unsigned char) SECOND_IPADDRESS(dwIPAddressG);
               gi.nIP3 = (unsigned char) THIRD_IPADDRESS(dwIPAddressG);
               gi.nIP4 = (unsigned char) FOURTH_IPADDRESS(dwIPAddressG);

               MBCMIF mif;

               if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK3))
                  gi.nEnergy = (rand() % 3) + 2;   // Only use [2, 3, 4] of the legal [0, 1, 2, 3, 4, 5, 6]
               else
                  gi.nEnergy = 6 - SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER3), TBM_GETPOS, 0, 0);

               if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK4))
                  gi.nTerrain = (rand() % 3) + 2;  // Only use [2, 3, 4] of the legal [0, 1, 2, 3, 4, 5, 6]
               else
                  gi.nTerrain = 6 - SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER4), TBM_GETPOS, 0, 0);

               if (BST_CHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHECK5))
                  gi.nWater = (rand() % 3) + 2;    // Only use [2, 3, 4] of the legal [0, 1, 2, 3, 4, 5, 6]
               else
                  gi.nWater = 6 - SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER5), TBM_GETPOS, 0, 0);

               gi.nSeed = rand(); // It is critical that the seed get set right before the generate.
               srand(gi.nSeed);

               switch (gi.nGenerator)
                  {
                  case SPIFF_GEN:
                     SpiffGenerate(gi, mif);
                     break;

                  case KATTON_GEN:
                     KattonGenerate(gi, mif);
                     break;
                  }

               try
                  {
                  BackupSystemMapFile();// TODO: Do single player differently.
                  makewiz(gi.nEnergy, gi.nTerrain, gi.nWater);
                  MakeMap(mif, gi);

                  if (LOWORD(wParam) == IDC_SINGLE_GENERATE)
                     {
                     gi.nIP1 = 192;
                     gi.nIP2 = 168;
                     gi.nIP3 = 1;
                     gi.nIP4 = 1;
                     }
                  else
                     {
                     PublishGameNumber(gi, hwndDlg);

                     // Prompt the user, tell them about the game number, and give them a chance to bail.
                     if (IDCANCEL == MessageBox(hwndDlg, "Your random map has been generated.\n\nThe game number for this map needs to be given to the people that you will be playing with.\nThis number is already on the clipboard, paste it into a message to them.\n\nOnce you have done this, press Ok to start Moonbase Commander or Cancel to abort.", "Moonbase Console Message", MB_OKCANCEL))
                        {
                        RestoreSystemMapFile();

                        return TRUE;
                        }
                     }

                  HostGame(hwndDlg, gi);
                  }
               catch (CMapError e)
                  {
                  RestoreSystemMapFile();

                  char szErrorHeader[80];
                  char szError[512];
                  sprintf(szErrorHeader, "Map Generation Error: Please Report This Information");
                  sprintf(szError, "%s\n\n"
                              "Generator:\t%s\n"
                              "Seed:\t\t%04X\n"
                              "Size:\t\t%d\n"
                              "nEnergy:\t\t%d\n"
                              "nTerrain:\t\t%d\n"
                              "nWater:\t\t%d\n"
                              "\n(%d, %d)\n"
                              "%d %d %d %d\n"
                              " %c %c %c\n"
                              "%d %d %d %d\n"
                              " %c %c %c\n"
                              "%d %d %d %d\n"
                              " %c %c %c\n"
                              "%d %d %d %d\n",
                              e.m_szErrorDescription,
                              (gi.nGenerator == SPIFF_GEN) ? "SpacemanSpiff" : "Katton",
                              (int)gi.nSeed,
                              (int)gi.nMapSize,
                              gi.nEnergy,
                              gi.nTerrain,
                              gi.nWater,
                              e.m_nX, e.m_nY,
                              mif.TTLLCorner(e.m_nX,e.m_nY),  mif.TTLCorner(e.m_nX,e.m_nY),  mif.TTRCorner(e.m_nX,e.m_nY), mif.TTRRCorner(e.m_nX,e.m_nY),
                                        mif.TLCenter(e.m_nX,e.m_nY),   mif.TCenter(e.m_nX,e.m_nY),    mif.TRCenter(e.m_nX,e.m_nY), 
                               mif.TLLCorner(e.m_nX,e.m_nY),   mif.TLCorner(e.m_nX,e.m_nY),   mif.TRCorner(e.m_nX,e.m_nY),  mif.TRRCorner(e.m_nX,e.m_nY),
                                         mif.LCenter(e.m_nX,e.m_nY),  mif.aaCenterMap[e.m_nX][e.m_nY], mif.RCenter(e.m_nX,e.m_nY),
                               mif.BLLCorner(e.m_nX,e.m_nY),   mif.BLCorner(e.m_nX,e.m_nY),   mif.BRCorner(e.m_nX,e.m_nY),  mif.BRRCorner(e.m_nX,e.m_nY),
                                        mif.BLCenter(e.m_nX,e.m_nY),   mif.BCenter(e.m_nX,e.m_nY),    mif.BRCenter(e.m_nX,e.m_nY),
                              mif.BBLLCorner(e.m_nX,e.m_nY),  mif.BBLCorner(e.m_nX,e.m_nY),  mif.BBRCorner(e.m_nX,e.m_nY), mif.BBRRCorner(e.m_nX,e.m_nY));

                  MessageBox(NULL, szError, szErrorHeader, MB_OK);
                  }
               catch (CGenericError e)
                  {
                  MessageBox(NULL, e.m_szErrorDescription, "Moonbase Console Error", MB_OK);
                  }

               return TRUE;
               }

            case IDC_BUTTON2:
               {
               if (!DialogBoxParam(hInstanceG, MAKEINTRESOURCE(IDD_DIALOG2), hwndDlg, JoinDlgProc, 0))
                  return TRUE; // bail if they cancel

               MBCMIF mif;

               // seed the generator
               srand(giG.nSeed);

               switch(giG.nGenerator)
                  {
                  case SPIFF_GEN:
                     SpiffGenerate(giG, mif);
                     break;

                  case KATTON_GEN:
                     KattonGenerate(giG, mif);
                     break;
                  }

               try
                  {
                  BackupSystemMapFile();
                  makewiz(giG.nEnergy, giG.nTerrain, giG.nWater);
                  MakeMap(mif, giG);
                  }
               catch (CGenericError e)
                  {
                  RestoreSystemMapFile();
                  MessageBox(NULL, e.m_szErrorDescription, "Moonbase Console Error", MB_OK);
                  }
               catch (...)
                  {
                  // Shouldn't get map generation errors here, only valid keys should be coming in.
                  }

               JoinGame(hwndDlg, giG);

               return TRUE;
               }
               
            default:
               return FALSE;
            }

      case WM_CLOSE:
         {
         char sz[80];

         wsprintf(sz, "%d", SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER1), TBM_GETPOS, 0, 0));
         WritePrivateProfileString("MoonbaseConsole", "SizeValue", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", IsDlgButtonChecked(hwndDlg, IDC_CHECK1));
         WritePrivateProfileString("MoonbaseConsole", "SizeRandom", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER2), TBM_GETPOS, 0, 0));
         WritePrivateProfileString("MoonbaseConsole", "GeneratorValue", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", IsDlgButtonChecked(hwndDlg, IDC_CHECK2));
         WritePrivateProfileString("MoonbaseConsole", "GeneratorRandom", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER3), TBM_GETPOS, 0, 0));
         WritePrivateProfileString("MoonbaseConsole", "EnergyValue", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", IsDlgButtonChecked(hwndDlg, IDC_CHECK3));
         WritePrivateProfileString("MoonbaseConsole", "EnergyRandom", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER4), TBM_GETPOS, 0, 0));
         WritePrivateProfileString("MoonbaseConsole", "TerrainValue", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", IsDlgButtonChecked(hwndDlg, IDC_CHECK4));
         WritePrivateProfileString("MoonbaseConsole", "TerrainRandom", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER5), TBM_GETPOS, 0, 0));
         WritePrivateProfileString("MoonbaseConsole", "WaterValue", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", IsDlgButtonChecked(hwndDlg, IDC_CHECK5));
         WritePrivateProfileString("MoonbaseConsole", "WaterRandom", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER6), TBM_GETPOS, 0, 0));
         WritePrivateProfileString("MoonbaseConsole", "TilesetValue", sz, szMoonbaseIniFileG);

         wsprintf(sz, "%d", IsDlgButtonChecked(hwndDlg, IDC_CHECK6));
         WritePrivateProfileString("MoonbaseConsole", "TilesetRandom", sz, szMoonbaseIniFileG);

         DestroyWindow(hwndDlg);
         return TRUE;
         }

      case WM_DESTROY:
         CleanUpMoonbaseINI();
         PostQuitMessage(0);
         return TRUE;
      } 
   return FALSE; 
   } 
예제 #4
0
LRESULT CALLBACK NetlinkSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                        LPARAM lParam)
{
   WCHAR tempwstr[MAX_PATH];
   char tempstr[MAX_PATH];

   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         SendDlgItemMessage(hDlg, IDC_LOCALREMOTEIP, IPM_SETADDRESS, 0, netlinklocalremoteip);

         sprintf(tempstr, "%d", netlinkport);
         SetDlgItemText(hDlg, IDC_PORTET, _16(tempstr));

         return TRUE;
      }
      case WM_NOTIFY:
     		switch (((NMHDR *) lParam)->code) 
    		{
				case PSN_SETACTIVE:
					break;

				case PSN_APPLY:
               // Local/Remote IP
               SendDlgItemMessage(hDlg, IDC_LOCALREMOTEIP, IPM_GETADDRESS, 0, (LPARAM)&netlinklocalremoteip);
               sprintf(tempstr, "%d.%d.%d.%d", (int)FIRST_IPADDRESS(netlinklocalremoteip), (int)SECOND_IPADDRESS(netlinklocalremoteip), (int)THIRD_IPADDRESS(netlinklocalremoteip), (int)FOURTH_IPADDRESS(netlinklocalremoteip));
               WritePrivateProfileStringA("Netlink", "LocalRemoteIP", tempstr, inifilename);

               // Port Number
               GetDlgItemText(hDlg, IDC_PORTET, tempwstr, MAX_PATH);
               WideCharToMultiByte(CP_ACP, 0, tempwstr, -1, tempstr, MAX_PATH, NULL, NULL);
               netlinkport = atoi(tempstr);
               WritePrivateProfileStringA("Netlink", "Port", tempstr, inifilename);

          		SetWindowLong(hDlg,	DWL_MSGRESULT, PSNRET_NOERROR);
					break;

				case PSN_KILLACTIVE:
	        		SetWindowLong(hDlg,	DWL_MSGRESULT, FALSE);
   				return 1;
					break;
				case PSN_RESET:
					break;
        	}
         break;
      case WM_DESTROY:
      {
         break;
      }
      default: break;
   }

   return FALSE;
}
예제 #5
0
//确定函数
void CServiceSet::OnOK()
{
	//变量定义
	DWORD dwSQLIP=0;
	TCHAR szBuffer[2000];

	//挂接类型
	if (m_GameKind.GetCurSel()==CB_ERR)
	{
		AfxMessageBox(TEXT("请选择挂接类型"),MB_ICONQUESTION);
		m_GameKind.SetFocus();
		return;
	}
	m_GameKind.GetLBText(m_GameKind.GetCurSel(),szBuffer);
	if (lstrcmp(TEXT("金币类"),szBuffer)==0) m_GameRoomInit.uKindID=1;
	else if (lstrcmp(TEXT("扑克类"),szBuffer)==0) m_GameRoomInit.uKindID=2;
	else if (lstrcmp(TEXT("棋类"),szBuffer)==0) m_GameRoomInit.uKindID=3;
	else if (lstrcmp(TEXT("对战类"),szBuffer)==0) m_GameRoomInit.uKindID=4;
	else if (lstrcmp(TEXT("比赛类"),szBuffer)==0) m_GameRoomInit.uKindID=5;
	else
	{
		AfxMessageBox(TEXT("请选择正确的挂接类型"),MB_ICONQUESTION);
		m_GameKind.SetFocus();
		return;
	}

	//游戏类型
	if (m_ComType.GetCurSel()==CB_ERR)
	{
		AfxMessageBox(TEXT("请选择游戏类型"),MB_ICONQUESTION);
		m_ComType.SetFocus();
		return;
	}
	m_ComType.GetLBText(m_ComType.GetCurSel(),szBuffer);
	if (lstrcmp(TEXT("点值游戏"),szBuffer)==0) m_GameRoomInit.InitInfo.uComType=TY_NORMAL_GAME;
	else if (lstrcmp(TEXT("比赛游戏"),szBuffer)==0) m_GameRoomInit.InitInfo.uComType=TY_MATCH_GAME;
	else if (lstrcmp(TEXT("金币游戏"),szBuffer)==0) m_GameRoomInit.InitInfo.uComType=TY_MONEY_GAME;
	else
	{
		AfxMessageBox(TEXT("请选择正确的游戏类型"),MB_ICONQUESTION);
		m_ComType.SetFocus();
		return;
	}

	//监听端口
	m_GameRoomInit.InitInfo.uListenPort=GetDlgItemInt(IDC_SOCKET_PORT);
	if ((m_GameRoomInit.InitInfo.uListenPort<3000L)||((m_GameRoomInit.InitInfo.uListenPort>30000L)))
	{
		AfxMessageBox(TEXT("请正确填写监听端口,有效范围 3000 到 30000"),MB_ICONQUESTION);
		GetDlgItem(IDC_SOCKET_PORT)->SetFocus();
		return;
	}

	//房间 ID
	m_GameRoomInit.InitInfo.uRoomID=GetDlgItemInt(IDC_ROOM_ID);
	if ((m_GameRoomInit.InitInfo.uRoomID<1L)||((m_GameRoomInit.InitInfo.uRoomID>30000L)))
	{
		AfxMessageBox(TEXT("请正确填写房间 ID,有效范围 1 到 30000"),MB_ICONQUESTION);
		GetDlgItem(IDC_ROOM_ID)->SetFocus();
		return;
	}

	//桌子数目
	m_GameRoomInit.InitInfo.uDeskCount=GetDlgItemInt(IDC_DESK_COUNT);
	if ((m_GameRoomInit.InitInfo.uDeskCount<10L)||((m_GameRoomInit.InitInfo.uDeskCount>200L)))
	{
		AfxMessageBox(TEXT("请正确填写桌子数目,有效范围 10 到 200"),MB_ICONQUESTION);
		GetDlgItem(IDC_DESK_COUNT)->SetFocus();
		return;
	}

	//基础分数
	m_GameRoomInit.InitInfo.uBasePoint=GetDlgItemInt(IDC_BASE_POINT);
	if (m_GameRoomInit.InitInfo.uBasePoint>10000L)
	{
		AfxMessageBox(TEXT("请正确填写基础分数,有效范围 0 到 10000"),MB_ICONQUESTION);
		GetDlgItem(IDC_BASE_POINT)->SetFocus();
		return;
	}
	
	//最少分数
	m_GameRoomInit.InitInfo.uLessPoint=GetDlgItemInt(IDC_LESS_POINT);
	if (m_GameRoomInit.InitInfo.uLessPoint>30000L)
	{
		AfxMessageBox(TEXT("请正确填写最少分数,有效范围 0 到 30000"),MB_ICONQUESTION);
		GetDlgItem(IDC_LESS_POINT)->SetFocus();
		return;
	}

	//最少分数
	m_GameRoomInit.InitInfo.uLessPoint=GetDlgItemInt(IDC_LESS_POINT);
	if (m_GameRoomInit.InitInfo.uLessPoint>30000L)
	{
		AfxMessageBox(TEXT("请正确填写最少分数,有效范围 0 到 30000"),MB_ICONQUESTION);
		GetDlgItem(IDC_LESS_POINT)->SetFocus();
		return;
	}

	//最大人数
	m_GameRoomInit.InitInfo.uMaxPeople=GetDlgItemInt(IDC_MAX_CONNECT);
	if (m_GameRoomInit.InitInfo.uLessPoint>1000L)
	{
		AfxMessageBox(TEXT("请正确填写最大人数,有效范围 0 到 1000"),MB_ICONQUESTION);
		GetDlgItem(IDC_MAX_CONNECT)->SetFocus();
		return;
	}

	//游戏服务器 IP
	if (m_CenterSQLIP.GetAddress(dwSQLIP)!=4)
	{
		AfxMessageBox(TEXT("请正确填写游戏数据库 IP"),MB_ICONQUESTION);
		m_CenterSQLIP.SetFocus();
		return;
	}
	sprintf(m_GameRoomInit.InitInfo.szSQLIP,TEXT("%d.%d.%d.%d"),FIRST_IPADDRESS(dwSQLIP),SECOND_IPADDRESS(dwSQLIP),THIRD_IPADDRESS(dwSQLIP),FOURTH_IPADDRESS(dwSQLIP));

	//登陆服务器 IP
	if (m_LogonSQLIP.GetAddress(dwSQLIP)!=4)
	{
		AfxMessageBox(TEXT("请正确填写用户数据库 IP"),MB_ICONQUESTION);
		m_LogonSQLIP.SetFocus();
		return;
	}
	sprintf(m_GameRoomInit.InitInfo.szLogonSQLIP,TEXT("%d.%d.%d.%d"),FIRST_IPADDRESS(dwSQLIP),SECOND_IPADDRESS(dwSQLIP),THIRD_IPADDRESS(dwSQLIP),FOURTH_IPADDRESS(dwSQLIP));

	//本地服务器 IP
	if (m_NativeSQLIP.GetAddress(dwSQLIP)!=4)
	{
		AfxMessageBox(TEXT("请正确填写本地数据库 IP"),MB_ICONQUESTION);
		m_NativeSQLIP.SetFocus();
		return;
	}
	sprintf(m_GameRoomInit.InitInfo.szNativeSQLIP,TEXT("%d.%d.%d.%d"),FIRST_IPADDRESS(dwSQLIP),SECOND_IPADDRESS(dwSQLIP),THIRD_IPADDRESS(dwSQLIP),FOURTH_IPADDRESS(dwSQLIP));

	//房间名字
	GetDlgItemText(IDC_ROOM_NAME,m_GameRoomInit.InitInfo.szGameRoomName,sizeof(m_GameRoomInit.InitInfo.szGameRoomName));

	//备注信息
	GetDlgItemText(IDC_ROOM_NOTE,m_GameRoomInit.szRoomNote,sizeof(m_GameRoomInit.szRoomNote));

	//调整参数
	if (m_GameRoomInit.uKindID==1)
	{
		if ((m_ServiceInfo.ServiceInfo.uSupportType&SUP_MONEY_GAME)==0)
		{
			AfxMessageBox(TEXT("此游戏不支持金币游戏模式,请重新选择挂接类型"),MB_ICONQUESTION);
			m_GameKind.SetFocus();
			return;
		}
		m_GameRoomInit.InitInfo.uComType=TY_MONEY_GAME;
	}
	if (m_GameRoomInit.uKindID==5)
	{
		if ((m_ServiceInfo.ServiceInfo.uSupportType&SUP_MATCH_GAME)==0)
		{
			AfxMessageBox(TEXT("此游戏不支持比赛游戏模式,请重新选择挂接类型"),MB_ICONQUESTION);
			m_GameKind.SetFocus();
			return;
		}
		m_GameRoomInit.InitInfo.uComType=TY_MATCH_GAME;
	}
	if (m_GameRoomInit.InitInfo.szGameTable[0]==0) lstrcpy(m_GameRoomInit.InitInfo.szGameTable,m_ServiceInfo.ServiceInfo.szGameTable);
	if (m_GameRoomInit.InitInfo.uComType==TY_MONEY_GAME)
	{
		m_GameRoomInit.uKindID=1;
		lstrcpy(m_GameRoomInit.InitInfo.szGameTable,TEXT("MoneyGameEx"));
		if (m_GameRoomInit.InitInfo.uMoneyPoint==0) m_GameRoomInit.InitInfo.uMoneyPoint=1;
	}
	else if (m_GameRoomInit.InitInfo.uComType==TY_MATCH_GAME)
	{
		m_GameRoomInit.uKindID=5;
		m_GameRoomInit.InitInfo.uMoneyPoint=0;
	}
	UINT uLessMaxPeople=m_GameRoomInit.InitInfo.uDeskCount*m_ServiceInfo.ServiceInfo.uDeskPeople+50;
	if (m_GameRoomInit.InitInfo.uMaxPeople<uLessMaxPeople) m_GameRoomInit.InitInfo.uMaxPeople=uLessMaxPeople;

	//生成连接字符
	CString strConnect;
#ifdef _DEBUG
	strConnect.Format(TEXT("Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s;"),
		m_pServiceManage->m_Info.m_szSQLPass,m_pServiceManage->m_Info.m_szSQLName,szLogonDataBaseName,m_pServiceManage->m_Info.m_szSQLAddr);
#else
	strConnect.Format(TEXT("Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s,3000;"),
		m_pServiceManage->m_Info.m_szSQLPass,m_pServiceManage->m_Info.m_szSQLName,szLogonDataBaseName,m_pServiceManage->m_Info.m_szSQLAddr);
#endif
	if(stc_bUseAccessDB)
		strConnect=stc_sLogonDataConnect;


	//连接数据库
	CAFCDataBase DataBase;
	DataBase.ShowError(true);
	if (DataBase.Open(strConnect)==false) return;

	//获取数据库密码
	if (m_pServiceManage->GetSQLDataInfo(m_GameRoomInit.InitInfo.szSQLIP,m_GameRoomInit.InitInfo.szSQLName,m_GameRoomInit.InitInfo.szSQLPass,DataBase)==false)
	{
		AfxMessageBox(TEXT("获取游戏数据库信息错误,请重新设置游戏数据库 IP 信息"));
		m_CenterSQLIP.SetFocus();
		return;
	}

	//获取数据库密码
	if (m_pServiceManage->GetSQLDataInfo(m_GameRoomInit.InitInfo.szLogonSQLIP,m_GameRoomInit.InitInfo.szLogonSQLName,m_GameRoomInit.InitInfo.szLogonSQLPass,DataBase)==false)
	{
		AfxMessageBox(TEXT("获取用户数据库信息错误,请重新设置游戏数据库 IP 信息"));
		m_LogonSQLIP.SetFocus();
		return;
	}

	//获取数据库密码
	if (m_pServiceManage->GetSQLDataInfo(m_GameRoomInit.InitInfo.szNativeSQLIP,m_GameRoomInit.InitInfo.szNativeSQLName,m_GameRoomInit.InitInfo.szNativeSQLPass,DataBase)==false)
	{
		AfxMessageBox(TEXT("获取本地数据库信息错误,请重新设置游戏数据库 IP 信息"));
		m_NativeSQLIP.SetFocus();
		return;
	}

	//执行语句资料
	sprintf(szBuffer,TEXT("INSERT INTO ComRoomInfo (RoomID,RoomName,ServiceIP,CenterSQLIP,LogonSQLIP,NativaSQLIP,ServerInfoID,")
		TEXT("ComType,SocketPort,KindID,NameID,MatchInfoID,DeskCount,MaxPeople,BasePoint,LessPoint,MoneyPoint,RoomRule,UserPower,")
		TEXT("LockTable,IPRuleTable,MatchTable,Note) ")
		TEXT("VALUES (%ld,'%s','%s','%s','%s','%s',%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,'%s','%s','%s','%s')"),
		m_GameRoomInit.InitInfo.uRoomID,m_GameRoomInit.InitInfo.szGameRoomName,m_pServiceManage->m_Info.m_szServiceIP,m_GameRoomInit.InitInfo.szSQLIP,
		m_GameRoomInit.InitInfo.szLogonSQLIP,m_GameRoomInit.InitInfo.szNativeSQLIP,m_ServiceInfo.uServiceID,m_GameRoomInit.InitInfo.uComType,
		m_GameRoomInit.InitInfo.uListenPort,m_GameRoomInit.uKindID,m_ServiceInfo.ServiceInfo.uNameID,m_GameRoomInit.InitInfo.dwMatchInfoID,
		m_GameRoomInit.InitInfo.uDeskCount,m_GameRoomInit.InitInfo.uMaxPeople,m_GameRoomInit.InitInfo.uBasePoint,m_GameRoomInit.InitInfo.uLessPoint,
		m_GameRoomInit.InitInfo.uMoneyPoint,m_GameRoomInit.InitInfo.dwRoomRule,m_GameRoomInit.InitInfo.dwUserPower,m_GameRoomInit.InitInfo.szLockTable,
		m_GameRoomInit.InitInfo.szIPRuleTable,m_GameRoomInit.InitInfo.szGameTable,m_GameRoomInit.szRoomNote);
	if (DataBase.Execute(szBuffer)==false) return;

	__super::OnOK();
}
예제 #6
0
/// 数值变 IP 字符
TCHAR * XGmMessageModule::ULongToIP(ULONG dwIP, TCHAR * szIP)
{
	wsprintf(szIP,TEXT("%d.%d.%d.%d"),FOURTH_IPADDRESS(dwIP),THIRD_IPADDRESS(dwIP),SECOND_IPADDRESS(dwIP),FIRST_IPADDRESS(dwIP));
	return szIP;
}