Lokasenna
Posts: 9297
Joined: 3/3/2012 From: Iowan in MD/DC Status: offline
|
quote:
ORIGINAL: Don Bowen quote:
ORIGINAL: Alfred quote:
ORIGINAL: Lokasenna quote:
ORIGINAL: Don Bowen quote:
ORIGINAL: Lokasenna I do think it's probably a case of using the wrong sign or a + instead of a - in the code. Nope, it ain't. Have you got inside knowledge?! It's the most obvious/simplest explanation for why 'next ship' goes backwards, unless to the devs backwards was really forwards... He most definitely has inside knowledge. He is the man who coded that part of AE. Alfred Actually this mechanism is residual from original WITP. Gary Grigsby or some other pioneer did the work. It is a simple link list, coded for speed. For those of you not familiar with a link list, it works like this: 1. A pointer in the TF (or base) record points (links) to the first ship added to the TF (or base). 2. A link in the ship record points to next record, but not the next record added. 3. Since unsorted link lists are inherently push-down, the pointer in the TF record is changed to point to the next record added and that record (the next one) acquires the pointer to the first record (ship) added. 4. All this is duplicated for next and previous to allow rapid direct access of either the next or previous ship. 5. Traversing the entire link list for a search or other operation (like a sort) is time consuming as one must access multiple records to read the entire list. A sorted link list would perform this operation, but at considerable expense in time. Also, only a single sort order could be specified - the extended sorts available on TF, Base, and other ship lists would not be available. As an example (looking at next path only for this example): 1. First ship is added to TF. TF points to ship 1, ship 1 pointer is null (empty). 2. Second ship is added to TF. TF pointer is changed to second ship and second ship acquires the previous TF pointer (to first ship). First ship's pointer stays null (it is never even touched). 3. Third ship is added. TF now points to third ship, third to second, second to fire. 4. Etc. ad nauseum. As you can see, addition of ships is direct and easy. It is not necessary to search any of the existing ship records. Only the TF record and the new ship are involved. And, as is evident, a next record process will always return the ships in the inverse order of their addition to the TF. Neat, thanks Don. Makes sense. I know from experience that making linked lists "backwards" is a PITA and not worth it. It's been too long since I coded anything; now I feel a little silly about the "backwards" phrase. And for those jumping on me, no I didn't know. I did look on the left there, but there's nothing on there about developing. I don't know about the rest of you, but in my world you look at the credits when you've "finished" a game...kind of a heuristic from the arcade days.
|