Thread: CODE Tags script bug

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446

    CODE Tags script bug

    Thanks for implementing again the code tag script. However there is some problem with it.

    I cannot reply with the text in attachment.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Hmm.
    Quote Originally Posted by Mario F.
    Nevermind. I see the brick definition on a previous post.

    So... let's go back.

    With the resize (which I don't suggest), your Brick class must have a default constructor. And it could be something like this:

    Code:
    class Brick : public Object
    {
    public:
                // Brick(int x, int y, unsigned int w, unsigned int h, int new_hp);
                Brick(int x = 0, int y = 0, unsigned int w = 0, unsigned int h = 0, int new_hp = 0);
                void SetHP(int num);
                int GetHP();
    protected:
                
    private:
                int hp;
    };
    This allows you to create a Brick instance without passing it any initializer. Just what the resize( ) needs. However, you will then have to set x, y, w and others inside the loops.

    With the former reserve( ) option, you don't need to mess with the Bricks constructor. You will do the loops like this:

    Code:
     
    bricks.reserve(rows);
          for(int y = 0; y < rows; y++)
          {
                  bricks.push_back();
                  bricks[y].reserve(columns);
                  for(int x = 0; x < columns; x++)
                  {
                          bricks[y].push_back(y, x, whatever_w_is, whatever_h_is, whatever_new_hp_is);
                          bricks[y][x].SetWidth(brick_w);
                          bricks[y][x].SetHeight(brick_h);
                          bricks[y][x].SetHP(brick_hp);
                          bricks[y][x].SetX( brick_x + (brick_w * x) );
                          bricks[y][x].SetY( brick_y + (brick_h * y) );
                  }
          }
    I think that should work of the top of my head. However, It does confuses me slightly those reserves on second thought. If you have something like, say, a 50 by 50 grid (which would be huge on a breakout type of game), those reserve( ) will not give you any benefit. This is a function that is better used on fast growing arrays with respectable dimensions. I would probably lose the reserve( ) lines altogether.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    Works fine for me...if I change the code tags to lowercase.
    There is a difference between tedious and difficult.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    And it came to pass that the code tag checking script was restored for the masses.
    Verily, there was much rejoicing and merriment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Absolutely! Good riddance code-tags-I-have-an-idea threads!
    My first experience with it was however... unpleasant. But I got it right now.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    silly me, I always just type the tags I need in my replies.
    [ and boy am I lazy with the shift key ..maybe that's why I never have problemswith my tags ]
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  7. #7
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Quote Originally Posted by Salem
    And it came to pass that the code tag checking script was restored for the masses.
    Verily, there was much rejoicing and merriment.
    But not yet a quick tag button ... sigh

  8. #8
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    > Rod y Gab

    Excellent video twomers. I only wished the bloody camera stayed still. The director should be shot.

    But it reminds me of some of the Gipsy Kings concerts with unknown invited guests. These "unknowns" where really people they were helping to come out of the woodwork in their own countries at least. Master(!!) guitar players some of them. I will never forget a concert in Madrid (or was it Barcelona?) where they had this blind guy playing with the guitar lying down on his lap (no, it was not Jeff Healey). He played faster than these two. It's... yeah!
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    Moderately Rabid Decrypt's Avatar
    Join Date
    Feb 2005
    Location
    Milwaukee, WI, USA
    Posts
    300
    Verily, there was much rejoicing and merriment
    [monty python] yaaaaaaaaay. [/monty]
    There is a difference between tedious and difficult.

  10. #10
    Administrator webmaster's Avatar
    Join Date
    Aug 2001
    Posts
    1,012
    Whoops. This should be fixed now.

  11. #11
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    [code][/code][C O D E][/C O D E] (ignore spaces)

    Both of the above used to work before, now only the small one does.

  12. #12
    Administrator webmaster's Avatar
    Join Date
    Aug 2001
    Posts
    1,012
    Both of the above used to work before, now only the small one does.
    Are you sure you're not just seeing a caching issue?

  13. #13
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    I dunno. I downloaded Martin's color coder, and it automatically puts the code tags to caps. Meh, I'll just have to deal with it I put it on my sig cause I didn't want to make a new thread about something code-tag related and forgot about this one. Now that I know someone knows though. Woo! Smaller sig

  14. #14
    Administrator webmaster's Avatar
    Join Date
    Aug 2001
    Posts
    1,012
    Code:
    {
    all caps code tags...
    }

  15. #15
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    I noticed Used that code tagger, and didn't have to change it to lower case best webmaster ever!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code tags bug
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 06-05-2006, 08:25 PM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Use Code Tags!
    By Govtcheez in forum C++ Programming
    Replies: 9
    Last Post: 09-06-2001, 12:57 PM
  5. Use Code Tags!
    By Govtcheez in forum C Programming
    Replies: 7
    Last Post: 09-04-2001, 06:54 PM