Skip to content

Commit f328121

Browse files
Replays POC (#492)
* Initial POC commit of replay code * Added more debug logs and update tick recording * Working version of replays. * Working version of demo replays. Still rare issues with long term replays. * Add replay POC * Temp muting logging for events * updating projet files * Updating Cmakelist * updating project and merging some files * Ignoring modcache * Merge of 1.15 code * More logging cleanup and simplifying code. * More merging of the 1.15 code. * Additional Merging * updating ui and filters * ensuring version is 141 instead of 143 * Removing sdl import * Removed unused dependencies * Removing unreachable code * Removing inused includes * Updating strcpy call * Don't open folder in linux * Remove stale replay logging * Fix up pathing for linux * Updating UI to support linux and change the mod checking behavior for dark fores assets. * Change functinoality of mod checker. * temp debug logging * Rewriting log * Fix for linux paths and sorting * Clean up some empty space - make it look nicer on linux. * Updating version - removing eye requirement in the events - adding recording/replay start messages. * Add logging toggle for replays * update linux offsets * Change playback counter * Adding append more for filestreaming. * fix log * never skip priority by default * Adding an option to run a replay via commandline. Also add parameter to show debug logs so you can add them to github action build to ensure there are no deltas * adding param to auto exit. * Adding latest editor changes from master. * Minor cleanup * Removing spurious log messages * Adding replay test mechanism * Ignore any replays * fixing tests workflow * Fix path * more debug * more workflow testing * More workflow debugging * More testing * workflow fix * more bug fixing * more workflow testing * more workflow test * add cmake Tests folder * testing * updating * more tests * top fix * test * log is ignored - changing to txt * Disable tests through actions. * Remove mousebot and turret number checking * Added testing --------- Co-authored-by: Karjala22 <78927981+Karjala22@users.noreply.github.com>
1 parent d2d6a35 commit f328121

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10376
-141
lines changed

.github/workflows/ubuntu-gcc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ jobs:
3333

3434
- name: Build
3535
# Build your program with the given configuration
36-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
36+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@
6161
.vs/
6262
Internal/
6363
TheForceEngine/Games/
64+
TheForceEngine/ModCache/
6465
TheForceEngine/Mods/
6566
TheForceEngine/screenshots/
6667
TheForceEngine/Reference/
68+
TheForceEngine/Replays/
6769
TheForceEngine/LawMaker/
6870
TheForceEngine/Backup/
6971
TheForceEngine/Exports/

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ if(ENABLE_TFE)
8585
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/UI_Images)
8686
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/UI_Text)
8787
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/EditorDef)
88+
execute_process(COMMAND ln -sf ${CMAKE_SOURCE_DIR}/TheForceEngine/Tests)
8889
include(CreateGitVersionH.cmake)
8990
create_git_version_h()
9091
endif()
@@ -137,6 +138,7 @@ if(ENABLE_TFE)
137138
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Shaders"
138139
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/SoundFonts"
139140
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Fonts"
141+
"${CMAKE_CURRENT_SOURCE_DIR}/TheForceEngine/Tests"
140142
DESTINATION "${CMAKE_INSTALL_DATADIR}"
141143
FILE_PERMISSIONS
142144
OWNER_READ OWNER_WRITE

TheForceEngine/TFE_DarkForces/Actor/mousebot.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ namespace TFE_DarkForces
148148
local(tick) = s_curTick;
149149
}
150150
else
151-
{
151+
{
152152
Tick dt = s_curTick - local(tick);
153153
// If enough time has past since the player was last spotted, go back to sleep.
154154
if (dt > 728) // ~5 seconds.
@@ -164,8 +164,8 @@ namespace TFE_DarkForces
164164
{
165165
local(odd) = (s_curTick & 1) ? JTRUE : JFALSE;
166166
angle14_32 deltaYaw = random(16338);
167-
local(moveMod)->target.yaw = local(odd) ? (local(obj)->yaw + deltaYaw) : (local(obj)->yaw - deltaYaw);
168-
167+
local(moveMod)->target.yaw = local(odd) ? (local(obj)->yaw + deltaYaw) : (local(obj)->yaw - deltaYaw);
168+
169169
local(moveMod)->target.speedRotation = random(0x3555) + 0x555;
170170
local(moveMod)->target.flags |= TARGET_MOVE_ROT;
171171
local(flip) = JFALSE;

TheForceEngine/TFE_DarkForces/GameUI/agentMenu.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,35 @@ namespace TFE_DarkForces
501501
menu_blitToScreen(s_framebuffer);
502502
}
503503

504+
void agentMenu_setAgentName(const char* name)
505+
{
506+
if (s_agentId < 0 || s_agentId >= MAX_AGENT_COUNT)
507+
{
508+
return;
509+
}
510+
strncpy(s_agentData[s_agentId].name, name, 32);
511+
}
512+
513+
s32 agentMenu_getAgentID()
514+
{
515+
return s_agentId;
516+
}
517+
518+
void agentMenu_setAgentId(s32 id)
519+
{
520+
s_agentId = id;
521+
}
522+
523+
void agentMenu_setAgentCount(s32 count)
524+
{
525+
s_agentCount = count;
526+
}
527+
528+
s32 agentMenu_getAgentCount()
529+
{
530+
return s_agentCount;
531+
}
532+
504533
void agentMenu_createNewAgent()
505534
{
506535
if (s_agentCount < MAX_AGENT_COUNT)

TheForceEngine/TFE_DarkForces/GameUI/agentMenu.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,12 @@ namespace TFE_DarkForces
1616
void agentMenu_load(LangHotkeys* hotkeys);
1717

1818
// Reset Presistent State.
19+
20+
s32 agentMenu_getAgentID();
21+
void agentMenu_setAgentId(s32 id);
22+
void agentMenu_setAgentCount(s32 count);
23+
s32 agentMenu_getAgentCount();
24+
void agentMenu_createNewAgent();
25+
void agentMenu_setAgentName(const char* name);
1926
void agentMenu_resetState();
2027
}

TheForceEngine/TFE_DarkForces/GameUI/menu.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <TFE_System/system.h>
1818
#include <TFE_Jedi/Renderer/virtualFramebuffer.h>
1919
#include <TFE_Jedi/Renderer/screenDraw.h>
20+
#include <TFE_Input/replay.h>
2021

2122
using namespace TFE_Jedi;
2223

@@ -62,16 +63,31 @@ namespace TFE_DarkForces
6263
s32 mx, my;
6364
TFE_Input::getMousePos(&mx, &my);
6465
s_cursorPosAccum = { 12*mx/10, my }; // Account for 320x200 in 4:3 scaling.
65-
66-
if (displayInfo.width >= displayInfo.height)
66+
67+
// Load the replay PDA positions.
68+
if (TFE_Input::isDemoPlayback())
6769
{
68-
s_cursorPos.x = clamp(s_cursorPosAccum.x * (s32)height / (s32)displayInfo.height, 0, (s32)width - 3);
69-
s_cursorPos.z = clamp(s_cursorPosAccum.z * (s32)height / (s32)displayInfo.height, 0, (s32)height - 3);
70+
Vec2i pdap = TFE_Input::getPDAPosition();
71+
s_cursorPos = pdap;
7072
}
7173
else
7274
{
73-
s_cursorPos.x = clamp(s_cursorPosAccum.x * (s32)width / (s32)displayInfo.width, 0, (s32)width - 3);
74-
s_cursorPos.z = clamp(s_cursorPosAccum.z * (s32)width / (s32)displayInfo.width, 0, (s32)height - 3);
75+
if (displayInfo.width >= displayInfo.height)
76+
{
77+
s_cursorPos.x = clamp(s_cursorPosAccum.x * (s32)height / (s32)displayInfo.height, 0, (s32)width - 3);
78+
s_cursorPos.z = clamp(s_cursorPosAccum.z * (s32)height / (s32)displayInfo.height, 0, (s32)height - 3);
79+
}
80+
else
81+
{
82+
s_cursorPos.x = clamp(s_cursorPosAccum.x * (s32)width / (s32)displayInfo.width, 0, (s32)width - 3);
83+
s_cursorPos.z = clamp(s_cursorPosAccum.z * (s32)width / (s32)displayInfo.width, 0, (s32)height - 3);
84+
}
85+
}
86+
87+
// Store the PDA positions for replay.
88+
if (TFE_Input::isRecording())
89+
{
90+
TFE_Input::storePDAPosition(s_cursorPos);
7591
}
7692
}
7793

TheForceEngine/TFE_DarkForces/GameUI/pda.cpp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
#include <TFE_Jedi/Level/rfont.h>
3030
#include <TFE_Jedi/Renderer/jediRenderer.h>
3131
#include <TFE_Settings/settings.h>
32-
#include <TFE_System/system.h>
32+
#include <TFE_Input/replay.h>
33+
#include <TFE_Input/inputMapping.h>
3334

3435
using namespace TFE_Jedi;
3536
using namespace TFE_Input;
@@ -126,7 +127,7 @@ namespace TFE_DarkForces
126127
// TFE
127128
reticle_enable(false);
128129
s_mouseAccum = { 0 };
129-
130+
mouseOldPosX = 0, mouseOldPosZ = 0;
130131
pauseLevelSound();
131132
if (!s_pdaLoaded)
132133
{
@@ -160,6 +161,7 @@ namespace TFE_DarkForces
160161
s_briefingMaxY = -BRIEF_VERT_MARGIN;
161162
}
162163
s_briefY = -BRIEF_VERT_MARGIN;
164+
163165
}
164166
s_overlayRect = s_pdaRect;
165167

@@ -169,7 +171,7 @@ namespace TFE_DarkForces
169171
}
170172
s_framebuffer = ldraw_getBitmap();
171173
lcanvas_getBounds(&s_viewBounds);
172-
174+
173175
s_pdaArt = lactorAnim_load("pda", &s_viewBounds, 0, 0, 0);
174176
s_palette = lpalette_load("menu");
175177
lactor_setTime(s_pdaArt, -1, -1);
@@ -210,6 +212,12 @@ namespace TFE_DarkForces
210212
pda_resetState();
211213
}
212214

215+
// Reset the tab to the map to support replay consistency.
216+
void pda_resetTab()
217+
{
218+
s_pdaMode = PDA_MODE_MAP;
219+
}
220+
213221
void pda_resetState()
214222
{
215223
s_pdaOpen = JFALSE;
@@ -246,6 +254,7 @@ namespace TFE_DarkForces
246254
TFE_Jedi::renderer_setType(RendererType(graphics->rendererIndex));
247255
TFE_Jedi::renderer_setLimits();
248256
}
257+
249258
}
250259

251260
void pda_update()
@@ -255,7 +264,10 @@ namespace TFE_DarkForces
255264
return;
256265
}
257266

258-
if (inputMapping_getActionState(IADF_PDA_TOGGLE) == STATE_PRESSED || TFE_Input::keyPressed(KEY_ESCAPE))
267+
// Special case to support Escape during demo playback
268+
if (inputMapping_getActionState(IADF_PDA_TOGGLE) == STATE_PRESSED
269+
|| TFE_Input::keyPressed(KEY_ESCAPE)
270+
|| inputMapping_getAction(IADF_MENU_TOGGLE) == STATE_PRESSED)
259271
{
260272
pda_close();
261273
return;
@@ -277,10 +289,10 @@ namespace TFE_DarkForces
277289
u32 outWidth, outHeight;
278290
vfb_getResolution(&outWidth, &outHeight);
279291
memset(vfb_getCpuBuffer(), 0, outWidth * outHeight);
280-
292+
281293
// Draw the overlay *behind* the main view - which means we must blit it to the view.
282294
pda_drawOverlay();
283-
295+
284296
// Finally draw the PDA background and UI controls.
285297
lcanvas_eraseRect(&s_viewBounds);
286298
lactor_setState(s_pdaArt, 0, 0);
@@ -351,12 +363,16 @@ namespace TFE_DarkForces
351363
// Ensure that mouse movements are not lost between updates.
352364
pda_handleMouseAccum(&wdx, &wdy);
353365

366+
// Ensure PDA key presses handle replay data
367+
bool mouseDown = TFE_Input::isDemoPlayback() && inputMapping_getAction(IADF_PRIMARY_FIRE) == STATE_DOWN || TFE_Input::mouseDown(MBUTTON_LEFT);
368+
bool mousePressed = TFE_Input::isDemoPlayback() && inputMapping_getAction(IADF_PRIMARY_FIRE) == STATE_PRESSED || TFE_Input::mousePressed(MBUTTON_LEFT);
369+
354370
// Handle Mouse Panning
355-
if (TFE_Input::mouseDown(MBUTTON_LEFT))
371+
if (mouseDown)
356372
{
357373
s32 mouseX, mouseZ;
358374
TFE_Input::getMousePos(&mouseX, &mouseZ);
359-
375+
360376
// Calculate deltas
361377
fixed16_16 deltaX = (mouseX - mouseOldPosX) << 16;
362378
fixed16_16 deltaZ = (mouseZ - mouseOldPosZ) << 16;
@@ -377,7 +393,7 @@ namespace TFE_DarkForces
377393
mouseMoveReset = true;
378394
}
379395

380-
if (TFE_Input::mousePressed(MBUTTON_LEFT) || s_simulatePressed >= 0 || wdy)
396+
if (s_simulatePressed >= 0 || wdy || mousePressed)
381397
{
382398
s_buttonPressed = -1;
383399
s32 count = (s_pdaMode == PDA_MODE_MAP || s_pdaMode == PDA_MODE_BRIEF) ? PDA_BTN_COUNT : PDA_BTN_EXIT + 1;
@@ -386,8 +402,8 @@ namespace TFE_DarkForces
386402
lactor_setState(s_pdaArt, 2 * (1 + i), 0);
387403
LRect buttonRect;
388404
lactorAnim_getFrame(s_pdaArt, &buttonRect);
389-
390-
if (!TFE_Input::mousePressed(MBUTTON_LEFT))
405+
406+
if (!TFE_Input::mousePressed(MBUTTON_LEFT) && !mousePressed)
391407
{
392408
if (i == s_simulatePressed)
393409
{
@@ -408,7 +424,7 @@ namespace TFE_DarkForces
408424
}
409425
}
410426

411-
if (s_pdaMode == PDA_MODE_MAP && (s_buttonPressed || wdy) && s_frameReady)
427+
if (s_pdaMode == PDA_MODE_MAP && (s_buttonPressed || wdy || mousePressed) && s_frameReady)
412428
{
413429
// Add support for mouse wheel scrolling.
414430
if (wdy < 0)
@@ -464,7 +480,7 @@ namespace TFE_DarkForces
464480
} break;
465481
}
466482
}
467-
else if (s_pdaMode == PDA_MODE_BRIEF && (s_buttonPressed || wdy) && s_frameReady)
483+
else if (s_pdaMode == PDA_MODE_BRIEF && (s_buttonPressed || wdy || mousePressed) && s_frameReady)
468484
{
469485
// Add support for mouse wheel scrolling.
470486
if (wdy > 0) // up
@@ -506,7 +522,7 @@ namespace TFE_DarkForces
506522
}
507523
}
508524
}
509-
else if (TFE_Input::mouseDown(MBUTTON_LEFT) && s_buttonPressed >= 0)
525+
else if (mouseDown && s_buttonPressed >= 0)
510526
{
511527
lactor_setState(s_pdaArt, 2 * (1 + s_buttonPressed), 0);
512528
LRect buttonRect;
@@ -850,7 +866,7 @@ namespace TFE_DarkForces
850866
u32 outWidth, outHeight;
851867
vfb_getResolution(&outWidth, &outHeight);
852868
memset(vfb_getCpuBuffer(), 0, outWidth * outHeight);
853-
869+
854870
u32 palette[256] = { 0 };
855871
vfb_setPalette(palette);
856872
}

TheForceEngine/TFE_DarkForces/GameUI/pda.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace TFE_DarkForces
1111
void pda_start(const char* levelName);
1212
void pda_cleanup();
1313
void pda_resetState();
14+
void pda_resetTab();
1415

1516
JBool pda_isOpen();
1617
void pda_update();

TheForceEngine/TFE_DarkForces/agent.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ namespace TFE_DarkForces
4848

4949
void agent_serialize(Stream* stream);
5050
void agent_restartEndLevelTask();
51+
5152
s32 agent_loadData();
5253
JBool agent_loadLevelList(const char* fileName);
5354
void agent_updateAgentSavedData();
5455
void agent_levelEndTask();
55-
5656
JBool agent_readConfigData(FileStream* file, s32 agentId, LevelSaveData* saveData);
5757
JBool agent_writeAgentConfigData(FileStream* file, s32 agentId, const LevelSaveData* saveData);
58+
void agent_writeSavedData(s32 agentId, LevelSaveData* saveData);
59+
void agent_readSavedData(s32 agentId, LevelSaveData* levelData);
5860
void agent_readSavedDataForLevel(s32 agentId, s32 levelIndex);
5961
void agent_saveLevelCompletion(u8 diff, s32 levelIndex);
6062
s32 agent_saveInventory(s32 agentId, s32 nextLevel);
@@ -72,6 +74,8 @@ namespace TFE_DarkForces
7274

7375
void agent_levelComplete();
7476
void agent_createLevelEndTask();
77+
78+
JBool createDarkPilotConfig(const char* path);
7579

7680
extern AgentData s_agentData[MAX_AGENT_COUNT];
7781
extern s32 s_maxLevelIndex;

0 commit comments

Comments
 (0)