비월선행록 v1.2933 한글 패치버전 특정 이벤트 오버플로우 현상 고치는 방법
한글 패치하고 나서 특정 이벤트 불러올 때, 아래의 화면 노출되는 경우가 있을 거임
한패한다고 들어간 플러그인이 textWidthEx 호출할 때 재귀 가드를 안 넣어놔서 생긴 버그로 추정됨.
콘솔모드로 원인 찾아서 반복하는 원인 중 하나인 autoLine.js 비활성화 해봤다가 오버플로우 증상은 고쳐졌지만,
대사 자동 줄바꿈이 안되는 문제가 생기면서 이게 원초적인 문제가 아님을 깨닫고
제대로 뜯어보니까
FlyCat_TextCenter가 텍스트 정렬하려면 너비 알아야해서 → textWidthEx() 호출 → convertEscapeCharacters() 호출 → Admin_LanguageCore가 여기 훅 걸려있음 → autoLine.js의 convertEscapeCharacters 호출 → 너비 재려고 this.textWidth() 호출 → 또 convertEscapeCharacters() 호출→ 또 Admin_LanguageCore 훅 → 또 autoLine.js의 convertEscapeCharacters 호출...(이하 반복) 꼬라지라서 오버플로우 지12랄 난거임
핵심은 autoLine이 너비를 재면서 내부적으로 다시 텍스트 처리를 부른 게 문제라 너비 계산이 텍스트 처리를 부르고, 텍스트 처리가 다시 너비 계산을 부르는 거지 같은 순환 구조가 생김
그래서 textWidthEx에 ‘이미 계산 중이면 그냥 0 반환하고 꺼져’라는 가드를 넣은 스크립트가 아래임
게임폴더\js\plugins 에서 autoLine.js 메모장이나 notepad++로 열고 컨트롤 a 누르고 아래의 내용 복붙하고 저장하셈
그냥 혼자 두고 쓰려다가 똑같은 증상 겪을 사람들 많을 거 같아서 공유함
자동 서식 변환때문에 소스코드 망가져서 코드블록에 넣어서 다시 함
/*:
* @plugindesc 自动换行(英文)
* @author FlyRoc
* @target MZ
*/
(function() {
const _textWidthEx = Window_Base.prototype.textWidthEx;
Window_Base.prototype.textWidthEx = function(text) {
if (this._calcingWidth) return 0;
this._calcingWidth = true;
const result = _textWidthEx.call(this, text);
this._calcingWidth = false;
return result;
};
})();
function validUpperCase(str) {
const reg = /^[A-Z]+$/
return reg.test(str)
}
Window_Message.prototype.convertEscapeCharacters = function (text) {
if (this._autoLineProcessing) {
text = text.replace(/\\/g, "\x1b");
text = text.replace(/\x1b\x1b/g, "\\");
text = text.replace(/\x1bV\[(\d+)\]/gi, (_, p1) =>
$gameVariables.value(parseInt(p1))
);
text = text.replace(/\x1bV\[(\d+)\]/gi, (_, p1) =>
$gameVariables.value(parseInt(p1))
);
text = text.replace(/\x1bN\[(\d+)\]/gi, (_, p1) =>
this.actorName(parseInt(p1))
);
text = text.replace(/\x1bP\[(\d+)\]/gi, (_, p1) =>
this.partyMemberName(parseInt(p1))
);
text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
return text;
}
this._autoLineProcessing = true;
const regex = /[\r\n]/g;
let match;
const newLineIndices = [];
while ((match = regex.exec(text))) {
newLineIndices.push(match.index);
}
var textWidth = 0;
var newText = [];
for (let i = 0; i < text.length; i++) {
var value = this.textWidth(text[i]);
newText.push(text[i]);
if (newLineIndices.includes(i)) {
textWidth = 0;
}
textWidth += value;
if (textWidth >= (this.width - 60)) {
newText.push('\n');
textWidth = 0;
};
};
text = newText.join('')
text = text.replace(/\\/g, "\x1b");
text = text.replace(/\x1b\x1b/g, "\\");
text = text.replace(/\x1bV\[(\d+)\]/gi, (_, p1) =>
$gameVariables.value(parseInt(p1))
);
text = text.replace(/\x1bV\[(\d+)\]/gi, (_, p1) =>
$gameVariables.value(parseInt(p1))
);
text = text.replace(/\x1bN\[(\d+)\]/gi, (_, p1) =>
this.actorName(parseInt(p1))
);
text = text.replace(/\x1bP\[(\d+)\]/gi, (_, p1) =>
this.partyMemberName(parseInt(p1))
);
text = text.replace(/\x1bG/gi, TextManager.currencyUnit);
text = text.replace(/\x1bCT\[(\d+)\]/gi, function () {
$gameMessage.setAlign(Number(arguments[1] || 0));
return "";
}.bind(this));
this._autoLineProcessing = false;
return text;
};Deleted comment.
s/somisoft
• 163,117 subscribers- 1. 게시물 규정 양식
업로드 시 링크 암호화 & 필수 정보를 기입할 것
- 2. 질문
국룰, 암호화 링크 등 기본사항 질문 금지, 탭 미준수시 차단 및 삭제
- 3. 요청
요청 기준 및 양식 미준수 & 댓글로만 자료 복구 요청 시 차단
- 4. 미성년자 / 근첩 / 페미 / 다중계정
조금이라도 의심되면 선 차단, 후 해명
- 5. 좆목 / 네임드화
닉언, 네임드화 등 친목질 금지
- 6. 분탕 및 어그로 / 혐짤 / 낚시 / 뇌절
해당 카테고리의 차단 기간 및 가중처벌은 처리자 재량으로 판단
- 7. 홍보 / 판촉 / 거래
허용되지 않은 모든 형태의 홍보, 거래, 교환, 조건부 공유 시 차단
- 8. 쌀먹 / 바이러스
조건부 공유 & 수익성 링크 & 고의적인 바이러스 유포 시 갱신차단
- 9. 자료 분류 / AI
미검수 시 표기 필수, 생성형 AI를 사용한 자료의 제목에 AI 미기입 시 차단
- 10. 실사 / 토들러
업로드시 갱신 차단
- 11. 기타 세부 규정은 서브 공지사항 참고