Pull SOrderUnitPair out of game header
This commit is contained in:
		
							parent
							
								
									9551560bc0
								
							
						
					
					
						commit
						ca1705ad4a
					
				
					 2 changed files with 40 additions and 30 deletions
				
			
		|  | @ -4,40 +4,11 @@ | ||||||
| #include "unit.h" | #include "unit.h" | ||||||
| #include "gametypes.h" | #include "gametypes.h" | ||||||
| #include "order.h" | #include "order.h" | ||||||
|  | #include "orderunitpair.h" | ||||||
| 
 | 
 | ||||||
| #define GAME_HEADER_FORMATTER "NAME:%s\nSIZE:[%u,%u]\nTURN:%u" | #define GAME_HEADER_FORMATTER "NAME:%s\nSIZE:[%u,%u]\nTURN:%u" | ||||||
| #define GAME_HEADER_DELIMITER "~~~~\n" | #define GAME_HEADER_DELIMITER "~~~~\n" | ||||||
| 
 | 
 | ||||||
| // Type for order and unit pairs
 |  | ||||||
| struct SOrderUnitPair |  | ||||||
| { |  | ||||||
|     // Straight up move constructor
 |  | ||||||
|     SOrderUnitPair( SOrderUnitPair && other ) |  | ||||||
|         : unit ( std::move(other.unit) ) |  | ||||||
|         , order ( other.order ) |  | ||||||
|     {} |  | ||||||
| 
 |  | ||||||
|     // Multi parameter constructor
 |  | ||||||
|     SOrderUnitPair( CUnit&& u, COrder o ) |  | ||||||
|         : unit ( std::move(u) ) |  | ||||||
|         , order ( o ) |  | ||||||
|     {} |  | ||||||
| 
 |  | ||||||
|     // Move assignment operator
 |  | ||||||
|     inline SOrderUnitPair & operator=( SOrderUnitPair && rhs ) |  | ||||||
|     { |  | ||||||
|         this->unit = std::move(rhs.unit); |  | ||||||
|         this->order = std::move(rhs.order); |  | ||||||
|         return *this; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     CUnit   unit;       // The unit
 |  | ||||||
|     COrder  order;      // Order for this unit from this turn
 |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| // Typedef for a vector of these unit pairs
 |  | ||||||
| typedef std::vector<SOrderUnitPair> OrderUnitPairVector; |  | ||||||
| 
 |  | ||||||
| // Full TTRTS Game class
 | // Full TTRTS Game class
 | ||||||
| // Stores information about the game
 | // Stores information about the game
 | ||||||
| // Can convert from a string or to a string
 | // Can convert from a string or to a string
 | ||||||
|  |  | ||||||
							
								
								
									
										39
									
								
								source/game/orderunitpair.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								source/game/orderunitpair.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | ||||||
|  | #ifndef _TTRTS_ORDERUNITPAIR_H_ | ||||||
|  | #define _TTRTS_ORDERUNITPAIR_H_ | ||||||
|  | 
 | ||||||
|  | #include "order.h" | ||||||
|  | #include "unit.h" | ||||||
|  | 
 | ||||||
|  | #include <vector> | ||||||
|  | 
 | ||||||
|  | // Type for order and unit pairs
 | ||||||
|  | struct SOrderUnitPair | ||||||
|  | { | ||||||
|  |     // Straight up move constructor
 | ||||||
|  |     SOrderUnitPair( SOrderUnitPair && other ) | ||||||
|  |             : unit ( std::move(other.unit) ) | ||||||
|  |             , order ( other.order ) | ||||||
|  |     {} | ||||||
|  | 
 | ||||||
|  |     // Multi parameter constructor
 | ||||||
|  |     SOrderUnitPair( CUnit&& u, COrder o ) | ||||||
|  |             : unit ( std::move(u) ) | ||||||
|  |             , order ( o ) | ||||||
|  |     {} | ||||||
|  | 
 | ||||||
|  |     // Move assignment operator
 | ||||||
|  |     inline SOrderUnitPair & operator=( SOrderUnitPair && rhs ) | ||||||
|  |     { | ||||||
|  |         this->unit = std::move(rhs.unit); | ||||||
|  |         this->order = std::move(rhs.order); | ||||||
|  |         return *this; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     CUnit   unit;       // The unit
 | ||||||
|  |     COrder  order;      // Order for this unit from this turn
 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | // Typedef for a vector of these unit pairs
 | ||||||
|  | typedef std::vector<SOrderUnitPair> OrderUnitPairVector; | ||||||
|  | 
 | ||||||
|  | #endif // _TTRTS_ORDERUNITPAIR_H_
 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue