From 0efde07a9f068afb6fada50df2a0fb24d4f9159a Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Wed, 29 Oct 2008 21:54:53 +0000 Subject: [PATCH] Fixed editor crash New level --- data/levels.dat | 1 + data/world1/level115.dat | 78 ++++++++++++++++++++++++++++++++++++++++ edit.c | 13 +++++-- rc.c | 28 ++++++++------- rc.h | 1 + 5 files changed, 107 insertions(+), 14 deletions(-) create mode 100644 data/world1/level115.dat diff --git a/data/levels.dat b/data/levels.dat index eb9cf1e..bfa928d 100644 --- a/data/levels.dat +++ b/data/levels.dat @@ -27,6 +27,7 @@ 103,level103.dat,Fishbowls 22,level22.dat,Platforms in the Sand 23,level23.dat,Twisty Little Passages +115,level115.dat,Fine and sunny 113,level113.dat,Mine Shaft 101,level101.dat,Sand Castle 102,level102.dat,Diving Pool diff --git a/data/world1/level115.dat b/data/world1/level115.dat new file mode 100644 index 0000000..8a57755 --- /dev/null +++ b/data/world1/level115.dat @@ -0,0 +1,78 @@ +bgfile beach1.png +bg 0 +hurryup 30 +help +endhelp +monsters +0 20 22 +12 34 14 +12 4 14 +60 22 13 +124 15 19 +124 24 19 +49 32 5 +49 7 5 +1 32 22 +1 7 22 +6 33 19 +6 4 10 +15 33 25 +15 4 25 +15 6 25 +15 35 25 +15 31 19 +15 29 19 +15 8 19 +15 10 19 +15 8 8 +15 10 8 +15 29 8 +15 31 8 +15 34 2 +15 36 2 +15 5 2 +15 3 2 +16 30 19 +16 9 19 +16 9 8 +16 30 8 +17 35 2 +17 4 2 +17 5 25 +17 34 25 +23 20 9 +endmonsters +exitdir 1 +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,17,0,0,0,0,0,0,0,17,0,0,0,0,25,25,25,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,16,16,16,16,16,16,16,16,16,16,16,16,16,16,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,25,25,25,25,25,25,25,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,25,25,25,25,25,25,25,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,24,15,15,15,15,15,15,15,15,15,15,15,15,15,15,24,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,25,25,25,0,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,0,25,25,25,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,25,25,25,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,0,0,0,0,0,25,25,25,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,44, +layer2 +39,0,44 +20,15,14 diff --git a/edit.c b/edit.c index 3604e82..e2eaf33 100644 --- a/edit.c +++ b/edit.c @@ -369,6 +369,8 @@ int main (int argc, char **argv) { int lev; // get level # at mouse posj lev = (my / (EDITTEXT + LLISTPADY)); + // adjust for world offset + lev = lev + (getworld(curlevelnum)-1)*20; if (curlevelnum != lev) { @@ -978,6 +980,10 @@ void clearlevel(void) { } /* clear level */ + if (curlevel->animtiles) { + free(level->animtiles); + curlevel->animtiles = NULL; + } for (x = 0; x < LEVELW; x++) { for (y = 0; y < LEVELH; y++) { offset = y*LEVELW+x; @@ -989,10 +995,13 @@ void clearlevel(void) { curlevel->map[offset] = T_BLANK; } curlevel->map2[offset] = T_BLANK; + curlevel->tileframe[offset] = 0; draweditortile(screen,x,y); } } + curlevel->nummonsters = 0; + modified = B_TRUE; } @@ -1199,12 +1208,12 @@ void drawlevellist(void) { area.h = EDITMAPH; SDL_FillRect(screen, &area, SDL_MapRGB(screen->format, 0, 0, 0)); - // draw level list + // draw level list (starting at current world) area.x = LLISTX; area.y = 0; area.w = 0; area.h = 0; - for (i =1; i < numlevels; i++) { + for (i = ((getworld(curlevelnum)-1)*20)+1; i < numlevels; i++) { if (i == curlevelnum) { col = &green; } else if (i <= 20) { diff --git a/rc.c b/rc.c index f05d0e5..f5a3d7e 100644 --- a/rc.c +++ b/rc.c @@ -357,7 +357,7 @@ int main (int argc, char **argv) { // turn off clock and water powerups if (player->powerup == PW_CLOCK) { Mix_ResumeMusic(); - player->powerup = B_FALSE; + losepowerup(player); } else if ((curlevel->iced == WATER_INPROGRESS) || (curlevel->iced == WATER_COMPLETE)) { curlevel->iced = B_FALSE; undoflood(); @@ -672,7 +672,7 @@ int main (int argc, char **argv) { } if (--player->timer1 == 0) { - player->powerup = B_FALSE; + losepowerup(player); } } else if (player->powerup == PW_SPRAYUP) { // green overlay for fly spray if (levelcomplete != LV_DOPOKER) { @@ -722,7 +722,7 @@ int main (int argc, char **argv) { if (--player->timer1 == 0) { - player->powerup = B_FALSE; + losepowerup(player); } } @@ -814,7 +814,7 @@ void tick(void) { if (clocktime < 0) { // finished! Mix_ResumeMusic(); - player->powerup = B_FALSE; + losepowerup(player); } } @@ -855,7 +855,7 @@ void tick(void) { // rings are disabled if ((player->powerup == PW_RINGWALK) || (player->powerup == PW_RINGJUMP)) { - player->powerup = B_FALSE; + losepowerup(player); } @@ -984,7 +984,7 @@ void nextlevel(void) { // phone is cancelled on boss levels if (player->powerup == PW_PHONE) { if (isbosslevel(curlevelnum)) { - player->powerup = B_FALSE; + losepowerup(player); skiplevels = 0; } } @@ -1046,10 +1046,10 @@ void nextlevel(void) { if (player->powerup == PW_PHONE) { skiplevels--; if (skiplevels <= 0) { - player->powerup = B_FALSE; + losepowerup(player); } } else { - player->powerup = B_FALSE; + losepowerup(player); } @@ -1203,7 +1203,7 @@ void die(sprite_t *s) { if (player->powerup == PW_CLOCK) { Mix_ResumeMusic(); } - player->powerup = B_FALSE; + losepowerup(player); resethurryup(curlevel); if (curmusic == fastmusic) { @@ -1261,7 +1261,7 @@ void die(sprite_t *s) { } else if (s == boss) { // boss effects // stop screen shaking if (player->powerup == PW_RATSHAKE) { - player->powerup = B_FALSE; + losepowerup(player); } // reset timers s->timer1 = 0; @@ -7527,7 +7527,7 @@ void docannoneffect(void) { if (!found) { printf("weird error - no cannon!!\n"); - player->powerup = B_FALSE; + losepowerup(player); } else { int initx,inity; int i; @@ -7580,7 +7580,7 @@ void docannoneffect(void) { if (timer % 8 == 0) { player->timer3--; if (player->timer3 <= 0) { - player->powerup = B_FALSE; + losepowerup(player); s->dead = D_FINAL; SDL_BlitSurface(temps, NULL, screen, NULL); } @@ -8633,3 +8633,7 @@ void stopteleporting(sprite_t *s) { s->img = imageset[s->id].img[F_WALK1]; } } + +void losepowerup(sprite_t *s) { + s->powerup = B_FALSE; +} diff --git a/rc.h b/rc.h index 80357e9..03e274f 100644 --- a/rc.h +++ b/rc.h @@ -102,3 +102,4 @@ void getinput(void); int isendoflev(void); void keeponscreen(sprite_t *s); void stopteleporting(sprite_t *s); +void losepowerup(sprite_t *s);