stop filtering space
This commit is contained in:
parent
6a199a8246
commit
acf639dd45
@ -421,7 +421,7 @@ void ClickButton(HWND hWnd, HWND h)
|
||||
// return len;
|
||||
//}
|
||||
|
||||
DWORD ThreadOutput(TextThread* thread, BYTE* out, DWORD len, DWORD new_line, bool space)
|
||||
DWORD ThreadOutput(TextThread* thread, BYTE* out, DWORD len, DWORD new_line)
|
||||
{
|
||||
if (len == 0)
|
||||
return len;
|
||||
|
@ -286,10 +286,10 @@ void HookManager::UnRegisterProcess(DWORD pid)
|
||||
// //swprintf(user_entry,L"UserHook%c",c);
|
||||
//}
|
||||
|
||||
void HookManager::DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD retn, DWORD spl, int len, bool space)
|
||||
void HookManager::DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD retn, DWORD spl, int len)
|
||||
{
|
||||
// jichi 20/27/2013: When PID is zero, the text comes from console, which I don't need
|
||||
if (!text || !pid || (len <= 0 && !space))
|
||||
if (!text || !pid || len <= 0)
|
||||
return;
|
||||
HM_LOCK;
|
||||
//bool flag=false;
|
||||
@ -305,7 +305,7 @@ void HookManager::DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD re
|
||||
create(it);
|
||||
}
|
||||
}
|
||||
it->AddText(text, len, false, space);
|
||||
it->AddText(text, len, false);
|
||||
}
|
||||
|
||||
void HookManager::AddConsoleOutput(LPCWSTR text)
|
||||
@ -315,8 +315,8 @@ void HookManager::AddConsoleOutput(LPCWSTR text)
|
||||
int len = wcslen(text) * 2;
|
||||
TextThread *console = threadTable[{0, -1UL, -1UL, -1UL}];
|
||||
//EnterCriticalSection(&hmcs);
|
||||
console->AddText((BYTE*)text,len,false,true);
|
||||
console->AddText((BYTE*)L"\r\n",4,false,true);
|
||||
console->AddText((BYTE*)text,len,false);
|
||||
console->AddText((BYTE*)L"\r\n",4,false);
|
||||
//LeaveCriticalSection(&hmcs);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
void AddConsoleOutput(LPCWSTR text);
|
||||
|
||||
// jichi 10/27/2013: Add const; add space.
|
||||
void DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD retn, DWORD split, int len, bool space);
|
||||
void DispatchText(DWORD pid, const BYTE *text, DWORD hook, DWORD retn, DWORD split, int len);
|
||||
void RemoveProcessContext(DWORD pid); // private
|
||||
void RemoveSingleHook(DWORD pid, DWORD addr);
|
||||
void RegisterProcess(DWORD pid, HANDLE hostPipe);
|
||||
|
@ -16,59 +16,6 @@
|
||||
|
||||
#define DEBUG "vnrhost/pipe.cc"
|
||||
|
||||
//DWORD WINAPI UpdateWindows(LPVOID lpThreadParameter);
|
||||
|
||||
namespace
|
||||
{ // unnamed
|
||||
|
||||
// jichi 10/27/2013
|
||||
// Check if text has leading space
|
||||
enum { FILTER_LIMIT = 0x20 }; // The same as the orignal ITH filter. So, I don't have to check \u3000
|
||||
//enum { FILTER_LIMIT = 0x19 };
|
||||
inline bool HasLeadingSpace(const BYTE *text, int len)
|
||||
{
|
||||
return len == 1 ? *text <= FILTER_LIMIT : // 1 byte
|
||||
*(WORD*)text <= FILTER_LIMIT; // 2 bytes
|
||||
}
|
||||
|
||||
// jichi 9/28/2013: Skip leading garbage
|
||||
// Note:
|
||||
// - Modifying limit will break manual translation. The orignal one is 0x20
|
||||
// - Eliminating 0x20 will break English-translated games
|
||||
const BYTE* Filter(const BYTE *str, int len)
|
||||
{
|
||||
#ifdef ITH_DISABLE_FILTER // jichi 9/28/2013: only for debugging purpose
|
||||
return str;
|
||||
#endif
|
||||
while (true)
|
||||
{
|
||||
if (len >= 2)
|
||||
{
|
||||
if (*(WORD*)str <= FILTER_LIMIT)
|
||||
{ // jichi 10/27/2013: two bytes
|
||||
str += 2;
|
||||
len -= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (*str <= FILTER_LIMIT)
|
||||
{ // jichi 10/27/2013: 1 byte
|
||||
str++;
|
||||
len--;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
CRITICAL_SECTION detachCs; // jichi 9/27/2013: also used in main
|
||||
//HANDLE hDetachEvent;
|
||||
extern HANDLE pipeExistsEvent;
|
||||
@ -153,14 +100,7 @@ DWORD WINAPI TextReceiver(LPVOID lpThreadParameter)
|
||||
|
||||
const BYTE *data = buffer + DATA_OFFSET; // th
|
||||
int dataLength = bytesRead - DATA_OFFSET;
|
||||
bool space = ::HasLeadingSpace(data, dataLength);
|
||||
if (space)
|
||||
{
|
||||
const BYTE *it = ::Filter(data, dataLength);
|
||||
dataLength -= it - data;
|
||||
data = it;
|
||||
}
|
||||
man->DispatchText(processId, data, hook, retn, split, dataLength, space);
|
||||
man->DispatchText(processId, data, hook, retn, split, dataLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,12 +78,12 @@ void TextThread::AddLineBreak()
|
||||
else
|
||||
AddToStore((BYTE *)"\r\n\r\n", 4);
|
||||
if (output)
|
||||
output(this, 0, 8, TRUE, false); // jichi 10/27/2013: space is false
|
||||
output(this, 0, 8, TRUE); // jichi 10/27/2013: space is false
|
||||
last_sentence = used;
|
||||
status &= ~BUFF_NEWLINE;
|
||||
}
|
||||
}
|
||||
void TextThread::AddText(const BYTE *con, int len, bool new_line, bool space)
|
||||
void TextThread::AddText(const BYTE *con, int len, bool new_line)
|
||||
{
|
||||
|
||||
if (status & BUFF_NEWLINE)
|
||||
@ -103,7 +103,7 @@ void TextThread::AddText(const BYTE *con, int len, bool new_line, bool space)
|
||||
if (len <= 0) return;
|
||||
BYTE *data = const_cast<BYTE *>(con); // jichi 10/27/2013: TODO: Figure out where con is modified
|
||||
if (output)
|
||||
len = output(this, data, len, new_line, space);
|
||||
len = output(this, data, len, new_line);
|
||||
if (AddToStore(data, len)) {
|
||||
//sentence_length += len;
|
||||
/*ResetRepeatStatus();
|
||||
|
@ -40,7 +40,7 @@ struct ThreadParameter {
|
||||
class TextThread;
|
||||
typedef void (* ConsoleCallback)(LPCSTR text);
|
||||
typedef void (* ConsoleWCallback)(LPCWSTR text);
|
||||
typedef DWORD (* ThreadOutputFilterCallback)(TextThread *, BYTE *, DWORD, DWORD, bool space); // jichi 10/27/2013: Add space
|
||||
typedef DWORD (* ThreadOutputFilterCallback)(TextThread *, BYTE *, DWORD, DWORD);
|
||||
typedef DWORD (* ThreadEventCallback)(TextThread *);
|
||||
|
||||
//extern DWORD split_time,repeat_count,global_filter,cyclic_remove;
|
||||
@ -53,7 +53,7 @@ public:
|
||||
virtual void GetEntryString(LPSTR buffer, DWORD max);
|
||||
|
||||
void Reset();
|
||||
void AddText(const BYTE *con,int len, bool new_line, bool space); // jichi 10/27/2013: add const; remove console; add space
|
||||
void AddText(const BYTE *con,int len, bool new_line); // jichi 10/27/2013: add const; remove console
|
||||
void AddLineBreak();
|
||||
void DispatchLastSentence();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user