Skip to content

Commit

Permalink
Nuked all windows newlines.
Browse files Browse the repository at this point in the history
Corrected "Foobar" to "Wizznic" in GPL header.
  • Loading branch information
Jimmy Christensen committed Jun 9, 2012
1 parent d237e7c commit aa80153
Show file tree
Hide file tree
Showing 68 changed files with 1,359 additions and 1,356 deletions.
188 changes: 94 additions & 94 deletions board.c
Expand Up @@ -12,19 +12,19 @@
* GNU General Public License for more details. * * GNU General Public License for more details. *
* * * *
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. * * along with Wizznic. If not, see <http://www.gnu.org/licenses/>. *
************************************************************************/ ************************************************************************/


#include "board.h" #include "board.h"


#include <stdio.h> #include <stdio.h>
#include "ticks.h" #include "ticks.h"
#include "strings.h" #include "strings.h"
#include "teleport.h" #include "teleport.h"
#include "particles.h" #include "particles.h"
#include "draw.h" #include "draw.h"
#include "input.h" #include "input.h"




static int isWall(playField* pf, int x, int y) static int isWall(playField* pf, int x, int y)
{ {
Expand Down Expand Up @@ -143,9 +143,9 @@ void boardSetWalls(playField* pf)
} }
} }


int loadField(playField* pf, const char* file) int loadField(playField* pf, const char* file)
{ {
FILE *f = fopen(file, "r"); FILE *f = fopen(file, "r");
if(!f) if(!f)
{ {
printf("%s %i Board: couldn't open '%s'\n",__FILE__,__LINE__,file); printf("%s %i Board: couldn't open '%s'\n",__FILE__,__LINE__,file);
Expand Down Expand Up @@ -201,13 +201,13 @@ int loadField(playField* pf, const char* file)
pf->board[x][y]->curLock=0; pf->board[x][y]->curLock=0;
pf->board[x][y]->sx = x; pf->board[x][y]->sx = x;
pf->board[x][y]->sy = y; pf->board[x][y]->sy = y;
pf->board[x][y]->dx = x; pf->board[x][y]->dx = x;
pf->board[x][y]->dy = y; pf->board[x][y]->dy = y;
pf->board[x][y]->tl = MOVERCOUNTDOWN; pf->board[x][y]->tl = MOVERCOUNTDOWN;
pf->board[x][y]->moveXspeed = 0; pf->board[x][y]->moveXspeed = 0;
pf->board[x][y]->moveYspeed = 0; pf->board[x][y]->moveYspeed = 0;


pf->board[x][y]->dmx = 0; pf->board[x][y]->dmx = 0;
} else { } else {
pf->board[x][y] = 0; pf->board[x][y] = 0;
} }
Expand All @@ -228,8 +228,8 @@ int loadField(playField* pf, const char* file)
//Figure out which tile to use for each wall (int 6) //Figure out which tile to use for each wall (int 6)
boardSetWalls(pf); boardSetWalls(pf);


return(1); return(1);
} }


void freeField(playField* pf) void freeField(playField* pf)
{ {
Expand Down Expand Up @@ -283,7 +283,7 @@ int moveBrick(playField* pf, int x, int y, int dirx, int diry, int block, int sp
return(0); return(0);
} }
} }


//If destination is empty //If destination is empty
if( !pf->board[dx][dy] || (block==NOBLOCK && (!pf->board[dx][dy] || pf->board[dx][dy]->type==RESERVED)) ) if( !pf->board[dx][dy] || (block==NOBLOCK && (!pf->board[dx][dy] || pf->board[dx][dy]->type==RESERVED)) )
{ {
Expand All @@ -309,10 +309,10 @@ int moveBrick(playField* pf, int x, int y, int dirx, int diry, int block, int sp
} }


return(0); return(0);
} }


//Move a brick instantly to teleports dest //Move a brick instantly to teleports dest
void telePortBrick(playField* pf,telePort_t* t,cursorType* cur) void telePortBrick(playField* pf,telePort_t* t,cursorType* cur)
{ {
psysSet_t ps; //Particle system for particle effect psysSet_t ps; //Particle system for particle effect
brickType* b = pf->board[t->sx][t->sy]; brickType* b = pf->board[t->sx][t->sy];
Expand Down Expand Up @@ -395,7 +395,7 @@ void telePortBrick(playField* pf,telePort_t* t,cursorType* cur)


//Play sound //Play sound
sndPlayOnce(SND_TELEPORTED, b->pxx); sndPlayOnce(SND_TELEPORTED, b->pxx);


} }


void doTelePort(playField* pf,cursorType* cur) void doTelePort(playField* pf,cursorType* cur)
Expand Down Expand Up @@ -424,7 +424,7 @@ static int vertMover(playField* pf,int x, int y, int dir)
{ {
//Outside bounds //Outside bounds
if(y+dir < 0 || y+dir == FIELDSIZE) return(0); if(y+dir < 0 || y+dir == FIELDSIZE) return(0);


//Abort if it's not a brick, or a mover. //Abort if it's not a brick, or a mover.
if(!isBrick(pf->board[x][y]) && !isMover(pf->board[x][y]) ) return(0); if(!isBrick(pf->board[x][y]) && !isMover(pf->board[x][y]) ) return(0);


Expand Down Expand Up @@ -518,24 +518,24 @@ void simField(playField* pf, cursorType* cur)
//Do we need to move it? //Do we need to move it?
int deltaX= (b->dx*brickSize+boardOffsetX) - b->pxx ; int deltaX= (b->dx*brickSize+boardOffsetX) - b->pxx ;
int deltaY= (b->dy*brickSize+boardOffsetY) - b->pxy ; int deltaY= (b->dy*brickSize+boardOffsetY) - b->pxy ;


if(deltaX || deltaY ) if(deltaX || deltaY )
{ {
//Doing this lock to only move one dir at a time //Doing this lock to only move one dir at a time
if( deltaX ) if( deltaX )
{ {
b->pxx += b->moveXspeed; b->pxx += b->moveXspeed;


if(b->moveXspeed < 0 && b->pxx < (b->dx*brickSize+boardOffsetX) ) if(b->moveXspeed < 0 && b->pxx < (b->dx*brickSize+boardOffsetX) )
b->pxx = (b->dx*brickSize+boardOffsetX); b->pxx = (b->dx*brickSize+boardOffsetX);


if(b->moveXspeed > 0 && b->pxx > (b->dx*brickSize+boardOffsetX) ) if(b->moveXspeed > 0 && b->pxx > (b->dx*brickSize+boardOffsetX) )
b->pxx = (b->dx*brickSize+boardOffsetX); b->pxx = (b->dx*brickSize+boardOffsetX);


} }
if( deltaY) if( deltaY)
{ {
b->pxy += b->moveYspeed; b->pxy += b->moveYspeed;
} }
//} //}
//Is cursor attached? //Is cursor attached?
Expand All @@ -561,9 +561,9 @@ void simField(playField* pf, cursorType* cur)
b->moveYspeed=0; b->moveYspeed=0;


//Put it down: //Put it down:
pf->board[ b->dx ][ b->dy ] = b; pf->board[ b->dx ][ b->dy ] = b;




//Clear source //Clear source
pf->board[ b->sx ][ b->sy ] = 0; pf->board[ b->sx ][ b->sy ] = 0;


Expand All @@ -577,7 +577,7 @@ void simField(playField* pf, cursorType* cur)
} }


//May I be forgiven for I do not know better. //May I be forgiven for I do not know better.
brickType* hack; brickType* hack;


//Run teleport rules first //Run teleport rules first
doTelePort(pf,cur); doTelePort(pf,cur);
Expand All @@ -602,16 +602,16 @@ void simField(playField* pf, cursorType* cur)
pf->board[x][y]->curLock=0; pf->board[x][y]->curLock=0;
} }


//Things that happens below it //Things that happens below it
if(y+1 < FIELDSIZE) if(y+1 < FIELDSIZE)
{ {


//Falling? //Falling?
if( !pf->board[x][y+1] ) if( !pf->board[x][y+1] )
{ {
//Move down //Move down
moveBrick(pf, x, y, 0, DIRDOWN, DOBLOCK, FALLINGSPEED); moveBrick(pf, x, y, 0, DIRDOWN, DOBLOCK, FALLINGSPEED);
} else //Laying on a reserved brick might mean that it should be attached to a mover. } else //Laying on a reserved brick might mean that it should be attached to a mover.
{ {
if( pf->board[x][y+1]->type == RESERVED) //Magnet to mover if( pf->board[x][y+1]->type == RESERVED) //Magnet to mover
{ {
Expand All @@ -638,10 +638,10 @@ void simField(playField* pf, cursorType* cur)
break; break;
} }
} else if(b->type==MOVERVERT) } else if(b->type==MOVERVERT)
{ {


//Only magnet if it's moving down (if it's moving up, it will eventually hit the resting brick) //Only magnet if it's moving down (if it's moving up, it will eventually hit the resting brick)
if(b->sy < b->dy) if(b->sy < b->dy)
{ {
//Fetch the original underlying brick. //Fetch the original underlying brick.
b=findMoving(pf, x,y+1); b=findMoving(pf, x,y+1);
Expand All @@ -651,9 +651,9 @@ void simField(playField* pf, cursorType* cur)
hack->pxy=b->pxy-20; hack->pxy=b->pxy-20;
hack->moveYspeed=b->moveYspeed; hack->moveYspeed=b->moveYspeed;
break; break;
} }
} }
} }


b=findMoving(pf,x,b->dy+1); b=findMoving(pf,x,b->dy+1);
} else { } else {
Expand All @@ -662,8 +662,8 @@ void simField(playField* pf, cursorType* cur)


} //Loop through list } //Loop through list
} }
} //Resting on a reserved } //Resting on a reserved
} //Not free } //Not free
} }
} }


Expand Down Expand Up @@ -746,29 +746,29 @@ void simField(playField* pf, cursorType* cur)
} }


} }
} }


} }
} }
} }


for(y=FIELDSIZE-1; y > -1; y--) for(y=FIELDSIZE-1; y > -1; y--)
{ {
for(x=0; x < FIELDSIZE; x++) for(x=0; x < FIELDSIZE; x++)
{ {
if(pf->board[x][y]) if(pf->board[x][y])
{ {
//Unmark "checked" status. //Unmark "checked" status.
pf->board[x][y]->checked=0; pf->board[x][y]->checked=0;


//Do delayed x movement //Do delayed x movement
if( isBrick(pf->board[x][y]) && pf->board[x][y]->dmx ) if( isBrick(pf->board[x][y]) && pf->board[x][y]->dmx )
{ {
b=pf->board[x][y]; b=pf->board[x][y];
curMoveBrick(pf, b, b->dmx); curMoveBrick(pf, b, b->dmx);
b->dmx=0; b->dmx=0;
} }


} }
} }
} }
Expand Down Expand Up @@ -799,7 +799,7 @@ int doRules(playField* pf)
listItem* li=pf->movingList; listItem* li=pf->movingList;
brickType* b; brickType* b;
while( (li = li->next) ) while( (li = li->next) )
{ {
if( isBrick((brickType*)li->data) ) if( isBrick((brickType*)li->data) )
bricksLeft++; bricksLeft++;
} }
Expand Down Expand Up @@ -965,50 +965,50 @@ brickType* findMoving(playField* pf, int x, int y)


} }
return(0); return(0);
} }


brickType* brickUnderCursor(playField* pf, int x, int y) brickType* brickUnderCursor(playField* pf, int x, int y)
{ {
brickType* b=findMoving(pf,x,y); brickType* b=findMoving(pf,x,y);


//If it's not moving, they maybe it's standing still //If it's not moving, they maybe it's standing still
if( !b && pf->board[x][y] ) if( !b && pf->board[x][y] )
b=pf->board[x][y]; b=pf->board[x][y];


if( b && isBrick(b) ) if( b && isBrick(b) )
return(b); return(b);


return(0); return(0);
} }


int curMoveBrick(playField *pf, brickType *b, int dir) int curMoveBrick(playField *pf, brickType *b, int dir)
{ {
//We can't move the brick, if it is falling. //We can't move the brick, if it is falling.
if( isBrickFalling(pf, b) ) return(0); if( isBrickFalling(pf, b) ) return(0);


//We can't move it if it is on top of brick that is exploding (makes "glitch" solving possible). //We can't move it if it is on top of brick that is exploding (makes "glitch" solving possible).
if( onTopOfReserved(pf, b->dx, b->dy) ) return(0); if( onTopOfReserved(pf, b->dx, b->dy) ) return(0);


//Move brick that is not moving<. //Move brick that is not moving<.
if(b->moveXspeed==0 && b->moveYspeed==0) if(b->moveXspeed==0 && b->moveYspeed==0)
{ {
//First, check that it's a brick, and not a reserved. //First, check that it's a brick, and not a reserved.
if(pf->board[b->sx][b->sy] && isBrick( pf->board[b->sx][b->sy]) ) if(pf->board[b->sx][b->sy] && isBrick( pf->board[b->sx][b->sy]) )
{ {
if(moveBrick( pf, b->sx, b->sy, dir, 0, DOBLOCK, CURSORMOVESPEED)) if(moveBrick( pf, b->sx, b->sy, dir, 0, DOBLOCK, CURSORMOVESPEED))
{ {
return(1); return(1);
} }
} }
} else { } else {
if( ((b->moveXspeed < 0 && dir > 0) || (b->moveXspeed > 0 && dir <0)) || b->moveYspeed ) if( ((b->moveXspeed < 0 && dir > 0) || (b->moveXspeed > 0 && dir <0)) || b->moveYspeed )
{ {
if(!b->dmx) if(!b->dmx)
{ {
b->dmx = dir; b->dmx = dir;
return(1); return(1);
} }
} }
} }
return(0); return(0);
} }

0 comments on commit aa80153

Please sign in to comment.