src/players.cpp
changeset 8732 b18f578f7c16
parent 8726 5ae45b46506b
child 8733 9e2d2a2619ff
equal deleted inserted replaced
8731:a2cab8a23491 8732:b18f578f7c16
    30 #include "autoreplace_func.h"
    30 #include "autoreplace_func.h"
    31 #include "autoreplace_gui.h"
    31 #include "autoreplace_gui.h"
    32 #include "string_func.h"
    32 #include "string_func.h"
    33 #include "ai/default/default.h"
    33 #include "ai/default/default.h"
    34 #include "ai/trolly/trolly.h"
    34 #include "ai/trolly/trolly.h"
       
    35 #include "road_func.h"
       
    36 #include "rail.h"
    35 
    37 
    36 /**
    38 /**
    37  * Sets the local player and updates the patch settings that are set on a
    39  * Sets the local player and updates the patch settings that are set on a
    38  * per-company (player) basis to reflect the core's state in the GUI.
    40  * per-company (player) basis to reflect the core's state in the GUI.
    39  * @param new_player the new player
    41  * @param new_player the new player
   586 			SndPlayFx(SND_01_BAD_YEAR);
   588 			SndPlayFx(SND_01_BAD_YEAR);
   587 		} else {
   589 		} else {
   588 			SndPlayFx(SND_00_GOOD_YEAR);
   590 			SndPlayFx(SND_00_GOOD_YEAR);
   589 		}
   591 		}
   590 	}
   592 	}
   591 }
       
   592 
       
   593 byte GetPlayerRailtypes(PlayerID p)
       
   594 {
       
   595 	byte rt = 0;
       
   596 	EngineID i;
       
   597 
       
   598 	for (i = 0; i != TOTAL_NUM_ENGINES; i++) {
       
   599 		const Engine* e = GetEngine(i);
       
   600 		const EngineInfo *ei = EngInfo(i);
       
   601 
       
   602 		if (e->type == VEH_TRAIN && HasBit(ei->climates, _opt.landscape) &&
       
   603 				(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
       
   604 			const RailVehicleInfo *rvi = RailVehInfo(i);
       
   605 
       
   606 			if (rvi->railveh_type != RAILVEH_WAGON) {
       
   607 				assert(rvi->railtype < RAILTYPE_END);
       
   608 				SetBit(rt, rvi->railtype);
       
   609 			}
       
   610 		}
       
   611 	}
       
   612 
       
   613 	return rt;
       
   614 }
       
   615 
       
   616 byte GetPlayerRoadtypes(PlayerID p)
       
   617 {
       
   618 	byte rt = 0;
       
   619 	EngineID i;
       
   620 
       
   621 	for (i = 0; i != TOTAL_NUM_ENGINES; i++) {
       
   622 		const Engine* e = GetEngine(i);
       
   623 		const EngineInfo *ei = EngInfo(i);
       
   624 
       
   625 		if (e->type == VEH_ROAD && HasBit(ei->climates, _opt.landscape) &&
       
   626 				(HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) {
       
   627 			SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
       
   628 		}
       
   629 	}
       
   630 
       
   631 	return rt;
       
   632 }
   593 }
   633 
   594 
   634 static void DeletePlayerStuff(PlayerID pi)
   595 static void DeletePlayerStuff(PlayerID pi)
   635 {
   596 {
   636 	Player *p;
   597 	Player *p;