337 } |
337 } |
338 *bufp = buf; |
338 *bufp = buf; |
339 return ret; |
339 return ret; |
340 } |
340 } |
341 |
341 |
|
342 static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
|
343 { |
|
344 RoadVehicleInfo *rvi = &_road_vehicle_info[engine]; |
|
345 byte *buf = *bufp; |
|
346 int i; |
|
347 bool ret = false; |
|
348 |
|
349 switch (prop) { |
|
350 case 0x08: { /* Speed */ |
|
351 FOR_EACH_ENGINE { |
|
352 uint8 speed = grf_load_byte(&buf); |
|
353 |
|
354 rvi[i].max_speed = speed; // ?? units |
|
355 } |
|
356 } break; |
|
357 case 0x09: { /* Running cost factor */ |
|
358 FOR_EACH_ENGINE { |
|
359 uint8 runcost = grf_load_byte(&buf); |
|
360 |
|
361 rvi[i].running_cost = runcost; |
|
362 } |
|
363 } break; |
|
364 case 0x0A: /* Running cost base */ |
|
365 /* TODO: I have no idea. --pasky */ |
|
366 FOR_EACH_ENGINE { |
|
367 grf_load_byte(&buf); |
|
368 } |
|
369 ret = true; |
|
370 break; |
|
371 case 0x0E: { /* Sprite ID */ |
|
372 FOR_EACH_ENGINE { |
|
373 uint8 spriteid = grf_load_byte(&buf); |
|
374 |
|
375 if (spriteid == 0xFF) |
|
376 spriteid = 0xFD; // cars have different custom id in the GRF file |
|
377 |
|
378 // This is currently not used but there's no reason |
|
379 // in not having it here for the future. |
|
380 if (spriteid == 0xFD && rvi[i].image_index != 0xFD) |
|
381 _engine_original_sprites[ROAD_ENGINES_INDEX + engine + i] = rvi[i].image_index; |
|
382 |
|
383 rvi[i].image_index = spriteid; |
|
384 } |
|
385 } break; |
|
386 case 0x0F: { /* Cargo capacity */ |
|
387 FOR_EACH_ENGINE { |
|
388 uint16 capacity = grf_load_word(&buf); |
|
389 |
|
390 rvi[i].capacity = capacity; |
|
391 } |
|
392 } break; |
|
393 case 0x10: { /* Cargo type */ |
|
394 FOR_EACH_ENGINE { |
|
395 uint8 cargo = grf_load_byte(&buf); |
|
396 |
|
397 rvi[i].cargo_type = cargo; |
|
398 } |
|
399 } break; |
|
400 case 0x11: { /* Cost factor */ |
|
401 FOR_EACH_ENGINE { |
|
402 uint8 cost_factor = grf_load_byte(&buf); |
|
403 |
|
404 rvi[i].base_cost = cost_factor; // ?? is it base_cost? |
|
405 } |
|
406 } break; |
|
407 case 0x12: { /* SFX */ |
|
408 FOR_EACH_ENGINE { |
|
409 uint8 sfx = grf_load_byte(&buf); |
|
410 |
|
411 rvi[i].sfx = sfx; |
|
412 } |
|
413 } break; |
|
414 case 0x13: /* Power in 10hp */ |
|
415 case 0x14: /* Weight in 1/4 tons */ |
|
416 case 0x15: /* Speed in mph*0.8 */ |
|
417 /* TODO: Support for road vehicles realistic power |
|
418 * computations (called rvpower in TTDPatch) is just |
|
419 * missing in OTTD yet. --pasky */ |
|
420 FOR_EACH_ENGINE { |
|
421 grf_load_byte(&buf); |
|
422 } |
|
423 ret = true; |
|
424 break; |
|
425 case 0x16: { /* Cargos available for refitting */ |
|
426 FOR_EACH_ENGINE { |
|
427 uint32 refit_mask = grf_load_dword(&buf); |
|
428 |
|
429 _engine_refit_masks[ROAD_ENGINES_INDEX + engine + i] = refit_mask; |
|
430 } |
|
431 } break; |
|
432 case 0x17: /* Callback */ |
|
433 case 0x18: /* Tractive effort */ |
|
434 /* TODO */ |
|
435 FOR_EACH_ENGINE { |
|
436 grf_load_byte(&buf); |
|
437 } |
|
438 ret = true; |
|
439 break; |
|
440 default: |
|
441 ret = true; |
|
442 } |
|
443 |
|
444 *bufp = buf; |
|
445 return ret; |
|
446 } |
|
447 |
342 static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
448 static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) |
343 { |
449 { |
344 ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
450 ShipVehicleInfo *svi = &_ship_vehicle_info[engine]; |
345 byte *buf = *bufp; |
451 byte *buf = *bufp; |
346 int i; |
452 int i; |
458 * V new-info new bytes of info (variable size; depends on properties) */ |
564 * V new-info new bytes of info (variable size; depends on properties) */ |
459 /* TODO: Only trains and ships are supported for now. */ |
565 /* TODO: Only trains and ships are supported for now. */ |
460 |
566 |
461 static const VCI_Handler handler[5] = { |
567 static const VCI_Handler handler[5] = { |
462 /* GSF_TRAIN */ RailVehicleChangeInfo, |
568 /* GSF_TRAIN */ RailVehicleChangeInfo, |
463 /* GSF_ROAD */ NULL, |
569 /* GSF_ROAD */ RoadVehicleChangeInfo, |
464 /* GSF_SHIP */ ShipVehicleChangeInfo, |
570 /* GSF_SHIP */ ShipVehicleChangeInfo, |
465 /* GSF_AIRCRAFT */ NULL, |
571 /* GSF_AIRCRAFT */ NULL, |
466 /* GSF_STATION */ NULL, |
572 /* GSF_STATION */ NULL, |
467 }; |
573 }; |
468 |
574 |
476 feature = buf[1]; |
582 feature = buf[1]; |
477 numprops = buf[2]; |
583 numprops = buf[2]; |
478 numinfo = buf[3]; |
584 numinfo = buf[3]; |
479 engine = buf[4]; |
585 engine = buf[4]; |
480 |
586 |
481 if (feature != GSF_TRAIN && feature != GSF_SHIP) { |
587 DEBUG(grf, 6) ("VehicleChangeInfo: Feature %d, %d properties, to apply to %d+%d", |
|
588 feature, numprops, engine, numinfo); |
|
589 |
|
590 if (feature != GSF_TRAIN && feature != GSF_ROAD && feature != GSF_SHIP) { |
482 grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported vehicle type %x, skipping.", feature); |
591 grfmsg(GMS_WARN, "VehicleChangeInfo: Unsupported vehicle type %x, skipping.", feature); |
483 return; |
592 return; |
484 } |
593 } |
485 |
594 |
486 ei = &_engine_info[engine + _vehshifts[feature]]; |
595 ei = &_engine_info[engine + _vehshifts[feature]]; |
526 |
635 |
527 ei[i].railtype_climates &= 0xf0; |
636 ei[i].railtype_climates &= 0xf0; |
528 ei[i].railtype_climates |= climates; |
637 ei[i].railtype_climates |= climates; |
529 } |
638 } |
530 } break; |
639 } break; |
531 case 0x07: { /* Loading spee */ |
640 case 0x07: { /* Loading speed */ |
532 /* TODO */ |
641 /* TODO */ |
533 /* Hyronymus explained me what does |
642 /* Hyronymus explained me what does |
534 * this mean and insists on having a |
643 * this mean and insists on having a |
535 * credit ;-). --pasky */ |
644 * credit ;-). --pasky */ |
536 /* TODO: This needs to be supported by |
645 /* TODO: This needs to be supported by |