mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
fixed CTF sounds. fixed close teewars bug
This commit is contained in:
parent
9a8c0809c7
commit
8fa8485a3a
|
@ -179,6 +179,22 @@ sounds {
|
||||||
chat_client {
|
chat_client {
|
||||||
"data/audio/sfx_msg-client.wv"
|
"data/audio/sfx_msg-client.wv"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctf_drop {
|
||||||
|
"data/audio/sfx_ctf_drop.wv"
|
||||||
|
}
|
||||||
|
|
||||||
|
ctf_return {
|
||||||
|
"data/audio/sfx_ctf_rtn.wv"
|
||||||
|
}
|
||||||
|
|
||||||
|
ctf_grab {
|
||||||
|
"data/audio/sfx_ctf_grab_pl.wv"
|
||||||
|
}
|
||||||
|
|
||||||
|
ctf_capture {
|
||||||
|
"data/audio/sfx_ctf_cap_pl.wv"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -990,6 +990,9 @@ static void client_run()
|
||||||
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('Q'))
|
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('Q'))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if(!gfx_window_open())
|
||||||
|
break;
|
||||||
|
|
||||||
/* pump the network */
|
/* pump the network */
|
||||||
client_pump_network();
|
client_pump_network();
|
||||||
|
|
||||||
|
|
|
@ -261,6 +261,10 @@ int gfx_window_active()
|
||||||
return glfwGetWindowParam(GLFW_ACTIVE) == GL_TRUE ? 1 : 0;
|
return glfwGetWindowParam(GLFW_ACTIVE) == GL_TRUE ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int gfx_window_open()
|
||||||
|
{
|
||||||
|
return glfwGetWindowParam(GLFW_OPENED) == GL_TRUE ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
VIDEO_MODE fakemodes[] = {
|
VIDEO_MODE fakemodes[] = {
|
||||||
{320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8},
|
{320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8},
|
||||||
|
|
|
@ -381,11 +381,12 @@ int snd_load_wv(const char *filename)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(snd->rate != 44100)
|
if(snd->rate != 44100)
|
||||||
{
|
{
|
||||||
dbg_msg("sound/wv", "file is %d Hz, not 44100 Hz. filename='%s'", snd->rate, filename);
|
dbg_msg("sound/wv", "file is %d Hz, not 44100 Hz. filename='%s'", snd->rate, filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(bitspersample != 16)
|
if(bitspersample != 16)
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,6 +118,7 @@ int gfx_get_video_modes(VIDEO_MODE *list, int maxcount);
|
||||||
void gfx_set_vsync(int val);
|
void gfx_set_vsync(int val);
|
||||||
|
|
||||||
int gfx_window_active();
|
int gfx_window_active();
|
||||||
|
int gfx_window_open();
|
||||||
|
|
||||||
/* textures */
|
/* textures */
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -24,6 +24,7 @@ enum
|
||||||
CHN_GUI=0,
|
CHN_GUI=0,
|
||||||
CHN_MUSIC,
|
CHN_MUSIC,
|
||||||
CHN_WORLD,
|
CHN_WORLD,
|
||||||
|
CHN_GLOBAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
data_container *data = 0x0;
|
data_container *data = 0x0;
|
||||||
|
@ -550,7 +551,8 @@ extern "C" void modc_init()
|
||||||
// setup sound channels
|
// setup sound channels
|
||||||
snd_set_channel(CHN_GUI, 1.0f, 0.0f);
|
snd_set_channel(CHN_GUI, 1.0f, 0.0f);
|
||||||
snd_set_channel(CHN_MUSIC, 1.0f, 0.0f);
|
snd_set_channel(CHN_MUSIC, 1.0f, 0.0f);
|
||||||
snd_set_channel(CHN_WORLD, 1.0f, 1.0f);
|
snd_set_channel(CHN_WORLD, 0.9f, 1.0f);
|
||||||
|
snd_set_channel(CHN_GLOBAL, 1.0f, 0.0f);
|
||||||
|
|
||||||
// load the data container
|
// load the data container
|
||||||
data = load_data_from_memory(internal_data);
|
data = load_data_from_memory(internal_data);
|
||||||
|
@ -718,22 +720,11 @@ static void process_events(int s)
|
||||||
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
temp_system.new_particle(p, v, 0.5f+0.5f*frandom(), 16.0f, 128.0f, 0.985f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(item.type == EVENT_SOUND)
|
else if(item.type == EVENT_SOUND_WORLD)
|
||||||
{
|
{
|
||||||
ev_sound *ev = (ev_sound *)data;
|
ev_sound *ev = (ev_sound *)data;
|
||||||
vec2 p(ev->x, ev->y);
|
if(ev->sound >= 0 && ev->sound < NUM_SOUNDS)
|
||||||
int soundid = ev->sound; //(ev->sound & SOUND_MASK);
|
snd_play_random(CHN_WORLD, ev->sound, 1.0f, vec2(ev->x, ev->y));
|
||||||
//bool bstartloop = (ev->sound & SOUND_LOOPFLAG_STARTLOOP) != 0;
|
|
||||||
//bool bstoploop = (ev->sound & SOUND_LOOPFLAG_STOPLOOP) != 0;
|
|
||||||
//float vol, pan;
|
|
||||||
//sound_vol_pan(p, &vol, &pan);
|
|
||||||
|
|
||||||
if(soundid >= 0 && soundid < NUM_SOUNDS)
|
|
||||||
{
|
|
||||||
// TODO: we need to control the volume of the diffrent sounds
|
|
||||||
// depening on the category
|
|
||||||
snd_play_random(CHN_WORLD, soundid, 1.0f, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2789,6 +2780,11 @@ extern "C" void modc_message(int msg)
|
||||||
client_datas[cid].emoticon = emoticon;
|
client_datas[cid].emoticon = emoticon;
|
||||||
client_datas[cid].emoticon_start = client_tick();
|
client_datas[cid].emoticon_start = client_tick();
|
||||||
}
|
}
|
||||||
|
else if(msg == MSG_SOUND_GLOBAL)
|
||||||
|
{
|
||||||
|
int soundid = msg_unpack_int();
|
||||||
|
snd_play_random(CHN_GLOBAL, soundid, 1.0f, vec2(0,0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void modc_connected()
|
extern "C" void modc_connected()
|
||||||
|
|
|
@ -30,7 +30,7 @@ enum
|
||||||
OBJTYPE_FLAG,
|
OBJTYPE_FLAG,
|
||||||
EVENT_EXPLOSION,
|
EVENT_EXPLOSION,
|
||||||
EVENT_DAMAGEINDICATION,
|
EVENT_DAMAGEINDICATION,
|
||||||
EVENT_SOUND,
|
EVENT_SOUND_WORLD,
|
||||||
EVENT_SMOKE,
|
EVENT_SMOKE,
|
||||||
EVENT_SPAWN,
|
EVENT_SPAWN,
|
||||||
EVENT_DEATH,
|
EVENT_DEATH,
|
||||||
|
@ -50,7 +50,8 @@ enum
|
||||||
MSG_STARTINFO, // client -> server
|
MSG_STARTINFO, // client -> server
|
||||||
MSG_CHANGEINFO, // client -> server
|
MSG_CHANGEINFO, // client -> server
|
||||||
MSG_READY_TO_ENTER, // server -> client
|
MSG_READY_TO_ENTER, // server -> client
|
||||||
MSG_WEAPON_PICKUP
|
MSG_WEAPON_PICKUP,
|
||||||
|
MSG_SOUND_GLOBAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -1398,7 +1398,7 @@ void create_targetted_sound(vec2 pos, int sound, int target, int loopingflags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// create a sound
|
// create a sound
|
||||||
ev_sound *ev = (ev_sound *)events.create(EVENT_SOUND, sizeof(ev_sound), target);
|
ev_sound *ev = (ev_sound *)events.create(EVENT_SOUND_WORLD, sizeof(ev_sound), target);
|
||||||
if(ev)
|
if(ev)
|
||||||
{
|
{
|
||||||
ev->x = (int)pos.x;
|
ev->x = (int)pos.x;
|
||||||
|
@ -1412,6 +1412,16 @@ void create_sound(vec2 pos, int sound, int loopingflags)
|
||||||
create_targetted_sound(pos, sound, -1, loopingflags);
|
create_targetted_sound(pos, sound, -1, loopingflags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void create_sound_global(int sound, int target)
|
||||||
|
{
|
||||||
|
if (sound < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
msg_pack_start(MSG_SOUND_GLOBAL, MSGFLAG_VITAL);
|
||||||
|
msg_pack_int(sound);
|
||||||
|
server_send_msg(-1);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: should be more general
|
// TODO: should be more general
|
||||||
player* intersect_player(vec2 pos0, vec2 pos1, vec2& new_pos, entity* notthis)
|
player* intersect_player(vec2 pos0, vec2 pos1, vec2& new_pos, entity* notthis)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "../game.h"
|
#include "../game.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
|
|
||||||
|
void create_sound_global(int sound, int target=-1);
|
||||||
|
|
||||||
//
|
//
|
||||||
class event_handler
|
class event_handler
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,7 @@ int gameobject_ctf::on_player_death(class player *victim, class player *killer,
|
||||||
had_flag |= 2;
|
had_flag |= 2;
|
||||||
if(f && f->carrying_player == victim)
|
if(f && f->carrying_player == victim)
|
||||||
{
|
{
|
||||||
|
create_sound_global(SOUND_CTF_DROP);
|
||||||
f->drop_tick = server_tick();
|
f->drop_tick = server_tick();
|
||||||
f->carrying_player = 0;
|
f->carrying_player = 0;
|
||||||
had_flag |= 1;
|
had_flag |= 1;
|
||||||
|
@ -77,6 +78,9 @@ void gameobject_ctf::tick()
|
||||||
teamscore[fi^1]++;
|
teamscore[fi^1]++;
|
||||||
for(int i = 0; i < 2; i++)
|
for(int i = 0; i < 2; i++)
|
||||||
flags[i]->reset();
|
flags[i]->reset();
|
||||||
|
|
||||||
|
dbg_msg("", "capture sound %d", SOUND_CTF_CAPTURE);
|
||||||
|
create_sound_global(SOUND_CTF_CAPTURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,21 +95,28 @@ void gameobject_ctf::tick()
|
||||||
{
|
{
|
||||||
// return the flag
|
// return the flag
|
||||||
if(!f->at_stand)
|
if(!f->at_stand)
|
||||||
|
{
|
||||||
|
create_sound_global(SOUND_CTF_RETURN);
|
||||||
f->reset();
|
f->reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// take the flag
|
// take the flag
|
||||||
f->at_stand = 0;
|
f->at_stand = 0;
|
||||||
f->carrying_player = players[i];
|
f->carrying_player = players[i];
|
||||||
|
create_sound_global(SOUND_CTF_GRAB);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!f->carrying_player)
|
if(!f->carrying_player && !f->at_stand)
|
||||||
{
|
{
|
||||||
if(server_tick() > f->drop_tick + SERVER_TICK_SPEED*30)
|
if(server_tick() > f->drop_tick + SERVER_TICK_SPEED*30)
|
||||||
|
{
|
||||||
|
create_sound_global(SOUND_CTF_RETURN);
|
||||||
f->reset();
|
f->reset();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f->vel.y += gravity;
|
f->vel.y += gravity;
|
||||||
|
|
Loading…
Reference in a new issue