Changeset - r37:ead8cba1b6f2
[Not reviewed]
master
0 5 1
dominik - 20 years ago 2004-08-13 11:28:59
dominik@openttd.org
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
6 files changed with 81 insertions and 12 deletions:
0 comments (0 inline, 0 general)
data/trkfoundw.grf
Show inline comments
 
new file 100644
 
binary diff not shown
landscape.c
Show inline comments
 
@@ -220,61 +220,75 @@ uint GetPartialZ(int x, int y, int corne
 
	}
 

	
 
	return z;
 
}
 

	
 
uint GetSlopeZ(int x,  int y)
 
{
 
	TileInfo ti;
 
//	int z;
 

	
 
	FindLandscapeHeight(&ti, x, y);
 

	
 
/*
 
	z = ti.z;
 
	x &= 0xF;
 
	y &= 0xF;
 

	
 

	
 
	assert(z < 256);
 
*/
 

	
 
	return _tile_type_procs[ti.type]->get_slope_z_proc(&ti);
 
}
 

	
 
/* TODO: add check if this tile has a foundation or not. Since this can't be done easily with the
 
	current landscape arrays, we might have to add a new TileTypeProc. */ 
 
bool hasFoundation(uint tile)
 
{
 
	return true;
 
}
 

	
 
void DrawFoundation(TileInfo *ti, uint f)
 
{
 
	uint32 sprite_base = SPR_SLOPES_BASE-14;
 
	if(hasFoundation( TILE_FROM_XY(ti->x, ti->y-1) )) sprite_base += 22;		// foundation in NW direction
 
	if(hasFoundation( TILE_FROM_XY(ti->x-1, ti->y) )) sprite_base += 22*2;	// foundation in NE direction
 

	
 
	if (f < 15) {
 
		// leveled foundation	
 
		AddSortableSpriteToDraw(f + 0x3DE - 1, ti->x, ti->y, 16, 16, 7, ti->z);
 
		if( sprite_base < SPR_SLOPES_BASE ) sprite_base = 990; // use original slope sprites
 

	
 
		AddSortableSpriteToDraw(f-1 + sprite_base, ti->x, ti->y, 16, 16, 7, ti->z);
 
		ti->z += 8;
 
		ti->tileh = 0;
 
		OffsetGroundSprite(31, 1);
 
	} else {
 
		// inclined foundation
 
		sprite_base += 14;
 
		
 
		AddSortableSpriteToDraw(
 
			HASBIT( (1<<1) | (1<<2) | (1<<4) | (1<<8), ti->tileh) ? (SPR_OPENTTD_BASE+17) + (f - 15) : 	ti->tileh + 0x3DE - 1,
 
			HASBIT( (1<<1) | (1<<2) | (1<<4) | (1<<8), ti->tileh) ? sprite_base + (f - 15) : 	ti->tileh + 0x3DE - 1,
 
			ti->x, ti->y, 1, 1, 1, ti->z
 
		);
 
		
 
		ti->tileh = _inclined_tileh[f - 15];
 
		OffsetGroundSprite(31, 9);
 
	}
 
}
 

	
 
void DoClearSquare(uint tile)
 
{
 
	ModifyTile(tile,
 
		MP_SETTYPE(MP_CLEAR) |
 
		MP_MAP2_CLEAR | MP_MAP3LO_CLEAR | MP_MAP3HI_CLEAR | MP_MAPOWNER | MP_MAP5,
 
		OWNER_NONE, /* map_owner */
 
		_generating_world ? 3 : 0 /* map5 */
 
	);
 
}
 

	
 
uint32 GetTileTrackStatus(uint tile, int mode)
 
{
 
	return _tile_type_procs[GET_TILETYPE(tile)]->get_tile_track_status_proc(tile, mode);
 
}
 

	
 
void ChangeTileOwner(uint tile, byte old_player, byte new_player)
readme.txt
Show inline comments
 
@@ -190,36 +190,36 @@ Example:
 

	
 
strgen lang/german.txt
 

	
 
This results in compiling german.txt and produces another file named german.lng.
 
Any missing strings are replaced with the english strings. Note that it looks for english.txt
 
in the lang subdirectory, which is where your language file should also be.
 

	
 
That's all! You should now be able to select the language in the game options.
 

	
 

	
 
X.X) Credits:
 
---- --------
 
The OpenTTD team:
 
  Ludvig Strigeus (ludde)        - OpenTTD author, main coder.
 
  Serge Paquet (vurlix)          - Assistant project manager, coder and webmaster.
 
  Dominik Scherer (dominik81)    - Coder
 
  Tamas Farago (Darkvater)       - Coder
 
  Owen Rudge (orudge)            - Contributor, forum host.
 
  Bjarni Corfitzen (Bjarni)      - MacOS port
 
  Cian Duffy (MYOB)              - BeOS port / manual writing
 
  Christian Rosentreter (tokaiz) - MorphOS/AmigaOS port
 
  Viktor Strigeus (wiggo)        - Web hosting services
 
  
 
Thanks to:
 
  Bug Reporters - Thanks for all bug reports.
 
  Josef Drexler - For his great work on TTDPatch.
 
  Marcin Grzegorczyk - For his TTDPatch work and documentation of TTD internals and graphics.
 
  Marcin Grzegorczyk - For his TTDPatch work and documentation of TTD internals and graphics (signals and track foundations).
 
  Mike Ragsdale - OpenTTD installer
 
  pasky - Many patches, newgrf support, etc.
 
  truesatan - Some patches
 
  TrueLight - Some patches
 
  Michael Polnick - Some patches
 
  Michael Blunck - Nice graphics
 
  George - Canal graphics
 
  Bug Reporters - Thanks for all bug reports.
 
  Chris Sawyer - For an amazing game.
 
  
spritecache.c
Show inline comments
 
@@ -50,48 +50,55 @@ static int _compact_cache_counter;
 

	
 
static const char * const _filename_list[] = {
 
	"TRG1R.GRF",
 
	"TRGIR.GRF",
 
	"signalsw.grf", //0x1320 - 0x1405 inclusive
 
//	"openttd.grf",	//0x1406 - 
 
	NULL
 
};
 

	
 
static const char * const _landscape_filenames[] = {
 
	"TRGCR.GRF",
 
	"TRGHR.GRF",
 
	"TRGTR.GRF"
 
};
 

	
 

	
 
#include "table/landscape_sprite.h"
 

	
 
static const uint16 * const _landscape_spriteindexes[] = {
 
	_landscape_spriteindexes_1,
 
	_landscape_spriteindexes_2,
 
	_landscape_spriteindexes_3,
 
};
 

	
 
static const uint16 * const _slopes_spriteindexes[] = {
 
	_slopes_spriteindexes_0,
 
	_slopes_spriteindexes_1,
 
	_slopes_spriteindexes_2,
 
	_slopes_spriteindexes_3,
 
};
 

	
 
static void CompactSpriteCache();
 

	
 
void DecodeSpecialSprite(const char *filename, int num, int load_index);
 

	
 
static void ReadSpriteHeaderSkipData(int num, int load_index)
 
{
 
	byte type;
 
	int8 i;
 
	int deaf = 0;
 

	
 
	if (_skip_sprites) {
 
		if (_skip_sprites > 0)
 
			_skip_sprites--;
 
		deaf = 1;
 
	}
 
	
 
	type = FioReadByte();
 
	if (type == 0xFF) {
 
		/* We need to really skip only special sprites in the deaf
 
		 * mode.  It won't hurt to proceed regular sprites as usual
 
		 * because if no special sprite referencing to them is
 
		 * processed, they themselves are never referenced and loaded
 
		 * on their own. */
 
		if (_skip_specials || deaf) {
 
@@ -189,94 +196,111 @@ static bool LoadNextSprite(int load_inde
 

	
 
#ifdef WANT_SPRITESIZES
 
	_sprite_xsize[load_index] = _cur_sprite.width;
 
	_sprite_ysize[load_index] = _cur_sprite.height;
 

	
 
	_sprite_xoffs[load_index] = _cur_sprite.x_offs;
 
	_sprite_yoffs[load_index] = _cur_sprite.y_offs;
 
#endif
 

	
 
	_sprite_ptr[load_index] = NULL;
 
#if defined(WANT_LOCKED)
 
	_sprite_locked[load_index] = false;
 
#endif
 

	
 
#if defined(WANT_NEW_LRU)
 
	_sprite_lru_new[load_index] = 0;
 
#else	
 
	_sprite_lru[load_index] = 0xFFFF;
 
	_sprite_lru_cur[load_index] = 0;
 
#endif
 

	
 
	return true;
 
}
 

	
 
static void SkipSprites(int count)
 
{
 
	while(count>0)
 
	{
 
		uint16 size;
 
		if ( (size = FioReadWord()) == 0)
 
			return;
 

	
 
		ReadSpriteHeaderSkipData(size, NUM_SPRITES-1);
 
		count--;
 
	}
 
}
 

	
 
// Checks, if trg1r.grf is the Windows version
 
static bool CheckGrfFile()
 
{
 
	byte check;
 
	FioSeekToFile(38); // Byte 38 has the value 0x21 in Windows version, 0x07 in DOS
 
	check = FioReadWord();
 
	FioSeekToFile(0);
 
	return (check==0x21);
 
}
 

	
 
static int LoadGrfFile(const char *filename, int load_index, int file_index)
 
{
 
	int load_index_org = load_index;
 

	
 
	FioOpenFile(file_index, filename);
 
	_cur_grffile = filename;
 
	_skip_specials = !strncmp(filename, "TRG", 3);
 

	
 
 	if(file_index==0 && !_ignore_wrong_grf)
 
 		if(!CheckGrfFile())
 
 			error("Wrong version of grf files!\nThe Windows 95 edition of Transport Tycoon Deluxe is required to play OTTD!\n(you can disable this message by starting with the \"-i\" switch.");
 

	
 
	while (LoadNextSprite(load_index, file_index)) {
 
		load_index++;
 
		if (load_index >= NUM_SPRITES) {
 
			error("Too many sprites. Recompile with higher NUM_SPRITES value or remove some custom GRF files.");
 
		}
 
	}
 

	
 
	_skip_sprites = 0; // clean up
 

	
 
	return load_index - load_index_org;
 
}
 

	
 
static void LoadGrfIndexed(const char *filename, const uint16 *index_tbl, int file_index)
 
{
 
	int start, end;
 
	int start;
 

	
 
	FioOpenFile(file_index, filename);
 

	
 
	for(;(start=*index_tbl++) != 0xffff;) {
 
		end = *index_tbl++;
 
		do {
 
			bool b = LoadNextSprite(start, file_index);
 
			assert(b);
 
		} while (++start <= end);
 
		int end = *index_tbl++;
 
		if(start==0xfffe) { // skip sprites (amount in second var)
 
			SkipSprites(end);
 
		} else { // load sprites and use indexes from start to end
 
			do {
 
				bool b = LoadNextSprite(start, file_index);
 
				assert(b);
 
			} while (++start <= end);
 
		}
 
	}
 
}	
 

	
 
typedef size_t CDECL fread_t(void*,size_t,size_t,FILE*);
 

	
 
static bool HandleCachedSpriteHeaders(const char *filename, bool read)
 
{
 
	FILE *f;
 
	fread_t *proc;
 
	uint32 hdr;
 

	
 
	if (!_cache_sprites)
 
		return false;
 

	
 
	if (read) {
 
		f = fopen(filename, "rb");
 
		proc = fread;
 

	
 
		if (f == NULL)
 
			return false;
 

	
 
		proc(&hdr, sizeof(hdr), 1, f);
 
		if (hdr != SPRITECACHE_ID) {
 
			fclose(f);
 
@@ -648,48 +672,50 @@ static const uint16 _openttd_grf_indexes
 
	634, 634, // nordic char: Ø
 
	SPR_OPENTTD_BASE+62, SPR_OPENTTD_BASE+70, // more icons
 
	0xffff,
 
};
 

	
 
static void LoadSpriteTables()
 
{
 
	int i,j;
 

	
 
	/* load initial sprites */
 
	if (!HandleCachedSpriteHeaders(_cached_filenames[_opt.landscape], true)) {
 
		
 
		int load_index = 0;
 
		for(i=0; _filename_list[i] != NULL; i++) {
 
			load_index += LoadGrfFile(_filename_list[i], load_index, (byte)i);
 
		}
 

	
 
		LoadGrfIndexed("openttd.grf", _openttd_grf_indexes, i++);
 

	
 
		{
 
			int l;
 
			if ((l=_sprite_page_to_load) != 0)
 
				LoadGrfIndexed(_landscape_filenames[l-1], _landscape_spriteindexes[l-1], i++); 
 
		}
 
		
 
		LoadGrfIndexed("trkfoundw.grf", _slopes_spriteindexes[_opt.landscape], i++);
 

	
 
		load_index = SPR_CANALS_BASE;
 
		load_index += LoadGrfFile("canalsw.grf", load_index, i++);
 
		/* XXX: Only for debugging. Will be more generic. */
 
		
 
		for(j=0; j!=lengthof(_newgrf_files) && _newgrf_files[j]; j++)
 
			load_index += LoadGrfFile(_newgrf_files[j], load_index, i++);
 

	
 
//		load_index += LoadGrfFile("arcticseto.grf", load_index, i++);
 
//		load_index += LoadGrfFile("tempsetpo.grf", load_index, i++);
 
//		load_index += LoadGrfFile("newshipso.grf", load_index, i++);
 
		//load_index += LoadGrfFile("brseto.grf", load_index, i++);
 

	
 
		HandleCachedSpriteHeaders(_cached_filenames[_opt.landscape], false);
 
	} else {
 
		for(i=0; _filename_list[i] != NULL; i++)
 
			FioOpenFile(i,_filename_list[i]); 
 
		
 
		FioOpenFile(i, "openttd.grf");
 
		FioOpenFile(i+1, "canalsw.grf");
 
		
 
		if (_sprite_page_to_load != 0)
 
			FioOpenFile(i+2, _landscape_filenames[_sprite_page_to_load-1]);
 
	}
table/landscape_sprite.h
Show inline comments
 
@@ -111,24 +111,52 @@ static const SpriteID _landscape_spritei
 
 0x2D0,  0x2D0,
 
 0xAA5,  0xAA6,
 
 0x50F,  0x50F,
 
 0x2EA,  0x2EA,
 
 0x2ED,  0x2EE,
 
 0x512,  0x513,
 
 0x4EB,  0x4EE,
 
 0x4E7,  0x4EA,
 
 0x985,  0xA28,
 
0x10E4, 0x1133,
 
 0x93D,  0x95C,
 
 0x97D,  0x984,
 
 0x7DA,  0x7DA,
 
 0x2E6,  0x2E6,
 
   0x1,    0x1,
 
 0xE54,  0xE54,
 
 0x51F,  0x520,
 
 0x514,  0x514,
 
 0x511,  0x511,
 
 0x322,  0x322,
 
 0xffff,
 
};
 

	
 

	
 
/* Slope graphics indexes temperate climate */
 
static const SpriteID _slopes_spriteindexes_0[] = {
 
 0xfffe,  3,
 
 SPR_SLOPES_BASE, SPR_SLOPES_BASE+73,
 
 0xffff,
 
};
 

	
 
/* Slope graphics indexes arctic climate */
 
static const SpriteID _slopes_spriteindexes_1[] = {
 
 0xfffe,  79,
 
 SPR_SLOPES_BASE, SPR_SLOPES_BASE+73,
 
 0xffff,
 
};
 

	
 
/* Slope graphics indexes tropical climate */
 
static const SpriteID _slopes_spriteindexes_2[] = {
 
 0xfffe,  155,
 
 SPR_SLOPES_BASE, SPR_SLOPES_BASE+73,
 
 0xffff,
 
};
 

	
 
/* Slope graphics indexes toyland climate */
 
static const SpriteID _slopes_spriteindexes_3[] = {
 
 0xfffe,  231,
 
 SPR_SLOPES_BASE, SPR_SLOPES_BASE+73,
 
 0xffff,
 
};
 

	
ttd.h
Show inline comments
 
@@ -447,50 +447,51 @@ enum SpecialStrings {
 

	
 
	SPECSTR_ANDCO_NAME = 0x70E6,
 
	SPECSTR_PRESIDENT_NAME = 0x70E7,
 
	SPECSTR_SONGNAME = 0x70E8,
 

	
 
	// reserve 32 strings for the *.lng files
 
	SPECSTR_LANGUAGE_START = 0x7100,
 
	SPECSTR_LANGUAGE_END = 0x711f,
 

	
 
	// reserve 32 strings for various screen resolutions
 
	SPECSTR_RESOLUTION_START = 0x7120,
 
	SPECSTR_RESOLUTION_END = 0x713f,
 

	
 
	// reserve 32 strings for screenshot formats
 
	SPECSTR_SCREENSHOT_START = 0x7140,
 
	SPECSTR_SCREENSHOT_END = 0x715F,
 

	
 
	STR_SPEC_SCREENSHOT_NAME = 0xF800,
 
	STR_SPEC_USERSTRING = 0xF801,
 
};
 

	
 
typedef void PlaceProc(uint tile);
 

	
 
enum Sprites {
 
	SPR_OPENTTD_BASE = 0x1406,
 
	SPR_CANALS_BASE = SPR_OPENTTD_BASE + 80,
 
	SPR_CANALS_BASE = 0x1406,
 
	SPR_SLOPES_BASE = SPR_CANALS_BASE + 70,
 
	SPR_OPENTTD_BASE = SPR_SLOPES_BASE + 74,
 
};
 

	
 
enum MAP_OWNERS {
 
	OWNER_TOWN			= 0xf, // a town owns the tile
 
	OWNER_NONE			= 0x10,// nobody owns the tile
 
	OWNER_WATER			= 0x11,// "water" owns the tile
 
	OWNER_SPECTATOR	= 0xff, // spectator in MP or in scenario editor
 
};
 

	
 
VARDEF bool _savegame_sort_dirty;
 
VARDEF byte _savegame_sort_order;
 

	
 
#define INVALID_UINT_TILE (uint)0xFFFFFFFF
 
#define INVALID_STRING_ID 0xFFFF
 

	
 
enum {
 
	MAX_SCREEN_WIDTH = 2048,
 
	MAX_SCREEN_HEIGHT = 1200,
 
};
 

	
 
#include "functions.h"
 
#include "variables.h"
 

	
 
#endif /* TTD_H */
0 comments (0 inline, 0 general)