#include <stdexcept>
MD5::MD5() :
+ buffer(),
+ digest(),
finalized()
{
init();
void MD5::update(std::istream& stream) {
uint8_t buffer_[1024];
- int len;
while (stream.good()) {
stream.read((char*)buffer_, 1024); // note that return value of read is unusable.
- len=stream.gcount();
+ int len = stream.gcount();
update(buffer_, len);
}
}
void MD5::update(std::ifstream& stream) {
uint8_t buffer_[1024];
- int len;
while (stream.good()) {
stream.read((char*)buffer_, 1024); // note that return value of read is unusable.
- len=stream.gcount();
+ int len = stream.gcount();
update(buffer_, len);
}
}
return readsize;
char *tmp = (char*)buffer;
- size_t i;
- char c;
- for (i = 0; i < readsize / 2; i++)
+ for (size_t i = 0; i < readsize / 2; i++)
{
- c = tmp[2*i];
+ char c = tmp[2*i];
tmp[2*i] = tmp[2*i+1];
tmp[2*i+1] = c;
}
- buffer = tmp;
+ *buffer = tmp;
#endif
return readsize;
void
Yeti::draw_hit_points(DrawingContext& context)
{
- int i;
-
if (hud_head)
{
context.push_transform();
context.set_translation(Vector(0, 0));
- for (i = 0; i < hit_points; ++i)
+ for (int i = 0; i < hit_points; ++i)
{
context.draw_surface(hud_head, Vector(BORDER_X + (i * hud_head->get_width()), BORDER_Y + 1), LAYER_FOREGROUND1);
}
i != sector->gameobjects.end(); ++i) {
YetiStalactite* stalactite = dynamic_cast<YetiStalactite*>(i->get());
if(stalactite && stalactite->is_hanging()) {
- float distancex;
if (hit_points >= 3) {
// drop stalactites within 3 of player, going out with each jump
- distancex = fabsf(stalactite->get_bbox().get_middle().x - player->get_bbox().get_middle().x);
+ float distancex = fabsf(stalactite->get_bbox().get_middle().x - player->get_bbox().get_middle().x);
if(distancex < stomp_count*32) {
stalactite->start_shaking();
}
{
float segment_width = bg_rect.get_width() / m_buttons.size();
float button_width = segment_width;
- float button_height = 24.0f;
Vector pos(bg_rect.p1.x + segment_width/2.0f + i * segment_width,
bg_rect.p2.y - 12);
if (i == m_selected_button)
{
+ float button_height = 24.0f;
float blink = (sinf(real_time * M_PI * 1.0f)/2.0f + 0.5f) * 0.5f + 0.25f;
ctx.draw_filled_rect(Rectf(Vector(pos.x - button_width/2, pos.y - button_height/2),
Vector(pos.x + button_width/2, pos.y + button_height/2)).grown(2.0f),
bufend(),
bufpos(),
c(),
+ token_string(),
token_length()
{
// trigger a refill of the buffer
#include "util/reader.hpp"
AmbientSound::AmbientSound(const Reader& lisp) :
- name(),
position(),
dimension(),
sample(),
}
AmbientSound::AmbientSound(Vector pos, float factor, float bias, float vol, std::string file) :
- name(),
position(),
dimension(),
sample(file),
virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
private:
- std::string name; /**< user-defined name for use in scripts or empty string if not scriptable */
Vector position;
Vector dimension;
//Create rainsplash
if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)){
bool vertical = (col == 2);
- int splash_x, splash_y;
if (!vertical) { //check if collision happened from above
+ int splash_x, splash_y; // move outside if statement when
+ // uncommenting the else statement below.
splash_x = int(particle->pos.x);
splash_y = int(particle->pos.y) - (int(particle->pos.y) % 32) + 32;
Sector::current()->add_object(std::make_shared<RainSplash>(Vector(splash_x, splash_y),vertical));
#include <assert.h>
IFileStreambuf::IFileStreambuf(const std::string& filename) :
+ buf(),
file()
{
// check this as PHYSFS seems to be buggy and still returns a
// Print the datadir searchpath to stdout, one path per
// line. Then exit. Intended for use by the supertux-editor.
char **sp;
- size_t sp_index;
sp = PHYSFS_getSearchPath();
if (sp)
- for (sp_index = 0; sp[sp_index]; sp_index++)
+ for (size_t sp_index = 0; sp[sp_index]; sp_index++)
std::cout << sp[sp_index] << std::endl;
PHYSFS_freeList(sp);
}
// split line into list of args
std::vector<std::string> args;
- size_t start = 0;
size_t end = 0;
while (1) {
- start = s.find_first_not_of(" ,", end);
+ size_t start = s.find_first_not_of(" ,", end);
end = s.find_first_of(" ,", start);
if (start == s.npos) break;
args.push_back(s.substr(start, end-start));
std::stringstream ss;
ss << _("Level target time") << ": " << Statistics::time_to_string(level->target_time);
context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color);
- py += static_cast<int>(Resources::normal_font->get_height());
}
}
assert(!m_screen_stack.empty());
static Uint32 fps_ticks = SDL_GetTicks();
- static int frame_count = 0;
m_screen_stack.back()->draw(context);
m_menu_manager->draw(context);
/* Calculate frames per second */
if (g_config->show_fps)
{
+ static int frame_count = 0;
++frame_count;
if (SDL_GetTicks() - fps_ticks >= 500)
update_game_objects();
- if(solid_tilemaps.size() < 1) { log_warning << "sector '" << name << "' does not contain a solid tile layer." << std::endl; }
+ if(solid_tilemaps.empty()) { log_warning << "sector '" << name << "' does not contain a solid tile layer." << std::endl; }
fix_old_tiles();
if(!camera) {
update_game_objects();
- if(solid_tilemaps.size() < 1) { log_warning << "sector '" << name << "' does not contain a solid tile layer." << std::endl; }
+ if(solid_tilemaps.empty()) { log_warning << "sector '" << name << "' does not contain a solid tile layer." << std::endl; }
fix_old_tiles();
update_game_objects();
#include "video/color.hpp"
#include "video/surface_ptr.hpp"
-namespace lisp { class Writer; }
namespace lisp { class Lisp; }
class DrawingContext;
break;
case TEXT:
{
- const TextRequest* textrequest = (TextRequest*) request.request_data;
+ const TextRequest* textrequest = static_cast<TextRequest*>(request.request_data);
textrequest->font->draw(&renderer, textrequest->text, request.pos,
textrequest->alignment, request.drawing_effect, request.color, request.alpha);
}
break;
case TEXT:
{
- const TextRequest* textrequest = (TextRequest*) request.request_data;
+ const TextRequest* textrequest = static_cast<TextRequest*>(request.request_data);
textrequest->font->draw(&renderer, textrequest->text, request.pos,
textrequest->alignment, request.drawing_effect, request.color, request.alpha);
}
GLLightmap::get_light(const DrawingRequest& request) const
{
const GetLightRequest* getlightrequest
- = (GetLightRequest*) request.request_data;
+ = static_cast<GetLightRequest*>(request.request_data);
float pixels[3];
for( int i = 0; i<3; i++)
GLPainter::draw_surface_part(const DrawingRequest& request)
{
const SurfacePartRequest* surfacepartrequest
- = (SurfacePartRequest*) request.request_data;
+ = static_cast<SurfacePartRequest*>(request.request_data);
const Surface* surface = surfacepartrequest->surface;
std::shared_ptr<GLTexture> gltexture = std::dynamic_pointer_cast<GLTexture>(surface->get_texture());
GLSurfaceData *surface_data = reinterpret_cast<GLSurfaceData *>(surface->get_surface_data());
GLPainter::draw_gradient(const DrawingRequest& request)
{
const GradientRequest* gradientrequest
- = (GradientRequest*) request.request_data;
+ = static_cast<GradientRequest*>(request.request_data);
const Color& top = gradientrequest->top;
const Color& bottom = gradientrequest->bottom;
GLPainter::draw_filled_rect(const DrawingRequest& request)
{
const FillRectRequest* fillrectrequest
- = (FillRectRequest*) request.request_data;
+ = static_cast<FillRectRequest*>(request.request_data);
glDisable(GL_TEXTURE_2D);
glColor4f(fillrectrequest->color.red, fillrectrequest->color.green,
void
GLPainter::draw_inverse_ellipse(const DrawingRequest& request)
{
- const InverseEllipseRequest* ellipse = (InverseEllipseRequest*)request.request_data;
+ const InverseEllipseRequest* ellipse = static_cast<InverseEllipseRequest*> (request.request_data);
glDisable(GL_TEXTURE_2D);
glColor4f(ellipse->color.red, ellipse->color.green,
SDLPainter::draw_surface_part(SDL_Renderer* renderer, const DrawingRequest& request)
{
//FIXME: support parameters request.blend
- const SurfacePartRequest* surface = (const SurfacePartRequest*) request.request_data;
- const SurfacePartRequest* surfacepartrequest = (SurfacePartRequest*) request.request_data;
+ const SurfacePartRequest* surface = static_cast<const SurfacePartRequest*>(request.request_data);
+ const SurfacePartRequest* surfacepartrequest = static_cast<SurfacePartRequest*>(request.request_data);
std::shared_ptr<SDLTexture> sdltexture = std::dynamic_pointer_cast<SDLTexture>(surface->surface->get_texture());
SDLPainter::draw_gradient(SDL_Renderer* renderer, const DrawingRequest& request)
{
const GradientRequest* gradientrequest
- = (GradientRequest*) request.request_data;
+ = static_cast<GradientRequest*>(request.request_data);
const Color& top = gradientrequest->top;
const Color& bottom = gradientrequest->bottom;
SDLPainter::draw_filled_rect(SDL_Renderer* renderer, const DrawingRequest& request)
{
const FillRectRequest* fillrectrequest
- = (FillRectRequest*) request.request_data;
+ = static_cast<FillRectRequest*>(request.request_data);
SDL_Rect rect;
rect.x = request.pos.x;
void
SDLPainter::draw_inverse_ellipse(SDL_Renderer* renderer, const DrawingRequest& request)
{
- const InverseEllipseRequest* ellipse = (InverseEllipseRequest*)request.request_data;
+ const InverseEllipseRequest* ellipse = static_cast<InverseEllipseRequest*>(request.request_data);
float x = request.pos.x;
float w = ellipse->size.x;
SDLSurfacePtr image(SDL_CreateRGBSurface(0, 1024, 1024, 8, 0, 0, 0, 0));
if (!image)
{
- throw err;
+ throw;
}
else
{