src/players.cpp
branchgamebalance
changeset 9911 0b8b245a2391
parent 9909 dce9a6923bb7
child 9912 1ac8aac92385
--- a/src/players.cpp	Wed Jun 13 11:17:30 2007 +0000
+++ b/src/players.cpp	Wed Jun 13 11:45:14 2007 +0000
@@ -27,6 +27,7 @@
 #include "date.h"
 #include "window.h"
 #include "player_face.h"
+#include "group.h"
 
 /**
  * Sets the local player and updates the patch settings that are set on a
@@ -638,6 +639,7 @@
  * if p1 = 2, then
  * - p2 = minimum amount of money available
  * if p1 = 3, then:
+ * - p1 bits  8-15 = engine group
  * - p2 bits  0-15 = old engine type
  * - p2 bits 16-31 = new engine type
  * if p1 = 4, then:
@@ -693,8 +695,10 @@
 		case 3: {
 			EngineID old_engine_type = GB(p2, 0, 16);
 			EngineID new_engine_type = GB(p2, 16, 16);
+			GroupID id_g = GB(p1, 16, 16);
 			int32 cost;
 
+			if (!IsValidGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR;
 			if (new_engine_type != INVALID_ENGINE) {
 				/* First we make sure that it's a valid type the user requested
 				 * check that it's an engine that is in the engine array */
@@ -714,9 +718,9 @@
 				if (!HASBIT(GetEngine(new_engine_type)->player_avail, _current_player))
 					return CMD_ERROR;
 
-				cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, flags);
+				cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, id_g, flags);
 			} else {
-				cost = RemoveEngineReplacementForPlayer(p, old_engine_type, flags);
+				cost = RemoveEngineReplacementForPlayer(p, old_engine_type,id_g, flags);
 			}
 
 			if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type);
@@ -901,6 +905,7 @@
 			p->is_active = false;
 		}
 		RemoveAllEngineReplacementForPlayer(p);
+		RemoveAllGroupsForPlayer(p);
 
 	} break;
 
@@ -1109,7 +1114,7 @@
 
 	    SLE_VAR(Player, player_color,          SLE_UINT8),
 	    SLE_VAR(Player, player_money_fraction, SLE_UINT8),
-	    SLE_VAR(Player, avail_railtypes,       SLE_UINT8),
+	SLE_CONDVAR(Player, avail_railtypes,       SLE_UINT8,                   0, 57),
 	    SLE_VAR(Player, block_preview,         SLE_UINT8),
 
 	    SLE_VAR(Player, cargo_types,           SLE_UINT16),