Game Development Community

Synchronising the time between server and clients and daytimer

by David McDonald · in Torque 3D Professional · 06/22/2010 (10:31 pm) · 21 replies

Hi all,
Currently I have a level where I have placed a daytimer object in the world editor.
This works like a charm however when a second client joins it gets the day timer starting at the initial setting rather than the current time in the world.

e.g. I log into the level and xx time passes so the sun has set and it's night time.
Second player logs into the world to duel with me yet he sees the initial time (whatever is set as the start time in the daytimer object).

I have fiddled with the ClientCmdSyncClock but this doesn't appear to achieve anything.

Any pointers on where I should focus my attention?
Page «Previous 1 2
#1
06/23/2010 (5:18 am)
When the client connects, send a commandToClient() to it with the current server daytimer time, and have the client change the time when this command arrives.
#2
06/23/2010 (6:43 am)
Thanks Manoel. Do you know how to extract the current daytimer information from the daytimer object placed in the mission.
#3
06/29/2010 (6:22 am)
Ok while working a myriad of other things I finally had time to revisit the time issue (Pardon the pun).
When a client logs into the dedicated server it pulls the current time down, no problem.
However the issue seems to be that the ToD object is not updating on the dedicated server.

Datablock is as follows:
new TimeOfDay(Daytimer) {
      axisTilt = "23.44";
      dayLength = "28800";
      startTime = "0.01";
      time = "0.01";
      play = "1";
      azimuthOverride = "1";
      dayScale = "0.92";
      nightScale = "1.09";
      position = "-26.016 2060.21 169.742";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      canSave = "1";
      canSaveDynamicFields = "1";
   };

Any ideas why the ToD on a dedicated server remains at whatever time is set (Start time or when I set with Daytimer.time=0.xxxx)?
#4
07/04/2010 (5:32 am)
@David: This is already fixed in Beta 2. The root of the problem was that the TimeOfDay object was using advanceTime (which is client side only) instead of processTick. Modify your source to read something like this (remove the entire advanceTime declaration):

void TimeOfDay::processTick( const Move *move )
{
   if ( !mPlay )
   {
      _updatePosition();
      return;
   }

   F32 dt = TickSec;
   
   F32 elevation = mRadToDeg( mNextElevation );
   
   if ( elevation > 350.0f || ( 0.0f <= elevation && elevation < 190.0f ) )
      dt *= mDayScale;
   else
      dt *= mNightScale;

   if ( mAnimateTime != -1.0f )
   {
      F32 target = mAnimateTime;
      F32 cur = mRadToDeg( mNextElevation );
      
      if ( target < cur )
         target += 360.0f;

      F32 dif = target - cur;

      F32 scale = mAnimateSpeed * mClampF( mPow( dif / 15.0f, 2 ), 0.1f, 1.0f );

      dt *= scale;
   }

   //Con::printf( "elevation ( %f ), ( %s )", elevation, ( daytime ) ? "day" : "night" );

   // do time updates   
   mTimeOfDay += dt / mDayLen;

   // It could be possible for more than a full day to 
   // pass in a single advance time, so I put this inside a loop
   // but timeEvents will not actually be called for the
   // skipped day.
   while ( mTimeOfDay > 1.0f )
      mTimeOfDay -= 1.0f;

   _updatePosition();

   _updateTimeEvents();
}

And of course modify the header file accordingly:

public:
   virtual void processTick( const Move *move );
#5
07/04/2010 (3:32 pm)
Many thanks,
I'll get my code-jockey onto it straight away.

Regards.
#6
07/07/2010 (10:10 am)
mAnimateTime and mAnimateSpeed undeclared indentifier ?
#7
07/07/2010 (11:39 am)
Alfio: How would you know? You don't have source, do you?
#8
07/07/2010 (12:27 pm)
Konrad:
I do not have the sources directly, but through a friend. At the moment I bought the license for the binary version, it is not yet necessary sources. I'm using the T3D for a commercial project, so it's clear my intention to buy within a few months, the license for the sources. The idea was to evaluate the product before purchasing it permanently.

The source borrowed, allowing me to deepen the knowledge of engine, and in some cases, help the community to report bugs, or simple answers to questions which i know the answer.
#9
07/07/2010 (12:41 pm)
If I borrowed your car for a month without your consent, would you consider that theft? Would it matter that I wanted to buy the same brand, and I was just gonna take it to see if it fit my expectations?
#10
07/07/2010 (1:08 pm)
Offtopic, but I sense a mangling/disregard of the EULA ;)
#11
07/07/2010 (1:17 pm)
Konrad:
You made me a specific question and i answered honestly.
I could be of agree with you, and not even like me. But seeing as i have the complete sources, it would be foolish not to use them. Actually, i haven't intentions use for profit, and i said soon, that i must buy the license for the source.

For the car: if i do not have to walk, could not be a problem. Of course, joke :-P
#12
07/07/2010 (1:33 pm)
The issue here is we all pay for source to help the Torque team fund development and you've stolen the source. Here some torque associates who are some of the best torque people around have looked at this and even put up a solution, and your getting that free too.

Torques business model is not like UDK where you pay once your successful, even though thats how you are using it and instead of just stealing the engine and working through it you've paid for a binary license so you can use this forum for support.
#13
07/07/2010 (2:15 pm)
Quote:Alfio: How would you know? You don't have source, do you?


Seems to be a growing problem. This is not the first time i see a BINARY licensee using T3D PRO, just last week it was a TGEA licensee thinking they had right to bark at the forums about T3D without even being a fellow T3D Licensee.

Often I see Torque EULA transgressors respond with hostility once they are called out on it; this is a sign that they know deep down inside, a game developer who will cheat and steal is never very well respected, no matter how skilled they may be.

EDIT: for creative use of the comma.
#14
07/07/2010 (6:33 pm)
Certainly, use of unlicensed software is not the best thing to do. I don't like to see one of my software turn freely on the net. But I have become aware of the potential of T3D, with the sources provided to me by a friend. And from there i decided to buy the license of the original binary version for more details.
Anyway, we must also see the use made of it. Introduce a software developed with products not licensed, is criminally insane.

From previous projects i have also the source of various 3D engines with big names. But i know for sure that the budget of this project is not the same as before. So between Unity and C4 (i'm licensed) and others, i chose the T3D. If is a problem the fact that i possess so maybe incorrect sources, means that it i must work without.

Also, looking on google, it seems that is not really difficult to get a copy of the source.
#15
07/08/2010 (12:33 am)
Since I kicked off this thread I might join in on the derailment.

Quote:Certainly, use of unlicensed software is not the best thing to do
Actually more than that, it is flat out illegal.

I agree entirely with Caylo here. Binary licensed customers who then grab the source from a friend, or off the net etc. are getting full development tools with community support.
Basically, you get everything I paid $1000 for at the cost of a binary licence.

If you wanted to evaluate the full version I thought there was a demo version you could get (Having bought the licence I never followed that route).

Quote:From previous projects i have also the source of various 3D engines with big names.

err....not sure you should have opened up that can of worms....So you are saying you have the source for other 3D engines without licencing them?



#16
07/08/2010 (9:13 pm)
Hoping to get this back on track,
@Konrad, the question is still valid about mAnimateTime and mAnimateSpeed. I stuck them in and declared them as F32 mAnimateTime; and F32 mAnimateSpeed; and I'm getting odd results:

[edit: - The odd results]

On starting the dedicated server I get any one of the following (Seemingly random) (Note my Timofday object is called Daytimer....clever eh? :-))

- echo(Daytimer.time); shows 0 all the time. No updating
- The same command shows small updates (Almost real time as opposed to the 3:1 daylength I have set)
- It screams through the 0-1 range in a fraction of a second
- I get -1.#QNAN

#17
07/12/2010 (3:39 pm)
OK,
We seemed to have solved it. mAnimateTime and mAnimateSpeed were declared as above however my odd results were from my own silliness. Both client and dedicated server needed to be the same build...go figure ;-)
#18
07/29/2010 (2:27 pm)
Hi guys, amusing thread thus far... Are any of you using AFX also? I'm getting a weird issue. I'm just running on one machine at the moment. I too, am getting the effect of during load in the, output monitor, that my Sunrise/Sunset (from post: http://www.torquepowered.com/community/forums/viewthread/107155 ) alternating every second, then when the client connects(same machine) I get a full load until "*** Phase 2: Download Ghost Objects: Mapping string: MissionStartPhase2Ack to index: 1" when all the objects load, and it flipps Sunrise/Sunset again 12 times and quits responding.

Can anyone shed some light on this?
#19
07/29/2010 (2:46 pm)
Too add to this, I removed the script from post: http://www.torquepowered.com/community/forums/viewthread/107155 now I get thur "*** Phase 3: Mission Lighting
Mission lighting done" and still get the stall.
#20
07/29/2010 (3:04 pm)
Grumble, Grumble, Grumble. Originaly I had left advanceTime in, AFX calls it alot in spells, it seems(haven't actualy tested, but found advanced time over 100 times though out the spells)... so now other than AFX and a few small mods to the binary. My code is now a pure copy of this post. It gets to "Mapping string: MissionStart to index: 12
Mapping string: SyncClock to index: 13" and freeze. I'm using AFX2_B1_for_T3D110_B1_SDK. we are talking about the same binary version as above correct? or T3D110_B1_SDK right? The joys of writing for undocument code, ha, ha, ha?
Page «Previous 1 2