Exemplo n.º 1
0
/**
 * Pay an amount of money.
 * rct2: 0x069C674
 * @param amount (eax)
 * @param type passed via global var 0x0141F56C, our type is that var/4.
 **/
void finance_payment(money32 amount, rct_expenditure_type type)
{
	money32 cur_money = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32));
	money32 new_money = cur_money - amount;

	//overflow check
	RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(new_money);
	RCT2_ADDRESS(RCT2_ADDRESS_EXPENDITURE_TABLE, money32)[type] -= amount;
	if (RCT2_ADDRESS(0x00988E60, uint32)[type] & 1)
		RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_EXPENDITURE, money32) -= amount; // Cumulative amount of money spent this day
	

	RCT2_GLOBAL(0x009A9804, uint32) |= 1; // money diry flag
	window_invalidate_by_id(WC_FINANCES, 0);
	window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0);
}
Exemplo n.º 2
0
static void window_cheats_money_mouseup()
{
	int i;
	short widgetIndex;
	rct_window *w;

	__asm mov widgetIndex, dx
	__asm mov w, esi

	switch (widgetIndex) {
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_TAB_1:
	case WIDX_TAB_2:
		window_cheats_set_page(w, widgetIndex - WIDX_TAB_1);
		break;
	case WIDX_HIGH_MONEY:
		i = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32));

		if (i < INT_MAX - CHEATS_MONEY_INCREMENT) {
			i += CHEATS_MONEY_INCREMENT;
		}
		else {
			i = INT_MAX;
		}
		RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(i);
		window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0);
		break;
	}
}
Exemplo n.º 3
0
static void window_cheats_guests_mouseup()
{
	short widgetIndex;
	rct_window *w;

	__asm mov widgetIndex, dx
	__asm mov w, esi
	rct_peep* peep;
	uint16 sprite_idx;

	switch (widgetIndex) {
	case WIDX_CLOSE:
		window_close(w);
		break;
	case WIDX_TAB_1:
	case WIDX_TAB_2:
		window_cheats_set_page(w, widgetIndex - WIDX_TAB_1);
		break;
	case WIDX_HAPPY_GUESTS:
		for (sprite_idx = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_idx != SPRITE_INDEX_NULL; sprite_idx = peep->next) {
			peep = &(RCT2_ADDRESS(RCT2_ADDRESS_SPRITE_LIST, rct_sprite)[sprite_idx].peep);
			if (peep->type != PEEP_TYPE_GUEST)
				continue;
			if (peep->var_2A != 0)
				continue;
			peep->happiness = 255;
		}
		window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0);
		break;
	}
}
Exemplo n.º 4
0
/*
 * Update status of marketing campaigns and send produce a news item when they have finished.
 * rct2: 0x0069E0C1
 **/
void marketing_update()
{
	for (int campaign = 0; campaign < ADVERTISING_CAMPAIGN_COUNT; campaign++) {
		uint8 campaign_weeks_left = RCT2_ADDRESS(0x01358102, uint8)[campaign];
		if (campaign_weeks_left == 0)
			continue;

		window_invalidate_by_id(WC_FINANCES, 0);

		// High bit marks the campaign as inactive, on first check the campaign is set actice
		// this makes campaigns run a full x weeks even when started in the middle of a week
		RCT2_ADDRESS(0x01358102, uint8)[campaign] &= ~(1 << 7);
		if (campaign_weeks_left & (1 << 7))
			continue;
		
		RCT2_ADDRESS(0x01358102, uint8)[campaign]--;
		if (campaign_weeks_left - 1 != 0)
			continue;

		int campaign_item = RCT2_ADDRESS(0x01358116, uint8)[campaign];

		// This sets the string parameters for the marketing types that have an argument.
		if (campaign == ADVERTISING_CAMPAIGN_RIDE_FREE || campaign == ADVERTISING_CAMPAIGN_RIDE) {
			RCT2_GLOBAL(0x013CE952, uint16) = RCT2_GLOBAL(0x01362942 + 304 * campaign_item, uint16);
			RCT2_GLOBAL(0x013CE954, uint32) = RCT2_GLOBAL(0x01362944 + 152 * campaign_item, uint32);
		} else if (campaign == ADVERTISING_CAMPAIGN_FOOD_OR_DRINK_FREE) {
			campaign_item += 2016;
			if (campaign_item >= 2048)
				campaign_item += 96;
			RCT2_GLOBAL(0x013CE952, uint16) = campaign_item;
		}

		news_item_add_to_queue(NEWS_ITEM_MONEY, STR_MARKETING_FINISHED_BASE + campaign, 0);
	}
}
Exemplo n.º 5
0
/**
 *
 *  rct2: 0x0066DF17
 */
static void window_save_prompt_close()
{
    // Unpause the game
    RCT2_GLOBAL(0x009DEA6E, uint8) &= ~2;
    unpause_sounds();
    window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);
}
Exemplo n.º 6
0
/**
 *
 *  rct2: 0x006A852F
 */
static void window_footpath_close()
{
    rct_window *w;

    window_get_register(w);

    RCT2_CALLPROC_EBPSAFE(0x006A7831);
    viewport_set_visibility(0);
    RCT2_CALLPROC_EBPSAFE(0x0068AB1B);
    RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~2;
    window_invalidate_by_id(WC_TOP_TOOLBAR, 0);
    hide_gridlines();
}
Exemplo n.º 7
0
/**
 * 
 *  rct2: 0x00667C15
 */
static void game_pause_toggle()
{
	char input_bl;

	__asm mov input_bl, bl

	if (input_bl & 1) {
		RCT2_GLOBAL(0x009DEA6E, uint32) ^= 1;
		window_invalidate_by_id(WC_TOP_TOOLBAR, 0);
		if (RCT2_GLOBAL(0x009DEA6E, uint32) & 1)
			pause_sounds();
		else
			unpause_sounds();
	}

	__asm mov ebx, 0
}
Exemplo n.º 8
0
/**
 * 
 *  rct2: 0x006E3E91
 */
void set_shortcut(int key)
{
	int i;

	// Unmap shortcut that already uses this key
	for (i = 0; i < 32; i++) {
		if (key == gShortcutKeys[i]) {
			gShortcutKeys[i] = 0xFFFF;
			break;
		}
	}

	// Map shortcut to this key
	gShortcutKeys[RCT2_GLOBAL(0x009DE511, uint8)] = key;
	window_close_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0);
	window_invalidate_by_id(WC_KEYBOARD_SHORTCUT_LIST, 0);
	config_save();
}
Exemplo n.º 9
0
static void window_cheats_mouseup()
{
    int i;
    short widgetIndex;
    rct_window *w;

    __asm mov widgetIndex, dx
    __asm mov w, esi

    switch (widgetIndex) {
    case WIDX_CLOSE:
        window_close(w);
        break;
    case WIDX_HIGH_MONEY:
        i = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32));
        i += 100000;
        RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32) = ENCRYPT_MONEY(i);

        window_invalidate_by_id(0x40 | WC_BOTTOM_TOOLBAR, 0);
        break;
    }
}
Exemplo n.º 10
0
/**
 *
 *  rct2: 0x0066DCBE
 */
void window_save_prompt_open()
{
    int stringId, x, y;
    rct_window* window;
    unsigned short prompt_mode;
    rct_widget *widgets;
    uint64 enabled_widgets;

    prompt_mode = RCT2_GLOBAL(RCT2_ADDRESS_SAVE_PROMPT_MODE, uint16);

    // do not show save prompt if we're in the title demo and click on load game
    if (prompt_mode != PM_QUIT && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) {
        game_load_or_quit_no_save_prompt();
        return;
    }

    // Check if window is already open
    window = window_bring_to_front_by_id(WC_SAVE_PROMPT, 0);
    if (window) {
        window_close(window);
    }

    if (prompt_mode == PM_QUIT) {
        widgets = window_quit_prompt_widgets;
        enabled_widgets =
            (1 << WQIDX_CLOSE) |
            (1 << WQIDX_OK) |
            (1 << WQIDX_CANCEL);
        x = 177;
        y = 34;
    } else {
        widgets = window_save_prompt_widgets;
        enabled_widgets =
            (1 << WIDX_CLOSE) |
            (1 << WIDX_SAVE) |
            (1 << WIDX_DONT_SAVE) |
            (1 << WIDX_CANCEL);
        x = 260;
        y = 50;
    }

    window = window_create(
                 (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - x / 2,
                 max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - y / 2),
                 x,
                 y,
                 (uint32*)window_save_prompt_events,
                 WC_SAVE_PROMPT,
                 WF_TRANSPARENT | WF_STICK_TO_FRONT
             );

    window->widgets = widgets;
    window->enabled_widgets = enabled_widgets;
    window_init_scroll_widgets(window);
    window->colours[0] = 154;

    // Pause the game
    RCT2_GLOBAL(0x009DEA6E, uint8) |= 2;
    pause_sounds();
    window_invalidate_by_id(0x80 | WC_TOP_TOOLBAR, 0);

    stringId = prompt_mode + STR_LOAD_GAME;
    if (stringId == STR_LOAD_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
        stringId = STR_LOAD_LANDSCAPE;
    if (stringId == STR_QUIT_GAME && RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)
        stringId = STR_QUIT_SCENARIO_EDITOR;
    window_save_prompt_widgets[WIDX_TITLE].image = stringId;
    window_save_prompt_widgets[WIDX_LABEL].image = prompt_mode + STR_SAVE_BEFORE_LOADING;

    if (!gGeneral_config.confirmation_prompt) {
        /* game_load_or_quit_no_save_prompt() will exec requested task and close this window
         * immediately again.
         * TODO restructure these functions when we're sure game_load_or_quit_no_save_prompt()
         * and game_load_or_quit() are not called by the original binary anymore.
         */

        if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0D) {
            game_load_or_quit_no_save_prompt();
            return;
        }

        if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 0) {
            if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) != 1) {
                RCT2_CALLPROC_EBPSAFE(0x0066EE54);
                game_load_or_quit_no_save_prompt();
                return;
            } else {
                tutorial_stop();
                game_load_or_quit_no_save_prompt();
                return;
            }
        }

        if (RCT2_GLOBAL(0x009DEA66, uint16) < 3840) {
            game_load_or_quit_no_save_prompt();
            return;
        }
    }

}