summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-08-06 19:50:26 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:36 +0200
commit0770c95c17191b8945695eb5c27c11d279e3c1b9 (patch)
treeae08d9afa6e83bbeeb586b21bb9823f43e93cdc6 /src/main.c
parent12c6a39177837a5c4dc8928a78140b4c3bb8f47a (diff)
Moved TranslatePoint into a separate file.
Implemented most of the main loop in main.c. Game now seems to run OK. Need to write texture code and then add OpenGL.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c124
1 files changed, 122 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 1ab8cc5..26ecc90 100644
--- a/src/main.c
+++ b/src/main.c
@@ -12,6 +12,10 @@
#include "vision.h"
#include "comp_shp.h"
#include "avp_envinfo.h"
+#include "stratdef.h"
+#include "bh_types.h"
+#include "avp_userprofile.h"
+#include "pldnet.h"
#include "cdtrackselection.h"
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
@@ -38,6 +42,9 @@ int ExitWindowsSystem()
int main(int argc, char *argv[])
{
+ int menusActive = 0;
+ int thisLevelHasBeenCompleted = 0;
+
LoadCDTrackList();
SetFastRandom();
@@ -56,7 +63,7 @@ int main(int argc, char *argv[])
InitialVideoMode();
/* Env_List can probably be removed */
-// Env_List[0]->main = &(ELOLevelToLoad); /* overwrite the first entry of crappy env_list with LevelName */
+// Env_List[0] = &(ELOLevelToLoad); /* overwrite the first entry of crappy env_list with LevelName */
Env_List[0]->main = LevelName;
InitialiseSystem();
@@ -128,21 +135,134 @@ int main(int argc, char *argv[])
switch(AvP.GameMode) {
case I_GM_Playing:
+ if ((!menusActive || (AvP.Network!=I_No_Network && !netGameData.skirmishMode)) && !AvP.LevelCompleted) {
+ /* TODO: print some debugging stuff */
+
+ DoAllShapeAnimations();
+
+ UpdateGame();
+
+ AvpShowViews();
+
+ MaintainHUD();
+
+ CheckCDAndChooseTrackIfNeeded();
+
+ if(InGameMenusAreRunning() && ( (AvP.Network!=I_No_Network && netGameData.skirmishMode) || (AvP.Network==I_No_Network)) ) {
+ SoundSys_StopAll();
+ }
+ } else {
+ ReadUserInput();
+
+ /* UpdateAllFMVTextures(); NOT YET */
+
+ SoundSys_Management();
+
+ FlushD3DZBuffer();
+
+ ThisFramesRenderingHasBegun();
+ }
+
+/* NOT YET
+ menusActive = AvP_InGameMenus();
+ if (AvP.RestartLevel) menusActive=0;
+*/
+
+ if (AvP.LevelCompleted) {
+ SoundSys_FadeOutFast();
+ DoCompletedLevelStatisticsScreen();
+ thisLevelHasBeenCompleted = 1;
+ }
+
+ ThisFramesRenderingHasFinished();
+
+/* NOT YET
+ InGameFlipBuffers();
+*/
+
+ FrameCounterHandler();
+ {
+ PLAYER_STATUS *playerStatusPtr = (PLAYER_STATUS *) (Player->ObStrategyBlock->SBdataptr);
+
+ if (!menusActive && playerStatusPtr->IsAlive && !AvP.LevelCompleted) {
+ DealWithElapsedTime();
+ }
+ }
break;
+
case I_GM_Menus:
AvP.GameMode = I_GM_Playing;
break;
case I_GM_Paused:
- break;
+// break;
default:
fprintf(stderr, "AvP.MainLoopRunning: gamemode = %d\n", AvP.GameMode);
exit(EXIT_FAILURE);
}
+
+ if (AvP.RestartLevel) {
+ AvP.RestartLevel = 0;
+ AvP.LevelCompleted = 0;
+/* NOT YET
+ FixCheatModesInUserProfile(UserProfilePtr);
+*/
+ RestartLevel();
+ }
+
break; /* TODO -- remove when loop works */
}
+
+ AvP.LevelCompleted = thisLevelHasBeenCompleted;
+
+/* NOT YET
+ FixCheatModesInUserProfile(UserProfilePtr);
+*/
+
+/* NOT YET
+ CloseFMV();
+ ReleaseAllFMVTextures();
+*/
+
+ CONSBIND_WriteKeyBindingsToConfigFile();
+
+ DeInitialisePlayer();
+
+ DeallocatePlayersMirrorImage();
+
+ KillHUD();
+
+ Destroy_CurrentEnvironment();
+
+ DeallocateAllImages();
+
+ EndNPCs();
+
+ ExitGame();
+
+ SoundSys_StopAll();
+
+ SoundSys_ResetFadeLevel();
+
+ CDDA_Stop();
+
+ if (AvP.Network != I_No_Network) {
+/* NOT YET
+ EndAVPNetGame();
+*/
+ }
+
+ ClearMemoryPool();
// }
+ SoundSys_StopAll();
+ SoundSys_RemoveAll();
+
+ ExitSystem();
+
+ CDDA_End();
+ ClearMemoryPool();
+
fprintf(stderr, "Now exiting Aliens vs Predator! At least it didn't crash!\n");
return 0;