Sign in to follow this  
kyborg

Explanation of code - no declaration of variable

Recommended Posts

kyborg    107
Hello,
I found this part of code on github, its from some Dwarf Fortress mode. [url="https://github.com/peterix/stonesense/blob/master/GUI.cpp"]link[/url] (it starts on line 946)

[source lang="cpp"]
void paintboard()
{
uint32_t starttime = clock();

int op, src, dst, alpha_op, alpha_src, alpha_dst;
al_get_separate_blender(&op, &src, &dst, &alpha_op, &alpha_src, &alpha_dst);
al_set_separate_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO,ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO);
if(config.transparentScreenshots)
{
al_clear_to_color(al_map_rgba(0,0,0,0));
}
else
{
al_clear_to_color(al_map_rgb(config.backr,config.backg,config.backb));
}
al_set_separate_blender(op, src, dst, alpha_op, alpha_src, alpha_dst);

// lock segment for painting and retrieve it.
[b]map_segment->lock();[/b]
WorldSegment * segment = map_segment->get();
...
[/source]
I am thinking about variable map_segment, because it wasnt declared in this function nor passed. But I dont think there is a mistake. So can you tell me how is this possible?

Thanks for answers

Share this post


Link to post
Share on other sites
Alex Melbourne    294
Just as a side note - that code comes with a solution file for Visual Studio. If you download that you can right-click on any variable, constant (basically any identifier) and click "Go To Definition".

Brilliant tool for looking at other people's code. Edited by BinaryPhysics

Share this post


Link to post
Share on other sites
Cornstalks    7030
[quote name='BinaryPhysics' timestamp='1342490400' post='4959832']
Just as a side not that code comes with a solution file for Visual Studio. If you download that you can right-click on any variable, constant (basically any identifier) and click "Go To Definition".

Brilliant tool for looking at other people's code.
[/quote]
Or hit F12. I hit it all the time. Edited by Cornstalks

Share this post


Link to post
Share on other sites
jbadams    25676
[quote name='Bacterius' timestamp='1342495641' post='4959852']
[size=2]Why was this downvoted? I mean, seriously? Negated..[/size]
[/quote]
[rollup='Moderator response (collapsed so as to not fill the topic with off-topic chat)'][size=3]If you hover over the down-vote button you'll see some descriptive text pop up saying "this response is not useful and does not improve the conversation"; I'm guessing someone thought that appropriate given Acotoz gave a less detailed version of the exact same response that the previous user (Cornstalks) had already given around three and-a-half hours earlier. Personally -- although I didn't go to the effort of down-voting the post myself -- I'd have to agree: even though the post is factually correct, taken in context it's a pointless response that adds no value what-so-ever to the conversation, and as such down-voting it is correct usage of the system.[/size]

[size=3]This is all well-and-truly off-topic however, and I'd ask you not to risk disrupting topics with this sort of post in future -- if you want to query a vote (or the concept of voting in general) you can make a topic in the Comments, Suggestions & Ideas forum, or contact a moderator privately -- we do investigate abuses of the system and have on occasion reversed votes we believe to be unfair or out of keeping with the spirit in which the system was intended.[/size][/rollup]

[b]It would be appreciated if there were no further off-topic replies from this point onward. [img]http://public.gamedev.net//public/style_emoticons/default/cool.png[/img][/b]

Share this post


Link to post
Share on other sites
Acotoz    73
Wait a minute, I thought I was the first response of this forum post.

That's why it seems like I'm posting something pointless

Share this post


Link to post
Share on other sites
jbadams    25676
A short time after the previous reply was posted that would be perfectly excusable... over three hours after the previous response though...? In any case...
[quote name='jbadams' timestamp='1342500239' post='4959863']
[b][size=4]It would be appreciated if there were [color=#ff0000]no further off-topic replies[/color] from this point onward.[/size][/b]
[/quote]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this