魔兽世界单机版(模拟器)入门介绍--Starting off with WoW Emulation. 翻译

本指南详细介绍了魔兽世界单机版的搭建过程,包括数据库、DBC文件、源代码编译等方面的知识,适合初学者及希望深入了解魔兽单机版技术的玩家。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:从06年玩魔兽到现在也13年了。5.48的时候在国外读研、时间特别多,在艾苏恩的“魔兽夜店”lm公会(永远记得这段快乐的时光),围攻奥格达到了我的顶峰(带团),回国后找工作6.X没玩。从7.x就开始咸鱼,H都没通。现在也得结婚成家了。以后更加咸鱼了,指不定哪天就AFK。差不多06年的时候就混迹于大芒果、藏宝湾这两个网站,虽然是高中生,那时候用家里的破电脑就开始搭建单机版,改数据库。晚上在自己房间能玩到4点多。从那时候对编程有了非常大的兴趣,以至于工作后多次转行成了程序猿。

很多WOWer想自己修复或者打造自己的wow单机,但是这些技术都被垄断在了一些淘宝店家手里。很多非编程人员完全摸不着头脑。所以我准备把自己未来的研究成果分享给大家。Trinitycore的C++源码我也看了下,很多技术点我没用过,所以这可能是个漫长的过程吧。

今天先立个flag,督促自己坚持下去。先翻译一下老外的一篇文章,原文在

http://www.ac-web.org/forums/showthread.php?229998-Starting-off-with-WoW-Emulation

 

魔兽世界单机版(模拟器)入门介绍

本教程的编写是希望您:我们社区的最新成员,在魔兽单机的假设上能够走正确的道路。本教程仅包含与wow模拟相关的基本知识,不适合社区中的资深成员。

译者按:老外说的这个模拟器就是咱们的单机版,我感觉大部分网游单机都是源码流出后,用官方源码架设出来的,基本与官方一致,特征一般需要虚拟机。但是魔兽是个例外,源码没有留出,是老外仿造着官方一点点写出来的模拟器,主流的开源团队有mangos和trinitycore(TC)他们的源代码都在github上,这里不对请指正。

 

在本教程中,我们将简要回顾:

1.-数据库,它们是什么以及它们的用途。

2.- DBC文件,它们是什么和它们的用途(包括客户端修改的信息)

3.-源代码,它是什么,它可以用于什么。(包括关于编译源代码的信息)

4.-编译自己的源代码和使用repack之间的区别和好处。

译者按:repack可以翻译成重打包,啥意思呢?刚才说了tc的源代码,咱们国人淘宝上卖的就是拿他们源代码修改过后,然后编译打包卖的。老外也会加上自己喜欢的东西然后重新打包,不过他们源码会公开而且不卖钱。你可以二次开发。

 

数据库。

1.     -为了解释重新打包和编译源代码之间的区别,我们必须先解释什么是数据库和dbc文件。

2.     -数据库编辑可以是在重新打包过的魔兽单机上,也可以在编译好的服务端上进行(这里我也没搞懂)。

3.-数据库是存储单元,用于存储物品、生物和任务到角色、角色成就、角色藏品、活动任务、账户等各种数据。

4.     -当你启动你的worldserver可执行文件时,它会从这些数据库表中读取和收集所有的数据,并将它们“放置”到c++容器中(我觉得这个c++容器可能指C++实例化后的对象)。

5.     -可以使用任何数据库编辑工具轻松地修改此数据。我们社区的首选工具是HeidiSQL。这个工具将允许您连接到数据库,并查看和编辑其中存储的所有信息。

6.     -例如你可以编辑物品/生物的外观、属性、名称、大小等。

7.     客户端方面,所有这些信息都存储在缓存文件夹中,所以一旦做了任何修改,你将不得不a)重新启动世界服务器,或者,如果可能的话,重新加载你刚才改的库表,使用  .reload * table_name *命令,b)重新启动游戏,删除你的缓存文件夹。(这个我没有自己实践,我没发现这个cache folder)

 

- DBC文件。

1.     - DBC文件在某种意义上类似于数据库,它们也被用作存储单元,但与数据库不同的是,这些文件存储客户端数据,而数据库保存所有服务器数据。你在游戏中看到的一切,从法术名称、视觉效果、物品显示、生物显示等等,都是使用DBC文件处理的。

2.     -和数据库一样,存储在DBC文件中的数据可以被进行修改。你可以创建自定义技能,可以更改某些东西的显示纹理(外观),插入来自其他游戏的自定义对象,将Legion(军团再临版本)数据导入到Woltk(80的巫妖王版本)等等。

3.编辑DBC文件和编辑数据库数据之间的主要区别是,为了看到游戏中实际的变化,你需要创建一个自定义.MPQ补丁包含你所有的修改DBC文件(或附加的.blp .m2 .skin或其他你添加的文件),把它放在你的客户端文件夹里。这里有一个关于如何创建自定义MPQ文件的简短教程。

 

-本示例教程将以向客户端添加自定义物品作为示例,后面一句没理解。。。

代码:

 

CREATE TABLE `patch_table` (

        `ID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',

        `ClassID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

        `SubclassID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

        `Sound_Override_Subclassid` TINYINT(3) NOT NULL DEFAULT '-1',

        `Material` TINYINT(4) NOT NULL DEFAULT '0',

        `DisplayInfoID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',

        `InventoryType` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

        `SheatheType` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

        PRIMARY KEY (`ID`),

        INDEX `items_index` (`ClassID`)

)

COMMENT='Item System'

COLLATE='utf8_general_ci'

ENGINE=MyISAM

ROW_FORMAT=FIXED;

 

建表的sql语句,程序猿还应该都熟悉,比较基础。不解释,看不懂的自学下sql和数据库基础。

 

Run this query 运行这个查询

Code:

INSERT INTO patch_table SELECT entry, class, subclass, SoundOverrideSubclass, Material, displayid, InventoryType, sheath FROM item_template

插数据到库表的操作

 

后面不翻译了。。。。这个我也没操作过不太理解

 

源代码和编译。

1.     -很可能是架设魔兽单机中“最可怕”的部分,也是让大多数成员陷入困境并放弃的部分。

2.     -虽然玩一个直接编译打包好的可能更容易,但是编译源代码会带来很多好处。

3.- trinitycore源代码是用c++编写的,c++被大多数人认为是最难掌握的语言之一。尽管语言本身很难学习,但是如果您只打算在源代码中进行少量的修改,那么你不需要完全理解它。

4.     - trinity源代码中的大多数类、方法和变量都被很好的命名了,在大多数情况下,它们的名称很好地描述了它们的用途。例如,

5.

代码:

玩家:能装备某物品(uint8 slot,uint16 &dest,道具* pItem, bool交换,bool not_loading) const

6.     是一个检查玩家是否可以穿上某装备的方法。

7.     如果你就靠常识,都能够轻松地找到并编辑您想要的函数。

8.     -一旦有了正确的文档,编译源代码是一个非常简单的过程。

9.     - trinitycore wiki页面有针对Linux和Windows的编译教程,这些教程总是保持最新。因此,我将不再在这里编写教程,而是贴出在Linux和Windows下编译教程的链接。

10.   Eluna是一个lua脚本引擎,给基于MaNGOS和TrinityCore内核用的。

该引擎允许使用Lua脚本语言编写脚本。

Lua比默认的数据库脚本系统更灵活,并且比c++更容易使用。

Lua允许快速的开发, 无需重新编译或启动就可以重新加载脚本。

1.     - Linux

2.     - Windows

3.     - Server Setup

4.     - Database Installation

5.     - Compiling Trinity on CentOS 7 by MyLilSuccy

 

-编译自己的源代码vs .使用打包好的单机

1.     -虽然玩个打包好的看起来更容易,但是编译自己的源代码会带来巨大的好处。

2.     -例如,如果你想要一个定制,或者让WoW体验更加有趣,如果没有源代码,你将只依赖数据库和dbc文件进行定制。虽然这对于某些项目来说已经足够了,但是拥有源代码始终有好处。你可以添加自定义脚本比如Rochet's Transmogrification 这个允许你改变你盔甲的外观,或者你可以添加一些源代码修改像Rochet's Item Gossip Script让你触发gossip(啥意思这里)窗口当使用一个东西而不是一个生物, 或触发一个玩家gossip窗口当某个事件发生时(一个gossip窗口弹出当玩家杀死一个生物,或类似的东西)。这可以用来制造传送石(很多单机版有的多功能炉石npc),有趣的生物杀戮系统等等。

3.-即使你是为了仿暴雪的游戏体验(仿官服端),有自己的源代码将允许你给boss定义脚本,修改寻路,编写技能脚本等,你不会只是依赖SmartAI和dbc补丁来实现这一点。

 

-有用的社区指南一览表。

1.     如何添加c++脚本到您的服务器- By JameyBoor

2.     让你的trinity服务器公开- By Jeutie

3. Stoneharry's 的技能编辑 - By StoneHarry

4.     RBAC系统- MyLilSuccy

5.     Server on a Stick (便携式服务端)-由MyLilSuccy

6.     更好的物品重加载方案  

 

后面附上英文原文:

This tutorial was written in hopes of getting you, the newest member of our community, on the right track.
This tutorial holds only the basic knowledge related to wow emulation, and is in no way intended for veteran members of the community.


In this tutorial we'll briefly go over:

  1. - Databases, what they are and what they are used for.
  2. - DBC files, what they are and what they are used for (Includes info on client sided modifications)
  3. - Source code, what it is and what it can be used for. (Includes info on compiling the source)
  4. - The differences and benefits between compiling your own source and using a repack.



- Databases.

  1. - In order to explain the difference between repacks and compiled sources, we will have to explain what databases and dbc files are first.
  2. - Database editing can be done both on repacks and compiled servers.
  3. - Databases are storage units, which are used for storing data ranging from, items, creatures and quests, to stuff like, characters, character achievements, character inventories, active quests, accounts and so on.
  4. - When you start up your worldserver executable, it reads and collects all of the data from these tables, and "places" them into C++ containers.
  5. - This data can easily be modified using any database editing tool. The preferred tool of the community is HeidiSQL. This tool will allow you to connect to your database, and view and edit all of the information stored inside of it.
  6. - For example you can edit item/creature appearances, their stats, their names, their size etc.
  7. - Client sided, all of this information is stored in the cache folder, so upon making any changes, you will have to, a) restart the world server, or, if possible, reload the table you were working in with the .reload *table_name* command, b) restart your game, and delete your cache folder.



- DBC Files.

  1. - DBC files are in a sense similar to the database, they are also used as storage units, but unlike the database, these files store client sided data, while the database holds all server data. Everything you see in game, from spell names, their visuals, item displays, creature displays etc. is handled using DBC files.
  2. - As well as the database data, the data stored in the DBC files can also be manipulated. You can create custom spells, you can change the textures of some displays, insert custom objects from other games, retro port data from Legion to Woltk, and much more.
  3. - The main difference between editing DBC files and editing Database data, is that, in order to see the actual changes ingame, you will have to create a custom .MPQ Patch containing all of your modified DBC Files (or the additional .blp, .m2, .skin or other files you added) and place it in your clients data folder. Here is a short tutorial on how to create a custom MPQ file.



- This example tutorial will be using the client sided implementation of custom items as an example, but the part of the tutorial which requires the creation of the custom patch, and placing DBC files into it, applies to almost all if not all DBC related edits.

Make a table in the database which will hold all item.dbc data

Code:

CREATE TABLE `patch_table` (

    `ID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',

    `ClassID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

    `SubclassID` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

    `Sound_Override_Subclassid` TINYINT(3) NOT NULL DEFAULT '-1',

    `Material` TINYINT(4) NOT NULL DEFAULT '0',

    `DisplayInfoID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0',

    `InventoryType` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

    `SheatheType` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',

    PRIMARY KEY (`ID`),

    INDEX `items_index` (`ClassID`)

)

COMMENT='Item System'

COLLATE='utf8_general_ci'

ENGINE=MyISAM

ROW_FORMAT=FIXED

;

Run this query

Code:

INSERT INTO patch_table SELECT entry, class, subclass, SoundOverrideSubclass, Material, displayid, InventoryType, sheath FROM item_template

 

After that use the build in option found in WDBXEditor to import all of the data from the newly created patch_table after that save the dbc changes.

(This is the fasted method I've discovered. It should take around half a minute to do everything)

Now that you have your dbc file set up, it's time to create a custom mpq patch containing the dbc file.

In order to do that you will need an MPQ editor, which you can grab here 
Ladik's MPQ Editor
Run the program and select the option to create a new mpq file. Then, create a new folder called "DBFilesClient" and place your newly created dbc file inside of it, like so:

Please ignore the other .dbc files and the two folders located inside my patch, those are not needed.

After that you can save your patch, place it in your data folder, delete your cache folder and re-run the game. Once in game you should be able to use spells with your weapons, and they should no longer appear as question marks in your inventory.

- Source code and compiling.

  1. - Quite possibly the "scariest" part of emulation, and the part at which most members get stuck at and give up.
  2. - Although it might be easier to pick up a repack, compiling the source brings a variety of benefits.
  3. - The trinitycore source is written in C++, which is by most, considered one of the hardest languages to master. Although the language itself is hard to learn, if you only plan on doing minor edits in the source, you're not expected to fully comprehend it.
  4. - Most of the Classes, methods and variables inside the trinity source are really well named, and in most cases their name perfectly describes their purpose. For example,
  5.  

Code:

  1.  
Player::CanEquipItem(uint8 slot, uint16 &dest, Item* pItem, bool swap, bool not_loading) const
  1.  
  2. is a method which checks if the player can, equip an item.
  3. If you use common knowledge, you'll be able to find and edit whichever function you want in a breeze.
  4. - Compiling the source is an extremely easy process, once you're given the right documentation.
  5. - The trinitycore wiki page has compiling tutorials for both Linux and Windows, and the tutorials are always kept up to date. So instead of writing a tutorial here, I'll post the links to the Linux and Windows requirements.
  6. Eluna - is a lua engine implementation for MaNGOS and TrinityCore based cores.
    This engine allows one to write scripts using the Lua scripting language.
    Lua is more flexible than the default database scripting systems and easier to use than C++.
    Lua allows for fast paced development - scripts can be reloaded without recompiling or restarting.

 

  1. Linux
  2. Windows
  3. Server Setup
  4. Database Installation
  5. Compiling Trinity on CentOS 7 by MyLilSuccy



- Compiling your own source vs Using a Repack.

  1. - While it may seem easier to pick up a repack, compiling your own source brings a vast amount of benefits.
  2. - For example, if you're going for a custom/fun WoW experience, without the source, you'll only rely on the database and the dbc files for customization. While that may be enough for some project, having the source on the side is always a benefit. You can add custom scripts like Rochet's Transmogrification which allows you to change the appearance of your armor, or you can add some source modifications like Rochet's Item Gossip Script which allows you to trigger gossip windows using an item instead of a creature, or trigger a player gossip window when a certain event occurs (a gossip window popup when the player kills a creature, or something similar). This can be used for creating Teleportation Stones, fun creature killstreak systems and a lot more.
  3. - Even if you're going for a blizzlike experience, having your own source will allow you to script bosses, modify pathfinding, write spell scripts etc. you wont be just relying on SmartAI and dbc fixes to achieve this.



- List of useful community guides.

  1. How to add C++ scripts to your server - By JameyBoor
  2. Making your trinity server public - By Jeutie
  3. Stoneharry's spell editor - By StoneHarry
  4. RBAC System - By MyLilSuccy
  5. Server on a Stick (Portable Server) - By MyLilSuccy
  6. Better Item Reloading
<think>嗯,用户遇到了一个编译错误,nvcc fatal error说'nvptx'这个值没有被定义为gpu-architecture的选项。我需要先弄清楚nvcc支持的GPU架构有哪些。 首先,我记得CUDA的nvcc编译器在指定架构时需要用特定的标识符,比如sm_xx或者compute_xx。比如sm_61对应Pascal架构,compute_75对应Turing。而用户这里用的是nvptx,这可能是一个错误的架构名称。可能用户混淆了不同编译工具链的架构指定方式,比如nvptx可能是GCC或LLVM中的某种目标架构,但在CUDA中并不适用。 接下来,我需要检查用户提供的引用。引用[1]提到sm_20的问题,解决方法可能是更新CUDA版本或者修改架构参数。引用[2]和[3]都涉及到compute_30和sm_30不被支持,建议移除旧版CUDA工具包或者调整架构参数。这可能说明用户的环境中有旧的CUDA组件,或者指定的架构太老或不被支持。 用户的问题中的错误信息是Value 'nvptx' not defined,这说明用户在编译时可能错误地指定了架构参数。比如,可能是在CMakeLists.txt或者构建脚本中错误地将架构写成了nvptx,而正确的应该是sm_xx或compute_xx。例如,nvptx是用于OpenCL或者其他编译器的目标架构,而CUDA的nvcc不支持这个参数。 解决方案方面,首先应该确认用户指定的架构参数是否正确。需要替换nvptx为有效的架构,如sm_75。其次,检查CUDA版本是否支持该架构,比如较新的CUDA版本可能不支持旧的架构。然后,查看构建脚本或CMake配置,确保没有错误地设置架构参数。此外,可能还需要清理旧的构建文件,确保没有缓存导致的问题。 另外,用户可能参考了某些文档或教程,错误地使用了架构参数。需要提醒用户查阅NVIDIA官方文档,确认正确的架构标识符。同时,检查是否有多个CUDA版本冲突,可能需要卸载旧版本,确保环境变量指向正确的CUDA安装路径。 最后,生成相关问题需要考虑用户可能遇到的类似问题,比如如何查看支持的架构、不同CUDA版本的支持情况、构建系统中的配置方法等,帮助用户扩展理解和解决其他潜在问题。</think>### 解决方案:`nvcc fatal error: Value 'nvptx'未定义`的修复步骤 该错误通常由**GPU架构名称错误**或**CUDA版本与架构不兼容**导致。以下是分步解决方案: --- #### 1. **确认正确的GPU架构名称** CUDA架构需使用`sm_XX`(硬件架构)或`compute_XX`(虚拟架构)格式,例如: - `sm_75`(Turing架构,如RTX 20系列) - `compute_86`(Ampere架构,如RTX 30系列) **错误示例**:`nvptx`是LLVM/NVPTX后端使用的架构名称,不适用于CUDA编译[^3]。 --- #### 2. **检查CUDA版本与架构的兼容性** 不同CUDA版本支持的架构范围不同: - **CUDA 11.x+**:默认不再支持`sm_30`及以下架构[^2][^3] - **CUDA 10.x**:支持`sm_30`到`sm_75` 通过以下命令查看当前CUDA支持的架构: ```bash nvcc --list-gpu-arch ``` --- #### 3. **修改编译参数** 在编译命令或构建脚本(如CMake)中替换错误参数: ```cmake # 错误示例:-arch=nvptx # 正确示例(根据GPU型号选择): set(CUDA_NVCC_FLAGS "-arch=sm_75") ``` --- #### 4. **清理旧版本CUDA工具包冲突** 若系统中存在通过`apt-get`安装的旧版CUDA工具包,可能导致路径冲突: ```bash apt-cache policy nvidia-cuda-toolkit # 检查是否安装旧版本 sudo apt remove nvidia-cuda-toolkit # 移除旧版本 rm -rf build/ # 清理构建缓存 ``` --- #### 5. **验证GPU架构支持** 通过`nvidia-smi`查询GPU型号,再对照[NVIDIA官方文档](https://developer.nvidia.com/cuda-gpus)确认对应架构名称。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值