14 #include "3rdparty/md5/md5.h" 
   53   if (filename != NULL) this->filename = 
stredup(filename);
 
   69   version(config.version),
 
   70   min_loadable_version(config.min_loadable_version),
 
   71   flags(config.flags & ~(1 << 
GCF_COPY)),
 
   72   status(config.status),
 
   73   grf_bugs(config.grf_bugs),
 
   74   num_params(config.num_params),
 
   75   num_valid_params(config.num_valid_params),
 
   76   palette(config.palette),
 
   77   has_param_defaults(config.has_param_defaults)
 
  103   this->
name->Release();
 
  104   this->
info->Release();
 
  105   this->
url->Release();
 
  186     if (*
info == NULL) 
continue;
 
  213   custom_message(error.custom_message),
 
  215   message(error.message),
 
  216   severity(error.severity)
 
  223 GRFError::~GRFError()
 
  238   max_value(UINT32_MAX),
 
  243   complete_labels(false)
 
  255   min_value(info.min_value),
 
  256   max_value(info.max_value),
 
  257   def_value(info.def_value),
 
  258   param_nr(info.param_nr),
 
  259   first_bit(info.first_bit),
 
  260   num_bit(info.num_bit),
 
  261   complete_labels(info.complete_labels)
 
  289   return GB(config->
param[this->param_nr], this->first_bit, this->num_bit);
 
  303     SB(config->
param[this->param_nr], this->first_bit, this->num_bit, value);
 
  331   for (
GRFConfig *c = _grfconfig_newgame; c != NULL; c = c->
next) c->SetSuitablePalette();
 
  332   for (
GRFConfig *c = _grfconfig_static;  c != NULL; c = c->
next) c->SetSuitablePalette();
 
  333   for (
GRFConfig *c = _all_grfs;          c != NULL; c = c->
next) c->SetSuitablePalette();
 
  345   static const uint header_len = 14;
 
  347   byte data[header_len];
 
  348   if (fread(data, 1, header_len, f) == header_len) {
 
  349     if (data[0] == 0 && data[1] == 0 && 
MemCmpT(data + 2, _grf_cont_v2_sig, 8) == 0) {
 
  351       size_t offset = ((size_t)data[13] << 24) | ((size_t)data[12] << 16) | ((size_t)data[11] << 8) | (size_t)data[10];
 
  352       if (offset >= 1 * 1024 * 1024 * 1024) {
 
  353         DEBUG(grf, 0, 
"Unexpectedly large offset for NewGRF");
 
  359       return header_len + offset;
 
  381   if (f == NULL) 
return false;
 
  383   long start = ftell(f);
 
  386   if (start < 0 || fseek(f, start, SEEK_SET) < 0) {
 
  392   while ((len = fread(buffer, 1, (size > 
sizeof(buffer)) ? 
sizeof(buffer) : size, f)) != 0 && size != 0) {
 
  394     checksum.Append(buffer, len);
 
  446   for (c = *config; c != NULL; c = next) {
 
  465   for (; src != NULL; src = src->
next) {
 
  496   if (list == NULL) 
return;
 
  498   for (prev = list, cur = list->
next; cur != NULL; prev = cur, cur = cur->
next) {
 
  516   while (*tail != NULL) tail = &(*tail)->
next;
 
  530   while (*tail != NULL) tail = &(*tail)->
next;
 
  570         DEBUG(grf, 1, 
"NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", 
BSWAP32(c->ident.grfid), c->filename, buf);
 
  574           memcpy(c->original_md5sum, c->ident.md5sum, 
sizeof(c->original_md5sum));
 
  584       DEBUG(grf, 0, 
"NewGRF %08X (%s) not found; checksum %s", 
BSWAP32(c->ident.grfid), c->filename, buf);
 
  599         memcpy(c->ident.md5sum, f->
ident.
md5sum, 
sizeof(c->ident.md5sum));
 
  613             *c->param_info.Append() = NULL;
 
  635    bool AddFile(
const char *filename, 
size_t basepath_length, 
const char *tar_filename);
 
  649 bool GRFFileScanner::AddFile(
const char *filename, 
size_t basepath_length, 
const char *tar_filename)
 
  655     if (_all_grfs == NULL) {
 
  662       for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->
next) {
 
  687     const char *name = NULL;
 
  689     if (name == NULL) name = c->
filename;
 
  732   DEBUG(grf, 1, 
"Scanning for NewGRFs");
 
  735   DEBUG(grf, 1, 
"Scan complete, found %d files", num);
 
  736   if (num != 0 && _all_grfs != NULL) {
 
  740     GRFConfig **to_sort = MallocT<GRFConfig*>(num);
 
  743     for (
GRFConfig *p = _all_grfs; p != NULL; p = p->
next, i++) {
 
  751     for (i = 1; i < num; i++) {
 
  752       to_sort[i - 1]->
next = to_sort[i];
 
  754     to_sort[num - 1]->
next = NULL;
 
  755     _all_grfs = to_sort[0];
 
  759 #ifdef ENABLE_NETWORK 
  810   assert((mode == 
FGCM_EXACT) != (md5sum == NULL));
 
  812   for (
const GRFConfig *c = _all_grfs; c != NULL; c = c->
next) {
 
  816     if (md5sum != NULL || mode == 
FGCM_ANY) 
return c;
 
  828 #ifdef ENABLE_NETWORK 
  858   for (grf = unknown_grfs; grf != NULL; grf = grf->
next) {
 
  859     if (grf->
grfid == grfid) {
 
  860       if (memcmp(md5sum, grf->
md5sum, 
sizeof(grf->
md5sum)) == 0) 
return grf->
name;
 
  864   if (!create) 
return NULL;
 
  866   grf = CallocT<UnknownGRF>(1);
 
  868   grf->
next  = unknown_grfs;
 
  892   for (c = _grfconfig; c != NULL; c = c->
next) {
 
  893     if ((c->
ident.
grfid & mask) == (grfid & mask)) 
return c;
 
  909     if (i > 0) dst = 
strecpy(dst, 
" ", last);