Files
@ r19448:41de09e68222
Branch filter:
Location: cpp/openttd-patchpack/source/src/newgrf_cargo.cpp - annotation
r19448:41de09e68222
3.7 KiB
text/x-c
(svn r24365) -Fix-ish: add C(XX)FLAGS_BUILD to all the executables that are compiled for the build enviroment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | r6365:410001496130 r6365:410001496130 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r9111:983de9c5a848 r6365:410001496130 r6383:09891b2cc6e4 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r18292:67d22b89b6c6 r6365:410001496130 r16464:ae3f342df07b r6383:09891b2cc6e4 r6365:410001496130 r11163:407814b6138f r6365:410001496130 r6365:410001496130 r6365:410001496130 r11985:d8202dea2203 r6365:410001496130 r6657:0c1322cba91d r6657:0c1322cba91d r11985:d8202dea2203 r11985:d8202dea2203 r6365:410001496130 r6657:0c1322cba91d r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r7327:28855024ff6c r6365:410001496130 r6365:410001496130 r17833:6e30fcc94ba8 r17833:6e30fcc94ba8 r9750:1e2535e15958 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r11991:9a2b087e564c r11985:d8202dea2203 r6365:410001496130 r11985:d8202dea2203 r6365:410001496130 r6365:410001496130 r6365:410001496130 r7327:28855024ff6c r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r6365:410001496130 r11991:9a2b087e564c r11985:d8202dea2203 r6365:410001496130 r11985:d8202dea2203 r6365:410001496130 r6460:74b53af67ae0 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r19046:7fa5045a9a14 r7717:a88200b1847a r6460:74b53af67ae0 r19049:47de46c9ad63 r19049:47de46c9ad63 r19049:47de46c9ad63 r19049:47de46c9ad63 r19049:47de46c9ad63 r19362:44a1cca54def r19049:47de46c9ad63 r19049:47de46c9ad63 r19362:44a1cca54def r19049:47de46c9ad63 r7717:a88200b1847a r19046:7fa5045a9a14 r7717:a88200b1847a r7717:a88200b1847a r6460:74b53af67ae0 | /* $Id$ */
/*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/** @file newgrf_cargo.cpp Implementation of NewGRF cargoes. */
#include "stdafx.h"
#include "debug.h"
#include "newgrf_spritegroup.h"
static uint32 CargoGetRandomBits(const ResolverObject *object)
{
return 0;
}
static uint32 CargoGetTriggers(const ResolverObject *object)
{
return 0;
}
static void CargoSetTriggers(const ResolverObject *object, int triggers)
{
return;
}
static uint32 CargoGetVariable(const ResolverObject *object, byte variable, uint32 parameter, bool *available)
{
DEBUG(grf, 1, "Unhandled cargo variable 0x%X", variable);
*available = false;
return UINT_MAX;
}
static const SpriteGroup *CargoResolveReal(const ResolverObject *object, const RealSpriteGroup *group)
{
/* Cargo action 2s should always have only 1 "loaded" state, but some
* times things don't follow the spec... */
if (group->num_loaded > 0) return group->loaded[0];
if (group->num_loading > 0) return group->loading[0];
return NULL;
}
static void NewCargoResolver(ResolverObject *res, const CargoSpec *cs)
{
res->GetRandomBits = &CargoGetRandomBits;
res->GetTriggers = &CargoGetTriggers;
res->SetTriggers = &CargoSetTriggers;
res->GetVariable = &CargoGetVariable;
res->ResolveReal = &CargoResolveReal;
res->u.cargo.cs = cs;
res->callback = CBID_NO_CALLBACK;
res->callback_param1 = 0;
res->callback_param2 = 0;
res->ResetState();
res->grffile = cs->grffile;
}
SpriteID GetCustomCargoSprite(const CargoSpec *cs)
{
const SpriteGroup *group;
ResolverObject object;
NewCargoResolver(&object, cs);
group = SpriteGroup::Resolve(cs->group, &object);
if (group == NULL) return 0;
return group->GetResult();
}
uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs)
{
ResolverObject object;
const SpriteGroup *group;
NewCargoResolver(&object, cs);
object.callback = callback;
object.callback_param1 = param1;
object.callback_param2 = param2;
group = SpriteGroup::Resolve(cs->group, &object);
if (group == NULL) return CALLBACK_FAILED;
return group->GetCallbackResult();
}
/**
* Translate a GRF-local cargo slot/bitnum into a CargoID.
* @param cargo GRF-local cargo slot/bitnum.
* @param grffile Originating GRF file.
* @param usebit Defines the meaning of \a cargo for GRF version < 7.
* If true, then \a cargo is a bitnum. If false, then \a cargo is a cargoslot.
* For GRF version >= 7 \a cargo is always a translated cargo bit.
* @return CargoID or CT_INVALID if the cargo is not available.
*/
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
{
/* Pre-version 7 uses the 'climate dependent' ID in callbacks and properties, i.e. cargo is the cargo ID */
if (grffile->grf_version < 7 && !usebit) return cargo;
/* Other cases use (possibly translated) cargobits */
if (grffile->cargo_list.Length() > 0) {
/* ...and the cargo is in bounds, then get the cargo ID for
* the label */
if (cargo < grffile->cargo_list.Length()) return GetCargoIDByLabel(grffile->cargo_list[cargo]);
} else {
/* Else the cargo value is a 'climate independent' 'bitnum' */
return GetCargoIDByBitnum(cargo);
}
return CT_INVALID;
}
|