Add orders files and COrder class to store orders
This commit is contained in:
parent
0057986380
commit
0e6c85229c
3 changed files with 77 additions and 0 deletions
42
game/orders.h
Normal file
42
game/orders.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef _ORDERS_H_
|
||||
#define _ORDERS_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "gametypes.h"
|
||||
|
||||
#define ORDER_DELIMITER ' '
|
||||
|
||||
// Type for all orders ( as a char )
|
||||
typedef char order_c;
|
||||
|
||||
// Container for an order
|
||||
struct COrder
|
||||
{
|
||||
// Unit order is for
|
||||
unit_id_t unit;
|
||||
|
||||
// Order command issued
|
||||
order_c order;
|
||||
|
||||
inline bool operator==( const COrder& rhs ) const;
|
||||
inline bool operator!=( const COrder& rhs ) const { return !(*this==rhs); }
|
||||
};
|
||||
|
||||
inline bool COrder::operator== ( const COrder& rhs ) const
|
||||
{
|
||||
return ( unit == rhs.unit ) && ( order == rhs.order );
|
||||
}
|
||||
|
||||
// Typedef a vector of orders
|
||||
typedef std::vector<COrder> COrderVector;
|
||||
|
||||
// Order strings stored as simply "[unit id] [order char]"
|
||||
|
||||
// string <--> order conversion functions
|
||||
std::string GetStringFromOrder( COrder& order );
|
||||
COrder GetOrderFromString( std::string order );
|
||||
|
||||
|
||||
#endif //_ORDERS_H_
|
Loading…
Add table
Add a link
Reference in a new issue