diff options
author | MW | 2007-02-02 17:23:56 +0000 |
---|---|---|
committer | MW | 2007-02-02 17:23:56 +0000 |
commit | e75e6f426bfc069e9185c8c72e8707399edfe299 (patch) | |
tree | 0700369d4d568eed609709abe0c4442637538218 | |
parent | Clean up (diff) | |
download | opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.zip opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.gz opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.bz2 opensim-SC_OLD-e75e6f426bfc069e9185c8c72e8707399edfe299.tar.xz |
Clean up. Added GridManager and teleport between regions/sims.
Diffstat (limited to '')
-rw-r--r-- | Agent_Manager.cs | 457 | ||||
-rw-r--r-- | AssemblyInfo.cs | 6 | ||||
-rw-r--r-- | Asset_manager.cs | 53 | ||||
-rw-r--r-- | Controller.cs | 173 | ||||
-rw-r--r-- | Login_manager.cs | 74 | ||||
-rw-r--r-- | Prim_manager.cs | 237 | ||||
-rw-r--r-- | Script_manager.cs | 46 | ||||
-rw-r--r-- | Second-server.csproj | 17 | ||||
-rw-r--r-- | Second-server.sln | 4 | ||||
-rw-r--r-- | Server.cs | 27 | ||||
-rw-r--r-- | Texture_manager.cs | 73 |
11 files changed, 725 insertions, 442 deletions
diff --git a/Agent_Manager.cs b/Agent_Manager.cs index 3b05480..9aa8d7f 100644 --- a/Agent_Manager.cs +++ b/Agent_Manager.cs | |||
@@ -32,122 +32,173 @@ using libsecondlife.AssetSystem; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using Axiom.MathLib; | 33 | using Axiom.MathLib; |
34 | 34 | ||
35 | namespace Second_server | 35 | namespace OpenSim |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// Description of Agent_Manager. | 38 | /// Description of Agent_Manager. |
39 | /// </summary> | 39 | /// </summary> |
40 | public class Agent_Manager | 40 | public class AgentManager |
41 | { | 41 | { |
42 | public Dictionary<libsecondlife.LLUUID,Avatar_data> Agent_list; | 42 | public Dictionary<libsecondlife.LLUUID,AvatarData> AgentList; |
43 | //public uint number_agents=0; | 43 | |
44 | private uint local_numer=0; | 44 | private uint local_numer=0; |
45 | private Server server; | 45 | private Server server; |
46 | public Prim_manager prim_man; | 46 | public PrimManager Prim_Manager; |
47 | private byte [] data1; | ||
48 | 47 | ||
49 | private libsecondlife.Packets.RegionHandshakePacket reg; | 48 | private libsecondlife.Packets.RegionHandshakePacket RegionPacket; |
50 | private System.Text.Encoding enc = System.Text.Encoding.ASCII; | 49 | private System.Text.Encoding enc = System.Text.Encoding.ASCII; |
51 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock avatar_template; | 50 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; |
52 | //private int appc=0; | 51 | |
53 | 52 | /// <summary> | |
54 | public Agent_Manager(Server serve) | 53 | /// |
54 | /// </summary> | ||
55 | /// <param name="serve"></param> | ||
56 | public AgentManager(Server serve) | ||
55 | { | 57 | { |
56 | Agent_list=new Dictionary<libsecondlife.LLUUID,Avatar_data>(); | 58 | AgentList=new Dictionary<libsecondlife.LLUUID,AvatarData>(); |
57 | server=serve; | 59 | server=serve; |
58 | this.initialise(); | 60 | this.initialise(); |
59 | } | 61 | } |
60 | //*************************************************** | 62 | |
61 | public Avatar_data Get_Agent(LLUUID id) | 63 | /// <summary> |
64 | /// | ||
65 | /// </summary> | ||
66 | /// <param name="id"></param> | ||
67 | /// <returns></returns> | ||
68 | public AvatarData GetAgent(LLUUID id) | ||
62 | { | 69 | { |
63 | 70 | if(!this.AgentList.ContainsKey(id)) | |
64 | |||
65 | if(!this.Agent_list.ContainsKey(id)) | ||
66 | { | 71 | { |
67 | return null; | 72 | return null; |
68 | } | 73 | } |
69 | else | 74 | else |
70 | { | 75 | { |
71 | Avatar_data ad=this.Agent_list[id]; | 76 | AvatarData ad=this.AgentList[id]; |
72 | return ad; | 77 | return ad; |
73 | } | 78 | } |
74 | } | 79 | } |
75 | 80 | /// <summary> | |
76 | public void Add_Agent(Avatar_data agent) | 81 | /// |
82 | /// </summary> | ||
83 | /// <param name="agent"></param> | ||
84 | public void AddAgent(AvatarData agent) | ||
77 | { | 85 | { |
78 | this.Agent_list.Add(agent.Full_ID,agent); | 86 | this.AgentList.Add(agent.FullID,agent); |
79 | } | 87 | } |
88 | /// <summary> | ||
89 | /// | ||
90 | /// </summary> | ||
91 | /// <param name="User_info"></param> | ||
92 | /// <param name="first"></param> | ||
93 | /// <param name="last"></param> | ||
94 | /// <returns></returns> | ||
95 | /// | ||
80 | 96 | ||
81 | public bool New_Agent(User_Agent_info User_info) | 97 | /// <summary> |
98 | /// | ||
99 | /// </summary> | ||
100 | /// <param name="User_info"></param> | ||
101 | /// <param name="first"></param> | ||
102 | /// <param name="last"></param> | ||
103 | /// <returns></returns> | ||
104 | public bool NewAgent(User_Agent_info User_info, string first, string last) | ||
82 | { | 105 | { |
83 | Avatar_data ad=new Avatar_data(); | 106 | AvatarData agent=new AvatarData(); |
84 | ad.Full_ID=User_info.AgentID; | 107 | agent.FullID=User_info.AgentID; |
85 | ad.Net_info=User_info; | 108 | agent.NetInfo=User_info; |
86 | ad.pos=new LLVector3(100,100,22); | 109 | agent.NetInfo.first_name=first; |
87 | this.Agent_list.Add(ad.Full_ID,ad); | 110 | agent.NetInfo.last_name=last; |
111 | agent.Position=new LLVector3(100,100,22); | ||
112 | this.AgentList.Add(agent.FullID,agent); | ||
88 | return(true); | 113 | return(true); |
89 | } | 114 | } |
90 | 115 | ||
91 | public void Agent_join(User_Agent_info User_info) | 116 | /// <summary> |
117 | /// | ||
118 | /// </summary> | ||
119 | /// <param name="UserInfo"></param> | ||
120 | public void RemoveAgent(User_Agent_info UserInfo) | ||
121 | { | ||
122 | this.AgentList.Remove(UserInfo.AgentID); | ||
123 | |||
124 | //tell other clients to delete this avatar | ||
125 | } | ||
126 | |||
127 | /// <summary> | ||
128 | /// | ||
129 | /// </summary> | ||
130 | /// <param name="User_info"></param> | ||
131 | public void AgentJoin(User_Agent_info User_info) | ||
92 | { | 132 | { |
93 | //send region data | 133 | //send region data |
94 | server.SendPacket(reg,true,User_info); | 134 | server.SendPacket(RegionPacket,true,User_info); |
95 | 135 | ||
96 | //inform client of join comlete | 136 | //inform client of join comlete |
97 | libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); | 137 | libsecondlife.Packets.AgentMovementCompletePacket mov=new AgentMovementCompletePacket(); |
98 | mov.AgentData.SessionID=User_info.SessionID; | 138 | mov.AgentData.SessionID=User_info.SessionID; |
99 | mov.AgentData.AgentID=User_info.AgentID; | 139 | mov.AgentData.AgentID=User_info.AgentID; |
100 | mov.Data.RegionHandle=1096213093147648; | 140 | mov.Data.RegionHandle=Globals.Instance.RegionHandle; |
101 | mov.Data.Timestamp=1169838966; | 141 | mov.Data.Timestamp=1169838966; |
102 | mov.Data.Position=new LLVector3(100f,100f,22f); | 142 | mov.Data.Position=new LLVector3(100f,100f,22f); |
103 | mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); | 143 | mov.Data.LookAt=new LLVector3(0.99f,0.042f,0); |
104 | server.SendPacket(mov,true,User_info); | 144 | server.SendPacket(mov,true,User_info); |
105 | } | 145 | } |
106 | public void tick() | 146 | |
147 | /// <summary> | ||
148 | /// | ||
149 | /// </summary> | ||
150 | public void UpdatePositions() | ||
107 | { | 151 | { |
108 | //update positions | 152 | //update positions |
109 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 153 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
110 | { | 154 | { |
111 | 155 | ||
112 | kp.Value.pos.X+=(kp.Value.vel.X*0.2f); | 156 | kp.Value.Position.X+=(kp.Value.Velocity.X*0.2f); |
113 | kp.Value.pos.Y+=(kp.Value.vel.Y*0.2f); | 157 | kp.Value.Position.Y+=(kp.Value.Velocity.Y*0.2f); |
114 | kp.Value.pos.Z+=(kp.Value.vel.Z*0.2f); | 158 | kp.Value.Position.Z+=(kp.Value.Velocity.Z*0.2f); |
115 | } | 159 | } |
116 | } | 160 | } |
117 | //************************************************************** | 161 | |
162 | /// <summary> | ||
163 | /// | ||
164 | /// </summary> | ||
118 | private void initialise() | 165 | private void initialise() |
119 | { | 166 | { |
120 | //Region data | 167 | //Region data |
121 | reg=new RegionHandshakePacket(); | 168 | RegionPacket=new RegionHandshakePacket(); |
122 | reg.RegionInfo.BillableFactor=0; | 169 | RegionPacket.RegionInfo.BillableFactor=0; |
123 | reg.RegionInfo.IsEstateManager=false; | 170 | RegionPacket.RegionInfo.IsEstateManager=false; |
124 | reg.RegionInfo.TerrainHeightRange00=60; | 171 | RegionPacket.RegionInfo.TerrainHeightRange00=60; |
125 | reg.RegionInfo.TerrainHeightRange01=60; | 172 | RegionPacket.RegionInfo.TerrainHeightRange01=60; |
126 | reg.RegionInfo.TerrainHeightRange10=60; | 173 | RegionPacket.RegionInfo.TerrainHeightRange10=60; |
127 | reg.RegionInfo.TerrainHeightRange11=60; | 174 | RegionPacket.RegionInfo.TerrainHeightRange11=60; |
128 | reg.RegionInfo.TerrainStartHeight00=20; | 175 | RegionPacket.RegionInfo.TerrainStartHeight00=20; |
129 | reg.RegionInfo.TerrainStartHeight01=20; | 176 | RegionPacket.RegionInfo.TerrainStartHeight01=20; |
130 | reg.RegionInfo.TerrainStartHeight10=20; | 177 | RegionPacket.RegionInfo.TerrainStartHeight10=20; |
131 | reg.RegionInfo.TerrainStartHeight11=20; | 178 | RegionPacket.RegionInfo.TerrainStartHeight11=20; |
132 | reg.RegionInfo.SimAccess=13; | 179 | RegionPacket.RegionInfo.SimAccess=13; |
133 | reg.RegionInfo.WaterHeight=5; | 180 | RegionPacket.RegionInfo.WaterHeight=5; |
134 | reg.RegionInfo.RegionFlags=72458694; | 181 | RegionPacket.RegionInfo.RegionFlags=72458694; |
135 | reg.RegionInfo.SimName=enc.GetBytes( "Test Sandbox\0"); | 182 | RegionPacket.RegionInfo.SimName=enc.GetBytes( Globals.Instance.RegionName); |
136 | reg.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); | 183 | RegionPacket.RegionInfo.SimOwner=new LLUUID("00000000-0000-0000-0000-000000000000"); |
137 | reg.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); | 184 | RegionPacket.RegionInfo.TerrainBase0=new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); |
138 | reg.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); | 185 | RegionPacket.RegionInfo.TerrainBase1=new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); |
139 | reg.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); | 186 | RegionPacket.RegionInfo.TerrainBase2=new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); |
140 | reg.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); | 187 | RegionPacket.RegionInfo.TerrainBase3=new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); |
141 | reg.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); | 188 | RegionPacket.RegionInfo.TerrainDetail0=new LLUUID("00000000-0000-0000-0000-000000000000"); |
142 | reg.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); | 189 | RegionPacket.RegionInfo.TerrainDetail1=new LLUUID("00000000-0000-0000-0000-000000000000"); |
143 | reg.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); | 190 | RegionPacket.RegionInfo.TerrainDetail2=new LLUUID("00000000-0000-0000-0000-000000000000"); |
144 | reg.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); | 191 | RegionPacket.RegionInfo.TerrainDetail3=new LLUUID("00000000-0000-0000-0000-000000000000"); |
145 | reg.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab33"); | 192 | RegionPacket.RegionInfo.CacheID=new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37"); |
146 | 193 | ||
147 | this.setuptemplate("objectupate168.dat"); | 194 | this.SetupTemplate("objectupate168.dat"); |
148 | } | 195 | } |
149 | 196 | ||
150 | public void setuptemplate(string name) | 197 | /// <summary> |
198 | /// | ||
199 | /// </summary> | ||
200 | /// <param name="name"></param> | ||
201 | private void SetupTemplate(string name) | ||
151 | { | 202 | { |
152 | /*ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 203 | /*ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
153 | objupdate.RegionData.RegionHandle=1096213093147648; | 204 | objupdate.RegionData.RegionHandle=1096213093147648; |
@@ -184,95 +235,87 @@ namespace Second_server | |||
184 | 235 | ||
185 | Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); | 236 | Array.Copy(pb,0,objdata.ObjectData,16,pb.Length); |
186 | 237 | ||
187 | avatar_template=objdata; | 238 | AvatarTemplate=objdata; |
188 | 239 | ||
189 | } | 240 | } |
190 | //********************************************************** | 241 | |
191 | public void send_intial_data(User_Agent_info User_info) | 242 | /// <summary> |
243 | /// | ||
244 | /// </summary> | ||
245 | /// <param name="User_info"></param> | ||
246 | public void SendInitialData(User_Agent_info User_info) | ||
192 | { | 247 | { |
193 | 248 | ||
194 | //shouldn't really have to read all this in from disk for every new client? | 249 | //shouldn't have to read all this in from disk for every new client |
195 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; | 250 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\layer_data\"; |
196 | 251 | ||
197 | //send layerdata | 252 | //send layerdata |
198 | LayerDataPacket layerpack=new LayerDataPacket(); | 253 | LayerDataPacket layerpack=new LayerDataPacket(); |
199 | layerpack.LayerID.Type=76; | 254 | layerpack.LayerID.Type=76; |
200 | //layerpack.LayerData.ReadfromFile(data_path+@"layerdata0.dat"); | 255 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata0.dat"); |
201 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata0.dat"); | 256 | |
202 | |||
203 | //server.SendPacket(layerpack,true,User_info); | ||
204 | |||
205 | LayerDataPacket layerpack1=new LayerDataPacket(); | 257 | LayerDataPacket layerpack1=new LayerDataPacket(); |
206 | layerpack1.LayerID.Type=76; | 258 | layerpack1.LayerID.Type=76; |
207 | //layerpack1.LayerData.ReadfromFile(data_path+@"layerdata1.dat"); | 259 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata1.dat"); |
208 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata1.dat"); | ||
209 | //server.SendPacket(layerpack1,true,User_info); | ||
210 | 260 | ||
211 | LayerDataPacket layerpack2=new LayerDataPacket(); | 261 | LayerDataPacket layerpack2=new LayerDataPacket(); |
212 | layerpack2.LayerID.Type=56; | 262 | layerpack2.LayerID.Type=56; |
213 | //layerpack2.LayerData.ReadfromFile(data_path+@"layerdata2.dat"); | 263 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata2.dat"); |
214 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata2.dat"); | ||
215 | //server.SendPacket(layerpack2,true,User_info); | ||
216 | 264 | ||
217 | LayerDataPacket layerpack3=new LayerDataPacket(); | 265 | LayerDataPacket layerpack3=new LayerDataPacket(); |
218 | layerpack3.LayerID.Type=55; | 266 | layerpack3.LayerID.Type=55; |
219 | //layerpack3.LayerData.ReadfromFile(data_path+@"layerdata3.dat"); | 267 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata3.dat"); |
220 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata3.dat"); | ||
221 | //server.SendPacket(layerpack3,true,User_info); | ||
222 | 268 | ||
223 | LayerDataPacket layerpack4=new LayerDataPacket(); | 269 | LayerDataPacket layerpack4=new LayerDataPacket(); |
224 | layerpack4.LayerID.Type=56; | 270 | layerpack4.LayerID.Type=56; |
225 | //layerpack4.LayerData.ReadfromFile(data_path+@"layerdata4.dat"); | 271 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata4.dat"); |
226 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata4.dat"); | ||
227 | //server.SendPacket(layerpack4,true,User_info); | ||
228 | 272 | ||
229 | LayerDataPacket layerpack5=new LayerDataPacket(); | 273 | LayerDataPacket layerpack5=new LayerDataPacket(); |
230 | layerpack5.LayerID.Type=55; | 274 | layerpack5.LayerID.Type=55; |
231 | //layerpack5.LayerData.ReadfromFile(data_path+@"layerdata5.dat"); | 275 | this.SendLayerData(User_info,ref layerpack,data_path+@"layerdata5.dat"); |
232 | this.read_layerdata(User_info,ref layerpack,data_path+@"layerdata5.dat"); | ||
233 | //server.SendPacket(layerpack5,true,User_info); | ||
234 | |||
235 | 276 | ||
236 | //send intial set of captured prims data? | 277 | //send intial set of captured prims data? |
237 | this.prim_man.Read_Prim_database( "objectdatabase.ini",User_info); | 278 | this.Prim_Manager.ReadPrimDatabase( "objectdatabase.ini",User_info); |
238 | 279 | ||
239 | //send prims that have been created by users | 280 | //send prims that have been created by users |
240 | //prim_man.send_existing_prims(User_info); | 281 | //prim_man.send_existing_prims(User_info); |
241 | 282 | ||
242 | //send update about clients avatar | 283 | //send update about clients avatar |
243 | this.send_intial_avatar_position(User_info); | 284 | this.SendInitialAvatarPosition(User_info); |
244 | 285 | ||
245 | //send updates about all other users | 286 | //send updates about all other users |
246 | //this.send_test_avatar_position(User_info); | 287 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
247 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | ||
248 | { | 288 | { |
249 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 289 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
250 | { | 290 | { |
251 | this.send_other_avatar_position(User_info,kp.Value); | 291 | this.SendOtherAvatarPosition(User_info,kp.Value); |
252 | } | 292 | } |
253 | } | 293 | } |
254 | |||
255 | |||
256 | } | 294 | } |
257 | public void send_intial_avatar_position(User_Agent_info User_info) | 295 | |
296 | /// <summary> | ||
297 | /// | ||
298 | /// </summary> | ||
299 | /// <param name="User_info"></param> | ||
300 | public void SendInitialAvatarPosition(User_Agent_info User_info) | ||
258 | { | 301 | { |
259 | //send a objectupdate packet with information about the clients avatar | 302 | //send a objectupdate packet with information about the clients avatar |
260 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 303 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
261 | objupdate.RegionData.RegionHandle=1096213093147648; | 304 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
262 | objupdate.RegionData.TimeDilation=64096; | 305 | objupdate.RegionData.TimeDilation=64096; |
263 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | 306 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; |
264 | 307 | ||
265 | objupdate.ObjectData[0]=avatar_template; | 308 | objupdate.ObjectData[0]=AvatarTemplate; |
266 | //give this avatar object a local id and assign the user a name | 309 | //give this avatar object a local id and assign the user a name |
267 | objupdate.ObjectData[0].ID=8880000+this.local_numer; | 310 | objupdate.ObjectData[0].ID=8880000+this.local_numer; |
268 | User_info.localID=objupdate.ObjectData[0].ID; | 311 | User_info.localID=objupdate.ObjectData[0].ID; |
269 | //User_info.name="Test"+this.local_numer+" User"; | 312 | //User_info.name="Test"+this.local_numer+" User"; |
270 | this.Get_Agent(User_info.AgentID).started=true; | 313 | this.GetAgent(User_info.AgentID).Started=true; |
271 | objupdate.ObjectData[0].FullID=User_info.AgentID; | 314 | objupdate.ObjectData[0].FullID=User_info.AgentID; |
272 | objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); | 315 | objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"); |
273 | User_info.name="FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"; | 316 | User_info.name="FirstName STRING RW SV "+User_info.first_name+"\nLastName STRING RW SV "+User_info.last_name+" \0"; |
274 | User_info.last_name="User"; | 317 | //User_info.last_name="User"; |
275 | User_info.first_name="Test"+this.local_numer; | 318 | //User_info.first_name="Test"+this.local_numer; |
276 | libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); | 319 | libsecondlife.LLVector3 pos2=new LLVector3(100f,100.0f,22.0f); |
277 | 320 | ||
278 | byte[] pb=pos2.GetBytes(); | 321 | byte[] pb=pos2.GetBytes(); |
@@ -283,36 +326,23 @@ namespace Second_server | |||
283 | server.SendPacket(objupdate,true,User_info); | 326 | server.SendPacket(objupdate,true,User_info); |
284 | 327 | ||
285 | //send this info to other existing clients | 328 | //send this info to other existing clients |
286 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 329 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
287 | { | 330 | { |
288 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 331 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
289 | { | 332 | { |
290 | server.SendPacket(objupdate,true,kp.Value.Net_info); | 333 | server.SendPacket(objupdate,true,kp.Value.NetInfo); |
291 | this.send_other_apper(kp.Value.Net_info,objupdate.ObjectData[0].FullID); | 334 | this.SendOtherAppearance(kp.Value.NetInfo,objupdate.ObjectData[0].FullID); |
292 | } | 335 | } |
293 | } | 336 | } |
294 | 337 | ||
295 | } | 338 | } |
296 | public void send_intial_avatar_apper(User_Agent_info user) | 339 | |
340 | /// <summary> | ||
341 | /// | ||
342 | /// </summary> | ||
343 | /// <param name="user"></param> | ||
344 | public void SendIntialAvatarAppearance(User_Agent_info user) | ||
297 | { | 345 | { |
298 | |||
299 | //seems that we don't send a avatarapperance for ourself. | ||
300 | /*AvatarAppearancePacket avp=new AvatarAppearancePacket(); | ||
301 | |||
302 | avp.VisualParam=new AvatarAppearancePacket.VisualParamBlock[218]; | ||
303 | avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes); | ||
304 | |||
305 | AvatarAppearancePacket.VisualParamBlock avblock=null; | ||
306 | for(int i=0; i<218; i++) | ||
307 | { | ||
308 | avblock=new AvatarAppearancePacket.VisualParamBlock(); | ||
309 | avblock.ParamValue=(byte)100; | ||
310 | avp.VisualParam[i]=avblock; | ||
311 | } | ||
312 | |||
313 | avp.Sender.IsTrial=false; | ||
314 | avp.Sender.ID=user.AgentID; | ||
315 | */ | ||
316 | 346 | ||
317 | AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); | 347 | AgentWearablesUpdatePacket aw=new AgentWearablesUpdatePacket(); |
318 | aw.AgentData.AgentID=user.AgentID; | 348 | aw.AgentData.AgentID=user.AgentID; |
@@ -323,22 +353,18 @@ namespace Second_server | |||
323 | aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; | 353 | aw.WearableData= new AgentWearablesUpdatePacket.WearableDataBlock[13]; |
324 | AgentWearablesUpdatePacket.WearableDataBlock awb=null; | 354 | AgentWearablesUpdatePacket.WearableDataBlock awb=null; |
325 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); | 355 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); |
326 | awb.WearableType=(byte)0; | 356 | awb.WearableType=(byte)0; |
327 | awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | 357 | awb.AssetID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); |
328 | //awb.ItemID=new LLUUID("b7878000-0000-0000-0000-000000000000"); | 358 | awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c"); |
329 | awb.ItemID=new LLUUID("b7878441893b094917f791174bc8401c"); | 359 | aw.WearableData[0]=awb; |
330 | //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); | 360 | |
331 | aw.WearableData[0]=awb; | 361 | /*awb=new AgentWearablesUpdatePacket.WearableDataBlock(); |
332 | 362 | awb.WearableType=(byte)1; | |
333 | 363 | awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | |
334 | /*awb=new AgentWearablesUpdatePacket.WearableDataBlock(); | 364 | awb.ItemID=new LLUUID("193f0876fc11d143797454352f9c9c26"); |
335 | awb.WearableType=(byte)1; | 365 | //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); |
336 | awb.AssetID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | 366 | aw.WearableData[1]=awb;*/ |
337 | awb.ItemID=new LLUUID("193f0876fc11d143797454352f9c9c26"); | 367 | |
338 | //awb.ItemID=new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
339 | aw.WearableData[1]=awb;*/ | ||
340 | |||
341 | |||
342 | for(int i=1; i<13; i++) | 368 | for(int i=1; i<13; i++) |
343 | { | 369 | { |
344 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); | 370 | awb=new AgentWearablesUpdatePacket.WearableDataBlock(); |
@@ -348,13 +374,15 @@ namespace Second_server | |||
348 | aw.WearableData[i]=awb; | 374 | aw.WearableData[i]=awb; |
349 | } | 375 | } |
350 | 376 | ||
351 | //server.SendPacket(avp,true,user); | ||
352 | server.SendPacket(aw,true,user); | 377 | server.SendPacket(aw,true,user); |
353 | //System.Console.WriteLine(avp); | ||
354 | |||
355 | |||
356 | } | 378 | } |
357 | public void send_other_apper(User_Agent_info user,LLUUID id) | 379 | |
380 | /// <summary> | ||
381 | /// | ||
382 | /// </summary> | ||
383 | /// <param name="user"></param> | ||
384 | /// <param name="id"></param> | ||
385 | public void SendOtherAppearance(User_Agent_info user,LLUUID id) | ||
358 | { | 386 | { |
359 | AvatarAppearancePacket avp=new AvatarAppearancePacket(); | 387 | AvatarAppearancePacket avp=new AvatarAppearancePacket(); |
360 | 388 | ||
@@ -384,47 +412,25 @@ namespace Second_server | |||
384 | server.SendPacket(avp,true,user); | 412 | server.SendPacket(avp,true,user); |
385 | 413 | ||
386 | } | 414 | } |
387 | 415 | /// <summary> | |
388 | public void send_test_avatar_position(User_Agent_info User_info) | 416 | /// |
389 | { | 417 | /// </summary> |
390 | //send a objectupdate packet with information about the clients avatar | 418 | /// <param name="User_info"></param> |
391 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 419 | /// <param name="avd"></param> |
392 | objupdate.RegionData.RegionHandle=1096213093147648; | 420 | public void SendOtherAvatarPosition(User_Agent_info User_info, AvatarData avd) |
393 | objupdate.RegionData.TimeDilation=64500; | ||
394 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | ||
395 | |||
396 | objupdate.ObjectData[0]=avatar_template; | ||
397 | //give this avatar object a local id and assign the user a name | ||
398 | objupdate.ObjectData[0].ID=8880000+this.local_numer; | ||
399 | objupdate.ObjectData[0].FullID=new LLUUID("00000000-0000-0000-5665-000000000034"); | ||
400 | objupdate.ObjectData[0].NameValue=enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); | ||
401 | libsecondlife.LLVector3 pos2=new LLVector3(120f,120.0f,22.0f); | ||
402 | |||
403 | byte[] pb=pos2.GetBytes(); | ||
404 | |||
405 | Array.Copy(pb,0,objupdate.ObjectData[0].ObjectData,16,pb.Length); | ||
406 | this.local_numer++; | ||
407 | |||
408 | server.SendPacket(objupdate,true,User_info); | ||
409 | |||
410 | this.send_other_apper(User_info,new LLUUID("00000000-0000-0000-5665-000000000034")); | ||
411 | |||
412 | } | ||
413 | |||
414 | public void send_other_avatar_position(User_Agent_info User_info, Avatar_data avd) | ||
415 | { | 421 | { |
416 | //send a objectupdate packet with information about the clients avatar | 422 | //send a objectupdate packet with information about the clients avatar |
417 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 423 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
418 | objupdate.RegionData.RegionHandle=1096213093147648; | 424 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
419 | objupdate.RegionData.TimeDilation=64500; | 425 | objupdate.RegionData.TimeDilation=64500; |
420 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | 426 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; |
421 | 427 | ||
422 | objupdate.ObjectData[0]=avatar_template; | 428 | objupdate.ObjectData[0]=AvatarTemplate; |
423 | //give this avatar object a local id and assign the user a name | 429 | //give this avatar object a local id and assign the user a name |
424 | objupdate.ObjectData[0].ID=avd.Net_info.localID; | 430 | objupdate.ObjectData[0].ID=avd.NetInfo.localID; |
425 | objupdate.ObjectData[0].FullID=avd.Net_info.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034"); | 431 | objupdate.ObjectData[0].FullID=avd.NetInfo.AgentID;//new LLUUID("00000000-0000-0000-5665-000000000034"); |
426 | objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.Net_info.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); | 432 | objupdate.ObjectData[0].NameValue=enc.GetBytes(avd.NetInfo.name);//enc.GetBytes("FirstName STRING RW SV Test"+ this.local_numer+"\nLastName STRING RW SV User \0"); |
427 | libsecondlife.LLVector3 pos2=new LLVector3(avd.pos.X,avd.pos.Y,avd.pos.Z); | 433 | libsecondlife.LLVector3 pos2=new LLVector3(avd.Position.X,avd.Position.Y,avd.Position.Z); |
428 | 434 | ||
429 | byte[] pb=pos2.GetBytes(); | 435 | byte[] pb=pos2.GetBytes(); |
430 | 436 | ||
@@ -433,11 +439,16 @@ namespace Second_server | |||
433 | 439 | ||
434 | server.SendPacket(objupdate,true,User_info); | 440 | server.SendPacket(objupdate,true,User_info); |
435 | 441 | ||
436 | this.send_other_apper(User_info,avd.Net_info.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034")); | 442 | this.SendOtherAppearance(User_info,avd.NetInfo.AgentID);//new LLUUID("00000000-0000-0000-5665-000000000034")); |
437 | 443 | ||
438 | } | 444 | } |
439 | //************************************************************* | 445 | |
440 | public void send_chat_message(User_Agent_info User_info, string line) | 446 | /// <summary> |
447 | /// | ||
448 | /// </summary> | ||
449 | /// <param name="User_info"></param> | ||
450 | /// <param name="line"></param> | ||
451 | public void SendChatMessage(User_Agent_info User_info, string line) | ||
441 | { | 452 | { |
442 | libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); | 453 | libsecondlife.Packets.ChatFromSimulatorPacket reply=new ChatFromSimulatorPacket(); |
443 | reply.ChatData.Audible=1; | 454 | reply.ChatData.Audible=1; |
@@ -452,23 +463,33 @@ namespace Second_server | |||
452 | server.SendPacket(reply,true,User_info); | 463 | server.SendPacket(reply,true,User_info); |
453 | 464 | ||
454 | //send to all users | 465 | //send to all users |
455 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 466 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
456 | { | 467 | { |
457 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 468 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
458 | { | 469 | { |
459 | server.SendPacket(reply,true,kp.Value.Net_info); | 470 | server.SendPacket(reply,true,kp.Value.NetInfo); |
460 | } | 471 | } |
461 | } | 472 | } |
462 | } | 473 | } |
463 | //************************************************************* | 474 | |
464 | public void send_move_command(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) | 475 | /// <summary> |
476 | /// | ||
477 | /// </summary> | ||
478 | /// <param name="user"></param> | ||
479 | /// <param name="stop"></param> | ||
480 | /// <param name="x"></param> | ||
481 | /// <param name="y"></param> | ||
482 | /// <param name="z"></param> | ||
483 | /// <param name="av_id"></param> | ||
484 | /// <param name="body"></param> | ||
485 | public void SendMoveCommand(User_Agent_info user, bool stop,float x, float y, float z, uint av_id, libsecondlife.LLQuaternion body) | ||
465 | { | 486 | { |
466 | uint ID=user.localID; | 487 | uint ID=user.localID; |
467 | //ID=av_id; | 488 | //ID=av_id; |
468 | byte[] bytes=new byte[60]; | 489 | byte[] bytes=new byte[60]; |
469 | 490 | ||
470 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); | 491 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); |
471 | im.RegionData.RegionHandle=1096213093147648; | 492 | im.RegionData.RegionHandle=Globals.Instance.RegionHandle;; |
472 | im.RegionData.TimeDilation=64096; | 493 | im.RegionData.TimeDilation=64096; |
473 | 494 | ||
474 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 495 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
@@ -477,7 +498,7 @@ namespace Second_server | |||
477 | 498 | ||
478 | im.ObjectData[0]=dat; | 499 | im.ObjectData[0]=dat; |
479 | 500 | ||
480 | dat.TextureEntry=avatar_template.TextureEntry; | 501 | dat.TextureEntry=AvatarTemplate.TextureEntry; |
481 | libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); | 502 | libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); |
482 | 503 | ||
483 | bytes[i++] = (byte)(ID % 256); | 504 | bytes[i++] = (byte)(ID % 256); |
@@ -571,16 +592,22 @@ namespace Second_server | |||
571 | server.SendPacket(im,true,user); | 592 | server.SendPacket(im,true,user); |
572 | 593 | ||
573 | //should send to all users. | 594 | //should send to all users. |
574 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in this.Agent_list) | 595 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in this.AgentList) |
575 | { | 596 | { |
576 | if(kp.Value.Net_info.AgentID!=user.AgentID) | 597 | if(kp.Value.NetInfo.AgentID!=user.AgentID) |
577 | { | 598 | { |
578 | server.SendPacket(im,true,kp.Value.Net_info); | 599 | server.SendPacket(im,true,kp.Value.NetInfo); |
579 | } | 600 | } |
580 | } | 601 | } |
581 | } | 602 | } |
582 | //************************************************************* | 603 | |
583 | public void read_layerdata(User_Agent_info User_info,ref LayerDataPacket lay,string name) | 604 | /// <summary> |
605 | /// | ||
606 | /// </summary> | ||
607 | /// <param name="User_info"></param> | ||
608 | /// <param name="lay"></param> | ||
609 | /// <param name="name"></param> | ||
610 | public void SendLayerData(User_Agent_info User_info,ref LayerDataPacket lay,string name) | ||
584 | { | 611 | { |
585 | FileInfo fInfo = new FileInfo(name); | 612 | FileInfo fInfo = new FileInfo(name); |
586 | 613 | ||
@@ -590,7 +617,7 @@ namespace Second_server | |||
590 | 617 | ||
591 | BinaryReader br = new BinaryReader(fStream); | 618 | BinaryReader br = new BinaryReader(fStream); |
592 | 619 | ||
593 | data1 = br.ReadBytes((int)numBytes); | 620 | byte [] data1 = br.ReadBytes((int)numBytes); |
594 | 621 | ||
595 | br.Close(); | 622 | br.Close(); |
596 | 623 | ||
@@ -601,18 +628,32 @@ namespace Second_server | |||
601 | } | 628 | } |
602 | } | 629 | } |
603 | 630 | ||
604 | public class Avatar_data | 631 | public class AvatarData |
605 | { | 632 | { |
606 | public User_Agent_info Net_info; | 633 | public User_Agent_info NetInfo; |
607 | public LLUUID Full_ID; | 634 | public LLUUID FullID; |
608 | public LLVector3 pos; | 635 | public LLVector3 Position; |
609 | public LLVector3 vel=new LLVector3(0,0,0); | 636 | public LLVector3 Velocity=new LLVector3(0,0,0); |
610 | public bool walk=false; | 637 | //public LLQuaternion Rotation; |
611 | public bool started=false; | 638 | public bool Walk=false; |
639 | public bool Started=false; | ||
640 | //public TextureEntry TextureEntry; | ||
612 | 641 | ||
613 | public Avatar_data() | 642 | public AvatarData() |
614 | { | 643 | { |
615 | 644 | ||
616 | } | 645 | } |
617 | } | 646 | } |
647 | /* | ||
648 | public class AvatarParams | ||
649 | { | ||
650 | public byte[] Params; | ||
651 | |||
652 | public AvatarParams() | ||
653 | { | ||
654 | |||
655 | } | ||
656 | |||
657 | } | ||
658 | */ | ||
618 | } | 659 | } |
diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs index 2738c92..3fc9cb3 100644 --- a/AssemblyInfo.cs +++ b/AssemblyInfo.cs | |||
@@ -36,11 +36,11 @@ using System.Runtime.InteropServices; | |||
36 | // change them to the information which is associated with the assembly | 36 | // change them to the information which is associated with the assembly |
37 | // you compile. | 37 | // you compile. |
38 | 38 | ||
39 | [assembly: AssemblyTitle("Second-server")] | 39 | [assembly: AssemblyTitle("OpenSim")] |
40 | [assembly: AssemblyDescription("")] | 40 | [assembly: AssemblyDescription("")] |
41 | [assembly: AssemblyConfiguration("")] | 41 | [assembly: AssemblyConfiguration("")] |
42 | [assembly: AssemblyCompany("")] | 42 | [assembly: AssemblyCompany("")] |
43 | [assembly: AssemblyProduct("Second-server")] | 43 | [assembly: AssemblyProduct("OpenSim")] |
44 | [assembly: AssemblyCopyright("")] | 44 | [assembly: AssemblyCopyright("")] |
45 | [assembly: AssemblyTrademark("")] | 45 | [assembly: AssemblyTrademark("")] |
46 | [assembly: AssemblyCulture("")] | 46 | [assembly: AssemblyCulture("")] |
@@ -56,4 +56,4 @@ using System.Runtime.InteropServices; | |||
56 | // You can specify all values by your own or you can build default build and revision | 56 | // You can specify all values by your own or you can build default build and revision |
57 | // numbers with the '*' character (the default): | 57 | // numbers with the '*' character (the default): |
58 | 58 | ||
59 | [assembly: AssemblyVersion("1.0.*")] | 59 | [assembly: AssemblyVersion("0.1.*")] |
diff --git a/Asset_manager.cs b/Asset_manager.cs index 3723e1d..20cf3a1 100644 --- a/Asset_manager.cs +++ b/Asset_manager.cs | |||
@@ -34,26 +34,26 @@ using libsecondlife.Packets; | |||
34 | using libsecondlife.AssetSystem; | 34 | using libsecondlife.AssetSystem; |
35 | using System.IO; | 35 | using System.IO; |
36 | 36 | ||
37 | namespace Second_server | 37 | namespace OpenSim |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// Description of Asset_manager. | 40 | /// Description of Asset_manager. |
41 | /// </summary> | 41 | /// </summary> |
42 | public class Asset_manager | 42 | public class AssetManager |
43 | { | 43 | { |
44 | public Dictionary<libsecondlife.LLUUID,Asset_info> Assets; | 44 | public Dictionary<libsecondlife.LLUUID,AssetInfo> Assets; |
45 | public ArrayList requests=new ArrayList(); //should change to a generic | 45 | public ArrayList requests=new ArrayList(); //should change to a generic |
46 | // public ArrayList uploads=new ArrayList(); | 46 | // public ArrayList uploads=new ArrayList(); |
47 | private Server server; | 47 | private Server server; |
48 | 48 | ||
49 | public Asset_manager(Server serve) | 49 | public AssetManager(Server serve) |
50 | { | 50 | { |
51 | server=serve; | 51 | server=serve; |
52 | Assets=new Dictionary<libsecondlife.LLUUID,Asset_info> (); | 52 | Assets=new Dictionary<libsecondlife.LLUUID,AssetInfo> (); |
53 | this.initialise(); | 53 | this.initialise(); |
54 | } | 54 | } |
55 | 55 | ||
56 | public void add_request(User_Agent_info user, LLUUID asset_id, TransferRequestPacket tran_req) | 56 | public void AddRequest(User_Agent_info user, LLUUID asset_id, TransferRequestPacket tran_req) |
57 | { | 57 | { |
58 | 58 | ||
59 | if(!this.Assets.ContainsKey(asset_id)) | 59 | if(!this.Assets.ContainsKey(asset_id)) |
@@ -61,18 +61,18 @@ namespace Second_server | |||
61 | //not found asset | 61 | //not found asset |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | Asset_info info=this.Assets[asset_id]; | 64 | AssetInfo info=this.Assets[asset_id]; |
65 | System.Console.WriteLine("send asset : "+asset_id); | 65 | System.Console.WriteLine("send asset : "+asset_id); |
66 | //for now as it will be only skin or shape request just send back the asset | 66 | //for now as it will be only skin or shape request just send back the asset |
67 | TransferInfoPacket tran_i=new TransferInfoPacket(); | 67 | TransferInfoPacket Transfer=new TransferInfoPacket(); |
68 | tran_i.TransferInfo.ChannelType=2; | 68 | Transfer.TransferInfo.ChannelType=2; |
69 | tran_i.TransferInfo.Status=0; | 69 | Transfer.TransferInfo.Status=0; |
70 | tran_i.TransferInfo.TargetType=0; | 70 | Transfer.TransferInfo.TargetType=0; |
71 | tran_i.TransferInfo.Params=tran_req.TransferInfo.Params; | 71 | Transfer.TransferInfo.Params=tran_req.TransferInfo.Params; |
72 | tran_i.TransferInfo.Size=info.data.Length; | 72 | Transfer.TransferInfo.Size=info.data.Length; |
73 | tran_i.TransferInfo.TransferID=tran_req.TransferInfo.TransferID; | 73 | Transfer.TransferInfo.TransferID=tran_req.TransferInfo.TransferID; |
74 | 74 | ||
75 | server.SendPacket(tran_i,true,user); | 75 | server.SendPacket(Transfer,true,user); |
76 | 76 | ||
77 | TransferPacketPacket tran_p=new TransferPacketPacket(); | 77 | TransferPacketPacket tran_p=new TransferPacketPacket(); |
78 | tran_p.TransferData.Packet=0; | 78 | tran_p.TransferData.Packet=0; |
@@ -110,14 +110,17 @@ namespace Second_server | |||
110 | private void initialise() | 110 | private void initialise() |
111 | { | 111 | { |
112 | //for now read in our test image | 112 | //for now read in our test image |
113 | Asset_info im=new Asset_info(); | 113 | AssetInfo im=new AssetInfo(); |
114 | im.filename="base_shape.dat"; | 114 | im.filename="base_shape.dat"; |
115 | im.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | 115 | im.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); |
116 | this.load_asset(im); | 116 | this.loadAsset(im); |
117 | this.Assets.Add(im.Full_ID,im); | 117 | this.Assets.Add(im.Full_ID,im); |
118 | } | 118 | } |
119 | private void load_asset(Asset_info info) | 119 | private void loadAsset(AssetInfo info) |
120 | { | 120 | { |
121 | //should request Asset from storage manager | ||
122 | //but for now read from file | ||
123 | |||
121 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\assets\"; | 124 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\assets\"; |
122 | string filename=data_path+@info.filename; | 125 | string filename=data_path+@info.filename; |
123 | FileInfo fInfo = new FileInfo(filename); | 126 | FileInfo fInfo = new FileInfo(filename); |
@@ -135,21 +138,21 @@ namespace Second_server | |||
135 | } | 138 | } |
136 | } | 139 | } |
137 | 140 | ||
138 | public class Asset_request | 141 | public class AssetRequest |
139 | { | 142 | { |
140 | public User_Agent_info req_user; | 143 | public User_Agent_info RequestUser; |
141 | public LLUUID req_image; | 144 | public LLUUID RequestImage; |
142 | public Asset_info asset_inf; | 145 | public AssetInfo asset_inf; |
143 | public long data_pointer=0; | 146 | public long data_pointer=0; |
144 | public int num_packets=0; | 147 | public int num_packets=0; |
145 | public int packet_counter=0; | 148 | public int packet_counter=0; |
146 | 149 | ||
147 | public Asset_request() | 150 | public AssetRequest() |
148 | { | 151 | { |
149 | 152 | ||
150 | } | 153 | } |
151 | } | 154 | } |
152 | public class Asset_info | 155 | public class AssetInfo |
153 | { | 156 | { |
154 | public byte[] data; | 157 | public byte[] data; |
155 | public LLUUID Full_ID; | 158 | public LLUUID Full_ID; |
@@ -159,7 +162,7 @@ namespace Second_server | |||
159 | public ulong last_used; //need to add a tick/time counter and keep record | 162 | public ulong last_used; //need to add a tick/time counter and keep record |
160 | // of how often images are requested to unload unused ones. | 163 | // of how often images are requested to unload unused ones. |
161 | 164 | ||
162 | public Asset_info() | 165 | public AssetInfo() |
163 | { | 166 | { |
164 | 167 | ||
165 | } | 168 | } |
diff --git a/Controller.cs b/Controller.cs index 351ff65..f2bd85c 100644 --- a/Controller.cs +++ b/Controller.cs | |||
@@ -38,11 +38,12 @@ using System.IO; | |||
38 | using Axiom.MathLib; | 38 | using Axiom.MathLib; |
39 | using log4net; | 39 | using log4net; |
40 | 40 | ||
41 | namespace Second_server { | 41 | namespace OpenSim |
42 | { | ||
42 | /// <summary> | 43 | /// <summary> |
43 | /// Description of MainForm. | 44 | /// Description of MainForm. |
44 | /// </summary> | 45 | /// </summary> |
45 | public partial class Controller : Server_callback { | 46 | public partial class Controller : ServerCallback { |
46 | 47 | ||
47 | 48 | ||
48 | 49 | ||
@@ -54,51 +55,79 @@ namespace Second_server { | |||
54 | 55 | ||
55 | } | 56 | } |
56 | public Server server; | 57 | public Server server; |
57 | 58 | public Logon _login; | |
58 | private Agent_Manager agent_man; | 59 | private AgentManager Agent_Manager; |
59 | private Prim_manager prim_man; | 60 | private PrimManager Prim_Manager; |
60 | private Texture_manager texture_man; | 61 | private TextureManager Texture_Manager; |
61 | private Asset_manager asset_man; | 62 | private AssetManager Asset_Manager; |
62 | private Login_manager login_man; //built in login server | 63 | private GridManager Grid_Manager; |
64 | private LoginManager Login_Manager; //built in login server | ||
63 | private ulong time; //ticks | 65 | private ulong time; //ticks |
64 | private Timer timer1 = new Timer(); | 66 | private Timer timer1 = new Timer(); |
65 | 67 | ||
66 | 68 | ||
67 | public Controller() { | 69 | public Controller() { |
70 | _login=new Logon(); // should create a list for these. | ||
68 | server = new Server( this ); | 71 | server = new Server( this ); |
69 | agent_man = new Agent_Manager( this.server ); | 72 | Agent_Manager = new AgentManager( this.server ); |
70 | prim_man = new Prim_manager( this.server ); | 73 | Prim_Manager = new PrimManager( this.server ); |
71 | texture_man = new Texture_manager( this.server ); | 74 | Texture_Manager = new TextureManager( this.server ); |
72 | asset_man = new Asset_manager( this.server ); | 75 | Asset_Manager = new AssetManager( this.server ); |
73 | prim_man.agent_man = agent_man; | 76 | Prim_Manager.Agent_Manager = Agent_Manager; |
74 | agent_man.prim_man = prim_man; | 77 | Agent_Manager.Prim_Manager = Prim_Manager; |
75 | login_man = new Login_manager(); // startup | 78 | Grid_Manager=new GridManager(this.server,Agent_Manager); |
76 | login_man.startup(); // login server | 79 | if(Globals.Instance.LoginSever) |
77 | timer1.Enabled = true; | 80 | { |
81 | Console.WriteLine("Starting login Server"); | ||
82 | Login_Manager = new LoginManager(_login); // startup | ||
83 | Login_Manager.Startup(); // login server | ||
84 | } | ||
85 | timer1.Enabled = true; | ||
78 | timer1.Interval = 200; | 86 | timer1.Interval = 200; |
79 | timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick ); | 87 | timer1.Elapsed +=new ElapsedEventHandler( this.Timer1Tick ); |
80 | 88 | ||
81 | 89 | ||
82 | } | 90 | } |
83 | public void main_callback( Packet pack, User_Agent_info User_info ) { | 91 | public void MainCallback( Packet pack, User_Agent_info User_info ) { |
84 | if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { | 92 | //System.Console.WriteLine(pack.Type); |
85 | System.Console.WriteLine(pack.Type); | 93 | if( ( pack.Type != PacketType.StartPingCheck ) && ( pack.Type != PacketType.AgentUpdate ) ) { |
94 | // System.Console.WriteLine(pack.Type); | ||
86 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; | 95 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; |
87 | } | 96 | } |
88 | if( pack.Type == PacketType.AgentSetAppearance ) { | 97 | if( pack.Type == PacketType.AgentSetAppearance ) { |
89 | System.Console.WriteLine(pack); | 98 | // System.Console.WriteLine(pack); |
90 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; | 99 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; |
91 | 100 | ||
92 | } | 101 | } |
102 | if(pack.Type== PacketType.MapBlockRequest) | ||
103 | { | ||
104 | //int MinX, MinY, MaxX, MaxY; | ||
105 | MapBlockRequestPacket MapRequest=(MapBlockRequestPacket)pack; | ||
106 | this.Grid_Manager.RequestMapBlock(User_info,MapRequest.PositionData.MinX,MapRequest.PositionData.MinY,MapRequest.PositionData.MaxX,MapRequest.PositionData.MaxY); | ||
107 | |||
108 | } | ||
109 | if(pack.Type== PacketType.CloseCircuit) | ||
110 | { | ||
111 | this.Agent_Manager.RemoveAgent(User_info); | ||
112 | } | ||
113 | if(pack.Type== PacketType.MapLayerRequest) | ||
114 | { | ||
115 | this.Grid_Manager.RequestMapLayer(User_info); | ||
116 | |||
117 | } | ||
118 | if((pack.Type== PacketType.TeleportRequest ) ||(pack.Type== PacketType.TeleportLocationRequest)) | ||
119 | { | ||
120 | TeleportLocationRequestPacket Request=(TeleportLocationRequestPacket)pack; | ||
121 | |||
122 | this.Grid_Manager.RequestTeleport(User_info,Request); | ||
123 | |||
124 | } | ||
93 | if( pack.Type == PacketType.TransferRequest ) { | 125 | if( pack.Type == PacketType.TransferRequest ) { |
94 | TransferRequestPacket tran = (TransferRequestPacket)pack; | 126 | TransferRequestPacket tran = (TransferRequestPacket)pack; |
95 | LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); | 127 | LLUUID id = new LLUUID( tran.TransferInfo.Params, 0 ); |
96 | 128 | ||
97 | if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) { | 129 | if( ( id == new LLUUID( "66c41e39-38f9-f75a-024e-585989bfab73" ) ) || ( id == new LLUUID( "e0ee49b5a4184df8d3c9a65361fe7f49" ) ) ) { |
98 | //System.Console.WriteLine(pack); | 130 | Asset_Manager.AddRequest( User_info, id, tran ); |
99 | //System.Console.WriteLine(tran.TransferInfo.TransferID); | ||
100 | asset_man.add_request( User_info, id, tran ); | ||
101 | //this.richTextBox1.Text=this.richTextBox1.Text+"\n "+pack.Type; | ||
102 | } | 131 | } |
103 | 132 | ||
104 | } | 133 | } |
@@ -111,23 +140,23 @@ namespace Second_server { | |||
111 | } | 140 | } |
112 | if( pack.Type == PacketType.CompleteAgentMovement ) { | 141 | if( pack.Type == PacketType.CompleteAgentMovement ) { |
113 | // new client | 142 | // new client |
114 | agent_man.Agent_join( User_info ); | 143 | Agent_Manager.AgentJoin( User_info ); |
115 | } | 144 | } |
116 | if( pack.Type == PacketType.RequestImage ) { | 145 | if( pack.Type == PacketType.RequestImage ) { |
117 | RequestImagePacket image_req = (RequestImagePacket)pack; | 146 | RequestImagePacket image_req = (RequestImagePacket)pack; |
118 | for( int i = 0; i < image_req.RequestImage.Length; i++ ) { | 147 | for( int i = 0; i < image_req.RequestImage.Length; i++ ) { |
119 | this.texture_man.add_request( User_info, image_req.RequestImage[ i ].Image ); | 148 | this.Texture_Manager.AddRequest( User_info, image_req.RequestImage[ i ].Image ); |
120 | 149 | ||
121 | } | 150 | } |
122 | } | 151 | } |
123 | if( pack.Type == PacketType.RegionHandshakeReply ) { | 152 | if( pack.Type == PacketType.RegionHandshakeReply ) { |
124 | //recieved regionhandshake so can now start sending info | 153 | //recieved regionhandshake so can now start sending info |
125 | agent_man.send_intial_data( User_info ); | 154 | Agent_Manager.SendInitialData( User_info ); |
126 | //this.setuptemplates("objectupate164.dat",User_info,false); | 155 | //this.setuptemplates("objectupate164.dat",User_info,false); |
127 | } | 156 | } |
128 | if( pack.Type == PacketType.ObjectAdd ) { | 157 | if( pack.Type == PacketType.ObjectAdd ) { |
129 | ObjectAddPacket ad = (ObjectAddPacket)pack; | 158 | ObjectAddPacket ad = (ObjectAddPacket)pack; |
130 | prim_man.create_prim( User_info, ad.ObjectData.RayEnd, ad ); | 159 | Prim_Manager.CreatePrim( User_info, ad.ObjectData.RayEnd, ad ); |
131 | //this.send_prim(User_info,ad.ObjectData.RayEnd, ad); | 160 | //this.send_prim(User_info,ad.ObjectData.RayEnd, ad); |
132 | } | 161 | } |
133 | if( pack.Type == PacketType.ObjectPosition ) { | 162 | if( pack.Type == PacketType.ObjectPosition ) { |
@@ -141,46 +170,55 @@ namespace Second_server { | |||
141 | if( mupd.ObjectData[ i ].Type == 9 ) //change position | 170 | if( mupd.ObjectData[ i ].Type == 9 ) //change position |
142 | { | 171 | { |
143 | libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 ); | 172 | libsecondlife.LLVector3 pos = new LLVector3( mupd.ObjectData[ i ].Data, 0 ); |
144 | 173 | // libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,12,true); | |
145 | prim_man.update_prim_position( User_info, pos.X, pos.Y, pos.Z, mupd.ObjectData[ i ].ObjectLocalID ); | 174 | Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,false ,libsecondlife.LLQuaternion.Identity); |
146 | //should update stored position of the prim | 175 | //should update stored position of the prim |
147 | } | 176 | } |
177 | else if( mupd.ObjectData[ i ].Type == 10 ) | ||
178 | { | ||
179 | //System.Console.WriteLine(mupd.ObjectData[ i ].Type); | ||
180 | //System.Console.WriteLine(mupd); | ||
181 | libsecondlife.LLVector3 pos = new LLVector3(100,100,22); | ||
182 | libsecondlife.LLQuaternion rot=new LLQuaternion(mupd.ObjectData[i].Data,0,true); | ||
183 | Prim_Manager.UpdatePrimPosition( User_info, pos, mupd.ObjectData[ i ].ObjectLocalID ,true ,rot); | ||
184 | |||
185 | } | ||
148 | } | 186 | } |
149 | } | 187 | } |
150 | if( pack.Type == PacketType.AgentWearablesRequest ) { | 188 | if( pack.Type == PacketType.AgentWearablesRequest ) { |
151 | agent_man.send_intial_avatar_apper( User_info ); | 189 | Agent_Manager.SendIntialAvatarAppearance( User_info ); |
152 | } | 190 | } |
153 | 191 | ||
154 | if( pack.Type == PacketType.AgentUpdate ) { | 192 | if( pack.Type == PacketType.AgentUpdate ) { |
155 | AgentUpdatePacket ag = (AgentUpdatePacket)pack; | 193 | AgentUpdatePacket ag = (AgentUpdatePacket)pack; |
156 | uint mask = ag.AgentData.ControlFlags & ( 1 ); | 194 | uint mask = ag.AgentData.ControlFlags & ( 1 ); |
157 | Avatar_data m_av = agent_man.Get_Agent( User_info.AgentID ); | 195 | AvatarData m_av = Agent_Manager.GetAgent( User_info.AgentID ); |
158 | if( m_av != null ) { | 196 | if( m_av != null ) { |
159 | if( m_av.started ) { | 197 | if( m_av.Started ) { |
160 | if( mask == ( 1 ) ) { | 198 | if( mask == ( 1 ) ) { |
161 | if( !m_av.walk ) { | 199 | if( !m_av.Walk ) { |
162 | //start walking | 200 | //start walking |
163 | agent_man.send_move_command( User_info, false, m_av.pos.X, m_av.pos.Y, m_av.pos.Z, 0, ag.AgentData.BodyRotation ); | 201 | Agent_Manager.SendMoveCommand( User_info, false, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation ); |
164 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 ); | 202 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3( 1, 0, 0 ); |
165 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z ); | 203 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion( ag.AgentData.BodyRotation.W, ag.AgentData.BodyRotation.X, ag.AgentData.BodyRotation.Y, ag.AgentData.BodyRotation.Z ); |
166 | Axiom.MathLib.Vector3 direc = q * v3; | 204 | Axiom.MathLib.Vector3 direc = q * v3; |
167 | direc.Normalize(); | 205 | direc.Normalize(); |
168 | direc = direc * ( ( 0.03f ) * 128f ); | 206 | direc = direc * ( ( 0.03f ) * 128f ); |
169 | 207 | ||
170 | m_av.vel.X = direc.x; | 208 | m_av.Velocity.X = direc.x; |
171 | m_av.vel.Y = direc.y; | 209 | m_av.Velocity.Y = direc.y; |
172 | m_av.vel.Z = direc.z; | 210 | m_av.Velocity.Z = direc.z; |
173 | m_av.walk = true; | 211 | m_av.Walk = true; |
174 | } | 212 | } |
175 | } | 213 | } |
176 | else { | 214 | else { |
177 | if( m_av.walk ) { | 215 | if( m_av.Walk ) { |
178 | //walking but key not pressed so need to stop | 216 | //walking but key not pressed so need to stop |
179 | agent_man.send_move_command( User_info, true, m_av.pos.X, m_av.pos.Y, m_av.pos.Z, 0, ag.AgentData.BodyRotation ); | 217 | Agent_Manager.SendMoveCommand( User_info, true, m_av.Position.X, m_av.Position.Y, m_av.Position.Z, 0, ag.AgentData.BodyRotation ); |
180 | m_av.walk = false; | 218 | m_av.Walk = false; |
181 | m_av.vel.X = 0; | 219 | m_av.Velocity.X = 0; |
182 | m_av.vel.Y = 0; | 220 | m_av.Velocity.Y = 0; |
183 | m_av.vel.Z = 0; | 221 | m_av.Velocity.Z = 0; |
184 | } | 222 | } |
185 | } | 223 | } |
186 | } | 224 | } |
@@ -205,25 +243,52 @@ namespace Second_server { | |||
205 | else if( comp[ 0 ] == "veloc" ) { | 243 | else if( comp[ 0 ] == "veloc" ) { |
206 | } | 244 | } |
207 | else { | 245 | else { |
208 | agent_man.send_chat_message( User_info, line ); | 246 | Agent_Manager.SendChatMessage( User_info, line ); |
209 | 247 | ||
210 | } | 248 | } |
211 | } | 249 | } |
212 | } | 250 | } |
213 | } | 251 | } |
214 | public void new_user( User_Agent_info User_info ) { | 252 | public void NewUserCallback( User_Agent_info UserInfo ) { |
215 | Console.WriteLine( "new user - {0} - has joined [session {1}]", User_info.AgentID.ToString(), User_info.SessionID.ToString() ); | 253 | Console.WriteLine( "new user - {0} - has joined [session {1}]", UserInfo.AgentID.ToString(), UserInfo.SessionID.ToString() +"curcuit used"+UserInfo.circuitCode); |
216 | agent_man.New_Agent( User_info ); | 254 | string first,last; |
255 | lock(_login) | ||
256 | { | ||
257 | first=_login.first; | ||
258 | last=_login.last; | ||
259 | |||
260 | //should get agentid and sessionid so they can be checked. | ||
261 | } | ||
262 | Agent_Manager.NewAgent( UserInfo ,first,last); | ||
263 | //now because of the lack of Global account management (User server etc) | ||
264 | //we need to reset the names back to default incase a teleport happens | ||
265 | //which will not have a Login name set, so they will use default names | ||
266 | lock(_login) | ||
267 | { | ||
268 | _login.first="Test"; | ||
269 | _login.last="User"; | ||
270 | } | ||
217 | } | 271 | } |
218 | 272 | ||
219 | public void error( string text ) { | 273 | public void ErrorCallback( string text ) { |
220 | Console.WriteLine( "error report: {0}", text ); | 274 | Console.WriteLine( "error report: {0}", text ); |
221 | } | 275 | } |
222 | 276 | ||
223 | void Timer1Tick( object sender, System.EventArgs e ) { | 277 | void Timer1Tick( object sender, System.EventArgs e ) { |
224 | this.time++; | 278 | this.time++; |
225 | agent_man.tick(); | 279 | Agent_Manager.UpdatePositions(); |
226 | texture_man.Do_work( time ); | 280 | Texture_Manager.DoWork( time ); |
227 | } | 281 | } |
228 | } | 282 | } |
229 | } \ No newline at end of file | 283 | public class Logon |
284 | { | ||
285 | public string first="Test"; | ||
286 | public string last="User"; | ||
287 | public LLUUID Agent; | ||
288 | public LLUUID Session; | ||
289 | public Logon() | ||
290 | { | ||
291 | |||
292 | } | ||
293 | } | ||
294 | } | ||
diff --git a/Login_manager.cs b/Login_manager.cs index 84f475d..a41bde3 100644 --- a/Login_manager.cs +++ b/Login_manager.cs | |||
@@ -25,7 +25,7 @@ | |||
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ | 27 | */ |
28 | 28 | using Nwc.XmlRpc; | |
29 | using System; | 29 | using System; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net; | 31 | using System.Net; |
@@ -33,24 +33,27 @@ using System.Net.Sockets; | |||
33 | using System.Text; | 33 | using System.Text; |
34 | using System.Text.RegularExpressions; | 34 | using System.Text.RegularExpressions; |
35 | using System.Threading; | 35 | using System.Threading; |
36 | using System.Collections; | ||
37 | using libsecondlife; | ||
36 | 38 | ||
37 | namespace Second_server | 39 | namespace OpenSim |
38 | { | 40 | { |
39 | /// <summary> | 41 | /// <summary> |
40 | /// Description of Login_manager. | 42 | /// Description of Login_manager. |
41 | /// </summary> | 43 | /// </summary> |
42 | public class Login_manager | 44 | public class LoginManager |
43 | { | 45 | { |
44 | public Login_manager() | 46 | public LoginManager(Logon login) |
45 | { | 47 | { |
46 | 48 | Login=login; | |
47 | } | 49 | } |
48 | 50 | public Logon Login; | |
49 | public ushort loginPort = 8080; | 51 | public ushort loginPort = 8080; |
50 | public IPAddress clientAddress = IPAddress.Loopback; | 52 | public IPAddress clientAddress = IPAddress.Loopback; |
51 | public IPAddress remoteAddress = IPAddress.Any; | 53 | public IPAddress remoteAddress = IPAddress.Any; |
52 | private Socket loginServer; | 54 | private Socket loginServer; |
53 | private Random RandomClass = new Random(); | 55 | private Random RandomClass = new Random(); |
56 | private int NumClients; | ||
54 | 57 | ||
55 | // InitializeLoginProxy: initialize the login proxy | 58 | // InitializeLoginProxy: initialize the login proxy |
56 | private void InitializeLoginProxy() { | 59 | private void InitializeLoginProxy() { |
@@ -59,7 +62,7 @@ namespace Second_server | |||
59 | loginServer.Listen(1); | 62 | loginServer.Listen(1); |
60 | } | 63 | } |
61 | 64 | ||
62 | public void startup() | 65 | public void Startup() |
63 | { | 66 | { |
64 | this.InitializeLoginProxy(); | 67 | this.InitializeLoginProxy(); |
65 | Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy)); | 68 | Thread runLoginProxy = new Thread(new ThreadStart(RunLoginProxy)); |
@@ -67,7 +70,7 @@ namespace Second_server | |||
67 | runLoginProxy.Start(); | 70 | runLoginProxy.Start(); |
68 | } | 71 | } |
69 | 72 | ||
70 | private void RunLoginProxy() { | 73 | private void RunLoginProxy() { |
71 | try { | 74 | try { |
72 | for (;;) { | 75 | for (;;) { |
73 | Socket client = loginServer.Accept(); | 76 | Socket client = loginServer.Accept(); |
@@ -121,11 +124,52 @@ namespace Second_server | |||
121 | if (match.Success) | 124 | if (match.Success) |
122 | contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); | 125 | contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString()); |
123 | } while (line != ""); | 126 | } while (line != ""); |
124 | System.Console.WriteLine(line); | 127 | |
125 | // read the HTTP body into a buffer | 128 | // read the HTTP body into a buffer |
126 | char[] content = new char[contentLength]; | 129 | char[] content = new char[contentLength]; |
127 | reader.Read(content, 0, contentLength); | 130 | reader.Read(content, 0, contentLength); |
128 | 131 | // System.Text.Encoding enc = System.Text.Encoding.ASCII; | |
132 | XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content)); | ||
133 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
134 | |||
135 | string first; | ||
136 | string last; | ||
137 | LLUUID Agent; | ||
138 | LLUUID Session; | ||
139 | |||
140 | //get login name | ||
141 | if(requestData.Contains("first")) | ||
142 | { | ||
143 | first=(string)requestData["first"]; | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | first="test"; | ||
148 | } | ||
149 | if(requestData.Contains("last")) | ||
150 | { | ||
151 | last=(string)requestData["last"]; | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | last="User"+NumClients.ToString(); | ||
156 | } | ||
157 | NumClients++; | ||
158 | |||
159 | //create a agent and session LLUUID | ||
160 | int AgentRand=this.RandomClass.Next(1,9999); | ||
161 | Agent=new LLUUID("99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead"); | ||
162 | int SessionRand=this.RandomClass.Next(1,999); | ||
163 | Session=new LLUUID("aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797"); | ||
164 | |||
165 | //copy data to login object | ||
166 | lock(Login) | ||
167 | { | ||
168 | Login.first=first; | ||
169 | Login.last=last; | ||
170 | Login.Agent=Agent; | ||
171 | Login.Session=Session; | ||
172 | } | ||
129 | 173 | ||
130 | // forward the XML-RPC response to the client | 174 | // forward the XML-RPC response to the client |
131 | writer.WriteLine("HTTP/1.0 200 OK"); | 175 | writer.WriteLine("HTTP/1.0 200 OK"); |
@@ -138,16 +182,16 @@ namespace Second_server | |||
138 | SR=File.OpenText("login.dat"); | 182 | SR=File.OpenText("login.dat"); |
139 | lines=SR.ReadLine(); | 183 | lines=SR.ReadLine(); |
140 | writer.WriteLine(lines); | 184 | writer.WriteLine(lines); |
141 | lines=SR.ReadLine(); | ||
142 | int ran=this.RandomClass.Next(1,9999); | ||
143 | 185 | ||
144 | lines="<member><name>session_id</name><value><string>99998888-"+ran.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead</string></value></member>"; | 186 | lines=SR.ReadLine(); |
187 | //lines="<member><name>session_id</name><value><string>"+Agent.ToString()+"</string></value></member>"; | ||
188 | lines="<member><name>session_id</name><value><string>99998888-"+AgentRand.ToString("0000")+"-4f52-8ec1-0b1d5cd6aead</string></value></member>"; | ||
145 | writer.WriteLine(lines); | 189 | writer.WriteLine(lines); |
146 | lines=SR.ReadLine(); | 190 | lines=SR.ReadLine(); |
147 | writer.WriteLine(lines); | 191 | writer.WriteLine(lines); |
148 | lines=SR.ReadLine(); | 192 | lines=SR.ReadLine(); |
149 | ran=this.RandomClass.Next(1,9999); | 193 | //lines="<member><name>agent_id</name><value><string>"+Session.ToString()+"</string></value></member>"; |
150 | lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+ran.ToString("0000")+"-8664-58f53e442797</string></value></member>"; | 194 | lines="<member><name>agent_id</name><value><string>aaaabbbb-8932-"+SessionRand.ToString("0000")+"-8664-58f53e442797</string></value></member>"; |
151 | writer.WriteLine(lines); | 195 | writer.WriteLine(lines); |
152 | lines=SR.ReadLine(); | 196 | lines=SR.ReadLine(); |
153 | 197 | ||
diff --git a/Prim_manager.cs b/Prim_manager.cs index da1d626..1dc075b 100644 --- a/Prim_manager.cs +++ b/Prim_manager.cs | |||
@@ -35,53 +35,63 @@ using libsecondlife.AssetSystem; | |||
35 | using System.IO; | 35 | using System.IO; |
36 | using Axiom.MathLib; | 36 | using Axiom.MathLib; |
37 | 37 | ||
38 | namespace Second_server | 38 | namespace OpenSim |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// Description of Prim_manager. | 41 | /// Description of Prim_manager. |
42 | /// </summary> | 42 | /// </summary> |
43 | public class Prim_manager | 43 | public class PrimManager |
44 | { | 44 | { |
45 | private Server server; | 45 | private Server server; |
46 | public Agent_Manager agent_man; | 46 | public AgentManager Agent_Manager; |
47 | 47 | ||
48 | private uint prim_count; | 48 | private uint prim_count; |
49 | 49 | ||
50 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock object_template; | 50 | public libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock PrimTemplate; |
51 | public Dictionary<libsecondlife.LLUUID,prim_info> Prim_list; | 51 | public Dictionary<libsecondlife.LLUUID,PrimInfo> PrimList; |
52 | public Prim_manager(Server serve) | 52 | |
53 | /// <summary> | ||
54 | /// | ||
55 | /// </summary> | ||
56 | /// <param name="serve"></param> | ||
57 | public PrimManager(Server serve) | ||
53 | { | 58 | { |
54 | server=serve; | 59 | server=serve; |
55 | Prim_list=new Dictionary<libsecondlife.LLUUID,prim_info> (); | 60 | PrimList=new Dictionary<libsecondlife.LLUUID,PrimInfo> (); |
56 | this.setuptemplates("objectupate164.dat"); | 61 | this.SetupTemplates("objectupate164.dat"); |
62 | |||
57 | } | 63 | } |
58 | 64 | ||
59 | 65 | /// <summary> | |
60 | //********************************************************************* | 66 | /// |
61 | public void create_prim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack) | 67 | /// </summary> |
68 | /// <param name="User_info"></param> | ||
69 | /// <param name="p1"></param> | ||
70 | /// <param name="add_pack"></param> | ||
71 | public void CreatePrim(User_Agent_info User_info, libsecondlife.LLVector3 p1, ObjectAddPacket add_pack) | ||
62 | { | 72 | { |
63 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 73 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
64 | objupdate.RegionData.RegionHandle=1096213093147648; | 74 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
65 | objupdate.RegionData.TimeDilation=64096; | 75 | objupdate.RegionData.TimeDilation=64096; |
66 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | 76 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; |
67 | 77 | PrimData PData=new PrimData(); | |
68 | objupdate.ObjectData[0]=this.object_template; | 78 | objupdate.ObjectData[0]=this.PrimTemplate; |
69 | objupdate.ObjectData[0].OwnerID=User_info.AgentID; | 79 | PData.OwnerID=objupdate.ObjectData[0].OwnerID=User_info.AgentID; |
70 | objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode; | 80 | PData.PCode=objupdate.ObjectData[0].PCode=add_pack.ObjectData.PCode; |
71 | objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin; | 81 | PData.PathBegin=objupdate.ObjectData[0].PathBegin=add_pack.ObjectData.PathBegin; |
72 | objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd; | 82 | PData.PathEnd=objupdate.ObjectData[0].PathEnd=add_pack.ObjectData.PathEnd; |
73 | objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX; | 83 | PData.PathScaleX=objupdate.ObjectData[0].PathScaleX=add_pack.ObjectData.PathScaleX; |
74 | objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY; | 84 | PData.PathScaleY=objupdate.ObjectData[0].PathScaleY=add_pack.ObjectData.PathScaleY; |
75 | objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX; | 85 | PData.PathShearX=objupdate.ObjectData[0].PathShearX=add_pack.ObjectData.PathShearX; |
76 | objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY; | 86 | PData.PathShearY=objupdate.ObjectData[0].PathShearY=add_pack.ObjectData.PathShearY; |
77 | objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew; | 87 | PData.PathSkew=objupdate.ObjectData[0].PathSkew=add_pack.ObjectData.PathSkew; |
78 | objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin; | 88 | PData.ProfileBegin=objupdate.ObjectData[0].ProfileBegin=add_pack.ObjectData.ProfileBegin; |
79 | objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd; | 89 | PData.ProfileEnd=objupdate.ObjectData[0].ProfileEnd=add_pack.ObjectData.ProfileEnd; |
80 | objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1); | 90 | PData.Scale=objupdate.ObjectData[0].Scale=add_pack.ObjectData.Scale;//new LLVector3(1,1,1); |
81 | objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve; | 91 | PData.PathCurve=objupdate.ObjectData[0].PathCurve=add_pack.ObjectData.PathCurve; |
82 | objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve; | 92 | PData.ProfileCurve=objupdate.ObjectData[0].ProfileCurve=add_pack.ObjectData.ProfileCurve; |
83 | objupdate.ObjectData[0].ParentID=0; | 93 | PData.ParentID=objupdate.ObjectData[0].ParentID=0; |
84 | objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow; | 94 | PData.ProfileHollow=objupdate.ObjectData[0].ProfileHollow=add_pack.ObjectData.ProfileHollow; |
85 | //finish off copying rest of shape data | 95 | //finish off copying rest of shape data |
86 | 96 | ||
87 | objupdate.ObjectData[0].ID=(uint)(702000+prim_count); | 97 | objupdate.ObjectData[0].ID=(uint)(702000+prim_count); |
@@ -95,30 +105,40 @@ namespace Second_server | |||
95 | server.SendPacket(objupdate,true,User_info); | 105 | server.SendPacket(objupdate,true,User_info); |
96 | 106 | ||
97 | //should send to all users | 107 | //should send to all users |
98 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in agent_man.Agent_list) | 108 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList) |
99 | { | 109 | { |
100 | if(kp.Value.Net_info.AgentID!=User_info.AgentID) | 110 | if(kp.Value.NetInfo.AgentID!=User_info.AgentID) |
101 | { | 111 | { |
102 | server.SendPacket(objupdate,true,kp.Value.Net_info); | 112 | server.SendPacket(objupdate,true,kp.Value.NetInfo); |
103 | } | 113 | } |
104 | } | 114 | } |
105 | //should store this infomation | 115 | //should store this infomation |
106 | prim_info n_prim=new prim_info(); | 116 | PrimInfo NewPrim=new PrimInfo(); |
107 | n_prim.full_ID=objupdate.ObjectData[0].FullID; | 117 | NewPrim.FullID=objupdate.ObjectData[0].FullID; |
108 | n_prim.local_ID=objupdate.ObjectData[0].ID; | 118 | NewPrim.LocalID=objupdate.ObjectData[0].ID; |
109 | n_prim.pos=p1; | 119 | NewPrim.Position=p1; |
120 | NewPrim.data=PData; | ||
110 | 121 | ||
111 | this.Prim_list.Add(n_prim.full_ID,n_prim); | 122 | this.PrimList.Add(NewPrim.FullID,NewPrim); |
112 | 123 | ||
113 | //store rest of data | 124 | //store rest of data |
114 | 125 | ||
115 | } | 126 | } |
116 | public void update_prim_position(User_Agent_info user,float x, float y, float z,uint l_id) | 127 | |
128 | /// <summary> | ||
129 | /// | ||
130 | /// </summary> | ||
131 | /// <param name="User"></param> | ||
132 | /// <param name="position"></param> | ||
133 | /// <param name="LocalID"></param> | ||
134 | /// <param name="setRotation"></param> | ||
135 | /// <param name="rotation"></param> | ||
136 | public void UpdatePrimPosition(User_Agent_info User,LLVector3 position,uint LocalID,bool setRotation, LLQuaternion rotation) | ||
117 | { | 137 | { |
118 | prim_info pri=null; | 138 | PrimInfo pri=null; |
119 | foreach (KeyValuePair<libsecondlife.LLUUID,prim_info> kp in this.Prim_list) | 139 | foreach (KeyValuePair<libsecondlife.LLUUID,PrimInfo> kp in this.PrimList) |
120 | { | 140 | { |
121 | if(kp.Value.local_ID==l_id) | 141 | if(kp.Value.LocalID==LocalID) |
122 | { | 142 | { |
123 | pri=kp.Value; | 143 | pri=kp.Value; |
124 | } | 144 | } |
@@ -127,18 +147,37 @@ namespace Second_server | |||
127 | { | 147 | { |
128 | return; | 148 | return; |
129 | } | 149 | } |
130 | uint ID=pri.local_ID; | 150 | uint ID=pri.LocalID; |
151 | libsecondlife.LLVector3 pos2=new LLVector3(position.X,position.Y,position.Z); | ||
152 | libsecondlife.LLQuaternion rotation2; | ||
153 | if(!setRotation) | ||
154 | { | ||
155 | pri.Position=pos2; | ||
156 | rotation2=new LLQuaternion(pri.Rotation.X,pri.Rotation.Y,pri.Rotation.Z,pri.Rotation.W); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | rotation2=new LLQuaternion(rotation.X,rotation.Y,rotation.Z,rotation.W); | ||
161 | |||
162 | pos2=pri.Position; | ||
163 | pri.Rotation=rotation; | ||
164 | } | ||
165 | rotation2.W+=1; | ||
166 | rotation2.X+=1; | ||
167 | rotation2.Y+=1; | ||
168 | rotation2.Z+=1; | ||
169 | |||
131 | byte[] bytes=new byte[60]; | 170 | byte[] bytes=new byte[60]; |
132 | 171 | ||
133 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); | 172 | ImprovedTerseObjectUpdatePacket im=new ImprovedTerseObjectUpdatePacket(); |
134 | im.RegionData.RegionHandle=1096213093147648; | 173 | im.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
135 | im.RegionData.TimeDilation=64096; | 174 | im.RegionData.TimeDilation=64096; |
136 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 175 | im.ObjectData=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
137 | int i=0; | 176 | int i=0; |
138 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | 177 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat=new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); |
139 | im.ObjectData[0]=dat; | 178 | im.ObjectData[0]=dat; |
140 | dat.TextureEntry=object_template.TextureEntry; | 179 | dat.TextureEntry=PrimTemplate.TextureEntry; |
141 | libsecondlife.LLVector3 pos2=new LLVector3(x,y,z); | 180 | //System.Console.WriteLine("new position is :"+position); |
142 | 181 | ||
143 | bytes[i++] = (byte)(ID % 256); | 182 | bytes[i++] = (byte)(ID % 256); |
144 | bytes[i++] = (byte)((ID >> 8) % 256); | 183 | bytes[i++] = (byte)((ID >> 8) % 256); |
@@ -151,7 +190,7 @@ namespace Second_server | |||
151 | // bytes[i++]=128; | 190 | // bytes[i++]=128; |
152 | // bytes[i++]=63; | 191 | // bytes[i++]=63; |
153 | byte[] pb=pos2.GetBytes(); | 192 | byte[] pb=pos2.GetBytes(); |
154 | pri.pos=pos2; | 193 | pri.Position=pos2; |
155 | Array.Copy(pb,0,bytes,i,pb.Length); | 194 | Array.Copy(pb,0,bytes,i,pb.Length); |
156 | i+=12; | 195 | i+=12; |
157 | ushort ac=32767; | 196 | ushort ac=32767; |
@@ -172,7 +211,27 @@ namespace Second_server | |||
172 | bytes[i++] = (byte)(ac % 256); | 211 | bytes[i++] = (byte)(ac % 256); |
173 | bytes[i++] = (byte)((ac >> 8) % 256); | 212 | bytes[i++] = (byte)((ac >> 8) % 256); |
174 | 213 | ||
214 | //if(setRotation) | ||
215 | //{ | ||
216 | |||
217 | ushort rw, rx,ry,rz; | ||
218 | rw=(ushort)(32768*rotation2.W); | ||
219 | rx=(ushort)(32768*rotation2.X); | ||
220 | ry=(ushort)(32768*rotation2.Y); | ||
221 | rz=(ushort)(32768*rotation2.Z); | ||
222 | |||
175 | //rot | 223 | //rot |
224 | bytes[i++] = (byte)(rx % 256); | ||
225 | bytes[i++] = (byte)((rx >> 8) % 256); | ||
226 | bytes[i++] = (byte)(ry % 256); | ||
227 | bytes[i++] = (byte)((ry >> 8) % 256); | ||
228 | bytes[i++] = (byte)(rz % 256); | ||
229 | bytes[i++] = (byte)((rz >> 8) % 256); | ||
230 | bytes[i++] = (byte)(rw % 256); | ||
231 | bytes[i++] = (byte)((rw >> 8) % 256); | ||
232 | //} | ||
233 | /*else | ||
234 | { | ||
176 | bytes[i++] = (byte)(ac % 256); | 235 | bytes[i++] = (byte)(ac % 256); |
177 | bytes[i++] = (byte)((ac >> 8) % 256); | 236 | bytes[i++] = (byte)((ac >> 8) % 256); |
178 | bytes[i++] = (byte)(ac % 256); | 237 | bytes[i++] = (byte)(ac % 256); |
@@ -181,7 +240,7 @@ namespace Second_server | |||
181 | bytes[i++] = (byte)((ac >> 8) % 256); | 240 | bytes[i++] = (byte)((ac >> 8) % 256); |
182 | bytes[i++] = (byte)(ac % 256); | 241 | bytes[i++] = (byte)(ac % 256); |
183 | bytes[i++] = (byte)((ac >> 8) % 256); | 242 | bytes[i++] = (byte)((ac >> 8) % 256); |
184 | 243 | }*/ | |
185 | //rotation vel | 244 | //rotation vel |
186 | bytes[i++] = (byte)(ac % 256); | 245 | bytes[i++] = (byte)(ac % 256); |
187 | bytes[i++] = (byte)((ac >> 8) % 256); | 246 | bytes[i++] = (byte)((ac >> 8) % 256); |
@@ -193,23 +252,32 @@ namespace Second_server | |||
193 | dat.Data=bytes; | 252 | dat.Data=bytes; |
194 | //server.SendPacket(im,true,user); | 253 | //server.SendPacket(im,true,user); |
195 | //should send to all users. | 254 | //should send to all users. |
196 | foreach (KeyValuePair<libsecondlife.LLUUID,Avatar_data> kp in agent_man.Agent_list) | 255 | foreach (KeyValuePair<libsecondlife.LLUUID,AvatarData> kp in Agent_Manager.AgentList) |
197 | { | 256 | { |
198 | if(kp.Value.Net_info.AgentID!=user.AgentID) | 257 | if(kp.Value.NetInfo.AgentID!=User.AgentID) |
199 | { | 258 | { |
200 | server.SendPacket(im,true,kp.Value.Net_info); | 259 | server.SendPacket(im,true,kp.Value.NetInfo); |
201 | } | 260 | } |
202 | } | 261 | } |
203 | } | 262 | } |
204 | public void send_existing_prims(User_Agent_info user) | 263 | |
264 | /// <summary> | ||
265 | /// | ||
266 | /// </summary> | ||
267 | /// <param name="user"></param> | ||
268 | public void SendExistingPrims(User_Agent_info user) | ||
205 | { | 269 | { |
206 | //send data for already created prims to a new joining user | 270 | //send data for already created prims to a new joining user |
207 | } | 271 | } |
208 | //************************************************************** | 272 | |
209 | public void setuptemplates(string name) | 273 | /// <summary> |
274 | /// | ||
275 | /// </summary> | ||
276 | /// <param name="name"></param> | ||
277 | public void SetupTemplates(string name) | ||
210 | { | 278 | { |
211 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 279 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
212 | objupdate.RegionData.RegionHandle=1096213093147648; | 280 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
213 | objupdate.RegionData.TimeDilation=64096; | 281 | objupdate.RegionData.TimeDilation=64096; |
214 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; | 282 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1]; |
215 | 283 | ||
@@ -224,7 +292,7 @@ namespace Second_server | |||
224 | 292 | ||
225 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); | 293 | libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1,ref i); |
226 | objupdate.ObjectData[0]=objdata; | 294 | objupdate.ObjectData[0]=objdata; |
227 | this.object_template=objdata; | 295 | this.PrimTemplate=objdata; |
228 | objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256; | 296 | objdata.UpdateFlags=objdata.UpdateFlags+12-16+32+256; |
229 | objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000"); | 297 | objdata.OwnerID=new LLUUID("00000000-0000-0000-0000-000000000000"); |
230 | //test adding a new texture to object , to test image downloading | 298 | //test adding a new texture to object , to test image downloading |
@@ -235,8 +303,13 @@ namespace Second_server | |||
235 | 303 | ||
236 | objdata.TextureEntry=ntex.ToBytes(); | 304 | objdata.TextureEntry=ntex.ToBytes(); |
237 | } | 305 | } |
238 | //******************************************************************** | 306 | |
239 | public void Read_Prim_database(string name,User_Agent_info user) | 307 | /// <summary> |
308 | /// | ||
309 | /// </summary> | ||
310 | /// <param name="name"></param> | ||
311 | /// <param name="user"></param> | ||
312 | public void ReadPrimDatabase(string name,User_Agent_info user) | ||
240 | { | 313 | { |
241 | StreamReader SR; | 314 | StreamReader SR; |
242 | string line; | 315 | string line; |
@@ -253,7 +326,7 @@ namespace Second_server | |||
253 | int num=Convert.ToInt32(comp[2]); | 326 | int num=Convert.ToInt32(comp[2]); |
254 | int start=Convert.ToInt32(comp[1]); | 327 | int start=Convert.ToInt32(comp[1]); |
255 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); | 328 | ObjectUpdatePacket objupdate=new ObjectUpdatePacket(); |
256 | objupdate.RegionData.RegionHandle=1096213093147648; | 329 | objupdate.RegionData.RegionHandle=Globals.Instance.RegionHandle; |
257 | objupdate.RegionData.TimeDilation=64096; | 330 | objupdate.RegionData.TimeDilation=64096; |
258 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; | 331 | objupdate.ObjectData=new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[num]; |
259 | 332 | ||
@@ -285,24 +358,44 @@ namespace Second_server | |||
285 | } | 358 | } |
286 | } | 359 | } |
287 | 360 | ||
288 | public class prim_info | 361 | public class PrimInfo |
289 | { | 362 | { |
290 | public LLVector3 pos; | 363 | public LLVector3 Position; |
291 | public LLVector3 vel; | 364 | public LLVector3 Velocity; |
292 | public uint local_ID; | 365 | public LLQuaternion Rotation=LLQuaternion.Identity; |
293 | public LLUUID full_ID; | 366 | public uint LocalID; |
294 | public prim_data data; | 367 | public LLUUID FullID; |
368 | public PrimData data; | ||
295 | 369 | ||
296 | public prim_info() | 370 | public PrimInfo() |
297 | { | 371 | { |
298 | pos=new LLVector3(0,0,0); | 372 | Position=new LLVector3(0,0,0); |
299 | vel=new LLVector3(0,0,0); | 373 | Velocity=new LLVector3(0,0,0); |
300 | data=new prim_data(); | 374 | //data=new PrimData(); |
301 | } | 375 | } |
302 | } | 376 | } |
303 | public class prim_data | 377 | public class PrimData |
304 | { | 378 | { |
305 | public prim_data() | 379 | public LLUUID OwnerID; |
380 | public byte PCode; | ||
381 | public byte PathBegin; | ||
382 | public byte PathEnd; | ||
383 | public byte PathScaleX; | ||
384 | public byte PathScaleY; | ||
385 | public byte PathShearX; | ||
386 | public byte PathShearY; | ||
387 | public sbyte PathSkew; | ||
388 | public byte ProfileBegin; | ||
389 | public byte ProfileEnd; | ||
390 | public LLVector3 Scale; | ||
391 | public byte PathCurve; | ||
392 | public byte ProfileCurve; | ||
393 | public uint ParentID=0; | ||
394 | public byte ProfileHollow; | ||
395 | |||
396 | public bool DataBaseStorage=false; | ||
397 | |||
398 | public PrimData() | ||
306 | { | 399 | { |
307 | 400 | ||
308 | } | 401 | } |
diff --git a/Script_manager.cs b/Script_manager.cs index 87f2eca..354247b 100644 --- a/Script_manager.cs +++ b/Script_manager.cs | |||
@@ -33,18 +33,18 @@ using System.Collections; | |||
33 | //using LuaInterface; | 33 | //using LuaInterface; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | 35 | ||
36 | namespace Second_server | 36 | namespace OpenSim |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// Description of Script_manager. | 39 | /// Description of Script_manager. |
40 | /// </summary> | 40 | /// </summary> |
41 | public class Script_manager | 41 | public class ScriptManager |
42 | { | 42 | { |
43 | //public LuaInterface.Lua Lu; | 43 | //public LuaInterface.Lua Lu; |
44 | //private ArrayList scripts; | 44 | //private ArrayList scripts; |
45 | //private prim_info current_prim; | 45 | //private prim_info current_prim; |
46 | 46 | ||
47 | public Script_manager() | 47 | public ScriptManager() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
@@ -54,36 +54,52 @@ namespace Second_server | |||
54 | //register any lua routines , like check finish script one | 54 | //register any lua routines , like check finish script one |
55 | Lu.OpenMathLib(); | 55 | Lu.OpenMathLib(); |
56 | }*/ | 56 | }*/ |
57 | public void script_register( script_object_interface script) | 57 | |
58 | private void RegisterFunctions() | ||
58 | { | 59 | { |
59 | //called by scripts to register themselves | 60 | //lu.RegisterFunction( "RegisterScript",this,this.GetType().GetMethod("ScriptRegister")); |
61 | //lu.RegisterFunction( "MoveObject",this,this.GetType().GetMethod("MoveObject")); | ||
62 | //lu.RegisterFunction( "Say",this,this.GetType().GetMethod("Say")); | ||
63 | |||
60 | } | 64 | } |
61 | 65 | ||
62 | public void Call_tick(prim_info prim) | 66 | public void Call_tick(PrimInfo prim) |
63 | { | 67 | { |
64 | //set current prim and then call tick function in linked script | 68 | //set current prim and then call tick function in linked script |
65 | } | 69 | } |
66 | public void Call_click(prim_info prim) | 70 | public void Call_touch(PrimInfo prim) |
67 | { | 71 | { |
68 | //set current prim and then call clicked function in linked script | 72 | //set current prim and then call clicked function in linked script |
69 | 73 | ||
70 | } | 74 | } |
71 | private void Register_functions() | 75 | public void Call_on_rex(PrimInfo prim) |
72 | { | 76 | { |
73 | //lu.RegisterFunction( "register_script",this,this.GetType().GetMethod("script_register")); | 77 | //set current prim and then call clicked function in linked script |
74 | //lu.RegisterFunction( "Move_object",this,this.GetType().GetMethod("Move_object")); | 78 | |
75 | |||
76 | } | 79 | } |
77 | //Lua registered functions | 80 | |
78 | public void Move_object(float x ,float y, float z) | 81 | #region Lua Functions |
82 | |||
83 | public void ScriptRegister( script_object_interface script) | ||
84 | { | ||
85 | //called by scripts to register themselves | ||
86 | } | ||
87 | public void MoveObject(float x ,float y, float z) | ||
79 | { | 88 | { |
80 | 89 | ||
81 | } | 90 | } |
91 | public void Say(string message) | ||
92 | { | ||
93 | |||
94 | } | ||
95 | #endregion | ||
96 | |||
82 | } | 97 | } |
83 | 98 | ||
84 | public interface script_object_interface | 99 | public interface script_object_interface |
85 | { | 100 | { |
86 | void Frame_tick(); | 101 | void frame_tick(); |
87 | void clicked(); | 102 | void touch(int num); |
103 | void on_rex(int num); | ||
88 | } | 104 | } |
89 | } | 105 | } |
diff --git a/Second-server.csproj b/Second-server.csproj index 79db97f..bb1c558 100644 --- a/Second-server.csproj +++ b/Second-server.csproj | |||
@@ -1,8 +1,8 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | 1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
2 | <PropertyGroup> | 2 | <PropertyGroup> |
3 | <OutputType>Exe</OutputType> | 3 | <OutputType>Exe</OutputType> |
4 | <RootNamespace>Controller</RootNamespace> | 4 | <RootNamespace>OpenSim</RootNamespace> |
5 | <AssemblyName>Second-server</AssemblyName> | 5 | <AssemblyName>OpenSim</AssemblyName> |
6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | 6 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | 7 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
8 | <ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid> | 8 | <ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid> |
@@ -35,6 +35,10 @@ | |||
35 | <Reference Include="System" /> | 35 | <Reference Include="System" /> |
36 | <Reference Include="System.Data" /> | 36 | <Reference Include="System.Data" /> |
37 | <Reference Include="System.Xml" /> | 37 | <Reference Include="System.Xml" /> |
38 | <Reference Include="libsecondlife"> | ||
39 | <HintPath>bin\Release\libsecondlife.dll</HintPath> | ||
40 | <SpecificVersion>False</SpecificVersion> | ||
41 | </Reference> | ||
38 | </ItemGroup> | 42 | </ItemGroup> |
39 | <ItemGroup> | 43 | <ItemGroup> |
40 | <Compile Include="AssemblyInfo.cs" /> | 44 | <Compile Include="AssemblyInfo.cs" /> |
@@ -47,12 +51,9 @@ | |||
47 | <Compile Include="Asset_manager.cs" /> | 51 | <Compile Include="Asset_manager.cs" /> |
48 | <Compile Include="Script_manager.cs" /> | 52 | <Compile Include="Script_manager.cs" /> |
49 | <Compile Include="Server.cs" /> | 53 | <Compile Include="Server.cs" /> |
50 | </ItemGroup> | 54 | <Compile Include="StorageManager.cs" /> |
51 | <ItemGroup> | 55 | <Compile Include="GridManager.cs" /> |
52 | <ProjectReference Include="..\..\libsecondlife\libsecondlife-cs\libsecondlife.csproj"> | 56 | <Compile Include="Globals.cs" /> |
53 | <Project>{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}</Project> | ||
54 | <Name>libsecondlife</Name> | ||
55 | </ProjectReference> | ||
56 | </ItemGroup> | 57 | </ItemGroup> |
57 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> | 58 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
58 | </Project> \ No newline at end of file | 59 | </Project> \ No newline at end of file |
diff --git a/Second-server.sln b/Second-server.sln index 9cdd672..2575f51 100644 --- a/Second-server.sln +++ b/Second-server.sln | |||
@@ -1,6 +1,6 @@ | |||
1 |  | 1 |  |
2 | Microsoft Visual Studio Solution File, Format Version 9.00 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 |
3 | # Visual Studio 2005 | 3 | # SharpDevelop 2.1.0.2017 |
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" | 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}" |
5 | EndProject | 5 | EndProject |
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife", "..\..\libsecondlife\libsecondlife-cs\libsecondlife.csproj", "{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}" | 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife", "..\..\libsecondlife\libsecondlife-cs\libsecondlife.csproj", "{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}" |
@@ -27,6 +27,8 @@ Global | |||
27 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | 27 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 |
28 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU | 28 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU |
29 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU | 29 | {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU |
30 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1 | ||
31 | {132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1 | ||
30 | EndGlobalSection | 32 | EndGlobalSection |
31 | GlobalSection(SolutionProperties) = preSolution | 33 | GlobalSection(SolutionProperties) = preSolution |
32 | HideSolutionNode = FALSE | 34 | HideSolutionNode = FALSE |
@@ -37,16 +37,17 @@ using System.Timers; | |||
37 | 37 | ||
38 | //really hacked , messy code | 38 | //really hacked , messy code |
39 | 39 | ||
40 | namespace Second_server | 40 | namespace OpenSim |
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Description of Server. | 43 | /// Description of Server. |
44 | /// </summary> | 44 | /// </summary> |
45 | public interface Server_callback | 45 | public interface ServerCallback |
46 | { | 46 | { |
47 | void main_callback(Packet pack, User_Agent_info User_info); | 47 | //should replace with delegates |
48 | void new_user(User_Agent_info User_info); | 48 | void MainCallback(Packet pack, User_Agent_info User_info); |
49 | void error(string text); | 49 | void NewUserCallback(User_Agent_info User_info); |
50 | void ErrorCallback(string text); | ||
50 | } | 51 | } |
51 | public class Server | 52 | public class Server |
52 | { | 53 | { |
@@ -91,7 +92,7 @@ namespace Second_server | |||
91 | get { return connected; } | 92 | get { return connected; } |
92 | } | 93 | } |
93 | 94 | ||
94 | private Server_callback callback_object; | 95 | private ServerCallback CallbackObject; |
95 | //private NetworkManager Network; | 96 | //private NetworkManager Network; |
96 | // private Dictionary<PacketType, List<NetworkManager.PacketCallback>> Callbacks; | 97 | // private Dictionary<PacketType, List<NetworkManager.PacketCallback>> Callbacks; |
97 | private uint Sequence = 0; | 98 | private uint Sequence = 0; |
@@ -125,10 +126,10 @@ namespace Second_server | |||
125 | /// <param name="circuit"></param> | 126 | /// <param name="circuit"></param> |
126 | /// <param name="ip"></param> | 127 | /// <param name="ip"></param> |
127 | /// <param name="port"></param> | 128 | /// <param name="port"></param> |
128 | public Server(Server_callback s_callback) | 129 | public Server(ServerCallback s_callback) |
129 | { | 130 | { |
130 | 131 | ||
131 | this.callback_object=s_callback; | 132 | this.CallbackObject=s_callback; |
132 | // Client = client; | 133 | // Client = client; |
133 | // Network = client.Network; | 134 | // Network = client.Network; |
134 | // Callbacks = callbacks; | 135 | // Callbacks = callbacks; |
@@ -148,7 +149,7 @@ namespace Second_server | |||
148 | // Create an endpoint that we will be communicating with (need it in two | 149 | // Create an endpoint that we will be communicating with (need it in two |
149 | // types due to .NET weirdness) | 150 | // types due to .NET weirdness) |
150 | // ipEndPoint = new IPEndPoint(ip, port); | 151 | // ipEndPoint = new IPEndPoint(ip, port); |
151 | ipEndPoint = new IPEndPoint(IPAddress.Any, 1000); | 152 | ipEndPoint = new IPEndPoint(IPAddress.Any, Globals.Instance.IpPort); |
152 | 153 | ||
153 | 154 | ||
154 | endPoint = (EndPoint)ipEndPoint; | 155 | endPoint = (EndPoint)ipEndPoint; |
@@ -486,7 +487,7 @@ namespace Second_server | |||
486 | new_user.endpoint=epSender; | 487 | new_user.endpoint=epSender; |
487 | new_user.Inbox = new Queue<uint>(Settings.INBOX_SIZE); | 488 | new_user.Inbox = new Queue<uint>(Settings.INBOX_SIZE); |
488 | 489 | ||
489 | this.callback_object.new_user(new_user); | 490 | this.CallbackObject.NewUserCallback(new_user); |
490 | this.User_agents.Add(new_user); | 491 | this.User_agents.Add(new_user); |
491 | 492 | ||
492 | } | 493 | } |
@@ -526,14 +527,14 @@ namespace Second_server | |||
526 | { | 527 | { |
527 | 528 | ||
528 | //error finding agent | 529 | //error finding agent |
529 | this.callback_object.error("no user found"); | 530 | this.CallbackObject.ErrorCallback("no user found"); |
530 | return; | 531 | return; |
531 | } | 532 | } |
532 | 533 | ||
533 | // Fail-safe check | 534 | // Fail-safe check |
534 | if (packet == null) | 535 | if (packet == null) |
535 | { | 536 | { |
536 | this.callback_object.error("couldn't build packet"); | 537 | this.CallbackObject.ErrorCallback("couldn't build packet"); |
537 | // Client.Log("Couldn't build a message from the incoming data", Helpers.LogLevel.Warning); | 538 | // Client.Log("Couldn't build a message from the incoming data", Helpers.LogLevel.Warning); |
538 | return; | 539 | return; |
539 | } | 540 | } |
@@ -615,7 +616,7 @@ namespace Second_server | |||
615 | } | 616 | } |
616 | 617 | ||
617 | // this.callback_object.error("calling callback"); | 618 | // this.callback_object.error("calling callback"); |
618 | this.callback_object.main_callback(packet,User_info); | 619 | this.CallbackObject.MainCallback(packet,User_info); |
619 | // this.callback_object.error("finished"); | 620 | // this.callback_object.error("finished"); |
620 | // Fire the registered packet events | 621 | // Fire the registered packet events |
621 | #region FireCallbacks | 622 | #region FireCallbacks |
diff --git a/Texture_manager.cs b/Texture_manager.cs index 1321358..0d88041 100644 --- a/Texture_manager.cs +++ b/Texture_manager.cs | |||
@@ -36,26 +36,26 @@ using libsecondlife.AssetSystem; | |||
36 | using System.IO; | 36 | using System.IO; |
37 | 37 | ||
38 | 38 | ||
39 | namespace Second_server | 39 | namespace OpenSim |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Description of Texture_manager. | 42 | /// Description of Texture_manager. |
43 | /// </summary> | 43 | /// </summary> |
44 | public class Texture_manager | 44 | public class TextureManager |
45 | { | 45 | { |
46 | public Dictionary<libsecondlife.LLUUID,Texture_image> textures; | 46 | public Dictionary<libsecondlife.LLUUID,TextureImage> textures; |
47 | public ArrayList requests=new ArrayList(); //should change to a generic | 47 | public ArrayList requests=new ArrayList(); //should change to a generic |
48 | public ArrayList uploads=new ArrayList(); | 48 | public ArrayList uploads=new ArrayList(); |
49 | private Server server; | 49 | private Server server; |
50 | 50 | ||
51 | public Texture_manager(Server serve) | 51 | public TextureManager(Server serve) |
52 | { | 52 | { |
53 | server=serve; | 53 | server=serve; |
54 | textures=new Dictionary<libsecondlife.LLUUID,Texture_image> (); | 54 | textures=new Dictionary<libsecondlife.LLUUID,TextureImage> (); |
55 | this.initialise(); | 55 | this.initialise(); |
56 | } | 56 | } |
57 | 57 | ||
58 | public void add_request(User_Agent_info user, LLUUID image_id) | 58 | public void AddRequest(User_Agent_info user, LLUUID image_id) |
59 | { | 59 | { |
60 | 60 | ||
61 | if(!this.textures.ContainsKey(image_id)) | 61 | if(!this.textures.ContainsKey(image_id)) |
@@ -66,10 +66,10 @@ namespace Second_server | |||
66 | server.SendPacket(im_not,true,user); | 66 | server.SendPacket(im_not,true,user); |
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | Texture_image imag=this.textures[image_id]; | 69 | TextureImage imag=this.textures[image_id]; |
70 | Texture_request req=new Texture_request(); | 70 | TextureRequest req=new TextureRequest(); |
71 | req.req_user=user; | 71 | req.RequestUser=user; |
72 | req.req_image=image_id; | 72 | req.RequestImage=image_id; |
73 | req.image_info=imag; | 73 | req.image_info=imag; |
74 | 74 | ||
75 | if(imag.data.LongLength>1000) //should be bigger or smaller? | 75 | if(imag.data.LongLength>1000) //should be bigger or smaller? |
@@ -87,11 +87,11 @@ namespace Second_server | |||
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | public void add_texture(LLUUID image_id, string name, byte[] data) | 90 | public void AddTexture(LLUUID image_id, string name, byte[] data) |
91 | { | 91 | { |
92 | 92 | ||
93 | } | 93 | } |
94 | public void Do_work(ulong time) | 94 | public void DoWork(ulong time) |
95 | { | 95 | { |
96 | if(this.requests.Count==0) | 96 | if(this.requests.Count==0) |
97 | { | 97 | { |
@@ -109,10 +109,10 @@ namespace Second_server | |||
109 | { | 109 | { |
110 | num=5; | 110 | num=5; |
111 | } | 111 | } |
112 | Texture_request req; | 112 | TextureRequest req; |
113 | for(int i=0; i<num; i++) | 113 | for(int i=0; i<num; i++) |
114 | { | 114 | { |
115 | req=(Texture_request)this.requests[i]; | 115 | req=(TextureRequest)this.requests[i]; |
116 | 116 | ||
117 | if(req.packet_counter==0) | 117 | if(req.packet_counter==0) |
118 | { | 118 | { |
@@ -126,9 +126,10 @@ namespace Second_server | |||
126 | im.ImageID.Size=(uint)req.image_info.data.Length; | 126 | im.ImageID.Size=(uint)req.image_info.data.Length; |
127 | im.ImageData.Data=req.image_info.data; | 127 | im.ImageData.Data=req.image_info.data; |
128 | im.ImageID.Codec=2; | 128 | im.ImageID.Codec=2; |
129 | server.SendPacket(im,true,req.req_user); | 129 | server.SendPacket(im,true,req.RequestUser); |
130 | req.packet_counter++; | 130 | req.packet_counter++; |
131 | req.image_info.last_used=time; | 131 | req.image_info.last_used=time; |
132 | System.Console.WriteLine("sent texture: "+req.image_info.Full_ID); | ||
132 | } | 133 | } |
133 | else | 134 | else |
134 | { | 135 | { |
@@ -145,7 +146,7 @@ namespace Second_server | |||
145 | //remove requests that have been completed | 146 | //remove requests that have been completed |
146 | for(int i=0; i<num; i++) | 147 | for(int i=0; i<num; i++) |
147 | { | 148 | { |
148 | req=(Texture_request)this.requests[i]; | 149 | req=(TextureRequest)this.requests[i]; |
149 | if(req.packet_counter==req.num_packets) | 150 | if(req.packet_counter==req.num_packets) |
150 | { | 151 | { |
151 | this.requests.Remove(req); | 152 | this.requests.Remove(req); |
@@ -153,7 +154,7 @@ namespace Second_server | |||
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
156 | public void recieve_texture(Packet pack) | 157 | public void RecieveTexture(Packet pack) |
157 | { | 158 | { |
158 | 159 | ||
159 | } | 160 | } |
@@ -161,15 +162,31 @@ namespace Second_server | |||
161 | private void initialise() | 162 | private void initialise() |
162 | { | 163 | { |
163 | //for now read in our test image | 164 | //for now read in our test image |
164 | Texture_image im=new Texture_image(); | 165 | TextureImage im=new TextureImage(); |
165 | im.filename="testpic2.jp2"; | 166 | im.filename="testpic2.jp2"; |
166 | im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); | 167 | im.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); |
167 | this.load_image(im); | 168 | this.LoadImage(im); |
168 | this.textures.Add(im.Full_ID,im); | 169 | this.textures.Add(im.Full_ID,im); |
170 | |||
171 | im=new TextureImage(); | ||
172 | im.filename="map_base.jp2"; | ||
173 | im.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006"); | ||
174 | this.LoadImage(im); | ||
175 | this.textures.Add(im.Full_ID,im); | ||
176 | |||
177 | im=new TextureImage(); | ||
178 | im.filename="map1.jp2"; | ||
179 | im.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008"); | ||
180 | this.LoadImage(im); | ||
181 | this.textures.Add(im.Full_ID,im); | ||
182 | |||
169 | } | 183 | } |
170 | private void load_image(Texture_image im) | 184 | private void LoadImage(TextureImage im) |
171 | { | 185 | { |
172 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\"; | 186 | //should request Image from StorageManager |
187 | //but for now read from file | ||
188 | |||
189 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\"; | ||
173 | string filename=data_path+@im.filename; | 190 | string filename=data_path+@im.filename; |
174 | FileInfo fInfo = new FileInfo(filename); | 191 | FileInfo fInfo = new FileInfo(filename); |
175 | 192 | ||
@@ -187,21 +204,21 @@ namespace Second_server | |||
187 | 204 | ||
188 | } | 205 | } |
189 | 206 | ||
190 | public class Texture_request | 207 | public class TextureRequest |
191 | { | 208 | { |
192 | public User_Agent_info req_user; | 209 | public User_Agent_info RequestUser; |
193 | public LLUUID req_image; | 210 | public LLUUID RequestImage; |
194 | public Texture_image image_info; | 211 | public TextureImage image_info; |
195 | public long data_pointer=0; | 212 | public long data_pointer=0; |
196 | public int num_packets=0; | 213 | public int num_packets=0; |
197 | public int packet_counter=0; | 214 | public int packet_counter=0; |
198 | 215 | ||
199 | public Texture_request() | 216 | public TextureRequest() |
200 | { | 217 | { |
201 | 218 | ||
202 | } | 219 | } |
203 | } | 220 | } |
204 | public class Texture_image | 221 | public class TextureImage |
205 | { | 222 | { |
206 | public byte[] data; | 223 | public byte[] data; |
207 | public LLUUID Full_ID; | 224 | public LLUUID Full_ID; |
@@ -211,7 +228,7 @@ namespace Second_server | |||
211 | public ulong last_used; //need to add a tick/time counter and keep record | 228 | public ulong last_used; //need to add a tick/time counter and keep record |
212 | // of how often images are requested to unload unused ones. | 229 | // of how often images are requested to unload unused ones. |
213 | 230 | ||
214 | public Texture_image() | 231 | public TextureImage() |
215 | { | 232 | { |
216 | 233 | ||
217 | } | 234 | } |