Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix atom name/desc not copying on appearance set #2145

Merged
10 changes: 10 additions & 0 deletions Content.IntegrationTests/DMProject/Tests/atom_appearance.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/obj/thingtocopy
name = "hello"
desc = "this is a thing"

/proc/test_appearance()
var/obj/thingtocopy/T = new()
var/obj/otherthing = new()
otherthing.appearance = T.appearance
ASSERT(otherthing.name == T.name)
ASSERT(otherthing.desc == T.desc)
13 changes: 13 additions & 0 deletions Content.IntegrationTests/DMProject/Tests/string_interpolation.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/obj/blombo
name = "Blombo"
gender = FEMALE

/obj/blorpo
name = "Blorpo"
gender = MALE

/proc/test_string_interpolation()
var/obj/blombo/b = new
var/obj/blorpo/b2 = new
var/result_text = "[b]? Nobody likes \him. \He is awful! Unlike [b2]. \He is pretty cool!"
ASSERT(result_text == "Blombo? Nobody likes her. She is awful! Unlike Blorpo. He is pretty cool!")
2 changes: 2 additions & 0 deletions Content.IntegrationTests/DMProject/code.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
test_color_matrix()
test_range()
test_verb_duplicate()
test_appearance()
test_nonlocal_var()
test_images()
test_filter_init()
test_string_interpolation()
world.log << "IntegrationTests successful, /world/New() exiting..."
2 changes: 2 additions & 0 deletions Content.IntegrationTests/DMProject/environment.dme
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include "code.dm"
#include "Tests/atom_appearance.dm"
#include "Tests/block.dm"
#include "Tests/color_matrix.dm"
#include "Tests/range.dm"
#include "Tests/verb_duplicate.dm"
#include "Tests/nonlocal_var.dm"
#include "Tests/image.dm"
#include "Tests/filter_initial.dm"
#include "Tests/string_interpolation.dm"
#include "map.dmm"
#include "interface.dmf"
14 changes: 8 additions & 6 deletions Content.Tests/DMProject/Tests/Preprocessor/macro_newline_var.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/datum/var/name

#define DEFINE_FLOORS(_PATH, _VARS) \
/obj/simulated/floor/_PATH{_VARS};\
/obj/unsimulated/floor/_PATH{_VARS};\
/obj/simulated/floor/airless/_PATH{_VARS};\
/obj/unsimulated/floor/airless/_PATH{_VARS};
/datum/simulated/floor/_PATH{_VARS};\
/datum/unsimulated/floor/_PATH{_VARS};\
/datum/simulated/floor/airless/_PATH{_VARS};\
/datum/unsimulated/floor/airless/_PATH{_VARS};

var/list/gvars_datum_init_order = list()

Expand Down Expand Up @@ -42,8 +44,8 @@ proc/RunTest()
ASSERT(test.len == 4)
InitGlobaltest2()
ASSERT(test2.len == 2)
var/obj/simulated/floor/carpet/regalcarpet/C1 = new()
var/obj/simulated/floor/carpet/regalcarpet/border/C2 = new()
var/datum/simulated/floor/carpet/regalcarpet/C1 = new()
var/datum/simulated/floor/carpet/regalcarpet/border/C2 = new()
ASSERT(C1.name == "regal carpet")
ASSERT(C2.name == "regal carpet border")

12 changes: 7 additions & 5 deletions Content.Tests/DMProject/Tests/Preprocessor/macro_numeric_path.dm
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/obj/thing_1/dodaa
/datum/var/name

/datum/thing_1/dodaa
name = "underscore 1 test"

#define NUMPATH_OBJDEF(num) /obj/thing_##num/name = #num
#define NUMPATH_OBJDEF(num) /datum/thing_##num/name = #num

NUMPATH_OBJDEF(4)
NUMPATH_OBJDEF(stuff)

/proc/RunTest()
var/obj/thing_1/dodaa/D = new
var/datum/thing_1/dodaa/D = new
ASSERT(D.name == "underscore 1 test")
var/obj/thing_4/T = new
var/datum/thing_4/T = new
ASSERT(T.name == "4")
var/obj/thing_stuff/Y = new
var/datum/thing_stuff/Y = new
ASSERT(Y.name == "stuff")
6 changes: 3 additions & 3 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation2.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

/obj/blombo
name = "Blombo"
/datum/blombo
var/name = "Blombo"

/proc/RunTest()
var/obj/blombo/b = new
var/datum/blombo/b = new
var/result_text = "Nobody likes [b]!"
ASSERT(result_text == "Nobody likes Blombo!")
31 changes: 20 additions & 11 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation3.dm
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
/datum/test/var/name

/obj/blombo
name = "Blombo"
gender = FEMALE

/obj/blorpo
name = "Blorpo"
gender = MALE
/datum/test/test1
name = ""
/datum/test/test2
name = " " // 3 spaces
/datum/test/test3
name = "\t"

/proc/RunTest()
var/obj/blombo/b = new
var/obj/blorpo/b2 = new
var/result_text = "[b]? Nobody likes \him. \He is awful! Unlike [b2]. \He is pretty cool!"
ASSERT(result_text == "Blombo? Nobody likes her. She is awful! Unlike Blorpo. He is pretty cool!")
var/list/correct = list(
"/datum/test/test1: ",
"/datum/test/test2: ",
"/datum/test/test3: \t"
)
var/i = 1
for (var/T in typesof(/datum/test))
if(T == /datum/test)
continue
var/datum/test/D = new T()
var/true_text = correct[i]
ASSERT(true_text == "[T]: \the [D]")
++i
32 changes: 13 additions & 19 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation4.dm
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/obj/test1
name = ""
/obj/test2
name = " " // 3 spaces
/obj/test3
name = "\t"


/proc/RunTest()
var/list/correct = list(
"/obj/test1: ",
"/obj/test2: ",
"/obj/test3: \t"
)
var/i = 1
for (var/T in typesof(/obj))
if(T == /obj)
continue
var/obj/O = new T()
var/true_text = correct[i]
ASSERT(true_text == "[T]: \the [O]")
++i
var/text = "["1"]\s"
ASSERT(text == "1s")
text = "[0]\s"
ASSERT(text == "0s")
text = "[null]\s"
ASSERT(text == "s")
text = "[1]\s"
ASSERT(text == "1")
text = "[1.00000001]\s"
ASSERT(text == "1")
text = "[1.0001]\s"
ASSERT(text == "1.0001s")
35 changes: 27 additions & 8 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation5.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@


/proc/RunTest()
var/atom/O = new()
O.name = "foo"
O.gender = FEMALE
var/atom/O2 = new
O2.name = "foob"
O2.gender = MALE
var/text = "[O2], \ref[O], \his"
ASSERT(findtextEx(text,", his") != 0)
var/text = "[0]\th"
ASSERT(text == "0th")
text = "[1]\th"
ASSERT(text == "1st")
text = "[2]\th"
ASSERT(text == "2nd")
text = "[3]\th"
ASSERT(text == "3rd")
text = "[4]\th"
ASSERT(text == "4th")
text = "[-1]\th"
ASSERT(text == "-1th")
text = "[4.52]\th"
ASSERT(text == "4th")
text = "the fitness [1.7]\th is a"
ASSERT(text == "the fitness 1st is a")
text = "the fitness [99999999]\th is a"
ASSERT(text == "the fitness 100000000th is a")
text = "[null]\th"
ASSERT(text == "0th")
var/datum/D = new
text = "[D]\th"
ASSERT(text == "0th")
var/foo = "bar"
text = "[foo]\th"
ASSERT(text == "0th")

26 changes: 11 additions & 15 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation6.dm
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@


/proc/RunTest()
var/text = "["1"]\s"
ASSERT(text == "1s")
text = "[0]\s"
ASSERT(text == "0s")
text = "[null]\s"
ASSERT(text == "s")
text = "[1]\s"
ASSERT(text == "1")
text = "[1.00000001]\s"
ASSERT(text == "1")
text = "[1.0001]\s"
ASSERT(text == "1.0001s")
/proc/RunTest()
ASSERT("\roman[1.5]" == "i")
ASSERT("\roman [1.5]" == " i")
ASSERT("\Roman[1.5]" == "I")
ASSERT("\Roman [1.5]" == " I")
ASSERT("\roman shitposts [1]" == " shitposts i")
ASSERT("\roman shitposts [1] \the [2] [3]\s" == " shitposts i 3s")
ASSERT("\roman[1.#INF]" == "")
ASSERT("\roman[-1.#INF]" == "-∞")
ASSERT("\roman [-1.#INF]" == " -∞")
ASSERT("\roman[1.#IND]" == "")
61 changes: 35 additions & 26 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation7.dm
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
/datum/thing
var/name = "thing"

/datum/Thing
var/name = "Thing"

/datum/proper_thing
var/name = "\proper thing"

/datum/plural_things
var/name = "things"
var/gender = PLURAL

/proc/RunTest()
var/text = "[0]\th"
ASSERT(text == "0th")
text = "[1]\th"
ASSERT(text == "1st")
text = "[2]\th"
ASSERT(text == "2nd")
text = "[3]\th"
ASSERT(text == "3rd")
text = "[4]\th"
ASSERT(text == "4th")
text = "[-1]\th"
ASSERT(text == "-1th")
text = "[4.52]\th"
ASSERT(text == "4th")
text = "the fitness [1.7]\th is a"
ASSERT(text == "the fitness 1st is a")
text = "the fitness [99999999]\th is a"
ASSERT(text == "the fitness 100000000th is a")
text = "[null]\th"
ASSERT(text == "0th")
var/datum/D = new
text = "[D]\th"
ASSERT(text == "0th")
var/foo = "bar"
text = "[foo]\th"
ASSERT(text == "0th")
// Lowercase \a on datums
ASSERT("\a [new /datum/thing]" == "a thing")
ASSERT("\a [new /datum/Thing]" == "Thing")
ASSERT("\a [new /datum/proper_thing]" == "thing")
ASSERT("\a [new /datum/plural_things]" == "some things")

// Uppercase \A on datums
ASSERT("\A [new /datum/thing]" == "A thing")
ASSERT("\A [new /datum/Thing]" == "Thing")
ASSERT("\A [new /datum/proper_thing]" == "thing")
ASSERT("\A [new /datum/plural_things]" == "Some things")

// Lowercase \a on strings
ASSERT("\a ["thing"]" == "a thing")
ASSERT("\a ["Thing"]" == "Thing")
ASSERT("\a ["\proper thing"]" == "thing")

// Uppercase \A on strings
ASSERT("\A ["thing"]" == "A thing")
ASSERT("\A ["Thing"]" == "Thing")
ASSERT("\A ["\proper thing"]" == "thing")

// Invalid \a
ASSERT("\a [123]" == "")
ASSERT("\A [123]" == "")
11 changes: 0 additions & 11 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation8.dm

This file was deleted.

39 changes: 0 additions & 39 deletions Content.Tests/DMProject/Tests/Text/StringInterpolation9.dm

This file was deleted.

1 change: 1 addition & 0 deletions OpenDream.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AABB/@EntryIndexedValue">AABB</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RT/@EntryIndexedValue">RT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DM/@EntryIndexedValue">DM</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DMF/@EntryIndexedValue">DMF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DMI/@EntryIndexedValue">DMI</s:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private void Update() {
// Would be nice if we could use ViewVariables instead, but I couldn't find a nice way to do that
// Would be especially nice if we could use VV to make these editable
AddPropertyIfNotDefault("Name", appearance.Name, MutableAppearance.Default.Name);
AddPropertyIfNotDefault("Desc", appearance.Desc, MutableAppearance.Default.Desc);
AddPropertyIfNotDefault("Icon State", appearance.IconState, MutableAppearance.Default.IconState);
AddPropertyIfNotDefault("Direction", appearance.Direction, MutableAppearance.Default.Direction);
AddPropertyIfNotDefault("Inherits Direction", appearance.InheritsDirection, MutableAppearance.Default.InheritsDirection);
Expand Down
4 changes: 3 additions & 1 deletion OpenDreamClient/Rendering/DMISpriteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public override void Shutdown() {
}

private void OnIconSizeChanged(EntityUid uid) {
_entityManager.TryGetComponent<TransformComponent>(uid, out var transform);
if (!_entityManager.TryGetComponent<TransformComponent>(uid, out var transform))
return;

_lookupSystem.FindAndAddToEntityTree(uid, xform: transform);
}

Expand Down
Loading
Loading