(conditions): Give sentinel a legible desc[], just in case.
(findcondition): Oops on hitting the sentinel. (retreat_ship1, retreat_land1): Don't bother to map code to lower case, it doesn't occur.
This commit is contained in:
parent
021a91a779
commit
cc29b27a67
1 changed files with 28 additions and 41 deletions
|
@ -50,33 +50,31 @@
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
|
||||||
static int findcondition(s_char);
|
static int findcondition(char);
|
||||||
static int retreat_land1(struct lndstr *, s_char, int);
|
static int retreat_land1(struct lndstr *, char, int);
|
||||||
static int retreat_ship1(struct shpstr *, s_char, int);
|
static int retreat_ship1(struct shpstr *, char, int);
|
||||||
|
|
||||||
struct ccode {
|
struct ccode {
|
||||||
s_char code;
|
char code;
|
||||||
s_char *desc[2];
|
char *desc[2];
|
||||||
} conditions[] = {
|
};
|
||||||
{
|
|
||||||
'i', {
|
struct ccode conditions[] = {
|
||||||
"retreated with a damaged friend", "was damaged",},}, {
|
{ 'i', { "retreated with a damaged friend",
|
||||||
't', {
|
"was damaged" } },
|
||||||
"retreated with a torpedoed ship", "was hit by a torpedo",},}, {
|
{ 't', { "retreated with a torpedoed ship",
|
||||||
's', {
|
"was hit by a torpedo" } },
|
||||||
"retreated with a ship scared by sonar",
|
{ 's', { "retreated with a ship scared by sonar",
|
||||||
"detected a sonar ping",},}, {
|
"detected a sonar ping" } },
|
||||||
'h', {
|
{ 'h', { "retreated with a helpless ship",
|
||||||
"retreated with a helpless ship",
|
"was fired upon with no one able to defend it" } },
|
||||||
"was fired upon with no one able to defend it",},}, {
|
{ 'b', { "retreated with a bombed friend",
|
||||||
'b', {
|
"was bombed" } },
|
||||||
"retreated with a bombed friend", "was bombed",},}, {
|
{ 'd', { "retreated with a depth-charged ship",
|
||||||
'd', {
|
"was depth-charged" } },
|
||||||
"retreated with a depth-charged ship", "was depth-charged",},}, {
|
{ 'u', { "retreated with a boarded ship", "was boarded" } },
|
||||||
'u', {
|
{ 0, { "panicked", "panicked"} }
|
||||||
"retreated with a boarded ship", "was boarded",},}, {
|
};
|
||||||
0, {
|
|
||||||
"", ""}},};
|
|
||||||
|
|
||||||
int
|
int
|
||||||
check_retreat_and_do_shipdamage(struct shpstr *sp, int dam)
|
check_retreat_and_do_shipdamage(struct shpstr *sp, int dam)
|
||||||
|
@ -152,9 +150,6 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
|
||||||
if (sp->shp_own == 0)
|
if (sp->shp_own == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (isupper(code))
|
|
||||||
code = tolower(code);
|
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
if (sp->shp_effic < SHIP_MINEFF) {
|
if (sp->shp_effic < SHIP_MINEFF) {
|
||||||
wu(0, sp->shp_own,
|
wu(0, sp->shp_own,
|
||||||
|
@ -341,18 +336,13 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
findcondition(s_char code)
|
findcondition(char code)
|
||||||
{
|
{
|
||||||
int x;
|
int i;
|
||||||
|
|
||||||
x = 0;
|
for (i = 0; conditions[i].code && conditions[i].code != code; i++) ;
|
||||||
while (conditions[x].code) {
|
CANT_HAPPEN(!conditions[i].code);
|
||||||
if (conditions[x].code == code)
|
return i;
|
||||||
return x;
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -427,9 +417,6 @@ retreat_land1(struct lndstr *lp, s_char code, int orig)
|
||||||
if (lp->lnd_own == 0)
|
if (lp->lnd_own == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (isupper(code))
|
|
||||||
code = tolower(code);
|
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
if (lp->lnd_effic < LAND_MINEFF) {
|
if (lp->lnd_effic < LAND_MINEFF) {
|
||||||
wu(0, lp->lnd_own,
|
wu(0, lp->lnd_own,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue