diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-10 03:47:27 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-10 03:47:27 +0000 |
commit | a4a5d536b46215d8040b6ef40f4b5f5141e5b299 (patch) | |
tree | 4688e08ef12fedcf4d9851cc28e8cefee87f04d5 /src | |
parent | 25892a33371561def57c1b554165b0a8220e9114 (diff) | |
download | hercules-a4a5d536b46215d8040b6ef40f4b5f5141e5b299.tar.gz hercules-a4a5d536b46215d8040b6ef40f4b5f5141e5b299.tar.bz2 hercules-a4a5d536b46215d8040b6ef40f4b5f5141e5b299.tar.xz hercules-a4a5d536b46215d8040b6ef40f4b5f5141e5b299.zip |
Minor improvement on npc_event_do_clock, moved it so that its only assigned when its actually used
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16895 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r-- | src/map/npc.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/src/map/npc.c b/src/map/npc.c index 41069c015..7389808c5 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -402,38 +402,43 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data) time_t timer; struct tm* t; char buf[64]; - char* day; int c = 0; timer = time(NULL); t = localtime(&timer); - switch (t->tm_wday) { - case 0: day = "Sun"; break; - case 1: day = "Mon"; break; - case 2: day = "Tue"; break; - case 3: day = "Wed"; break; - case 4: day = "Thu"; break; - case 5: day = "Fri"; break; - case 6: day = "Sat"; break; - default:day = ""; break; - } - if (t->tm_min != ev_tm_b.tm_min ) { + char* day; + + switch (t->tm_wday) { + case 0: day = "Sun"; break; + case 1: day = "Mon"; break; + case 2: day = "Tue"; break; + case 3: day = "Wed"; break; + case 4: day = "Thu"; break; + case 5: day = "Fri"; break; + case 6: day = "Sat"; break; + default:day = ""; break; + } + sprintf(buf,"OnMinute%02d",t->tm_min); - c+=npc_event_doall(buf); + c += npc_event_doall(buf); + sprintf(buf,"OnClock%02d%02d",t->tm_hour,t->tm_min); - c+=npc_event_doall(buf); + c += npc_event_doall(buf); + sprintf(buf,"On%s%02d%02d",day,t->tm_hour,t->tm_min); - c+=npc_event_doall(buf); + c += npc_event_doall(buf); } - if (t->tm_hour!= ev_tm_b.tm_hour) { + + if (t->tm_hour != ev_tm_b.tm_hour) { sprintf(buf,"OnHour%02d",t->tm_hour); - c+=npc_event_doall(buf); + c += npc_event_doall(buf); } - if (t->tm_mday!= ev_tm_b.tm_mday) { + + if (t->tm_mday != ev_tm_b.tm_mday) { sprintf(buf,"OnDay%02d%02d",t->tm_mon+1,t->tm_mday); - c+=npc_event_doall(buf); + c += npc_event_doall(buf); } memcpy(&ev_tm_b,t,sizeof(ev_tm_b)); |