newgrf_config.cpp File Reference

#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "variables.h"
#include "saveload.h"
#include "md5.h"
#include "network/network_data.h"
#include "newgrf.h"
#include "newgrf_config.h"
#include "core/alloc_func.hpp"
#include "string_func.h"
#include "fileio.h"
#include "fios.h"
#include <sys/stat.h>

Go to the source code of this file.

Functions

static bool CalcGRFMD5Sum (GRFConfig *config)
bool FillGRFDetails (GRFConfig *config, bool is_static)
void ClearGRFConfig (GRFConfig **config)
void ClearGRFConfigList (GRFConfig **config)
GRFConfig ** CopyGRFConfigList (GRFConfig **dst, const GRFConfig *src, bool init_only)
 Copy a GRF Config list.
static void RemoveDuplicatesFromGRFConfigList (GRFConfig *list)
 Removes duplicates from lists of GRFConfigs.
void AppendStaticGRFConfigs (GRFConfig **dst)
 Appends the static GRFs to a list of GRFs.
void AppendToGRFConfigList (GRFConfig **dst, GRFConfig *el)
 Appends an element to a list of GRFs.
void ResetGRFConfig (bool defaults)
GRFListCompatibility IsGoodGRFConfigList ()
 Check if all GRFs in the GRF config from a savegame can be loaded.
static bool ScanPathAddGrf (const char *filename)
static uint ScanPath (const char *path, int basepath_length)
static uint ScanTar (TarFileList::iterator tar)
static int CDECL GRFSorter (const void *p1, const void *p2)
 Simple sorter for GRFS.
void ScanNewGRFFiles ()
const GRFConfig * FindGRFConfig (uint32 grfid, const uint8 *md5sum)
GRFConfig * GetGRFConfig (uint32 grfid)
char * GRFBuildParamList (char *dst, const GRFConfig *c, const char *last)
static void Save_NGRF ()
static void Load_NGRF ()

Variables

GRFConfig * _all_grfs
GRFConfig * _grfconfig
GRFConfig * _grfconfig_newgame
GRFConfig * _grfconfig_static
static const uint32 OPENTTD_GRAPHICS_BASE_GRF_ID = BSWAP32(0xFF4F5400)
 Base GRF ID for OpenTTD's base graphics GRFs.
static const SaveLoad _grfconfig_desc []
const ChunkHandler _newgrf_chunk_handlers []


Detailed Description

Definition in file newgrf_config.cpp.


Function Documentation

void AppendStaticGRFConfigs ( GRFConfig **  dst  ) 

Appends the static GRFs to a list of GRFs.

Parameters:
dst the head of the list to add to

Definition at line 181 of file newgrf_config.cpp.

References CopyGRFConfigList(), and RemoveDuplicatesFromGRFConfigList().

void AppendToGRFConfigList ( GRFConfig **  dst,
GRFConfig *  el 
)

Appends an element to a list of GRFs.

Parameters:
dst the head of the list to add to
el the new tail to be

Definition at line 193 of file newgrf_config.cpp.

References RemoveDuplicatesFromGRFConfigList().

GRFConfig** CopyGRFConfigList ( GRFConfig **  dst,
const GRFConfig *  src,
bool  init_only 
)

Copy a GRF Config list.

Parameters:
dst pointer to destination list
src pointer to source list values
init_only the copied GRF will be processed up to GLS_INIT
Returns:
pointer to the last value added to the destination list

Definition at line 119 of file newgrf_config.cpp.

References ClrBit(), GCF_INIT_ONLY, and SetBit().

Referenced by AppendStaticGRFConfigs(), NewGRFConfirmationCallback(), and ShowNewGRFSettings().

static int CDECL GRFSorter ( const void *  p1,
const void *  p2 
) [static]

Simple sorter for GRFS.

Parameters:
p1 the first GRFConfig *
p2 the second GRFConfig *
Returns:
the same strcmp would return for the name of the NewGRF.

Definition at line 378 of file newgrf_config.cpp.

GRFListCompatibility IsGoodGRFConfigList (  ) 

Check if all GRFs in the GRF config from a savegame can be loaded.

Returns:
will return any of the following 3 values:
  • GLC_ALL_GOOD: No problems occured, all GRF files were found and loaded
  • GLC_COMPATIBLE: For one or more GRF's no exact match was found, but a compatible GRF with the same grfid was found and used instead
  • GLC_NOT_FOUND: For one or more GRF's no match was found at all

Definition at line 219 of file newgrf_config.cpp.

References BSWAP32(), buf, GCF_COMPATIBLE, GCF_COPY, GCS_NOT_FOUND, HasBit(), md5sumToString(), and SetBit().

static void RemoveDuplicatesFromGRFConfigList ( GRFConfig *  list  )  [static]

Removes duplicates from lists of GRFConfigs.

These duplicates are introduced when the _grfconfig_static GRFs are appended to the _grfconfig on a newgame or savegame. As the parameters of the static GRFs could be different that the parameters of the ones used non-statically. This can result in desyncs in multiplayers, so the duplicate static GRFs have to be removed.

This function _assumes_ that all static GRFs are placed after the non-static GRFs.

Parameters:
list the list to remove the duplicates from

Definition at line 159 of file newgrf_config.cpp.

Referenced by AppendStaticGRFConfigs(), and AppendToGRFConfigList().


Variable Documentation

const SaveLoad _grfconfig_desc[] [static]

Initial value:

 {
  SLE_STR(GRFConfig, filename,   SLE_STR, 0x40),
  SLE_VAR(GRFConfig, grfid,      SLE_UINT32),
  SLE_ARR(GRFConfig, md5sum,     SLE_UINT8, 16),
  SLE_ARR(GRFConfig, param,      SLE_UINT32, 0x80),
  SLE_VAR(GRFConfig, num_params, SLE_UINT8),

}

Definition at line 539 of file newgrf_config.cpp.

const ChunkHandler _newgrf_chunk_handlers[]

Initial value:

 {
  { 'NGRF', Save_NGRF, Load_NGRF, CH_ARRAY | CH_LAST }
}

const uint32 OPENTTD_GRAPHICS_BASE_GRF_ID = BSWAP32(0xFF4F5400) [static]

Base GRF ID for OpenTTD's base graphics GRFs.

Definition at line 527 of file newgrf_config.cpp.


Generated on Mon Sep 22 20:34:23 2008 for openttd by  doxygen 1.5.6