anchor.diff:  
   destructor TRender.Destroy;
   begin
  -  SetLength(RenderList, 0);
  +  fRenderList.Free;
     {$IFDEF MSWindows}
     wglMakeCurrent(h_DC, 0);
     wglDeleteContext(h_RC);
  
positive.code:   ID := fResource.HouseDat[Index].WoodPic+1;
    ShiftX := Loc.X + RXData[2].Pivot[ID].x/CELL_SIZE_PX;
    ShiftY := Loc.Y + (RXData[2].Pivot[ID].y+RXData[2].Size[ID].Y)/CELL_SIZE_PX-fTerrain.Land[Loc.Y+1,Loc.X].Height/CELL_HEIGHT_DIV;
    AddSpriteToList(2,ID,ShiftX,ShiftY,Loc.X,Loc.Y,true,0,Step);
  end;
  
  
  
negative.code:   glBlendFunc(GL_DST_COLOR,GL_ONE);
    glColor4f(Value/20,Value/20,Value/20,Value/20);
    glBegin(GL_QUADS);
      glkRect(0,0,fScreenX,fScreenY);
    glEnd;
  
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  end;
  
  
  { TRenderList }
  constructor TRenderList.Create;
  begin
    RenderCount := 0;
    SetLength(RenderList, 512);
  end;
  
  
  destructor TRenderList.Destroy;
  begin
    SetLength(RenderList, 0);
    inherited;
  end;
  
  
  procedure TRenderList.ClipRenderList;
  var i:integer; P:TKMPoint;
  begin
    SetLength(RO, RenderCount+1);
  
    for i:=1 to RenderCount do
    if RenderList[i].NewInst then begin
      RO[i]:=i;
      if RenderList[i].IsUnit then
      begin
        P.X:=round(RenderList[i].Obj.X-0.5);
        P.Y:=round(RenderList[i].Obj.Y-1);
      end else
      begin
        P.X:=round(RenderList[i].Obj.X);
        P.Y:=round(RenderList[i].Obj.Y);
      end;
      //RenderQuad(P.X,P.Y);
      RenderList[i].FOWvalue := MyPlayer.FogOfWar.CheckTileRevelation(P.X,P.Y);
      if (RenderList[i].FOWvalue <= 128) and RenderList[i].IsUnit then
        RO[i] := 0;
    end else begin
      RO[i]:=0;
      RenderList[i].FOWvalue:=RenderList[i-1].FOWvalue; //Take from previous
    end;
  end;
  
  
  {Need to sort all items in list from top-right to bottom-left}
  procedure TRenderList.SortRenderList;
  var i,k:integer;
  begin
    for i:=1 to RenderCount do if RO[i]<>0 then //Exclude child sprites from comparison
    for k:=i+1 to RenderCount do if RO[k]<>0 then
      if (RenderList[RO[k]].Loc.Y < RenderList[RO[i]].Loc.Y)
      or((RenderList[RO[k]].Loc.Y = RenderList[RO[i]].Loc.Y)
      and(RenderList[RO[k]].Loc.X > RenderList[RO[i]].Loc.X))
      then //TopMost Rightmost
        SwapInt(RO[k],RO[i])
  end;
  
  
  procedure TRenderList.AddSprite(aRX:byte; aID:word; pX,pY,oX,oY:single; aNew:boolean; const aTeam:cardinal=$00000000; const Step:single=-1; aIsUnit:boolean=false);
  begin
    inc(RenderCount);
    if length(RenderList)-1<RenderCount then setlength(RenderList,length(RenderList)+256); //Book some space
  
    RenderList[RenderCount].Loc:=KMPointF(pX,pY); //Position of sprite, floating-point
    RenderList[RenderCount].Obj:=KMPointF(oX,oY); //Position of object in tile-space, floating-point
    RenderList[RenderCount].RX:=aRX;              //RX library
    RenderList[RenderCount].ID:=aID;              //Texture ID
    RenderList[RenderCount].NewInst:=aNew;        //Is this a new item (can be occluded), or a child one (always on top of it's parent)
    RenderList[RenderCount].Team:=aTeam;          //Team ID (determines color)
    RenderList[RenderCount].AlphaStep:=Step;      //Alpha step for wip buildings
    RenderList[RenderCount].IsUnit:=aIsUnit;      //Because units use different FOW offsets
  
    RenderList[RenderCount].FOWvalue:=255;        //Visibility recomputed in ClipRender anyway
  end;
  
  
  {Now render all these items from list}
  procedure TRenderList.Render;
  var i,h:integer;
  begin
    ClipRenderList; //drop items that are outside of viewport
    SortRenderList; //sort items overlaying
  
    fStat_Sprites := RenderCount;
    fStat_Sprites2 := 0;
  
    for i:=1 to RenderCount do
    if RO[i]<>0 then begin
  
      h:=RO[i];
      //Incase no sprites were made
      if (RenderList[h].RX=2) and not MAKE_HOUSE_SPRITES then
        fRender.RenderDot(RenderList[h].Loc.X,RenderList[h].Loc.Y)
      else
      if (RenderList[h].RX=3) and not MAKE_UNIT_SPRITES then
        fRender.RenderDot(RenderList[h].Loc.X,RenderList[h].Loc.Y)
      else
      begin
  
        glPushMatrix;
          glTranslatef(RenderList[h].Obj.X,RenderList[h].Obj.Y,0);
          //glRotatef(rHeading,-1,0,0);
          glTranslatef(-RenderList[h].Obj.X,-RenderList[h].Obj.Y,0);
  
          repeat //Render child sprites only after their parent
            with RenderList[h] do begin
              if AlphaStep=-1 then
                fRender.RenderSprite(RX,ID,Loc.X,Loc.Y,Team,FOWvalue)
              else
                fRender.RenderSpriteAlphaTest(RX,ID,AlphaStep,Loc.X,Loc.Y,FOWvalue)
            end;
            inc(h);
            inc(fStat_Sprites2);
          until((h>RenderCount)or(RenderList[h].NewInst));
  
        glPopMatrix;
      end;
  
    end;
  
    RenderCount := 0;
  end;
  
  
  end.
  