diff --git a/Makefile.freebsd b/Makefile.freebsd index a0e0f3b..7e9cc5e 100644 --- a/Makefile.freebsd +++ b/Makefile.freebsd @@ -1,5 +1,5 @@ netmapr: netmapr.c constants.h netmapr.h Makefile - gcc -Wall -g netmapr.c -onetmapr `sdl11-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf + gcc -Wall -O2 -g netmapr.c -onetmapr `sdl11-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf install: netmapr install -C -o root -m 755 netmapr /usr/local/bin/netmapr diff --git a/Makefile.linux b/Makefile.linux index e6f97f0..ffae3b3 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,5 +1,5 @@ netmapr: netmapr.c constants.h netmapr.h Makefile - gcc -Wall -g netmapr.c -onetmapr `sdl-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf + gcc -Wall -O2 -g netmapr.c -onetmapr `sdl-config --libs --cflags` -L/usr/X11R6/lib -lX11 -lpthread -lXext -lSDL_ttf ln -f netmapr netmapr-viewer install: netmapr diff --git a/Makefile.windows b/Makefile.windows index 7bc11d6..a5b4133 100644 --- a/Makefile.windows +++ b/Makefile.windows @@ -1,5 +1,5 @@ netmapr: netmapr.c constants.h netmapr.h Makefile - gcc -mwindows -mno-cygwin -Wall -onetmapr.exe -g netmapr.c windows_files/attachicon.res -I/usr/local/include -lmingw32 -L/usr/local/lib -lSDLmain -lSDL -lSDL_ttf + gcc -mwindows -mno-cygwin -Wall -onetmapr.exe -O2 -g netmapr.c windows_files/attachicon.res -I/usr/local/include -lmingw32 -L/usr/local/lib -lSDLmain -lSDL -lSDL_ttf convert: convert.c convert.h Makefile gcc -Wall -g convert.c -I/usr/local/include -oconvert -lmingw32 -L/usr/local/lib -lSDLmain -lSDL diff --git a/constants.h b/constants.h index d28be77..e4f59a0 100644 --- a/constants.h +++ b/constants.h @@ -1,11 +1,11 @@ -#define VERSION "1.7c" +#define VERSION "1.7e" /* variable sizes */ #define SMALLBUFLEN 64 /* small text buffer */ #define BUFLEN 512 /* large text buffer */ /* user interface settings elements */ -#define DOUBLECLICKTHRES 250 /* how fast a double click needs to be (in ticks) */ +#define DOUBLECLICKTHRES 450 /* how fast a double click needs to be (in ticks) */ #define CURSORWIDTH 6 /* width of text cursor */ #define FIRSTLET 33 /* first ASCII value for letters */ #define LASTLET 122 /* last ASCII value for letters */ diff --git a/netmapr.c b/netmapr.c index d7623c1..ec445e8 100644 --- a/netmapr.c +++ b/netmapr.c @@ -20,6 +20,7 @@ SDL_Surface *screen, *buffer; SDL_Surface *emptyimg; SDL_Surface *icon; SDL_Event event; +int isevent; char svgbuf[BUFLEN]; FILE *svgfile; @@ -116,8 +117,8 @@ int numchildren = 0; char currentfilename[BUFLEN]; int state = S_NONE; -SDL_Surface *shadow; /* for object moves */ -SDL_Surface *bg; /* background for temp images*/ +SDL_Surface *shadow = NULL; /* for object moves */ +SDL_Surface *bg = NULL; /* background for temp images*/ int *linebg; /* background for temp lines */ int bgx,bgy; int bgw,bgh; @@ -151,7 +152,7 @@ int main (int argc, char **argv) { int done; int c; int c2; - int mod; + int mod = FALSE; int tmod; int o; Uint32 oldticks = 0; @@ -249,7 +250,15 @@ int main (int argc, char **argv) { } } /* check for input */ - while (SDL_PollEvent(&event)) { + //while (SDL_PollEvent(&event)) { + isevent = TRUE; + if (infoflash || errorflash) { + if (!SDL_PollEvent(&event)) isevent = FALSE; + } else { + if (!SDL_WaitEvent(&event)) isevent = FALSE; + } + + while (isevent) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: if (isonmap(event.button.x, event.button.y)) { @@ -1883,6 +1892,12 @@ int main (int argc, char **argv) { } break; } + + if (infoflash || errorflash) { + if (!SDL_PollEvent(&event)) isevent = FALSE; + } else { + isevent = FALSE; + } } } /* end main loop */ @@ -2593,7 +2608,10 @@ void adjustendpoint(SDL_Surface *screen, int *adjx, int *adjy, double x1, double */ oldo = o; } else { - if (temps != NULL) SDL_FreeSurface(temps); + if (temps != NULL) { + SDL_FreeSurface(temps); + temps = NULL; + } middlex = x; middley = y; break; @@ -2609,6 +2627,7 @@ void adjustendpoint(SDL_Surface *screen, int *adjx, int *adjy, double x1, double (tempc.b == map[curmap].bgcol.b)) { /* free temporary surface */ SDL_FreeSurface(temps); + temps = NULL; middlex = x; middley = y; @@ -2627,6 +2646,11 @@ void adjustendpoint(SDL_Surface *screen, int *adjx, int *adjy, double x1, double } } + + if (temps != NULL) { + SDL_FreeSurface(temps); + temps = NULL; + } *adjx = middlex; *adjy = middley; } @@ -2717,7 +2741,6 @@ void drawarrowhead(SDL_Surface *screen, double x1, double y1, double x2, double int arrowend1x,arrowend1y; int arrowend2x,arrowend2y; int middlex, middley; - int numpixels; int arrowlength = 5; int arrowthickness; @@ -2726,11 +2749,11 @@ void drawarrowhead(SDL_Surface *screen, double x1, double y1, double x2, double /* calculate arrow length based on line length line length > 40 means arrow length is 5, otherwise it's 3 */ - if (numpixels > 40) { - arrowlength = 5; - } else { - arrowlength = 3; - } + //if (numpixels > 40) { + // arrowlength = 5; + //} else { + arrowlength = 3; + //} /* adjust for line thickness */ arrowlength = arrowlength + arrowthickness - 1; @@ -2792,21 +2815,17 @@ void drawarrowheadSVG(double x1, double y1, double x2, double y2, SDL_Color c, i int arrowend1x,arrowend1y; int arrowend2x,arrowend2y; int middlex, middley; - int numpixels; int arrowlength = 5; int arrowthickness; arrowthickness = (arrowstyle & 0x0000ff); - /* calculate arrow length based on line length - line length > 40 means arrow length is 5, - otherwise it's 3 */ - if (numpixels > 40) { - arrowlength = 5; - } else { - arrowlength = 3; - } + //if (numpixels > 40) { + // arrowlength = 5; + //} else { + arrowlength = 3; + //} /* adjust for line thickness */ arrowlength = arrowlength + arrowthickness - 1; @@ -3497,6 +3516,8 @@ void drawobject(SDL_Surface *dest, mapobject_t *o, int doublebuffer) { fflush(stdout); } SDL_BlitSurface(temps, 0, dest, &area); + SDL_FreeSurface(temps); + temps = NULL; } else { SDL_UpdateRect(temps, 0, 0, o->w, o->h); } @@ -4370,6 +4391,7 @@ void drawobox(void) { SDL_BlitSurface(ts, 0, screen, &area); SDL_FreeSurface(ts); + ts = NULL; } } @@ -4439,6 +4461,7 @@ void drawtext(SDL_Surface *dest, text_t *t) { SDL_BlitSurface(ts, 0, dest, &area); SDL_FreeSurface(ts); + ts = NULL; } @@ -4752,11 +4775,14 @@ void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h realy1 = ((float)vimg->vector[i].y1 * yscale); realx2 = ((float)vimg->vector[i].x2 * xscale); realy2 = ((float)vimg->vector[i].y2 * yscale); + realx3 = 0; + realy3 = 0; + realx4 = 0; + realy4 = 0; } /* create temp surface */ - if ((vimg->vector[i].type == VT_POLY) || (vimg->vector[i].type == VT_SUBOBJ)) { if (temp == NULL) { temp = SDL_CreateRGBSurface(SDL_HWSURFACE,w+3, h+3, @@ -4893,13 +4919,16 @@ void drawvector(SDL_Surface *dest, vectorimg_t *vimg, int x, int y, int w, int h /* free it */ if (vimg->vector[i].type != VT_POLY) { if (!insubobj) { - //if (temp != NULL) { SDL_FreeSurface(temp); temp = NULL; - //} } } } + + if (temp != NULL) { + SDL_FreeSurface(temp); + temp = NULL; + } return; } @@ -4993,6 +5022,10 @@ void drawvectorSVG(vectorimg_t *vimg, int x, int y, int w, int h, SDL_Color *ove realy1 = y+ ((float)vimg->vector[i].y1 * yscale); realx2 = x+ ((float)vimg->vector[i].x2 * xscale); realy2 = y+ ((float)vimg->vector[i].y2 * yscale); + realx3 = 0; + realy3 = 0; + realx4 = 0; + realy4 = 0; } @@ -5156,6 +5189,7 @@ int endtext(void) { SDL_UpdateRect(screen, bgx, bgy, bg->w, bg->h); // free it SDL_FreeSurface(bg); + bg = NULL; } if (strlen(text) == 0) { @@ -5233,6 +5267,7 @@ int endtextedit(void) { SDL_UpdateRect(screen, bgx, bgy, bg->w, bg->h); // free it SDL_FreeSurface(bg); + bg = NULL; } if (strlen(text) == 0) { @@ -5268,7 +5303,9 @@ int endtextmove(int x, int y) { int txoff,tyoff; SDL_FreeSurface(shadow); + shadow = NULL; SDL_FreeSurface(bg); + bg = NULL; if (map[curmap].textob[map[curmap].curtext].anchor == -1) { txoff = 0; @@ -5717,7 +5754,7 @@ int loadmap(void) { void lowerselected(int amt) { int i,n; int temptype,tempid; - int target; + int target = 0; for (n = 0; n < amt; n++) { /* find map[curmap].object */ @@ -7117,7 +7154,7 @@ void initvars(void) { void raiseselected(int amt) { int i,n; int temptype,tempid; - int target; + int target = 0; for (n = 0; n < amt; n++) { /* find map[curmap].object */ @@ -7384,12 +7421,17 @@ int showfiledialog(void) { // free it //SDL_UpdateRect(screen,area.x, area.y, area.w, area.h); SDL_FreeSurface(bg); + bg = NULL; } /* copy new background */ sarea.x = startx; sarea.y = starty; sarea.w = tw + CURSORWIDTH; // include space for cursor sarea.h = DEFTEXTH*2; + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,sarea.w, sarea.h, buffer->format->BitsPerPixel, buffer->format->Rmask, buffer->format->Gmask,buffer->format->Bmask, @@ -7525,6 +7567,10 @@ int startlinkpointmove(int x, int y) { linex2 = map[curmap].olink[map[curmap].curlink].point[map[curmap].curlinkpoint].x + (LINESELHANDLESIZE / 2)+2; liney2 = map[curmap].olink[map[curmap].curlink].point[map[curmap].curlinkpoint].y + (LINESELHANDLESIZE / 2)+2; + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE, LINESELHANDLESIZE, LINESELHANDLESIZE, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7624,6 +7670,10 @@ int startobjmove (int x, int y) { starty = y; changestate(S_OBJMOVING); /* copy background */ + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].obj[map[curmap].curobj].w,map[curmap].obj[map[curmap].curobj].h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7639,6 +7689,10 @@ int startobjmove (int x, int y) { bgh = area.h; /* take a copy of the object itself */ + if (shadow != NULL) { + SDL_FreeSurface(shadow); + shadow = NULL; + } shadow = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].obj[map[curmap].curobj].w+3, map[curmap].obj[map[curmap].curobj].h+3, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7661,6 +7715,10 @@ int startresize (int x, int y) { changestate(S_RESIZING); /* copy background */ + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,MAXOBJWIDTH+2,MAXOBJHEIGHT+2, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7713,6 +7771,10 @@ int startresizetext(int x, int y) { drawstatusbar(); /* copy background */ + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].width,map[curmap].height, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7769,6 +7831,10 @@ int starttextmove (int x, int y) { starty = y ; changestate(S_TEXTMOVING); /* copy background */ + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,map[curmap].textob[map[curmap].curtext].w,th+5, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7784,6 +7850,10 @@ int starttextmove (int x, int y) { bgh = area.h; /* take a copy of the text itself */ + if (shadow != NULL) { + SDL_FreeSurface(shadow); + shadow = NULL; + } shadow = SDL_CreateRGBSurface(SDL_SWSURFACE,map[curmap].textob[map[curmap].curtext].w+3, th + 3, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -7919,12 +7989,17 @@ int updatefilename(void) { SDL_UpdateRect(screen, bgx, bgy, bg->w, bg->h); // free it SDL_FreeSurface(bg); + bg = NULL; } /* copy new background */ sarea.x = startx; sarea.y = starty; sarea.w = ((strlen(text)+1) * (DEFTEXTW*2)) +2; // include space for cursor sarea.h = DEFTEXTH*2; + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,sarea.w, sarea.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -8026,6 +8101,10 @@ int updatelinkpointshadow(int x, int y) { linex1 = x - (LINESELHANDLESIZE / 2); liney1 = y - (LINESELHANDLESIZE / 2); + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE, LINESELHANDLESIZE, LINESELHANDLESIZE, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -8299,6 +8378,7 @@ int updatetextcursor(void) { SDL_UpdateRect(screen, bgx, bgy, bg->w, bg->h); // free it SDL_FreeSurface(bg); + bg = NULL; } /* copy new background */ sarea.x = startx; @@ -8309,6 +8389,10 @@ int updatetextcursor(void) { sarea.h = th; //sarea.h = DEFTEXTH; //sarea.w = ((strlen(text)+1) * (DEFTEXTW)) +2; // include space for cursor + if (bg != NULL) { + SDL_FreeSurface(bg); + bg = NULL; + } bg = SDL_CreateRGBSurface(SDL_HWSURFACE,sarea.w, sarea.h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask,screen->format->Bmask, @@ -8596,7 +8680,9 @@ int endobjmove(int x, int y) { int newx, newy; SDL_FreeSurface(bg); + bg = NULL; SDL_FreeSurface(shadow); + shadow = NULL; /* check position */ if ((map[curmap].obj[map[curmap].curobj].x + x - startx) >= (map[curmap].width - map[curmap].obj[map[curmap].curobj].w)) { @@ -8638,6 +8724,7 @@ int endresize(int x, int y) { SDL_FreeSurface(bg); + bg = NULL; origw = map[curmap].obj[map[curmap].curobj].w; origh = map[curmap].obj[map[curmap].curobj].h; @@ -8722,6 +8809,7 @@ int endtextresize(int x, int y) { int tw,th; SDL_FreeSurface(bg); + bg = NULL; origw = map[curmap].textob[map[curmap].curtext].w; origh = map[curmap].textob[map[curmap].curtext].h; diff --git a/netmapr.exe b/netmapr.exe index 2634329..778af98 100755 Binary files a/netmapr.exe and b/netmapr.exe differ