Some tweaks to prevent silent errors.

This commit is contained in:
onpon4 2016-11-19 08:34:28 -05:00
parent e9330907b7
commit 7afd322a71
2 changed files with 26 additions and 14 deletions

View File

@ -22,7 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
object alien_defs[CD_MAX];
object aliens[ALIEN_MAX];
static const char *chrisKillMessage[] = {
static const int nChrisKillMessage = 15;
static const char *chrisKillMessage[nChrisKillMessage] = {
"Take that, robot oppressors!",
"Come on, WEAPCO, give me a challenge already!",
"Is that all you've got?",
@ -39,7 +40,9 @@ static const char *chrisKillMessage[] = {
"How do you like that, WEAPCO?",
"Maybe you should change your name to WEEPCO!"
};
static const char *phoebeKillMessage[] = {
static const int nPhoebeKillMessage = 11;
static const char *phoebeKillMessage[nPhoebeKillMessage] = {
"I got another one!",
"Target destroyed!",
"One more for me!",
@ -52,7 +55,9 @@ static const char *phoebeKillMessage[] = {
"We're such a great team!",
"I got it!"
};
static const char *ursulaKillMessage[] = {
static const int nUrsulaKillMessage = 14;
static const char *ursulaKillMessage[nUrsulaKillMessage] = {
"Kicked your ass!",
"You ain't so tough!",
"I was always a better WEAPCO pilot than you!",
@ -1765,7 +1770,7 @@ void alien_destroy(object *alien, object *attacker)
game.totalKills++;
if (((rand() % 16) == 0) && (alien-> flags & FL_WEAPCO))
{
r = rand() % 15;
r = rand() % nChrisKillMessage;
setRadioMessage(FS_CHRIS, chrisKillMessage[r], 0);
}
}
@ -1774,7 +1779,7 @@ void alien_destroy(object *alien, object *attacker)
game.wingMate1Kills++;
if (((rand() % 8) == 0) && (alien-> flags & FL_WEAPCO))
{
r = rand() % 11;
r = rand() % nPhoebeKillMessage;
setRadioMessage(FS_PHOEBE, phoebeKillMessage[r], 0);
}
}
@ -1783,7 +1788,7 @@ void alien_destroy(object *alien, object *attacker)
game.wingMate2Kills++;
if (((rand() % 8) == 0) && (alien-> flags & FL_WEAPCO))
{
r = rand() % 14;
r = rand() % nUrsulaKillMessage;
setRadioMessage(FS_URSULA, ursulaKillMessage[r], 0);
}
}

View File

@ -25,18 +25,25 @@ static Star stars[STARS_NUM];
static Uint32 frameLimit = 0;
static int thirds = 0;
static const char *klineInsult[] = {
static const int nKlineInsult = 3;
static const char *klineInsult[nKlineInsult] = {
"Pathetic.", "How very disappointing...", "Heroic. And stupid."
};
static const char *klineVenusInsult[] = {
static const int nKlineVenusInsult = 2;
static const char *klineVenusInsult[nKlineVenusInsult] = {
"Fool.", "And now you're nothing but a DEAD hero."
};
static const char *phoebePlayerHitMessage[3] = {
static const int nPhoebePlayerHitMessage = 3;
static const char *phoebePlayerHitMessage[nPhoebePlayerHitMessage] = {
"Oops! Sorry!",
"Whoops! Are you OK, Chris?",
"Oh, sorry! I didn't see you there!"
};
static const char *ursulaPlayerHitMessage[3] = {
static const int nUrsulaPlayerHitMessage = 3;
static const char *ursulaPlayerHitMessage[nUrsulaPlayerHitMessage] = {
"Get out of the way!",
"Don't fly into my missiles!",
"Dammit, Chris, you made me miss!"
@ -713,11 +720,11 @@ static void game_doBullets()
{
if (bullet->owner->classDef == CD_PHOEBE)
{
setRadioMessage(FS_PHOEBE, phoebePlayerHitMessage[rand() % 3], 0);
setRadioMessage(FS_PHOEBE, phoebePlayerHitMessage[rand() % nPhoebePlayerHitMessage], 0);
}
else if (bullet->owner->classDef == CD_URSULA)
{
setRadioMessage(FS_URSULA, ursulaPlayerHitMessage[rand() % 3], 0);
setRadioMessage(FS_URSULA, ursulaPlayerHitMessage[rand() % nUrsulaPlayerHitMessage], 0);
}
}
@ -1452,9 +1459,9 @@ static void game_doPlayer()
if (aliens[ALIEN_KLINE].active)
{
if (game.area == MISN_VENUS)
setRadioMessage(FS_KLINE, klineVenusInsult[rand() % 2], 1);
setRadioMessage(FS_KLINE, klineVenusInsult[rand() % nKlineVenusInsult], 1);
else
setRadioMessage(FS_KLINE, klineInsult[rand() % 3], 1);
setRadioMessage(FS_KLINE, klineInsult[rand() % nKlineInsult], 1);
}
else if ((aliens[ALIEN_BOSS].active) && (aliens[ALIEN_BOSS].classDef == CD_KRASS))
{