summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-07-12 23:25:20 -0300
committerJesusaves <cpntb1@ymail.com>2021-07-12 23:25:20 -0300
commita7e396a0d5459f401a916d7361ece608fed0c49f (patch)
tree05d020ec4f052e6f38a2bf1872a6fc8b3954eb1e
parent85f6f317c6f086c1155eb5a45c93781f4cf95943 (diff)
downloadserverdata-a7e396a0d5459f401a916d7361ece608fed0c49f.tar.gz
serverdata-a7e396a0d5459f401a916d7361ece608fed0c49f.tar.bz2
serverdata-a7e396a0d5459f401a916d7361ece608fed0c49f.tar.xz
serverdata-a7e396a0d5459f401a916d7361ece608fed0c49f.zip
Reimplement addnpctimer() altough in a less efficient way.
Father Time inherited it. Cycles every 1s while Weather cycles every 2.5s I would like to stop adding expensive hacks, please ^^
-rwxr-xr-xgit/hooks/post-merge17
-rw-r--r--npc/annuals/fathertime.txt46
2 files changed, 42 insertions, 21 deletions
diff --git a/git/hooks/post-merge b/git/hooks/post-merge
deleted file mode 100755
index 8a8b6bfc..00000000
--- a/git/hooks/post-merge
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-# Copy or symlink this into your .git/hooks directory.
-# E.g., from the top:
-# ln -s ../../git/hooks/post-merge .git/hooks
-# or cp git/hooks/post-merge .git/hooks
-# It may also be beneficial to install as a post-checkout hook
-
-# If we have local changes in the submodule, rebase or merge them
-# (rebase is better but dangerous in some circumstances)
-# git submodule update --rebase
-git submodule update --merge
-make news
-
-# WARNING: to people with push access.
-# it is essential that changes to the client data be pushed before changes to server data
-# Also, you may find this useful: (you should always clone using the git:// url)
-# git config --global url.git@github.com:.pushInsteadOf git://github.com
diff --git a/npc/annuals/fathertime.txt b/npc/annuals/fathertime.txt
index 6a92e7dc..bb2361a1 100644
--- a/npc/annuals/fathertime.txt
+++ b/npc/annuals/fathertime.txt
@@ -2,17 +2,55 @@
end;
OnInit:
+ .evtc = htnew; // event : time in seconds
if (debug >= 2) end;
- donpcevent strnpcinfo(0) + "::OnTimer20000";
- end;
OnClock0000:
-OnTimer20000:
donpcevent "#XmasConfig::OnCommandRestartQuest";
donpcevent "#HalloweenConfig::OnCommandRestartQuest";
donpcevent "Easter Eggs::OnCheckEaster";
- //initnpctimer;
+ initnpctimer;
+ end;
+
+OnTimer1000:
+ // There are no NPC timers ongoing, loop forever
+ if (!htsize(.evtc)) {
+ initnpctimer;
+ end;
+ }
+ // Otherwise, we got a job to do
+ .@hti = htiterator(.evtc);
+ .@cur = gettimetick(2);
+ for (.@key$ = htinextkey(.@hti); hticheck(.@hti); .@key$ = htinextkey(.@hti))
+ {
+ .@target=htget(.evtc, .@key$, 0);
+ // Not yet expired
+ if (.@target > .@cur)
+ continue;
+ // Execute NPC Event after removing it from hashtable
+ htput(.evtc, .@key$, 0);
+ donpcevent(.@key$);
+ }
+ // Deallocate memory and cycle forever
+ htidelete(.@hti);
+ initnpctimer;
end;
+
+public function addnpcevent {
+ .@ev$=getarg(1);
+ .@t=getarg(0);
+ htput(.evtc, .@ev$, gettimetick(2)+.@t);
+ return true;
+}
+
+// NPC Father Time end
+}
+
+function script addnpctimer {
+ .@t=getarg(0)/1000;
+ .@ev$=getarg(1);
+ "#HolidayConfig"::addnpcevent(.@t, .@ev$);
+ return true;
}
function script TMWBirthday {