mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
removed the GAMETYPE_ enum
This commit is contained in:
parent
5198d6bf01
commit
0a48454a55
|
@ -2,8 +2,7 @@ from datatypes import *
|
|||
|
||||
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
|
||||
PlayerStates = ["UNKNOWN", "PLAYING", "IN_MENU", "CHATTING"]
|
||||
GameTypes = ["DM", "TDM", "CTF"]
|
||||
GameFlags = ["TEAMS"]
|
||||
GameFlags = ["TEAMS", "FLAGS"]
|
||||
|
||||
Emoticons = [str(x) for x in xrange(1,16)]
|
||||
|
||||
|
@ -22,7 +21,6 @@ RawSource = '''
|
|||
'''
|
||||
|
||||
Enums = [
|
||||
Enum("GAMETYPE", GameTypes),
|
||||
Enum("PLAYERSTATE", PlayerStates),
|
||||
Enum("EMOTE", Emotes),
|
||||
Enum("POWERUP", Powerups),
|
||||
|
@ -96,7 +94,6 @@ Objects = [
|
|||
|
||||
NetIntRange("score_limit", 0, 'max_int'),
|
||||
NetIntRange("time_limit", 0, 'max_int'),
|
||||
NetIntRange("gametype", 0, len(GameTypes)),
|
||||
|
||||
NetIntRange("warmup", 0, 'max_int'),
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void server_setclientscore(int client_id, int score);
|
|||
See Also:
|
||||
<other_func>
|
||||
*/
|
||||
void server_setbrowseinfo(int game_type, int progression);
|
||||
void server_setbrowseinfo(const char *game_type, int progression);
|
||||
|
||||
/*
|
||||
Function: server_kick
|
||||
|
|
|
@ -27,7 +27,7 @@ static int64 game_start_time;
|
|||
static int current_tick = 0;
|
||||
static int run_server = 1;
|
||||
|
||||
static int browseinfo_gametype = -1;
|
||||
static char browseinfo_gametype[16] = {0};
|
||||
static int browseinfo_progression = -1;
|
||||
|
||||
static int64 lastheartbeat;
|
||||
|
@ -250,9 +250,9 @@ void server_setclientscore(int client_id, int score)
|
|||
clients[client_id].score = score;
|
||||
}
|
||||
|
||||
void server_setbrowseinfo(int game_type, int progression)
|
||||
void server_setbrowseinfo(const char *game_type, int progression)
|
||||
{
|
||||
browseinfo_gametype = game_type;
|
||||
str_copy(browseinfo_gametype, game_type, sizeof(browseinfo_gametype));
|
||||
browseinfo_progression = progression;
|
||||
if(browseinfo_progression > 100)
|
||||
browseinfo_progression = 100;
|
||||
|
|
|
@ -31,7 +31,6 @@ void HUD::render_goals()
|
|||
// render_scorehud
|
||||
// render_warmuptimer
|
||||
|
||||
int gametype = gameclient.snap.gameobj->gametype;
|
||||
int gameflags = gameclient.snap.gameobj->flags;
|
||||
|
||||
float whole = 300*gfx_screenaspect();
|
||||
|
@ -84,7 +83,7 @@ void HUD::render_goals()
|
|||
str_format(buf, sizeof(buf), "%d", t?gameclient.snap.gameobj->teamscore_blue:gameclient.snap.gameobj->teamscore_red);
|
||||
float w = gfx_text_width(0, 14, buf, -1);
|
||||
|
||||
if(gametype == GAMETYPE_CTF)
|
||||
if(gameflags&GAMEFLAG_FLAGS)
|
||||
{
|
||||
gfx_text(0, whole-20-w/2+5, 300-40-15+t*20, 14, buf, -1);
|
||||
if(gameclient.snap.flags[t])
|
||||
|
|
|
@ -62,7 +62,7 @@ void KILLMESSAGES::on_render()
|
|||
// render victim tee
|
||||
x -= 24.0f;
|
||||
|
||||
if(gameclient.snap.gameobj && gameclient.snap.gameobj->gametype == GAMETYPE_CTF)
|
||||
if(gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_FLAGS)
|
||||
{
|
||||
if(killmsgs[r].mode_special&1)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ void KILLMESSAGES::on_render()
|
|||
|
||||
if(killmsgs[r].victim != killmsgs[r].killer)
|
||||
{
|
||||
if(gameclient.snap.gameobj && gameclient.snap.gameobj->gametype == GAMETYPE_CTF)
|
||||
if(gameclient.snap.gameobj && gameclient.snap.gameobj->flags&GAMEFLAG_FLAGS)
|
||||
{
|
||||
if(killmsgs[r].mode_special&2)
|
||||
{
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
#include <string.h> // strcmp, strlen, strncpy
|
||||
#include <stdlib.h> // atoi
|
||||
|
||||
extern "C" {
|
||||
#include <engine/e_client_interface.h>
|
||||
#include <engine/e_config.h>
|
||||
#include <engine/client/ec_font.h>
|
||||
}
|
||||
#include <engine/e_client_interface.h>
|
||||
|
||||
#include <game/generated/g_protocol.hpp>
|
||||
#include <game/generated/gc_data.hpp>
|
||||
|
|
|
@ -14,30 +14,15 @@
|
|||
|
||||
GAMECONTROLLER::GAMECONTROLLER()
|
||||
{
|
||||
// select gametype
|
||||
if(strcmp(config.sv_gametype, "ctf") == 0)
|
||||
{
|
||||
gametype = GAMETYPE_CTF;
|
||||
dbg_msg("game", "-- Capture The Flag --");
|
||||
}
|
||||
else if(strcmp(config.sv_gametype, "tdm") == 0)
|
||||
{
|
||||
gametype = GAMETYPE_TDM;
|
||||
dbg_msg("game", "-- Team Death Match --");
|
||||
}
|
||||
else
|
||||
{
|
||||
gametype = GAMETYPE_DM;
|
||||
dbg_msg("game", "-- Death Match --");
|
||||
}
|
||||
|
||||
gametype = config.sv_gametype;
|
||||
|
||||
//
|
||||
do_warmup(config.sv_warmup);
|
||||
game_over_tick = -1;
|
||||
sudden_death = 0;
|
||||
round_start_tick = server_tick();
|
||||
round_count = 0;
|
||||
is_teamplay = false;
|
||||
game_flags = 0;
|
||||
teamscore[0] = 0;
|
||||
teamscore[1] = 0;
|
||||
|
||||
|
@ -87,7 +72,7 @@ bool GAMECONTROLLER::can_spawn(PLAYER *player, vec2 *out_pos)
|
|||
{
|
||||
SPAWNEVAL eval;
|
||||
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
{
|
||||
eval.friendly_team = player->team;
|
||||
|
||||
|
@ -175,7 +160,7 @@ void GAMECONTROLLER::resetgame()
|
|||
|
||||
const char *GAMECONTROLLER::get_team_name(int team)
|
||||
{
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
{
|
||||
if(team == 0)
|
||||
return "red team";
|
||||
|
@ -276,7 +261,7 @@ void GAMECONTROLLER::post_reset()
|
|||
void GAMECONTROLLER::on_player_info_change(class PLAYER *p)
|
||||
{
|
||||
const int team_colors[2] = {65387, 10223467};
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
{
|
||||
if(p->team >= 0 || p->team <= 1)
|
||||
{
|
||||
|
@ -297,7 +282,7 @@ int GAMECONTROLLER::on_character_death(class CHARACTER *victim, class PLAYER *ki
|
|||
victim->player->score--; // suicide
|
||||
else
|
||||
{
|
||||
if(is_teamplay && victim->team == killer->team)
|
||||
if(is_teamplay() && victim->team == killer->team)
|
||||
killer->score--; // teamkill
|
||||
else
|
||||
killer->score++; // normal kill
|
||||
|
@ -327,7 +312,7 @@ bool GAMECONTROLLER::is_friendly_fire(int cid1, int cid2)
|
|||
if(cid1 == cid2)
|
||||
return false;
|
||||
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
{
|
||||
if(game.players[cid1].team == game.players[cid2].team)
|
||||
return true;
|
||||
|
@ -364,7 +349,7 @@ void GAMECONTROLLER::tick()
|
|||
|
||||
if(config.sv_scorelimit)
|
||||
{
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
{
|
||||
prog = max(prog, (teamscore[0]*100)/config.sv_scorelimit);
|
||||
prog = max(prog, (teamscore[1]*100)/config.sv_scorelimit);
|
||||
|
@ -385,6 +370,12 @@ void GAMECONTROLLER::tick()
|
|||
server_setbrowseinfo(gametype, prog);
|
||||
}
|
||||
|
||||
|
||||
bool GAMECONTROLLER::is_teamplay() const
|
||||
{
|
||||
return game_flags&GAMEFLAG_TEAMS;
|
||||
}
|
||||
|
||||
void GAMECONTROLLER::snap(int snapping_client)
|
||||
{
|
||||
NETOBJ_GAME *gameobj = (NETOBJ_GAME *)snap_new_item(NETOBJTYPE_GAME, 0, sizeof(NETOBJ_GAME));
|
||||
|
@ -395,7 +386,7 @@ void GAMECONTROLLER::snap(int snapping_client)
|
|||
gameobj->score_limit = config.sv_scorelimit;
|
||||
gameobj->time_limit = config.sv_timelimit;
|
||||
gameobj->round_start_tick = round_start_tick;
|
||||
gameobj->gametype = gametype;
|
||||
gameobj->flags = game_flags;
|
||||
|
||||
gameobj->warmup = warmup;
|
||||
|
||||
|
@ -416,7 +407,7 @@ int GAMECONTROLLER::get_auto_team(int notthisid)
|
|||
}
|
||||
|
||||
int team = 0;
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
team = numplayers[0] > numplayers[1] ? 1 : 0;
|
||||
|
||||
if(can_join_team(team, notthisid))
|
||||
|
@ -493,7 +484,7 @@ int GAMECONTROLLER::clampteam(int team)
|
|||
{
|
||||
if(team < 0) // spectator
|
||||
return -1;
|
||||
if(is_teamplay)
|
||||
if(is_teamplay())
|
||||
return team&1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ protected:
|
|||
void cyclemap();
|
||||
void resetgame();
|
||||
|
||||
const char *gametype;
|
||||
|
||||
int round_start_tick;
|
||||
int game_over_tick;
|
||||
int sudden_death;
|
||||
|
@ -44,10 +46,11 @@ protected:
|
|||
int warmup;
|
||||
int round_count;
|
||||
|
||||
int game_flags;
|
||||
|
||||
|
||||
public:
|
||||
int gametype;
|
||||
bool is_teamplay;
|
||||
bool is_teamplay() const;
|
||||
|
||||
GAMECONTROLLER();
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ GAMECONTROLLER_CTF::GAMECONTROLLER_CTF()
|
|||
{
|
||||
flags[0] = 0;
|
||||
flags[1] = 0;
|
||||
is_teamplay = true;
|
||||
game_flags = GAMEFLAG_TEAMS|GAMEFLAG_FLAGS;
|
||||
}
|
||||
|
||||
bool GAMECONTROLLER_CTF::on_entity(int index, vec2 pos)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
GAMECONTROLLER_TDM::GAMECONTROLLER_TDM()
|
||||
{
|
||||
is_teamplay = true;
|
||||
game_flags = GAMEFLAG_TEAMS;
|
||||
}
|
||||
|
||||
int GAMECONTROLLER_TDM::on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon)
|
||||
|
|
|
@ -359,7 +359,7 @@ void mods_init()
|
|||
{
|
||||
mods_connected(MAX_CLIENTS-i-1);
|
||||
mods_client_enter(MAX_CLIENTS-i-1);
|
||||
if(game.controller->is_teamplay)
|
||||
if(game.controller->is_teamplay())
|
||||
game.players[MAX_CLIENTS-i-1].team = i&1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue