External Publication
Visit Post

OpenTTD AIs and Game Scripts • Re: nasal demons in action

Transport Tycoon Forums - Index page [Unofficial] March 2, 2026
Source

Yes, if you have a list of objects/arrays, that's really a list of references to those objects/arrays, so copying those list items to a different list will make two distinct lists that contain references to the same objects.

Code:

// Assume list1 contains a 10 objects, and list2 is empty// Also assume all the items in list1 are objects that have a property named "a", which are all initialized to 0.list2.AddList(list1);// list2 now contains the same items as list1list1.RemoveItem(0);list2.RemoveItem(1);// list1 and list2 have the same number of items, but different items are missing from eachlist1[3].a = 123;list2[4].a = 234;if (list2[3].a == 123 && list1[4].a == 234) { // This will be true because the items in list1 and list2 reference the same objects}

Statistics: Posted by jfs — 02 Mar 2026 11:05


Discussion in the ATmosphere

Loading comments...