From edde9137ae6cace0bc94ff496ba850723b472d48 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 13 Nov 2011 15:31:35 +0000 Subject: [PATCH] CardsValue is now optionally sent by the server. --- docs/pokerth.asn1 | 2 +- src/net/common/clientstate.cpp | 8 ++++++-- src/net/common/servergamestate.cpp | 3 ++- src/third_party/asn1/PlayerResult.c | 24 ++++++++++++------------ src/third_party/asn1/PlayerResult.h | 4 ++-- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/docs/pokerth.asn1 b/docs/pokerth.asn1 index f216bb1b..00a61f53 100644 --- a/docs/pokerth.asn1 +++ b/docs/pokerth.asn1 @@ -574,7 +574,7 @@ PlayerResult ::= SEQUENCE { resultCard1 Card, resultCard2 Card, bestHandPosition SEQUENCE SIZE(5) OF INTEGER, -- TODO size restrictions - cardsValue INTEGER, + cardsValue INTEGER OPTIONAL, moneyWon AmountOfMoney, playerMoney AmountOfMoney } diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index baefc18d..3147292b 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -1676,7 +1676,9 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr client tmpPlayer->setMyCards(tmpCards); for (int num = 0; num < 5; num++) bestHandPos[num] = *r->bestHandPosition.list.array[num]; - tmpPlayer->setMyCardsValueInt(r->cardsValue); + if (r->cardsValue) { + tmpPlayer->setMyCardsValueInt(*r->cardsValue); + } tmpPlayer->setMyBestHandPosition(bestHandPos); tmpPlayer->setMyCash(r->playerMoney); tmpPlayer->setLastMoneyWon(r->moneyWon); @@ -1984,7 +1986,9 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr client, tmpPlayer->setMyCards(tmpCards); for (int num = 0; num < 5; num++) bestHandPos[num] = *r->bestHandPosition.list.array[num]; - tmpPlayer->setMyCardsValueInt(r->cardsValue); + if (r->cardsValue) { + tmpPlayer->setMyCardsValueInt(*r->cardsValue); + } tmpPlayer->setMyBestHandPosition(bestHandPos); if (tmpPlayer->getMyCardsValueInt() > highestValueOfCards) highestValueOfCards = tmpPlayer->getMyCardsValueInt(); diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 90807f42..636af96c 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -199,7 +199,8 @@ SetPlayerResult(PlayerResult_t &playerResult, boost::shared_ptr ASN_SEQUENCE_ADD(&playerResult.bestHandPosition.list, handPos); } - playerResult.cardsValue = tmpPlayer->getMyCardsValueInt(); + playerResult.cardsValue = (long *)calloc(1, sizeof(long)); + *playerResult.cardsValue = tmpPlayer->getMyCardsValueInt(); playerResult.moneyWon = tmpPlayer->getLastMoneyWon(); playerResult.playerMoney = tmpPlayer->getMyCash(); } diff --git a/src/third_party/asn1/PlayerResult.c b/src/third_party/asn1/PlayerResult.c index 6c117243..39de1824 100644 --- a/src/third_party/asn1/PlayerResult.c +++ b/src/third_party/asn1/PlayerResult.c @@ -114,15 +114,6 @@ static asn_TYPE_member_t asn_MBR_PlayerResult_1[] = { 0, "bestHandPosition" }, - { ATF_NOFLAGS, 0, offsetof(struct PlayerResult, cardsValue), - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), - 0, - &asn_DEF_NativeInteger, - 0, /* Defer constraints checking to the member type */ - 0, /* PER is not compiled, use -gen-PER */ - 0, - "cardsValue" - }, { ATF_NOFLAGS, 0, offsetof(struct PlayerResult, moneyWon), (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, @@ -141,6 +132,15 @@ static asn_TYPE_member_t asn_MBR_PlayerResult_1[] = { 0, "playerMoney" }, + { ATF_POINTER, 1, offsetof(struct PlayerResult, cardsValue), + (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + 0, + &asn_DEF_NativeInteger, + 0, /* Defer constraints checking to the member type */ + 0, /* PER is not compiled, use -gen-PER */ + 0, + "cardsValue" + }, }; static ber_tlv_tag_t asn_DEF_PlayerResult_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) @@ -149,9 +149,9 @@ static asn_TYPE_tag2member_t asn_MAP_PlayerResult_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 5 }, /* playerId at 573 */ { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, -1, 4 }, /* resultCard1 at 574 */ { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 2, -2, 3 }, /* resultCard2 at 575 */ - { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 4, -3, 2 }, /* cardsValue at 577 */ - { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 5, -4, 1 }, /* moneyWon at 578 */ - { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 6, -5, 0 }, /* playerMoney at 580 */ + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 4, -3, 2 }, /* moneyWon at 577 */ + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 5, -4, 1 }, /* playerMoney at 578 */ + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 6, -5, 0 }, /* cardsValue at 579 */ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 3, 0, 0 } /* bestHandPosition at 576 */ }; static asn_SEQUENCE_specifics_t asn_SPC_PlayerResult_specs_1 = { diff --git a/src/third_party/asn1/PlayerResult.h b/src/third_party/asn1/PlayerResult.h index b68fa404..e8a97a85 100644 --- a/src/third_party/asn1/PlayerResult.h +++ b/src/third_party/asn1/PlayerResult.h @@ -14,8 +14,8 @@ /* Including external dependencies */ #include "NonZeroId.h" #include "Card.h" -#include #include "AmountOfMoney.h" +#include #include #include #include @@ -35,9 +35,9 @@ extern "C" { /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; } bestHandPosition; - long cardsValue; AmountOfMoney_t moneyWon; AmountOfMoney_t playerMoney; + long *cardsValue /* OPTIONAL */; /* * This type is extensible, * possible extensions are below.