Network protocol incompatibility due to WORDS_NEED_ALIGNMENT
Hi there.

The following applies to both d1x and d2x 0.58.1 (and probably earlier versions, too).
I got a bug report about erros connecting from RPI builds to normal games on desktop machines:
d1x-rebirth: main/multi.c:309: map_objnum_local_to_remote: Assertion 'remote_objnum > -1' failed.

It turns out that the object_rw structure which is dircelty used in the network protocol has compile time depenencies to the WORDS_NEED_ALIGNMENT option, which the RPi build is using. There are 2 padding words inserted in the WORDS_NEED_ALIGNMENT case, which of course totally screw up  parsing the network packets if two different builds of the game try to interact.

For the RPI, the WORDS_NEED_ALIGNEMT is actually only needed for the floating-point unit during rendering, so I was able to make a quick and dirty workaround as follows:

diff -Naur d1x-rebirth_v0.58.1-src/main/object.h d1x-rebirth_v0.58.1-src-fix/main/object.h
--- d1x-rebirth_v0.58.1-src/main/object.h       2013-04-22 12:02:58.000000000 +0200
+++ d1x-rebirth_v0.58.1-src-fix/main/object.h   2015-01-10 19:17:29.195307582 +0100
@@ -295,7 +295,7 @@
        int     signature;      // Every object ever has a unique signature...
        ubyte   type;           // what type of object this is... robot, weapon, hostage, powerup, fireball
        ubyte   id;             // which form of object...which powerup, robot, etc.
+#if defined(WORDS_NEED_ALIGNMENT) && !defined(RPI)
        short   pad;
        short   next,prev;      // id of next and previous connected object in Objects, -1 = no connection
@@ -338,7 +338,7 @@
                struct vclip_info      vclip_info;     // vclip
        } __pack__ rtype;

+#if defined(WORDS_NEED_ALIGNMENT) && !defined(RPI)
        short   pad2;
} __pack__ object_rw;

I think this whole WORDS_NEED_ALIGNMENT stuff needs some cleanup. I don't know if any architecture we care about actually even uses these code paths at all, besides the RPi.
In the RPI's case, only a fraction of the code paths enabled by WORDS_NEED_ALIGNMENT are actually required, so this could be reduced.

However, I think it would best to base any improvements on the current unification branch kp is working on. I don't know what is the status of the RPi support in that branch, but I'll have a look soon and will try to build current HEAD there.
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry
Unfortunately, object_rw is used both in netgame messages and in the savegame file.  If you add/remove the padding fields, you break compatibility with both of them.  This presents a nasty problem, since fixing it means RPI users lose access to old savegames and not fixing it means they cannot share savegames with unaligned users.

This type of problem is why I wrote the new serialization system.  Unfortunately, many things have not yet been converted to use it.  The bug you describe probably affects unification too, since object_rw has not been touched.
Thank you for pointing this out.That is very unfortunate indeed. OTOH, it is a good thing if this patch stops the RPi build from creating savegames which are incompatible with the rest of the world. I'll really have to look at all the places where WORDS_NEED_ALIGNMENT is used, maybe there are some other issues buried there.

As for the old savegames, I think it should be not too much hassle to write some converter utility. So if someone really needs to rescue such savegames, please drop me a note.
"Perfection is attained not when there is nothing more to add, but when there is nothing more to remove." -- Antoine de Saint Exupéry

Forum Jump:

Users browsing this thread: 1 Guest(s)