void CMapEditDlg::OnButtonSave() { FILE *pFilein; char caption[100]; //»ñÈ¡Ò¶ÃæÄÚÈÝ strcpy(caption,csMapName); char stype[100]; strcpy(stype,csMapStyle); char texture[100]; CString csTemp = _T(""); csTemp.Format(_T("%d"),m_nFloorNum); strcpy(texture,csTemp); char music[100]; strcpy(music,csMapMusic);// int height = m_nHeight;// int width = m_nWidth;// int t = 0;// int mymap[143];// // // for (int i = 0; i < width; i++)// {// for (int j = 0; j < height; j++)// {// mymap[t] = t;// t++;// }// }// csTemp = m_csMapPath + // str = "C://"+m_cCaption+".map"; //************************************************************************** if ((pFilein = fopen(csTemp, "ab+")) == NULL) { printf("cannot open file"); exit(0); } FILE *stream = tmpfile();//´´½¨ÁÙʱÎļþ fwrite(&caption, 100, 1, stream); // ½«ÄÚÈÝдÈëÁÙʱÎļþ fwrite(&stype, 100, 1, stream); fwrite(&texture, 100, 1, stream); fwrite(&music, 100, 1, stream); m_progress.SetPos(1); int i = 2; for (int nRow = 0; nRow < 11; nRow++) { for (int nCol = 0; nCol < 13; nCol++) { fwrite(&m_stMapObj[nRow][nCol],16,1,stream); i++; int n = static_cast<int>((static_cast<float>(i)/static_cast<float>(286))*100); m_progress.SetPos(n); } } rewind(stream);//ÒÆÖÁÎļþÍ· //¼ÓÃÜÎļþ
char ch; ch=fgetc(stream); CString s = _T("passwordfsdfasdfasdf"); char *psw = s.GetBuffer(0); int j = 0; i = 0; while(psw[++i]); int z = 0; while(!feof(stream)) { ch=ch^psw[j>=i?j=0:j++]; fputc(ch,pFilein); ch=fgetc(stream); z++; int n= 50 + static_cast<int>((static_cast<float>(z)/static_cast<float>(5376))*100); m_progress.SetPos(n); } _rmtmp();//ɾ³ýÁÙʱÎļþ fclose(pFilein); m_progress.ShowWindow(FALSE); m_progress.SetPos(0);}void CMapEditDlg::ReadMap(){ FILE *pFileout; // Îļþ²Ù×÷Ö¸Õë char caption[100] = ""; char stype[100] = ""; char texture[100] = ""; char music[100] = ""; int t = 0; CString str; // ÒÔ¶þ½øÖÆ·½Ê½´ò¿ªuser.datÎļþ CFileDialog dlg(TRUE,"*.map",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Map Files (*.map)|*.map|",NULL); if (dlg.DoModal() == IDOK) { str = dlg.GetPathName(); } else { return; } if ((pFileout = fopen(str, "rb")) == NULL) { printf("cannot open file"); exit(0); } // ³É¿é´ÓÎļþÖжÁÈ¡ FILE *stream = tmpfile();//´´½¨ÁÙʱÎļþ //½âÃÜÎļþ char ch;
ch=fgetc(pFileout); CString s = _T("passwordfsdfasdfasdf"); char *psw = s.GetBuffer(0); int a,b; b = a = 0; while(psw[++a]); int z = 0; while(!feof(pFileout)) { ch=ch^psw[b>=a?b=0:b++]; fputc(ch,stream); ch=fgetc(pFileout); z++; int n= static_cast<int>((static_cast<float>(z)/static_cast<float>(5376))*100); m_progress.SetPos(n); } fclose(pFileout); rewind(stream);//ÒÆÖÁÎļþÍ· fread(&caption, 100, 1, stream); fread(&stype, 100, 1, stream); fread(&texture, 100, 1, stream); fread(&music, 100, 1, stream); int i = 0; for (int nRow = 0; nRow < 11; nRow++) { for (int nCol = 0; nCol < 13; nCol++) { fwrite(&m_stMapObj[nRow][nCol],16,1,stream); i++; int n = 50 + static_cast<int>((static_cast<float>(i)/static_cast<float>(286))*100); m_progress.SetPos(n); } } _rmtmp();//ɾ³ýÁÙʱÎļþ m_progress.ShowWindow(FALSE); m_progress.SetPos(0);}