From b70653815c6fbd76f703bb2ac81a56f5ccb34dd4 Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Mon, 24 Jul 2006 13:40:12 +0000 Subject: [PATCH] (get_empobj_mob_max): New. Return maximum mobility based on ef_type. (miss): Use new get_empobj_mob_max(). --- include/empobj.h | 1 + src/lib/commands/miss.c | 14 +------------- src/lib/common/empobj.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/empobj.h b/include/empobj.h index 4c6825700..b2ef2252c 100644 --- a/include/empobj.h +++ b/include/empobj.h @@ -87,5 +87,6 @@ union empobj_storage { extern char *obj_nameof(struct empobj *gp); extern int put_empobj(struct empobj *gp); extern void *get_empobj_chr(struct empobj *gp); +extern int get_empobj_mob_max(int ef_type); #endif diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index 2e5f723b5..9880a363f 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -178,20 +178,8 @@ mission(void) desired_radius = 9999; } - switch (type) { - case EF_SHIP: - mobmax = ship_mob_max; - break; - case EF_LAND: - mobmax = land_mob_max; - break; - case EF_PLANE: - mobmax = plane_mob_max; - break; - default: - CANT_HAPPEN("bad TYPE"); + if ((mobmax = get_empobj_mob_max(type)) == -1) return RET_FAIL; - } mobused = ldround(mission_mob_cost * (double)mobmax, 1); diff --git a/src/lib/common/empobj.c b/src/lib/common/empobj.c index 5122d13b0..af371bbd1 100644 --- a/src/lib/common/empobj.c +++ b/src/lib/common/empobj.c @@ -37,6 +37,7 @@ #include "empobj.h" #include "file.h" +#include "optlist.h" #include "prototypes.h" char * @@ -101,3 +102,21 @@ get_empobj_chr(struct empobj *gp) } return cp; } + +int +get_empobj_mob_max(int ef_type) +{ + switch (ef_type) { + case EF_SHIP: + return ship_mob_max; + case EF_LAND: + return land_mob_max; + case EF_PLANE: + return plane_mob_max; + case EF_SECTOR: + return sect_mob_max; + default: + CANT_REACH(); + return -1; + } +} -- 2.43.0