This repository has been archived by the owner on May 3, 2024. It is now read-only.
forked from SierraBay/SierraBay12
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Почему это хорошо для игры Порт порта - ParadiseSS13/Paradise#23643 Все ПРы там, использовано правда гораздо больше, но мне ТАААК впадлу всё перечислять, потому что я тупо копировал код с пары и адаптировал его под сыр, ищите в репе пары если хочется. Нормальный чат, Fuckin' Finally ## Изображения изменений <details> <summary>Скриншоты</summary> ![image](https://github.com/ss220club/WyccerraBay220/assets/69762909/4489a085-0aaa-4d99-b8c8-d83be0f5dc00) </details> <!-- Если вы не меняли карту или спрайты, можете опустить эту секцию. Если хотите, можете вставить видео. --> ## Тестирование Буде буде <!-- Как вы тестировали свой PR, если делали это вовсе? --> ## Changelog :cl: add: GoonChan был беспощадно ёбнут ради TGchat'а, слава ТГчату! /:cl: <!-- Оба :cl:'а должны быть на месте, что-бы чейнджлог работал! Вы можете написать свой ник справа от первого :cl:, если хотите. Иначе будет использован ваш ник на ГитХабе. --> <!-- Вы можете использовать несколько записей с одинаковым префиксом (Они используются только для иконки в игре) и удалить ненужные. Помните, что чейнджлог должен быть понятен обычным игроком. --> <!-- Если чейнджлог не влияет на игроков(например, это рефактор), вы можете исключить всю секцию. -->
- Loading branch information
Showing
65 changed files
with
1,459 additions
and
4,571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) 2020 Aleksej Komarov | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
/// How many chat payloads to keep in history | ||
#define CHAT_RELIABILITY_HISTORY_SIZE 5 | ||
/// How many resends to allow before giving up | ||
#define CHAT_RELIABILITY_MAX_RESENDS 3 | ||
|
||
#define MESSAGE_TYPE_SYSTEM "system" | ||
#define MESSAGE_TYPE_LOCALCHAT "localchat" | ||
#define MESSAGE_TYPE_RADIO "radio" | ||
#define MESSAGE_TYPE_INFO "info" | ||
#define MESSAGE_TYPE_WARNING "warning" | ||
#define MESSAGE_TYPE_DEADCHAT "deadchat" | ||
#define MESSAGE_TYPE_OOC "ooc" | ||
#define MESSAGE_TYPE_ADMINPM "adminpm" | ||
#define MESSAGE_TYPE_COMBAT "combat" | ||
#define MESSAGE_TYPE_ADMINCHAT "adminchat" | ||
#define MESSAGE_TYPE_MENTORCHAT "mentorchat" | ||
#define MESSAGE_TYPE_EVENTCHAT "eventchat" | ||
#define MESSAGE_TYPE_ADMINLOG "adminlog" | ||
#define MESSAGE_TYPE_ATTACKLOG "attacklog" | ||
#define MESSAGE_TYPE_DEBUG "debug" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#define chat_box_regular(str) ("<div class='boxed_message'>" + str + "</div>") | ||
#define chat_box_examine(str) ("<div class='boxed_message left_align_text'>" + str + "</div>") | ||
#define chat_box_red(str) ("<div class='boxed_message red_border'>" + str + "</div>") | ||
#define chat_box_green(str) ("<div class='boxed_message green_border'>" + str + "</div>") | ||
#define chat_box_purple(str) ("<div class='boxed_message purple_border'>" + str + "</div>") | ||
#define chat_box_notice(str) ("<div class='boxed_message notice_border'>" + str + "</div>") | ||
#define chat_box_healthscan(str) ("<div class='boxed_message notice_border left_align_text'>" + str + "</div>") | ||
#define chat_box_notice_thick(str) ("<div class='boxed_message notice_border thick_border'>" + str + "</div>") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,91 @@ | ||
/** | ||
* Copyright (c) 2020 Aleksej Komarov | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
SUBSYSTEM_DEF(chat) | ||
name = "Chat" | ||
flags = SS_TICKER|SS_NO_INIT | ||
wait = 1 | ||
runlevels = RUNLEVELS_PREGAME | RUNLEVELS_GAME | ||
priority = SS_PRIORITY_CHAT | ||
init_order = SS_INIT_CHAT | ||
var/static/list/payload = list() | ||
|
||
|
||
/datum/controller/subsystem/chat/UpdateStat(time) | ||
return | ||
/// Associates a ckey with a list of messages to send to them. | ||
var/list/list/datum/chat_payload/client_to_payloads = list() | ||
|
||
/// Associates a ckey with an associative list of their last CHAT_RELIABILITY_HISTORY_SIZE messages. | ||
var/list/list/datum/chat_payload/client_to_reliability_history = list() | ||
|
||
/// Associates a ckey with their next sequence number. | ||
var/list/client_to_sequence_number = list() | ||
|
||
/datum/controller/subsystem/chat/proc/generate_payload(client/target, message_data) | ||
var/sequence = client_to_sequence_number[target.ckey] | ||
client_to_sequence_number[target.ckey] += 1 | ||
|
||
var/datum/chat_payload/payload = new | ||
payload.sequence = sequence | ||
payload.content = message_data | ||
|
||
if(!(target.ckey in client_to_reliability_history)) | ||
client_to_reliability_history[target.ckey] = list() | ||
var/list/client_history = client_to_reliability_history[target.ckey] | ||
client_history["[sequence]"] = payload | ||
|
||
if(length(client_history) > CHAT_RELIABILITY_HISTORY_SIZE) | ||
var/oldest = text2num(client_history[1]) | ||
for(var/index in 2 to length(client_history)) | ||
var/test = text2num(client_history[index]) | ||
if(test < oldest) | ||
oldest = test | ||
client_history -= "[oldest]" | ||
return payload | ||
|
||
/datum/controller/subsystem/chat/proc/send_payload_to_client(client/target, datum/chat_payload/payload) | ||
target.tgui_panel.window.send_message("chat/message", payload.into_message()) | ||
SEND_TEXT(target, payload.get_content_as_html()) | ||
|
||
/datum/controller/subsystem/chat/fire() | ||
for(var/ckey in client_to_payloads) | ||
var/client/target = GLOB.ckey_directory[ckey] | ||
if(isnull(target)) // verify client still exists | ||
LAZYREMOVE(client_to_payloads, ckey) | ||
continue | ||
|
||
/datum/controller/subsystem/chat/fire(resumed) | ||
for (var/client/C as anything in payload) | ||
send_output(C, payload[C], "browseroutput:output") | ||
payload -= C | ||
if (MC_TICK_CHECK) | ||
for(var/datum/chat_payload/payload as anything in client_to_payloads[ckey]) | ||
send_payload_to_client(target, payload) | ||
LAZYREMOVE(client_to_payloads, ckey) | ||
|
||
if(MC_TICK_CHECK) | ||
return | ||
|
||
/datum/controller/subsystem/chat/proc/queue(queue_target, list/message_data) | ||
var/list/targets = islist(queue_target) ? queue_target : list(queue_target) | ||
for(var/target in targets) | ||
var/client/client = CLIENT_FROM_VAR(target) | ||
if(isnull(client)) | ||
continue | ||
LAZYADDASSOC(client_to_payloads, client.ckey, generate_payload(client, message_data)) | ||
|
||
/datum/controller/subsystem/chat/proc/queue(target, message, handle_whitespace = TRUE, trailing_newline = TRUE) | ||
if (!target || !message) | ||
return | ||
if (!istext(message)) | ||
CRASH("to_chat called with invalid input type") | ||
if (target == world) | ||
target = GLOB.clients | ||
var/original_message = message //Some macros resist parsing elsewhere; strip them here | ||
message = replacetext(message, "\improper", "") | ||
message = replacetext(message, "\proper", "") | ||
if (handle_whitespace) | ||
message = replacetext(message, "\n", "<br>") | ||
message = replacetext(message, "\t", "[FOURSPACES][FOURSPACES]") | ||
if (trailing_newline) | ||
message += "<br>" | ||
var/twiceEncoded = url_encode(url_encode(message)) // Double encode so that JS can consume utf-8 | ||
if (islist(target)) | ||
for(var/I in target) | ||
queuePartTwo(I, message, original_message, twiceEncoded) | ||
else | ||
queuePartTwo(target, message, original_message, twiceEncoded) | ||
|
||
|
||
/datum/controller/subsystem/chat/proc/queuePartTwo(client/C, message, original, encoded) | ||
C = resolve_client(C) | ||
if (!C) | ||
return | ||
legacy_chat(C, original) | ||
if (C?.get_preference_value(/datum/client_preference/goonchat) != GLOB.PREF_YES) | ||
return | ||
if (!C.chatOutput || C.chatOutput.broken) | ||
return | ||
if (!C.chatOutput.loaded) | ||
C.chatOutput.messageQueue += message | ||
/datum/controller/subsystem/chat/proc/send_immediate(send_target, list/message_data) | ||
var/list/targets = islist(send_target) ? send_target : list(send_target) | ||
for(var/target in targets) | ||
var/client/client = CLIENT_FROM_VAR(target) | ||
if(isnull(client)) | ||
continue | ||
send_payload_to_client(client, generate_payload(client, message_data)) | ||
|
||
/datum/controller/subsystem/chat/proc/handle_resend(client/client, sequence) | ||
var/list/client_history = client_to_reliability_history[client.ckey] | ||
sequence = "[sequence]" | ||
if(isnull(client_history) || !(sequence in client_history)) | ||
return | ||
payload[C] += encoded | ||
|
||
var/datum/chat_payload/payload = client_history[sequence] | ||
if(payload.resends > CHAT_RELIABILITY_MAX_RESENDS) | ||
return // we tried but byond said no | ||
|
||
payload.resends += 1 | ||
send_payload_to_client(client, client_history[sequence]) |
Oops, something went wrong.