-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmods.c
107 lines (102 loc) · 2.27 KB
/
mods.c
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
/*
harris - a strategy game
Copyright (C) 2012-2015 Edward Cree
licensed under GPLv3+ - see top of harris.c for details
mods: bombertype modifications
*/
#include "mods.h"
#include "globals.h"
int apply_mod(unsigned int m)
{
unsigned int bt=mods[m].bt;
unsigned int mark=mods[m].mark;
if(mods[m].s==NUM_BSTATS)
return(0);
if(mark)
types[bt].newmark=mark;
for(;mark<MAX_MARKS;mark++)
{
struct bomberstats *bm=types[bt].mark+mark;
switch(mods[m].s)
{
case BSTAT_COST:
bm->cost=mods[m].v.i;
break;
case BSTAT_SPEED:
bm->speed=mods[m].v.i;
break;
case BSTAT_ALT:
bm->alt=mods[m].v.i;
break;
case BSTAT_CAPWT:
bm->capwt=mods[m].v.i;
break;
case BSTAT_CAPBULK:
bm->capbulk=mods[m].v.i;
break;
case BSTAT_SVP:
bm->svp=mods[m].v.i;
break;
case BSTAT_DEFN:
bm->defn=mods[m].v.i;
break;
case BSTAT_FAIL:
bm->fail=mods[m].v.i;
break;
case BSTAT_ACCU:
bm->accu=mods[m].v.i;
break;
case BSTAT_RANGE:
bm->range=mods[m].v.i;
return(0);
case BSTAT_CREW:
for(unsigned int c=0;c<MAX_CREW;c++)
bm->crew[c]=mods[m].v.crew[c];
return(0);
case BSTAT_LOADS:
if(mods[m].mark)
fprintf(stderr, "Warning, mod %s tries to change loads on mark %u, but loads are not marked\n", mods[m].desc, mods[m].mark);
if(mods[m].v.i<NBOMBLOADS)
{
types[bt].load[mods[m].v.i]=true;
return(0);
}
fprintf(stderr, "ignoring excessive bombload ID %d\n", mods[m].v.i);
return(1);
case BSTAT_NAVS:
if(mods[m].v.i<NNAVAIDS)
{
bm->nav[mods[m].v.i]=true;
return(0);
}
fprintf(stderr, "ignoring excessive navaid ID %d\n", mods[m].v.i);
return(1);
case BSTAT_FLAGS:
switch(mods[m].v.f)
{
case BFLAG_OVLTANK:
bm->ovltank=true;
return(0);
case BFLAG_CREWBG:
bm->crewbg=true;
return(0);
case BFLAG_NCREWBG:
bm->crewbg=false;
return(0);
case BFLAG_CREWWG:
bm->crewwg=true;
return(0);
case BFLAG_NCREWWG:
bm->crewwg=false;
return(0);
default:
fprintf(stderr, "ignoring unsupported flag %d\n", mods[m].v.f);
return(1);
}
default:
fprintf(stderr, "ignoring unsupported stat %d\n", mods[m].s);
return(1);
}
}
return(0);
}