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