Beispiel #1
0
void sendEntitiesList(Player *player)
{
    levelLoadMutex.lock(); // Protect player->inGame
    if (player->inGame == 0) // Not yet in game, send player's ponies list (Characters scene)
    {
        levelLoadMutex.unlock();
#if DEBUG_LOG
        win.logMessage("UDP: Sending ponies list");
#endif
        sendPonies(player);
        return;
    }
    else if (player->inGame > 1) // Not supposed to happen, let's do it anyway
    {
        //levelLoadMutex.unlock();
        win.logMessage(QString("UDP: Entities list already sent to ")+QString().setNum(player->pony.netviewId)
                       +", resending anyway");
        //return;
    }
    else // Loading finished, sending entities list
    win.logMessage(QString("UDP: Sending entities list to ")+QString().setNum(player->pony.netviewId));
    Scene* scene = findScene(player->pony.sceneName); // Spawn all the players on the client
    for (int i=0; i<scene->players.size(); i++)
        sendNetviewInstantiate(&scene->players[i]->pony, player);

    // Send npcs
    for (int i=0; i<win.npcs.size(); i++)
        if (win.npcs[i]->sceneName.toLower() == player->pony.sceneName.toLower())
        {
#if DEBUG_LOG
            win.logMessage("UDP: Sending NPC "+win.npcs[i]->name);
#endif
            sendNetviewInstantiate(win.npcs[i], player);
        }

    // Spawn some mobs in Zecoras
    if (scene->name.toLower() == "zecoras")
    {
        sendNetviewInstantiate(player,"mobs/dragon", win.getNewId(), win.getNewNetviewId(), {-33.0408, 0.000425577, 101.766}, {0,-1,0,1});
    }

    player->inGame = 2;
    levelLoadMutex.unlock();

    // Send stats of the client's pony
    sendSetMaxStatRPC(player, 0, 100);
    sendSetStatRPC(player, 0, 100);
    sendSetMaxStatRPC(player, 1, 100);
    sendSetStatRPC(player, 1, 100);
}
void sendEntitiesList(Player *player)
{
    levelLoadMutex.lock(); // Protect player->inGame
    if (player->inGame == 0) // Not yet in game, send player's ponies list (Characters scene)
    {
        levelLoadMutex.unlock();
        sendPonies(player);
        return;
    }
    else if (player->inGame > 1) // Not supposed to happen, let's do it anyway
    {
        //levelLoadMutex.unlock();
        win.logMessage(QString("UDP: Entities list already sent to ")+QString().setNum(player->pony.netviewId)
                       +", resending anyway");
        //return;
    }
    else // Loading finished, sending entities list
    win.logMessage(QString("UDP: Sending entities list to ")+QString().setNum(player->pony.netviewId));
    Scene* scene = findScene(player->pony.sceneName); // Spawn all the players on the client
    for (int i=0; i<scene->players.size(); i++)
        sendNetviewInstantiate(scene->players[i], player);

    /// SEND DONUT STEEL (in front of the mirror)
    if (scene->name == "RaritysBoutique")
    {
        win.logMessage(QString("UDP: Sending Donut Steel to ")+QString().setNum(player->pony.netviewId));
        sendNetviewInstantiate(player,"PlayerBase",0,0,UVector(24.7333,-1.16802,-51.7106), UQuaternion(0,-0.25,0,1));
    }

    player->inGame = 2;
    levelLoadMutex.unlock();

    // Send stats of the client's pony
    sendSetMaxStatRPC(player, 0, 100);
    sendSetStatRPC(player, 0, 100);
    sendSetMaxStatRPC(player, 1, 100);
    sendSetStatRPC(player, 1, 100);
}
void sendPonySave(Player *player, QByteArray msg)
{
    if (player->inGame < 2) // Not supposed to happen, ignoring the request
    {
        win.logMessage("UDP: Savegame requested too soon by "+QString().setNum(player->pony.netviewId));
        return;
    }

    quint16 netviewId = (quint8)msg[6] + ((quint8)msg[7]<<8);
    Player* refresh = Player::findPlayer(win.udpPlayers, netviewId);

    if (netviewId == player->pony.netviewId)
    {
        if (player->inGame == 3) // Hopefully that'll fix people stuck on the default cam without creating clones
        {
            win.logMessage("UDP: Savegame already sent to "+QString().setNum(player->pony.netviewId)
                           +", resending anyway");
        }
        else
            win.logMessage(QString("UDP: Sending pony save for/to ")+QString().setNum(netviewId));

        // Set current/max stats
        sendSetMaxStatRPC(player, 0, 100);
        sendSetStatRPC(player, 0, 100);
        sendSetMaxStatRPC(player, 1, 100);
        sendSetStatRPC(player, 1, 100);

        sendPonyData(player);

        // Set inventory (start with always the same, until we implement it properly)
        InventoryItem raincloudHat;
        raincloudHat.id=73;
        raincloudHat.index=0;
        InventoryItem goggles;
        goggles.id=17;
        goggles.index=1;
        InventoryItem hat;
        hat.id=62;
        hat.index=2;
        InventoryItem bag;
        bag.id=60;
        bag.index=3;
        player->inv.clear();
        player->inv << raincloudHat << goggles << hat << bag;
        player->worn.clear();
        //player->worn << goggles << bag;
        player->nBits = 15;
        sendInventoryRPC(player, player->inv, player->worn, player->nBits);

        // Send skills
        QList<QPair<quint32, quint32> > skills;
        skills << QPair<quint32, quint32>(10, 0); // Ground pound
        if (player->pony.getType() == Pony::EarthPony)
            skills << QPair<quint32, quint32>(5, 0); // Seismic buck
        else if (player->pony.getType() == Pony::Pegasus)
            skills << QPair<quint32, quint32>(11, 0); // Tornado
        else if (player->pony.getType() == Pony::Unicorn)
            skills << QPair<quint32, quint32>(2, 0); // Teleport
        sendSkillsRPC(player, skills);

        // Set current/max stats again (that's what the official server does, not my idea !)
        sendSetMaxStatRPC(player, 0, 100);
        sendSetStatRPC(player, 0, 100);
        sendSetMaxStatRPC(player, 1, 100);
        sendSetStatRPC(player, 1, 100);

        /// SEND DONUT STEEL (he's a moose dark-as-my-soul OC)
        if (player->pony.sceneName == "RaritysBoutique")
        {
            win.logMessage("UDP: Sending pony save for Donut Steel to "+QString().setNum(player->pony.netviewId));
            Player donutSteel;
            donutSteel.pony.id = donutSteel.pony.netviewId = 0;
            donutSteel.pony.ponyData = QByteArray::fromHex("0b446f6e757420537465656c0402b70000000000000000000000ca1a0017ff00032e03ff050072ff000c000b0000000000cdcc8c3fff9f");
            sendPonyData(&donutSteel, player);
        }

        refresh->inGame = 3;
    }
    else if (!refresh->IP.isEmpty())
    {
        win.logMessage(QString("UDP: Sending pony save for ")+QString().setNum(refresh->pony.netviewId)
                       +" to "+QString().setNum(player->pony.netviewId));

        sendWornRPC(refresh, player, refresh->worn);

        sendSetStatRPC(refresh, player, 0, 100);
        sendSetMaxStatRPC(refresh, player, 0, 100);
        sendSetStatRPC(refresh, player, 1, 100);
        sendSetMaxStatRPC(refresh, player, 1, 100);

        sendPonyData(refresh, player);

        if (!refresh->lastValidReceivedAnimation.isEmpty())
            sendMessage(player, MsgUserReliableOrdered12, refresh->lastValidReceivedAnimation);
    }
    else
    {
        win.logMessage("UDP: Error sending pony save : netviewId "+QString().setNum(netviewId)+" not found");
    }
}
Beispiel #4
0
void sendPonySave(Player *player, QByteArray msg)
{
    if (player->inGame < 2) // Not supposed to happen, ignoring the request
    {
        win.logMessage("UDP: Savegame requested too soon by "+QString().setNum(player->pony.netviewId));
        return;
    }

    quint16 netviewId = (quint8)msg[6] + ((quint16)(quint8)msg[7]<<8);
    Player* refresh = Player::findPlayer(win.udpPlayers, netviewId); // Find players

    // Find NPC
    Pony* npc = NULL;
    for (int i=0; i<win.npcs.size(); i++)
        if (win.npcs[i]->netviewId == netviewId)
            npc = win.npcs[i];

    // If we found a matching NPC, send him and exits
    if (npc != NULL)
    {
#if DEBUG_LOG
        win.logMessage("UDP: Sending ponyData and worn items for NPC "+npc->name);
#endif
        sendPonyData(npc, player);

        if (npc->inv.size()) // This NPC has a shop
        {
            sendAddViewAddShop(player, npc);
        }

        return;
    }

    if (netviewId == player->pony.netviewId) // Current player
    {
        if (player->inGame == 3) // Hopefully that'll fix people stuck on the default cam without creating clones
        {
            win.logMessage("UDP: Savegame already sent to "+QString().setNum(player->pony.netviewId)
                           +", resending anyway");
        }
        else
            win.logMessage(QString("UDP: Sending pony save for/to ")+QString().setNum(netviewId));

        // Set current/max stats
        sendSetMaxStatRPC(player, 0, 100);
        sendSetStatRPC(player, 0, 100);
        sendSetMaxStatRPC(player, 1, 100);
        sendSetStatRPC(player, 1, 100);

        sendPonyData(player);

        // Send inventory
        sendInventoryRPC(player, player->pony.inv, player->pony.worn, player->pony.nBits);

        // Send skills
        QList<QPair<quint32, quint32> > skills;
        skills << QPair<quint32, quint32>(10, 0); // Ground pound (all races)
        if (player->pony.getType() == Pony::EarthPony)
        {
            skills << QPair<quint32, quint32>(5, 0); // Seismic buck
            skills << QPair<quint32, quint32>(16, 0); // Rough Terrain
        }
        else if (player->pony.getType() == Pony::Pegasus)
        {
            skills << QPair<quint32, quint32>(11, 0); // Dual Cyclone
            skills << QPair<quint32, quint32>(14, 0); // Gale
        }
        else if (player->pony.getType() == Pony::Unicorn)
        {
            skills << QPair<quint32, quint32>(2, 0); // Teleport
            skills << QPair<quint32, quint32>(9, 0); // Rainbow Fields
            skills << QPair<quint32, quint32>(12, 0); // Heal
            skills << QPair<quint32, quint32>(15, 0); // Magical Arrow
        }
        sendSkillsRPC(player, skills);

        // Set current/max stats again (that's what the official server does, not my idea !)
        sendSetMaxStatRPC(player, 0, 100);
        sendSetStatRPC(player, 0, 100);
        sendSetMaxStatRPC(player, 1, 100);
        sendSetStatRPC(player, 1, 100);

        refresh->inGame = 3;
    }
    else if (!refresh->IP.isEmpty())
    {
        win.logMessage(QString("UDP: Sending pony save for ")+QString().setNum(refresh->pony.netviewId)
                       +" to "+QString().setNum(player->pony.netviewId));

        //sendWornRPC(refresh, player, refresh->worn);

        sendSetStatRPC(refresh, player, 0, 100);
        sendSetMaxStatRPC(refresh, player, 0, 100);
        sendSetStatRPC(refresh, player, 1, 100);
        sendSetMaxStatRPC(refresh, player, 1, 100);

        sendPonyData(&refresh->pony, player);

        if (!refresh->lastValidReceivedAnimation.isEmpty())
            sendMessage(player, MsgUserReliableOrdered12, refresh->lastValidReceivedAnimation);
    }
    else
    {
        win.logMessage("UDP: Error sending pony save : netviewId "+QString().setNum(netviewId)+" not found");
    }
}