Changeset - r3727:1785a129fadb
[Not reviewed]
master
0 2 0
peter1138 - 19 years ago 2006-05-02 21:43:47
peter1138@openttd.org
(svn r4703) - NewGRF: add support for callback 0x1D, "can wagon be attached". This can be used to disallow freight wagons to be placed in passenger trains, along with other uses.
2 files changed with 14 insertions and 0 deletions:
0 comments (0 inline, 0 general)
newgrf_callbacks.h
Show inline comments
 
@@ -22,12 +22,14 @@ enum CallbackID {
 
	// Refit capacity, the passed vehicle needs to have its ->cargo_type set to
 
	// the cargo we are refitting to, returns the new cargo capacity
 
	CBID_VEHICLE_REFIT_CAPACITY     = 0x15,
 

	
 
	CBID_TRAIN_ARTIC_ENGINE         = 0x16,
 

	
 
	CBID_TRAIN_ALLOW_WAGON_ATTACH   = 0x1D,
 

	
 
	/* This callback is called from vehicle purchase lists. It returns a value to be
 
	 * used as a custom string ID in the 0xD000 range. */
 
	CBID_VEHICLE_ADDITIONAL_TEXT    = 0x23,
 
};
 

	
 
/**
train_cmd.c
Show inline comments
 
@@ -24,12 +24,13 @@
 
#include "depot.h"
 
#include "waypoint.h"
 
#include "vehicle_gui.h"
 
#include "train.h"
 
#include "newgrf_callbacks.h"
 
#include "newgrf_engine.h"
 
#include "newgrf_text.h"
 
#include "direction.h"
 

	
 
static bool TrainCheckIfLineEnds(Vehicle *v);
 
static void TrainController(Vehicle *v);
 

	
 
static const byte _vehicle_initial_x_fract[4] = {10,8,4,8};
 
@@ -1073,12 +1074,23 @@ int32 CmdMoveRailVehicle(TileIndex tile,
 
		if (unit_num > _patches.max_trains)
 
			return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
		if (flags & DC_EXEC) src->unitnumber = unit_num;
 
	}
 

	
 
	if (dst_head != NULL) {
 
		/* Check NewGRF Callback 0x1D */
 
		uint16 callback = GetVehicleCallbackParent(CBID_TRAIN_ALLOW_WAGON_ATTACH, 0, 0, dst_head->engine_type, src, dst_head);
 
		if (callback != CALLBACK_FAILED) {
 
			if (callback == 0xFD) return CMD_ERROR;
 
			if (callback < 0xFD) {
 
				StringID error = GetGRFStringID(GetEngineGRFID(dst_head->engine_type), 0xD000 + callback);
 
				return_cmd_error(error);
 
			}
 
		}
 
	}
 

	
 
	/* do it? */
 
	if (flags & DC_EXEC) {
 
		/* clear the ->first cache */
 
		{
 
			Vehicle *u;
0 comments (0 inline, 0 general)