From b771141707e400648c76fc3bf3843d67a841922c Mon Sep 17 00:00:00 2001
From: Jessica Tölke <jtoelke@mail.upb.de>
Date: Fri, 30 Dec 2011 00:45:14 +0100
Subject: Handle quests on 019-1 in flags instead of one player variable for
 each. Added those player variables to the function ClearVariables.

---
 world/map/db/const.txt                 |  2 ++
 world/map/npc/019-1/santa_helper.txt   |  6 +++---
 world/map/npc/019-1/snowman.txt        |  6 +++---
 world/map/npc/functions/clear_vars.txt | 14 ++++++++++++--
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/world/map/db/const.txt b/world/map/db/const.txt
index 3d4443d1..85a5d68c 100644
--- a/world/map/db/const.txt
+++ b/world/map/db/const.txt
@@ -381,6 +381,8 @@ FLAG_TOWEL_COMPLETED	32	// got the towel from the towel npc
 FLAG_ANDRA_HELPED	64	// Knows Andra and agreed to help her
 FLAG_ROSSI_COMPLETED	128	// Completed the Rossi Quest
 FLAG_TUTORIAL_DONE	256	// player completed tutorial (or entered the tutorial area from outside after it was added)
+FLAG_SNOWMAN	512	// player gave candy to the snowman
+FLAG_SANTAS_HELPER	1024	// player gave presents to Santa's helper
 
 DOCK_tulimshar	1
 DOCK_hurnscald	2
diff --git a/world/map/npc/019-1/santa_helper.txt b/world/map/npc/019-1/santa_helper.txt
index 9c148407..f7d1f36e 100644
--- a/world/map/npc/019-1/santa_helper.txt
+++ b/world/map/npc/019-1/santa_helper.txt
@@ -2,8 +2,8 @@
 // quest made seasonal and adapted to new scripting standards by Jenalya
 
 019-1.gat,74,75,0|script|Santa's Helper|105,{
-    if (ChristmasQuest2 == 1) goto L_Done;
-
+    callfunc "ClearVariables";
+    if (FLAGS & FLAG_SANTAS_HELPER) goto L_Done;
     if ($@month == 12) goto L_Quest;
 
     mes "[Santa's Helper]";
@@ -54,7 +54,7 @@ L_Y:
     delitem "BluePresentBox", @blue_amount;
     delitem "GreenPresentBox", @green_amount;
     getitem "TurtleneckSweater", 1;
-    set ChristmasQuest2,1;
+    set FLAGS, FLAGS | FLAG_SANTAS_HELPER;
     goto L_Close;
 
 L_R:
diff --git a/world/map/npc/019-1/snowman.txt b/world/map/npc/019-1/snowman.txt
index 08513eae..529a7a50 100644
--- a/world/map/npc/019-1/snowman.txt
+++ b/world/map/npc/019-1/snowman.txt
@@ -2,8 +2,8 @@
 // quest made seasonal and adapted to new scripting standards by Jenalya
 
 019-1.gat,77,44,0|script|Snowman|129,{
-    if( ChristmasQuest == 1) goto L_Done;
-
+    callfunc "ClearVariables";
+    if (FLAGS & FLAG_SNOWMAN) goto L_Done;
     if ($@month == 12 || $@month == 1 || $@month == 2) goto L_Quest;
 
     mes "A beautiful snowman. It looks almost alive.";
@@ -52,7 +52,7 @@ L_Sure:
     mes "[Snowman]";
     mes "\"Here you go, enjoy your new hat!\"";
     getitem "SantaHat", 1;
-    set ChristmasQuest, 1;
+    set FLAGS, FLAGS | FLAG_SNOWMAN;
     goto L_Close;
 
 L_Need:
diff --git a/world/map/npc/functions/clear_vars.txt b/world/map/npc/functions/clear_vars.txt
index eed42a44..14794c95 100644
--- a/world/map/npc/functions/clear_vars.txt
+++ b/world/map/npc/functions/clear_vars.txt
@@ -96,12 +96,22 @@ function|script|ClearVariables|{
 
 
     //These lines are needed to migrate stuff from variables to flags
-    if (Open_Underground_Palace_Barrier) set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND;
+    if (Open_Underground_Palace_Barrier)
+        set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND;
     set Open_Underground_Palace_Barrier, 0;
 
-    if (Naem_Quest_Done) set FLAGS, FLAGS | FLAG_GOT_NAEM_GLOVES;
+    if (Naem_Quest_Done)
+        set FLAGS, FLAGS | FLAG_GOT_NAEM_GLOVES;
     set Naem_Quest_Done, 0;
 
+    if (ChristmasQuest)
+        set FLAGS, FLAGS | FLAG_SNOWMAN;
+    set ChristmasQuest, 0;
+
+    if (ChristmasQuest2)
+        set FLAGS, FLAGS | FLAG_SANTAS_HELPER;
+    set ChristmasQuest2, 0;
+
     if (#BankAccount < 0)
         goto FixBank;
 
-- 
cgit v1.2.3-70-g09d2