forked from yasumitsu/ja2-1.13-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamescreen.cpp
1227 lines (953 loc) · 29.5 KB
/
gamescreen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef PRECOMPILEDHEADERS
#include "JA2 All.h"
#include "HelpScreen.h"
#include "PreBattle Interface.h"
#else
#include "builddefines.h"
#include <stdio.h>
#include <time.h>
#include "sgp.h"
#include "gameloop.h"
#include "vobject.h"
#include "worlddef.h"
#include "renderworld.h"
#include "font.h"
#include "screenids.h"
#include "screens.h"
#include "overhead.h"
#include "Isometric Utils.h"
#include "sysutil.h"
#include "input.h"
#include "Event Pump.h"
#include "Font Control.h"
#include "Timer Control.h"
#include "Radar Screen.h"
#include "Render Dirty.h"
#include "Interface.h"
#include "Handle UI.h"
#include <wchar.h>
#include <tchar.h>
#include "cursors.h"
#include "vobject_blitters.h"
#include "Button System.h"
#include "lighting.h"
#include "renderworld.h"
#include "sys globals.h"
#include "environment.h"
#include "bullets.h"
#include "Assignments.h"
#include "message.h"
#include <string.h>
#include "overhead map.h"
#include "Strategic Exit GUI.h"
#include "strategic movement.h"
#include "Tactical Placement GUI.h"
#include "Air raid.h"
#include "Game Clock.h"
#include "game init.h"
//DEF: Test Code
#ifdef NETWORKED
#include "Networking.h"
#endif
#include "interface control.h"
#include "game clock.h"
#include "physics.h"
#include "fade screen.h"
#include "dialogue control.h"
#include "soldier macros.h"
#include "faces.h"
#include "strategicmap.h"
#include "gamescreen.h"
#include "interface.h"
#include "cursor control.h"
#include "strategic turns.h"
#include "merc entering.h"
#include "soldier create.h"
#include "Soldier Init List.h"
#include "interface panels.h"
#include "Map Information.h"
#include "environment.h"
#include "Squads.h"
#include "interface dialogue.h"
#include "auto bandage.h"
#include "meanwhile.h"
#include "strategic ai.h"
#include "HelpScreen.h"
#include "PreBattle Interface.h"
#include "Sound Control.h"
#include "MessageBoxScreen.h"
#include "Text.h"
#include "GameSettings.h"
#include "Random.h"
#include "editscreen.h"
#include "Scheduling.h"
#include "Animated ProgressBar.h"
#endif
#include "connect.h"
#ifdef JA2UB
#include "Ja25_Tactical.h"
#include "Ja25 Strategic Ai.h"
#include "ub_config.h"
#endif
#define ARE_IN_FADE_IN( ) ( gfFadeIn || gfFadeInitialized )
BOOLEAN fDirtyRectangleMode = FALSE;
UINT16 *gpFPSBuffer=NULL;
// MarkNote
// extern ScrollStringStPtr pStringS=NULL;
UINT32 counter=0;
UINT32 count=0;
BOOLEAN gfTacticalDoHeliRun = FALSE;
BOOLEAN gfPlayAttnAfterMapLoad = FALSE;
// VIDEO OVERLAYS
INT32 giFPSOverlay = 0;
INT32 giCounterPeriodOverlay = 0;
BOOLEAN gfExitToNewSector = FALSE;
//UINT8 gubNewSectorExitDirection;
BOOLEAN gfGameScreenLocateToSoldier = FALSE;
BOOLEAN gfEnteringMapScreen = FALSE;
UINT32 uiOldMouseCursor;
UINT8 gubPreferredInitialSelectedGuy = NOBODY;
BOOLEAN gfTacticalIsModal = FALSE;
MOUSE_REGION gTacticalDisableRegion;
BOOLEAN gfTacticalDisableRegionActive = FALSE;
INT8 gbTacticalDisableMode = FALSE;
MODAL_HOOK gModalDoneCallback;
BOOLEAN gfBeginEndTurn = FALSE;
extern BOOLEAN gfTopMessageDirty;
extern BOOLEAN gfFailedToSaveGameWhenInsideAMessageBox;
extern BOOLEAN gfFirstHeliRun;
extern BOOLEAN gfRenderFullThisFrame;
#ifdef JA2UB
extern void HandleCannotAffordNpcMsgBox();
extern BOOLEAN gfDisplayMsgBoxSayingCantAffordNPC;
#endif
// The InitializeGame function is responsible for setting up all data and Gaming Engine
// tasks which will run the game
RENDER_HOOK gRenderOverride = NULL;
#define NOINPUT_DELAY 60000
#define DEMOPLAY_DELAY 40000
#define RESTART_DELAY 6000
void TacticalScreenLocateToSoldier( );
UINT32 guiTacticalLeaveScreenID;
BOOLEAN guiTacticalLeaveScreen = FALSE;
void HandleModalTactical( );
extern void CheckForDisabledRegionRemove( );
extern void InternalLocateGridNo( INT32 sGridNo, BOOLEAN fForce );
UINT32 MainGameScreenInit(void)
{
VIDEO_OVERLAY_DESC VideoOverlayDesc;
UINT32 uiDestPitchBYTES;
UINT8 *pDestBuf=NULL;
/* If any 1 have time please calculate how big this buffer should be
* any questions? joker
*/
pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES );
gpZBuffer=InitZBuffer( uiDestPitchBYTES, SCREEN_HEIGHT);
UnLockVideoSurface( FRAME_BUFFER);
InitializeBackgroundRects();
//EnvSetTimeInHours(ENV_TIME_12);
SetRenderFlags(RENDER_FLAG_FULL);
// WDS - bug fix: VideoOverlayDesc must be initialized! - 07/16/2007
memset( &VideoOverlayDesc, 0, sizeof( VIDEO_OVERLAY_DESC ) );
// Init Video Overlays
// FIRST, FRAMERATE
VideoOverlayDesc.sLeft = 0;
VideoOverlayDesc.sTop = 0;
VideoOverlayDesc.uiFontID = SMALLFONT1;
VideoOverlayDesc.ubFontBack = FONT_MCOLOR_BLACK ;
VideoOverlayDesc.ubFontFore = FONT_MCOLOR_DKGRAY ;
VideoOverlayDesc.sX = VideoOverlayDesc.sLeft;
VideoOverlayDesc.sY = VideoOverlayDesc.sTop;
swprintf( VideoOverlayDesc.pzText, L"90" );
VideoOverlayDesc.BltCallback = BlitMFont;
giFPSOverlay = RegisterVideoOverlay( ( VOVERLAY_STARTDISABLED | VOVERLAY_DIRTYBYTEXT ), &VideoOverlayDesc );
// SECOND, PERIOD COUNTER
VideoOverlayDesc.sLeft = 30;
VideoOverlayDesc.sTop = 0;
VideoOverlayDesc.sX = VideoOverlayDesc.sLeft;
VideoOverlayDesc.sY = VideoOverlayDesc.sTop;
swprintf( VideoOverlayDesc.pzText, L"Levelnodes: 100000" );
VideoOverlayDesc.BltCallback = BlitMFont;
giCounterPeriodOverlay = RegisterVideoOverlay( ( VOVERLAY_STARTDISABLED | VOVERLAY_DIRTYBYTEXT ), &VideoOverlayDesc );
// register debug topics
// RegisterJA2DebugTopic( TOPIC_JA2, "Reg JA2 Debug" );
return TRUE;
}
// The ShutdownGame function will free up/undo all things that were started in InitializeGame()
// It will also be responsible to making sure that all Gaming Engine tasks exit properly
UINT32 MainGameScreenShutdown(void)
{
ShutdownZBuffer(gpZBuffer);
ShutdownBackgroundRects();
// Remove video Overlays
RemoveVideoOverlay( giFPSOverlay );
// WANNE: Plug a vanilla one-time memory leak.
// Fixed by Tron (Stracciatella): Revision: 6933
RemoveVideoOverlay( giCounterPeriodOverlay );
return TRUE;
}
void FadeInGameScreen( )
{
fFirstTimeInGameScreen = TRUE;
FadeInNextFrame( );
}
void FadeOutGameScreen( )
{
FadeOutNextFrame( );
}
void EnterTacticalScreen( )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen"));
guiTacticalLeaveScreen = FALSE;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: setpositionsndsactive"));
SetPositionSndsActive( );
// Set pending screen
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: setpendingnewscreen"));
SetPendingNewScreen( GAME_SCREEN );
// Set as active...
gTacticalStatus.uiFlags |= ACTIVE;
fInterfacePanelDirty = DIRTYLEVEL2;
//Disable all faces
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: setallautofacesinactive"));
SetAllAutoFacesInactive( );
// CHECK IF OURGUY IS NOW OFF DUTY
if ( gusSelectedSoldier != NOBODY )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: check our guy"));
if ( !OK_CONTROLLABLE_MERC( MercPtrs[ gusSelectedSoldier ] ) )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: SelectNextAvailSoldier, merc not controllable"));
SelectNextAvailSoldier( MercPtrs[ gusSelectedSoldier ] );
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: who is selected? %d", gusSelectedSoldier));
// ATE: If the current guy is sleeping, change....
if ( gusSelectedSoldier != NOBODY && MercPtrs[ gusSelectedSoldier ]->flags.fMercAsleep )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: SelectNextAvailSoldier, merc asleep"));
SelectNextAvailSoldier( MercPtrs[ gusSelectedSoldier ] );
}
}
else
{
// otherwise, make sure interface is team panel...
SetCurrentInterfacePanel( (UINT8)TEAM_PANEL );
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen:enable viewport region"));
if( !gfTacticalPlacementGUIActive )
{
MSYS_EnableRegion(&gRadarRegion);
}
MSYS_EnableRegion( &gViewportRegion );
// set default squad on sector entry
// ATE: moved these 2 call after initalizing the interface!
//SetDefaultSquadOnSectorEntry( FALSE );
//ExamineCurrentSquadLights( );
//UpdateMercsInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ );
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: Init Interface"));
// Init interface ( ALWAYS TO TEAM PANEL. DEF changed it to go back to the previous panel )
if( !gfTacticalPlacementGUIActive )
{
//make sure the gsCurInterfacePanel is valid
if( gsCurInterfacePanel < 0 || gsCurInterfacePanel >= NUM_UI_PANELS )
gsCurInterfacePanel = TEAM_PANEL;
SetCurrentInterfacePanel( (UINT8)gsCurInterfacePanel );
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: settacticalinterfaceflags"));
SetTacticalInterfaceFlags( 0 );
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: fix oversized squads"));
//SQUAD10: Check for squads that are oversized at current resolution and move them to another squad
FixOversizedSquadsInSector( );
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: set default squad on sector entry"));
// set default squad on sector entry
SetDefaultSquadOnSectorEntry( FALSE );
ExamineCurrentSquadLights( );
fFirstTimeInGameScreen = FALSE;
// Make sure it gets re-created....
DirtyTopMessage( );
// Set compression to normal!
//SetGameTimeCompressionLevel( TIME_COMPRESS_X1 );
// Select current guy...
//gfGameScreenLocateToSoldier = TRUE;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: check meanwhile"));
#ifdef JA2UB
/* Ja25 No meanwhiles */
#else
// Locate if in meanwhile...
if ( AreInMeanwhile( ) )
{
LocateToMeanwhileCharacter( );
}
#endif
if ( gTacticalStatus.uiFlags & IN_DEIDRANNA_ENDGAME )
{
InternalLocateGridNo( 4561, TRUE );
}
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: clear messages"));
// Clear tactical message q
ClearTacticalMessageQueue( );
// ATE: Enable messages again...
EnableScrollMessages( );
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("EnterTacticalScreen: done"));
}
void LeaveTacticalScreen( UINT32 uiNewScreen )
{
guiTacticalLeaveScreenID = uiNewScreen;
guiTacticalLeaveScreen = TRUE;
}
void InternalLeaveTacticalScreen( UINT32 uiNewScreen )
{
gpCustomizableTimerCallback = NULL;
// unload the sector they teleported out of
if ( !gfAutomaticallyStartAutoResolve )
{
CheckAndHandleUnloadingOfCurrentWorld();
}
SetPositionSndsInActive( );
// Turn off active flag
gTacticalStatus.uiFlags &= ( ~ACTIVE );
fFirstTimeInGameScreen = TRUE;
SetPendingNewScreen( uiNewScreen );
//Disable all faces
SetAllAutoFacesInactive( );
ResetInterfaceAndUI( );
// Remove cursor and reset height....
gsGlobalCursorYOffset = 0;
SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR );
// Shutdown panel
ShutdownCurrentPanel( );
//disable the radar map
MSYS_DisableRegion(&gRadarRegion);
//MSYS_DisableRegion( &gViewportRegion );
// We are leaving... turn off pedning autobadage...
SetAutoBandagePending( FALSE );
// ATE: Disable messages....
DisableScrollMessages( );
if ( uiNewScreen == MAINMENU_SCREEN )
{
//We want to reinitialize the game
ReStartingGame();
}
if ( uiNewScreen != MAP_SCREEN )
{
StopAnyCurrentlyTalkingSpeech( );
}
// If we have some disabled screens up.....remove...
CheckForDisabledRegionRemove( );
// ATE: Record last time we were in tactical....
gTacticalStatus.uiTimeSinceLastInTactical = GetWorldTotalMin( );
FinishAnySkullPanelAnimations( );
}
extern INT32 iInterfaceDialogueBox;
#ifdef JA2BETAVERSION
extern BOOLEAN ValidateSoldierInitLinks( UINT8 ubCode );
extern BOOLEAN gfDoDialogOnceGameScreenFadesIn;
#endif
UINT32 MainGameScreenHandle(void)
{
UINT32 uiNewScreen = GAME_SCREEN;
//DO NOT MOVE THIS FUNCTION CALL!!!
//This determines if the help screen should be active
// if( ( !gfTacticalDoHeliRun && !gfFirstHeliRun ) && ShouldTheHelpScreenComeUp( HELP_SCREEN_TACTICAL, FALSE ) )
// WANNE: Never show the helpscreen when leaving editor and going to the tactical game
#ifndef JA2EDITOR
if( !gfPreBattleInterfaceActive && ShouldTheHelpScreenComeUp( HELP_SCREEN_TACTICAL, FALSE ) )
{
// handle the help screen
HelpScreenHandler();
return( GAME_SCREEN );
}
#endif
#ifdef JA2BETAVERSION
DebugValidateSoldierData( );
#endif
if ( HandleAutoBandage( ) )
{
#ifndef VISIBLE_AUTO_BANDAGE
return( GAME_SCREEN );
#endif
}
#ifdef JA2UB
//jA25 UB
//Handle the strategic AI
JA25_HandleUpdateOfStrategicAi();
#endif
#if 0
{
PTR pData, pDestBuf;
UINT32 uiPitch, uiDestPitchBYTES;
pData = LockMouseBuffer( &uiPitch );
pDestBuf = LockVideoSurface(guiRENDERBUFFER, &uiDestPitchBYTES);
Blt16BPPTo16BPP((UINT16 *)pDestBuf, uiDestPitchBYTES,
(UINT16 *)pData, uiPitch,
0 , 0,
0 , 0,
64, 64 );
UnlockMouseBuffer( );
UnLockVideoSurface(guiRENDERBUFFER);
InvalidateRegion( 0, 0, 64, 64 );
//mprintf( 0, 55, L"W: %dH: %d", gsCurMouseWidth, gsCurMouseHeight );
}
#endif
if ( gfBeginEndTurn )
{
UIHandleEndTurn( NULL );
gfBeginEndTurn = FALSE;
}
/*
if ( gfExitToNewSector )
{
// Shade screen one frame
if ( gfExitToNewSector == 1 )
{
// Disable any saved regions!
EmptyBackgroundRects( );
// Remove cursor
uiOldMouseCursor = gViewportRegion.Cursor;
SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR );
//Shadow area
ShadowVideoSurfaceRect( FRAME_BUFFER, 0, 0, 640, 480 );
InvalidateScreen( );
// Next frame please
gfExitToNewSector++;
return( GAME_SCREEN );
}
else
{
// Go into sector
JumpIntoAdjacentSector( gubNewSectorExitDirection );
gfExitToNewSector = FALSE;
// Restore mouse
SetCurrentCursorFromDatabase( uiOldMouseCursor );
}
}
*/
// The gfFailedToSaveGameWhenInsideAMessageBox flag will only be set at this point if the game fails to save during
// a quick save and when the game was already in a message box.
//If the game failed to save when in a message box, pop up a message box stating an error occured
if( gfFailedToSaveGameWhenInsideAMessageBox )
{
gfFailedToSaveGameWhenInsideAMessageBox = FALSE;
DoMessageBox( MSG_BOX_BASIC_STYLE, zSaveLoadText[SLG_SAVE_GAME_ERROR], GAME_SCREEN, MSG_BOX_FLAG_OK, NULL, NULL );
return( GAME_SCREEN );
}
// Check if we are in bar animation...
if ( InTopMessageBarAnimation( ) )
{
ExecuteBaseDirtyRectQueue( );
EndFrameBufferRender( );
return( GAME_SCREEN );
}
if ( gfTacticalIsModal )
{
if ( gfTacticalIsModal == 1 )
{
gfTacticalIsModal++;
}
else
{
HandleModalTactical( );
return( GAME_SCREEN );
}
}
// OK, this is the pause system for when we see a guy...
if ( !ARE_IN_FADE_IN( ) )
{
if ( gTacticalStatus.fEnemySightingOnTheirTurn )
{
if ( (( GetJA2Clock( ) - gTacticalStatus.uiTimeSinceDemoOn ) > 3000) || is_client)//unpause straight away if in MP
{
if ( gTacticalStatus.ubCurrentTeam != gbPlayerNum )
{
MercPtrs[ gTacticalStatus.ubEnemySightingOnTheirTurnEnemyID ]->AdjustNoAPToFinishMove( FALSE );
}
MercPtrs[ gTacticalStatus.ubEnemySightingOnTheirTurnEnemyID ]->flags.fPauseAllAnimation = FALSE;
gTacticalStatus.fEnemySightingOnTheirTurn = FALSE;
}
}
}
// see if the helicopter is coming in this time for the initial entrance by the mercs
InitHelicopterEntranceByMercs( );
// Handle Environment controller here
EnvironmentController( TRUE );
if ( !ARE_IN_FADE_IN( ) )
{
HandleWaitTimerForNPCTrigger( );
// Check timer that could have been set to do anything
CheckCustomizableTimer();
// Handle physics engine
SimulateWorld( );
// Handle strategic engine
HandleStrategicTurn( );
}
if ( gfTacticalDoHeliRun )
{
gfGameScreenLocateToSoldier = FALSE;
#ifdef JA2UB
//if it is the first time in the game, and we are doing the heli crash code, locate to a different spot
if( gfFirstTimeInGameHeliCrash && gGameUBOptions.InGameHeli == FALSE )
{
InternalLocateGridNo( gGameUBOptions.LOCATEGRIDNO, TRUE ); // 15427
}
else
{
if ( gGameUBOptions.InGameHeliCrash == TRUE )
//InternalLocateGridNo( gMapInformation.sNorthGridNo, TRUE );
InternalLocateGridNo( gGameUBOptions.LOCATEGRIDNO, TRUE );
else
InternalLocateGridNo( gGameUBOptions.LOCATEGRIDNO, TRUE );
}
#else
InternalLocateGridNo( gGameExternalOptions.iInitialMercArrivalLocation, TRUE );
#endif
// Flugente: we might have reloaded the game, so we are currently not dropping mercs out of a helicopter
gfIngagedInDrop = FALSE;
// Start heli Run...
StartHelicopterRun();
// Update clock by one so that our DidGameJustStatrt() returns now false for things like LAPTOP, etc...
SetGameTimeCompressionLevel( TIME_COMPRESS_X1 );
//UpdateClock( 1 );
gfTacticalDoHeliRun = FALSE;
//SetMusicMode( MUSIC_TACTICAL_NOTHING );
}
if ( InOverheadMap( ) )
{
HandleOverheadMap( );
return( GAME_SCREEN );
}
#ifdef JA2UB
if ( !ARE_IN_FADE_IN( ) )
{
// HandleAirRaid( );
HandlePowerGenAlarm();
}
#endif
if ( gfGameScreenLocateToSoldier )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("maingamescreenhandle: tacticalscreenlocatetosoldier"));
TacticalScreenLocateToSoldier( );
gfGameScreenLocateToSoldier = FALSE;
}
if ( fFirstTimeInGameScreen )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("maingamescreenhandle: entertacticalscreen"));
EnterTacticalScreen( );
ShowLoadScreenHintInTacticalLog();
// Select a guy if he hasn;'
if( !gfTacticalPlacementGUIActive )
{
if ( gusSelectedSoldier != NOBODY && OK_INTERRUPT_MERC( MercPtrs[ gusSelectedSoldier ] ) )
{
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("maingamescreenhandle: selectsoldier"));
SelectSoldier( gusSelectedSoldier, FALSE, TRUE );
}
}
}
// ATE: check that this flag is not set.... display message if so
if ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN )
{
// Unset
guiTacticalInterfaceFlags &= (~INTERFACE_MAPSCREEN );
#ifdef JA2BETAVERSION
ScreenMsg( FONT_ORANGE, MSG_BETAVERSION, L"MAPSCREEN_INTERFACE flag set: Please remember how you entered Tactical." );
#endif
}
if ( HandleFadeOutCallback( ) )
{
return( GAME_SCREEN );
}
if ( guiCurrentScreen != MSG_BOX_SCREEN && guiCurrentScreen != MP_CHAT_SCREEN )
{
if ( HandleBeginFadeOut( GAME_SCREEN ) )
{
return( GAME_SCREEN );
}
}
#ifdef JA2UB
//if we are to display a mesg box about cant afford biggens
if( gfDisplayMsgBoxSayingCantAffordNPC )
{
HandleCannotAffordNpcMsgBox();
}
#endif
#ifdef JA2BETAVERSION
if( gfDoDialogOnceGameScreenFadesIn )
{
ValidateSoldierInitLinks( 4 );
}
#endif
HandleHeliDrop( );
if ( !ARE_IN_FADE_IN( ) )
{
HandleAutoBandagePending( );
#ifdef JA2UB
HandleThePlayerBeNotifiedOfSomeoneElseInSector();
#endif
}
// ATE: CHRIS_C LOOK HERE FOR GETTING AI CONSTANTLY GOING
//if ( gTacticalStatus.uiFlags & TURNBASED )
//{
// if ( !(gTacticalStatus.uiFlags & ENEMYS_TURN) )
// {
// EndTurn( );
// }
//}
// if ( gfScrollInertia == FALSE )
{
if ( !ARE_IN_FADE_IN( ) )
{
UpdateBullets( );
// Execute Tactical Overhead
ExecuteOverhead( );
}
// Handle animated cursors
if( gfWorldLoaded )
{
HandleAnimatedCursors( );
// Handle Interface
uiNewScreen = HandleTacticalUI( );
// called to handle things like face panels changeing due to team panel, squad changes, etc
// To be done AFTER HandleUI and before ExecuteOverlays( )
HandleDialogueUIAdjustments( );
HandleTalkingAutoFaces( );
}
#ifdef JA2EDITOR
else if( gfIntendOnEnteringEditor )
{
OutputDebugString( "Aborting normal game mode and entering editor mode...\n" );
SetPendingNewScreen( 0xffff ); //NO_SCREEN
return EDIT_SCREEN;
}
#endif
else if( !gfEnteringMapScreen )
{
gfEnteringMapScreen = TRUE;
}
if ( uiNewScreen != GAME_SCREEN )
{
return( uiNewScreen );
}
// Deque all game events
if ( !ARE_IN_FADE_IN( ) )
{
DequeAllGameEvents( TRUE );
}
}
/////////////////////////////////////////////////////
StartFrameBufferRender( );
HandleTopMessages( );
if ( gfScrollPending || gfScrollInertia )
{
}
else
{
// Handle Interface Stuff
SetUpInterface( );
HandleTacticalPanelSwitch( );
}
// Handle Scroll Of World
ScrollWorld( );
//SetRenderFlags( RENDER_FLAG_FULL );
RenderWorld( );
if ( gRenderOverride != NULL )
{
gRenderOverride( );
}
if ( gfScrollPending || gfScrollInertia )
{
RenderTacticalInterfaceWhileScrolling( );
}
else
{
// Handle Interface Stuff
//RenderTacticalInterface( );
}
#ifdef NETWORKED
// DEF: Test Code
PrintNetworkInfo();
#endif
// Render Interface
RenderTopmostTacticalInterface( );
#ifdef JA2TESTVERSION
if ( gTacticalStatus.uiFlags & ENGAGED_IN_CONV )
{
SetFont( MILITARYFONT1 );
SetFontBackground( FONT_MCOLOR_BLACK );
SetFontForeground( FONT_MCOLOR_LTGREEN );
mprintf( 0, 0, L"IN CONVERSATION %d", giNPCReferenceCount );
gprintfdirty( 0, 0, L"IN CONVERSATION %d", giNPCReferenceCount );
}
#ifdef JA2BETAVERSION
if ( GamePaused() == TRUE )
{
SetFont( MILITARYFONT1 );
SetFontBackground( FONT_MCOLOR_BLACK );
SetFontForeground( FONT_MCOLOR_LTGREEN );
mprintf( 0, 10, L"Game Clock Paused" );
gprintfdirty( 0, 10, L"Game Clock Paused" );
}
#endif
if ( gTacticalStatus.uiFlags & SHOW_ALL_MERCS )
{
INT32 iSchedules;
SCHEDULENODE *curr;
SetFont( MILITARYFONT1 );
SetFontBackground( FONT_MCOLOR_BLACK );
SetFontForeground( FONT_MCOLOR_LTGREEN );
mprintf( 0, 15, L"Attacker Busy Count: %d", gTacticalStatus.ubAttackBusyCount );
gprintfdirty( 0, 15, L"Attacker Busy Count: %d", gTacticalStatus.ubAttackBusyCount );
curr = gpScheduleList;
iSchedules = 0;
while( curr )
{
iSchedules++;
curr = curr->next;
}
mprintf( 0, 25, L"Schedules: %d", iSchedules );
gprintfdirty( 0, 25, L"Schedules: %d", iSchedules );
}
#endif
// Render view window
RenderRadarScreen( );
ResetInterface( );
if ( gfScrollPending )
{
DeleteVideoOverlaysArea( );
AllocateVideoOverlaysArea( );
SaveVideoOverlaysArea( FRAME_BUFFER );
ExecuteVideoOverlays( );
}
else
{
ExecuteVideoOverlays( );
}
// Adding/deleting of video overlays needs to be done below
// ExecuteVideoOverlays( )....
// Handle dialogue queue system
if ( !ARE_IN_FADE_IN( ) )
{
if ( gfPlayAttnAfterMapLoad )
{
gfPlayAttnAfterMapLoad = FALSE;
if ( gusSelectedSoldier != NOBODY )
{
if( !gGameSettings.fOptions[ TOPTION_MUTE_CONFIRMATIONS ] )
MercPtrs[ gusSelectedSoldier ]->DoMercBattleSound( BATTLE_SOUND_ATTN1 );
}
}
HandleDialogue( );
}
//Don't render if we have a scroll pending!
if ( !gfScrollPending && !gfScrollInertia && !gfRenderFullThisFrame )
{
RenderButtonsFastHelp( );
}
// Display Framerate
DisplayFrameRate( );
//UB
#ifdef JA2UB
/* JA2UB */
#else
CheckForMeanwhileOKStart( );
#endif
ScrollString( );
ExecuteBaseDirtyRectQueue( );
//KillBackgroundRects( );
/////////////////////////////////////////////////////
EndFrameBufferRender( );
if ( HandleFadeInCallback( ) )
{
// Re-render the scene!
SetRenderFlags( RENDER_FLAG_FULL );
fInterfacePanelDirty = DIRTYLEVEL2;
}
if ( HandleBeginFadeIn( GAME_SCREEN ) )
{
guiTacticalLeaveScreenID = FADE_SCREEN;
}
if ( guiTacticalLeaveScreen )
{
guiTacticalLeaveScreen = FALSE;
InternalLeaveTacticalScreen( guiTacticalLeaveScreenID );
}
// Check if we are to enter map screen
if ( gfEnteringMapScreen == 2 )
{
gfEnteringMapScreen = FALSE;
EnterMapScreen( );
}
// Are we entering map screen? if so, wait a frame!
if ( gfEnteringMapScreen > 0 )
{
gfEnteringMapScreen++;
}