ResponseCommon * ResponseCommon_New(const OperationCommon * operation, TreeNode objectsNode)
{
    ResponseCommon * response = NULL;

    if (operation != NULL)
    {
        if (objectsNode != NULL)
        {
            response = Awa_MemAlloc(sizeof(*response));
            if (response != NULL)
            {
                memset(response, 0, sizeof(*response));
                response->OperationCommon = operation;
                response->ObjectsNode = Tree_Copy(objectsNode);

                // build the Values data structure
                if (ResponseCommon_BuildValues(response) == AwaError_Success)
                {
                    // not all responses have Values, so success includes no values
                }
                else
                {
                    // there was an error building values
                    LogDebug("Failed to build response values - continuing");
                }

                if (ResponseCommon_BuildPathResults(response) == AwaError_Success)
                {
                    // not all responses have path results
                }
                else
                {
                    // there was an error building values
                    LogErrorWithEnum(AwaError_ResponseInvalid, "Failed to build path results - continuing");
                }

                response->NulledValues = Map_New();

                LogNew("ResponseCommon", response);

            }
            else
            {
                LogErrorWithEnum(AwaError_OutOfMemory);
            }
        }
        else
        {
            LogError("Content Response is NULL");
        }
    }
    else
    {
        LogError("Operation is NULL");
    }
    return response;
}
Esempio n. 2
0
AwaClientSubscribeOperation * AwaClientSubscribeOperation_New(const AwaClientSession * session)
{
    AwaClientSubscribeOperation * operation = NULL;

    if (session != NULL)
    {
        if (ClientSession_IsConnected(session) != false)
        {
            operation = Awa_MemAlloc(sizeof(*operation));
            if (operation != NULL)
            {
                memset(operation, 0, sizeof(*operation));
                operation->Common = OperationCommon_NewWithClientSession(session);
                if (operation->Common != NULL)
                {
                    operation->Subscribers = Map_New();

                    if (operation->Subscribers != NULL)
                    {
                        LogNew("AwaClientSubscribeOperation", operation);
                    }
                    else
                    {
                        LogErrorWithEnum(AwaError_OutOfMemory, "Could not create subscriber list.");
                        Awa_MemSafeFree(operation);
                        operation = NULL;
                    }
                }
                else
                {
                    LogErrorWithEnum(AwaError_Internal, "Unable to initialise operation.");
                    Awa_MemSafeFree(operation);
                    operation = NULL;
                }
            }
            else
            {
                LogErrorWithEnum(AwaError_OutOfMemory);
            }
        }
        else
        {
            LogError("Session is not connected");
        }
    }
    else
    {
        LogError("Session is NULL");
    }
    return operation;
}
Esempio n. 3
0
int IOCP_Init(IOCP* iocp, int threads)
{
	SYSTEM_INFO sysInfo;
	int i = 0;

	if(threads <= 0)
	{
		GetSystemInfo(&sysInfo);
		threads = sysInfo.dwNumberOfProcessors;
	}
	if(threads <= 0 || threads > 64)
		threads = 5; 

	if( NULL == (iocp->iocpHandle = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, (ULONG_PTR)NULL, threads)) )
	{
		iocp->lastErrorCode = GetLastError();
		//iocp->destory(iocp);
		IOCP_Destroy(iocp);
		return IOCP_UNDEFINED;
	}

	TimerQueue_Init(&iocp->timerQueue);
	LockPool_Init(&iocp->lockPool, 0);

	iocp->threads = threads;
	if(iocp->hThreads)
		xFree(iocp->hThreads);
	iocp->hThreads = xMalloc(sizeof(HANDLE)* threads);
	xMemSet(iocp->hThreads, 0, sizeof(HANDLE) * threads);

	for(i = 0; i < iocp->threads; ++i)
	{
		//if(0 == (iocp->hThreads[i] = _beginthreadex(NULL, 0, IOCP_Service, iocp, 0, NULL)))
		if(NULL == (iocp->hThreads[i] = CreateThread(NULL, 0, IOCP_Service, iocp, 0, NULL)))
		{
			//iocp->lastErrorCode = errno;
			iocp->lastErrorCode = GetLastError();
			//iocp->destroy(iocp);
			IOCP_Destroy(iocp);
			return IOCP_UNDEFINED;
		}
	}
	iocp->contextMap = Map_New();

	InitializeCriticalSection(&iocp->cs);
	iocp->inited = TRUE;
	return IOCP_SUCESS;
}
AwaServerListClientsOperation * AwaServerListClientsOperation_New(const AwaServerSession * session)
{
    AwaServerListClientsOperation * operation = NULL;

    if (session != NULL)
    {
        if (ServerSession_IsConnected(session) != false)
        {
            operation = Awa_MemAlloc(sizeof(*operation));
            if (operation != NULL)
            {
                memset(operation, 0, sizeof(*operation));
                operation->ServerResponse = NULL;
                operation->ServerOperation = ServerOperation_New(session);
                if (operation->ServerOperation != NULL)
                {
                    operation->ClientResponseMap = Map_New();
                    LogNew("AwaServerListClientsOperation", operation);
                }
                else
                {
                    LogErrorWithEnum(AwaError_Internal, "Unable to initialise operation");
                    Awa_MemSafeFree(operation);
                    operation = NULL;
                }
            }
            else
            {
                LogErrorWithEnum(AwaError_OutOfMemory);
            }
        }
        else
        {
            LogErrorWithEnum(AwaError_SessionNotConnected);
        }
    }
    else
    {
        LogError("Session is NULL");
    }
    return operation;
}
Esempio n. 5
0
/*
 =======================================================================================================================
    QE_LoadProject
 =======================================================================================================================
 */
bool QE_LoadProject(char *projectfile) {
	char		*data;
	ID_TIME_T		time;

	common->Printf("QE_LoadProject (%s)\n", projectfile);

	if ( fileSystem->ReadFile( projectfile, reinterpret_cast < void ** > (&data), &time) <= 0 ) {
		return false;
	}

	g_strProject = projectfile;
	g_PrefsDlg.m_strLastProject = projectfile;
	g_PrefsDlg.SavePrefs();

	CString strData = data;

	fileSystem->FreeFile( data );

	StartTokenParsing(strData.GetBuffer(0));
	g_qeglobals.d_project_entity = Entity_Parse(true);
	if (!g_qeglobals.d_project_entity) {
		Error("Couldn't parse %s", projectfile);
	}

	// set here some default project settings you need
	if (strlen(ValueForKey(g_qeglobals.d_project_entity, "brush_primit")) == 0) {
		SetKeyValue(g_qeglobals.d_project_entity, "brush_primit", "0");
	}

	g_qeglobals.m_bBrushPrimitMode = IntForKey(g_qeglobals.d_project_entity, "brush_primit");

	Eclass_InitForSourceDirectory(ValueForKey(g_qeglobals.d_project_entity, "entitypath"));
	g_Inspectors->FillClassList();	// list in entity window

	Map_New();

	// FillTextureMenu();
	FillBSPMenu();

	return true;
}
Esempio n. 6
0
AwaServerSession * AwaServerSession_New(void)
{
    AwaServerSession * session = Awa_MemAlloc(sizeof(*session));
    if (session != NULL)
    {
        memset(session, 0, sizeof(*session));

        session->SessionCommon = SessionCommon_New(SessionType_Server);
        if (session->SessionCommon != NULL)
        {
            session->Observers = Map_New();
            if (session->Observers)
            {
                session->NotificationQueue = Queue_New();
            }
            else
            {
                LogErrorWithEnum(AwaError_OutOfMemory, "Could not create observer list");
                SessionCommon_Free(&session->SessionCommon);
                Awa_MemSafeFree(session);
                session = NULL;
            }
        }
        else
        {
            LogErrorWithEnum(AwaError_OutOfMemory, "Could not create common session");
            SessionCommon_Free(&session->SessionCommon);
            Awa_MemSafeFree(session);
            session = NULL;
        }
    }
    else
    {
        LogErrorWithEnum(AwaError_OutOfMemory, "Could not create ServerSession");
    }
    return session;
}
Esempio n. 7
0
/*
   ================
   Map_LoadFile
   ================
 */
void Map_LoadFile( const char *filename ){
	clock_t start, finish;
	double elapsed_time;
	start = clock();

	Sys_BeginWait();
	Select_Deselect();
	/*!
	   \todo FIXME TTimo why is this commented out?
	   stability issues maybe? or duplicate feature?
	   forcing to show the console during map load was a good thing IMO
	 */
	//SetInspectorMode(W_CONSOLE);
	Sys_Printf( "Loading map from %s\n", filename );

	Map_Free();
	//++timo FIXME: maybe even easier to have Group_Init called from Map_Free?
	Group_Init();
	g_qeglobals.d_num_entities = 0;
	g_qeglobals.d_parsed_brushes = 0;


	// cancel the map loading process
	// used when conversion between standard map format and BP format is required and the user cancels the process
	g_bCancel_Map_LoadFile = false;

	strcpy( currentmap, filename );

	g_bScreenUpdates = false; // leo: avoid redraws while loading the map (see fenris:1952)

	// prepare to let the map module do the parsing
	FileStream file;
	const char* type = strrchr( filename,'.' );
	if ( type != NULL ) {
		type++;
	}
	// NOTE TTimo opening has binary doesn't make a lot of sense
	// but opening as text confuses the scriptlib parser
	// this may be a problem if we "rb" and use the XML parser, might have an incompatibility
	if ( file.Open( filename, "rb" ) ) {
		Map_Import( &file, type );
	}
	else{
		Sys_FPrintf( SYS_ERR, "ERROR: failed to open %s for read\n", filename );
	}
	file.Close();

	g_bScreenUpdates = true;

	if ( g_bCancel_Map_LoadFile ) {
		Sys_Printf( "Map_LoadFile canceled\n" );
		Map_New();
		Sys_EndWait();
		return;
	}

	if ( !world_entity ) {
		Sys_Printf( "No worldspawn in map.\n" );
		Map_New();
		Sys_EndWait();
		return;
	}
	finish = clock();
	elapsed_time = (double)( finish - start ) / CLOCKS_PER_SEC;

	Sys_Printf( "--- LoadMapFile ---\n" );
	Sys_Printf( "%s\n", filename );

	Sys_Printf( "%5i brushes\n",  g_qeglobals.d_parsed_brushes );
	Sys_Printf( "%5i entities\n", g_qeglobals.d_num_entities );
	Sys_Printf( "%5.2f second(s) load time\n", elapsed_time );

	Sys_EndWait();

	Map_RestoreBetween();

	//
	// move the view to a start position
	//
	Map_StartPosition();

	Map_RegionOff();

	modified = false;
	Sys_SetTitle( filename );

	Texture_ShowInuse();
	QERApp_SortActiveShaders();

	Sys_UpdateWindows( W_ALL );
}
AwaError ResponseCommon_BuildPathResults(ResponseCommon * response)
{
    AwaError result = AwaError_Success;  // success if no path results are found
    if (response != NULL)
    {
        FreeSimpleMap(&response->PathResults);
        response->PathResults = Map_New();
        if (response->PathResults != NULL)
        {
            TreeNode currentLeafNode = response->ObjectsNode;
            while ((currentLeafNode = ObjectsTree_GetNextLeafNode(currentLeafNode)) != NULL)
            {
                TreeNode currentNode = currentLeafNode;  // start at leaf and add path results for parents as well
                while (currentNode != NULL)
                {
                    char path[MAX_PATH_LENGTH] = { 0 };
                    ObjectsTree_GetPath(currentNode, path, sizeof(path));

                    TreeNode resultNode = Xml_Find(currentNode, "Result");
                    if (resultNode != NULL)
                    {
                        PathResult * pathResult = PathResult_New(resultNode);
                        if (pathResult != NULL)
                        {
                            if (!Map_Contains(response->PathResults, path))
                            {
                                Map_Put(response->PathResults, path, pathResult);
                                result = AwaError_Success;
                            }
                            else if (currentNode == currentLeafNode)
                            {
                                PathResult_Free(&pathResult);
                                result = LogErrorWithEnum(AwaError_Internal, "A pathResult already exists for %s\n", path);
                                goto error;
                            }
                            else
                            {
                                // Already added parent node
                                PathResult_Free(&pathResult);
                            }
                        }
                        else
                        {
                            result = LogErrorWithEnum(AwaError_Internal, "Could not create pathResult for %s", path);
                            goto error;
                        }
                    }
                    else
                    {
                        // not all leaves or responses have PathResults, so skip
                    }
                    currentNode = ObjectsTree_IsObjectNode(currentNode)? NULL : TreeNode_GetParent(currentNode);
                }
            }
        }
        else
        {
            result = LogErrorWithEnum(AwaError_OutOfMemory);
        }
    }
    else
    {
        result = LogErrorWithEnum(AwaError_ResponseInvalid, "response is NULL");
    }
error:
    return result;
}
AwaError ResponseCommon_BuildValues(ResponseCommon * response)
{
    AwaError result = AwaError_Success;  // success if no values are found
    if (response != NULL)
    {
        FreeValues(&response->Values);
        response->Values = Map_New();
        if (response->Values != NULL)
        {
            // get the resource type for the path
            const OperationCommon * operation = ResponseCommon_GetOperation(response);
            if (operation != NULL)
            {
                const SessionCommon * sessionCommon = OperationCommon_GetSessionCommon(operation);
                if (sessionCommon != NULL)
                {
                    TreeNode currentNode = response->ObjectsNode;
                    while ((currentNode = ObjectsTree_GetNextLeafNode(currentNode)) != NULL)
                    {
                        char path[MAX_PATH_LENGTH] = { 0 };
                        ObjectsTree_GetPath(currentNode, path, sizeof(path));

                        if (Path_IsValidForResource(path))
                        {
                            LogDebug("Build values path: %s", path);

                            const AwaResourceDefinition * resourceDefinition = SessionCommon_GetResourceDefinitionFromPath(sessionCommon, path);
                            if (resourceDefinition != NULL)
                            {
                                AwaResourceType resourceType = AwaResourceDefinition_GetType(resourceDefinition);
                                if (resourceType != AwaResourceType_Invalid)
                                {
                                    Value * value = Value_New(currentNode, resourceType);

                                    if (value != NULL)
                                    {
                                        if (!Map_Contains(response->Values, path))
                                        {
                                            LogDebug("MAP item path: %s", path);
                                            Map_Put(response->Values, path, value);
                                            result = AwaError_Success;
                                        }
                                        else
                                        {
                                            result = LogErrorWithEnum(AwaError_Internal, "A value already exists for %s", path);
                                        }
                                    }
                                    else
                                    {
                                        // No value is fine - occurs in operations where we only expect path results in the response.
                                    }

                                }
                                else
                                {
                                    result = LogErrorWithEnum(AwaError_DefinitionInvalid, "resourceDefinition for %s has invalid type", path);
                                }
                            }
                            else
                            {
                                result = LogErrorWithEnum(AwaError_DefinitionInvalid, "resourceDefinition for %s is NULL", path);
                            }
                        }
                    }
                }
                else
                {
                    result = LogErrorWithEnum(AwaError_SessionInvalid, "session is NULL");
                }
            }
            else
            {
                result = LogErrorWithEnum(AwaError_OperationInvalid, "operation is NULL");
            }
        }
        else
        {
            result = LogErrorWithEnum(AwaError_OutOfMemory);
        }
    }
    else
    {
        result = LogErrorWithEnum(AwaError_ResponseInvalid, "response is NULL");
    }
    return result;
}
Esempio n. 10
0
 /*
 =======================================================================================================================
	Map_LoadFile
 =======================================================================================================================
 */
void Map_LoadFile(const char *filename) {
	entity_t *ent;
	CWaitDlg dlg;
	idStr fileStr, status;
	idMapFile mapfile;

	Sys_BeginWait();
	Select_Deselect();

	dlg.AllowCancel( true );
	idStr( filename ).ExtractFileName( fileStr );
	sprintf( status, "Loading %s...", fileStr.c_str() );
	dlg.SetWindowText( status );
	sprintf( status, "Reading file %s...", fileStr.c_str() );
	dlg.SetText( status );

	// SetInspectorMode(W_CONSOLE);
	fileStr = filename;
	fileStr.BackSlashesToSlashes();

	common->Printf( "Map_LoadFile: %s\n", fileStr.c_str() );

	Map_Free();

	g_qeglobals.d_parsed_brushes = 0;
	strcpy( currentmap, filename );

	if(mapfile.Parse(filename, true, true)) {
		g_qeglobals.bNeedConvert = false;
		g_qeglobals.bOldBrushes = false;
		g_qeglobals.bPrimitBrushes = false;
		g_qeglobals.mapVersion = 1.0;

		long lastUpdate = 0;
		int count = mapfile.GetNumEntities();
		for (int i = 0; i < count; i++) {
			idMapEntity *mapent = mapfile.GetEntity(i);
			if (mapent) {
				idStr classname = mapent->epairs.GetString("classname");
				// Update 20 times a second
				if ( (GetTickCount() - lastUpdate) > 50 ) {
					lastUpdate = GetTickCount();
					sprintf(status, "Loading entity %i (%s)...", i, classname.c_str());
					dlg.SetText(status);
				}
				if ( dlg.CancelPressed() ) {
					Sys_Status("Map load cancelled.\n");
					Map_New();
					return;
				}
				if (classname == "worldspawn") {
					world_entity = EntityFromMapEntity(mapent, &dlg);
					Entity_PostParse(world_entity, &active_brushes);
				} else {
					ent = EntityFromMapEntity(mapent, &dlg);
					Entity_PostParse(ent, &active_brushes);
					Entity_Name(ent, true);
					// add the entity to the end of the entity list
					ent->next = &entities;
					ent->prev = entities.prev;
					entities.prev->next = ent;
					entities.prev = ent;
					g_qeglobals.d_num_entities++;
				}
			}
		}
	}

	if (!world_entity) {
		Sys_Status("No worldspawn in map.\n");
		Map_New();
		return;
	}

	common->Printf("--- LoadMapFile ---\n");
	common->Printf("%s\n", fileStr.c_str());

	common->Printf("%5i brushes\n", g_qeglobals.d_parsed_brushes);
	common->Printf("%5i entities\n", g_qeglobals.d_num_entities);

	dlg.SetText("Restoring Between");
	Map_RestoreBetween();

	dlg.SetText("Building Brush Data");
	common->Printf("Map_BuildAllDisplayLists\n");
	Map_BuildBrushData();

	//
	// reset the "need conversion" flag conversion to the good format done in
	// Map_BuildBrushData
	//
	g_qeglobals.bNeedConvert = false;

	// move the view to a start position
	ent = AngledEntity();

	g_pParentWnd->GetCamera()->Camera().angles[PITCH] = 0;

	if (ent) {
		GetVectorForKey(ent, "origin", g_pParentWnd->GetCamera()->Camera().origin);
		GetVectorForKey(ent, "origin", g_pParentWnd->GetXYWnd()->GetOrigin());
		g_pParentWnd->GetCamera()->Camera().angles[YAW] = FloatForKey(ent, "angle");
	}
	else {
		g_pParentWnd->GetCamera()->Camera().angles[YAW] = 0;
		VectorCopy(vec3_origin, g_pParentWnd->GetCamera()->Camera().origin);
		VectorCopy(vec3_origin, g_pParentWnd->GetXYWnd()->GetOrigin());
	}

	Map_RegionOff();

	mapModified = 0;

	if (GetFileAttributes(filename) & FILE_ATTRIBUTE_READONLY) {
		fileStr += " (read only) ";
	}
	Sys_SetTitle(fileStr);

	Texture_ShowInuse();

	if (g_pParentWnd->GetCamera()->GetRenderMode()) {
		g_pParentWnd->GetCamera()->BuildRendererState();
	}

	Sys_EndWait();
	Sys_UpdateWindows(W_ALL);
}
Esempio n. 11
0
/*
===========
QE_LoadProject
FIXME: the BuildShortPathName calls should be removed, it would get much more cleaner
  I don't have time to modify something so deep in the system, but this lead to a bug when loading .md3
	see Win_ent.cpp AssignModel
===========
*/
qboolean QE_LoadProject (char *projectfile)
{
	char	*data;
	Sys_Printf ("QE_LoadProject (%s)\n", projectfile);
	
	if ( LoadFileNoCrash (projectfile, (void **)&data) == -1)
		return false;
	
	g_strProject = projectfile;
	
	CString strData = data;
	free(data);
	
	CString strQ2Path = g_PrefsDlg.m_strQuake2;
	CString strQ2File;
	ExtractPath_and_Filename(g_PrefsDlg.m_strQuake2, strQ2Path, strQ2File);
	AddSlash(strQ2Path);
	
	
	char* pBuff = new char[1024];
	
	//BuildShortPathName(strQ2Path, pBuff, 1024);
	strcpy_s(pBuff, 1024,strQ2Path);	// Jonathan: strcpy_s replaces BuildShortPathName
	FindReplace(strData, "__Q2PATH", pBuff);
	//BuildShortPathName(g_strAppPath, pBuff, 1024);
	strcpy_s(pBuff, 1024,g_strAppPath);	// Jonathan: strcpy_s replaces BuildShortPathName
	FindReplace(strData, "__QERPATH", pBuff);
	
	char* pFile;
	if (GetFullPathName(projectfile, 1024, pBuff, &pFile))
	{
		g_PrefsDlg.m_strLastProject = pBuff;
		//BuildShortPathName(g_PrefsDlg.m_strLastProject, pBuff, 1024);
		g_PrefsDlg.m_strLastProject = pBuff;
		g_PrefsDlg.SavePrefs();
		
		ExtractPath_and_Filename(pBuff, strQ2Path, strQ2File);
		int nLen = strQ2Path.GetLength();
		if (nLen > 0)
		{
			if (strQ2Path[nLen - 1] == '\\')
				strQ2Path.SetAt(nLen-1,'\0');
			char* pBuffer = strQ2Path.GetBufferSetLength(_MAX_PATH + 1);
			int n = strQ2Path.ReverseFind('\\');
			if (n >=0 )
				pBuffer[n + 1] = '\0';
			strQ2Path.ReleaseBuffer();
			FindReplace(strData, "__QEPROJPATH", strQ2Path);
		}
	}
	
	
	StartTokenParsing (strData.GetBuffer(0));
	g_qeglobals.d_project_entity = Entity_Parse (true);
	if (!g_qeglobals.d_project_entity)
		Error ("Couldn't parse project file: %s", projectfile);

  // add a version checking to avoid people loading later versions of the project file and bitching against me
  int ver = IntForKey( g_qeglobals.d_project_entity, "version" );
  if (ver != 0)
  {
    char strMsg[1024];
    sprintf( strMsg, "This is a version %d project file. This build only supports <=0 project files.\n"
      "Please choose another project file or upgrade your version of Radiant.", ver );
    MessageBox( NULL, strMsg, "Can't load project file", MB_ICONERROR | MB_OK );
    return false;
  }

  for (int i = 0; i < g_nPathFixupCount; i++)
  {
    char *pPath = ValueForKey (g_qeglobals.d_project_entity, g_pPathFixups[i]);
    if (pPath[0] != '\\' && pPath[0] != '/')
    {
	    if (GetFullPathName(pPath, 1024, pBuff, &pFile))
      {
        SetKeyValue(g_qeglobals.d_project_entity, g_pPathFixups[i], pBuff);
      }
    }
  }

	delete []pBuff;

	// set here some default project settings you need
	if ( strlen( ValueForKey( g_qeglobals.d_project_entity, "brush_primit" ) ) == 0 )
	{
		SetKeyValue( g_qeglobals.d_project_entity, "brush_primit", "0" );
	}

	g_qeglobals.m_bBrushPrimitMode = IntForKey( g_qeglobals.d_project_entity, "brush_primit" );

  // usefull for the log file and debuggin f****d up configurations from users:
  // output the basic information of the .qe4 project file
  Sys_Printf("basepath    : %s\n", ValueForKey( g_qeglobals.d_project_entity, "basepath") );
  Sys_Printf("mapspath    : %s\n", ValueForKey( g_qeglobals.d_project_entity, "mapspath") );
//  the rsh command code is probably broken in these builds .. I would need ppl that actually use it ..
//  Sys_Printf("rshcmd         : %s\n", ValueForKey( g_qeglobals.d_project_entity, "rshcmd" ) );
//  Sys_Printf("remotebasepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "remotebasepath" ) );
  Sys_Printf("entitypath  : %s\n", ValueForKey( g_qeglobals.d_project_entity, "entitypath" ) );
  Sys_Printf("texturepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "texturepath" ) );

	Eclass_InitForSourceDirectory (ValueForKey (g_qeglobals.d_project_entity, "entitypath"));
	FillClassList();		// list in entity window
	
	Map_New();
	
	
	FillTextureMenu();
	FillBSPMenu();
	
	return true;
}
Esempio n. 12
0
/* handle all WM_COMMAND messages here */
LONG WINAPI CommandHandler (
    HWND    hWnd,
    WPARAM  wParam,
    LPARAM  lParam)
{
	HMENU hMenu;

    switch (LOWORD(wParam))
    {
//
// file menu
//
    	case ID_FILE_EXIT:
            /* exit application */
			if (!ConfirmModified())
				return TRUE;

            PostMessage (hWnd, WM_CLOSE, 0, 0L);
			break;

		case ID_FILE_OPEN:
			if (!ConfirmModified())
				return TRUE;
			OpenDialog ();
			break;

		case ID_FILE_NEW:
			if (!ConfirmModified())
				return TRUE;
			Map_New ();
			break;
		case ID_FILE_SAVE:
			if (!strcmp(currentmap, "unnamed.map"))
				SaveAsDialog ();
			else
				Map_SaveFile (currentmap, false);	// ignore region
			break;
		case ID_FILE_SAVEAS:
			SaveAsDialog ();
			break;

		case ID_FILE_LOADPROJECT:
			if (!ConfirmModified())
				return TRUE;
			ProjectDialog ();
			break;

		case ID_FILE_POINTFILE:
			if (g_qeglobals.d_pointfile_display_list)
				Pointfile_Clear ();
			else
				Pointfile_Check ();
			break;

//
// view menu
//
		case ID_VIEW_ENTITY:
			SetInspectorMode(W_ENTITY);
			break;
		case ID_VIEW_CONSOLE:
			SetInspectorMode(W_CONSOLE);
			break;
		case ID_VIEW_TEXTURE:
			SetInspectorMode(W_TEXTURE);
			break;

		case ID_VIEW_100:
			g_qeglobals.d_xy.scale = 1;
			Sys_UpdateWindows (W_XY|W_XY_OVERLAY);
			break;
		case ID_VIEW_ZOOMIN:
			g_qeglobals.d_xy.scale *= 5.0/4;
			if (g_qeglobals.d_xy.scale > 16)
				g_qeglobals.d_xy.scale = 16;
			Sys_UpdateWindows (W_XY|W_XY_OVERLAY);
			break;
		case ID_VIEW_ZOOMOUT:
			g_qeglobals.d_xy.scale *= 4.0/5;
			if (g_qeglobals.d_xy.scale < 0.1)
				g_qeglobals.d_xy.scale = 0.1;
			Sys_UpdateWindows (W_XY|W_XY_OVERLAY);
			break;

		case ID_VIEW_Z100:
			z.scale = 1;
			Sys_UpdateWindows (W_Z|W_Z_OVERLAY);
			break;
		case ID_VIEW_ZZOOMIN:
			z.scale *= 5.0/4;
			if (z.scale > 4)
				z.scale = 4;
			Sys_UpdateWindows (W_Z|W_Z_OVERLAY);
			break;
		case ID_VIEW_ZZOOMOUT:
			z.scale *= 4.0/5;
			if (z.scale < 0.125)
				z.scale = 0.125;
			Sys_UpdateWindows (W_Z|W_Z_OVERLAY);
			break;

		case ID_VIEW_CENTER:
			camera.angles[ROLL] = camera.angles[PITCH] = 0;
			camera.angles[YAW] = 22.5 * 
				floor( (camera.angles[YAW]+11)/22.5 );
			Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY);
			break;

		case ID_VIEW_UPFLOOR:
			Cam_ChangeFloor (true);
			break;
		case ID_VIEW_DOWNFLOOR:
			Cam_ChangeFloor (false);
			break;

		case ID_VIEW_SHOWNAMES:
			g_qeglobals.d_savedinfo.show_names = !g_qeglobals.d_savedinfo.show_names;
			CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWNAMES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_names ? MF_CHECKED : MF_UNCHECKED)  );
			Map_BuildBrushData();
			Sys_UpdateWindows (W_XY);
			break;

		case ID_VIEW_SHOWCOORDINATES:
			g_qeglobals.d_savedinfo.show_coordinates ^= 1;
			CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_coordinates ? MF_CHECKED : MF_UNCHECKED)  );
			Sys_UpdateWindows (W_XY);
			break;

		case ID_VIEW_SHOWBLOCKS:
			g_qeglobals.show_blocks ^= 1;
			CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWBLOCKS, MF_BYCOMMAND | (g_qeglobals.show_blocks ? MF_CHECKED : MF_UNCHECKED)  );
			Sys_UpdateWindows (W_XY);
			break;

		case ID_VIEW_SHOWLIGHTS:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTS ) & EXCLUDE_LIGHTS )
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED );
			else
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_CHECKED );				
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;

		case ID_VIEW_SHOWPATH:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_PATHS ) & EXCLUDE_PATHS )
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED );
			else
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_CHECKED );
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;

		case ID_VIEW_SHOWENT:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ENT ) & EXCLUDE_ENT )
				CheckMenuItem( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_UNCHECKED);
			else
				CheckMenuItem( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_CHECKED);
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;

		case ID_VIEW_SHOWWATER:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WATER ) & EXCLUDE_WATER )
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED );
			else
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_CHECKED );
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;

		case ID_VIEW_SHOWCLIP:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLIP ) & EXCLUDE_CLIP )
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED );
			else
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_CHECKED );
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;

		case ID_VIEW_SHOWDETAIL:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_DETAIL ) & EXCLUDE_DETAIL )
			{
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_UNCHECKED );
				SetWindowText (g_qeglobals.d_hwndCamera, "Camera View (DETAIL EXCLUDED)");
			}
			else
			{
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_CHECKED );
				SetWindowText (g_qeglobals.d_hwndCamera, "Camera View");
			}
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;

		case ID_VIEW_SHOWWORLD:
			if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WORLD ) & EXCLUDE_WORLD )
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED );
			else
				CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_CHECKED );
			Sys_UpdateWindows (W_XY|W_CAMERA);
			break;


//
// grid menu
//
		case ID_GRID_1:
		case ID_GRID_2:
		case ID_GRID_4:
		case ID_GRID_8:
		case ID_GRID_16:
		case ID_GRID_32:
		case ID_GRID_64:
		{
			hMenu = GetMenu(hWnd);
			
			CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED);
			CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED);
			CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED);
			CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED);
			CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED);
			CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED);
			CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED);

			switch (LOWORD(wParam))
			{
				case ID_GRID_1: g_qeglobals.d_gridsize = 0; break;
				case ID_GRID_2: g_qeglobals.d_gridsize = 1; break;
				case ID_GRID_4: g_qeglobals.d_gridsize = 2; break;
				case ID_GRID_8: g_qeglobals.d_gridsize = 3; break;
				case ID_GRID_16: g_qeglobals.d_gridsize = 4; break;
				case ID_GRID_32: g_qeglobals.d_gridsize = 5; break;
				case ID_GRID_64: g_qeglobals.d_gridsize = 6; break;
			}
			g_qeglobals.d_gridsize = 1 << g_qeglobals.d_gridsize;

			CheckMenuItem(hMenu, LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED);
			Sys_UpdateWindows (W_XY|W_Z);
			break;
		}

//
// texture menu
//
		case ID_VIEW_NEAREST:					
		case ID_VIEW_NEARESTMIPMAP:
		case ID_VIEW_LINEAR:
		case ID_VIEW_BILINEAR:
		case ID_VIEW_BILINEARMIPMAP:
		case ID_VIEW_TRILINEAR:
		case ID_TEXTURES_WIREFRAME:
		case ID_TEXTURES_FLATSHADE:
			Texture_SetMode (LOWORD(wParam));
			break;

		case ID_TEXTURES_SHOWINUSE:
			Sys_BeginWait ();
			Texture_ShowInuse ();
			SetInspectorMode(W_TEXTURE);
			break;

		case ID_TEXTURES_INSPECTOR:
			DoSurface ();
			break;

		case CMD_TEXTUREWAD:
		case CMD_TEXTUREWAD+1:
		case CMD_TEXTUREWAD+2:
		case CMD_TEXTUREWAD+3:
		case CMD_TEXTUREWAD+4:
		case CMD_TEXTUREWAD+5:
		case CMD_TEXTUREWAD+6:
		case CMD_TEXTUREWAD+7:
		case CMD_TEXTUREWAD+8:
		case CMD_TEXTUREWAD+9:
		case CMD_TEXTUREWAD+10:
		case CMD_TEXTUREWAD+11:
		case CMD_TEXTUREWAD+12:
		case CMD_TEXTUREWAD+13:
		case CMD_TEXTUREWAD+14:
		case CMD_TEXTUREWAD+15:
		case CMD_TEXTUREWAD+16:
		case CMD_TEXTUREWAD+17:
		case CMD_TEXTUREWAD+18:
		case CMD_TEXTUREWAD+19:
		case CMD_TEXTUREWAD+20:
		case CMD_TEXTUREWAD+21:
		case CMD_TEXTUREWAD+22:
		case CMD_TEXTUREWAD+23:
		case CMD_TEXTUREWAD+24:
		case CMD_TEXTUREWAD+25:
		case CMD_TEXTUREWAD+26:
		case CMD_TEXTUREWAD+27:
		case CMD_TEXTUREWAD+28:
		case CMD_TEXTUREWAD+29:
		case CMD_TEXTUREWAD+30:
		case CMD_TEXTUREWAD+31:
			Sys_BeginWait ();
			Texture_ShowDirectory (LOWORD(wParam));
			SetInspectorMode(W_TEXTURE);
			break;

//
// bsp menu
//
		case CMD_BSPCOMMAND:
		case CMD_BSPCOMMAND+1:
		case CMD_BSPCOMMAND+2:
		case CMD_BSPCOMMAND+3:
		case CMD_BSPCOMMAND+4:
		case CMD_BSPCOMMAND+5:
		case CMD_BSPCOMMAND+6:
		case CMD_BSPCOMMAND+7:
		case CMD_BSPCOMMAND+8:
		case CMD_BSPCOMMAND+9:
		case CMD_BSPCOMMAND+10:
		case CMD_BSPCOMMAND+11:
		case CMD_BSPCOMMAND+12:
		case CMD_BSPCOMMAND+13:
		case CMD_BSPCOMMAND+14:
		case CMD_BSPCOMMAND+15:
		case CMD_BSPCOMMAND+16:
		case CMD_BSPCOMMAND+17:
		case CMD_BSPCOMMAND+18:
		case CMD_BSPCOMMAND+19:
		case CMD_BSPCOMMAND+20:
		case CMD_BSPCOMMAND+21:
		case CMD_BSPCOMMAND+22:
		case CMD_BSPCOMMAND+23:
		case CMD_BSPCOMMAND+24:
		case CMD_BSPCOMMAND+25:
		case CMD_BSPCOMMAND+26:
		case CMD_BSPCOMMAND+27:
		case CMD_BSPCOMMAND+28:
		case CMD_BSPCOMMAND+29:
		case CMD_BSPCOMMAND+30:
		case CMD_BSPCOMMAND+31:
			{
				extern	char	*bsp_commands[256];

				RunBsp (bsp_commands[LOWORD(wParam-CMD_BSPCOMMAND)]);
			}
			break;

//
// misc menu
//
		case ID_MISC_BENCHMARK:
			SendMessage ( g_qeglobals.d_hwndCamera,
			WM_USER+267,	0, 0);
			break;

		case ID_TEXTUREBK:
			DoColor(COLOR_TEXTUREBACK);
			Sys_UpdateWindows (W_ALL);
			break;

		case ID_MISC_SELECTENTITYCOLOR:
			{
				extern int inspector_mode;
				
				if ( ( inspector_mode == W_ENTITY ) && DoColor(COLOR_ENTITY) == true )
				{
					extern void AddProp( void );
					
					char buffer[100];
					
					sprintf( buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0],
						g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1],
						g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] );
					
					SetWindowText( hwndEnt[EntValueField], buffer );
					SetWindowText( hwndEnt[EntKeyField], "_color" );
					AddProp();
				}
				Sys_UpdateWindows( W_ALL );
			}
			break;

		case ID_MISC_PRINTXY:
			WXY_Print();
			break;

		case ID_COLORS_XYBK:
			DoColor(COLOR_GRIDBACK);
			Sys_UpdateWindows (W_ALL);
			break;

		case ID_COLORS_MAJOR:
			DoColor(COLOR_GRIDMAJOR);
			Sys_UpdateWindows (W_ALL);
			break;

		case ID_COLORS_MINOR:
			DoColor(COLOR_GRIDMINOR);
			Sys_UpdateWindows (W_ALL);
			break;

		case ID_MISC_GAMMA:
			DoGamma();
			break;

		case ID_MISC_FINDBRUSH:
			DoFind();
			break;

		case ID_MISC_NEXTLEAKSPOT:
			Pointfile_Next();
			break;
		case ID_MISC_PREVIOUSLEAKSPOT:
			Pointfile_Prev();
			break;

//
// brush menu
//
		case ID_BRUSH_3SIDED:
			Brush_MakeSided (3);
			break;
		case ID_BRUSH_4SIDED:
			Brush_MakeSided (4);
			break;
		case ID_BRUSH_5SIDED:
			Brush_MakeSided (5);
			break;
		case ID_BRUSH_6SIDED:
			Brush_MakeSided (6);
			break;
		case ID_BRUSH_7SIDED:
			Brush_MakeSided (7);
			break;
		case ID_BRUSH_8SIDED:
			Brush_MakeSided (8);
			break;
		case ID_BRUSH_9SIDED:
			Brush_MakeSided (9);
			break;
		case ID_BRUSH_ARBITRARYSIDED:
			DoSides ();
			break;

//
// select menu
//
		case ID_BRUSH_FLIPX:
			Select_FlipAxis (0);
			break;
		case ID_BRUSH_FLIPY:
			Select_FlipAxis (1);
			break;
		case ID_BRUSH_FLIPZ:
			Select_FlipAxis (2);
			break;
		case ID_BRUSH_ROTATEX:
			Select_RotateAxis (0, 90);
			break;
		case ID_BRUSH_ROTATEY:
			Select_RotateAxis (1, 90);
			break;
		case ID_BRUSH_ROTATEZ:
			Select_RotateAxis (2, 90);
			break;

		case ID_SELECTION_ARBITRARYROTATION:
			DoRotate ();
			break;

		case ID_SELECTION_UNGROUPENTITY:
			Select_Ungroup ();
			break;

		case ID_SELECTION_CONNECT:
			ConnectEntities ();
			break;

		case ID_SELECTION_DRAGVERTECIES:
			if (g_qeglobals.d_select_mode == sel_vertex)
			{
				g_qeglobals.d_select_mode = sel_brush;
				Sys_UpdateWindows (W_ALL);
			}
			else
			{
				SetupVertexSelection ();
				if (g_qeglobals.d_numpoints)
					g_qeglobals.d_select_mode = sel_vertex;
			}
			break;
		case ID_SELECTION_DRAGEDGES:
			if (g_qeglobals.d_select_mode == sel_edge)
			{
				g_qeglobals.d_select_mode = sel_brush;
				Sys_UpdateWindows (W_ALL);
			}
			else
			{
				SetupVertexSelection ();
				if (g_qeglobals.d_numpoints)
					g_qeglobals.d_select_mode = sel_edge;
			}
			break;

		case ID_SELECTION_SELECTPARTIALTALL:
			Select_PartialTall ();
			break;
		case ID_SELECTION_SELECTCOMPLETETALL:
			Select_CompleteTall ();
			break;
		case ID_SELECTION_SELECTTOUCHING:
			Select_Touching ();
			break;
		case ID_SELECTION_SELECTINSIDE:
			Select_Inside ();
			break;
		case ID_SELECTION_CSGSUBTRACT:
			CSG_Subtract ();
			break;
		case ID_SELECTION_MAKEHOLLOW:
			CSG_MakeHollow ();
			break;

		case ID_SELECTION_CLONE:
			Select_Clone ();
			break;
		case ID_SELECTION_DELETE:
			Select_Delete ();
			break;
		case ID_SELECTION_DESELECT:
			Select_Deselect ();
			break;

		case ID_SELECTION_MAKE_DETAIL:
			Select_MakeDetail ();
			break;
		case ID_SELECTION_MAKE_STRUCTURAL:
			Select_MakeStructural ();
			break;


//
// region menu
//
		case ID_REGION_OFF:
			Map_RegionOff ();
			break;
		case ID_REGION_SETXY:
			Map_RegionXY ();
			break;
		case ID_REGION_SETTALLBRUSH:
			Map_RegionTallBrush ();
			break;
		case ID_REGION_SETBRUSH:
			Map_RegionBrush ();
			break;
		case ID_REGION_SETSELECTION:
			Map_RegionSelectedBrushes ();
			break;

		case IDMRU+1:
		case IDMRU+2:
		case IDMRU+3:
		case IDMRU+4:
		case IDMRU+5:
		case IDMRU+6:
		case IDMRU+7:
		case IDMRU+8:
		case IDMRU+9:
			DoMru(hWnd,LOWORD(wParam));
			break;

//
// help menu
//

		case ID_HELP_ABOUT:
			DoAbout();
			break;

		default:
            return FALSE;
    }

    return TRUE;
}
Esempio n. 13
0
/*
================
Map_LoadFile
================
*/
void Map_LoadFile (char *filename)
{
    char		*buf;
	entity_t	*ent;
	char         temp[1024];

	Sys_BeginWait ();
	Select_Deselect();
	//SetInspectorMode(W_CONSOLE);

	QE_ConvertDOSToUnixName( temp, filename );
	Sys_Printf ("Map_LoadFile: %s\n", temp );

	Map_Free ();
	//++timo FIXME: maybe even easier to have Group_Init called from Map_Free?
	Group_Init();

	g_qeglobals.d_parsed_brushes = 0;
	strcpy (currentmap, filename);

	if (LoadFile (filename, (void **)&buf) != -1)
	{

		StartTokenParsing (buf);
		g_qeglobals.d_num_entities = 0;

		// Timo
		// will be used in Entity_Parse to detect if a conversion between brush formats is needed
		g_qeglobals.bNeedConvert = false;
		g_qeglobals.bOldBrushes = false;
		g_qeglobals.bPrimitBrushes = false;

		while (1)
		{
			ent = Entity_Parse (false, &active_brushes);
			if (!ent)
				break;
			if (!strcmp(ValueForKey (ent, "classname"), "worldspawn"))
			{
				if (world_entity)
					Sys_Printf ("WARNING: multiple worldspawn\n");
				world_entity = ent;
			}
			else if (!strcmp(ValueForKey (ent, "classname"), "group_info"))
      {
        // it's a group thing!
        Group_Add(ent);
        Entity_Free(ent);
      }
      else
			{
				// add the entity to the end of the entity list
				ent->next = &entities;
				ent->prev = entities.prev;
				entities.prev->next = ent;
				entities.prev = ent;
				g_qeglobals.d_num_entities++;
			}
		}
	}

  free (buf);

	if (!world_entity)
	{
		Sys_Printf ("No worldspawn in map.\n");
		Map_New ();
		return;
	}

    Sys_Printf ("--- LoadMapFile ---\n");
    Sys_Printf ("%s\n", temp );

    Sys_Printf ("%5i brushes\n",  g_qeglobals.d_parsed_brushes );
    Sys_Printf ("%5i entities\n", g_qeglobals.d_num_entities);

	Map_RestoreBetween ();

	Sys_Printf ("Map_BuildAllDisplayLists\n");
    Map_BuildBrushData();

	// reset the "need conversion" flag
	// conversion to the good format done in Map_BuildBrushData
	g_qeglobals.bNeedConvert=false;

	//
	// move the view to a start position
	//
  ent = AngledEntity();

  g_pParentWnd->GetCamera()->Camera().angles[PITCH] = 0;
	if (ent)
	{
		GetVectorForKey (ent, "origin", g_pParentWnd->GetCamera()->Camera().origin);
		GetVectorForKey (ent, "origin", g_pParentWnd->GetXYWnd()->GetOrigin());
		g_pParentWnd->GetCamera()->Camera().angles[YAW] = FloatForKey (ent, "angle");
	}
	else
	{
		g_pParentWnd->GetCamera()->Camera().angles[YAW] = 0;
		VectorCopy (vec3_origin, g_pParentWnd->GetCamera()->Camera().origin);
		VectorCopy (vec3_origin, g_pParentWnd->GetXYWnd()->GetOrigin());
	}

	Map_RegionOff ();


	modified = false;
	Sys_SetTitle (temp);

	Texture_ShowInuse ();

	Sys_EndWait();
	Sys_UpdateWindows (W_ALL);

}