Rewrite Check to be a struct.

This commit is contained in:
UnknownShadow200 2016-04-15 08:53:46 +10:00
parent 488d80bb2e
commit b87366394b
23 changed files with 173 additions and 166 deletions

View File

@ -40,7 +40,7 @@ namespace MCGalaxy {
/// <summary> Called to handle the physics for this particular block. </summary>
/// <remarks>If this returns true, the usual 'death check' behaviour is skipped. </remarks>
public delegate void HandlePhysics(Level lvl, Check C);
public delegate void HandlePhysics(Level lvl, ref Check C);
internal static HandlePhysics[] physicsHandlers = new Block.HandlePhysics[256];
internal static HandlePhysics[] physicsDoorsHandlers = new Block.HandlePhysics[256];
@ -90,9 +90,9 @@ namespace MCGalaxy {
physicsHandlers[Block.birdwhite] = BirdPhysics.Do;
physicsHandlers[Block.birdlava] = BirdPhysics.Do;
physicsHandlers[Block.birdwater] = BirdPhysics.Do;
physicsHandlers[Block.birdred] = (lvl, C) => HunterPhysics.DoKiller(lvl, C, Block.air);
physicsHandlers[Block.birdblue] = (lvl, C) => HunterPhysics.DoKiller(lvl, C, Block.air);
physicsHandlers[Block.birdkill] = (lvl, C) => HunterPhysics.DoKiller(lvl, C, Block.air);
physicsHandlers[Block.birdred] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.air);
physicsHandlers[Block.birdblue] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.air);
physicsHandlers[Block.birdkill] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.air);
physicsHandlers[Block.snaketail] = SnakePhysics.DoTail;
physicsHandlers[Block.snake] = SnakePhysics.Do;
@ -102,12 +102,12 @@ namespace MCGalaxy {
physicsHandlers[Block.zombiehead] = ZombiePhysics.DoHead;
physicsHandlers[Block.creeper] = ZombiePhysics.Do;
physicsHandlers[Block.fishbetta] = (lvl, C) => HunterPhysics.DoKiller(lvl, C, Block.water);
physicsHandlers[Block.fishshark] = (lvl, C) => HunterPhysics.DoKiller(lvl, C, Block.water);
physicsHandlers[Block.fishlavashark] = (lvl, C) => HunterPhysics.DoKiller(lvl, C, Block.lava);
physicsHandlers[Block.fishgold] = (lvl, C) => HunterPhysics.DoFlee(lvl, C, Block.water);
physicsHandlers[Block.fishsalmon] = (lvl, C) => HunterPhysics.DoFlee(lvl, C, Block.water);
physicsHandlers[Block.fishsponge] = (lvl, C) => HunterPhysics.DoFlee(lvl, C, Block.water);
physicsHandlers[Block.fishbetta] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.water);
physicsHandlers[Block.fishshark] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.water);
physicsHandlers[Block.fishlavashark] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.lava);
physicsHandlers[Block.fishgold] = (Level lvl, ref Check C) => HunterPhysics.DoFlee(lvl, ref C, Block.water);
physicsHandlers[Block.fishsalmon] = (Level lvl, ref Check C) => HunterPhysics.DoFlee(lvl, ref C, Block.water);
physicsHandlers[Block.fishsponge] = (Level lvl, ref Check C) => HunterPhysics.DoFlee(lvl, ref C, Block.water);
physicsHandlers[Block.water] = SimpleLiquidPhysics.DoWater;
physicsHandlers[Block.activedeathwater] = SimpleLiquidPhysics.DoWater;
@ -115,10 +115,10 @@ namespace MCGalaxy {
physicsHandlers[Block.activedeathlava] = SimpleLiquidPhysics.DoLava;
physicsHandlers[Block.WaterDown] = ExtLiquidPhysics.DoWaterfall;
physicsHandlers[Block.LavaDown] = ExtLiquidPhysics.DoLavafall;
physicsHandlers[Block.WaterFaucet] = (lvl, C) =>
ExtLiquidPhysics.DoFaucet(lvl, C, Block.WaterDown);
physicsHandlers[Block.LavaFaucet] = (lvl, C) =>
ExtLiquidPhysics.DoFaucet(lvl, C, Block.LavaDown);
physicsHandlers[Block.WaterFaucet] = (Level lvl, ref Check C) =>
ExtLiquidPhysics.DoFaucet(lvl, ref C, Block.WaterDown);
physicsHandlers[Block.LavaFaucet] = (Level lvl, ref Check C) =>
ExtLiquidPhysics.DoFaucet(lvl, ref C, Block.LavaDown);
physicsHandlers[Block.finiteWater] = FinitePhysics.DoWaterOrLava;
physicsHandlers[Block.finiteLava] = FinitePhysics.DoWaterOrLava;
physicsHandlers[Block.finiteFaucet] = FinitePhysics.DoFaucet;
@ -138,22 +138,22 @@ namespace MCGalaxy {
physicsHandlers[Block.staircasestep] = OtherPhysics.DoStairs;
physicsHandlers[Block.wood_float] = OtherPhysics.DoFloatwood;
physicsHandlers[Block.sponge] = (lvl, C) => OtherPhysics.DoSponge(lvl, C, false);
physicsHandlers[Block.lava_sponge] = (lvl, C) => OtherPhysics.DoSponge(lvl, C, true);
physicsHandlers[Block.sponge] = (Level lvl, ref Check C) => OtherPhysics.DoSponge(lvl, ref C, false);
physicsHandlers[Block.lava_sponge] = (Level lvl, ref Check C) => OtherPhysics.DoSponge(lvl, ref C, true);
//Special blocks that are not saved
physicsHandlers[Block.air_flood] = (lvl, C) =>
AirPhysics.DoFlood(lvl, C, AirFlood.Full, Block.air_flood);
physicsHandlers[Block.air_flood_layer] = (lvl, C) =>
AirPhysics.DoFlood(lvl, C, AirFlood.Layer, Block.air_flood_layer);
physicsHandlers[Block.air_flood_down] = (lvl, C) =>
AirPhysics.DoFlood(lvl, C, AirFlood.Down, Block.air_flood_down);
physicsHandlers[Block.air_flood_up] = (lvl, C) =>
AirPhysics.DoFlood(lvl, C, AirFlood.Up, Block.air_flood_up);
physicsHandlers[Block.air_flood] = (Level lvl, ref Check C) =>
AirPhysics.DoFlood(lvl, ref C, AirFlood.Full, Block.air_flood);
physicsHandlers[Block.air_flood_layer] = (Level lvl, ref Check C) =>
AirPhysics.DoFlood(lvl, ref C, AirFlood.Layer, Block.air_flood_layer);
physicsHandlers[Block.air_flood_down] = (Level lvl, ref Check C) =>
AirPhysics.DoFlood(lvl, ref C, AirFlood.Down, Block.air_flood_down);
physicsHandlers[Block.air_flood_up] = (Level lvl, ref Check C) =>
AirPhysics.DoFlood(lvl, ref C, AirFlood.Up, Block.air_flood_up);
physicsHandlers[Block.smalltnt] = TntPhysics.DoSmallTnt;
physicsHandlers[Block.bigtnt] = (lvl, C) => TntPhysics.DoLargeTnt(lvl, C, 1);
physicsHandlers[Block.nuketnt] = (lvl, C) => TntPhysics.DoLargeTnt(lvl, C, 4);
physicsHandlers[Block.bigtnt] = (Level lvl, ref Check C) => TntPhysics.DoLargeTnt(lvl, ref C, 1);
physicsHandlers[Block.nuketnt] = (Level lvl, ref Check C) => TntPhysics.DoLargeTnt(lvl, ref C, 4);
physicsHandlers[Block.tntexplosion] = TntPhysics.DoTntExplosion;
physicsHandlers[Block.train] = TrainPhysics.Do;
@ -171,14 +171,14 @@ namespace MCGalaxy {
physicsHandlers[i] = DoorPhysics.odoorPhysics;
physicsDoorsHandlers[i] = DoorPhysics.odoorPhysics;
} else if (door == Block.door_tnt_air) {
physicsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4);
physicsDoorsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4);
physicsHandlers[door] = (Level lvl, ref Check C) => DoorPhysics.AnyDoor(lvl, ref C, 4);
physicsDoorsHandlers[door] = (Level lvl, ref Check C) => DoorPhysics.AnyDoor(lvl, ref C, 4);
} else if (door == Block.air_switch_air || door == Block.air_door_air) {
physicsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4, true);
physicsDoorsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 4, true);
physicsHandlers[door] = (Level lvl, ref Check C) => DoorPhysics.AnyDoor(lvl, ref C, 4, true);
physicsDoorsHandlers[door] = (Level lvl, ref Check C) => DoorPhysics.AnyDoor(lvl, ref C, 4, true);
} else if (door != Block.air) {
physicsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 16);
physicsDoorsHandlers[door] = (lvl, C) => DoorPhysics.AnyDoor(lvl, C, 16);
physicsHandlers[door] = (Level lvl, ref Check C) => DoorPhysics.AnyDoor(lvl, ref C, 16);
physicsDoorsHandlers[door] = (Level lvl, ref Check C) => DoorPhysics.AnyDoor(lvl, ref C, 16);
}
}
}

View File

@ -130,21 +130,21 @@ namespace MCGalaxy {
for (int i = 0; i < ListCheck.Count; i++) {
Check C = ListCheck.Items[i];
IntToPos(C.b, out x, out y, out z);
try {
PhysicsArgs info = C.data;
try {
if (PhysicsUpdate != null)
PhysicsUpdate(x, y, z, C.data.Data, info, this);
PhysicsUpdate(x, y, z, C.data, this);
if ((info.Raw & 0x3F) == 0 || ExtraInfoPhysics.DoDoorsOnly(this, C, null)) {
if ((C.data.Raw & 0x3F) == 0 || ExtraInfoPhysics.DoDoorsOnly(this, ref C, null)) {
Block.HandlePhysics handler = Block.physicsDoorsHandlers[blocks[C.b]];
if (handler != null)
handler(this, C);
else if ((info.Raw & 0x3F) == 0 || !info.HasWait)
handler(this, ref C);
else if ((C.data.Raw & 0x3F) == 0 || !C.data.HasWait)
C.data.Data = 255;
}
ListCheck.Items[i] = C;
} catch {
listCheckExists.Set(x, y, z, false);
ListCheck.Remove(C);
ListCheck.RemoveAt(i);
}
}
} else {
@ -152,22 +152,22 @@ namespace MCGalaxy {
Check C = ListCheck.Items[i];
IntToPos(C.b, out x, out y, out z);
try {
PhysicsArgs info = C.data;
if (PhysicsUpdate != null)
PhysicsUpdate(x, y, z, C.data.Data, info, this);
PhysicsUpdate(x, y, z, C.data, this);
if (OnPhysicsUpdateEvent.events.Count > 0)
OnPhysicsUpdateEvent.Call(x, y, z, C.data.Data, info, this);
OnPhysicsUpdateEvent.Call(x, y, z, C.data, this);
if ((info.Raw & 0x3F) == 0 || ExtraInfoPhysics.DoComplex(this, C)) {
if ((C.data.Raw & 0x3F) == 0 || ExtraInfoPhysics.DoComplex(this, ref C)) {
Block.HandlePhysics handler = Block.physicsHandlers[blocks[C.b]];
if (handler != null)
handler(this, C);
else if ((info.Raw & 0x3F) == 0 || !info.HasWait)
handler(this, ref C);
else if ((C.data.Raw & 0x3F) == 0 || !C.data.HasWait)
C.data.Data = 255;
}
ListCheck.Items[i] = C;
} catch {
listCheckExists.Set(x, y, z, false);
ListCheck.Remove(C);
ListCheck.RemoveAt(i);
}
}
}
@ -372,7 +372,7 @@ namespace MCGalaxy {
}
}
public class Check {
public struct Check {
public int b;
public PhysicsArgs data;

View File

@ -56,7 +56,7 @@ namespace MCGalaxy
public delegate void OnLevelUnload(Level l);
public delegate void OnPhysicsUpdate(ushort x, ushort y, ushort z, byte time, PhysicsArgs args, Level l);
public delegate void OnPhysicsUpdate(ushort x, ushort y, ushort z, PhysicsArgs args, Level l);
public delegate void OnPhysicsStateChanged(object sender, PhysicsState state);

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class AIPhysics {
public static Player ClosestPlayer(Level lvl, Check C) {
public static Player ClosestPlayer(Level lvl, ref Check C) {
if (!lvl.ai) return null;
int closestDist = 75;

View File

@ -22,7 +22,7 @@ namespace MCGalaxy.BlockPhysics {
public enum AirFlood { Full, Layer, Down, Up, }
public static class AirPhysics {
public static void DoAir(Level lvl, Check C) {
public static void DoAir(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -42,7 +42,7 @@ namespace MCGalaxy.BlockPhysics {
if (!C.data.HasWait) C.data.Data = 255;
}
public static void DoFlood(Level lvl, Check C, AirFlood mode, byte block) {
public static void DoFlood(Level lvl, ref Check C, AirFlood mode, byte block) {
Random rand = lvl.physRandom;
if (C.data.Data >= 1) {
lvl.AddUpdate(C.b, Block.air);

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class BirdPhysics {
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -40,27 +40,27 @@ namespace MCGalaxy.BlockPhysics {
case 3:
case 4:
case 5:
FlyTo(lvl, C, x - 1, y, z);
FlyTo(lvl, ref C, x - 1, y, z);
break;
case 6:
case 7:
case 8:
FlyTo(lvl, C, x + 1, y, z);
FlyTo(lvl, ref C, x + 1, y, z);
break;
case 9:
case 10:
case 11:
FlyTo(lvl, C, x, y, z - 1);
FlyTo(lvl, ref C, x, y, z - 1);
break;
default:
FlyTo(lvl, C, x, y, z + 1);
FlyTo(lvl, ref C, x, y, z + 1);
break;
}
lvl.AddUpdate(C.b, Block.air);
C.data.Data = 255;
}
static void FlyTo(Level lvl, Check C, int x, int y, int z) {
static void FlyTo(Level lvl, ref Check C, int x, int y, int z) {
int index = lvl.PosToInt((ushort)x, (ushort)y, (ushort)z);
if (index < 0)
return;

View File

@ -21,19 +21,19 @@ namespace MCGalaxy.BlockPhysics {
public static class DoorPhysics {
public static void odoorPhysics(Level lvl, Check C) {
public static void odoorPhysics(Level lvl, ref Check C) {
if (C.data.Data != 0) { C.data.Data = 0; return; }
odoorNeighbour(lvl, C, lvl.IntOffset(C.b, -1, 0, 0));
odoorNeighbour(lvl, C, lvl.IntOffset(C.b, +1, 0, 0));
odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, -1, 0));
odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, +1, 0));
odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, 0, -1));
odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, 0, +1));
odoorNeighbour(lvl, ref C, lvl.IntOffset(C.b, -1, 0, 0));
odoorNeighbour(lvl, ref C, lvl.IntOffset(C.b, +1, 0, 0));
odoorNeighbour(lvl, ref C, lvl.IntOffset(C.b, 0, -1, 0));
odoorNeighbour(lvl, ref C, lvl.IntOffset(C.b, 0, +1, 0));
odoorNeighbour(lvl, ref C, lvl.IntOffset(C.b, 0, 0, -1));
odoorNeighbour(lvl, ref C, lvl.IntOffset(C.b, 0, 0, +1));
C.data.Data++;
}
static void odoorNeighbour(Level lvl, Check C, int offset) {
static void odoorNeighbour(Level lvl, ref Check C, int offset) {
int index = C.b + offset;
byte block = Block.odoor(lvl.GetTile(index));
@ -42,11 +42,11 @@ namespace MCGalaxy.BlockPhysics {
}
//Change any door blocks nearby into door_air
public static void AnyDoor(Level lvl, Check C, int timer, bool instaUpdate = false) {
public static void AnyDoor(Level lvl, ref Check C, int timer, bool instaUpdate = false) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
if (C.data.Data != 0) {
CheckDoorRevert(lvl, C, timer); return;
CheckDoorRevert(lvl, ref C, timer); return;
}
PhysDoor(lvl, (ushort)(x + 1), y, z, instaUpdate);
@ -57,15 +57,15 @@ namespace MCGalaxy.BlockPhysics {
PhysDoor(lvl, x, (ushort)(y + 1), z, instaUpdate);
if (lvl.blocks[C.b] != Block.door_green_air) {
CheckDoorRevert(lvl, C, timer); return;
CheckDoorRevert(lvl, ref C, timer); return;
}
if (lvl.physics != 5)
ActivateNeighbours(lvl, C, x, y, z);
CheckDoorRevert(lvl, C, timer);
ActivateNeighbours(lvl, ref C, x, y, z);
CheckDoorRevert(lvl, ref C, timer);
}
static void ActivateNeighbours(Level lvl, Check C, ushort x, ushort y, ushort z) {
static void ActivateNeighbours(Level lvl, ref Check C, ushort x, ushort y, ushort z) {
for (int xx = -1; xx <= 1; xx++)
for (int yy = -1; yy <= 1; yy++)
for (int zz = -1; zz <= 1; zz++)
@ -101,7 +101,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
static void CheckDoorRevert(Level lvl, Check C, int timer) {
static void CheckDoorRevert(Level lvl, ref Check C, int timer) {
if (C.data.Data < timer) {
C.data.Data++;
} else {

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class ExtLiquidPhysics {
public static void DoMagma(Level lvl, Check C) {
public static void DoMagma(Level lvl, ref Check C) {
C.data.Data++;
if (C.data.Data < 3) return;
ushort x, y, z;
@ -59,7 +59,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoGeyser(Level lvl, Check C) {
public static void DoGeyser(Level lvl, ref Check C) {
C.data.Data++;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -96,7 +96,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoWaterfall(Level lvl, Check C) {
public static void DoWaterfall(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -124,7 +124,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoLavafall(Level lvl, Check C) {
public static void DoLavafall(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -152,7 +152,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoFaucet(Level lvl, Check C, byte target) {
public static void DoFaucet(Level lvl, ref Check C, byte target) {
C.data.Data++;
if (C.data.Data < 2) return;
C.data.Data = 0;

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class ExtraInfoPhysics {
public static bool DoDoorsOnly(Level lvl, Check C, Random rand) {
public static bool DoDoorsOnly(Level lvl, ref Check C, Random rand) {
if (!C.data.HasWait && lvl.blocks[C.b] == Block.air)
C.data.ResetTypes();
if (C.data.Type1 == PhysicsArgs.TntWars) return true;
@ -67,7 +67,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static bool DoComplex(Level lvl, Check C) {
public static bool DoComplex(Level lvl, ref Check C) {
if (!C.data.HasWait && lvl.blocks[C.b] == Block.air)
C.data.ResetTypes();
if (C.data.Type1 == PhysicsArgs.TntWars) return true;
@ -90,13 +90,13 @@ namespace MCGalaxy.BlockPhysics {
if (C.data.Data > args.WaitTime) {
if (C.data.Type1 == PhysicsArgs.Wait) C.data.Type1 = 0;
if (C.data.Type2 == PhysicsArgs.Wait) C.data.Type2 = 0;
DoOther(lvl, C, ref args);
DoOther(lvl, ref C, ref args);
return false;
}
C.data.Data++;
return true;
}
DoOther(lvl, C, ref args);
DoOther(lvl, ref C, ref args);
return false;
}
@ -117,11 +117,11 @@ namespace MCGalaxy.BlockPhysics {
}
}
static void DoOther(Level lvl, Check C, ref ExtraInfoArgs args) {
static void DoOther(Level lvl, ref Check C, ref ExtraInfoArgs args) {
Random rand = lvl.physRandom;
if (args.Rainbow) {
if (C.data.Data < 4) C.data.Data++;
else DoRainbow(lvl, C, rand, args.RainbowNum);
else DoRainbow(lvl, ref C, rand, args.RainbowNum);
return;
}
if (args.Revert) {
@ -150,10 +150,10 @@ namespace MCGalaxy.BlockPhysics {
}
if (args.Drop && rand.Next(1, 100) <= args.DropNum)
DoDrop(lvl, C, rand, args.DropNum, x, y, z);
DoDrop(lvl, ref C, rand, args.DropNum, x, y, z);
}
static void DoRainbow(Level lvl, Check C, Random rand, int rainbownum) {
static void DoRainbow(Level lvl, ref Check C, Random rand, int rainbownum) {
if (rainbownum > 2) {
byte block = lvl.blocks[C.b];
if (block < Block.red || block > Block.darkpink) {
@ -167,7 +167,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
static void DoDrop(Level lvl, Check C, Random rand, int dropnum, ushort x, ushort y, ushort z) {
static void DoDrop(Level lvl, ref Check C, Random rand, int dropnum, ushort x, ushort y, ushort z) {
int index = lvl.PosToInt(x, (ushort)(y - 1), z);
if (index < 0) return;

View File

@ -22,7 +22,7 @@ namespace MCGalaxy.BlockPhysics {
public static class FinitePhysics {
public unsafe static void DoWaterOrLava(Level lvl, Check C) {
public unsafe static void DoWaterOrLava(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -86,7 +86,7 @@ namespace MCGalaxy.BlockPhysics {
return false;
}
public unsafe static void DoFaucet(Level lvl, Check C) {
public unsafe static void DoFaucet(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);

View File

@ -54,7 +54,7 @@ namespace MCGalaxy.BlockPhysics {
lvl.MakeExplosion((ushort)x, (ushort)y, (ushort)z, -1);
}
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
if (C.data.Data < 2) {

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class FireworkPhysics {
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);

View File

@ -21,9 +21,9 @@ namespace MCGalaxy.BlockPhysics {
public static class HunterPhysics {
public static void DoKiller(Level lvl, Check C, byte target) {
public static void DoKiller(Level lvl, ref Check C, byte target) {
Random rand = lvl.physRandom;
Player closest = AIPhysics.ClosestPlayer(lvl, C);
Player closest = AIPhysics.ClosestPlayer(lvl, ref C);
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -36,7 +36,7 @@ namespace MCGalaxy.BlockPhysics {
case 3:
if ((closest.pos[0] / 32) - x != 0) {
index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (MoveFish(lvl, C, index, target)) return;
if (MoveFish(lvl, ref C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
@ -46,7 +46,7 @@ namespace MCGalaxy.BlockPhysics {
case 6:
if ((closest.pos[1] / 32) - y != 0) {
index = lvl.PosToInt(x, (ushort)(y + Math.Sign((closest.pos[1] / 32) - y)), z);
if (MoveFish(lvl, C, index, target)) return;
if (MoveFish(lvl, ref C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
@ -56,19 +56,19 @@ namespace MCGalaxy.BlockPhysics {
case 9:
if ((closest.pos[2] / 32) - z != 0) {
index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
if (MoveFish(lvl, C, index, target)) return;
if (MoveFish(lvl, ref C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
goto case 1;
}
}
RandomlyMove(lvl, C, rand, x, y, z, target);
RandomlyMove(lvl, ref C, rand, x, y, z, target);
}
public static void DoFlee(Level lvl, Check C, byte target) {
public static void DoFlee(Level lvl, ref Check C, byte target) {
Random rand = lvl.physRandom;
Player closest = AIPhysics.ClosestPlayer(lvl, C);
Player closest = AIPhysics.ClosestPlayer(lvl, ref C);
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -81,7 +81,7 @@ namespace MCGalaxy.BlockPhysics {
case 3:
if ((closest.pos[0] / 32) - x != 0) {
index = lvl.PosToInt((ushort)(x - Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (MoveFish(lvl, C, index, target)) return;
if (MoveFish(lvl, ref C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
@ -91,7 +91,7 @@ namespace MCGalaxy.BlockPhysics {
case 6:
if ((closest.pos[1] / 32) - y != 0) {
index = lvl.PosToInt(x, (ushort)(y - Math.Sign((closest.pos[1] / 32) - y)), z);
if (MoveFish(lvl, C, index, target)) return;
if (MoveFish(lvl, ref C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
@ -101,17 +101,17 @@ namespace MCGalaxy.BlockPhysics {
case 9:
if ((closest.pos[2] / 32) - z != 0) {
index = lvl.PosToInt(x, y, (ushort)(z - Math.Sign((closest.pos[2] / 32) - z)));
if (MoveFish(lvl, C, index, target)) return;
if (MoveFish(lvl, ref C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
goto case 1;
}
}
RandomlyMove(lvl, C, rand, x, y, z, target);
RandomlyMove(lvl, ref C, rand, x, y, z, target);
}
static bool MoveFish(Level lvl, Check C, int index, byte target) {
static bool MoveFish(Level lvl, ref Check C, int index, byte target) {
if (index >= 0 && lvl.blocks[index] == target && lvl.AddUpdate(index, lvl.blocks[C.b])) {
lvl.AddUpdate(C.b, target);
return true;
@ -119,33 +119,33 @@ namespace MCGalaxy.BlockPhysics {
return false;
}
static void RandomlyMove(Level lvl, Check C, Random rand, ushort x, ushort y, ushort z, byte target ) {
static void RandomlyMove(Level lvl, ref Check C, Random rand, ushort x, ushort y, ushort z, byte target ) {
switch (rand.Next(1, 15)) {
case 1:
if (MoveFish(lvl, C, lvl.PosToInt(x, (ushort)(y - 1), z), target)) return;
if (MoveFish(lvl, ref C, lvl.PosToInt(x, (ushort)(y - 1), z), target)) return;
goto case 3;
case 2:
if (MoveFish(lvl, C, lvl.PosToInt(x, (ushort)(y + 1), z), target)) return;
if (MoveFish(lvl, ref C, lvl.PosToInt(x, (ushort)(y + 1), z), target)) return;
goto case 6;
case 3:
case 4:
case 5:
if (MoveFish(lvl, C, lvl.PosToInt((ushort)(x - 1), y, z), target)) return;
if (MoveFish(lvl, ref C, lvl.PosToInt((ushort)(x - 1), y, z), target)) return;
goto case 9;
case 6:
case 7:
case 8:
if (MoveFish(lvl, C, lvl.PosToInt((ushort)(x + 1), y, z), target)) return;
if (MoveFish(lvl, ref C, lvl.PosToInt((ushort)(x + 1), y, z), target)) return;
goto case 12;
case 9:
case 10:
case 11:
MoveFish(lvl, C, lvl.PosToInt(x, y, (ushort)(z - 1)), target);
MoveFish(lvl, ref C, lvl.PosToInt(x, y, (ushort)(z - 1)), target);
break;
case 12:
case 13:
case 14:
MoveFish(lvl, C, lvl.PosToInt(x, y, (ushort)(z + 1)), target);
MoveFish(lvl, ref C, lvl.PosToInt(x, y, (ushort)(z + 1)), target);
break;
}
}

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class LeafPhysics {
public static void DoLeaf(Level lvl, Check C) {
public static void DoLeaf(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -41,11 +41,11 @@ namespace MCGalaxy.BlockPhysics {
if (rand.Next(10) == 0) C.data.Data++;
return;
}
if (DoLeafDecay(lvl, C)) lvl.AddUpdate(C.b, Block.air);
if (DoLeafDecay(lvl, ref C)) lvl.AddUpdate(C.b, Block.air);
C.data.Data = 255;
}
static bool DoLeafDecay(Level lvl, Check C) {
static bool DoLeafDecay(Level lvl, ref Check C) {
const int dist = 4;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);

View File

@ -23,7 +23,7 @@ namespace MCGalaxy.BlockPhysics {
public static class OtherPhysics {
public static void DoFalling(Level lvl, Check C) {
public static void DoFalling(Level lvl, ref Check C) {
if (lvl.physics == 0 || lvl.physics == 5) { C.data.Data = 255; return; }
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -73,7 +73,7 @@ namespace MCGalaxy.BlockPhysics {
C.data.Data = 255;
}
public static void DoStairs(Level lvl, Check C) {
public static void DoStairs(Level lvl, ref Check C) {
int bBelow = lvl.IntOffset(C.b, 0, -1, 0);
byte tile = lvl.GetTile(bBelow);
@ -87,7 +87,7 @@ namespace MCGalaxy.BlockPhysics {
C.data.Data = 255;
}
public static void DoFloatwood(Level lvl, Check C) {
public static void DoFloatwood(Level lvl, ref Check C) {
int index = lvl.IntOffset(C.b, 0, -1, 0);
if (lvl.GetTile(index) == Block.air) {
lvl.AddUpdate(C.b, Block.air);
@ -102,7 +102,7 @@ namespace MCGalaxy.BlockPhysics {
C.data.Data = 255;
}
public static void DoShrub(Level lvl, Check C) {
public static void DoShrub(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -127,7 +127,7 @@ namespace MCGalaxy.BlockPhysics {
C.data.Data = 255;
}
public static void DoDirt(Level lvl, Check C) {
public static void DoDirt(Level lvl, ref Check C) {
if (!lvl.GrassGrow) { C.data.Data = 255; return; }
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -145,7 +145,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoSponge(Level lvl, Check C, bool lava) {
public static void DoSponge(Level lvl, ref Check C, bool lava) {
for (int y = -2; y <= +2; ++y)
for (int z = -2; z <= +2; ++z)
for (int x = -2; x <= +2; ++x)
@ -177,7 +177,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoOther(Level lvl, Check C) {
public static void DoOther(Level lvl, ref Check C) {
if (lvl.physics <= 1) { C.data.Data = 255; return; }
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class RocketPhysics {
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;

View File

@ -22,46 +22,46 @@ namespace MCGalaxy.BlockPhysics {
public static class SimpleLiquidPhysics {
const StringComparison comp = StringComparison.Ordinal;
public static void DoWater(Level lvl, Check C) {
public static void DoWater(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
if (lvl.finite) {
lvl.liquids.Remove(C.b);
FinitePhysics.DoWaterOrLava(lvl, C);
FinitePhysics.DoWaterOrLava(lvl, ref C);
return;
}
if (lvl.randomFlow)
DoWaterRandowFlow(lvl, C);
DoWaterRandowFlow(lvl, ref C);
else
DoWaterUniformFlow(lvl, C);
DoWaterUniformFlow(lvl, ref C);
}
public static void DoLava(Level lvl, Check C) {
public static void DoLava(Level lvl, ref Check C) {
if (C.data.Data < 4) {
C.data.Data++; return;
}
if (lvl.finite) {
lvl.liquids.Remove(C.b);
FinitePhysics.DoWaterOrLava(lvl, C);
FinitePhysics.DoWaterOrLava(lvl, ref C);
return;
}
if (lvl.randomFlow)
DoLavaRandowFlow(lvl, C, true);
DoLavaRandowFlow(lvl, ref C, true);
else
DoLavaUniformFlow(lvl, C, true);
DoLavaUniformFlow(lvl, ref C, true);
}
public static void DoFastLava(Level lvl, Check C) {
public static void DoFastLava(Level lvl, ref Check C) {
if (lvl.randomFlow) {
byte oldTime = C.data.Data;
DoLavaRandowFlow(lvl, C, false);
DoLavaRandowFlow(lvl, ref C, false);
if (C.data.Data != 255)
C.data.Data = oldTime;
} else {
DoLavaUniformFlow(lvl, C, false);
DoLavaUniformFlow(lvl, ref C, false);
}
}
static void DoWaterRandowFlow(Level lvl, Check C) {
static void DoWaterRandowFlow(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
bool[] blocked = null;
ushort x, y, z;
@ -122,7 +122,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
static void DoWaterUniformFlow(Level lvl, Check C) {
static void DoWaterUniformFlow(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
lvl.liquids.Remove(C.b);
ushort x, y, z;
@ -174,7 +174,7 @@ namespace MCGalaxy.BlockPhysics {
return true;
}
static void DoLavaRandowFlow(Level lvl, Check C, bool checkWait) {
static void DoLavaRandowFlow(Level lvl, ref Check C, bool checkWait) {
Random rand = lvl.physRandom;
bool[] blocked = null;
ushort x, y, z;
@ -234,7 +234,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
static void DoLavaUniformFlow(Level lvl, Check C, bool checkWait) {
static void DoLavaUniformFlow(Level lvl, ref Check C, bool checkWait) {
Random rand = lvl.physRandom;
lvl.liquids.Remove(C.b);
ushort x, y, z;

View File

@ -21,12 +21,12 @@ namespace MCGalaxy.BlockPhysics {
public static class SnakePhysics {
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
int dirsVisited = 0, index = 0;
Player foundPlayer = AIPhysics.ClosestPlayer(lvl, C);
Player foundPlayer = AIPhysics.ClosestPlayer(lvl, ref C);
if (foundPlayer != null && rand.Next(1, 20) < 19) {
switch (rand.Next(1, 10)) {
@ -34,7 +34,7 @@ namespace MCGalaxy.BlockPhysics {
case 2:
case 3:
index = lvl.PosToInt((ushort)(x + Math.Sign((foundPlayer.pos[0] / 32) - x)), y, z);
if (index != C.b && MoveSnake(lvl, C, index)) return;
if (index != C.b && MoveSnake(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 3) break;
@ -43,7 +43,7 @@ namespace MCGalaxy.BlockPhysics {
case 5:
case 6:
index = lvl.PosToInt(x, (ushort) (y + Math.Sign((foundPlayer.pos[1] / 32) - y)), z);
if (index != C.b && MoveSnakeY(lvl, C, index)) return;
if (index != C.b && MoveSnakeY(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 3) break;
@ -52,7 +52,7 @@ namespace MCGalaxy.BlockPhysics {
case 8:
case 9:
index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((foundPlayer.pos[2] / 32) - z)));
if (index != C.b && MoveSnake(lvl, C, index)) return;
if (index != C.b && MoveSnake(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 3) break;
@ -66,7 +66,7 @@ namespace MCGalaxy.BlockPhysics {
case 2:
case 3:
index = lvl.IntOffset(C.b, -1, 0, 0);
if (MoveSnake(lvl, C, index)) return;
if (MoveSnake(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -75,7 +75,7 @@ namespace MCGalaxy.BlockPhysics {
case 5:
case 6:
index = lvl.IntOffset(C.b, 1, 0, 0);
if (MoveSnake(lvl, C, index)) return;
if (MoveSnake(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -84,7 +84,7 @@ namespace MCGalaxy.BlockPhysics {
case 8:
case 9:
index = lvl.IntOffset(C.b, 0, 0, 1);
if (MoveSnake(lvl, C, index)) return;
if (MoveSnake(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -94,7 +94,7 @@ namespace MCGalaxy.BlockPhysics {
case 12:
default:
index = lvl.IntOffset(C.b, 0, 0, -1);
if (MoveSnake(lvl, C, index)) return;
if (MoveSnake(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -102,7 +102,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoTail(Level lvl, Check C) {
public static void DoTail(Level lvl, ref Check C) {
if (lvl.GetTile(lvl.IntOffset(C.b, -1, 0, 0)) != Block.snake
|| lvl.GetTile(lvl.IntOffset(C.b, 1, 0, 0)) != Block.snake
|| lvl.GetTile(lvl.IntOffset(C.b, 0, 0, 1)) != Block.snake
@ -111,7 +111,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
static bool MoveSnake(Level lvl, Check C, int index) {
static bool MoveSnake(Level lvl, ref Check C, int index) {
if (
lvl.GetTile(lvl.IntOffset(index, 0, -1, 0)) == Block.air &&
lvl.GetTile(index) == Block.air) {
@ -135,7 +135,7 @@ namespace MCGalaxy.BlockPhysics {
return false;
}
static bool MoveSnakeY(Level lvl, Check C, int index ) {
static bool MoveSnakeY(Level lvl, ref Check C, int index ) {
byte block = lvl.GetTile(index);
byte blockAbove = lvl.GetTile(lvl.IntOffset(index, 0, 1, 0));
byte block2Above = lvl.GetTile(lvl.IntOffset(index, 0, 2, 0));

View File

@ -32,13 +32,13 @@ namespace MCGalaxy.BlockPhysics {
lvl.Blockchange(x, y, (ushort)(z - 1), lvl.GetTile(x, y, (ushort)(z - 1)) == Block.lavastill ? Block.air : Block.lavastill);
}
public static void DoTntExplosion(Level lvl, Check C) {
public static void DoTntExplosion(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
if (rand.Next(1, 11) <= 7)
lvl.AddUpdate(C.b, Block.air);
}
public static void DoLargeTnt(Level lvl, Check C, int power) {
public static void DoLargeTnt(Level lvl, ref Check C, int power) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -55,7 +55,7 @@ namespace MCGalaxy.BlockPhysics {
}
}
public static void DoSmallTnt(Level lvl, Check C) {
public static void DoSmallTnt(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class TrainPhysics {
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;

View File

@ -21,7 +21,7 @@ namespace MCGalaxy.BlockPhysics {
public static class ZombiePhysics {
public static void Do(Level lvl, Check C) {
public static void Do(Level lvl, ref Check C) {
Random rand = lvl.physRandom;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
@ -35,21 +35,21 @@ namespace MCGalaxy.BlockPhysics {
}
bool checkTime = true;
int index = 0;
Player closest = AIPhysics.ClosestPlayer(lvl, C);
Player closest = AIPhysics.ClosestPlayer(lvl, ref C);
if (closest != null && rand.Next(1, 20) < 18) {
if (rand.Next(1, 7) <= 3) {
index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (index != C.b && MoveZombie(lvl, C, index)) return;
if (index != C.b && MoveZombie(lvl, ref C, index)) return;
index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
if (index != C.b && MoveZombie(lvl, C, index)) return;
if (index != C.b && MoveZombie(lvl, ref C, index)) return;
} else {
index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
if (index != C.b && MoveZombie(lvl, C, index)) return;
if (index != C.b && MoveZombie(lvl, ref C, index)) return;
index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (index != C.b && MoveZombie(lvl, C, index)) return;
if (index != C.b && MoveZombie(lvl, ref C, index)) return;
}
checkTime = false;
}
@ -66,7 +66,7 @@ namespace MCGalaxy.BlockPhysics {
case 2:
case 3:
index = lvl.IntOffset(C.b, -1, 0, 0);
if (MoveZombie(lvl, C, index)) return;
if (MoveZombie(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -76,7 +76,7 @@ namespace MCGalaxy.BlockPhysics {
case 5:
case 6:
index = lvl.IntOffset(C.b, 1, 0, 0);
if (MoveZombie(lvl, C, index)) return;
if (MoveZombie(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -86,7 +86,7 @@ namespace MCGalaxy.BlockPhysics {
case 8:
case 9:
index = lvl.IntOffset(C.b, 0, 0, 1);
if (MoveZombie(lvl, C, index)) return;
if (MoveZombie(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -95,7 +95,7 @@ namespace MCGalaxy.BlockPhysics {
case 11:
case 12:
index = lvl.IntOffset(C.b, 0, 0, -1);
if (MoveZombie(lvl, C, index)) return;
if (MoveZombie(lvl, ref C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
@ -105,14 +105,14 @@ namespace MCGalaxy.BlockPhysics {
lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
}
public static void DoHead(Level lvl, Check C) {
public static void DoHead(Level lvl, ref Check C) {
if (lvl.GetTile(lvl.IntOffset(C.b, 0, -1, 0)) != Block.zombiebody
&& lvl.GetTile(lvl.IntOffset(C.b, 0, -1, 0)) != Block.creeper) {
C.data.Type1 = PhysicsArgs.Revert; C.data.Value1 = Block.air;
}
}
static bool MoveZombie(Level lvl, Check C, int index) {
static bool MoveZombie(Level lvl, ref Check C, int index) {
if(
lvl.GetTile(lvl.IntOffset(index, 0, -1, 0)) == Block.air &&
lvl.GetTile(index) == Block.air) {

View File

@ -94,11 +94,11 @@ namespace MCGalaxy {
internal OnPhysicsUpdateEvent(Level.OnPhysicsUpdate method, Priority priority, Plugin plugin)
: base(method, priority, plugin) { }
public static void Call(ushort x, ushort y, ushort z, byte time, PhysicsArgs extraInfo, Level l) {
public static void Call(ushort x, ushort y, ushort z, PhysicsArgs extraInfo, Level l) {
events.ForEach(
pl => {
try {
pl.method(x, y, z, time, extraInfo, l);
pl.method(x, y, z, extraInfo, l);
} catch (Exception e) {
Server.s.Log("Plugin " + pl.plugin.name + " errored when calling PhysicsUpdate Event."); Server.ErrorLog(e);
}

View File

@ -64,6 +64,13 @@ namespace MCGalaxy {
return true;
}
public void RemoveAt(int index) {
Count--;
if (index < Count)
Array.Copy(Items, index + 1, Items, index, Count - index);
Items[Count] = default(T);
}
public void RemoveAll(Predicate<T> condition) {
int j = 0;
for (int i = 0; i < Count; i++) {