(svn r7462) -Fix: when doing comparison in action 7/9, mask the param value so it has the 'same' size as the value it is compared to
authorglx
Sun, 10 Dec 2006 00:48:50 +0000
changeset 5306 8081baa646cd
parent 5305 e07957fe871e
child 5307 3e336ae5724a
(svn r7462) -Fix: when doing comparison in action 7/9, mask the param value so it has the 'same' size as the value it is compared to
newgrf.c
--- a/newgrf.c	Sun Dec 10 00:20:26 2006 +0000
+++ b/newgrf.c	Sun Dec 10 00:48:50 2006 +0000
@@ -2370,23 +2370,19 @@
 
 	param_val = GetParamVal(param, &cond_val);
 
-	/* Apply parameter mask, only for GRF parameters. */
-	if (param < 0x80) param_val &= mask;
-
 	DEBUG(grf, 7) ("Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val);
 	switch (condtype) {
 		case 0: result = !!(param_val & (1 << cond_val));
 			break;
 		case 1: result = !(param_val & (1 << cond_val));
 			break;
-		/* TODO: For the following, make it to work with paramsize>1. */
-		case 2: result = (param_val == cond_val);
+		case 2: result = (param_val & mask) == cond_val;
 			break;
-		case 3: result = (param_val != cond_val);
+		case 3: result = (param_val & mask) != cond_val;
 			break;
-		case 4: result = (param_val < cond_val);
+		case 4: result = (param_val & mask) < cond_val;
 			break;
-		case 5: result = (param_val > cond_val);
+		case 5: result = (param_val & mask) > cond_val;
 			break;
 
 		/* Tests 6 to 10 are only for param 0x88, GRFID checks */