File: craft.hc

package info (click to toggle)
craft 3.5-10
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,000 kB
  • ctags: 1,602
  • sloc: cpp: 3,794; makefile: 2,319; ansic: 857; sh: 385
file content (772 lines) | stat: -rw-r--r-- 21,217 bytes parent folder | download | duplicates (3)
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
#include <unistd.h>

#include "win.h"
#include "cmap.h"
#include "masks.h"
#include "player.h"
#include "craft_def.h"
#include "object_handler.h"
#include "land.h"
#include "xstring.h"
#include "setupedit.h"
#include "dial.h"
#include "scroller.h"
#include "buttons.h"
#include "ship.h"
#include "option_menu.h"
#include "xtimer.h"


#define        min_cycle_time  40

double         robo_power;
double         robo_agress;

int            overall_money;

int            q_step;

int            min_rland_dx;
int            min_rland_dy;
int            max_rland_dx;
int            max_rland_dy;

int            speed_stag;
int            speed_worker;
int            speed_trader;
int            speed_knight;
int            speed_pawn;
int            speed_scout;
int            speed_archer;
int            speed_home;
int            speed_farm;
int            speed_farm_exec;
int            speed_zombi;
int            speed_schrott;
int            speed_swim;
int            speed_water;
int            speed_hit;
int            speed_building_zombi;
int            speed_archer_hit;
int            speed_cata;
int            speed_cata_load;
int            speed_explosion;
int            speed_doktor;
int            speed_doktor_hit;
int            speed_general;
int            speed_trap;
int            speed_arrow;
int            speed_stone;
int            speed_ship1;
int            speed_ship2;
int            speed_ship_zombi;

char           land_name [128];

int            ilid        [max_land_dx][max_land_dy];
int            landscape   [max_land_dx][max_land_dy];
int            landhight   [max_land_dx][max_land_dy];
int            landpic     [max_land_dx][max_land_dy];
int            landoverlay [max_land_dx][max_land_dy][2];
int            landscape_dx;
int            landscape_dy;
int            landscale;
int            olandscale;

int            unit      [max_land_dx][max_land_dy];
int            upic      [max_land_dx][max_land_dy][8];

int            color_player [max_cols];
int            player_color [max_players];
bool           paused       [max_players];
double         p_speed      [max_players];
char           p_name       [max_players][128];
int            num_paused;

int            ticker;

default_options defaults;

bool           is_self;
bool           is_suny;
bool           is_water_world;

land_prop      land_properties [max_land_types]; 

object_handler *objects;

player         *players [max_players];
int            num_humans;
int            num_players;
int            active [max_players];

char           host  [max_players][128];
char           name  [max_players][128];
double         speed [max_players];           

      

/*--- main ------------------------------------------------------------------*/

void dump ()
  {print_landscape;
   print_landhight;
   print_landpic;
   print_units;
   print_upic;
   print_objs;

.  print_landscape
     {printf ("--- landscape\n");
      printf ("dx %d dy %d\n", landscape_dx, landscape_dy);
      for (int y = 0; y < landscape_dy; y++)
        {for (int x = 0; x < landscape_dx; x++)
           printf ("%4d ", landscape [x][y]);
         printf ("\n");
        };
     }.

.  print_landhight
     {printf ("--- landhight\n");
      printf ("dx %d dy %d\n", landscape_dx, landscape_dy);
      for (int y = 0; y < landscape_dy; y++)
        {for (int x = 0; x < landscape_dx; x++)
           printf ("%4d ", landhight [x][y]);
         printf ("\n");
        };
     }.

.  print_landpic
     {printf ("--- landpic\n");
      printf ("dx %d dy %d\n", landscape_dx, landscape_dy);
      for (int y = 0; y < landscape_dy; y++)
        {for (int x = 0; x < landscape_dx; x++)
           printf ("%4d ", landpic [x][y]);
         printf ("\n");
        };
     }.

.  print_units
     {printf ("--- unit\n");
      printf ("dx %d dy %d\n", landscape_dx, landscape_dy);
      for (int y = 0; y < landscape_dy; y++)
        {for (int x = 0; x < landscape_dx; x++)
           printf ("%4d ", unit [x][y]);
         printf ("\n");
        };
     }.

.  print_upic
     {printf ("--- upic\n");
      printf ("dx %d dy %d\n", landscape_dx, landscape_dy);
      for (int y = 0; y < landscape_dy; y++)
        {for (int x = 0; x < landscape_dx; x++)
           {for (int i = 0; i < 8; i++)
              printf ("%4d ", upic [x][y][i]);
            printf (",");
           };
         printf ("\n");
        };
     }.

.  print_objs
     {for (int i = 0; i < max_objects; i++)
        printf ("%d %d %d %d %d %d %d %d %d\n", 
                i, 
                objects->type [i],
                objects->is_free [i],
                objects->color [i],
                objects->x  [i],
                objects->y  [i], 
                objects->wx [i],
                objects->wy [i],
                objects->pic [i]);
    }.

  }

void handle_abnormal_termination ()
  {printf ("\nabnormal termination occurred ***\n");
/*
   dump   ();
*/
   exit   (0);
  }       

void handle_bus_error ()
  {printf ("\nbus error occurred ***\n");
/*
   dump   ();
*/
   exit   (0);
  }   

void handle_seg_fault ()
  {printf ("\nsegmentation fault occurred ***\n");
/*
   dump   ();
*/
   exit   (0);
  }  

void install_abnormal_termination_handler ()
  {
/*
   set_interrupt (SIGINT,  handle_abnormal_termination);
   set_interrupt (SIGBUS,  handle_bus_error);
   set_interrupt (SIGSEGV, handle_seg_fault);
   set_interrupt (SIGABRT, handle_abnormal_termination);
*/
  }

/*--- main ------------------------------------------------------------------*/

double pdist (int x1, int y1, int x2, int y2)
  {int xx = x1 - x2;
   int yy = y1 - y2;

   return sqrt (xx * xx + yy * yy);
  }

void init_speed (double factor)
  {speed_stag           = i_max (1, xspeed_stag);
   speed_worker         = i_max (1, (int)((double) xspeed_worker * factor));
   speed_trader         = i_max (1, (int)((double) xspeed_trader * factor));
   speed_knight         = i_max (1, (int)((double) xspeed_knight * factor));
   speed_pawn           = i_max (1, (int)((double) xspeed_pawn * factor));
   speed_scout          = i_max (1, (int)((double) xspeed_scout * factor));
   speed_archer         = i_max (1, (int)((double) xspeed_archer * factor));
   speed_home           = i_max (1, (int)((double) xspeed_home * factor));
   speed_farm           = i_max (1, (int)((double) xspeed_farm * factor));
   speed_farm_exec      = i_max (1, speed_farm - (int) (200.0 * factor));
   speed_zombi          = i_max (1, (int)((double) xspeed_zombi * factor));
   speed_schrott        = i_max (1, (int)((double) xspeed_schrott * factor));
   speed_swim           = i_max (1, (int)((double) xspeed_swim * factor));
   speed_water          = i_max (1, (int)((double) xspeed_water * factor));
   speed_hit            = i_max (1, (int)((double) xspeed_hit * factor));
   speed_building_zombi = i_max (1, (int)((double) xspeed_building_zombi * factor));
   speed_archer_hit     = i_max (1, (int)((double) xspeed_archer_hit * factor));
   speed_cata           = i_max (1, (int)((double) xspeed_cata * factor));
   speed_cata_load      = i_max (1, (int)((double) xspeed_cata_load * factor));
   speed_explosion      = i_max (1, (int)((double) xspeed_explosion * factor));
   speed_doktor         = i_max (1, (int)((double) xspeed_doktor * factor));
   speed_doktor_hit     = i_max (1, (int)((double) xspeed_doktor_hit * factor));
   speed_general        = i_max (1, (int)((double) xspeed_general * factor));
   speed_trap           = i_max (1, (int)((double) xspeed_trap * factor));
   speed_arrow          = i_max (1, (int)((double) xspeed_arrow * factor));
   speed_stone          = i_max (1, (int)((double) xspeed_stone * factor));
   speed_ship1          = i_max (1, (int)((double) xspeed_ship1 * factor));
   speed_ship2          = i_max (1, (int)((double) xspeed_ship2 * factor));
   speed_ship_zombi     = i_max (1, (int)((double) xspeed_ship_zombi*factor));
  }

void init_craft (char   host  [max_players][128],
                 char   name  [max_players][128],
                 double speed [max_players])

  {install_abnormal_termination_handler ();
   store_params;
   init_ticker;
   load_troups;
   init_land;
   init_players;

.  init_land
     {load_land_props ();
      if   (is_water_world)
           rnd_water_land  ();  
      else rnd_land ();
     }.

.  init_ticker
     {ticker = 0;
     }.

.  store_params
     {num_players = 0;
      num_humans  = 0;
      for (int i = 0; i < max_players; i++)
        cnt_player;
      num_paused  = 0;
     }.

.  cnt_player
     {if (active [i])
         {num_players++; 
          if (! is_robot)
             num_humans++;
         };
     }.

.  init_players
     {int i;

      olandscale = 1;
      for (i = 0; i < max_players; i++)
        {paused [i] = false; 
         strcpy (p_name [i], name [i]);
         p_speed [i] = 1;
        };
      for (i = 0; i < max_players; i++)
        if (active [i])
           gen_player;
      for (i = 0; i < max_players; i++)
        if (active [i])
           players [i]->initial_display ();
      color_player [red]    = 0;
      color_player [blue]   = 1;
      color_player [yellow] = 2;
      color_player [cyan]   = 3;
      player_color [0]      = red;
      player_color [1]      = blue;
      player_color [2]      = yellow;
      player_color [3]      = cyan;
     }.

.  gen_player
     {if (i == 0) players [i] = new player (i,
                                            name [i],
                                            host [i],
                                            red,
                                            p_speed [i],
                                            is_robot);
      if (i == 1) players [i] = new player (i,
                                            name [i],
                                            host [i],
                                            blue,
                                            p_speed [i],
                                            is_robot);
      if (i == 2) players [i] = new player (i,
                                            name [i],
                                            host [i],
                                            yellow,
                                            p_speed [i],
                                            is_robot);
      if (i == 3) players [i] = new player (i,
                                            name [i],
                                            host [i],
                                            cyan,
                                            p_speed [i],
                                            is_robot);
     }.

.  is_robot
     (strcmp (host [i], "-") == 0).

.  load_troups
     {objects = new object_handler ();
     }.

  }

void finish_craft ()
  {for (int i = 0; i < max_players; i++)
     if (active [i])
        delete (players [i]);
   delete (objects);
  }

void set_initial_objects ()
   {int color = blue;
    int il_locked [15];

    init;
    if (active [0]) {color = blue;   gen;};
    if (active [1]) {color = red;    gen;};
    if (active [2]) {color = yellow; gen;};
    if (active [3]) {color = cyan;   gen;};

.  init
     {for (int i = 0; i < 15; i++)
        il_locked [i] = false;
     }.

.  gen
     {int xx;
      int yy;

      get_xx_yy;
      gen_on_land;
     }.

.  gen_on_land
     {objects->create_worker (xx,     yy,  color, none);
      objects->create_worker (xx+1,   yy,  color, none);
      objects->create_knight (xx+1, yy+1,  color, none, is_self && ! is_robo);
      players [color_player [color]]->focus (xx, yy);
     }.

.  is_robo
     players [color_player [color]]->is_robot.

.  get_xx_yy
     {if   (is_water_world)
           get_island_xx_yy
      else get_land_xx_yy;
     }.

.  get_island_xx_yy
     {int il;

      get_il;
      while (il_locked [il])
        {get_il;
        };
      xx             = land_x_il (il);
      yy             = land_y_il (il);
      il_locked [il] = true;
      march;
     }.     

.  march
     {int  ox = xx;
      int  oy = yy;
      bool il_ok;

      check_il;
      while (! il_ok)
        {perhaps_backstep;
         step;
         check_il;
        };
      set_to_grass;
     }.

.  check_il
     {il_ok = could_become_grass;
     }.

.  set_to_grass
     {for (int xa = i_max (0, xx-2); xa < i_min (landscape_dx, xx+3); xa++)
        for (int ya = i_max (0, yy-2); ya < i_min (landscape_dy, yy+3); ya++)
          if (landhight [xa][ya] > 0 && unit [xa][ya] == none)
             {landscape [xa][ya] = land_grass;
              landpic   [xa][ya] = land_grass + land_profile (xa, ya, 1);;
              objects->refresh (xa, ya);
             };
      il_ok = true;
     }.

.  could_become_grass
     (1 <= xx && xx <= landscape_dx - 3 &&
      1 <= yy && yy <= landscape_dy - 3 &&
      unit [xx]  [yy]        == none &&
      unit [xx+1][yy]        == none &&
      unit [xx+1][yy+1]      == none &&
      landscape [xx]  [yy]   != land_water &&
      landscape [xx+1][yy]   != land_water &&
      landscape [xx+1][yy+1] != land_water &&
      landscape [xx]  [yy]   != land_sea   &&
      landscape [xx+1][yy]   != land_sea   &&
      landscape [xx+1][yy+1] != land_sea).

.  perhaps_backstep
     {if (is_water (10000, xx, yy))
         {xx = ox;
          yy = oy;
         };
     }.

.  step
     {ox = xx;
      oy = yy;
      xx = i_bound (1, xx + i_random (-2, 2), landscape_dx - 3);
      yy = i_bound (1, yy + i_random (-2, 2), landscape_dy - 3);
     }.

.  get_il
     {il = i_random (0, land_num_il () - 4 - 1);
     }.

.  get_land_xx_yy
     {bool ok;

      rnd;
      while (! ok)
        {rnd;
        };
     }.

.  rnd
     {int s;

      if (i_random (0, 100) > 50) s = 1; else s = -1;
      xx = landscape_dx/2 + i_random (10, landscape_dx/2 - 5) * s;
      if (i_random (0, 100) > 50) s = 1; else s = -1;
      yy = landscape_dy/2 + i_random (10, landscape_dy/2 - 5) * s;
      check_ok;
     }.

.  check_ok
     {ok = (! is_water_world                     &&
            landscape [xx]  [yy]   == land_grass &&
            landscape [xx+1][yy]   == land_grass &&
            landscape [xx+1][yy+1] == land_grass) ||
           (is_water_world && is_water (10000, xx, yy));
      for (int i = 0; i < max_objects; i++)
        if (! objects->is_free [i] && objects->type [i] == object_knight)
           ok &= (pdist (xx, yy, objects->x [i], objects->y [i]) > 25);
     }.
                 
  }

main (int num_params, char *shell_params [])
  {double act_speed;

   start_message;
   read_options;
#ifdef DATADIR
   change_dir;
#endif
   init_players;
   set_initial_objects ();
   exec_craft;
   finish_craft ();

.  start_message
     {printf ("CRAFT Version 3.5 (http://set.gmd.de/~hua) started\n");
     }.

.  read_options
     {
      defaults.is_self        = true;
      defaults.is_suny        = true;
      defaults.is_water_world = true;
      defaults.act_speed      = 4;
      defaults.q_step         = 1;
      defaults.r_power        = 3;
      defaults.r_agress       = 3;
      defaults.min_rland_dx   = 60;
      defaults.min_rland_dy   = 60;
      defaults.max_rland_dx   = 80;
      defaults.max_rland_dy   = 80;
      defaults.was_seed       = false;
      defaults.tic            = 0;
      defaults.active [0]     = true;
      defaults.active [1]     = true;
      defaults.active [2]     = false;
      defaults.active [3]     = false;

      int i;
      int opt;
      while((opt=getopt(num_params, shell_params, "k:v:i:f:r:x:y:X:Y:s:1:2:3:"))>0)
        switch (opt)
        {case 'k' : i=atoi(optarg); defaults.is_self=(i? true: false); break;
         case 'v' : i=atoi(optarg); defaults.is_suny=(i? true: false); break;
         case 'i' : i=atoi(optarg); defaults.is_water_world=(i? true: false); break;
         case 'f' : i=atoi(optarg); defaults.act_speed=i; break;
         case 'r' : i=atoi(optarg); defaults.r_power=i; break;
         case 'x' : i=atoi(optarg); defaults.min_rland_dx=i; break;
         case 'y' : i=atoi(optarg); defaults.min_rland_dy=i; break;
         case 'X' : i=atoi(optarg); defaults.max_rland_dx=i; break;
         case 'Y' : i=atoi(optarg); defaults.max_rland_dy=i; break;
         case 's' : i=atoi(optarg); defaults.was_seed=true; defaults.tic=i; break;
         case '1' : i=atoi(optarg); defaults.active[1]=(i? true: false); break;
         case '2' : i=atoi(optarg); defaults.active[2]=(i? true: false); break;
         case '3' : i=atoi(optarg); defaults.active[3]=(i? true: false); break;
         default  : printf("Unknown option %c\n", opt);
        }
     }.

#ifdef DATADIR
.  change_dir
     {if (chdir(DATADIR) < 0)
      printf ("Warning: cannot open data directory " DATADIR ";\n"
              "         looking in current working directory\n");
     }.
#endif

.  init_players
     {int tic;

      get_params;
      d_randomize (tic);
      init_speed  (act_speed);
      init_craft  (host, name, speed);
      printf      ("starting game with seed %d\n", tic);
     }.

.  get_params
     {for (int i = 0; i < max_players; i++)
        active [i] = false;
      option_menu (act_speed, tic);
     }.

.  exec_craft
     {bool quit = false;
      int  cnt;
      int  h = 0;

      set_cnt;
      while (! quit)
        cycle;
     }.

.  set_cnt
     {cnt = num_players;
     }.

.  cycle
     {int    suspend = -1;
      long   cycle_start_time = x_sys_time ();

      read_cmds;
      if (h % 3 == 0)
         check_pause;
      exec_objects;
      check_over;
      perhaps_delay;
     }.

.  perhaps_delay
     {long rest_dt = (min_cycle_time - (x_sys_time () - cycle_start_time));

      if (rest_dt > 10)
         {delay (rest_dt);
         };
     }.

.  check_pause
     {bool was = false;

      while (num_paused > 0) 
        {pause_a_bit;
        };
      if (was)
         pause_a_bit;
     }.

.  pause_a_bit
     {was = true;
      for (int i = 0; i < max_players; i++)
        if (active [i] && ! players [i]->is_robot)
           players [i]->handle_pause ();
      delay (min_cycle_time);
     }.

.  read_cmds
     {for (int pi = 0; pi < max_players; pi++)
        if (active [pi] && ! players [pi]->is_robot)
           read_player_cmd;
     }.

.  read_player_cmd 
     {int  cmd [max_marked];
      int  x   [max_marked];
      int  y   [max_marked];
      int  id  [max_marked];
      int  num;
      int  suspend    = -1;
      bool is_suspend = false;

      players [pi]->get_cmds (is_suspend, num, cmd, id, x, y);
      perhaps_exec_player_cmd;
      if (is_suspend)
         {suspend = pi;
          check_over;
         };
     }.

.  perhaps_exec_player_cmd
     {for (int p = 0; p < num; p++)
        exec_player_cmd;
     }.

.  exec_player_cmd
     {objects->new_order (id [p], cmd [p], x [p], y [p]);
     }.

.  exec_objects
     {for (int i = 0; i < 1; i++)
        {objects->exec ();
         ticker++;
        };
     }.

.  check_over
     {int only = -1;

      for (int i = 0; i < max_players; i++)
        if (active [i] &&
             (players [i]->num_mans <= 0 ||
              suspend == i ||
              players [i]->master_dead))
           handle_game_over
     }.

.  handle_game_over
     {char   msg       [128];
      win    *w        [max_players];
      button *b        [max_players];
      bool    m_active [max_players];

      if      (players [i]->master_dead)
              sprintf (msg, "%s haes been killed", name [i]);
      else if (players [i]->num_mans <= 0)
              sprintf (msg, "%s lost all his man", name [i]);
      else if (suspend == i)
              sprintf (msg, "%s gives up",         name [i]); 
      tell_to_players;
      ack_from_players;
      if (! players [i]->is_robot)
         num_humans--;
      cnt--;
      quit = (cnt <= 1 || num_humans < 1);
      for (int o = 0; o < max_players; o++)
        if (active [o] && o != i && ! players [o]->is_robot)
           only = o;
      if      (quit && only != -1)
              {sprintf (msg, "%s wins", name [only]);
               tell_to_players;
               ack_from_players;
              }
      else if (quit && only == -1)
              {sprintf (msg, "The computer wins, haha...");
               tell_to_players;
               ack_from_players;
              };
      players [i]->deactivate ();
      active [i] = false;
     }.

.  tell_to_players
     {for (int j = 0; j < max_players; j++)
        {m_active [j] = false;
         if (active [j] && ! players [j]->is_robot)
           tell_to_player;
        };
     }.

.  tell_to_player
     {tell (host [j], players [j]->w_land, w [j], msg);
      b        [j] = new button (w [j], "OK", 120, 80);
      m_active [j] = true;
     }.

.  ack_from_players
     {bool any_active = true;

      while (any_active)
        check_buttons;
     }.

.  check_buttons
     {any_active = false;
      for (int j = 0; j < max_players; j++)
        if (m_active [j])
           ack_from_player;
     }.

.  ack_from_player
     {any_active = true;
      w [j]->mark_mouse ();
      w [j]->tick ();
      if   (b [j]->eval ())
           {delete (b [j]);
            delete (w [j]);
            m_active [j] = false;
           }
      else w [j]->scratch_mouse ();
     }.

  }