src/newgrf.h
author belugas
Wed, 04 Apr 2007 01:35:16 +0000
changeset 6420 456c275f3313
parent 6359 8527262c4cf8
child 6541 dfa5165a5ab7
permissions -rw-r--r--
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1477
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1477
diff changeset
     2
6348
6dd01da7a02b (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6332
diff changeset
     3
/** @file newgrf.h */
6dd01da7a02b (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6332
diff changeset
     4
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
     5
#ifndef NEWGRF_H
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
     6
#define NEWGRF_H
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
     7
463
97ec66c280f2 (svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents: 455
diff changeset
     8
#include "station.h"
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6248
diff changeset
     9
#include "town.h"
5228
26dc9acf7d94 (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"
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    11
#include "helpers.hpp"
6143
dbca54e64e01 (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5587
diff changeset
    12
#include "cargotype.h"
463
97ec66c280f2 (svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents: 455
diff changeset
    13
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    14
enum GrfLoadingStage {
5228
26dc9acf7d94 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5225
diff changeset
    15
	GLS_FILESCAN,
5329
9c5e8061ea0f (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
    16
	GLS_SAFETYSCAN,
5225
af5d9de16c8d (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    17
	GLS_LABELSCAN,
af5d9de16c8d (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    18
	GLS_INIT,
6359
8527262c4cf8 (svn r9411) -Codechange: Add support for loading of newcargo data.
peter1138
parents: 6348
diff changeset
    19
	GLS_RESERVE,
5225
af5d9de16c8d (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    20
	GLS_ACTIVATION,
af5d9de16c8d (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    21
	GLS_END,
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    22
};
5225
af5d9de16c8d (svn r7345) -Codechange: enumification of NewGRF loading stage, and move enum definition to header for future use.
peter1138
parents: 5210
diff changeset
    23
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    24
DECLARE_POSTFIX_INCREMENT(GrfLoadingStage);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    25
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    26
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    27
struct GRFLabel {
3561
2f67415d44aa (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
    28
	byte label;
2f67415d44aa (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
    29
	uint32 nfo_line;
2f67415d44aa (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
    30
	uint32 pos;
2f67415d44aa (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
    31
	struct GRFLabel *next;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    32
};
3561
2f67415d44aa (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
    33
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    34
struct GRFFile {
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    35
	char *filename;
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    36
	uint32 grfid;
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    37
	uint16 sprite_offset;
3640
afe6a5032f6a (svn r4549) - NewGRF: store the grf version from Action 0x08.
peter1138
parents: 3638
diff changeset
    38
	byte grf_version;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    39
	GRFFile *next;
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    40
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    41
	/* A sprite group contains all sprites of a given vehicle (or multiple
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    42
	 * vehicles) when carrying given cargo. It consists of several sprite
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    43
	 * sets.  Group ids are refered as "cargo id"s by TTDPatch
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    44
	 * documentation, contributing to the global confusion.
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    45
	 *
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    46
	 * A sprite set contains all sprites of a given vehicle carrying given
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    47
	 * cargo at a given *stage* - that is usually its load stage. Ie. you
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    48
	 * can have a spriteset for an empty wagon, wagon full of coal,
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    49
	 * half-filled wagon etc.  Each spriteset contains eight sprites (one
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    50
	 * per direction) or four sprites if the vehicle is symmetric. */
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    51
3707
7dc7e4d2487e (svn r4650) - NewGRF: use the correct type for _cur_spriteid
peter1138
parents: 3640
diff changeset
    52
	SpriteID spriteset_start;
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    53
	int spriteset_numsets;
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    54
	int spriteset_numents;
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    55
	int spriteset_feature;
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    56
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    57
	int spritegroups_count;
3865
b80b50f14fcd (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
    58
	struct SpriteGroup **spritegroups;
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    59
4656
9c1d8c4d3e60 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 3865
diff changeset
    60
	uint sound_offset;
9c1d8c4d3e60 (svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents: 3865
diff changeset
    61
3768
5194cf3c57b1 (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
    62
	StationSpec **stations;
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6248
diff changeset
    63
	HouseSpec **housespec;
2345
f7251bd99942 (svn r2871) -Feature/Fix: Per GRF parameter lists
tron
parents: 2342
diff changeset
    64
f7251bd99942 (svn r2871) -Feature/Fix: Per GRF parameter lists
tron
parents: 2342
diff changeset
    65
	uint32 param[0x80];
6348
6dd01da7a02b (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6332
diff changeset
    66
	uint param_end;  ///< one more than the highest set parameter
3561
2f67415d44aa (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
    67
2f67415d44aa (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
    68
	GRFLabel *label; ///< Pointer to the first label. This is a linked list, not an array.
6143
dbca54e64e01 (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5587
diff changeset
    69
dbca54e64e01 (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5587
diff changeset
    70
	uint8 cargo_max;
dbca54e64e01 (svn r8886) -Codechange: (NewGRF) Add (partial) cargo translation table support, applied to action 3s only.
peter1138
parents: 5587
diff changeset
    71
	CargoLabel *cargo_list;
6147
ee050ca3889f (svn r8890) -Codechange: (NewGRF) add cargo translation support to engine var 47
peter1138
parents: 6143
diff changeset
    72
	uint8 cargo_map[NUM_CARGO];
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    73
};
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    74
1477
9389baf2bf3c (svn r1981) Typedef some structs and enums
tron
parents: 463
diff changeset
    75
extern GRFFile *_first_grffile;
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    76
3638
3e655c6e0914 (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
    77
extern SpriteID _signal_base;
5210
3415ef43c70a (svn r7325) -Feature: Add support for action 5 type 0x0D, coast sprites.
peter1138
parents: 4742
diff changeset
    78
extern SpriteID _coast_base;
4742
d915db693186 (svn r6654) - Codechange: If no 2cc vehicles are available, hide the secondary colour choice.
peter1138
parents: 4656
diff changeset
    79
extern bool _have_2cc;
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6248
diff changeset
    80
extern bool _have_newhouses;
463
97ec66c280f2 (svn r687) Export InitNewGRFFile() and DecodeSpecialSprite() properly.
pasky
parents: 455
diff changeset
    81
5228
26dc9acf7d94 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5225
diff changeset
    82
void LoadNewGRFFile(GRFConfig *config, uint file_index, GrfLoadingStage stage);
2342
aae24c9661ba (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
    83
void LoadNewGRF(uint load_index, uint file_index);
6348
6dd01da7a02b (svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents: 6332
diff changeset
    84
void ReloadNewGRFData(); // in openttd.cpp
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    85
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5352
diff changeset
    86
void CDECL grfmsg(int severity, const char *str, ...);
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5352
diff changeset
    87
455
b151d55203bf (svn r665) code fixes for newgrf.c/newgrf.h
dominik
parents: 453
diff changeset
    88
#endif /* NEWGRF_H */