Reformatting code using Kernighan & Ritchie style, tabs, tab width=4.

Command line: astyle --style=kr --indent=force-tab=4 --lineend=linux -n -r <file names>
This commit is contained in:
lotodore
2011-02-11 20:02:08 +00:00
parent 29dca1846e
commit 02518c67b2
232 changed files with 22743 additions and 21044 deletions
+65 -38
View File
@@ -1,7 +1,7 @@
//
// C++ Implementation: sdlplayer
//
// Description:
// Description:
//
//
// Author: FThauer FHammer <webmaster@pokerth.net>, (C) 2007
@@ -12,18 +12,18 @@
#include "sdlplayer.h"
#if (defined __APPLE__)
#include <SDL.h>
#include <SDL.h>
#else
#include <SDL/SDL.h>
#include <SDL/SDL.h>
#endif
using namespace std;
SDLPlayer::SDLPlayer(ConfigFile *c)
: soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c)
: soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c)
{
SDL_Init(SDL_INIT_AUDIO);
initAudio();
SDL_Init(SDL_INIT_AUDIO);
initAudio();
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
}
@@ -35,10 +35,10 @@ SDLPlayer::~SDLPlayer()
SDL_Quit();
}
void SDLPlayer::initAudio() {
void SDLPlayer::initAudio()
{
if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects"))
{
if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
int audio_channels = 2;
@@ -52,68 +52,94 @@ void SDLPlayer::initAudio() {
}
}
void SDLPlayer::playSound(string audioString, int playerID) {
void SDLPlayer::playSound(string audioString, int playerID)
{
if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav");
if(myFile.open(QIODevice::ReadOnly)) {
//set 3d position for player
int position = 0;
int distance = 0;
switch (playerID) {
case 0: { position = 180; distance = 10; }
case 0: {
position = 180;
distance = 10;
}
break;
case 1: { position = 281; distance = 50; }
case 1: {
position = 281;
distance = 50;
}
break;
case 2: { position = 315; distance = 120; }
case 2: {
position = 315;
distance = 120;
}
break;
case 3: { position = 338; distance = 160; }
case 3: {
position = 338;
distance = 160;
}
break;
case 4: { position = 23; distance = 160; }
case 4: {
position = 23;
distance = 160;
}
break;
case 5: { position = 45; distance = 120; }
case 5: {
position = 45;
distance = 120;
}
break;
case 6: { position = 79; distance = 50; }
case 6: {
position = 79;
distance = 50;
}
break;
default: { position = 0; distance = 0; }
default: {
position = 0;
distance = 0;
}
break;
}
audioDone();
QDataStream in(&myFile);
soundData = new Uint8[(int)myFile.size()];
in.readRawData( (char*)soundData, (int)myFile.size() );
sound = Mix_QuickLoad_WAV(soundData);
// set channel 0 to settings volume
sound = Mix_QuickLoad_WAV(soundData);
// set channel 0 to settings volume
Mix_Volume(0,myConfig->readConfigInt("SoundVolume")*10);
// set 3d effect
if(!Mix_SetPosition(0, position, distance)) {
printf("Mix_SetPosition: %s\n", Mix_GetError());
// no position effect, is it ok?
printf("Mix_SetPosition: %s\n", Mix_GetError());
// no position effect, is it ok?
}
currentChannel = Mix_PlayChannel(-1, sound,0);
}
// else cout << "could not load " << audioString << ".wav" << endl;
// else cout << "could not load " << audioString << ".wav" << endl;
//test
// audioDone();
// sound = Mix_LoadWAV( QString(QString::fromStdString(audioString)+QString(".wav")).toStdString().c_str() );
// currentChannel = Mix_PlayChannel(-1, sound,0);
// audioDone();
// sound = Mix_LoadWAV( QString(QString::fromStdString(audioString)+QString(".wav")).toStdString().c_str() );
// currentChannel = Mix_PlayChannel(-1, sound,0);
}
}
void SDLPlayer::audioDone() {
void SDLPlayer::audioDone()
{
if(audioEnabled) {
Mix_HaltChannel(currentChannel);
@@ -124,8 +150,9 @@ void SDLPlayer::audioDone() {
}
}
void SDLPlayer::closeAudio() {
void SDLPlayer::closeAudio()
{
if(audioEnabled) {
audioDone();
Mix_CloseAudio();