Copied main OpenSim code in order to integrate CAPS and ogs-cs auth

ogs-cs
gareth 2007-03-13 16:55:30 +00:00
parent 8a2bda947a
commit 04ff29341a
98 changed files with 8634 additions and 0 deletions

134
opensim/OGS.sql Normal file
View File

@ -0,0 +1,134 @@
-- 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);

Binary file not shown.

BIN
opensim/bin/Db4objects.Db4o.dll Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
opensim/bin/libsecondlife.dll Executable file

Binary file not shown.

BIN
opensim/bin/log4net.dll Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

9
opensim/genvers.sh Executable file
View File

@ -0,0 +1,9 @@
#!/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

@ -0,0 +1,105 @@
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

@ -0,0 +1,52 @@
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

@ -0,0 +1,16 @@
<?
// 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

@ -0,0 +1,25 @@
<?
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

@ -0,0 +1,9 @@
<?
// 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

@ -0,0 +1,7 @@
<?
// 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

@ -0,0 +1,42 @@
<?
// 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

@ -0,0 +1,828 @@
<?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

@ -0,0 +1,14 @@
<?
// 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

@ -0,0 +1,176 @@
<?
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

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

View File

@ -0,0 +1,85 @@
<?
// 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;
}
?>

170
opensim/ogs/login/index.php Normal file
View File

@ -0,0 +1,170 @@
<?
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

@ -0,0 +1,11 @@
<?
// 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";
?>

81
opensim/opensim.build Normal file
View File

@ -0,0 +1,81 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>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>
<nant>
<buildfiles>
<include name="src/GridInterfaces/default.build" />
<include name="src/ServerConsole/default.build" />
<include name="src/LocalServers/default.build" />
<include name="src/RemoteServers/default.build" />
<include name="src/physics/default.build" />
<include name="src/physics/plugins/default.build" />
<include name="src/LocalStorage/default.build" />
</buildfiles>
</nant>
<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" />
<include name="ServerConsole.dll" />
<include name="GridInterfaces.dll" />
<include name="PhysicsManager.dll" />
</references>
<sources basedir="src/">
<include name="*.cs" />
<include name="types/*.cs" />
<include name="world/*.cs" />
<include name="GridServers/*.cs" />
<include name="Assets/*.cs" />
</sources>
</csc>
<nant>
<buildfiles>
<include name="src/Config/default.build" />
</buildfiles>
</nant>
</target>
</project>

View File

@ -0,0 +1,436 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using System.Threading;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim;
using OpenSim.GridServers;
namespace OpenSim.Assets
{
/// <summary>
/// Manages local cache of assets and their sending to viewers.
/// </summary>
public class AssetCache : IAssetReceiver
{
public Dictionary<libsecondlife.LLUUID, AssetInfo> Assets;
public Dictionary<libsecondlife.LLUUID, TextureImage> Textures;
public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers
public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent
public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server
public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server
private IAssetServer _assetServer;
private Thread _assetCacheThread;
/// <summary>
///
/// </summary>
public AssetCache( IAssetServer assetServer)
{
_assetServer = assetServer;
_assetServer.SetReceiver(this);
Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo> ();
Textures = new Dictionary<libsecondlife.LLUUID, TextureImage> ();
this._assetCacheThread = new Thread( new ThreadStart(RunAssetManager));
this._assetCacheThread.IsBackground = true;
this._assetCacheThread.Start();
}
/// <summary>
///
/// </summary>
private void RunAssetManager()
{
this.ProcessAssetQueue();
this.ProcessTextureQueue();
Thread.Sleep(100);
}
/// <summary>
///
/// </summary>
private void ProcessTextureQueue()
{
if(this.TextureRequests.Count == 0)
{
//no requests waiting
return;
}
int num;
if(this.TextureRequests.Count < 5)
{
//lower than 5 so do all of them
num = this.TextureRequests.Count;
}
else
{
num=5;
}
AssetRequest req;
for(int i = 0; i < num; i++)
{
req=(AssetRequest)this.TextureRequests[i];
if(req.PacketCounter == 0)
{
//first time for this request so send imagedata packet
if(req.NumPackets == 1)
{
//only one packet so send whole file
ImageDataPacket im = new ImageDataPacket();
im.ImageID.Packets = 1;
im.ImageID.ID = req.ImageInfo.FullID;
im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
im.ImageData.Data = req.ImageInfo.Data;
im.ImageID.Codec = 2;
req.RequestUser.OutPacket(im);
req.PacketCounter++;
//req.ImageInfo.l= time;
//System.Console.WriteLine("sent texture: "+req.image_info.FullID);
}
else
{
//more than one packet so split file up
ImageDataPacket im = new ImageDataPacket();
im.ImageID.Packets = (ushort)req.NumPackets;
im.ImageID.ID = req.ImageInfo.FullID;
im.ImageID.Size = (uint)req.ImageInfo.Data.Length;
im.ImageData.Data = new byte[600];
Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600);
im.ImageID.Codec = 2;
req.RequestUser.OutPacket(im);
req.PacketCounter++;
//req.ImageInfo.last_used = time;
//System.Console.WriteLine("sent first packet of texture:
}
}
else
{
//send imagepacket
//more than one packet so split file up
ImagePacketPacket im = new ImagePacketPacket();
im.ImageID.Packet = (ushort)req.PacketCounter;
im.ImageID.ID = req.ImageInfo.FullID;
int size = req.ImageInfo.Data.Length - 600 - 1000*(req.PacketCounter - 1);
if(size > 1000) size = 1000;
im.ImageData.Data = new byte[size];
Array.Copy(req.ImageInfo.Data, 600 + 1000*(req.PacketCounter - 1), im.ImageData.Data, 0, size);
req.RequestUser.OutPacket(im);
req.PacketCounter++;
//req.ImageInfo.last_used = time;
//System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
}
}
//remove requests that have been completed
int count = 0;
for(int i = 0; i < num; i++)
{
req=(AssetRequest)this.TextureRequests[count];
if(req.PacketCounter == req.NumPackets)
{
this.TextureRequests.Remove(req);
}
else
{
count++;
}
}
}
public void AssetReceived(AssetBase asset, bool IsTexture)
{
//check if it is a texture or not
//then add to the correct cache list
//then check for waiting requests for this asset/texture (in the Requested lists)
//and move those requests into the Requests list.
if(IsTexture)
{
TextureImage image = new TextureImage(asset);
this.Textures.Add(image.FullID, image);
if(this.RequestedTextures.ContainsKey(image.FullID))
{
AssetRequest req = this.RequestedTextures[image.FullID];
req.ImageInfo = image;
this.RequestedTextures.Remove(image.FullID);
this.TextureRequests.Add(req);
}
}
else
{
AssetInfo assetInf = new AssetInfo(asset);
this.Assets.Add(assetInf.FullID, assetInf);
if(this.RequestedAssets.ContainsKey(assetInf.FullID))
{
AssetRequest req = this.RequestedAssets[assetInf.FullID];
req.AssetInf = assetInf;
this.RequestedAssets.Remove(assetInf.FullID);
this.AssetRequests.Add(req);
}
}
}
public void AssetNotFound(AssetBase asset)
{
//the asset server had no knowledge of requested asset
}
#region Assets
/// <summary>
///
/// </summary>
/// <param name="userInfo"></param>
/// <param name="transferRequest"></param>
public void AddAssetRequest(OpenSimClient userInfo, TransferRequestPacket transferRequest)
{
LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0);
//check to see if asset is in local cache, if not we need to request it from asset server.
if(!this.Assets.ContainsKey(requestID))
{
//not found asset
// so request from asset server
AssetRequest request = new AssetRequest();
request.RequestUser = userInfo;
request.RequestAssetID = requestID;
request.TransferRequestID = transferRequest.TransferInfo.TransferID;
this.RequestedAssets.Add(requestID,request);
this._assetServer.RequestAsset(requestID, false);
return;
}
//it is in our cache
AssetInfo asset = this.Assets[requestID];
//work out how many packets it should be sent in
// and add to the AssetRequests list
AssetRequest req = new AssetRequest();
req.RequestUser = userInfo;
req.RequestAssetID = requestID;
req.TransferRequestID = transferRequest.TransferInfo.TransferID;
req.AssetInf = asset;
if(asset.Data.LongLength>600)
{
//over 600 bytes so split up file
req.NumPackets = 1 + (int)(asset.Data.Length-600+999)/1000;
}
else
{
req.NumPackets = 1;
}
this.AssetRequests.Add(req);
}
/// <summary>
///
/// </summary>
private void ProcessAssetQueue()
{
if(this.AssetRequests.Count == 0)
{
//no requests waiting
return;
}
int num;
if(this.AssetRequests.Count < 5)
{
//lower than 5 so do all of them
num = this.AssetRequests.Count;
}
else
{
num=5;
}
AssetRequest req;
for(int i = 0; i < num; i++)
{
req=(AssetRequest)this.AssetRequests[i];
TransferInfoPacket Transfer = new TransferInfoPacket();
Transfer.TransferInfo.ChannelType = 2;
Transfer.TransferInfo.Status = 0;
Transfer.TransferInfo.TargetType = 0;
Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes();
Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length;
Transfer.TransferInfo.TransferID = req.TransferRequestID;
req.RequestUser.OutPacket(Transfer);
if(req.NumPackets == 1)
{
TransferPacketPacket TransferPacket = new TransferPacketPacket();
TransferPacket.TransferData.Packet = 0;
TransferPacket.TransferData.ChannelType = 2;
TransferPacket.TransferData.TransferID=req.TransferRequestID;
TransferPacket.TransferData.Data = req.AssetInf.Data;
TransferPacket.TransferData.Status = 1;
req.RequestUser.OutPacket(TransferPacket);
}
else
{
//more than one packet so split file up , for now it can't be bigger than 2000 bytes
TransferPacketPacket TransferPacket = new TransferPacketPacket();
TransferPacket.TransferData.Packet = 0;
TransferPacket.TransferData.ChannelType = 2;
TransferPacket.TransferData.TransferID=req.TransferRequestID;
byte[] chunk = new byte[1000];
Array.Copy(req.AssetInf.Data,chunk,1000);
TransferPacket.TransferData.Data = chunk;
TransferPacket.TransferData.Status = 0;
req.RequestUser.OutPacket(TransferPacket);
TransferPacket = new TransferPacketPacket();
TransferPacket.TransferData.Packet = 1;
TransferPacket.TransferData.ChannelType = 2;
TransferPacket.TransferData.TransferID = req.TransferRequestID;
byte[] chunk1 = new byte[(req.AssetInf.Data.Length-1000)];
Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length);
TransferPacket.TransferData.Data = chunk1;
TransferPacket.TransferData.Status = 1;
req.RequestUser.OutPacket(TransferPacket);
}
}
//remove requests that have been completed
for(int i = 0; i < num; i++)
{
this.AssetRequests.RemoveAt(0);
}
}
#endregion
#region Textures
/// <summary>
///
/// </summary>
/// <param name="userInfo"></param>
/// <param name="imageID"></param>
public void AddTextureRequest(OpenSimClient userInfo, LLUUID imageID)
{
//check to see if texture is in local cache, if not request from asset server
if(!this.Textures.ContainsKey(imageID))
{
//not is cache so request from asset server
AssetRequest request = new AssetRequest();
request.RequestUser = userInfo;
request.RequestAssetID = imageID;
request.IsTextureRequest = true;
this.RequestedTextures.Add(imageID, request);
this._assetServer.RequestAsset(imageID, true);
return;
}
TextureImage imag = this.Textures[imageID];
AssetRequest req = new AssetRequest();
req.RequestUser = userInfo;
req.RequestAssetID = imageID;
req.IsTextureRequest = true;
req.ImageInfo = imag;
if(imag.Data.LongLength>600)
{
//over 600 bytes so split up file
req.NumPackets = 1 + (int)(imag.Data.Length-600+999)/1000;
}
else
{
req.NumPackets = 1;
}
this.TextureRequests.Add(req);
}
#endregion
}
public class AssetRequest
{
public OpenSimClient RequestUser;
public LLUUID RequestAssetID;
public AssetInfo AssetInf;
public TextureImage ImageInfo;
public LLUUID TransferRequestID;
public long DataPointer = 0;
public int NumPackets = 0;
public int PacketCounter = 0;
public bool IsTextureRequest;
//public bool AssetInCache;
//public int TimeRequested;
public AssetRequest()
{
}
}
public class AssetInfo : AssetBase
{
public AssetInfo()
{
}
public AssetInfo(AssetBase aBase)
{
Data= aBase.Data;
FullID = aBase.FullID;
Type = aBase.Type;
InvType = aBase.InvType;
Name= aBase.Name;
Description = aBase.Description;
}
}
public class TextureImage : AssetBase
{
public TextureImage()
{
}
public TextureImage(AssetBase aBase)
{
Data= aBase.Data;
FullID = aBase.FullID;
Type = aBase.Type;
InvType = aBase.InvType;
Name= aBase.Name;
Description = aBase.Description;
}
}
}

74
opensim/src/Config.cs Normal file
View File

@ -0,0 +1,74 @@
/*
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 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 abstract class SimConfig
{
public string RegionName;
public uint RegionLocX;
public uint RegionLocY;
public ulong RegionHandle;
public int IPListenPort;
public string IPListenAddr;
public string AssetURL;
public string AssetSendKey;
public string GridURL;
public string GridSendKey;
public abstract void InitConfig();
public abstract void LoadFromGrid();
public abstract World LoadWorld();
public abstract void SaveMap();
}
public interface ISimConfig
{
SimConfig GetConfigObject();
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-simconfig")]
[assembly: AssemblyDescriptionAttribute("The default configuration handler")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,173 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using OpenSim;
using OpenSim.world;
using Db4objects.Db4o;
namespace Db40SimConfig
{
public class Db40ConfigPlugin: ISimConfig
{
public SimConfig GetConfigObject()
{
ServerConsole.MainConsole.Instance.WriteLine("Loading Db40Config dll");
return ( new DbSimConfig());
}
}
public class DbSimConfig :SimConfig
{
private IObjectContainer db;
public void LoadDefaults() {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
this.RegionName=ServerConsole.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ","OpenSim test");
this.RegionLocX=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ","997"));
this.RegionLocY=(uint)Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ","996"));
this.IPListenPort=Convert.ToInt32(ServerConsole.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ","9000"));
this.IPListenAddr=ServerConsole.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ","127.0.0.1");
if(!OpenSim_Main.sim.sandbox)
{
this.AssetURL=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server URL: ");
this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Asset server key: ");
this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid server URL: ");
this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Grid server key: ");
}
this.RegionHandle = Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
}
public override void InitConfig() {
try {
db = Db4oFactory.OpenFile("opensim.yap");
IObjectSet result = db.Get(typeof(DbSimConfig));
if(result.Count==1) {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Found a SimConfig object in the local database, loading");
foreach (DbSimConfig cfg in result) {
this.RegionName = cfg.RegionName;
this.RegionLocX = cfg.RegionLocX;
this.RegionLocY = cfg.RegionLocY;
this.RegionHandle = Util.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 {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
LoadDefaults();
ServerConsole.MainConsole.Instance.WriteLine("Writing out default settings to local database");
db.Set(this);
}
} catch(Exception e) {
db.Close();
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured");
ServerConsole.MainConsole.Instance.WriteLine(e.ToString());
}
ServerConsole.MainConsole.Instance.WriteLine("Sim settings loaded:");
ServerConsole.MainConsole.Instance.WriteLine("Name: " + this.RegionName);
ServerConsole.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
ServerConsole.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString());
ServerConsole.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
ServerConsole.MainConsole.Instance.WriteLine("Sandbox Mode? " + OpenSim_Main.sim.sandbox.ToString());
ServerConsole.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL);
ServerConsole.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey);
ServerConsole.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL);
ServerConsole.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey);
}
public override World LoadWorld()
{
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Loading world....");
World blank = new World();
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Looking for a heightmap in local DB");
IObjectSet world_result = db.Get(typeof(MapStorage));
if(world_result.Count>0) {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Found a heightmap in local database, loading");
MapStorage map=(MapStorage)world_result.Next();
blank.LandMap = map.Map;
} else {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - No heightmap found, generating new one");
HeightmapGenHills hills = new HeightmapGenHills();
blank.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - Saving heightmap to local database");
MapStorage map= new MapStorage();
map.Map = blank.LandMap;
db.Set(map);
db.Commit();
}
return blank;
}
public override void SaveMap()
{
IObjectSet world_result = db.Get(typeof(MapStorage));
if(world_result.Count>0) {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadWorld() - updating saved copy of heightmap in local database");
MapStorage map=(MapStorage)world_result.Next();
db.Delete(map);
}
MapStorage map1= new MapStorage();
map1.Map = OpenSim_Main.local_world.LandMap;
db.Set(map1);
db.Commit();
}
public override void LoadFromGrid() {
ServerConsole.MainConsole.Instance.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
// TODO: Make this crap work
/* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login");
WebResponse GridResponse = GridLogin.GetResponse();
byte[] idata = new byte[(int)GridResponse.ContentLength];
BinaryReader br = new BinaryReader(GridResponse.GetResponseStream());
br.Close();
GridResponse.Close();
*/
}
public void Shutdown() {
db.Close();
}
}
public class MapStorage
{
public float[] Map;
public MapStorage()
{
}
}
}

View File

@ -0,0 +1,53 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>SimConfig</RootNamespace>
<AssemblyName>SimConfig</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B063760D-DB8D-4F64-B6FE-335FAD1E650A}</ProjectGuid>
</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\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="Db4objects.Db4o">
<HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Db4SimConfig.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj">
<Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
<ProjectReference Include="..\..\Second-server.csproj">
<Project>{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}</Project>
<Name>Second-server</Name>
</ProjectReference>
<ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj">
<Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project>
<Name>GridInterfaces</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimConfig", "SimConfig.csproj", "{B063760D-DB8D-4F64-B6FE-335FAD1E650A}"
EndProject
Global
EndGlobal

View File

@ -0,0 +1,52 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../bin/SimConfig.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="SimConfig/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-simconfig" />
<attribute type="AssemblyDescriptionAttribute" value="The default configuration handler" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/SimConfig.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../bin/" failonempty="true">
<include name="System" />
<include name="System.Data" />
<include name="System.Xml" />
<include name="ServerConsole.dll" />
<include name="OpenSim.exe" />
<include name="Db4objects.Db4o.dll" />
</references>
<sources basedir="SimConfig/">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-gridinterfaces")]
[assembly: AssemblyDescriptionAttribute("Definitions for OGS interface")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,41 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>GridInterfaces</RootNamespace>
<AssemblyName>GridInterfaces</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="libsecondlife">
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="IAssetServer.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="IGridServer.cs" />
<Compile Include="ILocalStorage.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridInterfaces", "GridInterfaces.csproj", "{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.Build.0 = Release|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
using libsecondlife;
namespace OpenSim.GridServers
{
/// <summary>
/// Description of IAssetServer.
/// </summary>
public interface IAssetServer
{
void SetReceiver(IAssetReceiver receiver);
void RequestAsset(LLUUID assetID, bool isTexture);
void UpdateAsset(AssetBase asset);
void UploadNewAsset(AssetBase asset);
void SetServerInfo(string ServerUrl, string ServerKey);
}
// could change to delegate?
public interface IAssetReceiver
{
void AssetReceived(AssetBase asset, bool IsTexture);
void AssetNotFound(AssetBase asset);
}
public struct ARequest
{
public LLUUID AssetID;
public bool IsTexture;
}
public class AssetBase
{
public byte[] Data;
public LLUUID FullID;
public sbyte Type;
public sbyte InvType;
public string Name;
public string Description;
public AssetBase()
{
}
}
public interface IAssetPlugin
{
IAssetServer GetAssetServer();
}
}

View File

@ -0,0 +1,94 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using System.Net;
using System.Net.Sockets;
using System.IO;
using libsecondlife;
namespace OpenSim.GridServers
{
/// <summary>
/// Handles connection to Grid Servers.
/// also Sim to Sim connections?
/// </summary>
public interface IGridServer
{
bool RequestConnection();
UUIDBlock RequestUUIDBlock();
void RequestNeighbours(); //should return a array of neighbouring regions
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
void SetServerInfo(string ServerUrl, string ServerKey);
void AddNewSession(Login session); // only used by local version of grid server
// and didn't use to be part of this interface until we put this in a dll
}
public struct UUIDBlock
{
public LLUUID BlockStart;
public LLUUID BlockEnd;
}
public class AuthenticateResponse
{
public bool Authorised;
public Login LoginInfo;
public AuthenticateResponse()
{
}
}
public class Login
{
public string First = "Test";
public string Last = "User";
public LLUUID Agent;
public LLUUID Session;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
public Login()
{
}
}
public interface IGridPlugin
{
IGridServer GetGridServer();
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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 libsecondlife;
namespace GridInterfaces
{
/// <summary>
/// ILocalStorage. Really hacked together right now needs cleaning up
/// </summary>
public interface ILocalStorage
{
void StorePrim(PrimData prim);
void RemovePrim(LLUUID primID);
void LoadPrimitives(ILocalStorageReceiver receiver);
void ShutDown();
}
public interface ILocalStorageReceiver
{
void PrimFromStorage(PrimData prim);
}
public class PrimData
{
public LLUUID OwnerID;
public byte PCode;
public byte PathBegin;
public byte PathEnd;
public byte PathScaleX;
public byte PathScaleY;
public byte PathShearX;
public byte PathShearY;
public sbyte PathSkew;
public byte ProfileBegin;
public byte ProfileEnd;
public LLVector3 Scale;
public byte PathCurve;
public byte ProfileCurve;
public uint ParentID=0;
public byte ProfileHollow;
public sbyte PathRadiusOffset;
public byte PathRevolutions;
public sbyte PathTaperX;
public sbyte PathTaperY;
public sbyte PathTwist;
public sbyte PathTwistBegin;
//following only used during prim storage
public LLVector3 Position;
public LLQuaternion Rotation;
public uint LocalID;
public LLUUID FullID;
public PrimData()
{
}
}
}

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../../bin/GridInterfaces.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="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-gridinterfaces" />
<attribute type="AssemblyDescriptionAttribute" value="Definitions for OGS interface" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/GridInterfaces.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../bin" failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="libsecondlife.dll" />
</references>
<sources basedir="./">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

View File

@ -0,0 +1,322 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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 Nwc.XmlRpc;
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
using libsecondlife;
using OpenSim;
namespace OpenSim.GridServers
{
/// <summary>
/// When running in local (default) mode , handles client logins.
/// </summary>
public class LoginServer
{
public LoginServer(IGridServer gridServer)
{
_gridServer = gridServer;
}
private Login _login;
private IGridServer _gridServer;
private ushort _loginPort = 8080;
public IPAddress clientAddress = IPAddress.Loopback;
public IPAddress remoteAddress = IPAddress.Any;
private Socket loginServer;
private Random RandomClass = new Random();
private int NumClients;
private string _defaultResponse;
private string _mpasswd;
private bool _needPasswd=false;
// InitializeLogin: initialize the login
private void InitializeLogin() {
loginServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
loginServer.Bind(new IPEndPoint(remoteAddress, _loginPort));
loginServer.Listen(1);
this._needPasswd=false;
//read in default response string
StreamReader SR;
string lines;
SR=File.OpenText("new-login.dat");
//lines=SR.ReadLine();
while(!SR.EndOfStream)
{
lines = SR.ReadLine();
_defaultResponse += lines;
//lines = SR.ReadLine();
}
SR.Close();
this._mpasswd = EncodePassword("testpass");
}
public void Startup()
{
this.InitializeLogin();
Thread runLoginProxy = new Thread(new ThreadStart(RunLogin));
runLoginProxy.IsBackground = true;
runLoginProxy.Start();
}
private void RunLogin()
{
Console.WriteLine("Starting Login Server");
try
{
for (;;)
{
Socket client = loginServer.Accept();
IPEndPoint clientEndPoint = (IPEndPoint)client.RemoteEndPoint;
NetworkStream networkStream = new NetworkStream(client);
StreamReader networkReader = new StreamReader(networkStream);
StreamWriter networkWriter = new StreamWriter(networkStream);
try
{
LoginRequest(networkReader, networkWriter);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
networkWriter.Close();
networkReader.Close();
networkStream.Close();
client.Close();
// send any packets queued for injection
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
// ProxyLogin: proxy a login request
private void LoginRequest(StreamReader reader, StreamWriter writer)
{
lock(this)
{
string line;
int contentLength = 0;
// read HTTP header
do
{
// read one line of the header
line = reader.ReadLine();
// check for premature EOF
if (line == null)
throw new Exception("EOF in client HTTP header");
// look for Content-Length
Match match = (new Regex(@"Content-Length: (\d+)$")).Match(line);
if (match.Success)
contentLength = Convert.ToInt32(match.Groups[1].Captures[0].ToString());
} while (line != "");
// read the HTTP body into a buffer
char[] content = new char[contentLength];
reader.Read(content, 0, contentLength);
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
if(request.MethodName == "login_to_simulator")
{
Hashtable requestData = (Hashtable)request.Params[0];
string first;
string last;
string passwd;
LLUUID Agent;
LLUUID Session;
//get login name
if(requestData.Contains("first"))
{
first = (string)requestData["first"];
}
else
{
first = "test";
}
if(requestData.Contains("last"))
{
last = (string)requestData["last"];
}
else
{
last = "User"+NumClients.ToString();
}
if(requestData.Contains("passwd"))
{
passwd = (string)requestData["passwd"];
}
else
{
passwd = "notfound";
}
if( !Authenticate(first, last, passwd))
{
// Fail miserably
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
writer.WriteLine();
return;
}
NumClients++;
//create a agent and session LLUUID
Agent = GetAgentId( first, last );
int SessionRand = this.RandomClass.Next(1,999);
Session = new LLUUID("aaaabbbb-0200-"+SessionRand.ToString("0000")+"-8664-58f53e442797");
XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
Hashtable responseData = (Hashtable)response.Value;
responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort;
responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr;
responseData["agent_id"] = Agent.ToStringHyphenated();
responseData["session_id"] = Session.ToStringHyphenated();
ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"];
Hashtable Inventory1 = (Hashtable)InventoryList[0];
Hashtable Inventory2 = (Hashtable)InventoryList[1];
LLUUID BaseFolderID = LLUUID.Random();
LLUUID InventoryFolderID = LLUUID.Random();
Inventory2["name"] = "Base";
Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
Inventory2["type_default"] =6;
Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"];
Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
CustomiseLoginResponse( responseData, first, last );
this._login = new Login();
//copy data to login object
_login.First = first;
_login.Last = last;
_login.Agent = Agent;
_login.Session = Session;
_login.BaseFolder = BaseFolderID;
_login.InventoryFolder = InventoryFolderID;
//working on local computer so lets add to the gridserver's list of sessions
this._gridServer.AddNewSession(_login);
// forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK");
writer.WriteLine("Content-type: text/xml");
writer.WriteLine();
XmlTextWriter responseWriter = new XmlTextWriter(writer);
XmlRpcResponseSerializer.Singleton.Serialize(responseWriter, response);
responseWriter.Close();
}
else
{
writer.WriteLine("HTTP/1.0 403 Authentication Forbidden");
writer.WriteLine();
}
}
}
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )
{
}
protected virtual LLUUID GetAgentId(string firstName, string lastName)
{
LLUUID Agent;
int AgentRand = this.RandomClass.Next(1,9999);
Agent = new LLUUID("99998888-0100-"+AgentRand.ToString("0000")+"-8ec1-0b1d5cd6aead");
return Agent;
}
protected virtual bool Authenticate(string first, string last, string passwd)
{
if(this._needPasswd)
{
//every user needs the password to login
string encodedPass = passwd.Remove(0,3); //remove $1$
if(encodedPass == this._mpasswd)
{
return true;
}
else
{
return false;
}
}
else
{
//do not need password to login
return true;
}
}
private static string EncodePassword(string passwd)
{
Byte[] originalBytes;
Byte[] encodedBytes;
MD5 md5;
md5 = new MD5CryptoServiceProvider();
originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
encodedBytes = md5.ComputeHash(originalBytes);
return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
}
}
}

View File

@ -0,0 +1,149 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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
{
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

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-localservers")]
[assembly: AssemblyDescriptionAttribute("local grid servers")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,205 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using System.Threading;
using OpenSim.GridServers;
using libsecondlife;
namespace LocalGridServers
{
/// <summary>
///
/// </summary>
///
public class LocalGridPlugin : IGridPlugin
{
public LocalGridPlugin()
{
}
public IGridServer GetGridServer()
{
return(new LocalGridServer());
}
}
public class LocalAssetPlugin : IAssetPlugin
{
public LocalAssetPlugin()
{
}
public IAssetServer GetAssetServer()
{
return(new LocalAssetServer());
}
}
public class LocalAssetServer : IAssetServer
{
private IAssetReceiver _receiver;
private BlockingQueue<ARequest> _assetRequests;
public LocalAssetServer()
{
this._assetRequests = new BlockingQueue<ARequest>();
ServerConsole.MainConsole.Instance.WriteLine("Local Asset Server class created");
}
public void SetReceiver(IAssetReceiver receiver)
{
this._receiver = receiver;
}
public void RequestAsset(LLUUID assetID, bool isTexture)
{
ARequest req = new ARequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
//this._assetRequests.Enqueue(req);
}
public void UpdateAsset(AssetBase asset)
{
}
public void UploadNewAsset(AssetBase asset)
{
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
}
private void RunRequests()
{
while(true)
{
}
}
}
public class LocalGridServer :IGridServer
{
public List<Login> Sessions = new List<Login>();
public LocalGridServer()
{
Sessions = new List<Login>();
ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created");
}
public bool RequestConnection()
{
return true;
}
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
//we are running local
AuthenticateResponse user = new AuthenticateResponse();
lock(this.Sessions)
{
for(int i = 0; i < Sessions.Count; i++)
{
if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
{
user.Authorised = true;
user.LoginInfo = Sessions[i];
}
}
}
return(user);
}
public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
return(true);
}
public UUIDBlock RequestUUIDBlock()
{
UUIDBlock uuidBlock = new UUIDBlock();
return(uuidBlock);
}
public void RequestNeighbours()
{
return;
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
}
/// <summary>
/// used by the local login server to inform us of new sessions
/// </summary>
/// <param name="session"></param>
public void AddNewSession(Login session)
{
lock(this.Sessions)
{
this.Sessions.Add(session);
}
}
}
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

@ -0,0 +1,49 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>LocalGridServers</RootNamespace>
<AssemblyName>LocalGridServers</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D7F0395B-FADC-4936-80A0-D95AACE92F62}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="libsecondlife">
<HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LocalGrid.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj">
<Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
<ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj">
<Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project>
<Name>GridInterfaces</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalGridServers", "LocalGridServers.csproj", "{D7F0395B-FADC-4936-80A0-D95AACE92F62}"
EndProject
Global
EndGlobal

View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../../bin/LocalGridServers.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="LocalGridServers/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-localservers" />
<attribute type="AssemblyDescriptionAttribute" value="local grid servers" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/LocalGridServers.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../bin" failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="libsecondlife.dll" />
<include name="GridInterfaces.dll" />
<include name="ServerConsole.dll" />
</references>
<sources basedir="LocalGridServers/">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-localstorage")]
[assembly: AssemblyDescriptionAttribute("The local storage handler")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,139 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using Db4objects.Db4o;
using Db4objects.Db4o.Query;
using libsecondlife;
using GridInterfaces;
namespace Db4LocalStorage
{
/// <summary>
///
/// </summary>
public class Db4LocalStorage : ILocalStorage
{
private IObjectContainer db;
public Db4LocalStorage()
{
try
{
db = Db4oFactory.OpenFile("localworld.yap");
ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage creation");
}
catch(Exception e)
{
db.Close();
ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage :Constructor - Exception occured");
ServerConsole.MainConsole.Instance.WriteLine(e.ToString());
}
}
public void StorePrim(PrimData prim)
{
IObjectSet result = db.Query(new UUIDQuery(prim.FullID));
if(result.Count>0)
{
//prim already in storage
//so update it
PrimData found = (PrimData) result.Next();
found.PathBegin = prim.PathBegin;
found.PathCurve= prim.PathCurve;
found.PathEnd = prim.PathEnd;
found.PathRadiusOffset = prim.PathRadiusOffset;
found.PathRevolutions = prim.PathRevolutions;
found.PathScaleX= prim.PathScaleX;
found.PathScaleY = prim.PathScaleY;
found.PathShearX = prim.PathShearX;
found.PathShearY = prim.PathShearY;
found.PathSkew = prim.PathSkew;
found.PathTaperX = prim.PathTaperX;
found.PathTaperY = prim.PathTaperY;
found.PathTwist = prim.PathTwist;
found.PathTwistBegin = prim.PathTwistBegin;
found.PCode = prim.PCode;
found.ProfileBegin = prim.ProfileBegin;
found.ProfileCurve = prim.ProfileCurve;
found.ProfileEnd = prim.ProfileEnd;
found.ProfileHollow = prim.ProfileHollow;
found.Position = prim.Position;
found.Rotation = prim.Rotation;
db.Set(found);
db.Commit();
}
else
{
//not in storage
db.Set(prim);
db.Commit();
}
}
public void RemovePrim(LLUUID primID)
{
IObjectSet result = db.Query(new UUIDQuery(primID));
if(result.Count>0)
{
PrimData found = (PrimData) result.Next();
db.Delete(found);
}
}
public void LoadPrimitives(ILocalStorageReceiver receiver)
{
IObjectSet result = db.Get(typeof(PrimData));
ServerConsole.MainConsole.Instance.WriteLine("Db4LocalStorage.cs: LoadPrimitives() - number of prims in storages is "+result.Count);
foreach (PrimData prim in result) {
receiver.PrimFromStorage(prim);
}
}
public void ShutDown()
{
db.Commit();
db.Close();
}
}
public class UUIDQuery : Predicate
{
private LLUUID _findID;
public UUIDQuery(LLUUID find)
{
_findID = find;
}
public bool Match(PrimData prim)
{
return (prim.FullID == _findID);
}
}
}

View File

@ -0,0 +1,53 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Db4LocalStorage</RootNamespace>
<AssemblyName>Db4LocalStorage</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{74784F23-B0FD-484C-82C1-96C0215733DC}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="libsecondlife">
<HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Db4objects.Db4o">
<HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Db4LocalStorage.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj">
<Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
<ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj">
<Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project>
<Name>GridInterfaces</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}"
EndProject
Global
EndGlobal

View File

@ -0,0 +1,53 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../bin/Db4LocalStorage.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="Db4LocalStorage/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-localstorage" />
<attribute type="AssemblyDescriptionAttribute" value="The local storage handler" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/Db4LocalStorage.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../bin/" failonempty="true">
<include name="System" />
<include name="System.Data" />
<include name="System.Xml" />
<include name="libsecondlife.dll" />
<include name="GridInterfaces.dll" />
<include name="ServerConsole.dll" />
<include name="Db4objects.Db4o.dll" />
</references>
<sources basedir="Db4LocalStorage/">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

334
opensim/src/Main.cs Normal file
View File

@ -0,0 +1,334 @@
/*
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.Timers;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.world;
using OpenSim.GridServers;
using OpenSim.Assets;
using ServerConsole;
using PhysicsSystem;
namespace OpenSim
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class OpenSim_Main
{
public static OpenSim_Main sim;
public static SimConfig cfg;
public static World local_world;
public static Grid gridServers;
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 AssetCache assetCache;
public DateTime startuptime;
public Dictionary<EndPoint, OpenSimClient> ClientThreads = new Dictionary<EndPoint, OpenSimClient>();
private PhysicsManager physManager;
private System.Timers.Timer timer1 = new System.Timers.Timer();
private string ConfigDll = "SimConfig.dll";
private string _physicsEngine = "PhysX";
public bool sandbox = false;
public bool loginserver = false;
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("OpenSim " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local,"",0);
sim = new OpenSim_Main();
sim.sandbox = false;
sim.loginserver = false;
sim._physicsEngine = "PhysX";
for (int i = 0; i < args.Length; i++)
{
if(args[i] == "-sandbox")
{
sim.sandbox = true;
}
if(args[i] == "-loginserver")
{
sim.loginserver = true;
}
if(args[i] == "-realphysx")
{
sim._physicsEngine = "RealPhysX";
OpenSim.world.Avatar.PhysicsEngineFlying = true;
}
}
OpenSim_Main.gridServers = new Grid();
if(sim.sandbox)
{
OpenSim_Main.gridServers.AssetDll = "LocalGridServers.dll";
OpenSim_Main.gridServers.GridDll = "LocalGridServers.dll";
OpenSim_Main.gridServers.LoadPlugins();
ServerConsole.MainConsole.Instance.WriteLine("Starting in Sandbox mode");
}
else
{
OpenSim_Main.gridServers.AssetDll = "RemoteGridServers.dll";
OpenSim_Main.gridServers.GridDll = "RemoteGridServers.dll";
OpenSim_Main.gridServers.LoadPlugins();
ServerConsole.MainConsole.Instance.WriteLine("Starting in Grid mode");
}
if(sim.loginserver && sim.sandbox)
{
LoginServer loginServer = new LoginServer(OpenSim_Main.gridServers.GridServer);
loginServer.Startup();
}
sim.assetCache = new AssetCache(OpenSim_Main.gridServers.AssetServer);
sim.Startup();
while(true) {
ServerConsole.MainConsole.Instance.MainConsolePrompt();
}
}
private OpenSim_Main() {
}
private void Startup() {
startuptime=DateTime.Now;
// We check our local database first, then the grid for config options
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Loading configuration");
cfg = this.LoadConfigDll(this.ConfigDll);
cfg.InitConfig();
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Contacting gridserver");
cfg.LoadFromGrid();
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - We are " + cfg.RegionName + " at " + cfg.RegionLocX.ToString() + "," + cfg.RegionLocY.ToString());
ServerConsole.MainConsole.Instance.WriteLine("Initialising world");
local_world = cfg.LoadWorld();
timer1.Enabled = true;
timer1.Interval = 100;
timer1.Elapsed += new ElapsedEventHandler(this.Timer1Tick);
this.physManager = new PhysicsSystem.PhysicsManager();
this.physManager.LoadPlugins();
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting up messaging system");
local_world.PhysScene = this.physManager.GetPhysicsScene(this._physicsEngine); //should be reading from the config file what physics engine to use
local_world.PhysScene.SetTerrain(local_world.LandMap);
OpenSim_Main.gridServers.AssetServer.SetServerInfo(OpenSim_Main.cfg.AssetURL, OpenSim_Main.cfg.AssetSendKey);
OpenSim_Main.gridServers.GridServer.SetServerInfo(OpenSim_Main.cfg.GridURL, OpenSim_Main.cfg.GridSendKey);
local_world.LoadStorageDLL("Db4LocalStorage.dll"); //all these dll names shouldn't be hard coded.
local_world.LoadPrimsFromStorage();
MainServerListener();
}
private SimConfig LoadConfigDll(string dllName)
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
SimConfig config = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("ISimConfig", true);
if (typeInterface != null)
{
ISimConfig plug = (ISimConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
config = plug.GetConfigObject();
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
return config;
}
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() {
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - New thread started");
ServerConsole.MainConsole.Instance.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);
ServerConsole.MainConsole.Instance.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);
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:MainServerListener() - Listening...");
}
public static void Shutdown() {
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing all threads");
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing listener thread");
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Killing clients");
// IMPLEMENT THIS
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Shutdown() - Closing console and terminating");
OpenSim_Main.local_world.Close();
ServerConsole.MainConsole.Instance.Close();
Environment.Exit(0);
}
void Timer1Tick( object sender, System.EventArgs e )
{
local_world.Update();
}
}
public class Grid
{
public IAssetServer AssetServer;
public IGridServer GridServer;
public string AssetDll = "";
public string GridDll = "";
public Grid()
{
}
public void LoadPlugins()
{
this.AssetServer = this.LoadAssetDll(this.AssetDll);
this.GridServer = this.LoadGridDll(this.GridDll);
}
private IAssetServer LoadAssetDll(string dllName)
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
IAssetServer server = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IAssetPlugin", true);
if (typeInterface != null)
{
IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
server = plug.GetAssetServer();
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
return server;
}
private IGridServer LoadGridDll(string dllName)
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
IGridServer server = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IGridPlugin", true);
if (typeInterface != null)
{
IGridPlugin plug = (IGridPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
server = plug.GetGridServer();
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
return server;
}
}
}

View File

@ -0,0 +1,471 @@
/*
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;
using OpenSim.GridServers;
using OpenSim.world;
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 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;
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 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();
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
if(client.AgentID != this.AgentID)
{
ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
this.OutPacket(objupdate);
client.ClientAvatar.SendAppearanceToOtherAgent(this);
}
}
OpenSim_Main.local_world.GetInitialPrims(this);
break;
case PacketType.ObjectAdd:
OpenSim_Main.local_world.AddNewPrim((ObjectAddPacket)Pack, this);
break;
case PacketType.ObjectLink:
ServerConsole.MainConsole.Instance.WriteLine(Pack.ToString());
break;
case PacketType.ObjectScale:
ServerConsole.MainConsole.Instance.WriteLine(Pack.ToString());
break;
case PacketType.ObjectShape:
ObjectShapePacket shape = (ObjectShapePacket)Pack;
for(int i =0; i <shape.ObjectData.Length; i++)
{
foreach (Entity ent in OpenSim_Main.local_world.Entities.Values)
{
if(ent.localid == shape.ObjectData[i].ObjectLocalID)
{
((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]);
}
}
}
break;
case PacketType.MultipleObjectUpdate :
MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)Pack;
for( int i = 0; i < multipleupdate.ObjectData.Length; i++ )
{
if( multipleupdate.ObjectData[ i ].Type == 9 ) //change position
{
libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[ i ].Data, 0 );
foreach (Entity ent in OpenSim_Main.local_world.Entities.Values)
{
if(ent.localid == multipleupdate.ObjectData[ i ].ObjectLocalID)
{
((OpenSim.world.Primitive)ent).UpdatePosition( pos);
}
}
//should update stored position of the prim
}
else if(multipleupdate.ObjectData[i].Type == 10 )//rotation
{
libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
foreach (Entity ent in OpenSim_Main.local_world.Entities.Values)
{
if(ent.localid == multipleupdate.ObjectData[ i ].ObjectLocalID)
{
ent.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.W);
((OpenSim.world.Primitive)ent).UpdateFlag = true;
}
}
}
else if(multipleupdate.ObjectData[i].Type == 13 )//scale
{
libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[ i ].Data, 12 );
foreach (Entity ent in OpenSim_Main.local_world.Entities.Values)
{
if(ent.localid == multipleupdate.ObjectData[ i ].ObjectLocalID)
{
((OpenSim.world.Primitive)ent).Scale = scale;
}
}
}
}
break;
case PacketType.TransferRequest:
//Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
TransferRequestPacket transfer = (TransferRequestPacket)Pack;
OpenSim_Main.sim.assetCache.AddAssetRequest(this, transfer);
break;
case PacketType.AgentUpdate:
ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
break;
case PacketType.LogoutRequest:
ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
//tell all clients to kill our object
KillObjectPacket kill = new KillObjectPacket();
kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
kill.ObjectData[0].ID = this.ClientAvatar.localid;
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
client.OutPacket(kill);
}
OpenSim_Main.gridServers.GridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode);
lock(OpenSim_Main.local_world.Entities) {
OpenSim_Main.local_world.Entities.Remove(this.AgentID);
}
//need to do other cleaning up here too
OpenSim_Main.sim.ClientThreads.Remove(this.userEP);
this.ClientThread.Abort();
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))
{
ServerConsole.MainConsole.Instance.WriteLine("Resending " + packet.Type.ToString() + " packet, " +
(now - packet.TickCount) + "ms have passed");
packet.Header.Resent = true;
OutPacket(packet);
}
}
}
}
private void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
if (PendingAcks.Count > 250)
{
// FIXME: Handle the odd case where we have too many pending ACKs queued up
ServerConsole.MainConsole.Instance.WriteLine("Too many ACKs queued up!");
return;
}
ServerConsole.MainConsole.Instance.WriteLine("Sending PacketAck");
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;
}
}
}
}
}
//ServerConsole.MainConsole.Instance.WriteLine("OUT: \n" + Pack.ToString());
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) {
ServerConsole.MainConsole.Instance.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)
{
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) {
ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs - Started up new client thread to handle incoming request");
cirpack = initialcirpack;
userEP = remoteEP;
PacketQueue = new BlockingQueue<QueItem>();
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() {
ServerConsole.MainConsole.Instance.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() {
ServerConsole.MainConsole.Instance.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()
{
AuthenticateResponse sessionInfo = OpenSim_Main.gridServers.GridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
if(!sessionInfo.Authorised)
{
//session/circuit not authorised
ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
ClientThread.Abort();
}
else
{
ServerConsole.MainConsole.Instance.WriteLine("OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
//session is authorised
this.AgentID=cirpack.CircuitCode.ID;
this.SessionID=cirpack.CircuitCode.SessionID;
this.CircuitCode=cirpack.CircuitCode.Code;
InitNewClient();
this.ClientAvatar.firstname = sessionInfo.LoginInfo.First;
this.ClientAvatar.lastname = sessionInfo.LoginInfo.Last;
ClientLoop();
}
}
}
}

View File

@ -0,0 +1,211 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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 System.Threading;
using System.IO;
using System.Net;
using libsecondlife;
using libsecondlife.Packets;
using ServerConsole;
namespace OpenSim
{
/// <summary>
/// Description of ServerConsole.
/// </summary>
public class MServerConsole : ConsoleBase
{
private ConsoleType ConsType;
StreamWriter Log;
// 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 MServerConsole(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 override void Close() {
Log.WriteLine("OpenSim shutdown at " + DateTime.Now.ToString());
Log.Close();
}
public override void Write(string format, params object[] args)
{
Log.Write(format, args);
Console.Write(format, args);
return;
}
public override void WriteLine(string format, params object[] args)
{
Log.WriteLine(format, args);
Console.WriteLine(format, args);
return;
}
public override string ReadLine()
{
string TempStr=Console.ReadLine();
Log.WriteLine(TempStr);
return TempStr;
}
public override int Read() {
int TempInt= Console.Read();
Log.Write((char)TempInt);
return TempInt;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public override 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 override 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 override 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 override 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");
this.WriteLine("regenerate - regenerate the sim's terrain");
break;
case "show":
ShowCommands(cmdparams[0]);
break;
case "regenerate":
OpenSim_Main.local_world.RegenerateTerrain();
break;
case "shutdown":
OpenSim_Main.Shutdown();
break;
}
return null;
}
// Shows data about something
public override void ShowCommands(string ShowWhat) {
switch(ShowWhat) {
case "uptime":
this.WriteLine("OpenSim has been running since " + OpenSim_Main.sim.startuptime.ToString());
this.WriteLine("That is " + (DateTime.Now-OpenSim_Main.sim.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) {
if(OpenSim_Main.local_world.Entities[UUID].ToString()== "OpenSim.world.Avatar")
{
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 override 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);
}
public override void SetStatus(string status)
{
Console.Write( status + "\r" );
}
}
}

View File

@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("opensim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Playahead AB")]
[assembly: AssemblyProduct("opensim")]
[assembly: AssemblyCopyright("Copyright © Playahead AB 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1d09756b-a461-4302-b6fe-15c455317909")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-remoteservers")]
[assembly: AssemblyDescriptionAttribute("Connects to remote OGS installation")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,241 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.IO;
using libsecondlife;
using OpenSim.GridServers;
namespace RemoteGridServers
{
/// <summary>
///
/// </summary>
///
public class RemoteGridPlugin : IGridPlugin
{
public RemoteGridPlugin()
{
}
public IGridServer GetGridServer()
{
return(new RemoteGridServer());
}
}
public class RemoteAssetPlugin : IAssetPlugin
{
public RemoteAssetPlugin()
{
}
public IAssetServer GetAssetServer()
{
return(new RemoteAssetServer());
}
}
public class RemoteGridServer :IGridServer
{
private string GridServerUrl;
private string GridSendKey;
public RemoteGridServer()
{
ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created");
}
public bool RequestConnection()
{
return true;
}
public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
AuthenticateResponse user = new AuthenticateResponse();
WebRequest CheckSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/exists");
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
user.Authorised = true;
user.LoginInfo = new Login();
user.LoginInfo.Agent = agentID;
user.LoginInfo.Session = sessionID;
user.LoginInfo.First = "";
user.LoginInfo.Last = "";
}
else
{
// Invalid
user.Authorised = false;
}
return(user);
}
public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/delete");
WebResponse GridResponse = DeleteSession.GetResponse();
StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
String grTest = sr.ReadLine();
sr.Close();
GridResponse.Close();
ServerConsole.MainConsole.Instance.WriteLine("DEBUG: " + grTest);
return(true);
}
public UUIDBlock RequestUUIDBlock()
{
UUIDBlock uuidBlock = new UUIDBlock();
return(uuidBlock);
}
public void RequestNeighbours()
{
return;
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
this.GridServerUrl = ServerUrl;
this.GridSendKey = ServerKey;
}
public void AddNewSession(Login session)
{
}
}
public class RemoteAssetServer : IAssetServer
{
private IAssetReceiver _receiver;
private BlockingQueue<ARequest> _assetRequests;
private Thread _remoteAssetServerThread;
private string AssetServerUrl;
private string AssetSendKey;
public RemoteAssetServer()
{
this._assetRequests = new BlockingQueue<ARequest>();
this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
this._remoteAssetServerThread.IsBackground = true;
this._remoteAssetServerThread.Start();
ServerConsole.MainConsole.Instance.WriteLine("Remote Asset Server class created");
}
public void SetReceiver(IAssetReceiver receiver)
{
this._receiver = receiver;
}
public void RequestAsset(LLUUID assetID, bool isTexture)
{
ARequest req = new ARequest();
req.AssetID = assetID;
req.IsTexture = isTexture;
this._assetRequests.Enqueue(req);
}
public void UpdateAsset(AssetBase asset)
{
}
public void UploadNewAsset(AssetBase asset)
{
}
public void SetServerInfo(string ServerUrl, string ServerKey)
{
this.AssetServerUrl = ServerUrl;
this.AssetSendKey = ServerKey;
}
private void RunRequests()
{
while(true)
{
//we need to add support for the asset server not knowing about a requested asset
ARequest req = this._assetRequests.Dequeue();
LLUUID assetID = req.AssetID;
ServerConsole.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it");
WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data");
WebResponse AssetResponse = AssetLoad.GetResponse();
byte[] idata = new byte[(int)AssetResponse.ContentLength];
BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
idata = br.ReadBytes((int)AssetResponse.ContentLength);
br.Close();
AssetBase asset = new AssetBase();
asset.FullID = assetID;
asset.Data = idata;
_receiver.AssetReceived(asset, req.IsTexture );
}
}
}
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

@ -0,0 +1,49 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>RemoteGridServers</RootNamespace>
<AssemblyName>RemoteGridServers</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="libsecondlife">
<HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="RemoteGrid.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ServerConsole\ServerConsole\ServerConsole.csproj">
<Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
<ProjectReference Include="..\..\GridInterfaces\GridInterfaces.csproj">
<Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project>
<Name>GridInterfaces</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGridServers", "RemoteGridServers.csproj", "{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}"
EndProject
Global
EndGlobal

View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../../bin/RemoteGridServers.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="RemoteGridServers/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-remoteservers" />
<attribute type="AssemblyDescriptionAttribute" value="Connects to remote OGS installation" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/RemoteGridServers.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../bin" failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="libsecondlife.dll" />
<include name="GridInterfaces.dll" />
<include name="ServerConsole.dll" />
</references>
<sources basedir="RemoteGridServers/">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

View File

@ -0,0 +1,105 @@
<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>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</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>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>..\bin\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="libsecondlife">
<HintPath>..\bin\libsecondlife.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Axiom.MathLib">
<HintPath>..\bin\Axiom.MathLib.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="log4net">
<HintPath>..\bin\log4net.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Main.cs" />
<Compile Include="OpenSimClient.cs" />
<Compile Include="types\Mesh.cs" />
<Compile Include="types\Triangle.cs" />
<Compile Include="Util.cs" />
<Compile Include="world\Avatar.cs" />
<Compile Include="world\Entity.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" />
<Compile Include="GridServers\LoginServer.cs" />
<Compile Include="Assets\AssetCache.cs" />
<Compile Include="OpenSimConsole.cs" />
<Compile Include="HeightMapGenHills.cs" />
<Compile Include="VersionInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="GridInterfaces\GridInterfaces.csproj">
<Project>{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}</Project>
<Name>GridInterfaces</Name>
</ProjectReference>
<ProjectReference Include="LocalServers\LocalGridServers\LocalGridServers.csproj">
<Project>{D7F0395B-FADC-4936-80A0-D95AACE92F62}</Project>
<Name>LocalGridServers</Name>
</ProjectReference>
<ProjectReference Include="LocalStorage\Db4LocalStorage\Db4LocalStorage.csproj">
<Project>{74784F23-B0FD-484C-82C1-96C0215733DC}</Project>
<Name>Db4LocalStorage</Name>
</ProjectReference>
<ProjectReference Include="physics\PhysicsManager.csproj">
<Project>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</Project>
<Name>PhysicsManager</Name>
</ProjectReference>
<ProjectReference Include="RemoteServers\RemoteGridServers\RemoteGridServers.csproj">
<Project>{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}</Project>
<Name>RemoteGridServers</Name>
</ProjectReference>
<ProjectReference Include="ServerConsole\ServerConsole\ServerConsole.csproj">
<Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,116 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Second-server", "Second-server.csproj", "{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimConfig", "Config\SimConfig\SimConfig.csproj", "{B063760D-DB8D-4F64-B6FE-335FAD1E650A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalGridServers", "LocalServers\LocalGridServers\LocalGridServers.csproj", "{D7F0395B-FADC-4936-80A0-D95AACE92F62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGridServers", "RemoteServers\RemoteGridServers\RemoteGridServers.csproj", "{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridInterfaces", "GridInterfaces\GridInterfaces.csproj", "{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsManager", "physics\PhysicsManager.csproj", "{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "physics\plugins\PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "LocalStorage\Db4LocalStorage\Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealPhysXplugin", "physics\RealPhysX\RealPhysXplugin\RealPhysXplugin.csproj", "{56C1D214-F389-4228-921A-0A3A0712C159}"
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
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.Build.0 = Release|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.Build.0 = Release|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.Build.0 = Release|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.Build.0 = Release|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{74784F23-B0FD-484C-82C1-96C0215733DC}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.Build.0 = Release|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56C1D214-F389-4228-921A-0A3A0712C159}.Debug|.NET 1.1.Build.0 = Debug|.NET 1.1
{56C1D214-F389-4228-921A-0A3A0712C159}.Debug|.NET 1.1.ActiveCfg = Debug|.NET 1.1
{56C1D214-F389-4228-921A-0A3A0712C159}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56C1D214-F389-4228-921A-0A3A0712C159}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56C1D214-F389-4228-921A-0A3A0712C159}.Release|.NET 1.1.Build.0 = Release|.NET 1.1
{56C1D214-F389-4228-921A-0A3A0712C159}.Release|.NET 1.1.ActiveCfg = Release|.NET 1.1
{56C1D214-F389-4228-921A-0A3A0712C159}.Release|Any CPU.Build.0 = Release|Any CPU
{56C1D214-F389-4228-921A-0A3A0712C159}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-serverconsole")]
[assembly: AssemblyDescriptionAttribute("The default server console")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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 ServerConsole
{
public class MainConsole {
private static ConsoleBase instance;
public static ConsoleBase Instance
{
get
{
return instance;
}
set
{
instance = value;
}
}
}
public abstract class ConsoleBase
{
public enum ConsoleType {
Local, // Use stdio
TCP, // Use TCP/telnet
SimChat // Use in-world chat (for gods)
}
public abstract void Close();
public abstract void Write(string format, params object[] args);
public abstract void WriteLine(string format, params object[] args);
public abstract string ReadLine();
public abstract int Read() ;
// Displays a command prompt and waits for the user to enter a string, then returns that string
public abstract string CmdPrompt(string prompt) ;
// Displays a command prompt and returns a default value if the user simply presses enter
public abstract string CmdPrompt(string prompt, string defaultresponse);
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) ;
// Runs a command with a number of parameters
public abstract Object RunCmd(string Cmd, string[] cmdparams) ;
// Shows data about something
public abstract void ShowCommands(string ShowWhat) ;
// Displays a prompt to the user and then runs the command they entered
public abstract void MainConsolePrompt() ;
public abstract void SetStatus( string status );
}
}

View File

@ -0,0 +1,35 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ServerConsole</RootNamespace>
<AssemblyName>ServerConsole</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ServerConsole.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}"
EndProject
Global
EndGlobal

View File

@ -0,0 +1,48 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../../bin/ServerConsole.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="ServerConsole/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-serverconsole" />
<attribute type="AssemblyDescriptionAttribute" value="The default server console" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/ServerConsole.dll" debug="${debug}" verbose="true" warninglevel="4">
<references>
<include name="System" />
<include name="System.Xml" />
</references>
<sources basedir="ServerConsole/">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

87
opensim/src/Util.cs Normal file
View File

@ -0,0 +1,87 @@
/*
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 Util
{
public static ulong UIntsToLong(uint X, uint Y)
{
return Helpers.UIntsToLong(X,Y);
}
public Util()
{
}
}
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

@ -0,0 +1,37 @@
/*
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.1, Build 1173785234, Revision 192M";
}
}

View File

@ -0,0 +1,37 @@
/*
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";
}
}

62
opensim/src/opensim.sln Normal file
View File

@ -0,0 +1,62 @@

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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GridInterfaces", "GridInterfaces\GridInterfaces.csproj", "{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsManager", "physics\PhysicsManager.csproj", "{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole\ServerConsole.csproj", "{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalGridServers", "LocalServers\LocalGridServers\LocalGridServers.csproj", "{D7F0395B-FADC-4936-80A0-D95AACE92F62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoteGridServers", "RemoteServers\RemoteGridServers\RemoteGridServers.csproj", "{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimConfig", "Config\SimConfig\SimConfig.csproj", "{B063760D-DB8D-4F64-B6FE-335FAD1E650A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Db4LocalStorage", "LocalStorage\Db4LocalStorage\Db4LocalStorage.csproj", "{74784F23-B0FD-484C-82C1-96C0215733DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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|Any CPU.ActiveCfg = Release|Any CPU
{132A6E3E-8F2D-4BF5-BDFB-8555F53F334E}.Release|Any CPU.Build.0 = Release|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DA3174D-42F9-416D-9F0B-AF41FA2BE2F9}.Release|Any CPU.Build.0 = Release|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}.Release|Any CPU.Build.0 = Release|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D7F0395B-FADC-4936-80A0-D95AACE92F62}.Release|Any CPU.Build.0 = Release|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF0E7E62-34F4-4AB2-BDBD-AFC63224A7E5}.Release|Any CPU.Build.0 = Release|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B063760D-DB8D-4F64-B6FE-335FAD1E650A}.Release|Any CPU.Build.0 = Release|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74784F23-B0FD-484C-82C1-96C0215733DC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-physicsmanager")]
[assembly: AssemblyDescriptionAttribute("Handles physics plugins")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,285 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using System.Collections;
using System.IO;
using System.Reflection;
namespace PhysicsSystem
{
/// <summary>
/// Description of MyClass.
/// </summary>
public class PhysicsManager
{
private Dictionary<string, IPhysicsPlugin> _plugins=new Dictionary<string, IPhysicsPlugin>();
public PhysicsManager()
{
}
public PhysicsScene GetPhysicsScene(string engineName)
{
if( String.IsNullOrEmpty( engineName ) )
{
return new NullPhysicsScene();
}
if(_plugins.ContainsKey(engineName))
{
ServerConsole.MainConsole.Instance.WriteLine("creating "+engineName);
return _plugins[engineName].GetScene();
}
else
{
string error = String.Format("couldn't find physicsEngine: {0}", engineName);
ServerConsole.MainConsole.Instance.WriteLine( error );
throw new ArgumentException( error );
}
}
public void LoadPlugins()
{
string path = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory ,"Physics");
string[] pluginFiles = Directory.GetFiles(path, "*.dll");
for(int i= 0; i<pluginFiles.Length; i++)
{
this.AddPlugin(pluginFiles[i]);
}
}
private void AddPlugin(string FileName)
{
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("IPhysicsPlugin", true);
if (typeInterface != null)
{
IPhysicsPlugin plug = (IPhysicsPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
plug.Init();
this._plugins.Add(plug.GetName(),plug);
}
typeInterface = null;
}
}
}
pluginAssembly = null;
}
}
public interface IPhysicsPlugin
{
bool Init();
PhysicsScene GetScene();
string GetName();
void Dispose();
}
public abstract class PhysicsScene
{
public static PhysicsScene Null
{
get
{
return new NullPhysicsScene();
}
}
public abstract PhysicsActor AddAvatar(PhysicsVector position);
public abstract PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size);
public abstract void Simulate(float timeStep);
public abstract void GetResults();
public abstract void SetTerrain(float[] heightMap);
public abstract bool IsThreaded
{
get;
}
}
public class NullPhysicsScene : PhysicsScene
{
private static int m_workIndicator;
public override PhysicsActor AddAvatar(PhysicsVector position)
{
ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : AddAvatar({0})", position );
return PhysicsActor.Null;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : AddPrim({0},{1})", position, size );
return PhysicsActor.Null;
}
public override void Simulate(float timeStep)
{
m_workIndicator = ( m_workIndicator + 1 ) % 10;
ServerConsole.MainConsole.Instance.SetStatus( m_workIndicator.ToString() );
}
public override void GetResults()
{
ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : GetResults()" );
}
public override void SetTerrain(float[] heightMap)
{
ServerConsole.MainConsole.Instance.WriteLine("NullPhysicsScene : SetTerrain({0} items)", heightMap.Length );
}
public override bool IsThreaded
{
get { return false; }
}
}
public abstract class PhysicsActor
{
public static readonly PhysicsActor Null = new NullPhysicsActor();
public abstract PhysicsVector Position
{
get;
set;
}
public abstract PhysicsVector Velocity
{
get;
set;
}
public abstract PhysicsVector Acceleration
{
get;
}
public abstract bool Flying
{
get;
set;
}
public abstract void AddForce(PhysicsVector force);
public abstract void SetMomentum(PhysicsVector momentum);
}
public class NullPhysicsActor : PhysicsActor
{
public override PhysicsVector Position
{
get
{
return PhysicsVector.Zero;
}
set
{
return;
}
}
public override PhysicsVector Velocity
{
get
{
return PhysicsVector.Zero;
}
set
{
return;
}
}
public override PhysicsVector Acceleration
{
get { return PhysicsVector.Zero; }
}
public override bool Flying
{
get
{
return false;
}
set
{
return;
}
}
public override void AddForce(PhysicsVector force)
{
return;
}
public override void SetMomentum(PhysicsVector momentum)
{
return;
}
}
public class PhysicsVector
{
public float X;
public float Y;
public float Z;
public PhysicsVector()
{
}
public PhysicsVector(float x, float y, float z)
{
X = x;
Y = y;
Z = z;
}
public static readonly PhysicsVector Zero = new PhysicsVector(0f, 0f, 0f);
}
}

View File

@ -0,0 +1,41 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>PhysicsManager</RootNamespace>
<AssemblyName>PhysicsManager</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PhysicsManager.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServerConsole\ServerConsole\ServerConsole.csproj">
<Project>{C9A6026D-8E0C-4FE4-8691-FB2A566AA245}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysicsManager", "PhysicsManager.csproj", "{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "..\PhysXplugin\PhysXplugin\PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.Build.0 = Release|Any CPU
{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,31 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("RealPhysXplugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RealPhysXplugin")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,361 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.
*
*/
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using PhysicsSystem;
using PhysXWrapper;
namespace PhysXplugin
{
/// <summary>
/// Will be the PhysX plugin but for now will be a very basic physics engine
/// </summary>
public class PhysXPlugin : IPhysicsPlugin
{
private PhysXScene _mScene;
public PhysXPlugin()
{
}
public bool Init()
{
return true;
}
public PhysicsScene GetScene()
{
if(_mScene == null)
{
_mScene = new PhysXScene();
}
return(_mScene);
}
public string GetName()
{
return("RealPhysX");
}
public void Dispose()
{
}
}
public class PhysXScene :PhysicsScene
{
private List<PhysXCharacter> _characters = new List<PhysXCharacter>();
private List<PhysXPrim> _prims = new List<PhysXPrim>();
private float[] _heightMap;
private NxPhysicsSDK mySdk;
private NxScene scene;
public PhysXScene()
{
mySdk = NxPhysicsSDK.CreateSDK();
scene = mySdk.CreateScene();
}
public override PhysicsActor AddAvatar(PhysicsVector position)
{
Vec3 pos = new Vec3();
pos.X = position.X;
pos.Y = position.Y;
pos.Z = position.Z;
PhysXCharacter act = new PhysXCharacter( scene.AddCharacter(pos));
act.Position = position;
_characters.Add(act);
return act;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
Vec3 pos = new Vec3();
pos.X = position.X;
pos.Y = position.Y;
pos.Z = position.Z;
Vec3 siz = new Vec3();
siz.X = size.X;
siz.Y = size.Y;
siz.Z = size.Z;
PhysXPrim act = new PhysXPrim( scene.AddNewBox(pos, siz));
_prims.Add(act);
return act;
}
public override void Simulate(float timeStep)
{
foreach (PhysXCharacter actor in _characters)
{
actor.Move(timeStep);
}
scene.Simulate(timeStep);
scene.FetchResults();
scene.UpdateControllers();
foreach (PhysXCharacter actor in _characters)
{
actor.UpdatePosition();
}
}
public override void GetResults()
{
}
public override bool IsThreaded
{
get
{
return(false); // for now we won't be multithreaded
}
}
public override void SetTerrain(float[] heightMap)
{
this._heightMap = heightMap;
this.scene.AddTerrain(heightMap);
}
}
public class PhysXCharacter : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private NxCharacter _character;
private bool flying;
public PhysXCharacter(NxCharacter character)
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
_character = character;
}
public override bool Flying
{
get
{
return flying;
}
set
{
flying = value;
}
}
public override PhysicsVector Position
{
get
{
return _position;
}
set
{
_position = value;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration (PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
public void Move(float timeStep)
{
Vec3 vec = new Vec3();
vec.X = this._velocity.X * timeStep;
vec.Y = this._velocity.Y * timeStep;
if(flying)
{
vec.Z = ( this._velocity.Z) * timeStep;
}
else
{
vec.Z = (-9.8f + this._velocity.Z) * timeStep;
}
this._character.Move(vec);
}
public void UpdatePosition()
{
Vec3 vec = this._character.Position;
this._position.X = vec.X;
this._position.Y = vec.Y;
this._position.Z = vec.Z;
}
}
public class PhysXPrim : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private NxActor _prim;
public PhysXPrim(NxActor prim)
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
_prim = prim;
}
public override bool Flying
{
get
{
return false; //no flying prims for you
}
set
{
}
}
public override PhysicsVector Position
{
get
{
PhysicsVector pos = new PhysicsVector();
Vec3 vec = this._prim.Position;
pos.X = vec.X;
pos.Y = vec.Y;
pos.Z = vec.Z;
return pos;
}
set
{
PhysicsVector vec = value;
Vec3 pos = new Vec3();
pos.X = vec.X;
pos.Y = vec.Y;
pos.Z = vec.Z;
this._prim.Position = pos;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration (PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
}
}

View File

@ -0,0 +1,45 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>RealPhysXplugin</RootNamespace>
<AssemblyName>RealPhysXplugin</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{56C1D214-F389-4228-921A-0A3A0712C159}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="PhysX_Wrapper_Dotnet">
<HintPath>..\..\..\..\bin\PhysX_Wrapper_Dotnet.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="RealPhysX.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PhysicsManager.csproj">
<Project>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</Project>
<Name>PhysicsManager</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealPhysXplugin", "RealPhysXplugin.csproj", "{56C1D214-F389-4228-921A-0A3A0712C159}"
EndProject
Global
EndGlobal

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../../bin/PhysicsManager.dll" 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">
<loadfile file="../../VERSION" property="svnver"/>
<asminfo output="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-physicsmanager" />
<attribute type="AssemblyDescriptionAttribute" value="Handles physics plugins" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../bin/PhysicsManager.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../bin" failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="ServerConsole.dll" />
</references>
<sources basedir="./">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

View File

@ -0,0 +1,21 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 2.0.50727.42
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: CLSCompliantAttribute(false)]
[assembly: AssemblyVersionAttribute("0.1.*.192")]
[assembly: AssemblyTitleAttribute("opensim-physicsmanager-physx")]
[assembly: AssemblyDescriptionAttribute("PhysX plugin for OpenSim")]
[assembly: AssemblyCopyrightAttribute("Copyright © OGS development team 2007")]

View File

@ -0,0 +1,227 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.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.Generic;
using PhysicsSystem;
namespace PhysXplugin
{
/// <summary>
/// Will be the PhysX plugin but for now will be a very basic physics engine
/// </summary>
public class PhysXPlugin : IPhysicsPlugin
{
private PhysXScene _mScene;
public PhysXPlugin()
{
}
public bool Init()
{
return true;
}
public PhysicsScene GetScene()
{
if(_mScene == null)
{
_mScene = new PhysXScene();
}
return(_mScene);
}
public string GetName()
{
return("PhysX");
}
public void Dispose()
{
}
}
public class PhysXScene :PhysicsScene
{
private List<PhysXActor> _actors = new List<PhysXActor>();
private float[] _heightMap;
public PhysXScene()
{
}
public override PhysicsActor AddAvatar(PhysicsVector position)
{
PhysXActor act = new PhysXActor();
act.Position = position;
_actors.Add(act);
return act;
}
public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size)
{
return null;
}
public override void Simulate(float timeStep)
{
foreach (PhysXActor actor in _actors)
{
actor.Position.X = actor.Position.X + (actor.Velocity.X * timeStep);
actor.Position.Y = actor.Position.Y + (actor.Velocity.Y * timeStep);
actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
/*if(actor.Flying)
{
actor.Position.Z = actor.Position.Z + (actor.Velocity.Z * timeStep);
}
else
{
actor.Position.Z = actor.Position.Z + ((-9.8f + actor.Velocity.Z) * timeStep);
}
if(actor.Position.Z < (_heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1))
{*/
actor.Position.Z = _heightMap[(int)actor.Position.Y * 256 + (int)actor.Position.X]+1;
//}
if(actor.Position.X<0)
{
actor.Position.X = 0;
actor.Velocity.X = 0;
}
if(actor.Position.Y < 0)
{
actor.Position.Y = 0;
actor.Velocity.Y = 0;
}
if(actor.Position.X > 255)
{
actor.Position.X = 255;
actor.Velocity.X = 0;
}
if(actor.Position.Y > 255)
{
actor.Position.Y = 255;
actor.Velocity.X = 0;
}
}
}
public override void GetResults()
{
}
public override bool IsThreaded
{
get
{
return(false); // for now we won't be multithreaded
}
}
public override void SetTerrain(float[] heightMap)
{
this._heightMap = heightMap;
}
}
public class PhysXActor : PhysicsActor
{
private PhysicsVector _position;
private PhysicsVector _velocity;
private PhysicsVector _acceleration;
private bool flying;
public PhysXActor()
{
_velocity = new PhysicsVector();
_position = new PhysicsVector();
_acceleration = new PhysicsVector();
}
public override bool Flying
{
get
{
return false;
}
set
{
flying= value;
}
}
public override PhysicsVector Position
{
get
{
return _position;
}
set
{
_position = value;
}
}
public override PhysicsVector Velocity
{
get
{
return _velocity;
}
set
{
_velocity = value;
}
}
public override PhysicsVector Acceleration
{
get
{
return _acceleration;
}
}
public void SetAcceleration (PhysicsVector accel)
{
this._acceleration = accel;
}
public override void AddForce(PhysicsVector force)
{
}
public override void SetMomentum(PhysicsVector momentum)
{
}
}
}

View File

@ -0,0 +1,41 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>PhysXplugin</RootNamespace>
<AssemblyName>PhysXplugin</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{ADB751AA-8426-4668-B1FA-43762126CEB3}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PhysXplugin.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PhysicsManager.csproj">
<Project>{3C86A846-7977-4EE7-A8DC-DD487FA5DC2B}</Project>
<Name>PhysicsManager</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

View File

@ -0,0 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhysXplugin", "PhysXplugin.csproj", "{ADB751AA-8426-4668-B1FA-43762126CEB3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.Build.0 = Release|Any CPU
{ADB751AA-8426-4668-B1FA-43762126CEB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,49 @@
<?xml version="1.0"?>
<project name="OpenSim" default="build" basedir=".">
<description>nant buildfile for OpenSim</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../../../bin/Physics/PhysXplugin.dll" 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">
<loadfile file="../../../VERSION" property="svnver"/>
<asminfo output="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-physicsmanager-physx" />
<attribute type="AssemblyDescriptionAttribute" value="PhysX plugin for OpenSim" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../../../bin/Physics/PhysXplugin.dll" debug="${debug}" verbose="true" warninglevel="4">
<references basedir="../../../bin" failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="PhysicsManager.dll" />
</references>
<sources basedir="./">
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

28
opensim/src/types/Mesh.cs Normal file
View File

@ -0,0 +1,28 @@
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

@ -0,0 +1,28 @@
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;
}
}
}

487
opensim/src/world/Avatar.cs Normal file
View File

@ -0,0 +1,487 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using PhysicsSystem;
using Axiom.MathLib;
namespace OpenSim.world
{
public class Avatar : Entity
{
public static bool PhysicsEngineFlying;
public string firstname;
public string lastname;
public OpenSimClient ControllingClient;
private PhysicsActor _physActor;
private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
private bool updateflag;
private byte movementflag;
private List<NewForce> forcesList = new List<NewForce>();
private short _updateCount;
private Axiom.MathLib.Quaternion bodyRot;
public Avatar(OpenSimClient TheClient) {
ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
ControllingClient=TheClient;
position = new LLVector3(100.0f,100.0f,30.0f);
position.Z = OpenSim_Main.local_world.LandMap[(int)position.Y * 256 + (int)position.X]+1;
}
public PhysicsActor PhysActor
{
set
{
this._physActor = value;
}
}
public override void addForces()
{
lock(this.forcesList)
{
if(this.forcesList.Count>0)
{
for(int i=0 ; i < this.forcesList.Count; i++)
{
NewForce force = this.forcesList[i];
PhysicsVector phyVector = new PhysicsVector(force.X, force.Y, force.Z);
this._physActor.Velocity = phyVector;
this.updateflag = true;
this.velocity = new LLVector3(force.X, force.Y, force.Z); //shouldn't really be doing this
// but as we are setting the velocity (rather than using real forces) at the moment it is okay.
}
for(int i=0 ; i < this.forcesList.Count; i++)
{
this.forcesList.RemoveAt(0);
}
}
}
}
public override void update()
{
if(this.updateflag)
{
//need to send movement info
//so create the improvedterseobjectupdate packet
//use CreateTerseBlock()
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
client.OutPacket(terse);
}
updateflag =false;
//this._updateCount = 0;
}
else
{
//if((movementflag & 1) !=0)
//{
_updateCount++;
if(( (!PhysicsEngineFlying) && (_updateCount>3)) || (_updateCount>0))
{
//It has been a while since last update was sent so lets send one.
ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = terseBlock;
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
client.OutPacket(terse);
}
_updateCount = 0;
}
//}
}
}
public static 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 = 8880000;
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);
Avatar.AvatarTemplate = objdata;
}
public void CompleteMovement(World RegionInfo) {
ServerConsole.MainConsole.Instance.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(100f, 100f, 23f);
mov.Data.LookAt = new LLVector3(0.99f, 0.042f, 0);
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;
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++;
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values)
{
client.OutPacket(objupdate);
if(client.AgentID != ControllingClient.AgentID)
{
SendAppearanceToOtherAgent(client);
}
}
//this.ControllingClient.OutPacket(objupdate);
}
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 ObjectUpdatePacket CreateUpdatePacket()
{
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;
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._physActor.Position.X, (float)this._physActor.Position.Y, (float)this._physActor.Position.Z);
byte[] pb = pos2.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
return objupdate;
}
public void SendAppearanceToOtherAgent(OpenSimClient userInfo)
{
AvatarAppearancePacket avp = new AvatarAppearancePacket();
avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
//avp.ObjectData.TextureEntry=this.avatar_template.TextureEntry;// br.ReadBytes((int)numBytes);
LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-0000-000000000005"));
avp.ObjectData.TextureEntry = ntex.ToBytes();
AvatarAppearancePacket.VisualParamBlock avblock = null;
for(int i = 0; i < 218; i++)
{
avblock = new AvatarAppearancePacket.VisualParamBlock();
avblock.ParamValue = (byte)100;
avp.VisualParam[i] = avblock;
}
avp.Sender.IsTrial = false;
avp.Sender.ID = ControllingClient.AgentID;
userInfo.OutPacket(avp);
}
public void HandleUpdate(AgentUpdatePacket pack) {
if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) !=0)
{
this._physActor.Flying = true;
}
else
{
this._physActor.Flying = false;
}
if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) {
Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
if(((movementflag & 1) ==0) || (q!= this.bodyRot))
{
//we should add a new force to the list
// but for now we will deal with velocities
NewForce newVelocity = new NewForce();
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
Axiom.MathLib.Vector3 direc = q * v3;
direc.Normalize();
//work out velocity for sim physics system
direc = direc * ((0.03f) * 128f);
if(this._physActor.Flying)
direc *=2;
newVelocity.X = direc.x;
newVelocity.Y = direc.y;
newVelocity.Z = direc.z;
this.forcesList.Add(newVelocity);
movementflag = 1;
this.bodyRot = q;
}
}
else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) !=0) &&(PhysicsEngineFlying)) {
if(((movementflag & 2) ==0) && this._physActor.Flying)
{
//we should add a new force to the list
// but for now we will deal with velocities
NewForce newVelocity = new NewForce();
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
Axiom.MathLib.Vector3 direc = v3;
direc.Normalize();
//work out velocity for sim physics system
direc = direc * ((0.03f) * 128f *2);
newVelocity.X = direc.x;
newVelocity.Y = direc.y;
newVelocity.Z = direc.z;
this.forcesList.Add(newVelocity);
movementflag = 2;
}
}
else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) !=0) && (PhysicsEngineFlying)) {
if(((movementflag & 4) ==0) && this._physActor.Flying)
{
//we should add a new force to the list
// but for now we will deal with velocities
NewForce newVelocity = new NewForce();
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
//Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
Axiom.MathLib.Vector3 direc = v3;
direc.Normalize();
//work out velocity for sim physics system
direc = direc * ((0.03f) * 128f *2);
newVelocity.X = direc.x;
newVelocity.Y = direc.y;
newVelocity.Z = direc.z;
this.forcesList.Add(newVelocity);
movementflag = 4;
}
}
else if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) !=0) {
Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
if(((movementflag & 8) ==0) || (q!= this.bodyRot))
{
//we should add a new force to the list
// but for now we will deal with velocities
NewForce newVelocity = new NewForce();
Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
Axiom.MathLib.Vector3 direc = q * v3;
direc.Normalize();
//work out velocity for sim physics system
direc = direc * ((0.03f) * 128f);
if(this._physActor.Flying)
direc *=2;
newVelocity.X = direc.x;
newVelocity.Y = direc.y;
newVelocity.Z = direc.z;
this.forcesList.Add(newVelocity);
movementflag = 8;
this.bodyRot = q;
}
}
else
{
if((movementflag) !=0)
{
NewForce newVelocity = new NewForce();
newVelocity.X = 0;
newVelocity.Y = 0;
newVelocity.Z = 0;
this.forcesList.Add(newVelocity);
movementflag = 0;
}
}
}
//should be moved somewhere else
public void SendRegionHandshake(World RegionInfo) {
ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Creating empty RegionHandshake packet");
System.Text.Encoding _enc = System.Text.Encoding.ASCII;
RegionHandshakePacket handshake = new RegionHandshakePacket();
ServerConsole.MainConsole.Instance.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;
handshake.RegionInfo.RegionFlags = 72458694;
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");
ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs:SendRegionHandshake() - Sending RegionHandshake packet");
this.ControllingClient.OutPacket(handshake);
}
public 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._physActor.Position.X, this._physActor.Position.Y, this._physActor.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 InternVelocityX;
ushort InternVelocityY;
ushort InternVelocityZ;
Axiom.MathLib.Vector3 internDirec = new Axiom.MathLib.Vector3(this._physActor.Velocity.X, this._physActor.Velocity.Y, this._physActor.Velocity.Z);
internDirec = internDirec /128.0f;
internDirec.x += 1;
internDirec.y += 1;
internDirec.z += 1;
InternVelocityX = (ushort)(32768 * internDirec.x);
InternVelocityY = (ushort)(32768 * internDirec.y);
InternVelocityZ = (ushort)(32768 * internDirec.z);
ushort ac = 32767;
bytes[i++] = (byte)(InternVelocityX % 256);
bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
bytes[i++] = (byte)(InternVelocityY % 256);
bytes[i++] = (byte)((InternVelocityY>> 8) % 256);
bytes[i++] = (byte)(InternVelocityZ % 256);
bytes[i++] = (byte)((InternVelocityZ >> 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 class NewForce
{
public float X;
public float Y;
public float Z;
public NewForce()
{
}
}
}

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Text;
using Axiom.MathLib;
using OpenSim.types;
using libsecondlife;
namespace OpenSim.world
{
public class Entity
{
public libsecondlife.LLUUID uuid;
public uint localid;
public LLVector3 position;
public LLVector3 velocity;
public Quaternion rotation;
protected string name;
protected List<Entity> children;
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 addForces()
{
foreach (Entity child in children)
{
child.addForces();
}
}
public virtual void update() {
// Do any per-frame updates needed that are applicable to every type of entity
foreach (Entity child in children)
{
child.update();
}
}
public virtual string getName()
{
return name;
}
public virtual Mesh getMesh()
{
Mesh mesh = new Mesh();
foreach (Entity child in children)
{
mesh += child.getMesh();
}
return mesh;
}
public virtual void BackUp()
{
}
}
}

View File

@ -0,0 +1,429 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.types;
using libsecondlife;
using libsecondlife.Packets;
using GridInterfaces;
using PhysicsSystem;
namespace OpenSim.world
{
public class Primitive : Entity
{
protected float mesh_cutbegin;
protected float mesh_cutend;
protected PrimData primData;
protected bool newPrimFlag;
protected bool updateFlag;
protected bool dirtyFlag;
private ObjectUpdatePacket OurPacket;
private PhysicsActor _physActor;
private bool physicsEnabled;
public bool PhysicsEnabled
{
get
{
return physicsEnabled;
}
set
{
physicsEnabled = value;
}
}
public bool UpdateFlag
{
get
{
return updateFlag;
}
set
{
updateFlag = value;
}
}
public LLVector3 Scale
{
set
{
this.primData.Scale = value;
this.dirtyFlag = true;
}
get
{
return this.primData.Scale;
}
}
public PhysicsActor PhysActor
{
set
{
this._physActor = value;
}
}
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;
}
public void UpdatePosition( LLVector3 pos)
{
this.position = pos;
if(this._physActor != null && this.physicsEnabled)
{
this._physActor.Position = new PhysicsVector(pos.X, pos.Y, pos.Z);
}
this.updateFlag = true;
}
public override void update()
{
if(this.newPrimFlag)
{
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
client.OutPacket(OurPacket);
}
this.newPrimFlag = false;
}
else if(this.updateFlag)
{
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = this.CreateImprovedBlock();
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
client.OutPacket(terse);
}
this.updateFlag = false;
}
else if(this.dirtyFlag)
{
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
UpdateClient(client);
}
this.dirtyFlag = false;
}
else
{
if(this._physActor != null && this.physicsEnabled)
{
ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
terse.RegionData.TimeDilation = 64096;
terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
terse.ObjectData[0] = this.CreateImprovedBlock();
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
client.OutPacket(terse);
}
}
}
}
public void UpdateClient(OpenSimClient RemoteClient)
{
LLVector3 lPos;
if( this._physActor != null && this.physicsEnabled)
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
}
else
{
lPos = this.position;
}
byte[] pb = lPos.GetBytes();
Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
// OurPacket should be update with the follwing in updateShape() rather than having to do it here
OurPacket.ObjectData[0].OwnerID = this.primData.OwnerID;
OurPacket.ObjectData[0].PCode = this.primData.PCode;
OurPacket.ObjectData[0].PathBegin = this.primData.PathBegin;
OurPacket.ObjectData[0].PathEnd = this.primData.PathEnd;
OurPacket.ObjectData[0].PathScaleX = this.primData.PathScaleX;
OurPacket.ObjectData[0].PathScaleY = this.primData.PathScaleY;
OurPacket.ObjectData[0].PathShearX = this.primData.PathShearX;
OurPacket.ObjectData[0].PathShearY = this.primData.PathShearY;
OurPacket.ObjectData[0].PathSkew = this.primData.PathSkew;
OurPacket.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
OurPacket.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
OurPacket.ObjectData[0].Scale = this.primData.Scale;
OurPacket.ObjectData[0].PathCurve = this.primData.PathCurve;
OurPacket.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
OurPacket.ObjectData[0].ParentID = 0;
OurPacket.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
//finish off copying rest of shape data
OurPacket.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
OurPacket.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
OurPacket.ObjectData[0].PathTaperX = this.primData.PathTaperX;
OurPacket.ObjectData[0].PathTaperY = this.primData.PathTaperY;
OurPacket.ObjectData[0].PathTwist = this.primData.PathTwist;
OurPacket.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin;
RemoteClient.OutPacket(OurPacket);
}
public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
{
this.primData.PathBegin = addPacket.PathBegin;
this.primData.PathEnd = addPacket.PathEnd;
this.primData.PathScaleX = addPacket.PathScaleX;
this.primData.PathScaleY = addPacket.PathScaleY;
this.primData.PathShearX = addPacket.PathShearX;
this.primData.PathShearY = addPacket.PathShearY;
this.primData.PathSkew = addPacket.PathSkew;
this.primData.ProfileBegin = addPacket.ProfileBegin;
this.primData.ProfileEnd = addPacket.ProfileEnd;
this.primData.PathCurve = addPacket.PathCurve;
this.primData.ProfileCurve = addPacket.ProfileCurve;
this.primData.ProfileHollow = addPacket.ProfileHollow;
this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
this.primData.PathRevolutions = addPacket.PathRevolutions;
this.primData.PathTaperX = addPacket.PathTaperX;
this.primData.PathTaperY = addPacket.PathTaperY;
this.primData.PathTwist = addPacket.PathTwist;
this.primData.PathTwistBegin =addPacket.PathTwistBegin;
this.dirtyFlag = true;
}
public void CreateFromPacket( ObjectAddPacket addPacket, LLUUID agentID, uint localID)
{
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
PrimData PData = new PrimData();
this.primData = PData;
objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
objupdate.ObjectData[0].PSBlock = new byte[0];
objupdate.ObjectData[0].ExtraParams = new byte[1];
objupdate.ObjectData[0].MediaURL = new byte[0];
objupdate.ObjectData[0].NameValue = new byte[0];
objupdate.ObjectData[0].Text = new byte[0];
objupdate.ObjectData[0].TextColor = new byte[4];
objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
objupdate.ObjectData[0].Material = 3;
objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
objupdate.ObjectData[0].TextureAnim = new byte[0];
objupdate.ObjectData[0].Sound = LLUUID.Zero;
LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
objupdate.ObjectData[0].State = 0;
objupdate.ObjectData[0].Data = new byte[0];
PData.OwnerID = objupdate.ObjectData[0].OwnerID = agentID;
PData.PCode = objupdate.ObjectData[0].PCode = addPacket.ObjectData.PCode;
PData.PathBegin = objupdate.ObjectData[0].PathBegin = addPacket.ObjectData.PathBegin;
PData.PathEnd = objupdate.ObjectData[0].PathEnd = addPacket.ObjectData.PathEnd;
PData.PathScaleX = objupdate.ObjectData[0].PathScaleX = addPacket.ObjectData.PathScaleX;
PData.PathScaleY = objupdate.ObjectData[0].PathScaleY = addPacket.ObjectData.PathScaleY;
PData.PathShearX = objupdate.ObjectData[0].PathShearX = addPacket.ObjectData.PathShearX;
PData.PathShearY = objupdate.ObjectData[0].PathShearY = addPacket.ObjectData.PathShearY;
PData.PathSkew = objupdate.ObjectData[0].PathSkew = addPacket.ObjectData.PathSkew;
PData.ProfileBegin = objupdate.ObjectData[0].ProfileBegin = addPacket.ObjectData.ProfileBegin;
PData.ProfileEnd = objupdate.ObjectData[0].ProfileEnd = addPacket.ObjectData.ProfileEnd;
PData.Scale = objupdate.ObjectData[0].Scale = addPacket.ObjectData.Scale;
PData.PathCurve = objupdate.ObjectData[0].PathCurve = addPacket.ObjectData.PathCurve;
PData.ProfileCurve = objupdate.ObjectData[0].ProfileCurve = addPacket.ObjectData.ProfileCurve;
PData.ParentID = objupdate.ObjectData[0].ParentID = 0;
PData.ProfileHollow = objupdate.ObjectData[0].ProfileHollow = addPacket.ObjectData.ProfileHollow;
PData.PathRadiusOffset = objupdate.ObjectData[0].PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
PData.PathRevolutions = objupdate.ObjectData[0].PathRevolutions = addPacket.ObjectData.PathRevolutions;
PData.PathTaperX = objupdate.ObjectData[0].PathTaperX = addPacket.ObjectData.PathTaperX;
PData.PathTaperY = objupdate.ObjectData[0].PathTaperY = addPacket.ObjectData.PathTaperY;
PData.PathTwist = objupdate.ObjectData[0].PathTwist = addPacket.ObjectData.PathTwist;
PData.PathTwistBegin = objupdate.ObjectData[0].PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
//finish off copying rest of shape data
objupdate.ObjectData[0].ID = (uint)(localID);
objupdate.ObjectData[0].FullID = new LLUUID("edba7151-5857-acc5-b30b-f01efef" + (localID- 702000).ToString("00000"));
objupdate.ObjectData[0].ObjectData = new byte[60];
objupdate.ObjectData[0].ObjectData[46] = 128;
objupdate.ObjectData[0].ObjectData[47] = 63;
LLVector3 pos1= addPacket.ObjectData.RayEnd;
//update position
byte[] pb = pos1.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
this.newPrimFlag = true;
this.uuid = objupdate.ObjectData[0].FullID;
this.localid = objupdate.ObjectData[0].ID;
this.position = pos1;
this.OurPacket = objupdate;
}
public void CreateFromStorage(PrimData store)
{
//need to clean this up as it shares a lot of code with CreateFromPacket()
ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
objupdate.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle;
objupdate.RegionData.TimeDilation = 64096;
objupdate.ObjectData = new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock[1];
this.primData = store;
objupdate.ObjectData[0] = new ObjectUpdatePacket.ObjectDataBlock();
objupdate.ObjectData[0].PSBlock = new byte[0];
objupdate.ObjectData[0].ExtraParams = new byte[1];
objupdate.ObjectData[0].MediaURL = new byte[0];
objupdate.ObjectData[0].NameValue = new byte[0];
objupdate.ObjectData[0].Text = new byte[0];
objupdate.ObjectData[0].TextColor = new byte[4];
objupdate.ObjectData[0].JointAxisOrAnchor = new LLVector3(0,0,0);
objupdate.ObjectData[0].JointPivot = new LLVector3(0,0,0);
objupdate.ObjectData[0].Material = 3;
objupdate.ObjectData[0].UpdateFlags=32+65536+131072+256+4+8+2048+524288+268435456;
objupdate.ObjectData[0].TextureAnim = new byte[0];
objupdate.ObjectData[0].Sound = LLUUID.Zero;
LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
objupdate.ObjectData[0].TextureEntry = ntex.ToBytes();
objupdate.ObjectData[0].State = 0;
objupdate.ObjectData[0].Data = new byte[0];
objupdate.ObjectData[0].OwnerID = this.primData.OwnerID;
objupdate.ObjectData[0].PCode = this.primData.PCode;
objupdate.ObjectData[0].PathBegin = this.primData.PathBegin;
objupdate.ObjectData[0].PathEnd = this.primData.PathEnd;
objupdate.ObjectData[0].PathScaleX = this.primData.PathScaleX;
objupdate.ObjectData[0].PathScaleY = this.primData.PathScaleY;
objupdate.ObjectData[0].PathShearX = this.primData.PathShearX;
objupdate.ObjectData[0].PathShearY = this.primData.PathShearY;
objupdate.ObjectData[0].PathSkew = this.primData.PathSkew;
objupdate.ObjectData[0].ProfileBegin = this.primData.ProfileBegin;
objupdate.ObjectData[0].ProfileEnd = this.primData.ProfileEnd;
objupdate.ObjectData[0].Scale = this.primData.Scale;
objupdate.ObjectData[0].PathCurve = this.primData.PathCurve;
objupdate.ObjectData[0].ProfileCurve = this.primData.ProfileCurve;
objupdate.ObjectData[0].ParentID = 0;
objupdate.ObjectData[0].ProfileHollow = this.primData.ProfileHollow;
//finish off copying rest of shape data
objupdate.ObjectData[0].PathRadiusOffset = this.primData.PathRadiusOffset;
objupdate.ObjectData[0].PathRevolutions = this.primData.PathRevolutions;
objupdate.ObjectData[0].PathTaperX = this.primData.PathTaperX;
objupdate.ObjectData[0].PathTaperY = this.primData.PathTaperY;
objupdate.ObjectData[0].PathTwist = this.primData.PathTwist;
objupdate.ObjectData[0].PathTwistBegin= this.primData.PathTwistBegin;
objupdate.ObjectData[0].ID = (uint)store.LocalID;
objupdate.ObjectData[0].FullID = store.FullID;
objupdate.ObjectData[0].ObjectData = new byte[60];
objupdate.ObjectData[0].ObjectData[46] = 128;
objupdate.ObjectData[0].ObjectData[47] = 63;
LLVector3 pos1= store.Position;
//update position
byte[] pb = pos1.GetBytes();
Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 0, pb.Length);
this.uuid = objupdate.ObjectData[0].FullID;
this.localid = objupdate.ObjectData[0].ID;
this.position = pos1;
this.OurPacket = objupdate;
}
public ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
{
uint ID = this.localid;
byte[] bytes = new byte[60];
int i = 0;
ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
dat.TextureEntry = this.OurPacket.ObjectData[0].TextureEntry;
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++]= 0;
LLVector3 lPos;
if( this._physActor != null && this.physicsEnabled)
{
PhysicsVector pPos = this._physActor.Position;
lPos = new LLVector3( pPos.X, pPos.Y, pPos.Z);
}
else
{
lPos = this.position;
}
byte[] pb = lPos.GetBytes();
Array.Copy(pb, 0, bytes, i, pb.Length);
i += 12;
ushort ac = 32767;
//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);
//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);
ushort rw, rx,ry,rz;
rw = (ushort)(32768 * (this.rotation.w+1));
rx = (ushort)(32768 * (this.rotation.x+1));
ry = (ushort)(32768 * (this.rotation.y+1));
rz = (ushort)(32768 * (this.rotation.z+1));
//rot
bytes[i++] = (byte)(rx % 256);
bytes[i++] = (byte)((rx >> 8) % 256);
bytes[i++] = (byte)(ry % 256);
bytes[i++] = (byte)((ry >> 8) % 256);
bytes[i++] = (byte)(rz % 256);
bytes[i++] = (byte)((rz >> 8) % 256);
bytes[i++] = (byte)(rw % 256);
bytes[i++] = (byte)((rw >> 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 override void BackUp()
{
this.primData.FullID = this.uuid;
this.primData.LocalID = this.localid;
this.primData.Position = this.position;
this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z , this.rotation.w);
OpenSim_Main.local_world.localStorage.StorePrim(this.primData);
}
}
}

View File

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

View File

@ -0,0 +1,22 @@
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;
}
}
}
}

208
opensim/src/world/World.cs Normal file
View File

@ -0,0 +1,208 @@
using System;
using libsecondlife;
using libsecondlife.Packets;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using PhysicsSystem;
using GridInterfaces;
namespace OpenSim.world
{
public class World : ILocalStorageReceiver
{
public Dictionary<libsecondlife.LLUUID, Entity> Entities;
public float[] LandMap;
public ScriptEngine Scripts;
public uint _localNumber=0;
private PhysicsScene phyScene;
private float timeStep= 0.1f;
private libsecondlife.TerrainManager TerrainManager;
public ILocalStorage localStorage;
private Random Rand = new Random();
private uint _primCount = 702000;
private int storageCount;
public World()
{
ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
ServerConsole.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
TerrainManager = new TerrainManager(new SecondLife());
Avatar.SetupTemplate("avatar-template.dat");
// ServerConsole.MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
// Initialise this only after the world has loaded
// Scripts = new ScriptEngine(this);
}
public PhysicsScene PhysScene
{
set
{
this.phyScene = value;
}
get
{
return(this.phyScene);
}
}
public void Update()
{
if(this.phyScene.IsThreaded)
{
this.phyScene.GetResults();
}
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
Entities[UUID].addForces();
}
this.phyScene.Simulate(timeStep);
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
Entities[UUID].update();
}
//backup world data
this.storageCount++;
if(storageCount> 300) //set to how often you want to backup
{
this.Backup();
storageCount =0;
}
}
public bool LoadStorageDLL(string dllName)
{
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
ILocalStorage store = null;
foreach (Type pluginType in pluginAssembly.GetTypes())
{
if (pluginType.IsPublic)
{
if (!pluginType.IsAbstract)
{
Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
if (typeInterface != null)
{
ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
store = plug;
break;
}
typeInterface = null;
}
}
}
pluginAssembly = null;
this.localStorage = store;
return(store == null);
}
public void RegenerateTerrain()
{
HeightmapGenHills hills = new HeightmapGenHills();
this.LandMap = hills.GenerateHeightmap(200, 4.0f, 80.0f, false);
this.phyScene.SetTerrain(this.LandMap);
OpenSim_Main.cfg.SaveMap();
foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
this.SendLayerData(client);
}
}
public void LoadPrimsFromStorage()
{
ServerConsole.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives");
this.localStorage.LoadPrimitives(this);
}
public void PrimFromStorage(PrimData prim)
{
if(prim.LocalID >= this._primCount)
{
_primCount = prim.LocalID + 1;
}
ServerConsole.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId "+ prim.LocalID+ " ) from storage");
Primitive nPrim = new Primitive();
nPrim.CreateFromStorage(prim);
this.Entities.Add(nPrim.uuid, nPrim);
}
public void Close()
{
this.localStorage.ShutDown();
}
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 GetInitialPrims(OpenSimClient RemoteClient)
{
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
if(Entities[UUID].ToString()== "OpenSim.world.Primitive")
{
((OpenSim.world.Primitive)Entities[UUID]).UpdateClient(RemoteClient);
}
}
}
public void AddViewerAgent(OpenSimClient AgentClient) {
ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
Avatar NewAvatar = new Avatar(AgentClient);
ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
ServerConsole.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
NewAvatar.SendRegionHandshake(this);
PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z);
NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
this.Entities.Add(AgentClient.AgentID, NewAvatar);
}
public void AddNewPrim(ObjectAddPacket addPacket, OpenSimClient AgentClient)
{
ServerConsole.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
Primitive prim = new Primitive();
prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z);
PhysicsVector pSize = new PhysicsVector( 0.25f, 0.25f, 0.25f);
//prim.PhysActor = this.phyScene.AddPrim(pVec, pSize );
//prim.PhysicsEnabled = true;
this.Entities.Add(prim.uuid, prim);
this._primCount++;
}
public bool Backup() {
/* TODO: Save the current world entities state. */
ServerConsole.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives");
foreach (libsecondlife.LLUUID UUID in Entities.Keys)
{
Entities[UUID].BackUp();
}
return true;
}
}
}

View File

@ -0,0 +1,16 @@
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();
}
}