summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-03-22 17:25:29 (GMT)
committer Simon <simon@hardwired.org.uk>2011-03-22 17:25:29 (GMT)
commitc096b2b14a200a0cc0a08cfea839c9e7f4edf22e (patch)
tree6aaca470697115e62c8f5f4c612847499233dac7 /src/main.c
parent7d56b3358969164deccb7cc837aa5dd3b59ea4f3 (diff)
parentffc3e0a5ee780c05abe5ff53432583c40ed62032 (diff)
downloadpowder-c096b2b14a200a0cc0a08cfea839c9e7f4edf22e.zip
powder-c096b2b14a200a0cc0a08cfea839c9e7f4edf22e.tar.gz
More cracker fixes
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c1305
1 files changed, 1233 insertions, 72 deletions
diff --git a/src/main.c b/src/main.c
index 2602cfc..fe8496d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,12 +1,13 @@
/**
* Powder Toy - Main source
*
- * Copyright (c) 2008 - 2010 Stanislaw Skowronek.
- * Copyright (c) 2010 Simon Robertshaw
- * Copyright (c) 2010 Skresanov Savely
- * Copyright (c) 2010 Bryan Hoyle
- * Copyright (c) 2010 Nathan Cousins
- * Copyright (c) 2010 cracker64
+ * Copyright (c) 2008 - 2011 Stanislaw Skowronek.
+ * Copyright (c) 2010 - 2011 Simon Robertshaw
+ * Copyright (c) 2010 - 2011 Skresanov Savely
+ * Copyright (c) 2010 - 2011 Bryan Hoyle
+ * Copyright (c) 2010 - 2011 Nathan Cousins
+ * Copyright (c) 2010 - 2011 cracker64
+ * Copyright (c) 2011 jacksonmj
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +24,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
+#include <defines.h>
+
+#ifdef PYCONSOLE
+#include "Python.h"
+#include "pyconsole.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -41,7 +49,6 @@
#include <misc.h>
#include <font.h>
-#include <defines.h>
#include <powder.h>
#include <graphics.h>
#include <version.h>
@@ -52,6 +59,8 @@
#include <air.h>
#include <icon.h>
+pixel *vid_buf;
+
#define NUM_SOUNDS 2
struct sample {
Uint8 *data;
@@ -158,6 +167,7 @@ float mheat = 0.0f;
int do_open = 0;
int sys_pause = 0;
+int sys_shortcuts = 1;
int legacy_enable = 0; //Used to disable new features such as heat, will be set by commandline or save.
int death = 0, framerender = 0;
int amd = 1;
@@ -1183,6 +1193,746 @@ char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture="
"SSE"
#endif
;
+
+
+char console_error[255] = "";
+
+#ifdef PYCONSOLE
+/*
+ * PYTHON FUNCTIONS
+ * instructions on making a function callable from python:
+ * first you make a function that accepts (PyObject *self, PyObject *args) as arguments
+ * then you use PyArg_ParseTuple to parse the arguments, handle everything the function should do.
+ * register the function by adding a line to static PyMethodDef EmbMethods[] = {
+ * the line should look like this:
+ * {"PyFunctionname", Functionname, METH_VARARGS,"short help string"},
+ * for more information on the PyWhatever functions look here:
+ * http://docs.python.org/extending/extending.html
+ */
+
+//functions callable from python:
+
+static PyObject*
+emb_create(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int x,y,t;
+ char *name = "";
+ char *kwlist[] = {"x","y","t","name", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "II|Is:create",kwlist, &x,&y,&t,&name))
+ return NULL;
+ //
+ if(strcmp(name,"")!=0)
+ console_parse_type(name, &t, console_error);
+ return Py_BuildValue("i",create_part(-1,x,y,t));
+}
+//sys_pause = !sys_pause
+emb_pause(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if(!PyArg_ParseTuple(args, ":unpause"))
+ return NULL;
+ //
+ sys_pause=1;
+ return Py_BuildValue("i",1);
+}
+
+emb_unpause(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if(!PyArg_ParseTuple(args, ":pause"))
+ return NULL;
+ //
+ sys_pause=0;
+ return Py_BuildValue("i",1);
+}
+
+emb_toggle_pause(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if(!PyArg_ParseTuple(args, ":toggle_pause"))
+ return NULL;
+ //
+ sys_pause=!sys_pause;
+ return Py_BuildValue("i",1);
+}
+
+//console_mode
+
+emb_toggle_console(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if(!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=!console_mode;
+ return Py_BuildValue("i",1);
+}
+
+emb_open_console(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if(!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=1;
+ return Py_BuildValue("i",1);
+}
+
+emb_close_console(PyObject *self, PyObject *args)
+{
+ int x,y,t;
+ if(!PyArg_ParseTuple(args, ":toggle_console"))
+ return NULL;
+ //
+ console_mode=0;
+ return Py_BuildValue("i",1);
+}
+
+
+emb_log(PyObject *self, PyObject *args)
+{
+ char *buffer;
+ if(!PyArg_ParseTuple(args, "s:log",&buffer))
+ return NULL;
+ //
+ strcpy(console_error,buffer);
+ puts(buffer);
+ return Py_BuildValue("i",1);
+}
+
+char console_more=0;
+
+emb_console_more(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":log"))
+ return NULL;
+ //
+ console_more=1;
+ return Py_BuildValue("i",1);
+}
+
+emb_console_less(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":log"))
+ return NULL;
+ //
+ console_more=0;
+ return Py_BuildValue("i",1);
+}
+
+//drawtext(vid_buf, 15, 175-(cc*12), currentcommand->command, 255, 255, 255, 255);
+
+
+emb_reset_pressure(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":reset_pressure"))
+ return NULL;
+ //
+ for (int nx = 0; nx<XRES/CELL; nx++)
+ for (int ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = 0;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_reset_velocity(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":reset_velocity"))
+ return NULL;
+ //
+ for (int nx = 0; nx<XRES/CELL; nx++)
+ for (int ny = 0; ny<YRES/CELL; ny++)
+ {
+ vx[ny][nx] = 0;
+ vy[ny][nx] = 0;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_reset_sparks(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":reset_sparks"))
+ return NULL;
+ //
+ for(int i=0; i<NPART; i++)
+ {
+ if(parts[i].type==PT_SPRK)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 4;
+ }
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_life(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].life = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].life = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].life = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].life = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_type(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j=-1,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "settoint", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "|sIsIII:set_type",kwlist ,&type,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1 && j==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ console_parse_type(type, &life, console_error);
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].type = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].type = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].type = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].type = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_temp(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].temp = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].temp = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].temp = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].temp = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_tmp(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].tmp = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].tmp = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].tmp = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].tmp = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_x(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].x = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].x = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].x = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].x = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_y(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].y = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].y = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].y = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].y = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_ctype(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *type = "";
+ char *kwlist[] = {"setto", "toctypeint", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "s|IsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(!life)
+ console_parse_type(type, &life, console_error);
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].ctype = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].ctype = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].ctype = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].ctype = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_vx(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].vx = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].vx = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].vx = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].vx = life;
+ }
+ return Py_BuildValue("i",1);
+}
+
+emb_set_vy(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ int i = -1,life,j,x=-1,y=-1;
+ char *name = "";
+ char *kwlist[] = {"setto", "setfrom", "i", "x", "y", NULL};
+ if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y))
+ return NULL;
+ //
+ if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1)
+ return Py_BuildValue("s","Need more args(coords,i,or a particle name)");
+ if(strcmp(name,"all")==0)
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type)
+ parts[i].vy = life;
+ }
+ }
+ else if(console_parse_type(name, &j, console_error))
+ {
+ for(i=0; i<NPART; i++)
+ {
+ if(parts[i].type == j)
+ parts[i].vy = life;
+ }
+ }
+ else if(i!=-1)
+ {
+ if(parts[i].type != PT_NONE)
+ parts[i].vy = life;
+
+ }
+ else if(x!=-1 && y!=-1 && x>=0 && x<XRES && y>=0 && y<YRES)
+ {
+ if(parts[pmap[y][x]>>8].type != PT_NONE)
+ parts[pmap[y][x]>>8].vy = life;
+ }
+ return Py_BuildValue("i",1);
+}
+emb_get_pmap(PyObject *self, PyObject *args)
+{
+ int x,y;
+ if(!PyArg_ParseTuple(args, "II:get_pmap",&x,&y))
+ return NULL;
+ //
+ if(x<0 || y<0 || x>=XRES || y>=YRES)
+ return Py_BuildValue("i",-1);
+
+ return Py_BuildValue("I",pmap[y][x]);
+}
+emb_get_prop(PyObject *self, PyObject *args)
+{
+ int i;
+ char *prop = "";
+ if(!PyArg_ParseTuple(args, "Is:get_pmap",&i,&prop))
+ return NULL;
+ //
+ if(parts[i].type)
+ {
+ if(strcmp(prop,"type")==0)
+ return Py_BuildValue("i",parts[i].type);
+ if(strcmp(prop,"life")==0)
+ return Py_BuildValue("i",parts[i].life);
+ if(strcmp(prop,"ctype")==0)
+ return Py_BuildValue("i",parts[i].ctype);
+ if(strcmp(prop,"temp")==0)
+ return Py_BuildValue("i",parts[i].temp);
+ if(strcmp(prop,"tmp")==0)
+ return Py_BuildValue("i",parts[i].tmp);
+ if(strcmp(prop,"vy")==0)
+ return Py_BuildValue("f",parts[i].vy);
+ if(strcmp(prop,"vx")==0)
+ return Py_BuildValue("f",parts[i].vx);
+ if(strcmp(prop,"x")==0)
+ return Py_BuildValue("i",parts[i].x);
+ if(strcmp(prop,"y")==0)
+ return Py_BuildValue("i",parts[i].y);
+ }
+
+ return Py_BuildValue("i",-1);
+}
+
+emb_draw_pixel(PyObject *self, PyObject *args)
+{
+ int x,y,r,g,b,a;
+ a=255;
+ if(!PyArg_ParseTuple(args, "IIIII|I:draw_pixel",&x,&y,&r,&g,&b,&a))
+ return NULL;
+
+ if(vid_buf!=NULL)
+ {
+ drawpixel(vid_buf,x,y,r,g,b,a);
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+
+}
+
+//drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a)
+emb_draw_text(PyObject *self, PyObject *args)
+{
+ int x,y,r,g,b,a;
+ char *txt;
+ a=255;
+ if(!PyArg_ParseTuple(args, "IIsIII|I:draw_text",&x,&y,&txt,&r,&g,&b,&a))
+ return NULL;
+ if(vid_buf!=NULL)
+ {
+ drawtext(vid_buf,x,y,txt,r,g,b,a);
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+
+//drawrect(pixel *vid, int x, int y, int w, int h, int r, int g, int b, int a)
+emb_draw_rect(PyObject *self, PyObject *args)
+{
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if(!PyArg_ParseTuple(args, "IIIIIII|I:draw_rect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if(vid_buf!=NULL)
+ {
+ drawrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+
+emb_draw_fillrect(PyObject *self, PyObject *args)
+{
+ int x,y,w,h,r,g,b,a;
+ a=255;
+ if(!PyArg_ParseTuple(args, "IIIIIII|I:draw_fillrect",&x,&y,&w,&h,&r,&g,&b,&a))
+ return NULL;
+ if(vid_buf!=NULL)
+ {
+ fillrect(vid_buf,x,y,w,h,r,g,b,a);
+ //fillrect
+ return Py_BuildValue("i",1);
+ }
+ return Py_BuildValue("i",-1);
+}
+//int textwidth(char *s)
+emb_get_width(PyObject *self, PyObject *args)
+{
+ char *txt;
+ if(!PyArg_ParseTuple(args, "s:get_width",&txt))
+ return NULL;
+ return Py_BuildValue("i",textwidth(txt));
+}
+
+//SDL_GetMouseState(&x, &y)
+emb_get_mouse(PyObject *self, PyObject *args)
+{
+ int x,y,mask,b1,b2,b3;
+ if(!PyArg_ParseTuple(args, ":get_mouse"))
+ return NULL;
+ mask=SDL_GetMouseState(&x, &y);
+ b1=mask&SDL_BUTTON(1);
+ b2=mask&SDL_BUTTON(2);
+ b3=mask&SDL_BUTTON(3);
+ return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
+}
+
+//svf_name
+emb_get_name(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":get_name"))
+ return NULL;
+ if(svf_login)
+ return Py_BuildValue("s",svf_user);
+ else
+ return Py_BuildValue("s","");
+}
+
+emb_shortcuts_disable(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":shortcuts_disable"))
+ return NULL;
+ //
+ sys_shortcuts=0;
+ return Py_BuildValue("i",1);
+}
+
+emb_shortcuts_enable(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":shortcuts_enable"))
+ return NULL;
+ //
+ sys_shortcuts=1;
+ return Py_BuildValue("i",1);
+}
+
+emb_get_modifier(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":get_modifier"))
+ return NULL;
+ return Py_BuildValue("(iiiiii)",sdl_mod&KMOD_LCTRL,sdl_mod&KMOD_RCTRL,sdl_mod&KMOD_LALT,sdl_mod&KMOD_RALT,sdl_mod&KMOD_LSHIFT,sdl_mod&KMOD_RSHIFT);
+}
+
+static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
+ {"create", emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
+ {"log", emb_log, METH_VARARGS, "logs an error string to the console."},
+ {"reset_pressure", emb_reset_pressure, METH_VARARGS, "resets all the pressure."},
+ {"reset_velocity", emb_reset_velocity, METH_VARARGS, "resets all the velocity."},
+ {"reset_sparks", emb_reset_sparks, METH_VARARGS, "resets all the sparks."},
+ {"set_life", emb_set_life, METH_VARARGS|METH_KEYWORDS, "sets life of a specified particle."},
+ {"set_type", emb_set_type, METH_VARARGS|METH_KEYWORDS, "sets type of a specified particle."},
+ {"set_temp", emb_set_temp, METH_VARARGS|METH_KEYWORDS, "sets temp of a specified particle."},
+ {"set_tmp", emb_set_tmp, METH_VARARGS|METH_KEYWORDS, "sets tmp of a specified particle."},
+ {"set_x", emb_set_x, METH_VARARGS|METH_KEYWORDS, "sets x of a specified particle."},
+ {"set_y", emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets y of a specified particle."},
+ {"set_ctype", emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets ctype of a specified particle."},
+ {"set_vx", emb_set_vx, METH_VARARGS|METH_KEYWORDS, "sets vx of a specified particle."},
+ {"set_vy", emb_set_vy, METH_VARARGS|METH_KEYWORDS, "sets vy of a specified particle."},
+ {"pause", emb_pause, METH_VARARGS, "pause the game."},
+ {"unpause", emb_unpause, METH_VARARGS, "unpause the game."},
+ {"pause_toggle", emb_toggle_pause, METH_VARARGS, "toggle game pause."},
+ {"console_open", emb_open_console, METH_VARARGS, "open the game console."},
+ {"console_close", emb_close_console, METH_VARARGS, "close the game console."},
+ {"console_toggle", emb_toggle_console, METH_VARARGS, "toggle the game console."},
+ {"console_more", emb_console_more, METH_VARARGS, "turns the more indicator on."},
+ {"console_less", emb_console_less, METH_VARARGS, "turns the more indicator off."},
+ {"get_pmap", emb_get_pmap, METH_VARARGS, "get the pmap value."},
+ {"get_prop", emb_get_prop, METH_VARARGS, "get some properties."},
+ {"draw_pixel", emb_draw_pixel, METH_VARARGS, "draw a pixel."},
+ {"draw_text", emb_draw_text, METH_VARARGS, "draw some text."},
+ {"draw_rect", emb_draw_rect, METH_VARARGS, "draw a rect."},
+ {"draw_fillrect", emb_draw_fillrect, METH_VARARGS, "draw a rect."},
+ {"get_width", emb_get_width, METH_VARARGS, "get string width."},
+ {"get_mouse", emb_get_mouse, METH_VARARGS, "get mouse status."},
+ {"get_name", emb_get_name, METH_VARARGS, "get name of logged in user"},
+ {"shortcuts_disable", emb_shortcuts_disable, METH_VARARGS, "disable keyboard shortcuts"},
+ {"shortcuts_enable", emb_shortcuts_enable, METH_VARARGS, "enable keyboard shortcuts"},
+ {"get_modifier", emb_get_modifier, METH_VARARGS, "get pressed modifier keys"},
+ {NULL, NULL, 0, NULL}
+};
+#endif
+
int main(int argc, char *argv[])
{
int hud_enable = 1;
@@ -1197,11 +1947,11 @@ int main(int argc, char *argv[])
int FPS = 0;
int pastFPS = 0;
int past = 0;
- pixel *vid_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
void *http_ver_check;
void *http_session_check = NULL;
+ vid_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
char *ver_data=NULL, *check_data=NULL, *tmp;
- char console_error[255] = "";
+ //char console_error[255] = "";
int i, j, bq, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, old_ver_len;
#ifdef INTERNAL
int vs = 0;
@@ -1218,6 +1968,9 @@ int main(int argc, char *argv[])
int username_flash = 0, username_flash_t = 1;
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
GSPEED = 1;
+ #ifdef PYCONSOLE
+ PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey;
+ #endif
/* Set 16-bit stereo audio at 22Khz */
fmt.freq = 22050;
@@ -1227,6 +1980,61 @@ int main(int argc, char *argv[])
fmt.callback = mixaudio;
fmt.userdata = NULL;
+ #ifdef PYCONSOLE
+ //initialise python console
+ Py_Initialize();
+ Py_InitModule("tpt", EmbMethods);
+ //change the path to find all the correct modules
+ PyRun_SimpleString("import sys\nsys.path.append('.')");
+ PyRun_SimpleString("print 'python present.'");
+ //load the console module and whatnot
+ PyObject *tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8);
+ pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj);
+ if(pmodule!=NULL)
+ {
+ pfunc=PyObject_GetAttrString(pmodule,"handle");//get the handler function
+ if(pfunc && PyCallable_Check(pfunc))//check if it's really a function
+ {
+ printf("python console ready to go.\n");
+ }
+ else
+ {
+ PyErr_Print();
+ printf("unable to find handle function, mangled console.py?\n");
+ return -1;
+ }
+
+ pstep=PyObject_GetAttrString(pmodule,"step");//get the handler function
+ if(pstep && PyCallable_Check(pstep))//check if it's really a function
+ {
+ printf("step function found.\n");
+ }
+ else
+ {
+ printf("unable to find step function. ignoring.\n");
+ }
+
+ pkey=PyObject_GetAttrString(pmodule,"keypress");//get the handler function
+ if(pstep && PyCallable_Check(pkey))//check if it's really a function
+ {
+ printf("key function found.\n");
+ }
+ else
+ {
+ printf("unable to find key function. ignoring.\n");
+ }
+ }
+ else
+ {
+ //sys.stderr
+ PyErr_Print();
+ printf("unable to find console module, missing file or mangled console.py?\n");
+ return -1;
+ }
+#else
+ printf("python console disabled at compile time.");
+#endif
+
#ifdef MT
numCores = core_count();
#endif
@@ -1489,53 +2297,398 @@ int main(int argc, char *argv[])
}
do_s_check = (do_s_check+1) & 15;
}
-
- if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
- {
- if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
- {
- break;
- }
- }
- //if(sdl_key=='d' && isplayer)
- //{
- // death = 1;
- // //death = !(death);
- //}
- if (sdl_key=='f')
- {
- framerender = 1;
- }
- if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0])
+
+ if(sys_shortcuts==1)
+ {
+ if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
+ {
+ if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
+ {
+ break;
+ }
+ }
+ //if(sdl_key=='d' && isplayer)
+ //{
+ // death = 1;
+ // //death = !(death);
+ //}
+ if (sdl_key=='f')
+ {
+ framerender = 1;
+ }
+ if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0])
+ {
+ if (load_mode)
+ {
+ free(load_img);
+ free(load_data);
+ load_mode = 0;
+ load_data = NULL;
+ load_img = NULL;
+ }
+ if (it > 50)
+ it = 50;
+ if (sdl_key=='k' && stamps[1].name[0])
+ {
+ j = stamp_ui(vid_buf);
+ if (j>=0)
+ load_data = stamp_load(j, &load_size);
+ else
+ load_data = NULL;
+ }
+ else
+ load_data = stamp_load(0, &load_size);
+ if (load_data)
+ {
+ load_img = prerender_save(load_data, load_size, &load_w, &load_h);
+ if (load_img)
+ load_mode = 1;
+ else
+ free(load_data);
+ }
+ }
+ if (sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2))
+ {
+ if (it > 50)
+ it = 50;
+ save_mode = 1;
+ }
+ if (sdl_key=='1')
+ {
+ set_cmode(CM_VEL);
+ }
+ if (sdl_key=='2')
+ {
+ set_cmode(CM_PRESS);
+ }
+ if (sdl_key=='3')
+ {
+ set_cmode(CM_PERS);
+ }
+ if (sdl_key=='4')
+ {
+ set_cmode(CM_FIRE);
+ }
+ if (sdl_key=='5')
+ {
+ set_cmode(CM_BLOB);
+ }
+ if (sdl_key=='6')
+ {
+ set_cmode(CM_HEAT);
+ }
+ if (sdl_key=='7')
+ {
+ set_cmode(CM_FANCY);
+ }
+ if (sdl_key=='8')
+ {
+ set_cmode(CM_NOTHING);
+ }
+ if (sdl_key=='9')
+ {
+ set_cmode(CM_GRAD);
+ }
+ if (sdl_key=='0')
+ {
+ set_cmode(CM_CRACK);
+ }
+ if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE)
+ {
+ set_cmode(CM_LIFE);
+ }
+ if (sdl_key==SDLK_TAB)
+ {
+ CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
+ }
+ if (sdl_key==SDLK_LEFTBRACKET) {
+ if (sdl_zoom_trig==1)
+ {
+ ZSIZE -= 1;
+ if (ZSIZE>60)
+ ZSIZE = 60;
+ if (ZSIZE<2)
+ ZSIZE = 2;
+ ZFACTOR = 256/ZSIZE;
+ }
+ else
+ {
+ if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx -= 1;
+ bsy -= 1;
+ }
+ else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx -= 1;
+ }
+ else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
+ {
+ bsy -= 1;
+ }
+ else
+ {
+ bsx -= ceil((bsx/5)+0.5f);
+ bsy -= ceil((bsy/5)+0.5f);
+ }
+ if (bsx>1180)
+ bsx = 1180;
+ if (bsy>1180)
+ bsy = 1180;
+ if (bsx<0)
+ bsx = 0;
+ if (bsy<0)
+ bsy = 0;
+ }
+ }
+ if (sdl_key==SDLK_RIGHTBRACKET) {
+ if (sdl_zoom_trig==1)
+ {
+ ZSIZE += 1;
+ if (ZSIZE>60)
+ ZSIZE = 60;
+ if (ZSIZE<2)
+ ZSIZE = 2;
+ ZFACTOR = 256/ZSIZE;
+ }
+ else
+ {
+ if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ {
+ bsx += 1;
+ bsy += 1;
+ }
+ else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
+ {
+ bsx += 1;
+ }
+ else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
+ {
+ bsy += 1;
+ }
+ else
+ {
+ bsx += ceil((bsx/5)+0.5f);
+ bsy += ceil((bsy/5)+0.5f);
+ }
+ if (bsx>1180)
+ bsx = 1180;
+ if (bsy>1180)
+ bsy = 1180;
+ if (bsx<0)
+ bsx = 0;
+ if (bsy<0)
+ bsy = 0;
+ }
+ }
+ if (sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2))
+ DEBUG_MODE = !DEBUG_MODE;
+ if (sdl_key=='i')
+ {
+ int nx, ny;
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = -pv[ny][nx];
+ vx[ny][nx] = -vx[ny][nx];
+ vy[ny][nx] = -vy[ny][nx];
+ }
+ }
+ if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
+ active_menu = 11;
+ if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE)
+ REPLACE_MODE = !REPLACE_MODE;
+ if (sdl_key==SDLK_BACKQUOTE)
+ {
+ console_mode = !console_mode;
+ //hud_enable = !console_mode;
+ }
+ if (sdl_key=='g')
+ {
+ if (sdl_mod & (KMOD_SHIFT))
+ GRID_MODE = (GRID_MODE+9)%10;
+ else
+ GRID_MODE = (GRID_MODE+1)%10;
+ }
+ if (sdl_key=='=')
+ {
+ int nx, ny;
+ if(sdl_mod & (KMOD_CTRL))
+ {
+ for(i=0; i<NPART; i++)
+ if(parts[i].type==PT_SPRK)
+ {
+ parts[i].type = parts[i].ctype;
+ parts[i].life = 0;
+ }
+ }
+ else
+ {
+ for (nx = 0; nx<XRES/CELL; nx++)
+ for (ny = 0; ny<YRES/CELL; ny++)
+ {
+ pv[ny][nx] = 0;
+ vx[ny][nx] = 0;
+ vy[ny][nx] = 0;
+ }
+ }
+ }
+
+ if (sdl_key=='w' && (!isplayer2 || (sdl_mod & (KMOD_SHIFT)))) //Gravity, by Moach
+ {
+ ++gravityMode; // cycle gravity mode
+ itc = 51;
+
+ switch (gravityMode)
+ {
+ default:
+ gravityMode = 0;
+ case 0:
+ strcpy(itc_msg, "Gravity: Vertical");
+ break;
+ case 1:
+ strcpy(itc_msg, "Gravity: Off");
+ break;
+ case 2:
+ strcpy(itc_msg, "Gravity: Radial");
+ break;
+
+ }
+ }
+ if (sdl_key=='y')
+ {
+ ++airMode;
+ itc = 52;
+
+ switch (airMode)
+ {
+ default:
+ airMode = 0;
+ case 0:
+ strcpy(itc_msg, "Air: On");
+ break;
+ case 1:
+ strcpy(itc_msg, "Air: Pressure Off");
+ break;
+ case 2:
+ strcpy(itc_msg, "Air: Velocity Off");
+ break;
+ case 3:
+ strcpy(itc_msg, "Air: Off");
+ break;
+ case 4:
+ strcpy(itc_msg, "Air: No Update");
+ break;
+ }
+ }
+
+ if (sdl_key=='t')
+ VINE_MODE = !VINE_MODE;
+ if (sdl_key==SDLK_SPACE)
+ sys_pause = !sys_pause;
+ if (sdl_key=='h')
+ hud_enable = !hud_enable;
+ if (sdl_key=='p')
+ dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
+ if (sdl_key=='v'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ if (clipboard_ready==1)
+ {
+ load_data = malloc(clipboard_length);
+ memcpy(load_data, clipboard_data, clipboard_length);
+ load_size = clipboard_length;
+ if (load_data)
+ {
+ load_img = prerender_save(load_data, load_size, &load_w, &load_h);
+ if (load_img)
+ load_mode = 1;
+ else
+ free(load_data);
+ }
+ }
+ }
+ if (sdl_key=='r'&&(sdl_mod & (KMOD_CTRL))&&(sdl_mod & (KMOD_SHIFT)))
+ {
+ save_mode = 1;
+ copy_mode = 4;//invert
+ }
+ else if (sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ save_mode = 1;
+ copy_mode = 3;//rotate
+ }
+ else if (sdl_key=='r')
+ GENERATION = 0;
+ if (sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ save_mode = 1;
+ copy_mode = 2;
+ }
+ if (sdl_key=='c'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
+ {
+ save_mode = 1;
+ copy_mode = 1;
+ }
+ else if (sdl_key=='c')
+ {
+ set_cmode((cmode+1) % CM_COUNT);
+ if (it > 50)
+ it = 50;
+ }
+ if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo
+ {
+ int cbx, cby, cbi;
+
+ for (cbi=0; cbi<NPART; cbi++)
+ parts[cbi] = cb_parts[cbi];
+
+ for (cby = 0; cby<YRES; cby++)
+ for (cbx = 0; cbx<XRES; cbx++)
+ pmap[cby][cbx] = cb_pmap[cby][cbx];
+
+ for (cby = 0; cby<(YRES/CELL); cby++)
+ for (cbx = 0; cbx<(XRES/CELL); cbx++)
+ {
+ vx[cby][cbx] = cb_vx[cby][cbx];
+ vy[cby][cbx] = cb_vy[cby][cbx];
+ pv[cby][cbx] = cb_pv[cby][cbx];
+ bmap[cby][cbx] = cb_bmap[cby][cbx];
+ emap[cby][cbx] = cb_emap[cby][cbx];
+ }
+ }
+ }
+ #ifdef PYCONSOLE
+ if(pkey!=NULL && sdl_key!=NULL)
+ {
+ pargs=Py_BuildValue("(c)",sdl_key);
+ pvalue = PyObject_CallObject(pkey, pargs);
+ Py_DECREF(pargs);
+ pargs=NULL;
+ if(pvalue==NULL)
+ strcpy(console_error,"failed to execute key code.");
+ //Py_DECREF(pvalue);
+ //puts("a");
+ pvalue=NULL;
+ }
+ #endif
+#ifdef INTERNAL
+ int counterthing;
+ if (sdl_key=='v'&&!(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
{
- if (load_mode)
- {
- free(load_img);
- free(load_data);
- load_mode = 0;
- load_data = NULL;
- load_img = NULL;
- }
- if (it > 50)
- it = 50;
- if (sdl_key=='k' && stamps[1].name[0])
- {
- j = stamp_ui(vid_buf);
- if (j>=0)
- load_data = stamp_load(j, &load_size);
+ if (sdl_mod & (KMOD_SHIFT)) {
+ if (vs>=1)
+ vs = 0;
else
- load_data = NULL;
+ vs = 3;//every other frame
}
else
- load_data = stamp_load(0, &load_size);
- if (load_data)
{
- load_img = prerender_save(load_data, load_size, &load_w, &load_h);
- if (load_img)
- load_mode = 1;
+ if (vs>=1)
+ vs = 0;
else
- free(load_data);
+ vs = 1;
}
+ counterthing = 0;
}
if ((sdl_key=='s' && (sdl_mod & (KMOD_CTRL))) || (sdl_key=='s' && !isplayer2))
{
@@ -1585,50 +2738,57 @@ int main(int argc, char *argv[])
}
if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE)
{
- set_cmode(CM_LIFE);
+ if (counterthing+1>=vs)
+ {
+ dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
+ counterthing = 0;
+ }
+ counterthing = (counterthing+1)%3;
}
- if (sdl_key==SDLK_TAB)
+#endif
+
+ if (sdl_wheel)
{
- CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
- }
- if (sdl_key==SDLK_LEFTBRACKET) {
if (sdl_zoom_trig==1)
{
- ZSIZE -= 1;
+ ZSIZE += sdl_wheel;
if (ZSIZE>60)
ZSIZE = 60;
if (ZSIZE<2)
ZSIZE = 2;
ZFACTOR = 256/ZSIZE;
+ sdl_wheel = 0;
}
else
{
- if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
+ if (!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
{
- bsx -= 1;
- bsy -= 1;
+ bsx += sdl_wheel;
+ bsy += sdl_wheel;
}
else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
{
- bsx -= 1;
+ bsx += sdl_wheel;
}
else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
{
- bsy -= 1;
- }
- else
- {
- bsx -= ceil((bsx/5)+0.5f);
- bsy -= ceil((bsy/5)+0.5f);
+ bsy += sdl_wheel;
}
if (bsx>1180)
bsx = 1180;
- if (bsy>1180)
- bsy = 1180;
if (bsx<0)
bsx = 0;
+ if (bsy>1180)
+ bsy = 1180;
if (bsy<0)
bsy = 0;
+ sdl_wheel = 0;
+ /*if(su >= PT_NUM) {
+ if(sl < PT_NUM)
+ su = sl;
+ if(sr < PT_NUM)
+ su = sr;
+ }*/
}
}
if (sdl_key==SDLK_RIGHTBRACKET) {
@@ -2159,7 +3319,7 @@ int main(int argc, char *argv[])
if (!sdl_zoom_trig && zoom_en==1)
zoom_en = 0;
- if (sdl_key=='z' && zoom_en==2)
+ if (sdl_key=='z' && zoom_en==2 && sys_shortcuts==1)
zoom_en = 1;
if (load_mode)
@@ -2764,7 +3924,6 @@ int main(int argc, char *argv[])
if(!console_mode)
hud_enable = 1;
}
-
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
//Setting an element for the stick man
@@ -2782,13 +3941,14 @@ int main(int argc, char *argv[])
else
player2[2] = PT_DUST;
}
-
}
SDL_CloseAudio();
http_done();
+ Py_Finalize();//cleanup any python stuff.
return 0;
}
-int process_command(pixel *vid_buf,char *console,char *console_error) {
+#ifdef PYCONSOLE
+int process_command(pixel *vid_buf,char *console,char *console_error,PyObject *pfunc) {
int y,x,nx,ny,i,j,k,m;
int do_next = 1;
char xcoord[10];
@@ -2797,6 +3957,7 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
char console3[15];
char console4[15];
char console5[15];
+ PyObject *pvalue,*pargs;
//sprintf(console_error, "%s", console);
if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
{
@@ -3251,4 +4412,4 @@ int process_command(pixel *vid_buf,char *console,char *console_error) {
}
return 1;
}
-
+#endif