From fea297b2ac430a6e4d32a9842d8904a04989d495 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 31 Jan 2011 22:53:32 -0500 Subject: [PATCH 1/5] Update with simon, and drawing SPRK on walls crash fix. --- includes/defines.h | 4 ++-- src/interface.c | 10 +++++++++- src/powder.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index c22180f1d..95302fad4 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -7,8 +7,8 @@ #define PATH_SEP "/" #endif -#define SAVE_VERSION 45 -#define MINOR_VERSION 2 +#define SAVE_VERSION 46 +#define MINOR_VERSION 0 #define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter. //#define BETA diff --git a/src/interface.c b/src/interface.c index 112fef437..5940e6ead 100644 --- a/src/interface.c +++ b/src/interface.c @@ -867,11 +867,19 @@ void login_ui(pixel *vid_buf) if (res && !strncmp(res, "OK ", 3)) { char *s_id,*u_e,*nres; + printf("\n{%s}\n", res); s_id = strchr(res+3, ' '); + if (!s_id) + goto fail; *(s_id++) = 0; u_e = strchr(s_id, ' '); - *(u_e++) = 0; + if (!u_e){ + u_e = malloc(1); + memset(u_e, 0, 1); + } + else + *(u_e++) = 0; strcpy(svf_user_id, res+3); strcpy(svf_session_id, s_id); diff --git a/src/powder.c b/src/powder.c index b2932d151..6cafdb651 100644 --- a/src/powder.c +++ b/src/powder.c @@ -577,7 +577,7 @@ inline int create_part(int p, int x, int y, int t) if (t==PT_SPRK) { - if (!((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) + if ((pmap[y][x]>>8)>=NPART || !((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) return -1; if (parts[pmap[y][x]>>8].life!=0) return -1; From c558df240bce1e623522bc5b3d84ad9120b1d070 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 31 Jan 2011 23:30:53 -0500 Subject: [PATCH 2/5] made set work with all of one type of a particle (set type dust deut) turns all dust into deut --- src/main.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++- src/powder.c | 14 ++++----- 2 files changed, 89 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index e55e60c57..b5b2767e4 100644 --- a/src/main.c +++ b/src/main.c @@ -2553,7 +2553,7 @@ int main(int argc, char *argv[]) } int process_command(pixel *vid_buf,char *console,char *console_error) { -int nx,ny,i,j; +int nx,ny,i,j,k; char *console2; char *console3; char *console4; @@ -2674,6 +2674,15 @@ char *console5; parts[i].life = j; } } + else if (console_parse_type(console4, &j, console_error)) + { + k = atoi(console5); + for(i=0; i>8)>=NPART) continue; - for ( golnum = 1; golnum=2&&gol2[nx][ny][golnum]>=(goldelete%2)+goldelete/2) @@ -1345,7 +1345,7 @@ void update_particles_i(pixel *vid, int start, int inc) parts[r>>8].type = PT_NONE;//using kill_part makes it not work } gol2[nx][ny][0] = 0; - for ( z = 1; z=0 && j=clear_y-rt && j Date: Tue, 1 Feb 2011 20:35:41 -0500 Subject: [PATCH 3/5] testing playing .wav files. lol sounds --- src/interface.c | 3 +- src/main.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/src/interface.c b/src/interface.c index 5940e6ead..298957113 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3866,7 +3866,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.2 (by cracker64)\n" - "Current commands are quit, set, reset, load, create, file, kill\n" + "Current commands are quit, set, reset, load, create, file, kill, sound\n" "You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n" "You can also use 'all' instead of a particle number to do it to everything.\n" "You can now use particle names (ex. set type all deut)\n" @@ -3875,6 +3875,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show "Create particles with 'create deut x,y' where x and y are the coords\n" "Run scripts from file 'file filename'\n" "You can delete/kill a particle with 'kill x,y'" + "Play a sound with (sound blah.wav)" ,255, 187, 187, 255); cc = 0; diff --git a/src/main.c b/src/main.c index b5b2767e4..d4d4f01c9 100644 --- a/src/main.c +++ b/src/main.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -51,6 +52,69 @@ #include #include +#define NUM_SOUNDS 2 +struct sample { + Uint8 *data; + Uint32 dpos; + Uint32 dlen; +} sounds[NUM_SOUNDS]; + +void mixaudio(void *unused, Uint8 *stream, int len) +{ + int i; + Uint32 amount; + + for ( i=0; i len ) { + amount = len; + } + SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME); + sounds[i].dpos += amount; + } +} + +void PlaySound(char *file) +{ + int index; + SDL_AudioSpec wave; + Uint8 *data; + Uint32 dlen; + SDL_AudioCVT cvt; + + /* Look for an empty (or finished) sound slot */ + for ( index=0; index Date: Wed, 2 Feb 2011 00:15:57 -0500 Subject: [PATCH 4/5] fix a few things, some memsets were doubled. --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index d4d4f01c9..1d6f2ed56 100644 --- a/src/main.c +++ b/src/main.c @@ -74,7 +74,7 @@ void mixaudio(void *unused, Uint8 *stream, int len) } } -void PlaySound(char *file) +void play_sound(char *file) { int index; SDL_AudioSpec wave; @@ -2675,7 +2675,7 @@ char *console5; } else if(strcmp(console2, "sound")==0 && console3) { - PlaySound(console3); + play_sound(console3); } else if(strcmp(console2, "load")==0 && console3) { From db038e9643a99de5ddaba04d99eaceab91fc860d Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 2 Feb 2011 00:18:22 -0500 Subject: [PATCH 5/5] HERE are the doubled memsets --- src/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.c b/src/main.c index 1d6f2ed56..3f8d52925 100644 --- a/src/main.c +++ b/src/main.c @@ -543,10 +543,6 @@ int parse_save(void *save, int size, int replace, int x0, int y0) if (replace) { gravityMode = 1; - memset(photons, 0, sizeof(photons)); - memset(wireless, 0, sizeof(wireless)); - memset(gol2, 0, sizeof(gol2)); - memset(portal, 0, sizeof(portal)); memset(bmap, 0, sizeof(bmap)); memset(emap, 0, sizeof(emap));