changed the bindings commands to bind, unbind and dump_binds. added broadcast messages. fixed so that cl_editor works

This commit is contained in:
Magnus Auvinen 2008-03-22 11:45:48 +00:00
parent bede40f27d
commit 7797a65167
7 changed files with 50 additions and 14 deletions

View file

@ -1221,7 +1221,6 @@ static void client_run()
NETADDR4 bindaddr;
int64 reporttime = time_get();
int64 reportinterval = time_freq()*1;
int editor_active = 0;
static PERFORMACE_INFO rootscope = {"root", 0};
perf_start(&rootscope);
@ -1260,6 +1259,9 @@ static void client_run()
client_connect(config.cl_connect);
config.cl_connect[0] = 0;
*/
/* never start with the editor */
config.cl_editor = 0;
inp_mouse_mode_relative();
@ -1315,13 +1317,13 @@ static void client_run()
break;
if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('E'))
editor_active = editor_active^1;
config.cl_editor = config.cl_editor^1;
if(!gfx_window_open())
break;
/* render */
if(editor_active)
if(config.cl_editor)
{
client_update();
editor_update_and_render();

View file

@ -74,6 +74,10 @@ void client_data::update_render_info()
}
// broadcasts
char broadcast_text[1024] = {0};
int64 broadcast_time = 0;
void snd_play_random(int chn, int setid, float vol, vec2 pos)
{
soundset *set = &data->sounds[setid];
@ -1523,8 +1527,6 @@ void render_game()
render_spectators(width/2-w/2, 150+750+25+50+25, w);
}
{
gfx_mapscreen(0, 0, 300*gfx_screenaspect(), 300);
@ -1535,6 +1537,12 @@ void render_game()
gfx_text(0, 150*gfx_screenaspect()-w/2, 50, 24, text, -1);
}
if(time_get() < broadcast_time+time_freq()*5)
{
float w = gfx_text_width(0, 16, broadcast_text, -1);
gfx_text(0, 150*gfx_screenaspect()-w/2, 50, 16, broadcast_text, -1);
}
tuning_params standard_tuning;
// render warning about non standard tuning

View file

@ -75,8 +75,6 @@ enum
CHATMODE_NONE=0,
CHATMODE_ALL,
CHATMODE_TEAM,
//CHATMODE_CONSOLE,
//CHATMODE_REMOTECONSOLE,
};
extern int chat_mode;
@ -84,6 +82,10 @@ void chat_add_line(int client_id, int team, const char *line);
void chat_reset();
bool chat_input_handle(INPUT_EVENT e, void *user_data);
// broadcasts
extern char broadcast_text[1024];
extern int64 broadcast_time;
// line input helter
class line_input
{

View file

@ -243,7 +243,7 @@ static int get_key_id(const char *key_name)
return 0;
}
static void con_binds_set(void *result, void *user_data)
static void con_bind(void *result, void *user_data)
{
const char *key_name = console_arg_string(result, 0);
int id = get_key_id(key_name);
@ -258,7 +258,7 @@ static void con_binds_set(void *result, void *user_data)
}
static void con_binds_remove(void *result, void *user_data)
static void con_unbind(void *result, void *user_data)
{
const char *key_name = console_arg_string(result, 0);
int id = get_key_id(key_name);
@ -272,7 +272,7 @@ static void con_binds_remove(void *result, void *user_data)
binds_set(id, "");
}
static void con_binds_dump(void *result, void *user_data)
static void con_dump_binds(void *result, void *user_data)
{
for(int i = 0; i < KEY_LAST; i++)
{
@ -289,7 +289,7 @@ void binds_save()
{
if(keybindings[i][0] == 0)
continue;
str_format(buffer, sizeof(buffer), "binds_set %s %s", inp_key_name(i), keybindings[i]);
str_format(buffer, sizeof(buffer), "bind %s %s", inp_key_name(i), keybindings[i]);
client_save_line(buffer);
}
}
@ -342,9 +342,9 @@ void client_console_init()
MACRO_REGISTER_COMMAND("kill", "", con_kill, 0x0);
// bindings
MACRO_REGISTER_COMMAND("binds_set", "sr", con_binds_set, 0x0);
MACRO_REGISTER_COMMAND("binds_remove", "s", con_binds_remove, 0x0);
MACRO_REGISTER_COMMAND("binds_dump", "", con_binds_dump, 0x0);
MACRO_REGISTER_COMMAND("bind", "sr", con_bind, 0x0);
MACRO_REGISTER_COMMAND("unbind", "s", con_unbind, 0x0);
MACRO_REGISTER_COMMAND("dump_binds", "", con_dump_binds, 0x0);
// chatting
MACRO_REGISTER_COMMAND("say", "r", con_say, 0x0);

View file

@ -524,6 +524,12 @@ extern "C" void modc_message(int msgtype)
else
snd_play(CHN_GUI, data->sounds[SOUND_CHAT_SERVER].sounds[0].id, 0);
}
else if(msgtype == NETMSGTYPE_SV_BROADCAST)
{
NETMSG_SV_BROADCAST *msg = (NETMSG_SV_BROADCAST *)rawmsg;
str_copy(broadcast_text, msg->message, sizeof(broadcast_text));
broadcast_time = time_get();
}
else if(msgtype == NETMSGTYPE_SV_MOTD)
{
NETMSG_SV_MOTD *msg = (NETMSG_SV_MOTD *)rawmsg;

View file

@ -202,6 +202,10 @@ message sv_chat
string message
end
message sv_broadcast
string message
end
message sv_setinfo
range(0,MAX_CLIENTS-1) cid
string name

View file

@ -61,6 +61,14 @@ void send_chat(int cid, int team, const char *text)
}
void send_broadcast(const char *text)
{
NETMSG_SV_BROADCAST msg;
msg.message = text;
msg.pack(MSGFLAG_VITAL);
server_send_msg(-1);
}
void send_tuning_params(int cid)
{
msg_pack_start(NETMSGTYPE_SV_TUNE_PARAMS, MSGFLAG_VITAL);
@ -2214,6 +2222,11 @@ static void con_restart(void *result, void *user_data)
}
static void con_broadcast(void *result, void *user_data)
{
send_broadcast(console_arg_string(result, 0));
}
static void con_say(void *result, void *user_data)
{
send_chat(-1, -1, console_arg_string(result, 0));
}
@ -2226,6 +2239,7 @@ void mods_console_init()
MACRO_REGISTER_COMMAND("restart", "?i", con_restart, 0);
MACRO_REGISTER_COMMAND("broadcast", "r", con_broadcast, 0);
MACRO_REGISTER_COMMAND("say", "r", con_say, 0);
}
void mods_init()