From 34037c40d28c9fe179d930949320090448b249e9 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 15 Nov 2015 00:54:33 +0100 Subject: Fixed too-generic constant names of gettime() types - Follow-up to 3bd77ffc0daca508352834add828766490075aee - The names were too generic (not namespaced), and were easily clashing with custom (and potential future official) constants or variables. - Constants are now prefixed with a 'GETTIME_' namespace: - GETTIME_SECOND - GETTIME_MINUTE - GETTIME_HOUR - GETTIME_WEEKDAY - GETTIME_DAYOFMONTH - GETTIME_MONTH - GETTIME_YEAR - GETTIME_DAYOFYEAR - Fixed some excessive (and some times incorrect) parentheses in various scripts using gettime(). - Updated documentation. Signed-off-by: Haru --- db/const.txt | 16 +++---- db/pre-re/item_db.conf | 9 ++-- db/re/item_db.conf | 9 ++-- doc/sample/npc_test_time.txt | 26 +++++------ doc/script_commands.txt | 38 ++++++++-------- doc/woe_time_explanation.txt | 77 +++++++++++++++------------------ npc/airports/airships.txt | 8 ++-- npc/custom/etc/airplane.txt | 4 +- npc/custom/etc/bank_kafra.txt | 2 +- npc/custom/events/valentinesdayexp.txt | 10 ++--- npc/custom/events/xmas_rings_event.txt | 2 +- npc/custom/quests/thq/THQS_QuestNPC.txt | 8 ++-- npc/custom/woe_controller.txt | 8 ++-- npc/events/idul_fitri.txt | 2 +- npc/other/arena/arena_lvl50.txt | 8 ++-- npc/other/arena/arena_lvl60.txt | 8 ++-- npc/other/arena/arena_lvl70.txt | 8 ++-- npc/other/arena/arena_lvl80.txt | 8 ++-- npc/other/arena/arena_party.txt | 8 ++-- npc/quests/first_class/tu_archer.txt | 4 +- npc/quests/guildrelay.txt | 60 ++++++++++++------------- npc/quests/newgears/2010_headgears.txt | 2 +- npc/quests/partyrelay.txt | 6 +-- npc/quests/quests_ein.txt | 4 +- npc/quests/quests_lighthalzen.txt | 8 ++-- npc/quests/quests_louyang.txt | 66 +++++++++++----------------- npc/quests/quests_moscovia.txt | 17 +++++--- npc/quests/quests_umbala.txt | 6 +-- npc/quests/the_sign_quest.txt | 19 ++++---- npc/re/quests/quests_mora.txt | 2 +- npc/re/woe-fe/invest_main.txt | 14 +++--- npc/woe-fe/agit_controller.txt | 16 +++---- npc/woe-se/agit_start_se.txt | 16 +++---- 33 files changed, 240 insertions(+), 259 deletions(-) diff --git a/db/const.txt b/db/const.txt index 7b0b7c076..792f8f56e 100644 --- a/db/const.txt +++ b/db/const.txt @@ -3400,14 +3400,14 @@ MOUNT_DRAGON_BLUE 7 MOUNT_DRAGON_RED 8 // gettime( ) -SECOND 1 -MINUTE 2 -HOUR 3 -WEEKDAY 4 -DAYOFMONTH 5 -MONTH 6 -YEAR 7 -DAYOFYEAR 8 +GETTIME_SECOND 1 +GETTIME_MINUTE 2 +GETTIME_HOUR 3 +GETTIME_WEEKDAY 4 +GETTIME_DAYOFMONTH 5 +GETTIME_MONTH 6 +GETTIME_YEAR 7 +GETTIME_DAYOFYEAR 8 // Weekday SUNDAY 0 diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index 42d75e300..b66b1198c 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -38844,7 +38844,10 @@ item_db: ( Weight: 100 Loc: 256 View: 433 - Script: <" if(gettime(6)==9&&gettime(5)>=10&&gettime(5)<=24) bonus bAllStats, 4; "> + Script: <" + if (gettime(GETTIME_MONTH) == SEPTEMBER && gettime(GETTIME_DAYOFMONTH) >= 10 && gettime(GETTIME_DAYOFMONTH) <= 24) + bonus bAllStats, 4; + "> }, { Id: 5433 @@ -63137,8 +63140,8 @@ item_db: ( Buy: 0 Weight: 80 Script: <" - if(gettime(5)!=MDiceCone) { - MDiceCone = gettime(5); + if (gettime(GETTIME_DAYOFMONTH) != MDiceCone) { + MDiceCone = gettime(GETTIME_DAYOFMONTH); percentheal 50,50; } diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 9203ef46d..2b0f70489 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -50364,7 +50364,10 @@ item_db: ( Weight: 100 Loc: 256 View: 433 - Script: <" if(gettime(6)==9&&gettime(5)>=10&&gettime(5)<=24) bonus bAllStats,4; "> + Script: <" + if (gettime(GETTIME_MONTH) == SEPTEMBER && gettime(GETTIME_DAYOFMONTH) >= 10 && gettime(GETTIME_DAYOFMONTH) <= 24) + bonus bAllStats,4; + "> }, { Id: 5433 @@ -77254,8 +77257,8 @@ item_db: ( Buy: 0 Weight: 80 Script: <" - if(gettime(5)!=MDiceCone) { - MDiceCone = gettime(5); + if (gettime(GETTIME_DAYOFMONTH) != MDiceCone) { + MDiceCone = gettime(GETTIME_DAYOFMONTH); percentheal 50,50; } "> diff --git a/doc/sample/npc_test_time.txt b/doc/sample/npc_test_time.txt index 2af1dadd8..c3d4eae1d 100644 --- a/doc/sample/npc_test_time.txt +++ b/doc/sample/npc_test_time.txt @@ -3,23 +3,23 @@ //===== By: ================================================== //= rAthena Dev Team //===== Current Version: ===================================== -//= 20070315 -//===== Description: ========================================= +//= 20151115 +//===== Description: ========================================= //= Demonstrates time commands. //============================================================ prontera,157,181,6 script Time Sample 8W_SOLDIER,{ mes "[Time Sample]"; - mes "System Tick : " + gettimetick(0); - mes " Time Tick : " + gettimetick(1); - mes " GetTime(0) : " + gettime(0); - mes " GetTime(1) : " + gettime(1) + " (Sec)"; - mes " GetTime(2) : " + gettime(2) + " (Min)"; - mes " GetTime(3) : " + gettime(3) + " (Hour)"; - mes " GetTime(4) : " + gettime(4) + " (WeekDay)"; - mes " GetTime(5) : " + gettime(5) + " (MonthDay)"; - mes " GetTime(6) : " + gettime(6) + " (Month)"; - mes " GetTime(7) : " + gettime(7) + " (Year)"; - mes " GetTimeStr : " + gettimestr("%Y-%m/%d %H:%M:%S",19); + mes " System Tick : " + gettimetick(0); + mes " Time Tick : " + gettimetick(1); + mes " GETTIME_SECOND : " + gettime(GETTIME_SECOND) + " (Sec)"; + mes " GETTIME_MINUTE : " + gettime(GETTIME_MINUTE) + " (Min)"; + mes " GETTIME_HOUR : " + gettime(GETTIME_HOUR) + " (Hour)"; + mes " GETTIME_WEEKDAY : " + gettime(GETTIME_WEEKDAY) + " (WeekDay)"; + mes "GETTIME_DAYOFMONTH : " + gettime(GETTIME_DAYOFMONTH) + " (MonthDay)"; + mes " GETTIME_MONTH : " + gettime(GETTIME_MONTH) + " (Month)"; + mes " GETTIME_YEAR : " + gettime(GETTIME_YEAR) + " (Year)"; + mes " GETTIME_DAYOFYEAR : " + gettime(GETTIME_DAYOFYEAR) + " (Day of Year)"; + mes " gettimestr : " + gettimestr("%Y-%m/%d %H:%M:%S",19); close; } diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5219eed47..dff4461af 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3181,30 +3181,28 @@ Valid types are : This function returns specified information about the current system time. -Valid types are listed in const.txt: - 1 - SECOND - Seconds (of a minute) - 2 - MINUTE - Minutes (of an hour) - 3 - HOUR - Hour (of a day) - 4 - WEEKDAY - Week day (0 for Sunday, 6 is Saturday) - - Additional: (SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY) - 5 - DAYOFMONTH - Day of the month. - 6 - MONTH - Number of the month. - - Additional: ( JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER) - 7 - YEAR - Year. - 8 - DAYOFYEAR - Day of the year. +Valid types: + 1 - GETTIME_SECOND - Seconds (of a minute) + 2 - GETTIME_MINUTE - Minutes (of an hour) + 3 - GETTIME_HOUR - Hour (of a day) + 4 - GETTIME_WEEKDAY - Week day (0 for Sunday, 6 is Saturday) + - Additional: SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY + 5 - GETTIME_DAYOFMONTH - Day of the month. + 6 - GETTIME_MONTH - Number of the month. + - Additional: JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER + 7 - GETTIME_YEAR - Year + 8 - GETTIME_DAYOFYEAR - Day of the year. It will only return numbers based on types. Example : - if ( gettime(WEEKDAY) == SATURDAY ) { + if (gettime(GETTIME_WEEKDAY) == SATURDAY) { mes "It's a Saturday. I don't work on Saturdays."; + } else if (gettime(GETTIME_MONTH) == JANUARY) { + mes "It's January. I don't work on January."; + } else if (gettime(GETTIME_MONTH) == OCTOBER && gettime(GETTIME_DAYOFMONTH) == 31) { + mes "It's Halloween."; } - else if ( gettime(MONTH) == JANUARY ) { - mes "It's a January. I don't work on January."; - } - else if ( gettime(MONTH) == OCTOBER && gettime(DAYOFMONTH) == 31 ) { - mes "It's a Halloween."; - } - + --------------------------------------- *gettimestr(,) @@ -7578,7 +7576,7 @@ OnClock0600: end; OnInit: // setting correct mode upon server start-up - if(gettime(3)>=6 && gettime(3)<18) end; + if (gettime(GETTIME_HOUR) >= 6 && gettime(GETTIME_HOUR) < 18) end; OnClock1800: night; end; diff --git a/doc/woe_time_explanation.txt b/doc/woe_time_explanation.txt index 9f288eae7..d030355f8 100644 --- a/doc/woe_time_explanation.txt +++ b/doc/woe_time_explanation.txt @@ -3,7 +3,7 @@ //===== By: ================================================== //= erKURITA //===== Current Version: ===================================== -//= 20120717 +//= 20151115 //===== Description: ========================================= //= Details on the behavior of the default WoE controller. //============================================================ @@ -15,19 +15,8 @@ OnClock