summaryrefslogtreecommitdiff
path: root/src/players.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-19 09:40:18 +0000
committerrubidium <rubidium@openttd.org>2007-05-19 09:40:18 +0000
commit8f0f090c5139465bb2db1bf280886a563a68385d (patch)
treefcea59953bd1ce2ff5f0302669d3649bf7ca78bb /src/players.cpp
parent9a4b4ba4484112c7eefa6ed134ec4d725be7d2a7 (diff)
downloadopenttd-8f0f090c5139465bb2db1bf280886a563a68385d.tar.xz
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
Diffstat (limited to 'src/players.cpp')
-rw-r--r--src/players.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/players.cpp b/src/players.cpp
index 1a7487ce9..b142f669b 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -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 @@ static void DeletePlayerStuff(PlayerID pi)
* 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,11 @@ int32 CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
case 3: {
EngineID old_engine_type = GB(p2, 0, 16);
EngineID new_engine_type = GB(p2, 16, 16);
+ GroupID id_g = GB(p1, 16, 8);
int32 cost;
+ if (!IsValidGroupID(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 +719,9 @@ int32 CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 +906,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
p->is_active = false;
}
RemoveAllEngineReplacementForPlayer(p);
+ RemoveAllGroupsForPlayer(p);
} break;