Merge from rpi

This commit is contained in:
Tim Felgentreff 2022-05-30 22:20:53 +02:00
commit ad332c9a87
4 changed files with 26 additions and 5 deletions

View file

@ -318,9 +318,8 @@ void CMapInfo::Clear()
this->MapUID = 0;
}
CMap::CMap() : Fields(NULL), NoFogOfWar(false), TileGraphic(NULL)
CMap::CMap() : Fields(NULL), NoFogOfWar(false), TileGraphic(NULL), Tileset(NULL)
{
Tileset = new CTileset;
}
CMap::~CMap()
@ -333,6 +332,10 @@ CMap::~CMap()
*/
void CMap::Create()
{
if (!Tileset) {
Tileset = new CTileset;
}
Assert(!this->Fields);
this->Fields = new CMapField[this->Info.MapWidth * this->Info.MapHeight];

View file

@ -63,11 +63,18 @@ bool CallbackMusic; /// flag true callback ccl if stops
*/
static void MusicFinishedCallback()
{
static long MusicCallbackDebounce = 0;
long ticks = SDL_GetTicks();
if (MusicCallbackDebounce + 1000 < ticks) {
// only accept music finished callbacks for music playing longer than 1s
return;
}
MusicCallbackDebounce = ticks;
SDL_Event event;
SDL_zero(event);
event.type = SDL_SOUND_FINISHED;
event.user.code = 1;
event.user.data1 = CheckMusicFinished;
event.user.data1 = (void*) CheckMusicFinished;
SDL_PeepEvents(&event, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
}

View file

@ -269,16 +269,23 @@ bool UnitSoundIsPlaying(Origin *origin)
*/
static void ChannelFinished(int channel)
{
static long ChannelCallbackDebounce[MaxChannels] = {0};
if (channel < 0 || channel >= MaxChannels) {
fprintf(stderr, "ERROR: Out of bounds channel (how?)\n");
return;
}
long ticks = SDL_GetTicks();
if (ChannelCallbackDebounce[channel] + 200 < ticks) {
// only accept sound finished callbacks for sounds playing longer than 0.2s
return;
}
ChannelCallbackDebounce[channel] = ticks;
if (Channels[channel].FinishedCallback != NULL) {
SDL_Event event;
SDL_zero(event);
event.type = SDL_SOUND_FINISHED;
event.user.code = channel;
event.user.data1 = Channels[channel].FinishedCallback;
event.user.data1 = (void*) Channels[channel].FinishedCallback;
SDL_PeepEvents(&event, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
}
delete Channels[channel].Unit;

View file

@ -387,8 +387,12 @@ void InitVideoSdl()
}
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
int rendererFlags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
if (!Parameters::Instance.benchmark) {
rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
}
if (!TheRenderer) {
TheRenderer = SDL_CreateRenderer(TheWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE | SDL_RENDERER_PRESENTVSYNC);
TheRenderer = SDL_CreateRenderer(TheWindow, -1, rendererFlags);
}
SDL_RendererInfo rendererInfo;
SDL_GetRendererInfo(TheRenderer, &rendererInfo);