Bug#493409: fix for simutrans-makeobj
Peter De Wachter
pdewacht at gmail.com
Sun Aug 17 13:34:50 UTC 2008
Package: simutrans-makeobj
Followup-For: Bug #493409
With the attached series of patches I get identical results on i386,
amd64 and mips.
00_big_endian.patch
This uses the <endian.h> header to detect big-endian systems. This
replaces the hack in the Makefile (seriously, powerpc isn't the only
big-endian arch...). I don't think <endian.h> is portable, so this
probably isn't a suitable solution for upstream.
01_png.patch
Peter Green's PNG reader fix.
02_makeobj_fixes.patch
makeobj writes some data by dumping in-memory object instances to
disk. This is obviously not portable, so this needed to be
rewritten. It looks like Hajo fixed most of this in the past, I did
the rest.
03_makeobj_cleanup.patch
After the last patch the weird logic in obj_node_t isn't needed
anymore, so it can be removed. (This is strictly cleanup, it isn't
necessary for makeobj to run correctly.)
-------------- next part --------------
--- a/simtypes.h
+++ b/simtypes.h
@@ -8,6 +8,13 @@
#ifndef SIMTYPES_H
#define SIMTYPES_H
+#include <endian.h>
+#undef LITTLE_ENDIAN //endian.h gives these definitions we don't want
+#undef BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
+ #define BIG_ENDIAN
+#endif
+
#if defined _MSC_VER
# if _MSC_VER <= 1200
# error "Simutrans cannot be compiled with Visual C++ 6.0 or earlier."
-------------- next part --------------
--- a/utils/dr_rdpng.c
+++ b/utils/dr_rdpng.c
@@ -48,11 +48,15 @@
png_read_info(png_ptr, info_ptr);
+ //png_uint_32 is 64 bit on some architectures!
+ png_uint_32 widthpu32,heightpu32;
png_get_IHDR(
png_ptr, info_ptr,
- width, height, &bit_depth, &color_type,
+ &widthpu32, &heightpu32, &bit_depth, &color_type,
&interlace_type, NULL, NULL
);
+ *width = widthpu32;
+ *height = heightpu32;
if (*height % base_img_size != 0 || *width % base_img_size != 0) {
printf("read_png: Invalid image size.\n");
-------------- next part --------------
--- a/besch/writer/factory_writer.cc
+++ b/besch/writer/factory_writer.cc
@@ -38,14 +38,19 @@
{
rauch_besch_t besch;
memset(&besch, 0, sizeof(besch));
- obj_node_t node(this, sizeof(besch), &parent, true);
+ obj_node_t node(this, 10, &parent, false);
xref_writer_t::instance()->write_obj(outfp, node, obj_smoke, obj.get("smoke"), true);
besch.pos_off = obj.get_koord("smoketile", koord(0, 0));
besch.xy_off = obj.get_koord("smokeoffset", koord(0, 0));
besch.zeitmaske = obj.get_int( "smokespeed", 0);
- node.write_data(outfp, &besch);
+ node.write_sint16(outfp, besch.pos_off.x, 0);
+ node.write_sint16(outfp, besch.pos_off.y, 2);
+ node.write_sint16(outfp, besch.xy_off.x, 4);
+ node.write_sint16(outfp, besch.xy_off.x, 6);
+ node.write_sint16(outfp, besch.zeitmaske, 8);
+
node.write(outfp);
}
@@ -72,7 +77,7 @@
{
fabrik_lieferant_besch_t besch;
- obj_node_t node(this, sizeof(besch), &parent, true);
+ obj_node_t node(this, 8, &parent, false);
besch.anzahl = count;
besch.kapazitaet = capacity;
@@ -80,7 +85,11 @@
xref_writer_t::instance()->write_obj(outfp, node, obj_good, warename, true);
- node.write_data(outfp, &besch);
+ node.write_uint16(outfp, besch.kapazitaet, 0);
+ node.write_uint16(outfp, besch.anzahl, 2);
+ node.write_uint16(outfp, besch.verbrauch, 4);
+ node.write_uint16(outfp, 0, 6); //dummy, unused (and uninitialized in past versions)
+
node.write(outfp);
}
--- a/besch/writer/ground_writer.cc
+++ b/besch/writer/ground_writer.cc
@@ -10,7 +10,7 @@
{
grund_besch_t besch;
- obj_node_t node(this, sizeof(besch), &parent, true);
+ obj_node_t node(this, 0, &parent, false);
write_head(fp, node, obj);
@@ -37,6 +37,5 @@
}
imagelist2d_writer_t::instance()->write_obj(fp, node, keys);
- node.write_data(fp, &besch);
node.write(fp);
}
--- a/besch/writer/pedestrian_writer.cc
+++ b/besch/writer/pedestrian_writer.cc
@@ -12,7 +12,7 @@
fussgaenger_besch_t besch;
int i;
- obj_node_t node(this, sizeof(besch), &parent, true);
+ obj_node_t node(this, 4, &parent, false);
write_head(fp, node, obj);
@@ -33,6 +33,8 @@
}
imagelist_writer_t::instance()->write_obj(fp, node, keys);
- node.write_data(fp, &besch);
+ node.write_uint16(fp, besch.gewichtung, 0);
+ node.write_uint16(fp, 0, 2); //dummy, unused (and uninitialized in past versions)
+
node.write(fp);
}
--- a/besch/writer/skin_writer.cc
+++ b/besch/writer/skin_writer.cc
@@ -31,12 +31,11 @@
skin_besch_t besch;
- obj_node_t node(this, sizeof(besch), &parent, true);
+ obj_node_t node(this, 0, &parent, false);
write_head(fp, node, obj);
imagelist_writer_t::instance()->write_obj(fp, node, imagekeys);
- node.write_data(fp, &besch);
node.write(fp);
}
--- a/besch/writer/sound_writer.cc
+++ b/besch/writer/sound_writer.cc
@@ -7,7 +7,7 @@
void sound_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj)
{
- obj_node_t node(this, 4, &parent, true);
+ obj_node_t node(this, 4, &parent, false);
write_head(fp, node, obj);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 03_makeobj_cleanup.patch
Type: text/x-c++
Size: 10868 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-games-devel/attachments/20080817/b8ffd7d9/attachment.bin
More information about the Pkg-games-devel
mailing list