Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

WIN_QE3.CPP

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 #include "stdafx.h"
00023 #include "qe3.h"
00024 #include "mru.h"
00025 #include "PrefsDlg.h"
00026 
00028 // BSP frontend plugin
00029 // global flag for BSP frontend plugin is g_qeglobals.bBSPFrontendPlugin
00030 _QERPlugBSPFrontendTable g_BSPFrontendTable;
00031 CStringArray g_BSPFrontendCommands;
00032 
00033 extern CEdit* g_pEdit;
00034 
00035 int screen_width;
00036 int screen_height;
00037 qboolean    have_quit;
00038 
00039 int update_bits;
00040 
00041 HANDLE  bsp_process;
00042 
00043 //===========================================
00044 
00045 void Sys_MarkMapModified (void)
00046 {
00047     char            title[1024];
00048 
00049     if (modified != 1)
00050     {
00051         modified = true;    // mark the map as changed
00052         sprintf (title, "%s *", currentmap);
00053 
00054         QE_ConvertDOSToUnixName( title, title );
00055         Sys_SetTitle (title);
00056     }
00057 }
00058 
00059 
00060 void Sys_SetTitle (char *text)
00061 {
00062     SetWindowText (g_qeglobals.d_hwndMain, text);
00063 }
00064 
00065 HCURSOR waitcursor;
00066 
00067 void Sys_BeginWait (void)
00068 {
00069     waitcursor = SetCursor (LoadCursor (NULL, IDC_WAIT));
00070 }
00071 
00072 void Sys_EndWait (void)
00073 {
00074     if (waitcursor)
00075     {
00076         SetCursor (waitcursor);
00077         waitcursor = NULL;
00078     }
00079 }
00080 
00081 
00082 void Sys_GetCursorPos (int *x, int *y)
00083 {
00084     POINT lpPoint;
00085 
00086     GetCursorPos (&lpPoint);
00087     *x = lpPoint.x;
00088     *y = lpPoint.y;
00089 }
00090 
00091 void Sys_SetCursorPos (int x, int y)
00092 {
00093     SetCursorPos (x, y);
00094 }
00095 
00096 
00097 void Sys_Beep (void)
00098 {
00099     MessageBeep (MB_ICONASTERISK);
00100 }
00101 
00102 char    *TranslateString (char *buf)
00103 {
00104     static  char    buf2[32768];
00105     int     i, l;
00106     char    *out;
00107 
00108     l = strlen(buf);
00109     out = buf2;
00110     for (i=0 ; i<l ; i++)
00111     {
00112         if (buf[i] == '\n')
00113         {
00114             *out++ = '\r';
00115             *out++ = '\n';
00116         }
00117         else
00118             *out++ = buf[i];
00119     }
00120     *out++ = 0;
00121 
00122     return buf2;
00123 }
00124 
00125 
00126 void Sys_ClearPrintf (void)
00127 {
00128     char    text[4];
00129     text[0] = 0;
00130 
00131   SendMessage (g_qeglobals.d_hwndEdit, WM_SETTEXT, 0,   (LPARAM)text);
00132 }
00133 
00134 
00135 #define SCROLLBACK_MAX_LINES    600
00136 #define SCROLLBACK_DEL_CHARS    500
00137 
00138 void Sys_Printf (char *text, ...)
00139 {
00140     va_list argptr;
00141     char    buf[32768];
00142     char    *out;
00143     LRESULT result;             // PGM
00144     DWORD   oldPosS, oldPosE;   // PGM
00145 
00146     va_start (argptr,text);
00147     vsprintf (buf, text,argptr);
00148     va_end (argptr);
00149 
00150     out = TranslateString (buf);
00151 
00152 #ifdef LATER
00153     Sys_Status(out);
00154 #else
00155 //PGM
00156     result = SendMessage (g_qeglobals.d_hwndEdit, EM_GETLINECOUNT, 0, 0);
00157     if(result > SCROLLBACK_MAX_LINES)
00158     {
00159         char    replaceText[5];
00160         
00161         replaceText[0] = '\0';
00162 
00163         SendMessage (g_qeglobals.d_hwndEdit, WM_SETREDRAW, (WPARAM)0, (LPARAM)0);
00164         SendMessage (g_qeglobals.d_hwndEdit, EM_GETSEL, (WPARAM)&oldPosS, (LPARAM)&oldPosE);
00165         SendMessage (g_qeglobals.d_hwndEdit, EM_SETSEL, 0, SCROLLBACK_DEL_CHARS);
00166         SendMessage (g_qeglobals.d_hwndEdit, EM_REPLACESEL, (WPARAM)0, (LPARAM)replaceText);
00167         SendMessage (g_qeglobals.d_hwndEdit, EM_SETSEL, oldPosS, oldPosE);
00168         SendMessage (g_qeglobals.d_hwndEdit, WM_SETREDRAW, (WPARAM)1, (LPARAM)0);
00169     }
00170 //PGM
00171 
00172     SendMessage (g_qeglobals.d_hwndEdit, EM_REPLACESEL, 0, (LPARAM)out);
00173 #endif
00174 
00175 }
00176 
00177 
00178 double Sys_DoubleTime (void)
00179 {
00180     return clock()/ 1000.0;
00181 }
00182 
00183 void PrintPixels (HDC hDC)
00184 {
00185     int     i;
00186     PIXELFORMATDESCRIPTOR p[64];
00187 
00188     printf ("### flags color layer\n");
00189     for (i=1 ; i<64 ; i++)
00190     {
00191         if (!DescribePixelFormat ( hDC, i, sizeof(p[0]), &p[i]))
00192             break;
00193         printf ("%3i %5i %5i %5i\n", i,
00194             p[i].dwFlags,
00195             p[i].cColorBits,
00196             p[i].bReserved);
00197     }
00198     printf ("%i modes\n", i-1);
00199 }
00200 
00201 
00202 
00203 //==========================================================================
00204 
00205 void QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC )
00206 {
00207   qwglMakeCurrent( NULL, NULL );
00208   qwglDeleteContext( hGLRC );
00209     ReleaseDC( hWnd, hDC );
00210 }
00211         
00212 int WINAPI QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer )
00213 {
00214     static PIXELFORMATDESCRIPTOR pfd = {
00215         sizeof(PIXELFORMATDESCRIPTOR),  // size of this pfd
00216         1,                                            // version number
00217         PFD_DRAW_TO_WINDOW |                  // support window
00218         PFD_SUPPORT_OPENGL |                  // support OpenGL
00219         PFD_DOUBLEBUFFER,                       // double buffered
00220         PFD_TYPE_RGBA,                          // RGBA type
00221         24,                                           // 24-bit color depth
00222         0, 0, 0, 0, 0, 0,                 // color bits ignored
00223         0,                                            // no alpha buffer
00224         0,                                            // shift bit ignored
00225         0,                                            // no accumulation buffer
00226         0, 0, 0, 0,                               // accum bits ignored
00227         32,                                         // depth bits
00228         0,                                            // no stencil buffer
00229         0,                                            // no auxiliary buffer
00230         PFD_MAIN_PLANE,                         // main layer
00231         0,                                            // reserved
00232         0, 0, 0                                     // layer masks ignored
00233     };                              //
00234     int pixelformat = 0;            
00235 
00236     zbuffer = true;
00237     if ( !zbuffer )
00238         pfd.cDepthBits = 0;
00239 
00240   if (g_PrefsDlg.m_bSGIOpenGL)
00241   {
00242     if ( (pixelformat = qwglChoosePixelFormat(hDC, &pfd)) == 0 )
00243     {
00244         printf("%d",GetLastError());
00245       Error ("ChoosePixelFormat failed");
00246     }
00247   
00248     if (!qwglSetPixelFormat(hDC, pixelformat, &pfd))
00249       Error ("SetPixelFormat failed");
00250   }
00251   else
00252   {
00253     if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 )
00254     {
00255         printf("%d",GetLastError());
00256       Error ("ChoosePixelFormat failed");
00257     }
00258 
00259     if (!SetPixelFormat(hDC, pixelformat, &pfd))
00260       Error ("SetPixelFormat failed");
00261   }
00262 
00263     return pixelformat;
00264 }
00265 
00266 /*
00267 =================
00268 Error
00269 
00270 For abnormal program terminations
00271 =================
00272 */
00273 void Error (char *error, ...)
00274 {
00275     va_list argptr;
00276     char    text[1024];
00277     char    text2[1024];
00278     int     err;
00279     
00280     err = GetLastError ();
00281     int i = qglGetError();
00282     
00283     va_start (argptr,error);
00284     vsprintf (text, error,argptr);
00285     va_end (argptr);
00286     
00287     sprintf (text2, "%s\nGetLastError() = %i - %i\nAn unrecoverable error has occured. Would you like to edit Preferences before exiting Q3Radiant?", text, err, i);
00288     
00289     if (MessageBox(g_qeglobals.d_hwndMain, text2, "Error", MB_YESNO) == IDYES)
00290     {
00291         g_PrefsDlg.LoadPrefs();
00292         g_PrefsDlg.DoModal();
00293     }
00294     
00295     exit (1);
00296 }
00297 
00298 
00299 void Warning (char *error, ...)
00300 {
00301     va_list argptr;
00302     char    text[1024];
00303     int     err;
00304 
00305     err = GetLastError ();
00306   int i = qglGetError();
00307 
00308     va_start (argptr,error);
00309     vsprintf (text, error,argptr);
00310     va_end (argptr);
00311 
00312   Sys_Printf(text);
00313 }
00314 
00315 
00316 /*
00317 ======================================================================
00318 
00319 FILE DIALOGS
00320 
00321 ======================================================================
00322 */
00323  
00324 qboolean ConfirmModified (void)
00325 {
00326     if (!modified)
00327         return true;
00328 
00329     if (MessageBox (g_qeglobals.d_hwndMain, "This will lose changes to the map"
00330         , "warning", MB_OKCANCEL) == IDCANCEL)
00331         return false;
00332     return true;
00333 }
00334 
00335 static OPENFILENAME ofn;       /* common dialog box structure   */ 
00336 static char szDirName[MAX_PATH];    /* directory string              */ 
00337 static char szFile[260];       /* filename string               */ 
00338 static char szFileTitle[260];  /* file title string             */ 
00339 static char szFilter[260] =     /* filter string                 */ 
00340     "Map file (*.map, *.reg)\0*.map\0*.reg\0\0";
00341 static char szProjectFilter[260] =     /* filter string                 */ 
00342     "Q3Radiant project (*.qe4, *.prj)\0*.qe4\0*.prj\0\0";
00343 static char chReplace;         /* string separator for szFilter */ 
00344 static int i, cbString;        /* integer count variables       */ 
00345 static HANDLE hf;              /* file handle                   */ 
00346 
00347 void OpenDialog (void)
00348 {
00349     /* 
00350      * Obtain the system directory name and 
00351      * store it in szDirName. 
00352      */ 
00353  
00354     strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "mapspath") );
00355   if (strlen(szDirName) == 0)
00356   {
00357       strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") );
00358       strcat (szDirName, "\\maps");
00359   }
00360 
00361     /* Place the terminating null character in the szFile. */ 
00362  
00363     szFile[0] = '\0'; 
00364  
00365     /* Set the members of the OPENFILENAME structure. */ 
00366  
00367     ofn.lStructSize = sizeof(OPENFILENAME); 
00368     ofn.hwndOwner = g_qeglobals.d_hwndCamera;
00369     ofn.lpstrFilter = szFilter; 
00370     ofn.nFilterIndex = 1; 
00371     ofn.lpstrFile = szFile; 
00372     ofn.nMaxFile = sizeof(szFile); 
00373     ofn.lpstrFileTitle = szFileTitle; 
00374     ofn.nMaxFileTitle = sizeof(szFileTitle); 
00375     ofn.lpstrInitialDir = szDirName; 
00376     ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | 
00377         OFN_FILEMUSTEXIST; 
00378 
00379     /* Display the Open dialog box. */ 
00380  
00381     if (!GetOpenFileName(&ofn))
00382         return; // canceled
00383  
00384     // Add the file in MRU.
00385   //FIXME
00386     AddNewItem( g_qeglobals.d_lpMruMenu, ofn.lpstrFile);
00387 
00388     // Refresh the File menu.
00389   //FIXME
00390     PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0), 
00391             ID_FILE_EXIT);
00392 
00393     /* Open the file. */ 
00394  
00395     Map_LoadFile (ofn.lpstrFile);   
00396 }
00397 
00398 void ProjectDialog (void)
00399 {
00400     /* 
00401      * Obtain the system directory name and 
00402      * store it in szDirName. 
00403      */ 
00404  
00405     strcpy (szDirName, ValueForKey(g_qeglobals.d_project_entity, "basepath") );
00406     strcat (szDirName, "\\scripts");
00407 
00408     /* Place the terminating null character in the szFile. */ 
00409  
00410     szFile[0] = '\0'; 
00411  
00412     /* Set the members of the OPENFILENAME structure. */ 
00413  
00414     ofn.lStructSize = sizeof(OPENFILENAME); 
00415     ofn.hwndOwner = g_qeglobals.d_hwndCamera;
00416     ofn.lpstrFilter = szProjectFilter; 
00417     ofn.nFilterIndex = 1; 
00418     ofn.lpstrFile = szFile; 
00419     ofn.nMaxFile = sizeof(szFile); 
00420     ofn.lpstrFileTitle = szFileTitle; 
00421     ofn.nMaxFileTitle = sizeof(szFileTitle); 
00422     ofn.lpstrInitialDir = szDirName; 
00423     ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | 
00424         OFN_FILEMUSTEXIST; 
00425 
00426     /* Display the Open dialog box. */ 
00427  
00428     if (!GetOpenFileName(&ofn))
00429         return; // canceled
00430  
00431     // Refresh the File menu.
00432     PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0), 
00433             ID_FILE_EXIT);
00434 
00435     /* Open the file. */ 
00436     if (!QE_LoadProject(ofn.lpstrFile))
00437         Error ("Couldn't load project file");
00438 }
00439 
00440 
00441 extern void AddSlash(CString& strPath);
00442 void SaveAsDialog (bool bRegion)
00443 { 
00444     strcpy (szDirName, ValueForKey (g_qeglobals.d_project_entity, "basepath") );
00445   CString strPath = szDirName;
00446   AddSlash(strPath);
00447   strPath += "maps";
00448 
00449     /* Place the terminating null character in the szFile. */ 
00450  
00451     szFile[0] = '\0'; 
00452  
00453     /* Set the members of the OPENFILENAME structure. */ 
00454  
00455     ofn.lStructSize = sizeof(OPENFILENAME); 
00456     ofn.hwndOwner = g_qeglobals.d_hwndCamera;
00457     ofn.lpstrFilter = szFilter; 
00458     ofn.nFilterIndex = 1; 
00459     ofn.lpstrFile = szFile; 
00460     ofn.nMaxFile = sizeof(szFile); 
00461     ofn.lpstrFileTitle = szFileTitle; 
00462     ofn.nMaxFileTitle = sizeof(szFileTitle); 
00463     ofn.lpstrInitialDir = strPath; 
00464     ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | 
00465         OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT; 
00466 
00467     /* Display the Open dialog box. */ 
00468  
00469     if (!GetSaveFileName(&ofn))
00470         return; // canceled
00471 
00472   if (bRegion)
00473       DefaultExtension (ofn.lpstrFile, ".reg");
00474   else
00475       DefaultExtension (ofn.lpstrFile, ".map");
00476 
00477   if (!bRegion)
00478   {
00479       strcpy (currentmap, ofn.lpstrFile);
00480     AddNewItem(g_qeglobals.d_lpMruMenu, ofn.lpstrFile);
00481       PlaceMenuMRUItem(g_qeglobals.d_lpMruMenu,GetSubMenu(GetMenu(g_qeglobals.d_hwndMain),0),   ID_FILE_EXIT);
00482   }
00483     Map_SaveFile (ofn.lpstrFile, bRegion);  // ignore region
00484 }
00485 
00486 /*
00487 =======================================================
00488 
00489 Menu modifications
00490 
00491 =======================================================
00492 */
00493 
00494 /*
00495 ==================
00496 FillBSPMenu
00497 
00498 ==================
00499 */
00500 char    *bsp_commands[256];
00501 
00502 void FillBSPMenu (void)
00503 {
00504     HMENU   hmenu;
00505     epair_t *ep;
00506     int     i;
00507     static int count;
00508 
00509     hmenu = GetSubMenu (GetMenu(g_qeglobals.d_hwndMain), MENU_BSP);
00510 
00511     for (i=0 ; i<count ; i++)
00512         DeleteMenu (hmenu, CMD_BSPCOMMAND+i, MF_BYCOMMAND);
00513     count = 0;
00514 
00515     if ( g_qeglobals.bBSPFrontendPlugin )
00516     {
00517         CString str = g_BSPFrontendTable.m_pfnGetBSPMenu();
00518         char cTemp[1024];
00519         strcpy(cTemp, str);
00520         char* token = strtok(cTemp, ",;");
00521         if (token && *token == ' ')
00522         {
00523             while (*token == ' ')
00524                 token++;
00525         }
00526         i = 0;
00527         // first token is menu name
00528         ModifyMenu( GetMenu(g_qeglobals.d_hwndMain), MENU_BSP, MF_BYPOSITION, MENU_BSP, (LPCTSTR)token );
00529         // redraw the menu bar
00530         DrawMenuBar( g_qeglobals.d_hwndMain );
00531         token = strtok(NULL, ",;");
00532         while (token != NULL)
00533         {
00534             g_BSPFrontendCommands.Add(token);
00535             AppendMenu (hmenu, MF_ENABLED|MF_STRING, CMD_BSPCOMMAND+i, (LPCTSTR)token );
00536             token = strtok(NULL, ",;");
00537             i++;
00538         }
00539         count = i;
00540     }
00541     else
00542     {
00543         i = 0;
00544         for (ep = g_qeglobals.d_project_entity->epairs ; ep ; ep=ep->next)
00545         {
00546             if (ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p')
00547             {
00548                 bsp_commands[i] = ep->key;
00549                 AppendMenu (hmenu, MF_ENABLED|MF_STRING,
00550                     CMD_BSPCOMMAND+i, (LPCTSTR)ep->key);
00551                 i++;
00552             }
00553         }
00554         count = i;
00555     }
00556 }
00557 
00558 //==============================================
00559 void AddSlash(CString& strPath)
00560 {
00561   if (strPath.GetLength() > 0)
00562   {
00563     if (strPath.GetAt(strPath.GetLength()-1) != '\\')
00564       strPath += '\\';
00565   }
00566 }
00567 
00568 
00569 bool ExtractPath_and_Filename(const char* pPath, CString& strPath, CString& strFilename)
00570 {
00571   CString strPathName = pPath;
00572   int nSlash = strPathName.ReverseFind('\\');
00573   if (nSlash >= 0)
00574   {
00575     strPath = strPathName.Left(nSlash+1);
00576     strFilename = strPathName.Right(strPathName.GetLength() - nSlash - 1);
00577   }
00578   else strFilename = pPath;
00579   return true;
00580 }
00581 
00582 
00583 /*
00584 ===============
00585 CheckBspProcess
00586 
00587 See if the BSP is done yet
00588 ===============
00589 */
00590 extern void FindReplace(CString& strContents, const char* pTag, const char* pValue);
00591 extern CTime g_tBegin;
00592 
00593 void CheckBspProcess (void)
00594 {
00595     char    outputpath[1024];
00596     char    temppath[512];
00597     DWORD   exitcode;
00598     char    *out;
00599     BOOL    ret;
00600 
00601     if (!bsp_process)
00602         return;
00603 
00604     ret = GetExitCodeProcess (bsp_process, &exitcode);
00605     if (!ret)
00606         Error ("GetExitCodeProcess failed");
00607     if (exitcode == STILL_ACTIVE)
00608         return;
00609 
00610     bsp_process = 0;
00611 
00612     GetTempPath(512, temppath);
00613     sprintf (outputpath, "%sjunk.txt", temppath);
00614 
00615     LoadFile (outputpath, (void **)&out);
00616     Sys_Printf ("%s", out);
00617     Sys_Printf ("\ncompleted.\n");
00618     free (out);
00619 
00620     CTime tEnd = CTime::GetCurrentTime();
00621     CTimeSpan tElapsed = tEnd - g_tBegin;
00622     CString strElapsed;
00623     strElapsed.Format("Run time was %i hours, %i minutes and %i seconds", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());
00624     Sys_Printf(strElapsed.GetBuffer(0));
00625 
00626 
00627     Sys_Beep ();
00628     Pointfile_Check();
00629     // run game if no PointFile and pref is set
00630     //++timo needs to stop after BSP if leaked .. does run through vis and light instead ..
00631     if (g_PrefsDlg.m_bRunQuake == TRUE  && !g_qeglobals.d_pointfile_display_list)
00632     {
00633         char cCurDir[1024];
00634         GetCurrentDirectory(1024, cCurDir);
00635         CString strExePath = g_PrefsDlg.m_strQuake2;
00636         CString strOrgPath;
00637         CString strOrgFile;
00638         ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
00639         if (g_PrefsDlg.m_bSetGame == TRUE) // run in place with set game.. don't copy map
00640         {
00641             CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
00642             strExePath += " +set game ";
00643             strExePath += strBasePath;
00644             WinExec(strExePath, SW_SHOW);
00645         }
00646         else
00647         {
00648             CString strCopyPath = strExePath;
00649             char* pBuffer = strCopyPath.GetBufferSetLength(_MAX_PATH + 1);
00650             pBuffer[strCopyPath.ReverseFind('\\') + 1] = '\0';
00651             strCopyPath.ReleaseBuffer();
00652             SetCurrentDirectory(strCopyPath);
00653             CString strOrgPath;
00654             CString strOrgFile;
00655             ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
00656             AddSlash(strCopyPath);
00657             FindReplace(strOrgFile, ".map", ".bsp");
00658             //++timo modified for Quake3 !!
00659             strCopyPath += "baseq3\\maps\\";
00660             strCopyPath += strOrgFile;
00661             AddSlash(strOrgPath);
00662             strOrgPath += strOrgFile;
00663             bool bRun = (strOrgPath.CompareNoCase(strCopyPath) == 0);
00664             if (!bRun)
00665                 bRun = (CopyFile(strOrgPath, strCopyPath, FALSE) == TRUE);
00666             if (bRun)
00667             {
00668                 FindReplace(strOrgFile, ".bsp", "");
00669                 strExePath += " +map ";
00670                 strExePath += strOrgFile;
00671                 WinExec(strExePath, SW_SHOW);
00672             }
00673         }
00674         SetCurrentDirectory(cCurDir);
00675     }
00676 }
00677 
00678 extern int  cambuttonstate;
00679 
00680 extern "C" {
00681 void *Com_Allocate( int bytes ) {
00682     return malloc(bytes);
00683 }
00684 
00685 void Com_Dealloc( void *ptr ) {
00686     free(ptr);
00687 }
00688 
00689 
00690 void Com_Printf( const char *msg, ... ) {
00691     va_list argptr;
00692     char    buf[32768];
00693     char    *out;
00694 
00695     va_start (argptr,msg);
00696     vsprintf (buf, msg,argptr);
00697     va_end (argptr);
00698 
00699     out = TranslateString (buf);
00700 
00701     Sys_Printf(buf);
00702 }
00703 
00704 void Com_Error( int level, const char *error, ... ) {
00705     va_list argptr;
00706     char    buf[32768];
00707     char    *out;
00708 
00709     va_start (argptr,error);
00710     vsprintf (buf, error,argptr);
00711     va_end (argptr);
00712 
00713     out = TranslateString (buf);
00714 
00715     Sys_Printf(buf);
00716 }
00717 
00718 void Com_DPrintf( const char *msg, ... ) {
00719     return;
00720 }
00721 
00722 int FS_Write( const void *buffer, int len, fileHandle_t h ) {
00723     SafeWrite(reinterpret_cast<FILE*>(h), buffer, len);
00724     return len;
00725 }
00726 
00727 int FS_ReadFile( const char *qpath, void **buffer ) {
00728     CString strPath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
00729     AddSlash(strPath);
00730     strPath += qpath;
00731     return LoadFile(strPath, buffer);
00732 }
00733 
00734 void FS_FreeFile( void *buffer ) {
00735     Com_Dealloc(buffer);
00736 }
00737 
00738 fileHandle_t FS_FOpenFileWrite( const char *filename ) {
00739     CString strPath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
00740     AddSlash(strPath);
00741     strPath += filename;
00742     // bad casting ptr to int
00743     return reinterpret_cast<fileHandle_t>(SafeOpenWrite(strPath));
00744 }
00745 
00746 void FS_FCloseFile( fileHandle_t f ) {
00747     fclose(reinterpret_cast<FILE*>(f));
00748 }
00749 
00750 
00751 
00752 }
00753 

Generated on Thu Aug 25 12:38:43 2005 for Quake III Arena by  doxygen 1.3.9.1