diff options
author | UbitUmarov | 2019-11-17 15:01:21 +0000 |
---|---|---|
committer | UbitUmarov | 2019-11-17 15:01:21 +0000 |
commit | 103ebac0823b78934d60cb06cdaf97b817f29534 (patch) | |
tree | c6df753f2f8a56b4c334f33878b1e7464fe13646 | |
parent | remove some llUDP options (diff) | |
download | opensim-SC-103ebac0823b78934d60cb06cdaf97b817f29534.zip opensim-SC-103ebac0823b78934d60cb06cdaf97b817f29534.tar.gz opensim-SC-103ebac0823b78934d60cb06cdaf97b817f29534.tar.bz2 opensim-SC-103ebac0823b78934d60cb06cdaf97b817f29534.tar.xz |
terrain: make sure modify does get unblocked
-rwxr-xr-x | OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | 237 |
1 files changed, 122 insertions, 115 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 8f60d2f..f29011e 100755 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -1336,156 +1336,163 @@ namespace OpenSim.Region.CoreModules.World.Terrain | |||
1336 | if(now < NextModifyTerrainTime) | 1336 | if(now < NextModifyTerrainTime) |
1337 | return; | 1337 | return; |
1338 | 1338 | ||
1339 | NextModifyTerrainTime = double.MaxValue; // block it | 1339 | try |
1340 | |||
1341 | //m_log.DebugFormat("brushs {0} seconds {1} height {2}, parcel {3}", brushSize, seconds, height, parcelLocalID); | ||
1342 | bool god = m_scene.Permissions.IsGod(user); | ||
1343 | bool allowed = false; | ||
1344 | if (north == south && east == west) | ||
1345 | { | 1340 | { |
1346 | if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) | 1341 | NextModifyTerrainTime = double.MaxValue; // block it |
1342 | |||
1343 | //m_log.DebugFormat("brushs {0} seconds {1} height {2}, parcel {3}", brushSize, seconds, height, parcelLocalID); | ||
1344 | bool god = m_scene.Permissions.IsGod(user); | ||
1345 | bool allowed = false; | ||
1346 | if (north == south && east == west) | ||
1347 | { | 1347 | { |
1348 | bool[,] allowMask = new bool[m_channel.Width, m_channel.Height]; | 1348 | if (m_painteffects.ContainsKey((StandardTerrainEffects)action)) |
1349 | { | ||
1350 | bool[,] allowMask = new bool[m_channel.Width, m_channel.Height]; | ||
1349 | 1351 | ||
1350 | allowMask.Initialize(); | 1352 | allowMask.Initialize(); |
1351 | 1353 | ||
1352 | int startX = (int)(west - brushSize + 0.5); | 1354 | int startX = (int)(west - brushSize + 0.5); |
1353 | if (startX < 0) | 1355 | if (startX < 0) |
1354 | startX = 0; | 1356 | startX = 0; |
1355 | 1357 | ||
1356 | int startY = (int)(north - brushSize + 0.5); | 1358 | int startY = (int)(north - brushSize + 0.5); |
1357 | if (startY < 0) | 1359 | if (startY < 0) |
1358 | startY = 0; | 1360 | startY = 0; |
1359 | 1361 | ||
1360 | int endX = (int)(west + brushSize + 0.5); | 1362 | int endX = (int)(west + brushSize + 0.5); |
1361 | if (endX >= m_channel.Width) | 1363 | if (endX >= m_channel.Width) |
1362 | endX = m_channel.Width - 1; | 1364 | endX = m_channel.Width - 1; |
1363 | int endY = (int)(north + brushSize + 0.5); | 1365 | int endY = (int)(north + brushSize + 0.5); |
1364 | if (endY >= m_channel.Height) | 1366 | if (endY >= m_channel.Height) |
1365 | endY = m_channel.Height - 1; | 1367 | endY = m_channel.Height - 1; |
1366 | 1368 | ||
1367 | int x, y; | 1369 | int x, y; |
1368 | 1370 | ||
1369 | for (x = startX; x <= endX; x++) | 1371 | for (x = startX; x <= endX; x++) |
1370 | { | ||
1371 | for (y = startY; y <= endY; y++) | ||
1372 | { | 1372 | { |
1373 | if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1))) | 1373 | for (y = startY; y <= endY; y++) |
1374 | { | 1374 | { |
1375 | allowMask[x, y] = true; | 1375 | if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1))) |
1376 | allowed = true; | 1376 | { |
1377 | allowMask[x, y] = true; | ||
1378 | allowed = true; | ||
1379 | } | ||
1377 | } | 1380 | } |
1378 | } | 1381 | } |
1382 | if (allowed) | ||
1383 | { | ||
1384 | StoreUndoState(); | ||
1385 | m_painteffects[(StandardTerrainEffects) action].PaintEffect( | ||
1386 | m_channel, allowMask, west, south, height, brushSize, seconds, | ||
1387 | startX, endX, startY, endY); | ||
1388 | |||
1389 | //block changes outside estate limits | ||
1390 | if (!god) | ||
1391 | EnforceEstateLimits(startX, endX, startY, endY); | ||
1392 | } | ||
1379 | } | 1393 | } |
1380 | if (allowed) | 1394 | else |
1381 | { | 1395 | { |
1382 | StoreUndoState(); | 1396 | m_log.Debug("Unknown terrain brush type " + action); |
1383 | m_painteffects[(StandardTerrainEffects) action].PaintEffect( | ||
1384 | m_channel, allowMask, west, south, height, brushSize, seconds, | ||
1385 | startX, endX, startY, endY); | ||
1386 | |||
1387 | //block changes outside estate limits | ||
1388 | if (!god) | ||
1389 | EnforceEstateLimits(startX, endX, startY, endY); | ||
1390 | } | 1397 | } |
1391 | } | 1398 | } |
1392 | else | 1399 | else |
1393 | { | 1400 | { |
1394 | m_log.Debug("Unknown terrain brush type " + action); | 1401 | if (m_floodeffects.ContainsKey((StandardTerrainEffects)action)) |
1395 | } | ||
1396 | } | ||
1397 | else | ||
1398 | { | ||
1399 | if (m_floodeffects.ContainsKey((StandardTerrainEffects)action)) | ||
1400 | { | ||
1401 | bool[,] fillArea = new bool[m_channel.Width, m_channel.Height]; | ||
1402 | fillArea.Initialize(); | ||
1403 | |||
1404 | int startX = (int)west; | ||
1405 | int startY = (int)south; | ||
1406 | int endX = (int)east; | ||
1407 | int endY = (int)north; | ||
1408 | |||
1409 | if (startX < 0) | ||
1410 | startX = 0; | ||
1411 | else if (startX >= m_channel.Width) | ||
1412 | startX = m_channel.Width - 1; | ||
1413 | |||
1414 | if (endX < 0) | ||
1415 | endX = 0; | ||
1416 | else if (endX >= m_channel.Width) | ||
1417 | endX = m_channel.Width - 1; | ||
1418 | |||
1419 | if (startY < 0) | ||
1420 | startY = 0; | ||
1421 | else if (startY >= m_channel.Height) | ||
1422 | startY = m_channel.Height - 1; | ||
1423 | |||
1424 | if (endY < 0) | ||
1425 | endY = 0; | ||
1426 | else if (endY >= m_channel.Height) | ||
1427 | endY = m_channel.Height - 1; | ||
1428 | |||
1429 | int x, y; | ||
1430 | if (parcelLocalID == -1) | ||
1431 | { | 1402 | { |
1432 | for (x = startX; x <= endX; x++) | 1403 | bool[,] fillArea = new bool[m_channel.Width, m_channel.Height]; |
1404 | fillArea.Initialize(); | ||
1405 | |||
1406 | int startX = (int)west; | ||
1407 | int startY = (int)south; | ||
1408 | int endX = (int)east; | ||
1409 | int endY = (int)north; | ||
1410 | |||
1411 | if (startX < 0) | ||
1412 | startX = 0; | ||
1413 | else if (startX >= m_channel.Width) | ||
1414 | startX = m_channel.Width - 1; | ||
1415 | |||
1416 | if (endX < 0) | ||
1417 | endX = 0; | ||
1418 | else if (endX >= m_channel.Width) | ||
1419 | endX = m_channel.Width - 1; | ||
1420 | |||
1421 | if (startY < 0) | ||
1422 | startY = 0; | ||
1423 | else if (startY >= m_channel.Height) | ||
1424 | startY = m_channel.Height - 1; | ||
1425 | |||
1426 | if (endY < 0) | ||
1427 | endY = 0; | ||
1428 | else if (endY >= m_channel.Height) | ||
1429 | endY = m_channel.Height - 1; | ||
1430 | |||
1431 | int x, y; | ||
1432 | if (parcelLocalID == -1) | ||
1433 | { | 1433 | { |
1434 | for (y = startY; y <= endY; y++) | 1434 | for (x = startX; x <= endX; x++) |
1435 | { | 1435 | { |
1436 | if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1))) | 1436 | for (y = startY; y <= endY; y++) |
1437 | { | 1437 | { |
1438 | fillArea[x, y] = true; | 1438 | if (m_scene.Permissions.CanTerraformLand(user, new Vector3(x, y, -1))) |
1439 | allowed = true; | 1439 | { |
1440 | fillArea[x, y] = true; | ||
1441 | allowed = true; | ||
1442 | } | ||
1440 | } | 1443 | } |
1441 | } | 1444 | } |
1442 | } | 1445 | } |
1443 | } | 1446 | else |
1444 | else | ||
1445 | { | ||
1446 | if (!m_scene.Permissions.CanTerraformLand(user, new Vector3(-1, -1, parcelLocalID))) | ||
1447 | return; | ||
1448 | |||
1449 | ILandObject parcel = m_scene.LandChannel.GetLandObject(parcelLocalID); | ||
1450 | if(parcel == null) | ||
1451 | return; | ||
1452 | bool [,] parcelmap = parcel.GetLandBitmap(); | ||
1453 | //ugly | ||
1454 | for (x = startX; x <= endX; x++) | ||
1455 | { | 1447 | { |
1456 | int px = x >> 2; | 1448 | if (!m_scene.Permissions.CanTerraformLand(user, new Vector3(-1, -1, parcelLocalID))) |
1457 | y = startY; | 1449 | return; |
1458 | while( y <= endY) | 1450 | |
1451 | ILandObject parcel = m_scene.LandChannel.GetLandObject(parcelLocalID); | ||
1452 | if(parcel == null) | ||
1453 | return; | ||
1454 | |||
1455 | bool[,] parcelmap = parcel.GetLandBitmap(); | ||
1456 | //ugly | ||
1457 | for (x = startX; x <= endX; x++) | ||
1459 | { | 1458 | { |
1460 | int py = y >> 2; | 1459 | int px = x >> 2; |
1461 | bool inp = parcelmap[px, py]; | 1460 | y = startY; |
1462 | fillArea[x, y++] = inp; | 1461 | while( y <= endY) |
1463 | fillArea[x, y++] = inp; | 1462 | { |
1464 | fillArea[x, y++] = inp; | 1463 | int py = y >> 2; |
1465 | fillArea[x, y++] = inp; | 1464 | bool inp = parcelmap[px, py]; |
1465 | fillArea[x, y++] = inp; | ||
1466 | fillArea[x, y++] = inp; | ||
1467 | fillArea[x, y++] = inp; | ||
1468 | fillArea[x, y++] = inp; | ||
1469 | } | ||
1466 | } | 1470 | } |
1471 | |||
1472 | allowed = true; | ||
1467 | } | 1473 | } |
1468 | 1474 | ||
1469 | allowed = true; | 1475 | if (allowed) |
1470 | } | 1476 | { |
1477 | StoreUndoState(); | ||
1478 | m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, height, seconds, | ||
1479 | startX, endX, startY, endY); | ||
1471 | 1480 | ||
1472 | if (allowed) | 1481 | //block changes outside estate limits |
1482 | if (!god) | ||
1483 | EnforceEstateLimits(startX, endX, startY, endY); | ||
1484 | } | ||
1485 | } | ||
1486 | else | ||
1473 | { | 1487 | { |
1474 | StoreUndoState(); | 1488 | m_log.Debug("Unknown terrain flood type " + action); |
1475 | m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, height, seconds, | ||
1476 | startX, endX, startY, endY); | ||
1477 | |||
1478 | //block changes outside estate limits | ||
1479 | if (!god) | ||
1480 | EnforceEstateLimits(startX, endX, startY, endY); | ||
1481 | } | 1489 | } |
1482 | } | 1490 | } |
1483 | else | ||
1484 | { | ||
1485 | m_log.Debug("Unknown terrain flood type " + action); | ||
1486 | } | ||
1487 | } | 1491 | } |
1488 | NextModifyTerrainTime = Util.GetTimeStamp() + 0.02; // 20ms cooldown | 1492 | finally |
1493 | { | ||
1494 | NextModifyTerrainTime = Util.GetTimeStamp() + 0.02; // 20ms cooldown | ||
1495 | } | ||
1489 | } | 1496 | } |
1490 | 1497 | ||
1491 | private void client_OnBakeTerrain(IClientAPI remoteClient) | 1498 | private void client_OnBakeTerrain(IClientAPI remoteClient) |