Commit 134d364a authored by Gerstrong's avatar Gerstrong

Bug fixes

parent 58dc4d54
......@@ -175,16 +175,17 @@ void CLogFile::fltextOut(FONTCOLORS Color, bool List, const char *Text, ...)
textOut(Color, List, buffer);
}
void CLogFile::ftextOut(FONTCOLORS Color, const char *Text, ...)
{
char buffer[MAX_BUFFER];
va_list pArgList;
va_start(pArgList, Text);
vsprintf(buffer, Text, pArgList);
va_end(pArgList);
textOut(Color, buffer);
va_end(pArgList);
}
void CLogFile::FunctionResult (const char *Name,bool Result)
......
......@@ -102,8 +102,10 @@ private:
}
}
void reset() {
if(mutex) {
void reset()
{
if(mutex)
{
lock();
(*refCount)--;
if(*refCount == 0) {
......
......@@ -21,7 +21,7 @@ typedef int (*ThreadFunc) (void*);
struct CmdLineIntf;
struct Action {
virtual ~Action() {}
~Action() {}
virtual int handle() = 0;
};
......
......@@ -54,6 +54,11 @@ transluceny(0)
m_climbing = false;
supportedbyobject = false;
blockedd = false;
blockedu = false;
blockedl = false;
blockedr = false;
if(m_type != OBJ_NONE )
{
setupObjectType(g_pBehaviorEngine->getEpisode());
......
......@@ -45,7 +45,7 @@ struct EventRestartLevel : CEvent {
struct EventPlayerEndLevel : CEvent {
const uint16_t levelObject;
const bool sucess;
EventPlayerEndLevel(const EventExitLevel &ev) :
EventPlayerEndLevel(const EventExitLevel ev) :
levelObject(ev.levelObject), sucess(ev.sucess) {}
};
......
......@@ -97,6 +97,7 @@ bool CAudioGalaxy::LoadFromAudioCK(const CExeFile& ExeFile)
AudioFile.seekg( 0, std::ios::beg );
// create memory so we can store the Audio.ck there and use it later for extraction
//uint8_t *AudioCompFileData = new uint8_t[audiofilecompsize];
uint8_t *AudioCompFileData = new uint8_t[audiofilecompsize];
AudioFile.read((char*)AudioCompFileData, audiofilecompsize);
AudioFile.close();
......@@ -131,6 +132,7 @@ bool CAudioGalaxy::LoadFromAudioCK(const CExeFile& ExeFile)
if(!found)
{
g_pLogFile->textOut("CAudioGalaxy::LoadFromAudioCK(): No audio was found in that file! It seems to be empty.");
delete [] AudioCompFileData;
return false;
}
......@@ -155,7 +157,7 @@ bool CAudioGalaxy::LoadFromAudioCK(const CExeFile& ExeFile)
CSoundSlot zeroslot;
m_soundslot.assign(number_of_total_sounds, zeroslot);
for(unsigned int snd=0 ; snd<number_of_total_sounds ; snd++)
for( unsigned int snd=0 ; snd<number_of_total_sounds ; snd++ )
{
/// Now we have all the data we need.
// decompress every file of AUDIO.CK? using huffman decompression algorithm
......@@ -170,7 +172,8 @@ bool CAudioGalaxy::LoadFromAudioCK(const CExeFile& ExeFile)
const uint32_t audio_comp_data_start = audio_start+sizeof(uint32_t);
const uint32_t *AudioCompFileData32 = (uint32_t*) (void*) (AudioCompFileData + audio_start);
outsize = *AudioCompFileData32;
byte *imfdata = new byte[outsize];
//byte *imfdata = new byte[outsize];
byte imfdata[outsize];
Huffman.expand( (byte*)(AudioCompFileData+audio_comp_data_start), imfdata, audio_end-audio_comp_data_start, outsize);
......@@ -180,6 +183,8 @@ bool CAudioGalaxy::LoadFromAudioCK(const CExeFile& ExeFile)
readPCSpeakerSoundintoWaveForm( m_soundslot[snd], imfdata, outsize, (m_AudioSpec.format == AUDIO_S16) ? 2 : 1 );
}
}
delete [] AudioCompFileData;
}
else
g_pLogFile->textOut("CAudioGalaxy::LoadFromAudioCK(): Wrong Audio Format");
......
......@@ -443,8 +443,7 @@ void CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
case PLATFORM_HORIZ:
p_newfoe = new galaxy::CPlatformHorizontal(&Map, x, y); break;
case PLATFORM_DROP:
p_newfoe = new galaxy::CPlatformDrop(&Map, x, y);
break;
p_newfoe = new galaxy::CPlatformDrop(&Map, x, y); break;
case 33:
// Place Miragia in Episode 4 on the Map
......
......@@ -232,8 +232,9 @@ void CPlayGameGalaxy::process()
m_WorldMap.setActive(true);
m_LevelName = m_WorldMap.getLevelName();
m_WorldMap.loadAndPlayMusic();
const EventExitLevel exiteventinfo = *ev;
EventContainer.pop_Event();
EventContainer.add( new EventPlayerEndLevel(*ev) );
EventContainer.add( new EventPlayerEndLevel(exiteventinfo) );
}
else if( EventPlayTrack *ev = EventContainer.occurredEvent<EventPlayTrack>() )
{
......
......@@ -38,7 +38,10 @@ void CStatusScreenGalaxy::drawBase(SDL_Rect &EditRect)
#endif
const SDL_Rect& DestRect = g_pVideoDriver->getGameResolution();
mp_StatusSurface = SDL_CreateRGBSurface( flags, DestRect.w, DestRect.h, 32, rmask, gmask, bmask, amask);
if(mp_StatusSurface)
SDL_FreeSurface(mp_StatusSurface);
mp_StatusSurface = SDL_CreateRGBSurface( flags, DestRect.w, DestRect.h, 32, rmask, gmask, bmask, amask);
/// Draw the required bitmaps and backgrounds
// Draw the support Bitmap and see where the gray rectangle starts...
......
......@@ -31,6 +31,7 @@ void CStarRing::process()
if(sprite > STARRING_SPRITE+2)
{
sprite = STARRING_SPRITE;
m_animation_timer = 0;
}
}
......
......@@ -40,6 +40,15 @@
#include <string.h>
#include "dbopl.h"
_Chip::_Chip()
{
memset(freqMul, 0, 16*sizeof(Bit32u));
memset(linearRates, 0, 76*sizeof(Bit32u));
memset(attackRates, 0, 76*sizeof(Bit32u));
memset(chan, 0, 18*sizeof(Channel));
}
#define GCC_UNLIKELY(x) x
......@@ -337,14 +346,16 @@ static inline void Operator__UpdateDecay(Operator *self, const Chip* chip ) {
}
static inline void Operator__UpdateRelease(Operator *self, const Chip* chip ) {
Bit8u rate = self->reg80 & 0xf;
if ( rate ) {
if ( rate )
{
Bit8u val = (rate << 2) + self->ksr;
self->releaseAdd = chip->linearRates[ val ];
self->rateZero &= ~(1 << RELEASE);
if ( !(self->reg20 & MASK_SUSTAIN ) ) {
self->rateZero &= ~( 1 << SUSTAIN );
}
} else {
} else
{
self->rateZero |= (1 << RELEASE);
self->releaseAdd = 0;
if ( !(self->reg20 & MASK_SUSTAIN ) ) {
......
......@@ -181,6 +181,9 @@ struct _Chip {
//0 or -1 when enabled
Bit8s opl3Active;
// Constructor which sets some variables to zero.
_Chip();
};
void Chip__Setup(Chip *self, Bit32u rate );
......
......@@ -23,7 +23,8 @@
#define MOUSEWRAPPER 1
#endif
CInput::CInput() {
CInput::CInput()
{
#if defined(WIZ) || defined(GP2X)
volume_direction = VOLUME_NOCHG;
volume = 60-VOLUME_CHANGE_RATE;
......
......@@ -63,7 +63,7 @@ void CVideoDriver::resetSettings() {
initResolutionList();
// take the first default resolution. It might be changed if there is a config file already created
setMode(m_Resolutionlist.front().width, m_Resolutionlist.front().height, m_Resolutionlist.front().depth);
setMode( m_Resolutionlist.front() );
}
// initResolutionList() reads the local list of available resolution.
......@@ -170,7 +170,7 @@ void CVideoDriver::setMode(int width, int height,int depth)
setMode(res);
}
void CVideoDriver::setMode(st_resolution &res)
void CVideoDriver::setMode(const st_resolution res)
{
m_VidConfig.setResolution(res);
......
......@@ -74,7 +74,7 @@ public:
void setVidConfig(const CVidConfig& VidConf);
void setMode(int width, int height,int depth);
void setMode(st_resolution &res);
void setMode(const st_resolution res);
void setSpecialFXMode(bool SpecialFX);
void setFilter(short value);
void setZoom(short vale);
......
......@@ -40,9 +40,8 @@ bool CMusic::loadTrack(const CExeFile& ExeFile, const int track)
bool CMusic::load(const CExeFile& ExeFile, const int level)
{
m_AudioSpec = g_pSound->getAudioSpec();
CIMFPlayer *imf_player = new CIMFPlayer(m_AudioSpec);
imf_player->loadMusicForLevel(ExeFile, level);
mp_player = imf_player;
mp_player = new CIMFPlayer(m_AudioSpec);
(static_cast<CIMFPlayer*>(mp_player))->loadMusicForLevel(ExeFile, level);
if(!mp_player->open())
{
......
......@@ -87,7 +87,7 @@ bool CSound::init()
AudioSpec = obtained;
m_pMixedForm = new Uint8[AudioSpec.size]; // To make sure it's 4-byte aligned use malloc() instead of new()
m_MixedForm.reserve(AudioSpec.size);
g_pLogFile->ftextOut("SDL_AudioSpec:<br>");
g_pLogFile->ftextOut(" freq: %d<br>", AudioSpec.freq);
......@@ -131,7 +131,8 @@ void CSound::destroy()
SDL_CloseAudio();
m_mixing_channels = 0;
m_pMixedForm.tryDeleteData();
if(!m_MixedForm.empty())
m_MixedForm.clear();
if(!m_soundchannel.empty())
m_soundchannel.clear();
......@@ -211,10 +212,12 @@ void CSound::callback(void *unused, Uint8 *stream, int len)
m_callback_running = true;
Uint8* buffer = m_MixedForm.data();
if (g_pMusicPlayer->playing())
{
g_pMusicPlayer->readWaveform(m_pMixedForm.get(), len);
mixAudio(stream, m_pMixedForm.get(), len, m_MusicVolume, AudioSpec.format);
g_pMusicPlayer->readWaveform(buffer, len);
mixAudio(stream, buffer, len, m_MusicVolume, AudioSpec.format);
}
bool any_sound_playing = false;
......@@ -224,8 +227,8 @@ void CSound::callback(void *unused, Uint8 *stream, int len)
if(snd_chnl->isPlaying())
{
any_sound_playing |= true;
snd_chnl->readWaveform( m_pMixedForm.get(), len);
mixAudio(stream, m_pMixedForm.get(), len, m_SoundVolume, AudioSpec.format);
snd_chnl->readWaveform( buffer, len);
mixAudio(stream, buffer, len, m_SoundVolume, AudioSpec.format);
}
}
......
......@@ -78,7 +78,7 @@ private:
Uint8 m_SoundVolume;
bool m_sound_blaster_mode;
SmartPointer<Uint8> m_pMixedForm; // Mainly used by the callback function. Declared once and allocated
std::vector<Uint8> m_MixedForm; // Mainly used by the callback function. Declared once and allocated
// for the whole program
unsigned char *mp_SndSlotMap;
......
......@@ -142,8 +142,8 @@ void BlitSurfaceMerge( SDL_Surface *src, SDL_Rect *p_src_rect, SDL_Surface *dst,
db |= sb;
da |= sa;
*pixel_dst32 = SDL_MapRGBA(dst->format, dr, dg, db, da);
pixel_src+=src->format->BytesPerPixel;
pixel_dst+=dst->format->BytesPerPixel;
pixel_src += src->format->BytesPerPixel;
pixel_dst += dst->format->BytesPerPixel;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment