Author Topic: Briefing text coloring bug fix  (Read 10058 times)

0 Members and 3 Guests are viewing this topic.

Offline pedro

  • 23
Briefing text coloring bug fix
Hello everybody.

karajorma told me to fix this bug http://scp.indiegames.us/mantis/view.php?id=1992. I still don't have a working mantis account  :((BTW: can someone assign a random password to pedro mantis account ?), that's why I'm posting here a note in order to share my correction proposal.

The color bug has two causes:
1 - brief_color_text_init terminates every lines by a {letter=0 color=0 } colored_char. It is useless to add a strign termination character because the SCP_vector stores the string length. In addition it makes SCP_vector.size() = string length +1 which is not intuitive.
2 - brief_render_line draws briefing lines made of character sequences separated by spaces with the color of the last character of the sequence. FUBAR-BDHR notes shows every line are terminated by a {letter=0 color=0 } colored_char. This char is part of the character sequence because it is not a whitespace (whitespace is char 32, not 0), as a consequence the color 0 is used to draw the last character sequence of a line. This is surprising that this method tries to detect words because the coloring information have already been built by brief_color_text_init function. It would be more appropriate to focus on character colors.

I propose a double fix where the two fix are sufficient to solve mantis issue (http://scp.indiegames.us/mantis/view.php?id=1992):
1 - Modify brief_color_text_init to remove the extra terminal character
2 - Rewrite brief_render_line to work with character sequences delimited by color change.

Note that the current implementation of brief_color_text_init does not recognize ',.:;()' as word separators which causes the dot of "$g DELTA." string to be green whereas It could be considered to be white. I can fix it too, but it's a behavior modification, and I'm not able for now to be sure it's not going to add bugs.

Corrections are tested. I have a svn patch waiting for approval. I'm still not aware of the code commit procedure. Can someone show me the way ?

Thanks.
« Last Edit: November 09, 2009, 06:45:00 am by pedro »

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Briefing text coloring bug fix
Just post the patch here and someone (probably me) will check it over and commit it to SVN crediting you for it.

Changing the behaviour to recognise ,.:; etc would probably be a good idea but I'd like to hear if anyone is going to be screwed over by such a change before I suggest that you do it. 
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Briefing text coloring bug fix
Well the one problem I can think of are some of those missions where :v: forgot you couldn't use ; so there are extra lines of text in the missions. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline pedro

  • 23
Re: Briefing text coloring bug fix
Well the one problem I can think of are some of those missions where :v: forgot you couldn't use ; so there are extra lines of text in the missions.  

Sorry, I didn't get you. Do you mean the ";" character has a special meaning when used in briefing text ? Have you an example of what should work and what shouldn't ?
« Last Edit: November 09, 2009, 07:17:38 am by pedro »

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Steam
    • Twitter
    • ModDB Feature
Re: Briefing text coloring bug fix
And any mediavp missions having issue with it I'll be more than happy to correct or report on.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Briefing text coloring bug fix
Well the one problem I can think of are some of those missions where :v: forgot you couldn't use ; so there are extra lines of text in the missions.  

Sorry, I didn't get you. Do you mean the ";" character has a special meaning when used in briefing text ? Have you an example of what should work and what shouldn't ?

";" signifies a comment in mission files, everything past that will IIRC be ignored by the parser.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Briefing text coloring bug fix
E is right.  There are places where :v: forgot that in creating their own missions so you have things like this: (note not an actual example)

"You will be flying ship type x, however, weapons will be limited to y."
; however, weapons will be limited to y."
; however, weapons will be limited to y."
; however, weapons will be limited to y."

So if you made the ; parse correctly your briefing would then be:

"You will be flying ship type x, however, weapons will be limited to y.  ; however, weapons will be limited to y.; however, weapons will be limited to y.; however, weapons will be limited to y."

While they can be fixed in the MediaVP versions running with retail data would result in messed up text in some cases. 

No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Briefing text coloring bug fix
Isn't there a "$Semicolon" for inserting those into text in mission?

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Briefing text coloring bug fix
Either that or something close to it.  It was added awhile back (between 3.6.9 and 3.6.10 I believe) since people kept using them and occasionally it messed up missions. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Steam
    • Twitter
    • ModDB Feature
Re: Briefing text coloring bug fix
Well, I can also place fixed versions of the retail where necessary in to MV_Core which would still allow for full Retail experience.

I know of several of the missions in question.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Briefing text coloring bug fix
To be honest what you do with ; depends on the order these things work in. I suspect the game replaces any instance of $semicolon with a ; long before it gets to colouring the briefing text. In which case it shouldn't matter if Pedro makes the game treat ; differently from the way it does now.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline pedro

  • 23
Re: Briefing text coloring bug fix
Karajorma is true. I wandered the code, and here is what I found.

- First the mission text file is read and strip_comments function recognize several comment (including";") and then removes them.
- Then lcl_replace_stuff recognize and replace the following tokens: $callsign, $rank, $quote and $semicolon.
- And finally, brief_text_colorize scan the a string where comment have been removed, and where ";" exists because of $semicolon. In the given string there can be $f, $h.
All in all, I'm not going to break the mission parsing algorithm by changing the character colors.

I'm going to change the coloring algorithm (if you are ok) and consider the following character to be word separators:
[0;47] for a lot of chars including !"#$%&'()*+,-./
[58;64] for :;<=>?@
[91;94] for [\]^
{96} for  `
[123;127] for {|}~

And any mediavp missions having issue with it I'll be more than happy to correct or report on.
Feel free to report issues in mantis and assign them to me.
« Last Edit: November 10, 2009, 04:58:26 pm by pedro »

  

Offline pedro

  • 23
Re: Briefing text coloring bug fix
Here are the behavior modification introduced.
I detected a minor memory access out of allocated memory, that can be fixed.

- "$g Alpha_one, and $g     Delta." gives Alpha_one, and Delta." whereas it gave "Alpha_one, and Delta.".
- "Something $g" gives "Something" whereas it gave "Something $g".
- "Something $" gives "Something $" whereas it gave an unpredictable result because of the coloring depend on the char after the \0 of the given C string.

I tested it on several mission, the best would be to be able to process the complete mission list of freespace2 (any idea on how to do it ?).

A patch has been posted to the mantis.
« Last Edit: November 11, 2009, 03:11:00 am by pedro »

 

Offline Aardwolf

  • 211
  • Posts: 16,384
Re: Briefing text coloring bug fix
:welcome:

Greetings. Apparently you've already got contacts inside the SCP... nice to see more coders here, I guess.

 

Offline pedro

  • 23
Re: Briefing text coloring bug fix
Thanks. Nice to meet you Aardwolf.

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Steam
    • Twitter
    • ModDB Feature
Re: Briefing text coloring bug fix
A patch has been posted to the mantis.

Naturally, I read this just after getting to work. I'll test this out on the MediaVP missions in a test build as soon as I get home. Hopefully, we can combine this with the ability to have coloured text in De-Briefings as well as expanding on the currently available colours.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Briefing text coloring bug fix
Either that or something close to it.  It was added awhile back (between 3.6.9 and 3.6.10 I believe) since people kept using them and occasionally it messed up missions.
It was added on 5 September 2003, actually, which would make it just before 3.5.5.
« Last Edit: November 11, 2009, 08:34:58 pm by Goober5000 »

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Briefing text coloring bug fix
http://scp.indiegames.us/mantis/view.php?id=1753

Might have been added then but the work around wasn't added until March 29, 2009
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Briefing text coloring bug fix
...no, that's simply the briefing automatically replacing a ; token with a $semicolon token before it saves the file.  Related, but not the same feature.

 

Offline pedro

  • 23
Re: Briefing text coloring bug fix
I really would like to parse every mission file I have extracted from the original game, in order to extract the mission briefing and compare the resulting coloring of the new code to the previous ones. I hope to detect improvements and regressions. I have several questions:

Are colored texts currently used for something else than briefing ?

I succeeded to build a new exe from "code" VC Project adding fredstubs.cpp bus mission parsing function makes model lookups that fails because I don't run enough engine startup code. It looks to be easier to parse missions files by myself.

What is the fastest way to extract colored strings?