mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-25 12:38:30 +00:00
fix WaveCrop(): update wave->frameCount (#4003)
also allow `finalFrame = wave->frameCount' as the range of frames does not include it. Co-authored-by: Listeria monocytogenes <listeria@disroot.org>
This commit is contained in:
@@ -1278,7 +1278,7 @@ Wave WaveCopy(Wave wave)
|
|||||||
// NOTE: Security check in case of out-of-range
|
// NOTE: Security check in case of out-of-range
|
||||||
void WaveCrop(Wave *wave, int initFrame, int finalFrame)
|
void WaveCrop(Wave *wave, int initFrame, int finalFrame)
|
||||||
{
|
{
|
||||||
if ((initFrame >= 0) && (initFrame < finalFrame) && ((unsigned int)finalFrame < wave->frameCount))
|
if ((initFrame >= 0) && (initFrame < finalFrame) && ((unsigned int)finalFrame <= wave->frameCount))
|
||||||
{
|
{
|
||||||
int frameCount = finalFrame - initFrame;
|
int frameCount = finalFrame - initFrame;
|
||||||
|
|
||||||
@@ -1288,6 +1288,7 @@ void WaveCrop(Wave *wave, int initFrame, int finalFrame)
|
|||||||
|
|
||||||
RL_FREE(wave->data);
|
RL_FREE(wave->data);
|
||||||
wave->data = data;
|
wave->data = data;
|
||||||
|
wave->frameCount = (unsigned int)frameCount;
|
||||||
}
|
}
|
||||||
else TRACELOG(LOG_WARNING, "WAVE: Crop range out of bounds");
|
else TRACELOG(LOG_WARNING, "WAVE: Crop range out of bounds");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user