DNA2 Bug Fixes - Part 2

We discovered that most of the problems were were having was because of BYOND passing lists (e.g. SE and UI) by-ref instead of the assumed by-val.

This commit adds dna.Clone() and (UI|SE).Copy() where needed.  These should be used where DNA or SE/UI lists are COPIED, otherwise changes made in the reference will affect the real strand.

This change also messes with the gene activation logic.
This commit is contained in:
Rob Nelson
2014-02-06 23:07:35 -08:00
parent a290385e5a
commit 3121e4fb2d
22 changed files with 242 additions and 418 deletions

View File

@@ -119,6 +119,25 @@ var/global/floorIsLava = 0
else
body += "<A href='?src=\ref[src];makeanimal=\ref[M]'>Animalize</A> | "
// DNA2 - Admin Hax
if(iscarbon(M))
body += "<br><br>"
body += "<b>DNA Blocks:</b><br><table border='0'><tr><th>&nbsp;</th><th>1</th><th>2</th><th>3</th><th>4</th><th>5</th>"
var/bname
for(var/block=1;block<=DNA_SE_LENGTH;block++)
if(((block-1)%5)==0)
body += "</tr><tr><th>[block-1]</th>"
bname = assigned_blocks[block]
body += "<td>"
if(bname)
var/bstate=M.dna.GetSEState(block)
var/bcolor="[(bstate)?"#006600":"#ff0000"]"
body += "<A href='?src=\ref[src];togmutate=\ref[M];block=[block]' style='color:[bcolor];'>[bname]</A><sub>[block]</sub>"
else
body += "[block]"
body+="</td>"
body += "</tr></table>"
body += {"<br><br>
<b>Rudimentary transformation:</b><font size=2><br>These transformations only create a new mob type and copy stuff over. They do not take into account MMIs and similar mob-specific things. The buttons in 'Transformations' are preferred, when possible.</font><br>
<A href='?src=\ref[src];simplemake=observer;mob=\ref[M]'>Observer</A> |

View File

@@ -273,7 +273,7 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if(istype(M, /mob/living/carbon/human))
log_admin("[key_name(src)] has made [M.key] a changeling.")
spawn(10)
M.absorbed_dna[M.real_name] = M.dna
M.absorbed_dna[M.real_name] = M.dna.Clone()
M.make_changeling()
if(M.mind)
M.mind.special_role = "Changeling"
@@ -986,3 +986,19 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
usr << list2text(dead_mob_list,",")
if("Clients")
usr << list2text(clients,",")
// DNA2 - Admin Hax
/client/proc/cmd_admin_toggle_block(var/mob/M,var/block)
if(!ticker)
alert("Wait until the game starts")
return
if(istype(M, /mob/living/carbon))
M.dna.SetSEState(block,!M.dna.GetSEState(block))
domutcheck(M,null,MUTCHK_FORCED)
M.update_mutations()
var/state="[M.dna.GetSEState(block)?"on":"off"]"
var/blockname=assigned_blocks[block]
message_admins("[key_name_admin(src)] has toggled [M.key]'s [blockname] block [state]!")
log_admin("[key_name(src)] has toggled [M.key]'s [blockname] block [state]!")
else
alert("Invalid mob")

View File

@@ -447,9 +447,13 @@ Traitors and the like can also be revived with the previous role mostly intact.
if(record_found)//Pull up their name from database records if they did have a mind.
new_character.dna = new()//Let's first give them a new DNA.
new_character.dna.unique_enzymes = record_found.fields["b_dna"]//Enzymes are based on real name but we'll use the record for conformity.
new_character.dna.SE = record_found.fields["enzymes"]//This is the default of enzymes so I think it's safe to go with.
// I HATE BYOND. HATE. HATE. - N3X
var/list/newSE= record_found.fields["enzymes"]
var/list/newUI = record_found.fields["identity"]
new_character.dna.SE = newSE.Copy() //This is the default of enzymes so I think it's safe to go with.
new_character.dna.UpdateSE()
new_character.UpdateAppearance(record_found.fields["identity"])//Now we configure their appearance based on their unique identity, same as with a DNA machine or somesuch.
new_character.UpdateAppearance(newUI.Copy())//Now we configure their appearance based on their unique identity, same as with a DNA machine or somesuch.
else//If they have no records, we just do a random DNA for them, based on their random appearance/savefile.
new_character.dna.ready_dna(new_character)