/* send_queued_write() * * inputs - fd to have queue sent, client we're sending to * outputs - contents of queue * side effects - write is rescheduled if queue isnt emptied */ void send_queued(struct Client *to) { int retlen; #ifdef USE_IODEBUG_HOOKS hook_data_int hd; #endif rb_fde_t *F = to->localClient->F; if (!F) return; /* cant write anything to a dead socket. */ if(IsIOError(to)) return; /* Something wants us to not send anything currently */ /* if(IsCork(to)) return; */ /* try to flush later when the write event resets this */ if(IsFlush(to)) return; #ifdef USE_IODEBUG_HOOKS hd.client = to; if(to->localClient->buf_sendq.list.head) hd.arg1 = ((buf_line_t *) to->localClient->buf_sendq.list.head->data)->buf + to->localClient->buf_sendq.writeofs; #endif if(rb_linebuf_len(&to->localClient->buf_sendq)) { while ((retlen = rb_linebuf_flush(F, &to->localClient->buf_sendq)) > 0) { /* We have some data written .. update counters */ #ifdef USE_IODEBUG_HOOKS hd.arg2 = retlen; call_hook(h_iosend_id, &hd); if(to->localClient->buf_sendq.list.head) hd.arg1 = ((buf_line_t *) to->localClient->buf_sendq.list.head-> data)->buf + to->localClient->buf_sendq.writeofs; #endif ClearFlush(to); to->localClient->sendB += retlen; me.localClient->sendB += retlen; if(to->localClient->sendB > 1023) { to->localClient->sendK += (to->localClient->sendB >> 10); to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ } else if(me.localClient->sendB > 1023) { me.localClient->sendK += (me.localClient->sendB >> 10); me.localClient->sendB &= 0x03ff; }
int IsStraightFlush( PHAND pHand, PCARD pWild ) { int val = 0; if( IsFlush( pHand, pWild ) ) if( val = IsStraight( pHand, pWild ) ) { if( (val & 0xFF) == 0xD ) // special case - royal flush. return 0x900000; return ( val & 0xFF ) | 0x800000; } return 0; }
/* * EvaluateType *-------------------------------------------------- * Pre: Type of hand is Unknown * Post: The type of hand is evaluated *-------------------------------------------------- * Evaluates the hand on each hand type available * */ void Hand::EvaluateType(){ if(IsStraight() && IsFlush()){ type = STRAIGHT_FLUSH; }else if (IsN_Of_A_Kind(FOUR, true)){ type = FOUR_OF_A_KIND; }else if ( IsN_Of_A_Kind(THREE, false) && IsPair(PAIR, false, false)){ type = FULL_HOUSE; }else if (IsFlush()){ type = FLUSH; }else if (IsStraight()){ type = STRAIGHT; }else if (IsN_Of_A_Kind(THREE, true)){ type = THREE_OF_A_KIND; }else if (IsPair(PAIR, true, false)){ type = TWO_PAIRS; }else if (IsPair(PAIR, false, false)){ type = ONE_PAIR; }else{ type = HIGH_CARD; } }
int ValuePokerHand( PHAND pHand, PCARD pWild, int bHigh ) { int val; if( !pHand ) return 0; if( bHigh ) { val = Is5Kind( pHand, pWild ); // this is a special straight flush (name only?) // if( !val ) val = IsRoyalFlush( pHand, pWild ); if( !val ) val = IsStraightFlush( pHand, pWild ); if( !val ) val = Is4Kind( pHand, pWild ); if( !val ) val = IsFullHouse( pHand, pWild ); if( !val ) val = IsFlush( pHand, pWild ); if( !val ) val = IsStraight( pHand, pWild ); if( !val ) val = Is3Kind( pHand, pWild ); if( !val ) val = Is2Pair( pHand, pWild ); if( !val ) val = IsPair( pHand, pWild ); if( !val ) val = HighCard( pHand, pWild ); } else { val = HighCard( pHand, pWild ); // this is a special straight flush (name only?) // if( !val ) val = IsRoyalFlush( pHand, pWild ); if( !val ) val = IsStraightFlush( pHand, pWild ); if( !val ) val = Is4Kind( pHand, pWild ); if( !val ) val = IsFullHouse( pHand, pWild ); if( !val ) val = IsFlush( pHand, pWild ); if( !val ) val = IsStraight( pHand, pWild ); if( !val ) val = Is3Kind( pHand, pWild ); if( !val ) val = Is2Pair( pHand, pWild ); if( !val ) val = IsPair( pHand, pWild ); if( !val ) val = Is5Kind( pHand, pWild ); } return val; }
/* send_queued_write() * * inputs - fd to have queue sent, client we're sending to * outputs - contents of queue * side effects - write is rescheduled if queue isnt emptied */ void send_queued(struct Client *to) { int retlen; rb_fde_t *F = to->localClient->F; if (!F) return; /* cant write anything to a dead socket. */ if(IsIOError(to)) return; /* try to flush later when the write event resets this */ if(IsFlush(to)) return; if(rb_linebuf_len(&to->localClient->buf_sendq)) { while ((retlen = rb_linebuf_flush(F, &to->localClient->buf_sendq)) > 0) { /* We have some data written .. update counters */ ClearFlush(to); to->localClient->sendB += retlen; me.localClient->sendB += retlen; if(to->localClient->sendB > 1023) { to->localClient->sendK += (to->localClient->sendB >> 10); to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ } else if(me.localClient->sendB > 1023) { me.localClient->sendK += (me.localClient->sendB >> 10); me.localClient->sendB &= 0x03ff; }
int Evaluator::CompareCues(const CUE& c1, const CUE& c2) { bool f1 = IsFlush(c1); bool f2 = IsFlush(c2); bool st1 = IsStraight(c1); bool st2 = IsStraight(c2); if (f1 && st1) //c1 is a straight flush { if (f2 && st2)//c2 is a straight flush { return CompareStraightFlushes(c1, c2); } return 1; } if (f2 && st2) { return -1; } // neither hand is a straight flush ... next FOUR OF A KIND bool q1 = IsQuad(c1); bool q2 = IsQuad(c2); if (q1) { if (q2) { return CompareQuads(c1, c2); } return 1; //hand 1 is greater } if (q2) { return -1; } bool boat1 = IsBoat(c1); bool boat2 = IsBoat(c2); if (boat1) { if (boat2) { return CompareBoats(c1, c2); } return 1; } if (boat2) { return -1; } bool F1 = IsFlush(c1); bool F2 = IsFlush(c2); if (F1) { if (F1 && F2) { return CompareFlushs(c1, c2); } return 1; } if (F2) { return -1; } bool str1 = IsStraight(c1); bool str2 = IsStraight(c2); if (str1) { if (str2) { return CompareStraights(c1, c2); } return 1; } if (str2) { return -1; } bool trips1 = IsTrips(c1); bool trips2 = IsTrips(c2); if (trips1) { if (trips2) { return CompareTrips(c1, c2); } return 1; } if (trips2) { return -1; } bool twop1 = IsTwoPair(c1); bool twop2 = IsTwoPair(c2); if (twop1) { if (twop2) { return CompareTwoPair(c1, c2); } return 1; } if (twop2) { return -1; } bool onep1 = IsOnePair(c1); bool onep2 = IsOnePair(c2); if (onep1) { if (onep2) { return CompareOnePair(c1, c2); } return 1; } if (onep2) { return -1; } return CompareKickers(c1, c2); //COMPARE HIGH CARD IF NO HANDS };