diff --git a/.vs/Speedy Eggbert 2 Source/v17/.suo b/.vs/Speedy Eggbert 2 Source/v17/.suo index 6d27d95..7609fdf 100644 Binary files a/.vs/Speedy Eggbert 2 Source/v17/.suo and b/.vs/Speedy Eggbert 2 Source/v17/.suo differ diff --git a/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db b/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db index 743a67c..1b3d642 100644 Binary files a/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db and b/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db differ diff --git a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo index fb17b2b..c902b83 100644 Binary files a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo and b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo differ diff --git a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db index 65816d6..80722be 100644 Binary files a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db and b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db differ diff --git a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/DocumentLayout.json b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/DocumentLayout.json index 4a49fb6..d26aaae 100644 --- a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/DocumentLayout.json +++ b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/DocumentLayout.json @@ -168,7 +168,7 @@ "RelativeDocumentMoniker": "network.cpp", "ToolTip": "C:\\Users\\JonAd\\source\\repos\\HMVocaloid\\Speedy-Eggbert-2-Source-Code-Decomp\\network.cpp", "RelativeToolTip": "network.cpp", - "ViewState": "AQIAAC8BAAAAAAAAAAAAAAAAAAAAAAAA", + "ViewState": "AQIAADIBAAAAAAAAAAAAAAAAAAAAAAAA", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "WhenOpened": "2024-07-31T17:40:11.196Z", "EditorCaption": "" diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 7e433ed..2c4bc34 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -2,6 +2,6 @@ "ExpandedNodes": [ "" ], - "SelectedNode": "\\Speedy Eggbert 2 Source.sln", + "SelectedNode": "\\event.cpp", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 1cb6182..e717404 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/button.cpp b/button.cpp index d17a6cf..e37e7a2 100644 --- a/button.cpp +++ b/button.cpp @@ -25,7 +25,7 @@ CButton::CButton() m_type = 0; m_bEnable = TRUE; m_bHide = FALSE; - m_bSomething = 0; + m_bSomething = FALSE; m_state = 0; m_mouseState = 0; m_nbMenu = 0; @@ -46,10 +46,7 @@ CButton::~CButton() // Create a new Button BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound, - POINT pos, int type, BOOL bMinimizeRedraw, - int *pMenu, int nbMenu, - int *pToolTips, int nbToolTips, - int region, UINT message) + POINT pos, int type, BOOL bMinimizeRedraw, int region, UINT message) { POINT iconDim; int i, icon; @@ -71,14 +68,14 @@ BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound, m_bMinimizeRedraw = bMinimizeRedraw; m_bEnable = TRUE; m_bHide = FALSE; - m_bSomething = 0; + m_bSomething = FALSE; m_message = message; m_pos.x = pos.x; m_pos.y = pos.y; m_dim.x = iconDim.x; m_dim.y = iconDim.y; - m_nbMenu = nbMenu; - m_nbToolTips = nbToolTips; + m_nbMenu = 0; + m_nbToolTips = 0; m_selMenu = 0; m_state = 0; m_mouseState = 0; @@ -135,7 +132,10 @@ void CButton::SetSomethingMenu(int somethingMenu) { int i = somethingMenu; + while (0 < i) + { + } } // Draw a button in its state diff --git a/button.h b/button.h index 57a8243..dda6628 100644 --- a/button.h +++ b/button.h @@ -26,10 +26,7 @@ public: ~CButton(); BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound, - POINT pos, int type, BOOL bMinimizeRedraw, - int *pMenu, int nbMenu, - int *pTooltips, int nbToolTips, - int region, UINT message); + POINT pos, int type, BOOL bMinimizeRedraw, int region, UINT message); void SetSomethingMenu(int somethingMenu); void Draw(); void Redraw(); diff --git a/decor.cpp b/decor.cpp index 9ea6128..af8155c 100644 --- a/decor.cpp +++ b/decor.cpp @@ -94,6 +94,27 @@ void CDecor::Create(HWND hWnd, CSound* pSound, CPixmap* pPixmap, CNetwork* pNetw NotifFlush(); } +BOOL CDecor::LoadImages() +{ + POINT totalDim, iconDim; + char filename[52]; + + if (m_lastRegion == m_region) return TRUE; + m_lastRegion = m_region; + + totalDim.x = DIMCELX * 2 * 16; + totalDim.y = DIMCELY * 2 * 6; + iconDim.x = DIMCELX * 2; + iconDim.y = DIMCELY * 2; + sprintf(filename, "decor%.3d.blp", m_region); + if (!m_pPixmap->Cache2(CHBACK, filename, totalDim, iconDim, FALSE)) return FALSE; + if (m_region == 0) + { + return FALSE; + } + return TRUE; +} + void CDecor::NetMessageIndexFlush() { m_netMessageIndex1 = 0; @@ -192,26 +213,6 @@ void CDecor::NetStopCloud(int rank) // The only seemingly sane function. -BOOL CDecor::LoadImages() -{ - POINT totalDim, iconDim; - char filename[52]; - - if (m_lastRegion == m_region) return TRUE; - m_lastRegion = m_region; - - totalDim.x = DIMCELX * 2 * 16; - totalDim.y = DIMCELY * 2 * 6; - iconDim.x = DIMCELX * 2; - iconDim.y = DIMCELY * 2; - sprintf(filename, "decor%.3d.blp", m_region); - if (!m_pPixmap->Cache2(CHBACK, filename, totalDim, iconDim, FALSE)) return FALSE; - if (m_region == 0) - { - return FALSE; - } - return TRUE; -} void CDecor::InitGamer() { @@ -293,7 +294,8 @@ void CDecor::InitDecor() m_blupiAction = 1; m_blupiPhase = 0; m_blupiIcon = 0; - m_blupiChannel = 2; + m_blupiChannel.channel = CHBLUPI; + m_blupiChannel.blupiChannel = 0; m_blupiFocus = TRUE; m_blupiAir = FALSE; m_blupiHelico = FALSE; @@ -332,7 +334,7 @@ void CDecor::InitDecor() m_scrollAdd.x = 0; m_scrollAdd.y = 0; m_term = 0; - byeByeObjects = -1; + m_2ndPositionCalculationSlot = -1; } void CDecor::SetTime(int time) @@ -355,32 +357,42 @@ void CDecor::PlayPrepare(BOOL bTest) rand = Random(0, 23); */ - if (bTest) - { - m_nbVies = 3; - } + int blupiStart; - if (m_bMulti == 0) { - m_blupiPos = m_blupiStartPos; - m_blupiDir = m_blupiStartDir; - } - else - { - m_nbVies = 10; - m_blupiPos = m_blupiStartPos; - m_blupiDir = m_blupiStartDir; + if (bTest != FALSE) + { + *(BYTE*)(m_doors + 198) = 3; + } - } - if (m_blupiDir == 1) - { - m_blupiIcon = 4; - } - else - { - m_blupiIcon = 0; - } - m_blupiAction = 1; + if (*(int*)((int)m_blupiStartDir + 14) == FALSE) + { + m_blupiPos.x = *(LONG*)((int)&m_blupiFifoPos[9].y + 2); + m_blupiPos.y = *(LONG*)((int)&m_blupiStartPos[0].x + 2); + blupiStart = *(int*)((int)&m_blupiStartPos[3].y + 2); + } + else + { + *(BYTE*)(m_doors + 198) = 10; + blupiStart = *(int*)((int)&m_bMulti + 2); + m_blupiPos.x = *(LONG*)((int)&m_blupiFifoPos[blupiStart + 9].y + 2); + m_blupiPos.y = *(LONG*)((int)&m_blupiStartPos[blupiStart].x + 2); + blupiStart = *(int*)((int)m_blupiStartDir + *(int*)((int)&m_bMulti + 2) * 4 + -2); + } + m_blupiDir = blupiStart; + if (blupiStart == DIR_LEFT) + { + m_blupiIcon.icon = 4; + m_blupiIcon.type = 0; + } + else + { + m_blupiIcon.icon = 4; + m_blupiIcon.type = 0; + } + + m_blupiAction = ACTION_STOP; m_blupiPhase = 0; + m_blupiTransport = DIR_LEFT; m_blupiFocus = TRUE; m_blupiAir = FALSE; m_blupiHelico = FALSE; @@ -447,6 +459,7 @@ void CDecor::PlayPrepare(BOOL bTest) } m_goalPhase = 0; MoveObjectSort(); + UpdateCaisse(); m_scrollPoint = m_blupiPos; m_scrollAdd.x = 0; m_scrollAdd.y = 0; @@ -516,6 +529,75 @@ int CDecor::IsTerminated() return m_term; } +void CDecor::MoveStep() +{ + LONG* longDecor; + UINT posDecor; + int dimDecor; + + MoveObjectStep(); + + if ((m_phase == WM_PHASE_PLAY) || (m_phase == WM_PHASE_PLAYTEST)) + { + BlupiStep(); + + NotifStep(); + } + + if (m_phase == WM_PHASE_BUILD) + { + if ((m_keyPress & 2) != 0) + { + posDecor = m_posDecor.x + 50; + dimDecor = -(UINT)((m_dimDecor).x != 0) & 5760; + m_posDecor.x = dimDecor; + if ((int)posDecor < dimDecor) + { + m_posDecor.x = posDecor; + } + m_posCelHili.x = -1; + } + if ((m_keyPress & 1) != 0) + { + longDecor = &m_posDecor.y; + *longDecor = *longDecor + 50; + dimDecor = -(UINT)(m_dimDecor.y != 0) & 5920; + if ((int)dimDecor < m_posDecor.y) + { + m_posDecor.y = dimDecor; + } + m_posCelHili.y = dimDecor; + } + m_posCelHili.x = -1; + } + if ((m_keyPress & 4) != 0) + { + posDecor = m_posDecor.y + -50; + m_posDecor.y = posDecor; + if (posDecor < 0) + { + m_posDecor.y = 0; + } + m_posCelHili.x = -1; + } + return; +} + +void CDecor::NotifStep() +{ + int i; + + i = *(int*)(m_notifText[3] + 98); + + if (i == 0) + { + NotifPop(); + return; + } + *(int*)(m_notifText[3] + 98) = i + -1; + return; +} + // Fuck this function. That's all I can say. void CDecor::Build() @@ -656,13 +738,22 @@ void CDecor::Build() int CDecor::GetBlupiChannelStandard() { - if (m_bMulti && m_blupiChannel == CHBLUPI && m_team > 0) + int channel1; + int channel2; + + if (((*(int*)((int)m_blupiStartDir + 14) != FALSE) && + (channel1._0_2_ = m_blupiChannel.channel, + channel1._2_2_ = m_blupiChannel.blupiChannel, channel1 == 2)) && + (channel1 = *(int*)((int)&m_bMulti + 2), 0 < channel1)) { - return m_team + CHBLUPI1 - 1; + return channel1 + 10; } - return m_blupiChannel; + channel2._0_2_ = m_blupiChannel.channel; + channel2._2_2_ = m_blupiChannel.blupiChannel; + return channel2; } + BOOL CDecor::BlitzActif(int celx, int cely) { POINT pos; @@ -692,7 +783,7 @@ void CDecor::DrawInfo() { pos.x = 10; pos.y = 10; - DrawText(m_pPixmap, pos, *m_messages[i], 0); + DrawTextB(m_pPixmap, pos, m_messages[i], 0); } } if (m_nbVies > 0) @@ -798,6 +889,11 @@ void CDecor::SetInput(UINT input) } } +void CDecor::SetJoystickEnable(BOOL bJoystick) +{ + m_bJoystick = bJoystick; + return; +} void CDecor::SetSpeedX(double speed) { @@ -966,6 +1062,41 @@ void CDecor::PosSound(POINT pos) } } +void CDecor::DeleteCel(int celX, int celY) +{ + POINT cel; + POINT pos; + + m_2ndPositionCalculationSlot = -1; + + if ((((-1 < celX) && (celX < MAXCELX)) && (-1 < celY)) && (celY < MAXCELY)) + { + m_decor[celX][celY].icon = -1; + cel.y = celY; + cel.x = celX; + AdaptBorder(cel); + m_bigDecor[celX][celY].icon = -1; + pos.y = celY; + pos.x = celX; + MoveObjectDelete(pos); + } + return; +} + +void CDecor::SetGamerName(const char* playerName) +{ + char* name; + int result; + + name = m_missionTitle; + + result = strlen(playerName) + 1; + + strncpy(name, playerName, result); + + return; +} + // TODO: Add VehicleSoundsPhase void CDecor::UpdateCaisse() @@ -1108,14 +1239,14 @@ int CDecor::SetBlupiChannel() int CDecor::GetBlupiChannel() { - int m_blupiChannel = CHBLUPI; + int channel; - - if ( m_bMulti != 0 || - m_team > 0);{ - return m_team + 10; - } - return CHBLUPI; + if ((*(int*)((int)m_blupiStartDir + 14) != 0) && + (channel = *(int*)((int)&m_bMulti + 2), 0 < channel)) + { + return channel + CHELEMENT; + } + return CHBLUPI; } @@ -1210,7 +1341,7 @@ void CDecor::GetDoors(int doors) void CDecor::SetAllMissions(BOOL CheatDoors) { m_bCheatDoors = CheatDoors; - m_bPrivate, m_mission->AdaptDoors(); + m_bPrivate->AdaptDoors(m_mission); return; } @@ -5291,6 +5422,17 @@ void CDecor::SetTeam(int team) m_team = team; } +void CDecor::SetNetDebug(BOOL bNetDebug) +{ + m_bNetDebug = bNetDebug; + + if (bNetDebug != FALSE) + { + remove("debug.txt"); + } + return; +} + void CDecor::MemorizeDoors(BYTE* doors) { int i; @@ -6138,6 +6280,15 @@ BOOL CDecor::SearchTeleporte(POINT pos, POINT newpos) return FALSE; } +BOOL CDecor::SomethingMissionPath(int user, int mission, BOOL bUser) +{ + char str[260]; + + GetMissionPath(str, user, mission, bUser); + remove(str); + return TRUE; +} + BOOL CDecor::IsNormalJump(POINT pos) { pos.x += 32; @@ -8777,13 +8928,23 @@ void CDecor::OutputNetDebug(char* text) if (m_bNetDebug != FALSE) { sprintf(textbuffer, "/ snd=%d(%d)_rcv=%d(%d)", m_netPacketsSent, m_netPacketsSent2, m_netPacketsRecieved, m_netPacketsRecieved2); - + strcat(text, textbuffer); } + return; } -void CDecor::InitalizeDoors(GameData gameData) +void CDecor::InitalizeDoors(BYTE* doors) { - gameData.GetDoors(m_doors); + int i; + + i = 0; + + do + { + doors[i] = (BYTE)m_doors[i]; + i++; + } while (i < 200); + return; } void CDecor::GetBlupiInfo(BOOL* bHelico, BOOL* bJeep, BOOL* bSkate, BOOL* bNage) diff --git a/decor.h b/decor.h index 28d326a..eed7faa 100644 --- a/decor.h +++ b/decor.h @@ -159,13 +159,16 @@ MoveObject; typedef struct { - int icon; + short icon; + short type; } -Icon; +Icon4; typedef struct { short channel; + short blupiChannel; + short itemChannel; } IconChannel; @@ -201,6 +204,13 @@ typedef enum } WMessage; +typedef enum +{ + DIR_LEFT, + DIR_RIGHT +} +Direction; + typedef struct { @@ -620,7 +630,7 @@ public: BOOL GetPause(); void SetPause(BOOL bPause); void GetDoors(int doors); - void InitalizeDoors(GameData gameData); + void InitalizeDoors(BYTE* doors); void SetAllMissions(BOOL CheatDoors); void CheatAction(int cheat, MoveObject moveObject); void SetAccessBuild(BOOL build); @@ -731,9 +741,13 @@ public: BOOL CurrentRead(int gamer, int mission, BOOL bUser); void SetJoystickEnable(BOOL bJoystick); BOOL GetShowSecret(); + BOOL MissionStart(int gamer, int rank, BOOL bUser); void MemorizeDoors(BYTE* doors); - + void NotifPush(char* str); + void DeleteCel(int celX, int celY); + void SetGamerName(const char* playerName); + BOOL SomethingMissionPath(int user, int mission, BOOL bUser); // Network Related Functions void NetMessageIndexFlush(); @@ -747,6 +761,9 @@ public: void NetPlayerCollide(POINT pos, int* out); void TreatNetData(); void OutputNetDebug(char* text); + void NotifStep(); + void NotifPop(); + void SetNetDebug(BOOL bNetDebug); protected: @@ -762,6 +779,7 @@ protected: MoveObject m_moveObject[100][100]; ByeByeObject m_byeByeObjects; int m_input; + int m_bJoystick; int m_previousInput; int m_blupiTimeShield; POINT m_blupiPosMagic; @@ -810,8 +828,8 @@ protected: int m_direction; int m_actionFrameCount; POINT m_velocity; - int m_blupiIcon; - POINT m_blupiStartPos; + Icon4 m_blupiIcon; + POINT m_blupiStartPos[4]; int m_blupiStartDir; int m_blupiAction; BOOL m_bCheatDoors; diff --git a/def.h b/def.h index 59265ae..362cdcf 100644 --- a/def.h +++ b/def.h @@ -482,6 +482,8 @@ #define WM_PHASE_GWRITE 1584 #define WM_PHASE_DOQUIT 1587 #define WM_PHASE_GAMER 1545 +#define WM_PHASE_CLEARg 1528 +#define WM_PHASE_CLEARd 1561 diff --git a/event.cpp b/event.cpp index 78076cd..014727d 100644 --- a/event.cpp +++ b/event.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "def.h" #include "resource.h" #include "pixmap.h" @@ -1425,7 +1426,8 @@ CEvent::CEvent() int i; - + CMenu(m_menu); + m_somethingJoystick = 0; m_bFullScreen = TRUE; m_mouseType = MOUSETYPEGRA; @@ -1487,7 +1489,12 @@ CEvent::CEvent() CEvent::~CEvent() { - WriteInfo(); // Read the file "info.blp" + char* filename; + + WriteInfo(m_gamer, filename); // Read the file "info.blp" + OutputDebug(filename); + + return; } void CEvent::Create(HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, @@ -1950,17 +1957,88 @@ void CEvent::ChatSend() int netplay; UINT i; char* text; - char end; + char end[4]; + POINT* pos; DPID dpid; LPVOID data[25]; + char textInput[100]; text = m_textInput; if (m_textInput[0] != '\0') { netplay = NetSearchPlayer(m_pNetwork->m_dpid); - i = 0xFFFFFFFF; - end = &'<'; + strcpy(textInput, "<"); } + if (netplay != -1) + { + strcat(textInput, (const char*)m_pNetwork->m_players[netplay].name); + strcat(textInput, "> "); + strcat(textInput, text); + ChatMessageSound((char*)textInput); + end[0] = 108; + end[1] = 11; + dpid = m_pNetwork->m_dpid; + m_pNetwork->Send(&end, 108, 1); + text = 0; + pos[132].x = 0; + pos[132].y = strlen(text); + pos[133].x = 0; + m_textHiliEnd = i - 1; + m_textCursorIndex = 0; + SetEnable(WM_BUTTON20, 0); + } + return; +} + +void CEvent::ChatMessageSound(char* data) +{ + int num; + char (*chatZone); + char(*chat)[5]; + POINT pos; + + num = 3; + chatZone = m_chatZone[0]; + do + { + if (chatZone == '\0') + { + chat = m_chatZone + num * 20; + goto error; + } + num++; + chatZone = chatZone + 100; + } while (num < 6); + HandleChatBuffer(); + chat = (char(*) [5])m_text; + return; + +error: + strcpy((char*)chat, data); + pos.x = 320; + pos.y = 240; + m_pSound->PlayImage(11, pos, -1); +} + +void CEvent::HandleChatBuffer() +{ + char (*chatZone)[5]; + int num; + int result; + char* text; + + num = 5; + chatZone = m_chatZone; + do + { + result = strlen((const char*)chatZone + 100) + 1; + text = (char*)chatZone; + chatZone += 100; + memcpy(text, chatZone, result); + --num; + } while (num); + *((BYTE*)m_text) = 0; + return; } void CEvent::OutputNetDebug(const char* str) @@ -1969,15 +2047,17 @@ void CEvent::OutputNetDebug(const char* str) FILE* streamf; UINT element; + streamf = (FILE*)m_pDecor->GetNetDebug(); + if (m_pDecor->GetNetDebug() != FALSE) { if (fopen("debug.txt", "ab") != (FILE*)0) { - element = 0xFFFFFFFF; - strcpy(stream, str); + fwrite(str, 1, strlen((const char*)str), streamf); + streamf = (FILE*)fclose(streamf); } - fwrite(str, 1, (element - 1), streamf); - fclose(streamf); + + } return; } @@ -2014,12 +2094,16 @@ BOOL CEvent::DrawButtons() int i; int levels[2]; int types[2]; - int world, time, lg, button, volume, pente, icon; + int world, time, lg, button, volume, pente, icon, sound; + BOOL soundEnabled; char res[100]; + char textLeft[24]; char text[100]; + char pText[5]; POINT pos; RECT rect; BOOL bEnable; + WMessage phase; if ( (m_phase == WM_PHASE_INSERT && m_phase == WM_PHASE_BYE )) { @@ -2053,10 +2137,42 @@ BOOL CEvent::DrawButtons() } m_pDecor->OutputNetDebug(text); + phase = m_phase; + + if (((phase != WM_PHASE_PLAY) && (phase != WM_PHASE_PLAYTEST)) && (phase != WM_PHASE_BUILD)) + { + rect.right = 302; + rect.left = 2; + rect.top = 2; + rect.bottom = 14; + m_pPixmap->DrawPart(-1, 0, pos, rect, 1, FALSE); + } + DrawTextLeft(m_pPixmap, pos, textLeft, 10); if (m_phase == WM_PHASE_INIT) { - DrawTextNew(m_pPixmap, pos, R"(Version 2.0)", FONTLITTLE); + DrawTextB(m_pPixmap, pos, "Version 2.0", FONTLITTLE); + } + + if (m_phase == WM_PHASE_GAMER) + { + LoadString(TX_CHOOSEGAMER, res, 100); + lg = GetTextWidth(res, 0); + pos.y = 26; + pos.x = LXIMAGE / 2 - lg / 2; + DrawTextLeft(m_pPixmap, pos, res, 1); + pText = m_gamerNameList; + lg = 8; + do + { + pos.y = 69; + pos.x = 110; + DrawTextB(m_pPixmap, pos, pText, 0); + 69 = 69 + 40; + pText++; + lg++; + } while (lg != 0); + SetEnable(WM_PHASE_CLEARg, (m_filenameBuffer + -1) + m_gamer * 4 + 212); } if (m_phase == WM_PHASE_PLAY && m_phase == WM_PHASE_PLAYTEST && m_phase == WM_PHASE_BUILD) @@ -2075,7 +2191,12 @@ BOOL CEvent::DrawButtons() } if (m_phase == WM_PHASE_SETUP || m_phase == WM_PHASE_SETUPp) { - SetState(WM_BUTTON5, (m_pPixmap->GetTrueColor() == 0)); + sound = m_pSound->GetAudioVolume(); + soundEnabled = TRUE; + if ((sound == 0) || (m_pSound->GetEnable()) == FALSE) + { + soundEnabled = FALSE; + } } if (m_phase == WM_PHASE_PLAY || m_phase == WM_PHASE_PLAYTEST) { @@ -2185,6 +2306,118 @@ BOOL CEvent::DrawButtons() { DrawTextLeft(m_pPixmap, m_posToolTips, m_textToolTips, FONTWHITE); } + if (m_phase == WM_PHASE_CLEARg) + { + LoadString(TX_CHOOSEGAMER, res, 100); + lg = GetTextWidth((char*)res, 0); + pos.y = 102; + pos.x = 320 - lg / 2; + DrawTextLeft(m_pPixmap, pos, (char*)res, 1); + LoadString(TX_DISCARDGAME, res, 100); + lg = GetTextWidth(res, 0); + strcpy(text, (const char*)m_gamerName); + strcat(text, "?"); + lg = GetTextWidth(text, 0); + DrawTextLeft(m_pPixmap, pos, res, 0); + } + if (m_phase == WM_PHASE_CLEARd) + { + LoadString(TX_DESIGNMISSION, res, 100); + lg = GetTextWidth(res, 0); + pos.y = 104; + pos.x = 320 - lg / 2; + DrawTextLeft(m_pPixmap, pos, res, 1); + LoadString(TX_DELETEMISSION, res, 100); + GetWorld(); + sprintf(text, res); + lg = GetTextWidth(text, 0); + pos.y = 210; + pos.x = 320 - lg / 2; + DrawTextLeft(m_pPixmap, pos, text, 0); + strcpy(text, (char*)m_pDecor->GetMissionTitle()); + + if (text[0] == '\0') + { + LoadString(TX_NONAME, res, 100); + } + strcat(text, "?"); + lg = GetTextWidth(text, 0); + pos.y = 230; + pos.x = 320 - lg / 2; + DrawTextLeft(m_pPixmap, pos, res, 0); + } + if (m_phase == WM_PHASE_INFO) + { + LoadString(TX_DESIGNMISSION, res, 100); + lg = GetTextWidth(res, 0); + pos.y = 37; + pos.x = 320 - lg / 2; + DrawTextLeft(m_pPixmap, pos, res, 0); + // Unknown Field + // DrawIcon + // End of if function + LoadString(TX_MISSIONNUM, res, 100); + sprintf(text, res); + lg = GetTextWidth(text, 0); + pos.y = 106; + pos.x = 250 - lg / 2; + DrawTextLeft(m_pPixmap, pos, text, 1); + strcpy(text, (char*)m_pDecor->GetMissionTitle()); + if (res[0] == '\0') + { + LoadString(TX_NONAME, res, 100); + } + lg = GetTextWidth(res, 0); + pos.y = 269; + pos.x = 250 - lg / 2; + DrawTextLeft(m_pPixmap, pos, res, 0); + } +} + +void CEvent::PutTextInputBox(POINT pos) +{ + char textInput[100]; + char* textConst; + int text; + CPixmap* pPixmap; + int num; + UINT textHili; + LONG posD; + + text = GetTextWidth(m_textInput, 0); + posD = pos.x - text / 2; + textHili = m_textHiliStart; + + if (0 < (int)textHili) + { + memcpy(textInput, textConst, textHili); + pPixmap = m_pPixmap; + textInput[textHili] = 0; + DrawTextLeft(pPixmap, pos, textInput, 0); + text += GetTextWidth(textInput, 0); + } + if (m_textHiliStart < m_textHiliEnd) + { + textHili = m_textHiliEnd - m_textHiliStart; + memcpy(textInput, m_textInput + m_textHiliStart, text); + pPixmap = m_pPixmap; + textInput[textHili] = 0; + DrawTextLeft(pPixmap, pos, textInput, 2); + text += GetTextWidth(textInput, 0); + } + if (m_textCursorIndex % 16 < 8) + { + DrawTextLeft(pPixmap, pos, &"|", 0); + } + num = m_textCursorIndex; + + if (num < (int)strlen((const char*)m_textInput)) + { + strcpy(textInput, num + m_textInput); + DrawTextLeft(pPixmap, pos, textInput, 0); + } + m_textCursorIndex = m_textCursorIndex + 1; + return; } BOOL CEvent::TextSomething() @@ -2568,6 +2801,67 @@ void CEvent::TryInsert() } } +void CEvent::ReadAll() +{ + BOOL mission; + BOOL read; + BOOL bUser; + BOOL bPrivate; + BOOL bMission; + + if ((-1 < m_fileIndex) && (*(int*)((int)(m_filenameBuffer + -1) + m_fileIndex * 4 + 216) != 0)) + { + mission = m_pDecor->MissionStart(m_gamer, 999, bUser); + + if (mission != FALSE) + { + read = m_pDecor->Read(m_gamer, m_fileIndex, bMission, bPrivate); + + if (read != FALSE) + { + m_pDecor->DrawMap(FALSE, -1); + } + m_pDecor->Read(m_gamer, 999, bMission, bPrivate); + } + } + return; +} + +BOOL CEvent::SaveState(int rank) +{ + BOOL bMission; + BOOL bUser; + char str[100]; + + bMission = m_pDecor->MissionStart(m_gamer, rank, bUser); + + if (bMission == FALSE) + { + return FALSE; + } + LoadString(TX_GAMESAVED, str, 100); + m_pDecor->NotifPush(str); + // m_field959_0x6d10 = rank; + return TRUE; +} + +void CEvent::SomethingUserMissions(char* lpFilename, LPCSTR fileSomething) +{ + UINT buffer; + char* folderName; + + mkdir("\\User"); + strcpy(lpFilename, "\\User\\"); + strcat(lpFilename, fileSomething); + + if ((folderName = strstr(folderName, ".xch")) || ((buffer = 0, folderName - lpFilename != strlen(lpFilename) - 4))) + { + buffer = 0; + strcat(lpFilename, ".xch"); + } + return; +} + // Add SomethingHubWorld once figured out. // Very rough code, needs improvement @@ -2797,11 +3091,6 @@ int CEvent::GetTryPhase() return m_tryPhase; } -void CEvent::SomethingUserMissions(LPCSTR lpFileName, LPCSTR thing) -{ - -} - void CEvent::GetDoors(int doors) { for (int i = 0; i < 200; i++) @@ -3116,21 +3405,23 @@ void CEvent::DemoRecEvent(UINT message, UINT input, WPARAM wParam, LPARAM lParam } } -BOOL CEvent::WriteInfo() +BOOL CEvent::WriteInfo(int gamer, char* playername) { char filename[MAX_PATH]; FILE* file = NULL; DescInfo info; int nb; int doors; - GameData door[200]; + BYTE door[200]; + char text[100]; - strcpy(filename, "data\\info%.blp"); + sprintf(filename, "data\\info%.3d.blp", gamer); AddUserPath(filename); - file = fopen(filename, "wb"); if (file == NULL) goto error; + strcpy(text, (const char*)m_gamerName); + info.majRev = 1; info.prive = m_private; info.mission = m_mission; @@ -3141,7 +3432,7 @@ BOOL CEvent::WriteInfo() info.bHiliInfoButton = m_bHiliInfoButton; info.bAccessBuild = m_bAccessBuild; - m_pDecor->InitalizeDoors(door) + m_pDecor->InitalizeDoors(door); info.audioVolume = m_pSound->GetAudioVolume(); info.midiVolume = m_pSound->GetMidiVolume(); @@ -3178,16 +3469,19 @@ BOOL CEvent::ReadInfo(int gamer) LoadString(TX_READINFO, buffer, 100); sprintf(m_gamerName, buffer, gamer); sprintf(filename, "data\\info%.3d.blp", gamer); - - strcpy(filename, "data\\info%.3d.blp"); AddUserPath(filename); + file = fopen(filename, "rb"); if (file == NULL) goto error; nb = fread(&info, sizeof(DescInfo), 1, file); if (nb < 1) goto error; + if ((BYTE*)m_gamerName) + { + strcpy((char*)m_gamerName, buffer); + } info.majRev = 1; info.prive = m_private; @@ -3221,4 +3515,7 @@ BOOL CEvent::ReadPlayer() strcpy(filename, "data\\info%.3d.blp"); AddUserPath(filename); -} \ No newline at end of file + remove(filename); + return TRUE; +} + diff --git a/event.h b/event.h index fa39a02..faa4c2e 100644 --- a/event.h +++ b/event.h @@ -177,6 +177,12 @@ public: void IntroStep(); + void ReadAll(); + BOOL SaveState(int rank); + void SomethingUserMissions(char* lpFilename, LPCSTR fileSomething); + + + protected: void DrawTextCenter(int res, int x, int y, int font=0); BOOL CreateButtons(); @@ -198,12 +204,13 @@ protected: void PrivateLibelle(); BOOL ReadLibelle(int world, BOOL bSchool, BOOL bHelp); - BOOL WriteInfo(); + BOOL WriteInfo(int gamer, char* playername); BOOL ReadInfo(int gamer); void TryPhase(); void UnTryPhase(); int GetTryPhase(); BOOL ReadPlayer(); + void PutTextInputBox(POINT pos); void SetLives(int lives); void DemoRecStart(); @@ -220,6 +227,8 @@ protected: void NetSend(NetMessageType message, USHORT data); void NetDraw(); void ChatSend(); + void HandleChatBuffer(); + void ChatMessageSound(char* data); void MouseRelease(); void MouseCapture(); @@ -230,8 +239,10 @@ protected: int m_exercice; int m_mission; char m_gamerName[100]; + char m_gamerNameList[10][100]; void* m_somethingJoystick; int m_menuIndex; + int m_fileIndex; int m_menuDecor[10]; BOOL m_bMouseRelease; int m_private; @@ -326,6 +337,9 @@ protected: int m_mission; int m_multi; HINSTANCE m_hInstance; - char m_chatZone[100][5]; + char m_chatZone[100][5]; char m_text[100]; -}; \ No newline at end of file +}; + +extern +int DirectoryThing(LPCSTR filename); \ No newline at end of file diff --git a/pixmap.cpp b/pixmap.cpp index a1ba314..484991c 100644 --- a/pixmap.cpp +++ b/pixmap.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "def.h" #include "pixmap.h" #include "misc.h" @@ -672,33 +674,68 @@ BOOL CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim, BOOL CPixmap::Cache2(int channel, const char *pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette) { - POINT iconDim; + IDirectDrawPalette* dDP; + LPDIRECTDRAWSURFACE dDS; + HRESULT hErr; - if (strstr(pFilename, "blupi") == pFilename) + if ((channel < 0) || (channel > 99)) { return FALSE; } - else + + if (m_lpDDSurface[channel] != (LPDIRECTDRAWSURFACE)0) { - if (strstr(pFilename, "element") == pFilename) - { - return FALSE; - } - if (strstr(pFilename, "explo") == pFilename) - { - return FALSE; - } - if (strstr(pFilename, "object") == pFilename) - { - return FALSE; - } - return TRUE; + Flush(channel); } - if (bUsePalette != 0) + if (bUsePalette != FALSE) { - + if (m_bDebug != FALSE) + { + OutputDebug("Use palette"); + } + if (m_lpDDPal != (LPDIRECTDRAWPALETTE)0) + { + if (m_bDebug != FALSE) + { + OutputDebug("Release palette"); + } + m_lpDDPal->Release(); + m_lpDDPal = (LPDIRECTDRAWPALETTE)0; + } } + dDP = DDLoadPalette(m_lpDD, pFilename); + m_lpDDPal = (LPDIRECTDRAWPALETTE)0; + + if (dDP != (IDirectDrawPalette*)0) + { + if (m_bDebug != FALSE) + { + OutputDebug("Set palette"); + } + m_lpDDSPrimary->SetPalette((LPDIRECTDRAWPALETTE)0); + hErr = (m_lpDDSPrimary->SetPalette(m_lpDDPal)); + if (hErr != 0) + { + TraceErrorDD(hErr, pFilename, 1); + } + } + dDS = (LPDIRECTDRAWSURFACE)DDLoadBitmap(m_lpDD, pFilename, 0, 0); + m_lpDDSurface[channel] = dDS; + if (dDS == (LPDIRECTDRAWSURFACE)0) + { + OutputDebug("Fatal error: DDLoadBitmap"); + return FALSE; + } + if (m_bDebug != FALSE) + { + OutputDebug("DDSetColorKey"); + } + DDSetColorKey(m_lpDDSurface[channel], RGB(0, 0, 255)); + strcpy((char*)(m_filename + channel), pFilename); + m_totalDim[channel] = totalDim; + m_iconDim[channel] = iconDim; + return TRUE; } // Cache une image provenant d'un bitmap. @@ -859,7 +896,52 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor, int CPixmap::Benchmark() { + timeb time[2]; + RECT rect; + FILE* file; + int num; + int num2; + int num3; + UINT num4; + int num5; + int num6; + int i; + POINT pos; + POINT dest; + char buffer[100]; + ftime(time); + num = num4; + num2 = 29; + num3 = 10; + + rect.top = num; + rect.left = 29; + rect.right = 669; + rect.bottom = 509; + num5 = 120; + DrawPart(-1, -3, dest, rect, 1, FALSE); + do + { + QuickIcon(1, 1, pos); + num5++; + } while (num5); + ftime(time); + i = num4; + + if (num > num4) + { + i = num4 + 100; + } + num6 = i - num; + sprintf(buffer, "Benchmark = %d\r\n", i - num); + + if (fopen("data\\bench.blp", "wb")) + { + fwrite(buffer, strlen(buffer), 1, file); + fclose(file); + } + return num6; } void CPixmap::SetDebug(BOOL bDebug) diff --git a/resource.h b/resource.h index b763d3d..042543d 100644 --- a/resource.h +++ b/resource.h @@ -63,10 +63,16 @@ #define TX_BUTTON_ONLYVSCROLL 123 #define TX_BUTTON_TESTMISSION 124 #define TX_PAUSE 125 +#define TX_DISCARDGAME 145 +#define TX_DESIGNMISSION 147 +#define TX_CHOOSEGAMER 148 #define TX_MUSIC 149 #define TX_READINFO 167 #define TX_REGION 178 #define TX_INSERT 182 +#define TX_DELETEMISSION 184 +#define TX_NONAME 187 +#define TX_MISSIONNUM 189 #define TX_GAMEPAUSE 197 #define TX_FULL_END1 203 #define TX_FULL_END2 204 @@ -78,6 +84,7 @@ #define TX_MULTI_GNAME 251 #define TX_LOAD_CGAME 269 #define TX_SAVE_CGAME 270 +#define TX_GAMESAVED 288 #define TX_REPEAT_CULTIVE 500 #define TX_REPEAT_FLEUR 501