1
0
mirror of https://github.com/solemnwarning/directplay-lite synced 2024-12-30 16:45:37 +01:00
directplay-lite/src/AsyncHandleAllocator.cpp
Daniel Collins 2635fd04cd Initial SetPeerInfo() and SetPeerInfo() implementations.
Doesn't copy between peers and only allows fetching local player info
at this time.
2018-09-24 21:40:34 +01:00

62 lines
978 B
C++

#include <dplay8.h>
#include "AsyncHandleAllocator.hpp"
AsyncHandleAllocator::AsyncHandleAllocator():
next_enum_id(1),
next_connect_id(1),
next_send_id(1),
next_pinfo_id(1) {}
DPNHANDLE AsyncHandleAllocator::new_enum()
{
DPNHANDLE handle = next_enum_id++ | TYPE_ENUM;
next_enum_id &= ~TYPE_MASK;
if(next_enum_id == 0)
{
next_enum_id = 1;
}
return handle;
}
DPNHANDLE AsyncHandleAllocator::new_connect()
{
DPNHANDLE handle = next_connect_id++ | TYPE_ENUM;
next_connect_id &= ~TYPE_MASK;
if(next_connect_id == 0)
{
next_connect_id = 1;
}
return handle;
}
DPNHANDLE AsyncHandleAllocator::new_send()
{
DPNHANDLE handle = next_send_id++ | TYPE_ENUM;
next_send_id &= ~TYPE_MASK;
if(next_send_id == 0)
{
next_send_id = 1;
}
return handle;
}
DPNHANDLE AsyncHandleAllocator::new_pinfo()
{
DPNHANDLE handle = next_pinfo_id++ | TYPE_ENUM;
next_pinfo_id &= ~TYPE_MASK;
if(next_pinfo_id == 0)
{
next_pinfo_id = 1;
}
return handle;
}