summaryrefslogtreecommitdiff
path: root/src/powder.c
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2011-12-10 15:23:33 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-12-18 14:04:47 (GMT)
commit934d1da66eb5aec49769feaf00d0949f805fd3d5 (patch)
tree28ee674d06060d9940e1c235d2dba39f8a5c74f5 /src/powder.c
parent20dd54f36e971e9b9f8762309caa49ed07bea031 (diff)
downloadpowder-934d1da66eb5aec49769feaf00d0949f805fd3d5.zip
powder-934d1da66eb5aec49769feaf00d0949f805fd3d5.tar.gz
Move Newtonian gravity into a new file
Diffstat (limited to 'src/powder.c')
-rw-r--r--src/powder.c91
1 files changed, 1 insertions, 90 deletions
diff --git a/src/powder.c b/src/powder.c
index c683f68..853b216 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -4,12 +4,11 @@
#include <powder.h>
#include <air.h>
#include <misc.h>
+#include "gravity.h"
#ifdef LUACONSOLE
#include <luaconsole.h>
#endif
-int gravwl_timeout = 0;
-
int wire_placed = 0;
int lighting_recreate = 0;
@@ -23,7 +22,6 @@ unsigned char fighcount = 0; //Contains the number of fighters
particle *parts;
particle *cb_parts;
-int gravityMode = 0; // starts enabled in "vertical" mode...
int airMode = 0;
@@ -3364,90 +3362,3 @@ inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resb
*block1 = block1tmp;
*block2 = block2tmp;
}
-void grav_mask_r(int x, int y, char checkmap[YRES/CELL][XRES/CELL], char shape[YRES/CELL][XRES/CELL], char *shapeout)
-{
- if(x < 0 || x >= XRES/CELL || y < 0 || y >= YRES/CELL)
- return;
- if(x == 0 || y ==0 || y == (YRES/CELL)-1 || x == (XRES/CELL)-1)
- *shapeout = 1;
- checkmap[y][x] = 1;
- shape[y][x] = 1;
- if(x-1 >= 0 && !checkmap[y][x-1] && bmap[y][x-1]!=WL_GRAV)
- grav_mask_r(x-1, y, checkmap, shape, shapeout);
- if(y-1 >= 0 && !checkmap[y-1][x] && bmap[y-1][x]!=WL_GRAV)
- grav_mask_r(x, y-1, checkmap, shape, shapeout);
- if(x+1 < XRES/CELL && !checkmap[y][x+1] && bmap[y][x+1]!=WL_GRAV)
- grav_mask_r(x+1, y, checkmap, shape, shapeout);
- if(y+1 < YRES/CELL && !checkmap[y+1][x] && bmap[y+1][x]!=WL_GRAV)
- grav_mask_r(x, y+1, checkmap, shape, shapeout);
- return;
-}
-struct mask_el {
- char *shape;
- char shapeout;
- void *next;
-};
-typedef struct mask_el mask_el;
-void mask_free(mask_el *c_mask_el){
- if(c_mask_el==NULL)
- return;
- if(c_mask_el->next!=NULL)
- mask_free(c_mask_el->next);
- free(c_mask_el->shape);
- free(c_mask_el);
-}
-void gravity_mask()
-{
- char checkmap[YRES/CELL][XRES/CELL];
- int x = 0, y = 0;
- mask_el *t_mask_el = NULL;
- mask_el *c_mask_el = NULL;
- memset(checkmap, 0, sizeof(checkmap));
- for(x = 0; x < XRES/CELL; x++)
- {
- for(y = 0; y < YRES/CELL; y++)
- {
- if(bmap[y][x]!=WL_GRAV && checkmap[y][x] == 0)
- {
- //Create a new shape
- if(t_mask_el==NULL){
- t_mask_el = malloc(sizeof(mask_el));
- t_mask_el->shape = malloc((XRES/CELL)*(YRES/CELL));
- memset(t_mask_el->shape, 0, (XRES/CELL)*(YRES/CELL));
- t_mask_el->shapeout = 0;
- t_mask_el->next = NULL;
- c_mask_el = t_mask_el;
- } else {
- c_mask_el->next = malloc(sizeof(mask_el));
- c_mask_el = c_mask_el->next;
- c_mask_el->shape = malloc((XRES/CELL)*(YRES/CELL));
- memset(c_mask_el->shape, 0, (XRES/CELL)*(YRES/CELL));
- c_mask_el->shapeout = 0;
- c_mask_el->next = NULL;
- }
- //Fill the shape
- grav_mask_r(x, y, checkmap, c_mask_el->shape, &c_mask_el->shapeout);
- }
- }
- }
- c_mask_el = t_mask_el;
- memset(gravmask, 0, sizeof(gravmask));
- while(c_mask_el!=NULL)
- {
- char *cshape = c_mask_el->shape;
- for(x = 0; x < XRES/CELL; x++)
- {
- for(y = 0; y < YRES/CELL; y++)
- {
- if(cshape[y*(XRES/CELL)+x]){
- if(c_mask_el->shapeout)
- gravmask[y][x] = 0xFFFFFFFF;
- else
- gravmask[y][x] = 0x00000000;
- }
- }
- }
- c_mask_el = c_mask_el->next;
- }
- mask_free(t_mask_el);
-}