Skip to content

Commit c458298

Browse files
committed
fix(src): ScreenText not closing
1 parent cc53f0d commit c458298

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Over here will be noted all the update change logs.
44

5+
## v1.6.21-22 - [Release](https://github.com/swiftly-solution/swiftly/releases/tag/v1.6.22)
6+
7+
### Screen Text
8+
9+
- Possible crash fix for the screen texts
10+
511
## v1.6.20 - [Release](https://github.com/swiftly-solution/swiftly/releases/tag/v1.6.20)
612

713
### WebSockets

src/engine/gameevents/gameevents.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ bool EventManager::OnPostFireEvent(IGameEvent* pEvent, bool bDontBroadcast)
196196
std::string prettyEventName = gameEventsRegister[eventName];
197197

198198
if (prettyEventName == "OnRoundStart") {
199+
g_VGUI.ResetStateOfScreenTexts();
200+
199201
g_Plugin.RegisterTimeout(100, []() -> void {
200202
g_VGUI.RegenerateScreenTexts();
201203
});

src/engine/vgui/screentext.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
ScreenText::~ScreenText()
99
{
10+
if (pScreenEntity.IsValid()) {
11+
schema::SetProp<bool>(pScreenEntity.Get(), "CPointWorldText", "m_bEnabled", false);
12+
schema::SetProp<bool>(pScreenEntity.Get(), "CPointWorldText", "m_bDrawBackground", false);
13+
}
1014
}
1115

1216
void ScreenText::Create(Color color, std::string font, int size, bool drawBackground, bool isMenu)
@@ -57,6 +61,7 @@ void ScreenText::SetupViewForPlayer(Player* player)
5761

5862
if (!pScreenEntity.IsValid()) return;
5963
if (!pScreenEntity) return;
64+
6065
if (!player) return;
6166
if (player->IsFakeClient()) return;
6267

@@ -190,4 +195,9 @@ bool ScreenText::IsRenderingTo(CHandle<CEntityInstance> renderingTo)
190195
void ScreenText::SetRenderingTo(CEntityInstance* ent)
191196
{
192197
pRenderingTo.Set(ent);
198+
}
199+
200+
void ScreenText::ResetSpawnState()
201+
{
202+
pScreenEntity.Term();
193203
}

src/engine/vgui/screentext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class ScreenText
3232
void SetPosition(float posX = 0.0, float posY = 0.0);
3333
void SetRenderingTo(CEntityInstance* ent);
3434
void RegenerateText(bool recreate = true);
35+
void ResetSpawnState();
3536

3637
bool IsValidEntity();
3738
Player* GetPlayer();

src/engine/vgui/vgui.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ void VGUI::DeleteScreenText(uint64_t id)
4747
screenTexts.erase(id);
4848
}
4949

50+
void VGUI::ResetStateOfScreenTexts()
51+
{
52+
for (auto it = screenTexts.begin(); it != screenTexts.end(); ++it) {
53+
it->second->ResetSpawnState();
54+
}
55+
}
56+
5057
void VGUI::RegenerateScreenTexts()
5158
{
5259
for (auto it = screenTexts.begin(); it != screenTexts.end(); ++it) {

src/engine/vgui/vgui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class VGUI
2121
void DeleteScreenText(uint64_t id);
2222

2323
void RegenerateScreenTexts();
24+
void ResetStateOfScreenTexts();
2425

2526
void FilterRenderingItems(Player* player, CCheckTransmitInfo* pInfo);
2627

0 commit comments

Comments
 (0)