Jump to content
  • Advertisement
Sign in to follow this  
kyborg

Explanation of code - no declaration of variable

This topic is 2346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,
I found this part of code on github, its from some Dwarf Fortress mode. link (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.
map_segment->lock();
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
Advertisement
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

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.

Or hit F12. I hit it all the time. Edited by Cornstalks

Share this post


Link to post
Share on other sites

[size=2]Why was this downvoted? I mean, seriously? Negated..

[rollup='Moderator response (collapsed so as to not fill the topic with off-topic chat)']

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.

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.[/rollup]

It would be appreciated if there were no further off-topic replies from this point onward. cool.png

Share this post


Link to post
Share on other sites
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
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...

It would be appreciated if there were [color=#ff0000]no further off-topic replies from this point onward.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!