Finish WIN32 register_extension, fix Visual Studio compile

This commit is contained in:
jacksonmj 2011-03-27 18:13:52 +01:00 committed by Simon
parent 651208c5fb
commit 592b923b66
4 changed files with 53 additions and 45 deletions

View File

@ -42,10 +42,10 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
if(fe){ 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 orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations 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); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for(r = 0; r < 4; r++){ for(r = 0; r < 4; r++){
if(orbd[r]>1){ if(orbd[r]>1){

View File

@ -63,10 +63,10 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
} }
} }
if(fe){ 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 orbd[4] = {0, 0, 0, 0}; //Orbital distances
int orbl[4] = {0, 0, 0, 0}; //Orbital locations 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); orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl);
for(r = 0; r < 4; r++){ for(r = 0; r < 4; r++){
if(orbd[r]<254){ if(orbd[r]<254){

View File

@ -1324,11 +1324,12 @@ static PyObject* emb_console_less(PyObject *self, PyObject *args)
static PyObject* emb_reset_pressure(PyObject *self, PyObject *args) static PyObject* emb_reset_pressure(PyObject *self, PyObject *args)
{ {
int nx, ny;
if(!PyArg_ParseTuple(args, ":reset_pressure")) if(!PyArg_ParseTuple(args, ":reset_pressure"))
return NULL; return NULL;
// //
for (int nx = 0; nx<XRES/CELL; nx++) for (nx = 0; nx<XRES/CELL; nx++)
for (int ny = 0; ny<YRES/CELL; ny++) for (ny = 0; ny<YRES/CELL; ny++)
{ {
pv[ny][nx] = 0; pv[ny][nx] = 0;
} }
@ -1337,11 +1338,12 @@ static PyObject* emb_reset_pressure(PyObject *self, PyObject *args)
static PyObject* emb_reset_velocity(PyObject *self, PyObject *args) static PyObject* emb_reset_velocity(PyObject *self, PyObject *args)
{ {
int nx, ny;
if(!PyArg_ParseTuple(args, ":reset_velocity")) if(!PyArg_ParseTuple(args, ":reset_velocity"))
return NULL; return NULL;
// //
for (int nx = 0; nx<XRES/CELL; nx++) for (nx = 0; nx<XRES/CELL; nx++)
for (int ny = 0; ny<YRES/CELL; ny++) for (ny = 0; ny<YRES/CELL; ny++)
{ {
vx[ny][nx] = 0; vx[ny][nx] = 0;
vy[ny][nx] = 0; vy[ny][nx] = 0;
@ -1351,10 +1353,11 @@ static PyObject* emb_reset_velocity(PyObject *self, PyObject *args)
static PyObject* emb_reset_sparks(PyObject *self, PyObject *args) static PyObject* emb_reset_sparks(PyObject *self, PyObject *args)
{ {
int i;
if(!PyArg_ParseTuple(args, ":reset_sparks")) if(!PyArg_ParseTuple(args, ":reset_sparks"))
return NULL; return NULL;
// //
for(int i=0; i<NPART; i++) for(i=0; i<NPART; i++)
{ {
if(parts[i].type==PT_SPRK) if(parts[i].type==PT_SPRK)
{ {
@ -2059,7 +2062,6 @@ int main(int argc, char *argv[])
int past = 0; int past = 0;
void *http_ver_check; void *http_ver_check;
void *http_session_check = NULL; void *http_session_check = NULL;
vid_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
char *ver_data=NULL, *check_data=NULL, *tmp; 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; 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; int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
SDL_AudioSpec fmt; SDL_AudioSpec fmt;
int username_flash = 0, username_flash_t = 1; int username_flash = 0, username_flash_t = 1;
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
GSPEED = 1;
#ifdef PYCONSOLE #ifdef PYCONSOLE
PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey; PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs,*pstep,*pkey;
PyObject *tpt_console_obj;
#endif #endif
vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
GSPEED = 1;
/* Set 16-bit stereo audio at 22Khz */ /* Set 16-bit stereo audio at 22Khz */
fmt.freq = 22050; fmt.freq = 22050;
@ -2106,7 +2110,7 @@ int main(int argc, char *argv[])
pmodule = PyImport_Import(pname);//import module pmodule = PyImport_Import(pname);//import module
Py_DECREF(pname);//throw away string Py_DECREF(pname);//throw away string
#else #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); pmodule=PyImport_ExecCodeModule("tpt_console", tpt_console_obj);
#endif #endif
if(pmodule!=NULL) if(pmodule!=NULL)

View File

@ -16,6 +16,9 @@
#include "interface.h" #include "interface.h"
#include "graphics.h" #include "graphics.h"
#include "powder.h" #include "powder.h"
#if defined WIN32
#include <windows.h>
#endif
//Signum function //Signum function
#if defined(WIN32) && !defined(__GNUC__) #if defined(WIN32) && !defined(__GNUC__)
@ -403,16 +406,17 @@ int register_extension()
{ {
#if defined INSTALLABLE #if defined INSTALLABLE
#if defined WIN32 #if defined WIN32
LONG rresult; LONG rresult;
HKEY newkey; HKEY newkey;
char *currentfilename; char currentfilename[MAX_PATH] = "";
char *iconname; char *iconname;
char *opencommand; char *opencommand;
currentfilename = exe_name(); if (!GetModuleFileName(NULL, currentfilename, MAX_PATH))
iconname = malloc(strlen(currentfilename)+3); return 0;
currentfilename[MAX_PATH-1] = 0;
iconname = malloc(strlen(currentfilename)+6);
opencommand = malloc(strlen(currentfilename)+13); opencommand = malloc(strlen(currentfilename)+13);
sprintf(iconname, "%s,1", currentfilename); sprintf(iconname, "%s,-101", currentfilename);
sprintf(opencommand, "\"%s\" open:\"%%1\"", currentfilename); sprintf(opencommand, "\"%s\" open:\"%%1\"", currentfilename);
//Create extension entry //Create extension entry