Commit graph

1906 commits

Author SHA1 Message Date
Wayward Heart
cf43cf005b Don't store Exception objects' messages on the stack. 2024-08-27 22:20:36 -05:00
Wayward Heart
181192cb04 Close the SDL_RWops when we're done with it when loading midi audio. 2024-08-19 01:16:03 -05:00
Wayward Heart
891b1fd9f7 Don't close audio streams until we're sure we've found a file, and always attempt to load the requested file if the stream is closed.
This matches RGSS's behavior should an Audio method be called for a non-existent file, and prevents a segfault if an attempt raises an error and then play is called again for the previously playing file.

As part of this fix, we're now storing the SDL_RWops for audio streams directly in the source structs.
2024-08-19 01:16:03 -05:00
刘皓
f6b67ec99e
Remove the global volume multiplication by 0.8
This commit removes the multiplication of all OpenAL output by 0.8 added
by 4560589e25 because I feel like the 0.8
factor served no purpose other than to fix perceived problems with the
volume scale, which the commit that this pull request is part of is
supposed to address. Feel free to revert this commit if it turns out the
0.8 factor served some other purpose.
2024-08-07 01:06:45 -04:00
刘皓
f0294b0390
Change "35 dB" to "-35 dB" to be more accurate 2024-08-06 22:01:36 -04:00
刘皓
34d22dd809
Remove useless #include "al-util.h" from config.h 2024-08-06 16:28:20 -04:00
刘皓
684f3ac522
Use std::pow instead of std::powf 2024-08-06 16:26:23 -04:00
刘皓
6082a88511
Make the dB scale option 0 instead of the linear scale 2024-08-06 16:05:11 -04:00
刘皓
a7c59b13c6
Remove quadratic scaling from fadeInThread 2024-08-06 15:55:23 -04:00
刘皓
4a5328ba14
Add config option for volume scale 2024-08-06 15:50:06 -04:00
刘皓
d04b383667
Apply global volume after applying volume scale 2024-08-06 14:40:41 -04:00
刘皓
aaf5d3c8bf
Add dB volume scale 2024-08-06 12:58:16 -04:00
Wayward Heart
4bb13b9958 win32_wrap: add OEM keys
Actual values can vary by country, but these should be good defaults.
Values taken from Joiplay's src/input.cpp.
2024-08-03 04:04:55 -05:00
Wayward Heart
347ef9f53c Guard against disposed source bitmaps in Bitmap::addFrame 2024-08-02 09:26:51 -05:00
Wayward Heart
130375b6d8 Properly handle uninitialized and reinitialized objects
In RGSS, uninitialized disposable objects (and Fonts, sort of) are technically disposed, and other objects (Tone, Color, Rect, and Table) are created with all values set to 0. It's also possible to reinitialize them, although reinitializing disposables leaks memory.

This commit causes MiniFFI and FileInt objects to improperly raise disposed errors if used while uninitialized, but that feels acceptable to me.
2024-08-02 09:26:51 -05:00
Wayward Heart
99ad4fa636 Throw exceptions for Resets and Exits instead of directly raising.
While this does close small memory leaks, this is mostly for threading reasons. We're not supposed to call rb_raise with the gvl released, and calling rb_raise prevents GFX_UNLOCK from being called, which would cause problems for any games that want to call graphical operations in multiple threads should the user reset.

We're also now calling Graphics.__reset__ and Audio.__reset__ via eval instead of directly calling the functions, in case a game wants to hook them.
2024-08-02 09:26:51 -05:00
Wayward Heart
2622a84c53 Add @autoreleasepool blocks to the macOS specific files.
Without these blocks the strings aren't released until the thread that created them is closed, which means file accesses especially leak memory.

Also refocus the game when closing the keybindings window on macOS.
2024-08-02 09:26:51 -05:00
Wayward Heart
a73f9ccc1f Prevent memory leaks from rb_raise
rb_raise calls longjmp, which bypasses C++ destructors, and also keeps the error for catch blocks from being unallocated if passed by reference, which we do for exceptions.

Some of the calls I left can still jump out of try blocks, which you're not supposed to do, but there shouldn't be any objects with destructors initialized at those points so it's probably fine.
2024-08-02 09:26:51 -05:00
Splendide Imaginarius
1462dc9623
Merge pull request #204 from Splendide-Imaginarius/mkxp-z-fps
Remove framerate restrictions
2024-08-01 23:49:06 +00:00
Splendide Imaginarius
03a91cf444
Merge pull request #206 from Splendide-Imaginarius/mkxp-z-preload-mouse-buttons
win32_wrap: fix mouse buttons
2024-07-30 23:46:14 +00:00
Splendide Imaginarius
3e7ddd0552 win32_wrap: fix mouse buttons 2024-07-29 21:30:32 +00:00
Splendide Imaginarius
68a508b027
Merge pull request #205 from Splendide-Imaginarius/mkxp-z-mouse-hires
Fix mouse position in hires mode
2024-07-29 12:54:36 +00:00
Splendide Imaginarius
ef6ea8afdc
Merge pull request #203 from Splendide-Imaginarius/mkxp-z-symlink
Allow symlinks by default
2024-07-29 12:53:06 +00:00
Splendide Imaginarius
de4740d973 Fix mouse position in hires mode 2024-07-29 02:51:45 +00:00
Splendide Imaginarius
568abc7b26 Remove framerate restrictions
If game devs want to use framerates outside of Enterbrain's arbitrary
restrictions, there's no reason for us to prevent it. Same reason we
don't restrict the resolution.

Fixes https://github.com/mkxp-z/mkxp-z/issues/64
2024-07-29 01:16:21 +00:00
Splendide Imaginarius
084e80b38c Allow symlinks by default
PhysicsFS supports disabling symlinks, but this is intended for
environments where scripts are sandboxed. Since mkxp-z runs Ruby code
unsandboxed, this doesn't yield any practical security benefit for us.
2024-07-28 21:52:50 +00:00
Splendide Imaginarius
3376730416
Merge pull request #198 from Splendide-Imaginarius/mkxp-z-memory-leak-fix
Fix memory leak when disposing a high-res Bitmap
2024-07-15 23:57:26 +00:00
Splendide Imaginarius
67b98534d7
Merge pull request #191 from WaywardHeart/bitmap-memory-leaks
Fix a few memory leaks involving Bitmaps - ONE MAJOR
2024-07-02 22:59:35 +00:00
Splendide Imaginarius
83647b947d Fix memory leak when disposing a high-res Bitmap 2024-07-02 22:52:15 +00:00
Wayward Heart
9221cc7ec2 Fix major memory leak in Bitmap::initFromSurface
c89f3d5bd7 accidentally completely removed the call to free the surface when successfully creating a texture.
2024-06-02 02:02:31 -05:00
Wayward Heart
23e9f6cb1c Move the GFX_LOCK/GFX_UNLOCK call for disposing into disposable.h.
It's currently not (much of) a problem because few or no games use multiple threads, but I believe that ruby can run its garbage collector while the GVL is released, which means that Graphics.update and Graphics.wait are currently not thread safe.

Moving the call to GFX_LOCK into dispose() should fix this.
2024-06-02 01:51:59 -05:00
Wayward Heart
477162d1d3 Ensure that fonts for hires bitmaps get deleted. 2024-06-02 01:51:59 -05:00
Wayward Heart
65aab17dba Release resources if we error in the Bitmap constructor. 2024-06-02 01:51:59 -05:00
Splendide Imaginarius
8fcd6dd605
Merge pull request #182 from Splendide-Imaginarius/mkxp-z-lanczos-sprite-alpha-log
Refactor smooth sprite scaling
2024-04-30 03:06:26 +00:00
Splendide Imaginarius
c12f00c537
Merge pull request #164 from WaywardHeart/snapToBitmap-composite
Graphics::snapToBitmap needs to call p->screen.composite()
2024-04-29 20:55:21 +00:00
Splendide Imaginarius
b42c13a8ca
Merge pull request #163 from WaywardHeart/hang-on-close
Don't hang if the user closes the game while it's still initializing
2024-04-29 20:53:00 +00:00
Splendide Imaginarius
89801da619
Merge pull request #149 from WaywardHeart/viewportDisposablesRGSS1
Use signals to dispose of the children of Viewports in RGSS1
2024-04-29 20:51:10 +00:00
Splendide Imaginarius
7907822a1b Refactor smooth sprite scaling
This implements some of the logic for non-simple sprite scaling, and also
adds debug logging for the remaining missing logic.
2024-04-29 13:27:42 +00:00
Splendide Imaginarius
fc7a55f0b9
Merge pull request #181 from Splendide-Imaginarius/mkxp-z-expensive-log
Log expensive optional operations
2024-04-29 12:59:55 +00:00
Splendide Imaginarius
e929cfb7c7
Merge pull request #98 from WaywardHeart/transparent-blitting
Enable transparent blitting from megatextures.
2024-04-29 12:55:43 +00:00
Splendide Imaginarius
325a49666d Log expensive optional operations
Path caching and atlas dumping incur a nontrivial performance hit, so it's
useful to log that they're happening so that users are reminded to disable
them if they were enabled accidentally.
2024-04-10 22:48:49 +00:00
Splendide Imaginarius
1ed5101d6f Don't dump lores atlas if in hires mode
The lores atlas is empty in this scenario.
2024-04-10 22:46:41 +00:00
Splendide Imaginarius
a15e4aff14
Merge pull request #178 from Splendide-Imaginarius/mkxp-z-sprite-lanczos
Implement smooth scaling for simple sprites
2024-04-02 03:44:55 +00:00
Wayward Heart
8b14894b6f Fix blitting with negative dimensions 2024-03-24 07:47:58 -05:00
Wayward Heart
cf762c77f1 Only draw text to the hires bitmap when Hires mode is enabled 2024-03-24 07:47:58 -05:00
Wayward Heart
46d9095129 Use gl.unpack_subimage when blitting megasurfaces to textures when available 2024-03-24 07:47:58 -05:00
Wayward Heart
7539a2f34b Use SDL_LowerBlitScaled/SDL_SoftStretchLinear instead of SDL_BlitScaled 2024-03-24 07:47:58 -05:00
Wayward Heart
e477007061 Use stretchBlt in drawText 2024-03-24 07:47:58 -05:00
Wayward Heart
c89f3d5bd7 Change the create Bitmap from surface constructor to always take ownership of the surface, and provide an option to leave it as a mega surface 2024-03-24 07:47:58 -05:00
Wayward Heart
bd01e11f56 Fix blitting from megatextures
Code mostly taken from the implementation in Bitmap::drawText
2024-03-24 07:47:57 -05:00