mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
added sound component
This commit is contained in:
parent
b22dd1488c
commit
0511e1152a
|
@ -38,8 +38,5 @@ void CAMERA::on_render()
|
|||
|
||||
center = gameclient.local_character_pos + camera_offset;
|
||||
}
|
||||
|
||||
// set listner pos
|
||||
snd_set_listener_pos(center.x, center.y);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <game/client/gameclient.hpp>
|
||||
#include <game/client/gc_client.hpp>
|
||||
|
||||
#include <game/client/components/sounds.hpp>
|
||||
|
||||
#include "chat.hpp"
|
||||
|
||||
void CHAT::on_reset()
|
||||
|
@ -17,8 +19,6 @@ void CHAT::on_reset()
|
|||
current_line = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CHAT::con_say(void *result, void *user_data)
|
||||
{
|
||||
((CHAT*)user_data)->say(0, console_arg_string(result, 0));
|
||||
|
@ -87,9 +87,9 @@ void CHAT::on_message(int msgtype, void *rawmsg)
|
|||
add_line(msg->cid, msg->team, msg->message);
|
||||
|
||||
if(msg->cid >= 0) // TODO: repair me
|
||||
snd_play(CHN_GUI, data->sounds[SOUND_CHAT_CLIENT].sounds[0].id, 0);
|
||||
gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_CLIENT, 0, vec2(0,0));
|
||||
else
|
||||
snd_play(CHN_GUI, data->sounds[SOUND_CHAT_SERVER].sounds[0].id, 0);
|
||||
gameclient.sounds->play(SOUNDS::CHN_GUI, SOUND_CHAT_SERVER, 0, vec2(0,0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -360,12 +360,6 @@ void CONSOLE::on_init()
|
|||
|
||||
|
||||
/*
|
||||
static void client_console_print(const char *str)
|
||||
{
|
||||
// TODO: repair me
|
||||
//local_console.print_line(str);
|
||||
}
|
||||
|
||||
void console_rcon_print(const char *line)
|
||||
{
|
||||
// TODO: repair me
|
||||
|
@ -378,16 +372,6 @@ static void con_team(void *result, void *user_data)
|
|||
send_switch_team(console_arg_int(result, 0));
|
||||
}
|
||||
|
||||
static void con_say(void *result, void *user_data)
|
||||
{
|
||||
chat_say(0, console_arg_string(result, 0));
|
||||
}
|
||||
|
||||
static void con_sayteam(void *result, void *user_data)
|
||||
{
|
||||
chat_say(1, console_arg_string(result, 0));
|
||||
}
|
||||
|
||||
void send_kill(int client_id);
|
||||
|
||||
static void con_kill(void *result, void *user_data)
|
||||
|
@ -421,16 +405,6 @@ static void con_key_input_nextprev_weapon(void *result, void *user_data)
|
|||
input_data.wanted_weapon = 0;
|
||||
}
|
||||
|
||||
static void con_toggle_local_console(void *result, void *user_data)
|
||||
{
|
||||
console_toggle(0);
|
||||
}
|
||||
|
||||
static void con_toggle_remote_console(void *result, void *user_data)
|
||||
{
|
||||
console_toggle(1);
|
||||
}
|
||||
|
||||
static void con_emote(void *result, void *user_data)
|
||||
{
|
||||
send_emoticon(console_arg_int(result, 0));
|
||||
|
@ -458,30 +432,8 @@ void client_console_init()
|
|||
MACRO_REGISTER_COMMAND("dump_binds", "", con_dump_binds, 0x0);
|
||||
|
||||
// chatting
|
||||
MACRO_REGISTER_COMMAND("say", "r", con_say, 0x0);
|
||||
MACRO_REGISTER_COMMAND("say_team", "r", con_sayteam, 0x0);
|
||||
MACRO_REGISTER_COMMAND("chat", "s", con_chat, 0x0);
|
||||
MACRO_REGISTER_COMMAND("emote", "i", con_emote, 0);
|
||||
|
||||
// game commands
|
||||
MACRO_REGISTER_COMMAND("+left", "", con_key_input_state, &input_direction_left);
|
||||
MACRO_REGISTER_COMMAND("+right", "", con_key_input_state, &input_direction_right);
|
||||
MACRO_REGISTER_COMMAND("+jump", "", con_key_input_state, &input_data.jump);
|
||||
MACRO_REGISTER_COMMAND("+hook", "", con_key_input_state, &input_data.hook);
|
||||
MACRO_REGISTER_COMMAND("+fire", "", con_key_input_counter, &input_data.fire);
|
||||
MACRO_REGISTER_COMMAND("+weapon1", "", con_key_input_weapon, (void *)1);
|
||||
MACRO_REGISTER_COMMAND("+weapon2", "", con_key_input_weapon, (void *)2);
|
||||
MACRO_REGISTER_COMMAND("+weapon3", "", con_key_input_weapon, (void *)3);
|
||||
MACRO_REGISTER_COMMAND("+weapon4", "", con_key_input_weapon, (void *)4);
|
||||
MACRO_REGISTER_COMMAND("+weapon5", "", con_key_input_weapon, (void *)5);
|
||||
|
||||
MACRO_REGISTER_COMMAND("+nextweapon", "", con_key_input_nextprev_weapon, &input_data.next_weapon);
|
||||
MACRO_REGISTER_COMMAND("+prevweapon", "", con_key_input_nextprev_weapon, &input_data.prev_weapon);
|
||||
|
||||
MACRO_REGISTER_COMMAND("+emote", "", con_key_input_state, &emoticon_selector_active);
|
||||
MACRO_REGISTER_COMMAND("+scoreboard", "", con_key_input_state, &scoreboard_active);
|
||||
|
||||
binds_default();
|
||||
}
|
||||
|
||||
bool console_input_cli(INPUT_EVENT e, void *user_data)
|
||||
|
@ -524,41 +476,4 @@ bool console_input_normal_binds(INPUT_EVENT e, void *user_data)
|
|||
return false;
|
||||
return console_execute_event(e);
|
||||
}
|
||||
|
||||
void console_toggle(int type)
|
||||
{
|
||||
if(console_type != type && (console_state == CONSOLE_OPEN || console_state == CONSOLE_OPENING))
|
||||
{
|
||||
// don't toggle console, just switch what console to use
|
||||
}
|
||||
else
|
||||
{
|
||||
if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_OPEN)
|
||||
{
|
||||
state_change_end = time_now()+state_change_duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
float progress = state_change_end-time_now();
|
||||
float reversed_progress = state_change_duration-progress;
|
||||
|
||||
state_change_end = time_now()+reversed_progress;
|
||||
}
|
||||
|
||||
if (console_state == CONSOLE_CLOSED || console_state == CONSOLE_CLOSING)
|
||||
console_state = CONSOLE_OPENING;
|
||||
else
|
||||
console_state = CONSOLE_CLOSING;
|
||||
}
|
||||
|
||||
console_type = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int console_active()
|
||||
{
|
||||
return console_state != CONSOLE_CLOSED;
|
||||
}
|
||||
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,7 @@ void DEBUGHUD::render_netcorrections()
|
|||
|
||||
float velspeed = length(vec2(gameclient.snap.local_character->vx/256.0f, gameclient.snap.local_character->vy/256.0f))*50;
|
||||
|
||||
float ramp = velocity_ramp(velspeed, tuning.velramp_start, tuning.velramp_range, tuning.velramp_curvature);
|
||||
float ramp = velocity_ramp(velspeed, gameclient.tuning.velramp_start, gameclient.tuning.velramp_range, gameclient.tuning.velramp_curvature);
|
||||
|
||||
char buf[512];
|
||||
str_format(buf, sizeof(buf), "%.0f\n%.0f\n%.2f\n%d %s\n%d %d",
|
||||
|
@ -59,7 +59,7 @@ void DEBUGHUD::render_tuning()
|
|||
{
|
||||
char buf[128];
|
||||
float current, standard;
|
||||
tuning.get(i, ¤t);
|
||||
gameclient.tuning.get(i, ¤t);
|
||||
standard_tuning.get(i, &standard);
|
||||
|
||||
if(standard == current)
|
||||
|
@ -96,7 +96,7 @@ void DEBUGHUD::render_tuning()
|
|||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
float speed = i/100.0f * 3000;
|
||||
float ramp = velocity_ramp(speed, tuning.velramp_start, tuning.velramp_range, tuning.velramp_curvature);
|
||||
float ramp = velocity_ramp(speed, gameclient.tuning.velramp_start, gameclient.tuning.velramp_range, gameclient.tuning.velramp_curvature);
|
||||
float rampedspeed = (speed * ramp)/1000.0f;
|
||||
gfx_lines_draw((i-1)*2, y+height-pv*height, i*2, y+height-rampedspeed*height);
|
||||
//gfx_lines_draw((i-1)*2, 200, i*2, 200);
|
||||
|
|
|
@ -173,7 +173,7 @@ void HUD::render_tunewarning()
|
|||
|
||||
// render warning about non standard tuning
|
||||
bool flash = time_get()/(time_freq()/2)%2 == 0;
|
||||
if(config.cl_warning_tuning && memcmp(&standard_tuning, &tuning, sizeof(TUNING_PARAMS)) != 0)
|
||||
if(config.cl_warning_tuning && memcmp(&standard_tuning, &gameclient.tuning, sizeof(TUNING_PARAMS)) != 0)
|
||||
{
|
||||
const char *text = "Warning! Server is running non-standard tuning.";
|
||||
if(flash)
|
||||
|
|
|
@ -23,18 +23,18 @@ void ITEMS::render_projectile(const NETOBJ_PROJECTILE *current, int itemid)
|
|||
float speed = 0;
|
||||
if(current->type == WEAPON_GRENADE)
|
||||
{
|
||||
curvature = tuning.grenade_curvature;
|
||||
speed = tuning.grenade_speed;
|
||||
curvature = gameclient.tuning.grenade_curvature;
|
||||
speed = gameclient.tuning.grenade_speed;
|
||||
}
|
||||
else if(current->type == WEAPON_SHOTGUN)
|
||||
{
|
||||
curvature = tuning.shotgun_curvature;
|
||||
speed = tuning.shotgun_speed;
|
||||
curvature = gameclient.tuning.shotgun_curvature;
|
||||
speed = gameclient.tuning.shotgun_speed;
|
||||
}
|
||||
else if(current->type == WEAPON_GUN)
|
||||
{
|
||||
curvature = tuning.gun_curvature;
|
||||
speed = tuning.gun_speed;
|
||||
curvature = gameclient.tuning.gun_curvature;
|
||||
speed = gameclient.tuning.gun_speed;
|
||||
}
|
||||
|
||||
float ct = (client_tick()-current->start_tick)/(float)SERVER_TICK_SPEED + client_ticktime()*1/(float)SERVER_TICK_SPEED;
|
||||
|
@ -151,7 +151,7 @@ void ITEMS::render_laser(const struct NETOBJ_LASER *current)
|
|||
|
||||
float ticks = client_tick() + client_intratick() - current->start_tick;
|
||||
float ms = (ticks/50.0f) * 1000.0f;
|
||||
float a = ms / tuning.laser_bounce_delay;
|
||||
float a = ms / gameclient.tuning.laser_bounce_delay;
|
||||
a = clamp(a, 0.0f, 1.0f);
|
||||
float ia = 1-a;
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include "menus.hpp"
|
||||
#include "skins.hpp"
|
||||
|
||||
#include <engine/e_client_interface.h>
|
||||
|
||||
extern "C" {
|
||||
#include <engine/e_client_interface.h>
|
||||
#include <engine/e_config.h>
|
||||
#include <engine/client/ec_font.h>
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include <string.h> // strcmp, strlen, strncpy
|
||||
#include <stdlib.h> // atoi
|
||||
|
||||
#include <engine/e_client_interface.h>
|
||||
|
||||
extern "C" {
|
||||
#include <engine/e_client_interface.h>
|
||||
#include <engine/e_config.h>
|
||||
#include <engine/client/ec_font.h>
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
|
||||
extern "C" {
|
||||
#include <engine/e_config.h>
|
||||
}
|
||||
|
||||
#include <engine/e_client_interface.h>
|
||||
#include <game/generated/g_protocol.hpp>
|
||||
#include <game/generated/gc_data.hpp>
|
||||
|
@ -17,6 +12,7 @@ extern "C" {
|
|||
#include <game/client/components/flow.hpp>
|
||||
#include <game/client/components/skins.hpp>
|
||||
#include <game/client/components/effects.hpp>
|
||||
#include <game/client/components/sounds.hpp>
|
||||
|
||||
#include "players.hpp"
|
||||
|
||||
|
@ -178,7 +174,7 @@ void PLAYERS::render_player(
|
|||
static int64 skid_sound_time = 0;
|
||||
if(time_get()-skid_sound_time > time_freq()/10)
|
||||
{
|
||||
snd_play_random(CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, position);
|
||||
gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, position);
|
||||
skid_sound_time = time_get();
|
||||
}
|
||||
|
||||
|
|
42
src/game/client/components/sounds.cpp
Normal file
42
src/game/client/components/sounds.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include <engine/e_client_interface.h>
|
||||
#include <game/generated/gc_data.hpp>
|
||||
#include <game/client/gameclient.hpp>
|
||||
#include <game/client/components/camera.hpp>
|
||||
#include "sounds.hpp"
|
||||
|
||||
void SOUNDS::on_init()
|
||||
{
|
||||
// setup sound channels
|
||||
snd_set_channel(SOUNDS::CHN_GUI, 1.0f, 0.0f);
|
||||
snd_set_channel(SOUNDS::CHN_MUSIC, 1.0f, 0.0f);
|
||||
snd_set_channel(SOUNDS::CHN_WORLD, 0.9f, 1.0f);
|
||||
snd_set_channel(SOUNDS::CHN_GLOBAL, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
void SOUNDS::on_render()
|
||||
{
|
||||
// set listner pos
|
||||
snd_set_listener_pos(gameclient.camera->center.x, gameclient.camera->center.y);
|
||||
}
|
||||
|
||||
void SOUNDS::play(int chn, int setid, float vol, vec2 pos)
|
||||
{
|
||||
SOUNDSET *set = &data->sounds[setid];
|
||||
|
||||
if(!set->num_sounds)
|
||||
return;
|
||||
|
||||
if(set->num_sounds == 1)
|
||||
{
|
||||
snd_play_at(chn, set->sounds[0].id, 0, pos.x, pos.y);
|
||||
return;
|
||||
}
|
||||
|
||||
// play a random one
|
||||
int id;
|
||||
do {
|
||||
id = rand() % set->num_sounds;
|
||||
} while(id == set->last);
|
||||
snd_play_at(chn, set->sounds[id].id, 0, pos.x, pos.y);
|
||||
set->last = id;
|
||||
}
|
21
src/game/client/components/sounds.hpp
Normal file
21
src/game/client/components/sounds.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <game/client/component.hpp>
|
||||
|
||||
class SOUNDS : public COMPONENT
|
||||
{
|
||||
public:
|
||||
// sound channels
|
||||
enum
|
||||
{
|
||||
CHN_GUI=0,
|
||||
CHN_MUSIC,
|
||||
CHN_WORLD,
|
||||
CHN_GLOBAL,
|
||||
};
|
||||
|
||||
virtual void on_init();
|
||||
virtual void on_render();
|
||||
|
||||
void play(int chn, int setid, float vol, vec2 pos);
|
||||
};
|
||||
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
#include "components/controls.hpp"
|
||||
#include "components/effects.hpp"
|
||||
#include "components/scoreboard.hpp"
|
||||
#include "components/sounds.hpp"
|
||||
|
||||
GAMECLIENT gameclient;
|
||||
|
||||
|
@ -42,6 +43,7 @@ static DEBUGHUD debughud;
|
|||
static CONTROLS controls;
|
||||
static EFFECTS effects;
|
||||
static SCOREBOARD scoreboard;
|
||||
static SOUNDS sounds;
|
||||
|
||||
static PLAYERS players;
|
||||
static ITEMS items;
|
||||
|
@ -65,6 +67,7 @@ void GAMECLIENT::on_init()
|
|||
camera = &::camera;
|
||||
controls = &::controls;
|
||||
effects = &::effects;
|
||||
sounds = &::sounds;
|
||||
|
||||
// make a list of all the systems, make sure to add them in the corrent render order
|
||||
all.add(skins);
|
||||
|
@ -73,6 +76,7 @@ void GAMECLIENT::on_init()
|
|||
all.add(binds);
|
||||
all.add(controls);
|
||||
all.add(camera);
|
||||
all.add(sounds);
|
||||
all.add(particles); // doesn't render anything, just updates all the particles
|
||||
|
||||
all.add(&maplayers_background); // first to render
|
||||
|
@ -216,6 +220,48 @@ void GAMECLIENT::on_render()
|
|||
|
||||
void GAMECLIENT::on_message(int msgtype)
|
||||
{
|
||||
|
||||
// special messages
|
||||
if(msgtype == NETMSGTYPE_SV_EXTRAPROJECTILE)
|
||||
{
|
||||
/*
|
||||
int num = msg_unpack_int();
|
||||
|
||||
for(int k = 0; k < num; k++)
|
||||
{
|
||||
NETOBJ_PROJECTILE proj;
|
||||
for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
|
||||
((int *)&proj)[i] = msg_unpack_int();
|
||||
|
||||
if(msg_unpack_error())
|
||||
return;
|
||||
|
||||
if(extraproj_num != MAX_EXTRA_PROJECTILES)
|
||||
{
|
||||
extraproj_projectiles[extraproj_num] = proj;
|
||||
extraproj_num++;
|
||||
}
|
||||
}
|
||||
|
||||
return;*/
|
||||
}
|
||||
else if(msgtype == NETMSGTYPE_SV_TUNEPARAMS)
|
||||
{
|
||||
// unpack the new tuning
|
||||
TUNING_PARAMS new_tuning;
|
||||
int *params = (int *)&new_tuning;
|
||||
for(unsigned i = 0; i < sizeof(TUNING_PARAMS)/sizeof(int); i++)
|
||||
params[i] = msg_unpack_int();
|
||||
|
||||
// check for unpacking errors
|
||||
if(msg_unpack_error())
|
||||
return;
|
||||
|
||||
// apply new tuning
|
||||
tuning = new_tuning;
|
||||
return;
|
||||
}
|
||||
|
||||
void *rawmsg = netmsg_secure_unpack(msgtype);
|
||||
if(!rawmsg)
|
||||
{
|
||||
|
@ -281,7 +327,7 @@ void GAMECLIENT::on_message(int msgtype)
|
|||
else if(msgtype == NETMSGTYPE_SV_SOUNDGLOBAL)
|
||||
{
|
||||
NETMSG_SV_SOUNDGLOBAL *msg = (NETMSG_SV_SOUNDGLOBAL *)rawmsg;
|
||||
snd_play_random(CHN_GLOBAL, msg->soundid, 1.0f, vec2(0,0));
|
||||
gameclient.sounds->play(SOUNDS::CHN_GLOBAL, msg->soundid, 1.0f, vec2(0,0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,7 +379,7 @@ void GAMECLIENT::process_events()
|
|||
else if(item.type == NETEVENTTYPE_SOUNDWORLD)
|
||||
{
|
||||
NETEVENT_SOUNDWORLD *ev = (NETEVENT_SOUNDWORLD *)data;
|
||||
snd_play_random(CHN_WORLD, ev->soundid, 1.0f, vec2(ev->x, ev->y));
|
||||
gameclient.sounds->play(SOUNDS::CHN_WORLD, ev->soundid, 1.0f, vec2(ev->x, ev->y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -501,15 +547,15 @@ void GAMECLIENT::on_predict()
|
|||
{
|
||||
vec2 pos = world.characters[local_cid]->pos;
|
||||
int events = world.characters[local_cid]->triggered_events;
|
||||
if(events&COREEVENT_GROUND_JUMP) snd_play_random(CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, pos);
|
||||
if(events&COREEVENT_GROUND_JUMP) gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, pos);
|
||||
if(events&COREEVENT_AIR_JUMP)
|
||||
{
|
||||
gameclient.effects->air_jump(pos);
|
||||
snd_play_random(CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, pos);
|
||||
gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, pos);
|
||||
}
|
||||
//if(events&COREEVENT_HOOK_LAUNCH) snd_play_random(CHN_WORLD, SOUND_HOOK_LOOP, 1.0f, pos);
|
||||
//if(events&COREEVENT_HOOK_ATTACH_PLAYER) snd_play_random(CHN_WORLD, SOUND_HOOK_ATTACH_PLAYER, 1.0f, pos);
|
||||
if(events&COREEVENT_HOOK_ATTACH_GROUND) snd_play_random(CHN_WORLD, SOUND_HOOK_ATTACH_GROUND, 1.0f, pos);
|
||||
if(events&COREEVENT_HOOK_ATTACH_GROUND) gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_HOOK_ATTACH_GROUND, 1.0f, pos);
|
||||
//if(events&COREEVENT_HOOK_RETRACT) snd_play_random(CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ class GAMECLIENT
|
|||
|
||||
public:
|
||||
|
||||
// TODO: move this
|
||||
TUNING_PARAMS tuning;
|
||||
|
||||
vec2 local_character_pos;
|
||||
vec2 local_target_pos;
|
||||
|
||||
|
@ -103,6 +106,7 @@ public:
|
|||
class CAMERA *camera;
|
||||
class CONTROLS *controls;
|
||||
class EFFECTS *effects;
|
||||
class SOUNDS *sounds;
|
||||
};
|
||||
|
||||
extern GAMECLIENT gameclient;
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
||||
#include <base/math.hpp>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern "C" {
|
||||
#include <engine/e_client_interface.h>
|
||||
};
|
||||
|
||||
#include "../gamecore.hpp"
|
||||
#include "../version.hpp"
|
||||
#include "../layers.hpp"
|
||||
#include "gc_map_image.hpp"
|
||||
#include "../generated/gc_data.hpp"
|
||||
#include "gc_ui.hpp"
|
||||
#include "gc_client.hpp"
|
||||
#include "gc_render.hpp"
|
||||
|
||||
#include "components/skins.hpp"
|
||||
#include "components/damageind.hpp"
|
||||
#include "gameclient.hpp"
|
||||
|
||||
TUNING_PARAMS tuning;
|
||||
|
||||
void snd_play_random(int chn, int setid, float vol, vec2 pos)
|
||||
{
|
||||
SOUNDSET *set = &data->sounds[setid];
|
||||
|
||||
if(!set->num_sounds)
|
||||
return;
|
||||
|
||||
if(set->num_sounds == 1)
|
||||
{
|
||||
snd_play_at(chn, set->sounds[0].id, 0, pos.x, pos.y);
|
||||
return;
|
||||
}
|
||||
|
||||
// play a random one
|
||||
int id;
|
||||
do {
|
||||
id = rand() % set->num_sounds;
|
||||
} while(id == set->last);
|
||||
snd_play_at(chn, set->sounds[id].id, 0, pos.x, pos.y);
|
||||
set->last = id;
|
||||
}
|
|
@ -5,15 +5,6 @@
|
|||
|
||||
#include <game/client/gc_render.hpp>
|
||||
|
||||
// sound channels
|
||||
enum
|
||||
{
|
||||
CHN_GUI=0,
|
||||
CHN_MUSIC,
|
||||
CHN_WORLD,
|
||||
CHN_GLOBAL,
|
||||
};
|
||||
|
||||
extern TUNING_PARAMS tuning;
|
||||
|
||||
// predicted players
|
||||
|
@ -31,9 +22,8 @@ extern int extraproj_num;
|
|||
void extraproj_reset();
|
||||
|
||||
// various helpers
|
||||
void snd_play_random(int chn, int setid, float vol, vec2 pos);
|
||||
|
||||
void chat_enable_mode(int team);
|
||||
//void snd_play_random(int chn, int setid, float vol, vec2 pos);
|
||||
//void chat_enable_mode(int team);
|
||||
|
||||
inline vec2 random_dir() { return normalize(vec2(frandom()-0.5f, frandom()-0.5f)); }
|
||||
|
||||
|
|
|
@ -73,12 +73,6 @@ extern "C" void modc_init()
|
|||
//particle_reset();
|
||||
//menu_init();
|
||||
|
||||
// setup sound channels
|
||||
snd_set_channel(CHN_GUI, 1.0f, 0.0f);
|
||||
snd_set_channel(CHN_MUSIC, 1.0f, 0.0f);
|
||||
snd_set_channel(CHN_WORLD, 0.9f, 1.0f);
|
||||
snd_set_channel(CHN_GLOBAL, 1.0f, 0.0f);
|
||||
|
||||
// load the data container
|
||||
//data = load_data_from_memory(internal_data);
|
||||
|
||||
|
@ -145,47 +139,6 @@ void extraproj_reset()
|
|||
|
||||
extern "C" void modc_message(int msgtype)
|
||||
{
|
||||
// special messages
|
||||
if(msgtype == NETMSGTYPE_SV_EXTRAPROJECTILE)
|
||||
{
|
||||
/*
|
||||
int num = msg_unpack_int();
|
||||
|
||||
for(int k = 0; k < num; k++)
|
||||
{
|
||||
NETOBJ_PROJECTILE proj;
|
||||
for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
|
||||
((int *)&proj)[i] = msg_unpack_int();
|
||||
|
||||
if(msg_unpack_error())
|
||||
return;
|
||||
|
||||
if(extraproj_num != MAX_EXTRA_PROJECTILES)
|
||||
{
|
||||
extraproj_projectiles[extraproj_num] = proj;
|
||||
extraproj_num++;
|
||||
}
|
||||
}
|
||||
|
||||
return;*/
|
||||
}
|
||||
else if(msgtype == NETMSGTYPE_SV_TUNEPARAMS)
|
||||
{
|
||||
// unpack the new tuning
|
||||
TUNING_PARAMS new_tuning;
|
||||
int *params = (int *)&new_tuning;
|
||||
for(unsigned i = 0; i < sizeof(TUNING_PARAMS)/sizeof(int); i++)
|
||||
params[i] = msg_unpack_int();
|
||||
|
||||
// check for unpacking errors
|
||||
if(msg_unpack_error())
|
||||
return;
|
||||
|
||||
// apply new tuning
|
||||
tuning = new_tuning;
|
||||
return;
|
||||
}
|
||||
|
||||
gameclient.on_message(msgtype);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue