示例#1
0
void DisplayMeter::HandleMinus(uint8 val)
{
	if (val == 0) return;
	if (val > 100) val = 100;

	int newValue = m_nValue - val;
	if (newValue < 0) newValue = 0;
	int newPhase = -1;
	int testPhase = 0;
	//see if we've entered a new phase
	while (testPhase < DM_MAX_NUMBER_OF_PHASES)
	{
		//if our new value is less than the phase, but our old value is greater than it, we're in a new phase
		if ((int)newValue <= m_PhaseData[testPhase].nValue && (int)m_nValue > m_PhaseData[testPhase].nValue)
		{
			//if we find more than one possible phase use the lowest valued one
			if (newPhase < 0 || m_PhaseData[testPhase].nValue < m_PhaseData[newPhase].nValue)
				newPhase = testPhase;

		}
		testPhase++;
	}

	//if we have entered a new phase, see if it has a command
	if (newPhase >= 0)
	{
		if (m_PhaseData[newPhase].hstrCmd)
		{
			char* pCmd = g_pLTServer->GetStringData(m_PhaseData[newPhase].hstrCmd);
			if (pCmd && g_pCmdMgr->IsValidCmd(pCmd))
			{
				g_pCmdMgr->Process(pCmd);
			}
		}
	}


	if (newValue == 0)
	{
		HandleEnd();
		return;
	}

	m_nValue = newValue;

	// Send message to clients telling them about the DisplayMeter...
	UpdateClients();

	// Update the DisplayMeter...
//    g_pLTServer->SetNextUpdate(m_hObject, 0.001f);
}
示例#2
0
void DisplayMeter::TriggerMsg(HOBJECT hSender, const char *szMsg)
{
    ILTCommon* pCommon = g_pLTServer->Common();
	if (!pCommon) return;

	// ConParse does not destroy szMsg, so this is safe
	ConParse parse;
	parse.Init((char*)szMsg);

	while (pCommon->Parse(&parse) == LT_OK)
	{
		if (parse.m_nArgs > 0 && parse.m_Args[0])
		{
			if ((_stricmp(parse.m_Args[0], "show") == 0))
			{
				if (parse.m_nArgs > 1)
				{
                    HandleShow((uint8)atoi(parse.m_Args[1]));
				}
				else
					HandleShow(100);
			}
			else if (_stricmp(parse.m_Args[0], "plus") == 0)
			{
				if (parse.m_nArgs > 1)
				{
                    HandlePlus((uint8)atoi(parse.m_Args[1]));
				}
			}
			else if (_stricmp(parse.m_Args[0], "minus") == 0)
			{
				if (parse.m_nArgs > 1)
				{
                    HandleMinus((uint8)atoi(parse.m_Args[1]));
				}
			}
			else if (_stricmp(parse.m_Args[0], "set") == 0)
			{
				if (parse.m_nArgs > 1)
				{
                    HandleSet((uint8)atoi(parse.m_Args[1]));
				}
			}
			else if (_stricmp(parse.m_Args[0], "hide") == 0)
			{
				HandleEnd();
			}
		}
	}
}
示例#3
0
void DisplayTimer::Update()
{
	// Testing...
    //g_pLTServer->CPrint("Time Left: %.2f", m_Timer.GetCountdownTime());

	if (m_Timer.Stopped())
	{
		HandleEnd();
		return;
	}

	// Don't need updates until we time out.
    SetNextUpdate(m_Timer.GetCountdownTime( ));
}
示例#4
0
void DisplayMeter::HandleSet(uint8 val)
{
	if (val == 0)
	{
		if (m_nValue > 0)
			HandleEnd();
		return;
	}
	if (val > 100) val = 100;

	if (m_nValue == 0)
	{
		HandleShow(val);
		return;
	}

	m_nValue = val;

	// Send message to clients telling them about the DisplayMeter...
	UpdateClients();

	// Update the DisplayMeter...
//    g_pLTServer->SetNextUpdate(m_hObject, 0.001f);
}
示例#5
0
 void BattlePhase::End ()
 {
   HandleEnd ();
 }
示例#6
0
bool DisplayTimer::OnTrigger(HOBJECT hSender, const CParsedMsg &cMsg)
{
	static CParsedMsg::CToken s_cTok_Start("START");
	static CParsedMsg::CToken s_cTok_On("ON");
	static CParsedMsg::CToken s_cTok_Add("ADD");
	static CParsedMsg::CToken s_cTok_End("END");
	static CParsedMsg::CToken s_cTok_Off("OFF");
	static CParsedMsg::CToken s_cTok_Kill("KILL");
	static CParsedMsg::CToken s_cTok_Pause("PAUSE");
	static CParsedMsg::CToken s_cTok_Resume("RESUME");
	static CParsedMsg::CToken s_cTok_Team("TEAM");

	if ((cMsg.GetArg(0) == s_cTok_Start) ||
		(cMsg.GetArg(0) == s_cTok_On))
	{
		if (cMsg.GetArgCount() > 1)
		{
            HandleStart((LTFLOAT)atof(cMsg.GetArg(1)));
		}
	}
	else if (cMsg.GetArg(0) == s_cTok_Add)
	{
		if (cMsg.GetArgCount() > 1)
		{
            HandleAdd((LTFLOAT)atof(cMsg.GetArg(1)));
		}
	}
	else if ((cMsg.GetArg(0) == s_cTok_End) ||
			 (cMsg.GetArg(0) == s_cTok_Off))
	{
		HandleEnd();
	}
	else if (cMsg.GetArg(0) == s_cTok_Kill)
	{
		HandleAbort();
	}
	else if (cMsg.GetArg(0) == s_cTok_Pause)
	{
		HandlePause();
	}
	else if (cMsg.GetArg(0) == s_cTok_Resume)
	{
		HandleResume();
	}
	else if (cMsg.GetArg(0) == s_cTok_Team)
	{
		if( cMsg.GetArgCount( ) > 1 )
		{
			uint32 nTeamId = atoi( cMsg.GetArg( 1 ));
			if( nTeamId < MAX_TEAMS )
			{
				m_nTeamId = nTeamId;
			}
			else
			{
				m_nTeamId = INVALID_TEAM;
			}

			UpdateClients( );
		}
	}
	else
		return GameBase::OnTrigger(hSender, cMsg);

	return true;
}