mirror of
https://github.com/jummy0/sb2-decomp
synced 2025-03-14 20:23:30 +01:00
CEvent::CopyMission & general cleanup
This commit is contained in:
parent
52f2b79b44
commit
3eee5ff3d7
@ -71,6 +71,18 @@
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>$(ProjectName)_</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>$(ProjectName)_</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetName>$(ProjectName)_</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>$(ProjectName)_</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
|
667
src/decblupi.cpp
667
src/decblupi.cpp
File diff suppressed because it is too large
Load Diff
117
src/decmove.cpp
117
src/decmove.cpp
@ -7,94 +7,7 @@
|
||||
#include "dectables.h"
|
||||
|
||||
|
||||
BOOL CDecor::TestPath(RECT rect, POINT start, POINT end)
|
||||
{
|
||||
int num = abs(end.x - start.x);
|
||||
int num2 = abs(end.y - start.y);
|
||||
|
||||
POINT tinyPoint = start;
|
||||
if (num > num2)
|
||||
{
|
||||
RECT rect2;
|
||||
if (end.x > start.x)
|
||||
{
|
||||
for (int i = 0; i <= num; i++)
|
||||
{
|
||||
int j = i * (end.y - start.y) / num;
|
||||
rect2.left = rect.left + i;
|
||||
rect2.right = rect.right + i;
|
||||
rect2.top = rect.top + j;
|
||||
rect2.bottom = rect.bottom + j;
|
||||
if (DecorDetect(rect2))
|
||||
{
|
||||
end = tinyPoint;
|
||||
return FALSE;
|
||||
}
|
||||
tinyPoint.x = start.x + i;
|
||||
tinyPoint.y = start.y + j;
|
||||
}
|
||||
}
|
||||
if (end.x < start.x)
|
||||
{
|
||||
for (int i = 0; i >= -num; i--)
|
||||
{
|
||||
int j = i * (start.y - end.y) / num;
|
||||
rect2.left = rect.left + i;
|
||||
rect2.right = rect.right + i;
|
||||
rect2.top = rect.top + j;
|
||||
rect2.bottom = rect.bottom + j;
|
||||
if (DecorDetect(rect2))
|
||||
{
|
||||
end = tinyPoint;
|
||||
return FALSE;
|
||||
}
|
||||
tinyPoint.x = start.x + i;
|
||||
tinyPoint.y = start.y + j;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RECT rect2;
|
||||
if (end.y > start.y)
|
||||
{
|
||||
for (int j = 0; j <= num2; j++)
|
||||
{
|
||||
int i = j * (end.x - start.x) / num2;
|
||||
rect2.left = rect.left + i;
|
||||
rect2.right = rect.right + i;
|
||||
rect2.top = rect.top + j;
|
||||
rect2.bottom = rect.bottom + j;
|
||||
if (DecorDetect(rect2))
|
||||
{
|
||||
end = tinyPoint;
|
||||
return FALSE;
|
||||
}
|
||||
tinyPoint.x = start.x + i;
|
||||
tinyPoint.y = start.y + j;
|
||||
}
|
||||
}
|
||||
if (end.y < start.y)
|
||||
{
|
||||
for (int j = 0; j >= -num2; j--)
|
||||
{
|
||||
int i = j * (start.x - end.x) / num2;
|
||||
rect2.left = rect.left + i;
|
||||
rect2.right = rect.right + i;
|
||||
rect2.top = rect.top + j;
|
||||
rect2.bottom = rect.bottom + j;
|
||||
if (DecorDetect(rect2))
|
||||
{
|
||||
end = tinyPoint;
|
||||
return FALSE;
|
||||
}
|
||||
tinyPoint.x = start.x + i;
|
||||
tinyPoint.y = start.y + j;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CDecor::MoveObjectPollution()
|
||||
@ -481,7 +394,7 @@ void CDecor::MoveObjectStepLine(int i)
|
||||
POINT tinyPoint;
|
||||
BOOL flag = FALSE;
|
||||
RECT tinyRect;
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == 47 || m_moveObject[i].type == 48 && !m_blupiSuspend)
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == TYPE_ASCENSEURs || m_moveObject[i].type == TYPE_ASCENSEURsi && !m_blupiSuspend)
|
||||
{
|
||||
RECT src;
|
||||
src.left = m_blupiPos.x + 20;
|
||||
@ -520,7 +433,7 @@ void CDecor::MoveObjectStepLine(int i)
|
||||
tinyRect.right = posCurrent.x + 60 - 10;
|
||||
tinyRect.top = posCurrent.y + 10;
|
||||
tinyRect.bottom = posCurrent.y + 60 - 10;
|
||||
if (TestPath(tinyRect, m_moveObject[i].posCurrent, posCurrent))
|
||||
if (TestPath(tinyRect, m_moveObject[i].posCurrent, &posCurrent))
|
||||
{
|
||||
m_moveObject[i].posCurrent = posCurrent;
|
||||
m_moveObject[i].posStart = posCurrent;
|
||||
@ -617,7 +530,7 @@ void CDecor::MoveObjectStepLine(int i)
|
||||
m_moveObject[i].type = 0;
|
||||
}
|
||||
posCurrent = m_moveObject[i].posCurrent;
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == 47 || m_moveObject[i].type == 48)
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == TYPE_ASCENSEURs || m_moveObject[i].type == TYPE_ASCENSEURsi)
|
||||
{
|
||||
posCurrent.y -= 64;
|
||||
}
|
||||
@ -628,11 +541,11 @@ void CDecor::MoveObjectStepLine(int i)
|
||||
{
|
||||
m_blupiVector.x = m_moveObject[i].posCurrent.x - tinyPoint.x;
|
||||
m_blupiVector.y = m_moveObject[i].posCurrent.y - (m_blupiPos.y + 60 - BLUPIFLOOR);
|
||||
if (m_moveObject[i].type == 47)
|
||||
if (m_moveObject[i].type == TYPE_ASCENSEURs)
|
||||
{
|
||||
m_blupiVector.x = m_blupiVector.x + 2;
|
||||
}
|
||||
if (m_moveObject[i].type == 48)
|
||||
if (m_moveObject[i].type == TYPE_ASCENSEURsi)
|
||||
{
|
||||
m_blupiVector.x = m_blupiVector.x - 2;
|
||||
}
|
||||
@ -646,11 +559,11 @@ void CDecor::MoveObjectStepLine(int i)
|
||||
void CDecor::MoveObjectStepIcon(int i)
|
||||
{
|
||||
POINT pos;
|
||||
if (m_moveObject[i].type == 47)
|
||||
if (m_moveObject[i].type == TYPE_ASCENSEURs)
|
||||
{
|
||||
m_moveObject[i].icon = table_chenille[m_moveObject[i].phase / 1 % 6];
|
||||
}
|
||||
if (m_moveObject[i].type == 48)
|
||||
if (m_moveObject[i].type == TYPE_ASCENSEURsi)
|
||||
{
|
||||
m_moveObject[i].icon = table_chenillei[m_moveObject[i].phase / 1 % 6];
|
||||
}
|
||||
@ -771,27 +684,27 @@ void CDecor::MoveObjectStepIcon(int i)
|
||||
m_moveObject[i].icon = 29 + m_moveObject[i].phase / 3 % 8;
|
||||
m_moveObject[i].channel = 10;
|
||||
}
|
||||
if (m_moveObject[i].type == 21)
|
||||
if (m_moveObject[i].type == TYPE_CLE)
|
||||
{
|
||||
m_moveObject[i].icon = table_cle[m_moveObject[i].phase / 3 % 12];
|
||||
m_moveObject[i].channel = 10;
|
||||
}
|
||||
if (m_moveObject[i].type == 49)
|
||||
if (m_moveObject[i].type == TYPE_CLE1)
|
||||
{
|
||||
m_moveObject[i].icon = table_cle1[m_moveObject[i].phase / 3 % 12];
|
||||
m_moveObject[i].channel = 10;
|
||||
}
|
||||
if (m_moveObject[i].type == 50)
|
||||
if (m_moveObject[i].type == TYPE_CLE2)
|
||||
{
|
||||
m_moveObject[i].icon = table_cle2[m_moveObject[i].phase / 3 % 12];
|
||||
m_moveObject[i].channel = 10;
|
||||
}
|
||||
if (m_moveObject[i].type == 51)
|
||||
if (m_moveObject[i].type == TYPE_CLE3)
|
||||
{
|
||||
m_moveObject[i].icon = table_cle3[m_moveObject[i].phase / 3 % 12];
|
||||
m_moveObject[i].channel = 10;
|
||||
}
|
||||
if (m_moveObject[i].type == 24)
|
||||
if (m_moveObject[i].type == TYPE_SKATE)
|
||||
{
|
||||
m_moveObject[i].icon = table_skate[m_moveObject[i].phase / 1 % 34];
|
||||
m_moveObject[i].channel = 10;
|
||||
@ -1542,7 +1455,7 @@ void CDecor::DynamiteStart(int i, int dx, int dy)
|
||||
{
|
||||
if (m_moveObject[i].type == 2 || m_moveObject[i].type == 3 || m_moveObject[i].type == 96 || m_moveObject[i].type == 97 || m_moveObject[i].type == 4 ||
|
||||
m_moveObject[i].type == 6 || m_moveObject[i].type == 12 || m_moveObject[i].type == 13 || m_moveObject[i].type == 16 || m_moveObject[i].type == 17 ||
|
||||
m_moveObject[i].type == 19 || m_moveObject[i].type == 20 || m_moveObject[i].type == 24 || m_moveObject[i].type == 25 || m_moveObject[i].type == 26 || m_moveObject[i].type == 28 ||
|
||||
m_moveObject[i].type == 19 || m_moveObject[i].type == 20 || m_moveObject[i].type == TYPE_SKATE || m_moveObject[i].type == 25 || m_moveObject[i].type == 26 || m_moveObject[i].type == 28 ||
|
||||
m_moveObject[i].type == 30 || m_moveObject[i].type == 32 || m_moveObject[i].type == 33 || m_moveObject[i].type == 34 || m_moveObject[i].type == 40 || m_moveObject[i].type == 44 ||
|
||||
m_moveObject[i].type == 46 || m_moveObject[i].type == 52 || m_moveObject[i].type == 54 || m_moveObject[i].type == 200 || m_moveObject[i].type == 201 || m_moveObject[i].type == 202 ||
|
||||
m_moveObject[i].type == 203)
|
||||
@ -1607,7 +1520,7 @@ int CDecor::AscenseurDetect(RECT rect, POINT oldpos, POINT newpos)
|
||||
num = abs(num);
|
||||
for (int i = 0; i < MAXMOVEOBJECT; i++)
|
||||
{
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == 47 || m_moveObject[i].type == 48)
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == TYPE_ASCENSEURs || m_moveObject[i].type == TYPE_ASCENSEURsi)
|
||||
{
|
||||
RECT src;
|
||||
src.left = m_moveObject[i].posCurrent.x;
|
||||
@ -2023,7 +1936,7 @@ int CDecor::MoveAscenseurDetect(POINT pos, int height)
|
||||
src.bottom = pos.y + 60 + height - 1;
|
||||
for (int i = 0; i < MAXMOVEOBJECT; i++)
|
||||
{
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == 47 || m_moveObject[i].type == 48)
|
||||
if (m_moveObject[i].type == 1 || m_moveObject[i].type == TYPE_ASCENSEURs || m_moveObject[i].type == TYPE_ASCENSEURsi)
|
||||
{
|
||||
RECT src2;
|
||||
src2.left = m_moveObject[i].posCurrent.x;
|
||||
|
@ -215,7 +215,7 @@ public:
|
||||
BOOL *pbNage);
|
||||
|
||||
// DecMove.cpp
|
||||
BOOL TestPath(RECT rect, POINT start, POINT end);
|
||||
BOOL TestPath(RECT rect, POINT start, POINT *end);
|
||||
void MoveObjectPollution();
|
||||
void MoveObjectPlouf(POINT pos);
|
||||
void MoveObjectTiplouf(POINT pos);
|
||||
|
@ -2838,9 +2838,10 @@ BOOL CEvent::TreatEventBase(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
ChangePhase(WM_PHASE_INFO);
|
||||
return TRUE;
|
||||
}
|
||||
if ((m_phase == WM_PHASE_INIT) || (m_phase == WM_PHASE_WINMULTI)) ChangePhase(WM_PHASE_GAMER); return TRUE;
|
||||
if ((m_phase == WM_PHASE_BUILD) || ((m_phase == WM_PHASE_LOSTDESIGN || m_phase == WM_PHASE_LOST))) ChangePhase(WM_PHASE_INFO); return TRUE;
|
||||
if (((m_phase != WM_PHASE_INFO) && (m_phase != WM_PHASE_STOP)) && (m_phase != WM_PHASE_HELP))
|
||||
|
||||
if (m_phase == WM_PHASE_INIT || m_phase == WM_PHASE_WINMULTI) ChangePhase(WM_PHASE_GAMER); return TRUE;
|
||||
if (m_phase == WM_PHASE_BUILD || m_phase == WM_PHASE_LOSTDESIGN || m_phase == WM_PHASE_LOST) ChangePhase(WM_PHASE_INFO); return TRUE;
|
||||
if (m_phase != WM_PHASE_INFO && m_phase != WM_PHASE_STOP && m_phase != WM_PHASE_HELP)
|
||||
{
|
||||
if (m_phase == WM_PHASE_SERVICE)
|
||||
{
|
||||
@ -2857,13 +2858,13 @@ BOOL CEvent::TreatEventBase(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
ChatSend();
|
||||
return TRUE;
|
||||
}
|
||||
if (((m_phase != WM_PHASE_GREAD) && (m_phase != WM_PHASE_GREADp)) || ((m_choiceIndex < 0 || LoadState(m_choiceIndex) == FALSE)))
|
||||
if ((m_phase != WM_PHASE_GREAD && m_phase != WM_PHASE_GREADp) || m_choiceIndex < 0 || !LoadState(m_choiceIndex))
|
||||
{
|
||||
if (m_phase != WM_PHASE_GWRITE) return TRUE;
|
||||
|
||||
if (m_choiceIndex < 0) return TRUE;
|
||||
|
||||
if (SaveState(m_choiceIndex) == FALSE) return TRUE;
|
||||
if (!SaveState(m_choiceIndex)) return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4864,4 +4865,44 @@ void CEvent::DrawMap()
|
||||
void CEvent::NetAdjustLobbyButtons()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
BOOL CEvent::CopyMission(char *srcFileName, char *dstFileName)
|
||||
{
|
||||
FILE *srcFile = NULL;
|
||||
FILE *destFile = NULL;
|
||||
size_t num;
|
||||
BOOL bOK = TRUE;
|
||||
void *buffer = malloc(2560);
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
srcFile = fopen(srcFileName, "rb");
|
||||
if (!srcFile) goto die;
|
||||
destFile = fopen(dstFileName, "wb");
|
||||
if (destFile)
|
||||
{
|
||||
do
|
||||
{
|
||||
num = fread(buffer, 1, 2560, srcFile);
|
||||
if (ferror(srcFile)) break; // *
|
||||
if (num <= 0)
|
||||
{
|
||||
bOK = FALSE;
|
||||
break;
|
||||
}
|
||||
fwrite(buffer, 1, num, destFile);
|
||||
} while (!ferror(destFile)); // *
|
||||
}
|
||||
}
|
||||
if (srcFile) fclose(srcFile);
|
||||
die:
|
||||
if (destFile) fclose(destFile);
|
||||
if (buffer) free(buffer);
|
||||
return bOK;
|
||||
|
||||
// *
|
||||
// original code relies on undefined behavior specific to older msvc :
|
||||
// if (srcFile->_flag & _IOERR)
|
||||
// while (!(destFile->_flag & _IOERR))
|
||||
}
|
@ -189,6 +189,7 @@ protected:
|
||||
void DrawMap();
|
||||
BOOL CheckCDForWorld1();
|
||||
void NetAdjustLobbyButtons();
|
||||
BOOL CopyMission(char *srcFileName, char *dstFileName);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -16,11 +16,11 @@ CNetwork::CNetwork()
|
||||
m_dpid = 0;
|
||||
m_bHost = FALSE;
|
||||
m_providers.nb = 0;
|
||||
*m_providers.list = NULL;
|
||||
m_providers.pList = NULL;
|
||||
m_sessions.nb = 0;
|
||||
*m_sessions.list = NULL;
|
||||
m_sessions.pList = NULL;
|
||||
m_unknown.nb = 0;
|
||||
*m_unknown.list = NULL;
|
||||
m_unknown.pList = NULL;
|
||||
}
|
||||
|
||||
CNetwork::~CNetwork()
|
||||
@ -36,8 +36,8 @@ static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSPName,
|
||||
{
|
||||
if (lpContext->nb < MAXSESSION)
|
||||
{
|
||||
lpContext->list[lpContext->nb]->guid = *lpguidSP;
|
||||
strcpy(lpContext->list[lpContext->nb]->name, lpSPName);
|
||||
lpContext->pList[lpContext->nb]->guid = *lpguidSP;
|
||||
strcpy(lpContext->pList[lpContext->nb]->name, lpSPName);
|
||||
lpContext->nb++;
|
||||
}
|
||||
return TRUE;
|
||||
@ -47,9 +47,9 @@ BOOL CNetwork::EnumProviders()
|
||||
{
|
||||
FreeProviderList();
|
||||
m_providers.nb = 0;
|
||||
*m_providers.list = (NamedGUID*)malloc(MAXSESSION * sizeof(NamedGUID));
|
||||
m_providers.pList = (NamedGUID(*)[MAXSESSION]) malloc(MAXSESSION * sizeof(NamedGUID));
|
||||
|
||||
if (!m_providers.list) return FALSE;
|
||||
if (!m_providers.pList) return FALSE;
|
||||
#ifdef _UNICODE
|
||||
if (DirectPlayEnumerate((LPDPENUMDPCALLBACK)EnumProvidersCallback, &m_providers) != DP_OK)
|
||||
#else
|
||||
@ -70,7 +70,7 @@ int CNetwork::GetNbProviders()
|
||||
char* CNetwork::GetProviderName(int index)
|
||||
{
|
||||
if (index >= m_providers.nb) return NULL;
|
||||
return m_providers.list[index]->name;
|
||||
return m_providers.pList[index]->name;
|
||||
}
|
||||
|
||||
BOOL CNetwork::CreateProvider(int index)
|
||||
@ -80,7 +80,7 @@ BOOL CNetwork::CreateProvider(int index)
|
||||
|
||||
if (index >= m_providers.nb) return FALSE;
|
||||
|
||||
if (DirectPlayCreate(&m_providers.list[index]->guid, &lpDP, 0) == DP_OK)
|
||||
if (DirectPlayCreate(&m_providers.pList[index]->guid, &lpDP, 0) == DP_OK)
|
||||
{
|
||||
if (lpDP->QueryInterface(IID_IDirectPlay2A, (LPVOID*)&m_pDP) == DP_OK)
|
||||
{
|
||||
@ -88,16 +88,16 @@ BOOL CNetwork::CreateProvider(int index)
|
||||
}
|
||||
}
|
||||
|
||||
if (lpDP != NULL) lpDP->Release();
|
||||
if (lpDP) lpDP->Release();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CNetwork::FreeProviderList()
|
||||
{
|
||||
if (m_providers.list) free(m_providers.list); // wrong
|
||||
if (m_providers.pList) free(m_providers.pList); // wrong
|
||||
|
||||
m_providers.nb = 0;
|
||||
*m_providers.list = NULL;
|
||||
m_providers.pList = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -108,8 +108,8 @@ static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
|
||||
|
||||
if (lpContext->nb < MAXSESSION)
|
||||
{
|
||||
lpContext->list[lpContext->nb]->guid = lpThisSD->guidInstance;
|
||||
strcpy(lpContext->list[lpContext->nb]->name, lpThisSD->lpszSessionNameA);
|
||||
lpContext->pList[lpContext->nb]->guid = lpThisSD->guidInstance;
|
||||
strcpy(lpContext->pList[lpContext->nb]->name, lpThisSD->lpszSessionNameA);
|
||||
lpContext->nb++;
|
||||
}
|
||||
return TRUE;
|
||||
@ -121,9 +121,9 @@ BOOL CNetwork::EnumSessions()
|
||||
|
||||
FreeSessionList();
|
||||
m_sessions.nb = 0;
|
||||
*m_sessions.list = (NamedGUID*)malloc(MAXSESSION * sizeof(NamedGUID));
|
||||
m_sessions.pList = (NamedGUID(*)[MAXSESSION]) malloc(MAXSESSION * sizeof(NamedGUID));
|
||||
|
||||
if (!m_sessions.list) return FALSE;
|
||||
if (!m_sessions.pList) return FALSE;
|
||||
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
|
||||
@ -142,10 +142,10 @@ BOOL CNetwork::EnumSessions()
|
||||
char* CNetwork::GetSessionName(int index)
|
||||
{
|
||||
if (index >= m_sessions.nb) return NULL;
|
||||
return m_sessions.list[index]->name;
|
||||
return m_sessions.pList[index]->name;
|
||||
}
|
||||
|
||||
BOOL CNetwork::JoinSession(int index)
|
||||
BOOL CNetwork::JoinSession(int index, char* pPlayerName)
|
||||
{
|
||||
DPNAME name;
|
||||
DPSESSIONDESC2 desc;
|
||||
@ -155,7 +155,7 @@ BOOL CNetwork::JoinSession(int index)
|
||||
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
|
||||
desc.guidInstance = m_sessions.list[index]->guid;
|
||||
desc.guidInstance = m_sessions.pList[index]->guid;
|
||||
|
||||
hr = m_pDP->Open(&desc, DPOPEN_OPENSESSION);
|
||||
if (hr != DP_OK)
|
||||
@ -164,10 +164,10 @@ BOOL CNetwork::JoinSession(int index)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
name.dwSize = 16;
|
||||
name.dwFlags = 0;
|
||||
name.dwSize = sizeof(name);
|
||||
name.lpszShortNameA = pPlayerName;
|
||||
name.lpszLongNameA = NULL;
|
||||
|
||||
hr = m_pDP->CreatePlayer(&m_dpid, &name, NULL, NULL, 0, 0);
|
||||
if (hr != DP_OK)
|
||||
{
|
||||
@ -184,21 +184,22 @@ BOOL CNetwork::JoinSession(int index)
|
||||
|
||||
void CNetwork::FreeSessionList()
|
||||
{
|
||||
if (m_sessions.list) free(m_sessions.list);
|
||||
if (m_sessions.pList) free(m_sessions.pList);
|
||||
|
||||
m_sessions.nb = 0;
|
||||
*m_sessions.list = NULL;
|
||||
m_sessions.pList = NULL;
|
||||
}
|
||||
|
||||
BOOL CNetwork::CreateSession(char* pName)
|
||||
BOOL CNetwork::CreateSession(char* pSessionName, char* pPlayerName)
|
||||
{
|
||||
DPNAME name;
|
||||
DPSESSIONDESC2 desc;
|
||||
HRESULT hr;
|
||||
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
|
||||
desc.guidApplication = APP_GUID;
|
||||
desc.lpszSessionNameA = pName;
|
||||
desc.lpszSessionNameA = pSessionName;
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwFlags = DPSESSION_KEEPALIVE | DPSESSION_MIGRATEHOST;
|
||||
desc.dwMaxPlayers = MAXPLAYERS;
|
||||
@ -207,13 +208,26 @@ BOOL CNetwork::CreateSession(char* pName)
|
||||
if (hr != DP_OK)
|
||||
{
|
||||
TraceErrorDP(hr);
|
||||
m_pDP->Close();
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bHost = TRUE;
|
||||
return TRUE;
|
||||
name.dwSize = 16;
|
||||
name.dwFlags = 0;
|
||||
name.lpszShortNameA = pPlayerName;
|
||||
name.lpszLongNameA = NULL;
|
||||
hr = m_pDP->CreatePlayer(&m_dpid, &name, NULL, NULL, 0, 0);
|
||||
if (hr != DP_OK)
|
||||
{
|
||||
TraceErrorDP(hr);
|
||||
m_pDP->Close();
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bHost = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,10 +280,10 @@ BOOL CNetwork::Close()
|
||||
|
||||
void CNetwork::FreeUnknownList()
|
||||
{
|
||||
if (m_unknown.list) free(m_unknown.list);
|
||||
if (m_unknown.pList) free(m_unknown.pList);
|
||||
|
||||
m_unknown.nb = 0;
|
||||
*m_unknown.list = NULL;
|
||||
m_unknown.pList = NULL;
|
||||
}
|
||||
|
||||
BOOL CNetwork::IsHost()
|
||||
|
@ -31,7 +31,7 @@ NamedGUID;
|
||||
typedef struct
|
||||
{
|
||||
int nb;
|
||||
NamedGUID* list[MAXSESSION];
|
||||
NamedGUID (*pList)[MAXSESSION];
|
||||
}
|
||||
NamedGUIDList;
|
||||
|
||||
@ -48,9 +48,9 @@ public:
|
||||
void FreeProviderList();
|
||||
BOOL EnumSessions();
|
||||
char* GetSessionName(int index);
|
||||
BOOL JoinSession(int index);
|
||||
BOOL JoinSession(int index, char* pPlayerName);
|
||||
void FreeSessionList();
|
||||
BOOL CreateSession(char* pName);
|
||||
BOOL CreateSession(char* pSessionName, char* pPlayerName);
|
||||
BOOL Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
|
||||
BOOL Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer);
|
||||
BOOL Close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user