Ejemplo n.º 1
0
void Mobj_InflictDamage(mobj_t *mob, mobj_t const *inflictor, int damage)
{
    DENG_ASSERT(mob);

    // Do the damage.
    mob->health -= damage;

    // Notify the engine.
    THINKER_DATA(mob->thinker, MobjThinkerData).damageReceived(damage, inflictor);
}
Ejemplo n.º 2
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;
    }