aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25')
-rw-r--r--engines/sword25/detection.cpp3
-rw-r--r--engines/sword25/detection_tables.h25
-rw-r--r--engines/sword25/fmv/theora_decoder.cpp11
-rw-r--r--engines/sword25/gfx/animationtemplateregistry.cpp2
-rw-r--r--engines/sword25/gfx/graphicengine.cpp2
-rw-r--r--engines/sword25/gfx/image/art.cpp71
-rw-r--r--engines/sword25/gfx/image/art.h5
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp5
-rw-r--r--engines/sword25/gfx/image/vectorimage.cpp4
-rw-r--r--engines/sword25/gfx/image/vectorimagerenderer.cpp7
-rw-r--r--engines/sword25/gfx/staticbitmap.cpp5
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.cpp33
-rw-r--r--engines/sword25/kernel/inputpersistenceblock.h7
-rw-r--r--engines/sword25/kernel/outputpersistenceblock.cpp12
-rw-r--r--engines/sword25/kernel/persistenceblock.h42
-rw-r--r--engines/sword25/kernel/persistenceservice.cpp30
-rw-r--r--engines/sword25/kernel/persistenceservice.h1
-rw-r--r--engines/sword25/math/regionregistry.cpp2
-rw-r--r--engines/sword25/package/packagemanager.h3
-rw-r--r--engines/sword25/sfx/soundengine.cpp152
-rw-r--r--engines/sword25/sfx/soundengine.h18
-rw-r--r--engines/sword25/sword25.cpp2
-rw-r--r--engines/sword25/util/lua/lapi.cpp1
-rw-r--r--engines/sword25/util/lua/lauxlib.cpp1
-rw-r--r--engines/sword25/util/lua/lauxlib.h2
-rw-r--r--engines/sword25/util/lua/lbaselib.cpp1
-rw-r--r--engines/sword25/util/lua/lcode.cpp1
-rw-r--r--engines/sword25/util/lua/ldblib.cpp1
-rw-r--r--engines/sword25/util/lua/ldebug.cpp1
-rw-r--r--engines/sword25/util/lua/ldo.cpp2
-rw-r--r--engines/sword25/util/lua/ldo.h1
-rw-r--r--engines/sword25/util/lua/lfunc.cpp1
-rw-r--r--engines/sword25/util/lua/lgc.cpp1
-rw-r--r--engines/sword25/util/lua/linit.cpp1
-rw-r--r--engines/sword25/util/lua/liolib.cpp1
-rw-r--r--engines/sword25/util/lua/llex.cpp3
-rw-r--r--engines/sword25/util/lua/lmathlib.cpp1
-rw-r--r--engines/sword25/util/lua/lmem.cpp1
-rw-r--r--engines/sword25/util/lua/lmem.h1
-rw-r--r--engines/sword25/util/lua/loadlib.cpp1
-rw-r--r--engines/sword25/util/lua/lobject.h1
-rw-r--r--engines/sword25/util/lua/lopcodes.cpp1
-rw-r--r--engines/sword25/util/lua/loslib.cpp1
-rw-r--r--engines/sword25/util/lua/lstate.cpp1
-rw-r--r--engines/sword25/util/lua/lstate.h1
-rw-r--r--engines/sword25/util/lua/lstring.cpp1
-rw-r--r--engines/sword25/util/lua/lstrlib.cpp1
-rw-r--r--engines/sword25/util/lua/ltablib.cpp1
-rw-r--r--engines/sword25/util/lua/ltm.cpp1
-rw-r--r--engines/sword25/util/lua/luaconf.h1
-rw-r--r--engines/sword25/util/lua/lvm.cpp1
-rw-r--r--engines/sword25/util/lua/lzio.cpp2
-rw-r--r--engines/sword25/util/pluto/CHANGELOG1
-rw-r--r--engines/sword25/util/pluto/FILEFORMAT2
-rw-r--r--engines/sword25/util/pluto/THANKS1
-rw-r--r--engines/sword25/util/pluto/plzio.cpp2
56 files changed, 301 insertions, 182 deletions
diff --git a/engines/sword25/detection.cpp b/engines/sword25/detection.cpp
index b2f5795663..06e4ba2a7d 100644
--- a/engines/sword25/detection.cpp
+++ b/engines/sword25/detection.cpp
@@ -44,7 +44,7 @@ static const char *directoryGlobs[] = {
class Sword25MetaEngine : public AdvancedMetaEngine {
public:
Sword25MetaEngine() : AdvancedMetaEngine(Sword25::gameDescriptions, sizeof(ADGameDescription), sword25Game) {
- _guioptions = Common::GUIO_NOMIDI;
+ _guioptions = GUIO1(GUIO_NOMIDI);
_maxScanDepth = 2;
_directoryGlobs = directoryGlobs;
}
@@ -99,4 +99,3 @@ SaveStateList Sword25MetaEngine::listSaves(const char *target) const {
#else
REGISTER_PLUGIN_STATIC(SWORD25, PLUGIN_TYPE_ENGINE, Sword25MetaEngine);
#endif
-
diff --git a/engines/sword25/detection_tables.h b/engines/sword25/detection_tables.h
index fe9e6e7934..5e0473dee5 100644
--- a/engines/sword25/detection_tables.h
+++ b/engines/sword25/detection_tables.h
@@ -22,11 +22,6 @@
namespace Sword25 {
-using Common::GUIO_NONE;
-using Common::GUIO_NOSPEECH;
-using Common::GUIO_NOSFX;
-using Common::GUIO_NOMUSIC;
-
static const ADGameDescription gameDescriptions[] = {
{
"sword25",
@@ -35,7 +30,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -44,7 +39,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::FR_FRA,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -53,7 +48,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::DE_DEU,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -62,7 +57,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::HU_HUN,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -71,7 +66,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::IT_ITA,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -80,7 +75,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::PL_POL,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -89,7 +84,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::PT_BRA,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -98,7 +93,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::RU_RUS,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
{
"sword25",
@@ -107,7 +102,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::ES_ESP,
Common::kPlatformUnknown,
ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
// Extracted version
@@ -121,7 +116,7 @@ static const ADGameDescription gameDescriptions[] = {
Common::EN_ANY,
Common::kPlatformUnknown,
GF_EXTRACTED | ADGF_UNSTABLE,
- Common::GUIO_NONE
+ GUIO1(GUIO_NONE)
},
AD_TABLE_END_MARKER
};
diff --git a/engines/sword25/fmv/theora_decoder.cpp b/engines/sword25/fmv/theora_decoder.cpp
index 098bd2c6b9..a7ebb5df8c 100644
--- a/engines/sword25/fmv/theora_decoder.cpp
+++ b/engines/sword25/fmv/theora_decoder.cpp
@@ -424,6 +424,12 @@ bool TheoraDecoder::queueAudio() {
if (!_audStream)
return false;
+ // An audio buffer should have been allocated (either in the constructor or after queuing the current buffer)
+ if (!_audiobuf) {
+ warning("[TheoraDecoder::queueAudio] Invalid audio buffer");
+ return false;
+ }
+
bool queuedAudio = false;
for (;;) {
@@ -454,6 +460,11 @@ bool TheoraDecoder::queueAudio() {
// The audio mixer is now responsible for the old audio buffer.
// We need to create a new one.
_audiobuf = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t));
+ if (!_audiobuf) {
+ warning("[TheoraDecoder::queueAudio] Cannot allocate memory for audio buffer");
+ return false;
+ }
+
_audiobufFill = 0;
queuedAudio = true;
}
diff --git a/engines/sword25/gfx/animationtemplateregistry.cpp b/engines/sword25/gfx/animationtemplateregistry.cpp
index 43c099c89d..8184b49eba 100644
--- a/engines/sword25/gfx/animationtemplateregistry.cpp
+++ b/engines/sword25/gfx/animationtemplateregistry.cpp
@@ -34,7 +34,9 @@
#include "sword25/gfx/animationtemplateregistry.h"
#include "sword25/gfx/animationtemplate.h"
+namespace Common {
DECLARE_SINGLETON(Sword25::AnimationTemplateRegistry);
+}
namespace Sword25 {
diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp
index 91133b9fd2..14ba032107 100644
--- a/engines/sword25/gfx/graphicengine.cpp
+++ b/engines/sword25/gfx/graphicengine.cpp
@@ -156,7 +156,7 @@ RenderObjectPtr<Panel> GraphicEngine::getMainPanel() {
}
void GraphicEngine::setVsync(bool vsync) {
- warning("STUB: SetVsync(%d)", vsync);
+ // ScummVM has no concept of VSync
}
bool GraphicEngine::getVsync() const {
diff --git a/engines/sword25/gfx/image/art.cpp b/engines/sword25/gfx/image/art.cpp
index 2df8bd4f3e..2ba102e779 100644
--- a/engines/sword25/gfx/image/art.cpp
+++ b/engines/sword25/gfx/image/art.cpp
@@ -151,6 +151,8 @@ ArtSVP *art_svp_from_vpath(ArtVpath *vpath) {
n_segs_max = 16;
svp = (ArtSVP *)malloc(sizeof(ArtSVP) +
(n_segs_max - 1) * sizeof(ArtSVPSeg));
+ if (!svp)
+ error("[art_svp_from_vpath] Cannot allocate memory");
dir = 0;
n_points = 0;
@@ -167,9 +169,14 @@ ArtSVP *art_svp_from_vpath(ArtVpath *vpath) {
if (points != NULL && n_points >= 2) {
if (n_segs == n_segs_max) {
n_segs_max <<= 1;
- svp = (ArtSVP *)realloc(svp, sizeof(ArtSVP) +
- (n_segs_max - 1) *
- sizeof(ArtSVPSeg));
+ ArtSVP *tmp = (ArtSVP *)realloc(svp, sizeof(ArtSVP) +
+ (n_segs_max - 1) *
+ sizeof(ArtSVPSeg));
+
+ if (!tmp)
+ error("Cannot reallocate memory in art_svp_from_vpath()");
+
+ svp = tmp;
}
svp->segs[n_segs].n_points = n_points;
svp->segs[n_segs].dir = (dir > 0);
@@ -204,9 +211,14 @@ ArtSVP *art_svp_from_vpath(ArtVpath *vpath) {
y = points[n_points - 1].y;
if (n_segs == n_segs_max) {
n_segs_max <<= 1;
- svp = (ArtSVP *)realloc(svp, sizeof(ArtSVP) +
- (n_segs_max - 1) *
- sizeof(ArtSVPSeg));
+ ArtSVP *tmp = (ArtSVP *)realloc(svp, sizeof(ArtSVP) +
+ (n_segs_max - 1) *
+ sizeof(ArtSVPSeg));
+
+ if (!tmp)
+ error("Cannot reallocate memory in art_svp_from_vpath()");
+
+ svp = tmp;
}
svp->segs[n_segs].n_points = n_points;
svp->segs[n_segs].dir = (dir > 0);
@@ -246,9 +258,14 @@ ArtSVP *art_svp_from_vpath(ArtVpath *vpath) {
if (n_points >= 2) {
if (n_segs == n_segs_max) {
n_segs_max <<= 1;
- svp = (ArtSVP *)realloc(svp, sizeof(ArtSVP) +
- (n_segs_max - 1) *
- sizeof(ArtSVPSeg));
+ ArtSVP *tmp = (ArtSVP *)realloc(svp, sizeof(ArtSVP) +
+ (n_segs_max - 1) *
+ sizeof(ArtSVPSeg));
+
+ if (!tmp)
+ error("Cannot reallocate memory in art_svp_from_vpath()");
+
+ svp = tmp;
}
svp->segs[n_segs].n_points = n_points;
svp->segs[n_segs].dir = (dir > 0);
@@ -1026,6 +1043,8 @@ struct _ArtPriPoint {
static ArtPriQ *art_pri_new(void) {
ArtPriQ *result = art_new(ArtPriQ, 1);
+ if (!result)
+ error("[art_pri_new] Cannot allocate memory");
result->n_items = 0;
result->n_items_max = 16;
@@ -1157,8 +1176,13 @@ static int art_svp_writer_rewind_add_segment(ArtSvpWriter *self, int wind_left,
(swr->n_segs_max - 1) *
sizeof(ArtSVPSeg));
swr->svp = svp;
- swr->n_points_max = art_renew(swr->n_points_max, int,
- swr->n_segs_max);
+ int *tmp = art_renew(swr->n_points_max, int,
+ swr->n_segs_max);
+
+ if (!tmp)
+ error("Cannot reallocate memory in art_svp_writer_rewind_add_segment()");
+
+ swr->n_points_max = tmp;
}
seg = &svp->segs[seg_num];
seg->n_points = 1;
@@ -1169,6 +1193,9 @@ static int art_svp_writer_rewind_add_segment(ArtSvpWriter *self, int wind_left,
seg->bbox.x1 = x;
seg->bbox.y1 = y;
seg->points = art_new(ArtPoint, init_n_points_max);
+ if (!seg->points)
+ error("[art_svp_writer_rewind_add_segment] Cannot allocate memory");
+
seg->points[0].x = x;
seg->points[0].y = y;
return seg_num;
@@ -1213,6 +1240,8 @@ ArtSVP *art_svp_writer_rewind_reap(ArtSvpWriter *self) {
ArtSvpWriter *art_svp_writer_rewind_new(ArtWindRule rule) {
ArtSvpWriterRewind *result = art_new(ArtSvpWriterRewind, 1);
+ if (!result)
+ error("[art_svp_writer_rewind_new] Cannot allocate memory");
result->super.add_segment = art_svp_writer_rewind_add_segment;
result->super.add_point = art_svp_writer_rewind_add_point;
@@ -1222,6 +1251,9 @@ ArtSvpWriter *art_svp_writer_rewind_new(ArtWindRule rule) {
result->n_segs_max = 16;
result->svp = (ArtSVP *)malloc(sizeof(ArtSVP) +
(result->n_segs_max - 1) * sizeof(ArtSVPSeg));
+ if (!result->svp)
+ error("[art_svp_writer_rewind_new] Cannot allocate memory");
+
result->svp->n_segs = 0;
result->n_points_max = art_new(int, result->n_segs_max);
@@ -1392,6 +1424,9 @@ static void art_svp_intersect_push_pt(ArtIntersectCtx *ctx, ArtActiveSeg *seg,
seg->y1 = y;
pri_pt = art_new(ArtPriPoint, 1);
+ if (!pri_pt)
+ error("[art_svp_intersect_push_pt] Cannot allocate memory");
+
pri_pt->x = x;
pri_pt->y = y;
pri_pt->user_data = seg;
@@ -1855,6 +1890,8 @@ static void art_svp_intersect_horiz(ArtIntersectCtx *ctx, ArtActiveSeg *seg,
return;
hs = art_new(ArtActiveSeg, 1);
+ if (!hs)
+ error("[art_svp_intersect_horiz] Cannot allocate memory");
hs->flags = ART_ACTIVE_FLAGS_DEL | (seg->flags & ART_ACTIVE_FLAGS_OUT);
if (seg->flags & ART_ACTIVE_FLAGS_OUT) {
@@ -1993,10 +2030,11 @@ static void art_svp_intersect_add_seg(ArtIntersectCtx *ctx, const ArtSVPSeg *in_
ArtActiveSeg *seg = art_new(ArtActiveSeg, 1);
ArtActiveSeg *test;
double x0, y0;
- ArtActiveSeg *beg_range;
ArtActiveSeg *last = NULL;
ArtActiveSeg *left, *right;
ArtPriPoint *pri_pt = art_new(ArtPriPoint, 1);
+ if (!pri_pt)
+ error("[art_svp_intersect_add_seg] Cannot allocate memory");
seg->flags = 0;
seg->in_seg = in_seg;
@@ -2019,7 +2057,6 @@ static void art_svp_intersect_add_seg(ArtIntersectCtx *ctx, const ArtSVPSeg *in_
x0 = in_seg->points[0].x;
y0 = in_seg->points[0].y;
- beg_range = NULL;
for (test = ctx->active_head; test != NULL; test = test->right) {
double d;
int test_bneg = test->flags & ART_ACTIVE_FLAGS_BNEG;
@@ -2166,6 +2203,9 @@ void art_svp_intersector(const ArtSVP *in, ArtSvpWriter *out) {
return;
ctx = art_new(ArtIntersectCtx, 1);
+ if (!ctx)
+ error("[art_svp_intersector] Cannot allocate memory");
+
ctx->in = in;
ctx->out = out;
pq = art_pri_new();
@@ -2178,6 +2218,9 @@ void art_svp_intersector(const ArtSVP *in, ArtSvpWriter *out) {
ctx->in_curs = 0;
first_point = art_new(ArtPriPoint, 1);
+ if (!first_point)
+ error("[art_svp_intersector] Cannot allocate memory");
+
first_point->x = in->segs[0].points[0].x;
first_point->y = in->segs[0].points[0].y;
first_point->user_data = NULL;
@@ -2319,6 +2362,8 @@ static void art_svp_render_delete_active(int *active_segs, int j, int n_active_s
ArtSVPRenderAAIter *art_svp_render_aa_iter(const ArtSVP *svp,
int x0, int y0, int x1, int y1) {
ArtSVPRenderAAIter *iter = art_new(ArtSVPRenderAAIter, 1);
+ if (!iter)
+ error("[art_svp_render_aa_iter] Cannot allocate memory");
iter->svp = svp;
iter->y = y0;
diff --git a/engines/sword25/gfx/image/art.h b/engines/sword25/gfx/image/art.h
index bfeb31cc30..8c9c97bc57 100644
--- a/engines/sword25/gfx/image/art.h
+++ b/engines/sword25/gfx/image/art.h
@@ -51,10 +51,13 @@ namespace Sword25 {
#define art_expand(p, type, max) \
do { \
if(max) {\
- p = art_renew(p, type, max <<= 1); \
+ type *tmp = art_renew(p, type, max <<= 1); \
+ if (!tmp) error("Cannot reallocate memory for art data"); \
+ p = tmp; \
} else { \
max = 1; \
p = art_new(type, 1); \
+ if (!p) error("Cannot allocate memory for art data"); \
} \
} while (0)
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index f5f33d8e02..3b29b0333f 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -72,7 +72,10 @@ static byte *readSavegameThumbnail(const Common::String &filename, uint &fileSiz
// Seek to the actual PNG image
loadString(*file); // Marker (BS25SAVEGAME)
- loadString(*file); // Version
+ Common::String storedVersionID = loadString(*file); // Version
+ if (storedVersionID != "SCUMMVM1")
+ loadString(*file);
+
loadString(*file); // Description
uint32 compressedGamedataSize = atoi(loadString(*file).c_str());
loadString(*file); // Uncompressed game data size
diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp
index 9235ec2fcf..81f4fc2ad5 100644
--- a/engines/sword25/gfx/image/vectorimage.cpp
+++ b/engines/sword25/gfx/image/vectorimage.cpp
@@ -248,7 +248,7 @@ VectorImage::VectorImage(const byte *pFileData, uint fileSize, bool &success, co
}
// readout SWF size
- Common::Rect movieRect = flashRectToBSRect(bs);
+ flashRectToBSRect(bs);
// Get frame rate and frame count
/* uint32 frameRate = */
@@ -321,6 +321,8 @@ ArtBpath *VectorImage::storeBez(ArtBpath *bez, int lineStyle, int fillStyle0, in
bez[*bezNodes].code = ART_END;
ArtBpath *bez1 = art_new(ArtBpath, *bezNodes + 1);
+ if (!bez1)
+ error("[VectorImage::storeBez] Cannot allocate memory");
for (int i = 0; i <= *bezNodes; i++)
bez1[i] = bez[i];
diff --git a/engines/sword25/gfx/image/vectorimagerenderer.cpp b/engines/sword25/gfx/image/vectorimagerenderer.cpp
index 97dad3346d..6d4dc213f2 100644
--- a/engines/sword25/gfx/image/vectorimagerenderer.cpp
+++ b/engines/sword25/gfx/image/vectorimagerenderer.cpp
@@ -270,6 +270,9 @@ ArtVpath *art_vpath_cat(ArtVpath *a, ArtVpath *b) {
len_a = art_vpath_len(a);
len_b = art_vpath_len(b);
dest = art_new(ArtVpath, len_a + len_b + 1);
+ if (!dest)
+ error("[art_vpath_cat] Cannot allocate memory");
+
p = dest;
for (int i = 0; i < len_a; i++)
@@ -299,6 +302,8 @@ ArtVpath *art_vpath_reverse(ArtVpath *a) {
len = art_vpath_len(a);
dest = art_new(ArtVpath, len + 1);
+ if (!dest)
+ error("[art_vpath_reverse] Cannot allocate memory");
for (i = 0; i < len; i++) {
it = a[len - i - 1];
@@ -371,6 +376,8 @@ void drawBez(ArtBpath *bez1, ArtBpath *bez2, byte *buffer, int width, int height
int size = art_vpath_len(vec);
ArtVpath *vect = art_new(ArtVpath, size + 1);
+ if (!vect)
+ error("[drawBez] Cannot allocate memory");
int k;
for (k = 0; k < size; k++) {
diff --git a/engines/sword25/gfx/staticbitmap.cpp b/engines/sword25/gfx/staticbitmap.cpp
index 60ad94e20f..0ae07b36b5 100644
--- a/engines/sword25/gfx/staticbitmap.cpp
+++ b/engines/sword25/gfx/staticbitmap.cpp
@@ -170,7 +170,10 @@ bool StaticBitmap::unpersist(InputPersistenceBlock &reader) {
result &= Bitmap::unpersist(reader);
Common::String resourceFilename;
reader.readString(resourceFilename);
- result &= initBitmapResource(resourceFilename);
+ // We may not have saves, and we actually do not need to
+ // restore them. So do not even try to load them.
+ if (!resourceFilename.hasPrefix("/saves"))
+ result &= initBitmapResource(resourceFilename);
result &= RenderObject::unpersistChildren(reader);
diff --git a/engines/sword25/kernel/inputpersistenceblock.cpp b/engines/sword25/kernel/inputpersistenceblock.cpp
index c1cd771e39..cdce539c31 100644
--- a/engines/sword25/kernel/inputpersistenceblock.cpp
+++ b/engines/sword25/kernel/inputpersistenceblock.cpp
@@ -35,9 +35,10 @@
namespace Sword25 {
-InputPersistenceBlock::InputPersistenceBlock(const void *data, uint dataLength) :
+InputPersistenceBlock::InputPersistenceBlock(const void *data, uint dataLength, int version) :
_data(static_cast<const byte *>(data), dataLength),
- _errorState(NONE) {
+ _errorState(NONE),
+ _version(version) {
_iter = _data.begin();
}
@@ -54,8 +55,8 @@ void InputPersistenceBlock::read(int16 &value) {
void InputPersistenceBlock::read(signed int &value) {
if (checkMarker(SINT_MARKER)) {
- rawRead(&value, sizeof(signed int));
- value = convertEndianessFromStorageToSystem(value);
+ value = (int32)READ_LE_UINT32(_iter);
+ _iter += 4;
} else {
value = 0;
}
@@ -63,8 +64,8 @@ void InputPersistenceBlock::read(signed int &value) {
void InputPersistenceBlock::read(uint &value) {
if (checkMarker(UINT_MARKER)) {
- rawRead(&value, sizeof(uint));
- value = convertEndianessFromStorageToSystem(value);
+ value = READ_LE_UINT32(_iter);
+ _iter += 4;
} else {
value = 0;
}
@@ -72,8 +73,10 @@ void InputPersistenceBlock::read(uint &value) {
void InputPersistenceBlock::read(float &value) {
if (checkMarker(FLOAT_MARKER)) {
- rawRead(&value, sizeof(float));
- value = convertEndianessFromStorageToSystem(value);
+ uint32 tmp[1];
+ tmp[0] = READ_LE_UINT32(_iter);
+ value = ((float *)tmp)[0];
+ _iter += 4;
} else {
value = 0.0f;
}
@@ -81,12 +84,11 @@ void InputPersistenceBlock::read(float &value) {
void InputPersistenceBlock::read(bool &value) {
if (checkMarker(BOOL_MARKER)) {
- uint uintBool;
- rawRead(&uintBool, sizeof(float));
- uintBool = convertEndianessFromStorageToSystem(uintBool);
+ uint uintBool = READ_LE_UINT32(_iter);
+ _iter += 4;
value = uintBool == 0 ? false : true;
} else {
- value = 0.0f;
+ value = false;
}
}
@@ -116,13 +118,6 @@ void InputPersistenceBlock::readByteArray(Common::Array<byte> &value) {
}
}
-void InputPersistenceBlock::rawRead(void *destPtr, size_t size) {
- if (checkBlockSize(size)) {
- memcpy(destPtr, &*_iter, size);
- _iter += size;
- }
-}
-
bool InputPersistenceBlock::checkBlockSize(int size) {
if (_data.end() - _iter >= size) {
return true;
diff --git a/engines/sword25/kernel/inputpersistenceblock.h b/engines/sword25/kernel/inputpersistenceblock.h
index f643b06bc1..2518d7e32c 100644
--- a/engines/sword25/kernel/inputpersistenceblock.h
+++ b/engines/sword25/kernel/inputpersistenceblock.h
@@ -46,7 +46,7 @@ public:
OUT_OF_SYNC
};
- InputPersistenceBlock(const void *data, uint dataLength);
+ InputPersistenceBlock(const void *data, uint dataLength, int version);
virtual ~InputPersistenceBlock();
void read(int16 &value);
@@ -64,14 +64,17 @@ public:
return _errorState;
}
+ int getVersion() const { return _version; }
+
private:
bool checkMarker(byte marker);
bool checkBlockSize(int size);
- void rawRead(void *destPtr, size_t size);
Common::Array<byte> _data;
Common::Array<byte>::const_iterator _iter;
ErrorState _errorState;
+
+ int _version;
};
} // End of namespace Sword25
diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp
index cf28ea401f..e29d956e5f 100644
--- a/engines/sword25/kernel/outputpersistenceblock.cpp
+++ b/engines/sword25/kernel/outputpersistenceblock.cpp
@@ -43,19 +43,23 @@ OutputPersistenceBlock::OutputPersistenceBlock() {
void OutputPersistenceBlock::write(signed int value) {
writeMarker(SINT_MARKER);
- value = convertEndianessFromSystemToStorage(value);
+ value = TO_LE_32(value);
rawWrite(&value, sizeof(value));
}
void OutputPersistenceBlock::write(uint value) {
writeMarker(UINT_MARKER);
- value = convertEndianessFromSystemToStorage(value);
+ value = TO_LE_32(value);
rawWrite(&value, sizeof(value));
}
void OutputPersistenceBlock::write(float value) {
writeMarker(FLOAT_MARKER);
- value = convertEndianessFromSystemToStorage(value);
+ uint32 tmp[1];
+
+ ((float *)tmp)[0] = value;
+ tmp[0] = TO_LE_32(tmp[0]);
+
rawWrite(&value, sizeof(value));
}
@@ -63,7 +67,7 @@ void OutputPersistenceBlock::write(bool value) {
writeMarker(BOOL_MARKER);
uint uintBool = value ? 1 : 0;
- uintBool = convertEndianessFromSystemToStorage(uintBool);
+ uintBool = TO_LE_32(uintBool);
rawWrite(&uintBool, sizeof(uintBool));
}
diff --git a/engines/sword25/kernel/persistenceblock.h b/engines/sword25/kernel/persistenceblock.h
index d8440faa50..8ac3e84a41 100644
--- a/engines/sword25/kernel/persistenceblock.h
+++ b/engines/sword25/kernel/persistenceblock.h
@@ -64,48 +64,6 @@ protected:
BLOCK_MARKER
};
- // -----------------------------------------------------------------------------
- // Endianess Conversions
- // -----------------------------------------------------------------------------
- //
- // Everything is stored in Little Endian
- // Big Endian Systems will need to be byte swapped during both saving and reading of saved values
- //
-
- template<typename T>
- static T convertEndianessFromSystemToStorage(T value) {
- if (isBigEndian())
- reverseByteOrder(&value);
- return value;
- }
-
- template<typename T>
- static T convertEndianessFromStorageToSystem(T value) {
- if (isBigEndian())
- reverseByteOrder(&value);
- return value;
- }
-
-private:
- static bool isBigEndian() {
- uint dummy = 1;
- byte *dummyPtr = reinterpret_cast<byte *>(&dummy);
- return dummyPtr[0] == 0;
- }
-
- template<typename T>
- static void swap(T &one, T &two) {
- T temp = one;
- one = two;
- two = temp;
- }
-
- static void reverseByteOrder(void *ptr) {
- // Reverses the byte order of the 32-bit word pointed to by Ptr
- byte *charPtr = static_cast<byte *>(ptr);
- swap(charPtr[0], charPtr[3]);
- swap(charPtr[1], charPtr[2]);
- }
};
#define CTASSERT(ex) typedef char ctassert_type[(ex) ? 1 : -1]
diff --git a/engines/sword25/kernel/persistenceservice.cpp b/engines/sword25/kernel/persistenceservice.cpp
index c88360e031..27d669caa1 100644
--- a/engines/sword25/kernel/persistenceservice.cpp
+++ b/engines/sword25/kernel/persistenceservice.cpp
@@ -50,7 +50,9 @@ static const char *SAVEGAME_DIRECTORY = "saves";
static const char *FILE_MARKER = "BS25SAVEGAME";
static const uint SLOT_COUNT = 18;
static const uint FILE_COPY_BUFFER_SIZE = 1024 * 10;
-static const char *VERSIONID = "SCUMMVM1";
+static const char *VERSIONIDOLD = "SCUMMVM1";
+static const char *VERSIONID = "SCUMMVM2";
+static const int VERSIONNUM = 2;
#define MAX_SAVEGAME_SIZE 100
@@ -99,6 +101,7 @@ struct SavegameInformation {
bool isOccupied;
bool isCompatible;
Common::String description;
+ int version;
uint gamedataLength;
uint gamedataOffset;
uint gamedataUncompressedLength;
@@ -147,9 +150,15 @@ struct PersistenceService::Impl {
// Read in the header
Common::String storedMarker = loadString(file);
Common::String storedVersionID = loadString(file);
+ if (storedVersionID == VERSIONIDOLD) {
+ curSavegameInfo.version = 1;
+ } else {
+ Common::String versionNum = loadString(file);
+ curSavegameInfo.version = atoi(versionNum.c_str());
+ }
Common::String gameDescription = loadString(file);
- Common::String gameDataLength = loadString(file);
- curSavegameInfo.gamedataLength = atoi(gameDataLength.c_str());
+ Common::String gamedataLength = loadString(file);
+ curSavegameInfo.gamedataLength = atoi(gamedataLength.c_str());
Common::String gamedataUncompressedLength = loadString(file);
curSavegameInfo.gamedataUncompressedLength = atoi(gamedataUncompressedLength.c_str());
@@ -158,7 +167,7 @@ struct PersistenceService::Impl {
// The slot is marked as occupied.
curSavegameInfo.isOccupied = true;
// Check if the saved game is compatible with the current engine version.
- curSavegameInfo.isCompatible = (storedVersionID == Common::String(VERSIONID));
+ curSavegameInfo.isCompatible = (curSavegameInfo.version <= VERSIONNUM);
// Load the save game description.
curSavegameInfo.description = gameDescription;
// The offset to the stored save game data within the file.
@@ -242,6 +251,12 @@ Common::String &PersistenceService::getSavegameFilename(uint slotID) {
return result;
}
+int PersistenceService::getSavegameVersion(uint slotID) {
+ if (!checkslotID(slotID))
+ return -1;
+ return _impl->_savegameInformations[slotID].version;
+}
+
bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotFilename) {
// FIXME: This code is a hack which bypasses the savefile API,
// and should eventually be removed.
@@ -264,6 +279,11 @@ bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotF
file->writeString(VERSIONID);
file->writeByte(0);
+ char buf[20];
+ snprintf(buf, 20, "%d", VERSIONNUM);
+ file->writeString(buf);
+ file->writeByte(0);
+
TimeDate dt;
g_system->getTimeAndDate(dt);
file->writeString(formatTimestamp(dt));
@@ -385,7 +405,7 @@ bool PersistenceService::loadGame(uint slotID) {
memcpy(uncompressedDataBuffer, compressedDataBuffer, uncompressedBufferSize);
}
- InputPersistenceBlock reader(&uncompressedDataBuffer[0], curSavegameInfo.gamedataUncompressedLength);
+ InputPersistenceBlock reader(&uncompressedDataBuffer[0], curSavegameInfo.gamedataUncompressedLength, curSavegameInfo.version);
// Einzelne Engine-Module depersistieren.
bool success = true;
diff --git a/engines/sword25/kernel/persistenceservice.h b/engines/sword25/kernel/persistenceservice.h
index f73962892c..59e0a3661d 100644
--- a/engines/sword25/kernel/persistenceservice.h
+++ b/engines/sword25/kernel/persistenceservice.h
@@ -57,6 +57,7 @@ public:
void reloadSlots();
bool isSlotOccupied(uint slotID);
bool isSavegameCompatible(uint slotID);
+ int getSavegameVersion(uint slotID);
Common::String &getSavegameDescription(uint slotID);
Common::String &getSavegameFilename(uint slotID);
diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp
index dff8560205..68c360a5ee 100644
--- a/engines/sword25/math/regionregistry.cpp
+++ b/engines/sword25/math/regionregistry.cpp
@@ -34,7 +34,9 @@
#include "sword25/math/regionregistry.h"
#include "sword25/math/region.h"
+namespace Common {
DECLARE_SINGLETON(Sword25::RegionRegistry);
+}
namespace Sword25 {
diff --git a/engines/sword25/package/packagemanager.h b/engines/sword25/package/packagemanager.h
index c57c30636d..b0c6718008 100644
--- a/engines/sword25/package/packagemanager.h
+++ b/engines/sword25/package/packagemanager.h
@@ -141,6 +141,9 @@ public:
uint fileSize;
char *data = (char *)getFile(fileName, &fileSize);
char *result = (char *)malloc(fileSize + strlen(versionStr) + 1);
+ if (!result)
+ error("[PackageManager::getXmlFile] Cannot allocate memory");
+
strcpy(result, versionStr);
Common::copy(data, data + fileSize, result + strlen(versionStr));
result[fileSize + strlen(versionStr)] = '\0';
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp
index 9244137c25..78b2db19eb 100644
--- a/engines/sword25/sfx/soundengine.cpp
+++ b/engines/sword25/sfx/soundengine.cpp
@@ -33,6 +33,8 @@
#include "sword25/sfx/soundengine.h"
#include "sword25/package/packagemanager.h"
#include "sword25/kernel/resource.h"
+#include "sword25/kernel/inputpersistenceblock.h"
+#include "sword25/kernel/outputpersistenceblock.h"
#include "audio/decoders/vorbis.h"
@@ -61,6 +63,8 @@ SoundEngine::SoundEngine(Kernel *pKernel) : ResourceService(pKernel) {
_mixer = g_system->getMixer();
+ _maxHandleId = 1;
+
for (int i = 0; i < SOUND_HANDLES; i++)
_handles[i].type = kFreeHandle;
}
@@ -139,19 +143,24 @@ void SoundEngine::resumeLayer(uint layer) {
SndHandle *SoundEngine::getHandle(uint *id) {
- // NOTE: Index 0 means error. Thus we're not using it
- for (uint i = 1; i < SOUND_HANDLES; i++) {
+ for (uint i = 0; i < SOUND_HANDLES; i++) {
if (_handles[i].type != kFreeHandle && !_mixer->isSoundHandleActive(_handles[i].handle)) {
- debugC(kDebugSound, 5, "Handle %d has finished playing", i);
+ debugC(1, kDebugSound, "Handle %d has finished playing", _handles[i].id);
_handles[i].type = kFreeHandle;
}
}
- for (uint i = 1; i < SOUND_HANDLES; i++) {
+ for (uint i = 0; i < SOUND_HANDLES; i++) {
if (_handles[i].type == kFreeHandle) {
- debugC(kDebugSound, 5, "Allocated handle %d", i);
+ debugC(1, kDebugSound, "Allocated handle %d", _handles[i].id);
+ _handles[i].id = _maxHandleId;
+ _handles[i].type = kAllocatedHandle;
+
if (id)
- *id = i;
+ *id = _maxHandleId;
+
+ _maxHandleId++;
+
return &_handles[i];
}
}
@@ -161,6 +170,17 @@ SndHandle *SoundEngine::getHandle(uint *id) {
return NULL;
}
+SndHandle *SoundEngine::findHandle(uint id) {
+ for (uint i = 0; i < SOUND_HANDLES; i++) {
+ if (_handles[i].id == id)
+ return &_handles[i];
+ }
+
+ warning("Sound::findHandle(): Unknown handle");
+
+ return NULL;
+}
+
Audio::Mixer::SoundType getType(SoundEngine::SOUND_TYPES type) {
switch (type) {
case SoundEngine::MUSIC:
@@ -184,13 +204,27 @@ bool SoundEngine::playSound(const Common::String &fileName, SOUND_TYPES type, fl
return true;
}
-uint SoundEngine::playSoundEx(const Common::String &fileName, SOUND_TYPES type, float volume, float pan, bool loop, int loopStart, int loopEnd, uint layer) {
+uint SoundEngine::playSoundEx(const Common::String &fileName, SOUND_TYPES type, float volume, float pan, bool loop, int loopStart, int loopEnd, uint layer, uint handleId) {
Common::SeekableReadStream *in = Kernel::getInstance()->getPackage()->getStream(fileName);
#ifdef USE_VORBIS
Audio::SeekableAudioStream *stream = Audio::makeVorbisStream(in, DisposeAfterUse::YES);
#endif
- uint id;
- SndHandle *handle = getHandle(&id);
+ uint id = handleId;
+ SndHandle *handle;
+
+ if (handleId == 0x1337)
+ handle = getHandle(&id);
+ else
+ handle = &_handles[handleId];
+
+ handle->fileName = fileName;
+ handle->sndType = type;
+ handle->volume = volume;
+ handle->pan = pan;
+ handle->loop = loop;
+ handle->loopStart = loopStart;
+ handle->loopEnd = loopEnd;
+ handle->layer = layer;
debugC(1, kDebugSound, "SoundEngine::playSoundEx(%s, %d, %f, %f, %d, %d, %d, %d)", fileName.c_str(), type, volume, pan, loop, loopStart, loopEnd, layer);
@@ -202,43 +236,43 @@ uint SoundEngine::playSoundEx(const Common::String &fileName, SOUND_TYPES type,
}
void SoundEngine::setSoundVolume(uint handle, float volume) {
- assert(handle < SOUND_HANDLES);
-
debugC(1, kDebugSound, "SoundEngine::setSoundVolume(%d, %f)", handle, volume);
- _mixer->setChannelVolume(_handles[handle].handle, (byte)(volume * 255));
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle != NULL)
+ _mixer->setChannelVolume(sndHandle->handle, (byte)(volume * 255));
}
void SoundEngine::setSoundPanning(uint handle, float pan) {
- assert(handle < SOUND_HANDLES);
-
debugC(1, kDebugSound, "SoundEngine::setSoundPanning(%d, %f)", handle, pan);
- _mixer->setChannelBalance(_handles[handle].handle, (int8)(pan * 127));
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle != NULL)
+ _mixer->setChannelBalance(sndHandle->handle, (int8)(pan * 127));
}
void SoundEngine::pauseSound(uint handle) {
- assert(handle < SOUND_HANDLES);
-
debugC(1, kDebugSound, "SoundEngine::pauseSound(%d)", handle);
- _mixer->pauseHandle(_handles[handle].handle, true);
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle != NULL)
+ _mixer->pauseHandle(sndHandle->handle, true);
}
void SoundEngine::resumeSound(uint handle) {
- assert(handle < SOUND_HANDLES);
-
debugC(1, kDebugSound, "SoundEngine::resumeSound(%d)", handle);
- _mixer->pauseHandle(_handles[handle].handle, false);
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle != NULL)
+ _mixer->pauseHandle(sndHandle->handle, false);
}
void SoundEngine::stopSound(uint handle) {
- assert(handle < SOUND_HANDLES);
-
debugC(1, kDebugSound, "SoundEngine::stopSound(%d)", handle);
- _mixer->stopHandle(_handles[handle].handle);
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle != NULL)
+ _mixer->stopHandle(sndHandle->handle);
}
bool SoundEngine::isSoundPaused(uint handle) {
@@ -250,23 +284,30 @@ bool SoundEngine::isSoundPaused(uint handle) {
}
bool SoundEngine::isSoundPlaying(uint handle) {
- assert(handle < SOUND_HANDLES);
-
debugC(1, kDebugSound, "SoundEngine::isSoundPlaying(%d)", handle);
- return _mixer->isSoundHandleActive(_handles[handle].handle);
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle == NULL)
+ return false;
+ return _mixer->isSoundHandleActive(sndHandle->handle);
}
float SoundEngine::getSoundVolume(uint handle) {
debugC(1, kDebugSound, "SoundEngine::getSoundVolume(%d)", handle);
- return (float)_mixer->getChannelVolume(_handles[handle].handle) / 255.0;
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle == NULL)
+ return 0.f;
+ return (float)_mixer->getChannelVolume(sndHandle->handle) / 255.0;
}
float SoundEngine::getSoundPanning(uint handle) {
debugC(1, kDebugSound, "SoundEngine::getSoundPanning(%d)", handle);
- return (float)_mixer->getChannelBalance(_handles[handle].handle) / 127.0;
+ SndHandle* sndHandle = findHandle(handle);
+ if (sndHandle == NULL)
+ return 0.f;
+ return (float)_mixer->getChannelBalance(sndHandle->handle) / 127.0;
}
Resource *SoundEngine::loadResource(const Common::String &fileName) {
@@ -284,16 +325,61 @@ bool SoundEngine::canLoadResource(const Common::String &fileName) {
}
-bool SoundEngine::persist(OutputPersistenceBlock &writer) {
- warning("STUB: SoundEngine::persist()");
+ bool SoundEngine::persist(OutputPersistenceBlock &writer) {
+ writer.write(_maxHandleId);
+
+ for (uint i = 0; i < SOUND_HANDLES; i++) {
+ writer.write(_handles[i].id);
+
+ writer.writeString(_handles[i].fileName);
+ writer.write((int)_handles[i].sndType);
+ writer.write(_handles[i].volume);
+ writer.write(_handles[i].pan);
+ writer.write(_handles[i].loop);
+ writer.write(_handles[i].loopStart);
+ writer.write(_handles[i].loopEnd);
+ writer.write(_handles[i].layer);
+ }
return true;
}
bool SoundEngine::unpersist(InputPersistenceBlock &reader) {
- warning("STUB: SoundEngine::unpersist()");
+ _mixer->stopAll();
+
+ if (reader.getVersion() < 2)
+ return true;
+
+ reader.read(_maxHandleId);
+
+ for (uint i = 0; i < SOUND_HANDLES; i++) {
+ reader.read(_handles[i].id);
+
+ Common::String fileName;
+ int sndType;
+ float volume;
+ float pan;
+ bool loop;
+ int loopStart;
+ int loopEnd;
+ uint layer;
+
+ reader.readString(fileName);
+ reader.read(sndType);
+ reader.read(volume);
+ reader.read(pan);
+ reader.read(loop);
+ reader.read(loopStart);
+ reader.read(loopEnd);
+ reader.read(layer);
+
+ if (reader.isGood()) {
+ playSoundEx(fileName, (SOUND_TYPES)sndType, volume, pan, loop, loopStart, loopEnd, layer, i);
+ } else
+ return false;
+ }
- return true;
+ return reader.isGood();
}
diff --git a/engines/sword25/sfx/soundengine.h b/engines/sword25/sfx/soundengine.h
index 4dbd475846..8132ec556e 100644
--- a/engines/sword25/sfx/soundengine.h
+++ b/engines/sword25/sfx/soundengine.h
@@ -58,13 +58,22 @@ namespace Sword25 {
enum sndHandleType {
kFreeHandle,
- kEffectHandle,
- kVoiceHandle
+ kAllocatedHandle
};
struct SndHandle {
Audio::SoundHandle handle;
sndHandleType type;
+ uint32 id;
+
+ Common::String fileName;
+ int sndType;
+ float volume;
+ float pan;
+ bool loop;
+ int loopStart;
+ int loopEnd;
+ uint layer;
};
@@ -176,7 +185,7 @@ public:
* @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
- uint playSoundEx(const Common::String &fileName, SOUND_TYPES type, float volume = 1.0f, float pan = 0.0f, bool loop = false, int loopStart = -1, int loopEnd = -1, uint layer = 0);
+ uint playSoundEx(const Common::String &fileName, SOUND_TYPES type, float volume = 1.0f, float pan = 0.0f, bool loop = false, int loopStart = -1, int loopEnd = -1, uint layer = 0, uint handleId = 0x1337);
/**
* Sets the volume of a playing sound
@@ -244,10 +253,13 @@ public:
private:
bool registerScriptBindings();
SndHandle *getHandle(uint *id);
+ SndHandle *findHandle(uint id);
private:
Audio::Mixer *_mixer;
SndHandle _handles[SOUND_HANDLES];
+
+ uint32 _maxHandleId;
};
} // End of namespace Sword25
diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp
index b111746c32..2201188052 100644
--- a/engines/sword25/sword25.cpp
+++ b/engines/sword25/sword25.cpp
@@ -50,7 +50,9 @@
#include "sword25/gfx/animationtemplateregistry.h" // Needed so we can destroy the singleton
#include "sword25/gfx/renderobjectregistry.h" // Needed so we can destroy the singleton
+namespace Common {
DECLARE_SINGLETON(Sword25::RenderObjectRegistry);
+}
#include "sword25/math/regionregistry.h" // Needed so we can destroy the singleton
namespace Sword25 {
diff --git a/engines/sword25/util/lua/lapi.cpp b/engines/sword25/util/lua/lapi.cpp
index ff25cfc653..b97e90012c 100644
--- a/engines/sword25/util/lua/lapi.cpp
+++ b/engines/sword25/util/lua/lapi.cpp
@@ -1074,4 +1074,3 @@ LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
lua_unlock(L);
return name;
}
-
diff --git a/engines/sword25/util/lua/lauxlib.cpp b/engines/sword25/util/lua/lauxlib.cpp
index 1261777315..116d19dfce 100644
--- a/engines/sword25/util/lua/lauxlib.cpp
+++ b/engines/sword25/util/lua/lauxlib.cpp
@@ -655,4 +655,3 @@ LUALIB_API lua_State *luaL_newstate (void) {
if (L) lua_atpanic(L, &panic);
return L;
}
-
diff --git a/engines/sword25/util/lua/lauxlib.h b/engines/sword25/util/lua/lauxlib.h
index d58f290527..d3c1d5ca35 100644
--- a/engines/sword25/util/lua/lauxlib.h
+++ b/engines/sword25/util/lua/lauxlib.h
@@ -170,5 +170,3 @@ LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
#define luaL_reg luaL_Reg
#endif
-
-
diff --git a/engines/sword25/util/lua/lbaselib.cpp b/engines/sword25/util/lua/lbaselib.cpp
index 5032e6322a..3f0b645164 100644
--- a/engines/sword25/util/lua/lbaselib.cpp
+++ b/engines/sword25/util/lua/lbaselib.cpp
@@ -651,4 +651,3 @@ LUALIB_API int luaopen_base (lua_State *L) {
luaL_register(L, LUA_COLIBNAME, co_funcs);
return 2;
}
-
diff --git a/engines/sword25/util/lua/lcode.cpp b/engines/sword25/util/lua/lcode.cpp
index 6e7e10017f..ead780d359 100644
--- a/engines/sword25/util/lua/lcode.cpp
+++ b/engines/sword25/util/lua/lcode.cpp
@@ -836,4 +836,3 @@ void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
}
fs->freereg = base + 1; /* free registers with list values */
}
-
diff --git a/engines/sword25/util/lua/ldblib.cpp b/engines/sword25/util/lua/ldblib.cpp
index 618e9a843f..e5cb8231c0 100644
--- a/engines/sword25/util/lua/ldblib.cpp
+++ b/engines/sword25/util/lua/ldblib.cpp
@@ -398,4 +398,3 @@ LUALIB_API int luaopen_debug (lua_State *L) {
luaL_register(L, LUA_DBLIBNAME, dblib);
return 1;
}
-
diff --git a/engines/sword25/util/lua/ldebug.cpp b/engines/sword25/util/lua/ldebug.cpp
index 85c492cc77..e89ae9cad5 100644
--- a/engines/sword25/util/lua/ldebug.cpp
+++ b/engines/sword25/util/lua/ldebug.cpp
@@ -619,4 +619,3 @@ void luaG_runerror (lua_State *L, const char *fmt, ...) {
va_end(argp);
luaG_errormsg(L);
}
-
diff --git a/engines/sword25/util/lua/ldo.cpp b/engines/sword25/util/lua/ldo.cpp
index 49e0881a45..5d9667f4f0 100644
--- a/engines/sword25/util/lua/ldo.cpp
+++ b/engines/sword25/util/lua/ldo.cpp
@@ -534,5 +534,3 @@ int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
luaZ_freebuffer(L, &p.buff);
return status;
}
-
-
diff --git a/engines/sword25/util/lua/ldo.h b/engines/sword25/util/lua/ldo.h
index 4c97134805..e57b08dec0 100644
--- a/engines/sword25/util/lua/ldo.h
+++ b/engines/sword25/util/lua/ldo.h
@@ -54,4 +54,3 @@ LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop);
#endif
-
diff --git a/engines/sword25/util/lua/lfunc.cpp b/engines/sword25/util/lua/lfunc.cpp
index ce7acf4e77..f8fa19e25a 100644
--- a/engines/sword25/util/lua/lfunc.cpp
+++ b/engines/sword25/util/lua/lfunc.cpp
@@ -171,4 +171,3 @@ const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
}
return NULL; /* not found */
}
-
diff --git a/engines/sword25/util/lua/lgc.cpp b/engines/sword25/util/lua/lgc.cpp
index 71e581ad30..54f7b548dd 100644
--- a/engines/sword25/util/lua/lgc.cpp
+++ b/engines/sword25/util/lua/lgc.cpp
@@ -708,4 +708,3 @@ void luaC_linkupval (lua_State *L, UpVal *uv) {
}
}
}
-
diff --git a/engines/sword25/util/lua/linit.cpp b/engines/sword25/util/lua/linit.cpp
index 93f41d0350..a01f28d1ff 100644
--- a/engines/sword25/util/lua/linit.cpp
+++ b/engines/sword25/util/lua/linit.cpp
@@ -35,4 +35,3 @@ LUALIB_API void luaL_openlibs (lua_State *L) {
lua_call(L, 1, 0);
}
}
-
diff --git a/engines/sword25/util/lua/liolib.cpp b/engines/sword25/util/lua/liolib.cpp
index 6c00de5094..0d27f9677f 100644
--- a/engines/sword25/util/lua/liolib.cpp
+++ b/engines/sword25/util/lua/liolib.cpp
@@ -590,4 +590,3 @@ LUALIB_API int luaopen_io (lua_State *L) {
lua_pop(L, 1); /* pop 'popen' */
return 1;
}
-
diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp
index 4d73a6a600..464ab3ec15 100644
--- a/engines/sword25/util/lua/llex.cpp
+++ b/engines/sword25/util/lua/llex.cpp
@@ -188,7 +188,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) {
sprintf(buf, "%.1f", 1.0);
ls->decpoint = '.';
for (i = 0; buf[i]; i++) {
- if (!isspace(buf[i]) && !isdigit(buf[i])) {
+ if (!isspace(static_cast<unsigned char>(buf[i])) && !isdigit(static_cast<unsigned char>(buf[i]))) {
ls->decpoint = buf[i];
break;
}
@@ -472,4 +472,3 @@ void luaX_lookahead (LexState *ls) {
lua_assert(ls->lookahead.token == TK_EOS);
ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
}
-
diff --git a/engines/sword25/util/lua/lmathlib.cpp b/engines/sword25/util/lua/lmathlib.cpp
index 6c36bbcf4e..c1a645b296 100644
--- a/engines/sword25/util/lua/lmathlib.cpp
+++ b/engines/sword25/util/lua/lmathlib.cpp
@@ -274,4 +274,3 @@ LUALIB_API int luaopen_math (lua_State *L) {
#endif
return 1;
}
-
diff --git a/engines/sword25/util/lua/lmem.cpp b/engines/sword25/util/lua/lmem.cpp
index ccd69357e0..004a467dc8 100644
--- a/engines/sword25/util/lua/lmem.cpp
+++ b/engines/sword25/util/lua/lmem.cpp
@@ -83,4 +83,3 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
g->totalbytes = (g->totalbytes - osize) + nsize;
return block;
}
-
diff --git a/engines/sword25/util/lua/lmem.h b/engines/sword25/util/lua/lmem.h
index 97a888c7f8..6430912b41 100644
--- a/engines/sword25/util/lua/lmem.h
+++ b/engines/sword25/util/lua/lmem.h
@@ -46,4 +46,3 @@ LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
const char *errormsg);
#endif
-
diff --git a/engines/sword25/util/lua/loadlib.cpp b/engines/sword25/util/lua/loadlib.cpp
index f4cdd70a78..49934ce059 100644
--- a/engines/sword25/util/lua/loadlib.cpp
+++ b/engines/sword25/util/lua/loadlib.cpp
@@ -329,4 +329,3 @@ LUALIB_API int luaopen_package (lua_State *L) {
lua_pop(L, 1);
return 1; /* return 'package' table */
}
-
diff --git a/engines/sword25/util/lua/lobject.h b/engines/sword25/util/lua/lobject.h
index 5418a918b1..70b2c754ea 100644
--- a/engines/sword25/util/lua/lobject.h
+++ b/engines/sword25/util/lua/lobject.h
@@ -378,4 +378,3 @@ LUAI_FUNC void luaO_chunkid (char *out, const char *source, size_t len);
#endif
-
diff --git a/engines/sword25/util/lua/lopcodes.cpp b/engines/sword25/util/lua/lopcodes.cpp
index d9da16f689..255b2029e9 100644
--- a/engines/sword25/util/lua/lopcodes.cpp
+++ b/engines/sword25/util/lua/lopcodes.cpp
@@ -99,4 +99,3 @@ const lu_byte luaP_opmodes[NUM_OPCODES] = {
,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
};
-
diff --git a/engines/sword25/util/lua/loslib.cpp b/engines/sword25/util/lua/loslib.cpp
index b61f8c65e1..25bfa2d1b5 100644
--- a/engines/sword25/util/lua/loslib.cpp
+++ b/engines/sword25/util/lua/loslib.cpp
@@ -243,4 +243,3 @@ LUALIB_API int luaopen_os (lua_State *L) {
luaL_register(L, LUA_OSLIBNAME, syslib);
return 1;
}
-
diff --git a/engines/sword25/util/lua/lstate.cpp b/engines/sword25/util/lua/lstate.cpp
index e542bcbacc..26bed7bec2 100644
--- a/engines/sword25/util/lua/lstate.cpp
+++ b/engines/sword25/util/lua/lstate.cpp
@@ -211,4 +211,3 @@ LUA_API void lua_close (lua_State *L) {
luai_userstateclose(L);
close_state(L);
}
-
diff --git a/engines/sword25/util/lua/lstate.h b/engines/sword25/util/lua/lstate.h
index 94a6249461..05ccb43d5e 100644
--- a/engines/sword25/util/lua/lstate.h
+++ b/engines/sword25/util/lua/lstate.h
@@ -166,4 +166,3 @@ LUAI_FUNC lua_State *luaE_newthread (lua_State *L);
LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
#endif
-
diff --git a/engines/sword25/util/lua/lstring.cpp b/engines/sword25/util/lua/lstring.cpp
index cd55cc63bf..046b87ee1c 100644
--- a/engines/sword25/util/lua/lstring.cpp
+++ b/engines/sword25/util/lua/lstring.cpp
@@ -108,4 +108,3 @@ Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
G(L)->mainthread->next = obj2gco(u);
return u;
}
-
diff --git a/engines/sword25/util/lua/lstrlib.cpp b/engines/sword25/util/lua/lstrlib.cpp
index 2a1b8690e2..bcc869cb98 100644
--- a/engines/sword25/util/lua/lstrlib.cpp
+++ b/engines/sword25/util/lua/lstrlib.cpp
@@ -865,4 +865,3 @@ LUALIB_API int luaopen_string (lua_State *L) {
createmetatable(L);
return 1;
}
-
diff --git a/engines/sword25/util/lua/ltablib.cpp b/engines/sword25/util/lua/ltablib.cpp
index 607c09ae71..93be9e6077 100644
--- a/engines/sword25/util/lua/ltablib.cpp
+++ b/engines/sword25/util/lua/ltablib.cpp
@@ -276,4 +276,3 @@ LUALIB_API int luaopen_table (lua_State *L) {
luaL_register(L, LUA_TABLIBNAME, tab_funcs);
return 1;
}
-
diff --git a/engines/sword25/util/lua/ltm.cpp b/engines/sword25/util/lua/ltm.cpp
index 02856a58fc..60ca76689a 100644
--- a/engines/sword25/util/lua/ltm.cpp
+++ b/engines/sword25/util/lua/ltm.cpp
@@ -72,4 +72,3 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
}
return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject);
}
-
diff --git a/engines/sword25/util/lua/luaconf.h b/engines/sword25/util/lua/luaconf.h
index f3509e969b..f5affe9fd7 100644
--- a/engines/sword25/util/lua/luaconf.h
+++ b/engines/sword25/util/lua/luaconf.h
@@ -723,4 +723,3 @@ union luai_Cast { double l_d; long l_l; };
#endif
-
diff --git a/engines/sword25/util/lua/lvm.cpp b/engines/sword25/util/lua/lvm.cpp
index d0f2198651..d538d0b349 100644
--- a/engines/sword25/util/lua/lvm.cpp
+++ b/engines/sword25/util/lua/lvm.cpp
@@ -760,4 +760,3 @@ void luaV_execute (lua_State *L, int nexeccalls) {
}
}
}
-
diff --git a/engines/sword25/util/lua/lzio.cpp b/engines/sword25/util/lua/lzio.cpp
index e1e7b28a29..d05c613897 100644
--- a/engines/sword25/util/lua/lzio.cpp
+++ b/engines/sword25/util/lua/lzio.cpp
@@ -78,5 +78,3 @@ char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {
}
return buff->buffer;
}
-
-
diff --git a/engines/sword25/util/pluto/CHANGELOG b/engines/sword25/util/pluto/CHANGELOG
index e31ed26044..1be321f898 100644
--- a/engines/sword25/util/pluto/CHANGELOG
+++ b/engines/sword25/util/pluto/CHANGELOG
@@ -35,4 +35,3 @@ Earlier versions are changelogged on the LuaForge site.
* Fixed all outstanding 5.0->5.1 conversion issues
* Made heavier use of size_t in preference to int
* Fixed GC/Upval issue (thanks to Eric Jacobs)
-
diff --git a/engines/sword25/util/pluto/FILEFORMAT b/engines/sword25/util/pluto/FILEFORMAT
index b3f10ee603..e7716675c7 100644
--- a/engines/sword25/util/pluto/FILEFORMAT
+++ b/engines/sword25/util/pluto/FILEFORMAT
@@ -165,4 +165,4 @@ struct LocVar {
Object name; /* Name of the local variable */
int startpc; /* Point where variable is active */
int endpc; /* Point where variable is dead */
-}; \ No newline at end of file
+};
diff --git a/engines/sword25/util/pluto/THANKS b/engines/sword25/util/pluto/THANKS
index fea3595dbf..443713fa61 100644
--- a/engines/sword25/util/pluto/THANKS
+++ b/engines/sword25/util/pluto/THANKS
@@ -7,4 +7,3 @@ Goran Adrinek
Eric Jacobs
Anolan Milanes
Malte Thiesen
-
diff --git a/engines/sword25/util/pluto/plzio.cpp b/engines/sword25/util/pluto/plzio.cpp
index 0efc3dfcf2..21f69a9e8d 100644
--- a/engines/sword25/util/pluto/plzio.cpp
+++ b/engines/sword25/util/pluto/plzio.cpp
@@ -72,5 +72,3 @@ char *pdep_openspace (lua_State *L, Mbuffer *buff, size_t n) {
}
return buff->buffer;
}
-
-