From e07da2253a82d091f7bdad907890377f25a23556 Mon Sep 17 00:00:00 2001 From: jummy Date: Sat, 9 Nov 2024 16:55:41 -0600 Subject: [PATCH] mostly netcode stuff i think i forgor --- src/blupi.cpp | 115 +++++++++-------- src/decblupi.cpp | 24 +++- src/decmove.cpp | 57 ++++----- src/decnet.cpp | 316 ++++++++++++++++++++++++++++++++++++++++++----- src/decor.h | 7 +- src/def.h | 1 - src/event.cpp | 24 +++- src/event.h | 8 +- src/sound.cpp | 2 +- 9 files changed, 418 insertions(+), 136 deletions(-) diff --git a/src/blupi.cpp b/src/blupi.cpp index 62f0fae..e9a507d 100644 --- a/src/blupi.cpp +++ b/src/blupi.cpp @@ -232,17 +232,27 @@ BOOL ReadConfig(LPSTR lpCmdLine) return TRUE; } +// Mise à jour principale. + void UpdateFrame(void) { - int phase, term; + int phase, term, speed; g_pEvent->ReadInput(); phase = g_pEvent->GetPhase(); + + if (phase == WM_PHASE_INTRO1 || + phase == WM_PHASE_INTRO2) + { + g_pEvent->IntroStep(); + } + if (phase == WM_PHASE_PLAY || phase == WM_PHASE_PLAYTEST || phase == WM_PHASE_BUILD) { if (!g_pDecor->GetPause()) { - for (int i = 0; i < g_pEvent->GetSpeed() * g_speedRate; i++) + speed = g_pEvent->GetSpeed() * g_speedRate; + for (int i = 0; i < speed; i++) { g_pDecor->MoveStep(); g_pEvent->DemoStep(); @@ -255,7 +265,10 @@ void UpdateFrame(void) g_pEvent->DemoStep(); // d?marre ?v. d?mo automatique } - if (phase == WM_PHASE_PLAYMOVIE || phase == WM_PHASE_WINMOVIE || WM_PHASE_WINMOVIEDESIGN || WM_PHASE_WINMOVIEMULTI) + if (phase == WM_PHASE_PLAYMOVIE || + phase == WM_PHASE_WINMOVIE || + phase == WM_PHASE_WINMOVIEDESIGN || + phase == WM_PHASE_WINMOVIEMULTI) { g_pEvent->MovieToStart(); } @@ -267,61 +280,62 @@ void UpdateFrame(void) if (phase == WM_PHASE_PLAY) { - if (g_pEvent->IsPrivate() == FALSE) + term = g_pDecor->IsTerminated(); + + if (g_pEvent->IsPrivate()) { - if (g_pEvent->IsMulti() == FALSE) - { - if (g_pDecor->IsTerminated() == -1) - { - g_pEvent->GetWorldGroup(); - g_pEvent->SetLives(g_pDecor->GetNbVies()); - g_pEvent->ChangePhase(WM_PHASE_LOST); - } - if (g_pDecor->IsTerminated() == -2) - { - g_pEvent->SetLives(g_pDecor->GetNbVies()); - g_pEvent->ChangePhase(WM_PHASE_WINMOVIE); - } - if (0 < g_pDecor->IsTerminated()) - { - g_pEvent->SetLives(g_pDecor->GetNbVies()); - g_pEvent->SetMission(g_pDecor->IsTerminated()); - g_pEvent->ChangePhase(WM_PHASE_PLAY); - } - } - else - { - if (g_pDecor->IsTerminated() == -1) - { - g_pEvent->ChangePhase(WM_PHASE_WINMULTI); - return; - } - if (g_pDecor->IsTerminated() != 0) - { - g_pEvent->ChangePhase(WM_PHASE_WINMOVIEMULTI); - return; - } - } - } - else - { - if (g_pDecor->IsTerminated() == -1) + if (term == -1) { g_pEvent->ChangePhase(WM_PHASE_LOSTDESIGN); return; } - if (g_pDecor->IsTerminated() != 0) + if (term != 0) { g_pEvent->ChangePhase(WM_PHASE_WINMOVIEDESIGN); return; } } + else + { + if (g_pEvent->IsMulti()) + { + if (term == -1) + { + g_pEvent->ChangePhase(WM_PHASE_WINMULTI); + return; + } + if (term != 0) + { + g_pEvent->ChangePhase(WM_PHASE_WINMOVIEMULTI); + return; + } + } + else + { + if (term == -1) + { + g_pEvent->GetWorldGroup(); + g_pEvent->SetNbVies(g_pDecor->GetNbVies()); + g_pEvent->ChangePhase(WM_PHASE_LOST); + } + if (term == -2) + { + g_pEvent->SetNbVies(g_pDecor->GetNbVies()); + g_pEvent->ChangePhase(WM_PHASE_WINMOVIE); + } + if (term > 0) + { + g_pEvent->SetNbVies(g_pDecor->GetNbVies()); + g_pEvent->SetMission(term); + g_pEvent->ChangePhase(WM_PHASE_PLAY); + } + } + } } } -// Incomplete -void SetDecor(void) +void SetDecor() { RECT rect; UINT phase; @@ -429,7 +443,6 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, // La touche F10 envoie un autre message pour activer // le menu dans les applications Windows standard ! - //[The F10 key sends another message to activate the menu in standard Windows apps!] if (message == WM_SYSKEYDOWN && wParam == VK_F10) { message = WM_KEYDOWN; @@ -458,14 +471,10 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, } if (g_timer > 0) g_timer--; break; - case WM_SYSCOLORCHANGE: - OutputDebug("Event WM_SYSCOLORCHANGE\n"); - break; case WM_CREATE: hInstance = ((LPCREATESTRUCT)lParam)->hInstance; return 0; break; - case WM_ACTIVATEAPP: g_bActive = (wParam != 0); if (g_pEvent != NULL) @@ -501,8 +510,8 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, } return 0; - case WM_DISPLAYCHANGE: - OutputDebug("Event WM_DISPLAYCHANGE\n"); + case WM_SYSCOLORCHANGE: + OutputDebug("Event WM_SYSCOLORCHANGE\n"); break; case WM_QUERYNEWPALETTE: @@ -513,6 +522,10 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, OutputDebug("Event WM_PALLETECHANGED\n"); break; + case WM_DISPLAYCHANGE: + OutputDebug("Event WM_DISPLAYCHANGE\n"); + break; + case MM_MCINOTIFY: OutputDebug("Event MM_MCINOTIFY\n"); if (g_pEvent->IsMovie()) // film en cours ? diff --git a/src/decblupi.cpp b/src/decblupi.cpp index 794e51e..000a2f5 100644 --- a/src/decblupi.cpp +++ b/src/decblupi.cpp @@ -3714,7 +3714,17 @@ void CDecor::BlupiStep() m_blupiPhase = 0; PlaySound(27, m_blupiPos); } - if ((m_blupiAction == 11 && m_blupiPhase == 70) || (m_blupiAction == 75 && m_blupiPhase == 100) || (m_blupiAction == 76 && m_blupiPhase == 70) || (m_blupiAction == 77 && m_blupiPhase == 110) || (m_blupiAction == 78 && m_blupiPhase == 90) || (m_blupiAction == 79 && m_blupiPhase == 90) || (m_blupiAction == 80 && m_blupiPhase == 90) || (m_blupiAction == 81 && m_blupiPhase == 90) || (m_blupiAction == 24 && m_blupiPhase == 90) || (m_blupiAction == 54 && m_blupiPhase == 100) || (m_blupiAction == 57 && m_blupiPhase == 90)) + if ((m_blupiAction == 11 && m_blupiPhase == 70) || + (m_blupiAction == 75 && m_blupiPhase == 100) || + (m_blupiAction == 76 && m_blupiPhase == 70) || + (m_blupiAction == 77 && m_blupiPhase == 110) || + (m_blupiAction == 78 && m_blupiPhase == 90) || + (m_blupiAction == 79 && m_blupiPhase == 90) || + (m_blupiAction == 80 && m_blupiPhase == 90) || + (m_blupiAction == 81 && m_blupiPhase == 90) || + (m_blupiAction == 24 && m_blupiPhase == 90) || + (m_blupiAction == 54 && m_blupiPhase == 100) || + (m_blupiAction == 57 && m_blupiPhase == 90)) { if (m_nbVies > 0) { @@ -3729,33 +3739,35 @@ void CDecor::BlupiStep() tinyPoint.x = m_blupiPos.x - posDecor.x - 30; tinyPoint.y = m_blupiPos.y - posDecor.y; VoyageInit(VoyageGetPosVie(m_nbVies), tinyPoint, 48, 2); + NetSendBarePacket(PK_DIE, m_nbVies); } else { m_nbVies = -1; m_term = -1; DoorsLost(); + NetSendBarePacket(PK_LOST, 0); } m_blupiFront = FALSE; } if (m_dimDecor.y == 0) { - num3 = 480; + num3 = LYIMAGE; } else { - num3 = 6400; + num3 = DIMOBJY * MAXCELY; } if (m_blupiPos.y >= num3 + 1 && m_blupiPos.y <= num3 + 40) { - PlaySound(8, m_blupiPos); + PlaySound(SOUND_FALL, m_blupiPos); } if (m_blupiPos.y > num3 + 1000) { m_term = -1; DoorsLost(); } - if (m_blupiAction == 13 && m_blupiPhase == 40) + if (m_blupiAction == ACTION_WIN && m_blupiPhase == 70) { if (m_bPrivate) { @@ -3780,7 +3792,7 @@ void CDecor::BlupiStep() m_term = m_mission / 10 * 10; } } - if (m_blupiAction == ACTION_BYE && m_blupiPhase == 30) + if (m_blupiAction == ACTION_BYE && m_blupiPhase == 50) { ; num = IsWorld(m_blupiPos); diff --git a/src/decmove.cpp b/src/decmove.cpp index e14a9ad..96fa7e0 100644 --- a/src/decmove.cpp +++ b/src/decmove.cpp @@ -339,49 +339,36 @@ BOOL CDecor::ObjectStart(POINT pos, int type, int speed, BOOL bMulti) if (bMulti) { NetMessage msg; - msg.data1 = speed; msg.type = MESS_OBJECTSTART; - msg.x = pos.x; - msg.y = pos.y; - msg.channel = type; + msg.data1 = speed; + msg.data2 = pos.x; + msg.data3 = pos.y; + msg.data4 = type; NetMessagePush(&msg); } return TRUE; } -BOOL CDecor::ObjectDelete(POINT pos, int type) +BOOL CDecor::ObjectDelete(POINT pos, int type, BOOL bMulti) { + NetMessage msg; + int num = MoveObjectSearch(pos, type); if (num == -1) { return FALSE; } - if (m_moveObject[num].type == 4 || - m_moveObject[num].type == 12 || - m_moveObject[num].type == 16 || - m_moveObject[num].type == 17 || - m_moveObject[num].type == 20 || - m_moveObject[num].type == 40 || - m_moveObject[num].type == 96 || - m_moveObject[num].type == 97) - { - int num2 = 17; - double animationSpeed = 1.0; - if (m_moveObject[num].type == 4) - { - num2 = 7; - } - if (m_moveObject[num].type == 17 || m_moveObject[num].type == 20) - { - num2 = 33; - } - if (m_moveObject[num].type == 40) - { - animationSpeed = 0.5; - } - - } m_moveObject[num].type = 0; + if (bMulti) + { + msg.type = MESS_OBJECTDELETE; + msg.data1 = 0; + msg.data2 = pos.x; + msg.data3 = pos.y; + msg.data4 = type; + + NetMessagePush(&msg); + } return TRUE; } @@ -1590,7 +1577,7 @@ int CDecor::AscenseurDetect(RECT rect, POINT oldpos, POINT newpos) src.right = m_moveObject[i].posCurrent.x + DIMOBJX; src.top = m_moveObject[i].posCurrent.y; src.bottom = m_moveObject[i].posCurrent.y + 16; - if (dy < LIFT_RANGE_Y) + if (dy < (DIMBLUPIY / 2)) { RECT dest = { 0, 0, 0, 0 }; if (IntersectRect(&dest, &src, &rect)) @@ -1601,16 +1588,16 @@ int CDecor::AscenseurDetect(RECT rect, POINT oldpos, POINT newpos) else { RECT src2 = rect; - src2.top -= dy / LIFT_RANGE_Y * LIFT_RANGE_Y * dirY; - src2.bottom -= dy / LIFT_RANGE_Y * LIFT_RANGE_Y * dirY; - for (int j = 0; j <= dy / LIFT_RANGE_Y; j++) + src2.top -= dy / (DIMBLUPIY / 2) * (DIMBLUPIY / 2) * dirY; + src2.bottom -= dy / (DIMBLUPIY / 2) * (DIMBLUPIY / 2) * dirY; + for (int j = 0; j <= dy / (DIMBLUPIY / 2); j++) { RECT dest = { 0, 0, 0, 0 }; if (IntersectRect(&dest, &src, &src2)) { return i; } - src2.top += dirY * LIFT_RANGE_Y; + src2.top += dirY * (DIMBLUPIY / 2); src2.bottom += dy; } } diff --git a/src/decnet.cpp b/src/decnet.cpp index 75561dc..6dfb509 100644 --- a/src/decnet.cpp +++ b/src/decnet.cpp @@ -10,11 +10,11 @@ void CDecor::NetStopCloud(int rank) { NetMessage msg; - msg.data1 = 0; - msg.x = 0; - msg.y = 0; msg.type = MESS_STOPCLOUD; - msg.channel = rank; + msg.data1 = 0; + msg.data2 = 0; + msg.data3 = 0; + msg.data4 = rank; NetMessagePush(&msg); return; } @@ -23,11 +23,11 @@ void CDecor::NetPlaySound(short channel, POINT pos) { NetMessage msg; - msg.y = pos.y; - msg.x = pos.x; msg.type = MESS_PLAYSOUND; msg.data1 = 0; - msg.channel = channel; + msg.data2 = pos.x; + msg.data3 = pos.y; + msg.data4 = channel; NetMessagePush(&msg); return; } @@ -36,11 +36,11 @@ void CDecor::NetStopSound(short channel) { NetMessage msg; - msg.data1 = 0; - msg.x = 0; - msg.y = 0; msg.type = MESS_STOPSOUND; - msg.channel = channel; + msg.data1 = 0; + msg.data2 = 0; + msg.data3 = 0; + msg.data4 = channel; NetMessagePush(&msg); } @@ -48,19 +48,19 @@ void CDecor::NetDataFlush() { for (int i = 0; i < MAXNETPLAYER; i++) { - m_netPos[i].x = 0; - m_netPos[i].y = 0; - m_netIcons[i] = -1; - m_netUnk1[i] = 0; - m_netUnk2[i] = 0; + m_netBlupiPos[i].x = 0; + m_netBlupiPos[i].y = 0; + m_netBlupiIcon[i] = -1; + m_netBlupiSec[i] = 0; + m_netBlupiTransport[i] = 0; m_netTransports[i] = 0; - m_netPlayerPacketsReceived[i] = 0; - m_netPlayerPacketsReceived2[i] = 0; + m_netTimes[i] = 0; + m_netPrevTimes[i] = 0; m_netTimeSincePacket[i] = 0; m_netVitesses[i].x = 0; m_netVitesses[i].y = 0; - m_netUnk4[i].x = 0; - m_netUnk4[i].y = 0; + m_netBlupiPrevPos[i].x = 0; + m_netBlupiPrevPos[i].y = 0; } m_netPacketsSent = 0; m_netPacketsSent2 = 0; @@ -70,57 +70,305 @@ void CDecor::NetDataFlush() NetMessageIndexFlush(); } -void CDecor::NetFUN_155e0(BYTE _foo, short _bar) +void CDecor::NetSendBarePacket(BYTE type, short num) { char data[4]; data[0] = 4; - data[1] = _foo; - data[2] = _bar & 0xff; - data[3] = _bar >> 8; + data[1] = type; + data[2] = num & 0xff; + data[3] = num >> 8; m_pNetwork->Send(&data, 4, DPSEND_GUARANTEED); return; } void CDecor::TreatNetData() { + NetPacket pack; + NetMessage* pMsg; + int i, j, dt; + int flag = 0; + int player; + int foo; + char res[100]; + char text[100]; + BOOL recentSenders[MAXNETPLAYER]; + + if ((m_netMessageIndex1 != 0 || + m_blupiIcon != m_netPacketIcon || + m_blupiPos != m_netPacketPos) && + !m_bNetPacked || m_time % 2 == 0) + { + m_netPacketPos = m_blupiPos; + m_netPacketIcon = m_blupiIcon; + pack.time = m_time; + pack.keyPress = m_keyPress; + pack.blupiPosX = m_blupiPos.x; + pack.blupiPosY = m_blupiPos.y; + pack.blupiIcon = m_blupiIcon; + pack.size = sizeof(pack); + pack.type = 1; + pack.blupiSec = m_blupiSec; + pack.blupiChannel = m_blupiChannel; + pack.blupiTransport = m_blupiTransport; + pack.nbMessages = 0; + for (i = 0; i < MAXMESSAGEPERPACKET; i++) + { + if (!NetMessagePop(&pack.messages[i])) + { + break; + } + pack.nbMessages++; + if (pack.messages[i].type == MESS_OBJECTSTART || + pack.messages[i].type == MESS_OBJECTDELETE) + { + if (pack.messages[i].data4 != TYPE_EXPLO1 && + pack.messages[i].data4 != TYPE_EXPLO2 && + pack.messages[i].data4 != TYPE_EXPLO3 && + pack.messages[i].data4 != TYPE_EXPLO4 && + pack.messages[i].data4 != TYPE_EXPLO5 && + pack.messages[i].data4 != TYPE_EXPLO6 && + pack.messages[i].data4 != TYPE_EXPLO7 && + pack.messages[i].data4 != TYPE_EXPLO8 && + pack.messages[i].data4 != TYPE_EXPLO9 && + pack.messages[i].data4 != TYPE_EXPLO10 && + pack.messages[i].data4 != TYPE_SPLOUTCH1 && + pack.messages[i].data4 != TYPE_SPLOUTCH2 && + pack.messages[i].data4 != TYPE_SPLOUTCH3 && + pack.messages[i].data4 != TYPE_TENTACULE && + pack.messages[i].data4 != TYPE_PLOUF && + pack.messages[i].data4 != TYPE_BLUP && + pack.messages[i].data4 != TYPE_MAGICTRACK && + pack.messages[i].data4 != TYPE_SHIELDTRACK && + pack.messages[i].data4 != TYPE_TRESORTRACK && + pack.messages[i].data4 != TYPE_TIPLOUF && + pack.messages[i].data4 != TYPE_INVERTSTART && + pack.messages[i].data4 != TYPE_INVERTSTOP && + pack.messages[i].data4 != TYPE_POLLUTION) + { + flag = 1; + } + } + } + pack.unk12 = flag; + m_pNetwork->Send(&pack, sizeof(NetMessage) * pack.nbMessages + 20, flag); + m_netPacketsSent++; + if (flag) m_netPacketsSent2++; + } + + ZeroMemory(&recentSenders, sizeof(recentSenders)); + + for (i = 0; i < 10; i++) + { + if (!m_pNetwork->Receive(&pack, sizeof(pack), (LPDWORD)&player)) + { + break; + } + + if (pack.type == 1) + { + m_netPacketsReceived++; + if (pack.unk12) m_netPacketsReceived2++; + + if (player < MAXNETPLAYER) + { + if (pack.time > m_netTimes[player]) + { + m_netPrevTimes[player] = m_netTimes[player]; + recentSenders[player] = TRUE; + m_netTimes[player] = pack.time; + m_netBlupiPos[player].x = pack.blupiPosX; + m_netBlupiPos[player].y = pack.blupiPosY; + m_netBlupiIcon[player] = pack.blupiIcon; + m_netBlupiSec[player] = pack.blupiSec; + m_netBlupiTransport[player] = pack.blupiTransport; + dt = pack.time - m_netPrevTimes[player]; + if (dt <= 0) + { + m_netVitesses[player] = POINT(0, 0); + } + else + { + m_netVitesses[player] = (m_netBlupiPos[player] - m_netBlupiPrevPos[player]) / dt; + } + m_netBlupiPrevPos[player] = m_netBlupiPos[player]; + m_netTimeSincePacket[player] = 0; + } + } + for (j = 0; j < pack.nbMessages; j++) + { + pMsg = &pack.messages[j]; + switch (pMsg->type) + { + case MESS_OBJECTSTART: + ObjectStart(POINT(pMsg->data2, pMsg->data3), pMsg->data4, pMsg->data1, FALSE); + break; + case MESS_OBJECTDELETE: + ObjectDelete(POINT(pMsg->data2, pMsg->data3), pMsg->data4, FALSE); + break; + case MESS_MODIFDECOR: + ModifDecor(POINT(pMsg->data2, pMsg->data3), pMsg->data4, FALSE); + break; + case MESS_PLAYSOUND: + m_pSound->PlayImage(pMsg->data4, POINT(pMsg->data2, pMsg->data3) - m_posDecor, -1); + break; + case MESS_STOPSOUND: + m_pSound->StopSound(pMsg->data4); + break; + case MESS_ASCENSEURSTART: + NetAscenseurSynchro(pMsg->data4, STEP_STOPSTART); + break; + case MESS_ASCENSEUREND: + NetAscenseurSynchro(pMsg->data4, STEP_STOPEND); + break; + case MESS_STOPCLOUD: + if (pMsg->data4 == m_team) + { + m_blupiCloud = FALSE; + m_jauges[JAUGE_POWER].SetHide(TRUE); + } + break; + } + } + } + if (pack.type == PK_LEAVE) + { + LoadString(257, res, 100); + sprintf(text, res, m_pNetwork->m_players[player].name); + NotifPush(text); + m_pNetwork->m_players[player].bIsPresent = 0; + m_netBlupiIcon[player] = -1; + } + if (pack.type == PK_LOST) + { + LoadString(258, res, 100); + sprintf(text, res, m_pNetwork->m_players[player].name); + NotifPush(text); + m_pNetwork->m_players[player].bIsPresent = 0; + m_netBlupiIcon[player] = -1; + } + if (pack.type == PK_DIE) + { + if (pack.keyPress == 0) + { + LoadString(261, res, 100); + } + else if (pack.keyPress == 1) + { + LoadString(260, res, 100); + } + else + { + LoadString(259, res, 100); + } + sprintf(text, res, m_pNetwork->m_players[player].name, pack.keyPress); + NotifPush(text); + } + if (pack.type == PK_PAUSE) + { + m_bPause = pack.keyPress; + } + } + + for (i = 0; i < MAXNETPLAYER; i++) + { + if (!recentSenders[i]) + { + DoNetSmooth(i); + } + } } void CDecor::DoNetSmooth(int player) { + POINT start, end; + RECT rect; + if (m_bNetMovePredict && m_netBlupiIcon[player] != -1) + { + if (m_netTimeSincePacket[player] < 5) + { + start = m_netBlupiPos[player]; + end = start + m_netVitesses[player]; + rect = RECT(start.x + 12, start.y + 11, start.x + DIMBLUPIX - 12, start.y + DIMBLUPIY - 2); + TestPath(rect, start, &end); + m_netBlupiPos[player] = end; + } + m_netTimeSincePacket[player]++; + } } void CDecor::NetAdjustToLift() { for (int i = 0; i < MAXNETPLAYER; i++) { - if (m_netPos[i].x != -1 && m_netTransports[i] >= 0 && m_netTransports[i] < MAXMOVEOBJECT) + if (m_netBlupiPos[i].x != -1 && m_netTransports[i] >= 0 && m_netTransports[i] < MAXMOVEOBJECT) { - m_netPos[i].y = m_moveObject[m_netTransports[i]].posCurrent.y - 58; + m_netBlupiPos[i].y = m_moveObject[m_netTransports[i]].posCurrent.y - (DIMBLUPIY - 2); } } } -void CDecor::FUN_15da0(int index, short step) +void CDecor::NetAscenseurSynchro(int index, short step) { + int i; + POINT delta; + MoveObject* otherMob; + MoveObject* mob = &m_moveObject[index]; + mob->step = step; + mob->time = 0; + delta.x = abs(mob->posEnd.x - mob->posStart.x); + delta.y = abs(mob->posEnd.y - mob->posStart.y); + + for (i = 0; i < MAXMOVEOBJECT; i++) + { + otherMob = &m_moveObject[i]; + if (i != index && otherMob->type == mob->type) + { + if (otherMob->stepAdvance == mob->stepAdvance && + otherMob->stepRecede == mob->stepRecede && + otherMob->timeStopStart == mob->timeStopStart && + otherMob->timeStopEnd == mob->timeStopEnd) + { + otherMob->step = step; + otherMob->time = 0; + } + } + } } void CDecor::NetPlayerCollide(POINT pos, int* out) { int i; - tagRECT rect1; + RECT rect1; RECT rect2; RECT rect3; - rect2.right = pos.x + 44; rect2.left = pos.x + 16; rect2.top = pos.y + 11; - rect2.bottom = pos.y + 58; + rect2.right = pos.x + DIMBLUPIX - 16; + rect2.bottom = pos.y + DIMBLUPIY - 2; - // more + for (i = 0; i < MAXNETPLAYER; i++) + { + if (m_netBlupiIcon[i] != -1) + { + if (m_netBlupiSec[i] != SEC_HIDE) + { + rect1.left = m_netBlupiPos[i].x + 16; + rect1.top = m_netBlupiPos[i].y + 11; + rect1.right = m_netBlupiPos[i].x + DIMBLUPIX - 16; + rect1.bottom = m_netBlupiPos[i].y + DIMBLUPIY - 2; + } + if (IntersectRect(&rect3, &rect1, &rect2)) + { + *out = i; + } + } + } + *out = -1; } void CDecor::NetMessageIndexFlush() @@ -150,11 +398,13 @@ BOOL CDecor::NetMessagePush(NetMessage* message) return TRUE; } -BOOL CDecor::NetMessagePop(NetMessage* message) +BOOL CDecor::NetMessagePop(NetMessage* out_msg) { + int i; + if (m_netMessageIndex1 == 0) return FALSE; - CopyMemory(message, &m_netMessages[m_netMessageIndex3], sizeof(NetMessage)); + CopyMemory(out_msg, &m_netMessages[m_netMessageIndex3], sizeof(NetMessage)); m_netMessageIndex1--; m_netMessageIndex3++; if (m_netMessageIndex3 == MAXNETMESSAGE) diff --git a/src/decor.h b/src/decor.h index 281cd3c..ff98d48 100644 --- a/src/decor.h +++ b/src/decor.h @@ -52,11 +52,10 @@ MoveObject; typedef struct { - char type; - char data1; + short type; short x; short y; - short channel; + short z; } NetMessage; @@ -344,7 +343,7 @@ public: void StartSploutchGlu(POINT pos); BOOL ObjectStart(POINT pos, int type, int speed); BOOL ObjectStart(POINT pos, int type, int speed, BOOL bMulti); - BOOL ObjectDelete(POINT pos, int type); + BOOL ObjectDelete(POINT pos, int type, BOOL bMulti = FALSE); void MoveObjectStep(); void MoveObjectStepLine(int i); void MoveObjectStepIcon(int i); diff --git a/src/def.h b/src/def.h index 43ea5b5..31c14fa 100644 --- a/src/def.h +++ b/src/def.h @@ -33,7 +33,6 @@ #define MAXFIFOPOS 10 #define MAXCHAT 6 #define MAXSAVE 6 -#define LIFT_RANGE_Y 30 #define MAXDEMO 9999 #define MAXINDEX 20 diff --git a/src/event.cpp b/src/event.cpp index e7c8248..07e2163 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -5091,7 +5091,7 @@ error: return FALSE; } -void CEvent::SetLives(int lives) +void CEvent::SetNbVies(int lives) { m_lives = lives; } @@ -5842,4 +5842,26 @@ BOOL CEvent::CurrentWrite(int rank) return TRUE; } return FALSE; +} + +// Passe les images d'introduction. + +void CEvent::IntroStep() +{ + m_introTime++; + + if (m_introTime > 20 * 3) + { + if (m_phase == WM_PHASE_INTRO1) + { + ChangePhase(WM_PHASE_INTRO2); + return; + } + + if (m_phase == WM_PHASE_INTRO2) + { + ChangePhase(WM_PHASE_INIT); + return; + } + } } \ No newline at end of file diff --git a/src/event.h b/src/event.h index 683d567..a3f4599 100644 --- a/src/event.h +++ b/src/event.h @@ -132,7 +132,7 @@ public: void DebugDisplay(char m); void IntroStep(); - void SetLives(int lives); + void SetNbVies(int lives); void ReadAll(); BOOL SaveState(int rank); @@ -204,8 +204,8 @@ protected: int m_quicksaveIndex; int m_mission; char m_gamerName[100]; - char m_gamerNameList[8][100]; - BOOL m_gamerExist[8]; + char m_gamerNameList[MAXGAMER][100]; + BOOL m_gamerExist[MAXGAMER]; void* m_somethingJoystick; int m_menuIndex; int m_choiceIndex; @@ -213,7 +213,7 @@ protected: int m_menuDecor[11]; BOOL m_bMouseRelease; int m_private; - int m_bNamesExist[8]; + int m_bNamesExist[MAXGAMER]; int m_fileIndex; int m_maxMission; int m_phase; diff --git a/src/sound.cpp b/src/sound.cpp index 63d8d35..5dcebbc 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -556,7 +556,7 @@ BOOL CSound::PlayMusic(HWND hWnd, int music) sprintf(buf, "sound\\music%.3d.blp", music - 1); strcat(string, buf); - m_hBassStream = BASS_MIDI_StreamCreateFile(FALSE, string, 0, 0, BASS_SAMPLE_LOOP, 0); + m_hBassStream = BASS_MIDI_StreamCreateFile(FALSE, string, 0, 0, BASS_SAMPLE_LOOP | BASS_MIDI_DECAYEND | BASS_MIDI_NOCROP, 0); BASS_ChannelSetAttribute(m_hBassStream, BASS_ATTRIB_VOL, table[m_midiVolume]); BASS_ChannelSetAttribute(m_hBassStream, BASS_ATTRIB_MIDI_REVERB, 0); BASS_ChannelStart(m_hBassStream);