Skip to content

Commit

Permalink
revert most of the change from #1006 (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll authored Dec 12, 2023
1 parent 731aaa8 commit 658178f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to TTT2 will be documented here. Inspired by [keep a changel
### Fixed

- Fixed the UI being unable to handle wrapping text with non-utf8 languages that do not use ASCII whitespaces (by @TimGoll & @saibotk)
- Fixed ttt_game_text not working due to a refactor

## [v0.12.0b](https://github.com/TTT-2/TTT2/tree/v0.12.0b) (2023-12-11)

Expand Down
46 changes: 27 additions & 19 deletions gamemodes/terrortown/entities/entities/ttt_game_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ ENT.Message = ""
ENT.Color = COLOR_WHITE

local RECEIVE_ACTIVATOR = 0
local RECEIVE_ALL = 1
local RECEIVE_DETECTIVE = 2
local RECEIVE_TRAITOR = 3
local RECEIVE_INNOCENT = 4
local RECEIVE_CUSTOMROLE = 5

ENT.Receiver = RECEIVE_ACTIVATOR
Expand All @@ -35,7 +39,7 @@ function ENT:KeyValue(key, value)
self.Receiver = tonumber(value)

if not self.Receiver or self.Receiver < 0 or self.Receiver > 5 then
ErrorNoHalt("ERROR: ttt_game_text has invalid receiver value\n")
ErrorNoHalt("ERROR: ttt_game_text has invalid inputReceiver value\n")

self.Receiver = RECEIVE_ACTIVATOR
end
Expand All @@ -52,24 +56,28 @@ function ENT:AcceptInput(name, activator)
return false
end

if IsValid(activator) and activator:IsPlayer() then
local recv = activator
local receiver_tbl = {
RECEIVE_ALL = nil,
RECEIVE_DETECTIVE = GetRoleChatFilter(ROLE_DETECTIVE),
RECEIVE_TRAITOR = GetRoleChatFilter(TEAM_TRAITOR),
RECEIVE_INNOCENT = GetRoleChatFilter(TEAM_INNOCENT)
}

recv = self.teamReceiver and GetTeamChatFilter(self.teamReceiver) or receiver_tbl[self.Receiver]
CustomMsg(recv, self.Message, self.Color)

recv = nil
receiver_tbl = nil

return true
local inputReceiver = self.Receiver
local messageReceiver = activator

if inputReceiver == RECEIVE_ALL then
messageReceiver = nil
elseif inputReceiver == RECEIVE_DETECTIVE then
messageReceiver = GetRoleChatFilter(ROLE_DETECTIVE)
elseif inputReceiver == RECEIVE_TRAITOR then
messageReceiver = GetTeamChatFilter(TEAM_TRAITOR)
elseif inputReceiver == RECEIVE_INNOCENT then
messageReceiver = GetTeamChatFilter(TEAM_INNOCENT)
elseif inputReceiver == RECEIVE_ACTIVATOR then
if not IsValid(activator) or not activator:IsPlayer() then
ErrorNoHalt("ttt_game_text tried to show message to invalid !activator\n")

return true
end
elseif inputReceiver == RECEIVE_CUSTOMROLE and self.teamReceiver then
messageReceiver = GetTeamChatFilter(self.teamReceiver)
end

ErrorNoHalt("ttt_game_text tried to show message to invalid !activator\n")
return false -- either invalid activator or activator was not a player
CustomMsg(messageReceiver, self.Message, self.Color)

return true
end

0 comments on commit 658178f

Please sign in to comment.