Exemple #1
0
void CFormula::WarnAboutOutdatedConcepts()
{
	if (DoesFormulaAlreadyExist("f$play"))
	{
		OH_MessageBox("Your formula set contains a function f$play.\n"
			"The play-formula is an outdated messy concept,\n"
			"that got abolished in OpenHoldem 2.2.0.\n"
			"It got replaced by three separate functions:\n"
			"  * f$sitin\n"
			"  * f$sitout\n"
			"  * f$leave\n"
			"Please refer to the manual about how to adapt\n"
			"your formula set.",
			"Error", 0);
	}
	if (DoesFormulaAlreadyExist("f$swag") 
		|| DoesFormulaAlreadyExist("f$srai")
		|| DoesFormulaAlreadyExist("f$swag_adjust"))
	{
		OH_MessageBox("Your formula set contains old \"swag\"-functions.\n"
			"\"Swagging\" is an outdated messy concept,\n"
			"where the user had to care about everything.\n\n"
			"f$swag and its supporting functions and symbols\n"
			"got finally replaced by a single function f$betsize\n"
			"and OpenHoldem cares about all the rest automatically.\n\n"
			"Please refer to the manual about how to adapt\n"
			"your formula set.",
			"Error", 0);

	}
}
Exemple #2
0
void CMainFrame::OnFileLoadTableMap() 
{
	CFileDialog			cfd(true);
	int					line = 0, ret = 0;
	CString				e = "";

	cfd.m_ofn.lpstrInitialDir = prefs.path_tm();
	cfd.m_ofn.lpstrFilter = "OpenScrape Table Maps (.tm)\0*.tm\0All files (*.*)\0*.*\0\0";
	cfd.m_ofn.lpstrTitle = "Select OpenScrape table map to OPEN";

	if (cfd.DoModal() == IDOK)
	{
		CString loaded_version;
		ret = p_tablemap->LoadTablemap(cfd.m_ofn.lpstrFile, VER_OPENSCRAPE_2, &line, &loaded_version);
		
		if (loaded_version == VER_OPENHOLDEM_1 && ret == ERR_VERSION && !prefs.disable_msgbox())
		{
			e.Format("This is an OpenHoldem v1 profile (.ohdb1).\n"
					 "OpenHoldem versions 1.2.0 and higher require v2 Profiles (.ohdb2),\n"
					 "or OpenScrape Table Maps.\n");
			OH_MessageBox(e, "Table map load error", MB_OK);
		}

		else if ( (loaded_version == VER_OPENSCRAPE_1 || loaded_version == VER_OPENHOLDEM_2) )
		{
			OH_MessageBox("This is a version 1 table map.\n\n"\
					   "Version 2.0.0 and higher of OpenHoldem use a new format (version 2).  This\n"\
					   "table map has been loaded, but it is highly unlikely to work correctly until\n"\
					   "it has been opened in OpenScrape version 2.0.0 or higher, and adjustments\n"\
					   "have been made to autoplayer settings and region sizes.\n\n"\
					   "Please do not use this table map prior to updating it to version 2 in\n"\
					   "OpenScrape or you run the very serious risk of costly mis-scrapes.",
					   "Table map load warning", MB_OK | MB_ICONEXCLAMATION);		
		}

		else if (ret != SUCCESS)
		{
			e.Format("Error code: %d  line: %d", ret, line);
			OH_MessageBox(e, "Table map load error", MB_OK);
		}
		
		if (ret == SUCCESS)
		{
			// Reset "ScraperOutput" dialog, if it is live
			if (m_ScraperOutputDlg) 
			{
				m_ScraperOutputDlg->AddListboxItems();
				m_ScraperOutputDlg->UpdateDisplay();
			}

			prefs.set_path_tm(cfd.GetPathName());
		}
	}
}
void CConfigurationCheck::CheckForSwapMouseBtns()
{
	CString p_szKeySwapBtns = "Control Panel\\Mouse\\";
	CString p_szNameSwapBtns = "SwapMouseButtons";

	bool SwapBtns = false;

	if (atoi(GetValue("HKCU", 1, p_szKeySwapBtns, p_szNameSwapBtns)) == 1)
	{
		SwapBtns = true;
	}

	if (SwapBtns == true)
	{
		OH_MessageBox("It appears that your Mouse settings are not configured according to OpenHoldem specifications.\n\n"
			
			"The autoplayer has to generate mouse-events via a very low-level system-interface,\n"
			"and windows might/will swap these hardware-events for their inverse logical responses.\n\n"
			"This means Casinos clients will no longer interpret mouse-events correctly !\n"
			"Please Disable the - Swap Mouse Buttons - option in :\n\n"
			"Control Panel-> Mouse.\n\n"
			"and restart your user session in order to proceed\n",
			"Caution: Swap Mouse Buttons Activated", MB_OK|MB_ICONWARNING);
	}
}
void CConfigurationCheck::CheckForClassicalTheme()
{
	CString p_szKeyThemeActive = "Software\\Microsoft\\Windows\\CurrentVersion\\ThemeManager\\";
	CString p_szKeyWinVersion = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\";

	CString p_szNameThemeActive = "ThemeActive";
	CString p_szNameWinVersion = "CurrentVersion";

	bool classic_theme = false;

	CString win_Vs = GetValue("HKLM", 1, p_szKeyWinVersion, p_szNameWinVersion);

	CString WIN_2000 = "5.0";
	CString SRV_2003 = "5.2";

	if(win_Vs == WIN_2000 || win_Vs == SRV_2003)
	{
		classic_theme = true;
	}

	else if (atoi(GetValue("HKCU", 1, p_szKeyThemeActive, p_szNameThemeActive)) == 0)
	{
		classic_theme = true;
	}

	if (classic_theme == false)
	{
		OH_MessageBox("Classical Theme Not Found\n"
			"Settings deviate from recommended defaults.\n"
			"\n"
			"Please enable windows classical theme.\n"
			"for optimum compatibility \n",
			"Caution: Classical Theme Disabled", MB_OK|MB_ICONWARNING);
	}
}
Exemple #5
0
void CTableMapLoader::ParseAllTableMapsToLoadConnectionData(CString TableMapWildcard)
{
	CFileFind	hFile;
	SWholeMap	smap;
	int			line = 0;

	write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] ParseAllTableMapsToLoadConnectionData: %s\n", TableMapWildcard);
	_number_of_tablemaps_loaded = 0;
	CString	current_path = p_tablemap->filepath();
	BOOL bFound = hFile.FindFile(TableMapWildcard.GetString());
	while (bFound)
	{
		if (_number_of_tablemaps_loaded >= k_max_nmber_of_tablemaps)
		{
			write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] CAutoConnector: Error: Too many tablemaps. The autoconnector can only handle 25 TMs.", "Error", 0);
			OH_MessageBox("To many tablemaps.\n"
				"The auto-connector can handle 25 at most.", "ERROR", 0);
			return;
		}
		bFound = hFile.FindNextFile();
		if (!hFile.IsDots() && !hFile.IsDirectory() && hFile.GetFilePath()!=current_path)
		{
			int ret = p_tablemap->LoadTablemap((char *) hFile.GetFilePath().GetString(), 
				VER_OPENSCRAPE_2, &line);
			if (ret == SUCCESS)
			{
				CTableMapToSWholeMap(p_tablemap, &smap);
				ExtractConnectionDataFromCurrentTablemap(&smap);
				write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] Number of TMs loaded: %d\n", _number_of_tablemaps_loaded);
			}
		}
	}
}
void CConfigurationCheck::CheckForFontSmoothing()
{
	CString p_szKeyFontSmoothing = "Control Panel\\Desktop\\";
	CString p_szNameFontSmooth = "FontSmoothing";
	CString p_szNameFontSmoothType = "FontSmoothingType";

	bool font_smoothing = true;

	if (atoi(GetValue("HKCU", 1, p_szKeyFontSmoothing, p_szNameFontSmooth)) == 0)
	{
		if (atoi(GetValue("HKCU", 0, p_szKeyFontSmoothing, p_szNameFontSmoothType)) == 0)
		{
			font_smoothing = false;
		}
	}

	if (font_smoothing == true)
	{
		if (atoi(GetValue("HKCU", 1, p_szKeyFontSmoothing, p_szNameFontSmooth)) == 2)
		{
			int FontSmoothType = atoi(GetValue("HKCU", 0, p_szKeyFontSmoothing, p_szNameFontSmoothType));

			if (FontSmoothType == 2)
			{
				OH_MessageBox("It appears that Cleartype font smoothing is enabled.\n"
							"\n"
							"In order for OpenHoldem to reliably\n"
							"extract information from the poker client\n"
							"you should disable Font Smoothing.",
							"Caution: Font smoothing is enabled", MB_OK|MB_ICONWARNING);
			}

			else if (FontSmoothType == 1)
			{
				OH_MessageBox("It appears that Standard font smoothing is enabled.\n"
							"\n"
							"In order for OpenHoldem to reliably\n"
							"extract information from the poker client\n"
							"you should disable Font Smoothing.",
							"Caution: Font smoothing is enabled", MB_OK|MB_ICONWARNING);
			}
		}
	}
}
void CConfigurationCheck::CheckColourDepth()
{
	CWindowDC dc(NULL);
	int nBitsPerPixel = dc.GetDeviceCaps(PLANES) * dc.GetDeviceCaps(BITSPIXEL);
	if (nBitsPerPixel < 24)
		OH_MessageBox("It appears that your Display settings are not configured according to OpenHoldem specifications.\n"
				"24 bit color or higher is needed to reliably extract information from the poker client.\n\n"
				"For more info, look at the manual and the user forums",
				"Caution: Color Depth Too Low", MB_OK|MB_ICONWARNING);
}
Exemple #8
0
void CVersus::CheckForLoadedVersusBin()
{
	if (versus_bin_not_loaded)
	{
		OH_MessageBox("Impossible to use versus-symbols.\n"
			"Versus.bin not loaded and probably not installed.\n"
			"Please download this file from googlecode.", 
			"Versus Error", MB_OK | MB_TOPMOST);
	}
}
void CValidator::ValidateSingleRule()
{
	// Heuristic rules and not to be tested?
	if (_heuristic && !prefs.validator_use_heuristic_rules())
	{
		return;
	}
	// Test to be executed?
	if (_precondition) 
    { 
		// Test failed?
	    if (!_postcondition ) 
        { 
			if (_no_errors_this_heartbeat)
			{
				// First error: shoot replayframe, if needed
				if (prefs.validator_shoot_replayframe_on_error())
				{
					CReplayFrame crf;
					crf.CreateReplayFrame();
				}
				_no_errors_this_heartbeat = false;
			}
			if (prefs.validator_stop_on_error()) 
			{ 
				p_autoplayer->set_autoplayer_engaged(false); 
			}
			// Create error message
			CString the_ErrorMessage = "TESTCASE ID: " 
				+ CString(_testcase_id) 
				+ "\n\n";
			if (_heuristic)
			{
				the_ErrorMessage += "HEURISTIC RULE: yes\n\n";
			}
			the_ErrorMessage += "REASONING: "
				+ CString(_reasoning)
				+ "\n\n"
			    + "SYMBOLS AFFECTED: " 
				+ Symbols_And_Values(_symbols_possibly_affected); 
			// Show error message, if appropriate
			if (!prefs.disable_msgbox())
			{
				OH_MessageBox(the_ErrorMessage, "Validator Error", 
					MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION); 
			}
			// Log error message
			the_ErrorMessage.Replace("\n\n", ". ");
			the_ErrorMessage.Replace("\n", " ");
			write_log(1, "%s%s\n", "VALIDATOR ERROR: ", the_ErrorMessage);
		} 
    } 
}
Exemple #10
0
LONG WINAPI MyUnHandledExceptionFilter(EXCEPTION_POINTERS *pExceptionPointers) 
{
	// Create a minidump
	GenerateDump(pExceptionPointers);

	OH_MessageBox(
		"OpenHoldem is about to crash.\n"
		"A minidump has been created in your\n"
		"OpenHoldem startup directory.\n"
		"\n"
		"OpenHoldem will shut down when you click OK.",
		"FATAL ERROR", MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);
    return EXCEPTION_EXECUTE_HANDLER;
}
void CConfigurationCheck::CheckForMissingActivePerl()
{
	CString p_szKeyAP = "SOFTWARE\\Activestate\\ActivePerl\\";

	if (!OpenKey("HKLM", p_szKeyAP))
	{
		OH_MessageBox("Unable to detect\n"
			"ActiveState ActivePerl.\n"
			"\n"
			"This version is required for Perl users.\n"
			"if you don't use Perl you may turn this warning off\n"
			"by not loading the perl interpreter by default.",
			"Caution: ActivePerl missing", MB_OK|MB_ICONWARNING);
	}
}
Exemple #12
0
void CTableMapLoader::ExtractConnectionDataFromCurrentTablemap(SWholeMap *map)
{
	write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] ExtractConnectionDataFromCurrentTablemap(): %s\n", map->filepath);
	write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] number_of_tablemaps_loaded: %d\n", _number_of_tablemaps_loaded);

	// Avoiding to store the data twice, e.g. when we load a known TM manually
	if (tablemap_connection_dataAlreadyStored(map->filepath))
	{
		write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] ExtractConnectionDataFromCurrentTablemap(): already stored; early exit\n");
		return;
	}

	tablemap_connection_data[_number_of_tablemaps_loaded].FilePath = map->filepath;
	tablemap_connection_data[_number_of_tablemaps_loaded].SiteName = map->sitename;

	if (map->sitename == "")
	{
		CString error_message;
		error_message.Format("Tablemap contains no sitename.\n"
			"Sitenames are necessary to recognize duplicate TMs\n"
			"(and for other features like PokerTracker).\n\n",
			"%s", map->filepath);
		OH_MessageBox(error_message, "Warning", 0);
	}
	
	// Get clientsize info through TM-access-class
	p_tablemap_access->SetClientSize("clientsize", tablemap_connection_data[_number_of_tablemaps_loaded].ClientSizeX, tablemap_connection_data[_number_of_tablemaps_loaded].ClientSizeY);
	p_tablemap_access->SetClientSize("clientsizemin", tablemap_connection_data[_number_of_tablemaps_loaded].ClientSizeMinX, tablemap_connection_data[_number_of_tablemaps_loaded].ClientSizeMinY);
	p_tablemap_access->SetClientSize("clientsizemax", tablemap_connection_data[_number_of_tablemaps_loaded].ClientSizeMaxX, tablemap_connection_data[_number_of_tablemaps_loaded].ClientSizeMaxY);

	// Extract title text information
	p_tablemap_access->SetTitleText("titletext", tablemap_connection_data[_number_of_tablemaps_loaded].TitleText);
	// Extract negative title texs
	p_tablemap_access->SetTitleText("!titletext", tablemap_connection_data[_number_of_tablemaps_loaded].NegativeTitleText);
		
	CString s = "";
	for (int i=0; i<k_max_number_of_titletexts; i++)
	{
		s.Format("titletext%d", i);
		p_tablemap_access->SetTitleText(s, tablemap_connection_data[_number_of_tablemaps_loaded].TitleText_0_9[i]);

		s.Format("!titletext%d", i);
		p_tablemap_access->SetTitleText(s, tablemap_connection_data[_number_of_tablemaps_loaded].NegativeTitleText_0_9[i]);		
	}

	_number_of_tablemaps_loaded++;
}
void CConfigurationCheck::CheckForPerlPath()
{
	CString p_szKeyP = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\";
	CString p_szNameP = "Path";

	CString path = GetValue("HKLM", 1, p_szKeyP, p_szNameP);

	if (path.Find("Perl") == k_undefined)
	{
		OH_MessageBox("Path\n"
			"Perl was not correctly detected in your Path.\n"
			"\n"
			"If you don't use Perl you may turn this warning off\n"
			"by not loading the perl interpreter by default.",
			"Caution: Perl not found in %PATH%", MB_OK|MB_ICONWARNING);
	}
}
Exemple #14
0
LONG WINAPI MyUnHandledExceptionFilter(EXCEPTION_POINTERS *pExceptionPointers) 
{
	char flpath[MAX_PATH];
    char msg[1000];

	// Create a minidump
	GenerateDump(pExceptionPointers);

    sprintf_s(flpath, MAX_PATH, "%s\\fatal error.log", _startup_path);
    strcpy_s(msg, 1000, "OpenHoldem is about to crash.\n");
    strcat_s(msg, 1000, "A minidump has been created in your\n");
	strcat_s(msg, 1000, "OpenHoldem startup directory.\n");
    strcat_s(msg, 1000, "\n\nOpenHoldem will shut down when you click OK.");
    OH_MessageBox(msg, "FATAL ERROR", MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);

    return EXCEPTION_EXECUTE_HANDLER;
}
void CConfigurationCheck::CheckInputSettings()
{
	TCHAR KeyboardLayout[KL_NAMELENGTH];
	bool Success = GetKeyboardLayoutName((LPSTR)&KeyboardLayout);

	if (Success && (_tcscmp(KeyboardLayout, k_KeyboardLayout_UK_US_English) != 0))
	{
		OH_MessageBox("You seem to have non-english keyboard settings.\n"
				"Keyboard settings affect especially the decimal point in numbers\n"
				"and therefore the scraper-engine and the auto-player.\n"
				"If you continue, OpenHoldem may or may not work as expected.\n"
				"If you are an experienced user with a working setup\n"
				"you may turn this warning off.\n"
				"If you are new to OpenHoldem or encounter problems\n"
				"you should fix your keyboard settings\n",
				"Caution: Improper keyboard settings", MB_OK|MB_ICONWARNING);
	}
}
Exemple #16
0
void CTableMapLoader::CheckForDuplicatedTablemaps()
{
	CString error_message = "";
	for (int i=0; i<_number_of_tablemaps_loaded; i++)
	{
		for (int j=i+1; j<_number_of_tablemaps_loaded; j++)
		{
			if (tablemap_connection_data[i].SiteName == tablemap_connection_data[j].SiteName)
			{
				write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] tablemap_connection_dataDuplicated [%s] [true]\n", 
					tablemap_connection_data[i].SiteName);
				error_message.Format("It seems you have multiple versions of the same map in your scraper folder.\n\n"\
					"SITENAME = %s\n\n"\
					"This will cause problems as the autoconnector won't be able to decide which one to use.\n"\
					"Please remove the superfluous maps from the scraper folder.\n", 
					tablemap_connection_data[i].SiteName);
				OH_MessageBox((LPCTSTR) error_message, 
					"Warning! Duplicate SiteName", MB_OK|MB_ICONWARNING);
			}
		}
	}
}
Exemple #17
0
void CFormula::CreateHandListMatrices()
{
	CString		token = "";

	CSLock lock(m_critsec);

	for (int listnum=0; listnum<MAX_HAND_LISTS; listnum++)
		for (int i=0; i<=12; i++)
			for (int j=0; j<=12; j++)
				_formula.inlist[listnum][i][j] = false;

	for (int i=0; i<(int) _formula.mHandList.GetSize(); i++)
	{
		int listnum = atoi(_formula.mHandList[i].list.Mid(4).GetString());
		if (listnum>=MAX_HAND_LISTS)			
		{
			OH_MessageBox("List number too high.", "Error", 0);
			break;
		}
		ParseHandList(_formula.mHandList[i].list_text, _formula.inlist[listnum]);
	}
}
Exemple #18
0
CString CFilenames::IniFilename()
{
	WIN32_FIND_DATA find_file_data;
	HANDLE h_find;
	CString wildcard = OpenHoldemDirectory() + "\\*.INI";
	CString ini_filename;

	// Try to find "first" ini-file.
	// No matter how it is named -- it is the right one.
	// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx
	h_find = FindFirstFile(wildcard, &find_file_data);
	if (h_find == INVALID_HANDLE_VALUE) 
	{
		// No ini-file found.
		// Use default one (for saving).
		FindClose(h_find);
		return k_default_ini_filename;
	}
	ini_filename = find_file_data.cFileName;
	// Check that no more ini-files exist (potential problems).
	// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364428(v=vs.85).aspx
	if (FindNextFile(h_find, &find_file_data))
	{
		FindClose(h_find);
		OH_MessageBox(
			"More than one ini-file in OpenHoldem-directory.\n"
			"Don't know which one to use.\n"
			"\n"
			"Going to terminate...",
			"ERROR", 0);
		PostQuitMessage(-1);
		return "a_result_to_make_the_compiler_happy.ini";
	}
	FindClose(h_find);

	// Exactly one ini-file found
	return ini_filename;
}
void CConfigurationCheck::CheckForMissingMSVCRT()
{
	CString p_szKeyCRT = "SOFTWARE\\Microsoft\\DevDiv\\VC\\Servicing\\8.0\\RED\\1033\\";
	CString p_szNameCRT = "Install";

	bool installed = false;

	if (atoi(GetValue("HKLM", 0, p_szKeyCRT, p_szNameCRT)) == 1)
	{
		installed = true;
	}

	if (installed == false)
	{
		OH_MessageBox("Unable to detect\n"
			"Microsoft Visual C++ 2005 redistributable runtime library.\n"
			"\n"
			"This library is necessary for Perl users.\n"
			"if you don't use Perl you may turn this warning off\n"
			"by not loading the perl interpreter by default.",
			"Caution: MSVCRT 8.0 missing", MB_OK|MB_ICONWARNING);
	}
}
Exemple #20
0
void CPokerTrackerThread::WarnAboutInvalidPTSymbol(CString s)
{
	CString error_message = "Error: Invalid PT-symbol: " + s;
	OH_MessageBox(error_message, "Error", 0);
}
Exemple #21
0
void CFormula::CopyFormulaFrom(CFormula *f)
{
	SHandList		list;
	SFunction		func;
	int				from_count = 0, to_count = 0;
	bool			addit = false, deleteit = false;

	// Init locals
	list.list = "";
	list.list_text = "";
	func.cache = 0.;
	func.dirty = false;
	func.fresh = false;
	func.func = "";
	func.func_text = "";

	CSLock lock(m_critsec);

	// handle deleted udfs
	to_count = (int) _formula.mFunction.GetSize();
	for (int to_iter=0; to_iter<to_count; to_iter++)
	{
		from_count = (int) f->formula()->mFunction.GetSize();
		deleteit = true;
		for (int from_iter=0; from_iter<from_count; from_iter++)
		{
			if (_formula.mFunction[to_iter].func == f->formula()->mFunction[from_iter].func)
			{
				deleteit = false;
				from_iter = from_count+1;
			}
		}
		if (deleteit)
		{
			_formula.mFunction.RemoveAt(to_iter, 1);
			to_count = (int) _formula.mFunction.GetSize();
			to_iter-=1;
		}
	}

	// handle new/changed udfs
	from_count = (int) f->formula()->mFunction.GetSize();
	for (int from_iter=0; from_iter<from_count; from_iter++)
	{
		to_count = (int) _formula.mFunction.GetSize();
		addit = true;
		for (int to_iter=0; to_iter<to_count; to_iter++)
		{
			if (_formula.mFunction[to_iter].func == f->formula()->mFunction[from_iter].func)
			{
				// changed?
				addit = false;
				if (_formula.mFunction[to_iter].func_text == f->formula()->mFunction[from_iter].func_text)
				{
					// no change
					_formula.mFunction[to_iter].dirty = false;
					_formula.mFunction[to_iter].fresh = false;
				}
				else
				{
					// yup, it changed
					_formula.mFunction[to_iter].func_text = f->formula()->mFunction[from_iter].func_text;
					_formula.mFunction[to_iter].dirty = true;
					_formula.mFunction[to_iter].fresh = false;
					_formula.mFunction[to_iter].cache = 0.0;
				}
				to_iter = to_count+1;
			}
		}

		// new
		if (addit)
		{
			func.func = f->formula()->mFunction[from_iter].func;
			func.func_text = f->formula()->mFunction[from_iter].func_text;
			func.dirty = true;
			func.fresh = false;
			func.cache = 0.0;
			_formula.mFunction.Add(func);
		}
	}

	// Copy numbers
	_formula.dBankroll = f->formula()->dBankroll;
	_formula.dDefcon = f->formula()->dDefcon;
	_formula.dRake = f->formula()->dRake;
	_formula.dNit = f->formula()->dNit;

	// Copy hand lists
	_formula.mHandList.RemoveAll();
	from_count = (int) f->formula()->mHandList.GetSize();
	for (int from_iter=0; from_iter<from_count; from_iter++)
	{
		list.list = f->formula()->mHandList[from_iter].list;
		list.list_text = f->formula()->mHandList[from_iter].list_text;
		if (DoesFormulaAlreadyExist(list.list))
		{
			CString ErrorMessage = "Handlist does already exist: " + list.list;
			OH_MessageBox(ErrorMessage, "Error", 0);
		}
		else
		{
			_formula.mHandList.Add(list); 
		}
	}

	// Copy name
	_formula_name = f->formula_name();
}
Exemple #22
0
bool CFormula::ParseLoop(const CUPDUPDATA* pCUPDUPData)
{
	int				i = 0, j = 0, N = 0;
	CString			s = "";
	bool			result = false;
	int				stopchar = 0;
	int				c = 0, linenum = 0, colnum = 0;
	LARGE_INTEGER	bcount = {0}, ecount = {0}, lFrequency = {0};
	double			time_elapsed = 0.;
	sData			*data = (sData*) (pCUPDUPData->GetAppData());
	CGrammar		gram;
	bool            gui_enable_progress_dialog = !prefs.gui_disable_progress_dialog();

	pCUPDUPData->SetProgress("", 0, false);

	// init timer
	QueryPerformanceCounter(&bcount);
	QueryPerformanceFrequency(&lFrequency);

	N = (int) data->pParent->formula()->mFunction.GetSize();
	for (i=0; i<N; i++)
	{

		// Update progress dialog
		s.Format("Parsing formula set %s : %.0f%%", data->pParent->formula()->mFunction[i].func.GetString(), (double) i / (double) N * 100.0);
		QueryPerformanceCounter(&ecount);
		time_elapsed = ((double) (ecount.LowPart - bcount.LowPart))/((double) lFrequency.LowPart);
		pCUPDUPData->SetProgress(s.GetString(), (int) ((double) i / (double) N * 100.0), ((time_elapsed>=3.0) && gui_enable_progress_dialog));

		// Parse it if it is dirty, and not notes, dll or f$debug
		if (data->pParent->formula()->mFunction[i].dirty == true &&
				data->pParent->formula()->mFunction[i].func != "notes" &&
				data->pParent->formula()->mFunction[i].func != "dll" &&
				data->pParent->formula()->mFunction[i].func != "f$debug")
		{
			result = gram.ParseString(
							&data->pParent->formula()->mFunction[i].func_text, 
							data->pParent->formula(), 
							data->pParent->set_tpi(i), 
							&stopchar);

			if (!result)
			{
				linenum = colnum = 1;
				for (c=0; c<stopchar; c++)
				{
					if (data->pParent->formula()->mFunction[i].func_text.Mid(c, 1)=="\n")
					{
						linenum++;
						colnum = 1;
					}
					else
					{
						colnum++;
					}
				}
				s.Format("Error in parse of %s\nLine: %d  Character: %d\n\nNear:\n \"%s\"",
					 data->pParent->formula()->mFunction[i].func.GetString(),
					 linenum, colnum,
					 data->pParent->formula()->mFunction[i].func_text.Mid(stopchar, 40).GetString());
				OH_MessageBox(s, "PARSE ERROR", MB_OK);

				data->all_parsed = false;
			}

			else if (gram.parse_symbol_stop_strs()->GetSize() != 0)
			{
				s.Format("Error in parse of %s\n\nInvalid symbols:\n",
					 data->pParent->formula()->mFunction[i].func.GetString());
				for (j=0; j<gram.parse_symbol_stop_strs()->GetSize(); j++)
				{
					s.Append("   ");
					s.Append(gram.parse_symbol_stop_strs()->GetAt(j).c_str());
					s.Append("\n");
				}
				OH_MessageBox(s, "PARSE ERROR", MB_OK);

				data->all_parsed = false;
			}

			else
			{
				data->pParent->set_func_dirty(i, false);
			}
		}
	}
	pCUPDUPData->SetProgress("", 100, gui_enable_progress_dialog);

	return true;
}
// 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);
	}
}
Exemple #24
0
// Reading a part of a formula, which may be spread
// between two files in case of an old style whf / whx formula.
void CFormula::ReadFormulaFile(CArchive& ar, bool ignoreFirstLine)
{
	CString		strOneLine = ""; 
	int			content = 0;
	char		funcname[256] = {0};
	int			start = 0, end = 0;
		
	SFunction	func;	
	SHandList	list;		

	CSLock lock(m_critsec);

	// Ignore first line (date/time)
	if (ignoreFirstLine)
		ar.ReadString(strOneLine);

	// read data in, one line at a time
	strOneLine = "";
	content = FTnone;
	func.func = "";
	while(ar.ReadString(strOneLine)) 
	{ 
		// If this line marks the beginning of a function, then save the previously
		// collected function, and start a new one
		if (strOneLine.Mid(0,2)=="##") 
		{
			// Save the previously collected function
			if (content == FTlist) 
			{
				// Strip the LFCR off the last line (we need to add CRLF for all but the last line)
				list.list_text.TrimRight("\r\n");
				if (DoesFormulaAlreadyExist(list.list))
				{
					CString ErrorMessage = "Handlist does already exist: " + list.list;
					OH_MessageBox(ErrorMessage, "Error", 0);
				}
				else
				{
					_formula.mHandList.Add(list); 
				}
			}
			else if (content == FTfunc) 
			{
				func.func_text.TrimRight("\r\n");
				if (DoesFormulaAlreadyExist(func.func))
				{
					CString ErrorMessage = "Function does already exist: " + func.func;
					OH_MessageBox(ErrorMessage, "Error", 0);
				}
				else
				{
					_formula.mFunction.Add(func);
				}
			}
			// Get the function name				
			start = strOneLine.Find("##",0);

			// No need to check the result of start,
			// as this code gets executed only,
			// if a line starts with "##"	
			end = strOneLine.Find("##", start+2);

			// Checking for malformed function header
			// without trailing "##"
			if (end == -1) 
			{
				// Trying to continue gracefully.				
				// Skipping is not possible,
				// as this crashes the formula editor.											
				strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
				funcname[strOneLine.GetLength()]='\0';
				
				CString the_ErrorMessage = "Malformed function header!\nMissing trailing '##'.\n" 
					+ strOneLine + "\n"
					+ "Trying to continue...";
				OH_MessageBox(the_ErrorMessage, "Syntax Error", MB_OK | MB_ICONEXCLAMATION);
			}

			else 
			{
				strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
				funcname[end-2]='\0';
			}

			if (strcmp(funcname, "bankroll") == 0) { _formula.dBankroll = 0.0; content = FTbankroll; }
			
			else if (strcmp(funcname, "defcon") == 0) { _formula.dDefcon = 0.0; content = FTdefcon; }
			
			else if (strcmp(funcname, "rake") == 0) { _formula.dRake = 0.0; content = FTrake; }
			
			else if (strcmp(funcname, "nit") == 0) { _formula.dNit = 0.0; content = FTnit; }
			
			else if (memcmp(funcname, "list", 4) == 0) 
			{ 
				content = FTlist;
				list.list = funcname;
				list.list_text = "";
			}

			else 
			{
				content = FTfunc;
				func.func = funcname;
				func.func_text = "";
				func.dirty = true;
			}
		}

		// Get the function content
		else 
		{
			switch (content) 
			{
				 case FTbankroll:
					 if (strOneLine.GetLength())
						 _formula.dBankroll = atof(strOneLine.GetString());
					 break;
				 case FTdefcon:
					 if (strOneLine.GetLength())
						 _formula.dDefcon = atof(strOneLine.GetString());
					 break;
				 case FTrake:
					 if (strOneLine.GetLength())
						 _formula.dRake = atof(strOneLine.GetString());
					 break;
				 case FTnit:
					 if (strOneLine.GetLength())
						 _formula.dNit = atof(strOneLine.GetString());
					 break;
				 case FTlist:
					 list.list_text.Append(strOneLine); list.list_text.Append("\r\n");
					 break;
				 case FTfunc:
					 func.func_text.Append(strOneLine); func.func_text.Append("\r\n");
					 break;
			}
		}	
	}  

	// Add the last list/function to the CArray on EOF, if it was a list being processed
	if (content == FTlist) 
	{
		list.list_text.TrimRight("\r\n");
		if (DoesFormulaAlreadyExist(list.list))
		{
			CString ErrorMessage = "Handlist does already exist: " + list.list;
			OH_MessageBox(ErrorMessage, "Error", 0);
		}
		else
		{
			_formula.mHandList.Add(list); 
		}
	}
	else if (content == FTfunc) 
	{
		func.func_text.TrimRight("\r\n");
		if (DoesFormulaAlreadyExist(func.func))
		{
			CString ErrorMessage = "Function does already exist: " + func.func;
			OH_MessageBox(ErrorMessage, "Error", 0);
		}
		else
		{
			_formula.mFunction.Add(func);
		}
	}
}
Exemple #25
0
// COpenHoldemApp initialization
BOOL COpenHoldemApp::InitInstance()
{
	Scintilla_RegisterClasses(AfxGetInstanceHandle());

	// Initialize richedit2 library
	AfxInitRichEdit2();

	// Change class name of Dialog
	WNDCLASS wc;
	GetClassInfo(AfxGetInstanceHandle(), "#32770", &wc);

	wc.lpszClassName = "OpenHoldemFormula";
	wc.hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
	RegisterClass(&wc);

	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	// Since OH 2.2.0 we always use an ini-files,
	// the one and only in our OH-directory,
	// no matter how it is named.
	// For the technical details please see:
	// http://msdn.microsoft.com/de-de/library/xykfyy20(v=vs.80).aspx
	InstantiateSomeSingletonsForVeryEarlyUseInInitInstance();
	free((void*)m_pszProfileName);
	m_pszProfileName = _strdup(p_filenames->IniFilePath().GetString());
	prefs.LoadPreferences();
	
	// Classes
	if (!p_sessioncounter) p_sessioncounter = new CSessionCounter;
	// Start logging immediatelly after the loading the preferences
	// and initializing the sessioncounter.
	start_log();
	InstantiateAllSingletons();

	// mouse.dll - failure in load is fatal
	_mouse_dll = LoadLibrary("mouse.dll");
	if (_mouse_dll==NULL)
	{
		CString		t = "";
		t.Format("Unable to load mouse.dll, error: %d\n\nExiting.", GetLastError());
		OH_MessageBox(t, "OpenHoldem mouse.dll ERROR", MB_OK | MB_TOPMOST);
		return false;
	}
	else
	{
		_dll_mouse_process_message = (mouse_process_message_t) GetProcAddress(_mouse_dll, "ProcessMessage");
		_dll_mouse_click = (mouse_click_t) GetProcAddress(_mouse_dll, "MouseClick");
		_dll_mouse_click_drag = (mouse_clickdrag_t) GetProcAddress(_mouse_dll, "MouseClickDrag");

		if (_dll_mouse_process_message==NULL || _dll_mouse_click==NULL || _dll_mouse_click_drag==NULL)
		{
			CString		t = "";
			t.Format("Unable to find all symbols in mouse.dll");
			OH_MessageBox(t, "OpenHoldem mouse.dll ERROR", MB_OK | MB_TOPMOST);

			FreeLibrary(_mouse_dll);
			_mouse_dll = NULL;
			return false;
		}
	}

	// keyboard.dll - failure in load is fatal
	_keyboard_dll = LoadLibrary("keyboard.dll");
	if (_keyboard_dll==NULL)
	{
		CString		t = "";
		t.Format("Unable to load keyboard.dll, error: %d\n\nExiting.", GetLastError());
		OH_MessageBox(t, "OpenHoldem keyboard.dll ERROR", MB_OK | MB_TOPMOST);
		return false;
	}
	else
	{
		_dll_keyboard_process_message = (keyboard_process_message_t) GetProcAddress(_keyboard_dll, "ProcessMessage");
		_dll_keyboard_sendstring = (keyboard_sendstring_t) GetProcAddress(_keyboard_dll, "SendString");
		_dll_keyboard_sendkey = (keyboard_sendkey_t) GetProcAddress(_keyboard_dll, "SendKey");

		if (_dll_keyboard_process_message==NULL || _dll_keyboard_sendstring==NULL || _dll_keyboard_sendkey==NULL)
		{
			CString		t = "";
			t.Format("Unable to find all symbols in keyboard.dll");
			OH_MessageBox(t, "OpenHoldem keyboard.dll ERROR", MB_OK | MB_TOPMOST);

			FreeLibrary(_keyboard_dll);
			_keyboard_dll = NULL;
			return false;
		}
	}

	MyLoadStdProfileSettings(k_number_of_last_recently_used_files_in_file_menu);
	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CSingleDocTemplate* pDocTemplate;

	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(COpenHoldemDoc),
		RUNTIME_CLASS(CMainFrame),	   // main SDI frame window
		RUNTIME_CLASS(COpenHoldemView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	EnableShellOpen();
	RegisterShellFileTypes(false);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Open the most recently saved file. (First on the MRU list.) Get the last
	// file from the registry. We need not account for cmdInfo.m_bRunAutomated and
	// cmdInfo.m_bRunEmbedded as they are processed before we get here.
	if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
	{
		CString sLastPath(GetProfileString(_afxFileSection, "File1"));

		if (! sLastPath.IsEmpty())
		{
			CFile f;

			// If file is there, set to open!
			if (f.Open(sLastPath, CFile::modeRead | CFile::shareDenyWrite))
			{
				cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
				cmdInfo.m_strFileName = sLastPath;
				f.Close();
			}
		}
	}

	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	if (prefs.simple_window_title())
		m_pMainWnd->PostMessage(WMA_SETWINDOWTEXT, 0, (LPARAM)NULL);

	// The one and only window has been initialized, so show and update it
	if (prefs.gui_start_minimized())
	{
		m_pMainWnd->ShowWindow(SW_MINIMIZE);
	}
	else
	{
		m_pMainWnd->ShowWindow(SW_SHOW);
	}
	m_pMainWnd->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Bring main window to front
	m_pMainWnd->SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	m_pMainWnd->SetActiveWindow();
	m_pMainWnd->SetFocus();
	m_pMainWnd->SetForegroundWindow();

	// autoconnect on start, if preferred
	if (prefs.autoconnector_when_to_connect() == k_AutoConnector_Connect_Once)
	{
		p_autoconnector->Connect(NULL);
	}
	// Start thread anyway; permanent connection might be enabled later via preferences.
	p_autoconnectorthread->StartThread();	

	return TRUE;
}
Exemple #26
0
const double CPokerTrackerThread::ProcessQuery (const char * s)
{
	int		sym_raischair = p_symbol_engine_raisers_callers->raischair();

	if (!_connected || PQstatus(_pgconn) != CONNECTION_OK)
	{
		OH_MessageBox("Not connected to PokerTracker database.\n"
			"Can't use PokerTracker symbols.", "Error", 0);
		return -1.0;
	}

	// ATTENTION!
	//  
	// Be very careful, if a string is a prefix of multiple symbols,
	// e.g. "pt_vpip" is a prefix of both "pt_vpipX" and "pt_vpipsbX".
	// Take care to handle those cases correctly!

	// PokerTracker ring game symbols for the raise-chair
	if (StringAIsPrefixOfStringB("pt_r", s)
		&& !StringAIsPrefixOfStringB("pt_riverpct", s))
	{
		if		(StringIsExactMatch("pt_ricon", s))			return GetStat(sym_raischair, pt_icon);
		else if (StringIsExactMatch("pt_rpfr", s))			return GetStat(sym_raischair, pt_pfr);
		else if (StringIsExactMatch("pt_raggtotnopf", s))	return GetStat(sym_raischair, pt_aggtotnopf);
		else if (StringIsExactMatch("pt_raggtot", s))		return GetStat(sym_raischair, pt_aggtot);
		else if (StringIsExactMatch("pt_raggp", s))			return GetStat(sym_raischair, pt_aggp);
		else if (StringIsExactMatch("pt_raggf", s))			return GetStat(sym_raischair, pt_aggf);
		else if (StringIsExactMatch("pt_raggt", s))			return GetStat(sym_raischair, pt_aggt);
		else if (StringIsExactMatch("pt_raggr", s))			return GetStat(sym_raischair, pt_aggr);
		else if (StringIsExactMatch("pt_rfloppct", s))		return GetStat(sym_raischair, pt_floppct);
		else if (StringIsExactMatch("pt_rturnpct", s))		return GetStat(sym_raischair, pt_turnpct);
		else if (StringIsExactMatch("pt_rriverpct", s))		return GetStat(sym_raischair, pt_riverpct);
		else if (StringIsExactMatch("pt_rvpip", s))			return GetStat(sym_raischair, pt_vpip);
		else if (StringIsExactMatch("pt_rhands", s))		return GetStat(sym_raischair, pt_hands);
		else if (StringIsExactMatch("pt_rpf_rfi", s))		return GetStat(sym_raischair, pt_pf_rfi);
		else if (StringIsExactMatch("pt_rpf_cr", s))		return GetStat(sym_raischair, pt_pf_cr);
		else if (StringIsExactMatch("pt_rpfats", s))		return GetStat(sym_raischair, pt_pfats);
		else if (StringIsExactMatch("pt_rwsdp", s))			return GetStat(sym_raischair, pt_wsdp);
		else if (StringIsExactMatch("pt_rwssd", s))			return GetStat(sym_raischair, pt_wssd);
		else if (StringIsExactMatch("pt_rfbbts", s))		return GetStat(sym_raischair, pt_fbbts);
		else if (StringIsExactMatch("pt_rfsbts", s))		return GetStat(sym_raischair, pt_fsbts);

		else if (StringIsExactMatch("pt_rcbetflop", s))		return GetStat(sym_raischair, pt_cbetflop);
		else if (StringIsExactMatch("pt_rf3bettot", s))		return GetStat(sym_raischair, pt_f3bettot);
		else if (StringIsExactMatch("pt_rf3betpflop", s))	return GetStat(sym_raischair, pt_f3betpflop);
		else if (StringIsExactMatch("pt_rf3betflop", s))	return GetStat(sym_raischair, pt_f3betflop);
		else if (StringIsExactMatch("pt_rf3betturn", s))	return GetStat(sym_raischair, pt_f3betturn);
		else if (StringIsExactMatch("pt_rf3betriver", s))	return GetStat(sym_raischair, pt_f3betriver);
		else if (StringIsExactMatch("pt_rfcbetflop", s))	return GetStat(sym_raischair, pt_fcbetflop);
		else if (StringIsExactMatch("pt_rfcbetturn", s))	return GetStat(sym_raischair, pt_fcbetturn);
		else if (StringIsExactMatch("pt_rfcbetriver",s))	return GetStat(sym_raischair, pt_fcbetriver);
		else
		{
			// Invalid ring game symbol
			WarnAboutInvalidPTSymbol(s);
			return -1.0;
		}
	}
	// PokerTracker ring game symbols for chair X
	else if (StringAIsPrefixOfStringB("pt_", s))
	{
		if	    (StringAIsPrefixOfStringB("pt_iconlastr", s))		return GetStat(p_game_state->LastRaised(s[12]-'0'), pt_icon);
		else if (StringAIsPrefixOfStringB("pt_icon", s))			return GetStat(s[7]-'0', pt_icon);
		else if (StringAIsPrefixOfStringB("pt_pfr",s ))				return GetStat(s[6]-'0', pt_pfr);
		else if (StringAIsPrefixOfStringB("pt_aggtotnopf", s))		return GetStat(s[13]-'0', pt_aggtotnopf);
		else if (StringAIsPrefixOfStringB("pt_aggtot", s))			return GetStat(s[9]-'0', pt_aggtot);
		else if (StringAIsPrefixOfStringB("pt_aggp", s))			return GetStat(s[7]-'0', pt_aggp);
		else if (StringAIsPrefixOfStringB("pt_aggf", s))			return GetStat(s[7]-'0', pt_aggf);
		else if (StringAIsPrefixOfStringB("pt_aggt", s))			return GetStat(s[7]-'0', pt_aggt);
		else if (StringAIsPrefixOfStringB("pt_aggr", s))			return GetStat(s[7]-'0', pt_aggr);
		else if (StringAIsPrefixOfStringB("pt_floppct", s))			return GetStat(s[10]-'0', pt_floppct);
		else if (StringAIsPrefixOfStringB("pt_turnpct", s))			return GetStat(s[10]-'0', pt_turnpct);
		else if (StringAIsPrefixOfStringB("pt_riverpct", s))		return GetStat(s[11]-'0', pt_riverpct);
		else if (StringAIsPrefixOfStringB("pt_vpip", s))			return GetStat(s[7]-'0', pt_vpip);
		else if (StringAIsPrefixOfStringB("pt_hands", s))			return GetStat(s[8]-'0', pt_hands);
		else if (StringAIsPrefixOfStringB("pt_pf_rfi", s))			return GetStat(s[9]-'0', pt_pf_rfi);
		else if (StringAIsPrefixOfStringB("pt_pf_cr", s))			return GetStat(s[8]-'0', pt_pf_cr);
		else if (StringAIsPrefixOfStringB("pt_pfats", s))			return GetStat(s[8]-'0', pt_pfats);
		else if (StringAIsPrefixOfStringB("pt_wsdp", s))			return GetStat(s[7]-'0', pt_wsdp);
		else if (StringAIsPrefixOfStringB("pt_wssd",s))				return GetStat(s[7]-'0', pt_wssd);
		else if (StringAIsPrefixOfStringB("pt_fbbts", s))			return GetStat(s[8]-'0', pt_fbbts);
		else if (StringAIsPrefixOfStringB("pt_fsbts", s))			return GetStat(s[8]-'0', pt_fsbts);

		else if (StringAIsPrefixOfStringB("pt_cbetflop", s))		return GetStat(s[11]-'0', pt_cbetflop);
		else if (StringAIsPrefixOfStringB("pt_f3bettot", s))		return GetStat(s[11]-'0', pt_f3bettot);
		else if (StringAIsPrefixOfStringB("pt_f3betpflop", s))		return GetStat(s[15]-'0', pt_f3betpflop);
		else if (StringAIsPrefixOfStringB("pt_f3betflop", s))		return GetStat(s[12]-'0', pt_f3betflop);
		else if (StringAIsPrefixOfStringB("pt_f3betturn", s))		return GetStat(s[12]-'0', pt_f3betturn);
		else if (StringAIsPrefixOfStringB("pt_f3betriver", s))		return GetStat(s[13]-'0', pt_f3betriver);
		else if (StringAIsPrefixOfStringB("pt_fcbetflop", s))		return GetStat(s[12]-'0', pt_fcbetflop);
		else if (StringAIsPrefixOfStringB("pt_fcbetturn", s))		return GetStat(s[12]-'0', pt_fcbetturn);
		else if (StringAIsPrefixOfStringB("pt_fcbetriver", s))		return GetStat(s[12]-'0', pt_fcbetriver);
		else
		{
			// Invalid ring game symbol
			WarnAboutInvalidPTSymbol(s);
			return -1.0;
		}
	}
	// Poker Tracker tournament symbols for raise-chair
	else if (StringAIsPrefixOfStringB("ptt_r", s)
		&& !StringAIsPrefixOfStringB("ptt_riverpct", s))
	{
		if		(StringIsExactMatch("ptt_ricon", s))		return GetStat(sym_raischair, ptt_icon);
		else if (StringIsExactMatch("ptt_rpfr", s))			return GetStat(sym_raischair, ptt_pfr);
		else if (StringIsExactMatch("ptt_raggtotnopf", s))	return GetStat(sym_raischair, ptt_aggtotnopf);
		else if (StringIsExactMatch("ptt_raggtot", s))		return GetStat(sym_raischair, ptt_aggtot);
		else if (StringIsExactMatch("ptt_raggp", s))		return GetStat(sym_raischair, ptt_aggp);
		else if (StringIsExactMatch("ptt_raggf", s))		return GetStat(sym_raischair, ptt_aggf);
		else if (StringIsExactMatch("ptt_raggt", s))		return GetStat(sym_raischair, ptt_aggt);
		else if (StringIsExactMatch("ptt_raggr", s))		return GetStat(sym_raischair, ptt_aggr);
		else if (StringIsExactMatch("ptt_rfloppct", s))		return GetStat(sym_raischair, ptt_floppct);
		else if (StringIsExactMatch("ptt_rturnpct", s))		return GetStat(sym_raischair, ptt_turnpct);
		else if (StringIsExactMatch("ptt_rriverpct", s))	return GetStat(sym_raischair, ptt_riverpct);
		else if (StringIsExactMatch("ptt_rvpip", s))		return GetStat(sym_raischair, ptt_vpip);
		else if (StringIsExactMatch("ptt_rhands", s))		return GetStat(sym_raischair, ptt_hands);
		else if (StringIsExactMatch("ptt_rpf_rfi", s))		return GetStat(sym_raischair, ptt_pf_rfi);
		else if (StringIsExactMatch("ptt_rpf_cr", s))		return GetStat(sym_raischair, ptt_pf_cr);
		else if (StringIsExactMatch("ptt_rpfats", s))		return GetStat(sym_raischair, ptt_pfats);
		else if (StringIsExactMatch("ptt_rwsdp", s))		return GetStat(sym_raischair, ptt_wsdp);
		else if (StringIsExactMatch("ptt_rwssd", s))		return GetStat(sym_raischair, ptt_wssd);
		else if (StringIsExactMatch("ptt_rfbbts", s))		return GetStat(sym_raischair, ptt_fbbts);
		else if (StringIsExactMatch("ptt_rfsbts", s))		return GetStat(sym_raischair, ptt_fsbts);
		else
		{
			// Invalid tournament symbol
			WarnAboutInvalidPTSymbol(s);
			return -1.0;
		}
	}
	// Poker Tracker tournament symbols for chair x
	else if (StringIsExactMatch("ptt_", s))
	{
		if		(StringAIsPrefixOfStringB("ptt_iconlastr", s))		return GetStat(p_game_state->LastRaised(s[13]-'0'), ptt_icon);
		else if (StringAIsPrefixOfStringB("ptt_icon", s))			return GetStat(s[8]-'0', ptt_icon);
		else if (StringAIsPrefixOfStringB("ptt_pfr", s))			return GetStat(s[7]-'0', ptt_pfr);
		else if (StringAIsPrefixOfStringB("ptt_aggtotnopf", s))		return GetStat(s[14]-'0', ptt_aggtotnopf);
		else if (StringAIsPrefixOfStringB("ptt_aggtot", s))			return GetStat(s[10]-'0', ptt_aggtot);
		else if (StringAIsPrefixOfStringB("ptt_aggp", s))			return GetStat(s[8]-'0', ptt_aggp);
		else if (StringAIsPrefixOfStringB("ptt_aggf", s))			return GetStat(s[8]-'0', ptt_aggf);
		else if (StringAIsPrefixOfStringB("ptt_aggt", s))			return GetStat(s[8]-'0', ptt_aggt);
		else if (StringAIsPrefixOfStringB("ptt_aggr", s))			return GetStat(s[8]-'0', ptt_aggr);
		else if (StringAIsPrefixOfStringB("ptt_floppct", s))		return GetStat(s[11]-'0', ptt_floppct);
		else if (StringAIsPrefixOfStringB("ptt_turnpct", s))		return GetStat(s[11]-'0', ptt_turnpct);
		else if (StringAIsPrefixOfStringB("ptt_riverpct", s))		return GetStat(s[12]-'0', ptt_riverpct);
		else if (StringAIsPrefixOfStringB("ptt_vpip", s))			return GetStat(s[8]-'0', ptt_vpip);
		else if (StringAIsPrefixOfStringB("ptt_hands", s))			return GetStat(s[9]-'0', ptt_hands);
		else if (StringAIsPrefixOfStringB("ptt_pf_rfi", s))			return GetStat(s[10]-'0', ptt_pf_rfi);
		else if (StringAIsPrefixOfStringB("ptt_pf_cr", s))			return GetStat(s[9]-'0', ptt_pf_cr);
		else if (StringAIsPrefixOfStringB("ptt_pfats", s))			return GetStat(s[9]-'0', ptt_pfats);
		else if (StringAIsPrefixOfStringB("ptt_wsdp", s))			return GetStat(s[8]-'0', ptt_wsdp);
		else if (StringAIsPrefixOfStringB("ptt_wssd", s))			return GetStat(s[8]-'0', ptt_wssd);
		else if (StringAIsPrefixOfStringB("ptt_fbbts", s))			return GetStat(s[9]-'0', ptt_fbbts);
		else if (StringAIsPrefixOfStringB("ptt_fsbts", s))			return GetStat(s[9]-'0', ptt_fsbts);
		else
		{
			// Invalid tournament symbol
			WarnAboutInvalidPTSymbol(s);
			return -1.0;
		}
	}
	else
	{
		// Completely invalid symbol
		WarnAboutInvalidPTSymbol(s);
		return -1.0;
	}
}
Exemple #27
0
// COpenHoldemApp initialization
BOOL COpenHoldemApp::InitInstance()
{
	Scintilla_RegisterClasses(AfxGetInstanceHandle());

	// Initialize richedit2 library
	AfxInitRichEdit2();

	// Change class name of Dialog
	WNDCLASS wc;
	GetClassInfo(AfxGetInstanceHandle(), "#32770", &wc);

	wc.lpszClassName = "OpenHoldemFormula";
	wc.hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
	RegisterClass(&wc);

	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	bool load_from_registry = true;
	for (int i = 1; i < __argc; i++)
	{
		LPCTSTR pszParam = __targv[i];
		if (_tcsncmp(pszParam, "/ini:", 5) == 0) {
			CString path(pszParam+5);
			path.Replace("~", _startup_path);
			free((void*)m_pszProfileName);
			m_pszProfileName = _strdup(path);
			load_from_registry = false;
		}
		if (_tcscmp(pszParam, "/ini") == 0) {
			CString path;
			path.Format("%s\\openholdem.ini", _startup_path);
			free((void*)m_pszProfileName);
			m_pszProfileName = _strdup(path);
			load_from_registry = false;
		}
	}
	if (load_from_registry)
		SetRegistryKey(_T("OpenHoldem"));
	prefs.LoadPreferences(load_from_registry);
	
	// Classes
	if (!p_sessioncounter) p_sessioncounter = new CSessionCounter;
	// Start logging immediatelly after the loading the preferences
	// and initializing the sessioncounter.
	start_log();
	InstanciateAllSingletonsExceptSessionCounter(); 

	// mouse.dll - failure in load is fatal
	_mouse_dll = LoadLibrary("mouse.dll");
	if (_mouse_dll==NULL)
	{
		CString		t = "";
		t.Format("Unable to load mouse.dll, error: %d\n\nExiting.", GetLastError());
		OH_MessageBox(t, "OpenHoldem mouse.dll ERROR", MB_OK | MB_TOPMOST);
		return false;
	}
	else
	{
		_dll_mouse_process_message = (mouse_process_message_t) GetProcAddress(_mouse_dll, "ProcessMessage");
		_dll_mouse_click = (mouse_click_t) GetProcAddress(_mouse_dll, "MouseClick");
		_dll_mouse_click_drag = (mouse_clickdrag_t) GetProcAddress(_mouse_dll, "MouseClickDrag");

		if (_dll_mouse_process_message==NULL || _dll_mouse_click==NULL || _dll_mouse_click_drag==NULL)
		{
			CString		t = "";
			t.Format("Unable to find all symbols in mouse.dll");
			OH_MessageBox(t, "OpenHoldem mouse.dll ERROR", MB_OK | MB_TOPMOST);

			FreeLibrary(_mouse_dll);
			_mouse_dll = NULL;
			return false;
		}
	}

	// keyboard.dll - failure in load is fatal
	_keyboard_dll = LoadLibrary("keyboard.dll");
	if (_keyboard_dll==NULL)
	{
		CString		t = "";
		t.Format("Unable to load keyboard.dll, error: %d\n\nExiting.", GetLastError());
		OH_MessageBox(t, "OpenHoldem keyboard.dll ERROR", MB_OK | MB_TOPMOST);
		return false;
	}
	else
	{
		_dll_keyboard_process_message = (keyboard_process_message_t) GetProcAddress(_keyboard_dll, "ProcessMessage");
		_dll_keyboard_sendstring = (keyboard_sendstring_t) GetProcAddress(_keyboard_dll, "SendString");
		_dll_keyboard_sendkey = (keyboard_sendkey_t) GetProcAddress(_keyboard_dll, "SendKey");

		if (_dll_keyboard_process_message==NULL || _dll_keyboard_sendstring==NULL || _dll_keyboard_sendkey==NULL)
		{
			CString		t = "";
			t.Format("Unable to find all symbols in keyboard.dll");
			OH_MessageBox(t, "OpenHoldem keyboard.dll ERROR", MB_OK | MB_TOPMOST);

			FreeLibrary(_keyboard_dll);
			_keyboard_dll = NULL;
			return false;
		}
	}

	MyLoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
	if (m_pRecentFileList == NULL)
		AfxMessageBox("Still NULL");
	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CSingleDocTemplate* pDocTemplate;

	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(COpenHoldemDoc),
		RUNTIME_CLASS(CMainFrame),	   // main SDI frame window
		RUNTIME_CLASS(COpenHoldemView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// Enable DDE Execute open
	if (load_from_registry)
	{
		EnableShellOpen();
		RegisterShellFileTypes(false);
	}

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Open the most recently saved file. (First on the MRU list.) Get the last
	// file from the registry. We need not account for cmdInfo.m_bRunAutomated and
	// cmdInfo.m_bRunEmbedded as they are processed before we get here.
	if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
	{
		CString sLastPath(GetProfileString(_afxFileSection, "File1"));

		if (! sLastPath.IsEmpty())
		{
			CFile f;

			// If file is there, set to open!
			if (f.Open(sLastPath, CFile::modeRead | CFile::shareDenyWrite))
			{
				cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
				cmdInfo.m_strFileName = sLastPath;
				f.Close();
			}
		}
	}

	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	if (prefs.simple_window_title())
		m_pMainWnd->PostMessage(WMA_SETWINDOWTEXT, 0, (LPARAM)NULL);

	// The one and only window has been initialized, so show and update it
	if (prefs.gui_start_minimized())
	{
		m_pMainWnd->ShowWindow(SW_MINIMIZE);
	}
	else
	{
		m_pMainWnd->ShowWindow(SW_SHOW);
	}
	m_pMainWnd->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();

	// Bring main window to front
	m_pMainWnd->SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
	m_pMainWnd->SetActiveWindow();
	m_pMainWnd->SetFocus();
	m_pMainWnd->SetForegroundWindow();

	// autoconnect on start, if preferred
	if (prefs.autoconnector_when_to_connect() == k_AutoConnector_Connect_Once)
	{
		p_autoconnector->Connect(NULL);
	}
	// Start thread anyway; permanent connection might be enabled later via preferences.
	p_autoconnectorthread->StartThread();	

	return TRUE;
}
Exemple #28
0
void CDlgPpro::OnBnClickedConnectButton() 
{
	CDlgPpro		dlgppro;
	CString			s = "";
	PokerMessage	pm;
	CString			text = "";
	CMainFrame		*cmf = (CMainFrame *)theApp.m_pMainWnd;

	// Disconnect if we are already connected
	if (p_pokerpro->IsConnected()) 
	{
		// stop threads
		if (p_heartbeat_thread)
		{
			delete p_heartbeat_thread;
			p_heartbeat_thread = NULL;
		}

		if (p_pokertracker_thread)
			p_pokertracker_thread->StopThread();

		// Make sure autoplayer is off
		p_autoplayer->set_autoplayer_engaged(false);

		// Do the disconnect
		p_pokerpro->Disconnect();
		p_pokerpro->set_ppdata_clear();
		p_pokerpro->set_ppdata_reset_userchair();

		// Enable buttons, menu items
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW, true);
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_FILE_OPEN, true);
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_MAIN_TOOLBAR_GREENCIRCLE, true);
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_MAIN_TOOLBAR_REDCIRCLE, false);
	}
	else 
	{
		SaveSettingsToRegistry();

		// connect
		if (p_pokerpro->Connect(prefs.ppro_hostname().GetString(), prefs.ppro_port().GetString()) < 0) {
			OH_MessageBox("connection failed", "PPro connect error", MB_OK);
			return;
		}

		p_pokerpro->ResetHand();

		// send version info
		p_pokerpro->SendVersion();

		// log in
		int ret = p_pokerpro->SendLogin(prefs.ppro_username().GetString(), prefs.ppro_password().GetString());
		if ( ret < 0) 
		{
			OH_MessageBox("login failed", "PPro connect error", MB_OK);
			return;
		}

		// Reset symbols
		p_symbols->ResetSymbolsFirstTime();

		// Disable buttons, menu items
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_FILE_NEW, false);
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_FILE_OPEN, false);
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_MAIN_TOOLBAR_GREENCIRCLE, false);
		cmf->m_MainToolBar.GetToolBarCtrl().EnableButton(ID_MAIN_TOOLBAR_REDCIRCLE, false);

		// Make sure autoplayer is off
		p_autoplayer->set_autoplayer_engaged(false);

		// start heartbeat thread
		if (p_heartbeat_thread)
		{
			delete p_heartbeat_thread;
			write_log(3, "Stopped heartbeat thread: %08x\n", p_heartbeat_thread);
			p_heartbeat_thread = NULL;
		}

		p_heartbeat_thread = new CHeartbeatThread;
		write_log(3, "Started heartbeat thread: %08x\n", p_heartbeat_thread);
	}
}