【轉】ffluos編譯


FluffOS是在MUDOS基礎上更新完成的。進行了許多新功能和bug修復。 針對LPC有很好的兼容性,如果你的MUD運行MUDOS V22+版本,可以很容易運行在fluffos上。
系統環境:

CnetOS 7.x mini 最小化安裝
 

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

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

安裝編譯環境

yum install git
yum install gcc-c++
yum install bison-devel
yum install libevent-devel
yum install zlib-devel
yum install pcre-devel
yum install autoconf
yum install dos2unix 
yum install golang
yum install mysql-community-devel
yum install unzip
yum install pam-devel
 

Git獲取FluffOS最新源碼

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

這個是fluffos 3.o.x  設置好的 local_options ,兼容舊 Mudlib ( 后面有時間再補充每條設置的說明 )

 

注意: #undef SENSIBLE_MODIFIERS 

如果關注支持(static 模式),如果打開將不支持(static模式)

需要修改mudlib的部分代碼,關健詞(static、array),static 改為 nosave, array改為 mixed

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

#ifndef _LOCAL_OPTIONS_H_
#define _LOCAL_OPTIONS_H_

/****************************************************************************
 *                              COMPAT                                      *
 ****************************************************************************/
#undef NO_ADD_ACTION
#undef NO_SNOOP
#undef NO_ENVIRONMENT
#undef NO_WIZARDS
#undef NO_LIGHT
#define OLD_ED
#undef ED_INDENT_CASE
#define ED_INDENT_SPACES 4
#undef ED_USE_TABS
#define ED_TAB_WIDTH 8
#undef RECEIVE_ED
#define RESTRICTED_ED
#define SENSIBLE_MODIFIERS
#define ARRAY_RESERVED_WORD

/****************************************************************************
 *                           MISCELLANEOUS                                  *
 ****************************************************************************/
#define CUSTOM_CRYPT
#undef COMPAT_32
#define DEFAULT_PRAGMAS PRAGMA_SAVE_TYPES + PRAGMA_ERROR_CONTEXT + PRAGMA_OPTIMIZE
#define SAVE_EXTENSION ".o"
#undef PRIVS
#undef NO_SHADOWS
#undef USE_ICONV
#undef IPV6
#undef DTRACE

/****************************************************************************
 *                              PACKAGES                                    *
 ****************************************************************************/
#define PACKAGE_OPS
#define PACKAGE_CORE

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

#ifdef PACKAGE_DB
#define USE_MYSQL 1
#undef USE_MSQL
#undef USE_POSTGRES
#undef USE_SQLITE3
#define DEFAULT_DB  USE_MYSQL 
#endif  
 
#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
#undef AUTO_TRUST_BACKBONE
#endif
#define PACKAGE_COMPRESS
#define SAVE_GZ_EXTENSION ".o.gz"
#undef PACKAGE_THREAD

#undef DEBUGMALLOC 
#undef DEBUGMALLOC_EXTENSIONS
#undef CHECK_MEMORY 

#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、dtrace_compile)
        |
        |--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

name : HY-JHFY 
mud ip : 0.0.0.0    # all ip
external_port_1 : telnet 8888
external_port_2 : binary 6666
mudlib directory : /home/xxxmud/code
binary directory : /home/xxxmud/bin
log directory : /log
include directories : /include
master file : /adm/single/master
simulated efun file : /adm/single/simul_efun
swap file : /adm/single/swapfile
debug log file : debug.log
global include file : "/include/globals.h"
default fail message : What?
default error message :
time to clean up : 900
time to reset : 1800
time to swap : 900
compiler stack size : 600
evaluator stack size : 6000
inherit chain size : 30
maximum evaluation cost : 30000000
maximum local variables : 200
maximum call depth : 150
maximum array size : 25000
maximum buffer size : 400000
maximum mapping size : 150000
maximum string length : 320000
maximum bits in a bitfield : 12000
maximum byte transfer : 200000
maximum read file size : 320000
hash table size : 7001
object table size : 1501
living hash table size : 256
gametick msec : 1000
heartbeat interval msec : 1000
sane explode string : 1
reversible explode string : 0
sane sorting : 1
warn tab : 0
wombles : 0
call other type check : 0
call other warn : 0
mudlib error handler : 1
no resets : 0
lazy resets : 0
randomized resets : 1
no ansi : 1
strip before process input : 1
this player in call_out : 1
trace : 1
trace code : 0
interactive catch tell : 0
receive snoop : 1
snoop shadowed : 0
reverse defer : 0
has console : 1
noninteractive stderr write : 0
trap crashes : 1
old type behavior : 0
old range behavior : 0
warn old range behavior : 1
supress argument warnings : 1
enable_commands call init : 1
sprintf add_justified ignore ANSI colors : 1
apply cache bits : 22
call_out(0) next level : 1000
maximum users : 5000
 

好了下面我們開始啟動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、遷移后用戶密碼錯誤登陸不了

因為FluffOS 默認使用md5加密,不過 FluffOS  同樣兼容 crypt 加密

修改 vi /home/xxxmud/mudlib/include/globals.h   不同的mudlib 可能位置不一樣

加入 #define crypt oldcrypt   即可。

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

#define SAVE_EXTENSION __SAVE_EXTENSION__
#define save_binary

#pragma optimize 
#pragma save_binary 

#define crypt oldcrypt  
 

3、服務器端出現很多警告信息

出現這個問題,一般是因為你編譯時的 local_options 設置問題,去掉 PRAGMA_WARNINGS  重新編譯。
修改: #define DEFAULT_PRAGMAS PRAGMA_WARNINGS + PRAGMA_SAVE_TYPES + PRAGMA_ERROR_CONTEXT + PRAGMA_OPTIMIZE
改為: #define DEFAULT_PRAGMAS PRAGMA_SAVE_TYPES + PRAGMA_ERROR_CONTEXT + PRAGMA_OPTIMIZE
 

4、將你的mud 加入到 centos 的自動啟動服務的教程及腳本

編譯啟動腳本

記得要修改腳本內的以下配置為你的實際配置

########## Mud Start Config ############
DIR=/home/xxxmud/bin    #你實際的mud fluffos驅動地址
MUDCONFIG=${DIR}/config.ini  #你mud的配置文件名字
MUDNAME=HY6             #你mud的名字,用於存放進程pid號
MUDSTARTNAME=xxxmud     #你mud這個啟動腳本的名字
########################################
vi /etc/rc.d/init.d/xxxmud

#!/bin/bash
#chkconfig: 2345 80 90
#description:hymud
########## Mud Start Config ############
DIR=/home/xxxmud/bin
MUDCONFIG=${DIR}/config.ini
MUDNAME=HY6
MUDSTARTNAME=xxxmud
########################################

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 ()
{
        while(( $NUM < 1 ))
        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
                                  ${DIR}/driver ${MUDCONFIG} &
                echo $! > ${DIR}/${MUDNAME}.pid 
                        fi
                else 
            ${DIR}/driver ${MUDCONFIG} &
            echo $! > ${DIR}/${MUDNAME}.pid
        fi
        }

        ck_pid ${DIR}/${MUDNAME}.pid
        sleep 5
        done
}

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

status ()
{ 
    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" 
            fi    
        fi
    }

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

restart ()
{
    stop
    start
}

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

exit $RETVAL
 

然后加入系統服務來啟動

#改變權限

chown root.root /etc/rc.d/init.d/xxxmud #所有用戶都可以執行,單只有root可以修改
chmod +x /etc/rc.d/init.d/xxxmud #將mysqld 放入linux啟動管理體系中
chkconfig --add xxxmud #打開自啟動
chkconfig xxxmud on
 

#相關使用命令

service xxxmud start  #啟動mud服務
service xxxmud restart #重啟mud服務
service xxxmud stop    #停止mud服務
service xxxmud status  #查看mud運行狀態
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM