Changeset - r7673:ae96f5f8bc2f
[Not reviewed]
master
0 1 0
belugas - 17 years ago 2007-10-05 02:21:40
belugas@openttd.org
(svn r11204) -Feature: [NewGRF] Add support for Action 00 for Industries and IndustryTiles.
Thanks to :Csaboka for original concept, specs & help. Dalestan for technical explanations.
Pikkabird & Georges for detailled comments on their grf works. The Alpha testers (You know who you are).
And finally (but not least) Maedhros (newhouses), peter1138(newgrf) Rubidium and glx (numerous and welcome patches)
Remember: it certainly can be buggy. But be sure that behaviour has been tested in TTDP (if you can) before raising a flag.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -4631,193 +4631,193 @@ static void TranslateGRFStrings(byte *bu
 

	
 
/* 'Action 0xFF' */
 
static void GRFDataBlock(byte *buf, int len)
 
{
 
	if (_grf_data_blocks == 0) {
 
		grfmsg(2, "GRFDataBlock: unexpected data block, skipping");
 
		return;
 
	}
 

	
 
	buf++;
 
	uint8 name_len = grf_load_byte(&buf);
 
	const char *name = (const char *)buf;
 
	buf += name_len + 1;
 

	
 
	grfmsg(2, "GRFDataBlock: block name '%s'...", name);
 

	
 
	_grf_data_blocks--;
 

	
 
	switch (_grf_data_type) {
 
		case GDT_SOUND: LoadGRFSound(buf, len - name_len - 2); break;
 
		default: NOT_REACHED(); break;
 
	}
 
}
 

	
 

	
 
/* Used during safety scan on unsafe actions */
 
static void GRFUnsafe(byte *buf, int len)
 
{
 
	SETBIT(_cur_grfconfig->flags, GCF_UNSAFE);
 

	
 
	/* Skip remainder of GRF */
 
	_skip_sprites = -1;
 
}
 

	
 

	
 
static void InitializeGRFSpecial()
 
{
 
	_ttdpatch_flags[0] =  ((_patches.always_small_airport ? 1 : 0) << 0x0C)  // keepsmallairport
 
	                   |                                        (1 << 0x0D)  // newairports
 
	                   |                                        (1 << 0x0E)  // largestations
 
	                   |           ((_patches.longbridges ? 1 : 0) << 0x0F)  // longbridges
 
	                   |                                        (0 << 0x10)  // loadtime
 
	                   |                                        (1 << 0x12)  // presignals
 
	                   |                                        (1 << 0x13)  // extpresignals
 
	                   | ((_patches.never_expire_vehicles ? 1 : 0) << 0x16)  // enginespersist
 
	                   |                                        (1 << 0x1B)  // multihead
 
	                   |                                        (1 << 0x1D)  // lowmemory
 
	                   |                                        (1 << 0x1E); // generalfixes
 

	
 
	_ttdpatch_flags[1] =                                        (0 << 0x07)  // moreairports - based on units of noise
 
	                   |        ((_patches.mammoth_trains ? 1 : 0) << 0x08)  // mammothtrains
 
	                   |                                        (1 << 0x09)  // trainrefit
 
	                   |                                        (0 << 0x0B)  // subsidiaries
 
	                   |       ((_patches.gradual_loading ? 1 : 0) << 0x0C)  // gradualloading
 
	                   |                                        (1 << 0x12)  // unifiedmaglevmode - set bit 0 mode. Not revelant to OTTD
 
	                   |                                        (1 << 0x13)  // unifiedmaglevmode - set bit 1 mode
 
	                   |                                        (1 << 0x14)  // bridgespeedlimits
 
	                   |                                        (1 << 0x16)  // eternalgame
 
	                   |                                        (1 << 0x17)  // newtrains
 
	                   |                                        (1 << 0x18)  // newrvs
 
	                   |                                        (1 << 0x19)  // newships
 
	                   |                                        (1 << 0x1A)  // newplanes
 
	                   |           ((_patches.signal_side ? 1 : 0) << 0x1B)  // signalsontrafficside
 
	                   |                                        (1 << 0x1C); // electrifiedrailway
 

	
 
	_ttdpatch_flags[2] =                                        (1 << 0x01)  // loadallgraphics - obsolote
 
	                   |                                        (1 << 0x03)  // semaphores
 
	                   |                                        (0 << 0x0B)  // enhancedgui
 
	                   |                                        (0 << 0x0C)  // newagerating
 
	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x0D)  // buildonslopes
 
	                   |         ((_patches.full_load_any ? 1 : 0) << 0x0E)  // fullloadany
 
	                   |                                        (1 << 0x0F)  // planespeed - TODO depends on patch when implemented
 
	                   |                                        (0 << 0x10)  // moreindustriesperclimate - obsolete
 
	                   |                                        (0 << 0x11)  // moretoylandfeatures
 
	                   |                                        (1 << 0x12)  // newstations
 
	                   |                                        (0 << 0x13)  // tracktypecostdiff
 
	                   |                                        (1 << 0x14)  // manualconvert
 
	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x15)  // buildoncoasts
 
	                   |                                        (1 << 0x16)  // canals
 
	                   |                                        (1 << 0x17)  // newstartyear
 
	                   |    ((_patches.freight_trains > 1 ? 1 : 0) << 0x18)  // freighttrains
 
	                   |                                        (1 << 0x19)  // newhouses
 
	                   |                                        (1 << 0x1A)  // newbridges
 
	                   |                                        (1 << 0x1B)  // newtownnames
 
	                   |                                        (0 << 0x1C)  // moreanimations
 
	                   |    ((_patches.wagon_speed_limits ? 1 : 0) << 0x1D)  // wagonspeedlimits
 
	                   |                                        (1 << 0x1E)  // newshistory
 
	                   |                                        (0 << 0x1F); // custombridgeheads
 

	
 
	_ttdpatch_flags[3] =                                        (0 << 0x00)  // newcargodistribution
 
	                   |                                        (1 << 0x01)  // windowsnap
 
	                   |                                        (0 << 0x02)  // townbuildnoroad
 
	                   |                                        (0 << 0x03)  // pathbasedsignalling. To enable if ever pbs is back
 
	                   |                                        (0 << 0x04)  // aichoosechance
 
	                   |                                        (1 << 0x05)  // resolutionwidth
 
	                   |                                        (1 << 0x06)  // resolutionheight
 
	                   |                                        (0 << 0x07)  // newindustries
 
	                   |                                        (1 << 0x07)  // newindustries
 
	                   |         ((_patches.improved_load ? 1 : 0) << 0x08)  // fifoloading
 
	                   |                                        (0 << 0x09)  // townroadbranchprob
 
	                   |                                        (0 << 0x0A)  // tempsnowline
 
	                   |                                        (1 << 0x0B)  // newcargo
 
	                   |                                        (1 << 0x0C)  // enhancemultiplayer
 
	                   |                                        (1 << 0x0D)  // onewayroads
 
	                   |   ((_patches.nonuniform_stations ? 1 : 0) << 0x0E)  // irregularstations
 
	                   |                                        (1 << 0x0F)  // statistics
 
	                   |                                        (1 << 0x10)  // newsounds
 
	                   |                                        (1 << 0x11)  // autoreplace
 
	                   |                                        (1 << 0x12)  // autoslope
 
	                   |                                        (0 << 0x13)  // followvehicle
 
	                   |                                        (1 << 0x14)  // trams
 
	                   |                                        (0 << 0x15)  // enhancetunnels
 
	                   |                                        (1 << 0x16)  // shortrvs
 
	                   |                                        (1 << 0x17)  // articulatedrvs
 
	                   |                                        (1 << 0x1E); // variablerunningcosts
 
}
 

	
 
static void ResetCustomStations()
 
{
 
	for (GRFFile *file = _first_grffile; file != NULL; file = file->next) {
 
		if (file->stations == NULL) continue;
 
		for (uint i = 0; i < MAX_STATIONS; i++) {
 
			if (file->stations[i] == NULL) continue;
 
			StationSpec *statspec = file->stations[i];
 

	
 
			/* Release renderdata, if it wasn't copied from another custom station spec  */
 
			if (!statspec->copied_renderdata) {
 
				for (uint t = 0; t < statspec->tiles; t++) {
 
					free((void*)statspec->renderdata[t].seq);
 
				}
 
				free(statspec->renderdata);
 
			}
 

	
 
			/* Release platforms and layouts */
 
			if (!statspec->copied_layouts) {
 
				for (uint l = 0; l < statspec->lengths; l++) {
 
					for (uint p = 0; p < statspec->platforms[l]; p++) {
 
						free(statspec->layouts[l][p]);
 
					}
 
					free(statspec->layouts[l]);
 
				}
 
				free(statspec->layouts);
 
				free(statspec->platforms);
 
			}
 

	
 
			/* Release this station */
 
			free(statspec);
 
		}
 

	
 
		/* Free and reset the station data */
 
		free(file->stations);
 
		file->stations = NULL;
 
	}
 
}
 

	
 
static void ResetCustomHouses()
 
{
 
	GRFFile *file;
 
	uint i;
 

	
 
	for (file = _first_grffile; file != NULL; file = file->next) {
 
		if (file->housespec == NULL) continue;
 
		for (i = 0; i < HOUSE_MAX; i++) {
 
			free(file->housespec[i]);
 
		}
 

	
 
		free(file->housespec);
 
		file->housespec = NULL;
 
	}
 
}
 

	
 
static void ResetCustomIndustries()
 
{
 
	GRFFile *file;
 

	
 
	for (file = _first_grffile; file != NULL; file = file->next) {
 
		uint i;
 
		/* We are verifiying both tiles and industries specs loaded from the grf file
 
		 * First, let's deal with industryspec */
 
		if (file->industryspec != NULL) {
 

	
 
			for (i = 0; i < NUM_INDUSTRYTYPES; i++) {
 
				IndustrySpec *ind = file->industryspec[i];
 

	
 
				if (ind != NULL) {
 
					/* We need to remove the sounds array */
 
					if (HASBIT(ind->cleanup_flag, CLEAN_RANDOMSOUNDS)) {
 
						free((void*)ind->random_sounds);
 
					}
 

	
 
					/* We need to remove the tiles layouts */
 
					if (HASBIT(ind->cleanup_flag, CLEAN_TILELSAYOUT) && ind->table != NULL) {
 
						for (int j = 0; j < ind->num_table; j++) {
 
							/* remove the individual layouts */
0 comments (0 inline, 0 general)