diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bfabfd29..283d9d28b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 9cc1755af..7515fec28 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -30,6 +30,7 @@ #include "entities/character.h" #include "gamemodes/DDRace.h" +#include "gamemodes/mod.h" #include "player.h" #include "score.h" @@ -3592,7 +3593,10 @@ void CGameContext::OnInit(const void *pPersistentData) } } - m_pController = new CGameControllerDDRace(this); + if(!str_comp(Config()->m_SvGametype, "mod")) + m_pController = new CGameControllerMod(this); + else + m_pController = new CGameControllerDDRace(this); const char *pCensorFilename = "censorlist.txt"; IOHANDLE File = Storage()->OpenFile(pCensorFilename, IOFLAG_READ | IOFLAG_SKIP_BOM, IStorage::TYPE_ALL); diff --git a/src/game/server/gamemodes/mod.cpp b/src/game/server/gamemodes/mod.cpp new file mode 100644 index 000000000..1c6fc97f7 --- /dev/null +++ b/src/game/server/gamemodes/mod.cpp @@ -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(); +} diff --git a/src/game/server/gamemodes/mod.h b/src/game/server/gamemodes/mod.h new file mode 100644 index 000000000..f74d5306a --- /dev/null +++ b/src/game/server/gamemodes/mod.h @@ -0,0 +1,14 @@ +#ifndef GAME_SERVER_GAMEMODES_MOD_H +#define GAME_SERVER_GAMEMODES_MOD_H + +#include + +class CGameControllerMod : public IGameController +{ +public: + CGameControllerMod(class CGameContext *pGameServer); + ~CGameControllerMod(); + + void Tick() override; +}; +#endif // GAME_SERVER_GAMEMODES_MOD_H diff --git a/src/game/variables.h b/src/game/variables.h index df9bf9b83..93320fbad 100644 --- a/src/game/variables.h +++ b/src/game/variables.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")