I am strugging to remember how to set up a linked list.
I have this structure:
Code: Select all
type obj
name as string
long_name as string
additional_desc as string
location as integer
weight as integer
size as integer
description as string
hold_size as integer
surface_size as integer 'if you can put something on it how large the surface is
holding as integer
surface as integer 'total size of things on surface
closed as ubyte '0 is closable,1 is closed,2 is lockable, 3 is locked
status as ubyte 'bit value bit 0 is in,1 is on (mutually exclusive), 2 is hidden, 4 is wearable, 5 is being worn,6 is carried
cloth_type as integer 'if its clothing relates to the tyep as follows
'1 is hat, 2 is body underwear, 3 is body mid layer (shirts), 4 is body upper (jumper), 5 is body outer (coat)
'6 is legs under, 7 is legs mid (trousers), 8 is legs outer (water proofs), 9 is socks, 10 is shoes
holds_list as string 'the numbers of the contained objects in the form <object><object>....<last object>
surface_list as string 'the numbers of the objects on its surface in the form <object><object>....<last object>
location as integer 'objects location (points to room or container)
next_object_ptr as integer 'pointer to next object in the list
objects_in_ptr as integer 'pointer to any objects inside this one
objects_on_ptr as integer 'pointer to any objects on this one
objects_under_ptr as integer 'pointer to any objects under this one
end type
I read the object's location etc for each one in a loop so each object will now have its location, but no links to any other objects in the same place and need some way of linking the objects together so that I have something like:
room ->object->object->object(n)
The only way I can figure it out is to have 2 loops like this in pseudocode
Code: Select all
loop a for each object_a
loop b for each object_b
if object_a.location=object_b.location then
if object_a.next_object_ptr =0 then
object_a.next_object_ptr=object_b
end loop b
end loop a
Here's that structure
Code: Select all
type rooms
long_desc as string
short_desc as string
directions as string
invalid as string
visited as integer
object_ptr as integer
end type
Thanks in advance.