mirror of
				https://github.com/JezuzLizard/T4SP-Server-Plugin.git
				synced 2025-11-03 19:17:10 +00:00 
			
		
		
		
	Use t6-gsc-utils as a base.
This commit is contained in:
		
							
								
								
									
										66
									
								
								src/game/game.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								src/game/game.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "structs.hpp"
 | 
			
		||||
 | 
			
		||||
#define SELECT(mp, sp) (game::environment::t4mp() ? mp : sp)
 | 
			
		||||
 | 
			
		||||
namespace game
 | 
			
		||||
{
 | 
			
		||||
	enum gamemode
 | 
			
		||||
	{
 | 
			
		||||
		multiplayer,
 | 
			
		||||
		singleplayer,
 | 
			
		||||
		none
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	extern gamemode current;
 | 
			
		||||
 | 
			
		||||
	namespace environment
 | 
			
		||||
	{
 | 
			
		||||
		bool t4mp();
 | 
			
		||||
		bool t4sp();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	template <typename T>
 | 
			
		||||
	class symbol
 | 
			
		||||
	{
 | 
			
		||||
	public:
 | 
			
		||||
		symbol(const size_t t4mp, const size_t t4sp)
 | 
			
		||||
			: t4mp_(reinterpret_cast<T*>(t4mp))
 | 
			
		||||
			, t4sp_(reinterpret_cast<T*>(t4sp))
 | 
			
		||||
		{
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		T* get() const
 | 
			
		||||
		{
 | 
			
		||||
			if (environment::t4mp())
 | 
			
		||||
			{
 | 
			
		||||
				return t4mp_;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return t4sp_;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		void set(const size_t ptr)
 | 
			
		||||
		{
 | 
			
		||||
			this->t4mp_ = reinterpret_cast<T*>(ptr);
 | 
			
		||||
			this->t4sp_ = reinterpret_cast<T*>(ptr);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		operator T* () const
 | 
			
		||||
		{
 | 
			
		||||
			return this->get();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		T* operator->() const
 | 
			
		||||
		{
 | 
			
		||||
			return this->get();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	private:
 | 
			
		||||
		T* t4mp_;
 | 
			
		||||
		T* t4sp_;
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#include "symbols.hpp"
 | 
			
		||||
		Reference in New Issue
	
	Block a user