mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
- more updates to support big endian
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include "command.h"
|
||||
#include "map_preview.h"
|
||||
#include "world.h"
|
||||
|
||||
#include "byte_order.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Graphics;
|
||||
@@ -359,6 +359,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||
if(readBytes != 1) {
|
||||
throw megaglest_runtime_error("Invalid map header detected for file: " + path);
|
||||
}
|
||||
fromEndianMapFileHeader(header);
|
||||
|
||||
if(next2Power(header.width) != header.width){
|
||||
throw megaglest_runtime_error("Map width is not a power of 2");
|
||||
@@ -408,6 +409,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
x = Shared::PlatformByteOrder::fromCommonEndian(x);
|
||||
|
||||
readBytes = fread(&y, sizeof(int32), 1, f);
|
||||
if(readBytes != 1) {
|
||||
@@ -415,6 +417,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
y = Shared::PlatformByteOrder::fromCommonEndian(y);
|
||||
|
||||
startLocations[i]= Vec2i(x, y)*cellScale;
|
||||
}
|
||||
@@ -433,6 +436,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
alt = Shared::PlatformByteOrder::fromCommonEndian(alt);
|
||||
|
||||
SurfaceCell *sc= getSurfaceCell(i, j);
|
||||
sc->setVertex(Vec3f(i*mapScale, alt / heightFactor, j*mapScale));
|
||||
@@ -449,6 +453,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
surf = Shared::PlatformByteOrder::fromCommonEndian(surf);
|
||||
|
||||
getSurfaceCell(i, j)->setSurfaceType(surf-1);
|
||||
}
|
||||
@@ -465,6 +470,7 @@ Checksum Map::load(const string &path, TechTree *techTree, Tileset *tileset) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",readBytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
objNumber = Shared::PlatformByteOrder::fromCommonEndian(objNumber);
|
||||
|
||||
SurfaceCell *sc= getSurfaceCell(toSurfCoords(Vec2i(i, j)));
|
||||
if(objNumber == 0) {
|
||||
|
@@ -823,7 +823,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
startLocations[i].x = Shared::PlatformByteOrder::toCommonEndian(startLocations[i].x);
|
||||
startLocations[i].x = Shared::PlatformByteOrder::fromCommonEndian(startLocations[i].x);
|
||||
|
||||
bytes = fread(&startLocations[i].y, sizeof(int32), 1, f1);
|
||||
if(bytes != 1) {
|
||||
@@ -831,7 +831,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
startLocations[i].y = Shared::PlatformByteOrder::toCommonEndian(startLocations[i].y);
|
||||
startLocations[i].y = Shared::PlatformByteOrder::fromCommonEndian(startLocations[i].y);
|
||||
}
|
||||
|
||||
//read Heights
|
||||
@@ -844,7 +844,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
cells[i][j].height = Shared::PlatformByteOrder::toCommonEndian(cells[i][j].height);
|
||||
cells[i][j].height = Shared::PlatformByteOrder::fromCommonEndian(cells[i][j].height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -857,7 +857,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
cells[i][j].surface = Shared::PlatformByteOrder::toCommonEndian(cells[i][j].surface);
|
||||
cells[i][j].surface = Shared::PlatformByteOrder::fromCommonEndian(cells[i][j].surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,7 +871,7 @@ void MapPreview::loadFromFile(const string &path) {
|
||||
snprintf(szBuf,8096,"fread returned wrong size = %zu on line: %d.",bytes,__LINE__);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
obj = Shared::PlatformByteOrder::toCommonEndian(obj);
|
||||
obj = Shared::PlatformByteOrder::fromCommonEndian(obj);
|
||||
|
||||
if (obj <= 10) {
|
||||
cells[i][j].object = obj;
|
||||
|
Reference in New Issue
Block a user