From 5e8a04c54f8288aa3fb44264682ae93a0f556e6e Mon Sep 17 00:00:00 2001 From: Andreas Ortmann Date: Mon, 3 Oct 2016 18:56:49 +0200 Subject: [PATCH] ignore the sound for now. event mechanism is working good with renderer. --- game/CMakeLists.txt | 9 +- game/sound/dummy_sound.cpp | 130 +++++++++++++++++++++++++++++ game/state/state.cpp | 8 +- test/{amok.sh => shoot_n_times.py} | 14 +++- 4 files changed, 151 insertions(+), 10 deletions(-) create mode 100644 game/sound/dummy_sound.cpp rename test/{amok.sh => shoot_n_times.py} (51%) diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt index cd611b0..d5a0caa 100644 --- a/game/CMakeLists.txt +++ b/game/CMakeLists.txt @@ -19,6 +19,8 @@ set(GAME_SRC network/session.cpp + sound/sound_effects.cpp + util.cpp game.cpp @@ -36,10 +38,9 @@ set(GAME_SRC set(SOUND_LIBRARIES "") # TODO: make optional! -set(GAME_SRC ${GAME_SRC} sound/sound.cpp sound/sound_effects.cpp) - -set(SOUND_LIBRARIES -lportaudio -lsndfile) -#set(GAME_SRC "${GAME_SRC} sound/dummy_sound.cpp sound/dummy_sound_effects.cpp") +#set(GAME_SRC ${GAME_SRC} sound/sound.cpp) +#set(SOUND_LIBRARIES -lportaudio -lsndfile) +set(GAME_SRC ${GAME_SRC} sound/dummy_sound.cpp) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/game/sound/dummy_sound.cpp b/game/sound/dummy_sound.cpp new file mode 100644 index 0000000..f7e7c68 --- /dev/null +++ b/game/sound/dummy_sound.cpp @@ -0,0 +1,130 @@ +#include "sound.hpp" + +namespace sound { + bool initSound(void) + { + return false; + } + + void deleteOldSounds() + { + } + + SoundHandle *playSound(enum Sound type, float amplitude) + { + (void) type; + (void) amplitude; + return NULL; + } + + SoundHandle *playFrequency(float freq, float amplitude) + { + (void) freq; + (void) amplitude; + return NULL; + } + + bool configureEnvelope(SoundHandle *handle, float rise, float hold, float decay) + { + (void) handle; + (void) rise; + (void) hold; + (void) decay; + return false; + } + + bool configureOvershoot(SoundHandle *handle, float relativeOvershootTime) + { + (void) handle; + (void) relativeOvershootTime; + return false; + } + + bool configureEnvelopeWait(SoundHandle *handle, float rise, float hold, float decay, float wait) + { + (void) handle; + (void) rise; + (void) hold; + (void) decay; + (void) wait; + return false; + } + + bool configureEnvelopeLooping(SoundHandle *handle, float rise, float hold, float decay, float wait) + { + (void) handle; + (void) rise; + (void) hold; + (void) decay; + (void) wait; + return false; + } + + float getRiseDuration(SoundHandle *handle) + { + (void) handle; + return 0.0f; + } + float getHoldDuration(SoundHandle *handle) + { + (void) handle; + return 0.0f; + } + + float getDecayDuration(SoundHandle *handle) + { + (void) handle; + return 0.0f; + } + + float getWaitTime(SoundHandle *handle) + { + (void) handle; + return 0.0f; + } + + void configureWaitTime(SoundHandle *handle, float waitTime) + { + (void) handle; + (void) waitTime; + } + + void setLoopCount(SoundHandle *handle, int numRepetitions) + { + (void) handle; + (void) numRepetitions; + } + + bool stopSound(SoundHandle *handle) + { + (void) handle; + return true; + } + + void stopAllSounds(void) + { + } + + void teardownSound(void) + { + } + + bool startDumpingWav(const char *filename) + { + (void) filename; + return false; + } + + void stopDumpingWav(void) + { + } + + int numActiveSounds(void) + { + } + + void deleteSound(SoundHandle *handle) + { + (void) handle; + } +} diff --git a/game/state/state.cpp b/game/state/state.cpp index 80f22ff..70debcb 100644 --- a/game/state/state.cpp +++ b/game/state/state.cpp @@ -528,8 +528,8 @@ namespace game { case EventType::Explosion: { ExplosionEvent *ee = static_cast(evt); - std::cout<<"got explosion delete event, finally deleting explosion #" - << ee->object()->id << std::endl; + //std::cout<<"got explosion delete event, finally deleting explosion #" + // << ee->object()->id << std::endl; delete(ee->object()); } @@ -538,8 +538,8 @@ namespace game { case EventType::Missile: { auto *me = static_cast(evt); - std::cout<<"got missile delete event, finally deleting missile #" - << me->object()->id << std::endl; + //std::cout<<"got missile delete event, finally deleting missile #" + // << me->object()->id << std::endl; delete(me->object()); } diff --git a/test/amok.sh b/test/shoot_n_times.py similarity index 51% rename from test/amok.sh rename to test/shoot_n_times.py index b71afeb..a73a197 100755 --- a/test/amok.sh +++ b/test/shoot_n_times.py @@ -3,13 +3,23 @@ import os import random import time import socket +import sys + +delay = 0.1 + +if len(sys.argv) <= 1: + print("usage: ./prog $NUM_SHOOTS [$FLOAT_DELAY_BETWEEN_SHOTS]") + exit(1) + +if len(sys.argv) > 2: + delay = float(sys.argv[2]) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("192.168.0.191", 3490)) -for i in range(100): +for i in range(int(sys.argv[1])): a = random.randint(0, 360) msg = str(a) + " \r\n" s.send(msg.encode()) - time.sleep(0.1) + time.sleep(delay)