Don’t Starve Together Source Code Issue Report
Dear Klei Development Team,
Hello! I am a passionate DST player who has discovered some potential issues while reading through the game’s source code. I hope these findings can be brought to your attention and possibly fixed in future updates. Below are the specific issues I’ve identified:
1. json.lua
Issue: In the decode_scanArray function, the object variable should be declared as a local variable.
Current Code:
object, startPos = decode(s,startPos)
Suggested Change:
local object, startPos = decode(s,startPos)
Impact: The current implementation may pollute the global namespace, potentially causing variable conflicts.
2. scheduler.lua
Issue 1: In the Run method, task:SetList(nil) should be changed to v:SetList(nil).
Issue 2: In Scheduler:Run(), the if not success then block should not directly return as it interrupts the loop.
Issue 3: There is code redundancy between v:SetList(nil) and self:KillTask(v).
Impact: These issues may cause task scheduling anomalies, particularly unexpected interruptions when handling multiple tasks.
3. modutil.lua
Issue: The debug output in the env.GetShardModRPC function is incorrect.
Current Code:
initprint("GetModRPC")
Suggested Change:
initprint("GetShardModRPC")
Impact: Inaccurate debug information may confuse developers when troubleshooting issues.
4. recipe.lua
Issue: The RecipePostInit callback function has incomplete parameters.
Current Code:
for k,recipepostinit in pairs(ModManager:GetPostInitFns("RecipePostInit")) do
Suggested Change:
for k,recipepostinit in pairs(ModManager:GetPostInitFns("RecipePostInit",self.name)) do
Impact: The current implementation may prevent recipe modifications from being correctly applied during mod initialization.
5. widgets/spinner.lua
Issue: The code uses the TextEdit module which has not been imported.
Current Code:
self.text = self:AddChild(TextEdit(self.textinfo.font, self.textinfo.size))
Impact: This may cause related UI components to malfunction.
6. networkclientrpc.lua
Issue: The SendModRPCToShard functionality does not work as expected.
Details: According to the code and comments, the shards parameter can be nil, a shardid, or a table. However, player clients also receive this RPC, resulting in error messages in player logs similar to:
[02:03:01]: Invalid RPC namespace: multiworldpicker 1
[02:03:26]: Invalid RPC namespace: multiworldpicker 1
Impact: This may cause RPC communication issues in multi-world mode, affecting game functionality and stability.
Thank you for taking the time to read my feedback. I greatly enjoy playing Don’t Starve Together and hope to contribute to its improvement. Please feel free to contact me if you have any questions.
Best regards,
[BaiQi43]
[Email: baiqi43@qq.com]
Don’t Starve Together 源码问题反馈
尊敬的Klei开发团队:
您好!我是一位热爱DST的玩家,在阅读游戏源码的过程中发现了一些潜在的问题,希望能够引起您的注意并在未来的版本中得到修复。以下是我发现的具体问题:
1. json.lua
问题:在decode_scanArray函数中,object变量应该声明为局部变量。
当前代码:
object, startPos = decode(s,startPos)
建议修改为:
local object, startPos = decode(s,startPos)
影响:当前实现可能会污染全局命名空间,导致潜在的变量冲突。
2. scheduler.lua
问题1:Run方法中task:SetList(nil)应改为v:SetList(nil)。
问题2:Scheduler:Run()中的if not success then语句块不应该直接return,这会中断循环。
问题3:v:SetList(nil)与self:KillTask(v)存在代码冗余。
影响:这些问题可能导致任务调度异常,特别是在处理多个任务时可能会出现意外中断。
3. modutil.lua
问题:env.GetShardModRPC函数中的调试输出有误。
当前代码:
initprint("GetModRPC")
建议修改为:
initprint("GetShardModRPC")
影响:调试信息不准确,可能导致开发者在排查问题时产生混淆。
4. recipe.lua
问题:RecipePostInit回调函数的参数不完整。
当前代码:
for k,recipepostinit in pairs(ModManager:GetPostInitFns("RecipePostInit")) do
建议修改为:
for k,recipepostinit in pairs(ModManager:GetPostInitFns("RecipePostInit",self.name)) do
影响:当前实现可能导致模组初始化时无法正确应用配方修改。
5. widgets/spinner.lua
问题:使用了未引入的TextEdit模块。
当前代码:
self.text = self:AddChild(TextEdit(self.textinfo.font, self.textinfo.size))
影响:可能导致相关UI组件无法正常工作。
6. networkclientrpc.lua
问题:SendModRPCToShard功能工作不符合预期。
详细说明:根据代码和注释,shards参数可以是nil或shardid或table,但是玩家客户端也会收到这个RPC,导致玩家日志中出现类似以下的报错信息:
[02:03:01]: Invalid RPC namespace: multiworldpicker 1
[02:03:26]: Invalid RPC namespace: multiworldpicker 1
影响:这可能导致多世界模式下的RPC通信出现问题,影响游戏功能和稳定性。
感谢您抽出宝贵时间阅读我的反馈。我非常喜爱《Don’t Starve Together》这款游戏,希望能为游戏的改进贡献一份力量。如有任何疑问,请随时与我联系。
祝开发顺利!
[BaiQi43]
[邮箱:baiqi43@qq.com]
Please check and verify the source code
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now