Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] Re: (PR#12546) Divide handicaps to real handicaps and chea
Home

[Freeciv-Dev] Re: (PR#12546) Divide handicaps to real handicaps and chea

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#12546) Divide handicaps to real handicaps and cheats
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Sat, 19 Mar 2005 08:29:08 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12546 >

Per I. Mathisen wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12546 >
> 
> On Sat, 19 Mar 2005, Marko Lindqvist wrote:
> 
>>Handicaps need cleanup.
>>
>>Currently some handicaps really are handicaps (relative to rules) and
>>some are cheats. It's not always clear if given 'handicap' is positive
>>or negative thing to have. For more self documenting code there should
>>be separate ai_handicap() and ai_cheat() functions.

  After some twiddling with the code it seems that it's actually best to 
have one generically named function and to code handicap/cheat status 
into effect name.

>>Further, ai_handicap() currently returns TRUE for human players. For
>>some (current) handicaps this is ok, for some it's wrong. So sometimes
>>it's callers responsibility to check that human players are handled
>>correctly, sometimes caller can rely on ai_handicap() return value.
> 
> I am thinking this should be done simultaneously or after adding player
> effects.

  This can hardly be left after player effects. I'd say that this is 
prerequisite for them. Player effects are not very general if 
ai_handicap() / ai_cheat() / player_has_effect() / whatever() *callers* 
hardcode behavior for human players.
  But ai_handicap() could be renamed in this change, to one without any 
'ai' -prefix. player_has_effect() ?


To sum, typical uses would look something like this:

if(player_has_effect(pplayer, C_MAP) || map_is_known(pplayer, x, y))
{ ... }

if(player_has_effect(pplayer, H_LIMITEDHUTS))
{ ... }


vs current

if(ai_handicap(pplayer, H_MAP) || map_is_known(pplayer, x, y))
{ ... }

if(pplayer->ai.control && ai_handicap(pplayer, H_LIMITEDHUTS))
{ ... }


  - ML





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