The Ur-Quan Masters Discussion Forum

The Ur-Quan Masters Re-Release => Technical Issues => Topic started by: Elvish Pillager on February 23, 2007, 07:42:09 pm



Title: Problem with too many elements when modding UQM
Post by: Elvish Pillager on February 23, 2007, 07:42:09 pm
Various times while developing my mod, I caused large amounts of shot to created, but at some point, it would stop making more shots, and each time would say:

AllocLink(): No more elements

I found where this is in the code, but I have been unable to track it to a cause... I would quite like a more unlimited amount of objects in my arena!


Title: Re: Problem with too many elements when modding UQM
Post by: meep-eep on February 23, 2007, 08:07:38 pm
The code works with pre-allocated lists of Elements, probably so that it can make certain guarantees about memory usage. If there are no more elements available, some things just won't show up.
The elements are allocated when InitQueue() is called. The one you're probably running into is called from InitContexts(). If you just want more elements, you can simply change the '100' into something you like better. If you want the game to dynamically allocate more elements, you'll have to modify the displist code yourself.


Title: Re: Problem with too many elements when modding UQM
Post by: Elvish Pillager on February 23, 2007, 08:33:58 pm
Increasing the number to more than 255 causes the game to crash on startup:

*** glibc detected *** ./uqm: malloc(): memory corruption: 0x10563968 ***
======= Backtrace: =========
/lib/libc.so.6[0xfb9c4a4]
/lib/libc.so.6[0xfb9eaa0]
/lib/libc.so.6(malloc+0xc4)[0xfba08a4]
./uqm[0x100a7d98]
./uqm[0x100a7f44]
./uqm[0x100bb7b0]
./uqm[0x100bb26c]
./uqm[0x1007bc04]
./uqm[0x10015af0]
./uqm[0x1004661c]
./uqm[0x100bc208]
/usr/lib/libSDL-1.2.so.0[0xff8f348]
/usr/lib/libSDL-1.2.so.0[0xffcad28]
/lib/libpthread.so.0[0xff4b9bc]
/lib/libc.so.6(__clone+0x84)[0xfbf7cb4]


Title: Re: Problem with too many elements when modding UQM
Post by: meep-eep on February 23, 2007, 08:52:58 pm
It looks like the size is stored in a single byte (num_objects in struct queue). You could change the type (you'd also need to change AllocQueueTableTab.
But it looks like the code actually has a mode to allocate these links dynamically after all. Just don't #define QUEUE_TABLE in displist.h.


Title: Re: Problem with too many elements when modding UQM
Post by: Elvish Pillager on February 23, 2007, 09:07:08 pm
Cool, thanks.