-
Notifications
You must be signed in to change notification settings - Fork 77
Replays POC #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replays POC #492
Changes from 65 commits
18421a5
9ba869b
5d4f089
f9b9a33
c647178
f705b90
e425b75
e47d5d1
c6cd639
83728b3
fef63e9
83b0bba
bde3e4f
e8638e7
52360e6
5759a7c
a4af801
7a3c270
3dd429a
bbcf767
c43f888
5832e6d
62ce1ac
d02c738
01a0ba0
cc3af63
8ebfd45
1068024
8589ab6
dd96465
c0d9f68
f82ef82
2c2b8e2
845f893
f885f53
5b40dd2
c53709e
0da2621
511e44e
63c1166
674ab36
7ffed3a
d225050
d530d12
626fe4a
60cb5e3
de69d8e
f967481
36e00f0
a3ac19e
3918af2
a985321
ea75130
54df93d
cc3832b
8a98030
f86f99d
11f692a
ebd2126
7d7408b
d408ada
83ac59a
d7af3dd
c090e8b
91f9b34
24704d7
fc68b8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,11 @@ namespace TFE_DarkForces | |
static MouseBot* s_curMouseBot; | ||
static s32 s_mouseNum = 0; | ||
|
||
void mousebot_resetNum() | ||
{ | ||
s_mouseNum = 0; | ||
} | ||
|
||
MessageType mousebot_handleDamage(MessageType msg, MouseBot* mouseBot) | ||
{ | ||
SecObject* obj = mouseBot->logic.obj; | ||
|
@@ -148,7 +153,7 @@ namespace TFE_DarkForces | |
local(tick) = s_curTick; | ||
} | ||
else | ||
{ | ||
{ | ||
Tick dt = s_curTick - local(tick); | ||
// If enough time has past since the player was last spotted, go back to sleep. | ||
if (dt > 728) // ~5 seconds. | ||
|
@@ -164,8 +169,8 @@ namespace TFE_DarkForces | |
{ | ||
local(odd) = (s_curTick & 1) ? JTRUE : JFALSE; | ||
angle14_32 deltaYaw = random(16338); | ||
local(moveMod)->target.yaw = local(odd) ? (local(obj)->yaw + deltaYaw) : (local(obj)->yaw - deltaYaw); | ||
|
||
local(moveMod)->target.yaw = local(odd) ? (local(obj)->yaw + deltaYaw) : (local(obj)->yaw - deltaYaw); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now it is my turn to nit pick :-) |
||
local(moveMod)->target.speedRotation = random(0x3555) + 0x555; | ||
local(moveMod)->target.flags |= TARGET_MOVE_ROT; | ||
local(flip) = JFALSE; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,8 @@ | |
#include <TFE_Jedi/Level/rfont.h> | ||
#include <TFE_Jedi/Renderer/jediRenderer.h> | ||
#include <TFE_Settings/settings.h> | ||
#include <TFE_System/system.h> | ||
#include <TFE_Input/replay.h> | ||
#include <TFE_Input/inputMapping.h> | ||
|
||
using namespace TFE_Jedi; | ||
using namespace TFE_Input; | ||
|
@@ -126,7 +127,7 @@ namespace TFE_DarkForces | |
// TFE | ||
reticle_enable(false); | ||
s_mouseAccum = { 0 }; | ||
|
||
mouseOldPosX = 0, mouseOldPosZ = 0; | ||
pauseLevelSound(); | ||
if (!s_pdaLoaded) | ||
{ | ||
|
@@ -160,6 +161,7 @@ namespace TFE_DarkForces | |
s_briefingMaxY = -BRIEF_VERT_MARGIN; | ||
} | ||
s_briefY = -BRIEF_VERT_MARGIN; | ||
|
||
} | ||
s_overlayRect = s_pdaRect; | ||
|
||
|
@@ -169,7 +171,7 @@ namespace TFE_DarkForces | |
} | ||
s_framebuffer = ldraw_getBitmap(); | ||
lcanvas_getBounds(&s_viewBounds); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another one |
||
s_pdaArt = lactorAnim_load("pda", &s_viewBounds, 0, 0, 0); | ||
s_palette = lpalette_load("menu"); | ||
lactor_setTime(s_pdaArt, -1, -1); | ||
|
@@ -210,6 +212,12 @@ namespace TFE_DarkForces | |
pda_resetState(); | ||
} | ||
|
||
// Reset the tab to the map to support replay consistency. | ||
void pda_resetTab() | ||
{ | ||
s_pdaMode = PDA_MODE_MAP; | ||
} | ||
|
||
void pda_resetState() | ||
{ | ||
s_pdaOpen = JFALSE; | ||
|
@@ -246,6 +254,7 @@ namespace TFE_DarkForces | |
TFE_Jedi::renderer_setType(RendererType(graphics->rendererIndex)); | ||
TFE_Jedi::renderer_setLimits(); | ||
} | ||
|
||
} | ||
|
||
void pda_update() | ||
|
@@ -255,7 +264,10 @@ namespace TFE_DarkForces | |
return; | ||
} | ||
|
||
if (inputMapping_getActionState(IADF_PDA_TOGGLE) == STATE_PRESSED || TFE_Input::keyPressed(KEY_ESCAPE)) | ||
// Special case to support Escape during demo playback | ||
if (inputMapping_getActionState(IADF_PDA_TOGGLE) == STATE_PRESSED | ||
|| TFE_Input::keyPressed(KEY_ESCAPE) | ||
|| inputMapping_getAction(IADF_MENU_TOGGLE) == STATE_PRESSED) | ||
{ | ||
pda_close(); | ||
return; | ||
|
@@ -277,10 +289,10 @@ namespace TFE_DarkForces | |
u32 outWidth, outHeight; | ||
vfb_getResolution(&outWidth, &outHeight); | ||
memset(vfb_getCpuBuffer(), 0, outWidth * outHeight); | ||
|
||
// Draw the overlay *behind* the main view - which means we must blit it to the view. | ||
pda_drawOverlay(); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a couple more |
||
// Finally draw the PDA background and UI controls. | ||
lcanvas_eraseRect(&s_viewBounds); | ||
lactor_setState(s_pdaArt, 0, 0); | ||
|
@@ -351,12 +363,16 @@ namespace TFE_DarkForces | |
// Ensure that mouse movements are not lost between updates. | ||
pda_handleMouseAccum(&wdx, &wdy); | ||
|
||
// Ensure PDA key presses handle replay data | ||
bool mouseDown = TFE_Input::isDemoPlayback() && inputMapping_getAction(IADF_PRIMARY_FIRE) == STATE_DOWN || TFE_Input::mouseDown(MBUTTON_LEFT); | ||
bool mousePressed = TFE_Input::isDemoPlayback() && inputMapping_getAction(IADF_PRIMARY_FIRE) == STATE_PRESSED || TFE_Input::mousePressed(MBUTTON_LEFT); | ||
|
||
// Handle Mouse Panning | ||
if (TFE_Input::mouseDown(MBUTTON_LEFT)) | ||
if (mouseDown) | ||
{ | ||
s32 mouseX, mouseZ; | ||
TFE_Input::getMousePos(&mouseX, &mouseZ); | ||
|
||
// Calculate deltas | ||
fixed16_16 deltaX = (mouseX - mouseOldPosX) << 16; | ||
fixed16_16 deltaZ = (mouseZ - mouseOldPosZ) << 16; | ||
|
@@ -377,7 +393,7 @@ namespace TFE_DarkForces | |
mouseMoveReset = true; | ||
} | ||
|
||
if (TFE_Input::mousePressed(MBUTTON_LEFT) || s_simulatePressed >= 0 || wdy) | ||
if (s_simulatePressed >= 0 || wdy || mousePressed) | ||
{ | ||
s_buttonPressed = -1; | ||
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 | |
lactor_setState(s_pdaArt, 2 * (1 + i), 0); | ||
LRect buttonRect; | ||
lactorAnim_getFrame(s_pdaArt, &buttonRect); | ||
|
||
if (!TFE_Input::mousePressed(MBUTTON_LEFT)) | ||
if (!TFE_Input::mousePressed(MBUTTON_LEFT) && !mousePressed) | ||
{ | ||
if (i == s_simulatePressed) | ||
{ | ||
|
@@ -408,7 +424,7 @@ namespace TFE_DarkForces | |
} | ||
} | ||
|
||
if (s_pdaMode == PDA_MODE_MAP && (s_buttonPressed || wdy) && s_frameReady) | ||
if (s_pdaMode == PDA_MODE_MAP && (s_buttonPressed || wdy || mousePressed) && s_frameReady) | ||
{ | ||
// Add support for mouse wheel scrolling. | ||
if (wdy < 0) | ||
|
@@ -464,7 +480,7 @@ namespace TFE_DarkForces | |
} break; | ||
} | ||
} | ||
else if (s_pdaMode == PDA_MODE_BRIEF && (s_buttonPressed || wdy) && s_frameReady) | ||
else if (s_pdaMode == PDA_MODE_BRIEF && (s_buttonPressed || wdy || mousePressed) && s_frameReady) | ||
{ | ||
// Add support for mouse wheel scrolling. | ||
if (wdy > 0) // up | ||
|
@@ -506,7 +522,7 @@ namespace TFE_DarkForces | |
} | ||
} | ||
} | ||
else if (TFE_Input::mouseDown(MBUTTON_LEFT) && s_buttonPressed >= 0) | ||
else if (mouseDown && s_buttonPressed >= 0) | ||
{ | ||
lactor_setState(s_pdaArt, 2 * (1 + s_buttonPressed), 0); | ||
LRect buttonRect; | ||
|
@@ -850,7 +866,7 @@ namespace TFE_DarkForces | |
u32 outWidth, outHeight; | ||
vfb_getResolution(&outWidth, &outHeight); | ||
memset(vfb_getCpuBuffer(), 0, outWidth * outHeight); | ||
|
||
u32 palette[256] = { 0 }; | ||
vfb_setPalette(palette); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that Lucius adds a
// TFE
comment above new functions and variables that have been added, it helps us see what did not come from vanillaI've been trying to do the same
I think it would be good if you could do this as well, where possible