コード例 #1
0
ファイル: DialogSAPrefs6.cpp プロジェクト: ohzooboy/oh
void CDlgSAPrefs6::OnBnClickedPtTest()
{
	CString			conn_str = "", ip_addr = "", port = "", user = "", pass = "", dbname = "", e = "";
	CMainFrame		*pMyMainWnd  = (CMainFrame *) (theApp.m_pMainWnd);

	m_pt_ip.GetWindowText(ip_addr);
	m_pt_port.GetWindowText(port);
	m_pt_user.GetWindowText(user);
	m_pt_pass.GetWindowText(pass);
	m_pt_dbname.GetWindowText(dbname);

	conn_str = "host=" + ip_addr;
	conn_str += " port=" + port;
	conn_str += " user="******" password="******" dbname='" + dbname;
	conn_str += "'";

	// Set busy cursor
	pMyMainWnd->set_wait_cursor(true);
	pMyMainWnd->BeginWaitCursor();

	// Test the connection parameters
	PGconn	*pgconn = PQconnectdb(conn_str.GetString());

	// Unset busy cursor
	pMyMainWnd->EndWaitCursor();
	pMyMainWnd->set_wait_cursor(false);

	if (PQstatus(pgconn) == CONNECTION_OK) 
	{
		write_log_pokertracker(1, "Test: PostgreSQL DB opened successfully <%s/%s/%s>\n", ip_addr, port, dbname);
		if (PQisthreadsafe()) 
		{
			write_log_pokertracker(1, "Test: PostgreSQL library is thread safe.\n\n");
			OH_MessageBox_Interactive("PostgreSQL DB opened successfully", "Success", MB_OK);
		}
		else 
		{
			write_log_pokertracker(1, "Test: PostgreSQL library is *NOT* thread safe!  This is a problem!\n\n");
			OH_MessageBox_Interactive("PostgreSQL DB opened successfully, but\nPostgreSQL library is *NOT* thread safe!\nThis is a problem!",
					   "Success (partial)", MB_OK);
		}
		PQfinish(pgconn);
	}
	else 
	{
		write_log_pokertracker(1, "Test: ERROR opening PostgreSQL DB: %s\n\n", PQerrorMessage(pgconn));
		e = "ERROR opening PostgreSQL DB:\n";
		e += PQerrorMessage(pgconn);
		e += "\nConn string:";
		e += conn_str;

		OH_MessageBox_Interactive(e.GetString(), "ERROR", MB_OK);

		PQfinish(pgconn);
	}
}
コード例 #2
0
void CDlgSAPrefs2::OnOK()
{
	CString			text = "";

	m_FrameDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_FRAMEDELAY)
	{
		OH_MessageBox_Interactive("Invalid Frame Delay", "ERROR", MB_OK);
		return;
	}
	preferences.SetValue(k_prefs_frame_delay, strtoul(text.GetString(), 0, 10));

	m_ClickDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_CLICKDELAY)
	{
		OH_MessageBox_Error_Warning("Invalid Click Delay");
		return;
	}
	preferences.SetValue(k_prefs_click_delay, strtoul(text.GetString(), 0, 10));

	m_SwagDelay1.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY1)
	{
		OH_MessageBox_Interactive("Invalid Betsize Delay (Select to Delete)", "ERROR", MB_OK);
		return;
	}
	preferences.SetValue(k_prefs_swag_delay_1, strtoul(text.GetString(), 0, 10));

	m_SwagDelay2.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY2)
	{
		OH_MessageBox_Interactive("Invalid Betsize Delay (Delete to Entry)", "ERROR", MB_OK);
		return;
	}
	preferences.SetValue(k_prefs_swag_delay_2, strtoul(text.GetString(), 0, 10));

	m_SwagDelay3.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY3) 
	{
		OH_MessageBox_Interactive("Invalid Betsize Delay (Entry to Confirm)", "ERROR", MB_OK);
		return;
	}
	preferences.SetValue(k_prefs_swag_delay_3, strtoul(text.GetString(), 0, 10));

	preferences.SetValue(k_prefs_engage_autoplayer, m_Autoplayer_Upon_Connection.GetCheck()==BST_CHECKED ? true : false);
	preferences.SetValue(k_prefs_restore_position_and_focus, m_Restore_Position_And_Focus.GetCheck()==BST_CHECKED ? true : false);
	preferences.SetValue(k_prefs_use_auto_replay, m_Use_Auto_Replay.GetCheck()==BST_CHECKED ? true : false);
	preferences.SetValue(k_prefs_swag_use_comma, m_SwagUseComma.GetCheck()==BST_CHECKED ? true : false);
	
	CSAPrefsSubDlg::OnOK();
}
コード例 #3
0
void CDlgSAPrefs2::OnOK()
{
	CString			text = "";

	m_FrameDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_FRAMEDELAY)
	{
		OH_MessageBox_Interactive("Invalid Frame Delay", "ERROR", MB_OK);
		return;
	}
	prefs.set_frame_delay(strtoul(text.GetString(), 0, 10));

	m_ClickDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_CLICKDELAY)
	{
		OH_MessageBox_Error_Warning("Invalid Click Delay", "ERROR");
		return;
	}
	prefs.set_click_delay(strtoul(text.GetString(), 0, 10));

	m_SwagDelay1.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY1)
	{
		OH_MessageBox_Interactive("Invalid Swag Delay (Select to Delete)", "ERROR", MB_OK);
		return;
	}
	prefs.set_swag_delay_1(strtoul(text.GetString(), 0, 10));

	m_SwagDelay2.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY2)
	{
		OH_MessageBox_Interactive("Invalid Swag Delay (Delete to Entry)", "ERROR", MB_OK);
		return;
	}
	prefs.set_swag_delay_2(strtoul(text.GetString(), 0, 10));

	m_SwagDelay3.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY3) 
	{
		OH_MessageBox_Interactive("Invalid Swag Delay (Entry to Confirm)", "ERROR", MB_OK);
		return;
	}
	prefs.set_swag_delay_3(strtoul(text.GetString(), 0, 10));

	prefs.set_engage_autoplayer(m_Autoplayer_Upon_Connection.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_swag_use_comma(m_SwagUseComma.GetCheck()==BST_CHECKED ? true : false);
	
	CSAPrefsSubDlg::OnOK();
}
コード例 #4
0
ファイル: MainFrm.cpp プロジェクト: ohzooboy/oh
void CMainFrame::OnHelp()
{
    if (_access("OpenHoldem_Manual.chm", F_OK) != 0)
    {
        OH_MessageBox_Interactive("\"OpenHoldem_Manual.chm\" not found.\nPlease put it into your OpenHoldem folder.", "Error", 0);
    }
    else
    {
        long long int RetValue = long long int(ShellExecute(NULL, "open", "OpenHoldem_Manual.chm", NULL, NULL, SW_SHOW));
        if (RetValue <= 32)
        {
            OH_MessageBox_Interactive("Error opening help-file", "Error", 0);
        }
    }
}
コード例 #5
0
ファイル: DialogSAPrefs11.cpp プロジェクト: ohzooboy/oh
// DialogSAPrefs11 message handlers
void CDlgSAPrefs11::OnOK()
{
	CString			text = "";

	prefs.set_log_symbol_enabled(m_EnableLog.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_trace_enabled(m_EnableTrace.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_basic_logging_enabled(m_EnableBasicInfo.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_error_logging_enabled(m_EnableErrorLogging.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_dll_logging_enabled(m_EnableDLLLogging.GetCheck()==BST_CHECKED ? true : false);


	m_MaximumLog.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)<0 || strtoul(text.GetString(), 0, 10)>MAX_MAX_LOG) {
		OH_MessageBox_Interactive("Invalid maximum log amount!", "ERROR", MB_OK);
		return;
	}
	prefs.set_log_symbol_max_log(strtoul(text.GetString(), 0, 10));

	prefs.set_disable_msgbox(m_disable_msgbox.GetCheck()==BST_CHECKED ? true : false);

	m_MaximumLogSize.GetWindowText(text);
	prefs.set_log_max_logsize(strtoul(text.GetString(), NULL, 10));
	
	CSAPrefsSubDlg::OnOK();
}
コード例 #6
0
void CMainFrame::OnEditFormula() {
	if (m_formulaScintillaDlg) {
		if (m_formulaScintillaDlg->m_dirty)	{
			if (OH_MessageBox_Interactive(
				  "The Formula Editor has un-applied changes.\n"
				  "Really exit?", 
				  "Formula Editor", MB_ICONWARNING|MB_YESNO) == IDNO) {
				p_flags_toolbar->EnableButton(ID_MAIN_TOOLBAR_FORMULA, true);
				return;
			}
		}
    BOOL	bWasShown = ::IsWindow(m_formulaScintillaDlg->m_hWnd) && m_formulaScintillaDlg->IsWindowVisible();
    m_formulaScintillaDlg->DestroyWindow();
    if (bWasShown)
    {
			return;
    }
	}
  if (p_autoplayer->autoplayer_engaged()) {
    // The menu item Edit->Formula is disabled,
    // this is just an extra failsafe.
    return;
  }
  m_formulaScintillaDlg = new CDlgFormulaScintilla(this);
	m_formulaScintillaDlg->Create(CDlgFormulaScintilla::IDD,this);
	m_formulaScintillaDlg->ShowWindow(SW_SHOW);
	p_flags_toolbar->EnableButton(ID_MAIN_TOOLBAR_FORMULA, true);
}
コード例 #7
0
void CTablemapCompletenessChecker::ErrorMissingItem(CString item) {
  CString message;
  message.Format("Missing item in tablemap: %s.\n"
    "This item is absolutely necessary for correct execution.\n"
    "%s", 
    item, p_tablemap->filepath());
  OH_MessageBox_Interactive(message, "Error", 0);
}
コード例 #8
0
bool VerifyListName(CString name) {
  if (memcmp(name, "list", 4)!=0) {
	OH_MessageBox_Interactive(
      "Lists must begin with the name 'list'.\r\n"
      "e.g. 'list_limp_UTG'", 
      "Invalid Name", MB_ICONERROR);
	return false;
  } else if (strlen(name)==4) {
	OH_MessageBox_Interactive(
      "Lists must begin with the name 'list'\r\n"
      "and be followed by a number or identifier.\r\n"
      "e.g. 'list45'", 
      "Invalid Name", MB_ICONERROR);
	return false;
  }
  return true;
}
コード例 #9
0
bool VerifyFunctionName(CString name) {
  if (!COHScriptObject::IsFunction(name)) {
	OH_MessageBox_Interactive(
      "UDF's must begin with the name 'f$'\r\n"
      "e.g. 'f$myfunc'", 
      "Invalid Name", MB_ICONERROR);
	  return false;
  } else if (strlen(name)==2) {
   OH_MessageBox_Interactive(
     "UDF's must begin with the name 'f$'\r\n"
     "and be followed be the name of the function.\r\n"
     "e.g. 'f$myfunc'", 
     "Invalid Name", MB_ICONERROR);
	return false;
  }
  return true;
}
コード例 #10
0
void CDlgSAPrefs2::OnOK()
{
	CString			text = "";

	m_FrameDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_FRAMEDELAY)
	{
		OH_MessageBox_Interactive("Invalid Frame Delay", "ERROR", MB_OK);
		return;
	}
	prefs.set_frame_delay(strtoul(text.GetString(), 0, 10));

	m_SwagDelay1.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY1)
	{
		OH_MessageBox_Interactive("Invalid Swag Delay (Select to Delete)", "ERROR", MB_OK);
		return;
	}
	prefs.set_swag_delay_1(strtoul(text.GetString(), 0, 10));

	m_SwagDelay2.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY2)
	{
		OH_MessageBox_Interactive("Invalid Swag Delay (Delete to Entry)", "ERROR", MB_OK);
		return;
	}
	prefs.set_swag_delay_2(strtoul(text.GetString(), 0, 10));

	m_SwagDelay3.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)>MAX_SWAGDELAY3) 
	{
		OH_MessageBox_Interactive("Invalid Swag Delay (Entry to Confirm)", "ERROR", MB_OK);
		return;
	}
	prefs.set_swag_delay_3(strtoul(text.GetString(), 0, 10));

	prefs.set_ap_auto(m_AutoAP.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_focus_detect(m_FocusDetect.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_swag_use_comma(m_SwagUseComma.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_calc_only_my_turn(m_CalcOnMyTurn.GetCheck()==BST_CHECKED ? true : false);
	prefs.set_need_balance_stability(m_NeedBalanceStability.GetCheck()==BST_CHECKED ? true : false);

	CSAPrefsSubDlg::OnOK();
}
コード例 #11
0
void CTablemapCompletenessChecker::ErrorDeprecatedItem(CString item) {
  CString message;
  message.Format("Deprecated item in tablemap: %s.\n"
    "You can safely delete this item from the tablemap.\n"
    "Due to a simplification of OpenHoldem it is no longer required.\n"
    "The reasons and potential consequences are documented in the release-notes.\n"
    "%s", 
    item, p_tablemap->filepath());
  OH_MessageBox_Interactive(message, "Error", 0);
}
コード例 #12
0
void CDlgSAPrefs10::OnOK()
{
	CString			text = "";

	m_MinimumDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)<0 || strtoul(text.GetString(), 0, 10)>MAX_DELAY) {
		OH_MessageBox_Interactive("Invalid minimum Chat Delay", "ERROR", MB_OK);
		return;
	}
	prefs.set_chat_min_delay(strtoul(text.GetString(), 0, 10));

	m_RandomDelay.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)<0 || strtoul(text.GetString(), 0, 10)>MAX_DELAY) {
		OH_MessageBox_Interactive("Invalid random Chat Delay", "ERROR", MB_OK);
		return;
	}
	prefs.set_chat_random_delay(strtoul(text.GetString(), 0, 10));

	CSAPrefsSubDlg::OnOK();
}
コード例 #13
0
ファイル: DialogSAPrefs11.cpp プロジェクト: ohzooboy/oh
void CDlgSAPrefs11::OnBnClickedDisableMsgbox()
{
	if (m_disable_msgbox.GetCheck()==BST_CHECKED)
		OH_MessageBox_Interactive("Warning: Selecting this option instructs OpenHoldem to refrain from\n"
				   "displaying ANY runtime informational or error message boxes.  Examples\n"
				   "include parse errors, DLL load errors, etc.  It is strongly advised that\n"
				   "this option only be used in a production environment that has been\n"
				   "completely and thoroughly tested for proper behavior.\n\n"
				   "Note that interactive messages are not disabled, such as when using the\n"
				   "formula editor.", "WARNING", MB_OK);
}
コード例 #14
0
// Generates smart error-messages on failure
// To be used by the parser
void CFunctionCollection::VerifyExistence(CString name) {
  if (Exists(name)) return;
  // Error: function does not exist
  CString similar_name = GetSimilarNameWithDifferentCases(name);
  if (similar_name != "") {
    CString message;
    message.Format("%s%s%s%s%s",
      "Function used but never defined: ",
      name, 
      "\nDid you mean ",
      similar_name,
      " instead?");
    OH_MessageBox_Interactive(message, "Error", 0);
    return;
  } 
  // Else: general error-message
  CString message;
  message.Format("Function used but never defined\n%s", name);
  OH_MessageBox_Interactive(message, "Error", 0);
}
コード例 #15
0
void CMainFrame::OpenHelpFile(CString windows_help_file_chm)
{
	long long int RetValue = long long int(ShellExecute(NULL, "open", windows_help_file_chm, NULL, NULL, SW_SHOW));
	if (RetValue <= 32)
	{
		CString error_message;
		error_message.Format("Could not open help-file %s\n"
			"Please put it into your OpenHoldem folder\n",
			windows_help_file_chm);
		OH_MessageBox_Interactive(error_message, "Error", 0);
	}
}
コード例 #16
0
ファイル: DialogSAPrefs4.cpp プロジェクト: ohzooboy/oh
void CDlgSAPrefs4::OnOK()
{
    CString			text = "";

    m_ScrapeDelay.GetWindowText(text);
    if (strtoul(text.GetString(), 0, 10)<MIN_SCRAPEDELAY || strtoul(text.GetString(), 0, 10)>MAX_SCRAPEDELAY) {
        OH_MessageBox_Interactive("Invalid Scrape Delay", "ERROR", MB_OK);
        return;
    }
    preferences.SetValue(k_prefs_scrape_delay, strtoul(text.GetString(), 0, 10));

    CSAPrefsSubDlg::OnOK();
}
コード例 #17
0
// Returns the next function (including header),
// i.e. everything up to the second-next-function or end of file.
void CFormulaFileSplitter::ScanForNextFunctionOrList(CArchive &formula_file) {
  // Function-header is the first line, 
  // (usually the last line of last scan)
  // rest is content
  _function_header = _next_line;
  _function_text = ""; 
  while (true) {
    try {
      if (!formula_file.ReadString(_next_line)) {
	      break;
      }
    }
    catch (CException *e) {
	    // break;
    }
    ++_total_line_processed;
    // Avoid problems with "empty" lines before first function header
    // that contain spaces.
    _next_line.TrimRight();
#ifdef DEBUG_FORMULA_FILESPLITTER
    //printf("[CFormulaFileSplitter] next line: %s\n", _next_line);
#endif
    if (IsFunctionHeader(_next_line)
        && _first_function_processed) {
      // Next function found
      // Only continue, if we found the first one
      //
      // In case of break: keep that function-header for the next query
      _starting_line_of_current_function = _total_line_processed;
      break;
	  }
    if (_function_header.IsEmpty() || (_function_header.Find('#') < 0)) {
      // Escpecially meant to catch OpenGeeks newlines 
      // (which are not empty) at the beginning of the file.
      // Other cases can't happen, as we search for ## 
      // when looking for the next function-header. 
      _function_header = _next_line;
    } else {
      _first_function_processed = true;
      // Add non-function-header (content) to the functions body
      _function_text += _next_line;
      _function_text += "\n";
    }
  } 
#ifdef DEBUG_FORMULA_FILESPLITTER
  //printf("[CFormulaFileSplitter] next function: %s\n", _formula_content);
  OH_MessageBox_Interactive(_function_text, "Function", 0);
#endif
}
コード例 #18
0
// COpenHoldemDoc serialization
void COpenHoldemDoc::Serialize(CArchive& ar) 
{
	// Writing a file
	if (ar.IsStoring()) 
	{
		// Store archive in the new OpenHoldem format
		p_function_collection->Save(ar);
		// Do not close this archive here.
		// It's expected to stay open at this point!
	}
	// Reading a file
	else 
	{
		// Extra caution, in case we want to load a formula,
		// while the autoplayer is engaged.
		// This currently can only happen via the MRU-list.
		// The alternative way would be to disable that list...
		//
		// MainFrame.cpp:
		// ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE16, &CMainFrame::OnUpdateLRUList)
		//
		// void CMainFrame::OnUpdateLRUList(CCmdUI *pCmdUI)
		// {
		//	pCmdUI->Enable(!p_autoplayer->autoplayer_engaged());
		// }
		//
		// Unfortunatelly this does not work, 
		// but removes the list and replaces it once with the default: "Recent file".
		//
		// And there's very little information about both
		// ON_UPDATE_COMMAND_UI_RANGE and temporary disabling of MRU-lists.
		//
		// So we decided to go that route.
		//
		if (p_autoplayer->autoplayer_engaged())
		{
			OH_MessageBox_Interactive("Can't load formula while autoplayer engaged.", "ERROR", 0);
			return;
		}
		// Read ohf file
    assert(p_formula_parser != NULL);
		p_formula_parser->ParseFormulaFileWithUserDefinedBotLogic(ar);
		SetModifiedFlag(false);
		p_openholdem_title->UpdateTitle();

    // Try to (re)load (new) dll
		p_dll_extension->Load("");
	}
}
コード例 #19
0
bool CFunctionCollection::Rename(CString from_name, CString to_name) {
  CSLock lock(m_critsec);
  COHScriptObject *object_to_rename = LookUp(from_name);
  if (object_to_rename == NULL) return false;
  if (p_function_collection->LookUp(to_name) != NULL) {
    OH_MessageBox_Interactive("Cannot rename to a function/list that already exists", "Error", 0);
    return false;
  }
  // Delete old entry from the binary tree... 
  Delete(from_name);
  // ...then rename...
  object_to_rename->SetName(to_name);
  // ...and insert again.
  Add(object_to_rename);
  return true;
}
コード例 #20
0
void CParseErrors::Error(CString short_message) {
  if (short_message.Right(1) != "\n") {
    short_message += "\n";
  }
	CString message;
	message.Format("%s%s%s%s%s%i%s%s%i%s%s%s%s%s",
		"Error: ", short_message, 
		"=====================================================\n"
		"Function: ", CFormulaParser::CurrentFunctionName(), "\n"
		"Line absolute: ", CTokenizer::LineAbsolute(), "\n",
		"Line relative: ", CTokenizer::LineRelative(), "\n",
		"=====================================================\n",
		ErroneousCodeSnippet(), "\n",
		"=====================================================\n");
	OH_MessageBox_Interactive(message, "Parse Error", 0);
}
コード例 #21
0
// Generates smart error-messages on failure
// To be used by the parser
void CFunctionCollection::VerifyExistence(CString name) {
  if (Exists(name)) return;
  // Error: function does not exist
  CString message;
  message.Format("Function used but never defined> %s\n\n", name);
  CString similar_name = GetSimilarNameWithDifferentCases(name);
  name = name.MakeLower();
  if (similar_name != "") {
     message += "Did you mean ";
     message += similar_name;
     message += " instead?";
  } else if (name.Left(5) == "hand$" || name.Left(6) == "board$" || name.Left(4) == "user") {
    message += "hand$ and board$ expressions and user-variables\n";
    message += "are built-in and must be lower-cases.";
  } else {
    // Else: general error-message
  }
  OH_MessageBox_Interactive(message, "Error", 0);
}
コード例 #22
0
void CDlgSAPrefs16::OnOK()
{
	CString text = "";

	prefs.set_rebuy_condition_no_cards(_rebuy_condition_no_cards_Button.GetCheck() == true);
	prefs.set_rebuy_condition_change_in_handnumber(_rebuy_condition_change_in_handnumber_Button.GetCheck() == true);
	prefs.set_rebuy_condition_heuristic_check_for_occlusion(_rebuy_condition_heuristic_check_for_occlusion_Button.GetCheck() == true);

	_rebuy_minimum_time_to_next_try_Edit.GetWindowText(text);
	if (strtoul(text.GetString(), 0, 10)<0 || strtoul(text.GetString(), 0, 10)>MAX_MINIMUM_DELAY_TO_NEXT_REBUY) 
	{
		OH_MessageBox_Interactive("Invalid minimum time to next rebuy", "ERROR", MB_OK);
		return;
	}
	prefs.set_rebuy_minimum_time_to_next_try(strtoul(text.GetString(), 0, 10));

	_rebuy_script_Edit.GetWindowText(text);
	prefs.set_rebuy_script(text);
	
	CSAPrefsSubDlg::OnOK();
}
コード例 #23
0
BOOL COpenHoldemDoc::SaveModified()
{
	if (m_formulaScintillaDlg)
	{
		if (m_formulaScintillaDlg->m_dirty)
		{
			if (OH_MessageBox_Interactive(
				"The Formula Editor has un-applied changes.\n"
				"Really exit?", 
				"Formula Editor", MB_ICONWARNING|MB_YESNO) == IDNO)
			{
				return false;
			}
		}

		// Kill the formula dialog
		if(m_formulaScintillaDlg) 
			m_formulaScintillaDlg->DestroyWindow();

	}
	return CDocument::SaveModified();
}
コード例 #24
0
ファイル: CSharedMem.cpp プロジェクト: buranela/OpenHoldemV12
void CSharedMem::VerifyMainMutexName()
{
	// Some people were "smart" enough to use multiple ini-files
	// with differing mutex names:
	//
	// This leads to lots of problems:
	// * autoplayer actions no longer synchronized
	// * no longer unique session ID
	// * all bots try to write to the same log-file
	int CRC = crc32((const unsigned char *) prefs.mutex_name().GetString());
	if (CRC_of_main_mutexname == 0)
	{
		// Set the mutex
		// We have a potential race-condition here, but can't do anything.
		// But chances are very low that all instances interrupt
		// each other at the same time and same point.
		CRC_of_main_mutexname = CRC;
	}
	else if (CRC_of_main_mutexname != CRC)
	{
		// Another instance set another CRC,
		// i.e. has another name for the main mutex
		// ==> failure.
		// We assume that the user is present at the very first
		// test-run, so we throw an interactive message, no matter what.
		OH_MessageBox_Interactive("Incorrect mutex name.\n"
			"It is strictly necessary that all instances\n"
			"of OpenHoldem get the same main mutex name,\n"
			"otherwise very important functionality will fail:\n"
			"  * autoplayer synchronization\n"
			"  * session ID\n"
			"  * unique log-files\n"
			"Going to terminate...",
			"Mutex Error", 0);
		PostQuitMessage(-1);
	}
}
コード例 #25
0
// Menu -> Edit -> View Scraper Output
void CMainFrame::OnScraperOutput() {
	if (m_ScraperOutputDlg) {
		write_log(preferences.debug_gui(), "[GUI] m_ScraperOutputDlg = %i\n", m_ScraperOutputDlg);
		write_log(preferences.debug_gui(), "[GUI] Going to destroy existing scraper output dialog\n");

		BOOL	bWasShown = ::IsWindow(m_ScraperOutputDlg->m_hWnd) && m_ScraperOutputDlg->IsWindowVisible();
		write_log(preferences.debug_gui(), "[GUI] Scraper output dialog was visible: %s\n", Bool2CString(bWasShown));

    CDlgScraperOutput::DestroyWindowSafely();
		if (bWasShown) {
			write_log(preferences.debug_gui(), "[GUI] Scraper output dialog destroyed; going to return\n");
			return;
		}
	}	else {
		write_log(preferences.debug_gui(), "[GUI] Scraper output dialog does not yet exist\n");
	}
	
	OH_MessageBox_Interactive("Please note:\n"
	  "OpenScrape scrapes everything, but OpenHoldem is optimized\n"		  
	  "to scrape only necessary info.\n"
	  "\n"
	  "For example:\n"
	  "If a players first card is \"cardback\" we don't even have to scrape the second one.\n"
	  "This is a feature, not a bug.\n",
	  "Info", 0);

	write_log(preferences.debug_gui(), "[GUI] Going to create scraper output dialog\n");
	m_ScraperOutputDlg = new CDlgScraperOutput(this);
	write_log(preferences.debug_gui(), "[GUI] Scraper output dialog: step 1 finished\n");
	m_ScraperOutputDlg->Create(CDlgScraperOutput::IDD,this);
	write_log(preferences.debug_gui(), "[GUI] Scraper output dialog: step 2 finished\n");
	m_ScraperOutputDlg->ShowWindow(SW_SHOW);
	write_log(preferences.debug_gui(), "[GUI] Scraper output dialog: step 3 finished\n");
	p_flags_toolbar->EnableButton(ID_MAIN_TOOLBAR_SCRAPER_OUTPUT, true);
	write_log(preferences.debug_gui(), "[GUI] Scraper output dialog: step 4 (final) finished\n"); 
}
コード例 #26
0
// Generates smart error-messages on failure
// To be used by the parser
void CFunctionCollection::VerifyExistence(CString name) {
  // The OpenPPL-symbol "Random" is no longer implemented in the library
  // but as a built-in symbol to prevent symbol-caching.
  // Therefore we don't want to check if it is "missing" in the library.
  // http://www.maxinmontreal.com/forums/viewtopic.php?f=111&t=19611
  if (name == "Random") return;
  if (Exists(name)) return;
  // Error: function does not exist
  CString message;
  message.Format("Function used but never defined: %s\n\n", name);
  CString similar_name = GetSimilarNameWithDifferentCases(name);
  name = name.MakeLower();
  if (similar_name != "") {
     message += "Did you mean ";
     message += similar_name;
     message += " instead?";
  } else if (name.Left(5) == "hand$" || name.Left(6) == "board$" || name.Left(4) == "user") {
    message += "hand$ and board$ expressions and user-variables\n";
    message += "are built-in and must be lower-cases.";
  } else {
    // Else: general error-message
  }
  OH_MessageBox_Interactive(message, "Error", 0);
}
コード例 #27
0
void CProblemSolver::TryToDetectBeginnersProblems()
{
	if (NoTableMapsInScraperFolder())
	{
		OH_MessageBox_Interactive(
			"BAD NEWS:\n"
			"    - No tablemaps in scraper folder.\n"
			"\n"
			"You need a tablemap for every casino and game-type.",
			k_title_string, 0);

	}
	else if (NotConnected())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n"
			"\n"
			"BAD NEWS:\n"
			"    - You are not connected to a table.\n"
			"\n"
			" To connect to a table three conditions must be met:\n"
			"    - You need a tablemap for that casino and game-type.\n"
			"    - The table must match z$clientsizemin and z$clientsizemax.\n"
      "         OpenScrape -> Menu -> View\n"
			"    - The s$titletext must match.\n"
			"If OpenHoldem does not connect, then you have to fix your tablemap.",
			k_title_string, 0);
	}
	else if (NoOpponents())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n."
			"    - You are connected to a table.\n"
			"\n"
			"BAD NEWS:\n"
			"    - There seem to be no opponents.\n"
			"\n"
			"Please revisit your tablemap, especially:\n"
			"    - Seated regions\n"
			"    - Active regions\n"
			"    - Cardbacks\n",
			k_title_string, 0);
	}
	else if (UserChairUnknown())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n"
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"\n"
			"BAD NEWS:\n"
			"    - You are not seated or userchair not (yet) recognized.\n"
			"\n"
			"To detect the userchair three conditions must be met:\n"
			"    - Player must be active (not sitting out).\n"
			"    - Cards visible.\n"
			"    -  Buttons visible at the same time.\n"
			"Please revisit your tablemap.",
			k_title_string, 0);
	}
	else if (AutoPlayerDidActAtLeastOnce())
	{
		// This is the GOOD case!
		OH_MessageBox_Interactive(
			"REALLY GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder.\n"
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized.\n"
			"    - The autoplayer did act at least once.\n"
			"\n"
			"This means that your map and your settings\n"
			"are at least not completely wrong.\n" 
			"The rest is fine-tuning,\n"
			"we won't deal with that here.\n"
			"\n"
			"Good luck, dear friend.\n",
			k_title_string, 0);
	}
	// Cards and buttons get handled after the good case,
	// because cards and buttons are not always visible,
	// even if everything is ok.
	else if (NoCardsVisible())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder\n."
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized.\n"
			"\n"
			"BAD NEWS:\n"
			"    - You don't have any cards\n"
			"\n"       
			"Please revisit your tablemap\n"
			"to make sure that cards get scraped correctly.",
			k_title_string, 0);
	}
	else if (NotEnoughButtonsVisible())
	{
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder\n."
			"    - You are connected to a table.\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized.\n"
			"    - Your cards got recognized.\n"
			"\n"
			"BAD NEWS:\n"
			"    - Not enough buttons detected.\n"
			"\n"       
			"Please revisit your tablemap\n"
			"to make sure that all buttons get scraped correctly.",     
			k_title_string, 0);
	}
	else
	{
		// This should not happen.
		// No error detected, but autoplayer did not yet act.
		OH_MessageBox_Interactive(
			"GOOD NEWS:\n"
			"    - At least one tablemap in scraper folder\n."
			"    - You are connected to a table\n"
			"    - At least one opponent got recognized.\n"
			"    - Your chair got recognized\n"
			"    - Your cards got recognized\n"
			"    - Buttons got detected\n"
			"\n"
			"BAD NEWS:\n"
			"    - The autoplayer did not (yet) act,\n"        
			"\n"
			"The autoplayer should act within some seconds,\n"
			"as long as the autoplayer is engaged (default).\n",
			k_title_string, 0);
	}
}
コード例 #28
0
void CTablemapCompletenessChecker::VerifyMap() {
  // Only session 0 verifies the tablemaps
  // for better performance amd to avoid driving users crazy.
  if (p_sessioncounter->session_id() > 0) return;
  // Absoluely mandatory for connection
  CheckItem("titletext");
  // Necessary for connection: either clientsize or min/max
  if (!p_tablemap->ItemExists("clientsizemin") || !p_tablemap->ItemExists("clientsizemax")) {
    CheckItem("clientsize");
  }
  // All the rest is only needed for tables, but not for the lobby
  if (p_tablemap->islobby()) return;
  // Basic info, needed by every table
  CheckItem("nchairs");
  CheckItem("network");
  CheckItem("sitename"); 
  CheckItem("ttlimits");
  // Range-check nchairs
  int nchairs = p_tablemap->nchairs();
  int last_chair = nchairs - 1;
  if ((nchairs < 2) || (nchairs > kMaxNumberOfPlayers)) {
    CString message;
    message.Format("Tablemap item nchairs out of range\n"
      "Correct values: 2..10\n"
      "%s",
      p_tablemap->filepath());
    OH_MessageBox_Interactive(message, "Error", 0);
  }
  // Check mandatory items for every seat
  CheckSetOfItems("p", last_chair, "active",   true);  
  CheckSetOfItems("p", last_chair, "balance",  true);
  CheckSetOfItems("p", last_chair, "dealer",   true);
  CheckSetOfItems("p", last_chair, "name",     true);
  CheckSetOfItems("p", last_chair, "seated",   true);
  CheckSetOfItems("p", last_chair, "cardback", true);
  CheckSetOfItems("p", last_chair, "cardface0nocard", true);
  CheckSetOfItems("p", last_chair, "cardface1nocard", true);
  // Check mandatory cards faces (or rank + suit) for every seat
  for (int i=0; i<nchairs; ++i) {
    CheckCardFaces("p", i, "cardface0");
    CheckCardFaces("p", i, "cardface1");
  }
  CheckBetsOrChips();
  // Community cards
  for (int i=0; i<kNumberOfCommunityCards; ++i) {
    CheckCardFaces("c0cardface", i, "");
  }
  int last_communitz_card = kNumberOfCommunityCards - 1;
  CheckSetOfItems("c0cardface", last_communitz_card, "nocard", true);
  CheckMainPot();
  // Action buttons
  int number_of_buttons_seen = 0;
  for (int i=0; i<k_max_number_of_buttons; ++i) {
    CString button;
    button.Format("i%dbutton", i);
    if (p_tablemap->ItemExists(button)) {
      ++number_of_buttons_seen;
      CheckItem("i", i, "state");
      CheckItem("i", i, "label");
    }
  }
  if (number_of_buttons_seen < 3) {
    CString message;
    message.Format(
      "A tablemap needs at least 3 buttons:\n" 
      "  Fold, Check/Call, Bet/Raise\n"
      "At least one of them is missing.\n"
      "%s",
      p_tablemap->filepath());
    OH_MessageBox_Interactive(message, "Error", 0);
  }
  // No Limit only
  if (IsNoLimitMap()) {
    CheckItem("swagdeletionmethod");
    CheckItem("swagtextmethod");
    CheckItem("swagconfirmationmethod");
    CheckItem("i3edit");
    // i3edit ("swagging") needs a swagconfirmation-button,
    // which might be something different than min-raise-button.
    CheckItem("i3button");
    CheckItem("i3state");
    CheckItem("i3label");
    // Slider now optional, as allinmethod (= 3) is gone.
    // CheckItem("i3slider");
    // CheckItem("i3handle");
  }
  // Font-types
  for (int i=0; i<k_max_number_of_font_groups_in_tablemap; ++i) {
    if (p_tablemap->FontGroupInUse(i)) {
      CheckItem("t", i, "type");
    }
  }
    // Optional uX-regions
  CheckSetOfItems("u", last_chair, "name",    false);
  CheckSetOfItems("u", last_chair, "seated",  false);
  CheckSetOfItems("u", last_chair, "active",  false);
  CheckSetOfItems("u", last_chair, "balance", false);
  CheckSetOfItems("u", last_chair, "bet",     false);
  CheckSetOfItems("u", last_chair, "dealer",  false);
  // Not checked, despite nice to have
  //   * betpot-buttons
  //   * i86-buttons
  //
  // Not necessary, as optional
  //   * r$c0isfinaltable
  //   * potmethod
  //   * buttonclickmethod
  //   * betpotmethod
  //   * targetsize
  // and some others  
  //
  // r$c0istournament no longer supported, works automatically
  if (p_tablemap->ItemExists("c0istournament")) {
    ErrorDeprecatedItem("c0istournament");
  }
  // handresetmethod no longer supported, works automatically
  if (p_tablemap->ItemExists("handresetmethod")) {
    ErrorDeprecatedItem("handresetmethod");
  }
  // activemethod no longer upported since OpenHoldem 7.3.1
  // since it was based on backward-compatibilitz for a bug
  // http://www.maxinmontreal.com/forums/viewtopic.php?f=117&t=17818&start=30#p125307
  if (p_tablemap->ItemExists("activemethod")) {
    ErrorDeprecatedItem("activemethod");
  }
  // allinmethod no longer supported, works automatically
  if (p_tablemap->ItemExists("allinmethod")) {
    ErrorDeprecatedItem("allinmethod");
  }
}
コード例 #29
0
// COpenHoldemDoc serialization
void COpenHoldemDoc::Serialize(CArchive& ar) 
{
	// Extra caution, in case we want to load a formula,
	// while the autoplayer is engaged.
	// This currently can only happen via the MRU-list.
	// The alternative way would be to disable that list...
	//
	// MainFrame.cpp:
	// ON_UPDATE_COMMAND_UI_RANGE(ID_FILE_MRU_FILE1, ID_FILE_MRU_FILE16, &CMainFrame::OnUpdateLRUList)
	//
	// void CMainFrame::OnUpdateLRUList(CCmdUI *pCmdUI)
	// {
	//	pCmdUI->Enable(!p_autoplayer->autoplayer_engaged());
	// }
	//
	// Unfortunatelly this does not work, 
	// but removes the list and replaces it once with the default: "Recent file".
	//
	// And there's very little information about both
	// ON_UPDATE_COMMAND_UI_RANGE and temporary disabling of MRU-lists.
	//
	// So we decided to go that route.
	//
	if (p_autoplayer->autoplayer_engaged())
	{
		// This error can happen only in interactive mode,
		// so there's no need to turn that Messagebox off
		// depending on prefs.disable_msgbox()
		OH_MessageBox("Can't load a formula while autoplayer engaged.", "ERROR", 0);
		return;
	}
	CMainFrame		*pMyMainWnd  = (CMainFrame *) (theApp.m_pMainWnd);

	// Writing a file
	if (ar.IsStoring()) 
	{
		// Store archive in the new OpenHoldem format
		bool use_new_OHF_format = !IsWinHoldemFormat(ar.GetFile()->GetFileName());
		p_formula->WriteFormula(ar);
		// Do not close this archive here.
		// It's expected to stay open at this point!
		if (IsWinHoldemFormat(ar.GetFile()->GetFileName())) 
		{	
			// If the file was in the old WHF format,
			// store it also in the new OHF format.
			CString the_new_FileName = GetPathName();
			the_new_FileName.Replace("whf", "ohf");		
			// Notification
			OH_MessageBox_Interactive("Converting file formats\n{whf, whx} -> {ohf}",
				"File Conversion", MB_OK | MB_ICONINFORMATION);	
			// Open new style formula (OHF)	
			CFile OHF_File;
			OHF_File.Open(the_new_FileName, CFile::modeCreate | CFile::modeWrite);
			CArchive OHF_Archive(&OHF_File, CArchive::store);
			// Write new style formula (OHF) in any case
			p_formula->WriteFormula(OHF_Archive);
			// Close archive and file
			OHF_Archive.Close();
			OHF_File.Close();		
		}
	}
	// Reading a file
	else 
	{
		// Kill the formula dialog, if it is open
		if(m_formulaScintillaDlg) 
		{
			delete m_formulaScintillaDlg;
			m_formulaScintillaDlg	=	NULL;
			pMyMainWnd->m_MainToolBar.GetToolBarCtrl().CheckButton(ID_MAIN_TOOLBAR_FORMULA, false);
		}

		// Read ohf / whf file
		ReadFormula(ar);
		SetModifiedFlag(false);

		p_formula->set_formula_name(ar.GetFile()->GetFileName());

		// Try to unload dll
		p_dll_extension->UnloadDll();

		// Create hand list matrices
		p_formula->CreateHandListMatrices();

		// Create parse trees for newly loaded formula
		p_formula->ParseAllFormula(pMyMainWnd->GetSafeHwnd(), prefs.disable_msgbox());

		// Load dll, if set in preferences
		if (prefs.dll_load_on_startup())
			p_dll_extension->LoadDll("");
		if (prefs.simple_window_title() && theApp.m_pMainWnd)
			theApp.m_pMainWnd->PostMessage(WMA_SETWINDOWTEXT, 0, (LPARAM)NULL);
	}
}