Commit 00236dba authored by Eiko Oltmanns's avatar Eiko Oltmanns

added function to include pointers in crc calculation

parent b3a529d6
......@@ -207,9 +207,8 @@ uint32_t cUnit::getChecksum(uint32_t crc) const
crc = calcCheckSum(p->getId(), crc);
for (const auto& p : detectedByPlayerList)
crc = calcCheckSum(p->getId(), crc);
//cJob* job
crc = calcCheckSum(isBig, crc);
crc = calcCheckSum(owner?owner->getId():0, crc);
crc = calcCheckSum(owner, crc);
crc = calcCheckSum(position, crc);
crc = calcCheckSum(customName, crc);
crc = calcCheckSum(turnsDisabled, crc);
......
......@@ -1567,7 +1567,7 @@ uint32_t cVehicle::getChecksum(uint32_t crc) const
crc = calcCheckSum(BuildPath, crc);
crc = calcCheckSum(WalkFrame, crc);
for ( const auto& p : detectedInThisTurnByPlayerList)
crc = calcCheckSum(p->getId(), crc);
crc = calcCheckSum(p, crc);
//cClientMoveJob* clientMoveJob;
//std::shared_ptr<cAutoMJob> autoMoveJob;
crc = calcCheckSum(tileMovementOffset, crc);
......
......@@ -183,7 +183,7 @@ void cAttackJob::onRemoveUnit(const cUnit& unit)
//------------------------------------------------------------------------------
uint32_t cAttackJob::getChecksum(uint32_t crc) const
{
crc = calcCheckSum(aggressor->getId(), crc);
crc = calcCheckSum(aggressor, crc);
crc = calcCheckSum(targetPosition, crc);
crc = calcCheckSum(lockedTargets, crc);
crc = calcCheckSum(fireDir, crc);
......
......@@ -411,7 +411,7 @@ const cEndMoveAction& cMoveJob::getEndMoveAction() const
//------------------------------------------------------------------------------
uint32_t cMoveJob::getChecksum(uint32_t crc) const
{
crc = calcCheckSum(vehicle->getId(), crc);
crc = calcCheckSum(vehicle, crc);
crc = calcCheckSum(path, crc);
crc = calcCheckSum(state, crc);
crc = calcCheckSum(savedSpeed, crc);
......
......@@ -81,6 +81,20 @@ uint32_t calcCheckSum(const T& data, uint32_t crc)
return crcWrapper::getChecksum(data, crc);
};
template <typename T>
uint32_t calcCheckSum(const T* data, uint32_t crc)
{
//target type of the pointer must have a getId() member
return calcCheckSum(data ? data->getId() : -1, crc);
}
template <typename T>
uint32_t calcCheckSum(T* data, uint32_t crc)
{
//target type of the pointer must have a getId() member
return calcCheckSum(data ? data->getId() : -1, crc);
}
template<typename T>
uint32_t calcCheckSum(const std::vector<T>& data, uint32_t checksum)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment