From: DeaDDooMER Date: Sat, 11 Mar 2017 15:45:33 +0000 (+0300) Subject: Fix load cfg files and textures X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=commitdiff_plain;h=e1395893ec7223a8a86c66cdc49e4a9fb48b15c2 Fix load cfg files and textures --- diff --git a/BUGS b/BUGS index ca7100b..29fcd09 100644 --- a/BUGS +++ b/BUGS @@ -33,4 +33,4 @@ + От больших грибов больно уж чорные тени. У тыкв тоже надо поправить. После удаления всех сохранений кнопки остаются на вид активными Даже в четвёртой альфе грибы генерировались в пещерах! Нужно вернуть! -Текстурпаки вроде как не работают ++ Текстурпаки вроде как не работают diff --git a/res/autoexec.cfg b/res/autoexec.cfg index b639c32..ba654bc 100644 --- a/res/autoexec.cfg +++ b/res/autoexec.cfg @@ -1,3 +1,6 @@ +;ЛОл + + ;Standard execute file for CaveCraft SET_RESOLUTION 176 208 TRUE BL_UPD 2 @@ -28,7 +31,6 @@ LOAD_MINIMAP_TEX TRUE MAX_PARTICLES 255 EXEC AUTO keyboard.cfg EXEC AUTO vkeyboard.cfg -EXEC AUTO textures.cfg EXEC AUTO items.cfg EXEC AUTO blocks.cfg EXEC AUTO crafts.cfg diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index e23b865..af345fd 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -53,7 +53,7 @@ var moon_phase:integer; toolus,toolind:integer; osadki_ani:integer; - sd,sav_fl:string; + sav_fl:string; global_light:integer; world_typ:integer; float:image; @@ -107,68 +107,70 @@ procedure maxfps; delay(del); end; -procedure cleartextures; - var - no:image; - ix,iy,iz:integer; - begin - bg[0]:=no; - bg[1]:=no; - float:=no; - compas:=no; - for ix:=0 to 7 do clock[ix]:=no; - - {for ix:=0 to maxBlockTex do - begin - tex[ix]:=no; - tex8[ix]:=no; - end; - for ix:=0 to maxItemTex do - begin - item[ix]:=no; - item8[ix]:=no; - end;} - for ix:=0 to 8 do back[ix]:=no; - - player.freeSkin; - - for ix:=0 to 34 do - gui[ix]:=no; - - for ix:=0 to 9 do tue[ix]:=no; - - for ix:=0 to 7 do osad[0,ix]:=no; - for ix:=0 to 7 do osad[1,ix]:=no; +procedure ClearTextures; + var + no : image; + ix, iy, iz : integer; + begin + bg[0] := no; + bg[1] := no; + float := no; + compas := no; + for ix := 0 to 7 do + clock[ix] := no; + + for ix := 0 to maxBlockTex do + begin + tex[ix] := no; + tex8[ix] := no; + end; + for ix := 0 to maxItemTex do + begin + item[ix] := no; + item8[ix] := no; + end; - for ix:=0 to 15 do light[ix]:=no; + for ix := 0 to 8 do + back[ix]:=no; - for ix:=0 to 7 do - begin - pr_1[ix]:=no; - pr_2[ix]:=no; - pr_3[ix]:=no; - pr_4[ix]:=no; - pr_5[ix]:=no; - end; - bubble:=no; + player.freeSkin; - for ix:=0 to 15 do - pr_boom[ix]:=no; + for ix := 0 to 34 do + gui[ix] := no; + for ix := 0 to 9 do + tue[ix] := no; + for ix := 0 to 7 do + osad[0, ix] := no; + for ix := 0 to 7 do + osad[1, ix] := no; - mob.freeSkin; + for ix := 0 to 15 do + light[ix] := no; + for ix := 0 to 7 do + begin + pr_1[ix] := no; + pr_2[ix] := no; + pr_3[ix] := no; + pr_4[ix] := no; + pr_5[ix] := no; + end; - sky:=no; + bubble := no; + for ix := 0 to 15 do + pr_boom[ix] := no; - sun:=no; - moon:=no; + mob.freeSkin; - sign_im:=no; + sky := no; + sun := no; + moon := no; + sign_im := no; - for ix:=0 to CONST_MAX_CURS do - LoadCurImg(no, ix); + for ix := 0 to CONST_MAX_CURS do + LoadCurImg(no, ix); - //resetVirtualKeyboard(-1); - end; + //resetVirtualKeyboard(-1); + end; procedure create_msg(s:string); var @@ -204,6 +206,8 @@ procedure loadtexture(path:string); for ix:=0 to 8 do back[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); end; + console.exec('textures.cfg', 'AUTO'); + player.loadSkin('char_ani.png', path); mob.loadSkin(path); @@ -1038,7 +1042,7 @@ procedure start_uu; rs:=openRecordStore('SD'); sd:=readRecordStoreEntry(rs,1); closeRecordStore(rs); - console.exec('autoexec.cfg', 'AUTO', true); + console.exec('autoexec.cfg', 'AUTO'); if sd='' then begin init_touch; @@ -1394,6 +1398,7 @@ procedure menu_tex; if m_cur=0 then begin if cur_name>0 then begin + debug("Select TexturePack @ /" + sd + "/cavecraft/texturepacks/" + names[cur_name]); tex_pack:=names[cur_name]; LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); @@ -1401,9 +1406,13 @@ procedure menu_tex; rs:=openRecordStore('TX'); t:=addRecordStoreEntry(rs,tex_pack); closeRecordStore(rs); + + LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); + loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/'); end; else begin + debug("Cancel Select TecturePack"); tex_pack:=''; loadtexture('/'); deleteRecordStore('TX'); diff --git a/src/console.pas b/src/console.pas index 49b9435..d239081 100644 --- a/src/console.pas +++ b/src/console.pas @@ -39,12 +39,13 @@ interface sd:string; + EOFstr, ENDstr:boolean; //max_particles:integer; - module procedure save_settings; procedure load_settings; procedure call_console; - procedure exec(s, search:string; acces:boolean); + procedure exec(s, search:string); procedure addToLog(str:string); implementation @@ -58,12 +59,10 @@ var lastCommand:string; parseStr:string; - EOFstr, ENDstr:boolean; stack: array [0..0] of integer; stack_pointer:integer; - autoexec_acces:boolean; regimg:image; procedure resetStack(size:integer); @@ -445,7 +444,7 @@ procedure exeCommand(str:string); com:=UpCase(nextWord); - if (cheats) or (autoexec_acces) or (gamemode=1) then + if (cheats) or (gamemode=1) then begin if com='TIME' then game_time:=decodeInt(nextWord); @@ -629,7 +628,7 @@ procedure exeCommand(str:string); if com='EXEC' then begin tmp:=nextWord; - exec(nextWord, tmp, autoexec_acces); + exec(nextWord, tmp); end; else if com='RESET_ITEMS' then @@ -741,7 +740,9 @@ procedure exeCommand(str:string); end; else if com='LOAD_TEX' then - regimg:=ld_tex(nextWord, '/'+sd+'/cavecraft/', ''); + begin + regimg:=ld_tex(nextWord, '/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/', ''); + end; else if com='RESET_TEX' then resetTmpImg; @@ -885,15 +886,12 @@ procedure call_console; forever; end; -procedure exec(s, search:string; acces:boolean); +procedure exec(s, search:string); var res:resource; str:string; - tmp_acces, tmpEOF:boolean; + tmpEOF : Boolean; begin - tmp_acces:=autoexec_acces; - autoexec_acces:=acces; - search:=UpCase(search); if search='LOCAL' then @@ -931,7 +929,6 @@ procedure exec(s, search:string; acces:boolean); else begin addToLog('Unknown load type "'+search+'", file "'+s+'" not executed!'); - autoexec_acces:=tmp_acces; exit; end; @@ -946,8 +943,9 @@ procedure exec(s, search:string; acces:boolean); else addToLog('Execute file "'+s+'" not found!'); + EOFstr := false; + ENDstr := false; CloseResource(res); - autoexec_acces:=tmp_acces; end; initialization diff --git a/src/func.mpsrc b/src/func.mpsrc index a80e3ec..5089d0c 100644 --- a/src/func.mpsrc +++ b/src/func.mpsrc @@ -20,18 +20,20 @@ function readstr:string; implementation uses canvas,imgcolor,jsr75i, vars, safeload, items,maps, items_store; - //Загрузка изображения из текстурпака, ели такого нет, то происходит загрузка из архива игры -function ld_tex(name,path,folder:string):image; - begin - if tex_pack<>'' then - begin - if file_exists(path+folder+name)=1 then - begin - ld_tex:=safely_load_image_fs(path+folder+name); - end; else ld_tex:=loadimage('/'+folder+name); - end; - if tex_pack='' then ld_tex:=loadimage('/'+folder+name); - end; +//Загрузка текстуры с автоматическим выбором источника +function ld_tex(name, path, folder : String) : Image; + var + n, p : String; + begin + n := folder + name; + + //Debug("ld_tex (tex_pack:" + tex_pack + ") : " + path + n); + + if file_exists(path + n) = 1 then + ld_tex := safely_load_image_fs(path + n); + else + ld_tex := loadimage('/' + n); + end; function readint:integer; var