X-Git-Url: https://deadsoftware.ru/gitweb?p=cavecraft.git;a=blobdiff_plain;f=src%2FCAVE.mpsrc;h=830a6abac54eaeb688b7640322757eff3c4e9781;hp=0d305849e358ef1108de30fb24a68376cf90e8e9;hb=4d7cf2ab1e10d9926d03afb5a3f883bcf5312469;hpb=9115be0a19d5716f33a2e2cba76f3447ce0f4c2f diff --git a/src/CAVE.mpsrc b/src/CAVE.mpsrc index 0d30584..830a6ab 100644 --- a/src/CAVE.mpsrc +++ b/src/CAVE.mpsrc @@ -1,6 +1,7 @@ program CAVE; uses + Items, sign, jsr75i, drop, @@ -10,7 +11,6 @@ uses memory, worldgen, canvas, - items, safeload, mobs, console, @@ -28,7 +28,8 @@ uses chest, inv, items_store, - video; + video, + Blocks; const version_map = 9; @@ -116,7 +117,7 @@ procedure ClearTextures; float := no; compas := no; for ix := 0 to 7 do - clock[ix] := no; + Vars.clock[ix] := no; for ix := 0 to maxBlockTex do begin @@ -187,7 +188,7 @@ procedure loadtexture(path:string); compas:=ld_tex('compass.png',path,'gui/'); im:=ld_tex('clock.png',path,'gui/'); for ix:=0 to 7 do - clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); + Vars.clock[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0); if load_back_tex then begin im:=ld_tex('back.png',path,''); @@ -1712,11 +1713,10 @@ function setBlock(invcur, x, y:integer):boolean; item:=inv.getItem(invcur); sum:=inv.getSum(invcur); block:=getMap(x, y); - sblock:=getItemInfo(item); + sblock := Items.GetData(item); - if getItemType(item)=ITEM_TYPE_BLOCK then - if inv.isNull(invcur)=false then - if getBlockSet(block)=true then + if (Items.GetType(item) = Items.block) and (Inv.IsNull(invcur) = false) then + if Blocks.IsOverlapped(block) then // if (coll_xy(x, y)=false) or (getBlockColl(item)=0) then begin if set_block_code(sblock, x, y)=false then @@ -1961,20 +1961,13 @@ procedure draw; for ix:=minx to maxx do for iy:=miny to maxy do begin - if ifosad then if (getBackMap(ix)>=iy) and (osadki=true) and getBlockTrans(getmap(ix,iy)) then - begin - if getBiomMap(ix)=0 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); - else - if getBiomMap(ix)=2 then drawimage(osad[1,osadki_ani],(ix*16)-camx,(iy*16)-camy); - else - if getBiomMap(ix)=3 then drawimage(osad[0,osadki_ani],(ix*16)-camx,(iy*16)-camy); - end; - if drw_back then - if getBlockTrans(getmap(ix,iy)) then - draw_back(ix,iy); - - if getBlockFore(getmap(ix,iy))=false then - draw_block(ix,iy); + if ifosad and osadki and (getBackMap(ix) >= iy) and Blocks.IsTransporent(getmap(ix, iy)) then begin + if getBiomMap(ix) = 0 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + else if getBiomMap(ix) = 2 then drawimage(osad[1, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + else if getBiomMap(ix) = 3 then drawimage(osad[0, osadki_ani], (ix * 16) - camx, (iy * 16) - camy) + end; + if drw_back and Blocks.IsTransporent(getmap(ix, iy)) then draw_back(ix, iy); + if Blocks.IsForeground(getmap(ix,iy)) = false then draw_block(ix,iy); end; {===================[drop]===================} Drop.Draw(camx, camy); @@ -1988,8 +1981,7 @@ procedure draw; for ix:=minx to maxx do for iy:=miny to maxy do begin - if getBlockFore(getmap(ix, iy)) then - draw_block(ix, iy); + if Blocks.IsForeground(getmap(ix, iy)) then draw_block(ix, iy); setcolor(0, 0, 0); if light_type = 1 then @@ -2036,7 +2028,7 @@ procedure draw; drawimage(gui[1],tmp_ax,0); for ix:=0 to 8 do begin - drawItem(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); + Items.Draw(inv.getItem(ix), inv.getSum(ix), (ix*16)+tmp_ax+ix*2+4, 1, true); end; drawimage(gui[17],(invslot*16)+tmp_ax+invslot*2+2,0); @@ -2177,14 +2169,14 @@ procedure usetools(invcur, x, y:integer); else if (block>0) then begin - if (getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) then + if (Items.GetType(item) = Items.tool) and (getBlockTool(block)=getToolType(item)) then toolus:=toolus+getToolSpeed(item); else toolus:=toolus+1; if toolus>=getBlockHP(block) then begin - if ((getItemType(item)=ITEM_TYPE_TOOL) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then + if ((Items.GetType(item) = Items.tool) and (getBlockTool(block)=getToolType(item)) and (getToolLvl(item)>=getBlockLvl(block))) or (getBlockLvl(block)<=0) then begin setMap(0, x, y); destroy_block_1(block, x, y); @@ -2197,7 +2189,7 @@ procedure usetools(invcur, x, y:integer); setMapInfo(0, x, y); end; - if getItemType(item)=ITEM_TYPE_TOOL then + if Items.GetType(item) = Items.tool then begin inv.setSum(inv.getSum(invcur)-1, invcur); inv.fixNull(invcur); @@ -2223,7 +2215,7 @@ function rt_useweap:boolean; h:=player.getH; item:=inv.getItem(invslot); - if getItemType(item)=1 then + if Items.GetType(item) = Items.tool then damg:=getToolDamg(item); else damg:=1; @@ -3008,12 +3000,288 @@ procedure draw_debug; drawImage(light[i], getWidth - 16, 16 * i); end; + function ItemToString(id : integer) : string; + var + name : string; + begin + if id = Items.none then name := 'none' + else if id = Items.dirt then name := 'dirt' + else if id = Items.grass then name := 'grass' + else if id = Items.stone then name := 'stone' + else if id = Items.oakWoodPlanks then name := 'oakWoodPlanks' + else if id = Items.cobblestone then name := 'cobblestone' + else if id = Items.bedrock then name := 'bedrock' + else if id = Items.sand then name := 'sand' + else if id = Items.gravel then name := 'gravel' + else if id = Items.oakWood then name := 'oakWood' + else if id = Items.obsidian then name := 'obsidian' + else if id = Items.bookshelf then name := 'bookshelf' + else if id = Items.mossStone then name := 'mossStone' + else if id = Items.blockOfIron then name := 'blockOfIron' + else if id = Items.blockOfGold then name := 'blockOfGold' + else if id = Items.blockOfDiamond then name := 'blockOfDiamond' + else if id = Items.goldOre then name := 'goldOre' + else if id = Items.ironOre then name := 'ironOre' + else if id = Items.coalOre then name := 'coalOre' + else if id = Items.diamondOre then name := 'diamondOre' + else if id = Items.redstoneOre then name := 'redstoneOre' + else if id = Items.oakLeaves then name := 'oakLeaves' + else if id = Items.redFlower then name := 'redFlower' + else if id = Items.yellowFlower then name := 'yellowFlower' + else if id = Items.redMooshroom then name := 'redMooshroom' + else if id = Items.brownMooshroom then name := 'brownMooshroom' + else if id = Items.torch then name := 'torch' + else if id = Items.tnt then name := 'tnt' + else if id = Items.chest then name := 'chest' + else if id = Items.craftingTable then name := 'craftingTable' + else if id = Items.cactus then name := 'cactus' + else if id = Items.glass then name := 'glass' + else if id = Items.wool1 then name := 'wool1' + else if id = Items.wool2 then name := 'wool2' + else if id = Items.wool3 then name := 'wool3' + else if id = Items.wool4 then name := 'wool4' + else if id = Items.wool5 then name := 'wool5' + else if id = Items.wool6 then name := 'wool6' + else if id = Items.wool7 then name := 'wool7' + else if id = Items.wool8 then name := 'wool8' + else if id = Items.wool9 then name := 'wool9' + else if id = Items.wool10 then name := 'wool10' + else if id = Items.wool11 then name := 'wool11' + else if id = Items.wool12 then name := 'wool12' + else if id = Items.wool13 then name := 'wool13' + else if id = Items.wool14 then name := 'wool14' + else if id = Items.wool15 then name := 'wool15' + else if id = Items.wool16 then name := 'wool16' + else if id = Items.snow then name := 'snow' + else if id = Items.ladder then name := 'ladder' + else if id = Items.water then name := 'water' + else if id = Items.lava then name := 'lava' + else if id = Items.oakSapling then name := 'oakSapling' + else if id = Items.sponge then name := 'sponge' + else if id = Items.lapisLazuliOre then name := 'lapisLazuliOre' + else if id = Items.lapisLazuliBlock then name := 'lapisLazuliBlock' + else if id = Items.sandstone then name := 'sandstone' + else if id = Items.tallGrass then name := 'tallGrass' + else if id = Items.deadBush then name := 'deadBush' + else if id = Items.cobweb then name := 'cobweb' + else if id = Items.bricks then name := 'bricks' + else if id = Items.snowBlock then name := 'snowBlock' + else if id = Items.ice then name := 'ice' + else if id = Items.snowLayer then name := 'snowLayer' + else if id = Items.clayBlock then name := 'clayBlock' + else if id = Items.sugarCane then name := 'sugarCane' + else if id = Items.pumpkin then name := 'pumpkin' + else if id = Items.jackLantern then name := 'jackLantern' + else if id = Items.stoneBricks then name := 'stoneBricks' + else if id = Items.mossyStoneBricks then name := 'mossyStoneBricks' + else if id = Items.crackedStoneBricks then name := 'crackedStoneBricks' + else if id = Items.chiseledStokeBricks then name := 'chiseledStokeBricks' + else if id = Items.ironBras then name := 'ironBras' + else if id = Items.melonBlock then name := 'melonBlock' + else if id = Items.mycelium then name := 'mycelium' + else if id = Items.backgroundOakWood then name := 'backgroundOakWood' + else if id = Items.spawner then name := 'spawner' + else if id = Items.bed1 then name := 'bed1' + else if id = Items.bed2 then name := 'bed2' + else if id = Items.openWoodenDoor1 then name := 'openWoodenDoor1' + else if id = Items.openWoodenDoor2 then name := 'openWoodenDoor2' + else if id = Items.closedWoodenDoor1 then name := 'closedWoodenDoor1' + else if id = Items.closedWoodenDoor2 then name := 'closedWoodenDoor2' + else if id = Items.birchWood then name := 'birchWood' + else if id = Items.backgroundBirchWood then name := 'backgroundBirchWood' + else if id = Items.spruceWood then name := 'spruceWood' + else if id = Items.backgroundSpruceWood then name := 'backgroundSpruceWood' + else if id = Items.spruceLeaves then name := 'spruceLeaves' + else if id = Items.redMushroomBlock1 then name := 'redMushroomBlock1' + else if id = Items.redMushroomBlock2 then name := 'redMushroomBlock2' + else if id = Items.brownMushroomBlock1 then name := 'brownMushroomBlock1' + else if id = Items.brownMushroomBlock2 then name := 'brownMushroomBlock2' + else if id = Items.oakFence then name := 'oakFence' + else if id = Items.backgroundOakFence then name := 'backgroundOakFence' + else if id = Items.backgroundOakWoodPlanks then name := 'backgroundOakWoodPlanks' + else if id = Items.painting1 then name := 'painting1' + else if id = Items.painting2 then name := 'painting2' + else if id = Items.painting3 then name := 'painting3' + else if id = Items.painting4 then name := 'painting4' + else if id = Items.painting5 then name := 'painting5' + else if id = Items.painting6 then name := 'painting6' + else if id = Items.painting7 then name := 'painting7' + else if id = Items.reservedBlockItem1 then name := 'reservedBlockItem1' + else if id = Items.vines then name := 'vines' + else if id = Items.sign then name := 'sign' + else if id = Items.redstoneTorch then name := 'redstoneTorch' + else if id = Items.furnace then name := 'furnace' + else if id = Items.closedWoodenTrapdoor then name := 'closedWoodenTrapdoor' + else if id = Items.openWoodenTrapdoor then name := 'openWoodenTrapdoor' + else if id = Items.netherrack then name := 'netherrack' + else if id = Items.netherPortal then name := 'netherPortal' + else if id = Items.glowstone then name := 'glowstone' + else if id = Items.birchLeaves then name := 'birchLeaves' + else if id = Items.soulSand then name := 'soulSand' + else if id = Items.birchSapling then name := 'birchSapling' + else if id = Items.spruceSapling then name := 'spruceSapling' + else if id = Items.redstoneLampOff then name := 'redstoneLampOff' + else if id = Items.redstoneLampOn then name := 'redstoneLampOn' + else if id = Items.backgroundObsidian then name := 'backgroundObsidian' + else if id = Items.glassPlane then name := 'glassPlane' + else if id = Items.farmland then name := 'farmland' + else if id = Items.cake then name := 'cake' + else if id = Items.reservedBlockItem2 then name := 'reservedBlockItem2' + else if id = Items.reservedBlockItem3 then name := 'reservedBlockItem3' + else if id = Items.reservedBlockItem4 then name := 'reservedBlockItem4' + else if id = Items.reservedBlockItem5 then name := 'reservedBlockItem5' + else if id = Items.reservedBlockItem6 then name := 'reservedBlockItem6' + else if id = Items.stick then name := 'stick' + else if id = Items.dandelionYellow then name := 'dandelionYellow' + else if id = Items.roseRed then name := 'roseRed' + else if id = Items.superSpecialUnneededTool then name := 'superSpecialUnneededTool' + else if id = Items.pickaxe1 then name := 'pickaxe1' + else if id = Items.pickaxe2 then name := 'pickaxe2' + else if id = Items.pickaxe3 then name := 'pickaxe3' + else if id = Items.pickaxe4 then name := 'pickaxe4' + else if id = Items.pickaxe5 then name := 'pickaxe5' + else if id = Items.shovel1 then name := 'shovel1' + else if id = Items.shovel2 then name := 'shovel2' + else if id = Items.shovel3 then name := 'shovel3' + else if id = Items.shovel4 then name := 'shovel4' + else if id = Items.shovel5 then name := 'shovel5' + else if id = Items.axe1 then name := 'axe1' + else if id = Items.axe2 then name := 'axe2' + else if id = Items.axe3 then name := 'axe3' + else if id = Items.axe4 then name := 'axe4' + else if id = Items.axe5 then name := 'axe5' + else if id = Items.shears then name := 'shears' + else if id = Items.sword1 then name := 'sword1' + else if id = Items.sword2 then name := 'sword2' + else if id = Items.sword3 then name := 'sword3' + else if id = Items.sword4 then name := 'sword4' + else if id = Items.sword5 then name := 'sword5' + else if id = Items.fishingRod then name := 'fishingRod' + else if id = Items.lighter then name := 'lighter' + else if id = Items.hoe1 then name := 'hoe1' + else if id = Items.hoe2 then name := 'hoe2' + else if id = Items.hoe3 then name := 'hoe3' + else if id = Items.hoe4 then name := 'hoe4' + else if id = Items.hoe5 then name := 'hoe5' + else if id = Items.reservedToolItem then name := 'reservedToolItem' + else if id = Items.coal then name := 'coal' + else if id = Items.redstone then name := 'redstone' + else if id = Items.diamond then name := 'diamond' + else if id = Items.brick then name := 'brick' + else if id = Items.ironIngot then name := 'ironIngot' + else if id = Items.goldIngot then name := 'goldIngot' + else if id = Items.lapisLazuli then name := 'lapisLazuli' + else if id = Items.strand then name := 'strand' + else if id = Items.snowball then name := 'snowball' + else if id = Items.clay then name := 'clay' + else if id = Items.book then name := 'book' + else if id = Items.bucket then name := 'bucket' + else if id = Items.waterBucket then name := 'waterBucket' + else if id = Items.lavaBucket then name := 'lavaBucket' + else if id = Items.milkBucket then name := 'milkBucket' + else if id = Items.paper then name := 'paper' + else if id = Items.melon then name := 'melon' + else if id = Items.egg then name := 'egg' + else if id = Items.door then name := 'door' + else if id = Items.bed then name := 'bed' + else if id = Items.spawnEggZombie then name := 'spawnEggZombie' + else if id = Items.spawnEggSheep then name := 'spawnEggSheep' + else if id = Items.spawnEggPig then name := 'spawnEggPig' + else if id = Items.gunpowder then name := 'gunpowder' + else if id = Items.bowl then name := 'bowl' + else if id = Items.mushroomStew then name := 'mushroomStew' + else if id = Items.map then name := 'map' + else if id = Items.painting then name := 'painting' + else if id = Items.rawPorkchop then name := 'rawPorkchop' + else if id = Items.cookedPorkchop then name := 'cookedPorkchop' + else if id = Items.rottenFlesh then name := 'rottenFlesh' + else if id = Items.camera1 then name := 'camera1' + else if id = Items.camera2 then name := 'camera2' + else if id = Items.camera3 then name := 'camera3' + else if id = Items.goldNugget then name := 'goldNugget' + else if id = Items.sugar then name := 'sugar' + else if id = Items.spiderEye then name := 'spiderEye' + else if id = Items.feather then name := 'feather' + else if id = Items.leather then name := 'leather' + else if id = Items.rawBeef then name := 'rawBeef' + else if id = Items.steak then name := 'steak' + else if id = Items.apple then name := 'apple' + else if id = Items.goldenApple then name := 'goldenApple' + else if id = Items.rawChicken then name := 'rawChicken' + else if id = Items.cookedChicken then name := 'cookedChicken' + else if id = Items.spawnEggChicken then name := 'spawnEggChicken' + else if id = Items.spawnEggCreeper then name := 'spawnEggCreeper' + else if id = Items.flint then name := 'flint' + else if id = Items.spawnEggCow then name := 'spawnEggCow' + else if id = Items.spawnEggMooshroom then name := 'spawnEggMooshroom' + else if id = Items.rawFish then name := 'rawFish' + else if id = Items.cookedFish then name := 'cookedFish' + else if id = Items.spawnEggPigman then name := 'spawnEggPigman' + else if id = Items.spawnEggSpider then name := 'spawnEggSpider' + else if id = Items.glowstoneDust then name := 'glowstoneDust' + else if id = Items.clock then name := 'clock' + else if id = Items.compass then name := 'compass' + else if id = Items.seeds then name := 'seeds' + else if id = Items.wheat then name := 'wheat' + else if id = Items.bread then name := 'bread' + else if id = Items.boneMeal then name := 'boneMeal' + else if id = Items.melonSeeds then name := 'melonSeeds' + else if id = Items.pumpkinSeeds then name := 'pumpkinSeeds' + else name := '' + id; + result := name; + end; + + procedure PrintItem(id, typ, tex, max, info, texsource, indicator : integer; dividable : boolean); + var + name, tname, indname : string; + begin + name := ItemToString(id); + + if typ = Items.block then tname := 'block' + else if typ = Items.tool then tname := 'tool' + else if typ = Items.reserved then tname := 'reserved' + else if typ = Items.orditem then tname := 'orditem' + else tname := '' + typ; + + if indicator = Items.noindicator then indname := 'noindicator' + else if indicator = Items.numeric then indname := 'numeric' + else if indicator = Items.line then indname := 'line' + else indname := '' + indicator; + + Debug(' InitItem(' + name + ', ' + tname + ', ' + tex + ', ' + max + ', ' + info + ', ' + texsource + ', ' + indname + ', ' + dividable + ');'); + end; + + procedure PrintItemTable; + var + id : integer; + begin + for id := 0 to 222 do begin + PrintItem( + id, + Items.GetType(id), + Items.GetTexture(id), + Items.GetMaximum(id), + Items.GetData(id), + Items.GetTextureSource(id), + Items.GetIndicatorType(id), + Items.IsDividable(id) + ); + end; + + for id := 0 to 194 do begin + Debug(' InitOrdItem(' + ItemToString(Items.GetOrdinary(id)) + ');'); + end; + end; + begin qt_start; hung_time:=getrelativetimems; hp_time:=getrelativetimems; air_time:=getrelativetimems; portal_time:=getrelativetimems; + + PrintItemTable; + repeat proc_fps; keyhandler;