MUD游戏开发直接学习开源的项目是不错的方式,大家也都很喜欢了看其它MUD游戏的代码学习,但是游戏代码也有一些笨重的地方,这里推荐几个专门用来学习和测试的LIB,方便需要的同学。
testsuite
这是FluffOS驱动自带的测试LIB,优势是对几乎所有efun都写了测试用例,如果你不知道某个efun的用法,可以看看官方给的测试用例,相关代码目录 /single/tests/。
除了下载FluffOS源码获取这个测试LIB外,为方便有需要的人,也提供一个单独可用的LIB下载:
LPC-TEST
这是本站LPC教程使用的学习LIB,本 LIB 和 fluffos 自带的 testsuite 不同点是 testsuite 主要是驱动功能测试,本 LIB 除了基础 LPC语言教程代码(/cmds/demo/)外,另外提供具体游戏开发的功能模块演示,比如:玩家基础功能、游戏地图、虚拟迷宫、战斗和怪物变身等等,用更少的代码理解游戏开发的功能实现。
LPC-TEST项目下载地址:
xMUD
不管是testsuite还是LPC-TEST都是针对最新的FluffOS驱动,对旧版驱动不提供支持,有时我们需要测试mudos、FluffOS v2017和 FluffOS v2019的差异怎么办?为些我写了一个非常小的项目xMUD,几乎不带任何游戏功能,只是能使用mudos/FluffOS v2017和v2019驱动(对应不同的运行时配置文件),方便一些功能测试。
_ _______ _______ _________ _______ _______ _________
( \ ( ____ )( ____ \ \__ __/( ____ \( ____ \\__ __/
| ( | ( )|| ( \/ ) ( | ( \/| ( \/ ) (
| | | (____)|| | | | | (__ | (_____ | |
| | | _____)| | | | | __) (_____ ) | |
| | | ( | | | | | ( ) | | |
| (____/\| ) | (____/\ | | | (____/\/\____) | | |
(_______/|/ (_______/ )_( (_______/\_______) )_(
---------------------------------------------------------------------
最小LPC测试LIB,可使用mudos、fluffos v2017和fluffos v2019驱动。
* mudos运行时配置文件:mudos.cfg,默认端口 2000
* fluffos v2017运行时配置文件:v2017.cfg,默认端口 2017
* fluffos v2019运行时配置文件:v2019.cfg,默认端口 2019
> 核心测试指令:eval update variables
---------------------------------------------------------------------
xMUD项目下载地址:
LPCC
FluffOS驱动自带了一个lpcc调试程序,相对在游戏中调试代码,使用lpcc能看到更多信息,弊端是不能调试玩家相关的内容,但对一些和玩家对象无关的代码使用lpcc也很方便,运行后自动退出,不用每次update。为方便只用lpcc,我写了一个和xMUD一样迷你的项目用来快速测试一些代码。
LPC代码编译调试项目,使用方式:
lpcc config.ini <你的代码文件>
如在项目根目录新建文件test.c:
void create()
{
debug(__FILE__);
}
编译运行:lpcc config.ini test
➜ lpcc git:(master) ✗ lpcc config.ini test
Processing config file: config.ini
New Debug log location: "log/debug.log".
Initializing internal stuff ....
Event backend in use: epoll
Loading simul_efun file : kernel/simulated_efun
Loading master file: kernel/master
"/test.c"
NAME: /test.c
INHERITS:
name fio vio
---------------- --- ---
FUNCTIONS:
name offset mods flags fio # locals # args
--------------------- ------ ---- ------- --- -------- ------
0: create 0 +-- --s---- 0 0
;;; test.c
VARIABLES:
STRINGS:
0: test.c
1: include/globals.h
2: /test.c
DISASSEMBLY:
;; Function: void create()
0000: 0E 02 short_string ; "/test.c"
0002: 71 00 00 01 simul_efun ; "debug" args: 1
0006: 01 pop ;
0007: 2F return_zero ;
; test.c:3
;;; *** Line Number Info ***
absolute line -> (file, line) table:
0 lines from 1 [test.c]
1 lines from 2 [include/globals.h]
5 lines from 1 [test.c]
address -> absolute line table:
0000-0007: 4
Trace duration: 7007.700000 us, dumping 29 events to trace_lpcc.json in separate thread.
[thread 139666774755072d]: Dump trace successfully to file trace_lpcc.json, cost 0 ms.
LPCC项目下载地址: