Jump to content

SendModRPCToShard Function Behavior


BaiQi43
  • Pending

Dear Klei Entertainment Team,

I hope this message finds you well. I am writing to report a bug in the game Don't Starve Together related to the SendModRPCToShard function.

Bug Description: When the parameter shards (world ID list) is set to nil, the function SendModRPCToShard sends the RPC to all connected clients, which is not in line with the game's intended behavior.

Here is the relevant section of the official source code and its comments:

==============================================================

-- SendRPCToShard(SHARD_RPC.RPCNAME, shards, ...)
-- shards is either:
-- nil == all connected shards
-- shardid == send to that shard
-- table == list of shards to send to
function SendRPCToShard(code, ...)
.....................
end

==============================================================

As per the code comments, when shards is nil, the function should send the RPC to all connected shards. This intended functionality is correctly implemented. However, the issue arises because the function also sends the RPC to all connected clients, which is an unnecessary and unintended behavior.

Steps to Reproduce:

  1. Call SendModRPCToShard with the shards parameter set to nil.
  2. Observe that the RPC is sent to all connected clients in addition to all connected shards.

Expected Behavior: The RPC should only be sent to all connected shards when the shards parameter is nil, as described in the code comments. It should not send the RPC to all connected clients.

I hope this information helps in identifying and fixing the issue. Thank you for your continuous support and efforts in improving the game.


Steps to Reproduce

主题:Bug报告:SendModRPCToShard函数行为

尊敬的Klei娱乐团队,

希望您一切安好。我写这封信是为了报告游戏《饥荒联机版》中与SendModRPCToShard函数相关的一个Bug。

Bug描述: 当参数shards(世界ID表)为nil时,函数SendModRPCToShard会将RPC发送给所有连接的客户端玩家,这不符合游戏设定。

以下是官方源码中相关代码和注释:

==============================================================

-- SendRPCToShard(SHARD_RPC.RPCNAME, shards, ...)
-- shards is either:
-- nil == all connected shards
-- shardid == send to that shard
-- table == list of shards to send to
function SendRPCToShard(code, ...)
.....................
end

==============================================================

根据代码注释,当shardsnil时,函数应将RPC发送到所有连接的碎片(shards)。这一预期功能本身实现了,但是问题在于函数还将RPC发送给了所有连接的客户端玩家,这是多余且非预期的行为。

重现步骤:

  1. 调用SendModRPCToShard并将shards参数设置为nil
  2. 观察到RPC被发送到所有连接的客户端玩家以及所有连接的碎片。

预期行为:shards参数为nil时,RPC应仅发送到所有连接的碎片,如代码注释所描述的那样,不应发送给所有连接的客户端玩家。

希望这些信息有助于识别和修复问题。感谢您不断地支持和努力改进游戏。

 




User Feedback


client_log_2024-05-12-12-14-05
[00:56:52]: Invalid RPC namespace:     multiworldpicker    1    
[00:57:54]: Invalid RPC namespace:     multiworldpicker    1    
[00:58:08]: Invalid RPC namespace:     multiworldpicker    1    
[00:59:06]: Invalid RPC namespace:     multiworldpicker    1    

 code:
 

function HandleShardModRPC(sender, tick, namespace, code, data)
    if SHARD_MOD_RPC_HANDLERS[namespace] ~= nil then
        local fn = SHARD_MOD_RPC_HANDLERS[namespace]
	

	
        if fn ~= nil then
            table.insert(RPC_Shard_Queue, { fn, sender, data, tick })
        else
            print("Invalid RPC code: ", namespace, code)
        end
    else
        print("Invalid RPC namespace: ", namespace, code)
    end
end

Share this comment


Link to comment
Share on other sites



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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...