Skip to content

Commit

Permalink
Reduce compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yvt committed Apr 6, 2014
1 parent ad5701b commit d856bca
Show file tree
Hide file tree
Showing 27 changed files with 52 additions and 105 deletions.
13 changes: 9 additions & 4 deletions Sources/AngelScript/addons/scriptarray.cpp
Expand Up @@ -170,7 +170,9 @@ void RegisterScriptArray(asIScriptEngine *engine, bool defaultArray)

if( defaultArray )
{
#ifndef NDEBUG
int r = engine->RegisterDefaultArrayType("array<T>"); assert( r >= 0 );
#endif
}
}

Expand Down Expand Up @@ -863,8 +865,9 @@ bool CScriptArray::operator==(const CScriptArray &other) const
if( state == asEXECUTION_ABORTED )
cmpContext->Abort();
}
else
else{
cmpContext->Release();
}

return isEqual;
}
Expand Down Expand Up @@ -1045,8 +1048,9 @@ int CScriptArray::Find(asUINT index, void *value) const
if( state == asEXECUTION_ABORTED )
cmpContext->Abort();
}
else
else{
cmpContext->Release();
}

return ret;
}
Expand Down Expand Up @@ -1218,8 +1222,9 @@ void CScriptArray::Sort(asUINT index, asUINT count, bool asc)
if( state == asEXECUTION_ABORTED )
cmpContext->Abort();
}
else
else{
cmpContext->Release();
}
}

// internal
Expand Down Expand Up @@ -1346,7 +1351,7 @@ void CScriptArray::Precache()

if( (flags & asTM_INREF) )
{
if( (paramTypeId & asTYPEID_OBJHANDLE) || mustBeConst && !(flags & asTM_CONST) )
if( (paramTypeId & asTYPEID_OBJHANDLE) || (mustBeConst && !(flags & asTM_CONST)) )
continue;
}
else if( paramTypeId & asTYPEID_OBJHANDLE )
Expand Down
2 changes: 1 addition & 1 deletion Sources/AngelScript/addons/scripthelper.cpp
Expand Up @@ -477,7 +477,7 @@ void PrintException(asIScriptContext *ctx, bool printStack)
{
if( ctx->GetState() != asEXECUTION_EXCEPTION ) return;

asIScriptEngine *engine = ctx->GetEngine();
//asIScriptEngine *engine = ctx->GetEngine();
const asIScriptFunction *function = ctx->GetExceptionFunction();
printf("func: %s\n", function->GetDeclaration());
printf("modl: %s\n", function->GetModuleName());
Expand Down
4 changes: 2 additions & 2 deletions Sources/AngelScript/addons/scriptstdstring.cpp
Expand Up @@ -435,10 +435,10 @@ static asINT64 parseInt(const string &val, asUINT base, asUINT *byteCount)
if( *end == '-' )
{
sign = true;
*end++;
end++;
}
else if( *end == '+' )
*end++;
end++;

asINT64 res = 0;
if( base == 10 )
Expand Down
2 changes: 1 addition & 1 deletion Sources/AngelScript/addons/weakref.cpp
Expand Up @@ -230,7 +230,7 @@ static void ScriptWeakRefRelease_Generic(asIScriptGeneric *gen)

void CScriptWeakRef_Get_Generic(asIScriptGeneric *gen)
{
int typeId = gen->GetArgTypeId(0);
//int typeId = gen->GetArgTypeId(0);
CScriptWeakRef *self = reinterpret_cast<CScriptWeakRef*>(gen->GetObject());
gen->SetReturnAddress(self->Get());
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Client/ChatWindow.cpp
Expand Up @@ -108,7 +108,7 @@ namespace spades {
float x = 0.f, maxW = GetWidth();
float lh = GetLineHeight(), h = lh;
size_t wordStart = std::string::npos;
size_t wordStartOutPos;
size_t wordStartOutPos = 0;

for(size_t i = 0; i < msg.size(); i++){
if(msg[i] > MsgColorMax &&
Expand Down
5 changes: 0 additions & 5 deletions Sources/Client/Client.cpp
Expand Up @@ -55,11 +55,6 @@
#include "NetClient.h"


static float nextRandom() {
return (float)rand() / (float)RAND_MAX;
}


SPADES_SETTING(cg_chatBeep, "1");


Expand Down
16 changes: 8 additions & 8 deletions Sources/Client/Client_Draw.cpp
Expand Up @@ -300,11 +300,11 @@ namespace spades {
void Client::DrawDebugAim() {
SPADES_MARK_FUNCTION();

float scrWidth = renderer->ScreenWidth();
float scrHeight = renderer->ScreenHeight();
float wTime = world->GetTime();
//float scrWidth = renderer->ScreenWidth();
//float scrHeight = renderer->ScreenHeight();
//float wTime = world->GetTime();
Player *p = GetWorld()->GetLocalPlayer();
IFont *font;
//IFont *font;

Weapon *w = p->GetWeapon();
float spread = w->GetSpread();
Expand Down Expand Up @@ -378,7 +378,7 @@ namespace spades {

float scrWidth = renderer->ScreenWidth();
float scrHeight = renderer->ScreenHeight();
float wTime = world->GetTime();
//float wTime = world->GetTime();
Player *p = GetWorld()->GetLocalPlayer();
IFont *font;

Expand Down Expand Up @@ -705,7 +705,7 @@ namespace spades {

Player *p = GetWorld()->GetLocalPlayer();
IFont *font;
float scrWidth = renderer->ScreenWidth();
//float scrWidth = renderer->ScreenWidth();
float scrHeight = renderer->ScreenHeight();

std::string str = std::to_string(p->GetHealth());
Expand All @@ -730,9 +730,9 @@ namespace spades {
SPADES_MARK_FUNCTION();

float scrWidth = renderer->ScreenWidth();
float scrHeight = renderer->ScreenHeight();
//float scrHeight = renderer->ScreenHeight();
IFont *font;
float wTime = world->GetTime();
//float wTime = world->GetTime();

for(auto& ent: localEntities){
ent->Render2D();
Expand Down
8 changes: 1 addition & 7 deletions Sources/Client/GameMap.cpp
Expand Up @@ -30,12 +30,6 @@
#include <algorithm>
#include <Core/AutoLocker.h>

// silly VOXLAP function
static inline void ftol(float f, long *a)
{
*a = (long)floor(f+0.5f);
}

namespace spades {
namespace client {
GameMap::GameMap():
Expand Down Expand Up @@ -413,7 +407,7 @@ namespace spades {
for(int i = 0; i < maxSteps; i++){
IntVector3 nextBlock;
int hasNextBlock = 0;
float nextBlockTime;
float nextBlockTime = 0.f;

if(invX != 0.f){
nextBlock = iv;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Client/NetClient.cpp
Expand Up @@ -858,7 +858,7 @@ namespace spades {
break;
{
//reader.ReadByte(); // skip player Id
Player *p = GetPlayerOrNull(reader.ReadByte());
//Player *p = GetPlayerOrNull(reader.ReadByte());
float fuseLen = reader.ReadFloat();
Vector3 pos, vel;
pos.x = reader.ReadFloat();
Expand Down Expand Up @@ -1495,7 +1495,7 @@ namespace spades {
}
case PacketTypeChangeWeapon:
{
Player * p = GetPlayerOrNull(reader.ReadByte());
//Player * p = GetPlayerOrNull(reader.ReadByte());
WeaponType wType;
int weapon = reader.ReadByte();
switch(weapon){
Expand Down
2 changes: 1 addition & 1 deletion Sources/Client/PhysicsConstants.h
Expand Up @@ -86,7 +86,7 @@ enum hitTag_t {
hit_Arms = 8
};

static hitTag_t& operator |= ( hitTag_t& left, const hitTag_t& right )
static inline hitTag_t& operator |= ( hitTag_t& left, const hitTag_t& right )
{
left = static_cast<hitTag_t>( static_cast<int>(left) | static_cast<int>(right) );
return left;
Expand Down
10 changes: 3 additions & 7 deletions Sources/Client/Player.cpp
Expand Up @@ -565,8 +565,8 @@ namespace spades {
std::map<int, HitTestDebugger::PlayerHit> playerHits;
std::vector<Vector3> bulletVectors;

Vector3 right = GetRight();
Vector3 up = GetUp();
//Vector3 right = GetRight();
//Vector3 up = GetUp();

int pellets = weapon->GetPelletSize();
float spread = weapon->GetSpread();
Expand Down Expand Up @@ -850,10 +850,7 @@ namespace spades {
outBlockCoord.x < map->Width() && outBlockCoord.y < map->Height() &&
outBlockCoord.z < map->Depth()){
if(outBlockCoord.z < 62){
int x = outBlockCoord.x;
int y = outBlockCoord.y;
int z = outBlockCoord.z;
SPAssert(map->IsSolid(x, y, z));
SPAssert(map->IsSolid(outBlockCoord.x, outBlockCoord.y, outBlockCoord.z));

// send destroy command only for local cmd
if(this == world->GetLocalPlayer()) {
Expand Down Expand Up @@ -894,7 +891,6 @@ namespace spades {
256);

Player *hitPlayer = NULL;
float hitPlayerDistance = 3.f;
int hitFlag = 0;

for(int i = 0; i < world->GetNumPlayerSlots(); i++){
Expand Down
3 changes: 1 addition & 2 deletions Sources/Client/ScoreboardView.cpp
Expand Up @@ -98,10 +98,9 @@ namespace spades {
Handle<IImage>image;
IFont *font;
Vector2 pos, size;
char buf[256];
std::string str;
float scrWidth = renderer->ScreenWidth();
float scrHeight = renderer->ScreenHeight();
//float scrHeight = renderer->ScreenHeight();
const Vector4 whiteColor = {1,1,1,1};
Handle<IImage> whiteImage = renderer->RegisterImage("Gfx/White.tga");

Expand Down
2 changes: 1 addition & 1 deletion Sources/Client/TCProgressView.cpp
Expand Up @@ -85,7 +85,7 @@ namespace spades {
if(p && p->GetTeamId() < 2 && p->IsAlive()){
// show approaching territory
TCGameMode::Territory *nearTerritory = NULL;
int nearTerId;
int nearTerId = 0;
float distance = 0.f;
int myTeam = p->GetTeamId();

Expand Down
2 changes: 2 additions & 0 deletions Sources/Core/DeflateStream.cpp
Expand Up @@ -184,7 +184,9 @@ namespace spades {
SPAssert(mode == CompressModeDecompress);
char inputBuffer[chunkSize];
char outputBuffer[chunkSize];
#ifndef NDEBUG
uLong oval = zstream.total_out;
#endif

if(reachedEOF)
return;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Core/FltkPreferenceImporter.cpp
Expand Up @@ -34,6 +34,8 @@

namespace spades {


#ifdef WIN32
static std::string SdlReceiveString(char *ptr) {
if(!ptr) {
return "";
Expand All @@ -42,8 +44,6 @@ namespace spades {
SDL_free(ptr);
return s;
}

#ifdef WIN32
static std::wstring Utf8ToWString(const char *s) {
auto *ws = (WCHAR*)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", (char *)(s), SDL_strlen(s)+1);
if(!ws) return L"";
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Math.h
Expand Up @@ -836,7 +836,7 @@ namespace spades {
AABB3 GetBoundingAABB() const;
};

static OBB3 operator *(const Matrix4&m, const OBB3& b) {
static inline OBB3 operator *(const Matrix4&m, const OBB3& b) {
return OBB3(m * b.m);
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Settings.h
Expand Up @@ -86,7 +86,7 @@ namespace spades {
}
};*/

static bool operator ==(const std::string& str, Settings::ItemHandle& handle) {
static inline bool operator ==(const std::string& str, Settings::ItemHandle& handle) {
return str == (std::string)handle;
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Strings.cpp
Expand Up @@ -808,7 +808,7 @@ namespace spades {

SkipWhitespace();
std::string directive;
int directiveIdx;
int directiveIdx = 0;
while(pos < po.size()) {
auto tk = ReadToken();
if(tk.first == TokenType::Symbol) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Draw/GLBasicShadowMapRenderer.cpp
Expand Up @@ -266,7 +266,7 @@ namespace spades {
GLProfiler profiler(device, "Slice %d / %d", i + 1,
(int)NumSlices);

float farDist;
float farDist = 0.0;
// TODO: variable far distance according to the scene definition
// (note that this needs uniform shader variable)
switch(i){
Expand Down
2 changes: 1 addition & 1 deletion Sources/Draw/GLMapShadowRenderer.cpp
Expand Up @@ -163,7 +163,7 @@ namespace spades{
int bx = 0, by = 0;
for(size_t i = 0; i < coarseUpdateBitmap.size(); i++) {
if(coarseUpdateBitmap[i]){
int minValue = -1, maxValue;
int minValue = -1, maxValue = 0;

uint32_t *bmp = bitmap.data();
bmp += bx + by * w;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Draw/SWModelRenderer.cpp
Expand Up @@ -76,8 +76,8 @@ namespace spades {
float dot2 = Vector3::Dot(axis2, lightVec) * fastRSqrt(axis2.GetPoweredLength());
float dot3 = Vector3::Dot(axis3, lightVec) * fastRSqrt(axis3.GetPoweredLength());
for(int x = 0; x < 3; x++){
float d;
int cnt;
float d = 0.0;
int cnt = 0;
switch(x){
case 0: d = -dot1; cnt = 1; break;
case 1: d = 0.f; cnt = 0; break;
Expand Down
2 changes: 1 addition & 1 deletion Sources/ENet/peer.c
Expand Up @@ -715,7 +715,7 @@ enet_peer_queue_incoming_command (ENetPeer * peer, const ENetProtocol * command,
static ENetIncomingCommand dummyCommand;

ENetChannel * channel = & peer -> channels [command -> header.channelID];
enet_uint32 unreliableSequenceNumber = 0, reliableSequenceNumber;
enet_uint32 unreliableSequenceNumber = 0, reliableSequenceNumber = 0;
enet_uint16 reliableWindow, currentWindow;
ENetIncomingCommand * incomingCommand;
ENetListIterator currentCommand;
Expand Down
4 changes: 3 additions & 1 deletion Sources/ENet/protocol.c
Expand Up @@ -83,6 +83,7 @@ enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event)
}

return 1;
default: break;
}
}

Expand Down Expand Up @@ -170,7 +171,7 @@ enet_protocol_remove_sent_unreliable_commands (ENetPeer * peer)
static ENetProtocolCommand
enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliableSequenceNumber, enet_uint8 channelID)
{
ENetOutgoingCommand * outgoingCommand;
ENetOutgoingCommand * outgoingCommand = NULL;
ENetListIterator currentCommand;
ENetProtocolCommand commandNumber;
int wasSent = 1;
Expand Down Expand Up @@ -863,6 +864,7 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer *
enet_list_empty (& peer -> sentReliableCommands))
enet_peer_disconnect (peer, peer -> eventData);
break;
default: break;
}

return 0;
Expand Down

0 comments on commit d856bca

Please sign in to comment.