mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Add sv_gametype and sample mod
This commit is contained in:
parent
2dbfc72a4d
commit
becffb9377
|
@ -2540,6 +2540,8 @@ if(SERVER)
|
|||
gamecontroller.h
|
||||
gamemodes/DDRace.cpp
|
||||
gamemodes/DDRace.h
|
||||
gamemodes/mod.cpp
|
||||
gamemodes/mod.h
|
||||
gameworld.cpp
|
||||
gameworld.h
|
||||
player.cpp
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "entities/character.h"
|
||||
#include "gamemodes/DDRace.h"
|
||||
#include "gamemodes/mod.h"
|
||||
#include "player.h"
|
||||
#include "score.h"
|
||||
|
||||
|
@ -3592,6 +3593,9 @@ void CGameContext::OnInit(const void *pPersistentData)
|
|||
}
|
||||
}
|
||||
|
||||
if(!str_comp(Config()->m_SvGametype, "mod"))
|
||||
m_pController = new CGameControllerMod(this);
|
||||
else
|
||||
m_pController = new CGameControllerDDRace(this);
|
||||
|
||||
const char *pCensorFilename = "censorlist.txt";
|
||||
|
|
24
src/game/server/gamemodes/mod.cpp
Normal file
24
src/game/server/gamemodes/mod.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include "mod.h"
|
||||
|
||||
// Exchange this to a string that identifies your game mode.
|
||||
// DM, TDM and CTF are reserved for teeworlds original modes.
|
||||
// DDraceNetwork and TestDDraceNetwork are used by DDNet.
|
||||
#define GAME_TYPE_NAME "Mod"
|
||||
#define TEST_TYPE_NAME "TestMod"
|
||||
|
||||
CGameControllerMod::CGameControllerMod(class CGameContext *pGameServer) :
|
||||
IGameController(pGameServer)
|
||||
{
|
||||
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
|
||||
|
||||
//m_GameFlags = GAMEFLAG_TEAMS; // GAMEFLAG_TEAMS makes it a two-team gamemode
|
||||
}
|
||||
|
||||
CGameControllerMod::~CGameControllerMod() = default;
|
||||
|
||||
void CGameControllerMod::Tick()
|
||||
{
|
||||
// this is the main part of the gamemode, this function is run every tick
|
||||
|
||||
IGameController::Tick();
|
||||
}
|
14
src/game/server/gamemodes/mod.h
Normal file
14
src/game/server/gamemodes/mod.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef GAME_SERVER_GAMEMODES_MOD_H
|
||||
#define GAME_SERVER_GAMEMODES_MOD_H
|
||||
|
||||
#include <game/server/gamecontroller.h>
|
||||
|
||||
class CGameControllerMod : public IGameController
|
||||
{
|
||||
public:
|
||||
CGameControllerMod(class CGameContext *pGameServer);
|
||||
~CGameControllerMod();
|
||||
|
||||
void Tick() override;
|
||||
};
|
||||
#endif // GAME_SERVER_GAMEMODES_MOD_H
|
|
@ -178,6 +178,7 @@ MACRO_CONFIG_INT(ClSkipStartMenu, cl_skip_start_menu, 0, 0, 1, CFGFLAG_CLIENT |
|
|||
// server
|
||||
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, 0, 0, CFGFLAG_SERVER, "Number of seconds to do warmup before round starts")
|
||||
MACRO_CONFIG_STR(SvMotd, sv_motd, 900, "", CFGFLAG_SERVER, "Message of the day to display for the clients")
|
||||
MACRO_CONFIG_STR(SvGametype, sv_gametype, 32, "ddnet", CFGFLAG_SAVE | CFGFLAG_SERVER, "Game type (ddnet, mod)")
|
||||
MACRO_CONFIG_INT(SvTournamentMode, sv_tournament_mode, 0, 0, 1, CFGFLAG_SERVER, "Tournament mode. When enabled, players joins the server as spectator")
|
||||
MACRO_CONFIG_INT(SvSpamprotection, sv_spamprotection, 1, 0, 1, CFGFLAG_SERVER, "Spam protection")
|
||||
|
||||
|
|
Loading…
Reference in a new issue