aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Terrain/Features/RectangleFeature.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain/Features/RectangleFeature.cs')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Features/RectangleFeature.cs149
1 files changed, 0 insertions, 149 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Features/RectangleFeature.cs b/OpenSim/Region/CoreModules/World/Terrain/Features/RectangleFeature.cs
deleted file mode 100644
index 33c3fbe..0000000
--- a/OpenSim/Region/CoreModules/World/Terrain/Features/RectangleFeature.cs
+++ /dev/null
@@ -1,149 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenSim.Region.CoreModules.World.Terrain;
30using OpenSim.Region.Framework.Interfaces;
31
32namespace OpenSim.Region.CoreModules.World.Terrain.Features
33{
34 public class RectangleFeature : TerrainFeature
35 {
36 public RectangleFeature(ITerrainModule module) : base(module)
37 {
38 }
39
40 public override string CreateFeature(ITerrainChannel map, string[] args)
41 {
42 string val;
43 string result;
44 if (args.Length < 7)
45 {
46 result = "Usage: " + GetUsage();
47 }
48 else
49 {
50 result = String.Empty;
51
52 float targetElevation;
53 val = base.parseFloat(args[3], out targetElevation);
54 if (val != String.Empty)
55 {
56 result = val;
57 }
58
59 int xOrigin;
60 val = base.parseInt(args[4], out xOrigin);
61 if (val != String.Empty)
62 {
63 result = val;
64 }
65 else if (xOrigin < 0 || xOrigin >= map.Width)
66 {
67 result = "x-origin must be within the region";
68 }
69
70 int yOrigin;
71 val = base.parseInt(args[5], out yOrigin);
72 if (val != String.Empty)
73 {
74 result = val;
75 }
76 else if (yOrigin < 0 || yOrigin >= map.Height)
77 {
78 result = "y-origin must be within the region";
79 }
80
81 int xDelta;
82 val = base.parseInt(args[6], out xDelta);
83 if (val != String.Empty)
84 {
85 result = val;
86 }
87 else if (xDelta <= 0)
88 {
89 result = "x-size must be greater than zero";
90 }
91
92 int yDelta;
93 if (args.Length > 7)
94 {
95 val = base.parseInt(args[7], out yDelta);
96 if (val != String.Empty)
97 {
98 result = val;
99 }
100 else if (yDelta <= 0)
101 {
102 result = "y-size must be greater than zero";
103 }
104 }
105 else
106 {
107 // no y-size.. make it square
108 yDelta = xDelta;
109 }
110
111 // slightly more complex validation, if required.
112 if (result == String.Empty)
113 {
114 if (xOrigin + xDelta > map.Width)
115 {
116 result = "(x-origin + x-size) must be within the region size";
117 }
118 else if (yOrigin + yDelta > map.Height)
119 {
120 result = "(y-origin + y-size) must be within the region size";
121 }
122 }
123
124 // if it's all good, then do the work
125 if (result == String.Empty)
126 {
127 int yPos = yOrigin + yDelta;
128 while(--yPos >= yOrigin)
129 {
130 int xPos = xOrigin + xDelta;
131 while(--xPos >= xOrigin)
132 {
133 map[xPos, yPos] = (double)targetElevation;
134 }
135 }
136 }
137 }
138
139 return result;
140 }
141
142 public override string GetUsage()
143 {
144 return "rectangle <height> <x-origin> <y-origin> <x-size> [<y-size>]";
145 }
146 }
147
148}
149