mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
setting of correct game type in game controller. fixed gametype filter in browser. various cleanups
This commit is contained in:
parent
62d9ff05d6
commit
04eddacd65
|
@ -177,7 +177,7 @@ int gfx_init()
|
|||
}
|
||||
else
|
||||
{
|
||||
int result = glfwOpenWindow(screen_width, screen_height, 0, 0, 0, 8, 24, 0, GLFW_WINDOW);
|
||||
int result = glfwOpenWindow(screen_width, screen_height, 0, 0, 0, config.gfx_alphabits, 24, 0, GLFW_WINDOW);
|
||||
if(result != GL_TRUE)
|
||||
{
|
||||
dbg_msg("game", "failed to create gl context");
|
||||
|
|
|
@ -48,6 +48,7 @@ static int num_server_capacity = 0;
|
|||
|
||||
static int sorthash = 0;
|
||||
static char filterstring[64] = {0};
|
||||
static char filtergametypestring[128] = {0};
|
||||
|
||||
static int serverlist_lan = 1;
|
||||
static int64 broadcast_time = 0;
|
||||
|
@ -181,7 +182,13 @@ static void client_serverbrowse_filter()
|
|||
if(!matchfound)
|
||||
filtered = 1;
|
||||
}
|
||||
|
||||
else if(config.b_filter_gametype[0] != 0)
|
||||
{
|
||||
/* match against game type */
|
||||
if(!str_find_nocase(serverlist[i]->info.gametype, config.b_filter_gametype))
|
||||
filtered = 1;
|
||||
}
|
||||
|
||||
if(filtered == 0)
|
||||
sorted_serverlist[num_sorted_servers++] = i;
|
||||
}
|
||||
|
@ -195,7 +202,6 @@ static int client_serverbrowse_sorthash()
|
|||
i |= config.b_filter_pw<<6;
|
||||
i |= config.b_sort_order<<7;
|
||||
i |= config.b_filter_compatversion<<8;
|
||||
i |= config.b_filter_gametype<<9;
|
||||
i |= config.b_filter_ping<<16;
|
||||
return i;
|
||||
}
|
||||
|
@ -236,6 +242,7 @@ static void client_serverbrowse_sort()
|
|||
for(i = 0; i < num_sorted_servers; i++)
|
||||
serverlist[sorted_serverlist[i]]->info.sorted_index = i;
|
||||
|
||||
str_copy(filtergametypestring, config.b_filter_gametype, sizeof(filtergametypestring));
|
||||
str_copy(filterstring, config.b_filter_string, sizeof(filterstring));
|
||||
sorthash = client_serverbrowse_sorthash();
|
||||
}
|
||||
|
@ -467,6 +474,6 @@ void client_serverbrowse_update()
|
|||
|
||||
/* check if we need to resort */
|
||||
/* TODO: remove the strcmp */
|
||||
if(sorthash != client_serverbrowse_sorthash() || strcmp(filterstring, config.b_filter_string) != 0)
|
||||
if(sorthash != client_serverbrowse_sorthash() || strcmp(filterstring, config.b_filter_string) != 0 || strcmp(filtergametypestring, config.b_filter_gametype) != 0)
|
||||
client_serverbrowse_sort();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ MACRO_CONFIG_INT(b_filter_full, 0, 0, 1)
|
|||
MACRO_CONFIG_INT(b_filter_empty, 0, 0, 1)
|
||||
MACRO_CONFIG_INT(b_filter_pw, 0, 0, 1)
|
||||
MACRO_CONFIG_INT(b_filter_ping, 999, 0, 999)
|
||||
MACRO_CONFIG_INT(b_filter_gametype, 0xf, 0, 0xf)
|
||||
MACRO_CONFIG_STR(b_filter_gametype, 128, "")
|
||||
MACRO_CONFIG_INT(b_filter_compatversion, 1, 0, 1)
|
||||
|
||||
MACRO_CONFIG_INT(b_sort, 0, 0, 256)
|
||||
|
|
|
@ -65,6 +65,16 @@ void CONTROLS::on_init()
|
|||
{ static INPUTSET set = {this, &input_data.prev_weapon, 0}; MACRO_REGISTER_COMMAND("+prevweapon", "", con_key_input_nextprev_weapon, (void *)&set); }
|
||||
}
|
||||
|
||||
void CONTROLS::on_message(int msg, void *rawmsg)
|
||||
{
|
||||
if(msg == NETMSGTYPE_SV_WEAPONPICKUP)
|
||||
{
|
||||
NETMSG_SV_WEAPONPICKUP *msg = (NETMSG_SV_WEAPONPICKUP *)rawmsg;
|
||||
if(config.cl_autoswitch_weapons)
|
||||
input_data.wanted_weapon = msg->weapon+1;
|
||||
}
|
||||
}
|
||||
|
||||
int CONTROLS::snapinput(int *data)
|
||||
{
|
||||
static NETOBJ_PLAYER_INPUT last_data = {0};
|
||||
|
|
|
@ -12,6 +12,7 @@ public:
|
|||
int input_direction_right;
|
||||
|
||||
CONTROLS();
|
||||
virtual void on_message(int msg, void *rawmsg);
|
||||
virtual bool on_mousemove(float x, float y);
|
||||
virtual void on_init();
|
||||
|
||||
|
|
|
@ -296,7 +296,17 @@ void MENUS::render_serverbrowser(RECT main_view)
|
|||
ui_do_label(&button, version, 12.0f, 1);
|
||||
}
|
||||
else if(id == COL_GAMETYPE)
|
||||
ui_do_label(&button, item->gametype, 12.0f, 0);
|
||||
{
|
||||
// all these are just for nice compability
|
||||
if(item->gametype[0] == '0' && item->gametype[1] == 0)
|
||||
ui_do_label(&button, "DM", 12.0f, 0);
|
||||
else if(item->gametype[0] == '1' && item->gametype[1] == 0)
|
||||
ui_do_label(&button, "TDM", 12.0f, 0);
|
||||
else if(item->gametype[0] == '2' && item->gametype[1] == 0)
|
||||
ui_do_label(&button, "CTF", 12.0f, 0);
|
||||
else
|
||||
ui_do_label(&button, item->gametype, 12.0f, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,8 +435,16 @@ void MENUS::render_serverbrowser(RECT main_view)
|
|||
ui_hsplit_t(&filters, 20.0f, &button, &filters);
|
||||
ui_do_label(&button, "Quick search: ", 14.0f, -1);
|
||||
ui_vsplit_l(&button, 95.0f, 0, &button);
|
||||
ui_margin(&button, 1.0f, &button);
|
||||
ui_do_edit_box(&config.b_filter_string, &button, config.b_filter_string, sizeof(config.b_filter_string), 14.0f);
|
||||
|
||||
|
||||
ui_hsplit_t(&filters, 20.0f, &button, &filters);
|
||||
ui_do_label(&button, "Game types: ", 14.0f, -1);
|
||||
ui_vsplit_l(&button, 95.0f, 0, &button);
|
||||
ui_margin(&button, 1.0f, &button);
|
||||
ui_do_edit_box(&config.b_filter_gametype, &button, config.b_filter_gametype, sizeof(config.b_filter_gametype), 14.0f);
|
||||
|
||||
ui_vsplit_l(&filters, 180.0f, &filters, &types);
|
||||
|
||||
// render filters
|
||||
|
@ -442,10 +460,6 @@ void MENUS::render_serverbrowser(RECT main_view)
|
|||
if (ui_do_button(&config.b_filter_pw, "No password", config.b_filter_pw, &button, ui_draw_checkbox, 0))
|
||||
config.b_filter_pw ^= 1;
|
||||
|
||||
ui_hsplit_t(&filters, 20.0f, &button, &filters);
|
||||
if (ui_do_button((char *)&config.b_filter_compatversion, "Compatible Version", config.b_filter_compatversion, &button, ui_draw_checkbox, 0))
|
||||
config.b_filter_compatversion ^= 1;
|
||||
|
||||
// game types
|
||||
/*
|
||||
ui_hsplit_t(&types, 20.0f, &button, &types);
|
||||
|
@ -462,8 +476,13 @@ void MENUS::render_serverbrowser(RECT main_view)
|
|||
*/
|
||||
|
||||
// ping
|
||||
ui_hsplit_t(&types, 20.0f, &button, &types);
|
||||
if (ui_do_button((char *)&config.b_filter_compatversion, "Compatible Version", config.b_filter_compatversion, &button, ui_draw_checkbox, 0))
|
||||
config.b_filter_compatversion ^= 1;
|
||||
|
||||
ui_hsplit_t(&types, 2.0f, &button, &types);
|
||||
ui_hsplit_t(&types, 20.0f, &button, &types);
|
||||
|
||||
{
|
||||
RECT editbox;
|
||||
ui_vsplit_l(&button, 40.0f, &editbox, &button);
|
||||
|
@ -517,7 +536,7 @@ void MENUS::render_serverbrowser(RECT main_view)
|
|||
config.b_filter_empty = 0;
|
||||
config.b_filter_pw = 0;
|
||||
config.b_filter_ping = 999;
|
||||
config.b_filter_gametype = 0xf;
|
||||
config.b_filter_gametype[0] = 0;
|
||||
config.b_filter_compatversion = 1;
|
||||
config.b_filter_string[0] = 0;
|
||||
}
|
||||
|
|
|
@ -225,23 +225,30 @@ void SCOREBOARD::render_scoreboard(float x, float y, float w, int team, const ch
|
|||
|
||||
void SCOREBOARD::on_render()
|
||||
{
|
||||
if(!active)
|
||||
bool do_scoreboard = false;
|
||||
|
||||
// if we activly wanna look on the scoreboard
|
||||
if(active)
|
||||
do_scoreboard = true;
|
||||
|
||||
if(gameclient.snap.local_info && gameclient.snap.local_info->team != -1)
|
||||
{
|
||||
// we are not a spectator, check if we are ead
|
||||
if(!gameclient.snap.local_character || gameclient.snap.local_character->health < 0)
|
||||
do_scoreboard = true;
|
||||
}
|
||||
|
||||
// if we the game is over
|
||||
if(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over)
|
||||
do_scoreboard = true;
|
||||
|
||||
if(!do_scoreboard)
|
||||
return;
|
||||
|
||||
// if the score board is active, then we should clear the motd message aswell
|
||||
gameclient.motd->clear();
|
||||
if(active)
|
||||
gameclient.motd->clear();
|
||||
|
||||
// TODO: repair me
|
||||
/*
|
||||
bool do_scoreboard = false;
|
||||
|
||||
// if we are dead
|
||||
if(!spectate && (!gameclient.snap.local_character || gameclient.snap.local_character->health < 0))
|
||||
do_scoreboard = true;
|
||||
|
||||
// if we the game is over
|
||||
if(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over)
|
||||
do_scoreboard = true;*/
|
||||
|
||||
float width = 400*3.0f*gfx_screenaspect();
|
||||
float height = 400*3.0f;
|
||||
|
|
|
@ -73,7 +73,7 @@ static void load_sounds_thread(void *do_render)
|
|||
// load sounds
|
||||
for(int s = 0; s < data->num_sounds; s++)
|
||||
{
|
||||
if(do_render) // TODO: repair me
|
||||
if(do_render)
|
||||
gameclient.menus->render_loading(load_current/(float)load_total);
|
||||
for(int i = 0; i < data->sounds[s].num_sounds; i++)
|
||||
{
|
||||
|
@ -175,7 +175,6 @@ void GAMECLIENT::on_init()
|
|||
// load textures
|
||||
for(int i = 0; i < data->num_images; i++)
|
||||
{
|
||||
// TODO: repair me
|
||||
gameclient.menus->render_loading(load_current/load_total);
|
||||
data->images[i].id = gfx_load_texture(data->images[i].filename, IMG_AUTO, 0);
|
||||
load_current++;
|
||||
|
@ -387,13 +386,6 @@ void GAMECLIENT::on_message(int msgtype)
|
|||
|
||||
clients[msg->cid].update_render_info();
|
||||
}
|
||||
else if(msgtype == NETMSGTYPE_SV_WEAPONPICKUP)
|
||||
{
|
||||
// TODO: repair me
|
||||
/*NETMSG_SV_WEAPONPICKUP *msg = (NETMSG_SV_WEAPONPICKUP *)rawmsg;
|
||||
if(config.cl_autoswitch_weapons)
|
||||
input_data.wanted_weapon = msg->weapon+1;*/
|
||||
}
|
||||
else if(msgtype == NETMSGTYPE_SV_READYTOENTER)
|
||||
{
|
||||
client_entergame();
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
GAMECONTROLLER::GAMECONTROLLER()
|
||||
{
|
||||
gametype = config.sv_gametype;
|
||||
gametype = "unknown";
|
||||
|
||||
//
|
||||
do_warmup(config.sv_warmup);
|
||||
|
|
|
@ -10,6 +10,7 @@ GAMECONTROLLER_CTF::GAMECONTROLLER_CTF()
|
|||
{
|
||||
flags[0] = 0;
|
||||
flags[1] = 0;
|
||||
gametype = "CTF";
|
||||
game_flags = GAMEFLAG_TEAMS|GAMEFLAG_FLAGS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
||||
#include "dm.hpp"
|
||||
|
||||
|
||||
GAMECONTROLLER_DM::GAMECONTROLLER_DM()
|
||||
{
|
||||
gametype = "DM";
|
||||
}
|
||||
|
||||
void GAMECONTROLLER_DM::tick()
|
||||
{
|
||||
do_player_score_wincheck();
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
class GAMECONTROLLER_DM : public GAMECONTROLLER
|
||||
{
|
||||
public:
|
||||
GAMECONTROLLER_DM();
|
||||
virtual void tick();
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
GAMECONTROLLER_TDM::GAMECONTROLLER_TDM()
|
||||
{
|
||||
gametype = "TDM";
|
||||
game_flags = GAMEFLAG_TEAMS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue