Fix some warnings

This commit is contained in:
Bart van Strien
2011-12-27 21:25:06 +01:00
parent a855a01f02
commit 864c800e10
11 changed files with 49 additions and 25 deletions
+9 -2
View File
@@ -22,12 +22,13 @@
// STD
#include <iostream>
#include <climits>
namespace love
{
namespace filesystem
{
FileData::FileData(unsigned int size, const std::string & filename)
FileData::FileData(uint64 size, const std::string & filename)
: data(new char[size]), size(size), filename(filename)
{
if (filename.rfind('.') != std::string::npos)
@@ -44,9 +45,15 @@ namespace filesystem
return (void*)data;
}
int FileData::getSize() const
// TODO: Enable this
/*uint64 FileData::getSize() const
{
return size;
}*/
int FileData::getSize() const
{
return size > INT_MAX ? INT_MAX : (int) size;
}
const std::string & FileData::getFilename() const
+6 -3
View File
@@ -25,6 +25,7 @@
#include <string>
#include <common/Data.h>
#include <common/StringMap.h>
#include <common/int.h>
namespace love
{
@@ -38,7 +39,7 @@ namespace filesystem
char * data;
// Size of the data.
unsigned int size;
uint64 size;
// The filename used for error purposes.
std::string filename;
@@ -55,12 +56,14 @@ namespace filesystem
DECODE_MAX_ENUM
}; // Decoder
FileData(unsigned int size, const std::string & filename);
FileData(uint64 size, const std::string & filename);
virtual ~FileData();
// Implements Data.
void * getData() const;
//TODO: Enable this
//uint64 getSize() const;
int getSize() const;
const std::string & getFilename() const;
@@ -79,4 +82,4 @@ namespace filesystem
} // filesystem
} // love
#endif // LOVE_FILESYSTEM_FILE_DATA_H
#endif // LOVE_FILESYSTEM_FILE_DATA_H
+8 -3
View File
@@ -139,6 +139,8 @@ namespace physfs
int64 max = (int64)PHYSFS_fileLength(file);
size = (size == ALL) ? max : size;
size = (size > max) ? max : size;
// Sadly, we'll have to clamp to 32 bits here
size = (size > UINT32_MAX) ? UINT32_MAX : size;
int64 read = (int64)PHYSFS_read(file, dst, 1, size);
@@ -153,8 +155,11 @@ namespace physfs
if (file == 0)
throw love::Exception("Could not write to file. File not open.");
// Another clamp, for the time being.
size = (size > UINT32_MAX) ? UINT32_MAX : size;
// Try to write.
int written = static_cast<int64>(PHYSFS_write(file, data, 1, size));
int64 written = static_cast<int64>(PHYSFS_write(file, data, 1, size));
// Check that correct amount of data was written.
if (written != size)
@@ -174,8 +179,8 @@ namespace physfs
// It zigs, we zag.
inline bool test_eof(File * that, PHYSFS_File *)
{
int pos = that->tell();
int size = that->getSize();
int64 pos = that->tell();
int64 size = that->getSize();
return pos == -1 || size == -1 || pos >= size;
}
#else
+3 -3
View File
@@ -481,14 +481,14 @@ namespace physfs
// Find the next newline.
// pos must be at the start of the line we're trying to find.
int pos = file->tell();
int64 pos = file->tell();
int newline = -1;
int totalread = 0;
while (!file->eof())
{
int current = file->tell();
int read = file->read(buf, bufsize);
int64 current = file->tell();
int64 read = file->read(buf, bufsize);
totalread += read;
if (read < 0)
+1 -1
View File
@@ -81,7 +81,7 @@ namespace physfs
File * file = luax_checkfile(L, 1);
Data * d = 0;
int64 size = (int64)luaL_optnumber(L, 2, file->getSize());
int64 size = (int64)luaL_optnumber(L, 2, (lua_Number) file->getSize());
try
{
+3 -3
View File
@@ -267,11 +267,11 @@ namespace opengl
// on wordwrap, push line to line buffer and clear string builder
if (width >= wrap && oldwidth > 0)
{
int realw = width;
int realw = (int) width;
lines_to_draw.push_back( string_builder.str() );
string_builder.str( "" );
width = static_cast<float>(getWidth( word ));
realw -= width;
realw -= (int) width;
if (realw > maxw)
maxw = realw;
}
@@ -281,7 +281,7 @@ namespace opengl
}
// push last line
if (width > maxw)
maxw = width;
maxw = (int) width;
lines_to_draw.push_back( string_builder.str() );
}
+5 -5
View File
@@ -775,10 +775,10 @@ namespace opengl
if (overdraw_top && overdraw_bottom)
{
overdraw_top[pos] = vertices[pos];
overdraw_top[pos+1] = vertices[pos] * halo + q * (1. - halo);
overdraw_top[pos+1] = vertices[pos] * halo + q * (1.f - halo);
overdraw_bottom[pos] = vertices[pos+1];
overdraw_bottom[pos+1] = vertices[pos+1] * halo + q * (1. - halo);
overdraw_bottom[pos+1] = vertices[pos+1] * halo + q * (1.f - halo);
}
}
@@ -800,7 +800,7 @@ namespace opengl
// get line vertex boundaries
// if not looping, extend the line at the beginning, else use last point as `p'
float halfwidth = lineWidth/2.0f;
float halo = 1. + 1./halfwidth; // XXX: customizable?
float halo = 1.f + 1.f/halfwidth; // XXX: customizable?
r = Vector(coords[0], coords[1]);
if (!looping)
q = r * 2 - Vector(coords[2], coords[3]);
@@ -837,10 +837,10 @@ namespace opengl
// odd indices point to outer vertices => alpha = 0.
Colorf tmp;
glGetFloatv(GL_CURRENT_COLOR, (GLfloat*)(&tmp));
Color color(tmp.r * 255.0f, tmp.g * 255.0f, tmp.b * 255.0f, tmp.a * 255.0f);
Color color((unsigned char) (tmp.r * 255.0f), (unsigned char) (tmp.g * 255.0f), (unsigned char) (tmp.b * 255.0f), (unsigned char) (tmp.a * 255.0f));
Color *colors = new Color[count];
for (int i = 0; i < count; ++i)
for (unsigned int i = 0; i < count; ++i)
{
colors[i] = color;
colors[i].a *= int(i%2 == 0); // avoids branching. equiv to colors[i].a *= (i%2==0) ? 1 : 0;
+1 -1
View File
@@ -389,7 +389,7 @@ namespace opengl
bool Image::hasNpot()
{
return GLEE_ARB_texture_non_power_of_two;
return GLEE_ARB_texture_non_power_of_two != 0;
}
} // opengl
+2 -2
View File
@@ -108,9 +108,9 @@ namespace opengl
for (size_t i = 0; i < NUM_VERTICES; ++i)
{
if (x)
vertices[i].s = 1.0 - vertices[i].s;
vertices[i].s = 1.0f - vertices[i].s;
if (y)
vertices[i].t = 1.0 - vertices[i].t;
vertices[i].t = 1.0f - vertices[i].t;
}
}
@@ -1019,7 +1019,7 @@ namespace opengl
float radius = (float)luaL_checknumber(L, 4);
int points;
if (lua_isnoneornil(L, 5))
points = radius > 10 ? radius : 10;
points = radius > 10 ? (int) (radius) : 10;
else
points = luaL_checkint(L, 5);
@@ -1041,7 +1041,7 @@ namespace opengl
float angle2 = (float)luaL_checknumber(L, 6);
int points;
if (lua_isnoneornil(L, 7))
points = radius > 10 ? radius : 10;
points = radius > 10 ? (int) (radius) : 10;
else
points = luaL_checkint(L, 7);