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
This commit is contained in:
Eugene Sandulenko 2010-08-07 20:09:40 +00:00
parent 7257ee345b
commit ab85540a1b
12 changed files with 270 additions and 326 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);
// PNG Signatur überprüfen
if (!png_check_sig(reinterpret_cast<png_bytep>(const_cast<char *>(FileDataPtr)), 8)) {
error("png_check_sig failed");
}
// 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.");
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
error("Could not create libpng info struct.");
}
// Alternative Lesefunktion benutzen
png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
// PNG Header einlesen
png_read_info(png_ptr, info_ptr);
// PNG Informationen auslesen
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&Width, (png_uint_32 *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
// Pitch des Ausgabebildes berechnen
Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width);
// 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.");
}
// 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.");
}
// 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);
}
// 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);
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
BS_LOG_ERRORLN("Could not create libpng info struct.");
throw(0);
}
// Rücksprungpunkt setzen. Wird im Falle eines Fehlers angesprungen.
if (setjmp(png_jmpbuf(png_ptr))) throw(0);
// Alternative Lesefunktion benutzen
png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
// PNG Header einlesen
png_read_info(png_ptr, info_ptr);
// PNG Informationen auslesen
png_get_IHDR(png_ptr, info_ptr, (unsigned long *)&Width, (unsigned long *)&Height, &BitDepth, &ColorType, &InterlaceType, NULL, NULL);
// Pitch des Ausgabebildes berechnen
Pitch = BS_GraphicEngine::CalcPitch(ColorFormat, Width);
// 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);
}
// 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);
}
// 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);
}
}
}
// 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 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;
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;
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);
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);
// Die Strukturen freigeben
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
// Der Funktionsaufruf war nicht erfolgreich
return false;
}
// Temporäre Buffer freigeben
delete[] pRowPtr;
delete[] RawDataBuffer;
// Der Funktionsaufruf war erfolgreich
return true;
@ -308,49 +269,38 @@ 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);
// PNG Header einlesen
png_read_info(png_ptr, info_ptr);
// 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);
// 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;
// Die Strukturen freigeben
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
// 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.");
}
catch (int) {
if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
if (info_ptr) png_destroy_read_struct(NULL, &info_ptr, NULL);
// Der Funktionsaufruf war nicht erfolgreich
return false;
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
error("Could not create libpng info struct.");
}
// Alternative Lesefunktion benutzen
png_set_read_fn(png_ptr, (void *)FileDataPtr, png_user_read_data);
// PNG Header einlesen
png_read_info(png_ptr, info_ptr);
// 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);
// 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;
// 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;
}

View file

@ -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-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);
}
}
// 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;
}
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());
// 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-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;

View file

@ -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:

View file

@ -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();
}
// -----------------------------------------------------------------------------

View file

@ -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

View file

@ -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

View file

@ -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();

View file

@ -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

View file

@ -46,7 +46,7 @@ namespace Sword25 {
// Constants
// -----------------------------------------------------------------------------
static const int infinity = INT_MAX;
static const int infinity = (~(-1));
// -----------------------------------------------------------------------------
// Constructor / Destructor

View file

@ -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 \