static bool BubbleTick(EffectVehicle *v) { uint anim_state; v->progress++; if ((v->progress & 3) != 0) return true; if (v->spritenum == 0) { v->cur_image++; if (v->cur_image < SPR_BUBBLE_GENERATE_3) { v->UpdatePositionAndViewport(); return true; } if (v->animation_substate != 0) { v->spritenum = GB(Random(), 0, 2) + 1; } else { v->spritenum = 6; } anim_state = 0; } else { anim_state = v->animation_state + 1; } const BubbleMovement *b = &_bubble_movement[v->spritenum - 1][anim_state]; if (b->y == 4 && b->x == 0) { delete v; return false; } if (b->y == 4 && b->x == 1) { if (v->z_pos > 180 || Chance16I(1, 96, Random())) { v->spritenum = 5; if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_2F_POP, v); } anim_state = 0; } if (b->y == 4 && b->x == 2) { TileIndex tile; anim_state++; if (_settings_client.sound.ambient) SndPlayVehicleFx(SND_31_EXTRACT, v); tile = TileVirtXY(v->x_pos, v->y_pos); if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile); } v->animation_state = anim_state; b = &_bubble_movement[v->spritenum - 1][anim_state]; v->x_pos += b->x; v->y_pos += b->y; v->z_pos += b->z; v->cur_image = SPR_BUBBLE_0 + b->image; v->UpdatePositionAndViewport(); return true; }
static void TileLoopTreesAlps(TileIndex tile) { int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT; if (k < 0) { switch (GetTreeGround(tile)) { case TREE_GROUND_SNOW_DESERT: SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3); break; case TREE_GROUND_ROUGH_SNOW: SetTreeGroundDensity(tile, TREE_GROUND_ROUGH, 3); break; default: return; } } else { uint density = min((uint)k / TILE_HEIGHT, 3); if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT && GetTreeGround(tile) != TREE_GROUND_ROUGH_SNOW) { TreeGround tg = GetTreeGround(tile) == TREE_GROUND_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT; SetTreeGroundDensity(tile, tg, density); } else if (GetTreeDensity(tile) != density) { SetTreeGroundDensity(tile, GetTreeGround(tile), density); } else { if (GetTreeDensity(tile) == 3) { uint32 r = Random(); if (Chance16I(1, 200, r)) { SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile); } } return; } } MarkTileDirtyByTile(tile); }
static void TileLoopTreesDesert(TileIndex tile) { switch (GetTropicZone(tile)) { case TROPICZONE_DESERT: if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) { SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3); MarkTileDirtyByTile(tile); } break; case TROPICZONE_RAINFOREST: { static const SoundFx forest_sounds[] = { SND_42_LOON_BIRD, SND_43_LION, SND_44_MONKEYS, SND_48_DISTANT_BIRD }; uint32 r = Random(); if (Chance16I(1, 200, r)) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile); break; } default: break; } }
static FORCEINLINE bool Chance16R(const uint a, const uint b, uint32 &r) { r = Random(); return Chance16I(a, b, r); }
static FORCEINLINE bool Chance16(const uint a, const uint b) { return Chance16I(a, b, Random()); }
static inline bool Chance16R(const uint a, const uint b, uint32 &r) { r = Random(); return Chance16I(a, b, r); }
static inline bool Chance16(const uint a, const uint b) { return Chance16I(a, b, Random()); }