Deleted old trunk code

adam
gareth 2007-03-07 18:48:38 +00:00
parent 0b6f8a02a7
commit b3844c1f73
49 changed files with 0 additions and 3856 deletions

134
OGS.sql
View File

@ -1,134 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 2.6.3-pl1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Feb 16, 2007 at 09:54 PM
-- Server version: 4.0.23
-- PHP Version: 4.4.0
--
-- Database: `OGS`
--
-- --------------------------------------------------------
--
-- Table structure for table `Grid_settings`
--
DROP TABLE IF EXISTS `Grid_settings`;
CREATE TABLE IF NOT EXISTS `Grid_settings` (
`Setting` text NOT NULL,
`value` text NOT NULL
) TYPE=MyISAM;
--
-- Dumping data for table `Grid_settings`
--
INSERT INTO `Grid_settings` (`Setting`, `value`) VALUES ('highest_LLUUID', '51AEFF430000000000000000000002fd');
-- --------------------------------------------------------
--
-- Table structure for table `foreign_profiles`
--
DROP TABLE IF EXISTS `foreign_profiles`;
CREATE TABLE IF NOT EXISTS `foreign_profiles` (
`userprofile_LLUUID` varchar(32) NOT NULL default '',
`foreigngrid` text NOT NULL,
`profile_firstname` text NOT NULL,
`profile_lastname` text NOT NULL,
`profile_passwdmd5` text NOT NULL,
`homesim_ip` text NOT NULL,
`homesim_port` int(11) NOT NULL default '0',
`homeasset_url` text NOT NULL,
`homeuser_url` text NOT NULL,
`look_at` text NOT NULL,
`region_handle` text NOT NULL,
`position` text NOT NULL,
PRIMARY KEY (`userprofile_LLUUID`)
) TYPE=MyISAM;
--
-- Dumping data for table `foreign_profiles`
--
-- --------------------------------------------------------
--
-- Table structure for table `local_user_profiles`
--
DROP TABLE IF EXISTS `local_user_profiles`;
CREATE TABLE IF NOT EXISTS `local_user_profiles` (
`userprofile_LLUUID` varchar(32) NOT NULL default '',
`profile_firstname` text NOT NULL,
`profile_lastname` text NOT NULL,
`profile_passwdmd5` text NOT NULL,
`homesim_ip` text NOT NULL,
`homesim_port` int(11) NOT NULL default '0',
`homeasset_url` text NOT NULL,
`look_at` text NOT NULL,
`region_handle` text NOT NULL,
`position` text NOT NULL,
PRIMARY KEY (`userprofile_LLUUID`)
) TYPE=MyISAM;
--
-- Dumping data for table `local_user_profiles`
--
INSERT INTO `local_user_profiles` (`userprofile_LLUUID`, `profile_firstname`, `profile_lastname`, `profile_passwdmd5`, `homesim_ip`, `homesim_port`, `homeasset_url`, `look_at`, `region_handle`, `position`) VALUES ('51AEFF43000000000000000000000100', 'Test', 'User', '$1$098f6bcd4621d373cade4e832627b4f6', '127.0.0.1', 1000, 'http://dummyassetserver.net/', 'r-0.57343, r-0.819255,r0', 'r255232,254976', 'r41.6589, r100.8374, r22.5072');
-- --------------------------------------------------------
--
-- Table structure for table `region_profiles`
--
DROP TABLE IF EXISTS `region_profiles`;
CREATE TABLE IF NOT EXISTS `region_profiles` (
`RegionID` varchar(32) NOT NULL default '',
`Name` text NOT NULL,
`GridLocX` bigint(20) NOT NULL default '0',
`GridLocY` bigint(20) NOT NULL default '0',
`region_handle` text NOT NULL,
`ip_addr` text NOT NULL,
`port` text NOT NULL,
PRIMARY KEY (`RegionID`)
) TYPE=MyISAM;
--
-- Dumping data for table `region_profiles`
--
INSERT INTO `region_profiles` (`RegionID`, `Name`, `GridLocX`, `GridLocY`, `region_handle`, `ip_addr`, `port`) VALUES ('51AEFF43000000000000000000000200', 'Test sandbox', 997, 996, 'r255232,254976', '127.0.0.1', '1000');
-- --------------------------------------------------------
--
-- Table structure for table `sessions`
--
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE IF NOT EXISTS `sessions` (
`session_id` varchar(32) NOT NULL default '',
`secure_session_id` text NOT NULL,
`agent_id` text NOT NULL,
`session_start` datetime NOT NULL default '0000-00-00 00:00:00',
`session_end` datetime NOT NULL default '0000-00-00 00:00:00',
`session_active` tinyint(4) NOT NULL default '0',
`current_location` text NOT NULL,
`remote_ip` text NOT NULL,
`circuit_code` int(11) NOT NULL default '0',
PRIMARY KEY (`session_id`)
) TYPE=MyISAM;
--
-- Dumping data for table `sessions`
--
INSERT INTO `sessions` (`session_id`, `secure_session_id`, `agent_id`, `session_start`, `session_end`, `session_active`, `current_location`, `remote_ip`, `circuit_code`) VALUES ('51AEFF430000000000000000000002fc', '51AEFF430000000000000000000002fd', '51AEFF43000000000000000000000100', '2007-02-16 21:13:19', '0000-00-00 00:00:00', 1, 'r255232,254976', '81.174.255.70', 0);

22
README
View File

@ -1,22 +0,0 @@
Some basic instructions on how to use OpenSim/OGS for hackers and geeks
-------------------------------------------------
1.First, either get in touch with a grid owner or install the OGS server components on your own server.
2.Ask the grid owner to send you keys over a secure channel (encrypted email, paper mail, phone, encrypted IM/IRC). If you and the grid owner are not concerned about security (YOU SHOULD BE!!!) then this exchange can be done over any communications channel.
3.Edit src/Config.cs to reflect your changes or if the grid owner has provided you with a template/custom database, drop opensim.yap into bin/
4.If you edited src/Config.cs then run "nant build" at the root directory
5.With mono on Linux/BSD cd into bin/ and run "mono OpenSim.exe", On win32 just run OpenSim.exe
5.Login to the grid with a standard viewer and find your sim (note that at certain times the SVN version does not allow logins)
Some basic instructions on how to use OpenSim/OGS for the laymen
-------------------------------------------------
1.Ensure you either have mono or the .NET framework runtime installed
2.Find a grid owner
3.Ask the grid owner to send you connection instructions
4.Either install the grid owner's opensim.yap by placing it into the same directory as OpenSim.exe or follow their instructions
5.On Linux/BSD, go to a command prompt and type:
cd /path/to/where/you/downloaded/
cd bin/
mono OpenSim.exe
6.Login to the grid in the normal way

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +0,0 @@
#!/bin/sh
# WILL NOT BUILD WITHOUT THIS FILE, VERY IMPORTANT!
kill -9 `/var/run/brain/pituaritygland/melatonin`
/usr/sbin/service norephrine start
rm -rf /brain/receptors/adenosine/*
# Caused a conflict with taste.buds, removed for now
# drink /var/drinks/coffee
# We use this instead, enables implementation of the WINGS (Will Interefere with Need for General Sleep) protocol
drink /var/drinks/redbull

View File

@ -1,9 +0,0 @@
#!/bin/bash
MAJOR=0
MINOR=1
BUILD=`date +%s`
REVISION=`svnversion | sed s/:// | sed s/M//`
REALREVISION=`svnversion`
cat src/VersionInfo.cs.template | sed s/@@VERSION/"$MAJOR.$MINOR, Build $BUILD, Revision $REALREVISION"/g >src/VersionInfo.cs
echo -n $MAJOR.$MINOR.*.$REVISION >VERSION

View File

@ -1,105 +0,0 @@
LLWearable version 22
Female Shape and Outfit 3 Shape
Created by system from avatar's appearance.
permissions 0
{
base_mask 00082000
owner_mask 00082000
group_mask 00082000
everyone_mask 00082000
next_owner_mask 00082000
creator_id 3d924400-038e-6ad9-920b-cfbb9b40585c
owner_id 542ffb8e-8932-49b9-8664-58f53e442797
last_owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c
group_id 00000000-0000-0000-0000-000000000000
}
sale_info 0
{
sale_type not
sale_price 0
}
type 0
parameters 82
1 .21
2 -.5
4 -.11
5 -.1
6 -.3
7 -.4
8 -.5
10 .7
11 .34
12 -.5
13 0
14 .04
15 .58
17 .56
18 -.26
19 -.73
20 -.34
21 -.01
22 1
23 -.5
24 -.63
25 .44
27 .05
33 -.24
34 -.7
35 -.16
36 -.2
37 -.98
38 -.5
80 0
105 .07
155 -.22
157 0
185 -1
193 .86
196 -.74
505 .65
506 .12
507 -1.5
515 0
517 .16
518 .8
629 0
637 0
646 .4
647 1
649 .36
650 .85
652 .49
653 -1
656 0
659 .65
662 .5
663 0
664 0
665 0
675 -.15
676 .26
678 .28
682 .27
683 -.19
684 -.09
685 0
690 .45
692 .4
693 -0
753 -.5
756 -.08
758 .24
759 .6
760 .11
764 -.38
765 -.3
769 .42
773 .51
795 .16
796 .11
799 .36
841 0
842 -.82
879 0
880 0
textures 0

View File

@ -1,52 +0,0 @@
LLWearable version 22
Sexy - Female Skin
permissions 0
{
base_mask 00086000
owner_mask 00086000
group_mask 00000000
everyone_mask 00000000
next_owner_mask 00086000
creator_id 3b659a92-dbf0-4301-8fdc-208d78f00d77
owner_id 3d924400-038e-6ad9-920b-cfbb9b40585c
last_owner_id 101358d5-469d-4b24-9b85-4dc3c05e635d
group_id 00000000-0000-0000-0000-000000000000
}
sale_info 0
{
sale_type not
sale_price 10
}
type 1
parameters 26
108 0
110 0
111 0
116 0
117 1
150 0
162 0
163 0
165 0
700 .01
701 .5
702 .26
703 0
704 0
705 .5
706 .6
707 0
708 0
709 0
710 0
711 .5
712 0
713 .7
714 0
715 0
775 0
textures 3
0 f9261672-5058-9ef8-c0c4-48f43a0b16d4
5 b6ba53be-b5bf-9a1f-2e19-21daf998429c
6 703f6e24-a1fb-1980-acaf-6ab8a99a5bd5

View File

@ -1,16 +0,0 @@
<?
// All the asset server specific stuff lives here
// The asset server's relative URL to the root of the webserver
// If you place this at http://servername/assets then this would be set to /assets/index.php
// wikipedia style URLs need to be implemented - and will be (en.wikipedia.org/wiki/blabla rather than en.wikipedia.org/wiki/index.php?something=bla or en.wikipedia.org/wiki.php/bla)
$asset_home = "/ogs/assetserver/";
// The key we expect from sims
$sim_recvkey = "1234";
// The path where the asset repository is stored, this should be readable by the webserver but NOT in the document root
// The default below is BAD for production use and intended to be simply generic - change it or risk copyright theft
// greater than you could ever imagine, alternatively use .htaccess or other mechanisms.
$asset_repos = "/usr/local/sites/osgrid.org/web/ogs/assetserver/assets";
?>

View File

@ -1,25 +0,0 @@
<?
error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
include("assetserver_config.inc.php");
// Parse out the parameters from the URL
$params = str_replace($asset_home,'', $_SERVER['REQUEST_URI']);
$params = str_replace("index.php/","",$params);
$params = split('/',$params);
// Die if the key doesn't match
if($params[1]!=$sim_recvkey) {
die();
}
// Send requested data
switch($params[0]) {
case 'getasset':
if($params[3]=="data") {
Header("Content-Length: ". (string)filesize($asset_repos . "/" . $params[2] . "/data"));
readfile($asset_repos . "/" . $params[2] . "/data");
}
break;
}
?>

View File

@ -1,9 +0,0 @@
<?
// this file tells all the OGS services where to find the MySQL database
// if multiple OGS services are running on one machine, it is assumed that they all use the same MySQL server/database
$dbhost="YOURSERVERHERE";
$dbuser="opengridservice";
$dbname="OGS";
$dbpasswd="supersecret";
?>

View File

@ -1,7 +0,0 @@
<?
// this file is common across servers and must be kept in sync
$gridserver_url="http://www.garethnelson.com/ogs/gridserver/";
$grid_owner="Gareth Nelson";
?>

View File

@ -1,42 +0,0 @@
<?
// Some generic utilities which may be used by any services
function inc_lluuid($lluuid)
{
$partB = substr($lluuid, 15);
$partB = (float)base_convert($partB,16,10)+1;
$partB = sprintf('%016x', $partB);
$partA = substr($lluuid, 0, 16);
if(substr($lluuid,15,16)=='FFFFFFFFFFFFFFFE') {
$partA = (float)base_convert($partA,16,10)+1;
$partA = sprintf('%016x', $partA);
}
$returnval = sprintf('%s%s',$partA, $partB);
return $returnval;
}
function format_lluuid($uuid)
{
return strtolower(substr($uuid,0,8)."-".substr($uuid,8,4)."-".substr($uuid,12,4)."-".substr($uuid,16,4)."-".substr($uuid,20));
}
function output_xml_block($blockname, $data) {
echo("<$blockname>\n");
foreach($data as $name => $value) {
echo(" <$name>$value</$name>\n");
}
echo("</$blockname>\n");
}
function rand_uuid()
{
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) );
}
?>

View File

@ -1,828 +0,0 @@
<?php
/*
IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002
Version 1.61 - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars)
Site: http://scripts.incutio.com/xmlrpc/
Manual: http://scripts.incutio.com/xmlrpc/manual.php
Made available under the Artistic License: http://www.opensource.org/licenses/artistic-license.php
*/
class IXR_Value {
var $data;
var $type;
function IXR_Value ($data, $type = false) {
$this->data = $data;
if (!$type) {
$type = $this->calculateType();
}
$this->type = $type;
if ($type == 'struct') {
/* Turn all the values in the array in to new IXR_Value objects */
foreach ($this->data as $key => $value) {
$this->data[$key] = new IXR_Value($value);
}
}
if ($type == 'array') {
for ($i = 0, $j = count($this->data); $i < $j; $i++) {
$this->data[$i] = new IXR_Value($this->data[$i]);
}
}
}
function calculateType() {
if ($this->data === true || $this->data === false) {
return 'boolean';
}
if (is_integer($this->data)) {
return 'i4';
}
if (is_double($this->data)) {
return 'double';
}
// Deal with IXR object types base64 and date
if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
return 'date';
}
if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
return 'base64';
}
if (is_object($this->data)) {
return 'object';
}
if (!is_array($this->data)) {
return 'string';
}
/* We have an array - is it an array or a struct ? */
if ($this->isStruct($this->data)) {
return 'struct';
} else {
return 'array';
}
}
function getXml() {
/* Return XML for this value */
switch ($this->type) {
case 'boolean':
return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
break;
case 'i4':
return '<i4>'.$this->data.'</i4>';
break;
case 'double':
return '<double>'.$this->data.'</double>';
break;
case 'string':
return '<string>'.htmlspecialchars($this->data).'</string>';
break;
case 'array':
$return = '<array><data>'."";
foreach ($this->data as $item) {
$return .= ' <value>'.$item->getXml()."</value>";
}
$return .= '</data></array>';
return $return;
break;
case 'struct':
$return = '<struct>'."";
foreach ($this->data as $name => $value) {
$return .= "<member><name>$name</name><value>";
$return .= $value->getXml()."</value></member>";
}
$return .= '</struct>';
return $return;
break;
case 'date':
case 'base64':
return $this->data->getXml();
break;
case 'object':
return $this->data->getXml();
break;
}
return false;
}
function isStruct($array) {
/* Nasty function to check if an array is a struct or not */
$expected = 0;
foreach ($array as $key => $value) {
if ((string)$key != (string)$expected) {
return true;
}
$expected++;
}
return false;
}
}
class IXR_Message {
var $message;
var $messageType; // methodCall / methodResponse / fault
var $faultCode;
var $faultString;
var $methodName;
var $params;
// Current variable stacks
var $_arraystructs = array(); // The stack used to keep track of the current array/struct
var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
var $_currentStructName = array(); // A stack as well
var $_param;
var $_value;
var $_currentTag;
var $_currentTagContents;
// The XML parser
var $_parser;
function IXR_Message ($message) {
$this->message = $message;
}
function parse() {
// first remove the XML declaration
$this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
if (trim($this->message) == '') {
return false;
}
$this->_parser = xml_parser_create();
// Set XML parser to take the case of tags in to account
xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
// Set XML parser callback functions
xml_set_object($this->_parser, $this);
xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
xml_set_character_data_handler($this->_parser, 'cdata');
if (!xml_parse($this->_parser, $this->message)) {
/* die(sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->_parser)),
xml_get_current_line_number($this->_parser))); */
return false;
}
xml_parser_free($this->_parser);
// Grab the error messages, if any
if ($this->messageType == 'fault') {
$this->faultCode = $this->params[0]['faultCode'];
$this->faultString = $this->params[0]['faultString'];
}
return true;
}
function tag_open($parser, $tag, $attr) {
$this->currentTag = $tag;
switch($tag) {
case 'methodCall':
case 'methodResponse':
case 'fault':
$this->messageType = $tag;
break;
/* Deal with stacks of arrays and structs */
case 'data': // data is to all intents and puposes more interesting than array
$this->_arraystructstypes[] = 'array';
$this->_arraystructs[] = array();
break;
case 'struct':
$this->_arraystructstypes[] = 'struct';
$this->_arraystructs[] = array();
break;
}
}
function cdata($parser, $cdata) {
$this->_currentTagContents .= $cdata;
}
function tag_close($parser, $tag) {
$valueFlag = false;
switch($tag) {
case 'int':
case 'i4':
$value = (int)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'double':
$value = (double)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'string':
$value = (string)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'dateTime.iso8601':
$value = new IXR_Date(trim($this->_currentTagContents));
// $value = $iso->getTimestamp();
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'value':
// "If no type is indicated, the type is string."
if (trim($this->_currentTagContents) != '') {
$value = (string)$this->_currentTagContents;
$this->_currentTagContents = '';
$valueFlag = true;
}
break;
case 'boolean':
$value = (boolean)trim($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
case 'base64':
$value = base64_decode($this->_currentTagContents);
$this->_currentTagContents = '';
$valueFlag = true;
break;
/* Deal with stacks of arrays and structs */
case 'data':
case 'struct':
$value = array_pop($this->_arraystructs);
array_pop($this->_arraystructstypes);
$valueFlag = true;
break;
case 'member':
array_pop($this->_currentStructName);
break;
case 'name':
$this->_currentStructName[] = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break;
case 'methodName':
$this->methodName = trim($this->_currentTagContents);
$this->_currentTagContents = '';
break;
}
if ($valueFlag) {
/*
if (!is_array($value) && !is_object($value)) {
$value = trim($value);
}
*/
if (count($this->_arraystructs) > 0) {
// Add value to struct or array
if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
// Add to struct
$this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
} else {
// Add to array
$this->_arraystructs[count($this->_arraystructs)-1][] = $value;
}
} else {
// Just add as a paramater
$this->params[] = $value;
}
}
}
}
class IXR_Server {
var $data;
var $callbacks = array();
var $message;
var $capabilities;
function IXR_Server($callbacks = false, $data = false) {
$this->setCapabilities();
if ($callbacks) {
$this->callbacks = $callbacks;
}
$this->setCallbacks();
$this->serve($data);
}
function serve($data = false) {
if (!$data) {
global $HTTP_RAW_POST_DATA;
if (!$HTTP_RAW_POST_DATA) {
die('XML-RPC server accepts POST requests only.');
}
$data = $HTTP_RAW_POST_DATA;
}
$this->message = new IXR_Message($data);
if (!$this->message->parse()) {
$this->error(-32700, 'parse error. not well formed');
}
if ($this->message->messageType != 'methodCall') {
$this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
}
$result = $this->call($this->message->methodName, $this->message->params);
// Is the result an error?
if (is_a($result, 'IXR_Error')) {
$this->error($result);
}
// Encode the result
$r = new IXR_Value($result);
$resultxml = $r->getXml();
// Create the XML
$xml = <<<EOD
<methodResponse><params><param><value>$resultxml</value></param></params></methodResponse>
EOD;
// Send it
$this->output($xml);
}
function call($methodname, $args) {
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
}
$method = $this->callbacks[$methodname];
// Perform the callback and send the response
if (count($args) == 1) {
// If only one paramater just send that instead of the whole array
$args = $args[0];
}
// Are we dealing with a function or a method?
if (substr($method, 0, 5) == 'this:') {
// It's a class method - check it exists
$method = substr($method, 5);
if (!method_exists($this, $method)) {
return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
}
// Call the method
$result = $this->$method($args);
} else {
// It's a function - does it exist?
if (!function_exists($method)) {
return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
}
// Call the function
$result = $method($args);
}
return $result;
}
function error($error, $message = false) {
// Accepts either an error object or an error code and message
if ($message && !is_object($error)) {
$error = new IXR_Error($error, $message);
}
$this->output($error->getXml());
}
function output($xml) {
$xml = '<?xml version="1.0" encoding="utf-8"?>'."".$xml;
$length = strlen($xml);
header('Connection: close');
header('Content-Length: '.$length);
header('Content-Type: text/xml');
header('Date: '.date('r'));
echo $xml;
exit;
}
function hasMethod($method) {
return in_array($method, array_keys($this->callbacks));
}
function setCapabilities() {
// Initialises capabilities array
$this->capabilities = array(
'xmlrpc' => array(
'specUrl' => 'http://www.xmlrpc.com/spec',
'specVersion' => 1
),
'faults_interop' => array(
'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
'specVersion' => 20010516
),
'system.multicall' => array(
'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
'specVersion' => 1
),
);
}
function getCapabilities($args) {
return $this->capabilities;
}
function setCallbacks() {
$this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
$this->callbacks['system.listMethods'] = 'this:listMethods';
$this->callbacks['system.multicall'] = 'this:multiCall';
}
function listMethods($args) {
// Returns a list of methods - uses array_reverse to ensure user defined
// methods are listed before server defined methods
return array_reverse(array_keys($this->callbacks));
}
function multiCall($methodcalls) {
// See http://www.xmlrpc.com/discuss/msgReader$1208
$return = array();
foreach ($methodcalls as $call) {
$method = $call['methodName'];
$params = $call['params'];
if ($method == 'system.multicall') {
$result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
} else {
$result = $this->call($method, $params);
}
if (is_a($result, 'IXR_Error')) {
$return[] = array(
'faultCode' => $result->code,
'faultString' => $result->message
);
} else {
$return[] = array($result);
}
}
return $return;
}
}
class IXR_Request {
var $method;
var $args;
var $xml;
function IXR_Request($method, $args) {
$this->method = $method;
$this->args = $args;
$this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>
EOD;
foreach ($this->args as $arg) {
$this->xml .= '<param><value>';
$v = new IXR_Value($arg);
$this->xml .= $v->getXml();
$this->xml .= "</value></param>";
}
$this->xml .= '</params></methodCall>';
}
function getLength() {
return strlen($this->xml);
}
function getXml() {
return $this->xml;
}
}
class IXR_Client {
var $server;
var $port;
var $path;
var $useragent;
var $response;
var $message = false;
var $debug = false;
// Storage place for an error message
var $error = false;
function IXR_Client($server, $path = false, $port = 80) {
if (!$path) {
// Assume we have been given a URL instead
$bits = parse_url($server);
$this->server = $bits['host'];
$this->port = isset($bits['port']) ? $bits['port'] : 80;
$this->path = isset($bits['path']) ? $bits['path'] : '/';
// Make absolutely sure we have a path
if (!$this->path) {
$this->path = '/';
}
} else {
$this->server = $server;
$this->path = $path;
$this->port = $port;
}
$this->useragent = 'The Incutio XML-RPC PHP Library';
}
function query() {
$args = func_get_args();
$method = array_shift($args);
$request = new IXR_Request($method, $args);
$length = $request->getLength();
$xml = $request->getXml();
$r = "\r\n";
$request = "POST {$this->path} HTTP/1.0$r";
$request .= "Host: {$this->server}$r";
$request .= "Content-Type: text/xml$r";
$request .= "User-Agent: {$this->useragent}$r";
$request .= "Content-length: {$length}$r$r";
$request .= $xml;
// Now send the request
if ($this->debug) {
echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
}
$fp = @fsockopen($this->server, $this->port);
if (!$fp) {
$this->error = new IXR_Error(-32300, 'transport error - could not open socket');
return false;
}
fputs($fp, $request);
$contents = '';
$gotFirstLine = false;
$gettingHeaders = true;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if (!$gotFirstLine) {
// Check line for '200'
if (strstr($line, '200') === false) {
$this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
return false;
}
$gotFirstLine = true;
}
if (trim($line) == '') {
$gettingHeaders = false;
}
if (!$gettingHeaders) {
$contents .= trim($line)."\n";
}
}
if ($this->debug) {
echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
}
// Now parse what we've got back
$this->message = new IXR_Message($contents);
if (!$this->message->parse()) {
// XML error
$this->error = new IXR_Error(-32700, 'parse error. not well formed');
return false;
}
// Is the message a fault?
if ($this->message->messageType == 'fault') {
$this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
return false;
}
// Message must be OK
return true;
}
function getResponse() {
// methodResponses can only have one param - return that
return $this->message->params[0];
}
function isError() {
return (is_object($this->error));
}
function getErrorCode() {
return $this->error->code;
}
function getErrorMessage() {
return $this->error->message;
}
}
class IXR_Error {
var $code;
var $message;
function IXR_Error($code, $message) {
$this->code = $code;
$this->message = $message;
}
function getXml() {
$xml = <<<EOD
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>{$this->code}</int></value>
</member>
<member>
<name>faultString</name>
<value><string>{$this->message}</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
EOD;
return $xml;
}
}
class IXR_Date {
var $year;
var $month;
var $day;
var $hour;
var $minute;
var $second;
function IXR_Date($time) {
// $time can be a PHP timestamp or an ISO one
if (is_numeric($time)) {
$this->parseTimestamp($time);
} else {
$this->parseIso($time);
}
}
function parseTimestamp($timestamp) {
$this->year = date('Y', $timestamp);
$this->month = date('Y', $timestamp);
$this->day = date('Y', $timestamp);
$this->hour = date('H', $timestamp);
$this->minute = date('i', $timestamp);
$this->second = date('s', $timestamp);
}
function parseIso($iso) {
$this->year = substr($iso, 0, 4);
$this->month = substr($iso, 4, 2);
$this->day = substr($iso, 6, 2);
$this->hour = substr($iso, 9, 2);
$this->minute = substr($iso, 12, 2);
$this->second = substr($iso, 15, 2);
}
function getIso() {
return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
}
function getXml() {
return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
}
function getTimestamp() {
return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
}
}
class LLBlock {
var $data;
var $xml;
function LLBlock($data) {
$this->data = $data;
}
function getXml() {
if(count($this->data)>0) {
$this->xml="<array><data><value><struct>";
foreach($this->data as $name => $value) {
$this->xml=$this->xml."<member><name>".$name."</name><value><string>".$value."</string></value></member>";
}
$this->xml=$this->xml."</struct></value></data></array>";
return $this->xml;
}
}
}
class IXR_Base64 {
var $data;
function IXR_Base64($data) {
$this->data = $data;
}
function getXml() {
return '<base64>'.base64_encode($this->data).'</base64>';
}
}
class IXR_IntrospectionServer extends IXR_Server {
var $signatures;
var $help;
function IXR_IntrospectionServer() {
$this->setCallbacks();
$this->setCapabilities();
$this->capabilities['introspection'] = array(
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
'specVersion' => 1
);
$this->addCallback(
'system.methodSignature',
'this:methodSignature',
array('array', 'string'),
'Returns an array describing the return type and required parameters of a method'
);
$this->addCallback(
'system.getCapabilities',
'this:getCapabilities',
array('struct'),
'Returns a struct describing the XML-RPC specifications supported by this server'
);
$this->addCallback(
'system.listMethods',
'this:listMethods',
array('array'),
'Returns an array of available methods on this server'
);
$this->addCallback(
'system.methodHelp',
'this:methodHelp',
array('string', 'string'),
'Returns a documentation string for the specified method'
);
}
function addCallback($method, $callback, $args, $help) {
$this->callbacks[$method] = $callback;
$this->signatures[$method] = $args;
$this->help[$method] = $help;
}
function call($methodname, $args) {
// Make sure it's in an array
if ($args && !is_array($args)) {
$args = array($args);
}
// Over-rides default call method, adds signature check
if (!$this->hasMethod($methodname)) {
return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
}
$method = $this->callbacks[$methodname];
$signature = $this->signatures[$methodname];
$returnType = array_shift($signature);
// Check the number of arguments
if (count($args) != count($signature)) {
// print 'Num of args: '.count($args).' Num in signature: '.count($signature);
return new IXR_Error(-32602, 'server error. wrong number of method parameters');
}
// Check the argument types
$ok = true;
$argsbackup = $args;
for ($i = 0, $j = count($args); $i < $j; $i++) {
$arg = array_shift($args);
$type = array_shift($signature);
switch ($type) {
case 'int':
case 'i4':
if (is_array($arg) || !is_int($arg)) {
$ok = false;
}
break;
case 'base64':
case 'string':
if (!is_string($arg)) {
$ok = false;
}
break;
case 'boolean':
if ($arg !== false && $arg !== true) {
$ok = false;
}
break;
case 'float':
case 'double':
if (!is_float($arg)) {
$ok = false;
}
break;
case 'date':
case 'dateTime.iso8601':
if (!is_a($arg, 'IXR_Date')) {
$ok = false;
}
break;
}
if (!$ok) {
return new IXR_Error(-32602, 'server error. invalid method parameters');
}
}
// It passed the test - run the "real" method call
return parent::call($methodname, $argsbackup);
}
function methodSignature($method) {
if (!$this->hasMethod($method)) {
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
}
// We should be returning an array of types
$types = $this->signatures[$method];
$return = array();
foreach ($types as $type) {
switch ($type) {
case 'string':
$return[] = 'string';
break;
case 'int':
case 'i4':
$return[] = 42;
break;
case 'double':
$return[] = 3.1415;
break;
case 'dateTime.iso8601':
$return[] = new IXR_Date(time());
break;
case 'boolean':
$return[] = true;
break;
case 'base64':
$return[] = new IXR_Base64('base64');
break;
case 'array':
$return[] = array('array');
break;
case 'struct':
$return[] = array('struct' => 'struct');
break;
}
}
return $return;
}
function methodHelp($method) {
return $this->help[$method];
}
}
class IXR_ClientMulticall extends IXR_Client {
var $calls = array();
function IXR_ClientMulticall($server, $path = false, $port = 80) {
parent::IXR_Client($server, $path, $port);
$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
}
function addCall() {
$args = func_get_args();
$methodName = array_shift($args);
$struct = array(
'methodName' => $methodName,
'params' => $args
);
$this->calls[] = $struct;
}
function query() {
// Prepare multicall, then call the parent::query() method
return parent::query('system.multicall', $this->calls);
}
}
?>

View File

@ -1,14 +0,0 @@
<?
// All the grid server specific stuff lives here
// What we send to authenticate to the user/login server
$userserver_sendkey="1234";
// What we expect to get back from the user/login server
$userserver_recvkey="1234";
$sim_recvkey = "1234";
$sim_sendkey = "1234";
$grid_home = "/ogs/gridserver/";
?>

View File

@ -1,176 +0,0 @@
<?
error_reporting(E_ALL); // yes, we remember this from the login server, don't we boys and girls? don't kill innocent XML-RPC!
// these files are soooo common..... (to the grid)
include("../common/xmlrpc.inc.php");
include("../common/database.inc.php");
include("../common/grid_config.inc.php");
include("../common/util.inc.php");
include("gridserver_config.inc.php"); // grid server specific config stuff
function get_sim_info($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $userserver_sendkey, $userserver_recvkey;
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args['authkey']!=$userserver_recvkey) {
return Array(
'authkey' => 'I can play the bad key trick too you know',
'login' => 'false'
);
}
// if we get to here, the key is valid, give that login server what it wants!
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$region_handle = $args['region_handle'];
$query = "SELECT * FROM region_profiles WHERE region_handle='$region_handle'";
$result = mysql_query($query);
return mysql_fetch_assoc($result);
}
function get_session_info($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $sim_sendkey, $sim_recvkey;
// authkey, session-id, agent-id
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args[0]!=$sim_recvkey) {
return Array(
'authkey' => "I can play the bad key trick too you know"
);
}
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$session_id = $args[1];
$agent_id = $args[2];
$query = "SELECT * FROM sessions WHERE session_id = '$session_id' AND agent_id='$agent_id' AND session_active=1";
$result = mysql_query($query);
if(mysql_num_rows($result)>0) {
$info=mysql_fetch_assoc($result);
$circuit_code = $info['circuit_code'];
$secure_session_id=$info['secure_session_id'];
$query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
$result=mysql_query($query);
$userinfo=mysql_fetch_assoc($result);
$firstname=$userinfo['profile_firstname'];
$lastname=$userinfo['profile_lastname'];
$agent_id=$userinfo['userprofile_LLUUID'];
return Array(
'authkey' => $sim_sendkey,
'circuit_code' => $circuit_code,
'agent_id' => $agent_id,
'session_id' => $session_id,
'secure_session_id' => $secure_session_id,
'firstname' => $firstname,
'lastname' => $lastname
);
}
}
function check_loggedin($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $userserver_sendkey, $userserver_recvkey;
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args['authkey']!=$userserver_recvkey) {
return Array(
'authkey' => "I can play the bad key trick too you know"
);
}
// if we get to here, the key is valid, give that login server what it wants!
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$userprofile_LLUUID = $args['userprofile_LLUUID'];
$query = "SELECT * FROM sessions WHERE agent_id='$userprofile_LLUUID' AND session_active=1";
$result = mysql_query($query);
if(mysql_num_rows($result)>1) {
return Array(
'authkey' => $userserver_sendkey,
'logged_in' => 1
);
} else {
return Array(
'authkey' => $userserver_sendkey,
'logged_in' => 0
);
}
}
function create_session($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $userserver_sendkey, $userserver_recvkey;
// First see who's talking to us, if key is invalid then send an invalid one back and nothing more
if($args['authkey']!=$userserver_recvkey) {
return Array(
'authkey' => "I can play the bad key trick too you know"
);
}
// if we get to here, the key is valid, give that login server what it wants!
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
// yes, secure_sessionid should be different, i know...
$query = "SELECT value FROM Grid_settings WHERE setting='highest_LLUUID'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$highest_LLUUID = $row['value'];
$newsession_id=inc_lluuid($highest_LLUUID);
$secure_session_id=inc_lluuid($newsession_id);
$query="UPDATE Grid_settings SET value='$secure_session_id' WHERE setting='highest_LLUUID' LIMIT 1";
$result=mysql_query($query);
$userprofile_LLUUID=$args['userprofile_LLUUID'];
$current_location=$args['current_location'];
$remote_ip=$args['remote_ip'];
$query="INSERT INTO sessions(session_id,secure_session_id,agent_id,session_start,session_active,current_location,remote_ip) VALUES('$newsession_id','$secure_session_id','$userprofile_LLUUID',NOW(),1,'$current_location','$remote_ip')";
$result=mysql_query($query);
if(!isset($result)) {
die();
}
return Array(
'authkey' => $userserver_sendkey,
'session_id' => $newsession_id,
'secure_session_id' => $secure_session_id
);
}
$server=new IXR_Server(
Array(
'check_session_loggedin' => 'check_loggedin',
'create_session' => 'create_session',
'get_sim_info' => 'get_sim_info',
'get_session_info' => 'get_session_info'
)
);
?>

View File

@ -1,5 +0,0 @@
Options +FollowSymlinks
RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteRule .* index.php [L]

View File

@ -1,85 +0,0 @@
<?
// DIRTY HACK ALERT!!!!!!!!!!!!!
// The following code shows the vital importance of the r69 revision of the original gareth/ branch
// This file parses URLs of the format:
// usersessions/key/userid/data
// where key is the key to authenticate with the grid, userid is the user's LLUUID and data is the data about the user's session being requested
// if the data requested is left out, an XML response will be sent
error_reporting(E_ALL); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
include("../gridserver_config.inc.php");
include("../../common/database.inc.php");
include("../../common/util.inc.php");
// Parse out the parameters from the URL
$params = str_replace($grid_home,'', $_SERVER['REQUEST_URI']);
$params = str_replace("index.php/","",$params);
$params = split('/',$params);
// Die if the key doesn't match
if($params[1]!=$sim_recvkey) {
die();
}
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$agent_id = strtolower($params[2]);
$query = "SELECT * FROM sessions WHERE agent_id='$agent_id' AND session_active=1";
// if we have 4 params, then param 4 is the command
if(count($params)==4) {
$cmd=$params['3'];
} else if(count($params)==5) {
$circuit_code=$params[3];
$cmd=$params[4]; // otherwise, 5 is the command and 4 is the circuit code
}
$result = mysql_query($query);
if(mysql_num_rows($result)>0) {
$info=mysql_fetch_assoc($result);
$circuit_code = $info['circuit_code'];
if($circuit_code == 0) $circuit_code=$params['4'];
$secure_session_id=$info['secure_session_id'];
$session_id=$info['session_id'];
$query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
$result=mysql_query($query);
$userinfo=mysql_fetch_assoc($result);
$firstname=$userinfo['profile_firstname'];
$lastname=$userinfo['profile_lastname'];
$agent_id=$userinfo['userprofile_LLUUID'];
$exists=1;
} else {
$exists=0;
}
// if only 3 params, assume we are sending an XML response
if(count($params)==3) {
output_xml_block("usersession",Array(
'authkey' => $sim_sendkey,
'circuit_code' => $circuit_code,
'agent_id' => $agent_id,
'session_id' => $session_id,
'secure_session_id' => $secure_session_id,
'firstname' => $firstname,
'lastname' => $lastname
));
}
switch($cmd) {
case 'exists':
echo $exists;
break;
case 'delete':
$query = "UPDATE sessions SET session_active=0, session_end=NOW() WHERE agent_id='$agent_id' LIMIT 1";
$deleteresult = mysql_query($query);
break;
}
?>

View File

@ -1,170 +0,0 @@
<?
error_reporting(0); // Remember kids, PHP errors kill XML-RPC responses!
// include all the common stuff
include("../common/xmlrpc.inc.php");
include("../common/database.inc.php");
include("../common/grid_config.inc.php");
include("../common/util.inc.php");
include("login_config.inc.php"); // include login/user specific config stuff (authentication keys etc)
function login($args) {
global $dbhost,$dbuser,$dbpasswd,$dbname;
global $grid_owner, $gridserver_sendkey, $gridserver_recvkey, $gridserver_url;
if(get_magic_quotes_gpc()) {
$firstname=addslashes($args['first']);
$lastname=addslashes($args['last']);
$passwd=addslashes($args['passwd']);
} else {
$firstname=$args['first'];
$lastname=$args['last'];
$passwd=$args['passwd'];
}
$link = mysql_connect($dbhost,$dbuser,$dbpasswd)
OR die("Unable to connect to database");
mysql_select_db($dbname)
or die("Unable to select database");
$query = "SELECT userprofile_LLUUID, profile_firstname, profile_lastname, profile_passwdmd5, homesim_ip, homesim_port, homeasset_url, look_at, region_handle, position FROM local_user_profiles WHERE profile_firstname='".$firstname."' AND profile_lastname='".$lastname."' AND profile_passwdmd5='" .$passwd."'";
$profile_lookup_result=mysql_query($query);
if(mysql_num_rows($profile_lookup_result) >0) {
$profiledata = mysql_fetch_assoc($profile_lookup_result);
// if we get here, the username/password is valid, but still need to check there's not an already existing session
$client = new IXR_Client($gridserver_url);
if (!$client->query('check_session_loggedin', Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'server_type' => 'login'))) { // if this doesn't work, grid server is down - that's bad
return Array (
'reason' => 'key',
'message' => "Could not connect to grid server. Please try again later or contact the grid owner ". $grid_owner,
'login' => "false"
);
}
$response=$client->getResponse();
if($response['authkey'] != $gridserver_recvkey) { // if this doesn't match up, it's a fake grid server
return Array (
'reason' => 'key',
'message' => "Could not connect to grid server due to possible security issues. It is possible that the grid has been compromised. Please contact the grid owner " . $grid_owner . " and report this issue",
'login' => "false"
);
}
if($response['logged_in'] == 1) { // if the user is already logged in, tell them
return Array (
'reason' => 'presence',
'message' => "You appear to already be logged into this grid, if your client has recently crashed then please try again later",
'login' => "false"
);
}
// now we start a new session on the grid
$remote_ip=$_SERVER['REMOTE_ADDR'];
$region_handle=$profiledata['region_handle'];
$client->query('create_session',Array('userprofile_LLUUID' => $profiledata['userprofile_LLUUID'], 'authkey' => $gridserver_sendkey, 'remote_ip' => $remote_ip, 'current_location' => $region_handle));
$response = $client->getResponse();
$session_id = $response['session_id'];
$secure_session_id = $response['secure_session_id'];
// ask the grid server what the IP address and port of the sim we want to connect to is
$client->query('get_sim_info', Array('region_handle' => $region_handle, 'authkey' => $gridserver_sendkey) );
$siminfo = $client->getResponse();
// send the final response!
$position=$profiledata['position'];
$look_at=$profiledata['look_at'];
$LocX=intval($siminfo['GridLocX'])*256;
$LocY=intval($siminfo['GridLocY'])*256;
$home="{'region_handle':'$region_handle', 'position':'$position', 'look_at':'$look_at'}";
$globaltextures = new LLBlock(
Array(
'sun_texture_id' => "cce0f112-878f-4586-a2e2-a8f104bba271",
'cloud_texture_id' => "fc4b9f0b-d008-45c6-96a4-01dd947ac621",
'moon_texture_id' => "d07f6eed-b96a-47cd-b51d-400ad4a1c428"
));
$login_flags = new LLBlock(
Array(
'stipend_since_login' => "N",
'ever_logged_in' => "Y",
'gendered' => "Y",
'daylight_savings' => "N"
));
$ui_config = new LLBlock(
Array(
'allow_first_life' => "Y"
));
$inventory_skeleton = new LLBlock(Array(
Array(
'name' => 'My inventory',
'parent_id' => '00000000-0000-0000-0000-000000000000',
'version' => 4,
'type_default' => 8,
'folder_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8'
),
Array(
'name' => 'Textures',
'parent_id' => 'f798e114-c10f-409b-a90d-a11577ff1de8',
'version' => 1,
'type_default' => 0,
'folder_id' => 'fc8b4059-30bb-43a8-a042-46f5b431ad82'
)));
$inventory_root = new LLBlock(
Array(
'folder_id' => "f798e114-c10f-409b-a90d-a11577ff1de8"
));
$initial_outfit = new LLBlock(
Array(
'folder_name' => "Nightclub Female",
'gender' => "female"
));
return Array (
'message' => "Welcome to OGS!",
'session_id' => format_lluuid($session_id),
'sim_port' => intval($siminfo['port']),
'agent_access' => "M",
'start_location' => "last",
'global-textures' => $globaltextures,
'seconds_since_epoch' => time(),
'first_name' => $profiledata['profile_firstname'],
'circuit_code' => 50633318,
'login_flags' => $login_flags,
'seed_capability' => '',
'home' => $home,
'secure_session_id' => format_lluuid($secure_session_id),
'last_name' => $profiledata['profile_lastname'],
'ui-config' => $ui_config,
'region_x' => $LocX,
'inventory_skeleton' => $inventory_skeleton,
'sim_ip' => $siminfo['ip_addr'],
'region_y' => $LocY,
'inventory-root' => $inventory_root,
'login' => "true",
'look_at' => $look_at,
'agent_id' => format_lluuid($profiledata['userprofile_LLUUID']),
'initial-outfit' => $initial_outfit
);
} else {
// this is the default invalid username/password error
return Array (
'reason' => 'key',
'message' => "You have entered an invalid name/password combination or are using an incompatible client. Please check with the grid owner " .$grid_owner . " if you are sure your login details are accurate.",
'login' => "false",
);
}
}
$server=new IXR_Server(array('login_to_simulator' => 'login'));
?>

View File

@ -1,11 +0,0 @@
<?
// All the user/login server specific stuff lives here
// What we send to authenticate to the grid server
$gridserver_sendkey="1234";
// What we expect to get back from the grid server
$gridserver_recvkey="1234";
$gridserver_url="http://www.osgrid.org/ogs/gridserver/index.php";
?>

View File

@ -1,63 +0,0 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>First nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="bin/OpenSim.exe" failonerror="false" />
<delete file="bin/OpenSim.pdb" failonerror="false" />
</target>
<target name="svnupdate" description="updates to latest SVN">
<exec program="svn">
<arg value="update" />
</exec>
</target>
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
</target>
<target name="build" description="compiles the source code">
<exec program="genvers.sh" />
<loadfile file="VERSION" property="svnver"/>
<asminfo output="src/AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.InteropServices" />
</imports>
<attributes>
<attribute type="ComVisibleAttribute" value="false" />
<attribute type="CLSCompliantAttribute" value="false" />
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
<attribute type="AssemblyTitleAttribute" value="opensim" />
<attribute type="AssemblyDescriptionAttribute" value="The C# implementation of the simulator portion of OGS" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="exe" output="bin/OpenSim.exe" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="bin/" failonempty="true">
<include name="System" />
<include name="System.Data" />
<include name="System.Xml" />
<include name="Axiom.MathLib.dll" />
<include name="libsecondlife.dll" />
<include name="log4net.dll" />
<include name="Db4objects.Db4o.dll" />
</references>
<sources basedir="src/">
<include name="AssemblyInfo.cs" />
<include name="ServerConsole.cs" />
<include name="Config.cs" />
<include name="VersionInfo.cs" />
<include name="Util.cs" />
<include name="types/*.cs" />
<include name="world/*.cs" />
<include name="OpenSimClient.cs" />
<include name="Main.cs" />
</sources>
</csc>
</target>
</project>

View File

@ -1,44 +0,0 @@
<Project name="opensim" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="./bin/Debug" assembly="opensim" />
<Build debugmode="True" target="Exe" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
<CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
<Configuration name="Release" ctype="DotNetProjectConfiguration">
<Output directory="./bin/Release" assembly="opensim" />
<Build debugmode="False" target="Exe" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
<CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
</Configurations>
<Contents>
<File name="./src/Config.cs" subtype="Code" buildaction="Compile" />
<File name="./src/Main.cs" subtype="Code" buildaction="Compile" />
<File name="./src/OpenSimClient.cs" subtype="Code" buildaction="Compile" />
<File name="./src/Util.cs" subtype="Code" buildaction="Compile" />
<File name="./src/VersionInfo.cs" subtype="Code" buildaction="Compile" />
<File name="./src/types/BitPack.cs" subtype="Code" buildaction="Compile" />
<File name="./src/types/Mesh.cs" subtype="Code" buildaction="Compile" />
<File name="./src/types/Triangle.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/Avatar.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/Entity.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/Primitive.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/ScriptEngine.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/SurfacePatch.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/TerrainDecoder.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/World.cs" subtype="Code" buildaction="Compile" />
<File name="./src/world/scripting/IScript.cs" subtype="Code" buildaction="Compile" />
<File name="./src/AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Assembly" localcopy="True" refto="./bin/Axiom.MathLib.dll" />
<ProjectReference type="Assembly" localcopy="True" refto="./bin/Db4objects.Db4o.dll" />
<ProjectReference type="Assembly" localcopy="True" refto="./bin/libsecondlife.dll" />
<ProjectReference type="Assembly" localcopy="True" refto="./bin/log4net.dll" />
</References>
</Project>

View File

@ -1,16 +0,0 @@
<Combine name="opensim" fileversion="2.0">
<Configurations active="Debug">
<Configuration name="Debug" ctype="CombineConfiguration">
<Entry build="True" name="opensim" configuration="Debug" />
</Configuration>
<Configuration name="Release" ctype="CombineConfiguration">
<Entry build="True" name="opensim" configuration="Release" />
</Configuration>
</Configurations>
<StartMode startupentry="opensim" single="True">
<Execute type="None" entry="opensim" />
</StartMode>
<Entries>
<Entry filename="./opensim.mdp" />
</Entries>
</Combine>

View File

@ -1,174 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using Db4objects.Db4o;
using libsecondlife;
using OpenSim.world;
namespace OpenSim
{
/// <summary>
/// This class handles connection to the underlying database used for configuration of the region.
/// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate
/// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from
/// what is hardcoded here and then saved into opensim.yap for future startups.
/// </summary>
public class SimConfig
{
public string RegionName;
public uint RegionLocX;
public uint RegionLocY;
public ulong RegionHandle;
public int IPListenPort;
public string IPListenAddr;
public bool sandbox = true;
public string AssetURL = String.Empty;
public string AssetSendKey = String.Empty;
public string GridURL = String.Empty;
public string GridSendKey = String.Empty;
private IObjectContainer db;
public void LoadDefaults()
{
string tempstring;
OpenSim_Main.localcons.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
this.RegionName = OpenSim_Main.localcons.CmdPrompt("Name [OpenSim test]: ", "OpenSim test");
this.RegionLocX = (uint)Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("Grid Location X [997]: ", "997"));
this.RegionLocY = (uint)Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("Grid Location Y [996]: ", "996"));
this.IPListenPort = Convert.ToInt32(OpenSim_Main.localcons.CmdPrompt("UDP port for client connections [9000]: ", "9000"));
this.IPListenAddr = OpenSim_Main.localcons.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1");
tempstring = OpenSim_Main.localcons.CmdPrompt("Run in sandbox or grid mode? [sandbox]: ", "sandbox", "sandbox", "grid");
this.sandbox = tempstring.Equals("sandbox");
if (!this.sandbox)
{
this.AssetURL = OpenSim_Main.localcons.CmdPrompt("Asset server URL: ");
this.AssetSendKey = OpenSim_Main.localcons.CmdPrompt("Asset server key: ");
this.GridURL = OpenSim_Main.localcons.CmdPrompt("Grid server URL: ");
this.GridSendKey = OpenSim_Main.localcons.CmdPrompt("Grid server key: ");
}
this.RegionHandle = Helpers.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
}
public void InitConfig()
{
try
{
db = Db4oFactory.OpenFile("opensim.yap");
IObjectSet result = db.Get(typeof(SimConfig));
if (result.Count == 1)
{
OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading");
foreach (SimConfig cfg in result)
{
this.sandbox = cfg.sandbox;
this.RegionName = cfg.RegionName;
this.RegionLocX = cfg.RegionLocX;
this.RegionLocY = cfg.RegionLocY;
this.RegionHandle = Helpers.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
this.IPListenPort = cfg.IPListenPort;
this.IPListenAddr = cfg.IPListenAddr;
this.AssetURL = cfg.AssetURL;
this.AssetSendKey = cfg.AssetSendKey;
this.GridURL = cfg.GridURL;
this.GridSendKey = cfg.GridSendKey;
}
}
else
{
OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
LoadDefaults();
OpenSim_Main.localcons.WriteLine("Writing out default settings to local database");
db.Set(this);
}
}
catch (Exception e)
{
db.Close();
OpenSim_Main.localcons.WriteLine("Config.cs:InitConfig() - Exception occured");
OpenSim_Main.localcons.WriteLine(e.ToString());
}
OpenSim_Main.localcons.WriteLine("Sim settings loaded:");
OpenSim_Main.localcons.WriteLine("Name: " + this.RegionName);
OpenSim_Main.localcons.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
OpenSim_Main.localcons.WriteLine("Region Handle: " + this.RegionHandle.ToString());
OpenSim_Main.localcons.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
OpenSim_Main.localcons.WriteLine("Sandbox Mode? " + this.sandbox.ToString());
OpenSim_Main.localcons.WriteLine("Asset URL: " + this.AssetURL);
OpenSim_Main.localcons.WriteLine("Asset key: " + this.AssetSendKey);
OpenSim_Main.localcons.WriteLine("Grid URL: " + this.GridURL);
OpenSim_Main.localcons.WriteLine("Grid key: " + this.GridSendKey);
}
public World LoadWorld()
{
OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Loading world....");
World blank = new World();
OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB");
IObjectSet world_result = db.Get(new float[65536]);
if (world_result.Count > 0)
{
OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading");
blank.LandMap = (float[])world_result.Next();
}
else
{
OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one");
HeightmapGenHills hills = new HeightmapGenHills();
blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
OpenSim_Main.localcons.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database");
db.Set(blank.LandMap);
db.Commit();
}
return blank;
}
public void LoadFromGrid()
{
OpenSim_Main.localcons.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
// TODO: Make this crap work
}
public void Shutdown()
{
db.Close();
}
}
}

View File

@ -1,159 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using System.IO;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.world;
namespace OpenSim
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class OpenSim_Main
{
public static DateTime startuptime;
public static OpenSim_Main sim;
public static SimConfig cfg;
public static World local_world;
public static ServerConsole localcons;
private static Thread MainListener;
public static Socket Server;
private static IPEndPoint ServerIncoming;
private static byte[] RecvBuffer = new byte[4096];
private byte[] ZeroBuffer = new byte[8192];
private static IPEndPoint ipeSender;
private static EndPoint epSender;
private static AsyncCallback ReceivedData;
public Dictionary<EndPoint, OpenSimClient> ClientThreads = new Dictionary<EndPoint, OpenSimClient>();
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
sim = new OpenSim_Main();
sim.Startup();
while(true) {
localcons.MainConsolePrompt();
}
}
private OpenSim_Main() {
}
public static void Shutdown() {
localcons.WriteLine("Main.cs:Shutdown() - Closing all threads");
localcons.WriteLine("Main.cs:Shutdown() - Killing listener thread");
MainListener.Abort();
localcons.WriteLine("Main.cs:Shutdown() - Killing clients");
// IMPLEMENT THIS
localcons.WriteLine("Main.cs:Shutdown() - Closing console and terminating");
localcons.Close();
Environment.Exit(0);
}
private void Startup() {
startuptime=DateTime.Now;
localcons=new ServerConsole(ServerConsole.ConsoleType.Local,"",0);
// We check our local database first, then the grid for config options
localcons.WriteLine("Main.cs:Startup() - Loading configuration");
cfg = new SimConfig();
cfg.InitConfig();
localcons.WriteLine("Main.cs:Startup() - Contacting gridserver");
cfg.LoadFromGrid();
localcons.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString());
localcons.WriteLine("Initialising world");
local_world = cfg.LoadWorld();
localcons.WriteLine("Main.cs:Startup() - Starting up main world loop");
local_world.InitLoop();
localcons.WriteLine("Main.cs:Startup() - Starting up messaging system");
MainListener = new Thread(new ThreadStart(MainServerListener));
MainListener.Start();
Thread.Sleep(500); // give other threads a chance to catch up
string[] noparams = new string[1];
noparams[0]="";
localcons.WriteLine("\nOpenSim ready\nType help for list of commands");
}
private void OnReceivedData(IAsyncResult result) {
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
Packet packet = null;
int numBytes = Server.EndReceiveFrom(result, ref epSender);
int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
// This is either a new client or a packet to send to an old one
if(ClientThreads.ContainsKey(epSender)) {
ClientThreads[epSender].InPacket(packet);
} else if( packet.Type == PacketType.UseCircuitCode ) { // new client
OpenSimClient newuser = new OpenSimClient(epSender,(UseCircuitCodePacket)packet);
ClientThreads.Add(epSender, newuser);
} else { // invalid client
Console.Error.WriteLine("Main.cs:OnReceivedData() - WARNING: Got a packet from an invalid client - " + epSender.ToString());
}
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
private void MainServerListener() {
localcons.WriteLine("Main.cs:MainServerListener() - New thread started");
localcons.WriteLine("Main.cs:MainServerListener() - Opening UDP socket on " + cfg.IPListenAddr + ":" + cfg.IPListenPort);
ServerIncoming = new IPEndPoint(IPAddress.Any, cfg.IPListenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Server.Bind(ServerIncoming);
localcons.WriteLine("Main.cs:MainServerListener() - UDP socket bound, getting ready to listen");
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint) ipeSender;
ReceivedData = new AsyncCallback(this.OnReceivedData);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
localcons.WriteLine("Main.cs:MainServerListener() - Listening...");
while(true) {
Thread.Sleep(100);
local_world.DoStuff();
}
}
}
}

View File

@ -1,510 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using System.Timers;
namespace OpenSim
{
/// <summary>
/// Handles new client connections
/// Constructor takes a single Packet and authenticates everything
/// </summary>
public class OpenSimClient
{
public LLUUID AgentID;
public LLUUID SessionID;
public uint CircuitCode;
public world.Avatar ClientAvatar;
private UseCircuitCodePacket cirpack;
private Thread ClientThread;
public EndPoint userEP;
private BlockingQueue<QueItem> PacketQueue;
private BlockingQueue<TransferRequestPacket> AssetRequests;
private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
private System.Timers.Timer AckTimer;
private uint Sequence = 0;
private object SequenceLock = new object();
private const int MAX_APPENDED_ACKS = 10;
private const int RESEND_TIMEOUT = 4000;
private const int MAX_SEQUENCE = 0xFFFFFF;
//private Queue<uint> Inbox;
public void ack_pack(Packet Pack)
{
//libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
//ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
//ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
//ack_it.Packets[0].ID = Pack.Header.ID;
//ack_it.Header.Reliable = false;
//OutPacket(ack_it);
if (Pack.Header.Reliable)
{
lock (PendingAcks)
{
uint sequence = (uint)Pack.Header.Sequence;
if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
}
}
}
public void AssetLoader()
{
if (OpenSim_Main.cfg.sandbox == false)
{
WebResponse AssetResponse;
byte[] idata;
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread");
TransferRequestPacket reqPacket = AssetRequests.Dequeue();
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it");
LLUUID AssetID = new LLUUID(reqPacket.TransferInfo.Params, 0);
try
{
WebRequest AssetLoad = WebRequest.Create(OpenSim_Main.cfg.AssetURL + "getasset/" + OpenSim_Main.cfg.AssetSendKey + "/" + AssetID + "/data");
AssetResponse = AssetLoad.GetResponse();
idata = new byte[(int)AssetResponse.ContentLength];
BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
idata = br.ReadBytes((int)AssetResponse.ContentLength);
br.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return;
}
TransferInfoPacket Transfer = new TransferInfoPacket();
Transfer.TransferInfo.ChannelType = 2;
Transfer.TransferInfo.Status = 0;
Transfer.TransferInfo.TargetType = 0;
Transfer.TransferInfo.Params = reqPacket.TransferInfo.Params;
Transfer.TransferInfo.Size = (int)AssetResponse.ContentLength;
Transfer.TransferInfo.TransferID = reqPacket.TransferInfo.TransferID;
OutPacket(Transfer);
TransferPacketPacket TransferPacket = new TransferPacketPacket();
TransferPacket.TransferData.Packet = 0;
TransferPacket.TransferData.ChannelType = 2;
TransferPacket.TransferData.TransferID = reqPacket.TransferInfo.TransferID;
if (AssetResponse.ContentLength > 1000)
{
byte[] chunk = new byte[1000];
Array.Copy(idata, chunk, 1000);
TransferPacket.TransferData.Data = chunk;
TransferPacket.TransferData.Status = 0;
OutPacket(TransferPacket);
TransferPacket = new TransferPacketPacket();
TransferPacket.TransferData.Packet = 1;
TransferPacket.TransferData.ChannelType = 2;
TransferPacket.TransferData.TransferID = reqPacket.TransferInfo.TransferID;
byte[] chunk1 = new byte[(idata.Length - 1000)];
Array.Copy(idata, 1000, chunk1, 0, chunk1.Length);
TransferPacket.TransferData.Data = chunk1;
TransferPacket.TransferData.Status = 1;
OutPacket(TransferPacket);
}
else
{
TransferPacket.TransferData.Status = 1;
TransferPacket.TransferData.Data = idata;
OutPacket(TransferPacket);
}
AssetResponse.Close();
}
}
public void Logout()
{
// TODO - kill any AssetLoaders
ClientThread.Abort();
}
public void ProcessInPacket(Packet Pack)
{
ack_pack(Pack);
switch (Pack.Type)
{
case PacketType.CompleteAgentMovement:
ClientAvatar.CompleteMovement(OpenSim_Main.local_world);
ClientAvatar.SendInitialPosition();
break;
case PacketType.RegionHandshakeReply:
OpenSim_Main.local_world.SendLayerData(this);
break;
case PacketType.AgentWearablesRequest:
ClientAvatar.SendInitialAppearance();
break;
case PacketType.TransferRequest:
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
// We put transfer requests into a big queue and then spawn a thread for each new one
TransferRequestPacket transfer = (TransferRequestPacket)Pack;
AssetRequests.Enqueue(transfer);
Thread AssetLoaderThread = new Thread(new ThreadStart(AssetLoader));
AssetLoaderThread.Start();
break;
case PacketType.LogoutRequest:
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
lock (OpenSim_Main.local_world.Entities)
{
OpenSim_Main.local_world.Entities.Remove(this.AgentID);
}
if (OpenSim_Main.cfg.sandbox == false)
{
WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete");
WebResponse GridResponse = DeleteSession.GetResponse();
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
String grTest = sr.ReadLine();
sr.Close();
GridResponse.Close();
OpenSim_Main.localcons.WriteLine("DEBUG: " + grTest);
}
this.ClientThread.Abort();
break;
case PacketType.AgentUpdate:
ClientAvatar.HandleAgentUpdate((AgentUpdatePacket)Pack);
break;
case PacketType.ChatFromViewer:
ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") break;
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
reply.ChatData.Audible = 1;
reply.ChatData.Message = inchatpack.ChatData.Message;
reply.ChatData.ChatType = 1;
reply.ChatData.SourceType = 1;
reply.ChatData.Position = this.ClientAvatar.position;
reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0");
reply.ChatData.OwnerID = this.AgentID;
reply.ChatData.SourceID = this.AgentID;
foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values)
{
client.OutPacket(reply);
}
break;
}
}
private void ResendUnacked()
{
int now = Environment.TickCount;
lock (NeedAck)
{
foreach (Packet packet in NeedAck.Values)
{
if (now - packet.TickCount > RESEND_TIMEOUT)
{
packet.Header.Resent = true;
OutPacket(packet);
}
}
}
}
private void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
if (PendingAcks.Count > 250)
{
return;
}
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
foreach (uint ack in PendingAcks.Values)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack;
i++;
}
acks.Header.Reliable = false;
OutPacket(acks);
PendingAcks.Clear();
}
}
}
private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
{
SendAcks();
ResendUnacked();
}
public void ProcessOutPacket(Packet Pack)
{
// Keep track of when this packet was sent out
Pack.TickCount = Environment.TickCount;
if (!Pack.Header.Resent)
{
// Set the sequence number
lock (SequenceLock)
{
if (Sequence >= MAX_SEQUENCE)
Sequence = 1;
else
Sequence++;
Pack.Header.Sequence = Sequence;
}
if (Pack.Header.Reliable) //DIRTY HACK
{
lock (NeedAck)
{
if (!NeedAck.ContainsKey(Pack.Header.Sequence))
{
NeedAck.Add(Pack.Header.Sequence, Pack);
}
else
{
// Client.Log("Attempted to add a duplicate sequence number (" +
// packet.Header.Sequence + ") to the NeedAck dictionary for packet type " +
// packet.Type.ToString(), Helpers.LogLevel.Warning);
}
}
// Don't append ACKs to resent packets, in case that's what was causing the
// delivery to fail
if (!Pack.Header.Resent)
{
// Append any ACKs that need to be sent out to this packet
lock (PendingAcks)
{
if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS &&
Pack.Type != PacketType.PacketAck &&
Pack.Type != PacketType.LogoutRequest)
{
Pack.Header.AckList = new uint[PendingAcks.Count];
int i = 0;
foreach (uint ack in PendingAcks.Values)
{
Pack.Header.AckList[i] = ack;
i++;
}
PendingAcks.Clear();
Pack.Header.AppendedAcks = true;
}
}
}
}
}
byte[] ZeroOutBuffer = new byte[4096];
byte[] sendbuffer;
sendbuffer = Pack.ToBytes();
try
{
if (Pack.Header.Zerocoded)
{
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
OpenSim_Main.Server.SendTo(ZeroOutBuffer, packetsize, SocketFlags.None, userEP);
}
else
{
OpenSim_Main.Server.SendTo(sendbuffer, sendbuffer.Length, SocketFlags.None, userEP);
}
}
catch (Exception)
{
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
ClientThread.Abort();
}
}
public void InPacket(Packet NewPack)
{
// Handle appended ACKs
if (NewPack.Header.AppendedAcks)
{
lock (NeedAck)
{
foreach (uint ack in NewPack.Header.AckList)
{
OpenSim_Main.localcons.WriteLine("Got appended ack: " + ack);
NeedAck.Remove(ack);
}
}
}
// Handle PacketAck packets
if (NewPack.Type == PacketType.PacketAck)
{
PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
lock (NeedAck)
{
foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
{
NeedAck.Remove(block.ID);
}
}
}
else if ((NewPack.Type == PacketType.StartPingCheck))
{
//reply to pingcheck
libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack;
libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket();
endPing.PingID.PingID = startPing.PingID.PingID;
OutPacket(endPing);
}
else
{
QueItem item = new QueItem();
item.Packet = NewPack;
item.Incoming = true;
this.PacketQueue.Enqueue(item);
}
}
public void OutPacket(Packet NewPack)
{
QueItem item = new QueItem();
item.Packet = NewPack;
item.Incoming = false;
this.PacketQueue.Enqueue(item);
}
public OpenSimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack)
{
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request");
cirpack = initialcirpack;
userEP = remoteEP;
PacketQueue = new BlockingQueue<QueItem>();
AssetRequests = new BlockingQueue<TransferRequestPacket>();
AckTimer = new System.Timers.Timer(500);
AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
AckTimer.Start();
ClientThread = new Thread(new ThreadStart(AuthUser));
ClientThread.IsBackground = true;
ClientThread.Start();
}
private void ClientLoop()
{
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:ClientLoop() - Entered loop");
while (true)
{
QueItem nextPacket = PacketQueue.Dequeue();
if (nextPacket.Incoming)
{
//is a incoming packet
ProcessInPacket(nextPacket.Packet);
}
else
{
//is a out going packet
ProcessOutPacket(nextPacket.Packet);
}
}
}
private void InitNewClient()
{
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
OpenSim_Main.local_world.AddViewerAgent(this);
world.Entity tempent = OpenSim_Main.local_world.Entities[this.AgentID];
this.ClientAvatar = (world.Avatar)tempent;
}
private void AuthUser()
{
if (OpenSim_Main.cfg.sandbox == false)
{
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
OpenSim_Main.localcons.WriteLine(OpenSim_Main.cfg.GridURL);
WebResponse GridResponse = CheckSession.GetResponse();
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
String grTest = sr.ReadLine();
sr.Close();
GridResponse.Close();
if (String.IsNullOrEmpty(grTest) || grTest.Equals("1"))
{ // YAY! Valid login
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
this.AgentID = cirpack.CircuitCode.ID;
this.SessionID = cirpack.CircuitCode.SessionID;
this.CircuitCode = cirpack.CircuitCode.Code;
InitNewClient();
ClientLoop();
}
else
{ // Invalid
OpenSim_Main.localcons.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
ClientThread.Abort();
}
}
else
{
this.AgentID = cirpack.CircuitCode.ID;
this.SessionID = cirpack.CircuitCode.SessionID;
this.CircuitCode = cirpack.CircuitCode.Code;
InitNewClient();
ClientLoop();
}
}
}
}

View File

@ -1,65 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>OpenSim</RootNamespace>
<AssemblyName>OpenSim</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</ProjectGuid>
<StartupObject>OpenSim.OpenSim_Main</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\bin\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>..\bin\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="Axiom.MathLib, Version=0.7.0.25497, Culture=neutral">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\Axiom.MathLib.dll</HintPath>
</Reference>
<Reference Include="Db4objects.Db4o, Version=6.0.1.0, Culture=neutral, PublicKeyToken=6199cd4f203aa8eb, processorArchitecture=MSIL" />
<Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\libsecondlife.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\bin\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Main.cs" />
<Compile Include="OpenSimClient.cs" />
<Compile Include="ServerConsole.cs" />
<Compile Include="types\Mesh.cs" />
<Compile Include="types\Triangle.cs" />
<Compile Include="Util.cs" />
<Compile Include="VersionInfo.cs" />
<Compile Include="world\Avatar.cs" />
<Compile Include="world\Entity.cs" />
<Compile Include="world\HeightmapGenHills.cs" />
<Compile Include="world\PhysicsEngine.cs" />
<Compile Include="world\Primitive.cs" />
<Compile Include="world\ScriptEngine.cs" />
<Compile Include="world\scripting\IScript.cs" />
<Compile Include="world\SurfacePatch.cs" />
<Compile Include="world\World.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -1,26 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET 1.1 = Debug|.NET 1.1
Debug|Any CPU = Debug|Any CPU
Release|.NET 1.1 = Release|.NET 1.1
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.ActiveCfg = Debug|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|.NET 1.1.Build.0 = Debug|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.ActiveCfg = Release|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,195 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.IO;
using System.Net;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim
{
public class ServerConsole {
private ConsoleType ConsType;
StreamWriter Log;
public enum ConsoleType {
Local, // Use stdio
TCP, // Use TCP/telnet
SimChat // Use in-world chat (for gods)
}
// STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
// constype - the type of console to use (see enum ConsoleType)
// sparam - depending on the console type:
// TCP - the IP to bind to (127.0.0.1 if blank)
// Local - param ignored
// SimChat - the AgentID of this sim's admin
// and for the iparam:
// TCP - the port to bind to
// Local - param ignored
// SimChat - the chat channel to accept commands from
public ServerConsole(ConsoleType constype, string sparam, int iparam) {
ConsType = constype;
switch(constype) {
case ConsoleType.Local:
Console.WriteLine("ServerConsole.cs - creating new local console");
Console.WriteLine("Logs will be saved to current directory in opensim-console.log");
Log=File.AppendText("opensim-console.log");
Log.WriteLine("========================================================================");
Log.WriteLine("OpenSim " + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
break;
case ConsoleType.TCP:
break;
case ConsoleType.SimChat:
break;
default:
Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
break;
}
}
public void Close() {
Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString());
Log.Close();
}
// You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here
public void WriteLine(string Line) {
Log.WriteLine(Line);
Console.WriteLine(Line);
return;
}
public string ReadLine() {
string TempStr=Console.ReadLine();
Log.WriteLine(TempStr);
return TempStr;
}
public int Read() {
int TempInt= Console.Read();
Log.Write((char)TempInt);
return TempInt;
}
public void Write(string Line) {
Console.Write(Line);
Log.Write(Line);
return;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public string CmdPrompt(string prompt) {
this.Write(prompt);
return this.ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
public string CmdPrompt(string prompt, string defaultresponse) {
string temp=CmdPrompt(prompt);
if(temp=="") {
return defaultresponse;
} else {
return temp;
}
}
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) {
bool itisdone=false;
string temp=CmdPrompt(prompt,defaultresponse);
while(itisdone==false) {
if((temp==OptionA) || (temp==OptionB)) {
itisdone=true;
} else {
this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
temp=CmdPrompt(prompt,defaultresponse);
}
}
return temp;
}
// Runs a command with a number of parameters
public Object RunCmd(string Cmd, string[] cmdparams) {
switch(Cmd) {
case "help":
this.WriteLine("show users - show info about connected users");
this.WriteLine("shutdown - disconnect all clients and shutdown");
break;
case "show":
ShowCommands(cmdparams[0]);
break;
case "shutdown":
OpenSim_Main.Shutdown();
break;
}
return null;
}
// Shows data about something
public void ShowCommands(string ShowWhat) {
switch(ShowWhat) {
case "uptime":
this.WriteLine("OpenSim has been running since " + OpenSim_Main.startuptime.ToString());
this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.startuptime).ToString());
break;
case "users":
OpenSim.world.Avatar TempAv;
this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}","Firstname", "Lastname","Agent ID", "Session ID", "Circuit", "IP"));
foreach (libsecondlife.LLUUID UUID in OpenSim_Main.local_world.Entities.Keys) {
TempAv=(OpenSim.world.Avatar)OpenSim_Main.local_world.Entities[UUID];
this.WriteLine(String.Format("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}",TempAv.firstname, TempAv.lastname,UUID, TempAv.ControllingClient.SessionID, TempAv.ControllingClient.CircuitCode, TempAv.ControllingClient.userEP.ToString()));
}
break;
}
}
// Displays a prompt to the user and then runs the command they entered
public void MainConsolePrompt() {
string[] tempstrarray;
string tempstr = this.CmdPrompt("OpenSim-" + OpenSim_Main.cfg.RegionHandle.ToString() + " # ");
tempstrarray = tempstr.Split(' ');
string cmd=tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
Array.Reverse(tempstrarray);
string[] cmdparams=(string[])tempstrarray;
RunCmd(cmd,cmdparams);
}
}
}

View File

@ -1,75 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim
{
/// <summary>
/// </summary>
public class QueItem {
public QueItem()
{
}
public Packet Packet;
public bool Incoming;
}
public class BlockingQueue< T > {
private Queue< T > _queue = new Queue< T >();
private object _queueSync = new object();
public void Enqueue(T value)
{
lock(_queueSync)
{
_queue.Enqueue(value);
Monitor.Pulse(_queueSync);
}
}
public T Dequeue()
{
lock(_queueSync)
{
if( _queue.Count < 1)
Monitor.Wait(_queueSync);
return _queue.Dequeue();
}
}
}
}

View File

@ -1,37 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace OpenSim
{
/// <summary>
/// </summary>
public class VersionInfo
{
public static string Version = "0.0.1-unofficial";
}
}

View File

@ -1,37 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace OpenSim
{
/// <summary>
/// </summary>
public class VersionInfo
{
public static string Version = "@@VERSION";
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.types
{
// TODO: This will need some performance tuning no doubt.
public class Mesh
{
public List<Triangle> mesh;
public Mesh()
{
mesh = new List<Triangle>();
}
public void AddTri(Triangle tri)
{
mesh.Add(tri);
}
public static Mesh operator +(Mesh a, Mesh b)
{
a.mesh.AddRange(b.mesh);
return a;
}
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Axiom.MathLib;
namespace OpenSim.types
{
public class Triangle
{
Vector3 a;
Vector3 b;
Vector3 c;
public Triangle()
{
a = new Vector3();
b = new Vector3();
c = new Vector3();
}
public Triangle(Vector3 A, Vector3 B, Vector3 C)
{
a = A;
b = B;
c = C;
}
}
}

View File

@ -1,256 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using Axiom.MathLib;
namespace OpenSim.world
{
public class Avatar : Entity
{
public string firstname;
public string lastname;
public OpenSimClient ControllingClient;
public LLVector3 oldvel;
public LLVector3 oldpos;
public uint CurrentKeyMask;
public bool walking;
private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
public Avatar(OpenSimClient TheClient) {
OpenSim_Main.localcons.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
ControllingClient=TheClient;
SetupTemplate("avatar-template.dat");
position = new LLVector3(100.0f,100.0f,60.0f);
}
public override void update() {
lock(this) {
base.update();
oldvel=this.velocity;
oldpos=this.position;
if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) {
Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f);
tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f;
this.velocity.X = tmpVelocity.x;
this.velocity.Y = tmpVelocity.y;
this.velocity.Z = tmpVelocity.z;
this.walking=true;
} else {
this.velocity.X=0;
this.velocity.Y=0;
this.velocity.Z=0;
this.walking=false;
}
}
}
private void SetupTemplate(string name)
{
int i = 0;
FileInfo fInfo = new FileInfo(name);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(name, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
byte [] data1 = br.ReadBytes((int)numBytes);
br.Close();
fStream.Close();
libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock objdata = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
System.Text.Encoding enc = System.Text.Encoding.ASCII;
libsecondlife.LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
pos.X = 100f;
objdata.ID = this.localid;
objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
libsecondlife.LLVector3 pos2 = new LLVector3(100f,100f,23f);
//objdata.FullID=user.AgentID;
byte[] pb = pos.GetBytes();
Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
AvatarTemplate = objdata;
}
public void CompleteMovement(World RegionInfo) {
OpenSim_Main.localcons.WriteLine("Avatar.cs:CompleteMovement() - Constructing AgentMovementComplete packet");
AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
mov.AgentData.SessionID = this.ControllingClient.SessionID;
mov.AgentData.AgentID = this.ControllingClient.AgentID;
mov.Data.RegionHandle = OpenSim_Main.cfg.RegionHandle;
// TODO - dynamicalise this stuff
mov.Data.Timestamp = 1172750370;
mov.Data.Position = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
OpenSim_Main.localcons.WriteLine("Sending AgentMovementComplete packet");
ControllingClient.OutPacket(mov);
}
public void SendInitialPosition() {
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
//send a objectupdate packet with information about the clients avatar
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
objupdate.ObjectData[0] = AvatarTemplate;
//give this avatar object a local id and assign the user a name
objupdate.ObjectData[0].ID = this.localid;
//User_info.name="Test"+this.local_numer+" User";
objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
OpenSim_Main.local_world._localNumber++;
this.ControllingClient.OutPacket(objupdate);
}
public override ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() {
byte[] bytes = new byte[60];
int i=0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
dat.TextureEntry = AvatarTemplate.TextureEntry;
libsecondlife.LLVector3 pos2 = new LLVector3(this.position.X, this.position.Y, this.position.Z);
uint ID = this.localid;
bytes[i++] = (byte)(ID % 256);
bytes[i++] = (byte)((ID >> 8) % 256);
bytes[i++] = (byte)((ID >> 16) % 256);
bytes[i++] = (byte)((ID >> 24) % 256);
bytes[i++] = 0;
bytes[i++] = 1;
i += 14;
bytes[i++] = 128;
bytes[i++] = 63;
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, bytes, i, pb.Length);
i += 12;
ushort ac = 32767;
bytes[i++] = (byte)((ushort)(((this.velocity.X/128f)+1)*32767) % 256 );
bytes[i++] = (byte)(((ushort)(((this.velocity.X/128f)+1)*32767) >> 8) % 256);
bytes[i++] = (byte)((ushort)(((this.velocity.Y/128f)+1)*32767) % 256);
bytes[i++] = (byte)(((ushort)(((this.velocity.Y/128f)+1)*32767) >> 8) % 256);
bytes[i++] = (byte)((ushort)(((this.velocity.Z/128f)+1)*32767) % 256);
bytes[i++] = (byte)(((ushort)(((this.velocity.Z/128f)+1)*32767) >> 8) % 256);
//accel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rot
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
//rotation vel
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
bytes[i++] = (byte)(ac % 256);
bytes[i++] = (byte)((ac >> 8) % 256);
dat.Data=bytes;
return(dat);
}
public void SendInitialAppearance() {
AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
aw.AgentData.AgentID = this.ControllingClient.AgentID;
aw.AgentData.SerialNum = 0;
aw.AgentData.SessionID = ControllingClient.SessionID;
aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
AgentWearablesUpdatePacket.WearableDataBlock awb = new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType = (byte)0;
awb.AssetID = new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73");
awb.ItemID = LLUUID.Random();
aw.WearableData[0] = awb;
for(int i=1; i<13; i++) {
awb = new AgentWearablesUpdatePacket.WearableDataBlock();
awb.WearableType = (byte)i;
awb.AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
awb.ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
aw.WearableData[i] = awb;
}
ControllingClient.OutPacket(aw);
}
public void SendRegionHandshake(World RegionInfo) {
OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
RegionHandshakePacket handshake = new RegionHandshakePacket();
OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionhandshake() - Filling in RegionHandshake details");
handshake.RegionInfo.BillableFactor = 0;
handshake.RegionInfo.IsEstateManager = false;
handshake.RegionInfo.TerrainHeightRange00 = 60;
handshake.RegionInfo.TerrainHeightRange01 = 60;
handshake.RegionInfo.TerrainHeightRange10 = 60;
handshake.RegionInfo.TerrainHeightRange11 = 60;
handshake.RegionInfo.TerrainStartHeight00 = 10;
handshake.RegionInfo.TerrainStartHeight01 = 10;
handshake.RegionInfo.TerrainStartHeight10 = 10;
handshake.RegionInfo.TerrainStartHeight11 = 10;
handshake.RegionInfo.SimAccess = 13;
handshake.RegionInfo.WaterHeight = 20.0f;
handshake.RegionInfo.RegionFlags = 72458694; // TODO: WTF sirs? Use an enum!
handshake.RegionInfo.SimName = _enc.GetBytes(OpenSim_Main.cfg.RegionName + "\0");
handshake.RegionInfo.SimOwner = new LLUUID("00000000-0000-0000-0000-000000000000");
handshake.RegionInfo.TerrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
handshake.RegionInfo.TerrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3");
handshake.RegionInfo.TerrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
handshake.RegionInfo.TerrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
handshake.RegionInfo.TerrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
handshake.RegionInfo.TerrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
handshake.RegionInfo.TerrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
handshake.RegionInfo.TerrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
handshake.RegionInfo.CacheID = new LLUUID("545ec0a5-5751-1026-8a0b-216e38a7ab37");
OpenSim_Main.localcons.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
this.ControllingClient.OutPacket(handshake);
}
public void HandleAgentUpdate(AgentUpdatePacket update) {
lock(this) {
this.CurrentKeyMask = update.AgentData.ControlFlags;
this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z);
this.needupdate = true;
}
}
}
}

View File

@ -1,65 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Axiom.MathLib;
using libsecondlife;
using OpenSim.types;
using libsecondlife.Packets;
namespace OpenSim.world
{
public class Entity
{
protected libsecondlife.LLUUID uuid;
protected uint localid;
public LLVector3 position;
public LLVector3 velocity;
protected Quaternion rotation;
protected string name;
protected List<Entity> children;
public bool needupdate;
public Entity()
{
uuid = new libsecondlife.LLUUID();
localid = 8880000 + (OpenSim_Main.local_world._localNumber++); // FIXME - race condition!
position = new LLVector3();
velocity = new LLVector3();
rotation = new Quaternion();
name = "(basic entity)";
children = new List<Entity>();
}
public virtual void update() {
// Do any per-frame updates needed that are applicable to every type of entity
foreach (Entity child in children)
{
if(child.needupdate)
child.update();
}
this.needupdate=false;
}
public virtual ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateTerseBlock() {
return null;
}
public virtual string getName()
{
return name;
}
public virtual Mesh getMesh()
{
Mesh mesh = new Mesh();
foreach (Entity child in children)
{
mesh += child.getMesh();
}
return mesh;
}
}
}

View File

@ -1,122 +0,0 @@
using System;
namespace libsecondlife
{
public class HeightmapGenHills
{
private Random Rand = new Random();
private int NumHills;
private float HillMin;
private float HillMax;
private bool Island;
private float[] heightmap;
public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island)
{
NumHills = numHills;
HillMin = hillMin;
HillMax = hillMax;
Island = island;
heightmap = new float[256 * 256];
for (int i = 0; i < numHills; i++)
{
AddHill();
}
Normalize();
return heightmap;
}
private void AddHill()
{
float x, y;
float radius = RandomRange(HillMin, HillMax);
if (Island)
{
// Which direction from the center of the map the hill is placed
float theta = RandomRange(0, 6.28f);
// How far from the center of the map to place the hill. The radius
// is subtracted from the range to prevent any part of the hill from
// reaching the edge of the map
float distance = RandomRange(radius / 2.0f, 128.0f - radius);
x = 128.0f + (float)Math.Cos(theta) * distance;
y = 128.0f + (float)Math.Sin(theta) * distance;
}
else
{
x = RandomRange(-radius, 256.0f + radius);
y = RandomRange(-radius, 256.0f + radius);
}
float radiusSq = radius * radius;
float distSq;
float height;
int xMin = (int)(x - radius) - 1;
int xMax = (int)(x + radius) + 1;
if (xMin < 0) xMin = 0;
if (xMax > 255) xMax = 255;
int yMin = (int)(y - radius) - 1;
int yMax = (int)(y + radius) + 1;
if (yMin < 0) yMin = 0;
if (yMax > 255) yMax = 255;
// Loop through each affected cell and determine the height at that point
for (int v = yMin; v <= yMax; ++v)
{
float fv = (float)v;
for (int h = xMin; h <= xMax; ++h)
{
float fh = (float)h;
// Determine how far from the center of this hill this point is
distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv);
height = radiusSq - distSq;
// Don't add negative hill values
if (height > 0.0f) heightmap[h + v * 256] += height;
}
}
}
private void Normalize()
{
float min = heightmap[0];
float max = heightmap[0];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 256; y++)
{
if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256];
if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256];
}
}
// Avoid a rare divide by zero
if (min != max)
{
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 256; y++)
{
heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin);
}
}
}
}
private float RandomRange(float min, float max)
{
return (float)Rand.NextDouble() * (max - min) + min;
}
}
}

View File

@ -1,32 +0,0 @@
using System;
using System.Threading;
using libsecondlife;
using libsecondlife.Packets;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.world
{
public class PhysicsEngine
{
public PhysicsEngine() {
}
public void Startup() {
OpenSim_Main.localcons.WriteLine("PhysicsEngine.cs:Startup() - DOING NOTHING, DUMMY FUNCTION!");
}
public void DoStuff(World simworld) {
foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys)
{
simworld.Entities[UUID].position += simworld.Entities[UUID].velocity;
simworld.Entities[UUID].position.Z = simworld.LandMap[(int)simworld.Entities[UUID].position.Y * 256 + (int)simworld.Entities[UUID].position.X]+1;
if(simworld.Entities[UUID].position.X<0) simworld.Entities[UUID].position.X=0;
if(simworld.Entities[UUID].position.Y<0) simworld.Entities[UUID].position.Y=0;
if(simworld.Entities[UUID].position.X>255) simworld.Entities[UUID].position.X=255;
if(simworld.Entities[UUID].position.Y>255) simworld.Entities[UUID].position.Y=255;
}
}
}
}

View File

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.types;
namespace OpenSim.world
{
public class Primitive : Entity
{
protected float mesh_cutbegin;
protected float mesh_cutend;
public Primitive()
{
mesh_cutbegin = 0.0f;
mesh_cutend = 1.0f;
}
public override Mesh getMesh()
{
Mesh mesh = new Mesh();
Triangle tri = new Triangle(
new Axiom.MathLib.Vector3(0.0f, 1.0f, 1.0f),
new Axiom.MathLib.Vector3(1.0f, 0.0f, 1.0f),
new Axiom.MathLib.Vector3(1.0f, 1.0f, 0.0f));
mesh.AddTri(tri);
mesh += base.getMesh();
return mesh;
}
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.world
{
public class ScriptEngine
{
public ScriptEngine(World env)
{
}
public void LoadScript()
{
}
}
}

View File

@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.world
{
public class SurfacePatch
{
public float[] HeightMap;
public SurfacePatch() {
HeightMap = new float[16*16];
int xinc;
int yinc;
for(xinc=0; xinc<16; xinc++) for(yinc=0; yinc<16; yinc++) {
HeightMap[xinc+(yinc*16)]=100.0f;
}
}
}
}

View File

@ -1,112 +0,0 @@
using System;
using System.Threading;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.world
{
public class World
{
public Dictionary<libsecondlife.LLUUID, Entity> Entities;
public float[] LandMap;
public ScriptEngine Scripts;
public uint _localNumber = 0;
public PhysicsEngine physics;
private libsecondlife.TerrainManager TerrainManager;
private Random Rand = new Random();
public World()
{
OpenSim_Main.localcons.WriteLine("World.cs - creating new entitities instance");
Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
OpenSim_Main.localcons.WriteLine("World.cs - creating LandMap");
TerrainManager = new TerrainManager(new SecondLife());
}
public void InitLoop()
{
OpenSim_Main.localcons.WriteLine("World.cs:StartLoop() - Initialising physics");
this.physics = new PhysicsEngine();
physics.Startup();
}
public void DoStuff()
{
lock (this)
{
physics.DoStuff(this);
this.Update();
}
}
public void Update()
{
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
if (Entities[UUID].needupdate)
{
Entities[UUID].update();
if (Entities[UUID] is Avatar)
{
Avatar avatar = (Avatar)Entities[UUID];
if ((avatar.oldpos != avatar.position) || (avatar.oldvel != avatar.velocity) || avatar.walking)
{
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock();
foreach (OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values)
{
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
terse.RegionData.TimeDilation = 0;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
client.OutPacket(terse);
}
}
}
}
}
}
public void SendLayerData(OpenSimClient RemoteClient)
{
int[] patches = new int[4];
for (int y = 0; y < 16; y++)
{
for (int x = 0; x < 16; x = x + 4)
{
patches[0] = x + 0 + y * 16;
patches[1] = x + 1 + y * 16;
patches[2] = x + 2 + y * 16;
patches[3] = x + 3 + y * 16;
Packet layerpack = TerrainManager.CreateLandPacket(LandMap, patches);
RemoteClient.OutPacket(layerpack);
}
}
}
public void AddViewerAgent(OpenSimClient AgentClient)
{
OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
Avatar NewAvatar = new Avatar(AgentClient);
OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
this.Entities.Add(AgentClient.AgentID, NewAvatar);
OpenSim_Main.localcons.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
NewAvatar.SendRegionHandshake(this);
this.Update(); // will work for now, but needs to be optimised so we don't update everything in the sim for each new user
}
public bool Backup()
{
/* TODO: Save the current world entities state. */
return false;
}
}
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.world.scripting
{
public interface IScriptHost {
bool Register(IScript iscript);
}
public interface IScript
{
string Name{get;set;}
IScriptHost Host{get;set;}
void Show();
}
}