mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r10992) -Fix [FS#1132]: huge amount of vehicles in the "ungrouped" group. Patch by frosch.
This commit is contained in:
parent
5ce935c6eb
commit
ac838de385
@ -49,7 +49,7 @@ void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
|
|||||||
{
|
{
|
||||||
Player *p = GetPlayer(_local_player);
|
Player *p = GetPlayer(_local_player);
|
||||||
byte type = GetEngine(e)->type;
|
byte type = GetEngine(e)->type;
|
||||||
uint num_engines = GetGroupNumEngines(id_g, e);
|
uint num_engines = GetGroupNumEngines(_local_player, id_g, e);
|
||||||
|
|
||||||
if (num_engines == 0 || p->num_engines[e] == 0) {
|
if (num_engines == 0 || p->num_engines[e] == 0) {
|
||||||
/* We don't have any of this engine type.
|
/* We don't have any of this engine type.
|
||||||
@ -154,7 +154,7 @@ static void GenerateReplaceVehList(Window *w, bool draw_left)
|
|||||||
|
|
||||||
if (draw_left) {
|
if (draw_left) {
|
||||||
const GroupID selected_group = WP(w, replaceveh_d).sel_group;
|
const GroupID selected_group = WP(w, replaceveh_d).sel_group;
|
||||||
const uint num_engines = GetGroupNumEngines(selected_group, e);
|
const uint num_engines = GetGroupNumEngines(_local_player, selected_group, e);
|
||||||
|
|
||||||
/* Skip drawing the engines we don't have any of and haven't set for replacement */
|
/* Skip drawing the engines we don't have any of and haven't set for replacement */
|
||||||
if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e, selected_group) == INVALID_ENGINE) continue;
|
if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e, selected_group) == INVALID_ENGINE) continue;
|
||||||
|
@ -853,7 +853,8 @@ void DrawEngineList(VehicleType type, int x, int y, const EngineList eng_list, u
|
|||||||
|
|
||||||
for (; min < max; min++, y += step_size) {
|
for (; min < max; min++, y += step_size) {
|
||||||
const EngineID engine = eng_list[min];
|
const EngineID engine = eng_list[min];
|
||||||
const uint num_engines = GetGroupNumEngines(selected_group, engine);
|
/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_player here. */
|
||||||
|
const uint num_engines = GetGroupNumEngines(_local_player, selected_group, engine);
|
||||||
|
|
||||||
SetDParam(0, engine);
|
SetDParam(0, engine);
|
||||||
DrawString(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? 0xC : 0x10);
|
DrawString(x + x_offset, y, STR_ENGINE_NAME, engine == selected_id ? 0xC : 0x10);
|
||||||
|
@ -76,15 +76,17 @@ static inline uint GetGroupArraySize(void)
|
|||||||
* @param id_e The EngineID of the engine to count
|
* @param id_e The EngineID of the engine to count
|
||||||
* @return The number of engines with EngineID id_e in the group
|
* @return The number of engines with EngineID id_e in the group
|
||||||
*/
|
*/
|
||||||
static inline uint GetGroupNumEngines(GroupID id_g, EngineID id_e)
|
static inline uint GetGroupNumEngines(PlayerID p, GroupID id_g, EngineID id_e)
|
||||||
{
|
{
|
||||||
if (IsValidGroupID(id_g)) return GetGroup(id_g)->num_engines[id_e];
|
if (IsValidGroupID(id_g)) return GetGroup(id_g)->num_engines[id_e];
|
||||||
|
|
||||||
uint num = GetPlayer(_local_player)->num_engines[id_e];
|
uint num = GetPlayer(p)->num_engines[id_e];
|
||||||
if (!IsDefaultGroupID(id_g)) return num;
|
if (!IsDefaultGroupID(id_g)) return num;
|
||||||
|
|
||||||
const Group *g;
|
const Group *g;
|
||||||
FOR_ALL_GROUPS(g) num -= g->num_engines[id_e];
|
FOR_ALL_GROUPS(g) {
|
||||||
|
if (g->owner == p) num -= g->num_engines[id_e];
|
||||||
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user