forked from stuart73/Onslaught
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPCGame.cpp
More file actions
301 lines (249 loc) · 8.65 KB
/
Copy pathPCGame.cpp
File metadata and controls
301 lines (249 loc) · 8.65 KB
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
#include "Common.h"
#if TARGET == PC
//#include "DX.h"
#include "Game.h"
#include "Camera.h"
#include "Engine.h"
#include "Profile.h"
#include "Map.h"
#include "EventManager.h"
#include "SoundManager.h"
#include "debuglog.h"
#include "console.h"
#include "debris.h"
#include "wall.h"
#include "scheduledevent.h"
#include "DebugText.h"
#include "music.h"
#include "spriterenderer.h"
#include "renderinfo.h"
#include "Player.h"
#include "World.h"
//*******************************************************************************
CPCGame GAME;
//*******************************************************************************
void CPCGame::DrawGameStuff()
{
//*****************************************************
//** Screen Grab?
static BOOL grabbing = FALSE;
if(PLATFORM.KeyOnce(VK_F8))
grabbing = !grabbing;
if(grabbing)
{
static int frameno=0;
if(frameno==0) CreateDirectory(ToTCHAR("grabs"),NULL);
// Skip existing files
bool framenumok=false;
while (!framenumok)
{
char name[32];
sprintf(name,"grabs\\scr%.4d.tga",frameno);
FILE *f=fopen(name,"r");
if (f)
{
fclose(f);
frameno++;
}
else
framenumok=TRUE;
}
LT.DumpScreen(frameno++);
}
//*****************************************************
//** Assorted Debug stuff
DBT.Out("World %d, Time = %2.2f, Event list size = %d(%d) (proc last frame=%d), Num Things = %d, ",GetCurrentLevel(), EVENT_MANAGER.GetTime(), EVENT_MANAGER.TotalEvents(), CScheduledEvent::GetNumCreated(), EVENT_MANAGER.GetNumEventsProcessedInLastUpdate(), WORLD.GetThingNB().Size());
if (mFixedFrameRate)
{
DBT.Out(", (fixed rate gc) %2.2f FPS ", PLATFORM.GetFPS());
}
else
{
DBT.Out(" %2.2f FPS ", PLATFORM.GetFPS());
}
CPlayer* p = GetPlayer(0) ;
if (p)
{
if (p->IsGod())
{
DBT.Out("\nGOD mode Score = %0d", mScore);
}
else
{
CBattleEngine* player_unit = p->GetBattleEngine() ;
{
if(player_unit)
{
DBT.Out("\n Health = %2.2f Energy = %2.2f Score = %0d", player_unit->GetLife() , player_unit->GetEnergy(), mScore);
if (player_unit->IsAugActive())
DBT.Out("\n Aug Bar = %2.2f Aug Active", player_unit->GetAugValue());
else
DBT.Out("\n Aug Bar = %2.2f", player_unit->GetAugValue());
}
}
}
}
PLATFORM.Font( FONT_DEBUG )->DrawText( 0, 0, 0xffffff80, ToWCHAR(DBT.GetPtrAndReset()), 0L );
DBT.GetPtrAndReset();
LOG.Render();
//!JCL-MAP
/* if (!(MAP.GetGenerator()->AreShadowsValid()))
{
PLATFORM.DrawDebugText( 451, 461, 0xff000000, "Shadows out of date.", 0L );
PLATFORM.DrawDebugText( 450, 460, 0xff7f7f7f, "Shadows out of date.", 0L );
}*/
// more hacks
if ((mGameState==GAME_STATE_LEVEL_LOST) || (mGameState==GAME_STATE_LEVEL_WON))
{
mWinLoseScreenAlpha+=16;
if (mWinLoseScreenAlpha>0xA0)
mWinLoseScreenAlpha=0xA0;
DWORD alpha=mWinLoseScreenAlpha<<24;
RENDERINFO.SetFogEnabled(false);
if (mGameState==GAME_STATE_LEVEL_WON)
CSPRITERENDERER::DrawColouredSprite(0,0,0.001f,mWinScreen,alpha | 0x00FFFFFF,(640.0f/1024.0f),(480.0f/512.0f));
else
CSPRITERENDERER::DrawColouredSprite(0,0,0.001f,mLoseScreen,alpha | 0x00FFFFFF,(640.0f/1024.0f),(480.0f/512.0f));
int x,y;
char buffer[256];
x=100;
y=100;
CPlayer *p=GetPlayer(0);
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FFFFFF,ToWCHAR("Total mission time :"));
sprintf(buffer,"%.2fs",((float) p->GetStat(PS_TIMEASJET)+p->GetStat(PS_TIMEASWALKER))/20.0f);
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x+400,(float) y,alpha | 0x00FFFFFF,ToWCHAR(buffer));
y+=32;
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FFFFFF,ToWCHAR("Time in jet mode :"));
sprintf(buffer,"%.2fs",((float) p->GetStat(PS_TIMEASJET))/20.0f);
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x+400,(float) y,alpha | 0x00FFFFFF,ToWCHAR(buffer));
y+=32;
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FFFFFF,ToWCHAR("Time in walker mode :"));
sprintf(buffer,"%.2fs",((float) p->GetStat(PS_TIMEASWALKER))/20.0f);
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x+400,(float) y,alpha | 0x00FFFFFF,ToWCHAR(buffer));
y+=32;
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FFFFFF,ToWCHAR("Rounds fired :"));
sprintf(buffer,"%d",p->GetStat(PS_ROUNDSFIRED));
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x+400,(float) y,alpha | 0x00FFFFFF,ToWCHAR(buffer));
y+=32;
if (p->GetStat(PS_ROUNDSFIRED)>0)
{
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FFFFFF,ToWCHAR("Accuracy :"));
sprintf(buffer,"%.2f%%",((float) p->GetStat(PS_ROUNDSHIT)*100.0f) / ((float) p->GetStat(PS_ROUNDSFIRED)));
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x+400,(float) y,alpha | 0x00FFFFFF,ToWCHAR(buffer));
y+=32;
}
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FFFFFF,ToWCHAR("Damage taken :"));
sprintf(buffer,"%.2f",((float) p->GetStat(PS_DAMAGETAKEN)) / 256.0f);
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x+400,(float) y,alpha | 0x00FFFFFF,ToWCHAR(buffer));
y+=32;
if (p->GetStat(PS_CHEATED)>0)
{
PLATFORM.Font( FONT_NORMAL )->DrawText((float) x,(float) y,alpha | 0x00FF0000,ToWCHAR("CHEATER!"));
y+=32;
}
RENDERINFO.SetFogEnabled(true);
}
// DBT.Out("\nFract=%f - time=%f, basetime=%f, emt=%f\n",GetFrameRenderFraction(),mFrameTime,mBaseTime,EVENT_MANAGER.GetTime());
}
void CPCGame::DumpTimeRecords()
{
#ifdef DEBUG_TIMERECORDS
FILE *f=fopen("c:\\timerec.txt","wt");
int r=mCurrentTR;
int oldr=mCurrentTR;
char buffer[1024],tbuf[1024];
sprintf(buffer,"Base time\tStart offset\tTime taken\tRenders\tRender 1f\tRender 2f\tRender 3f\tRender 4f\tFrame length\tFPS rate\tStatus\n");
fwrite(buffer,strlen(buffer),1,f);
for (int i=0;i<TIMERECORDS;i++)
{
sprintf(buffer,"%f\t%f\t%f\t%d\t",
mTimeRecord[r].basetime,
mTimeRecord[r].starttimeoffset,mTimeRecord[r].timetaken,
mTimeRecord[r].renders);
if (mTimeRecord[r].renders>0)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[0]+(1-mTimeRecord[oldr].renderfraction[mTimeRecord[oldr].renders-1]));
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
if (mTimeRecord[r].renders>1)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[1]-mTimeRecord[r].renderfraction[0]);
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
if (mTimeRecord[r].renders>2)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[2]-mTimeRecord[r].renderfraction[1]);
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
if (mTimeRecord[r].renders>3)
sprintf(tbuf,"%f\t",mTimeRecord[r].renderfraction[3]-mTimeRecord[r].renderfraction[2]);
else
sprintf(tbuf,"-\t\t");
strcat(buffer,tbuf);
sprintf(tbuf,"%f\t%f\t%s\n",
mTimeRecord[r].framelength,
mTimeRecord[r].fps,mTimeRecord[r].status);
strcat(buffer,tbuf);
fwrite(buffer,strlen(buffer),1,f);
oldr=r;
r++;
if (r>=TIMERECORDS)
r=0;
}
fclose(f);
f=fopen("c:\\renderrec.txt","wt");
r=mCurrentRR;
oldr=mCurrentRR;
sprintf(buffer,"End time\tEnd time delta\tTime taken\tFrame code\tRender number\tDelta ratio\tIdeal DR\n");
fwrite(buffer,strlen(buffer),1,f);
for (i=0;i<TIMERECORDS;i++)
{
sprintf(buffer,"%f\t%f\t%f\t%f\t%d\t%f\t%f\n",
mRenderRecord[r].renderendtime,
mRenderRecord[r].renderendtime-mRenderRecord[oldr].renderendtime,
mRenderRecord[r].renderlength,
mRenderRecord[r].renderframetime,
mRenderRecord[r].rendernumber,
(mRenderRecord[r].renderendtime-mRenderRecord[oldr].renderendtime)/(mRenderRecord[r].renderframetime-mRenderRecord[oldr].renderframetime),
(mRenderRecord[r].renderstarttime-mRenderRecord[oldr].renderstarttime)/(mRenderRecord[r].renderframetime-mRenderRecord[oldr].renderframetime));
fwrite(buffer,strlen(buffer),1,f);
oldr=r;
r++;
if (r>=TIMERECORDS)
r=0;
}
fclose(f);
#endif
}
void CPCGame::AddTimeStatus(char *s)
{
#ifdef DEBUG_TIMERECORDS
if ((strlen(mTimeRecord[mCurrentTR].status)+strlen(s))<255)
{
strcat(mTimeRecord[mCurrentTR].status,s);
strcat(mTimeRecord[mCurrentTR].status," ");
}
else
{
if (strlen(mTimeRecord[mCurrentTR].status)<250)
strcat(mTimeRecord[mCurrentTR].status,"...");
}
#endif
}
//*******************************************************************************
/*
if (mFixedFrameRate)
{
float time = (float)timeGetTime() * 0.001f;
if (time - mLastUpdateTime > MAX_UPDATE_TIME)
{
mLastUpdateTime = time ;
GAME.Update() ;
}
}
else
{
GAME.Update() ;
}
*/
#endif