Example #1
0
void CZoneInstance::IncreaseZoneCounter(CCharEntity* PChar)
{
	DSP_DEBUG_BREAK_IF(PChar == NULL);
	DSP_DEBUG_BREAK_IF(PChar->loc.zone != NULL);
	DSP_DEBUG_BREAK_IF(PChar->PTreasurePool != NULL);

	//return char to instance (d/c or logout)
	if (!PChar->PInstance)
	{
		for (auto instance : instanceList)
		{
			if (instance->CharRegistered(PChar))
			{
				PChar->PInstance = instance;
			}
		}
		if (PChar->m_GMlevel > 0)
		{
			PChar->PInstance = new CInstance(this, 0);
		}
	}

	if (PChar->PInstance)
	{
		PChar->targid = PChar->PInstance->GetNewTargID();

		if (PChar->targid >= 0x700)
		{
			ShowError(CL_RED"CZone::InsertChar : targid is high (03hX)\n" CL_RESET, PChar->targid);
			return;
		}

		PChar->PInstance->InsertPC(PChar);
		CharZoneIn(PChar);

		if (!PChar->PInstance->CharRegistered(PChar))
		{
			PChar->PInstance->RegisterChar(PChar);
			PChar->loc.p = PChar->PInstance->GetEntryLoc();
			CTaskMgr::getInstance()->AddTask(new CTaskMgr::CTask("afterInstanceRegister", gettick() + 500, PChar, CTaskMgr::TASK_ONCE, luautils::AfterInstanceRegister));
		}
	}
	else
	{
		//instance no longer exists: put them outside (at exit)
		PChar->loc.prevzone = GetID();
		zoneutils::GetZone(luautils::OnInstanceLoadFailed(this))->IncreaseZoneCounter(PChar);
	}
}
Example #2
0
void CZone::IncreaseZoneCounter(CCharEntity* PChar)
{
    DSP_DEBUG_BREAK_IF(PChar == nullptr);
    DSP_DEBUG_BREAK_IF(PChar->loc.zone != nullptr);
    DSP_DEBUG_BREAK_IF(PChar->PTreasurePool != nullptr);

    PChar->targid = m_zoneEntities->GetNewTargID();

    if (PChar->targid >= 0x700)
    {
        ShowError(CL_RED"CZone::InsertChar : targid is high (03hX)\n" CL_RESET, PChar->targid);
        return;
    }

    m_zoneEntities->InsertPC(PChar);

    if (!ZoneTimer && !m_zoneEntities->CharListEmpty())
    {
        createZoneTimer();
    }

    CharZoneIn(PChar);
}
Example #3
0
void CZoneInstance::IncreaseZoneCounter(CCharEntity* PChar)
{
    DSP_DEBUG_BREAK_IF(PChar == nullptr);
    DSP_DEBUG_BREAK_IF(PChar->loc.zone != nullptr);
    DSP_DEBUG_BREAK_IF(PChar->PTreasurePool != nullptr);

    //return char to instance (d/c or logout)
    if (!PChar->PInstance)
    {
        for (auto instance : instanceList)
        {
            if (instance->CharRegistered(PChar))
            {
                PChar->PInstance = instance;
            }
        }
        if (!PChar->PInstance && PChar->m_GMlevel > 0)
        {
            PChar->PInstance = new CInstance(this, 0);
        }
    }

    if (PChar->PInstance)
    {
        PChar->targid = PChar->PInstance->GetNewTargID();

        if (PChar->targid >= 0x700)
        {
            ShowError(CL_RED"CZone::InsertChar : targid is high (03hX)\n" CL_RESET, PChar->targid);
            return;
        }

        PChar->PInstance->InsertPC(PChar);
        luautils::OnInstanceZoneIn(PChar, PChar->PInstance);
        CharZoneIn(PChar);

        /* disabled until invalid packet error can be worked around (not sending all
           level related stuff twice (before and after level sync)
        if (PChar->PInstance->GetLevelCap() > 0)
        {
            PChar->StatusEffectContainer->DelStatusEffectsByFlag(EFFECTFLAG_DISPELABLE | EFFECTFLAG_ON_ZONE);
            PChar->StatusEffectContainer->AddStatusEffect(new CStatusEffect(
                EFFECT_LEVEL_RESTRICTION,
                EFFECT_LEVEL_RESTRICTION,
                PChar->PInstance->GetLevelCap(),
                0, 0)
            );
        }*/

        if (PChar->PInstance->CheckFirstEntry(PChar->id))
        {
            PChar->loc.p = PChar->PInstance->GetEntryLoc();
            CTaskMgr::getInstance()->AddTask(new CTaskMgr::CTask("afterInstanceRegister", server_clock::now() + 500ms, PChar, CTaskMgr::TASK_ONCE, luautils::AfterInstanceRegister));
        }
    }
    else
    {
        //instance no longer exists: put them outside (at exit)
        PChar->loc.prevzone = GetID();

        uint16 zoneid = luautils::OnInstanceLoadFailed(this);

        zoneutils::GetZone(zoneid > MAX_ZONEID ? PChar->loc.prevzone : zoneid)->IncreaseZoneCounter(PChar);
    }
}