Merge pull request #8841 from ChillerDragon/pr_unhardcode_07_gameflags

Share gameflags for 0.6/0.7 instead of hardcoding it
This commit is contained in:
Robert Müller 2024-08-31 07:38:22 +00:00 committed by GitHub
commit f0449befa5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 34 additions and 21 deletions

View file

@ -4,6 +4,16 @@
#include "protocolglue.h" #include "protocolglue.h"
int GameFlags_ClampToSix(int Flags)
{
int Six = 0;
if(Flags & GAMEFLAG_TEAMS)
Six |= GAMEFLAG_TEAMS;
if(Flags & GAMEFLAG_FLAGS)
Six |= GAMEFLAG_FLAGS;
return Six;
}
int PlayerFlags_SevenToSix(int Flags) int PlayerFlags_SevenToSix(int Flags)
{ {
int Six = 0; int Six = 0;

View file

@ -1,6 +1,7 @@
#ifndef ENGINE_SHARED_PROTOCOLGLUE_H #ifndef ENGINE_SHARED_PROTOCOLGLUE_H
#define ENGINE_SHARED_PROTOCOLGLUE_H #define ENGINE_SHARED_PROTOCOLGLUE_H
int GameFlags_ClampToSix(int Flags);
int PlayerFlags_SevenToSix(int Flags); int PlayerFlags_SevenToSix(int Flags);
int PlayerFlags_SixToSeven(int Flags); int PlayerFlags_SixToSeven(int Flags);
void PickupType_SevenToSix(int Type7, int &Type6, int &SubType6); void PickupType_SevenToSix(int Type7, int &Type6, int &SubType6);

View file

@ -1483,26 +1483,6 @@ void CGameContext::OnClientEnter(int ClientId)
} }
m_pController->OnPlayerConnect(m_apPlayers[ClientId]); m_pController->OnPlayerConnect(m_apPlayers[ClientId]);
if(Server()->IsSixup(ClientId))
{
{
protocol7::CNetMsg_Sv_GameInfo Msg;
Msg.m_GameFlags = protocol7::GAMEFLAG_RACE;
Msg.m_MatchCurrent = 1;
Msg.m_MatchNum = 0;
Msg.m_ScoreLimit = 0;
Msg.m_TimeLimit = 0;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId);
}
// /team is essential
{
protocol7::CNetMsg_Sv_CommandInfoRemove Msg;
Msg.m_pName = "team";
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId);
}
}
{ {
CNetMsg_Sv_CommandInfoGroupStart Msg; CNetMsg_Sv_CommandInfoGroupStart Msg;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId); Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId);

View file

@ -2,6 +2,7 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/shared/config.h> #include <engine/shared/config.h>
#include <engine/shared/protocolglue.h>
#include <game/generated/protocol.h> #include <game/generated/protocol.h>
#include <game/mapitems.h> #include <game/mapitems.h>
#include <game/server/score.h> #include <game/server/score.h>
@ -397,6 +398,26 @@ void IGameController::OnPlayerConnect(CPlayer *pPlayer)
str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), pPlayer->GetTeam()); str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientId, Server()->ClientName(ClientId), pPlayer->GetTeam());
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
} }
if(Server()->IsSixup(ClientId))
{
{
protocol7::CNetMsg_Sv_GameInfo Msg;
Msg.m_GameFlags = m_GameFlags;
Msg.m_MatchCurrent = 1;
Msg.m_MatchNum = 0;
Msg.m_ScoreLimit = 0;
Msg.m_TimeLimit = 0;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId);
}
// /team is essential
{
protocol7::CNetMsg_Sv_CommandInfoRemove Msg;
Msg.m_pName = "team";
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, ClientId);
}
}
} }
void IGameController::OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) void IGameController::OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason)
@ -553,7 +574,7 @@ void IGameController::Snap(int SnappingClient)
if(!pGameInfoObj) if(!pGameInfoObj)
return; return;
pGameInfoObj->m_GameFlags = m_GameFlags; pGameInfoObj->m_GameFlags = GameFlags_ClampToSix(m_GameFlags);
pGameInfoObj->m_GameStateFlags = 0; pGameInfoObj->m_GameStateFlags = 0;
if(m_GameOverTick != -1) if(m_GameOverTick != -1)
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_GAMEOVER; pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_GAMEOVER;

View file

@ -18,6 +18,7 @@ CGameControllerDDRace::CGameControllerDDRace(class CGameContext *pGameServer) :
IGameController(pGameServer) IGameController(pGameServer)
{ {
m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME; m_pGameType = g_Config.m_SvTestingCommands ? TEST_TYPE_NAME : GAME_TYPE_NAME;
m_GameFlags = protocol7::GAMEFLAG_RACE;
} }
CGameControllerDDRace::~CGameControllerDDRace() = default; CGameControllerDDRace::~CGameControllerDDRace() = default;