Skip to main content

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password
Register
  • Home
  • Browse
    • 2D Art
    • 3D Art
    • Concept Art
    • Textures
    • Music
    • Sound Effects
    • Documents
    • Featured Tutorials
  • Submit Art
  • Collect
    • My Collections
    • Art Collections
  • Forums
  • FAQ
  • Leaderboards
    • All Time
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
    • Weekly
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
  • ❤ Donate
FLARE [ARCHIVED]

XP bar bugs

Pur
Wednesday, June 5, 2013 - 18:11

I decided to test out the limits of the XP bar since I saw it behaving strangely at times.  I managed to get it to level 16 where it bumped up to 2B+ XP required for the next level, and the progress showed up once, when I was around 60% of the way through level 16, then disappeared again.  When I gained enough XP to level to 17, it rolled the current XP over to -2B.

I'll look at the class and see if I can work out the bugs.

The question is... how do I submit the changes?  It's been a loooong time since I submitted changes other than directly to the repository and I assume you don't want to give that access to just anyone.

Let me know what your preferred method is.

Pur

P.S.  If you want to see a game that could really use an engine like this, check out http://www.nethack.org/

 

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Wednesday, June 5, 2013 - 19:35

The following changes to MenuStatBar::render() fixes the issue with big numbers.  Note that one goes in each orientation section, one using bar_pos.w and the other bar_pos.h

       else bar_length = (1.0 * stat_cur) * (1.0*bar_pos.w) / (1.0*stat_max);

       else bar_length = (1.0 * stat_cur) * (1.0*bar_pos.h) / (1.0*stat_max);

Pur

P.S. I just realized the current download is still 0.18 so these fixes may already be in 0.19.  :P  To check, just go to a saved game save and change xp to 2000000000 (2 Billion).  Then to check the overflow issue, set the miners to give 100000000 XP (100 Million) and go kill a few.

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Wednesday, June 5, 2013 - 19:32

Ding!  Level 17!

LOL

That's what you get when you add the following to CampaignManager::rewardXP

    hero->xp += (amount * (100 + hero->effects.bonus_xp)) / 100;
    if (hero->xp < 0) hero->xp = std::numeric_limits<int>::max();    /* added */
    hero->refresh_stats = true;

and of course the include at the top:

    #include <limits>

If it's already fixed then just ignore me.

  • Log in or register to post comments
Stefan Beller
joined 13 years 2 months ago
Thursday, June 6, 2013 - 03:54

Currently we are using github as our code hosting platform and git as the version control.

  • get an account at github.com
  • click on fork at https://github.com/clintbellanger/flare-engine/
  • use git to get a local copy to your computer (depending on your operating system, maybe see http://windows.github.com/ for a decent windows client, or install git, git gui directly from your package repository of your linux distribution
  • apply changes at your local copy
  • commit these changes to your local repository
  • push it to github/<yourusername>/flare-engine
  • open a "Pull request" to request your changes being pulled to the mainline repository again

 

 

  • Log in or register to post comments
Stefan Beller
joined 13 years 2 months ago
Thursday, June 6, 2013 - 04:06

The first bug is not yet fixed, though we're slowly approaching 0.19. As I am unsure whether you want to contribute in long term (and so many steps to go through may have annoyed you) I propose a patch. Instead of using floating points, I think long integers should also be fine.

Please see https://github.com/clintbellanger/flare-engine/pull/696

  • Log in or register to post comments
Stefan Beller
joined 13 years 2 months ago
Thursday, June 6, 2013 - 04:16

For you second bug found, I did a proposal here:
https://github.com/clintbellanger/flare-engine/pull/697

Thank you very much for the bug reports. Reporting bugs is essential to make flare a good game :)
I hope you still have fun playing flare, although these bugs existed in the first place.

 

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Wednesday, June 12, 2013 - 08:45

Changing XP to unsigned long (https://github.com/clintbellanger/flare-engine/pull/697) will re-introduce the issue fixed in the stat bar (https://github.com/clintbellanger/flare-engine/pull/696) because a long * int gives up to 96 bits result which will not fit into a 64-bit long.  Also, MenuStatBar::update() requires an int, and you'd be sending it an unsigned long value.

The problem I was pointing out was that at the hard limit of XP, when you gain more XP, it will roll over when it should just stick at that limit.

Suppose for the sake of oversimplification that XP was unsigned byte.  You go out and kill a zombie and go to 1 XP.  254 zombies later you are up to 255 XP.  One more kill and you end up with 256 XP.  But you only get back the BYTE value which in this case is... (byte)256 = 0 XP.

My solution posted above would check to see if there were a rollover and if so, just reset it to max XP.

Of course what I posted would fail for an unsigned, and would be a serious "hack" if there were some way for a starting character to loose XP.

A better solution would be to use longs for the math, then use the min() of that and (long)std::numeric_limits<int>::max()

If you wish to keep unsigned long for the XP, then anything dealing with stats needs to be able to handle unsigned longs.  It's easy enough to find these places; just go into your save file and set your XP=3000000000 (3 Billion) which will show up as negative anywhere you haven't dealt with unsigned long values.

To fix just the overflow, something like the following should work (untested):

void CampaignManager::rewardXP(int amount, bool show_message) {
    unsigned long max_gain = std::numeric_limits<unsigned long>::max() - hero->xp;
    unsigned long xp_gain = ((unsigned long)amount *
           (100 + hero->get(STAT_XP_GAIN))) / 100;
    hero->xp += min(xp_gain, max_gain);
    hero->refresh_stats = true;
    if (show_message) addMsg(msg->get("You receive %d XP.", min(xp_gain, max_gain)));
}

 

  • Log in or register to post comments
Clint Bellanger
joined 15 years 8 months ago
Thursday, June 13, 2013 - 07:57
Clint Bellanger's picture

Did you really get 2B XP?

Or were you doing some kind of modding of enemy XP? Or save file modding? Just curious.

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Thursday, June 13, 2013 - 18:24

I did some of both.  The first post (above) was done by changing Miner enemy file to give a few mil XP.  That way I could see how the XP bar behaved as it advanced, as well as what happened when it hit the hard limit.

More recently, XP was changed to unsigned long, so I just edited a save file to 3B XP.  When I log them in the XP bar tooltip shows -1294967296/-256.

One thing that I do know is that if you give out code, there is no guarantee as to what people will try to get it to do, so a test suite is pretty much mandatory in my experience.  I won't mention a certain MMO that started with code for a MUD.  :P

On another note...

If you are open to suggestions on improving the quest line in the alpha...

  1. Have Sir Evan Maddox give a quest when he dies, "Avenge me..." that leads to the old (wo)man hiding from the undead in the Avergard Complex.
  2. In the complex the old (wo)man nods and says they remember the young man who betrayed the lord.  He fled to the mines and hasn't been seen since.
  3. That leads obviously to the Necromancer Apprentice who betrayed his lord in turning to the dark side then fled to the mines.
  4. This apprentice in turn could drop a clue leading to the brothers.  (Can the engine handle things like note and maps objects?)

I have plenty of ideas, but little in the way of artistic flair unfortunately.

 Pur

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Thursday, June 13, 2013 - 18:26

By the way, Pur was taken on GitHub so I had to make do with puros.

 

  • Log in or register to post comments
Clint Bellanger
joined 15 years 8 months ago
Thursday, June 13, 2013 - 18:26
Clint Bellanger's picture

Ah that's fine. This isn't the kind of game that warrants a test suite. I expect people to mess with the code and data, that's a big part of why it's open source.

Worst that could happen, someone cheats at a single player game? I guess the actual worst is if they manage to crash the engine, but maybe that turns into a bug report.

The Alpha quest line is sort of done. It may be revived/retold later, but it will be mostly replaced for 0.19.

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Thursday, June 13, 2013 - 19:00

Cool.

So what bugs are you looking for amd where do I post them?

Pur

 

  • Log in or register to post comments
Clint Bellanger
joined 15 years 8 months ago
Thursday, June 13, 2013 - 19:04
Clint Bellanger's picture

The engine and the game have different issues lists.

https://github.com/clintbellanger/flare-engine/issues

https://github.com/clintbellanger/flare-game/issues

Report any bugs you don't already see, especially any that cause the game to crash. 

  • Log in or register to post comments
Pur
joined 12 years 2 days ago
Thursday, June 13, 2013 - 19:12

No crashes yet except for leaving out the default mods directory.  :P

By the way, I finished off the brothers before I ever heard about blowing up the pillar.  I thought it was obvious that since I had teleport (and anyone could go buy the boots) that that was the way across.

/shrug

Pur

 

  • Log in or register to post comments