50a7722242
Made some funky smart pointer things for chunks. Fixed a bug where the client would override the player position on the server and back again, resulting in sending too many chunks to the client which it doesn't even need. Fixed some compiler warnings in cPickup.cpp git-svn-id: http://mc-server.googlecode.com/svn/trunk@164 0a769ca7-a7f5-676a-18bf-c427514a06d6
37 lines
678 B
C++
37 lines
678 B
C++
#pragma once
|
|
|
|
#include "cChunk.h"
|
|
|
|
class ptr_cChunk
|
|
{
|
|
public:
|
|
ptr_cChunk( cChunk* a_Ptr )
|
|
: m_Ptr( a_Ptr )
|
|
{
|
|
if( m_Ptr ) m_Ptr->AddReference();
|
|
}
|
|
|
|
ptr_cChunk( const ptr_cChunk& a_Clone )
|
|
: m_Ptr( a_Clone.m_Ptr )
|
|
{
|
|
if( m_Ptr ) m_Ptr->AddReference();
|
|
}
|
|
|
|
~ptr_cChunk()
|
|
{
|
|
if( m_Ptr ) m_Ptr->RemoveReference();
|
|
}
|
|
|
|
cChunk* operator-> ()
|
|
{
|
|
return m_Ptr;
|
|
}
|
|
|
|
cChunk& operator* () { return *m_Ptr; }
|
|
bool operator!() { return !m_Ptr; }
|
|
bool operator==( const ptr_cChunk& a_Other ) { return m_Ptr == a_Other.m_Ptr; }
|
|
operator bool() { return m_Ptr != 0; }
|
|
operator cChunk*() { return m_Ptr; }
|
|
private:
|
|
cChunk* m_Ptr;
|
|
}; |