Logs ending with "2" and class property resetting automagically

Game development with Board Game Arena Studio
Post Reply
0BuRner
Posts: 12
Joined: 13 April 2020, 17:00

Logs ending with "2" and class property resetting automagically

Post by 0BuRner »

Hello,

I'm wondering why all my logs are suffixed with "2".
24/04 16:33:35 [debug] [T84988] [2318710/BuRner1] Top card: 8 ♣2
24/04 16:33:35 [debug] [T84988] [2318710/BuRner1] true2
24/04 16:33:35 [debug] [T84988] [2318710/BuRner1] Challenge try: 02
24/04 16:33:35 [debug] [T84988] [2318710/BuRner1] Challenge MAX try: 02
24/04 16:33:35 [debug] [T84988] [2318710/BuRner1] type_arg: 82
I'm having some really really weird issues (my class variable are somehow reset... - not in my code, I debug everything for so long). I suspect there is something wrong running simultaneously.

In constructor:

Code: Select all

$this->challengeMaxTry = 0;
In method:

Code: Select all

$this->challengeMaxTry = 1;
(NO OTHER CODE RELATED TO THIS PROPERTY)
I set debug in this method before and after setting the variable value to 1, it's ok at first call, at second call my variable went back to value 0...

Help, I'm going crazy :(
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Logs ending with "2" and class property resetting automagically

Post by RicardoRix »

If you need variables to persist then you need to store them in the DB.
We should have probably have figured this out from your 1st thread. :oops:

put a var_dump('here1'); in the constructor. (not 100% sure this works) - you'll see then how often it gets triggered.

Server programming is not like a normal program. Your class does not persist in memory.
On a page refresh, F5, the server runs - your class is created - delivers it's page content and then disappears.

There is another trick if you need a variable to persist, (ASP.NET terminology) you can use the 'page state' where this is passed to the client and then back again in a post back, but AFAIK this is beyond the scope of what you need for BGA programming, just use the DB.
Post Reply

Return to “Developers”