Simplify build_bridge(): replace a switch by a function pointer
This commit is contained in:
parent
0ec19fe81e
commit
9ef7200406
1 changed files with 5 additions and 10 deletions
|
@ -643,7 +643,8 @@ build_bridge(char what)
|
||||||
{
|
{
|
||||||
struct natstr *natp = getnatp(player->cnum);
|
struct natstr *natp = getnatp(player->cnum);
|
||||||
struct nstr_sect nstr;
|
struct nstr_sect nstr;
|
||||||
int gotsect, built;
|
int (*build_it)(struct sctstr *, short[]);
|
||||||
|
int gotsect;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
|
||||||
switch (what) {
|
switch (what) {
|
||||||
|
@ -652,6 +653,7 @@ build_bridge(char what)
|
||||||
pr("Building a span requires a tech of %.0f\n", buil_bt);
|
pr("Building a span requires a tech of %.0f\n", buil_bt);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
build_it = build_bspan;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (!opt_BRIDGETOWERS) {
|
if (!opt_BRIDGETOWERS) {
|
||||||
|
@ -663,6 +665,7 @@ build_bridge(char what)
|
||||||
buil_tower_bt);
|
buil_tower_bt);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
build_it = build_btower;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CANT_REACH();
|
CANT_REACH();
|
||||||
|
@ -676,15 +679,7 @@ build_bridge(char what)
|
||||||
gotsect++;
|
gotsect++;
|
||||||
if (!player->owner)
|
if (!player->owner)
|
||||||
continue;
|
continue;
|
||||||
switch (what) {
|
if (build_it(§, sect.sct_item))
|
||||||
case 'b':
|
|
||||||
built = build_bspan(§, sect.sct_item);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
built = build_btower(§, sect.sct_item);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (built)
|
|
||||||
putsect(§);
|
putsect(§);
|
||||||
}
|
}
|
||||||
if (!gotsect) {
|
if (!gotsect) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue