# newgrf_config.h

Go to the documentation of this file.

    00001 /* $Id: newgrf_config.h 20576 2010-08-20 10:31:20Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef NEWGRF_CONFIG_H
    00013 #define NEWGRF_CONFIG_H
    00014
    00015 #include "strings_type.h"
    00016 #include "core/alloc_type.hpp"
    00017
    00019 enum GCF_Flags {
    00020   GCF_SYSTEM,
    00021   GCF_UNSAFE,
    00022   GCF_STATIC,
    00023   GCF_COMPATIBLE,
    00024   GCF_COPY,
    00025   GCF_INIT_ONLY,
    00026   GCF_RESERVED,
    00027
    00028 };
    00029
    00031 enum GRFStatus {
    00032   GCS_UNKNOWN,
    00033   GCS_DISABLED,
    00034   GCS_NOT_FOUND,
    00035   GCS_INITIALISED,
    00036   GCS_ACTIVATED
    00037 };
    00038
    00040 enum GRFBugs {
    00041   GBUG_VEH_LENGTH,
    00042   GBUG_VEH_REFIT,
    00043   GBUG_VEH_POWERED_WAGON,
    00044 };
    00045
    00047 enum GRFListCompatibility {
    00048   GLC_ALL_GOOD,
    00049   GLC_COMPATIBLE,
    00050   GLC_NOT_FOUND
    00051 };
    00052
    00054 struct GRFIdentifier {
    00055   uint32 grfid;
    00056   uint8 md5sum[16];
    00057 };
    00058
    00060 struct GRFError : ZeroedMemoryAllocator {
    00061   GRFError(StringID severity, StringID message = 0);
    00062   ~GRFError();
    00063
    00064   char *custom_message;
    00065   char *data;
    00066   StringID message;
    00067   StringID severity;
    00068   uint8 num_params;
    00069   uint32 param_value[2];
    00070 };
    00071
    00073 struct GRFConfig : public GRFIdentifier {
    00074   char *filename;
    00075   char *name;
    00076   char *info;
    00077   GRFError *error;
    00078
    00079   uint8 flags;
    00080   GRFStatus status;
    00081   uint32 grf_bugs;
    00082   uint32 param[0x80];
    00083   uint8 num_params;
    00084   bool windows_paletted;
    00085
    00086   struct GRFConfig *next;
    00087
    00088   bool IsOpenTTDBaseGRF() const;
    00089 };
    00090
    00091 extern GRFConfig *_all_grfs;
    00092 extern GRFConfig *_grfconfig;
    00093 extern GRFConfig *_grfconfig_newgame;
    00094 extern GRFConfig *_grfconfig_static;
    00095
    00096 void ScanNewGRFFiles();
    00097 void CheckForMissingSprites();
    00098 const GRFConfig *FindGRFConfig(uint32 grfid, const uint8 *md5sum = NULL);
    00099 GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF);
    00100 GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
    00101 void AppendStaticGRFConfigs(GRFConfig **dst);
    00102 void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
    00103 void ClearGRFConfig(GRFConfig **config);
    00104 void ClearGRFConfigList(GRFConfig **config);
    00105 void ResetGRFConfig(bool defaults);
    00106 GRFListCompatibility IsGoodGRFConfigList();
    00107 bool FillGRFDetails(GRFConfig *config, bool is_static);
    00108 char *GRFBuildParamList(char *dst, const GRFConfig *c, const char *last);
    00109 GRFConfig *DuplicateGRFConfig(const GRFConfig *c);
    00110
    00111 /* In newgrf_gui.cpp */
    00112 void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config);
    00113
    00114 #ifdef ENABLE_NETWORK
    00115 /* For communication about GRFs over the network */
    00116 #define UNKNOWN_GRF_NAME_PLACEHOLDER "<Unknown>"
    00117 char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create);
    00118 #endif /* ENABLE_NETWORK */
    00119
    00120 #endif /* NEWGRF_CONFIG_H */