255
261
&& game.state != STATE_NEXT_PLAY)
258
if (game.players[p].team >= 0) {
262
for (p2 = 0; p2 < game.num_players; p2++)
263
if (game.players[p2].team == game.players[p].team)
264
tricks += game.players[p2].tricks;
266
add_player_message(s, "Tricks: %d (%d)\n",
267
game.players[p].tricks, tricks);
269
add_player_message(s, "Tricks: %d\n", game.players[p].tricks);
264
#if 0 /* Disabled - this is deemed too confusing. */
268
for (p2 = 0; p2 < game.num_players; p2++)
269
if (game.players[p2].team == game.players[p].team)
270
tricks += game.players[p2].tricks;
272
add_player_message(s, "Tricks: %d (%d)\n",
273
game.players[p].tricks, tricks);
275
add_player_message(s, "Tricks: %d\n", game.players[p].tricks);
273
279
void add_player_action_message(player_t p)
352
358
ggz_free(cardlist2);
355
static int **cumulative_scores = NULL;
356
static int c_score_count = 0;
357
static int c_score_size = 0;
359
/* Surely there's some library function to do this... */
360
static int int_len(int x)
362
int len = x < 0 ? 1 : 0;
364
for (x = abs(x); x > 0; x /= 10)
370
/* This function is extra-ordinarily overcomplicated. I hate string
372
static void send_cumulative_scores(void)
376
int widths[game.num_players];
378
if (!game.cumulative_scores)
381
/* First, put up the list of players/teams and calculate the string
382
width of each. This is a pretty complicated process... */
383
if (game.num_teams == 0) {
385
for (p = 0; p < game.num_players; p++) {
386
widths[p] = strlen(get_player_name(p));
390
snprintf(buf + buf_len, sizeof(buf) - buf_len,
394
game.num_players - 1 ? "" : " ");
399
memset(widths, 0, sizeof(widths));
401
for (t = 0; t < game.num_teams; t++) {
404
char *orig = buf + buf_len;
406
for (p = 0; p < game.num_players; p++) {
407
if (game.players[p].team == t) {
417
snprintf(buf + buf_len,
426
widths[t] = strlen(orig);
428
if (t != game.num_teams - 1) {
430
snprintf(buf + buf_len,
431
sizeof(buf) - buf_len, " ");
435
buf_len += snprintf(buf + buf_len, sizeof(buf) - buf_len, "\n");
437
for (r = 0; r < c_score_count; r++) {
440
0 ? game.num_players : game.num_teams;
441
int x; /* player or team... */
443
for (x = 0; x < max; x++) {
444
int score = cumulative_scores[r][x];
445
int iw = int_len(score);
446
int extra = widths[x] - iw;
448
/* this overcomplicated bit of hackery is intended to
449
center the score under the name. Unfortunately, it
450
assumes the number isn't longer than 3 characters. */
452
snprintf(buf + buf_len, sizeof(buf) - buf_len,
453
"%*s%*d%*s%s", extra / 2, "", iw,
454
score, (extra + 1) / 2, "",
455
(x == max - 1) ? "" : " ");
458
snprintf(buf + buf_len, sizeof(buf) - buf_len, "\n");
461
set_global_message("Scores", "%s", buf);
464
void init_cumulative_scores()
468
if (!game.cumulative_scores)
471
/* Free the array. */
472
if (cumulative_scores) {
473
for (i = 0; i < c_score_count; i++)
474
ggz_free(cumulative_scores[i]);
475
ggz_free(cumulative_scores);
478
cumulative_scores = NULL;
479
c_score_count = c_score_size = 0;
481
send_cumulative_scores();
484
/* add on this hand's scores */
485
void update_cumulative_scores()
487
int num = game.num_teams > 0 ? game.num_teams : game.num_players;
490
if (!game.cumulative_scores)
493
if (c_score_count > c_score_size) {
495
c_score_size = c_score_size * 3 / 2;
497
ggz_realloc(cumulative_scores,
499
sizeof(*cumulative_scores));
501
score_round = ggz_malloc(num * sizeof(**cumulative_scores));
502
cumulative_scores[c_score_count - 1] = score_round;
504
if (game.num_teams == 0) {
506
for (p = 0; p < game.num_players; p++)
507
cumulative_scores[c_score_count - 1][p] =
508
game.players[p].score;
511
for (p = 0; p < game.num_players; p++) {
512
cumulative_scores[c_score_count -
513
1][game.players[p].team] =
514
game.players[p].score;
518
send_cumulative_scores();
521
void send_bid_history()
361
void send_bid_history(void)
523
363
int r, buf_len = 0, widths[game.num_players];