// Ryzom - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include "stdpch.h" #include "nel/misc/debug.h" #include "nel/misc/vector.h" #include "property_history.h" #include "history.h" #include "game_share/action.h" #include "game_share/continuous_action.h" #include "game_share/action_position.h" #include using namespace std; using namespace NLMISC; using namespace CLFECOMMON; /* * Constructor */ CPropertyHistory::CPropertyHistory() { _MaxDeltaSend = DefaultMaxDeltaSend; } void CPropertyHistory::clear() { uint32 num = (uint32)_ClientEntries.size(); _ClientEntries.clear(); _ClientEntries.resize(num); } void CPropertyHistory::setMaximumClient(uint maxClient) { _ClientEntries.resize(maxClient); } // void CPropertyHistory::addClient(TClientId clientId) { nlassert(clientId < _ClientEntries.size() && !_ClientEntries[clientId].EntryUsed); CClientEntry &entry = _ClientEntries[clientId]; entry.reset(); entry.EntryUsed = true; } void CPropertyHistory::removeClient(TClientId clientId) { nlassert(clientId < _ClientEntries.size() && _ClientEntries[clientId].EntryUsed); _ClientEntries[clientId].reset(); } void CPropertyHistory::resetClient(TClientId clientId) { nlassert(clientId < _ClientEntries.size() && _ClientEntries[clientId].EntryUsed); CClientEntry &entry = _ClientEntries[clientId]; uint i; for (i=0; i(action); if (act.isDelta()) { return true; } // search if entity is already used CEntityEntry &entity = _ClientEntries[clientId].Entities[action.CLEntityId]; nlassert(entity.Used); // This asumes the continuous properties are the same for everyone uint16 propIndex = act.PropertyCode; CPropertyEntry &entry = entity.Properties[propIndex]; if (entry.AllowDelta > 0 && allowPack) { if (--entry.AllowDelta > 0) { act.packDelta(entry.Garanted); return true; } else { // disable next incoming garanted packets // until we send a garanted packet entry.Packet = 0xFFFFFFFF; return false; } } else { return false; } } // bool CPropertyHistory::packDelta(TClientId clientId, CActionPosition &action, bool allowPack) { nlassert(clientId < _ClientEntries.size() && _ClientEntries[clientId].EntryUsed); if (action.isDelta()) { return true; } // search if entity is already used CEntityEntry &entity = _ClientEntries[clientId].Entities[action.CLEntityId]; nlassert(entity.Used); CPropertyEntry &ex = entity.Properties[PROPERTY_POSX]; if (ex.AllowDelta > 0 && allowPack) { if (--ex.AllowDelta > 0) { action.packDelta(entity.Properties[PROPERTY_POSX].Garanted, entity.Properties[PROPERTY_POSY].Garanted, entity.Properties[PROPERTY_POSZ].Garanted); return true; } else { // disable next incoming garanted packets // until we send a garanted packet ex.Packet = 0xFFFFFFFF; return false; } } else { return false; } } */ // // // void CPropertyHistory::ackProperty(TClientId clientId, TCLEntityId entityId, uint32 packet, TPropIndex propId) { //nlassert(clientId < _ClientEntries.size() && _ClientEntries[clientId].EntryUsed); /* if (!isContinuousProperty(propId)) return; CEntityEntry &entity = _ClientEntries[clientId].Entities[entityId]; // search if entity exists already if (!entity.Used) return; CPropertyEntry &entry = entity.Properties[propId]; // assume all previous packet have been ack'ed (ack- or ack+) if (packet == entry.Packet) { if (entry.AllowDelta == 0) entry.AllowDelta = _MaxDeltaSend; if (propId == PROPERTY_POSITION) { entity.garantyPosition(); } else { entry.Garanted = entry.ToGaranty; } entry.Packet = 0xFFFFFFFF; // nldebug("FECONTH: Ack Garanted CL=%d CEId=%d Pk=%d (%.2f,%.2f)", clientId, entityId, packet, entry.Garanted.Float); } */ } void CPropertyHistory::negAckProperty(TClientId clientId, TCLEntityId entityId, uint32 packet, TPropIndex propId) { /* nlassert(clientId < _ClientEntries.size() && _ClientEntries[clientId].EntryUsed); CEntityEntry &entity = _ClientEntries[clientId].Entities[entityId]; // search if entity exists already if (!entity.Used) return; CPropertyEntry &entry = entity.Properties[propId]; if (packet == entry.Packet) { entry.Packet = 0xFFFFFFFF; // nldebug("FECONTH: negAcked CL=%d CEId=%d Pk=%d", entityId, propId, packet); } */ } void CPropertyHistory::ackProperties(TClientId clientId, TCLEntityId entityId, uint32 packet, const vector &ids) { /* nlassert(clientId < _ClientEntries.size() && _ClientEntries[clientId].EntryUsed); CEntityEntry &entity = _ClientEntries[clientId].Entities[entityId]; // search if entity exists already nlassert(entity.Used); uint i; for (i=0; i= 0 ? conversion : -1); } void CPropertyHistory::setPropertyConversion(CPropertyTranslation *properties, sint numProperties) { sint i; for (i=0; i= 0 ? properties[i].Translation : -1); } */