diff --git a/source/duke3d/src/events_defs.h b/source/duke3d/src/events_defs.h index 3da1d84ef..b03303388 100644 --- a/source/duke3d/src/events_defs.h +++ b/source/duke3d/src/events_defs.h @@ -135,6 +135,11 @@ enum GameEvent_t { EVENT_UPDATESCREENAREA, EVENT_DISPLAYBORDER, EVENT_SETDEFAULTS, + EVENT_MAINMENUSCREEN, + EVENT_NEWGAMESCREEN, + EVENT_ENDLEVELSCREEN, + EVENT_EXITGAMESCREEN, + EVENT_EXITPROGRAMSCREEN, #ifdef LUNATIC EVENT_ANIMATEALLSPRITES, #endif diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index cd5203c5d..9cbb2ce2a 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -281,13 +281,16 @@ void G_GameExit(const char *msg) if (!g_quickExit) { - if (g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ') + if (VM_OnEventWithReturn(EVENT_EXITGAMESCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 0 && + g_mostConcurrentPlayers > 1 && g_player[myconnectindex].ps->gm&MODE_GAME && GTFLAGS(GAMETYPE_SCORESHEET) && *msg == ' ') { G_BonusScreen(1); setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP); } - if (*msg != 0 && *(msg+1) != 'V' && *(msg+1) != 'Y') + // shareware and TEN screens + if (VM_OnEventWithReturn(EVENT_EXITPROGRAMSCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 0 && + *msg != 0 && *(msg+1) != 'V' && *(msg+1) != 'Y') G_DisplayExtraScreens(); } @@ -5995,7 +5998,8 @@ static int G_EndOfLevel(void) ready2send = 0; - if (ud.display_bonus_screen == 1) + if ((VM_OnEventWithReturn(EVENT_ENDLEVELSCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0)) == 0 && + ud.display_bonus_screen == 1) { int32_t i = ud.screen_size; ud.screen_size = 0; diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index 7a3a5188e..7f1bf3013 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -731,6 +731,11 @@ const char *EventNames[MAXEVENTS] = "EVENT_UPDATESCREENAREA", "EVENT_DISPLAYBORDER", "EVENT_SETDEFAULTS", + "EVENT_MAINMENUSCREEN", + "EVENT_NEWGAMESCREEN", + "EVENT_ENDLEVELSCREEN", + "EVENT_EXITGAMESCREEN", + "EVENT_EXITPROGRAMSCREEN", #ifdef LUNATIC "EVENT_ANIMATEALLSPRITES", #endif diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 1887680ed..16c83aa84 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -1356,6 +1356,11 @@ static void prelevel(char g) } +static inline int G_HaveUserMap(void) +{ + return (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0); +} + void G_NewGame(int volumeNum, int levelNum, int skillNum) { DukePlayer_t *const pPlayer = g_player[0].ps; @@ -1372,11 +1377,31 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum) ready2send = 0; - if (ud.m_recstat != 2 && ud.last_level >= 0 && (g_netServer || ud.multimode > 1) && (ud.coop&GAMETYPE_SCORESHEET)) + if (ud.m_recstat != 2 && ud.last_level >= 0 && + VM_OnEventWithReturn(EVENT_EXITGAMESCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 0 && + (g_netServer || ud.multimode > 1) && (ud.coop&GAMETYPE_SCORESHEET)) G_BonusScreen(1); - if (levelNum == 0 && volumeNum == 3 && (!g_netServer && ud.multimode < 2) && ud.lockout == 0 - && (G_GetLogoFlags() & LOGO_NOE4CUTSCENE)==0) + g_showShareware = GAMETICSPERSEC*34; + + ud.level_number = levelNum; + ud.volume_number = volumeNum; + ud.player_skill = skillNum; + ud.secretlevel = 0; + ud.from_bonus = 0; + + ud.last_level = -1; + g_lastAutoSaveArbitraryID = -1; + g_lastautosave.reset(); + g_lastusersave.reset(); + g_quickload = nullptr; + + int const UserMap = G_HaveUserMap(); + + // we don't want the intro to play after the multiplayer setup screen + if ((!g_netServer && ud.multimode < 2) && UserMap == 0 && + VM_OnEventWithReturn(EVENT_NEWGAMESCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 0 && + levelNum == 0 && volumeNum == 3 && ud.lockout == 0 && (G_GetLogoFlags() & LOGO_NOE4CUTSCENE)==0) { S_PlayMusic(g_mapInfo[MUS_BRIEFING].musicfn); @@ -1405,20 +1430,6 @@ end_vol4a: FX_StopAllSounds(); } - g_showShareware = GAMETICSPERSEC*34; - - ud.level_number = levelNum; - ud.volume_number = volumeNum; - ud.player_skill = skillNum; - ud.secretlevel = 0; - ud.from_bonus = 0; - - ud.last_level = -1; - g_lastAutoSaveArbitraryID = -1; - g_lastautosave.reset(); - g_lastusersave.reset(); - g_quickload = nullptr; - #ifdef EDUKE32_TOUCH_DEVICES pPlayer->zoom = 360; #else @@ -1779,11 +1790,6 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum realloc_copy(&g_mapInfo[levelNum].musicfn, "dethtoll.mid"); } -static inline int G_HaveUserMap(void) -{ - return (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0); -} - int G_EnterLevel(int gameMode) { int32_t i, mii; diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 00b6bc058..977fd11cc 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -1470,7 +1470,9 @@ void G_DisplayLogo(void) S_StopMusic(); FX_StopAllSounds(); // JBF 20031228 S_ClearSoundLocks(); // JBF 20031228 - if ((!g_netServer && ud.multimode < 2) && (logoflags & LOGO_ENABLED) && !g_noLogo) + if (!g_noLogo /* && (!g_netServer && ud.multimode < 2) */ && + VM_OnEventWithReturn(EVENT_MAINMENUSCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 0 && + (logoflags & LOGO_ENABLED)) { if ( #ifndef EDUKE32_TOUCH_DEVICES