r3382 - in packages/trunk/glest/debian: . patches
Eddy Petrisor
eddyp-guest at alioth.debian.org
Thu Jul 12 18:18:48 UTC 2007
Author: eddyp-guest
Date: 2007-07-12 18:18:48 +0000 (Thu, 12 Jul 2007)
New Revision: 3382
Added:
packages/trunk/glest/debian/patches/20_be-support-from-kozz.dpatch
Modified:
packages/trunk/glest/debian/changelog
Log:
new BE patch which seems to be better than my own
Modified: packages/trunk/glest/debian/changelog
===================================================================
--- packages/trunk/glest/debian/changelog 2007-07-12 15:38:23 UTC (rev 3381)
+++ packages/trunk/glest/debian/changelog 2007-07-12 18:18:48 UTC (rev 3382)
@@ -1,8 +1,11 @@
glest (2.0.0-2) UNRELEASED; urgency=low
- * NOT RELEASED YET
+ * added a disabled dpatch for the endianness issue; it was downloaded from
+ http://kozz.org/files/games/glest/glest-cvs20070102-endian.patch.gz;
+ explanations about the patch are at:
+ http://www.powerdeveloper.org/forums/viewtopic.php?p=6675
- -- Eddy Petrișor <eddy.petrisor at gmail.com> Tue, 19 Jun 2007 14:33:20 +0100
+ -- Eddy Petrișor <eddy.petrisor at gmail.com> Thu, 12 Jul 2007 21:12:08 +0300
glest (2.0.0-1) unstable; urgency=low
Added: packages/trunk/glest/debian/patches/20_be-support-from-kozz.dpatch
===================================================================
--- packages/trunk/glest/debian/patches/20_be-support-from-kozz.dpatch (rev 0)
+++ packages/trunk/glest/debian/patches/20_be-support-from-kozz.dpatch 2007-07-12 18:18:48 UTC (rev 3382)
@@ -0,0 +1,637 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 20_be-support-from-kozz.dpatch by Eddy Petrișor <eddy.petrisor at gmail.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Patch from Emanuel Steen (Kozz) which adds BE support to glest - more
+## DP: info at
+## DP: http://www.powerdeveloper.org/forums/viewtopic.php?p=6615&sid=eea0f061be
+## DP: 143cbf8e98c10c9e7a6d6a#6615
+
+ at DPATCH@
+
+diff -Nru glest.orig/source/glest_game/menu/main_menu.cpp glest/source/glest_game/menu/main_menu.cpp
+--- glest.orig/source/glest_game/menu/main_menu.cpp 2007-01-02 12:23:43.000000000 +0100
++++ glest/source/glest_game/menu/main_menu.cpp 2007-01-02 12:23:42.000000000 +0100
+@@ -23,6 +23,7 @@
+ #include "faction.h"
+ #include "metrics.h"
+ #include "leak_dumper.h"
++#include "byteswap.h"
+
+ using namespace Shared::Sound;
+ using namespace Shared::Util;
+@@ -511,6 +512,12 @@
+
+ MapFileHeader header;
+ fread(&header, sizeof(MapFileHeader), 1, f);
++ header.version = letoh32(header.version);
++ header.maxPlayers = letoh32(header.maxPlayers);
++ header.width = letoh32(header.width);
++ header.height = letoh32(header.height);
++ header.altFactor = letoh32(header.altFactor);
++ header.waterLevel = letoh32(header.waterLevel);
+
+ mapInfo->size.x= header.width;
+ mapInfo->size.y= header.height;
+diff -Nru glest.orig/source/glest_game/world/map.cpp glest/source/glest_game/world/map.cpp
+--- glest.orig/source/glest_game/world/map.cpp 2007-01-02 12:23:43.000000000 +0100
++++ glest/source/glest_game/world/map.cpp 2007-01-02 12:23:42.000000000 +0100
+@@ -20,6 +20,7 @@
+ #include "tech_tree.h"
+ #include "config.h"
+ #include "leak_dumper.h"
++#include "byteswap.h"
+
+ using namespace Shared::Graphics;
+ using namespace Shared::Util;
+@@ -122,6 +123,13 @@
+ //read header
+ MapFileHeader header;
+ fread(&header, sizeof(MapFileHeader), 1, f);
++ header.version = letoh32(header.version);
++ header.maxPlayers = letoh32(header.maxPlayers);
++ header.width = letoh32(header.width);
++ header.height = letoh32(header.height);
++ header.altFactor = letoh32(header.altFactor);
++ header.waterLevel = letoh32(header.waterLevel);
++
+
+ if(next2Power(header.width) != header.width){
+ throw runtime_error("Map width is not a power of 2");
+@@ -146,7 +154,9 @@
+ for(int i=0; i<maxPlayers; ++i){
+ int x, y;
+ fread(&x, sizeof(int32), 1, f);
++ x = letoh32(x);
+ fread(&y, sizeof(int32), 1, f);
++ y = letoh32(y);
+ startLocations[i]= Vec2i(x, y)*cellScale;
+ }
+
+@@ -160,6 +170,7 @@
+ for(int i=0; i<surfaceW; ++i){
+ float32 alt;
+ fread(&alt, sizeof(float32), 1, f);
++ alt = byteswap(alt);
+ SurfaceCell *sc= getSurfaceCell(i, j);
+ sc->setVertex(Vec3f(i*mapScale, alt / heightFactor, j*mapScale));
+ }
+diff -Nru glest.orig/source/shared_lib/include/sound/sound_file_loader.h glest/source/shared_lib/include/sound/sound_file_loader.h
+--- glest.orig/source/shared_lib/include/sound/sound_file_loader.h 2007-01-02 12:23:43.000000000 +0100
++++ glest/source/shared_lib/include/sound/sound_file_loader.h 2007-01-02 12:23:42.000000000 +0100
+@@ -80,6 +80,11 @@
+ private:
+ OggVorbis_File *vf;
+ FILE *f;
++#if BYTE_ORDER == BIG_ENDIAN
++ static const int bigendianp = 1;
++#else
++ static const int bigendianp = 0;
++#endif
+
+ public:
+ virtual void open(const string &path, SoundInfo *soundInfo);
+diff -Nru glest.orig/source/shared_lib/include/util/byteswap.h glest/source/shared_lib/include/util/byteswap.h
+--- glest.orig/source/shared_lib/include/util/byteswap.h 1970-01-01 01:00:00.000000000 +0100
++++ glest/source/shared_lib/include/util/byteswap.h 2007-01-02 12:23:42.000000000 +0100
+@@ -0,0 +1,198 @@
++/* $OpenBSD: endian.h,v 1.14 2004/01/11 19:17:31 brad Exp $ */
++
++/*-
++ * Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++/*
++ * Generic definitions for little- and big-endian systems. Other endianesses
++ * has to be dealt with in the specific machine/endian.h file for that port.
++ *
++ * This file is meant to be included from a little- or big-endian port's
++ * machine/endian.h after setting BYTE_ORDER to either 1234 for little endian
++ * or 4321 for big..
++ */
++
++#ifndef _BYTESWAP_H_
++#define _BYTESWAP_H_
++
++#undef LITTLE_ENDIAN
++#define LITTLE_ENDIAN 1234
++#undef BIG_ENDIAN
++#define BIG_ENDIAN 4321
++#undef PDP_ENDIAN
++#define PDP_ENDIAN 3412
++
++#ifdef __GNUC__
++
++#define __swap16gen(x) __extension__({ \
++ uint16 __swap16gen_x = (x); \
++ \
++ (uint16)((__swap16gen_x & 0xff) << 8 | \
++ (__swap16gen_x & 0xff00) >> 8); \
++})
++
++#define __swap32gen(x) __extension__({ \
++ uint32 __swap32gen_x = (x); \
++ \
++ (uint32)((__swap32gen_x & 0xff) << 24 | \
++ (__swap32gen_x & 0xff00) << 8 | \
++ (__swap32gen_x & 0xff0000) >> 8 | \
++ (__swap32gen_x & 0xff000000) >> 24); \
++})
++
++#else /* __GNUC__ */
++
++/* Note that these macros evaluate their arguments several times. */
++#define __swap16gen(x) \
++ (uint16)(((uint16)(x) & 0xff) << 8 | ((uint16)(x) & 0xff00) >> 8)
++
++#define __swap32gen(x) \
++ (uint32)(((uint32)(x) & 0xff) << 24 | \
++ ((uint32)(x) & 0xff00) << 8 | ((uint32)(x) & 0xff0000) >> 8 | \
++ ((uint32)(x) & 0xff000000) >> 24)
++
++#endif /* __GNUC__ */
++
++/*
++ * Define MD_SWAP if you provide swap{16,32}md functions/macros that are
++ * optimized for your architecture, These will be used for swap{16,32}
++ * unless the argument is a constant and we are using GCC, where we can
++ * take advantage of the CSE phase much better by using the generic version.
++ */
++#ifdef MD_SWAP
++#if __GNUC__
++
++#define swap16(x) __extension__({ \
++ uint16 __swap16_x = (x); \
++ \
++ __builtin_constant_p(x) ? __swap16gen(__swap16_x) : \
++ __swap16md(__swap16_x); \
++})
++
++#define swap32(x) __extension__({ \
++ uint32 __swap32_x = (x); \
++ \
++ __builtin_constant_p(x) ? __swap32gen(__swap32_x) : \
++ __swap32md(__swap32_x); \
++})
++
++#endif /* __GNUC__ */
++
++#else /* MD_SWAP */
++#define swap16 __swap16gen
++#define swap32 __swap32gen
++#endif /* MD_SWAP */
++
++#define swap16_multi(v, n) do { \
++ size_t __swap16_multi_n = (n); \
++ uint16 *__swap16_multi_v = (v); \
++ \
++ while (__swap16_multi_n) { \
++ *__swap16_multi_v = swap16(*__swap16_multi_v); \
++ __swap16_multi_v++; \
++ __swap16_multi_n--; \
++ } \
++} while (0)
++
++uint32 htobe32(uint32);
++uint16 htobe16(uint16);
++uint32 betoh32(uint32);
++uint16 betoh16(uint16);
++
++uint32 htole32(uint32);
++uint16 htole16(uint16);
++uint32 letoh32(uint32);
++uint16 letoh16(uint16);
++
++#if BYTE_ORDER == LITTLE_ENDIAN
++
++inline float byteswap(float in) {
++ return in;
++}
++
++/* Can be overridden by machine/endian.h before inclusion of this file. */
++#ifndef _QUAD_HIGHWORD
++#define _QUAD_HIGHWORD 1
++#endif
++#ifndef _QUAD_LOWWORD
++#define _QUAD_LOWWORD 0
++#endif
++
++#define htobe16 swap16
++#define htobe32 swap32
++#define betoh16 swap16
++#define betoh32 swap32
++
++#define htole16(x) (x)
++#define htole32(x) (x)
++#define letoh16(x) (x)
++#define letoh32(x) (x)
++
++#endif /* BYTE_ORDER */
++
++#if BYTE_ORDER == BIG_ENDIAN
++
++inline float byteswap(float in) {
++ float retVal;
++ char* p = (char*)&retVal;
++ char* i = (char*)∈
++ p[0] = i[3];
++ p[1] = i[2];
++ p[2] = i[1];
++ p[3] = i[0];
++
++ return retVal;
++}
++
++/* Can be overridden by machine/endian.h before inclusion of this file. */
++#ifndef _QUAD_HIGHWORD
++#define _QUAD_HIGHWORD 0
++#endif
++#ifndef _QUAD_LOWWORD
++#define _QUAD_LOWWORD 1
++#endif
++
++#define htole16 swap16
++#define htole32 swap32
++#define letoh16 swap16
++#define letoh32 swap32
++
++#define htobe16(x) (x)
++#define htobe32(x) (x)
++#define betoh16(x) (x)
++#define betoh32(x) (x)
++
++#endif /* BYTE_ORDER */
++
++#define htons htobe16
++#define htonl htobe32
++#define ntohs betoh16
++#define ntohl betoh32
++
++#define NTOHL(x) (x) = ntohl((uint32)(x))
++#define NTOHS(x) (x) = ntohs((uint16)(x))
++#define HTONL(x) (x) = htonl((uint32)(x))
++#define HTONS(x) (x) = htons((uint16)(x))
++
++#endif /* _SYS_ENDIAN_H_ */
+diff -Nru glest.orig/source/shared_lib/sources/graphics/model.cpp glest/source/shared_lib/sources/graphics/model.cpp
+--- glest.orig/source/shared_lib/sources/graphics/model.cpp 2007-01-02 12:23:43.000000000 +0100
++++ glest/source/shared_lib/sources/graphics/model.cpp 2007-01-02 12:23:42.000000000 +0100
+@@ -19,6 +19,7 @@
+ #include "conversion.h"
+ #include "util.h"
+ #include "leak_dumper.h"
++#include "byteswap.h"
+
+ using namespace Shared::Platform;
+
+@@ -95,6 +96,12 @@
+ //read header
+ MeshHeaderV2 meshHeader;
+ fread(&meshHeader, sizeof(MeshHeaderV2), 1, f);
++ meshHeader.vertexFrameCount = letoh32(meshHeader.vertexFrameCount);
++ meshHeader.normalFrameCount = letoh32(meshHeader.normalFrameCount);
++ meshHeader.texCoordFrameCount = letoh32(meshHeader.texCoordFrameCount);
++ meshHeader.colorFrameCount = letoh32(meshHeader.colorFrameCount);
++ meshHeader.pointCount = letoh32(meshHeader.pointCount);
++ meshHeader.indexCount = letoh32(meshHeader.indexCount);
+
+
+ if(meshHeader.normalFrameCount!=meshHeader.vertexFrameCount){
+@@ -130,21 +137,53 @@
+
+ //read data
+ fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (frameCount*vertexCount); ++i) {
++ vertices[i].x = byteswap(vertices[i].x);
++ vertices[i].y = byteswap(vertices[i].y);
++ vertices[i].z = byteswap(vertices[i].z);
++ }
++
+ fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
+- if(textures[mtDiffuse]!=NULL){
++ for (unsigned int i = 0; i < (frameCount*vertexCount); ++i) {
++ normals[i].x = byteswap(normals[i].x);
++ normals[i].y = byteswap(normals[i].y);
++ normals[i].z = byteswap(normals[i].z);
++ }
++
++ if (textures[mtDiffuse] != NULL) {
+ fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (vertexCount); ++i) {
++ texCoords[i].x = byteswap(texCoords[i].x);
++ texCoords[i].y = byteswap(texCoords[i].y);
++ }
+ }
++
+ fread(&diffuseColor, sizeof(Vec3f), 1, f);
++ diffuseColor.x = byteswap(diffuseColor.x);
++ diffuseColor.y = byteswap(diffuseColor.y);
++ diffuseColor.z = byteswap(diffuseColor.z);
++
+ fread(&opacity, sizeof(float32), 1, f);
++ opacity = byteswap(opacity);
++
+ fseek(f, sizeof(Vec4f)*(meshHeader.colorFrameCount-1), SEEK_CUR);
+ fread(indices, sizeof(uint32)*indexCount, 1, f);
++ for (unsigned int i = 0; i < indexCount; ++i) {
++ indices[i] = letoh32(indices[i]);
++ }
+ }
+
+ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager){
+ //read header
+ MeshHeaderV3 meshHeader;
+ fread(&meshHeader, sizeof(MeshHeaderV3), 1, f);
+-
++ meshHeader.vertexFrameCount = letoh32(meshHeader.vertexFrameCount);
++ meshHeader.normalFrameCount = letoh32(meshHeader.normalFrameCount);
++ meshHeader.texCoordFrameCount = letoh32(meshHeader.texCoordFrameCount);
++ meshHeader.colorFrameCount = letoh32(meshHeader.colorFrameCount);
++ meshHeader.pointCount = letoh32(meshHeader.pointCount);
++ meshHeader.indexCount = letoh32(meshHeader.indexCount);
++ meshHeader.properties = letoh32(meshHeader.properties);
+
+ if(meshHeader.normalFrameCount!=meshHeader.vertexFrameCount){
+ throw runtime_error("Old model: vertex frame count different from normal frame count");
+@@ -175,22 +214,60 @@
+
+ //read data
+ fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (frameCount*vertexCount); ++i) {
++ vertices[i].x = byteswap(vertices[i].x);
++ vertices[i].y = byteswap(vertices[i].y);
++ vertices[i].z = byteswap(vertices[i].z);
++ }
++
+ fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (frameCount*vertexCount); ++i) {
++ normals[i].x = byteswap(normals[i].x);
++ normals[i].y = byteswap(normals[i].y);
++ normals[i].z = byteswap(normals[i].z);
++ }
++
+ if(textures[mtDiffuse]!=NULL){
+ for(int i=0; i<meshHeader.texCoordFrameCount; ++i){
+ fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (vertexCount); ++i) {
++ texCoords[i].x = byteswap(texCoords[i].x);
++ texCoords[i].y = byteswap(texCoords[i].y);
++ }
+ }
+ }
+ fread(&diffuseColor, sizeof(Vec3f), 1, f);
++ diffuseColor.x = byteswap(diffuseColor.x);
++ diffuseColor.y = byteswap(diffuseColor.y);
++ diffuseColor.z = byteswap(diffuseColor.z);
++
+ fread(&opacity, sizeof(float32), 1, f);
++ opacity = byteswap(opacity);
++
+ fseek(f, sizeof(Vec4f)*(meshHeader.colorFrameCount-1), SEEK_CUR);
+ fread(indices, sizeof(uint32)*indexCount, 1, f);
++ for (unsigned int i = 0; i < indexCount; ++i) {
++ indices[i] = letoh32(indices[i]);
++ }
+ }
+
+ void Mesh::load(const string &dir, FILE *f, TextureManager *textureManager){
+ //read header
+ MeshHeader meshHeader;
+ fread(&meshHeader, sizeof(MeshHeader), 1, f);
++ meshHeader.frameCount = letoh32(meshHeader.frameCount);
++ meshHeader.vertexCount = letoh32(meshHeader.vertexCount);
++ meshHeader.indexCount = letoh32(meshHeader.indexCount);
++ meshHeader.diffuseColor[0] = byteswap(meshHeader.diffuseColor[0]);
++ meshHeader.diffuseColor[1] = byteswap(meshHeader.diffuseColor[1]);
++ meshHeader.diffuseColor[2] = byteswap(meshHeader.diffuseColor[2]);
++ meshHeader.specularColor[0] = byteswap(meshHeader.specularColor[0]);
++ meshHeader.specularColor[1] = byteswap(meshHeader.specularColor[1]);
++ meshHeader.specularColor[2] = byteswap(meshHeader.specularColor[2]);
++ meshHeader.specularPower = byteswap(meshHeader.specularPower);
++ meshHeader.opacity = byteswap(meshHeader.opacity);
++ meshHeader.properties = letoh32(meshHeader.properties);
++ meshHeader.textures = letoh32(meshHeader.textures);
+
+ //init
+ frameCount= meshHeader.frameCount;
+@@ -233,11 +310,31 @@
+
+ //read data
+ fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (frameCount*vertexCount); ++i) {
++ vertices[i].x = byteswap(vertices[i].x);
++ vertices[i].y = byteswap(vertices[i].y);
++ vertices[i].z = byteswap(vertices[i].z);
++ }
++
+ fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (frameCount*vertexCount); ++i) {
++ normals[i].x = byteswap(normals[i].x);
++ normals[i].y = byteswap(normals[i].y);
++ normals[i].z = byteswap(normals[i].z);
++ }
++
+ if(meshHeader.textures!=0){
+ fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
++ for (unsigned int i = 0; i < (vertexCount); ++i) {
++ texCoords[i].x = byteswap(texCoords[i].x);
++ texCoords[i].y = byteswap(texCoords[i].y);
++ }
+ }
++
+ fread(indices, sizeof(uint32)*indexCount, 1, f);
++ for (unsigned int i = 0; i < indexCount; ++i) {
++ indices[i] = letoh32(indices[i]);
++ }
+
+ //tangents
+ if(textures[mtNormal]!=NULL){
+@@ -401,7 +498,7 @@
+ //read header
+ ModelHeaderOld modelHeader;
+ fread(&modelHeader, sizeof(ModelHeader), 1, f);
+- meshCount= modelHeader.meshCount;
++ meshCount= letoh16(modelHeader.meshCount);
+
+ if(modelHeader.id[0]!='G' || modelHeader.id[1]!='3' || modelHeader.id[2]!='D'){
+ throw runtime_error("Model: "+path+": is not a valid G3D model");
+@@ -452,7 +549,7 @@
+ //model header
+ ModelHeader modelHeader;
+ fread(&modelHeader, sizeof(ModelHeader), 1, f);
+- meshCount= modelHeader.meshCount;
++ meshCount= letoh16(modelHeader.meshCount);
+ if(modelHeader.type!=mtMorphMesh){
+ throw runtime_error("Invalid model type");
+ }
+@@ -468,6 +565,7 @@
+ else if(fileHeader.version==3){
+
+ fread(&meshCount, sizeof(meshCount), 1, f);
++ meshCount = letoh32(meshCount);
+ meshes= new Mesh[meshCount];
+ for(uint32 i=0; i<meshCount; ++i){
+ meshes[i].loadV3(dir, f, textureManager);
+@@ -478,6 +576,7 @@
+ else if(fileHeader.version==2){
+
+ fread(&meshCount, sizeof(meshCount), 1, f);
++ meshCount = letoh32(meshCount);
+ meshes= new Mesh[meshCount];
+ for(uint32 i=0; i<meshCount; ++i){
+ meshes[i].loadV2(dir, f, textureManager);
+diff -Nru glest.orig/source/shared_lib/sources/graphics/pixmap.cpp glest/source/shared_lib/sources/graphics/pixmap.cpp
+--- glest.orig/source/shared_lib/sources/graphics/pixmap.cpp 2007-01-02 12:23:43.000000000 +0100
++++ glest/source/shared_lib/sources/graphics/pixmap.cpp 2007-01-02 12:23:42.000000000 +0100
+@@ -18,6 +18,7 @@
+ #include "util.h"
+ #include "math_util.h"
+ #include "leak_dumper.h"
++#include "byteswap.h"
+
+ using namespace std;
+
+@@ -97,6 +98,13 @@
+ //read header
+ TargaFileHeader fileHeader;
+ fread(&fileHeader, sizeof(TargaFileHeader), 1, file);
++ fileHeader.colourMapOrigin = letoh16(fileHeader.colourMapOrigin);
++ fileHeader.colourMapLength = letoh16(fileHeader.colourMapLength);
++ fileHeader.xOrigin = letoh16(fileHeader.xOrigin);
++ fileHeader.yOrigin = letoh16(fileHeader.yOrigin);
++ fileHeader.width = letoh16(fileHeader.width);
++ fileHeader.height = letoh16(fileHeader.height);
++
+
+ //check that we can load this tga file
+ if(fileHeader.idLength!=0){
+@@ -224,6 +232,8 @@
+ //read file header
+ BitmapFileHeader fileHeader;
+ fread(&fileHeader, sizeof(BitmapFileHeader), 1, file);
++ fileHeader.size = letoh32(fileHeader.size);
++ fileHeader.offsetBits = letoh32(fileHeader.offsetBits);
+ if(fileHeader.type1!='B' || fileHeader.type2!='M'){
+ throw runtime_error(path +" is not a bitmap");
+ }
+@@ -231,6 +241,18 @@
+ //read info header
+ BitmapInfoHeader infoHeader;
+ fread(&infoHeader, sizeof(BitmapInfoHeader), 1, file);
++ infoHeader.size = letoh32(infoHeader.size);
++ infoHeader.width = letoh32(infoHeader.width);
++ infoHeader.height = letoh32(infoHeader.height);
++ infoHeader.planes = letoh16(infoHeader.planes);
++ infoHeader.bitCount = letoh16(infoHeader.bitCount);
++ infoHeader.compression = letoh32(infoHeader.compression);
++ infoHeader.sizeImage = letoh32(infoHeader.sizeImage);
++ infoHeader.xPelsPerMeter = letoh32(infoHeader.xPelsPerMeter);
++ infoHeader.yPelsPerMeter = letoh32(infoHeader.yPelsPerMeter);
++ infoHeader.clrUsed = letoh32(infoHeader.clrUsed);
++ infoHeader.clrImportant = letoh32(infoHeader.clrImportant);
++
+ if(infoHeader.bitCount!=24){
+ throw runtime_error(path+" is not a 24 bit bitmap");
+ }
+diff -Nru glest.orig/source/shared_lib/sources/sound/sound_file_loader.cpp glest/source/shared_lib/sources/sound/sound_file_loader.cpp
+--- glest.orig/source/shared_lib/sources/sound/sound_file_loader.cpp 2007-01-02 12:23:43.000000000 +0100
++++ glest/source/shared_lib/sources/sound/sound_file_loader.cpp 2007-01-02 12:23:42.000000000 +0100
+@@ -16,6 +16,7 @@
+
+ #include "sound.h"
+ #include "leak_dumper.h"
++#include "byteswap.h"
+
+ using namespace Shared::Platform;
+ using namespace std;
+@@ -47,6 +48,7 @@
+
+ //RIFF chunk - Size
+ f.read((char*) &size32, 4);
++ size32 = letoh32(size32);
+
+ //RIFF chunk - Data (WAVE string)
+ f.read(chunkId, 4);
+@@ -66,26 +68,33 @@
+
+ //first sub-chunk (header) - Size
+ f.read((char*) &size32, 4);
++ size32 = letoh32(size32);
+
+ //first sub-chunk (header) - Data (encoding type) - Ignore
+ f.read((char*) &size16, 2);
++ size16 = letoh16(size16);
+
+ //first sub-chunk (header) - Data (nChannels)
+ f.read((char*) &size16, 2);
++ size16 = letoh16(size16);
+ soundInfo->setChannels(size16);
+
+ //first sub-chunk (header) - Data (nsamplesPerSecond)
+ f.read((char*) &size32, 4);
++ size32 = letoh32(size32);
+ soundInfo->setsamplesPerSecond(size32);
+
+ //first sub-chunk (header) - Data (nAvgBytesPerSec) - Ignore
+ f.read((char*) &size32, 4);
++ size32 = letoh32(size32);
+
+ //first sub-chunk (header) - Data (blockAlign) - Ignore
+ f.read((char*) &size16, 2);
++ size16 = letoh16(size16);
+
+ //first sub-chunk (header) - Data (nsamplesPerSecond)
+ f.read((char*) &size16, 2);
++ size16 = letoh16(size16);
+ soundInfo->setBitsPerSample(size16);
+
+ if (soundInfo->getBitsPerSample() != 8 && soundInfo->getBitsPerSample()!=16){
+@@ -106,6 +115,7 @@
+
+ //second sub-chunk (samples) - Size
+ f.read((char*) &size32, 4);
++ size32 = letoh32(size32);
+ dataSize= size32;
+ soundInfo->setSize(dataSize);
+ }
+@@ -121,6 +131,11 @@
+
+ uint32 WavSoundFileLoader::read(int8 *samples, uint32 size){
+ f.read(reinterpret_cast<char*> (samples), size);
++ int32 *tmp = NULL;
++ tmp = (int32 *)samples;
++ for (unsigned int i = 0; i < size/4; ++i) {
++ tmp[i] = letoh32(tmp[i]);
++ }
+ return f.gcount();
+ }
+
+@@ -159,7 +174,7 @@
+
+ while(size>0){
+ int bytesRead= ov_read(vf, reinterpret_cast<char*> (samples), size,
+- 0, 2, 1, §ion);
++ bigendianp, 2, 1, §ion);
+ if(bytesRead==0){
+ break;
+ }
More information about the Pkg-games-commits
mailing list