File diff r10780:f7de0458659f → r10781:758b3ae29fdd
src/newgrf.cpp
Show inline comments
 
@@ -3954,24 +3954,25 @@ static void SkipIf(byte *buf, size_t len
 
	if (!check_length(len, 6, "SkipIf")) return;
 
	buf++;
 
	uint8 param     = grf_load_byte(&buf);
 
	uint8 paramsize = grf_load_byte(&buf);
 
	uint8 condtype  = grf_load_byte(&buf);
 

	
 
	if (condtype < 2) {
 
		/* Always 1 for bit tests, the given value should be ignored. */
 
		paramsize = 1;
 
	}
 

	
 
	switch (paramsize) {
 
		case 8: cond_val = grf_load_dword(&buf); mask = grf_load_dword(&buf); break;
 
		case 4: cond_val = grf_load_dword(&buf); mask = 0xFFFFFFFF; break;
 
		case 2: cond_val = grf_load_word(&buf);  mask = 0x0000FFFF; break;
 
		case 1: cond_val = grf_load_byte(&buf);  mask = 0x000000FF; break;
 
		default: break;
 
	}
 

	
 
	if (param < 0x80 && _cur_grffile->param_end <= param) {
 
		grfmsg(7, "SkipIf: Param %d undefined, skipping test", param);
 
		return;
 
	}
 

	
 
	uint32 param_val = GetParamVal(param, &cond_val);
 
@@ -3979,25 +3980,25 @@ static void SkipIf(byte *buf, size_t len
 
	grfmsg(7, "SkipIf: Test condtype %d, param 0x%08X, condval 0x%08X", condtype, param_val, cond_val);
 

	
 
	/*
 
	 * Parameter (variable in specs) 0x88 can only have GRF ID checking
 
	 * conditions, except conditions 0x0B and 0x0C (cargo availability)
 
	 * as those ignore the parameter. So, when the condition type is
 
	 * either of those, the specific variable 0x88 code is skipped, so
 
	 * the "general" code for the cargo availability conditions kicks in.
 
	 */
 
	if (param == 0x88 && condtype != 0x0B && condtype != 0x0C) {
 
		/* GRF ID checks */
 

	
 
		GRFConfig *c = GetGRFConfig(cond_val);
 
		GRFConfig *c = GetGRFConfig(cond_val, mask);
 

	
 
		if (c != NULL && HasBit(c->flags, GCF_STATIC) && !HasBit(_cur_grfconfig->flags, GCF_STATIC) && c->status != GCS_DISABLED && _networking) {
 
			DisableStaticNewGRFInfluencingNonStaticNewGRFs(c);
 
			c = NULL;
 
		}
 

	
 
		if (condtype != 10 && c == NULL) {
 
			grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val));
 
			return;
 
		}
 

	
 
		switch (condtype) {