Message-ID: <20010421194907.70468.qmail@web13304.mail.yahoo.com> Date: Sat, 21 Apr 2001 12:49:07 -0700 (PDT) From: Rafael Frongillo Subject: linear hline error To: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: djgpp AT delorie DOT com Hello My problem is this: my program crashes once in a while during the 'explode' function (see below) when type==3. Sometimes the program goes right through 'explode' with type==3, but doesn't crash, other times it does. The error message I get when symifying is: Call frame traceback EIPs: 0x0003fb54 __linear_hline16+484 0x0000c920 _circlefill+368 0x0000000a 0xa My graphics setup is this: set_color_depth(16); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) printf("Error: graphics init\n%s\n", allegro_error); set_color_conversion(COLORCONV_TOTAL); Do you know what could be causing this? -Rafael Frongillo FILE msls.cpp: #include "msls.h" MSL::MSL(){ x=y=w=h=d=type=range=pn=exploding=exp= guynum=dx=dy=speed=damage=pushval=fdelay=0; } int MSL::firing[WEPNUM+1] = {0,0,0,0}; MSL::MSL(int typ, int xx, int yy, int dd, int guyn) : x(xx), y(yy), d(dd), type(typ), pn(0), exploding(0), exp(0), guynum(guyn), dx(0), dy(0) { switch(type) { case 1 : range = 200; w = h = 10; fdelay = 10; speed = 12; damage = 10; pushval = 5; play_sample(msfire[1], 255, 128, 1000, 0); break; case 2 : range = 100; w = 20; h = 7; fdelay = 1; speed = 9; damage = 3; pushval = 1; if (!firing[2]) play_sample(msfire[2], 255, 128, 1000, 1); break; case 3 : range = 400; w = 30; h = 8; fdelay = 18; speed = 8; damage = 5; pushval = 6; play_sample(msfire[3], 255, 128, 1000, 0); break; case 4 : range = 1000; w = speed = 100; h = 3; fdelay = 20; damage = 10; pushval = 5; play_sample(msfire[4], 255, 128, 1000, 0); break; } int t = 0; switch (d) { case UP : t = w; w = h; h = t; y -= h; x -= w/2; break; case DN : t = w; w = h; h = t; x -= w/2; break; case LF : x -= w; y -= h/2; break; case RT : y -= h/2; break; } firing[type]++; } void MSL::move() { int picval; if (exploding) explode(1); if (d != 0 && !exploding) { switch (d) { case LF : x -= speed; dx -= speed; picval = 1; break; case RT : x += speed; dx += speed; picval = 0; break; case UP : y -= speed; dy -= speed; picval = 2; break; case DN : y += speed; dy += speed; picval = 3; break; } switch (type) { case 1 : temp = mp1[picval][pn]; pn++; pn%=2; break; case 2 : temp = mp2[picval][random()%3]; break; case 3 : temp = mp3[picval][pn]; pn++; pn%=4; break; case 4 : temp = create_bitmap(1,1); putpixel(temp,0,0,pink); switch (d) { case DN : y -= speed; case UP : h += speed; rectfill(buf,x,y,x+w,y+h,green); rectfill(buf,x+1,y,x+2,y+h,yellow); break; case RT : x -= speed; case LF : w += speed; rectfill(buf,x,y,x+w,y+h,green); rectfill(buf,x,y+1,x+w,y+2,yellow); break; } } if (abs(dx) > range || abs(dy) > range) explode(0); if (d) draw_sprite(buf,temp,x+(w-temp->w)/2,y+(h-temp->h)/2); } if (!exploding && checkWalls()) explode(1); } void MSL::explode(int expl) { int picval; exploding++; if (exploding==1) { play_sample(mshit[type], 255, 128, 1000, 0); } switch (d) { case RT : picval = 0; break; case LF : picval = 1; break; case UP : picval = 2; break; case DN : picval = 3; break; } switch (type) { case 1 : if (!expl || exploding > 3) destroy(); else temp = mp1[picval][exploding+1]; break; case 2 : destroy(); break; case 3 : w = h = 10 * exploding; x -= 5; y -= 5; if (exploding > 10) destroy(); temp = create_bitmap(w,h); rectfill(temp,0,0,w,h,pink); circlefill(temp,w/2,h/2,w/2,yellow); circlefill(temp,w/2,h/2,w/2-5,orange); circlefill(temp,w/2,h/2,w/2-10,red); circlefill(temp,w/2,h/2,w/2-15,pink); break; case 4 : temp = create_bitmap(1,1); putpixel(temp,0,0,pink); switch (d) { case DN : y += speed; case UP : h -= speed; rectfill(buf,x,y,x+w,y+h,green); rectfill(buf,x+1,y,x+2,y+h,yellow); break; case RT : x += speed; case LF : w -= speed; rectfill(buf,x,y,x+w,y+h,green); rectfill(buf,x,y+1,x+w,y+2,yellow); break; } if (w <= 0 || h <= 0) destroy(); break; } if (exploding) { draw_sprite(buf,temp,x,y); } } int MSL::check(int &gx, int &gy, int gw, int gh, int gnum) { if (gnum!=guynum && x+w > gx - gw/4 && x < gx + gw/4 && y+h > gy + 5 && y < gy + gh) { if (type==3) { if (sqrt(pow(gx-x,2)+pow(gy-gh/2-y,2))>w+5) return 0; int gd=0; if (gx < x + w/2) { gx -= pushval; gd = LF; } else if (gx > x + w/2) { gx += pushval; gd = RT; } if (gy + h/2 < y + h/2 && d==UP) { gy -= pushval; gd = UP; } for (int i=0; i