From 26f28b9ad8e4e16118f2587b009512b01a3347dd Mon Sep 17 00:00:00 2001
From: JP_ANON <anonymous@anonymous.com>
Date: Thu, 2 Mar 2023 21:20:50 +0100
Subject: [PATCH] Fixed bug where Dirtiness from Partner-led actions could be
 excessively high

---
 #Translation/bug-fixes.txt                       |  6 +++++-
 ERB/TRANSLATION/BUGFIX.ERB                       | 16 ++++++++++++++++
 ...\213\344\270\273\345\260\216\357\274\211.ERB" |  1 +
 ...\216\345\276\214\350\203\214\344\275\215.ERB" |  1 +
 ...\214\350\203\214\344\275\215\357\274\241.ERB" |  1 +
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/#Translation/bug-fixes.txt b/#Translation/bug-fixes.txt
index 39df6aeac2..566156f58f 100644
--- a/#Translation/bug-fixes.txt
+++ b/#Translation/bug-fixes.txt
@@ -298,4 +298,8 @@ ERB\NEWGAME\強くてニューゲーム.ERB
 	Fix description shown when fishing up a rotor, due to wonky id handling
 
 @GET_SCORE_INFO_NO, @GET_SCORE_INFO_MESSAGE
-	Ensure SCORE_INFO_NO is properly initialized, to prevent player from obtaining any character-dependent score if TARGET is 0
\ No newline at end of file
+	Ensure SCORE_INFO_NO is properly initialized, to prevent player from obtaining any character-dependent score if TARGET is 0
+
+@DIRT_CHECK, @COM320, @COM322, @COM323
+	Ensure that the dirtiness multiplier stored in the global Y variable is always set to a proper value before dirtiness is calculated
+	This variable can be set from an unknown place, so COMs that don't set it in a CAN_COM could have unpredictable values
\ No newline at end of file
diff --git a/ERB/TRANSLATION/BUGFIX.ERB b/ERB/TRANSLATION/BUGFIX.ERB
index bff87698d2..ad507d4d27 100644
--- a/ERB/TRANSLATION/BUGFIX.ERB
+++ b/ERB/TRANSLATION/BUGFIX.ERB
@@ -109,3 +109,19 @@ SIF GROUPMATCH( ITEMSTOCK(ARG), 2, 5 ) || ((ITEMSALES:ARG > 0 && ITEMSALES:ARG <
 	SETCOLOR 150,150,150
 PRINTFORML %LOCALS,48,LEFT%%ARGS:1%
 RESETCOLOR
+
+;ensures value of Y is set properly for COMs that do not use CAN_COM
+@DIRT_CHECK
+Y = 0
+;愛液の汚れ
+SIF STAIN:PLAYER:2 & 1
+	Y += 1
+;精液の汚れ
+SIF STAIN:PLAYER:2 & 4
+	Y += 3
+;アナルの汚れ
+SIF STAIN:PLAYER:2 & 8
+	Y += 7
+SIF STAIN:PLAYER:2 & 16
+	Y += 15
+Y = Y * (2 - TALENT:汚臭耐性) / 2
\ No newline at end of file
diff --git "a/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF320 \346\255\243\345\270\270\344\275\215\357\274\210\347\233\270\346\211\213\344\270\273\345\260\216\357\274\211.ERB" "b/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF320 \346\255\243\345\270\270\344\275\215\357\274\210\347\233\270\346\211\213\344\270\273\345\260\216\357\274\211.ERB"
index 2ec275904c..02edac6c7c 100644
--- "a/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF320 \346\255\243\345\270\270\344\275\215\357\274\210\347\233\270\346\211\213\344\270\273\345\260\216\357\274\211.ERB"	
+++ "b/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF320 \346\255\243\345\270\270\344\275\215\357\274\210\347\233\270\346\211\213\344\270\273\345\260\216\357\274\211.ERB"	
@@ -69,6 +69,7 @@ SIF BEDROOM(CFLAG:PLAYER:現在位置) && !ASSIPLAY
 SIF SOURCE:快V >= 1000
 	SOURCE:快V = 1000
 
+CALL DIRT_CHECK() ;bugfix custom code
 ;上のほうで計算した汚れデータ
 SOURCE:不潔 = Y*10 + 60
 CALL 特殊ソース処理
diff --git "a/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF322 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215.ERB" "b/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF322 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215.ERB"
index 298cf32565..10d8beca4f 100644
--- "a/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF322 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215.ERB"	
+++ "b/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF322 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215.ERB"	
@@ -50,6 +50,7 @@ SOURCE:露出 = 150
 SIF TFLAG:193
 	SOURCE:露出 = 300
 
+CALL DIRT_CHECK() ;bugfix custom code
 ;上のほうで計算した汚れデータ
 SOURCE:不潔 = Y*10 + 60
 CALL 特殊ソース処理
diff --git "a/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF323 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215\357\274\241.ERB" "b/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF323 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215\357\274\241.ERB"
index 0b59f8f03b..1cb76a352c 100644
--- "a/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF323 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215\357\274\241.ERB"	
+++ "b/ERB/\343\202\263\343\203\236\343\203\263\343\203\211\351\226\242\351\200\243/COMF/COMF323 \347\233\270\346\211\213\344\270\273\345\260\216\345\276\214\350\203\214\344\275\215\357\274\241.ERB"	
@@ -46,6 +46,7 @@ SOURCE:苦痛 = 900
 SOURCE:露出 = 100
 SOURCE:逸脱 = 200
 
+CALL DIRT_CHECK() ;bugfix custom code
 ;上のほうで計算した汚れデータ
 SOURCE:不潔 = Y*10 + 60
 
-- 
GitLab