(svn r4657) - NewGRF: use grf_load_byte() in favour of array accesses

pull/155/head
peter1138 19 years ago
parent ee227f7e69
commit b8cc6d6cee

@ -1128,10 +1128,11 @@ static void VehicleChangeInfo(byte *buf, int len)
} }
check_length(len, 6, "VehicleChangeInfo"); check_length(len, 6, "VehicleChangeInfo");
feature = buf[1]; buf++;
numprops = buf[2]; feature = grf_load_byte(&buf);
numinfo = buf[3]; numprops = grf_load_byte(&buf);
engine = buf[4]; numinfo = grf_load_byte(&buf);
engine = grf_load_byte(&buf);
DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d", DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d",
feature, numprops, engine, numinfo); feature, numprops, engine, numinfo);
@ -1149,8 +1150,6 @@ static void VehicleChangeInfo(byte *buf, int len)
ei = &_engine_info[engine + _vehshifts[feature]]; ei = &_engine_info[engine + _vehshifts[feature]];
} }
buf += 5;
while (numprops-- && buf < bufend) { while (numprops-- && buf < bufend) {
uint8 prop = grf_load_byte(&buf); uint8 prop = grf_load_byte(&buf);
bool ignoring = false; bool ignoring = false;
@ -1973,16 +1972,16 @@ static void SkipIf(byte *buf, int len)
GRFLabel *choice = NULL; GRFLabel *choice = NULL;
check_length(len, 6, "SkipIf"); check_length(len, 6, "SkipIf");
param = buf[1]; buf++;
paramsize = buf[2]; param = grf_load_byte(&buf);
condtype = buf[3]; paramsize = grf_load_byte(&buf);
condtype = grf_load_byte(&buf);
if (condtype < 2) { if (condtype < 2) {
/* Always 1 for bit tests, the given value should be ignored. */ /* Always 1 for bit tests, the given value should be ignored. */
paramsize = 1; paramsize = 1;
} }
buf += 4;
switch (paramsize) { switch (paramsize) {
case 4: cond_val = grf_load_dword(&buf); break; case 4: cond_val = grf_load_dword(&buf); break;
case 2: cond_val = grf_load_word(&buf); break; case 2: cond_val = grf_load_word(&buf); break;

Loading…
Cancel
Save