the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 71 lines 1.2 kB view raw
1 2 3#include "stdafx.h" 4 5 6 7TLSStorageOrbis* TLSStorageOrbis::m_pInstance = NULL; 8 9BOOL TLSStorageOrbis::m_activeList[sc_maxSlots]; 10__thread LPVOID TLSStorageOrbis::m_values[sc_maxSlots]; 11 12 13 14TLSStorageOrbis::TLSStorageOrbis() 15{ 16 for(int i=0;i<sc_maxSlots; i++) 17 { 18 m_activeList[i] = false; 19 m_values[i] = NULL; 20 } 21} 22 23TLSStorageOrbis* TLSStorageOrbis::Instance() 24{ 25 if ( m_pInstance == 0 ) // Is this the first time? 26 { 27 m_pInstance = new TLSStorageOrbis; // Create the singleton instance. 28 } 29 return m_pInstance; 30} 31 32 33int TLSStorageOrbis::Alloc() 34{ 35 for(int i=0; i<sc_maxSlots; i++) 36 { 37 if(m_activeList[i] == false) 38 { 39 m_activeList[i] = true; 40 m_values[i] = NULL; 41 return i; 42 } 43 } 44 assert(0); // we've ran out of slots 45} 46 47BOOL TLSStorageOrbis::Free( DWORD _index ) 48{ 49 if(m_activeList[_index] == false) 50 return false; // not been allocated 51 52 m_activeList[_index] = false; 53 m_values[_index] = NULL; 54 return true; 55} 56 57BOOL TLSStorageOrbis::SetValue( DWORD _index, LPVOID _val ) 58{ 59 if(m_activeList[_index] == false) 60 return false; 61 m_values[_index] = _val; 62 return true; 63} 64 65LPVOID TLSStorageOrbis::GetValue( DWORD _index ) 66{ 67 if(m_activeList[_index] == false) 68 return NULL; 69 return m_values[_index]; 70} 71