Merge pull request #7475 from ChillerDragon/pr_gametype_mod

Add sv_gametype and sample mod
This commit is contained in:
heinrich5991 2023-11-19 03:07:24 +00:00 committed by GitHub
commit d4713cbfe2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 1 deletions

View file

@ -2542,6 +2542,8 @@ if(SERVER)
gamecontroller.h
gamemodes/DDRace.cpp
gamemodes/DDRace.h
gamemodes/mod.cpp
gamemodes/mod.h
gameworld.cpp
gameworld.h
player.cpp

View file

@ -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";

View 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();
}

View 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

View file

@ -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")