mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Fix some warnings
This commit is contained in:
@@ -27,6 +27,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define INT8_MAX 0x7F
|
||||||
|
#define UINT8_MAX 0xFF
|
||||||
|
#define INT16_MAX 0x7FFF
|
||||||
|
#define UINT16_MAX 0xFFFF
|
||||||
|
#define INT32_MAX 0x7FFFFFFF
|
||||||
|
#define UINT32_MAX 0xFFFFFFFF
|
||||||
|
#define INT64_MAX 0x7FFFFFFFFFFFFFFF
|
||||||
|
#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
// Blame Microsoft
|
// Blame Microsoft
|
||||||
|
|||||||
@@ -22,12 +22,13 @@
|
|||||||
|
|
||||||
// STD
|
// STD
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
namespace filesystem
|
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)
|
: data(new char[size]), size(size), filename(filename)
|
||||||
{
|
{
|
||||||
if (filename.rfind('.') != std::string::npos)
|
if (filename.rfind('.') != std::string::npos)
|
||||||
@@ -44,9 +45,15 @@ namespace filesystem
|
|||||||
return (void*)data;
|
return (void*)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FileData::getSize() const
|
// TODO: Enable this
|
||||||
|
/*uint64 FileData::getSize() const
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int FileData::getSize() const
|
||||||
|
{
|
||||||
|
return size > INT_MAX ? INT_MAX : (int) size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string & FileData::getFilename() const
|
const std::string & FileData::getFilename() const
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <common/Data.h>
|
#include <common/Data.h>
|
||||||
#include <common/StringMap.h>
|
#include <common/StringMap.h>
|
||||||
|
#include <common/int.h>
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,7 @@ namespace filesystem
|
|||||||
char * data;
|
char * data;
|
||||||
|
|
||||||
// Size of the data.
|
// Size of the data.
|
||||||
unsigned int size;
|
uint64 size;
|
||||||
|
|
||||||
// The filename used for error purposes.
|
// The filename used for error purposes.
|
||||||
std::string filename;
|
std::string filename;
|
||||||
@@ -55,12 +56,14 @@ namespace filesystem
|
|||||||
DECODE_MAX_ENUM
|
DECODE_MAX_ENUM
|
||||||
}; // Decoder
|
}; // Decoder
|
||||||
|
|
||||||
FileData(unsigned int size, const std::string & filename);
|
FileData(uint64 size, const std::string & filename);
|
||||||
|
|
||||||
virtual ~FileData();
|
virtual ~FileData();
|
||||||
|
|
||||||
// Implements Data.
|
// Implements Data.
|
||||||
void * getData() const;
|
void * getData() const;
|
||||||
|
//TODO: Enable this
|
||||||
|
//uint64 getSize() const;
|
||||||
int getSize() const;
|
int getSize() const;
|
||||||
|
|
||||||
const std::string & getFilename() const;
|
const std::string & getFilename() const;
|
||||||
@@ -79,4 +82,4 @@ namespace filesystem
|
|||||||
} // filesystem
|
} // filesystem
|
||||||
} // love
|
} // love
|
||||||
|
|
||||||
#endif // LOVE_FILESYSTEM_FILE_DATA_H
|
#endif // LOVE_FILESYSTEM_FILE_DATA_H
|
||||||
|
|||||||
@@ -139,6 +139,8 @@ namespace physfs
|
|||||||
int64 max = (int64)PHYSFS_fileLength(file);
|
int64 max = (int64)PHYSFS_fileLength(file);
|
||||||
size = (size == ALL) ? max : size;
|
size = (size == ALL) ? max : size;
|
||||||
size = (size > max) ? 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);
|
int64 read = (int64)PHYSFS_read(file, dst, 1, size);
|
||||||
|
|
||||||
@@ -153,8 +155,11 @@ namespace physfs
|
|||||||
if (file == 0)
|
if (file == 0)
|
||||||
throw love::Exception("Could not write to file. File not open.");
|
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.
|
// 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.
|
// Check that correct amount of data was written.
|
||||||
if (written != size)
|
if (written != size)
|
||||||
@@ -174,8 +179,8 @@ namespace physfs
|
|||||||
// It zigs, we zag.
|
// It zigs, we zag.
|
||||||
inline bool test_eof(File * that, PHYSFS_File *)
|
inline bool test_eof(File * that, PHYSFS_File *)
|
||||||
{
|
{
|
||||||
int pos = that->tell();
|
int64 pos = that->tell();
|
||||||
int size = that->getSize();
|
int64 size = that->getSize();
|
||||||
return pos == -1 || size == -1 || pos >= size;
|
return pos == -1 || size == -1 || pos >= size;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -481,14 +481,14 @@ namespace physfs
|
|||||||
|
|
||||||
// Find the next newline.
|
// Find the next newline.
|
||||||
// pos must be at the start of the line we're trying to find.
|
// 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 newline = -1;
|
||||||
int totalread = 0;
|
int totalread = 0;
|
||||||
|
|
||||||
while (!file->eof())
|
while (!file->eof())
|
||||||
{
|
{
|
||||||
int current = file->tell();
|
int64 current = file->tell();
|
||||||
int read = file->read(buf, bufsize);
|
int64 read = file->read(buf, bufsize);
|
||||||
totalread += read;
|
totalread += read;
|
||||||
|
|
||||||
if (read < 0)
|
if (read < 0)
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace physfs
|
|||||||
File * file = luax_checkfile(L, 1);
|
File * file = luax_checkfile(L, 1);
|
||||||
Data * d = 0;
|
Data * d = 0;
|
||||||
|
|
||||||
int64 size = (int64)luaL_optnumber(L, 2, file->getSize());
|
int64 size = (int64)luaL_optnumber(L, 2, (lua_Number) file->getSize());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -267,11 +267,11 @@ namespace opengl
|
|||||||
// on wordwrap, push line to line buffer and clear string builder
|
// on wordwrap, push line to line buffer and clear string builder
|
||||||
if (width >= wrap && oldwidth > 0)
|
if (width >= wrap && oldwidth > 0)
|
||||||
{
|
{
|
||||||
int realw = width;
|
int realw = (int) width;
|
||||||
lines_to_draw.push_back( string_builder.str() );
|
lines_to_draw.push_back( string_builder.str() );
|
||||||
string_builder.str( "" );
|
string_builder.str( "" );
|
||||||
width = static_cast<float>(getWidth( word ));
|
width = static_cast<float>(getWidth( word ));
|
||||||
realw -= width;
|
realw -= (int) width;
|
||||||
if (realw > maxw)
|
if (realw > maxw)
|
||||||
maxw = realw;
|
maxw = realw;
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ namespace opengl
|
|||||||
}
|
}
|
||||||
// push last line
|
// push last line
|
||||||
if (width > maxw)
|
if (width > maxw)
|
||||||
maxw = width;
|
maxw = (int) width;
|
||||||
lines_to_draw.push_back( string_builder.str() );
|
lines_to_draw.push_back( string_builder.str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -775,10 +775,10 @@ namespace opengl
|
|||||||
if (overdraw_top && overdraw_bottom)
|
if (overdraw_top && overdraw_bottom)
|
||||||
{
|
{
|
||||||
overdraw_top[pos] = vertices[pos];
|
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] = 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
|
// get line vertex boundaries
|
||||||
// if not looping, extend the line at the beginning, else use last point as `p'
|
// if not looping, extend the line at the beginning, else use last point as `p'
|
||||||
float halfwidth = lineWidth/2.0f;
|
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]);
|
r = Vector(coords[0], coords[1]);
|
||||||
if (!looping)
|
if (!looping)
|
||||||
q = r * 2 - Vector(coords[2], coords[3]);
|
q = r * 2 - Vector(coords[2], coords[3]);
|
||||||
@@ -837,10 +837,10 @@ namespace opengl
|
|||||||
// odd indices point to outer vertices => alpha = 0.
|
// odd indices point to outer vertices => alpha = 0.
|
||||||
Colorf tmp;
|
Colorf tmp;
|
||||||
glGetFloatv(GL_CURRENT_COLOR, (GLfloat*)(&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];
|
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] = color;
|
||||||
colors[i].a *= int(i%2 == 0); // avoids branching. equiv to colors[i].a *= (i%2==0) ? 1 : 0;
|
colors[i].a *= int(i%2 == 0); // avoids branching. equiv to colors[i].a *= (i%2==0) ? 1 : 0;
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ namespace opengl
|
|||||||
|
|
||||||
bool Image::hasNpot()
|
bool Image::hasNpot()
|
||||||
{
|
{
|
||||||
return GLEE_ARB_texture_non_power_of_two;
|
return GLEE_ARB_texture_non_power_of_two != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ namespace opengl
|
|||||||
for (size_t i = 0; i < NUM_VERTICES; ++i)
|
for (size_t i = 0; i < NUM_VERTICES; ++i)
|
||||||
{
|
{
|
||||||
if (x)
|
if (x)
|
||||||
vertices[i].s = 1.0 - vertices[i].s;
|
vertices[i].s = 1.0f - vertices[i].s;
|
||||||
if (y)
|
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);
|
float radius = (float)luaL_checknumber(L, 4);
|
||||||
int points;
|
int points;
|
||||||
if (lua_isnoneornil(L, 5))
|
if (lua_isnoneornil(L, 5))
|
||||||
points = radius > 10 ? radius : 10;
|
points = radius > 10 ? (int) (radius) : 10;
|
||||||
else
|
else
|
||||||
points = luaL_checkint(L, 5);
|
points = luaL_checkint(L, 5);
|
||||||
|
|
||||||
@@ -1041,7 +1041,7 @@ namespace opengl
|
|||||||
float angle2 = (float)luaL_checknumber(L, 6);
|
float angle2 = (float)luaL_checknumber(L, 6);
|
||||||
int points;
|
int points;
|
||||||
if (lua_isnoneornil(L, 7))
|
if (lua_isnoneornil(L, 7))
|
||||||
points = radius > 10 ? radius : 10;
|
points = radius > 10 ? (int) (radius) : 10;
|
||||||
else
|
else
|
||||||
points = luaL_checkint(L, 7);
|
points = luaL_checkint(L, 7);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user