Skip to content

Commit 7b85ab9

Browse files
committed
OOBState: Additional matches with idiot_level_data fix
1 parent 7eacb84 commit 7b85ab9

File tree

2 files changed

+114
-24
lines changed

2 files changed

+114
-24
lines changed

src/SB/Game/zEntPlayerOOBState.cpp

Lines changed: 103 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "xMathInlines.h"
66
#include "zSurface.h"
77
#include "zRenderState.h"
8+
#include "zEntPlayerBungeeState.h"
89

910
#include <types.h>
1011
#include <rwplcore.h>
@@ -637,10 +638,6 @@ namespace oob_state
637638
this->updatess[9] = &supdate_fade_out;
638639
}
639640

640-
grab_state_type::tutorial_callback::tutorial_callback(grab_state_type& owner) : owner(owner)
641-
{
642-
}
643-
644641
grab_state_type::substate_enum grab_state_type::supdate_fade_out(grab_state_type& gst,
645642
xScene& scene, F32& dt)
646643
{
@@ -858,10 +855,35 @@ namespace oob_state
858855
{
859856
return SS_BEGIN_WAIT;
860857
};
858+
859+
grab_state_type::tutorial_callback::tutorial_callback(grab_state_type& owner) : owner(owner)
860+
{
861+
}
862+
863+
out_state_type::out_state_type() : state_type(STATE_OUT)
864+
{
865+
}
866+
867+
in_state_type::in_state_type() : state_type(STATE_IN)
868+
{
869+
}
870+
871+
void state_type::start()
872+
{
873+
};
874+
875+
void state_type::stop()
876+
{
877+
};
861878
} // namespace
862879
} // namespace oob_state
863880

864-
float oob_state::oob_timer()
881+
bool oob_state::IsPlayerInControl()
882+
{
883+
return oob_state::shared.control == 0;
884+
}
885+
886+
F32 oob_state::oob_timer()
865887
{
866888
if (shared.reset_time == fixed.reset_time)
867889
{
@@ -871,6 +893,82 @@ float oob_state::oob_timer()
871893
return -1.0f;
872894
}
873895

896+
bool oob_state::render()
897+
{
898+
if ((shared.flags & 0x3) != 3)
899+
{
900+
return false;
901+
}
902+
903+
if (!shared.control)
904+
{
905+
return false;
906+
}
907+
908+
xLightKit_Enable(globals.player.ent.lightKit, globals.currWorld);
909+
xEntRender(&globals.player.ent);
910+
xLightKit_Enable(NULL, globals.currWorld);
911+
912+
return true;
913+
}
914+
915+
void oob_state::fx_render()
916+
{
917+
if ((shared.flags & 0x3) != 3)
918+
{
919+
return;
920+
}
921+
922+
if (shared.control && shared.fade_alpha < 1.0f)
923+
{
924+
render_fade();
925+
render_ghost();
926+
}
927+
928+
if (shared.render_hand && shared.model != NULL)
929+
{
930+
render_hand();
931+
}
932+
}
933+
934+
void oob_state::force_start()
935+
{
936+
if ((shared.flags & 0x7) == 0x3 && !bungee_state::active())
937+
{
938+
if (globals.player.ControlOff & 0x8000)
939+
{
940+
shared.flags |= 0x8;
941+
oob_player_teleported = false;
942+
}
943+
else
944+
{
945+
shared.flags &= ~0x8;
946+
shared.state->stop();
947+
shared.state = shared.states[2];
948+
shared.state->start();
949+
}
950+
}
951+
}
952+
953+
void oob_state::read_persistent(xSerial& s)
954+
{
955+
for (U32 i = 0; i < 6; i++)
956+
{
957+
S32 val;
958+
s.Read_b1(&val);
959+
960+
idiot_levels[i].triggered = (bool)val;
961+
}
962+
}
963+
964+
void oob_state::write_persistent(xSerial& s)
965+
{
966+
for (U32 i = 0; i < 6; i++)
967+
{
968+
s.Write_b1((bool)idiot_levels[i].triggered);
969+
}
970+
}
971+
874972
void oob_state::in_state_type::start()
875973
{
876974
shared.reset_time = FLOAT_MAX;
@@ -892,19 +990,6 @@ void oob_state::out_state_type::stop() {
892990

893991
};
894992

895-
void oob_state::state_type::start() {
896-
897-
};
898-
899-
void oob_state::state_type::stop() {
900-
901-
};
902-
903-
bool oob_state::IsPlayerInControl()
904-
{
905-
return oob_state::shared.control == 0;
906-
}
907-
908993
namespace oob_state
909994
{
910995
namespace

src/SB/Game/zEntPlayerOOBState.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace oob_state
1313
{
1414
bool render();
1515
void fx_render();
16+
void force_start();
1617
void read_persistent(xSerial& s);
1718
void write_persistent(xSerial& s);
1819
void load_settings(xIniFile& ini);
@@ -43,19 +44,23 @@ namespace oob_state
4344
state_type(state_enum state);
4445
virtual void start();
4546
virtual void stop();
46-
virtual state_enum update(xScene& scene, F32& dt);
47+
virtual state_enum update(xScene& scene, F32& dt) = 0;
4748
};
4849

4950
struct in_state_type : state_type
5051
{
51-
void start();
52-
void stop();
52+
in_state_type();
53+
virtual void start();
54+
virtual void stop();
55+
virtual state_enum update(xScene& scene, F32& dt);
5356
};
5457

5558
struct out_state_type : state_type
5659
{
57-
void start();
58-
void stop();
60+
out_state_type();
61+
virtual void start();
62+
virtual void stop();
63+
virtual state_enum update(xScene& scene, F32& dt);
5964
};
6065

6166
struct grab_state_type : state_type
@@ -251,7 +256,7 @@ namespace oob_state
251256

252257
struct idiot_level_data
253258
{
254-
bool triggered; // offset 0x0, size 0x1
259+
U8 triggered; // offset 0x0, size 0x1
255260
U32 scene; // offset 0x4, size 0x4
256261
};
257262

0 commit comments

Comments
 (0)