Fix issue in Rocket.lua script.
[cafu-Engine.git] / Ca3DE / Server / ClientInfo.cpp
blobaa2cbbc0dcdd612692d2ad561a48d2f8ea80bb6c
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
7 #include "ClientInfo.hpp"
10 ClientInfoT::ClientInfoT(const NetAddressT& ClientAddress_, const std::string& PlayerName_, const std::string& ModelName_)
11 : ClientAddress(ClientAddress_),
12 GameProtocol(),
13 ReliableDatas(),
14 TimeSinceLastMessage(0.0),
15 TimeSinceLastUpdate(0.0),
16 ClientState(Wait4MapInfoACK),
17 PlayerName(PlayerName_),
18 ModelName(ModelName_),
19 EntityID(0),
20 PreviousPlayerCommand(),
21 PendingPlayerCommands(),
22 LastPlayerCommandNr(0),
23 LastKnownFrameReceived(0),
24 BaseLineFrameNr(1),
25 OldStatesPVSEntityIDs()
27 OldStatesPVSEntityIDs.PushBackEmpty(16); // The size MUST be a power of 2.
31 void ClientInfoT::InitForNewWorld(unsigned long ClientEntityID)
33 ClientState = Wait4MapInfoACK;
34 EntityID = ClientEntityID;
36 PreviousPlayerCommand = PlayerCommandT();
37 PendingPlayerCommands.Overwrite();
39 // The client restarts the player command numbering at 1 whenever a new world is entered.
40 // A value of 0 means that no player command has been received yet (in the current world).
41 LastPlayerCommandNr = 0;
43 // From Ca3DEWorldT init (ctor), the client knows the baselines ("create states") for frame 1,
44 // so the server does not have to sent `SC1_EntityBaseLine` messages for the entities in the map file.
45 // However, the first `SC1_FrameInfo` message can *not* delta from frame 1, but must delta from the
46 // baselines, because the client's PVS info for frame 1 is not setup. And even if it was, the server
47 // frame is probably much much larger than 1, so that limited PVS information buffering would require
48 // sending from the baseline anyway. Thus LastKnownFrameReceived = 0.
49 LastKnownFrameReceived = 0;
50 BaseLineFrameNr = 1;
52 for (unsigned int i = 0; i < OldStatesPVSEntityIDs.Size(); i++)
53 OldStatesPVSEntityIDs[i].Overwrite();