Manic Digger

It is currently Tue Oct 24, 2017 4:02 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Added the ability to define areas where users can build.
PostPosted: Wed May 04, 2011 1:56 pm 
Offline

Joined: Mon Mar 14, 2011 2:42 pm
Posts: 136
Jek2,

The latest nightly has fixed most of the issues.

Also I mis-spoke earlier. The area config works on most restrictive. So if you want an admin area in the middle, you can define one. Here is my config for my server for example:
Code:
  <Areas>
    <Area>
      <Coords>0,0,10000,5000</Coords>
      <PermittedUsers>[User]</PermittedUsers>
    </Area>
    <Area>
      <Coords>0,5001,10000,10000</Coords>
      <PermittedUsers>[Builder]</PermittedUsers>
    </Area>
    <Area>
      <Coords>4990,4990,5010,5010</Coords>
      <PermittedUsers>[Admin]</PermittedUsers>
    </Area>
  </Areas>

You may want to change [User] to [Guest] for yours if you want anyone to be able to build and not just users registered on fragmer.net.


Top
 Profile  
 
 Post subject: Re: Added the ability to define areas where users can build.
PostPosted: Wed May 04, 2011 5:38 pm 
Offline
User avatar

Joined: Fri Apr 29, 2011 11:46 am
Posts: 64
Thanks!!! HAS very much helped))))))))))))) :D :roll:

_________________
I am the one who I am.


Top
 Profile  
 
 Post subject: Re: Added the ability to define areas where users can build.
PostPosted: Mon May 09, 2011 7:47 am 
Offline
Site Admin

Joined: Mon Jun 21, 2010 12:02 pm
Posts: 394
On 4 may 2011 I also added the updated patch.


Top
 Profile  
 
 Post subject: Re: Added the ability to define areas where users can build.
PostPosted: Sun Aug 07, 2011 11:13 am 
Offline
User avatar

Joined: Thu Apr 21, 2011 7:29 pm
Posts: 335
Code:
  <Areas>
    <Area>
      <Coords>0,0,10000,5000</Coords>
      <PermittedUsers>[Builder]</PermittedUsers>
    </Area>
    <Area>
      <Coords>0,5001,10000,10000</Coords>
      <PermittedUsers>[Builder]</PermittedUsers>
    </Area>
  </Areas>


That doesn't work. Even though I set both zones to [Builder], anyone can build. MD Version: 2011-07-14.

_________________
Uwielbiam creepery, przy nich można się naprawdę rozerwać!
Song for all minecraft fanboys!


Top
 Profile  
 
 Post subject: Re: Added the ability to define areas where users can build.
PostPosted: Wed Aug 17, 2011 7:29 pm 
Offline

Joined: Fri Jul 08, 2011 10:55 pm
Posts: 159
Location: Karlsruhe, Germany
Hi,

I followed up a bit with the area definitions.
In older nightlies, it seemed that there is a problem. When the server starts, the function ServerConfig() is called twice and loading a default configuration. Unfortunately the default area configurations
Code:
  <Areas>
    <Area>
      <Coords>0,0,10000,5000</Coords>
      <PermittedUsers>[Guest]</PermittedUsers>
    </Area>
    <Area>
      <Coords>0,5001,10000,10000</Coords>
      <PermittedUsers>[Builder]</PermittedUsers>
    </Area>
  </Areas>

are being saved into the area list (config.Areas) , additionally to your own area definitions in the ServerConfig.xml.
So it can happen that the definitions are in conflict and provoke that your own definition don't work.
A fast rectification is simply to comment out the following lines in the ServerConfig().
Code:
            AreaConfig publicArea = new AreaConfig();
            publicArea.Coords = "0,0,10000,5000";
            publicArea.PermittedUsers = "[Guest]";
            this.Areas.Add(publicArea);
            AreaConfig builderArea = new AreaConfig();
            builderArea.Coords = "0,5001,10000,10000";
            builderArea.PermittedUsers = "[Builder]";
            this.Areas.Add(builderArea);

I saw that this was done in the latest nightly. However I don't know if that is a proper solution.
Is it really necessary to load a default configuration on start and even two times in succession?

Anyway, there are other sections which made me musing:

Can't the if statement in the following function
Code:
        public bool IsInCoords(int x, int y)
        {
            if (x >= Math.Min(x1, x2) && x <= Math.Max(x1, x2) && y >= Math.Min(y1, y2) && y <= Math.Max(y1, y2))   
            {
                return true;
            }
            else
            {
                return false;
            }
        }

not just being replaced with
Code:
if (x >= x1 && x <= x2 && y >= y1 && y <= y2)

?

I also replaced the implementation of the function
Code:
        public bool CanUserBuild(ManicDiggerServer.Server.Client client, int x, int y)
        {
            bool canBuild = true;
            foreach (AreaConfig area in this.Areas)
            {
                if (area.IsInCoords(x, y))
                {
                    if (!area.CanUserBuild(client))
                    {
                        return false;
                    }
                }
            }
            return canBuild;
        }

with
Code:
        public bool CanUserBuild(ManicDiggerServer.Server.Client client, int x, int y)
        {         
            bool canBuild = false;
            foreach (AreaConfig area in this.Areas)
            {
                if (area.IsInCoords(x, y))
                {
                    if (area.CanUserBuild(client))
                    {
                        return true;
                    }
                }
            }
            return canBuild;
        }

Isn't it better to just look up if there is a defined area containing the current player position and check if the player can build there, instead of searching for an area definition where the player can't build?

Anyway, after that few changes, the area definitions seemed finally to work.
Here is how it could look like:
Image

Uploaded with ImageShack.us.

At the moment, I am working on a command to assign areas in game.


Regards

Edit:
Oh, I was wrong. I guess it is surely better to check if there is an area at the current position where the player can't build.
So you can define overlapping areas, e.g. an area assigned to a certain person inside a bigger builder area.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group