Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Genghis on March 16, 2010, 10:26:51 pm

Title: Bugfix + is there a good place for utility macros?
Post by: Genghis on March 16, 2010, 10:26:51 pm
I submitted a candidate fix patch for bug 2132 (http://scp.indiegames.us/mantis/view.php?id=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?
Title: Re: Bugfix + is there a good place for utility macros?
Post by: General Battuta on March 16, 2010, 10:35:26 pm
This man knows OpenGL! We must obtain him!
Title: Re: Bugfix + is there a good place for utility macros?
Post by: Goober5000 on March 16, 2010, 11:15:25 pm
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?
Title: Re: Bugfix + is there a good place for utility macros?
Post by: General Battuta on March 16, 2010, 11:16:19 pm
Cargo has nothing to do with it, but he knows OpenGL. Haven't you guys been after an OpenGL coder for a long time?
Title: Re: Bugfix + is there a good place for utility macros?
Post by: karajorma on March 17, 2010, 02:29:13 am
Couldn't you just use sprintf() to output the value instead? That seems to be how the code tends to do things.
Title: Re: Bugfix + is there a good place for utility macros?
Post by: Genghis on March 17, 2010, 06:04:32 am
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.
Title: Re: Bugfix + is there a good place for utility macros?
Post by: karajorma on March 17, 2010, 06:15:57 am
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?
Title: Re: Bugfix + is there a good place for utility macros?
Post by: Genghis on March 17, 2010, 08:42:23 am
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 (http://scp.indiegames.us/mantis/file_download.php?file_id=1448&type=bug).

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 (http://scp.indiegames.us/mantis/view.php?id=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.
Title: Re: Bugfix + is there a good place for utility macros?
Post by: karajorma on March 17, 2010, 09:20:01 am
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. :)