equal
deleted
inserted
replaced
44 #include "sound_func.h" |
44 #include "sound_func.h" |
45 #include "string_func.h" |
45 #include "string_func.h" |
46 #include "road_func.h" |
46 #include "road_func.h" |
47 #include "player_base.h" |
47 #include "player_base.h" |
48 #include "settings_type.h" |
48 #include "settings_type.h" |
|
49 #include "network/network.h" |
49 #include "map_func.h" |
50 #include "map_func.h" |
50 #include <map> |
51 #include <map> |
51 |
52 |
52 #include "table/strings.h" |
53 #include "table/strings.h" |
53 #include "table/sprites.h" |
54 #include "table/sprites.h" |
3798 } |
3799 } |
3799 } |
3800 } |
3800 } |
3801 } |
3801 } |
3802 } |
3802 |
3803 |
|
3804 /** |
|
3805 * Disable a static NewGRF when it is influencing another (non-static) |
|
3806 * NewGRF as this could cause desyncs. |
|
3807 * |
|
3808 * We could just tell the NewGRF querying that the file doesn't exist, |
|
3809 * but that might give unwanted results. Disabling the NewGRF gives the |
|
3810 * best result as no NewGRF author can complain about that. |
|
3811 * @param c the NewGRF to disable. |
|
3812 */ |
|
3813 static void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig *c) |
|
3814 { |
|
3815 if (c->error != NULL) { |
|
3816 free(c->error->custom_message); |
|
3817 free(c->error->data); |
|
3818 free(c->error); |
|
3819 } |
|
3820 c->status = GCS_DISABLED; |
|
3821 c->error = CallocT<GRFError>(1); |
|
3822 c->error->data = strdup(_cur_grfconfig->name); |
|
3823 c->error->severity = STR_NEWGRF_ERROR_MSG_FATAL; |
|
3824 c->error->message = STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC; |
|
3825 } |
|
3826 |
3803 /* Action 0x07 */ |
3827 /* Action 0x07 */ |
3804 /* Action 0x09 */ |
3828 /* Action 0x09 */ |
3805 static void SkipIf(byte *buf, size_t len) |
3829 static void SkipIf(byte *buf, size_t len) |
3806 { |
3830 { |
3807 /* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
3831 /* <07/09> <param-num> <param-size> <condition-type> <value> <num-sprites> |
3851 * the "general" code for the cargo availability conditions kicks in. |
3875 * the "general" code for the cargo availability conditions kicks in. |
3852 */ |
3876 */ |
3853 if (param == 0x88 && condtype != 0x0B && condtype != 0x0C) { |
3877 if (param == 0x88 && condtype != 0x0B && condtype != 0x0C) { |
3854 /* GRF ID checks */ |
3878 /* GRF ID checks */ |
3855 |
3879 |
3856 const GRFConfig *c = GetGRFConfig(cond_val); |
3880 GRFConfig *c = GetGRFConfig(cond_val); |
|
3881 |
|
3882 if (c != NULL && HasBit(c->flags, GCF_STATIC) && !HasBit(_cur_grfconfig->flags, GCF_STATIC) && c->status != GCS_DISABLED && _networking) { |
|
3883 DisableStaticNewGRFInfluencingNonStaticNewGRFs(c); |
|
3884 c = NULL; |
|
3885 } |
3857 |
3886 |
3858 if (condtype != 10 && c == NULL) { |
3887 if (condtype != 10 && c == NULL) { |
3859 grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); |
3888 grfmsg(7, "SkipIf: GRFID 0x%08X unknown, skipping test", BSWAP32(cond_val)); |
3860 return; |
3889 return; |
3861 } |
3890 } |
4453 } |
4482 } |
4454 } |
4483 } |
4455 } else { |
4484 } else { |
4456 /* Read another GRF File's parameter */ |
4485 /* Read another GRF File's parameter */ |
4457 const GRFFile *file = GetFileByGRFID(data); |
4486 const GRFFile *file = GetFileByGRFID(data); |
4458 if (file == NULL || src1 >= file->param_end) { |
4487 GRFConfig *c = GetGRFConfig(data); |
|
4488 if (c != NULL && HasBit(c->status, GCF_STATIC) && !HasBit(_cur_grfconfig->status, GCF_STATIC) && _networking) { |
|
4489 /* Disable the read GRF if it is a static NewGRF. */ |
|
4490 DisableStaticNewGRFInfluencingNonStaticNewGRFs(c); |
|
4491 src1 = 0; |
|
4492 } else if (file == NULL || src1 >= file->param_end || (c != NULL && c->status == GCS_DISABLED)) { |
4459 src1 = 0; |
4493 src1 = 0; |
4460 } else { |
4494 } else { |
4461 src1 = file->param[src1]; |
4495 src1 = file->param[src1]; |
4462 } |
4496 } |
4463 } |
4497 } |