Avoiding WithinStarlaneJumps via Effect Universe Objects

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
User avatar
Space Dragon
Posts: 411
Joined: Tue Sep 20, 2011 10:32 pm
Location: Halle (Saale)

Avoiding WithinStarlaneJumps via Effect Universe Objects

#1 Post by cami » Thu Sep 22, 2011 9:41 am

I was asked to make this remark from the WithinStarlaneJumps implementation thread a separate post, so here it goes.

Many effects apply to targets within a certain starlane range from their source. Instead of having each possible target search its neighborhood for sources that can affect it, the source objects could create a new kind of (invisible) "effect" object in all systems within range. Thus, only the source object needs to scan its neighborhood, not every potential target. The source object should keep references to the effect objects, with farthest sorted first, so it can easily extend or shrink the effect range without re-scanning its neighborhood. At the very least, the effect objects must keep a reference to the source, so that they can be removed by another neighborhood scan when the source loses the effect (and it also avoids having to store all the other information about the effect in the object).

The only advantage of this strategy over the proposed improvement of WithinStarlaneJumps is that it avoids re-scanning the neighborhood of the "sources" every turn.
Yesterday, we were still on the brink. Fortunately, today we have come one step further.

Post Reply