src/newgrf.h
author celestar
Tue, 19 Jun 2007 07:21:01 +0000
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
permissions -rw-r--r--
(svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 1477
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 1477
diff changeset
     2
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9896
diff changeset
     3
/** @file newgrf.h */
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9896
diff changeset
     4
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
     5
#ifndef NEWGRF_H
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
     6
#define NEWGRF_H
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
     7
463
91bcad840bcd (svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents: 455
diff changeset
     8
#include "station.h"
9896
2473804114de (svn r9324) [gamebalance] -Sync: r9314:9322 from trunk (newhouses)
celestar
parents: 9895
diff changeset
     9
#include "town.h"
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5225
diff changeset
    10
#include "newgrf_config.h"
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    11
#include "helpers.hpp"
6469
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5838
diff changeset
    12
#include "cargotype.h"
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    13
#include "industry.h"
463
91bcad840bcd (svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents: 455
diff changeset
    14
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    15
enum GrfLoadingStage {
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5225
diff changeset
    16
	GLS_FILESCAN,
5329
2b117d8652f0 (svn r7490) -Feature: Load a list of NewGRFs from the config (in the [newgrf-static] section) that should always be loaded. These will also be active during the intro screen, and in multiplayer games. Only "network-safe" NewGRFs are permitted, such as fonts and sprite replacement sets.
peter1138
parents: 5234
diff changeset
    17
	GLS_SAFETYSCAN,
5225
52ddcedcc6f7 (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    18
	GLS_LABELSCAN,
52ddcedcc6f7 (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    19
	GLS_INIT,
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9896
diff changeset
    20
	GLS_RESERVE,
5225
52ddcedcc6f7 (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    21
	GLS_ACTIVATION,
52ddcedcc6f7 (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    22
	GLS_END,
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    23
};
5225
52ddcedcc6f7 (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    24
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    25
DECLARE_POSTFIX_INCREMENT(GrfLoadingStage);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    26
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    27
enum GrfMiscBit {
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    28
	GMB_DESERT_TREES_FIELDS    = 0, // Unsupported.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    29
	GMB_DESERT_PAVED_ROADS     = 1,
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    30
	GMB_FIELD_BOUNDING_BOX     = 2, // Unsupported.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    31
	GMB_TRAIN_WIDTH_32_PIXELS  = 3,
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    32
	GMB_AMBIENT_SOUND_CALLBACK = 4, // Unsupported.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    33
	GMB_CATENARY_ON_3RD_TRACK  = 5, // Unsupported.
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
    34
};
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
    35
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    36
struct GRFLabel {
3561
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    37
	byte label;
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    38
	uint32 nfo_line;
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    39
	uint32 pos;
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    40
	struct GRFLabel *next;
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    41
};
3561
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    42
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    43
struct GRFFile {
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    44
	char *filename;
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    45
	uint32 grfid;
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    46
	uint16 sprite_offset;
3640
b73687dd2b62 (svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents: 3638
diff changeset
    47
	byte grf_version;
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    48
	GRFFile *next;
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    49
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    50
	/* A sprite group contains all sprites of a given vehicle (or multiple
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    51
	 * vehicles) when carrying given cargo. It consists of several sprite
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    52
	 * sets.  Group ids are refered as "cargo id"s by TTDPatch
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    53
	 * documentation, contributing to the global confusion.
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    54
	 *
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    55
	 * A sprite set contains all sprites of a given vehicle carrying given
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    56
	 * cargo at a given *stage* - that is usually its load stage. Ie. you
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    57
	 * can have a spriteset for an empty wagon, wagon full of coal,
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    58
	 * half-filled wagon etc.  Each spriteset contains eight sprites (one
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    59
	 * per direction) or four sprites if the vehicle is symmetric. */
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    60
3707
2999a89e8abd (svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents: 3640
diff changeset
    61
	SpriteID spriteset_start;
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    62
	int spriteset_numsets;
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    63
	int spriteset_numents;
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    64
	int spriteset_feature;
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    65
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    66
	int spritegroups_count;
3865
a0bf688e6f85 (svn r4901) - Codechange: change 'SpriteGroup *' to 'struct SpriteGroup *' within StationSpec and GRFFile struct declarations. Now only code which actually references those pointers needs to know about the SpriteGroup struct. Remove some unnecessary lingering header dependencies.
peter1138
parents: 3775
diff changeset
    67
	struct SpriteGroup **spritegroups;
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    68
4656
acffecd6f484 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 3865
diff changeset
    69
	uint sound_offset;
acffecd6f484 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 3865
diff changeset
    70
3768
46d328178509 (svn r4760) - Newstations: change the way custom stations are allocated when loading from GRF, as the current way was flawed (reallocing memory which is referenced elsewhere)
peter1138
parents: 3707
diff changeset
    71
	StationSpec **stations;
9896
2473804114de (svn r9324) [gamebalance] -Sync: r9314:9322 from trunk (newhouses)
celestar
parents: 9895
diff changeset
    72
	HouseSpec **housespec;
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    73
	IndustrySpec **industryspec;
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    74
	IndustryTileSpec **indtspec;
2345
8a14ff5d4851 (svn r2871) -Feature/Fix: Per GRF parameter lists
tron
parents: 2342
diff changeset
    75
8a14ff5d4851 (svn r2871) -Feature/Fix: Per GRF parameter lists
tron
parents: 2342
diff changeset
    76
	uint32 param[0x80];
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9896
diff changeset
    77
	uint param_end;  ///< one more than the highest set parameter
3561
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    78
29c95ab685c0 (svn r4439) - NewGRF: Add support for Action 0x10. This also required an extra pre-stage (before initialize and activation) to scan the GRF file for GOTO labels. Big thanks for peter1138 for the guidance and answers, as well as parts of the code.
Darkvater
parents: 3501
diff changeset
    79
	GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array.
6469
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5838
diff changeset
    80
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5838
diff changeset
    81
	uint8 cargo_max;
05a2e97144ec (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5838
diff changeset
    82
	CargoLabel *cargo_list;
6473
03480a0f016e (svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents: 6469
diff changeset
    83
	uint8 cargo_map[NUM_CARGO];
9895
7bd07f43b0e3 (svn r9321) [gamebalance] -Sync: r9025:9314 from trunk
celestar
parents: 6473
diff changeset
    84
};
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    85
1477
2174a73b11c9 (svn r1981) Typedef some structs and enums
tron
parents: 463
diff changeset
    86
extern GRFFile *_first_grffile;
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    87
3638
6e0b43d905d4 (svn r4546) - NewGRF: add support for Action 0x05, type 0x04: replacement signal graphics. Thanks to Purno for supplying data to test
peter1138
parents: 3628
diff changeset
    88
extern SpriteID _signal_base;
5210
dc52acfad05c (svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents: 4742
diff changeset
    89
extern SpriteID _coast_base;
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    90
9913
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
    91
struct GRFLoadedFeatures {
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
    92
	bool has_2CC;             ///< Set if any vehicle is loaded which uses 2cc (two company colours).
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
    93
	bool has_newhouses;       ///< Set if there are any newhouses loaded.
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
    94
	bool has_newindustries;   ///< Set if there are any newindustries loaded.
9912
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    95
};
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    96
1ac8aac92385 (svn r10136) [gamebalance] -Sync: r9900:10100 from trunk
celestar
parents: 9911
diff changeset
    97
/* Indicates which are the newgrf features currently loaded ingame */
9913
e79cd19772dd (svn r10213) [gamebalance] -Sync: r10100:10200 from trunk
celestar
parents: 9912
diff changeset
    98
extern GRFLoadedFeatures _loaded_newgrf_features;
463
91bcad840bcd (svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents: 455
diff changeset
    99
5228
c4a780348f66 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5225
diff changeset
   100
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage);
2342
c19fb4f2df30 (svn r2868) Change the way NewGRFs are loaded: The loading process i no longer bolted onto the normal graphics loading.
tron
parents: 2186
diff changeset
   101
void LoadNewGRF(uint load_index, uint file_index);
9906
6f41b8713b65 (svn r9674) [gamebalance] -Sync: r9322:9420 from trunk
celestar
parents: 9896
diff changeset
   102
void ReloadNewGRFData(); // in openttd.cpp
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
   103
5568
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5352
diff changeset
   104
void CDECL grfmsg(int severity, const char *str, ...);
75f13d7bfaed (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5352
diff changeset
   105
9911
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
   106
bool HasGrfMiscBit(GrfMiscBit bit);
0b8b245a2391 (svn r10135) [gamebalance] -Sync: r9700:9900 from trunk
celestar
parents: 9906
diff changeset
   107
455
e7ac799e1437 (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
   108
#endif /* NEWGRF_H */