Database Teleporter BRIGADOON-0009
An Open Simulator Teleporter using a central database.
Loading...
Searching...
No Matches
teleport_heartbeat.osl File Reference

Go to the source code of this file.

Functions

 rdProcessFailureMessage (string FailureMessage)
 Convert error messages into something that is more readable.
integer rdSetAnonType (string ValueObject, integer InfoInteger)
 Set of Reset the Anonymous Flag.
integer rdGetVersionNumber (string VersionString)
 Convert Version String into an Integer.
integer rdSetLocationType (string ValueString, integer LocationInfo)
 Set the teleporter Location Type.
string rdAdjustPosition (string Line)
 rdSaveNewTeleportNotecard (list teleport_list)
 Save the Teleportation Destinations into a Notecard.
 rdSendHeartbeatMessage ()

Variables

string VERSION_STRING = "1.3.0"
float MINIMUM_HEARTBEAT_PERIOD = 0.1
 The fastest allowable heartbeat.
float DEFAULT_LOCATION_OFFSET = 2.0
 The default offset from the landing teleport position when using a display panel;.
string CONFIG_NOTECARD_NAME = "brigadoon_teleporter.config"
string CONFIG_DESTINATIONS_NAME = "teleport_destinations.config"
string COMMENT_PREAMBLE = "//"
integer COMMENT_PREAMBLE_LENGTH = 2
string DATABASE_INTERFACE = "DATABASE_INTERFACE"
string LOCATION_NAME = "LOCATION_NAME"
string LANDING_OFFSET = "LANDING_OFFSET"
 The Configuration File Identifier for the Landing Offset Distance.
string HEARTBEAT_PERIOD = "HEARTBEAT_PERIOD"
 The Configuration File Identifier for the Heartbeat Period.
string FRONT_OFFSET_ANGLE = "FRONT_OFFSET_ANGLE"
 The Configuration File Identifier for the Look At Angle.
string LOCATION_TYPE = "LOCATION_TYPE"
 The Configuration File Identifier for the Location Type.
string GROUP_LOCATION = "GROUP"
 The Configuration File Identifier for all Goup Locations.
string ANONYMOUS_UNIT = "ANONYMOUS"
 The configuration Identifier for Anonymous Operation.
string REGION_LOCATION = "REGION"
 The Configuration File Identifier for the Regional Location.
string WORLD_LOCATION = "WORLD"
 The Configuration File Identifier for the World Location.
string METAVERSE_LOCATION = "METAVERSE"
 The Configuration File Identifier for the Metaverse Location.
integer GROUP_FLAG = 1
 Numeric identifier of a Group Location.
integer REGION_FLAG = 2
integer WORLD_FLAG = 4
integer METAVERSE_FLAG = 8
integer LOCATION_MASK = ~(GROUP_FLAG + REGION_FLAG + WORLD_FLAG + METAVERSE_FLAG)
 A mask to remove locaiton information.
integer ANONYMOUS_FLAG = 16
 This flag designates the teleporter as anonymous.
string LOCALITY_GROUP = "LOCALITY_GROUP"
 Configuration File Identifier for the Regional Location.
float TIMER_OFF = 0.0
float MINIMUM_HEARTBEAT_INTERVAL = 600
float MINIMUM_OFFSET = 0.5
 Minimum allowable offset.
float MAXIMUM_OFFSET = 10.0
 Maximum allowable offset.
string location_world
string location_name
string locality_group = "null"
string location_region
float landing_offset = DEFAULT_LOCATION_OFFSET
 The distance offset between the landing and the Teleporter.
key heartbeat_key
 The Heatbeat HTTP Requrest Key.
list destination_data
 A list of the Teleport Destinations from the COnfiguration File.
float front_offset_angle = 0.0
 The LookAt angle after teleportation.
string database_interface
float heartbeat_period
 Interval in seconds between Heartbeat messages.
list teleport_list
 The list of Teleport Destinations.
integer location_info = 0
 Information on the Teleporter Location.
integer version_number
 Version number as integer.
list destination_preamble

Function Documentation

◆ rdAdjustPosition()

string rdAdjustPosition ( string Line)

Definition at line 469 of file teleport_heartbeat.osl.

470{
471 string world;
472 string region;
473 string output_line;
474 vector landing;
475 vector look_at;
476
477 // Split the Entry into components
478 list components = llParseString2List(Line, ["|"], []);
479
480 string name = components[0];
481 vector init_pos = (vector)components[1];
482 rotation initial_rot = (rotation)components[2];
483 vector offset_info = (vector)components[3];
484 string location_group = components[4];
485 integer address_type = (integer)components[5];
486
487 if (address_type == 2)
488 {
489 region = components[6];
490 world = components[7];
491 }
492 else if (address_type == 1)
493 {
494 region = components[6];
495 world = location_world;
496 }
497 else if (address_type == 0)
498 {
499 region = location_region;
500 world = location_world;
501 }
502 else
503 {
504 llSay(DEBUG_CHANNEL, "Format Error");
505 }
506
507 // Because of the Inherent lilmit of eight(8) elements when parsing a string
508 // three (3) of teh numeric items were condensed into a vector to overcome this
509 // problem.
510 float offset_distance = (float)offset_info.x;
511 float look_angle = (float)offset_info.y;
512 integer location_information = (integer)offset_info.z;
513
514 // Determine the Landing Position by adding offset to the Teleporter's Location
515 // The offset is set negative to move to it "back to the front" of the Teleporter Object
516 landing = init_pos + llRot2Fwd(initial_rot) * -offset_distance;
517
518 vector temp = llRot2Euler(initial_rot * llAxisAngle2Rot(<0,0,1>, look_angle));
519 look_at = <llCos(temp.z), llSin(temp.z), 0.0>;
520
521 // Create the String to be stored in the Teleport Destination Notecard.
522
523 output_line = name + "|" + world + "|" + region + "|";
524 output_line += (string)landing + '|' + (string)look_at + '|';
525 output_line += (string)location_information + '|';
526 output_line += location_group + "\n";
527
528 return output_line;
529}
string location_region
Region holding the Teleporter.
string location_world
The Teleporter Location's World.

References location_region, and location_world.

◆ rdGetVersionNumber()

integer rdGetVersionNumber ( string VersionString)

Convert Version String into an Integer.

Parameters
VersionString to be converted
Returns
Integer value of the Version String

Definition at line 423 of file teleport_heartbeat.osl.

424{
425 integer version;
426
427 list versions = llParseString2List(VersionString, ["."], []);
428 version = (integer)llList2String(versions,2) + ((integer)llList2String(versions,1) * 100) + ((integer)llList2String(versions,0) * 10000);
429
430 return version;
431}

◆ rdProcessFailureMessage()

rdProcessFailureMessage ( string FailureMessage)

Convert error messages into something that is more readable.

Parameters
Theerror message string to be decoded

This routine takes the abbreviated error message and expands this to an error message that should be more readable by a user not familar with how the program operates.

Definition at line 350 of file teleport_heartbeat.osl.

351{
352 string failure_message;
353
354 list status = llParseString2List(FailureMessage, [":"], ["\n"]);
355 string failure_type = llList2String(status, 0);
356
357 // Explain why the Teleporter could not be automatically processed
358 if (failure_type == "BANNED")
359 {
360 failure_message = "Teleporters owned by user " + llList2String(status, 1) + " are not permitted to";
361 failure_message += " add teleporters to the database, update teleporter information or update teleporter destinations.";
362 }
363
364 // Explain that the Updating of the Datasbase using the Heartbeat message has failed.
365 else if (failure_type == "UPDATE")
366 {
367 failure_message = "The updating of the Teleporter's information in the database has unexpectedly failure with the error message: ";
368 failure_message += llList2String(status, 1);
369 }
370
371 // Explain that the Insertion into the Database using the Heartbeat message has failed
372 else if (failure_type == "INSERT")
373 {
374 failure_message = "The insertion of a new teleporter's information into the database has failed unexpectedly with the error message: ";
375 failure_message += llList2String(status, 1);
376 }
377
378 // Explain that the Insertion/update failed because the Teleporter name was already in use and duplicate names are not allowed.
379 else if (failure_type == "NAME_MATCH")
380 {
381 failure_message = "Unable to insert the new teleporter's information into the database because the Teleporter's Name is already in use ";
382 failure_message += "by another teleporter located at " + llList2String(status, 1);
383 }
384
385 // Explain that a failure in extracting the destination list for this Teleporter
386 else if (failure_type == "EXTRACT")
387 {
388 failure_message = "The extraction of the list of teleporter destinations has failed unexpectedly with the error message: ";
389 failure_message += llList2String(status, 1);
390 }
391
392 // Explain that Teleporters from world's outside of this one cannot be added automatically added.
393 else if (failure_type == "INVADER")
394 {
395 failure_message = "Teleports from home world '" + llList2String(status, 1) + "' are not permitted to ";
396 failure_message += " add teleporters to the database, update teleporter information or update teleporter destinations.";
397 }
398
399 // Tell the person what to do if there was an error.
400 failure_message += "\n If you wish to report this as an error please send this message to River Drifter with details of what happened and when.\n";
401 llSay(0, failure_message);
402}

◆ rdSaveNewTeleportNotecard()

rdSaveNewTeleportNotecard ( list teleport_list)

Save the Teleportation Destinations into a Notecard.

Parameters
telport_listList of telportation destinations

This routine will remove the Teleportation Notecard and make a new Notecard.

Definition at line 539 of file teleport_heartbeat.osl.

540{
541 // Add the Preamble Text before the List of Destinations
543
544 // Delete the Existing Teleporter Destination Notecard, if it exists
545 integer count = llGetInventoryNumber(INVENTORY_NOTECARD);
546 integer index = 0;
547 for (; index < count; ++index)
548 {
549 if (llGetInventoryName(INVENTORY_NOTECARD, index) == CONFIG_DESTINATIONS_NAME)
550 {
551 llRemoveInventory(CONFIG_DESTINATIONS_NAME);
552 index = count; // Ext Loop
553 }
554 }
555
556 // Write the Teleport List to a New Notecard
558}
string CONFIG_DESTINATIONS_NAME
The automatically generated list of teleporter destinations.
list teleport_list
The list of Teleport Destinations.
list destination_preamble

References CONFIG_DESTINATIONS_NAME, destination_preamble, and teleport_list.

◆ rdSendHeartbeatMessage()

rdSendHeartbeatMessage ( )

\break Send a heartbeat to the database via the webserver

This message sends a heartbeat command to the program controlling the database. The message contains the following information:

This message serves two purposes. First, it confirms that the teleporter still exists and is operational. Secondly, it confirms, and updates if necessary, the information about the Teleporter.

This information allows the database program to automatically delete destinations where the teleporter and by inference, the regions has disappeared.

Definition at line 573 of file teleport_heartbeat.osl.

574{
575 // Do a cursory Check that the configuration has been set up
576 if ((location_name != "") && (database_interface != ""))
577 {
578 // Reset the Data received for the Database
579 teleport_list = [];
580 integer teleport_list_started = FALSE;
581
582 key teleporter_key = llGetKey();
583 list details = llGetObjectDetails(teleporter_key, [OBJECT_POS, OBJECT_ROT, OBJECT_OWNER, OBJECT_GROUP]);
584
585 string heartbeat_message = database_interface + "?command=heartbeat"
586 + "&name=" + llEscapeURL(location_name)
587 + "&key=" + teleporter_key
588 + "&position=" + osReplaceString(llList2String(details, 0), " ", "", -1, 0)
589 + "&rotation=" + osReplaceString(llList2String(details, 1), " ", "", -1, 0)
590 + "&owner=" + llList2String(details, 2)
591 + "&group=" + llList2String(details, 3)
592 + "&world=" + location_world
593 + "&region=" + llGetRegionName()
594 + "&offset=" + (string)landing_offset
595 + "&offsetangle=" + (string)front_offset_angle
596 + "&locationinfo=" + (string)location_info
597 + "&vernum=" + (string)version_number
598 + "&localitygroup=" + locality_group;
599 heartbeat_key = llHTTPRequest(heartbeat_message, [HTTP_BODY_MAXLENGTH,16384], [""]);
600 }
601 else
602 {
603 llSay(DEBUG_CHANNEL, "Either the location_name or database_interface are undefined! Teleporter " + location_name + " has been disabled");
604 llSetScriptState(llGetScriptName(), FALSE);
605 }
606}
string location_name
The display name of the current location.
string database_interface
The HTTP address for invoking the php script to do the scanning & deleting.
float front_offset_angle
The LookAt angle after teleportation.
float landing_offset
The distance offset between the landing and the Teleporter.
key heartbeat_key
The Heatbeat HTTP Requrest Key.
integer version_number
Version number as integer.
string locality_group
integer location_info
Information on the Teleporter Location.

References database_interface, front_offset_angle, heartbeat_key, landing_offset, locality_group, location_info, location_name, location_world, teleport_list, and version_number.

◆ rdSetAnonType()

integer rdSetAnonType ( string ValueObject,
integer InfoInteger )

Set of Reset the Anonymous Flag.

Definition at line 409 of file teleport_heartbeat.osl.

410{
411 if (llToUpper(ValueObject) == "YES") InfoInteger |= ANONYMOUS_FLAG; else InfoInteger &= ~ANONYMOUS_FLAG;
412
413 return InfoInteger;
414}
integer ANONYMOUS_FLAG
This flag designates the teleporter as anonymous.

References ANONYMOUS_FLAG.

◆ rdSetLocationType()

integer rdSetLocationType ( string ValueString,
integer LocationInfo )

Set the teleporter Location Type.

Parameters
ValueStringThe String holding the Types
LocationInfoCurrent Location Info value
Returns
The Updated LocationInfo

Definition at line 441 of file teleport_heartbeat.osl.

442{
443 integer location_buffer = 0;
444
445 // Cut the Location Types out of the Location Info
446 LocationInfo &= LOCATION_MASK;
447
448 // Break the Value String into Components
449 list type_component = llParseString2List(ValueString, [","], []);
450 integer list_size = llGetListLength(type_component);
451 integer index = 0;
452
453 // Process each LocationType
454 for (; index < list_size; ++index)
455 {
456 string location_type = llStringTrim(llList2String(type_component, index), STRING_TRIM);
457 if (location_type == GROUP_LOCATION) location_buffer += GROUP_FLAG;
458 else if (location_type == REGION_LOCATION) location_buffer += REGION_FLAG;
459 else if (location_type == WORLD_LOCATION) location_buffer += WORLD_FLAG;
460 else if (location_type == METAVERSE_LOCATION) location_buffer += METAVERSE_FLAG;
461 }
462
463 // Put intp the Location Information
464 LocationInfo |= location_buffer;
465
466 return LocationInfo;
467}
integer REGION_FLAG
Number value of REgion Location flag.
integer METAVERSE_FLAG
Number value of Metaverse Location flag.
integer WORLD_FLAG
Number value of World Location flag.
string WORLD_LOCATION
The Configuration File Identifier for the World Location.
string REGION_LOCATION
The Configuration File Identifier for the Regional Location.
string GROUP_LOCATION
The Configuration File Identifier for all Goup Locations.
string METAVERSE_LOCATION
The Configuration File Identifier for the Metaverse Location.
integer GROUP_FLAG
Numeric identifier of a Group Location.
integer LOCATION_MASK
A mask to remove locaiton information.

References GROUP_FLAG, GROUP_LOCATION, LOCATION_MASK, METAVERSE_FLAG, METAVERSE_LOCATION, REGION_FLAG, REGION_LOCATION, WORLD_FLAG, and WORLD_LOCATION.

Variable Documentation

◆ ANONYMOUS_FLAG

integer ANONYMOUS_FLAG = 16

This flag designates the teleporter as anonymous.

An anonymouns teleporter is one that resides in the teleporter database, but is not included in the list of avaialble destinations in any teleporter.

This feature is primarily available to allow an admin to get to any destination, without the admin's location being revealed.

Definition at line 193 of file teleport_heartbeat.osl.

Referenced by rdSetAnonType().

◆ ANONYMOUS_UNIT

string ANONYMOUS_UNIT = "ANONYMOUS"

The configuration Identifier for Anonymous Operation.

Definition at line 122 of file teleport_heartbeat.osl.

◆ COMMENT_PREAMBLE

string COMMENT_PREAMBLE = "//"

Definition at line 64 of file teleport_heartbeat.osl.

◆ COMMENT_PREAMBLE_LENGTH

integer COMMENT_PREAMBLE_LENGTH = 2

Definition at line 71 of file teleport_heartbeat.osl.

◆ CONFIG_DESTINATIONS_NAME

string CONFIG_DESTINATIONS_NAME = "teleport_destinations.config"

Definition at line 56 of file teleport_heartbeat.osl.

◆ CONFIG_NOTECARD_NAME

string CONFIG_NOTECARD_NAME = "brigadoon_teleporter.config"

Definition at line 46 of file teleport_heartbeat.osl.

◆ DATABASE_INTERFACE

string DATABASE_INTERFACE = "DATABASE_INTERFACE"

Definition at line 77 of file teleport_heartbeat.osl.

◆ database_interface

string database_interface

Definition at line 289 of file teleport_heartbeat.osl.

◆ DEFAULT_LOCATION_OFFSET

float DEFAULT_LOCATION_OFFSET = 2.0

The default offset from the landing teleport position when using a display panel;.

This value can be altered in the "teleporter.config" notecard.

NOTE: This value MUST be in the range of 0.5 to 10 metres. If it is outside of this range it will be clamped to the closest valid value.

Definition at line 38 of file teleport_heartbeat.osl.

◆ destination_data

list destination_data

A list of the Teleport Destinations from the COnfiguration File.

Definition at line 274 of file teleport_heartbeat.osl.

◆ destination_preamble

list destination_preamble
Initial value:
= [
"// Filename: teleport_destinations.config",
"// Version: " + VERSION_STRING,
"// Date: " + llGetDate() + " UTC",
"// Author: River Drifter",
"// Email: river-drifter@aussiebroadband.com.au",
"// Licence: Creative Commons Attribution Share Alike 4.0 International or better",
"//",
"// *NOTE*: This file is periodically recreated by the Teleporter Heartbeat script.",
"// All entries place here manually will be lost when the file is recreated. If you",
"// wish do testing with manual entries, disable the heartbeat script for the duration.",
"//=========================================================="
]
string VERSION_STRING
The Current version of the software.

Definition at line 328 of file teleport_heartbeat.osl.

Referenced by rdSaveNewTeleportNotecard().

◆ FRONT_OFFSET_ANGLE

string FRONT_OFFSET_ANGLE = "FRONT_OFFSET_ANGLE"

The Configuration File Identifier for the Look At Angle.

Definition at line 101 of file teleport_heartbeat.osl.

◆ front_offset_angle

float front_offset_angle = 0.0

The LookAt angle after teleportation.

This value defaults to 0 if an angle isn't supplied in the configuration notecard.

Definition at line 283 of file teleport_heartbeat.osl.

Referenced by rdSendHeartbeatMessage().

◆ GROUP_FLAG

integer GROUP_FLAG = 1

Numeric identifier of a Group Location.

Definition at line 155 of file teleport_heartbeat.osl.

Referenced by rdSetLocationType().

◆ GROUP_LOCATION

string GROUP_LOCATION = "GROUP"

The Configuration File Identifier for all Goup Locations.

Show all instantances of a Group location, even it is isn't associated with the Group location identification of this Teleporter.

Definition at line 116 of file teleport_heartbeat.osl.

Referenced by rdSetLocationType().

◆ heartbeat_key

key heartbeat_key

The Heatbeat HTTP Requrest Key.

Definition at line 268 of file teleport_heartbeat.osl.

Referenced by rdSendHeartbeatMessage().

◆ HEARTBEAT_PERIOD

string HEARTBEAT_PERIOD = "HEARTBEAT_PERIOD"

The Configuration File Identifier for the Heartbeat Period.

Definition at line 95 of file teleport_heartbeat.osl.

◆ heartbeat_period

float heartbeat_period

Interval in seconds between Heartbeat messages.

Definition at line 296 of file teleport_heartbeat.osl.

◆ LANDING_OFFSET

string LANDING_OFFSET = "LANDING_OFFSET"

The Configuration File Identifier for the Landing Offset Distance.

Definition at line 89 of file teleport_heartbeat.osl.

◆ landing_offset

float landing_offset = DEFAULT_LOCATION_OFFSET

The distance offset between the landing and the Teleporter.

Definition at line 262 of file teleport_heartbeat.osl.

Referenced by rdSendHeartbeatMessage().

◆ LOCALITY_GROUP

string LOCALITY_GROUP = "LOCALITY_GROUP"

Configuration File Identifier for the Regional Location.

Definition at line 199 of file teleport_heartbeat.osl.

◆ locality_group

string locality_group = "null"

Definition at line 249 of file teleport_heartbeat.osl.

Referenced by rdSendHeartbeatMessage().

◆ location_info

integer location_info = 0

Information on the Teleporter Location.

Definition at line 310 of file teleport_heartbeat.osl.

Referenced by rdSendHeartbeatMessage().

◆ LOCATION_MASK

integer LOCATION_MASK = ~(GROUP_FLAG + REGION_FLAG + WORLD_FLAG + METAVERSE_FLAG)

A mask to remove locaiton information.

If the location_info is ANDed with this mask, all of the location types are removed.

Definition at line 181 of file teleport_heartbeat.osl.

Referenced by rdSetLocationType().

◆ LOCATION_NAME

string LOCATION_NAME = "LOCATION_NAME"

Definition at line 83 of file teleport_heartbeat.osl.

◆ location_name

string location_name

Definition at line 247 of file teleport_heartbeat.osl.

◆ location_region

string location_region

Definition at line 256 of file teleport_heartbeat.osl.

◆ LOCATION_TYPE

string LOCATION_TYPE = "LOCATION_TYPE"

The Configuration File Identifier for the Location Type.

Definition at line 107 of file teleport_heartbeat.osl.

◆ location_world

string location_world

Definition at line 238 of file teleport_heartbeat.osl.

◆ MAXIMUM_OFFSET

float MAXIMUM_OFFSET = 10.0

Maximum allowable offset.

Definition at line 225 of file teleport_heartbeat.osl.

◆ METAVERSE_FLAG

integer METAVERSE_FLAG = 8

Definition at line 173 of file teleport_heartbeat.osl.

◆ METAVERSE_LOCATION

string METAVERSE_LOCATION = "METAVERSE"

The Configuration File Identifier for the Metaverse Location.

A Metaverse location is a location that is listed in the deestination list if it is not in the same world as the teleporter.

Definition at line 149 of file teleport_heartbeat.osl.

Referenced by rdSetLocationType().

◆ MINIMUM_HEARTBEAT_INTERVAL

float MINIMUM_HEARTBEAT_INTERVAL = 600

Definition at line 213 of file teleport_heartbeat.osl.

◆ MINIMUM_HEARTBEAT_PERIOD

float MINIMUM_HEARTBEAT_PERIOD = 0.1

The fastest allowable heartbeat.

This is the minimum interval allowed between heartbeats. This is set to prevent the script from flooding the databse webserver with heartbeat messages, in what would essentially be a denial of service attack.

Definition at line 27 of file teleport_heartbeat.osl.

◆ MINIMUM_OFFSET

float MINIMUM_OFFSET = 0.5

Minimum allowable offset.

Definition at line 219 of file teleport_heartbeat.osl.

◆ REGION_FLAG

integer REGION_FLAG = 2

Definition at line 161 of file teleport_heartbeat.osl.

◆ REGION_LOCATION

string REGION_LOCATION = "REGION"

The Configuration File Identifier for the Regional Location.

A region location is a location that is only included in the destination list if it is in the same region as the teleporter.

Definition at line 131 of file teleport_heartbeat.osl.

Referenced by rdSetLocationType().

◆ teleport_list

list teleport_list

The list of Teleport Destinations.

Definition at line 303 of file teleport_heartbeat.osl.

Referenced by rdSaveNewTeleportNotecard(), and rdSendHeartbeatMessage().

◆ TIMER_OFF

float TIMER_OFF = 0.0

Definition at line 205 of file teleport_heartbeat.osl.

◆ version_number

integer version_number

Version number as integer.

This integer takes the version string like "1.2.3" into a single integer. The integer is calculated using:

(1 * 10000) + (2 * 100) + 3 => 10023

Definition at line 321 of file teleport_heartbeat.osl.

Referenced by rdSendHeartbeatMessage().

◆ VERSION_STRING

string VERSION_STRING = "1.3.0"

Definition at line 17 of file teleport_heartbeat.osl.

◆ WORLD_FLAG

integer WORLD_FLAG = 4

Definition at line 167 of file teleport_heartbeat.osl.

◆ WORLD_LOCATION

string WORLD_LOCATION = "WORLD"

The Configuration File Identifier for the World Location.

A world location is a location that is only included if the destination is in the same world as the teleporter.

Definition at line 140 of file teleport_heartbeat.osl.

Referenced by rdSetLocationType().