more of the chat and console stuff

This commit is contained in:
Magnus Auvinen 2007-12-09 09:51:26 +00:00
parent 0aea326dca
commit 12d13a2d34

View file

@ -38,6 +38,8 @@ enum
CHATMODE_NONE=0,
CHATMODE_ALL,
CHATMODE_TEAM,
CHATMODE_CONSOLE,
CHATMODE_REMOTECONSOLE,
};
static int chat_mode = CHATMODE_NONE;
@ -725,6 +727,7 @@ static void process_events(int s)
static player_core predicted_prev_player;
static player_core predicted_player;
static int last_new_predicted_tick = -1;
extern "C" void modc_predict()
{
@ -756,11 +759,18 @@ extern "C" void modc_predict()
}
// predict
int num_predicted = 0;
int got = 0;
for(int tick = client_tick()+1; tick <= client_predtick(); tick++)
{
num_predicted++;
// fetch the local
if(tick == client_predtick() && world.players[local_cid])
{
got|=1;
predicted_prev_player = *world.players[local_cid];
}
// first calculate where everyone should move
for(int c = 0; c < MAX_CLIENTS; c++)
@ -788,11 +798,26 @@ extern "C" void modc_predict()
world.players[c]->move();
world.players[c]->quantize();
if(tick > last_new_predicted_tick)
{
last_new_predicted_tick = tick;
/*
dbg_msg("predict", "%d %d %d", tick,
(int)world.players[c]->pos.x, (int)world.players[c]->pos.y,
(int)world.players[c]->vel.x, (int)world.players[c]->vel.y);*/
}
}
if(tick == client_predtick() && world.players[local_cid])
{
got|=2;
predicted_player = *world.players[local_cid];
}
}
if(got!=3)
dbg_msg("predict", "way few predictions %d %d", num_predicted, got);
}
extern "C" void modc_newsnapshot()
@ -1844,6 +1869,24 @@ void render_world(float center_x, float center_y, float zoom)
// draw the sun
if(config.gfx_high_detail)
{
if(0)
{
gfx_mapscreen(0,0,1,1);
gfx_texture_set(-1);
gfx_quads_begin();
vec4 top(0x11/(float)0xff, 0x1a/(float)0xff, 0x21/(float)0xff, 1.0f);
vec4 bottom(0x2a/(float)0xff, 0x40/(float)0xff, 0x52/(float)0xff, 1.0f);
gfx_setcolorvertex(0, top.r, top.g, top.b, top.a);
gfx_setcolorvertex(1, top.r, top.g, top.b, top.a);
gfx_setcolorvertex(2, bottom.r, bottom.g, bottom.b, bottom.a);
gfx_setcolorvertex(3, bottom.r, bottom.g, bottom.b, bottom.a);
gfx_quads_drawTL(0, 0, 1, 1);
gfx_quads_end();
mapscreen_to_world(center_x, center_y, zoom);
}
else
{
render_sun(20+center_x*0.6f, 20+center_y*0.6f);
@ -1863,7 +1906,6 @@ void render_world(float center_x, float center_y, float zoom)
}
gfx_quads_end();
// draw backdrop
gfx_texture_set(data->images[IMAGE_BACKDROP].id);
gfx_quads_begin();
@ -1872,6 +1914,7 @@ void render_world(float center_x, float center_y, float zoom)
gfx_quads_drawTL(1024*x+center_x*parallax_amount, (center_y)*parallax_amount+150+512, 1024, 512);
gfx_quads_end();
}
}
// render background tilemaps
tilemap_render(32.0f, 0);
@ -2006,12 +2049,9 @@ void render_game()
// send message
if(chat_input_len)
{
if(chat_input[0] == '/') // check for local command
config_set(&chat_input[1]);
else
{
// check for remote command
if(inp_key_pressed(KEY_RSHIFT) || inp_key_pressed(KEY_LSHIFT))
if(chat_mode == CHATMODE_CONSOLE)
config_set(chat_input);
else if(chat_mode == CHATMODE_REMOTECONSOLE)
client_rcon(chat_input);
else
{
@ -2026,7 +2066,6 @@ void render_game()
client_send_msg();
}
}
}
chat_mode = CHATMODE_NONE;
}
@ -2064,6 +2103,12 @@ void render_game()
if(inp_key_down(config.key_teamchat))
chat_mode = CHATMODE_TEAM;
if(inp_key_down(config.key_console))
chat_mode = CHATMODE_CONSOLE;
if(inp_key_down(config.key_remoteconsole))
chat_mode = CHATMODE_REMOTECONSOLE;
if(chat_mode != CHATMODE_NONE)
{
mem_zero(chat_input, sizeof(chat_input));
@ -2454,6 +2499,10 @@ void render_game()
sprintf(buf, "All: %s_", chat_input);
else if(chat_mode == CHATMODE_TEAM)
sprintf(buf, "Team: %s_", chat_input);
else if(chat_mode == CHATMODE_CONSOLE)
sprintf(buf, "Console: %s_", chat_input);
else if(chat_mode == CHATMODE_REMOTECONSOLE)
sprintf(buf, "Rcon: %s_", chat_input);
else
sprintf(buf, "Chat: %s_", chat_input);
gfx_pretty_text(x, y, 10.0f, buf, 380);