/* Copyright (C) 2005, 2010 - Cryptic Sea This file is part of Gish. Gish is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ void saveblock(int blocknum) { int count; int changeddir; char filename[13]="blck000.blk"; changeddir=chdir("block"); filename[4]=48+(blocknum/100)%10; filename[5]=48+(blocknum/10)%10; filename[6]=48+blocknum%10; if ((fp=fopen(filename,"wb"))!=NULL) { fwrite2(&block[blocknum].numoflines,4,1,fp); for (count=0;count2) { yline=polygontemp[count2].ivertex[0][1]; xleft=polygontemp[count2].ivertex[0][0]; xright=polygontemp[count2].ivertex[0][0]; vertleft=0; vertright=0; for (count=1;countpolygontemp[count2].ivertex[count][1] || (yline==polygontemp[count2].ivertex[count][1] && xleft>polygontemp[count2].ivertex[count][0])) { yline=polygontemp[count2].ivertex[count][1]; xleft=polygontemp[count2].ivertex[count][0]; xright=polygontemp[count2].ivertex[count][0]; vertleft=count; vertright=count; } } if (yline<0) yline=0; yend=polygontemp[count2].ivertex[0][1]; for (count=1;count0) vertleftnext=vertleft-1; else vertleftnext=polygontemp[count2].numofverts-1; xleftadd=(polygontemp[count2].ivertex[vertleftnext][0]<<16)-xleft; if ((polygontemp[count2].ivertex[vertleftnext][1]-yline)>0) xleftadd/=(polygontemp[count2].ivertex[vertleftnext][1]-yline); vertrightnext=(vertright+1)%polygontemp[count2].numofverts; xrightadd=(polygontemp[count2].ivertex[vertrightnext][0]<<16)-xright; if ((polygontemp[count2].ivertex[vertrightnext][1]-yline)>0) xrightadd/=(polygontemp[count2].ivertex[vertrightnext][1]-yline); while (yline0) vertleftnext=vertleft-1; else vertleftnext=polygontemp[count2].numofverts-1; xleftadd=(polygontemp[count2].ivertex[vertleftnext][0]<<16)-xleft; if ((polygontemp[count2].ivertex[vertleftnext][1]-yline)>0) xleftadd/=(polygontemp[count2].ivertex[vertleftnext][1]-yline); } if (yline==polygontemp[count2].ivertex[vertrightnext][1]) { vertright=vertrightnext; vertrightnext=(vertright+1)%polygontemp[count2].numofverts; xrightadd=(polygontemp[count2].ivertex[vertrightnext][0]<<16)-xright; if ((polygontemp[count2].ivertex[vertrightnext][1]-yline)>0) xrightadd/=(polygontemp[count2].ivertex[vertrightnext][1]-yline); } xstart=xleft>>16; if (xstart<0) xstart=0; if (xstart>texture[blocknum].sizex-1) xstart=texture[blocknum].sizex-1; xend=xright>>16; if (xend<0) xend=0; if (xend>texture[blocknum].sizex) xend=texture[blocknum].sizex; while (xstart