Пример #1
0
void NetSv_SendGameState(int flags, int to)
{
    if(!IS_NETWORK_SERVER) return;

    de::String const gameId = COMMON_GAMESESSION->gameId();

    // Print a short message that describes the game state.
    LOG_NET_NOTE("Sending game setup: %s %s %s")
            << gameId
            << gameMapUri.resolved()
            << gameConfigString;

    // Send an update to all the players in the game.
    for(int i = 0; i < MAXPLAYERS; ++i)
    {
        if(!players[i].plr->inGame) continue;
        if((unsigned)to != DDSP_ALL_PLAYERS && to != i) continue;

        Writer *writer = D_NetWrite();
        Writer_WriteByte(writer, flags);

        // Game identity key.
        Writer_WriteByte(writer, gameId.length());
        Writer_Write(writer, gameId.toLatin1().constData(), gameId.length());

        // The current map.
        Uri_Write(reinterpret_cast<Uri *>(&gameMapUri), writer);

        // The current episode number.
        Writer_WriteByte(writer, ::gameEpisode);

        // Old map number. Presently unused.
        Writer_WriteByte(writer, 0);

        Writer_WriteByte(writer, (COMMON_GAMESESSION->rules().deathmatch & 0x3)
            | (!COMMON_GAMESESSION->rules().noMonsters? 0x4 : 0)
#if !__JHEXEN__
            | (COMMON_GAMESESSION->rules().respawnMonsters? 0x8 : 0)
#else
            | 0
#endif
            | (cfg.jumpEnabled? 0x10 : 0));

        // Note that SM_NOTHINGS will result in a value of '7'.
        Writer_WriteByte(writer, COMMON_GAMESESSION->rules().skill & 0x7);
        Writer_WriteFloat(writer, (float)P_GetGravity());

        if(flags & GSF_CAMERA_INIT)
        {
            mobj_t *mo = players[i].plr->mo;
            Writer_WriteFloat(writer, mo->origin[VX]);
            Writer_WriteFloat(writer, mo->origin[VY]);
            Writer_WriteFloat(writer, mo->origin[VZ]);
            Writer_WriteUInt32(writer, mo->angle);
        }

        // Send the packet.
        Net_SendPacket(i, GPT_GAME_STATE, Writer_Data(writer), Writer_Size(writer));
    }
}
Пример #2
0
void WI_DrawPatch(patchid_t patchId, de::String const &replacement, de::Vector2i const &origin,
    int alignFlags, int patchFlags, short textFlags)
{
    if(!replacement.isEmpty())
    {
        // Use the replacement string.
        Point2Raw const originAsPoint2Raw(origin.x, origin.y);
        FR_DrawText3(replacement.toUtf8().constData(), &originAsPoint2Raw, alignFlags, textFlags);
        return;
    }
    // Use the original patch.
    GL_DrawPatch(patchId, origin, alignFlags, patchFlags);
}
Пример #3
0
static void NetSv_CycleToMapNum(de::Uri const &mapUri)
{
    de::String const warpCommand = de::String("warp ") + mapUri.compose(de::Uri::DecodePath);
    DD_Execute(false, warpCommand.toUtf8().constData());

    // In a couple of seconds, send everyone the rules of this map.
    for(int i = 0; i < MAXPLAYERS; ++i)
    {
        cycleRulesCounter[i] = 3 * TICSPERSEC;
    }

    cycleMode    = CYCLE_IDLE;
    cycleCounter = 0;
}
Пример #4
0
de::String Hu_ChoosePatchReplacement(patchreplacemode_t mode, patchid_t patchId, de::String const &text)
{
    if(mode != PRM_NONE)
    {
        // We might be able to replace the patch with a string replacement.
        if(patchId != 0)
        {
            patchinfo_t info;
            R_GetPatchInfo(patchId, &info);
            if(!info.flags.isCustom)
            {
                if(text.isEmpty())
                {
                    // Look for a user replacement.
                    return de::String(Hu_FindPatchReplacementString(patchId, PRF_NO_PWAD));
                }

                return text;
            }
        }
        else
        {
            return text;
        }
    }

    return ""; // No replacement available/wanted.
}
Пример #5
0
static void readUri(Uri* uri, Reader* reader, de::String defaultScheme = "")
{
    Uri_Clear(uri);

    ddstring_t scheme;
    Str_InitStd(&scheme);
    Str_Read(&scheme, reader);

    ddstring_t path;
    Str_InitStd(&path);
    Str_Read(&path, reader);

    if(Str_IsEmpty(&scheme) && !defaultScheme.isEmpty())
    {
        Str_Set(&scheme, defaultScheme.toUtf8().constData());
    }

    Uri_SetScheme(uri, Str_Text(&scheme));
    Uri_SetPath  (uri, Str_Text(&path  ));
}
Пример #6
0
void Hu_DrawMapTitle(float alpha, dd_bool mapIdInsteadOfAuthor)
{
    de::Uri const mapUri    = COMMON_GAMESESSION->mapUri();
    de::String const title  = G_MapTitle(mapUri);
    de::String const author = G_MapAuthor(mapUri, CPP_BOOL(cfg.common.hideIWADAuthor));

    float y = 0;

    DGL_Enable(DGL_TEXTURE_2D);
    DGL_Color4f(1, 1, 1, alpha);

    FR_SetFont(FID(GF_FONTB));
    FR_LoadDefaultAttrib();
    FR_SetColorAndAlpha(defFontRGB[0], defFontRGB[1], defFontRGB[2], alpha);

#if __JDOOM__ || __JDOOM64__
    patchid_t patchId = 0;
    de::Uri const titleImage = G_MapTitleImage(mapUri);
    if(!titleImage.isEmpty())
    {
        if(!titleImage.scheme().compareWithoutCase("Patches"))
        {
            patchId = R_DeclarePatch(titleImage.path().toUtf8().constData());
        }
    }
    WI_DrawPatch(patchId, Hu_ChoosePatchReplacement(PRM_ALLOW_TEXT, patchId, title),
                 de::Vector2i(), ALIGN_TOP, 0, DTF_ONLY_SHADOW);

    // Following line of text placed according to patch height.
    y += Hu_MapTitleFirstLineHeight();

#elif __JHERETIC__ || __JHEXEN__
    if(!title.isEmpty())
    {
        FR_DrawTextXY3(title.toUtf8().constData(), 0, 0, ALIGN_TOP, DTF_ONLY_SHADOW);
        y += 20;
    }
#endif

    if(mapIdInsteadOfAuthor)
    {
        FR_SetFont(FID(GF_FONTA));
#if defined(__JHERETIC__) || defined(__JHEXEN__)
        FR_SetColorAndAlpha(.85f, .85f, .85f, alpha);
#else
        FR_SetColorAndAlpha(.6f, .6f, .6f, alpha);
#endif
        FR_DrawTextXY3(mapUri.path().toUtf8().constData(), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW);
    }
    else if(!author.isEmpty())
    {
        FR_SetFont(FID(GF_FONTA));
        FR_SetColorAndAlpha(.5f, .5f, .5f, alpha);
        FR_DrawTextXY3(author.toUtf8().constData(), 0, y, ALIGN_TOP, DTF_ONLY_SHADOW);
    }

    DGL_Disable(DGL_TEXTURE_2D);
}
Пример #7
0
DE_BEGIN

bool PictureData::loadFromFile(const DE::String &fullPath)
{
    QImage image(fullPath.c_nstr());
    if(image.isNull()){
        return false;
    }
    setWidth(image.width());
    setHeight(image.height());
    IOData* imgData = new IOData();
    imgData->initWithSize(getWidth() * getHeight() * 4);
    QImage imagegl = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied);
    memcpy(imgData->getBuffer(),imagegl.bits(),imgData->getSize());
    setData(imgData);
    return true;
}
Пример #8
0
dd_bool Hu_IsMapTitleAuthorVisible()
{
    de::String const author = G_MapAuthor(COMMON_GAMESESSION->mapUri(), CPP_BOOL(cfg.common.hideIWADAuthor));
    return !author.isEmpty() && (actualMapTime <= 6 * TICSPERSEC);
}