diff options
| author | jacksonmj <mj-pt@jacksonmj.co.uk> | 2011-03-27 17:13:52 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2011-04-04 15:10:03 (GMT) |
| commit | 592b923b6610bf5f90812a8f514abb8ce4f677d1 (patch) | |
| tree | 059e5360acf98cc7cdcdd43f4918e6216ad8259c /src | |
| parent | 651208c5fbba5d0703e174a6abe2c8a228730803 (diff) | |
| download | powder-592b923b6610bf5f90812a8f514abb8ce4f677d1.zip powder-592b923b6610bf5f90812a8f514abb8ce4f677d1.tar.gz | |
Finish WIN32 register_extension, fix Visual Studio compile
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/prti.c | 4 | ||||
| -rw-r--r-- | src/elements/prto.c | 4 | ||||
| -rw-r--r-- | src/main.c | 76 | ||||
| -rw-r--r-- | src/misc.c | 14 |
4 files changed, 53 insertions, 45 deletions
diff --git a/src/elements/prti.c b/src/elements/prti.c index 2b08aae..5c34cf9 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -42,10 +42,10 @@ int update_PRTI(UPDATE_FUNC_ARGS) { if(fe){ - if(!parts[i].life) parts[i].life = rand(); - if(!parts[i].ctype) parts[i].life = rand(); int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbl[4] = {0, 0, 0, 0}; //Orbital locations + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); for(r = 0; r < 4; r++){ if(orbd[r]>1){ diff --git a/src/elements/prto.c b/src/elements/prto.c index adf82a7..40cf97c 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -63,10 +63,10 @@ int update_PRTO(UPDATE_FUNC_ARGS) { } } if(fe){ - if(!parts[i].life) parts[i].life = rand(); - if(!parts[i].ctype) parts[i].life = rand(); int orbd[4] = {0, 0, 0, 0}; //Orbital distances int orbl[4] = {0, 0, 0, 0}; //Orbital locations + if(!parts[i].life) parts[i].life = rand(); + if(!parts[i].ctype) parts[i].life = rand(); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); for(r = 0; r < 4; r++){ if(orbd[r]<254){ @@ -1324,45 +1324,48 @@ static PyObject* emb_console_less(PyObject *self, PyObject *args) static PyObject* 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); + int nx, ny; + if(!PyArg_ParseTuple(args, ":reset_pressure")) + return NULL; + // + for (nx = 0; nx<XRES/CELL; nx++) + for (ny = 0; ny<YRES/CELL; ny++) + { + pv[ny][nx] = 0; + } + return Py_BuildValue("i",1); } static PyObject* 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); + int nx, ny; + if(!PyArg_ParseTuple(args, ":reset_velocity")) + return NULL; + // + for (nx = 0; nx<XRES/CELL; nx++) + for (ny = 0; ny<YRES/CELL; ny++) + { + vx[ny][nx] = 0; + vy[ny][nx] = 0; + } + return Py_BuildValue("i",1); } static PyObject* 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); + int i; + if(!PyArg_ParseTuple(args, ":reset_sparks")) + return NULL; + // + for(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); } static PyObject* emb_set_life(PyObject *self, PyObject *args, PyObject *keywds) @@ -2059,7 +2062,6 @@ int main(int argc, char *argv[]) int past = 0; 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] = ""; 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; @@ -2076,11 +2078,13 @@ int main(int argc, char *argv[]) int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0; SDL_AudioSpec fmt; int username_flash = 0, username_flash_t = 1; +#ifdef PYCONSOLE + PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey; + PyObject *tpt_console_obj; +#endif + vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); 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; @@ -2106,7 +2110,7 @@ int main(int argc, char *argv[]) pmodule = PyImport_Import(pname);//import module Py_DECREF(pname);//throw away string #else - PyObject *tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8); + tpt_console_obj = PyMarshal_ReadObjectFromString(tpt_console_pyc+8, sizeof(tpt_console_pyc)-8); pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj); #endif if(pmodule!=NULL) @@ -16,6 +16,9 @@ #include "interface.h" #include "graphics.h" #include "powder.h" +#if defined WIN32 +#include <windows.h> +#endif //Signum function #if defined(WIN32) && !defined(__GNUC__) @@ -403,16 +406,17 @@ int register_extension() { #if defined INSTALLABLE #if defined WIN32 - LONG rresult; HKEY newkey; - char *currentfilename; + char currentfilename[MAX_PATH] = ""; char *iconname; char *opencommand; - currentfilename = exe_name(); - iconname = malloc(strlen(currentfilename)+3); + if (!GetModuleFileName(NULL, currentfilename, MAX_PATH)) + return 0; + currentfilename[MAX_PATH-1] = 0; + iconname = malloc(strlen(currentfilename)+6); opencommand = malloc(strlen(currentfilename)+13); - sprintf(iconname, "%s,1", currentfilename); + sprintf(iconname, "%s,-101", currentfilename); sprintf(opencommand, "\"%s\" open:\"%%1\"", currentfilename); //Create extension entry |
