diff --git a/game/automap.c b/game/automap.c index 627be43..8820bd1 100644 --- a/game/automap.c +++ b/game/automap.c @@ -248,7 +248,7 @@ void psani_poznamek_event(EVENT_MSG *msg,void **data) switch (c) { case 8:if (index) index--; text[index]=0;break; - case 27:strcpy(text,save); + case 27:strcpy(text,save);break; case 13:save_text_to_map(x,y,cur_depth,text); send_message(E_DONE,E_MOUSE,psani_poznamek_event);msg->msg=-2;return; default:if (c>=32) @@ -407,8 +407,10 @@ static void draw_amap_sector(int x,int y,int sector,int mode,int turn,int line1, case S_SCHODY:set_font(H_FSYMB,0x3e0); memcpy(charcolors,stairs_colors,sizeof(stairs_colors)); print_symbol(x,y,'s');break; - case S_TELEPORT:for(i=0,sd=map_sides+sector*4;i<4 && ~sd->flags & SD_SEC_VIS;i++,sd++); - if (i!=4) {set_font(H_FSYMB,0x3e0);print_symbol(x,y,'T');}break; + case S_TELEPORT: + for(i=0,sd=map_sides+sector*4;i<4 && ~sd->flags & SD_SEC_VIS;i++,sd++) {} + if (i!=4) {set_font(H_FSYMB,0x3e0);print_symbol(x,y,'T');} + break; case S_DIRA:set_font(H_FSYMB,NOSHADOW(0));print_symbol(x,y,'N');break; } } diff --git a/game/builder.c b/game/builder.c index a0e99f1..79a3c4d 100644 --- a/game/builder.c +++ b/game/builder.c @@ -228,7 +228,8 @@ void chveni(int i) static int count=0; if (!count && !i) return; - if (i) count=i;count--; + if (i) count=i; + count--; if (!count) pos=0; wait_retrace(); setvesa_displaystart(8*pos,0); @@ -960,18 +961,22 @@ void draw_players(int sector,int dir,int celx,int cely) freep[f=p_place_table[d][j]]=i+1; } } - if (pp==1 && freep[f] & 1) - {pp=f+1&3;freep[pp]=freep[f];freep[f]=0;} - for(i=0;i<5;i++) - if ((j=freep[d=p_place_table[0][i]])!=0) { - if (postavy[j-1].lives) - { - set_font(H_FLITT5,barvy_skupin[postavy[j-1].groupnum]); - draw_player(ablock(H_POSTAVY+j-1),celx,cely,p_positions_x[d],p_positions_y[d],HUMAN_ADJUST,postavy[j-1].jmeno); - } - else - draw_player(ablock(H_KOSTRA),celx,cely,p_positions_x[d],p_positions_y[d]-32,HUMAN_ADJUST,NULL); + if (pp == 1 && freep[f] & 1) { + pp = (f + 1) & 3; + freep[pp] = freep[f]; + freep[f] = 0; } + for (i = 0; i < 5; i++) + if ((j = freep[d = p_place_table[0][i]]) != 0) { + if (postavy[j - 1].lives) { + set_font(H_FLITT5, barvy_skupin[postavy[j - 1].groupnum]); + draw_player(ablock(H_POSTAVY + j - 1), celx, cely, + p_positions_x[d], p_positions_y[d], HUMAN_ADJUST, + postavy[j - 1].jmeno); + } else + draw_player(ablock(H_KOSTRA), celx, cely, p_positions_x[d], + p_positions_y[d] - 32, HUMAN_ADJUST, NULL); + } } diff --git a/game/dialogy.c b/game/dialogy.c index d23d006..545f7bf 100644 --- a/game/dialogy.c +++ b/game/dialogy.c @@ -1141,11 +1141,11 @@ static void dark_screen(int time,int gtime) for(i=0,h=postavy;iused && h->lives) { z=h->vlastnosti[VLS_HPREG]*gtime;z+=h->lives; - if (z>h->vlastnosti[VLS_MAXHIT]) z=h->vlastnosti[VLS_MAXHIT];h->lives=z; + if (z>h->vlastnosti[VLS_MAXHIT]) {z=h->vlastnosti[VLS_MAXHIT];h->lives=z;} z=h->vlastnosti[VLS_MPREG]*gtime;z+=h->mana; - if (z>h->vlastnosti[VLS_MAXMANA]) z=h->vlastnosti[VLS_MAXMANA];h->mana=z; + if (z>h->vlastnosti[VLS_MAXMANA]) {z=h->vlastnosti[VLS_MAXMANA];h->mana=z;} z=h->vlastnosti[VLS_VPREG]*gtime;z+=h->kondice; - if (z>h->vlastnosti[VLS_KONDIC]) z=h->vlastnosti[VLS_KONDIC];h->kondice=z; + if (z>h->vlastnosti[VLS_KONDIC]) {z=h->vlastnosti[VLS_KONDIC];h->kondice=z;} } bott_draw(0); } @@ -1208,7 +1208,7 @@ void do_dialog() case 128:add_desc(Get_string());break; case 129:show_emote(Get_string());break; case 130:save_name(Get_short());break; - case 131:iff=!iff; + case 131:iff=!iff;break; case 132:load_name(Get_short());break; case 133:nahodne(0,0,Get_short());break; case 134:p1=Get_short();p2=Get_short();nahodne(VLS_SMAGIE,p1,p2);break; @@ -1257,7 +1257,7 @@ void do_dialog() case 172:code_page=Get_short();break; case 173:break; //ALT_SENTENCE case 174:iff=join_character(Get_short());break; - case 189:dead_players=1; + case 189:dead_players=1;break; case 175:echo(Get_string()); p1=Get_short(); if (dlg_ask_who()) if (p1) goto_paragraph(p1); else iff=1; diff --git a/game/enemy.c b/game/enemy.c index f6fea34..ee3ee85 100644 --- a/game/enemy.c +++ b/game/enemy.c @@ -420,8 +420,8 @@ int mob_pocet_vychodu(int sector,int dir) sector<<=2; return ((map_sides[sector+dir].flags & SD_MONST_IMPS)==0)+ - ((map_sides[sector+(dir+1 & 3)].flags & SD_MONST_IMPS)==0)+ - ((map_sides[sector+(dir-1 & 3)].flags & SD_MONST_IMPS)==0); + ((map_sides[sector+((dir+1) & 3)].flags & SD_MONST_IMPS)==0)+ + ((map_sides[sector+((dir-1) & 3)].flags & SD_MONST_IMPS)==0); } //retval: 0 - sector is free @@ -638,7 +638,7 @@ void stop_mob(TMOB *p) { if (miri_middle(q)) { - p->dir=p->dir+1 & 3; + p->dir=(p->dir+1) & 3; stop_mob(q); } } @@ -746,7 +746,7 @@ char return_home(TMOB *p,int *smer) int i; i=p->dir; - if (!mob_check_next_sector(p->sector,i+1&3,p->stay_strategy & MOB_BIG,0) || !mob_check_next_sector(p->sector,i+3&3,p->stay_strategy & MOB_BIG,0)) return 1; + if (!mob_check_next_sector(p->sector,(i+1)&3,p->stay_strategy & MOB_BIG,0) || !mob_check_next_sector(p->sector,(i+3)&3,p->stay_strategy & MOB_BIG,0)) return 1; if (p->sector==p->home_pos) return 1; najdi_cestu(p->sector,p->home_pos,SD_MONST_IMPS,&path,(p->stay_strategy & MOB_BIG)?1:2); if (path==NULL) @@ -849,7 +849,7 @@ void rozhodni_o_smeru(TMOB *p) } if (dir==-1) { - dir=p->dir;p->dir=p->dir+2&3; + dir=p->dir;p->dir=(p->dir+2)&3; stop_mob(p); p->walk_data=rnd(32)+223; if (vdir!=-1)p->dir=vdir; @@ -862,7 +862,7 @@ void rozhodni_o_smeru(TMOB *p) stop_mob(p); p->walk_data=oldwalk; } - else if ((p->dir-dir &0x3)==2 && (p->headx!=p->locx || p->heady!=p->locy)) + else if (((p->dir-dir) &0x3)==2 && (p->headx!=p->locx || p->heady!=p->locy)) { stop_mob(p); p->walk_data=0; @@ -1780,8 +1780,8 @@ void sirit_zvuk(word start) mob=mob_map[d]-MOB_START; if (mob>=0) { - reakce_na_hluk(mob,i+2&3); - if ((mob=mobs[mob].next-MOB_START)>=0) reakce_na_hluk(mob,i+2&3); + reakce_na_hluk(mob,(i+2)&3); + if ((mob=mobs[mob].next-MOB_START)>=0) reakce_na_hluk(mob,(i+2)&3); } } } @@ -1920,7 +1920,7 @@ char akce_moba_zac(TMOB *m) {stop_all_mobs_on_sector(m->sector);smeruj_moba(m,0);} else stop_mob(m); viewsector=sect; - viewdir=m->dir+2 &3; + viewdir=(m->dir+2) &3; m->csektor=sect; if ((m->vlajky & MOB_CASTING)&& rnd(100)<=(unsigned int)m->vlastnosti[VLS_SMAGIE]) m->mode=MBA_SPELL;else m->mode=MBA_ATTACK; bott_draw(1); @@ -1961,7 +1961,7 @@ char akce_moba_zac(TMOB *m) m->mode=MBA_ATTACK; smeruj_moba(m,0); viewsector=h->sektor; - viewdir=m->dir+2 & 3; + viewdir=(m->dir+2) & 3; return 0; } else diff --git a/game/engine1.c b/game/engine1.c index e6a1cec..739dfbb 100644 --- a/game/engine1.c +++ b/game/engine1.c @@ -372,8 +372,10 @@ void create_tables(void) 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; - if (xl<0) xl=0;if (xr<0) xr=0; - if (xl>639) xl=639;if (xr>639) xr=639; + 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); @@ -405,8 +407,10 @@ void create_tables(void) } xl=xl*(y1-2)/points[0][1][0].y+MIDDLE_X; xr=xr*(y1-2)/points[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; + 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; diff --git a/game/gamesave.c b/game/gamesave.c index 3403332..afa0fd5 100644 --- a/game/gamesave.c +++ b/game/gamesave.c @@ -526,7 +526,7 @@ _inline unsigned char rotate(unsigned char c) int pack_status_file(FILE *f,const char *status_name) { char rcheck=0; - uint32_t fsz; + int32_t fsz; char *buffer,*c; unsigned char name_len; diff --git a/game/globals.h b/game/globals.h index b0506c9..4a6bc88 100644 --- a/game/globals.h +++ b/game/globals.h @@ -263,10 +263,10 @@ static __inline int rangrnd(int a, int b) {return rnd(b-a+1)+a;} #define MAX_HLAD(x) (((x)->vlastnosti[VLS_MAXHIT]/2+2*24)*HODINA) #define MAX_ZIZEN(x) (((x)->vlastnosti[VLS_MAXHIT]/3+24)*HODINA) -#define concat(c,s1,s2) \ - c=alloca(strlen(s1)+strlen(s2)+1);\ - strcpy(c,s1);\ - strcat(c,s2) + + +#define concat(c,s1,s2) c=strcat(strcpy((char *)alloca(strlen(s1)+strlen(s2)+1),s1),s2) +#define concat_r(c,s1,s2) strcat(strcpy((char *)alloca(strlen(s1)+strlen(s2)+1),s1),s2) #define get_ap(vls) (((vls[VLS_POHYB])>0 && (vls[VLS_POHYB])<15)?1:(vls[VLS_POHYB])/15) @@ -277,7 +277,7 @@ static __inline int rangrnd(int a, int b) {return rnd(b-a+1)+a;} //typy sektoru -#define ISTELEPORT(c) ((c)==S_TELEPORT || (c)>=S_USERTELEPORT && (c)<=S_USERTELEPORT_END) +#define ISTELEPORT(c) ((c)==S_TELEPORT || ((c)>=S_USERTELEPORT && (c)<=S_USERTELEPORT_END)) #define ISTELEPORTSECT(sect) ISTELEPORT(map_sectors[sect].sector_type) #undef S_NORMAL diff --git a/game/globmap.c b/game/globmap.c index 24729c4..7a6b0ae 100644 --- a/game/globmap.c +++ b/game/globmap.c @@ -360,7 +360,8 @@ static void preskoc_prikaz(void) case EOF: if (uroven!=0)ex_error(OD_OUT);return;break; case '{': if (last==OD_CRIT || last==OD_NEWLINE) uroven++;break; case '}': if (last==OD_NEWLINE) uroven--; if (uroven<0) ex_error(OD_IN); - else if (uroven==0)return;break; + else if (uroven==0)return; + break; } if (ODD!=0) ending=0; } @@ -569,8 +570,13 @@ void global_map_point(EVENT_MSG *msg,void **_) } if (ms->event_type & 0x2 && ms->y>SCREEN_OFFLINE && ms->y<378) { - if (last_index && index_tab[last_index].defined) if (load_index_map(last_index)) return; - else;else return; + if (last_index && index_tab[last_index].defined) { + if (load_index_map(last_index)) { + return; + } + } else { + return; + } unwire_proc(); wire_proc(); msg->msg=-1; diff --git a/game/interfac.c b/game/interfac.c index 4d72243..93a59bf 100644 --- a/game/interfac.c +++ b/game/interfac.c @@ -351,6 +351,9 @@ void type_text(EVENT_MSG *msg,void **data) { case 8:if (index) index--; text[index]='_';text[index+1]=0;break; case 13:text[index]=0;strcpy(source,text); + send_message(E_DONE,E_MOUSE,type_text); + send_message(E_DONE,E_KEYBOARD,type_text); + break; case 27:send_message(E_DONE,E_MOUSE,type_text); send_message(E_DONE,E_KEYBOARD,type_text); return; @@ -441,6 +444,8 @@ void type_text_v2(va_list args) break; case 13:strcpy(text_buffer,text); ok=1; + wait_loop=0; + break; case 27:wait_loop=0; break; case 0:switch(znak>>8) @@ -1610,8 +1615,13 @@ void show_jrc_logo(char *filename) palw[i]=b | (r<<11) | (g<<6); } } - if (!bnk) wait_retrace();put_picture(xp,yp,pcx); - if (bnk) {wait_retrace();showview(xp,yp,pcxw[0],pcxw[1]);} + if (!bnk) + wait_retrace(); + put_picture(xp, yp, pcx); + if (bnk) { + wait_retrace(); + showview(xp, yp, pcxw[0], pcxw[1]); + } ccc=cdiff; mix_back_sound(0); } diff --git a/game/inv.c b/game/inv.c index e9fcde8..e801bf8 100644 --- a/game/inv.c +++ b/game/inv.c @@ -627,7 +627,8 @@ static int get_top_of_next(int sect,int id) //vraci souradnici predmetu na nasle sect=map_sectors[sect].step_next[viewdir]; if (sect==0) return 0; id=3-id; - idd=id+viewdir & 3;sect<<=2; + idd=(id+viewdir) & 3; + sect<<=2; cnt=count_items_visible(map_items[sect+idd])-1; if (cnt<0) cnt=0; return get_item_top(0,1,possx[id],possy[id],NULL,cnt); @@ -2260,10 +2261,11 @@ void build_fly_map() if (fly_count>fly_map_size || !counter) { free(fly_map);fly_map=NewArr(LETICI_VEC,fly_count); - if (!counter) + if (!counter) { SEND_LOG("(FLY) Fly_map was reduced - capacity: %d flies in game / was: %d",fly_count,fly_map_size); - else + } else { SEND_LOG("(FLY) Fly_map was expanded - capacity: %d flies in game / was: %d",fly_count,fly_map_size); + } counter=1000; fly_map_size=fly_count; } @@ -2676,106 +2678,99 @@ static void redraw_keepers_items() showview(BUYBOX_X,BUYBOX_Y,w[0],w[1]); } -char shop_keeper_click(int id, int xa, int ya,int xr,int yr) - { - id;xa;ya; - if (picked_item==NULL) - { - int i,j; - xr=(xa-BUYBOX_X-SHP_ICPLCX); - yr=(ya-BUYBOX_Y-SHP_ICPLCY); - if (xr<0 || yr<0) return 0; - xr/=SHP_ICSIZX; - yr/=SHP_ICSIZY; - i=yr*4+xr; - if (i<8 && i>=0 && (j=shp_item_map[i])!=0) - { - picked_item=NewArr(short,2); - picked_item[0]=shp_item_map[i]; - picked_item[1]=0; - shp_item_map[i]=0; - cur_owner=-1; - schovej_mysku(); - pick_set_cursor(); - redraw_keepers_items(); - ukaz_mysku(); - update_mysky(); - if ((get_control_key_state()) && (game_extras & EX_FAST_TRADE) && get_sell_price(*picked_item)<=money) - { - play_sample_at_channel(H_SND_OBCHOD,1,100); - money-=get_sell_price(*picked_item); - sell_item(*picked_item); - if (put_item_to_inv(human_selected,picked_item)) - { - picked_item=NULL; - pick_set_cursor(); - } - rebuild_keepers_items(); - cur_owner=picked_item!=NULL; - redraw_shop(); - } - return 1; +char shop_keeper_click(int id, int xa, int ya, int xr, int yr) { + id; + xa; + ya; + if (picked_item == NULL) { + int i, j; + xr = (xa - BUYBOX_X - SHP_ICPLCX); + yr = (ya - BUYBOX_Y - SHP_ICPLCY); + if (xr < 0 || yr < 0) + return 0; + xr /= SHP_ICSIZX; + yr /= SHP_ICSIZY; + i = yr * 4 + xr; + if (i < 8 && i >= 0 && (j = shp_item_map[i]) != 0) { + picked_item = NewArr(short, 2); + picked_item[0] = shp_item_map[i]; + picked_item[1] = 0; + shp_item_map[i] = 0; + cur_owner = -1; + schovej_mysku(); + pick_set_cursor(); + redraw_keepers_items(); + ukaz_mysku(); + update_mysky(); + if ((get_control_key_state()) && (game_extras & EX_FAST_TRADE) + && get_sell_price(*picked_item) <= money) { + play_sample_at_channel(H_SND_OBCHOD, 1, 100); + money -= get_sell_price(*picked_item); + sell_item(*picked_item); + if (put_item_to_inv(human_selected, picked_item)) { + picked_item = NULL; + pick_set_cursor(); + } + rebuild_keepers_items(); + cur_owner = picked_item != NULL; + redraw_shop(); + } + return 1; } - } - else - if (cur_owner==-1) - { + } else if (cur_owner == -1) { free(picked_item); - picked_item=NULL; + picked_item = NULL; rebuild_keepers_items(); schovej_mysku(); pick_set_cursor(); redraw_keepers_items(); ukaz_mysku(); update_mysky(); - cur_owner=0; + cur_owner = 0; return 1; - } - if (cur_owner!=-1 && picked_item!=NULL) - { - int price,z; + } + if (cur_owner != -1 && picked_item != NULL) { + int price, z; char c[200]; mouse_set_cursor(H_MS_DEFAULT); - if (picked_item[1]!=0) - { - message(1,0,0,"",texty[100],texty[80]); - wire_shop(); - } - else - { - price=make_offer(z=picked_item[0]); - if (!price) - { - sprintf(c,texty[103],glob_items[z-1].jmeno); - message(1,0,0,"",c,texty[80]); - wire_shop(); - } - else - { - int p;TPRODUCT *pp; + if (picked_item[1] != 0) { + message(1, 0, 0, "", texty[100], texty[80]); + wire_shop(); + } else { + price = make_offer(z = picked_item[0]); + if (!price) { + sprintf(c, texty[103], glob_items[z - 1].jmeno); + message(1, 0, 0, "", c, texty[80]); + wire_shop(); + } else { + int p; + TPRODUCT *pp; - pp=find_sell_product(z); - sprintf(c,texty[102],price); - p=message(3,0,1,texty[118],c,texty[77],texty[230],texty[78]); - if (p==2) price=-1; - if (p==1) price=smlouvat(price,pp->cena,pp->pocet,money,0); - if (price>=0) - { - play_sample_at_channel(H_SND_OBCHOD,1,100); - buy_item(z); - free(picked_item);picked_item=NULL; - money+=price; - rebuild_keepers_items(); - } - wire_shop(); - } - } + pp = find_sell_product(z); + sprintf(c, texty[102], price); + p = message(3, 0, 1, texty[118], c, texty[77], texty[230], + texty[78]); + if (p == 2) + price = -1; + if (p == 1) + price = smlouvat(price, pp->cena, pp->pocet, money, 0); + if (price >= 0) { + play_sample_at_channel(H_SND_OBCHOD, 1, 100); + buy_item(z); + free(picked_item); + picked_item = NULL; + money += price; + rebuild_keepers_items(); + } + wire_shop(); + } + } pick_set_cursor(); update_mysky(); return 1; - } - return 0; - } + } + return 0; +} char shop_bag_click(int id,int xa,int ya,int xr,int yr) diff --git a/game/kouzla.c b/game/kouzla.c index 47298b7..f662ca0 100644 --- a/game/kouzla.c +++ b/game/kouzla.c @@ -104,7 +104,12 @@ #define FLG_SCORE 0x80000 //zapnute ukazovani score nad potvorama. #define FLG_HALUCINACE 0x100000 // zapne halucinaci -#define GET_WORD(c) *(word *)c;c+=2 +static inline word _impl_get_word(unsigned char **c) { + word r = (*c)[0] + 256* (*c)[1]; + c+=2; + return r; +} +#define GET_WORD(c) _impl_get_word(&c) #define MAX_SPELLS 500 @@ -367,8 +372,8 @@ static void spell_vzplanuti2(THE_TIMER *tt) if (map_sides[(ss<<2)+du].flags & SD_PLAY_IMPS) return; ss1=ss2=ss=map_sectors[ss].step_next[du]; if (ss==0) return; - dp=du+1&3; - dl=du+3&3; + dp=(du+1)&3; + dl=(du+3)&3; do { if (ss1!=0) @@ -1090,7 +1095,7 @@ static void spell_summon(int cil) int i; stdir=rnd(4); - for(i=0;i<4;i++,stdir=stdir+1&3) + for(i=0;i<4;i++,stdir=(stdir+1)&3) if (!mob_check_next_sector(sector,stdir,mobs[slc].stay_strategy,0)) break; if (i==4) { @@ -1100,7 +1105,7 @@ static void spell_summon(int cil) sector=map_sectors[sector].step_next[stdir]; } mobs[slc].sector=sector; - if (cil>0) mobs[slc].dir=postavy[cil-1].direction+2&3; + if (cil>0) mobs[slc].dir=(postavy[cil-1].direction+2)&3; if (cil<0) mobs[slc].dir=mobs[-cil-1].dir; refresh_mob_map(); } @@ -1273,7 +1278,8 @@ void spell_special(int num,TKOUZLO *spl,int spc) case SP_PRIPOJENIA:spell_pripojenia(spl->owner);break; case SP_CHVENI:chveni(100);break; case SP_DEFAULT_EFFEKT: - if (spl->cil>0)display_spell_in_icone(H_SPELLDEF,1<<(spl->cil-1));break; + if (spl->cil>0) display_spell_in_icone(H_SPELLDEF,1<<(spl->cil-1)); + break; case SP_TRUE_SEEING: true_seeing=1;_flag_map[num]|=FLG_TRUESEEING;break; case SP_SCORE:show_lives=1;_flag_map[num]|=FLG_SCORE;break; case SP_HALUCINACE:set_halucination=1;_flag_map[num]|=FLG_HALUCINACE; @@ -1281,7 +1287,7 @@ void spell_special(int num,TKOUZLO *spl,int spc) break; case SP_TELEPORT:if (hod_na_uspech(spl->cil,spl)) spell_teleport(spl->cil,spl->owner,spl->teleport_target);break; case SP_PHASEDOOR:if (hod_na_uspech(spl->cil,spl)) spell_teleport(spl->cil,spl->owner,-1);break; - case SP_SUMMON: spell_summon(spl->cil); + case SP_SUMMON: spell_summon(spl->cil); break; case SP_HLUBINA1:if (hlubina_level==0) hlubina_level=1;_flag_map[num]|=FLG_HLUBINA1; break; case SP_HLUBINA2:hlubina_level=2;_flag_map[num]|=FLG_HLUBINA2; @@ -1413,66 +1419,214 @@ void call_spell(int i) start = c; c+=p->start; twins=0; - do - switch (twins=twins==3?0:twins,*c++) - { - case S_zivel:p->pc=GET_WORD(c); - if (p->owner>=0 && !GlobEvent(MAGLOB_ONFIREMAGIC+p->pc,postavy[p->owner].sektor,postavy[p->owner].direction)) - { - spell_end(i,p->cil,p->owner); - return; - } - break; - case S_hpnorm_min:parm1=GET_WORD(c);twins|=1;if (twins==3) spell_hit(p->cil,parm1,parm2,p->owner);break; - case S_hpnorm_max:parm2=GET_WORD(c);twins|=2;if (twins==3) spell_hit(p->cil,parm1,parm2,p->owner);break; - case S_hpzivl_min:parm1=GET_WORD(c);twins|=1;if (twins==3) spell_hit_zivel(p->cil,parm1,parm2,p->owner,p->pc);break; - case S_hpzivl_max:parm2=GET_WORD(c);twins|=2;if (twins==3) spell_hit_zivel(p->cil,parm1,parm2,p->owner,p->pc);break; - case S_vlastnost:parm1=GET_WORD(c);twins|=1; - if (twins==3) if (hod_na_uspech(p->cil,p)) zmen_vlastnost(i,p->cil,parm1,parm2);break; - case S_vls_kolik:parm2=GET_WORD(c);twins|=2; - if (twins==3) if (hod_na_uspech(p->cil,p)) zmen_vlastnost(i,p->cil,parm1,parm2);break; - case S_trvani:p->delay=GET_WORD(c);p->wait=0;ext=1;break; - case S_throw_item:z=GET_WORD(c);spell_throw(p->cil,z);break; - case S_create_item:z=GET_WORD(c);spell_create(p->cil,z);break; - case S_create_weapon:z=GET_WORD(c);spell_create_weapon(p->cil,z);break; - case S_animace:if (p->owner>=0 && !p->traceon)spell_anim((char *)c);c=(unsigned char *)strchr((char *)c,0);c++;break; - case S_zvuk:if (p->owner>=0 && !p->traceon)spell_sound((char *)c);c=(unsigned char *)strchr((char *)c,0);c++;break; - case S_wait:p->wait=GET_WORD(c);if (p->owner>=0) ext=1;break; - case 0xff:spell_end(i,p->cil,p->owner);return; - case S_pvls:parm2=GET_WORD(c);twins|=2; - if (twins==3) if (hod_na_uspech(p->cil,p)) zmen_vlastnost_percent(i,p->cil,parm1,parm2);break; - case S_set:parm2=GET_WORD(c);if (hod_na_uspech(p->cil,p)) set_flag(i,p->cil,parm2,1);break; - case S_reset:parm2=GET_WORD(c);if (hod_na_uspech(p->cil,p)) set_flag(i,p->cil,parm2,0);break; - case S_special:parm2=GET_WORD(c);spell_special(i,p,parm2);break; - case S_drain_min:parm1=GET_WORD(c);twins|=1;if (twins==3) spell_drain(p,p->cil,parm1,parm2);break; - case S_drain_max:parm2=GET_WORD(c);twins|=2;if (twins==3) spell_drain(p,p->cil,parm1,parm2);break; - case S_rand_min:parm1=GET_WORD(c);twins|=1;if (twins==3) calc_rand_value(parm1,parm2);break; - case S_rand_max:parm2=GET_WORD(c);twins|=2;if (twins==3) calc_rand_value(parm1,parm2);break; - case S_mana:parm1=GET_WORD(c);set_kondice_mana(parm1,p,S_mana,0);break; - case S_kondice:parm1=GET_WORD(c);set_kondice_mana(parm1,p,S_kondice,1);break; - case S_mana_clip:parm1=GET_WORD(c);set_kondice_mana(parm1,p,S_mana,1);break; - case S_mana_steal:parm1=GET_WORD(c);spell_mana_steal(parm1,p->cil,p->owner);break; - case S_location_sector: parm1=GET_WORD(c); - TelepLocation.sector=parm1; - TelepLocation.loc_x=0; - TelepLocation.loc_y=0; - break; - case S_location_map: TelepLocation.map=(char *)c;c=(unsigned char *)strchr((char *)c,0);c++;break; - case S_location_dir: parm1=GET_WORD(c);TelepLocation.dir=parm1;break; - case S_location_x: TelepLocation.loc_x=GET_WORD(c);TelepLocation.map=0;break; - case S_location_y: TelepLocation.loc_y=GET_WORD(c);TelepLocation.map=0;break; - default: - { - char *d="Chyba v popisu kouzel: Program narazil na neznamou instrukci %d (%02X) pri zpracovani kouzla s cislem %d. Kouzlo bylo ukon�eno"; - char *c=alloca(strlen(d)+20); - sprintf(c,d,*(c-1),*(c-1),p->num); - bott_disp_text(c); - spell_end(i,p->cil,p->owner); - return; + do { + switch (twins = twins == 3 ? 0 : twins, *c++) { + case S_zivel: + p->pc = GET_WORD(c) + ; + if (p->owner >= 0 + && !GlobEvent(MAGLOB_ONFIREMAGIC + p->pc, + postavy[p->owner].sektor, + postavy[p->owner].direction)) { + spell_end(i, p->cil, p->owner); + return; + } + break; + case S_hpnorm_min: + parm1 = GET_WORD(c) + ; + twins |= 1; + if (twins == 3) + spell_hit(p->cil, parm1, parm2, p->owner); + break; + case S_hpnorm_max: + parm2 = GET_WORD(c) + ; + twins |= 2; + if (twins == 3) + spell_hit(p->cil, parm1, parm2, p->owner); + break; + case S_hpzivl_min: + parm1 = GET_WORD(c) + ; + twins |= 1; + if (twins == 3) + spell_hit_zivel(p->cil, parm1, parm2, p->owner, p->pc); + break; + case S_hpzivl_max: + parm2 = GET_WORD(c) + ; + twins |= 2; + if (twins == 3) + spell_hit_zivel(p->cil, parm1, parm2, p->owner, p->pc); + break; + case S_vlastnost: + parm1 = GET_WORD(c) + ; + twins |= 1; + if (twins == 3 && (hod_na_uspech(p->cil, p))) + zmen_vlastnost(i, p->cil, parm1, parm2); + break; + case S_vls_kolik: + parm2 = GET_WORD(c) + ; + twins |= 2; + if (twins == 3 && (hod_na_uspech(p->cil, p))) + zmen_vlastnost(i, p->cil, parm1, parm2); + break; + case S_trvani: + p->delay = GET_WORD(c) + ; + p->wait = 0; + ext = 1; + break; + case S_throw_item: + z = GET_WORD(c) + ; + spell_throw(p->cil, z); + break; + case S_create_item: + z = GET_WORD(c) + ; + spell_create(p->cil, z); + break; + case S_create_weapon: + z = GET_WORD(c) + ; + spell_create_weapon(p->cil, z); + break; + case S_animace: + if (p->owner >= 0 && !p->traceon) + spell_anim((char*) c); + c = (unsigned char*) strchr((char*) c, 0); + c++; + break; + case S_zvuk: + if (p->owner >= 0 && !p->traceon) + spell_sound((char*) c); + c = (unsigned char*) strchr((char*) c, 0); + c++; + break; + case S_wait: + p->wait = GET_WORD(c) + ; + if (p->owner >= 0) + ext = 1; + break; + case 0xff: + spell_end(i, p->cil, p->owner); + return; + case S_pvls: + parm2 = GET_WORD(c) + ; + twins |= 2; + if (twins == 3 && (hod_na_uspech(p->cil, p))) + zmen_vlastnost_percent(i, p->cil, parm1, parm2); + break; + case S_set: + parm2 = GET_WORD(c) + ; + if (hod_na_uspech(p->cil, p)) + set_flag(i, p->cil, parm2, 1); + break; + case S_reset: + parm2 = GET_WORD(c) + ; + if (hod_na_uspech(p->cil, p)) + set_flag(i, p->cil, parm2, 0); + break; + case S_special: + parm2 = GET_WORD(c) + ; + spell_special(i, p, parm2); + break; + case S_drain_min: + parm1 = GET_WORD(c) + ; + twins |= 1; + if (twins == 3) + spell_drain(p, p->cil, parm1, parm2); + break; + case S_drain_max: + parm2 = GET_WORD(c) + ; + twins |= 2; + if (twins == 3) + spell_drain(p, p->cil, parm1, parm2); + break; + case S_rand_min: + parm1 = GET_WORD(c) + ; + twins |= 1; + if (twins == 3) + calc_rand_value(parm1, parm2); + break; + case S_rand_max: + parm2 = GET_WORD(c) + ; + twins |= 2; + if (twins == 3) + calc_rand_value(parm1, parm2); + break; + case S_mana: + parm1 = GET_WORD(c) + ; + set_kondice_mana(parm1, p, S_mana, 0); + break; + case S_kondice: + parm1 = GET_WORD(c) + ; + set_kondice_mana(parm1, p, S_kondice, 1); + break; + case S_mana_clip: + parm1 = GET_WORD(c) + ; + set_kondice_mana(parm1, p, S_mana, 1); + break; + case S_mana_steal: + parm1 = GET_WORD(c) + ; + spell_mana_steal(parm1, p->cil, p->owner); + break; + case S_location_sector: + parm1 = GET_WORD(c) + ; + TelepLocation.sector = parm1; + TelepLocation.loc_x = 0; + TelepLocation.loc_y = 0; + break; + case S_location_map: + TelepLocation.map = (char*) c; + c = (unsigned char*) strchr((char*) c, 0); + c++; + break; + case S_location_dir: + parm1 = GET_WORD(c) + ; + TelepLocation.dir = parm1; + break; + case S_location_x: + TelepLocation.loc_x = GET_WORD(c) + ; + TelepLocation.map = 0; + break; + case S_location_y: + TelepLocation.loc_y = GET_WORD(c) + ; + TelepLocation.map = 0; + break; + default: { + char *d = + "Chyba v popisu kouzel: Program narazil na neznamou instrukci %d (%02X) pri zpracovani kouzla s cislem %d. Kouzlo bylo ukon�eno"; + char *c = alloca(strlen(d) + 20); + sprintf(c, d, *(c - 1), *(c - 1), p->num); + bott_disp_text(c); + spell_end(i, p->cil, p->owner); + return; } - - } + } + } while(!ext); p->start=c-start; } diff --git a/game/realgame.c b/game/realgame.c index eb6200f..c8199a5 100644 --- a/game/realgame.c +++ b/game/realgame.c @@ -660,8 +660,8 @@ void calc_fly() { TFLY *q,*z; - q=duplic_fly(p);q->smer=p->smer+1&3; - z=duplic_fly(p);z->smer=p->smer-1&3; + q=duplic_fly(p);q->smer=(p->smer+1)&3; + z=duplic_fly(p);z->smer=(p->smer-1)&3; add_fly(q); add_fly(z); } @@ -1055,82 +1055,93 @@ static void akce_voda(THUMAN *h,int mode) bott_draw(0); } -void check_players_place(char mode) - { - int i; - THUMAN *h=postavy; - char vir_eff=0; - static char vir_zavora=0; - char levitat; +void check_players_place(char mode) { + int i; + THUMAN *h = postavy; + char vir_eff = 0; + static char vir_zavora = 0; + char levitat; - for(i=0;iused && h->lives) - { - int sect; - int u1; + for (i = 0; i < POCET_POSTAV; i++, h++) + if (h->used && h->lives) { + int sect; + int u1; - levitat=(h->vlastnosti[VLS_KOUZLA] & SPL_LEVITATION)!=0; - sect=h->sektor; - if (sect>=mapsize) continue; - switch (map_sectors[sect].sector_type) - { - case S_ACID:if (!levitat) { - if (h->lives>3) {h->lives-=3;bott_draw(0);} - } else - player_hit(h,3+7*mode,0); - break; - case S_VIR: - if (!levitat) { - if (mode==0 && vir_zavora==0) - { - int i,smer; - vir_zavora=1;pass_zavora=0; - smer=rnd(100)<50?-1:1; - if (vir_eff==0) - for(i=0;i<8;i++) turn_zoom(smer); - vir_eff=1; - vir_zavora=0; - cancel_pass=1; - } - } else - break; - case S_LAVA: if (!levitat) - { - u1=(h->lives); - player_hit(h,u1,0); - bott_draw(0); - } - else - { - if (h->lives>3) {h->lives-=3;bott_draw(0);} - else player_hit(h,3+7*mode,0); - } + levitat = (h->vlastnosti[VLS_KOUZLA] & SPL_LEVITATION) != 0; + sect = h->sektor; + if (sect >= mapsize) + continue; + switch (map_sectors[sect].sector_type) { + case S_ACID: + if (!levitat) { + if (h->lives > 3) { + h->lives -= 3; + bott_draw(0); + } else { + player_hit(h, 3 + 7 * mode, 0); + } + } + break; + case S_VIR: + if (!levitat) { + if (mode == 0 && vir_zavora == 0) { + int i, smer; + vir_zavora = 1; + pass_zavora = 0; + smer = rnd(100) < 50 ? -1 : 1; + if (vir_eff == 0) + for (i = 0; i < 8; i++) + turn_zoom(smer); + vir_eff = 1; + vir_zavora = 0; + cancel_pass = 1; + } + } + break; + case S_LAVA: + if (!levitat) { + u1 = (h->lives); + player_hit(h, u1, 0); + bott_draw(0); + } else { + if (h->lives > 3) { + h->lives -= 3; + bott_draw(0); + } else + player_hit(h, 3 + 7 * mode, 0); + } - - break; - case S_SSMRT: - u1=(h->lives); - player_hit(h,u1,0); - bott_draw(0); - break; - case S_VODA: - if (!levitat) { - akce_voda(h,mode);break; - } - case S_DIRA:if (!pass_zavora) postavy_propadnout(sect);break; - case S_LODKA:if (lodka!=1 && mode) - { - set_backgrnd_mode(1);lodka=1; - } - break; + break; + case S_SSMRT: + u1 = (h->lives); + player_hit(h, u1, 0); + bott_draw(0); + break; + case S_VODA: + if (!levitat) { + akce_voda(h, mode); + } + break; + case S_DIRA: + if (!pass_zavora) + postavy_propadnout(sect); + break; + case S_LODKA: + if (lodka != 1 && mode) { + set_backgrnd_mode(1); + lodka = 1; + } + break; + } + if (mglob.map_effector == ME_PVODA + && ~map_coord[h->sektor].flags & MC_SAFEPLACE) + akce_voda(h, mode); + if (map_sectors[sect].sector_type != S_LODKA && lodka) { + set_backgrnd_mode(0); + lodka = 0; + } } - if (mglob.map_effector==ME_PVODA && ~map_coord[h->sektor].flags & MC_SAFEPLACE) akce_voda(h,mode); - if (map_sectors[sect].sector_type!=S_LODKA && lodka) - { - set_backgrnd_mode(0);lodka=0; - } - } - } +} static void move_lodka(int oldsect,int newsect) { @@ -1305,8 +1316,7 @@ void build_player_map() //je nutne volat po presunu postav char chod_s_postavama(char sekupit) { - int i,/*j,*/lastsec=-1; - char marks[6]; + int i; char gatt=0; signed char group_nums[7]; @@ -1324,55 +1334,14 @@ char chod_s_postavama(char sekupit) { if (postavy[i].groupnum==cur_group) { - lastsec=postavy[i].sektor; postavy[i].sektor=viewsector; postavy[i].direction=viewdir; postavy[i].utek=1; postavy[i].kondice-=weigth_defect(postavy+i); if (postavy[i].kondice<0) postavy[i].kondice=0; - marks[i]=1; group_nums[cur_group]=1; } - else - if (sekupit && lastsec==viewsector) marks[i]=postavy[i].sektor==viewsector; - else marks[i]=0; } - //map_coord[viewsector].flags|=MC_PLAYER; -/* if (formace && sekupit) - { - int gr=2; - for(;;) - { - THUMAN *h1,*h2; - int dir; - char attach=0; - for(i=0;h1=postavy+group_sort[i],iused && h1->lives && !marks[group_sort[i]]) - { - int sc; - int ss=(sc=h1->sektor)<<2; - for(dir=0;dir<4;dir++) if (map_sectors[sc].step_next[dir]==lastsec && ~map_sides[ss+dir].flags & SD_PLAY_IMPS) break; - if (dir!=4) - { - for(j=0,h2=postavy;jused && h2->lives && h2->groupnum==h1->groupnum) - { - h2->sektor=lastsec; - h2->direction=dir; - h2->utek=1; - marks[j]=1; - } - lastsec=sc; - attach=1; - gatt=1; - group_nums[h1->groupnum]=gr++; - } - } - if (!attach) break; - } - for(i=1;i<7;i++) if (group_nums[i]==-1) group_nums[i]=gr++; - for(i=0;izmeny, m1->vlastnosti, 1, fl->damage, fl->hit_bonus)); - m1->dir = fl->smer + 2 & 3; + m1->dir = (fl->smer + 2) & 3; } else { mob_hit(m1, vypocet_zasahu(it->zmeny, m1->vlastnosti, 2, fl->damage, @@ -2120,8 +2122,8 @@ char zasah_veci(int sector,TFLY *fl) mob_hit(m2, vypocet_zasahu(it->zmeny, m1->vlastnosti, 2, fl->damage, fl->hit_bonus)); - m1->dir = fl->smer + 2 & 3; - m2->dir = fl->smer + 2 & 3; + m1->dir = (fl->smer + 2) & 3; + m2->dir = (fl->smer + 2) & 3; } return 1; } @@ -2180,7 +2182,7 @@ char zasah_veci(int sector,TFLY *fl) for(i=0;iinv[i]==0) { m1->inv[i]=it-glob_items+1;break;} if (i==MOBS_INV) fl->flags &=FLY_DESTROY; } - m1->dir=fl->smer+2&3; + m1->dir=(fl->smer+2)&3; return 1; } else if (map_coord[sector].flags & MC_PLAYER && (fl->owner<=0 || pocet_zivych(sector)>2)) diff --git a/game/specproc.c b/game/specproc.c index 8e1a092..d21fe35 100644 --- a/game/specproc.c +++ b/game/specproc.c @@ -488,13 +488,13 @@ static char mob_strelec(int event_type,TMOB *m) { int s=m->sector; m->user_data&=~128; - i=m->dir+2&3; + i=(m->dir+2)&3; while (s && !(map_coord[s].flags & MC_PLAYER)) if (map_sides[(s<<2)+i].flags & SD_MONST_IMPS) s=0;else s=map_sectors[s].step_next[i]; if (s) m->dir=i;else return 1; } return 0; //strilej } - i=i+2&3; + i=(i+2)&3; if (mob_check_next_sector(m->sector,i,m->stay_strategy & MOB_BIG,0)) { int l=4,z,max=RAND_MAX; diff --git a/libs/basicobj.c b/libs/basicobj.c index 86709f3..180f69d 100644 --- a/libs/basicobj.c +++ b/libs/basicobj.c @@ -40,7 +40,7 @@ CTL3D *def_border(int btype,int color) highlight(&ctl,color); switch (btype) { - case 0:ctl.bsize=0; + case 0:ctl.bsize=0;break; case 1:ctl.light=color;ctl.shadow=color;ctl.bsize=1;break; case 2:ctl.bsize=2;ctl.ctldef=0;break; case 3:ctl.bsize=2;ctl.ctldef=3;break; @@ -782,8 +782,8 @@ void input_line_event(EVENT_MSG *msg,OBJREC *o) case 'M':if (cursor0) cursor--;break; case 'S':if (cursormaxvalue-p->minvalue; wsize=x2-x1; barsize=wsize*p->parview/valsize; - if (barsize>wsize) barsize=wsize;if (barsize<2) barsize=2; + if (barsize>wsize) barsize=wsize; + if (barsize<2) barsize=2; wsize-=barsize; curcolor=p->bgcolor; bar32(x1,y1,x2,y2); diff --git a/libs/bgraph2a.c b/libs/bgraph2a.c index 852aefc..63fe478 100644 --- a/libs/bgraph2a.c +++ b/libs/bgraph2a.c @@ -320,6 +320,9 @@ void put_picture(word x,word y,void *p) word xss=xs; word yss=ys; + if (x > DxGetResX() || y > DxGetResY()) return; + + if (x+xss>=DxGetResX()) xss=DxGetResX()-x; if (y+yss>=DxGetResY()) yss=DxGetResY()-y; @@ -387,6 +390,7 @@ void get_picture(word x,word y,word xs,word ys,void *p) word *data=p; word xss=xs; word yss=ys; + if (x > DxGetResX() || y > DxGetResY()) return; if (x+xss>=DxGetResX()) xss=DxGetResX()-x; if (y+yss>=DxGetResY()) yss=DxGetResY()-y; diff --git a/libs/memman.c b/libs/memman.c index 97e6c5a..adbb59b 100644 --- a/libs/memman.c +++ b/libs/memman.c @@ -275,7 +275,6 @@ void heap_error(size_t size) //heap system char repeat=0,did=0; THANDLE_DATA *lastblock=NULL; char *last_free=NULL; - int num; do { maxcounter=0; @@ -295,14 +294,13 @@ void heap_error(size_t size) //heap system if (last_free!=NULL) { d=(char *)h->blockdata-last_free; - if (dmaxcounter) { maxcounter=c; sh=h; did=1; - num=i*BK_MINOR_HANDLES+j; } } } diff --git a/libs/strlists.c b/libs/strlists.c index e85842f..e2742e1 100644 --- a/libs/strlists.c +++ b/libs/strlists.c @@ -259,6 +259,7 @@ void string_list_event(EVENT_MSG *msg,OBJREC *o) break; } } + break; case E_LOST_FOCUS:clicked=0; } } diff --git a/platform/sdl/sdl_context.cpp b/platform/sdl/sdl_context.cpp index ff7f13b..148cbc1 100644 --- a/platform/sdl/sdl_context.cpp +++ b/platform/sdl/sdl_context.cpp @@ -96,6 +96,7 @@ void SDLContext::init_screen(DisplayMode mode, const char *title) { } done = true; done.notify_all(); + SDL_ShowCursor(SDL_DISABLE); if (!err) event_loop(stp); _texture.reset(); _renderer.reset();