glob2-devel
[Top][All Lists]
Advanced

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

Re: [glob2-devel] Re: level 1 buildings not repairable?


From: Joe Wells
Subject: Re: [glob2-devel] Re: level 1 buildings not repairable?
Date: Thu, 12 Apr 2007 13:23:22 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Kai Antweiler <address@hidden> writes:

> ...  Fixing it should be as simple as
> reverting every part of that new "forbiddenzone around buildings"
> feature in recent cvs and checking that no other patches rely on
> it.
>
> I attach the complete diff:

...

> +void Building::addForbiddenZoneToUpgradeArea(void)
> +{
> +     int midPosX=posX-type->decLeft;
> +     int midPosY=posY-type->decTop;
> +
> +     int targetLevelTypeNum=-1;
> +     if (constructionResultState==UPGRADE)
> +             targetLevelTypeNum=type->nextLevel;
> +     else if (constructionResultState==REPAIR)
> +             targetLevelTypeNum=type->prevLevel;

The above line looks extremely suspicious!  Shouldn't it be using the
_current_ level for this?  Or does prevLevel mean something other than
“previous level”?

> +     else
> +             assert(false);
> +
> +     BuildingType 
> *targetBt=globalContainer->buildingsTypes.get(targetLevelTypeNum);
> +     int newPosX=midPosX+targetBt->decLeft;
> +     int newPosY=midPosY+targetBt->decTop;
> +     int newWidth=targetBt->width;
> +     int newHeight=targetBt->height;
> +     for(int nx=0; nx<newWidth; ++nx)
> +     {
> +             for(int ny=0; ny<newHeight; ++ny)
> +             {
> +                     
> owner->map->addHiddenForbidden(owner->map->normalizeX(newPosX+nx), 
> owner->map->normalizeY(newPosY+ny), owner->teamNumber); 
> +             }
> +     }
> +}
> +
> +
> +
> +void Building::removeForbiddenZoneFromUpgradeArea(void)
> +{
> +     int midPosX=posX-type->decLeft;
> +     int midPosY=posY-type->decTop;
> +
> +     int targetLevelTypeNum=-1;
> +     if (constructionResultState==UPGRADE)
> +             targetLevelTypeNum=type->nextLevel;
> +     else if (constructionResultState==REPAIR)
> +             targetLevelTypeNum=type->prevLevel;

Again, looks suspicious.

> +     else
> +             assert(false);
> +
> +     BuildingType 
> *targetBt=globalContainer->buildingsTypes.get(targetLevelTypeNum);
> +     int newPosX=midPosX+targetBt->decLeft;
> +     int newPosY=midPosY+targetBt->decTop;
> +     int newWidth=targetBt->width;
> +     int newHeight=targetBt->height;
> +     for(int nx=0; nx<newWidth; ++nx)
> +     {
> +             for(int ny=0; ny<newHeight; ++ny)
> +             {
> +                     
> owner->map->removeHiddenForbidden(owner->map->normalizeX(newPosX+nx), 
> owner->map->normalizeY(newPosY+ny), owner->teamNumber); 
> +             }
> +     }
> +}

-- 
Joe




reply via email to

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