ULTIMA8: Fixing compiler warnings

This commit is contained in:
Paul Gilbert 2020-02-17 21:30:36 -08:00
parent d47abaeb50
commit 16379e7856
12 changed files with 112 additions and 114 deletions

View File

@ -63,8 +63,8 @@ public:
typedef const T const_reference;
vector() : Common::Array<T>() {}
vector(size_t size) : Common::Array<T>() {
Common::Array<T>::reserve(size);
vector(size_t newSize) : Common::Array<T>() {
Common::Array<T>::reserve(newSize);
}
typename Common::Array<T>::iterator erase(typename Common::Array<T>::iterator pos) {

View File

@ -389,7 +389,7 @@ bool INIFile::value(istring key, bool &ret) {
return true;
}
void INIFile::set(istring key, string value) {
void INIFile::set(istring key, string strValue) {
if (!stripRoot(key)) return;
istring s, k;
splitKey(key, s, k);
@ -404,22 +404,22 @@ void INIFile::set(istring key, string value) {
assert(section);
}
section->setKey(k, value);
section->setKey(k, strValue);
}
void INIFile::set(istring key, const char *value) {
string v = value;
void INIFile::set(istring key, const char *strValue) {
string v = strValue;
set(key, v);
}
void INIFile::set(istring key, int value) {
void INIFile::set(istring key, int intValue) {
char buf[32];
snprintf(buf, 32, "%d", value);
snprintf(buf, 32, "%d", intValue);
set(key, buf);
}
void INIFile::set(istring key, bool value) {
if (value)
void INIFile::set(istring key, bool boolValue) {
if (boolValue)
set(key, "true");
else
set(key, "false");

View File

@ -59,10 +59,10 @@ public:
bool value(istring key, bool &ret);
// set value
void set(istring key, Std::string value);
void set(istring key, const char *value);
void set(istring key, int value);
void set(istring key, bool value);
void set(istring key, Std::string strValue);
void set(istring key, const char *strValue);
void set(istring key, int intValue);
void set(istring key, bool boolValue);
// remove key
void unset(istring key);

View File

@ -65,11 +65,11 @@ struct SKFEvent {
static const int FADESTEPS = 16; // HACK: half speed
SKFPlayer::SKFPlayer(RawArchive *movie, int width, int height, bool _introMusicHack)
SKFPlayer::SKFPlayer(RawArchive *movie, int width, int height, bool introMusicHack)
: _width(width), _height(height), _skf(movie),
_curFrame(0), _curObject(0), _curAction(0), _curEvent(0), _playing(false),
_timer(0), _frameRate(15), _fadeColour(0), _fadeLevel(0), _buffer(0), _subs(0),
_introMusicHack(_introMusicHack), _lastUpdate(0), _subtitleY(0) {
_introMusicHack(introMusicHack), _lastUpdate(0), _subtitleY(0) {
IDataSource *eventlist = _skf->get_datasource(0);
if (!eventlist) {
perr << "No eventlist found in SKF" << Std::endl;

View File

@ -36,16 +36,16 @@ DEFINE_RUNTIME_CLASSTYPE_CODE(ScalerGump, DesktopGump)
ScalerGump::ScalerGump(int32 x, int32 y, int32 width, int32 height) :
DesktopGump(x, y, width, height),
swidth1(width), sheight1(height), scaler1(0), buffer1(0),
swidth2(width), sheight2(height), scaler2(0), buffer2(0),
width(width), height(height) {
_swidth1(width), _sheight1(height), _scaler1(0), _buffer1(0),
_swidth2(width), _sheight2(height), _scaler2(0), _buffer2(0),
_width(width), _height(height) {
setupScaling();
}
ScalerGump::~ScalerGump() {
FORGET_OBJECT(buffer1);
FORGET_OBJECT(buffer2);
FORGET_OBJECT(_buffer1);
FORGET_OBJECT(_buffer2);
}
void ScalerGump::Paint(RenderSurface *surf, int32 lerp_factor, bool scaled) {
@ -58,28 +58,28 @@ void ScalerGump::Paint(RenderSurface *surf, int32 lerp_factor, bool scaled) {
if (IsHidden()) return;
// No scaling or filtering
if (!buffer1) {
if (!_buffer1) {
PaintChildren(surf, lerp_factor, scaled);
return;
}
// Render to texture
buffer1->BeginPainting();
PaintChildren(buffer1, lerp_factor, true);
buffer1->EndPainting();
_buffer1->BeginPainting();
PaintChildren(_buffer1, lerp_factor, true);
_buffer1->EndPainting();
if (!buffer2) {
DoScalerBlit(buffer1->GetSurfaceAsTexture(), swidth1, sheight1, surf, width, height, scaler1);
if (!_buffer2) {
DoScalerBlit(_buffer1->GetSurfaceAsTexture(), _swidth1, _sheight1, surf, _width, _height, _scaler1);
} else {
buffer2->BeginPainting();
DoScalerBlit(buffer1->GetSurfaceAsTexture(), swidth1, sheight1, buffer2, swidth2, sheight2, scaler1);
buffer2->EndPainting();
_buffer2->BeginPainting();
DoScalerBlit(_buffer1->GetSurfaceAsTexture(), _swidth1, _sheight1, _buffer2, _swidth2, _sheight2, _scaler1);
_buffer2->EndPainting();
DoScalerBlit(buffer2->GetSurfaceAsTexture(), swidth2, sheight2, surf, width, height, scaler2);
DoScalerBlit(_buffer2->GetSurfaceAsTexture(), _swidth2, _sheight2, surf, _width, _height, _scaler2);
}
int32 scalex = (width << 16) / swidth1;
int32 scaley = (height << 16) / sheight1;
int32 scalex = (_width << 16) / _swidth1;
int32 scaley = (_height << 16) / _sheight1;
// Iterate all children
Std::list<Gump *>::reverse_iterator it = _children.rbegin();
@ -133,26 +133,26 @@ void ScalerGump::DoScalerBlit(Texture *src, int swidth, int sheight, RenderSurfa
void ScalerGump::ParentToGump(int32 &px, int32 &py, PointRoundDir r) {
px -= _x;
px *= _dims.w;
if (px < 0 && r == ROUND_TOPLEFT) px -= (width - 1);
if (px > 0 && r == ROUND_BOTTOMRIGHT) px += (width - 1);
px /= width;
if (px < 0 && r == ROUND_TOPLEFT) px -= (_width - 1);
if (px > 0 && r == ROUND_BOTTOMRIGHT) px += (_width - 1);
px /= _width;
py -= _y;
py *= _dims.h;
if (py < 0 && r == ROUND_TOPLEFT) py -= (height - 1);
if (py > 0 && r == ROUND_BOTTOMRIGHT) py += (height - 1);
py /= height;
if (py < 0 && r == ROUND_TOPLEFT) py -= (_height - 1);
if (py > 0 && r == ROUND_BOTTOMRIGHT) py += (_height - 1);
py /= _height;
}
// Convert a gump point to parent relative point
void ScalerGump::GumpToParent(int32 &gx, int32 &gy, PointRoundDir r) {
gx *= width;
gx *= _width;
if (gx < 0 && r == ROUND_TOPLEFT) gx -= (_dims.w - 1);
if (gx > 0 && r == ROUND_BOTTOMRIGHT) gx += (_dims.w - 1);
gx /= _dims.w;
gx += _x;
gy *= height;
gy *= _height;
if (gy < 0 && r == ROUND_TOPLEFT) gy -= (_dims.h - 1);
if (gy > 0 && r == ROUND_BOTTOMRIGHT) gy += (_dims.h - 1);
gy /= _dims.h;
@ -164,8 +164,8 @@ void ScalerGump::RenderSurfaceChanged() {
Rect new_dims;
_parent->GetDims(new_dims);
width = new_dims.w;
height = new_dims.h;
_width = new_dims.w;
_height = new_dims.h;
setupScaling();
@ -173,66 +173,66 @@ void ScalerGump::RenderSurfaceChanged() {
}
void ScalerGump::setupScaling() {
FORGET_OBJECT(buffer1);
FORGET_OBJECT(buffer2);
FORGET_OBJECT(_buffer1);
FORGET_OBJECT(_buffer2);
swidth1 = 320;
sheight1 = 200;
swidth2 = 0;
sheight2 = 0;
_swidth1 = 320;
_sheight1 = 200;
_swidth2 = 0;
_sheight2 = 0;
const Scaler *point = &Ultima8Engine::get_instance()->point_scaler;
scaler1 = scaler2 = point;
_scaler1 = _scaler2 = point;
if (swidth1 < 0) swidth1 = -swidth1;
else if (swidth1 == 0) swidth1 = width;
else if (swidth1 < 100) swidth1 = width / swidth1;
if (_swidth1 < 0) _swidth1 = -_swidth1;
else if (_swidth1 == 0) _swidth1 = _width;
else if (_swidth1 < 100) _swidth1 = _width / _swidth1;
if (sheight1 < 0) sheight1 = -sheight1;
else if (sheight1 == 0) sheight1 = height;
else if (sheight1 < 100) sheight1 = height / sheight1;
if (_sheight1 < 0) _sheight1 = -_sheight1;
else if (_sheight1 == 0) _sheight1 = _height;
else if (_sheight1 < 100) _sheight1 = _height / _sheight1;
if (swidth2 < 0) swidth2 = -swidth2;
else if (swidth2 != 0 && swidth2 < 100) swidth2 = width / swidth2;
if (_swidth2 < 0) _swidth2 = -_swidth2;
else if (_swidth2 != 0 && _swidth2 < 100) _swidth2 = _width / _swidth2;
if (sheight2 < 0) sheight2 = -sheight2;
else if (sheight2 != 0 && sheight2 < 100) sheight2 = height / sheight2;
if (_sheight2 < 0) _sheight2 = -_sheight2;
else if (_sheight2 != 0 && _sheight2 < 100) _sheight2 = _height / _sheight2;
_dims.w = swidth1;
_dims.h = sheight1;
_dims.w = _swidth1;
_dims.h = _sheight1;
// We don't care, we are not going to support filters, at least not at the moment
if (swidth1 == width && sheight1 == height) return;
if (_swidth1 == _width && _sheight1 == _height) return;
buffer1 = RenderSurface::CreateSecondaryRenderSurface(swidth1, sheight1);
_buffer1 = RenderSurface::CreateSecondaryRenderSurface(_swidth1, _sheight1);
// scaler2's factor isn't set so auto detect
if (swidth2 == 0 || sheight2 == 0) {
// scaler 1 is arbitrary so scaler2 not required
if (scaler1->ScaleArbitrary()) return;
// _scaler2's factor isn't set so auto detect
if (_swidth2 == 0 || _sheight2 == 0) {
// scaler 1 is arbitrary so _scaler2 not required
if (_scaler1->ScaleArbitrary()) return;
swidth2 = swidth1 * 32;
sheight2 = sheight1 * 32;
_swidth2 = _swidth1 * 32;
_sheight2 = _sheight1 * 32;
for (int i = 31; i >= 0; i--) {
if (scaler1->ScaleBits() & (1 << i)) {
if (swidth2 > width || sheight2 > height) {
swidth2 = swidth1 * i;
sheight2 = sheight1 * i;
if (_scaler1->ScaleBits() & (1 << i)) {
if (_swidth2 > _width || _sheight2 > _height) {
_swidth2 = _swidth1 * i;
_sheight2 = _sheight1 * i;
}
}
}
}
// scaler2 is required
if (swidth2 != width || sheight2 != height) {
// _scaler2 is required
if (_swidth2 != _width || _sheight2 != _height) {
// Well almost, in this situation we code in DoScalerBlit to do this for us
// scaler2 not required
if (width == 640 && height == 480 &&
swidth2 == 640 && sheight2 == 400 &&
swidth1 == 320 && sheight2 == 200) {
// _scaler2 not required
if (_width == 640 && _height == 480 &&
_swidth2 == 640 && _sheight2 == 400 &&
_swidth1 == 320 && _sheight2 == 200) {
return;
}
buffer2 = RenderSurface::CreateSecondaryRenderSurface(swidth2, sheight2);
_buffer2 = RenderSurface::CreateSecondaryRenderSurface(_swidth2, _sheight2);
}
}

View File

@ -57,23 +57,23 @@ public:
PointRoundDir r = ROUND_TOPLEFT) override;
void GetScaledSize(int32 &sw, int32 &sh) const {
sw = swidth1;
sh = sheight1;
sw = _swidth1;
sh = _sheight1;
}
protected:
int swidth1;
int sheight1;
const Scaler *scaler1;
RenderSurface *buffer1;
int _swidth1;
int _sheight1;
const Scaler *_scaler1;
RenderSurface *_buffer1;
int swidth2;
int sheight2;
const Scaler *scaler2;
RenderSurface *buffer2;
int _swidth2;
int _sheight2;
const Scaler *_scaler2;
RenderSurface *_buffer2;
int32 width;
int32 height;
int32 _width;
int32 _height;
private:
void setupScaling();

View File

@ -47,8 +47,8 @@ static const int entryfont = 4;
DEFINE_RUNTIME_CLASSTYPE_CODE(U8SaveGump, Gump)
U8SaveGump::U8SaveGump(bool save, int page)
: Gump(0, 0, 5, 5), _save(save), _page(page) {
U8SaveGump::U8SaveGump(bool saveMode, int page)
: Gump(0, 0, 5, 5), _save(saveMode), _page(page) {
}
U8SaveGump::~U8SaveGump() {

View File

@ -54,8 +54,8 @@ ButtonWidget::ButtonWidget(int x, int y, Std::string txt, bool gamefont,
}
ButtonWidget::ButtonWidget(int x, int y, FrameID frame_up, FrameID frame_down,
bool _mouseOver, int32 layer)
: Gump(x, y, 5, 5, 0, 0, layer), _textWidget(0), _mouseOver(_mouseOver) {
bool mouseOver, int32 layer)
: Gump(x, y, 5, 5, 0, 0, layer), _textWidget(0), _mouseOver(mouseOver) {
_shapeUp = GameData::get_instance()->getShape(frame_up);
_shapeDown = GameData::get_instance()->getShape(frame_down);
_frameNumUp = frame_up._frameNum;

View File

@ -851,7 +851,7 @@ void Ultima8Engine::paint() {
if (_drawRenderStats) {
static long diff = 0;
static long fps = 0;
static long paint = 0;
static long paintGumps = 0;
char buf[256] = { '\0' };
FixedWidthFont *confont = con->GetConFont();
int v_offset = 0;
@ -859,7 +859,7 @@ void Ultima8Engine::paint() {
if (tdiff >= 250) {
diff = tdiff / t;
paint = tpaint / t;
paintGumps = tpaint / t;
fps = 1000 * t / tdiff;
t = 0;
tdiff = 0;
@ -870,7 +870,7 @@ void Ultima8Engine::paint() {
_screen->PrintTextFixed(confont, buf, dims.w - char_w * strlen(buf), v_offset);
v_offset += confont->_height;
snprintf(buf, 255, "Paint Gumps %li ms ", paint);
snprintf(buf, 255, "Paint Gumps %li ms ", paintGumps);
_screen->PrintTextFixed(confont, buf, dims.w - char_w * strlen(buf), v_offset);
v_offset += confont->_height;

View File

@ -697,16 +697,16 @@ void AvatarMoverProcess::turnToDirection(int direction) {
MainActor *avatar = getMainActor();
bool combatRun = (avatar->getActorFlags() & Actor::ACT_COMBATRUN) != 0;
int curdir = avatar->getDir();
int step;
int stepDelta;
bool combat = avatar->isInCombat() && !combatRun;
Animation::Sequence turnanim;
Animation::Sequence standanim = Animation::stand;
if ((curdir - direction + 8) % 8 < 4) {
step = -1;
stepDelta = -1;
turnanim = Animation::lookLeft;
} else {
step = 1;
stepDelta = 1;
turnanim = Animation::lookRight;
}
@ -728,7 +728,7 @@ void AvatarMoverProcess::turnToDirection(int direction) {
prevpid = animpid;
dir = (dir + step + 8) % 8;
dir = (dir + stepDelta + 8) % 8;
}
ProcId animpid = avatar->doAnim(standanim, direction);

View File

@ -46,8 +46,9 @@ bool QuickAvatarMoverProcess::_quarter = false;
QuickAvatarMoverProcess::QuickAvatarMoverProcess() : Process(1), _dx(0), _dy(0), _dz(0), _dir(0) {
}
QuickAvatarMoverProcess::QuickAvatarMoverProcess(int x, int y, int z, int _dir) : Process(1), _dx(x), _dy(y), _dz(z), _dir(_dir) {
QuickAvatarMoverProcess::terminateMover(_dir);
QuickAvatarMoverProcess::QuickAvatarMoverProcess(int x, int y, int z, int dir) : Process(1),
_dx(x), _dy(y), _dz(z), _dir(dir) {
QuickAvatarMoverProcess::terminateMover(dir);
assert(_dir < 6);
amp[_dir] = getPid();
}

View File

@ -21,16 +21,13 @@
*/
#include "ultima/ultima8/misc/pent_include.h"
#include "ultima/ultima8/world/gravity_process.h"
#include "ultima/ultima8/world/actors/actor.h"
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/world/current_map.h"
#include "ultima/ultima8/kernel/kernel.h"
#include "ultima/ultima8/world/world.h"
#include "ultima/ultima8/world/get_object.h"
#include "ultima/ultima8/filesys/idata_source.h"
#include "ultima/ultima8/filesys/odata_source.h"
@ -170,7 +167,7 @@ void GravityProcess::run() {
// If it landed on top of hititem and hititem is not land, the item
// should always bounce.
bool terminate = true;
bool termFlag = true;
Item *hititem = getItem(hititemid);
if (_zSpeed < -2 && !p_dynamic_cast<Actor *>(item)) {
#ifdef BOUNCE_DIAG
@ -181,7 +178,7 @@ void GravityProcess::run() {
if (!hititem->getShapeInfo()->is_land() || _zSpeed < -2 * _gravity) {
// Bounce!
terminate = false;
termFlag = false;
#ifdef BOUNCE_DIAG
int xspeedold = _xSpeed;
int yspeedold = _ySpeed;
@ -213,7 +210,7 @@ void GravityProcess::run() {
_xSpeed /= 4;
_ySpeed /= 4;
_zSpeed /= 2;
if (_zSpeed == 0) terminate = true;
if (_zSpeed == 0) termFlag = true;
} else {
// Not on land; this bounce approximates what's seen
// in the original U8 when Kilandra's daughters ghost
@ -229,7 +226,7 @@ void GravityProcess::run() {
<< _zSpeed << " heading " << headingold_r
<< " impulse " << heading_r << " ("
<< (_xSpeed - xspeedold) << "," << (_ySpeed - yspeedold)
<< "), terminate: " << terminate << Std::endl;
<< "), termFlag: " << termFlag << Std::endl;
#endif
} else {
#ifdef BOUNCE_DIAG
@ -245,7 +242,7 @@ void GravityProcess::run() {
<< "]: slow hit" << Std::endl;
#endif
}
if (terminate) {
if (termFlag) {
item->clearFlag(Item::FLG_BOUNCING);
terminateDeferred();
} else {