Skip to content

Commit 89748d6

Browse files
committed
Reduced compiler warnings
1 parent 0f9bbcc commit 89748d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+129
-98
lines changed

OpenSpades.xcodeproj/project.pbxproj

+2-6
Original file line numberDiff line numberDiff line change
@@ -2830,8 +2830,7 @@
28302830
INFOPLIST_FILE = "XSpades/XSpades-Info.plist";
28312831
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
28322832
LIBRARY_SEARCH_PATHS = (
2833-
"$(inherited)",
2834-
/Users/tcpp/Programs/MacPrograms2/Ysr/DerivedData/Ysr/Build/Products/Release,
2833+
"$(inherited)"
28352834
);
28362835
MACOSX_DEPLOYMENT_TARGET = 10.7;
28372836
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2864,8 +2863,7 @@
28642863
INFOPLIST_FILE = "XSpades/XSpades-Info.plist";
28652864
LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks";
28662865
LIBRARY_SEARCH_PATHS = (
2867-
"$(inherited)",
2868-
/Users/tcpp/Programs/MacPrograms2/Ysr/DerivedData/Ysr/Build/Products/Release,
2866+
"$(inherited)"
28692867
);
28702868
MACOSX_DEPLOYMENT_TARGET = 10.7;
28712869
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2905,7 +2903,6 @@
29052903
HEADER_SEARCH_PATHS = (
29062904
/Library/Frameworks/SDL2.framework/Headers,
29072905
/Library/Frameworks/SDL2_image.framework/Headers,
2908-
/usr/local/include/FL/images,
29092906
/usr/local/include,
29102907
Sources/ENet/include,
29112908
"$(SRCROOT)",
@@ -2950,7 +2947,6 @@
29502947
HEADER_SEARCH_PATHS = (
29512948
/Library/Frameworks/SDL2.framework/Headers,
29522949
/Library/Frameworks/SDL2_image.framework/Headers,
2953-
/usr/local/include/FL/images,
29542950
/usr/local/include,
29552951
Sources/ENet/include,
29562952
"$(SRCROOT)",

Sources/AngelScript/addons/scriptarray.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -859,16 +859,19 @@ bool CScriptArray::operator==(const CScriptArray &other) const
859859
}
860860

861861
if( cmpContext )
862+
{
862863
if( isNested )
863864
{
864865
asEContextState state = cmpContext->GetState();
865866
cmpContext->PopState();
866867
if( state == asEXECUTION_ABORTED )
867868
cmpContext->Abort();
868869
}
869-
else{
870+
else
871+
{
870872
cmpContext->Release();
871873
}
874+
}
872875

873876
return isEqual;
874877
}
@@ -1042,16 +1045,19 @@ int CScriptArray::Find(asUINT index, void *value) const
10421045
}
10431046

10441047
if( cmpContext )
1048+
{
10451049
if( isNested )
10461050
{
10471051
asEContextState state = cmpContext->GetState();
10481052
cmpContext->PopState();
10491053
if( state == asEXECUTION_ABORTED )
10501054
cmpContext->Abort();
10511055
}
1052-
else{
1056+
else
1057+
{
10531058
cmpContext->Release();
10541059
}
1060+
}
10551061

10561062
return ret;
10571063
}
@@ -1216,6 +1222,7 @@ void CScriptArray::Sort(asUINT index, asUINT count, bool asc)
12161222
}
12171223

12181224
if( cmpContext )
1225+
{
12191226
if( isNested )
12201227
{
12211228
asEContextState state = cmpContext->GetState();
@@ -1226,6 +1233,7 @@ void CScriptArray::Sort(asUINT index, asUINT count, bool asc)
12261233
else{
12271234
cmpContext->Release();
12281235
}
1236+
}
12291237
}
12301238

12311239
// internal

Sources/AngelScript/addons/scriptbuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int CScriptBuilder::LoadScriptSection(const char *filename)
166166

167167
// Determine size of the file
168168
fseek(f, 0, SEEK_END);
169-
int len = ftell(f);
169+
int len = static_cast<int> (ftell(f));
170170
fseek(f, 0, SEEK_SET);
171171

172172
// On Win32 it is possible to do the following instead

Sources/AngelScript/addons/scriptdictionary.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ CScriptArray* CScriptDictionary::GetKeys() const
307307
for( it = dict.begin(); it != dict.end(); it++ )
308308
{
309309
current++;
310-
*(string*)array->At(current) = it->first;
310+
*(string*)array->At(static_cast<asUINT> (current)) = it->first;
311311
}
312312

313313
return array;

Sources/AngelScript/source/as_gc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int asCGarbageCollector::GetObjectInGC(asUINT idx, asUINT *seqNbr, void **obj, a
151151

152152
ENTERCRITICALSECTION(gcCritical);
153153
asSObjTypePair *o = 0;
154-
asUINT newObjs = gcNewObjects.GetLength();
154+
asUINT newObjs = static_cast<asUINT>(gcNewObjects.GetLength());
155155
if( idx < newObjs )
156156
o = &gcNewObjects[idx];
157157
else if( idx < gcOldObjects.GetLength() + newObjs )

Sources/AngelScript/source/as_restore.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ int asCReader::ReadInner()
300300
engine->WriteMessage("", 0, 0, asMSGTYPE_ERROR, TXT_GLOBAL_VARS_NOT_ALLOWED);
301301
error = true;
302302
}
303-
module->scriptGlobals.Allocate(count, 0);
303+
module->scriptGlobals.Allocate((unsigned int) count, 0);
304304
for( i = 0; i < count && !error; ++i )
305305
{
306306
ReadGlobalProperty();

Sources/Audio/ALDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ namespace spades {
124124
al::qalGenBuffers(1, &handle);
125125
ALCheckError();
126126
al::qalBufferData(handle, alFormat,
127-
bytes.data(), bytes.size(),
127+
bytes.data(), (ALuint) bytes.size(),
128128
audioStream->GetSamplingFrequency());
129129
ALCheckError();
130130

Sources/Client/Client.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ namespace spades {
179179
// initialize player view objects
180180
clientPlayers.resize(world->GetNumPlayerSlots());
181181
for(size_t i = 0; i < world->GetNumPlayerSlots(); i++) {
182-
Player *p = world->GetPlayer(i);
182+
Player *p = world->GetPlayer(static_cast<unsigned int> (i));
183183
if(p){
184184
clientPlayers[i] = new ClientPlayer(p, this);
185185
}else{
@@ -721,7 +721,7 @@ namespace spades {
721721
if(nextId >= static_cast<int>(world->GetNumPlayerSlots()))
722722
nextId = 0;
723723
if(nextId < 0)
724-
nextId = world->GetNumPlayerSlots() - 1;
724+
nextId = static_cast<int> (world->GetNumPlayerSlots() - 1);
725725

726726
Player *p = world->GetPlayer(nextId);
727727
if(p == nullptr)

Sources/Client/Client_Scene.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ namespace spades {
538538
Player *p = world->GetLocalPlayer();
539539

540540
for(size_t i = 0; i < world->GetNumPlayerSlots(); i++)
541-
if(world->GetPlayer(i)){
541+
if(world->GetPlayer(static_cast<unsigned int>(i))){
542542
SPAssert(clientPlayers[i]);
543543
clientPlayers[i]->AddToScene();
544544
}

Sources/Client/HitTestDebugger.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace spades {
101101
// fit FoV to include all possibly hit players
102102
float range = 0.2f;
103103
for(std::size_t i = 0; i < world->GetNumPlayerSlots(); i++) {
104-
auto *p = world->GetPlayer(i);
104+
auto *p = world->GetPlayer(static_cast<unsigned int> (i));
105105
if(!p) continue;
106106
if(p == localPlayer) continue;
107107
if(p->GetTeamId() == localPlayer->GetTeamId()) continue;
@@ -203,7 +203,7 @@ namespace spades {
203203
};
204204

205205
for(std::size_t i = 0; i < numPlayers; i++) {
206-
auto *p = world->GetPlayer(i);
206+
auto *p = world->GetPlayer(static_cast<unsigned int> (i));
207207
if(!p) continue;
208208
if(p == localPlayer) continue;
209209
if(!p->IsAlive()) continue;
@@ -214,7 +214,7 @@ namespace spades {
214214
auto hitboxes = p->GetHitBoxes();
215215
PlayerHit hit;
216216
{
217-
auto it = hits.find(i);
217+
auto it = hits.find(static_cast<int> (i));
218218
if(it != hits.end()) {
219219
hit = it->second;
220220
}

Sources/Client/NetClient.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ namespace spades {
740740
if((int)cg_protocolVersion == 4)
741741
bytesPerEntry++;
742742

743-
int entries = reader.GetData().size() / bytesPerEntry;
743+
int entries = static_cast<int> (reader.GetData().size() / bytesPerEntry);
744744
for(int i = 0; i < entries; i++){
745745
int idx = i;
746746
if((int)cg_protocolVersion == 4)
@@ -1143,7 +1143,7 @@ namespace spades {
11431143

11441144

11451145
if(p){
1146-
p->UsedBlocks(cells.size());
1146+
p->UsedBlocks(static_cast<int> (cells.size()));
11471147
client->PlayerCreatedBlock(p);
11481148
}
11491149
}

Sources/Client/PaletteView.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ namespace spades {
166166
if((sel == i) != (phase == 1))
167167
continue;
168168

169-
int row = i / 8;
170-
int col = i % 8;
169+
int row = static_cast<int> (i / 8);
170+
int col = static_cast<int> (i % 8);
171171

172172
bool selected = sel == i;
173173

Sources/Core/DeflateStream.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace spades {
8888
SPRaise("State is invalid");
8989
}
9090

91-
zstream.avail_in = buffer.size();
91+
zstream.avail_in = (uint) buffer.size();
9292
zstream.next_in = (Bytef*)buffer.data();
9393

9494
do{
@@ -203,7 +203,7 @@ namespace spades {
203203
inputBuffer[i] = nextbuffer[i];
204204
readSize = baseStream->Read(inputBuffer + nextbuffer.size(), readSize);
205205
readSize += nextbuffer.size();
206-
zstream.avail_in = readSize;
206+
zstream.avail_in = (uint) readSize;
207207
zstream.next_in = (Bytef*)inputBuffer;
208208

209209
do{

Sources/Core/Math.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ namespace spades {
373373
}
374374

375375
IntVector3 Floor() const{
376-
return IntVector3::Make((long)floorf(x),
377-
(long)floorf(y),
378-
(long)floorf(z));
376+
return IntVector3::Make((int) floorf(x),
377+
(int) floorf(y),
378+
(int) floorf(z));
379379
}
380380
};
381381

Sources/Core/PngWriter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace {
3030
unsigned WriteCallback(void* input, std::size_t size, std::size_t numel, void* user_ptr) {
3131
auto stream = static_cast<spades::IStream*>(user_ptr);
3232
stream->Write(input, size * numel);
33-
return size * numel;
33+
return static_cast<unsigned> (size * numel);
3434
}
3535
}
3636

Sources/Core/SdlImageReader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace spades {
9898
std::string str;
9999
public:
100100
StringSdlRWops(std::string s):str(s) {
101-
op = SDL_RWFromConstMem(str.data(), str.size());
101+
op = SDL_RWFromConstMem(str.data(), (int) str.size());
102102
}
103103
~StringSdlRWops() {
104104
SDL_RWclose(op);

Sources/Core/Strings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ namespace spades {
829829
tk = ReadToken();
830830
if(tk.first == TokenType::Indexer) {
831831
try {
832-
directiveIdx = std::stol(tk.second);
832+
directiveIdx = static_cast<int> (std::stol(tk.second));
833833
currentMsgText[directiveIdx] = std::string();
834834
}catch(...){
835835
SPRaise("Integer parse error of '%s' at line %d", tk.second.c_str(), line);

Sources/Core/Strings.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,13 @@ namespace spades {
241241
template<> std::string ToString<Vector4>(const Vector4& v);
242242
template<> std::string ToString<IntVector3>(const IntVector3& v);
243243

244+
// `CheckPlural` converts the given value to an integer for plural form identification.
245+
// Let's ignore huge numbers for now...
244246
template<class ...T> int CheckPlural(T... args) { return 1; }
245247
template<class ...T> int CheckPlural(int v, T... args) { return v; }
246-
template<class ...T> int CheckPlural(long v, T... args) { return v; }
248+
template<class ...T> int CheckPlural(long v, T... args) { return static_cast<int> (v); }
247249
template<class ...T> int CheckPlural(unsigned int v, T... args) { return v; }
248-
template<class ...T> int CheckPlural(unsigned long v, T... args) { return v; }
250+
template<class ...T> int CheckPlural(unsigned long v, T... args) { return static_cast<int> (v); }
249251
template<class ...T> int CheckPlural(short v, T... args) { return v; }
250252
template<class ...T> int CheckPlural(unsigned short v, T... args) { return v; }
251253
template<class ...T> int CheckPlural(char v, T... args) { return v; }

Sources/Core/Thread.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include "Mutex.h"
2424
#include "IRunnable.h"
25+
#include "../Imports/SDL.h"
2526

2627
namespace spades {
2728

@@ -30,7 +31,7 @@ namespace spades {
3031
Mutex lock;
3132
IRunnable *runnable;
3233
bool volatile autoDelete;
33-
unsigned int volatile threadId;
34+
SDL_threadID volatile threadId;
3435

3536
static int InternalRunner(void *);
3637
void Quited();

Sources/Core/ZipFileSystem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace spades {
109109
SPADES_MARK_FUNCTION();
110110
size_t outBytes;
111111
if(streaming){
112-
int out = unzReadCurrentFile(zip, buf, bytes);
112+
int out = unzReadCurrentFile(zip, buf, (uint) bytes);
113113
if(out < 0){
114114
SPRaise("Unzip error: 0x%08x", bytes);
115115
}

Sources/Core/jpge.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ class cfile_stream : public output_stream
942942

943943
uint get_size() const
944944
{
945-
return m_pFile ? ftell(m_pFile) : 0;
945+
return m_pFile ? (uint) ftell(m_pFile) : 0;
946946
}
947947
};
948948

Sources/Core/pnglite.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ static int png_read_ihdr(png_t* png)
167167
#if DO_CRC_CHECKS
168168
file_read_ul(png, &orig_crc);
169169

170-
calc_crc = crc32(0L, 0, 0);
171-
calc_crc = crc32(calc_crc, ihdr, 13+4);
170+
calc_crc = (unsigned) crc32(0L, 0, 0);
171+
calc_crc = (unsigned) crc32(calc_crc, ihdr, 13+4);
172172

173173
if(orig_crc != calc_crc)
174174
return PNG_CRC_ERROR;
@@ -220,8 +220,8 @@ static int png_write_ihdr(png_t* png)
220220

221221
file_write(png, ihdr, 1, 13+4);
222222

223-
crc = crc32(0L, 0, 0);
224-
crc = crc32(crc, ihdr, 13+4);
223+
crc = (unsigned) crc32(0L, 0, 0);
224+
crc = (unsigned) crc32(crc, ihdr, 13+4);
225225

226226
file_write_ul(png, crc);
227227

@@ -481,7 +481,7 @@ static int png_write_idats(png_t* png, unsigned char* data)
481481
unsigned long written;
482482
unsigned long crc;
483483
unsigned size = png->width * png->height * png->bpp + png->height;
484-
unsigned chunk_size = compressBound(size);
484+
unsigned chunk_size = (unsigned) compressBound(size);
485485

486486
(void)png_init_deflate;
487487
(void)png_end_deflate;
@@ -494,16 +494,16 @@ static int png_write_idats(png_t* png, unsigned char* data)
494494
compress(chunk+4, &written, data, size);
495495

496496
crc = crc32(0L, Z_NULL, 0);
497-
crc = crc32(crc, chunk, written+4);
498-
set_ul(chunk+written+4, crc);
499-
file_write_ul(png, written);
497+
crc = crc32(crc, chunk, (unsigned) written + 4);
498+
set_ul(chunk + written + 4, (unsigned) crc);
499+
file_write_ul(png, (unsigned) written);
500500
file_write(png, chunk, 1, written+8);
501501
png_free(chunk);
502502

503503
file_write_ul(png, 0);
504504
file_write(png, "IEND", 1, 4);
505505
crc = crc32(0L, (const unsigned char *)"IEND", 4);
506-
file_write_ul(png, crc);
506+
file_write_ul(png, (unsigned) crc);
507507

508508
return PNG_NO_ERROR;
509509
}
@@ -536,9 +536,9 @@ static int png_read_idat(png_t* png, unsigned length)
536536
}
537537

538538
#if DO_CRC_CHECKS
539-
calc_crc = crc32(0L, Z_NULL, 0);
540-
calc_crc = crc32(calc_crc, (unsigned char*)"IDAT", 4);
541-
calc_crc = crc32(calc_crc, (unsigned char*)png->readbuf, length);
539+
calc_crc = (unsigned) crc32(0L, Z_NULL, 0);
540+
calc_crc = (unsigned) crc32(calc_crc, (unsigned char*)"IDAT", 4);
541+
calc_crc = (unsigned) crc32(calc_crc, (unsigned char*)png->readbuf, length);
542542

543543
file_read_ul(png, &orig_crc);
544544

0 commit comments

Comments
 (0)