DEADSOFTWARE

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