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.
7 #include "ClientInfo.hpp"
10 ClientInfoT::ClientInfoT(const NetAddressT
& ClientAddress_
, const std::string
& PlayerName_
, const std::string
& ModelName_
)
11 : ClientAddress(ClientAddress_
),
14 TimeSinceLastMessage(0.0),
15 TimeSinceLastUpdate(0.0),
16 ClientState(Wait4MapInfoACK
),
17 PlayerName(PlayerName_
),
18 ModelName(ModelName_
),
20 PreviousPlayerCommand(),
21 PendingPlayerCommands(),
22 LastPlayerCommandNr(0),
23 LastKnownFrameReceived(0),
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;
52 for (unsigned int i
= 0; i
< OldStatesPVSEntityIDs
.Size(); i
++)
53 OldStatesPVSEntityIDs
[i
].Overwrite();