Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: KeldorKatarn on June 19, 2009, 05:55:54 pm
-
Could this be why capships don't use death screams even when assigned a persona and marking "always scream on death"?
// Don't play death scream unless a small ship.
if ( q->builtin_type == MESSAGE_WINGMAN_SCREAM ) {
int t = Ship_info[Ships[Message_shipnum].ship_info_index].flags;
int t2 = SIF_SMALL_SHIP;
int t3 = t & t2;
if (!t3) {
goto all_done;
}
}
Found in void message_queue_process(), missionmessage.cpp
If yes, would it break anything for this to also check for the flag "always scream on death" and if that one is said, it also works for non-small ships? That would take away the need for introducing
an additional flag to get the possibility for capships to have death screams.
-
:wtf:
That is one of the strangest pieces of code I've seen in a long time. Why the hell are they declaring everything into ints they only use once?
Anyway, making it a straightforward check of either SIF_SMALL_SHIP or always scream should be fine. That flag is only set if someone has turned it on in FRED anyway.
-
Ok, preparing a patch...
Here it is
[attachment has decomposed]
-
Gotos make baby Jesus cry.
-
Have to disagree with you there. In some cases goto can be the most sensible flow handler. The problem is that they are often abused resulting in rather rubbish code. Used sparingly and with a great deal of care there is still some use for goto.
-
Well, I didn't put the goto in ;)
What do you say, can this patch be added to trunk? Would help Saga out, we wouldn't have to hack capship death screams in FRED anymore :)
-
Try doing this without gotos:
int parse()
{
Token tok;
reading:
tok = gettoken();
if (tok == END)
return ACCEPT;
shifting:
if (shift(tok))
goto reading;
reducing:
if (reduce(tok))
goto shifting;
return ERROR;
}
Source: http://david.tribble.com/text/goto.html (http://david.tribble.com/text/goto.html)
-
What do you say, can this patch be added to trunk?
I only came here to make sure I got your name correct on the log entry. :D
I edited the patch cause the way they had it (which you'd copied) was rather silly.
-
Have to disagree with you there. In some cases goto can be the most sensible flow handler. The problem is that they are often abused resulting in rather rubbish code. Used sparingly and with a great deal of care there is still some use for goto.
I'd still be wary (http://xkcd.com/292/) of it. :p
-
What do you say, can this patch be added to trunk?
I only came here to make sure I got your name correct on the log entry. :D
I edited the patch cause the way they had it (which you'd copied) was rather silly.
Well I used the two temporary booleans to introduce some names that actually show what's going on. Kept the line shorter and made the if-clause easier to understand for someone
else. Doesn't matter if you got rid of them and put the statements right into the if however. As long as the functionality is there we're happy =)
-
Well the nice thing about ship flags is that they are pretty self explanatory anyway.
-
True enough ;)