Add switch_open to set the initial state of a switch to open

This commit is contained in:
def 2015-07-22 23:31:50 +02:00
parent 6ae503353d
commit a04578b3ba
5 changed files with 23 additions and 1 deletions

View file

@ -167,6 +167,7 @@ void CCollision::Init(class CLayers *pLayers)
for (int i = 0; i < m_NumSwitchers+1; ++i)
{
m_pSwitchers[i].m_Initial = true;
for (int j = 0; j < MAX_CLIENTS; ++j)
{
m_pSwitchers[i].m_Status[j] = true;

View file

@ -120,6 +120,7 @@ private:
struct SSwitchers
{
bool m_Status[MAX_CLIENTS];
bool m_Initial;
int m_EndTick[MAX_CLIENTS];
int m_Type[MAX_CLIENTS];
};

View file

@ -1785,6 +1785,20 @@ void CGameContext::ConTuneSetZoneMsgLeave(IConsole::IResult *pResult, void *pUse
}
}
void CGameContext::ConSwitchOpen(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
int Switch = pResult->GetInteger(0);
if (pSelf->Collision()->m_NumSwitchers > 0 && Switch >= 0 && Switch < pSelf->Collision()->m_NumSwitchers+1)
{
pSelf->Collision()->m_pSwitchers[Switch].m_Initial = false;
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "switch %d opened by default", Switch);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
}
}
void CGameContext::ConPause(IConsole::IResult *pResult, void *pUserData)
{
CGameContext *pSelf = (CGameContext *)pUserData;
@ -2232,6 +2246,7 @@ void CGameContext::OnConsoleInit()
Console()->Register("tune_zone_reset", "?i", CFGFLAG_SERVER, ConTuneResetZone, this, "reset zone tuning in zone x or in all zones");
Console()->Register("tune_zone_enter", "is", CFGFLAG_SERVER, ConTuneSetZoneMsgEnter, this, "which message to display on zone enter; use 0 for normal area");
Console()->Register("tune_zone_leave", "is", CFGFLAG_SERVER, ConTuneSetZoneMsgLeave, this, "which message to display on zone leave; use 0 for normal area");
Console()->Register("switch_open", "i", CFGFLAG_SERVER, ConSwitchOpen, this, "Whether a switch is open by default (otherwise closed)");
Console()->Register("pause_game", "", CFGFLAG_SERVER, ConPause, this, "Pause/unpause game");
Console()->Register("change_map", "?r", CFGFLAG_SERVER|CFGFLAG_STORE, ConChangeMap, this, "Change map");
Console()->Register("random_map", "?i", CFGFLAG_SERVER, ConRandomMap, this, "Random map");
@ -2320,6 +2335,10 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
g_Config.m_SvTeleportHoldHook = 0;
g_Config.m_SvTeam = 1;
g_Config.m_SvShowOthersDefault = 0;
if(Collision()->m_NumSwitchers > 0)
for (int i = 0; i < Collision()->m_NumSwitchers+1; ++i)
Collision()->m_pSwitchers[i].m_Initial = true;
}
Console()->ExecuteFile(g_Config.m_SvResetFile);

View file

@ -69,6 +69,7 @@ class CGameContext : public IGameServer
static void ConTuneResetZone(IConsole::IResult *pResult, void *pUserData);
static void ConTuneSetZoneMsgEnter(IConsole::IResult *pResult, void *pUserData);
static void ConTuneSetZoneMsgLeave(IConsole::IResult *pResult, void *pUserData);
static void ConSwitchOpen(IConsole::IResult *pResult, void *pUserData);
static void ConPause(IConsole::IResult *pResult, void *pUserData);
static void ConChangeMap(IConsole::IResult *pResult, void *pUserData);
static void ConRandomMap(IConsole::IResult *pResult, void *pUserData);

View file

@ -199,7 +199,7 @@ void CGameTeams::SetForceCharacterTeam(int ClientID, int Team)
if (GameServer()->Collision()->m_NumSwitchers > 0) {
for (int i = 0; i < GameServer()->Collision()->m_NumSwitchers+1; ++i)
{
GameServer()->Collision()->m_pSwitchers[i].m_Status[Team] = true;
GameServer()->Collision()->m_pSwitchers[i].m_Status[Team] = GameServer()->Collision()->m_pSwitchers[i].m_Initial;
GameServer()->Collision()->m_pSwitchers[i].m_EndTick[Team] = 0;
GameServer()->Collision()->m_pSwitchers[i].m_Type[Team] = TILE_SWITCHOPEN;
}