mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Don't use sizeof() in pointer arithmetic or as indices; use found variables
This commit is contained in:
@@ -252,7 +252,7 @@ void news_item_add_to_queue(uint8 type, rct_string_id string_id, uint32 assoc)
|
||||
|
||||
// find first open slot
|
||||
while (newsItem->type != NEWS_ITEM_NULL) {
|
||||
if (newsItem + sizeof(newsItem) >= (rct_news_item*)0x13CB1CC)
|
||||
if (newsItem + 1 >= (rct_news_item*)0x13CB1CC)
|
||||
news_item_close_current();
|
||||
else
|
||||
newsItem++;
|
||||
|
||||
@@ -420,10 +420,10 @@ void scenario_objective8_check()
|
||||
ride->excitement >= RIDE_RATING(7,00) && type_already_counted[subtype_id] == 0){
|
||||
|
||||
// this calculates the length, no idea why it's done so complicated though.
|
||||
uint8 limit = ride->pad_088[63];
|
||||
uint8 limit = ride->var_0C7;
|
||||
uint32 sum = 0;
|
||||
for (int j = 0; j < limit; ++j) {
|
||||
sum += ((uint32*)&ride->pad_088[92])[j];
|
||||
sum += ((uint32*)&ride->var_0E4)[j];
|
||||
}
|
||||
if ((sum >> 16) > (uint32)objective_length) {
|
||||
type_already_counted[subtype_id]++;
|
||||
|
||||
@@ -234,7 +234,7 @@ static int window_wheel_input(rct_window *w, int wheel)
|
||||
continue;
|
||||
|
||||
// Originally always checked first scroll view, bug maybe?
|
||||
scroll = &w->scrolls[i * sizeof(rct_scroll)];
|
||||
scroll = &w->scrolls[i];
|
||||
if (scroll->flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE)) {
|
||||
window_scroll_wheel_input(w, i, wheel);
|
||||
return 1;
|
||||
@@ -308,7 +308,7 @@ static void window_all_wheel_input()
|
||||
if (widgetIndex != -1) {
|
||||
widget = &w->widgets[widgetIndex];
|
||||
if (widget->type == WWT_SCROLL) {
|
||||
scroll = &w->scrolls[RCT2_GLOBAL(0x01420075, uint8) * sizeof(rct_scroll)];
|
||||
scroll = &w->scrolls[RCT2_GLOBAL(0x01420075, uint8)];
|
||||
if (scroll->flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE)) {
|
||||
window_scroll_wheel_input(w, window_get_scroll_index(w, widgetIndex), wheel);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user