Merge pull request #671 from devnexen/code_fixes

Reducing some compilation warnings.
This commit is contained in:
YVT 2017-11-19 13:16:29 +09:00 committed by GitHub
commit b68a17c148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 116 additions and 113 deletions

View File

@ -329,10 +329,10 @@ namespace spades {
static void DebugLog(const char *msg, void *) { SPLog("YSR Debug: %s", msg); }
YsrDevice::YsrDevice()
: gameMap(nullptr),
driver(new YsrDriver()),
roomHistoryPos(0),
listenerPosition(MakeVector3(0, 0, 0)) {
: driver(new YsrDriver()),
gameMap(nullptr),
listenerPosition(MakeVector3(0, 0, 0)),
roomHistoryPos(0) {
SDL_AudioSpec spec;
spec.callback = reinterpret_cast<SDL_AudioCallback>(RenderCallback);
spec.userdata = this;

View File

@ -27,7 +27,7 @@
namespace spades {
namespace client {
CenterMessageView::CenterMessageView(Client *client, IFont *font)
: client(client), font(font), renderer(client->GetRenderer()) {
: client(client), renderer(client->GetRenderer()), font(font) {
SPADES_MARK_FUNCTION();
for (int i = 0; i < 2; i++)

View File

@ -72,52 +72,51 @@ namespace spades {
Client::Client(IRenderer *r, IAudioDevice *audioDev, const ServerAddress &host,
FontManager *fontManager)
: renderer(r),
audioDevice(audioDev),
playerName(cg_playerName.operator std::string().substr(0, 15)),
hasDelayedReload(false),
hostname(host),
: playerName(cg_playerName.operator std::string().substr(0, 15)),
logStream(nullptr),
fontManager(fontManager),
hostname(host),
renderer(r),
audioDevice(audioDev),
readyToClose(false),
scoreboardVisible(false),
flashlightOn(false),
inGameLimbo(false),
frameToRendererInit(5),
time(0.f),
timeSinceInit(0.f),
readyToClose(false),
worldSubFrame(0.f),
frameToRendererInit(5),
timeSinceInit(0.f),
hasLastTool(false),
lastPosSentTime(0.f),
lastAliveTime(0.f),
lastKills(0),
hasDelayedReload(false),
localFireVibrationTime(-1.f),
grenadeVibration(0.f),
grenadeVibrationSlow(0.f),
scoreboardVisible(false),
flashlightOn(false),
hitFeedbackIconState(0.f),
hitFeedbackFriendly(false),
focalLength(20.f),
targetFocalLength(20.f),
autoFocusEnabled(true),
hitFeedbackIconState(0.f),
hitFeedbackFriendly(false),
localFireVibrationTime(-1.f),
lastPosSentTime(0.f),
worldSubFrame(0.f),
grenadeVibration(0.f),
grenadeVibrationSlow(0.f),
lastMyCorpse(nullptr),
hasLastTool(false),
nextScreenShotIndex(0),
nextMapShotIndex(0),
alertDisappearTime(-10000.f),
// FIXME: preferences?
followYaw(0.f),
followPitch(0.f),
inGameLimbo(false),
fontManager(fontManager),
alertDisappearTime(-10000.f),
lastMyCorpse(nullptr),
corpseSoftTimeLimit(30.f), // FIXME: this is not used
corpseSoftLimit(6),
corpseHardLimit(16),
followYaw(0.f),
followPitch(0.f) {
nextScreenShotIndex(0),
nextMapShotIndex(0) {
SPADES_MARK_FUNCTION();
SPLog("Initializing...");

View File

@ -201,7 +201,7 @@ namespace spades {
float ScreenHeight() { return base->ScreenHeight(); }
};
ClientPlayer::ClientPlayer(Player *p, Client *c) : player(p), client(c), hasValidOriginMatrix(false) {
ClientPlayer::ClientPlayer(Player *p, Client *c) : client(c), player(p), hasValidOriginMatrix(false) {
SPADES_MARK_FUNCTION();
sprintState = 0.f;

View File

@ -193,10 +193,10 @@ namespace spades {
FTFont::FTFont(client::IRenderer *renderer, FTFontSet *fontSet, float height,
float lineHeight)
: client::IFont(renderer),
fontSet(fontSet),
height(height),
renderer(renderer),
lineHeight(lineHeight),
renderer(renderer) {
height(height),
fontSet(fontSet) {
SPADES_MARK_FUNCTION();
SPAssert(renderer);

View File

@ -51,7 +51,7 @@ namespace spades {
int numHeadHits;
std::array<int, 3> numLimbHits;
int numTorsoHits;
PlayerHit() : numHeadHits(0), numLimbHits({0, 0, 0}), numTorsoHits(0) {}
PlayerHit() : numHeadHits(0), numLimbHits({{0, 0, 0}}), numTorsoHits(0) {}
};
/** Save hit detection debug image */

View File

@ -49,7 +49,7 @@ namespace spades {
MenuItem() {}
MenuItem(MenuType type, AABB2 rt, std::string txt)
: type(type), rect(rt), hover(false), text(txt) {}
: type(type), rect(rt), text(txt), hover(false) {}
};
Client *client;
IRenderer *renderer;

View File

@ -57,7 +57,7 @@ namespace spades {
struct PlayerInput;
struct WeaponInput;
class Grenade;
class GameProperties;
struct GameProperties;
class NetClient {
Client *client;
NetClientStatus status;

View File

@ -36,8 +36,8 @@ namespace spades {
shootingPreviously(false),
reloading(false),
nextShotTime(0.f),
reloadEndTime(-100.f),
reloadStartTime(-101.f),
reloadEndTime(-100.f),
lastDryFire(false) {
SPADES_MARK_FUNCTION();
}

View File

@ -28,7 +28,7 @@ namespace spades {
namespace client {
class World;
class Player;
class GameProperties;
struct GameProperties;
class Weapon {
World *world;

View File

@ -43,7 +43,7 @@ namespace spades {
class IGameMode;
class Client; // FIXME: for debug
class HitTestDebugger;
class GameProperties;
struct GameProperties;
class World {
friend class Client; // FIXME: for debug
public:

View File

@ -31,7 +31,7 @@
#include <ScriptBindings/ScriptManager.h>
namespace spades {
Bitmap::Bitmap(int ww, int hh) : w(ww), h(hh), autoDelete(true), pixels(nullptr) {
Bitmap::Bitmap(int ww, int hh) : w(ww), h(hh), pixels(nullptr), autoDelete(true) {
SPADES_MARK_FUNCTION();
if (w < 1 || h < 1 || w > 8192 || h > 8192) {
@ -42,7 +42,7 @@ namespace spades {
SPAssert(pixels != NULL);
}
Bitmap::Bitmap(uint32_t *pixels, int w, int h) : pixels(pixels), w(w), h(h), autoDelete(false) {
Bitmap::Bitmap(uint32_t *pixels, int w, int h) : w(w), h(h), pixels(pixels), autoDelete(false) {
SPADES_MARK_FUNCTION();
if (w < 1 || h < 1 || w > 8192 || h > 8192) {

View File

@ -295,7 +295,7 @@ namespace spades {
SPADES_MARK_FUNCTION();
}
ConcurrentDispatch::ConcurrentDispatch(std::string name)
: entry(NULL), name(name), runnable(NULL) {
: name(name), entry(NULL), runnable(NULL) {
SPADES_MARK_FUNCTION();
}

View File

@ -24,5 +24,6 @@ namespace spades {
class IRunnable {
public:
virtual void Run() = 0;
virtual ~IRunnable() {};
};
}

View File

@ -50,7 +50,7 @@ namespace spades {
size_t remDataPos;
public:
ZipFileInputStream(ZipFileSystem *fs, unzFile zf) : streaming(true), zip(zf), fs(fs) {
ZipFileInputStream(ZipFileSystem *fs, unzFile zf) : fs(fs), zip(zf), streaming(true) {
SPADES_MARK_FUNCTION();
}

View File

@ -27,11 +27,11 @@
namespace spades {
namespace draw {
GLDynamicLightShader::GLDynamicLightShader()
: dynamicLightRadius("dynamicLightRadius"),
: dynamicLightOrigin("dynamicLightOrigin"),
dynamicLightColor("dynamicLightColor"),
dynamicLightOrigin("dynamicLightOrigin"),
dynamicLightSpotMatrix("dynamicLightSpotMatrix"),
dynamicLightRadius("dynamicLightRadius"),
dynamicLightRadiusInversed("dynamicLightRadiusInversed"),
dynamicLightSpotMatrix("dynamicLightSpotMatrix"),
dynamicLightProjectionTexture("dynamicLightProjectionTexture")
{

View File

@ -37,14 +37,14 @@ namespace spades {
projectionViewMatrix("projectionViewMatrix"),
rightVector("rightVector"),
upVector("upVector"),
positionAttribute("positionAttribute"),
texCoordAttribute("texCoordAttribute"),
colorAttribute("colorAttribute"),
texture("mainTexture"),
viewMatrix("viewMatrix"),
fogDistance("fogDistance"),
fogColor("fogColor"),
viewOriginVector("viewOriginVector") {
viewOriginVector("viewOriginVector"),
positionAttribute("positionAttribute"),
texCoordAttribute("texCoordAttribute"),
colorAttribute("colorAttribute") {
SPADES_MARK_FUNCTION();
program = renderer->RegisterProgram("Shaders/LongSprite.program");

View File

@ -48,7 +48,7 @@ namespace spades {
renderer->RegisterImage("Gfx/AmbientOcclusion.png");
}
GLMapRenderer::GLMapRenderer(client::GameMap *m, GLRenderer *r) : gameMap(m), renderer(r) {
GLMapRenderer::GLMapRenderer(client::GameMap *m, GLRenderer *r) : renderer(r), gameMap(m) {
SPADES_MARK_FUNCTION();
device = renderer->GetGLDevice();

View File

@ -26,7 +26,7 @@
namespace spades {
namespace draw {
GLProgramAttribute::GLProgramAttribute(const std::string &n)
: name(n), last(NULL), loc(-1) {}
: last(NULL), loc(-1), name(n) {}
int GLProgramAttribute::operator()(spades::draw::GLProgram *prog) {
SPADES_MARK_FUNCTION_DEBUG();

View File

@ -97,8 +97,8 @@ namespace spades {
lastColorBufferTexture(0),
fogDistance(128.f),
renderingMirror(false),
duringSceneRendering(false),
lastTime(0) {
lastTime(0),
duringSceneRendering(false) {
SPADES_MARK_FUNCTION();
SPLog("GLRenderer bootstrap");

View File

@ -34,10 +34,11 @@
namespace spades {
namespace draw {
GLShadowShader::GLShadowShader()
: fogColor("fogColor"),
: eyeOrigin("eyeOrigin"),
eyeFront("eyeFront"),
eyeOrigin("eyeOrigin"),
mapShadowTexture("mapShadowTexture"),
fogColor("fogColor"),
ambientColor("ambientColor"),
shadowMapViewMatrix("shadowMapViewMatrix"),
shadowMapTexture1("shadowMapTexture1"),
shadowMapTexture2("shadowMapTexture2"),
@ -50,7 +51,6 @@ namespace spades {
radiosityTextureX("radiosityTextureX"),
radiosityTextureY("radiosityTextureY"),
radiosityTextureZ("radiosityTextureZ"),
ambientColor("ambientColor"),
pagetableSize("pagetableSize"),
pagetableSizeInv("pagetableSizeInv"),
minLod("minLod"),

View File

@ -37,27 +37,27 @@ namespace spades {
GLSoftLitSpriteRenderer::GLSoftLitSpriteRenderer(GLRenderer *renderer)
: renderer(renderer),
device(renderer->GetGLDevice()),
settings(renderer->GetSettings()),
device(renderer->GetGLDevice()),
projectionViewMatrix("projectionViewMatrix"),
rightVector("rightVector"),
upVector("upVector"),
positionAttribute("positionAttribute"),
spritePosAttribute("spritePosAttribute"),
colorAttribute("colorAttribute"),
frontVector("frontVector"),
viewOriginVector("viewOriginVector"),
texture("mainTexture"),
depthTexture("depthTexture"),
viewMatrix("viewMatrix"),
fogDistance("fogDistance"),
fogColor("sRGBFogColor"),
depthTexture("depthTexture"),
zNearFar("zNearFar"),
frontVector("frontVector"),
viewOriginVector("viewOriginVector"),
cameraPosition("cameraPosition"),
positionAttribute("positionAttribute"),
spritePosAttribute("spritePosAttribute"),
colorAttribute("colorAttribute"),
emissionAttribute("emissionAttribute"),
dlRAttribute("dlRAttribute"),
dlGAttribute("dlGAttribute"),
dlBAttribute("dlBAttribute"),
emissionAttribute("emissionAttribute"),
cameraPosition("cameraPosition") {
dlBAttribute("dlBAttribute") {
SPADES_MARK_FUNCTION();
program = renderer->RegisterProgram("Shaders/SoftLitSprite.program");

View File

@ -39,17 +39,17 @@ namespace spades {
projectionViewMatrix("projectionViewMatrix"),
rightVector("rightVector"),
upVector("upVector"),
positionAttribute("positionAttribute"),
spritePosAttribute("spritePosAttribute"),
colorAttribute("colorAttribute"),
frontVector("frontVector"),
viewOriginVector("viewOriginVector"),
texture("mainTexture"),
depthTexture("depthTexture"),
viewMatrix("viewMatrix"),
fogDistance("fogDistance"),
fogColor("fogColor"),
depthTexture("depthTexture"),
zNearFar("zNearFar"),
frontVector("frontVector"),
viewOriginVector("viewOriginVector") {
positionAttribute("positionAttribute"),
spritePosAttribute("spritePosAttribute"),
colorAttribute("colorAttribute") {
SPADES_MARK_FUNCTION();
program = renderer->RegisterProgram("Shaders/SoftSprite.program");

View File

@ -36,14 +36,14 @@ namespace spades {
projectionViewMatrix("projectionViewMatrix"),
rightVector("rightVector"),
upVector("upVector"),
positionAttribute("positionAttribute"),
spritePosAttribute("spritePosAttribute"),
colorAttribute("colorAttribute"),
texture("mainTexture"),
viewMatrix("viewMatrix"),
fogDistance("fogDistance"),
fogColor("fogColor"),
viewOriginVector("viewOriginVector") {
viewOriginVector("viewOriginVector"),
positionAttribute("positionAttribute"),
spritePosAttribute("spritePosAttribute"),
colorAttribute("colorAttribute") {
SPADES_MARK_FUNCTION();
program = renderer->RegisterProgram("Shaders/Sprite.program");

View File

@ -31,7 +31,7 @@
namespace spades {
namespace draw {
SWFlatMapRenderer::SWFlatMapRenderer(SWRenderer *r, client::GameMap *map)
: map(map), r(r), needsUpdate(true), w(map->Width()), h(map->Height()) {
: r(r), map(map), w(map->Width()), h(map->Height()), needsUpdate(true) {
SPADES_MARK_FUNCTION();
if (w & 31) {

View File

@ -43,13 +43,13 @@ namespace spades {
}
SWImage::SWImage(Bitmap *m)
: w(static_cast<float>(m->GetWidth())),
: ew(m->GetWidth()),
eh(m->GetHeight()),
isWhite(false),
w(static_cast<float>(m->GetWidth())),
h(static_cast<float>(m->GetHeight())),
iw(1.f / w),
ih(1.f / h),
ew(m->GetWidth()),
eh(m->GetHeight()),
isWhite(false) {
ih(1.f / h) {
bmp.resize(ew * eh);
// premultiplied alpha
@ -72,11 +72,11 @@ namespace spades {
SWImage::SWImage(int w, int h)
: ew(w),
eh(h),
isWhite(false),
w(static_cast<float>(ew)),
h(static_cast<float>(eh)),
iw(1.f / w),
ih(1.f / h),
isWhite(false) {
ih(1.f / h) {
bmp.reserve(ew * eh);
}

View File

@ -105,14 +105,14 @@ namespace spades {
};
SWMapRenderer::SWMapRenderer(SWRenderer *r, client::GameMap *m, SWFeatureLevel level)
: map(m),
: w(m->Width()),
h(m->Height()),
renderer(r),
level(level),
map(m),
frameBuf(nullptr),
depthBuf(nullptr),
rleHeap(m->Width() * m->Height() * 64),
level(level),
w(m->Width()),
h(m->Height()),
renderer(r) {
rleHeap(m->Width() * m->Height() * 64) {
rle.resize(w * h);
rleLen.resize(w * h);

View File

@ -43,7 +43,8 @@ DEFINE_SPADES_SETTING(r_swNumThreads, "4");
namespace spades {
namespace draw {
SWRenderer::SWRenderer(SWPort *port, SWFeatureLevel level)
: port(port),
: featureLevel(level),
port(port),
map(nullptr),
fb(nullptr),
inited(false),
@ -53,8 +54,7 @@ namespace spades {
drawColorAlphaPremultiplied(MakeVector4(1, 1, 1, 1)),
legacyColorPremultiply(false),
lastTime(0),
duringSceneRendering(false),
featureLevel(level) {
duringSceneRendering(false) {
SPADES_MARK_FUNCTION();

View File

@ -427,7 +427,7 @@ namespace spades {
IGLDevice::UInteger SDLGLDevice::GenBuffer() {
SPADES_MARK_FUNCTION_DEBUG();
GLuint i;
GLuint i = 0;
#if GLEW
if (glGenBuffers)
glGenBuffers(1, &i);
@ -469,7 +469,7 @@ namespace spades {
case draw::IGLDevice::ReadWrite: acc = GL_READ_WRITE; break;
default: SPInvalidEnum("access", access);
}
void *ret;
void *ret = nullptr;
#if GLEW
if (glMapBuffer)
ret = glMapBuffer(parseBufferTarget(target), acc);
@ -565,7 +565,7 @@ namespace spades {
IGLDevice::UInteger SDLGLDevice::GenQuery() {
SPADES_MARK_FUNCTION_DEBUG();
GLuint val;
GLuint val = 0;
#if GLEW
if (glGenQueries)
glGenQueries(1, &val);
@ -640,7 +640,7 @@ namespace spades {
}
IGLDevice::UInteger SDLGLDevice::GetQueryObjectUInteger(UInteger query, Enum pname) {
GLuint val;
GLuint val = 0;
SPADES_MARK_FUNCTION_DEBUG();
#if GLEW
@ -684,7 +684,7 @@ namespace spades {
}
IGLDevice::UInteger64 SDLGLDevice::GetQueryObjectUInteger64(UInteger query, Enum pname) {
GLuint64 val;
GLuint64 val = 0;
SPADES_MARK_FUNCTION_DEBUG();
#if GLEW
@ -1300,7 +1300,7 @@ namespace spades {
IGLDevice::UInteger SDLGLDevice::CreateShader(Enum type) {
SPADES_MARK_FUNCTION();
IGLDevice::UInteger ret;
IGLDevice::UInteger ret = 0;
#if GLEW
if (glCreateShader)
switch (type) {
@ -1386,7 +1386,7 @@ namespace spades {
IGLDevice::Integer SDLGLDevice::GetShaderInteger(UInteger shader, Enum param) {
SPADES_MARK_FUNCTION();
GLint ret;
GLint ret = -1;
#if GLEW
if (glGetShaderiv)
switch (param) {
@ -1454,7 +1454,7 @@ namespace spades {
IGLDevice::Integer SDLGLDevice::GetProgramInteger(UInteger shader, Enum param) {
SPADES_MARK_FUNCTION();
GLint ret;
GLint ret = -1;
#if GLEW
if (glGetProgramiv)
switch (param) {
@ -1520,6 +1520,7 @@ namespace spades {
return glCreateProgramObjectARB();
else
ReportMissingFunc("glCreateProgram");
return 0;
#else
CheckExistence(glCreateProgram);
return glCreateProgram();
@ -1625,6 +1626,7 @@ namespace spades {
return glGetAttribLocationARB(program, name);
else
ReportMissingFunc("glGetAttribLocation");
return 0;
#else
CheckExistence(glGetAttribLocation);
return glGetAttribLocation(program, name);
@ -1654,6 +1656,7 @@ namespace spades {
return glGetUniformLocationARB(program, name);
else
ReportMissingFunc("glGetUniformLocation");
return 0;
#else
CheckExistence(glGetUniformLocation);
return glGetUniformLocation(program, name);
@ -1799,7 +1802,7 @@ namespace spades {
}
IGLDevice::UInteger SDLGLDevice::GenFramebuffer() {
GLuint v;
GLuint v = 0;
#if GLEW
if (glGenFramebuffers)
glGenFramebuffers(1, &v);
@ -1844,7 +1847,7 @@ namespace spades {
CheckError();
}
IGLDevice::Enum SDLGLDevice::CheckFramebufferStatus(spades::draw::IGLDevice::Enum target) {
GLenum ret;
GLenum ret = 0;
#if GLEW
if (glCheckFramebufferStatus)
ret = glCheckFramebufferStatus(parseFramebufferTarget(target));
@ -1950,7 +1953,7 @@ namespace spades {
}
IGLDevice::UInteger SDLGLDevice::GenRenderbuffer() {
GLuint v;
GLuint v = 0;
#if GLEW
if (glGenRenderbuffers)
glGenRenderbuffers(1, &v);

View File

@ -38,9 +38,9 @@ namespace spades {
StartupScreenHelper *helper, client::FontManager *fontManager)
: renderer(r),
audioDevice(a),
fontManager(fontManager),
startRequested(false),
helper(helper),
fontManager(fontManager) {
helper(helper) {
SPADES_MARK_FUNCTION();
if (r == NULL)
SPInvalidArgument("r");