Ejemplo n.º 1
0
/**
 * The actual script is sent to the clients. @a script can be NULL.
 */
void Sv_Finale(finaleid_t id, int flags, const char* script)
{
    size_t scriptLen = 0;

    if(isClient) return;

    // How much memory do we need?
    if(script)
    {
        flags |= FINF_SCRIPT;
        scriptLen = strlen(script);
    }

    // First the flags.
    Msg_Begin(PSV_FINALE);
    Writer_WriteByte(msgWriter, flags);
    Writer_WriteUInt32(msgWriter, id); // serverside Id

    if(script)
    {
        // Then the script itself.
        Writer_WriteUInt32(msgWriter, scriptLen);
        Writer_Write(msgWriter, script, scriptLen);
    }

    Msg_End();

    Net_SendBuffer(NSP_BROADCAST, 0);
}
Ejemplo n.º 2
0
void Str_Write(const ddstring_t *str, Writer *writer)
{
    size_t len = Str_Length(str);

    DENG_ASSERT(str);

    Writer_WriteUInt32(writer, len);
    Writer_Write(writer, Str_Text(str), len);
}
Ejemplo n.º 3
0
void StringArray_Write(const StringArray *ar, Writer *writer)
{
    assert(ar);
    Writer_WriteUInt32(writer, ar->array.size());
    // Write each of the strings.
    for(StringArray::Strings::const_iterator i = ar->array.begin(); i != ar->array.end(); ++i)
    {
        Str_Write(**i, writer);
    }
}
Ejemplo n.º 4
0
static void NetSv_SendFinaleState(fi_state_t* s)
{
    Writer* writer = D_NetWrite();

    // First the flags.
    Writer_WriteByte(writer, s->mode);

    Writer_WriteUInt32(writer, s->finaleId);

    // Then the conditions.
    Writer_WriteByte(writer, 2); // Number of conditions.
    Writer_WriteByte(writer, s->conditions.secret);
    Writer_WriteByte(writer, s->conditions.leave_hub);

    Net_SendPacket(DDSP_ALL_PLAYERS, GPT_FINALE_STATE, Writer_Data(writer), Writer_Size(writer));
}
Ejemplo n.º 5
0
void Net_SendPing(int player, int count)
{
    client_t           *cl = clients + player;

    // Valid destination?
    if((player == consolePlayer) || (isClient && player))
        return;

    if(count)
    {
        // We can't start a new ping run until the old one is done.
        if(cl->ping.sent)
            return;

        // Start a new ping session.
        if(count > MAX_PINGS)
            count = MAX_PINGS;
        cl->ping.current = 0;
        cl->ping.total = count;
    }
    else
    {
        // Continue or finish the current pinger.
        if(++cl->ping.current >= cl->ping.total)
        {
            // We're done.
            cl->ping.sent = 0;
            // Print a summary (average ping, loss %).
            Net_ShowPingSummary(netBuffer.player);
            return;
        }
    }

    // Send a new ping.
    Msg_Begin(PKT_PING);
    cl->ping.sent = Timer_RealMilliseconds();
    Writer_WriteUInt32(msgWriter, cl->ping.sent);
    Msg_End();

    // Update the length of the message.
    netBuffer.player = player;
    N_SendPacket(10000);
}
Ejemplo n.º 6
0
    /**
     * Serializes the specified thinker and writes it to save state.
     */
    static int writeThinkerWorker(thinker_t *th, void *context)
    {
        writethinkerworker_params_t const &p = *static_cast<writethinkerworker_params_t *>(context);

        // We are only concerned with thinkers we have save info for.
        ThinkerClassInfo *thInfo = SV_ThinkerInfo(*th);
        if (!thInfo) return false;

        // Are we excluding players?
        if (p.excludePlayers)
        {
            if (th->function == P_MobjThinker && ((mobj_t *) th)->player)
            {
                return false;
            }
        }

        // Only the server saves this class of thinker?
        if ((thInfo->flags & TSF_SERVERONLY) && IS_CLIENT)
        {
            return false;
        }

        // Write the header block for this thinker.
        Writer_WriteByte(p.msw->writer(), thInfo->thinkclass); // Thinker type byte.
        Writer_WriteByte(p.msw->writer(), Thinker_InStasis(th)? 1 : 0); // In stasis?

        // Private identifier of the thinker.
        de::Id::Type const privateId = (th->d? THINKER_DATA(*th, ThinkerData).id().asUInt32() : 0);
        Writer_WriteUInt32(p.msw->writer(), privateId);

        // Write the thinker data.
        thInfo->writeFunc(th, p.msw);

        return false;
    }