New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New RNG #17
New RNG #17
Conversation
On what platforms did you try to compile this? We don't use exceptions, I think mostly due to msvc6 dying on them. Use some other fallback instead. |
I compiled it on Linux and (not gemrb but in another project) on Windows 7 with VS2010.
|
Sure, you can use error(). MSVC6 is old, of course, but one of our main sages is using it still. |
I wanted to merge this, but it seems to be causing corruption somewhere. I can pretty easily get it to crash in our (tile overlay) drawing code, but a valgrind run revealed nothing. Very fishy. |
I remember that I was able to load a BGT savegame with that and everything seemed to work so far. How do you produce the crash? |
combat, but not immediately, so the exact trigger still evades me. Oh, isn't the stdexcept include is now rendundant, with the exception gone? |
I created a new game, entered combat and also experience segfaults unless I kill the enemy with one hit. I opened the core dump and it tells me that the binary was unable to access some memory at plugins/SDLVideo/TileRenderer.inl:144 |
Good, you get the exact same problem. One thing I noticed is that many times the viewport jumped just before that, so perhaps the Viewport var gets corrupted (viewport of frame 3 is fine). Looking further ... |
Yep, scoring a critical hit seems to be a way to trigger it (but works fine without this pull). A screenshake is associated with that, but it's delayed one tick, so it wasn't immediately obvious. I guess the algo can't handle negative arguments? ShakeY can be negative ... |
Yep yep, double confirmed, it's the changes in GlobalTimer.cpp that are causing this. Since the shake can be ordered from scripts, we can't guarantee the params will always be positive, so I suggest two things:
|
I see... I did not expect negative values and as signed values are converted to congruent unsigned values, it has some unintended behaviour (like... crashing ^^). |
I renamed the random function from before and introduced a random function that handles the parameters first. |
Thanks! |
Here is the new RNG I talked about in the forums and I also replaced all rand() calls from gemrb core to use the new RNG:
I'd also like to replace the following rand() calls from the plugins:
but as soon as I do it, I get undefined references to the RNG class from the linker, though it is included in libgem_core.so after building. This is probably a CMake thing.