diff options
-rw-r--r-- | db/const.txt | 6 | ||||
-rw-r--r-- | npc/002-3_Desert_mines/mine_triggertwo.txt | 4 | ||||
-rw-r--r-- | npc/002-3_Desert_mines/naem.txt | 8 | ||||
-rw-r--r-- | npc/functions/clear_vars.txt | 8 | ||||
-rwxr-xr-x | tools/showvars.py | 61 |
5 files changed, 61 insertions, 26 deletions
diff --git a/db/const.txt b/db/const.txt index 07027254..f51f1dfe 100644 --- a/db/const.txt +++ b/db/const.txt @@ -250,8 +250,10 @@ MFLAG_ELANORE_OMAR 32768 // Told Omar about Elanore's involvement MFLAG_KNOWS_UNFOCUS_RECIPE 65536 // Luca told me about how to unfocus -//Flags set in the FLAGS variable: -FLAG_HAS_BOWLER_BURNSDAY 1 +// Flags set in the FLAGS variable: +FLAG_HAS_BOWLER_BURNSDAY 1 // every year's poem at burns day, shannon gives you a bowler hat +FLAG_OPENED_UNDERGROUND 2 // this flag is a replacement for variable Open_Underground_Palace_Barrier, which was used only as bool +FLAG_GOT_NAEM_GLOVES 4 // this replaces Naem_Quest_Done, which was used as a bool variable DOCK_tulimshar 1 DOCK_hurnscald 2 diff --git a/npc/002-3_Desert_mines/mine_triggertwo.txt b/npc/002-3_Desert_mines/mine_triggertwo.txt index 21e1d965..5d005620 100644 --- a/npc/002-3_Desert_mines/mine_triggertwo.txt +++ b/npc/002-3_Desert_mines/mine_triggertwo.txt @@ -4,7 +4,7 @@ if (TMW_Quest == 36) goto L_Trigger_2; if (TMW_Quest == 35) goto L_Trigger_Wrong_2; - if (TMW_Quest == 34) goto L_Trigger_Wrong_2; + if (TMW_Quest == 34) goto L_Trigger_Wrong_2; mes "There is a large button on the ground. A key hole appears on the button."; close; @@ -42,7 +42,7 @@ L_Right_2: L_Left_2: set TMW_Quest, 37; - set Open_Underground_Palace_Barrier, 1; + set FLAGS, FLAGS | FLAG_OPENED_UNDERGROUND; mes "You turn the key left. A clicking sound echoes throughout the mine, followed by a loud thump."; close; diff --git a/npc/002-3_Desert_mines/naem.txt b/npc/002-3_Desert_mines/naem.txt index aca3e0c2..5f0f9bd6 100644 --- a/npc/002-3_Desert_mines/naem.txt +++ b/npc/002-3_Desert_mines/naem.txt @@ -2,8 +2,8 @@ 002-3.gat,85,97,6 script Naem 109,{ - if (Naem_Quest_Done == 1) goto L_Naem_Complete; - if (Open_Underground_Palace_Barrier == 1) goto L_Naem_Gloves; + if (FLAGS & FLAG_GOT_NAEM_GLOVES) goto L_Naem_Complete; + if (FLAGS & FLAG_OPENED_UNDERGROUND) goto L_Naem_Gloves; if (TMW_Quest == 34) goto L_Naem_Code; if (TMW_Quest == 33) goto L_Naem_Lt; if (TMW_Quest == 32) goto L_Naem_Memory; @@ -113,12 +113,12 @@ L_Naem_Code: L_Naem_Gloves: getinventorylist; if (@inventorylist_count == 100) goto L_Nathan_TooMany; - set Naem_Quest_Done, 1; + set FLAGS, FLAGS | FLAG_GOT_NAEM_GLOVES; getitem "MinerGloves", 1; mes "[Naem]"; mes "\"Hey, good job on getting that together! Take these gloves, they might prove useful in the underground palace.\""; close; - + L_Naem_TooMany: mes "[Naem]"; mes "\"You have too many items for me to give you a reward.\""; diff --git a/npc/functions/clear_vars.txt b/npc/functions/clear_vars.txt index ae83968f..62eada3d 100644 --- a/npc/functions/clear_vars.txt +++ b/npc/functions/clear_vars.txt @@ -94,6 +94,14 @@ function script ClearVariables { set Xmas2010, 0; set Golbenez_Inn_Cost, 0; + + //These lines are needed to migrate stuff from variables to flags + 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; + set Naem_Quest_Done, 0; + if (#BankAccount < 0) goto FixBank; return; diff --git a/tools/showvars.py b/tools/showvars.py index 4b3d0cb4..94ab3338 100755 --- a/tools/showvars.py +++ b/tools/showvars.py @@ -16,6 +16,7 @@ def handleFile(fname): f = open(fname) lines = f.readlines(); f.close() + rm=[] for l in lines: #remove comments line = l.split(r"//")[0] @@ -39,43 +40,67 @@ def handleFile(fname): if endpos>0: #ok its a oneliner, the comma is in the same line: varname = line[0:endpos].strip() - if varname.startswith("@"): - continue - if varname.startswith("$"): - continue - if varname in allvars: - if not fname in allvars[varname]: - allvars[varname] += [fname] + assignment = line[endpos+1:].strip()[:-1] # remove semicolon + if assignment != "0": + if varname.startswith("@"): + continue + if varname.startswith("$"): + continue + if varname in allvars: + if not fname in allvars[varname]: + allvars[varname] += [fname] + else: + allvars[varname] = [fname] else: - allvars[varname] = [fname] + #print fname + if fname == "." + os.sep + "functions" + os.sep + "clear_vars.txt": + rm += [varname] + else: # ok error, you need to check manually: print "\tline:\t",line + return rm allvars = {} - +rmvars = [] print "please check manully for vars in here:" os.chdir(".."+os.sep+"npc") + for tpl in os.walk("."): for fname in tpl[2]: - handleFile(tpl[0]+os.sep+fname) + rmvars += handleFile(tpl[0]+os.sep+fname) # now check if the variable is not in npc/functions/clear_vars.txt, if so remove it -checkstring = "." + os.sep + "functions" + os.sep + "clear_vars.txt" -rm = [] +#~ checkstring = "." + os.sep + "functions" + os.sep + "clear_vars.txt" +#~ rm = [] +#~ for var in allvars: + #~ if checkstring in allvars[var]: + #~ rm += [var] + +unusedcounter=0 +usedcounter=0 +print "These variables are found in the scripts, which are deleted in clear_vars" for var in allvars: - if checkstring in allvars[var]: - rm += [var] + if not var in rmvars: + continue + + unusedcounter+=1 + print "\t",var + if options.verbose: + for fname in allvars[var]: + print "\t","\t", fname -#now really remove these vars -for var in rm: - del allvars[var] print "These variables are valid variables of the scripts:" for var in allvars: + if var in rmvars: + continue + + usedcounter+=1 print "\t",var if options.verbose: for fname in allvars[var]: print "\t","\t", fname -print "number of vars:", len(allvars) +print "number of vars used:", usedcounter +print "number of vars cleared:", unusedcounter |