XP bar bugs
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/
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.
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.
Currently we are using github as our code hosting platform and git as the version control.
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
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.
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)));
}
Did you really get 2B XP?
Or were you doing some kind of modding of enemy XP? Or save file modding? Just curious.
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...
I have plenty of ideas, but little in the way of artistic flair unfortunately.
Pur
By the way, Pur was taken on GitHub so I had to make do with puros.
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.
Cool.
So what bugs are you looking for amd where do I post them?
Pur
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.
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