Пример #1
0
bool DecisionObject::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_Stop("STOP");
	static CParsedMsg::CToken s_cTok_Off("OFF");
	static CParsedMsg::CToken s_cTok_Lock("LOCK");
	static CParsedMsg::CToken s_cTok_Unlock("UNLOCK");

	if ((cMsg.GetArg(0) == s_cTok_Start) ||
		(cMsg.GetArg(0) == s_cTok_On)
		)
	{
		HandleShow();
	}
	else if ((cMsg.GetArg(0) == s_cTok_Stop) ||
		(cMsg.GetArg(0) == s_cTok_Off)
		)
	{
		HandleAbort();
	}
	else if( cMsg.GetArg(0) == s_cTok_Lock )
	{
		m_bLock = true;
	}
	else if( cMsg.GetArg(0) == s_cTok_Unlock )
	{
		m_bLock = false;
	}
	else
		return GameBase::OnTrigger(hSender, cMsg);

	return true;
}
Пример #2
0
void DecisionObject::HandleChoose(uint8 nChoice)
{
	if( m_bLock )
		return;

	//special case of closing a open decision window as another one is being opened
	// in this case do not notify the client
	if (nChoice == -1)
	{
		HandleAbort(false);
		return;
	}

	if (nChoice >= MAX_DECISION_CHOICES)
	{
		HandleAbort();
		return;
	}


	if (m_ChoiceData[nChoice].hstrCmd)
	{
		const char* pCmd = g_pLTServer->GetStringData(m_ChoiceData[nChoice].hstrCmd);
		if (pCmd && g_pCmdMgr->IsValidCmd(pCmd))
		{
			g_pCmdMgr->Process(pCmd, m_hObject, m_hObject);
		}
	}
	else
	{
		HandleAbort();
		return;
	}

	if (m_bRemoveAfterChoice)
		g_pLTServer->RemoveObject(m_hObject);

	// Send message to clients telling them about the DecisionObject...
	Show(false);

}
Пример #3
0
void DecisionObject::HandleChoose(HOBJECT hPlayer, uint8 nChoice)
{
	if( m_bLock )
		return;

	//special case of closing a open decision window as another one is being opened
	// in this case do not notify the client
	if (nChoice == (uint8)-1)
	{
		HandleAbort( hPlayer, false);
		return;
	}

	if (nChoice >= MAX_DECISION_CHOICES)
	{
		HandleAbort( hPlayer );
		return;
	}


	if( !m_ChoiceData[nChoice].sCmd.empty() )
	{
		if( !m_ChoiceData[nChoice].sCmd.empty() )
		{
			g_pCmdMgr->QueueCommand( m_ChoiceData[nChoice].sCmd.c_str(), hPlayer, m_hObject );
		}
	}
	else
	{
		HandleAbort( hPlayer );
		return;
	}

	if (m_bRemoveAfterChoice)
		g_pLTServer->RemoveObject(m_hObject);

	// Send message to clients telling them about the DecisionObject...
	Show(false);

}
Пример #4
0
void DisplayTimer::HandleEnd()
{
	if (m_hstrEndCmd)
	{
        const char* pCmd = g_pLTServer->GetStringData(m_hstrEndCmd);

		if (pCmd && g_pCmdMgr->IsValidCmd(pCmd))
		{
			g_pCmdMgr->Process(pCmd, m_hObject, m_hObject);
		}
	}

	// Tell client to stop the timer...

	HandleAbort();
}
Пример #5
0
void DecisionObject::HandleOffMsg( HOBJECT hSender, const CParsedMsg &crParsedMsg )
{
	HandleAbort( hSender );
}
Пример #6
0
StaticCompressor::StaticCompressor(int compressionLevel,
                                       int compressionThreshold)
{
  buffer_     = NULL;
  bufferSize_ = 0;

  compressionStream_.zalloc = (alloc_func) 0;
  compressionStream_.zfree  = (free_func) 0;
  compressionStream_.opaque = (voidpf) 0;

  decompressionStream_.zalloc = (alloc_func) 0;
  decompressionStream_.zfree  = (free_func) 0;
  decompressionStream_.opaque = (void *) 0;

  decompressionStream_.next_in = (Bytef *) 0;
  decompressionStream_.avail_in = 0;

  #ifdef TEST
  *logofs << "StaticCompressor: Compression level is "
          << compressionLevel << ".\n" << logofs_flush;
  #endif

  int result = deflateInit2(&compressionStream_, compressionLevel, Z_DEFLATED,
                                15, 9, Z_DEFAULT_STRATEGY);

  if (result != Z_OK)
  {
    #ifdef PANIC
    *logofs << "StaticCompressor: PANIC! Cannot initialize the "
            << "compression stream. Error is '" << zError(result)
            << "'.\n" << logofs_flush;
    #endif

    cerr << "Error" << ": Cannot initialize the compression "
         << "stream. Error is '" << zError(result) << "'.\n";

    HandleAbort();
  }

  result = inflateInit2(&decompressionStream_, 15);

  if (result != Z_OK)
  {
    #ifdef PANIC
    *logofs << "StaticCompressor: PANIC! Cannot initialize the "
            << "decompression stream. Error is '" << zError(result)
            << "'.\n" << logofs_flush;
    #endif

    cerr << "Error" << ": Cannot initialize the decompression "
         << "stream. Error is '" << zError(result) << "'.\n";

    HandleAbort();
  }

  #ifdef TEST
  *logofs << "StaticCompressor: Compression threshold is "
          << compressionThreshold << ".\n" << logofs_flush;
  #endif

  threshold_ = compressionThreshold;
}
Пример #7
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;
}