Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GridNav doesnt work properly #20

Open
SirWayN3 opened this issue Feb 14, 2019 · 3 comments
Open

GridNav doesnt work properly #20

SirWayN3 opened this issue Feb 14, 2019 · 3 comments

Comments

@SirWayN3
Copy link

The GridNav in LUA does work correct, giving me the correct amount of squares, with buildable areas ect.
But when sending this to JS via GNV, this doesnt work at all.

[BH] Max World Bounds:
[BH] -16352 16352 -16352 16352
[BH] -256 255 -256 255
[BH] Free: 65243 Blocked: 196901
Compiled Building Helper!
[BH] Sending GNV to player 0
Registering GNV [512,512] Min Bounds: X=-256, Y=-256
Free: 16315 Blocked: 81792

the Sum of Squares in LUA is 512*512. But in JS, this does not work. Still searching for the issue, this isnt working.

@SirWayN3
Copy link
Author

i found the problem. the GNV_message length differs:

LUA: 87552 (x3 EQ 262.656 Grid Blocks)
JS: 32766 (Max Size of Datatype INTEGER)

I think the LUA Function Send_ServerToPlayer is limited here. Trying to Split the String into Multiple Events now...

@SirWayN3
Copy link
Author

SirWayN3 commented Feb 25, 2019

Works for me, cant find the Function for JS access to the string with for loop.
building_helper.js:

function RegisterGNV(msg){
    var GridNav = [];
    var squareX = msg.squareX
    var squareY = msg.squareY
    var boundX = msg.boundX
    var boundY = msg.boundY
    // Edit by SirWayNe 25.02.2019 - Function does not allow Arrays to be passed or string length > 32766
    msg.gnv = msg.gnv_split1.concat(msg.gnv_split2,msg.gnv_split3)
    $.Msg("Registering GNV ["+squareX+","+squareY+"] ","Min Bounds: X="+boundX+", Y="+boundY,' Split Count:',msg.splitCount,' Length:',msg.gnv.length)
	// end Edit by SirWayNe

buildinghelper.lua:

function BuildingHelper:SendGNV(args)
    local playerID = args.PlayerID
    if playerID then
        local player = PlayerResource:GetPlayer(playerID)
        if player then
            BuildingHelper:print("Sending GNV to player "..playerID)
            -- Edited by SirWayNe 25.02.2018 - String cant he longer then 32667 due to Function from Valve SendToPlayer
            local t = {}
            for k,v in pairs(BuildingHelper.Encoded_Split) do
                -- print(k)
                t["gnv_split"..k] = BuildingHelper.Encoded_Split[k]
                t.splitCount = k
            end
            t.squareX = BuildingHelper.squareX
            t.squareY = BuildingHelper.squareY
            t.boundX = BuildingHelper.minBoundX
            t.boundY = BuildingHelper.minBoundY
            CustomGameEventManager:Send_ServerToPlayer(player, "gnv_register", t )
            
            -- CustomGameEventManager:Send_ServerToPlayer(player, "gnv_register", {gnv=BuildingHelper.Encoded, squareX = BuildingHelper.squareX, squareY = BuildingHelper.squareY, boundX = BuildingHelper.minBoundX, boundY = BuildingHelper.minBoundY })
            -- end Edit by SirWayNe
        end
    end
end

@MNoya
Copy link
Owner

MNoya commented Mar 1, 2019

Hey @SirWayN3 thanks for the report and proposing a solution.
I updated the format of your last message (use triple ` to make code blocks)

I will try looking into this during this weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants