[freeciv-ai] Re: ai move cleanup #4
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, 8 Aug 2002, Gregory Berkolaiko wrote:
> Issue 1:
>
> In ai_unit_bodyguard_move:
> +if (bodyguard->moves_left < map_move_cost(bodyguard, x, y)) {
> + /* should generally should not happen */
> + freelog(LOG_VERBOSE, "%s: %s left its %s bodyguard behind at (%d,%d)!",
> + pplayer->name, unit_type(punit)->name,
> + unit_type(bodyguard)->name, x, y);
> + return;
> +}
>
> If bodyguard->moves_left > 0, the bodyguard can still attempt to move!
Right.
(Interestingly, if I read the code right, a unit with move == 0 can still
attack. Is this correct or a misreading or a bug? Seems the client stops
it from happening, but a modified client should be able to do it.)
> Issue 2:
>
> In has_bodyguard, after punit->ai.bodyguard = 0;
> Can we have a freelog(LOG_DEBUG, "%s's bodyguard has disappeared!");
> ?
Ok.
> Issue 3:
>
> In do_unit_goto, why do you remove
>
> - /* Don't attack more than once per goto */
> - if (penemy && !pplayer->ai.control) { /* Should I cancel for ai's too? */
> - punit->activity = ACTIVITY_IDLE;
> - send_unit_info(NULL, punit);
> - return GR_FOUGHT;
> - }
> -
This check is done in ai_unit_move. The function returns FALSE, and
do_unit_goto returns GR_FAILED. Just as it was before, except then it was
handle_unit_move_request that did it. The AI code doesn't check for
GR_FOUGHT and the above code would (in theory) never be called.
> In any case, can you move the declarations of penemy, x, y and dir inside
> the do-while loop?
Yes.
> Issue 4: (a nitpick)
> in handle_unit_move_request after /******* ok now move the unit *******/
>
> +if (can_unit_move_to_tile_with_notify(punit, dest_x, dest_y, igzoc)
> + && try_move_unit(punit, dest_x, dest_y)) {
>
> the second line should be shifted one space to the right.
:)
> The rest seems to be pretty good work.Also seems to fix the bug when an
> attacker wouldn't occupy an empty city because it's bodyguard wouldn't
> budge.I didn't test it though. Savegames would differ at later stage, I
> assume?
The savegames differ, yes.
Yours
Per
|
|