(svn r12357) [NewGRF_ports] -Codechange: Use instantiation of new FSMPortMovingData to create a copy of a const. NewGRF_ports
authorrichk
Mon, 10 Mar 2008 16:35:38 +0000
branchNewGRF_ports
changeset 6883 8a09982aebc5
parent 6882 f508b3bab2c5
child 10179 eec5a7dcbf61
(svn r12357) [NewGRF_ports] -Codechange: Use instantiation of new FSMPortMovingData to create a copy of a const.
src/aircraft_cmd.cpp
src/fsmport.h
--- a/src/aircraft_cmd.cpp	Mon Mar 10 16:29:40 2008 +0000
+++ b/src/aircraft_cmd.cpp	Mon Mar 10 16:35:38 2008 +0000
@@ -100,8 +100,8 @@
  */
 static AirportMovingData* RotateAMDbyOrientation(Vehicle *v, const FSMPortMovingData* amd, byte size_x, byte size_y, byte FSM_orientation)
 {
-	FSMPortMovingData* new_amd;
-	new_amd = copyFSMMovingData(amd);
+	/* Make a copy of the original moving data */
+	FSMPortMovingData *new_amd = new FSMPortMovingData(amd);
 
 	switch (FSM_orientation) {
 		case DIR_NE:
--- a/src/fsmport.h	Mon Mar 10 16:29:40 2008 +0000
+++ b/src/fsmport.h	Mon Mar 10 16:35:38 2008 +0000
@@ -17,19 +17,19 @@
 	Direction direction;
 	byte state;
 	byte block;  //block number for this specific location
-};
 
-static FSMPortMovingData* copyFSMMovingData(const FSMPortMovingData *md) {
-	FSMPortMovingData* new_md = new FSMPortMovingData;
-	new_md->x = md->x;
-	new_md->y = md->y;
-	new_md->z = md->z;
-	new_md->direction = md->direction;
-	new_md->flag = md->flag;
-	new_md->state = md->state;
-	new_md->block = md->block;
-	return new_md;
-}
+	FSMPortMovingData() {}
+
+	FSMPortMovingData(const FSMPortMovingData *md) {
+		this->x = md->x;
+		this->y = md->y;
+		this->z = md->z;
+		this->direction = md->direction;
+		this->flag      = md->flag;
+		this->state     = md->state;
+		this->block     = md->block;
+	}
+};
 
 struct FSMCommand {
 	FSMCommand *next;         ///< Possible extra movement choices from this position