=== modified file 'libendian/src/swap.cpp' --- libendian/src/swap.cpp 2011-09-08 22:02:15 +0000 +++ libendian/src/swap.cpp 2012-02-01 20:20:13 +0000 @@ -71,7 +71,7 @@ */ int libendian::swap_i(int i) { - return swap_ui((unsigned short)i); + return swap_ui((unsigned int)i); } /////////////////////////////////////////////////////////////////////////////// === modified file 'libsiedler2/src/ArchivItem_Bitmap_Player.cpp' --- libsiedler2/src/ArchivItem_Bitmap_Player.cpp 2011-12-30 23:06:06 +0000 +++ libsiedler2/src/ArchivItem_Bitmap_Player.cpp 2012-02-01 23:07:17 +0000 @@ -141,6 +141,7 @@ */ int libsiedler2::baseArchivItem_Bitmap_Player::load(FILE *file, const ArchivItem_Palette *palette) { + unsigned short *starts = NULL; unsigned char *data = NULL; if(file == NULL) @@ -182,12 +183,21 @@ if(length != 0) { data = new unsigned char[length]; - if(libendian::le_read_uc(data, length, file) != (int)length) - return 7; + + starts = (unsigned short *)data; + + for(unsigned int i = 0; i < height; ++i) + { + if(libendian::le_read_us(&starts[i], file) != 0) + return 7; + } + + if(libendian::le_read_uc(&data[height*2], length-(height*2), file) != (int)(length-(height*2))) + return 8; } - if(load(width, height, &data[height*2], (unsigned short*)data, false, length, palette) != 0) - return 8; + if(load(width, height, &data[height*2], starts, false, length, palette) != 0) + return 9; delete[] data; @@ -230,6 +240,9 @@ position = (unsigned int)starts[y] - (absolute ? 0 : (height*2) ); + if (position > (length-(absolute ? 0 : (height*2)))) + return 1; + // Solange Zeile einlesen, bis x voll ist while(x < width) { @@ -411,8 +424,13 @@ return 9; // Daten schreiben - if(libendian::le_write_uc(data, length, file) != (int)length) - return 10; + for(unsigned int i = 0; i < height; ++i) + { + if(libendian::le_write_us(((unsigned short *)data)[i], file) != 0) + return 10; + } + if(libendian::le_write_uc(&data[height*2], length-(height*2), file) != (int)(length-(height*2))) + return 11; delete[] data; === modified file 'libsiedler2/src/ArchivItem_Bitmap_RLE.cpp' --- libsiedler2/src/ArchivItem_Bitmap_RLE.cpp 2011-09-08 22:02:15 +0000 +++ libsiedler2/src/ArchivItem_Bitmap_RLE.cpp 2012-02-01 22:29:19 +0000 @@ -315,8 +315,13 @@ return 9; // Daten schreiben - if(libendian::le_write_uc(data, length, file) != (int)length) - return 10; + for(unsigned int i = 0; i < height; ++i) + { + if(libendian::le_write_us(((unsigned short *)data)[i], file) != 0) + return 10; + } + if(libendian::le_write_uc(&data[height*2], length-(height*2), file) != (int)(length-(height*2))) + return 11; delete[] data; === modified file 'libsiedler2/src/ArchivItem_Bitmap_Shadow.cpp' --- libsiedler2/src/ArchivItem_Bitmap_Shadow.cpp 2011-09-08 22:02:15 +0000 +++ libsiedler2/src/ArchivItem_Bitmap_Shadow.cpp 2012-02-01 22:54:37 +0000 @@ -305,8 +305,13 @@ return 9; // Daten schreiben - if(libendian::le_write_uc(data, length, file) != (int)length) - return 10; + for(unsigned int i = 0; i < height; ++i) + { + if(libendian::le_write_us(((unsigned short *)data)[i], file) != 0) + return 10; + } + if(libendian::le_write_uc(&data[height*2], length-(height*2), file) != (int)(length-(height*2))) + return 11; delete[] data; === modified file 'libsiedler2/src/ArchivItem_Bob.cpp' --- libsiedler2/src/ArchivItem_Bob.cpp 2011-09-08 22:02:15 +0000 +++ libsiedler2/src/ArchivItem_Bob.cpp 2012-02-01 22:50:25 +0000 @@ -142,8 +142,11 @@ return 6; unsigned short *starts = new unsigned short[height]; - if(libendian::le_read_uc((unsigned char*)starts, height*2, file) != height*2) - return 7; + for(unsigned int i = 0; i < height; ++i) + { + if(libendian::le_read_us(&starts[i], file) != 0) + return 7; + } unsigned char ny; if(libendian::le_read_uc(&ny, 1, file) != 1) @@ -218,8 +221,11 @@ return 16; starts[i] = new unsigned short[heights[i]]; - if(libendian::le_read_uc((unsigned char*)starts[i], heights[i]*2, file) != heights[i]*2) - return 17; + for(unsigned int i2 = 0; i2 < heights[i]; ++i2) + { + if(libendian::le_read_us(&starts[i][i2], file) != 0) + return 17; + } if(libendian::le_read_uc(&ny[i], 1, file) != 1) return 18; === modified file 'libsiedler2/src/ArchivItem_Sound_Midi.cpp' --- libsiedler2/src/ArchivItem_Sound_Midi.cpp 2011-09-08 22:02:15 +0000 +++ libsiedler2/src/ArchivItem_Sound_Midi.cpp 2012-02-01 23:25:41 +0000 @@ -130,7 +130,7 @@ case 0x4D54726B: // "MTrk" { // Länge einlesen - if(libendian::be_read_ui(&length, file) != 0) + if(libendian::le_read_ui(&length, file) != 0) return 10; fseek(file, -8, SEEK_CUR); === modified file 'libsiedler2/src/ArchivItem_Sound_Wave.cpp' --- libsiedler2/src/ArchivItem_Sound_Wave.cpp 2011-09-08 22:02:15 +0000 +++ libsiedler2/src/ArchivItem_Sound_Wave.cpp 2012-02-02 20:11:51 +0000 @@ -155,6 +155,11 @@ unsigned int size = length + 16; +#if BYTE_ORDER == BIG_ENDIAN + size = libendian::swap_ui(size); + length = libendian::swap_ui(length); +#endif + memcpy(&header[4], &size, 4); memcpy(&header[40], &length, 4); === modified file 'libsiedler2/src/WriteTXT.cpp' --- libsiedler2/src/WriteTXT.cpp 2011-09-08 22:02:15 +0000 +++ libsiedler2/src/WriteTXT.cpp 2012-02-01 22:16:04 +0000 @@ -117,8 +117,11 @@ return 8; // Starts schreiben - if(libendian::le_write_c((char*)starts, 4*count, txt) != 4*count) - return 9; + for(unsigned long i = 0; i < count; ++i) + { + if(libendian::le_write_i(starts[i], txt) != 0) + return 9; + } // Texte schreiben for(unsigned long i = 0; i < count; ++i) === modified file 's-c/resample-1.8.1/sndlib-20/mus-config.h' --- s-c/resample-1.8.1/sndlib-20/mus-config.h 2010-05-31 22:01:00 +0000 +++ s-c/resample-1.8.1/sndlib-20/mus-config.h 2012-02-02 21:24:02 +0000 @@ -18,7 +18,7 @@ #define HAVE_STRDUP 1 #define HAVE_FILENO 1 #define HAVE_COMPLEX_TRIG 1 -/* #undef WORDS_BIGENDIAN */ +#define WORDS_BIGENDIAN 1 #define HAVE_FCNTL_H 1 #define HAVE_LIMITS_H 1 === modified file 's-c/src/main.cpp' --- s-c/src/main.cpp 2011-09-08 22:02:15 +0000 +++ s-c/src/main.cpp 2012-02-02 21:28:12 +0000 @@ -39,6 +39,7 @@ #include "tokenizer.hpp" #include "../../libsiedler2/src/libsiedler2.h" +#include "../../libendian/src/libendian.h" int usage(int argc, char *argv[]) { @@ -186,6 +187,10 @@ unsigned char *data = new unsigned char[wave->getLength()]; memcpy(data, wave->getData(), wave->getLength()); unsigned short bitrate = 8; +#if BYTE_ORDER == BIG_ENDIAN + frequency = libendian::swap_i(frequency); + bitrate = libendian::swap_us(bitrate); +#endif memcpy(&data[24], &frequency, 4); memcpy(&data[28], &frequency, 4); memcpy(&data[34], &bitrate, 2);