Skip to content

Commit 2f2d573

Browse files
committed
Added pragma regions to shrink down the amount of code present
1 parent f5b314b commit 2f2d573

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

p2mm.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ bool CP2MMServerPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateInt
169169
if (!this->m_hWnd)
170170
Log(WARNING, false, "Failed to find game window!");
171171

172+
// MARK: Determine Current Game
173+
#pragma region Determine Current Game
172174
// Determine which Portal 2 branch game we are running and if its supported.
173175
// TODO: Rework this to be a switch case then if and else if statements.
174176
bool unsupportedGame = false;
@@ -235,11 +237,14 @@ bool CP2MMServerPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateInt
235237
MessageBox(this->m_hWnd, "P2:MM is being run with a unsupported Source Engine/Portal 2 branch game!\n\"-forcep2mmload\" has been specified to stop the plugin shutting down the game.\nProceed with caution as crashes and bugs could occur!", "Unsupported P2:MM Game", MB_OK | MB_ICONEXCLAMATION);
236238
Log(WARNING, false, R"(P2:MM is being run with a unsupported Source Engine/Portal 2 branch game! "-forcep2mmload" has been specified to stop the plugin shutting down the game. Proceed with caution as crashes and bugs could occur!)");
237239
}
240+
#pragma endregion
238241

239242
Log(INFO, true, "Connecting tier libraries...");
240243
ConnectTier1Libraries(&interfaceFactory, 1);
241244
ConnectTier2Libraries(&interfaceFactory, 1);
242245

246+
// MARK: Engine Interfaces
247+
#pragma region Engine Interfaces
243248
// Make sure that all the interfaces needed are loaded and usable.
244249
Log(INFO, true, "Loading interfaces...");
245250
Log(INFO, true, "Loading engineServer...");
@@ -321,6 +326,7 @@ bool CP2MMServerPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateInt
321326
this->m_bNoUnload = true;
322327
return false;
323328
}
329+
#pragma endregion
324330

325331
MathLib_Init(2.2f, 2.2f, 0.0f, 2.0f);
326332
ConVar_Register(0);
@@ -364,6 +370,8 @@ bool CP2MMServerPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateInt
364370
CommandLine()->AppendParm("-allowspectators", "");
365371
}
366372

373+
// MARK: Patches and Hooks
374+
#pragma region Patches and Hooks
367375
// big ol' try catch because game has a TerminateProcess handler for exceptions...
368376
// why this wasn't here is mystifying, - 10/2024 NULLderef
369377
try
@@ -486,7 +494,8 @@ bool CP2MMServerPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateInt
486494
this->m_bNoUnload = true;
487495
return false;
488496
}
489-
497+
#pragma endregion
498+
490499
CDiscordIntegration::UpdateDiscordRPC();
491500

492501
Log(INFO, false, "Loaded plugin! Yay! :D");
@@ -536,6 +545,8 @@ void CP2MMServerPlugin::Unload(void)
536545
DisconnectTier2Libraries();
537546
DisconnectTier1Libraries();
538547

548+
// MARK: Patches and Hooks
549+
#pragma region Patches and Hooks
539550
try
540551
{
541552
// Undo byte patches
@@ -581,6 +592,7 @@ void CP2MMServerPlugin::Unload(void)
581592
Log(WARNING, false, R"(Encountered error when unload plugin! :( Exception: "%s")", ex.what());
582593
Log(ERRORR, false, "P2:MM failed to unload!\nGame has to be shutdown as possibly some other patches/hooks are still connected which can cause issues!");
583594
}
595+
#pragma endregion
584596

585597
if (p2mm_discord_rpc.GetBool() && CDiscordIntegration::DiscordRPCRunning())
586598
CDiscordIntegration::ShutdownDiscordRPC();

0 commit comments

Comments
 (0)