Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Explanation of code - no declaration of variable


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 kyborg   Members   -  Reputation: 107

Like
0Likes
Like

Posted 16 July 2012 - 01:36 PM

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. [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

Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6991

Like
9Likes
Like

Posted 16 July 2012 - 01:45 PM

It's a global variable, defined at line 42 of the same file.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#3 BinaryPhysics   Members   -  Reputation: 294

Like
2Likes
Like

Posted 16 July 2012 - 08:00 PM

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, 19 July 2012 - 03:11 PM.


#4 Cornstalks   Crossbones+   -  Reputation: 6991

Like
1Likes
Like

Posted 16 July 2012 - 08:03 PM

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, 16 July 2012 - 08:04 PM.

[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#5 jbadams   Senior Staff   -  Reputation: 19409

Like
1Likes
Like

Posted 16 July 2012 - 10:43 PM

Why was this downvoted? I mean, seriously? Negated..

Moderator response (collapsed so as to not fill the topic with off-topic chat)


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

#6 Acotoz   Members   -  Reputation: 73

Like
0Likes
Like

Posted 16 July 2012 - 10:55 PM

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

#7 jbadams   Senior Staff   -  Reputation: 19409

Like
0Likes
Like

Posted 16 July 2012 - 11:02 PM

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 no further off-topic replies from this point onward.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS