File: func.c

package info (click to toggle)
xblast-tnt 2.10.4-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,444 kB
  • sloc: ansic: 54,105; sh: 4,014; makefile: 129; sed: 16
file content (978 lines) | stat: -rw-r--r-- 22,026 bytes parent folder | download | duplicates (6)
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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
/*
 * func.c - function pointers for special extras
 *
 * $Id: func.c,v 1.22 2006/03/29 21:46:27 alfie Exp $
 *
 * Program XBLAST 
 * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2; or (at your option)
 * any later version
 *
 * This program is distributed in the hope that it will be entertaining,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "xblast.h"

/*
 * global variables
 */
void (*specialExtraFunc) (BMPlayer *);
void (*specialKeyFunc) (BMPlayer *);

/*
 * local types
 */
typedef void (*SpecialExtraFunc) (BMPlayer *);
typedef void (*SpecialKeyFunc) (BMPlayer *);
static char *seVoidName = N_("No Special Extra");
static char *skVoidName = N_("No Special Key");

/* 
 * void functions 
 */
void
SpecialExtraVoid (BMPlayer * ps)
{
}

void
SpecialKeyVoid (BMPlayer * ps)
{
}

/* 
 * Invincible 
 */
static void
SpecialExtraInvincible (BMPlayer * ps)
{
	SND_Play (SND_INVINC, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->illtime = 0;
	ps->illness = ps->health;
	ps->invincible += EXTRA_INVINCIBLE;
}								/* SpecialExtraInvincible */

/* 
 * Kicking 
 */
static void
SpecialExtraKick (BMPlayer * ps)
{
	SND_Play (SND_NEWKICK, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->kick = XBTrue;
}								/* SpecialExtraKick */

/* 
 * Remote Control 
 */
static void
SpecialExtraRC (BMPlayer * ps)
{
	SND_Play (SND_NEWRC, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->remote_control = XBTrue;
}								/* SpecialExtraRC */

static void
SpecialKeyRC (BMPlayer * ps)
{
	if (ps->remote_control > 0) {
		if (IgnitePlayersBombs (ps)) {
			SND_Play (SND_SHOOT, ps->x / (PIXW / MAX_SOUND_POSITION));
		}
	}
}								/* SpecialKeyRC */

/*
 * bombs choice extra 
 */
static void
SpecialExtraChoice (BMPlayer * ps)
{
	char tutu[40];
	if (ps->choice_bomb_type == NUM_BMT) {
		int i;
		for (i = ChoiceDefaultBomb; bomb_name_choice[i] == NULL; i = ((i + 1) % NUM_BMT)) ;
		ps->choice_bomb_type = i;
		if (ps->local) {
			sprintf (tutu, "%s : ", p_string[ps->id].name);
			strcat (tutu, bomb_name_choice[(ps->choice_bomb_type)]);
			SetMessage (tutu, XBTrue);
		}
	}
}

static void
SpecialKeyChoice (BMPlayer * ps)
{

	if (ps->choice_bomb_type != NUM_BMT) {
		char tutu[40];
		int i;
		i = ps->choice_bomb_type;
		for (i = ((i + 1) % NUM_BMT); bomb_name_choice[i] == NULL; i = ((i + 1) % NUM_BMT)) ;
		ps->choice_bomb_type = i;
		if (ps->local) {
			sprintf (tutu, "%s : ", p_string[ps->id].name);
			strcat (tutu, bomb_name_choice[(ps->choice_bomb_type)]);
			SetMessage (tutu, XBTrue);

		}
	}
}

/* Written by VVL */
static void
SpecialKeyThrough (BMPlayer * ps)
{
	if ((ps->throughCount > 0) && (ps->lives > 0)) {
		if (ps->through) {
			ps->through = 0;
		}
		else {
			ps->through = EXTRA_THROUGH_TIME;
			ps->throughCount--;
		}
	}
}

 /**/
/* Walk through bomb Mode */
	 /**/ static void
SpecialExtraThrough (BMPlayer * ps)
{
	ps->throughCount += 1;
}

/* 
 * Teleport 
 */
static void
SpecialExtraTeleport (BMPlayer * ps)
{
	SND_Play (SND_NEWTELE, ps->x / (PIXW / MAX_SOUND_POSITION));
	if (ps->teleport == 0) {
		ps->teleport = 1;
	}
}								/* SpecialExtraTeleport */

static void
SpecialKeyTeleport (BMPlayer * ps)
{
	if (ps->teleport == 1) {
		ps->teleport = TELEPORT_TIME;
	}
}								/* SpecialKeyTeleport */

/* 
 * Frogger  extra (galatius(skywalker))
 */
static void
SpecialExtraFrogger (BMPlayer * ps)
{
	// SND_Play (SND_NEWTELE, ps->x / (PIXW / MAX_SOUND_POSITION));

	ps->frogger++;
}								/* SpecialExtraFrogger */

static void
SpecialKeyFrogger (BMPlayer * ps)
{
	if ((ps->lives > 0) && (ps->frogger) && (!ps->dying)) {
		/* do_bell(); */
		DoFrog (ps);
	}
}								/* SpecialKeyFrogger */

/* 
 * Daleif Illness  (galatius(skywalker))
 * Note that picking up this extra gets you *rid* of the daleif illness *
 */
static void
SpecialExtraDaleif (BMPlayer * ps)
{
	ps->daleif = 0;
}								/* SpecialExtraDalif */

/* 
 * Extra Ignite All 
 */
static void
SpecialExtraIgniteAll (BMPlayer * ps)
{
	SND_Play (SND_BUTT, ps->x / (PIXW / MAX_SOUND_POSITION));
	IgniteAllBombs (ps);
}								/* SpecialExtraIgniteAll */

static void
SpecialKeySpecialBomb (BMPlayer * ps)
{
	DropBomb (ps, BMTspecial);
}								/* SpecialKeySpecialBomb */

static void
SpecialExtraSpecialBomb (BMPlayer * ps)
{
	SND_Play (SND_SPBOMB, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->special_bombs += 3;
}								/* SpecialextraSpecialBomb */

/*
 * Junkie (Garth again)
 */
void
SpecialExtraJunkie (BMPlayer * ps)
{
	SND_Play (SND_INJ, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->junkie = MAX_JUNKIE_TIME;
}								/* SpecialExtraJunkie */

/* 
 * Air Pump (Garth Denley) 
 */
static void
SpecialExtraAir (BMPlayer * ps)
{
	SND_Play (SND_NEWPUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->air_button = XBTrue;
}								/* SpecialExtraAir */

static void
SpecialKeyAir (BMPlayer * ps)
{
	if ((ps->air_button > 0) && (ps->lives > 0)) {
		SND_Play (SND_PUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
		DoAir (ps);
	}
}								/* SpecialKeyAir */

/* 
 * Sucker (Stephan Natschlaeger)
 */
static void
SpecialExtraSuck (BMPlayer * ps)
{
	SND_Play (SND_NEWPUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->suck_button = XBTrue;
}								/* SpecialExtraSuck */

/* 
 * Ghost (Belgium Guys)
 */
void
SpecialExtraGhost (BMPlayer * ps)
{
	SND_Play (SND_NEWPUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->ghost = EXTRA_GHOST_TIME;

}								/* SpecialExtraGhost */

static void
SpecialKeySuck (BMPlayer * ps)
{
	if ((ps->suck_button > 0) && (ps->lives > 0)) {
		SND_Play (SND_PUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
		DoSuck (ps);
	}
}								/* SpecialKeySuck */

/*
 * poison extra
 */
void
SpecialExtraPoison (BMPlayer * ps)
{
	if (!ps->invincible) {
		ps->dying = DEAD_TIME;
	}
}								/* SpecialExtraPoison */

/*
 * spinner extra (long stunned )
 */
static void
SpecialExtraLongStunned (BMPlayer * ps)
{
	SND_Play (SND_STUN, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->stunned = STUN_TIME * 4;
}								/* SpecialExtraLongStunned */

/*
 * speed extra
 */
static void
SpecialExtraSpeed (BMPlayer * ps)
{
	SND_Play (SND_FAST, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->illness = IllRun;
	ps->health = IllRun;
	ps->illtime = 0;
}								/* SpecialExtraSpeed */

/*
 * speed extra
 */
static void
SpecialExtraSpeed2 (BMPlayer * ps)
{
	SND_Play (SND_FAST, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->illness = IllRun;
	ps->health = IllRun;
	ps->illtime = 0;
	ps->speed++;
}								/* SpecialExtraSpeed */

/*
 * slow extra
 */
void
SpecialExtraSlow (BMPlayer * ps)
{
	SND_Play (SND_SLOW, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->illness = IllSlow;
	ps->health = IllSlow;
	ps->illtime = 0;
}								/* SpecialExtraSlow */

/*
 * mayhem extra
 */
static void
SpecialExtraMayhem (BMPlayer * ps)
{
	SND_Play (SND_SLAY, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->kick = XBTrue;
	ps->illness = IllRun;
	ps->health = IllRun;
	ps->illtime = 0;
}								/* SpecialExtraMayhem */

/*
 * holy grail extra
 */
static void
SpecialExtraHolyGrail (BMPlayer * ps)
{
	SND_Play (SND_HOLY, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->lives += KillOtherPlayers (ps->team);
	if (ps->lives > 9) {
		ps->lives = 9;
	}
	ps->invincible = NEW_INVINCIBLE;
	ps->dying = DEAD_TIME;
}								/* SpecialExtraHolyGrail */

/* Added by "Belgium Guys" */
/* steal extra */
 /**/ static void
SpecialExtraSteal (BMPlayer * ps)
{

	ps->bombs += StealBombsOtherPlayers (ps->team);
	ps->range += StealRangeOtherPlayers (ps->team);
}

/*
 * multiple extra 
 */
static void
SpecialExtraLife (BMPlayer * ps)
{
	SND_Play (SND_LIFE, ps->x / (PIXW / MAX_SOUND_POSITION));
	if (ps->lives < 9) {
		ps->lives++;
	}
}								/* SpecialExtraLife */

/*
 * multiple extra 
 */
static void
SpecialExtraMultiple (BMPlayer * ps)
{
	switch (GameRandomNumber (11)) {
	case 0:
	case 1:
		SpecialExtraSpeed (ps);
		break;
	case 2:
	case 3:
		SpecialExtraPoison (ps);
		break;
	case 4:
	case 5:
		SpecialExtraInvincible (ps);
		break;
	case 6:
	case 7:
		SpecialExtraLongStunned (ps);
		break;
	case 8:
	case 9:
		SpecialExtraAir (ps);
		break;
	case 10:
		SpecialExtraLife (ps);
		break;
	}
}								/* SpecialExtraMultiple */

/*Skywalker epfl */

/* Written by VVL */
/* Electrify */
static void
SpecialExtraElectrify (BMPlayer * ps)
{
	ps->electrify = EXTRA_ELECTRIFY_COUNT;
}

static void
SpecialKeyElectrify (BMPlayer * ps)
{
	if ((ps->lives > 0) && (ps->electrify)) {
		if (ElectrifyOtherPlayers (ps->id)) {
			/* Success ... another player is hit! :-) */
			ps->electrify = 0;
		}
		else {
			/* Failure ... just try again! :-( */
			ps->electrify--;
		}
	}
}

static void
SpecialExtraFarter (BMPlayer * ps)
{
	ps->farter = 1;
}

static void
SpecialKeyFarter (BMPlayer * ps)
{
	if (ps != NULL) {
		if ((ps->lives > 0) && (ps->farter)) {
			/*     do_bell(); */
			FartOnOtherPlayers (ps);
		}
	}
}

/* Fart on players and bombs (galatius) */

static void
SpecialExtraBfarter (BMPlayer * ps)
{
	if (ps != NULL) {
		ps->bfarter = 1;
	}
}

/* Fart on players and bombs (galatius) */
static void
SpecialKeyBfarter (BMPlayer * ps)
{
	if ((ps->lives > 0) && (ps->bfarter) && ps != NULL) {
		/*     do_bell(); */
		FartOnOtherPlayers (ps);
		DoAir (ps);
	}
}

static void
SpecialExtraSwapColor (BMPlayer * ps)
{
	SwapColorOtherPlayers (ps->team);
}

static void
SpecialExtraSwapPosition (BMPlayer * ps)
{
	SwapPositionOtherPlayers (ps->team);
}

/* */

/*
 * cloaking device
 */
static void
SpecialExtraCloak (BMPlayer * ps)
{
	int w = 1;
	if (ps->cloaking < 0) {
		ps->cloaking *= -1;
		w = -1;
	}
	ps->cloaking += 2 * EXTRA_INVINCIBLE;
	ps->cloaking *= w;
	SND_Play (SND_NEWCLOAK, ps->x / (PIXW / MAX_SOUND_POSITION));
}								/* SpecialExtraCloak */

static void
SpecialKeyCloak (BMPlayer * ps)
{
	ps->cloaking *= -1;
	if (ps->cloaking > 0) {
		SND_Play (SND_DECLOAK, ps->x / (PIXW / MAX_SOUND_POSITION));
	}
	else if (ps->cloaking < 0) {
		SND_Play (SND_ENCLOAK, ps->x / (PIXW / MAX_SOUND_POSITION));
	}
}								/* SpecialKeyCloak */

/*
 * pow extra (stun others)
 */
void
SpecialExtraStunOthers (BMPlayer * ps)
{
	StunOtherPlayers (ps->team, STUN_TIME * 4);
}

/*
 * morphing extra (player becomes a bomb)
 */
static void
SpecialExtraMorph (BMPlayer * ps)
{
	ps->num_morph++;
}

static void
SpecialKeyMorph (BMPlayer * ps)
{
	if ((0 < ps->num_morph) && (0 < ps->bombs) && (!ps->morphed)) {
#ifdef DEBUG
		fprintf (stderr, "Player %d morphs", ps->id);
#endif
		ps->morphed = 1;
		DropBomb (ps, BMTdefault);
	}
}								/* SpecialKeyMorph */

static void
SpecialExtraStop (BMPlayer * ps)
{

	ps->stop = XBTrue;
}

static void
SpecialKeyStop (BMPlayer * ps)
{
	if (ps->stop > 0) {

		StopPlayersBombs (ps);
	}
}

/* Written by Amilhastre */
static void
SpecialExtraEvilGrail (BMPlayer * ps)
{
	ps->evilill = ILLDEATHTIME;
}

/* phantom extra */
/* Written by Amilhastre */
static void
SpecialExtraPhantom (BMPlayer * ps)
{
	if (!ps->phantom)
		ps->phantom = 3 * EXTRA_INVISIBLE;
	else
		ps->phantom += EXTRA_INVISIBLE;
}

/* revive extra */
/* Written by Amilhastre */
static void
SpecialExtraRevive (BMPlayer * ps)
{
	ps->revive++;
}

/* ** Skywalker **
 * sniping extra (player moves the bomb)
 */
static void
SpecialExtraSnipe (BMPlayer * ps)
{
	ps->num_snipe++;
}

static void
SpecialKeySnipe (BMPlayer * ps)
{
	if ((0 < ps->num_snipe) && (0 < ps->bombs) && (ps->sniping == 0)) {

		ps->sniping = 2;
		DropBomb (ps, BMTdefault);
		ps->sniping = 1;
	}
	else {
		if (ps->sniping == 1) {
			if (IgnitePlayersBombs (ps)) {
				ps->sniping = 1;
				ps->d_soll = GoStop;
			}
		}
	}

}								/* SpecialKeySnipe */

/* EPFL */

static void
SpecialExtraJump (BMPlayer * ps)
{
	SND_Play (SND_NEWPUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
	ps->jump_button += 1;
}

static void
SpecialKeyJump (BMPlayer * ps)
{
	if ((ps->jump_button > 0) && (ps->lives > 0)) {
		SND_Play (SND_PUMP, ps->x / (PIXW / MAX_SOUND_POSITION));
		DoJump (ps);
	}
}

/* END EPFL */

/*
 * conversion tables
 */
/* extra pickup functions */
static DBToData extraTable[] = {
	{"air", (void *)SpecialExtraAir},
	{"bfarter", (void *)SpecialExtraBfarter},	/* skywalker */
	{"choicebombtype", (void *)SpecialExtraChoice},	/* skywalker */
	{"cloak", (void *)SpecialExtraCloak},
	{"daleif", (void *)SpecialExtraDaleif},
	{"electrify", (void *)SpecialExtraElectrify},
	{"evilgrail", (void *)SpecialExtraEvilGrail},
	{"farter", (void *)SpecialExtraFarter},	/* skywalker */
	{"frogger", (void *)SpecialExtraFrogger},	/* skywalker */
	{"ghost", (void *)SpecialExtraGhost},	/* skywalker */
	{"holyGrail", (void *)SpecialExtraHolyGrail},
	{"igniteAll", (void *)SpecialExtraIgniteAll},
	{"invincible", (void *)SpecialExtraInvincible},
	{"jump", (void *)SpecialExtraJump},	/* skywalker */
	{"junkie", (void *)SpecialExtraJunkie},
	{"kick", (void *)SpecialExtraKick},
	{"life", (void *)SpecialExtraLife},
	{"longStunned", (void *)SpecialExtraLongStunned},
	{"mayhem", (void *)SpecialExtraMayhem},
	{"morph", (void *)SpecialExtraMorph},
	{"multiple", (void *)SpecialExtraMultiple},
	{"phantom", (void *)SpecialExtraPhantom},
	{"poison", (void *)SpecialExtraPoison},
	{"rc", (void *)SpecialExtraRC},
	{"revive", (void *)SpecialExtraRevive},
	{"slow", (void *)SpecialExtraSlow},
	{"snipe", (void *)SpecialExtraSnipe},	/* skywalker */
	{"specialBomb", (void *)SpecialExtraSpecialBomb},
	{"speed", (void *)SpecialExtraSpeed},
	{"speed2", (void *)SpecialExtraSpeed2},
	{"steal", (void *)SpecialExtraSteal},
	{"stop", (void *)SpecialExtraStop},
	{"stunOthers", (void *)SpecialExtraStunOthers},
	{"sucker", (void *)SpecialExtraSuck},
	{"swapcolor", (void *)SpecialExtraSwapColor},	/* skywalker */
	{"swapposition", (void *)SpecialExtraSwapPosition},	/* skywalker */
	{"teleport", (void *)SpecialExtraTeleport},
	{"through", (void *)SpecialExtraThrough},
	{"void", (void *)SpecialExtraVoid},
	{NULL, NULL}
};

/* extra key functions */
static DBToData keyTable[] = {
	{"air", (void *)SpecialKeyAir},
	{"bfarter", (void *)SpecialKeyBfarter},
	{"choicebombtype", (void *)SpecialKeyChoice},	/* skywalker */
	{"cloak", (void *)SpecialKeyCloak},
	{"electrify", (void *)SpecialKeyElectrify},
	{"farter", (void *)SpecialKeyFarter},	/* skywalker */
	{"frogger", (void *)SpecialKeyFrogger},	/* skywalker */
	{"jump", (void *)SpecialKeyJump},	/* skywalker */
	{"morph", (void *)SpecialKeyMorph},
	{"rc", (void *)SpecialKeyRC},
	{"snipe", (void *)SpecialKeySnipe},	/* skywalker */
	{"specialBomb", (void *)SpecialKeySpecialBomb},
	{"stop", (void *)SpecialKeyStop},
	{"sucker", (void *)SpecialKeySuck},
	{"teleport", (void *)SpecialKeyTeleport},
	{"through", (void *)SpecialKeyThrough},
	{"void", (void *)SpecialKeyVoid},
	{NULL, NULL}
};

/*
 * parse func section of level data
 */
XBBool
ParseLevelFunc (const DBSection * section, DBSection * warn)
{
	void *ptr;
	/* check if section exists */
	if (NULL == section) {
		Dbg_Out ("LEVEL: func section is missing!\n");
		DB_CreateEntryString (warn, atomMissing, "true");
		return XBFalse;
	}
	/* Extra has default */
	switch (DB_ConvertEntryData (section, atomExtra, &ptr, extraTable)) {
	case DCR_NoSuchEntry:
		Dbg_Level ("default for %s\n", DB_SectionEntryString (section, atomExtra));
		specialExtraFunc = SpecialExtraVoid;
		break;
	case DCR_Failure:
		Dbg_Out ("LEVEL: warning for %s\n", DB_SectionEntryString (section, atomExtra));
		specialExtraFunc = SpecialExtraVoid;
		DB_CreateEntryString (warn, atomExtra, DB_DataToString (extraTable, specialExtraFunc));
		break;
	default:
		assert (ptr != NULL);
		specialExtraFunc = (SpecialExtraFunc) ptr;
		break;
	}
	/* check for swap extras, buggy for < 2.10.2 */
	if (!Version_AtLeast (VERSION_JOINT, &Ver_2_10_2)) {
		if (specialExtraFunc == SpecialExtraSwapColor) {
			/* add warning and reject level */
			DB_CreateEntryString (warn, atomExtra, DB_DataToString (extraTable, specialExtraFunc));
			return XBFalse;
		}
	}
	/* Key has default */
	switch (DB_ConvertEntryData (section, atomKey, &ptr, keyTable)) {
	case DCR_NoSuchEntry:
		Dbg_Level ("default for %s\n", DB_SectionEntryString (section, atomKey));
		specialKeyFunc = SpecialKeyVoid;
		break;
	case DCR_Failure:
		Dbg_Out ("LEVEL: warning for %s\n", DB_SectionEntryString (section, atomKey));
		specialKeyFunc = SpecialKeyVoid;
		DB_CreateEntryString (warn, atomExtra, DB_DataToString (keyTable, specialKeyFunc));
		break;
	default:
		assert (ptr != NULL);
		specialKeyFunc = (SpecialKeyFunc) ptr;
		break;
	}
	return XBTrue;
}

/*
 * config section [FUNC]
 */
void
ConfigLevelFunc (const DBSection * section)
{
	/* set extra info */
	if (specialExtraFunc == SpecialExtraAir) {
		AddExtraInfo (N_("Airpump as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraBfarter) {	/* skywalker */
		AddExtraInfo (N_("Bfarter as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraChoice) {	/* skywalker */
		AddExtraInfo (N_("Choice as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraCloak) {
		AddExtraInfo (N_("Cloak as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraDaleif) {
		AddExtraInfo (N_("Daleif as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraElectrify) {
		AddExtraInfo (N_("Electrify as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraFarter) {	/* skywalker */
		AddExtraInfo (N_("Farter as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraFrogger) {	/* skywalker */
		AddExtraInfo (N_("Frogger as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraGhost) {	/* skywalker */
		AddExtraInfo (N_("Ghost as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraHolyGrail) {
		AddExtraInfo (N_("The Holy Grail as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraIgniteAll) {
		AddExtraInfo (N_("Button as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraInvincible) {
		AddExtraInfo (N_("Invincibility as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraJump) {
		AddExtraInfo (N_("Jump as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraJunkie) {
		AddExtraInfo (N_("Junkie virus as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraKick) {
		AddExtraInfo (N_("Kick as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraLife) {
		AddExtraInfo (N_("Free life as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraLongStunned) {
		AddExtraInfo (N_("Spinner as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraMayhem) {
		AddExtraInfo (N_("Mayhem (Kick & Run) as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraMorph) {
		AddExtraInfo (N_("Morphing as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraMultiple) {
		AddExtraInfo (N_("Random special extra"));
	}
	else if (specialExtraFunc == SpecialExtraPhantom) {
		AddExtraInfo (N_("Phantom as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraPoison) {
		AddExtraInfo (N_("Poison as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraRC) {
		AddExtraInfo (N_("Remote control as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraRevive) {
		AddExtraInfo (N_("Revive control as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSnipe) {	/* skywalker */
		AddExtraInfo (N_("Snipe as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraStop) {	/* skywalker */
		AddExtraInfo (N_("Stop as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSuck) {	/* skywalker */
		AddExtraInfo (N_("Sucker as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSwapColor) {	/* skywalker */
		AddExtraInfo (N_("Swapcolor as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSwapPosition) {	/* skywalker */
		AddExtraInfo (N_("Swapposition as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSlow) {
		AddExtraInfo (N_("Slowdown as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSpeed) {
		AddExtraInfo (N_("Speed as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraSpeed2) {
		AddExtraInfo (N_("SpeedII as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraStop) {
		AddExtraInfo (N_("Stop as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraStunOthers) {
		AddExtraInfo (N_("Stunner as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraTeleport) {
		AddExtraInfo (N_("Teleporter as an extra"));
	}
	else if (specialExtraFunc == SpecialExtraThrough) {
		AddExtraInfo (N_("Through as an extra"));
	}
}								/* ConfigLevelFunc */

/*
 *
 */
XBBool
HasSpecialBombs (void)
{
	return (specialExtraFunc == SpecialExtraSpecialBomb);
}								/* HasSpecialBombs */

/*
 * return the name of the extra type
 */
const char *
GetExtraNameFunc (void *type)
{
	int i;
	if (type == SpecialExtraVoid)
		return seVoidName;
	for (i = 0; extraTable[i].value != NULL; ++i)
		if (extraTable[i].value == type)
			return extraTable[i].key;
	return seVoidName;
}
const char *
GetExtraNameInt (int type)
{
	int i;
	for (i = 0; extraTable[i].value != NULL; ++i)
		if (i == type)
			return extraTable[i].key;
	return seVoidName;
}

/*
 * return the name of the key type
 */
const char *
GetKeyNameFunc (void *type)
{
	int i;
	if (type == SpecialKeyVoid)
		return skVoidName;
	for (i = 0; keyTable[i].value != NULL; ++i)
		if (keyTable[i].value == type)
			return keyTable[i].key;
	return skVoidName;
}
const char *
GetKeyNameInt (int type)
{
	int i;
	for (i = 0; keyTable[i].value != NULL; ++i)
		if (i == type)
			return keyTable[i].key;
	return skVoidName;
}

/*
 * return the number of the key type
 */
int
GetNumberOfKeys (void)
{
	int i;
	for (i = 0; keyTable[i].value != NULL; ++i) ;
	return i;
}

/*
 * return the number of the extra type
 */
int
GetNumberOfExtras (void)
{
	int i;
	for (i = 0; extraTable[i].value != NULL; ++i) ;
	return i;
}

/*
 * end of file func.c
 */