glob2-devel
[Top][All Lists]
Advanced

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

Re: [glob2-devel] Cleanups...


From: Nuage
Subject: Re: [glob2-devel] Cleanups...
Date: Mon, 24 Jan 2005 20:18:09 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050122

Thank you for pointing out possible possible improvement of the code.

Here is some explaination of the code:

in Map.h:
protected:
        //Used for scheduling computation time.
        bool gradientUpdated[32][MAX_NB_RESSOURCES][2];

As written, this is used to schedule the computation of the ressource
gradients. Ressources gradient is currently the one of the most time
consuming computation. In order to make the game feeling smooth, the
idea is to make an idential amount of ressource gradient computation
on each tick. Currently we make exactly one ressource gradient
computation on each tick. (History: when they where slower, we did used
to make one gradient on 2 ticks).

This is done in Map.cpp
void Map::syncStep(Uint32 stepCounter)
currenlty at line 1204

Once a ressource gradient is computed, which can be uniquely identified
with "t", "r", "s", then the gradientUpdated[t][r][s] is set to "true".
Once they are all updated, they are all set back to "false". They are
all set to "false" when an external event occurs, like at the game
loading or creation.

Therfor, it can't by simplified with only one "bool resetgradients" as
you suggested. Your latest code suggestion (correction.diff) would
only compute one gradient ressouce: for the team[0], the ressource[0]
(#defined WOOD) ("wheat"), for the swimming[0] (non-swimming) units.

If you tested it shortly, you probably didn't noticed any bad behaviour.
It's not obvious why. To ensure fair and smooth start for each team, all
the ressources gradients are computed at the beggining (init/loading)
of a new game. And as far as the gradient are quite "flexible", you
won't notice any bad baheviour util a ressource is seriously consumed,
or the ressouce is removed from a place. But then the unit would go
to a place where there is no more ressource.

Just ask if something is not clear.

Thank you!
Nuage


simon schuler wrote:
I was a bit browsing through the code today, triing to understand the whole code. Sometimes the code isn't easy to understand, but that's normal for such a project... I found a lot of loops, which are (in my opinion) useless. I have attached a patch to remove some useless loops, and replace them with equivalent code.

Summary of the patch: I removed the bool gradientUpdated[32][MAX_NB_RESSOURCES][2] array and replaced it with equivalent faster code.

simon



------------------------------------------------------------------------

_______________________________________________
glob2-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/glob2-devel




reply via email to

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