How to make sure I have the latest production version of the code?

Game development with Board Game Arena Studio
Post Reply
Jeromie
Posts: 24
Joined: 04 April 2020, 21:13

How to make sure I have the latest production version of the code?

Post by Jeromie »

Hello,

I've been trying to take over maintenance of a game to fix a few bugs but I've quickly realized that I wasn't able to make a build with the code I initially retrieved because of 2 errors:

1. "Forbidden access to g_user detected."
2. A space in a filename that couldn't be added to svn

I've temporarily made these go away to see if there were more problems, but this scares me: could it mean that the version I have is not the one in production?
I'm still learning how to use BGA Studio and I don't want to break the game by releasing some unfinished changes by the previous devs that I'm not aware of.
From the "commit log", I think the original dev stopped working on it in 2021. Then I'm seeing one PHP8 commit in 2023 then a few technical ones in October 2024.

I have not succeeded to make sense of the "Source code version control" UI, I'm familiar with git and I've used svn in the past but that thing doesn't do what I expect at all.
I've asked support (ticket #7049056) but I think they tried a build with my temporary fixes, which succeeded. They seem to have moved on, it's been over a week since the last exchange.
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: How to make sure I have the latest production version of the code?

Post by thoun »

The g_user test on commit is fairly new, the last version in production can still have it if it was deployed before.
The svn issues happens, you'll need to trust us on the fact that it is the production version.
Jeromie
Posts: 24
Joined: 04 April 2020, 21:13

Re: How to make sure I have the latest production version of the code?

Post by Jeromie »

Alright thanks.

What would be the replacement for g_user in the following code?

Code: Select all

    function argProductionPlayerTurn()
    {
        //multiplayer
        //get possible moves and send them
	 global $g_user;
        if ($g_user->is_logged()) {
            return array("gamedatas" => self::getAllDatas(self::getCurrentPlayerId(), false, true, false));
        } else {
            return array();
        }
    }  
I didn't find anything similar and I'm not sure the check is useful, I've a few combination of going offline and turned-based and it didn't seem to break anything. But this goes way beyond my current understanding of the framework and I'm trying to be careful, maybe too much.
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: How to make sure I have the latest production version of the code?

Post by thoun »

Oh that looks like very old code. I'm not very sure is_logged return true for spectators or not, but I would try something like this :

Code: Select all

   function argProductionPlayerTurn()
    {
        //multiplayer
        //get possible moves and send them
	$currentUserId = (int)$this->getCurrentPlayerId();
        if ($currentUserId > 0) {
            return array("gamedatas" => self::getAllDatas($currentUserId, false, true, false));
        } else {
            return array();
        }
    }  
Jeromie
Posts: 24
Joined: 04 April 2020, 21:13

Re: How to make sure I have the latest production version of the code?

Post by Jeromie »

Right! Spectators is why that matters, I didn't test that and now that I did, I see that the existing code crashes for spectators in production as well.

Your suggestion build but wasn't enough to fix the issue, but this seems to work better

Code: Select all

    function argProductionPlayerTurn()
    {
        if ($this->isSpectator()) {
            return array();
        } else {
            return array("gamedatas" => self::getAllDatas(self::getCurrentPlayerId(), false, true, false));
        }
    }
Thank you
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: How to make sure I have the latest production version of the code?

Post by thoun »

Yah, I wasn't sure at all the existing code was working for spectators! Thanks for confirming my intuition, and for fixing it :)
Post Reply

Return to “Developers”