CPokerTrackerThread::CPokerTrackerThread() { // Initialize variables _pt_thread = NULL; _conn_str.Format("host=%s port=%s user=%s password=%s dbname='%s'", prefs.pt_ip_addr(), prefs.pt_port(), prefs.pt_user(), prefs.pt_pass(), prefs.pt_dbname()); ClearAllStats(); _connected = false; _m_stop_thread = NULL; _m_wait_thread = NULL; SetStatGroups(); SetStatTypes(); _pgconn = NULL; }
bool CPokerTrackerThread::QueryName(const char * query_name, const char * scraped_name, char * best_name) { char strQry[k_max_length_of_query] = {0}; int lev_dist = 0, bestLD = 0, bestLDindex = 0; PGresult *res = NULL; char siteidstr[k_max_length_of_site_id] = {0}; bool result = false; CLevDistance myLD; int siteid = 0; static int _last_siteid = -1; double Levenshtein_distance_matching_factor = 0.2; //No more unnecessary queries when we don't even have a siteid to check siteid = pt_lookup.GetSiteId(); if (siteid == k_undefined) return false; // siteid has changed -- we're using ManualMode if (siteid != _last_siteid) { ClearAllStats(); _last_siteid = siteid; } if (!_connected || PQstatus(_pgconn) != CONNECTION_OK) return false; if (0 == strlen(query_name)) return false; sprintf_s(siteidstr, k_max_length_of_site_id, "%d", siteid); // PT version 3 name query strcpy_s(strQry, k_max_length_of_query, "SELECT player_name FROM player WHERE player_name like '"); strcat_s(strQry, k_max_length_of_query, query_name); strcat_s(strQry, k_max_length_of_query, "' AND id_site="); strcat_s(strQry, k_max_length_of_query, siteidstr); try { res = PQexec(_pgconn, strQry); } catch (_com_error &e) { write_log_pokertracker(prefs.debug_pokertracker(), "Postgres Query error:\n"); write_log_pokertracker(prefs.debug_pokertracker(), "\tCode = %08lx\n", e.Error()); write_log_pokertracker(prefs.debug_pokertracker(), "\tCode meaning = %s\n", e.ErrorMessage()); _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); write_log_pokertracker(prefs.debug_pokertracker(), "\tSource = %s\n", (LPCTSTR) bstrSource); write_log_pokertracker(prefs.debug_pokertracker(), "\tDescription = %s\n", (LPCTSTR) bstrDescription); write_log_pokertracker(prefs.debug_pokertracker(), "\tQuery = [%s]\n", strQry); } // We got nothing, return false if (PQntuples(res) == 0) { result = false; } // If we get one tuple, all is good - return the one name if (PQntuples(res) == 1) { lev_dist = myLD.LD(scraped_name, PQgetvalue(res, 0, 0)); if (lev_dist<=(int)strlen(PQgetvalue(res, 0, 0))*Levenshtein_distance_matching_factor ) { strcpy_s(best_name, k_max_length_of_playername, PQgetvalue(res, 0, 0)); result = true; } else { result = false; } } // We got more than one tuple, figure the Levenshtein distance for all of them // and return the best else if ((PQntuples(res) > 1)) { bestLD = 999; for (int i=0; i<PQntuples(res); i++) { lev_dist = myLD.LD(scraped_name, PQgetvalue(res, i, 0)); if (lev_dist<bestLD && lev_dist<(int)strlen(PQgetvalue(res, i, 0))*Levenshtein_distance_matching_factor ) { bestLD = lev_dist; bestLDindex = i; } } if (bestLD != 999) { strcpy_s(best_name, k_max_length_of_playername, PQgetvalue(res, bestLDindex, 0)); result = true; } else { result = false; } } PQclear(res); return result; }
void CSymbolEnginePokerTracker::ResetOnConnection() { ClearAllStats(); p_pokertracker_thread->StartThread(); }
void CSymbolEnginePokerTracker::ResetOnHandreset() { if (p_symbol_engine_isrush->isrush()) ClearAllStats(); }
void CSymbolEnginePokerTracker::InitOnStartup() { check_for_identity_of_players_executed_this_heartbeat = false; ClearAllStats(); }