1
0
forked from 0ad/0ad

C++0x compatibility (fix narrowing conversions in initialisers; avoid ambiguity with std::next)

This was SVN commit r7739.
This commit is contained in:
Ykkrosh 2010-07-11 22:40:17 +00:00
parent 828efdde8f
commit 8c1deecdbe
4 changed files with 12 additions and 12 deletions

View File

@ -141,7 +141,7 @@ static LibError UniFont_reload(UniFont* f, const PIVFS& vfs, const VfsPath& base
GLfloat w = (GLfloat)Width / (GLfloat)TextureWidth;
GLfloat h = (GLfloat)Height / (GLfloat)TextureHeight;
GlyphData g = { u, -v, u+w, -v+h, OffsetX, -OffsetY, OffsetX+Width, -OffsetY+Height, Advance };
GlyphData g = { u, -v, u+w, -v+h, (i16)OffsetX, (i16)-OffsetY, (i16)(OffsetX+Width), (i16)(-OffsetY+Height), (i16)Advance };
(*f->glyphs)[(u16)Codepoint] = g;
}

View File

@ -131,7 +131,7 @@ static LibError bmp_encode(Tex* RESTRICT t, DynArray* RESTRICT da)
const size_t hdr_size = sizeof(BmpHeader); // needed for BITMAPFILEHEADER
const size_t img_size = tex_img_size(t);
const size_t file_size = hdr_size + img_size;
const long h = (t->flags & TEX_TOP_DOWN)? -(long)t->h : (long)t->h;
const i32 h = (t->flags & TEX_TOP_DOWN)? -(i32)t->h : (i32)t->h;
size_t transforms = t->flags;
transforms &= ~TEX_ORIENTATION; // no flip needed - we can set top-down bit.
@ -147,7 +147,7 @@ static LibError bmp_encode(Tex* RESTRICT t, DynArray* RESTRICT da)
// BITMAPINFOHEADER
40, // biSize = sizeof(BITMAPINFOHEADER)
(long)t->w,
(i32)t->w,
h,
1, // biPlanes
(u16)t->bpp,

View File

@ -1481,7 +1481,7 @@ void CCmpPathfinder::ComputeShortPath(const IObstructionTestFilter& filter, enti
vertexes[n].pred = curr.id;
if (n == GOAL_VERTEX_ID)
vertexes[n].p = npos; // remember the new best goal position
ShortPathPriorityQueue::Item t = { n, g + vertexes[n].h };
ShortPathPriorityQueue::Item t = { (u16)n, g + vertexes[n].h };
open.push(t);
// Remember the heuristically best vertex we've seen so far, in case we never actually reach the target

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2010 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////////////
template<typename T> T next(T x) { T t = x; return ++t; }
template<typename T> T next_it(T x) { T t = x; return ++t; }
template<typename T> void delete_fn(T* v) { delete v; }
@ -74,11 +74,11 @@ void CommandProc::Submit(Command* cmd)
{
// If some commands have been undone at the time we insert this new one,
// delete and remove them all.
std::for_each(next(m_CurrentCommand), m_Commands.end(), delete_fn<Command>);
m_Commands.erase(next(m_CurrentCommand), m_Commands.end());
assert(next(m_CurrentCommand) == m_Commands.end());
std::for_each(next_it(m_CurrentCommand), m_Commands.end(), delete_fn<Command>);
m_Commands.erase(next_it(m_CurrentCommand), m_Commands.end());
assert(next_it(m_CurrentCommand) == m_Commands.end());
m_CurrentCommand = m_Commands.insert(next(m_CurrentCommand), cmd);
m_CurrentCommand = m_Commands.insert(next_it(m_CurrentCommand), cmd);
(*m_CurrentCommand)->Do();
}
@ -94,7 +94,7 @@ void CommandProc::Undo()
void CommandProc::Redo()
{
if (next(m_CurrentCommand) != m_Commands.end())
if (next_it(m_CurrentCommand) != m_Commands.end())
{
++m_CurrentCommand;
(*m_CurrentCommand)->Redo();
@ -109,7 +109,7 @@ void CommandProc::Merge()
return;
}
if (next(m_CurrentCommand) != m_Commands.end())
if (next_it(m_CurrentCommand) != m_Commands.end())
{
debug_warn(L"Merge illogic: not at stack top");
return;