Add classic ingame web

ryzomclassic-develop
kaetemi 5 years ago
parent 7ac4eb3097
commit 85c9d4e4b6

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyAndroidApp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -1,12 +0,0 @@
#Tue Feb 21 13:19:14 SGT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mkyong.android"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".WebViewActivity"
android:theme="@android:style/Theme.NoTitleBar" />
<activity
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:name=".MainActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

@ -1,6 +0,0 @@
/** Automatically generated file. DO NOT MODIFY */
package com.mkyong.android;
public final class BuildConfig {
public final static boolean DEBUG = true;
}

@ -1,25 +0,0 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.mkyong.android;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int webView1=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040000;
}
}

@ -1 +0,0 @@
Info: Android Application Made by Matthew Lagoe for browsing the AMS on your android device!

@ -1,40 +0,0 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

@ -1,11 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-18

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id='@+id/webView1'
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
/>

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Ryzom Core AMS</string>
</resources>

@ -1,22 +0,0 @@
package com.mkyong.android;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://shard.ryzomcore.org/ams/index.php");
}
}

@ -1,7 +0,0 @@
###################################################################
CREDITS REGARDING THE AMS
##################################################################
- Muhammad Usman (Charisma Layout http://usman.it/themes/charisma/)
- prdatur (Icon Set http://opengameart.org/users/prdatur)
- Tobi (original Drupal Module)
- Botanic (Mentoring & original drupal module)

@ -1 +0,0 @@
The following variables are required and must be set to a variable (not constant) and called before including ams_lib/libinclude.php

@ -1,10 +0,0 @@
; $Id$
name = Ryzom Account Manager
description = Ryzom Login Service Integration - inserts and updates users and manages accounts.
core = 7.x
package = Ryzom Plugins
configure = admin/settings/ryzommanage
; Information added by drupal.org packaging script on 2012-04-24
version = "7.x-.01"
core = "7.x"

@ -1,31 +0,0 @@
<?php
// $id$
/**
* @file
* Medals module install file.
*/
function ryzommanage_install() {
$vocab = array(
'name' => 'Ryzom Manager',
'machine_name' => 'ryzommanage',
'description' => 'Ryzom Login Service integration - inserts and updates users and manages accounts.',
'module' => 'ryzommanage',
);
$vocab = (object) $vocab;
db_query("CREATE TABLE ryzommanage_querycache (
`SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`type` VARCHAR( 64 ) NOT NULL ,
`query` VARCHAR( 512 ) NOT NULL
);");
}
function ryzommanage_uninstall() {
db_query("DROP TABLE ryzommanage_querycache;");
}
function _ryzommanage_vocab_fields() {
}

@ -1,931 +0,0 @@
<?php
/*
Drupal 7 ryzom core module
Copyright (C) 2013 Matthew Lagoe (Botanic) & Paige Offerdahl (Tobi)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once("/ams_lib/libinclude.php");
//output template
function loadTemplate($template,$vars)
{
extract($vars);
include($template);
}
/**
*
* Function ryzommanage_admin
*
* @takes Nothing
* @return array $form
*
* Info: Creates the box's etc that go in the ryzom admin menu
*
*/
function ryzommanage_admin()
{
$form = array();
//admin menu items
$form['ryzommanage_serverurl'] = array(
'#type' => 'textfield',
'#title' => t('Server url'),
'#default_value' => variable_get('ryzommanage_serverurl', 'localhost'),
'#description' => t("The url of the ryzom server to integrate with."),
'#required' => TRUE
);
$form['ryzommanage_mysqlport'] = array(
'#type' => 'textfield',
'#title' => t('Port for MySQL'),
'#size' => 5,
'#maxlength' => 5,
'#default_value' => variable_get('ryzommanage_mysqlport', '3306'),
'#description' => t("The MySQL port of the ryzom server to integrate with."),
'#required' => TRUE,
'#element_validate' => array(
'_check_port_value'
)
);
$form['ryzommanage_dbname'] = array(
'#type' => 'textfield',
'#title' => t('Database Name'),
'#default_value' => variable_get('ryzommanage_dbname', 'nel'),
'#description' => t("The MySQL database name to connect to."),
'#required' => TRUE
);
$form['ryzommanage_username'] = array(
'#type' => 'textfield',
'#title' => t('MySQL Username'),
'#default_value' => variable_get('ryzommanage_username', 'root'),
'#description' => t("The MySQL username to connect with."),
'#required' => TRUE
);
$form['ryzommanage_password'] = array(
'#type' => 'password_confirm',
'#title' => t('MySQL Password'),
'#description' => t("Confirm the MySQL password.")
);
return system_settings_form($form);
}
//validate registration webpage
function ryzommanage_form_alter(&$form, &$form_state, $form_id)
{
if($form_id == "user_register_form")
{
$form['#validate'][] = '_webpage_registration';
} elseif($form_id == "user_profile_form") {
$form['#validate'][] = '_webpage_profile';
}
}
function _webpage_registration(&$form_state)
{
$user = checkUser($form_state['account']['name']['#value']);
$email = validEmail($form_state['account']['mail']['#value']);
if ($user != "success") {
form_set_error('name', t($user));
}
if ($email != "success") {
form_set_error('mail', t('Not a valid email address, please check it and try again.'));
}
}
function _webpage_profile(&$form_state)
{
$email = validEmail($form_state['account']['mail']['#value']);
if ($email != "success") {
form_set_error('mail', t('Not a valid email address, please check it and try again.'));
}
if ((checkPassword($form_state['account']['pass']['#value']['pass1']) == "success" ) and ( $form_state['account']['pass']['#value']['pass1'] ==
$form_state['account']['pass']['#value']['pass2'] )) {
}
}
/**
*
* Function ryzommanage_menu
*
* @takes Nothing
* @return array $items
*
* Info: Creates the menu item in the admin interface
*
*/
function ryzommanage_menu()
{
$items = array();
//page for client registration
$items['register'] = array(
'title' => 'register',
'page callback' => '_collect_register',
'page arguments' => array(1, 2),
'access callback' => 'user_access',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
//main menu item
$items['admin/config/ryzommanage'] = array(
'title' => 'Ryzom Server Integration',
'description' => 'Ryzom integration information.',
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array(
'administer site configuration'
),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system')
);
// First submenu item
$items['admin/config/ryzommanage/serversettings'] = array(
'title' => 'Ryzom Server Settings',
'description' => 'This is the first child item in the section',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'ryzommanage_admin'
),
'access arguments' => array(
'administer site configuration'
)
);
// Second submenu item
$items['admin/config/ryzommanage/nameregister'] = array(
'title' => 'Name Registration Settings',
'description' => 'Configure default behavior of name registration module.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'name_registration_admin_settings'
),
'access arguments' => array(
'administer site configuration'
)
);
return $items;
}
function name_registration_admin_settings() {
$form = array();
$form['ryzommanage_game-name'] = array(
'#type' => 'textfield',
'#title' => t('Game Name'),
'#default_value' => variable_get('ryzommanage_game-name', ''),
'#description' => t("Name of game used on registration pages."),
'#required' => TRUE
);
//this is not the TOS url used in the create account page, you change that in the config of the client with the ConditionsTermsURL value
$form['ryzommanage_TOS'] = array(
'#type' => 'textfield',
'#title' => t('Terms of Service URL'),
'#default_value' => variable_get('ryzommanage_TOS', ''),
'#description' => t("The url of the TOS for your server."),
'#required' => TRUE
);
$form['ryzommanage_register-welcome'] = array(
'#type' => 'textarea',
'#title' => t('Registration Welcome Message'),
'#default_value' => variable_get('ryzommanage_register-welcome', ''),
'#description' => t("Registration welcome message on first page of create account."),
'#required' => TRUE
);
return system_settings_form($form);
}
/**
*
* Function ryzommanage_menu
*
* @takes Int $element, &$form_state
* @return Nothing
*
* Info: Used by ryzommanage_mysqlport to validate ryzommanage_admin will run form_error if port is not between 1 and 65535.
*
*/
function _check_port_value($element, &$form_state)
{
if ((!is_numeric(parse_size($element['#value']))) or ((parse_size($element['#value']) > 65535) or (parse_size($element['#value']) < 1))) {
form_error($element, t($element['#value'] . ' is not a valid value for the MySQL port, it must be a valid value. You must choose a number between 1 and 65535.'));
}
}
/**
*
* Function ryzommanage_block_info
*
* @takes Nothing
* @return array $blocks
*
* Info: Info for block that shows the user menu
*
*/
function ryzommanage_block_info()
{
$blocks['ryzommanage_usersblock'] = array(
// info: The name of the block.
'info' => t('Ryzom Manage User Block'),
'status' => TRUE,
'region' => '-1', // Not usually provided.
'visibility' => BLOCK_VISIBILITY_LISTED // Not usually provided.
);
return $blocks;
}
/**
*
* Function ryzommanage_block_view
*
* @takes Nothing
* @return array $block
*
* Info: View for block
*
*/
function ryzommanage_block_view($delta = '')
{
$block = array();
//The $delta parameter tells us which block is being requested.
switch ($delta) {
case 'ryzommanage_usersblock':
$block['subject'] = t("uppercase this please");
$block['content'] = top_bar();
break;
}
return $block;
}
/**
*
* Function _collect_register
*
* @takes
* @return Nothing
*
* Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to /
*
*/
function _collect_register($nids, $collection)
{
syncdata();
//if not using ryzom core client show registration page
if (check_if_game_client()) {
return_client_httpdata();
} else {
//redirect to registration page
header("Location: /user/register");
}
}
/**
*
* Function check_if_game_client
*
* @takes Nothing
* @return Boolean
*
* Info: Returns True if connecting client is ryzom core
*
*/
function check_if_game_client()
{
//if HTTP_USER_AGENT is not set then its ryzom core
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
return true;
} else {
return false;
}
}
/**
*
* Function return_client_httpdata
*
* @takes
* @return
*
* Info: Returns ryzom core formatted html for use in registration via client
*
*/
function return_client_httpdata()
{
//check if values exist
if (isset($_POST["Username"]) and isset($_POST["Password"]) and isset($_POST["Email"]) )
{
//check values
$user = checkUser($_POST["Username"]);
$pass = checkPassword($_POST["Password"]);
$cpass = confirmPassword();
$email = checkEmail($_POST["Email"]);
} else {
$user = "";
$pass = "";
$cpass = "";
$email = "";
}
//if all are good then create user
if (($user == "success") and ($pass == "success") and ($cpass == "success") and ($email == "success") and (isset($_POST["TaC"]))) {
$edit = array(
'name' => $_POST["Username"],
'pass' => $_POST["Password"],
'mail' => $_POST["Email"],
'init' => $_POST["Email"],
'unhashpass' => $_POST["Password"],
'status' => 1,
'access' => REQUEST_TIME
);
user_save(NULL, $edit);
header('Location: email_sent.php');
exit;
} else {
$pageElements = array(
'GAME_NAME' => variable_get('ryzommanage_game-name', ''),
'WELCOME_MESSAGE' => variable_get('ryzommanage_register-welcome', ''),
'USERNAME' => $user,
'PASSWORD' => $pass,
'CPASSWORD' => $cpass,
'EMAIL' => $email
);
if ($user != "success") {
$pageElements['USERNAME_ERROR'] = 'TRUE';
} else {
$pageElements['USERNAME_ERROR'] = 'FALSE';
}
if ($pass != "success") {
$pageElements['PASSWORD_ERROR'] = 'TRUE';
} else {
$pageElements['PASSWORD_ERROR'] = 'FALSE';
}
if ($cpass != "success") {
$pageElements['CPASSWORD_ERROR'] = 'TRUE';
} else {
$pageElements['CPASSWORD_ERROR'] = 'FALSE';
}
if ($email != "success") {
$pageElements['EMAIL_ERROR'] = 'TRUE';
} else {
$pageElements['EMAIL_ERROR'] = 'FALSE';
}
if (isset($_POST["TaC"])) {
$pageElements['TAC_ERROR'] = 'FALSE';
} else {
$pageElements['TAC_ERROR'] = 'TRUE';
}
loadTemplate('templates/ingame_register.phtml',$pageElements);
}
}
/**
*
* Function checkUser
*
* @takes $username
* @return string
*
* Info: Returns a string based on if the username is valid, if valid then "success" is returned
*
*/
function checkUser($username)
{
if (isset($username)) {
if (strlen($username) > 12) {
return "Username must be no more than 12 characters.";
} elseif (strlen($username) < 5) {
return "Username must be 5 or more characters.";
} elseif (!preg_match('/^[a-z0-9\.]*$/', $username)) {
return "Username can only contain numbers and letters.";
} elseif (db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array(
':name' => $username
))->fetchField()) {
return "Username " . $username . " is in use.";
} else {
return "success";
}
} else {
return "success";
}
return "fail";
}
/**
*
* Function checkPassword
*
* @takes $pass
* @return string
*
* Info: Returns a string based on if the password is valid, if valid then "success" is returned
*
*/
function checkPassword($pass)
{
if (isset($pass)) {
if (strlen($pass) > 20) {
return "Password must be no more than 20 characters.";
} elseif (strlen($pass) < 5) {
return "Password must be more than 5 characters.";
} else {
return "success";
}
}
return "fail";
}
/**
*
* Function confirmPassword
*
* @takes $pass
* @return string
*
* Info: Verify's $_POST["Password"] is the same as $_POST["ConfirmPass"]
*
*/
function confirmPassword()
{
if (($_POST["Password"]) != ($_POST["ConfirmPass"])) {
return "Passwords do not match.";
} else {
return "success";
}
return "fail";
}
/**
*
* Function checkEmail
*
* @takes $email
* @return
*
*
*
*/
function checkEmail($email)
{
if (isset($email)) {
if (!validEmail($email)) {
return "Email address is not valid.";
} elseif (db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(
':mail' => $email
))->fetchField()) {
return "Email is in use.";
} else {
return "success";
}
} else {
return "success";
}
return "fail";
}
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex) {
$isValid = false;
} else {
$domain = substr($email, $atIndex + 1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64) {
// local part length exceeded
$isValid = false;
} else if ($domainLen < 1 || $domainLen > 255) {
// domain part length exceeded
$isValid = false;
} else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
// local part starts or ends with '.'
$isValid = false;
} else if (preg_match('/\\.\\./', $local)) {
// local part has two consecutive dots
$isValid = false;
} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
// character not valid in domain part
$isValid = false;
} else if (preg_match('/\\.\\./', $domain)) {
// domain part has two consecutive dots
$isValid = false;
} else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) {
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
function generateSALT($length = 2)
{
// start with a blank salt
$salt = "";
// define possible characters - any character in this string can be
// picked for use in the salt, so if you want to put vowels back in
// or add special characters such as exclamation marks, this is where
// you should do it
$possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";
// we refer to the length of $possible a few times, so let's grab it now
$maxlength = strlen($possible);
// check for length overflow and truncate if necessary
if ($length > $maxlength) {
$length = $maxlength;
}
// set up a counter for how many characters are in the salt so far
$i = 0;
// add random characters to $salt until $length is reached
while ($i < $length) {
// pick a random character from the possible ones
$char = substr($possible, mt_rand(0, $maxlength - 1), 1);
// have we already used this character in $salt?
if (!strstr($salt, $char)) {
// no, so it's OK to add it onto the end of whatever we've already got...
$salt .= $char;
// ... and increase the counter by one
$i++;
}
}
// done!
return $salt;
}
function createUser($values)
{
$login = $values[0];
$pass = $values[1];
$email = $values[2];
$salt = generateSALT();
$hashpass = crypt($pass, $salt);
$params = array(
$login,
$hashpass,
$email
);
try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306');
$dbname = variable_get('ryzommanage_dbname', 'nel');
$username = variable_get('ryzommanage_username', 'root');
$password = variable_get('ryzommanage_password', '');
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "createUser",
"query" => json_encode(array(
$login,
$pass,
$email
))
))->execute();
return true;
}
try {
$statement = $dbh->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)");
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "createUser",
"query" => json_encode(array(
$login,
$pass,
$email
))
))->execute();
return true;
}
try {
$statement->execute($params);
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "createUser",
"query" => json_encode(array(
$login,
$pass,
$email
))
))->execute();
return true;
}
createPermissions(array($login));
}
function createPermissions($values) {
try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306');
$dbname = variable_get('ryzommanage_dbname', 'nel');
$username = variable_get('ryzommanage_username', 'root');
$password = variable_get('ryzommanage_password', '');
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "createPermissions",
"query" => json_encode(array(
$values[0]
))
))->execute();
return true;
}
try {
$sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';");
$sth->execute();
$result = $sth->fetchAll();
/*foreach ($result as $UId) {
$statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'r2', 'OPEN');");
$statement->execute($values);
$statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'ryzom_open', 'OPEN');");
$statement->execute($values);
}*///FIXME: GARBAGE
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "createPermissions",
"query" => json_encode(array(
$values[0]
))
))->execute();
return true;
}
return true;
}
function login_form($login_form)
{
$login_form['#action'] = url(current_path(), array(
'query' => drupal_get_destination(),
'external' => FALSE
));
$login_form['#id'] = 'user-login-form';
$login_form['#validate'] = user_login_default_validators();
$login_form['#submit'][] = 'user_login_submit';
$login_form['name'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#maxlength' => 12,
'#size' => 15,
'#required' => TRUE
);
$login_form['pass'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#maxlength' => 20,
'#size' => 15,
'#required' => TRUE
);
$items = array();
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) {
$items[] = l(t('Create new account'), 'user/register', array(
'attributes' => array(
'title' => t('Create a new user account.')
)
));
}
$items[] = l(t('Request new password'), 'user/password', array(
'attributes' => array(
'title' => t('Request new password via e-mail.')
)
));
$login_form['links'] = array(
'#markup' => theme('item_list', array(
'items' => $items
))
);
$login_form['remember_me'] = array(
'#type' => 'checkbox',
'#title' => t('Remember Me'),
'#default_value' => 0
);
$login_form['actions'] = array(
'#type' => 'actions'
);
$login_form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Log in')
);
return $login_form;
}
function top_bar()
{
global $user;
$userId = $user->uid;
if (user_is_logged_in()) {
// Logged in user
return "<div class='ryzomuserbar'>Notepad | Mail | Wiki | Profile | Craft Recipe-Book | Occupations | News/Events | <a href='/user/".$userId."/edit'>Account</a> | <a href='/user/logout'>Logout</a></div>";
} else {
return drupal_get_form('login_form');
// Not logged in
}
}
function ryzommanage_user_presave(&$edit, $account, $category)
{
if (isset($edit['unhashpass'])) {
$pass = $edit['unhashpass'];
} elseif (isset($_POST['pass']['pass1'])) {
$pass = $_POST['pass']['pass1'];
}
if (!isset($edit['name'])) {
$name = $user->name;
} else {
$name = $edit['name'];
}
if ($account->is_new == 1 ) {
createUser(array($edit['name'], $pass, $edit['mail']));
} else {
user_edit( array($edit['name'], $pass));
}
}
function ryzommanage_form_user_register_form_alter(&$form, &$form_state, $form_id) {
// Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user
// registration form.
// Change the data for the username and email fields
$form['account']['name']['#maxlength'] = '12';
$form['account']['name']['#description'] = '5-12 lower-case characters and numbers. The login (username) you create here will be your login name.<br />The name of your game characters will be chosen later on.<br />';
$form['account']['mail']['#description'] = 'Please verify that the e-mail address you enter here is valid and will remain valid in the future.<br />It will be used to manage your Tempest in the Aether account.<br />';
// Add a checkbox to registration form about agreeing to terms of use.
$form['terms_of_use'] = array(
'#type' => 'checkbox',
'#title' => t("I agree with the <a href='".variable_get('ryzommanage_TOS', '')."'>terms and conditions</a>."),
'#required' => TRUE,
);
}
function ryzommanage_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
// Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user
// registration form.
// Change the data for the password field
$form['account']['pass']['#description'] = 'Password must be 5-20 characters.<br />';
}
function user_edit($values) {
$username = $values[0];
$newpassword = $values[1];
$salt = generateSALT();
$pass = crypt($newpassword, $salt);
try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306');
$dbname = variable_get('ryzommanage_dbname', 'nel');
$ryusername = variable_get('ryzommanage_username', 'root');
$password = variable_get('ryzommanage_password', '');
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $ryusername, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "user_edit",
"query" => json_encode(array(
$username,
$newpassword
))
))->execute();
return true;
}
$sql = "UPDATE `nel`.`user` SET `Password` = ? WHERE `user`.`Login` = ?";
try {
$q = $dbh->prepare($sql);
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "user_edit",
"query" => json_encode(array(
$username,
$newpassword
))
))->execute();
return true;
}
try {
$q->execute(array( $pass, $username));
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
$nid = db_insert('ryzommanage_querycache')->fields(array(
"SID" => NULL,
"type" => "user_edit",
"query" => json_encode(array(
$username,
$newpassword
))
))->execute();
return true;
}
return true;
}
/**
*
* Function syncdata
*
* @takes Nothing
* @return array $values
*
* Info: Runs functions to finish syncing data when shard is offline
*
*/
function syncdata () {
try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306');
$dbname = variable_get('ryzommanage_dbname', 'nel');
$ryusername = variable_get('ryzommanage_username', 'root');
$password = variable_get('ryzommanage_password', '');
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $ryusername, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
return true;
}
$query = db_select('ryzommanage_querycache', 'q')
->fields('q', array('SID', 'type', 'query'));
$result = $query->execute();
foreach ($result as $record) {
watchdog('ryzommanage_usersync', $record->query, NULL, WATCHDOG_ERROR);
switch($record->type) {
case 'createPermissions':
case 'user_edit':
case 'createUser':
watchdog('ryzommanage_usersync', $record->type, NULL, WATCHDOG_INFO);
$SID = $record->SID;
$num_deleted = db_delete('ryzommanage_querycache')
->condition('SID', $SID)
->execute();
$func = $record->type;
$func(json_decode($record->query));
}
}
}
/**
*
* Function ryzommanage_cron
*
* @takes
* @return
*
* Info: Runs the syncdata function with the drupal cron
*
*/
function ryzommanage_cron() {
syncdata();
}

@ -1,116 +0,0 @@
<div class="title">
RYZOM CORE INGAME REGISTRATION
</div>
<div>
<?php echo $WELCOME_MESSAGE; ?>
</div>
<form name="Page1"
method="post"
action="register">
<table>
<tr>
<td width="33%" <?php if ($USERNAME_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Username">Desired Username: </td>
<td width="25%">
<input type="text"
name="Username"
value=""
maxlength="12"
onfocus=
"javascript:showTooltip('5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on.', this);" />
</td>
<td id="comment-Username" <?php if ($USERNAME_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($USERNAME_ERROR == "TRUE"){ echo $USERNAME;}?></td>
</tr>
<tr>
<td width="33%" <?php if ($PASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Password">Desired Password:</td>
<td width="25%">
<input type="password"
name="Password"
value=""
maxlength="20"
onkeyup=
"testPassword(document.Page1.Password.value, 'comment-Password')"
onfocus="javascript:showTooltip(' 5-20 characters.', this);" />
</td>
<td id="comment-Password" <?php if ($PASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($PASSWORD_ERROR == "TRUE"){ echo $PASSWORD;}?></td>
</tr>
<tr>
<td width="33%"<?php if ($CPASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-ConfirmPass">Confirm Password:</td>
<td width="25%"><input type="password"
name="ConfirmPass"
value=""
maxlength="20"
onfocus="javascript:showTooltip('Retype your Password', this);" />
</td>
<td id="comment-ConfirmPass" <?php if ($CPASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?>width="42%"><?php if ($CPASSWORD_ERROR == "TRUE"){ echo $CPASSWORD;}?></td>
</tr>
<tr>
<td width="33%" <?php if ($EMAIL_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Email">Email Address (to which a confirmation email will be sent):</td>
<td width="25%">
<input type="text"
name="Email"
value=""
maxlength="255"
onfocus=
"javascript:showTooltip('Please verify that the e-mail address you enter here is valid and will remain valid in the future. It will only be used to manage your <?php echo $GAME_NAME; ?> account.', this);" />
</td>
<td id="comment-Email" <?php if ($EMAIL_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($EMAIL_ERROR == "TRUE"){ echo $EMAIL;}?></td>
</tr>
<tr>
<td width=
"33%" <?php if ($TAC_ERROR == "TRUE"){ echo 'class="error"';}?>
colspan="2"><input type="checkbox"
name="TaC"
value="1"
onfocus="javascript:showTooltip('', this);" /><span id=
"caption-TaC">YES, I agree to the terms of
service</span></td><?php if ($TAC_ERROR == "TRUE"){
echo '<td id="comment-TaC" class="error" width="42%">You must accept the Terms of Service</td>';}
else {
echo '<td width="42%" id="comment-TaC" >';}; ?>
</tr>
</table>
<div class="c1">
<input type="submit"
name="Submit"
value="Continue" />
</div>
</form>
<div id="signupTooltip"
class="c2"
inset=""></div>
<div id="tooltip-Username">
5-12 lower-case characters and numbers. The login (username) you create here will be
your login name. The name of your game characters will be chosen later on.
</div>
<div id="tooltip-Password">
5-20 characters.
</div>
<div id="tooltip-ConfirmPass">
Retype your Password
</div>
<div id="tooltip-Email">
Please verify that the e-mail address you enter here is valid and will remain valid
in the future. It will be used to manage your <?php echo $GAME_NAME; ?> account.
</div>
<div id="tooltip-TaC"></div>

@ -1,161 +0,0 @@
{block name=content}
<tr><td>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr bgcolor="{$second_menu_bg_color}" valign="middle">
<td>
<table>
<tr>
<td>
<table cellspacing="0" cellpadding="4">
<tr>
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=show_user&id={$target_id}"><h7>Browse User</h7></a></td>
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=createticket&user_id={$target_id}"><h7>Send Ticket</h7></a></td>
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1}
{if $userPermission eq 1}
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=change_permission&user_id={$target_id}&value=2"><h7>Make Moderator</h7></a></td>
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=change_permission&user_id={$target_id}&value=3"><h7>Make Admin</h7></a></td>
{else if $userPermission eq 2 }
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=change_permission&user_id={$target_id}&value=1"><h7>Demote to User</h7></a></td>
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=change_permission&user_id={$target_id}&value=3"><h7>Make Admin</h7></a></td>
{else if $userPermission eq 3 }
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=change_permission&user_id={$target_id}&value=1"><h7>Demote to User</h7></a></td>
<td valign="middle" nowrap><a href="{$ingame_webpath}?page=change_permission&user_id={$target_id}&value=2"><h7>Demote to Moderator</h7></a></td>
{/if}
{/if}
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="3" bgcolor="#000000"></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" bgcolor="{$title_bg_color}" cellspacing="2">
<tr><td height="7"></td><td></td></tr>
<tr>
<td width="3%"></td>
<td width="100%" height="12" valign="middle"><h1>Change Settings of {$target_username}</h1></td>
</tr>
<tr>
<td height="5"></td><td></td>
</tr>
</table>
</td></tr>
<tr><td>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr bgcolor="#000000" valign="middle">
<td>
<table>
<tr><td height="8"></td></tr>
</table>
</td>
</tr>
<tr><td height="2"></td></tr>
<tr><td height="1" bgcolor="#000000"></td></tr>
<tr><td height="10"></td></tr>
<tr valign="middle">
<td>
<table width="100%" height="100%" cellpadding="10">
<tr><td>
<table width="100%" bgcolor="{$main_tbl_color}" border="2">
<tr><td>
<table cellpadding="10">
<tr><td>
<p><h3>Change Password</h3></p>
<form id="changePassword" method="post" action="{$ingame_webpath}?page=settings&id={$target_id}">
<table cellpadding="1">
{if !isset($changesOther) or $changesOther eq "FALSE"}
<tr>
<td valign="middle">
Current Password:
</td>
<td>
<input type="text" id="CurrentPass" name="CurrentPass" {if isset($prevCurrentPass)}value="{$prevCurrentPass}"{/if}>
{if isset($MATCH_ERROR) and $MATCH_ERROR eq "TRUE"}<font color="red">The password is incorrect</font>{/if}
</td>
</p>
</tr>
{/if}
<tr><td valign="middle">
New Password:
</td><td>
<input type="text" class="input-xlarge" id="NewPass" name="NewPass" placeholder="Your new password" {if isset($prevNewPass)}value="{$prevNewPass}"{/if}>
{if isset($NEWPASSWORD_ERROR) and $NEWPASSWORD_ERROR eq "TRUE"}<font color="red">{$newpass_error_message}</font>{/if}
</td></tr>
<tr><td valign="middle">
Confirm New Password:
</td><td>
<input type="text" class="input-xlarge" id="ConfirmNewPass" name="ConfirmNewPass" placeholder="Re-enter the new password" {if isset($prevConfirmNewPass)}value="{$prevConfirmNewPass}"{/if}>
{if isset($CNEWPASSWORD_ERROR) and $CNEWPASSWORD_ERROR eq "TRUE"}<font color="red">{$confirmnewpass_error_message}</font>{/if}
</td></tr>
</table>
{if isset($SUCCESS_PASS) and $SUCCESS_PASS eq "OK"}
<p><font color="green">
The password has been changed!
</font></p>
{/if}
<input type="hidden" name="function" value="change_password">
<input type="hidden" name="target_id" value="{$target_id}">
<p><input type="submit" value="Change Password"/></p>
</form>
</td></tr>
</table>
</td></tr>
</table>
</td></tr>
<tr><td>
<table width="100%" bgcolor="{$main_tbl_color}" border="2">
<tr><td>
<table cellpadding="10">
<tr><td>
<p><h3>Change Email</h3></p>
<form id="changeEmail" class="form-vertical" method="post" action="{$ingame_webpath}?page=settings&id={$target_id}">
<table>
<tr><td valign="middle">
New Email:
</td><td>
<input type="text" class="input-xlarge" id="NewEmail" size="200" name="NewEmail" placeholder="Your new email" {if isset($prevNewEmail)}value="{$prevNewEmail}"{else if isset($current_mail)}value="{$current_mail}"{/if}>
{if isset($EMAIL_ERROR) and $EMAIL_ERROR eq "TRUE"}<font color="red">{$EMAIL}</font>{/if}
</td></tr>
</table>
{if isset($SUCCESS_MAIL) and $SUCCESS_MAIL eq "OK"}
<p>
<font color="green">The email has been changed!</green>
</p>
{/if}
<input type="hidden" name="function" value="change_mail">
<input type="hidden" name="target_id" value="{$target_id}">
<p>
<input type="submit" value="Change Email"/>
</p>
</form>
</td></tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
</td>
</tr>
</table>
</td></tr>
{/block}

@ -1,327 +0,0 @@
<?php
/**
* handles CMS/WWW related functions regarding user management & registration.
* inherits from the Users class. The methods of this class have to be rewritten according to the CMS's functionality that you wish to use.
* The drupal_module has a webusers class of its own in the module itself.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
class WebUsers extends Users{
private $uId; /**< The user id */
private $login; /**< The username */
private $email; /**< The email address */
private $firstname; /**< The users first name */
private $lastname; /**< The users last name */
private $gender; /**< The gender */
private $country; /**< 2 letter word matching the country of the user */
private $receiveMail; /**< configuration regarding if the user wants to receive email notifications or not. */
private $language; /**< Language of the user */
/**
* A constructor.
* loads the object with the UID, if none is given it will use 0.
* @param $UId the UID of the user you want to instantiate.
*/
function __construct($UId = 0) {
$this->uId = $UId;
}
/**
* sets the object's attributes.
* @param $values should be an array.
*/
public function set($values){
$this->uId = $values['uid'];
$this->login = $values['name'];
$this->email = $values['mail'];
//$this->firstname = $values['FirstName'];
//$this->lastname = $values['LastName'];
//$this->gender = $values['Gender'];
//$this->country = $values['Country'];
//$this->receiveMail = $values['ReceiveMail'];
//$this->language = $values['Language'];
}
/**
* function that checks if a username exists already or not.
* This function overrides the function of the base class.
* @param $username the username in question
* @return string Info: Returns 0 if the user is not in the web db, else a positive number is returned.
*/
protected function checkUserNameExists($username){
return db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array(':name' => $username))->fetchField();
}
/**
* function that checks if a email exists already or not.
* This function overrides the function of the base class.
* @param $email the email address in question.
* @return string Info: Returns 0 if the email address is not in the web db, else a positive number is returned.
*/
protected function checkEmailExists($email){
return db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(':mail' => $email))->fetchField();
}
/**
* check if the login username and password match the db.
* @param $username the inserted username
* @param $password the inserted password (unhashed)
* @return the logged in user's db row as array if login was a success, else "fail" will be returned.
*/
public static function checkLoginMatch($username,$password){
if(!user_authenticate($username, $password)){
return 'fail';
}else{
return db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc();
}
}
/**
* returns te id for a given username
* @param $username the username
* @return the user's id linked to the username
*/
public static function getId($username){
$row = db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username))->fetchAssoc();
return $row['uid'];
}
/**
* returns te id for a given emailaddress
* @param $email the emailaddress
* @return the user's id linked to the emailaddress
*/
public static function getIdFromEmail($email){
$dbw = new DBLayer("web");
$statement = $dbw->execute("SELECT * FROM ams_user WHERE Email=:email", array('email' => $email));
$row = $statement->fetch();
if(!empty($row)){
return $row['UId'];
}else{
return "FALSE";
}
}
/**
* get uId attribute of the object.
*/
public function getUId(){
return $this->uId;
}
/**
* get login attribute of the object.(username)
*/
public function getUsername(){
if(! isset($this->login) || $this->login == ""){
$row = db_query("SELECT * FROM {users} WHERE uid = :id", array(':id' => $this->uId))->fetchAssoc();
$this->set($row);
}
return $this->login;
}
/**
* get email attribute of the object.
*/
public function getEmail(){
if(! isset($this->email) || $this->email == ""){
$row = db_query("SELECT * FROM {users} WHERE uid = :id", array(':id' => $this->uId))->fetchAssoc();
$this->set($row);
}
return $this->email;
}
/**
* get basic info of the object.
* @return returns an array in the form of Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country, 'ReceiveMail' => $this->receiveMail)
*/
public function getInfo(){
$dbw = new DBLayer("web");
if(! (isset($this->firstname) && isset($this->lastname) && isset($this->gender) && isset($this->country) && isset($this->receiveMail) ) ||
$this->firstname == "" || $this->lastname == "" || $this->gender == "" || $this->country == "" || $this->receiveMail == ""){
$statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId));
$row = $statement->fetch();
$this->set($row);
}
$result = Array('FirstName' => $this->firstname, 'LastName' => $this->lastname, 'Gender' => $this->gender, 'Country' => $this->country, 'ReceiveMail' => $this->receiveMail);
return $result;
}
/**
* get receiveMail attribute of the object.
*/
public function getReceiveMail(){
$dbw = new DBLayer("web");
if(! isset($this->receiveMail) || $this->receiveMail == ""){
$statement = $dbw->execute("SELECT * FROM ams_user WHERE UId=:id", array('id' => $this->uId));
$row = $statement->fetch();
$this->set($row);
}
return $this->receiveMail;
}
/**
* get language attribute of the object.
*/
public function getLanguage(){
return $DEFAULT_LANGUAGE;
}
/**
* check if the user is logged in.
* @return true or false
*/
public static function isLoggedIn(){
if(isset($_SESSION['user'])){
return true;
}
return false;
}
/**
* update the password.
* update the password in the shard + update the password in the www/CMS version.
* @param $user the username
* @param $pass the new password.
* @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
*/
public static function setPassword($user, $pass){
$hashpass = crypt($pass, WebUsers::generateSALT());
$reply = WebUsers::setAmsPassword($user, $hashpass);
$drupal_pass = user_hash_password($pass);
$values = Array('user' => $user, 'pass' => $drupal_pass);
try {
//make connection with and put into shard db
db_query("UPDATE {users} SET pass = :pass WHERE name = :user", $values);
}
catch (PDOException $e) {
//ERROR: the web DB is offline
}
return $reply;
}
/**
* update the emailaddress.
* update the emailaddress in the shard + update the emailaddress in the www/CMS version.
* @param $user the username
* @param $mail the new emailaddress.
* @return ok if it worked, if the lib or shard is offline it will return liboffline or shardoffline.
*/
public static function setEmail($user, $mail){
$reply = WebUsers::setAmsEmail($user, $mail);
$values = Array('user' => $user, 'mail' => $mail);
try {
//make connection with and put into shard db
db_query("UPDATE {users} SET mail = :mail WHERE name = :user", $values);
}
catch (PDOException $e) {
//ERROR: the web DB is offline
}
return $reply;
}
/**
* update the setReceiveMail value in the db.
* update the receiveMail in the www/CMS version.
* @param $user the username
* @param $receivemail the receivemail setting .
*/
public static function setReceiveMail($user, $receivemail){
$values = Array('user' => $user, 'receivemail' => $receivemail);
try {
//make connection with and put into shard db
$dbw = new DBLayer("web");
$dbw->execute("UPDATE ams_user SET ReceiveMail = :receivemail WHERE UId = :user ",$values);
}
catch (PDOException $e) {
//ERROR: the web DB is offline
}
}
/**
* update the language value in the db.
* update the language in the www/CMS version.
* @param $user the username
* @param $language the new language value.
*/
public static function setLanguage($user, $language){
$values = Array('user' => $user, 'language' => $language);
try {
//make connection with and put into shard db
$dbw = new DBLayer("web");
$dbw->execute("UPDATE ams_user SET Language = :language WHERE UId = :user ",$values);
}
catch (PDOException $e) {
//ERROR: the web DB is offline
}
}
/**
* return all users.
* @return return an array of users
*/
public function getUsers(){
$dbl = new DBLayer("web");
$data = $dbl->executeWithoutParams("SELECT * FROM ams_user");
return $data;
}
/**
* return the query that should get all users.
* @return string: the query to receive all users.
*/
public static function getAllUsersQuery(){
return "SELECT * FROM users WHERE `uid` > 0";
}
/**
* creates a webuser.
* it will set the language matching to the language cookie setting and add it to the www/CMS's DB.
* @param $name the username
* @param $pass the unhashed password
* @param $mail the email address
*/
public static function createWebuser($name, $pass, $mail){
//register account with the correct language (check if cookie is already set)!
if ( isset( $_COOKIE['Language'] ) ) {
$lang = $_COOKIE['Language'];
}else{
global $DEFAULT_LANGUAGE;
$lang = $DEFAULT_LANGUAGE;
}
$values = Array('name' => $name, 'pass' => $pass, 'mail' => $mail, 'lang' => $lang);
try {
$dbw = new DBLayer("web");
return $dbw->executeReturnId("INSERT INTO ams_user (Login, Password, Email, Language) VALUES (:name, :pass, :mail, :lang)",$values);
}
catch (PDOException $e) {
//ERROR: the web DB is offline
}
}
}

@ -1,111 +0,0 @@
<?php
/**
* This file contains all variables needed by other php scripts.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
// Variables for database access to the CMS/WWW database
$cfg['db']['web']['host'] = variable_get('ryzommanage_webserverurl', 'localhost');
$cfg['db']['web']['port'] = variable_get('ryzommanage_webmysqlport', '3306');
$cfg['db']['web']['name'] = variable_get('ryzommanage_webdbname', 'drupal');
$cfg['db']['web']['user'] = variable_get('ryzommanage_webusername', 'shard');
$cfg['db']['web']['pass'] = variable_get('ryzommanage_webpassword', '');
// Variables for database access to the lib database
$cfg['db']['lib']['host'] = variable_get('ryzommanage_libserverurl', 'localhost');
$cfg['db']['lib']['port'] = variable_get('ryzommanage_libmysqlport', '3306');
$cfg['db']['lib']['name'] = variable_get('ryzommanage_libdbname', 'ryzom_ams_lib');
$cfg['db']['lib']['user'] = variable_get('ryzommanage_libusername', 'shard');
$cfg['db']['lib']['pass'] = variable_get('ryzommanage_libpassword', '');
// Variables for database access to the shard database
$cfg['db']['shard']['host'] = variable_get('ryzommanage_shardserverurl', 'localhost');
$cfg['db']['shard']['port'] = variable_get('ryzommanage_shardmysqlport', '3306');
$cfg['db']['shard']['name'] = variable_get('ryzommanage_sharddbname', 'nel');
$cfg['db']['shard']['user'] = variable_get('ryzommanage_shardusername', 'shard');
$cfg['db']['shard']['pass'] = variable_get('ryzommanage_shardpassword', '');
// Variables for database access to the open_ring database
$cfg['db']['ring']['host'] = variable_get('ryzommanage_ringserverurl', 'localhost');
$cfg['db']['ring']['port'] = variable_get('ryzommanage_ringmysqlport', '3306');
$cfg['db']['ring']['name'] = variable_get('ryzommanage_ringdbname', 'ring_open');
$cfg['db']['ring']['user'] = variable_get('ryzommanage_ringusername', 'shard');
$cfg['db']['ring']['pass'] = variable_get('ryzommanage_ringpassword', '');
// To connect to an IMAP server running on port 143 on the local machine,
// do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password");
// POP3 server on port 110: $mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
// SSL IMAP or POP3 server, add /ssl after the protocol: $mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");
// To connect to an SSL IMAP or POP3 server with a self-signed certificate,
// add /ssl/novalidate-cert after the protocol specification:
// $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");
// NNTP server on port 119 use: $nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
// To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to.
//$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX';
//imap connection string as explained above
$cfg['mail']['default_mailserver']= '{imap.gmail.com:993/imap/ssl}INBOX';
//groupemail is the email that sends the email
$cfg['mail']['default_groupemail'] = 'example@gmail.com';
//groupname will be the name displayed as sender
$cfg['mail']['default_groupname'] = 'Ryzomcore Support';
//the username of the account
$cfg['mail']['default_username'] = 'example@gmail.com';
//the matching password
$cfg['mail']['default_password'] = 'lol123bol';
//the host, being used when a mail is sent from a support group: support_groups_name@host
$cfg['mail']['host'] = "ryzomcore.com";
//Defines mailing related stuff
$SUPPORT_GROUP_IMAP_CRYPTKEY = "azerty";
$TICKET_MAILING_SUPPORT = false;
//You have to create this dir at first!
//The incoming emails will be backed up here and the log file keeps track of the mail_cron job.
$MAIL_DIR = "/home/username/mail";
$MAIL_LOG_PATH = "/home/username/mail/cron_mail.log";
//crypt is being used by encrypting & decrypting of the IMAP password of the supportgroups
$cfg['crypt']['key'] = 'Sup3rS3cr3tStuff';
$cfg['crypt']['enc_method'] = 'AES-256-CBC';
$cfg['crypt']['hash_method'] = "SHA512";
//terms of service url location
$TOS_URL = variable_get('ryzommanage_TOS', 'http://www.gnu.org/licenses/agpl-3.0.html');
//-----------------------------------------------------------------------------------------
// If true= the server will add automatically unknown user in the database
// (in nel.user= nel.permission= ring.ring_user and ring.characters
$ALLOW_UNKNOWN = true ;
// if true= the login service automaticaly create a ring user and a editor character if needed
$CREATE_RING = true ;
// site paths definitions, you shouldn't have to alter these!
$AMS_LIB = dirname( __FILE__ ) . '/ams_lib';
$AMS_TRANS = $AMS_LIB . '/translations';
$AMS_CACHEDIR = $AMS_LIB . '/cache';
$SITEBASE = dirname( __FILE__ );
//the paths to your website url
$BASE_WEBPATH = 'http://localhost:40917/drupal';
$IMAGELOC_WEBPATH = $BASE_WEBPATH. '/sites/all/modules/ryzommanage/ams_lib/img' ;
$WEBPATH = $BASE_WEBPATH .'/ams';
$INGAME_WEBPATH = $BASE_WEBPATH . '/ingame';
$CONFIG_PATH = dirname( __FILE__ );
//defines the default language
$DEFAULT_LANGUAGE = 'en';
//defines if logging actions should happen or not.
$TICKET_LOGGING = false;
//defines the time format display
$TIME_FORMAT = "m-d-Y H:i:s";
//defines which ingame layout template should be used
$INGAME_LAYOUT = "basic";
//forces to load the ingame templates if set to true
$FORCE_INGAME = false;

@ -1,9 +0,0 @@
<?php
function logout(){
session_unset();
session_destroy();
global $INGAME_WEBPATH;
header("Location: ". $INGAME_WEBPATH);
exit;
}

@ -1,298 +0,0 @@
<?php
function settings(){
if(WebUsers::isLoggedIn()){
//in case id-GET param set it's value as target_id, if no id-param is given, ue the session id.
if(isset($_GET['id'])){
if(($_GET['id'] != $_SESSION['id']) && (!Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) ){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
}else{
$webUser = new Webusers($_GET['id']);
//$result = $webUser->getInfo();
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) && ($_GET['id']!= $_SESSION['id'])){
$result['changesOther'] = "TRUE";
}
$result['target_id'] = $_GET['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
}else{
$webUser = new Webusers($_SESSION['id']);
//$result = $webUser->getInfo();
$result['target_id'] = $_SESSION['id'];
$result['current_mail'] = $webUser->getEmail();
$result['target_username'] = $webUser->getUsername();
}
//Sanitize Data
$result['current_mail'] = filter_var($result['current_mail'], FILTER_SANITIZE_EMAIL);
$result['target_username'] = filter_var($result['target_username'], FILTER_SANITIZE_STRING);
//$result['FirstName'] = filter_var($result['FirstName'], FILTER_SANITIZE_STRING);
//$result['LastName'] = filter_var($result['LastName'], FILTER_SANITIZE_STRING);
//$result['Country'] = filter_var($result['Country'], FILTER_SANITIZE_STRING);
//$result['Gender'] = filter_var($result['Gender'], FILTER_SANITIZE_NUMBER_INT);
//$result['ReceiveMail'] = filter_var($result['ReceiveMail'], FILTER_SANITIZE_NUMBER_INT);
//$result['country_array'] = getCountryArray();
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
}
}
function getCountryArray(){
$countries = array(
'AA'=>'None Selected',
'AF'=>'Afghanistan',
'AL'=>'Albania',
'DZ'=>'Algeria',
'AS'=>'American Samoa',
'AD'=>'Andorra',
'AO'=>'Angola',
'AI'=>'Anguilla',
'AQ'=>'Antarctica',
'AG'=>'Antigua And Barbuda',
'AR'=>'Argentina',
'AM'=>'Armenia',
'AW'=>'Aruba',
'AU'=>'Australia',
'AT'=>'Austria',
'AZ'=>'Azerbaijan',
'BS'=>'Bahamas',
'BH'=>'Bahrain',
'BD'=>'Bangladesh',
'BB'=>'Barbados',
'BY'=>'Belarus',
'BE'=>'Belgium',
'BZ'=>'Belize',
'BJ'=>'Benin',
'BM'=>'Bermuda',
'BT'=>'Bhutan',
'BO'=>'Bolivia',
'BA'=>'Bosnia And Herzegovina',
'BW'=>'Botswana',
'BV'=>'Bouvet Island',
'BR'=>'Brazil',
'IO'=>'British Indian Ocean Territory',
'BN'=>'Brunei',
'BG'=>'Bulgaria',
'BF'=>'Burkina Faso',
'BI'=>'Burundi',
'KH'=>'Cambodia',
'CM'=>'Cameroon',
'CA'=>'Canada',
'CV'=>'Cape Verde',
'KY'=>'Cayman Islands',
'CF'=>'Central African Republic',
'TD'=>'Chad',
'CL'=>'Chile',
'CN'=>'China',
'CX'=>'Christmas Island',
'CC'=>'Cocos (Keeling) Islands',
'CO'=>'Columbia',
'KM'=>'Comoros',
'CG'=>'Congo',
'CK'=>'Cook Islands',
'CR'=>'Costa Rica',
'CI'=>'Cote D\'Ivorie (Ivory Coast)',
'HR'=>'Croatia (Hrvatska)',
'CU'=>'Cuba',
'CY'=>'Cyprus',
'CZ'=>'Czech Republic',
'CD'=>'Democratic Republic Of Congo (Zaire)',
'DK'=>'Denmark',
'DJ'=>'Djibouti',
'DM'=>'Dominica',
'DO'=>'Dominican Republic',
'TP'=>'East Timor',
'EC'=>'Ecuador',
'EG'=>'Egypt',
'SV'=>'El Salvador',
'GQ'=>'Equatorial Guinea',
'ER'=>'Eritrea',
'EE'=>'Estonia',
'ET'=>'Ethiopia',
'FK'=>'Falkland Islands (Malvinas)',
'FO'=>'Faroe Islands',
'FJ'=>'Fiji',
'FI'=>'Finland',
'FR'=>'France',
'FX'=>'France, Metropolitan',
'GF'=>'French Guinea',
'PF'=>'French Polynesia',
'TF'=>'French Southern Territories',
'GA'=>'Gabon',
'GM'=>'Gambia',
'GE'=>'Georgia',
'DE'=>'Germany',
'GH'=>'Ghana',
'GI'=>'Gibraltar',
'GR'=>'Greece',
'GL'=>'Greenland',
'GD'=>'Grenada',
'GP'=>'Guadeloupe',
'GU'=>'Guam',
'GT'=>'Guatemala',
'GN'=>'Guinea',
'GW'=>'Guinea-Bissau',
'GY'=>'Guyana',
'HT'=>'Haiti',
'HM'=>'Heard And McDonald Islands',
'HN'=>'Honduras',
'HK'=>'Hong Kong',
'HU'=>'Hungary',
'IS'=>'Iceland',
'IN'=>'India',
'ID'=>'Indonesia',
'IR'=>'Iran',
'IQ'=>'Iraq',
'IE'=>'Ireland',
'IL'=>'Israel',
'IT'=>'Italy',
'JM'=>'Jamaica',
'JP'=>'Japan',
'JO'=>'Jordan',
'KZ'=>'Kazakhstan',
'KE'=>'Kenya',
'KI'=>'Kiribati',
'KW'=>'Kuwait',
'KG'=>'Kyrgyzstan',
'LA'=>'Laos',
'LV'=>'Latvia',
'LB'=>'Lebanon',
'LS'=>'Lesotho',
'LR'=>'Liberia',
'LY'=>'Libya',
'LI'=>'Liechtenstein',
'LT'=>'Lithuania',
'LU'=>'Luxembourg',
'MO'=>'Macau',
'MK'=>'Macedonia',
'MG'=>'Madagascar',
'MW'=>'Malawi',
'MY'=>'Malaysia',
'MV'=>'Maldives',
'ML'=>'Mali',
'MT'=>'Malta',
'MH'=>'Marshall Islands',
'MQ'=>'Martinique',
'MR'=>'Mauritania',
'MU'=>'Mauritius',
'YT'=>'Mayotte',
'MX'=>'Mexico',
'FM'=>'Micronesia',
'MD'=>'Moldova',
'MC'=>'Monaco',
'MN'=>'Mongolia',
'MS'=>'Montserrat',
'MA'=>'Morocco',
'MZ'=>'Mozambique',
'MM'=>'Myanmar (Burma)',
'NA'=>'Namibia',
'NR'=>'Nauru',
'NP'=>'Nepal',
'NL'=>'Netherlands',
'AN'=>'Netherlands Antilles',
'NC'=>'New Caledonia',
'NZ'=>'New Zealand',
'NI'=>'Nicaragua',
'NE'=>'Niger',
'NG'=>'Nigeria',
'NU'=>'Niue',
'NF'=>'Norfolk Island',
'KP'=>'North Korea',
'MP'=>'Northern Mariana Islands',
'NO'=>'Norway',
'OM'=>'Oman',
'PK'=>'Pakistan',
'PW'=>'Palau',
'PA'=>'Panama',
'PG'=>'Papua New Guinea',
'PY'=>'Paraguay',
'PE'=>'Peru',
'PH'=>'Philippines',
'PN'=>'Pitcairn',
'PL'=>'Poland',
'PT'=>'Portugal',
'PR'=>'Puerto Rico',
'QA'=>'Qatar',
'RE'=>'Reunion',
'RO'=>'Romania',
'RU'=>'Russia',
'RW'=>'Rwanda',
'SH'=>'Saint Helena',
'KN'=>'Saint Kitts And Nevis',
'LC'=>'Saint Lucia',
'PM'=>'Saint Pierre And Miquelon',
'VC'=>'Saint Vincent And The Grenadines',
'SM'=>'San Marino',
'ST'=>'Sao Tome And Principe',
'SA'=>'Saudi Arabia',
'SN'=>'Senegal',
'SC'=>'Seychelles',
'SL'=>'Sierra Leone',
'SG'=>'Singapore',
'SK'=>'Slovak Republic',
'SI'=>'Slovenia',
'SB'=>'Solomon Islands',
'SO'=>'Somalia',
'ZA'=>'South Africa',
'GS'=>'South Georgia And South Sandwich Islands',
'KR'=>'South Korea',
'ES'=>'Spain',
'LK'=>'Sri Lanka',
'SD'=>'Sudan',
'SR'=>'Suriname',
'SJ'=>'Svalbard And Jan Mayen',
'SZ'=>'Swaziland',
'SE'=>'Sweden',
'CH'=>'Switzerland',
'SY'=>'Syria',
'TW'=>'Taiwan',
'TJ'=>'Tajikistan',
'TZ'=>'Tanzania',
'TH'=>'Thailand',
'TG'=>'Togo',
'TK'=>'Tokelau',
'TO'=>'Tonga',
'TT'=>'Trinidad And Tobago',
'TN'=>'Tunisia',
'TR'=>'Turkey',
'TM'=>'Turkmenistan',
'TC'=>'Turks And Caicos Islands',
'TV'=>'Tuvalu',
'UG'=>'Uganda',
'UA'=>'Ukraine',
'AE'=>'United Arab Emirates',
'UK'=>'United Kingdom',
'US'=>'United States',
'UM'=>'United States Minor Outlying Islands',
'UY'=>'Uruguay',
'UZ'=>'Uzbekistan',
'VU'=>'Vanuatu',
'VA'=>'Vatican City (Holy See)',
'VE'=>'Venezuela',
'VN'=>'Vietnam',
'VG'=>'Virgin Islands (British)',
'VI'=>'Virgin Islands (US)',
'WF'=>'Wallis And Futuna Islands',
'EH'=>'Western Sahara',
'WS'=>'Western Samoa',
'YE'=>'Yemen',
'YU'=>'Yugoslavia',
'ZM'=>'Zambia',
'ZW'=>'Zimbabwe'
);
return $countries;
}

@ -1,46 +0,0 @@
<?php
function show_user(){
//if logged in
if(WebUsers::isLoggedIn()){
if( !isset($_GET['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id'] ){
if(isset($_GET['id'])){
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
}else{
$result['target_id'] = $_SESSION['id'];
}
$webUser = new WebUsers($result['target_id']);
$result['target_name'] = $webUser->getUsername();
$result['mail'] = $webUser->getEmail();
//$info = $webUser->getInfo();
//$result['firstName'] = $info['FirstName'];
//$result['lastName'] = $info['LastName'];
//$result['country'] = $info['Country'];
//$result['gender'] = $info['Gender'];
$ticket_user = Ticket_User::constr_ExternId($result['target_id']);
$result['userPermission'] = $ticket_user->getPermission();
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE";
}
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId());
$result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category"));
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
}
}

@ -1,11 +0,0 @@
; $Id$
name = Ryzom Account Manager
description = Ryzom Login Service Integration - inserts and updates users and manages accounts.
core = 7.x
package = Ryzom Plugins
configure = admin/settings/ryzommanage
; Information added by drupal.org packaging script on 2012-04-24
version = "7.x-.01"
core = "7.x"

@ -1,31 +0,0 @@
<?php
// $id$
/**
* @file
* Medals module install file.
*/
function ryzommanage_install() {
$vocab = array(
'name' => 'Ryzom Manager',
'machine_name' => 'ryzommanage',
'description' => 'Ryzom Login Service integration - inserts and updates users and manages accounts.',
'module' => 'ryzommanage',
);
$vocab = (object) $vocab;
db_query("CREATE TABLE ryzommanage_querycache (
`SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`type` VARCHAR( 64 ) NOT NULL ,
`query` VARCHAR( 512 ) NOT NULL
);");
}
function ryzommanage_uninstall() {
db_query("DROP TABLE ryzommanage_querycache;");
}
function _ryzommanage_vocab_fields() {
}

@ -1,38 +0,0 @@
{block name=content}
<h2>Create a new Ticket</h2>
<form id="changePassword" method="post" action="ams?page=createticket&id={$target_id}">
<table>
<tr>
<td>
<label>Title</label>
<input type="text" size="60" id="Title" name="Title">
</td>
</tr>
<tr>
<td>
<label>Category</label>
<select name="Category">
{foreach from=$category key=k item=v}
<option value="{$k}">{$v}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td>
<label>Description</label>
<textarea rows="12" id="Content" style="width: 90%;" name="Content"></textarea>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="function" value="create_ticket">
<input type="hidden" name="target_id" value="{$target_id}">
<button type="submit">Send Ticket</button>
</td>
</tr>
</table>
</form>
{/block}

@ -1,77 +0,0 @@
{block name=content}
<table width="100%">
<tr>
<td width="25%">
<a data-original-title="{$nrAssignedWaiting} Assigned to you and waiting for support!" data-rel="tooltip" class="well span3 top-block"
href="ams?page=show_queue&get=create&userid={$user_id}&groupid=1&what=waiting_for_support&how=assigned&who=user">
<div style="text-align:center;">Tickets Waiting for Direct Action:
<font color="red">{$nrAssignedWaiting}</font></div>
</a>
</td>
<td width="25%">
<a data-original-title="{$nrToDo} Tickets Todo." data-rel="tooltip" class="well span3 top-block" href="ams?page=show_queue&get=todo">
<div style="text-align:center;">Tickets Todo:
<font color="red">{$nrToDo}</font></div>
</a>
</td>
<td width="25">
<a data-original-title="By {$newestTicketAuthor}" data-rel="tooltip" class="well span3 top-block" href="ams?page=show_ticket&id={$newestTicketId}">
<div style="text-align:center;">Newest Ticket:
<font color="red">{$newestTicketTitle}</font></div>
</a>
</td>
<td width="25%">
<a data-original-title="{$nrTotalTickets} tickets in total" data-rel="tooltip" class="well span3 top-block" href="ams?page=show_queue&get=all">
<div style="text-align:center;">Total amount of Tickets:
<font color="red">{$nrTotalTickets}</font></div>
</a>
</td>
</tr>
</table>
<div class="row-fluid">
<div class="box span12">
<div class="box-header well">
<h2><i class="icon-info-sign"></i> {$home_title}</h2>
<div class="box-icon">
<a href="#" class="btn btn-round" onclick="javascript:show_help('intro');return false;"><i class="icon-info-sign"></i></a>
<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
</div>
</div>
<div class="box-content">
<p><strong>{$home_info}</strong></p>
<p>This is the GSOC project of Daan Janssens mentored by Matthew Lagoe.</p>
<p>The features as admin covered in this project are:</p>
<ul>
<li>Manage user accounts</li>
<li>Make users moderator or admin</li>
<li>browse user's tickets</li>
<li>Create a new ticket for a specific user as admin</li>
<li>Create a new support group (and link an email to it)</li>
<li>Add mods to support groups</li>
<li>Assign ticket to you</li>
<li>Forward ticket to a support group</li>
<li>Add hidden messages to a ticket only viewable by other mods</li>
<li>Browse ticket queues or create one dynamically</li>
<li>Sync changes after the game server is back up after being down for a while</li>
<li>Browse the log of a ticket</li>
<li>Browse additional info sent along when a ticket is created ingame</li>
<li>All the above can be done while ingame too</li>
</ul>
<div class="clearfix"></div>
</div>
</div>
</div>
{/block}

@ -1,116 +0,0 @@
<div class="title">
RYZOM CORE INGAME REGISTRATION
</div>
<div>
<?php echo $WELCOME_MESSAGE; ?>
</div>
<form name="Page1"
method="post"
action="register">
<table>
<tr>
<td width="33%" <?php if ($USERNAME_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Username">Desired Username: </td>
<td width="25%">
<input type="text"
name="Username"
value=""
maxlength="12"
onfocus=
"javascript:showTooltip('5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on.', this);" />
</td>
<td id="comment-Username" <?php if ($USERNAME_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($USERNAME_ERROR == "TRUE"){ echo $USERNAME;}?></td>
</tr>
<tr>
<td width="33%" <?php if ($PASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Password">Desired Password:</td>
<td width="25%">
<input type="password"
name="Password"
value=""
maxlength="20"
onkeyup=
"testPassword(document.Page1.Password.value, 'comment-Password')"
onfocus="javascript:showTooltip(' 5-20 characters.', this);" />
</td>
<td id="comment-Password" <?php if ($PASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($PASSWORD_ERROR == "TRUE"){ echo $PASSWORD;}?></td>
</tr>
<tr>
<td width="33%"<?php if ($CPASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-ConfirmPass">Confirm Password:</td>
<td width="25%"><input type="password"
name="ConfirmPass"
value=""
maxlength="20"
onfocus="javascript:showTooltip('Retype your Password', this);" />
</td>
<td id="comment-ConfirmPass" <?php if ($CPASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?>width="42%"><?php if ($CPASSWORD_ERROR == "TRUE"){ echo $CPASSWORD;}?></td>
</tr>
<tr>
<td width="33%" <?php if ($EMAIL_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Email">Email Address (to which a confirmation email will be sent):</td>
<td width="25%">
<input type="text"
name="Email"
value=""
maxlength="255"
onfocus=
"javascript:showTooltip('Please verify that the e-mail address you enter here is valid and will remain valid in the future. It will only be used to manage your <?php echo $GAME_NAME; ?> account.', this);" />
</td>
<td id="comment-Email" <?php if ($EMAIL_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($EMAIL_ERROR == "TRUE"){ echo $EMAIL;}?></td>
</tr>
<tr>
<td width=
"33%" <?php if ($TAC_ERROR == "TRUE"){ echo 'class="error"';}?>
colspan="2"><input type="checkbox"
name="TaC"
value="1"
onfocus="javascript:showTooltip('', this);" /><span id=
"caption-TaC">YES, I agree to the terms of
service</span></td><?php if ($TAC_ERROR == "TRUE"){
echo '<td id="comment-TaC" class="error" width="42%">You must accept the Terms of Service</td>';}
else {
echo '<td width="42%" id="comment-TaC" >';}; ?>
</tr>
</table>
<div class="c1">
<input type="submit"
name="Submit"
value="Continue" />
</div>
</form>
<div id="signupTooltip"
class="c2"
inset=""></div>
<div id="tooltip-Username">
5-12 lower-case characters and numbers. The login (username) you create here will be
your login name. The name of your game characters will be chosen later on.
</div>
<div id="tooltip-Password">
5-20 characters.
</div>
<div id="tooltip-ConfirmPass">
Retype your Password
</div>
<div id="tooltip-Email">
Please verify that the e-mail address you enter here is valid and will remain valid
in the future. It will be used to manage your <?php echo $GAME_NAME; ?> account.
</div>
<div id="tooltip-TaC"></div>

@ -1,105 +0,0 @@
{block name=content}
<h2>List of all Support Groups</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Tag</th>
<th>Email</th>
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<th>Action</th>{/if}
</tr>
</thead>
<tbody>
{foreach from=$grouplist item=group}
<tr>
<td>{$group.sGroupId}</td>
<td><a href ="ams?page=show_sgroup&id={$group.sGroupId}">{$group.name}</a></td>
<td class="center">{$group.tag}</td>
<td class="center">{$group.groupemail}</td>
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<td class="center"><a href="ams?page=sgroup_list&delete={$group.sGroupId}"><font color="red">Delete</font></a></td>{/if}
</tr>
{/foreach}
</tbody>
</table>
{if isset($isAdmin) && $isAdmin eq 'TRUE'}
<h2>Add a support group</h2>
<form id="addSGroup" class="form-vertical" method="post" action="ams?page=sgroup_list">
<table>
<tr>
<td>
<table>
<tr>
<td>
<label>Group name</label>
<input type="text" maxlength="20" id="Name" name="Name">
</td>
<td>
<label>Group Tag</label>
<input type="text" maxlength="4" id="Tag" name="Tag">
</td>
<td>
<label>Group EmailAddress</label>
<input type="text" id="GroupEmail" name="GroupEmail">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
<label>IMAP MailServer IP</label>
<input type="text" id="IMAP_MailServer" name="IMAP_MailServer">
</td>
<td>
<label class="control-label">IMAP Username</label>
<input type="text" id="IMAP_Username" name="IMAP_Username">
</td>
<td>
<label class="control-label">IMAP Password</label>
<input type="password" id="IMAP_Password" name="IMAP_Password">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="function" value="add_sgroup">
<button type="submit" class="btn btn-primary" >Add</button>
</td>
</tr>
</table>
</form>
{if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"}
<font color="green">
<p>{$group_success}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NAME_TAKEN"}
<font color="red">
<p>{$group_name_taken}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "TAG_TAKEN"}
<font color="red">
<p>{$group_tag_taken}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SIZE_ERROR"}
<font color="red">
<p>{$group_size_error}</p>
</font>
{/if}
{/if}
{/block}

@ -1,204 +0,0 @@
{block name=content}
<h1>Ticket Queue {$queue_view}</h1>
<table>
<tr>
<td>
<table>
<tr>
<td width=20%><a href="ams?page=show_queue&get=todo">Todo tickets</a></td>
<td width=20%><a href="ams?page=show_queue&get=all">All tickets</a></td>
<td width=20%><a href="ams?page=show_queue&get=all_open">All open tickets</a></td>
<td width=20%><a href="ams?page=show_queue&get=archive">Ticket Archive</a></td>
<td width=20%><a href="ams?page=show_queue&get=not_assigned">Not Assigned Tickets</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<form id="create_queue" class="form-vertical" method="post" action="ams?page=show_queue&get=create" style="margin:0px 0px 0px;">
<table>
<tr>
<td>
<table width=100%>
<tr>
<td>
Show
</td>
<td>
<select name="what">
<option value="all" {if isset($prev_created_what) and $prev_created_what eq "all"}selected="selected"{/if}>all</option>
<option value="waiting_for_support" {if isset($prev_created_what) and $prev_created_what eq "waiting_for_support"}selected="selected"{/if}>waiting for support</option>
<option value="waiting_for_users" {if isset($prev_created_what) and $prev_created_what eq "waiting_for_users"}selected="selected"{/if}>waiting for user</option>
<option value="closed" {if isset($prev_created_what) and $prev_created_what eq "closed"}selected="selected"{/if}>closed</option>
</select>
</td>
<td>
tickets
</td>
<td>
<select name="how">
<option value="assigned" {if isset($prev_created_how) and $prev_created_how eq "assigned"}selected="selected"{/if}>assigned</option>
<option value="not_assigned" {if isset($prev_created_how) and $prev_created_how eq "not_assigned"}selected="selected"{/if}>not assigned</option>
</select>
</td>
<td>
to
</td>
<td>
<select name="who" onchange="aimedforwhochanged(this.value);">
<option value="user" {if isset($prev_created_who) and $prev_created_who eq "user"}selected="selected"{/if}>user</option>
<option value="support_group" {if isset($prev_created_who) and $prev_created_who eq "support_group"}selected="selected"{/if}>support group</option>
</select>
</td>
<td>
<span id="userList" {if isset($prev_created_who) and $prev_created_who eq "user"}style="display:inline;"{else if isset($prev_created_who) and $prev_created_who eq "support_group"}style="display:none;"{else}style="display:inline;"{/if}>
<select name="userid">
{foreach from=$teamlist item=member}
<option value="{$member.tUserId}" {if isset($prev_created_userid)} {if $prev_created_userid eq $member.tUserId}selected="selected"{/if}{else if $user_id eq $member.tUserId}selected="selected"{/if}>{$member.name}</option>
{/foreach}
</select>
</span>
</td>
<td>
<span id="supportGroupList" {if isset($prev_created_who) and $prev_created_who eq "user"}style="display:none;"{else if isset($prev_created_who) and $prev_created_who eq "support_group"}style="display:inline;"{else}style="display:none;"{/if}>
<select name="groupid">
{foreach from=$grouplist item=group}
<option value="{$group.sGroupId}" {if isset($prev_created_groupid) and $prev_created_groupid eq $group.sGroupId}selected="selected"{/if}>{$group.name}</option>
{/foreach}
</select>
</span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="action" value="create_queue">
<button type="submit" style="bottom:4px; position:relative;">View</button>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
{if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"}
<font color="green">
{$success_assigned}
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"}
<font color="green">
{$success_unassigned}
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"}
<font color="red">
{$ticket_not_existing}
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"}
<font color="red">
{$ticket_already_assigned}
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"}
<font color="red">
{$ticket_not_assigned}
</font>
{/if}
</td>
</tr>
<tr>
<td>
<table width=100%>
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Assigned</th>
<th>Timestamp</th>
<th>Category</th>
<th>Status</th>
<th>SupportGroup</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{foreach from=$tickets item=ticket}
<tr>
<td>{$ticket.tId}</td>
<td><a href ="ams?page=show_ticket&id={$ticket.tId}">{$ticket.title}</a></td>
<td>{if $ticket.assignedText neq ""} <a href="ams?page=show_user&id={$ticket.assigned}">{$ticket.assignedText} {else}<i> {$not_assigned}</i> {/if}</td>
<td class="center"><span title="{$ticket.timestamp_elapsed}" data-rel="tooltip" data-placement="right">{$ticket.timestamp}</span></td>
<td class="center">{$ticket.category}</td>
<td class="center"><font color=" {if $ticket.status eq 0}green{else if $ticket.status eq 1}orange{else if $ticket.status eq 3}red{/if}"> {$ticket.statusText}</font></td>
<td class="center">
{if $ticket.forwardedGroupName eq "0"}
<i>{$public_sgroup}</i>
{else}
<span class="label label-info"><a href="ams?page=show_sgroup&id={$ticket.forwardedGroupId}">{$ticket.forwardedGroupName}</a></span>
{/if}
</td>
<td>
{if $ticket.assigned eq 0}
<form id="assign_ticket" class="form-vertical" method="post" action="{$getURL}" style="margin:0px 0px 0px;">
<input type="hidden" name="ticket_id" value="{$ticket.tId}">
<input type="hidden" name="action" value="assignTicket">
<button type="submit" class="btn btn-primary" ><i class="icon-flag icon-white"></i> Assign Ticket</button>
</form>
{else if $ticket.assigned eq $user_id}
<form id="assign_ticket" class="form-vertical" method="post" action="{$getURL}" style="margin:0px 0px 0px;">
<input type="hidden" name="ticket_id" value="{$ticket.tId}">
<input type="hidden" name="action" value="unAssignTicket">
<button type="submit" class="btn btn-warning" ><i class="icon-remove icon-white"></i> Remove Assign</button>
</form>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
<center>
<a href="{$pagination_base_link}&pagenum=1">&laquo;</a> |
{foreach from=$links item=link}
<a href="{$pagination_base_link}&pagenum={$link}">{if $link == $currentPage}<u>{/if}{$link}{if $link == $currentPage}</u>{/if}</a> |
{/foreach}
<a href="{$pagination_base_link}&pagenum={$lastPage}">&raquo;</a>
</center>
</td>
</tr>
</table>
<!----- /javascript for this page -->
<script type="text/javascript">
function aimedforwhochanged(value)
{
if (value == "user")
{
//hide the supportGroupList span
var elem = document.getElementById("supportGroupList");
elem.style.display="none";
var elem2 = document.getElementById("userList");
elem2.style.display="inline";
}
else if(value == "support_group")
{
//hide the userList span
var elem = document.getElementById("supportGroupList");
elem.style.display= "inline";
var elem2 = document.getElementById("userList");
elem2.style.display="none";
}
}
</script>
{/block}

@ -1,24 +0,0 @@
{block name=content}
<h1>Show Reply</h1>
<h2>Reply ID#{$reply_id} of Ticket <a href="ams?page=show_ticket&id={$ticket_id}">#{$ticket_id}</a></h2>
<table>
<tr>
<td>
<p><font color="blue"> {$reply_timestamp}</font>
{if $author_permission eq '1'}
<span class="label label-success"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$author}">{$authorName}{else} {$authorName} {/if}</a></strong></span></p>
{else if $author_permission gt '1'}
<span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$author}">{$authorName}{else} {$authorName} {/if}</a></strong></span></p>
{/if}
<p><pre{if $author_permission gt '1'} {if $hidden eq 0} style="background-color:rgb(248, 200, 200);"{else if $hidden eq 1}style="background-color:rgb(207, 254, 255);"{/if}{/if}> {if $hidden eq 1}<i>{/if}{$reply_content}{if $hidden eq 1}</i>{/if}</pre></p>
</td>
</tr>
</table>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}

@ -1,118 +0,0 @@
{block name=content}
<h2>{$groupsname} Members List</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<th>Action</th>{/if}
</tr>
</thead>
<tbody>
{foreach from=$userlist item=user}
<tr>
<td>{$user.tUserId}</td>
<td><a href ="ams?page=show_user&id={$user.tUserId}">{$user.name}</a></td>
{if isset($isAdmin) && $isAdmin eq 'TRUE'}<td class="center"><a href="ams?page=show_sgroup&id={$target_id}&delete={$user.tUserId}"><font color="red"> Delete</font></a></td>{/if}
</tr>
{/foreach}
</tbody>
</table>
{if isset($isAdmin) && $isAdmin eq 'TRUE'}
<h2>Add user to '{$groupsname}'</h2>
<table>
<tr>
<td>
<form id="addSGroup" class="form-vertical" method="post" action="ams?page=show_sgroup&id={$target_id}">
<label>Username:</label>
<input type="text" maxlength="15" id="Name" name="Name">
<input type="hidden" name="function" value="add_user_to_sgroup">
<input type="hidden" name="target_id" value="{$target_id}">
<button type="submit" class="btn btn-primary" >Add</button>
</form>
</td>
</tr>
</table>
{if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "SUCCESS"}
<font color="green">
<p>{$add_to_group_success}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "ALREADY_ADDED"}
<font color="red">
<p>{$user_already_added}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "GROUP_NOT_EXISTING"}
<font color="red">
<p>{$group_not_existing}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "USER_NOT_EXISTING"}
<font color="red">
<p>{$user_not_existing}</p>
</font>
{else if isset($RESULT_OF_ADDING) and $RESULT_OF_ADDING eq "NOT_MOD_OR_ADMIN"}
<font color="red">
<p>{$not_mod_or_admin}</p>
</font>
{/if}
<h2>Modify Email Settings</h2>
<form id="modifyMailSGroup" class="form-vertical" method="post" action="ams?page=show_sgroup&id={$target_id}">
<table>
<tr>
<td>
<label>Group Email</label>
<input type="text" id="GroupEmail" name="GroupEmail" value="{$groupemail}">
</td>
<td>
<label>IMAP Mail Server</label>
<input type="text" id="IMAP_MailServer" name="IMAP_MailServer" value="{$imap_mailserver}">
</td>
</tr>
<tr>
<td>
<label>IMAP Username</label>
<input type="text" id="IMAP_Username" name="IMAP_Username" value="{$imap_username}">
</td>
<td>
<label>IMAP Password</label>
<input type="password" id="IMAP_Password" name="IMAP_Password">
</td>
</tr>
<tr>
<td>
<input type="hidden" name="function" value="modify_email_of_sgroup">
<input type="hidden" name="target_id" value="{$target_id}">
<button type="submit" class="btn btn-primary" >Update</button>
</td>
<td></td>
</tr>
</table>
</form>
{if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "SUCCESS"}
<font color="green">
{$modify_mail_of_group_success}
</font>
{else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "EMAIL_NOT_VALID"}
<font color="red">
{$email_not_valid}
</font>
{else if isset($RESULT_OF_MODIFYING) and $RESULT_OF_MODIFYING eq "NO_PASSWORD"}
<font color="red">
{$no_password_given}
</font>
{/if}
{/if}
{/block}

@ -1,188 +0,0 @@
{block name=content}
<h1><u>Title</u>: {$ticket_title} [ID#{$ticket_tId}] </h1>
<table>
<tr>
{if isset($isMod) and $isMod eq "TRUE"}
<td>
Ticket Assigning:
{if $ticket_assignedTo eq 0}
<form id="assign_ticket" class="form-vertical" method="post" action="" >
<input type="hidden" name="ticket_id" value="{$ticket_tId}">
<input type="hidden" name="action" value="assignTicket">
<button type="submit">Assign Ticket</button>
</form>
{else if $ticket_assignedTo eq $user_id}
<form id="assign_ticket" class="form-vertical" method="post" action="" >
<input type="hidden" name="ticket_id" value="{$ticket_tId}">
<input type="hidden" name="action" value="unAssignTicket">
<button type="submit">Remove Assign</button>
</form>
{/if}
</td>
<td>
Forward to Group:
<form id="forward" class="form-vertical" method="post" action="">
<select name="group">
<option></option>
{foreach from=$sGroups key=k item=v}
<option value="{$k}">{$v}</option>
{/foreach}
</select>
<input type="hidden" name="ticket_id" value="{$ticket_tId}">
<input type="hidden" name="action" value="forward">
<button type="submit">Forward</button>
</form>
</td>
{/if}
{if isset($isMod) and $isMod eq "TRUE"}<td><a href="ams?page=show_ticket_log&id={$ticket_tId}">Show Ticket Log</a></td>{/if}
<td><a href="ams?page=createticket&user_id={$ticket_author}">Send Other Ticket</a></td>
{if $hasInfo}<td><a href="ams?page=show_ticket_info&id={$ticket_tId}">Show ticket Info</a></td>{/if}
</tr>
</table>
{if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"}
<font color="green">
<p>{$success_assigned}</p>
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"}
<font color="green">
<p>{$success_unassigned}</p>
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"}
<font color="red">
<p>{$ticket_not_existing}</p>
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"}
<font color="red">
<p>{$ticket_already_assigned}</p>
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"}
<font color="red">
<p>{$ticket_not_assigned}</p>
</font>
{/if}
{if isset($ACTION_RESULT) and $ACTION_RESULT eq "INVALID_SGROUP"}
<font color="red">
<p>{$invalid_sgroup}</p>
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"}
<font color="red">
<p>{$ticket_not_existing}</p>
</font>
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_FORWARDED"}
<font color="green">
<p>{$success_forwarded}</p>
</font>
{/if}
<form id="changeTicket" method="post" action="ams?page=show_ticket&id={$ticket_tId}">
<table width=100%>
<tr>
<td width=33%><strong>Original Submitted: </strong>{$ticket_timestamp}</td>
<td width=33%><strong>Last Updated: </strong>{$ticket_lastupdate}</td>
<td width=33%><strong>Status: </strong>{if $ticket_status neq 3}<font color="green">Open</font>{/if} <font color="{if $ticket_status eq 0}green{else if $ticket_status eq 1}orange{else if $ticket_status eq 3}red{/if}"><strong>{$ticket_statustext}</strong></font></td>
</tr>
<tr>
<td width=33%><strong>Category: </strong>{$ticket_category}</td>
<td width=33%><strong>Priority: </strong>{$ticket_prioritytext}</td>
<td width=33%><strong>Support Group: </strong>
<span class="label label-info">
{if $ticket_forwardedGroupName eq "0"}
<i>{$public_sgroup}</i>
{else}
<a href="ams?page=show_sgroup&id={$ticket_forwardedGroupId}">{$ticket_forwardedGroupName}</a>
{/if}
</span>
</td>
</tr>
<tr>
<td width=33%><strong>Assigned To: </strong>{if $ticket_assignedTo neq ""} <a href="ams?page=show_user&id={$ticket_assignedTo}">{$ticket_assignedToText}</a> {else}<i> {$not_assigned}</i> {/if}</td>
<td width=33%></td>
<td width=33%></td>
</tr>
</table>
<table class="table table-bordered" >
<tbody>
{foreach from=$ticket_replies item=reply}
<tr>
<td>
<p>
<font color="blue"> {$reply.timestamp}</font>
{if $reply.permission eq '1'}
<span class="label label-success"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}"> {$reply.author}{else} {$reply.author} {/if}</a></strong></span>
{else if $reply.permission gt '1'}
<span class="label label-warning"><strong>{if isset($isMod) and $isMod eq "TRUE"} <a href="ams?page=show_user&id={$reply.authorExtern}"><font color="red">{$reply.author}</font>{else}<font color="red"> {$reply.author} </font>{/if}</a></strong></span>
{/if}
</p>
<p><pre{if $reply.permission gt '1'} {if $reply.hidden eq 0} style="background-color:rgb(248, 200, 200);"{else if $reply.hidden eq 1}style="background-color:rgb(207, 254, 255);"{/if}{/if}> {if $reply.hidden eq 1}<i>{/if}{$reply.replyContent}{if $reply.hidden eq 1}</i>{/if}</pre></p>
</td>
</tr>
{/foreach}
{if $ticket_status eq 3}
<tr>
<td>
<p><pre style="background-color:rgb(255, 230, 153);">Ticket is closed.</pre></p>
</td>
</tr>
{/if}
<tr>
<td>
<form id="reply" class="form-vertical" method="post" action="ams?page=show_ticket&id={$ticket_tId}">
{if $ticket_status neq 3}
<legend>{$t_reply}:</legend>
<label>{$t_fill}</label>
<textarea rows="6" class="span12" style="width: 90%;" id="Content" name="Content"></textarea>
{if isset($isMod) and $isMod eq "TRUE"}
<label>Options</label>
<input type="checkbox" name="hidden">Hide reply for user.
{/if}
{/if}
</td>
</tr>
<tr>
<td>
{if isset($isMod) and $isMod eq "TRUE"}
<div style="display: inline-block;">
<label>Change status to</label>
<select name="ChangeStatus">
{foreach from=$statusList key=k item=v}
<option value="{$k}">{$v}</option>
{/foreach}
</select>
</div>
<div style="display: inline-block; margin-left:10px;"">
<label>Change priority to</label>
<select name="ChangePriority">
{foreach from=$ticket_priorities key=k item=v}
<option value="{$k}" {if $k eq $ticket_priority}selected="selected"{/if}>{$v}</option>
{/foreach}
</select>
</div>
{/if}
</td>
</tr>
<tr>
<td>
<input type="hidden" name="function" value="reply_on_ticket">
<input type="hidden" name="ticket_id" value="{$ticket_id}">
<button type="submit" class="btn btn-primary" >{$t_send}</button>
</form>
</td>
</tr>
</tbody>
</table>
{/block}

@ -1,79 +0,0 @@
{block name=content}
<h1><a href="ams?page=show_ticket&id={$ticket_id}">[#{$ticket_id}] {$ticket_title}</a> </h1>
<h2>Actions</h2>
<table width=100%>
<tr>
{if isset($isMod) and $isMod eq "TRUE"}<td width=33%><a href="ams?page=show_ticket_log&id={$ticket_id}">Show Ticket Log</a></td>{/if}
<td width=33%><a href="ams?page=createticket&user_id={$ticket_author}">Send Other Ticket</a></td>
<td width=33%><a href="ams?page=show_ticket&id={$ticket_id}">Show Ticket</a></td>
</tr>
</table>
<h2>Additional Info </h2>
<table>
<tr>
<td><center><strong> Ingame related </strong></center></td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/shard.png"/><strong> Shard ID: </strong>{$shard_id}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/user.png"/><strong> User_Id: </strong>{$user_id}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/position.png"/><strong> User Position: </strong>{$user_position}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/view.png"/><strong> View Position: </strong>{$view_position}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/client.png"/><strong> Client_Version: </strong> {$client_version}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/patch.png"/><strong> Patch_Version: </strong>{$patch_version}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/server.png"/><strong> Server_Tick: </strong>{$server_tick}</td>
</tr>
<tr class="alert alert-info">
<td><center><strong> Hardware & Software related </strong></center></td>
</tr>
<tr>
<td><strong><img src="{$IMAGELOC_WEBPATH}/info/memory.png"/> Memory: </strong>{$memory}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/processor.png"/><strong> Processor: </strong>{$processor}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/cpuid.png"/><strong> Cpu_Id: </strong>{$cpu_id}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/mask.png"/><strong> Cpu_Mask: </strong>{$cpu_mask}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/ht.png"/><strong> HT: </strong>{$ht}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/os.png"/><strong> OS: </strong>{$os}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/nel.png"/><strong> NeL3D: </strong>{$nel3d}</td>
</tr>
<tr class="alert alert-info">
<td><center><strong> Network related </strong></center></td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/connect.png"/><strong> Connect_State: </strong>{$connect_state}</td>
</tr>
<tr>
<td><img src="{$IMAGELOC_WEBPATH}/info/local.png"/><strong> Local_Address: </strong>{$local_address}</td>
</tr>
</table>
{/block}

@ -1,26 +0,0 @@
{block name=content}
<h2><i class="icon-tag"></i> Log of Ticket #{$ticket_id}</h2>
<legend>Title: <a href="ams?page=show_ticket&id={$ticket_id}">{$ticket_title}</a></legend>
<table>
<thead>
<tr>
<th>ID</th>
<th>Timestamp</th>
<th>Query</th>
</tr>
</thead>
<tbody>
{foreach from=$ticket_logs item=log}
<tr>
<td>{$log.tLogId}</td>
<td>{$log.timestamp}</td>
<td>{$log.query}</td>
</tr>
{/foreach}
</tbody>
</table>
{/block}

@ -1,93 +0,0 @@
{block name=content}
<h2><i class="icon-user"></i> Profile of {$target_name}</h2>
<table >
<tbody>
<tr >
<td><strong>Email:</strong></td>
<td>{$mail}</td>
</tr>
<tr >
<td><strong>Role:</strong></td>
<td>
{if $userPermission eq 1}<font color="green">User</font>{/if}
{if $userPermission eq 2}<font color="orange">Moderator</font>{/if}
{if $userPermission eq 3}<font color="red">Admin</font>{/if}
</td>
</tr>
</tbody>
</table>
<h2><i class="icon-th"></i>Actions</h2>
<table width="100%">
<tr>
<td width="25%">
<a href="ams?page=settings&id={$target_id}">Edit User</a>
</td>
<td width="25%">
<a href="ams?page=createticket&user_id={$target_id}">Send Ticket</a>
</td>
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $target_id neq 1}
{if $userPermission eq 1}
<td width="25%">
<a href="ams?page=change_permission&user_id={$target_id}&value=2">Make Moderator</a>
</td>
<td width="25%">
<a href="ams?page=change_permission&user_id={$target_id}&value=3">Make Admin</a>
</td>
{else if $userPermission eq 2 }
<td width="25%">
<a href="ams?page=change_permission&user_id={$target_id}&value=1">Demote to User</a>
</td>
<td width="25%">
<a href="ams?page=change_permission&user_id={$target_id}&value=3">Make Admin</a>
</td>
{else if $userPermission eq 3 }
<td width="25%">
<a href="ams?page=change_permission&user_id={$target_id}&value=1">Demote to User</a>
</td>
<td width="25%">
<a href="ams?page=change_permission&user_id={$target_id}&value=2">Demote to Moderator</a>
</td>
{/if}
{/if}
</tr>
</table>
<h2><i class="icon-tag"></i> Tickets of {$target_name}</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Timestamp</th>
<th>Category</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{foreach from=$ticketlist item=ticket}
<tr>
<td>{$ticket.tId}</td>
<td><a href ="ams?page=show_ticket&id={$ticket.tId}">{$ticket.title}</a></td>
<td class="center"><i>{$ticket.timestamp}</i></td>
<td class="center">{$ticket.category}</td>
<td class="center"><font color=" {if $ticket.status eq 0}green{else if $ticket.status eq 1}orange{else if $ticket.status eq 3}red{/if}">{$ticket.statusText}</span></td>
</tr>
{/foreach}
</tbody>
</table>
{/block}

@ -1,62 +0,0 @@
{block name=content}
<h1Members</h1>
<table>
<thead>
<tr>
<th>Id</th>
<th>Username</th>
<th>Email</th>
<th>Permission</th>
<th>Action</th>
</tr>
</thead>
<tbody>
{foreach from=$userlist item=element}
<tr>
<td>{$element.id}</td>
<td class="center"><a href="ams?page=show_user&id={$element.id}">{$element.username}</a></td>
<td class="center">{$element.email}</td>
{if $element.permission eq 1}<td class="center"><font color="green">User</font></td>{/if}
{if $element.permission eq 2}<td class="center"><font color="orange">Moderator</font></td>{/if}
{if $element.permission eq 3}<td class="center"><font color="red">Admin</font></td>{/if}
<td class="center">
<table>
<tr><td>
<a class="btn btn-primary" href="ams?page=show_user&id={$element.id}"><i class=" icon-eye-open icon-white"></i> Show User</a>
</td>
<td>
<a href='{$base_webpath}/user/{$element.id}/edit'><i class=" icon-pencil icon-white"></i> Edit User</a>
</td>
{if isset($isAdmin) and $isAdmin eq 'TRUE' and $element.id neq 1}
{if $element.permission eq 1}
<td><a href="ams?page=change_permission&user_id={$element.id}&value=2">Make Moderator</a></td>
<td><a href="ams?page=change_permission&user_id={$element.id}&value=3">Make Admin</a></td>
{else if $element.permission eq 2 }
<td><a href="ams?page=change_permission&user_id={$element.id}&value=1">Demote to User</a></td>
<td><a href="ams?page=change_permission&user_id={$element.id}&value=3">Make Admin</a></td>
{else if $element.permission eq 3 }
<td><a href="ams?page=change_permission&user_id={$element.id}&value=1">Demote to User</a></td>
<td><a href="ams?page=change_permission&user_id={$element.id}&value=2">Demote to Moderator</a></td>
{/if}
{/if}
<tr>
</table>
</td>
</tr>
{/foreach}
</tbody>
</table>
<center>
<a href="ams?page=userlist&pagenum=1">&laquo;</a> |
{foreach from=$links item=link}
<a href="ams?page=userlist&pagenum={$link}">{if $link == $currentPage}<u>{/if}{$link}{if $link == $currentPage}</u>{/if}</a> |
{/foreach}
<a href="ams?page=userlist&pagenum={$lastPage}">&raquo;</a>
</center>
{/block}

@ -1,10 +0,0 @@
-Make Permission www dependend, so it can be implemented in drupal with hook_permission();
-in helpers make_folders mkdir($value); should be drupal_mkdir();
-fix the callback in add_user_to_sgroup.php and show_sgroup.php in the func dir
-put mycrypt stuff from func/modify_email_of_sgroup in the setPassword itself.
-fix the error paths by making them use the ingame_path & outgame paths too
module related:
-put the install.php stuff into the module.install file
-add extra data fields that can be changed like the gender, country

@ -1,118 +0,0 @@
<?php
/**
* This file contains all variables needed by other php scripts.
* @author Daan Janssens, mentored by Matthew Lagoe
*/
// Variables for database access to the www/CMS database
$cfg['db']['web']['host'] = 'localhost';
$cfg['db']['web']['port'] = '3306';
$cfg['db']['web']['name'] = 'ryzom_ams';
$cfg['db']['web']['user'] = 'shard';
$cfg['db']['web']['pass'] = '';
// Variables for database access to the lib database
$cfg['db']['lib']['host'] = 'localhost';
$cfg['db']['lib']['port'] = '3306';
$cfg['db']['lib']['name'] = 'ryzom_ams_lib';
$cfg['db']['lib']['user'] = 'shard';
$cfg['db']['lib']['pass'] = '';
// Variables for database access to the shard database
$cfg['db']['shard']['host'] = 'localhost';
$cfg['db']['shard']['port'] = '3306';
$cfg['db']['shard']['name'] = 'nel';
$cfg['db']['shard']['user'] = 'shard';
$cfg['db']['shard']['pass'] = '';
// Variables for database access to the ring_open database
$cfg['db']['ring']['host'] = 'localhost';
$cfg['db']['ring']['port'] = '3306';
$cfg['db']['ring']['name'] = 'ring_open';
$cfg['db']['ring']['user'] = 'shard';
$cfg['db']['ring']['pass'] = '';
// Variables for database access to the nel_tool database
$cfg['db']['tool']['host'] = 'localhost';
$cfg['db']['tool']['port'] = '3306';
$cfg['db']['tool']['name'] = 'nel_tool';
$cfg['db']['tool']['user'] = 'shard';
$cfg['db']['tool']['pass'] = '';
// To connect to an IMAP server running on port 143 on the local machine,
// do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password");
// POP3 server on port 110: $mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
// SSL IMAP or POP3 server, add /ssl after the protocol: $mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");
// To connect to an SSL IMAP or POP3 server with a self-signed certificate,
// add /ssl/novalidate-cert after the protocol specification:
// $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");
// NNTP server on port 119 use: $nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
// To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to.
//$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX';
//imap connection string as explained above
$cfg['mail']['default_mailserver']= '{imap.gmail.com:993/imap/ssl}INBOX';
//groupemail is the email that sends the email
$cfg['mail']['default_groupemail'] = 'example@gmail.com';
//groupname will be the name displayed as sender
$cfg['mail']['default_groupname'] = 'Ryzomcore Support';
//the username of the account
$cfg['mail']['default_username'] = 'example@gmail.com';
//the matching password
$cfg['mail']['default_password'] = 'passw0rd';
//the host, being used when a mail is sent from a support group: support_groups_name@host
$cfg['mail']['host'] = "ryzomcore.com";
//Defines mailing related stuff
$SUPPORT_GROUP_IMAP_CRYPTKEY = "azerty";
$TICKET_MAILING_SUPPORT = false;
//You have to create this dir at first!
//The incoming emails will be backed up here and the log file keeps track of the mail_cron job.
$MAIL_DIR = "/home/username/mail";
$MAIL_LOG_PATH = "/home/username/mail/cron_mail.log";
//terms of service url location
$TOS_URL ="http://www.gnu.org/licenses/agpl-3.0.html";
//crypt is being used by encrypting & decrypting of the IMAP password of the supportgroups
$cfg['crypt']['key'] = 'Sup3rS3cr3tStuff';
$cfg['crypt']['enc_method'] = 'AES-256-CBC';
$cfg['crypt']['hash_method'] = "SHA512";
//-----------------------------------------------------------------------------------------
// If true= the server will add automatically unknown user in the database
// (in nel.user= nel.permission= ring.ring_user and ring.characters
$ALLOW_UNKNOWN = true ;
// if true= the login service automaticaly create a ring user and a editor character if needed
$CREATE_RING = true ;
// site paths definitions (you shouldn't have to edit these..)
$AMS_LIB = dirname( dirname( __FILE__ ) ) . '/ams_lib';
$AMS_TRANS = $AMS_LIB . '/translations';
$AMS_CACHEDIR = $AMS_LIB . '/cache';
//Here your inc and func resides
$SITEBASE = dirname( __FILE__ ) . '/html/' ;
//the paths to your website url
$BASE_WEBPATH = '';
$IMAGELOC_WEBPATH = $BASE_WEBPATH.'img';
$WEBPATH = $BASE_WEBPATH . '/index.php';
$INGAME_WEBPATH = $BASE_WEBPATH . '/index.php';
$CONFIG_PATH = dirname( __FILE__ );
//defines the default language
$DEFAULT_LANGUAGE = 'en';
//defines if logging actions should happen or not.
$TICKET_LOGGING = true;
//defines the time format display
$TIME_FORMAT = "m-d-Y H:i:s";
//defines which ingame layout template should be used
$INGAME_LAYOUT = "basic";
//forces to load the ingame templates if set to true
$FORCE_INGAME = false;

@ -0,0 +1,100 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="basics">
<ATOM Name="name" Value="long axe"/>
<ATOM Name="family" Value="melee weapon"/>
<ATOM Name="ItemType" Value="Two Hand Axe"/>
<STRUCT Name="EquipmentInfo">
<ARRAY Name="EquipmentSlots">
<ATOM Name="two_hands" Value="Two Hands"/>
</ARRAY>
</STRUCT>
</STRUCT>
<STRUCT Name="melee weapon">
<ATOM Name="category" Value="Heavy"/>
<ATOM Name="skill" Value="two handed axe"/>
<ATOM Name="damage type" Value="Slashing"/>
<ATOM Name="latency" Value="6"/>
</STRUCT>
<STRUCT Name="crafting tool">
<ATOM Name="type" Value="Sharpener"/>
</STRUCT>
<STRUCT Name="3d">
<ATOM Name="icon" Value="MW_2h_axe.tga"/>
<ATOM Name="anim_set" Value="2H"/>
</STRUCT>
<STRUCT Name="faber">
<ATOM Name="Skill" Value="make two_hands melee weapons"/>
<ATOM Name="Tool type" Value="Sharpener"/>
<ATOM Name="Price" Value="0.1*Standart_prices*8"/>
<STRUCT Name="Create">
<ATOM Name="MP 1" Value="Raw Material for Blade"/>
<ATOM Name="Quantity 1" Value="1"/>
<ATOM Name="MP 2" Value="Raw Material for Shaft"/>
<ATOM Name="MP 2 Property" Value="Stiff"/>
<ATOM Name="Quantity 2" Value="1"/>
<ATOM Name="MP 3" Value="Raw Material for Grip"/>
<ATOM Name="MP 3 Property" Value="Grip"/>
<ATOM Name="Quantity 3" Value="1"/>
<ATOM Name="MP 4" Value="Raw Material for Counterweight"/>
<ATOM Name="MP 4 Property" Value="Dense"/>
<ATOM Name="Quantity 4" Value="1"/>
</STRUCT>
</STRUCT>
<STRUCT Name="AsBrick">
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="RootFaber"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="MW_2h_axe.tga"/>
<ATOM Name="IconOver" Value="item_plan_over.tga"/>
</STRUCT>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<LOG>Thu Aug 22 20:07:54 2002 (receveur) .basics.name = long_axe
Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.category = Heavy
Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.latency = 6
Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.rate of fire = 2
Thu Aug 22 20:08:40 2002 (receveur) .melee weapon.skill = GreatAxe
Thu Aug 22 20:08:46 2002 (receveur) .melee weapon.damage type = Slashing
Thu Aug 22 20:09:22 2002 (receveur) .basics.quality level = $filename
Tue Aug 27 14:56:14 2002 (wuibout) .3d.icon = MW_2h_axe.tga
Thu Oct 03 15:20:39 2002 (receveur) .basics.weight = very heavy
Thu Oct 03 15:20:48 2002 (receveur) .basics.hit points = high
Thu Dec 12 11:51:26 2002 (favre) formName Pasted =
Fri Jan 03 15:56:12 2003 (receveur) .melee weapon.skill = great axe
Thu Feb 20 18:09:11 2003 (favre) .faber.Career = faber
Thu Feb 20 18:09:11 2003 (favre) .faber.Skill = make two_hands melee weapons
Thu Feb 20 18:09:11 2003 (favre) .faber.Specialization = make long axe
Wed Feb 26 17:36:47 2003 (favre) .faber.Tool type = Sharpener
Wed Feb 26 17:36:52 2003 (favre) .crafting tool.type = Sharpener
Thu Feb 27 17:21:36 2003 (receveur) .faber.Create.MP 1 = yellow_amber.item
Thu Feb 27 17:21:36 2003 (receveur) .faber.Create.Quantity 1 = 6
Thu Feb 27 17:21:39 2003 (receveur) .faber.Create.Quantity 2 = 5
Thu Feb 27 17:22:12 2003 (receveur) .faber.Create.MP 2 = desert_pod.items
Mon Mar 03 15:29:25 2003 (receveur) .melee weapon.latency = 4
Mon Mar 03 15:29:25 2003 (receveur) .melee weapon.rate of fire =
Thu May 29 16:05:58 2003 (fleury) .melee weapon.latency = 6
Tue Sep 16 19:24:56 2003 (coutelas) .basics.ItemType = Two Hand Axe
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 1 = Raw Material for Blade
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 2 = Raw Material for Shaft
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 2 Property = Stiff
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 3 = Raw Material for Grip
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 3 Property = Grip
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 4 = Raw Material for Counterweight
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.MP 4 Property = Dense
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 1 = 1
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 2 = 1
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 3 = 1
Tue Sep 16 19:24:56 2003 (coutelas) .faber.Create.Quantity 4 = 1
Tue Sep 16 19:24:56 2003 (coutelas) .melee weapon.skill = two handed axe
Tue Sep 16 19:25:31 2003 (coutelas) .AsBrick.Client.Icon = MW_2h_axe.tga
Thu Sep 18 12:25:52 2003 (coutelas) .basics.family = melee weapon
Thu Sep 18 18:57:52 2003 (coutelas) .AsBrick.Basics.FamilyId = RootFaber
Fri Sep 19 11:39:52 2003 (coutelas) .AsBrick.Client.IconOver = item_plan_over.tga</LOG>
</FORM>

@ -0,0 +1,42 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="basics">
<ATOM Name="origin" Value="fyros"/>
<ATOM Name="family" Value="melee weapon"/>
<STRUCT Name="EquipmentInfo">
<ARRAY Name="EquipmentSlots">
<ATOM Value="Right Hand"/>
</ARRAY>
</STRUCT>
</STRUCT>
<STRUCT Name="3d">
<ATOM Name="shape" Value="FY_Wea_hache2M.shape"/>
<ATOM Name="shape_female" Value="FY_Wea_hache2M.shape"/>
<ATOM Name="icon background" Value="BK_fyros.tga"/>
<ATOM Name="anim_set" Value="2H"/>
</STRUCT>
<STRUCT Name="faber">
<STRUCT Name="Create">
<ATOM Name="Cost" Value="HP Default"/>
<ATOM Name="Difficulty" Value="(&quot;basics.quality level&quot;-4)*10*(0.9-0.1*(&quot;#faber.Create.MP 1&quot;+&quot;#faber.Create.MP 2&quot;+&quot;#faber.Create.MP 3&quot;+&quot;#faber.Create.MP 4&quot;+&quot;#faber.Create.MP 5&quot;))"/>
</STRUCT>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<LOG>Fri Jul 05 10:15:18 2002 (mauduit) .3d.shape = TR_HOM_VISAGE.shape
Fri Jul 05 10:25:30 2002 (mauduit) .3d.shape = Tr_Wea_Hache2M.shape
Thu Jul 11 11:34:49 2002 (mauduit) .3d.anim_set = 2H
Thu Jul 11 11:34:49 2002 (mauduit) .3d.shape_female = Tr_Wea_Hache2M.shape
Thu Jul 11 11:34:49 2002 (mauduit) .basics.EquipmentInfo.EquipmentSlots[0] = Right Hand
Thu Jul 11 11:34:49 2002 (mauduit) .basics.family = melee weapon
Thu Jul 11 11:34:49 2002 (mauduit) .basics.origin = tryker
Thu Jul 11 11:34:49 2002 (mauduit) formName Resized = 1
Thu Jul 11 13:33:18 2002 (mauduit) .3d.shape = FY_Wea_hache2M.shape
Thu Jul 11 13:33:18 2002 (mauduit) .3d.shape_female = FY_Wea_hache2M.shape
Thu Jul 11 13:33:18 2002 (mauduit) .basics.origin = fyros
Tue Aug 27 15:02:55 2002 (wuibout) .3d.icon background = BK_fyros.tga</LOG>
</FORM>

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="SabrinaCost" Value="20"/>
<ATOM Name="Property 0" Value="-10"/>
<ATOM Name="LearnRequiresOneOfSkills" Value="C 0"/>
<ATOM Name="Skill" Value="C"/>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,59 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="BCFMEA"/>
<ATOM Name="SabrinaCost" Value="15"/>
<ATOM Name="LearnRequiresOneOfSkills" Value="SCFM2 200"/>
<ATOM Name="Skill" Value="SCFM2SAB"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="MW_2h_axe.tga"/>
<ATOM Name="IconBack" Value="BK_fyros_brick.tga"/>
<ATOM Name="IconOver" Value="FP_over.tga"/>
<ATOM Name="IconOver2"/>
</STRUCT>
<STRUCT Name="faber">
<ATOM Name="Tool type" Value="Sharpener"/>
<ATOM Name="Durability Factor" Value="1"/>
<ATOM Name="Weight Factor" Value="1"/>
<ATOM Name="DMG Factor" Value="1"/>
<ATOM Name="Slashing protect factor" Value="1"/>
<ATOM Name="Blunt protect factor" Value="1"/>
<ATOM Name="Piercing protect factor" Value="1"/>
<ATOM Name="Dodge factor" Value="1"/>
<ATOM Name="Parry factor" Value="1"/>
<ATOM Name="Speed Factor" Value="1"/>
<ATOM Name="Range Factor" Value="1"/>
<ATOM Name="SapLoad Factor" Value="1"/>
<STRUCT Name="Create">
<ATOM Name="Crafted Item" Value="icfm2sa.sitem"/>
<ATOM Name="Nb built items" Value="1"/>
<ATOM Name="MP 1 Group"/>
<ATOM Name="MP 1" Value="Raw Material for Blade"/>
<ATOM Name="MP 1 Property" Value="Undefined"/>
<ATOM Name="Quantity 1" Value="1"/>
<ATOM Name="MP 2 Group"/>
<ATOM Name="MP 2" Value="Raw Material for Shaft"/>
<ATOM Name="MP 2 Property" Value="Stiff"/>
<ATOM Name="Quantity 2" Value="1"/>
<ATOM Name="MP 3 Group"/>
<ATOM Name="MP 3" Value="Raw Material for Grip"/>
<ATOM Name="MP 3 Property" Value="Gripping"/>
<ATOM Name="Quantity 3" Value="1"/>
<ATOM Name="MP 4 Group"/>
<ATOM Name="MP 4" Value="Raw Material for Counterweight"/>
<ATOM Name="MP 4 Property" Value="Dense"/>
<ATOM Name="Quantity 4" Value="1"/>
<ATOM Name="MP 5 Group"/>
<ATOM Name="MP 5"/>
<ATOM Name="MP 5 Property" Value="Undefined"/>
<ATOM Name="Quantity 5" Value="0"/>
</STRUCT>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="BCPA"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="FP_Melee.tga"/>
<ATOM Name="IconBack" Value="BK_fyros_brick.tga"/>
<ATOM Name="IconOver" Value="FP_Over.tga"/>
</STRUCT>
<STRUCT Name="Mandatory">
<ATOM Name="f0" Value="BCFMEA"/>
</STRUCT>
<STRUCT Name="Credit">
<ATOM Name="f0" Value="BCCA"/>
<ATOM Name="f1" Value="BCXMCA"/>
<ATOM Name="f2" Value="BCXMCB"/>
<ATOM Name="f3" Value="BCXMCC"/>
<ATOM Name="f4" Value="BCXMCD"/>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="BMCA"/>
<ATOM Name="SabrinaCost" Value="-5"/>
<ATOM Name="Property 1" Value="SAP: 5.000000*1.5/10"/>
<ATOM Name="Property 3" Value="NULL"/>
<ATOM Name="Property 4" Value="NULL"/>
<ATOM Name="LearnRequiresOneOfSkills" Value="M 0"/>
<ATOM Name="Action Nature" Value="UNKNOWN"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="ICO_Sap.tga"/>
<ATOM Name="IconBack" Value="CP_Back.tga"/>
<ATOM Name="IconOver" Value="CP_Over_More.tga"/>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="BMPA"/>
<ATOM Name="SabrinaCost" Value="0"/>
<ATOM Name="LearnRequiresOneOfSkills" Value="M 0"/>
<ATOM Name="Action Nature" Value="OFFENSIVE"/>
<ATOM Name="Skill" Value="SMTPG"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="ICO_Atysian.tga"/>
<ATOM Name="IconBack" Value="MP_Back_Offensive.tga"/>
</STRUCT>
<STRUCT Name="Mandatory">
<ATOM Name="f0" Value="BMTODEA"/>
</STRUCT>
<STRUCT Name="Optional">
<ATOM Name="f0" Value="BMOA"/>
<ATOM Name="f1" Value="BMOC"/>
<ATOM Name="f2" Value="BMOD"/>
<ATOM Name="f3" Value="BMOE"/>
<ATOM Name="f4" Value="BMOB"/>
</STRUCT>
<STRUCT Name="Credit">
<ATOM Name="f0" Value="BMCA"/>
<ATOM Name="f1" Value="BMCB"/>
<ATOM Name="f2" Value="BMCC"/>
<ATOM Name="f3" Value="BMCD"/>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="BMTODEA"/>
<ATOM Name="SabrinaCost" Value="0"/>
<ATOM Name="LearnRequiresOneOfSkills" Value="M 0"/>
<ATOM Name="Action Nature" Value="OFFENSIVE"/>
<ATOM Name="Skill" Value="SMTODB"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="ICO_Blunt.tga"/>
<ATOM Name="IconBack" Value="EF_Back.tga"/>
</STRUCT>
<STRUCT Name="Parameter">
<ATOM Name="f0" Value="BMTODMB"/>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<STRUCT Name="Basics">
<ATOM Name="FamilyId" Value="BMTODMB"/>
<ATOM Name="SabrinaCost" Value="5"/>
<ATOM Name="Property 0" Value="MA: mto"/>
<ATOM Name="Property 1" Value="MA_DMG: 5*8: 5*0: 5*2"/>
<ATOM Name="Property 2" Value="MA_DMG_TYPE: blunt"/>
<ATOM Name="Property 3" Value="MA_END"/>
<ATOM Name="Property 4" Value="NULL"/>
<ATOM Name="LearnRequiresOneOfSkills" Value="M 0"/>
<ATOM Name="Action Nature" Value="OFFENSIVE"/>
</STRUCT>
<STRUCT Name="Client">
<ATOM Name="Icon" Value="ICO_Power.tga"/>
<ATOM Name="IconBack" Value="PA_Back.tga"/>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
</FORM>

@ -0,0 +1,191 @@
/*
Sabrina_test project: player manager
*/
#include "nel/misc/sstring.h"
#include "sabrina/entity_base.h"
#include "sabrina/sabrina_actor_creature.h"
#ifdef NL_OS_WINDOWS
#pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list
#endif
//------------------------------------------------------------------------
// CNPCRecord / CCreatureRecord
//------------------------------------------------------------------------
class CNPCRecord: public CEntityBase
{
public:
CNPCRecord(const CSString& name);
ISabrinaActor* getSabrinaActor() { return const_cast<CSabrinaActorCreature*>(getSabAct()); }
const CSString& getName() const { return _Name; }
const CSabrinaActorCreature* getSabAct() const { return &_SabrinaActor; }
private:
CSString _Name;
CSabrinaActorCreature _SabrinaActor;
};
class CCreatureRecord: public CEntityBase
{
public:
CCreatureRecord(const CSString& name);
ISabrinaActor* getSabrinaActor() { return const_cast<CSabrinaActorCreature*>(getSabAct()); }
const CSString& getName() const { return _Name; }
const CSabrinaActorCreature* getSabAct() const { return &_SabrinaActor; }
private:
CSString _Name;
CSabrinaActorCreature _SabrinaActor;
};
//------------------------------------------------------------------------
// CNPCRecord / CCreatureRecord inlines
//------------------------------------------------------------------------
CNPCRecord::CNPCRecord(const CSString& name): _SabrinaActor(this)
{
_Name=name;
}
CCreatureRecord::CCreatureRecord(const CSString& name): _SabrinaActor(this)
{
_Name=name;
}
//------------------------------------------------------------------------
// CBotManager
//------------------------------------------------------------------------
class CBotManager
{
public:
void addNPC(const CSString& name);
void removeNPC(const CSString& name);
void listNPCs() const;
CNPCRecord* getNPC(const CSString& name);
void addCreature(const CSString& name,const NLMISC::CSheetId sheet);
void removeCreature(const CSString& name);
void listCreatures() const;
CCreatureRecord* getCreature(const CSString& name);
CEntityBase* getBot(const CSString& name);
private:
std::vector<CNPCRecord*> _NPCs;
std::vector<CCreatureRecord*> _Creatures;
};
//------------------------------------------------------------------------
// CBotManager inlines - Creature
//------------------------------------------------------------------------
inline void CBotManager::addCreature(const CSString& name,const NLMISC::CSheetId sheet)
{
removeCreature(name);
_Creatures.push_back(new CCreatureRecord(name));
}
inline void CBotManager::removeCreature(const CSString& name)
{
for (uint i=_Creatures.size();i--;)
{
if (_Creatures[i]->getName()==name)
{
delete _Creatures[i];
_Creatures[i]=_Creatures[_Creatures.size()-1];
_Creatures.pop_back();
}
}
}
inline void CBotManager::listCreatures() const
{
for (uint i=_Creatures.size();i--;)
{
CSString s="Creature";
s+=": "+_Creatures[i]->getName();
s+=": "+_Creatures[i]->getSabAct()->stateString();
nlinfo("%s",s.c_str());
}
}
inline CCreatureRecord* CBotManager::getCreature(const CSString& name)
{
for (uint i=_Creatures.size();i--;)
{
if (_Creatures[i]->getName()==name)
{
return _Creatures[i];
}
}
return NULL;
}
//------------------------------------------------------------------------
// CBotManager inlines - NPC
//------------------------------------------------------------------------
inline void CBotManager::addNPC(const CSString& name)
{
removeNPC(name);
_NPCs.push_back(new CNPCRecord(name));
}
inline void CBotManager::removeNPC(const CSString& name)
{
for (uint i=_NPCs.size();i--;)
{
if (_NPCs[i]->getName()==name)
{
delete _NPCs[i];
_NPCs[i]=_NPCs[_NPCs.size()-1];
_NPCs.pop_back();
}
}
}
inline void CBotManager::listNPCs() const
{
for (uint i=_NPCs.size();i--;)
{
CSString s="NPC";
s+=": "+_NPCs[i]->getName();
s+=": "+_NPCs[i]->getSabAct()->stateString();
nlinfo("%s",s.c_str());
}
}
inline CNPCRecord* CBotManager::getNPC(const CSString& name)
{
for (uint i=_NPCs.size();i--;)
{
if (_NPCs[i]->getName()==name)
{
return _NPCs[i];
}
}
return NULL;
}
//------------------------------------------------------------------------
// CBotManager inlines
//------------------------------------------------------------------------
inline CEntityBase* CBotManager::getBot(const CSString& name)
{
CEntityBase* result= getNPC(name);
if (result!=NULL)
return result;
else
return getCreature(name);
}

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<ATOM Name="brick 0" Value="bcpa01.sbrick"/>
<ATOM Name="brick 1" Value="bcfmea01.sbrick"/>
<ATOM Name="brick 2" Value="bcca01.sbrick"/>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<LOG>Sun Oct 12 01:01:33 2003 (miller) .brick 0 = bcpa01.sbrick
Sun Oct 12 01:01:33 2003 (miller) .brick 1 = bsfmea01.sbrick
Sun Oct 12 01:01:33 2003 (miller) .brick 2 = bcca01.sbrick</LOG>
</FORM>

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<PARENT Filename="_2h_axe.sitem"/>
<PARENT Filename="_fy_Wea_Hache2M.sitem"/>
<STRUCT>
<STRUCT Name="basics">
<ATOM Name="name" Value="fyros long axe"/>
<ATOM Name="origin" Value="fyros"/>
</STRUCT>
<STRUCT Name="melee weapon">
<ATOM Name="skill" Value="two handed axe fyros"/>
</STRUCT>
<STRUCT Name="3d">
<ATOM Name="map_variant" Value="Low Quality"/>
</STRUCT>
<STRUCT Name="faber">
<ATOM Name="Skill" Value="burning 2h axe craft"/>
<ATOM Name="Price" Value="0.1*Standart_prices*8"/>
<STRUCT Name="Create">
<ATOM Name="MP 1 Family" Value="Wood"/>
</STRUCT>
</STRUCT>
<STRUCT Name="AsBrick">
<STRUCT Name="Client">
<ATOM Name="IconBack" Value="BK_fyros_brick.tga"/>
</STRUCT>
</STRUCT>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<LOG>Thu Aug 08 09:25:01 2002 (mauduit) .3d.map_variant = Low Quality
Fri Sep 27 15:31:17 2002 (favre) .basics.name = fyros long axe
Thu Sep 18 12:28:08 2003 (coutelas) .basics.origin = fyros
Thu Sep 18 12:28:08 2003 (coutelas) .faber.Create.MP 1 Family = Wood
Thu Sep 18 12:28:08 2003 (coutelas) .faber.Skill = burning 2h axe craft
Thu Sep 18 12:28:08 2003 (coutelas) .melee weapon.skill = two handed axe fyros
Fri Sep 19 12:05:35 2003 (coutelas) .AsBrick.Client.IconBack = BK_fyros_brick.tga</LOG>
</FORM>

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<FORM Revision="$Revision: 1.1 $" State="modified">
<STRUCT>
<ATOM Name="brick 0" Value="bmpa01.sbrick"/>
<ATOM Name="brick 1" Value="bmtodea01.sbrick"/>
<ATOM Name="brick 2" Value="bmtodmb01.sbrick"/>
<ATOM Name="brick 3" Value="bmca01.sbrick"/>
</STRUCT>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<STRUCT/>
<LOG>Sun Oct 12 00:57:33 2003 (miller) .brick 0 = bmpa01.sbrick
Sun Oct 12 00:57:33 2003 (miller) .brick 1 = bmtodea01.sbrick
Sun Oct 12 00:57:33 2003 (miller) .brick 2 = bmtodmb01.sbrick
Sun Oct 12 00:57:33 2003 (miller) .brick 3 = bmca01.sbrick</LOG>
</FORM>

@ -0,0 +1,114 @@
/*
Sabrina_test project: player manager
*/
#include "nel/misc/sstring.h"
#include "sabrina/entity_base.h"
#include "sabrina/sabrina_actor_player.h"
#ifdef NL_OS_WINDOWS
#pragma warning (disable : 4355) // warning C4355: 'this' : used in base member initializer list
#endif
//------------------------------------------------------------------------
// CPlayerRecord
//------------------------------------------------------------------------
class CPlayerRecord: public CEntityBase
{
public:
CPlayerRecord(const CSString& name);
ISabrinaActor* getSabrinaActor() { return const_cast<CSabrinaActorPlayer*>(getSabAct()); }
const CSString& getName() const { return _Name; }
const CSabrinaActorPlayer* getSabAct() const { return &_SabrinaActor; }
CSabrinaActorPlayer* getSabAct() { return &_SabrinaActor; }
private:
CSString _Name;
CSabrinaActorPlayer _SabrinaActor;
};
//------------------------------------------------------------------------
// CPlayerRecord inlines
//------------------------------------------------------------------------
CPlayerRecord::CPlayerRecord(const CSString& name): _SabrinaActor(this)
{
_Name=name;
}
//------------------------------------------------------------------------
// CPlayerManager
//------------------------------------------------------------------------
class CPlayerManager
{
public:
CPlayerManager();
void addPlayer(const CSString& name);
void removePlayer(const CSString& name);
void listPlayers() const;
CPlayerRecord* getPlayer(const CSString& name);
private:
std::vector<CPlayerRecord*> _Players;
uint32 _UniquePlayerId;
};
//------------------------------------------------------------------------
// CPlayerManager inlines
//------------------------------------------------------------------------
CPlayerManager::CPlayerManager()
{
_UniquePlayerId=0;
}
inline void CPlayerManager::addPlayer(const CSString& name)
{
removePlayer(name);
_Players.push_back(new CPlayerRecord(name));
_Players[_Players.size()-1]->setEntityRowId(_UniquePlayerId++);
_Players[_Players.size()-1]->getSabAct()->addMemoryBank("default");
}
inline void CPlayerManager::removePlayer(const CSString& name)
{
for (uint i=_Players.size();i--;)
{
if (_Players[i]->getName()==name)
{
delete _Players[i];
_Players[i]=_Players[_Players.size()-1];
_Players.pop_back();
}
}
}
inline void CPlayerManager::listPlayers() const
{
for (uint i=_Players.size();i--;)
{
CSString s="Player";
s+=": "+_Players[i]->getName();
s+=": "+_Players[i]->getSabAct()->stateString();
nlinfo("%s",s.c_str());
}
}
inline CPlayerRecord* CPlayerManager::getPlayer(const CSString& name)
{
for (uint i=_Players.size();i--;)
{
if (_Players[i]->getName()==name)
{
return _Players[i];
}
}
return NULL;
}

@ -0,0 +1,313 @@
/** \file sabrina_test.cpp
*
* $Id: sabrina_test.cpp,v 1.2 2004/03/01 19:22:19 lecroart Exp $
*/
#include "nel/misc/command.h"
#include "nel/misc/path.h"
#include "game_share/ryzom_entity_id.h"
#include "game_share/tick_event_handler.h"
#include "sabrina_test.h"
#include "sabrina/sabrina_pointers.h"
#include "sabrina/sabrina_phrase_description.h"
#include "sabrina/sabrina_phrase_manager.h"
using namespace NLMISC;
using namespace NLNET;
using namespace std;
//---------------------------------------------------
// CallbackArray
//---------------------------------------------------
TUnifiedCallbackItem CallbackArray[] =
{
{ "AZERTY", NULL },
};
//---------------------------------------------------
// Globals
//---------------------------------------------------
namespace SABTEST
{
CServiceTest* TheService;
uint32 SimTickCount;
}
//---------------------------------------------------
// Service Init :
//
//---------------------------------------------------
void CServiceTest::init ()
{
SABTEST::TheService=this;
setUpdateTimeout(100);
CTickEventHandler::init(SABTEST::TheService->tickUpdate);
CSabrinaStaticPhraseDescriptionManager::init();
CSabrinaPhraseManager::init();
}
//---------------------------------------------------
// Service update :
//
//---------------------------------------------------
bool CServiceTest::update ()
{
if (SABTEST::SimTickCount)
{
CTickEventHandler::simulateTick();
--SABTEST::SimTickCount;
}
return true;
}
//---------------------------------------------------
// Tick update :
//
//---------------------------------------------------
void CServiceTest::tickUpdate ()
{
CSabrinaPhraseManager::update();
}
//---------------------------------------------------
// Service release :
//
//---------------------------------------------------
void CServiceTest::release ()
{
CSabrinaStaticPhraseDescriptionManager::release();
CSabrinaPhraseManager::release();
}
/****************************************************************\
Service register
\****************************************************************/
NLNET_SERVICE_MAIN (CServiceTest, "SabrinaTest", "sabrina_test", 0, CallbackArray, "", "")
/****************************************************************\
Command section
\****************************************************************/
ISabrinaActor* getActorByName(const CSString& name)
{
CEntityBase* result=NULL;
result= SABTEST::plrMgr()->getPlayer(name);
if (result!=NULL)
return result->getSabrinaActor();
result= SABTEST::botMgr()->getBot(name);
if (result!=NULL)
return result->getSabrinaActor();
return NULL;
}
NLMISC_COMMAND(newPlayer,"createPlayer","<name>")
{
if(args.size() != 1) return false;
if (getActorByName(args[0])!=NULL)
{
nlinfo("Actor already exists: %s",args[0].c_str());
return true;
}
SABTEST::plrMgr()->addPlayer(args[0]);
return true;
}
NLMISC_COMMAND(newNPC,"createNPC","<name>")
{
if(args.size() != 1) return false;
if (getActorByName(args[0])!=NULL)
{
nlinfo("Actor already exists: %s",args[0].c_str());
return true;
}
SABTEST::botMgr()->addNPC(args[0]);
return true;
}
NLMISC_COMMAND(newCreature,"createCreature","<name> <sheet>")
{
if(args.size() != 2) return false;
if (getActorByName(args[0])!=NULL)
{
nlinfo("Actor already exists: %s",args[0].c_str());
return true;
}
SABTEST::botMgr()->addCreature(args[0],NLMISC::CSheetId(args[1]));
return true;
}
NLMISC_COMMAND(plrTarget,"plrTarget","<name> <tgt>")
{
if(args.size() != 2) return false;
ISabrinaActor* actor= getActorByName(args[0]);
ISabrinaActor* target= getActorByName(args[1]);
if (actor==NULL)
{
nlinfo("Failed to identify actor: %s",args[0].c_str());
return true;
}
if (target==NULL)
{
nlinfo("Failed to identify target: %s",args[1].c_str());
return true;
}
actor->getEntity()->setTarget(target->getEntity());
return true;
}
NLMISC_COMMAND(plrMemSPhrase,"plrMemSPhrase","<player> <memory bank name> <slot in memory bank> <sphrase file name>")
{
if(args.size() != 4) return false;
// get a pointer to the player.
CSabrinaActorPlayer* actor= const_cast<CSabrinaActorPlayer*>(SABTEST::plrMgr()->getPlayer(args[0])->getSabAct());
if (actor==NULL)
{
nlinfo("Failed to identify player: %s",args[0].c_str());
return true;
}
// convert 'slot' param to int
uint32 slot;
if ( CSString(args[2]).atoi(slot)==false )
{
nlwarning("Invalid slot...");
return false;
}
// lookup the phrase in the static phrase table
ISabrinaPhraseDescriptionPtr phrase= CSabrinaStaticPhraseDescriptionManager::getPhrase(NLMISC::CSheetId(args[3]));
if (phrase==NULL)
{
nlwarning("Phrase file not found...");
return false;
}
// do the memorising
actor->memorize(args[1],slot,phrase);
return true;
}
NLMISC_COMMAND(plrMemUserPhrase,"plrMemSPhrase","<player> <memory bank name> <slot in memory bank> <phrase name> <brick>[<brick>[...]]")
{
if(args.size() < 5) return false;
// get a pointer to the player.
CSabrinaActorPlayer* actor= const_cast<CSabrinaActorPlayer*>(SABTEST::plrMgr()->getPlayer(args[0])->getSabAct());
if (actor==NULL)
{
nlinfo("Failed to identify player: %s",args[0].c_str());
return true;
}
// convert 'slot' params to int
uint32 slot;
if ( CSString(args[2]).atoi(slot)==false )
return false;
// setup a vector of bricks
std::vector<NLMISC::CSheetId> bricks;
for (uint32 i=4;i<args.size();++i)
bricks.push_back(NLMISC::CSheetId(args[i]));
// do the memorising
ISabrinaPhraseDescriptionPtr newPhrase= (ISabrinaPhraseDescription*)new CSabrinaPhraseDescriptionUser(args[3],bricks);
actor->memorize(args[1],slot,newPhrase);
return true;
}
NLMISC_COMMAND(plrUsePhrase, "plrUsePhrase ", "<player> <memory bank name> <slot in memory bank>")
{
if(args.size() != 3) return false;
// get a pointer to the player.
CSabrinaActorPlayer* actor= const_cast<CSabrinaActorPlayer*>(SABTEST::plrMgr()->getPlayer(args[0])->getSabAct());
if (actor==NULL)
{
nlinfo("Failed to identify player: %s",args[0].c_str());
return true;
}
// convert 'slot' params to string
uint32 slot;
if ( CSString(args[2]).atoi(slot)==false )
return false;
// do the memorising
actor->setActiveMemoryBank(args[1]);
actor->executeAction(slot);
return true;
}
NLMISC_COMMAND(listActors,"listEntities","")
{
if(args.size() != 0) return false;
SABTEST::botMgr()->listCreatures();
SABTEST::botMgr()->listNPCs();
SABTEST::plrMgr()->listPlayers();
return true;
}
NLMISC_COMMAND(simTick,"simulate 1 or more tick","[<tick count>]")
{
uint32 count=1;
if (args.size()>0)
count=atoi(args[0].c_str());
if (count==0)
return false;
SABTEST::SimTickCount=count;
return true;
}
NLMISC_COMMAND(makeSheetId,"make sheet id file from scratch","")
{
if(args.size() != 0) return false;
std::string fileName="src_v2/sabrina_test/sheet_id.bin.test";
nlinfo("Creating file: %s",fileName.c_str());
std::map<NLMISC::CSheetId,std::string> allFiles;
std::vector<std::string> itemFiles;
std::vector<std::string> brickFiles;
std::vector<std::string> phraseFiles;
NLMISC::CPath::getFileList("sitem",itemFiles);
NLMISC::CPath::getFileList("sbrick",brickFiles);
NLMISC::CPath::getFileList("sphrase",phraseFiles);
nlinfo("adding %d sitem files",itemFiles.size());
nlinfo("adding %d sbrick files",brickFiles.size());
nlinfo("adding %d sphrase files",phraseFiles.size());
uint32 i;
for (i=itemFiles.size();i--;) allFiles[NLMISC::CSheetId().build(i+1,1)]= itemFiles[i];
for (i=brickFiles.size();i--;) allFiles[NLMISC::CSheetId().build(i+1,2)]= brickFiles[i];
for (i=phraseFiles.size();i--;) allFiles[NLMISC::CSheetId().build(i+1,3)]= phraseFiles[i];
NLMISC::COFile file(fileName);
file.serialCont(allFiles);
file.close();
return true;
}

@ -0,0 +1,68 @@
/** \file sabrina_test.h
*
* $Id: sabrina_test.h,v 1.2 2004/03/01 19:22:19 lecroart Exp $
*/
#ifndef GD_SABRINA_TEST_H
#define GD_SABRINA_TEST_H
#include "nel/misc/types_nl.h"
#include "nel/misc/time_nl.h"
#include "nel/net/service.h"
#include "player_manager.h"
#include "bot_manager.h"
//------------------------------------------------------------------------
// Class for the srevice objects...
class CServiceTest : public NLNET::IService
{
public:
// Service basics...
void init ();
bool update ();
void release ();
static void tickUpdate();
// accessors for entoty managers
CBotManager* getBotManager()
{
return &_BotManager;
}
CPlayerManager* getPlrManager()
{
return &_PlayerManager;
}
private:
CBotManager _BotManager;
CPlayerManager _PlayerManager;
};
//------------------------------------------------------------------------
// Globals and Handy routines for accessing the service object
namespace SABTEST
{
extern CServiceTest* TheService;
inline CPlayerManager* plrMgr()
{
return TheService->getPlrManager();
}
inline CBotManager* botMgr()
{
return TheService->getBotManager();
}
}
#endif // GD_SERVICE_TEST_H
/* End of sabrina_test.h */

@ -0,0 +1,982 @@
/** \file front_end_property_receiver.cpp
* Container for manage property receivers for front end
*
* $Id: front_end_property_receiver.cpp,v 1.21 2004/03/01 19:22:19 lecroart Exp $
*/
#include "front_end_property_receiver.h"
#include "nel/misc/path.h"
using namespace std;
using namespace NLNET;
using namespace NLMISC;
using namespace NLGEORGES;
// Static members of CFrontEndPropertyReceiver
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::_FirstFreeEntity;
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::_FirstUpdatedEntityProperties;
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::_FirstUpdatedEntityVision;
vector< CFrontEndPropertyReceiver::SEntity > CFrontEndPropertyReceiver::_VectorEntities;
CFrontEndPropertyReceiver::TMapIdToIndex CFrontEndPropertyReceiver::_MapIdToIndex;
//CFrontEndPropertyReceiver::SIndexProperties CFrontEndPropertyReceiver::PropertyIndexByType [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ];
CFrontEndPropertyReceiver::SPropertyDesc CFrontEndPropertyReceiver::PropertiesProperty [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ];
CFrontEndPropertyReceiver::SOtherPropertyDesc CFrontEndPropertyReceiver::OtherProperties [ NB_OTHER_PROPERTIES ];
uint32 CFrontEndPropertyReceiver::PropertiesContinuousMask [ NB_TYPE_ENTITIES ];
//---------------------------------------------------
// Init
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::initFrontEndPropertyReceiver( const string& filenameProperties, const string& filenameEntityIndex )
{
// reserve place for vector....
_VectorEntities.resize( FE_NBMAX_ENTITIES ); // not reserve!
// prepare FreeEntityProperties linking;
unsigned int i = 0;
for( std::vector< SEntity >::iterator it = _VectorEntities.begin(); it != _VectorEntities.end(); ++it )
{
it->code = 0;
it->bitfield = 0;
it->mask = 0;
it->nextFreeEntity = ++i;
it->nextUpdatedEntityProperties = -2;
it->nextUpdatedEntityVision = -2;
}
/*
for( i = 0; i < NB_TYPE_ENTITIES; ++i )
{
for( int j = 0; j < NB_PROPERTIES_PER_ENTITY; ++j )
{
PropertyIndexByType [ i ] [ j ].PropertyName = "";
PropertyIndexByType [ i ] [ j ].PropertyIndex = 127;
}
}
*/
// prepare FreeEntityProperties linking;
_FirstFreeEntity = 0;
// prepare UpdatedEntityProperties linking;
_FirstUpdatedEntityProperties = -1;
// prepare UpdatedEntityProperties linking;
_FirstUpdatedEntityVision = -1;
// Load sheet for properties's property
CLoader loader;
UFormElm item;
item.SetLoader( &loader );
try
{
item.Load( CPath::lookup( filenameEntityIndex ) );
}
catch (Exception &e){ nlwarning("CFrontEndPropertyReceiver::initFrontEndPropertyReceiver : '%s' -> '%s'.", filenameEntityIndex.c_str(), e.what());}
map< string, uint8 > EntityIndexMap;
UFormElm *pRoot = item.GetElt(0);
initEntityIndex( pRoot, EntityIndexMap );
item.Clear();
try
{
item.Load( CPath::lookup( filenameProperties ) );
}
catch (Exception &e){ nlwarning("CFrontEndPropertyReceiver::initFrontEndPropertyReceiver : '%s' -> '%s'.", filenameProperties.c_str(), e.what());}
pRoot = item.GetElt(0);
initPropertyDescriptor( pRoot, EntityIndexMap );
// Precalculate the the continuous mask
for( int ii = 0; ii < NB_TYPE_ENTITIES; ++ii )
{
uint32 continuousMask = 0;
for( uint32 j = 0; j < NB_PROPERTIES_PER_ENTITY; ++j )
{
for( int k = 0; k < NB_PROPERTIES_PER_ENTITY; ++k )
{
if( PropertiesProperty [ ii ] [ k ].Index == j )
{
uint32 idx = 1;
idx <<= PropertiesProperty [ ii ] [ k ].Index;
continuousMask |= idx & ( ( PropertiesProperty [ ii ] [ k ].Continuous) ? 0 : 1 );
}
}
}
// Changed 4/04/2002: i to ii
PropertiesContinuousMask [ ii ] = continuousMask;
}
// register callback function for process delta update messages of mirror and vision
NLNET::TUnifiedCallbackItem _cbArray[3];
_cbArray[0].Callback = cbDeltaUpdate;
_cbArray[0].Key = "DELTA_UPDATE";
_cbArray[1].Callback = cbDeltaUpdateRemove;
_cbArray[1].Key = "DELTA_UPDATE_REMOVE";
_cbArray[2].Callback = cbDeltaVision;
_cbArray[2].Key = "VISIONS_DELTA";
CUnifiedNetwork::getInstance()->addCallbackArray( _cbArray, 3 );
}
//---------------------------------------------------
// Init entity index map with sheet
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::initEntityIndex( UFormElm *pElt, map< string, uint8 >& EntityIndexMap )
{
uint32 i;
CItemEltAtom *pAtomElt = dynamic_cast<CItemEltAtom*>(pElt);
if (pAtomElt != NULL)
{
EntityIndexMap.insert( make_pair( pAtomElt->GetName(), (uint8) atoi( pAtomElt->GetCurrentResult().c_str() ) ) );
return;
}
// If the element is a structure
CItemEltStruct *pStructElt = dynamic_cast<CItemEltStruct*>(pElt);
if (pStructElt != NULL)
{
for (i = 0; i < pStructElt->GetNbStructElt(); ++i)
initEntityIndex(pStructElt->GetStructElt(i), EntityIndexMap );
return;
}
}
//---------------------------------------------------
// Init properties descriptor
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::initPropertyDescriptor( UFormElm *pElt, map< string, uint8 >& EntityIndexMap, uint32 ident, uint32 itemNumber, bool OtherProperty )
{
uint32 i;
static uint32 entityIndex;
CItemEltAtom *pAtomElt = dynamic_cast<CItemEltAtom*>(pElt);
if (pAtomElt != NULL)
{
nldebug("FEPROPINIT: Atom element %s, value %s", pAtomElt->GetName().c_str(), pAtomElt->GetCurrentResult().c_str() );
if( ident == 2 )
{
entityIndex = atoi( pAtomElt->GetCurrentResult().c_str() );
}
else
{
if( !OtherProperty )
{
initPropertyDesc( pAtomElt, entityIndex, itemNumber );
}
}
return;
}
// If the element is a structure
CItemEltStruct *pStructElt = dynamic_cast<CItemEltStruct*>(pElt);
if (pStructElt != NULL)
{
if( ident == 0 )
{
nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() );
}
else if( ident == 1 )
{
nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() );
}
else if( ident == 2 )
{
nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() );
}
else if( ident == 3 )
{
nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() );
}
else if( ident == 4 )
{
nldebug("FEPROPINIT: Struct element %s", pStructElt->GetName().c_str() );
}
if( ident == 3 )
{
UFormElm *pEltChild = pStructElt->GetElt("Index");
if( pEltChild != 0 )
{
sint32 indexTest = atoi( pEltChild->GetCurrentResult().c_str() );
if( atoi( pEltChild->GetCurrentResult().c_str() ) < 0)
{
OtherProperty = true;
initOtherPropertyDesc( pStructElt );
}
else
{
OtherProperty = false;
}
}
}
for (i = 0; i < pStructElt->GetNbStructElt(); ++i)
{
initPropertyDescriptor( pStructElt->GetStructElt(i), EntityIndexMap/*, entityIndex*/, ident+1, itemNumber, OtherProperty );
if( ident == 2 )
{
itemNumber++;
};
}
if( ident == 3 )
{
if( PropertiesProperty [ entityIndex ] [ itemNumber ].Union == true )
{
uint64 unionMask = 1;
unionMask<<=PropertiesProperty [ entityIndex ] [ itemNumber ].NbBits; // setup bit NbBits to 1 (ie the one above desired bitmask) followed by all 0s
unionMask-=1; // setup the bitmask (bottm NbBits of unionMask are all 1 rest are 0)
unionMask<<=PropertiesProperty [ entityIndex ] [ itemNumber ].UnionShift; // shift up the bitmask to the correct location in the QuadWord
PropertiesProperty [ entityIndex ] [ itemNumber ].UnionMask = unionMask;
}
}
return;
}
}
//---------------------------------------------------
// Init subscription for service
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::initFrontEndPropertySubscription( const string& serviceName )
{
nlinfo("<CFrontEndPropertyReceiver::initFrontEndPropertySubscription> service name %s",serviceName.c_str() );
// subscribe to delta update for properties
pair< string, uint32 > Property;
for( int ii = 0; ii < NB_TYPE_ENTITIES; ++ii )
{
for( uint32 j = 0; j < NB_PROPERTIES_PER_ENTITY; ++j )
{
if( PropertiesProperty [ii] [j].ServiceOwner == serviceName )
{
Property = make_pair( PropertiesProperty [ii] [j].PropertyName, 1 << PropertiesProperty [ii] [j].UpdateFrequency );
CFrontEndPropertyReceiver::askPropertySubscribe( serviceName, Property );
}
}
}
// subscribe to delta update for other properties (like Sheet Id )
for( int i = 0; i < NB_OTHER_PROPERTIES; ++i )
{
if( OtherProperties [i].ServiceOwner == serviceName )
{
Property = make_pair( OtherProperties [i].PropertyName, 1 << OtherProperties [i].UpdateFrequency );
CFrontEndPropertyReceiver::askPropertySubscribe( serviceName, Property );
}
}
}
//---------------------------------------------------
// Remove entities in receiver when downing serviceID is owner
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::serviceDown( uint16 serviceId )
{
for( TMapIdToIndex::iterator it = _MapIdToIndex.begin(); it != _MapIdToIndex.end(); ++it )
{
if( (*it).first.DynamicId == serviceId || (*it).first.CreatorId == serviceId )
{
deleteEntity( (*it).first );
}
}
}
//---------------------------------------------------
// release
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::freeFrontEndPropertyReceiver( void )
{
endUpdatedProperties();
endUpdatedVision();
}
//---------------------------------------------------
// Init property with george's sheet
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::initPropertyDesc( UFormElm *pElt, uint32 entity, uint32 property )
{
if( pElt->GetName() == string("Index") )
{
PropertiesProperty [ entity ] [ property ].Index = (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else if( pElt->GetName() == string("NbBits") )
{
PropertiesProperty [ entity ] [ property ].NbBits = (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else if(pElt->GetName() == string("Continuous") )
{
PropertiesProperty [ entity ] [ property ].Continuous = (pElt->GetCurrentResult() == "true") ? true : false;
}
else if( pElt->GetName() == string("Union") )
{
PropertiesProperty [ entity ] [ property ].Union = (pElt->GetCurrentResult() == "true") ? true : false;
}
else if( pElt->GetName() == string("Shift") )
{
PropertiesProperty [ entity ] [ property ].UnionShift = (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else if( pElt->GetName() == string("PropertyName") )
{
PropertiesProperty [ entity ] [ property ].PropertyName = pElt->GetCurrentResult();
}
else if( pElt->GetName() == string("ServiceOwner") )
{
PropertiesProperty [ entity ] [ property ].ServiceOwner = pElt->GetCurrentResult();
}
else if( pElt->GetName() == string("UpdateFrequency") )
{
PropertiesProperty [ entity ] [ property ].UpdateFrequency = (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else if( pElt->GetName() == string("PropertyType") )
{
PropertiesProperty [ entity ] [ property ].PropertyType = (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else
{
nlwarning("CFrontEndPropertyReceiver::initPropertyDesc property %s is unknown for entity %d property %d", pElt->GetName().c_str(), entity, property );
}
}
//---------------------------------------------------
// Init entity other properties with george's sheet
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::initOtherPropertyDesc( UFormElm *pEltProperty )
{
uint32 Index = 0;
UFormElm *pElt = pEltProperty->GetElt("Index");
if( pElt != 0 )
{
Index = 255 - (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else
{
nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property Index not in properties's property sheet" );
}
pElt = pEltProperty->GetElt("NbBits");
if( pElt != 0 )
{
OtherProperties[ Index ].NbBits = (uint8) atoi( pElt->GetCurrentResult().c_str() );
}
else
{
nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property NbBits not in properties's property sheet" );
}
pElt = pEltProperty->GetElt("PropertyName");
if( pElt != 0 )
{
OtherProperties[ Index ].PropertyName = pElt->GetCurrentResult();
}
else
{
nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property PropertyName not in properties's property sheet" );
}
pElt = pEltProperty->GetElt("ServiceOwner");
if( pElt != 0 )
{
OtherProperties[ Index ].ServiceOwner = pElt->GetCurrentResult();
}
else
{
nlwarning("CFrontEndPropertyReceiver::initOtherPropertyDesc property ServiceOwner not in properties's property sheet" );
}
}
//---------------------------------------------------
// Entity management : delete entity
//
//---------------------------------------------------
bool CFrontEndPropertyReceiver::deleteEntity( const CEntityId& id )
{
TPropertiesIndex i = findIndex( id );
// if failed, do nothing
if( i == -1 )
return( false );
// must delete it!
_VectorEntities[i].code |= PROPERTY_CODE_ERASE;
// If it's not in the list of updated entity, push it in!
if( _VectorEntities[i].nextUpdatedEntityProperties == -2 )
{
_VectorEntities[i].nextUpdatedEntityProperties = _FirstUpdatedEntityProperties;
_FirstUpdatedEntityProperties = i;
}
return( true );
}
//---------------------------------------------------
// Entity management : called for deleting entities
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::setDeleted( TPropertiesIndex indexprop )
{
// buid the link of free entries.
_VectorEntities[indexprop].nextFreeEntity = _FirstFreeEntity;
_FirstFreeEntity = indexprop;
releaseIndexToId( _VectorEntities[indexprop].id );
}
//---------------------------------------------------
// Entity management : give pointer on SEntity
//
//---------------------------------------------------
CFrontEndPropertyReceiver::SEntity* CFrontEndPropertyReceiver::getEntity( const TPropertiesIndex indexprop )
{
return( &(_VectorEntities[indexprop]) );
}
//---------------------------------------------------
// Property management : Set a new property
//
//---------------------------------------------------
bool CFrontEndPropertyReceiver::setProperties( const CEntityId& id, uint32 index, TPropertiesValue& value )
{
// Find the index
TPropertiesIndex i = findIndex( id );
if( i == -1 )
{
// it's a new index to build
i = assignIndexToId( id );
// if failed
if( i == -1 )
return( false );
// if not, it's a new entity
_VectorEntities[i].id = id;
_VectorEntities[i].code |= PROPERTY_CODE_NEW;
// Set the ContinueValuesMask;
TPropertiesContMask mask = 0;
// set mask of Continuous properties (bits for property continuous is set to 0, 1 if none continuous)
_VectorEntities[i].mask = PropertiesContinuousMask [ id.Type ];
}
else
{
if( _VectorEntities[i].code & PROPERTY_CODE_ERASE )
{
_VectorEntities[i].code &= ~PROPERTY_CODE_ERASE;
}
}
SEntity* p = &(_VectorEntities[i]);
// Set the bitfield and the value
uint32 indexProperty = PropertiesProperty [ id.Type ] [ index ].Index;
if( (1 << indexProperty) & (~ p->mask) )
{
p->bitfield |= 1 << indexProperty;
}
if( PropertiesProperty [ id.Type ] [ index ].Union )
{
p->properties[ indexProperty ] = ( p->properties[ indexProperty ] & ~ PropertiesProperty [ id.Type ] [ index ].UnionMask ) | ( ( value << PropertiesProperty [ id.Type ] [ index ].UnionShift ) & PropertiesProperty [ id.Type ] [ index ].UnionMask );
}
else
{
p->properties[ indexProperty ] = value;
}
// If it's not in the list of updated entity, push it in!
if( p->nextUpdatedEntityProperties == -2 )
{
p->nextUpdatedEntityProperties = _FirstUpdatedEntityProperties;
_FirstUpdatedEntityProperties = i;
}
return( true );
}
//---------------------------------------------------
// Property management : Get the first modified properties since the last EndUpdatedProperties
//
//---------------------------------------------------
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getFirstUpdatedProperties()
{
return( _FirstUpdatedEntityProperties );
}
//---------------------------------------------------
// Property management : Get the next modified properties
//
//---------------------------------------------------
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getNextUpdatedProperties( TPropertiesIndex indexprop )
{
// if it's the end or continuous values have changed and there is not new ou erase entity in the code, then go to the next elt
SEntity* p = &(_VectorEntities[indexprop]);
TPropertiesIndex i = p->nextUpdatedEntityProperties;
if( ( i == -1 )||( p->code )||( p->bitfield & p->mask ) )
return( i );
else
return( getNextUpdatedProperties( i ) );
}
//---------------------------------------------------
// Property management : Call it after getting all the updated properties (eg, the.GetNextUpdatedProperties function return -1 )
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::endUpdatedProperties()
{
// for all the entities in the list of updated
while( _FirstUpdatedEntityProperties != -1 )
{
// Get the next entity
SEntity* p = &(_VectorEntities[_FirstUpdatedEntityProperties]);
// erase entity if needed
if( ( p->code & PROPERTY_CODE_ERASE ) != 0 )
{
setDeleted( _FirstUpdatedEntityProperties );
}
// RAZ code
p->code &= ~( PROPERTY_CODE_NEW | PROPERTY_CODE_ERASE );
// RAZ bitfield
p->bitfield = 0;
// Remove it from list of updated entities
_FirstUpdatedEntityProperties = p->nextUpdatedEntityProperties;
p->nextUpdatedEntityProperties = -2;
}
}
//---------------------------------------------------
// Vision management : Set a new delta of vision
//
//---------------------------------------------------
bool CFrontEndPropertyReceiver::setVision( const CEntityId& id, const map< NLMISC::CEntityId, TVisionSlot >& visionIn, const vector< NLMISC::CEntityId >& visionOut )
{
// Find the index
TPropertiesIndex iviewer = findIndex( id );
if( iviewer == -1 )
{
nlwarning( "Trouble when synchronising vision and properties: viewer not created" );
return false;
}
SEntity* p = &(_VectorEntities[iviewer]);
// If entity has no unprocessed vision
if( p->nextUpdatedEntityVision == -2 )
{
// Insert the entity in the vision list
p->nextUpdatedEntityVision = _FirstUpdatedEntityVision;
_FirstUpdatedEntityVision = iviewer;
for( map< CEntityId, TVisionSlot >::const_iterator itIn = visionIn.begin(); itIn != visionIn.end(); ++itIn )
{
// Find the index of the id
TPropertiesIndex iviewed = findIndex( (*itIn).first );
if( iviewed == -1 )
{
// no synchronisation
nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision in and properties: viewed not inserted" );
}
else
{
p->VisionIn.insert( make_pair( iviewed, (*itIn).second ) );
}
}
for( vector< NLMISC::CEntityId >::const_iterator itOut = visionOut.begin(); itOut != visionOut.end(); ++itOut )
{
// Find the index of the id
TPropertiesIndex iviewed = findIndex( *itOut );
if( iviewed == -1 )
{
// no synchronisation
nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision out and properties: viewed not inserted" );
}
else
{
p->VisionOut.insert( iviewed );
}
}
}
else
{
// merging old and new delta vision update (only if front-end have not process previous vision update)
for( map< NLMISC::CEntityId, TVisionSlot >::const_iterator itIn = visionIn.begin(); itIn != visionIn.end(); ++itIn )
{
// Find the index of the id
TPropertiesIndex iviewed = findIndex( (*itIn).first );
if( iviewed == -1 )
{
// no synchronisation
nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision in and properties: viewed not inserted" );
}
else
{
p->VisionIn.insert( make_pair( iviewed, (*itIn).second ) );
set< TPropertiesIndex >::iterator it = p->VisionOut.find( iviewed );
if( it != p->VisionOut.end() )
{
p->VisionOut.erase( it );
}
}
}
for( vector< NLMISC::CEntityId >::const_iterator itOut = visionOut.begin(); itOut != visionOut.end(); ++itOut )
{
// Find the index of the id
TPropertiesIndex iviewed = findIndex( *itOut );
if( iviewed == -1 )
{
// no synchronisation
nlwarning( "CFrontEndPropertyReceiver::setVision: Trouble when synchronising vision out and properties: viewed not inserted" );
}
else
{
p->VisionOut.insert( iviewed );
map< TPropertiesIndex, TVisionSlot >::iterator it = p->VisionIn.find( iviewed );
if( it != p->VisionIn.end() )
{
p->VisionIn.erase( it );
}
}
}
}
return true;
}
//---------------------------------------------------
// Vision management : Get the first modified vision since the last EndUpdatedVision
//
//---------------------------------------------------
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getFirstUpdatedVision()
{
return( _FirstUpdatedEntityVision );
}
//---------------------------------------------------
// Vision management : Get the next modified vision
//
//---------------------------------------------------
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::getNextUpdatedVision( TPropertiesIndex indexprop )
{
return( _VectorEntities[indexprop].nextUpdatedEntityVision );
}
//---------------------------------------------------
// Vision management : Call it after getting all the updated vision (eg, the.GetNextUpdatedVision function return -1 )
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::endUpdatedVision()
{
// for all the entities in the list of updated
while( _FirstUpdatedEntityVision != -1 )
{
// Get the next entity
TPropertiesIndex i = _FirstUpdatedEntityVision;
SEntity* p = &(_VectorEntities[_FirstUpdatedEntityVision]);
// Clean the lists
p->VisionIn.clear();
p->VisionOut.clear();
// Remove it from list of updated entities
_FirstUpdatedEntityVision = p->nextUpdatedEntityVision;
p->nextUpdatedEntityVision = -2;
}
}
//---------------------------------------------------
// CEntityId / index management : Create a new index for the CEntityId
//
//---------------------------------------------------
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::assignIndexToId( const CEntityId& id )
{
// insert a new elt
std::pair< TMapIdToIndex::iterator, bool> result = _MapIdToIndex.insert( TMapIdToIndex::value_type( id, _FirstFreeEntity ) );
// if failed
if( !result.second )
return( -1 );
// if not, actualize _FirstFreeEntityProperties
TPropertiesIndex i = _FirstFreeEntity;
_FirstFreeEntity = _VectorEntities[i].nextFreeEntity;
return( i );
}
//---------------------------------------------------
// CEntityId / index management : Release index / id association
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::releaseIndexToId( const NLMISC::CEntityId& id )
{
// find the index from the id
TMapIdToIndex::iterator it = _MapIdToIndex.find( id );
if( it != _MapIdToIndex.end() )
{
_MapIdToIndex.erase( it );
}
}
//---------------------------------------------------
// CEntityId / index management : Get index, return true if finded and the value is setting. If false, value is undefined
//
//---------------------------------------------------
CFrontEndPropertyReceiver::TPropertiesIndex CFrontEndPropertyReceiver::findIndex( const CEntityId& id )
{
// find the index from the id
TMapIdToIndex::iterator it = _MapIdToIndex.find( id );
// if failed
if( it == _MapIdToIndex.end() )
return( -1 );
// if not
return( it->second );
}
//---------------------------------------------------
// UpdateProperties, unserial update mirrors message and process it
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::updateProperties( CMessage& msgin )
{
//nlinfo("Received a properties update");
TPropertiesValue Value;
while( (uint32)msgin.getPos () != msgin.length() )
{
string PropertyName;
msgin.serial( PropertyName );
if( PropertyName == "Mode" )
{
nlwarning("Mode updated");
}
CEntityId id;
msgin.serial( id );
while( id != CEntityId::Unknown )
{
Value = 0;
uint32 indexProperty = 0;
while( indexProperty < NB_PROPERTIES_PER_ENTITY )
{
if( PropertiesProperty[ id.Type & 0x7f ] [ indexProperty ].PropertyName == PropertyName )
{
switch( PropertiesProperty[ id.Type & 0x7f ] [ indexProperty ].PropertyType )
{
case 0: // uint8
{
uint8 v;
msgin.serial( v );
Value = v;
}
break;
case 1: // sint8
{
sint8 v;
msgin.serial( v );
Value = v;
}
break;
case 2: // uint16
{
uint16 v;
msgin.serial( v );
Value = v;
}
break;
case 3: // sint16
{
sint16 v;
msgin.serial( v );
Value = v;
}
break;
case 4: // uint32
{
uint32 v;
msgin.serial( v );
Value = v;
}
break;
case 5: // sint32
{
sint32 v;
msgin.serial( v );
Value = v;
}
break;
case 6: // uint64
{
uint64 v;
msgin.serial( v );
Value = v;
}
break;
case 7: // sint64
{
sint64 v;
msgin.serial( v );
Value = v;
}
break;
case 8: // float
{
float v;
msgin.serial( v );
*((float *)(&Value)) = v;
}
break;
case 9: // double
{
double v;
msgin.serial( v );
*((double *)(&Value)) = v;
}
break;
default:
nlwarning("Unknown type %d", PropertiesProperty[ id.Type & 0x7f ] [ indexProperty ].PropertyType );
nlstop;
}
setProperties( id, indexProperty, Value );
break;
}
++indexProperty;
// if property is special property type, it's still code dependant at this time....
if( indexProperty == NB_PROPERTIES_PER_ENTITY )
{
if( PropertyName == string("TickPos") )
{
TPropertiesIndex Index = findIndex( id );
if( Index == 255 )
{
Value = 0;
setProperties( id, x, Value ); // Create entity entry
Index = findIndex( id );
}
msgin.serial( _VectorEntities[ Index ].TickPosition );
}
else if( PropertyName == string("Sheet") )
{
TPropertiesIndex Index = findIndex( id );
if( Index == 255 )
{
Value = 0;
setProperties( id, x, Value ); // Create entity entry
Index = findIndex( id );
}
msgin.serial( _VectorEntities[ Index ].SheetId );
}
}
}
msgin.serial( id );
}
}
}
///
//---------------------------------------------------
// RemoveEntity, unserial remove message and remove corresponding Entity
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::removeEntity( CMessage& msgin )
{
list< CEntityId > entityToRemove;
msgin.serialCont( entityToRemove );
for( list< CEntityId >::iterator it = entityToRemove.begin(); it != entityToRemove.end(); ++it )
{
deleteEntity( *it );
}
}
//---------------------------------------------------
// UpdateVision, unserial update vision message and process it
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::updateVision( CMessage& msgin )
{
nlinfo("Received a vision update");
list< SPlayerVisionDelta > deltaVision;
msgin.serialCont( deltaVision );
for( list< SPlayerVisionDelta >::iterator it = deltaVision.begin(); it != deltaVision.end(); ++it )
{
setVision( (*it).Id, (*it).EntityIn, (*it).EntityOut );
}
}
//---------------------------------------------------
// Ask subscribe for one property
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::askPropertySubscribe( const string& ServiceSubscribe, const pair< string, uint32 >& Property )
{
CMessage msgOut( "PROPERTY_SUBSCRIBE" );
string serviceSubscribe = ServiceSubscribe;
string PropertyName = Property.first;
uint32 UpdateDelay = Property.second;
msgOut.serial( PropertyName );
msgOut.serial( UpdateDelay );
CUnifiedNetwork::getInstance()->send( serviceSubscribe, msgOut );
nlinfo("<CFrontEndPropertyReceiver::askPropertySubscribe> ask for property %s to service %s", PropertyName.c_str() , serviceSubscribe.c_str() );
}
//---------------------------------------------------
// Ask subscribe for list of properties
//
//---------------------------------------------------
void CFrontEndPropertyReceiver::askPropertiesSubscribe( const string& ServiceSubscribe, const list< pair< string, uint32 > >& Properties )
{
CMessage msgOut( "PROPERTIES_SUBSCRIBE" );
uint16 numberProperty = Properties.size();
msgOut.serial( numberProperty );
string PropertyName;
uint32 UpdateDelay;
for( list< pair< string, uint32 > >::const_iterator it = Properties.begin(); it != Properties.end(); ++it )
{
PropertyName = (*it).first;
UpdateDelay = (*it).second;
msgOut.serial( PropertyName );
msgOut.serial( UpdateDelay );
nlinfo("<CFrontEndPropertyReceiver::askPropertySubscribe> ask for property %s to service %s", PropertyName.c_str() , ServiceSubscribe.c_str() );
}
CUnifiedNetwork::getInstance()->send( ServiceSubscribe, msgOut );
}
//---------------------------------------------------
// Callback for delta mirror update received
//
//---------------------------------------------------
void cbDeltaUpdate( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
{
CFrontEndPropertyReceiver::updateProperties( msgin );
}
// Callback for delta vision update remove received
void cbDeltaUpdateRemove( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
{
CFrontEndPropertyReceiver::removeEntity( msgin );
}
//---------------------------------------------------
// Callback for delta vision update received
//
//---------------------------------------------------
void cbDeltaVision( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
{
CFrontEndPropertyReceiver::updateVision( msgin );
}

@ -0,0 +1,246 @@
/** \file front_end_property_receiver.h
* Container for manage property received by front end
*
* $Id: front_end_property_receiver.h,v 1.17 2004/03/01 19:22:19 lecroart Exp $
*/
#ifndef RY_FRONT_END_PROPERTY_RECEIVER_H
#define RY_FRONT_END_PROPERTY_RECEIVER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/time_nl.h"
#include "nel/misc/path.h"
#include "nel/misc/entity_id.h"
#include "nel/georges/u_form_elm.h"
#include "nel/georges/u_form_loader.h"
#include "nel/net/service.h"
#include <list>
#include <set>
#include <vector>
#include <map>
#include <string>
#define NB_TYPE_ENTITIES 3
#define NB_PROPERTIES_PER_ENTITY 16
#define FE_NBMAX_ENTITIES 50000
#define PROPERTY_CODE_ERASE 1<<31
#define PROPERTY_CODE_NEW 1<<30
#define NB_OTHER_PROPERTIES 2
/**
* Manage delta received of property for front end
* \author Alain Saffray
* \author Nevrax France
* \date 2001
*/
class CFrontEndPropertyReceiver
{
public:
typedef uint32 TPropertiesBitfield;
typedef uint32 TPropertiesIndex;
typedef uint32 TPropertiesCode;
typedef uint32 TPropertiesContMask;
typedef uint64 TPropertiesValue;
typedef uint32 TPropertiesValueIndex;
typedef uint16 TVisionSlot;
typedef std::map< NLMISC::CEntityId, uint32 > TMapIdToIndex;
struct SPropIndexCode
{
TPropertiesIndex index;
TPropertiesCode code;
};
struct SEntity
{
NLMISC::CEntityId id; // Entity Id
uint32 SheetId; // Id fiche of entity
TPropertiesCode code; // can be an "union" with bitfield and code => 3*32 bits -> 32 bits
TPropertiesBitfield bitfield; // can be an "union" with bitfield and code => 3*32 bits -> 32 bits
TPropertiesIndex nextFreeEntity; // can be an "union" with bitfield and code => 3*32 bits -> 32 bits
TPropertiesIndex nextUpdatedEntityProperties;
TPropertiesIndex nextUpdatedEntityVision;
TPropertiesContMask mask;
TPropertiesValue properties[NB_PROPERTIES_PER_ENTITY];
NLMISC::TGameCycle TickPosition;
std::map< TPropertiesIndex, TVisionSlot > VisionIn;
std::set< TPropertiesIndex > VisionOut;
/**
* Return GameCycle of property update
* \param PropertyIdx is property index
* \return Game cycle last update for property index
*/
NLMISC::TGameCycle getGameCycleForProperty( uint32 PropertyIdx ) { return TickPosition; }
};
struct SPropertyDesc
{
bool Continuous; // true if property is continuous type (FE not informed of changes)
bool Union; // true if property is with another in 64 bits property
std::string PropertyName; // name of property
std::string ServiceOwner; // name of owner service of property
uint8 UpdateFrequency;// Frequency of subcribtion updating (in number of ticks)
uint8 Index; // index of property (in array of property)
uint8 NbBits; // number of bits used by property
uint8 UnionShift; // bit shifting for union in 64 bits property destination
uint64 UnionMask; // mask for and/or operations for write property in 64 bits destination
uint8 PropertyType; // Type of property
};
struct SOtherPropertyDesc
{
std::string PropertyName; // name of property
std::string ServiceOwner; // name of owner service of property
uint8 NbBits; // number of bits used by property
uint8 UpdateFrequency;// Frequency of subcribtion updating (in number of ticks)
};
struct SIndexProperties
{
std::string PropertyName;
uint8 PropertyIndex;
};
enum EPropertyIndex { x = 0, y, z, theta, mode, behaviour, nameStringId };
enum EntityTypeIndex { player = 0, unknown = 127 };
// static SIndexProperties PropertyIndexByType [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ];
static SPropertyDesc PropertiesProperty [ NB_TYPE_ENTITIES ] [ NB_PROPERTIES_PER_ENTITY ];
static SOtherPropertyDesc OtherProperties [ NB_OTHER_PROPERTIES ];
static uint32 PropertiesContinuousMask [ NB_TYPE_ENTITIES ];
/*
* Init of property receiver
*\param filename if georges sheet describe properties informations
*/
static void initFrontEndPropertyReceiver( const std::string& filenameProperties, const std::string& filenameEntityIndex );
/*
* Init entity index map with sheet
*\param pElt is a pointer on current element item of sheet
*\param EntityIndexMap is map association name of element ans it's index
*/
static void initEntityIndex( NLGEORGES::UFormElm *pElt, std::map< std::string, uint8 >& EntityIndexMap );
/*
* Init properties descriptor
*\Param pElt is a pointer on current element item of sheet
*\param EntityIndexMap is map association name of element ans it's index
*\param entityIndex is current index of entity
*\param ident is deep in tree structure
*\param itemNumber is idex/number of item in current deep tree structure
*/
static void initPropertyDescriptor( NLGEORGES::UFormElm *pElt, std::map< std::string, uint8 >& EntityIndexMap, uint32 ident = 0, uint32 itemNumber = 0, bool OtherProperty = false );
/// Init subscription for service up
static void initFrontEndPropertySubscription( const std::string& serviceName );
/// Remove entities in receiver when downing serviceID is owner
static void serviceDown( uint16 serviceId );
/// release data
static void freeFrontEndPropertyReceiver( void );
/// Entity management : called for deleting entities
static SEntity* getEntity( const TPropertiesIndex indexprop );
/// Property management : Set a new property
static bool setProperties( const NLMISC::CEntityId& id, uint32 indexvalue, TPropertiesValue& value );
/// Property management : Get the first modified properties since the last EndUpdatedProperties
static TPropertiesIndex getFirstUpdatedProperties();
/// Property management : Get the next modified properties
static TPropertiesIndex getNextUpdatedProperties( TPropertiesIndex indexprop );
/// Property management : Call it after getting all the updated properties (eg, the.GetNextUpdatedProperties function return -1 )
static void endUpdatedProperties();
/// Vision management : Set a new delta of vision
static bool setVision( const NLMISC::CEntityId& id, const std::map< NLMISC::CEntityId, TVisionSlot >& visionIn, const std::vector< NLMISC::CEntityId >& visionOut );
/// Vision management : Get the first modified vision since the last EndUpdatedVision
static TPropertiesIndex getFirstUpdatedVision();
/// Vision management : Get the next modified vision
static TPropertiesIndex getNextUpdatedVision( TPropertiesIndex indexprop );
/// Vision management : Call it after getting all the updated vision (eg, the.GetNextUpdatedVision function return -1 )
static void endUpdatedVision();
/// UpdateProperties, unserial update message and update corresponding properties
static void updateProperties( NLNET::CMessage& msgin );
/// RemoveEntity, unserial remove message and update corresponding Entity / properties
static void removeEntity( NLNET::CMessage& msgin );
/// UpdateProperties, unserial update message and update corresponding properties
static void updateVision( NLNET::CMessage& msgin );
/// Ask subscribe for one property
static void askPropertySubscribe( const std::string& ServiceSubscribe, const std::pair< std::string, uint32>& Property );
/// Ask subscribe for list of properties
static void askPropertiesSubscribe( const std::string& ServiceSubscribe, const std::list< std::pair< std::string, uint32 > >& Properties );
private:
static TPropertiesIndex _FirstFreeEntity;
static TPropertiesIndex _FirstUpdatedEntityProperties;
static TPropertiesIndex _FirstUpdatedEntityVision;
static std::vector< SEntity > _VectorEntities;
static TMapIdToIndex _MapIdToIndex;
struct SPlayerVisionDelta
{
NLMISC::CEntityId Id;
std::vector< NLMISC::CEntityId > EntityOut;
std::map< NLMISC::CEntityId, TVisionSlot > EntityIn;
void serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
f.serial( Id );
f.serialCont( EntityOut );
f.serialCont( EntityIn );
}
};
// CEntityId / index management : Create a new index for the CEntityId
static TPropertiesIndex assignIndexToId( const NLMISC::CEntityId& Id );
// CEntityId / index management : Get index, return true if finded and the value is setting. If false, value is undefined
static TPropertiesIndex findIndex( const NLMISC::CEntityId& id );
// CEntityId / index management : Release index / id association
static void releaseIndexToId( const NLMISC::CEntityId& id );
// Entity management : delete entity
static bool deleteEntity( const NLMISC::CEntityId& id );
// Entity management : called for deleting entities
static void setDeleted( TPropertiesIndex indexprop );
// init property with george's sheet
static void initPropertyDesc( NLGEORGES::UFormElm *pEltProperty, uint32 entity, uint32 property );
// Init entity other properties with george's sheet
static void initOtherPropertyDesc( NLGEORGES::UFormElm *pEltProperty );
};
// Callback for delta mirror update received
void cbDeltaUpdate( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId );
// Callback for delta vision update remove received
void cbDeltaUpdateRemove( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId );
// Callback for delta vision update received
void cbDeltaVision( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId );
#endif // RY_FRONT_END_PROPERTY_RECEIVER_H
/* End of front_end_property_receiver.h */

@ -0,0 +1,256 @@
/** \file service_test.cpp
* <File description>
*
* $Id: service_test.cpp,v 1.20 2004/03/01 19:22:19 lecroart Exp $
*/
#include "service_test.h"
#include "game_share/ryzom_entity_id.h"
#include "nel/misc/command.h"
#include "nel/misc/path.h"
#include "front_end_property_receiver.h"
using namespace NLMISC;
using namespace NLNET;
using namespace NLGEORGES;
using namespace std;
CServiceTest* pServiceTest = NULL;
/**
* CallbackArray
*/
TUnifiedCallbackItem CallbackArray[] =
{
{ "AZERTY", NULL },
};
// includes pour les register class qui suivent (grrrr !!!!)
#include "nel/georges/form_body_elt.h"
#include "nel/georges/form_body_elt_atom.h"
#include "nel/georges/form_body_elt_list.h"
#include "nel/georges/form_body_elt_struct.h"
//---------------------------------------------------
// Service Init :
//
//---------------------------------------------------
void CServiceTest::init (void)
{
// init obligatoire pour george (penser à demander l'encapsulation de ça dans une methode init)
NLMISC_REGISTER_CLASS( CFormBodyElt );
NLMISC_REGISTER_CLASS( CFormBodyEltAtom );
NLMISC_REGISTER_CLASS( CFormBodyEltList );
NLMISC_REGISTER_CLASS( CFormBodyEltStruct );
setUpdateTimeout(10);
pServiceTest = this;
// DebugLog->addNegativeFilter(" ");
// Define path where to search the sheets.
CPath::addSearchPath( "service_test_data/sheets", true, false );
CUnifiedNetwork::getInstance()->setServiceUpCallback ("*", cbServiceUp, NULL);
CUnifiedNetwork::getInstance()->setServiceDownCallback( string("*"), cbServiceDown, 0);
CPath::addSearchPath( "fe_data/sheets", true, false );
CFrontEndPropertyReceiver::initFrontEndPropertyReceiver( string("entity_prop.entity_prop"), string("rien") );
}
//---------------------------------------------------
// Service update :
//
//---------------------------------------------------
bool CServiceTest::update (void)
{
serviceUpdate();
return true;
}
//---------------------------------------------------
// Service release :
//
//---------------------------------------------------
void CServiceTest::release (void)
{
CFrontEndPropertyReceiver::freeFrontEndPropertyReceiver();
}
//---------------------------------------------------
// Service release :
//
//---------------------------------------------------
void CServiceTest::serviceUpdate(void)
{
//-----------------------------------------------
// implementation d'exemple
//
//-----------------------------------------------
// Read properties
uint64 value;
CFrontEndPropertyReceiver::TPropertiesIndex index = CFrontEndPropertyReceiver::getFirstUpdatedProperties();
while( index != -1 )
{
CFrontEndPropertyReceiver::SEntity* p = CFrontEndPropertyReceiver::getEntity( index );
bool is_new = ( ( p->code & PROPERTY_CODE_NEW ) != 0 ); // true = new entity
bool is_del = ( ( p->code & PROPERTY_CODE_ERASE ) != 0 ); // true = deleted entity
if( is_new ) // Entity is new, we can read it's CEntityId and SheetId
{
nlinfo( "Entity %s is new, SheetId of entity is %d", p->id.toString().c_str(), p->SheetId );
}
if( is_del )
{
nlinfo( "Entity %s is deleted", p->id.toString().c_str() );
}
uint32 mask = 1;
for( uint32 i = 0; i < NB_PROPERTIES_PER_ENTITY; ++i )
{
if( p->bitfield & mask )
{
value = p->properties[i]; //read here a modified property
nlinfo( "Property %d of entity %s change to value %"NL_I64"d at TGameCyle %d", i, p->id.toString().c_str(), value, p->getGameCycleForProperty( i ) );
}
mask <<= 1;
}
index = CFrontEndPropertyReceiver::getNextUpdatedProperties( index );
}
CFrontEndPropertyReceiver::endUpdatedProperties();
// read vision
index = CFrontEndPropertyReceiver::getFirstUpdatedVision();
uint32 sizeout = 0;
uint32 sizein = 0;
while( index != -1 )
{
CFrontEndPropertyReceiver::SEntity* p = CFrontEndPropertyReceiver::getEntity( index );
sizeout = p->VisionOut.size(); // p->VisionOut entities out of vision
sizein = p->VisionIn.size(); // p->VisionIn entities in of vision
if(sizeout != 0)
{
nlinfo("entity out of vision for entity %s", p->id.toString().c_str());
for( set< CFrontEndPropertyReceiver::TPropertiesIndex >::iterator itOut = p->VisionOut.begin(); itOut != p->VisionOut.end(); ++itOut )
{
CFrontEndPropertyReceiver::SEntity* pOut = CFrontEndPropertyReceiver::getEntity( *itOut );
nlinfo("====> Entity exit of vision: %s", pOut->id.toString().c_str() );
}
}
if(sizein != 0)
{
nlinfo("new entity in vision for entity %s", p->id.toString().c_str());
for( map< CFrontEndPropertyReceiver::TPropertiesIndex, CFrontEndPropertyReceiver::TVisionSlot >::iterator itIn = p->VisionIn.begin(); itIn != p->VisionIn.end(); ++itIn )
{
CFrontEndPropertyReceiver::SEntity* pIn = CFrontEndPropertyReceiver::getEntity( (*itIn).first );
nlinfo("====> Entity enter in vision: %s to Slot %d", pIn->id.toString().c_str(), (*itIn).second );
}
}
index = CFrontEndPropertyReceiver::getNextUpdatedVision( index );
}
CFrontEndPropertyReceiver::endUpdatedVision();
}
/****************************************************************\
****************************************************************
Callback functions
****************************************************************
\****************************************************************/
// Callback called at service connexion
void cbServiceUp( const string& serviceName, uint16 serviceId, void * )
{
CFrontEndPropertyReceiver::initFrontEndPropertySubscription( serviceName );
}
// Callback called at service down
void cbServiceDown( const string& serviceName, uint16 serviceId, void * )
{
CFrontEndPropertyReceiver::serviceDown( serviceId );
}
/****************************************************************\
****************************************************************
Service register
****************************************************************
\****************************************************************/
NLNET_SERVICE_MAIN (CServiceTest, "ServiceTest", "service_test", 0, CallbackArray, "", "")
/****************************************************************\
****************************************************************
Command section
****************************************************************
\****************************************************************/
// Command for display data changed to receiver
NLMISC_COMMAND(subscribe,"Subscribe to delta update"," ")
{
// Define path where to search the sheets.
// CPath::addSearchPath( "service_test_data/sheets", true, false );
// CFrontEndPropertyReceiver::initFrontEndPropertyReceiver( string("entity_prop.entity_prop") );
list< pair< string, uint32 > > Properties;
Properties.push_back( make_pair( string("X"), 0x00000001 ) );
Properties.push_back( make_pair( string("Y"), 0x00000001 ) );
Properties.push_back( make_pair( string("Z"), 0x00000001 ) );
Properties.push_back( make_pair( string("Theta"), 0x00000001 ) );
CFrontEndPropertyReceiver::askPropertiesSubscribe( string("GPMS"), Properties );
return true;
}
// Command to add an entity to the GPMS
NLMISC_COMMAND(addEntity,"Add entity to GPMS","entity Id, entity PosX(meters), entity PosY, entity PosZ, service Id")
{
// check args, if there s not the right number of parameter, return bad
if(args.size() != 5) return false;
// get the values
uint32 Id = atoi(args[0].c_str());
uint32 PosX = atoi(args[1].c_str()) * 1000;
uint32 PosY = atoi(args[2].c_str()) * 1000;
sint32 PosZ = atoi(args[3].c_str()) * 1000;
uint16 FeId = atoi(args[4].c_str());
// Init Entity
CEntityId id;
id.Type = RYZOMID::player;
id.Id = Id;
id.DynamicId = FeId;
// CWorldPositionManager::addEntity(id, 1000 * PosX, 1000*PosY, 1000*PosZ, 0.0f, CTickEventHandler::getGameCycle() - 1/*CTickEventHandler::getGameCycles()*/,/*sheet*/0,FeId);
CMessage msgout("ADD_ENTITY");
msgout.serial( id );
msgout.serial( PosX );
msgout.serial( PosY );
msgout.serial( PosZ );
float theta = 0.0f;
msgout.serial( theta );
NLMISC::TGameCycle tick = 0;
// tick = CTickEventHandler::getGameCycle();
msgout.serial( tick );
uint32 sheet = 0;
msgout.serial( sheet );
CUnifiedNetwork::getInstance()->send( "GPMS", msgout );
return true;
}

@ -0,0 +1,50 @@
/** \file service_test.h
* <File description>
*
* $Id: service_test.h,v 1.7 2004/03/01 19:22:19 lecroart Exp $
*/
#ifndef GD_SERVICE_TEST_H
#define GD_SERVICE_TEST_H
#include "nel/misc/types_nl.h"
#include "nel/misc/time_nl.h"
#include "nel/net/service.h"
#include "front_end_property_receiver.h"
// Callback called at service connexion
void cbServiceUp( const std::string& serviceName, uint16 serviceId, void * );
// Callback called at service down
void cbServiceDown( const std::string& serviceName, uint16 serviceId, void * );
/**
* <Class description>
* \author Guillaume PUZIN
* \author Nevrax France
* \date 2001
*/
class CServiceTest : public NLNET::IService
{
public:
// Initialisation of service
void init (void);
// Update net processing
bool update (void);
// Update service processing
void serviceUpdate(void);
// Release the service
void release (void);
};
#endif // GD_SERVICE_TEST_H
/* End of service_test.h */

@ -0,0 +1,160 @@
#ifndef EGS_PLACE_HOLDER_H
#define EGS_PLACE_HOLDER_H
#include "nel/misc/smart_ptr.h"
#include "nel/misc/enum_bitset.h"
#include "nel/misc/sheet_id.h"
#include "nel/net/cvar_log_filter.h"
#include "game_share/skills.h"
#include "game_share/characteristics.h"
#include "game_share/type_skill_mod.h"
#include "game_share/item_family.h"
#include "game_share/item_type.h"
#include "game_share/inventories.h"
#include "entities_game_service/game_item_manager/weapon_craft_parameters.h"
#include "entities_game_service/weapon_damage_table.h"
NL_DECLARE_CVAR_INFO_LOG_FUNCTION(egs_giinfo, GameItemLogEnabled, true)
class CGameItemPtr;
class CInventoryBase : public NLMISC::CRefCount
{
public:
enum // for pseudo constantes
{
INSERT_IN_FIRST_FREE_SLOT = 0xFFFFFFFF,
REMOVE_MAX_STACK_QUANTITY = 0xFFFFFFFF,
INVALID_INVENTORY_SLOT = INSERT_IN_FIRST_FREE_SLOT,
};
enum TItemChange
{
itc_bulk = 1<<0,
itc_weight = 1<<1,
itc_enchant = 1<<2,
itc_hp = 1<<3,
itc_inserted = 1<<4,
itc_removed = 1<<5,
itc_lock_state = 1<<6,
itc_info_version = 1<<7,
itc_worned = 1<<8,
};
enum TInventoryOpResult
{
ior_overbulk,
};
typedef NLMISC::CEnumBitset<TItemChange> TItemChangeFlags;
uint getSlotCount() {return 0;};
virtual void onItemStackSizeChanged(uint32 slot, uint32 previousStackSize) {}
virtual void onItemChanged(uint32 slot, CInventoryBase::TItemChangeFlags changeFlags) {}
virtual CGameItemPtr removeItem(uint32 slot, uint32 quantity = REMOVE_MAX_STACK_QUANTITY, TInventoryOpResult * res = NULL);
virtual TInventoryOpResult insertItem(CGameItemPtr &item, uint32 slot = INSERT_IN_FIRST_FREE_SLOT, bool autoStack = false) { return ior_overbulk;}
};
typedef NLMISC::CSmartPtr<class CInventoryBase> CInventoryPtr;
namespace ITEM_WORN_STATE
{
enum TItemWornState
{
Unspoiled = 0,
WornState1,
WornState2,
WornState3,
WornState4,
Worned,
};
}
class CPlayerManager
{
};
struct CMP
{
uint16 StatEnergy; // 0..100
};
class CStaticBrick
{
};
class CStaticItem
{
public:
float getBaseWeight() const;
std::string Name;
uint32 Weight;
uint32 Bulk;
NLMISC::CSheetId CraftPlan;
SKILLS::ESkills RequiredSkill;
SKILLS::ESkills RequiredSkill2;
CHARACTERISTICS::TCharacteristics RequiredCharac;
std::vector<CTypeSkillMod> TypeSkillMods;
float RequiredSkillQualityFactor;
sint16 RequiredSkillQualityOffset;
uint16 MinRequiredSkillLevel;
float RequiredSkillQualityFactor2;
sint16 RequiredSkillQualityOffset2;
uint16 MinRequiredSkillLevel2;
float RequiredCharacQualityFactor;
sint16 RequiredCharacQualityOffset;
uint16 MinRequiredCharacLevel;
uint32 Stackable;
ITEMFAMILY::EItemFamily Family;
CMP * Mp;
ITEM_TYPE::TItemType Type;
};
class CSheets
{
public:
static CStaticItem *getForm(const NLMISC::CSheetId &sheet) {return NULL;};
static const CStaticBrick* getSBrickForm( const NLMISC::CSheetId& sheetId );
};
//NL_DECLARE_CVAR_INFO_LOG_FUNCTION(egs_giinfo, GameItemLogEnabled, true)
extern NLMISC::CVariable<float> WornState1;
extern NLMISC::CVariable<float> WornState2;
extern NLMISC::CVariable<float> WornState3;
extern NLMISC::CVariable<float> WornState4;
class CGameItemManager
{
public:
};
extern CGameItemManager GameItemManager;
class CCharacter
{
public:
inline const TDataSetRow& getEntityRowId() const
{
static TDataSetRow foo;
return foo;
}
const CInventoryPtr &getInventory(INVENTORIES::TInventory id) const;
};
#endif

@ -0,0 +1,45 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/dynloadlib.h"
#include "src/cpptest.h"
using namespace std;
Test::Suite *createPrimitiveObjectTS(const std::string &workingPath);
Test::Suite *createModuleInterfaceTS();
// global test for any game share feature
class CGameShareTS : public Test::Suite
{
public:
CGameShareTS(const std::string &workingPath)
{
add(auto_ptr<Test::Suite>(createPrimitiveObjectTS(workingPath)));
add(auto_ptr<Test::Suite>(createModuleInterfaceTS()));
// initialise the application context
NLMISC::CApplicationContext::getInstance();
NLMISC::createDebug();
}
private:
};
//
//// register the misc test suite
//void registerNelMiscTestSuite(Test::Suite &mainTestSuite)
//{
// mainTestSuite.add(auto_ptr<Test::Suite>(new CMiscTestSuite));
//}
auto_ptr<Test::Suite> intRegisterTestSuite(const std::string &workingPath)
{
return static_cast<Test::Suite*>(new CGameShareTS(workingPath));
}
NL_LIB_EXPORT_SYMBOL(registerTestSuite, void, intRegisterTestSuite);

@ -0,0 +1,246 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/dynloadlib.h"
#include "nel/misc/path.h"
#include "nel/net/unified_network.h"
#include "nel/net/module.h"
#include "nel/net/module_manager.h"
#include "nel/net/module_builder_parts.h"
#include "src/cpptest.h"
#include "test_module_itf.h"
using namespace std;
using namespace NLMISC;
using namespace NLNET;
using namespace TST_MOD_ITF;
//class A
//{
//public:
// void getParentFromA()
// {
// getParent("A");
// }
// virtual void getParent(const char*) =0;
//};
//
//class B
//{
//public:
// void getParentFromB()
// {
// getParent("B");
// }
// virtual void getParent(const char*) =0;
//};
//
//
//class C
//: public A, B
//{
//public:
//
// C()
// {
// getParentFromA();
// getParentFromB();
// }
//
// virtual void getParent(const char*childName)
// {
// printf("Child %s called getParent", childName);
// }
//};
//
//C c;
//
//class D
//{
// virtual void getParent(const char*childName)
// {
// printf("Child %s called getParent", childName);
// }
//};
class CModuleServant
: public CEmptyModuleServiceBehav<CEmptyModuleCommBehav<CEmptySocketBehav<CModuleBase> > >,
public CTestModuleInterfaceSkel
{
bool _ImmediateDispatching;
public:
CModuleServant()
{
CTestModuleInterfaceSkel::init(this);
_ImmediateDispatching = false;
}
bool isImmediateDispatchingSupported() const
{
return _ImmediateDispatching;
}
// void onProcessModuleMessage(IModuleProxy *sender, const CMessage &message)
// {
// if (CTestModuleInterfaceSkel::onDispatchMessage(sender, message))
// return;
//
// nlassert(false);
// }
void noParam(NLNET::IModuleProxy *sender)
{
}
uint32 twoWayInvoke(NLNET::IModuleProxy *sender, uint32 value1, uint32 value2)
{
return value1+value2;
}
void setImmediateDispatching(bool value)
{
_ImmediateDispatching = value;
}
};
NLNET_REGISTER_MODULE_FACTORY(CModuleServant, "ModuleServant");
class CModuleClient
: public CEmptyModuleServiceBehav<CEmptyModuleCommBehav<CEmptySocketBehav<CModuleBase> > >
{
public:
TModuleProxyPtr Servant;
bool TaskRunning;
uint32 Result;
void startTask()
{
TaskRunning = true;
NLNET_START_MODULE_TASK(CModuleClient, taskFunc);
}
void onModuleUp(IModuleProxy *proxy)
{
if (proxy->getModuleClassName() == "ModuleServant")
{
Servant = proxy;
}
}
void onModuleDown(IModuleProxy *proxy)
{
if (proxy == Servant)
Servant = NULL;
}
void taskFunc()
{
while (Servant == NULL)
{
if (getActiveModuleTask()->isTerminationRequested())
return;
getActiveModuleTask()->yield();
}
CTestModuleInterfaceProxy tmi(Servant);
Result = tmi.twoWayInvoke(this, 32, 4);
TaskRunning = false;
}
void callImmediat()
{
nlassert(Servant != NULL);
CTestModuleInterfaceProxy tmi(Servant);
Result = tmi.twoWayInvoke(this, 32, 4);
}
};
NLNET_REGISTER_MODULE_FACTORY(CModuleClient, "ModuleClient");
class CModuleInterfaceTS: public Test::Suite
{
public:
CModuleInterfaceTS()
{
TEST_ADD(CModuleInterfaceTS::testTwoWay);
}
void testTwoWay()
{
// create two modules and test the two way invocation protocol
IModuleManager::getInstance();
CCommandRegistry &cr = CCommandRegistry::getInstance();
cr.execute("moduleManager.createModule StandardGateway gw", InfoLog());
cr.execute("moduleManager.createModule ModuleServant srv", InfoLog());
cr.execute("moduleManager.createModule ModuleClient clt", InfoLog());
// plug the modules
cr.execute("srv.plug gw", InfoLog());
cr.execute("clt.plug gw", InfoLog());
// retreive the client module
IModule *mod = IModuleManager::getInstance().getLocalModule("clt");
TEST_ASSERT(mod != NULL);
CModuleClient *client = dynamic_cast<CModuleClient *>(mod);
TEST_ASSERT(client != NULL);
CModuleServant *servant = dynamic_cast<CModuleServant *>(IModuleManager::getInstance().getLocalModule("srv"));
TEST_ASSERT(servant != NULL);
client->startTask();
// update the modules
for (uint i=0; i<10; ++i)
{
IModuleManager::getInstance().updateModules();
nlSleep(10);
}
// check that the client have received the response
TEST_ASSERT(client->TaskRunning == false);
// check that the result is ok
TEST_ASSERT(client->Result == 36);
// Retry with immediate dispatching and direct call thank to the interface gernerator
client->Result = 0;
servant->setImmediateDispatching(true);
client->callImmediat();
// check that the result is ok
TEST_ASSERT(client->Result == 36);
// cleanup
// detroy the modules
cr.execute("moduleManager.deleteModule gw", InfoLog());
cr.execute("moduleManager.deleteModule srv", InfoLog());
cr.execute("moduleManager.deleteModule clt", InfoLog());
}
};
Test::Suite *createModuleInterfaceTS()
{
return static_cast<Test::Suite*>(new CModuleInterfaceTS());
}

@ -0,0 +1,145 @@
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
#include "test_module_itf.h"
namespace TST_MOD_ITF
{
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
const CTestModuleInterfaceSkel::TMessageHandlerMap &CTestModuleInterfaceSkel::getMessageHandlers() const
{
static TMessageHandlerMap handlers;
static bool init = false;
if (!init)
{
std::pair < TMessageHandlerMap::iterator, bool > res;
res = handlers.insert(std::make_pair(std::string("TMI_NP"), &CTestModuleInterfaceSkel::noParam_skel));
// if this assert, you have a doubly message name in your interface definition !
nlassert(res.second);
res = handlers.insert(std::make_pair(std::string("TMI_TWI"), &CTestModuleInterfaceSkel::twoWayInvoke_skel));
// if this assert, you have a doubly message name in your interface definition !
nlassert(res.second);
init = true;
}
return handlers;
}
bool CTestModuleInterfaceSkel::fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message)
{
const TMessageHandlerMap &mh = getMessageHandlers();
TMessageHandlerMap::const_iterator it(mh.find(message.getName()));
if (it == mh.end())
{
return false;
}
TMessageHandler cmd = it->second;
(this->*cmd)(sender, message);
return true;
}
void CTestModuleInterfaceSkel::noParam_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message)
{
H_AUTO(CTestModuleInterfaceSkel_noParam_TMI_NP);
noParam(sender);
}
void CTestModuleInterfaceSkel::twoWayInvoke_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message)
{
H_AUTO(CTestModuleInterfaceSkel_twoWayInvoke_TMI_TWI);
uint32 value1;
nlRead(__message, serial, value1);
uint32 value2;
nlRead(__message, serial, value2);
uint32 __ret = twoWayInvoke(sender, value1, value2);
// encode the return message
NLNET::CMessage __retMsg;
__retMsg.setType("R_TMI_TWI", NLNET::CMessage::Response);
nlWrite(__retMsg, serial, __ret);
// and send back the response
sender->sendModuleMessage(static_cast<NLNET::IModule*>(_Interceptor.getRegistrar()), __retMsg);
}
void CTestModuleInterfaceProxy::noParam(NLNET::IModule *sender)
{
if (_LocalModuleSkel && _LocalModule->isImmediateDispatchingSupported())
{
// immediate local synchronous dispatching
_LocalModuleSkel->noParam(_ModuleProxy->getModuleGateway()->getPluggedModuleProxy(sender));
}
else
{
// send the message for remote dispatching and execution or local queing
NLNET::CMessage __message;
buildMessageFor_noParam(__message);
_ModuleProxy->sendModuleMessage(sender, __message);
}
}
uint32 CTestModuleInterfaceProxy::twoWayInvoke(NLNET::IModule *sender, uint32 value1, uint32 value2)
{
if (_LocalModuleSkel && _LocalModule->isImmediateDispatchingSupported())
{
// immediate local synchronous dispatching
return _LocalModuleSkel->twoWayInvoke(_ModuleProxy->getModuleGateway()->getPluggedModuleProxy(sender), value1, value2);
}
else
{
// send the message for remote dispatching and execution
NLNET::CMessage __message;
buildMessageFor_twoWayInvoke(__message, value1, value2);
NLNET::CMessage __retMsg;
sender->invokeModuleOperation(_ModuleProxy, __message, __retMsg);
// check the return message type
if (__retMsg.getName() != "R_TMI_TWI")
throw NLNET::IModule::EInvokeBadReturn();
uint32 __ret;
nlRead(__retMsg, serial, __ret);
return __ret;
}
}
// Message serializer. Return the message received in reference for easier integration
const NLNET::CMessage &CTestModuleInterfaceProxy::buildMessageFor_noParam(NLNET::CMessage &__message)
{
__message.setType("TMI_NP");
return __message;
}
// Message serializer. Return the message received in reference for easier integration
const NLNET::CMessage &CTestModuleInterfaceProxy::buildMessageFor_twoWayInvoke(NLNET::CMessage &__message, uint32 value1, uint32 value2)
{
__message.setType("TMI_TWI", NLNET::CMessage::Request);
nlWrite(__message, serial, value1);
nlWrite(__message, serial, value2);
return __message;
}
}

@ -0,0 +1,143 @@
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
#ifndef TEST_MODULE_INTERFACE
#define TEST_MODULE_INTERFACE
#include "nel/misc/hierarchical_timer.h"
#include "nel/misc/string_conversion.h"
#include "nel/net/message.h"
#include "nel/net/module.h"
#include "nel/net/module_builder_parts.h"
#include "nel/net/module_message.h"
#include "nel/net/module_gateway.h"
namespace TST_MOD_ITF
{
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
class CTestModuleInterfaceSkel
{
public:
/// the interceptor type
typedef NLNET::CInterceptorForwarder < CTestModuleInterfaceSkel> TInterceptor;
protected:
CTestModuleInterfaceSkel()
{
// do early run time check for message table
getMessageHandlers();
}
virtual ~CTestModuleInterfaceSkel()
{
}
void init(NLNET::IModule *module)
{
_Interceptor.init(this, module);
}
public:
// unused interceptors
std::string fwdBuildModuleManifest() const { return std::string(); }
void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {};
void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {};
void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {};
// process module message interceptor
bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
private:
typedef void (CTestModuleInterfaceSkel::*TMessageHandler)(NLNET::IModuleProxy *sender, const NLNET::CMessage &message);
typedef std::map<std::string, TMessageHandler> TMessageHandlerMap;
const TMessageHandlerMap &getMessageHandlers() const;
void noParam_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
void twoWayInvoke_skel(NLNET::IModuleProxy *sender, const NLNET::CMessage &__message);
// declare one interceptor member of the skeleton
TInterceptor _Interceptor;
// declare the interceptor forwarder as friend of this class
friend class NLNET::CInterceptorForwarder < CTestModuleInterfaceSkel>;
public:
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
virtual void noParam(NLNET::IModuleProxy *sender) =0;
virtual uint32 twoWayInvoke(NLNET::IModuleProxy *sender, uint32 value1, uint32 value2) =0;
};
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
class CTestModuleInterfaceProxy
{
/// Smart pointer on the module proxy
NLNET::TModuleProxyPtr _ModuleProxy;
// Pointer on the local module that implement the interface (if the proxy is for a local module)
NLNET::TModulePtr _LocalModule;
// Direct pointer on the server implementation interface for collocated module
CTestModuleInterfaceSkel *_LocalModuleSkel;
public:
CTestModuleInterfaceProxy(NLNET::IModuleProxy *proxy)
{
_ModuleProxy = proxy;
// initialize collocated servant interface
if (proxy->getModuleDistance() == 0)
{
_LocalModule = proxy->getLocalModule();
nlassert(_LocalModule != NULL);
CTestModuleInterfaceSkel::TInterceptor *interceptor = NULL;
interceptor = static_cast < NLNET::CModuleBase* >(_LocalModule.getPtr())->getInterceptor(interceptor);
nlassert(interceptor != NULL);
_LocalModuleSkel = interceptor->getParent();
nlassert(_LocalModuleSkel != NULL);
}
else
_LocalModuleSkel = 0;
}
virtual ~CTestModuleInterfaceProxy()
{
}
NLNET::IModuleProxy *getModuleProxy()
{
return _ModuleProxy;
}
void noParam(NLNET::IModule *sender);
uint32 twoWayInvoke(NLNET::IModule *sender, uint32 value1, uint32 value2);
// Message serializer. Return the message received in reference for easier integration
static const NLNET::CMessage &buildMessageFor_noParam(NLNET::CMessage &__message);
// Message serializer. Return the message received in reference for easier integration
static const NLNET::CMessage &buildMessageFor_twoWayInvoke(NLNET::CMessage &__message, uint32 value1, uint32 value2);
};
}
#endif

@ -0,0 +1,22 @@
<generator header_tag="TEST_MODULE_INTERFACE">
<namespace name="TST_MOD_ITF">
<module_interface name="CTestModuleInterface">
<method name="noParam" msg="TMI_NP">
</method>
<method name="twoWayInvoke" msg="TMI_TWI">
<return type="uint32"/>
<param type="uint32" name="value1"/>
<param type="uint32" name="value2"/>
</method>
</module_interface>
</namespace>
</generator>

@ -0,0 +1,388 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/dynloadlib.h"
#include "nel/misc/path.h"
#include "nel/net/service.h"
#include "nel/net/module_manager.h"
#include "src/cpptest.h"
#include "game_share/mysql_wrapper.h"
#include "client/session_browser.h"
#include <cstdlib>
#include <mysql.h>
using namespace std;
using namespace NLMISC;
using namespace NLNET;
using namespace RSMGR;
extern void session_browser_force_link();
void foo()
{
session_browser_force_link();
}
const nbUserField = 4;
const char *userData[][nbUserField] =
{
{ "10000", "test_user1", "DF01A8C0|0674E006|00002710", "cs_offline"},
{ "10001", "test_user2", "DF01A8C0|0674E006|00002711", "cs_online"},
{ "268435455", "bad_user", "DF01A8C0|0674E006|FFFFFFFF", "cs_online"},
};
class CSessionBrowserTS
: public Test::Suite,
public CSessionBrowser
{
string _WorkingPath;
// string _BaseDir;
// string _CurrentPath;
// string _CurrentPathToRestore;
bool _ConnFailed;
bool _DisconnectionReceived;
bool _SessionReceived;
std::vector < TSessionDesc > _Sessions;
MSW::CConnection _RingDb;
IService _Service;
public:
CSessionBrowserTS(const std::string &workingPath)
{
_WorkingPath = workingPath;
NLMISC::createDebug();
// add a variable
CConfigFile::CVar mainlandNames;
mainlandNames.Type = CConfigFile::CVar::T_STRING;
mainlandNames.StrValues.resize(9);
mainlandNames.setAsString("101", 0);
mainlandNames.setAsString("Aniro", 1);
mainlandNames.setAsString("ani", 2);
mainlandNames.setAsString("102", 3);
mainlandNames.setAsString("Leanon", 4);
mainlandNames.setAsString("lea", 5);
mainlandNames.setAsString("103", 6);
mainlandNames.setAsString("Arispotle", 7);
mainlandNames.setAsString("ari", 8);
IService::getInstance()->ConfigFile.insertVar("HomeMainlandNames", mainlandNames);
// check database population
nlverify(_RingDb.connect("borisb2", "root", "", "ring"));
CCommandRegistry &cr = CCommandRegistry::getInstance();
cr.execute("moduleManager.createModule StandardGateway gw", InfoLog());
cr.execute("moduleManager.createModule SessionBrowserServerMod sbs suAddr=localhost:49999 listenPort=1234 ring_db(host=borisb2 user=ring password= base=ring)", InfoLog());
cr.execute("suc.plug gw", InfoLog());
// fill the database with some users
// cleanup the previously created users
CSString query;
query << "DELETE FROM ring_users WHERE user_id >= 10000";
_RingDb.query(query);
for (uint i=0; i<sizeofarray(userData); ++i)
{
CSString query;
query << "INSERT INTO ring_users (user_id, user_name, cookie, current_status)";
query << " VALUES (";
for (uint j=0; j<nbUserField; ++j)
{
query << "'" << userData[i][j] <<"'";
if (j != nbUserField-1)
query << ", ";
}
query << ")";
_RingDb.query(query);
}
// fill the database with some character
const nbCharField = 9;
const char *charData[][nbCharField] =
{
// char_id, char_name, user_id, guil_id, best_combat_level, home_mainland_session_id, race, civilisation, cult
{ "160000", "test_char1", "10000", "0", "20", "102", "r_fyros", "c_fyros", "c_neutral" },
{ "160016", "test_char2", "10001", "0", "20", "102", "r_fyros", "c_fyros", "c_neutral" },
{ "4294967280", "bad_char", "268435455", "0", "20", "102", "r_fyros", "c_fyros", "c_neutral" },
};
// cleanup the previously created users
query = "DELETE FROM characters WHERE char_id >= 160000";
_RingDb.query(query);
for (uint i=0; i<sizeofarray(charData); ++i)
{
CSString query;
query << "INSERT INTO characters (char_id, char_name, user_id, guild_id, best_combat_level, home_mainland_session_id, race, civilisation, cult)";
query << " VALUES (";
for (uint j=0; j<nbCharField; ++j)
{
query << "'" << charData[i][j] <<"'";
if (j != nbCharField-1)
query << ", ";
}
query << ")";
_RingDb.query(query);
}
#define RACE_FILTER_ALL "rf_neutral,rf_matis,rf_fyros,rf_tryker,rf_zorai"
#define RELIG_ALL "rf_neutral,rf_kami,rf_karavan"
// fill the database with some guilds
const uint nbSessionField = 9;
const char *sessionData[][nbSessionField] =
{
// session_id session_type title owner level state host_shard_id race_filter religion_filter
{ "100000", "st_anim", "ts_1", "16000", "sl_a", "ss_open", "100", RACE_FILTER_ALL , RELIG_ALL },
{ "100001", "st_anim", "ts_2", "16001", "sl_b", "ss_open", "100", RACE_FILTER_ALL , RELIG_ALL },
{ "100002", "st_anim", "ts_2", "16001", "sl_b", "ss_open", "100", "rf_matis" , RELIG_ALL },
};
// cleanup the previously created sessions
query = "DELETE FROM sessions WHERE session_id >= 100000";
_RingDb.query(query);
for (uint i=0; i<sizeofarray(sessionData); ++i)
{
CSString query;
query << "INSERT INTO sessions (session_id, session_type, title, owner, level, state, host_shard_id, race_filter, religion_filter, guild_filter)";
query << " VALUES (";
for (uint j=0; j<nbSessionField; ++j)
{
query << "'" << sessionData[i][j] <<"'";
if (j != nbSessionField-1)
query << ", ";
}
query << ", 'gf_any_player')";
_RingDb.query(query);
}
// add the tests methods
TEST_ADD(CSessionBrowserTS::failAuth);
TEST_ADD(CSessionBrowserTS::listSession);
TEST_ADD(CSessionBrowserTS::failListSession_disconnected);
}
void setup()
{
_ConnFailed = false;
_DisconnectionReceived = false;
_SessionReceived = false;
_Sessions.clear();
}
~CSessionBrowserTS()
{
CPath::setCurrentPath(_WorkingPath.c_str());
// delete _Context;
}
void updateNetwork()
{
for (uint i=0; i<50; ++i)
{
nlSleep(100);
update();
IModuleManager::getInstance().updateModules();
}
}
void connectAndAuth(uint32 userIndex)
{
CLoginCookie cookie;
cookie.setFromString(userData[userIndex][2]);
setAuthInfo(cookie);
connectItf(CInetAddress("localhost:1234"));
}
void failListSession_disconnected()
{
connectAndAuth(2);
getSessionList(0xffffffff);
// update the network
updateNetwork();
TEST_ASSERT(_DisconnectionReceived);
TEST_ASSERT(!_SessionReceived);
TEST_ASSERT(_Sessions.size() == 0);
}
void failAuth()
{
connectItf(CInetAddress("localhost:1234"));
_Sessions.clear();
_SessionReceived = false;
getSessionList(160016);
// update the network
updateNetwork();
TEST_ASSERT(_DisconnectionReceived);
TEST_ASSERT(!_SessionReceived);
}
void listSession()
{
connectAndAuth(1);
getSessionList(160016);
// update the network
updateNetwork();
TEST_ASSERT(_DisconnectionReceived);
TEST_ASSERT(_SessionReceived);
TEST_ASSERT(_Sessions.size() == 1);
}
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
/// Disconnection callback : the connection to the server is lost
virtual void on_CRingSessionManagerWebClient_Disconnection(NLNET::TSockId from)
{
nlstop;
}
// Generic response to invoke.
// result contains 0 if no error, more than 0 in case of error
virtual void on_invokeResult(NLNET::TSockId from, uint32 userId, uint32 resultCode, const std::string &resultString)
{
// forward the response to the appropriate client
nlstop;
}
// result is : 0 : session have been created fine
// 1 : invalid session type
// 2 : invalid level
// 3 : unknown character
// 4 : not used
// 5 : invalid access type
// 6 : invalid rule type
// 7 : invalid duration
virtual void on_scheduleSessionResult(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint8 result, const std::string &resultString)
{
nlstop;
}
// Return the result of the session joining attempt
// If join is ok, the shardAddr contain <ip:port> of the
// Front end that waits for the player to come in and the.
// participation mode for the character (editor, animator or player).
// If ok, the web must return a page with a lua script.
// that trigger the action handler 'on_connect_to_shard' :
// <lua>runAH(nul, "on_connect_to_shard", "cookie=cookieValue|fsAddr=shardAddr|mode=participantStatus");<lua>
// result : 0 : ok the client can join the session
// 1 : char not found
// 2 : session not found
// 3 : no session participant for this character (not used for a mainland shard)
// 4 : can't find session server (not used for a mainland shard)
// 5 : shard hosting session is not reachable
// 6 : nel user info not found
// 7 : ring user not found
// 8 : welcome service rejected connection request
// 9 : session service shutdown (not used for a mainland shard)
// 10 : no mainland shard found (joinMainland only)
// 11 : internal error
// 12 : failed to request for access permission
// 13 : can't find access permission for user and domain
// 14 : Welcome service is closed for you
virtual void on_joinSessionResult(NLNET::TSockId from, uint32 userId, uint32 result, const std::string &shardAddr, const std::string &participantStatus)
{
nlstop;
}
// Return the list of online shards on which the user is allowed to connect,
// and their current dynamic attributes. Other attributes (e.g. names)
// can be queried from the database. Offline shards are the ones in the database
// of the same domain but not listed in the result.
// Then the client will have to call joinShard to connect on an online shard.
virtual void on_getShardsResult(NLNET::TSockId from, uint32 userId, const std::string &result)
{
nlstop;
}
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
/// Disconnection callback : the connection to the server is lost
virtual void on_CSessionBrowserServerWebClient_Disconnection(NLNET::TSockId from)
{
nldebug("Lost connection with server");
_DisconnectionReceived = true;
}
// Return the list of available session
virtual void on_sessionList(NLNET::TSockId from, uint32 charId, const std::vector < TSessionDesc > &sessions)
{
_SessionReceived = true;
_Sessions = sessions;
}
///////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////
virtual void on_connectionFailed()
{
_ConnFailed = true;
}
// // The connection has been closed.
// virtual void on_connectionClosed()
// {
// nlstop;
// }
};
NLMISC::CApplicationContext *Context;
auto_ptr<Test::Suite> intRegisterTestSuite(const std::string &workingPath)
{
Context = new CApplicationContext();
// init a new nel instance
INelContext::getInstance();
// init the module manager
IModuleManager::getInstance();
return static_cast<Test::Suite*>(new CSessionBrowserTS(workingPath));
}
NL_LIB_EXPORT_SYMBOL(registerTestSuite, void, intRegisterTestSuite);

@ -0,0 +1,336 @@
/** Test file for the ring sesison manager module */
#include "nel/misc/types_nl.h"
#include "nel/misc/command.h"
#include "nel/net/module.h"
#include "nel/net/module_builder_parts.h"
#include "nel/net/module_manager.h"
#include "nel/net/unified_network.h"
#include "nel/net/service.h"
#include "src/cpptest.h"
#include "game_share/mysql_wrapper.h"
#include "entities_game_service/player_manager/player_manager_interface.h"
#include "entities_game_service/player_manager/character_interface.h"
#include "entities_game_service/modules/shard_unifier_client.h"
#include "entities_game_service/modules/char_name_mapper_client.h"
#include "shard_unifier_service/database_mapping.h"
using namespace std;
using namespace NLMISC;
using namespace NLNET;
using namespace RSMGR;
// some globals for the test
static TSessionId sessionId(0);
uint32 userId1 = 1;
static uint32 charId = (userId1*16)+0;
uint32 userId2 = 2;
static uint32 invitedCharId = (userId2*16)+0;
class CPlayer;
void sendCharactersSummary( CPlayer *player, bool AllAutorized)
{
}
/** Interface to the char name mapper client singleton */
class CCharNameMapperClient : public ICharNameMapperClient
{
public:
void mapCharacterName(const NLMISC::CEntityId &charEid, const ucstring &charName)
{
}
};
CCharNameMapperClient charNameMapper;
class CCharacter;
class CPHCharacter : public ICharacter
{
virtual const NLMISC::CEntityId& getCharId() const
{
static NLMISC::CEntityId eid;
return eid;
}
virtual void setName(const ucstring &name)
{
}
virtual bool getEnterFlag() const
{
return true;
}
virtual uint32 getLastDisconnectionDate()
{
return 0;
}
};
ICharacter *ICharacter::getInterface(::CCharacter *character, bool onlyOnline)
{
return NULL;
}
ICharacter *ICharacter::getInterface(uint32 charId, bool onlyOnline)
{
return NULL;
}
void cbCreateChar_part2(uint32 userId, const CCreateCharMsg &createCharMsg, bool ok)
{
}
void sendIfNameIsValide( uint32 userId, bool nameValide )
{
}
class CPlayerManagerPH : public IPlayerManager
{
TMapPlayers _Players;
virtual const TMapPlayers& getPlayers()
{
return _Players;
}
/** Get the active character for the given player id */
virtual ::CCharacter * getActiveChar( uint32 userId )
{
return NULL;
}
/** Get the specified character of a player */
virtual ::CCharacter * getChar( uint32 userId, uint32 index )
{
return NULL;
}
/** A character has been renamed by name unifier */
virtual void characterRenamed(uint32 charId, const std::string &newName)
{
}
virtual void sendImpulseToClient(const NLMISC::CEntityId & id, const std::string & msgName )
{
}
virtual void addAllCharForStringIdRequest()
{
}
virtual void addEntityForStringIdRequest(const NLMISC::CEntityId &eid)
{
}
virtual void checkContactLists()
{
}
virtual void playerEntityRemoved(const NLMISC::CEntityId &eid)
{
}
};
CPlayerManagerPH playerManager;
IPlayerManager *IPlayerManager::_Instance = NULL;
class CTestService : public NLNET::IService
{
};
class CCharacterSyncTS: public Test::Suite
{
MSW::CConnection _Conn;
string OldPath;
public:
CCharacterSyncTS(const std::string &workingPath)
{
OldPath = CPath::getCurrentPath();
CPath::setCurrentPath(workingPath.c_str());
// force instanciation of the module manager
IModuleManager::getInstance();
// create the session manager module
CCommandRegistry &cr = CCommandRegistry::getInstance();
string DBHost = "borisb2";
// create a pseudo service
CTestService service;
service.setArgs("-Zu");
service.main("TS", "test_service", 0, ".", ".", "");
service.anticipateShardId(100);
cr.execute("addNegativeFilterInfo EIT", InfoLog());
cr.execute("moduleManager.createModule StandardGateway gw", InfoLog());
cr.execute("moduleManager.createModule ShardUnifierClient suc", InfoLog());
cr.execute("suc.plug gw", InfoLog());
cr.execute("moduleManager.createModule CharacterSynchronisation cs ring_db(host="+DBHost+" user=root password= base=ring) nel_db(host="+DBHost+" user=root password= base=nel)", InfoLog());
cr.execute("cs.plug gw", InfoLog());
// check module creation
nlassert(IModuleManager::getInstance().getLocalModule("suc") != NULL);
nlassert(IModuleManager::getInstance().getLocalModule("cs") != NULL);
nlassert(IModuleManager::getInstance().getLocalModule("gw") != NULL);
// check database population
nlverify(_Conn.connect(DBHost, "root", "", "ring"));
// check the first user id
CRingUserPtr ru = CRingUser::load(_Conn, userId1, __FILE__, __LINE__);
if (ru == NULL)
{
// create a new record
ru = CRingUser::createTransient(__FILE__, __LINE__);
ru->setUserName("toto");
// ru->setCurrentSession(0);
nlverify(ru->create(_Conn));
userId1 = ru->getObjectId();
}
charId = (userId1 * 16)+0;
// check the character
CCharacterPtr character = RSMGR::CCharacter::load(_Conn, charId, __FILE__, __LINE__);
if (character == NULL)
{
// create a character
character = RSMGR::CCharacter::createTransient(__FILE__, __LINE__);
character->setObjectId(charId);
character->setCharName("toto_char");
character->setUserId(userId1);
character->setGuildId(0);
character->setBestCombatLevel(100);
nlverify(character->create(_Conn));
}
// check the second user id
ru = CRingUser::load(_Conn, userId2, __FILE__, __LINE__);
if (ru == NULL)
{
// create a new record
ru = CRingUser::createTransient(__FILE__, __LINE__);
ru->setUserName("invited");
// ru->setCurrentSession(0);
nlverify(ru->create(_Conn));
userId2 = ru->getObjectId();
}
invitedCharId = (userId2 * 16)+0;
// check the character
character = RSMGR::CCharacter::load(_Conn, invitedCharId, __FILE__, __LINE__);
if (character == NULL)
{
// create a character
character = RSMGR::CCharacter::createTransient(__FILE__, __LINE__);
character->setObjectId(invitedCharId);
character->setCharName("invited_char");
character->setUserId(userId2);
character->setGuildId(0);
character->setBestCombatLevel(100);
nlverify(character->create(_Conn));
}
// add the tests
TEST_ADD(CCharacterSyncTS::addCharacter);
}
~CCharacterSyncTS()
{
// delete the session manager module
CCommandRegistry &cr = CCommandRegistry::getInstance();
cr.execute("moduleManager.deleteModule suc", InfoLog());
cr.execute("moduleManager.deleteModule cs", InfoLog());
cr.execute("moduleManager.deleteModule gw", InfoLog());
// remove the object created for the test
if (userId1 != 1)
{
CRingUserPtr ru = CRingUser::load(_Conn, userId1, __FILE__, __LINE__);
if (ru != NULL)
ru->remove(_Conn);
ru = CRingUser::load(_Conn, userId2, __FILE__, __LINE__);
if (ru != NULL)
ru->remove(_Conn);
}
_Conn.closeConn();
CPath::setCurrentPath(OldPath.c_str());
}
void addCharacter()
{
// egs create a new character in slot 0
uint32 newCharId = (userId1<<4)+0;
TEST_ASSERT(IShardUnifierEvent::getInstance() != NULL);
CCharacterPtr character = RSMGR::CCharacter::load(_Conn, newCharId, __FILE__, __LINE__);
if (character != NULL)
{
character->remove(_Conn);
character = CCharacterPtr();
}
CHARSYNC::TCharInfo charInfo;
charInfo.setCharEId(CEntityId(0, newCharId));
charInfo.setBestCombatLevel(10);
charInfo.setCharName("0th character");
IShardUnifierEvent::getInstance()->onNewChar(charInfo);
// message dispatch will be done immediately, so the result should be cool right now
character = RSMGR::CCharacter::load(_Conn, newCharId, __FILE__, __LINE__);
TEST_ASSERT(character != NULL);
TEST_ASSERT(character->getBestCombatLevel() == 10);
TEST_ASSERT(character->getCharName() == "0th character");
}
};
Test::Suite *createCCharacterSyncTS(const std::string &workingPath)
{
return new CCharacterSyncTS(workingPath);
}

@ -0,0 +1,440 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/dynloadlib.h"
#include "nel/misc/path.h"
#include "nel/net/service.h"
#include "src/cpptest.h"
#include "game_share/mysql_wrapper.h"
#include "test_mapping.h"
#include <cstdlib>
#include <mysql.h>
using namespace std;
using namespace NLMISC;
using namespace NLNET;
using namespace TM;
class CNopeTS: public Test::Suite
{
string _WorkingPath;
// string _BaseDir;
// string _CurrentPath;
// string _CurrentPathToRestore;
// database connection
MSW::CConnection _Conn;
uint32 _RootId;
// NLMISC::CApplicationContext *_Context;
public:
CNopeTS(const std::string &workingPath)
{
NLMISC::CPath::setCurrentPath((workingPath+"/test_files/shard_unifier_test").c_str());
// connect to the database
MYSQL *mysql;
mysql = mysql_init(NULL);
nlverify(mysql_real_connect(mysql, "borisb2", NULL, NULL, NULL, 0,NULL,0) == mysql);
const char *error = mysql_error(mysql);
// build the database and table needed for the test
nlverify(mysql_query(mysql, "DROP DATABASE test") == 0);
nlverify(mysql_query(mysql, "CREATE DATABASE test") == 0);
nlverify(mysql_select_db(mysql, "test") == 0);
nlverify(mysql_query(mysql, "CREATE TABLE `map_child` ( \
`Id` int(10) unsigned NOT NULL default '0',\
`parent_id` int(10) unsigned NOT NULL default '0',\
PRIMARY KEY (`Id`)\
) TYPE=MyISAM;") == 0);
nlverify(mysql_query(mysql, "CREATE TABLE `one_child` (\
`Id` int(10) unsigned NOT NULL default '0',\
PRIMARY KEY (`Id`)\
) TYPE=MyISAM;") == 0);
nlverify(mysql_query(mysql, "CREATE TABLE `root_table` (\
`Id` int(10) unsigned NOT NULL auto_increment,\
PRIMARY KEY (`Id`)\
) TYPE=MyISAM;") == 0);
nlverify(mysql_query(mysql, "CREATE TABLE `vector_child` (\
`Id` int(10) unsigned NOT NULL default '0',\
`parent_id` int(10) unsigned NOT NULL default '0',\
`info` int(10) NOT NULL default '0',\
PRIMARY KEY (`Id`)\
) TYPE=MyISAM;") == 0);
_WorkingPath = workingPath;
TEST_ADD(CNopeTS::store)
TEST_ADD(CNopeTS::load)
TEST_ADD(CNopeTS::storeOneChild)
TEST_ADD(CNopeTS::loadOneChild)
TEST_ADD(CNopeTS::badOneChild)
TEST_ADD(CNopeTS::removeOneChild)
TEST_ADD(CNopeTS::storeVectorChild)
TEST_ADD(CNopeTS::loadVectorChild)
TEST_ADD(CNopeTS::getVectorChildByIndex)
TEST_ADD(CNopeTS::removeVectorChild)
TEST_ADD(CNopeTS::storeMapChild)
TEST_ADD(CNopeTS::loadMapChild)
TEST_ADD(CNopeTS::removeMapChild)
TEST_ADD(CNopeTS::onDelete)
}
~CNopeTS()
{
// terminate cleanly the embedded database server
// mysql_server_end();
CPath::setCurrentPath(_WorkingPath.c_str());
// delete _Context;
}
void setup()
{
NLMISC::CPath::setCurrentPath((_WorkingPath+"/test_files/shard_unifier_test").c_str());
// _Conn.addOption(MYSQL_READ_DEFAULT_GROUP, "libmysqld_client");
// _Conn.addOption(MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);
nlassert(_Conn.connect("borisb2", "", "", "test"));
uint32 cacheSize = NOPE::CPersistentCache::getInstance().getInstanceCount();
}
void tear_down()
{
_Conn.closeConn();
// clear the object cache
NOPE::CPersistentCache::getInstance().clearCache();
}
void onDelete()
{
// create a root element, then add some childs, delete the root and check the state or existence
// of child depending on 'on-delete' specified behavior
CRootTablePtr rt = CRootTable::createTransient(__FILE__, __LINE__);
TEST_ASSERT(rt->create(_Conn));
uint32 rootId = rt->getObjectId();
CMapChildPtr mapChilds[10];
CVectorChildPtr vectorChilds[10];
COneChildPtr oneChild;
// create some childs
for (uint i=0; i<10; ++i)
{
mapChilds[i] = CMapChild::createTransient(__FILE__, __LINE__);
mapChilds[i]->setParentId(rootId);
mapChilds[i]->setObjectId(i+1000);
TEST_ASSERT(mapChilds[i]->create(_Conn));
}
for (uint i=0; i<10; ++i)
{
vectorChilds[i] = CVectorChild::createTransient(__FILE__, __LINE__);
vectorChilds[i]->setParentId(rootId);
vectorChilds[i]->setObjectId(i+1000);
TEST_ASSERT(vectorChilds[i]->create(_Conn));
}
oneChild = COneChild::createTransient(__FILE__, __LINE__);
oneChild->setObjectId(rootId);
oneChild->create(_Conn);
// ok, now delete the root and check the childs
TEST_ASSERT(rt->remove(_Conn));
TEST_ASSERT(oneChild->getPersistentState() == NOPE::os_removed);
for (uint i =0; i<10; ++i)
{
TEST_ASSERT(mapChilds[i]->getObjectId() == i+1000);
TEST_ASSERT(mapChilds[i]->getPersistentState() == NOPE::os_removed);
}
for (uint i =0; i<10; ++i)
{
TEST_ASSERT(vectorChilds[i]->getObjectId() == i+1000);
TEST_ASSERT(vectorChilds[i]->getPersistentState() == NOPE::os_clean);
TEST_ASSERT(vectorChilds[i]->getParentId() == 0);
}
}
void removeMapChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
TEST_ASSERT(rt->loadMapChilds(_Conn, __FILE__, __LINE__));
TEST_ASSERT(rt->getMapChildsById(5) != NULL);
TEST_ASSERT(rt->getMapChildsById(5)->remove(_Conn));
TEST_ASSERT(rt->getMapChildsById(5) == NULL);
TEST_ASSERT(rt->getMapChilds().size() == 9);
}
void loadMapChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
TEST_ASSERT(rt->loadMapChilds(_Conn, __FILE__, __LINE__));
TEST_ASSERT(rt->getMapChilds().size() == 10);
}
void storeMapChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
rt->loadMapChilds(_Conn, __FILE__, __LINE__);
// create 10 element in the map childs
for (uint i=0; i<10; ++i)
{
CMapChildPtr mc = CMapChild::createTransient(__FILE__, __LINE__);
mc->setObjectId(i+1);
mc->setParentId(rt->getObjectId());
TEST_ASSERT(mc->create(_Conn));
TEST_ASSERT(rt->getMapChilds().size() == i+1);
TEST_ASSERT(rt->getMapChildsById(mc->getObjectId()) == mc);
}
}
void removeVectorChild()
{
// remove one element in the middle of the vector
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
// load the vector childs
TEST_ASSERT(rt->loadVectorChilds(_Conn, __FILE__, __LINE__));
TEST_ASSERT(rt->getVectorChildsByIndex(5)->remove(_Conn));
TEST_ASSERT(rt->getVectorChilds().size() == 9);
}
void getVectorChildByIndex()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
// load the vector childs
TEST_ASSERT(rt->loadVectorChilds(_Conn, __FILE__, __LINE__));
TEST_ASSERT(rt->getVectorChildsById(15) == NULL);
TEST_ASSERT(rt->getVectorChildsById(5) != NULL);
}
void loadVectorChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
// load the vector childs
TEST_ASSERT(rt->loadVectorChilds(_Conn, __FILE__, __LINE__));
// check the number of elements
TEST_ASSERT(rt->getVectorChilds().size() == 10);
}
void storeVectorChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
// load the vector childs (this load nothing as there are no child for now)
rt->loadVectorChilds(_Conn, __FILE__, __LINE__);
// create some vector child
for (uint i=0; i<10; ++i)
{
CVectorChildPtr vc = CVectorChild::createTransient(__FILE__, __LINE__);
vc->setObjectId(i+1);
vc->setParentId(rt->getObjectId());
vc->setInfo(sint32(i));
TEST_ASSERT(vc->create(_Conn));
TEST_ASSERT(rt->getVectorChilds().size() == i+1);
TEST_ASSERT(rt->getVectorChilds().back() == vc);
}
}
void removeOneChild()
{
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
TEST_ASSERT(rt != NULL);
// load the child
TEST_ASSERT(rt->loadOneChild(_Conn, __FILE__, __LINE__));
// remove the child from the persistent store
TEST_ASSERT(rt->getOneChild()->remove(_Conn));
// check that the parent link is updated
TEST_ASSERT(rt->getOneChild() == NULL);
}
void badOneChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
// load the child
rt->loadOneChild(_Conn, __FILE__, __LINE__);
// create a new one child
COneChildPtr oc = COneChild::createTransient(__FILE__, __LINE__);
oc->setObjectId(rt->getObjectId());
// this must fail (either during insert (if db support constraint) or after, when updating the root table)
TEST_ASSERT(oc->create(_Conn) == false);
}
void loadOneChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
{
// load the child
COneChildPtr oc = COneChild::load(_Conn, rt->getObjectId(), __FILE__, __LINE__);
TEST_ASSERT(oc != NULL);
// TEST_ASSERT(rt->getOneChild() == NULL);
}
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 1);
rt->loadOneChild(_Conn, __FILE__, __LINE__);
TEST_ASSERT(rt->getOneChild() != NULL);
TEST_ASSERT(rt->getOneChild()->getObjectId() == rt->getObjectId());
}
void storeOneChild()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
// load the root element
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
// load the child (in fact, this load nothing because there is no child for now)
rt->loadOneChild(_Conn, __FILE__, __LINE__);
TEST_ASSERT(rt->getOneChild() == NULL);
// create the one child relation element
COneChildPtr oc = COneChild::createTransient(__FILE__, __LINE__);
oc->setObjectId(rt->getObjectId());
// store the element
TEST_ASSERT(oc->create(_Conn));
// check that the parent relation have been updated
TEST_ASSERT(rt->getOneChild() == oc)
}
void load()
{
clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
{
CRootTablePtr rt = CRootTable::load(_Conn, _RootId, __FILE__, __LINE__);
TEST_ASSERT(rt != NULL);
TEST_ASSERT(rt->getObjectId() == _RootId);
}
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 1);
NOPE::CPersistentCache::getInstance().clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
}
void store()
{
// make sure the cache is clean
clearCache();
{
CRootTablePtr rt = CRootTable::createTransient(__FILE__, __LINE__);
TEST_ASSERT(rt->create(_Conn));
_RootId = rt->getObjectId();
}
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 1);
NOPE::CPersistentCache::getInstance().clearCache();
TEST_ASSERT(NOPE::CPersistentCache::getInstance().getInstanceCount() == 0);
}
void clearCache()
{
CVectorChild::clearCache();
NOPE::CPersistentCache::getInstance().clearCache();
}
};
Test::Suite *createCNopeTS(const std::string &workingPath)
{
return new CNopeTS(workingPath);
}

@ -0,0 +1,190 @@
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/dynloadlib.h"
#include "nel/misc/path.h"
#include "nel/net/service.h"
#include "src/cpptest.h"
//#include "pd_lib/pd_string_manager.h"
#include "game_share/mysql_wrapper.h"
#include "entities_game_service/guild_manager/guild_manager_interface.h"
#include "entities_game_service/guild_manager/guild_interface.h"
#include "test_mapping.h"
#include <cstdlib>
#include <mysql.h>
using namespace std;
using namespace NLMISC;
using namespace NLNET;
class CGuildManagerPH : public IGuildManager
{
virtual void guildMemberChanged (EGSPD::CGuildMemberPD *guildMemberPd)
{
nlstop;
}
/// the member list has been changed (ether add/replace or delete)
virtual void guildMemberListChanged (EGSPD::CGuildPD *guildPd)
{
nlstop;
}
virtual void updateGuildMembersStringIds()
{
// nlstop;
}
virtual void createGuildStep2 (uint32 guildId, const ucstring &guildName, CHARSYNC::TCharacterNameResult result)
{
nlstop;
}
virtual CGuild *getGuildFromId (uint32 guildId)
{
nlstop;
return NULL;
}
virtual void addGuildsAwaitingString ( const ucstring & guildStr, uint32 guildId )
{
nlstop;
}
/// get raw access to the guild list (not const)
virtual const EGSPD::CGuildContainerPD *getGuildContainer() const
{
nlstop;
return NULL;
}
/// A player entity have been removed from eid translator, check all guild member list
virtual void playerEntityRemoved(const NLMISC::CEntityId &eid)
{
nlstop;
}
/// check if guilds have been loaded
virtual bool guildLoaded()
{
return true;
}
/// fill a list with all guild descriptors
virtual void fillGuildInfos(std::vector<CHARSYNC::CGuildInfo> &guildInfos)
{
// nlstop;
}
/// Check all guild member lists against the entity translator
virtual void checkGuildMemberLists()
{
}
// A character connect/disconnect on another shard, update the online tags
virtual void characterConnectionEvent(const NLMISC::CEntityId &eid, bool online)
{
}
};
CGuildManagerPH guildManager;
IGuildManager &IGuildManager::getInstance()
{
return guildManager;
}
IGuild *IGuild::getGuildInterface(::CGuild *guild)
{
nlstop;
return NULL;
}
void IGuild::setNameWrap(const ucstring &name)
{
nlstop;
}
uint32 IGuild::getIdWrap()
{
nlstop;
return 0;
}
bool IGuild::isProxyWrap()
{
nlstop;
return false;
}
void IGuild::updateMembersStringIds()
{
nlstop;
}
class CGuildPH : public IGuild
{
};
//namespace RY_PDS
//{
// bool CPDStringManager::isWaitingIOSStoreStringResult()
// {
// return false;
// }
//};
Test::Suite *createCNopeTS(const std::string &workingPath);
Test::Suite *createCRSMTS(const std::string &workingPath);
Test::Suite *createCCharacterSyncTS(const std::string &workingPath);
class CShardUnifierTS: public Test::Suite
{
string _WorkingPath;
// string _BaseDir;
// string _CurrentPath;
// string _CurrentPathToRestore;
NLMISC::CApplicationContext *_Context;
public:
CShardUnifierTS(const std::string &workingPath)
{
_Context = new CApplicationContext();
// init a new nel instance
INelContext::getInstance();
_WorkingPath = workingPath;
NLMISC::createDebug();
// add(auto_ptr<Test::Suite>(createCNopeTS(workingPath)));
add(auto_ptr<Test::Suite>(createCRSMTS(workingPath)));
add(auto_ptr<Test::Suite>(createCCharacterSyncTS(workingPath)));
}
~CShardUnifierTS()
{
CPath::setCurrentPath(_WorkingPath.c_str());
// delete _Context;
}
};
auto_ptr<Test::Suite> intRegisterTestSuite(const std::string &workingPath)
{
return static_cast<Test::Suite*>(new CShardUnifierTS(workingPath));
}
NL_LIB_EXPORT_SYMBOL(registerTestSuite, void, intRegisterTestSuite);

@ -0,0 +1,49 @@
<generator header_tag="TEST_MAPPING">
<namespace name="TM">
<class name="CRootTable">
<database table="root_table"/>
<property type="uint32" name="Id" db_col="Id" unique_id="true" autogen="true"/>
<child_class type="COneChild" name="OneChild" relation="one-to-one" on-delete="cascade"/>
<child_class type="CMapChild" name="MapChilds" relation="one-to-many" cont="map" on-delete="cascade"/>
<child_class type="CVectorChild" name="VectorChilds" relation="one-to-many" cont="vector" on-delete="update"/>
</class>
<class name="COneChild">
<database table="one_child"/>
<parent class="CRootTable" child_name="OneChild" relation="one-to-one" db_col="Id" />
<property type="uint32" name="Id" db_col="Id" unique_id="true"/>
</class>
<class name="CMapChild">
<database table="map_child"/>
<parent class="CRootTable" child_name="MapChilds" relation="one-to-many" db_col="parent_id" cont="map"/>
<property type="uint32" name="Id" db_col="Id" unique_id="true"/>
<property type="uint32" name="ParentId" db_col="parent_id" />
</class>
<class name="CVectorChild">
<database table="vector_child"/>
<parent class="CRootTable" child_name="VectorChilds" relation="one-to-many" db_col="parent_id" cont="vector"/>
<property type="uint32" name="Id" db_col="Id" unique_id="true"/>
<property type="uint32" name="ParentId" db_col="parent_id" />
<property type="sint32" name="Info" db_col="info" />
</class>
</namespace>
</generator>

@ -0,0 +1,296 @@
#include "test_web_interface.h"
#include "test_web_interface_itf.h"
#include "nel/net/service.h"
using namespace std;
using namespace NLMISC;
using namespace NLNET;
using namespace TWI;
class CTestWebInterfaceServiceImpl
: public TWI::CTestInterfaceWebItf,
public TWI::CTestInterfaceWeb2Itf
{
uint32 _TestState;
public:
/////////////////////////////////////////
/// Web interface callback imp
/////////////////////////////////////////
virtual void on_CTestInterfaceWeb_Connection(NLNET::TSockId from)
{
nlinfo("Connect from %s, %s", from->asString().c_str(), from->getTcpSock()->remoteAddr().asString().c_str());
}
virtual void on_CTestInterfaceWeb_Disconnection(NLNET::TSockId from)
{
nlinfo("Disconnect from %s, %s", from->asString().c_str(), from->getTcpSock()->remoteAddr().asString().c_str());
// if (_TestState == 0
// || _TestState == 1
// || _TestState == 3
// || _TestState == 5
// || _TestState == 9
// || _TestState == 13
// || _TestState == 15
// || _TestState == 17
// || _TestState == 19)
// {
// // ok
// }
// else
// {
// nlwarning("Receive disconnect in state %u", _TestState);
//// nlstop;
// }
//
// if (_TestState > 0)
// _TestState++;
}
virtual void on_beginTest(NLNET::TSockId from)\
{
_TestState = 0;
}
virtual void on_sendUInt32(NLNET::TSockId from, uint32 i32)
{
if (_TestState == 0)
{
nlassert(i32 == 0x12345678);
returnUInt32(from, 0x12345678);
}
else if (_TestState == 3)
{
nlassert(i32 == 0xFEDCBA98);
returnUInt32(from, 0x12345678);
}
else if (_TestState == 9)
{
nlassert(i32 == 0x12345678);
returnUInt32(from, 0x12345678);
returnUInt32(from, 0x87654321);
}
else if (_TestState == 10)
{
nlassert(i32 == 0x12345678);
returnUInt8(from, 0x34);
returnUInt32(from, 0x87654321);
}
else if (_TestState == 11)
{
nlassert(i32 == 0x12345678);
// no response, live client alone and friendless
}
else
{
nlwarning("Received sendInt32 in state %u", _TestState);
// nlstop;
};
_TestState++;
}
virtual void on_sendUInt8(NLNET::TSockId from, uint8 i8)
{
if (_TestState == 1)
{
nlassert(i8 == 0xf1);
returnUInt8(from, 0xf1);
}
else if (_TestState == 4)
{
nlassert(i8 == 0xcc);
returnUInt8(from, 0x01);
}
else
{
nlwarning("Received sendInt8 in state %u", _TestState);
// nlstop;
};
_TestState++;
}
virtual void on_sendString(NLNET::TSockId from, const std::string &str)
{
if (_TestState == 2)
{
nlassert(str == "hello world");
returnString(from, "hello world");
}
else if (_TestState == 5)
{
nlassert(str == "hello world");
returnString(from, "ok");
}
else
{
nlwarning("Received sendString in state %u", _TestState);
// nlstop;
};
_TestState++;
}
virtual void on_composite1(NLNET::TSockId from, uint32 i32, uint8 i8, const std::string &str)
{
if (_TestState == 6)
{
nlassert(i32 == 0x12345678);
nlassert(i8 == 0x9A);
nlassert(str == "Ibm");
returnComposite1(from, 0x12345678, 0x9a, "hal");
}
else
{
nlwarning("Received sendComposite1 in state %u", _TestState);
// nlstop;
};
_TestState++;
}
virtual void on_composite2(NLNET::TSockId from, const std::string &str1, const std::string &str2, const std::string &str3, const std::string &str4)
{
if (_TestState == 7)
{
nlassert(str1 == "ABCD");
nlassert(str2 == "EFGH IJKL");
nlassert(str3 == "MNO");
nlassert(str4 == "PQ");
returnComposite2(from, "ABCD", "EFGH IJKL", "MNO", "PQ");
}
else
{
nlwarning("Received sendComposite2 in state %u", _TestState);
// nlstop;
};
_TestState++;
}
virtual void on_composite3(NLNET::TSockId from, uint8 i81, uint32 i321, const std::string &str1, uint8 i82, uint32 i322, const std::string &str2, uint8 i83, uint32 i323, const std::string &str3, uint8 i84, uint32 i324, const std::string &str4, uint32 i325, uint8 i85)
{
if (_TestState == 8)
{
nlassert(i81 == 0x9a);
nlassert(i321 == 0x12345678);
nlassert(str1 == "ABC");
nlassert(i322 == 0xbcdef012);
nlassert(i82 == 0x34);
nlassert(str2 == "DEFGH");
nlassert(i323 == 0x567890ab);
nlassert(i83 == 0xcd);
nlassert(str3 == "I");
nlassert(i324 == 0xef012345);
nlassert(i84 == 0x67);
nlassert(str4 == "");
nlassert(i325 == 0x01234567);
nlassert(i85 == 0x89);
returnComposite3(from, 0x9a, 0x12345678, "ABC",
0x34, 0xbcdef012, "DEFGH",
0xcd, 0x567890ab, "I",
0x67, 0xef012345, "",
0x01234567, 0x89);
}
else
{
nlwarning("Received sendComposite3 in state %u", _TestState);
// nlstop;
};
_TestState++;
}
///////////////////////////////////
// Wel interface 2 impl
//////////////////////////////////
/// Connection callback : a new interface client connect
virtual void on_CTestInterfaceWeb2_Connection(NLNET::TSockId from)
{
}
/// Disconnection callback : one of the interface client disconnect
virtual void on_CTestInterfaceWeb2_Disconnection(NLNET::TSockId from)
{
}
virtual void on_sendVectorUInt32(NLNET::TSockId from, const std::vector<uint32> &vi32)
{
returnVectorUInt32(from, vi32);
}
virtual void on_sendVectorString(NLNET::TSockId from, const std::vector<std::string> &vstr)
{
returnVectorString(from, vstr);
}
virtual std::string on_twoWayCall(NLNET::TSockId from, const std::string &param)
{
return param;
}
virtual uint32 on_twoWayCallInt(NLNET::TSockId from, uint32 param)
{
return param;
}
virtual TEnum on_twoWayCallEnum(NLNET::TSockId from, TEnum param)
{
return param;
}
virtual std::vector<uint32> on_twoWayCallVector(NLNET::TSockId from, const std::vector<uint32> &param)
{
return param;
}
virtual void on_mixedVector(NLNET::TSockId from, uint32 param1, const std::vector<std::string> &vstr, const std::vector<uint32> &vi32)
{
returnMixedVector(from, param1, vstr, vi32);
}
virtual uint32 on_mixedTwoWayVector(NLNET::TSockId from, uint32 param1, const std::vector<std::string> &vstr, const std::vector<uint32> &vi32)
{
return param1;
}
};
class CTestWebInterfaceService
: public IService
{
CTestWebInterfaceServiceImpl *_WebItf;
public:
void init ()
{
_WebItf = new CTestWebInterfaceServiceImpl;
_WebItf->CTestInterfaceWebItf::openItf(8061);
_WebItf->CTestInterfaceWeb2Itf::openItf(8062);
}
bool update ()
{
// update the web interface
_WebItf->CTestInterfaceWebItf::update();
_WebItf->CTestInterfaceWeb2Itf::update();
return true;
}
void release ()
{
delete _WebItf;
}
};
NLNET::TUnifiedCallbackItem cbArray[]=
{ "", NULL};
NLNET_SERVICE_MAIN(CTestWebInterfaceService, "WTI", "test_web_interface", 8060, cbArray, ".", ".");

@ -0,0 +1,11 @@
/////////////////////////////////////////////////////////////////
// WARNING : this is a generated file, don't change it !
/////////////////////////////////////////////////////////////////
#include "test_web_interface_itf.h"
namespace TWI
{
}

@ -0,0 +1,269 @@
<generator header_tag="TEST_WEB_INTERFACE_ITF">
<namespace name="TWI">
<callback_interface name="CTestInterfaceWeb" caller="php">
<doc line="Test interface for web to C++ messaging"/>
<invoke name="beginTest" msg="BT">
</invoke>
<!-- first basic types sended and returned -->
<invoke name="sendUInt32" msg="S32">
<param type="uint32" name="i32"/>
</invoke>
<return name="returnUInt32" msg="R32">
<param type="uint32" name="i32"/>
</return>
<invoke name="sendUInt8" msg="S8">
<param type="uint8" name="i8" php_serial="UInt8"/>
</invoke>
<return name="returnUInt8" msg="R8">
<param type="uint8" name="i8" php_serial="UInt8"/>
</return>
<invoke name="sendString" msg="SS">
<param type="std::string" name="str" php_serial="String" byref="true"/>
</invoke>
<return name="returnString" msg="RS">
<param type="std::string" name="str" byref="true" php_serial="String" byref="true"/>
</return>
<!-- now, some composite request -->
<invoke name="composite1" msg="SC1">
<param type="uint32" name="i32"/>
<param type="uint8" name="i8" php_serial="UInt8"/>
<param type="std::string" name="str" php_serial="String" byref="true"/>
</invoke>
<return name="returnComposite1" msg="RC1">
<param type="uint32" name="i32"/>
<param type="uint8" name="i8" php_serial="UInt8"/>
<param type="std::string" name="str" php_serial="String" byref="true"/>
</return>
<invoke name="composite2" msg="SC2">
<param type="std::string" name="str1" php_serial="String" byref="true"/>
<param type="std::string" name="str2" php_serial="String" byref="true"/>
<param type="std::string" name="str3" php_serial="String" byref="true"/>
<param type="std::string" name="str4" php_serial="String" byref="true"/>
</invoke>
<return name="returnComposite2" msg="RC2">
<param type="std::string" name="str1" php_serial="String" byref="true"/>
<param type="std::string" name="str2" php_serial="String" byref="true"/>
<param type="std::string" name="str3" php_serial="String" byref="true"/>
<param type="std::string" name="str4" php_serial="String" byref="true"/>
</return>
<invoke name="composite3" msg="SC3">
<param type="uint8" name="i81" php_serial="UInt8"/>
<param type="uint32" name="i321"/>
<param type="std::string" name="str1" php_serial="String" byref="true"/>
<param type="uint8" name="i82" php_serial="UInt8"/>
<param type="uint32" name="i322"/>
<param type="std::string" name="str2" php_serial="String" byref="true"/>
<param type="uint8" name="i83" php_serial="UInt8"/>
<param type="uint32" name="i323"/>
<param type="std::string" name="str3" php_serial="String" byref="true"/>
<param type="uint8" name="i84" php_serial="UInt8"/>
<param type="uint32" name="i324"/>
<param type="std::string" name="str4" php_serial="String" byref="true"/>
<param type="uint32" name="i325"/>
<param type="uint8" name="i85" php_serial="UInt8"/>
</invoke>
<return name="returnComposite3" msg="RC3">
<param type="uint8" name="i81" php_serial="UInt8"/>
<param type="uint32" name="i321"/>
<param type="std::string" name="str1" php_serial="String" byref="true"/>
<param type="uint8" name="i82" php_serial="UInt8"/>
<param type="uint32" name="i322"/>
<param type="std::string" name="str2" php_serial="String" byref="true"/>
<param type="uint8" name="i83" php_serial="UInt8"/>
<param type="uint32" name="i323"/>
<param type="std::string" name="str3" php_serial="String" byref="true"/>
<param type="uint8" name="i84" php_serial="UInt8"/>
<param type="uint32" name="i324"/>
<param type="std::string" name="str4" php_serial="String" byref="true"/>
<param type="uint32" name="i325"/>
<param type="uint8" name="i85" php_serial="UInt8"/>
</return>
</callback_interface>
<callback_interface name="CTestInterface2Web" caller="php">
<doc line="a second interface to stress the generator"/>
<invoke name="sendInt32_2" msg="S322">
<param type="uint32" name="i32"/>
</invoke>
<return name="returnInt32_2" msg="R322">
<param type="uint32" name="i32"/>
</return>
</callback_interface>
<!--
The test must be run as follow (it's web side driven)
0 - Initialise the test service
0.1 - web connect to test service
0.2 - send 'beginTest' to test service
0.3 - disconnect
1 - First simple message test and disco/reco phpstate Internal server state
1.1 - web connect to test service
1.2 - send 'sendInt32(0x12345678)' 0++
1.3 - wait for returnInt32 0++
check i32 = 0x12345678
1.4 - disconnect
1.5 - web connect to test service
1.6 - send 'sendInt8(0xf1)' 1++
1.7 - wait for returnInt8 1++
check i8 = 0xf1
1.8 - disconnect
1.9 - web connect to test service
1.10 - send 'sendString("hello world")' 2++
1.11 - wait for returnString 2++
check str = "hello world"
1.12 - disconnect
2 - Second, test multiple msg in the same cnx
2.1 - connect to test service
2.2 - send 'sendInt32(0xFEDCBA98)' 3++
2.3 - wait for returnInt32 3++
check i32 = 0x12345678
2.4 - send 'sendInt8(0xCC)' 4++
2.5 - wait for returnInt8 4++
check i8 = 0x01
2.6 - send 'sendString("hello world")' 5++
2.7 - wait for returnString 5++
check str = "ok"
2.8 - disconnect
3 - Third test composite mesage
3.1 - connect to test service
3.2 - send 'composite1(0x12345678, 0x9A, "Ibm")' 6++
3.3 - wait for returnComposite1 6++
check i32 = 0x12345678
check i8 = 0x9a
checl str = "hal"
3.4 - send 'composite2("ABCD","EFGH IJKL","MNO","PQ")' 7++
3.5 - wait for returnComposite2 7++
check str1 = "ABCD"
check str2 = "EFGH IJKL"
check str3 = "MNO"
check str4 = "PQ"
3.6 - send 'composite3(0x9a, 0x12345678, "ABC", 8++
0x34, 0xbcdef012, "DEFGH",
0xcd, 0x567890ab, "I",
0x67, 0xef012345, "",
0x01234567, 0x89)'
3.7 - wait for returnComposite3 8++
check all value must be like in calling composite3
3.8 - disconnect
4 - Test mutiple return message
2.1 - connect to test service
2.2 - send 'sendInt32(0x12345678)' 9++
2.3 - wait for returnInt32 9++
check i32 = 0x12345678
2.3 - wait for returnInt32 10++
check i32 = 0x87654321
2.4 - disconnect
5 - check support of faulty messages
5.1 - connect to test service
5.2 - send 'sendInt32(0x12345678)' 10++
5.3 - wait for returnInt32 11++
you receive returnInt8 instead and must ignore it
5.4 - wait for returnInt32 12++
check i32 = 0x87654321
5.5 - disconnect
6 - support of clean timeout ( return a default error page before
being killed by web server)
6.1 - connect to test service
6.2 - send 'sendInt32(0x12345678)' 11++
6.3 - wait for returnInt32 13++
6.4 - after 15 second (configurable?) without response, giveup using some language specific exception.
6.5 - disconnect
-->
<enum name="TEnum">
<item name="enum_a"/>
<item name="enum_b"/>
<item name="enum_c"/>
</enum>
<!-- vector, two way invoke and structured parameters -->
<callback_interface name="CTestInterfaceWeb2" caller="php">
<invoke name="sendVectorUInt32" msg="SV32">
<param type="uint32" name="vi32" array="true"/>
</invoke>
<return name="returnVectorUInt32" msg="RV32">
<param type="uint32" name="i32" array="true"/>
</return>
<invoke name="sendVectorString" msg="SVS">
<param type="std::string" name="vstr" array="true" php_serial="String"/>
</invoke>
<return name="returnVectorString" msg="RVS">
<param type="std::string" name="vstr" array="true" php_serial="String"/>
</return>
<invoke name="twoWayCall" msg="TWC">
<return type="std::string" php_serial="String"/>
<param type="std::string" name="param" php_serial="String" byref="true"/>
</invoke>
<invoke name="twoWayCallInt" msg="TWCI">
<return type="uint32"/>
<param type="uint32" name="param"/>
</invoke>
<invoke name="twoWayCallEnum" msg="TWCE">
<return type="TEnum" enum="true"/>
<param type="TEnum" name="param" enum="true"/>
</invoke>
<invoke name="twoWayCallVector" msg="TWCV">
<return type="uint32" array="true"/>
<param type="uint32" name="param" array="true"/>
</invoke>
<invoke name="mixedVector" msg="MVI">
<param type="uint32" name="param1"/>
<param type="std::string" name="vstr" array="true" php_serial="String"/>
<param type="uint32" name="vi32" array="true"/>
</invoke>
<return name="returnMixedVector" msg="RMVI">
<param type="uint32" name="param1"/>
<param type="std::string" name="vstr" array="true" php_serial="String"/>
<param type="uint32" name="vi32" array="true"/>
</return>
<invoke name="mixedTwoWayVector" msg="TWMV">
<return type="uint32"/>
<param type="uint32" name="param1"/>
<param type="std::string" name="vstr" array="true" php_serial="String"/>
<param type="uint32" name="vi32" array="true"/>
</invoke>
</callback_interface>
</namespace>
</generator>

@ -0,0 +1,70 @@
<?php
include_once('thread_utils.php');
include_once('mail_utils.php');
include_once('admin_utils.php');
if (($user_login != "support" || ($remote_addr != "192.168.1.153" && $remote_addr != "192.168.3.1")) && $remote_addr != "127.0.0.1")
{
die();
}
importParam('recover_forum');
if ($recover_forum)
{
echo "recover forum $recover_forum<br>\n";
recover_thread($recover_forum);
die();
}
importParam('recover_thread');
importParam('recover_threadthread');
if ($recover_thread && isset($recover_threadthread))
{
echo "recover forum $recover_thread<br>\n";
recover_one_thread($recover_thread, $recover_threadthread);
die();
}
importParam('rename_forum');
importParam('into_forum');
if ($rename_forum)
{
echo "rename forum $rename_forum into $into_forum<br>\n";
rename_forum($rename_forum, $into_forum);
die();
}
importParam('shard');
importParam('mailbox');
importParam('mail');
if ($mail)
{
$mdir = get_user_dir($mailbox, $shard);
readfile($mdir.$mail);
die();
}
else if ($mailbox)
{
display_mailbox_content($shard, $mailbox);
die();
}
importParam('forum');
importParam('thread');
if ($thread)
{
display_thread_content($shard, $forum, $thread);
die();
}
else if ($forum)
{
display_forum_content($shard, $forum);
die();
}
?>

@ -0,0 +1,103 @@
<?php
$server = "localhost";
$port = 80;
// import HTTP_GET_VARS as _GET if _GET doesn't exist
if (!isset($_GET) && isset($HTTP_GET_VARS))
$_GET = &$HTTP_GET_VARS;
echo "<form method='get' action='$PHP_SELF'>\n";
echo "SHARD: <input type='text' name='shard' value='".$_GET['shard']."'><br>\n";
echo "MAILBOX: <input type='text' name='mailbox' value='".$_GET['mailbox']."'><br>\n";
echo "FORUM: <input type='text' name='forum' value='".$_GET['forum']."'><br>\n";
echo "<input type='submit' value='Retrieve'><br>\n";
echo "</form>\n";
if ($_GET["mailbox"])
{
echo "Get mailbox ".$_GET["mailbox"]." content:<br>\n";
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
fputs($s,"GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&mailbox=".$_GET["mailbox"]." HTTP/1.0\n\n");
while(!feof($s))
{
$l = trim(fgets($s, 2048));
if (ereg("^FILE:(.*)", $l, $reg))
echo "<a href=\"$PHP_SELF?shard=".$_GET["shard"]."&mailbox=".$_GET["mailbox"]."&mail=".$reg[1]."\">".$reg[1]."</a><br>\n";
}
fclose($s);
echo "<br><br>\n";
}
if ($_GET["mail"])
{
echo "Get mail ".$_GET["mailbox"]."/".$_GET["mail"]." content:<br>\n";
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&mail=".$_GET["mail"]."&mailbox=".$_GET["mailbox"]." HTTP/1.0\n\n");
echo "Content of mail:<br>\n";
while(!feof($s))
echo nl2br(htmlentities(trim(fgets($s, 2048))));
fclose($s);
echo "<br><br>\n";
}
if ($_GET["recover_thread"])
{
echo "Recover thread ".$_GET["forum"]." ".$_GET["recover_thread"]."<br>\n";
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&recover_thread=".$_GET["forum"]."&recover_threadthread=".$_GET["recover_thread"]." HTTP/1.0\n\n");
fclose($s);
echo "<br><br>\n";
}
if ($_GET["forum"])
{
echo "Get forum ".$_GET["forum"]." content:<br>\n";
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&forum=".$_GET["forum"]." HTTP/1.0\n\n");
while(!feof($s))
{
$l = trim(fgets($s, 2048));
if (ereg("^FILE:(.*)", $l, $reg))
{
echo "<a href=\"$PHP_SELF?shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&thread=".trim($reg[1])."\">".trim($reg[1])."</a>\n";
if ($reg[1]{0} == '_')
{
echo " <a href=\"$PHP_SELF?shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&recover_thread=".trim($reg[1])."\">recover thread</a>\n";
}
echo "<br>\n";
}
}
fclose($s);
echo "<br><br>\n";
}
if ($_GET["thread"])
{
echo "Get thread ".$_GET["forum"]."/".$_GET["thread"]." content:<br>\n";
$s = fsockopen($server, $port, &$errno, &$errstr, 30) or die ("ERROR: can't connect to $server:$port");
fputs($s, "GET /websrv/admin.php?user_login=support&shard=".$_GET["shard"]."&forum=".$_GET["forum"]."&thread=".$_GET["thread"]." HTTP/1.0\n\n");
echo "Content of thread:<br>\n";
while(!feof($s))
{
$l = trim(fgets($s, 2048));
if (ereg("^TOPIC:(.*) SUBMIT:(.*)$", $l, $reg))
echo nl2br(htmlentities(" TOPIC:".$reg[1]."SUBMITED BY: ".$reg[2]."\n"));
if (ereg("^AUTHOR:(.*) DATE:(.*) POST:(.*)", $l, $reg))
echo nl2br(htmlentities("AUTHOR: ".$reg[1]." DATE:".$reg[2]." POST:".$reg[3]."\n"));
}
fclose($s);
echo "<br><br>\n";
}
?>

@ -0,0 +1,46 @@
<?php
function display_mailbox_content($shard, $user)
{
$udir = get_user_dir($user, $shard);
echo "-- MAILBOX $user ($udir)\n";
$dir = opendir($udir);
while ($dir && ($file = readdir($dir)))
if (ereg("^mail_([0-9]*)\.html", $file) || ereg("^_mail_([0-9]*)\.html", $file))
echo "FILE:$file\n";
echo "-- END MAILBOX $user\n";
}
function display_forum_content($shard, $user)
{
$udir = get_user_dir($user, $shard);
echo "-- FORUM $user ($udir)\n";
$dir = opendir($udir);
while ($dir && ($file = readdir($dir)))
if (ereg("^thread_([0-9]*)\.index", $file) || ereg("^_thread_([0-9]*)\.index", $file))
echo "FILE:$file\n";
echo "-- END FORUM $user\n";
}
function display_thread_content($shard, $forum, $thread)
{
$udir = get_user_dir($forum, $shard);
read_index($udir.$thread, &$header, &$array);
$a = explode("%%", $header);
echo "-- THREAD $forum $thread\n";
echo "TOPIC: ".$a[1]." SUBMIT: ".$a[0]."\n";
if (count($array) > 0)
{
foreach ($array as $post)
{
echo "AUTHOR: ".$post[0]." DATE: ".$post[2]." POST: ".$post[1]."\n";
}
}
echo "-- END THREAD $forum $thread\n";
}
?>

@ -0,0 +1,21 @@
<?php
include_once('utils.php');
unset($user);
$user = $user_login;
$user_dir = get_user_dir($user, $shard);
if (!is_dir($user_dir))
die("0");
$fname = $user_dir.'new_mails';
if (file_exists($fname))
{
unlink($fname);
die("1");
}
else
{
die("0");
}
?>

@ -0,0 +1,6 @@
<?php
$USERS_DIR = '/home/nevrax/live/www'; // without final /
$TEMPLATE_DIR = './template'; // without final /
?>

@ -0,0 +1,31 @@
<?php
include_once('mail_utils.php');
//
// INPUT:
//
// $user_login login of the user that consults the mailbox
// $select_mail_%% mails to be removed
//
read_template('confirm_delete_mail.html', $confirm_delete_mail);
$mails = array();
$selected_mails = '';
foreach ($_POST as $var => $value)
{
if (matchParam($var, "select_mail_", $mail))
{
$mails[] = $mail;
$selected_mails .= "<input type='hidden' name='select_mail_$mail' value='selected'>\n";
}
}
//
$instance = str_replace(array('%%MAIL%%', '%%SELECTED_MAILS%%'),
array($mails[0], $selected_mails),
$confirm_delete_mail);
echo $instance;
?>

@ -0,0 +1,71 @@
<?php
include_once('thread_utils.php');
//
// INPUT:
//
// $user_login login of the user that consults the forum
// $shard shard from which the user connects in
// $post_from user who create the thread
// $post_to forum in which the thread is to be created
// $post_subject topic of the new thread
// $post_content content of the first post (optional)
//
importParam('post_from');
importParam('post_to');
importParam('post_subject');
importParam('post_content');
check_character_belongs_to_guild($user_login, $post_to);
// check mail is valid
//if (!isset($post_from) || !isset($post_to) || !isset($post_subject))
// die('Incomplete post to send');
//if ($post_subject == '') $post_subject = 'No Subject';
// check recipient has an account
$to_dir = build_user_dir($post_to, $shard);
$to_index = $to_dir.'forum.index';
if (!file_exists($to_index))
{
build_forum_page($post_to);
}
if (trim($post_subject) != '')
{
$post_from = clean_string($post_from);
$post_to = clean_string($post_to);
$post_subject = clean_string($post_subject);
//
// send mail to recipient
//
// create new thread index
add_thread_to_forum_index($post_from, $post_to, $post_subject, $index);
// create thread file
create_thread($post_from, $post_to, $post_subject, $index);
// add main post to thread
if ($post_content != "")
add_post($post_from, $post_to, $post_content, $index, $last_date);
// rebuild thread page
build_thread_page($post_to, $index, $num_posts);
// update forum index since thread was touched
update_forum_index($post_to, $index, $num_posts, $last_date);
// rebuild forum page
build_forum_page($post_to);
}
// redirect browser to new forum page
//redirect("forum.php?forum=$post_to");
exportParam('forum', $post_to);
//$forum = $post_to;
include('forum.php');
?>

@ -0,0 +1,135 @@
<?php
include_once('mail_utils.php');
include_once('thread_utils.php');
if ($enter_login)
{
if ($login)
setcookie('user_login', $login, time()+86400);
else
setcookie('user_login');
}
if ($rebuild_mailbox)
{
build_mail_page($user);
}
if ($rebuild_forum)
{
build_forum_page($user);
}
if ($rebuild_thread)
{
build_thread_page($user, $thread, $num_posts);
}
if ($remove_thread)
{
remove_thread($user, $thread);
}
function selectUser($var)
{
return "<select name='$var'>\n".
"<option value='ace'>Ace\n".
"<option value='ben'>Ben\n".
"<option value='hulud'>Hulud\n".
"<option value='lem'>Lem\n".
"<option value='guild'>Guild\n".
"<option value='guest'>Guest\n".
"</select>\n";
}
echo "<html><head><title>Fake post form</title></head>\n";
echo "<body>\n";
echo "<table><form method=post action='form_post.php'>\n";
echo "<tr valign=top><td></td><td><input type=submit value='Refresh'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "<table><form method=post action='form_post.php'>\n";
echo "<tr valign=top><td>Login</td><td><input type=text name='login' size=50 maxlength=255 value='$user_login'></td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit name='enter_login' value='Enter'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Post a mail<br>\n";
echo "<table><form method=post action='post_mail.php'>\n";
echo "<tr valign=top><td>From</td><td>".selectUser('mail_from')."</td></tr>\n";
echo "<tr valign=top><td>To</td><td>".selectUser('mail_to')."</td></tr>\n";
echo "<tr valign=top><td>Subject</td><td><input type=text name='mail_subject' size=50 maxlength=255></td></tr>\n";
echo "<tr valign=top><td>Content</td><td><textarea name='mail_content' rows=20 cols=50></textarea></td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit value='Send'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Rebuild a mail box<br>\n";
echo "<table><form method=post action='form_post.php'>\n";
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit name='rebuild_mailbox' value='Rebuild'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Create a thread in a forum<br>\n";
echo "<table><form method=post action='create_thread.php'>\n";
echo "<tr valign=top><td>From</td><td>".selectUser('post_from')."</td></tr>\n";
echo "<tr valign=top><td>To</td><td>".selectUser('post_to')."</td></tr>\n";
echo "<tr valign=top><td>Subject</td><td><input type=text name='post_subject' size=50 maxlength=255></td></tr>\n";
echo "<tr valign=top><td>Content</td><td><textarea name='post_content' rows=20 cols=50></textarea></td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit value='Post'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Post a topic in a thread<br>\n";
echo "<table><form method=post action='post.php'>\n";
echo "<tr valign=top><td>From</td><td>".selectUser('post_from')."</td></tr>\n";
echo "<tr valign=top><td>To</td><td>".selectUser('post_to')."</td></tr>\n";
echo "<tr valign=top><td>Thread</td><td><input type=text name='post_thread' size=50 maxlength=255></td></tr>\n";
echo "<tr valign=top><td>Content</td><td><textarea name='post_content' rows=20 cols=50></textarea></td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit value='Post'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Rebuild a forum<br>\n";
echo "<table><form method=post action='form_post.php'>\n";
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit name='rebuild_forum' value='Rebuild'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Rebuild a thread<br>\n";
echo "<table><form method=post action='form_post.php'>\n";
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
echo "<tr valign=top><td>Thread</td><td><input type=text name='thread' size=50 maxlength=255></td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit name='rebuild_thread' value='Rebuild'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "Remove a thread<br>\n";
echo "<table><form method=post action='form_post.php'>\n";
echo "<tr valign=top><td>User</td><td>".selectUser('user')."</td></tr>\n";
echo "<tr valign=top><td>Thread</td><td><input type=text name='thread' size=50 maxlength=255></td></tr>\n";
echo "<tr valign=top><td></td><td><input type=submit name='remove_thread' value='Remove'></td></tr>\n";
echo "</form></table>\n";
echo "<br><hr><br>\n";
echo "</body>\n";
echo "</html>\n";
?>

@ -0,0 +1,29 @@
<?php
include_once('utils.php');
//
// INPUT:
//
// $user_login login of the user that consults the forum
// $shard shard from which the user connects in
// $forum forum to view
//
importParam('forum');
importParam('page');
check_character_belongs_to_guild($user_login, $forum);
$forum_dir = build_user_dir($forum, $shard);
$fname = $forum_dir.'forum'.(isset($page) && $page!="" && $page!="0" ? "_$page" : '').'.html';
if (!file_exists($fname))
{
include_once('thread_utils.php');
build_forum_page($forum);
}
$f = fopen($fname, 'r');
echo fread($f, filesize($fname));
fclose($f);
?>

@ -0,0 +1,123 @@
<?php
$race = &$_GET['race'];
$faction = &$_GET['faction'];
$shard = &$_GET['shard'];
$lang = &$_GET['lang'];
$user_login = &$_GET['user_login'];
$guild_name=&$_GET['guild_name'];
$guild_name=str_replace('_',' ', $guild_name);
include 'episode2_hof_outils.php';
$include_files = hof_init(array('episode2_valeurs_craft.hdt','episode2_valeurs_seuils.hdt'), 'episode2_hof_noms_%lang%.php');
foreach ($include_files as $include_file)
{
if (!@include $include_file)
{
//die('include file '.$include_file.' not found');
exit();
}
}
include 'episode2_hof_titles.php';
echo '<html>';
echo '<head><title>'.$titre.'</title></head>';
echo '<body bgcolor="#30353A">';
echo hof_tab_hgroup($tabs, 'chantier');
echo '<br>';
if ($faction=='karavan')
{
$tmp_item1_max = ${"maxSocle".$race};
$tmp_item1_cur = ${"Socle".$race};
$item1_percent = min($tmp_item1_cur, $tmp_item1_max) * 100 / $tmp_item1_max;
$tmp_item2_max = ${"maxColonne".$race};
$tmp_item2_cur = ${"Colonne".$race};
$item2_percent = min($tmp_item2_cur, $tmp_item2_max) * 100 / $tmp_item2_max;
$tmp_item3_max = ${"maxComble".$race};
$tmp_item3_cur = ${"Comble".$race};
$item3_percent = min($tmp_item3_cur, $tmp_item3_max) * 100 / $tmp_item3_max;
$tmp_item4_max = ${"maxMuraille".$race};
$tmp_item4_cur = ${"Muraille".$race};
$item4_percent = min($tmp_item4_cur, $tmp_item4_max) * 100 / $tmp_item4_max;
$tmp_item5_max = ${"maxRevetement".$race};
$tmp_item5_cur = ${"Revetement".$race};
$item5_percent = min($tmp_item5_cur, $tmp_item5_max) * 100 / $tmp_item5_max;
$tmp_item6_max = ${"maxOrnement".$race};
$tmp_item6_cur = ${"Ornement".$race};
$item6_percent = min($tmp_item6_cur, $tmp_item6_max) * 100 / $tmp_item6_max;
$tmp_item7_max = ${"maxStatue".$race};
$tmp_item7_cur = ${"Statue".$race};
$item7_percent = min($tmp_item7_cur, $tmp_item7_max) * 100 / $tmp_item7_max;
$tmp_main_max = ${"maxJustice".$race};
$tmp_main_cur = ${"Justice".$race};
$main_percent = min($tmp_main_cur, $tmp_main_max) * 100 / $tmp_main_max;
}
else
{
$tmp_item1_max = ${"maxRacine".$race};
$tmp_item1_cur = ${"Racine".$race};
$item1_percent = min($tmp_item1_cur, $tmp_item1_max) * 100 / $tmp_item1_max;
$tmp_item2_max = ${"maxTronc".$race};
$tmp_item2_cur = ${"Tronc".$race};
$item2_percent = min($tmp_item2_cur, $tmp_item2_max) * 100 / $tmp_item2_max;
$tmp_item3_max = ${"maxFibre".$race};
$tmp_item3_cur = ${"Fibre".$race};
$item3_percent = min($tmp_item3_cur, $tmp_item3_max) * 100 / $tmp_item3_max;
$tmp_item4_max = ${"maxEcorce".$race};
$tmp_item4_cur = ${"Ecorce".$race};
$item4_percent = min($tmp_item4_cur, $tmp_item4_max) * 100 / $tmp_item4_max;
$tmp_item5_max = ${"maxFeuille".$race};
$tmp_item5_cur = ${"Feuille".$race};
$item5_percent = min($tmp_item5_cur, $tmp_item5_max) * 100 / $tmp_item5_max;
$tmp_item6_max = ${"maxFleur".$race};
$tmp_item6_cur = ${"Fleur".$race};
$item6_percent = min($tmp_item6_cur, $tmp_item6_max) * 100 / $tmp_item6_max;
$tmp_item7_max = ${"maxSymbole".$race};
$tmp_item7_cur = ${"Symbole".$race};
$item7_percent = min($tmp_item7_cur, $tmp_item7_max) * 100 / $tmp_item7_max;
$tmp_main_max = ${"maxNoyau".$race};
$tmp_main_cur = ${"Noyau".$race};
$main_percent = min($tmp_main_cur, $tmp_main_max) * 100 / $tmp_main_max;
}
$total_percent= ($item1_percent+$item2_percent+$item3_percent+$item4_percent+$item5_percent+$item6_percent+$item7_percent+$main_percent)/8;
echo '<table nowrap cellspacing=10 width=100% align="center"><tr><td height=5 bgcolor="#101112"></td></tr><tr><td><table nowrap cellspacing=10 width=100% align="center">';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right"><H2>'.$txt_progress_batiment.'</H2></td><td width=300 align="left">'.hof_progress_bar_huge($total_percent).'</td><td width=25></td></tr></table><table nowrap cellspacing=10 width=100% align="center">';
if ($noActe == 1)
{
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece1.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item1_percent,1).'</td><td width=25></td></tr>';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece2.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item2_percent,1).'</td><td width=25></td></tr>';
}
else
{
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece1.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item1_percent,0).'</td><td width=25></td></tr>';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece2.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item2_percent,0).'</td><td width=25></td></tr>';
if($noActe == 2)
{
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece3.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item3_percent,1).'</td><td width=25></td></tr>';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece4.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item4_percent,1).'</td><td width=25></td></tr>';
}
else
{
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece3.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item3_percent,0).'</td><td width=25></td></tr>';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece4.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item4_percent,0).'</td><td width=25></td></tr>';
if($noActe == 3)
{
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece5.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item5_percent,1).'</td><td width=25></td></tr>';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece6.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item6_percent,1).'</td><td width=25></td></tr>';
echo '<tr><td width=25></td><td width=300 valign="middle" align="right">'.$txt_piece7.'&nbsp;</td><td width=300 align="left">'.hof_progress_bar($item7_percent,1).'</td><td width=25></td></tr>';
}
}
}
echo '<tr><td width=25></td><td width=300 valign="middle" align="right"><b>'.$txt_piece8.'</b>&nbsp;</td><td width=300 align="left">'.hof_progress_bar($main_percent,1).'</td><td width=25></td></tr></table>';
echo '<tr><td height=5 bgcolor="#101112"></td></tr></table>';
echo '</body>';
echo '</html>';
?>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save