Author Topic: Bugfix + is there a good place for utility macros?  (Read 2017 times)

0 Members and 1 Guest are viewing this topic.

Offline Genghis

  • KHAAAAAAAN!!!
  • 24
    • Linkedin
Bugfix + is there a good place for utility macros?
I submitted a candidate fix patch for bug 2132, I attached it to the bug report in Mantis.

I made it so that it simply displays an error message when the cargo limit is exceeded, and then sets the cargo name to blank (z=-1).  I wasn't sure whether that was the best approach, or if I should set it to z=0, "Nothing"?

The other thing is that in the patch I added a neat little utility macro I use all the time, to help make the error message more friendly by including the value of MAX_CARGO.  Is there a better place for little utility macros and helper functions such as this?

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Bugfix + is there a good place for utility macros?
This man knows OpenGL! We must obtain him!

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Bugfix + is there a good place for utility macros?
What does cargo have to do with OpenGL?

But regardless, we could always use skilled programmers. :)  Would you be interested in joining or following the SCP?

  

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Bugfix + is there a good place for utility macros?
Cargo has nothing to do with it, but he knows OpenGL. Haven't you guys been after an OpenGL coder for a long time?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Bugfix + is there a good place for utility macros?
Couldn't you just use sprintf() to output the value instead? That seems to be how the code tends to do things.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Genghis

  • KHAAAAAAAN!!!
  • 24
    • Linkedin
Re: Bugfix + is there a good place for utility macros?
What does cargo have to do with OpenGL?
  Nothing at all :)  But I needed to start somewhere and tackling small bugs is always a good way-in to a project.

Quote from: karajorma
Couldn't you just use sprintf() to output the value instead? That seems to be how the code tends to do things.
I could have, done yes, although that would cause an extra call to sprintf() every time a ship is updated whereas the macro is all done at compile time.  Makes no difference really, this code isn't performance-critical at all so I'm happy to use sprintf() if that's how it's done everywhere else.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Bugfix + is there a good place for utility macros?
The fix looks okay to me if I swap a sprintf() for the the macro. Setting it to blank is probably a better idea than setting it to "Nothing" as that actually shows in the game as "Nothing" rather than leaving the cargo a mystery IIRC.

I'll commit this in a bit.

What are you thinking of working on next?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Genghis

  • KHAAAAAAAN!!!
  • 24
    • Linkedin
Re: Bugfix + is there a good place for utility macros?
I posted a new patch that uses CString.Format, which seems to be the convention in that code (it's already used further down in the same function).  You can get it here.

Next I was thinking of just going through unassigned bugs and cherry-picking ones that don't have too much design debate and which will help me to understand the engine better.  I was considering 2151 next, since it would help me get to grips with tbl files and so forth.  Looking at the available commentary, tbl files appear to be a bit of a dark horror mystery, so I figured it would be a good place for me to go shine a torch.
« Last Edit: March 17, 2010, 08:45:31 am by Genghis »

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Bugfix + is there a good place for utility macros?
tbl files are in general fairly easy to get to grips with. In this case it's just a matter of a lack of error checking.

So it seems like a pretty good choice. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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