DEADSOFTWARE

blocks.cfg -> Blocks.pas
[cavecraft.git] / src / CAVE.mpsrc
index 6de766ba1a2b5bb5536d231afc86dd059fc144ec..a43998d85f579e1be265f6d7b286907bd3f7f7a5 100644 (file)
@@ -6,14 +6,12 @@ uses
  drop,\r
  invui,\r
  vars,\r
- particles_store,\r
  randoms,\r
  memory,\r
  worldgen,\r
  canvas,\r
- items,\r
  safeload,\r
- mob,\r
+ mobs,\r
  console,\r
  effects,\r
  particles,\r
@@ -29,11 +27,14 @@ uses
  chest,\r
  inv,\r
  items_store,\r
- video;\r
+ video,\r
+ Blocks,\r
+ BlocksLogic,\r
+ Items,\r
+ ItemsLogic;\r
 \r
 const\r
- version = 'BETA 9';\r
- version_map = 9;\r
+  version_map = 9;\r
 \r
 var\r
  keymode,updx,updy:integer;\r
@@ -54,7 +55,7 @@ var
  moon_phase:integer;\r
  toolus,toolind:integer;\r
  osadki_ani:integer;\r
- sd,sav_fl:string;\r
+ sav_fl:string;\r
  global_light:integer;\r
  world_typ:integer;\r
  float:image;\r
@@ -108,68 +109,59 @@ procedure maxfps;
   delay(del);\r
  end;\r
 \r
-procedure cleartextures;\r
- var\r
-  no:image;\r
-  ix,iy,iz:integer;\r
- begin\r
-  bg[0]:=no;\r
-  bg[1]:=no;\r
-  float:=no;\r
-  compas:=no;\r
-  for ix:=0 to 7 do clock[ix]:=no;\r
-\r
-  {for ix:=0 to maxBlockTex do\r
-   begin\r
-    tex[ix]:=no;\r
-    tex8[ix]:=no;\r
-   end;\r
-  for ix:=0 to maxItemTex do\r
-   begin\r
-    item[ix]:=no;\r
-    item8[ix]:=no;\r
-   end;}\r
- for ix:=0 to 8 do back[ix]:=no;\r
-\r
-  player.freeSkin;\r
-\r
-  for ix:=0 to 34 do\r
-   gui[ix]:=no;\r
-\r
-  for ix:=0 to 9 do tue[ix]:=no;\r
-\r
-  for ix:=0 to 7 do osad[0,ix]:=no;\r
-  for ix:=0 to 7 do osad[1,ix]:=no;\r
-\r
-  for ix:=0 to 15 do light[ix]:=no;\r
+procedure ClearTextures;\r
+  var\r
+    no : image;\r
+    ix, iy, iz : integer;\r
+  begin\r
+    bg[0] := no;\r
+    bg[1] := no;\r
+    float := no;\r
+    compas := no;\r
+    for ix := 0 to 7 do\r
+      Vars.clock[ix] := no;\r
+\r
+    for ix := 0 to maxBlockTex do\r
+      begin\r
+        tex[ix] := no;\r
+        tex8[ix] := no;\r
+      end;\r
+    for ix := 0 to maxItemTex do\r
+      begin\r
+        item[ix] := no;\r
+        item8[ix] := no;\r
+      end;\r
 \r
-  for ix:=0 to 7 do\r
-   begin\r
-    pr_1[ix]:=no;\r
-    pr_2[ix]:=no;\r
-    pr_3[ix]:=no;\r
-    pr_4[ix]:=no;\r
-    pr_5[ix]:=no;\r
-   end;\r
-  bubble:=no;\r
+    for ix := 0 to 8 do\r
+      back[ix]:=no;\r
 \r
-  for ix:=0 to 15 do\r
-   pr_boom[ix]:=no;\r
+    player.freeSkin;\r
 \r
-  mob.freeSkin;\r
+    for ix := 0 to 34 do\r
+      gui[ix] := no;\r
+    for ix := 0 to 9 do\r
+      tue[ix] := no;\r
+    for ix := 0 to 7 do\r
+      osad[0, ix] := no;\r
+    for ix := 0 to 7 do\r
+      osad[1, ix] := no;\r
 \r
-  sky:=no;\r
+    for ix := 0 to 15 do\r
+      light[ix] := no;\r
 \r
-  sun:=no;\r
-  moon:=no;\r
+    Particles.FreeTextures;\r
+    Mobs.FreeTextures;\r
 \r
-  sign_im:=no;\r
+    sky := no;\r
+    sun := no;\r
+    moon := no;\r
+    sign_im := no;\r
 \r
-  for ix:=0 to CONST_MAX_CURS do\r
-   LoadCurImg(no, ix);\r
+    for ix := 0 to CONST_MAX_CURS do\r
+      LoadCurImg(no, ix);\r
 \r
-  //resetVirtualKeyboard(-1);\r
- end;\r
+    //resetVirtualKeyboard(-1);\r
 end;\r
 \r
 procedure create_msg(s:string);\r
  var\r
@@ -198,15 +190,17 @@ 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
     for ix:=0 to 8 do back[ix]:=rotate_image_from_image(im,ix*16,0,16,16,0);\r
    end;\r
 \r
-  player.loadSkin('char_ani.png', path);\r
-  mob.loadSkin(path);\r
+  console.exec('textures.cfg', 'AUTO');\r
+\r
+  Player.LoadSkin('char_ani.png', path);\r
+  Mobs.LoadTextures(path);\r
 \r
   im:=ld_tex('gui.png',path,'gui/');\r
   gui[0]:=rotate_image_from_image(im,0,0,16,16,0);\r
@@ -255,22 +249,7 @@ procedure loadtexture(path:string);
     for ix:=0 to 15 do light[ix]:=rotate_image_from_image(im,16*ix,0,16,16,0);\r
    end;\r
 \r
-  if load_particles_tex then\r
-   begin\r
-    im:=ld_tex('particles.png',path,'terrain/');\r
-    for ix:=0 to 7 do\r
-     begin\r
-      pr_1[ix]:=rotate_image_from_image(im,8*ix,0,8,8,0);\r
-      pr_2[ix]:=rotate_image_from_image(im,8*ix,8,8,8,0);\r
-      pr_3[ix]:=rotate_image_from_image(im,8*ix,16,8,8,0);\r
-      pr_4[ix]:=rotate_image_from_image(im,8*ix,24,8,8,0);\r
-      pr_5[ix]:=rotate_image_from_image(im,8*ix,32,8,8,0);\r
-     end;\r
-    bubble:=rotate_image_from_image(im,0,40,8,8,0);\r
-    im:=ld_tex('explosion.png',path,'terrain/');\r
-    for ix:=0 to 15 do\r
-     pr_boom[ix]:=rotate_image_from_image(im,32*ix,0,32,32,0);\r
-   end;\r
+  Particles.LoadTextures(path);\r
 \r
   im:=ld_tex('partition.png',path,'gui/');\r
   gui[18]:=rotate_image_from_image(im,0,0,84,42,0);\r
@@ -335,18 +314,12 @@ procedure cleargame;
 \r
   //anim_del2:=0;\r
 \r
-  inv.resetData;\r
-\r
-  chest.resetData;\r
-\r
-  furnace.resetData;\r
-\r
-  drop.resetData;\r
-\r
-  mob.resetData;\r
-\r
-  //gb_up_pa:=0;\r
-  reset_particles(max_particles+1);\r
+  Inv.ResetData;\r
+  Chest.ResetData;\r
+  Furnace.ResetData;\r
+  Drop.ResetData;\r
+  Mobs.ResetData;\r
+  Particles.ResetData;\r
 \r
   for ix:=0 to 255 do\r
    begin\r
@@ -513,31 +486,19 @@ procedure saveworld(path:string);
        write_byte(getBackMap(ix));\r
        write_byte(getBiomMap(ix));\r
       end;\r
-     drw_load_line('Chests',55);\r
-     //Chests\r
-     chest.saveData;\r
-     drw_load_line('Furnaces',60);\r
-     //Furnaces\r
-     furnace.saveData;\r
-     drw_load_line('Mobs',70);\r
-     //Mobs\r
-     mob.saveData;\r
-     drw_load_line('Drop',80);\r
-     //Drop\r
-     drop.saveData;\r
-      drw_load_line('Particles',85);\r
-     //Particles\r
-     writeint(max_particles);\r
-     write_byte(gb_up_pa);\r
-     for ix:=0 to max_particles do\r
-      begin\r
-       write_byte(get_particle_type(ix));\r
-       write_byte(get_particle_ani(ix));\r
-       writeint(get_particle_x(ix));\r
-       writeint(get_particle_y(ix));\r
-      end;\r
-     drw_load_line('Other',90);\r
-     //Other\r
+\r
+     drw_load_line('Chests', 55);\r
+     Chest.SaveData;\r
+     drw_load_line('Furnaces', 60);\r
+     Furnace.SaveData;\r
+     drw_load_line('Mobs', 70);\r
+     Mobs.SaveData;\r
+     drw_load_line('Drop', 80);\r
+     Drop.SaveData;\r
+     drw_load_line('Particles', 85);\r
+     Particles.SaveData;\r
+\r
+     drw_load_line('Other', 90);\r
      write_byte(updx);\r
      write_byte(updy);\r
      writebool(osadki);\r
@@ -645,31 +606,17 @@ function loadworld(path:string):boolean;
        setBackMap(read_byte, ix);\r
        setBiomMap(read_byte, ix);\r
       end;\r
-     drw_load_line('Chests',55);\r
-     //Chests\r
-     chest.loadData;\r
-     drw_load_line('Furnaces',60);\r
-     //Furnaces\r
-     furnace.loadData;\r
-     //Mobs\r
-     mob.loadData;\r
-     drw_load_line('Drop',80);\r
-     //Drop\r
-     drop.loadData;\r
-     drw_load_line('Particles',85);\r
-     //Particles\r
-     max_particles:=readint;\r
-     reset_particles(max_particles+1);\r
-     gb_up_pa:=read_byte;\r
-     for ix:=0 to max_particles do\r
-      begin\r
-       set_particle_type(ix,read_byte);\r
-       set_particle_ani(ix,read_byte);\r
-       set_particle_x(ix,readint);\r
-       set_particle_y(ix,readint);\r
-      end;\r
-      drw_load_line('Other',90);\r
-     //Other\r
+     drw_load_line('Chests', 55);\r
+     Chest.LoadData;\r
+     drw_load_line('Furnaces', 60);\r
+     Furnace.LoadData;\r
+     Mobs.LoadData;\r
+     drw_load_line('Drop', 80);\r
+     Drop.LoadData;\r
+     drw_load_line('Particles', 85);\r
+     Particles.LoadData;\r
+\r
+     drw_load_line('Other',90);\r
      updx:=read_byte;\r
      updy:=read_byte;\r
      osadki:=readbool;\r
@@ -1039,7 +986,7 @@ procedure start_uu;
   rs:=openRecordStore('SD');\r
   sd:=readRecordStoreEntry(rs,1);\r
   closeRecordStore(rs);\r
-  console.exec('autoexec.cfg', 'AUTO', true);\r
+  console.exec('autoexec.cfg', 'AUTO');\r
   if sd='' then\r
    begin\r
     init_touch;\r
@@ -1395,6 +1342,7 @@ procedure menu_tex;
     if m_cur=0 then begin\r
      if cur_name>0 then\r
       begin\r
+       debug("Select TexturePack @ /" + sd + "/cavecraft/texturepacks/" + names[cur_name]);\r
        tex_pack:=names[cur_name];\r
        LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
        loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
@@ -1402,9 +1350,13 @@ procedure menu_tex;
        rs:=openRecordStore('TX');\r
        t:=addRecordStoreEntry(rs,tex_pack);\r
        closeRecordStore(rs);\r
+\r
+       LoadDrawFont('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
+       loadtexture('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/');\r
       end;\r
      else\r
       begin\r
+       debug("Cancel Select TecturePack");\r
        tex_pack:='';\r
        loadtexture('/');\r
        deleteRecordStore('TX');\r
@@ -1478,7 +1430,7 @@ var
       end; else\r
      if m_cur=-1 then\r
       begin\r
-       s_particles:=not s_particles;\r
+       Particles.enabled := not Particles.enabled;\r
       end; else\r
      if m_cur=0 then\r
       begin\r
@@ -1532,7 +1484,7 @@ var
 \r
    drw_btn('Light:'+light_type,-3,m_cur,0,1);\r
    drw_btn('Weather:'+ifosad,-2,m_cur,0,1);\r
-   drw_btn('Particles:'+s_particles,-1,m_cur,0,1);\r
+   drw_btn('Particles:' + Particles.enabled, -1, m_cur, 0, 1);\r
    drw_btn('Hide GUI:'+not drawgui,0,m_cur,0,1);\r
    drw_btn('Touch:'+(load_key_tex>0),1,m_cur,0,1);\r
    drw_btn('JPEG:'+s_jpeg_quality,2,m_cur,0,1);\r
@@ -1763,11 +1715,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
@@ -2012,46 +1963,50 @@ 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 BlocksLogic.Draw(ix, iy, camx, camy);\r
    end;\r
   {===================[drop]===================}\r
-  drop.draw(camx, camy);\r
+  Drop.Draw(camx, camy);\r
   {===================[particles]===================}\r
-  if s_particles then draw_particle;\r
+  Particles.Draw(camx, camy);\r
   {===================[player]===================}\r
-  if hp>0 then\r
-   begin\r
-    player.draw(camx, camy);\r
-   end;\r
-\r
+  Player.Draw(camx, camy);\r
   {===================[mobs]===================}\r
-  mob.draw(camx, camy);\r
+  Mobs.Draw(camx, camy);\r
   {===================[draw_blocks]===================}\r
   for ix:=minx to maxx do\r
   for iy:=miny to maxy do\r
-   begin\r
-    if getBlockFore(getmap(ix,iy))=true then\r
-     draw_block(ix,iy);\r
+    begin\r
+      if Blocks.IsForeground(getmap(ix, iy)) then BlocksLogic.Draw(ix, iy, camx, camy);\r
 \r
-    setcolor(0,0,0);\r
-    if (light_type=1) then begin if getmaplight(ix,iy)=0 then fillrect((ix*16)-camx,(iy*16)-camy,16,16); end;\r
-     else\r
-    if light_type=2 then begin if getmaplight(ix,iy)<15 then begin if (ix*16-camx<getWidth) and (ix*16-camx>0-16) and (iy*16-camy<getHeight) and (iy*16-camy>0-16) then drawimage(light[getmaplight(ix,iy)],(ix*16)-camx,(iy*16)-camy); end; end;\r
-   end;\r
-   if (toolus>0) and (toolind<10) and (getmap(curx,cury)>0) then begin if toolind>9 then toolind:=9; drawimage(tue[toolind],curx*16-camx,cury*16-camy); end;\r
+      setcolor(0, 0, 0);\r
+      if light_type = 1 then\r
+        begin\r
+          if getmaplight(ix,iy) = 0 then\r
+            fillrect((ix * 16) - camx, (iy * 16) - camy, 16, 16);\r
+        end;\r
+      else if light_type = 2 then\r
+        begin \r
+          if getmaplight(ix, iy) < 15 then\r
+             drawimage(light[getmaplight(ix, iy)], (ix * 16) - camx, (iy * 16) - camy);\r
+        end;\r
+     end;\r
+\r
+   // debug\r
+   // drawimage(light[getmaplight(player.getX div 16, player.getY div 16)], 0, 0);\r
+\r
+   if (toolus > 0) and (toolind < 10) and (getmap(curx,cury) > 0) then\r
+     begin\r
+       if toolind > 9 then\r
+         toolind:=9;\r
+       drawimage(tue[toolind], curx * 16 - camx, cury * 16 - camy);\r
+     end;\r
   {===================[gui]===================}\r
   if drawgui then\r
    begin\r
@@ -2075,7 +2030,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
+      ItemsLogic.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
@@ -2216,14 +2171,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 (Blocks.GetTool(block) = getToolType(item)) then\r
      toolus:=toolus+getToolSpeed(item);\r
     else\r
      toolus:=toolus+1;\r
 \r
-    if toolus>=getBlockHP(block) then\r
+    if toolus >= Blocks.GetResistant(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 (Blocks.GetTool(block) = getToolType(item)) and (getToolLvl(item) >= Blocks.GetLevel(block))) or (Blocks.GetLevel(block) <= 0) then\r
        begin\r
         setMap(0, x, y);\r
         destroy_block_1(block, x, y);\r
@@ -2236,7 +2191,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
@@ -2247,8 +2202,9 @@ procedure usetools(invcur, x, y:integer);
      end;\r
    end;\r
 \r
-  if (toolus>0) and (toolus<=getBlockHP(block)) then\r
-   toolind:=((toolus*100) div getBlockHP(block)) div 10;\r
+  if (toolus > 0) and (toolus <= Blocks.GetResistant(block)) then begin\r
+    toolind := ((toolus * 100) div Blocks.GetResistant(block)) div 10;\r
+  end;\r
  end;\r
 \r
 function rt_useweap:boolean;\r
@@ -2262,15 +2218,15 @@ 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
 \r
   if posi=0 then\r
-   i:=mob.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3);\r
+   i:=Mobs.findAndHit(damg, x-TILE_SIZE, y, TILE_SIZE+(w/2), h, -2, -3);\r
   else\r
-   i:=mob.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3);\r
+   i:=Mobs.findAndHit(damg, x+(w/2), y, TILE_SIZE+(w/2), h, 2, -3);\r
 \r
   if i<>-1 then\r
    begin\r
@@ -2705,9 +2661,9 @@ procedure phyhandler;
  var\r
   i:integer;\r
  begin\r
-  player.calcPhysics;\r
-  mob.updatePhy;\r
-  drop.calcPhy;\r
+  Player.CalcPhysics;\r
+  Mobs.UpdatePhy;\r
+  Drop.CalcPhy;\r
  end;\r
 \r
 procedure light_fillrect(l,x,y,r:integer);\r
@@ -2764,7 +2720,7 @@ procedure calc_sun(ix,m:integer);
    begin\r
     setmaplight(ss,ix,iy);\r
     if ss=0 then break;\r
-    ss:=ss-getBlockTr(getmap(ix,iy));\r
+    ss := ss - Blocks.GetLightAbsorbtion(getmap(ix, iy));\r
     if ss<0 then ss:=0;\r
    end;\r
   for iy:=iy+1 to 127 do\r
@@ -2875,6 +2831,9 @@ procedure game;
 \r
   game_time:=game_time+(600000 div (fps_t*1000));\r
 \r
+// Ускорение игрового времени в 10 раз\r
+//  game_time := game_time + (600000 div (fps_t*100));\r
+\r
   if (game_time>600000) or (game_time<0) then\r
    begin\r
     game_time:=0;\r
@@ -2883,19 +2842,20 @@ procedure game;
     load_moon('/'+sd+'/cavecraft/texturepacks/'+tex_pack+'/',moon_phase);\r
    end;\r
 \r
-  tim:=10000*getimagewidth(sky)/600000*game_time/10000;\r
-  global_light:=effects.get(sky,tim,1,1) {and $F};\r
+  tim := 10000 * getimagewidth(sky) / 600000 * game_time / 10000;\r
+  global_light := effects.get(sky, tim, 1, 1) div 16;\r
 \r
   if clock_stage<>game_time div 75000 then begin clock_stage:=clock_stage+1; if clock_stage>7 then clock_stage:=0; end;\r
 \r
-  if x<0 then x:=0;\r
-  if x+8>4094 then x:=4086;\r
-  if getBlockColl(getmap(x div 16, y div 16))>0 then hp:=hp-1;\r
+  if x < 0 then x := 0;\r
+  else if x + 8 > 4094 then x := 4086;\r
+  if Blocks.IsSolid(getmap(x div 16, y div 16)) then hp := hp - 1;\r
+\r
   if random(4096)=random(4096) then begin osadki:=not osadki; end;\r
   osadki_ani:=osadki_ani+1;\r
   if osadki_ani>7 then osadki_ani:=0;\r
 \r
-  if random(20)=random(20) then create_particle(6,x,y);\r
+  if Random(20) = Random(20) then Particles.Create(Particles.bubble, x, y);\r
 \r
   if gamemode=1 then begin hp:=666; hunger:=666; end;\r
 \r
@@ -2906,9 +2866,8 @@ procedure game;
 \r
   //if s_spawn_mob then if random(4096)=1547 then megaspawn;\r
 \r
-  mob.update;\r
-\r
-  if particle_upd then update_particle;\r
+  Mobs.Update;\r
+  Particles.Update;\r
 \r
   if light_type>0 then\r
    begin\r
@@ -2930,9 +2889,11 @@ procedure game;
   for ix:=minx to maxx do\r
   for iy:=miny to maxy do\r
    begin\r
-    if light_type=0 then setmaplight(15,ix,iy);\r
-     else\r
-    if light_type>0 then if getBlockLi(getmap(ix,iy))>0 then calc_light(getBlockLi(getmap(ix,iy)),ix,iy);\r
+    if light_type = 0 then begin\r
+      SetMapLight(15, ix, iy);\r
+    end else if (light_type > 0) and (Blocks.GetLightEmission(getmap(ix, iy)) > 0) then begin\r
+      calc_light(Blocks.GetLightEmission(GetMap(ix, iy)), ix, iy);\r
+    end;\r
    end;\r
 \r
   minx:=(camx/16)-((getwidth/2)/16);\r
@@ -3024,12 +2985,324 @@ procedure qt_start;
   menu;\r
  end;\r
 \r
+procedure draw_debug;\r
+  var\r
+    i : Integer;\r
+  begin\r
+    //drawfonttext('X:'+(x div 16-128),0,0);\r
+    //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8);\r
+    drawfonttext('CURX:'+(curx-128),0,16);\r
+    drawfonttext('CURY:'+cury,0,24);\r
+    drawfonttext('UPDX:'+updx,0,32);\r
+    drawfonttext('UPDY:'+updy,0,40);\r
+    drawfonttext('FPS:'+fps,0,56);\r
+    drawfonttext('Free RAM:'+free_ram/1024+' KB',0,64);\r
+    drawfonttext('Total RAM:'+memory.get_totalmemory div 1024+' KB',0,72);\r
+    drawfonttext('SEED:'+seed,0,88);\r
+    drawfonttext('Game time:'+game_time,0,96);\r
+    drawfonttext('Global light:' + global_light, 0, 104);\r
+\r
+    for i := 0 to 15 do\r
+      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.giftChest then name := 'giftChest'\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.wheatBlock then name := 'wheatBlock'\r
+      else if id = Items.melonStem then name := 'melonStem'\r
+      else if id = Items.pumpkinStem then name := 'pumpkinStem'\r
+      else if id = Items.burningFurnace then name := 'burningFurnace'\r
+      else if id = Items.reservedBlockItem then name := 'reservedBlockItem'\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
+\r
+        for id := 0 to 125 do begin\r
+          Debug('  InitBlock(' + ItemToString(id) + ', ' +\r
+                Blocks.GetTexture(id) + ', ' +\r
+                Blocks.GetResistant(id) + ', ' +\r
+                Blocks.GetTool(id) + ', ' +\r
+                Blocks.GetLevel(id) + ', ' +\r
+                Blocks.GetLightAbsorbtion(id) + ', ' +\r
+                Blocks.GetLightEmission(id) + ', ' +\r
+                Blocks.IsSolid(id) + ', ' +\r
+                Blocks.IsTransporent(id) + ', ' +\r
+                Blocks.IsForeground(id) + ', ' +\r
+                Blocks.IsOverlapped(id) + ');'\r
+          );\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
@@ -3038,20 +3311,8 @@ begin
   draw;\r
   drawfonttext(version,getWidth-(length(version)*8),getHeight-8);\r
   if getrelativetimems-msg_time[4]>500 then begin free_ram:=memory.get_freememory; if free_ram<0 then free_ram:=-free_ram; msg_time[4]:=getrelativetimems; end;\r
-  if deb=true then\r
-   begin\r
-    //drawfonttext('X:'+(x div 16-128),0,0);\r
-    //drawfonttext('Y:'+integertostring(127-(y div 16)),0,8);\r
-    drawfonttext('CURX:'+(curx-128),0,16);\r
-    drawfonttext('CURY:'+cury,0,24);\r
-    drawfonttext('UPDX:'+updx,0,32);\r
-    drawfonttext('UPDY:'+updy,0,40);\r
-    drawfonttext('FPS:'+fps,0,56);\r
-    drawfonttext('Free RAM:'+free_ram/1024+' KB',0,64);\r
-    drawfonttext('Total RAM:'+memory.get_totalmemory div 1024+' KB',0,72);\r
-    drawfonttext('SEED:'+seed,0,88);\r
-    drawfonttext('Game time:'+game_time,0,96);\r
-   end;\r
+  if deb = true then\r
+    draw_debug;\r
 \r
   drawVideo;\r
   maxfps;\r