远征ol源代码转换linux系统
本帖最后由 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 编译
================================================================================
四、文件统计
================================================================================
# # 重新编译
# cd /opt/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# 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: 离开目录“/opt/moleserver/games/dzpk”# 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
# 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
# cd /opt/moleserver/bin
#
#
# ls configs/
database.ini
#
#
# ./account_server &
60462
#
# # 3. 启动游戏主服务器
# ./game_server &
60463
# 使用方法:account_server 账号服务器配置ID
使用方法:game_server 游戏服务器配置ID
更新WindowsVisual 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 |
+----+------------------+------------+-----------+---------------------+-------------+----------------+
#
# # 检查 mol_gameroom 表
# 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 |
+----+--------+--------------------------+------------+------------+------------------+-----------+------------+-----------+-----------+-------------+--------------------+---------------------+---------------------+-------+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+--------+
# cd /opt/moleserver/bin
# ./account_server 1
opening '/opt/moleserver/bin/logs/account1_server_normal.log'
opening '/opt/moleserver/bin/logs/account1_server_error.log'
./game_server 1
account_server.cpp:63 main 数据库:localhost root 123456 moleweb 连接成功。
account_server.cpp:83 main 登陆服务器:127.0.0.1,端口:3333 启动成功。
account_server.cpp:85 main 服务器启动成功,开始处理...
要做运行移植工具
需要 C++ Windows/Linux 双平台专家 我个人可以解决好他了
我全部移植支持Linux
#
# chmod +x port_to_linux.sh
# cd /home/Xgame2001_source
# bash port_to_linux.sh
========================================
Xgame2001 Windows to Linux 移植工具
========================================
> # 9. 统计信息
> echo " 统计信息..."
> echo "源文件数量: $(find SrcServer -name "*.cpp" | wc -l)"
> echo "头文件数量: $(find SrcServer -name "*.h" | wc -l)"
>
> # 10. 完成
> echo " 移植准备完成!"
> echo ""
> echo "使用方法:"
> echo "1. cd /home/Xgame2001_source"
> echo "2. bash build_linux_auto.sh"
> echo ""
> echo "如果编译失败,需要手动修复剩余的错误。"
> echo "========================================"
>
> ENDSCRIPT
#
# chmod +x port_to_linux.sh
# cd /home/Xgame2001_source
# bash port_to_linux.sh
========================================
Xgame2001 Windows to Linux 移植工具
========================================
> # 9. 统计信息
> echo " 统计信息..."
> echo "源文件数量: $(find SrcServer -name "*.cpp" | wc -l)"
> echo "头文件数量: $(find SrcServer -name "*.h" | wc -l)"
>
> # 10. 完成
> echo " 移植准备完成!"
> echo ""
> echo "使用方法:"
> echo "1. cd /home/Xgame2001_source"
> echo "2. bash build_linux_auto.sh"
> echo ""
> echo "如果编译失败,需要手动修复剩余的错误。"
> echo "========================================"
>
> ENDSCRIPT
#
# chmod +x port_to_linux.sh
# cd /home/Xgame2001_source
# bash port_to_linux.sh
========================================
Xgame2001 Windows to Linux 移植工具
========================================
创建 Linux 兼容层...
创建 Windows API 兼容层...
替换 Windows 头文件...
替换 Windows 关键字...
统计信息...
源文件数量: 1706
头文件数量: 2338
移植准备完成!
沙发: 谢谢分享 多谢分享,虽然不懂。。。 多谢分享,先收藏,有空编译看看 感谢这位愿意分享的小伙伴!!!哈拉少!!!(年初七快乐!!!) :感谢分享!!! 不发源码,发这些有什么用? 多谢分享,先收藏, 这工作量太大了,你好有毅力 等下你了 感谢楼主分享 感谢分享大佬牛掰 这么好的帖子,倘若别人看不到,那么不是浪费楼主的心血吗?经过痛苦的思想斗争,我终于下定决心,我要把这个帖子一直往上顶,往上顶!顶到所有人都看到为止。
远征ol源代码转换linux系统 感谢大神分享 66666666666 远征ol源代码转换linux系统
页:
[1]