* Free mod audio data that wasn't previously being freed
* Fix memory leaks if sound decoding/init fails
* Remove unnecessary checks
* drain pending sample copies
* more audio decoder freeing
* seems to be memory safe now
- audio_custom_shutdown was being called 4 times per game_deinit lol
- freeing stuff properly, be safe against threads by flagging shutdowns
- add an error path to audio_load_internal
- flag currently destroying nodes
etc
* oops, Lua shouldn't have access to this
* apply review changes
---------
Co-authored-by: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com>
* improve custom behaviors logic
* clarify description of get behavior functions; get name returns last name instead of first; create generic name only when needed
* review
* fix potential buffer overflow
This pr fixes an issue on linux where the function ns_socket_get_id_str always returns empty string.
See glibc implementation of vsnprintf : [vsnprintf implementation](https://elixir.bootlin.com/glibc/glibc-2.36/source/libio/vsnprintf.c#L112). First string parameter is "emptied" before starting the copy.
And I suspect the original snprintf to rewrite twice the same value in id_str (except if I missed something) so we can just remove it.
This issue gives moderator access to all players when they connect/reconnect after adding one player as moderator because all players have the same id : "".
How to reproduce :
Host server (via socket, not coopnet) on sm64coopdx linux version
Add moderator to one player
All new connected or reconnected player are promoted to moderator
When generating multiple actors, if two or more data nodes share the same name, the generated actors can reference the wrong nodes in their display lists/geo layouts.
This results in:
- The wrong nodes compiled into binary files
- Intermediate layouts generated as actors since nothing is referencing them anymore, treating them as root geo layouts
The simplest fix was to first check for the model identifier (renamed to `mDataIdentifier`, since it's no longer related to models) when looking for nodes, to ensure it picks the right node, even if multiple nodes share the same name.
Fixes issue introduced by bb142d5769 because someone didn't check the C standard to verify it was ok to use (it was me).
`strcasestr` is not apart of the C standard and is a GNU extension. Windows does not play well with this. The solution was to define a quite simple custom function partially based on the glibc implementation. Function should be reviewed.
The existing draw distance options don't actually increase the draw distance. It only impacts whether or not distant objects are rendered.
This PR:
- Adds another option to the draw distance setting in the display menu, called "Infinite". It is not truly infinite, but it is significantly larger than what current options allow. Due to it not being truly infinite, we could use the name "Max" instead to be more accurate.
- Exposes a new function to the Lua API `draw_distance_scalar_is_infinite` which returns whether or not the infinite setting is enabled.
- `draw_distance_scalar_is_infinite` is now used in several places in this repo to bypass distance checks for objects if infinite mode is enabled.
- Fixes a bug where you couldn't bypass the distance check in `obj_is_in_view`, meaning you could never disable all object distance culling.
- The infinite setting now forces the far plane to be at least a minimum of `1,000,000`.
* C++ lighting engine
Runs better using my new system for storing and iterating through lights.
I removed the lighting ctx profiler because after I've realized its very inaccurate and was probably programmed incorrectly from the start. Although I remember it working fine before and not constantly showing 20 ms or higher when I'm in an extremely simple level with extremely simple lights and the FPS is way too high for it to be taking 20 ms.
* Whoops
* Make some optimizations
* Fix small bug with LE inside graphics vertex function
I also brought back the lighting profiler because it's better than nothing.
* Some optimizations
* Cache active lights and 4 lights per vertex limit
Less branching and less iterating with the limit
* Screen shader effects for Lua [OpenGL]
Hue, saturation, brightness, contrast, exposure, dithering, posterization
Global = usually an object in the world
Non global = usually a screen element
Also:
* Changed skyboxes to use environment color instead of vertex color, visually identical
* Changed hud head texture to be non global
* changed power meter to be non global
* changed sparkles to be global
* changed some BBH vertex types to global
OpenGL renderer supported only for now.
* Add default values and better function names
Also fixed sizes in reset function
* Add scanlines effect
* Add global enabled function
* Fix some default values
* Hopefully fix white sparkles
* Whoops
* Address review
* Update function names
* Fix shader crash
* Address reviews
* Add builtin updater to macos
* Compile using trimmed build
* Implement windows
* Add coopdx updater binary
* idk what this is
* Dont need that
* Undo temp code, close stdin, stdout, and stderror so we dont print to error
* Add intel
* Linux
* Finalize
Co-authored-by: AgentXLP <44549182+AgentXLP@users.noreply.github.com>
* Update updater executables (cross compiled, need to test)
* Update windows exec
* Update mac libs
* Update windows lib
* Address review
---------
Co-authored-by: AgentXLP <44549182+AgentXLP@users.noreply.github.com>
* Unify renderers into one build, no more segregation
* Fix Linux compilation error
* How does one miss this
* Rename this
* Fix silly naming error that I missed
* Update Russian translation
* use hashmaps in mod cache
* use templates, suggested by peachy
an attempt to do what peachy is talking about
* that looks unusual
* change data to key parameter
Loading the scroll targets was probably the slowest parts to loading a romhack.
The reason for this is that many romhacks can have thousands of calls to `add_scroll_target`.
So, for 4,107 calls to `add_scroll_target`, the time went from ~4.5759 seconds to ~0.0173 seconds in total.
Changes made:
- Previously, simply finding the material data to scroll was rather slow due to using a linear sub string search across all vertices in all levels. To speed this up, I added a cache.
The cache bypasses checking every level by storing the exact string (rather than the substring) in a hashmap, so lookups become a simple case of a string lookup as a key in the map. It falls back to the full lookup if the cache doesn't hit.
- Changed the vertex buffer management in `scroll_targets.c` to behave closer to a modern dynamic array, where buffer size is doubled each time a new vertex buffer is added, to reduce the number of allocations performed.
* Fix erroneous sync valid packets
When the server received a sync valid packet from another player, it would also set the server player's level. This simple fix makes this no longer happen.
* Fix sync valid packets with host
Okay, so it turns out that the host was unable to differentiate between packets meant to validate other players, and packets meant to validate itself (sent when entering a level another player is already in). I changed so that the packet also includes who the sync packet is validating. Requires an additional byte, as well as adding an argument to network_send_sync_valid.
* Don't have server inform itself
Fixes HOOK_ON_SYNC_VALID being called twice
Add a way to save and load a gfx state in display lists.
Its primary purpose is to save the gfx state before rendering a held object, then restore it later.
It fixes the issue where Mario had opaque legs with the vanish and metal caps when holding an object.
* Scale bone anim support
Code changes provided by ExcellentGamer. Supports model anims which modify scale.
* Peachy code changes by ExcellentGamer
* Autogen constants
* changed vc3f_set to vec3f_copy
Allows modders to play audio streams on channels other than level background music.
4 constants have been added for this purpose:
- `MOD_AUDIO_CHANNEL_MASTER` - sound is only affected by master volume
- `MOD_AUDIO_CHANNEL_MUSIC` - sound is affected by music volume, same as previous behaviour
- `MOD_AUDIO_CHANNEL_SFX` - sound is affected by sfx volume, same as sample behaviour
- `MOD_AUDIO_CHANNEL_ENV` - sound is affected by env volume
This was done instead of using the existing `SEQ_PLAYER_*` constants to avoid confusion and because there isn't a `NONE`/`MASTER` option.
Additionally, sets the default to `MOD_AUDIO_CHANNEL_MUSIC` as to not break compatibility.
```lua
audio_stream_set_volume_channel(stream, MOD_AUDIO_CHANNEL_SFX) -- wow its just like a sample
audio_stream_get_volume_channel(stream) -- returns MOD_AUDIO_CHANNEL_SFX (its actually 2)
```
## Low hanging fruit optimisations for the memory data structures in `memory.c`
Mostly generic performance improvements:
- Swapping `calloc` calls for `malloc` calls where it's safe
- Combined allocations into one large allocation for `node + buffer`
- Using `realloc` instead of full `calloc` + `memcpy` + `free`.
- Add `smlua_collision_add_surface`, `_move_surface`, `_delete_surface` Lua APIs
- Add `remove_static_object_collision` to fully free a SOC and its surfaces
- Split surface pools into separate static, SOC, and dynamic pools
- Replace index-based SOC tracking with unique ID counter (`sSOCIdCounter`)
- Invalidate Lua CObjects for recycled surfaces on pool clear
- Expose `SURFACE_POOL_STATIC/DYNAMIC/SOC` constants to Lua
- Add `growing_array_swap_and_pop` and `growing_array_swap_and_pop_index` to memory utils
Co-authored-by: MysterD <myster@d>