- 精华
- 阅读权限
- 90
- 贡献
- 人
- 好友
- 相册
- 分享
- 听众
- 收听
- 注册时间
- 2010-1-8
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
本帖最后由 bfdz49 于 2026-2-23 15:34 编辑
- <font color="#ff0000">这个版本被我全部替换linux系统来修复 不过问题很多我修复差不多 注意我只替换C++11 移植到 Linux 的难度太大,支持 Linux 的开源游戏服务器框架,我个人修复问题特别多在 Linux 上安装 VirtualBox 或 VMware,运行 Windows 虚拟机进行编译</font> 没有一定的技术别下载 这个源代码很多东西有问题
复制代码- ================================================================================
- Xgame 游戏源码 - VS2022 & C++11 改造完成
- ================================================================================
- 修改日期: 2026-02-21
- 修改版本: 1.0
- ================================================================================
- 一、服务端和客户端改造内容
- ================================================================================
- 1. 项目文件转换 (VS2008 -> VS2022)
- ✓ 将 .vcproj 转换为 .vcxproj 格式
- ✓ 更新工具集到 v143 (Visual Studio 2022)
- ✓ 更新解决方案文件到 VS2022 格式
- ✓ 添加 x86/x64 平台支持
- ✓ 设置 C++20 语言标准
- 2. C++11/C++20 支持
- ✓ 添加 C++11 标准头文件:
- - <atomic>
- - <chrono>
- - <thread>
- - <mutex>
- - <condition_variable>
- - <memory>
- - <functional>
- ✓ 设置 LanguageStandard 为 stdcpp20
- 3. 编译配置
- ✓ Debug/Release 配置
- ✓ Win32/x64 平台支持
- ✓ Unicode 字符集
- ✓ Windows 10 SDK
- ================================================================================
- 二、服务器架构
- ================================================================================
- 服务端 (SrcServer):
- ├── Cluster/ # 集悍衿�
- │ ├── GatewayServer # 网关服务器
- │ ├── LoginServer # 登录服务器
- │ ├── CenterServer # 中心服务器
- │ ├── WorldServer # 世界服务器
- │ ├── VoiceServer # 语音服务器
- │ 俯ぉ� ...
- ├── SceneServer/ # 场景服务器
- │ ├── EntityServer # 实体服务器
- │ ├── SkillServer # 技能服务器
- │ ├── TaskServer # 任务服务器
- │ ├── ChatServer # 聊天服务器
- │ └── ...
- ├── Social/ # 社交服务器
- │ ├── ChatService # 聊天服务
- │ ├── FriendService # 好友服务
- │ ├── TeamService # 队伍服务
- │ └── ...
- └── DBSvr/ # 数据库服务器
- 客户端 (SrcClient):
- ├── Client/ # 主客户端
- │ ├── Game # 游戏主程序
- │ ├── GameUI # 游戏UI
- │ └── ...
- ├── RenderEngine/ # 渲染引擎
- ├── UI/ # UI系统
- └── ...
- ================================================================================
- 三、编译说明
- ================================================================================
- Windows (Visual Studio 2022):
- 1. 安装 Visual Studio 2022
- 2. 安装 "使用 C++ 的桌面开发" 工作负载
- 3. 打开解决方案文件 (.sln)
- 4. 选择配置 (Debug/Release) 和平台 (x86/x64)
- 5. 按 F7 编译
- ================================================================================
- 四、文件统计
- ================================================================================
复制代码- [root@192 gameserver]# # 重新编译
- [root@192 gameserver]# cd /opt/moleserver
- [root@192 moleserver]# make 2>&1 | tail -30
- from CServerServiceManager.h:4,
- from CServerServiceManager.cpp:1:
- ../../include/molnet/dataprovider.h:59:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error) = 0;
- ^~~~~
- ../../include/molnet/dataprovider.h:62:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error) = 0;
- ^~~~~
- ../../include/molnet/dataprovider.h:65:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error) = 0;
- ^~~~~
- In file included from ../../include/molnet/Network.h:18:0,
- from cdefines.h:4,
- from CServerServiceManager.h:4,
- from CServerServiceManager.cpp:1:
- ../../include/molnet/mysqldataprovider.h:58:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- ../../include/molnet/mysqldataprovider.h:61:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- ../../include/molnet/mysqldataprovider.h:64:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- g++ -std=c++11 -o ../../bin/games/libgame_ddz.so objs/*.o -I ../../include/molnet -O2 -shared -fexceptions -fPIC -DLINUX -lpthread -L ../../libs -lmolnet -lmysqlclient -ljsoncpp
复制代码- [root@192 moleserver]# make 2>&1 | tail -50
- from cdefines.h:4,
- from crobotlogicframe.h:4,
- from crobotlogicframe.cpp:1:
- ../../include/molnet/mysqldataprovider.h:58:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- ../../include/molnet/mysqldataprovider.h:61:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- ../../include/molnet/mysqldataprovider.h:64:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- g++ -std=c++11 -c -I ../../include/molnet -O2 -shared -fexceptions -fPIC -DLINUX -lpthread -L ../../libs -lmolnet -lmysqlclient -ljsoncpp CServerServiceManager.cpp -o objs/CServerServiceManager.o
- In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/ext/hash_map:60:0,
- from ../../include/molnet/common.h:53,
- from ../../include/molnet/Network.h:7,
- from cdefines.h:4,
- from CServerServiceManager.h:4,
- from CServerServiceManager.cpp:1:
- /opt/rh/devtoolset-7/root/usr/include/c++/7/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. [-Wcpp]
- #warning \
- ^~~~~~~
- In file included from ../../include/molnet/Network.h:16:0,
- from cdefines.h:4,
- from CServerServiceManager.h:4,
- from CServerServiceManager.cpp:1:
- ../../include/molnet/dataprovider.h:59:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error) = 0;
- ^~~~~
- ../../include/molnet/dataprovider.h:62:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error) = 0;
- ^~~~~
- ../../include/molnet/dataprovider.h:65:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error) = 0;
- ^~~~~
- In file included from ../../include/molnet/Network.h:18:0,
- from cdefines.h:4,
- from CServerServiceManager.h:4,
- from CServerServiceManager.cpp:1:
- ../../include/molnet/mysqldataprovider.h:58:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- ../../include/molnet/mysqldataprovider.h:61:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- ../../include/molnet/mysqldataprovider.h:64:3: warning: dynamic exception specifications are deprecated in C++11 [-Wdeprecated]
- throw (std::runtime_error);
- ^~~~~
- g++ -std=c++11 -o ../../bin/games/libgame_dzpk.so objs/*.o -I ../../include/molnet -O2 -shared -fexceptions -fPIC -DLINUX -lpthread -L ../../libs -lmolnet -lmysqlclient -ljsoncpp
- make[1]: 离开目录“/opt/moleserver/games/dzpk”
复制代码- [root@192 bin]# find /opt/moleserver -name "*.sh" 2>/dev/null
- find /opt/moleserver -type f -executable 2>/dev/null | grep -E "(server|start|run)" | head -20
- /opt/moleserver/CMS/vendor/paragonie/random_compat/build-phar.sh
- [root@192 bin]# find /opt/moleserver -type f -executable 2>/dev/null | grep -E "(server|start|run)" | head -20
- /opt/moleserver/.git/hooks/applypatch-msg.sample
- /opt/moleserver/.git/hooks/commit-msg.sample
- /opt/moleserver/.git/hooks/post-update.sample
- /opt/moleserver/.git/hooks/pre-applypatch.sample
- /opt/moleserver/.git/hooks/pre-commit.sample
- /opt/moleserver/.git/hooks/pre-rebase.sample
- /opt/moleserver/.git/hooks/prepare-commit-msg.sample
- /opt/moleserver/.git/hooks/update.sample
- /opt/moleserver/bin/games/libgame_ddz.so
- /opt/moleserver/bin/games/libgame_lhd.so
- /opt/moleserver/bin/games/libgame_lunpan.so
- /opt/moleserver/bin/games/libgame_sszp.so
- /opt/moleserver/bin/games/libgame_bcbm.so
- /opt/moleserver/bin/games/libgame_brnn.so
- /opt/moleserver/bin/games/libgame_hlddz.so
- /opt/moleserver/bin/games/libgame_xzmj.so
- /opt/moleserver/bin/games/libgame_zjh.so
- /opt/moleserver/bin/games/libgame_dzpk.so
- /opt/moleserver/bin/account_server
- /opt/moleserver/bin/game_server
- [root@192 bin]# cd /opt/moleserver/bin
- [root@192 bin]#
- [root@192 bin]#
- [root@192 bin]# ls configs/
- database.ini
- [root@192 bin]#
- [root@192 bin]#
- [root@192 bin]# ./account_server &
- [1] 60462
- [root@192 bin]#
- [root@192 bin]# # 3. 启动游戏主服务器
- [root@192 bin]# ./game_server &
- [2] 60463
- [root@192 bin]# 使用方法:account_server 账号服务器配置ID
- 使用方法:game_server 游戏服务器配置ID
复制代码
更新Windows Visual Studio 2022 源代码本身是Visual 2008 现在2008很多库没有 无法实现 我已经全部升级 有什么问题留言
通过网盘分享的文件:Xgame2001_source.rar
链接: https://pan.baidu.com/s/1DDwn4dDPi4NmXfhBKGhtcg 提取码: g26b
安装 MySQL
- sudo yum install mysql-server mysql -y
- sudo yum install mariadb-server mariadb -y
复制代码
创建数据库
# 登录 MySQL
mysql -u root -p
# 创建数据库
CREATE DATABASE moleweb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# 导入数据(如果有 SQL 文件)
mysql -u root -p moleweb < /opt/moleserver/database/moleweb.sql
检查 database.ini
cat /opt/moleserver/bin/configs/database.ini
确保配置与 MySQL 设置匹配
| id | servername | serverport | serverip | createtime | serverstate | curplayercount |
+----+------------------+------------+-----------+---------------------+-------------+----------------+
| 1 | 验证服务器2 | 3333 | 127.0.0.1 | 2019-12-24 14:06:35 | 0 | 0 |
+----+------------------+------------+-----------+---------------------+-------------+----------------+
[root@192 bin]#
[root@192 bin]# # 检查 mol_gameroom 表
[root@192 bin]# mysql -u root -p123456 -e "SELECT * FROM moleweb.mol_gameroom WHERE id=1;"
+----+--------+--------------------------+------------+------------+------------------+-----------+------------+-----------+-----------+-------------+--------------------+---------------------+---------------------+-------+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
| id | gameid | servername | serverport | tablecount | tableplayercount | serverip | gamingtype | lastmoney | pielement | roomrevenue | currealplayercount | currobotplayercount | createtime | state | QueueGaming | serverparameter | gstate |
+----+--------+--------------------------+------------+------------+------------------+-----------+------------+-----------+-----------+-------------+--------------------+---------------------+---------------------+-------+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
} | 0 |
+----+--------+--------------------------+------------+------------+------------------+-----------+------------+-----------+-----------+-------------+--------------------+---------------------+---------------------+-------+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
[root@192 bin]# cd /opt/moleserver/bin
[root@192 bin]# ./account_server 1
[14:57][2026-02-23 14:57:17] opening '/opt/moleserver/bin/logs/account1_server_normal.log'
[14:57][2026-02-23 14:57:17] opening '/opt/moleserver/bin/logs/account1_server_error.log'
./game_server 1
[14:57] [BSC] account_server.cpp:63 main 数据库:localhost root 123456 moleweb 连接成功。
[14:57] [BSC] account_server.cpp:83 main 登陆服务器:127.0.0.1,端口:3333 启动成功。
[14:57] [BSC] account_server.cpp:85 main 服务器启动成功,开始处理...
要做运行移植工具
需要 C++ Windows/Linux 双平台专家 我个人可以解决好他了
我全部移植支持Linux
[root@192 Xgame2001_source]#
[root@192 Xgame2001_source]# chmod +x port_to_linux.sh
[root@192 Xgame2001_source]# cd /home/Xgame2001_source
[root@192 Xgame2001_source]# bash port_to_linux.sh
========================================
Xgame2001 Windows to Linux 移植工具
========================================
> # 9. 统计信息
> echo "[9/10] 统计信息..."
> echo "源文件数量: $(find SrcServer -name "*.cpp" | wc -l)"
> echo "头文件数量: $(find SrcServer -name "*.h" | wc -l)"
>
> # 10. 完成
> echo "[10/10] 移植准备完成!"
> echo ""
> echo "使用方法:"
> echo " 1. cd /home/Xgame2001_source"
> echo " 2. bash build_linux_auto.sh"
> echo ""
> echo "如果编译失败,需要手动修复剩余的错误。"
> echo "========================================"
>
> ENDSCRIPT
[root@192 Xgame2001_source]#
[root@192 Xgame2001_source]# chmod +x port_to_linux.sh
[root@192 Xgame2001_source]# cd /home/Xgame2001_source
[root@192 Xgame2001_source]# bash port_to_linux.sh
========================================
Xgame2001 Windows to Linux 移植工具
========================================
> # 9. 统计信息
> echo "[9/10] 统计信息..."
> echo "源文件数量: $(find SrcServer -name "*.cpp" | wc -l)"
> echo "头文件数量: $(find SrcServer -name "*.h" | wc -l)"
>
> # 10. 完成
> echo "[10/10] 移植准备完成!"
> echo ""
> echo "使用方法:"
> echo " 1. cd /home/Xgame2001_source"
> echo " 2. bash build_linux_auto.sh"
> echo ""
> echo "如果编译失败,需要手动修复剩余的错误。"
> echo "========================================"
>
> ENDSCRIPT
[root@192 Xgame2001_source]#
[root@192 Xgame2001_source]# chmod +x port_to_linux.sh
[root@192 Xgame2001_source]# cd /home/Xgame2001_source
[root@192 Xgame2001_source]# bash port_to_linux.sh
========================================
Xgame2001 Windows to Linux 移植工具
========================================
[1/10] 创建 Linux 兼容层...
[2/10] 创建 Windows API 兼容层...
[3/10] 替换 Windows 头文件...
[4/10] 替换 Windows 关键字...
[9/10] 统计信息...
源文件数量: 1706
头文件数量: 2338
[10/10] 移植准备完成!
|
评分
-
查看全部评分
|