Skip to content

Commit

Permalink
Merge branch 'master' into newrenderer
Browse files Browse the repository at this point in the history
# Conflicts:
#	source/games/exhumed/src/2d.cpp
  • Loading branch information
coelckers committed Apr 17, 2021
2 parents dc8b72b + 53cd895 commit 82194bb
Show file tree
Hide file tree
Showing 48 changed files with 1,934 additions and 1,513 deletions.
1 change: 1 addition & 0 deletions source/CMakeLists.txt
Expand Up @@ -1034,6 +1034,7 @@ set (PCH_SOURCES
build/src/polymost.cpp

core/movie/playmve.cpp
core/movie/movieplayer.cpp
core/automap.cpp
core/cheats.cpp
core/cheathandler.cpp
Expand Down
1 change: 1 addition & 0 deletions source/build/include/buildtypes.h
Expand Up @@ -188,6 +188,7 @@ enum

// Raze extensions, using the higher bits to avoid conflitcs with the reserved and undocumented bits above.
CSTAT_SPRITE_MDLROTATE = 1u<<16u, // Only for tsprites: rotate if this is a model or voxel.
CSTAT_SPRITE_NOFIND = 1u<<17u, // Invisible to neartag and hitscan

};
enum
Expand Down
4 changes: 4 additions & 0 deletions source/build/src/clip.cpp
Expand Up @@ -1412,6 +1412,10 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
{
auto const spr = (uspriteptr_t)&sprite[z];
uint32_t const cstat = spr->cstat;

if (cstat & CSTAT_SPRITE_NOFIND)
continue;

#ifdef USE_OPENGL
if (!hitallsprites)
#endif
Expand Down
2 changes: 2 additions & 0 deletions source/build/src/engine.cpp
Expand Up @@ -1167,6 +1167,8 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
{
auto const spr = (uspriteptr_t)&sprite[z];

if (spr->cstat & CSTAT_SPRITE_NOFIND)
continue;
if (blacklist_sprite_func && blacklist_sprite_func(z))
continue;

Expand Down
3 changes: 2 additions & 1 deletion source/common/2d/v_2ddrawer.cpp
Expand Up @@ -189,8 +189,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, PushTriangle, Shape2D_PushTriangle)
//
//==========================================================================

int F2DDrawer::AddCommand(const RenderCommand *data)
int F2DDrawer::AddCommand(RenderCommand *data)
{
data->mScreenFade = screenFade;
if (mData.Size() > 0 && data->isCompatible(mData.Last()))
{
// Merge with the last command.
Expand Down
4 changes: 3 additions & 1 deletion source/common/2d/v_2ddrawer.h
Expand Up @@ -118,6 +118,7 @@ class F2DDrawer
ETexMode mDrawMode;
uint8_t mLightLevel;
uint8_t mFlags;
float mScreenFade;

bool useTransform;
DMatrix3x3 transform;
Expand Down Expand Up @@ -149,6 +150,7 @@ class F2DDrawer
mLightLevel == other.mLightLevel &&
mColor1.d == other.mColor1.d &&
useTransform == other.useTransform &&
mScreenFade == other.mScreenFade &&
(
!useTransform ||
(
Expand All @@ -172,7 +174,7 @@ class F2DDrawer
int fullscreenautoaspect = 3;
int cliptop = -1, clipleft = -1, clipwidth = -1, clipheight = -1;

int AddCommand(const RenderCommand *data);
int AddCommand(RenderCommand *data);
void AddIndices(int firstvert, int count, ...);
private:
void AddIndices(int firstvert, TArray<int> &v);
Expand Down
17 changes: 15 additions & 2 deletions source/common/audio/music/music.cpp
Expand Up @@ -110,13 +110,18 @@ void S_SetMusicCallbacks(MusicCallbacks* cb)
//==========================================================================

static std::unique_ptr<SoundStream> musicStream;
static TArray<SoundStream*> customStreams;

SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata)
{
int flags = 0;
if (numchannels < 2) flags |= SoundStream::Mono;
auto stream = GSnd->CreateStream(cb, int(size), flags, samplerate, userdata);
if (stream) stream->Play(true, 1);
if (stream)
{
stream->Play(true, 1);
customStreams.Push(stream);
}
return stream;
}

Expand All @@ -125,11 +130,19 @@ void S_StopCustomStream(SoundStream *stream)
if (stream)
{
stream->Stop();
auto f = customStreams.Find(stream);
if (f < customStreams.Size()) customStreams.Delete(f);
delete stream;
}

}

void S_PauseAllCustomStreams(bool on)
{
for (auto s : customStreams)
{
s->SetPaused(on);
}
}

static TArray<int16_t> convert;
static bool FillStream(SoundStream* stream, void* buff, int len, void* userdata)
Expand Down
1 change: 1 addition & 0 deletions source/common/audio/music/s_music.h
Expand Up @@ -14,6 +14,7 @@ class SoundStream;
typedef bool(*StreamCallback)(SoundStream* stream, void* buff, int len, void* userdata);
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata);
void S_StopCustomStream(SoundStream* stream);
void S_PauseAllCustomStreams(bool on);

struct MusicCallbacks
{
Expand Down
15 changes: 9 additions & 6 deletions source/common/engine/d_event.cpp
Expand Up @@ -76,12 +76,15 @@ void D_ProcessEvents (void)
continue;
if (ev->type == EV_DeviceChange)
UpdateJoystickMenu(I_UpdateDeviceList());
if (gamestate == GS_INTRO)
continue;
if (C_Responder (ev))
continue; // console ate the event
if (M_Responder (ev))
continue; // menu ate the event

if (gamestate != GS_INTRO) // GS_INTRO blocks the UI.
{
if (C_Responder(ev))
continue; // console ate the event
if (M_Responder(ev))
continue; // menu ate the event
}

G_Responder (ev);
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/rendering/hwrenderer/hw_draw2d.cpp
Expand Up @@ -85,7 +85,6 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size());
state.SetVertexBuffer(&vb);
state.EnableFog(false);
state.SetScreenFade(drawer->screenFade);

for(auto &cmd : commands)
{
Expand All @@ -94,6 +93,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
state.SetRenderStyle(cmd.mRenderStyle);
state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed));
state.EnableFog(2); // Special 2D mode 'fog'.
state.SetScreenFade(cmd.mScreenFade);

state.SetTextureMode(cmd.mDrawMode);

Expand Down
12 changes: 12 additions & 0 deletions source/core/cheats.cpp
Expand Up @@ -44,6 +44,7 @@
#include "mmulti.h"
#include "gstrings.h"
#include "gamecontrol.h"
#include "screenjob.h"
#include "mapinfo.h"

CVAR(Bool, sv_cheats, true, CVAR_ARCHIVE|CVAR_SERVERINFO)
Expand Down Expand Up @@ -239,6 +240,17 @@ void changeMap(int player, uint8_t** stream, bool skip)
//
//---------------------------------------------------------------------------

void endScreenJob(int player, uint8_t** stream, bool skip)
{
if (!skip) EndScreenJob();
}

//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------

void ChangeLevel(MapRecord* map, int skill)
{
Net_WriteByte(DEM_CHANGEMAP);
Expand Down
1 change: 1 addition & 0 deletions source/core/cheats.h
Expand Up @@ -8,3 +8,4 @@ EXTERN_CVAR(Bool, sv_cheats)

void genericCheat(int player, uint8_t** stream, bool skip);
void changeMap(int player, uint8_t** stream, bool skip);
void endScreenJob(int player, uint8_t** stream, bool skip);
6 changes: 6 additions & 0 deletions source/core/console/d_event.cpp
Expand Up @@ -43,6 +43,7 @@
#include "gamecontrol.h"
#include "uiinput.h"
#include "automap.h"
#include "screenjob.h"

//==========================================================================
//
Expand All @@ -53,6 +54,11 @@

bool G_Responder (event_t *ev)
{
if (gamestate == GS_INTRO || gamestate == GS_INTERMISSION)
{
return ScreenJobResponder(ev);
}

if (CT_Responder(ev))
return true; // chat ate the event
if (Cheat_Responder(ev))
Expand Down
1 change: 1 addition & 0 deletions source/core/d_net.cpp
Expand Up @@ -1674,6 +1674,7 @@ bool D_CheckNetGame (void)

Net_SetCommandHandler(DEM_GENERICCHEAT, genericCheat);
Net_SetCommandHandler(DEM_CHANGEMAP, changeMap);
Net_SetCommandHandler(DEM_ENDSCREENJOB, endScreenJob);

for (i = 0; i < MAXNETNODES; i++)
{
Expand Down
1 change: 1 addition & 0 deletions source/core/d_protocol.h
Expand Up @@ -89,6 +89,7 @@ enum EDemoCommand
DEM_GENERICCHEAT,
DEM_GIVE,
DEM_CHANGEMAP,
DEM_ENDSCREENJOB,

DEM_MAX
};
Expand Down
30 changes: 6 additions & 24 deletions source/core/gamecontrol.cpp
Expand Up @@ -1008,29 +1008,6 @@ int RunGame()
//
//---------------------------------------------------------------------------


void TickSubsystems()
{
// run these on an independent timer until we got something working for the games.
static const uint64_t tickInterval = 1'000'000'000 / 30;
static uint64_t nexttick = 0;

auto nowtick = I_nsTime();
if (nexttick == 0) nexttick = nowtick;
int cnt = 0;
while (nexttick <= nowtick && cnt < 5)
{
nexttick += tickInterval;
C_Ticker();
M_Ticker();
C_RunDelayedCommands();
cnt++;
}
// If this took too long the engine was most likely suspended so recalibrate the timer.
// Perfect precision is not needed here.
if (cnt == 5) nexttick = nowtick + tickInterval;
}

void updatePauseStatus()
{
// This must go through the network in multiplayer games.
Expand All @@ -1053,7 +1030,10 @@ void updatePauseStatus()
}
}

paused ? S_PauseSound(!pausedWithKey, !paused) : S_ResumeSound(paused);
if (paused)
S_PauseSound(!pausedWithKey, !paused);
else
S_ResumeSound(paused);
}

//==========================================================================
Expand Down Expand Up @@ -1143,6 +1123,7 @@ void S_PauseSound (bool notmusic, bool notsfx)
{
soundEngine->SetPaused(true);
GSnd->SetSfxPaused (true, 0);
S_PauseAllCustomStreams(true);
}
}

Expand All @@ -1161,6 +1142,7 @@ void S_ResumeSound (bool notsfx)
{
soundEngine->SetPaused(false);
GSnd->SetSfxPaused (false, 0);
S_PauseAllCustomStreams(false);
}
}

Expand Down
5 changes: 3 additions & 2 deletions source/core/mainloop.cpp
Expand Up @@ -328,9 +328,10 @@ static void GameTicker()

case GS_MENUSCREEN:
case GS_FULLCONSOLE:
break;
case GS_INTERMISSION:
case GS_INTRO:
// These elements do not tick at game rate.
ScreenJobTick();
break;

}
Expand Down Expand Up @@ -370,7 +371,7 @@ void Display()
case GS_INTRO:
case GS_INTERMISSION:
// screen jobs are not bound by the game ticker so they need to be ticked in the display loop.
RunScreenJobFrame();
ScreenJobDraw();
break;

case GS_LEVEL:
Expand Down

0 comments on commit 82194bb

Please sign in to comment.