Ejemplo n.º 1
0
void PathFinder::findReturnPath(int robx, int roby) {
    restore();

    std::queue<Point> list = std::queue<Point>();

    Point target = Point(robx, roby);
    list.push(target);
    PFgrid[robx][roby].cost = 0;

    while (true) {
        target = list.front();

        if (target.x == WIDTH / 2 && target.y == HEIGHT / 2) {
            break;
        }

        fillSeenAround(&list, target, -1, 0, 2);
        fillSeenAround(&list, target, 1, 0, 2);
        fillSeenAround(&list, target, 0, -1, 2);
        fillSeenAround(&list, target, 0, 1, 2);
        fillSeenAround(&list, target, -1, -1, 3);
        fillSeenAround(&list, target, -1, 1, 3);
        fillSeenAround(&list, target, 1, -1, 3);
        fillSeenAround(&list, target, 1, 1, 3);

        list.pop();
        if (list.empty()) {
            break;
        }
    }
    if (isStartAccessible()) {
        choosePath(Point(WIDTH / 2, HEIGHT / 2), robx, roby);
        #ifdef PRINT
            PRINT("RETURN PATH FOUND");
        #endif
    }
};
void FormMain_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
  if (controlWithDefValue != 0 && id == controlWithDefValue
    && codeNotify==EN_CHANGE)
    controlWithDefValue= 0;

  switch (id)
  {
    case IDOK:
      btnOk_Click(hwnd); break;
    case IDCANCEL:
      btnCancel_Click(hwnd); break;
    case IDC_BUTTON_DETAILS:
      btnDetails_Click(hwnd); break;
    case IDC_BUTTON_HELP:
      btnHelp_Click(hwnd); break;
    case IDC_BUTTON_TEST:
      btnTest_Click(hwnd); break;
    case IDC_SSLKEYCHOOSER:
      chooseFile(hwnd, IDC_EDIT_sslkey); break;
    case IDC_SSLCERTCHOOSER:
      chooseFile(hwnd, IDC_EDIT_sslcert); break;
    case IDC_SSLCACHOOSER:
      chooseFile(hwnd, IDC_EDIT_sslca); break;
    case IDC_SSLCAPATHCHOOSER:
      choosePath(hwnd, IDC_EDIT_sslcapath); break;
    case IDC_RSAKEYCHOOSER:
      chooseFile(hwnd, IDC_EDIT_rsakey); break;
    case IDC_CHOOSER_plugin_dir:
      choosePath(hwnd, IDC_EDIT_plugin_dir); break;
    case IDC_RADIO_tcp:
    case IDC_RADIO_pipe:
      SwitchTcpOrPipe(hwnd, !!Button_GetCheck(GetDlgItem(hwnd, IDC_RADIO_pipe)));
      break;
    case IDC_CHECK_cursor_prefetch_active:
      {
        HWND cursorTab= TabCtrl_1.hTabPages[CURSORS_TAB-1];
        assert(cursorTab);
        HWND prefetch= GetDlgItem(cursorTab, IDC_EDIT_cursor_prefetch_number);
        assert(prefetch);

        EnableWindow(prefetch, !!Button_GetCheck(GetDlgItem(cursorTab,
                                            IDC_CHECK_cursor_prefetch_active)));
                  
        if (Edit_GetTextLength(prefetch) == 0)
        {
          setUnsignedFieldData(cursorTab, default_cursor_prefetch,
                              IDC_EDIT_cursor_prefetch_number);
        }
      }
      break;
    case IDC_EDIT_name:
    {
      if (codeNotify==EN_CHANGE)
      {
        int len = Edit_GetTextLength(GetDlgItem(hwnd,IDC_EDIT_name));
        Button_Enable(GetDlgItem(hwnd,IDOK), len > 0);
        Button_Enable(GetDlgItem(hwnd,IDC_BUTTON_TEST), len > 0);
        RedrawWindow(hwnd,NULL,NULL,RDW_INVALIDATE);
      }
      break;
    }

    case IDC_EDIT_dbname:
      processDbCombobox(hwnd, hwndCtl, codeNotify);
    break;

    case IDC_EDIT_charset:
      processCharsetCombobox(hwnd, hwndCtl, codeNotify);
	}

	return;
}
Ejemplo n.º 3
0
void PathFinder::findNewPath(int robx, int roby) {
    restore();
    
    std::queue<Point> list = std::queue<Point>();

    Point target = Point(robx, roby);
    list.push(target);
    PFgrid[robx][roby].cost = 0;

    bool margin = PFgrid[robx][roby].margin;
    // 0 margins not filled, break at !seen
    // 1 unwalkable not filled, switch at !margin

    while (true) {
        target = list.front();

        // if unseen found
        if (!grid[target.x][target.y].seen) {
            mapExplored = 0;
            break;
        }

        // if not-margin found, stop searching through the margin
        if (!PFgrid[target.x][target.y].margin) {
            margin = 0;
        }

        if (margin) {
            fillWalkableAround(&list, target, -1, 0, 2);
            fillWalkableAround(&list, target, 1, 0, 2);
            fillWalkableAround(&list, target, 0, -1, 2);
            fillWalkableAround(&list, target, 0, 1, 2);
            fillWalkableAround(&list, target, -1, -1, 3);
            fillWalkableAround(&list, target, -1, 1, 3);
            fillWalkableAround(&list, target, 1, -1, 3);
            fillWalkableAround(&list, target, 1, 1, 3);
        } else {
            fillNotMarginAround(&list, target, -1, 0, 2);
            fillNotMarginAround(&list, target, 1, 0, 2);
            fillNotMarginAround(&list, target, 0, -1, 2);
            fillNotMarginAround(&list, target, 0, 1, 2);
            fillNotMarginAround(&list, target, -1, -1, 3);
            fillNotMarginAround(&list, target, -1, 1, 3);
            fillNotMarginAround(&list, target, 1, -1, 3);
            fillNotMarginAround(&list, target, 1, 1, 3);
        }

        list.pop();
        if (list.empty()) {
            mapExplored = 1;
            break;
        }
    }
    if (mapExplored) {
        #ifdef PRINT
            PRINT("MAX EXPLORED");
        #endif
        findReturnPath(robx, roby);
    } else {
        choosePath(target, robx, roby);
    }
};