Skip to content

Commit

Permalink
Make private method internal
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Mar 13, 2019
1 parent 0a72cb1 commit 817e287
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 60 deletions.
2 changes: 2 additions & 0 deletions CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ void CGame::delMapObj()
MapObj = nullptr;
}

namespace {
void WaitForEnter()
{
#ifndef NDEBUG
Expand Down Expand Up @@ -246,6 +247,7 @@ bool checkWriteable(const bfs::path& folder)
bfs::remove(testFileName);
return true;
}
} // namespace

#undef main
int main(int /*argc*/, char* /*argv*/ [])
Expand Down
3 changes: 2 additions & 1 deletion CIO/CFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void CFont::setMouseData(SDL_MouseButtonEvent button)
}
}

namespace {
unsigned getIndexForChar(uint8_t c)
{
// subtract 32 shows that we start by spacebar as 'zero-position'
Expand Down Expand Up @@ -174,7 +175,7 @@ unsigned getIndexForChar(uint8_t c)
else
return 60;
}

} // namespace
bool CFont::writeText()
{
if(string_.empty())
Expand Down
2 changes: 2 additions & 0 deletions CMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ void CMap::setMouseData(const SDL_MouseButtonEvent& button)
}
}

namespace {
SavedVertex saveVertex(Position pt, const bobMAP& map)
{
SavedVertex res;
Expand Down Expand Up @@ -712,6 +713,7 @@ void restoreVertex(const SavedVertex& vertex, bobMAP& map)
}
}
}
} // namespace

void CMap::setKeyboardData(const SDL_KeyboardEvent& key)
{
Expand Down
4 changes: 4 additions & 0 deletions CSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <algorithm>
#include <cassert>

namespace {
SDL_Rect rect2SDL_Rect(const Rect& rect)
{
Point<Sint16> origin(rect.getOrigin());
Expand Down Expand Up @@ -39,6 +40,7 @@ void DrawFadedTexturedTrigon(SDL_Surface* dest, Point16 p1, Point16 p2, Point16
sge_FadedTexturedTrigonColorKeys(dest, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, source, rect.x, rect.y, right, rect.y, middle, bottom, I1,
I2, I2, &source->format->colorkey, 1);
}
} // namespace

bool CSurface::drawTextures = false;
bool CSurface::useOpenGL = false;
Expand Down Expand Up @@ -362,6 +364,7 @@ void CSurface::DrawTriangleField(SDL_Surface* display, const DisplayRectangle& d
}
}

namespace {
enum class BorderPreference
{
None,
Expand Down Expand Up @@ -515,6 +518,7 @@ bool GetAdjustedPoints(const DisplayRectangle& displayRect, const bobMAP& myMap,
p3 -= displayRect.getOrigin();
return true;
}
} // namespace

void CSurface::GetTerrainTextureCoords(MapType mapType, TriangleTerrainType texture, bool isRSU, int texture_move, Point16& upper,
Point16& left, Point16& right, Point16& upper2, Point16& left2, Point16& right2)
Expand Down
46 changes: 19 additions & 27 deletions SGE/sge_blib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "sge_blib.h"
#include "sge_primitives.h"
#include "sge_primitives_int.h"
#include "sge_surface.h"
#include <boost/numeric/conversion/cast.hpp>
#include <SDL.h>
Expand All @@ -38,16 +39,6 @@ extern Uint8 _sge_update;
extern Uint8 _sge_lock;
extern Uint8 _sge_alpha_hack;

/* We need some internal functions */
extern void _Line(SDL_Surface* surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
extern void _LineAlpha(SDL_Surface* Surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 Color, Uint8 alpha);
extern void _HLine(SDL_Surface* Surface, Sint16 x1, Sint16 x2, Sint16 y, Uint32 Color);
extern void _HLineAlpha(SDL_Surface* Surface, Sint16 x1, Sint16 x2, Sint16 y, Uint32 Color, Uint8 alpha);
extern void callback_alpha_hack(SDL_Surface* surf, Sint16 x, Sint16 y, Uint32 color);
extern void _AALineAlpha(SDL_Surface* dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, Uint8 alpha);
extern void _AAmcLineAlpha(SDL_Surface* dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r1, Uint8 g1, Uint8 b1, Uint8 r2, Uint8 g2,
Uint8 b2, Uint8 alpha);

/* Macro to inline RGB mapping */
static constexpr Uint32 MapRGB(const SDL_PixelFormat& format, Uint8 r, Uint8 g, Uint8 b)
{
Expand Down Expand Up @@ -85,7 +76,7 @@ static constexpr Uint32 ScaleRGB(const SDL_PixelFormat& format, Uint32 value, Si
//==================================================================================
// Draws a horisontal line, fading the colors
//==================================================================================
void _FadedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r1, Uint8 g1, Uint8 b1, Uint8 r2, Uint8 g2, Uint8 b2)
static void _FadedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r1, Uint8 g1, Uint8 b1, Uint8 r2, Uint8 g2, Uint8 b2)
{
Sint16 x;
Uint8 t;
Expand Down Expand Up @@ -227,7 +218,8 @@ void sge_FadedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r1,
//==================================================================================
// Draws a horisontal, textured line
//==================================================================================
void _TexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2, Sint16 sy2)
static void _TexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2,
Sint16 sy2)
{
Sint16 x;

Expand Down Expand Up @@ -446,8 +438,8 @@ void _TexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surfac
//==================================================================================
// Draws a horisontal, gouraud shaded and textured line
//==================================================================================
void _FadedTexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2,
Sint16 sy2, Sint32 i1, Sint32 i2)
static void _FadedTexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2,
Sint16 sy2, Sint32 i1, Sint32 i2)
{
Sint16 x;
Sint32 i;
Expand Down Expand Up @@ -694,8 +686,8 @@ void _FadedTexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_S
//==================================================================================
// Draws a horisontal, gouraud shaded and textured line respecting the color key
//==================================================================================
void _FadedTexturedLineColorKey(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2,
Sint16 sy2, Sint32 i1, Sint32 i2)
static void _FadedTexturedLineColorKey(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1,
Sint16 sx2, Sint16 sy2, Sint32 i1, Sint32 i2)
{
Sint16 x;
Sint32 i;
Expand Down Expand Up @@ -929,8 +921,8 @@ void _FadedTexturedLineColorKey(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16
//==================================================================================
// Draws a horisontal, textured line with precalculated gouraud shading
//==================================================================================
void _PreCalcFadedTexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2,
Sint16 sy2, Uint16 i1, Uint16 i2, Uint8 PreCalcPalettes[][256])
static void _PreCalcFadedTexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1,
Sint16 sx2, Sint16 sy2, Uint16 i1, Uint16 i2, Uint8 PreCalcPalettes[][256])
{
Sint16 x;
Uint16 i;
Expand Down Expand Up @@ -1166,8 +1158,8 @@ void _PreCalcFadedTexturedLine(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y
//==================================================================================
// Draws a horisontal, textured line with precalculated gouraud shading (and respecting the colorkey)
//==================================================================================
void _PreCalcFadedTexturedLineColorKey(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1,
Sint16 sx2, Sint16 sy2, Uint16 i1, Uint16 i2, Uint8 PreCalcPalettes[][256])
static void _PreCalcFadedTexturedLineColorKey(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1,
Sint16 sy1, Sint16 sx2, Sint16 sy2, Uint16 i1, Uint16 i2, Uint8 PreCalcPalettes[][256])
{
Sint16 x;
Uint16 i;
Expand Down Expand Up @@ -1407,9 +1399,9 @@ void _PreCalcFadedTexturedLineColorKey(SDL_Surface* dest, Sint16 x1, Sint16 x2,
//==================================================================================
// Draws a horisontal, textured line with precalculated gouraud shading (respecting colorkeys)
//==================================================================================
void _PreCalcFadedTexturedLineColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1,
Sint16 sx2, Sint16 sy2, Uint16 i1, Uint16 i2, Uint8 PreCalcPalettes[][256], Uint32 keys[],
int keycount)
static void _PreCalcFadedTexturedLineColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1,
Sint16 sy1, Sint16 sx2, Sint16 sy2, Uint16 i1, Uint16 i2, Uint8 PreCalcPalettes[][256],
Uint32 keys[], int keycount)
{
Sint16 x;
Uint16 i;
Expand Down Expand Up @@ -1654,8 +1646,8 @@ void _PreCalcFadedTexturedLineColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 x2,
//==================================================================================
// Draws a horisontal, gouraud shaded and textured line (respecting colorkeys)
//==================================================================================
void _FadedTexturedLineColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1, Sint16 sx2,
Sint16 sy2, Sint32 i1, Sint32 i2, Uint32 keys[], int keycount)
static void _FadedTexturedLineColorKeys(SDL_Surface* dest, Sint16 x1, Sint16 x2, Sint16 y, SDL_Surface* source, Sint16 sx1, Sint16 sy1,
Sint16 sx2, Sint16 sy2, Sint32 i1, Sint32 i2, Uint32 keys[], int keycount)
{
Sint16 x;
Sint32 i;
Expand Down Expand Up @@ -3913,7 +3905,7 @@ struct pline_p
};

/* Radix sort */
pline* rsort(pline* inlist)
static pline* rsort(pline* inlist)
{
if(!inlist)
return nullptr;
Expand Down Expand Up @@ -3966,7 +3958,7 @@ pline* rsort(pline* inlist)
}

/* Calculate the scanline for y */
pline* get_scanline(pline_p* plist, Uint16 n, Sint32 y)
static pline* get_scanline(pline_p* plist, Uint16 n, Sint32 y)
{
pline* p = nullptr;
pline* list = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion SGE/sge_bm_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ sge_bmpFont* sge_BF_CreateFont(SDL_Surface* surface, Uint8 flags)
//==================================================================================
// Loads the font into a new struct
//==================================================================================
sge_bmpFont* sge_BF_OpenFont(char* file, Uint8 flags)
sge_bmpFont* sge_BF_OpenFont(const char* file, Uint8 flags)
{
sge_bmpFont* font;
SDL_Surface* Temp;
Expand Down
2 changes: 1 addition & 1 deletion SGE/sge_collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int sge_bbcheck(sge_cdata* cd1, Sint16 x1, Sint16 y1, sge_cdata* cd2, Sint16 x2,
//==================================================================================
// Checks bounding boxes for collision: 0-no collision 1-collision
//==================================================================================
int _sge_bbcheck(Sint16 x1, Sint16 y1, Uint16 w1, Uint16 h1, Sint16 x2, Sint16 y2, Uint16 w2, Uint16 h2)
static int _sge_bbcheck(Sint16 x1, Sint16 y1, Uint16 w1, Uint16 h1, Sint16 x2, Sint16 y2, Uint16 w2, Uint16 h2)
{
if(x1 < x2)
{
Expand Down
9 changes: 5 additions & 4 deletions SGE/sge_primitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "sge_primitives.h"
#include "sge_primitives_int.h"
#include "sge_surface.h"
#include <SDL.h>
#include <math.h>
Expand Down Expand Up @@ -146,7 +147,7 @@ void sge_HLineAlpha(SDL_Surface* Surface, Sint16 x1, Sint16 x2, Sint16 y, Uint8
//==================================================================================
// Internal draw vertical line
//==================================================================================
void _VLine(SDL_Surface* Surface, Sint16 x, Sint16 y1, Sint16 y2, Uint32 Color)
static void _VLine(SDL_Surface* Surface, Sint16 x, Sint16 y1, Sint16 y2, Uint32 Color)
{
if(y1 > y2)
{
Expand Down Expand Up @@ -218,7 +219,7 @@ void sge_VLine(SDL_Surface* Surface, Sint16 x, Sint16 y1, Sint16 y2, Uint8 R, Ui
//==================================================================================
// Internal draw vertical line (alpha - no update)
//==================================================================================
void _VLineAlpha(SDL_Surface* Surface, Sint16 x, Sint16 y1, Sint16 y2, Uint32 Color, Uint8 alpha)
static void _VLineAlpha(SDL_Surface* Surface, Sint16 x, Sint16 y1, Sint16 y2, Uint32 Color, Uint8 alpha)
{
Uint8 update = _sge_update;
Uint8 lock = _sge_lock;
Expand Down Expand Up @@ -319,7 +320,7 @@ void sge_DoLine(SDL_Surface* Surface, Sint16 X1, Sint16 Y1, Sint16 X2, Sint16 Y2
#define CLIP_REJECT(a, b) ((a) & (b))
#define CLIP_ACCEPT(a, b) (!((a) | (b)))

int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom)
static int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom)
{
int code = 0;

Expand All @@ -336,7 +337,7 @@ int clipEncode(Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16
return code;
}

int clipLine(SDL_Surface* dst, Sint16* x1, Sint16* y1, Sint16* x2, Sint16* y2)
static int clipLine(SDL_Surface* dst, Sint16* x1, Sint16* y1, Sint16* x2, Sint16* y2)
{
int code1, code2;
bool draw = false;
Expand Down
32 changes: 32 additions & 0 deletions SGE/sge_primitives_int.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* SDL Graphics Extension
* Drawing primitives (header)
*
* Started 990815 (split from sge_draw 010611)
*
* License: LGPL v2+ (see the file LICENSE)
* (c)1999-2003 Anders Lindström
*/

/*********************************************************************
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
*********************************************************************/

#ifndef sge_primitives_int_H
#define sge_primitives_int_H

#include "sge_internal.h"
#include <SDL.h>

void _Line(SDL_Surface* surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
void _LineAlpha(SDL_Surface* Surface, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 Color, Uint8 alpha);
void _HLine(SDL_Surface* Surface, Sint16 x1, Sint16 x2, Sint16 y, Uint32 Color);
void _HLineAlpha(SDL_Surface* Surface, Sint16 x1, Sint16 x2, Sint16 y, Uint32 Color, Uint8 alpha);
void callback_alpha_hack(SDL_Surface* surf, Sint16 x, Sint16 y, Uint32 color);
void _AALineAlpha(SDL_Surface* dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, Uint8 alpha);
void _AAmcLineAlpha(SDL_Surface* dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 r1, Uint8 g1, Uint8 b1, Uint8 r2, Uint8 g2,
Uint8 b2, Uint8 alpha);
#endif
12 changes: 6 additions & 6 deletions SGE/sge_rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ SDL_Rect sge_transform_tmap(SDL_Surface* src, SDL_Surface* dst, float angle, flo
// Helper function to sge_transform()
// Returns the bounding box
//==================================================================================
void _calcRect(SDL_Surface* src, SDL_Surface* dst, float theta, float xscale, float yscale, Uint16 px, Uint16 py, Uint16 qx, Uint16 qy,
Sint16* xmin, Sint16* ymin, Sint16* xmax, Sint16* ymax)
static void _calcRect(SDL_Surface* src, SDL_Surface* dst, float theta, float xscale, float yscale, Uint16 px, Uint16 py, Uint16 qx,
Uint16 qy, Sint16* xmin, Sint16* ymin, Sint16* xmax, Sint16* ymax)
{
Sint16 x, y, rx, ry;

Expand Down Expand Up @@ -318,8 +318,8 @@ void _calcRect(SDL_Surface* src, SDL_Surface* dst, float theta, float xscale, fl
// We get better performance if AA and normal rendering is seperated into two functions (better optimization).
// sge_transform() is used as a wrapper.

SDL_Rect sge_transformNorm(SDL_Surface* src, SDL_Surface* dst, float angle, float xscale, float yscale, Uint16 px, Uint16 py, Uint16 qx,
Uint16 qy, Uint8 flags)
static SDL_Rect sge_transformNorm(SDL_Surface* src, SDL_Surface* dst, float angle, float xscale, float yscale, Uint16 px, Uint16 py,
Uint16 qx, Uint16 qy, Uint8 flags)
{
Sint32 dy, sx, sy;
Sint16 x, y, rx, ry;
Expand Down Expand Up @@ -425,8 +425,8 @@ SDL_Rect sge_transformNorm(SDL_Surface* src, SDL_Surface* dst, float angle, floa
return r;
}

SDL_Rect sge_transformAA(SDL_Surface* src, SDL_Surface* dst, float angle, float xscale, float yscale, Uint16 px, Uint16 py, Uint16 qx,
Uint16 qy, Uint8 flags)
static SDL_Rect sge_transformAA(SDL_Surface* src, SDL_Surface* dst, float angle, float xscale, float yscale, Uint16 px, Uint16 py,
Uint16 qx, Uint16 qy, Uint8 flags)
{
Sint32 dy, sx, sy;
Sint16 x, y, rx, ry;
Expand Down
2 changes: 1 addition & 1 deletion SGE/sge_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ struct seg
* A 4-connected neighbor is a pixel above, below, left, or right of a pixel.
*/
// First a generic (slow) version and then 8/16/32 bpp versions
void _FloodFillX(SDL_Surface* dst, Sint16 x, Sint16 y, Uint32 color)
static void _FloodFillX(SDL_Surface* dst, Sint16 x, Sint16 y, Uint32 color)
{
Sint16 l, x1, x2, dy;
Uint32 oc; /* old pixel color */
Expand Down
Loading

0 comments on commit 817e287

Please sign in to comment.