About Store Forum Documentation Contact



Post Reply 
Ineisis -Detailed tutorials
Author Message
Donik Offline
Member

Post: #16
RE: Ineisis -Detailed tutorials
Works now =)
Let's hope you get twins grin
05-11-2013 02:42 PM
Find all posts by this user Quote this message in a reply
jwilde464 Offline
Member

Post: #17
RE: Ineisis -Detailed tutorials
After updating the editor these are the lines that its having problems with. Both lines are from void LoadEditorWorld.

Image &temp_image = the_area.getData().height();

This line is giving this error:
1>d:\projects\ineisis online (esenthel 2.0 project)\_build_\ineisis server\source\world.cpp(47): error C2064: term does not evaluate to a function taking 0 arguments

and

data.heightmap.setHeight(hx, hy, (the_area.data().height().pixelF(hx, hy)+128));

is giving:
1>d:\projects\ineisis online (esenthel 2.0 project)\_build_\ineisis server\source\world.cpp(51): error C2064: term does not evaluate to a function taking 0 arguments
and
1>d:\projects\ineisis online (esenthel 2.0 project)\_build_\ineisis server\source\world.cpp(51): error C2228: left of '.pixelF' must have class/struct/union

Sorted pfft

Change the first line to:
Image &temp_image = the_area.getData().height;
and the second to:
data.heightmap.setHeight(hx, hy, (the_area.data().height.pixelFI(hx, hy)+128));
(This post was last modified: 06-06-2013 02:22 AM by jwilde464.)
05-26-2013 10:41 PM
Find all posts by this user Quote this message in a reply
kevindekever Offline
Member

Post: #18
RE: Ineisis -Detailed tutorials
thx for sharing, i added two lines for materials:
Code:
void ChangeWorld(C UID &world_id)
{
   Net.World &world = *Net.Worlds(world_id);
   Game.ObjMemx<CustomStatic> Items;
   Game.World.mode(Game.WORLD_MANUAL);
   Game.World.setObjType(Items, OBJ_STATIC)
             .New(APEWorldID);
   int        areas=Areas+1;
   for(int x=-areas; x<areas; x++)
      for(int y=-areas; y<areas; y++)
      {
         VecI2 a(x, y);
         Memc<Game.WorldManager.AreaState> areastates;
         areastates.New().set(a, Game.AREA_LOAD);
         Game.World.areaSetState(areastates, true);
         Game.Area *the_area = Game.World.areaLoaded(a);
         Area *data= GetArea(world, VecI2(x, y));
         Image &temp_image =the_area.getData().height;
         Image &temp_image2 =the_area.getData().material_map;
         RectI ah= RectI(VecI2(0, 0), VecI2(HmRes+1, HmRes+1));
         for( int hy=ah.min.y;  hy<=ah.max.y; hy++)
            for( int hx=ah.min.x;  hx<=ah.max.x; hx++)
               {    
                   data.heightmap.setHeight(hx, hy, (the_area.data().height.pixelFI(hx, hy)+128));
                 data.heightmap.setMaterial(hx, hy,  (the_area.getData().materials[temp_image2.pixel(hx, hy)]));
               }  
                    
    
         if(Items.elms())
         {
            REPA(Items)
            {
               VecI local(Items[i].pos().x, Items[i].pos().y, Items[i].pos().z);
               SetObj(&world, local, Items[i].matrix().angle(), Items[i].get_ID());
            }
         }
      }
      Game.World.del();
      
}

Image &temp_image2 =the_area.getData().material_map;
data.heightmap.setMaterial(hx, hy, (the_area.getData().materials[temp_image2.pixel(hx, hy)]));


because of material_map some passages aren't nice as in editor
(This post was last modified: 07-28-2013 09:54 PM by kevindekever.)
07-28-2013 09:41 PM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #19
RE: Ineisis -Detailed tutorials
(05-26-2013 10:41 PM)jwilde464 Wrote:  After updating the editor these are the lines that its having problems with. Both lines are from void LoadEditorWorld.

Image &temp_image = the_area.getData().height();

This line is giving this error:
1>d:\projects\ineisis online (esenthel 2.0 project)\_build_\ineisis server\source\world.cpp(47): error C2064: term does not evaluate to a function taking 0 arguments

and

data.heightmap.setHeight(hx, hy, (the_area.data().height().pixelF(hx, hy)+128));

is giving:
1>d:\projects\ineisis online (esenthel 2.0 project)\_build_\ineisis server\source\world.cpp(51): error C2064: term does not evaluate to a function taking 0 arguments
and
1>d:\projects\ineisis online (esenthel 2.0 project)\_build_\ineisis server\source\world.cpp(51): error C2228: left of '.pixelF' must have class/struct/union

Sorted pfft

Change the first line to:
Image &temp_image = the_area.getData().height;
and the second to:
data.heightmap.setHeight(hx, hy, (the_area.data().height.pixelFI(hx, hy)+128));

Thank you that helped but now I'm getting a new error. I don't know if its because of a newer version or what.
So I get a 'replaceClass' is not a member of EE.Net:World

Net.World.replaceClass<World>();

Any Idea's why?
08-12-2013 12:27 AM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #20
RE: Ineisis -Detailed tutorials
can you post the whole error?
08-12-2013 04:22 AM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #21
RE: Ineisis -Detailed tutorials
Quote:1>------ Build started: Project: Ineisis Server, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>Compiling...
1>Auto.cpp
1>Scheduler.cpp
1>Pos.cpp
1>Objects.cpp
1>Net Chr.cpp
1>Names.cpp
1>Heightmap.cpp
1>Ground Objects.cpp
1>Grass.cpp
1>Constants.cpp
1>Commands.cpp
1>Blocks.cpp
1>Action Performance.cpp
1>Account.cpp
1>Tree.cpp
1>Torch.cpp
1>Static.cpp
1>Obj.cpp
1>Door.cpp
1>World.cpp
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(59) : error C2039: 'replaceClass' : is not a member of 'EE::Net::World'
1> d:\esenthel engine\bin\esenthelengine\net\net world.h(24) : see declaration of 'EE::Net::World'
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(59) : error C2065: 'replaceClass' : undeclared identifier
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(59) : error C2275: 'World' : illegal use of this type as an expression
1> d:\esenthel engine\projects\_build_\ineisis server\source\$world.h(3) : see declaration of 'World'
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(59) : error C2059: syntax error : ')'
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(169) : warning C4068: unknown pragma
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(186) : warning C4068: unknown pragma
1>d:\esenthel engine\projects\_build_\ineisis server\source\world.cpp(203) : warning C4068: unknown pragma
1>Generating Code...
1>Compiling...
1>SQL.cpp
1>Server.cpp
1>Message Performance.cpp
1>Main.cpp
1>Mail.cpp
1>Magic.cpp
1>Client Game.cpp
1>Client Account.cpp
1>Client.cpp
1>Area.cpp
1>Generating Code...
1>Build log was saved at "file://d:\Esenthel Engine\Projects\_Build_\Ineisis Server\Debug\BuildLog.htm"
1>Ineisis Server - 4 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thanks for looking at this. smile
08-12-2013 10:30 PM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #22
RE: Ineisis -Detailed tutorials
Hi Palaxe,

I will look at this tonight when i get home. Can you please also attach your world.cpp file just to be safe? If you do that, i will for sure be able to figure it out tonight.
08-12-2013 10:47 PM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #23
RE: Ineisis -Detailed tutorials
(08-12-2013 10:47 PM)Ozmodian Wrote:  Hi Palaxe,

I will look at this tonight when i get home. Can you please also attach your world.cpp file just to be safe? If you do that, i will for sure be able to figure it out tonight.
Code:
/******************************************************************************/
class World : Net.World
{
   static void Save(Cell<Net.Area> &net_area, ptr user)
   {
      if(Area *area=net_area.cast<Area>())area.saveChanges();
   }

   flt hmHeight(C Vec2 &xz, bool smooth=true)
   {
      if(Cell<Net.Area> *grid=T.grid.find(worldToArea(xz)))if(Area *area=grid.cast<Area>())return area.hmHeight(xz, smooth);
      return 0;
   }

   World()
   {
      areaSize(AreaSize);
      grid.replaceClass<Area>();
   }
  ~World()
   {
      // save changes before closing
      FCreateDirs(dataPath()+"Area");
      grid.func(Save);
   }
}
/******************************************************************************/
const bool UpdateWorldFormat=false; // use this to re-save all areas at server startup, and immediately close the server app after it
/******************************************************************************/
Area* GetArea(Net.World &world, C VecI2 &xy) {return world.grid.get(xy).cast<Area>();} // get world area casted to 'Area' class
/******************************************************************************/
void LoadWorld(C UID &world_id) // load all areas of 'world_id' world into memory
{
   Net.World &world   =*Net.Worlds(world_id);
   Str        area_dir= world.dataPath()+"Area";
   for(FileFind ff(area_dir); ff(); )
      if(!Contains(ff.name, '@'))
   {
      VecI2 xy=TextVecI2(ff.name);
      if(Area *area=GetArea(world,xy))
      {
         area.load(ff.pathName());
       //area.heightmap.fillHoles(UID(10409022, 1195409879, 1143007153, 3722121309));
         if(UpdateWorldFormat)area.save(ff.pathName());
      }
   }
}
void SetWorldAreas()
{
   Net.World &world=*Net.Worlds(MainWorldID);
   int        areas=Areas+1;
   for(int x=-areas; x<areas; x++)
   for(int y=-areas; y<areas; y++)if(Area *area=GetArea(world, VecI2(x, y)))area.heightmap.create(UID(10409022, 1195409879, 1143007153, 3722121309));
}
void LoadEditorworld(C UID &world_id)
{
   Net.World &world =*Net.Worlds(world_id);
   Game.World.mode(Game.WORLD_MANUAL);
   Game.World.New(Editorworld);
   int        areas=Areas+1;
   for(int x=-areas; x<areas; x++)
   for(int y=-areas; y<areas; y++)
   {
      VecI2 a(x, y);
      Memc<Game.WorldManager.AreaState> areastates;
      areastates.New().set(a, Game.AREA_LOAD);
      Game.World.areaSetState(areastates, true);
      Game.Area* the_area = Game.World.areaLoaded(a);
      Area *data=GetArea(world, VecI2(x, y));
      //Image &temp_image = the_area.getData().height():
      Image &temp_image = the_area.getData().height;
      RectI ah = RectI(VecI2(0, 0), VecI2(HmRes+1, HmRes+1));
      for(int hy=ah.min.y;  hy<=ah.max.y; hy++)
      for(int hx=ah.min.x;  hx<=ah.max.x; hx++)
      //data.heightmap.setHeight(hx, hy, (the_area.data().height.pixelF(hx, hy)+128));
      data.heightmap.setHeight(hx, hy, (the_area.data().height.pixelFI(hx, hy)+128));
      
   }
   Game.World.del();
}
void InitWorld()
{
   Net.World.replaceClass<World>();
   SetWorldAreas();
   LoadWorld(MainWorldID);
   LoadEditorworld(MainWorldID);
}
void ShutWorld()
{
   Net.Worlds.del(); // delete manually before resource caches are deleted (to have access to resource paths)
}
/******************************************************************************/
void ChangeHeight(Net.World *world, C VecI2 &pos, Image &delta) // must be synced with Client.SetHeightServer
{
   if(world)
   {
      Image final; final.createSoft(delta.x(), delta.y(), 1, IMAGE_I8);
      Memc<Client*> clients;
      Memc<Ver    > height_vers;

      RectI rect_h=RectI(pos.x, pos.y, pos.x+delta.x()-1, pos.y+delta.y()-1)&WorldBoundsHeightmap,
            rect_a(HeightmapToArea(rect_h.min), HeightmapToArea(rect_h.max));

      for(int ay=rect_a.min.y; ay<=rect_a.max.y; ay++) // iterate areas
      for(int ax=rect_a.min.x; ax<=rect_a.max.x; ax++)
      {
         VecI2 a(ax,ay);
         if(Area *data=GetArea(*world, a))
         {
            bool  modified=data.modified();
            RectI ah =AreaToHeightmap(a), // area heightmap
                  ahi=ah&rect_h;          // area heightmap intersection
            for(int hy=ahi.min.y; hy<=ahi.max.y; hy++) // iterate area heightmap
            for(int hx=ahi.min.x; hx<=ahi.max.x; hx++)
            {
               int ix=hx-rect_h.min.x, iy=hy-rect_h.min.y, // image
                   lx=hx-    ah.min.x, ly=hy-    ah.min.y; // local
               data.heightmap.changeHeight(lx, ly, delta.pixel(ix, iy)-128);
               final.pixel(ix, iy, data.heightmap.getHeight(lx, ly));
            }
            if(!modified)Server.areaModified(*data);
            REPA(data.clients)clients.include(data.clients[i]);

               height_vers.add(data.heightmap.ver.height_uid);
         }else height_vers.New().zero();
      }
      File f; ServerWriteSetHeight(f, pos, final, height_vers); Distribute(clients, f);
   }
}
/******************************************************************************/
void SetMaterial(Net.World *world, C VecI2 &pos, C MaterialPtr &material)
{
   if(Cuts(pos, WorldBoundsHeightmap))
      if(world)
   {
      int   hm_res=HmRes;
      VecI2 area  (DivFloor(pos.x, hm_res), DivFloor(pos.y, hm_res)),
            local (     Mod(pos.x, hm_res),      Mod(pos.y, hm_res));

      if(Area *data=GetArea(*world, area)) // center
      {
         bool modified=data.modified(); data.heightmap.setMaterial(local.x, local.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, area, local, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
      }

      if(local.x<=0) // left
      {
         VecI2 a(area.x-1, area.y); if(Area *data=GetArea(*world, a))
         {
            bool modified=data.modified(); VecI2 l(hm_res, local.y); data.heightmap.setMaterial(l.x, l.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, a, l, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
         }

         if(local.y<=0) // left back
         {
            VecI2 a(area.x-1, area.y-1); if(Area *data=GetArea(*world, a))
            {
               bool modified=data.modified(); VecI2 l(hm_res, hm_res); data.heightmap.setMaterial(l.x, l.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, a, l, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
            }
         }
      }

      if(local.y<=0) // back
      {
         VecI2 a(area.x, area.y-1); if(Area *data=GetArea(*world, a))
         {
            bool modified=data.modified(); VecI2 l(local.x, hm_res); data.heightmap.setMaterial(l.x, l.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, a, l, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
         }
      }
   }
}
/******************************************************************************/
void SetGrass(Net.World *world, C Game.ObjParamsPtr &obj, C VecI2 &area_xy, Grass.Type.Instance &instance)
{
   if(Cuts(area_xy, WorldBoundsAreas))
      if(world)
         if(Area *area=GetArea(*world, area_xy))
   {
      bool modified=area.modified();
      area.grass.set(obj, instance); // set grass
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetGrass(f, obj, area_xy, instance, area.grass.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetBlock(Net.World *world, C VecI &pos, C MaterialPtr &material)
{
   if(Cuts(pos, WorldBoundsBlocks))
      if(world)
         if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      bool modified=area.modified();
      VecI local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      {
      #pragma FIXME // check if can be performed
         area.blocks.set(local.x, local.y, local.z, material); // set block
      }
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetBlock(f, pos, area.blocks.material(local), area.blocks.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetObj(Net.World *world, C VecI &pos, flt angle, C Game.ObjParamsPtr &obj)
{
   if(Cuts(pos, WorldBoundsBlocks))
      if(world)
         if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      bool modified=area.modified();
      Pos  local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      {
      #pragma FIXME // check if can be performed
         area.objects.set(local.x, local.y, local.z, *area, angle, obj); // set object
      }
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetObj(f, pos, area.objects.findObj(local), area.objects.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetGroundObj(Net.World *world, C VecI &pos, flt angle, C Game.ObjParamsPtr &obj)
{
   if(Cuts(pos, WorldBoundsBlocks))
      if(world)
         if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      bool modified=area.modified();
      Pos  local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      {
      #pragma FIXME // check if can be performed
         area.ground_objects.set(local.x, local.z, *area, angle, obj); // set object
      }
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetGroundObj(f, pos, area.ground_objects.findObj(local), area.ground_objects.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetObjState(Net.World *world, C VecI &pos, int obj_type, File &f)
{
   if(world && Cuts(pos, WorldBoundsBlocks) && GetObjContainer(obj_type))
      if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      Pos local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      area.objects.state(local, obj_type, f, null); // set object state
   }
}
/******************************************************************************/
void SetGroundObjState(Net.World *world, C VecI &pos, int obj_type, File &f)
{
   if(world && Cuts(pos, WorldBoundsBlocks) && GetObjContainer(obj_type))
      if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      Pos local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      area.ground_objects.state(local, obj_type, f, null); // set object state
   }
}
/******************************************************************************/


Thanks smile I been over the video like 100 times trying to see where I went wrong and just can't seem to find it.
08-12-2013 11:43 PM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #24
RE: Ineisis -Detailed tutorials
simple typo my friend:

Net.World.replaceClass<World>();
should be
Net.Worlds.replaceClass<World>();

have fun!
08-13-2013 05:05 AM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #25
RE: Ineisis -Detailed tutorials
Oh Wow...
I can't believe it. I been though it a thousand times and couldn't figure it out. I guess I was in the zone.
Thanks so much for your help. Works like a charm smile

BTW Thank you for making these lessons. They really help!
And I like how you explained things on your charts. Its very clear smile
(This post was last modified: 08-13-2013 05:40 AM by Palaxe.)
08-13-2013 05:27 AM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #26
RE: Ineisis -Detailed tutorials
Thanks OZMODIAN for the second Video's
I just finished watching them and am going to attempt to make the changes on my test or learning server.
I was wondering if a player removed a tree, static obj that you placed in the world. would it respawn or is it gone forever?

P.S. The vids are great how did you figure out all this stuff smile
08-14-2013 06:10 AM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #27
RE: Ineisis -Detailed tutorials
It would be gone. The player has full control of the world still.

I am glad you liked them. I just finished my code for my next (way overdue) video. I will be covering water and grass in this video. Stay tuned.
08-14-2013 04:02 PM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #28
RE: Ineisis -Detailed tutorials
I hope I'm not being a pain.
I been working on this next part trying to figure this all out. And when I built it I keep running into the same error. I put it together twice and failed each time.

So this is my error,
Quote:E:\mark\Esenthel Engine - Copy\Projects\_Build_\Ineisis Server\Project 2010.vcxproj : warning : Platform 'x64' referenced in the project file 'Ineisis Server' cannot be found. Please make sure you have it installed under '%VCTargetsPath%\Platforms\x64'.
1>------ Build started: Project: Ineisis Server, Configuration: Debug Win32 ------
1> World.cpp
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\world.cpp(37): error C2065: 'EditorWorldID' : undeclared identifier
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\world.cpp(76): error C3861: 'LoadEditorworld': identifier not found
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\world.cpp(183): warning C4068: unknown pragma
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\world.cpp(200): warning C4068: unknown pragma
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\world.cpp(217): warning C4068: unknown pragma
1> Load Static.cpp
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\load static.cpp(21): warning C4390: ';' : empty controlled statement found; is this the intent?
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\load static.cpp(26): error C2039: 'del' : is not a member of 'EE::Game::Obj'
1> e:\mark\esenthel engine - copy\bin\esenthelengine\game\object.h(12) : see declaration of 'EE::Game::Obj'
1>e:\mark\esenthel engine - copy\projects\_build_\ineisis server\source\load static.cpp(26): error C3861: 'del': identifier not found
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

And here is my codes that I changed.
Code:
/******************************************************************************/
class World : Net.World
{
   static void Save(Cell<Net.Area> &net_area, ptr user)
   {
      if(Area *area=net_area.cast<Area>())area.saveChanges();
   }

   flt hmHeight(C Vec2 &xz, bool smooth=true)
   {
      if(Cell<Net.Area> *grid=T.grid.find(worldToArea(xz)))if(Area *area=grid.cast<Area>())return area.hmHeight(xz, smooth);
      return 0;
   }

   World()
   {
      areaSize(AreaSize);
      grid.replaceClass<Area>();
   }
  ~World()
   {
      // save changes before closing
      FCreateDirs(dataPath()+"Area");
      grid.func(Save);
   }
}
/******************************************************************************/
const bool UpdateWorldFormat=false; // use this to re-save all areas at server startup, and immediately close the server app after it
/******************************************************************************/
Area* GetArea(Net.World &world, C VecI2 &xy) {return world.grid.get(xy).cast<Area>();} // get world area casted to 'Area' class
/******************************************************************************/
void LoadWorld(C UID &world_id) // load all areas of 'world_id' world into memory
{
   Net.World &world   =*Net.Worlds(world_id);
   Str        area_dir= world.dataPath()+"Area";
   for(FileFind ff(area_dir); ff(); )
      if(!Contains(ff.name, '@'))
   {
      VecI2 xy=TextVecI2(ff.name);
      if(Area *area=GetArea(world,xy))
      {
         area.load(ff.pathName());
       //area.heightmap.fillHoles(UID(10409022, 1195409879, 1143007153, 3722121309));
         if(UpdateWorldFormat)area.save(ff.pathName());
      }
   }
}
void SetWorldAreas()
{
   Net.World &world=*Net.Worlds(MainWorldID);
   int        areas=Areas+1;
   for(int x=-areas; x<areas; x++)
   for(int y=-areas; y<areas; y++)if(Area *area=GetArea(world, VecI2(x, y)))area.heightmap.create(UID(10409022, 1195409879, 1143007153, 3722121309));
}
void LoadWorldFromEditor(C UID &world_id)
{
   Net.World &world = *Net.Worlds(world_id);
   Game.ObjMemx<CustStatic> Items;
   Game.World.mode(Game.WORLD_MANUAL);
   Game.World.setObjType(Items, OBJ_STATIC)
             .New(EditorWorldID);
   int        areas=Areas+1;
   for(int x=-areas; x<areas; x++)
      for(int y=-areas; y<areas; y++)
      {
         VecI2 a(x, y);
         Memc<Game.WorldManager.AreaState> areastates;
         areastates.New().set(a, Game.AREA_INACTIVE);
         Game.World.areaSetState(areastates, true);
         Game.Area* the_area = Game.World.areaLoaded(a);
         Area *data=GetArea(world, VecI2(x, y));
         Image &temp_image = the_area.getData().height;
         Image &temp_image2 = the_area.getData().material_map;
         RectI ah = RectI(VecI2(0, 0), VecI2(HmRes+1, HmRes+1));
         for(int hy=ah.min.y;  hy<=ah.max.y; hy++)
            for(int hx=ah.min.x;  hx<=ah.max.x; hx++)
               {    
                   data.heightmap.setHeight(hx, hy, (the_area.data().height.pixelFI(hx, hy)+128));
                 data.heightmap.setMaterial(hx, hy,  (the_area.getData().materials[temp_image2.pixel(hx, hy)]));
               }  
                    
    
         if(Items.elms())
         {
            REPA(Items)
            {
               VecI local(Items[i].pos().x, Items[i].pos().y, Items[i].pos().z);
               SetObj(&world, local, Items[i].matrix().angle(), Items[i].get_ID());
            }
         }
      }
      Game.World.del();
      
}
void InitWorld()
{
   Net.Worlds.replaceClass<World>();
   SetWorldAreas();
   LoadWorld(MainWorldID);
   LoadEditorworld(MainWorldID);
}
void ShutWorld()
{
   Net.Worlds.del(); // delete manually before resource caches are deleted (to have access to resource paths)
}
/******************************************************************************/
void ChangeHeight(Net.World *world, C VecI2 &pos, Image &delta) // must be synced with Client.SetHeightServer
{
   if(world)
   {
      Image final; final.createSoft(delta.x(), delta.y(), 1, IMAGE_I8);
      Memc<Client*> clients;
      Memc<Ver    > height_vers;

      RectI rect_h=RectI(pos.x, pos.y, pos.x+delta.x()-1, pos.y+delta.y()-1)&WorldBoundsHeightmap,
            rect_a(HeightmapToArea(rect_h.min), HeightmapToArea(rect_h.max));

      for(int ay=rect_a.min.y; ay<=rect_a.max.y; ay++) // iterate areas
      for(int ax=rect_a.min.x; ax<=rect_a.max.x; ax++)
      {
         VecI2 a(ax,ay);
         if(Area *data=GetArea(*world, a))
         {
            bool  modified=data.modified();
            RectI ah =AreaToHeightmap(a), // area heightmap
                  ahi=ah&rect_h;          // area heightmap intersection
            for(int hy=ahi.min.y; hy<=ahi.max.y; hy++) // iterate area heightmap
            for(int hx=ahi.min.x; hx<=ahi.max.x; hx++)
            {
               int ix=hx-rect_h.min.x, iy=hy-rect_h.min.y, // image
                   lx=hx-    ah.min.x, ly=hy-    ah.min.y; // local
               data.heightmap.changeHeight(lx, ly, delta.pixel(ix, iy)-128);
               final.pixel(ix, iy, data.heightmap.getHeight(lx, ly));
            }
            if(!modified)Server.areaModified(*data);
            REPA(data.clients)clients.include(data.clients[i]);

               height_vers.add(data.heightmap.ver.height_uid);
         }else height_vers.New().zero();
      }
      File f; ServerWriteSetHeight(f, pos, final, height_vers); Distribute(clients, f);
   }
}
/******************************************************************************/
void SetMaterial(Net.World *world, C VecI2 &pos, C MaterialPtr &material)
{
   if(Cuts(pos, WorldBoundsHeightmap))
      if(world)
   {
      int   hm_res=HmRes;
      VecI2 area  (DivFloor(pos.x, hm_res), DivFloor(pos.y, hm_res)),
            local (     Mod(pos.x, hm_res),      Mod(pos.y, hm_res));

      if(Area *data=GetArea(*world, area)) // center
      {
         bool modified=data.modified(); data.heightmap.setMaterial(local.x, local.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, area, local, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
      }

      if(local.x<=0) // left
      {
         VecI2 a(area.x-1, area.y); if(Area *data=GetArea(*world, a))
         {
            bool modified=data.modified(); VecI2 l(hm_res, local.y); data.heightmap.setMaterial(l.x, l.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, a, l, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
         }

         if(local.y<=0) // left back
         {
            VecI2 a(area.x-1, area.y-1); if(Area *data=GetArea(*world, a))
            {
               bool modified=data.modified(); VecI2 l(hm_res, hm_res); data.heightmap.setMaterial(l.x, l.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, a, l, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
            }
         }
      }

      if(local.y<=0) // back
      {
         VecI2 a(area.x, area.y-1); if(Area *data=GetArea(*world, a))
         {
            bool modified=data.modified(); VecI2 l(local.x, hm_res); data.heightmap.setMaterial(l.x, l.y, material); if(!modified)Server.areaModified(*data); File f; ServerWriteSetMaterial(f, a, l, material, data.heightmap.ver.mtrl_uid); Distribute(data.clients, f); // send to clients
         }
      }
   }
}
/******************************************************************************/
void SetGrass(Net.World *world, C Game.ObjParamsPtr &obj, C VecI2 &area_xy, Grass.Type.Instance &instance)
{
   if(Cuts(area_xy, WorldBoundsAreas))
      if(world)
         if(Area *area=GetArea(*world, area_xy))
   {
      bool modified=area.modified();
      area.grass.set(obj, instance); // set grass
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetGrass(f, obj, area_xy, instance, area.grass.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetBlock(Net.World *world, C VecI &pos, C MaterialPtr &material)
{
   if(Cuts(pos, WorldBoundsBlocks))
      if(world)
         if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      bool modified=area.modified();
      VecI local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      {
      #pragma FIXME // check if can be performed
         area.blocks.set(local.x, local.y, local.z, material); // set block
      }
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetBlock(f, pos, area.blocks.material(local), area.blocks.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetObj(Net.World *world, C VecI &pos, flt angle, C Game.ObjParamsPtr &obj)
{
   if(Cuts(pos, WorldBoundsBlocks))
      if(world)
         if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      bool modified=area.modified();
      Pos  local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      {
      #pragma FIXME // check if can be performed
         area.objects.set(local.x, local.y, local.z, *area, angle, obj); // set object
      }
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetObj(f, pos, area.objects.findObj(local), area.objects.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetGroundObj(Net.World *world, C VecI &pos, flt angle, C Game.ObjParamsPtr &obj)
{
   if(Cuts(pos, WorldBoundsBlocks))
      if(world)
         if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      bool modified=area.modified();
      Pos  local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      {
      #pragma FIXME // check if can be performed
         area.ground_objects.set(local.x, local.z, *area, angle, obj); // set object
      }
      if(!modified)Server.areaModified(*area);
      File f; ServerWriteSetGroundObj(f, pos, area.ground_objects.findObj(local), area.ground_objects.ver); Distribute(area.clients, f); // send to clients
   }
}
/******************************************************************************/
void SetObjState(Net.World *world, C VecI &pos, int obj_type, File &f)
{
   if(world && Cuts(pos, WorldBoundsBlocks) && GetObjContainer(obj_type))
      if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      Pos local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      area.objects.state(local, obj_type, f, null); // set object state
   }
}
/******************************************************************************/
void SetGroundObjState(Net.World *world, C VecI &pos, int obj_type, File &f)
{
   if(world && Cuts(pos, WorldBoundsBlocks) && GetObjContainer(obj_type))
      if(Area *area=GetArea(*world, BlockToArea(pos)))
   {
      Pos local(Mod(pos.x, BlocksDim), pos.y, Mod(pos.z, BlocksDim));
      area.ground_objects.state(local, obj_type, f, null); // set object state
   }
}
/******************************************************************************/

And then my Static
Code:
class CustStatic : Game :: Static
{
   Game.ObjParams obj;
   void create(Game.ObjParams &obj)
   {
      super.create(obj);
      T.obj = obj;
   }
   C UID get_ID()
   {
      if (&obj);
      
      return obj.base().id();
      return UIDZero;
   }
  
   ~CustStatic()
   {
      Obj.del();
   }
   CustStatic (){};
}

So the editor says .New(EditorWorldID); Is the problem on the first error.
LoadEditorworld(MainWorldID); Identifier not found.
So its not seeing my main world that I made?
I'm lost on this one :(
If you would be so kind to explain to me where and why I'm going wrong I would really appreciate it.

Thanks for all your help smile
(This post was last modified: 08-15-2013 09:33 PM by Palaxe.)
08-15-2013 09:28 PM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #29
RE: Ineisis -Detailed tutorials
I am at work so i can't look at the details but i am pretty sure you just declared your editor world ID wrong. It should be in the Constants file. you need to set it to the UID of the world you created with the editor.
08-15-2013 09:52 PM
Find all posts by this user Quote this message in a reply
Palaxe Offline
Member

Post: #30
RE: Ineisis -Detailed tutorials
LOL.. I'm at work as well. When I get home I'll take a look at that as well.
Thanks for the help and reply.
08-15-2013 10:51 PM
Find all posts by this user Quote this message in a reply
Post Reply