From 626cc8fa6a6cf5e2f046d138b72e3122614c46ad Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Apr 2011 15:28:57 +0100 Subject: Remove a TON of warnings diff --git a/includes/graphics.h b/includes/graphics.h index eed3ed6..31f8c57 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -64,17 +64,9 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc); void draw_menu(pixel *vid_buf, int i, int hover); -#if defined(WIN32) && !defined(__GNUC__) -_inline void drawpixel(pixel *vid, int x, int y, int r, int g, int b, int a); -#else -extern inline void drawpixel(pixel *vid, int x, int y, int r, int g, int b, int a); -#endif +void drawpixel(pixel *vid, int x, int y, int r, int g, int b, int a); -#if defined(WIN32) && !defined(__GNUC__) -_inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a); -#else -extern inline int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a); -#endif +int drawchar(pixel *vid, int x, int y, int c, int r, int g, int b, int a); int drawtext(pixel *vid, int x, int y, const char *s, int r, int g, int b, int a); @@ -99,13 +91,10 @@ void textnpos(char *s, int n, int w, int *cx, int *cy); int textwidthx(char *s, int w); int textposxy(char *s, int width, int w, int h); + int textwrapheight(char *s, int width); -#if defined(WIN32) && !defined(__GNUC__) -_inline void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a); -#else void blendpixel(pixel *vid, int x, int y, int r, int g, int b, int a); -#endif void draw_icon(pixel *vid_buf, int x, int y, char ch, int flag); @@ -122,7 +111,9 @@ void xor_line(int x1, int y1, int x2, int y2, pixel *vid); void xor_rect(pixel *vid, int x, int y, int w, int h); void draw_parts(pixel *vid); + void draw_wavelengths(pixel *vid, int x, int y, int h, int wl); + void render_signs(pixel *vid_buf); void render_fire(pixel *dst); diff --git a/includes/misc.h b/includes/misc.h index c3ba03e..ef23b1e 100644 --- a/includes/misc.h +++ b/includes/misc.h @@ -20,24 +20,13 @@ __asm__ __volatile ("cpuid":\ #endif static char hex[] = "0123456789ABCDEF"; + //Signum function -#if defined(WIN32) && !defined(__GNUC__) -extern _inline int isign(float i); -#else -extern inline int isign(float i); -#endif +int isign(float i); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline unsigned clamp_flt(float f, float min, float max); -#else -extern inline unsigned clamp_flt(float f, float min, float max); -#endif +unsigned clamp_flt(float f, float min, float max); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline float restrict_flt(float f, float min, float max); -#else -extern inline float restrict_flt(float f, float min, float max); -#endif +float restrict_flt(float f, float min, float max); char *mystrdup(char *s); diff --git a/includes/powder.h b/includes/powder.h index 8e40ead..66614b2 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -814,43 +814,19 @@ static void create_gain_photon(int pp); void kill_part(int i); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline void part_change_type(int i, int x, int y, int t); -#else -extern inline void part_change_type(int i, int x, int y, int t); -#endif +void part_change_type(int i, int x, int y, int t); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline int create_part(int p, int x, int y, int t); -#else -extern inline int create_part(int p, int x, int y, int t); -#endif +int create_part(int p, int x, int y, int t); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline void delete_part(int x, int y); -#else -extern inline void delete_part(int x, int y); -#endif +void delete_part(int x, int y); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline int is_wire(int x, int y); -#else -extern inline int is_wire(int x, int y); -#endif +int is_wire(int x, int y); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline int is_wire_off(int x, int y); -#else -extern inline int is_wire_off(int x, int y); -#endif +int is_wire_off(int x, int y); void set_emap(int x, int y); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline int parts_avg(int ci, int ni, int t); -#else -extern int parts_avg(int ci, int ni, int t); -#endif +int parts_avg(int ci, int ni, int t); int nearest_part(int ci, int t); @@ -869,20 +845,11 @@ int flood_parts(int x, int y, int c, int cm, int bm); int create_parts(int x, int y, int rx, int ry, int c); void create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c); -void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate); - -#if defined(WIN32) && !defined(__GNUC__) -extern _inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); -#else -extern inline void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); -#endif +void *transform_save(void *odata, int *size, matrix2d transform, vector2d translate); +void orbitalparts_get(int block1, int block2, int resblock1[], int resblock2[]); -#if defined(WIN32) && !defined(__GNUC__) -extern _inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); -#else -extern inline void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); -#endif +void orbitalparts_set(int *block1, int *block2, int resblock1[], int resblock2[]); #endif diff --git a/src/main.c b/src/main.c index c019bfd..c6776d3 100644 --- a/src/main.c +++ b/src/main.c @@ -2049,2310 +2049,2311 @@ static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your fun }; #endif -int main(int argc, char *argv[]) -{ - int hud_enable = 1; - int active_menu = 0; -#ifdef BETA - int is_beta = 0; -#endif - char uitext[512] = ""; - char heattext[256] = ""; - char coordtext[128] = ""; - int currentTime = 0; - int FPS = 0; - int pastFPS = 0; - int elapsedTime = 0; - int limitFPS = 60; - void *http_ver_check; - void *http_session_check = NULL; - 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; -#ifdef INTERNAL - int vs = 0; -#endif - int wavelength_gfx = 0; - int x, y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty; - int da = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2; - float nfvx, nfvy; - int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0; - void *load_data=NULL; - pixel *load_img=NULL;//, *fbi_img=NULL; - 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; - - /* Set 16-bit stereo audio at 22Khz */ - fmt.freq = 22050; - fmt.format = AUDIO_S16; - fmt.channels = 2; - fmt.samples = 512; - fmt.callback = mixaudio; - fmt.userdata = NULL; - #ifdef PYCONSOLE - //initialise python console - Py_Initialize(); - PyRun_SimpleString("print 'python present.'"); - Py_InitModule("tpt", EmbMethods); - - //change the path to find all the correct modules - PyRun_SimpleString("import sys\nsys.path.append('./tptPython.zip')\nsys.path.append('.')"); - //load the console module and whatnot -#ifdef PYEXT - PyRun_SimpleString(tpt_console_py); - printf("using external python console file.\n"); - pname=PyString_FromString("tpt_console");//create string object - pmodule = PyImport_Import(pname);//import module - Py_DECREF(pname);//throw away string -#else - 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) +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]; + char ycoord[10]; + char console2[15]; + 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) { - 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"); - pyready = 0; - pygood = 0; - } - - 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 + sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?! + if (strcmp(console2, "quit")==0) { - printf("unable to find key function. ignoring.\n"); + return -1; + } else { + //handle them command + pargs=Py_BuildValue("(s)",console); + pvalue = PyObject_CallObject(pfunc, pargs); + Py_DECREF(pargs); + pargs=NULL; + if (pvalue==NULL) + strcpy(console_error,"failed to execute code."); + pvalue=NULL; } } - else - { - //sys.stderr - PyErr_Print(); - printf("unable to find console module, missing file or mangled console.py?\n"); - pyready = 0; - pygood = 0; - } -#else - printf("python console disabled at compile time."); -#endif - -#ifdef MT - numCores = core_count(); -#endif -//TODO: Move out version stuff -#ifdef BETA - if (is_beta) - { - old_ver_len = textwidth(old_ver_msg_beta); - } - else - { - old_ver_len = textwidth(old_ver_msg); - } -#else - old_ver_len = textwidth(old_ver_msg); + return 1; +} #endif - menu_count(); - parts = calloc(sizeof(particle), NPART); - cb_parts = calloc(sizeof(particle), NPART); - for (i=0; i1180) - bsx = 1180; - if (bsx<0) - bsx = 0; - if (bsy>1180) - bsy = 1180; - if (bsy<0) - bsy = 0; - - update_particles(vid_buf); //update everything - draw_parts(vid_buf); //draw particles - - if (cmode==CM_PERS) - { - if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames - { - dim_copy_pers(pers_bg, vid_buf); - } - else - { - memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); - } - fire_fc = (fire_fc+1) % 3; - } - if (cmode==CM_FIRE||cmode==CM_BLOB||cmode==CM_FANCY) - render_fire(vid_buf); - - render_signs(vid_buf); - - memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas - clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES); - - draw_svf_ui(vid_buf); - - if (http_ver_check) - { - if (!do_check && http_async_req_status(http_ver_check)) - { - ver_data = http_async_req_stop(http_ver_check, &http_ret, NULL); - if (http_ret==200 && ver_data) - { -#ifdef BETA - if (sscanf(ver_data, "%d.%d.%d", &major, &minor, &is_beta)==3) - if (major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION) || (major==SAVE_VERSION && is_beta == 0)) - old_version = 1; -#else - if (sscanf(ver_data, "%d.%d", &major, &minor)==2) - if (major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION)) - old_version = 1; -#endif - free(ver_data); - } - http_ver_check = NULL; - } - do_check = (do_check+1) & 15; - } - if (http_session_check) - { - if (!do_s_check && http_async_req_status(http_session_check)) - { - check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL); - if (http_ret==200 && check_data) + if (file_script) { + FILE *f=fopen(console3, "r"); + if (f) { - if (!strncmp(check_data, "EXPIRED", 7)) - { - //Session expired - strcpy(svf_user, ""); - strcpy(svf_pass, ""); - strcpy(svf_user_id, ""); - strcpy(svf_session_id, ""); - svf_login = 0; - svf_own = 0; - svf_admin = 0; - svf_mod = 0; - } - else if (!strncmp(check_data, "BANNED", 6)) - { - //User banned - strcpy(svf_user, ""); - strcpy(svf_pass, ""); - strcpy(svf_user_id, ""); - strcpy(svf_session_id, ""); - svf_login = 0; - svf_own = 0; - svf_admin = 0; - svf_mod = 0; - error_ui(vid_buf, 0, "Unable to log in\nYour account has been suspended, consider reading the rules."); - } - else if (!strncmp(check_data, "OK", 2)) + char fileread[5000];//TODO: make this change with file size + char pch[5000]; + char tokens[10]; + int tokensize; + nx = 0; + ny = 0; + j = 0; + m = 0; + if (console4[0]) + console_parse_coords(console4, &nx , &ny, console_error); + memset(pch,0,sizeof(pch)); + memset(fileread,0,sizeof(fileread)); + fread(fileread,1,5000,f); + for (i=0; i2) { - //User is elevated - if (!strncmp(check_data+3, "ADMIN", 5)) + if (fileread[i] != '\n') + { + pch[i-j] = fileread[i]; + if (fileread[i] != ' ') + tokens[i-m] = fileread[i]; + } + if (fileread[i] == ' ' || fileread[i] == '\n') + { + if (sregexp(tokens,"^x.[0-9],y.[0-9]")==0)//TODO: fix regex matching to work with x,y ect, right now it has to have a +0 or -0 { - svf_admin = 1; - svf_mod = 0; + char temp[5]; + int starty = 0; + tokensize = strlen(tokens); + x = 0; + y = 0; + sscanf(tokens,"x%d,y%d",&x,&y); + sscanf(tokens,"%9s,%9s",xcoord,ycoord); + x += nx; + y += ny; + sprintf(xcoord,"%d",x); + sprintf(ycoord,"%d",y); + for (k = 0; k30) { - username_flash_t = -1; - username_flash = 30; - } else if (username_flash<0) { - username_flash_t = 1; - username_flash = 0; + //sprintf(console_error, "%s exists", console3); + fclose(f); } - username_flash += username_flash_t; - if (svf_login) - drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 175-(username_flash*5)); else - drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[checking]", 255, 255, 255, 255); + { + sprintf(console_error, "%s does not exist", console3); + } } - do_s_check = (do_s_check+1) & 15; + else + { + sprintf(console_error, "Scripts are not enabled"); + } + } - - if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts + else if (strcmp(console2, "sound")==0 && console3[0]) { - if (sdl_key=='q' || sdl_key==SDLK_ESCAPE) + if (sound_enable) play_sound(console3); + else strcpy(console_error, "Audio device not available - cannot play sounds"); + } + else if (strcmp(console2, "python")==0) + if (pygood==1) + pyready=1; + else + strcpy(console_error, "python not ready. check stdout for more info."); + else if (strcmp(console2, "load")==0 && console3[0]) { - if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit")) + j = atoi(console3); + if (j) { - break; + open_ui(vid_buf, console3, NULL); + console_mode = 0; } } - if (sdl_key=='i' && (sdl_mod & KMOD_CTRL)) + else if (strcmp(console2, "if")==0 && console3[0]) { - if(confirm_ui(vid_buf, "Install Powder Toy", "You are about to install The Powder Toy", "Install")) + if (strcmp(console3, "type")==0)//TODO: add more than just type, and be able to check greater/less than { - if(register_extension()) + if (console_parse_partref(console4, &i, console_error) + && console_parse_type(console5, &j, console_error)) { - info_ui(vid_buf, "Install success", "Powder Toy has been installed!"); + if (parts[i].type==j) + return 1; + else + return 0; } else - { - error_ui(vid_buf, 0, "Install failed - You may not have permission or you may be on a platform that does not support installation"); - } + return 0; } } - //if(sdl_key=='d' && isplayer) - //{ - // death = 1; - // //death = !(death); - //} - if (sdl_key=='f') + else if (strcmp(console2, "create")==0 && console3[0] && console4[0]) { - framerender = 1; + if (console_parse_type(console3, &j, console_error) + && console_parse_coords(console4, &nx, &ny, console_error)) + { + if (!j) + strcpy(console_error, "Cannot create particle with type NONE"); + else if (create_part(-1,nx,ny,j)<0) + strcpy(console_error, "Could not create particle"); + } } - if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0]) + else if ((strcmp(console2, "delete")==0 || strcmp(console2, "kill")==0) && console3[0]) { - if (load_mode) + if (console_parse_partref(console3, &i, console_error)) + kill_part(i); + } + else if (strcmp(console2, "reset")==0 && console3[0]) + { + if (strcmp(console3, "pressure")==0) { - free(load_img); - free(load_data); - load_mode = 0; - load_data = NULL; - load_img = NULL; + for (nx = 0; nx 50) - it = 50; - if (sdl_key=='k' && stamps[1].name[0]) + else if (strcmp(console3, "velocity")==0) { - j = stamp_ui(vid_buf); - if (j>=0) - load_data = stamp_load(j, &load_size); - else - load_data = NULL; + for (nx = 0; nx 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) + else if (strcmp(console3, "temp")==0) { - ZSIZE -= 1; - if (ZSIZE>60) - ZSIZE = 60; - if (ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; + for (i=0; i1180) - 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) + if (strcmp(console3, "temp")==0) { - ZSIZE += 1; - if (ZSIZE>60) - ZSIZE = 60; - if (ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; + if (strcmp(console4, "all")==0) + { + f = atof(console5); + for (i=0; i1180) - 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 50) - it = 50; - } - if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo - { - int cbx, cby, cbi; + else + strcpy(console_error, "Invalid Command"); + } + return 1; +} - for (cbi=0; cbi=1) - vs = 0; - else - vs = 3;//every other frame + /* Open the audio device and start playing sound! */ + if ( SDL_OpenAudio(&fmt, NULL) < 0 ) + { + fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError()); } else { - if (vs>=1) - vs = 0; - else - vs = 1; + sound_enable = 1; + SDL_PauseAudio(0); } - counterthing = 0; } - if (vs) + else if (!strncmp(argv[i], "scripts", 5)) { - if (counterthing+1>=vs) + file_script = 1; + } + else if (!strncmp(argv[i], "open", 4) && i+11180) + bsx = 1180; + if (bsx<0) + bsx = 0; + if (bsy>1180) + bsy = 1180; + if (bsy<0) + bsy = 0; + + update_particles(vid_buf); //update everything + draw_parts(vid_buf); //draw particles + + if (cmode==CM_PERS) { - if (sdl_zoom_trig==1)//zoom window change + if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames { - ZSIZE += sdl_wheel; - if (ZSIZE>60) - ZSIZE = 60; - if (ZSIZE<2) - ZSIZE = 2; - ZFACTOR = 256/ZSIZE; - sdl_wheel = 0; + dim_copy_pers(pers_bg, vid_buf); } - else //change brush size + else { - if (!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) - { - bsx += sdl_wheel; - bsy += sdl_wheel; - } - else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) - { - bsx += sdl_wheel; - } - else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) - { - bsy += sdl_wheel; - } - if (bsx>1180) - bsx = 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; - }*/ + memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE); } + fire_fc = (fire_fc+1) % 3; } + if (cmode==CM_FIRE||cmode==CM_BLOB||cmode==CM_FANCY) + render_fire(vid_buf); - bq = b; // bq is previous mouse state - b = SDL_GetMouseState(&x, &y); // b is current mouse state + render_signs(vid_buf); - for (i=0; i=sdl_scale*(XRES-2) && x= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && ySAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION) || (major==SAVE_VERSION && is_beta == 0)) + old_version = 1; +#else + if (sscanf(ver_data, "%d.%d", &major, &minor)==2) + if (major>SAVE_VERSION || (major==SAVE_VERSION && minor>MINOR_VERSION)) + old_version = 1; +#endif + free(ver_data); + } + http_ver_check = NULL; } + do_check = (do_check+1) & 15; } - menu_ui_v3(vid_buf, active_menu, &sl, &sr, b, bq, x, y); //draw the elements in the current menu - - if (zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy //change mouse position while it is in a zoom window - && x0 && y0 && x>8)>=NPART || !cr)) + if (!do_s_check && http_async_req_status(http_session_check)) { - if (DEBUG_MODE) + check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL); + if (http_ret==200 && check_data) { - int tctype = parts[cr>>8].ctype; - if (tctype>=PT_NUM || tctype<0 || (cr&0xFF)==PT_PHOT) - tctype = 0; - if ((cr&0xFF)==PT_PIPE) + if (!strncmp(check_data, "EXPIRED", 7)) + { + //Session expired + strcpy(svf_user, ""); + strcpy(svf_pass, ""); + strcpy(svf_user_id, ""); + strcpy(svf_session_id, ""); + svf_login = 0; + svf_own = 0; + svf_admin = 0; + svf_mod = 0; + } + else if (!strncmp(check_data, "BANNED", 6)) + { + //User banned + strcpy(svf_user, ""); + strcpy(svf_pass, ""); + strcpy(svf_user_id, ""); + strcpy(svf_session_id, ""); + svf_login = 0; + svf_own = 0; + svf_admin = 0; + svf_mod = 0; + error_ui(vid_buf, 0, "Unable to log in\nYour account has been suspended, consider reading the rules."); + } + else if (!strncmp(check_data, "OK", 2)) + { + //Session valid + if (strlen(check_data)>2) { + //User is elevated + if (!strncmp(check_data+3, "ADMIN", 5)) + { + svf_admin = 1; + svf_mod = 0; + } + else if (!strncmp(check_data+3, "MOD", 3)) + { + svf_admin = 0; + svf_mod = 1; + } + } + } + else { - if (parts[cr>>8].tmp>8].tmp; - else tctype = 0; + //No idea, but log the user out anyway + strcpy(svf_user, ""); + strcpy(svf_pass, ""); + strcpy(svf_user_id, ""); + strcpy(svf_session_id, ""); + svf_login = 0; + svf_own = 0; + svf_admin = 0; + svf_mod = 0; } - sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); - sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale); + save_presets(0); + free(check_data); } else { -#ifdef BETA - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); -#else - sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); -#endif + //Unable to check session, YOU WILL BE TERMINATED + strcpy(svf_user, ""); + strcpy(svf_pass, ""); + strcpy(svf_user_id, ""); + strcpy(svf_session_id, ""); + svf_login = 0; + svf_own = 0; + svf_admin = 0; + svf_mod = 0; } - if ((cr&0xFF)==PT_PHOT) wavelength_gfx = parts[cr>>8].ctype; - } - else - { - sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); - if (DEBUG_MODE) - { - sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); + http_session_check = NULL; + } else { + clearrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14); + drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255); + drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255); + if (username_flash>30) { + username_flash_t = -1; + username_flash = 30; + } else if (username_flash<0) { + username_flash_t = 1; + username_flash = 0; } - } - } - - mx = x; - my = y; - if (update_flag) - { - info_box(vid_buf, "Finalizing update..."); - if (last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION)) - { - update_cleanup(); - error_ui(vid_buf, 0, "Update failed - try downloading a new version."); - } - else - { - if (update_finish()) - error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + username_flash += username_flash_t; + if (svf_login) + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 175-(username_flash*5)); else - info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!"); + drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[checking]", 255, 255, 255, 255); } - update_flag = 0; + do_s_check = (do_s_check+1) & 15; } - if (b && !bq && x>=(XRES-19-old_ver_len)*sdl_scale && - x<=(XRES-14)*sdl_scale && y>=(YRES-22)*sdl_scale && y<=(YRES-9)*sdl_scale && old_version) + if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts { - tmp = malloc(64); -#ifdef BETA - if (is_beta) - { - sprintf(tmp, "Your version: %d (Beta %d), new version: %d (Beta %d).", SAVE_VERSION, MINOR_VERSION, major, minor); - } - else + if (sdl_key=='q' || sdl_key==SDLK_ESCAPE) { - sprintf(tmp, "Your version: %d (Beta %d), new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); + if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit")) + { + break; + } } -#else - sprintf(tmp, "Your version: %d.%d, new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); -#endif - if (confirm_ui(vid_buf, "Do you want to update The Powder Toy?", tmp, "Update")) + if (sdl_key=='i' && (sdl_mod & KMOD_CTRL)) { - free(tmp); - tmp = download_ui(vid_buf, my_uri, &i); - if (tmp) + if(confirm_ui(vid_buf, "Install Powder Toy", "You are about to install The Powder Toy", "Install")) { - save_presets(1); - if (update_start(tmp, i)) + if(register_extension()) { - update_cleanup(); - save_presets(0); - error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + info_ui(vid_buf, "Install success", "Powder Toy has been installed!"); } else - return 0; + { + error_ui(vid_buf, 0, "Install failed - You may not have permission or you may be on a platform that does not support installation"); + } } } - else - free(tmp); - } - if (y>=sdl_scale*(YRES+(MENUSIZE-20))) //mouse checks for buttons at the bottom, to draw mouseover texts - { - if (x>=189*sdl_scale && x<=202*sdl_scale && svf_login && svf_open && svf_myvote==0) - { - db = svf_own ? 275 : 272; - if (da < 51) - da ++; - } - else if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0) - { - db = svf_own ? 275 : 272; - if (da < 51) - da ++; - } - else if (x>=189 && x<=217 && svf_login && svf_open && svf_myvote!=0) + //if(sdl_key=='d' && isplayer) + //{ + // death = 1; + // //death = !(death); + //} + if (sdl_key=='f') { - db = (svf_myvote==1) ? 273 : 274; - if (da < 51) - da ++; + framerender = 1; } - else if (x>=219*sdl_scale && x<=((XRES+BARSIZE-(510-349))*sdl_scale) && svf_login && svf_open) + if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0]) { - db = svf_own ? 257 : 256; - if (da < 51) - da ++; + 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); + } } - else if (x>=((XRES+BARSIZE-(510-351))*sdl_scale) && x<((XRES+BARSIZE-(510-366))*sdl_scale)) + if (sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2)) { - db = 270; - if (da < 51) - da ++; + if (it > 50) + it = 50; + save_mode = 1; } - else if (x>=((XRES+BARSIZE-(510-367))*sdl_scale) && x<((XRES+BARSIZE-(510-383))*sdl_scale)) + if (sdl_key=='1') { - db = 266; - if (da < 51) - da ++; + set_cmode(CM_VEL); } - else if (x>=37*sdl_scale && x<=187*sdl_scale && svf_login) + if (sdl_key=='2') { - db = 259; - if (svf_open && svf_own && x<=55*sdl_scale) - db = 258; - if (da < 51) - da ++; + set_cmode(CM_PRESS); } - else if (x>=((XRES+BARSIZE-(510-385))*sdl_scale) && x<=((XRES+BARSIZE-(510-476))*sdl_scale)) + if (sdl_key=='3') { - db = svf_login ? 261 : 260; - if (svf_admin) - { - db = 268; - } - else if (svf_mod) - { - db = 271; - } - if (da < 51) - da ++; + set_cmode(CM_PERS); } - else if (x>=sdl_scale && x<=17*sdl_scale) + if (sdl_key=='4') { - db = 262; - if (da < 51) - da ++; + set_cmode(CM_FIRE); } - else if (x>=((XRES+BARSIZE-(510-494))*sdl_scale) && x<=((XRES+BARSIZE-(510-509))*sdl_scale)) + if (sdl_key=='5') { - db = sys_pause ? 264 : 263; - if (da < 51) - da ++; + set_cmode(CM_BLOB); } - else if (x>=((XRES+BARSIZE-(510-476))*sdl_scale) && x<=((XRES+BARSIZE-(510-491))*sdl_scale)) + if (sdl_key=='6') { - db = 267; - if (da < 51) - da ++; + set_cmode(CM_HEAT); } - else if (x>=19*sdl_scale && x<=35*sdl_scale && svf_open) + if (sdl_key=='7') { - db = 265; - if (da < 51) - da ++; - } - else if (da > 0) - da --; - } - else if (da > 0)//fade away mouseover text - da --; - - if (!sdl_zoom_trig && zoom_en==1) - zoom_en = 0; - - if (sdl_key=='z' && zoom_en==2 && sys_shortcuts==1) - zoom_en = 1; - - if (load_mode) - { - load_x = CELL*((mx/sdl_scale-load_w/2+CELL/2)/CELL); - load_y = CELL*((my/sdl_scale-load_h/2+CELL/2)/CELL); - if (load_x+load_w>XRES) load_x=XRES-load_w; - if (load_y+load_h>YRES) load_y=YRES-load_h; - if (load_x<0) load_x=0; - if (load_y<0) load_y=0; - if (bq==1 && !b) + set_cmode(CM_FANCY); + } + if (sdl_key=='8') { - parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap); - free(load_data); - free(load_img); - load_mode = 0; + set_cmode(CM_NOTHING); } - else if (bq==4 && !b) + if (sdl_key=='9') { - free(load_data); - free(load_img); - load_mode = 0; + set_cmode(CM_GRAD); } - } - else if (save_mode==1)//getting the area you are selecting - { - save_x = (mx/sdl_scale)/CELL; - save_y = (my/sdl_scale)/CELL; - if (save_x >= XRES/CELL) save_x = XRES/CELL-1; - if (save_y >= YRES/CELL) save_y = YRES/CELL-1; - save_w = 1; - save_h = 1; - if (b==1) + if (sdl_key=='0') { - save_mode = 2; + set_cmode(CM_CRACK); } - else if (b==4) + if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE) { - save_mode = 0; - copy_mode = 0; + set_cmode(CM_LIFE); } - } - else if (save_mode==2) - { - save_w = (mx/sdl_scale+CELL/2)/CELL - save_x; - save_h = (my/sdl_scale+CELL/2)/CELL - save_y; - if (save_w>XRES/CELL) save_w = XRES/CELL; - if (save_h>YRES/CELL) save_h = YRES/CELL; - if (save_w<1) save_w = 1; - if (save_h<1) save_h = 1; - if (!b) + if (sdl_key==SDLK_TAB) { - if (copy_mode==1)//CTRL-C, copy - { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts); - clipboard_ready = 1; - save_mode = 0; - copy_mode = 0; - } - else if (copy_mode==2)//CTRL-X, cut - { - clipboard_data=build_save(&clipboard_length, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL, bmap, fvx, fvy, signs, parts); - clipboard_ready = 1; - save_mode = 0; - copy_mode = 0; - clear_area(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - } - else//normal save + CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ; + } + if (sdl_key==SDLK_LEFTBRACKET) { + if (sdl_zoom_trig==1) { - stamp_save(save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - save_mode = 0; + ZSIZE -= 1; + if (ZSIZE>60) + ZSIZE = 60; + if (ZSIZE<2) + ZSIZE = 2; + ZFACTOR = 256/ZSIZE; } - } - } - else if (sdl_zoom_trig && zoom_en<2) - { - x /= sdl_scale; - y /= sdl_scale; - x -= ZSIZE/2; - y -= ZSIZE/2; - if (x<0) x=0; - if (y<0) y=0; - if (x>XRES-ZSIZE) x=XRES-ZSIZE; - if (y>YRES-ZSIZE) y=YRES-ZSIZE; - zoom_x = x; - zoom_y = y; - zoom_wx = (x 50) - it = 50; - x /= sdl_scale; - y /= sdl_scale; - if (y>=YRES+(MENUSIZE-20))//check if mouse is on menu buttons - { - if (!lb)//mouse is NOT held down, so it is a first click + else { - if (x>=189 && x<=202 && svf_login && svf_open && svf_myvote==0 && svf_own==0) + if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) { - if (execute_vote(vid_buf, svf_id, "Up")) - { - svf_myvote = 1; - } + bsx -= 1; + bsy -= 1; } - if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0 && svf_own==0) + else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) { - if (execute_vote(vid_buf, svf_id, "Down")) - { - svf_myvote = -1; - } + bsx -= 1; } - if (x>=219 && x<=(XRES+BARSIZE-(510-349)) && svf_login && svf_open) - tag_list_ui(vid_buf); - if (x>=(XRES+BARSIZE-(510-351)) && x<(XRES+BARSIZE-(510-366)) && !bq) + else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) { - legacy_enable = !legacy_enable; + bsy -= 1; } - if (x>=(XRES+BARSIZE-(510-367)) && x<=(XRES+BARSIZE-(510-383)) && !bq) + else { - clear_sim(); - for (i=0; i=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) + 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))) { - login_ui(vid_buf); - if (svf_login) { - save_presets(0); - http_session_check = NULL; - } + bsx += 1; + bsy += 1; } - if (x>=37 && x<=187 && svf_login) + else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) { - if (!svf_open || !svf_own || x>51) - { - if (save_name_ui(vid_buf)) { - execute_save(vid_buf); - if (svf_id[0]) { - copytext_ui(vid_buf, "Save ID", "Saved successfully!", svf_id); - } - } - } - else - execute_save(vid_buf); - while (!sdl_poll()) - if (!SDL_GetMouseState(&x, &y)) - break; - b = bq = 0; + bsx += 1; } - if (x>=1 && x<=17) + else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) { - search_ui(vid_buf); - memset(fire_bg, 0, XRES*YRES*PIXELSIZE); - memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); - memset(fire_r, 0, sizeof(fire_r)); - memset(fire_g, 0, sizeof(fire_g)); - memset(fire_b, 0, sizeof(fire_b)); + bsy += 1; } - if (x>=19 && x<=35 && svf_last && svf_open && !bq) { - //int tpval = sys_pause; - parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); - //sys_pause = tpval; + else + { + bsx += ceil((bsx/5)+0.5f); + bsy += ceil((bsy/5)+0.5f); } - if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) + 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+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) - sys_pause = !sys_pause; - lb = 0; } } - else if (y=signx && x<=signx+signw && y>=signy && y<=signy+signh) - { - char buff[256]; - int sldr; - - memset(buff, 0, sizeof(buff)); - - for (sldr=3; signs[signi].text[sldr] != '|'; sldr++) - buff[sldr-3] = signs[signi].text[sldr]; + 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; - buff[sldr-3] = '\0'; - open_ui(vid_buf, buff, 0); - } - } } + } + if (sdl_key=='y') + { + ++airMode; + itc = 52; - if (c==WL_SIGN+100) + switch (airMode) { - if (!bq) - add_sign_ui(vid_buf, x, y); + 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; } - //for the click functions, lx and ly, are the positions of where the FIRST click happened. x,y are current mouse position. - else if (lb)//lb means you are holding mouse down + } + + 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) { - if (lm == 1)//line tool - { - xor_line(lx, ly, x, y, vid_buf); - if (c==WL_FAN+100 && lx>=0 && ly>=0 && lx0 && y+j>0 && x+i0 && y+j>0 && x+i0 && y0 && x>8)>=NPART || !cr)) - { - c = sl = cr&0xFF; - } - else - { - //Something - } - } - lx = x; - ly = y; - lb = 0; - lm = 0; - } - else //normal click, spawn element - { - //Copy state before drawing any particles (for undo)7 - int cbx, cby, cbi; + transform = m2d_new(-1,0,0,1); //horizontal invert + doTransform = 1; + } + else if (sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) + { + transform = m2d_new(0,1,-1,0); //rotate anticlockwise 90 degrees + doTransform = 1; + } + else if (sdl_mod & (KMOD_CTRL)) + { + doTransform = 1; + if (sdl_key==SDLK_LEFT) translate = v2d_new(-1,0); + else if (sdl_key==SDLK_RIGHT) translate = v2d_new(1,0); + else if (sdl_key==SDLK_UP) translate = v2d_new(0,-1); + else if (sdl_key==SDLK_DOWN) translate = v2d_new(0,1); + else doTransform = 0; + } + if (doTransform) + { + ndata = transform_save(load_data, &load_size, transform, translate); + if (ndata!=load_data) free(load_data); + free(load_img); + load_data = ndata; + load_img = prerender_save(load_data, load_size, &load_w, &load_h); + } + } + if (sdl_key=='r'&&!(sdl_mod & (KMOD_CTRL|KMOD_SHIFT))) + 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=1) + vs = 0; + else + vs = 3;//every other frame + } + else { - x /= sdl_scale; - y /= sdl_scale; - c = (lb&1) ? sl : sr; - su = c; - if (lm == 1)//line - { - if (c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN) - create_line(lx, ly, x, y, bsx, bsy, c); - } - else//box - create_box(lx, ly, x, y, c); - lm = 0; + if (vs>=1) + vs = 0; + else + vs = 1; } - lb = 0; + counterthing = 0; } - - if (load_mode)//draw preview of stamp + if (vs) { - draw_image(vid_buf, load_img, load_x, load_y, load_w, load_h, 128); - xor_rect(vid_buf, load_x, load_y, load_w, load_h); + if (counterthing+1>=vs) + { + dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE); + counterthing = 0; + } + counterthing = (counterthing+1)%3; } +#endif - if (save_mode)//draw dotted lines for selection + if (sdl_wheel) { - xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); - da = 51;//draws mouseover text for the message - db = 269;//the save message + if (sdl_zoom_trig==1)//zoom window change + { + ZSIZE += sdl_wheel; + if (ZSIZE>60) + ZSIZE = 60; + if (ZSIZE<2) + ZSIZE = 2; + ZFACTOR = 256/ZSIZE; + sdl_wheel = 0; + } + else //change brush size + { + if (!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) + { + bsx += sdl_wheel; + bsy += sdl_wheel; + } + else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL))) + { + bsx += sdl_wheel; + } + else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT))) + { + bsy += sdl_wheel; + } + if (bsx>1180) + bsx = 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 (zoom_en!=1 && !load_mode && !save_mode)//draw normal cursor + bq = b; // bq is previous mouse state + b = SDL_GetMouseState(&x, &y); // b is current mouse state + + for (i=0; i=sdl_scale*(XRES-2) && x= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy //change mouse position while it is in a zoom window + && x0 && y0 && x51?255:itc*5); + int cr; //cr is particle under mouse, for drawing HUD information + if (photons[y/sdl_scale][x/sdl_scale]) { + cr = photons[y/sdl_scale][x/sdl_scale]; + } else { + cr = pmap[y/sdl_scale][x/sdl_scale]; + } + if (!((cr>>8)>=NPART || !cr)) + { + if (DEBUG_MODE) + { + int tctype = parts[cr>>8].ctype; + if (tctype>=PT_NUM || tctype<0 || (cr&0xFF)==PT_PHOT) + tctype = 0; + if ((cr&0xFF)==PT_PIPE) + { + if (parts[cr>>8].tmp>8].tmp; + else tctype = 0; + } + sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); + sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale); + } else { +#ifdef BETA + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life); +#else + sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f); +#endif + } + if ((cr&0xFF)==PT_PHOT) wavelength_gfx = parts[cr>>8].ctype; + } + else + { + sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]); + if (DEBUG_MODE) + { + sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale); + } + } } - if (it)//intro message + + mx = x; + my = y; + if (update_flag) { - it--; - drawtext(vid_buf, 16, 20, it_msg, 255, 255, 255, it>51?255:it*5); + info_box(vid_buf, "Finalizing update..."); + if (last_major>SAVE_VERSION || (last_major==SAVE_VERSION && last_minor>=MINOR_VERSION)) + { + update_cleanup(); + error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + } + else + { + if (update_finish()) + error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + else + info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!"); + } + update_flag = 0; } - if (old_version) + if (b && !bq && x>=(XRES-19-old_ver_len)*sdl_scale && + x<=(XRES-14)*sdl_scale && y>=(YRES-22)*sdl_scale && y<=(YRES-9)*sdl_scale && old_version) { - clearrect(vid_buf, XRES-21-old_ver_len, YRES-24, old_ver_len+9, 17); + tmp = malloc(64); #ifdef BETA if (is_beta) { - drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg_beta, 255, 216, 32, 255); + sprintf(tmp, "Your version: %d (Beta %d), new version: %d (Beta %d).", SAVE_VERSION, MINOR_VERSION, major, minor); } else { - drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255); + sprintf(tmp, "Your version: %d (Beta %d), new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); } #else - drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255); + sprintf(tmp, "Your version: %d.%d, new version: %d.%d.", SAVE_VERSION, MINOR_VERSION, major, minor); #endif - drawrect(vid_buf, XRES-19-old_ver_len, YRES-22, old_ver_len+5, 13, 255, 216, 32, 255); + if (confirm_ui(vid_buf, "Do you want to update The Powder Toy?", tmp, "Update")) + { + free(tmp); + tmp = download_ui(vid_buf, my_uri, &i); + if (tmp) + { + save_presets(1); + if (update_start(tmp, i)) + { + update_cleanup(); + save_presets(0); + error_ui(vid_buf, 0, "Update failed - try downloading a new version."); + } + else + return 0; + } + } + else + free(tmp); } - - FPS++; - currentTime = SDL_GetTicks(); - elapsedTime = currentTime-pastFPS; - if (elapsedTime>=1000) + if (y>=sdl_scale*(YRES+(MENUSIZE-20))) //mouse checks for buttons at the bottom, to draw mouseover texts { - FPSB = FPS; - FPS = 0; - pastFPS = currentTime; + if (x>=189*sdl_scale && x<=202*sdl_scale && svf_login && svf_open && svf_myvote==0) + { + db = svf_own ? 275 : 272; + if (da < 51) + da ++; + } + else if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0) + { + db = svf_own ? 275 : 272; + if (da < 51) + da ++; + } + else if (x>=189 && x<=217 && svf_login && svf_open && svf_myvote!=0) + { + db = (svf_myvote==1) ? 273 : 274; + if (da < 51) + da ++; + } + else if (x>=219*sdl_scale && x<=((XRES+BARSIZE-(510-349))*sdl_scale) && svf_login && svf_open) + { + db = svf_own ? 257 : 256; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-351))*sdl_scale) && x<((XRES+BARSIZE-(510-366))*sdl_scale)) + { + db = 270; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-367))*sdl_scale) && x<((XRES+BARSIZE-(510-383))*sdl_scale)) + { + db = 266; + if (da < 51) + da ++; + } + else if (x>=37*sdl_scale && x<=187*sdl_scale && svf_login) + { + db = 259; + if (svf_open && svf_own && x<=55*sdl_scale) + db = 258; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-385))*sdl_scale) && x<=((XRES+BARSIZE-(510-476))*sdl_scale)) + { + db = svf_login ? 261 : 260; + if (svf_admin) + { + db = 268; + } + else if (svf_mod) + { + db = 271; + } + if (da < 51) + da ++; + } + else if (x>=sdl_scale && x<=17*sdl_scale) + { + db = 262; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-494))*sdl_scale) && x<=((XRES+BARSIZE-(510-509))*sdl_scale)) + { + db = sys_pause ? 264 : 263; + if (da < 51) + da ++; + } + else if (x>=((XRES+BARSIZE-(510-476))*sdl_scale) && x<=((XRES+BARSIZE-(510-491))*sdl_scale)) + { + db = 267; + if (da < 51) + da ++; + } + else if (x>=19*sdl_scale && x<=35*sdl_scale && svf_open) + { + db = 265; + if (da < 51) + da ++; + } + else if (da > 0) + da --; } - else if (elapsedTime>20 && FPS*1000/elapsedTime>limitFPS) + else if (da > 0)//fade away mouseover text + da --; + + if (!sdl_zoom_trig && zoom_en==1) + zoom_en = 0; + + if (sdl_key=='z' && zoom_en==2 && sys_shortcuts==1) + zoom_en = 1; + + if (load_mode) { - SDL_Delay(5); + load_x = CELL*((mx/sdl_scale-load_w/2+CELL/2)/CELL); + load_y = CELL*((my/sdl_scale-load_h/2+CELL/2)/CELL); + if (load_x+load_w>XRES) load_x=XRES-load_w; + if (load_y+load_h>YRES) load_y=YRES-load_h; + if (load_x<0) load_x=0; + if (load_y<0) load_y=0; + if (bq==1 && !b) + { + parse_save(load_data, load_size, 0, load_x, load_y, bmap, fvx, fvy, signs, parts, pmap); + free(load_data); + free(load_img); + load_mode = 0; + } + else if (bq==4 && !b) + { + free(load_data); + free(load_img); + load_mode = 0; + } } - - if (hud_enable) + else if (save_mode==1)//getting the area you are selecting { -#ifdef BETA - sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode); -#else - if (DEBUG_MODE) - sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode); - else - sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB); -#endif - if (REPLACE_MODE) - strappend(uitext, " [REPLACE MODE]"); - if (sdl_mod&(KMOD_CAPS)) - strappend(uitext, " [CAP LOCKS]"); - if (GRID_MODE) - sprintf(uitext, "%s [GRID: %d]", uitext, GRID_MODE); -#ifdef INTERNAL - if (vs) - strappend(uitext, " [FRAME CAPTURE]"); -#endif - - if (sdl_zoom_trig||zoom_en) + save_x = (mx/sdl_scale)/CELL; + save_y = (my/sdl_scale)/CELL; + if (save_x >= XRES/CELL) save_x = XRES/CELL-1; + if (save_y >= YRES/CELL) save_y = YRES/CELL-1; + save_w = 1; + save_h = 1; + if (b==1) + { + save_mode = 2; + } + else if (b==4) + { + save_mode = 0; + copy_mode = 0; + } + } + else if (save_mode==2) + { + save_w = (mx/sdl_scale+CELL/2)/CELL - save_x; + save_h = (my/sdl_scale+CELL/2)/CELL - save_y; + if (save_w>XRES/CELL) save_w = XRES/CELL; + if (save_h>YRES/CELL) save_h = YRES/CELL; + if (save_w<1) save_w = 1; + if (save_h<1) save_h = 1; + if (!b) { - if (zoom_xXRES-ZSIZE) x=XRES-ZSIZE; + if (y>YRES-ZSIZE) y=YRES-ZSIZE; + zoom_x = x; + zoom_y = y; + zoom_wx = (x 50) + it = 50; + x /= sdl_scale; + y /= sdl_scale; + if (y>=YRES+(MENUSIZE-20))//check if mouse is on menu buttons { - char *console; - sys_pause = 1; - console = console_ui(vid_buf,console_error,console_more); - console = mystrdup(console); - strcpy(console_error,""); - if (process_command_old(vid_buf,console,&console_error)==-1) + if (!lb)//mouse is NOT held down, so it is a first click { - free(console); - break; + if (x>=189 && x<=202 && svf_login && svf_open && svf_myvote==0 && svf_own==0) + { + if (execute_vote(vid_buf, svf_id, "Up")) + { + svf_myvote = 1; + } + } + if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0 && svf_own==0) + { + if (execute_vote(vid_buf, svf_id, "Down")) + { + svf_myvote = -1; + } + } + if (x>=219 && x<=(XRES+BARSIZE-(510-349)) && svf_login && svf_open) + tag_list_ui(vid_buf); + if (x>=(XRES+BARSIZE-(510-351)) && x<(XRES+BARSIZE-(510-366)) && !bq) + { + legacy_enable = !legacy_enable; + } + if (x>=(XRES+BARSIZE-(510-367)) && x<=(XRES+BARSIZE-(510-383)) && !bq) + { + clear_sim(); + for (i=0; i=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476))) + { + login_ui(vid_buf); + if (svf_login) { + save_presets(0); + http_session_check = NULL; + } + } + if (x>=37 && x<=187 && svf_login) + { + if (!svf_open || !svf_own || x>51) + { + if (save_name_ui(vid_buf)) { + execute_save(vid_buf); + if (svf_id[0]) { + copytext_ui(vid_buf, "Save ID", "Saved successfully!", svf_id); + } + } + } + else + execute_save(vid_buf); + while (!sdl_poll()) + if (!SDL_GetMouseState(&x, &y)) + break; + b = bq = 0; + } + if (x>=1 && x<=17) + { + search_ui(vid_buf); + memset(fire_bg, 0, XRES*YRES*PIXELSIZE); + memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE); + memset(fire_r, 0, sizeof(fire_r)); + memset(fire_g, 0, sizeof(fire_g)); + memset(fire_b, 0, sizeof(fire_b)); + } + if (x>=19 && x<=35 && svf_last && svf_open && !bq) { + //int tpval = sys_pause; + parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, fvx, fvy, signs, parts, pmap); + //sys_pause = tpval; + } + if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq) + { + if (b & SDL_BUTTON_LMASK) { + set_cmode((cmode+1) % CM_COUNT); + } + if (b & SDL_BUTTON_RMASK) { + if ((cmode+(CM_COUNT-1)) % CM_COUNT == CM_LIFE) { + set_cmode(CM_GRAD); + } else { + set_cmode((cmode+(CM_COUNT-1)) % CM_COUNT); + } + } + } + if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq) + sys_pause = !sys_pause; + lb = 0; } - free(console); - if (!console_mode) - hud_enable = 1; } -#else - char *console; - sys_pause = 1; - console = console_ui(vid_buf,console_error,console_more); - console = mystrdup(console); - strcpy(console_error,""); - if (process_command_old(vid_buf,console,&console_error)==-1) + else if (y=signx && x<=signx+signw && y>=signy && y<=signy+signh) + { + char buff[256]; + int sldr; - //Setting an element for the stick man - if (isplayer==0) - { - if (ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT) - player[2] = sr; - else - player[2] = PT_DUST; - } - if (isplayer2==0) - { - if (ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT) - player2[2] = sr; - else - player2[2] = PT_DUST; - } - } - SDL_CloseAudio(); - http_done(); + memset(buff, 0, sizeof(buff)); -#ifdef PYCONSOLE + for (sldr=3; signs[signi].text[sldr] != '|'; sldr++) + buff[sldr-3] = signs[signi].text[sldr]; - PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.py'))\nexcept:\n pass"); - PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyo'))\nexcept:\n pass"); - PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyc'))\nexcept:\n pass"); + buff[sldr-3] = '\0'; + open_ui(vid_buf, buff, 0); + } + } + } - Py_Finalize();//cleanup any python stuff. -#endif - return 0; -} -#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]; - char ycoord[10]; - char console2[15]; - 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) - { - sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?! - if (strcmp(console2, "quit")==0) - { - return -1; - } else { - //handle them command - pargs=Py_BuildValue("(s)",console); - pvalue = PyObject_CallObject(pfunc, pargs); - Py_DECREF(pargs); - pargs=NULL; - if (pvalue==NULL) - strcpy(console_error,"failed to execute code."); - pvalue=NULL; - } - } - return 1; -} -#endif -int process_command_old(pixel *vid_buf,char *console,char *console_error) { - int y,x,nx,ny,i,j,k,m; - float f; - int do_next = 1; - char xcoord[10] = ""; - char ycoord[10] = ""; - char console2[15] = ""; - char console3[15] = ""; - char console4[15] = ""; - char console5[15] = ""; - //sprintf(console_error, "%s", console); - if (console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0) - { - sscanf(console,"%14s %14s %14s %14s", console2, console3, console4, console5);//why didn't i know about this function?! - if (strcmp(console2, "quit")==0) - { - return -1; - } - else if (strcmp(console2, "file")==0 && console3[0]) - { - if (file_script) { - FILE *f=fopen(console3, "r"); - if (f) + if (c==WL_SIGN+100) { - char fileread[5000];//TODO: make this change with file size - char pch[5000]; - char tokens[10]; - int tokensize; - nx = 0; - ny = 0; - j = 0; - m = 0; - if (console4[0]) - console_parse_coords(console4, &nx , &ny, console_error); - memset(pch,0,sizeof(pch)); - memset(fileread,0,sizeof(fileread)); - fread(fileread,1,5000,f); - for (i=0; i=0 && ly>=0 && lx0 && y+j>0 && x+i0 && y+j>0 && x+i0 && y0 && x>8)>=NPART || !cr)) { - char temp[5]; - int starty = 0; - tokensize = strlen(tokens); - x = 0; - y = 0; - sscanf(tokens,"x%d,y%d",&x,&y); - sscanf(tokens,"%9s,%9s",xcoord,ycoord); - x += nx; - y += ny; - sprintf(xcoord,"%d",x); - sprintf(ycoord,"%d",y); - for (k = 0; k=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN) + create_line(lx, ly, x, y, bsx, bsy, c); } - else - return 0; + else//box + create_box(lx, ly, x, y, c); + lm = 0; } + lb = 0; } - else if (strcmp(console2, "create")==0 && console3[0] && console4[0]) + + if (load_mode)//draw preview of stamp { - if (console_parse_type(console3, &j, console_error) - && console_parse_coords(console4, &nx, &ny, console_error)) - { - if (!j) - strcpy(console_error, "Cannot create particle with type NONE"); - else if (create_part(-1,nx,ny,j)<0) - strcpy(console_error, "Could not create particle"); - } + draw_image(vid_buf, load_img, load_x, load_y, load_w, load_h, 128); + xor_rect(vid_buf, load_x, load_y, load_w, load_h); } - else if ((strcmp(console2, "delete")==0 || strcmp(console2, "kill")==0) && console3[0]) + + if (save_mode)//draw dotted lines for selection { - if (console_parse_partref(console3, &i, console_error)) - kill_part(i); + xor_rect(vid_buf, save_x*CELL, save_y*CELL, save_w*CELL, save_h*CELL); + da = 51;//draws mouseover text for the message + db = 269;//the save message } - else if (strcmp(console2, "reset")==0 && console3[0]) + + if (zoom_en!=1 && !load_mode && !save_mode)//draw normal cursor { - if (strcmp(console3, "pressure")==0) - { - for (nx = 0; nx51?255:itc*5); } - else if (strcmp(console2, "set")==0 && console3[0] && console4[0] && console5[0]) + if (it)//intro message { - if (strcmp(console3, "life")==0) - { - if (strcmp(console4, "all")==0) - { - j = atoi(console5); - for (i=0; i51?255:it*5); + } + + if (old_version) + { + clearrect(vid_buf, XRES-21-old_ver_len, YRES-24, old_ver_len+9, 17); +#ifdef BETA + if (is_beta) + { + drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg_beta, 255, 216, 32, 255); } - if (strcmp(console3, "tmp")==0) + else { - if (strcmp(console4, "all")==0) - { - j = atoi(console5); - for (i=0; i=1000) + { + FPSB = FPS; + FPS = 0; + pastFPS = currentTime; + } + else if (elapsedTime>20 && FPS*1000/elapsedTime>limitFPS) + { + SDL_Delay(5); + } + + if (hud_enable) + { +#ifdef BETA + sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode); +#else + if (DEBUG_MODE) + sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode); + else + sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB); +#endif + if (REPLACE_MODE) + strappend(uitext, " [REPLACE MODE]"); + if (sdl_mod&(KMOD_CAPS)) + strappend(uitext, " [CAP LOCKS]"); + if (GRID_MODE) + sprintf(uitext, "%s [GRID: %d]", uitext, GRID_MODE); +#ifdef INTERNAL + if (vs) + strappend(uitext, " [FRAME CAPTURE]"); +#endif + + if (sdl_zoom_trig||zoom_en) { - if (strcmp(console4, "all")==0) - { - j = atoi(console5); - for (i=0; i0 || sr == PT_NEUT || sr == PT_PHOT) + player[2] = sr; + else + player[2] = PT_DUST; + } + if (isplayer2==0) + { + if (ptypes[sr].falldown>0 || sr == PT_NEUT || sr == PT_PHOT) + player2[2] = sr; + else + player2[2] = PT_DUST; } - else - strcpy(console_error, "Invalid Command"); } - return 1; -} + SDL_CloseAudio(); + http_done(); + +#ifdef PYCONSOLE + + PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.py'))\nexcept:\n pass"); + PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyo'))\nexcept:\n pass"); + PyRun_SimpleString("import os,tempfile,os.path\ntry:\n os.remove(os.path.join(tempfile.gettempdir(),'tpt_console.pyc'))\nexcept:\n pass"); + + Py_Finalize();//cleanup any python stuff. +#endif + return 0; +} \ No newline at end of file -- cgit v0.9.2-21-gd62e