简体   繁体   中英

Improve load data with C++ into Unreal Engine

I'm developing a game with C++ and Unreal Engine.

Every time I start the game I have to read data from a text file. This text file has, at this moment, 117,955 lines divided into 24 registers. The first character on each line is an index to identify them.

I will to load 12 or 13 registers, so I need to find them first. All the registers will be consecutive: from 0 to 12, or from 5 to 17.

I don't know if this is the best method to load data into a program. Now, I open the file, read it line by line until I found the first register.

I've thought that I can split the file into 24 text files, one for each register. But maybe it could be slower to open and close 13 files.

Another option is to use a small database engine like mySQL or maybe mongoDB.

You are more experienced programmers because I've just started to learn C++ and I always have programmed with C# and using SQL Server.

What do you recommend me?

I don't beleive mysql or mongo is a right choice (background server process is an overkill for a game), I suggest you to look at sqlite.

If you're relatively good with databases, using a database could hugely improve your development speed (instead of thinking about your custom file format you just use old sql)

Another point is your data will be well organized, you'll have statistics on your side, with a few simple scripts you can create distributed environment/web interface for your game designers to add content/items/scripts to your game

As for the design: encapsulate database access anyway. It will help you later. Ie if you'll find that even sqlite is too slow for you, can burn-in your data to binary files

SQLite is good solution. You can use this plugin SQLiteUE4 to interact with DB or at least to look at C++ code. Here link to guide .

MongoDB will be problematic because of c++ API hasn`t stable version and require a lot of depencies.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM