diff --git a/PCX/PODLAHY.C b/PCX/PODLAHY.C index 98e9e9e..a7321b5 100644 --- a/PCX/PODLAHY.C +++ b/PCX/PODLAHY.C @@ -32,7 +32,7 @@ struct tbarva palette[256]; char datapath[]=""; extern struct all_view showtabs; -extern t_points points; +extern t_points viewport_geometry; void do_events() { @@ -103,11 +103,11 @@ void draw_it_all_f() int i,m,y,m2,s; y=0;s=0; - m2=(360-MIDDLE_Y)-points[0][0][VIEW3D_Z].y; + m2=(360-MIDDLE_Y)-viewport_geometry[0][0][VIEW3D_Z].y; shadow_max=m2; for (i=0;i ${CMAKE_BINARY_DIR}/default_font.base64 + COMMAND file_to_base64 ${CMAKE_CURRENT_LIST_DIR}/boldcz.fon > ${CMAKE_BINARY_DIR}/default_font.base64 DEPENDS ${CMAKE_CURRENT_LIST_DIR}/boldcz.fon) diff --git a/game/builder.c b/game/builder.c index a2810a5..e9d253c 100644 --- a/game/builder.c +++ b/game/builder.c @@ -1029,7 +1029,7 @@ int draw_sloup_sector(int celx,int cely,int sector) if (q->flags & SD_SPEC) show_cel2(celx,cely-1,ablock(num_ofsets[MAIN_NUM]+q->sec+(q->sec_anim>>4)),0,0,2, ghost_walls| (q->flags & tmask)); else - show_cel2(celx,cely-1,ablock(num_ofsets[MAIN_NUM]+q->sec+(q->sec_anim>>4)),(q->xsec<<1)+celx*(points[0][0][cely].x-points[0][0][cely-1].x)/2,q->ysec<<1,0, ghost_walls| (q->flags & tmask)); + show_cel2(celx,cely-1,ablock(num_ofsets[MAIN_NUM]+q->sec+(q->sec_anim>>4)),(q->xsec<<1)+celx*(viewport_geometry[0][0][cely].x-viewport_geometry[0][0][cely-1].x)/2,q->ysec<<1,0, ghost_walls| (q->flags & tmask)); } return 0; } @@ -1075,10 +1075,10 @@ void draw_sector(int celx,int cely,int s) void back_clear(int celx,int color) { int x1,y1,x2,y2,xc; - y1=points[0][0][VIEW3D_Z].y+MIDDLE_Y+SCREEN_OFFLINE; - y2=points[0][1][VIEW3D_Z].y+MIDDLE_Y+SCREEN_OFFLINE; - x2=points[0][1][VIEW3D_Z].x+MIDDLE_X; - x1=-points[0][1][VIEW3D_Z].x+MIDDLE_X; + y1=viewport_geometry[0][0][VIEW3D_Z].y+MIDDLE_Y+SCREEN_OFFLINE; + y2=viewport_geometry[0][1][VIEW3D_Z].y+MIDDLE_Y+SCREEN_OFFLINE; + x2=viewport_geometry[0][1][VIEW3D_Z].x+MIDDLE_X; + x1=-viewport_geometry[0][1][VIEW3D_Z].x+MIDDLE_X; xc=(x2-x1+2)*celx; x1=x1+xc-1; x2=x2+xc; diff --git a/game/clk_map.c b/game/clk_map.c index b2b7791..286fdce 100644 --- a/game/clk_map.c +++ b/game/clk_map.c @@ -45,10 +45,10 @@ char clk_touch_vyk(int sector,int side,int xr,int yr) x2=v->xpos+v->xs/2; y1=320-(v->ypos+v->ys); y2=320-(v->ypos); - x1+=MIDDLE_X-points[0][1][1].x; - x2+=MIDDLE_X-points[0][1][1].x; - y1+=MIDDLE_Y+points[0][1][1].y; - y2+=MIDDLE_Y+points[0][1][1].y; + x1+=MIDDLE_X-viewport_geometry[0][1][1].x; + x2+=MIDDLE_X-viewport_geometry[0][1][1].x; + y1+=MIDDLE_Y+viewport_geometry[0][1][1].y; + y2+=MIDDLE_Y+viewport_geometry[0][1][1].y; if (x1<=xr && xr<=x2 && y1<=yr && yr<=y2) { if (picked_item==NULL) @@ -113,18 +113,18 @@ char clk_touch(int id,int xa,int ya,int xr,int yr) y2=ya+y1/2; y1=y2-y1; x1=x2-x1; - x1+=MIDDLE_X-points[0][1][1].x; - x2+=MIDDLE_X-points[0][1][1].x; - y1+=MIDDLE_Y+points[0][1][1].y; - y2+=MIDDLE_Y+points[0][1][1].y; + x1+=MIDDLE_X-viewport_geometry[0][1][1].x; + x2+=MIDDLE_X-viewport_geometry[0][1][1].x; + y1+=MIDDLE_Y+viewport_geometry[0][1][1].y; + y2+=MIDDLE_Y+viewport_geometry[0][1][1].y; ext=1; } else if (map_sides[id].sec==0) { - x1=MIDDLE_X-points[0][0][1].x; - y1=MIDDLE_Y+points[0][1][1].y; + x1=MIDDLE_X-viewport_geometry[0][0][1].x; + y1=MIDDLE_Y+viewport_geometry[0][1][1].y; x2=640-x1; - y2=MIDDLE_Y+points[0][0][1].y; + y2=MIDDLE_Y+viewport_geometry[0][0][1].y; ext=((map_sides[id].flags & SD_THING_IMPS) && !(map_sides[id].oblouk & SD_ITPUSH)); } else return 0; diff --git a/game/engine1.c b/game/engine1.c index 4211fb8..9cc0075 100644 --- a/game/engine1.c +++ b/game/engine1.c @@ -16,16 +16,16 @@ #include #define CTVR 128 -t_points points; +t_points viewport_geometry; struct all_view showtabs; static char backgrnd_mode=0; static int lclip,rclip; ZOOMINFO zoom; -char zooming_xtable[ZOOM_PHASES][VIEW_SIZE_X]; -short zooming_ytable[ZOOM_PHASES][VIEW_SIZE_Y]; -short zooming_points[ZOOM_PHASES][4] +static char zooming_xtable[ZOOM_PHASES][VIEW_SIZE_X]; +static short zooming_ytable[ZOOM_PHASES][VIEW_SIZE_Y]; +static short zooming_points[ZOOM_PHASES][4] ={ {620,349,10,3}, {600,338,20,7}, @@ -37,9 +37,9 @@ short zooming_points[ZOOM_PHASES][4] {480,271,80,28}, {460,259,90,31} }; -int zooming_step=2; -int rot_phases=2; -int yreq; +static int zooming_step=2; +static int rot_phases=1; +//int yreq; int last_scale; char secnd_shade=1; @@ -100,11 +100,11 @@ void lodka64b(void *source,void *target,void *background,void *xlat,int32_t xysi //#pragma aux lodka64b parm [ESI][EDI][EAX][EBX][ECX] modify [EAX EDX] */ -void *p,*p2,*pozadi,*podlaha,*strop,*sit;int i; -void (*zooming)(void *source,int32_t target,word *background,void *xlat,int32_t xysize); -void (*turn)(int32_t lbuf,void *src1,void *src2,int size1); -word *GetBuffer2nd(); -word *background; +//void *p,*p2,*pozadi,*podlaha,*strop,*sit;int i; +//void (*zooming)(void *source,int32_t target,word *background,void *xlat,int32_t xysize); +//void (*turn)(int32_t lbuf,void *src1,void *src2,int size1); +//word *GetBuffer2nd(); +//word *background; char nofloors=0,show_names=0,show_lives=0; @@ -232,10 +232,10 @@ void calc_points(void) x2=START_X2+2*START_X1*j;y2=START_Y2; for (i=0;iMIDDLE_X) showtabs.z_table[x][y].used=0; + if (viewport_geometry[x][0][y+1].x>MIDDLE_X) showtabs.z_table[x][y].used=0; else { showtabs.z_table[x][y].used=1; - rozdil1=points[x][0][y].x-points[x][0][y+1].x; - rozdil2=rozdil1-MIDDLE_X+points[x][0][y+1].x; - rozdil3=points[0][0][y].x-points[0][0][y+1].x; + rozdil1=viewport_geometry[x][0][y].x-viewport_geometry[x][0][y+1].x; + rozdil2=rozdil1-MIDDLE_X+viewport_geometry[x][0][y+1].x; + rozdil3=viewport_geometry[0][0][y].x-viewport_geometry[0][0][y+1].x; if (rozdil2<0) { - showtabs.z_table[x][y].xpos=MIDDLE_X-points[x][0][y].x; + showtabs.z_table[x][y].xpos=MIDDLE_X-viewport_geometry[x][0][y].x; showtabs.z_table[x][y].txtoffset=0; } else { - showtabs.z_table[x][y].xpos=MIDDLE_X-points[x][0][y].x; + showtabs.z_table[x][y].xpos=MIDDLE_X-viewport_geometry[x][0][y].x; showtabs.z_table[x][y].txtoffset=(TXT_SIZE_X_3D*rozdil2/rozdil1); } showtabs.z_table[x][y].point_total=rozdil1; @@ -325,23 +325,23 @@ void create_tables(void) { int rozdil1,rozdil2; - if (x && points[x-1][0][y].x>TXT_SIZE_X) showtabs.z_table[x][y].used=0; + if (x && viewport_geometry[x-1][0][y].x>TXT_SIZE_X) showtabs.z_table[x][y].used=0; else { showtabs.x_table[x][y].used=1; - rozdil1=points[1][0][y+1].x-points[0][0][y+1].x; - rozdil2=-MIDDLE_X+points[x][0][y+1].x; + rozdil1=viewport_geometry[1][0][y+1].x-viewport_geometry[0][0][y+1].x; + rozdil2=-MIDDLE_X+viewport_geometry[x][0][y+1].x; if (rozdil2<0) { - showtabs.x_table[x][y].xpos=MIDDLE_X-points[x][0][y+1].x; + showtabs.x_table[x][y].xpos=MIDDLE_X-viewport_geometry[x][0][y+1].x; showtabs.x_table[x][y].txtoffset=0; showtabs.x_table[x][y].max_x=rozdil1; } else { - showtabs.x_table[x][y].xpos=MIDDLE_X-points[x][0][y+1].x; + showtabs.x_table[x][y].xpos=MIDDLE_X-viewport_geometry[x][0][y+1].x; showtabs.x_table[x][y].txtoffset=(TXT_SIZE_X*rozdil2/rozdil1); - showtabs.x_table[x][y].max_x=MIDDLE_X-points[x-1][0][y+1].x; + showtabs.x_table[x][y].max_x=MIDDLE_X-viewport_geometry[x-1][0][y+1].x; } if (x!=0)showtabs.x_table[x][y].xpos2=VIEW_SIZE_X-(showtabs.x_table[x][y].xpos+rozdil1); showtabs.x_table[x][y].point_total=rozdil1; @@ -357,32 +357,32 @@ void create_tables(void) strd=CF_XMAP_SIZE>>1; y1=(VIEW_SIZE_Y-y)-MIDDLE_Y; - yp=1;while (points[0][0][yp].y>y1) yp++; + yp=1;while (viewport_geometry[0][0][yp].y>y1) yp++; if (xstrd) { - xl=+points[x-strd-1][0][0].x;xr=+points[x-strd][0][0].x; + xl=+viewport_geometry[x-strd-1][0][0].x;xr=+viewport_geometry[x-strd][0][0].x; } else { continue; } y1=(VIEW_SIZE_Y-y)-MIDDLE_Y; - xl=xl*(y1+1)/points[0][0][0].y+MIDDLE_X; - xr=xr*(y1+1)/points[0][0][0].y+MIDDLE_X; + xl=xl*(y1+1)/viewport_geometry[0][0][0].y+MIDDLE_X; + xr=xr*(y1+1)/viewport_geometry[0][0][0].y+MIDDLE_X; if (xl<0) xl=0; if (xr<0) xr=0; if (xl>639) xl=639; if (xr>639) xr=639; showtabs.f_table[x][y].lineofs=(y1+MIDDLE_Y)*2*scr_linelen2+xl*2; showtabs.f_table[x][y].linesize=xr-xl+(xl!=xr); - showtabs.f_table[x][y].counter=(y1-points[0][0][yp].y); + showtabs.f_table[x][y].counter=(y1-viewport_geometry[0][0][yp].y); showtabs.f_table[x][y].txtrofs=(y1+MIDDLE_Y-VIEW_SIZE_Y+F_YMAP_SIZE)*1280+xl*2; } @@ -393,31 +393,31 @@ void create_tables(void) strd=CF_XMAP_SIZE>>1; y1=y-MIDDLE_Y; - yp=1;while (points[0][1][yp].ystrd) { - xl=+points[x-strd-1][1][0].x;xr=+points[x-strd][1][0].x; + xl=+viewport_geometry[x-strd-1][1][0].x;xr=+viewport_geometry[x-strd][1][0].x; } else { continue; } - xl=xl*(y1-2)/points[0][1][0].y+MIDDLE_X; - xr=xr*(y1-2)/points[0][1][0].y+MIDDLE_X; + xl=xl*(y1-2)/viewport_geometry[0][1][0].y+MIDDLE_X; + xr=xr*(y1-2)/viewport_geometry[0][1][0].y+MIDDLE_X; if (xl<0) xl=0; if (xr<0) xr=0; if (xl>639) xl=639; if (xr>639) xr=639; showtabs.c_table[x][y].lineofs=(y1+MIDDLE_Y)*2*scr_linelen2+xl*2; showtabs.c_table[x][y].linesize=xr-xl+(xl!=xr); - showtabs.c_table[x][y].counter=points[0][1][yp].y-y1; + showtabs.c_table[x][y].counter=viewport_geometry[0][1][yp].y-y1; showtabs.c_table[x][y].txtrofs=(y1+MIDDLE_Y)*1280+xl*2; } @@ -604,8 +604,8 @@ void show_cel(int celx,int cely,const void *stena,int xofs,int yofs,char rev, in xofs-=(txtsx>>1)*TXT_SIZE_X/TXT_SIZE_X_3D;yofs-=txtsy>>1; } rev&=1; - yss=(points[0][0][cely].y-points[0][0][cely+1].y)*xofs/TXT_SIZE_X; - ysd=(points[0][1][cely].y-points[0][1][cely+1].y)*xofs/TXT_SIZE_X; + yss=(viewport_geometry[0][0][cely].y-viewport_geometry[0][0][cely+1].y)*xofs/TXT_SIZE_X; + ysd=(viewport_geometry[0][1][cely].y-viewport_geometry[0][1][cely+1].y)*xofs/TXT_SIZE_X; yofs=yofs*(yd->vert_size-yss+ysd)/TXT_SIZE_Y+yss; xofs=xofs*x3d->point_total/TXT_SIZE_X; if (txtsx>x3d->point_total && celx) @@ -627,7 +627,7 @@ void show_cel(int celx,int cely,const void *stena,int xofs,int yofs,char rev, in if (x+realsx>640) realsx=640-x; if (realsx<=0) return; yofs=yd->drawline-yofs; - yofs+=(plac==1)?(-yp->vert_size+points[0][0][cely+1].y-points[0][0][cely].y):((plac==2)?(yd->vert_size):0); + yofs+=(plac==1)?(-yp->vert_size+viewport_geometry[0][0][cely+1].y-viewport_geometry[0][0][cely].y):((plac==2)?(yd->vert_size):0); if (yofs>360) { int r=yofs-360,ui; @@ -738,7 +738,7 @@ void draw_floor_ceil(int celx,int cely,char f_c,const void *txtr) txtr=(void *)((word *)txtr+3); if (f_c==0) //podlaha { - y=(VIEW_SIZE_Y-MIDDLE_Y)-points[0][0][cely].y+1; + y=(VIEW_SIZE_Y-MIDDLE_Y)-viewport_geometry[0][0][cely].y+1; if (y<1) y=1; txtr=(void *)((word *)txtr); fcdraw(txtr,GetBuffer2nd()+SCREEN_OFFSET,&showtabs.f_table[celx+3][y]); @@ -750,7 +750,7 @@ void draw_floor_ceil(int celx,int cely,char f_c,const void *txtr) } else { - y=points[0][1][cely].y+MIDDLE_Y+1; + y=viewport_geometry[0][1][cely].y+MIDDLE_Y+1; if (y<0) y=0; fcdraw(txtr,GetBuffer2nd()+SCREEN_OFFSET,&showtabs.c_table[celx+3][y]); /* if (debug) @@ -942,7 +942,7 @@ void clear_buff(word *background,word backcolor,int lines) if (background!=NULL) put_picture(0,SCREEN_OFFLINE,background);else lines=0; if (lines!=360) - for (i=lines;i<360;i++) + for (int i=lines;i<360;i++) clear_color(GetBuffer2nd()+SCREEN_OFFSET+scr_linelen2*i,640,backcolor); } @@ -951,7 +951,7 @@ void clear_screen(word *screen, word color) { int32_t scr_linelen2 = GetScreenPitch(); -for (i=0;i<480;i++) clear_color(screen+scr_linelen2*i,640,color); +for (int i=0;i<480;i++) clear_color(screen+scr_linelen2*i,640,color); } void general_engine_init() @@ -974,12 +974,12 @@ void map_pos(int celx,int cely,int posx,int posy,int posz,int *x,int *y) posx=CTVR-posx; celx=-celx; } - p1=(points[0][0][cely].y-points[0][1][cely].y); - p2=(points[0][0][cely+1].y-points[0][1][cely+1].y); + p1=(viewport_geometry[0][0][cely].y-viewport_geometry[0][1][cely].y); + p2=(viewport_geometry[0][0][cely+1].y-viewport_geometry[0][1][cely+1].y); last_scale=p=posy*(p2-p1)/CTVR+p1; - *y=points[0][0][cely].y-(posy*(points[0][0][cely].y-points[0][0][cely+1].y)/CTVR)-p*posz/CTVR; - xr=points[celx][0][cely].x-(posy*(points[celx][0][cely].x-points[celx][0][cely+1].x)/CTVR); - if (celx) xl=points[celx-1][0][cely].x-(posy*(points[celx-1][0][cely].x-points[celx-1][0][cely+1].x)/CTVR); + *y=viewport_geometry[0][0][cely].y-(posy*(viewport_geometry[0][0][cely].y-viewport_geometry[0][0][cely+1].y)/CTVR)-p*posz/CTVR; + xr=viewport_geometry[celx][0][cely].x-(posy*(viewport_geometry[celx][0][cely].x-viewport_geometry[celx][0][cely+1].x)/CTVR); + if (celx) xl=viewport_geometry[celx-1][0][cely].x-(posy*(viewport_geometry[celx-1][0][cely].x-viewport_geometry[celx-1][0][cely+1].x)/CTVR); else xl=-xr; *x=xl+((xr-xl)*posx/CTVR); if (negate2) *x=-*x; @@ -1201,14 +1201,14 @@ void set_lclip_rclip(int celx,int cely,int lc,int rc) { if (rc) { - x=points[celx][0][cely].x+MIDDLE_X; - xs=points[celx][0][cely].x-points[celx][0][cely+1].x; + x=viewport_geometry[celx][0][cely].x+MIDDLE_X; + xs=viewport_geometry[celx][0][cely].x-viewport_geometry[celx][0][cely+1].x; rclip=x-rc*xs/TXT_SIZE_X_3D; if (rclip>640) rclip=640; } if (celx>0 && lc) { - lclip=points[celx-1][0][cely].x+MIDDLE_X; + lclip=viewport_geometry[celx-1][0][cely].x+MIDDLE_X; if (lclip>rclip) lclip=rclip; } @@ -1218,14 +1218,14 @@ void set_lclip_rclip(int celx,int cely,int lc,int rc) if (lc) { int cc=-celx; - x=-points[cc][0][cely].x+MIDDLE_X; - xs=points[cc][0][cely].x-points[cc][0][cely+1].x; + x=-viewport_geometry[cc][0][cely].x+MIDDLE_X; + xs=viewport_geometry[cc][0][cely].x-viewport_geometry[cc][0][cely+1].x; lclip=x+lc*xs/TXT_SIZE_X_3D; if (lclip<0) lclip=0; } if (celx<0 && rc) { - rclip=-points[(-celx)-1][0][cely].x+MIDDLE_X; + rclip=-viewport_geometry[(-celx)-1][0][cely].x+MIDDLE_X; if (rclip(-1); for (unsigned int i = 0; i < 64;++i) { int c = _charset[i]-32; _charmap[c] = static_cast(i); diff --git a/libs/csv.hpp b/libs/csv.hpp index 6648b6f..23073ec 100644 --- a/libs/csv.hpp +++ b/libs/csv.hpp @@ -352,7 +352,7 @@ inline bool CSVReader::readRow(const CSVFieldIndexMapping &mapping,T } else { static_assert(std::is_same_v); CSVState st = read(buff); - std::transform(buff.begin(), buff.end(), buff.begin(), [](char c) { return std::tolower(c); }); + std::transform(buff.begin(), buff.end(), buff.begin(), [](char c) -> char { return std::tolower(c); }); if (buff == "y" || buff == "t" || buff =="true" || buff == "yes" || buff == "on") { target.*ptr = true; } else if (buff == "n" || buff == "f" || buff =="false" || buff == "no" || buff == "off") { diff --git a/libs/cztable.c b/libs/cztable.c index 9ac5f95..9c3eec5 100644 --- a/libs/cztable.c +++ b/libs/cztable.c @@ -55,7 +55,7 @@ static char prepare=1; static void PrepareTabs() { unsigned int i; - for (i=0;i<256;i++) {xlatkm2win[i]=i;xlatwin2km[i]=i;} + for (i=0;i<256;i++) {xlatkm2win[i]=(char)i;xlatwin2km[i]=(char)i;} for (i=0;i +#include + +int main(int argc, char **argv) { + if (argc != 2) { + std::cerr << "Requires name of the file" << std::endl; + return 1; + } + + std::ifstream input(argv[1], std::ios::in|std::ios::binary); + if (!input) { + std::cerr << "Failed to open:" << argv[1] << std::endl; + } + auto in_iter = std::istream_iterator(input); + auto in_end = std::istream_iterator(); + auto out_iter = std::ostream_iterator(std::cout); + base64.encode(in_iter, in_end, out_iter); + return 0; +} \ No newline at end of file diff --git a/libs/memman.c b/libs/memman.c index 4903bbc..bee7b0d 100644 --- a/libs/memman.c +++ b/libs/memman.c @@ -362,7 +362,7 @@ THANDLE_DATA *def_handle(int handle,const char *filename,ABLOCK_DECODEPROC decom h->seekpos=i; return h; } - memcpy(h->src_file,filename,12); + strncpy(h->src_file,filename,sizeof(h->src_file)); h->seekpos=0; strupper(h->src_file); h->loadproc=decompress; @@ -669,7 +669,7 @@ void display_status() if (h->src_file[0]) strncpy(nname,h->src_file,12);else strcpy(nname,""); printf("%04Xh ... %12s %s %s %08lXh %6d %10d %6d \n",i*BK_MINOR_HANDLES+j, nname,names[h->status-1], - copys,(unsigned long)h->blockdata,h->size,h->counter,h->lockcount); + copys,(unsigned long)(uintptr_t)h->blockdata,h->size,h->counter,h->lockcount); ln++; total_data+=h->size; if(h->status==BK_PRESENT)total_mem+=h->size; diff --git a/libs/memman.h b/libs/memman.h index e1a0cc9..1d5e4c4 100644 --- a/libs/memman.h +++ b/libs/memman.h @@ -42,7 +42,7 @@ typedef struct meminfo { typedef struct thandle_data { - char src_file[12]; //12 + char src_file[16]; //12 int32_t seekpos; //16 const void *blockdata; //20 char flags; //21 diff --git a/libs/strlists.c b/libs/strlists.c index f1fb0d5..93fcff1 100644 --- a/libs/strlists.c +++ b/libs/strlists.c @@ -49,7 +49,7 @@ void string_list_init(OBJREC *o,va_list params) } -void string_list_change() +void string_list_change(void) { OBJREC *o1,*o2; STRING_LIST_DATA *p; @@ -93,7 +93,7 @@ void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o) STRING_LIST_DATA *p; int y; char savech[]=" "; - int znh,i,j,max; + int znh,i,j,max = 1; TSTR_LIST ls; int savcolor=curcolor; diff --git a/mapedit/Podlahar/Podlahy.c b/mapedit/Podlahar/Podlahy.c index 5bb43e0..404bf87 100644 --- a/mapedit/Podlahar/Podlahy.c +++ b/mapedit/Podlahar/Podlahy.c @@ -33,7 +33,7 @@ struct tbarva palette[256]; char datapath[]=""; extern struct all_view showtabs; -extern t_points points; +extern t_points viewport_geometry; void do_events() { @@ -110,11 +110,11 @@ void draw_it_all_f(int genMlhu) int i,m,y,m2,s; y=0;s=0; - m2=(360-MIDDLE_Y)-points[0][0][VIEW3D_Z].y; + m2=(360-MIDDLE_Y)-viewport_geometry[0][0][VIEW3D_Z].y; shadow_max=m2; for (i=0;i path to configuration file\n" "-a path for adventure file (.adv)\n" - "-l set language (cz|en)" + "-l set language (cz|en)\n" "-s generate string-tables (for localization) and exit\n" "-h this help\n"); exit(0); diff --git a/platform/platform.h b/platform/platform.h index db75203..6d287fa 100644 --- a/platform/platform.h +++ b/platform/platform.h @@ -14,6 +14,8 @@ #pragma warning(disable: 4267) #pragma warning(disable: 4100) #pragma warning(disable: 4456) +#pragma warning(disable: 4457) +#pragma warning(disable: 4702) #define CASE_FALLTHROUGH #else #define CASE_FALLTHROUGH [[fallthrough]] diff --git a/platform/windows/app_start.cpp b/platform/windows/app_start.cpp index 531819a..54ba982 100644 --- a/platform/windows/app_start.cpp +++ b/platform/windows/app_start.cpp @@ -3,28 +3,30 @@ #include "../platform.h" #include #include +#include +#define WIN32_LEAN_AND_MEAN +#include +#include +#include -void show_help(const char *arg0) { - printf( +void show_help(std::ostream &out, const char *arg0) { + out << "Brany Skeldalu (Gates of Skeldal) portable game player\n" "Copyright (c) 2025 Ondrej Novak. All rights reserved.\n\n" "This work is licensed under the terms of the MIT license.\n" "For a copy, see .\n" "\n" - "Usage:" - ); - printf("%s [-f ] [-a ] [-l ] [-s ] [-h]\n\n", arg0); - - printf("-f path to configuration file\n" + "Usage:"; + out << arg0 << " [-f ] [-a ] [-l ] [-s ] [-h]\n\n"; + out << "-f path to configuration file\n" "-a path for adventure file (.adv)\n" - "-l set language (cz|en)" + "-l set language (cz|en)\n" "-s generate string-tables (for localization) and exit\n" - "-h this help\n"); - exit(0); + "-h this help\n"; } -void show_help_short() { - printf("Use -h for help\n"); +void show_help_short(std::ostream &out) { + out << "Use -h for help\n"; } @@ -33,26 +35,43 @@ int main(int argc, char **argv) { std::string adv_config_file; std::string gen_stringtable_path; std::string lang; + std::ostringstream console; for (int optchr = -1; (optchr = getopt(argc, argv, "hf:a:s:l:")) != -1; ) { switch (optchr) { case 'f': config_name = optarg;break; case 'a': adv_config_file = optarg;break; - case 'h': show_help(argv[0]);break; + case 'h': show_help(console, argv[0]);break; case 'l': lang = optarg;break; case 's': gen_stringtable_path = optarg;break; - default: show_help_short(); - return 1; + default: show_help_short(console);break; } } + if (!check_file_exists(config_name.c_str())) { + console << "ERROR: A configuration file was not found:\n\n" << config_name << "\n\n"; + show_help(console, argv[0]); + } + SKELDAL_CONFIG cfg; - cfg.short_help = show_help_short; + cfg.short_help = []{}; cfg.show_error = [](const char *txt) { - std::cerr << "ERROR: " << txt << std::endl; + char buff[MAX_PATH]; + GetModuleFileNameA(NULL,buff,MAX_PATH); + MessageBoxA(NULL,txt,buff, MB_OK|MB_ICONEXCLAMATION|MB_SYSTEMMODAL|MB_APPLMODAL); + ExitProcess(1); }; cfg.adventure_path = adv_config_file.empty()?NULL:adv_config_file.c_str(); cfg.config_path = config_name.c_str(); cfg.lang_path = lang.empty()?NULL:lang.c_str(); + + { + std::string msg = console.str(); + if (!msg.empty()) { + cfg.show_error(msg.c_str()); + return 1; + } + } + try { if (!gen_stringtable_path.empty()) { @@ -63,7 +82,7 @@ int main(int argc, char **argv) { } } catch (const std::exception &e) { - std::cerr << "ERROR: " << e.what() << std::endl; + cfg.show_error(e.what()); return 1; } @@ -71,3 +90,19 @@ int main(int argc, char **argv) { } +int WinMain(HINSTANCE,HINSTANCE ,LPSTR, INT) { + + int argc; + LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &argc); + + char **argv = (char **)alloca(sizeof(char *) * argc); + for (int i = 0; i < argc; ++i) { + DWORD need = WideCharToMultiByte(CP_UTF8,0,szArglist[i],wcslen(szArglist[i]),NULL,NULL,NULL,FALSE)+1; + argv[i] = (char *)alloca(sizeof(char) * need); + WideCharToMultiByte(CP_UTF8,0,szArglist[i],wcslen(szArglist[i]),argv[i],need,NULL,FALSE); + argv[i][need-1] = 0; + } + GlobalFree(szArglist); + return main(argc, argv); +} + diff --git a/platform/windows/icon.ico b/platform/windows/icon.ico new file mode 100644 index 0000000..0cd1f57 Binary files /dev/null and b/platform/windows/icon.ico differ diff --git a/platform/windows/skeldal.manifest b/platform/windows/skeldal.manifest new file mode 100644 index 0000000..dab929e --- /dev/null +++ b/platform/windows/skeldal.manifest @@ -0,0 +1,8 @@ + + + + + UTF-8 + + + diff --git a/platform/windows/skeldal.rc b/platform/windows/skeldal.rc new file mode 100644 index 0000000..1bc463a --- /dev/null +++ b/platform/windows/skeldal.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "icon.ico"