[英]Saving and Loading Data C++
I know of a crude way of saving program data, keeping it in a text file. 我知道保存程序数据的粗略方法,将其保存在文本文件中。 The problem is that anyone has access to the text file and can manipulate it.
问题是任何人都可以访问文本文件并可以操作它。 For example I want to save and load game data which changes as the game progresses.
例如,我想保存并加载随游戏进行而变化的游戏数据。 What methods are there to store such data and keep it accessible only within the game program so it isn't manipulated by others?
有哪些方法可以存储这些数据,并且只能在游戏程序中访问它,以免被其他人操纵?
The idea is to format your data in such a way so that it is not readable by humans. 我们的想法是以这样的方式格式化您的数据,使其不被人类阅读。 This can by done using a number of methods.
这可以使用许多方法完成。
You should store your data in binary files. 您应该将数据存储在二进制文件中。 But people still can change it anyway (like I often change skill point or stat point of my character in Diablo2 :D) so you should consider find a algorithm to calculate hash sum and store it within your data.
但人们仍然可以改变它(就像我经常在Diablo2:D中更改我的角色的技能点或统计点)所以你应该考虑找到一个算法来计算哈希值并将其存储在你的数据中。
You could save the data in a binary file. 您可以将数据保存在二进制文件中。 Just write and read the bits from and to the c++ object.
只需从c ++对象写入和读取位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.