[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [glob2-devel] I'm confused by the code in NewNicowar::control_attack
From: |
Joe Wells |
Subject: |
Re: [glob2-devel] I'm confused by the code in NewNicowar::control_attacks |
Date: |
Sat, 11 Aug 2007 07:51:57 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
"Bradley Arsenault" <address@hidden> writes:
> On 8/10/07, Joe Wells <address@hidden> wrote:
>
> "Bradley Arsenault" <address@hidden> writes:
>
> gdb says b is NULL after this command, so get_building is clearly
> returning NULL.
>
>
> Yes, its being given an invalid input somehow.
>
> First, am I correct in understanding that b is actually supposed to be
> an attack flag (not a real building)?
>
> b is supposed to be an attack flag, because the I that is used to
> get_buildings
> comes from the vector attack_flags.
The i that is used is an _index_ of the vector attack_flags, not
something in one of the vector's slots. The code looks like this:
for(int i=0; i<attack_flags.size(); ++i)
{
Building* b = echo.get_building_register().get_building(i);
...
}
I am guessing from what you say that it should look like this instead:
for(int i=0; i<attack_flags.size(); ++i)
{
Building* b = echo.get_building_register().get_building(attack_flags[i]);
...
}
Am I right?
> Is it always the case that the building register contains only attack
> flags? Otherwise why should entries 0, 1, 2, etc., be guaranteed to
> be only attack flags and not also other buildings that are being
> managed?
>
> The difference between Echo and the actual game is that every building is
> given
> a unique ID for the entire game. Rather than the GID's, which can be re-used,
> the echo ID's are only used once for a building. I store those ID's in the
> vector attack_flags and retrieve them in this function. Somehow, the vector
> contains an ID for a flag that has already been destroyed. 0, 1, 2, and
> probably up to 20 are most likely normal buildings cause thats what nicowar
> constructs first, somewhere in there would be a couple exploration flags. A
> flag is a building the game engines perspective, except in a few special
> circumstances.
The reason why I asked about 0, 1, 2, etc., is that these are the
values this loop actually uses. See comments above.
The crash is with i == 0.
Yes, my analysis must be right. What is happening is that it crashes
when I start killing the buildings with small echo numbers. That's
because it's doing get_building(i) instead of
get_building(attack_flags[i]).
> So b->locked[true] indicates whether the attack flag is accessible by
> land *or* water, while b->locked[false] indicates whether it is
> accessible by land only? Right?
>
> Yes.
>
> For what it is worth, this happened when I had wiped out about 1/3 of
> Nicowar's base area. Would that cause Nicowar to delete one of its
> attack flags in a strange way?
This is the cause. I killed a building with a small echo number like
0 or 1.
> Hmm, it might have something to do with it, although doubtful. It might have
> removed the flag with that is_locked override right there since i've never
> actually seen nicowar do it in action (despite much hard testing)
--
Joe