File: protocol-enums.c

package info (click to toggle)
mah-jong 1.8-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,384 kB
  • ctags: 2,186
  • sloc: ansic: 26,312; perl: 393; makefile: 272; sh: 122
file content (256 lines) | stat: -rw-r--r-- 13,814 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
char *protocol_print_GameOption(const GameOption t) {
  if ( t == GOUnknown ) return "Unknown";
  if ( t == GOTimeout ) return "Timeout";
  if ( t == GOTimeoutGrace ) return "TimeoutGrace";
  if ( t == GOScoreLimit ) return "ScoreLimit";
  if ( t == GONoLimit ) return "NoLimit";
  if ( t == GOMahJongScore ) return "MahJongScore";
  if ( t == GOSevenPairs ) return "SevenPairs";
  if ( t == GOSevenPairsVal ) return "SevenPairsVal";
  if ( t == GOFlowers ) return "Flowers";
  if ( t == GOFlowersLoose ) return "FlowersLoose";
  if ( t == GOFlowersOwnEach ) return "FlowersOwnEach";
  if ( t == GOFlowersOwnBoth ) return "FlowersOwnBoth";
  if ( t == GOFlowersBouquet ) return "FlowersBouquet";
  if ( t == GODeadWall ) return "DeadWall";
  if ( t == GODeadWall16 ) return "DeadWall16";
  if ( t == GOConcealedFully ) return "ConcealedFully";
  if ( t == GOConcealedAlmost ) return "ConcealedAlmost";
  if ( t == GOLosersPurity ) return "LosersPurity";
  if ( t == GOKongHas3Types ) return "KongHas3Types";
  if ( t == GOEastDoubles ) return "EastDoubles";
  if ( t == GOLosersSettle ) return "LosersSettle";
  if ( t == GODiscDoubles ) return "DiscDoubles";
  if ( t == GOShowOnWashout ) return "ShowOnWashout";
  if ( t == GOEnd ) return "End";
  return (char *)0;
}

GameOption protocol_scan_GameOption(const char *s) {
  if ( strcmp(s,"Unknown") == 0 ) return GOUnknown;
  if ( strcmp(s,"Timeout") == 0 ) return GOTimeout;
  if ( strcmp(s,"TimeoutGrace") == 0 ) return GOTimeoutGrace;
  if ( strcmp(s,"ScoreLimit") == 0 ) return GOScoreLimit;
  if ( strcmp(s,"NoLimit") == 0 ) return GONoLimit;
  if ( strcmp(s,"MahJongScore") == 0 ) return GOMahJongScore;
  if ( strcmp(s,"SevenPairs") == 0 ) return GOSevenPairs;
  if ( strcmp(s,"SevenPairsVal") == 0 ) return GOSevenPairsVal;
  if ( strcmp(s,"Flowers") == 0 ) return GOFlowers;
  if ( strcmp(s,"FlowersLoose") == 0 ) return GOFlowersLoose;
  if ( strcmp(s,"FlowersOwnEach") == 0 ) return GOFlowersOwnEach;
  if ( strcmp(s,"FlowersOwnBoth") == 0 ) return GOFlowersOwnBoth;
  if ( strcmp(s,"FlowersBouquet") == 0 ) return GOFlowersBouquet;
  if ( strcmp(s,"DeadWall") == 0 ) return GODeadWall;
  if ( strcmp(s,"DeadWall16") == 0 ) return GODeadWall16;
  if ( strcmp(s,"ConcealedFully") == 0 ) return GOConcealedFully;
  if ( strcmp(s,"ConcealedAlmost") == 0 ) return GOConcealedAlmost;
  if ( strcmp(s,"LosersPurity") == 0 ) return GOLosersPurity;
  if ( strcmp(s,"KongHas3Types") == 0 ) return GOKongHas3Types;
  if ( strcmp(s,"EastDoubles") == 0 ) return GOEastDoubles;
  if ( strcmp(s,"LosersSettle") == 0 ) return GOLosersSettle;
  if ( strcmp(s,"DiscDoubles") == 0 ) return GODiscDoubles;
  if ( strcmp(s,"ShowOnWashout") == 0 ) return GOShowOnWashout;
  if ( strcmp(s,"End") == 0 ) return GOEnd;
  return -1;
}


char *protocol_print_GameOptionType(const GameOptionType t) {
  if ( t == GOTBool ) return "bool";
  if ( t == GOTInt ) return "int";
  if ( t == GOTNat ) return "nat";
  if ( t == GOTScore ) return "score";
  if ( t == GOTString ) return "string";
  return (char *)0;
}

GameOptionType protocol_scan_GameOptionType(const char *s) {
  if ( strcmp(s,"bool") == 0 ) return GOTBool;
  if ( strcmp(s,"int") == 0 ) return GOTInt;
  if ( strcmp(s,"nat") == 0 ) return GOTNat;
  if ( strcmp(s,"score") == 0 ) return GOTScore;
  if ( strcmp(s,"string") == 0 ) return GOTString;
  return -1;
}


char *protocol_print_ControllerMsgType(const ControllerMsgType t) {
  if ( t == CMsgError ) return "CMsgError";
  if ( t == CMsgInfoTiles ) return "CMsgInfoTiles";
  if ( t == CMsgStateSaved ) return "CMsgStateSaved";
  if ( t == CMsgConnectReply ) return "CMsgConnectReply";
  if ( t == CMsgReconnect ) return "CMsgReconnect";
  if ( t == CMsgPlayer ) return "CMsgPlayer";
  if ( t == CMsgNewRound ) return "CMsgNewRound";
  if ( t == CMsgGame ) return "CMsgGame";
  if ( t == CMsgNewHand ) return "CMsgNewHand";
  if ( t == CMsgPlayerDeclaresSpecial ) return "CMsgPlayerDeclaresSpecial";
  if ( t == CMsgStartPlay ) return "CMsgStartPlay";
  if ( t == CMsgStopPlay ) return "CMsgStopPlay";
  if ( t == CMsgPause ) return "CMsgPause";
  if ( t == CMsgPlayerReady ) return "CMsgPlayerReady";
  if ( t == CMsgPlayerDraws ) return "CMsgPlayerDraws";
  if ( t == CMsgPlayerDrawsLoose ) return "CMsgPlayerDrawsLoose";
  if ( t == CMsgPlayerDiscards ) return "CMsgPlayerDiscards";
  if ( t == CMsgClaimDenied ) return "CMsgClaimDenied";
  if ( t == CMsgPlayerDoesntClaim ) return "CMsgPlayerDoesntClaim";
  if ( t == CMsgDangerousDiscard ) return "CMsgDangerousDiscard";
  if ( t == CMsgPlayerClaimsPung ) return "CMsgPlayerClaimsPung";
  if ( t == CMsgPlayerPungs ) return "CMsgPlayerPungs";
  if ( t == CMsgPlayerFormsClosedPung ) return "CMsgPlayerFormsClosedPung";
  if ( t == CMsgPlayerClaimsKong ) return "CMsgPlayerClaimsKong";
  if ( t == CMsgPlayerKongs ) return "CMsgPlayerKongs";
  if ( t == CMsgPlayerDeclaresClosedKong ) return "CMsgPlayerDeclaresClosedKong";
  if ( t == CMsgPlayerAddsToPung ) return "CMsgPlayerAddsToPung";
  if ( t == CMsgPlayerRobsKong ) return "CMsgPlayerRobsKong";
  if ( t == CMsgCanMahJong ) return "CMsgCanMahJong";
  if ( t == CMsgPlayerClaimsChow ) return "CMsgPlayerClaimsChow";
  if ( t == CMsgPlayerChows ) return "CMsgPlayerChows";
  if ( t == CMsgPlayerFormsClosedChow ) return "CMsgPlayerFormsClosedChow";
  if ( t == CMsgWashOut ) return "CMsgWashOut";
  if ( t == CMsgPlayerClaimsMahJong ) return "CMsgPlayerClaimsMahJong";
  if ( t == CMsgPlayerMahJongs ) return "CMsgPlayerMahJongs";
  if ( t == CMsgPlayerPairs ) return "CMsgPlayerPairs";
  if ( t == CMsgPlayerFormsClosedPair ) return "CMsgPlayerFormsClosedPair";
  if ( t == CMsgPlayerShowsTiles ) return "CMsgPlayerShowsTiles";
  if ( t == CMsgPlayerSpecialSet ) return "CMsgPlayerSpecialSet";
  if ( t == CMsgPlayerFormsClosedSpecialSet ) return "CMsgPlayerFormsClosedSpecialSet";
  if ( t == CMsgPlayerOptionSet ) return "CMsgPlayerOptionSet";
  if ( t == CMsgHandScore ) return "CMsgHandScore";
  if ( t == CMsgSettlement ) return "CMsgSettlement";
  if ( t == CMsgGameOver ) return "CMsgGameOver";
  if ( t == CMsgGameOption ) return "CMsgGameOption";
  if ( t == CMsgChangeManager ) return "CMsgChangeManager";
  if ( t == CMsgMessage ) return "CMsgMessage";
  if ( t == CMsgWall ) return "CMsgWall";
  if ( t == CMsgComment ) return "CMsgComment";
  if ( t == CMsgSwapTile ) return "CMsgSwapTile";
  return (char *)0;
}

ControllerMsgType protocol_scan_ControllerMsgType(const char *s) {
  if ( strcmp(s,"CMsgError") == 0 ) return CMsgError;
  if ( strcmp(s,"CMsgInfoTiles") == 0 ) return CMsgInfoTiles;
  if ( strcmp(s,"CMsgStateSaved") == 0 ) return CMsgStateSaved;
  if ( strcmp(s,"CMsgConnectReply") == 0 ) return CMsgConnectReply;
  if ( strcmp(s,"CMsgReconnect") == 0 ) return CMsgReconnect;
  if ( strcmp(s,"CMsgPlayer") == 0 ) return CMsgPlayer;
  if ( strcmp(s,"CMsgNewRound") == 0 ) return CMsgNewRound;
  if ( strcmp(s,"CMsgGame") == 0 ) return CMsgGame;
  if ( strcmp(s,"CMsgNewHand") == 0 ) return CMsgNewHand;
  if ( strcmp(s,"CMsgPlayerDeclaresSpecial") == 0 ) return CMsgPlayerDeclaresSpecial;
  if ( strcmp(s,"CMsgStartPlay") == 0 ) return CMsgStartPlay;
  if ( strcmp(s,"CMsgStopPlay") == 0 ) return CMsgStopPlay;
  if ( strcmp(s,"CMsgPause") == 0 ) return CMsgPause;
  if ( strcmp(s,"CMsgPlayerReady") == 0 ) return CMsgPlayerReady;
  if ( strcmp(s,"CMsgPlayerDraws") == 0 ) return CMsgPlayerDraws;
  if ( strcmp(s,"CMsgPlayerDrawsLoose") == 0 ) return CMsgPlayerDrawsLoose;
  if ( strcmp(s,"CMsgPlayerDiscards") == 0 ) return CMsgPlayerDiscards;
  if ( strcmp(s,"CMsgClaimDenied") == 0 ) return CMsgClaimDenied;
  if ( strcmp(s,"CMsgPlayerDoesntClaim") == 0 ) return CMsgPlayerDoesntClaim;
  if ( strcmp(s,"CMsgDangerousDiscard") == 0 ) return CMsgDangerousDiscard;
  if ( strcmp(s,"CMsgPlayerClaimsPung") == 0 ) return CMsgPlayerClaimsPung;
  if ( strcmp(s,"CMsgPlayerPungs") == 0 ) return CMsgPlayerPungs;
  if ( strcmp(s,"CMsgPlayerFormsClosedPung") == 0 ) return CMsgPlayerFormsClosedPung;
  if ( strcmp(s,"CMsgPlayerClaimsKong") == 0 ) return CMsgPlayerClaimsKong;
  if ( strcmp(s,"CMsgPlayerKongs") == 0 ) return CMsgPlayerKongs;
  if ( strcmp(s,"CMsgPlayerDeclaresClosedKong") == 0 ) return CMsgPlayerDeclaresClosedKong;
  if ( strcmp(s,"CMsgPlayerAddsToPung") == 0 ) return CMsgPlayerAddsToPung;
  if ( strcmp(s,"CMsgPlayerRobsKong") == 0 ) return CMsgPlayerRobsKong;
  if ( strcmp(s,"CMsgCanMahJong") == 0 ) return CMsgCanMahJong;
  if ( strcmp(s,"CMsgPlayerClaimsChow") == 0 ) return CMsgPlayerClaimsChow;
  if ( strcmp(s,"CMsgPlayerChows") == 0 ) return CMsgPlayerChows;
  if ( strcmp(s,"CMsgPlayerFormsClosedChow") == 0 ) return CMsgPlayerFormsClosedChow;
  if ( strcmp(s,"CMsgWashOut") == 0 ) return CMsgWashOut;
  if ( strcmp(s,"CMsgPlayerClaimsMahJong") == 0 ) return CMsgPlayerClaimsMahJong;
  if ( strcmp(s,"CMsgPlayerMahJongs") == 0 ) return CMsgPlayerMahJongs;
  if ( strcmp(s,"CMsgPlayerPairs") == 0 ) return CMsgPlayerPairs;
  if ( strcmp(s,"CMsgPlayerFormsClosedPair") == 0 ) return CMsgPlayerFormsClosedPair;
  if ( strcmp(s,"CMsgPlayerShowsTiles") == 0 ) return CMsgPlayerShowsTiles;
  if ( strcmp(s,"CMsgPlayerSpecialSet") == 0 ) return CMsgPlayerSpecialSet;
  if ( strcmp(s,"CMsgPlayerFormsClosedSpecialSet") == 0 ) return CMsgPlayerFormsClosedSpecialSet;
  if ( strcmp(s,"CMsgPlayerOptionSet") == 0 ) return CMsgPlayerOptionSet;
  if ( strcmp(s,"CMsgHandScore") == 0 ) return CMsgHandScore;
  if ( strcmp(s,"CMsgSettlement") == 0 ) return CMsgSettlement;
  if ( strcmp(s,"CMsgGameOver") == 0 ) return CMsgGameOver;
  if ( strcmp(s,"CMsgGameOption") == 0 ) return CMsgGameOption;
  if ( strcmp(s,"CMsgChangeManager") == 0 ) return CMsgChangeManager;
  if ( strcmp(s,"CMsgMessage") == 0 ) return CMsgMessage;
  if ( strcmp(s,"CMsgWall") == 0 ) return CMsgWall;
  if ( strcmp(s,"CMsgComment") == 0 ) return CMsgComment;
  if ( strcmp(s,"CMsgSwapTile") == 0 ) return CMsgSwapTile;
  return -1;
}


char *protocol_print_PlayerMsgType(const PlayerMsgType t) {
  if ( t == PMsgSaveState ) return "PMsgSaveState";
  if ( t == PMsgLoadState ) return "PMsgLoadState";
  if ( t == PMsgConnect ) return "PMsgConnect";
  if ( t == PMsgRequestReconnect ) return "PMsgRequestReconnect";
  if ( t == PMsgDeclareSpecial ) return "PMsgDeclareSpecial";
  if ( t == PMsgRequestPause ) return "PMsgRequestPause";
  if ( t == PMsgReady ) return "PMsgReady";
  if ( t == PMsgDiscard ) return "PMsgDiscard";
  if ( t == PMsgNoClaim ) return "PMsgNoClaim";
  if ( t == PMsgPung ) return "PMsgPung";
  if ( t == PMsgFormClosedPung ) return "PMsgFormClosedPung";
  if ( t == PMsgKong ) return "PMsgKong";
  if ( t == PMsgDeclareClosedKong ) return "PMsgDeclareClosedKong";
  if ( t == PMsgAddToPung ) return "PMsgAddToPung";
  if ( t == PMsgQueryMahJong ) return "PMsgQueryMahJong";
  if ( t == PMsgChow ) return "PMsgChow";
  if ( t == PMsgFormClosedChow ) return "PMsgFormClosedChow";
  if ( t == PMsgDeclareWashOut ) return "PMsgDeclareWashOut";
  if ( t == PMsgMahJong ) return "PMsgMahJong";
  if ( t == PMsgPair ) return "PMsgPair";
  if ( t == PMsgFormClosedPair ) return "PMsgFormClosedPair";
  if ( t == PMsgShowTiles ) return "PMsgShowTiles";
  if ( t == PMsgSpecialSet ) return "PMsgSpecialSet";
  if ( t == PMsgFormClosedSpecialSet ) return "PMsgFormClosedSpecialSet";
  if ( t == PMsgSetPlayerOption ) return "PMsgSetPlayerOption";
  if ( t == PMsgSetGameOption ) return "PMsgSetGameOption";
  if ( t == PMsgQueryGameOption ) return "PMsgQueryGameOption";
  if ( t == PMsgListGameOptions ) return "PMsgListGameOptions";
  if ( t == PMsgChangeManager ) return "PMsgChangeManager";
  if ( t == PMsgSendMessage ) return "PMsgSendMessage";
  if ( t == PMsgSwapTile ) return "PMsgSwapTile";
  return (char *)0;
}

PlayerMsgType protocol_scan_PlayerMsgType(const char *s) {
  if ( strcmp(s,"PMsgSaveState") == 0 ) return PMsgSaveState;
  if ( strcmp(s,"PMsgLoadState") == 0 ) return PMsgLoadState;
  if ( strcmp(s,"PMsgConnect") == 0 ) return PMsgConnect;
  if ( strcmp(s,"PMsgRequestReconnect") == 0 ) return PMsgRequestReconnect;
  if ( strcmp(s,"PMsgDeclareSpecial") == 0 ) return PMsgDeclareSpecial;
  if ( strcmp(s,"PMsgRequestPause") == 0 ) return PMsgRequestPause;
  if ( strcmp(s,"PMsgReady") == 0 ) return PMsgReady;
  if ( strcmp(s,"PMsgDiscard") == 0 ) return PMsgDiscard;
  if ( strcmp(s,"PMsgNoClaim") == 0 ) return PMsgNoClaim;
  if ( strcmp(s,"PMsgPung") == 0 ) return PMsgPung;
  if ( strcmp(s,"PMsgFormClosedPung") == 0 ) return PMsgFormClosedPung;
  if ( strcmp(s,"PMsgKong") == 0 ) return PMsgKong;
  if ( strcmp(s,"PMsgDeclareClosedKong") == 0 ) return PMsgDeclareClosedKong;
  if ( strcmp(s,"PMsgAddToPung") == 0 ) return PMsgAddToPung;
  if ( strcmp(s,"PMsgQueryMahJong") == 0 ) return PMsgQueryMahJong;
  if ( strcmp(s,"PMsgChow") == 0 ) return PMsgChow;
  if ( strcmp(s,"PMsgFormClosedChow") == 0 ) return PMsgFormClosedChow;
  if ( strcmp(s,"PMsgDeclareWashOut") == 0 ) return PMsgDeclareWashOut;
  if ( strcmp(s,"PMsgMahJong") == 0 ) return PMsgMahJong;
  if ( strcmp(s,"PMsgPair") == 0 ) return PMsgPair;
  if ( strcmp(s,"PMsgFormClosedPair") == 0 ) return PMsgFormClosedPair;
  if ( strcmp(s,"PMsgShowTiles") == 0 ) return PMsgShowTiles;
  if ( strcmp(s,"PMsgSpecialSet") == 0 ) return PMsgSpecialSet;
  if ( strcmp(s,"PMsgFormClosedSpecialSet") == 0 ) return PMsgFormClosedSpecialSet;
  if ( strcmp(s,"PMsgSetPlayerOption") == 0 ) return PMsgSetPlayerOption;
  if ( strcmp(s,"PMsgSetGameOption") == 0 ) return PMsgSetGameOption;
  if ( strcmp(s,"PMsgQueryGameOption") == 0 ) return PMsgQueryGameOption;
  if ( strcmp(s,"PMsgListGameOptions") == 0 ) return PMsgListGameOptions;
  if ( strcmp(s,"PMsgChangeManager") == 0 ) return PMsgChangeManager;
  if ( strcmp(s,"PMsgSendMessage") == 0 ) return PMsgSendMessage;
  if ( strcmp(s,"PMsgSwapTile") == 0 ) return PMsgSwapTile;
  return -1;
}