summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2012-12-12 22:40:37 -0800
committerBen Longbons <b.r.longbons@gmail.com>2012-12-12 22:43:10 -0800
commitf9563edf69f083287630f4b17db70d97524196d6 (patch)
tree495a75932bf493c4a2afb94f924e3efde4ea70a8 /src
parent608f959900968e83fd25231c72308fc608742dd5 (diff)
downloadtmwa-f9563edf69f083287630f4b17db70d97524196d6.tar.gz
tmwa-f9563edf69f083287630f4b17db70d97524196d6.tar.bz2
tmwa-f9563edf69f083287630f4b17db70d97524196d6.tar.xz
tmwa-f9563edf69f083287630f4b17db70d97524196d6.zip
Delete old tools
If there was anything you actually used, tell me.
Diffstat (limited to 'src')
-rw-r--r--src/tool/adduser.cpp115
-rw-r--r--src/tool/backup100
-rw-r--r--src/tool/cgi/addaccount.cgi204
-rw-r--r--src/tool/checkversion85
-rw-r--r--src/tool/convert.cpp302
-rw-r--r--src/tool/getlogincount122
-rwxr-xr-xsrc/tool/indent.sh8
-rwxr-xr-xsrc/tool/ipcheck.rb82
-rw-r--r--src/tool/itemfrob.cpp130
-rw-r--r--src/tool/itemsearch.cpp136
-rw-r--r--src/tool/ladmin3793
-rw-r--r--src/tool/mapcheck.sh34
-rw-r--r--src/tool/mapchecker.sh56
-rw-r--r--src/tool/mapfrob.cpp129
-rw-r--r--src/tool/marriage-info.cpp482
-rwxr-xr-xsrc/tool/marriage-info.sh20
-rw-r--r--src/tool/moneycount/athena_text.cpp263
-rw-r--r--src/tool/moneycount/athena_text.hpp9
-rw-r--r--src/tool/moneycount/inf.cpp1482
-rw-r--r--src/tool/moneycount/inf.hpp228
-rw-r--r--src/tool/moneycount/main.cpp180
-rw-r--r--src/tool/moneycount/mmo.hpp309
-rw-r--r--src/tool/moneycount/portability_exceptions.hpp33
-rw-r--r--src/tool/moneycount/portability_fixes.cpp39
-rw-r--r--src/tool/moneycount/portability_fixes.hpp127
-rw-r--r--src/tool/skillfrob.cpp80
-rwxr-xr-xsrc/tool/stats.sh44
-rw-r--r--src/webserver/GNUmakefile7
-rw-r--r--src/webserver/doc/API.txt50
-rw-r--r--src/webserver/doc/README11
-rw-r--r--src/webserver/generate.cpp35
-rw-r--r--src/webserver/htmlstyle.cpp45
-rw-r--r--src/webserver/logs.cpp8
-rw-r--r--src/webserver/main.cpp145
-rw-r--r--src/webserver/pages/about.cpp6
-rw-r--r--src/webserver/pages/notdone.cpp6
-rw-r--r--src/webserver/pages/sample.cpp22
-rw-r--r--src/webserver/parse.cpp132
38 files changed, 0 insertions, 9059 deletions
diff --git a/src/tool/adduser.cpp b/src/tool/adduser.cpp
deleted file mode 100644
index 1954b66..0000000
--- a/src/tool/adduser.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- This program adds an user to account.txt
- Don't usr it When login-sever is working.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-char *account_txt = "../save/account.txt";
-
-//-----------------------------------------------------
-// Function to suppress control characters in a string.
-//-----------------------------------------------------
-int remove_control_chars (unsigned char *str)
-{
- int i;
- int change = 0;
-
- for (i = 0; str[i]; i++)
- {
- if (str[i] < 32)
- {
- str[i] = '_';
- change = 1;
- }
- }
-
- return change;
-}
-
-int main (int argc, char *argv[])
-{
-
- char username[24];
- char password[24];
- char sex[2];
-
- int next_id, id;
- char line[1024];
-
- // Check to see if account.txt exists.
- printf ("Checking if '%s' file exists...\n", account_txt);
- FILE *FPaccin = fopen (account_txt, "r");
- if (FPaccin == NULL)
- {
- printf ("'%s' file not found!\n", account_txt);
- printf ("Run the setup wizard please.\n");
- exit (0);
- }
-
- next_id = 2000000;
- while (fgets (line, sizeof (line) - 1, FPaccin))
- {
- if (line[0] == '/' && line[1] == '/')
- {
- continue;
- }
- if (sscanf (line, "%d\t%%newid%%\n", &id) == 1)
- {
- if (next_id < id)
- {
- next_id = id;
- }
- }
- else
- {
- sscanf (line, "%i%[^ ]", &id);
- if (next_id <= id)
- {
- next_id = id + 1;
- }
- }
- }
- fclose (FPaccin);
- printf ("File exists.\n");
-
- printf ("Don't create an account if the login-server is online!!!\n");
- printf
- ("If the login-server is online, press ctrl+C now to stop this software.\n");
- printf ("\n");
-
- strcpy (username, "");
- while (strlen (username) < 4 || strlen (username) > 23)
- {
- printf ("Enter an username (4-23 characters): ");
- scanf ("%s", &username);
- username[23] = 0;
- remove_control_chars (username);
- }
-
- strcpy (password, "");
- while (strlen (password) < 4 || strlen (password) > 23)
- {
- printf ("Enter a password (4-23 characters): ");
- scanf ("%s", &password);
- password[23] = 0;
- remove_control_chars (password);
- }
-
- strcpy (sex, "");
- while (strcmp (sex, "F") != 0 && strcmp (sex, "M") != 0)
- {
- printf ("Enter a gender (M for male, F for female): ");
- scanf ("%s", &sex);
- }
-
- FILE *FPaccout = fopen (account_txt, "r+");
- fseek (FPaccout, 0, SEEK_END);
- fprintf (FPaccout, "%i %s %s - %s -\r\n", next_id, username,
- password, sex);
- fclose (FPaccout);
-
- printf ("Account added.\n");
-}
diff --git a/src/tool/backup b/src/tool/backup
deleted file mode 100644
index bde63b5..0000000
--- a/src/tool/backup
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/perl
-
-##########################################################################
-# Athena用データバックアップツール
-#
-#  Athenaの各種データファイル*.txtをバックアップするツール
-#
-#-------------------------------------------------------------------------
-# 設定方法
-#  実行する時のカレントフォルダからのデータへのパス、ファイルのリストを
-#  正しく設定します。バックアップ先のフォルダは自動作成されないので、
-#  自分で作成しておく必要があります。
-#  フォルダの最後の「/」は省略できません。
-#
-#  フォルダは引数でも指定できます。例>./backup ../save/ ./backup_data/
-#  フォルダの最後の「/」は省略できません。
-#
-#  実行するとバックアップ先のフォルダへ、ファイル名に現在の日付と時刻を
-#  つけてファイルをコピーします。
-#
-# * toolフォルダ内にbackup_dataフォルダを作成し、
-#   athena.shの中に「./tool/backup ./save/ ./tool/backup_data/」
-# という行を追加すると、athenaを起動するたびにバックアップが取れます
-#
-# 復元するときは引数に「-r 日付と時刻」を指定します。
-#  またその後ろにフォルダを指定することも出来ます
-#  例1> ./backup -r 200309191607
-#  例2> ./backup -r 200309191607 ../save ./backup_data/
-#  この例では2003/09/19の16:07分にバックアップしたデータを復元しています
-#
-#  復元するとき、Athenaディレクトリにあるデータは *.bak に名前を変更して
-#  残しているので、いらない場合は rm *.bak などで消してください。
-#
-##########################################################################
-
-$sdir="../save/"; #バックアップ元(Athenaのディレクトリ/save/)
-$tdir="./backup_data/"; #バックアップ先
-
-@files=( #ファイルのリスト
- "account","athena","storage","party","guild","castle","pet"
-);
-
-
-#-------------------------------設定ここまで-----------------------------
-
-
-
-
-
-
-
-
-
-
-
-if($ARGV[0]=~/^\-r$/i || $ARGV[0]=~/\-\-(recover|restore)/i){
- #復元処理
-
- $file=$ARGV[1];
- $sdir=$ARGV[2]||$sdir;
- $tdir=$ARGV[3]||$tdir;
- &restorecopy($_) foreach @files;
- exit(0);
-}
-
-#バックアップ処理
-$sdir=$ARGV[0]||$sdir;
-$tdir=$ARGV[1]||$tdir;
-
-unless( -d $tdir ){
- print "$0: \"$tdir\" : No such directory\n";
- exit(1);
-}
-
-(undef,$min,$hour,$day,$month,$year)=localtime;
-
-$file=sprintf("%04d%02d%02d%02d%02d",
- $year+1900, $month+1, $day, $hour, $min );
-
-&backupcopy($_) foreach @files;
-exit(0);
-
-sub backupcopy {
- my($name)= @_;
- system("cp $sdir$name.txt $tdir$name$file.txt");
-}
-
-sub restorecopy {
- my($name)= @_;
- unless( -f "$sdir$name.txt" ){
- printf("$0: \"$sdir$name.txt\" not found!\n");
- return 0;
- }
- unless( -f "$tdir$name$file.txt" ){
- printf("$0: \"$tdir$name$file.txt\" not found!\n");
- return 0;
- }
- rename "$sdir$name.txt","$sdir$name.bak";
- system("cp $tdir$name$file.txt $sdir$name.txt");
-}
diff --git a/src/tool/cgi/addaccount.cgi b/src/tool/cgi/addaccount.cgi
deleted file mode 100644
index 009f30f..0000000
--- a/src/tool/cgi/addaccount.cgi
+++ /dev/null
@@ -1,204 +0,0 @@
-#!/usr/bin/perl
-
-#=========================================================================
-# addaccount.cgi ver.1.00
-# ladminをラップした、アカウントを作成するCGI。
-# ladmin ver.1.04での動作を確認。
-#
-# ** 設定方法 **
-#
-# - 下の$ladmin変数にladminへのパスを設定すること。
-# - UNIX系OSで使用する場合はladminと共に改行コードを変換すること、また
-# ファイル先頭行をperlの正しいパスにすること。例> $ which perl
-# - サーバープログラムやブラウザによっては $cgiuri にこのファイルへの
-# 完全なURIをセットしなければならない場合もある。
-# - perlにパスが通っていない場合は $perl をperlへの正しいパスにすること。
-# - 他は普通のCGIと同じです。(実行権やcgi-binフォルダなど)
-#
-# ** その他 **
-# addaccount.cgi をブラウザで開くとサンプルHTML(そのまま使えます)が
-# 開きます。また、このcgiはブラウザから送られるAccept-Languageが
-# jaで始まっていればメッセージの一部を日本語に変換します。
-# (IEならインターネットオプションの言語設定で一番上に日本語を置く)
-# それ以外の場合は英語のまま出力します。
-#-------------------------------------------------------------------------
-
-my($ladmin) = "../ladmin"; # ladminのパス(おそらく変更が必要)
-
-my($cgiuri) = "./addaccount.cgi"; # このファイルのURI
-my($perl) = "perl"; # perlのコマンド名
-
-
-
-#--------------------------- 設定ここまで --------------------------------
-
-
-
-
-
-
-use strict;
-use CGI;
-
-my($cgi)= new CGI;
-my(%langconv)=(
- 'Athena login-server administration tool.*' => '',
- 'logged on.*' => '',
-);
-
-# ----- 日本語環境なら変換テーブルをセット -----
-if($ENV{'HTTP_ACCEPT_LANGUAGE'}=~/^ja/){
- my(%tmp)=(
- 'Account \[(.+)\] is successfully created.*'
- => 'アカウント "$1" を作成しました.',
- 'Account \[(.+)\] creation failed\. same account exists.*'
- => 'アカウント "$1" は既に存在します.',
- 'Illeagal charactor found in UserID.*'
- => 'IDの中に不正な文字があります.',
- 'Illeagal charactor found in Password.*'
- => 'Passwordの中に不正な文字があります.',
- 'input UserID 4-24 bytes.'
- => 'IDは半角4〜24文字で入力してください.',
- 'input Password 4-24 bytes.'
- => 'Passwordは半角4〜24文字で入力してください.',
- 'Illeagal gender.*'
- => '性別がおかしいです.',
- 'Cant connect to login server.*'
- => 'ログインサーバーに接続できません.',
- 'login error.*'
- => 'ログインサーバーへの管理者権限ログインに失敗しました',
- "Can't execute ladmin.*"
- => 'ladminの実行に失敗しました',
- 'UserID "(.+)" is already used.*'
- => 'ID "$1" は既に使用されています.',
- 'You can use UserID \"(.+)\".*'
- => 'ID "$1" は使用可能です.',
-
- 'account making' =>'アカウント作成',
- '\>UserID' =>'>ID',
- '\>Password' =>'>パスワード',
- '\>Gender' =>'>性別',
- '\>Male' =>'>男性',
- '\>Female' =>'>女性',
- '\"Make Account\"' =>'"アカウント作成"',
- '\"Check UserID\"' =>'"IDのチェック"',
- );
- map { $langconv{$_}=$tmp{$_}; } keys (%tmp);
-}
-
-# ----- 追加 -----
-if( $cgi->param("addaccount") ){
- my($userid)= $cgi->param("userid");
- my($passwd)= $cgi->param("passwd");
- my($gender)= lc(substr($cgi->param("gender"),0,1));
- if(length($userid)<4 || length($userid)>24){
- HttpError("input UserID 4-24 bytes.");
- }
- if(length($passwd)<4 || length($passwd)>24){
- HttpError("input Password 4-24 bytes.");
- }
- if($userid=~/[^0-9A-Za-z\@\_\-\']/){
- HttpError("Illeagal charactor found in UserID.");
- }
- if($passwd=~/[\x00-\x1f\x80-\xff\']/){
- HttpError("Illeagal charactor found in Password.");
- }
- if($gender!~/[mf]/){
- HttpError("Gender error.");
- }
- open PIPE,"$perl $ladmin --add $userid $gender $passwd |"
- or HttpError("Can't execute ladmin.");
- my(@msg)=<PIPE>;
- close PIPE;
- HttpMsg(@msg);
-}
-# ----- 存在チェック -----
-elsif( $cgi->param("check") ){
- my($userid)= $cgi->param("userid");
- if(length($userid)<4 || length($userid)>24){
- HttpError("input UserID 4-24 bytes.");
- }
- if($userid=~/[^0-9A-Za-z\@\_\-\']/){
- HttpError("Illeagal charactor found in UserID.");
- }
- open PIPE,"$perl $ladmin --search --regex \\b$userid\\b |"
- or HttpError("Can't execute ladmin.");
- my(@msg)=<PIPE>;
- close PIPE;
- if(scalar(@msg)==6 && (split /[\s\0]+/,substr($msg[4],11,24))[0] eq $userid){
- HttpMsg("NG : UserID \"$userid\" is already used.");
- }elsif(scalar(@msg)==5){
- HttpMsg("OK : You can use UserID \"$userid\"");
- }
- HttpError("ladmin error ?\n---output---\n",@msg);
-}
-
-# ----- フォーム -----
-else{
- print LangConv( <<"EOM" );
-Content-type: text/html\n
-<html>
- <head>
- <title>Athena account making cgi</title>
- </head>
- <body>
- <h1>Athena account making cgi</h1>
- <form action="$cgiuri" method="post">
- <table border=2>
- <tr>
- <th>UserID</th>
- <td><input name="userid" size=24 maxlength=24></td>
- </tr>
- <tr>
- <th>Password</th>
- <td><input name="passwd" size=24 maxlength=24 type="password"></td>
- </tr>
- <tr>
- <th>Gender</th>
- <td>
- <input type="radio" name="gender" value="male">Male
- <input type="radio" name="gender" value="female">Female
- </td>
- </tr>
- <tr>
- <td colspan=2>
- <input type="submit" name="addaccount" value="Make Account">
- <input type="submit" name="check" value="Check UserID">
- </td>
- </tr>
- </table>
- </form>
- </body>
-</html>
-EOM
- exit;
-}
-
-sub LangConv {
- my(@lst)= @_;
- my($a,$b,@out)=();
- foreach $a(@lst){
- foreach $b(keys %langconv){
- $a=~s/$b/$langconv{$b}/g;
- my($rep1)=$1;
- $a=~s/\$1/$rep1/g;
- }
- push @out,$a;
- }
- return @out;
-}
-
-sub HttpMsg {
- my($msg)=join("", LangConv(@_));
- $msg=~s/\n/<br>\n/g;
- print LangConv("Content-type: text/html\n\n"),$msg;
- exit;
-}
-
-sub HttpError {
- my($msg)=join("", LangConv(@_));
- $msg=~s/\n/<br>\n/g;
- print LangConv("Content-type: text/html\n\n"),$msg;
- exit;
-}
-
diff --git a/src/tool/checkversion b/src/tool/checkversion
deleted file mode 100644
index 9e485d9..0000000
--- a/src/tool/checkversion
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/perl -w
-
-##########################################################################
-# INFORMATION TOOL ABOUT THE SERVERS VERSION OF ATHENA
-#
-# By connection on a server, this software display the version of the
-# designed server.
-#-------------------------------------------------------------------------
-# Usages:
-# ./checkversion IP:port
-# ./checkversion IP port
-# perl checkversion IP:port
-# perl checkversion IP port
-#
-# note: default port: 6900
-#
-# When successfull, the software return the value 0.
-#
-##########################################################################
-
-#------------------------- start of configuration ------------------------
-
-$connecttimeout = 10; # Connection Timeout (in seconds)
-
-#-------------------------- End of configuration -------------------------
-
-use IO::Socket;
-
-unless($ARGV[0]) {
- print "USAGE: $0 server_ip:port\n";
- exit(1);
-}
-
-$server = $ARGV[0];
-$port = $ARGV[1];
-$port = $1 if ($server =~ s/:(\d+)//);
-$port ||= 6900;
-
-# Connection to the server
-my($so,$er) = ();
-eval{
- $so = IO::Socket::INET->new(
- PeerAddr=> $server,
- PeerPort=> $port,
- Proto => "tcp",
- Timeout => $connecttimeout) or $er = 1;
-};
-
-if($er || $@) {
- print "Can't not connect to server [$server:$port] !\n";
- exit(2);
-}
-
-# Request for the server version
-print $so pack("v",30000); # 0x7530
-$so->flush();
-
-# Receiving of the answer of the server
-if (read($so,$buf,10) < 10) {
- print "Invalid answer. It isn't an athena server or it is a too old version.\n";
- exit(5);
-}
-
-# Sending end of connection to the server
-print $so pack("v",30002); # 0x7532
-$so->flush();
-
-# Analyse of the answer
-my($ret,$maver,$miver,$rev,$dev,$mod,$type,$mdver) = unpack("v c6 v",$buf);
-
-if ($ret != 30001) { # 0x7531
- print "Invalid answer. It isn't an athena server or it is a too old version.\n";
- exit(6);
-}
-
-my(@stype) = ();
-foreach $i(0..3) {
- push @stype,(("login","char","inter","map")[$i]) if( $type & (1<<$i) );
-}
-print " ".join("/",@stype)." server [$server:$port].\n";
-printf " Athena version %s-%d.%d", ("stable","dev")[$dev], $maver,$miver;
-printf " revision %d",$rev if $rev;
-printf "%s%d\n",("","-mod")[$mod],$mdver;
-
-exit(0);
diff --git a/src/tool/convert.cpp b/src/tool/convert.cpp
deleted file mode 100644
index e256fc9..0000000
--- a/src/tool/convert.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#define MAX_INVENTORY 100
-#define MAX_CART 100
-#define MAX_SKILL 350
-#define GLOBAL_REG_NUM 16
-
-struct item
-{
- int id;
- short nameid;
- short amount;
- short equip;
- char identify;
- char refine;
- char attribute;
- short card[4];
-};
-struct point
-{
- char map[16];
- short x, y;
-};
-struct skill
-{
- unsigned short id, lv, flag;
-};
-struct global_reg
-{
- char str[16];
- int value;
-};
-
-struct mmo_charstatus
-{
- int char_id;
- int account_id;
- int base_exp, job_exp, zeny;
-
- short class;
- short status_point, skill_point;
- short hp, max_hp, sp, max_sp;
- short option, karma, manner;
- short hair, hair_color, clothes_color;
- int party_id, guild_id, pet_id;
-
- short weapon, shield;
- short head_top, head_mid, head_bottom;
-
- char name[24];
- unsigned char base_level, job_level;
- unsigned char str, agi, vit, int_, dex, luk, char_num, sex;
-
- struct point last_point, save_point, memo_point[3];
- struct item inventory[MAX_INVENTORY], cart[MAX_CART];
- struct skill skill[MAX_SKILL];
- int global_reg_num;
- struct global_reg global_reg[GLOBAL_REG_NUM];
-};
-
-int mmo_char_tostr (char *str, struct mmo_charstatus *p)
-{
- int i;
- sprintf (str, "%d\t%d,%d\t%s\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%s,%d,%d\t%s,%d,%d", p->char_id, p->account_id, p->char_num, p->name, //
- p->class, p->base_level, p->job_level, p->base_exp, p->job_exp, p->zeny, p->hp, p->max_hp, p->sp, p->max_sp, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->status_point, p->skill_point, p->option, p->karma, p->manner, //
- p->party_id, p->guild_id, p->pet_id, p->hair, p->hair_color, p->clothes_color, p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, p->last_point.map, p->last_point.x, p->last_point.y, //
- p->save_point.map, p->save_point.x, p->save_point.y);
- strcat (str, "\t");
- for (i = 0; i < 3; i++)
- if (p->memo_point[i].map[0])
- {
- sprintf (str + strlen (str), "%s,%d,%d", p->memo_point[i].map,
- p->memo_point[i].x, p->memo_point[i].y);
- }
- strcat (str, "\t");
- for (i = 0; i < MAX_INVENTORY; i++)
- if (p->inventory[i].nameid)
- {
- sprintf (str + strlen (str), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->inventory[i].id, p->inventory[i].nameid,
- p->inventory[i].amount, p->inventory[i].equip,
- p->inventory[i].identify, p->inventory[i].refine,
- p->inventory[i].attribute, p->inventory[i].card[0],
- p->inventory[i].card[1], p->inventory[i].card[2],
- p->inventory[i].card[3]);
- }
- strcat (str, "\t");
- for (i = 0; i < MAX_CART; i++)
- if (p->cart[i].nameid)
- {
- sprintf (str + strlen (str), "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->cart[i].id, p->cart[i].nameid, p->cart[i].amount,
- p->cart[i].equip, p->cart[i].identify, p->cart[i].refine,
- p->cart[i].attribute, p->cart[i].card[0],
- p->cart[i].card[1], p->cart[i].card[2],
- p->cart[i].card[3]);
- }
- strcat (str, "\t");
- for (i = 0; i < MAX_SKILL; i++)
- if (p->skill[i].id)
- {
- sprintf (str + strlen (str), "%d,%d ", p->skill[i].id,
- p->skill[i].lv);
- }
- strcat (str, "\t");
- for (i = 0; i < p->global_reg_num; i++)
- sprintf (str + strlen (str), "%s,%d ", p->global_reg[i].str,
- p->global_reg[i].value);
- strcat (str, "\t");
- return 0;
-}
-
-int mmo_char_fromstr (char *str, struct mmo_charstatus *p)
-{
- int tmp_int[256];
- int set, next, len, i;
-
- set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, //
- &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], //
- &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], p->last_point.map, &tmp_int[34], &tmp_int[35], //
- p->save_point.map, &tmp_int[36], &tmp_int[37], &next);
- p->char_id = tmp_int[0];
- p->account_id = tmp_int[1];
- p->char_num = tmp_int[2];
- p->class = tmp_int[3];
- p->base_level = tmp_int[4];
- p->job_level = tmp_int[5];
- p->base_exp = tmp_int[6];
- p->job_exp = tmp_int[7];
- p->zeny = tmp_int[8];
- p->hp = tmp_int[9];
- p->max_hp = tmp_int[10];
- p->sp = tmp_int[11];
- p->max_sp = tmp_int[12];
- p->str = tmp_int[13];
- p->agi = tmp_int[14];
- p->vit = tmp_int[15];
- p->int_ = tmp_int[16];
- p->dex = tmp_int[17];
- p->luk = tmp_int[18];
- p->status_point = tmp_int[19];
- p->skill_point = tmp_int[20];
- p->option = tmp_int[21];
- p->karma = tmp_int[22];
- p->manner = tmp_int[23];
- p->party_id = tmp_int[24];
- p->guild_id = tmp_int[25];
- p->pet_id = 0;
- p->hair = tmp_int[26];
- p->hair_color = tmp_int[27];
- p->clothes_color = tmp_int[28];
- p->weapon = tmp_int[29];
- p->shield = tmp_int[30];
- p->head_top = tmp_int[31];
- p->head_mid = tmp_int[32];
- p->head_bottom = tmp_int[33];
- p->last_point.x = tmp_int[34];
- p->last_point.y = tmp_int[35];
- p->save_point.x = tmp_int[36];
- p->save_point.y = tmp_int[37];
- if (set != 41)
- return 0;
- if (str[next] == '\n' || str[next] == '\r')
- return 1; // 新規データ
- next++;
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- set =
- sscanf (str + next, "%[^,],%d,%d%n", p->memo_point[i].map,
- &tmp_int[0], &tmp_int[1], &len);
- if (set != 3)
- return 0;
- p->memo_point[i].x = tmp_int[0];
- p->memo_point[i].y = tmp_int[1];
- next += len;
- if (str[next] == ' ')
- next++;
- }
- next++;
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- set = sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
- &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
- &len);
- if (set != 11)
- return 0;
- p->inventory[i].id = tmp_int[0];
- p->inventory[i].nameid = tmp_int[1];
- p->inventory[i].amount = tmp_int[2];
- p->inventory[i].equip = tmp_int[3];
- p->inventory[i].identify = tmp_int[4];
- p->inventory[i].refine = tmp_int[5];
- p->inventory[i].attribute = tmp_int[6];
- p->inventory[i].card[0] = tmp_int[7];
- p->inventory[i].card[1] = tmp_int[8];
- p->inventory[i].card[2] = tmp_int[9];
- p->inventory[i].card[3] = tmp_int[10];
- next += len;
- if (str[next] == ' ')
- next++;
- }
- next++;
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- set = sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
- &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
- &len);
- if (set != 11)
- return 0;
- p->cart[i].id = tmp_int[0];
- p->cart[i].nameid = tmp_int[1];
- p->cart[i].amount = tmp_int[2];
- p->cart[i].equip = tmp_int[3];
- p->cart[i].identify = tmp_int[4];
- p->cart[i].refine = tmp_int[5];
- p->cart[i].attribute = tmp_int[6];
- p->cart[i].card[0] = tmp_int[7];
- p->cart[i].card[1] = tmp_int[8];
- p->cart[i].card[2] = tmp_int[9];
- p->cart[i].card[3] = tmp_int[10];
- next += len;
- if (str[next] == ' ')
- next++;
- }
- next++;
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- set = sscanf (str + next, "%d,%d%n", &tmp_int[0], &tmp_int[1], &len);
- if (set != 2)
- return 0;
- p->skill[tmp_int[0]].id = tmp_int[0];
- p->skill[tmp_int[0]].lv = tmp_int[1];
- next += len;
- if (str[next] == ' ')
- next++;
- }
- next++;
- for (i = 0;
- str[next] && str[next] != '\t' && str[next] != '\n'
- && str[next] != '\r'; i++)
- { //global_reg実装以前のathena.txt互換のため一応'\n'チェック
- set = sscanf (str + next, "%[^,],%d%n",
- p->global_reg[i].str, &p->global_reg[i].value, &len);
- if (set != 2)
- return 0;
- next += len;
- if (str[next] == ' ')
- next++;
- }
- p->global_reg_num = i;
- return 1;
-}
-
-int mmo_char_convert (char *fname1, char *fname2)
-{
- char line[65536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp, *ofp;
-
- ifp = fopen_ (fname1, "r");
- ofp = fopen_ (fname2, "w");
- if (ifp == NULL)
- {
- printf ("file not found %s\n", fname1);
- return 0;
- }
- if (ofp == NULL)
- {
- printf ("file open error %s\n", fname2);
- return 0;
- }
- while (fgets (line, 65535, ifp))
- {
- memset (&char_dat, 0, sizeof (struct mmo_charstatus));
- ret = mmo_char_fromstr (line, &char_dat);
- if (ret)
- {
- mmo_char_tostr (line, &char_dat);
- fprintf (ofp, "%s\n", line);
- }
- }
- fcloseall ();
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- if (argc < 3)
- {
- printf ("Usage: convert <input filename> <output filename>\n");
- exit (0);
- }
- mmo_char_convert (argv[1], argv[2]);
-
- return 0;
-}
diff --git a/src/tool/getlogincount b/src/tool/getlogincount
deleted file mode 100644
index 45c6f81..0000000
--- a/src/tool/getlogincount
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/usr/bin/perl -w
-
-##########################################################################
-# INFORMATION TOOL ABOUT THE # OF ONLINE PLAYERS ON ATHENA SERVERS
-#
-# By connection on the athena login-server, this software displays the
-# number of online players.
-#
-#-------------------------------------------------------------------------
-# Software usage:
-# Configure the IP, the port and a valid account of the server.
-# After, use at your choice:
-# ./getlogincount - display the number of online players on all servers.
-# ./getlogincount --premier or
-# ./getlogincount --first -- display the number of online players of the
-# first server in the received list.
-# ./getlogincount [servername] -- display the number of online players
-# of the specified server.
-#
-# If successfull, the software return the value 0.
-#
-##########################################################################
-
-#------------------------------ CONFIGURATION ----------------------------
-
-$loginserverip = "127.0.0.1"; # IP of the login-server
-$loginserverport = 6900; # port of the login-server
-$loginaccount = "s1"; # a valid account name
-$loginpasswd = "p1"; # the password of the valid account name
-
-$connecttimeout = 10; # Connection timeout (in seconds)
-
-#-------------------------------------------------------------------------
-
-use IO::Socket;
-
-my($sname) = $ARGV[0];
-if (!defined($sname)) {
- $sname = "";
-}
-
-# Connection to the login-server
-my($so,$er) = ();
-eval{
- $so = IO::Socket::INET->new(
- PeerAddr=> $loginserverip,
- PeerPort=> $loginserverport,
- Proto => "tcp",
- Timeout => $connecttimeout) or $er=1;
-};
-if($er || $@){
- print "Can't not connect to the login-server [${loginserverip}:$loginserverport] !\n";
- exit(2);
-}
-
-# Request to connect on login-server
-print $so pack("v V a24 a24 C",0x0064,9,$loginaccount,$loginpasswd,3);
-$so->flush();
-
-# Fail to connect
-if(unpack("v", &soread(\$so,2)) != 0x0069) {
- print "Login error.\n";
- exit(3);
-}
-
-# Get length of the received packet
-my($plen) = unpack("v",&soread(\$so,2))-4;
-
-# Suppress information of the account (we need only information about the servers)
-&soread(\$so,43);
-$plen -= 43;
-
-# Check about the number of online servers
-if ($plen < 32) {
- printf "No server is connected to login-server.\n";
- exit(1);
-}
-
-# Read information of the servers
-my(@slist) = ();
-for(;$plen > 0;$plen -= 32) {
- my($name,$count) = unpack("x6 a20 V",&soread(\$so,32));
- $name = substr($name,0,index($name,"\0"));
- push @slist, [ $name, $count ];
-}
-
-# Display the result
-if($sname eq "--first" || $sname eq "--premier") { # If we ask only for the first server
- printf "%-20s : %5d\n",$slist[0][0],$slist[0][1];
-} elsif ($sname eq "") { # If we ask for all servers
- foreach $i(@slist) {
- printf "%-20s : %5d\n",$i->[0],$i->[1];
- }
-} else { # If we ask for a specified server (by its name)
- my($flag) = 1;
- foreach $i(@slist) {
- if($i->[0] eq $sname) {
- printf "%-20s : %5d\n",$i->[0],$i->[1];
- $flag = 0;
- }
- }
- if($flag) { # If the server doesn't exist
- printf "The server [$sname] doesn't exist.\n";
- exit(1);
- }
-}
-
-# End of the software
-$so->shutdown(2);
-$so->close();
-exit(0);
-
-# Sub-function: get data from the socket
-sub soread {
- my($so,$len) = @_;
- my($sobuf);
- if(read($$so,$sobuf,$len) < $len) {
- print "Socket read error.\n";
- exit(5);
- }
- return $sobuf;
-};
diff --git a/src/tool/indent.sh b/src/tool/indent.sh
deleted file mode 100755
index d71f224..0000000
--- a/src/tool/indent.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# Simple script to help format code to TMW-eA standards.
-# You should use this on any file you edit before
-# committing to git.
-indent -nbad -bap -sc -bl -blf -bli0 -cli4 -cbi0 -di5 \
--nbc -bls -ip2 -nut -ts4 -bap -i4 -sob -npsl $*
-
-
diff --git a/src/tool/ipcheck.rb b/src/tool/ipcheck.rb
deleted file mode 100755
index 7c2e22a..0000000
--- a/src/tool/ipcheck.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env ruby
-# A script to check which characters play from the same IP address
-# (c) 2009 Bjorn Lindeijer
-#
-# Summary of how it works:
-#
-# Character -> Account
-# Account -> IP
-# IP -> Accounts
-# Accounts -> Characters
-#
-
-if ARGV.length != 1
- puts "Usage: ipcheck.rb character_name"
- exit 1
-else
- $search_character = ARGV[0]
- puts "Searching for character #{$search_character}"
-end
-
-class Character
- attr_reader :name, :account_id
-
- def initialize(name, account_id)
- @name = name
- @account_id = account_id
- end
-end
-
-class Account
- attr_reader :id, :ip, :last_login
-
- def initialize(id, ip, last_login)
- @id = id
- @ip = ip
- @last_login = last_login
- end
-end
-
-accounts = Array.new
-characters = Array.new
-
-File.open("save/athena.txt", "r") do |f|
- f.each_line do |line|
- split = line.split("\t")
- if split.length >= 3
- account_id, char_index = split[1].split(',')
- character_name = split[2]
- characters.push(Character.new(character_name, account_id))
- if $search_character.casecmp(character_name) == 0
- puts "Searching for account #{account_id}"
- $search_account_id = account_id
- end
- end
- end
-end
-
-if not $search_account_id
- puts "Error: character #{$search_character} not found!"
- exit 1
-end
-
-File.open("save/account.txt", "r") do |f|
- f.each_line do |line|
- split = line.split("\t")
- if split.length >= 11
- account_id, last_login, ip = split[0], split[3], split[10]
- accounts.push(Account.new(account_id, ip, last_login))
- if $search_account_id == account_id
- puts "Searching for IP #{ip}"
- $search_ip = ip
- end
- end
- end
-end
-
-accounts.find_all { |a| a.ip == $search_ip }.each do |a|
- puts "Characters for account #{a.id} (last login #{a.last_login}):"
- characters.find_all { |c| c.account_id == a.id }.each do |c|
- puts " #{c.name}"
- end
-end
diff --git a/src/tool/itemfrob.cpp b/src/tool/itemfrob.cpp
deleted file mode 100644
index 81638eb..0000000
--- a/src/tool/itemfrob.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-// Compile with
-// gcc -m32 -I src/char -I src/common charfrob.c -o charfrob src/common/timer.o src/common/malloc.o src/common/socket.o src/common/lock.o src/common/db.o src/char/int_pet.o src/char/int_storage.o src/char/inter.o src/char/int_party.o src/char/int_guild.o
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../common/mmo.hpp"
-// Yes, this is intentional
-#include "../char/char.cpp"
-
-// Well, this is not terribly elegant, but I don't have that much time.
-#define MAX_ITEM_ID 65535
-int inv_translate[MAX_ITEM_ID];
-
-void transform_char (struct mmo_charstatus *p)
-{
- int k;
- for (k = 0; k < MAX_INVENTORY; k++)
- p->inventory[k].nameid = inv_translate[p->inventory[k].nameid];
-}
-
-int mmo_char_convert ()
-{
- char line[965536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp, *ofp;
-
- ifp = stdin;
- ofp = stdout;
- while (fgets (line, 65535, ifp))
- {
- memset (&char_dat, 0, sizeof (struct mmo_charstatus));
- ret = mmo_char_fromstr (line, &char_dat);
- if (ret)
- {
- transform_char (&char_dat);
- mmo_char_tostr (line, &char_dat);
- fprintf (ofp, "%s\n", line);
- }
- }
- return 0;
-}
-
-#define PARSE_MODE_NEXTNUM 0
-#define PARSE_MODE_RANGE 1
-
-int init (char *source, char *dest)
-{
- int i;
- char *end_of_num;
- int dest_nr = strtol (dest, &end_of_num, 0);
- int range_start;
- int mode = PARSE_MODE_NEXTNUM;
-
- if (*end_of_num)
- {
- fprintf (stderr, "Invalid inventory ID: `%s'\n", dest);
- return 1;
- }
-
- /* init */
- for (i = 0; i < MAX_ITEM_ID; i++)
- inv_translate[i] = i;
-
- while (*source)
- {
- int nr = strtol (source, &end_of_num, 0);
- char sep;
-
- if (end_of_num == source)
- {
- fprintf (stderr, "Invalid source range description: `%s'\n",
- source);
- return 1;
- }
-
- switch (mode)
- {
- case PARSE_MODE_NEXTNUM:
- inv_translate[nr] = dest_nr;
- break;
- case PARSE_MODE_RANGE:
- for (i = range_start; i <= nr; i++)
- inv_translate[i] = dest_nr;
- break;
- default:
- fprintf (stderr, "Internal error at %d\n", __LINE__);
- return 1;
- };
-
- sep = *end_of_num++;
-
- switch (sep)
- {
- case '-':
- range_start = nr;
- mode = PARSE_MODE_RANGE;
- break;
- case ',':
- mode = PARSE_MODE_NEXTNUM;
- break;
- case 0:
- return 0;
- default:
- fprintf (stderr, "Invalid token in range spec: `%c'\n", sep);
- return 1;
- }
-
- source = end_of_num;
- }
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- if (argc < 3)
- {
- printf
- ("Usage: %s <inventory ID input range> <inventory ID output>\n",
- argv[0]);
- printf ("e.g., %s 501-555 701\n", argv[0]);
- exit (0);
- }
- if (init (argv[1], argv[2]))
- return 1;
-
- mmo_char_convert ();
-
- return 0;
-}
diff --git a/src/tool/itemsearch.cpp b/src/tool/itemsearch.cpp
deleted file mode 100644
index ab36a9d..0000000
--- a/src/tool/itemsearch.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-// This code is GPL, blah blah
-//
-// Writen for TheManaWorld by Chuck Miller, A.K.A. Kage
-
-#include <cstring>
-#include <iostream>
-#include <stdlib.h>
-#include <string>
-
-using namespace std;
-
-bool useStorage;
-int itemID;
-
-int itemCount(string itemData)
-{
- int counter = 0;
- int pointer = 0;
-
- do
- {
- int ending = itemData.find(',', pointer + 1);
- if (ending == string::npos)
- ending = itemData.size();
- if (counter == 1 && atoi(itemData.substr(pointer, ending - pointer).c_str()) != itemID)
- return 0;
- if (counter == 2)
- return atoi(itemData.substr(pointer, ending - pointer).c_str());
- counter++;
- } while ((pointer = itemData.find(',',pointer) + 1) != string::npos + 1);
-
- return 0;
-}
-
-int parseItemData(string &items)
-{
- int counter = 0;
- int pointer = 0;
-
- int total = 0;
-
- do
- {
- int ending = items.find(' ', pointer + 1);
- if (ending == string::npos)
- ending = items.size();
- total += itemCount(items.substr(pointer, ending - pointer));
- counter++;
- } while ((pointer = items.find(' ',pointer) + 1) != string::npos + 1);
-
- return total;
-}
-
-void parseLine(string &line)
-{
- int counter = 0;
- int pointer = 0;
-
- string AccountId, Name, Items;
-
- do
- {
- if (!useStorage)
- {
- if (counter == 1 || counter == 2 || counter == 15)
- {
- int ending = line.find('\t', pointer + 1);
- if (ending == string::npos)
- ending = line.size();
- switch (counter)
- {
- case 1:
- AccountId = line.substr(pointer,ending - pointer);
- break;
- case 2:
- Name = line.substr(pointer, ending - pointer);
- break;
- case 15:
- Items = line.substr(pointer, ending - pointer);
- }
- }
- }
- else if (useStorage)
- {
- int ending = line.find('\t', pointer + 1);
- if (ending == string::npos)
- ending = line.size();
-
- if (counter == 0)
- AccountId = line.substr(pointer,ending - pointer);
- else if (counter == 1)
- Items = line.substr(pointer,ending - pointer);
- }
-
- counter++;
- } while ((pointer = line.find('\t',pointer) + 1) != string::npos + 1 && counter < 16);
-
- if ((counter = parseItemData(Items)) > 0)
- cout << "Account = " << AccountId << "; Name = \"" << Name << "\"; Count = " << counter << "\n";
-}
-
-void parseInput()
-{
- string input;
- while (getline(cin, input))
- {
- parseLine(input);
- }
-}
-
-int main(int argc,char *argv[])
-{
- if(argc < 2)
- {
- printf("Usage: %s <item ID>\n", argv[0]);
- printf("Usage2: %s -s <item ID>\n", argv[0]);
- printf("e.g., %s 701\n", argv[0]);
- printf("Will return all users who own that item\n");
- printf("Option \"-s\" will expect storage files\n");
- exit(0);
- }
- if (strcmp(argv[1],"-s") == 0)
- {
- useStorage = true;
- itemID = atoi(argv[2]);
- }
- else
- {
- useStorage = false;
- itemID = atoi(argv[1]);
- }
- parseInput();
-
- return 0;
-}
-
diff --git a/src/tool/ladmin b/src/tool/ladmin
deleted file mode 100644
index d0c0be4..0000000
--- a/src/tool/ladmin
+++ /dev/null
@@ -1,3793 +0,0 @@
-#!/usr/bin/perl
-use POSIX;
-##########################################################################
-# EAthena login-server remote administration tool
-# New ladamin by [Yor]
-##########################################################################
-#-------------------------------INSTRUCTIONS------------------------------
-# Set the 4 variables below:
-# IP of the login server.
-# Port where the login-server listens incoming packets.
-# Password of administration (same of config_athena.conf).
-# Displayed language of the sofware (if not correct, english is used).
-# IMPORTANT:
-# Be sure that you authorize remote administration in login-server
-# (see login_athena.conf, 'admin_state' parameter)
-#-------------------------------------------------------------------------
-my($loginserverip) = "127.0.0.1"; # IP of login-server
-my($loginserverport) = 6900; # Port of login-server
-my($loginserveradminpassword) = "admin"; # Administration password
-my($connecttimeout) = 10; # Timeout of connection (in seconds)
-my($passenc) = 2; # Encoding type of the password
-my($defaultlanguage) = "E"; # Default language (F: Franais/E: English)
- # (if it's not 'F', default is English)
-
-#-------------------------------------------------------------------------
-# LIST of COMMANDs that you can type at the prompt:
-# To use these commands you can only type only the first letters.
-# You must type a minimum of letters (you can not type 'a',
-# because ladmin doesn't know if it's for 'aide' or for 'add')
-# <Example> q <= quit, li <= list, pass <= passwd, etc.
-#
-# Note: every time you must give a account_name, you can use "" or '' (spaces can be included)
-#
-# aide/help/?
-# Display the description of the commands
-# aide/help/? [command]
-# Display the description of the specified command
-#
-# add <account_name> <sex> <password>
-# Create an account with the default email (a@a.com).
-# Concerning the sex, only the first letter is used (F or M).
-# The e-mail is set to a@a.com (default e-mail). It's like to have no e-mail.
-# When the password is omitted, the input is done without displaying of the pressed keys.
-# <example> add testname Male testpass
-#
-# ban/banish yyyy/mm/dd hh:mm:ss <account name>
-# Changes the final date of a banishment of an account.
-# Same command of banset, except that account_name is at end
-#
-# banadd <account_name> <modifier>
-# Adds or substracts time from the final date of a banishment of an account.
-# Modifier is done as follows:
-# Adjustment value (-1, 1, +1, etc...)
-# Modified element:
-# a or y: year
-# m: month
-# j or d: day
-# h: hour
-# mn: minute
-# s: second
-# <example> banadd testname +1m-2mn1s-6y
-# this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
-# NOTE: If you modify the final date of a non-banished account,
-# you fix the final date to (actual time +- adjustments)
-#
-# banset <account_name> yyyy/mm/dd [hh:mm:ss]
-# Changes the final date of a banishment of an account.
-# Default time: 23:59:59
-# banset <account_name> 0
-# Set a non-banished account (0 = unbanished).
-#
-# block <account name>
-# Set state 5 (You have been blocked by the GM Team) to an account.
-# Same command of state <account_name> 5.
-#
-# check <account_name> <password>
-# Check the validity of a password for an account
-# NOTE: Server will never sends back a password.
-# It's the only method you have to know if a password is correct.
-# The other method is to have a ('physical') access to the accounts file.
-#
-# create <account_name> <sex> <email> <password>
-# Like the 'add' command, but with e-mail moreover.
-# <example> create testname Male my@mail.com testpass
-#
-# del <account name>
-# Remove an account.
-# This order requires confirmation. After confirmation, the account is deleted.
-#
-# email <account_name> <email>
-# Modify the e-mail of an account.
-#
-# getcount
-# Give the number of players online on all char-servers.
-#
-# gm <account_name> [GM_level]
-# Modify the GM level of an account.
-# Default value remove GM level (GM level = 0).
-# <example> gm testname 80
-#
-# id <account name>
-# Give the id of an account.
-#
-# info <account_id>
-# Display complete information of an account.
-#
-# kami <message>
-# Sends a broadcast message on all map-server (in yellow).
-# kamib <message>
-# Sends a broadcast message on all map-server (in blue).
-#
-# language <language>
-# Change the language of displaying.
-#
-# list/ls [start_id [end_id]]
-# Display a list of accounts.
-# 'start_id', 'end_id': indicate end and start identifiers.
-# Research by name is not possible with this command.
-# <example> list 10 9999999
-#
-# listBan/lsBan [start_id [end_id]]
-# Like list/ls, but only for accounts with state or banished
-#
-# listGM/lsGM [start_id [end_id]]
-# Like list/ls, but only for GM accounts
-#
-# listOK/lsOK [start_id [end_id]]
-# Like list/ls, but only for accounts without state and not banished
-#
-# memo <account_name> <memo>
-# Modify the memo of an account.
-# 'memo': it can have until 253 characters (with spaces or not).
-#
-# name <account_id>
-# Give the name of an account.
-#
-# passwd <account_name> <new_password>
-# Change the password of an account.
-# When new password is omitted, the input is done without displaying of the pressed keys.
-#
-# quit/end/exit
-# End of the program of administration
-#
-# reloadGM
-# Reload GM configuration file
-#
-# search <expression>
-# Seek accounts.
-# Displays the accounts whose names correspond.
-# search -r/-e/--expr/--regex <expression>
-# Seek accounts by regular expression.
-# Displays the accounts whose names correspond.
-#
-# sex <account_name> <sex>
-# Modify the sex of an account.
-# <example> sex testname Male
-#
-# state <account_name> <new_state> <error_message_#7>
-# Change the state of an account.
-# 'new_state': state is the state of the packet 0x006a + 1. The possibilities are:
-# 0 = Account ok 6 = Your Game's EXE file is not the latest version
-# 1 = Unregistered ID 7 = You are Prohibited to log in until %s
-# 2 = Incorrect Password 8 = Server is jammed due to over populated
-# 3 = This ID is expired 9 = No MSG
-# 4 = Rejected from Server 100 = This ID has been totally erased
-# 5 = You have been blocked by the GM Team
-# all other values are 'No MSG', then use state 9 please.
-# 'error_message_#7': message of the code error 6 = Your are Prohibited to log in until %s (packet 0x006a)
-#
-# timeadd <account_name> <modifier>
-# Adds or substracts time from the validity limit of an account.
-# Modifier is done as follows:
-# Adjustment value (-1, 1, +1, etc...)
-# Modified element:
-# a or y: year
-# m: month
-# j or d: day
-# h: hour
-# mn: minute
-# s: second
-# <example> timeadd testname +1m-2mn1s-6y
-# this example adds 1 month and 1 second, and substracts 2 minutes and 6 years at the same time.
-# NOTE: You can not modify a unlimited validity limit.
-# If you want modify it, you want probably create a limited validity limit.
-# So, at first, you must set the validity limit to a date/time.
-#
-# timeset <account_name> yyyy/mm/dd [hh:mm:ss]
-# Changes the validity limit of an account.
-# Default time: 23:59:59
-# timeset <account_name> 0
-# Gives an unlimited validity limit (0 = unlimited).
-#
-# unban/unbanish <account name>
-# Unban an account.
-# Same command of banset 0.
-#
-# unblock <account name>
-# Set state 0 (Account ok) to an account.
-# Same command of state <account_name> 0.
-#
-# version
-# Display the version of the login-server.
-#
-# who <account name>
-# Displays complete information of an account.
-#
-#-------------------------------------------------------------------------
-# Possibilities to execute ladmin in command line by usage of the software with a parameter:
-# ./ladmin --mode param1 ...
-#
-# --makesymlink -- Create the symbolic links for a use in shell
-# --add <account_name> <sex> <password> -- Create an account with the default email (or -a)
-# --ban yyyy/mm/dd hh:mm:ss <account_name> -- Change the final date of a banishment of an account (or -b)
-# --banadd <account_name> <modifier> -- Add or substract time from the final date of a banishment of an account (or - ba)
-# --banset <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the final date of a banishment of an account (or -bs)
-# --banset <account_name> 0 -- Unbanish an account (or -bs)
-# --block <account_name> -- Set state 5 to an account (or -bl)
-# --check <account_name> <password> -- Check the validity of a password for an account (or -check)
-# --create <account_name> <sex> <email> <password> -- Create an account with email (or -c)
-# --del <account_name> -- Remove an account (or -d)
-# --email <account_name> <email> -- Modify an email of an account (or -e)
-# --getcount -- Give the number of players online on all char-servers (or -g)
-# --gm <account_name> <GM_level> -- Change the GM level of an account (or -gm)
-# --id <account_name> -- Give the id of an account (or -i)
-# --info <account_id> -- Display complete information of an account (or -info)
-# --kami <message> -- Sends a broadcast message on all map-server (in yellow).
-# --kamib <message> -- Sends a broadcast message on all map-server (in blue).
-# --language <language> -- Change the language of displaying (-lang).
-# --list [First_id [Last_id]] -- Display a list of accounts (or -l)
-# --listBan [start_id [end_id]] -- Display a list of accounts with state or banished (or -lBan)
-# --listGM [First_id [Last_id]] -- Display a list of GM accounts (or -lGM)
-# --listOK [start_id [end_id]] -- Display a list of accounts without state and not banished (or -lOK)
-# --memo <account_name> <memo> -- Modify the memo of an account (or -e)
-# --name <account_id> -- Give the name of an account (or -n)
-# --passwd <account_name> <new_password> -- Change the password of an account (or -p)
-# --reloadGM -- Reload GM configuration file (or -r)
-# --search <expression> -- Seek accounts (or -s)
-# --search -e/-r/--expr/--regex <expression> -- Seek accounts by REGEX (or -s)
-# --sex <account_name> <sex> -- Change the sex of an account (or -sex)
-# --state <account_name> <new_state> <error_message_#7> -- Change the state of an account (or -t)
-# --timeadd <account_name> <modifier> -- Add or substract time from the validity limit of an account (or - ta)
-# --timeset <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the validify limit of an account (or -ts)
-# --timeset <account_name> 0 -- Give a unlimited validity limit (or -ts)
-# --unban/unbanish <account_name> -- Unban an account (or -uba)
-# --unblock <account_name> -- Set state 0 to an account (or -ubl)
-# --version -- Display the version of the login-server (or -v)
-# --who <account_name> -- Display complete information of an account (or -w)
-#
-# <example> ./ladmin --addaccount testname Male testpass
-#
-#-------------------------------------------------------------------------
-# Possibilities to execute ladmin with symbolic links in Shell
-# To create the symbolic links, execute ladmin with the '-- makesymlink' option.
-#
-# addaccount <account_name> <sex> <password> -- Create an account with the default email
-# banaccount yyyy/mm/dd hh:mm:ss <account_name> -- Change the final date of a banishment of an account
-# banaddaccount <account_name> <modifier> -- Add or substract time from the final date of a banishment of an account
-# bansetaccount <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the final date of a banishment of an account
-# bansetaccount <account_name> 0 -- Unbanish an account
-# blockaccount <account_name> -- Set state 5 (blocked by the GM Team) to an account
-# checkaccount <account_name> <password> -- Check the validity of a password for an account
-# createaccount <account_name> <sex> <email> <password> -- Create an account with email
-# delaccount <account_name> -- Remove an account
-# emailaccount <account_name> <email> -- Modify an email of an account
-# getcount -- Give the number of players online on all char-servers
-# gmaccount <account_name> <GM_level> -- Change the GM level of an account
-# idaccount <account_name> -- Give the id of an account
-# infoaccount <account_id> -- Display complete information of an account
-# kami <message> -- Sends a broadcast message on all map-server (in yellow).
-# kamib <message> -- Sends a broadcast message on all map-server (in blue).
-# ladminlanguage <language> -- Change the language of displaying.
-# listaccount [First_id [Last_id]] -- Display a list of accounts
-# listBanaccount [start_id [end_id]] -- Display a list of accounts with state or banished
-# listGMaccount [First_id [Last_id]] -- Display a list of GM accounts
-# listOKaccount [start_id [end_id]] -- Display a list of accounts without state and not banished
-# loginserverversion -- Display the version of the login-server
-# memoaccount <account_name> <memo> -- Modify the memo of an account
-# nameaccount <account_id> -- Give the name of an account
-# passwdaccount <account_name> <new_password> -- Change the password of an account
-# reloadGM -- Reload GM configuration file
-# searchaccount <expression> -- Seek accounts
-# searchaccount -e/-r/--expr/--regex <expression> -- Seek accounts by REGEX
-# sexaccount <account_name> <sex> -- Change the sex of an account (or -sex)
-# stateaccount <account_name> <new_state> <error_message_#7> -- Change the state of an account
-# timeaddaccount <account_name> <modifier> -- Add or substract time from the validity limit of an account
-# timesetaccount <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the validify limit of an account
-# timesetaccount <account_name> 0 -- Give a unlimited validity limit
-# unbanaccount <account_name> -- Unban an account
-# unblockaccount <account_name> -- Set state 0 (Account ok) to an account
-# whoaccount <account_name> -- Display complete information of an account
-# <exemple> ./addaccount testname Male testpass
-#
-#-------------------------------------------------------------------------
-# About the encoding:
-#
-# The Digest::MD5 module is necessary to use the encrypted password system.
-# When the software cannot found the Digest::MD5 module,
-# encoding is automatically disabled ($passenc=0), which allows
-# to use this program in any cases.
-#
-#-------------------------------------------------------------------------
-# How to use ladmin with UNIX:
-#
-# You excecute ladmin as a standard command.
-# <Example of preparation to have an access to ladmin>
-# $ mv ladmin ladmin_org
-# $ nkf -eLu ladmin_org > ladmin
-# $ chmod 700 ladmin
-# <Example to start directly ladmin>
-# $ perl ladmin
-#
-##########################################################################
-
-
-use strict;
-use IO::Socket;
-use Term::ReadLine;
-eval { use POSIX qw(:termios_h); };
-eval { use Digest::MD5 qw(md5); } if $passenc;
-$passenc = 0 if($@);
-
-my($ver) = "1.00";
-
-# Start of termios
-my($termios, $orgterml, $termlecho, $termlnoecho) = ();
-eval{
- $termios = POSIX::Termios->new();
- $termios->getattr(fileno(STDIN));
- $orgterml = $termios->getlflag();
- $termlecho = ECHO | ECHOK | ICANON;
- $termlnoecho = $orgterml & ~$termlecho;
-};
-
-# Modification of termios for the displaying of passwords (no displays for pressed keys)
-sub cbreak() {
- if ($termios) {
- $termios->setlflag($termlnoecho);
- $termios->setcc(VTIME, 1);
- $termios->setattr(fileno(STDIN), TCSANOW);
- }
-}
-# Modification of termios to return at the normal displaying (after input of the passwords)
-sub cooked() {
- if ($termios) {
- $termios->setlflag($orgterml);
- $termios->setcc(VTIME,0);
- $termios->setattr(fileno(STDIN),TCSANOW);
- }
-}
-END{ cooked() }
-
-if ($defaultlanguage eq "F") {
- print "Outil d'administration distance de eAthena V.$ver\n";
-} else {
- print "EAthena login-server administration tool V.$ver\n";
-}
-
-# Creation of the symbolic links for call of the program in line command of the shell
-if ($ARGV[0] eq "--makesymlink") {
- symlink $0, "loginserverversion";
- symlink $0, "addaccount";
- symlink $0, "banaccount";
- symlink $0, "banaddaccount";
- symlink $0, "bansetaccount";
- symlink $0, "blockaccount";
- symlink $0, "checkaccount";
- symlink $0, "createaccount";
- symlink $0, "delaccount";
- symlink $0, "emailaccount";
- symlink $0, "getcount";
- symlink $0, "gmaccount";
- symlink $0, "idaccount";
- symlink $0, "infoaccount";
- symlink $0, "kami";
- symlink $0, "kamib";
- symlink $0, "ladminlanguage";
- symlink $0, "listaccount";
- symlink $0, "listBanaccount";
- symlink $0, "listGMaccount";
- symlink $0, "listOKaccount";
- symlink $0, "memoaccount";
- symlink $0, "nameaccount";
- symlink $0, "passwdaccount";
- symlink $0, "reloadGM";
- symlink $0, "searchaccount";
- symlink $0, "sexaccount";
- symlink $0, "stateaccount";
- symlink $0, "timeaddaccount";
- symlink $0, "timesetaccount";
- symlink $0, "unbanaccount";
- symlink $0, "unblockaccount";
- symlink $0, "whoaccount";
- if ($defaultlanguage eq "F") {
- print "Liens symbliques crs.\n";
- } else {
- print "Symbolic links created.\n";
- }
- exit(0);
-}
-
-# Connection to the login-server
-my($so,$er) = ();
-eval{
- $so = IO::Socket::INET->new(
- PeerAddr=> $loginserverip,
- PeerPort=> $loginserverport,
-# Proto => "tcp",
- Timeout => $connecttimeout) or $er = 1;
-};
-if ($er || $@) {
- if ($defaultlanguage eq "F") {
- print "\nImpossible de se connecter au serveur de login [${loginserverip}:$loginserverport] !\n";
- } else {
- print "\nImpossible to have a connection with the login-server [${loginserverip}:$loginserverport] !\n";
- }
- print "$!\n"; # Displaying of the error
- exit(2);
-}
-
-# Sending the administration password
-if ($passenc == 0) {
- print $so pack("v2a24",0x7918,0,$loginserveradminpassword);
- $so->flush();
-} else {
- print $so pack("v",0x791a);
- $so->flush();
- my($buf) = readso(4);
- if (unpack("v",$buf) != 0x01dc) {
- if ($defaultlanguage eq "F") {
- print "Erreur au login (chec de la cration de la clef md5).\n";
- } else {
- print "Error at login (failure of the md5 key creation).\n";
- }
- }
- $buf = readso(unpack("x2v",$buf)-4);
- my($md5bin) = md5(($passenc == 1) ? $buf.$loginserveradminpassword : $loginserveradminpassword.$buf);
- print $so pack("v2a16",0x7918,$passenc,$md5bin);
- $so->flush();
-}
-
-# Waiting of the server reply
-my($buf) = readso(3);
-
-if (unpack("v",$buf) != 0x7919 || unpack("x2c",$buf) != 0) {
- if ($defaultlanguage eq "F") {
- print "Erreur de login:\n";
- print " - mot de passe incorrect,\n";
- print " - systme d'administration non activ, ou\n";
- print " - IP non autorise.\n";
- } else {
- print "Error at login:\n";
- print " - incorrect password,\n";
- print " - administration system not activated, or\n";
- print " - unauthorised IP.\n";
- }
- quit();
- exit(4);
-}
-
-if ($defaultlanguage eq "F") {
- print "Connexion tablie.\n";
-} else {
- print "Established connection.\n";
-}
-
-#-------------------------------------------------------------------------
-# Here are checked the command lines with arguments and symbolic links (no prompt)
-
-if ($0 =~ /addaccount$/ ||
- (($ARGV[0] eq "-a" || $ARGV[0] eq "--add") && ((shift @ARGV), 1))) {
- my($r) = addaccount($ARGV[0], $ARGV[1], $ARGV[2]);
- quit();
- exit($r);
-} elsif ($0 =~ /banaccount$/ || $0 =~ /banishaccount$/ ||
- (($ARGV[0] eq "-b" || $ARGV[0] eq "--ban" || $ARGV[0] eq "--banish") && ((shift @ARGV), 1))) {
- my($r) = bansetaccount($ARGV[1], $ARGV[2], $ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /banaddaccount$/ ||
- (($ARGV[0] eq "-ba" || $ARGV[0] eq "--banadd") && ((shift @ARGV), 1))) {
- my($r) = banaddaccount($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /bansetaccount$/ ||
- (($ARGV[0] eq "-bs" || $ARGV[0] eq "--banset") && ((shift @ARGV), 1))) {
- my($r) = bansetaccount($ARGV[0], $ARGV[1], $ARGV[2]);
- quit();
- exit($r);
-} elsif ($0 =~ /blockaccount$/ ||
- (($ARGV[0] eq "-bl" || $ARGV[0] eq "--block") && ((shift @ARGV), 1))) {
- my($r) = changestate($ARGV[0], 5, "");
- quit();
- exit($r);
-} elsif ($0 =~ /checkaccount$/ ||
- (($ARGV[0] eq "-check" || $ARGV[0] eq "--check") && ((shift @ARGV), 1))) {
- my($r) = checkaccount($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /createaccount$/ ||
- (($ARGV[0] eq "-c" || $ARGV[0] eq "--create") && ((shift @ARGV), 1))) {
- my($r) = createaccount($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]);
- quit();
- exit($r);
-} elsif ($0 =~ /delaccount$/ ||
- (($ARGV[0] eq "-d" || $ARGV[0] eq "--del") && ((shift @ARGV), 1))) {
- my($r) = delaccount($ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /emailaccount$/ ||
- (($ARGV[0] eq "-e" || $ARGV[0] eq "--email") && ((shift @ARGV), 1))) {
- my($r) = changeemail($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /getcount$/ ||
- (($ARGV[0] eq "-g" || $ARGV[0] eq "--getcount") && ((shift @ARGV), 1))) {
- my($r) = getlogincount();
- quit();
- exit($r);
-} elsif ($0 =~ /gmaccount$/ ||
- (($ARGV[0] eq "-gm" || $ARGV[0] eq "--gm") && ((shift @ARGV), 1))) {
- my($r) = changegmlevel($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /id$/ ||
- (($ARGV[0] eq "-i" || $ARGV[0] eq "--id") && ((shift @ARGV), 1))) {
- my($r) = idaccount($ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /infoaccount$/ ||
- (($ARGV[0] eq "-info" || $ARGV[0] eq "--info") && ((shift @ARGV), 1))) {
- my($r) = infoaccount($ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /kami$/ ||
- (($ARGV[0] eq "-kami" || $ARGV[0] eq "--kami") && ((shift @ARGV), 1))) {
- my($r) = sendbroadcast(0, $ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /kamib$/ ||
- (($ARGV[0] eq "-kamib" || $ARGV[0] eq "--kamib") && ((shift @ARGV), 1))) {
- my($r) = sendbroadcast(0x10, $ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /ladminlanguage$/ ||
- (($ARGV[0] eq "-lang" || $ARGV[0] eq "--language") && ((shift @ARGV), 1))) {
- my($r) = changelanguage($ARGV[0]);
- quit();
- exit($r);
-} elsif ($0 =~ /listaccount$/ ||
- (($ARGV[0] eq "-l" || $ARGV[0] eq "--list") && ((shift @ARGV), 1))) {
- my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 0); # 0: to list all
- quit();
- exit($r);
-} elsif ($0 =~ /listBanaccount$/ ||
- (($ARGV[0] eq "-lBan" || $ARGV[0] eq "--listBan") && ((shift @ARGV), 1))) {
- my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 3); # 3: to list only accounts with state or banished
- quit();
- exit($r);
-} elsif ($0 =~ /listGMaccount$/ ||
- (($ARGV[0] eq "-lGM" || $ARGV[0] eq "--listGM") && ((shift @ARGV), 1))) {
- my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 1); # 1: to list only GM
- quit();
- exit($r);
-} elsif ($0 =~ /listOKaccount$/ ||
- (($ARGV[0] eq "-lOK" || $ARGV[0] eq "--listOK") && ((shift @ARGV), 1))) {
- my($r) = listaccount(int($ARGV[0]), int($ARGV[1]), 4); # 4: to list only accounts without state and not banished
- quit();
- exit($r);
-} elsif ($0 =~ /loginserverversion$/ ||
- (($ARGV[0] eq "-v" || $ARGV[0] eq "--version") && ((shift @ARGV), 1))) {
- my($r) = checkloginversion();
- quit();
- exit($r);
-} elsif ($0 =~ /memoaccount$/ ||
- (($ARGV[0] eq "-m" || $ARGV[0] eq "--memo") && ((shift @ARGV), 1))) {
- my($r) = changememo($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /nameaccount$/ ||
- (($ARGV[0] eq "-n" || $ARGV[0] eq "--name") && ((shift @ARGV), 1))) {
- my($r) = nameaccount(int($ARGV[0]));
- quit();
- exit($r);
-} elsif ($0 =~ /passwdaccount$/ ||
- (($ARGV[0] eq "-p" || $ARGV[0] eq "--passwd") && ((shift @ARGV), 1))) {
- my($r) = changepasswd($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /reloadGM$/ ||
- (($ARGV[0] eq "-r" || $ARGV[0] eq "--reloadGM") && ((shift @ARGV), 1))) {
- my($r) = reloadGM();
- quit();
- exit($r);
-} elsif ($0 =~ /searchaccount$/ ||
- (($ARGV[0] eq "-s" || $ARGV[0] eq "--search") && ((shift @ARGV), 1))) {
- my($r) = searchaccount($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /sexaccount$/ ||
- (($ARGV[0] eq "-sex" || $ARGV[0] eq "--sex") && ((shift @ARGV), 1))) {
- my($r) = changesex($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /stateaccount$/ ||
- (($ARGV[0] eq "-t" || $ARGV[0] eq "--state") && ((shift @ARGV), 1))) {
- my($r) = changestate($ARGV[0], $ARGV[1], $ARGV[2]);
- quit();
- exit($r);
-} elsif ($0 =~ /timeaddaccount$/ ||
- (($ARGV[0] eq "-ta" || $ARGV[0] eq "--timeadd") && ((shift @ARGV), 1))) {
- my($r) = timeaddaccount($ARGV[0], $ARGV[1]);
- quit();
- exit($r);
-} elsif ($0 =~ /timesetaccount$/ ||
- (($ARGV[0] eq "-ts" || $ARGV[0] eq "--timeset") && ((shift @ARGV), 1))) {
- my($r) = timesetaccount($ARGV[0], $ARGV[1], $ARGV[2]);
- quit();
- exit($r);
-} elsif ($0 =~ /unbanaccount$/ || $0 =~ /unbanishaccount$/ ||
- (($ARGV[0] eq "-uba" || $ARGV[0] eq "--unban" || $ARGV[0] eq "--unbanish") && ((shift @ARGV), 1))) {
- my($r) = bansetaccount($ARGV[0], 0, "");
- quit();
- exit($r);
-} elsif ($0 =~ /unblockaccount$/ ||
- (($ARGV[0] eq "-ubl" || $ARGV[0] eq "--unblock") && ((shift @ARGV), 1))) {
- my($r) = changestate($ARGV[0], 0, "");
- quit();
- exit($r);
-} elsif ($0 =~ /whoaccount$/ ||
- (($ARGV[0] eq "-w" || $ARGV[0] eq "--who") && ((shift @ARGV), 1))) {
- my($r) = whoaccount($ARGV[0]);
- quit();
- exit($r);
-}
-
-#-------------------------------------------------------------------------
-if ($defaultlanguage eq "F") {
- print "Lecture de la version du serveur de login...\n";
-} else {
- print "Reading of the version of the login-server...\n";
-}
-checkloginversion();
-
-# Set the prompt line
-my($term) = new Term::ReadLine "ladmin";
-
-# Here begin the infinite loop to read prompts
-while(1) {
- # Displaying of the prompt
- print "\n";
- if ($defaultlanguage eq "F") {
- printf "\033[32mPour afficher les commandes, tapez 'Entre'.\033[0m\n";
- } else {
- printf "\033[32mTo list the commands, type 'enter'.\033[0m\n";
- }
- my($cmd) = $term->readline("ladmin> ");
- # split and recovery of the input
- chomp $cmd; # remove cariage return
- $cmd =~ s/\x1b\[\d*\w//g; # remove (esc)[(number)(1alpha) = screen control sequence
- $cmd =~ s/[\x00-\x1f]//g; # remove control char
- my($command, $parameters) = split /\s+/,$cmd,2; # extract command and parameters
- $command = lc($command); # command in lowercase
- my(@paramlist) = split /\s+/,$parameters; # get list of parameters
-
- if ($command eq "?" || $command eq "") {
- $command = "aide" if ($defaultlanguage eq "F");
- $command = "help" if ($defaultlanguage ne "F");
- }
-
- # Analyse of the command
- eval {
-# help
- if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
- displayhelp("aide", $paramlist[0]);
- } elsif ("help" =~ /^\Q$command/) {
- displayhelp("help", $paramlist[0]);
-
-# general commands
- } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(.*)/)) {
- addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> <sex> <password>
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- addaccount($paramlist[0], $paramlist[1], ""); # <account_name> <sex> <password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(.*)/)) {
- addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> <sex> <password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- addaccount($paramlist[0], $paramlist[1], ""); # <account_name> <sex> <password>
- } else {
- @paramlist = split /\s+/,$parameters;
- addaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> <sex> <password>
- }
-
- } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) {
- if (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+"(.*)"/)) { # yyyy/mm/dd hh:mm:ss <account_name>
- bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^(\S+)\s+(\S+)\s+'(.*)'/)) { # yyyy/mm/dd hh:mm:ss <account_name>
- bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } else {
- @paramlist = split /\s+/,$parameters,3; # yyyy/mm/dd hh:mm:ss <account_name>
- bansetaccount($paramlist[2], $paramlist[0], $paramlist[1]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- }
-
- } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- banaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- banaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
- } else {
- @paramlist = split /\s+/,$parameters;
- banaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
- }
-
- } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) {
- bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) {
- bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- bansetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } else {
- @paramlist = split /\s+/,$parameters;
- bansetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- }
-
- } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) {
- if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- changestate($paramlist[0], 5, ""); # <account_name> <new_state> <error_message_#7>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- changestate($paramlist[0], 5, ""); # <account_name> <new_state> <error_message_#7>
- } else {
- @paramlist = split /\s+/,$parameters,1;
- changestate($paramlist[0], 5, ""); # <account_name> <new_state> <error_message_#7>
- }
-
- } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) {
- checkaccount($paramlist[0], $paramlist[1]); # <account_name> <password>
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- checkaccount($paramlist[0], ""); # <account_name> <password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) {
- checkaccount($paramlist[0], $paramlist[1]); # <account_name> <password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- checkaccount($paramlist[0], ""); # <account_name> <password>
- } else {
- @paramlist = split /\s+/,$parameters;
- checkaccount($paramlist[0], $paramlist[1]); # <account_name> <password>
- }
-
- } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)\s+(.*)/)) {
- createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # <account_name> <sex> <email> <password>
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) {
- createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # <account_name> <sex> <email> <password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)\s+(.*)/)) {
- createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # <account_name> <sex> <email> <password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) {
- createaccount($paramlist[0], $paramlist[1], $paramlist[2], ""); # <account_name> <sex> <email> <password>
- } else {
- @paramlist = split /\s+/,$parameters;
- createaccount($paramlist[0], $paramlist[1], $paramlist[2], $paramlist[3]); # <account_name> <sex> <email> <password>
- }
-
- } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) {
- if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- delaccount($paramlist[0]); # <account_name>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- delaccount($paramlist[0]); # <account_name>
- } else {
- @paramlist = split /\s+/,$parameters,1;
- delaccount($paramlist[0]); # <account_name>
- }
-
- } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- changeemail($paramlist[0], $paramlist[1]); # <account_name> <email>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- changeemail($paramlist[0], $paramlist[1]); # <account_name> <email>
- } else {
- @paramlist = split /\s+/,$parameters;
- changeemail($paramlist[0], $paramlist[1]); # <account_name> <email>
- }
-
- } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
- getlogincount();
-
- } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- changegmlevel($paramlist[0], int($paramlist[1])); # <account_name> <GM_level>
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- changegmlevel($paramlist[0], 0); # <account_name> <GM_level>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- changegmlevel($paramlist[0], int($paramlist[1])); # <account_name> <GM_level>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- changegmlevel($paramlist[0], 0); # <account_name> <GM_level>
- } else {
- @paramlist = split /\s+/,$parameters;
- changegmlevel($paramlist[0], int($paramlist[1])); # <account_name> <GM_level>
- }
-
- } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
- if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- idaccount($paramlist[0]); # <account_name>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- idaccount($paramlist[0]); # <account_name>
- } else {
- @paramlist = split /\s+/,$parameters,1;
- idaccount($paramlist[0]); # <account_name>
- }
-
- } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
- infoaccount(int($paramlist[0])); # <account_id>
-
- } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'?
- @paramlist = split /\s+/,$parameters,1;
- sendbroadcast(0, $paramlist[0]); # <type> <message>
-
- } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'?
- @paramlist = split /\s+/,$parameters,1;
- sendbroadcast(0x10, $paramlist[0]); # <type> <message>
-
- } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'?
- changelanguage($paramlist[0]); # <language>
-
- } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'?
- listaccount(int($paramlist[0]), int($paramlist[1]), 0); # [start_id [end_id]] 0: to list all
-
- } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'?
- listaccount(int($paramlist[0]), int($paramlist[1]), 3); # [start_id [end_id]] 3: to list only accounts with state or banished
-
- } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'?
- listaccount(int($paramlist[0]), int($paramlist[1]), 1); # [start_id [end_id]] 1: to list only GM
-
- } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'?
- listaccount(int($paramlist[0]), int($paramlist[1]), 4); # [start_id [end_id]] 4: to list only accounts without state and not banished
-
- } elsif ("memo" =~ /^\Q$command/) {
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) {
- changememo($paramlist[0], $paramlist[1]); # <account_name> <memo>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) {
- changememo($paramlist[0], $paramlist[1]); # <account_name> <memo>
- } else {
- @paramlist = split /\s+/,$parameters,2;
- changememo($paramlist[0], $paramlist[1]); # <account_name> <memo>
- }
-
- } elsif ("name" =~ /^\Q$command/) {
- nameaccount(int($paramlist[0])); # <account_id>
-
- } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) {
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(.*)/)) {
- changepasswd($paramlist[0], $paramlist[1]); # <account_name> <new_password>
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- changepasswd($paramlist[0], ""); # <account_name> <new_password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(.*)/)) {
- changepasswd($paramlist[0], $paramlist[1]); # <account_name> <new_password>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- changepasswd($paramlist[0], ""); # <account_name> <new_password>
- } else {
- @paramlist = split /\s+/,$parameters,2;
- changepasswd($paramlist[0], $paramlist[1]); # <account_name> <new_password>
- }
-
- } elsif ("reloadgm" =~ /^\Q$command/) {
- reloadGM();
-
- } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
- $command ne "se") { # check 2 letters command: 'search' or 'sex'?
- if (@paramlist = ($parameters =~ m/^(-{1,2}[re]\S*)\s+(.*)/)) {
- searchaccount($paramlist[0], $paramlist[1]); # -r/-e/--expr/--regex <expression> | <expression>
- } else {
- @paramlist = split /\s+/,$parameters,1;
- searchaccount($paramlist[0], ""); # -r/-e/--expr/--regex <expression> | <expression>
- }
-
- } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
- $command ne "se") { # check 2 letters command: 'search' or 'sex'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- changesex($paramlist[0], $paramlist[1]); # <account_name> <sex>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- changesex($paramlist[0], $paramlist[1]); # <account_name> <sex>
- } else {
- @paramlist = split /\s+/,$parameters;
- changesex($paramlist[0], $paramlist[1]); # <account_name> <sex>
- }
-
- } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)\s+(.*)/)) {
- changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # <account_name> <new_state> <error_message_#7>
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\d+)/)) {
- changestate($paramlist[0], int($paramlist[1]), ""); # <account_name> <new_state> <error_message_#7>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)\s+(.*)/)) {
- changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # <account_name> <new_state> <error_message_#7>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\d+)/)) {
- changestate($paramlist[0], int($paramlist[1]), ""); # <account_name> <new_state> <error_message_#7>
- } else {
- @paramlist = split /\s+/,$parameters,3;
- changestate($paramlist[0], int($paramlist[1]), $paramlist[2]); # <account_name> <new_state> <error_message_#7>
- }
-
- } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- timeaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- timeaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
- } else {
- @paramlist = split /\s+/,$parameters;
- timeaddaccount($paramlist[0], $paramlist[1]); # <account_name> <modifier>
- }
-
- } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
- if (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)\s+(\S+)/)) {
- timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^"(.*)"\s+(\S+)/)) {
- timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)\s+(\S+)/)) {
- timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'\s+(\S+)/)) {
- timesetaccount($paramlist[0], $paramlist[1], "23:59:59"); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } else {
- @paramlist = split /\s+/,$parameters;
- timesetaccount($paramlist[0], $paramlist[1], $paramlist[2]); # <account_name> yyyy/mm/dd [hh:mm:ss]
- }
-
- } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) {
- if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- bansetaccount($paramlist[0], 0, ""); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- bansetaccount($paramlist[0], 0, ""); # <account_name> yyyy/mm/dd [hh:mm:ss]
- } else {
- @paramlist = split /\s+/,$parameters,1;
- bansetaccount($paramlist[0], 0, ""); # <account_name> yyyy/mm/dd [hh:mm:ss]
- }
-
- } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) {
- if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- changestate($paramlist[0], 0, ""); # <account_name> <new_state> <error_message_#7>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- changestate($paramlist[0], 0, ""); # <account_name> <new_state> <error_message_#7>
- } else {
- @paramlist = split /\s+/,$parameters,1;
- changestate($paramlist[0], 0, ""); # <account_name> <new_state> <error_message_#7>
- }
-
- } elsif ("version" =~ /^\Q$command/) {
- checkloginversion();
-
- } elsif ("who" =~ /^\Q$command/) {
- if (@paramlist = ($parameters =~ m/^"(.*)"/)) {
- whoaccount($paramlist[0]); # <account_name>
- } elsif (@paramlist = ($parameters =~ m/^'(.*)'/)) {
- whoaccount($paramlist[0]); # <account_name>
- } else {
- @paramlist = split /\s+/,$parameters,1;
- whoaccount($paramlist[0]); # <account_name>
- }
-
-# quit
- } elsif ("quit" =~ /^\Q$command/ ||
- (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?
- last;
-
-# unknown command
- } elsif ($command) {
- if ($defaultlanguage eq "F") {
- print "Commande inconnue [".$command."]\n";
- } else {
- print "Unknown command [".$command."]\n";
- }
- }
-# $term->addhistory($cmd) if $command;
- };
- if ($@) {
- if ($defaultlanguage eq "F") {
- print "Erreur [".$command."]\n$@";
- } else {
- print "Error [".$command."]\n$@";
- }
- }
-};
-
-# End of the software
-quit();
-
-if ($defaultlanguage eq "F") {
- print "Au revoir.\n";
-} else {
- print "Bye.\n";
-}
-exit(0);
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Displaying of the version of the login-server
-sub checkloginversion() {
- print $so pack("v",30000); # 0x7530
- $so->flush();
- $buf = readso(10);
- # Analyse du Packet
- my($ret, $maver, $miver, $rev, $dev, $mod, $type, $mdver) = unpack("vc6v", $buf);
- if ($ret != 30001) { #0x7531
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- exit(6);
- }
-
- print " Login-Server [$loginserverip:$loginserverport]\n";
- printf " eAthena version %s-%d.%d", ("stable", "dev")[$dev], $maver, $miver;
- printf " revision %d", $rev if $rev;
- printf "%s%d.\n", ("", "-mod")[$mod], $mdver;
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Displaying of the help
-sub displayhelp() {
- my($help, $receivedcommand) = @_;
-
- my($command) = lc($receivedcommand); # command in lowercase
-
- if ($command eq "") {
- $command = "not a command"; # any value that is not a command
- }
-
- if ($command eq "?") {
- $command = "aide" if ($defaultlanguage eq "F");
- $command = "help" if ($defaultlanguage ne "F");
- }
-
- if ($help eq "aide") {
- if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
- printf "aide/help/?\n";
- printf " Affiche la description des commandes\n";
- printf "aide/help/? [commande]\n";
- printf " Affiche la description de la commande specifie\n";
- } elsif ("help" =~ /^\Q$command/) {
- printf "aide/help/?\n";
- printf " Display the description of the commands\n";
- printf "aide/help/? [command]\n";
- printf " Display the description of the specified command\n";
- } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
- printf "add <nomcompte> <sexe> <motdepasse>\n";
- printf " Cre un compte avec l'email par dfaut (a\@a.com).\n";
- printf " Concernant le sexe, seule la premire lettre compte (F ou M).\n";
- printf " L'e-mail est a\@a.com (e-mail par dfaut). C'est comme n'avoir aucun e-mail.\n";
- printf " Lorsque motdepasse est omis, la saisie se fait sans que la frappe se voit.\n";
- printf " <exemple> add testname Male testpass\n";
- } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) {
- printf "ban/banish aaaa/mm/jj hh:mm:ss <nomcompte>\n";
- printf " Change la date de fin de bannissement d'un compte.\n";
- printf " La diffrence avec banset est la position du nom du compte.\n";
- } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
- printf "banadd <nomcompte> <Modificateur>\n";
- printf " Ajoute ou soustrait du temps la date de banissement d'un compte.\n";
- printf " Les modificateurs sont construits comme suit:\n";
- printf " Valeur d'ajustement (-1, 1, +1, etc...)\n";
- printf " Elment modifi:\n";
- printf " a ou y: anne\n";
- printf " m: mois\n";
- printf " j ou d: jour\n";
- printf " h: heure\n";
- printf " mn: minute\n";
- printf " s: seconde\n";
- printf " <exemple> banadd testname +1m-2mn1s-6a\n";
- printf " Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n";
- printf " et 6 ans dans le mme temps.\n";
- printf "NOTE: Si vous modifez la date de banissement d'un compte non bani,\n";
- printf " vous indiquez comme date (le moment actuel +- les ajustements)\n";
- } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
- printf "banset <nomcompte> aaaa/mm/jj [hh:mm:ss]\n";
- printf " Change la date de fin de bannissement d'un compte.\n";
- printf " Heure par dfaut: 23:59:59\n";
- printf "banset <nomcompte> 0\n";
- printf " Dbanni un compte (0 = de-banni).\n";
- } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) {
- printf "block <nom compte>\n";
- printf " Place le status d'un compte 5 (You have been blocked by the GM Team).\n";
- printf " La commande est l'quivalent de state <nom_compte> 5.\n";
- } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
- printf "check <nomcompte> <motdepasse>\n";
- printf " Vrifie la validit d'un mot de passe pour un compte\n";
- printf " NOTE: Le serveur n'enverra jamais un mot de passe.\n";
- printf " C'est la seule mthode que vous possdez pour savoir\n";
- printf " si un mot de passe est le bon. L'autre mthode est\n";
- printf " d'avoir un accs ('physique') au fichier des comptes.\n";
- } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
- printf "create <nomcompte> <sexe> <email> <motdepasse>\n";
- printf " Comme la commande add, mais avec l'e-mail en plus.\n";
- printf " <exemple> create testname Male mon\@mail.com testpass\n";
- } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) {
- printf "del <nomcompte>\n";
- printf " Supprime un compte.\n";
- printf " La commande demande confirmation. Aprs confirmation, le compte est dtruit.\n";
- } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'?
- printf "email <nomcompte> <email>\n";
- printf " Modifie l'e-mail d'un compte.\n";
- } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
- printf "getcount\n";
- printf " Donne le nombre de joueurs en ligne par serveur de char.\n";
- } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
- printf "gm <nomcompte> [Niveau_GM]\n";
- printf " Modifie le niveau de GM d'un compte.\n";
- printf " Valeur par dfaut: 0 (suppression du niveau de GM).\n";
- printf " <exemple> gm nomtest 80\n";
- } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
- printf "id <nomcompte>\n";
- printf " Donne l'id d'un compte.\n";
- } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
- printf "info <idcompte>\n";
- printf " Affiche les informations sur un compte.\n";
- } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'?
- printf "kami <message>\n";
- printf " Envoi un message gnral sur tous les serveurs de map (en jaune).\n";
- } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'?
- printf "kamib <message>\n";
- printf " Envoi un message gnral sur tous les serveurs de map (en bleu).\n";
- } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'?
- printf("language <langue>\n");
- printf(" Change la langue d'affichage.\n");
- printf(" Langues possibles: 'Franais' ou 'English'.\n");
- } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'?
- printf "list/ls [Premier_id [Dernier_id]]\n";
- printf " Affiche une liste de comptes.\n";
- printf " 'Premier_id', 'Dernier_id': indique les identifiants de dpart et de fin.\n";
- printf " La recherche par nom n'est pas possible avec cette commande.\n";
- printf " <example> list 10 9999999\n";
- } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'?
- printf "listBan/lsBan [Premier_id [Dernier_id]]\n";
- printf " Comme list/ls, mais seulement pour les comptes GM avec un statut ou bannis.\n";
- } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'?
- printf "listGM/lsGM [Premier_id [Dernier_id]]\n";
- printf " Comme list/ls, mais seulement pour les comptes GM.\n";
- } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'?
- printf "listOK/lsOK [Premier_id [Dernier_id]]\n";
- printf " Comme list/ls, mais seulement pour les comptes sans statut et non bannis.\n";
- } elsif ("memo" =~ /^\Q$command/) {
- printf "memo <nomcompte> <memo>\n";
- printf " Modifie le mmo d'un compte.\n";
- printf " 'memo': Il peut avoir jusqu' 253 caractres (avec des espaces ou non).\n";
- } elsif ("name" =~ /^\Q$command/) {
- printf "name <idcompte>\n";
- printf " Donne le nom d'un compte.\n";
- } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) {
- printf "passwd <nomcompte> <nouveaumotdepasse>\n";
- printf " Change le mot de passe d'un compte.\n";
- printf " Lorsque nouveaumotdepasse est omis,\n";
- printf " la saisie se fait sans que la frappe ne se voit.\n";
- } elsif ("reloadgm" =~ /^\Q$command/) {
- printf "reloadGM\n";
- printf " Reload GM configuration file\n";
- } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
- $command ne "se") { # check 2 letters command: 'search' or 'sex'?
- printf "search <expression>\n";
- printf " Cherche des comptes.\n";
- printf " Affiche les comptes dont les noms correspondent.\n";
- printf "search -r/-e/--expr/--regex <expression>\n";
- printf " Cherche des comptes par expression regulire.\n";
- printf " Affiche les comptes dont les noms correspondent.\n";
- } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
- $command ne "se") { # check 2 letters command: 'search' or 'sex'?
- printf "sex <nomcompte> <sexe>\n";
- printf " Modifie le sexe d'un compte.\n";
- printf " <exemple> sex testname Male\n";
- } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'?
- printf "state <nomcompte> <nouveaustatut> <message_erreur_7>\n";
- printf " Change le statut d'un compte.\n";
- printf " 'nouveaustatut': Le statut est le mme que celui du packet 0x006a + 1.\n";
- printf " les possibilits sont:\n";
- printf " 0 = Compte ok\n";
- printf " 1 = Unregistered ID\n";
- printf " 2 = Incorrect Password\n";
- printf " 3 = This ID is expired\n";
- printf " 4 = Rejected from Server\n";
- printf " 5 = You have been blocked by the GM Team\n";
- printf " 6 = Your Game's EXE file is not the latest version\n";
- printf " 7 = You are Prohibited to log in until...\n";
- printf " 8 = Server is jammed due to over populated\n";
- printf " 9 = No MSG\n";
- printf " 100 = This ID has been totally erased\n";
- printf " all other values are 'No MSG', then use state 9 please.\n";
- printf " 'message_erreur_7': message du code erreur 6 =\n";
- printf " = Your are Prohibited to log in until... (packet 0x006a)\n";
- } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
- printf "timeadd <nomcompte> <modificateur>\n";
- printf " Ajoute/soustrait du temps la limite de validit d'un compte.\n";
- printf " Le modificateur est compos comme suit:\n";
- printf " Valeur modificatrice (-1, 1, +1, etc...)\n";
- printf " Elment modifi:\n";
- printf " a ou y: anne\n";
- printf " m: mois\n";
- printf " j ou d: jour\n";
- printf " h: heure\n";
- printf " mn: minute\n";
- printf " s: seconde\n";
- printf " <exemple> timeadd testname +1m-2mn1s-6a\n";
- printf " Cette exemple ajoute 1 mois et une seconde, et soustrait 2 minutes\n";
- printf " et 6 ans dans le mme temps.\n";
- printf "NOTE: Vous ne pouvez pas modifier une limite de validit illimite. Si vous\n";
- printf " dsirez le faire, c'est que vous voulez probablement crer un limite de\n";
- printf " validit limite. Donc, en premier, fix une limite de valitid.\n";
- } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
- printf "timeset <nomcompte> aaaa/mm/jj [hh:mm:ss]\n";
- printf " Change la limite de validit d'un compte.\n";
- printf " Heure par dfaut: 23:59:59\n";
- printf "timeset <nomcompte> 0\n";
- printf " Donne une limite de validit illimite (0 = illimite).\n";
- } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) {
- printf "unban/unbanish <nom compte>\n";
- printf " Ote le banissement d'un compte.\n";
- printf " La commande est l'quivalent de banset <nom_compte> 0.\n";
- } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) {
- printf "unblock <nom compte>\n";
- printf " Place le status d'un compte 0 (Compte ok).\n";
- printf " La commande est l'quivalent de state <nom_compte> 0.\n";
- } elsif ("version" =~ /^\Q$command/) {
- printf "version\n";
- printf " Affiche la version du login-serveur.\n";
- } elsif ("who" =~ /^\Q$command/) {
- printf "who <nomcompte>\n";
- printf " Affiche les informations sur un compte.\n";
- } elsif ("quit" =~ /^\Q$command/ ||
- (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n";
- printf "quit/end/exit\n";
- printf " Fin du programme d'administration.\n";
- } else {
- if ($receivedcommand ne "") {
- printf "Commande inconnue [%s] pour l'aide. Affichage de toutes les commandes.\n", $receivedcommand;
- }
- print << "ENDOFAIDE";
- aide/help/? -- Affiche cet aide
- aide/help/? [commande] -- Affiche l'aide de la commande
- add <nomcompte> <sexe> <motdepasse> -- Cre un compte (sans email)
- ban/banish aaaa/mm/jj hh:mm:ss <nomcompte>-- Change la date finale de banismnt
- banadd/ba <nomcompte> <modificateur> -- Ajout/soustrait du temps la
- exemple: ba moncompte +1m-2mn1s-2y date finale de banissement
- banset/bs <nomcompte> aaaa/mm/jj [hh:mm:ss] -- Change la date fin de banisemnt
- banset/bs <nomcompte> 0 -- D-banis un compte.
- block <nom compte> -- Mets le status d'un compte 5 (blocked by the GM Team)
- check <nomcompte> <motdepasse> -- Vrifie un mot de passe d'un compte
- create <nomcompte> <sexe> <email> <motdepasse> -- Cre un compte (avec email)
- del <nomcompte> -- Supprime un compte
- email <nomcompte> <email> -- Modifie l'e-mail d'un compte
- getcount -- Donne le nb de joueurs en ligne
- gm <nomcompte> [Niveau_GM] -- Modifie le niveau de GM d'un compte
- id <nomcompte> -- Donne l'id d'un compte
- info <idcompte> -- Affiche les infos sur un compte
- kami <message> -- Envoi un message gnral (en jaune)
- kamib <message> -- Envoi un message gnral (en bleu)
- language <langue> -- Change la langue d'affichage.
- list/ls [Premier_id [Dernier_id] ] -- Affiche une liste de comptes
- listBan/lsBan [Premier_id [Dernier_id] ]-- Affiche une liste de comptes
- avec un statut ou bannis
- listGM/lsGM [Premier_id [Dernier_id] ] -- Affiche une liste de comptes GM
- listOK/lsOK [Premier_id [Dernier_id] ] -- Affiche une liste de comptes
- sans status et non bannis
- memo <nomcompte> <memo> -- Modifie le memo d'un compte
- name <idcompte> -- Donne le nom d'un compte
- passwd <nomcompte> <nouveaumotdepasse> -- Change le mot de passe d'un compte
- quit/end/exit -- Fin du programme d'administation
- reloadGM -- Recharger le fichier de config des GM
- search <expression> -- Cherche des comptes
- search -e/-r/--expr/--regex <expression> -- Cherche des comptes par REGEX
- sex <nomcompte> <sexe> -- Modifie le sexe d'un compte
- state <nomcompte> <nouveaustatut> <messageerr7> -- Change le statut d'1 compte
- timeadd/ta <nomcompte> <modificateur> -- Ajout/soustrait du temps la
- exemple: ta moncompte +1m-2mn1s-2y limite de validit
- timeset/ts <nomcompte> aaaa/mm/jj [hh:mm:ss] -- Change la limite de validit
- timeset/ts <nomcompte> 0 -- limite de validit = illimite
- unban/unbanish <nom compte> -- Ote le banissement d'un compte
- unblock <nom compte> -- Mets le status d'un compte 0 (Compte ok)
- version -- Donne la version du login-serveur
- who <nomcompte> -- Affiche les infos sur un compte
-ENDOFAIDE
- printf(" Note: Pour les noms de compte avec des espaces, tapez \"<nom compte>\" (ou ').\n");
- }
- } else {
- if ("aide" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
- printf "aide/help/?\n";
- printf " Display the description of the commands\n";
- printf "aide/help/? [command]\n";
- printf " Display the description of the specified command\n";
- } elsif ("help" =~ /^\Q$command/) {
- printf "aide/help/?\n";
- printf " Display the description of the commands\n";
- printf "aide/help/? [command]\n";
- printf " Display the description of the specified command\n";
- } elsif ("add" =~ /^\Q$command/ && $command ne "a") { # check 1 letter command: 'aide' or 'add'?
- printf "add <account_name> <sex> <password>\n";
- printf " Create an account with the default email (a\@a.com).\n";
- printf " Concerning the sex, only the first letter is used (F or M).\n";
- printf " The e-mail is set to a\@a.com (default e-mail). It's like to have no e-mail.\n";
- printf " When the password is omitted,\n";
- printf " the input is done without displaying of the pressed keys.\n";
- printf " <example> add testname Male testpass\n";
- } elsif ($command eq "ban" || ("banish" =~ /^\Q$command/ && length($command) >= 4)) {
- printf "ban/banish yyyy/mm/dd hh:mm:ss <account_name>\n";
- printf " Changes the final date of a banishment of an account.\n";
- printf " The difference with banset is the position of the account name.\n";
- } elsif (("banadd" =~ /^\Q$command/ || $command eq "ba") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
- printf "banadd <account_name> <modifier>\n";
- printf " Adds or substracts time from the final date of a banishment of an account.\n";
- printf " Modifier is done as follows:\n";
- printf " Adjustment value (-1, 1, +1, etc...)\n";
- printf " Modified element:\n";
- printf " a or y: year\n";
- printf " m: month\n";
- printf " j or d: day\n";
- printf " h: hour\n";
- printf " mn: minute\n";
- printf " s: second\n";
- printf " <example> banadd testname +1m-2mn1s-6y\n";
- printf " this example adds 1 month and 1 second, and substracts 2 minutes\n";
- printf " and 6 years at the same time.\n";
- printf "NOTE: If you modify the final date of a non-banished account,\n";
- printf " you fix the final date to (actual time +- adjustments)\n";
- } elsif (("banset" =~ /^\Q$command/ || $command eq "bs") && $command ne "b") { # check 1 letter command: 'ba' or 'bs'?
- printf "banset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
- printf " Changes the final date of a banishment of an account.\n";
- printf " Default time: 23:59:59\n";
- printf "banset <account_name> 0\n";
- printf " Set a non-banished account (0 = unbanished).\n";
- } elsif ("block" =~ /^\Q$command/ && length($command) >= 2) {
- printf "block <account name>\n";
- printf " Set state 5 (You have been blocked by the GM Team) to an account.\n";
- printf " Same command of state <account_name> 5.\n";
- } elsif ("check" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
- printf "check <account_name> <password>\n";
- printf " Check the validity of a password for an account.\n";
- printf " NOTE: Server will never sends back a password.\n";
- printf " It's the only method you have to know if a password is correct.\n";
- printf " The other method is to have a ('physical') access to the accounts file.\n";
- } elsif ("create" =~ /^\Q$command/ && $command ne "c") { # check 1 letter command: 'check' or 'create'?
- printf "create <account_name> <sex> <email> <password>\n";
- printf " Like the 'add' command, but with e-mail moreover.\n";
- printf " <example> create testname Male my\@mail.com testpass\n";
- } elsif ("del" =~ /^\Q$command/ || "delete" =~ /^\Q$command/) {
- printf "del <account_name>\n";
- printf " Remove an account.\n";
- printf " This order requires confirmation. After confirmation, the account is deleted.\n";
- } elsif ("email" =~ /^\Q$command/ && $command ne "e") { # check 1 letter command: 'email', 'end' or 'exit'?
- printf "email <account_name> <email>\n";
- printf " Modify the e-mail of an account.\n";
- } elsif ("getcount" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
- printf "getcount\n";
- printf " Give the number of players online on all char-servers.\n";
- } elsif ("gm" =~ /^\Q$command/ && $command ne "g") { # check 1 letter command: 'getcount' or 'gm'?
- printf "gm <account_name> [GM_level]\n";
- printf " Modify the GM level of an account.\n";
- printf " Default value remove GM level (GM level = 0).\n";
- printf " <example> gm testname 80\n";
- } elsif ("id" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
- printf "id <account_name>\n";
- printf " Give the id of an account.\n";
- } elsif ("info" =~ /^\Q$command/ && $command ne "i") { # check 1 letter command: 'id' or 'info'?
- printf "info <account_id>\n";
- printf " Display complete information of an account.\n";
- } elsif ($command eq "kami") { # check all letters command: 'kami' or 'kamib'?
- printf "kami <message>\n";
- printf " Sends a broadcast message on all map-server (in yellow).\n";
- } elsif ($command eq "kamib") { # check all letters command: 'kami' or 'kamib'?
- printf "kamib <message>\n";
- printf " Sends a broadcast message on all map-server (in blue).\n";
- } elsif ("language" =~ /^\Q$command/ && $command ne "l") { # check 1 letter command: 'list' or 'language'?
- printf("language <language>\n");
- printf(" Change the language of displaying.\n");
- printf(" Possible languages: Franais or English.\n");
- } elsif (("list" =~ /^\Q$command/ || $command eq "ls") && $command ne "l") { # check 1 letter command: 'list' or 'language'?
- printf "list/ls [start_id [end_id]]\n";
- printf " Display a list of accounts.\n";
- printf " 'start_id', 'end_id': indicate end and start identifiers.\n";
- printf " Research by name is not possible with this command.\n";
- printf " <example> list 10 9999999\n";
- } elsif (("listban" =~ /^\Q$command/ || $command eq "lsban") && $command ne "l") { # need to specificaly write Ban to have this list # check 1 letter command: 'list' or 'language'?
- printf "listBan/lsBan [start_id [end_id]]\n";
- printf " Like list/ls, but only for accounts with state or banished.\n";
- } elsif (("listgm" =~ /^\Q$command/ || $command eq "lsgm") && $command ne "l") { # need to specificaly write GM to have this list # check 1 letter command: 'list' or 'language'?
- printf "listGM/lsGM [start_id [end_id]]\n";
- printf " Like list/ls, but only for GM accounts.\n";
- } elsif (("listok" =~ /^\Q$command/ || $command eq "lsok") && $command ne "l") { # need to specificaly write OK to have this list # check 1 letter command: 'list' or 'language'?
- printf "listOK/lsOK [start_id [end_id]]\n";
- printf " Like list/ls, but only for accounts without state and not banished.\n";
- } elsif ("memo" =~ /^\Q$command/) {
- printf "memo <account_name> <memo>\n";
- printf " Modify the memo of an account.\n";
- printf " 'memo': it can have until 253 characters (with spaces or not).\n";
- } elsif ("name" =~ /^\Q$command/) {
- printf "name <account_id>\n";
- printf " Give the name of an account.\n";
- } elsif ("passwd" =~ /^\Q$command/ || "password" =~ /^\Q$command/) {
- printf "passwd <account_name> <new_password>\n";
- printf " Change the password of an account.\n";
- printf " When new password is omitted,\n";
- printf " the input is done without displaying of the pressed keys.\n";
- } elsif ("reloadgm" =~ /^\Q$command/) {
- printf "reloadGM\n";
- printf " Reload GM configuration file\n";
- } elsif ("search" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
- $command ne "se") { # check 2 letters command: 'search' or 'sex'?
- printf "search <expression>\n";
- printf " Seek accounts.\n";
- printf " Displays the accounts whose names correspond.\n";
- printf "search -r/-e/--expr/--regex <expression>\n";
- printf " Seek accounts by regular expression.\n";
- printf " Displays the accounts whose names correspond.\n";
- } elsif ("sex" =~ /^\Q$command/ && $command ne "s" && # check 1 letter command: 'search', 'state' or 'sex'?
- $command ne "se") { # check 2 letters command: 'search' or 'sex'?
- printf "sex <account_name> <sex>\n";
- printf " Modify the sex of an account.\n";
- printf " <example> sex testname Male\n";
- } elsif ("state" =~ /^\Q$command/ && $command ne "s") { # check 1 letter command: 'search', 'state' or 'sex'?
- printf "state <account_name> <new_state> <error_message_#7>\n";
- printf " Change the state of an account.\n";
- printf " 'new_state': state is the state of the packet 0x006a + 1.\n";
- printf " The possibilities are:\n";
- printf " 0 = Account ok\n";
- printf " 1 = Unregistered ID\n";
- printf " 2 = Incorrect Password\n";
- printf " 3 = This ID is expired\n";
- printf " 4 = Rejected from Server\n";
- printf " 5 = You have been blocked by the GM Team\n";
- printf " 6 = Your Game's EXE file is not the latest version\n";
- printf " 7 = You are Prohibited to log in until...\n";
- printf " 8 = Server is jammed due to over populated\n";
- printf " 9 = No MSG\n";
- printf " 100 = This ID has been totally erased\n";
- printf " all other values are 'No MSG', then use state 9 please.\n";
- printf " 'error_message_#7': message of the code error 6\n";
- printf " = Your are Prohibited to log in until... (packet 0x006a)\n";
- } elsif (("timeadd" =~ /^\Q$command/ || $command eq "ta") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
- printf "timeadd <account_name> <modifier>\n";
- printf " Adds or substracts time from the validity limit of an account.\n";
- printf " Modifier is done as follows:\n";
- printf " Adjustment value (-1, 1, +1, etc...)\n";
- printf " Modified element:\n";
- printf " a or y: year\n";
- printf " m: month\n";
- printf " j or d: day\n";
- printf " h: hour\n";
- printf " mn: minute\n";
- printf " s: second\n";
- printf " <example> timeadd testname +1m-2mn1s-6y\n";
- printf " this example adds 1 month and 1 second, and substracts 2 minutes\n";
- printf " and 6 years at the same time.\n";
- printf "NOTE: You can not modify a unlimited validity limit.\n";
- printf " If you want modify it, you want probably create a limited validity limit.\n";
- printf " So, at first, you must set the validity limit to a date/time.\n";
- } elsif (("timeset" =~ /^\Q$command/ || $command eq "ts") && $command ne "t") { # check 1 letter command: 'ta' or 'ts'?
- printf "timeset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
- printf " Changes the validity limit of an account.\n";
- printf " Default time: 23:59:59\n";
- printf "timeset <account_name> 0\n";
- printf " Gives an unlimited validity limit (0 = unlimited).\n";
- } elsif ($command eq "unban" || ("unbanish" =~ /^\Q$command/ && length($command) >= 4)) {
- printf "unban/unbanish <account name>\n";
- printf " Remove the banishment of an account.\n";
- printf " This command works like banset <account_name> 0.\n";
- } elsif ("unblock" =~ /^\Q$command/ && length($command) >= 4) {
- printf "unblock <account name>\n";
- printf " Set state 0 (Account ok) to an account.\n";
- printf " This command works like state <account_name> 0.\n";
- } elsif ("version" =~ /^\Q$command/) {
- printf "version\n";
- printf " Display the version of the login-server.\n";
- } elsif ("who" =~ /^\Q$command/) {
- printf "who <account_name>\n";
- printf " Displays complete information of an account.\n";
- } elsif ("quit" =~ /^\Q$command/ ||
- (("end" =~ /^\Q$command/ || "exit" =~ /^\Q$command/) && $command ne "e")) { # check 1 letter command: 'email', 'end' or 'exit'?\n";
- printf "quit/end/exit\n";
- printf " End of the program of administration.\n";
- } else {
- if ($receivedcommand ne "") {
- printf "Unknown command [%s] for help. Displaying of all commands.\n", $receivedcommand;
- }
- print << "ENDOFHELP";
- aide/help/? -- Display this help
- aide/help/? [command] -- Display the help of the command
- add <account_name> <sex> <password> -- Create an account with default email
- ban/banish yyyy/mm/dd hh:mm:ss <account_name> -- Change final date of a ban
- banadd/ba <account_name> <modifier> -- Add or substract time from the final
- example: ba apple +1m-2mn1s-2y date of a banishment of an account
- banset/bs <account_name> yyyy/mm/dd [hh:mm:ss] -- Change final date of a ban
- banset/bs <account_name> 0 -- Un-banish an account
- block <account name> -- Set state 5 (blocked by the GM Team) to an account
- check <account_name> <password> -- Check the validity of a password
- create <account_name> <sex> <email> <passwrd> -- Create an account with email
- del <account_name> -- Remove an account
- email <account_name> <email> -- Modify an email of an account
- getcount -- Give the number of players online
- gm <account_name> [GM_level] -- Modify the GM level of an account
- id <account_name> -- Give the id of an account
- info <account_id> -- Display all information of an account
- kami <message> -- Sends a broadcast message (in yellow)
- kamib <message> -- Sends a broadcast message (in blue)
- language <language> -- Change the language of displaying.
- list/ls [First_id [Last_id]] -- Display a list of accounts
- listBan/lsBan [First_id [Last_id]] -- Display a list of accounts
- with state or banished
- listGM/lsGM [First_id [Last_id]] -- Display a list of GM accounts
- listOK/lsOK [First_id [Last_id]] -- Display a list of accounts
- without state and not banished
- memo <account_name> <memo> -- Modify the memo of an account
- name <account_id> -- Give the name of an account
- passwd <account_name> <new_password> -- Change the password of an account
- quit/end/exit -- End of the program of administation
- reloadGM -- Reload GM configuration file
- search <expression> -- Seek accounts
- search -e/-r/--expr/--regex <expressn> -- Seek accounts by regular-expression
- sex <nomcompte> <sexe> -- Modify the sex of an account
- state <account_name> <new_state> <error_message_#7> -- Change the state
- timeadd/ta <account_name> <modifier> -- Add or substract time from the
- example: ta apple +1m-2mn1s-2y validity limit of an account
- timeset/ts <account_name> yyyy/mm/dd [hh:mm:ss] -- Change the validify limit
- timeset/ts <account_name> 0 -- Give a unlimited validity limit
- unban/unbanish <account name> -- Remove the banishment of an account
- unblock <account name> -- Set state 0 (Account ok) to an account
- version -- Gives the version of the login-server
- who <account_name> -- Display all information of an account
-ENDOFHELP
- printf(" Note: To use spaces in an account name, type \"<account name>\" (or ').\n");
- }
- }
-
- return 0;
-}
-#--------------------------------------------------------------------------
-
-# Sub-function: Displaying of the accounts list
-sub listaccount() {
- my($st, $ed, $listflag) = @_;
- my($i);
- my($n) = (0);
- # 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567
- if ($defaultlanguage eq "F") {
- print " id_compte GM nom_utilisateur sexe count statut\n";
- } else {
- print "account_id GM user_name sex count state\n";
- }
- print "-------------------------------------------------------------------------------\n";
- while(1) {
- print $so pack("vV2", 0x7920, $st, $ed);
- $so->flush();
- $buf = readso(4);
- if (unpack("v", $buf) != 0x7921) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- exit(10);
- }
- my($len) = unpack("x2v", $buf);
- last if ($len <= 4);
- for($i = 4; $i < $len; $i += 38) {
- my(@dat) = unpack("VCa24cVV", readso(38));
- $st = $dat[0] + 1;
- if ($listflag == 0 ||
- ($listflag == 1 && $dat[1] > 0) || # check GM flag
- ($listflag == 3 && $dat[5] != 0) || # check with state or banished
- ($listflag == 4 && $dat[5] == 0)) { # check without state and not banished
- printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0],
- ($dat[1] == 0 ? " " : $dat[1]),
- $dat[2],
- ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]),
- $dat[4],
- (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
- "Unregistered ID",
- "Incorrect Password",
- "This ID is expired",
- "Rejected from Server",
- "Blocked by the GM Team", # You have been blocked by the GM Team
- "Your EXE file is too old", # Your Game's EXE file is not the latest version
- "Banishement or\n Prohibited to login until %s", # You are Prohibited to log in until %s
- "Server is over populated", # Server is jammed due to over populated
- "No MSG",
- "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased
- $n++;
- }
- }
- }
- if ($defaultlanguage eq "F") {
- if ($n == 0) {
- print "Aucun compte trouv.\n";
- } elsif ($n == 1) {
- print "1 compte trouv.\n";
- } else {
- print "$n comptes trouvs.\n";
- }
- } else {
- if ($n == 0) {
- print "No account found.\n";
- } elsif ($n == 1) {
- print "1 account found.\n";
- } else {
- print "$n accounts found.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: add an account with the default e-mail
-sub addaccount() {
- my($userid, $sex, $passwd) = @_;
- if ($userid eq "" || !defined($userid)) {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> add nomtest Male motdepassetest\n";
- } else {
- print "Please input an account name.\n";
- print "<example> add testname Male testpass\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
-# if ($userid =~ /[^A-Za-z0-9\@-_]/) {
-# if ($defaultlanguage eq "F") {
-# print "Caractre interdit trouv dans le nom du compte ".$`."[${&}]${'}\n";
-# } else {
-# print "Illegal character found in the account name ".$`."[${&}]${'}\n";
-# }
-# return 101;
-# }
- $sex = uc(substr($sex, 0, 1));
- if ($sex !~ /^[MF]$/) {
- if ($defaultlanguage eq "F") {
- print "Sexe incorrect [$sex]. Entrez M ou F svp.\n";
- } else {
- print "Illegal gender [$sex]. Please input M or F.\n";
- }
- return 103;
- }
- if ($passwd eq "") {
- return 108 if (($passwd = typepasswd()) eq "");
- }
- if (verify_password($passwd) == 0) {
- return 104;
- }
- print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, "");
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7931) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 106;
- }
- $buf = readso(28);
- if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec la cration du compte [$userid]. Un compte identique existe dj.\n";
- } else {
- print "Account [$userid] creation failed. Same account already exists.\n";
- }
- return 107;
- } else {
- if ($defaultlanguage eq "F") {
- printf "Compte [$userid] cr avec succs [id: %d].\n", unpack("V",$buf);
- } else {
- printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf);
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: add an account with an e-mail
-sub createaccount() {
- my($userid, $sex, $email, $passwd) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> create nomtest Male mon\@email.com motdepassetest\n";
- } else {
- print "Please input an account name.\n";
- print "<example> create testname Male my\@mail.com testpass\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
-# if ($userid =~ /[^A-Za-z0-9\@-_]/) {
-# if ($defaultlanguage eq "F") {
-# print "Caractre interdit trouv dans le nom du compte ".$`."[${&}]${'}\n";
-# } else {
-# print "Illegal character found in the account name ".$`."[${&}]${'}\n";
-# }
-# return 101;
-# }
- $sex = uc(substr($sex, 0, 1));
- if ($sex !~ /^[MF]$/) {
- if ($defaultlanguage eq "F") {
- print "Sexe incorrect [$sex]. Entrez M ou F svp.\n";
- } else {
- print "Illegal gender [$sex]. Please input M or F.\n";
- }
- return 103;
- }
- if (length($email) < 3) {
- if ($defaultlanguage eq "F") {
- print "Email trop courte [$email]. Entrez une e-mail valide svp.\n";
- } else {
- print "Email is too short [$email]. Please input a valid e-mail.\n";
- }
- return 109;
- }
- if (length($email) > 39) {
- if ($defaultlanguage eq "F") {
- print "Email trop longue [$email]. Entrez une e-mail de 39 caractres maximum svp.\n";
- } else {
- print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n";
- }
- return 109;
- }
- if (verify_email($email) == 0) {
- if ($defaultlanguage eq "F") {
- print "Email incorrecte [$email]. Entrez une e-mail valide svp.\n";
- } else {
- print "Invalid email [$email]. Please input a valid e-mail.\n";
- }
- return 109;
- }
- if ($passwd eq "") {
- return 108 if (($passwd = typepasswd()) eq "");
- }
- if (verify_password($passwd) == 0) {
- return 104;
- }
- print $so pack("va24a24a1a40", 0x7930, $userid, $passwd, $sex, $email);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7931) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 106;
- }
- $buf = readso(28);
- if (unpack("V", $buf) == -1 || unpack("V", $buf) == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec la cration du compte [$userid]. Un compte identique existe dj.\n";
- } else {
- print "Account [$userid] creation failed. Same account already exists.\n";
- }
- return 107;
- } else {
- if ($defaultlanguage eq "F") {
- printf "Compte [$userid] cr avec succs [id: %d].\n", unpack("V",$buf);
- } else {
- printf "Account [$userid] is successfully created [id: %d].\n", unpack("V",$buf);
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: deletion of an account
-sub delaccount() {
- my($userid) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> del nomtestasupprimer\n";
- } else {
- print "Please input an account name.\n";
- print "<example> del testnametodelete\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- if ($defaultlanguage eq "F") {
- print "** Etes-vous vraiment sr de vouloir SUPPRIMER le compte [$userid]? (o/n) ";
- } else {
- print "** Are you really sure to DELETE account [$userid]? (y/n) ";
- }
- if (lc(substr(<STDIN>, 0, 1)) !~ /[oy]/) {
- if ($defaultlanguage eq "F") {
- print "Suppression annule\n.";
- } else {
- print "Deletion canceled\n";
- }
- return 121;
- }
- print $so pack("va24", 0x7932, $userid);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7933) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 122;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec de la suppression du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] deletion failed. Account doesn't exist.\n";
- }
- return 123;
- } else {
- if ($defaultlanguage eq "F") {
- print "Compte [$name][id: $id2] SUPPRIME avec succs.\n";
- } else {
- print "Account [$name][id: $id2] is successfully DELETED.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: modification of a password
-sub changepasswd() {
- my($userid, $passwd) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> passwd nomtest nouveaumotdepasse\n";
- } else {
- print "Please input an account name.\n";
- print "<example> passwd testname newpassword\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- if ($passwd eq "") {
- return 134 if (($passwd = typepasswd()) eq "");
- }
- if (verify_password($passwd) == 0) {
- return 131;
- }
- print $so pack("va24a24", 0x7934, $userid,$passwd);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7935) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 132;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec de la modification du mot de passe du compte [$userid].\n";
- print "Le compte [$userid] n'existe pas.\n";
- } else {
- print "Account [$userid] password changing failed.\n";
- print "Account [$userid] doesn't exist.\n";
- }
- return 133;
- } else {
- if ($defaultlanguage eq "F") {
- print "Modification du mot de passe du compte [$name][id: $id2] russie.\n";
- } else {
- print "Account [$name][id: $id2] password successfully changed.\n";
- }
- }
- return 130;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: modification of an account e-mail
-sub changeemail() {
- my($userid, $email) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> email testname nouveauemail\n";
- } else {
- print "Please input an account name.\n";
- print "<example> email testname newemail\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- if (length($email) < 3) {
- if ($defaultlanguage eq "F") {
- print "Email trop courte [$email]. Entrez une e-mail valide svp.\n";
- } else {
- print "Email is too short [$email]. Please input a valid e-mail.\n";
- }
- return 109;
- }
- if (length($email) > 39) {
- if ($defaultlanguage eq "F") {
- print "Email trop longue [$email]. Entrez une e-mail de 39 caractres maximum svp.\n";
- } else {
- print "Email is too long [$email]. Please input an e-mail with 39 bytes at the most.\n";
- }
- return 109;
- }
- if (verify_email($email) == 0) {
- if ($defaultlanguage eq "F") {
- print "Email incorrect [$email]. Entrez une e-mail valide svp.\n";
- } else {
- print "Invalid email [$email]. Please input a valid e-mail.\n";
- }
- return 109;
- }
- print $so pack("va24a40", 0x7940, $userid, $email);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7941) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 162;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec de la modification de l'e-mail du compte [$userid].\n";
- print "Le compte [$userid] n'existe pas.\n";
- } else {
- print "Account [$userid] e-mail changing failed.\n";
- print "Account [$userid] doesn't exist.\n";
- }
- return 133;
- } else {
- if ($defaultlanguage eq "F") {
- print "Modification de l'e-mail du compte [$name][id: $id2] russie.\n";
- } else {
- print "Account [$name][id: $id2] e-mail successfully changed.\n";
- }
- }
- return 160;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: search of accounts
-sub searchaccount() {
- my($p1, $p2) = @_;
- my($exp) = ("");
- if ($p1 eq "-e" || $p1 eq "-r" || $p1 eq "--regex" || $p1 eq "--expr") {
- if ($p2 eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez une expression rgulire ou utilisez 'ls' pour avoir tous les comptes.\n";
- } else {
- print "Input a regular expression or use 'ls' to obtain all accounts.\n";
- }
- return 141;
- }
- $exp = $p2;
- } else {
- if ($p1 eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez une chane ou utilisez 'ls' pour avoir tous les comptes.\n";
- } else {
- print "Input a string or use 'ls' to obtain all accounts.\n";
- }
- return 141;
- }
- my($c) = 0;
- $exp = lc($p1);
- $exp =~ s/([\@])/\\$1/g;
- $c += $exp =~ s/([\-\[\]])/\\$1/g;
- $c += $exp =~ s/([\*\?])/.$1/g;
- $c += $exp =~ s/\\\[(.)\\\-(.)\\\]/[$1-$2]/g;
- $exp = "^$exp\$" if $c;
- }
- if (eval{ "" =~ /$exp/; }, $@) {
- if ($defaultlanguage eq "F") {
- print "Expression rgulire non reconnue.\n";
- } else {
- print "Regular-Expression compiling failed.\n";
- }
- return 141;
- }
- my($i);
- my($n, $st) = (0, 0);
- # 0123456789 01 01234567890123456789012301234 012345 0123456789012345678901234567
- if ($defaultlanguage eq "F") {
- print " id_compte GM nom_utilisateur sexe count statut\n";
- } else {
- print "account_id GM user_name sex count state\n";
- }
- print "-------------------------------------------------------------------------------\n";
- while(1) {
- print $so pack("vV2", 0x7920, $st, 0);
- $so->flush();
- $buf = readso(4);
- if (unpack("v", $buf) != 0x7921) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- exit(10);
- }
- my($len) = unpack("x2v", $buf);
- last if ($len <= 4);
- for($i = 4; $i < $len; $i += 38) {
- my(@dat) = unpack("VCa24cVV", readso(38));
- $st = $dat[0] + 1;
- next if (lc($dat[2]) !~ /$exp/);
- printf "%10d %2s %-24s%-5s %6d %-27s\n", $dat[0],
- ($dat[1] == 0 ? " " : $dat[1]),
- $dat[2],
- ($defaultlanguage eq "F" ? ("Femme","Male","Servr")[$dat[3]] : ("Femal","Male","Servr")[$dat[3]]),
- $dat[4],
- (($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
- "Unregistered ID",
- "Incorrect Password",
- "This ID is expired",
- "Rejected from Server",
- "Blocked by the GM Team", # You have been blocked by the GM Team
- "Your EXE file is too old", # Your Game's EXE file is not the latest version
- "Banishement or\n Prohibited to login until %s", # You are Prohibited to log in until %s
- "Server is over populated", # Server is jammed due to over populated
- "No MSG",
- "This ID is totally erased")[$dat[5] == 100 ? 10 : $dat[5]]; # This ID has been totally erased
- $n++;
- }
- }
- if ($defaultlanguage eq "F") {
- if ($n == 0) {
- print "Aucun compte trouv.\n";
- } elsif ($n == 1) {
- print "1 compte trouv.\n";
- } else {
- print "$n comptes trouvs.\n";
- }
- } else {
- if ($n == 0) {
- print "No account found.\n";
- } elsif ($n == 1) {
- print "1 account found.\n";
- } else {
- print "$n accounts found.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: modify the sex of an account
-sub changesex() {
- my($userid, $sex) = @_;
- if ($userid eq "" || !defined($userid)) {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> sex nomtest Male\n";
- } else {
- print "Please input an account name.\n";
- print "<example> sex testname Male\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
-# if ($userid =~ /[^A-Za-z0-9\@-_]/) {
-# if ($defaultlanguage eq "F") {
-# print "Caractre interdit trouv dans le nom du compte ".$`."[${&}]${'}\n";
-# } else {
-# print "Illegal character found in the account name ".$`."[${&}]${'}\n";
-# }
-# return 101;
-# }
- $sex = uc(substr($sex, 0, 1));
- if ($sex !~ /^[MF]$/) {
- if ($defaultlanguage eq "F") {
- print "Sexe incorrect [$sex]. Entrez M ou F svp.\n";
- } else {
- print "Illegal gender [$sex]. Please input M or F.\n";
- }
- return 103;
- }
- print $so pack("va24a1", 0x793c, $userid, $sex);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x793d) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec du changement du sexe du compte [$userid].\n";
- print "Le compte n'existe pas ou le sexe est dj celui demand.\n";
- } else {
- print "Account [$userid] sex changing failed.\n";
- print "Account doesn't exist or the sex is already the good sex.\n";
- }
- } else {
- if ($defaultlanguage eq "F") {
- print "Sexe du compte [$name][id: $id2] chang avec succs.\n";
- } else {
- print "Account [$name][id: $id2] sex successfully changed.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: modify the GM level of an account
-sub changegmlevel() {
- my($userid, $gm_level) = @_;
- if ($userid eq "" || !defined($userid)) {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> gm nomtest 80\n";
- } else {
- print "Please input an account name.\n";
- print "<example> gm testname 80\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
-# if ($userid =~ /[^A-Za-z0-9\@-_]/) {
-# if ($defaultlanguage eq "F") {
-# print "Caractre interdit trouv dans le nom du compte ".$`."[${&}]${'}\n";
-# } else {
-# print "Illegal character found in the account name ".$`."[${&}]${'}\n";
-# }
-# return 101;
-# }
- $gm_level = int($gm_level);
- if ($gm_level < 0 || $gm_level > 99) {
- if ($defaultlanguage eq "F") {
- print "Niveau de GM incorrect [$gm_level]. Entrez une valeur de 0 99 svp.\n";
- } else {
- print "Illegal GM level [$gm_level]. Please input a value from 0 to 99.\n";
- }
- return 103;
- }
- print $so pack("va24C", 0x793e, $userid, $gm_level);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x793f) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec du changement du niveau de GM du compte [$userid].\n";
- print "Le compte n'existe pas, le niveau de GM est dj celui demand,\n";
- print "ou il est impossible de modifier le fichier des comptes GM.\n";
- } else {
- print "Account [$userid] GM level changing failed.\n";
- print "Account doesn't exist, the GM level is already the good GM level,\n";
- print "or it's impossible to modify the GM accounts file.\n";
- }
- } else {
- if ($defaultlanguage eq "F") {
- print "Niveau de GM du compte [$name][id: $id2] chang avec succs.\n";
- } else {
- print "Account [$name][id: $id2] GM level successfully changed.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Modification of a state
-sub changestate {
- my($userid, $s, $error_message) = @_;
- # Valid values: 0: ok, or value of the 0x006a packet + 1
- if ($s eq "" || (($s < 0 || $s > 9) && $s != 100)) {
- if ($defaultlanguage eq "F") {
- print "Entrez une des valeurs suivantes svp:\n";
- print " 0 = Compte ok 6 = Your Game's EXE file is not the latest version\n";
- } else {
- print "Please input one of these values:\n";
- print " 0 = Account ok 6 = Your Game's EXE file is not the latest version\n";
- }
- print " 1 = Unregistered ID 7 = You are Prohibited to log in until %s\n";
- print " 2 = Incorrect Password 8 = Server is jammed due to over populated\n";
- print " 3 = This ID is expired 9 = No MSG\n";
- print " 4 = Rejected from Server 100 = This ID has been totally erased\n";
- print " 5 = You have been blocked by the GM Team\n";
- if ($defaultlanguage eq "F") {
- print "<exemples> state nomtest 5\n";
- print " state nomtest 7 fin de votre ban\n";
- print " block <nom du compte>\n";
- print " unblock <nom du compte>\n";
- } else {
- print "<examples> state testname 5\n";
- print " state testname 7 end of your ban\n";
- print " block <account name>\n";
- print " unblock <account name>\n";
- }
- return 151;
- }
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemples> state nomtest 5\n";
- print " state nomtest 7 fin de votre ban\n";
- print " block <nom du compte>\n";
- print " unblock <nom du compte>\n";
- } else {
- print "Please input an account name.\n";
- print "<examples> state testname 5\n";
- print " state testname 7 end of your ban\n";
- print " block <account name>\n";
- print " unblock <account name>\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- if ($s != 7) {
- $error_message = "-";
- } else {
- if (length($error_message) < 1) {
- if ($defaultlanguage eq "F") {
- print "Message d'erreur trop court. Entrez un message de 1-19 caractres.\n";
- } else {
- print "Error message is too short. Please input a message of 1-19 bytes.\n";
- }
- return 102;
- }
- if (length($error_message) > 19) {
- if ($defaultlanguage eq "F") {
- print "Message d'erreur trop long. Entrez un message de 1-19 caractres.\n";
- } else {
- print "Error message is too long. Please input a message of 1-19 bytes.\n";
- }
- return 102;
- }
- }
- print $so pack("va24Va20", 0x7936, $userid, $s, $error_message);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7937) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(32);
- my(@dat) = unpack("Va24V", $buf);
- while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
- chop($dat[1]);
- };
- if ($dat[0] != -1 && $dat[0] != 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Statut du compte [$dat[1]][id: $dat[0]] chang avec succs en [";
- } else {
- print "Account [$dat[1]][id: $dat[0]] state successfully changed in [";
- }
- print ((($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
- "Unregistered ID",
- "Incorrect Password",
- "This ID is expired",
- "Rejected from Server",
- "You have been blocked by the GM Team",
- "Your Game's EXE file is not the latest version",
- "You are Prohibited to log in until %s",
- "Server is jammed due to over populated",
- "No MSG",
- "This ID has been totally erased")[$dat[2] == 100 ? 10 : $dat[2]]);
- print "].\n";
- } else {
- if ($defaultlanguage eq "F") {
- print "Echec du changement du statut du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] state changing failed. Account doesn't exist.\n";
- }
- }
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Displaying of the number of online players
-sub getlogincount {
- # Request to the login-server
- print $so pack("v", 0x7938);
- $so->flush();
-
- $buf = readso(4);
- # Connection failed
- if (unpack("v", $buf) != 0x7939) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- exit(3);
- }
-
- # Get length of the received packet
- my($len) = unpack("x2v", $buf) - 4;
-
- # Read information of the servers
- if ($len < 1) {
- if ($defaultlanguage eq "F") {
- printf " Aucun serveur n'est connect au login serveur.\n";
- } else {
- printf " No server is connected to the login-server.\n";
- }
- } else {
- my(@slist) = ();
- for(; $len > 0; $len -= 32) {
- my($name, $count) = unpack("x6 a20 V", readso(32));
- $name = substr($name, 0, index($name, "\0"));
- push @slist, [ $name, $count ];
- }
- # Displaying of result
- my($i);
- if ($defaultlanguage eq "F") {
- printf " Nombre de joueurs en ligne (serveur: nb):\n";
- } else {
- printf " Number of online players (server: number).\n";
- }
- foreach $i(@slist) {
- printf " %-20s : %5d\n", $i->[0], $i->[1];
- }
- }
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Modification of a memo field
-sub changememo {
- my($userid, $memo) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> memo nomtest nouveau memo\n";
- } else {
- print "Please input an account name.\n";
- print "<example> memo testname new memo\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- if (length($memo) > 254) {
- if ($defaultlanguage eq "F") {
- print "Mmo trop long (".length($memo)." caractres).\n";
- print "Entrez un mmo de 254 caractres maximum svp.\n";
- } else {
- print "Memo is too long (".length($memo)." characters).\n";
- print "Please input a memo of 254 bytes at the maximum.\n";
- }
- return 102;
- }
- if (length($memo) == 0) {
- print $so pack("va24v", 0x7942, $userid, 0);
- } else {
- print $so pack("va24va".length($memo), 0x7942, $userid, length($memo), $memo);
- }
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7943) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec du changement du mmo du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] memo changing failed. Account doesn't exist.\n";
- }
- } else {
- if ($defaultlanguage eq "F") {
- print "Mmo du compte [$name][id: $id2] chang avec succs.\n";
- } else {
- print "Account [$name][id: $id2] memo successfully changed.\n";
- }
- }
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Request to obtain an account id
-sub idaccount() {
- my($userid) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> id nomtest\n";
- } else {
- print "Please input an account name.\n";
- print "<example> id testname\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- print $so pack("va24", 0x7944, $userid);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7945) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 122;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Impossible de trouver l'id du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Unabled to find the account [$userid] id. Account doesn't exist.\n";
- }
- return 123;
- } else {
- if ($defaultlanguage eq "F") {
- print "Le compte [$name] a pour id: $id2.\n";
- } else {
- print "The account [$name] have the id: $id2.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Request to obtain an account name
-sub nameaccount() {
- my($id) = @_;
- if ($id < 0) {
- if ($defaultlanguage eq "F") {
- print "Entrez un id ayant une valeur positive svp.\n";
- } else {
- print "Please input a positive value for the id.\n";
- }
- return 136;
- }
- print $so pack("vV", 0x7946, $id);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7947) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 122;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if (length($name) == 0 || $name eq "") {
- if ($defaultlanguage eq "F") {
- print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n";
- } else {
- print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n";
- }
- return 123;
- } else {
- if ($defaultlanguage eq "F") {
- print "Le compte [id: $id2] a pour nom: $name.\n";
- } else {
- print "The account [id: $id2] have the name: $name.\n";
- }
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Set a validity limit of an account
-sub timesetaccount() {
- my($userid, $date, $time) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple>: timeset <nom_du_compte> aaaa/mm/jj [hh:mm:ss]\n";
- print " timeset <nom_du_compte> 0 (0 = illimit)\n";
- printf " Heure par dfaut [hh:mm:ss]: 23:59:59\n";
- } else {
- print "Please input an account name.\n";
- print "<example>: timeset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
- print " timeset <account_name> 0 (0 = unlimited)\n";
- printf " Default time [hh:mm:ss]: 23:59:59\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- my($year, $month, $day) = split(/[.\-\/]/, $date);
- my($hour, $minute, $second) = split(/:/, $time);
- if ($time eq "") {
- $hour = 23;
- $minute = 59;
- $second = 59;
- }
- my($timestamp);
- if ($year eq "" ||
- ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) {
- if ($defaultlanguage eq "F") {
- print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
- } else {
- print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
- }
- return 102;
- }
- if ($year == 0) {
- $timestamp = 0;
- } else {
- if ($year < 70) {
- $year = $year + 100;
- }
- if ($year >= 1900) {
- $year = $year - 1900;
- }
- if ($month < 1 || $month > 12) {
- if ($defaultlanguage eq "F") {
- print "Entrez un mois correct svp (entre 1 et 12).\n";
- } else {
- print "Please give a correct value for the month (from 1 to 12).\n";
- }
- return 102;
- }
- $month = $month - 1;
- if ($day < 1 || $day > 31) {
- if ($defaultlanguage eq "F") {
- print "Entrez un jour correct svp (entre 1 et 31).\n";
- } else {
- print "Please give a correct value for the day (from 1 to 31).\n";
- }
- return 102;
- }
- if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) ||
- ($month == 1 && $day > 29)) {
- if ($defaultlanguage eq "F") {
- print "Entrez un jour correct en fonction du mois svp.\n";
- } else {
- print "Please give a correct value for a day of this month.\n";
- }
- return 102;
- }
- if ($hour < 0 || $hour > 23) {
- if ($defaultlanguage eq "F") {
- print "Entrez une heure correcte svp (entre 0 et 23).\n";
- } else {
- print "Please give a correct value for the hour (from 0 to 23).\n";
- }
- return 102;
- }
- if ($minute < 0 || $minute > 59) {
- if ($defaultlanguage eq "F") {
- print "Entrez des minutes correctes svp (entre 0 et 59).\n";
- } else {
- print "Please give a correct value for the minutes (from 0 to 59).\n";
- }
- return 102;
- }
- if ($second < 0 || $second > 59) {
- if ($defaultlanguage eq "F") {
- print "Entrez des secondes correctes svp (entre 0 et 59).\n";
- } else {
- print "Please give a correct value for the seconds (from 0 to 59).\n";
- }
- return 102;
- }
- $timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification
- if ($timestamp == undef) {
- if ($defaultlanguage eq "F") {
- print "Date incorrecte.\n";
- print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
- } else {
- print "Invalid date.\n";
- print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
- }
- return 102;
- }
- }
-
- print $so pack("va24V", 0x7948, $userid, $timestamp);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7949) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(32);
- my(@dat) = unpack("Va24V", $buf);
- while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
- chop($dat[1]);
- };
- if ($dat[0] != -1 && $dat[0] != 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Limite de validit du compte [$dat[1]][id: $dat[0]] change avec succs ".
- ($dat[2] == 0 ? "en [illimit].\n" : "pour tre jusqu'au ".(POSIX::ctime($dat[2])));
- } else {
- print "Validity Limit of the account [$dat[1]][id: $dat[0]] successfully changed ".
- ($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2])));
- }
- # localtime($dat[2]) is also possible to display instead of POSIX::ctime.
- } else {
- if ($defaultlanguage eq "F") {
- print "Echec du changement de la validit du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] validity limit changing failed. Account doesn't exist.\n";
- }
- }
-
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Add/substract time to the validity limit of an account
-sub timeaddaccount() {
- my($userid, $modif) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print " <exemple> timeadd nomtest +1m-2mn1s-6y\n";
- print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
- print " et 6 ans dans le mme temps.\n";
- } else {
- print "Please input an account name.\n";
- print " <example> timeadd testname +1m-2mn1s-6y\n";
- print " this example adds 1 month and 1 second, and substracts 2 minutes\n";
- print " and 6 years at the same time.\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- my($year, $month, $day) = (0, 0 ,0);
- my($hour, $minute, $second) = (0, 0 ,0);
-
- $modif = lc($modif);
- while (length($modif) > 0) {
- my($value) = int($modif);
- if ($value == 0) {
- $modif = substr($modif, 1);
- } else {
- if (substr($modif, 0, 1) =~ /[\-\+]/) {
- $modif = substr($modif, 1);
- }
- while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) {
- $modif = substr($modif, 1);
- }
- if (index($modif, "s") == 0) {
- $second = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "mn") == 0) {
- $minute = $value;
- $modif = substr($modif, 2);
- } elsif (index($modif, "h") == 0) {
- $hour = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "d") == 0 || index($modif, "j") == 0) {
- $day = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "m") == 0) {
- $month = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "y") == 0 || index($modif, "a") == 0) {
- $year = $value;
- $modif = substr($modif, 1);
- } else {
- $modif = substr($modif, 1);
- }
- }
- }
-
- if ($defaultlanguage eq "F") {
- print " anne: $year\n";
- print " mois: $month\n";
- print " jour: $day\n";
- print " heure: $hour\n";
- print " minute: $minute\n";
- print " seconde: $second\n";
- } else {
- print " year: $year\n";
- print " month: $month\n";
- print " day: $day\n";
- print " hour: $hour\n";
- print " minute: $minute\n";
- print " second: $second\n";
- }
-
- if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) {
- if ($defaultlanguage eq "F") {
- print "Vous devez entrer un ajustement avec cette commande, svp:\n";
- print " Valeur d'ajustement (-1, 1, +1, etc...)\n";
- print " Element modifi:\n";
- print " a ou y: anne\n";
- print " m: mois\n";
- print " j ou d: jour\n";
- print " h: heure\n";
- print " mn: minute\n";
- print " s: seconde\n";
- print " <exemple> timeadd nomtest +1m-2mn1s-6y\n";
- print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
- print " et 6 ans dans le mme temps.\n";
- } else {
- print "Please give an adjustment with this command:\n";
- print " Adjustment value (-1, 1, +1, etc...)\n";
- print " Modified element:\n";
- print " a or y: year\n";
- print " m: month\n";
- print " j or d: day\n";
- print " h: hour\n";
- print " mn: minute\n";
- print " s: second\n";
- print " <example> timeadd testname +1m-2mn1s-6y\n";
- print " this example adds 1 month and 1 second, and substracts 2 minutes\n";
- print " and 6 years at the same time.\n";
- }
- return 137;
- }
- if ($year > 127 || $year < -127) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement d'annes correct (de -127 127), svp.\n";
- } else {
- print "Please give a correct adjustment for the years (from -127 to 127).\n";
- }
- return 137;
- }
- if ($month > 255 || $month < -255) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de mois correct (de -255 255), svp.\n";
- } else {
- print "Please give a correct adjustment for the months (from -255 to 255).\n";
- }
- return 137;
- }
- if ($day > 32767 || $day < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de jours correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the days (from -32767 to 32767).\n";
- }
- return 137;
- }
- if ($hour > 32767 || $hour < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement d'heures correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the hours (from -32767 to 32767).\n";
- }
- return 137;
- }
- if ($minute > 32767 || $minute < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de minutes correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n";
- }
- return 137;
- }
- if ($second > 32767 || $second < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de secondes correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n";
- }
- return 137;
- }
-
- print $so pack("va24vvvvvv", 0x7950, $userid, $year, $month, $day, $hour, $minute, $second);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7951) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(32);
- my(@dat) = unpack("Va24V", $buf);
- while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
- chop($dat[1]);
- };
- if ($dat[0] == -1 || $dat[0] == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec du changement de la validit du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] validity limit changing failed. Account doesn't exist.\n";
- }
- } elsif ($dat[2] == 0) {
- if ($defaultlanguage eq "F") {
- print "Limite de validit du compte [$dat[1]][id: $dat[0]] inchange.\n";
- print "Le compte a une validit illimite ou\n";
- print "la modification est impossible avec les ajustements demands.\n";
- } else {
- print "Validity limit of the account [$dat[1]][id: $dat[0]] unchanged.\n";
- print "The account have an unlimited validity limit or\n";
- print "the changing is impossible with the proposed adjustments.\n";
- }
- } else {
- if ($defaultlanguage eq "F") {
- print "Limite de validit du compte [$dat[1]][id: $dat[0]] change avec succs ".
- ($dat[2] == 0 ? "en [illimit].\n" : "pour tre jusqu'au ".(POSIX::ctime($dat[2])));
- } else {
- print "Validity limit of the account [$dat[1]][id: $dat[0]] successfully changed ".
- ($dat[2] == 0 ? "to [unlimited].\n" : "to be until ".(POSIX::ctime($dat[2])));
- }
- # localtime($dat[2]) is also possible to display instead of POSIX::ctime.
- }
-
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Set the final date of a banishment of an account
-sub bansetaccount() {
- my($userid, $date, $time) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple>: banset <nom_du_compte> aaaa/mm/jj [hh:mm:ss]\n";
- print " banset <nom_du_compte> 0 (0 = d-bani)\n";
- print " ban/banish aaaa/mm/jj hh:mm:ss <nom du compte>\n";
- print " unban/unbanish <nom du compte>\n";
- printf " Heure par dfaut [hh:mm:ss]: 23:59:59\n";
- } else {
- print "Please input an account name.\n";
- print "<example>: banset <account_name> yyyy/mm/dd [hh:mm:ss]\n";
- print " banset <account_name> 0 (0 = un-banished)\n";
- print " ban/banish yyyy/mm/dd hh:mm:ss <account name>\n";
- print " unban/unbanish <account name>\n";
- printf " Default time [hh:mm:ss]: 23:59:59\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- my($year, $month, $day) = split(/[.\-\/]/, $date);
- my($hour, $minute, $second) = split(/:/, $time);
- if ($time eq "") {
- $hour = 23;
- $minute = 59;
- $second = 59;
- }
- my($timestamp);
- if ($year eq "" ||
- ($year != 0 && ($month eq "" || $day eq "" || $hour eq "" || $minute eq "" || $second eq ""))) {
- if ($defaultlanguage eq "F") {
- print "Entrez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
- } else {
- print "Please input 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
- }
- return 102;
- }
- if ($year == 0) {
- $timestamp = 0;
- } else {
- if ($year < 70) {
- $year = $year + 100;
- }
- if ($year >= 1900) {
- $year = $year - 1900;
- }
- if ($month < 1 || $month > 12) {
- if ($defaultlanguage eq "F") {
- print "Entrez un mois correct svp (entre 1 et 12).\n";
- } else {
- print "Please give a correct value for the month (from 1 to 12).\n";
- }
- return 102;
- }
- $month = $month - 1;
- if ($day < 1 || $day > 31) {
- if ($defaultlanguage eq "F") {
- print "Entrez un jour correct svp (entre 1 et 31).\n";
- } else {
- print "Please give a correct value for the day (from 1 to 31).\n";
- }
- return 102;
- }
- if ((($month == 3 || $month == 5 || $month == 8 || $month == 10) && $day > 30) ||
- ($month == 1 && $day > 29)) {
- if ($defaultlanguage eq "F") {
- print "Entrez un jour correct en fonction du mois svp.\n";
- } else {
- print "Please give a correct value for a day of this month.\n";
- }
- return 102;
- }
- if ($hour < 0 || $hour > 23) {
- if ($defaultlanguage eq "F") {
- print "Entrez une heure correcte svp (entre 0 et 23).\n";
- } else {
- print "Please give a correct value for the hour (from 0 to 23).\n";
- }
- return 102;
- }
- if ($minute < 0 || $minute > 59) {
- if ($defaultlanguage eq "F") {
- print "Entrez des minutes correctes svp (entre 0 et 59).\n";
- } else {
- print "Please give a correct value for the minutes (from 0 to 59).\n";
- }
- return 102;
- }
- if ($second < 0 || $second > 59) {
- if ($defaultlanguage eq "F") {
- print "Entrez des secondes correctes svp (entre 0 et 59).\n";
- } else {
- print "Please give a correct value for the seconds (from 0 to 59).\n";
- }
- return 102;
- }
- $timestamp = POSIX::mktime($second, $minute, $hour, $day, $month, $year, 0, 0, -1); # -1: no winter/summer time modification
- if ($timestamp == undef) {
- if ($defaultlanguage eq "F") {
- print "Date incorrecte.\n";
- print "Ajoutez 0 ou une date et une heure svp (format: 0 ou aaaa/mm/jj hh:mm:ss).\n";
- } else {
- print "Invalid date.\n";
- print "Please add 0 or a date and a time (format: 0 or yyyy/mm/dd hh:mm:ss).\n";
- }
- return 102;
- }
- }
-
- print $so pack("va24V", 0x794a, $userid, $timestamp);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x794b) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(32);
- my(@dat) = unpack("Va24V", $buf);
- while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
- chop($dat[1]);
- };
- if ($dat[0] != -1 && $dat[0] != 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] change avec succs ".
- ($dat[2] == 0 ? "en [d-bannie].\n" : "pour tre jusqu'au ".(POSIX::ctime($dat[2])));
- } else {
- print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ".
- ($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2])));
- }
- # localtime($dat[2]) is also possible to display instead of POSIX::ctime.
- } else {
- if ($defaultlanguage eq "F") {
- print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n";
- }
- }
-
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Add/substract time to the final date of a banishment of an account
-sub banaddaccount() {
- my($userid, $modif) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print " <exemple> banadd nomtest +1m-2mn1s-6y\n";
- print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
- print " et 6 ans dans le mme temps.\n";
- } else {
- print "Please input an account name.\n";
- print " <example> banadd testname +1m-2mn1s-6y\n";
- print " this example adds 1 month and 1 second, and substracts 2 minutes\n";
- print " and 6 years at the same time.\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- my($year, $month, $day) = (0, 0 ,0);
- my($hour, $minute, $second) = (0, 0 ,0);
-
- $modif = lc($modif);
- while (length($modif) > 0) {
- my($value) = int($modif);
- if ($value == 0) {
- $modif = substr($modif, 1);
- } else {
- if (substr($modif, 0, 1) =~ /[\-\+]/) {
- $modif = substr($modif, 1);
- }
- while (length($modif) > 0 && substr($modif, 0, 1) =~ /[0-9]/) {
- $modif = substr($modif, 1);
- }
- if (index($modif, "s") == 0) {
- $second = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "mn") == 0) {
- $minute = $value;
- $modif = substr($modif, 2);
- } elsif (index($modif, "h") == 0) {
- $hour = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "d") == 0 || index($modif, "j") == 0) {
- $day = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "m") == 0) {
- $month = $value;
- $modif = substr($modif, 1);
- } elsif (index($modif, "y") == 0 || index($modif, "a") == 0) {
- $year = $value;
- $modif = substr($modif, 1);
- } else {
- $modif = substr($modif, 1);
- }
- }
- }
-
- if ($defaultlanguage eq "F") {
- print " anne: $year\n";
- print " mois: $month\n";
- print " jour: $day\n";
- print " heure: $hour\n";
- print " minute: $minute\n";
- print " seconde: $second\n";
- } else {
- print " year: $year\n";
- print " month: $month\n";
- print " day: $day\n";
- print " hour: $hour\n";
- print " minute: $minute\n";
- print " second: $second\n";
- }
-
- if ($year == 0 && $month == 0 && $day == 0 && $hour == 0 && $minute == 0 && $second == 0) {
- if ($defaultlanguage eq "F") {
- print "Vous devez entrer un ajustement avec cette commande, svp:\n";
- print " Valeur d'ajustement (-1, 1, +1, etc...)\n";
- print " Element modifi:\n";
- print " a ou y: anne\n";
- print " m: mois\n";
- print " j ou d: jour\n";
- print " h: heure\n";
- print " mn: minute\n";
- print " s: seconde\n";
- print " <exemple> banadd nomtest +1m-2mn1s-6y\n";
- print " Cette exemple ajoute 1 mois et 1 seconde, et soustrait 2 minutes\n";
- print " et 6 ans dans le mme temps.\n";
- } else {
- print "Please give an adjustment with this command:\n";
- print " Adjustment value (-1, 1, +1, etc...)\n";
- print " Modified element:\n";
- print " a or y: year\n";
- print " m: month\n";
- print " j or d: day\n";
- print " h: hour\n";
- print " mn: minute\n";
- print " s: second\n";
- print " <example> banadd testname +1m-2mn1s-6y\n";
- print " this example adds 1 month and 1 second, and substracts 2 minutes\n";
- print " and 6 years at the same time.\n";
- }
- return 137;
- }
- if ($year > 127 || $year < -127) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement d'annes correct (de -127 127), svp.\n";
- } else {
- print "Please give a correct adjustment for the years (from -127 to 127).\n";
- }
- return 137;
- }
- if ($month > 255 || $month < -255) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de mois correct (de -255 255), svp.\n";
- } else {
- print "Please give a correct adjustment for the months (from -255 to 255).\n";
- }
- return 137;
- }
- if ($day > 32767 || $day < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de jours correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the days (from -32767 to 32767).\n";
- }
- return 137;
- }
- if ($hour > 32767 || $hour < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement d'heures correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the hours (from -32767 to 32767).\n";
- }
- return 137;
- }
- if ($minute > 32767 || $minute < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de minutes correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the minutes (from -32767 to 32767).\n";
- }
- return 137;
- }
- if ($second > 32767 || $second < -32767) {
- if ($defaultlanguage eq "F") {
- print "Entrez un ajustement de secondes correct (de -32767 32767), svp.\n";
- } else {
- print "Please give a correct adjustment for the seconds (from -32767 to 32767).\n";
- }
- return 137;
- }
-
- print $so pack("va24vvvvvv", 0x794c, $userid, $year, $month, $day, $hour, $minute, $second);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x794d) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(32);
- my(@dat) = unpack("Va24V", $buf);
- while (length($dat[1]) > 0 && substr($dat[1], length($dat[1])-1, 1) eq chr(0)) {
- chop($dat[1]);
- };
- if ($dat[0] == -1 || $dat[0] == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Echec du changement de la date finale de banissement du compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Account [$userid] final date of banishment changing failed. Account doesn't exist.\n";
- }
- } else {
- if ($defaultlanguage eq "F") {
- print "Date finale de banissement du compte [$dat[1]][id: $dat[0]] change avec succs ".
- ($dat[2] == 0 ? "en [d-bannie].\n" : "pour tre jusqu'au ".(POSIX::ctime($dat[2])));
- } else {
- print "Final date of banishment of the account [$dat[1]][id: $dat[0]] successfully changed ".
- ($dat[2] == 0 ? "to [unbanished].\n" : "to be until ".(POSIX::ctime($dat[2])));
- }
- # localtime($dat[2]) is also possible to display instead of POSIX::ctime.
- }
-
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Request to displaying information about an account (by its name)
-sub whoaccount() {
- my($userid) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> who nomtest\n";
- } else {
- print "Please input an account name.\n";
- print "<example> who testname\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
-
- print $so pack("va24", 0x7952, $userid);
- $so->flush();
-
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7953) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 122;
- }
- my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148));
- my($memo) = "";
- if ($memo_size > 0) {
- $memo = unpack("a".$memo_size, readso($memo_size));
- }
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) {
- chop($error_message);
- };
- while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) {
- chop($last_login);
- };
- while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) {
- chop($last_ip);
- };
- while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) {
- chop($email);
- };
- while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) {
- chop($memo);
- };
-
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Impossible de trouver le compte [$userid]. Le compte n'existe pas.\n";
- } else {
- print "Unabled to find the account [$userid]. Account doesn't exist.\n";
- }
- return 123;
- } else {
- if ($defaultlanguage eq "F") {
- print "Le compte [$userid] a les caractristiques suivantes:\n";
- } else {
- print "The account [$userid] is set with:\n";
- }
- if ($GM_level == 0) {
- print " Id: $id2 (non-GM)\n";
- } else {
- if ($defaultlanguage eq "F") {
- print " Id: $id2 (GM niveau $GM_level)\n";
- } else {
- print " Id: $id2 (GM level $GM_level)\n";
- }
- }
- if ($defaultlanguage eq "F") {
- print " Nom: '$name'\n";
- print " Sexe: ".("Femme", "Male", "Serveur")[$sex]."\n";
- } else {
- print " Name: '$name'\n";
- print " Sex: ".("Female", "Male", "Server")[$sex]."\n";
- }
- print " E-mail: $email\n";
- if ($status == 7) {
- print " Statut: 7 [You are Prohibited to log in until $error_message]\n";
- } else {
- print " Statut: $status [".(
- ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
- "Unregistered ID",
- "Incorrect Password",
- "This ID is expired",
- "Rejected from Server",
- "You have been blocked by the GM Team",
- "Your Game's EXE file is not the latest version",
- "You are Prohibited to log in until %s",
- "Server is jammed due to over populated",
- "No MSG",
- "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n";
- }
- if ($defaultlanguage eq "F") {
- print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date)));
- print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n";
- print " Dernire connexion le: $last_login (ip: $last_ip)\n";
- print " Limite de validit: ".($validite == 0 ? "illimit.\n" : "jusqu'au ".(POSIX::ctime($validite)));
- } else {
- print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date)));
- print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n";
- print " Last connection at: $last_login (ip: $last_ip)\n";
- print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite)));
- }
- print " Memo: '$memo'\n";
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Request to displaying information about an account (by its id)
-sub infoaccount() {
- my($id) = @_;
- if ($id < 0) {
- if ($defaultlanguage eq "F") {
- print "Entrez un id ayant une valeur positive svp.\n";
- } else {
- print "Please input a positive value for the id.\n";
- }
- return 136;
- }
-
- print $so pack("vV", 0x7954, $id);
- $so->flush();
-
- $buf = readso(2);
- if (unpack("v", $buf) != 0x7953) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 122;
- }
- my($id2, $GM_level, $name, $sex, $count, $status, $error_message, $last_login, $last_ip, $email, $validite, $ban_date, $memo_size) = unpack("VCa24cVVa20a24a16a40VVv", readso(148));
- my($memo) = "";
- if ($memo_size > 0) {
- $memo = unpack("a".$memo_size, readso($memo_size));
- }
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- while (length($error_message) > 0 && substr($error_message, length($error_message)-1, 1) eq chr(0)) {
- chop($error_message);
- };
- while (length($last_login) > 0 && substr($last_login, length($last_login)-1, 1) eq chr(0)) {
- chop($last_login);
- };
- while (length($last_ip) > 0 && substr($last_ip, length($last_ip)-1, 1) eq chr(0)) {
- chop($last_ip);
- };
- while (length($email) > 0 && substr($email, length($email)-1, 1) eq chr(0)) {
- chop($email);
- };
- while (length($memo) > 0 && substr($memo, length($memo)-1, 1) eq chr(0)) {
- chop($memo);
- };
-
- if (length($name) == 0 || $name eq "") {
- if ($defaultlanguage eq "F") {
- print "Impossible de trouver le nom du compte [id: $id2]. Le compte n'existe pas.\n";
- } else {
- print "Unabled to find the account [id: $id2] name. Account doesn't exist.\n";
- }
- return 123;
- } else {
- if ($defaultlanguage eq "F") {
- print "Le compte [id: $id2] a les caractristiques suivantes:\n";
- } else {
- print "The account [id: $id2] is set with:\n";
- }
- if ($GM_level == 0) {
- print " Id: $id2 (non-GM)\n";
- } else {
- if ($defaultlanguage eq "F") {
- print " Id: $id2 (GM niveau $GM_level)\n";
- } else {
- print " Id: $id2 (GM level $GM_level)\n";
- }
- }
- if ($defaultlanguage eq "F") {
- print " Nom: '$name'\n";
- print " Sexe: ".("Femme", "Male", "Serveur")[$sex]."\n";
- } else {
- print " Name: '$name'\n";
- print " Sex: ".("Female", "Male", "Server")[$sex]."\n";
- }
- print " E-mail: $email\n";
- if ($status == 7) {
- print " Statut: 7 [You are Prohibited to log in until $error_message]\n";
- } else {
- print " Statut: $status [".(
- ($defaultlanguage eq "F" ? "Compte Ok" : "Account OK"),
- "Unregistered ID",
- "Incorrect Password",
- "This ID is expired",
- "Rejected from Server",
- "You have been blocked by the GM Team",
- "Your Game's EXE file is not the latest version",
- "You are Prohibited to log in until %s",
- "Server is jammed due to over populated",
- "No MSG",
- "This ID is totally erased")[$status == 100 ? 10 : $status]."]\n";
- }
- if ($defaultlanguage eq "F") {
- print " Banissement: ".($ban_date == 0 ? "non banni.\n" : "jusqu'au ".(POSIX::ctime($ban_date)));
- print " Compteur: $count connexion".("s", "")[$count > 1 ? 0 : 1]."\n";
- print " Dernire connexion le: $last_login (ip: $last_ip)\n";
- print " Limite de validit: ".($validite == 0 ? "illimit.\n" : "jusqu'au ".(POSIX::ctime($validite)));
- } else {
- print " Banishment: ".($ban_date == 0 ? "not banished.\n" : "until ".(POSIX::ctime($ban_date)));
- print " Count: $count connection".("s", "")[$count > 1 ? 0 : 1]."\n";
- print " Last connection at: $last_login (ip: $last_ip)\n";
- print " Validity limit: ".($validite == 0 ? "unlimited.\n" : "until ".(POSIX::ctime($validite)));
- }
- print " Memo: '$memo'\n";
- }
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Check the validity of a password
-# (Note: never send back a password with login-server!! security of passwords)
-sub checkaccount() {
- my($userid, $passwd) = @_;
- if ($userid eq "") {
- if ($defaultlanguage eq "F") {
- print "Entrez un nom de compte svp.\n";
- print "<exemple> check testname motdepasse\n";
- } else {
- print "Please input an account name.\n";
- print "<example> check testname password\n";
- }
- return 136;
- }
- if (verify_accountname($userid) == 0) {
- return 102;
- }
- if ($passwd eq "") {
- return 134 if (($passwd = typepasswd()) eq "");
- }
- if (verify_password($passwd) == 0) {
- return 131;
- }
- print $so pack("va24a24", 0x793a, $userid,$passwd);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x793b) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 132;
- }
- $buf = readso(28);
- my($id2, $name) = unpack("Va24", $buf);
- while (length($name) > 0 && substr($name, length($name)-1, 1) eq chr(0)) {
- chop($name);
- };
- if ($id2 == -1 || $id2 == 4294967295) {
- if ($defaultlanguage eq "F") {
- print "Le compte [$userid] n'existe pas ou le mot de passe est incorrect.\n";
- } else {
- print "The account [$userid] doesn't exist or the password is incorrect.\n";
- }
- return 133;
- } else {
- if ($defaultlanguage eq "F") {
- print "Le mot de passe donn correspond bien au compte [$name][id: $id2].\n";
- } else {
- print "The proposed password is correct for the account [$name][id: $id2].\n";
- }
- }
- return 130;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Request to login-server to reload GM configuration file
-sub reloadGM() {
- print $so pack("v", 0x7955);
- $so->flush();
- if ($defaultlanguage eq "F") {
- print "Demande de recharger le fichier de configuration des GM envoye.\n";
- print "Vrifiez les comptes GM actuels (aprs rechargement):\n";
- } else {
- print "Request to reload the GM configuration file sended.\n";
- print "Check the actual GM accounts (after reloading):\n";
- }
- &listaccount(0, 0, 1); # 1: to list only GM
- return 180;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Send a broadcast message
-sub sendbroadcast() {
- my($type, $message) = @_;
- if ($message eq "" || length($message) == 0) {
- if ($defaultlanguage eq "F") {
- print "Entrez un message svp.\n";
- if ($type == 0) {
- print "<exemple> kami un message\n";
- } else {
- print "<exemple> kamib un message\n";
- }
- } else {
- print "Please input a message.\n";
- if ($type == 0) {
- print "<example> kami a message\n";
- } else {
- print "<example> kamib a message\n";
- }
- }
- return 136;
- }
-
- print $so pack("vvVa".length($message), 0x794e, $type, length($message), $message);
- $so->flush();
- $buf = readso(2);
- if (unpack("v", $buf) != 0x794f) {
- if ($defaultlanguage eq "F") {
- print "Problme de connexion au serveur (rponse incorrecte).\n";
- } else {
- print "Connection error to the server (incorrect answer).\n";
- }
- return 152;
- }
- $buf = readso(2);
- my($answer) = unpack("v", $buf);
- if ($answer == -1 || $answer == 65535) {
- if ($defaultlanguage eq "F") {
- print "Echec de l'envoi du message. Aucun server de char en ligne.\n";
- } else {
- print "Message sending failed. No online char-server.\n";
- }
- } else {
- if ($defaultlanguage eq "F") {
- print "Message transmis au server de logins avec succs.\n";
- } else {
- print "Message successfully sended to login-server.\n";
- }
- }
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Change language of displaying
-sub changelanguage() {
- my($language) = @_;
- if ($language eq "" || length($language) == 0) {
- if ($defaultlanguage == 'F') {
- printf("Entrez une langue svp.\n");
- printf("<exemple> language english\n");
- printf(" language franais\n");
- } else {
- printf("Please input a language.\n");
- printf("<example> language english\n");
- printf(" language franais\n");
- }
- return 136;
- }
-
- $language = uc(substr($language, 0, 1));
- if ($language =~ /^[EF]$/) {
- $defaultlanguage = $language;
- if ($defaultlanguage == 'F') {
- printf("Changement de la langue d'affichage en Franais.\n");
- } else {
- printf("Displaying language changed to English.\n");
- }
- } else {
- if ($defaultlanguage == 'F') {
- printf("Langue non paramtre (langues possibles: 'Franais' ou 'English').\n");
- } else {
- printf("Undefined language (possible languages: Franais or English).\n");
- }
- }
-
- return 0;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: sending 'end of connection' packet
-sub quit() {
- print $so pack("v", 0x7532);
- $so->flush();
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Get datas from the socket
-sub readso() {
- my($len) = shift;
- my($buf);
- if (read($so, $buf, $len) < $len) {
- if ($defaultlanguage eq "F") {
- print "Erreur de lecture sur la Socket.\n";
- } else {
- print "Socket read error.\n";
- }
- exit(3);
- }
- return $buf;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Input of a password
-sub typepasswd {
- my($passwd1, $passwd2);
- cbreak();
- if ($defaultlanguage eq "F") {
- print "Entrez le mot de passe > "; $passwd1 = <STDIN>; chomp($passwd1); print "\n";
- print "R-entrez le mot de passe > "; $passwd2 = <STDIN>; chomp($passwd2); print "\n";
- } else {
- print "Type the password > "; $passwd1 = <STDIN>; chomp($passwd1); print "\n";
- print "Verify the password > "; $passwd2 = <STDIN>; chomp($passwd2); print "\n";
- }
- cooked();
- if ($passwd1 ne $passwd2) {
- if ($defaultlanguage eq "F") {
- print "Erreur de vrification du mot de passe: Saisissez le mme mot de passe svp.\n";
- } else {
- print "Password verification failed. Please input same password.\n";
- }
- return "";
- }
- return $passwd1;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Return ordonal text of a number
-sub makeordinal {
- my($c) = shift;
- if ($defaultlanguage eq "F") {
- if ($c < 1) {
- return $c;
- }
- return $c.("er", "me")[$c == 1 ? 0 : 1];
- } else {
- if ($c % 10 < 4 && $c % 10 != 0 && ($c < 10 || $c > 20)) {
- return $c.("st","nd","rd")[$c % 10 - 1];
- }
- return $c."th";
- }
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Test of the validity of an account name (return 0 if incorrect, and 1 if ok)
-sub verify_accountname {
- my($account_name) = @_; # Get the account_name
- if ($account_name =~ /[\x00-\x1f]/) { # remove control char
- my($c) = length($`) + 1;
- if ($defaultlanguage eq "F") {
- print "Caractre interdit trouv dans le nom du compte (".makeordinal($c)." caractre).\n";
- } else {
- print "Illegal character found in the account name (".makeordinal($c)." character).\n";
- }
- return 0;
- }
- if (length($account_name) < 4) {
- if ($defaultlanguage eq "F") {
- print "Nom du compte trop court. Entrez un nom de compte de 4-23 caractres.\n";
- } else {
- print "Account name is too short. Please input an account name of 4-23 bytes.\n";
- }
- return 0;
- }
- if (length($account_name) > 23) {
- if ($defaultlanguage eq "F") {
- print "Nom du compte trop long. Entrez un nom de compte de 4-23 caractres.\n";
- } else {
- print "Account name is too long. Please input an account name of 4-23 bytes.\n";
- }
- return 0;
- }
- return 1;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Test of the validity of password (return 0 if incorrect, and 1 if ok)
-sub verify_password {
- my($password) = @_; # Get the password
- if ($password =~ /[\x00-\x1f]/) {
- my($c) = length($`) + 1;
- if ($defaultlanguage eq "F") {
- print "Caractre interdit trouv dans le mot de passe (".makeordinal($c)." caractre).\n";
- } else {
- print "Illegal character found in the password (".makeordinal($c)." character).\n";
- }
- return 0;
- }
- if (length($password) < 4) {
- if ($defaultlanguage eq "F") {
- print "Mot de passe trop court. Entrez un mot de passe de 4-23 caractres.\n";
- } else {
- print "Password is too short. Please input a password of 4-23 bytes.\n";
- }
- return 0;
- }
- if (length($password) > 23) {
- if ($defaultlanguage eq "F") {
- print "Mot de passe trop long. Entrez un mot de passe de 4-23 caractres.\n";
- } else {
- print "Password is too long. Please input a password of 4-23 bytes.\n";
- }
- return 0;
- }
- return 1;
-}
-
-#--------------------------------------------------------------------------
-
-# Sub-function: Test of the validity of an e-mail (return 0 if incorrect, and 1 if ok)
-sub verify_email {
- my($email) = @_; # Get the e-mail
- # To ignore a '.' before the @ (wanadoo, a provider, do that)
- $email =~ s/\.\@/\@/;
- # If the e-mail is void, it's not correct -> return 0
- if ($email eq '') {
- return(0);
- }
- # If the e-mail have no "@", it's not correct -> return 0
- if ($email !~ /\@/) {
- return(0);
- }
- # If the e-mail have a ",", a space, a tab or a ";", it's not correct -> return 0
- if ($email =~ /[\,|\s|\;]/) {
- return(0)
- };
- # IF
- # (the e-mail contains 2 "@", or ".." or "@." or starts or finishes by a ".")
- # OR IF
- # (the e-mail doesn't contain "@localhost" AND
- # - it doesn't contain characters followed by "@" itself followed by letters itself followed by "." and 2 or more letters
- # - or an IP address)
- # -> so, it's not good ! (finish !)
- if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ ||
- ($email !~ /^.+\@localhost$/ &&
- $email !~ /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}|[0-9]{1,3}\]?$/)) {
- return(0); # non-valid email
- } else {
- # If not, the e-email address is correct
- return(1); # valid email
- }
-} \ No newline at end of file
diff --git a/src/tool/mapcheck.sh b/src/tool/mapcheck.sh
deleted file mode 100644
index 337884c..0000000
--- a/src/tool/mapcheck.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-echo "============================================"
-echo "= map server status checker... ="
-echo "============================================"
-./map-server.exe &
-sleep 40
-
-while [ 0 ]
-do
- pcpu=` top -n 1| grep map-server | awk '{print $9}' | awk 'BEGIN{FS="."} {print $1}' `
- if [ "$pcpu" -gt 80 ];then
- echo "============================================"
- echo "map server is more than 80% (now $pcpu%)"
- echo "============================================"
- ppid=` ps -a | grep map-server | awk '{print $1}' `
- kill $ppid
- ./map-server.exe &
- sleep 40
- else
- pmapct=` ps -a| grep map-server | wc -l `
- if [ "$pmapct" -eq 0 ];then
- echo "============================================"
- echo "map server is not running..."
- echo "restart map server..."
- echo "============================================"
- ./map-server.exe &
- sleep 40
- #echo "test"
- else
- echo "map server is ok (now $pcpu%)..."
- sleep 5
- fi
- fi
-done \ No newline at end of file
diff --git a/src/tool/mapchecker.sh b/src/tool/mapchecker.sh
deleted file mode 100644
index 7250c34..0000000
--- a/src/tool/mapchecker.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-athena_dir="/home/athena/658/"
-
-while [ true ] ; do
-
-if [ ` ps fauxw | grep map-server | grep -v grep | wc -l ` -eq 0 ];then
- #echo `date` " -- map-server crashed - restarting"
- echo `date` " -- map-server crashed - restarting" >> /var/log/athena_status.log
- killall -9 map-server
- cd $athena_dir
- nohup ./map-server ./conf/map_athena.conf ./inter_athena.conf &
- sleep 240
- #sleep 40 #for fast pc's remove the "#" at the beginning of the line and delete the line above
-fi
-
-
-if [ ` ps fauxw | grep map-server | grep -v grep | awk '{print $3}' | awk 'BEGIN{FS="."} {print $1}' ` -gt 10 ];then
- #echo `date` " -- mapserver cpuload over 10 - restarting"
- echo `date` " -- mapserver cpuload over 10 - restarting" >> /var/log/athena_status.log
- killall -9 map-server
- cd $athena_dir
- nohup ./map-server ./conf/map_athena.conf ./inter_athena.conf &
- sleep 240
- #sleep 40 #for fast pc's remove the "#" at the beginning of the line and delete the line above
- #echo `date` " -- restarted"
- echo `date` " -- restarted" >> /var/log/athena_status.log
-fi
-
-if [ ` ps fauxw | grep char-server | grep -v grep | wc -l ` -eq 0 ];then
- #echo `date` " -- char server crashed - restarting"
- echo `date` " -- char server crashed - restarting" >> /var/log/athena_status.log
- killall -9 char-server
- cd $athena_dir
- nohup ./char-server ./conf/char_athena.conf ./conf/inter_athena.conf &
- #echo `date` " -- restarted"
- echo `date` " -- restarted" >> /var/log/athena_status.log
-
-fi
-
-if [ ` ps fauxw | grep login-server | grep -v grep | wc -l ` -eq 0 ];then
- #echo `date` " -- login server crashed - restarting"
- echo `date` " -- login server crashed - restarting" >> /var/log/athena_status.log
- killall -9 login-server
- cd $athena_dir
- nohup ./login-server ./conf/login_athena.conf &
- #echo `date` " -- restarted"
- echo `date` " -- restarted" >> /var/log/athena_status.log
-
-fi
-
-
-#echo `date` " -- everything is fine"
-echo `date` " -- everything is fine" >> /var/log/athena_status.log
-sleep 30
-done
diff --git a/src/tool/mapfrob.cpp b/src/tool/mapfrob.cpp
deleted file mode 100644
index 8663ae0..0000000
--- a/src/tool/mapfrob.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-// Compile with
-// gcc -m32 -I src/char -I src/common charfrob.c -o charfrob src/common/timer.o src/common/malloc.o src/common/socket.o src/common/lock.o src/common/db.o src/char/int_pet.o src/char/int_storage.o src/char/inter.o src/char/int_party.o src/char/int_guild.o
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../common/mmo.hpp"
-// Yes, this is intentional
-#include "../char/char.cpp"
-
-// Well, this is not terribly elegant, but I don't have that much time.
-#define MAX_MAP 1024
-#define MAP_NAME_SIZE 32
-int maps_nr = 0;
-struct
-{
- char old[MAP_NAME_SIZE], new[MAP_NAME_SIZE];
-} maps[MAX_MAP];
-
-void transform_point (struct point *p)
-{
- int k;
-
- if (!p->map[0])
- return;
-
- for (k = 0; k < maps_nr; k++)
- if (!strcmp (p->map, maps[k].old))
- {
- strcpy (p->map, maps[k].new);
- return;
- }
-
- fprintf (stderr, "Warning: untranslated map `%s'\n", p->map);
-}
-
-void transform_char (struct mmo_charstatus *p)
-{
- int i;
-
- transform_point (&p->last_point);
- transform_point (&p->save_point);
-
- for (i = 0; i < 10; i++)
- transform_point (&p->memo_point[i]);
-}
-
-int mmo_char_convert ()
-{
- char line[965536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp, *ofp;
-
- ifp = stdin;
- ofp = stdout;
- while (fgets (line, 65535, ifp))
- {
- memset (&char_dat, 0, sizeof (struct mmo_charstatus));
- ret = mmo_char_fromstr (line, &char_dat);
- if (ret)
- {
- transform_char (&char_dat);
- mmo_char_tostr (line, &char_dat);
- fprintf (ofp, "%s\n", line);
- }
- }
- return 0;
-}
-
-#define PARSE_MODE_NEXTNUM 0
-#define PARSE_MODE_RANGE 1
-
-int init (int count, char **translates)
-{
- int i;
- char *suffix = ".gat";
-
- for (i = 0; i < count; i++)
- {
- char *src = translates[i];
- char *dest = strchr (src, ':');
-
- if (!dest)
- {
- fprintf (stderr, "Missing colon in: `%s'\n", src);
- return 1;
- }
-
- *dest++ = 0;
-
- if (strlen (src) + strlen (suffix) >= MAP_NAME_SIZE)
- {
- fprintf (stderr, "Map name prefix too long: `%s'\n", src);
- return 1;
- }
-
- if (strlen (dest) + strlen (suffix) >= MAP_NAME_SIZE)
- {
- fprintf (stderr, "Map name prefix too long: `%s'\n", dest);
- return 1;
- }
-
- strncpy (maps[maps_nr].old, src, MAP_NAME_SIZE);
- strcat (maps[maps_nr].old, suffix);
- strncpy (maps[maps_nr].new, dest, MAP_NAME_SIZE);
- strcat (maps[maps_nr].new, suffix);
-
- ++maps_nr;
- }
-
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- if (argc < 2)
- {
- printf ("Usage: %s oldmap0:newmap0 oldmap1:newmap1 ...\n", argv[0]);
- printf ("e.g., %s new_1-1:001-2 new_2-1:001-1\n", argv[0]);
- puts ("The extension `.gat' is appended implicitly.");
- exit (0);
- }
- if (init (argc - 1, argv + 1))
- return 1;
-
- mmo_char_convert ();
-
- return 0;
-}
diff --git a/src/tool/marriage-info.cpp b/src/tool/marriage-info.cpp
deleted file mode 100644
index 3552a9b..0000000
--- a/src/tool/marriage-info.cpp
+++ /dev/null
@@ -1,482 +0,0 @@
-/* To build:
-gcc -O2 -m32 -Isrc/common -Isrc/char -Isrc/map -Isrc/login -o marriage-info \
-marriage-info.c src/common/socket.o src/common/timer.o src/common/db.o \
-src/common/lock.o src/common/malloc.o src/char/int_guild.o \
-src/char/int_party.o src/char/int_storage.o src/char/inter.o
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../login/login.hpp"
-#include "../common/mmo.hpp"
-// Yes, this is intentional
-#include "../char/char.cpp"
-
-int mode;
-#define MODE_MARRIED 0
-#define MODE_SINGLES_F 1
-#define MODE_SINGLES_M 2
-#define MODE_SINGLES_A 3
-
-#define CHUNK_SIZE 1024
-
-/* chunked list to represent leaves */
-typedef struct {
- int char_id;
- int exp;
- char name[24];
- unsigned char level;
- unsigned char sex;
-} char_leaf_t;
-
-/* Chunks are in descending order, but chars are in ascending order */
-typedef struct chunklist_node {
- int size;
- char_leaf_t chars[CHUNK_SIZE];
- struct chunklist_node *next;
-} chunklist_node_t;
-
-chunklist_node_t *list = NULL;
-
-static void
-insert(chunklist_node_t **listp, struct mmo_charstatus *p)
-{
- chunklist_node_t *chunk = *listp;
- char_leaf_t *l;
-
- if ((chunk && chunk->size == CHUNK_SIZE)
- || (!chunk)) {
- chunk = malloc(sizeof(chunklist_node_t));
- chunk->size = 0;
- chunk->next = *listp;
- *listp = chunk;
- }
-
- l = &chunk->chars[chunk->size++];
-
- l->char_id = p->char_id;
- l->level = p->base_level;
- l->exp = p->base_exp;
- l->sex = p->sex;
- strcpy(l->name, p->name);
-}
-
-static int
-compare_leaf(const void *l, const void *r)
-{
- return ((char_leaf_t *)l)->char_id - ((char_leaf_t *)r)->char_id;
-}
-
-static char_leaf_t *
-find(chunklist_node_t *list, int char_id)
-{
- if (!list)
- return NULL; /* fatal error */
- else {
- int start = list->chars[0].char_id;
- int stop = list->chars[list->size - 1].char_id;
-
- if (char_id >= start && char_id <= stop) { /* in this chunk */
- char_leaf_t key;
- key.char_id = char_id;
- return (char_leaf_t *)
- bsearch(&key, &list->chars, list->size, sizeof(char_leaf_t),
- compare_leaf);
- }
- else find(list->next, char_id);
- }
-}
-
-
-void /* replace blanks with percent signs */
-namefrob(char *n)
-{
- while (*n++) /* can't start with a blank */
- if (*n == ' ')
- *n = '%';
-}
-
-/*
---------------------------------------------------------------------------------
- Copied and pasted due to lacking modularity
-*/
-
-char account_filename[1024] = "save/account.txt";
-int account_id_count = START_ACCOUNT_NUM;
-
-struct auth_dat {
- int account_id, sex;
- char userid[24], pass[24], lastlogin[24];
- int logincount;
- int state;
- char email[40];
- char error_message[20];
- time_t ban_until_time;
- time_t connect_until_time;
- char last_ip[16];
- char memo[255];
- int account_reg2_num;
- struct global_reg account_reg2[ACCOUNT_REG2_NUM];
-} *auth_dat;
-
-int auth_num = 0, auth_max = 0;
-
-
-/*
- Reading of the accounts database
-*/
-int mmo_auth_init(void) {
- FILE *fp;
- int account_id, logincount, state, n, i, j, v;
- char line[2048], *p, userid[2048], pass[2048], lastlogin[2048], sex, email[2048], error_message[2048], last_ip[2048], memo[2048];
- time_t ban_until_time;
- time_t connect_until_time;
- char str[2048];
- int GM_count = 0;
- int server_count = 0;
-
- auth_dat = calloc(sizeof(struct auth_dat) * 256, 1);
- auth_max = 256;
-
- fp = fopen(account_filename, "r");
- if (fp == NULL) {
- printf("\033[1;31mmmo_auth_init: Accounts file [%s] not found.\033[0m\n", account_filename);
- return 0;
- }
-
- while(fgets(line, sizeof(line)-1, fp) != NULL) {
- if (line[0] == '/' && line[1] == '/')
- continue;
- line[sizeof(line)-1] = '\0';
- p = line;
-
- if (((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t"
- "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]\t%ld%n",
- &account_id, userid, pass, lastlogin, &sex, &logincount, &state,
- email, error_message, &connect_until_time, last_ip, memo, &ban_until_time, &n)) == 13 && line[n] == '\t') ||
- ((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t"
- "%[^\t]\t%[^\t]\t%ld\t%[^\t]\t%[^\t]%n",
- &account_id, userid, pass, lastlogin, &sex, &logincount, &state,
- email, error_message, &connect_until_time, last_ip, memo, &n)) == 12 && line[n] == '\t')) {
- n = n + 1;
-
- if (account_id > END_ACCOUNT_NUM) {
- continue;
- }
- userid[23] = '\0';
- remove_control_chars(userid);
- for(j = 0; j < auth_num; j++) {
- if (auth_dat[j].account_id == account_id) {
- break;
- } else if (strcmp(auth_dat[j].userid, userid) == 0) {
- break;
- }
- }
- if (j != auth_num)
- continue;
-
- if (auth_num >= auth_max) {
- auth_max += 256;
- auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max);
- }
-
- memset(&auth_dat[auth_num], '\0', sizeof(struct auth_dat));
-
- auth_dat[auth_num].account_id = account_id;
-
- strncpy(auth_dat[auth_num].userid, userid, 24);
-
- pass[23] = '\0';
- remove_control_chars(pass);
- strncpy(auth_dat[auth_num].pass, pass, 24);
-
- lastlogin[23] = '\0';
- remove_control_chars(lastlogin);
- strncpy(auth_dat[auth_num].lastlogin, lastlogin, 24);
-
- auth_dat[auth_num].sex = (sex == 'S' || sex == 's') ? 2 : (sex == 'M' || sex == 'm');
-
- if (logincount >= 0)
- auth_dat[auth_num].logincount = logincount;
- else
- auth_dat[auth_num].logincount = 0;
-
- if (state > 255)
- auth_dat[auth_num].state = 100;
- else if (state < 0)
- auth_dat[auth_num].state = 0;
- else
- auth_dat[auth_num].state = state;
-
- if (e_mail_check(email) == 0) {
- strncpy(auth_dat[auth_num].email, "a@a.com", 40);
- } else {
- remove_control_chars(email);
- strncpy(auth_dat[auth_num].email, email, 40);
- }
-
- error_message[19] = '\0';
- remove_control_chars(error_message);
- if (error_message[0] == '\0' || state != 7) {
- strncpy(auth_dat[auth_num].error_message, "-", 20);
- } else {
- strncpy(auth_dat[auth_num].error_message, error_message, 20);
- }
-
- if (i == 13)
- auth_dat[auth_num].ban_until_time = ban_until_time;
- else
- auth_dat[auth_num].ban_until_time = 0;
-
- auth_dat[auth_num].connect_until_time = connect_until_time;
-
- last_ip[15] = '\0';
- remove_control_chars(last_ip);
- strncpy(auth_dat[auth_num].last_ip, last_ip, 16);
-
- memo[254] = '\0';
- remove_control_chars(memo);
- strncpy(auth_dat[auth_num].memo, memo, 255);
-
- for(j = 0; j < ACCOUNT_REG2_NUM; j++) {
- p += n;
- if (sscanf(p, "%[^\t,],%d %n", str, &v, &n) != 2) {
- if (p[0] == ',' && sscanf(p, ",%d %n", &v, &n) == 1) {
- j--;
- continue;
- } else
- break;
- }
- str[31] = '\0';
- remove_control_chars(str);
- strncpy(auth_dat[auth_num].account_reg2[j].str, str, 32);
- auth_dat[auth_num].account_reg2[j].value = v;
- }
- auth_dat[auth_num].account_reg2_num = j;
-
- if (isGM(account_id) > 0)
- GM_count++;
- if (auth_dat[auth_num].sex == 2)
- server_count++;
-
- auth_num++;
- if (account_id >= account_id_count)
- account_id_count = account_id + 1;
-
- } else if ((i = sscanf(line, "%d\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%d\t%d\t%n",
- &account_id, userid, pass, lastlogin, &sex, &logincount, &state, &n)) >= 5) {
- if (account_id > END_ACCOUNT_NUM) {
- continue;
- }
- userid[23] = '\0';
- remove_control_chars(userid);
- for(j = 0; j < auth_num; j++) {
- if (auth_dat[j].account_id == account_id) {
- break;
- } else if (strcmp(auth_dat[j].userid, userid) == 0) {
- break;
- }
- }
- if (j != auth_num)
- continue;
-
- if (auth_num >= auth_max) {
- auth_max += 256;
- auth_dat = realloc(auth_dat, sizeof(struct auth_dat) * auth_max);
- }
-
- memset(&auth_dat[auth_num], '\0', sizeof(struct auth_dat));
-
- auth_dat[auth_num].account_id = account_id;
-
- strncpy(auth_dat[auth_num].userid, userid, 24);
-
- pass[23] = '\0';
- remove_control_chars(pass);
- strncpy(auth_dat[auth_num].pass, pass, 24);
-
- lastlogin[23] = '\0';
- remove_control_chars(lastlogin);
- strncpy(auth_dat[auth_num].lastlogin, lastlogin, 24);
-
- auth_dat[auth_num].sex = (sex == 'S' || sex == 's') ? 2 : (sex == 'M' || sex == 'm');
-
- if (i >= 6) {
- if (logincount >= 0)
- auth_dat[auth_num].logincount = logincount;
- else
- auth_dat[auth_num].logincount = 0;
- } else
- auth_dat[auth_num].logincount = 0;
-
- if (i >= 7) {
- if (state > 255)
- auth_dat[auth_num].state = 100;
- else if (state < 0)
- auth_dat[auth_num].state = 0;
- else
- auth_dat[auth_num].state = state;
- } else
- auth_dat[auth_num].state = 0;
-
- strncpy(auth_dat[auth_num].email, "a@a.com", 40);
- strncpy(auth_dat[auth_num].error_message, "-", 20);
- auth_dat[auth_num].ban_until_time = 0;
- auth_dat[auth_num].connect_until_time = 0;
- strncpy(auth_dat[auth_num].last_ip, "-", 16);
- strncpy(auth_dat[auth_num].memo, "-", 255);
-
- for(j = 0; j < ACCOUNT_REG2_NUM; j++) {
- p += n;
- if (sscanf(p, "%[^\t,],%d %n", str, &v, &n) != 2) {
- if (p[0] == ',' && sscanf(p, ",%d %n", &v, &n) == 1) {
- j--;
- continue;
- } else
- break;
- }
- str[31] = '\0';
- remove_control_chars(str);
- strncpy(auth_dat[auth_num].account_reg2[j].str, str, 32);
- auth_dat[auth_num].account_reg2[j].value = v;
- }
- auth_dat[auth_num].account_reg2_num = j;
-
- if (isGM(account_id) > 0)
- GM_count++;
- if (auth_dat[auth_num].sex == 2)
- server_count++;
-
- auth_num++;
- if (account_id >= account_id_count)
- account_id_count = account_id + 1;
-
- } else {
- i = 0;
- if (sscanf(line, "%d\t%%newid%%\n%n", &account_id, &i) == 1 &&
- i > 0 && account_id > account_id_count)
- account_id_count = account_id;
- }
- }
- fclose(fp);
-
- if (auth_num == 0) {
- sprintf(line, "No account found in %s.", account_filename);
- } else {
- if (auth_num == 1) {
- sprintf(line, "1 account read in %s,", account_filename);
- } else {
- sprintf(line, "%d accounts read in %s,", auth_num, account_filename);
- }
- if (GM_count == 0) {
- sprintf(str, "%s of which is no GM account and", line);
- } else if (GM_count == 1) {
- sprintf(str, "%s of which is 1 GM account and", line);
- } else {
- sprintf(str, "%s of which is %d GM accounts and", line, GM_count);
- }
- if (server_count == 0) {
- sprintf(line, "%s no server account ('S').", str);
- } else if (server_count == 1) {
- sprintf(line, "%s 1 server account ('S').", str);
- } else {
- sprintf(line, "%s %d server accounts ('S').", str, server_count);
- }
- }
-
- return 0;
-}
-
-/*--------------------------------------------------------------------------------*/
-
-
-void
-mmo_check_dumpworthy(struct mmo_charstatus *p)
-{
- int i;
- namefrob(p->name);
-
- for (i = 0; i < auth_num; i++)
- if (auth_dat[i].account_id == p->account_id) {
- p->sex = auth_dat[i].sex;
- break;
- }
-
- if (p->partner_id) {
- if (mode != MODE_MARRIED)
- return;
-
- if (p->partner_id < p->char_id) {
- char_leaf_t *partner = find(list, p->partner_id);
- if (!partner)
- fprintf(stderr, "Char %d (%s)'s partner (%d) no longer available\n",
- p->char_id,
- p->name,
- p->partner_id);
- else
- printf ("%d\t%d\t%s\t%s\t%d\t%s\t%s\t%d--%d,%d\n",
- p->base_level + partner->level,
- p->base_exp + partner->exp,
- p->name, p->sex? "M" : "F", p->base_level,
- partner->name, partner->sex? "M" : "F", partner->level);
- } else {
- insert(&list, p);
- }
- } else if (p->sex == (mode - 1))
- printf("%d\t%d\t%s\n", p->base_level, p->base_exp, p->name);
- else if (mode == MODE_SINGLES_A)
- printf("%d\t%d\t%s\t%s\n", p->base_level, p->base_exp, p->name, p->sex? "M" : "F");
-}
-
-int mmo_char_dump()
-{
- char line[965536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp,*ofp;
-
- ifp=stdin;
- while(fgets(line,65535,ifp)){
- memset(&char_dat,0,sizeof(struct mmo_charstatus));
- ret=mmo_char_fromstr(line,&char_dat);
- if(ret){
- mmo_check_dumpworthy(&char_dat);
- }
- }
- return 0;
-}
-
-
-int init(char *mode_s)
-{
- if (!strcmp(mode_s, "-c"))
- mode = MODE_MARRIED;
- else if (!strcmp(mode_s, "-f"))
- mode = MODE_SINGLES_F;
- else if (!strcmp(mode_s, "-m"))
- mode = MODE_SINGLES_M;
- else if (!strcmp(mode_s, "-s"))
- mode = MODE_SINGLES_A;
- else {
- fprintf(stderr, "Unknown mode `%s'\n", mode_s);
- return 1;
- }
- return 0;
-}
-
-int main(int argc,char *argv[])
-{
- mmo_auth_init();
-
- if(argc < 2) {
- printf("Usage: %s <mode>\n", argv[0]);
- printf("Where <mode> is one of -c (couples), -s (singles), -f (female singles), -m (male singles)\n", argv[0]);
- exit(0);
- }
- if (init(argv[1]))
- return 1;
-
- mmo_char_dump();
-
- return 0;
-}
diff --git a/src/tool/marriage-info.sh b/src/tool/marriage-info.sh
deleted file mode 100755
index 2389d7f..0000000
--- a/src/tool/marriage-info.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#! /bin/sh
-
-cd ~/tmwserver
-
-cat save/athena.txt | sort -n > athena-sorted.txt
-
-printf "Top married couples\n===================\n" > ~/public_html/stats/married.txt
-cat athena-sorted.txt | ./marriage-info -c | sort -rn | awk '{printf "%d %s oo %s (%s (%s, %d), %s(%s, %d))\n", ++rank, $3, $6, $3, $4, $5, $6, $7, $8}' | tr '%' ' ' >> ~/public_html/stats/married.txt
-
-printf "Top female singles\n==================\n" > ~/public_html/stats/female-singles.txt
-cat athena-sorted.txt | ./marriage-info -f | sort -rn | awk '{printf "%d %s(%d)\n", ++rank, $3, $1}' | tr '%' ' ' | head -50 >> ~/public_html/stats/female-singles.txt
-
-printf "Top male singles\n===============\n" > ~/public_html/stats/male-singles.txt
-cat athena-sorted.txt | ./marriage-info -m | sort -rn | awk '{printf "%d %s(%d)\n", ++rank, $3, $1}' | tr '%' ' ' | head -50 >> ~/public_html/stats/male-singles.txt
-
-printf "Top singles\n===============\n" > ~/public_html/stats/singles.txt
-cat athena-sorted.txt | ./marriage-info -s | sort -rn | awk '{printf "%d %s(%s, %d)\n", ++rank, $3, $4, $1}' | tr '%' ' ' | head -50 >> ~/public_html/stats/singles.txt
-
-rm athena-sorted.txt
-
diff --git a/src/tool/moneycount/athena_text.cpp b/src/tool/moneycount/athena_text.cpp
deleted file mode 100644
index 8cf5457..0000000
--- a/src/tool/moneycount/athena_text.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-#include "athena_text.hpp"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "mmo.hpp"
-
-//-------------------------------------------------------------------------
-// Function to set the character from the line (at read of characters file)
-//-------------------------------------------------------------------------
-int mmo_char_fromstr (char *str, struct mmo_charstatus *p)
-{
- int tmp_int[256];
- int set, next, len, i;
-
- // initilialise character
- memset (p, '\0', sizeof (struct mmo_charstatus));
-
- // If it's not char structure of version 1008 and after
- if ((set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, //
- &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], //
- &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], p->last_point.map, &tmp_int[35], &tmp_int[36], //
- p->save_point.map, &tmp_int[37], &tmp_int[38],
- &tmp_int[39], &next)) != 43)
- {
- tmp_int[39] = 0; // partner id
- // If not char structure from version 384 to 1007
- if ((set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, //
- &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], //
- &tmp_int[24], &tmp_int[25], &tmp_int[26], &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], p->last_point.map, &tmp_int[35], &tmp_int[36], //
- p->save_point.map, &tmp_int[37], &tmp_int[38],
- &next)) != 42)
- {
- // It's char structure of a version before 384
- tmp_int[26] = 0; // pet id
- set = sscanf (str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" "\t%[^,],%d,%d\t%[^,],%d,%d%n", &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, //
- &tmp_int[3], &tmp_int[4], &tmp_int[5], &tmp_int[6], &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12], &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18], &tmp_int[19], &tmp_int[20], &tmp_int[21], &tmp_int[22], &tmp_int[23], //
- &tmp_int[24], &tmp_int[25], //
- &tmp_int[27], &tmp_int[28], &tmp_int[29], &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34], p->last_point.map, &tmp_int[35], &tmp_int[36], //
- p->save_point.map, &tmp_int[37], &tmp_int[38],
- &next);
- set += 2;
- //printf("char: old char data ver.1\n");
- // Char structure of version 1007 or older
- }
- else
- {
- set++;
- //printf("char: old char data ver.2\n");
- }
- // Char structure of version 1008+
- }
- else
- {
- //printf("char: new char data ver.3\n");
- }
- if (set != 43)
- return 0;
-
- p->char_id = tmp_int[0];
- p->account_id = tmp_int[1];
- p->char_num = tmp_int[2];
- p->classb = tmp_int[3];
- p->base_level = tmp_int[4];
- p->job_level = tmp_int[5];
- p->base_exp = tmp_int[6];
- p->job_exp = tmp_int[7];
- p->zeny = tmp_int[8];
- p->hp = tmp_int[9];
- p->max_hp = tmp_int[10];
- p->sp = tmp_int[11];
- p->max_sp = tmp_int[12];
- p->str = tmp_int[13];
- p->agi = tmp_int[14];
- p->vit = tmp_int[15];
- p->int_ = tmp_int[16];
- p->dex = tmp_int[17];
- p->luk = tmp_int[18];
- p->status_point = tmp_int[19];
- p->skill_point = tmp_int[20];
- p->option = tmp_int[21];
- p->karma = tmp_int[22];
- p->manner = tmp_int[23];
- p->party_id = tmp_int[24];
- p->guild_id = tmp_int[25];
-// p->pet_id = tmp_int[26];
- p->hair = tmp_int[27];
- p->hair_color = tmp_int[28];
- p->clothes_color = tmp_int[29];
- p->weapon = tmp_int[30];
- p->shield = tmp_int[31];
- p->head_top = tmp_int[32];
- p->head_mid = tmp_int[33];
- p->head_bottom = tmp_int[34];
- p->last_point.x = tmp_int[35];
- p->last_point.y = tmp_int[36];
- p->save_point.x = tmp_int[37];
- p->save_point.y = tmp_int[38];
- p->partner_id = tmp_int[39];
-
- if (str[next] == '\n' || str[next] == '\r')
- return 1; // ?V?K?f?[?^
-
- next++;
-
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- if (sscanf
- (str + next, "%[^,],%d,%d%n", p->memo_point[i].map, &tmp_int[0],
- &tmp_int[1], &len) != 3)
- return -3;
- p->memo_point[i].x = tmp_int[0];
- p->memo_point[i].y = tmp_int[1];
- next += len;
- if (str[next] == ' ')
- next++;
- }
-
- next++;
-
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
- &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
- &tmp_int[11], &len) == 12)
- {
- // do nothing, it's ok
- }
- else if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
- &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
- &len) == 11)
- {
- tmp_int[11] = 0; // broken doesn't exist in this version -> 0
- }
- else // invalid structure
- return -4;
- p->inventory[i].id = tmp_int[0];
- p->inventory[i].nameid = tmp_int[1];
- p->inventory[i].amount = tmp_int[2];
- p->inventory[i].equip = tmp_int[3];
- p->inventory[i].identify = tmp_int[4];
- p->inventory[i].refine = tmp_int[5];
- p->inventory[i].attribute = tmp_int[6];
- p->inventory[i].card[0] = tmp_int[7];
- p->inventory[i].card[1] = tmp_int[8];
- p->inventory[i].card[2] = tmp_int[9];
- p->inventory[i].card[3] = tmp_int[10];
- p->inventory[i].broken = tmp_int[11];
- next += len;
- if (str[next] == ' ')
- next++;
- }
-
- next++;
-
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
- &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
- &tmp_int[11], &len) == 12)
- {
- // do nothing, it's ok
- }
- else if (sscanf (str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
- &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
- &tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10],
- &len) == 11)
- {
- tmp_int[11] = 0; // broken doesn't exist in this version -> 0
- }
- else // invalid structure
- return -5;
- p->cart[i].id = tmp_int[0];
- p->cart[i].nameid = tmp_int[1];
- p->cart[i].amount = tmp_int[2];
- p->cart[i].equip = tmp_int[3];
- p->cart[i].identify = tmp_int[4];
- p->cart[i].refine = tmp_int[5];
- p->cart[i].attribute = tmp_int[6];
- p->cart[i].card[0] = tmp_int[7];
- p->cart[i].card[1] = tmp_int[8];
- p->cart[i].card[2] = tmp_int[9];
- p->cart[i].card[3] = tmp_int[10];
- p->cart[i].broken = tmp_int[11];
- next += len;
- if (str[next] == ' ')
- next++;
- }
-
- next++;
-
- for (i = 0; str[next] && str[next] != '\t'; i++)
- {
- if (sscanf (str + next, "%d,%d%n", &tmp_int[0], &tmp_int[1], &len) !=
- 2)
- return -6;
- p->skill[tmp_int[0]].id = tmp_int[0];
- p->skill[tmp_int[0]].lv = tmp_int[1] & 0xffff;
- p->skill[tmp_int[0]].flags = ((tmp_int[1] >> 16) & 0xffff);
- next += len;
- if (str[next] == ' ')
- next++;
- }
-
- next++;
-
- for (i = 0;
- str[next] && str[next] != '\t' && str[next] != '\n'
- && str[next] != '\r'; i++)
- { // global_reg?????O??athena.txt????^????'\n'?`?F?b?N
- if (sscanf
- (str + next, "%[^,],%d%n", p->global_reg[i].str,
- &p->global_reg[i].value, &len) != 2)
- {
- // because some scripts are not correct, the str can be "". So, we must check that.
- // If it's, we must not refuse the character, but just this REG value.
- // Character line will have something like: nov_2nd_cos,9 ,9 nov_1_2_cos_c,1 (here, ,9 is not good)
- if (str[next] == ','
- && sscanf (str + next, ",%d%n", &p->global_reg[i].value,
- &len) == 1)
- i--;
- else
- return -7;
- }
- next += len;
- if (str[next] == ' ')
- next++;
- }
- p->global_reg_num = i;
-
- return 1;
-}
-
-int accreg_fromstr (char *str, struct accreg *reg)
-{
- int j, v, n;
- char buf[128];
- const char *p = str;
-
- if (sscanf (p, "%d\t%n", &reg->account_id, &n) != 1
- || reg->account_id <= 0)
- return 0;
-
- for (j = 0, p += n; j < ACCOUNT_REG_NUM; j++, p += n)
- {
- if (sscanf (p, "%[^,],%d %n", buf, &v, &n) != 2)
- break;
- memcpy (reg->reg[j].str, buf, 32);
- reg->reg[j].value = v;
- }
- reg->reg_num = j;
-
- return 1;
-}
-
diff --git a/src/tool/moneycount/athena_text.hpp b/src/tool/moneycount/athena_text.hpp
deleted file mode 100644
index e4b7025..0000000
--- a/src/tool/moneycount/athena_text.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef ATHENA_TEXT_HPP
-#define ATHENA_TEXT_HPP
-#include "mmo.hpp"
-
-int mmo_char_fromstr (char *str, struct mmo_charstatus *p);
-
-int accreg_fromstr (char *str, struct accreg *reg);
-
-#endif
diff --git a/src/tool/moneycount/inf.cpp b/src/tool/moneycount/inf.cpp
deleted file mode 100644
index 80b0475..0000000
--- a/src/tool/moneycount/inf.cpp
+++ /dev/null
@@ -1,1482 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// The integer is represented as a sequence of bytes. They are stored such that
-// element 0 is the lsB, which makes sense when seen as an integer offset but
-// is counter-intuitive when you think that a string is usually read from left
-// to right, 0 to size-1, in which case the lsB is on the *left*.
-
-// This solution is compatible with 32-bit and 64-bit machines with either
-// little-endian or big-endian representations of integers.
-
-// Problem: I'm using std::string, which is an array of char. However, char is
-// not well-defined - it could be signed or unsigned.
-
-// In fact, there's no requirement for a char to even be one byte - it can be
-// any size of one byte or more. However, it's just impossible to make any
-// progress with that naffness (thanks to the C non-standardisation committee)
-// and the practice is that char on every platform/compiler I've ever come
-// across is that char = byte.
-
-// The algorithms here use unsigned char to represent bit-patterns so I have to
-// be careful to type-cast from char to unsigned char a lot. I use a typedef to
-// make life easier.
-
-////////////////////////////////////////////////////////////////////////////////
-#include "inf.hpp"
-#include <ctype.h>
-////////////////////////////////////////////////////////////////////////////////
-
-namespace stlplus
-{
-
- ////////////////////////////////////////////////////////////////////////////////
- // choose a sensible C type for a byte
-
- typedef unsigned char byte;
-
- ////////////////////////////////////////////////////////////////////////////////
- // local functions
-
- // removes leading bytes that don't contribute to the value to create the minimum string representation
- static void reduce_string(std::string& data)
- {
- while(data.size() > 1 &&
- ((byte(data[data.size()-1]) == byte(0) && byte(data[data.size()-2]) < byte(128)) ||
- (byte(data[data.size()-1]) == byte(255) && byte(data[data.size()-2]) >= byte(128))))
- {
- data.erase(data.end()-1);
- }
- }
-
- // generic implementations of type conversions from integer type to internal representation
- // data: integer value for conversion
- // result: internal representation
-
- template <typename T>
- static void convert_from_signed(const T& data, std::string& result)
- {
- result.erase();
- bool lsb_first = little_endian();
- byte* address = (byte*)&data;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = (lsb_first ? i : (sizeof(T) - i - 1));
- result.append(1,address[offset]);
- }
- reduce_string(result);
- }
-
- template <typename T>
- static void convert_from_unsigned(const T& data, std::string& result)
- {
- result.erase();
- bool lsb_first = little_endian();
- byte* address = (byte*)&data;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = (lsb_first ? i : (sizeof(T) - i - 1));
- result.append(1,address[offset]);
- }
- // inf is signed - so there is a possible extra sign bit to add
- result.append(1,std::string::value_type(0));
- reduce_string(result);
- }
-
- // generic implementations of type conversions from internal representation to an integer type
- // data : string representation of integer
- // result: integer result of conversion
- // return: flag indicating success - false = overflow
-
- template <class T>
- bool convert_to_signed(const std::string& data, T& result)
- {
- bool lsb_first = little_endian();
- byte* address = (byte*)&result;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = lsb_first ? i : (sizeof(T) - i - 1);
- if (i < data.size())
- address[offset] = byte(data[i]);
- else if (data.empty() || (byte(data[data.size()-1]) < byte(128)))
- address[offset] = byte(0);
- else
- address[offset] = byte(255);
- }
- return data.size() <= sizeof(T);
- }
-
- template <class T>
- bool convert_to_unsigned(const std::string& data, T& result)
- {
- bool lsb_first = little_endian();
- byte* address = (byte*)&result;
- for (size_t i = 0; i < sizeof(T); i++)
- {
- size_t offset = lsb_first ? i : (sizeof(T) - i - 1);
- if (i < data.size())
- address[offset] = byte(data[i]);
- else
- address[offset] = byte(0);
- }
- return data.size() <= sizeof(T);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // Conversions to string
-
- static char to_char [] = "0123456789abcdefghijklmnopqrstuvwxyz";
- static int from_char [] =
- {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
- -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
- };
-
- static void convert_to_string(const stlplus::inf& data, std::string& result, unsigned radix = 10)
- throw(std::invalid_argument)
- {
- // only support the C-style radixes plus 0b for binary
- if (radix != 2 && radix != 8 && radix != 10 && radix != 16)
- throw std::invalid_argument("invalid radix value");
- inf local_i = data;
- // untangle all the options
- bool binary = radix == 2;
- bool octal = radix == 8;
- bool hex = radix == 16;
- // the C representations for binary, octal and hex use 2's-complement representation
- // all other represenations use sign-magnitude
- if (hex || octal || binary)
- {
- // bit-pattern representation
- // this is the binary representation optionally shown in octal or hex
- // first generate the binary by masking the bits
- for (unsigned j = local_i.bits(); j--; )
- result += (local_i.bit(j) ? '1' : '0');
- // the result is now the full width of the type - e.g. int will give a 32-bit result
- // now interpret this as either binary, octal or hex and add the prefix
- if (binary)
- {
- // trim down to the smallest string that preserves the value
- while (true)
- {
- // do not trim to less than 1 bit (sign only)
- if (result.size() <= 1) break;
- // only trim if it doesn't change the sign and therefore the value
- if (result[0] != result[1]) break;
- result.erase(0,1);
- }
- // add the prefix
- result.insert((std::string::size_type)0, "0b");
- }
- else if (octal)
- {
- // the result is currently binary
- // trim down to the smallest string that preserves the value
- while (true)
- {
- // do not trim to less than 2 bits (sign plus 1-bit magnitude)
- if (result.size() <= 2) break;
- // only trim if it doesn't change the sign and therefore the value
- if (result[0] != result[1]) break;
- result.erase(0,1);
- }
- // also ensure that the binary is a multiple of 3 bits to make the conversion to octal easier
- while (result.size() % 3 != 0)
- result.insert((std::string::size_type)0, 1, result[0]);
- // now convert to octal
- std::string octal_result;
- for (unsigned i = 0; i < result.size()/3; i++)
- {
- // yuck - ugly or what?
- if (result[i*3] == '0')
- {
- if (result[i*3+1] == '0')
- {
- if (result[i*3+2] == '0')
- octal_result += '0';
- else
- octal_result += '1';
- }
- else
- {
- if (result[i*3+2] == '0')
- octal_result += '2';
- else
- octal_result += '3';
- }
- }
- else
- {
- if (result[i*3+1] == '0')
- {
- if (result[i*3+2] == '0')
- octal_result += '4';
- else
- octal_result += '5';
- }
- else
- {
- if (result[i*3+2] == '0')
- octal_result += '6';
- else
- octal_result += '7';
- }
- }
- }
- result = octal_result;
- // add the prefix
- result.insert((std::string::size_type)0, "0");
- }
- else
- {
- // similar to octal
- while (true)
- {
- // do not trim to less than 2 bits (sign plus 1-bit magnitude)
- if (result.size() <= 2) break;
- // only trim if it doesn't change the sign and therefore the value
- if (result[0] != result[1]) break;
- result.erase(0,1);
- }
- // pad to a multiple of 4 characters
- while (result.size() % 4 != 0)
- result.insert((std::string::size_type)0, 1, result[0]);
- // now convert to hex
- std::string hex_result;
- for (unsigned i = 0; i < result.size()/4; i++)
- {
- // yuck - ugly or what?
- if (result[i*4] == '0')
- {
- if (result[i*4+1] == '0')
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += '0';
- else
- hex_result += '1';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += '2';
- else
- hex_result += '3';
- }
- }
- else
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += '4';
- else
- hex_result += '5';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += '6';
- else
- hex_result += '7';
- }
- }
- }
- else
- {
- if (result[i*4+1] == '0')
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += '8';
- else
- hex_result += '9';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += 'a';
- else
- hex_result += 'b';
- }
- }
- else
- {
- if (result[i*4+2] == '0')
- {
- if (result[i*4+3] == '0')
- hex_result += 'c';
- else
- hex_result += 'd';
- }
- else
- {
- if (result[i*4+3] == '0')
- hex_result += 'e';
- else
- hex_result += 'f';
- }
- }
- }
- }
- result = hex_result;
- // add the prefix
- result.insert((std::string::size_type)0, "0x");
- }
- }
- else
- {
- // convert to sign-magnitude
- // the representation is:
- // [sign]magnitude
- bool negative = local_i.negative();
- local_i.abs();
- // create a representation of the magnitude by successive division
- inf inf_radix(radix);
- do
- {
- std::pair<inf,inf> divided = local_i.divide(inf_radix);
- unsigned remainder = divided.second.to_unsigned();
- char digit = to_char[remainder];
- result.insert((std::string::size_type)0, 1, digit);
- local_i = divided.first;
- }
- while(!local_i.zero());
- // add the prefixes
- // add a sign only for negative values
- if (negative)
- result.insert((std::string::size_type)0, 1, '-');
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // Conversions FROM string
-
- void convert_from_string(const std::string& str, inf& result, unsigned radix = 10) throw(std::invalid_argument)
- {
- result = 0;
- // only support the C-style radixes plus 0b for binary
- // a radix of 0 means deduce the radix from the input - assume 10
- if (radix != 0 && radix != 2 && radix != 8 && radix != 10 && radix != 16)
- throw std::invalid_argument("invalid radix value");
- unsigned i = 0;
- // the radix passed as a parameter is just the default - it can be
- // overridden by the C prefix
- // Note: a leading zero is the C-style prefix for octal - I only make this
- // override the default when the default radix is not specified
- // first check for a C-style prefix
- bool c_style = false;
- if (i < str.size() && str[i] == '0')
- {
- // binary or hex
- if (i+1 < str.size() && tolower(str[i+1]) == 'x')
- {
- c_style = true;
- radix = 16;
- i += 2;
- }
- else if (i+1 < str.size() && tolower(str[i+1]) == 'b')
- {
- c_style = true;
- radix = 2;
- i += 2;
- }
- else if (radix == 0)
- {
- c_style = true;
- radix = 8;
- i += 1;
- }
- }
- if (radix == 0)
- radix = 10;
- if (c_style)
- {
- // the C style formats are bit patterns not integer values - these need
- // to be sign-extended to get the right value
- std::string binary;
- if (radix == 2)
- {
- for (unsigned j = i; j < str.size(); j++)
- {
- switch(str[j])
- {
- case '0':
- binary += '0';
- break;
- case '1':
- binary += '1';
- break;
- default:
- throw std::invalid_argument("invalid binary character in string " + str);
- }
- }
- }
- else if (radix == 8)
- {
- for (unsigned j = i; j < str.size(); j++)
- {
- switch(str[j])
- {
- case '0':
- binary += "000";
- break;
- case '1':
- binary += "001";
- break;
- case '2':
- binary += "010";
- break;
- case '3':
- binary += "011";
- break;
- case '4':
- binary += "100";
- break;
- case '5':
- binary += "101";
- break;
- case '6':
- binary += "110";
- break;
- case '7':
- binary += "111";
- break;
- default:
- throw std::invalid_argument("invalid octal character in string " + str);
- }
- }
- }
- else
- {
- for (unsigned j = i; j < str.size(); j++)
- {
- switch(tolower(str[j]))
- {
- case '0':
- binary += "0000";
- break;
- case '1':
- binary += "0001";
- break;
- case '2':
- binary += "0010";
- break;
- case '3':
- binary += "0011";
- break;
- case '4':
- binary += "0100";
- break;
- case '5':
- binary += "0101";
- break;
- case '6':
- binary += "0110";
- break;
- case '7':
- binary += "0111";
- break;
- case '8':
- binary += "1000";
- break;
- case '9':
- binary += "1001";
- break;
- case 'a':
- binary += "1010";
- break;
- case 'b':
- binary += "1011";
- break;
- case 'c':
- binary += "1100";
- break;
- case 'd':
- binary += "1101";
- break;
- case 'e':
- binary += "1110";
- break;
- case 'f':
- binary += "1111";
- break;
- default:
- throw std::invalid_argument("invalid hex character in string " + str);
- }
- }
- }
- // now convert the value
- result.resize(binary.size());
- for (unsigned j = 0; j < binary.size(); j++)
- result.preset(binary.size() - j - 1, binary[j] == '1');
- }
- else
- {
- // sign-magnitude representation
- // now scan for a sign and find whether this is a negative number
- bool negative = false;
- if (i < str.size())
- {
- switch (str[i])
- {
- case '-':
- negative = true;
- i++;
- break;
- case '+':
- i++;
- break;
- }
- }
- for (; i < str.size(); i++)
- {
- result *= inf(radix);
- unsigned char ascii = (unsigned char)str[i];
- int ch = from_char[ascii] ;
- if (ch == -1)
- throw std::invalid_argument("invalid decimal character in string " + str);
- result += inf(ch);
- }
- if (negative)
- result.negate();
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // constructors - mostly implemented in terms of the assignment operators
-
- inf::inf(void)
- {
- // void constructor initialises to zero - represented as a single-byte value containing zero
- m_data.append(1,std::string::value_type(0));
- }
-
- inf::inf(short r)
- {
- operator=(r);
- }
-
- inf::inf(unsigned short r)
- {
- operator=(r);
- }
-
- inf::inf(int r)
- {
- operator=(r);
- }
-
- inf::inf(unsigned r)
- {
- operator=(r);
- }
-
- inf::inf(long r)
- {
- operator=(r);
- }
-
- inf::inf(unsigned long r)
- {
- operator=(r);
- }
-
- inf::inf (const std::string& r) throw(std::invalid_argument)
- {
- operator=(r);
- }
-
- inf::inf(const inf& r)
- {
-#ifdef __BORLANDC__
- // work round bug in Borland compiler - copy constructor fails if string
- // contains null characters, so do my own copy
- for (unsigned i = 0; i < r.m_data.size(); i++)
- m_data += r.m_data[i];
-#else
- m_data = r.m_data;
-#endif
- }
-
- ////////////////////////////////////////////////////////////////////////////////
-
- inf::~inf(void)
- {
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // assignments convert from iteger types to internal representation
-
- inf& inf::operator = (short r)
- {
- convert_from_signed(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (unsigned short r)
- {
- convert_from_unsigned(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (int r)
- {
- convert_from_signed(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (unsigned r)
- {
- convert_from_unsigned(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (long r)
- {
- convert_from_signed(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (unsigned long r)
- {
- convert_from_unsigned(r, m_data);
- return *this;
- }
-
- inf& inf::operator = (const std::string& r) throw(std::invalid_argument)
- {
- convert_from_string(r, *this);
- return *this;
- }
-
- inf& inf::operator = (const inf& r)
- {
- m_data = r.m_data;
- return *this;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
-
- short inf::to_short(bool truncate) const throw(std::overflow_error)
- {
- short result = 0;
- if (!convert_to_signed(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_short");
- return result;
- }
-
- unsigned short inf::to_unsigned_short(bool truncate) const throw(std::overflow_error)
- {
- unsigned short result = 0;
- if (!convert_to_unsigned(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_unsigned_short");
- return result;
- }
-
- int inf::to_int(bool truncate) const throw(std::overflow_error)
- {
- int result = 0;
- if (!convert_to_signed(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_int");
- return result;
- }
-
- unsigned inf::to_unsigned(bool truncate) const throw(std::overflow_error)
- {
- unsigned result = 0;
- if (!convert_to_unsigned(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_unsigned");
- return result;
- }
-
- long inf::to_long(bool truncate) const throw(std::overflow_error)
- {
- long result = 0;
- if (!convert_to_signed(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_long");
- return result;
- }
-
- unsigned long inf::to_unsigned_long(bool truncate) const throw(std::overflow_error)
- {
- unsigned long result = 0;
- if (!convert_to_unsigned(m_data, result))
- if (!truncate)
- throw std::overflow_error("stlplus::inf::to_unsigned_long");
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // resize the inf regardless of the data
-
- void inf::resize(unsigned bits)
- {
- if (bits == 0) bits = 1;
- unsigned bytes = (bits+7)/8;
- byte extend = negative() ? byte(255) : byte (0);
- while(bytes > m_data.size())
- m_data.append(1,extend);
- }
-
- // reduce the bit count to the minimum needed to preserve the value
-
- void inf::reduce(void)
- {
- reduce_string(m_data);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // the number of significant bits in the number
-
- unsigned inf::bits (void) const
- {
- // The number of significant bits in the integer value - this is the number
- // of indexable bits less any redundant sign bits at the msb
- // This does not assume that the inf has been reduced to its minimum form
- unsigned result = indexable_bits();
- bool sign = bit(result-1);
- while (result > 1 && (sign == bit(result-2)))
- result--;
- return result;
- }
-
- unsigned inf::size(void) const
- {
- return bits();
- }
-
- unsigned inf::indexable_bits (void) const
- {
- return 8 * unsigned(m_data.size());
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // bitwise operations
-
- bool inf::bit (unsigned index) const throw(std::out_of_range)
- {
- if (index >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::bit"));
- // first split the offset into byte offset and bit offset
- unsigned byte_offset = index/8;
- unsigned bit_offset = index%8;
- return (byte(m_data[byte_offset]) & (byte(1) << bit_offset)) != 0;
- }
-
- bool inf::operator [] (unsigned index) const throw(std::out_of_range)
- {
- return bit(index);
- }
-
- void inf::set (unsigned index) throw(std::out_of_range)
- {
- if (index >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::set"));
- // first split the offset into byte offset and bit offset
- unsigned byte_offset = index/8;
- unsigned bit_offset = index%8;
- m_data[byte_offset] |= (byte(1) << bit_offset);
- }
-
- void inf::clear (unsigned index) throw(std::out_of_range)
- {
- if (index >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::clear"));
- // first split the offset into byte offset and bit offset
- unsigned byte_offset = index/8;
- unsigned bit_offset = index%8;
- m_data[byte_offset] &= (~(byte(1) << bit_offset));
- }
-
- void inf::preset (unsigned index, bool value) throw(std::out_of_range)
- {
- if (value)
- set(index);
- else
- clear(index);
- }
-
- inf inf::slice(unsigned low, unsigned high) const throw(std::out_of_range)
- {
- if (low >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::slice: low index"));
- if (high >= indexable_bits())
- throw std::out_of_range(std::string("stlplus::inf::slice: high index"));
- inf result;
- if (high >= low)
- {
- // create a result the right size and filled with sign bits
- std::string::size_type result_size = (high-low+1+7)/8;
- result.m_data.erase();
- byte extend = bit(high) ? byte(255) : byte (0);
- while (result.m_data.size() < result_size)
- result.m_data.append(1,extend);
- // now set the relevant bits
- for (unsigned i = low; i <= high; i++)
- result.preset(i-low, bit(i));
- }
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // testing operations
-
- bool inf::negative (void) const
- {
- return bit(indexable_bits()-1);
- }
-
- bool inf::natural (void) const
- {
- return !negative();
- }
-
- bool inf::positive (void) const
- {
- return natural() && !zero();
- }
-
- bool inf::zero (void) const
- {
- for (std::string::size_type i = 0; i < m_data.size(); i++)
- if (m_data[i] != 0)
- return false;
- return true;
- }
-
- bool inf::non_zero (void) const
- {
- return !zero();
- }
-
- bool inf::operator ! (void) const
- {
- return zero();
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // comparison operators
-
- bool inf::operator == (const inf& r) const
- {
- // Two infs are equal if they are numerically equal, even if they are
- // different sizes (i.e. they could be non-reduced values).
- // This makes life a little more complicated than if I could assume that values were reduced.
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = bytes; i--; )
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- if (l_byte != r_byte)
- return false;
- }
- return true;
- }
-
- bool inf::operator != (const inf& r) const
- {
- return !operator==(r);
- }
-
- bool inf::operator < (const inf& r) const
- {
- // This could be implemented in terms of subtraction. However, it can be
- // simplified since there is no need to calculate the accurate difference,
- // just the direction of the difference. I compare from msB down and as
- // soon as a byte difference is found, that defines the ordering. The
- // problem is that in 2's-complement, all negative values are greater than
- // all natural values if you just do a straight unsigned comparison. I
- // handle this by doing a preliminary test for different signs.
-
- // For example, a 3-bit signed type has the coding:
- // 000 = 0
- // ...
- // 011 = 3
- // 100 = -4
- // ...
- // 111 = -1
-
- // So, for natural values, the ordering of the integer values is the
- // ordering of the bit patterns. Similarly, for negative values, the
- // ordering of the integer values is the ordering of the bit patterns
- // However, the bit patterns for the negative values are *greater than*
- // the natural values. This is a side-effect of the naffness of
- // 2's-complement representation
-
- // first handle the case of comparing two values with different signs
- bool l_sign = negative();
- bool r_sign = r.negative();
- if (l_sign != r_sign)
- {
- // one argument must be negative and the other natural
- // the left is less if it is the negative one
- return l_sign;
- }
- // the arguments are the same sign
- // so the ordering is a simple unsigned byte-by-byte comparison
- // However, this is complicated by the possibility that the values could be different lengths
- byte l_extend = l_sign ? byte(255) : byte (0);
- byte r_extend = r_sign ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = bytes; i--; )
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- if (l_byte != r_byte)
- return l_byte < r_byte;
- }
- // if I get here, the two are equal, so that is not less-than
- return false;
- }
-
- bool inf::operator <= (const inf& r) const
- {
- return !(r < *this);
- }
-
- bool inf::operator > (const inf& r) const
- {
- return r < *this;
- }
-
- bool inf::operator >= (const inf& r) const
- {
- return !(*this < r);
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // logical operators
-
- inf& inf::invert (void)
- {
- for (std::string::size_type i = 0; i < m_data.size(); i++)
- m_data[i] = ~m_data[i];
- return *this;
- }
-
- inf inf::operator ~ (void) const
- {
- inf result(*this);
- result.invert();
- return result;
- }
-
- inf& inf::operator &= (const inf& r)
- {
- // bitwise AND is extended to the length of the largest argument
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = 0; i < bytes; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- byte result = l_byte & r_byte;
- if (i < m_data.size())
- m_data[i] = result;
- else
- m_data.append(1,result);
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator & (const inf& r) const
- {
- inf result(*this);
- result &= r;
- return result;
- }
-
- inf& inf::operator |= (const inf& r)
- {
- // bitwise OR is extended to the length of the largest argument
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = 0; i < bytes; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- byte result = l_byte | r_byte;
- if (i < m_data.size())
- m_data[i] = result;
- else
- m_data.append(1,result);
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator | (const inf& r) const
- {
- inf result(*this);
- result |= r;
- return result;
- }
-
- inf& inf::operator ^= (const inf& r)
- {
- // bitwise XOR is extended to the length of the largest argument
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- std::string::size_type bytes = maximum(m_data.size(),r.m_data.size());
- for (std::string::size_type i = 0; i < bytes; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- byte result = l_byte ^ r_byte;
- if (i < m_data.size())
- m_data[i] = result;
- else
- m_data.append(1,result);
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator ^ (const inf& r) const
- {
- inf result(*this);
- result ^= r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // shift operators all preserve the value by increasing the word size
-
- inf& inf::operator <<= (unsigned shift)
- {
- // left shift is a shift towards the msb, with 0s being shifted in at the lsb
- // split this into a byte shift followed by a bit shift
-
- // first expand the value to be big enough for the result
- std::string::size_type new_size = (indexable_bits() + shift + 7) / 8;
- byte extend = negative() ? byte(255) : byte (0);
- while (m_data.size() < new_size)
- m_data.append(1,extend);
- // now do the byte shift
- unsigned byte_shift = shift/8;
- if (byte_shift > 0)
- {
- for (std::string::size_type b = new_size; b--; )
- m_data[b] = (b >= byte_shift) ? m_data[b-byte_shift] : byte(0);
- }
- // and finally the bit shift
- unsigned bit_shift = shift%8;
- if (bit_shift > 0)
- {
- for (std::string::size_type b = new_size; b--; )
- {
- byte current = byte(m_data[b]);
- byte previous = b > 0 ? m_data[b-1] : byte(0);
- m_data[b] = (current << bit_shift) | (previous >> (8 - bit_shift));
- }
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator << (unsigned shift) const
- {
- inf result(*this);
- result <<= shift;
- return result;
- }
-
- inf& inf::operator >>= (unsigned shift)
- {
- // right shift is a shift towards the lsb, with sign bits being shifted in at the msb
- // split this into a byte shift followed by a bit shift
-
- // a byte of sign bits
- byte extend = negative() ? byte(255) : byte (0);
- // do the byte shift
- unsigned byte_shift = shift/8;
- if (byte_shift > 0)
- {
- for (std::string::size_type b = 0; b < m_data.size(); b++)
- m_data[b] = (b + byte_shift < m_data.size()) ? m_data[b+byte_shift] : extend;
- }
- // and finally the bit shift
- unsigned bit_shift = shift%8;
- if (bit_shift > 0)
- {
- for (std::string::size_type b = 0; b < m_data.size(); b++)
- {
- byte current = byte(m_data[b]);
- byte next = ((b+1) < m_data.size()) ? m_data[b+1] : extend;
- byte shifted = (current >> bit_shift) | (next << (8 - bit_shift));
- m_data[b] = shifted;
- }
- }
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator >> (unsigned shift) const
- {
- inf result(*this);
- result >>= shift;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // negation operators
-
- inf& inf::negate (void)
- {
- // do 2's-complement negation
- // equivalent to inversion plus one
- invert();
- operator += (inf(1));
- return *this;
- }
-
- inf inf::operator - (void) const
- {
- inf result(*this);
- result.negate();
- return result;
- }
-
- inf& inf::abs(void)
- {
- if (negative()) negate();
- return *this;
- }
-
- inf abs(const inf& i)
- {
- inf result = i;
- result.abs();
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // addition operators
-
- inf& inf::operator += (const inf& r)
- {
- // do 2's-complement addition
- // Note that the addition can give a result that is larger than either argument
- byte carry = 0;
- std::string::size_type max_size = maximum(m_data.size(),r.m_data.size());
- byte l_extend = negative() ? byte(255) : byte (0);
- byte r_extend = r.negative() ? byte(255) : byte (0);
- for (std::string::size_type i = 0; i < max_size; i++)
- {
- byte l_byte = (i < m_data.size() ? byte(m_data[i]) : l_extend);
- byte r_byte = (i < r.m_data.size() ? byte(r.m_data[i]) : r_extend);
- // calculate the addition in a type that is bigger than a byte in order to catch the carry-out
- unsigned short result = ((unsigned short)(l_byte)) + ((unsigned short)(r_byte)) + carry;
- // now truncate the result to get the lsB
- if (i < m_data.size())
- m_data[i] = byte(result);
- else
- m_data.append(1,byte(result));
- // and capture the carry out by grabbing the second byte of the result
- carry = byte(result >> 8);
- }
- // if the result overflowed or underflowed, add an extra byte to catch it
- unsigned short result = ((unsigned short)(l_extend)) + ((unsigned short)(r_extend)) + carry;
- if (byte(result) != (negative() ? byte(255) : byte(0)))
- m_data.append(1,byte(result));
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator + (const inf& r) const
- {
- inf result(*this);
- result += r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // subtraction operators
-
- inf& inf::operator -= (const inf& r)
- {
- // subtraction is defined in terms of negation and addition
- inf negated = -r;
- operator += (negated);
- return *this;
- }
-
- inf inf::operator - (const inf& r) const
- {
- inf result(*this);
- result -= r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // multiplication operators
-
- inf& inf::operator *= (const inf& r)
- {
- // 2's complement multiplication
- // one day I'll do a more efficient version than this based on the underlying representation
- inf left(*this);
- inf right = r;
- // make the right value natural but preserve its sign for later
- bool right_negative = right.negative();
- right.abs();
- // implemented as a series of conditional additions
- operator = (0);
- // left.resize(right.bits() + left.bits() - 1);
- left <<= right.bits()-1;
- for (unsigned i = right.bits(); i--; )
- {
- if (right[i])
- operator += (left);
- left >>= 1;
- }
- if (right_negative)
- negate();
- // now reduce the result
- reduce();
- return *this;
- }
-
- inf inf::operator * (const inf& r) const
- {
- inf result(*this);
- result *= r;
- return result;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // division and remainder operators
-
- std::pair<inf,inf> inf::divide(const inf& right) const throw(divide_by_zero)
- {
- if (right.zero())
- throw divide_by_zero("stlplus::inf::divide");
- inf numerator(*this);
- inf denominator = right;
- // make the numerator natural but preserve the sign for later
- bool numerator_negative = numerator.negative();
- numerator.abs();
- // same with the denominator
- bool denominator_negative = denominator.negative();
- denominator.abs();
- // the quotient and remainder will form the result
- // start with the quotiont zero and the remainder equal to the whole of the
- // numerator, then do trial subtraction from this
- inf quotient;
- inf remainder = numerator;
- // there's nothing more to do if the numerator is smaller than the denominator
- // but otherwise do the division
- if (numerator.bits() >= denominator.bits())
- {
- // make the quotient big enough to take the result
- quotient.resize(numerator.bits());
- // start with the numerator shifted to the far left
- unsigned shift = numerator.bits() - denominator.bits();
- denominator <<= shift;
- // do the division by repeated subtraction,
- for (unsigned i = shift+1; i--; )
- {
- if (remainder >= denominator)
- {
- remainder -= denominator;
- quotient.set(i);
- }
- denominator >>= 1;
- }
- }
- // now adjust the signs
- // x/(-y) == (-x)/y == -(x/y)
- if (numerator_negative != denominator_negative)
- quotient.negate();
- quotient.reduce();
- // x%(-y) == x%y and (-x)%y == -(x%y)
- if (numerator_negative)
- remainder.negate();
- remainder.reduce();
- return std::pair<inf,inf>(quotient,remainder);
- }
-
- inf& inf::operator /= (const inf& r) throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- operator=(result.first);
- return *this;
- }
-
- inf inf::operator / (const inf& r) const throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- return result.first;
- }
-
- inf& inf::operator %= (const inf& r) throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- operator=(result.second);
- return *this;
- }
-
- inf inf::operator % (const inf& r) const throw(divide_by_zero)
- {
- std::pair<inf,inf> result = divide(r);
- return result.second;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // prefix (void) and postfix (int) operators
-
- inf& inf::operator ++ (void)
- {
- operator += (inf(1));
- return *this;
- }
-
- inf inf::operator ++ (int)
- {
- inf old(*this);
- operator += (inf(1));
- return old;
- }
-
- inf& inf::operator -- (void)
- {
- operator -= (inf(1));
- return *this;
- }
-
- inf inf::operator -- (int)
- {
- inf old(*this);
- operator -= (inf(1));
- return old;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // string representation and I/O routines
-
- std::string inf::to_string(unsigned radix) const
- throw(std::invalid_argument)
- {
- std::string result;
- convert_to_string(*this, result, radix);
- return result;
- }
-
- inf& inf::from_string(const std::string& value, unsigned radix)
- throw(std::invalid_argument)
- {
- convert_from_string(value, *this, radix);
- return *this;
- }
-
- std::ostream& operator << (std::ostream& str, const inf& i)
- {
- try
- {
- // get radix
- unsigned radix = 10;
- if (str.flags() & std::ios_base::oct)
- radix = 8;
- if (str.flags() & std::ios_base::hex)
- radix = 16;
- // the field width is handled by iostream, so I don't need to handle it as well
- // generate the string representation then print it
- str << i.to_string(radix);
- }
- catch(const std::invalid_argument)
- {
- str.setstate(std::ios_base::badbit);
- }
- return str;
- }
-
- std::istream& operator >> (std::istream& str, inf& i)
- {
- try
- {
- // get radix
- unsigned radix = 10;
- if (str.flags() & std::ios_base::oct)
- radix = 8;
- if (str.flags() & std::ios_base::hex)
- radix = 16;
- // now get the string image of the value
- std::string image;
- str >> image;
- // and convert to inf
- i.from_string(image, radix);
- }
- catch(const std::invalid_argument)
- {
- str.setstate(std::ios_base::badbit);
- }
- return str;
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- // diagnostic dump
- // just convert to hex
-
- std::string inf::image_debug(void) const
- {
- // create this dump in the human-readable form, i.e. msB to the left
- std::string result = "0x";
- for (std::string::size_type i = m_data.size(); i--; )
- {
- byte current = m_data[i];
- byte msB = (current & byte(0xf0)) >> 4;
- result += to_char[msB];
- byte lsB = (current & byte(0x0f));
- result += to_char[lsB];
- }
- return result;
- }
-
- const std::string& inf::get_bytes(void) const
- {
- return m_data;
- }
-
- void inf::set_bytes(const std::string& data)
- {
- m_data = data;
- }
-
-} // end namespace stlplus
diff --git a/src/tool/moneycount/inf.hpp b/src/tool/moneycount/inf.hpp
deleted file mode 100644
index f28541a..0000000
--- a/src/tool/moneycount/inf.hpp
+++ /dev/null
@@ -1,228 +0,0 @@
-#ifndef STLPLUS_INF
-#define STLPLUS_INF
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// An infinite-precision integer class. This allows calculations on large
-// integers to be performed without overflow.
-
-// this class can throw the following exceptions:
-// std::out_of_range
-// std::overflow_error
-// std::invalid_argument
-// stlplus::divide_by_zero // why doesn't std have this?
-// all of these are derivations of the baseclass:
-// std::logic_error
-// So you can catch all of them by catching the baseclass
-
-// Warning: inf was never intended to be fast, it is just for programs which
-// need a bit of infinite-precision integer arithmetic. For high-performance
-// processing, use the Gnu Multi-Precision (GMP) library. The inf type is just
-// easier to integrate and is already ported to all platforms and compilers
-// that STLplus is ported to.
-
-////////////////////////////////////////////////////////////////////////////////
-#include "portability_fixes.hpp"
-#include "portability_exceptions.hpp"
-#include <string>
-#include <iostream>
-
-////////////////////////////////////////////////////////////////////////////////
-
-namespace stlplus
-{
-
-////////////////////////////////////////////////////////////////////////////////
-
- class inf
- {
- public:
-
- //////////////////////////////////////////////////////////////////////////////
- // constructors and assignments initialise the inf
-
- // the void constructor initialises to zero, the others initialise to the
- // value of the C integer type or the text value contained in the string
-
- inf(void);
- explicit inf(short);
- explicit inf(unsigned short);
- explicit inf(int);
- explicit inf(unsigned);
- explicit inf(long);
- explicit inf(unsigned long);
- explicit inf(const std::string&) throw(std::invalid_argument);
- inf(const inf&);
-
- ~inf(void);
-
- // assignments with equivalent behaviour to the constructors
-
- inf& operator = (short);
- inf& operator = (unsigned short);
- inf& operator = (int);
- inf& operator = (unsigned);
- inf& operator = (long);
- inf& operator = (unsigned long);
- inf& operator = (const std::string&) throw(std::invalid_argument);
- inf& operator = (const inf&);
-
- //////////////////////////////////////////////////////////////////////////////
- // conversions back to the C types
- // truncate: controls the behaviour when the value is too long for the result
- // true: truncate the value
- // false: throw an exception
-
- short to_short(bool truncate = true) const throw(std::overflow_error);
- unsigned short to_unsigned_short(bool truncate = true) const throw(std::overflow_error);
-
- int to_int(bool truncate = true) const throw(std::overflow_error);
- unsigned to_unsigned(bool truncate = true) const throw(std::overflow_error);
-
- long to_long(bool truncate = true) const throw(std::overflow_error);
- unsigned long to_unsigned_long(bool truncate = true) const throw(std::overflow_error);
-
- //////////////////////////////////////////////////////////////////////////////
- // bitwise manipulation
-
- void resize(unsigned bits);
- void reduce(void);
-
- // the number of significant bits in the value
- unsigned bits (void) const;
- unsigned size (void) const;
-
- // the number of bits that can be accessed by the bit() method (=bits() rounded up to the next byte)
- unsigned indexable_bits(void) const;
-
- bool bit (unsigned index) const throw(std::out_of_range);
- bool operator [] (unsigned index) const throw(std::out_of_range);
-
- void set (unsigned index) throw(std::out_of_range);
- void clear (unsigned index) throw(std::out_of_range);
- void preset (unsigned index, bool value) throw(std::out_of_range);
-
- inf slice(unsigned low, unsigned high) const throw(std::out_of_range);
-
- //////////////////////////////////////////////////////////////////////////////
- // tests for common values or ranges
-
- bool negative (void) const;
- bool natural (void) const;
- bool positive (void) const;
- bool zero (void) const;
- bool non_zero (void) const;
-
- // tests used in if(i) and if(!i)
-// operator bool (void) const;
- bool operator ! (void) const;
-
- //////////////////////////////////////////////////////////////////////////////
- // comparisons
-
- bool operator == (const inf&) const;
- bool operator != (const inf&) const;
- bool operator < (const inf&) const;
- bool operator <= (const inf&) const;
- bool operator > (const inf&) const;
- bool operator >= (const inf&) const;
-
- //////////////////////////////////////////////////////////////////////////////
- // bitwise logic operations
-
- inf& invert (void);
- inf operator ~ (void) const;
-
- inf& operator &= (const inf&);
- inf operator & (const inf&) const;
-
- inf& operator |= (const inf&);
- inf operator | (const inf&) const;
-
- inf& operator ^= (const inf&);
- inf operator ^ (const inf&) const;
-
- inf& operator <<= (unsigned shift);
- inf operator << (unsigned shift) const;
-
- inf& operator >>= (unsigned shift);
- inf operator >> (unsigned shift) const;
-
- //////////////////////////////////////////////////////////////////////////////
- // arithmetic operations
-
- inf& negate (void);
- inf operator - (void) const;
-
- inf& abs(void);
- friend inf abs(const inf&);
-
- inf& operator += (const inf&);
- inf operator + (const inf&) const;
-
- inf& operator -= (const inf&);
- inf operator - (const inf&) const;
-
- inf& operator *= (const inf&);
- inf operator * (const inf&) const;
-
- inf& operator /= (const inf&) throw(divide_by_zero);
- inf operator / (const inf&) const throw(divide_by_zero);
-
- inf& operator %= (const inf&) throw(divide_by_zero);
- inf operator % (const inf&) const throw(divide_by_zero);
-
- // combined division operator - returns the result pair(quotient,remainder) in one go
- std::pair<inf,inf> divide(const inf&) const throw(divide_by_zero);
-
- //////////////////////////////////////////////////////////////////////////////
- // pre- and post- increment and decrement
-
- inf& operator ++ (void);
- inf operator ++ (int);
- inf& operator -- (void);
- inf operator -- (int);
-
- //////////////////////////////////////////////////////////////////////////////
- // string representation and I/O
-
- std::string image_debug(void) const;
-
- // conversion to a string representation
- // radix must be 10, 2, 8 or 16
- std::string to_string(unsigned radix = 10) const
- throw(std::invalid_argument);
-
- // conversion from a string
- // radix == 0 - radix is deduced from the input - assumed 10 unless number is prefixed by 0b, 0 or 0x
- // however, you can specify the radix to be 10, 2, 8 or 16 to force that interpretation
- inf& from_string(const std::string&, unsigned radix = 0)
- throw(std::invalid_argument);
-
- //////////////////////////////////////////////////////////////////////////////
- private:
- std::string m_data;
- public:
- const std::string& get_bytes(void) const;
- void set_bytes(const std::string&);
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // redefine friends for gcc v4.1
-
- inf abs(const inf&);
-
- ////////////////////////////////////////////////////////////////////////////////
-
- std::ostream& operator << (std::ostream&, const inf&);
- std::istream& operator >> (std::istream&, inf&);
-
- ////////////////////////////////////////////////////////////////////////////////
-
-} // end namespace stlplus
-
-#endif
diff --git a/src/tool/moneycount/main.cpp b/src/tool/moneycount/main.cpp
deleted file mode 100644
index 2c3d56c..0000000
--- a/src/tool/moneycount/main.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fstream>
-#include <iostream>
-#include <vector>
-#include <algorithm>
-#include <cmath>
-
-#include "mmo.hpp"
-#include "athena_text.hpp"
-#include "inf.hpp"
-
-#define ATHENA_FILE "save/athena.txt"
-#define ACCREG_FILE "save/accreg.txt"
-
-std::vector<int> values;
-
-void countAthena()
-{
- int total = 0;
- std::string input;
- std::ifstream fp(ATHENA_FILE);
- char *buffer = new char[65536];
-
- while (fp.good())
- {
- std::getline(fp,input);
- mmo_charstatus *thisChar = new struct mmo_charstatus;
-
- strcpy(buffer,input.c_str());
-
- if (mmo_char_fromstr(buffer, thisChar))
- {
- total++;
- values.push_back(thisChar->zeny);
- }
-
- delete thisChar;
- }
-
-
- std::cout << "Parsed a total of " << total << " lines in " << ATHENA_FILE << std::endl << std::endl;
-
- delete [] buffer;
- fp.close();
-}
-
-void countAccReg()
-{
- int total = 0;
- std::ifstream fp(ACCREG_FILE);
- char *buffer = new char[65536];
- while (fp.good())
- {
- std::string line;
- std::getline(fp, line);
- struct accreg *reg = new struct accreg;
-
- strcpy(buffer, line.c_str());
-
- if (accreg_fromstr(buffer, reg))
- {
- total++;
- for (int i = 0; i < reg->reg_num; i++)
- {
- if (strcmp(reg->reg[i].str,"#BankAccount") == 0)
- {
- values.push_back(reg->reg[i].value);
- }
- }
- }
-
- delete reg;
- }
-
- std::cout << "Parsed a total of " << total << " lines in " << ACCREG_FILE << std::endl << std::endl;
-
- delete [] buffer;
- fp.close();
-}
-
-stlplus::inf stdDevTotal(0);
-stlplus::inf sum(0);
-stlplus::inf mean(0);
-
-bool lessthan (int i,int j) { return (i<j); }
-void findstddev(int i) { stdDevTotal += stlplus::inf((stlplus::inf(i) - mean) * (stlplus::inf(i) - mean)); }
-void findSum(int i) { sum += stlplus::inf(i); }
-
-stlplus::inf infsqrt(stlplus::inf &x)
-{
- stlplus::inf old(x);
- stlplus::inf newv(x / stlplus::inf(2));
- while (old - newv > stlplus::inf(1))
- {
- old = newv;
- newv = old - (old * old - x) / (stlplus::inf(2) * old);
- }
- return newv;
-}
-
-
-void showStats()
-{
- // Reset globals
- sum = 0;
- mean = 0;
- stdDevTotal = 0;
-
- std::sort(values.begin(), values.end(), lessthan);
- std::for_each(values.begin(), values.end(), findSum);
-
- stlplus::inf total(sum);
- stlplus::inf count(values.size());
- stlplus::inf mean(total / count);
-
- std::for_each(values.begin(), values.end(), findstddev);
-
- int a4th = stlplus::inf(count / stlplus::inf(4)).to_int();
- int a10th = stlplus::inf(count / stlplus::inf(10)).to_int();
-
- int lower = values[0],
-
- t1 = values[a10th * 1],
- t2 = values[a10th * 2],
-
- q1 = values[a4th * 1],
-
- t3 = values[a10th * 3],
- t4 = values[a10th * 4],
-
- median = values[a4th * 2],
-
- t6 = values[a10th * 6],
- t7 = values[a10th * 7],
-
- q3 = values[a4th * 3],
-
- t8 = values[a10th * 8],
- t9 = values[a10th * 9],
-
- upper = values[count.to_int() - 1];
-
- stlplus::inf variance(stdDevTotal / count);
-
- std::cout << "Sum = " << total
- << "\nCount = " << count
- << "\nMean = " << mean
- << "\nSimple Variance = " << variance
- << "\nStandard Deviation = " << infsqrt(variance)
- << "\nLower bound = " << lower
- << "\n10th Percentile = " << t1
- << "\n20th Percentile = " << t2
- << "\nQ1 = " << q1
- << "\n30th Percentile = " << t3
- << "\n40th Percentile = " << t4
- << "\nMedian = " << median
- << "\n60th Percentile = " << t6
- << "\n70th Percentile = " << t7
- << "\nQ3 = " << q3
- << "\n80th Percentile = " << t8
- << "\n90th Percentile = " << t9
- << "\nUpper bound = " << upper << std::endl << std::endl;
-}
-
-int main()
-{
- countAthena();
- std::cout << "The stats for player held money is:" << std::endl;
- showStats();
- values.clear();
-
- countAccReg();
- std::cout << "The stats for bank held money is:" << std::endl;
- showStats();
-
- return 0;
-}
-
diff --git a/src/tool/moneycount/mmo.hpp b/src/tool/moneycount/mmo.hpp
deleted file mode 100644
index beb29c5..0000000
--- a/src/tool/moneycount/mmo.hpp
+++ /dev/null
@@ -1,309 +0,0 @@
-// $Id: mmo.h,v 1.3 2004/09/25 20:12:25 PoW Exp $
-// Original : mmo.h 2003/03/14 12:07:02 Rev.1.7
-
-#ifndef MMO_HPP
-#define MMO_HPP
-
-#include <time.h>
-
-#define FIFOSIZE_SERVERLINK 256*1024
-
-// set to 0 to not check IP of player between each server.
-// set to another value if you want to check (1)
-#define CMP_AUTHFIFO_IP 1
-
-#define CMP_AUTHFIFO_LOGIN2 1
-
-#define MAX_MAP_PER_SERVER 512
-#define MAX_INVENTORY 100
-#define MAX_AMOUNT 30000
-#define MAX_ZENY 1000000000 // 1G zeny
-#define MAX_CART 100
-#define MAX_SKILL 450
-#define GLOBAL_REG_NUM 96
-#define ACCOUNT_REG_NUM 16
-#define ACCOUNT_REG2_NUM 16
-#define DEFAULT_WALK_SPEED 150
-#define MIN_WALK_SPEED 0
-#define MAX_WALK_SPEED 1000
-#define MAX_STORAGE 300
-#define MAX_GUILD_STORAGE 1000
-#define MAX_PARTY 12
-#define MAX_GUILD 120 // increased max guild members to accomodate for +2 increase for extension levels [Valaris] (removed) [PoW]
-#define MAX_GUILDPOSITION 20 // increased max guild positions to accomodate for all members [Valaris] (removed) [PoW]
-#define MAX_GUILDEXPLUSION 32
-#define MAX_GUILDALLIANCE 16
-#define MAX_GUILDSKILL 8
-#define MAX_GUILDCASTLE 24 // increased to include novice castles [Valaris]
-#define MAX_GUILDLEVEL 50
-
-#define MIN_HAIR_STYLE battle_config.min_hair_style
-#define MAX_HAIR_STYLE battle_config.max_hair_style
-#define MIN_HAIR_COLOR battle_config.min_hair_color
-#define MAX_HAIR_COLOR battle_config.max_hair_color
-#define MIN_CLOTH_COLOR battle_config.min_cloth_color
-#define MAX_CLOTH_COLOR battle_config.max_cloth_color
-
-// for produce
-#define MIN_ATTRIBUTE 0
-#define MAX_ATTRIBUTE 4
-#define ATTRIBUTE_NORMAL 0
-#define MIN_STAR 0
-#define MAX_STAR 3
-
-#define MIN_PORTAL_MEMO 0
-#define MAX_PORTAL_MEMO 2
-
-#define MAX_STATUS_TYPE 5
-
-#define CHAR_CONF_NAME "conf/char_athena.conf"
-
-struct account
-{
- int account_id;
- char name[50];
- char password[50];
- char lastlogin[50];
- char sex;
- int num_logins;
- int state;
- char email[50];
- char error_message[50];
- long valitidy_time;
- char last_ip[50];
- char memo[50];
- long ban_time;
-};
-
-
-struct item
-{
- int id;
- short nameid;
- short amount;
- unsigned short equip;
- char identify;
- char refine;
- char attribute;
- short card[4];
- short broken;
-};
-
-struct point
-{
- char map[24];
- short x, y;
-};
-
-struct skill
-{
- unsigned short id, lv, flags;
-};
-
-struct global_reg
-{
- char str[32];
- int value;
-};
-
-struct accreg
-{
- int account_id, reg_num;
- struct global_reg reg[ACCOUNT_REG_NUM];
-};
-
-struct mmo_charstatus
-{
- int char_id;
- int account_id;
- int partner_id;
-
- int base_exp, job_exp, zeny;
-
- short classb;
- short status_point, skill_point;
- int hp, max_hp, sp, max_sp;
- short option, karma, manner;
- short hair, hair_color, clothes_color;
- int party_id, guild_id;
-
- short weapon, shield;
- short head_top, head_mid, head_bottom;
-
- char name[24];
- unsigned char base_level, job_level;
- short str, agi, vit, int_, dex, luk;
- unsigned char char_num, sex;
-
- unsigned long mapip;
- unsigned int mapport;
-
- struct point last_point, save_point, memo_point[10];
- struct item inventory[MAX_INVENTORY], cart[MAX_CART];
- struct skill skill[MAX_SKILL];
- int global_reg_num;
- struct global_reg global_reg[GLOBAL_REG_NUM];
- int account_reg_num;
- struct global_reg account_reg[ACCOUNT_REG_NUM];
- int account_reg2_num;
- struct global_reg account_reg2[ACCOUNT_REG2_NUM];
-};
-
-struct storage
-{
- int dirty;
- int account_id;
- short storage_status;
- short storage_amount;
- struct item storage_[MAX_STORAGE];
-};
-
-struct guild_storage
-{
- int dirty;
- int guild_id;
- short storage_status;
- short storage_amount;
- struct item storage_[MAX_GUILD_STORAGE];
-};
-
-struct map_session_data;
-
-struct gm_account
-{
- int account_id;
- int level;
-};
-
-struct party_member
-{
- int account_id;
- char name[24], map[24];
- int leader, online, lv;
- struct map_session_data *sd;
-};
-
-struct party
-{
- int party_id;
- char name[24];
- int exp;
- int item;
- struct party_member member[MAX_PARTY];
-};
-
-struct guild_member
-{
- int account_id, char_id;
- short hair, hair_color, gender, classb, lv;
- int exp, exp_payper;
- short online, position;
- int rsv1, rsv2;
- char name[24];
- struct map_session_data *sd;
-};
-
-struct guild_position
-{
- char name[24];
- int mode;
- int exp_mode;
-};
-
-struct guild_alliance
-{
- int opposition;
- int guild_id;
- char name[24];
-};
-
-struct guild_explusion
-{
- char name[24];
- char mes[40];
- char acc[40];
- int account_id;
- int rsv1, rsv2, rsv3;
-};
-
-struct guild_skill
-{
- int id, lv;
-};
-
-struct guild
-{
- int guild_id;
- short guild_lv, connect_member, max_member, average_lv;
- int exp, next_exp, skill_point, castle_id;
- char name[24], master[24];
- struct guild_member member[MAX_GUILD];
- struct guild_position position[MAX_GUILDPOSITION];
- char mes1[60], mes2[120];
- int emblem_len, emblem_id;
- char emblem_data[2048];
- struct guild_alliance alliance[MAX_GUILDALLIANCE];
- struct guild_explusion explusion[MAX_GUILDEXPLUSION];
- struct guild_skill skill[MAX_GUILDSKILL];
-};
-
-struct guild_castle
-{
- int castle_id;
- char map_name[24];
- char castle_name[24];
- char castle_event[24];
- int guild_id;
- int economy;
- int defense;
- int triggerE;
- int triggerD;
- int nextTime;
- int payTime;
- int createTime;
- int visibleC;
- int visibleG0;
- int visibleG1;
- int visibleG2;
- int visibleG3;
- int visibleG4;
- int visibleG5;
- int visibleG6;
- int visibleG7;
- int Ghp0; // added Guardian HP [Valaris]
- int Ghp1;
- int Ghp2;
- int Ghp3;
- int Ghp4;
- int Ghp5;
- int Ghp6;
- int Ghp7;
- int GID0;
- int GID1;
- int GID2;
- int GID3;
- int GID4;
- int GID5;
- int GID6;
- int GID7; // end addition [Valaris]
-};
-struct square
-{
- int val1[5];
- int val2[5];
-};
-
-enum
-{
- GBI_EXP = 1, // ?M???h??EXP
- GBI_GUILDLV = 2, // ?M???h??Lv
- GBI_SKILLPOINT = 3, // ?M???h?~X?L???|?C???g
- GBI_SKILLLV = 4, // ?M???h?X?L??Lv
-
- GMI_POSITION = 0, // ?????o?[???E??X
- GMI_EXP = 1, // ?????o?[??EXP
-
-};
-
-#endif // MMO_HPP
-
diff --git a/src/tool/moneycount/portability_exceptions.hpp b/src/tool/moneycount/portability_exceptions.hpp
deleted file mode 100644
index c66b7bf..0000000
--- a/src/tool/moneycount/portability_exceptions.hpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef STLPLUS_PORTABILITY_EXCEPTIONS
-#define STLPLUS_PORTABILITY_EXCEPTIONS
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// Adds missing arithmetic exceptions used in this library but missing from std
-
-////////////////////////////////////////////////////////////////////////////////
-#include "portability_fixes.hpp"
-#include <string>
-#include <stdexcept>
-
-namespace stlplus
-{
-
- ////////////////////////////////////////////////////////////////////////////////
- // thrown by division when the divisor is zero
- // This is a subclass of std::logic_error so can be caught by a generic catch clause for the superclass
-
- class divide_by_zero : public std::logic_error {
- public:
- divide_by_zero (const std::string& what_arg): std::logic_error (what_arg) { }
- };
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // end namespace stlplus
-
-#endif
diff --git a/src/tool/moneycount/portability_fixes.cpp b/src/tool/moneycount/portability_fixes.cpp
deleted file mode 100644
index e26ee28..0000000
--- a/src/tool/moneycount/portability_fixes.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-////////////////////////////////////////////////////////////////////////////////
-#include "portability_fixes.hpp"
-
-#ifdef MSWINDOWS
-#include "windows.h"
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// problems with missing functions
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef MSWINDOWS
-unsigned sleep(unsigned seconds)
-{
- Sleep(1000*seconds);
- // should return remaining time if interrupted - however Windoze Sleep cannot be interrupted
- return 0;
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Function for establishing endian-ness
-////////////////////////////////////////////////////////////////////////////////
-
-bool stlplus::little_endian(void)
-{
- int sample = 1;
- char* sample_bytes = (char*)&sample;
- return sample_bytes[0] != 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
diff --git a/src/tool/moneycount/portability_fixes.hpp b/src/tool/moneycount/portability_fixes.hpp
deleted file mode 100644
index b6a030c..0000000
--- a/src/tool/moneycount/portability_fixes.hpp
+++ /dev/null
@@ -1,127 +0,0 @@
-#ifndef STLPLUS_PORTABILITY_FIXES
-#define STLPLUS_PORTABILITY_FIXES
-////////////////////////////////////////////////////////////////////////////////
-
-// Author: Andy Rushton
-// Copyright: (c) Southampton University 1999-2004
-// (c) Andy Rushton 2004-2009
-// License: BSD License, see ../docs/license.html
-
-// Contains work arounds for OS or Compiler specific problems to try to make
-// them look more alike
-
-// It is strongly recommended that this header be included as the first
-// #include in every source file
-
-////////////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////////////
-// Problem with MicroSoft defining two different macros to identify Windows
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(_WIN32) || defined(_WIN32_WCE)
-#define MSWINDOWS
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Problems with unnecessary or unfixable compiler warnings
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef _MSC_VER
-// Microsoft Visual Studio
-// shut up the following irritating warnings
-// 4786 - VC6, identifier string exceeded maximum allowable length and was truncated (only affects debugger)
-// 4305 - VC6, identifier type was converted to a smaller type
-// 4503 - VC6, decorated name was longer than the maximum the compiler allows (only affects debugger)
-// 4309 - VC6, type conversion operation caused a constant to exceeded the space allocated for it
-// 4290 - VC6, C++ exception specification ignored
-// 4800 - VC6, forcing value to bool 'true' or 'false' (performance warning)
-// 4675 - VC7.1, "change" in function overload resolution _might_ have altered program
-// 4996 - VC8, 'xxxx' was declared deprecated
-#pragma warning(disable: 4786 4305 4503 4309 4290 4800 4675 4996)
-#endif
-
-#ifdef __BORLANDC__
-// Borland
-// Shut up the following irritating warnings
-// 8026 - Functions with exception specifications are not expanded inline
-// 8027 - Functions with xxx are not expanded inline
-#pragma warn -8026
-#pragma warn -8027
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Problems with redefinition of min/max in various different versions of library headers
-////////////////////////////////////////////////////////////////////////////////
-
-// The Windows headers define macros called max/min which conflict with the templates std::max and std::min.
-// So, to avoid conflicts, MS removed the std::max/min rather than fixing the problem!
-// From Visual Studio .NET (SV7, compiler version 13.00) the STL templates have been added correctly.
-// For MFC compatibility, only undef min and max in non-MFC programs - some bits of MFC
-// use macro min/max in headers.
-
-// I've created extra template function definitions minimum/maximum that avoid all the problems above
-
-namespace stlplus
-{
- template<typename T> const T& maximum(const T& l, const T& r) {return l > r ? l : r;}
- template<typename T> const T& minimum(const T& l, const T& r) {return l < r ? l : r;}
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Problems with differences between namespaces
-////////////////////////////////////////////////////////////////////////////////
-
-// Note: not sure of the relevance of this - maybe deprecated?
-// problem in gcc pre-v3 where the sub-namespaces in std aren't present
-// this mean that the statement "using namespace std::rel_ops" created an error because the namespace didn't exist
-
-// I've done a fix here that creates an empty namespace for this case, but I
-// do *not* try to move the contents of std::rel_ops into namespace std
-// This fix only works if you use "using namespace std::rel_ops" to bring in the template relational operators (e.g. != defined i.t.o. ==)
-
-#ifdef __GNUC__
-namespace std
-{
- namespace rel_ops
- {
- }
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// problems with missing functions
-////////////////////////////////////////////////////////////////////////////////
-
-#ifdef MSWINDOWS
-unsigned sleep(unsigned seconds);
-#else
-#include <unistd.h>
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Function for establishing endian-ness
-////////////////////////////////////////////////////////////////////////////////
-// Different machine architectures store data using different byte orders.
-// This is referred to as Big- and Little-Endian Byte Ordering.
-//
-// The issue is: where does a pointer to an integer type actually point?
-//
-// In both conventions, the address points to the left of the word but:
-// Big-Endian - The most significant byte is on the left end of a word
-// Little-Endian - The least significant byte is on the left end of a word
-//
-// Bytes are addressed left to right, so in big-endian order byte 0 is the
-// msB, whereas in little-endian order byte 0 is the lsB. For example,
-// Intel-based machines store data in little-endian byte order so byte 0 is
-// the lsB.
-//
-// This function establishes byte order at run-time
-
-namespace stlplus
-{
- bool little_endian(void);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-#endif
diff --git a/src/tool/skillfrob.cpp b/src/tool/skillfrob.cpp
deleted file mode 100644
index 901f765..0000000
--- a/src/tool/skillfrob.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// Compile with
-// gcc -m32 -Wall -Wno-pointer-sign -fno-strict-aliasing -I src/char -I src/common src/tool/skillfrob.c -o skillfrob src/common/timer.o src/common/malloc.o src/common/socket.o src/common/lock.o src/common/db.o src/char/int_storage.o src/char/inter.o src/char/int_party.o src/char/int_guild.o
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "../common/mmo.hpp"
-#include "../char/char.cpp"
-
-unsigned char skills[MAX_SKILL];
-
-void transform_char (struct mmo_charstatus *p)
-{
- int i;
-
- for (i = 0; i < MAX_SKILL; i++)
- {
- if (skills[(*p).skill[i].id])
- {
- (*p).skill[i].lv = 0;
- (*p).skill[i].flags = 0;
- }
- }
-}
-
-int mmo_char_convert ()
-{
- char line[965536];
- int ret;
- struct mmo_charstatus char_dat;
- FILE *ifp, *ofp;
-
- ifp = stdin;
- ofp = stdout;
- while (fgets (line, 65535, ifp))
- {
- memset (&char_dat, 0, sizeof (struct mmo_charstatus));
- ret = mmo_char_fromstr (line, &char_dat);
- if (ret)
- {
- transform_char (&char_dat);
- mmo_char_tostr (line, &char_dat);
- fprintf (ofp, "%s\n", line);
- }
- }
- fcloseall ();
- return 0;
-}
-
-int init (int count, char **translates)
-{
- int i, skill;
-
- memset (skills, 0, sizeof (skills));
-
- for (i = 0; i < count; i++)
- {
- skill = atoi (translates[i]);
- if (skill > 0)
- {
- skills[skill] = 1;
- }
- }
-
- return 0;
-}
-
-int main (int argc, char *argv[])
-{
- if (argc < 2)
- {
- printf ("Usage: %s skillid1 skillid2 ...\n", argv[0]);
- exit (0);
- }
- if (init (argc - 1, argv + 1))
- return 1;
-
- mmo_char_convert ();
-
- return 0;
-}
diff --git a/src/tool/stats.sh b/src/tool/stats.sh
deleted file mode 100755
index 9ea021b..0000000
--- a/src/tool/stats.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/bash
-
-ATHENATXT="save/athena.txt"
-DEST="$HOME/public_html/stats"
-
-:> ${DEST}/top-money.txt
-(echo "TOP 50 RICHEST PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); sub(/ *[0-9]+$/,"",$6);print $6,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-money.txt
-
-:> ${DEST}/top-highest-level.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); print $3,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-level.txt
-
-:> ${DEST}/top-highest-str.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); sub(/^[0-9]+[[:space:]]*/,"",$9);print $9,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-str.txt
-
-:> ${DEST}/top-highest-agi.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); print $10,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-agi.txt
-
-:> ${DEST}/top-highest-vit.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); print $11,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-vit.txt
-
-:> ${DEST}/top-highest-int.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); print $12,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-int.txt
-
-:> ${DEST}/top-highest-dex.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); print $13,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-dex.txt
-
-:> ${DEST}/top-highest-luk.txt
-(echo "TOP 50 HIGHEST LEVEL PLAYERS"; echo ""; cat ${ATHENATXT} \
-| awk -F , '{sub(/^[0-9] */,"",$2);sub(/ *[0-9]$/,"",$2); sub(/[[:space:]]*[0-9]+$/,"",$14);print $14,$2}' \
-| sort -nr | head -n 50 | awk '{first=$1;$1="";print $0, "("first")"}' | nl -s ". "; echo ""; echo "Generated at `date`") >> ${DEST}/top-highest-luk.txt
diff --git a/src/webserver/GNUmakefile b/src/webserver/GNUmakefile
deleted file mode 100644
index 0520440..0000000
--- a/src/webserver/GNUmakefile
+++ /dev/null
@@ -1,7 +0,0 @@
-.SUFFIXES:
-all:
- ${MAKE} -C ../.. webserver
-clean:
- rm -r ../../obj/webserver/
-%::
- ${MAKE} -C ../.. obj/webserver/$@
diff --git a/src/webserver/doc/API.txt b/src/webserver/doc/API.txt
deleted file mode 100644
index c80f7bd..0000000
--- a/src/webserver/doc/API.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-Here's the webserver API, so you can work on the webserver.
-
-My personal goal is to make this interface simple, so that coding it
-will be like coding in some scripting language...
-
-
-
-char *get_param(char in_string[500], char swhat[500]);
-
-This function simply returns various data from the query string.
- *Pass get_param NOTHING longer than 500 in length!
-
- What do I pass where in_string is?
- The query string.
-
- What do I pass where swhat is?
- One of two things...
- Either 0 for the path of the 'page'
- or you can pass it the param you wish to lookup.
-
-
-
-
-
-
-char *get_query(char *inquery);
-
-This function simply returns a query string from the raw server request.
-This is used once in main, I doubt you'll need it.
-
-
-
-
-
-void web_send(int sockin, char *in_data);
-
-Super easy way of sending data to a webpage!
-Simply put in the socket name and then the data.
-
- Ex:
- web_send(socket, "I like cheese!\n");
-
-
-
-
-char *html_header(char* title);
-Easy way to print the eAthena header for the server.
-
- Ex:
- web_send(sockethere, html_header("About"));
diff --git a/src/webserver/doc/README b/src/webserver/doc/README
deleted file mode 100644
index 0e94ff2..0000000
--- a/src/webserver/doc/README
+++ /dev/null
@@ -1,11 +0,0 @@
-This readme is intended for the programmers of eAthena.
-
-This webserver's apis are in API.txt.
-
-To make this simple, generate.c should handle most of the work this sever does
-in terms of what people see.
-
-When a request is made the server shoots it off to generate.c.
-
-You are welcome to create more functions used by generate.c to generate pages
-though, so don't feel limited by that one file.
diff --git a/src/webserver/generate.cpp b/src/webserver/generate.cpp
deleted file mode 100644
index 1fed224..0000000
--- a/src/webserver/generate.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-
-void generate_page (char password[25], int sock_in, char *query, char *ip)
-{
- char *page = get_param (query, 0);
- char *ppass = get_param (query, "password");
-
- if ((ppass == 0) || (strcmp (password, ppass) != 0))
- {
- web_send (sock_in, html_header ("Enter your password"));
- web_send (sock_in,
- "<H1>NOT LOGGED IN!</H1><form action=\"/\" method=\"GET\">\n");
- web_send (sock_in,
- "Enter your password:<br>\n<input type=\"text\" name=\"password\">\n");
- web_send (sock_in, "<input type=\"submit\" value=\"Login\">\n");
- }
- else
- {
-
- //To make this simple, we will have a bunch of if statements
- //that then shoot out data off into functions.
-
- //The 'index'
- if (strcmp (page, "/") == 0)
- generate_notdone (sock_in, query, ip);
-
- //About page:
- if (strcmp (page, "/about.html") == 0)
- generate_about (sock_in, query, ip);
-
- //Test page:
- if (strcmp (page, "/testing/") == 0)
- generate_sample (sock_in, query, ip);
-
- }
-}
diff --git a/src/webserver/htmlstyle.cpp b/src/webserver/htmlstyle.cpp
deleted file mode 100644
index 3007a24..0000000
--- a/src/webserver/htmlstyle.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-char output[10000];
-
-char *html_header (char *title)
-{
- memset (output, 0x0, 10000);
- char *text =
- "<body text=\"#000000\" bgcolor=\"#939393\" link=\"#0033FF\">\n"
- "<br><table width=\"92%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\"\n"
- "align=\"center\" class=\"bordercolor\"><tbody><tr><td class=\"bordercolor\" width=\"100%\">\n"
- "<table bgcolor=\"#ffffff\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n"
- "<tbody><tr><td><table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#ffffff\">\n"
- "<tbody><tr><img src=\"http://eathena.sourceforge.net/athena.jpg\" alt=\"Athena\">\n"
- "<td bgcolor=\"#ffffff\"></td></tr></tbody></table></td></tr></tbody></table>\n"
- "</td></tr><tr align=\"left\"><td class=\"bordercolor\"><table bgcolor=\"#c6c6c6\" width=\"100%\" cellspacing=\"0\"\n"
- "cellpadding=\"0\" style=\"text-align: left; margin-right: auto; margin-left: 0px;\">\n";
- "<tbody><tr><td width=\"100%\" align=\"center\"><table border=\"0\" width=\"100%\" cellpadding=\"3\"\n"
- "cellspacing=\"0\" bgcolor=\"#c6c6c6\" align=\"center\"><tbody><tr>"
- "<td valign=\"middle\" bgcolor=\"#c6c6c6\" align=\"center\"><a href=\"/cgi-bin/forum/YaBB.cgi\">"
- "<span style=\"text-decoration: underline;\"><span style=\"font-weight: bold;\">\n"
- "To the Forum</span></span></a><br></td></tr></tbody></table></td></tr></tbody>\n"
- "</table></td></tr><tr><td class=\"bordercolor\" align=\"center\">\n"
- "<table bgcolor=\"#ffffff\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n"
- "<tbody><tr><td width=\"100%\" align=\"center\"><table border=\"0\" width=\"100%\" cellpadding=\"5\"\n"
- "cellspacing=\"0\" bgcolor=\"#ffffff\" align=\"center\"><tbody><tr>\n"
- "<td valign=\"middle\" bgcolor=\"#ffffff\" align=\"center\"><font size=\"2\" color=\"#6e94b7\">\n"
- "<b>Athena</b> &laquo; Portal &raquo;</font></td></tr></tbody></table></td></tr></tbody>"
- "</table></td></tr></tbody></table>\n";
-
- sprintf (output, "<title>%s</title>\n%s\n", title, text);
-
- return output;
-}
-
-char *html_start_form (char *location, char *action)
-{
- memset (output, 0x0, 10000);
- sprintf (output, "<form action=\"%s\" method=\"%s\">", location, action);
- return output;
-
-}
-
-char *html_end_forum (void)
-{
- return "</form>";
-}
diff --git a/src/webserver/logs.cpp b/src/webserver/logs.cpp
deleted file mode 100644
index 67bf55e..0000000
--- a/src/webserver/logs.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <time.h>
-
-void log_visit (char *query, char *ip)
-{
- time_t timer;
- timer = time (NULL);
- printf ("%s - \"%s\" - %s", ip, query, asctime (localtime (&timer)));
-}
diff --git a/src/webserver/main.cpp b/src/webserver/main.cpp
deleted file mode 100644
index 0e227d3..0000000
--- a/src/webserver/main.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/***************************************************************************
- description
- -------------------
- author : (C) 2004 by Michael J. Flickinger
- email : mjflick@cpan.org
-
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/wait.h>
-#include <signal.h>
-
-#define BLOG 10
-
-char *header = "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n";
-char recvin[500], password[25];
-int s_port;
-
-void sigchld_handler (int s)
-{
- while (wait (NULL) > 0);
-}
-
-int main (int argc, char **argv)
-{
- if (argc < 3)
- {
- printf ("eAthena Web Server\n");
- printf ("usage: %s [password] [port]\n", argv[0]);
- exit (0);
- }
-
- s_port = atoi (argv[2]);
-
- if ((s_port < 1) || (s_port > 65534))
- {
- printf ("Error: The port you choose is not valid port.\n");
- exit (0);
- }
-
- if (strlen (argv[1]) > 25)
- {
- printf ("Error: Your password is too long.\n");
- printf ("It must be shorter than 25 characters.\n");
- exit (0);
- }
-
- memset (password, 0x0, 25);
- memcpy (password, argv[1], strlen (argv[1]));
-
- int sockfd, new_fd;
- struct sockaddr_in my_addr;
- struct sockaddr_in their_addr;
- int sin_size;
-
- struct sigaction sa;
-
- int yes = 1;
-
- if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) == -1)
- {
- perror ("Darn, this is broken.");
- exit (0);
- }
-
- if (setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof (int)) ==
- -1)
- {
- perror ("Error... :-(");
- }
-
- //Now we know we have a working socket. :-)
-
- my_addr.sin_family = AF_INET;
- my_addr.sin_port = htons (s_port);
- my_addr.sin_addr.s_addr = INADDR_ANY;
- memset (&(my_addr.sin_zero), '\0', 8);
-
- if (bind (sockfd, (struct sockaddr *) &my_addr, sizeof (struct sockaddr))
- == -1)
- {
- perror ("can not bind to this port");
- exit (0);
- }
-
- if (listen (sockfd, BLOG) == -1)
- {
- perror ("can not listen on port");
- exit (0);
- }
-
- sa.sa_handler = sigchld_handler;
-
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = SA_RESTART;
-
- if (sigaction (SIGCHLD, &sa, NULL) == -1)
- {
- perror ("sigaction sucks");
- exit (0);
- }
-
- printf ("The eAthena webserver is up and listening on port %i.\n",
- s_port);
-
- while (1)
- {
- sin_size = sizeof (struct sockaddr_in);
- new_fd = accept (sockfd, (struct sockaddr *) &their_addr, &sin_size);
-
- if (!fork ())
- {
- close (sockfd);
- memset (recvin, 0x0, 500);
- recv (new_fd, recvin, 500, 0);
- send (new_fd, header, strlen (header), 0);
- generate_page (password, new_fd, get_query (recvin),
- inet_ntoa (their_addr.sin_addr));
- log_visit (get_query (recvin), inet_ntoa (their_addr.sin_addr));
-
- close (new_fd);
- exit (0);
- }
- close (new_fd);
- }
-
- return 0;
-}
diff --git a/src/webserver/pages/about.cpp b/src/webserver/pages/about.cpp
deleted file mode 100644
index b548da9..0000000
--- a/src/webserver/pages/about.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-void generate_about (int sock_in, char *query, char *ip)
-{
-//printf("%s", html_header("About"));
- web_send (sock_in, html_header ("About"));
- web_send (sock_in, "<center>eAthena Web Server!</center>\n");
-}
diff --git a/src/webserver/pages/notdone.cpp b/src/webserver/pages/notdone.cpp
deleted file mode 100644
index 1fcd44b..0000000
--- a/src/webserver/pages/notdone.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-void generate_notdone (int sock_in, char *query, char *ip)
-{
- web_send (sock_in, "<title>Not here!</title>\n");
- web_send (sock_in,
- "<h2><center>This page/feature is not done yet.</center>\n</h2>");
-}
diff --git a/src/webserver/pages/sample.cpp b/src/webserver/pages/sample.cpp
deleted file mode 100644
index 6a33dc0..0000000
--- a/src/webserver/pages/sample.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-void generate_sample (int sock_in, char *query, char *ip)
-{
-
- char *name = get_param (query, "name");
-
- web_send (sock_in, "<title>SAMPLE</title>\n");
-
- //If a name was not entered...
- if (name == '\0')
- {
- web_send (sock_in, "<form action=\"/testing/\" method=\"GET\">\n");
- web_send (sock_in, "<input type=\"text\" name=\"name\">\n");
- web_send (sock_in, "<input type=\"submit\">\n");
- }
- else
- {
- web_send (sock_in, "Your name is: ");
- web_send (sock_in, get_param (query, "name"));
- }
- printf ("OK!\n");
-}
diff --git a/src/webserver/parse.cpp b/src/webserver/parse.cpp
deleted file mode 100644
index 66ef43b..0000000
--- a/src/webserver/parse.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-#include <stdlib.h>
-
-char filtered_query[2000];
-char rdata[500];
-char param_n[500];
-char param_d[500];
-
-char *get_query (char *inquery)
-{
- memset (filtered_query, 0x0, 2000);
- sscanf (inquery, "GET %s %[$]", filtered_query);
- return (filtered_query);
-}
-
-void web_send (int sockin, char *in_data)
-{
- send (sockin, in_data, strlen (in_data), 0);
-}
-
-//THIS IS BAD CODE BE CAREFULL WITH IT!
-//Watch out for buffer overflow...
-//When using please make sure to check the string size.
-
-//Also note:
-//I take no pride in this code, it is a really bad way of doing this...
-char *get_param (char in_string[500], char swhat[500])
-{
- int i = 0;
- int marker, iswitch, pint, dint;
- char flux[500];
- memset (flux, 0x0, 500);
-
- //Get the path of out "page"
- if (swhat == 0)
- {
- //while i is not equal to array size
- while (i != 500)
- {
- //if there is a question mark, halt!
- if (in_string[i] == '?')
- {
- i = 499;
- }
- else
- rdata[i] = in_string[i];
-
- i++;
- }
- return rdata;
- }
- else //so, we want a param...
- {
- //calculate where param begins
- while (i != 500)
- {
- if (in_string[i] == '?')
- {
- marker = i + 1;
- i = 499;
- }
- i++;
- }
-
- i = 0;
-
- //keep morons from trying to crash this
- if ((marker > 500) || (marker < 1))
- marker = 500;
-
- while (marker != 500)
- {
- if ((in_string[marker] != '&') && (in_string[marker] != '\0'))
- {
- flux[i] = in_string[marker];
- i++;
- }
- else
- {
-
- //we have a param, now we must dig through it
-
- //clear temp vars
- memset (param_n, 0x0, 500);
- memset (param_d, 0x0, 500);
- iswitch = 0;
- pint = 0;
- dint = 0;
- i = 0;
-
- //split result into param_n and param_d
- while (i != 500)
- {
- if ((flux[i] != '=') && (flux[i] != '\0'))
- {
- if (iswitch == 0)
- {
- param_n[pint] = flux[i];
- pint++;
- }
- else
- {
- param_d[dint] = flux[i];
- dint++;
- }
- }
- else
- {
- iswitch = 1;
- }
- if (flux[i] == '\0')
- i = 499;
-
- i++;
- }
-
- if (strcmp (param_n, swhat) == 0)
- {
- return param_d;
- }
-
- i = 0;
- }
-
- if (in_string[marker] == '\0')
- {
- marker = 499;
- }
- marker++;
- }
- return 0;
- }
-}