mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Merge pull request #373 from yogstation13/upstream-merge-37167
[MIRROR] Changes ntnet address assignment from numerical ascending to 16 hexadecimal randomized seeded (in English, everything is now randomized instead of predictable)
This commit is contained in:
@@ -9,6 +9,7 @@ PROCESSING_SUBSYSTEM_DEF(networks)
|
||||
var/assignment_hardware_id = HID_RESTRICTED_END
|
||||
var/list/networks_by_id = list() //id = network
|
||||
var/list/interfaces_by_id = list() //hardware id = component interface
|
||||
var/resolve_collisions = TRUE
|
||||
|
||||
/datum/controller/subsystem/processing/networks/Initialize()
|
||||
station_network = new
|
||||
@@ -34,3 +35,17 @@ PROCESSING_SUBSYSTEM_DEF(networks)
|
||||
/datum/controller/subsystem/processing/networks/proc/unregister_interface(datum/component/ntnet_interface/D)
|
||||
interfaces_by_id -= D.hardware_id
|
||||
return TRUE
|
||||
|
||||
/datum/controller/subsystem/processing/networks/proc/get_next_HID()
|
||||
var/string = "[num2text(assignment_hardware_id++, 12)]"
|
||||
return make_address(string)
|
||||
|
||||
/datum/controller/subsystem/processing/networks/proc/make_address(string)
|
||||
if(!string)
|
||||
return resolve_collisions? make_address("[num2text(rand(HID_RESTRICTED_END, 999999999999), 12)]"):null
|
||||
var/hex = md5(string)
|
||||
if(!hex)
|
||||
return //errored
|
||||
. = "[copytext(hex, 1, 9)]" //16 ^ 8 possibilities I think.
|
||||
if(interfaces_by_id[.])
|
||||
return resolve_collisions? make_address("[num2text(rand(HID_RESTRICTED_END, 999999999999), 12)]"):null
|
||||
|
||||
Reference in New Issue
Block a user