Memory usage optimization

This commit is contained in:
DepressedTWM 2026-05-19 13:18:04 +04:00
parent ec6247b5c7
commit e59ac9f339
10 changed files with 27 additions and 40 deletions

View file

@ -426,3 +426,4 @@ void ALStream::streamData(){
SDL_Delay(AUDIO_SLEEP);
}
}

View file

@ -33,16 +33,16 @@
#include <SDL3/SDL_timer.h>
struct AudioPrivate{
int bgm_volume;
int sfx_volume;
unsigned char bgm_volume;
unsigned char sfx_volume;
AudioStream bgm;
AudioStream bgs;
AudioStream me;
int current_bgm_volume;
int current_bgs_volume;
int current_me_volume;
unsigned char current_bgm_volume;
unsigned char current_bgs_volume;
unsigned char current_me_volume;
SoundEmitter se;
@ -232,7 +232,7 @@ Audio::Audio(RGSSThreadData &rtData)
{}
void Audio::bgmPlay(const char *filename, int volume, int pitch, float pos){
void Audio::bgmPlay(const char *filename, short volume, short pitch, float pos){
p->current_bgm_volume = volume;
p->bgm.play(filename, (volume*p->bgm_volume)/100, pitch, pos);
}
@ -246,7 +246,7 @@ void Audio::bgmFade(int time){
}
void Audio::bgsPlay(const char *filename, int volume, int pitch, float pos){
void Audio::bgsPlay(const char *filename, short volume, short pitch, float pos){
p->current_bgs_volume = volume;
p->bgs.play(filename, (volume*p->sfx_volume)/100, pitch, pos);
}
@ -260,7 +260,7 @@ void Audio::bgsFade(int time){
}
void Audio::mePlay(const char *filename, int volume, int pitch){
void Audio::mePlay(const char *filename, short volume, short pitch){
p->current_me_volume = volume;
p->me.play(filename, (volume*p->bgm_volume)/100, pitch);
}
@ -274,7 +274,7 @@ void Audio::meFade(int time){
}
void Audio::sePlay(const char *filename, int volume, int pitch){
void Audio::sePlay(const char *filename, short volume, short pitch){
p->se.play(filename, (volume*p->sfx_volume)/100, pitch);
}
@ -301,7 +301,7 @@ int Audio::getBGM_Volume() const{
return p->bgm_volume;
}
void Audio::setBGM_Volume(int value){
void Audio::setBGM_Volume(short value){
if(value > 100){
value = 100;
}else if(value < 0){
@ -320,7 +320,7 @@ int Audio::getSFX_Volume() const{
return p->sfx_volume;
}
void Audio::setSFX_Volume(int value){
void Audio::setSFX_Volume(short value){
if(value > 100){
value = 100;
}else if(value < 0){

View file

@ -39,29 +39,19 @@ struct RGSSThreadData;
class Audio{
public:
void bgmPlay(const char *filename,
int volume = 100,
int pitch = 100,
float pos = 0);
void bgmPlay(const char *filename, short volume = 100, short pitch = 100, float pos = 0);
void bgmStop();
void bgmFade(int time);
void bgsPlay(const char *filename,
int volume = 100,
int pitch = 100,
float pos = 0);
void bgsPlay(const char *filename, short volume = 100, short pitch = 100, float pos = 0);
void bgsStop();
void bgsFade(int time);
void mePlay(const char *filename,
int volume = 100,
int pitch = 100);
void mePlay(const char *filename, short volume = 100, short pitch = 100);
void meStop();
void meFade(int time);
void sePlay(const char *filename,
int volume = 100,
int pitch = 100);
void sePlay(const char *filename, short volume = 100, short pitch = 100);
void seStop();
float bgmPos();

View file

@ -70,7 +70,7 @@ AudioStream::~AudioStream(){
SDL_DestroyMutex(streamMut);
}
void AudioStream::play(const std::string &filename, int volume, int pitch, float offset){
void AudioStream::play(const std::string &filename, int volume, int pitch, float offset) {
finiFadeOutInt();
lockStream();
@ -134,7 +134,7 @@ void AudioStream::play(const std::string &filename, int volume, int pitch, float
stream.setPitch(_pitch);
if (offset > 0){
setVolume(FadeIn, 0);
0 setVolume(FadeIn, 0);
startFadeIn();
}
@ -279,8 +279,7 @@ void AudioStream::fadeOutThread(){
if (state != ALStream::Playing
|| resVol < 0
|| fade.reqFini)
{
|| fade.reqFini){
if (state != ALStream::Paused)
stream.stop();

View file

@ -1069,9 +1069,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align){
GLMeta::blitRectangle(posRect, Vec2i());
GLMeta::blitEnd();
FloatRect bltRect(0, 0,
(float) (gpTexSize.x * squeeze) / gpTex2.width,
(float) gpTexSize.y / gpTex2.height);
FloatRect bltRect(0, 0, (float) (gpTexSize.x * squeeze) / gpTex2.width, (float) gpTexSize.y / gpTex2.height);
BltShader &shader = shState->shaders().blt;
shader.bind();

View file

@ -66,7 +66,7 @@ namespace po = boost::program_options;
Config::Config()
{}
void Config::read(int argc, char *argv[]){
void Config::read(short argc, char *argv[]){
#define PO_DESC_ALL \
PO_DESC(debugMode, bool, false) \
PO_DESC(screenMode, bool, false) \
@ -179,7 +179,7 @@ void Config::read(int argc, char *argv[]){
defScreenW = 640;
defScreenH = 480;
}
#ifdef STEAM
/* Override fullscreen config if Big Picture */
if (const char *env = std::getenv("SteamTenfoot")){

View file

@ -27,7 +27,7 @@
#include <set>
struct Config{
int rgssVersion;
unsigned char rgssVersion;
bool debugMode;
bool screenMode;
@ -89,7 +89,7 @@ struct Config{
Config();
void read(int argc, char *argv[]);
void read(short argc, char *argv[]);
};
#endif // CONFIG_H

View file

@ -65,8 +65,7 @@ public:
protected:
void guardDisposed() const{
if (isDisposed())
throw Exception(Exception::RGSSError,
"disposed %s", klassName());
throw Exception(Exception::RGSSError, "disposed %s", klassName());
}
private:

View file

@ -101,7 +101,7 @@ void Color::serialize(char *buffer) const{
writeDouble(&buffer, alpha);
}
Color *Color::deserialize(const char *data, int len){
Color *Color::deserialize(const char *data, short len){
if (len != 32)
throw Exception(Exception::ArgumentError, "Color: Serialized data invalid");

View file

@ -66,7 +66,7 @@ struct Color : public Serializable{
/* Serializable */
int serialSize() const;
void serialize(char *buffer) const;
static Color *deserialize(const char *data, int len);
static Color *deserialize(const char *data, short len);
/* Internal */
void updateInternal();