Some fixes, use datadir for sounds too
This commit is contained in:
parent
d2e51f7389
commit
9928297edf
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
*.o
|
||||
bomber
|
||||
sdlbomber
|
||||
matcher
|
||||
|
14
Makefile
14
Makefile
@ -4,10 +4,10 @@ WARNFLAGS = -Wall -Wmissing-declarations -Wdeclaration-after-statement -Wcast-al
|
||||
override CFLAGS += -D_REENTRANT -O2 $(shell sdl-config --cflags) $(DBG) $(WARNFLAGS)
|
||||
|
||||
.PHONY: all clean install
|
||||
all: bomber
|
||||
all: sdlbomber
|
||||
|
||||
bomber: bomber.o gfx.o sound.o announce.o
|
||||
gcc -o bomber bomber.o gfx.o sound.o announce.o $(shell sdl-config --libs) -lavahi-common -lavahi-client $(DBG)
|
||||
sdlbomber: bomber.o gfx.o sound.o announce.o
|
||||
gcc -o sdlbomber bomber.o gfx.o sound.o announce.o $(shell sdl-config --libs) -lavahi-common -lavahi-client $(DBG)
|
||||
|
||||
matcher: matcher.c
|
||||
|
||||
@ -20,10 +20,10 @@ sound.o: sound.c
|
||||
announce.o: announce.c announce.h
|
||||
|
||||
clean:
|
||||
rm -f *.o matcher bomber
|
||||
rm -f *.o matcher sdlbomber
|
||||
|
||||
install: bomber
|
||||
install: sdlbomber
|
||||
echo "Installing into $(DESTDIR)"
|
||||
mkdir -p "$(DESTDIR)/usr/bin/" "$(DESTDIR)/usr/share/sdlbomber/"
|
||||
install -m 0755 bomber "$(DESTDIR)/usr/bin/"
|
||||
install -m 0644 data/*.pcx "$(DESTDIR)/usr/share/sdlbomber/"
|
||||
install -m 0755 sdlbomber "$(DESTDIR)/usr/bin/"
|
||||
install -m 0644 data/*.pcx data/*.raw "$(DESTDIR)/usr/share/sdlbomber/"
|
||||
|
9
bomber.c
9
bomber.c
@ -11,18 +11,15 @@
|
||||
#include <signal.h>
|
||||
#include "bomber.h"
|
||||
#include "gfx.h"
|
||||
#include "announce.h"
|
||||
#include "sound.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include "announce.h"
|
||||
|
||||
static void domode(void);
|
||||
static int iterate(void);
|
||||
static int scaninvite(int size);
|
||||
|
||||
#ifndef DATADIR
|
||||
#define DATADIR "."
|
||||
#endif
|
||||
|
||||
#define FRACTION 9
|
||||
#define MAXMSG 4096
|
||||
#define PORT 5521
|
||||
@ -840,7 +837,7 @@ char tname[256];
|
||||
if(ihand<0)
|
||||
{
|
||||
char tname2[256];
|
||||
sprintf(tname2,"data/%s.pcx",tname);
|
||||
sprintf(tname2,"%s.pcx",tname);
|
||||
ihand=open(tname2,O_RDONLY);
|
||||
if(ihand<0)
|
||||
return 1;
|
||||
|
9
bomber.h
9
bomber.h
@ -328,13 +328,4 @@ received will be answered with PKT_QUIT.
|
||||
|
||||
*/
|
||||
|
||||
int soundopen(void);
|
||||
void soundclose(void);
|
||||
void playsound(int n);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // BOMBER_H
|
||||
|
||||
|
||||
|
58
sound.c
58
sound.c
@ -5,24 +5,26 @@
|
||||
#include <SDL_audio.h>
|
||||
#include <SDL_error.h>
|
||||
|
||||
char dirlist[]="data";
|
||||
#include "sound.h"
|
||||
|
||||
int readsound(int num);
|
||||
static char dirlist[]=DATADIR;
|
||||
|
||||
#define NUMSOUNDS (sizeof(soundnames)/sizeof(char*))
|
||||
static int readsound(int num);
|
||||
|
||||
#define NUMSOUNDS ((int)(sizeof(soundnames)/sizeof(char*)))
|
||||
#define MIXMAX 16
|
||||
|
||||
#define SOUND_QUIET -1
|
||||
|
||||
char *soundnames[] =
|
||||
{
|
||||
"bomb1.raw",
|
||||
"power1.raw",
|
||||
"death.raw",
|
||||
"drop.raw",
|
||||
"bomb2.raw",
|
||||
"power2.raw",
|
||||
static const char *soundnames[] = {
|
||||
"bomb1.raw",
|
||||
"power1.raw",
|
||||
"death.raw",
|
||||
"drop.raw",
|
||||
"bomb2.raw",
|
||||
"power2.raw",
|
||||
};
|
||||
|
||||
typedef struct sample
|
||||
{
|
||||
char *data;
|
||||
@ -31,21 +33,21 @@ typedef struct sample
|
||||
|
||||
#define SNDFRAGMENT 1024
|
||||
|
||||
sample samples[NUMSOUNDS];
|
||||
static sample samples[NUMSOUNDS];
|
||||
|
||||
int soundworking=0;
|
||||
int fragment;
|
||||
int soundwrite,soundread;
|
||||
int *soundbuffer;
|
||||
int soundbufferlen;
|
||||
unsigned char sndclip[8192];
|
||||
static int soundworking=0;
|
||||
static int fragment;
|
||||
// static int soundwrite,soundread;
|
||||
static int *soundbuffer;
|
||||
static int soundbufferlen;
|
||||
static unsigned char sndclip[8192];
|
||||
|
||||
#define MAXSOUNDCOMMANDS 32
|
||||
char soundcommands[MAXSOUNDCOMMANDS];
|
||||
int soundtake,soundput;
|
||||
static char soundcommands[MAXSOUNDCOMMANDS];
|
||||
static int soundtake,soundput;
|
||||
|
||||
int sndplaying[MIXMAX],sndposition[MIXMAX];
|
||||
void fillaudio(void *udata,Uint8 *buffer,int len)
|
||||
static int sndplaying[MIXMAX],sndposition[MIXMAX];
|
||||
static void fillaudio(void *udata,Uint8 *buffer,int len)
|
||||
{
|
||||
char com,*p;
|
||||
int i,j,*ip;
|
||||
@ -91,8 +93,7 @@ int which;
|
||||
}
|
||||
|
||||
|
||||
int soundopen(void)
|
||||
{
|
||||
int soundopen(void) {
|
||||
SDL_AudioSpec wanted;
|
||||
int i,j;
|
||||
|
||||
@ -131,8 +132,7 @@ int i,j;
|
||||
SDL_PauseAudio(0);
|
||||
return 0;
|
||||
}
|
||||
void soundclose(void)
|
||||
{
|
||||
void soundclose(void) {
|
||||
if(soundworking)
|
||||
{
|
||||
SDL_CloseAudio();
|
||||
@ -141,8 +141,7 @@ void soundclose(void)
|
||||
}
|
||||
|
||||
|
||||
int readsound(int num)
|
||||
{
|
||||
int readsound(int num) {
|
||||
char name[256],*p1,*p2,ch;
|
||||
int i,file,size,len;
|
||||
p1=dirlist;
|
||||
@ -177,8 +176,7 @@ int i,file,size,len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void playsound(int n)
|
||||
{
|
||||
void playsound(int n) {
|
||||
soundcommands[soundput]=n;
|
||||
soundput=(soundput+1)&(MAXSOUNDCOMMANDS-1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user