[SCM] transportation simulator branch, master, updated. upstream/100.0-31-gee400ca
Ansgar Burchardt
ansgar at 2008.43-1.org
Mon Aug 18 20:39:12 UTC 2008
The following commit has been merged in the master branch:
commit ee400cae6d7647053ef99a734da10decce82868a
Author: Ansgar Burchardt <ansgar at 2008.43-1.org>
Date: Mon Aug 18 21:22:34 2008 +0200
Fix makeobj portability issues (Closes: #493409)
* Fix makeobj portability issues (Closes: #493409)
+ 01_png.patch: png_uint_32 might actually be 64bit on some archs
(thanks to Peter Green)
+ 02_makeobj_fixes.patch, 03_makeobj_cleanup.patch: Add proper
serialization code instead of dumping in-memory objects
(thanks to Peter de Wachter)
diff --git a/debian/changelog b/debian/changelog
index baa17a7..c10a78e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,12 @@ simutrans (100.0+ds1-3) UNRELEASED; urgency=low
* Omit translations for be (Belaruskaja), cn (Sim. Chinese), id (Bahasa),
no (Norsk) because they are very incomplete or otherwise broken
(Closes: #481266)
+ * Fix makeobj portability issues (Closes: #493409)
+ + 01_png.patch: png_uint_32 might actually be 64bit on some archs
+ (thanks to Peter Green)
+ + 02_makeobj_fixes.patch, 03_makeobj_cleanup.patch: Add proper
+ serialization code instead of dumping in-memory objects
+ (thanks to Peter de Wachter)
-- Ansgar Burchardt <ansgar at 43-1.org> Mon, 18 Aug 2008 20:07:36 +0200
diff --git a/debian/patches/01_png.patch b/debian/patches/01_png.patch
new file mode 100644
index 0000000..a8a2ce6
--- /dev/null
+++ b/debian/patches/01_png.patch
@@ -0,0 +1,19 @@
+--- 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");
diff --git a/debian/patches/02_makeobj_fixes.patch b/debian/patches/02_makeobj_fixes.patch
new file mode 100644
index 0000000..b8fe6ad
--- /dev/null
+++ b/debian/patches/02_makeobj_fixes.patch
@@ -0,0 +1,112 @@
+--- 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);
+
diff --git a/debian/patches/03_makeobj_cleanup.patch b/debian/patches/03_makeobj_cleanup.patch
new file mode 100644
index 0000000..979f43a
--- /dev/null
+++ b/debian/patches/03_makeobj_cleanup.patch
@@ -0,0 +1,379 @@
+--- a/besch/writer/obj_node.cc
++++ b/besch/writer/obj_node.cc
+@@ -8,14 +8,13 @@
+ uint32 obj_node_t::free_offset; // next free offset in file
+
+
+-obj_node_t::obj_node_t(obj_writer_t* writer, int size, obj_node_t* parent, bool adjust)
++obj_node_t::obj_node_t(obj_writer_t* writer, int size, obj_node_t* parent)
+ {
+ this->parent = parent;
+- this->adjust = adjust;
+
+ desc.type = writer->get_type();
+ desc.children = 0;
+- desc.size = adjust ? (size - sizeof(obj_besch_t)) : size;
++ desc.size = size;
+ write_offset = free_offset + sizeof(desc);
+ free_offset = write_offset + desc.size;
+ }
+@@ -39,21 +38,12 @@
+
+ void obj_node_t::write_data(FILE* fp, const void* data)
+ {
+- write_data_at(fp, data, 0, adjust ? desc.size + 4 : desc.size);
++ write_data_at(fp, data, 0, desc.size);
+ }
+
+
+ void obj_node_t::write_data_at(FILE* fp, const void* data, int offset, int size)
+ {
+- if (adjust) {
+- if (offset < sizeof(obj_besch_t)) {
+- data = static_cast<const char*>(data) + sizeof(obj_besch_t) - offset;
+- size -= sizeof(obj_besch_t) - offset;
+- offset = 0;
+- } else {
+- offset -= sizeof(obj_besch_t);
+- }
+- }
+ if (offset < 0 || size < 0 || offset + size > desc.size) {
+ char reason[1024];
+ sprintf(reason, "invalid parameters (offset=%d, size=%d, obj_size=%d)", offset, size, desc.size);
+--- a/besch/writer/obj_node.h
++++ b/besch/writer/obj_node.h
+@@ -16,7 +16,6 @@
+
+ uint32 write_offset; // Start of node data in file (after node.desc)
+ obj_node_t* parent;
+- bool adjust; // a normal besch structure start with 4 extra bytes
+
+ public:
+ // set_start_offset() - set offset of first node in file
+@@ -27,7 +26,7 @@
+ // writer object, that writes the node to the file
+ // size space needed for node data
+ // parent parent node
+- obj_node_t(obj_writer_t* writer, int size, obj_node_t* parent, bool adjust);
++ obj_node_t(obj_writer_t* writer, int size, obj_node_t* parent);
+
+ // Write the complete node data to the file
+ void write_data(FILE* fp, const void* data);
+--- a/besch/writer/bridge_writer.cc
++++ b/besch/writer/bridge_writer.cc
+@@ -12,7 +12,7 @@
+
+ void bridge_writer_t::write_obj(FILE* outfp, obj_node_t& parent, tabfileobj_t& obj)
+ {
+- obj_node_t node(this, 22, &parent, false);
++ obj_node_t node(this, 22, &parent);
+
+ uint8 wegtyp = get_waytype(obj.get("waytype"));
+ uint16 topspeed = obj.get_int("topspeed", 999);
+--- a/besch/writer/building_writer.cc
++++ b/besch/writer/building_writer.cc
+@@ -18,7 +18,7 @@
+ {
+ haus_tile_besch_t besch;
+
+- obj_node_t node(this, 7, &parent, false);
++ obj_node_t node(this, 7, &parent);
+
+ besch.phasen = 0;
+ for (int i = 0; i < seasons; i++) {
+@@ -68,7 +68,7 @@
+ haus_besch_t besch;
+
+ // Hajo: take care, hardocded size of node on disc here!
+- obj_node_t node(this, 26, &parent, false);
++ obj_node_t node(this, 26, &parent);
+
+ write_head(fp, node, obj);
+
+--- a/besch/writer/citycar_writer.cc
++++ b/besch/writer/citycar_writer.cc
+@@ -12,7 +12,7 @@
+ stadtauto_besch_t besch;
+ int i;
+
+- obj_node_t node(this, 10, &parent, false);
++ obj_node_t node(this, 10, &parent);
+
+ besch.gewichtung = obj.get_int("distributionweight", 1);
+
+--- a/besch/writer/crossing_writer.cc
++++ b/besch/writer/crossing_writer.cc
+@@ -38,7 +38,7 @@
+ }
+
+ // ok, node can be allocated now
+- obj_node_t node(this, total_len, &parent, false);
++ obj_node_t node(this, total_len, &parent);
+ write_head(fp, node, obj);
+
+ // Hajo: version number
+--- a/besch/writer/factory_writer.cc
++++ b/besch/writer/factory_writer.cc
+@@ -12,7 +12,7 @@
+ {
+ field_besch_t besch;
+ memset(&besch, 0, sizeof(besch));
+- obj_node_t node(this, 11, &parent, false);
++ obj_node_t node(this, 11, &parent);
+
+ xref_writer_t::instance()->write_obj(outfp, node, obj_field, s, true);
+
+@@ -38,7 +38,7 @@
+ {
+ rauch_besch_t besch;
+ memset(&besch, 0, sizeof(besch));
+- obj_node_t node(this, 10, &parent, false);
++ obj_node_t node(this, 10, &parent);
+
+ xref_writer_t::instance()->write_obj(outfp, node, obj_smoke, obj.get("smoke"), true);
+ besch.pos_off = obj.get_koord("smoketile", koord(0, 0));
+@@ -57,7 +57,7 @@
+
+ void factory_product_writer_t::write_obj(FILE* outfp, obj_node_t& parent, int capacity, int factor, const char* warename)
+ {
+- obj_node_t node(this, sizeof(uint16) * 3, &parent, false);
++ obj_node_t node(this, sizeof(uint16) * 3, &parent);
+
+ xref_writer_t::instance()->write_obj(outfp, node, obj_good, warename, true);
+
+@@ -77,7 +77,7 @@
+ {
+ fabrik_lieferant_besch_t besch;
+
+- obj_node_t node(this, 8, &parent, false);
++ obj_node_t node(this, 8, &parent);
+
+ besch.anzahl = count;
+ besch.kapazitaet = capacity;
+@@ -117,7 +117,7 @@
+ }
+ besch.pax_level = obj.get_int("pax_level", 12);
+
+- obj_node_t node(this, 18, &parent, false);
++ obj_node_t node(this, 18, &parent);
+
+ obj.put("type", "fac");
+
+--- a/besch/writer/good_writer.cc
++++ b/besch/writer/good_writer.cc
+@@ -9,7 +9,7 @@
+
+ void good_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj)
+ {
+- obj_node_t node(this, 10, &parent, false);
++ obj_node_t node(this, 10, &parent);
+
+ write_head(fp, node, obj);
+ text_writer_t::instance()->write_obj(fp, node, obj.get("metric"));
+--- 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, 0, &parent, false);
++ obj_node_t node(this, 0, &parent);
+
+ write_head(fp, node, obj);
+
+--- a/besch/writer/groundobj_writer.cc
++++ b/besch/writer/groundobj_writer.cc
+@@ -11,7 +11,7 @@
+
+ void groundobj_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj)
+ {
+- obj_node_t node(this, 16, &parent, false); /* false, because we write this ourselves */
++ obj_node_t node(this, 16, &parent);
+ write_head(fp, node, obj);
+
+ // Hajodoc: Preferred height of this tree type
+--- a/besch/writer/image_writer.cc
++++ b/besch/writer/image_writer.cc
+@@ -324,7 +324,7 @@
+
+ #ifdef IMG_VERSION0
+ // ok, need to be changed to hand mode ...
+- obj_node_t node(this, 12 + (bild.len * sizeof(uint16)), &parent, false);
++ obj_node_t node(this, 12 + (bild.len * sizeof(uint16)), &parent);
+
+ // to avoid any problems due to structure changes, we write manually the data
+ node.write_uint8 (outfp, bild.x, 0);
+@@ -343,7 +343,7 @@
+ }
+ #else
+ // ok, need to be changed to hand mode ...
+- obj_node_t node(this, 10 + (bild.len * sizeof(uint16)), &parent, false);
++ obj_node_t node(this, 10 + (bild.len * sizeof(uint16)), &parent);
+
+ // to avoid any problems due to structure changes, we write manually the data
+ node.write_uint16(outfp, bild.x, 0);
+--- a/besch/writer/imagelist2d_writer.cc
++++ b/besch/writer/imagelist2d_writer.cc
+@@ -10,7 +10,7 @@
+ {
+ bildliste2d_besch_t besch;
+
+- obj_node_t node(this, 4, &parent, false);
++ obj_node_t node(this, 4, &parent);
+
+ slist_iterator_tpl<slist_tpl<cstring_t> > iter(keys);
+
+--- a/besch/writer/imagelist_writer.cc
++++ b/besch/writer/imagelist_writer.cc
+@@ -11,7 +11,7 @@
+ {
+ bildliste_besch_t besch;
+
+- obj_node_t node(this, 4, &parent, false);
++ obj_node_t node(this, 4, &parent);
+
+ slist_iterator_tpl<cstring_t> iter(keys);
+
+--- 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, 4, &parent, false);
++ obj_node_t node(this, 4, &parent);
+
+ write_head(fp, node, obj);
+
+--- a/besch/writer/roadsign_writer.cc
++++ b/besch/writer/roadsign_writer.cc
+@@ -11,7 +11,7 @@
+
+ void roadsign_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj)
+ {
+- obj_node_t node(this, 14, &parent, false); /* false, because we write this ourselves */
++ obj_node_t node(this, 14, &parent);
+
+ // Hajodoc: Preferred height of this tree type
+ // Hajoval: int (useful range: 0-14)
+--- a/besch/writer/root_writer.cc
++++ b/besch/writer/root_writer.cc
+@@ -48,7 +48,7 @@
+ printf("writing file %s\n", filename);
+ write_header(outfp);
+
+- node = new obj_node_t(this, 0, NULL, false);
++ node = new obj_node_t(this, 0, NULL);
+ }
+
+ for( int i=0; i==0 || i<argc; i++ ) {
+@@ -86,7 +86,7 @@
+ printf(" writing file %s\n", (const char*)name);
+ write_header(outfp);
+
+- node = new obj_node_t(this, 0, NULL, false);
++ node = new obj_node_t(this, 0, NULL);
+ }
+ obj_writer_t::write(outfp, *node, obj);
+
+--- a/besch/writer/skin_writer.cc
++++ b/besch/writer/skin_writer.cc
+@@ -31,7 +31,7 @@
+
+ skin_besch_t besch;
+
+- obj_node_t node(this, 0, &parent, false);
++ obj_node_t node(this, 0, &parent);
+
+ write_head(fp, node, obj);
+
+--- 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, false);
++ obj_node_t node(this, 4, &parent);
+
+ write_head(fp, node, obj);
+
+--- a/besch/writer/text_writer.cc
++++ b/besch/writer/text_writer.cc
+@@ -11,7 +11,7 @@
+ }
+ int len = strlen(text);
+
+- obj_node_t node(this, len + 1, &parent, false);
++ obj_node_t node(this, len + 1, &parent);
+
+ node.write_data(outfp, text);
+ node.write(outfp);
+--- a/besch/writer/tree_writer.cc
++++ b/besch/writer/tree_writer.cc
+@@ -11,7 +11,7 @@
+
+ void tree_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& obj)
+ {
+- obj_node_t node(this, 6, &parent, false); /* false, because we write this ourselves */
++ obj_node_t node(this, 6, &parent);
+ write_head(fp, node, obj);
+
+ // Hajodoc: Preferred height of this tree type
+--- a/besch/writer/tunnel_writer.cc
++++ b/besch/writer/tunnel_writer.cc
+@@ -14,7 +14,7 @@
+ {
+ int pos, i;
+
+- obj_node_t node(this, 20, &parent, false);
++ obj_node_t node(this, 20, &parent);
+
+ uint32 topspeed = obj.get_int("topspeed", 999);
+ uint32 preis = obj.get_int("cost", 0);
+--- a/besch/writer/vehicle_writer.cc
++++ b/besch/writer/vehicle_writer.cc
+@@ -76,7 +76,7 @@
+ }
+ }
+
+- obj_node_t node(this, total_len, &parent, false);
++ obj_node_t node(this, total_len, &parent);
+
+ write_head(fp, node, obj);
+
+--- a/besch/writer/way_obj_writer.cc
++++ b/besch/writer/way_obj_writer.cc
+@@ -21,8 +21,7 @@
+ };
+ int ribi, hang;
+
+- // Hajo: node size is 24 bytes
+- obj_node_t node(this, 20, &parent, false);
++ obj_node_t node(this, 20, &parent);
+
+
+ // Hajo: Version needs high bit set as trigger -> this is required
+--- a/besch/writer/way_writer.cc
++++ b/besch/writer/way_writer.cc
+@@ -22,7 +22,7 @@
+ int ribi, hang;
+
+ // Hajo: node size is 25 bytes
+- obj_node_t node(this, 26, &parent, false);
++ obj_node_t node(this, 26, &parent);
+
+
+ // Hajo: Version needs high bit set as trigger -> this is required
+--- a/besch/writer/xref_writer.cc
++++ b/besch/writer/xref_writer.cc
+@@ -16,8 +16,7 @@
+ sizeof(char) + // Fatal-Flag
+ sizeof(obj_type) + // type of dest node
+ len + 1, // 0-terminated name of dest node
+- &parent,
+- false
++ &parent
+ );
+
+ char c = fatal ? 1 : 0;
diff --git a/debian/patches/series b/debian/patches/series
index e444917..af77259 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,6 @@ path-for-game-data.diff
config.diff
fix_makeobj_compilation.diff
fix_casts.diff
+01_png.patch
+02_makeobj_fixes.patch
+03_makeobj_cleanup.patch
--
transportation simulator
More information about the Pkg-games-commits
mailing list