Skip to content

Commit

Permalink
Latejoin asset sending for tacmaps
Browse files Browse the repository at this point in the history
Minor refactoring
  • Loading branch information
Drulikar committed Oct 16, 2023
1 parent 942ae03 commit 57fce31
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 20 deletions.
30 changes: 30 additions & 0 deletions code/controllers/subsystem/minimap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,36 @@ SUBSYSTEM_DEF(minimaps)

return map_list[map_length]

/**
* Sends relevant flattened tacmaps to a late joiner.
*
* Arguments:
* * user: The mob that is either an observer, marine, or xeno
*/
/datum/proc/send_tacmap_assets_latejoin(mob/user)
if(!user.client)
return

var/is_observer = user.faction == FACTION_NEUTRAL && isobserver(user)
if(is_observer || user.faction == FACTION_MARINE)
// Send marine maps
var/datum/flattend_tacmap/latest = get_tacmap_data_png(FACTION_MARINE)
if(latest)
SSassets.transport.send_assets(user.client, latest.asset_key)
var/datum/flattend_tacmap/unannounced = get_unannounced_tacmap_data_png(FACTION_MARINE)
if(unannounced && (!latest || latest.asset_key != unannounced.asset_key))
SSassets.transport.send_assets(user.client, unannounced.asset_key)

var/mob/living/carbon/xenomorph/xeno = user
if(is_observer || istype(xeno) && xeno.hivenumber == XENO_HIVE_NORMAL)
// Send xeno maps
var/datum/flattend_tacmap/latest = get_tacmap_data_png(XENO_HIVE_NORMAL)
if(latest)
SSassets.transport.send_assets(user.client, latest.asset_key)
var/datum/flattend_tacmap/unannounced = get_unannounced_tacmap_data_png(XENO_HIVE_NORMAL)
if(unannounced && (!latest || latest.asset_key != unannounced.asset_key))
SSassets.transport.send_assets(user.client, unannounced.asset_key)

/**
* Flattens the current map and then distributes it for the specified faction as an unannounced map.
*
Expand Down
28 changes: 14 additions & 14 deletions code/game/gamemodes/cm_initialize.dm
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ Additional game mode variables.
for(var/mob_name in picked_hive.banished_ckeys)
if(picked_hive.banished_ckeys[mob_name] == xeno_candidate.ckey)
to_chat(xeno_candidate, SPAN_WARNING("You are banished from the [picked_hive], you may not rejoin unless the Queen re-admits you or dies."))
return
return FALSE
if(isnewplayer(xeno_candidate))
var/mob/new_player/noob = xeno_candidate
noob.close_spawn_windows()
Expand All @@ -443,9 +443,6 @@ Additional game mode variables.
return FALSE
new_xeno = userInput

if(!xeno_candidate)
return FALSE

if(!(new_xeno in GLOB.living_xeno_list) || new_xeno.stat == DEAD)
to_chat(xeno_candidate, SPAN_WARNING("You cannot join if the xenomorph is dead."))
return FALSE
Expand Down Expand Up @@ -479,14 +476,14 @@ Additional game mode variables.
else new_xeno = pick(available_xenos_non_ssd) //Just picks something at random.
if(istype(new_xeno) && xeno_candidate && xeno_candidate.client)
if(isnewplayer(xeno_candidate))
var/mob/new_player/N = xeno_candidate
N.close_spawn_windows()
var/mob/new_player/noob = xeno_candidate
noob.close_spawn_windows()
for(var/mob_name in new_xeno.hive.banished_ckeys)
if(new_xeno.hive.banished_ckeys[mob_name] == xeno_candidate.ckey)
to_chat(xeno_candidate, SPAN_WARNING("You are banished from this hive, You may not rejoin unless the Queen re-admits you or dies."))
return
return FALSE
if(transfer_xeno(xeno_candidate, new_xeno))
return 1
return TRUE
to_chat(xeno_candidate, "JAS01: Something went wrong, tell a coder.")

/datum/game_mode/proc/attempt_to_join_as_facehugger(mob/xeno_candidate)
Expand Down Expand Up @@ -614,20 +611,21 @@ Additional game mode variables.
/datum/game_mode/proc/transfer_xeno(xeno_candidate, mob/living/new_xeno)
if(!xeno_candidate || !isxeno(new_xeno) || QDELETED(new_xeno))
return FALSE

var/datum/mind/xeno_candidate_mind
if(ismind(xeno_candidate))
xeno_candidate_mind = xeno_candidate
else if(ismob(xeno_candidate))
var/mob/M = xeno_candidate
if(M.mind)
xeno_candidate_mind = M.mind
var/mob/xeno_candidate_mob = xeno_candidate
if(xeno_candidate_mob.mind)
xeno_candidate_mind = xeno_candidate_mob.mind
else
xeno_candidate_mind = new /datum/mind(M.key, M.ckey)
xeno_candidate_mind = new /datum/mind(xeno_candidate_mob.key, xeno_candidate_mob.ckey)
xeno_candidate_mind.active = TRUE
xeno_candidate_mind.current = new_xeno
else if(isclient(xeno_candidate))
var/client/C = xeno_candidate
xeno_candidate_mind = new /datum/mind(C.key, C.ckey)
var/client/xeno_candidate_client = xeno_candidate
xeno_candidate_mind = new /datum/mind(xeno_candidate_client.key, xeno_candidate_client.ckey)
xeno_candidate_mind.active = TRUE
xeno_candidate_mind.current = new_xeno
else
Expand All @@ -645,6 +643,8 @@ Additional game mode variables.
SSround_recording.recorder.update_key(new_xeno)
if(new_xeno.client)
new_xeno.client.change_view(world_view_size)
if(isnewplayer(xeno_candidate))
send_tacmap_assets_latejoin(new_xeno)

msg_admin_niche("[new_xeno.key] has joined as [new_xeno].")
if(isxeno(new_xeno)) //Dear lord
Expand Down
2 changes: 1 addition & 1 deletion code/modules/cm_aliens/structures/special/pylon_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
to_chat(new_xeno, SPAN_XENOANNOUNCE("You are a xenomorph larva awakened from slumber!"))
playsound(new_xeno, 'sound/effects/xeno_newlarva.ogg', 50, 1)
if(new_xeno.client)
if(new_xeno.client?.prefs.toggles_flashing & FLASH_POOLSPAWN)
if(new_xeno.client.prefs.toggles_flashing & FLASH_POOLSPAWN)
window_flash(new_xeno.client)

linked_hive.stored_larva--
Expand Down
12 changes: 7 additions & 5 deletions code/modules/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@

if(observer.client)
observer.client.change_view(world_view_size)
send_tacmap_assets_latejoin(observer)

observer.set_huds_from_prefs()

qdel(src)
return 1
return TRUE

if("late_join")

Expand Down Expand Up @@ -276,11 +277,12 @@
if(player.get_playtime(STATISTIC_HUMAN) == 0 && player.get_playtime(STATISTIC_XENO) == 0)
msg_admin_niche("NEW JOIN: <b>[key_name(character, 1, 1, 0)]</b>. IP: [character.lastKnownIP], CID: [character.computer_id]")
if(character.client)
var/client/C = character.client
if(C.player_data && C.player_data.playtime_loaded && length(C.player_data.playtimes) == 0)
var/client/client = character.client
if(client.player_data && client.player_data.playtime_loaded && length(client.player_data.playtimes) == 0)
msg_admin_niche("NEW PLAYER: <b>[key_name(character, 1, 1, 0)]</b>. IP: [character.lastKnownIP], CID: [character.computer_id]")
if(C.player_data && C.player_data.playtime_loaded && ((round(C.get_total_human_playtime() DECISECONDS_TO_HOURS, 0.1)) <= 5))
msg_sea("NEW PLAYER: <b>[key_name(character, 0, 1, 0)]</b> only has [(round(C.get_total_human_playtime() DECISECONDS_TO_HOURS, 0.1))] hours as a human. Current role: [get_actual_job_name(character)] - Current location: [get_area(character)]")
if(client.player_data && client.player_data.playtime_loaded && ((round(client.get_total_human_playtime() DECISECONDS_TO_HOURS, 0.1)) <= 5))
msg_sea("NEW PLAYER: <b>[key_name(character, 0, 1, 0)]</b> only has [(round(client.get_total_human_playtime() DECISECONDS_TO_HOURS, 0.1))] hours as a human. Current role: [get_actual_job_name(character)] - Current location: [get_area(character)]")
send_tacmap_assets_latejoin(character)

character.client.init_verbs()
qdel(src)
Expand Down

0 comments on commit 57fce31

Please sign in to comment.