Reduce compiler warnings

This commit is contained in:
yvt 2014-04-06 22:42:17 +09:00
parent ad5701bcd9
commit d856bcadaa
27 changed files with 52 additions and 105 deletions

View File

@ -170,7 +170,9 @@ void RegisterScriptArray(asIScriptEngine *engine, bool defaultArray)
if( defaultArray )
{
#ifndef NDEBUG
int r = engine->RegisterDefaultArrayType("array<T>"); assert( r >= 0 );
#endif
}
}
@ -863,8 +865,9 @@ bool CScriptArray::operator==(const CScriptArray &other) const
if( state == asEXECUTION_ABORTED )
cmpContext->Abort();
}
else
else{
cmpContext->Release();
}
return isEqual;
}
@ -1045,8 +1048,9 @@ int CScriptArray::Find(asUINT index, void *value) const
if( state == asEXECUTION_ABORTED )
cmpContext->Abort();
}
else
else{
cmpContext->Release();
}
return ret;
}
@ -1218,8 +1222,9 @@ void CScriptArray::Sort(asUINT index, asUINT count, bool asc)
if( state == asEXECUTION_ABORTED )
cmpContext->Abort();
}
else
else{
cmpContext->Release();
}
}
// internal
@ -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 )

View File

@ -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());

View File

@ -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 )

View File

@ -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());
}

View File

@ -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 &&

View File

@ -55,11 +55,6 @@
#include "NetClient.h"
static float nextRandom() {
return (float)rand() / (float)RAND_MAX;
}
SPADES_SETTING(cg_chatBeep, "1");

View File

@ -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();
@ -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;
@ -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());
@ -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();

View File

@ -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():
@ -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;

View File

@ -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();
@ -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){

View File

@ -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;

View File

@ -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();
@ -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()) {
@ -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++){

View File

@ -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");

View File

@ -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();

View File

@ -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;

View File

@ -34,6 +34,8 @@
namespace spades {
#ifdef WIN32
static std::string SdlReceiveString(char *ptr) {
if(!ptr) {
return "";
@ -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"";

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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){

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -83,6 +83,7 @@ enet_protocol_dispatch_incoming_commands (ENetHost * host, ENetEvent * event)
}
return 1;
default: break;
}
}
@ -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;
@ -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;

View File

@ -224,57 +224,7 @@ namespace spades {
query = new ServerListQuery(this);
query->Start();
}
static std::string TextifyHTML(const std::string& html) {
std::string out;
int blankLineLength = 0;
bool inTag = false;
bool inTagName = false;
bool hasLetter = false;
std::string tagName;
for(size_t i = 0; i < html.size(); i++){
if(html[i] == '<') {
inTag = true;
inTagName = true;
tagName.clear();
}
if(inTag) {
if(inTagName) {
if(html[i] == '/')
i++;
if(html[i] < 'a' || html[i] > 'z') {
inTagName = false;
if(html[i] == '>') {
inTag = false;
}
if(tagName == "br" ||
tagName == "h3" ||
tagName == "h2") {
if(blankLineLength < 1) {
out += "\n";
hasLetter = false;
blankLineLength++;
}
}
}else{
tagName += html[i];
}
}else if(html[i] == '>') {
inTag = false;
}
continue;
}
bool isLetter = !isspace(html[i]);
if(hasLetter == false && isLetter == false)
continue;
hasLetter = true;
blankLineLength = 0;
out += html[i];
}
return out;
}
#include "Credits.inc" // C++11 raw string literal makes some tools (ex. xgettext, Xcode) misbehave
std::string MainScreenHelper::GetCredits() {

View File

@ -39,7 +39,7 @@ SPADES_SETTING(r_ignoreGLErrors, "1");
static uint32_t vertCount = 0;
static uint32_t drawOps = 0;
static Uint32 lastFrame = 0;
// static Uint32 lastFrame = 0;
namespace spades {
namespace gui {
@ -118,10 +118,12 @@ ReportError(err, __LINE__, __PRETTY_FUNCTION__); \
func, __FILE__, line);
}
}
#ifdef GLEW
static void ReportMissingFunc(const char *func){
SPRaise("GL function %s missing",
func);
}
#endif
SDLGLDevice::SDLGLDevice(SDL_Window *s):
window(s) {
@ -160,7 +162,7 @@ ReportError(err, __LINE__, __PRETTY_FUNCTION__); \
SPLog("Shading Language Version: %s", ret);
}
SPLog("--- Extensions ---");
if(glGetStringi) {
if(&glGetStringi) {
GLint cnt = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &cnt);
if(cnt <= 0) goto retrvFail;

View File

@ -243,6 +243,7 @@ namespace spades {
manager->CheckError(r);
break;
default: break;
}
}
};

View File

@ -1065,6 +1065,7 @@ namespace spades {
break;
default: break;
}