if(dtime > 2.0)
dtime = 2.0;
- /*
- Day/night
- */
- {
- s32 d = 8;
- s32 t = (((m_time_of_day.get() + 24000/d/2)%24000)/(24000/d));
- s32 dn = 0;
- if(t == d/4 || t == (d-d/4))
- dn = 1;
- else if(t < d/4 || t > (d-d/4))
- dn = 2;
- else
- dn = 0;
-
- u32 dr = 1000;
- if(dn == 0)
- dr = 1000;
- if(dn == 1)
- dr = 600;
- if(dn == 2)
- dr = 300;
-
- if(dr != m_env.getDayNightRatio())
- {
- //dstream<<"dr="<<dr<<std::endl;
- dout_client<<DTIME<<"Client: changing day-night ratio"<<std::endl;
- m_env.setDayNightRatio(dr);
- m_env.expireMeshes(true);
- }
- }
-
//dstream<<"Client steps "<<dtime<<std::endl;
our_peer_id = m_con.GetPeerID();
}
// Cancel if we don't have a peer id
- if(our_peer_id == PEER_ID_NEW){
+ if(our_peer_id == PEER_ID_INEXISTENT){
dout_client<<DTIME<<"TOCLIENT_PLAYERPOS cancelled: "
"we have no peer id"
<<std::endl;
our_peer_id = m_con.GetPeerID();
}
// Cancel if we don't have a peer id
- if(our_peer_id == PEER_ID_NEW){
+ if(our_peer_id == PEER_ID_INEXISTENT){
dout_client<<DTIME<<"TOCLIENT_PLAYERINFO cancelled: "
"we have no peer id"
<<std::endl;
time = time % 24000;
m_time_of_day.set(time);
//dstream<<"Client: time="<<time<<std::endl;
+
+ /*
+ Day/night
+
+ time_of_day:
+ 0 = midnight
+ 12000 = midday
+ */
+ {
+ const s32 daylength = 16;
+ const s32 nightlength = 6;
+ const s32 daytimelength = 8;
+ s32 d = daylength;
+ s32 t = (((m_time_of_day.get())%24000)/(24000/d));
+ u32 dr;
+ if(t < nightlength/2 || t >= d - nightlength/2)
+ dr = 400;
+ else if(t >= d/2 - daytimelength/2 && t < d/2 + daytimelength/2)
+ dr = 1000;
+ else
+ dr = 750;
+
+ dstream<<"time_of_day="<<m_time_of_day.get()
+ <<", t="<<t
+ <<", dr="<<dr
+ <<std::endl;
+
+ if(dr != m_env.getDayNightRatio())
+ {
+ //dstream<<"dr="<<dr<<std::endl;
+ dout_client<<DTIME<<"Client: changing day-night ratio"<<std::endl;
+ m_env.setDayNightRatio(dr);
+ m_env.expireMeshes(true);
+ }
+ }
+
}
else if(command == TOCLIENT_CHAT_MESSAGE)
{
} //try
catch(con::PeerNotFoundException &e)
{
- dout_client<<DTIME<<"Client::AsyncProcessData(): Cancelling: The server"
- " connection doesn't exist (a timeout or not yet connected?)"<<std::endl;
+ /*dout_client<<DTIME<<"Client::AsyncProcessData(): Cancelling: The server"
+ " connection doesn't exist (a timeout or not yet connected?)"<<std::endl;*/
return false;
}
}
m_con.Send(PEER_ID_SERVER, channelnum, data, reliable);
}
-bool Client::isFetchingBlocks()
-{
- JMutexAutoLock conlock(m_con_mutex);
- con::Peer *peer = m_con.GetPeerNoEx(PEER_ID_SERVER);
- // Not really fetching but can't fetch more.
- if(peer == NULL) return true;
-
- con::Channel *channel = &(peer->channels[1]);
- /*
- NOTE: Channel 0 should always be used for fetching blocks,
- and for nothing else.
- */
- if(channel->incoming_reliables.size() > 0)
- return true;
- if(channel->outgoing_reliables.size() > 0)
- return true;
- return false;
-}
-
IncomingPacket Client::getPacket()
{
JMutexAutoLock lock(m_incoming_queue_mutex);
0: start digging
1: place block
2: stop digging (all parameters ignored)
+ 3: digging completed
*/
u8 datasize = 2 + 1 + 6 + 6 + 2;
SharedBuffer<u8> data(datasize);
}
// Set peer id if not set already
- if(myplayer->peer_id == PEER_ID_NEW)
+ if(myplayer->peer_id == PEER_ID_INEXISTENT)
myplayer->peer_id = our_peer_id;
// Check that an existing peer_id is the same as the connection's
assert(myplayer->peer_id == our_peer_id);