Skip to main content

Mudos[win] 迁移到 FluffOS 3.x[Linux] 编译、mudlib 修改过程 for CnetOS 7.x

FluffOS是在MUDOS基础上更新完成的。进行了许多新功能和bug修复。 针对LPC有很好的兼容性,如果你的MUD运行MUDOS V22+版本,可以很容易运行在fluffos上。
系统环境

CnetOS 7.x mini 最小化安装


安装 mysql-community-devel 需要先安装mysql的源

wget http://repo.mysql.com/mysql57-community-release-el7.rpm
sudo rpm -ivh mysql57-community-release-el7.rpm

安装编译环境

yum install zlib-devel pcre-devel bison gtest dos2unix unzip
yum install git gcc-c++ autoconf golang cmake
yum install mysql-community-devel pam-devel libevent-devel bison-devel
yum install openssl-devel jemalloc-devel libicu-devel gtest-devel

如果安装最新版本的编译环境请参考如下地址
《How to overcome “'aclocal-1.15' is missing on your system” warning when compiling?》

Git获取FluffOS最新源码

git clone https://github.com/fluffos/fluffos.git

这个是fluffos 3.o.x 设置好的 local_options 兼容旧 Mudlib ( 后面有时间再补充每条设置的说明 )

/*
 * local_options.h: compile-time configuration of the driver
 */

/****************************************************************************
 * EVERY time you change ANYTHING in this file, RECOMPILE from scratch.     *
 * (type "make clean" then "make" on a UNIX system) Failure to do so may    *
 * cause the driver to behave oddly.                                        *
 ****************************************************************************/

/* NOTES: Many of the configurable options are now set in the runtime config.
 * 
 * This file only contain a list of default settings, for quick diffing .
 * See detailed explaination from 'local_options.README'
 */

#ifndef _LOCAL_OPTIONS_H_
#define _LOCAL_OPTIONS_H_


#define DEBUGMALLOC
#define DEBUGMALLOC_EXTENSIONS
/****************************************************************************
 *                              COMPAT                                      *
 ****************************************************************************/
#undef NO_ADD_ACTION
#undef NO_SNOOP
#undef NO_ENVIRONMENT
#undef NO_WIZARDS
#undef NO_LIGHT
#undef NO_SHADOWS
#undef NO_RESETS
#undef NO_BUFFER_TYPE
#undef ED_INDENT_CASE
#undef ED_USE_TABS
#undef SNOOP_SHADOWED
#undef FLUSH_OUTPUT_IMMEDIATELY

#undef LAZY_RESETS
#undef RECEIVE_ED
#undef PRIVS
#undef USE_ICONV
#undef IPV6
#undef DTRACE
#undef CHECK_MEMORY
#undef HAS_STATUS_TYPE
#undef CAST_CALL_OTHERS
#undef NONINTERACTIVE_STDERR_WRITE 
#undef INTERACTIVE_CATCH_TELL
#undef CALL_OTHER_TYPE_CHECK
#undef CALL_OTHER_WARN
#undef WARN_TAB
#undef WOMBLES
#undef GET_CHAR_IS_BUFFERED

#define SANE_EXPLODE_STRING
#undef REVERSIBLE_EXPLODE_STRING
#define NO_ANSI
#define STRIP_BEFORE_PROCESS_INPUT 
#define OLD_TYPE_BEHAVIOR
#define OLD_RANGE_BEHAVIOR
#define STRING_STATS
#define ARRAY_STATS
#define LOG_CATCHES
#define ARGUMENTS_IN_TRACEBACK
#define LOCALS_IN_TRACEBACK
#define MUDLIB_ERROR_HANDLER
#define TRAP_CRASHES
#define THIS_PLAYER_IN_CALL_OUT
#define CALLOUT_HANDLES

#define RECEIVE_SNOOP
#define PROFILE_FUNCTIONS
#define CACHE_STATS

#define OLD_ED
#define ED_INDENT_SPACES 4
#define ED_TAB_WIDTH 8
#define RESTRICTED_ED
#define SENSIBLE_MODIFIERS
#define ARRAY_RESERVED_WORD
#define REF_RESERVED_WORD

#define COMPRESS_FUNCTION_TABLES

#define CALLOUT_CYCLE_SIZE 512 
#define LARGEST_PRINTABLE_STRING 16384
#define MESSAGE_BUFFER_SIZE 16384 
#define APPLY_CACHE_BITS 20 
#define COMMAND_BUF_SIZE 6000
#define CFG_COMPILER_STACK_SIZE 600
#define CFG_MAX_GLOBAL_VARIABLES 65536
#define SMALL_STRING_SIZE 300
#define LARGE_STRING_SIZE 3000
#define MAX_SAVE_SVALUE_DEPTH 100
#define CFG_MAX_LOCAL_VARIABLES 300
#define CFG_EVALUATOR_STACK_SIZE 6000
#define CFG_MAX_CALL_DEPTH 300
#define CFG_LIVING_HASH_SIZE 4096
#define HEARTBEAT_INTERVAL 2000000
/****************************************************************************
 *                           MISCELLANEOUS                                  *
 ****************************************************************************/
#define CUSTOM_CRYPT
#undef COMPAT_32
#define DEFAULT_PRAGMAS PRAGMA_SAVE_TYPES + PRAGMA_ERROR_CONTEXT + PRAGMA_OPTIMIZE 
#define SAVE_EXTENSION ".o"
/****************************************************************************
 *                              PACKAGES                                    *
 ****************************************************************************/
#define PACKAGE_OPS
#define PACKAGE_CORE

#define PACKAGE_CONTRIB
#define PACKAGE_DEVELOP
#define PACKAGE_MATH
#define PACKAGE_MATRIX
#define PACKAGE_MUDLIB_STATS
#define PACKAGE_SOCKETS
#undef PACKAGE_PARSER
#define PACKAGE_EXTERNAL

#define PACKAGE_DB
#ifdef PACKAGE_DB
#define USE_MYSQL 1
#undef USE_MSQL
#undef USE_POSTGRES
#undef USE_SQLITE3
#define DEFAULT_DB  USE_MYSQL
#endif

#define ALLOW_INHERIT_AFTER_FUNCTION
#define PACKAGE_ASYNC
#define PACKAGE_SHA1
#undef PACKAGE_CRYPTO
#define PACKAGE_TRIM
#define PACKAGE_PCRE
#undef PACKAGE_DWLIB

#define PACKAGE_UIDS
#ifdef PACKAGE_UIDS
#define AUTO_SETEUID
#define AUTO_TRUST_BACKBONE
#endif

#define HAVE_ZLIB
#define PACKAGE_COMPRESS
#define SAVE_GZ_EXTENSION ".o.gz"
#undef PACKAGE_THREAD

#endif/* _LOCAL_OPTIONS_H_ */

编译FluffOS过程

$ cd fluffos
$ ./build.FluffOS     #如果你编译环境缺少依赖包会在这个过程提醒通过 yum search xxx 查找安装再继续build
$ make                #上面build这一步通过这一步基本没什么问题很顺利
$ make install  

部署你的 FluffOS+MudLib
假设你的fluffos编译目录在 /home/fluffos/
假如你的mudlib运行目录在 /home/xxxmud/

/home/fluffos/src/   #编译成功后的驱动 
               |--- driver

/home/xxxmud/ #mud布署目录
           |------ bin/
           |		|-- driver      #刚编译好的驱动移到这里
           |		|-- config.ini  #mud配置文件 要参考/home/fluffos/src/Config.example 修改 
           |
           |------ mudlib/	    #把你的mudlib整个打包解压放到这里
                     |-- adm
                     |-- binaries
                     |--.............

有关mud配置文件 参考 /home/fluffos/src/Config.example 进行修改
下面放一个config.ini 样例
vi /home/xxxmud/bin/config.ini

###############################################################################
#              Customizable runtime config file for FluffOS                   #
###############################################################################
# NOTE: All paths specified here are relative to the mudlib directory except  #
#       for mudlib directory, and binary directory.                           #
# Lines beginning with a # or a newline are ignored.                          #
###############################################################################

# name of this mud
# should be changed prioir to the 'mud ip', otherwise it might yield strange
# results to either yourself or other users of this mudlib!
name : HY-JHFY 

# for machines with multiple IP addresses, this specifies which one to use.  this
# replaces the SERVER_IP compile-time define.
#mud ip : 255.255.255.255
mud ip : 0.0.0.0 

# the external ports we support
external_port_1 : telnet 1863
external_port_2 : telnet 1864

# absolute pathname of mudlib
mudlib directory : /home/hymud/Mudlib_hy

# absolute pathname of driver/config dir
binary directory : /home/hymud/bin

# ------------------------------------------------------------------------
#
# You shouldn't change anything below this point unless you know what
# you're changing.... =)
#

# debug.log and author/domain stats are stored here
log directory : /log

# the directories which are searched by #include <...>
# for multiple dirs, separate each path with a ':'
# see also 'master::get_include_path'
include directories : /include

# the file which defines the master object
master file : /adm/single/master

# the file where all global simulated efuns are defined.
simulated efun file : /adm/single/simul_efun

# file to swap out objects; not used if time to swap is 0
swap file : /adm/tmp/swapfile

# alternate debug.log file name (assumed to be in specified 'log directory')
debug log file : debug.log

# This is an include file which is automatically #include'd in all objects
global include file : "/include/globals.h"

# default no-matching-action message
default fail message : 什么?

# default message when error() occurs (optional)
default error message : [1;33m你发现事情不大对了但是又说不上来。[2;37;0m

# if an object is left alone for a certain time, then the
# function clean_up will be called. This function can do anything,
# like destructing the object. If the function isn't defined by the
# object, then nothing will happen.
# This time should be substantially longer than the swapping time.
time to clean up : 900

# How many seconds until an object is reset again.
# This value should be somewhere reasonable in between 'time to clean up' and
# 'time to swap'.
time to reset : 1800

# How long time until an unused object is swapped out.
# Machine with too many players and too little memory: 900 (15 minutes)
# Machine with few players and lot of memory: 10000
# Machine with infinite memory: 0 (never swap).
time to swap : 900

# Set the size of the compiler stack. This defines how complex expressions
# the compiler can parse.  (unused currently)
compiler stack size : 600

# Set the maximum stack size of the stack machine. This stack will also
# contain all local variables and arguments.
evaluator stack size : 6000

# Max inherit chain size
inherit chain size : 30

# Maximum amount of "eval cost" per thread - execution is halted when 
# it is exceeded.
maximum evaluation cost : 30000000

# Max number of local variables in a function.
maximum local variables : 20000

# Set the maximum call depth for functions.
maximum call depth : 15000

# This is the maximum array size allowed for one single array.
maximum array size : 25000

# This is the maximum allowed size of a variable of type 'buffer'.
maximum buffer size : 400000

# Max size for a mapping
maximum mapping size : 150000

# maximum length of a string variable
maximum string length : 320000

# Maximum number of bits in a bit field. They are stored in printable
# strings, 6 bits per byte.
maximum bits in a bitfield : 12000

# max number of bytes you allow to be read and written with read_bytes 
# and write_bytes
maximum byte transfer : 200000

# Max size of a file allowed to be read by 'read_file()'.
maximum read file size : 320000

# Set the size of the shared string hash table.  This number should a prime,
# probably between 1000 and 30000; if you set it to about 1/5 of the number
# of distinct strings you have, you will get a hit ratio (number of
# comparisons to find a string) very close to 1, as found strings are
# automatically moved to the head of a hash chain.  You will never need more,
# and you will still get good results with a smaller table.
hash table size : 30000

# Set this like you did with the strings; probably set to about 1/4 of the
# number of objects in a game, as the distribution of accesses to objects is
# somewhat more uniform than that of strings.
object table size : 15000

# There is a hash table for living objects, used by find_living().
# This must be one of 4, 16, 64, 256, 1024, 4096
living hash table size : 4096 

# Set the granularity of game-time (shortest time interval visible ingame)
gametick msec : 100

# Set heartbeat interval in milliseconds (ms).
heartbeat interval msec : 1000

# explode():
#
# The old behavior (#undef both of the below) strips any number of delimiters
# at the start of the string, and one at the end.  So explode("..x.y..z..",
# ".") gives ({ "x", "y", "", "z", "" })
#
# sane explode string strips off at most one leading delimiter, and still
# strips off one at the end, so the example above gives
# ({ "", "x", "y", "", "z", "" }).
#
# reversible explode string overrides SANE_EXPLODE_STRING, and makes it so
# that implode(explode(x, y), y) is always x; i.e. no delimiters are ever
# stripped.  So the example above gives
# ({ "", "", "x", "y", "", "z", "", "" }).
sane explode string : 1
reversible explode string : 0

#
sane sorting : 1

# Some versions of the editor built in indent function use tabs for
# indenting. This options turns on a warning message for files indented with
# tabs instead of spaces.
warn tab : 0

# Don't allow spaces between start/end of array/mapping/functional token
# chars so ({1,2,3}) still works, but ( { 1 , 2 , 3 } ) doesn't and
# ({ 1 , 2 , 3 }) does.
wombles : 0

# Enable type checking for call_other() (-> operator on objects)
call other type check : 0 

# Make it warning instead of errors
call other warn : 0

# If you set this, the driver doesn't do any handling of runtime errors,
# other than to turn the heartbeats of objects off.  Information about the
# error is passed in a mapping to the error_handler() function in the master
# object.  Whatever is returned is put in the debug.log.
#
# A good mudlib error handler is one of the best tools for tracking down
# errors.  Unfortunately, you need to have one.  Check the testsuite or other
# libs for an example.
mudlib error handler : 1

# Completely disable the periodic calling of reset()
no resets : 0

# If this option is set, an object will only have reset() called in it when
# it is touched via call_other() or move_object() (assuming enough time has
# passed since the last reset).  If it is unset, then reset() will be called
# as always (which guaranteed that reset would always be called at least
# once).  The advantage of lazy resets is that reset doesn't get called in an
# object that is touched once and never again (which can save memory since
# some objects won't get reloaded that otherwise would).
lazy resets : 0

#
randomized resets : 0

# Set if you wish to disallow users from typing in commands that contain ANSI
# escape sequences.  Setting NO_ANSI causes all escapes (ASCII 27) to be
# replaced with a space ' ' before the string is passed to the action
# routines added with add_action.
no ansi : 1

# 'strip before process input' allows the location where the stripping is
# done to be controlled.  If it is set, then process_input() doesn't see ANSI
# characters either; if it is unset ESC chars can be processed by
# process_input(), but are stripped before add_actions are called.  Note that
# if NO_ADD_ACTION is defined, then setting 'no ansi' without
# 'strip before process input' is the same as unsetting 'no ansi'.
#
# If you anticipate problems with users intentionally typing in ANSI codes to
# make your terminal flash, etc set this.
strip before process input : 1

# Set this if you wish this_player() to be usable from within call_out()
# callbacks.
this player in call_out : 1

# Set this to enable the trace() and traceprefix() efuns.  (keeping this
# unset will cause the driver to run faster).
trace : 1

# Set this to enable code tracing (the driver will print out the previous
# lines of code to an error) eval_instruction() runs about twice as fast when
# this is not set (for the most common eoperators).
trace code : 0 

# Set this if you want catch_tell called on interactives as well as NPCs.  If
# this is set, the user object will need a catch_tell(msg) method that calls
# receive(msg);
interactive catch tell : 0

# Set this if you want snoop text to be sent to the receive_snoop() function
# in the snooper object (instead of being sent directly via add_message()).
# This is useful if you want to build a smart client that does something
# different with snoop messages.
receive snoop : 1

# Set this if you want snoop to report what is sent to the player even in the
# event that the player's catch_tell() is shadowed and the player may not be
# seeing what is being sent.  Messages of this sort will be prefixed with $$.
snoop shadowed : 0

#
reverse defer : 0

# If set, the driver can take the argument '-C' which will give the driver an
# interactive console (you can type commands at the terminal.)  Backgrounding
# the driver will turn off the console, but sending signal SIGTTIN (kill -21)
# to the driver can turn it back on.  Typing 'help' will display commands
# available.  The intent is to allow the inspection of things that are
# difficult to inspect from inside the mud.
has console : 1

# If set, all writes/tells/etc to noninteractive objects will be written to
# stderr prefixed with a ']' (old behavior).
#
# Compat status: Easy to support, and also on the "It's a bug!  No, it's
# a feature!" religious war list.
noninteractive stderr write : 0

# Set this if you want FluffOS to call crash() in master.c and then shutdown
# when signals are received that would normally crash the driver.
trap crashes : 1 

# Reintroduces a bug in type-checking that effectively renders compile time
# type checking useless.  For backwards compatibility.
#
# Compat status: dealing with all the resulting compile errors can be a huge
# pain even if they are correct, and the impact on the code is small.
old type behavior : 0 

# Set this if you want negative indexes in string or buffer range values
# (i.e.  foo = x[-2..-1]; not lvalue for e.g. not x[-2..-1] = foo, the latter is always
# illegal) to mean counting from the end 
#
# Compat status: Not horribly difficult to replace reliance on this, but not
# trivial, and cannot be simulated.
old range behavior : 1
warn old range behavior : 0 

# supress warnings about unused arguments; only warn about unused local
# variables.  Makes older code (where argument names were required) compile
# more quietly.
supress argument warnings : 1

#
enable_commands call init : 1

#
sprintf add_justified ignore ANSI colors : 1

# Defines the number of bits to use in the call_other cache (in interpret.c).
# 
# Memory overhead is (1 << APPLY_CACHE_BITS)*16.
# [assuming 32 bit pointers and 16 bit shorts]
#
# ACB:     entries:     overhead:
#   6           64            1k
#   8          256            4k
#  10        1,024           16k
#  12        4,096           64k
#  14       16,384          256k
#  16       65,536            1M
#  20    1,048,576           16M
#  22    4,194,304           64M
apply cache bits : 22

#
call_out(0) next level : 5000

# maximum number of users in the game (unused currently)
maximum users : 1000

好了下面我们开始启动mud服务吧继续往下看介绍将mud加为centos服务自动启动。

[root@mud]# /home/hymud/bin/driver /home/hymud/bin/config.conf&
在部署过程中会遇到的一些问题

1、Linux *.h *.c 乱码及回车符号问题
由于大多人编码在windows下编码在Linux上需要转换一下或者通过ftp上传时会可自动转码
使用下面的命令进行转码操作

[root@mud mud]# cd /home/xxxmud
[root@mud mud]# find . -name "*.h" -exec dos2unix {} \;
[root@mud mud]# find . -name "*.c" -exec dos2unix {} \;
[root@mud mud]# find . -name "*.o" -exec dos2unix {} \;

2、迁移后用户密码错误登陆不了以及不再支持static 全在这里进行更改

#define crypt oldcrypt        //因为FluffOS 默认使用md5加密不过 FluffOS  同样兼容 crypt 加密
#define static nosave        //不再支持static 这里定议为 static转换为nosave
#define private protected  //这里重要将 private 转义为 protected  

通过以上三个调整基本上能兼容大多的mudlib
修改 vi /home/xxxmud/mudlib/include/globals.h

/ globals.h 
// this file will be automatically included by the driver

#define SAVE_EXTENSION __SAVE_EXTENSION__
#pragma optimize 

//这里是修改mudlib达到兼容性
#define crypt oldcrypt 
#define static nosave
#define private protected

3、将你的mud 加入到 centos 的自动启动服务的教程及脚本.
编译启动脚本,记得要修改脚本内的以下配置为你的实际配置:

mudstart 这个脚本放到 /home/hymud/bin 下面,根据你的目录自己修改.

#!/bin/bash
########## Mud Start Config ############
DIR=/home/xxxmud/bin    #你实际的mud fluffos驱动地址
MUDCONFIG=${DIR}/config.ini  #你mud的配置文件名字
MUDNAME=HY6             #你mud的名字用于存放进程pid号
MUDSTARTNAME=xxxmud     #你mud这个启动脚本的名字
########################################
RETVAL=0 
NUM=0

#ulimit -n 65535 
echo 999999999 > /proc/sys/vm/max_map_count

usage ()
{
	echo $"Usage: $0 {start|stop|restart|status}" 1>&2
	RETVAL=2
}   

start ()
{
        ${DIR}/driver ${MUDCONFIG} &
	echo $! > ${DIR}/${MUDNAME}.pid
}

stop ()
{
	function kill_pid() {
		if [[ -f $1 ]]; then
			kill -9 `cat $1`
			rm $1
		fi
	}
	kill_pid ${DIR}/${MUDNAME}.pid
	[ "$?" != "0" ] && RETVAL=1
}

status ()
{
	while true
	do 

	sn=`ps -ef | grep driver | grep -v grep |awk '{print $2}'`

        if [ ! $sn ]; then
           sn=0
        fi

	function ck_pid() {
		if [[ -f $1 ]]; then
			if [[ ${sn} = `cat $1` ]]; then
				echo "${MUDSTARTNAME} Service Runing PID: ${sn}"
			else
				echo "${MUDSTARTNAME} Service Not Run"
				restart 
			fi
		else
			restart	
		fi
	}

	ck_pid ${DIR}/${MUDNAME}.pid

	sleep 5
	done& 
}

restart ()
{
	stop
	start
}

case "$1" in
    stop) stop ;;
    status) status ;;
    start|restart) restart ;;
    *) usage ;;
esac

exit $RETVAL

hymud 这个脚本做为系统的服务进行启动,启动调用 mudstart 脚本
有关 /home/hymud/bin/ 修改成你的路径

#!/bin/bash
#chkconfig: 2345 80 90
#description:hymud
########## Mud Start Config ############
/home/hymud/bin/mudstart status&

然后把 hymud 脚本加入到系统服务

cp hymud /etc/init.d/         #把脚本拷到 /etc/init.d/
chmod +x /etc/init.d/hymud    #附于脚本的执行权限
chkconfig --add hymud         #把hymud 加入系统服务
chkconfig hymud on            #激活hymud 开机自动启动
service xxxmud start  #启动mud服务
service xxxmud restart #重启mud服务
service xxxmud stop    #停止mud服务
service xxxmud status  #查看mud运行状态

最后推荐几个MUD站点

FluffOS 中文站:  http://www.fluffos.net/index.php
北大侠客行MUD论坛http://pkuxkx.net/forum/index.php 
泥巴创世纪 http://www.mudbuilder.com
泥巴客栈http://www.xiaqiang.com.cn

《海洋IV - 江湖风云录》 已稳定运行于FluffOS Mysql

              ≡ ─────海洋VI- 江湖风云─────≡     
             ≡ ────全新中文网络泥巴游戏─────≡   

                   【    
          ◎■■■■】〓〓〓〓〓〓〓〓〓〓〓> 
                   【   
  |※※※※         笑看飞花落海洋  神州大地鹰飞扬         ※※※※|
  |※※※※         一浪打浪又一浪  江山代代人才出         ※※※※|
  |※※※※         英雄独剑走江湖  且把真心照月明         ※※※※|
  |※※※※         誓为红颜去闯荡  世世代代永相依         ※※※※|
  |※※※※         桃花梨花落海洋  可知处处是我家         ※※※※|
  |※※※※         情深缘浅论短长  乱世英雄乱世舞         ※※※※|
  |※※※※         他日征途伴英雄  愿我海洋浪不停         ※※※※|
  |※※※※         一样痴心一样狂  海洋英雄梦不息         ※※※※|  

           -----------------------------------  

          《海洋VI》 QQ群       3541849 8372963  
          《海洋VI》 主页地址   http://www.jhfy.org 
          《海洋VI》 游戏地址   hy.21sun.net 1863
          
如果输入英文名字后没有反应说明您使用的软件不合适请使用 zMUD 进行游戏

什么是 FluffOS?