aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2010-08-07 20:09:40 +0000
committerEugene Sandulenko2010-10-12 22:37:13 +0000
commitab85540a1bb59d7f69b89868805d1fe2a2adc89c (patch)
tree174c8976b018ecf939f6d1a6c67d84665d9623a8 /engines
parent7257ee345b9c71e0aa0677061de0a0466c183cb9 (diff)
downloadscummvm-rg350-ab85540a1bb59d7f69b89868805d1fe2a2adc89c.tar.gz
scummvm-rg350-ab85540a1bb59d7f69b89868805d1fe2a2adc89c.tar.bz2
scummvm-rg350-ab85540a1bb59d7f69b89868805d1fe2a2adc89c.zip
SWORD25: More compilation fixes
Now almost everything compiles fine. Several files were tricked and there are references to tinyxml.h and of course fmod and agg. OpenGL gfx renderer removed from the project, we need to create our own from the scratch. svn-id: r53224
Diffstat (limited to 'engines')
-rw-r--r--engines/sword25/gfx/graphicengine.cpp6
-rw-r--r--engines/sword25/gfx/graphicengine.h2
-rw-r--r--engines/sword25/gfx/image/pngloader.cpp360
-rw-r--r--engines/sword25/gfx/image/vectorimage.cpp145
-rw-r--r--engines/sword25/gfx/renderobject.cpp24
-rw-r--r--engines/sword25/gfx/renderobjectmanager.cpp2
-rw-r--r--engines/sword25/gfx/screenshot.cpp14
-rw-r--r--engines/sword25/gfx/screenshot.h4
-rw-r--r--engines/sword25/gfx/text.cpp4
-rw-r--r--engines/sword25/gfx/timedrenderobject.cpp4
-rw-r--r--engines/sword25/math/walkregion.cpp2
-rw-r--r--engines/sword25/module.mk5
12 files changed, 258 insertions, 314 deletions
diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp
index 075bf9757a..f20d858707 100644
--- a/engines/sword25/gfx/graphicengine.cpp
+++ b/engines/sword25/gfx/graphicengine.cpp
@@ -108,14 +108,12 @@ namespace {
bool DoSaveScreenshot(BS_GraphicEngine &GraphicEngine, const Common::String &Filename, bool Thumbnail) {
unsigned int Width;
unsigned int Height;
- Common::Array<unsigned int> Data;
- if (!GraphicEngine.GetScreenshot(Width, Height, Data)) {
+ byte *Data;
+ if (!GraphicEngine.GetScreenshot(Width, Height, &Data)) {
BS_LOG_ERRORLN("Call to GetScreenshot() failed. Cannot save screenshot.");
return false;
}
- unsigned int test = Data.size();
-
if (Thumbnail)
return BS_Screenshot::SaveThumbnailToFile(Width, Height, Data, Filename);
else
diff --git a/engines/sword25/gfx/graphicengine.h b/engines/sword25/gfx/graphicengine.h
index 82559e1a48..45603efb6e 100644
--- a/engines/sword25/gfx/graphicengine.h
+++ b/engines/sword25/gfx/graphicengine.h
@@ -199,7 +199,7 @@ public:
* @param Height Returns the height of the frame buffer
* @param Data Returns the raw data of the frame buffer as an array of 32-bit colour values.
*/
- virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, Common::Array<unsigned int> &Data) = 0;
+ virtual bool GetScreenshot(unsigned int &Width, unsigned int &Height, byte **Data) = 0;
virtual BS_RenderObjectPtr<BS_Panel> GetMainPanel() = 0;
diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp
index 1c896a7675..3f892c7af1 100644
--- a/engines/sword25/gfx/image/pngloader.cpp
+++ b/engines/sword25/gfx/image/pngloader.cpp
@@ -85,209 +85,170 @@ bool BS_PNGLoader::DoDecodeImage(const char *FileDataPtr, unsigned int FileSize,
return false;
}
- try {
- // PNG Signatur überprüfen
- if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8)) {
- throw(0);
- }
-
- // Die beiden PNG Strukturen erstellen
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) {
- BS_LOG_ERRORLN("Could not create libpng read struct.");
- throw(0);
- }
-
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
- BS_LOG_ERRORLN("Could not create libpng info struct.");
- throw(0);
- }
+ // PNG Signatur überprüfen
+ if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8)) {
+ error("png_check_sig failed");
+ }
- // Rücksprungpunkt setzen. Wird im Falle eines Fehlers angesprungen.
- if (setjmp(png_jmpbuf(png_ptr))) throw(0);
+ // Die beiden PNG Strukturen erstellen
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) {
+ error("Could not create libpng read struct.");
+ }
- // Alternative Lesefunktion benutzen
- png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ error("Could not create libpng info struct.");
+ }
- // PNG Header einlesen
- png_read_info(png_ptr, info_ptr);
+ // Alternative Lesefunktion benutzen
+ png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
- // PNG Informationen auslesen
- png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
+ // PNG Header einlesen
+ png_read_info(png_ptr, info_ptr);
- // Pitch des Ausgabebildes berechnen
- Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width);
+ // PNG Informationen auslesen
+ png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
- // Speicher für die endgültigen Bilddaten reservieren
- // Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten
- UncompressedDataPtr = new char[Pitch * Height];
- if (!UncompressedDataPtr) {
- BS_LOG_ERRORLN("Could not allocate memory for output image.");
- throw(0);
- }
+ // Pitch des Ausgabebildes berechnen
+ Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width);
- // Bilder jeglicher Farbformate werden zunächst in ARGB Bilder umgewandelt
- if (BitDepth == 16)
- png_set_strip_16(png_ptr);
- if (ColorType == PNG_COLOR_TYPE_PALETTE)
- png_set_expand(png_ptr);
- if (BitDepth < 8)
- png_set_expand(png_ptr);
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
- png_set_expand(png_ptr);
- if (ColorType == PNG_COLOR_TYPE_GRAY ||
- ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
- png_set_gray_to_rgb(png_ptr);
-
- png_set_bgr(png_ptr);
-
- if (ColorType != PNG_COLOR_TYPE_RGB_ALPHA)
- png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
-
- // Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen
- png_read_update_info(png_ptr, info_ptr);
- png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
-
- // PNGs ohne Interlacing werden Zeilenweise eingelesen
- if (InterlaceType == PNG_INTERLACE_NONE) {
- // Speicher für eine Bildzeile reservieren
- RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
- if (!RawDataBuffer) {
- BS_LOG_ERRORLN("Could not allocate memory for row buffer.");
- throw(0);
- }
+ // Speicher für die endgültigen Bilddaten reservieren
+ // Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten
+ UncompressedDataPtr = new char[Pitch * Height];
+ if (!UncompressedDataPtr) {
+ error("Could not allocate memory for output image.");
+ }
- // Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren
- for (i = 0; i < Height; i++) {
- // Zeile einlesen
- png_read_row(png_ptr, RawDataBuffer, NULL);
-
- // Zeile konvertieren
- switch (ColorFormat) {
- case BS_GraphicEngine::CF_RGB16:
- RowARGB32ToRGB16((unsigned char *)RawDataBuffer,
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
- break;
-
- case BS_GraphicEngine::CF_RGB15:
- RowARGB32ToRGB15((unsigned char *)RawDataBuffer,
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
- break;
-
- case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
- RowARGB32ToRGB16_INTERLEAVED((unsigned char *)RawDataBuffer,
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
- break;
-
- case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
- RowARGB32ToRGB15_INTERLEAVED((unsigned char *)RawDataBuffer,
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
- break;
-
- case BS_GraphicEngine::CF_ARGB32:
- memcpy(&UncompressedDataPtr[i * Pitch],
- RawDataBuffer,
- Pitch);
- break;
-
- case BS_GraphicEngine::CF_ABGR32:
- RowARGB32ToABGR32((unsigned char *)RawDataBuffer,
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
- break;
-
- default:
- BS_ASSERT(false);
- }
- }
+ // Bilder jeglicher Farbformate werden zunächst in ARGB Bilder umgewandelt
+ if (BitDepth == 16)
+ png_set_strip_16(png_ptr);
+ if (ColorType == PNG_COLOR_TYPE_PALETTE)
+ png_set_expand(png_ptr);
+ if (BitDepth < 8)
+ png_set_expand(png_ptr);
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_expand(png_ptr);
+ if (ColorType == PNG_COLOR_TYPE_GRAY ||
+ ColorType == PNG_COLOR_TYPE_GRAY_ALPHA)
+ png_set_gray_to_rgb(png_ptr);
+
+ png_set_bgr(png_ptr);
+
+ if (ColorType != PNG_COLOR_TYPE_RGB_ALPHA)
+ png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
+
+ // Nachdem die Transformationen registriert wurden, werden die Bilddaten erneut eingelesen
+ png_read_update_info(png_ptr, info_ptr);
+ png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
+
+ // PNGs ohne Interlacing werden Zeilenweise eingelesen
+ if (InterlaceType == PNG_INTERLACE_NONE) {
+ // Speicher für eine Bildzeile reservieren
+ RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
+ if (!RawDataBuffer) {
+ error("Could not allocate memory for row buffer.");
}
- // PNGs mit Interlacing werden an einem Stück eingelesen
- else {
- // Speicher für das komplette Bild reservieren
- RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr) * Height];
- if (!RawDataBuffer) {
- BS_LOG_ERRORLN("Could not allocate memory for raw image buffer.");
- throw(0);
- }
-
- // Speicher für die Rowpointer reservieren
- pRowPtr = new png_bytep[Height];
- if (!pRowPtr) {
- BS_LOG_ERRORLN("Could not allocate memory for row pointers.");
- throw(0);
- }
-
- // Alle Rowpointer mit den richtigen Offsets initialisieren
- for (i = 0; i < Height; i++)
- pRowPtr[i] = RawDataBuffer + i * png_get_rowbytes(png_ptr, info_ptr);
- // Bild einlesen
- png_read_image(png_ptr, pRowPtr);
+ // Bilddaten zeilenweise einlesen und in das gewünschte Zielformat konvertieren
+ for (i = 0; i < Height; i++) {
+ // Zeile einlesen
+ png_read_row(png_ptr, RawDataBuffer, NULL);
- // Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren
+ // Zeile konvertieren
switch (ColorFormat) {
case BS_GraphicEngine::CF_RGB16:
- for (i = 0; i < Height; i++)
- RowARGB32ToRGB16((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB16((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
break;
case BS_GraphicEngine::CF_RGB15:
- for (i = 0; i < Height; i++)
- RowARGB32ToRGB15((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB15((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
break;
case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
- for (i = 0; i < Height; i++)
- RowARGB32ToRGB16_INTERLEAVED((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB16_INTERLEAVED((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
break;
case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
- for (i = 0; i < Height; i++)
- RowARGB32ToRGB15_INTERLEAVED((unsigned char *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
- (unsigned char *)&UncompressedDataPtr[i * Pitch],
- Width);
+ RowARGB32ToRGB15_INTERLEAVED((byte *)RawDataBuffer,
+ (byte *)&UncompressedDataPtr[i * Pitch], Width);
break;
case BS_GraphicEngine::CF_ARGB32:
- for (i = 0; i < Height; i++)
- memcpy(&UncompressedDataPtr[i * Pitch],
- &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)],
- Pitch);
+ memcpy(&UncompressedDataPtr[i * Pitch], RawDataBuffer, Pitch);
+ break;
+
+ case BS_GraphicEngine::CF_ABGR32:
+ RowARGB32ToABGR32((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
break;
+
+ default:
+ assert(0);
}
}
+ } else {
+ // PNGs mit Interlacing werden an einem Stück eingelesen
+ // Speicher für das komplette Bild reservieren
+ RawDataBuffer = new png_byte[png_get_rowbytes(png_ptr, info_ptr) * Height];
+ if (!RawDataBuffer) {
+ error("Could not allocate memory for raw image buffer.");
+ }
- // Die zusätzlichen Daten am Ende des Bildes lesen
- png_read_end(png_ptr, NULL);
+ // Speicher für die Rowpointer reservieren
+ pRowPtr = new png_bytep[Height];
+ if (!pRowPtr) {
+ error("Could not allocate memory for row pointers.");
+ }
- // Die Strukturen freigeben
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+ // Alle Rowpointer mit den richtigen Offsets initialisieren
+ for (i = 0; i < Height; i++)
+ pRowPtr[i] = RawDataBuffer + i * png_get_rowbytes(png_ptr, info_ptr);
- // Temporäre Buffer freigeben
- delete[] pRowPtr;
- delete[] RawDataBuffer;
- }
+ // Bild einlesen
+ png_read_image(png_ptr, pRowPtr);
+
+ // Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren
+ switch (ColorFormat) {
+ case BS_GraphicEngine::CF_RGB16:
+ for (i = 0; i < Height; i++)
+ RowARGB32ToRGB16((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (byte *)&UncompressedDataPtr[i * Pitch], Width);
+ break;
- catch (int) {
- delete[] pRowPtr;
- delete[] RawDataBuffer;
- if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
- if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, NULL);
+ case BS_GraphicEngine::CF_RGB15:
+ for (i = 0; i < Height; i++)
+ RowARGB32ToRGB15((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (byte *)&UncompressedDataPtr[i * Pitch], Width);
+ break;
- // Der Funktionsaufruf war nicht erfolgreich
- return false;
+ case BS_GraphicEngine::CF_RGB16_INTERLEAVED:
+ for (i = 0; i < Height; i++)
+ RowARGB32ToRGB16_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (byte *)&UncompressedDataPtr[i * Pitch], Width);
+ break;
+
+ case BS_GraphicEngine::CF_RGB15_INTERLEAVED:
+ for (i = 0; i < Height; i++)
+ RowARGB32ToRGB15_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
+ (byte *)&UncompressedDataPtr[i * Pitch], Width);
+ break;
+
+ case BS_GraphicEngine::CF_ARGB32:
+ for (i = 0; i < Height; i++)
+ memcpy(&UncompressedDataPtr[i * Pitch], &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)], Pitch);
+ break;
+ }
}
+
+ // Die zusätzlichen Daten am Ende des Bildes lesen
+ png_read_end(png_ptr, NULL);
+
+ // Die Strukturen freigeben
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
+
+ // Temporäre Buffer freigeben
+ delete[] pRowPtr;
+ delete[] RawDataBuffer;
// Der Funktionsaufruf war erfolgreich
return true;
@@ -308,48 +269,37 @@ bool BS_PNGLoader::DoImageProperties(const char *FileDataPtr, unsigned int FileS
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
- try {
- // Die beiden PNG Strukturen erstellen
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) {
- BS_LOG_ERRORLN("Could not create libpng read struct.");
- throw(0);
- }
- info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) {
- BS_LOG_ERRORLN("Could not create libpng info struct.");
- throw(0);
- }
-
- // Alternative Lesefunktion benutzen
- png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
+ // Die beiden PNG Strukturen erstellen
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) {
+ error("Could not create libpng read struct.");
+ }
- // PNG Header einlesen
- png_read_info(png_ptr, info_ptr);
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ error("Could not create libpng info struct.");
+ }
- // PNG Informationen auslesen
- int BitDepth;
- int ColorType;
- png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
+ // Alternative Lesefunktion benutzen
+ png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
- // PNG-ColorType in BS ColorFormat konvertieren.
- if (ColorType & PNG_COLOR_MASK_ALPHA || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
- ColorFormat = BS_GraphicEngine::CF_ARGB32;
- else
- ColorFormat = BS_GraphicEngine::CF_RGB24;
+ // PNG Header einlesen
+ png_read_info(png_ptr, info_ptr);
- // Die Strukturen freigeben
- png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
- }
+ // PNG Informationen auslesen
+ int BitDepth;
+ int ColorType;
+ png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, NULL, NULL, NULL);
- catch (int) {
- if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
- if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, NULL);
+ // PNG-ColorType in BS ColorFormat konvertieren.
+ if (ColorType & PNG_COLOR_MASK_ALPHA || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ ColorFormat = BS_GraphicEngine::CF_ARGB32;
+ else
+ ColorFormat = BS_GraphicEngine::CF_RGB24;
- // Der Funktionsaufruf war nicht erfolgreich
- return false;
- }
+ // Die Strukturen freigeben
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return true;
@@ -367,7 +317,7 @@ bool BS_PNGLoader::ImageProperties(const char *FileDataPtr, unsigned int FileSiz
bool BS_PNGLoader::DoIsCorrectImageFormat(const char *FileDataPtr, unsigned int FileSize) {
if (FileSize > 8)
- return png_check_sig((unsigned char *)FileDataPtr, 8) ? true : false;
+ return png_check_sig((byte *)FileDataPtr, 8) ? true : false;
else
return false;
}
diff --git a/engines/sword25/gfx/image/vectorimage.cpp b/engines/sword25/gfx/image/vectorimage.cpp
index a8c84ee6b3..9e3e2fef71 100644
--- a/engines/sword25/gfx/image/vectorimage.cpp
+++ b/engines/sword25/gfx/image/vectorimage.cpp
@@ -76,7 +76,7 @@ public:
inline u32 GetBits(unsigned int BitCount) {
if (BitCount == 0 || BitCount > 32) {
- throw(runtime_error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time"));
+ error("SWFBitStream::GetBits() must read at least 1 and at most 32 bits at a time");
}
u32 value = 0;
@@ -132,7 +132,7 @@ public:
inline void FlushByte() {
if (m_WordMask != 128) {
if (m_Pos >= m_End) {
- throw(runtime_error("Attempted to read past end of file"));
+ error("Attempted to read past end of file");
} else {
m_Word = *m_Pos++;
m_WordMask = 128;
@@ -143,7 +143,7 @@ public:
inline void SkipBytes(unsigned int SkipLength) {
FlushByte();
if (m_Pos + SkipLength >= m_End) {
- throw(runtime_error("Attempted to read past end of file"));
+ error("Attempted to read past end of file");
} else {
m_Pos += SkipLength;
m_Word = *(m_Pos - 1);
@@ -237,79 +237,71 @@ BS_VectorImage::BS_VectorImage(const unsigned char *pFileData, unsigned int File
// Im Folgenden werden die Dateidaten aus diesem ausgelesen.
SWFBitStream bs(pFileData, FileSize);
- try {
- // SWF-Signatur überprüfen
- u32 Signature[3];
- Signature[0] = bs.GetU8();
- Signature[1] = bs.GetU8();
- Signature[2] = bs.GetU8();
- if (Signature[0] != 'F' ||
- Signature[1] != 'W' ||
- Signature[2] != 'S') {
- BS_LOG_ERRORLN("File is not a valid SWF-file");
- return;
- }
-
- // Versionsangabe überprüfen
- u32 Version = bs.GetU8();
- if (Version > MAX_ACCEPTED_FLASH_VERSION) {
- BS_LOG_ERRORLN("File is of version %d. Highest accepted version is %d.", Version, MAX_ACCEPTED_FLASH_VERSION);
- return;
- }
-
- // Dateigröße auslesen und mit der tatsächlichen Größe vergleichen
- u32 StoredFileSize = bs.GetU32();
- if (StoredFileSize != FileSize) {
- BS_LOG_ERRORLN("File is not a valid SWF-file");
- return;
- }
+ // SWF-Signatur überprüfen
+ u32 Signature[3];
+ Signature[0] = bs.GetU8();
+ Signature[1] = bs.GetU8();
+ Signature[2] = bs.GetU8();
+ if (Signature[0] != 'F' ||
+ Signature[1] != 'W' ||
+ Signature[2] != 'S') {
+ BS_LOG_ERRORLN("File is not a valid SWF-file");
+ return;
+ }
- // SWF-Maße auslesen
- BS_Rect MovieRect = FlashRectToBSRect(bs);
-
- // Framerate und Frameanzahl auslesen
- u32 FrameRate = bs.GetU16();
- u32 FrameCount = bs.GetU16();
-
- // Tags parsen
- // Da wir uns nur für das erste DefineShape-Tag interessieren
- bool KeepParsing = true;
- while (KeepParsing) {
- // Tags beginnen immer an Bytegrenzen
- bs.FlushByte();
-
- // Tagtyp und Länge auslesen
- u16 TagTypeAndLength = bs.GetU16();
- u32 TagType = TagTypeAndLength >> 6;
- u32 TagLength = TagTypeAndLength & 0x3f;
- if (TagLength == 0x3f) TagLength = bs.GetU32();
-
- switch (TagType) {
- case 2:
- // DefineShape
- Success = ParseDefineShape(2, bs);
- return;
- case 22:
- // DefineShape2
- Success = ParseDefineShape(2, bs);
- return;
- case 32:
- Success = ParseDefineShape(3, bs);
- return;
- default:
- // Unbekannte Tags ignorieren
- bs.SkipBytes(TagLength);
- }
- }
+ // Versionsangabe überprüfen
+ u32 Version = bs.GetU8();
+ if (Version > MAX_ACCEPTED_FLASH_VERSION) {
+ BS_LOG_ERRORLN("File is of version %d. Highest accepted version is %d.", Version, MAX_ACCEPTED_FLASH_VERSION);
+ return;
}
- catch (runtime_error &e) {
- // Fehler loggen und Funktion verlassen
- // Success ist somit "false" und signalisiert dem Programmierer, dass die Konstruktion fehlgeschlagen ist.
- BS_LOG_ERRORLN("The following exception occured while parsing a SWF-file: %s", e.what());
+ // Dateigröße auslesen und mit der tatsächlichen Größe vergleichen
+ u32 StoredFileSize = bs.GetU32();
+ if (StoredFileSize != FileSize) {
+ BS_LOG_ERRORLN("File is not a valid SWF-file");
return;
}
+ // SWF-Maße auslesen
+ BS_Rect MovieRect = FlashRectToBSRect(bs);
+
+ // Framerate und Frameanzahl auslesen
+ u32 FrameRate = bs.GetU16();
+ u32 FrameCount = bs.GetU16();
+
+ // Tags parsen
+ // Da wir uns nur für das erste DefineShape-Tag interessieren
+ bool KeepParsing = true;
+ while (KeepParsing) {
+ // Tags beginnen immer an Bytegrenzen
+ bs.FlushByte();
+
+ // Tagtyp und Länge auslesen
+ u16 TagTypeAndLength = bs.GetU16();
+ u32 TagType = TagTypeAndLength >> 6;
+ u32 TagLength = TagTypeAndLength & 0x3f;
+ if (TagLength == 0x3f)
+ TagLength = bs.GetU32();
+
+ switch (TagType) {
+ case 2:
+ // DefineShape
+ Success = ParseDefineShape(2, bs);
+ return;
+ case 22:
+ // DefineShape2
+ Success = ParseDefineShape(2, bs);
+ return;
+ case 32:
+ Success = ParseDefineShape(3, bs);
+ return;
+ default:
+ // Unbekannte Tags ignorieren
+ bs.SkipBytes(TagLength);
+ }
+ }
+
// Die Ausführung darf nicht an dieser Stelle ankommen: Entweder es wird ein Shape gefunden, dann wird die Funktion mit vorher verlassen, oder
// es wird keines gefunden, dann tritt eine Exception auf sobald über das Ende der Datei hinaus gelesen wird.
BS_ASSERT(false);
@@ -329,7 +321,8 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs)
// Styles einlesen
unsigned int NumFillBits;
unsigned int NumLineBits;
- if (!ParseStyles(ShapeType, bs, NumFillBits, NumLineBits)) return false;
+ if (!ParseStyles(ShapeType, bs, NumFillBits, NumLineBits))
+ return false;
unsigned int LineStyle = 0;
unsigned int FillStyle0 = 0;
@@ -409,9 +402,8 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs)
m_Elements.back().m_Paths.move_to(LastX, LastY);
}
}
- }
- // Edge Record
- else {
+ } else {
+ // Edge Record
u32 EdgeFlag = bs.GetBits(1);
u32 NumBits = bs.GetBits(4) + 2;
@@ -427,9 +419,8 @@ bool BS_VectorImage::ParseDefineShape(unsigned int ShapeType, SWFBitStream &bs)
double AnchorX = ControlX + AnchorDeltaX;
double AnchorY = ControlY + AnchorDeltaY;
m_Elements.back().m_Paths.curve3(ControlX, ControlY, AnchorX, AnchorY);
- }
- // Staight edge
- else {
+ } else {
+ // Staight edge
s32 DeltaX = 0;
s32 DeltaY = 0;
diff --git a/engines/sword25/gfx/renderobject.cpp b/engines/sword25/gfx/renderobject.cpp
index 8be0dfb380..4909569ca0 100644
--- a/engines/sword25/gfx/renderobject.cpp
+++ b/engines/sword25/gfx/renderobject.cpp
@@ -304,7 +304,7 @@ void BS_RenderObject::SetVisible(bool Visible) {
// -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::String &Filename) {
- BS_RenderObjectPtr<BS_Animation> AniPtr(new BS_Animation(this, Filename));
+ BS_RenderObjectPtr<BS_Animation> AniPtr((new BS_Animation(this->GetHandle(), Filename))->GetHandle());
if (AniPtr.IsValid() && AniPtr->GetInitSuccess())
return AniPtr;
else {
@@ -317,9 +317,9 @@ BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const Common::Str
// -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_AnimationTemplate &AnimationTemplate) {
- BS_Animation *AniPtr = new BS_Animation(this, AnimationTemplate);
+ BS_Animation *AniPtr = new BS_Animation(this->GetHandle(), AnimationTemplate);
if (AniPtr && AniPtr->GetInitSuccess())
- return AniPtr;
+ return AniPtr->GetHandle();
else {
delete AniPtr;
return BS_RenderObjectPtr<BS_Animation>();
@@ -329,7 +329,7 @@ BS_RenderObjectPtr<BS_Animation> BS_RenderObject::AddAnimation(const BS_Animatio
// -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String &Filename) {
- BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_StaticBitmap(this, Filename));
+ BS_RenderObjectPtr<BS_Bitmap> BitmapPtr((new BS_StaticBitmap(this->GetHandle(), Filename))->GetHandle());
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
return BS_RenderObjectPtr<BS_Bitmap>(BitmapPtr);
else {
@@ -341,7 +341,7 @@ BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddBitmap(const Common::String &F
// -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Width, unsigned int Height) {
- BS_RenderObjectPtr<BS_Bitmap> BitmapPtr(new BS_DynamicBitmap(this, Width, Height));
+ BS_RenderObjectPtr<BS_Bitmap> BitmapPtr((new BS_DynamicBitmap(this->GetHandle(), Width, Height))->GetHandle());
if (BitmapPtr.IsValid() && BitmapPtr->GetInitSuccess())
return BitmapPtr;
else {
@@ -353,7 +353,7 @@ BS_RenderObjectPtr<BS_Bitmap> BS_RenderObject::AddDynamicBitmap(unsigned int Wid
// -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, unsigned int Color) {
- BS_RenderObjectPtr<BS_Panel> PanelPtr(new BS_Panel(this, Width, Height, Color));
+ BS_RenderObjectPtr<BS_Panel> PanelPtr((new BS_Panel(this->GetHandle(), Width, Height, Color))->GetHandle());
if (PanelPtr.IsValid() && PanelPtr->GetInitSuccess())
return PanelPtr;
else {
@@ -365,7 +365,7 @@ BS_RenderObjectPtr<BS_Panel> BS_RenderObject::AddPanel(int Width, int Height, un
// -----------------------------------------------------------------------------
BS_RenderObjectPtr<BS_Text> BS_RenderObject::AddText(const Common::String &Font, const Common::String &Text) {
- BS_RenderObjectPtr<BS_Text> TextPtr(new BS_Text(this));
+ BS_RenderObjectPtr<BS_Text> TextPtr((new BS_Text(this->GetHandle()))->GetHandle());
if (TextPtr.IsValid() && TextPtr->GetInitSuccess() && TextPtr->SetFont(Font)) {
TextPtr->SetText(Text);
return TextPtr;
@@ -499,23 +499,23 @@ BS_RenderObjectPtr<BS_RenderObject> BS_RenderObject::RecreatePersistedRenderObje
switch (Type) {
case TYPE_PANEL:
- Result = new BS_Panel(Reader, this, Handle);
+ Result = (new BS_Panel(Reader, this->GetHandle(), Handle))->GetHandle();
break;
case TYPE_STATICBITMAP:
- Result = new BS_StaticBitmap(Reader, this, Handle);
+ Result = (new BS_StaticBitmap(Reader, this->GetHandle(), Handle))->GetHandle();
break;
case TYPE_DYNAMICBITMAP:
- Result = new BS_DynamicBitmap(Reader, this, Handle);
+ Result = (new BS_DynamicBitmap(Reader, this->GetHandle(), Handle))->GetHandle();
break;
case TYPE_TEXT:
- Result = new BS_Text(Reader, this, Handle);
+ Result = (new BS_Text(Reader, this->GetHandle(), Handle))->GetHandle();
break;
case TYPE_ANIMATION:
- Result = new BS_Animation(Reader, this, Handle);
+ Result = (new BS_Animation(Reader, this->GetHandle(), Handle))->GetHandle();
break;
default:
diff --git a/engines/sword25/gfx/renderobjectmanager.cpp b/engines/sword25/gfx/renderobjectmanager.cpp
index 583cc77345..0198c7be2c 100644
--- a/engines/sword25/gfx/renderobjectmanager.cpp
+++ b/engines/sword25/gfx/renderobjectmanager.cpp
@@ -59,7 +59,7 @@ namespace Sword25 {
BS_RenderObjectManager::BS_RenderObjectManager(int Width, int Height, int FramebufferCount) :
m_FrameStarted(false) {
// Wurzel des BS_RenderObject-Baumes erzeugen.
- m_RootPtr = new BS_RootRenderObject(this, Width, Height);
+ m_RootPtr = (new BS_RootRenderObject(this, Width, Height))->GetHandle();
}
// -----------------------------------------------------------------------------
diff --git a/engines/sword25/gfx/screenshot.cpp b/engines/sword25/gfx/screenshot.cpp
index 59e52e1ab4..0c48966d0b 100644
--- a/engines/sword25/gfx/screenshot.cpp
+++ b/engines/sword25/gfx/screenshot.cpp
@@ -59,7 +59,8 @@ struct RGB_PIXEL {
unsigned char Blue;
};
-bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string &Filename) {
+bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename) {
+#if 0
BS_ASSERT(Data.size() == Width * Height);
// Buffer für Bildschirminhalt in RGB reservieren
@@ -146,13 +147,17 @@ bool BS_Screenshot::SaveToFile(unsigned int Width, unsigned int Height, const ve
BS_LOG_ERRORLN("Could not create screenshot (\"%s\").", Filename.c_str());
return false;
}
+#else
+ warning("STUB: BS_Screenshot::SaveToFile(%d, %d, .., %s)", Width, Height, Filename.c_str());
+#endif
return true;
}
// -----------------------------------------------------------------------------
-bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height, const vector<unsigned int> & Data, const string &Filename) {
+bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename) {
+#if 0
//
// Diese Methode nimmt ein Screenshot mit den Maßen von 800x600 und erzeugt einen Screenshot mit den Maßen von 200x125.
// Dabei werden je 50 Pixel oben und unten abgeschnitten (die Interface-Leisten im Spiel). Das verbleibende Bild von 800x500 wird auf
@@ -199,6 +204,11 @@ bool BS_Screenshot::SaveThumbnailToFile(unsigned int Width, unsigned int Height,
// Bild als PNG Speichern.
return SaveToFile(200, 125, ThumbnailData, Filename);
+#else
+ warning("STUB: BS_Screenshot::SaveThumbnailToFile(%d, %d, .., %s)", Width, Height, Filename.c_str());
+
+ return true;
+#endif
}
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/screenshot.h b/engines/sword25/gfx/screenshot.h
index 10e176c1a4..a5b3f79e0f 100644
--- a/engines/sword25/gfx/screenshot.h
+++ b/engines/sword25/gfx/screenshot.h
@@ -53,8 +53,8 @@ namespace Sword25 {
class BS_Screenshot {
public:
- static bool SaveToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename);
- static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const Common::Array<unsigned int> & Data, const Common::String &Filename);
+ static bool SaveToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename);
+ static bool SaveThumbnailToFile(unsigned int Width, unsigned int Height, const byte *Data, const Common::String &Filename);
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/text.cpp b/engines/sword25/gfx/text.cpp
index eafd6d8152..418c428258 100644
--- a/engines/sword25/gfx/text.cpp
+++ b/engines/sword25/gfx/text.cpp
@@ -183,7 +183,7 @@ bool BS_Text::DoRender() {
int CurX = m_AbsoluteX + (*Iter).BBox.left;
int CurY = m_AbsoluteY + (*Iter).BBox.top;
for (unsigned int i = 0; i < (*Iter).Text.size(); ++i) {
- BS_Rect CurRect = FontPtr->GetCharacterRect((unsigned char)(*Iter).Text.at(i));
+ BS_Rect CurRect = FontPtr->GetCharacterRect((unsigned char)(*Iter).Text[i]);
BS_Rect RenderRect(CurX, CurY, CurX + CurRect.GetWidth(), CurY + CurRect.GetHeight());
int RenderX = CurX + (RenderRect.left - RenderRect.left);
@@ -322,7 +322,7 @@ void BS_Text::UpdateMetrics(BS_FontResource &FontResource) {
m_Height = 0;
for (unsigned int i = 0; i < m_Text.size(); ++i) {
- const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text.at(i));
+ const BS_Rect &CurRect = FontResource.GetCharacterRect((unsigned char)m_Text[i]);
m_Width += CurRect.GetWidth();
if (i != m_Text.size() - 1) m_Width += FontResource.GetGapWidth();
if (m_Height < CurRect.GetHeight()) m_Height = CurRect.GetHeight();
diff --git a/engines/sword25/gfx/timedrenderobject.cpp b/engines/sword25/gfx/timedrenderobject.cpp
index eff62c3135..98510f056f 100644
--- a/engines/sword25/gfx/timedrenderobject.cpp
+++ b/engines/sword25/gfx/timedrenderobject.cpp
@@ -45,12 +45,12 @@ namespace Sword25 {
BS_TimedRenderObject::BS_TimedRenderObject(BS_RenderObjectPtr<BS_RenderObject> pParent, TYPES Type, unsigned int Handle) :
BS_RenderObject(pParent, Type, Handle) {
BS_ASSERT(GetManager());
- GetManager()->AttatchTimedRenderObject(this);
+ GetManager()->AttatchTimedRenderObject(this->GetHandle());
}
BS_TimedRenderObject::~BS_TimedRenderObject() {
BS_ASSERT(GetManager());
- GetManager()->DetatchTimedRenderObject(this);
+ GetManager()->DetatchTimedRenderObject(this->GetHandle());
}
} // End of namespace Sword25
diff --git a/engines/sword25/math/walkregion.cpp b/engines/sword25/math/walkregion.cpp
index 0ef2958521..82ee0bf782 100644
--- a/engines/sword25/math/walkregion.cpp
+++ b/engines/sword25/math/walkregion.cpp
@@ -46,7 +46,7 @@ namespace Sword25 {
// Constants
// -----------------------------------------------------------------------------
-static const int infinity = INT_MAX;
+static const int infinity = (~(-1));
// -----------------------------------------------------------------------------
// Constructor / Destructor
diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk
index 6c2a531d93..b64a0f371e 100644
--- a/engines/sword25/module.mk
+++ b/engines/sword25/module.mk
@@ -31,13 +31,8 @@ MODULE_OBJS := \
gfx/image/pngloader.o \
gfx/image/vectorimage.o \
gfx/image/vectorimagerenderer.o \
- gfx/opengl/glimage.o \
- gfx/opengl/glvectorimageblit.o \
- gfx/opengl/openglgfx.o \
- gfx/opengl/swimage.o \
input/inputengine.o \
input/inputengine_script.o \
- input/stdwininput.o \
kernel/callbackregistry.o \
kernel/filesystemutil.o \
kernel/inputpersistenceblock.o \