📄 protocol.h
字号:
int hands_as_east; /* number of hands completed with this dealer */ int firsteast; /* id of player who was east in first hand of game */ int east_score; /* east's score in game */ int south_score; int west_score; int north_score; int protversion; /* protocol version to be used in this game */ int manager; /* id of player owning this game */} CMsgGameMsg;/* Message to say that the wind of the round has changed */typedef struct _CMsgNewRoundMsg { ControllerMsgType type; /* CMsgNewRound */ TileWind round; /* wind of the new round */} CMsgNewRoundMsg;/* Message sent by controller to start new hand. It also tells where the live wall notionally starts; this is completely irrelevant to the actual implementation, but can be used to give players a consistent view of the wall.*/typedef struct _CMsgNewHandMsg { ControllerMsgType type; /* CMsgNewHand */ int east; /* id of east player for this hand: just to check */ int start_wall; /* the wall (as a seat number) in which the live wall starts*/ int start_stack; /* the stack (from right) at which the live wall starts */} CMsgNewHandMsg;/* Message sent by controller to draw one tile for player. Other players will receive this message with a blank tile.*/typedef struct _CMsgPlayerDrawsMsg { ControllerMsgType type; /* CMsgPlayerDraws */ int id; /* player drawing tile */ Tile tile; /* tile drawn (HiddenTile if not known to us) */} CMsgPlayerDrawsMsg;/* Message sent by controller to draw a loose tile for player. Other players will receive this message with a blank tile.*/typedef struct _CMsgPlayerDrawsLooseMsg { ControllerMsgType type; /* CMsgPlayerDrawsLoose */ int id; /* player drawing tile */ Tile tile; /* tile drawn (HiddenTile if not known to us) */} CMsgPlayerDrawsLooseMsg;/* Message sent by the player to declare a special tile. If the tile is blank, player has no more specials. (Of course, the controller knows this anyway.) This message is also used during play.*/typedef struct _PMsgDeclareSpecialMsg { /* alias ds */ PlayerMsgType type; /* PMsgDeclareSpecial */ Tile tile; /* tile being declared, or blank */} PMsgDeclareSpecialMsg;/* Message sent by controller to implement special declaration. */typedef struct _CMsgPlayerDeclaresSpecialMsg { ControllerMsgType type; /* CMsgPlayerDeclaresSpecial */ int id; /* player making declaration */ Tile tile; /* tile being declared (blank if player finished) */} CMsgPlayerDeclaresSpecialMsg;/* This message is sent to all players, to tell them they may start normal play. This happens either when a game starts, or to restart a game that was suspended. */typedef struct _CMsgStartPlayMsg { ControllerMsgType type; /* CMsgStartPlay */ int id; /* not strictly necessary: id of player due to do something */} CMsgStartPlayMsg;/* This message is sent to all players to stop play. This may be (for example) because a player has lost its connection.*/typedef struct _CMsgStopPlayMsg { ControllerMsgType type; /* CMsgStopPlay */ char *reason; /* human readable explanation */} CMsgStopPlayMsg;/* This message is sent by a player to request a pause in play. If granted, all players (including the pausing player) must give permission to continue again. */typedef struct _PMsgRequestPauseMsg { PlayerMsgType type; /* PMsgRequestPause */ char *reason; /* reason for pause; will be passed to other players */} PMsgRequestPauseMsg;/* This message is sent by the controller when it wishes to gain the permission of players to proceed. This happens typically at: the end of declaring specials, before play proper starts; at the end of a hand, before proceeding to the next hand. */typedef struct _CMsgPauseMsg { ControllerMsgType type; /* CMsgPause */ int exempt; /* 0, or the id of the one player who is NOT being asked to confirm readiness (typically because it's them to proceed) */ int requestor; /* 0, or id of player who requested pause */ char *reason; /* reason for pause. This will (it happens) be phrased as an infinitive, e.g. "to start play" */} CMsgPauseMsg;/* and this is the reply */typedef struct _PMsgReadyMsg { PlayerMsgType type; /* PMsgReady */} PMsgReadyMsg;/* and this tells other players who's ready (and bloody emacs gets confused by that quote, so here's another) */typedef struct _CMsgPlayerReadyMsg { ControllerMsgType type; /* CMsgPlayerReady */ int id;} CMsgPlayerReadyMsg;/* Message sent by player to announce discard */typedef struct _PMsgDiscardMsg { /* alias d */ PlayerMsgType type; /* PMsgDiscard */ Tile tile; /* tile to be discarded */ bool calling; /* player is making a Calling declaration */} PMsgDiscardMsg;/* Message sent by controller to implement discard */typedef struct _CMsgPlayerDiscardsMsg { ControllerMsgType type; /* CMsgPlayerDiscards */ int id; /* player discarding */ Tile tile; /* tile being discarded */ int discard; /* a serial number for this discard */ bool calling; /* player is making a Calling declaration */} CMsgPlayerDiscardsMsg;/* This message is sent by a player to say that it has no claim on the current discard. It implies a request to draw a tile if it's the player's turn.*/typedef struct _PMsgNoClaimMsg { /* alias n */ PlayerMsgType type; /* PMsgNoClaim */ int discard; /* serial number of discard */} PMsgNoClaimMsg;/* Message sent by controller to say that a player is making no claim on the current discard. Usually this is sent only to the player concerned.*/typedef struct _CMsgPlayerDoesntClaimMsg { ControllerMsgType type; /* CMsgPlayerDoesntClaim */ int id; /* player */ int discard; /* current discard serial */ bool timeout; /* 1 if this is generated by timeout in controller */} CMsgPlayerDoesntClaimMsg;/* This message is informational, and is sent by the controller after a claim has been implemented to announce that the discard was dangerous.*/typedef struct _CMsgDangerousDiscardMsg { ControllerMsgType type; /* CMsgDangerousDiscard */ int id; /* player who discarded */ int discard; /* serial number of the dangerous discard */ bool nochoice; /* discard was dangerous, but discarder had no choice */} CMsgDangerousDiscardMsg;/* Message sent by player to claim a pung. In the usual rules, it is possible to claim a pung up to the time the *next* tile is discarded. At the moment, we don't implement that, but we should in due course. Hence a pung (etc.) claim includes an integer identifying the discard that is being claimed---the integer was assigned by the controller. This provides some protection against delays.*/typedef struct _PMsgPungMsg { /* alias p */ PlayerMsgType type; /* PMsgPung */ int discard; /* id of discard being claimed */} PMsgPungMsg;/* Message sent by controller to other players to inform them of a pung claim (NOT of its success).*/typedef struct _CMsgPlayerClaimsPungMsg { ControllerMsgType type; /* CMsgPlayerClaimsPung */ int id; /* player claiming */ int discard; /* discard being claimed */} CMsgPlayerClaimsPungMsg;/* generic refusal message sent by controller to deny a claim. */typedef struct _CMsgClaimDeniedMsg { ControllerMsgType type; /* CMsgClaimDenied */ int id; /* player who made claim */ char *reason; /* if non-NULL, human readable explanation */} CMsgClaimDeniedMsg;/* Message sent by controller to implement a successful pung claim. */typedef struct _CMsgPlayerPungsMsg { ControllerMsgType type; /* CMsgPlayerPungs */ int id; /* player who made claim */ Tile tile; /* tile of pung---redundant, but included for safety */} CMsgPlayerPungsMsg;/* Message to declare a closed pung during scoring */typedef struct _PMsgFormClosedPungMsg { PlayerMsgType type; /* PMsgFormClosedPung */ Tile tile;} PMsgFormClosedPungMsg;typedef struct _CMsgPlayerFormsClosedPungMsg { ControllerMsgType type; /* CMsgPlayerFormsClosedPung */ int id; Tile tile;} CMsgPlayerFormsClosedPungMsg;/* now the same for kongs */typedef struct _PMsgKongMsg { /* alias k */ PlayerMsgType type; /* PMsgKong */ int discard; /* id of discard being claimed */} PMsgKongMsg;/* Message sent by controller to other players to inform them of a pung claim (NOT of its success).*/typedef struct _CMsgPlayerClaimsKongMsg { ControllerMsgType type; /* CMsgPlayerClaimsKong */ int id; /* player claiming */ int discard; /* discard being claimed */} CMsgPlayerClaimsKongMsg;/* the generic refusal message applies *//* Message sent by controller to implement a successful pung claim. */typedef struct _CMsgPlayerKongsMsg { ControllerMsgType type; /* CMsgPlayerKongs */ int id; /* player who made claim */ Tile tile; /* tile of kong---redundant, but included for safety */} CMsgPlayerKongsMsg;/* Message sent by player to announce a concealed kong. */typedef struct _PMsgDeclareClosedKongMsg { /* alias ck */ PlayerMsgType type; /* PMsgDeclareClosedKong */ Tile tile; /* which kong */} PMsgDeclareClosedKongMsg;/* Message sent by controller to implement a concealed kong Because the kong may possibly be robbed, it gets a discard serial number. */typedef struct _CMsgPlayerDeclaresClosedKongMsg { ControllerMsgType type; /* CMsgPlayerDeclaresClosedKong */ int id; /* player declaring kong */ Tile tile; /* tile being konged */ int discard; /* serial */} CMsgPlayerDeclaresClosedKongMsg;/* Message sent by player to add drawn tile to exposed pung */typedef struct _PMsgAddToPungMsg { PlayerMsgType type; /* PMsgAddToPung */ Tile tile; /* which pung */} PMsgAddToPungMsg;/* Message sent by controller to implement adding to a pung Because the kong may possibly be robbed, it gets a discard serial number. */typedef struct _CMsgPlayerAddsToPungMsg { ControllerMsgType type; /* CMsgPlayerAddsToPung */ int id; /* player */ Tile tile; /* the tile being added */ int discard; /* serial */} CMsgPlayerAddsToPungMsg;/* Message sent by controller to say that the player has robbed the just declared kong */typedef struct _CMsgPlayerRobsKongMsg { ControllerMsgType type; /* CMsgPlayerRobsKong */ int id; /* player */ Tile tile; /* tile being robbed (redundant) */} CMsgPlayerRobsKongMsg;/* Message sent by player to ask whether it has a mah-jong hand. Needed because only the server knows fully what hands are allowed: the client code might be an earlier version. */typedef struct _PMsgQueryMahJongMsg { PlayerMsgType type; /* PMsgQueryMahJong */ Tile tile; /* do I have mahjong with this tile added? HiddenTile means no tile */} PMsgQueryMahJongMsg;/* And the reply */typedef struct _CMsgCanMahJongMsg { ControllerMsgType type; /* CMsgCanMahJong */ Tile tile; /* the tile specified */ bool answer; /* yes or no */} CMsgCanMahJongMsg;/* Message sent by player to claim chow. The player should specify where the chowed tile will go (i.e. lower, upper, middle). However, for added realism, it is permissible to specify "any" (AnyPos) for the position. If this is done, and the chow claim is successful, then the controller will send to the chowing player (and only to the chowing player) a PlayerChows message with the cpos set to AnyPos. The player must then send another Chow message with the position specified.*/typedef struct _PMsgChowMsg { /* alias c */ PlayerMsgType type; /* PMsgChow */ int discard; /* discard being claimed */ ChowPosition cpos; /* where the discard will go */} PMsgChowMsg;/* Message sent by controller to announce a chow claim */typedef struct _CMsgPlayerClaimsChowMsg { ControllerMsgType type; /* CMsgPlayerClaimsChow */ int id; /* player claiming */ int discard; /* discard being claimed */ ChowPosition cpos; /* chowposition specified (may be AnyPos) */} CMsgPlayerClaimsChowMsg;/* the general refusal message applies *//* Message sent by controller to implement a chow claim. See above for meaning of this message with cpos == AnyPos. */typedef struct _CMsgPlayerChowsMsg { ControllerMsgType type; /* CMsgPlayerChows */ int id; /* player claiming */ Tile tile; /* tile being claimed (redundant, but...) */ ChowPosition cpos; /* position of claimed tile in chow */} CMsgPlayerChowsMsg;/* To form a closed chow during scoring. As all tiles are in hand, we require that the chow is specified by the lower tile.*/typedef struct _PMsgFormClosedChowMsg { PlayerMsgType type; /* PMsgFormClosedChow */ Tile tile;} PMsgFormClosedChowMsg;typedef struct _CMsgPlayerFormsClosedChowMsg { ControllerMsgType type; /* CMsgPlayerFormsClosedChow */ int id; Tile tile;} CMsgPlayerFormsClosedChowMsg;/* some rules allow a player to declare a washout under certain circumstances.*/typedef struct _PMsgDeclareWashOutMsg { PlayerMsgType type; /* PMsgDeclareWashOut */} PMsgDeclareWashOutMsg;/* Message sent by controller to declare a dead hand */typedef struct _CMsgWashOutMsg { ControllerMsgType type; /* CMsgWashOut */ char *reason; /* reason for washout */} CMsgWashOutMsg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -