diff options
author | jhurliman | 2007-03-07 05:09:18 +0000 |
---|---|---|
committer | jhurliman | 2007-03-07 05:09:18 +0000 |
commit | 0b6f8a02a7d0927031bf812429770d6ecc5f483a (patch) | |
tree | 6795f255e730e5cdfcf79191a0fd64734951d691 /src/world/World.cs | |
parent | NEVER COMMIT WITHOUT A TEST COMPILE! (diff) | |
download | opensim-SC_OLD-0b6f8a02a7d0927031bf812429770d6ecc5f483a.zip opensim-SC_OLD-0b6f8a02a7d0927031bf812429770d6ecc5f483a.tar.gz opensim-SC_OLD-0b6f8a02a7d0927031bf812429770d6ecc5f483a.tar.bz2 opensim-SC_OLD-0b6f8a02a7d0927031bf812429770d6ecc5f483a.tar.xz |
* Updating libsecondlife.dll to the latest version with a working LayerData function
* Reformatting some source files
* Adding a try/catch sanity check around a phoning home check to osgrid.org
* Updating the MSVC project file
* Converted LayerData generation to use the functions built in to libsecondlife
* Removing unused BitPack.cs and TerrainDecoder.cs files
* Added a basic terrain generator (hills algorithm)
Diffstat (limited to 'src/world/World.cs')
-rw-r--r-- | src/world/World.cs | 137 |
1 files changed, 79 insertions, 58 deletions
diff --git a/src/world/World.cs b/src/world/World.cs index 83788cd..158ddc2 100644 --- a/src/world/World.cs +++ b/src/world/World.cs | |||
@@ -1,9 +1,9 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Threading; | 2 | using System.Threading; |
3 | using libsecondlife; | ||
4 | using libsecondlife.Packets; | ||
5 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
6 | using System.Text; | 4 | using System.Text; |
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | 7 | ||
8 | namespace OpenSim.world | 8 | namespace OpenSim.world |
9 | { | 9 | { |
@@ -12,77 +12,98 @@ namespace OpenSim.world | |||
12 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | 12 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; |
13 | public float[] LandMap; | 13 | public float[] LandMap; |
14 | public ScriptEngine Scripts; | 14 | public ScriptEngine Scripts; |
15 | public TerrainDecode terrainengine = new TerrainDecode(); | 15 | public uint _localNumber = 0; |
16 | public uint _localNumber=0; | 16 | public PhysicsEngine physics; |
17 | public PhysicsEngine physics; | 17 | |
18 | 18 | private libsecondlife.TerrainManager TerrainManager; | |
19 | private Random Rand = new Random(); | 19 | private Random Rand = new Random(); |
20 | 20 | ||
21 | public World() | 21 | public World() |
22 | { | 22 | { |
23 | OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance"); | 23 | OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance"); |
24 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); | 24 | Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); |
25 | |||
26 | OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap"); | ||
27 | TerrainManager = new TerrainManager(new SecondLife()); | ||
28 | } | ||
25 | 29 | ||
26 | OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap"); | 30 | public void InitLoop() |
27 | terrainengine = new TerrainDecode(); | 31 | { |
28 | LandMap = new float[65536]; | 32 | OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics"); |
29 | 33 | this.physics = new PhysicsEngine(); | |
34 | physics.Startup(); | ||
30 | } | 35 | } |
31 | 36 | ||
32 | public void InitLoop() { | 37 | public void DoStuff() |
33 | OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics"); | 38 | { |
34 | this.physics = new PhysicsEngine(); | 39 | lock (this) |
35 | physics.Startup(); | 40 | { |
36 | } | 41 | physics.DoStuff(this); |
37 | 42 | this.Update(); | |
38 | public void DoStuff() { | 43 | } |
39 | lock(this) { | 44 | } |
40 | physics.DoStuff(this); | ||
41 | this.Update(); | ||
42 | } | ||
43 | } | ||
44 | 45 | ||
45 | public void Update() { | 46 | public void Update() |
47 | { | ||
46 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) | 48 | foreach (libsecondlife.LLUUID UUID in Entities.Keys) |
47 | { | 49 | { |
48 | if(Entities[UUID].needupdate) { | 50 | if (Entities[UUID].needupdate) |
49 | Entities[UUID].update(); | 51 | { |
50 | 52 | Entities[UUID].update(); | |
51 | if(Entities[UUID] is Avatar) { | 53 | |
52 | Avatar avatar=(Avatar)Entities[UUID]; | 54 | if (Entities[UUID] is Avatar) |
53 | if((avatar.oldpos!=avatar.position) || (avatar.oldvel!=avatar.velocity) || avatar.walking) { | 55 | { |
54 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); | 56 | Avatar avatar = (Avatar)Entities[UUID]; |
55 | foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { | 57 | if ((avatar.oldpos != avatar.position) || (avatar.oldvel != avatar.velocity) || avatar.walking) |
56 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | 58 | { |
57 | terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME | 59 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); |
58 | terse.RegionData.TimeDilation = 0; | 60 | foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) |
59 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 61 | { |
60 | terse.ObjectData[0] = terseBlock; | 62 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); |
61 | client.OutPacket(terse); | 63 | terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME |
62 | } | 64 | terse.RegionData.TimeDilation = 0; |
63 | }} | 65 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
64 | } | 66 | terse.ObjectData[0] = terseBlock; |
67 | client.OutPacket(terse); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | } | ||
65 | } | 72 | } |
66 | } | 73 | } |
67 | 74 | ||
68 | public void SendLayerData(OpenSimClient RemoteClient) { | 75 | public void SendLayerData(OpenSimClient RemoteClient) |
69 | for(int x=0; x<16; x=x+4) for(int y=0; y<16; y++){ | 76 | { |
70 | Packet layerpack=this.terrainengine.CreateLayerPacket(LandMap, x,y,x+4,y+1); | 77 | int[] patches = new int[4]; |
71 | RemoteClient.OutPacket(layerpack); | ||
72 | } | ||
73 | } | ||
74 | 78 | ||
75 | public void AddViewerAgent(OpenSimClient AgentClient) { | 79 | for (int y = 0; y < 16; y++) |
76 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | 80 | { |
77 | Avatar NewAvatar = new Avatar(AgentClient); | 81 | for (int x = 0; x < 16; x = x + 4) |
78 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); | 82 | { |
79 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | 83 | patches[0] = x + 0 + y * 16; |
80 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); | 84 | patches[1] = x + 1 + y * 16; |
81 | NewAvatar.SendRegionHandshake(this); | 85 | patches[2] = x + 2 + y * 16; |
82 | this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user | 86 | patches[3] = x + 3 + y * 16; |
83 | } | ||
84 | 87 | ||
85 | public bool Backup() { | 88 | Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches); |
89 | RemoteClient.OutPacket(layerpack); | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | public void AddViewerAgent(OpenSimClient AgentClient) | ||
95 | { | ||
96 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | ||
97 | Avatar NewAvatar = new Avatar(AgentClient); | ||
98 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); | ||
99 | this.Entities.Add(AgentClient.AgentID, NewAvatar); | ||
100 | OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); | ||
101 | NewAvatar.SendRegionHandshake(this); | ||
102 | this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user | ||
103 | } | ||
104 | |||
105 | public bool Backup() | ||
106 | { | ||
86 | /* TODO: Save the current world entities state. */ | 107 | /* TODO: Save the current world entities state. */ |
87 | 108 | ||
88 | return false; | 109 | return false; |