Created attachment 228676 [details]
patch for team.c (assumes other patches already applied)
I started out to fix a problem that turned out to be not a problem. On the way I found all manner of really bad things (tm). It was hard to fathom with the pre-c89 compatibility layer, but then it was also really bad code that assumed 32 bits (ish) with some assumption that quads were long long and pointers mixed in with ints.
Anyways... this cleans up most things, doesn't really change behaviour.