From d57c5ef5e0bbbc21a8f4e9f5bd9281348b0be11f Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sun, 13 Feb 2011 00:05:09 +0000 Subject: [PATCH] Visual Studio compatibility Also fix two compiler warnings --- includes/defines.h | 4 ++++ src/interface.c | 5 ++--- src/main.c | 16 +++++++++------- src/powder.c | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index f4a2a4dfa..3b765aabc 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -83,6 +83,10 @@ typedef unsigned int pixel; #define GLASS_IOR 1.9 #define GLASS_DISP 0.07 +#ifdef WIN32 +#define strcasecmp stricmp +#endif + typedef unsigned char uint8; extern int amd; diff --git a/src/interface.c b/src/interface.c index 32c83a18b..d3057d8e0 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3841,7 +3841,7 @@ struct command_history { typedef struct command_history command_history; command_history *last_command = NULL; char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands - int mx,my,b,bq,cc,ci = -1; + int mx,my,b,cc,ci = -1; command_history *currentcommand; ui_edit ed; ed.x = 15; @@ -3857,7 +3857,6 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show //fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190); while (!sdl_poll()) { - bq = b; b = SDL_GetMouseState(&mx, &my); mx /= sdl_scale; my /= sdl_scale; @@ -3994,9 +3993,9 @@ int console_parse_coords(char *txt, int *x, int *y, char *err) } int console_parse_partref(char *txt, int *which, char *err) { + int i = -1, nx, ny; strcpy(err,""); // TODO: use regex? - int i = -1, nx, ny; if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err)) { i = pmap[ny][nx]; diff --git a/src/main.c b/src/main.c index bb2747323..370f693f7 100644 --- a/src/main.c +++ b/src/main.c @@ -1198,9 +1198,9 @@ int main(int argc, char *argv[]) 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; GSPEED = 1; - SDL_AudioSpec fmt; /* Set 16-bit stereo audio at 22Khz */ fmt.freq = 22050; fmt.format = AUDIO_S16; @@ -2361,16 +2361,18 @@ int main(int argc, char *argv[]) { char buff[256]; int sldr; + char *buff2; memset(buff, 0, sizeof(buff)); for(sldr=3; signs[signi].text[sldr] != '|'; sldr++) buff[sldr-3] = signs[signi].text[sldr]; - char buff2[sldr-2]; //TODO: Fix this for Visual Studio - memset(buff2, 0, sizeof(buff2)); + buff2 = malloc(sldr-2); + memset(buff2, 0, sldr-2); memcpy(&buff2, &buff, sldr-3); open_ui(vid_buf, buff2, 0); + free(buff2); } } } @@ -2753,18 +2755,18 @@ int process_command(pixel *vid_buf,char *console,char *console_error) { FILE *f=fopen(console3, "r"); if(f) { + 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) console_parse_coords(console4, &nx , &ny, console_error); - char fileread[5000];//TODO: make this change with file size - char pch[5000]; memset(pch,0,sizeof(pch)); memset(fileread,0,sizeof(fileread)); - char tokens[10]; - int tokensize; fread(fileread,1,5000,f); for(i=0; i=XRES || y>=YRES || i>=NPART) - return -1; + return; parts[i].type = t; if (t==PT_PHOT)// || t==PT_NEUT) {