#include #include #include #include #include using namespace std; int OldIndex[2] = {0}; int OldSize; int NewIndex = 0; string List[2][50000][2]; void FindSame(string NewString) { while(1) { if(OldIndex[0]>OldSize) { break; } if(NewString.compare(List[1][OldIndex[0]][0])==0) { List[0][NewIndex][0].clear(); OldIndex[1] = OldIndex[0]; break; } OldIndex[0]++; if(NewString.compare(List[1][OldIndex[0]][0])<0) { break; } } } void ListInsert() { int a; while(1) { if(OldIndex[0]>OldSize) { OldSize++; List[0][OldIndex[0]][0] = List[1][NewIndex][0]; OldIndex[0]++; break; } if(List[1][NewIndex][1].compare(List[0][OldIndex[0]][1])==0) { List[0][OldIndex[0]][0] = List[1][NewIndex][0]; break; } if(List[1][NewIndex][1].compare(List[0][OldIndex[0]][1])<0) { OldSize++; OldIndex[0]++; a = OldSize; while(a>(OldIndex[0]+1)) { List[0][a][0] = List[0][a-1][0]; a--; } List[0][OldIndex[0]][0] = List[1][NewIndex][0]; break; } OldIndex[0]++; } } void MakeRelativePath(string* Char, string RelativePath) { char buffer[MAX_PATH]; GetModuleFileName( NULL, buffer, MAX_PATH ); string::size_type pos = string( buffer ).find_last_of( "\\/" ); Char->clear(); Char->append(string( buffer ).substr( 0, pos)); Char->append("\\"); Char->append(RelativePath); } int main() { string File[4]; bool StreamState[3]; int NewSize; char *Path; string Nigger; stringstream Buffer[3]; MakeRelativePath(&Nigger, "NewStrings.txt"); Path = (char*)Nigger.c_str(); ifstream Stream1(Path); Buffer[0] << Stream1.rdbuf(); File[0] = Buffer[0].str(); StreamState[0] = !Stream1; MakeRelativePath(&Nigger, "OldStrings.txt"); Path = (char*)Nigger.c_str(); ifstream Stream2(Path); Buffer[1] << Stream2.rdbuf(); File[1] = Buffer[1].str(); StreamState[1] = !Stream2; MakeRelativePath(&Nigger, "Translate.txt"); Path = (char*)Nigger.c_str(); ifstream Stream3(Path); Buffer[2] << Stream3.rdbuf(); File[2] = Buffer[2].str(); StreamState[2] = !Stream3; if(StreamState[1]==true) { cout << "Error opening OldStrings.txt" << endl; Sleep(3000); return 0; } if(StreamState[2]==false) { cout << "Merging changes..." << endl; int a, c = 1; bool d; unsigned int b[2] = {0}; while(c<3) { a = 0; b[0] = 0, b[1] = 0; d = true; while(1) { if(b[1]>File[c].length()){ if(c==2) { NewSize = a; } else { OldSize = a; } break; } else { if((char)((File[c].substr(b[1],1)).c_str())[0]=='\n') { if((b[1]-b[0])>0) { List[c-1][a][0].append(File[c].substr(b[0],b[1]-b[0])); } b[0] = b[1] + 1; a++; d = true; } else { if((char)((File[c].substr(b[1],1)).c_str())[0]=='=' and d == true) { if((b[1]-b[0])>0) { List[c-1][a][1].append(File[c].substr(b[0],b[1]+1-b[0])); d = false; } } } b[1]++; } } c++; } while(NewIndex<=NewSize) { ListInsert(); NewIndex++; } a = 0, c = 0; while(a<=OldSize) { if(List[0][a][0].length()>1) { if(c>0) { File[3].append("\n"); } c++; File[3].append(List[0][a][0]); } a++; } cout << "Strings merging finished; GameStrings.txt created." << endl; if(c==1) { cout << "The file has " << c << " line." << endl; } else { cout << "The file has " << c << " lines." << endl; } ofstream StreamO("GameStrings.txt"); StreamO << File[3]; Sleep(3000); } else { if(StreamState[0]==true) { cout << "Error opening NewStrings.txt or Translator.txt" << endl; Sleep(3000); return 0; } cout << "Creating translator file..." << endl; int a, c = 0; unsigned int b[2] = {0}; while(c<2) { a = 0; b[0] = 0, b[1] = 0; while(1) { if(b[1]>File[c].length()){ if(c==0) { NewSize = a; } else { OldSize = a; } break; } else { if((char)((File[c].substr(b[1],1)).c_str())[0]=='\n') { if((b[1]-b[0])>0) { List[c][a][0].append(File[c].substr(b[0],b[1]-b[0])); } b[0] = b[1] + 1; a++; } b[1]++; } } c++; } while(NewIndex<=NewSize) { OldIndex[0] = OldIndex[1]; FindSame(List[0][NewIndex][0]); NewIndex++; } a = 0, c = 0; while(a<=NewSize) { if(List[0][a][0].length()>1) { if(c>0) { File[3].append("\n"); } c++; File[3].append(List[0][a][0]); } a++; } if(c>0) { cout << "Strings processing finished; Translate.txt created." << endl; if(c==1) { cout << "There was " << c << " updated line." << endl; } else { cout << "There were " << c << " updated lines." << endl; } ofstream StreamO("Translate.txt"); StreamO << File[3]; } else { cout << "Strings match; no file created." << endl; } Sleep(3000); } return 0; }