00001
00002
00005 #include "stdafx.h"
00006 #include "openttd.h"
00007 #include "variables.h"
00008 #include "debug.h"
00009 #include "viewport_func.h"
00010 #include "landscape.h"
00011 #include "town_map.h"
00012 #include "sprite.h"
00013 #include "newgrf.h"
00014 #include "newgrf_house.h"
00015 #include "newgrf_spritegroup.h"
00016 #include "newgrf_town.h"
00017 #include "newgrf_sound.h"
00018 #include "newgrf_commons.h"
00019 #include "transparency.h"
00020 #include "functions.h"
00021 #include "company_func.h"
00022 #include "animated_tile_func.h"
00023 #include "company_base.h"
00024
00025 static BuildingCounts<uint32> _building_counts;
00026 static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
00027
00028 HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, HOUSE_MAX, INVALID_HOUSE_ID);
00029
00030 HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid)
00031 {
00032
00033 for (int i = 1; i != lengthof(_class_mapping); i++) {
00034 HouseClassMapping *map = &_class_mapping[i];
00035
00036 if (map->class_id == grf_class_id && map->grfid == grfid) return (HouseClassID)i;
00037
00038 if (map->class_id == 0 && map->grfid == 0) {
00039 map->class_id = grf_class_id;
00040 map->grfid = grfid;
00041 return (HouseClassID)i;
00042 }
00043 }
00044 return HOUSE_NO_CLASS;
00045 }
00046
00047 void InitializeBuildingCounts()
00048 {
00049 memset(&_building_counts, 0, sizeof(_building_counts));
00050 }
00051
00058 void IncreaseBuildingCount(Town *t, HouseID house_id)
00059 {
00060 HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
00061
00062 if (!_loaded_newgrf_features.has_newhouses) return;
00063
00064 t->building_counts.id_count[house_id]++;
00065 _building_counts.id_count[house_id]++;
00066
00067 if (class_id == HOUSE_NO_CLASS) return;
00068
00069 t->building_counts.class_count[class_id]++;
00070 _building_counts.class_count[class_id]++;
00071 }
00072
00079 void DecreaseBuildingCount(Town *t, HouseID house_id)
00080 {
00081 HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
00082
00083 if (!_loaded_newgrf_features.has_newhouses) return;
00084
00085 if (t->building_counts.id_count[house_id] > 0) t->building_counts.id_count[house_id]--;
00086 if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;
00087
00088 if (class_id == HOUSE_NO_CLASS) return;
00089
00090 if (t->building_counts.class_count[class_id] > 0) t->building_counts.class_count[class_id]--;
00091 if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
00092 }
00093
00094 static uint32 HouseGetRandomBits(const ResolverObject *object)
00095 {
00096 const TileIndex tile = object->u.house.tile;
00097 return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseRandomBits(tile);
00098 }
00099
00100 static uint32 HouseGetTriggers(const ResolverObject *object)
00101 {
00102 const TileIndex tile = object->u.house.tile;
00103 return (tile == INVALID_TILE || !IsTileType(tile, MP_HOUSE)) ? 0 : GetHouseTriggers(tile);
00104 }
00105
00106 static void HouseSetTriggers(const ResolverObject *object, int triggers)
00107 {
00108 const TileIndex tile = object->u.house.tile;
00109 if (IsTileType(tile, MP_HOUSE)) SetHouseTriggers(tile, triggers);
00110 }
00111
00112 static uint32 GetNumHouses(HouseID house_id, const Town *town)
00113 {
00114 uint8 map_id_count, town_id_count, map_class_count, town_class_count;
00115 HouseClassID class_id = GetHouseSpecs(house_id)->class_id;
00116
00117 map_id_count = ClampU(_building_counts.id_count[house_id], 0, 255);
00118 map_class_count = ClampU(_building_counts.class_count[class_id], 0, 255);
00119 town_id_count = ClampU(town->building_counts.id_count[house_id], 0, 255);
00120 town_class_count = ClampU(town->building_counts.class_count[class_id], 0, 255);
00121
00122 return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
00123 }
00124
00125 uint32 GetNearbyTileInformation(byte parameter, TileIndex tile)
00126 {
00127 tile = GetNearbyTile(parameter, tile);
00128 return GetNearbyTileInformation(tile);
00129 }
00130
00132 typedef struct {
00133 const HouseSpec *hs;
00134 TileIndex north_tile;
00135 } SearchNearbyHouseData;
00136
00142 static bool SearchNearbyHouseID(TileIndex tile, void *user_data)
00143 {
00144 if (IsTileType(tile, MP_HOUSE)) {
00145 HouseID house = GetHouseType(tile);
00146 const HouseSpec *hs = GetHouseSpecs(house);
00147 if (hs->grffile != NULL) {
00148 SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
00149
00150 TileIndex north_tile = tile + GetHouseNorthPart(house);
00151 if (north_tile == nbhd->north_tile) return false;
00152
00153 return hs->local_id == nbhd->hs->local_id &&
00154 hs->grffile->grfid == nbhd->hs->grffile->grfid;
00155 }
00156 }
00157 return false;
00158 }
00159
00165 static bool SearchNearbyHouseClass(TileIndex tile, void *user_data)
00166 {
00167 if (IsTileType(tile, MP_HOUSE)) {
00168 HouseID house = GetHouseType(tile);
00169 const HouseSpec *hs = GetHouseSpecs(house);
00170 if (hs->grffile != NULL) {
00171 SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
00172
00173 TileIndex north_tile = tile + GetHouseNorthPart(house);
00174 if (north_tile == nbhd->north_tile) return false;
00175
00176 return hs->class_id == nbhd->hs->class_id &&
00177 hs->grffile->grfid == nbhd->hs->grffile->grfid;
00178 }
00179 }
00180 return false;
00181 }
00182
00188 static bool SearchNearbyHouseGRFID(TileIndex tile, void *user_data)
00189 {
00190 if (IsTileType(tile, MP_HOUSE)) {
00191 HouseID house = GetHouseType(tile);
00192 const HouseSpec *hs = GetHouseSpecs(house);
00193 if (hs->grffile != NULL) {
00194 SearchNearbyHouseData *nbhd = (SearchNearbyHouseData *)user_data;
00195
00196 TileIndex north_tile = tile + GetHouseNorthPart(house);
00197 if (north_tile == nbhd->north_tile) return false;
00198
00199 return hs->grffile->grfid == nbhd->hs->grffile->grfid;
00200 }
00201 }
00202 return false;
00203 }
00204
00214 static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseID house)
00215 {
00216 static TestTileOnSearchProc * const search_procs[3] = {
00217 SearchNearbyHouseID,
00218 SearchNearbyHouseClass,
00219 SearchNearbyHouseGRFID,
00220 };
00221 TileIndex found_tile = tile;
00222 uint8 searchtype = GB(parameter, 6, 2);
00223 uint8 searchradius = GB(parameter, 0, 6);
00224 if (searchtype >= lengthof(search_procs)) return 0;
00225 if (searchradius < 1) return 0;
00226
00227 SearchNearbyHouseData nbhd;
00228 nbhd.hs = GetHouseSpecs(house);
00229 nbhd.north_tile = tile + GetHouseNorthPart(house);
00230
00231
00232 if (CircularTileSearch(&found_tile, 2 * searchradius + 1, search_procs[searchtype], &nbhd)) {
00233 return DistanceManhattan(found_tile, tile);
00234 }
00235 return 0;
00236 }
00237
00243 static uint32 HouseGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available)
00244 {
00245 const Town *town = object->u.house.town;
00246 TileIndex tile = object->u.house.tile;
00247 HouseID house_id = object->u.house.house_id;
00248
00249 if (object->scope == VSG_SCOPE_PARENT) {
00250 return TownGetVariable(variable, parameter, available, town);
00251 }
00252
00253 switch (variable) {
00254
00255 case 0x40: return (IsTileType(tile, MP_HOUSE) ? GetHouseBuildingStage(tile) : 0) | TileHash2Bit(TileX(tile), TileY(tile)) << 2;
00256
00257
00258 case 0x41: return IsTileType(tile, MP_HOUSE) ? GetHouseAge(tile) : 0;
00259
00260
00261 case 0x42: return GetTownRadiusGroup(town, tile);
00262
00263
00264 case 0x43: return GetTerrainType(tile);
00265
00266
00267 case 0x44: return GetNumHouses(house_id, town);
00268
00269
00270 case 0x45: return _generating_world ? 1 : 0;
00271
00272
00273 case 0x46: return IsTileType(tile, MP_HOUSE) ? GetHouseAnimationFrame(tile) : 0;
00274
00275
00276 case 0x47: return TileY(tile) << 16 | TileX(tile);
00277
00278
00279 case 0x60: return GetNumHouses(parameter, town);
00280
00281
00282 case 0x61: {
00283 const HouseSpec *hs = GetHouseSpecs(house_id);
00284 if (hs->grffile == NULL) return 0;
00285
00286 HouseID new_house = _house_mngr.GetID(parameter, hs->grffile->grfid);
00287 return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, town);
00288 }
00289
00290
00291 case 0x62: return GetNearbyTileInformation(parameter, tile);
00292
00293
00294 case 0x63: {
00295 TileIndex testtile = GetNearbyTile(parameter, tile);
00296 return IsTileType(testtile, MP_HOUSE) ? GetHouseAnimationFrame(testtile) : 0;
00297 }
00298
00299
00300
00301
00302
00303 case 0x65: return GetDistanceFromNearbyHouse(parameter, tile, object->u.house.house_id);
00304 }
00305
00306 DEBUG(grf, 1, "Unhandled house property 0x%X", variable);
00307
00308 *available = false;
00309 return UINT_MAX;
00310 }
00311
00312 static const SpriteGroup *HouseResolveReal(const ResolverObject *object, const SpriteGroup *group)
00313 {
00314
00315 return NULL;
00316 }
00317
00323 static void NewHouseResolver(ResolverObject *res, HouseID house_id, TileIndex tile, Town *town)
00324 {
00325 res->GetRandomBits = HouseGetRandomBits;
00326 res->GetTriggers = HouseGetTriggers;
00327 res->SetTriggers = HouseSetTriggers;
00328 res->GetVariable = HouseGetVariable;
00329 res->ResolveReal = HouseResolveReal;
00330
00331 res->u.house.tile = tile;
00332 res->u.house.town = town;
00333 res->u.house.house_id = house_id;
00334
00335 res->callback = CBID_NO_CALLBACK;
00336 res->callback_param1 = 0;
00337 res->callback_param2 = 0;
00338 res->last_value = 0;
00339 res->trigger = 0;
00340 res->reseed = 0;
00341 res->count = 0;
00342
00343 const HouseSpec *hs = GetHouseSpecs(house_id);
00344 res->grffile = (hs != NULL ? hs->grffile : NULL);
00345 }
00346
00347 uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile)
00348 {
00349 ResolverObject object;
00350 const SpriteGroup *group;
00351
00352 NewHouseResolver(&object, house_id, tile, town);
00353 object.callback = callback;
00354 object.callback_param1 = param1;
00355 object.callback_param2 = param2;
00356
00357 group = Resolve(GetHouseSpecs(house_id)->spritegroup, &object);
00358 if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
00359
00360 return group->g.callback.result;
00361 }
00362
00363 static void DrawTileLayout(const TileInfo *ti, const SpriteGroup *group, byte stage, HouseID house_id)
00364 {
00365 const DrawTileSprites *dts = group->g.layout.dts;
00366 const DrawTileSeqStruct *dtss;
00367
00368 const HouseSpec *hs = GetHouseSpecs(house_id);
00369 SpriteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOUR_START;
00370 if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) {
00371 uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile);
00372 if (callback != CALLBACK_FAILED) {
00373
00374 palette = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
00375 }
00376 }
00377
00378 SpriteID image = dts->ground.sprite;
00379 SpriteID pal = dts->ground.pal;
00380
00381 if (IS_CUSTOM_SPRITE(image)) image += stage;
00382
00383 if (GB(image, 0, SPRITE_WIDTH) != 0) {
00384 DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, palette));
00385 }
00386
00387 foreach_draw_tile_seq(dtss, dts->seq) {
00388 if (GB(dtss->image.sprite, 0, SPRITE_WIDTH) == 0) continue;
00389
00390 image = dtss->image.sprite;
00391 pal = dtss->image.pal;
00392
00393
00394 if (IsInvisibilitySet(TO_HOUSES) && !HasBit(image, SPRITE_MODIFIER_OPAQUE)) return;
00395
00396 if (IS_CUSTOM_SPRITE(image)) image += stage;
00397
00398 pal = SpriteLayoutPaletteTransform(image, pal, palette);
00399
00400 if ((byte)dtss->delta_z != 0x80) {
00401 AddSortableSpriteToDraw(
00402 image, pal,
00403 ti->x + dtss->delta_x, ti->y + dtss->delta_y,
00404 dtss->size_x, dtss->size_y,
00405 dtss->size_z, ti->z + dtss->delta_z,
00406 !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_HOUSES)
00407 );
00408 } else {
00409
00410 AddChildSpriteScreen(image, pal, (byte)dtss->delta_x, (byte)dtss->delta_y, !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(TO_HOUSES));
00411 }
00412 }
00413 }
00414
00415 void DrawNewHouseTile(TileInfo *ti, HouseID house_id)
00416 {
00417 const HouseSpec *hs = GetHouseSpecs(house_id);
00418 const SpriteGroup *group;
00419 ResolverObject object;
00420
00421 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
00422
00423 NewHouseResolver(&object, house_id, ti->tile, GetTownByTile(ti->tile));
00424
00425 group = Resolve(hs->spritegroup, &object);
00426 if (group == NULL || group->type != SGT_TILELAYOUT) {
00427
00428 DrawGroundSprite(SPR_SHADOW_CELL, PAL_NONE);
00429 } else {
00430
00431 byte stage = GetHouseBuildingStage(ti->tile);
00432 stage = Clamp(stage - 4 + group->g.layout.num_sprites, 0, group->g.layout.num_sprites - 1);
00433 DrawTileLayout(ti, group, stage, house_id);
00434 }
00435 }
00436
00437 void AnimateNewHouseTile(TileIndex tile)
00438 {
00439 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
00440 byte animation_speed = hs->animation_speed;
00441 bool frame_set_by_callback = false;
00442
00443 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) {
00444 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
00445 if (callback_res != CALLBACK_FAILED) animation_speed = Clamp(callback_res & 0xFF, 2, 16);
00446 }
00447
00448
00449
00450
00451
00452 if (_tick_counter % (1 << animation_speed) != 0) return;
00453
00454 byte frame = GetHouseAnimationFrame(tile);
00455 byte num_frames = GB(hs->animation_frames, 0, 7);
00456
00457 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) {
00458 uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0;
00459 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), GetTownByTile(tile), tile);
00460
00461 if (callback_res != CALLBACK_FAILED) {
00462 frame_set_by_callback = true;
00463
00464 switch (callback_res & 0xFF) {
00465 case 0xFF:
00466 DeleteAnimatedTile(tile);
00467 break;
00468 case 0xFE:
00469
00470 frame_set_by_callback = false;
00471 break;
00472 default:
00473 frame = callback_res & 0xFF;
00474 break;
00475 }
00476
00477
00478
00479 if (GB(callback_res, 8, 7) != 0) PlayTileSound(hs->grffile, GB(callback_res, 8, 7), tile);
00480 }
00481 }
00482
00483 if (!frame_set_by_callback) {
00484 if (frame < num_frames) {
00485 frame++;
00486 } else if (frame == num_frames && HasBit(hs->animation_frames, 7)) {
00487
00488 frame = 0;
00489 } else {
00490
00491 DeleteAnimatedTile(tile);
00492 }
00493 }
00494
00495 SetHouseAnimationFrame(tile, frame);
00496 MarkTileDirtyByTile(tile);
00497 }
00498
00499 void ChangeHouseAnimationFrame(const GRFFile *file, TileIndex tile, uint16 callback_result)
00500 {
00501 switch (callback_result & 0xFF) {
00502 case 0xFD: break;
00503 case 0xFE: AddAnimatedTile(tile); break;
00504 case 0xFF: DeleteAnimatedTile(tile); break;
00505 default:
00506 SetHouseAnimationFrame(tile, callback_result & 0xFF);
00507 AddAnimatedTile(tile);
00508 break;
00509 }
00510
00511
00512 if (GB(callback_result, 8, 7) != 0) PlayTileSound(file, GB(callback_result, 8, 7), tile);
00513 }
00514
00515 bool CanDeleteHouse(TileIndex tile)
00516 {
00517 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
00518
00519
00520
00521 if ((IsValidCompanyID(_current_company) && IsHumanCompany(_current_company))
00522 || _current_company == OWNER_WATER || _current_company == OWNER_NONE) return true;
00523
00524 if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) {
00525 uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
00526 return (callback_res == CALLBACK_FAILED || callback_res == 0);
00527 } else {
00528 return !(hs->extra_flags & BUILDING_IS_PROTECTED);
00529 }
00530 }
00531
00532 static void AnimationControl(TileIndex tile, uint16 random_bits)
00533 {
00534 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
00535
00536 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
00537 uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random();
00538 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), GetTownByTile(tile), tile);
00539
00540 if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res);
00541 }
00542 }
00543
00544 bool NewHouseTileLoop(TileIndex tile)
00545 {
00546 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
00547
00548 if (GetHouseProcessingTime(tile) > 0) {
00549 DecHouseProcessingTime(tile);
00550 return true;
00551 }
00552
00553 TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP);
00554 if (hs->building_flags & BUILDING_HAS_1_TILE) TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
00555
00556 if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) {
00557
00558
00559
00560
00561 if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) {
00562 uint16 random = GB(Random(), 0, 16);
00563
00564 if (hs->building_flags & BUILDING_HAS_1_TILE) AnimationControl(tile, random);
00565 if (hs->building_flags & BUILDING_2_TILES_Y) AnimationControl(TILE_ADDXY(tile, 0, 1), random);
00566 if (hs->building_flags & BUILDING_2_TILES_X) AnimationControl(TILE_ADDXY(tile, 1, 0), random);
00567 if (hs->building_flags & BUILDING_HAS_4_TILES) AnimationControl(TILE_ADDXY(tile, 1, 1), random);
00568 } else {
00569 AnimationControl(tile, 0);
00570 }
00571 }
00572
00573
00574 if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) {
00575 uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
00576 if (callback_res != CALLBACK_FAILED && GB(callback_res, 0, 8) > 0) {
00577 ClearTownHouse(GetTownByTile(tile), tile);
00578 return false;
00579 }
00580 }
00581
00582 SetHouseProcessingTime(tile, hs->processing_time);
00583 MarkTileDirtyByTile(tile);
00584 return true;
00585 }
00586
00587 static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_random, bool first)
00588 {
00589 ResolverObject object;
00590
00591
00592 assert(IsTileType(tile, MP_HOUSE));
00593
00594 HouseID hid = GetHouseType(tile);
00595 HouseSpec *hs = GetHouseSpecs(hid);
00596
00597 if (hs->spritegroup == NULL) return;
00598
00599 NewHouseResolver(&object, hid, tile, GetTownByTile(tile));
00600
00601 object.callback = CBID_RANDOM_TRIGGER;
00602 object.trigger = trigger;
00603
00604 const SpriteGroup *group = Resolve(hs->spritegroup, &object);
00605 if (group == NULL) return;
00606
00607 byte new_random_bits = Random();
00608 byte random_bits = GetHouseRandomBits(tile);
00609 random_bits &= ~object.reseed;
00610 random_bits |= (first ? new_random_bits : base_random) & object.reseed;
00611 SetHouseRandomBits(tile, random_bits);
00612
00613 switch (trigger) {
00614 case HOUSE_TRIGGER_TILE_LOOP:
00615
00616 break;
00617
00618 case HOUSE_TRIGGER_TILE_LOOP_TOP:
00619 if (!first) {
00620
00621 MarkTileDirtyByTile(tile);
00622 break;
00623 }
00624
00625 if (hs->building_flags & BUILDING_2_TILES_Y) DoTriggerHouse(TILE_ADDXY(tile, 0, 1), trigger, random_bits, false);
00626 if (hs->building_flags & BUILDING_2_TILES_X) DoTriggerHouse(TILE_ADDXY(tile, 1, 0), trigger, random_bits, false);
00627 if (hs->building_flags & BUILDING_HAS_4_TILES) DoTriggerHouse(TILE_ADDXY(tile, 1, 1), trigger, random_bits, false);
00628 break;
00629 }
00630 }
00631
00632 void TriggerHouse(TileIndex t, HouseTrigger trigger)
00633 {
00634 DoTriggerHouse(t, trigger, 0, true);
00635 }