Jump to content

how to catch gone items (cooked)? prevent RPC invalid data issue


Recommended Posts

Hi,

I noticed that in my Home Base Mod, where I use RPC to send an inst to client to further check this inst, I still get from time to time RPC errors, so I printet the inst, this is the result:

1) When starting the game I get:
[00:02:26]: 107588 - pond_mos    
[00:02:26]: Error decoding lua RPC sender

2) When cooking some meat or harvesting from farm (or plant at farm) I get:

[00:10:37]: 127235 - smallmeat    
[00:10:37]: Invalid RPC data type
[00:12:59]: 109354 - twigs    
[00:12:59]: Invalid RPC data type
[00:13:56]: 131834 - monstermeat    
[00:13:56]: Invalid RPC data type
[00:16:22]: 106476 - plant_normal    
[00:16:22]: Invalid RPC data type
[00:18:54]: 106451 - fast_farmplot    
[00:18:54]: Invalid RPC data type

So my questions:
1) is pond_mos pond moss? I guess this is not a structure like a tree or something? So I think because it is special, it triggers an error in the following functions. But instead showing the issue, the log only shows this decode error message in RPC...
So what is the special thing about this pond_mos? How can I prevent the error or just don't make RPC, when inst is something like pond_mos (don't want to add sth that only deals with pond_mos, cause there could be other simular things?)

2) In the GetIsWet function from entityscript for items is normally "self.replica.inventoryitem" used. For items no RPC is needed, so in my modded version I just return the original GetIsWet, "if self.replica.inventoryitem~=nil". But obviously for the items above this is nil, so at the moment they are sent via RPC which results in this error message.
How to catch those "just destroyed" items? I think it is not "InLimbo", although I thought this is what InLimbo means. Cause all items in inventory are also InLimbo.

Edited by Serpens
Link to comment
Share on other sites

On 9/8/2016 at 8:46 PM, Serpens said:

1) is pond_mos pond moss?

It's the pond prefab in the marsh biome.

Not sure what's happening, since we don't have access to how the game encodes entities.

TheNet:SendModRPCToServer(id_table.namespace, id_table.id, ...)

TheNet:SendRPCToServer(code, ...)

The ... are the extra stuff we send to the handler.

On 9/8/2016 at 8:46 PM, Serpens said:

How to catch those "just destroyed" items?

Do the check

if inst and inst:IsValid() then

before sending the RPC and you are good to go.

Link to comment
Share on other sites

Thanks, the IsValid() check works :)

About the pond_mos:
 

AddModRPCHandler(GLOBAL.KnownModIndex:GetModActualName("Home Base Bonus"), "HomeBaseMod_handler", function(player, inst)
    print("RCP Handler")
    if player and inst~=nil then
        UpdateNewWetTag(inst)
	end
end)

local function EntityScriptPostConstruct(self) 
    local _GetIsWet = self.GetIsWet 
    self.GetIsWet = function(inst,...) 
        print("_____")
        print(inst)
        if mytype(inst) == "table" and inst:IsValid() then
            local RPC = GetModRPC(GLOBAL.KnownModIndex:GetModActualName("Home Base Bonus"), "HomeBaseMod_handler") 
            SendModRPCToServer(RPC, inst)
        end
        print("after send rpc")
        return inst:HasTag("IsNewWet")
    end
end
AddGlobalClassPostConstruct("entityscript","EntityScript", EntityScriptPostConstruct)

this code results in this output:
 

Quote

[00:00:24]: _____    
[00:00:24]: 102014 - pond_mos   
[00:00:24]: Error decoding lua RPC sender
[00:00:24]: after send rpc
[00:00:24]: _____    
[00:00:24]: 102018 - pond_mos   
[00:00:24]: Error decoding lua RPC sender
[00:00:24]: after send rpc 

So the AddModRPCHandler is not even called for pond_mos.
I have no idea how to prevent this, except checking, if prefab is pond_mos...

But this error only happens at game start. If the game is running, also pond_mos does work without an issue.
So is there a check I can make to see, if the game is already running?

Link to comment
Share on other sites

4 hours ago, Serpens said:

So is there a check I can make to see, if the game is already running?

Well the game starts running from the start, but I get what you mean.

if not GLOBAL.POPULATING and inst and inst:IsValid() then

Try this check.

 

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
 Share

×
  • Create New...