Fix runtimes and togglecreep

This commit is contained in:
Shifty/Anthomansland
2020-06-03 23:27:15 +02:00
parent 03e476dc19
commit a31cf3d3f2
5 changed files with 53 additions and 32 deletions

View File

@@ -214,9 +214,10 @@ var/const/MAX_SAVE_SLOTS = 16
var/jingle = JINGLE_CLASSIC
// Runscape-like chat
var/chat_on_map = TRUE
var/mob_chat_on_map = FALSE
var/max_chat_length = CHAT_MESSAGE_MAX_LENGTH
var/see_chat_non_mob = TRUE
var/obj_chat_on_map = FALSE
var/no_goonchat_for_obj = FALSE
var/client/client
var/saveloaded = 0
@@ -419,12 +420,15 @@ var/const/MAX_SAVE_SLOTS = 16
<a href='?_src_=prefs;preference=credits_volume'><b>[credits_volume]</b></a><br>
<b>Window Flashing</b>
<a href='?_src_=prefs;preference=window_flashing'><b>[(window_flashing) ? "Yes":"No"]</b></a><br>
<b>Show Runechat Chat Bubbles:</b>
<a href='?_src_=prefs;preference=chat_on_map'>[chat_on_map ? "Enabled" : "Disabled"]</a><br>
<center>Runechat prefererences</center>
<b>Chat on map for mobs:</b>
<a href='?_src_=prefs;preference=mob_chat_on_map'>[mob_chat_on_map ? "Enabled" : "Disabled"]</a><br>
<b>Chat on map for objects:</b>
<a href='?_src_=prefs;preference=obj_chat_on_map'>[obj_chat_on_map ? "Enabled" : "Disabled"]</a><br>
<b>No goonchat messages for objects:</b>
<a href='?_src_=prefs;preference=no_goonchat_for_obj'>[no_goonchat_for_obj ? "Enabled" : "Disabled"]</a><br>
<b>Runechat message char limit:</b>
<a href='?_src_=prefs;preference=max_chat_length;task=input'>[max_chat_length]</a><br>
<b>See Runechat for non-mobs:</b>
<a href='?_src_=prefs;preference=see_chat_non_mob'>[see_chat_non_mob ? "Enabled" : "Disabled"]</a><br>
</div>
</div>"}
@@ -1521,14 +1525,18 @@ NOTE: The change will take effect AFTER any current recruiting periods."}
if("typing_indicator")
typing_indicator = !typing_indicator
if ("chat_on_map")
chat_on_map = !chat_on_map
if ("mob_chat_on_map")
mob_chat_on_map = !mob_chat_on_map
if ("obj_chat_on_map")
obj_chat_on_map = !obj_chat_on_map
if ("max_chat_length")
max_chat_length = input(user, "Choose the max character length of shown Runechat messages. Valid range is 1 to [CHAT_MESSAGE_MAX_LENGTH] (default: [initial(max_chat_length)]))", "Character Preference", max_chat_length) as null|num
if ("see_chat_non_mob")
see_chat_non_mob = !see_chat_non_mob
if ("no_goonchat_for_obj")
no_goonchat_for_obj = !no_goonchat_for_obj
if(user.client.holder)
switch(href_list["preference"])

View File

@@ -137,9 +137,10 @@
window_flashing = sanitize_integer(window_flashing, 0, 1, initial(window_flashing))
antag_objectives = sanitize_integer(antag_objectives, 0, 1, initial(antag_objectives))
typing_indicator = sanitize_integer(typing_indicator, 0, 1, initial(typing_indicator))
chat_on_map = sanitize_integer(chat_on_map, 0, 1, initial(chat_on_map))
mob_chat_on_map = sanitize_integer(mob_chat_on_map, 0, 1, initial(mob_chat_on_map))
max_chat_length = sanitize_integer(max_chat_length, 0, CHAT_MESSAGE_MAX_LENGTH, initial(typing_indicator))
see_chat_non_mob = sanitize_integer(see_chat_non_mob, 0, 1, initial(see_chat_non_mob))
obj_chat_on_map = sanitize_integer(obj_chat_on_map, 0, 1, initial(obj_chat_on_map))
no_goonchat_for_obj = sanitize_integer(no_goonchat_for_obj, 0, 1, initial(no_goonchat_for_obj))
initialize_preferences()
return 1
@@ -221,15 +222,15 @@
check.Add("SELECT ckey FROM client WHERE ckey = ?", ckey)
if(check.Execute(db))
if(!check.NextRow())
q.Add("INSERT into client (ckey, ooc_color, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, chat_on_map, max_chat_length, see_chat_non_mob) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",\
ckey, ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, chat_on_map, max_chat_length, see_chat_non_mob)
q.Add("INSERT into client (ckey, ooc_color, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map, no_goonchat_for_obj) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?)",\
ckey, ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map, no_goonchat_for_obj)
if(!q.Execute(db))
message_admins("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #: [q.Error()] - [q.ErrorMsg()]")
WARNING("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #:[q.Error()] - [q.ErrorMsg()]")
return 0
else
q.Add("UPDATE client SET ooc_color=?,lastchangelog=?,UI_style=?,default_slot=?,toggles=?,UI_style_color=?,UI_style_alpha=?,warns=?,warnbans=?,randomslot=?,volume=?,usewmp=?,special=?,usenanoui=?,tooltips=?,progress_bars=?,space_parallax=?,space_dust=?,parallax_speed=?, stumble=?, attack_animation=?, pulltoggle=?, credits=?, jingle=?, hear_voicesound=?, hear_instruments=?, ambience_volume=?, credits_volume=?, window_flashing=?, antag_objectives=? , typing_indicator=? , chat_on_map=? , max_chat_length=?, see_chat_non_mob=?, WHERE ckey = ?",\
ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, chat_on_map, max_chat_length, see_chat_non_mob, ckey)
q.Add("UPDATE client SET ooc_color=?,lastchangelog=?,UI_style=?,default_slot=?,toggles=?,UI_style_color=?,UI_style_alpha=?,warns=?,warnbans=?,randomslot=?,volume=?,usewmp=?,special=?,usenanoui=?,tooltips=?,progress_bars=?,space_parallax=?,space_dust=?,parallax_speed=?, stumble=?, attack_animation=?, pulltoggle=?, credits=?, jingle=?, hear_voicesound=?, hear_instruments=?, ambience_volume=?, credits_volume=?, window_flashing=?, antag_objectives=? , typing_indicator=? , mob_chat_on_map=? , max_chat_length=?, obj_chat_on_map=?, no_goonchat_for_obj=?, WHERE ckey = ?",\
ooccolor, lastchangelog, UI_style, default_slot, toggles, UI_style_color, UI_style_alpha, warns, warnbans, randomslot, volume, usewmp, special_popup, usenanoui, tooltips, progress_bars, space_parallax, space_dust, parallax_speed, stumble, attack_animation, pulltoggle, credits, jingle, hear_voicesound, hear_instruments, ambience_volume, credits_volume, window_flashing, antag_objectives, typing_indicator, mob_chat_on_map, max_chat_length, obj_chat_on_map,no_goonchat_for_obj, ckey)
if(!q.Execute(db))
message_admins("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #: [q.Error()] - [q.ErrorMsg()]")
WARNING("Error in save_preferences_sqlite [__FILE__] ln:[__LINE__] #:[q.Error()] - [q.ErrorMsg()]")
@@ -279,9 +280,10 @@
S["window_flashing"]<< window_flashing
S["antag_objectives"]<< antag_objectives
S["typing_indicator"]<< typing_indicator
S["chat_on_map"] << chat_on_map
S["mob_chat_on_map"] << mob_chat_on_map
S["max_chat_length"] << max_chat_length
S["see_chat_non_mob"] << see_chat_non_mob
S["obj_chat_on_map"] << obj_chat_on_map
S["no_goonchat_for_obj"] << no_goonchat_for_obj
return 1
//saving volume changes

View File

@@ -6,22 +6,26 @@
var/mig1
var/mig2
var/mig3
if(!hasColumn("client","chat_on_map"))
mig1 = execute("ALTER TABLE `client` ADD COLUMN chat_on_map INTEGER DEFAULT 0")
if(!hasColumn("client","mob_chat_on_map"))
mig1 = execute("ALTER TABLE `client` ADD COLUMN mob_chat_on_map INTEGER DEFAULT 0")
if(!hasColumn("client","max_chat_length"))
mig2 = execute("ALTER TABLE `client` ADD COLUMN max_chat_length INTEGER DEFAULT [CHAT_MESSAGE_MAX_LENGTH]")
if(!hasColumn("client","see_chat_non_mob"))
mig3 = execute("ALTER TABLE `client` ADD COLUMN see_chat_non_mob INTEGER DEFAULT 0")
return mig1 && mig2 && mig3
if(!hasColumn("client","obj_chat_on_map"))
mig3 = execute("ALTER TABLE `client` ADD COLUMN obj_chat_on_map INTEGER DEFAULT 0")
if(!hasColumn("client","no_goonchat_for_obj"))
mig4 = execute("ALTER TABLE `client` ADD COLUMN no_goonchat_for_obj INTEGER DEFAULT 0")
return mig1 && mig2 && mig3 && mig4
/datum/migration/sqlite/ss13_prefs/_023/down()
var/mig1
var/mig2
var/mig3
if(hasColumn("client","chat_on_map"))
mig1 = execute("ALTER TABLE `client` DROP COLUMN chat_on_map")
if(hasColumn("client","mob_chat_on_map"))
mig1 = execute("ALTER TABLE `client` DROP COLUMN mob_chat_on_map")
if(hasColumn("client","obj_chat_on_map"))
mig2 = execute("ALTER TABLE `client` DROP COLUMN obj_chat_on_map")
if(hasColumn("client","max_chat_length"))
mig2 = execute("ALTER TABLE `client` DROP COLUMN max_chat_length")
if(hasColumn("client","see_chat_non_mob"))
mig3 = execute("ALTER TABLE `client` DROP COLUMN see_chat_non_mob")
return mig1 && mig2 && mig3
mig3 = execute("ALTER TABLE `client` DROP COLUMN max_chat_length")
if(hasColumn("client","no_goonchat_for_obj"))
mig4 = execute("ALTER TABLE `client` DROP COLUMN no_goonchat_for_obj")
return mig1 && mig2 && mig3 && mig4

View File

@@ -45,7 +45,7 @@
if ((client.prefs.toggles & CHAT_GHOSTRADIO) != CHAT_GHOSTRADIO)
say_testing(src, "/mob/dead/observer/Hear(): CHAT_GHOSTRADIO is disabled, blocking. ([client.prefs.toggles] & [CHAT_GHOSTRADIO]) = [client.prefs.toggles & CHAT_GHOSTRADIO]")
return
if (client?.prefs.chat_on_map && (client.prefs.see_chat_non_mob || ismob(speech.speaker)))
if (client?.prefs.mob_chat_on_map && (client.prefs.obj_chat_on_map || ismob(speech.speaker)))
create_chat_message(speech.speaker, speech.language, speech.message, speech.mode)
to_chat(src, "<a href='?src=\ref[src];follow=\ref[source]'>(Follow)</a> [rendered_speech]")

View File

@@ -261,9 +261,16 @@ var/list/department_radio_keys = list(
rendered_message = replacetextEx(rendered_message, "AI", "<i style='color: blue;'>AI</i>")
rendered_message = replacetext(rendered_message, ai.real_name, "<i style='color: blue;'>[ai.real_name]</i>")
show_message(rendered_message, type, deaf_message, deaf_type, src)
if (client?.prefs.chat_on_map && stat != UNCONSCIOUS && (client.prefs.see_chat_non_mob || ismob(speech.speaker)) && !is_deaf())
// Runechat messages
if (ismob(speech.speaker) && client?.prefs.mob_chat_on_map && stat != UNCONSCIOUS && !is_deaf())
create_chat_message(speech.speaker, speech.language, speech.message, speech.mode)
else if (client?.prefs.obj_chat_on_map && stat != UNCONSCIOUS && !is_deaf())
create_chat_message(speech.speaker, speech.language, speech.message, speech.mode)
if (ismob(speech.speaker))
show_message(rendered_message, type, deaf_message, deaf_type, src)
else if (!client.prefs.no_goonchat_for_obj || legnthtext(speech.message) > client?.prefs.max_chat_length) // Objects : only display if no goonchat on map or if the runemessage is too small.
show_message(rendered_message, type, deaf_message, deaf_type, src)
return rendered_message
/mob/living/proc/hear_radio_only()