diff options
author | Justin Clarke Casey | 2008-09-12 20:12:03 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-09-12 20:12:03 +0000 |
commit | 52a4c4d82f9c5b808e6c61fd51c1c70e42865565 (patch) | |
tree | f63a4ea443597b2d79ad6c2b7acff058c4437425 /OpenSim/Framework/Communications/UserManagerBase.cs | |
parent | remove hidden faces inside prim meshes to improve memory use and startup time (diff) | |
download | opensim-SC_OLD-52a4c4d82f9c5b808e6c61fd51c1c70e42865565.zip opensim-SC_OLD-52a4c4d82f9c5b808e6c61fd51c1c70e42865565.tar.gz opensim-SC_OLD-52a4c4d82f9c5b808e6c61fd51c1c70e42865565.tar.bz2 opensim-SC_OLD-52a4c4d82f9c5b808e6c61fd51c1c70e42865565.tar.xz |
* Check in first part of http://opensimulator.org/mantis/view.php?id=2073
* This patch aims to introduce look at direction persistence between logins. It won't be active until the second part of the patch is committed in about two weeks time. At
this point, region servers that haven't upgraded past this revision may run into problems
* This checkin upgrades the user database. As always, we recommend you have backups in case something goes wrong.
* Many thanks to tyre for this patch.
Diffstat (limited to 'OpenSim/Framework/Communications/UserManagerBase.cs')
-rw-r--r-- | OpenSim/Framework/Communications/UserManagerBase.cs | 196 |
1 files changed, 96 insertions, 100 deletions
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index b6564bf..75c4dc1 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs | |||
@@ -388,84 +388,115 @@ namespace OpenSim.Framework.Communications | |||
388 | // Profile UUID | 388 | // Profile UUID |
389 | agent.ProfileID = profile.ID; | 389 | agent.ProfileID = profile.ID; |
390 | 390 | ||
391 | // Current position (from Home) | 391 | // Current location/position/alignment |
392 | agent.Handle = profile.HomeRegion; | 392 | if (profile.CurrentAgent != null) |
393 | agent.Position = profile.HomeLocation; | ||
394 | |||
395 | // If user specified additional start, use that | ||
396 | if (requestData.ContainsKey("start")) | ||
397 | { | 393 | { |
398 | string startLoc = ((string)requestData["start"]).Trim(); | 394 | agent.Region = profile.CurrentAgent.Region; |
399 | if (("last" == startLoc) && (profile.CurrentAgent != null)) | 395 | agent.Handle = profile.CurrentAgent.Handle; |
400 | { | 396 | agent.Position = profile.CurrentAgent.Position; |
401 | if ((profile.CurrentAgent.Position.X > 0) | 397 | agent.LookAt = profile.CurrentAgent.LookAt; |
402 | && (profile.CurrentAgent.Position.Y > 0) | 398 | } |
403 | && (profile.CurrentAgent.Position.Z > 0) | 399 | else |
404 | ) | 400 | { |
405 | { | 401 | agent.Region = profile.HomeRegionID; |
406 | // TODO: Right now, currentRegion has not been used in GridServer for requesting region. | 402 | agent.Handle = profile.HomeRegion; |
407 | // TODO: It is only using currentHandle. | 403 | agent.Position = profile.HomeLocation; |
408 | agent.Region = profile.CurrentAgent.Region; | 404 | agent.LookAt = profile.HomeLookAt; |
409 | agent.Handle = profile.CurrentAgent.Handle; | ||
410 | agent.Position = profile.CurrentAgent.Position; | ||
411 | } | ||
412 | } | ||
413 | |||
414 | // if (!(startLoc == "last" || startLoc == "home")) | ||
415 | // { | ||
416 | // // Format: uri:Ahern&162&213&34 | ||
417 | // try | ||
418 | // { | ||
419 | // string[] parts = startLoc.Remove(0, 4).Split('&'); | ||
420 | // //string region = parts[0]; | ||
421 | // | ||
422 | // //////////////////////////////////////////////////// | ||
423 | // //SimProfile SimInfo = new SimProfile(); | ||
424 | // //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey); | ||
425 | // } | ||
426 | // catch (Exception) | ||
427 | // { | ||
428 | // } | ||
429 | // } | ||
430 | } | 405 | } |
431 | 406 | ||
432 | // What time did the user login? | 407 | // What time did the user login? |
433 | agent.LoginTime = Util.UnixTimeSinceEpoch(); | 408 | agent.LoginTime = Util.UnixTimeSinceEpoch(); |
434 | agent.LogoutTime = 0; | 409 | agent.LogoutTime = 0; |
435 | 410 | ||
436 | // Current location | 411 | profile.CurrentAgent = agent; |
437 | agent.InitialRegion = UUID.Zero; // Fill in later | 412 | } |
438 | agent.Region = UUID.Zero; // Fill in later | 413 | |
414 | public void CreateAgent(UserProfileData profile, LLSD request) | ||
415 | { | ||
416 | UserAgentData agent = new UserAgentData(); | ||
417 | |||
418 | // User connection | ||
419 | agent.AgentOnline = true; | ||
420 | |||
421 | //if (request.Params.Count > 1) | ||
422 | //{ | ||
423 | // IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1]; | ||
424 | // agent.AgentIP = RemoteIPEndPoint.Address.ToString(); | ||
425 | // agent.AgentPort = (uint)RemoteIPEndPoint.Port; | ||
426 | //} | ||
427 | |||
428 | // Generate sessions | ||
429 | RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); | ||
430 | byte[] randDataS = new byte[16]; | ||
431 | byte[] randDataSS = new byte[16]; | ||
432 | rand.GetBytes(randDataS); | ||
433 | rand.GetBytes(randDataSS); | ||
434 | |||
435 | agent.SecureSessionID = new UUID(randDataSS, 0); | ||
436 | agent.SessionID = new UUID(randDataS, 0); | ||
437 | |||
438 | // Profile UUID | ||
439 | agent.ProfileID = profile.ID; | ||
440 | |||
441 | // Current location/position/alignment | ||
442 | if (profile.CurrentAgent != null) | ||
443 | { | ||
444 | agent.Region = profile.CurrentAgent.Region; | ||
445 | agent.Handle = profile.CurrentAgent.Handle; | ||
446 | agent.Position = profile.CurrentAgent.Position; | ||
447 | agent.LookAt = profile.CurrentAgent.LookAt; | ||
448 | } | ||
449 | else | ||
450 | { | ||
451 | agent.Region = profile.HomeRegionID; | ||
452 | agent.Handle = profile.HomeRegion; | ||
453 | agent.Position = profile.HomeLocation; | ||
454 | agent.LookAt = profile.HomeLookAt; | ||
455 | } | ||
456 | |||
457 | // What time did the user login? | ||
458 | agent.LoginTime = Util.UnixTimeSinceEpoch(); | ||
459 | agent.LogoutTime = 0; | ||
439 | 460 | ||
440 | profile.CurrentAgent = agent; | 461 | profile.CurrentAgent = agent; |
441 | } | 462 | } |
442 | 463 | ||
443 | /// <summary> | 464 | /// <summary> |
465 | /// Saves a target agent to the database | ||
466 | /// </summary> | ||
467 | /// <param name="profile">The users profile</param> | ||
468 | /// <returns>Successful?</returns> | ||
469 | public bool CommitAgent(ref UserProfileData profile) | ||
470 | { | ||
471 | // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" | ||
472 | // TODO: what is the logic should be? | ||
473 | bool ret = false; | ||
474 | ret = AddUserAgent(profile.CurrentAgent); | ||
475 | ret = ret & UpdateUserProfile(profile); | ||
476 | return ret; | ||
477 | } | ||
478 | |||
479 | /// <summary> | ||
444 | /// Process a user logoff from OpenSim. | 480 | /// Process a user logoff from OpenSim. |
445 | /// </summary> | 481 | /// </summary> |
446 | /// <param name="userid"></param> | 482 | /// <param name="userid"></param> |
447 | /// <param name="regionid"></param> | 483 | /// <param name="regionid"></param> |
448 | /// <param name="regionhandle"></param> | 484 | /// <param name="regionhandle"></param> |
449 | /// <param name="posx"></param> | 485 | /// <param name="position"></param> |
450 | /// <param name="posy"></param> | 486 | /// <param name="lookat"></param> |
451 | /// <param name="posz"></param> | 487 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) |
452 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
453 | { | 488 | { |
454 | if (StatsManager.UserStats != null) | 489 | if (StatsManager.UserStats != null) |
455 | StatsManager.UserStats.AddLogout(); | 490 | StatsManager.UserStats.AddLogout(); |
456 | 491 | ||
457 | UserProfileData userProfile; | 492 | UserProfileData userProfile = GetUserProfile(userid); |
458 | UserAgentData userAgent; | ||
459 | Vector3 currentPos = new Vector3(posx, posy, posz); | ||
460 | |||
461 | userProfile = GetUserProfile(userid); | ||
462 | 493 | ||
463 | if (userProfile != null) | 494 | if (userProfile != null) |
464 | { | 495 | { |
465 | // This line needs to be in side the above if statement or the UserServer will crash on some logouts. | 496 | // This line needs to be in side the above if statement or the UserServer will crash on some logouts. |
466 | m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); | 497 | m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + position.X + "," + position.Y + "," + position.Z + ")"); |
467 | 498 | ||
468 | userAgent = userProfile.CurrentAgent; | 499 | UserAgentData userAgent = userProfile.CurrentAgent; |
469 | if (userAgent != null) | 500 | if (userAgent != null) |
470 | { | 501 | { |
471 | userAgent.AgentOnline = false; | 502 | userAgent.AgentOnline = false; |
@@ -475,10 +506,11 @@ namespace OpenSim.Framework.Communications | |||
475 | { | 506 | { |
476 | userAgent.Region = regionid; | 507 | userAgent.Region = regionid; |
477 | } | 508 | } |
478 | |||
479 | userAgent.Handle = regionhandle; | 509 | userAgent.Handle = regionhandle; |
480 | userAgent.Position = currentPos; | 510 | userAgent.Position = position; |
481 | userProfile.CurrentAgent = userAgent; | 511 | userAgent.LookAt = lookat; |
512 | //userProfile.CurrentAgent = userAgent; | ||
513 | userProfile.LastLogin = userAgent.LogoutTime; | ||
482 | 514 | ||
483 | CommitAgent(ref userProfile); | 515 | CommitAgent(ref userProfile); |
484 | } | 516 | } |
@@ -494,54 +526,18 @@ namespace OpenSim.Framework.Communications | |||
494 | } | 526 | } |
495 | } | 527 | } |
496 | 528 | ||
497 | public void CreateAgent(UserProfileData profile, LLSD request) | ||
498 | { | ||
499 | UserAgentData agent = new UserAgentData(); | ||
500 | |||
501 | // User connection | ||
502 | agent.AgentOnline = true; | ||
503 | |||
504 | // Generate sessions | ||
505 | RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider(); | ||
506 | byte[] randDataS = new byte[16]; | ||
507 | byte[] randDataSS = new byte[16]; | ||
508 | rand.GetBytes(randDataS); | ||
509 | rand.GetBytes(randDataSS); | ||
510 | |||
511 | agent.SecureSessionID = new UUID(randDataSS, 0); | ||
512 | agent.SessionID = new UUID(randDataS, 0); | ||
513 | |||
514 | // Profile UUID | ||
515 | agent.ProfileID = profile.ID; | ||
516 | |||
517 | // Current position (from Home) | ||
518 | agent.Handle = profile.HomeRegion; | ||
519 | agent.Position = profile.HomeLocation; | ||
520 | |||
521 | // What time did the user login? | ||
522 | agent.LoginTime = Util.UnixTimeSinceEpoch(); | ||
523 | agent.LogoutTime = 0; | ||
524 | |||
525 | // Current location | ||
526 | agent.InitialRegion = UUID.Zero; // Fill in later | ||
527 | agent.Region = UUID.Zero; // Fill in later | ||
528 | |||
529 | profile.CurrentAgent = agent; | ||
530 | } | ||
531 | |||
532 | /// <summary> | 529 | /// <summary> |
533 | /// Saves a target agent to the database | 530 | /// Process a user logoff from OpenSim (deprecated as of 2008-08-27) |
534 | /// </summary> | 531 | /// </summary> |
535 | /// <param name="profile">The users profile</param> | 532 | /// <param name="userid"></param> |
536 | /// <returns>Successful?</returns> | 533 | /// <param name="regionid"></param> |
537 | public bool CommitAgent(ref UserProfileData profile) | 534 | /// <param name="regionhandle"></param> |
535 | /// <param name="posx"></param> | ||
536 | /// <param name="posy"></param> | ||
537 | /// <param name="posz"></param> | ||
538 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
538 | { | 539 | { |
539 | // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" | 540 | LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3()); |
540 | // TODO: what is the logic should be? | ||
541 | bool ret = false; | ||
542 | ret = AddUserAgent(profile.CurrentAgent); | ||
543 | ret = ret & UpdateUserProfile(profile); | ||
544 | return ret; | ||
545 | } | 541 | } |
546 | 542 | ||
547 | #endregion | 543 | #endregion |