adonthell-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-devel] Speeding up schedules


From: Kai Sterker
Subject: [Adonthell-devel] Speeding up schedules
Date: Tue, 30 Apr 2002 12:04:32 +0200

As far as I remember from the tests Alex made way back, those 14
schedule scripts running in Waste's Edge consume nearly as much CPU as
the renderer. But if you take a closer look at them, there is much room
for speed-ups.

The thing to change are all these 

    blah = self.myself.get_val ("blah") - 1
    self.myself.set_val ("blah", blah)

Code like that is executed 50 or more times per second for every NPC!
Fact is, this code originates from a time where the scripts weren't
classes. There was no other way to store such counters other than the
NPC itself. But now we could easily store stuff like this in class
variables, which would be way more efficient.

The only problem that comes up is saving and restoring the exact state
of a NPC. For that purpose it _does_ make sense to store those things
with the NPC. In the schedule constructor, the values can be read once
and stored in class variables. In the destructor they are written back
into the NPC. However, we'd also need a save_state function that writes
them to the NPC before the NPC is saved.

That seems to be the easiest solution to me. And it would require only
little changes to existing code. I'm not sure we should change the
current scripts at all, but those scripts we are going to write for v0.4
should make use of this optimization.

So if you agree, I'll integrate this into the schedule manager proposed
in my last mail. (But I might make a few tests with Waste's Edge
nontheless).

Kai



reply via email to

[Prev in Thread] Current Thread [Next in Thread]