All pastes #1667933 Raw Edit

Untitled

public c v1 · immutable
#1667933 ·published 2009-11-12 10:40 UTC
rendered paste body
#include <windows.h>#include <winuser.h>#include <stdio.h>#include <string.h>#include <stdarg.h>#include <math.h>#include <malloc.h>#include <sys/types.h>#include <dirent.h>#define USE_CLIPBOARD#define USE_DLL//Table->Info strings#define TBL_NAME        0#define TBL_LIMIT       1#define TBL_TYPE        2#define SEAT_QUERY      0#define SEAT_ADD        1#define SEAT_REMOVE     2//Table commands for FTP_ControlTable()#define CMD_LEAVE       1#define CMD_AUTOPOSTTOGGLE 2#define CMD_CHECKFOLD   3#define CMD_CALL        4#define CMD_RAISE       5#define CMD_SITOUTNEXT  6#define CMD_GETCHIPS    7#define CMD_PLAYHAND    8//Misc configuration#define FTP_STACKSIZE   200           //Auto-topup amount (ie. 20bb for SSS NL)#define FTP_MAXTABLES   18#define FTP_MAXFAIL     10000#define FTP_LOGDIR      "c:\\program files\\full tilt poker\\handhistory\\"#define FTP_LOGBUFFSIZE 8192//Output types for FTP_Print()#define INF_WARN        0#define INF_MISC        1#define INF_UNKNOWN     2#define INF_TABLE       3#define INF_STUFF       4#define INF_DLL         5//Names for parsed dealer messages#define LINE_NEWHAND   1#define LINE_HOLECARDS 2#define LINE_FLOP      3#define LINE_TURN      4#define LINE_RIVER     5#define LINE_RAISE     6#define LINE_CALL      7#define LINE_BET       8#define LINE_CHECK     9#define LINE_FOLD      10#define LINE_SITOUT    11#define LINE_SITDOWN   12#define LINE_STANDUP   13#define LINE_ADDS      14#define LINE_DISCONN   15#define LINE_RECONN    16#define LINE_RETURNED  17#define LINE_WINPOT    18#define LINE_UNCALLED  19#define LINE_POSTBB    20//Table->HandState (preflop = dealt, but before flop, 0 = not dealt)#define HAND_PREFLOP   1#define HAND_FLOP      2#define HAND_TURN      3#define HAND_RIVER     4struct pk_card { int Suit,Rank; };struct hands { int C1[1326], C2[1326], Size; };struct ftp_buttons { HWND CheckFold,Call,Raise,RaiseEdit,DealMeIn; };struct player_info{    int ID;          //'unique' number    char *Name;    int Bets,Calls;  //Counters for each bet/call they make (used for AF calc)    float AF;        //aggression factor    int Playing;     //1=player is in the hand    int Range;       //lowest card rank they have won with};struct table_info{    /* Strings */    int ID;          //our location in the array    char *Me;        //Our full-tilt username    char *Info[4];   //Name,Limit,Gametype,spare (TBL_* defines above)    char *Seats[10]; //strings of all player names at table        /* Control Stuff */    HWND Handle;     //Handle of table window    HWND ChatHandle; //Handle of the chat window    RECT ChatPos;    //Dimensions of the chat control    RECT WinPos;     //Location of each corner of the table window (absolute)    //struct ftp_buttons ControlHandles;  //Handles of the fold/call/raise buttons    char *DealerMsg; //Last line from the dealer chat    FILE *Log;       //The open FD of the table log (if FTP_OpenTableLog() succeeded)    char *LogFile;   //Complete filename of logfile for this table.    char *LogBuffer; //Contains the last dealer message obtained from the table window.    int Decision;    //Set by the logic engine, directly passed to FTP_ControlTable    long TimeStamp;  //timestamp when we executed our last decision    void *Tcl;       //Pointer to this tables' Tcl_Interp.    char *Output;    //Ptr to a Tcl_Alloc()'d buffer for TCL scripts to output info    long LastPixel;  //Used to detect if theres new dealer messages to read    int Timeout;     //If this is 1, clipboard took too long to read last try    HANDLE Thread;   //Our Decide() thread handle    int Busy;        //1=Decide() thread is still running        /* Poker Stuff */    struct pk_card Cards[2]; //Our hole cards    struct pk_card Board[5]; //The table's cards    struct player_info *Player;    int Action;      //Are we playing? (Set to 1 when dealt)    int HandCount;   //++ Each time dealt.    int HandState;   //1=dealt, 2=flop, 3=turn, 4=river    int BB;          //Size of the Big Bet    int Stack;       //Our stack size    int Pot;         //Current pot size    int AutoSitOut;  //If stack surpasses this value, we select 'Sit Out Next Hand'    int RaiseCount;  //Number of raises since last handstate change    int RaiseTotal;  //Bet size to-call since last handstate change    int RaiseAmount; //If Decision is CMD_RAISE, this specifies the amount to raise by.    int Callers;     //Number of calls for this handstate (Raise resets this to 1)    int Players;     //Players in the hand (Decrements per fold)    int PlayerCount; //Players sitting down (TODO: Fix this :/)    int Position;    //POS_EP -> POS_BB, our position at the table.    int NotReady;    //If this is 1, do not play a hand since we dont know all the positions.    int MaxHands;    //If HandCount > MaxHands, click 'Sit Out Next Hand'    int HandScore;   //Result of pEvalHand on our current holecards    int Calls,Bets;  //Overall counters for calls and bets (for the whole table, not us)    char *HandName;  //English name for the current hand rank    char *OpponentRange; //Set by the game logic, this will be the range of pCalcWinPr()    struct hands Range; //used by pCalcWinPr (contains rank integers)    float HandStrength;    float WinPr;     //Calculated at each handstate from flop onwards, this is the                     //probability of our hand winning based on exhaustive search of                     //every possible card combination against <Players-1>.                     //Returns a value between 0.0 and 1.0};//Function pointers for DLL stuff//fn_<ReturnType_<ArgTypes>HMODULE hDLL;typedef void (*fn_void_void)(void);typedef int (*fn_int_void)(void);typedef int (*fn_int_tableinfop)(struct table_info *);typedef void (*fn_void_hwnd)(HWND);//Global variablesstruct table_info *Tables[FTP_MAXTABLES];int ntables, TableLoopCount;char DLL_Filename[256], *lastclip;int copyerrors;int    findBytes(char *b, int bl, char *f, int fl);BOOL   CALLBACK cbFindTableWindow(HWND hwnd, LPARAM lParam);void   MouseClick(int x, int y);void   GetRGB(long col, int *r, int *g, int *b);int    GetCardRankFromChar(char c);int    GetCardSuitFromChar(char c);int    IsFlushDraw(struct table_info *Target);void   FTP_Print(int type, char *fmt, ...);LPVOID FTP_AddChatToTable(struct table_info *Target);int    FTP_AddTable(HWND hwnd);int    FTP_IsInputRequired(struct table_info *Target);int    FTP_ControlTable(struct table_info *Target, int Command);int    FTP_RewriteTableArray();void   FTP_CheckForNewTables();int    FTP_OpenTableLog(struct table_info *Target);int    FTP_ParseDealer(struct table_info *Target, int Type, char *Msg);int    FTP_UpdateTable(struct table_info *Target);int    FTP_UpdateTableLog(struct table_info *Target);int    FTP_SortHoleCards(struct table_info *Target);int    FTP_SortBoard(struct table_info *Target);int    FTP_Decide(struct table_info *Target);void   FTP_Cleanup(struct table_info *Target);