Skip to content

Commit

Permalink
Merge branch 'master' into maint-3_2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachael Alexanderson committed Dec 17, 2017
2 parents 8027369 + ceffe1b commit abe262c
Show file tree
Hide file tree
Showing 51 changed files with 299 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ git:
matrix:
include:
- os: osx
osx_image: xcode9.1
osx_image: xcode9.2
env:
- CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7"

Expand Down
8 changes: 4 additions & 4 deletions game-music-emu/gme/Fir_Resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#undef PI
#define PI 3.1415926535897932384626433832795029

#if _MSC_VER >= 1911 && defined _M_X64
#if _MSC_VER >= 1911
#pragma float_control(precise, on, push)
#endif // _MSC_VER >= 1911 && _M_X64
#endif // _MSC_VER >= 1911

static void gen_sinc( double rolloff, int width, double offset, double spacing, double scale,
int count, short* out )
Expand Down Expand Up @@ -56,9 +56,9 @@ static void gen_sinc( double rolloff, int width, double offset, double spacing,
}
}

#if _MSC_VER >= 1911 && defined _M_X64
#if _MSC_VER >= 1911
#pragma float_control(pop)
#endif // _MSC_VER >= 1911 && _M_X64
#endif // _MSC_VER >= 1911

Fir_Resampler_::Fir_Resampler_( int width, sample_t* impulses_ ) :
width_( width ),
Expand Down
19 changes: 17 additions & 2 deletions src/am_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ CVAR (Bool, am_showkeys, true, CVAR_ARCHIVE);
CVAR (Int, am_showtriggerlines, 0, CVAR_ARCHIVE);
CVAR (Int, am_showthingsprites, 0, CVAR_ARCHIVE);

CUSTOM_CVAR (Int, am_emptyspacemargin, 0, CVAR_ARCHIVE)
{
if (self < 0)
{
self = 0;
}
else if (self > 90)
{
self = 90;
}

AM_NewResolution();
}

//=============================================================================
//
// Automap colors
Expand Down Expand Up @@ -1063,8 +1077,9 @@ static void AM_findMinMaxBoundaries ()

static void AM_calcMinMaxMtoF()
{
double a = SCREENWIDTH / max_w;
double b = StatusBar->GetTopOfStatusbar() / max_h;
const double safe_frame = 1.0 - am_emptyspacemargin / 100.0;
double a = safe_frame * (SCREENWIDTH / max_w);
double b = safe_frame * (StatusBar->GetTopOfStatusbar() / max_h);

min_scale_mtof = a < b ? a : b;
max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS);
Expand Down
4 changes: 2 additions & 2 deletions src/b_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ bool FCajunMaster::LoadBots ()
}
if (!sc.OpenFile(tmp))
{
Printf("Unable to open %s. So no bots\n");
Printf("Unable to open %s. So no bots\n", tmp.GetChars());
return false;
}

Expand Down Expand Up @@ -665,4 +665,4 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, RemoveAllBots)
PARAM_BOOL(fromlist);
bglobal.RemoveAllBots(fromlist);
return 0;
}
}
38 changes: 37 additions & 1 deletion src/c_dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ FButtonStatus Button_Mlook, Button_Klook, Button_Use, Button_AltAttack,
Button_AM_PanLeft, Button_AM_PanRight, Button_AM_PanDown, Button_AM_PanUp,
Button_AM_ZoomIn, Button_AM_ZoomOut;

bool ParsingKeyConf;
bool ParsingKeyConf, ParsingMenuDef = false;

// To add new actions, go to the console and type "key <action name>".
// This will give you the key value to use in the first column. Then
Expand Down Expand Up @@ -187,6 +187,21 @@ static const char *KeyConfCommands[] =
"clearplayerclasses"
};

static const char *MenuDefCommands[] =
{
"snd_reset",
"reset2defaults",
"menuconsole",
"clearnodecache",
"am_restorecolors",
"special",
"puke",
"fpuke",
"pukename",
"event",
"netevent"
};

// CODE --------------------------------------------------------------------

IMPLEMENT_CLASS(DWaitingCommand, false, false)
Expand Down Expand Up @@ -584,6 +599,25 @@ void C_DoCommand (const char *cmd, int keynum)
}
}

if (ParsingMenuDef)
{
int i;

for (i = countof(MenuDefCommands)-1; i >= 0; --i)
{
if (strnicmp (beg, MenuDefCommands[i], len) == 0 &&
MenuDefCommands[i][len] == 0)
{
break;
}
}
if (i < 0)
{
Printf ("Invalid command for MENUDEF/ZScript: %s\n", beg);
return;
}
}

// Check if this is an action
if (*beg == '+' || *beg == '-')
{
Expand Down Expand Up @@ -670,7 +704,9 @@ DEFINE_ACTION_FUNCTION(DOptionMenuItemCommand, DoCommand)
if (CurrentMenu == nullptr) return 0;
PARAM_PROLOGUE;
PARAM_STRING(cmd);
ParsingMenuDef = true;
C_DoCommand(cmd);
ParsingMenuDef = false;
return 0;
}

Expand Down
11 changes: 3 additions & 8 deletions src/cmdlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,18 +544,13 @@ void CreatePath(const char *fn)
{
*p = '\0';
}
struct stat info;
if (DirEntryExists(copy))
if (!DirEntryExists(copy) && mkdir(copy, 0755) == -1)
{
if (info.st_mode & S_IFDIR)
goto exists;
}
if (mkdir(copy, 0755) == -1)
{ // failed
// failed
free(copy);
return;
}
exists: if (p != NULL)
if (p != NULL)
{
*p = '/';
}
Expand Down
2 changes: 1 addition & 1 deletion src/d_dehacked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ bool D_LoadDehFile(const char *patchfile)
{
FileReader fr;

if (!fr.Open(patchfile))
if (fr.Open(patchfile))
{
PatchSize = fr.GetLength();

Expand Down
2 changes: 1 addition & 1 deletion src/d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ void D_Display ()


{
screen->FrameTime = I_msTime();
screen->FrameTime = I_msTimeFS();
TexMan.UpdateAnimations(screen->FrameTime);
R_UpdateSky(screen->FrameTime);
switch (gamestate)
Expand Down
2 changes: 1 addition & 1 deletion src/g_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2978,7 +2978,7 @@ bool G_CheckDemoStatus (void)
bool saved = false;
if (fw != nullptr)
{
auto size = long(demo_p - demobuffer);
const size_t size = demo_p - demobuffer;
saved = fw->Write(demobuffer, size) == size;
delete fw;
if (!saved) remove(demoname);
Expand Down
2 changes: 1 addition & 1 deletion src/gl/models/gl_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void FGLModelRenderer::DrawElements(int numIndices, size_t offset)

double FGLModelRenderer::GetTimeFloat()
{
return (float)I_msTime() * (float)TICRATE / 1000.0f;
return (double)I_msTime() * (double)TICRATE / 1000.;
}

//===========================================================================
Expand Down
6 changes: 4 additions & 2 deletions src/gl/renderer/gl_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#include "r_videoscale.h"

EXTERN_CVAR(Int, screenblocks)
EXTERN_CVAR(Int, vid_scalemode)

CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE);

Expand Down Expand Up @@ -312,7 +311,10 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds)
mSceneViewport.height = height;

// Scale viewports to fit letterbox
if ((gl_scale_viewport && !framebuffer->IsFullscreen() && vid_scalemode == 0) || !FGLRenderBuffers::IsEnabled())
bool notScaled = ((mScreenViewport.width == ViewportScaledWidth(mScreenViewport.width, mScreenViewport.height)) &&
(mScreenViewport.width == ViewportScaledHeight(mScreenViewport.width, mScreenViewport.height)) &&
!ViewportIsScaled43());
if ((gl_scale_viewport && !framebuffer->IsFullscreen() && notScaled) || !FGLRenderBuffers::IsEnabled())
{
mScreenViewport.width = mOutputLetterbox.width;
mScreenViewport.height = mOutputLetterbox.height;
Expand Down
2 changes: 1 addition & 1 deletion src/gl/renderer/gl_renderstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool FRenderState::ApplyShader()
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
activeShader->muClipHeight.Set(mClipHeight);
activeShader->muClipHeightDirection.Set(mClipHeightDirection);
activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * mShaderTimer / 1000.f);
activeShader->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
activeShader->muClipSplit.Set(mClipSplit);
Expand Down
6 changes: 3 additions & 3 deletions src/gl/scene/gl_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, f
GLRenderer->mAngles.Roll.Degrees = r_viewpoint.Angles.Roll.Degrees;

// Scroll the sky
GLRenderer->mSky1Pos = (double)fmod(screen->FrameTime * level.skyspeed1, 1024.f) * 90./256.;
GLRenderer->mSky2Pos = (double)fmod(screen->FrameTime * level.skyspeed2, 1024.f) * 90./256.;
GLRenderer->mSky1Pos = (double)fmod((double)screen->FrameTime * (double)level.skyspeed1, 1024.f) * 90./256.;
GLRenderer->mSky2Pos = (double)fmod((double)screen->FrameTime * (double)level.skyspeed2, 1024.f) * 90./256.;



Expand Down Expand Up @@ -969,7 +969,7 @@ void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width,

uint8_t * scr = (uint8_t *)M_Malloc(width * height * 3);
glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr);
M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width*3);
M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width * 3, Gamma);
M_Free(scr);
}

Expand Down
7 changes: 3 additions & 4 deletions src/gl/scene/gl_sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,9 @@ void GLSprite::Draw(int pass)
sector_t *cursec = actor ? actor->Sector : particle ? particle->subsector->sector : nullptr;
if (cursec != nullptr)
{
PalEntry finalcol(ThingColor.a,
ThingColor.r * cursec->SpecialColors[sector_t::sprites].r / 255,
ThingColor.g * cursec->SpecialColors[sector_t::sprites].g / 255,
ThingColor.b * cursec->SpecialColors[sector_t::sprites].b / 255);
const PalEntry finalcol = fullbright
? ThingColor
: ThingColor.Modulate(cursec->SpecialColors[sector_t::sprites]);

gl_RenderState.SetObjectColor(finalcol);
}
Expand Down
12 changes: 6 additions & 6 deletions src/gl/scene/gl_weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,18 +385,18 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
// now draw the different layers of the weapon.
// For stencil render styles brightmaps need to be disabled.
gl_RenderState.EnableBrightmap(!(RenderStyle.Flags & STYLEF_ColorIsFixed));
PalEntry finalcol(ThingColor.a,
ThingColor.r * viewsector->SpecialColors[sector_t::sprites].r / 255,
ThingColor.g * viewsector->SpecialColors[sector_t::sprites].g / 255,
ThingColor.b * viewsector->SpecialColors[sector_t::sprites].b / 255);

const bool bright = isBright(psp);
const PalEntry finalcol = bright
? ThingColor
: ThingColor.Modulate(viewsector->SpecialColors[sector_t::sprites]);
gl_RenderState.SetObjectColor(finalcol);

if (psp->GetState() != nullptr)
{
FColormap cmc = cm;
int ll = lightlevel;
if (isBright(psp))
if (bright)
{
if (fakesec == viewsector || in_area != area_below)
{
Expand Down Expand Up @@ -487,4 +487,4 @@ void GLSceneDrawer::DrawTargeterSprites()
{
if (psp->GetState() != nullptr) DrawPSprite(player, psp, psp->x, psp->y, false, 0, false);
}
}
}
7 changes: 5 additions & 2 deletions src/gl/system/gl_framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
EXTERN_CVAR (Float, vid_brightness)
EXTERN_CVAR (Float, vid_contrast)
EXTERN_CVAR (Bool, vid_vsync)
EXTERN_CVAR(Int, vid_scalemode)

CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE)

Expand Down Expand Up @@ -487,7 +486,7 @@ void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int
//
//===========================================================================

void OpenGLFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type)
void OpenGLFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type, float &gamma)
{
const auto &viewport = GLRenderer->mOutputLetterbox;

Expand Down Expand Up @@ -527,6 +526,10 @@ void OpenGLFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch,
pitch = -w*3;
color_type = SS_RGB;
buffer = ScreenshotBuffer + w * 3 * (h - 1);

// Screenshot should not use gamma correction if it was already applied to rendered image
EXTERN_CVAR(Bool, fullscreen);
gamma = 1 == vid_hwgamma || (2 == vid_hwgamma && !fullscreen) ? 1.0f : Gamma;
}

//===========================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/gl/system/gl_framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class OpenGLFrameBuffer : public SDLGLFB
// Retrieves a buffer containing image data for a screenshot.
// Hint: Pitch can be negative for upside-down images, in which case buffer
// points to the last row in the buffer, which will be the first row output.
virtual void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type);
virtual void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type, float &gamma) override;

// Releases the screenshot buffer.
virtual void ReleaseScreenshotBuffer();
Expand Down
7 changes: 4 additions & 3 deletions src/gl/system/gl_swframebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1671,15 +1671,15 @@ void OpenGLSWFrameBuffer::SetBlendingRect(int x1, int y1, int x2, int y2)
//
//==========================================================================

void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type)
void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type, float &gamma)
{
Super::GetScreenshotBuffer(buffer, pitch, color_type);
Super::GetScreenshotBuffer(buffer, pitch, color_type, gamma);
/*
LockedRect lrect;

if (!Accel2D)
{
Super::GetScreenshotBuffer(buffer, pitch, color_type);
Super::GetScreenshotBuffer(buffer, pitch, color_type, gamma);
return;
}
buffer = nullptr;
Expand All @@ -1702,6 +1702,7 @@ void OpenGLSWFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch
buffer = (const uint8_t *)lrect.pBits;
pitch = lrect.Pitch;
color_type = SS_BGRA;
gamma = Gamma;
}
}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/gl/system/gl_swframebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OpenGLSWFrameBuffer : public SDLGLFB
int GetPageCount() override;
void SetVSync(bool vsync) override;
void NewRefreshRate() override;
void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type) override;
void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type, float &gamma) override;
void ReleaseScreenshotBuffer() override;
void SetBlendingRect(int x1, int y1, int x2, int y2) override;
bool Begin2D(bool copy3d) override;
Expand Down
5 changes: 5 additions & 0 deletions src/i_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ uint64_t I_msTime()
return NSToMS(I_nsTime());
}

uint64_t I_msTimeFS() // from "start"
{
return (FirstFrameStartTime == 0) ? 0 : NSToMS(I_nsTime() - FirstFrameStartTime);
}

int I_GetTime()
{
return NSToTic(CurrentFrameStartTime - FirstFrameStartTime);
Expand Down
3 changes: 3 additions & 0 deletions src/i_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ void I_FreezeTime(bool frozen);
// [RH] Returns millisecond-accurate time
uint64_t I_msTime();

// [SP] Returns millisecond-accurate time from start
uint64_t I_msTimeFS();

// Nanosecond-accurate time
uint64_t I_nsTime();
Loading

0 comments on commit abe262c

Please sign in to comment.