forked from perilouswithadollarsign/cstrike15_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.cpp
122 lines (94 loc) · 2.39 KB
/
misc.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Miscellaneous utility functions.
//
// $NoKeywords: $
//=============================================================================//
#include "stdafx.h"
#include <direct.h>
#include <time.h>
#include "MapSolid.h"
#include "mapworld.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
static DWORD holdrand;
void randomize()
{
holdrand = DWORD(time(NULL));
}
DWORD random()
{
return(holdrand = holdrand * 214013L + 2531011L);
}
// MapCheckDlg.cpp:
BOOL DoesContainDuplicates(CMapSolid *pSolid);
static BOOL bCheckDupes = FALSE;
void NotifyDuplicates(CMapSolid *pSolid)
{
if(!bCheckDupes)
return; // stop that
if(DoesContainDuplicates(pSolid))
{
if(IDNO == AfxMessageBox("Duplicate Plane! Do you want more messages?",
MB_YESNO))
{
bCheckDupes = FALSE;
}
}
}
void NotifyDuplicates(const CMapObjectList *pList)
{
if(!bCheckDupes)
return; // stop that
FOR_EACH_OBJ( *pList, pos )
{
CMapClass *pobj = (CUtlReference< CMapClass >)pList->Element(pos);
if(!pobj->IsMapClass(MAPCLASS_TYPE(CMapSolid)))
continue; // not a solid
NotifyDuplicates((CMapSolid*) pobj);
}
}
int mychdir(LPCTSTR pszDir)
{
int curdrive = _getdrive();
// changes to drive/directory
if(pszDir[1] == ':' && _chdrive(toupper(pszDir[0]) - 'A' + 1) == -1)
return -1;
if(_chdir(pszDir) == -1)
{
// change back to original disk
_chdrive(curdrive);
return -1;
}
return 0;
}
void WriteDebug(char *pszStr)
{
#if 0
static BOOL bFirst = TRUE;
if(bFirst)
remove("wcdebug.txt");
bFirst = FALSE;
FILE *fp = fopen("wcdebug.txt", "ab");
fprintf(fp, "%s\r\n", pszStr);
fclose(fp);
#endif
}
//-----------------------------------------------------------------------------
// Purpose: Adds the given object to the list if it is a leaf object (no children).
// Input : pObject - Object to add to the list.
// pList - List to put the children in.
// Output : Returns TRUE to continue enumerating when called from EnumChildren.
//-----------------------------------------------------------------------------
BOOL AddLeavesToListCallback(CMapClass *pObject, CMapObjectList *pList)
{
if (pObject->GetChildCount() == 0)
{
pList->AddToTail(pObject);
}
return(TRUE);
}
bool IsWorldObject(CMapAtom *pObject)
{
return (dynamic_cast<CMapWorld*>(pObject) != NULL);
}