1 // _________ __ __ 2 // / _____// |_____________ _/ |______ ____ __ __ ______ 3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 6 // \/ \/ \//_____/ \/ 7 // ______________________ ______________________ 8 // T H E W A R B E G I N S 9 // Stratagus - A free fantasy real time strategy game engine 10 // 11 /**@name time_period_schedule.cpp - The time period schedule source file. */ 12 // 13 // (c) Copyright 2018-2019 by Andrettin 14 // 15 // This program is free software; you can redistribute it and/or modify 16 // it under the terms of the GNU General Public License as published by 17 // the Free Software Foundation; only version 2 of the License. 18 // 19 // This program is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU General Public License for more details. 23 // 24 // You should have received a copy of the GNU General Public License 25 // along with this program; if not, write to the Free Software 26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 27 // 02111-1307, USA. 28 // 29 30 //@{ 31 32 /*---------------------------------------------------------------------------- 33 -- Includes 34 ----------------------------------------------------------------------------*/ 35 36 #include "stratagus.h" 37 38 #include "time/time_period_schedule.h" 39 40 /*---------------------------------------------------------------------------- 41 -- Variables 42 ----------------------------------------------------------------------------*/ 43 44 /*---------------------------------------------------------------------------- 45 -- Functions 46 ----------------------------------------------------------------------------*/ 47 48 /** 49 ** @brief Calculate the hour multiplier used to for the passage of in-game hours relating to this schedule 50 */ CalculateHourMultiplier()51void CTimePeriodSchedule::CalculateHourMultiplier() 52 { 53 int multiplier = 1; 54 55 if (this->TotalHours > DEFAULT_HOURS_PER_DAY) { 56 multiplier = this->GetDefaultHourMultiplier(); 57 if (this->TotalHours > this->GetDefaultTotalHours()) { 58 multiplier += (this->TotalHours * 100 / this->GetDefaultTotalHours() - 100) * this->GetDefaultHourMultiplier() / HOUR_MULTIPLIER_DIVIDER / 100; //this makes duration increases effectively level off after the default number of days per year; at the same time, this formula also serves to calculate the hour multiplier for duration lengths greater than a week and smaller than a year 59 } else if (this->TotalHours < this->GetDefaultTotalHours()) { 60 long long int multiplier_modifier = this->TotalHours * 100 / this->GetDefaultTotalHours(); 61 multiplier_modifier -= 100; 62 multiplier_modifier *= this->GetDefaultHourMultiplier(); 63 multiplier_modifier /= 100; 64 multiplier += multiplier_modifier; 65 } 66 } 67 68 this->HourMultiplier = std::max(multiplier, 1); 69 } 70 71 //@} 72