diff --git a/devTools/check.py b/devTools/check.py index 8a0a99e23794c718ef005dcf792f5815bacf4e2e..a995652213dbecb02dbe81b729dacc2de4726281 100755 --- a/devTools/check.py +++ b/devTools/check.py @@ -3,8 +3,11 @@ import fileinput import re import sys +WARNING = '\033[93m' +ENDC = '\033[0m' + def myprint(*args): - print(filename + ":",*args) + print(WARNING, filename + ":", ENDC,*args) def yield_line_and_islastline(f): global filename @@ -26,43 +29,49 @@ pattern = re.compile(r'(<<(\/?) *(if|for|else|switch|case)[^<>]*)') tagfound = [] -for line, isLastLine in yield_line_and_islastline(fileinput.input()): - for (whole,end,tag) in re.findall(pattern,line): - if tag == "else" or tag == 'case': - if len(tagfound) == 0: - myprint("Found", tag, "but with no opening tag:") - myprint(" ", linenumber,":", whole) - fileinput.nextfile() - lasttag = tagfound[-1] - if (tag == "else" and lasttag["tag"] != "if") or (tag == "case" and lasttag["tag"] != "switch"): - myprint("Mismatched else: Opening tag was:") - myprint(" ",lasttag["linenumber"],":", lasttag["whole"]) - myprint("But this tag was:") - myprint(" ",linenumber,":", whole) - fileinput.nextfile() - break - elif end != '/': - tagfound.append({"whole": whole, "linenumber":linenumber,"tag":tag}) - else: - if len(tagfound) == 0: - myprint("Found closing tag but with no opening tag:") - myprint(" ", linenumber,":", whole) - fileinput.nextfile() - break - lasttag = tagfound.pop() - if lasttag["tag"] != tag: - myprint("Mismatched tag: Opening tag was:") - myprint(" ",lasttag["linenumber"],":", lasttag["whole"]) - myprint("Closing tag was:") - myprint(" ",linenumber,":", whole) - fileinput.nextfile() - break +try: + for line, isLastLine in yield_line_and_islastline(fileinput.input()): + for (whole,end,tag) in re.findall(pattern,line): + if tag == "else" or tag == 'case': + if len(tagfound) == 0: + myprint("Found", tag, "but with no opening tag:") + myprint(" ", linenumber,":", whole) + fileinput.nextfile() + lasttag = tagfound[-1] + if (tag == "else" and lasttag["tag"] != "if") or (tag == "case" and lasttag["tag"] != "switch"): + myprint("Mismatched else: Opening tag was:") + myprint(" ",lasttag["linenumber"],":", lasttag["whole"]) + myprint("But this tag was:") + myprint(" ",linenumber,":", whole) + fileinput.nextfile() + break + elif end != '/': + tagfound.append({"whole": whole, "linenumber":linenumber,"tag":tag}) + else: + if len(tagfound) == 0: + myprint("Found closing tag but with no opening tag:") + myprint(" ", linenumber,":", whole) + fileinput.nextfile() + break + lasttag = tagfound.pop() + if lasttag["tag"] != tag: + myprint("Mismatched tag: Opening tag was:") + myprint(" ",lasttag["linenumber"],":", lasttag["whole"]) + myprint("Closing tag was:") + myprint(" ",linenumber,":", whole) + fileinput.nextfile() + break + + if isLastLine: + if len(tagfound) != 0: + myprint("End of file found but", len(tagfound), ("tag hasn't" if len(tagfound)==1 else "tags haven't"), "been closed:") + for tag in tagfound: + myprint(" ", tag["linenumber"],":", tag["whole"]) + tagfound = [] +except UnicodeDecodeError as e: + myprint(e) + print(" Hint: In linux, you can get more details about unicode errors by running:") + print(" isutf8", filename) - if isLastLine: - if len(tagfound) != 0: - myprint("End of file found but", len(tagfound), ("tag hasn't" if len(tagfound)==1 else "tags haven't"), "been closed:") - for tag in tagfound: - myprint(" ", tag["linenumber"],":", tag["whole"]) - tagfound = [] diff --git a/sanityCheck b/sanityCheck index 386a44381a7cd6f9771e7a90e9c1b59900070e4a..1563ed06ad6905516c16a561ad7b2f46be14a77e 100755 --- a/sanityCheck +++ b/sanityCheck @@ -4,50 +4,72 @@ if [ ! -d ".git" ]; then echo "No .git repo found - skipping sanity checks" exit 0 fi + +WARNING='\033[93m' +WARNING='\033[93m' +ENDC='\033[0m' + +myprint() { + while read data; do + echo -n -e "[$1]$WARNING" + echo "$data" + done +} + GREP="git grep -n --color" # Check for missing right angle bracket: <</if> -$GREP "<</[^>]*>[^>]" -- 'src/*' | sed 's/^/[Rule1] /' -$GREP "<<[^>()]*>[^()<>"$'\r]*\r'"\?$" -- 'src/*' | sed 's/^/[Rule2] /' +$GREP "<</[^>]*>[^>]" -- 'src/*' | myprint "MissingClosingAngleBracket" +$GREP "<<[^>()]*>[^()<>"$'\r]*\r'"\?$" -- 'src/*' | myprint "MissingClosingAngleBracket" # Check for missing left angle bracket: </if>> -$GREP "[^<]</[^<>]*>>" -- 'src/*' | sed 's/^/[Rule3] /' +$GREP "[^<]</[^<>]*>>" -- 'src/*' | myprint "MissingOpeningAngleBracket2" # Check for accidental assignment. e.g.: <<if $foo = "hello">> -$GREP "<<[ ]*if[^>=]*[^><\!=]=[^=][^>]*>>" -- 'src/*' | sed 's/^/[Rule4] /' +$GREP "<<[ ]*if[^>=]*[^><\!=]=[^=][^>]*>>" -- 'src/*' | myprint "AccidentalAssignmentInIf" # Check for missing ". e.g.: <<if $foo = "hello>> -$GREP "<<[^\"<>]*\"[^\"<>]*>>" -- 'src/*' | sed 's/^/[Rule5] /' +$GREP "<<[^\"<>]*\"[^\"<>]*>>" -- 'src/*' | myprint "MissingSpeachMark" # Check for missing ". e.g.: <<if $foo = "hello) -$GREP "<<[^\"<>]*\([^\"<>]*\"[^><\"]*\"\| [<>] \)*\"\([^\"<>]*\"[^><\"]*\"\| [<>] \)*\([^\"<>]\| [<>] \)*>>" -- 'src/*' | sed 's/^/[Rule6] /' +$GREP "<<[^\"<>]*\([^\"<>]*\"[^><\"]*\"\| [<>] \)*\"\([^\"<>]*\"[^><\"]*\"\| [<>] \)*\([^\"<>]\| [<>] \)*>>" -- 'src/*' | myprint "MissingSpeachMark2" # Check for colors like: @@color:red - should be @@.red -$GREP -e "@@color:" --and --not -e "@@color:rgb([0-9 ]\+,[0-9 ]\+,[0-9 ]\+)" -- "src/*" | sed 's/^/[Rule7] /' +$GREP -e "@@color:" --and --not -e "@@color:rgb([0-9 ]\+,[0-9 ]\+,[0-9 ]\+)" -- "src/*" | myprint "UseCssColors" # Check for missing $ in activeSlave or PC -$GREP "<<[ ]*[^\$><_\[]*\(activeSlave\|PC\)[.]" -- "src/*" | sed 's/^/[Rule8] /' +$GREP "<<[ ]*[^\$><_\[]*\(activeSlave\|PC\)[.]" -- "src/*" | myprint "MissingDollar" # Check for closing bracket without opening bracket. e.g.: <<if foo)>> (but <<case "foo")>> is valid, so ignore those -$GREP -e "<<[ a-zA-Z]\+[^()<>]*)" --and --not -e "<< *case" -- "src/*" | sed 's/^/[Rule9] /' +$GREP -e "<<[ a-zA-Z]\+[^()<>]*)" --and --not -e "<< *case" -- "src/*" | myprint "MissingOpeningBracket" # Check for opening bracket without closing bracket. e.g.: <<if (foo>> -$GREP -e "<<[ a-zA-Z]\+([^()<>]*>>" -- "src/*" | sed 's/^/[Rule10] /' +$GREP -e "<<[ a-zA-Z]\+([^()<>]*>>" -- "src/*" | myprint "MissingClosingBracket" # Check for two closing brackets but one opening bracket. e.g.: <<if (foo))>> -$GREP -e "<<[ a-zA-Z]\+[^()<>]*([^()]*)[^()]*)[^()<>]*>>" -- "src/*" | sed 's/^/[Rule11] /' +$GREP -e "<<[ a-zA-Z]\+[^()<>]*([^()]*)[^()]*)[^()<>]*>>" -- "src/*" | myprint "MissingOpeningBracket2" # Check for one closing bracket but two opening brackets. e.g.: <<if ((foo)>> -$GREP -e "<<[ a-zA-Z]\+[^()<>]*([^()]*([^()]*)[^()<>]*>>" -- "src/*" | sed 's/^/[Rule12] /' +$GREP -e "<<[ a-zA-Z]\+[^()<>]*([^()]*([^()]*)[^()<>]*>>" -- "src/*" | myprint "MissingClosingBracket2" +$GREP -e "<<.*[(][^<>)]*[(][^<>)]*)\?[^<>)]*>>" -- "src/*" | myprint "MissingClosingBracket3" # Check for missing >>. e.g.: <<if $foo -$GREP "<<[^<>]*[^,\"\[{"$'\r]\r'"\?$" -- 'src/*' | sed 's/^/[Rule13] /' +$GREP "<<[^<>]*[^,\"\[{"$'\r]\r'"\?$" -- 'src/*' | myprint "MissingClosingAngleBrackets" # Check for too many >>>. e.g.: <</if>>> -$GREP "<<[^<>]*[<>]\?[^<>]*>>>" -- "src/*.tw" | sed 's/^/[Rule14] /' +$GREP "<<[^<>]*[<>]\?[^<>]*>>>" -- "src/*.tw" | myprint "TooManyAngleBrackets" # Check for wrong capitilization on 'activeslave' and other common typos -$GREP -e "\$act" --and --not -e "\$\(activeSlave\|activeArcology\|activeStandard\|activeOrgan\|activeLimbs\)" -- "src/*" | sed 's/^/[Rule15a] /' -$GREP "\(csae\|[a-z] She \|attepmts\|youreslf\|advnaces\)" -- 'src/*' | sed 's/^/[Rule15b] /' -$GREP "\$slave\[" -- 'src/*' | sed 's/^/[Rule15c] /' +$GREP -e "\$act" --and --not -e "\$\(activeSlave\|activeArcology\|activeStandard\|activeOrgan\|activeLimbs\)" -- "src/*" | myprint "WrongCapitilization" +$GREP "\(csae\|[a-z] She \|attepmts\|youreslf\|advnaces\)" -- 'src/*' | myprint "SpellCheck" +$GREP "\$slave\[" -- 'src/*' | myprint "ShouldBeSlaves" # Check for strange spaces e.g. $slaves[$i]. lips -$GREP "\$slaves\[\$i\]\. " -- 'src/*' | sed 's/^/[Rule16] /' +$GREP "\$slaves\[\$i\]\. " -- 'src/*' | myprint "MissingPropertyAfterSlaves" # Check using refreshmentType instead of refreshment -$GREP "\$PC.refreshmentType[^ =]" -- 'src/*' | sed 's/^/[Rule17] /' +$GREP "\$PC.refreshmentType[^ =]" -- 'src/*' | myprint "ShouldBeRefreshment" # Check, e.g., <<//if>> -$GREP "<</[a-zA-Z]*[^a-zA-Z<>]\+[a-zA-Z]*>>" -- 'src/*' | sed 's/^/[Rule18] /' +$GREP "<</[a-zA-Z]*[^a-zA-Z<>]\+[a-zA-Z]*>>" -- 'src/*' | myprint "DoubleSlash" +# Check, e.g. <<else $foo==4 +$GREP "<<else >\?[^>]" -- 'src/*' | myprint "ShouldBeElseIf" # Check, e.g., =to -$GREP "=to" -- 'src/*' | sed 's/^/[Rule19] /' +$GREP "=to" -- 'src/*' | myprint "EqualAndTo" # Check doing $slaves.foo instead of $slaves[i].foo -$GREP -e "[$]slaves[.]" --and --not -e '[$]slaves[.]\(length\|random\|map\|filter\|deleteAt\|push\)' -- 'src/*' | sed 's/^/[Rule20] /' -# Try to check for accidentally mixing slaves[] and activeSlave. This can have a lot of false matches, but catches some good matches too -$GREP -e "activeSlave[.]" --and -e "slaves\[..\?\][.]" --and --not -e '[.]ID' --and --not -e 'slaves\[..\?\][.]\(slaveName\|actualAge\|relation\|assignment\|devotion\|trust\|vagina\)' -- 'src/*' | sed 's/^/[Rule21] /' +$GREP -e "[$]slaves[.]" --and --not -e '[$]slaves[.]\(length\|random\|map\|filter\|deleteAt\|push\)' -- 'src/*' | myprint "MissingSlavesIndex" +# Try to check for accidentally mixing slaves[] and activeSlave. This can have a lot of false matches, but has caught a lot of bugs so it's worth the pain +$GREP -e "activeSlave[.]" --and -e "slaves\[..\?\][.]" --and --not -e '[.]ID' --and --not -e 'slaves\[..\?\][.]\(slaveName\|actualAge\|relation\|assignment\|age\|devotion\|trust\|vagina\)' -- 'src/*' | myprint "MaybeAccidentalMixingOfSlavesAndActiveSlave" + +# Check that we do not have any variables that we use only once. e.g. $onlyUsedOnce +( +cd src/ +strings $(find . -name "*.tw" ) | tr -c '$a-zA-Z' '\n' | sed -n '/^[$]/p' | sort | uniq -c | grep ' 1 ' | sed 's/^ *1 [$]/-e[$]/' | sed 's/$/\\\\W/' | xargs -r git grep -n --color | myprint "OnlyUsedOnce" +) + # Check that all the tags are properly opened and closed git ls-files "src/*.tw" | xargs -d '\n' ./devTools/check.py diff --git a/src/pregmod/fSlaveSlaveDickConsummate.tw b/src/pregmod/fSlaveSlaveDickConsummate.tw index be814b358fda78c2c663c6cfdf240187d7ddc70d..f97af3cb6b5268eb97a902b36b3d4e8fcfb39405 100644 --- a/src/pregmod/fSlaveSlaveDickConsummate.tw +++ b/src/pregmod/fSlaveSlaveDickConsummate.tw @@ -129,17 +129,17 @@ Next, you see to $slaverapistx.slaveName. <<set $activeSlave.penetrativeCount += 1>> <<set $penetrativeTotal += 1>> -<<if ($slaverapistx.fetish == "dominant") && ($slaverapistx.fetishStrength > 20) && (($slaverapistx.vagina == 0)>> +<<if ($slaverapistx.fetish == "dominant") && ($slaverapistx.fetishStrength > 20) && ($slaverapistx.vagina == 0)>> She lowers her virgin pussy onto $activeSlave.slaveName waiting member, impaling herself slowly and teasing her bound victim. This act @@.lime; breaks in her pussy.@@ <<set $slaverapistx.vagina = 1>> <<set $slaverapistx.devotion += 4>> <<set $slaverapistx.fetishStrength += 1>> -<<elseif $slaverapistx.devotion > 20) && (($activeSlave.vagina == 0) >> +<<elseif $slaverapistx.devotion > 20) && ($activeSlave.vagina == 0) >> She accepts your orders without comment and lowers her virgin pussy on $slaverapistx.slaveName's ready dick. She gasps in shock when she feels her hot seed. @@.hotpink;She is broken to slavery@@ by this application of her body, which naturally @@.lime;will break in her pussy.@@ <<set $activeSlave.vagina = 1>> <<set $activeSlave.devotion += 10>> -<<elseif ($activeSlave.devotion >= -20) && (($activeSlave.vagina == 0)>> +<<elseif ($activeSlave.devotion >= -20) && ($activeSlave.vagina == 0)>> She is clearly unhappy at the idea of losing her pearl of great price to $slaverapistx.slaveName; this probably isn't what she imagined her first real sex would be like. She fears he might get pregnant. Nevertheless, @@.hotpink;she is broken to slavery@@ by this application of her body, which naturally @@.lime;will break in her pussy.@@ <<set $activeSlave.vagina = 1>> <<set $activeSlave.devotion += 4>> diff --git a/src/pregmod/fSlaveSlaveVagConsummate.tw b/src/pregmod/fSlaveSlaveVagConsummate.tw index 3529dc0071a912ab76e0f62e75ad1a4252c0d6c5..65e95a805c76a8bd88632de1c7d999d9c72758a5 100644 --- a/src/pregmod/fSlaveSlaveVagConsummate.tw +++ b/src/pregmod/fSlaveSlaveVagConsummate.tw @@ -155,7 +155,7 @@ Next, you see to $activeSlave.slaveName. <<set $vaginalTotal += 1>> -<<if ($activeSlave.fetish == "submissive") && ($activeSlave.fetishStrength > 60) && ($activeSlave.fetishKnown == 1) && (($activeSlave.vagina == 0)>> +<<if ($activeSlave.fetish == "submissive") && ($activeSlave.fetishStrength > 60) && ($activeSlave.fetishKnown == 1) && ($activeSlave.vagina == 0)>> She presents her virgin pussy to $slaverapistx.slaveName without protest. This act @@.lime; breaks in her pussy.@@ <<set $activeSlave.vagina = 1>> <<set $activeSlave.devotion += 4>> @@ -165,11 +165,11 @@ Next, you see to $activeSlave.slaveName. She smiles and presents her pussy to $slaverapistx.slaveName. @@.hotpink;She enjoys@@ submitting to a dominant slave. <<set $activeSlave.devotion += 4>> -<<elseif ($activeSlave.devotion > 20) && (($activeSlave.vagina == 0) >> +<<elseif ($activeSlave.devotion > 20) && ($activeSlave.vagina == 0) >> She accepts your orders without comment and presents her virgin pussy to $slaverapistx.slaveName. She gasps in shock when she feels the <<if $slaverapistx.dick > 0>>$dicksize dick<else>>strap-on<</if>> eneter her. @@.hotpink;She is broken to slavery@@ by this application of her body, which naturally @@.lime;will break in her pussy.@@ <<set $activeSlave.vagina = 1>> <<set $activeSlave.devotion += 10>> -<<elseif ($activeSlave.devotion >= -20) && (($activeSlave.vagina == 0)>> +<<elseif ($activeSlave.devotion >= -20) && ($activeSlave.vagina == 0)>> She is clearly unhappy at the idea of losing her pearl of great price to $slaverapistx.slaveName; this probably isn't what she imagined her first real sex would be like. Nevertheless, @@.hotpink;she is broken to slavery@@ by this application of her body, which naturally @@.lime;will break in her pussy.@@ <<set $activeSlave.vagina = 1>> <<set $activeSlave.devotion += 4>>