summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-05-10 21:55:44 +0000
committerpeter1138 <peter1138@openttd.org>2006-05-10 21:55:44 +0000
commit5ebd8be2d638b580e6d6cc51615dc9f6629d88d8 (patch)
treed690aa3cd890bb86ad7abb4ca73e433b95a5e38a
parentf513850371e04a81341db31be0e7680693be8588 (diff)
downloadopenttd-5ebd8be2d638b580e6d6cc51615dc9f6629d88d8.tar.xz
(svn r4818) - NewGRF: add support for reading another GRF file's parameters, and warn if GRF Resource Management is tried.
-rw-r--r--newgrf.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/newgrf.c b/newgrf.c
index 7be6f79ae..b9cbc004e 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -2300,23 +2300,45 @@ static void ParamSet(byte *buf, int len)
oper &= 0x7F;
}
- /* The source1 and source2 operands refer to the grf parameter number
- * like in action 6 and 7. In addition, they can refer to the special
- * variables available in action 7, or they can be FF to use the value
- * of <data>. If referring to parameters that are undefined, a value
- * of 0 is used instead. */
- if (src1 == 0xFF) {
- src1 = data;
+ if (src2 == 0xFE) {
+ if (GB(data, 0, 8) == 0xFF) {
+ if (data == 0x0000FFFF) {
+ /* Patch variables */
+ grfmsg(GMS_WARN, "ParamSet: Reading Patch variables unsupport.");
+ return;
+ } else {
+ /* GRF Resource Management */
+ grfmsg(GMS_WARN, "ParamSet: GRF Resource Management unsupported.");
+ return;
+ }
+ } else {
+ /* Read another GRF File's parameter */
+ const GRFFile *file = GetFileByGRFID(data);
+ if (file == NULL || src1 >= file->param_end) {
+ src1 = 0;
+ } else {
+ src1 = file->param[src1];
+ }
+ }
} else {
- uint32 temp;
- src1 = GetParamVal(src1, &temp);
- }
+ /* The source1 and source2 operands refer to the grf parameter number
+ * like in action 6 and 7. In addition, they can refer to the special
+ * variables available in action 7, or they can be FF to use the value
+ * of <data>. If referring to parameters that are undefined, a value
+ * of 0 is used instead. */
+ if (src1 == 0xFF) {
+ src1 = data;
+ } else {
+ uint32 temp;
+ src1 = GetParamVal(src1, &temp);
+ }
- if (src2 == 0xFF) {
- src2 = data;
- } else {
- uint32 temp;
- src2 = GetParamVal(src2, &temp);
+ if (src2 == 0xFF) {
+ src2 = data;
+ } else {
+ uint32 temp;
+ src2 = GetParamVal(src2, &temp);
+ }
}
/* TODO: You can access the parameters of another GRF file by using