[Scummvm-cvs-logs] scummvm master -> f20c8b963a8fae6895067bc0c9dcb02cd1135fd3
bluegr
md5 at scummvm.org
Thu May 5 21:16:32 CEST 2011
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
51136ac4ae SWORD25: Marked more functions as unused
d7334628bd SWORD25: Moved the thumbnail handling code to its appropriate place
f20c8b963a SWORD25: Disabled code which isn't necessary with our PNG decoder
Commit: 51136ac4aeed8733c10e0c148ea1a8dc30e824ca
https://github.com/scummvm/scummvm/commit/51136ac4aeed8733c10e0c148ea1a8dc30e824ca
Author: md5 (md5 at scummvm.org)
Date: 2011-05-05T12:00:52-07:00
Commit Message:
SWORD25: Marked more functions as unused
Changed paths:
engines/sword25/kernel/kernel_script.cpp
diff --git a/engines/sword25/kernel/kernel_script.cpp b/engines/sword25/kernel/kernel_script.cpp
index 458f6b2..43a144b 100644
--- a/engines/sword25/kernel/kernel_script.cpp
+++ b/engines/sword25/kernel/kernel_script.cpp
@@ -42,45 +42,9 @@
namespace Sword25 {
-static int disconnectService(lua_State *L) {
- // This function apparently is not used by the game scripts
- lua_pushboolean(L, true);
-
- return 1;
-}
-
-static int getActiveServiceIdentifier(lua_State *L) {
- // This function apparently is not used by the game scripts
- lua_pushstring(L, "QUUX");
-
- return 1;
-}
-
-static int getSuperclassCount(lua_State *L) {
- // This function is only used by a single function in system/kernel.lua which is never called.
- lua_pushnumber(L, 0);
-
- return 1;
-}
-
-static int getSuperclassIdentifier(lua_State *L) {
- // This function is only used by a single function in system/kernel.lua which is never called.
- lua_pushstring(L, "FOO");
-
- return 1;
-}
-
-static int getServiceCount(lua_State *L) {
- // This function is only used by a single function in system/kernel.lua which is never called.
- lua_pushnumber(L, 0);
-
- return 1;
-}
-
-static int getServiceIdentifier(lua_State *L) {
- // This function is only used by a single function in system/kernel.lua which is never called.
- lua_pushstring(L, "BAR");
-
+// Marks a function that should never be used
+static int dummyFuncError(lua_State *L) {
+ error("Dummy function invoked by LUA");
return 1;
}
@@ -177,12 +141,12 @@ static int getUsedMemory(lua_State *L) {
static const char *KERNEL_LIBRARY_NAME = "Kernel";
static const luaL_reg KERNEL_FUNCTIONS[] = {
- {"DisconnectService", disconnectService},
- {"GetActiveServiceIdentifier", getActiveServiceIdentifier},
- {"GetSuperclassCount", getSuperclassCount},
- {"GetSuperclassIdentifier", getSuperclassIdentifier},
- {"GetServiceCount", getServiceCount},
- {"GetServiceIdentifier", getServiceIdentifier},
+ {"DisconnectService", dummyFuncError},
+ {"GetActiveServiceIdentifier", dummyFuncError},
+ {"GetSuperclassCount", dummyFuncError},
+ {"GetSuperclassIdentifier", dummyFuncError},
+ {"GetServiceCount", dummyFuncError},
+ {"GetServiceIdentifier", dummyFuncError},
{"GetMilliTicks", getMilliTicks},
{"GetTimer", getTimer},
{"StartService", startService},
@@ -241,20 +205,6 @@ static int setY(lua_State *L) {
return 0;
}
-static int getClientX(lua_State *L) {
- // This function apparently is not used by the game scripts
- lua_pushnumber(L, 0);
-
- return 1;
-}
-
-static int getClientY(lua_State *L) {
- // This function apparently is not used by the game scripts
- lua_pushnumber(L, 0);
-
- return 1;
-}
-
static int getWidth(lua_State *L) {
// This function apparently is not used by the game scripts
lua_pushnumber(L, 800);
@@ -332,20 +282,6 @@ static int closeWanted(lua_State *L) {
return 1;
}
-static int waitForFocus(lua_State *L) {
- // This function apparently is not used by the game scripts
- lua_pushbooleancpp(L, true);
-
- return 1;
-}
-
-static int hasFocus(lua_State *L) {
- // This function apparently is not used by the game scripts
- lua_pushbooleancpp(L, true);
-
- return 1;
-}
-
static const char *WINDOW_LIBRARY_NAME = "Window";
static const luaL_reg WINDOW_FUNCTIONS[] = {
@@ -355,8 +291,8 @@ static const luaL_reg WINDOW_FUNCTIONS[] = {
{"SetX", setX},
{"GetY", getY},
{"SetY", setY},
- {"GetClientX", getClientX},
- {"GetClientY", getClientY},
+ {"GetClientX", dummyFuncError},
+ {"GetClientY", dummyFuncError},
{"GetWidth", getWidth},
{"GetHeight", getHeight},
{"SetWidth", setWidth},
@@ -365,8 +301,8 @@ static const luaL_reg WINDOW_FUNCTIONS[] = {
{"SetTitle", setTitle},
{"ProcessMessages", processMessages},
{"CloseWanted", closeWanted},
- {"WaitForFocus", waitForFocus},
- {"HasFocus", hasFocus},
+ {"WaitForFocus", dummyFuncError},
+ {"HasFocus", dummyFuncError},
{0, 0}
};
@@ -436,29 +372,6 @@ static int emptyCache(lua_State *L) {
return 0;
}
-static int isLogCacheMiss(lua_State *L) {
- Kernel *pKernel = Kernel::getInstance();
- assert(pKernel);
- ResourceManager *pResource = pKernel->getResourceManager();
- assert(pResource);
-
- // This isn't used in any script
- lua_pushbooleancpp(L, false);
-
- return 1;
-}
-
-static int setLogCacheMiss(lua_State *L) {
- Kernel *pKernel = Kernel::getInstance();
- assert(pKernel);
- ResourceManager *pResource = pKernel->getResourceManager();
- assert(pResource);
-
- // This isn't used in any script
-
- return 0;
-}
-
static int dumpLockedResources(lua_State *L) {
Kernel *pKernel = Kernel::getInstance();
assert(pKernel);
@@ -478,8 +391,8 @@ static const luaL_reg RESOURCE_FUNCTIONS[] = {
{"GetMaxMemoryUsage", getMaxMemoryUsage},
{"SetMaxMemoryUsage", setMaxMemoryUsage},
{"EmptyCache", emptyCache},
- {"IsLogCacheMiss", isLogCacheMiss},
- {"SetLogCacheMiss", setLogCacheMiss},
+ {"IsLogCacheMiss", dummyFuncError},
+ {"SetLogCacheMiss", dummyFuncError},
{"DumpLockedResources", dumpLockedResources},
{0, 0}
};
Commit: d7334628bd59a8d4019be788d1a42b9171beae3b
https://github.com/scummvm/scummvm/commit/d7334628bd59a8d4019be788d1a42b9171beae3b
Author: md5 (md5 at scummvm.org)
Date: 2011-05-05T12:03:15-07:00
Commit Message:
SWORD25: Moved the thumbnail handling code to its appropriate place
PNGLoader is able to load images embedded in saved games already. This
helps remove some duplicate code
Changed paths:
engines/sword25/gfx/image/renderedimage.cpp
engines/sword25/package/packagemanager.cpp
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 806d9b2..65ff1c7 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -36,6 +36,7 @@
// INCLUDES
// -----------------------------------------------------------------------------
+#include "common/savefile.h"
#include "sword25/package/packagemanager.h"
#include "sword25/gfx/image/pngloader.h"
#include "sword25/gfx/image/renderedimage.h"
@@ -44,6 +45,14 @@
namespace Sword25 {
+// Duplicated from kernel/persistenceservice.cpp
+static Common::String generateSavegameFilename(uint slotID) {
+ char buffer[100];
+ // NOTE: This is hardcoded to sword25
+ snprintf(buffer, 100, "%s.%.3d", "sword25", slotID);
+ return Common::String(buffer);
+}
+
// -----------------------------------------------------------------------------
// CONSTRUCTION / DESTRUCTION
// -----------------------------------------------------------------------------
@@ -62,7 +71,20 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
// Load file
byte *pFileData;
uint fileSize;
- pFileData = pPackage->getFile(filename, &fileSize);
+
+ if (filename.hasPrefix("/saves")) {
+ // A savegame thumbnail
+ Common::SaveFileManager *sfm = g_system->getSavefileManager();
+ int slotNum = atoi(filename.c_str() + filename.size() - 3);
+ Common::InSaveFile *file = sfm->openForLoading(generateSavegameFilename(slotNum));
+ fileSize = file->size();
+ pFileData = new byte[fileSize];
+ file->read(pFileData, fileSize);
+ delete file;
+ } else {
+ pFileData = pPackage->getFile(filename, &fileSize);
+ }
+
if (!pFileData) {
error("File \"%s\" could not be loaded.", filename.c_str());
return;
diff --git a/engines/sword25/package/packagemanager.cpp b/engines/sword25/package/packagemanager.cpp
index 7c6343a..7a64fe2 100644
--- a/engines/sword25/package/packagemanager.cpp
+++ b/engines/sword25/package/packagemanager.cpp
@@ -141,29 +141,6 @@ bool PackageManager::loadDirectoryAsPackage(const Common::String &directoryName,
}
}
-// Duplicated from kernel/persistenceservice.cpp
-static Common::String generateSavegameFilename(uint slotID) {
- char buffer[100];
- // NOTE: This is hardcoded to sword25
- snprintf(buffer, 100, "%s.%.3d", "sword25", slotID);
- return Common::String(buffer);
-}
-
-// Duplicated from kernel/persistenceservice.cpp
-static Common::String loadString(Common::InSaveFile *in, uint maxSize = 999) {
- Common::String result;
-
- char ch = (char)in->readByte();
- while (ch != '\0') {
- result += ch;
- if (result.size() >= maxSize)
- break;
- ch = (char)in->readByte();
- }
-
- return result;
-}
-
byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr) {
const Common::String B25S_EXTENSION(".b25s");
Common::SeekableReadStream *in;
@@ -188,40 +165,6 @@ byte *PackageManager::getFile(const Common::String &fileName, uint *fileSizePtr)
return buffer;
}
- if (fileName.hasPrefix("/saves")) {
- // A savegame thumbnail
- Common::SaveFileManager *sfm = g_system->getSavefileManager();
- int slotNum = atoi(fileName.c_str() + fileName.size() - 3);
- Common::InSaveFile *file = sfm->openForLoading(generateSavegameFilename(slotNum));
-
- if (file) {
- loadString(file); // storedMarker
- loadString(file); // storedVersionID
- loadString(file); // gameDescription
- int gameDataLength = atoi(loadString(file).c_str());
- loadString(file); // gamedataUncompressedLength
- // Skip the savegame data
- file->skip(gameDataLength);
-
- int thumbnailSize = file->size() - file->pos();
-
- if (thumbnailSize <= 0) {
- warning("Saved game at slot %d does not contain a thumbnail", slotNum);
- delete file;
- return 0;
- }
-
- if (fileSizePtr)
- *fileSizePtr = thumbnailSize;
-
- byte *thumbnail = new byte[thumbnailSize];
- file->read(thumbnail, thumbnailSize);
-
- delete file;
- return thumbnail;
- }
- }
-
Common::ArchiveMemberPtr fileNode = getArchiveMember(normalizePath(fileName, _currentDirectory));
if (!fileNode)
return 0;
Commit: f20c8b963a8fae6895067bc0c9dcb02cd1135fd3
https://github.com/scummvm/scummvm/commit/f20c8b963a8fae6895067bc0c9dcb02cd1135fd3
Author: md5 (md5 at scummvm.org)
Date: 2011-05-05T12:12:38-07:00
Commit Message:
SWORD25: Disabled code which isn't necessary with our PNG decoder
Changed paths:
engines/sword25/gfx/image/pngloader.cpp
engines/sword25/gfx/image/pngloader.h
engines/sword25/gfx/image/renderedimage.cpp
engines/sword25/gfx/image/swimage.cpp
diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp
index f6c00b6..d3c119b 100644
--- a/engines/sword25/gfx/image/pngloader.cpp
+++ b/engines/sword25/gfx/image/pngloader.cpp
@@ -32,9 +32,6 @@
*
*/
-// Define to use ScummVM's PNG decoder, instead of libpng
-#define USE_INTERNAL_PNG_DECODER
-
#ifndef USE_INTERNAL_PNG_DECODER
// Disable symbol overrides so that we can use png.h
#define FORBIDDEN_SYMBOL_ALLOW_ALL
@@ -242,8 +239,8 @@ bool PNGLoader::decodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncom
return doDecodeImage(fileDataPtr + pngOffset, fileSize - pngOffset, uncompressedDataPtr, width, height, pitch);
}
-bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height) {
#ifndef USE_INTERNAL_PNG_DECODER
+bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height) {
// Check for valid PNG signature
if (!doIsCorrectImageFormat(fileDataPtr, fileSize))
return false;
@@ -280,9 +277,7 @@ bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, int &w
// Destroy libpng structures
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
-#else
- // We don't need to read the image properties here...
-#endif
+
return true;
}
@@ -292,5 +287,9 @@ bool PNGLoader::imageProperties(const byte *fileDataPtr, uint fileSize, int &wid
return doImageProperties(fileDataPtr + pngOffset, fileSize - pngOffset, width, height);
}
+#else
+ // We don't need to read the image properties here...
+#endif
+
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/pngloader.h b/engines/sword25/gfx/image/pngloader.h
index e0d68ff..fea6ece 100644
--- a/engines/sword25/gfx/image/pngloader.h
+++ b/engines/sword25/gfx/image/pngloader.h
@@ -40,6 +40,9 @@
namespace Sword25 {
+// Define to use ScummVM's PNG decoder, instead of libpng
+#define USE_INTERNAL_PNG_DECODER
+
/**
* Class for loading PNG files, and PNG data embedded into savegames.
*
@@ -50,7 +53,9 @@ protected:
PNGLoader() {} // Protected constructor to prevent instances
static bool doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch);
+#ifndef USE_INTERNAL_PNG_DECODER
static bool doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height);
+#endif
public:
@@ -72,6 +77,8 @@ public:
byte *&pUncompressedData,
int &width, int &height,
int &pitch);
+
+#ifndef USE_INTERNAL_PNG_DECODER
/**
* Extract the properties of an image.
* @param[in] fileDatePtr pointer to the image data
@@ -86,6 +93,8 @@ public:
static bool imageProperties(const byte *fileDatePtr, uint fileSize,
int &width,
int &height);
+#endif
+
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index 65ff1c7..132c516 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -90,15 +90,17 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
return;
}
+#ifndef USE_INTERNAL_PNG_DECODER
// Determine image properties
- int pitch;
if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
error("Could not read image properties.");
delete[] pFileData;
return;
}
+#endif
// Uncompress the image
+ int pitch;
if (!PNGLoader::decodeImage(pFileData, fileSize, _data, _width, _height, pitch)) {
error("Could not decode image.");
delete[] pFileData;
diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp
index 3b9b939..0f3814e 100644
--- a/engines/sword25/gfx/image/swimage.cpp
+++ b/engines/sword25/gfx/image/swimage.cpp
@@ -56,14 +56,16 @@ SWImage::SWImage(const Common::String &filename, bool &result) :
return;
}
+#ifndef USE_INTERNAL_PNG_DECODER
// Determine image properties
- int pitch;
if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
error("Could not read image properties.");
return;
}
+#endif
// Uncompress the image
+ int pitch;
byte *pUncompressedData;
if (!PNGLoader::decodeImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
error("Could not decode image.");
More information about the Scummvm-git-logs
mailing list