Fixed one of my bugs and did some refactoring. Still more refactoring to do...

This commit is contained in:
U-ASUS-EEEPC\Cameron Hall 2015-11-13 13:48:21 -06:00
parent 0757b09781
commit 2cd40b025a
1 changed files with 45 additions and 63 deletions

View File

@ -1974,7 +1974,6 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
/* Continuing dissassembly - work in progress /* Continuing dissassembly - work in progress
* Known bugs: * Known bugs:
* Raising the corner of a piece of land doesn't remove walls. * Raising the corner of a piece of land doesn't remove walls.
* Small scenery elements (ones that take up 1/4 of a tile) are not removed when changing land height.
* Original bugs: * Original bugs:
* Lowering the land tile underneath a wall removes the wall. * Lowering the land tile underneath a wall removes the wall.
* Land can be raised over flat scenery items (gardens, for example) without removing them. * Land can be raised over flat scenery items (gardens, for example) without removing them.
@ -1990,7 +1989,7 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
RCT2_GLOBAL(0x9E2E18, uint32) = 0; RCT2_GLOBAL(0x9E2E18, uint32) = 0;
if(ebx&GAME_COMMAND_FLAG_APPLY) if(ebx&GAME_COMMAND_FLAG_APPLY)
{ {
footpath_remove_litter(eax, ebx, map_element_height(eax, ecx)); footpath_remove_litter(eax, ecx, map_element_height(eax, ecx));
//Hmmm... I have a bug in here where raising the corner of a tile doesn't remove walls on it. //Hmmm... I have a bug in here where raising the corner of a tile doesn't remove walls on it.
map_remove_walls_at(eax, ecx, edx*8-16, edx*8+32); map_remove_walls_at(eax, ecx, edx*8-16, edx*8+32);
} }
@ -2008,47 +2007,41 @@ static money32 map_set_land_height(int flags, int x, int y, int height, int styl
uint8 *pbl = (uint8 *)&ebx; uint8 *pbl = (uint8 *)&ebx;
uint8 *pbh = (uint8 *)&ebx+1; uint8 *pbh = (uint8 *)&ebx+1;
/* rct_map_element *mapElement = map_get_first_element_at(eax/32, ecx/32); //esi
esi = ecx&0xFFFF; //movzx esi, cx
esi <<= 8;
esi |= eax;
esi >>= 3;
esi = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, uint32)[(int)esi/4];
*/
esi = (int)map_get_first_element_at(eax/32, ecx/32);
*pdh = *pdl; *pdh = *pdl;
*pdh += 4; *pdh += 4;
loc_663A54: //loc_663A54:
eax = map_element_get_type((rct_map_element *)esi); do{
if(eax!=MAP_ELEMENT_TYPE_SCENERY || *pdl>((rct_map_element *)esi)->clearance_height || *pdh<((rct_map_element *)esi)->base_height) int type = map_element_get_type(mapElement); //eax
goto loc_663AA3; rct_scenery_entry *sceneryEntry; //eax
eax = ((rct_map_element *)esi)->properties.scenery.type;
eax = RCT2_ADDRESS(RCT2_ADDRESS_SMALL_SCENERY_ENTRIES, uint32)[eax]; if(type!=MAP_ELEMENT_TYPE_SCENERY || *pdl>(mapElement)->clearance_height || *pdh<(mapElement)->base_height)
if(((rct_scenery_entry *)eax)->small_scenery.height>0x40) //cmp byte ptr [eax+0Ah], 40h; jbe short loc_663A87 continue;
{ type = mapElement->properties.scenery.type;
if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32)&PARK_FLAGS_FORBID_TREE_REMOVAL) sceneryEntry = RCT2_ADDRESS(RCT2_ADDRESS_SMALL_SCENERY_ENTRIES, rct_scenery_entry *)[type];
if(sceneryEntry->small_scenery.height>0x40) //cmp byte ptr [eax+0Ah], 40h; jbe short loc_663A87
{ {
//rct2: 0x663C45 if(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32)&PARK_FLAGS_FORBID_TREE_REMOVAL)
map_obstruction_set_error_text((rct_map_element *)esi); {
return MONEY32_UNDEFINED; //rct2: 0x663C45
map_obstruction_set_error_text(mapElement);
return MONEY32_UNDEFINED;
}
} }
} //rct2: 0x663A87
//rct2: 0x663A87 RCT2_GLOBAL(0x9E2E18, money32) += ((rct_scenery_entry *)sceneryEntry)->small_scenery.removal_price*10;
//callcode_push3(0x663A87, saved_eax, saved_ecx, saved_edx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx; //rct2: 0x663A94
ecx = ((rct_scenery_entry *)eax)->small_scenery.removal_price*10; if((ebx&GAME_COMMAND_FLAG_APPLY))
RCT2_GLOBAL(0x9E2E18, uint32) += ecx; {
//rct2: 0x663A94 map_element_remove(mapElement);
if((ebx&GAME_COMMAND_FLAG_APPLY)) mapElement--;
{ }
map_element_remove((rct_map_element *)esi); //loc_663AA3:
esi = esi-8; }while(!((mapElement++)->flags&MAP_ELEMENT_FLAG_LAST_TILE));
}
loc_663AA3: esi =(int)mapElement;
esi = esi+8;
if(!((*(uint8 *)esi-7)&MAP_ELEMENT_FLAG_LAST_TILE))
goto loc_663A54;
edx = saved_edx; edx = saved_edx;
ecx = saved_ecx; ecx = saved_ecx;
eax = saved_eax; eax = saved_eax;
@ -2058,35 +2051,28 @@ loc_663AA3:
//callcode_push3(0x663AB2, saved_eax, saved_ebx, saved_ecx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx; //callcode_push3(0x663AB2, saved_eax, saved_ebx, saved_ecx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx;
/* mapElement = map_get_first_element_at(eax/32, ecx/32); //esi
esi = ecx&0xFFFF; //movzx esi, cx
esi <<= 8;
esi |= eax&0xFFFF; //or si, ax
esi >>= 3;
esi = RCT2_ADDRESS(RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS, uint32)[esi/4];
*/
rct_map_element *mapElement = map_get_first_element_at(eax/32, ecx/32); //esi
esi = (int)mapElement; esi = (int)mapElement;
//callcode_push3(0x663AC4, saved_eax, saved_ebx, saved_ecx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx; //callcode_push3(0x663AC4, saved_eax, saved_ebx, saved_ecx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx;
loc_663AC4: do{
eax = mapElement->type; //loc_663AC4:
eax &= 0x3C; //eax = mapElement->type&0x3C;
if(eax==8) int type = mapElement->type&0x3C; //eax
{ if(type!=8)
ebp = ((rct_map_element *)mapElement)->properties.track.ride_index; //not sure what union member we need here. [esi+7] continue;
eax = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[ebp].subtype; int rideIndex = mapElement->properties.track.ride_index; //ebp
eax = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[rideIndex].subtype;
eax = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, uint32)[eax]; eax = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, uint32)[eax];
eax = ((rct_ride_type *)eax)->max_height; eax = ((rct_ride_type *)eax)->max_height;
if(eax==0) if(eax==0)
{ {
eax = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[ebp].type; eax = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride)[rideIndex].type;
eax = RCT2_GLOBAL(0x97D218+eax*8, uint8); eax = RCT2_GLOBAL(0x97D218+eax*8, uint8);
} }
//rct2: 0x663AFC //rct2: 0x663AFC
ebx = mapElement->clearance_height; ebx = mapElement->clearance_height-*pdl;
ebx -= *pdl;
if(ebx>=0) if(ebx>=0)
{ {
ebx >>= 1; ebx >>= 1;
@ -2097,18 +2083,14 @@ loc_663AC4:
return MONEY32_UNDEFINED; return MONEY32_UNDEFINED;
} }
} }
} loc_663B1A:;
loc_663B1A: }while(!((mapElement++)->flags&MAP_ELEMENT_FLAG_LAST_TILE));
mapElement++;
if((mapElement-1)->flags&MAP_ELEMENT_FLAG_LAST_TILE)
goto loc_663AC4;
ecx = saved_ecx; ecx = saved_ecx;
ebx = saved_ebx; ebx = saved_ebx;
eax = saved_eax; eax = saved_eax;
saved_ecx = ecx; saved_ecx = ecx;
ebp *= 0x260;
esi = (int)mapElement;
//callcode_push1(0x663B27, saved_ecx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx; //callcode_push1(0x663B27, saved_ecx, &eax, &ebx, &ecx, (int *)&edx, (int *)&esi, &edi, &ebp); return ebx;
/* /*
@ -5495,4 +5477,4 @@ rct_map_element *map_get_track_element_at_of_type(int x, int y, int z, int track
} while (!map_element_is_last_for_tile(mapElement++)); } while (!map_element_is_last_for_tile(mapElement++));
return NULL; return NULL;
} }