Exemple #1
0
bool CSector::MoveCharToSector( CChar * pChar )
{
	ADDTOCALLSTACK("CSector::MoveCharToSector");
	// Move a CChar into this CSector.
	// ASSUME: called from CChar.MoveToChar() assume ACtive char.

	if ( IsCharActiveIn(pChar) )
		return false;	// already here

	// Check my save parity vs. this sector's
	if ( pChar->IsStatFlag( STATF_SaveParity ) != m_fSaveParity )
	{
		if ( g_World.IsSaving())
		{
			if ( m_fSaveParity == g_World.m_fSaveParity )
			{
				// Save out the CChar now. the sector has already been saved.
				if ( pChar->m_pPlayer )
					pChar->r_WriteParity(g_World.m_FilePlayers);
				else
					pChar->r_WriteParity(g_World.m_FileWorld);
			}
			else
			{
				// We need to write out this CSector now. (before adding client)
				r_Write();
			}
		}
	}

	m_Chars_Active.AddCharToSector(pChar);	// remove from previous spot.
	return true;
}
Exemple #2
0
void CSector::CheckSaveParity(CChar* pChar)
{
	ADDTOCALLSTACK("CSector::CheckSaveParity");
	// NOTE:
	// pChar is not yet added to any charlist of this sector
	// ASSUME: called from CSector.MoveCharToSector() or CSector.MoveDisconnectedCharToSector().

	// Check my save parity vs. this sector's and save out if not saved yet
	if ( pChar->IsStatFlag( STATF_SaveParity ) != m_fSaveParity )
	{
		if ( g_World.IsSaving())
		{
			if ( m_fSaveParity == g_World.m_fSaveParity )
			{
				// Save out the CChar now. the sector has already been saved.
				if ( pChar->m_pPlayer )
					pChar->r_WriteParity(g_World.m_FilePlayers);
				else
					pChar->r_WriteParity(g_World.m_FileWorld);
			}
			else
			{
				// We need to write out this CSector now. (before adding client)
				r_Write();
			}
		}
	}
}
Exemple #3
0
bool CSector::MoveCharToSector( CChar * pChar )
{
	ADDTOCALLSTACK("CSector::MoveCharToSector");
	// Move a CChar into this CSector.
    ASSERT(pChar);

	if ( IsCharActiveIn(pChar) )
		return false;	// already here

	// Check my save parity vs. this sector's
	if ( pChar->IsStatFlag( STATF_SAVEPARITY ) != m_fSaveParity )
	{
		if ( g_World.IsSaving())
		{
			if ( m_fSaveParity == g_World.m_fSaveParity )
			{
				// Save out the CChar now. the sector has already been saved.
				if ( pChar->m_pPlayer )
					pChar->r_WriteParity(g_World.m_FilePlayers);
				else
					pChar->r_WriteParity(g_World.m_FileWorld);
			}
			else
			{
				// We need to write out this CSector now. (before adding client)
				r_Write();
			}
		}
	}

    m_Chars_Active.AddCharActive(pChar);	// remove from previous spot.
    if (IsSleeping())
    {
        CClient *pClient = pChar->GetClient();
        if (pClient)    // A client just entered
        {
            GoAwake();    // Awake the sector
        }
        else if (!pChar->IsSleeping())    // An NPC entered, but the sector is sleeping
        {
            pChar->GoSleep(); // then make the NPC sleep too.
        }
    }
    else
    {
        if (pChar->m_pNPC && pChar->IsSleeping())
        {
            pChar->GoAwake();
        }
    }
	
	return true;
}