Mercurial > hg > early-roguelike
comparison arogue7/daemon.c @ 239:837044d2c362
Merge the GCC5 and build fix branches.
This fixes all warnings produced by GCC 5, except the ones related to
system functions. Those could be fixed by including the proper headers,
but it would be better to replace the system-dependent code with
functions from mdport.c.
author | John "Elwin" Edwards |
---|---|
date | Fri, 11 Mar 2016 19:47:52 -0500 |
parents | e1cd27c5464f |
children |
comparison
equal
deleted
inserted
replaced
232:bac2c81fec78 | 239:837044d2c362 |
---|---|
76 /* | 76 /* |
77 * find_slot: | 77 * find_slot: |
78 * Find a particular slot in the table | 78 * Find a particular slot in the table |
79 */ | 79 */ |
80 struct delayed_action * | 80 struct delayed_action * |
81 find_slot(int (*func)()) | 81 find_slot(void (*func)()) |
82 { | 82 { |
83 reg int i; | 83 reg int i; |
84 reg struct delayed_action *dev; | 84 reg struct delayed_action *dev; |
85 | 85 |
86 for (i = 0, dev = f_list; i < MAXFUSES; i++, dev++) | 86 for (i = 0, dev = f_list; i < MAXFUSES; i++, dev++) |
93 /* | 93 /* |
94 * start_daemon: | 94 * start_daemon: |
95 * Start a daemon, takes a function. | 95 * Start a daemon, takes a function. |
96 */ | 96 */ |
97 void | 97 void |
98 start_daemon(int (*func)(), int arg, int type) | 98 start_daemon(void (*func)(), void *arg, int type) |
99 { | 99 { |
100 reg struct delayed_action *dev; | 100 reg struct delayed_action *dev; |
101 | 101 |
102 dev = d_slot(); | 102 dev = d_slot(); |
103 if (dev != NULL) { | 103 if (dev != NULL) { |
104 dev->d_type = type; | 104 dev->d_type = type; |
105 dev->d_func = func; | 105 dev->d_func = func; |
106 dev->d_.arg = arg; | 106 dev->d_.varg = arg; |
107 dev->d_time = DAEMON; | 107 dev->d_time = DAEMON; |
108 demoncnt += 1; /* update count */ | 108 demoncnt += 1; /* update count */ |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
113 /* | 113 /* |
114 * kill_daemon: | 114 * kill_daemon: |
115 * Remove a daemon from the list | 115 * Remove a daemon from the list |
116 */ | 116 */ |
117 void | 117 void |
118 kill_daemon(int (*func)()) | 118 kill_daemon(void (*func)()) |
119 { | 119 { |
120 reg struct delayed_action *dev; | 120 reg struct delayed_action *dev; |
121 reg int i; | 121 reg int i; |
122 | 122 |
123 for (i = 0, dev = d_list; i < MAXDAEMONS; i++, dev++) { | 123 for (i = 0, dev = d_list; i < MAXDAEMONS; i++, dev++) { |
152 for (dev = d_list; dev <= &d_list[MAXDAEMONS-1]; dev++) | 152 for (dev = d_list; dev <= &d_list[MAXDAEMONS-1]; dev++) |
153 /* | 153 /* |
154 * Executing each one, giving it the proper arguments | 154 * Executing each one, giving it the proper arguments |
155 */ | 155 */ |
156 if (dev->d_type == flag && dev->d_time == DAEMON) | 156 if (dev->d_type == flag && dev->d_time == DAEMON) |
157 (*dev->d_func)(dev->d_.arg); | 157 (*dev->d_func)(dev->d_.varg); |
158 } | 158 } |
159 | 159 |
160 | 160 |
161 /* | 161 /* |
162 * fuse: | 162 * fuse: |
163 * Start a fuse to go off in a certain number of turns | 163 * Start a fuse to go off in a certain number of turns |
164 */ | 164 */ |
165 void | 165 void |
166 fuse(int (*func)(), int arg, int time, int type) | 166 fuse(void (*func)(), void *arg, int time, int type) |
167 { | 167 { |
168 reg struct delayed_action *wire; | 168 reg struct delayed_action *wire; |
169 | 169 |
170 wire = f_slot(); | 170 wire = f_slot(); |
171 if (wire != NULL) { | 171 if (wire != NULL) { |
172 wire->d_type = type; | 172 wire->d_type = type; |
173 wire->d_func = func; | 173 wire->d_func = func; |
174 wire->d_.arg = arg; | 174 if (func == changeclass || func == res_strength) |
175 wire->d_.arg = *(int *) arg; | |
176 else | |
177 wire->d_.varg = arg; | |
175 wire->d_time = time; | 178 wire->d_time = time; |
176 fusecnt += 1; /* update count */ | 179 fusecnt += 1; /* update count */ |
177 } | 180 } |
178 } | 181 } |
179 | 182 |
181 /* | 184 /* |
182 * lengthen: | 185 * lengthen: |
183 * Increase the time until a fuse goes off | 186 * Increase the time until a fuse goes off |
184 */ | 187 */ |
185 void | 188 void |
186 lengthen(int (*func)(), int xtime) | 189 lengthen(void (*func)(), int xtime) |
187 { | 190 { |
188 reg struct delayed_action *wire; | 191 reg struct delayed_action *wire; |
189 | 192 |
190 if ((wire = find_slot(func)) == NULL) | 193 if ((wire = find_slot(func)) == NULL) |
191 return; | 194 return; |
196 /* | 199 /* |
197 * extinguish: | 200 * extinguish: |
198 * Put out a fuse | 201 * Put out a fuse |
199 */ | 202 */ |
200 void | 203 void |
201 extinguish(int (*func)()) | 204 extinguish(void (*func)()) |
202 { | 205 { |
203 reg struct delayed_action *wire; | 206 reg struct delayed_action *wire; |
204 | 207 |
205 if ((wire = find_slot(func)) == NULL) | 208 if ((wire = find_slot(func)) == NULL) |
206 return; | 209 return; |
230 * to remove the fuse from the list once it has gone off. | 233 * to remove the fuse from the list once it has gone off. |
231 */ | 234 */ |
232 if(flag == wire->d_type && wire->d_time > 0 && | 235 if(flag == wire->d_type && wire->d_time > 0 && |
233 --wire->d_time == 0) { | 236 --wire->d_time == 0) { |
234 wire->d_type = EMPTY; | 237 wire->d_type = EMPTY; |
235 if (wire->d_func != NULL) | 238 if (wire->d_func == changeclass || wire->d_func == res_strength) |
236 (*wire->d_func)(wire->d_.arg); | 239 (*wire->d_func)(wire->d_.arg); |
240 else if (wire->d_func != NULL) | |
241 (*wire->d_func)(wire->d_.varg); | |
237 fusecnt -= 1; | 242 fusecnt -= 1; |
238 } | 243 } |
239 } | 244 } |
240 } | 245 } |
241 | 246 |