Beispiel #1
0
void AutoSave_Timer() {

	/* 'fired every minute */
	static int Minutos = 0;
	static int MinutosLatsClean = 0;
	static int MinsPjesSave = 0;
	static int MinsSendMotd = 0;

	static int PrintConsole = 0;

	Minutos = Minutos + 1;
	MinsPjesSave = MinsPjesSave + 1;
	MinsSendMotd = MinsSendMotd + 1;

	double tmpHappyHour;

	/* Imprimir en la consola el numero de users */
	PrintConsole++;
	if (PrintConsole >= IntervaloImprimirEnConsola) {
		std::cerr << vb6::dateToString(vb6::Now()) << " Online: " << NumUsers << std::endl;
		PrintConsole = 0;
	}

	/* ' HappyHour */
	iDay = vb6::Weekday(vb6::Now());
	tmpHappyHour = HappyHourDays[iDay];

	if (tmpHappyHour != HappyHour) {

		if (HappyHourActivated) {
			/* ' Reestablece la exp de los npcs */
			if (HappyHour != 0) {
				UpdateNpcsExp(1 / HappyHour);
			}
		}

		/* ' Desactiva */
		if (tmpHappyHour == 1) {
			SendData(SendTarget_ToAll, 0,
					dakara::protocol::server::BuildConsoleMsg("¡Ha concluido la Happy Hour!", FontTypeNames_FONTTYPE_DIOS));

			HappyHourActivated = false;

			/* ' Activa */
		} else {
			UpdateNpcsExp(tmpHappyHour);

			if (HappyHour != 1) {
				SendData(SendTarget_ToAll, 0,
						dakara::protocol::server::BuildConsoleMsg(
								"Se ha modificado la Happy Hour, a partir de ahora las criaturas aumentan su experiencia en un "
										+ vb6::CStr(vb6::Round((tmpHappyHour - 1) * 100, 2)) + "%",
								FontTypeNames_FONTTYPE_DIOS));
			} else {
				SendData(SendTarget_ToAll, 0,
						dakara::protocol::server::BuildConsoleMsg(
								"¡Ha comenzado la Happy Hour! ¡Las criaturas aumentan su experiencia en un "
										+ vb6::CStr(vb6::Round((tmpHappyHour - 1) * 100, 2)) + "%!",
								FontTypeNames_FONTTYPE_DIOS));
			}

			HappyHourActivated = true;
		}

		HappyHour = tmpHappyHour;
	}

	AreasOptimizacion();

	/* 'Actualizamos el centinela */
	PasarMinutoCentinela();

	if (Minutos == MinutosWs - 1) {
		SendData(SendTarget_ToAll, 0,
				dakara::protocol::server::BuildConsoleMsg("Worldsave en 1 minuto ...", FontTypeNames_FONTTYPE_VENENO));
	}

	if (Minutos >= MinutosWs) {
		DoBackUp();
		aClon->VaciarColeccion();
		Minutos = 0;
	}

	if (MinsPjesSave == MinutosGuardarUsuarios - 1) {
		SendData(SendTarget_ToAll, 0,
				dakara::protocol::server::BuildConsoleMsg("CharSave en 1 minuto ...", FontTypeNames_FONTTYPE_VENENO));
	} else if (MinsPjesSave >= MinutosGuardarUsuarios) {
		ActualizaExperiencias();
		GuardarUsuarios();
		MinsPjesSave = 0;
	}

	if (MinutosLatsClean >= 15) {
		MinutosLatsClean = 0;
		/* 'respawn de los guardias en las pos originales */
		ReSpawnOrigPosNpcs();
		LimpiarMundo();
	} else {
		MinutosLatsClean = MinutosLatsClean + 1;
	}

	if (MinsSendMotd >= MinutosMotd) {
		int i;
		for (i = (1); i <= (LastUser); i++) {
			if (UserList[i].flags.UserLogged) {
				SendMOTD(i);
			}
		}
		MinsSendMotd = 0;
	}

	PurgarPenas();
	CheckIdleUser();

	LogNumUsers();
}
Beispiel #2
0
void WorldSession::FullLogin(Player* plr)
{
    Log.Debug("WorldSession", "Fully loading player %u", plr->GetLowGUID());

    SetPlayer(plr);
    m_MoverWoWGuid.Init(plr->GetGUID());

    MapMgr* mgr = sInstanceMgr.GetInstance(plr);
    if (mgr && mgr->m_battleground)
    {
        // Don't allow player to login into a bg that has ended or is full
        if (mgr->m_battleground->HasEnded() || mgr->m_battleground->HasFreeSlots(plr->GetTeamInitial(), mgr->m_battleground->GetType() == false))
            mgr = NULL;
    }

    // Trying to log to an instance that doesn't exists anymore?
    if (!mgr)
    {
        if (!IS_INSTANCE(plr->m_bgEntryPointMap))
        {
            plr->m_position.x = plr->m_bgEntryPointX;
            plr->m_position.y = plr->m_bgEntryPointY;
            plr->m_position.z = plr->m_bgEntryPointZ;
            plr->m_position.o = plr->m_bgEntryPointO;
            plr->m_mapId = plr->m_bgEntryPointMap;
        }
        else
        {
            plr->m_position.x = plr->GetBindPositionX();
            plr->m_position.y = plr->GetBindPositionY();
            plr->m_position.z = plr->GetBindPositionZ();
            plr->m_position.o = 0;
            plr->m_mapId = plr->GetBindMapId();
        }
    }

    // copy to movement array
    movement_packet[0] = m_MoverWoWGuid.GetNewGuidMask();
    memcpy(&movement_packet[1], m_MoverWoWGuid.GetNewGuid(), m_MoverWoWGuid.GetNewGuidLen());

    // world preload
    uint32 VMapId;
    float VO;
    float VX;
    float VY;
    float VZ;

    // GMs should start on GM Island and be bound there
    if (HasGMPermissions() && plr->m_FirstLogin && sWorld.gamemaster_startonGMIsland)
    {
        VMapId = 1;
        VO = 0;
        VX = 16222.6f;
        VY = 16265.9f;
        VZ = 14.2085f;

        plr->m_position.x = VX;
        plr->m_position.y = VY;
        plr->m_position.z = VZ;
        plr->m_position.o = VO;
        plr->m_mapId = VMapId;

        plr->SetBindPoint(plr->GetPositionX(), plr->GetPositionY(), plr->GetPositionZ(), plr->GetMapId(), plr->GetZoneId());
    }
    else
    {
        VMapId = plr->GetMapId();
        VO = plr->GetOrientation();
        VX = plr->GetPositionX();
        VY = plr->GetPositionY();
        VZ = plr->GetPositionZ();
    }

    plr->SendLoginVerifyWorld(VMapId, VX, VY, VZ, VO);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////
    // send voicechat state - active/inactive
    //
    // {SERVER} Packet: (0x03C7) UNKNOWN PacketSize = 2
    // |------------------------------------------------|----------------|
    // |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF|
    // |------------------------------------------------|----------------|
    // |02 01                                            |..              |
    // -------------------------------------------------------------------
    //
    //
    // Old packetdump is OLD. This is probably from 2.2.0 (that was the patch when it was added to wow)!
    //
    //////////////////////////////////////////////////////////////////////////////////////////////////////

    StackWorldPacket<20> datab(SMSG_FEATURE_SYSTEM_STATUS);

    datab.Initialize(SMSG_FEATURE_SYSTEM_STATUS);

    datab << uint8(2);
    datab << uint8(0);

    SendPacket(&datab);

    WorldPacket dataldm(SMSG_LEARNED_DANCE_MOVES, 4 + 4);

    dataldm << uint32(0);
    dataldm << uint32(0);

    SendPacket(&dataldm);

    plr->UpdateAttackSpeed();

    // Make sure our name exists (for premade system)
    PlayerInfo* info = objmgr.GetPlayerInfo(plr->GetLowGUID());
    if (!info)
    {
        info = new PlayerInfo;
        info->class_ = plr->getClass();
        info->gender = plr->getGender();
        info->guid = plr->GetLowGUID();
        info->name = strdup(plr->GetName());
        info->lastLevel = plr->getLevel();
        info->lastOnline = UNIXTIME;
        info->lastZone = plr->GetZoneId();
        info->race = plr->getRace();
        info->team = plr->GetTeam();
        info->guild = NULL;
        info->guildRank = NULL;
        info->guildMember = NULL;
        info->m_Group = NULL;
        info->subGroup = 0;
        objmgr.AddPlayerInfo(info);
    }
    plr->m_playerInfo = info;
    if (plr->m_playerInfo->guild)
    {
        plr->SetGuildId(plr->m_playerInfo->guild->GetGuildId());
        plr->SetGuildRank(plr->m_playerInfo->guildRank->iId);
    }

    info->m_loggedInPlayer = plr;

    // account data == UI config
    SendAccountDataTimes(PER_CHARACTER_CACHE_MASK);

    // Set TIME OF LOGIN
    CharacterDatabase.Execute("UPDATE characters SET online = 1 WHERE guid = %u", plr->GetLowGUID());

    bool enter_world = true;

    // Find our transporter and add us if we're on one.
    if (plr->transporter_info.guid)
    {
        if (Transporter* pTrans = objmgr.GetTransporter(Arcemu::Util::GUID_LOPART(plr->transporter_info.guid)))
        {
            if (plr->IsDead())
            {
                plr->ResurrectPlayer();
                plr->SetHealth(plr->GetMaxHealth());
                plr->SetPower(POWER_TYPE_MANA, plr->GetMaxPower(POWER_TYPE_MANA));
            }

            float c_tposx = pTrans->GetPositionX() + plr->transporter_info.x;
            float c_tposy = pTrans->GetPositionY() + plr->transporter_info.y;
            float c_tposz = pTrans->GetPositionZ() + plr->transporter_info.z;

            if (plr->GetMapId() != pTrans->GetMapId())       // loaded wrong map
            {
                plr->SetMapId(pTrans->GetMapId());

                StackWorldPacket<20> dataw(SMSG_NEW_WORLD);

                dataw << pTrans->GetMapId();
                dataw << c_tposx;
                dataw << c_tposy;
                dataw << c_tposz;
                dataw << plr->GetOrientation();

                SendPacket(&dataw);

                // shit is sent in worldport ack.
                enter_world = false;
            }

            plr->SetPosition(c_tposx, c_tposy, c_tposz, plr->GetOrientation(), false);
            plr->m_CurrentTransporter = pTrans;
            pTrans->AddPlayer(plr);
        }
    }

    Log.Debug("Login", "Player %s logged in.", plr->GetName());

    sWorld.incrementPlayerCount(plr->GetTeam());

    if (plr->m_FirstLogin)
    {
        if (PlayerCreateInfo* create_info = objmgr.GetPlayerCreateInfo(info->race, info->class_))
        {
            uint32 introid = create_info->introid;
            OutPacket(SMSG_TRIGGER_CINEMATIC, 4, &introid);
        }

        if (sWorld.m_AdditionalFun)    //cebernic: tells people who 's newbie :D
        {
            const int classtext[] = { 0, 5, 6, 8, 9, 11, 0, 4, 3, 7, 0, 10 };
            sWorld.SendLocalizedWorldText(true, "{65}", classtext[(uint32)plr->getClass()], plr->GetName(), (plr->IsTeamHorde() ? "{63}" : "{64}"));
        }
    }

    LOG_DETAIL("WORLD: Created new player for existing players (%s)", plr->GetName());

    // Login time, will be used for played time calc
    plr->m_playedtime[2] = uint32(UNIXTIME);

    //Issue a message telling all guild members that this player has signed on
    if (plr->IsInGuild())
    {
        if (Guild* pGuild = plr->m_playerInfo->guild)
        {
            WorldPacket data(SMSG_GUILD_EVENT, 50);

            data << uint8(GUILD_EVENT_MOTD);
            data << uint8(1);

            if (pGuild->GetMOTD())
                data << pGuild->GetMOTD();
            else
                data << uint8(0);

            SendPacket(&data);

            pGuild->LogGuildEvent(GUILD_EVENT_HASCOMEONLINE, 1, plr->GetName());
        }
    }

    // Send online status to people having this char in friendlist
    _player->Social_TellFriendsOnline();
    // send friend list (for ignores)
    _player->Social_SendFriendList(7);

    plr->SendDungeonDifficulty();
    plr->SendRaidDifficulty();

    plr->SendEquipmentSetList();

#ifndef GM_TICKET_MY_MASTER_COMPATIBLE
    GM_Ticket* ticket = objmgr.GetGMTicketByPlayer(_player->GetGUID());
    if (ticket != NULL)
    {
        //Send status change to gm_sync_channel
        Channel* chn = channelmgr.GetChannel(sWorld.getGmClientChannel().c_str(), _player);
        if (chn)
        {
            std::stringstream ss;
            ss << "GmTicket:" << GM_TICKET_CHAT_OPCODE_ONLINESTATE;
            ss << ":" << ticket->guid;
            ss << ":1";
            chn->Say(_player, ss.str().c_str(), NULL, true);
        }
    }
#endif

    // server Message Of The Day
    SendMOTD();

    //Set current RestState
    if (plr->m_isResting)
        // We are resting at an inn , turn on Zzz
        plr->ApplyPlayerRestState(true);

    //Calculate rest bonus if there is time between lastlogoff and now
    if (plr->m_timeLogoff > 0 && plr->getLevel() < plr->GetMaxLevel())    // if timelogoff = 0 then it's the first login
    {
        uint32 currenttime = uint32(UNIXTIME);
        uint32 timediff = currenttime - plr->m_timeLogoff;

        //Calculate rest bonus
        if (timediff > 0)
            plr->AddCalculatedRestXP(timediff);
    }

    if (info->m_Group)
        info->m_Group->Update();

    if (enter_world && !_player->GetMapMgr())
        plr->AddToWorld();

    sHookInterface.OnFullLogin(_player);

    objmgr.AddPlayer(_player);
}